diff --git a/segmentmodel/assets/__vite-browser-external-d053bc6e.js b/segmentmodel/assets/__vite-browser-external-d053bc6e.js new file mode 100644 index 0000000..2cc560c --- /dev/null +++ b/segmentmodel/assets/__vite-browser-external-d053bc6e.js @@ -0,0 +1 @@ +const e={},t=Object.freeze(Object.defineProperty({__proto__:null,default:e},Symbol.toStringTag,{value:"Module"}));export{e as L,t as _}; diff --git a/segmentmodel/assets/_commonjsHelpers-de833af9.js b/segmentmodel/assets/_commonjsHelpers-de833af9.js new file mode 100644 index 0000000..ad4f157 --- /dev/null +++ b/segmentmodel/assets/_commonjsHelpers-de833af9.js @@ -0,0 +1 @@ +var u=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function f(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function l(e){if(e.__esModule)return e;var r=e.default;if(typeof r=="function"){var t=function o(){return this instanceof o?Reflect.construct(r,arguments,this.constructor):r.apply(this,arguments)};t.prototype=r.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(e).forEach(function(o){var n=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(t,o,n.get?n:{enumerable:!0,get:function(){return e[o]}})}),t}export{l as a,u as c,f as g}; diff --git a/segmentmodel/assets/index-234835b1.js b/segmentmodel/assets/index-234835b1.js new file mode 100644 index 0000000..5fc8f86 --- /dev/null +++ b/segmentmodel/assets/index-234835b1.js @@ -0,0 +1 @@ +import{L as Y,u as L,a as X}from"./long-c1fdf4ae.js";import{b as E}from"./index-462333f7.js";import{g as W}from"./_commonjsHelpers-de833af9.js";import{L as R}from"./__vite-browser-external-d053bc6e.js";import{R as k}from"./remoteFile-1948951e.js";import{_ as J,L as K}from"./index-d89cadd6.js";class U{constructor(e,t){this.blockPosition=e,this.dataPosition=t}toString(){return`${this.blockPosition}:${this.dataPosition}`}compareTo(e){return this.blockPosition-e.blockPosition||this.dataPosition-e.dataPosition}static min(...e){let t,n=0;for(;!t;n+=1)t=e[n];for(;n<e.length;n+=1)t.compareTo(e[n])>0&&(t=e[n]);return t}}function y(o,e=0,t=!1){if(t)throw new Error("big-endian virtual file offsets not implemented");return new U(o[e+7]*1099511627776+o[e+6]*4294967296+o[e+5]*16777216+o[e+4]*65536+o[e+3]*256+o[e+2],o[e+1]<<8|o[e])}class z{constructor(e,t,n,r){this.minv=e,this.maxv=t,this.bin=n,this._fetchedSize=r}toUniqueString(){return`${this.minv}..${this.maxv} (bin ${this.bin}, fetchedSize ${this.fetchedSize()})`}toString(){return this.toUniqueString()}compareTo(e){return this.minv.compareTo(e.minv)||this.maxv.compareTo(e.maxv)||this.bin-e.bin}fetchedSize(){return this._fetchedSize!==void 0?this._fetchedSize:this.maxv.blockPosition+65536-this.minv.blockPosition}}function Z(o){return new Promise(e=>setTimeout(e,o))}function ee(o){if(o.greaterThan(Number.MAX_SAFE_INTEGER)||o.lessThan(Number.MIN_SAFE_INTEGER))throw new Error("integer overflow");return o.toNumber()}function te(o){if(o&&o.aborted)if(typeof DOMException>"u"){const e=new Error("aborted");throw e.code="ERR_ABORTED",e}else throw new DOMException("aborted","AbortError")}function ne(o,e){return e.minv.blockPosition-o.maxv.blockPosition<65e3&&e.maxv.blockPosition-o.minv.blockPosition<5e6}function re(o={}){return"aborted"in o?{signal:o}:o}function O(o,e){const t=[];let n;if(o.length===0)return o;o.sort((r,a)=>{const i=r.minv.blockPosition-a.minv.blockPosition;return i===0?r.minv.dataPosition-a.minv.dataPosition:i});for(const r of o)(!e||r.maxv.compareTo(e)>0)&&(n===void 0?(t.push(r),n=r):ne(n,r)?r.maxv.compareTo(n.maxv)>0&&(n.maxv=r.maxv):(t.push(r),n=r));return t}function H(o,e){return{lineCount:ee(Y.fromBytesLE(Array.prototype.slice.call(o,e,e+8),!0))}}function P(o,e){return o?o.compareTo(e)>0?e:o:e}function ae(o,e=t=>t){let t=0,n=0;const r=[],a={};for(let i=0;i<o.length;i+=1)if(!o[i]){if(n<i){let c=o.toString("utf8",n,i);c=e(c),r[t]=c,a[c]=t}n=i+1,t+=1}return{refNameToId:a,refIdToName:r}}class G{constructor({filehandle:e,renameRefSeq:t=n=>n}){this.filehandle=e,this.renameRefSeq=t}}const se=21578050;function ie(o,e){return o-o%e}function oe(o,e){return o-o%e+e}function de(o,e){return e-=1,[[0,0],[1+(o>>26),1+(e>>26)],[9+(o>>23),9+(e>>23)],[73+(o>>20),73+(e>>20)],[585+(o>>17),585+(e>>17)],[4681+(o>>14),4681+(e>>14)]]}class A extends G{async lineCount(e,t){var n,r;return((r=(n=(await this.parse(t)).indices[e])===null||n===void 0?void 0:n.stats)===null||r===void 0?void 0:r.lineCount)||0}async _parse(e){const t=await this.filehandle.readFile(e);if(t.readUInt32LE(0)!==se)throw new Error("Not a BAI file");const n=t.readInt32LE(4),a=((1<<(5+1)*3)-1)/7;let i=8,c;const d=new Array(n);for(let s=0;s<n;s++){const l=t.readInt32LE(i);let u;i+=4;const h={};for(let b=0;b<l;b+=1){const x=t.readUInt32LE(i);if(i+=4,x===a+1)i+=4,u=H(t,i+16),i+=32;else{if(x>a+1)throw new Error("bai index contains too many bins, please use CSI");{const g=t.readInt32LE(i);i+=4;const p=new Array(g);for(let w=0;w<g;w++){const v=y(t,i);i+=8;const S=y(t,i);i+=8,c=P(c,v),p[w]=new z(v,S,x)}h[x]=p}}}const f=t.readInt32LE(i);i+=4;const m=new Array(f);for(let b=0;b<f;b++){const x=y(t,i);i+=8,c=P(c,x),m[b]=x}d[s]={binIndex:h,linearIndex:m,stats:u}}return{bai:!0,firstDataLine:c,maxBlockSize:65536,indices:d,refCount:n}}async indexCov(e,t,n,r={}){const i=t!==void 0,d=(await this.parse(r)).indices[e];if(!d)return[];const{linearIndex:s=[],stats:l}=d;if(s.length===0)return[];const u=n===void 0?(s.length-1)*16384:oe(n,16384),h=t===void 0?0:ie(t,16384),f=i?new Array((u-h)/16384):new Array(s.length-1),m=s[s.length-1].blockPosition;if(u>(s.length-1)*16384)throw new Error("query outside of range of linear index");let b=s[h/16384].blockPosition;for(let x=h/16384,g=0;x<u/16384;x++,g++)f[g]={score:s[x+1].blockPosition-b,start:x*16384,end:x*16384+16384},b=s[x+1].blockPosition;return f.map(x=>({...x,score:x.score*((l==null?void 0:l.lineCount)||0)/m}))}async blocksForRange(e,t,n,r={}){t<0&&(t=0);const a=await this.parse(r);if(!a)return[];const i=a.indices[e];if(!i)return[];const c=de(t,n),d=[];for(const[f,m]of c)for(let b=f;b<=m;b++)if(i.binIndex[b]){const x=i.binIndex[b];for(const g of x)d.push(g)}const s=i.linearIndex.length;let l;const u=Math.min(t>>14,s-1),h=Math.min(n>>14,s-1);for(let f=u;f<=h;++f){const m=i.linearIndex[f];m&&(!l||m.compareTo(l)<0)&&(l=m)}return O(d,l)}async parse(e={}){return this.setupP||(this.setupP=this._parse(e).catch(t=>{throw this.setupP=void 0,t})),this.setupP}async hasRefSeq(e,t={}){var n;return!!(!((n=(await this.parse(t)).indices[e])===null||n===void 0)&&n.binIndex)}}var I=E.Buffer,M=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];typeof Int32Array<"u"&&(M=new Int32Array(M));function j(o){if(I.isBuffer(o))return o;var e=typeof I.alloc=="function"&&typeof I.from=="function";if(typeof o=="number")return e?I.alloc(o):new I(o);if(typeof o=="string")return e?I.from(o):new I(o);throw new Error("input must be buffer, number, or string, received "+typeof o)}function ce(o){var e=j(4);return e.writeInt32BE(o,0),e}function B(o,e){o=j(o),I.isBuffer(e)&&(e=e.readUInt32BE(0));for(var t=~~e^-1,n=0;n<o.length;n++)t=M[(t^o[n])&255]^t>>>8;return t^-1}function F(){return ce(B.apply(null,arguments))}F.signed=function(){return B.apply(null,arguments)};F.unsigned=function(){return B.apply(null,arguments)>>>0};var fe=F;const he=W(fe),le=21582659,ue=38359875;function xe(o,e){return o*2**e}function q(o,e){return Math.floor(o/2**e)}class T extends G{constructor(){super(...arguments),this.maxBinNumber=0,this.depth=0,this.minShift=0}async lineCount(e,t){var n,r;return((r=(n=(await this.parse(t)).indices[e])===null||n===void 0?void 0:n.stats)===null||r===void 0?void 0:r.lineCount)||0}async indexCov(){return[]}parseAuxData(e,t){const n=e.readInt32LE(t),r=n&65536?"zero-based-half-open":"1-based-closed",a={0:"generic",1:"SAM",2:"VCF"}[n&15];if(!a)throw new Error(`invalid Tabix preset format flags ${n}`);const i={ref:e.readInt32LE(t+4),start:e.readInt32LE(t+8),end:e.readInt32LE(t+12)},c=e.readInt32LE(t+16),d=c?String.fromCharCode(c):"",s=e.readInt32LE(t+20),l=e.readInt32LE(t+24);return{columnNumbers:i,coordinateType:r,metaValue:c,metaChar:d,skipLines:s,format:a,formatFlags:n,...ae(e.subarray(t+28,t+28+l),this.renameRefSeq)}}async _parse(e){const t=await this.filehandle.readFile(e),n=await L(t);let r;if(n.readUInt32LE(0)===le)r=1;else if(n.readUInt32LE(0)===ue)r=2;else throw new Error("Not a CSI file");this.minShift=n.readInt32LE(4),this.depth=n.readInt32LE(8),this.maxBinNumber=((1<<(this.depth+1)*3)-1)/7;const a=n.readInt32LE(12),i=a>=30?this.parseAuxData(n,16):void 0,c=n.readInt32LE(16+a);let d=16+a+4,s;const l=new Array(c);for(let u=0;u<c;u++){const h=n.readInt32LE(d);d+=4;const f={};let m;for(let b=0;b<h;b++){const x=n.readUInt32LE(d);if(d+=4,x>this.maxBinNumber)m=H(n,d+28),d+=28+16;else{s=P(s,y(n,d)),d+=8;const g=n.readInt32LE(d);d+=4;const p=new Array(g);for(let w=0;w<g;w+=1){const v=y(n,d);d+=8;const S=y(n,d);d+=8,s=P(s,v),p[w]=new z(v,S,x)}f[x]=p}}l[u]={binIndex:f,stats:m}}return{csiVersion:r,firstDataLine:s,indices:l,refCount:c,csi:!0,maxBlockSize:65536,...i}}async blocksForRange(e,t,n,r={}){t<0&&(t=0);const a=await this.parse(r),i=a==null?void 0:a.indices[e];if(!i)return[];const c=this.reg2bins(t,n);if(c.length===0)return[];const d=[];for(const[s,l]of c)for(let u=s;u<=l;u++)if(i.binIndex[u]){const h=i.binIndex[u];for(const f of h)d.push(f)}return O(d,new U(0,0))}reg2bins(e,t){e-=1,e<1&&(e=1),t>2**50&&(t=2**34),t-=1;let n=0,r=0,a=this.minShift+this.depth*3;const i=[];for(;n<=this.depth;a-=3,r+=xe(1,n*3),n+=1){const c=r+q(e,a),d=r+q(t,a);if(d-c+i.length>this.maxBinNumber)throw new Error(`query ${e}-${t} is too large for current binning scheme (shift ${this.minShift}, depth ${this.depth}), try a smaller query or a coarser index binning scheme`);i.push([c,d])}return i}async parse(e={}){return this.setupP||(this.setupP=this._parse(e).catch(t=>{throw this.setupP=void 0,t})),this.setupP}async hasRefSeq(e,t={}){var n;return!!(!((n=(await this.parse(t)).indices[e])===null||n===void 0)&&n.binIndex)}}const _={BAM_FPAIRED:1,BAM_FPROPER_PAIR:2,BAM_FUNMAP:4,BAM_FMUNMAP:8,BAM_FREVERSE:16,BAM_FMREVERSE:32,BAM_FREAD1:64,BAM_FREAD2:128,BAM_FSECONDARY:256,BAM_FQCFAIL:512,BAM_FDUP:1024,BAM_FSUPPLEMENTARY:2048},N="=ACMGRSVTWYHKDBN".split(""),C="MIDNSHP=X???????".split("");class be{constructor(e){this.data={},this._tagList=[],this._allTagsParsed=!1;const{bytes:t,fileOffset:n}=e,{byteArray:r,start:a}=t;this.data={},this.bytes=t,this._id=n,this._refID=r.readInt32LE(a+4),this.data.start=r.readInt32LE(a+8),this.flags=(r.readInt32LE(a+16)&4294901760)>>16}get(e){return this[e]?this.data[e]?this.data[e]:(this.data[e]=this[e](),this.data[e]):this._get(e.toLowerCase())}end(){return this.get("start")+this.get("length_on_ref")}seq_id(){return this._refID}_get(e){return e in this.data?this.data[e]:(this.data[e]=this._parseTag(e),this.data[e])}_tags(){this._parseAllTags();let e=["seq"];this.isSegmentUnmapped()||e.push("start","end","strand","score","qual","MQ","CIGAR","length_on_ref","template_length"),this.isPaired()&&e.push("next_segment_position","pair_orientation"),e=e.concat(this._tagList||[]);for(const n of Object.keys(this.data))n[0]!=="_"&&n!=="next_seq_id"&&e.push(n);const t={};return e.filter(n=>{if(n in this.data&&this.data[n]===void 0||n==="CG"||n==="cg")return!1;const r=n.toLowerCase(),a=t[r];return t[r]=!0,!a})}parent(){}children(){return this.get("subfeatures")}id(){return this._id}mq(){const e=(this.get("_bin_mq_nl")&65280)>>8;return e===255?void 0:e}score(){return this.get("mq")}qual(){var e;return(e=this.qualRaw())===null||e===void 0?void 0:e.join(" ")}qualRaw(){if(this.isSegmentUnmapped())return;const{start:e,byteArray:t}=this.bytes,n=e+36+this.get("_l_read_name")+this.get("_n_cigar_op")*4+this.get("_seq_bytes"),r=this.get("seq_length");return t.subarray(n,n+r)}strand(){return this.isReverseComplemented()?-1:1}multi_segment_next_segment_strand(){if(!this.isMateUnmapped())return this.isMateReverseComplemented()?-1:1}name(){return this.get("_read_name")}_read_name(){const e=this.get("_l_read_name"),{byteArray:t,start:n}=this.bytes;return t.toString("ascii",n+36,n+36+e-1)}_parseTag(e){if(this._allTagsParsed)return;const{byteArray:t,start:n}=this.bytes;let r=this._tagOffset||n+36+this.get("_l_read_name")+this.get("_n_cigar_op")*4+this.get("_seq_bytes")+this.get("seq_length");const a=this.bytes.end;let i;for(;r<a&&i!==e;){const c=String.fromCharCode(t[r],t[r+1]);i=c.toLowerCase();const d=String.fromCharCode(t[r+2]);r+=3;let s;switch(d){case"A":{s=String.fromCharCode(t[r]),r+=1;break}case"i":{s=t.readInt32LE(r),r+=4;break}case"I":{s=t.readUInt32LE(r),r+=4;break}case"c":{s=t.readInt8(r),r+=1;break}case"C":{s=t.readUInt8(r),r+=1;break}case"s":{s=t.readInt16LE(r),r+=2;break}case"S":{s=t.readUInt16LE(r),r+=2;break}case"f":{s=t.readFloatLE(r),r+=4;break}case"Z":case"H":{for(s="";r<=a;){const l=t[r++];if(l===0)break;s+=String.fromCharCode(l)}break}case"B":{s="";const l=t[r++],u=String.fromCharCode(l),h=t.readInt32LE(r);if(r+=4,u==="i")if(c==="CG")for(let f=0;f<h;f++){const m=t.readInt32LE(r),b=m>>4,x=C[m&15];s+=b+x,r+=4}else for(let f=0;f<h;f++)s+=t.readInt32LE(r),f+1<h&&(s+=","),r+=4;if(u==="I")if(c==="CG")for(let f=0;f<h;f++){const m=t.readUInt32LE(r),b=m>>4,x=C[m&15];s+=b+x,r+=4}else for(let f=0;f<h;f++)s+=t.readUInt32LE(r),f+1<h&&(s+=","),r+=4;if(u==="s")for(let f=0;f<h;f++)s+=t.readInt16LE(r),f+1<h&&(s+=","),r+=2;if(u==="S")for(let f=0;f<h;f++)s+=t.readUInt16LE(r),f+1<h&&(s+=","),r+=2;if(u==="c")for(let f=0;f<h;f++)s+=t.readInt8(r),f+1<h&&(s+=","),r+=1;if(u==="C")for(let f=0;f<h;f++)s+=t.readUInt8(r),f+1<h&&(s+=","),r+=1;if(u==="f")for(let f=0;f<h;f++)s+=t.readFloatLE(r),f+1<h&&(s+=","),r+=4;break}default:console.warn(`Unknown BAM tag type '${d}', tags may be incomplete`),s=void 0,r=a}if(this._tagOffset=r,this._tagList.push(c),i===e)return s;this.data[i]=s}this._allTagsParsed=!0}_parseAllTags(){this._parseTag("")}_parseCigar(e){return e.match(/\d+\D/g).map(t=>[t.match(/\D/)[0].toUpperCase(),Number.parseInt(t,10)])}isPaired(){return!!(this.flags&_.BAM_FPAIRED)}isProperlyPaired(){return!!(this.flags&_.BAM_FPROPER_PAIR)}isSegmentUnmapped(){return!!(this.flags&_.BAM_FUNMAP)}isMateUnmapped(){return!!(this.flags&_.BAM_FMUNMAP)}isReverseComplemented(){return!!(this.flags&_.BAM_FREVERSE)}isMateReverseComplemented(){return!!(this.flags&_.BAM_FMREVERSE)}isRead1(){return!!(this.flags&_.BAM_FREAD1)}isRead2(){return!!(this.flags&_.BAM_FREAD2)}isSecondary(){return!!(this.flags&_.BAM_FSECONDARY)}isFailedQc(){return!!(this.flags&_.BAM_FQCFAIL)}isDuplicate(){return!!(this.flags&_.BAM_FDUP)}isSupplementary(){return!!(this.flags&_.BAM_FSUPPLEMENTARY)}cigar(){if(this.isSegmentUnmapped())return;const{byteArray:e,start:t}=this.bytes,n=this.get("_n_cigar_op");let r=t+36+this.get("_l_read_name");const a=this.get("seq_length");let i="",c=0,d=e.readInt32LE(r),s=d>>4,l=C[d&15];if(l==="S"&&s===a)return r+=4,d=e.readInt32LE(r),s=d>>4,l=C[d&15],l!=="N"&&console.warn("CG tag with no N tag"),this.data.length_on_ref=s,this.get("CG");for(let u=0;u<n;++u)d=e.readInt32LE(r),s=d>>4,l=C[d&15],i+=s+l,l!=="H"&&l!=="S"&&l!=="I"&&(c+=s),r+=4;return this.data.length_on_ref=c,i}_flags(){}length_on_ref(){return this.data.length_on_ref?this.data.length_on_ref:(this.get("cigar"),this.data.length_on_ref)}_n_cigar_op(){return this.get("_flag_nc")&65535}_l_read_name(){return this.get("_bin_mq_nl")&255}_seq_bytes(){return this.get("seq_length")+1>>1}getReadBases(){return this.seq()}seq(){const{byteArray:e,start:t}=this.bytes,n=t+36+this.get("_l_read_name")+this.get("_n_cigar_op")*4,r=this.get("_seq_bytes"),a=this.get("seq_length");let i="",c=0;for(let d=0;d<r;++d){const s=e[n+d];i+=N[(s&240)>>4],c++,c<a&&(i+=N[s&15],c++)}return i}getPairOrientation(){if(!this.isSegmentUnmapped()&&!this.isMateUnmapped()&&this._refID===this._next_refid()){const e=this.isReverseComplemented()?"R":"F",t=this.isMateReverseComplemented()?"R":"F";let n=" ",r=" ";this.isRead1()?(n="1",r="2"):this.isRead2()&&(n="2",r="1");const a=[];return this.template_length()>0?(a[0]=e,a[1]=n,a[2]=t,a[3]=r):(a[2]=e,a[3]=n,a[0]=t,a[1]=r),a.join("")}return""}_bin_mq_nl(){return this.bytes.byteArray.readInt32LE(this.bytes.start+12)}_flag_nc(){return this.bytes.byteArray.readInt32LE(this.bytes.start+16)}seq_length(){return this.bytes.byteArray.readInt32LE(this.bytes.start+20)}_next_refid(){return this.bytes.byteArray.readInt32LE(this.bytes.start+24)}_next_pos(){return this.bytes.byteArray.readInt32LE(this.bytes.start+28)}template_length(){return this.bytes.byteArray.readInt32LE(this.bytes.start+32)}toJSON(){const e={};for(const t of Object.keys(this))t.charAt(0)==="_"||t==="bytes"||(e[t]=this[t]);return e}}function V(o){const e=o.split(/\r?\n/),t=[];for(const n of e){const[r,...a]=n.split(/\t/);r&&t.push({tag:r.slice(1),data:a.map(i=>{const[c,d]=i.split(":",2);return{tag:c,value:d}})})}return t}const Q=21840194,D=65536;async function me(o){let e=[];for await(const t of o)e=e.concat(t);return e}class ge{read(){throw new Error("never called")}stat(){throw new Error("never called")}readFile(){throw new Error("never called")}close(){throw new Error("never called")}}class _e{constructor({bamFilehandle:e,bamPath:t,bamUrl:n,baiPath:r,baiFilehandle:a,baiUrl:i,csiPath:c,csiFilehandle:d,csiUrl:s,htsget:l,yieldThreadTime:u=100,renameRefSeqs:h=f=>f}){if(this.htsget=!1,this.featureCache=new J({cache:new K({maxSize:50}),fill:async(f,m)=>{const{chunk:b,opts:x}=f,{data:g,cpositions:p,dpositions:w}=await this._readChunk({chunk:b,opts:{...x,signal:m}});return this.readBamFeatures(g,p,w,b)}}),this.renameRefSeq=h,e)this.bam=e;else if(t)this.bam=new R(t);else if(n)this.bam=new k(n);else if(l)this.htsget=!0,this.bam=new ge;else throw new Error("unable to initialize bam");if(d)this.index=new T({filehandle:d});else if(c)this.index=new T({filehandle:new R(c)});else if(s)this.index=new T({filehandle:new k(s)});else if(a)this.index=new A({filehandle:a});else if(r)this.index=new A({filehandle:new R(r)});else if(i)this.index=new A({filehandle:new k(i)});else if(t)this.index=new A({filehandle:new R(`${t}.bai`)});else if(n)this.index=new A({filehandle:new k(`${n}.bai`)});else if(l)this.htsget=!0;else throw new Error("unable to infer index format");this.yieldThreadTime=u}async getHeaderPre(e){const t=re(e);if(!this.index)return;const n=await this.index.parse(t),r=n.firstDataLine?n.firstDataLine.blockPosition+65535:void 0;let a;if(r){const l=r+D,u=await this.bam.read(E.Buffer.alloc(l),0,l,0,t);if(!u.bytesRead)throw new Error("Error reading header");a=u.buffer.subarray(0,Math.min(u.bytesRead,r))}else a=await this.bam.readFile(t);const i=await L(a);if(i.readInt32LE(0)!==Q)throw new Error("Not a BAM file");const c=i.readInt32LE(4);this.header=i.toString("utf8",8,8+c);const{chrToIndex:d,indexToChr:s}=await this._readRefSeqs(c+8,65535,t);return this.chrToIndex=d,this.indexToChr=s,V(this.header)}getHeader(e){return this.headerP||(this.headerP=this.getHeaderPre(e).catch(t=>{throw this.headerP=void 0,t})),this.headerP}async getHeaderText(e={}){return await this.getHeader(e),this.header}async _readRefSeqs(e,t,n){if(e>t)return this._readRefSeqs(e,t*2,n);const r=t+D,{bytesRead:a,buffer:i}=await this.bam.read(E.Buffer.alloc(r),0,t,0,n);if(!a)throw new Error("Error reading refseqs from header");const c=await L(i.subarray(0,Math.min(a,t))),d=c.readInt32LE(e);let s=e+4;const l={},u=[];for(let h=0;h<d;h+=1){const f=c.readInt32LE(s),m=this.renameRefSeq(c.toString("utf8",s+4,s+4+f-1)),b=c.readInt32LE(s+f+4);if(l[m]=h,u.push({refName:m,length:b}),s=s+8+f,s>c.length)return console.warn(`BAM header is very big. Re-fetching ${t} bytes.`),this._readRefSeqs(e,t*2,n)}return{chrToIndex:l,indexToChr:u}}async getRecordsForRange(e,t,n,r){return me(this.streamRecordsForRange(e,t,n,r))}async*streamRecordsForRange(e,t,n,r){var a;await this.getHeader(r);const i=(a=this.chrToIndex)===null||a===void 0?void 0:a[e];if(i===void 0||!this.index)yield[];else{const c=await this.index.blocksForRange(i,t-1,n,r);yield*this._fetchChunkFeatures(c,i,t,n,r)}}async*_fetchChunkFeatures(e,t,n,r,a={}){const{viewAsPairs:i}=a,c=[];let d=!1;for(const s of e){const l=await this.featureCache.get(s.toString(),{chunk:s,opts:a},a.signal),u=[];for(const h of l)if(h.seq_id()===t)if(h.get("start")>=r){d=!0;break}else h.get("end")>=n&&u.push(h);if(c.push(u),yield u,d)break}te(a.signal),i&&(yield this.fetchPairs(t,c,a))}async fetchPairs(e,t,n){const{pairAcrossChr:r,maxInsertSize:a=2e5}=n,i={},c={};t.map(h=>{const f={};for(const m of h){const b=m.name(),x=m.id();f[b]||(f[b]=0),f[b]++,c[x]=1}for(const[m,b]of Object.entries(f))b===1&&(i[m]=!0)});const d=[];t.map(h=>{for(const f of h){const m=f.name(),b=f.get("start"),x=f._next_pos(),g=f._next_refid();this.index&&i[m]&&(r||g===e&&Math.abs(b-x)<a)&&d.push(this.index.blocksForRange(g,x,x+1,n))}});const s=new Map,l=await Promise.all(d);for(const h of l.flat())s.has(h.toString())||s.set(h.toString(),h);return(await Promise.all([...s.values()].map(async h=>{const{data:f,cpositions:m,dpositions:b,chunk:x}=await this._readChunk({chunk:h,opts:n}),g=[];for(const p of await this.readBamFeatures(f,m,b,x))i[p.get("name")]&&!c[p.id()]&&g.push(p);return g}))).flat()}async _readRegion(e,t,n={}){const{bytesRead:r,buffer:a}=await this.bam.read(E.Buffer.alloc(t),0,t,e,n);return a.subarray(0,Math.min(r,t))}async _readChunk({chunk:e,opts:t}){const n=await this._readRegion(e.minv.blockPosition,e.fetchedSize(),t),{buffer:r,cpositions:a,dpositions:i}=await X(n,e);return{data:r,cpositions:a,dpositions:i,chunk:e}}async readBamFeatures(e,t,n,r){let a=0;const i=[];let c=0,d=+Date.now();for(;a+4<e.length;){const s=e.readInt32LE(a),l=a+4+s-1;if(n){for(;a+r.minv.dataPosition>=n[c++];);c--}if(l<e.length){const u=new be({bytes:{byteArray:e,start:a,end:l},fileOffset:t.length>0?t[c]*256+(a-n[c])+r.minv.dataPosition+1:he.signed(e.slice(a,l))});i.push(u),this.yieldThreadTime&&+Date.now()-d>this.yieldThreadTime&&(await Z(1),d=+Date.now())}a=l+1}return i}async hasRefSeq(e){var t,n;const r=(t=this.chrToIndex)===null||t===void 0?void 0:t[e];return r===void 0?!1:(n=this.index)===null||n===void 0?void 0:n.hasRefSeq(r)}async lineCount(e){var t;const n=(t=this.chrToIndex)===null||t===void 0?void 0:t[e];return n===void 0||!this.index?0:this.index.lineCount(n)}async indexCov(e,t,n){var r;if(!this.index)return[];await this.index.parse();const a=(r=this.chrToIndex)===null||r===void 0?void 0:r[e];return a===void 0?[]:this.index.indexCov(a,t,n)}async blocksForRange(e,t,n,r){var a;if(!this.index)return[];await this.index.parse();const i=(a=this.chrToIndex)===null||a===void 0?void 0:a[e];return i===void 0?[]:this.index.blocksForRange(i,t,n,r)}}async function $(o,e){const t=await Promise.all(o.map(async n=>{const{url:r,headers:a}=n;if(r.startsWith("data:"))return E.Buffer.from(r.split(",")[1],"base64");{const{referer:i,...c}=a,d=await fetch(r,{...e,headers:{...e==null?void 0:e.headers,...c}});if(!d.ok)throw new Error(`HTTP ${d.status} fetching ${r}: ${await d.text()}`);return E.Buffer.from(await d.arrayBuffer())}}));return E.Buffer.concat(await Promise.all(t.map(n=>L(n))))}class Ae extends _e{constructor(e){super({htsget:!0}),this.baseUrl=e.baseUrl,this.trackId=e.trackId}async*streamRecordsForRange(e,t,n,r){var a;const c=`${`${this.baseUrl}/${this.trackId}`}?referenceName=${e}&start=${t}&end=${n}&format=BAM`,d=(a=this.chrToIndex)===null||a===void 0?void 0:a[e];if(d===void 0)yield[];else{const s=await fetch(c,{...r});if(!s.ok)throw new Error(`HTTP ${s.status} fetching ${c}: ${await s.text()}`);const l=await s.json(),u=await $(l.htsget.urls.slice(1),r);yield*this._fetchChunkFeatures([{buffer:u,_fetchedSize:void 0,bin:0,compareTo(){return 0},toUniqueString(){return`${e}_${t}_${n}`},fetchedSize(){return 0},minv:{dataPosition:0,blockPosition:0,compareTo:()=>0},maxv:{dataPosition:Number.MAX_SAFE_INTEGER,blockPosition:0,compareTo:()=>0},toString(){return`${e}_${t}_${n}`}}],d,t,n,r)}}async _readChunk({chunk:e}){if(!e.buffer)throw new Error("expected chunk.buffer in htsget");return{data:e.buffer,cpositions:[],dpositions:[],chunk:e}}async getHeader(e={}){const t=`${this.baseUrl}/${this.trackId}?referenceName=na&class=header`,n=await fetch(t,e);if(!n.ok)throw new Error(`HTTP ${n.status} fetching ${t}: ${await n.text()}`);const r=await n.json(),a=await $(r.htsget.urls,e);if(a.readInt32LE(0)!==Q)throw new Error("Not a BAM file");const i=a.readInt32LE(4),c=a.toString("utf8",8,8+i),d=V(c),s=[],l={},u=d.filter(h=>h.tag==="SQ");for(const[h,f]of u.entries()){let m="",b=0;for(const x of f.data)x.tag==="SN"?m=x.value:x.tag==="LN"&&(b=+x.value);l[m]=h,s[h]={refName:m,length:b}}return this.chrToIndex=l,this.indexToChr=s,d}}export{A as BAI,_e as BamFile,be as BamRecord,T as CSI,Ae as HtsgetFile}; diff --git a/segmentmodel/assets/index-25a06bb0.js b/segmentmodel/assets/index-25a06bb0.js deleted file mode 100644 index 39f6291..0000000 --- a/segmentmodel/assets/index-25a06bb0.js +++ /dev/null @@ -1,477 +0,0 @@ -var DS=Object.defineProperty;var BS=(t,e,n)=>e in t?DS(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var Gt=(t,e,n)=>(BS(t,typeof e!="symbol"?e+"":e,n),n),Qc=(t,e,n)=>{if(!e.has(t))throw TypeError("Cannot "+n)};var re=(t,e,n)=>(Qc(t,e,"read from private field"),n?n.call(t):e.get(t)),ge=(t,e,n)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,n)},qn=(t,e,n,r)=>(Qc(t,e,"write to private field"),r?r.call(t,n):e.set(t,n),n);var lm=(t,e,n,r)=>({set _(i){qn(t,e,i,n)},get _(){return re(t,e,r)}}),se=(t,e,n)=>(Qc(t,e,"access private method"),n);(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const a of i)if(a.type==="childList")for(const o of a.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(i){const a={};return i.integrity&&(a.integrity=i.integrity),i.referrerPolicy&&(a.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?a.credentials="include":i.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function r(i){if(i.ep)return;i.ep=!0;const a=n(i);fetch(i.href,a)}})();/** - * @license - * Copyright 2017 Google LLC - * SPDX-License-Identifier: BSD-3-Clause - */var eh;const Ju=window,oo=Ju.trustedTypes,um=oo?oo.createPolicy("lit-html",{createHTML:t=>t}):void 0,Nd="$lit$",Xr=`lit$${(Math.random()+"").slice(9)}$`,Cw="?"+Xr,NS=`<${Cw}>`,Qi=document,Is=()=>Qi.createComment(""),ks=t=>t===null||typeof t!="object"&&typeof t!="function",Tw=Array.isArray,$S=t=>Tw(t)||typeof(t==null?void 0:t[Symbol.iterator])=="function",th=`[ -\f\r]`,Zo=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,fm=/-->/g,cm=/>/g,Ci=RegExp(`>|${th}(?:([^\\s"'>=/]+)(${th}*=${th}*(?:[^ -\f\r"'\`<>=]|("|')|))|$)`,"g"),hm=/'/g,dm=/"/g,Fw=/^(?:script|style|textarea|title)$/i,OS=t=>(e,...n)=>({_$litType$:t,strings:e,values:n}),ot=OS(1),so=Symbol.for("lit-noChange"),et=Symbol.for("lit-nothing"),pm=new WeakMap,Ni=Qi.createTreeWalker(Qi,129,null,!1);function Iw(t,e){if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return um!==void 0?um.createHTML(e):e}const LS=(t,e)=>{const n=t.length-1,r=[];let i,a=e===2?"<svg>":"",o=Zo;for(let s=0;s<n;s++){const u=t[s];let l,f,c=-1,h=0;for(;h<u.length&&(o.lastIndex=h,f=o.exec(u),f!==null);)h=o.lastIndex,o===Zo?f[1]==="!--"?o=fm:f[1]!==void 0?o=cm:f[2]!==void 0?(Fw.test(f[2])&&(i=RegExp("</"+f[2],"g")),o=Ci):f[3]!==void 0&&(o=Ci):o===Ci?f[0]===">"?(o=i??Zo,c=-1):f[1]===void 0?c=-2:(c=o.lastIndex-f[2].length,l=f[1],o=f[3]===void 0?Ci:f[3]==='"'?dm:hm):o===dm||o===hm?o=Ci:o===fm||o===cm?o=Zo:(o=Ci,i=void 0);const d=o===Ci&&t[s+1].startsWith("/>")?" ":"";a+=o===Zo?u+NS:c>=0?(r.push(l),u.slice(0,c)+Nd+u.slice(c)+Xr+d):u+Xr+(c===-2?(r.push(void 0),s):d)}return[Iw(t,a+(t[n]||"<?>")+(e===2?"</svg>":"")),r]};class Rs{constructor({strings:e,_$litType$:n},r){let i;this.parts=[];let a=0,o=0;const s=e.length-1,u=this.parts,[l,f]=LS(e,n);if(this.el=Rs.createElement(l,r),Ni.currentNode=this.el.content,n===2){const c=this.el.content,h=c.firstChild;h.remove(),c.append(...h.childNodes)}for(;(i=Ni.nextNode())!==null&&u.length<s;){if(i.nodeType===1){if(i.hasAttributes()){const c=[];for(const h of i.getAttributeNames())if(h.endsWith(Nd)||h.startsWith(Xr)){const d=f[o++];if(c.push(h),d!==void 0){const p=i.getAttribute(d.toLowerCase()+Nd).split(Xr),m=/([.?@])?(.*)/.exec(d);u.push({type:1,index:a,name:m[2],strings:p,ctor:m[1]==="."?PS:m[1]==="?"?US:m[1]==="@"?qS:Xf})}else u.push({type:6,index:a})}for(const h of c)i.removeAttribute(h)}if(Fw.test(i.tagName)){const c=i.textContent.split(Xr),h=c.length-1;if(h>0){i.textContent=oo?oo.emptyScript:"";for(let d=0;d<h;d++)i.append(c[d],Is()),Ni.nextNode(),u.push({type:2,index:++a});i.append(c[h],Is())}}}else if(i.nodeType===8)if(i.data===Cw)u.push({type:2,index:a});else{let c=-1;for(;(c=i.data.indexOf(Xr,c+1))!==-1;)u.push({type:7,index:a}),c+=Xr.length-1}a++}}static createElement(e,n){const r=Qi.createElement("template");return r.innerHTML=e,r}}function lo(t,e,n=t,r){var i,a,o,s;if(e===so)return e;let u=r!==void 0?(i=n._$Co)===null||i===void 0?void 0:i[r]:n._$Cl;const l=ks(e)?void 0:e._$litDirective$;return(u==null?void 0:u.constructor)!==l&&((a=u==null?void 0:u._$AO)===null||a===void 0||a.call(u,!1),l===void 0?u=void 0:(u=new l(t),u._$AT(t,n,r)),r!==void 0?((o=(s=n)._$Co)!==null&&o!==void 0?o:s._$Co=[])[r]=u:n._$Cl=u),u!==void 0&&(e=lo(t,u._$AS(t,e.values),u,r)),e}class MS{constructor(e,n){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=n}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){var n;const{el:{content:r},parts:i}=this._$AD,a=((n=e==null?void 0:e.creationScope)!==null&&n!==void 0?n:Qi).importNode(r,!0);Ni.currentNode=a;let o=Ni.nextNode(),s=0,u=0,l=i[0];for(;l!==void 0;){if(s===l.index){let f;l.type===2?f=new rp(o,o.nextSibling,this,e):l.type===1?f=new l.ctor(o,l.name,l.strings,this,e):l.type===6&&(f=new VS(o,this,e)),this._$AV.push(f),l=i[++u]}s!==(l==null?void 0:l.index)&&(o=Ni.nextNode(),s++)}return Ni.currentNode=Qi,a}v(e){let n=0;for(const r of this._$AV)r!==void 0&&(r.strings!==void 0?(r._$AI(e,r,n),n+=r.strings.length-2):r._$AI(e[n])),n++}}let rp=class kw{constructor(e,n,r,i){var a;this.type=2,this._$AH=et,this._$AN=void 0,this._$AA=e,this._$AB=n,this._$AM=r,this.options=i,this._$Cp=(a=i==null?void 0:i.isConnected)===null||a===void 0||a}get _$AU(){var e,n;return(n=(e=this._$AM)===null||e===void 0?void 0:e._$AU)!==null&&n!==void 0?n:this._$Cp}get parentNode(){let e=this._$AA.parentNode;const n=this._$AM;return n!==void 0&&(e==null?void 0:e.nodeType)===11&&(e=n.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,n=this){e=lo(this,e,n),ks(e)?e===et||e==null||e===""?(this._$AH!==et&&this._$AR(),this._$AH=et):e!==this._$AH&&e!==so&&this._(e):e._$litType$!==void 0?this.g(e):e.nodeType!==void 0?this.$(e):$S(e)?this.T(e):this._(e)}k(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}$(e){this._$AH!==e&&(this._$AR(),this._$AH=this.k(e))}_(e){this._$AH!==et&&ks(this._$AH)?this._$AA.nextSibling.data=e:this.$(Qi.createTextNode(e)),this._$AH=e}g(e){var n;const{values:r,_$litType$:i}=e,a=typeof i=="number"?this._$AC(e):(i.el===void 0&&(i.el=Rs.createElement(Iw(i.h,i.h[0]),this.options)),i);if(((n=this._$AH)===null||n===void 0?void 0:n._$AD)===a)this._$AH.v(r);else{const o=new MS(a,this),s=o.u(this.options);o.v(r),this.$(s),this._$AH=o}}_$AC(e){let n=pm.get(e.strings);return n===void 0&&pm.set(e.strings,n=new Rs(e)),n}T(e){Tw(this._$AH)||(this._$AH=[],this._$AR());const n=this._$AH;let r,i=0;for(const a of e)i===n.length?n.push(r=new kw(this.k(Is()),this.k(Is()),this,this.options)):r=n[i],r._$AI(a),i++;i<n.length&&(this._$AR(r&&r._$AB.nextSibling,i),n.length=i)}_$AR(e=this._$AA.nextSibling,n){var r;for((r=this._$AP)===null||r===void 0||r.call(this,!1,!0,n);e&&e!==this._$AB;){const i=e.nextSibling;e.remove(),e=i}}setConnected(e){var n;this._$AM===void 0&&(this._$Cp=e,(n=this._$AP)===null||n===void 0||n.call(this,e))}};class Xf{constructor(e,n,r,i,a){this.type=1,this._$AH=et,this._$AN=void 0,this.element=e,this.name=n,this._$AM=i,this.options=a,r.length>2||r[0]!==""||r[1]!==""?(this._$AH=Array(r.length-1).fill(new String),this.strings=r):this._$AH=et}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(e,n=this,r,i){const a=this.strings;let o=!1;if(a===void 0)e=lo(this,e,n,0),o=!ks(e)||e!==this._$AH&&e!==so,o&&(this._$AH=e);else{const s=e;let u,l;for(e=a[0],u=0;u<a.length-1;u++)l=lo(this,s[r+u],n,u),l===so&&(l=this._$AH[u]),o||(o=!ks(l)||l!==this._$AH[u]),l===et?e=et:e!==et&&(e+=(l??"")+a[u+1]),this._$AH[u]=l}o&&!i&&this.j(e)}j(e){e===et?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}}class PS extends Xf{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===et?void 0:e}}const zS=oo?oo.emptyScript:"";class US extends Xf{constructor(){super(...arguments),this.type=4}j(e){e&&e!==et?this.element.setAttribute(this.name,zS):this.element.removeAttribute(this.name)}}let qS=class extends Xf{constructor(e,n,r,i,a){super(e,n,r,i,a),this.type=5}_$AI(e,n=this){var r;if((e=(r=lo(this,e,n,0))!==null&&r!==void 0?r:et)===so)return;const i=this._$AH,a=e===et&&i!==et||e.capture!==i.capture||e.once!==i.once||e.passive!==i.passive,o=e!==et&&(i===et||a);a&&this.element.removeEventListener(this.name,this,i),o&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){var n,r;typeof this._$AH=="function"?this._$AH.call((r=(n=this.options)===null||n===void 0?void 0:n.host)!==null&&r!==void 0?r:this.element,e):this._$AH.handleEvent(e)}};class VS{constructor(e,n,r){this.element=e,this.type=6,this._$AN=void 0,this._$AM=n,this.options=r}get _$AU(){return this._$AM._$AU}_$AI(e){lo(this,e)}}const gm=Ju.litHtmlPolyfillSupport;gm==null||gm(Rs,rp),((eh=Ju.litHtmlVersions)!==null&&eh!==void 0?eh:Ju.litHtmlVersions=[]).push("2.8.0");const Qu=(t,e,n)=>{var r,i;const a=(r=n==null?void 0:n.renderBefore)!==null&&r!==void 0?r:e;let o=a._$litPart$;if(o===void 0){const s=(i=n==null?void 0:n.renderBefore)!==null&&i!==void 0?i:null;a._$litPart$=o=new rp(e.insertBefore(Is(),s),s,void 0,n??{})}return o._$AI(t),o};/** - * @license - * Copyright 2017 Google LLC - * SPDX-License-Identifier: BSD-3-Clause - */const HS={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},GS=t=>(...e)=>({_$litDirective$:t,values:e});let jS=class{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,n,r){this._$Ct=e,this._$AM=n,this._$Ci=r}_$AS(e,n){return this.update(e,n)}update(e,n){return this.render(...n)}};/** - * @license - * Copyright 2018 Google LLC - * SPDX-License-Identifier: BSD-3-Clause - */const mm=GS(class extends jS{constructor(t){var e;if(super(t),t.type!==HS.ATTRIBUTE||t.name!=="class"||((e=t.strings)===null||e===void 0?void 0:e.length)>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(t){return" "+Object.keys(t).filter(e=>t[e]).join(" ")+" "}update(t,[e]){var n,r;if(this.it===void 0){this.it=new Set,t.strings!==void 0&&(this.nt=new Set(t.strings.join(" ").split(/\s/).filter(a=>a!=="")));for(const a in e)e[a]&&!(!((n=this.nt)===null||n===void 0)&&n.has(a))&&this.it.add(a);return this.render(e)}const i=t.element.classList;this.it.forEach(a=>{a in e||(i.remove(a),this.it.delete(a))});for(const a in e){const o=!!e[a];o===this.it.has(a)||!((r=this.nt)===null||r===void 0)&&r.has(a)||(o?(i.add(a),this.it.add(a)):(i.remove(a),this.it.delete(a)))}return so}});var bm={},uu={},nh=34,Ti=10,fu=13;function Rw(t){return new Function("d","return {"+t.map(function(e,n){return JSON.stringify(e)+": d["+n+'] || ""'}).join(",")+"}")}function WS(t,e){var n=Rw(t);return function(r,i){return e(n(r),i,t)}}function ym(t){var e=Object.create(null),n=[];return t.forEach(function(r){for(var i in r)i in e||n.push(e[i]=i)}),n}function Bt(t,e){var n=t+"",r=n.length;return r<e?new Array(e-r+1).join(0)+n:n}function ZS(t){return t<0?"-"+Bt(-t,6):t>9999?"+"+Bt(t,6):Bt(t,4)}function YS(t){var e=t.getUTCHours(),n=t.getUTCMinutes(),r=t.getUTCSeconds(),i=t.getUTCMilliseconds();return isNaN(t)?"Invalid Date":ZS(t.getUTCFullYear())+"-"+Bt(t.getUTCMonth()+1,2)+"-"+Bt(t.getUTCDate(),2)+(i?"T"+Bt(e,2)+":"+Bt(n,2)+":"+Bt(r,2)+"."+Bt(i,3)+"Z":r?"T"+Bt(e,2)+":"+Bt(n,2)+":"+Bt(r,2)+"Z":n||e?"T"+Bt(e,2)+":"+Bt(n,2)+"Z":"")}function Dw(t,e){var n=new RegExp('["'+t+` -\r]`),r=t.charCodeAt(0);function i(h,d){var p,m,y=a(h,function(w,A){if(p)return p(w,A-1);m=w,p=d?WS(w,d):Rw(w)});return y.columns=m||[],y}function a(h,d){var p=[],m=h.length,y=0,w=0,A,C=m<=0,E=!1,k=!0,R=e?e.comment:void 0;h.charCodeAt(m-1)===Ti&&--m,h.charCodeAt(m-1)===fu&&--m;function I(){if(C)return uu;if(E)return E=!1,k=!0,bm;if(k&&R){for(;;){let J=0;for(;J<R.length&&R.charAt(J)===h.charAt(J+y);)J++;if(J!==R.length)break;for(y+=J;y<m&&(N=h.charCodeAt(y++),N!==Ti);)if(N===fu){h.charCodeAt(y)===Ti&&++y;break}}if(y>=m)return uu}k=!1;var T,B=y,N;if(h.charCodeAt(B)===nh){for(;y++<m&&h.charCodeAt(y)!==nh||h.charCodeAt(++y)===nh;);return(T=y)>=m?C=!0:(N=h.charCodeAt(y++))===Ti?E=!0:N===fu&&(E=!0,h.charCodeAt(y)===Ti&&++y),h.slice(B+1,T-1).replace(/""/g,'"')}for(;y<m;){if((N=h.charCodeAt(T=y++))===Ti)E=!0;else if(N===fu)E=!0,h.charCodeAt(y)===Ti&&++y;else if(N!==r)continue;return h.slice(B,T)}return C=!0,h.slice(B,m)}for(;(A=I())!==uu;){for(var O=[];A!==bm&&A!==uu;)O.push(A),A=I();d&&(O=d(O,w++))==null||p.push(O)}return p}function o(h,d){return h.map(function(p){return d.map(function(m){return c(p[m])}).join(t)})}function s(h,d){return d==null&&(d=ym(h)),[d.map(c).join(t)].concat(o(h,d)).join(` -`)}function u(h,d){return d==null&&(d=ym(h)),o(h,d).join(` -`)}function l(h){return h.map(f).join(` -`)}function f(h){return h.map(c).join(t)}function c(h){return h==null?"":h instanceof Date?YS(h):n.test(h+="")?'"'+h.replace(/"/g,'""')+'"':h}return{parse:i,parseRows:a,format:s,formatBody:u,formatRows:l,formatRow:f,formatValue:c}}var XS=Dw(" "),KS=XS.parseRows;function mi(t,e,n){return t.fields=e||[],t.fname=n,t}function JS(t){return t==null?null:t.fname}function Bw(t){return t==null?null:t.fields}function QS(t){return t.length===1?e3(t[0]):t3(t)}const e3=t=>function(e){return e[t]},t3=t=>{const e=t.length;return function(n){for(let r=0;r<e;++r)n=n[t[r]];return n}};function je(t){throw Error(t)}function n3(t){const e=[],n=t.length;let r=null,i=0,a="",o,s,u;t=t+"";function l(){e.push(a+t.substring(o,s)),a="",o=s+1}for(o=s=0;s<n;++s)if(u=t[s],u==="\\")a+=t.substring(o,s++),o=s;else if(u===r)l(),r=null,i=-1;else{if(r)continue;o===i&&u==='"'||o===i&&u==="'"?(o=s+1,r=u):u==="."&&!i?s>o?l():o=s+1:u==="["?(s>o&&l(),i=o=s+1):u==="]"&&(i||je("Access path missing open bracket: "+t),i>0&&l(),i=0,o=s+1)}return i&&je("Access path missing closing bracket: "+t),r&&je("Access path missing closing quote: "+t),s>o&&(s++,l()),e}function Kf(t,e,n){const r=n3(t);return t=r.length===1?r[0]:t,mi((n&&n.get||QS)(r),[t],e||t)}Kf("id");const Jf=mi(t=>t,[],"identity");mi(()=>0,[],"zero");mi(()=>1,[],"one");mi(()=>!0,[],"true");mi(()=>!1,[],"false");var en=Array.isArray;function Bn(t){return t===Object(t)}function kn(t){return t[t.length-1]}function Ds(t){return t==null||t===""?null:+t}const Nw=t=>e=>t*Math.exp(e),$w=t=>e=>Math.log(t*e),r3=t=>e=>Math.sign(e)*Math.log1p(Math.abs(e/t)),i3=t=>e=>Math.sign(e)*Math.expm1(Math.abs(e))*t,ef=t=>e=>e<0?-Math.pow(-e,t):Math.pow(e,t);function ip(t,e,n,r){const i=n(t[0]),a=n(kn(t)),o=(a-i)*e;return[r(i-o),r(a-o)]}function a3(t,e){return ip(t,e,Ds,Jf)}function o3(t,e){var n=Math.sign(t[0]);return ip(t,e,$w(n),Nw(n))}function s3(t,e,n){return ip(t,e,ef(n),ef(1/n))}function Qf(t,e,n,r,i){const a=r(t[0]),o=r(kn(t)),s=e!=null?r(e):(a+o)/2;return[i(s+(a-s)*n),i(s+(o-s)*n)]}function Ow(t,e,n){return Qf(t,e,n,Ds,Jf)}function Lw(t,e,n){const r=Math.sign(t[0]);return Qf(t,e,n,$w(r),Nw(r))}function $d(t,e,n,r){return Qf(t,e,n,ef(r),ef(1/r))}function l3(t,e,n,r){return Qf(t,e,n,r3(r),i3(r))}function Od(t){return t!=null?en(t)?t:[t]:[]}function u3(t,e,n){let r=t[0],i=t[1],a;return i<r&&(a=i,i=r,r=a),a=i-r,a>=n-e?[e,n]:[r=Math.min(Math.max(r,e),n-a),r+a]}function qt(t){return typeof t=="function"}const f3="descending";function Mw(t,e,n){n=n||{},e=Od(e)||[];const r=[],i=[],a={},o=n.comparator||c3;return Od(t).forEach((s,u)=>{s!=null&&(r.push(e[u]===f3?-1:1),i.push(s=qt(s)?s:Kf(s,null,n)),(Bw(s)||[]).forEach(l=>a[l]=1))}),i.length===0?null:mi(o(i,r),Object.keys(a))}const Pw=(t,e)=>(t<e||t==null)&&e!=null?-1:(t>e||e==null)&&t!=null?1:(e=e instanceof Date?+e:e,(t=t instanceof Date?+t:t)!==t&&e===e?-1:e!==e&&t===t?1:0),c3=(t,e)=>t.length===1?h3(t[0],e[0]):d3(t,e,t.length),h3=(t,e)=>function(n,r){return Pw(t(n),t(r))*e},d3=(t,e,n)=>(e.push(0),function(r,i){let a,o=0,s=-1;for(;o===0&&++s<n;)a=t[s],o=Pw(a(r),a(i));return o*e[s]});function p3(t){return qt(t)?t:()=>t}function ap(t){for(let e,n,r=1,i=arguments.length;r<i;++r){e=arguments[r];for(n in e)t[n]=e[n]}return t}const g3=Object.prototype.hasOwnProperty;function Ma(t,e){return g3.call(t,e)}function ec(t){return typeof t=="boolean"}function m3(t){return Object.prototype.toString.call(t)==="[object Date]"}function b3(t){return t&&qt(t[Symbol.iterator])}function Vt(t){return typeof t=="number"}function We(t){return typeof t=="string"}function y3(t,e){const n=t[0],r=kn(t),i=+e;return i?i===1?r:n+i*(r-n):n}function tf(t){return t&&kn(t)-t[0]||0}function tc(t){return en(t)?"["+t.map(tc)+"]":Bn(t)||We(t)?JSON.stringify(t).replace("\u2028","\\u2028").replace("\u2029","\\u2029"):t}function w3(t){return t==null||t===""?null:!t||t==="false"||t==="0"?!1:!!t}const x3=t=>Vt(t)||m3(t)?t:Date.parse(t);function _3(t,e){return e=e||x3,t==null||t===""?null:e(t)}function v3(t){return t==null||t===""?null:t+""}function nf(t){const e={},n=t.length;for(let r=0;r<n;++r)e[t[r]]=!0;return e}var wm={},rh={},ih=34,Yo=10,ah=13;function zw(t){return new Function("d","return {"+t.map(function(e,n){return JSON.stringify(e)+": d["+n+'] || ""'}).join(",")+"}")}function E3(t,e){var n=zw(t);return function(r,i){return e(n(r),i,t)}}function xm(t){var e=Object.create(null),n=[];return t.forEach(function(r){for(var i in r)i in e||n.push(e[i]=i)}),n}function Nt(t,e){var n=t+"",r=n.length;return r<e?new Array(e-r+1).join(0)+n:n}function A3(t){return t<0?"-"+Nt(-t,6):t>9999?"+"+Nt(t,6):Nt(t,4)}function S3(t){var e=t.getUTCHours(),n=t.getUTCMinutes(),r=t.getUTCSeconds(),i=t.getUTCMilliseconds();return isNaN(t)?"Invalid Date":A3(t.getUTCFullYear())+"-"+Nt(t.getUTCMonth()+1,2)+"-"+Nt(t.getUTCDate(),2)+(i?"T"+Nt(e,2)+":"+Nt(n,2)+":"+Nt(r,2)+"."+Nt(i,3)+"Z":r?"T"+Nt(e,2)+":"+Nt(n,2)+":"+Nt(r,2)+"Z":n||e?"T"+Nt(e,2)+":"+Nt(n,2)+"Z":"")}function C3(t){var e=new RegExp('["'+t+` -\r]`),n=t.charCodeAt(0);function r(c,h){var d,p,m=i(c,function(y,w){if(d)return d(y,w-1);p=y,d=h?E3(y,h):zw(y)});return m.columns=p||[],m}function i(c,h){var d=[],p=c.length,m=0,y=0,w,A=p<=0,C=!1;c.charCodeAt(p-1)===Yo&&--p,c.charCodeAt(p-1)===ah&&--p;function E(){if(A)return rh;if(C)return C=!1,wm;var R,I=m,O;if(c.charCodeAt(I)===ih){for(;m++<p&&c.charCodeAt(m)!==ih||c.charCodeAt(++m)===ih;);return(R=m)>=p?A=!0:(O=c.charCodeAt(m++))===Yo?C=!0:O===ah&&(C=!0,c.charCodeAt(m)===Yo&&++m),c.slice(I+1,R-1).replace(/""/g,'"')}for(;m<p;){if((O=c.charCodeAt(R=m++))===Yo)C=!0;else if(O===ah)C=!0,c.charCodeAt(m)===Yo&&++m;else if(O!==n)continue;return c.slice(I,R)}return A=!0,c.slice(I,p)}for(;(w=E())!==rh;){for(var k=[];w!==wm&&w!==rh;)k.push(w),w=E();h&&(k=h(k,y++))==null||d.push(k)}return d}function a(c,h){return c.map(function(d){return h.map(function(p){return f(d[p])}).join(t)})}function o(c,h){return h==null&&(h=xm(c)),[h.map(f).join(t)].concat(a(c,h)).join(` -`)}function s(c,h){return h==null&&(h=xm(c)),a(c,h).join(` -`)}function u(c){return c.map(l).join(` -`)}function l(c){return c.map(f).join(t)}function f(c){return c==null?"":c instanceof Date?S3(c):e.test(c+="")?'"'+c.replace(/"/g,'""')+'"':c}return{parse:r,parseRows:i,format:o,formatBody:s,formatRows:u,formatRow:l,formatValue:f}}function T3(t){return t}function F3(t){if(t==null)return T3;var e,n,r=t.scale[0],i=t.scale[1],a=t.translate[0],o=t.translate[1];return function(s,u){u||(e=n=0);var l=2,f=s.length,c=new Array(f);for(c[0]=(e+=s[0])*r+a,c[1]=(n+=s[1])*i+o;l<f;)c[l]=s[l],++l;return c}}function I3(t,e){for(var n,r=t.length,i=r-e;i<--r;)n=t[i],t[i++]=t[r],t[r]=n}function k3(t,e){return typeof e=="string"&&(e=t.objects[e]),e.type==="GeometryCollection"?{type:"FeatureCollection",features:e.geometries.map(function(n){return _m(t,n)})}:_m(t,e)}function _m(t,e){var n=e.id,r=e.bbox,i=e.properties==null?{}:e.properties,a=Uw(t,e);return n==null&&r==null?{type:"Feature",properties:i,geometry:a}:r==null?{type:"Feature",id:n,properties:i,geometry:a}:{type:"Feature",id:n,bbox:r,properties:i,geometry:a}}function Uw(t,e){var n=F3(t.transform),r=t.arcs;function i(f,c){c.length&&c.pop();for(var h=r[f<0?~f:f],d=0,p=h.length;d<p;++d)c.push(n(h[d],d));f<0&&I3(c,p)}function a(f){return n(f)}function o(f){for(var c=[],h=0,d=f.length;h<d;++h)i(f[h],c);return c.length<2&&c.push(c[0]),c}function s(f){for(var c=o(f);c.length<4;)c.push(c[0]);return c}function u(f){return f.map(s)}function l(f){var c=f.type,h;switch(c){case"GeometryCollection":return{type:c,geometries:f.geometries.map(l)};case"Point":h=a(f.coordinates);break;case"MultiPoint":h=f.coordinates.map(a);break;case"LineString":h=o(f.arcs);break;case"MultiLineString":h=f.arcs.map(o);break;case"Polygon":h=u(f.arcs);break;case"MultiPolygon":h=f.arcs.map(u);break;default:return null}return{type:c,coordinates:h}}return l(e)}function R3(t,e){var n={},r={},i={},a=[],o=-1;e.forEach(function(l,f){var c=t.arcs[l<0?~l:l],h;c.length<3&&!c[1][0]&&!c[1][1]&&(h=e[++o],e[o]=l,e[f]=h)}),e.forEach(function(l){var f=s(l),c=f[0],h=f[1],d,p;if(d=i[c])if(delete i[d.end],d.push(l),d.end=h,p=r[h]){delete r[p.start];var m=p===d?d:d.concat(p);r[m.start=d.start]=i[m.end=p.end]=m}else r[d.start]=i[d.end]=d;else if(d=r[h])if(delete r[d.start],d.unshift(l),d.start=c,p=i[c]){delete i[p.end];var y=p===d?d:p.concat(d);r[y.start=p.start]=i[y.end=d.end]=y}else r[d.start]=i[d.end]=d;else d=[l],r[d.start=c]=i[d.end=h]=d});function s(l){var f=t.arcs[l<0?~l:l],c=f[0],h;return t.transform?(h=[0,0],f.forEach(function(d){h[0]+=d[0],h[1]+=d[1]})):h=f[f.length-1],l<0?[h,c]:[c,h]}function u(l,f){for(var c in l){var h=l[c];delete f[h.start],delete h.start,delete h.end,h.forEach(function(d){n[d<0?~d:d]=1}),a.push(h)}}return u(i,r),u(r,i),e.forEach(function(l){n[l<0?~l:l]||a.push([l])}),a}function D3(t){return Uw(t,B3.apply(this,arguments))}function B3(t,e,n){var r,i,a;if(arguments.length>1)r=N3(t,e,n);else for(i=0,r=new Array(a=t.arcs.length);i<a;++i)r[i]=i;return{type:"MultiLineString",arcs:R3(t,r)}}function N3(t,e,n){var r=[],i=[],a;function o(c){var h=c<0?~c:c;(i[h]||(i[h]=[])).push({i:c,g:a})}function s(c){c.forEach(o)}function u(c){c.forEach(s)}function l(c){c.forEach(u)}function f(c){switch(a=c,c.type){case"GeometryCollection":c.geometries.forEach(f);break;case"LineString":s(c.arcs);break;case"MultiLineString":case"Polygon":u(c.arcs);break;case"MultiPolygon":l(c.arcs);break}}return f(e),i.forEach(n==null?function(c){r.push(c[0].i)}:function(c){n(c[0].g,c[c.length-1].g)&&r.push(c[0].i)}),r}function ds(t,e){return t==null||e==null?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function $3(t,e){return t==null||e==null?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function nc(t){let e,n,r;t.length!==2?(e=ds,n=(s,u)=>ds(t(s),u),r=(s,u)=>t(s)-u):(e=t===ds||t===$3?t:O3,n=t,r=t);function i(s,u,l=0,f=s.length){if(l<f){if(e(u,u)!==0)return f;do{const c=l+f>>>1;n(s[c],u)<0?l=c+1:f=c}while(l<f)}return l}function a(s,u,l=0,f=s.length){if(l<f){if(e(u,u)!==0)return f;do{const c=l+f>>>1;n(s[c],u)<=0?l=c+1:f=c}while(l<f)}return l}function o(s,u,l=0,f=s.length){const c=i(s,u,l,f-1);return c>l&&r(s[c-1],u)>-r(s[c],u)?c-1:c}return{left:i,center:o,right:a}}function O3(){return 0}function qw(t){return t===null?NaN:+t}const Vw=nc(ds),Ld=Vw.right;Vw.left;nc(qw).center;const ko=Ld;function L3(t,e){let n,r;if(e===void 0)for(const i of t)i!=null&&(n===void 0?i>=i&&(n=r=i):(n>i&&(n=i),r<i&&(r=i)));else{let i=-1;for(let a of t)(a=e(a,++i,t))!=null&&(n===void 0?a>=a&&(n=r=a):(n>a&&(n=a),r<a&&(r=a)))}return[n,r]}class ea extends Map{constructor(e,n=z3){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:n}}),e!=null)for(const[r,i]of e)this.set(r,i)}get(e){return super.get(vm(this,e))}has(e){return super.has(vm(this,e))}set(e,n){return super.set(M3(this,e),n)}delete(e){return super.delete(P3(this,e))}}function vm({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):n}function M3({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):(t.set(r,n),n)}function P3({_intern:t,_key:e},n){const r=e(n);return t.has(r)&&(n=t.get(r),t.delete(r)),n}function z3(t){return t!==null&&typeof t=="object"?t.valueOf():t}function Md(t){return t}function rc(t,...e){return Hw(t,Md,Md,e)}function U3(t,...e){return Hw(t,Array.from,Md,e)}function Hw(t,e,n,r){return function i(a,o){if(o>=r.length)return n(a);const s=new ea,u=r[o++];let l=-1;for(const f of a){const c=u(f,++l,a),h=s.get(c);h?h.push(f):s.set(c,[f])}for(const[f,c]of s)s.set(f,i(c,o));return e(s)}(t,0)}const q3=Math.sqrt(50),V3=Math.sqrt(10),H3=Math.sqrt(2);function rf(t,e,n){const r=(e-t)/Math.max(0,n),i=Math.floor(Math.log10(r)),a=r/Math.pow(10,i),o=a>=q3?10:a>=V3?5:a>=H3?2:1;let s,u,l;return i<0?(l=Math.pow(10,-i)/o,s=Math.round(t*l),u=Math.round(e*l),s/l<t&&++s,u/l>e&&--u,l=-l):(l=Math.pow(10,i)*o,s=Math.round(t/l),u=Math.round(e/l),s*l<t&&++s,u*l>e&&--u),u<s&&.5<=n&&n<2?rf(t,e,n*2):[s,u,l]}function af(t,e,n){if(e=+e,t=+t,n=+n,!(n>0))return[];if(t===e)return[t];const r=e<t,[i,a,o]=r?rf(e,t,n):rf(t,e,n);if(!(a>=i))return[];const s=a-i+1,u=new Array(s);if(r)if(o<0)for(let l=0;l<s;++l)u[l]=(a-l)/-o;else for(let l=0;l<s;++l)u[l]=(a-l)*o;else if(o<0)for(let l=0;l<s;++l)u[l]=(i+l)/-o;else for(let l=0;l<s;++l)u[l]=(i+l)*o;return u}function Pd(t,e,n){return e=+e,t=+t,n=+n,rf(t,e,n)[2]}function ta(t,e,n){e=+e,t=+t,n=+n;const r=e<t,i=r?Pd(e,t,n):Pd(t,e,n);return(r?-1:1)*(i<0?1/-i:i)}function Gw(t,e,n=qw){if(!(!(r=t.length)||isNaN(e=+e))){if(e<=0||r<2)return+n(t[0],0,t);if(e>=1)return+n(t[r-1],r-1,t);var r,i=(r-1)*e,a=Math.floor(i),o=+n(t[a],a,t),s=+n(t[a+1],a+1,t);return o+(s-o)*(i-a)}}function Bs(t,e,n){t=+t,e=+e,n=(i=arguments.length)<2?(e=t,t=0,1):i<3?1:+n;for(var r=-1,i=Math.max(0,Math.ceil((e-t)/n))|0,a=new Array(i);++r<i;)a[r]=t+r*n;return a}function cu(t,e){let n=0;if(e===void 0)for(let r of t)(r=+r)&&(n+=r);else{let r=-1;for(let i of t)(i=+e(i,++r,t))&&(n+=i)}return n}function G3(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)}function of(t,e){if((n=(t=e?t.toExponential(e-1):t.toExponential()).indexOf("e"))<0)return null;var n,r=t.slice(0,n);return[r.length>1?r[0]+r.slice(2):r,+t.slice(n+1)]}function uo(t){return t=of(Math.abs(t)),t?t[1]:NaN}function j3(t,e){return function(n,r){for(var i=n.length,a=[],o=0,s=t[0],u=0;i>0&&s>0&&(u+s+1>r&&(s=Math.max(1,r-u)),a.push(n.substring(i-=s,i+s)),!((u+=s+1)>r));)s=t[o=(o+1)%t.length];return a.reverse().join(e)}}function W3(t){return function(e){return e.replace(/[0-9]/g,function(n){return t[+n]})}}var Z3=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function ui(t){if(!(e=Z3.exec(t)))throw new Error("invalid format: "+t);var e;return new op({fill:e[1],align:e[2],sign:e[3],symbol:e[4],zero:e[5],width:e[6],comma:e[7],precision:e[8]&&e[8].slice(1),trim:e[9],type:e[10]})}ui.prototype=op.prototype;function op(t){this.fill=t.fill===void 0?" ":t.fill+"",this.align=t.align===void 0?">":t.align+"",this.sign=t.sign===void 0?"-":t.sign+"",this.symbol=t.symbol===void 0?"":t.symbol+"",this.zero=!!t.zero,this.width=t.width===void 0?void 0:+t.width,this.comma=!!t.comma,this.precision=t.precision===void 0?void 0:+t.precision,this.trim=!!t.trim,this.type=t.type===void 0?"":t.type+""}op.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===void 0?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===void 0?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type};function Y3(t){e:for(var e=t.length,n=1,r=-1,i;n<e;++n)switch(t[n]){case".":r=i=n;break;case"0":r===0&&(r=n),i=n;break;default:if(!+t[n])break e;r>0&&(r=0);break}return r>0?t.slice(0,r)+t.slice(i+1):t}var jw;function X3(t,e){var n=of(t,e);if(!n)return t+"";var r=n[0],i=n[1],a=i-(jw=Math.max(-8,Math.min(8,Math.floor(i/3)))*3)+1,o=r.length;return a===o?r:a>o?r+new Array(a-o+1).join("0"):a>0?r.slice(0,a)+"."+r.slice(a):"0."+new Array(1-a).join("0")+of(t,Math.max(0,e+a-1))[0]}function Em(t,e){var n=of(t,e);if(!n)return t+"";var r=n[0],i=n[1];return i<0?"0."+new Array(-i).join("0")+r:r.length>i+1?r.slice(0,i+1)+"."+r.slice(i+1):r+new Array(i-r.length+2).join("0")}const Am={"%":(t,e)=>(t*100).toFixed(e),b:t=>Math.round(t).toString(2),c:t=>t+"",d:G3,e:(t,e)=>t.toExponential(e),f:(t,e)=>t.toFixed(e),g:(t,e)=>t.toPrecision(e),o:t=>Math.round(t).toString(8),p:(t,e)=>Em(t*100,e),r:Em,s:X3,X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function Sm(t){return t}var Cm=Array.prototype.map,Tm=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function K3(t){var e=t.grouping===void 0||t.thousands===void 0?Sm:j3(Cm.call(t.grouping,Number),t.thousands+""),n=t.currency===void 0?"":t.currency[0]+"",r=t.currency===void 0?"":t.currency[1]+"",i=t.decimal===void 0?".":t.decimal+"",a=t.numerals===void 0?Sm:W3(Cm.call(t.numerals,String)),o=t.percent===void 0?"%":t.percent+"",s=t.minus===void 0?"−":t.minus+"",u=t.nan===void 0?"NaN":t.nan+"";function l(c){c=ui(c);var h=c.fill,d=c.align,p=c.sign,m=c.symbol,y=c.zero,w=c.width,A=c.comma,C=c.precision,E=c.trim,k=c.type;k==="n"?(A=!0,k="g"):Am[k]||(C===void 0&&(C=12),E=!0,k="g"),(y||h==="0"&&d==="=")&&(y=!0,h="0",d="=");var R=m==="$"?n:m==="#"&&/[boxX]/.test(k)?"0"+k.toLowerCase():"",I=m==="$"?r:/[%p]/.test(k)?o:"",O=Am[k],T=/[defgprs%]/.test(k);C=C===void 0?6:/[gprs]/.test(k)?Math.max(1,Math.min(21,C)):Math.max(0,Math.min(20,C));function B(N){var J=R,ee=I,Q,he,be;if(k==="c")ee=O(N)+ee,N="";else{N=+N;var Se=N<0||1/N<0;if(N=isNaN(N)?u:O(Math.abs(N),C),E&&(N=Y3(N)),Se&&+N==0&&p!=="+"&&(Se=!1),J=(Se?p==="("?p:s:p==="-"||p==="("?"":p)+J,ee=(k==="s"?Tm[8+jw/3]:"")+ee+(Se&&p==="("?")":""),T){for(Q=-1,he=N.length;++Q<he;)if(be=N.charCodeAt(Q),48>be||be>57){ee=(be===46?i+N.slice(Q+1):N.slice(Q))+ee,N=N.slice(0,Q);break}}}A&&!y&&(N=e(N,1/0));var Ke=J.length+N.length+ee.length,Ze=Ke<w?new Array(w-Ke+1).join(h):"";switch(A&&y&&(N=e(Ze+N,Ze.length?w-ee.length:1/0),Ze=""),d){case"<":N=J+N+ee+Ze;break;case"=":N=J+Ze+N+ee;break;case"^":N=Ze.slice(0,Ke=Ze.length>>1)+J+N+ee+Ze.slice(Ke);break;default:N=Ze+J+N+ee;break}return a(N)}return B.toString=function(){return c+""},B}function f(c,h){var d=l((c=ui(c),c.type="f",c)),p=Math.max(-8,Math.min(8,Math.floor(uo(h)/3)))*3,m=Math.pow(10,-p),y=Tm[8+p/3];return function(w){return d(m*w)+y}}return{format:l,formatPrefix:f}}var hu,gt,sp;J3({thousands:",",grouping:[3],currency:["$",""]});function J3(t){return hu=K3(t),gt=hu.format,sp=hu.formatPrefix,hu}function Ww(t){return Math.max(0,-uo(Math.abs(t)))}function Zw(t,e){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(uo(e)/3)))*3-uo(Math.abs(t)))}function Yw(t,e){return t=Math.abs(t),e=Math.abs(e)-t,Math.max(0,uo(e)-uo(t))+1}const oh=new Date,sh=new Date;function rt(t,e,n,r){function i(a){return t(a=arguments.length===0?new Date:new Date(+a)),a}return i.floor=a=>(t(a=new Date(+a)),a),i.ceil=a=>(t(a=new Date(a-1)),e(a,1),t(a),a),i.round=a=>{const o=i(a),s=i.ceil(a);return a-o<s-a?o:s},i.offset=(a,o)=>(e(a=new Date(+a),o==null?1:Math.floor(o)),a),i.range=(a,o,s)=>{const u=[];if(a=i.ceil(a),s=s==null?1:Math.floor(s),!(a<o)||!(s>0))return u;let l;do u.push(l=new Date(+a)),e(a,s),t(a);while(l<a&&a<o);return u},i.filter=a=>rt(o=>{if(o>=o)for(;t(o),!a(o);)o.setTime(o-1)},(o,s)=>{if(o>=o)if(s<0)for(;++s<=0;)for(;e(o,-1),!a(o););else for(;--s>=0;)for(;e(o,1),!a(o););}),n&&(i.count=(a,o)=>(oh.setTime(+a),sh.setTime(+o),t(oh),t(sh),Math.floor(n(oh,sh))),i.every=a=>(a=Math.floor(a),!isFinite(a)||!(a>0)?null:a>1?i.filter(r?o=>r(o)%a===0:o=>i.count(0,o)%a===0):i)),i}const fo=rt(()=>{},(t,e)=>{t.setTime(+t+e)},(t,e)=>e-t);fo.every=t=>(t=Math.floor(t),!isFinite(t)||!(t>0)?null:t>1?rt(e=>{e.setTime(Math.floor(e/t)*t)},(e,n)=>{e.setTime(+e+n*t)},(e,n)=>(n-e)/t):fo);fo.range;const Tr=1e3,on=Tr*60,Fr=on*60,Dr=Fr*24,lp=Dr*7,Fm=Dr*30,lh=Dr*365,Ir=rt(t=>{t.setTime(t-t.getMilliseconds())},(t,e)=>{t.setTime(+t+e*Tr)},(t,e)=>(e-t)/Tr,t=>t.getUTCSeconds());Ir.range;const ic=rt(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*Tr)},(t,e)=>{t.setTime(+t+e*on)},(t,e)=>(e-t)/on,t=>t.getMinutes());ic.range;const ac=rt(t=>{t.setUTCSeconds(0,0)},(t,e)=>{t.setTime(+t+e*on)},(t,e)=>(e-t)/on,t=>t.getUTCMinutes());ac.range;const oc=rt(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*Tr-t.getMinutes()*on)},(t,e)=>{t.setTime(+t+e*Fr)},(t,e)=>(e-t)/Fr,t=>t.getHours());oc.range;const sc=rt(t=>{t.setUTCMinutes(0,0,0)},(t,e)=>{t.setTime(+t+e*Fr)},(t,e)=>(e-t)/Fr,t=>t.getUTCHours());sc.range;const ri=rt(t=>t.setHours(0,0,0,0),(t,e)=>t.setDate(t.getDate()+e),(t,e)=>(e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*on)/Dr,t=>t.getDate()-1);ri.range;const Wi=rt(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/Dr,t=>t.getUTCDate()-1);Wi.range;const Xw=rt(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/Dr,t=>Math.floor(t/Dr));Xw.range;function ga(t){return rt(e=>{e.setDate(e.getDate()-(e.getDay()+7-t)%7),e.setHours(0,0,0,0)},(e,n)=>{e.setDate(e.getDate()+n*7)},(e,n)=>(n-e-(n.getTimezoneOffset()-e.getTimezoneOffset())*on)/lp)}const Sl=ga(0),sf=ga(1),Q3=ga(2),eC=ga(3),co=ga(4),tC=ga(5),nC=ga(6);Sl.range;sf.range;Q3.range;eC.range;co.range;tC.range;nC.range;function ma(t){return rt(e=>{e.setUTCDate(e.getUTCDate()-(e.getUTCDay()+7-t)%7),e.setUTCHours(0,0,0,0)},(e,n)=>{e.setUTCDate(e.getUTCDate()+n*7)},(e,n)=>(n-e)/lp)}const Cl=ma(0),lf=ma(1),rC=ma(2),iC=ma(3),ho=ma(4),aC=ma(5),oC=ma(6);Cl.range;lf.range;rC.range;iC.range;ho.range;aC.range;oC.range;const Ns=rt(t=>{t.setDate(1),t.setHours(0,0,0,0)},(t,e)=>{t.setMonth(t.getMonth()+e)},(t,e)=>e.getMonth()-t.getMonth()+(e.getFullYear()-t.getFullYear())*12,t=>t.getMonth());Ns.range;const $s=rt(t=>{t.setUTCDate(1),t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCMonth(t.getUTCMonth()+e)},(t,e)=>e.getUTCMonth()-t.getUTCMonth()+(e.getUTCFullYear()-t.getUTCFullYear())*12,t=>t.getUTCMonth());$s.range;const or=rt(t=>{t.setMonth(0,1),t.setHours(0,0,0,0)},(t,e)=>{t.setFullYear(t.getFullYear()+e)},(t,e)=>e.getFullYear()-t.getFullYear(),t=>t.getFullYear());or.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:rt(e=>{e.setFullYear(Math.floor(e.getFullYear()/t)*t),e.setMonth(0,1),e.setHours(0,0,0,0)},(e,n)=>{e.setFullYear(e.getFullYear()+n*t)});or.range;const sr=rt(t=>{t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCFullYear(t.getUTCFullYear()+e)},(t,e)=>e.getUTCFullYear()-t.getUTCFullYear(),t=>t.getUTCFullYear());sr.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:rt(e=>{e.setUTCFullYear(Math.floor(e.getUTCFullYear()/t)*t),e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0)},(e,n)=>{e.setUTCFullYear(e.getUTCFullYear()+n*t)});sr.range;function Kw(t,e,n,r,i,a){const o=[[Ir,1,Tr],[Ir,5,5*Tr],[Ir,15,15*Tr],[Ir,30,30*Tr],[a,1,on],[a,5,5*on],[a,15,15*on],[a,30,30*on],[i,1,Fr],[i,3,3*Fr],[i,6,6*Fr],[i,12,12*Fr],[r,1,Dr],[r,2,2*Dr],[n,1,lp],[e,1,Fm],[e,3,3*Fm],[t,1,lh]];function s(l,f,c){const h=f<l;h&&([l,f]=[f,l]);const d=c&&typeof c.range=="function"?c:u(l,f,c),p=d?d.range(l,+f+1):[];return h?p.reverse():p}function u(l,f,c){const h=Math.abs(f-l)/c,d=nc(([,,y])=>y).right(o,h);if(d===o.length)return t.every(ta(l/lh,f/lh,c));if(d===0)return fo.every(Math.max(ta(l,f,c),1));const[p,m]=o[h/o[d-1][2]<o[d][2]/h?d-1:d];return p.every(m)}return[s,u]}const[sC,lC]=Kw(sr,$s,Cl,Xw,sc,ac),[uC,fC]=Kw(or,Ns,Sl,ri,oc,ic),Os="year",Ls="quarter",Ms="month",Ps="week",zs="date",lc="day",up="dayofyear",Us="hours",qs="minutes",Vs="seconds",uc="milliseconds",cC=[Os,Ls,Ms,Ps,zs,lc,up,Us,qs,Vs,uc];cC.reduce((t,e,n)=>(t[e]=1+n,t),{});const hC={[Os]:or,[Ls]:Ns.every(3),[Ms]:Ns,[Ps]:Sl,[zs]:ri,[lc]:ri,[up]:ri,[Us]:oc,[qs]:ic,[Vs]:Ir,[uc]:fo},dC={[Os]:sr,[Ls]:$s.every(3),[Ms]:$s,[Ps]:Cl,[zs]:Wi,[lc]:Wi,[up]:Wi,[Us]:sc,[qs]:ac,[Vs]:Ir,[uc]:fo};function pC(t){return hC[t]}function gC(t){return dC[t]}function uh(t){if(0<=t.y&&t.y<100){var e=new Date(-1,t.m,t.d,t.H,t.M,t.S,t.L);return e.setFullYear(t.y),e}return new Date(t.y,t.m,t.d,t.H,t.M,t.S,t.L)}function fh(t){if(0<=t.y&&t.y<100){var e=new Date(Date.UTC(-1,t.m,t.d,t.H,t.M,t.S,t.L));return e.setUTCFullYear(t.y),e}return new Date(Date.UTC(t.y,t.m,t.d,t.H,t.M,t.S,t.L))}function Xo(t,e,n){return{y:t,m:e,d:n,H:0,M:0,S:0,L:0}}function Jw(t){var e=t.dateTime,n=t.date,r=t.time,i=t.periods,a=t.days,o=t.shortDays,s=t.months,u=t.shortMonths,l=Ko(i),f=Jo(i),c=Ko(a),h=Jo(a),d=Ko(o),p=Jo(o),m=Ko(s),y=Jo(s),w=Ko(u),A=Jo(u),C={a:Se,A:Ke,b:Ze,B:Mn,c:null,d:Nm,e:Nm,f:MC,g:ZC,G:XC,H:$C,I:OC,j:LC,L:Qw,m:PC,M:zC,p:ke,q:Pe,Q:Lm,s:Mm,S:UC,u:qC,U:VC,V:HC,w:GC,W:jC,x:null,X:null,y:WC,Y:YC,Z:KC,"%":Om},E={a:kt,A:xn,b:Pn,B:M,c:null,d:$m,e:$m,f:t6,g:c6,G:d6,H:JC,I:QC,j:e6,L:tx,m:n6,M:r6,p:L,q:j,Q:Lm,s:Mm,S:i6,u:a6,U:o6,V:s6,w:l6,W:u6,x:null,X:null,y:f6,Y:h6,Z:p6,"%":Om},k={a:B,A:N,b:J,B:ee,c:Q,d:Dm,e:Dm,f:RC,g:Rm,G:km,H:Bm,I:Bm,j:TC,L:kC,m:CC,M:FC,p:T,q:SC,Q:BC,s:NC,S:IC,u:xC,U:_C,V:vC,w:wC,W:EC,x:he,X:be,y:Rm,Y:km,Z:AC,"%":DC};C.x=R(n,C),C.X=R(r,C),C.c=R(e,C),E.x=R(n,E),E.X=R(r,E),E.c=R(e,E);function R(H,Y){return function(S){var _=[],q=-1,G=0,ue=H.length,ne,fe,Rt;for(S instanceof Date||(S=new Date(+S));++q<ue;)H.charCodeAt(q)===37&&(_.push(H.slice(G,q)),(fe=Im[ne=H.charAt(++q)])!=null?ne=H.charAt(++q):fe=ne==="e"?" ":"0",(Rt=Y[ne])&&(ne=Rt(S,fe)),_.push(ne),G=q+1);return _.push(H.slice(G,q)),_.join("")}}function I(H,Y){return function(S){var _=Xo(1900,void 0,1),q=O(_,H,S+="",0),G,ue;if(q!=S.length)return null;if("Q"in _)return new Date(_.Q);if("s"in _)return new Date(_.s*1e3+("L"in _?_.L:0));if(Y&&!("Z"in _)&&(_.Z=0),"p"in _&&(_.H=_.H%12+_.p*12),_.m===void 0&&(_.m="q"in _?_.q:0),"V"in _){if(_.V<1||_.V>53)return null;"w"in _||(_.w=1),"Z"in _?(G=fh(Xo(_.y,0,1)),ue=G.getUTCDay(),G=ue>4||ue===0?lf.ceil(G):lf(G),G=Wi.offset(G,(_.V-1)*7),_.y=G.getUTCFullYear(),_.m=G.getUTCMonth(),_.d=G.getUTCDate()+(_.w+6)%7):(G=uh(Xo(_.y,0,1)),ue=G.getDay(),G=ue>4||ue===0?sf.ceil(G):sf(G),G=ri.offset(G,(_.V-1)*7),_.y=G.getFullYear(),_.m=G.getMonth(),_.d=G.getDate()+(_.w+6)%7)}else("W"in _||"U"in _)&&("w"in _||(_.w="u"in _?_.u%7:"W"in _?1:0),ue="Z"in _?fh(Xo(_.y,0,1)).getUTCDay():uh(Xo(_.y,0,1)).getDay(),_.m=0,_.d="W"in _?(_.w+6)%7+_.W*7-(ue+5)%7:_.w+_.U*7-(ue+6)%7);return"Z"in _?(_.H+=_.Z/100|0,_.M+=_.Z%100,fh(_)):uh(_)}}function O(H,Y,S,_){for(var q=0,G=Y.length,ue=S.length,ne,fe;q<G;){if(_>=ue)return-1;if(ne=Y.charCodeAt(q++),ne===37){if(ne=Y.charAt(q++),fe=k[ne in Im?Y.charAt(q++):ne],!fe||(_=fe(H,S,_))<0)return-1}else if(ne!=S.charCodeAt(_++))return-1}return _}function T(H,Y,S){var _=l.exec(Y.slice(S));return _?(H.p=f.get(_[0].toLowerCase()),S+_[0].length):-1}function B(H,Y,S){var _=d.exec(Y.slice(S));return _?(H.w=p.get(_[0].toLowerCase()),S+_[0].length):-1}function N(H,Y,S){var _=c.exec(Y.slice(S));return _?(H.w=h.get(_[0].toLowerCase()),S+_[0].length):-1}function J(H,Y,S){var _=w.exec(Y.slice(S));return _?(H.m=A.get(_[0].toLowerCase()),S+_[0].length):-1}function ee(H,Y,S){var _=m.exec(Y.slice(S));return _?(H.m=y.get(_[0].toLowerCase()),S+_[0].length):-1}function Q(H,Y,S){return O(H,e,Y,S)}function he(H,Y,S){return O(H,n,Y,S)}function be(H,Y,S){return O(H,r,Y,S)}function Se(H){return o[H.getDay()]}function Ke(H){return a[H.getDay()]}function Ze(H){return u[H.getMonth()]}function Mn(H){return s[H.getMonth()]}function ke(H){return i[+(H.getHours()>=12)]}function Pe(H){return 1+~~(H.getMonth()/3)}function kt(H){return o[H.getUTCDay()]}function xn(H){return a[H.getUTCDay()]}function Pn(H){return u[H.getUTCMonth()]}function M(H){return s[H.getUTCMonth()]}function L(H){return i[+(H.getUTCHours()>=12)]}function j(H){return 1+~~(H.getUTCMonth()/3)}return{format:function(H){var Y=R(H+="",C);return Y.toString=function(){return H},Y},parse:function(H){var Y=I(H+="",!1);return Y.toString=function(){return H},Y},utcFormat:function(H){var Y=R(H+="",E);return Y.toString=function(){return H},Y},utcParse:function(H){var Y=I(H+="",!0);return Y.toString=function(){return H},Y}}}var Im={"-":"",_:" ",0:"0"},ft=/^\s*\d+/,mC=/^%/,bC=/[\\^$*+?|[\]().{}]/g;function _e(t,e,n){var r=t<0?"-":"",i=(r?-t:t)+"",a=i.length;return r+(a<n?new Array(n-a+1).join(e)+i:i)}function yC(t){return t.replace(bC,"\\$&")}function Ko(t){return new RegExp("^(?:"+t.map(yC).join("|")+")","i")}function Jo(t){return new Map(t.map((e,n)=>[e.toLowerCase(),n]))}function wC(t,e,n){var r=ft.exec(e.slice(n,n+1));return r?(t.w=+r[0],n+r[0].length):-1}function xC(t,e,n){var r=ft.exec(e.slice(n,n+1));return r?(t.u=+r[0],n+r[0].length):-1}function _C(t,e,n){var r=ft.exec(e.slice(n,n+2));return r?(t.U=+r[0],n+r[0].length):-1}function vC(t,e,n){var r=ft.exec(e.slice(n,n+2));return r?(t.V=+r[0],n+r[0].length):-1}function EC(t,e,n){var r=ft.exec(e.slice(n,n+2));return r?(t.W=+r[0],n+r[0].length):-1}function km(t,e,n){var r=ft.exec(e.slice(n,n+4));return r?(t.y=+r[0],n+r[0].length):-1}function Rm(t,e,n){var r=ft.exec(e.slice(n,n+2));return r?(t.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function AC(t,e,n){var r=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(e.slice(n,n+6));return r?(t.Z=r[1]?0:-(r[2]+(r[3]||"00")),n+r[0].length):-1}function SC(t,e,n){var r=ft.exec(e.slice(n,n+1));return r?(t.q=r[0]*3-3,n+r[0].length):-1}function CC(t,e,n){var r=ft.exec(e.slice(n,n+2));return r?(t.m=r[0]-1,n+r[0].length):-1}function Dm(t,e,n){var r=ft.exec(e.slice(n,n+2));return r?(t.d=+r[0],n+r[0].length):-1}function TC(t,e,n){var r=ft.exec(e.slice(n,n+3));return r?(t.m=0,t.d=+r[0],n+r[0].length):-1}function Bm(t,e,n){var r=ft.exec(e.slice(n,n+2));return r?(t.H=+r[0],n+r[0].length):-1}function FC(t,e,n){var r=ft.exec(e.slice(n,n+2));return r?(t.M=+r[0],n+r[0].length):-1}function IC(t,e,n){var r=ft.exec(e.slice(n,n+2));return r?(t.S=+r[0],n+r[0].length):-1}function kC(t,e,n){var r=ft.exec(e.slice(n,n+3));return r?(t.L=+r[0],n+r[0].length):-1}function RC(t,e,n){var r=ft.exec(e.slice(n,n+6));return r?(t.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function DC(t,e,n){var r=mC.exec(e.slice(n,n+1));return r?n+r[0].length:-1}function BC(t,e,n){var r=ft.exec(e.slice(n));return r?(t.Q=+r[0],n+r[0].length):-1}function NC(t,e,n){var r=ft.exec(e.slice(n));return r?(t.s=+r[0],n+r[0].length):-1}function Nm(t,e){return _e(t.getDate(),e,2)}function $C(t,e){return _e(t.getHours(),e,2)}function OC(t,e){return _e(t.getHours()%12||12,e,2)}function LC(t,e){return _e(1+ri.count(or(t),t),e,3)}function Qw(t,e){return _e(t.getMilliseconds(),e,3)}function MC(t,e){return Qw(t,e)+"000"}function PC(t,e){return _e(t.getMonth()+1,e,2)}function zC(t,e){return _e(t.getMinutes(),e,2)}function UC(t,e){return _e(t.getSeconds(),e,2)}function qC(t){var e=t.getDay();return e===0?7:e}function VC(t,e){return _e(Sl.count(or(t)-1,t),e,2)}function ex(t){var e=t.getDay();return e>=4||e===0?co(t):co.ceil(t)}function HC(t,e){return t=ex(t),_e(co.count(or(t),t)+(or(t).getDay()===4),e,2)}function GC(t){return t.getDay()}function jC(t,e){return _e(sf.count(or(t)-1,t),e,2)}function WC(t,e){return _e(t.getFullYear()%100,e,2)}function ZC(t,e){return t=ex(t),_e(t.getFullYear()%100,e,2)}function YC(t,e){return _e(t.getFullYear()%1e4,e,4)}function XC(t,e){var n=t.getDay();return t=n>=4||n===0?co(t):co.ceil(t),_e(t.getFullYear()%1e4,e,4)}function KC(t){var e=t.getTimezoneOffset();return(e>0?"-":(e*=-1,"+"))+_e(e/60|0,"0",2)+_e(e%60,"0",2)}function $m(t,e){return _e(t.getUTCDate(),e,2)}function JC(t,e){return _e(t.getUTCHours(),e,2)}function QC(t,e){return _e(t.getUTCHours()%12||12,e,2)}function e6(t,e){return _e(1+Wi.count(sr(t),t),e,3)}function tx(t,e){return _e(t.getUTCMilliseconds(),e,3)}function t6(t,e){return tx(t,e)+"000"}function n6(t,e){return _e(t.getUTCMonth()+1,e,2)}function r6(t,e){return _e(t.getUTCMinutes(),e,2)}function i6(t,e){return _e(t.getUTCSeconds(),e,2)}function a6(t){var e=t.getUTCDay();return e===0?7:e}function o6(t,e){return _e(Cl.count(sr(t)-1,t),e,2)}function nx(t){var e=t.getUTCDay();return e>=4||e===0?ho(t):ho.ceil(t)}function s6(t,e){return t=nx(t),_e(ho.count(sr(t),t)+(sr(t).getUTCDay()===4),e,2)}function l6(t){return t.getUTCDay()}function u6(t,e){return _e(lf.count(sr(t)-1,t),e,2)}function f6(t,e){return _e(t.getUTCFullYear()%100,e,2)}function c6(t,e){return t=nx(t),_e(t.getUTCFullYear()%100,e,2)}function h6(t,e){return _e(t.getUTCFullYear()%1e4,e,4)}function d6(t,e){var n=t.getUTCDay();return t=n>=4||n===0?ho(t):ho.ceil(t),_e(t.getUTCFullYear()%1e4,e,4)}function p6(){return"+0000"}function Om(){return"%"}function Lm(t){return+t}function Mm(t){return Math.floor(+t/1e3)}var Ca,fp,rx,cp,ix;g6({dateTime:"%x, %X",date:"%-m/%-d/%Y",time:"%-I:%M:%S %p",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});function g6(t){return Ca=Jw(t),fp=Ca.format,rx=Ca.parse,cp=Ca.utcFormat,ix=Ca.utcParse,Ca}function as(t){const e={};return n=>e[n]||(e[n]=t(n))}function m6(t,e){return n=>{const r=t(n),i=r.indexOf(e);if(i<0)return r;let a=b6(r,i);const o=a<r.length?r.slice(a):"";for(;--a>i;)if(r[a]!=="0"){++a;break}return r.slice(0,a)+o}}function b6(t,e){let n=t.lastIndexOf("e"),r;if(n>0)return n;for(n=t.length;--n>e;)if(r=t.charCodeAt(n),r>=48&&r<=57)return n+1}function y6(t){const e=as(t.format),n=t.formatPrefix;return{format:e,formatPrefix:n,formatFloat(r){const i=ui(r||",");if(i.precision==null){switch(i.precision=12,i.type){case"%":i.precision-=2;break;case"e":i.precision-=1;break}return m6(e(i),e(".1f")(1)[1])}else return e(i)},formatSpan(r,i,a,o){o=ui(o??",f");const s=ta(r,i,a),u=Math.max(Math.abs(r),Math.abs(i));let l;if(o.precision==null)switch(o.type){case"s":return isNaN(l=Zw(s,u))||(o.precision=l),n(o,u);case"":case"e":case"g":case"p":case"r":{isNaN(l=Yw(s,u))||(o.precision=l-(o.type==="e"));break}case"f":case"%":{isNaN(l=Ww(s))||(o.precision=l-(o.type==="%")*2);break}}return e(o)}}}w6();function w6(){return y6({format:gt,formatPrefix:sp})}function Pm(t,e,n){n=n||{},Bn(n)||je(`Invalid time multi-format specifier: ${n}`);const r=e(Vs),i=e(qs),a=e(Us),o=e(zs),s=e(Ps),u=e(Ms),l=e(Ls),f=e(Os),c=t(n[uc]||".%L"),h=t(n[Vs]||":%S"),d=t(n[qs]||"%I:%M"),p=t(n[Us]||"%I %p"),m=t(n[zs]||n[lc]||"%a %d"),y=t(n[Ps]||"%b %d"),w=t(n[Ms]||"%B"),A=t(n[Ls]||"%B"),C=t(n[Os]||"%Y");return E=>(r(E)<E?c:i(E)<E?h:a(E)<E?d:o(E)<E?p:u(E)<E?s(E)<E?m:y:f(E)<E?l(E)<E?w:A:C)(E)}function ax(t){const e=as(t.format),n=as(t.utcFormat);return{timeFormat:r=>We(r)?e(r):Pm(e,pC,r),utcFormat:r=>We(r)?n(r):Pm(n,gC,r),timeParse:as(t.parse),utcParse:as(t.utcParse)}}let zd;x6();function x6(){return zd=ax({format:fp,parse:rx,utcFormat:cp,utcParse:ix})}function _6(t){return ax(Jw(t))}function v6(t){return arguments.length?zd=_6(t):zd}const E6=/^(data:|([A-Za-z]+:)?\/\/)/,A6=/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp|file|data):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i,S6=/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205f\u3000]/g,zm="file://";function C6(t,e){return n=>({options:n||{},sanitize:F6,load:T6,fileAccess:!!e,file:I6(e),http:R6(t)})}async function T6(t,e){const n=await this.sanitize(t,e),r=n.href;return n.localFile?this.file(r):this.http(r,e)}async function F6(t,e){e=ap({},this.options,e);const n=this.fileAccess,r={href:null};let i,a,o;const s=A6.test(t.replace(S6,""));(t==null||typeof t!="string"||!s)&&je("Sanitize failure, invalid URI: "+tc(t));const u=E6.test(t);return(o=e.baseURL)&&!u&&(!t.startsWith("/")&&!o.endsWith("/")&&(t="/"+t),t=o+t),a=(i=t.startsWith(zm))||e.mode==="file"||e.mode!=="http"&&!u&&n,i?t=t.slice(zm.length):t.startsWith("//")&&(e.defaultProtocol==="file"?(t=t.slice(2),a=!0):t=(e.defaultProtocol||"http")+":"+t),Object.defineProperty(r,"localFile",{value:!!a}),r.href=t,e.target&&(r.target=e.target+""),e.rel&&(r.rel=e.rel+""),e.context==="image"&&e.crossOrigin&&(r.crossOrigin=e.crossOrigin+""),r}function I6(t){return t?e=>new Promise((n,r)=>{t.readFile(e,(i,a)=>{i?r(i):n(a)})}):k6}async function k6(){je("No file system access.")}function R6(t){return t?async function(e,n){const r=ap({},this.options.http,n),i=n&&n.response,a=await t(e,r);return a.ok?qt(a[i])?a[i]():a.text():je(a.status+""+a.statusText)}:D6}async function D6(){je("No HTTP fetch method available.")}const B6=t=>t!=null&&t===t,N6=t=>t==="true"||t==="false"||t===!0||t===!1,$6=t=>!Number.isNaN(Date.parse(t)),ox=t=>!Number.isNaN(+t)&&!(t instanceof Date),O6=t=>ox(t)&&Number.isInteger(+t),Um={boolean:w3,integer:Ds,number:Ds,date:_3,string:v3,unknown:Jf},du=[N6,O6,ox,$6],L6=["boolean","integer","number","date"];function M6(t,e){if(!t||!t.length)return"unknown";const n=t.length,r=du.length,i=du.map((a,o)=>o+1);for(let a=0,o=0,s,u;a<n;++a)for(u=e?t[a][e]:t[a],s=0;s<r;++s)if(i[s]&&B6(u)&&!du[s](u)&&(i[s]=0,++o,o===du.length))return"string";return L6[i.reduce((a,o)=>a===0?o:a,0)-1]}function P6(t,e){return e.reduce((n,r)=>(n[r]=M6(t,r),n),{})}function qm(t){const e=function(n,r){const i={delimiter:t};return hp(n,r?ap(r,i):i)};return e.responseType="text",e}function hp(t,e){return e.header&&(t=e.header.map(tc).join(e.delimiter)+` -`+t),C3(e.delimiter).parse(t+"")}hp.responseType="text";function z6(t){return typeof Buffer=="function"&&qt(Buffer.isBuffer)?Buffer.isBuffer(t):!1}function dp(t,e){const n=e&&e.property?Kf(e.property):Jf;return Bn(t)&&!z6(t)?U6(n(t),e):n(JSON.parse(t))}dp.responseType="json";function U6(t,e){return!en(t)&&b3(t)&&(t=[...t]),e&&e.copy?JSON.parse(JSON.stringify(t)):t}const q6={interior:(t,e)=>t!==e,exterior:(t,e)=>t===e};function sx(t,e){let n,r,i,a;return t=dp(t,e),e&&e.feature?(n=k3,i=e.feature):e&&e.mesh?(n=D3,i=e.mesh,a=q6[e.filter]):je("Missing TopoJSON feature or mesh parameter."),r=(r=t.objects[i])?n(t,r,a):je("Invalid TopoJSON object: "+i),r&&r.features||[r]}sx.responseType="json";const ch={dsv:hp,csv:qm(","),tsv:qm(" "),json:dp,topojson:sx};function lx(t,e){return arguments.length>1?(ch[t]=e,this):Ma(ch,t)?ch[t]:null}function ux(t,e,n,r){e=e||{};const i=lx(e.type||"json");return i||je("Unknown data format type: "+e.type),t=i(t,e),e.parse&&V6(t,e.parse,n,r),Ma(t,"columns")&&delete t.columns,t}function V6(t,e,n,r){if(!t.length)return;const i=v6();n=n||i.timeParse,r=r||i.utcParse;let a=t.columns||Object.keys(t[0]),o,s,u,l,f,c;e==="auto"&&(e=P6(t,a)),a=Object.keys(e);const h=a.map(d=>{const p=e[d];let m,y;if(p&&(p.startsWith("date:")||p.startsWith("utc:")))return m=p.split(/:(.+)?/,2),y=m[1],(y[0]==="'"&&y[y.length-1]==="'"||y[0]==='"'&&y[y.length-1]==='"')&&(y=y.slice(1,-1)),(m[0]==="utc"?r:n)(y);if(!Um[p])throw Error("Illegal format pattern: "+d+":"+p);return Um[p]});for(u=0,f=t.length,c=a.length;u<f;++u)for(o=t[u],l=0;l<c;++l)s=a[l],o[s]=h[l](o[s])}const fc=C6(typeof fetch<"u"&&fetch,null),H6=`.genome-spy { - font-family: system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; - position: relative; -} -.genome-spy canvas { - transform: scale(1, 1); - opacity: 1; - transition: transform 0.6s, opacity 0.6s; -} -.genome-spy .loading-message { - position: absolute; - top: 0; - bottom: 0; - left: 0; - right: 0; - display: flex; - align-items: center; - justify-content: center; -} -.genome-spy .loading-message .message { - color: #666; - opacity: 0; - transition: opacity 0.7s; -} -.genome-spy.loading canvas { - transform: scale(0.95, 0.95); - opacity: 0; -} -.genome-spy.loading .loading-message .message { - opacity: 1; -} -.genome-spy.loading .ellipsis { - animation: blinker 1s linear infinite; -} -@keyframes blinker { - 50% { - opacity: 0; - } -} -.genome-spy .tooltip { - position: absolute; - max-width: 450px; - overflow: hidden; - background: #f6f6f6; - padding: 10px; - font-size: 13px; - box-shadow: 0px 3px 15px 0px rgba(0, 0, 0, 0.21); - pointer-events: none; - z-index: 100; -} -.genome-spy .tooltip > :last-child { - margin-bottom: 0; -} -.genome-spy .tooltip > .title { - padding-bottom: 5px; - margin-bottom: 5px; - border-bottom: 1px dashed #b6b6b6; -} -.genome-spy .tooltip .summary { - font-size: 12px; -} -.genome-spy .tooltip table { - border-collapse: collapse; -} -.genome-spy .tooltip table:first-child { - margin-top: 0; -} -.genome-spy .tooltip table th, -.genome-spy .tooltip table td { - padding: 2px 0.4em; - vertical-align: top; -} -.genome-spy .tooltip table th:first-child, -.genome-spy .tooltip table td:first-child { - padding-left: 0; -} -.genome-spy .tooltip table th { - text-align: left; - font-weight: bold; -} -.genome-spy .tooltip .color-legend { - display: inline-block; - width: 0.8em; - height: 0.8em; - margin-left: 0.4em; - box-shadow: 0px 0px 3px 1px white; -} -.genome-spy .tooltip .attributes .hovered { - background-color: #e0e0e0; -} -.genome-spy .tooltip .na { - color: #aaa; - font-style: italic; - font-size: 80%; -} -.genome-spy .gene-track-tooltip .summary { - font-size: 90%; -} -.genome-spy .message-box { - display: flex; - align-items: center; - justify-content: center; - position: absolute; - top: 0; - height: 100%; - width: 100%; -} -.genome-spy .message-box > div { - border: 1px solid red; - padding: 10px; - background: #fff0f0; -}`;function G6(t,e){var n=t.getBoundingClientRect();return[e.clientX-n.left-t.clientLeft,e.clientY-n.top-t.clientTop]}function uf(t,e){return t.length==e.length&&t.every((n,r)=>t[r]===e[r])}function Jt(t){return Array.isArray(t)?t:typeof t<"u"?[t]:[]}function Tl(t){return t[t.length-1]}class j6{constructor(e){this.container=e,this.element=document.createElement("div"),this.element.className="tooltip",this._visible=!0,this.container.appendChild(this.element),this._previousTooltipDatum=void 0,this.enabledStack=[!0],this._penaltyUntil=0,this._lastCoords=void 0,this._previousMove=0,this.clear()}set visible(e){e!=this._visible&&(this.element.style.display=e?null:"none",this._visible=e)}get visible(){return this._visible}get enabled(){return Tl(this.enabledStack)??!0}pushEnabledState(e){this.enabledStack.push(e),e||(this.visible=!1)}popEnabledState(){this.enabledStack.pop()}handleMouseMove(e){this.mouseCoords=G6(this.container,e);const n=performance.now();!this.visible&&!this._isPenalty()&&n-this._previousMove>500&&(this._penaltyUntil=n+70),this._lastCoords&&W6(this.mouseCoords,this._lastCoords)>20&&(this._penaltyUntil=n+400),this._lastCoords=this.mouseCoords,this.visible&&this.updatePlacement(),this._previousMove=n}updatePlacement(){const[n,r]=this.mouseCoords;let i=n+20;i>this.container.clientWidth-this.element.offsetWidth&&(i=n-20-this.element.offsetWidth),this.element.style.left=i+"px",this.element.style.top=Math.min(r+20,this.container.clientHeight-this.element.offsetHeight)+"px"}setContent(e){if(!e||!this.enabled||this._isPenalty()){this.visible&&(Qu("",this.element),this.visible=!1),this._previousTooltipDatum=void 0;return}Qu(e,this.element),this.visible=!0,this.updatePlacement()}clear(){this._previousTooltipDatum=void 0,this.setContent(void 0)}updateWithDatum(e,n){e!==this._previousTooltipDatum&&(this._previousTooltipDatum=e,n||(n=r=>Promise.resolve(ot`${JSON.stringify(r)}`)),n(e).then(r=>this.setContent(r)).catch(r=>{if(r!=="debounced")throw r}))}_isPenalty(){return this._penaltyUntil&&this._penaltyUntil>performance.now()}}function W6(t,e){let n=0;for(let r=0;r<t.length;r++)n+=(t[r]-e[r])**2;return Math.sqrt(n)}const Z6="RawCode",Y6="Literal",X6="Property",K6="Identifier",J6="ArrayExpression",Q6="BinaryExpression",eT="CallExpression",tT="ConditionalExpression",nT="LogicalExpression",rT="MemberExpression",iT="ObjectExpression",aT="UnaryExpression";function Nn(t){this.type=t}Nn.prototype.visit=function(t){let e,n,r;if(t(this))return 1;for(e=oT(this),n=0,r=e.length;n<r;++n)if(e[n].visit(t))return 1};function oT(t){switch(t.type){case J6:return t.elements;case Q6:case nT:return[t.left,t.right];case eT:return[t.callee].concat(t.arguments);case tT:return[t.test,t.consequent,t.alternate];case rT:return[t.object,t.property];case iT:return t.properties;case X6:return[t.key,t.value];case aT:return[t.argument];case K6:case Y6:case Z6:default:return[]}}var lr,te,U,_t,Te,cc=1,Fl=2,na=3,bi=4,hc=5,ba=6,$t=7,Il=8,sT=9;lr={};lr[cc]="Boolean";lr[Fl]="<end>";lr[na]="Identifier";lr[bi]="Keyword";lr[hc]="Null";lr[ba]="Numeric";lr[$t]="Punctuator";lr[Il]="String";lr[sT]="RegularExpression";var lT="ArrayExpression",uT="BinaryExpression",fT="CallExpression",cT="ConditionalExpression",fx="Identifier",hT="Literal",dT="LogicalExpression",pT="MemberExpression",gT="ObjectExpression",mT="Property",bT="UnaryExpression",st="Unexpected token %0",yT="Unexpected number",wT="Unexpected string",xT="Unexpected identifier",_T="Unexpected reserved word",vT="Unexpected end of input",Ud="Invalid regular expression",hh="Invalid regular expression: missing /",cx="Octal literals are not allowed in strict mode.",ET="Duplicate data property in object literal not allowed in strict mode",dt="ILLEGAL",Hs="Disabled.",AT=new RegExp("[\\xAA\\xB5\\xBA\\xC0-\\xD6\\xD8-\\xF6\\xF8-\\u02C1\\u02C6-\\u02D1\\u02E0-\\u02E4\\u02EC\\u02EE\\u0370-\\u0374\\u0376\\u0377\\u037A-\\u037D\\u037F\\u0386\\u0388-\\u038A\\u038C\\u038E-\\u03A1\\u03A3-\\u03F5\\u03F7-\\u0481\\u048A-\\u052F\\u0531-\\u0556\\u0559\\u0561-\\u0587\\u05D0-\\u05EA\\u05F0-\\u05F2\\u0620-\\u064A\\u066E\\u066F\\u0671-\\u06D3\\u06D5\\u06E5\\u06E6\\u06EE\\u06EF\\u06FA-\\u06FC\\u06FF\\u0710\\u0712-\\u072F\\u074D-\\u07A5\\u07B1\\u07CA-\\u07EA\\u07F4\\u07F5\\u07FA\\u0800-\\u0815\\u081A\\u0824\\u0828\\u0840-\\u0858\\u08A0-\\u08B2\\u0904-\\u0939\\u093D\\u0950\\u0958-\\u0961\\u0971-\\u0980\\u0985-\\u098C\\u098F\\u0990\\u0993-\\u09A8\\u09AA-\\u09B0\\u09B2\\u09B6-\\u09B9\\u09BD\\u09CE\\u09DC\\u09DD\\u09DF-\\u09E1\\u09F0\\u09F1\\u0A05-\\u0A0A\\u0A0F\\u0A10\\u0A13-\\u0A28\\u0A2A-\\u0A30\\u0A32\\u0A33\\u0A35\\u0A36\\u0A38\\u0A39\\u0A59-\\u0A5C\\u0A5E\\u0A72-\\u0A74\\u0A85-\\u0A8D\\u0A8F-\\u0A91\\u0A93-\\u0AA8\\u0AAA-\\u0AB0\\u0AB2\\u0AB3\\u0AB5-\\u0AB9\\u0ABD\\u0AD0\\u0AE0\\u0AE1\\u0B05-\\u0B0C\\u0B0F\\u0B10\\u0B13-\\u0B28\\u0B2A-\\u0B30\\u0B32\\u0B33\\u0B35-\\u0B39\\u0B3D\\u0B5C\\u0B5D\\u0B5F-\\u0B61\\u0B71\\u0B83\\u0B85-\\u0B8A\\u0B8E-\\u0B90\\u0B92-\\u0B95\\u0B99\\u0B9A\\u0B9C\\u0B9E\\u0B9F\\u0BA3\\u0BA4\\u0BA8-\\u0BAA\\u0BAE-\\u0BB9\\u0BD0\\u0C05-\\u0C0C\\u0C0E-\\u0C10\\u0C12-\\u0C28\\u0C2A-\\u0C39\\u0C3D\\u0C58\\u0C59\\u0C60\\u0C61\\u0C85-\\u0C8C\\u0C8E-\\u0C90\\u0C92-\\u0CA8\\u0CAA-\\u0CB3\\u0CB5-\\u0CB9\\u0CBD\\u0CDE\\u0CE0\\u0CE1\\u0CF1\\u0CF2\\u0D05-\\u0D0C\\u0D0E-\\u0D10\\u0D12-\\u0D3A\\u0D3D\\u0D4E\\u0D60\\u0D61\\u0D7A-\\u0D7F\\u0D85-\\u0D96\\u0D9A-\\u0DB1\\u0DB3-\\u0DBB\\u0DBD\\u0DC0-\\u0DC6\\u0E01-\\u0E30\\u0E32\\u0E33\\u0E40-\\u0E46\\u0E81\\u0E82\\u0E84\\u0E87\\u0E88\\u0E8A\\u0E8D\\u0E94-\\u0E97\\u0E99-\\u0E9F\\u0EA1-\\u0EA3\\u0EA5\\u0EA7\\u0EAA\\u0EAB\\u0EAD-\\u0EB0\\u0EB2\\u0EB3\\u0EBD\\u0EC0-\\u0EC4\\u0EC6\\u0EDC-\\u0EDF\\u0F00\\u0F40-\\u0F47\\u0F49-\\u0F6C\\u0F88-\\u0F8C\\u1000-\\u102A\\u103F\\u1050-\\u1055\\u105A-\\u105D\\u1061\\u1065\\u1066\\u106E-\\u1070\\u1075-\\u1081\\u108E\\u10A0-\\u10C5\\u10C7\\u10CD\\u10D0-\\u10FA\\u10FC-\\u1248\\u124A-\\u124D\\u1250-\\u1256\\u1258\\u125A-\\u125D\\u1260-\\u1288\\u128A-\\u128D\\u1290-\\u12B0\\u12B2-\\u12B5\\u12B8-\\u12BE\\u12C0\\u12C2-\\u12C5\\u12C8-\\u12D6\\u12D8-\\u1310\\u1312-\\u1315\\u1318-\\u135A\\u1380-\\u138F\\u13A0-\\u13F4\\u1401-\\u166C\\u166F-\\u167F\\u1681-\\u169A\\u16A0-\\u16EA\\u16EE-\\u16F8\\u1700-\\u170C\\u170E-\\u1711\\u1720-\\u1731\\u1740-\\u1751\\u1760-\\u176C\\u176E-\\u1770\\u1780-\\u17B3\\u17D7\\u17DC\\u1820-\\u1877\\u1880-\\u18A8\\u18AA\\u18B0-\\u18F5\\u1900-\\u191E\\u1950-\\u196D\\u1970-\\u1974\\u1980-\\u19AB\\u19C1-\\u19C7\\u1A00-\\u1A16\\u1A20-\\u1A54\\u1AA7\\u1B05-\\u1B33\\u1B45-\\u1B4B\\u1B83-\\u1BA0\\u1BAE\\u1BAF\\u1BBA-\\u1BE5\\u1C00-\\u1C23\\u1C4D-\\u1C4F\\u1C5A-\\u1C7D\\u1CE9-\\u1CEC\\u1CEE-\\u1CF1\\u1CF5\\u1CF6\\u1D00-\\u1DBF\\u1E00-\\u1F15\\u1F18-\\u1F1D\\u1F20-\\u1F45\\u1F48-\\u1F4D\\u1F50-\\u1F57\\u1F59\\u1F5B\\u1F5D\\u1F5F-\\u1F7D\\u1F80-\\u1FB4\\u1FB6-\\u1FBC\\u1FBE\\u1FC2-\\u1FC4\\u1FC6-\\u1FCC\\u1FD0-\\u1FD3\\u1FD6-\\u1FDB\\u1FE0-\\u1FEC\\u1FF2-\\u1FF4\\u1FF6-\\u1FFC\\u2071\\u207F\\u2090-\\u209C\\u2102\\u2107\\u210A-\\u2113\\u2115\\u2119-\\u211D\\u2124\\u2126\\u2128\\u212A-\\u212D\\u212F-\\u2139\\u213C-\\u213F\\u2145-\\u2149\\u214E\\u2160-\\u2188\\u2C00-\\u2C2E\\u2C30-\\u2C5E\\u2C60-\\u2CE4\\u2CEB-\\u2CEE\\u2CF2\\u2CF3\\u2D00-\\u2D25\\u2D27\\u2D2D\\u2D30-\\u2D67\\u2D6F\\u2D80-\\u2D96\\u2DA0-\\u2DA6\\u2DA8-\\u2DAE\\u2DB0-\\u2DB6\\u2DB8-\\u2DBE\\u2DC0-\\u2DC6\\u2DC8-\\u2DCE\\u2DD0-\\u2DD6\\u2DD8-\\u2DDE\\u2E2F\\u3005-\\u3007\\u3021-\\u3029\\u3031-\\u3035\\u3038-\\u303C\\u3041-\\u3096\\u309D-\\u309F\\u30A1-\\u30FA\\u30FC-\\u30FF\\u3105-\\u312D\\u3131-\\u318E\\u31A0-\\u31BA\\u31F0-\\u31FF\\u3400-\\u4DB5\\u4E00-\\u9FCC\\uA000-\\uA48C\\uA4D0-\\uA4FD\\uA500-\\uA60C\\uA610-\\uA61F\\uA62A\\uA62B\\uA640-\\uA66E\\uA67F-\\uA69D\\uA6A0-\\uA6EF\\uA717-\\uA71F\\uA722-\\uA788\\uA78B-\\uA78E\\uA790-\\uA7AD\\uA7B0\\uA7B1\\uA7F7-\\uA801\\uA803-\\uA805\\uA807-\\uA80A\\uA80C-\\uA822\\uA840-\\uA873\\uA882-\\uA8B3\\uA8F2-\\uA8F7\\uA8FB\\uA90A-\\uA925\\uA930-\\uA946\\uA960-\\uA97C\\uA984-\\uA9B2\\uA9CF\\uA9E0-\\uA9E4\\uA9E6-\\uA9EF\\uA9FA-\\uA9FE\\uAA00-\\uAA28\\uAA40-\\uAA42\\uAA44-\\uAA4B\\uAA60-\\uAA76\\uAA7A\\uAA7E-\\uAAAF\\uAAB1\\uAAB5\\uAAB6\\uAAB9-\\uAABD\\uAAC0\\uAAC2\\uAADB-\\uAADD\\uAAE0-\\uAAEA\\uAAF2-\\uAAF4\\uAB01-\\uAB06\\uAB09-\\uAB0E\\uAB11-\\uAB16\\uAB20-\\uAB26\\uAB28-\\uAB2E\\uAB30-\\uAB5A\\uAB5C-\\uAB5F\\uAB64\\uAB65\\uABC0-\\uABE2\\uAC00-\\uD7A3\\uD7B0-\\uD7C6\\uD7CB-\\uD7FB\\uF900-\\uFA6D\\uFA70-\\uFAD9\\uFB00-\\uFB06\\uFB13-\\uFB17\\uFB1D\\uFB1F-\\uFB28\\uFB2A-\\uFB36\\uFB38-\\uFB3C\\uFB3E\\uFB40\\uFB41\\uFB43\\uFB44\\uFB46-\\uFBB1\\uFBD3-\\uFD3D\\uFD50-\\uFD8F\\uFD92-\\uFDC7\\uFDF0-\\uFDFB\\uFE70-\\uFE74\\uFE76-\\uFEFC\\uFF21-\\uFF3A\\uFF41-\\uFF5A\\uFF66-\\uFFBE\\uFFC2-\\uFFC7\\uFFCA-\\uFFCF\\uFFD2-\\uFFD7\\uFFDA-\\uFFDC]"),ST=new RegExp("[\\xAA\\xB5\\xBA\\xC0-\\xD6\\xD8-\\xF6\\xF8-\\u02C1\\u02C6-\\u02D1\\u02E0-\\u02E4\\u02EC\\u02EE\\u0300-\\u0374\\u0376\\u0377\\u037A-\\u037D\\u037F\\u0386\\u0388-\\u038A\\u038C\\u038E-\\u03A1\\u03A3-\\u03F5\\u03F7-\\u0481\\u0483-\\u0487\\u048A-\\u052F\\u0531-\\u0556\\u0559\\u0561-\\u0587\\u0591-\\u05BD\\u05BF\\u05C1\\u05C2\\u05C4\\u05C5\\u05C7\\u05D0-\\u05EA\\u05F0-\\u05F2\\u0610-\\u061A\\u0620-\\u0669\\u066E-\\u06D3\\u06D5-\\u06DC\\u06DF-\\u06E8\\u06EA-\\u06FC\\u06FF\\u0710-\\u074A\\u074D-\\u07B1\\u07C0-\\u07F5\\u07FA\\u0800-\\u082D\\u0840-\\u085B\\u08A0-\\u08B2\\u08E4-\\u0963\\u0966-\\u096F\\u0971-\\u0983\\u0985-\\u098C\\u098F\\u0990\\u0993-\\u09A8\\u09AA-\\u09B0\\u09B2\\u09B6-\\u09B9\\u09BC-\\u09C4\\u09C7\\u09C8\\u09CB-\\u09CE\\u09D7\\u09DC\\u09DD\\u09DF-\\u09E3\\u09E6-\\u09F1\\u0A01-\\u0A03\\u0A05-\\u0A0A\\u0A0F\\u0A10\\u0A13-\\u0A28\\u0A2A-\\u0A30\\u0A32\\u0A33\\u0A35\\u0A36\\u0A38\\u0A39\\u0A3C\\u0A3E-\\u0A42\\u0A47\\u0A48\\u0A4B-\\u0A4D\\u0A51\\u0A59-\\u0A5C\\u0A5E\\u0A66-\\u0A75\\u0A81-\\u0A83\\u0A85-\\u0A8D\\u0A8F-\\u0A91\\u0A93-\\u0AA8\\u0AAA-\\u0AB0\\u0AB2\\u0AB3\\u0AB5-\\u0AB9\\u0ABC-\\u0AC5\\u0AC7-\\u0AC9\\u0ACB-\\u0ACD\\u0AD0\\u0AE0-\\u0AE3\\u0AE6-\\u0AEF\\u0B01-\\u0B03\\u0B05-\\u0B0C\\u0B0F\\u0B10\\u0B13-\\u0B28\\u0B2A-\\u0B30\\u0B32\\u0B33\\u0B35-\\u0B39\\u0B3C-\\u0B44\\u0B47\\u0B48\\u0B4B-\\u0B4D\\u0B56\\u0B57\\u0B5C\\u0B5D\\u0B5F-\\u0B63\\u0B66-\\u0B6F\\u0B71\\u0B82\\u0B83\\u0B85-\\u0B8A\\u0B8E-\\u0B90\\u0B92-\\u0B95\\u0B99\\u0B9A\\u0B9C\\u0B9E\\u0B9F\\u0BA3\\u0BA4\\u0BA8-\\u0BAA\\u0BAE-\\u0BB9\\u0BBE-\\u0BC2\\u0BC6-\\u0BC8\\u0BCA-\\u0BCD\\u0BD0\\u0BD7\\u0BE6-\\u0BEF\\u0C00-\\u0C03\\u0C05-\\u0C0C\\u0C0E-\\u0C10\\u0C12-\\u0C28\\u0C2A-\\u0C39\\u0C3D-\\u0C44\\u0C46-\\u0C48\\u0C4A-\\u0C4D\\u0C55\\u0C56\\u0C58\\u0C59\\u0C60-\\u0C63\\u0C66-\\u0C6F\\u0C81-\\u0C83\\u0C85-\\u0C8C\\u0C8E-\\u0C90\\u0C92-\\u0CA8\\u0CAA-\\u0CB3\\u0CB5-\\u0CB9\\u0CBC-\\u0CC4\\u0CC6-\\u0CC8\\u0CCA-\\u0CCD\\u0CD5\\u0CD6\\u0CDE\\u0CE0-\\u0CE3\\u0CE6-\\u0CEF\\u0CF1\\u0CF2\\u0D01-\\u0D03\\u0D05-\\u0D0C\\u0D0E-\\u0D10\\u0D12-\\u0D3A\\u0D3D-\\u0D44\\u0D46-\\u0D48\\u0D4A-\\u0D4E\\u0D57\\u0D60-\\u0D63\\u0D66-\\u0D6F\\u0D7A-\\u0D7F\\u0D82\\u0D83\\u0D85-\\u0D96\\u0D9A-\\u0DB1\\u0DB3-\\u0DBB\\u0DBD\\u0DC0-\\u0DC6\\u0DCA\\u0DCF-\\u0DD4\\u0DD6\\u0DD8-\\u0DDF\\u0DE6-\\u0DEF\\u0DF2\\u0DF3\\u0E01-\\u0E3A\\u0E40-\\u0E4E\\u0E50-\\u0E59\\u0E81\\u0E82\\u0E84\\u0E87\\u0E88\\u0E8A\\u0E8D\\u0E94-\\u0E97\\u0E99-\\u0E9F\\u0EA1-\\u0EA3\\u0EA5\\u0EA7\\u0EAA\\u0EAB\\u0EAD-\\u0EB9\\u0EBB-\\u0EBD\\u0EC0-\\u0EC4\\u0EC6\\u0EC8-\\u0ECD\\u0ED0-\\u0ED9\\u0EDC-\\u0EDF\\u0F00\\u0F18\\u0F19\\u0F20-\\u0F29\\u0F35\\u0F37\\u0F39\\u0F3E-\\u0F47\\u0F49-\\u0F6C\\u0F71-\\u0F84\\u0F86-\\u0F97\\u0F99-\\u0FBC\\u0FC6\\u1000-\\u1049\\u1050-\\u109D\\u10A0-\\u10C5\\u10C7\\u10CD\\u10D0-\\u10FA\\u10FC-\\u1248\\u124A-\\u124D\\u1250-\\u1256\\u1258\\u125A-\\u125D\\u1260-\\u1288\\u128A-\\u128D\\u1290-\\u12B0\\u12B2-\\u12B5\\u12B8-\\u12BE\\u12C0\\u12C2-\\u12C5\\u12C8-\\u12D6\\u12D8-\\u1310\\u1312-\\u1315\\u1318-\\u135A\\u135D-\\u135F\\u1380-\\u138F\\u13A0-\\u13F4\\u1401-\\u166C\\u166F-\\u167F\\u1681-\\u169A\\u16A0-\\u16EA\\u16EE-\\u16F8\\u1700-\\u170C\\u170E-\\u1714\\u1720-\\u1734\\u1740-\\u1753\\u1760-\\u176C\\u176E-\\u1770\\u1772\\u1773\\u1780-\\u17D3\\u17D7\\u17DC\\u17DD\\u17E0-\\u17E9\\u180B-\\u180D\\u1810-\\u1819\\u1820-\\u1877\\u1880-\\u18AA\\u18B0-\\u18F5\\u1900-\\u191E\\u1920-\\u192B\\u1930-\\u193B\\u1946-\\u196D\\u1970-\\u1974\\u1980-\\u19AB\\u19B0-\\u19C9\\u19D0-\\u19D9\\u1A00-\\u1A1B\\u1A20-\\u1A5E\\u1A60-\\u1A7C\\u1A7F-\\u1A89\\u1A90-\\u1A99\\u1AA7\\u1AB0-\\u1ABD\\u1B00-\\u1B4B\\u1B50-\\u1B59\\u1B6B-\\u1B73\\u1B80-\\u1BF3\\u1C00-\\u1C37\\u1C40-\\u1C49\\u1C4D-\\u1C7D\\u1CD0-\\u1CD2\\u1CD4-\\u1CF6\\u1CF8\\u1CF9\\u1D00-\\u1DF5\\u1DFC-\\u1F15\\u1F18-\\u1F1D\\u1F20-\\u1F45\\u1F48-\\u1F4D\\u1F50-\\u1F57\\u1F59\\u1F5B\\u1F5D\\u1F5F-\\u1F7D\\u1F80-\\u1FB4\\u1FB6-\\u1FBC\\u1FBE\\u1FC2-\\u1FC4\\u1FC6-\\u1FCC\\u1FD0-\\u1FD3\\u1FD6-\\u1FDB\\u1FE0-\\u1FEC\\u1FF2-\\u1FF4\\u1FF6-\\u1FFC\\u200C\\u200D\\u203F\\u2040\\u2054\\u2071\\u207F\\u2090-\\u209C\\u20D0-\\u20DC\\u20E1\\u20E5-\\u20F0\\u2102\\u2107\\u210A-\\u2113\\u2115\\u2119-\\u211D\\u2124\\u2126\\u2128\\u212A-\\u212D\\u212F-\\u2139\\u213C-\\u213F\\u2145-\\u2149\\u214E\\u2160-\\u2188\\u2C00-\\u2C2E\\u2C30-\\u2C5E\\u2C60-\\u2CE4\\u2CEB-\\u2CF3\\u2D00-\\u2D25\\u2D27\\u2D2D\\u2D30-\\u2D67\\u2D6F\\u2D7F-\\u2D96\\u2DA0-\\u2DA6\\u2DA8-\\u2DAE\\u2DB0-\\u2DB6\\u2DB8-\\u2DBE\\u2DC0-\\u2DC6\\u2DC8-\\u2DCE\\u2DD0-\\u2DD6\\u2DD8-\\u2DDE\\u2DE0-\\u2DFF\\u2E2F\\u3005-\\u3007\\u3021-\\u302F\\u3031-\\u3035\\u3038-\\u303C\\u3041-\\u3096\\u3099\\u309A\\u309D-\\u309F\\u30A1-\\u30FA\\u30FC-\\u30FF\\u3105-\\u312D\\u3131-\\u318E\\u31A0-\\u31BA\\u31F0-\\u31FF\\u3400-\\u4DB5\\u4E00-\\u9FCC\\uA000-\\uA48C\\uA4D0-\\uA4FD\\uA500-\\uA60C\\uA610-\\uA62B\\uA640-\\uA66F\\uA674-\\uA67D\\uA67F-\\uA69D\\uA69F-\\uA6F1\\uA717-\\uA71F\\uA722-\\uA788\\uA78B-\\uA78E\\uA790-\\uA7AD\\uA7B0\\uA7B1\\uA7F7-\\uA827\\uA840-\\uA873\\uA880-\\uA8C4\\uA8D0-\\uA8D9\\uA8E0-\\uA8F7\\uA8FB\\uA900-\\uA92D\\uA930-\\uA953\\uA960-\\uA97C\\uA980-\\uA9C0\\uA9CF-\\uA9D9\\uA9E0-\\uA9FE\\uAA00-\\uAA36\\uAA40-\\uAA4D\\uAA50-\\uAA59\\uAA60-\\uAA76\\uAA7A-\\uAAC2\\uAADB-\\uAADD\\uAAE0-\\uAAEF\\uAAF2-\\uAAF6\\uAB01-\\uAB06\\uAB09-\\uAB0E\\uAB11-\\uAB16\\uAB20-\\uAB26\\uAB28-\\uAB2E\\uAB30-\\uAB5A\\uAB5C-\\uAB5F\\uAB64\\uAB65\\uABC0-\\uABEA\\uABEC\\uABED\\uABF0-\\uABF9\\uAC00-\\uD7A3\\uD7B0-\\uD7C6\\uD7CB-\\uD7FB\\uF900-\\uFA6D\\uFA70-\\uFAD9\\uFB00-\\uFB06\\uFB13-\\uFB17\\uFB1D-\\uFB28\\uFB2A-\\uFB36\\uFB38-\\uFB3C\\uFB3E\\uFB40\\uFB41\\uFB43\\uFB44\\uFB46-\\uFBB1\\uFBD3-\\uFD3D\\uFD50-\\uFD8F\\uFD92-\\uFDC7\\uFDF0-\\uFDFB\\uFE00-\\uFE0F\\uFE20-\\uFE2D\\uFE33\\uFE34\\uFE4D-\\uFE4F\\uFE70-\\uFE74\\uFE76-\\uFEFC\\uFF10-\\uFF19\\uFF21-\\uFF3A\\uFF3F\\uFF41-\\uFF5A\\uFF66-\\uFFBE\\uFFC2-\\uFFC7\\uFFCA-\\uFFCF\\uFFD2-\\uFFD7\\uFFDA-\\uFFDC]");function dc(t,e){if(!t)throw new Error("ASSERT: "+e)}function xr(t){return t>=48&&t<=57}function pp(t){return"0123456789abcdefABCDEF".indexOf(t)>=0}function ps(t){return"01234567".indexOf(t)>=0}function CT(t){return t===32||t===9||t===11||t===12||t===160||t>=5760&&[5760,6158,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279].indexOf(t)>=0}function Gs(t){return t===10||t===13||t===8232||t===8233}function kl(t){return t===36||t===95||t>=65&&t<=90||t>=97&&t<=122||t===92||t>=128&&AT.test(String.fromCharCode(t))}function ff(t){return t===36||t===95||t>=65&&t<=90||t>=97&&t<=122||t>=48&&t<=57||t===92||t>=128&&ST.test(String.fromCharCode(t))}const TT={if:1,in:1,do:1,var:1,for:1,new:1,try:1,let:1,this:1,else:1,case:1,void:1,with:1,enum:1,while:1,break:1,catch:1,throw:1,const:1,yield:1,class:1,super:1,return:1,typeof:1,delete:1,switch:1,export:1,import:1,public:1,static:1,default:1,finally:1,extends:1,package:1,private:1,function:1,continue:1,debugger:1,interface:1,protected:1,instanceof:1,implements:1};function hx(){for(;U<_t;){const t=te.charCodeAt(U);if(CT(t)||Gs(t))++U;else break}}function qd(t){var e,n,r,i=0;for(n=t==="u"?4:2,e=0;e<n;++e)U<_t&&pp(te[U])?(r=te[U++],i=i*16+"0123456789abcdef".indexOf(r.toLowerCase())):we({},st,dt);return String.fromCharCode(i)}function FT(){var t,e,n,r;for(t=te[U],e=0,t==="}"&&we({},st,dt);U<_t&&(t=te[U++],!!pp(t));)e=e*16+"0123456789abcdef".indexOf(t.toLowerCase());return(e>1114111||t!=="}")&&we({},st,dt),e<=65535?String.fromCharCode(e):(n=(e-65536>>10)+55296,r=(e-65536&1023)+56320,String.fromCharCode(n,r))}function dx(){var t,e;for(t=te.charCodeAt(U++),e=String.fromCharCode(t),t===92&&(te.charCodeAt(U)!==117&&we({},st,dt),++U,t=qd("u"),(!t||t==="\\"||!kl(t.charCodeAt(0)))&&we({},st,dt),e=t);U<_t&&(t=te.charCodeAt(U),!!ff(t));)++U,e+=String.fromCharCode(t),t===92&&(e=e.substr(0,e.length-1),te.charCodeAt(U)!==117&&we({},st,dt),++U,t=qd("u"),(!t||t==="\\"||!ff(t.charCodeAt(0)))&&we({},st,dt),e+=t);return e}function IT(){var t,e;for(t=U++;U<_t;){if(e=te.charCodeAt(U),e===92)return U=t,dx();if(ff(e))++U;else break}return te.slice(t,U)}function kT(){var t,e,n;return t=U,e=te.charCodeAt(U)===92?dx():IT(),e.length===1?n=na:TT.hasOwnProperty(e)?n=bi:e==="null"?n=hc:e==="true"||e==="false"?n=cc:n=na,{type:n,value:e,start:t,end:U}}function dh(){var t=U,e=te.charCodeAt(U),n,r=te[U],i,a,o;switch(e){case 46:case 40:case 41:case 59:case 44:case 123:case 125:case 91:case 93:case 58:case 63:case 126:return++U,{type:$t,value:String.fromCharCode(e),start:t,end:U};default:if(n=te.charCodeAt(U+1),n===61)switch(e){case 43:case 45:case 47:case 60:case 62:case 94:case 124:case 37:case 38:case 42:return U+=2,{type:$t,value:String.fromCharCode(e)+String.fromCharCode(n),start:t,end:U};case 33:case 61:return U+=2,te.charCodeAt(U)===61&&++U,{type:$t,value:te.slice(t,U),start:t,end:U}}}if(o=te.substr(U,4),o===">>>=")return U+=4,{type:$t,value:o,start:t,end:U};if(a=o.substr(0,3),a===">>>"||a==="<<="||a===">>=")return U+=3,{type:$t,value:a,start:t,end:U};if(i=a.substr(0,2),r===i[1]&&"+-<>&|".indexOf(r)>=0||i==="=>")return U+=2,{type:$t,value:i,start:t,end:U};if(i==="//"&&we({},st,dt),"<>=!+-*%&|^/".indexOf(r)>=0)return++U,{type:$t,value:r,start:t,end:U};we({},st,dt)}function RT(t){let e="";for(;U<_t&&pp(te[U]);)e+=te[U++];return e.length===0&&we({},st,dt),kl(te.charCodeAt(U))&&we({},st,dt),{type:ba,value:parseInt("0x"+e,16),start:t,end:U}}function DT(t){let e="0"+te[U++];for(;U<_t&&ps(te[U]);)e+=te[U++];return(kl(te.charCodeAt(U))||xr(te.charCodeAt(U)))&&we({},st,dt),{type:ba,value:parseInt(e,8),octal:!0,start:t,end:U}}function Vm(){var t,e,n;if(n=te[U],dc(xr(n.charCodeAt(0))||n===".","Numeric literal must start with a decimal digit or a decimal point"),e=U,t="",n!=="."){if(t=te[U++],n=te[U],t==="0"){if(n==="x"||n==="X")return++U,RT(e);if(ps(n))return DT(e);n&&xr(n.charCodeAt(0))&&we({},st,dt)}for(;xr(te.charCodeAt(U));)t+=te[U++];n=te[U]}if(n==="."){for(t+=te[U++];xr(te.charCodeAt(U));)t+=te[U++];n=te[U]}if(n==="e"||n==="E")if(t+=te[U++],n=te[U],(n==="+"||n==="-")&&(t+=te[U++]),xr(te.charCodeAt(U)))for(;xr(te.charCodeAt(U));)t+=te[U++];else we({},st,dt);return kl(te.charCodeAt(U))&&we({},st,dt),{type:ba,value:parseFloat(t),start:e,end:U}}function BT(){var t="",e,n,r,i,a=!1;for(e=te[U],dc(e==="'"||e==='"',"String literal must starts with a quote"),n=U,++U;U<_t;)if(r=te[U++],r===e){e="";break}else if(r==="\\")if(r=te[U++],!r||!Gs(r.charCodeAt(0)))switch(r){case"u":case"x":te[U]==="{"?(++U,t+=FT()):t+=qd(r);break;case"n":t+=` -`;break;case"r":t+="\r";break;case"t":t+=" ";break;case"b":t+="\b";break;case"f":t+="\f";break;case"v":t+="\v";break;default:ps(r)?(i="01234567".indexOf(r),i!==0&&(a=!0),U<_t&&ps(te[U])&&(a=!0,i=i*8+"01234567".indexOf(te[U++]),"0123".indexOf(r)>=0&&U<_t&&ps(te[U])&&(i=i*8+"01234567".indexOf(te[U++]))),t+=String.fromCharCode(i)):t+=r;break}else r==="\r"&&te[U]===` -`&&++U;else{if(Gs(r.charCodeAt(0)))break;t+=r}return e!==""&&we({},st,dt),{type:Il,value:t,octal:a,start:n,end:U}}function NT(t,e){let n=t;e.indexOf("u")>=0&&(n=n.replace(/\\u\{([0-9a-fA-F]+)\}/g,(r,i)=>{if(parseInt(i,16)<=1114111)return"x";we({},Ud)}).replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,"x"));try{new RegExp(n)}catch{we({},Ud)}try{return new RegExp(t,e)}catch{return null}}function $T(){var t,e,n,r,i;for(t=te[U],dc(t==="/","Regular expression literal must start with a slash"),e=te[U++],n=!1,r=!1;U<_t;)if(t=te[U++],e+=t,t==="\\")t=te[U++],Gs(t.charCodeAt(0))&&we({},hh),e+=t;else if(Gs(t.charCodeAt(0)))we({},hh);else if(n)t==="]"&&(n=!1);else if(t==="/"){r=!0;break}else t==="["&&(n=!0);return r||we({},hh),i=e.substr(1,e.length-2),{value:i,literal:e}}function OT(){var t,e,n;for(e="",n="";U<_t&&(t=te[U],!!ff(t.charCodeAt(0)));)++U,t==="\\"&&U<_t?we({},st,dt):(n+=t,e+=t);return n.search(/[^gimuy]/g)>=0&&we({},Ud,n),{value:n,literal:e}}function LT(){var t,e,n,r;return Te=null,hx(),t=U,e=$T(),n=OT(),r=NT(e.value,n.value),{literal:e.literal+n.literal,value:r,regex:{pattern:e.value,flags:n.value},start:t,end:U}}function MT(t){return t.type===na||t.type===bi||t.type===cc||t.type===hc}function px(){if(hx(),U>=_t)return{type:Fl,start:U,end:U};const t=te.charCodeAt(U);return kl(t)?kT():t===40||t===41||t===59?dh():t===39||t===34?BT():t===46?xr(te.charCodeAt(U+1))?Vm():dh():xr(t)?Vm():dh()}function Ot(){const t=Te;return U=t.end,Te=px(),U=t.end,t}function gx(){const t=U;Te=px(),U=t}function PT(t){const e=new Nn(lT);return e.elements=t,e}function Hm(t,e,n){const r=new Nn(t==="||"||t==="&&"?dT:uT);return r.operator=t,r.left=e,r.right=n,r}function zT(t,e){const n=new Nn(fT);return n.callee=t,n.arguments=e,n}function UT(t,e,n){const r=new Nn(cT);return r.test=t,r.consequent=e,r.alternate=n,r}function gp(t){const e=new Nn(fx);return e.name=t,e}function os(t){const e=new Nn(hT);return e.value=t.value,e.raw=te.slice(t.start,t.end),t.regex&&(e.raw==="//"&&(e.raw="/(?:)/"),e.regex=t.regex),e}function Gm(t,e,n){const r=new Nn(pT);return r.computed=t==="[",r.object=e,r.property=n,r.computed||(n.member=!0),r}function qT(t){const e=new Nn(gT);return e.properties=t,e}function jm(t,e,n){const r=new Nn(mT);return r.key=e,r.value=n,r.kind=t,r}function VT(t,e){const n=new Nn(bT);return n.operator=t,n.argument=e,n.prefix=!0,n}function we(t,e){var n,r=Array.prototype.slice.call(arguments,2),i=e.replace(/%(\d)/g,(a,o)=>(dc(o<r.length,"Message reference must be in range"),r[o]));throw n=new Error(i),n.index=U,n.description=i,n}function pc(t){t.type===Fl&&we(t,vT),t.type===ba&&we(t,yT),t.type===Il&&we(t,wT),t.type===na&&we(t,xT),t.type===bi&&we(t,_T),we(t,st,t.value)}function vt(t){const e=Ot();(e.type!==$t||e.value!==t)&&pc(e)}function Le(t){return Te.type===$t&&Te.value===t}function ph(t){return Te.type===bi&&Te.value===t}function HT(){const t=[];for(U=Te.start,vt("[");!Le("]");)Le(",")?(Ot(),t.push(null)):(t.push(ra()),Le("]")||vt(","));return Ot(),PT(t)}function Wm(){U=Te.start;const t=Ot();return t.type===Il||t.type===ba?(t.octal&&we(t,cx),os(t)):gp(t.value)}function GT(){var t,e,n,r;if(U=Te.start,t=Te,t.type===na)return n=Wm(),vt(":"),r=ra(),jm("init",n,r);if(t.type===Fl||t.type===$t)pc(t);else return e=Wm(),vt(":"),r=ra(),jm("init",e,r)}function jT(){var t=[],e,n,r,i={},a=String;for(U=Te.start,vt("{");!Le("}");)e=GT(),e.key.type===fx?n=e.key.name:n=a(e.key.value),r="$"+n,Object.prototype.hasOwnProperty.call(i,r)?we({},ET):i[r]=!0,t.push(e),Le("}")||vt(",");return vt("}"),qT(t)}function WT(){vt("(");const t=mp();return vt(")"),t}const ZT={if:1};function YT(){var t,e,n;if(Le("("))return WT();if(Le("["))return HT();if(Le("{"))return jT();if(t=Te.type,U=Te.start,t===na||ZT[Te.value])n=gp(Ot().value);else if(t===Il||t===ba)Te.octal&&we(Te,cx),n=os(Ot());else{if(t===bi)throw new Error(Hs);t===cc?(e=Ot(),e.value=e.value==="true",n=os(e)):t===hc?(e=Ot(),e.value=null,n=os(e)):Le("/")||Le("/=")?(n=os(LT()),gx()):pc(Ot())}return n}function XT(){const t=[];if(vt("("),!Le(")"))for(;U<_t&&(t.push(ra()),!Le(")"));)vt(",");return vt(")"),t}function KT(){U=Te.start;const t=Ot();return MT(t)||pc(t),gp(t.value)}function JT(){return vt("."),KT()}function QT(){vt("[");const t=mp();return vt("]"),t}function eF(){var t,e,n;for(t=YT();;)if(Le("."))n=JT(),t=Gm(".",t,n);else if(Le("("))e=XT(),t=zT(t,e);else if(Le("["))n=QT(),t=Gm("[",t,n);else break;return t}function Zm(){const t=eF();if(Te.type===$t&&(Le("++")||Le("--")))throw new Error(Hs);return t}function Lu(){var t,e;if(Te.type!==$t&&Te.type!==bi)e=Zm();else{if(Le("++")||Le("--"))throw new Error(Hs);if(Le("+")||Le("-")||Le("~")||Le("!"))t=Ot(),e=Lu(),e=VT(t.value,e);else{if(ph("delete")||ph("void")||ph("typeof"))throw new Error(Hs);e=Zm()}}return e}function Ym(t){let e=0;if(t.type!==$t&&t.type!==bi)return 0;switch(t.value){case"||":e=1;break;case"&&":e=2;break;case"|":e=3;break;case"^":e=4;break;case"&":e=5;break;case"==":case"!=":case"===":case"!==":e=6;break;case"<":case">":case"<=":case">=":case"instanceof":case"in":e=7;break;case"<<":case">>":case">>>":e=8;break;case"+":case"-":e=9;break;case"*":case"/":case"%":e=11;break}return e}function tF(){var t,e,n,r,i,a,o,s,u,l;if(t=Te,u=Lu(),r=Te,i=Ym(r),i===0)return u;for(r.prec=i,Ot(),e=[t,Te],o=Lu(),a=[u,r,o];(i=Ym(Te))>0;){for(;a.length>2&&i<=a[a.length-2].prec;)o=a.pop(),s=a.pop().value,u=a.pop(),e.pop(),n=Hm(s,u,o),a.push(n);r=Ot(),r.prec=i,a.push(r),e.push(Te),n=Lu(),a.push(n)}for(l=a.length-1,n=a[l],e.pop();l>1;)e.pop(),n=Hm(a[l-1].value,a[l-2],n),l-=2;return n}function ra(){var t,e,n;return t=tF(),Le("?")&&(Ot(),e=ra(),vt(":"),n=ra(),t=UT(t,e,n)),t}function mp(){const t=ra();if(Le(","))throw new Error(Hs);return t}function nF(t){te=t,U=0,_t=te.length,Te=null,gx();const e=mp();if(Te.type!==Fl)throw new Error("Unexpect token after expression.");return e}var rF={NaN:"NaN",E:"Math.E",LN2:"Math.LN2",LN10:"Math.LN10",LOG2E:"Math.LOG2E",LOG10E:"Math.LOG10E",PI:"Math.PI",SQRT1_2:"Math.SQRT1_2",SQRT2:"Math.SQRT2",MIN_VALUE:"Number.MIN_VALUE",MAX_VALUE:"Number.MAX_VALUE"};function iF(t){function e(o,s,u,l){let f=t(s[0]);return u&&(f=u+"("+f+")",u.lastIndexOf("new ",0)===0&&(f="("+f+")")),f+"."+o+(l<0?"":l===0?"()":"("+s.slice(1).map(t).join(",")+")")}function n(o,s,u){return l=>e(o,l,s,u)}const r="new Date",i="String",a="RegExp";return{isNaN:"Number.isNaN",isFinite:"Number.isFinite",abs:"Math.abs",acos:"Math.acos",asin:"Math.asin",atan:"Math.atan",atan2:"Math.atan2",ceil:"Math.ceil",cos:"Math.cos",exp:"Math.exp",floor:"Math.floor",hypot:"Math.hypot",log:"Math.log",max:"Math.max",min:"Math.min",pow:"Math.pow",random:"Math.random",round:"Math.round",sin:"Math.sin",sqrt:"Math.sqrt",tan:"Math.tan",clamp:function(o){o.length<3&&je("Missing arguments to clamp function."),o.length>3&&je("Too many arguments to clamp function.");const s=o.map(t);return"Math.max("+s[1]+", Math.min("+s[2]+","+s[0]+"))"},now:"Date.now",utc:"Date.UTC",datetime:r,date:n("getDate",r,0),day:n("getDay",r,0),year:n("getFullYear",r,0),month:n("getMonth",r,0),hours:n("getHours",r,0),minutes:n("getMinutes",r,0),seconds:n("getSeconds",r,0),milliseconds:n("getMilliseconds",r,0),time:n("getTime",r,0),timezoneoffset:n("getTimezoneOffset",r,0),utcdate:n("getUTCDate",r,0),utcday:n("getUTCDay",r,0),utcyear:n("getUTCFullYear",r,0),utcmonth:n("getUTCMonth",r,0),utchours:n("getUTCHours",r,0),utcminutes:n("getUTCMinutes",r,0),utcseconds:n("getUTCSeconds",r,0),utcmilliseconds:n("getUTCMilliseconds",r,0),length:n("length",null,-1),parseFloat:"parseFloat",parseInt:"parseInt",upper:n("toUpperCase",i,0),lower:n("toLowerCase",i,0),substring:n("substring",i),split:n("split",i),trim:n("trim",i,0),regexp:a,test:n("test",a),if:function(o){o.length<3&&je("Missing arguments to if function."),o.length>3&&je("Too many arguments to if function.");const s=o.map(t);return"("+s[0]+"?"+s[1]+":"+s[2]+")"}}}function aF(t){const e=t&&t.length-1;return e&&(t[0]==='"'&&t[e]==='"'||t[0]==="'"&&t[e]==="'")?t.slice(1,-1):t}function oF(t){t=t||{};const e=t.allowed?nf(t.allowed):{},n=t.forbidden?nf(t.forbidden):{},r=t.constants||rF,i=(t.functions||iF)(c),a=t.globalvar,o=t.fieldvar,s=qt(a)?a:p=>`${a}["${p}"]`;let u={},l={},f=0;function c(p){if(We(p))return p;const m=h[p.type];return m==null&&je("Unsupported type: "+p.type),m(p)}const h={Literal:p=>p.raw,Identifier:p=>{const m=p.name;return f>0?m:Ma(n,m)?je("Illegal identifier: "+m):Ma(r,m)?r[m]:Ma(e,m)?m:(u[m]=1,s(m))},MemberExpression:p=>{const m=!p.computed,y=c(p.object);m&&(f+=1);const w=c(p.property);return y===o&&(l[aF(w)]=1),m&&(f-=1),y+(m?"."+w:"["+w+"]")},CallExpression:p=>{p.callee.type!=="Identifier"&&je("Illegal callee type: "+p.callee.type);const m=p.callee.name,y=p.arguments,w=Ma(i,m)&&i[m];return w||je("Unrecognized function: "+m),qt(w)?w(y):w+"("+y.map(c).join(",")+")"},ArrayExpression:p=>"["+p.elements.map(c).join(",")+"]",BinaryExpression:p=>"("+c(p.left)+" "+p.operator+" "+c(p.right)+")",UnaryExpression:p=>"("+p.operator+c(p.argument)+")",ConditionalExpression:p=>"("+c(p.test)+"?"+c(p.consequent)+":"+c(p.alternate)+")",LogicalExpression:p=>"("+c(p.left)+p.operator+c(p.right)+")",ObjectExpression:p=>"{"+p.properties.map(c).join(",")+"}",Property:p=>{f+=1;const m=c(p.key);return f-=1,m+":"+c(p.value)}};function d(p){const m={code:c(p),globals:Object.keys(u),fields:Object.keys(l)};return u={},l={},m}return d.functions=i,d.constants=r,d}function bp(t,e={}){const n=oF({forbidden:[],allowed:["datum"],globalvar:"global",fieldvar:"datum"});try{const r=nF(t),i=n(r),a=Function("datum","global",`"use strict"; return (${i.code});`),o=s=>a(s,e);return o.fields=i.fields,o}catch(r){throw new Error(`Invalid expression: ${t}, ${r.message}`)}}function ur(t,e){switch(arguments.length){case 0:break;case 1:this.range(t);break;default:this.range(e).domain(t);break}return this}function yi(t,e){switch(arguments.length){case 0:break;case 1:{typeof t=="function"?this.interpolator(t):this.range(t);break}default:{this.domain(t),typeof e=="function"?this.interpolator(e):this.range(e);break}}return this}const Vd=Symbol("implicit");function yp(){var t=new ea,e=[],n=[],r=Vd;function i(a){let o=t.get(a);if(o===void 0){if(r!==Vd)return r;t.set(a,o=e.push(a)-1)}return n[o%n.length]}return i.domain=function(a){if(!arguments.length)return e.slice();e=[],t=new ea;for(const o of a)t.has(o)||t.set(o,e.push(o)-1);return i},i.range=function(a){return arguments.length?(n=Array.from(a),i):n.slice()},i.unknown=function(a){return arguments.length?(r=a,i):r},i.copy=function(){return yp(e,n).unknown(r)},ur.apply(i,arguments),i}function Ro(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function Rl(t,e){var n=Object.create(t.prototype);for(var r in e)n[r]=e[r];return n}function wi(){}var ia=.7,po=1/ia,Va="\\s*([+-]?\\d+)\\s*",js="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",er="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",sF=/^#([0-9a-f]{3,8})$/,lF=new RegExp(`^rgb\\(${Va},${Va},${Va}\\)$`),uF=new RegExp(`^rgb\\(${er},${er},${er}\\)$`),fF=new RegExp(`^rgba\\(${Va},${Va},${Va},${js}\\)$`),cF=new RegExp(`^rgba\\(${er},${er},${er},${js}\\)$`),hF=new RegExp(`^hsl\\(${js},${er},${er}\\)$`),dF=new RegExp(`^hsla\\(${js},${er},${er},${js}\\)$`),Xm={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};Ro(wi,fi,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:Km,formatHex:Km,formatHex8:pF,formatHsl:gF,formatRgb:Jm,toString:Jm});function Km(){return this.rgb().formatHex()}function pF(){return this.rgb().formatHex8()}function gF(){return mx(this).formatHsl()}function Jm(){return this.rgb().formatRgb()}function fi(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=sF.exec(t))?(n=e[1].length,e=parseInt(e[1],16),n===6?Qm(e):n===3?new lt(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):n===8?pu(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):n===4?pu(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|e&240,((e&15)<<4|e&15)/255):null):(e=lF.exec(t))?new lt(e[1],e[2],e[3],1):(e=uF.exec(t))?new lt(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=fF.exec(t))?pu(e[1],e[2],e[3],e[4]):(e=cF.exec(t))?pu(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=hF.exec(t))?n1(e[1],e[2]/100,e[3]/100,1):(e=dF.exec(t))?n1(e[1],e[2]/100,e[3]/100,e[4]):Xm.hasOwnProperty(t)?Qm(Xm[t]):t==="transparent"?new lt(NaN,NaN,NaN,0):null}function Qm(t){return new lt(t>>16&255,t>>8&255,t&255,1)}function pu(t,e,n,r){return r<=0&&(t=e=n=NaN),new lt(t,e,n,r)}function wp(t){return t instanceof wi||(t=fi(t)),t?(t=t.rgb(),new lt(t.r,t.g,t.b,t.opacity)):new lt}function cf(t,e,n,r){return arguments.length===1?wp(t):new lt(t,e,n,r??1)}function lt(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}Ro(lt,cf,Rl(wi,{brighter(t){return t=t==null?po:Math.pow(po,t),new lt(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?ia:Math.pow(ia,t),new lt(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new lt(Zi(this.r),Zi(this.g),Zi(this.b),hf(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:e1,formatHex:e1,formatHex8:mF,formatRgb:t1,toString:t1}));function e1(){return`#${$i(this.r)}${$i(this.g)}${$i(this.b)}`}function mF(){return`#${$i(this.r)}${$i(this.g)}${$i(this.b)}${$i((isNaN(this.opacity)?1:this.opacity)*255)}`}function t1(){const t=hf(this.opacity);return`${t===1?"rgb(":"rgba("}${Zi(this.r)}, ${Zi(this.g)}, ${Zi(this.b)}${t===1?")":`, ${t})`}`}function hf(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function Zi(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function $i(t){return t=Zi(t),(t<16?"0":"")+t.toString(16)}function n1(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new Tn(t,e,n,r)}function mx(t){if(t instanceof Tn)return new Tn(t.h,t.s,t.l,t.opacity);if(t instanceof wi||(t=fi(t)),!t)return new Tn;if(t instanceof Tn)return t;t=t.rgb();var e=t.r/255,n=t.g/255,r=t.b/255,i=Math.min(e,n,r),a=Math.max(e,n,r),o=NaN,s=a-i,u=(a+i)/2;return s?(e===a?o=(n-r)/s+(n<r)*6:n===a?o=(r-e)/s+2:o=(e-n)/s+4,s/=u<.5?a+i:2-a-i,o*=60):s=u>0&&u<1?0:o,new Tn(o,s,u,t.opacity)}function Hd(t,e,n,r){return arguments.length===1?mx(t):new Tn(t,e,n,r??1)}function Tn(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}Ro(Tn,Hd,Rl(wi,{brighter(t){return t=t==null?po:Math.pow(po,t),new Tn(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?ia:Math.pow(ia,t),new Tn(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+(this.h<0)*360,e=isNaN(t)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*e,i=2*n-r;return new lt(gh(t>=240?t-240:t+120,i,r),gh(t,i,r),gh(t<120?t+240:t-120,i,r),this.opacity)},clamp(){return new Tn(r1(this.h),gu(this.s),gu(this.l),hf(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const t=hf(this.opacity);return`${t===1?"hsl(":"hsla("}${r1(this.h)}, ${gu(this.s)*100}%, ${gu(this.l)*100}%${t===1?")":`, ${t})`}`}}));function r1(t){return t=(t||0)%360,t<0?t+360:t}function gu(t){return Math.max(0,Math.min(1,t||0))}function gh(t,e,n){return(t<60?e+(n-e)*t/60:t<180?n:t<240?e+(n-e)*(240-t)/60:e)*255}const bx=Math.PI/180,yx=180/Math.PI,df=18,wx=.96422,xx=1,_x=.82521,vx=4/29,Ha=6/29,Ex=3*Ha*Ha,bF=Ha*Ha*Ha;function Ax(t){if(t instanceof tr)return new tr(t.l,t.a,t.b,t.opacity);if(t instanceof kr)return Sx(t);t instanceof lt||(t=wp(t));var e=wh(t.r),n=wh(t.g),r=wh(t.b),i=mh((.2225045*e+.7168786*n+.0606169*r)/xx),a,o;return e===n&&n===r?a=o=i:(a=mh((.4360747*e+.3850649*n+.1430804*r)/wx),o=mh((.0139322*e+.0971045*n+.7141733*r)/_x)),new tr(116*i-16,500*(a-i),200*(i-o),t.opacity)}function Gd(t,e,n,r){return arguments.length===1?Ax(t):new tr(t,e,n,r??1)}function tr(t,e,n,r){this.l=+t,this.a=+e,this.b=+n,this.opacity=+r}Ro(tr,Gd,Rl(wi,{brighter(t){return new tr(this.l+df*(t??1),this.a,this.b,this.opacity)},darker(t){return new tr(this.l-df*(t??1),this.a,this.b,this.opacity)},rgb(){var t=(this.l+16)/116,e=isNaN(this.a)?t:t+this.a/500,n=isNaN(this.b)?t:t-this.b/200;return e=wx*bh(e),t=xx*bh(t),n=_x*bh(n),new lt(yh(3.1338561*e-1.6168667*t-.4906146*n),yh(-.9787684*e+1.9161415*t+.033454*n),yh(.0719453*e-.2289914*t+1.4052427*n),this.opacity)}}));function mh(t){return t>bF?Math.pow(t,1/3):t/Ex+vx}function bh(t){return t>Ha?t*t*t:Ex*(t-vx)}function yh(t){return 255*(t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055)}function wh(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function yF(t){if(t instanceof kr)return new kr(t.h,t.c,t.l,t.opacity);if(t instanceof tr||(t=Ax(t)),t.a===0&&t.b===0)return new kr(NaN,0<t.l&&t.l<100?0:NaN,t.l,t.opacity);var e=Math.atan2(t.b,t.a)*yx;return new kr(e<0?e+360:e,Math.sqrt(t.a*t.a+t.b*t.b),t.l,t.opacity)}function jd(t,e,n,r){return arguments.length===1?yF(t):new kr(t,e,n,r??1)}function kr(t,e,n,r){this.h=+t,this.c=+e,this.l=+n,this.opacity=+r}function Sx(t){if(isNaN(t.h))return new tr(t.l,0,0,t.opacity);var e=t.h*bx;return new tr(t.l,Math.cos(e)*t.c,Math.sin(e)*t.c,t.opacity)}Ro(kr,jd,Rl(wi,{brighter(t){return new kr(this.h,this.c,this.l+df*(t??1),this.opacity)},darker(t){return new kr(this.h,this.c,this.l-df*(t??1),this.opacity)},rgb(){return Sx(this).rgb()}}));var Cx=-.14861,xp=1.78277,_p=-.29227,gc=-.90649,Ws=1.97294,i1=Ws*gc,a1=Ws*xp,o1=xp*_p-gc*Cx;function wF(t){if(t instanceof Yi)return new Yi(t.h,t.s,t.l,t.opacity);t instanceof lt||(t=wp(t));var e=t.r/255,n=t.g/255,r=t.b/255,i=(o1*r+i1*e-a1*n)/(o1+i1-a1),a=r-i,o=(Ws*(n-i)-_p*a)/gc,s=Math.sqrt(o*o+a*a)/(Ws*i*(1-i)),u=s?Math.atan2(o,a)*yx-120:NaN;return new Yi(u<0?u+360:u,s,i,t.opacity)}function Wd(t,e,n,r){return arguments.length===1?wF(t):new Yi(t,e,n,r??1)}function Yi(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}Ro(Yi,Wd,Rl(wi,{brighter(t){return t=t==null?po:Math.pow(po,t),new Yi(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?ia:Math.pow(ia,t),new Yi(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=isNaN(this.h)?0:(this.h+120)*bx,e=+this.l,n=isNaN(this.s)?0:this.s*e*(1-e),r=Math.cos(t),i=Math.sin(t);return new lt(255*(e+n*(Cx*r+xp*i)),255*(e+n*(_p*r+gc*i)),255*(e+n*(Ws*r)),this.opacity)}}));function Tx(t,e,n,r,i){var a=t*t,o=a*t;return((1-3*t+3*a-o)*e+(4-6*a+3*o)*n+(1+3*t+3*a-3*o)*r+o*i)/6}function Fx(t){var e=t.length-1;return function(n){var r=n<=0?n=0:n>=1?(n=1,e-1):Math.floor(n*e),i=t[r],a=t[r+1],o=r>0?t[r-1]:2*i-a,s=r<e-1?t[r+2]:2*a-i;return Tx((n-r/e)*e,o,i,a,s)}}function Ix(t){var e=t.length;return function(n){var r=Math.floor(((n%=1)<0?++n:n)*e),i=t[(r+e-1)%e],a=t[r%e],o=t[(r+1)%e],s=t[(r+2)%e];return Tx((n-r/e)*e,i,a,o,s)}}const mc=t=>()=>t;function kx(t,e){return function(n){return t+n*e}}function xF(t,e,n){return t=Math.pow(t,n),e=Math.pow(e,n)-t,n=1/n,function(r){return Math.pow(t+r*e,n)}}function bc(t,e){var n=e-t;return n?kx(t,n>180||n<-180?n-360*Math.round(n/360):n):mc(isNaN(t)?e:t)}function _F(t){return(t=+t)==1?ut:function(e,n){return n-e?xF(e,n,t):mc(isNaN(e)?n:e)}}function ut(t,e){var n=e-t;return n?kx(t,n):mc(isNaN(t)?e:t)}const Zd=function t(e){var n=_F(e);function r(i,a){var o=n((i=cf(i)).r,(a=cf(a)).r),s=n(i.g,a.g),u=n(i.b,a.b),l=ut(i.opacity,a.opacity);return function(f){return i.r=o(f),i.g=s(f),i.b=u(f),i.opacity=l(f),i+""}}return r.gamma=t,r}(1);function Rx(t){return function(e){var n=e.length,r=new Array(n),i=new Array(n),a=new Array(n),o,s;for(o=0;o<n;++o)s=cf(e[o]),r[o]=s.r||0,i[o]=s.g||0,a[o]=s.b||0;return r=t(r),i=t(i),a=t(a),s.opacity=1,function(u){return s.r=r(u),s.g=i(u),s.b=a(u),s+""}}}var vF=Rx(Fx),EF=Rx(Ix);function vp(t,e){e||(e=[]);var n=t?Math.min(e.length,t.length):0,r=e.slice(),i;return function(a){for(i=0;i<n;++i)r[i]=t[i]*(1-a)+e[i]*a;return r}}function Dx(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function AF(t,e){return(Dx(e)?vp:Bx)(t,e)}function Bx(t,e){var n=e?e.length:0,r=t?Math.min(n,t.length):0,i=new Array(r),a=new Array(n),o;for(o=0;o<r;++o)i[o]=xi(t[o],e[o]);for(;o<n;++o)a[o]=e[o];return function(s){for(o=0;o<r;++o)a[o]=i[o](s);return a}}function Nx(t,e){var n=new Date;return t=+t,e=+e,function(r){return n.setTime(t*(1-r)+e*r),n}}function Cn(t,e){return t=+t,e=+e,function(n){return t*(1-n)+e*n}}function $x(t,e){var n={},r={},i;(t===null||typeof t!="object")&&(t={}),(e===null||typeof e!="object")&&(e={});for(i in e)i in t?n[i]=xi(t[i],e[i]):r[i]=e[i];return function(a){for(i in n)r[i]=n[i](a);return r}}var Yd=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,xh=new RegExp(Yd.source,"g");function SF(t){return function(){return t}}function CF(t){return function(e){return t(e)+""}}function Ox(t,e){var n=Yd.lastIndex=xh.lastIndex=0,r,i,a,o=-1,s=[],u=[];for(t=t+"",e=e+"";(r=Yd.exec(t))&&(i=xh.exec(e));)(a=i.index)>n&&(a=e.slice(n,a),s[o]?s[o]+=a:s[++o]=a),(r=r[0])===(i=i[0])?s[o]?s[o]+=i:s[++o]=i:(s[++o]=null,u.push({i:o,x:Cn(r,i)})),n=xh.lastIndex;return n<e.length&&(a=e.slice(n),s[o]?s[o]+=a:s[++o]=a),s.length<2?u[0]?CF(u[0].x):SF(e):(e=u.length,function(l){for(var f=0,c;f<e;++f)s[(c=u[f]).i]=c.x(l);return s.join("")})}function xi(t,e){var n=typeof e,r;return e==null||n==="boolean"?mc(e):(n==="number"?Cn:n==="string"?(r=fi(e))?(e=r,Zd):Ox:e instanceof fi?Zd:e instanceof Date?Nx:Dx(e)?vp:Array.isArray(e)?Bx:typeof e.valueOf!="function"&&typeof e.toString!="function"||isNaN(e)?$x:Cn)(t,e)}function TF(t){var e=t.length;return function(n){return t[Math.max(0,Math.min(e-1,Math.floor(n*e)))]}}function FF(t,e){var n=bc(+t,+e);return function(r){var i=n(r);return i-360*Math.floor(i/360)}}function Dl(t,e){return t=+t,e=+e,function(n){return Math.round(t*(1-n)+e*n)}}var s1=180/Math.PI,Xd={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Lx(t,e,n,r,i,a){var o,s,u;return(o=Math.sqrt(t*t+e*e))&&(t/=o,e/=o),(u=t*n+e*r)&&(n-=t*u,r-=e*u),(s=Math.sqrt(n*n+r*r))&&(n/=s,r/=s,u/=s),t*r<e*n&&(t=-t,e=-e,u=-u,o=-o),{translateX:i,translateY:a,rotate:Math.atan2(e,t)*s1,skewX:Math.atan(u)*s1,scaleX:o,scaleY:s}}var mu;function IF(t){const e=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(t+"");return e.isIdentity?Xd:Lx(e.a,e.b,e.c,e.d,e.e,e.f)}function kF(t){return t==null||(mu||(mu=document.createElementNS("http://www.w3.org/2000/svg","g")),mu.setAttribute("transform",t),!(t=mu.transform.baseVal.consolidate()))?Xd:(t=t.matrix,Lx(t.a,t.b,t.c,t.d,t.e,t.f))}function Mx(t,e,n,r){function i(l){return l.length?l.pop()+" ":""}function a(l,f,c,h,d,p){if(l!==c||f!==h){var m=d.push("translate(",null,e,null,n);p.push({i:m-4,x:Cn(l,c)},{i:m-2,x:Cn(f,h)})}else(c||h)&&d.push("translate("+c+e+h+n)}function o(l,f,c,h){l!==f?(l-f>180?f+=360:f-l>180&&(l+=360),h.push({i:c.push(i(c)+"rotate(",null,r)-2,x:Cn(l,f)})):f&&c.push(i(c)+"rotate("+f+r)}function s(l,f,c,h){l!==f?h.push({i:c.push(i(c)+"skewX(",null,r)-2,x:Cn(l,f)}):f&&c.push(i(c)+"skewX("+f+r)}function u(l,f,c,h,d,p){if(l!==c||f!==h){var m=d.push(i(d)+"scale(",null,",",null,")");p.push({i:m-4,x:Cn(l,c)},{i:m-2,x:Cn(f,h)})}else(c!==1||h!==1)&&d.push(i(d)+"scale("+c+","+h+")")}return function(l,f){var c=[],h=[];return l=t(l),f=t(f),a(l.translateX,l.translateY,f.translateX,f.translateY,c,h),o(l.rotate,f.rotate,c,h),s(l.skewX,f.skewX,c,h),u(l.scaleX,l.scaleY,f.scaleX,f.scaleY,c,h),l=f=null,function(d){for(var p=-1,m=h.length,y;++p<m;)c[(y=h[p]).i]=y.x(d);return c.join("")}}}var RF=Mx(IF,"px, ","px)","deg)"),DF=Mx(kF,", ",")",")"),BF=1e-12;function l1(t){return((t=Math.exp(t))+1/t)/2}function NF(t){return((t=Math.exp(t))-1/t)/2}function $F(t){return((t=Math.exp(2*t))-1)/(t+1)}const OF=function t(e,n,r){function i(a,o){var s=a[0],u=a[1],l=a[2],f=o[0],c=o[1],h=o[2],d=f-s,p=c-u,m=d*d+p*p,y,w;if(m<BF)w=Math.log(h/l)/e,y=function(I){return[s+I*d,u+I*p,l*Math.exp(e*I*w)]};else{var A=Math.sqrt(m),C=(h*h-l*l+r*m)/(2*l*n*A),E=(h*h-l*l-r*m)/(2*h*n*A),k=Math.log(Math.sqrt(C*C+1)-C),R=Math.log(Math.sqrt(E*E+1)-E);w=(R-k)/e,y=function(I){var O=I*w,T=l1(k),B=l/(n*A)*(T*$F(e*O+k)-NF(k));return[s+B*d,u+B*p,l*T/l1(e*O+k)]}}return y.duration=w*1e3*e/Math.SQRT2,y}return i.rho=function(a){var o=Math.max(.001,+a),s=o*o,u=s*s;return t(o,s,u)},i}(Math.SQRT2,2,4);function Px(t){return function(e,n){var r=t((e=Hd(e)).h,(n=Hd(n)).h),i=ut(e.s,n.s),a=ut(e.l,n.l),o=ut(e.opacity,n.opacity);return function(s){return e.h=r(s),e.s=i(s),e.l=a(s),e.opacity=o(s),e+""}}}const LF=Px(bc);var MF=Px(ut);function PF(t,e){var n=ut((t=Gd(t)).l,(e=Gd(e)).l),r=ut(t.a,e.a),i=ut(t.b,e.b),a=ut(t.opacity,e.opacity);return function(o){return t.l=n(o),t.a=r(o),t.b=i(o),t.opacity=a(o),t+""}}function zx(t){return function(e,n){var r=t((e=jd(e)).h,(n=jd(n)).h),i=ut(e.c,n.c),a=ut(e.l,n.l),o=ut(e.opacity,n.opacity);return function(s){return e.h=r(s),e.c=i(s),e.l=a(s),e.opacity=o(s),e+""}}}const zF=zx(bc);var UF=zx(ut);function Ux(t){return function e(n){n=+n;function r(i,a){var o=t((i=Wd(i)).h,(a=Wd(a)).h),s=ut(i.s,a.s),u=ut(i.l,a.l),l=ut(i.opacity,a.opacity);return function(f){return i.h=o(f),i.s=s(f),i.l=u(Math.pow(f,n)),i.opacity=l(f),i+""}}return r.gamma=e,r}(1)}const qF=Ux(bc);var VF=Ux(ut);function Ep(t,e){e===void 0&&(e=t,t=xi);for(var n=0,r=e.length-1,i=e[0],a=new Array(r<0?0:r);n<r;)a[n]=t(i,i=e[++n]);return function(o){var s=Math.max(0,Math.min(r-1,Math.floor(o*=r)));return a[s](o-s)}}function HF(t,e){for(var n=new Array(e),r=0;r<e;++r)n[r]=t(r/(e-1));return n}const GF=Object.freeze(Object.defineProperty({__proto__:null,interpolate:xi,interpolateArray:AF,interpolateBasis:Fx,interpolateBasisClosed:Ix,interpolateCubehelix:qF,interpolateCubehelixLong:VF,interpolateDate:Nx,interpolateDiscrete:TF,interpolateHcl:zF,interpolateHclLong:UF,interpolateHsl:LF,interpolateHslLong:MF,interpolateHue:FF,interpolateLab:PF,interpolateNumber:Cn,interpolateNumberArray:vp,interpolateObject:$x,interpolateRgb:Zd,interpolateRgbBasis:vF,interpolateRgbBasisClosed:EF,interpolateRound:Dl,interpolateString:Ox,interpolateTransformCss:RF,interpolateTransformSvg:DF,interpolateZoom:OF,piecewise:Ep,quantize:HF},Symbol.toStringTag,{value:"Module"}));function jF(t){return function(){return t}}function Kd(t){return+t}var u1=[0,1];function Lt(t){return t}function Jd(t,e){return(e-=t=+t)?function(n){return(n-t)/e}:jF(isNaN(e)?NaN:.5)}function WF(t,e){var n;return t>e&&(n=t,t=e,e=n),function(r){return Math.max(t,Math.min(e,r))}}function ZF(t,e,n){var r=t[0],i=t[1],a=e[0],o=e[1];return i<r?(r=Jd(i,r),a=n(o,a)):(r=Jd(r,i),a=n(a,o)),function(s){return a(r(s))}}function YF(t,e,n){var r=Math.min(t.length,e.length)-1,i=new Array(r),a=new Array(r),o=-1;for(t[r]<t[0]&&(t=t.slice().reverse(),e=e.slice().reverse());++o<r;)i[o]=Jd(t[o],t[o+1]),a[o]=n(e[o],e[o+1]);return function(s){var u=ko(t,s,1,r)-1;return a[u](i[u](s))}}function Bl(t,e){return e.domain(t.domain()).range(t.range()).interpolate(t.interpolate()).clamp(t.clamp()).unknown(t.unknown())}function yc(){var t=u1,e=u1,n=xi,r,i,a,o=Lt,s,u,l;function f(){var h=Math.min(t.length,e.length);return o!==Lt&&(o=WF(t[0],t[h-1])),s=h>2?YF:ZF,u=l=null,c}function c(h){return h==null||isNaN(h=+h)?a:(u||(u=s(t.map(r),e,n)))(r(o(h)))}return c.invert=function(h){return o(i((l||(l=s(e,t.map(r),Cn)))(h)))},c.domain=function(h){return arguments.length?(t=Array.from(h,Kd),f()):t.slice()},c.range=function(h){return arguments.length?(e=Array.from(h),f()):e.slice()},c.rangeRound=function(h){return e=Array.from(h),n=Dl,f()},c.clamp=function(h){return arguments.length?(o=h?!0:Lt,f()):o!==Lt},c.interpolate=function(h){return arguments.length?(n=h,f()):n},c.unknown=function(h){return arguments.length?(a=h,c):a},function(h,d){return r=h,i=d,f()}}function qx(){return yc()(Lt,Lt)}function Vx(t,e,n,r){var i=ta(t,e,n),a;switch(r=ui(r??",f"),r.type){case"s":{var o=Math.max(Math.abs(t),Math.abs(e));return r.precision==null&&!isNaN(a=Zw(i,o))&&(r.precision=a),sp(r,o)}case"":case"e":case"g":case"p":case"r":{r.precision==null&&!isNaN(a=Yw(i,Math.max(Math.abs(t),Math.abs(e))))&&(r.precision=a-(r.type==="e"));break}case"f":case"%":{r.precision==null&&!isNaN(a=Ww(i))&&(r.precision=a-(r.type==="%")*2);break}}return gt(r)}function ya(t){var e=t.domain;return t.ticks=function(n){var r=e();return af(r[0],r[r.length-1],n??10)},t.tickFormat=function(n,r){var i=e();return Vx(i[0],i[i.length-1],n??10,r)},t.nice=function(n){n==null&&(n=10);var r=e(),i=0,a=r.length-1,o=r[i],s=r[a],u,l,f=10;for(s<o&&(l=o,o=s,s=l,l=i,i=a,a=l);f-- >0;){if(l=Pd(o,s,n),l===u)return r[i]=o,r[a]=s,e(r);if(l>0)o=Math.floor(o/l)*l,s=Math.ceil(s/l)*l;else if(l<0)o=Math.ceil(o*l)/l,s=Math.floor(s*l)/l;else break;u=l}return t},t}function Hx(){var t=qx();return t.copy=function(){return Bl(t,Hx())},ur.apply(t,arguments),ya(t)}function Gx(t){var e;function n(r){return r==null||isNaN(r=+r)?e:r}return n.invert=n,n.domain=n.range=function(r){return arguments.length?(t=Array.from(r,Kd),n):t.slice()},n.unknown=function(r){return arguments.length?(e=r,n):e},n.copy=function(){return Gx(t).unknown(e)},t=arguments.length?Array.from(t,Kd):[0,1],ya(n)}function jx(t,e){t=t.slice();var n=0,r=t.length-1,i=t[n],a=t[r],o;return a<i&&(o=n,n=r,r=o,o=i,i=a,a=o),t[n]=e.floor(i),t[r]=e.ceil(a),t}function f1(t){return Math.log(t)}function c1(t){return Math.exp(t)}function XF(t){return-Math.log(-t)}function KF(t){return-Math.exp(-t)}function JF(t){return isFinite(t)?+("1e"+t):t<0?0:t}function QF(t){return t===10?JF:t===Math.E?Math.exp:e=>Math.pow(t,e)}function e4(t){return t===Math.E?Math.log:t===10&&Math.log10||t===2&&Math.log2||(t=Math.log(t),e=>Math.log(e)/t)}function h1(t){return(e,n)=>-t(-e,n)}function Ap(t){const e=t(f1,c1),n=e.domain;let r=10,i,a;function o(){return i=e4(r),a=QF(r),n()[0]<0?(i=h1(i),a=h1(a),t(XF,KF)):t(f1,c1),e}return e.base=function(s){return arguments.length?(r=+s,o()):r},e.domain=function(s){return arguments.length?(n(s),o()):n()},e.ticks=s=>{const u=n();let l=u[0],f=u[u.length-1];const c=f<l;c&&([l,f]=[f,l]);let h=i(l),d=i(f),p,m;const y=s==null?10:+s;let w=[];if(!(r%1)&&d-h<y){if(h=Math.floor(h),d=Math.ceil(d),l>0){for(;h<=d;++h)for(p=1;p<r;++p)if(m=h<0?p/a(-h):p*a(h),!(m<l)){if(m>f)break;w.push(m)}}else for(;h<=d;++h)for(p=r-1;p>=1;--p)if(m=h>0?p/a(-h):p*a(h),!(m<l)){if(m>f)break;w.push(m)}w.length*2<y&&(w=af(l,f,y))}else w=af(h,d,Math.min(d-h,y)).map(a);return c?w.reverse():w},e.tickFormat=(s,u)=>{if(s==null&&(s=10),u==null&&(u=r===10?"s":","),typeof u!="function"&&(!(r%1)&&(u=ui(u)).precision==null&&(u.trim=!0),u=gt(u)),s===1/0)return u;const l=Math.max(1,r*s/e.ticks().length);return f=>{let c=f/a(Math.round(i(f)));return c*r<r-.5&&(c*=r),c<=l?u(f):""}},e.nice=()=>n(jx(n(),{floor:s=>a(Math.floor(i(s))),ceil:s=>a(Math.ceil(i(s)))})),e}function Sp(){const t=Ap(yc()).domain([1,10]);return t.copy=()=>Bl(t,Sp()).base(t.base()),ur.apply(t,arguments),t}function d1(t){return function(e){return Math.sign(e)*Math.log1p(Math.abs(e/t))}}function p1(t){return function(e){return Math.sign(e)*Math.expm1(Math.abs(e))*t}}function Cp(t){var e=1,n=t(d1(e),p1(e));return n.constant=function(r){return arguments.length?t(d1(e=+r),p1(e)):e},ya(n)}function Wx(){var t=Cp(yc());return t.copy=function(){return Bl(t,Wx()).constant(t.constant())},ur.apply(t,arguments)}function g1(t){return function(e){return e<0?-Math.pow(-e,t):Math.pow(e,t)}}function t4(t){return t<0?-Math.sqrt(-t):Math.sqrt(t)}function n4(t){return t<0?-t*t:t*t}function Tp(t){var e=t(Lt,Lt),n=1;function r(){return n===1?t(Lt,Lt):n===.5?t(t4,n4):t(g1(n),g1(1/n))}return e.exponent=function(i){return arguments.length?(n=+i,r()):n},ya(e)}function Fp(){var t=Tp(yc());return t.copy=function(){return Bl(t,Fp()).exponent(t.exponent())},ur.apply(t,arguments),t}function r4(){return Fp.apply(null,arguments).exponent(.5)}function Zx(){var t=[],e=[],n=[],r;function i(){var o=0,s=Math.max(1,e.length);for(n=new Array(s-1);++o<s;)n[o-1]=Gw(t,o/s);return a}function a(o){return o==null||isNaN(o=+o)?r:e[ko(n,o)]}return a.invertExtent=function(o){var s=e.indexOf(o);return s<0?[NaN,NaN]:[s>0?n[s-1]:t[0],s<n.length?n[s]:t[t.length-1]]},a.domain=function(o){if(!arguments.length)return t.slice();t=[];for(let s of o)s!=null&&!isNaN(s=+s)&&t.push(s);return t.sort(ds),i()},a.range=function(o){return arguments.length?(e=Array.from(o),i()):e.slice()},a.unknown=function(o){return arguments.length?(r=o,a):r},a.quantiles=function(){return n.slice()},a.copy=function(){return Zx().domain(t).range(e).unknown(r)},ur.apply(a,arguments)}function Yx(){var t=0,e=1,n=1,r=[.5],i=[0,1],a;function o(u){return u!=null&&u<=u?i[ko(r,u,0,n)]:a}function s(){var u=-1;for(r=new Array(n);++u<n;)r[u]=((u+1)*e-(u-n)*t)/(n+1);return o}return o.domain=function(u){return arguments.length?([t,e]=u,t=+t,e=+e,s()):[t,e]},o.range=function(u){return arguments.length?(n=(i=Array.from(u)).length-1,s()):i.slice()},o.invertExtent=function(u){var l=i.indexOf(u);return l<0?[NaN,NaN]:l<1?[t,r[0]]:l>=n?[r[n-1],e]:[r[l-1],r[l]]},o.unknown=function(u){return arguments.length&&(a=u),o},o.thresholds=function(){return r.slice()},o.copy=function(){return Yx().domain([t,e]).range(i).unknown(a)},ur.apply(ya(o),arguments)}function Xx(){var t=[.5],e=[0,1],n,r=1;function i(a){return a!=null&&a<=a?e[ko(t,a,0,r)]:n}return i.domain=function(a){return arguments.length?(t=Array.from(a),r=Math.min(t.length,e.length-1),i):t.slice()},i.range=function(a){return arguments.length?(e=Array.from(a),r=Math.min(t.length,e.length-1),i):e.slice()},i.invertExtent=function(a){var o=e.indexOf(a);return[t[o-1],t[o]]},i.unknown=function(a){return arguments.length?(n=a,i):n},i.copy=function(){return Xx().domain(t).range(e).unknown(n)},ur.apply(i,arguments)}function i4(t){return new Date(t)}function a4(t){return t instanceof Date?+t:+new Date(+t)}function Ip(t,e,n,r,i,a,o,s,u,l){var f=qx(),c=f.invert,h=f.domain,d=l(".%L"),p=l(":%S"),m=l("%I:%M"),y=l("%I %p"),w=l("%a %d"),A=l("%b %d"),C=l("%B"),E=l("%Y");function k(R){return(u(R)<R?d:s(R)<R?p:o(R)<R?m:a(R)<R?y:r(R)<R?i(R)<R?w:A:n(R)<R?C:E)(R)}return f.invert=function(R){return new Date(c(R))},f.domain=function(R){return arguments.length?h(Array.from(R,a4)):h().map(i4)},f.ticks=function(R){var I=h();return t(I[0],I[I.length-1],R??10)},f.tickFormat=function(R,I){return I==null?k:l(I)},f.nice=function(R){var I=h();return(!R||typeof R.range!="function")&&(R=e(I[0],I[I.length-1],R??10)),R?h(jx(I,R)):f},f.copy=function(){return Bl(f,Ip(t,e,n,r,i,a,o,s,u,l))},f}function o4(){return ur.apply(Ip(uC,fC,or,Ns,Sl,ri,oc,ic,Ir,fp).domain([new Date(2e3,0,1),new Date(2e3,0,2)]),arguments)}function s4(){return ur.apply(Ip(sC,lC,sr,$s,Cl,Wi,sc,ac,Ir,cp).domain([Date.UTC(2e3,0,1),Date.UTC(2e3,0,2)]),arguments)}function wc(){var t=0,e=1,n,r,i,a,o=Lt,s=!1,u;function l(c){return c==null||isNaN(c=+c)?u:o(i===0?.5:(c=(a(c)-n)*i,s?Math.max(0,Math.min(1,c)):c))}l.domain=function(c){return arguments.length?([t,e]=c,n=a(t=+t),r=a(e=+e),i=n===r?0:1/(r-n),l):[t,e]},l.clamp=function(c){return arguments.length?(s=!!c,l):s},l.interpolator=function(c){return arguments.length?(o=c,l):o};function f(c){return function(h){var d,p;return arguments.length?([d,p]=h,o=c(d,p),l):[o(0),o(1)]}}return l.range=f(xi),l.rangeRound=f(Dl),l.unknown=function(c){return arguments.length?(u=c,l):u},function(c){return a=c,n=c(t),r=c(e),i=n===r?0:1/(r-n),l}}function _i(t,e){return e.domain(t.domain()).interpolator(t.interpolator()).clamp(t.clamp()).unknown(t.unknown())}function kp(){var t=ya(wc()(Lt));return t.copy=function(){return _i(t,kp())},yi.apply(t,arguments)}function Kx(){var t=Ap(wc()).domain([1,10]);return t.copy=function(){return _i(t,Kx()).base(t.base())},yi.apply(t,arguments)}function Jx(){var t=Cp(wc());return t.copy=function(){return _i(t,Jx()).constant(t.constant())},yi.apply(t,arguments)}function Rp(){var t=Tp(wc());return t.copy=function(){return _i(t,Rp()).exponent(t.exponent())},yi.apply(t,arguments)}function l4(){return Rp.apply(null,arguments).exponent(.5)}function xc(){var t=0,e=.5,n=1,r=1,i,a,o,s,u,l=Lt,f,c=!1,h;function d(m){return isNaN(m=+m)?h:(m=.5+((m=+f(m))-a)*(r*m<r*a?s:u),l(c?Math.max(0,Math.min(1,m)):m))}d.domain=function(m){return arguments.length?([t,e,n]=m,i=f(t=+t),a=f(e=+e),o=f(n=+n),s=i===a?0:.5/(a-i),u=a===o?0:.5/(o-a),r=a<i?-1:1,d):[t,e,n]},d.clamp=function(m){return arguments.length?(c=!!m,d):c},d.interpolator=function(m){return arguments.length?(l=m,d):l};function p(m){return function(y){var w,A,C;return arguments.length?([w,A,C]=y,l=Ep(m,[w,A,C]),d):[l(0),l(.5),l(1)]}}return d.range=p(xi),d.rangeRound=p(Dl),d.unknown=function(m){return arguments.length?(h=m,d):h},function(m){return f=m,i=m(t),a=m(e),o=m(n),s=i===a?0:.5/(a-i),u=a===o?0:.5/(o-a),r=a<i?-1:1,d}}function Qx(){var t=ya(xc()(Lt));return t.copy=function(){return _i(t,Qx())},yi.apply(t,arguments)}function e_(){var t=Ap(xc()).domain([.1,1,10]);return t.copy=function(){return _i(t,e_()).base(t.base())},yi.apply(t,arguments)}function t_(){var t=Cp(xc());return t.copy=function(){return _i(t,t_()).constant(t.constant())},yi.apply(t,arguments)}function Dp(){var t=Tp(xc());return t.copy=function(){return _i(t,Dp()).exponent(t.exponent())},yi.apply(t,arguments)}function u4(){return Dp.apply(null,arguments).exponent(.5)}function Bp(t,e,n){const r=t-e+n*2;return t?r>0?r:1:0}const f4="identity",go="linear",ci="log",Nl="pow",$l="sqrt",_c="symlog",n_="time",r_="utc",nr="sequential",Do="diverging",Qd="quantile",i_="quantize",a_="threshold",Np="ordinal",e0="point",o_="band",$p="bin-ordinal",it="continuous",Ol="discrete",Ll="discretizing",yn="interpolating",s_="temporal";function c4(t){return function(e){let n=e[0],r=e[1],i;return r<n&&(i=n,n=r,r=i),[t.invert(n),t.invert(r)]}}function h4(t){return function(e){const n=t.range();let r=e[0],i=e[1],a=-1,o,s,u,l;for(i<r&&(s=r,r=i,i=s),u=0,l=n.length;u<l;++u)n[u]>=r&&n[u]<=i&&(a<0&&(a=u),o=u);if(!(a<0))return r=t.invertExtent(n[a]),i=t.invertExtent(n[o]),[r[0]===void 0?r[1]:r[0],i[1]===void 0?i[0]:i[1]]}}function Op(){const t=yp().unknown(void 0),e=t.domain,n=t.range;let r=[0,1],i,a,o=!1,s=0,u=0,l=.5;delete t.unknown;function f(){const c=e().length,h=r[1]<r[0],d=r[1-h],p=Bp(c,s,u);let m=r[h-0];i=(d-m)/(p||1),o&&(i=Math.floor(i)),m+=(d-m-i*(c-s))*l,a=i*(1-s),o&&(m=Math.round(m),a=Math.round(a));const y=Bs(c).map(w=>m+i*w);return n(h?y.reverse():y)}return t.domain=function(c){return arguments.length?(e(c),f()):e()},t.range=function(c){return arguments.length?(r=[+c[0],+c[1]],f()):r.slice()},t.rangeRound=function(c){return r=[+c[0],+c[1]],o=!0,f()},t.bandwidth=function(){return a},t.step=function(){return i},t.round=function(c){return arguments.length?(o=!!c,f()):o},t.padding=function(c){return arguments.length?(u=Math.max(0,Math.min(1,c)),s=u,f()):s},t.paddingInner=function(c){return arguments.length?(s=Math.max(0,Math.min(1,c)),f()):s},t.paddingOuter=function(c){return arguments.length?(u=Math.max(0,Math.min(1,c)),f()):u},t.align=function(c){return arguments.length?(l=Math.max(0,Math.min(1,c)),f()):l},t.invertRange=function(c){if(c[0]==null||c[1]==null)return;const h=r[1]<r[0],d=h?n().reverse():n(),p=d.length-1;let m=+c[0],y=+c[1],w,A,C;if(!(m!==m||y!==y)&&(y<m&&(C=m,m=y,y=C),!(y<d[0]||m>r[1-h])))return w=Math.max(0,Ld(d,m)-1),A=m===y?w:Ld(d,y)-1,m-d[w]>a+1e-10&&++w,h&&(C=w,w=p-A,A=p-C),w>A?void 0:e().slice(w,A+1)},t.invert=function(c){const h=t.invertRange([c,c]);return h&&h[0]},t.copy=function(){return Op().domain(e()).range(r).round(o).paddingInner(s).paddingOuter(u).align(l)},f()}function l_(t){const e=t.copy;return t.padding=t.paddingOuter,delete t.paddingInner,t.copy=function(){return l_(e())},t}function d4(){return l_(Op().paddingInner(1))}var p4=Array.prototype.map;function g4(t){return p4.call(t,Ds)}const m4=Array.prototype.slice;function u_(){let t=[],e=[];function n(r){return r==null||r!==r?void 0:e[(ko(t,r)-1)%e.length]}return n.domain=function(r){return arguments.length?(t=g4(r),n):t.slice()},n.range=function(r){return arguments.length?(e=m4.call(r),n):e.slice()},n.tickFormat=function(r,i){return Vx(t[0],kn(t),r??10,i)},n.copy=function(){return u_().domain(n.domain()).range(n.range())},n}const pf=new Map,b4=Symbol("vega_scale");function y4(t){return t[b4]=!0,t}function w4(t,e,n){const r=function(){const a=e();return a.invertRange||(a.invertRange=a.invert?c4(a):a.invertExtent?h4(a):void 0),a.type=t,y4(a)};return r.metadata=nf(Od(n)),r}function Ae(t,e,n){return arguments.length>1?(pf.set(t,w4(t,e,n)),this):x4(t)?pf.get(t):void 0}Ae(f4,Gx);Ae(go,Hx,it);Ae(ci,Sp,[it,ci]);Ae(Nl,Fp,it);Ae($l,r4,it);Ae(_c,Wx,it);Ae(n_,o4,[it,s_]);Ae(r_,s4,[it,s_]);Ae(nr,kp,[it,yn]);Ae(`${nr}-${go}`,kp,[it,yn]);Ae(`${nr}-${ci}`,Kx,[it,yn,ci]);Ae(`${nr}-${Nl}`,Rp,[it,yn]);Ae(`${nr}-${$l}`,l4,[it,yn]);Ae(`${nr}-${_c}`,Jx,[it,yn]);Ae(`${Do}-${go}`,Qx,[it,yn]);Ae(`${Do}-${ci}`,e_,[it,yn,ci]);Ae(`${Do}-${Nl}`,Dp,[it,yn]);Ae(`${Do}-${$l}`,u4,[it,yn]);Ae(`${Do}-${_c}`,t_,[it,yn]);Ae(Qd,Zx,[Ll,Qd]);Ae(i_,Yx,Ll);Ae(a_,Xx,Ll);Ae($p,u_,[Ol,Ll]);Ae(Np,yp,Ol);Ae(o_,Op,Ol);Ae(e0,d4,Ol);function x4(t){return pf.has(t)}function Ml(t,e){const n=pf.get(t);return n&&n.metadata[e]}function wt(t){return Ml(t,it)}function hi(t){return Ml(t,Ol)}function La(t){return Ml(t,Ll)}function f_(t){return Ml(t,ci)}function vc(t){return Ml(t,yn)}function _4(t,e){const n=e[0],r=kn(e)-n;return function(i){return t(n+i*r)}}function Ec(t,e,n){return Ep(c_(e||"rgb",n),t)}function v4(t,e){const n=new Array(e),r=e+1;for(let i=0;i<e;)n[i]=t(++i/r);return n}function c_(t,e){const n=GF[E4(t)];return e!=null&&n&&n.gamma?n.gamma(e):n}function E4(t){return"interpolate"+t.toLowerCase().split("-").map(e=>e[0].toUpperCase()+e.slice(1)).join("")}const A4={blues:"cfe1f2bed8eca8cee58fc1de74b2d75ba3cf4592c63181bd206fb2125ca40a4a90",greens:"d3eecdc0e6baabdda594d3917bc77d60ba6c46ab5e329a512089430e7735036429",greys:"e2e2e2d4d4d4c4c4c4b1b1b19d9d9d8888887575756262624d4d4d3535351e1e1e",oranges:"fdd8b3fdc998fdb87bfda55efc9244f87f2cf06b18e4580bd14904b93d029f3303",purples:"e2e1efd4d4e8c4c5e0b4b3d6a3a0cc928ec3827cb97566ae684ea25c3696501f8c",reds:"fdc9b4fcb49afc9e80fc8767fa7051f6573fec3f2fdc2a25c81b1db21218970b13",blueGreen:"d5efedc1e8e0a7ddd18bd2be70c6a958ba9144ad77319c5d2089460e7736036429",bluePurple:"ccddecbad0e4a8c2dd9ab0d4919cc98d85be8b6db28a55a6873c99822287730f71",greenBlue:"d3eecec5e8c3b1e1bb9bd8bb82cec269c2ca51b2cd3c9fc7288abd1675b10b60a1",orangeRed:"fddcaffdcf9bfdc18afdad77fb9562f67d53ee6545e24932d32d1ebf130da70403",purpleBlue:"dbdaebc8cee4b1c3de97b7d87bacd15b9fc93a90c01e7fb70b70ab056199045281",purpleBlueGreen:"dbd8eac8cee4b0c3de93b7d872acd1549fc83892bb1c88a3097f8702736b016353",purpleRed:"dcc9e2d3b3d7ce9eccd186c0da6bb2e14da0e23189d91e6fc61159ab07498f023a",redPurple:"fccfccfcbec0faa9b8f98faff571a5ec539ddb3695c41b8aa908808d0179700174",yellowGreen:"e4f4acd1eca0b9e2949ed68880c97c62bb6e47aa5e3297502083440e723b036034",yellowOrangeBrown:"feeaa1fedd84fecc63feb746fca031f68921eb7215db5e0bc54c05ab3d038f3204",yellowOrangeRed:"fee087fed16ffebd59fea849fd903efc7335f9522bee3423de1b20ca0b22af0225",blueOrange:"134b852f78b35da2cb9dcae1d2e5eff2f0ebfce0bafbbf74e8932fc5690d994a07",brownBlueGreen:"704108a0651ac79548e3c78af3e6c6eef1eac9e9e48ed1c74da79e187a72025147",purpleGreen:"5b1667834792a67fb6c9aed3e6d6e8eff0efd9efd5aedda971bb75368e490e5e29",purpleOrange:"4114696647968f83b7b9b4d6dadbebf3eeeafce0bafbbf74e8932fc5690d994a07",redBlue:"8c0d25bf363adf745ef4ae91fbdbc9f2efeed2e5ef9dcae15da2cb2f78b3134b85",redGrey:"8c0d25bf363adf745ef4ae91fcdccbfaf4f1e2e2e2c0c0c0969696646464343434",yellowGreenBlue:"eff9bddbf1b4bde5b594d5b969c5be45b4c22c9ec02182b82163aa23479c1c3185",redYellowBlue:"a50026d4322cf16e43fcac64fedd90faf8c1dcf1ecabd6e875abd04a74b4313695",redYellowGreen:"a50026d4322cf16e43fcac63fedd8df9f7aed7ee8ea4d86e64bc6122964f006837",pinkYellowGreen:"8e0152c0267edd72adf0b3d6faddedf5f3efe1f2cab6de8780bb474f9125276419",spectral:"9e0142d13c4bf0704afcac63fedd8dfbf8b0e0f3a1a9dda269bda94288b55e4fa2",viridis:"440154470e61481a6c482575472f7d443a834144873d4e8a39568c35608d31688e2d708e2a788e27818e23888e21918d1f988b1fa08822a8842ab07f35b77943bf7154c56866cc5d7ad1518fd744a5db36bcdf27d2e21be9e51afde725",magma:"0000040404130b0924150e3720114b2c11603b0f704a107957157e651a80721f817f24828c29819a2e80a8327db6377ac43c75d1426fde4968e95462f1605df76f5cfa7f5efc8f65fe9f6dfeaf78febf84fece91fddea0fcedaffcfdbf",inferno:"0000040403130c0826170c3b240c4f330a5f420a68500d6c5d126e6b176e781c6d86216b932667a12b62ae305cbb3755c73e4cd24644dd513ae65c30ed6925f3771af8850ffb9506fca50afcb519fac62df6d645f2e661f3f484fcffa4",plasma:"0d088723069033059742039d5002a25d01a66a00a87801a88405a7900da49c179ea72198b12a90ba3488c33d80cb4779d35171da5a69e16462e76e5bed7953f2834cf68f44fa9a3dfca636fdb32ffec029fcce25f9dc24f5ea27f0f921",cividis:"00205100235800265d002961012b65042e670831690d346b11366c16396d1c3c6e213f6e26426e2c456e31476e374a6e3c4d6e42506e47536d4c566d51586e555b6e5a5e6e5e616e62646f66676f6a6a706e6d717270717573727976737c79747f7c75827f758682768985778c8877908b78938e789691789a94789e9778a19b78a59e77a9a177aea575b2a874b6ab73bbaf71c0b26fc5b66dc9b96acebd68d3c065d8c462ddc85fe2cb5ce7cf58ebd355f0d652f3da4ff7de4cfae249fce647",rainbow:"6e40aa883eb1a43db3bf3cafd83fa4ee4395fe4b83ff576eff6659ff7847ff8c38f3a130e2b72fcfcc36bee044aff05b8ff4576ff65b52f6673af27828ea8d1ddfa319d0b81cbecb23abd82f96e03d82e14c6edb5a5dd0664dbf6e40aa",sinebow:"ff4040fc582af47218e78d0bd5a703bfbf00a7d5038de70b72f41858fc2a40ff402afc5818f4720be78d03d5a700bfbf03a7d50b8de71872f42a58fc4040ff582afc7218f48d0be7a703d5bf00bfd503a7e70b8df41872fc2a58ff4040",turbo:"23171b32204a3e2a71453493493eae4b49c54a53d7485ee44569ee4074f53c7ff8378af93295f72e9ff42ba9ef28b3e926bce125c5d925cdcf27d5c629dcbc2de3b232e9a738ee9d3ff39347f68950f9805afc7765fd6e70fe667cfd5e88fc5795fb51a1f84badf545b9f140c5ec3cd0e637dae034e4d931ecd12ef4c92bfac029ffb626ffad24ffa223ff9821ff8d1fff821dff771cfd6c1af76118f05616e84b14df4111d5380fcb2f0dc0260ab61f07ac1805a313029b0f00950c00910b00",browns:"eedbbdecca96e9b97ae4a865dc9856d18954c7784cc0673fb85536ad44339f3632",tealBlues:"bce4d89dd3d181c3cb65b3c245a2b9368fae347da0306a932c5985",teals:"bbdfdfa2d4d58ac9c975bcbb61b0af4da5a43799982b8b8c1e7f7f127273006667",warmGreys:"dcd4d0cec5c1c0b8b4b3aaa7a59c9998908c8b827f7e7673726866665c5a59504e",goldGreen:"f4d166d5ca60b6c35c98bb597cb25760a6564b9c533f8f4f33834a257740146c36",goldOrange:"f4d166f8be5cf8aa4cf5983bf3852aef701be2621fd65322c54923b142239e3a26",goldRed:"f4d166f6be59f9aa51fc964ef6834bee734ae56249db5247cf4244c43141b71d3e",lightGreyRed:"efe9e6e1dad7d5cbc8c8bdb9bbaea9cd967ddc7b43e15f19df4011dc000b",lightGreyTeal:"e4eaead6dcddc8ced2b7c2c7a6b4bc64b0bf22a6c32295c11f85be1876bc",lightMulti:"e0f1f2c4e9d0b0de9fd0e181f6e072f6c053f3993ef77440ef4a3c",lightOrange:"f2e7daf7d5baf9c499fab184fa9c73f68967ef7860e8645bde515bd43d5b",lightTealBlue:"e3e9e0c0dccf9aceca7abfc859afc0389fb9328dad2f7ca0276b95255988",darkBlue:"3232322d46681a5c930074af008cbf05a7ce25c0dd38daed50f3faffffff",darkGold:"3c3c3c584b37725e348c7631ae8b2bcfa424ecc31ef9de30fff184ffffff",darkGreen:"3a3a3a215748006f4d048942489e4276b340a6c63dd2d836ffeb2cffffaa",darkMulti:"3737371f5287197d8c29a86995ce3fffe800ffffff",darkRed:"3434347036339e3c38cc4037e75d1eec8620eeab29f0ce32ffeb2c"},S4={category10:"1f77b4ff7f0e2ca02cd627289467bd8c564be377c27f7f7fbcbd2217becf",category20:"1f77b4aec7e8ff7f0effbb782ca02c98df8ad62728ff98969467bdc5b0d58c564bc49c94e377c2f7b6d27f7f7fc7c7c7bcbd22dbdb8d17becf9edae5",category20b:"393b795254a36b6ecf9c9ede6379398ca252b5cf6bcedb9c8c6d31bd9e39e7ba52e7cb94843c39ad494ad6616be7969c7b4173a55194ce6dbdde9ed6",category20c:"3182bd6baed69ecae1c6dbefe6550dfd8d3cfdae6bfdd0a231a35474c476a1d99bc7e9c0756bb19e9ac8bcbddcdadaeb636363969696bdbdbdd9d9d9",tableau10:"4c78a8f58518e4575672b7b254a24beeca3bb279a2ff9da69d755dbab0ac",tableau20:"4c78a89ecae9f58518ffbf7954a24b88d27ab79a20f2cf5b43989483bcb6e45756ff9d9879706ebab0acd67195fcbfd2b279a2d6a5c99e765fd8b5a5",accent:"7fc97fbeaed4fdc086ffff99386cb0f0027fbf5b17666666",dark2:"1b9e77d95f027570b3e7298a66a61ee6ab02a6761d666666",paired:"a6cee31f78b4b2df8a33a02cfb9a99e31a1cfdbf6fff7f00cab2d66a3d9affff99b15928",pastel1:"fbb4aeb3cde3ccebc5decbe4fed9a6ffffcce5d8bdfddaecf2f2f2",pastel2:"b3e2cdfdcdaccbd5e8f4cae4e6f5c9fff2aef1e2cccccccc",set1:"e41a1c377eb84daf4a984ea3ff7f00ffff33a65628f781bf999999",set2:"66c2a5fc8d628da0cbe78ac3a6d854ffd92fe5c494b3b3b3",set3:"8dd3c7ffffb3bebadafb807280b1d3fdb462b3de69fccde5d9d9d9bc80bdccebc5ffed6f"};function h_(t){const e=t.length/6|0,n=new Array(e);for(let r=0;r<e;)n[r]="#"+t.slice(r*6,++r*6);return n}function d_(t,e){for(const n in t)Lp(n,e(t[n]))}const m1={};d_(S4,h_);d_(A4,t=>Ec(h_(t)));function Lp(t,e){return t=t&&t.toLowerCase(),arguments.length>1?(m1[t]=e,this):m1[t]}function C4(){let t=0;const e=new Map,n=r=>{let i=e.get(r);return i===void 0&&(i=t++,e.set(r,i)),i};return n.addAll=r=>{for(const i of r)n(i)},n.invert=r=>{for(const i of e.entries())if(i[1]==r)return i[0]},n.domain=()=>[...e.keys()],n}function Ac(){const t=e=>e;return t.invert=e=>e,t.copy=Ac,t.invertRange=()=>{},t.type="null",t}function T4(t,e){const n={};e||(e=t.encoding);for(const[r,i]of Object.entries(e)){if(!i)continue;const a=((sn(i)&&i.resolutionChannel)??(Ki(r)&&r))||void 0,o=t.unitView.getScaleResolution(a);n[r]=F4(e[r],o==null?void 0:o.getScale(),t.unitView.getAccessor(r),r)}return n}function F4(t,e,n,r){let i;if(Rn(t)){const a=t.value;i=o=>a,i.constant=!0,i.constantValue=!0,i.accessor=void 0}else if(n)if(r=="text")i=a=>{},i.accessor=n,i.constant=n.constant;else{if(!e)if(!Ki(r))e=Ac();else throw new Error(`Missing scale! "${r}": ${JSON.stringify(t)}`);if(i=a=>e(n(a)),hi(e.type)){const a=C4();a.addAll(e.domain()),i.indexer=a}i.constant=n.constant,i.accessor=n,i.scale=e}else throw new Error(`Missing value or accessor (field, expr, datum) on channel "${r}": ${JSON.stringify(t)}`);return i.invert=e?a=>e.invert(a):a=>{throw new Error("No scale available, cannot invert: "+JSON.stringify(t))},i.channelDef=t,i.applyMetadata=a=>{for(const o in i)o in i&&(a[o]=i[o]);return a},i}function Rn(t){return t&&"value"in t}function Pl(t){return t&&"field"in t}function zl(t){return t&&"datum"in t}function sn(t){return Pl(t)||zl(t)||Mp(t)||p_(t)}function t0(t,e){const n=t.mark.encoding[e];if(sn(n))return n;throw new Error("Not a channel def with scale!")}function p_(t){return t&&"chrom"in t}function Mp(t){return t&&"expr"in t}const Bo=["x","y"],I4=["x2","y2"],k4=[...Bo,...I4];function g_(t){return Bo.includes(t)}function Zs(t){return k4.includes(t)}const Pp={x:"x2",y:"y2"},m_=Object.fromEntries(Object.entries(Pp).map(t=>[t[1],t[0]]));function gs(t){return t in m_}function R4(t){const e=Pp[t];if(e)return e;throw new Error(`${t} has no secondary channel!`)}function aa(t){return m_[t]??t}function Xi(t){return["color","fill","stroke"].includes(aa(t))}function Sc(t){return["shape","squeeze"].includes(t)}function Ki(t){return["x","y","x2","y2","color","fill","stroke","opacity","fillOpacity","strokeOpacity","strokeWidth","size","shape","angle","dx","dy","sample"].includes(t)}function b_(t){switch(t){case"shape":return["circle","square","triangle-up","cross","diamond","triangle-down","triangle-right","triangle-left"]}}function y_(t){if(!Sc(t))throw new Error("Not a discrete channel: "+t);const e=new Map(b_(t).map((n,r)=>[n,r]));return n=>{const r=e.get(n);if(r!==void 0)return r;throw new Error(`Invalid value for "${t}" channel: ${n}`)}}function De(t,e=t){if(/^[A-Za-z0-9_]+$/.test(t)){const n=new Function("datum",`return datum[${JSON.stringify(t)}]`);return mi(n,[t],e)}else return Kf(t)}class D4{constructor(){this.accessorCreators=[],this.register(e=>{if(Pl(e))try{const n=De(e.field);return n.constant=!1,n.fields=Bw(n),n}catch(n){throw new Error(`Invalid field definition: ${n.message}`)}}),this.register(e=>Mp(e)?B4(e.expr):void 0),this.register(e=>{if(zl(e)){const r=p3(e.datum);return r.constant=!0,r.fields=[],r}})}register(e){this.accessorCreators.push(e)}createAccessor(e){for(const n of this.accessorCreators){const r=n(e);if(r)return r}}}function B4(t){const e=bp(t);return e.constant=e.fields.length==0,e}/* @license twgl.js 4.24.0 Copyright (c) 2015, Gregg Tavares All Rights Reserved. -Available via the MIT license. -see: http://github.com/greggman/twgl.js for details */const zp=5120,Ys=5121,Up=5122,qp=5123,Vp=5124,Hp=5125,Gp=5126,N4=32819,$4=32820,O4=33635,L4=5131,M4=33640,P4=35899,z4=35902,U4=36269,q4=34042,w_={};{const t=w_;t[zp]=Int8Array,t[Ys]=Uint8Array,t[Up]=Int16Array,t[qp]=Uint16Array,t[Vp]=Int32Array,t[Hp]=Uint32Array,t[Gp]=Float32Array,t[N4]=Uint16Array,t[$4]=Uint16Array,t[O4]=Uint16Array,t[L4]=Uint16Array,t[M4]=Uint32Array,t[P4]=Uint32Array,t[z4]=Uint32Array,t[U4]=Uint32Array,t[q4]=Uint32Array}function jp(t){if(t instanceof Int8Array)return zp;if(t instanceof Uint8Array||t instanceof Uint8ClampedArray)return Ys;if(t instanceof Int16Array)return Up;if(t instanceof Uint16Array)return qp;if(t instanceof Int32Array)return Vp;if(t instanceof Uint32Array)return Hp;if(t instanceof Float32Array)return Gp;throw new Error("unsupported typed array type")}function V4(t){if(t===Int8Array)return zp;if(t===Uint8Array||t===Uint8ClampedArray)return Ys;if(t===Int16Array)return Up;if(t===Uint16Array)return qp;if(t===Int32Array)return Vp;if(t===Uint32Array)return Hp;if(t===Float32Array)return Gp;throw new Error("unsupported typed array type")}function H4(t){const e=w_[t];if(!e)throw new Error("unknown gl type");return e}const gf=typeof SharedArrayBuffer<"u"?function(e){return e&&e.buffer&&(e.buffer instanceof ArrayBuffer||e.buffer instanceof SharedArrayBuffer)}:function(e){return e&&e.buffer&&e.buffer instanceof ArrayBuffer};function G4(...t){console.error(...t)}function x_(...t){console.warn(...t)}function j4(t,e){return typeof WebGLBuffer<"u"&&e instanceof WebGLBuffer}function __(t,e){return typeof WebGLRenderbuffer<"u"&&e instanceof WebGLRenderbuffer}function Cc(t,e){return typeof WebGLTexture<"u"&&e instanceof WebGLTexture}function W4(t,e){return typeof WebGLSampler<"u"&&e instanceof WebGLSampler}const v_=35044,rr=34962,Z4=34963,Y4=34660,X4=5120,K4=5121,J4=5122,Q4=5123,e8=5124,t8=5125,n8=5126,E_={attribPrefix:""};function A_(t,e,n,r,i){t.bindBuffer(e,n),t.bufferData(e,r,i||v_)}function S_(t,e,n,r){if(j4(t,e))return e;n=n||rr;const i=t.createBuffer();return A_(t,n,i,e,r),i}function C_(t){return t==="indices"}function r8(t){return t instanceof Int8Array||t instanceof Uint8Array}function i8(t){return t===Int8Array||t===Uint8Array}function a8(t){return t.length?t:t.data}const o8=/coord|texture/i,s8=/color|colour/i;function T_(t,e){let n;if(o8.test(t)?n=2:s8.test(t)?n=4:n=3,e%n>0)throw new Error(`Can not guess numComponents for attribute '${t}'. Tried ${n} but ${e} values is not evenly divisible by ${n}. You should specify it.`);return n}function l8(t,e){return t.numComponents||t.size||T_(e,a8(t).length)}function Wp(t,e){if(gf(t))return t;if(gf(t.data))return t.data;Array.isArray(t)&&(t={data:t});let n=t.type;return n||(C_(e)?n=Uint16Array:n=Float32Array),new n(t.data)}function u8(t,e){const n={};return Object.keys(e).forEach(function(r){if(!C_(r)){const i=e[r],a=i.attrib||i.name||i.attribName||E_.attribPrefix+r;if(i.value){if(!Array.isArray(i.value)&&!gf(i.value))throw new Error("array.value is not array or typedarray");n[a]={value:i.value}}else{let o,s,u,l;if(i.buffer&&i.buffer instanceof WebGLBuffer)o=i.buffer,l=i.numComponents||i.size,s=i.type,u=i.normalize;else if(typeof i=="number"||typeof i.data=="number"){const f=i.data||i,c=i.type||Float32Array,h=f*c.BYTES_PER_ELEMENT;s=V4(c),u=i.normalize!==void 0?i.normalize:i8(c),l=i.numComponents||i.size||T_(r,f),o=t.createBuffer(),t.bindBuffer(rr,o),t.bufferData(rr,h,i.drawType||v_)}else{const f=Wp(i,r);o=S_(t,f,void 0,i.drawType),s=jp(f),u=i.normalize!==void 0?i.normalize:r8(f),l=l8(i,r)}n[a]={buffer:o,numComponents:l,type:s,normalize:u,stride:i.stride||0,offset:i.offset||0,divisor:i.divisor===void 0?void 0:i.divisor,drawType:i.drawType}}}}),t.bindBuffer(rr,null),n}function f8(t,e,n,r){n=Wp(n),r!==void 0?(t.bindBuffer(rr,e.buffer),t.bufferSubData(rr,r,n)):A_(t,rr,e.buffer,n,e.drawType)}function c8(t,e){return e===X4||e===K4?1:e===J4||e===Q4?2:e===e8||e===t8||e===n8?4:0}const _h=["position","positions","a_position"];function h8(t,e){let n,r;for(r=0;r<_h.length&&(n=_h[r],!(n in e||(n=E_.attribPrefix+n,n in e)));++r);r===_h.length&&(n=Object.keys(e)[0]);const i=e[n];if(!i.buffer)return 1;t.bindBuffer(rr,i.buffer);const a=t.getBufferParameter(rr,Y4);t.bindBuffer(rr,null);const o=c8(t,i.type),s=a/o,u=i.numComponents||i.size,l=s/u;if(l%1!==0)throw new Error(`numComponents ${u} not correct for length ${length}`);return l}function d8(t,e,n){const r=u8(t,e),i=Object.assign({},n||{});i.attribs=Object.assign({},n?n.attribs:{},r);const a=e.indices;if(a){const o=Wp(a,"indices");i.indices=S_(t,o,Z4),i.numElements=o.length,i.elementType=jp(o)}else i.numElements||(i.numElements=h8(t,i.attribs));return i}function No(t){return!!t.texStorage2D}const n0=function(){const t={},e={};function n(r){const i=r.constructor.name;if(!t[i]){for(const a in r)if(typeof r[a]=="number"){const o=e[r[a]];e[r[a]]=o?`${o} | ${a}`:a}t[i]=!0}}return function(i,a){return n(i),e[a]||(typeof a=="number"?`0x${a.toString(16)}`:a)}}(),vi={textureColor:new Uint8Array([128,192,255,255]),textureOptions:{},crossOrigin:void 0},mo=gf,F_=function(){let t;return function(){return t=t||(typeof document<"u"&&document.createElement?document.createElement("canvas").getContext("2d"):null),t}}(),b1=6406,Vn=6407,Ge=6408,y1=6409,w1=6410,Qo=6402,x1=34041,mf=33071,p8=9728,g8=9729,$r=3553,Br=34067,di=32879,pi=35866,Tc=34069,m8=34070,b8=34071,y8=34072,w8=34073,x8=34074,r0=10241,i0=10240,bf=10242,yf=10243,_1=32882,_8=33082,v8=33083,E8=33084,A8=33085,Zp=3317,I_=3314,k_=32878,R_=3316,D_=3315,B_=32877,S8=37443,C8=37441,T8=37440,F8=33321,I8=36756,k8=33325,R8=33326,D8=33330,B8=33329,N8=33338,$8=33337,O8=33340,L8=33339,M8=33323,P8=36757,z8=33327,U8=33328,q8=33336,V8=33335,H8=33332,G8=33331,j8=33334,W8=33333,Z8=32849,Y8=35905,X8=36194,K8=36758,J8=35898,Q8=35901,eI=34843,tI=34837,nI=36221,rI=36239,iI=36215,aI=36233,oI=36209,sI=36227,lI=32856,uI=35907,fI=36759,cI=32855,hI=32854,dI=32857,pI=34842,gI=34836,mI=36220,bI=36238,yI=36975,wI=36214,xI=36232,_I=36226,vI=36208,EI=33189,AI=33190,SI=36012,CI=36013,TI=35056,Hr=5120,He=5121,bu=5122,Ta=5123,yu=5124,Fi=5125,bt=5126,v1=32819,E1=32820,A1=33635,vn=5131,es=36193,vh=33640,FI=35899,II=35902,kI=36269,RI=34042,wu=33319,Fa=33320,xu=6403,Ia=36244,ka=36248,Ii=36249;let Eh;function Fc(t){if(!Eh){const e={};e[b1]={textureFormat:b1,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[1,2,2,4],type:[He,vn,es,bt]},e[y1]={textureFormat:y1,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[1,2,2,4],type:[He,vn,es,bt]},e[w1]={textureFormat:w1,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[2,4,4,8],type:[He,vn,es,bt]},e[Vn]={textureFormat:Vn,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[3,6,6,12,2],type:[He,vn,es,bt,A1]},e[Ge]={textureFormat:Ge,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4,8,8,16,2,2],type:[He,vn,es,bt,v1,E1]},e[Qo]={textureFormat:Qo,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2,4],type:[Fi,Ta]},e[F8]={textureFormat:xu,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[1],type:[He]},e[I8]={textureFormat:xu,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[1],type:[Hr]},e[k8]={textureFormat:xu,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[4,2],type:[bt,vn]},e[R8]={textureFormat:xu,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[4],type:[bt]},e[D8]={textureFormat:Ia,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[1],type:[He]},e[B8]={textureFormat:Ia,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[1],type:[Hr]},e[H8]={textureFormat:Ia,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2],type:[Ta]},e[G8]={textureFormat:Ia,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2],type:[bu]},e[j8]={textureFormat:Ia,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[Fi]},e[W8]={textureFormat:Ia,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[yu]},e[M8]={textureFormat:wu,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[2],type:[He]},e[P8]={textureFormat:wu,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[2],type:[Hr]},e[z8]={textureFormat:wu,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[8,4],type:[bt,vn]},e[U8]={textureFormat:wu,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[8],type:[bt]},e[q8]={textureFormat:Fa,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2],type:[He]},e[V8]={textureFormat:Fa,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2],type:[Hr]},e[N8]={textureFormat:Fa,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[Ta]},e[$8]={textureFormat:Fa,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[bu]},e[O8]={textureFormat:Fa,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[8],type:[Fi]},e[L8]={textureFormat:Fa,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[8],type:[yu]},e[Z8]={textureFormat:Vn,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[3],type:[He]},e[Y8]={textureFormat:Vn,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[3],type:[He]},e[X8]={textureFormat:Vn,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[3,2],type:[He,A1]},e[K8]={textureFormat:Vn,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[3],type:[Hr]},e[J8]={textureFormat:Vn,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[12,6,4],type:[bt,vn,FI]},e[Q8]={textureFormat:Vn,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[12,6,4],type:[bt,vn,II]},e[eI]={textureFormat:Vn,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[12,6],type:[bt,vn]},e[tI]={textureFormat:Vn,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[12],type:[bt]},e[nI]={textureFormat:ka,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[3],type:[He]},e[rI]={textureFormat:ka,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[3],type:[Hr]},e[iI]={textureFormat:ka,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[6],type:[Ta]},e[aI]={textureFormat:ka,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[6],type:[bu]},e[oI]={textureFormat:ka,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[12],type:[Fi]},e[sI]={textureFormat:ka,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[12],type:[yu]},e[lI]={textureFormat:Ge,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4],type:[He]},e[uI]={textureFormat:Ge,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4],type:[He]},e[fI]={textureFormat:Ge,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[4],type:[Hr]},e[cI]={textureFormat:Ge,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4,2,4],type:[He,E1,vh]},e[hI]={textureFormat:Ge,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4,2],type:[He,v1]},e[dI]={textureFormat:Ge,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4],type:[vh]},e[pI]={textureFormat:Ge,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[16,8],type:[bt,vn]},e[gI]={textureFormat:Ge,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[16],type:[bt]},e[mI]={textureFormat:Ii,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[He]},e[bI]={textureFormat:Ii,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[Hr]},e[yI]={textureFormat:Ii,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[vh]},e[wI]={textureFormat:Ii,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[8],type:[Ta]},e[xI]={textureFormat:Ii,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[8],type:[bu]},e[_I]={textureFormat:Ii,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[16],type:[yu]},e[vI]={textureFormat:Ii,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[16],type:[Fi]},e[EI]={textureFormat:Qo,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2,4],type:[Ta,Fi]},e[AI]={textureFormat:Qo,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[Fi]},e[SI]={textureFormat:Qo,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[bt]},e[TI]={textureFormat:x1,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[RI]},e[CI]={textureFormat:x1,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[kI]},Object.keys(e).forEach(function(n){const r=e[n];r.bytesPerElementMap={},r.bytesPerElement.forEach(function(i,a){const o=r.type[a];r.bytesPerElementMap[o]=i})}),Eh=e}return Eh[t]}function DI(t,e){const n=Fc(t);if(!n)throw"unknown internal format";const r=n.bytesPerElementMap[e];if(r===void 0)throw"unknown internal format";return r}function $o(t){const e=Fc(t);if(!e)throw"unknown internal format";return{format:e.textureFormat,type:e.type[0]}}function S1(t){return(t&t-1)===0}function BI(t,e,n,r){if(!No(t))return S1(e)&&S1(n);const i=Fc(r);if(!i)throw"unknown internal format";return i.colorRenderable&&i.textureFilterable}function NI(t){const e=Fc(t);if(!e)throw"unknown internal format";return e.textureFilterable}function N_(t,e,n){return mo(e)?jp(e):n||He}function _u(t,e,n,r,i){if(i%1!==0)throw"can't guess dimensions";if(!n&&!r){const a=Math.sqrt(i/(e===Br?6:1));a%1===0?(n=a,r=a):(n=i,r=1)}else if(r){if(!n&&(n=i/r,n%1))throw"can't guess dimensions"}else if(r=i/n,r%1)throw"can't guess dimensions";return{width:n,height:r}}function bo(t,e){e.colorspaceConversion!==void 0&&t.pixelStorei(S8,e.colorspaceConversion),e.premultiplyAlpha!==void 0&&t.pixelStorei(C8,e.premultiplyAlpha),e.flipY!==void 0&&t.pixelStorei(T8,e.flipY)}function $_(t){t.pixelStorei(Zp,4),No(t)&&(t.pixelStorei(I_,0),t.pixelStorei(k_,0),t.pixelStorei(R_,0),t.pixelStorei(D_,0),t.pixelStorei(B_,0))}function $I(t,e,n,r){r.minMag&&(n.call(t,e,r0,r.minMag),n.call(t,e,i0,r.minMag)),r.min&&n.call(t,e,r0,r.min),r.mag&&n.call(t,e,i0,r.mag),r.wrap&&(n.call(t,e,bf,r.wrap),n.call(t,e,yf,r.wrap),(e===di||W4(t,e))&&n.call(t,e,_1,r.wrap)),r.wrapR&&n.call(t,e,_1,r.wrapR),r.wrapS&&n.call(t,e,bf,r.wrapS),r.wrapT&&n.call(t,e,yf,r.wrapT),r.minLod&&n.call(t,e,_8,r.minLod),r.maxLod&&n.call(t,e,v8,r.maxLod),r.baseLevel&&n.call(t,e,E8,r.baseLevel),r.maxLevel&&n.call(t,e,A8,r.maxLevel)}function O_(t,e,n){const r=n.target||$r;t.bindTexture(r,e),$I(t,r,t.texParameteri,n)}function OI(t){return t=t||vi.textureColor,mo(t)?t:new Uint8Array([t[0]*255,t[1]*255,t[2]*255,t[3]*255])}function a0(t,e,n,r,i,a){n=n||vi.textureOptions,a=a||Ge;const o=n.target||$r;if(r=r||n.width,i=i||n.height,t.bindTexture(o,e),BI(t,r,i,a))t.generateMipmap(o);else{const s=NI(a)?g8:p8;t.texParameteri(o,r0,s),t.texParameteri(o,i0,s),t.texParameteri(o,bf,mf),t.texParameteri(o,yf,mf)}}function Xs(t){return t.auto===!0||t.auto===void 0&&t.level===void 0}function o0(t,e){return e=e||{},e.cubeFaceOrder||[Tc,m8,b8,y8,w8,x8]}function s0(t,e){const r=o0(t,e).map(function(i,a){return{face:i,ndx:a}});return r.sort(function(i,a){return i.face-a.face}),r}function L_(t,e,n,r){r=r||vi.textureOptions;const i=r.target||$r,a=r.level||0;let o=n.width,s=n.height;const u=r.internalFormat||r.format||Ge,l=$o(u),f=r.format||l.format,c=r.type||l.type;if(bo(t,r),t.bindTexture(i,e),i===Br){const h=n.width,d=n.height;let p,m;if(h/6===d)p=d,m=[0,0,1,0,2,0,3,0,4,0,5,0];else if(d/6===h)p=h,m=[0,0,0,1,0,2,0,3,0,4,0,5];else if(h/3===d/2)p=h/3,m=[0,0,1,0,2,0,0,1,1,1,2,1];else if(h/2===d/3)p=h/2,m=[0,0,1,0,0,1,1,1,0,2,1,2];else throw"can't figure out cube map from element: "+(n.src?n.src:n.nodeName);const y=F_();y?(y.canvas.width=p,y.canvas.height=p,o=p,s=p,s0(t,r).forEach(function(w){const A=m[w.ndx*2+0]*p,C=m[w.ndx*2+1]*p;y.drawImage(n,A,C,p,p,0,0,p,p),t.texImage2D(w.face,a,u,f,c,y.canvas)}),y.canvas.width=1,y.canvas.height=1):typeof createImageBitmap<"u"&&(o=p,s=p,s0(t,r).forEach(function(w){const A=m[w.ndx*2+0]*p,C=m[w.ndx*2+1]*p;t.texImage2D(w.face,a,u,p,p,0,f,c,null),createImageBitmap(n,A,C,p,p,{premultiplyAlpha:"none",colorSpaceConversion:"none"}).then(function(E){bo(t,r),t.bindTexture(i,e),t.texImage2D(w.face,a,u,f,c,E),Xs(r)&&a0(t,e,r,o,s,u)})}))}else if(i===di||i===pi){const h=Math.min(n.width,n.height),d=Math.max(n.width,n.height),p=d/h;if(p%1!==0)throw"can not compute 3D dimensions of element";const m=n.width===d?1:0,y=n.height===d?1:0;t.pixelStorei(Zp,1),t.pixelStorei(I_,n.width),t.pixelStorei(k_,0),t.pixelStorei(B_,0),t.texImage3D(i,a,u,h,h,h,0,f,c,null);for(let w=0;w<p;++w){const A=w*h*m,C=w*h*y;t.pixelStorei(R_,A),t.pixelStorei(D_,C),t.texSubImage3D(i,a,0,0,w,h,h,1,f,c,n)}$_(t)}else t.texImage2D(i,a,u,f,c,n);Xs(r)&&a0(t,e,r,o,s,u),O_(t,e,r)}function Ul(){}function LI(t){if(typeof document<"u"){const e=document.createElement("a");return e.href=t,e.hostname===location.hostname&&e.port===location.port&&e.protocol===location.protocol}else{const e=new URL(location.href).origin;return new URL(t,location.href).origin===e}}function MI(t,e){return e===void 0&&!LI(t)?"anonymous":e}function PI(t,e,n){n=n||Ul;let r;if(e=e!==void 0?e:vi.crossOrigin,e=MI(t,e),typeof Image<"u"){r=new Image,e!==void 0&&(r.crossOrigin=e);const i=function(){r.removeEventListener("error",a),r.removeEventListener("load",o),r=null},a=function(){const u="couldn't load image: "+t;G4(u),n(u,r),i()},o=function(){n(null,r),i()};return r.addEventListener("error",a),r.addEventListener("load",o),r.src=t,r}else if(typeof ImageBitmap<"u"){let i,a;const o=function(){n(i,a)},s={};e&&(s.mode="cors"),fetch(t,s).then(function(u){if(!u.ok)throw u;return u.blob()}).then(function(u){return createImageBitmap(u,{premultiplyAlpha:"none",colorSpaceConversion:"none"})}).then(function(u){a=u,setTimeout(o)}).catch(function(u){i=u,setTimeout(o)}),r=null}return r}function M_(t){return typeof ImageBitmap<"u"&&t instanceof ImageBitmap||typeof ImageData<"u"&&t instanceof ImageData||typeof HTMLElement<"u"&&t instanceof HTMLElement}function Yp(t,e,n){return M_(t)?(setTimeout(function(){n(null,t)}),t):PI(t,e,n)}function Xp(t,e,n){n=n||vi.textureOptions;const r=n.target||$r;if(t.bindTexture(r,e),n.color===!1)return;const i=OI(n.color);if(r===Br)for(let a=0;a<6;++a)t.texImage2D(Tc+a,0,Ge,1,1,0,Ge,He,i);else r===di||r===pi?t.texImage3D(r,0,Ge,1,1,1,0,Ge,He,i):t.texImage2D(r,0,Ge,1,1,0,Ge,He,i)}function zI(t,e,n,r){return r=r||Ul,n=n||vi.textureOptions,Xp(t,e,n),n=Object.assign({},n),Yp(n.src,n.crossOrigin,function(a,o){a?r(a,e,o):(L_(t,e,o,n),r(null,e,o))})}function UI(t,e,n,r){r=r||Ul;const i=n.src;if(i.length!==6)throw"there must be 6 urls for a cubemap";const a=n.level||0,o=n.internalFormat||n.format||Ge,s=$o(o),u=n.format||s.format,l=n.type||He,f=n.target||$r;if(f!==Br)throw"target must be TEXTURE_CUBE_MAP";Xp(t,e,n),n=Object.assign({},n);let c=6;const h=[],d=o0(t,n);let p;function m(y){return function(w,A){--c,w?h.push(w):A.width!==A.height?h.push("cubemap face img is not a square: "+A.src):(bo(t,n),t.bindTexture(f,e),c===5?o0().forEach(function(C){t.texImage2D(C,a,o,u,l,A)}):t.texImage2D(y,a,o,u,l,A),Xs(n)&&t.generateMipmap(f)),c===0&&r(h.length?h:void 0,e,p)}}p=i.map(function(y,w){return Yp(y,n.crossOrigin,m(d[w]))})}function qI(t,e,n,r){r=r||Ul;const i=n.src,a=n.internalFormat||n.format||Ge,o=$o(a),s=n.format||o.format,u=n.type||He,l=n.target||pi;if(l!==di&&l!==pi)throw"target must be TEXTURE_3D or TEXTURE_2D_ARRAY";Xp(t,e,n),n=Object.assign({},n);let f=i.length;const c=[];let h;const d=n.level||0;let p=n.width,m=n.height;const y=i.length;let w=!0;function A(C){return function(E,k){if(--f,E)c.push(E);else{if(bo(t,n),t.bindTexture(l,e),w){w=!1,p=n.width||k.width,m=n.height||k.height,t.texImage3D(l,d,a,p,m,y,0,s,u,null);for(let R=0;R<y;++R)t.texSubImage3D(l,d,0,0,R,p,m,1,s,u,k)}else{let R=k,I;(k.width!==p||k.height!==m)&&(I=F_(),R=I.canvas,I.canvas.width=p,I.canvas.height=m,I.drawImage(k,0,0,p,m)),t.texSubImage3D(l,d,0,0,C,p,m,1,s,u,R),I&&R===I.canvas&&(I.canvas.width=0,I.canvas.height=0)}Xs(n)&&t.generateMipmap(l)}f===0&&r(c.length?c:void 0,e,h)}}h=i.map(function(C,E){return Yp(C,n.crossOrigin,A(E))})}function P_(t,e,n,r){r=r||vi.textureOptions;const i=r.target||$r;t.bindTexture(i,e);let a=r.width,o=r.height,s=r.depth;const u=r.level||0,l=r.internalFormat||r.format||Ge,f=$o(l),c=r.format||f.format,h=r.type||N_(t,n,f.type);if(mo(n))n instanceof Uint8ClampedArray&&(n=new Uint8Array(n.buffer));else{const y=H4(h);n=new y(n)}const d=DI(l,h),p=n.byteLength/d;if(p%1)throw"length wrong size for format: "+n0(t,c);let m;if(i===di||i===pi)if(!a&&!o&&!s){const y=Math.cbrt(p);if(y%1!==0)throw"can't guess cube size of array of numElements: "+p;a=y,o=y,s=y}else a&&(!o||!s)?(m=_u(t,i,o,s,p/a),o=m.width,s=m.height):o&&(!a||!s)?(m=_u(t,i,a,s,p/o),a=m.width,s=m.height):(m=_u(t,i,a,o,p/s),a=m.width,o=m.height);else m=_u(t,i,a,o,p),a=m.width,o=m.height;if($_(t),t.pixelStorei(Zp,r.unpackAlignment||1),bo(t,r),i===Br){const y=d/n.BYTES_PER_ELEMENT,w=p/6*y;s0(t,r).forEach(A=>{const C=w*A.ndx,E=n.subarray(C,C+w);t.texImage2D(A.face,u,l,a,o,0,c,h,E)})}else i===di||i===pi?t.texImage3D(i,u,l,a,o,s,0,c,h,n):t.texImage2D(i,u,l,a,o,0,c,h,n);return{width:a,height:o,depth:s,type:h}}function VI(t,e,n){const r=n.target||$r;t.bindTexture(r,e);const i=n.level||0,a=n.internalFormat||n.format||Ge,o=$o(a),s=n.format||o.format,u=n.type||o.type;if(bo(t,n),r===Br)for(let l=0;l<6;++l)t.texImage2D(Tc+l,i,a,n.width,n.height,0,s,u,null);else r===di||r===pi?t.texImage3D(r,i,a,n.width,n.height,n.depth,0,s,u,null):t.texImage2D(r,i,a,n.width,n.height,0,s,u,null)}function Ks(t,e,n){n=n||Ul,e=e||vi.textureOptions;const r=t.createTexture(),i=e.target||$r;let a=e.width||1,o=e.height||1;const s=e.internalFormat||Ge;t.bindTexture(i,r),i===Br&&(t.texParameteri(i,bf,mf),t.texParameteri(i,yf,mf));let u=e.src;if(u)if(typeof u=="function"&&(u=u(t,e)),typeof u=="string")zI(t,r,e,n);else if(mo(u)||Array.isArray(u)&&(typeof u[0]=="number"||Array.isArray(u[0])||mo(u[0]))){const l=P_(t,r,u,e);a=l.width,o=l.height}else Array.isArray(u)&&(typeof u[0]=="string"||M_(u[0]))?i===Br?UI(t,r,e,n):qI(t,r,e,n):(L_(t,r,u,e),a=u.width,o=u.height);else VI(t,r,e);return Xs(e)&&a0(t,r,e,a,o,s),O_(t,r,e),r}function HI(t,e,n,r,i,a){r=r||n.width,i=i||n.height,a=a||n.depth;const o=n.target||$r;t.bindTexture(o,e);const s=n.level||0,u=n.internalFormat||n.format||Ge,l=$o(u),f=n.format||l.format;let c;const h=n.src;if(h&&(mo(h)||Array.isArray(h)&&typeof h[0]=="number")?c=n.type||N_(t,h,l.type):c=n.type||l.type,o===Br)for(let d=0;d<6;++d)t.texImage2D(Tc+d,s,u,r,i,0,f,c,null);else o===di||o===pi?t.texImage3D(o,s,u,r,i,a,0,f,c,null):t.texImage2D(o,s,u,r,i,0,f,c,null)}const GI=x_,wf=33984,jI=35048,Ic=34962,WI=34963,Kp=35345,z_=35718,ZI=35721,YI=35971,XI=35382,KI=35396,JI=35398,QI=35392,ek=35395,kc=5126,U_=35664,q_=35665,V_=35666,Jp=5124,H_=35667,G_=35668,j_=35669,W_=35670,Z_=35671,Y_=35672,X_=35673,K_=35674,J_=35675,Q_=35676,tk=35678,nk=35680,rk=35679,ik=35682,ak=35685,ok=35686,sk=35687,lk=35688,uk=35689,fk=35690,ck=36289,hk=36292,dk=36293,Qp=5125,ev=36294,tv=36295,nv=36296,pk=36298,gk=36299,mk=36300,bk=36303,yk=36306,wk=36307,xk=36308,_k=36311,Rc=3553,Dc=34067,eg=32879,Bc=35866,le={};function rv(t,e){return le[e].bindPoint}function vk(t,e){return function(n){t.uniform1f(e,n)}}function Ek(t,e){return function(n){t.uniform1fv(e,n)}}function Ak(t,e){return function(n){t.uniform2fv(e,n)}}function Sk(t,e){return function(n){t.uniform3fv(e,n)}}function Ck(t,e){return function(n){t.uniform4fv(e,n)}}function iv(t,e){return function(n){t.uniform1i(e,n)}}function av(t,e){return function(n){t.uniform1iv(e,n)}}function ov(t,e){return function(n){t.uniform2iv(e,n)}}function sv(t,e){return function(n){t.uniform3iv(e,n)}}function lv(t,e){return function(n){t.uniform4iv(e,n)}}function Tk(t,e){return function(n){t.uniform1ui(e,n)}}function Fk(t,e){return function(n){t.uniform1uiv(e,n)}}function Ik(t,e){return function(n){t.uniform2uiv(e,n)}}function kk(t,e){return function(n){t.uniform3uiv(e,n)}}function Rk(t,e){return function(n){t.uniform4uiv(e,n)}}function Dk(t,e){return function(n){t.uniformMatrix2fv(e,!1,n)}}function Bk(t,e){return function(n){t.uniformMatrix3fv(e,!1,n)}}function Nk(t,e){return function(n){t.uniformMatrix4fv(e,!1,n)}}function $k(t,e){return function(n){t.uniformMatrix2x3fv(e,!1,n)}}function Ok(t,e){return function(n){t.uniformMatrix3x2fv(e,!1,n)}}function Lk(t,e){return function(n){t.uniformMatrix2x4fv(e,!1,n)}}function Mk(t,e){return function(n){t.uniformMatrix4x2fv(e,!1,n)}}function Pk(t,e){return function(n){t.uniformMatrix3x4fv(e,!1,n)}}function zk(t,e){return function(n){t.uniformMatrix4x3fv(e,!1,n)}}function Ft(t,e,n,r){const i=rv(t,e);return No(t)?function(a){let o,s;Cc(t,a)?(o=a,s=null):(o=a.texture,s=a.sampler),t.uniform1i(r,n),t.activeTexture(wf+n),t.bindTexture(i,o),t.bindSampler(n,s)}:function(a){t.uniform1i(r,n),t.activeTexture(wf+n),t.bindTexture(i,a)}}function It(t,e,n,r,i){const a=rv(t,e),o=new Int32Array(i);for(let s=0;s<i;++s)o[s]=n+s;return No(t)?function(s){t.uniform1iv(r,o),s.forEach(function(u,l){t.activeTexture(wf+o[l]);let f,c;Cc(t,u)?(f=u,c=null):(f=u.texture,c=u.sampler),t.bindSampler(n,c),t.bindTexture(a,f)})}:function(s){t.uniform1iv(r,o),s.forEach(function(u,l){t.activeTexture(wf+o[l]),t.bindTexture(a,u)})}}le[kc]={Type:Float32Array,size:4,setter:vk,arraySetter:Ek};le[U_]={Type:Float32Array,size:8,setter:Ak,cols:2};le[q_]={Type:Float32Array,size:12,setter:Sk,cols:3};le[V_]={Type:Float32Array,size:16,setter:Ck,cols:4};le[Jp]={Type:Int32Array,size:4,setter:iv,arraySetter:av};le[H_]={Type:Int32Array,size:8,setter:ov,cols:2};le[G_]={Type:Int32Array,size:12,setter:sv,cols:3};le[j_]={Type:Int32Array,size:16,setter:lv,cols:4};le[Qp]={Type:Uint32Array,size:4,setter:Tk,arraySetter:Fk};le[ev]={Type:Uint32Array,size:8,setter:Ik,cols:2};le[tv]={Type:Uint32Array,size:12,setter:kk,cols:3};le[nv]={Type:Uint32Array,size:16,setter:Rk,cols:4};le[W_]={Type:Uint32Array,size:4,setter:iv,arraySetter:av};le[Z_]={Type:Uint32Array,size:8,setter:ov,cols:2};le[Y_]={Type:Uint32Array,size:12,setter:sv,cols:3};le[X_]={Type:Uint32Array,size:16,setter:lv,cols:4};le[K_]={Type:Float32Array,size:32,setter:Dk,rows:2,cols:2};le[J_]={Type:Float32Array,size:48,setter:Bk,rows:3,cols:3};le[Q_]={Type:Float32Array,size:64,setter:Nk,rows:4,cols:4};le[ak]={Type:Float32Array,size:32,setter:$k,rows:2,cols:3};le[ok]={Type:Float32Array,size:32,setter:Lk,rows:2,cols:4};le[sk]={Type:Float32Array,size:48,setter:Ok,rows:3,cols:2};le[lk]={Type:Float32Array,size:48,setter:Pk,rows:3,cols:4};le[uk]={Type:Float32Array,size:64,setter:Mk,rows:4,cols:2};le[fk]={Type:Float32Array,size:64,setter:zk,rows:4,cols:3};le[tk]={Type:null,size:0,setter:Ft,arraySetter:It,bindPoint:Rc};le[nk]={Type:null,size:0,setter:Ft,arraySetter:It,bindPoint:Dc};le[rk]={Type:null,size:0,setter:Ft,arraySetter:It,bindPoint:eg};le[ik]={Type:null,size:0,setter:Ft,arraySetter:It,bindPoint:Rc};le[ck]={Type:null,size:0,setter:Ft,arraySetter:It,bindPoint:Bc};le[hk]={Type:null,size:0,setter:Ft,arraySetter:It,bindPoint:Bc};le[dk]={Type:null,size:0,setter:Ft,arraySetter:It,bindPoint:Dc};le[pk]={Type:null,size:0,setter:Ft,arraySetter:It,bindPoint:Rc};le[gk]={Type:null,size:0,setter:Ft,arraySetter:It,bindPoint:eg};le[mk]={Type:null,size:0,setter:Ft,arraySetter:It,bindPoint:Dc};le[bk]={Type:null,size:0,setter:Ft,arraySetter:It,bindPoint:Bc};le[yk]={Type:null,size:0,setter:Ft,arraySetter:It,bindPoint:Rc};le[wk]={Type:null,size:0,setter:Ft,arraySetter:It,bindPoint:eg};le[xk]={Type:null,size:0,setter:Ft,arraySetter:It,bindPoint:Dc};le[_k]={Type:null,size:0,setter:Ft,arraySetter:It,bindPoint:Bc};function Nc(t,e){return function(n){if(n.value)switch(t.disableVertexAttribArray(e),n.value.length){case 4:t.vertexAttrib4fv(e,n.value);break;case 3:t.vertexAttrib3fv(e,n.value);break;case 2:t.vertexAttrib2fv(e,n.value);break;case 1:t.vertexAttrib1fv(e,n.value);break;default:throw new Error("the length of a float constant value must be between 1 and 4!")}else t.bindBuffer(Ic,n.buffer),t.enableVertexAttribArray(e),t.vertexAttribPointer(e,n.numComponents||n.size,n.type||kc,n.normalize||!1,n.stride||0,n.offset||0),n.divisor!==void 0&&t.vertexAttribDivisor(e,n.divisor)}}function Ei(t,e){return function(n){if(n.value)if(t.disableVertexAttribArray(e),n.value.length===4)t.vertexAttrib4iv(e,n.value);else throw new Error("The length of an integer constant value must be 4!");else t.bindBuffer(Ic,n.buffer),t.enableVertexAttribArray(e),t.vertexAttribIPointer(e,n.numComponents||n.size,n.type||Jp,n.stride||0,n.offset||0),n.divisor!==void 0&&t.vertexAttribDivisor(e,n.divisor)}}function $c(t,e){return function(n){if(n.value)if(t.disableVertexAttribArray(e),n.value.length===4)t.vertexAttrib4uiv(e,n.value);else throw new Error("The length of an unsigned integer constant value must be 4!");else t.bindBuffer(Ic,n.buffer),t.enableVertexAttribArray(e),t.vertexAttribIPointer(e,n.numComponents||n.size,n.type||Qp,n.stride||0,n.offset||0),n.divisor!==void 0&&t.vertexAttribDivisor(e,n.divisor)}}function tg(t,e,n){const r=n.size,i=n.count;return function(a){t.bindBuffer(Ic,a.buffer);const o=a.size||a.numComponents||r,s=o/i,u=a.type||kc,f=le[u].size*o,c=a.normalize||!1,h=a.offset||0,d=f/i;for(let p=0;p<i;++p)t.enableVertexAttribArray(e+p),t.vertexAttribPointer(e+p,s,u,c,f,h+d*p),a.divisor!==void 0&&t.vertexAttribDivisor(e+p,a.divisor)}}const Qe={};Qe[kc]={size:4,setter:Nc};Qe[U_]={size:8,setter:Nc};Qe[q_]={size:12,setter:Nc};Qe[V_]={size:16,setter:Nc};Qe[Jp]={size:4,setter:Ei};Qe[H_]={size:8,setter:Ei};Qe[G_]={size:12,setter:Ei};Qe[j_]={size:16,setter:Ei};Qe[Qp]={size:4,setter:$c};Qe[ev]={size:8,setter:$c};Qe[tv]={size:12,setter:$c};Qe[nv]={size:16,setter:$c};Qe[W_]={size:4,setter:Ei};Qe[Z_]={size:8,setter:Ei};Qe[Y_]={size:12,setter:Ei};Qe[X_]={size:16,setter:Ei};Qe[K_]={size:4,setter:tg,count:2};Qe[J_]={size:9,setter:tg,count:3};Qe[Q_]={size:16,setter:tg,count:4};function uv(t){const e=t.name;return e.startsWith("gl_")||e.startsWith("webgl_")}const Uk=/(\.|\[|]|\w+)/g,qk=t=>t>="0"&&t<="9";function fv(t,e,n,r){const i=t.split(Uk).filter(s=>s!=="");let a=0,o="";for(;;){const s=i[a++];o+=s;const u=qk(s[0]),l=u?parseInt(s):s;if(u&&(o+=i[a++]),a===i.length){n[l]=e;break}else{const c=i[a++],h=c==="[",d=n[l]||(h?[]:{});n[l]=d,n=d,r[o]=r[o]||function(p){return function(m){cv(p,m)}}(d),o+=c}}}function Vk(t,e){let n=0;function r(s,u,l){const f=u.name.endsWith("[0]"),c=u.type,h=le[c];if(!h)throw new Error(`unknown type: 0x${c.toString(16)}`);let d;if(h.bindPoint){const p=n;n+=u.size,f?d=h.arraySetter(t,c,p,l,u.size):d=h.setter(t,c,p,l,u.size)}else h.arraySetter&&f?d=h.arraySetter(t,l):d=h.setter(t,l);return d.location=l,d}const i={},a={},o=t.getProgramParameter(e,z_);for(let s=0;s<o;++s){const u=t.getActiveUniform(e,s);if(uv(u))continue;let l=u.name;l.endsWith("[0]")&&(l=l.substr(0,l.length-3));const f=t.getUniformLocation(e,u.name);if(f){const c=r(e,u,f);i[l]=c,fv(l,c,a,i)}}return i}function Hk(t,e){const n={},r=t.getProgramParameter(e,YI);for(let i=0;i<r;++i){const a=t.getTransformFeedbackVarying(e,i);n[a.name]={index:i,type:a.type,size:a.size}}return n}function Gk(t,e){const n=t.getProgramParameter(e,z_),r=[],i=[];for(let s=0;s<n;++s){i.push(s),r.push({});const u=t.getActiveUniform(e,s);r[s].name=u.name}[["UNIFORM_TYPE","type"],["UNIFORM_SIZE","size"],["UNIFORM_BLOCK_INDEX","blockNdx"],["UNIFORM_OFFSET","offset"]].forEach(function(s){const u=s[0],l=s[1];t.getActiveUniforms(e,i,t[u]).forEach(function(f,c){r[c][l]=f})});const a={},o=t.getProgramParameter(e,XI);for(let s=0;s<o;++s){const u=t.getActiveUniformBlockName(e,s),l={index:t.getUniformBlockIndex(e,u),usedByVertexShader:t.getActiveUniformBlockParameter(e,s,KI),usedByFragmentShader:t.getActiveUniformBlockParameter(e,s,JI),size:t.getActiveUniformBlockParameter(e,s,QI),uniformIndices:t.getActiveUniformBlockParameter(e,s,ek)};l.used=l.usedByVertexShader||l.usedByFragmentShader,a[u]=l}return{blockSpecs:a,uniformData:r}}const C1=/\[\d+\]\.$/,jk=(t,e)=>((t+(e-1))/e|0)*e;function Wk(t,e,n,r){if(e||n){r=r||1;const a=t.length/4;return function(o){let s=0,u=0;for(let l=0;l<a;++l){for(let f=0;f<r;++f)t[s++]=o[u++];s+=4-r}}}else return function(i){i.length?t.set(i):t[0]=i}}function Zk(t,e,n,r){const i=n.blockSpecs,a=n.uniformData,o=i[r];if(!o)return GI("no uniform block object named:",r),{name:r,uniforms:{}};const s=new ArrayBuffer(o.size),u=t.createBuffer(),l=o.index;t.bindBuffer(Kp,u),t.uniformBlockBinding(e,o.index,l);let f=r+".";C1.test(f)&&(f=f.replace(C1,"."));const c={},h={},d={};return o.uniformIndices.forEach(function(p){const m=a[p];let y=m.name;y.startsWith(f)&&(y=y.substr(f.length));const w=y.endsWith("[0]");w&&(y=y.substr(0,y.length-3));const A=le[m.type],C=A.Type,E=w?jk(A.size,16)*m.size:A.size*m.size,k=new C(s,m.offset,E/C.BYTES_PER_ELEMENT);c[y]=k;const R=Wk(k,w,A.rows,A.cols);h[y]=R,fv(y,R,d,h)}),{name:r,array:s,asFloat:new Float32Array(s),buffer:u,uniforms:c,setters:h}}function T1(t,e,n){return Zk(t,e.program,e.uniformBlockSpec,n)}function Yk(t,e,n){const i=(e.uniformBlockSpec||e).blockSpecs[n.name];if(i){const a=i.index;return t.bindBufferRange(Kp,a,n.buffer,n.offset||0,n.array.byteLength),!0}return!1}function F1(t,e,n){Yk(t,e,n)&&t.bufferData(Kp,n.array,jI)}function I1(t,e){const n=t.setters;for(const r in e){const i=n[r];if(i){const a=e[r];i(a)}}}function cv(t,e){for(const n in e){const r=t[n];typeof r=="function"?r(e[n]):cv(t[n],e[n])}}function Zt(t,...e){const n=t.uniformSetters||t,r=e.length;for(let i=0;i<r;++i){const a=e[i];if(Array.isArray(a)){const o=a.length;for(let s=0;s<o;++s)Zt(n,a[s])}else for(const o in a){const s=n[o];s&&s(a[o])}}}function Xk(t,e){const n={},r=t.getProgramParameter(e,ZI);for(let i=0;i<r;++i){const a=t.getActiveAttrib(e,i);if(uv(a))continue;const o=t.getAttribLocation(e,a.name),s=Qe[a.type],u=s.setter(t,o,s);u.location=o,n[a.name]=u}return n}function Kk(t,e){for(const n in e){const r=t[n];r&&r(e[n])}}function Oo(t,e,n){n.vertexArrayObject?t.bindVertexArray(n.vertexArrayObject):(Kk(e.attribSetters||e,n.attribs),n.indices&&t.bindBuffer(WI,n.indices))}function Jk(t,e){const n=Vk(t,e),r=Xk(t,e),i={program:e,uniformSetters:n,attribSetters:r};return No(t)&&(i.uniformBlockSpec=Gk(t,e),i.transformFeedbackInfo=Hk(t,e)),i}const Qk=4,k1=5123;function ql(t,e,n,r,i,a){n=n===void 0?Qk:n;const o=e.indices,s=e.elementType,u=r===void 0?e.numElements:r;i=i===void 0?0:i,s||o?a!==void 0?t.drawElementsInstanced(n,u,s===void 0?k1:e.elementType,i,a):t.drawElements(n,u,s===void 0?k1:e.elementType,i):a!==void 0?t.drawArraysInstanced(n,i,u,a):t.drawArrays(n,i,u)}const eR=36160,Oi=36161,tR=3553,nR=5121,rR=6402,iR=6408,aR=33190,oR=36012,sR=35056,lR=36013,uR=32854,fR=32855,cR=36194,hv=33189,dv=6401,pv=36168,ng=34041,l0=36064,Oc=36096,gv=36128,rg=33306,u0=33071,f0=9729,mv=[{format:iR,type:nR,min:f0,wrap:u0},{format:ng}],Dn={};Dn[ng]=rg;Dn[dv]=gv;Dn[pv]=gv;Dn[rR]=Oc;Dn[hv]=Oc;Dn[aR]=Oc;Dn[oR]=Oc;Dn[sR]=rg;Dn[lR]=rg;function hR(t,e){return Dn[t]||Dn[e]}const Ai={};Ai[uR]=!0;Ai[fR]=!0;Ai[cR]=!0;Ai[ng]=!0;Ai[hv]=!0;Ai[dv]=!0;Ai[pv]=!0;function dR(t){return Ai[t]}const pR=32;function gR(t){return t>=l0&&t<l0+pR}function mR(t,e,n,r){const i=eR,a=t.createFramebuffer();t.bindFramebuffer(i,a),n=n||t.drawingBufferWidth,r=r||t.drawingBufferHeight,e=e||mv;const o=[],s={framebuffer:a,attachments:[],width:n,height:r};return e.forEach(function(u,l){let f=u.attachment;const c=u.samples,h=u.format;let d=u.attachmentPoint||hR(h,u.internalFormat);if(d||(d=l0+l),gR(d)&&o.push(d),!f)if(c!==void 0||dR(h))f=t.createRenderbuffer(),t.bindRenderbuffer(Oi,f),c>1?t.renderbufferStorageMultisample(Oi,c,h,n,r):t.renderbufferStorage(Oi,h,n,r);else{const p=Object.assign({},u);p.width=n,p.height=r,p.auto===void 0&&(p.auto=!1,p.min=p.min||p.minMag||f0,p.mag=p.mag||p.minMag||f0,p.wrapS=p.wrapS||p.wrap||u0,p.wrapT=p.wrapT||p.wrap||u0),f=Ks(t,p)}if(__(t,f))t.framebufferRenderbuffer(i,d,Oi,f);else if(Cc(t,f))u.layer!==void 0?t.framebufferTextureLayer(i,d,f,u.level||0,u.layer):t.framebufferTexture2D(i,d,u.target||tR,f,u.level||0);else throw new Error("unknown attachment type");s.attachments.push(f)}),t.drawBuffers&&t.drawBuffers(o),s}function bR(t,e,n,r,i){r=r||t.drawingBufferWidth,i=i||t.drawingBufferHeight,e.width=r,e.height=i,n=n||mv,n.forEach(function(a,o){const s=e.attachments[o],u=a.format,l=a.samples;if(l!==void 0||__(t,s))t.bindRenderbuffer(Oi,s),l>1?t.renderbufferStorageMultisample(Oi,l,u,r,i):t.renderbufferStorage(Oi,u,r,i);else if(Cc(t,s))HI(t,s,a,r,i);else throw new Error("unknown attachment type")})}function yR(t,e,n){const r=t.createVertexArray();return t.bindVertexArray(r),e.length||(e=[e]),e.forEach(function(i){Oo(t,i,n)}),t.bindVertexArray(null),{numElements:n.numElements,elementType:n.elementType,vertexArrayObject:r}}const wR=/^(.*?)_/;function xR(t,e){n0(t,0);const n=t.getExtension(e);if(n){const r={},i=wR.exec(e)[1],a="_"+i;for(const o in n){const s=n[o],u=typeof s=="function",l=u?i:a;let f=o;o.endsWith(l)&&(f=o.substring(0,o.length-l.length)),t[f]!==void 0?!u&&t[f]!==s&&x_(f,t[f],s,o):u?t[f]=function(c){return function(){return c.apply(n,arguments)}}(s):(t[f]=s,r[f]=s)}r.constructor={name:n.constructor.name},n0(r,0)}return n}const R1=["ANGLE_instanced_arrays","EXT_blend_minmax","EXT_color_buffer_float","EXT_color_buffer_half_float","EXT_disjoint_timer_query","EXT_disjoint_timer_query_webgl2","EXT_frag_depth","EXT_sRGB","EXT_shader_texture_lod","EXT_texture_filter_anisotropic","OES_element_index_uint","OES_standard_derivatives","OES_texture_float","OES_texture_float_linear","OES_texture_half_float","OES_texture_half_float_linear","OES_vertex_array_object","WEBGL_color_buffer_float","WEBGL_compressed_texture_atc","WEBGL_compressed_texture_etc1","WEBGL_compressed_texture_pvrtc","WEBGL_compressed_texture_s3tc","WEBGL_compressed_texture_s3tc_srgb","WEBGL_depth_texture","WEBGL_draw_buffers"];function bv(t){for(let e=0;e<R1.length;++e)xR(t,R1[e])}function _R(t,e){const n=["webgl2","webgl","experimental-webgl"];let r=null;for(let i=0;i<n.length;++i)if(r=t.getContext(n[i],e),r){bv(r);break}return r}function vR(t,e){return _R(t,e)}const ER=`/***The vertex position wrt the rectangle specified by(x,x2,y,y2).*[0,0]=[x,y],[1,1]=[x2,y2].*The x or y component may contain fractional values if the rectangle*have been tessellated.*/in vec2 frac;uniform vec2 uMinSize;uniform float uMinOpacity;uniform vec4 uCornerRadii;out lowp vec4 vFillColor;out lowp vec4 vStrokeColor;out float vHalfStrokeWidth;out vec4 vCornerRadii; -#if defined(ROUNDED_CORNERS) || defined(STROKED) -out vec2 vPosInPixels; -#endif -out vec2 vHalfSizeInPixels;/***Clamps the minimumSize and returns an opacity that reflects the amount of clamping.*/float clampMinSize(inout float pos,float frac,float size,float minSize){if(minSize>0.0&&abs(size)<minSize){pos+=(frac-0.5)*(minSize*sign(size)-size);return abs(size)/minSize;}return 1.0;}void sort(inout float a,inout float b){if(a>b){float tmp=b;b=a;a=tmp;}}void main(void){vec2 normalizedMinSize=uMinSize/uViewportSize;float x=getScaled_x();float x2=getScaled_x2();float y=getScaled_y();float y2=getScaled_y2();sort(x,x2);sort(y,y2);float clampMargin=1.0;vec2 pos1=vec2(clamp(x,0.0-clampMargin,1.0+clampMargin),y);vec2 pos2=vec2(clamp(x2,0.0-clampMargin,1.0+clampMargin),y2);vec2 size=pos2-pos1;if(size.x<=0.0||size.y<=0.0){gl_Position=vec4(0.0,0.0,0.0,1.0);return;}vec2 pos=pos1+frac*size;size.y*=getSampleFacetHeight(pos);float opaFactor=uViewOpacity*max(uMinOpacity,clampMinSize(pos.x,frac.x,size.x,normalizedMinSize.x)*clampMinSize(pos.y,frac.y,size.y,normalizedMinSize.y));pos=applySampleFacet(pos); -#if defined(ROUNDED_CORNERS) || defined(STROKED) -float aaPadding=1.0/uDevicePixelRatio;float strokeWidth=getScaled_strokeWidth();float strokeOpacity=getScaled_strokeOpacity()*opaFactor;vec2 centeredFrac=frac-0.5;vec2 expand=centeredFrac*(strokeWidth+aaPadding)/uViewportSize;pos+=expand;vec2 sizeInPixels=size*uViewportSize;vPosInPixels=(centeredFrac+expand/size)*sizeInPixels;vHalfSizeInPixels=sizeInPixels/2.0;vCornerRadii=min(uCornerRadii,min(vHalfSizeInPixels.x,vHalfSizeInPixels.y));vHalfStrokeWidth=strokeWidth/2.0;vStrokeColor=vec4(getScaled_stroke()*strokeOpacity,strokeOpacity); -#endif -gl_Position=unitToNdc(pos);float fillOpacity=getScaled_fillOpacity()*opaFactor;vFillColor=vec4(getScaled_fill()*fillOpacity,fillOpacity);setupPicking();}`,AR=`#if defined(ROUNDED_CORNERS) || defined(STROKED) -in vec2 vPosInPixels; -#endif -in vec2 vHalfSizeInPixels;in lowp vec4 vFillColor;in lowp vec4 vStrokeColor;in float vHalfStrokeWidth;in vec4 vCornerRadii;out lowp vec4 fragColor;float sdRoundedBox(vec2 p,vec2 b,vec4 r){r.xy=p.x>0.0 ? r.xy : r.zw;r.x=p.y>0.0 ? r.x : r.y;vec2 q=abs(p)-b+r.x;return min(max(q.x,q.y),0.0)+length(max(q,0.0))-r.x;}float sdSharpBox(vec2 p,vec2 b){vec2 q=abs(p)-b;return max(q.x,q.y);}void main(void){ -#if defined(ROUNDED_CORNERS) || defined(STROKED) -#ifdef ROUNDED_CORNERS -float d=sdRoundedBox(vPosInPixels,vHalfSizeInPixels,vCornerRadii); -#else -float d=sdSharpBox(vPosInPixels,vHalfSizeInPixels); -#endif -fragColor=distanceToColor(d,vFillColor,vStrokeColor,vHalfStrokeWidth);if(fragColor.a==0.0){discard;} -#else -fragColor=vFillColor; -#endif -if(uPickingEnabled){fragColor=vPickingColor;}}`,ig="attr_",yv="uDomain_",SR="range_",D1="scale_",wv="getScaled_",c0="uRangeTexture_",B1=3402823466e29;function CR(t){const e=t.match(/^(?:(\w+)-)?(\w+)$/);if(!e)throw new Error("Not a scale type: "+t);return{family:e[1]||"continuous",transform:e[2]}}function TR(t,e){let n;if(Sc(t))n=Li(y_(t)(e));else if(We(e))if(Xi(t))n=IR(e);else throw new Error(`String values are not supported on the "${t}" channel: ${e}`);else if(ec(e))n=Li(e?1:0);else if(e===null)if(Xi(t))n=Li([0,0,0]);else throw new Error(`null value is not supported on the "${t}" chanel.`);else n=Li(e);return` -#define ${t}_DEFINED -${n.type} ${wv}${t}() { - // Constant value - return ${n}; -}`}function FR(t,e,n){if(Rn(n))throw new Error(`Cannot create scale for "value": ${JSON.stringify(n)}`);if(!e)throw new Error("Scale is undefined");const r=aa(t),i=ig+t,a=yv+r,o=SR+r,s=xf(e.type),u=s?"vec2":"float",l=e.domain?e.domain().length:void 0;let f;const c=[];c.push(""),c.push("/".repeat(70)),c.push(`// Channel: ${t}`),c.push(""),c.push(`#define ${t}_DEFINED`);const{transform:h}=CR(e.type),d=(I,...O)=>kR.apply(null,[I,"value",...O]);let p;switch(h){case"linear":p=d("scaleLinear","domain",o);break;case"log":p=d("scaleLog","domain",o,e.base());break;case"symlog":p=d("scaleSymlog","domain",o,e.constant());break;case"pow":case"sqrt":p=d("scalePow","domain",o,e.exponent());break;case"index":case"locus":p=d("scaleBandHp","domain",o,e.paddingInner(),e.paddingOuter(),e.align(),n.band??.5);break;case"point":case"band":p=d("scaleBand","domain",o,e.paddingInner(),e.paddingOuter(),e.align(),n.band??.5);break;case"ordinal":case"null":case"identity":p=d("scaleIdentity");break;case"threshold":break;default:throw new Error(`Unsupported scale type: ${e.type}! ${t}: ${JSON.stringify(n)}`)}const m=vc(e.type)||wt(e.type)&&Xi(t)?[0,1]:e.range?e.range():void 0;if(m&&t==r&&m.length&&m.every(Vt)){const I=N1(m);c.push(`const ${I.type} ${o} = ${I};`)}const y=Xi(t)?"vec3":"float";let w;if(Xi(t)){const I=c0+r;if(t==r&&c.push(`uniform sampler2D ${I};`),wt(e.type))w=`getInterpolatedColor(${I}, transformed)`;else if(hi(e.type)||La(e.type))w=`getDiscreteColor(${I}, int(transformed))`;else throw new Error("Problem with color scale!")}else if(e.type==="ordinal"||La(e.type)){const I=c0+r;t==r&&c.push(`uniform sampler2D ${I};`),w=`getDiscreteColor(${I}, int(transformed)).r`}zl(n)?c.push(`uniform highp ${u} ${i};`):c.push(`in highp ${u} ${i};`);const A=[],C=wt(e.type)&&l>2,E=La(e.type)||C;if(A.push("int slot = 0;"),E){const I=a;A.push(C?`while (slot < ${I}.length() - 2 && value >= ${I}[slot + 1]) { slot++; }`:`while (slot < ${I}.length() && value >= ${I}[slot]) { slot++; }`)}const k=wt(e.type)||La(e.type)||["band","point"].includes(e.type);if(p){const I=a;k&&(s?A.push(`vec3 domain = ${I};`):A.push(`vec2 domain = vec2(${I}[slot], ${I}[slot + 1]);`)),A.push(`float transformed = ${p};`),C&&A.push(`transformed = (float(slot) + transformed) / (float(${I}.length() - 1));`)}else A.push("float transformed = float(slot);");"clamp"in e&&e.clamp()&&A.push(`transformed = clampToRange(transformed, ${N1(m)});`),A.push(`return ${w??"transformed"};`),c.push(` -${y} ${D1}${t}(${u} value) { -${A.map(I=>` ${I} -`).join("")} -}`),c.push(` -${y} ${wv}${t}() { - return ${D1}${t}(${i}); -}`);const R=c.join(` -`);if(k&&t==r){const I=wt(e.type)||La(e.type)?l:2;f=s?`highp vec3 ${a};`:`mediump float ${a}[${I}];`}return{glsl:R,domainUniform:f}}function h0(t){if(!Vt(t))throw new Error(`Not a number: ${t}`);if(t==1/0)return""+B1;if(t==-1/0)return""+-B1;{let e=`${t}`;return/^(-)?\d+$/.test(e)&&(e+=".0"),e}}function Li(t){typeof t=="number"&&(t=[t]);const e=t.length;if(e<1||e>4)throw new Error("Invalid number of components: "+e);let n,r;return e>1?(n=`vec${e}`,r=`${n}(${t.map(h0).join(", ")})`):(n="float",r=h0(t[0])),Object.assign(r,{type:n,numComponents:e})}function IR(t){const e=fi(t).rgb();return Li([e.r,e.g,e.b].map(n=>n/255))}function N1(t){return Li([t[0],Tl(t)])}function kR(t,...e){const n=[];for(const r of e)Vt(r)?n.push(h0(r)):en(r)?n.push(Li(r)):n.push(r);return`${t}(${n.join(", ")})`}function xf(t){return t=="index"||t=="locus"}const xv=2**11,RR=xv-1;function _v(t,e=[]){const n=t&RR,r=t-n;return e[0]=r,e[1]=n,e}function DR(t){const e=t%xv;return[t-e,e]}function BR(t){return[...DR(t[0]),t[1]-t[0]]}class NR{constructor(e){this.size=e,this.arrays={},this.pushers=[],this.dataUpdaters=[],this.vertexCount=0}addConverter(e,n){const r=this.createUpdater(ig+e,n.numComponents||1,n.arrayReference),i=n.f;this.dataUpdaters.push(n.arrayReference?a=>r(i(a)):a=>r(i(a)))}createUpdater(e,n,r){if(!Vt(this.size))throw new Error("The number of vertices must be defined!");let i,a,o=0;const s=new Float32Array(this.size*n);if(this.arrays[e]={data:s,numComponents:n},n==1){let u=0;const l=f=>{u=+f};i=()=>{s[o++]=u},a=l}else{let u=r??[0];const l=r?f=>{}:f=>{u=f};switch(n){case 1:break;case 2:i=()=>{s[o++]=u[0],s[o++]=u[1]},a=l;break;case 3:i=()=>{s[o++]=u[0],s[o++]=u[1],s[o++]=u[2]},a=l;break;case 4:i=()=>{s[o++]=u[0],s[o++]=u[1],s[o++]=u[2],s[o++]=u[3]},a=l;break;default:throw new Error("Invalid numComponents: "+n)}}return this.pushers.push(i),a}_unrollPushAll(){let e="",n="";for(let i=0;i<this.pushers.length;i++)e+=`const p${i} = that.pushers[${i}]; -`,n+=`p${i}(); -`;const r=new Function("that",`${e} - - return function unrolledPushAll() { - ${n} - that.vertexCount++; - }; - `);this.pushAll=r(this)}pushAll(){this.size>1e5?this._unrollPushAll():this.pushAll=()=>{for(let n=0;n<this.pushers.length;n++)this.pushers[n]();this.vertexCount++},this.pushAll()}updateFromDatum(e){for(let n=0;n<this.dataUpdaters.length;n++)this.dataUpdaters[n](e)}pushFromDatum(e){this.updateFromDatum(e),this.pushAll()}}const Pa=5,Ah=127;function d0(t){const e=[];for(let p=0;p<=Ah;p++)e.push(void 0);const n=new Map;for(const p of t.chars)p.id<=Ah?e[p.id]=p:n.set(p.id,p);const r=8722;n.has(r)||n.set(r,e["-".charCodeAt(0)]);function i(p){return(p<=Ah?e[p]:n.get(p))||e[63]}function a(p){return i(p.charCodeAt(0))}const o=t.common.base,s=a("x"),u=a("X"),l=a("q"),f=s.height-Pa*2,c=u.height-Pa*2,h=l.height-s.height+l.yoffset-s.yoffset;function d(p,m=1){let y=0;for(let w=0;w<p.length;w++)y+=i(p.charCodeAt(w)).xadvance;return y/o*m}return{measureWidth:d,getCharByCode:i,getChar:a,xHeight:f,capHeight:c,descent:h,common:t.common}}function $R(t,e=0,n=1){return Math.max(e,Math.min(n,t))}const $1=2**31-1,OR=-(2**31);function LR(t,e,n,r=n){const i=new Int32Array(t);i.fill($1);let a=OR,o=!1;const s=new Int32Array(t),u=e[0],f=(e[1]-e[0])/t,c=(y,w)=>{const A=(y-u)/f,C=Math.floor(A);return $R(w&&C==A?C-1:C,0,t-1)};function h(y,w,A){w>a?a=w:o||(o=!0,console.debug("Items are not ordered properly. Disabling binned index."));const C=n(y),E=c(C,!1);i[E]>w&&(i[E]=w),s[E]<A&&(s[E]=A)}function d(y,w,A){w>a?a=w:o||(o=!0,console.debug("Items are not ordered properly. Disabling binned index."));const C=n(y),E=r(y),k=c(C,!1),R=c(E,!0);for(let I=k;I<=R;I++)i[I]>w&&(i[I]=w),s[I]<A&&(s[I]=A)}const p=(y,w,A=[0,0])=>{const C=c(y,!1),E=c(w,!0),k=i[C],R=Math.max(s[E],k);return A[0]=k,A[1]=R,A},m=()=>{for(let w=1;w<s.length;w++)s[w]<s[w-1]&&(s[w]=s[w-1]);let y=!0;for(let w=i.length-1;w>0;w--)y&&i[w]==$1?(i[w]=s[w],y=!1):i[w-1]>i[w]&&(i[w-1]=i[w]);return p};if(h.getIndex=m,d.getIndex=m,!o)return n==r?h:d}class Vl{constructor({encoders:e,numVertices:n=void 0,attributes:r=[]}){this.encoders=e,this.variableEncoders=Object.fromEntries(Object.entries(e).filter(([i,a])=>r.includes(i)&&a&&a.scale&&!a.constant)),this.allocatedVertices=n,this.variableBuilder=new NR(n);for(const[i,a]of Object.entries(this.variableEncoders)){const o=a.accessor,s=[0,0],u=xf(a.scale.type),l=a.indexer,f=l?c=>l(o(c)):u?c=>_v(o(c),s):o;this.variableBuilder.addConverter(i,{f,numComponents:u?2:1,arrayReference:u?s:void 0})}this.lastOffset=0,this.rangeMap=new ea([],JSON.stringify)}registerBatch(e){var a;const n=this.lastOffset,r=this.variableBuilder.vertexCount,i=r-n;i&&this.rangeMap.set(e,{offset:n,count:i,xIndex:(a=this.xIndexer)==null?void 0:a.getIndex()}),this.lastOffset=r}addBatches(e){for(const[n,r]of e)this.addBatch(n,r)}addBatch(e,n,r=0,i=n.length){this.prepareXIndexer(n,r,i);for(let a=r;a<i;a++){const o=n[a];this.variableBuilder.pushFromDatum(o),this.addToXIndex(o)}this.registerBatch(e)}prepareXIndexer(e,n=0,r=n+e.length){const i=()=>{this.addToXIndex=u=>{},this.xIndexer=void 0};if(!e.length||r-n<0){i();return}const a=u=>{var l;return u&&wt((l=u.scale)==null?void 0:l.type)&&u},o=a(this.variableEncoders.x),s=a(this.variableEncoders.x2);if(o){const u=o.accessor,l=s?s.accessor:u,f=[u(e[n]),l(e[r-1])];if(f[1]>f[0]){this.xIndexer=LR(50,f,u,l);let c=this.variableBuilder.vertexCount;this.addToXIndex=h=>{let d=this.variableBuilder.vertexCount;this.xIndexer(h,c,d),c=d}}else i()}else i()}addToXIndex(e){}toArrays(){return{arrays:this.variableBuilder.arrays,vertexCount:this.variableBuilder.vertexCount,allocatedVertices:this.allocatedVertices,rangeMap:this.rangeMap}}}class MR extends Vl{constructor({encoders:e,attributes:n,tessellationThreshold:r=1/0,visibleRange:i=[-1/0,1/0],numItems:a}){super({encoders:e,attributes:n,numVertices:r==1/0?a*6:void 0}),this.visibleRange=i,this.tessellationThreshold=r||1/0,this.updateFrac=this.variableBuilder.createUpdater("frac",2)}addBatch(e,n,r=0,i=n.length){if(i<=r)return;const a=this.encoders,[o,s]=this.visibleRange,u=h=>h.accessor||(d=>0),l=u(a.x),f=u(a.x2);this.prepareXIndexer(n,r,i);const c=[0,0];this.updateFrac(c);for(let h=r;h<i;h++){const d=n[h];let p=l(d),m=f(d);if(p>m&&([p,m]=[m,p]),m<o||p>s)continue;p<o&&(p=o),m>s&&(m=s),this.variableBuilder.updateFromDatum(d),c[0]=0,c[1]=0;const y=1;this.variableBuilder.pushAll();for(let w=0;w<=y;w++)c[0]=w/y,c[1]=0,this.variableBuilder.pushAll(),c[1]=1,this.variableBuilder.pushAll();this.variableBuilder.pushAll(),this.addToXIndex(d)}this.registerBatch(e)}}class PR extends Vl{constructor({encoders:e,attributes:n,tessellationThreshold:r=1/0,visibleRange:i=[-1/0,1/0],numItems:a}){super({encoders:e,attributes:n,numVertices:r==1/0?a*6:void 0}),this.visibleRange=i,this.tessellationThreshold=r||1/0,this.updateSide=this.variableBuilder.createUpdater("side",1),this.updatePos=this.variableBuilder.createUpdater("pos",1)}addBatch(e,n,r=0,i=n.length){this.prepareXIndexer(n,r,i);for(let a=r;a<i;a++){const o=n[a];this.variableBuilder.updateFromDatum(o),this.updateSide(-.5),this.updatePos(0),this.variableBuilder.pushAll();const s=1;for(let u=0;u<=s;u++)this.updatePos(u/s),this.updateSide(-.5),this.variableBuilder.pushAll(),this.updateSide(.5),this.variableBuilder.pushAll();this.variableBuilder.pushAll(),this.addToXIndex(o)}this.registerBatch(e)}}class zR extends Vl{constructor({encoders:e,attributes:n,numItems:r=void 0}){super({encoders:e,attributes:n,numVertices:r})}}class UR extends Vl{constructor({encoders:e,attributes:n,numItems:r=void 0}){super({encoders:e,attributes:n,numVertices:r})}toArrays(){const e=this.variableBuilder.arrays;for(let n of Object.values(e))n.divisor=1;return super.toArrays()}}class qR extends Vl{constructor({encoders:e,attributes:n,fontMetrics:r,properties:i,numCharacters:a=void 0}){super({encoders:e,attributes:n,numVertices:a*6}),this.metadata=r,this.metrics=r,this.properties=i;const s=e.text.channelDef;this.numberFormat=!Rn(s)&&"format"in s&&s.format?gt(s.format):u=>u,this.updateVertexCoord=this.variableBuilder.createUpdater("vertexCoord",2),this.updateTextureCoord=this.variableBuilder.createUpdater("textureCoord",2),this.updateWidth=this.variableBuilder.createUpdater("width",1)}addBatch(e,n,r=0,i=n.length){const a=this.properties.align||"left",o=this.properties.logoLetters??!1,s=this.metadata.common.base,u=this.metadata.common.scaleH;let l=-Pa;switch(this.properties.baseline){case"top":l+=this.metrics.capHeight;break;case"middle":l+=this.metrics.capHeight/2;break;case"bottom":l-=this.metrics.descent;break}const f=this.encoders.text.accessor||this.encoders.text,c=[0,0];this.updateVertexCoord(c);const h=[0,0];this.updateTextureCoord(h),this.prepareXIndexer(n,r,i);for(let d=r;d<i;d++){const p=n[d],m=this.numberFormat(f(p)),y=We(m)?m:m===null?"":""+m;if(y.length==0)continue;this.variableBuilder.updateFromDatum(p);const w=o?y.length:this.metrics.measureWidth(y);this.updateWidth(w);let A=a=="right"?-w:a=="center"?-w/2:0;if(!o){const R=this.metrics.getCharByCode(y.charCodeAt(0));A-=(R.width-R.xadvance)/s/2}let C=-.5,E=1,k=1;for(let R=0;R<y.length;R++){const I=this.metrics.getCharByCode(y.charCodeAt(R)),O=o?1:I.xadvance/s;if(I.id==32){A+=O;continue}o?(k=(I.width+Pa*2)/I.width,A=-k/2,E=(I.height+Pa*2)/I.height,C=-.5-Pa/I.height):(E=I.height/s,C=-(I.height+I.yoffset+l)/s,k=I.width/s);const T=I.x,B=I.y;c[0]=A,c[1]=C+E,h[0]=T/u,h[1]=B/u,this.variableBuilder.pushAll(),c[0]=A+k,c[1]=C+E,h[0]=(T+I.width)/u,h[1]=B/u,this.variableBuilder.pushAll(),c[0]=A,c[1]=C,h[0]=T/u,h[1]=(B+I.height)/u,this.variableBuilder.pushAll(),c[0]=A+k,c[1]=C+E,h[0]=(T+I.width)/u,h[1]=B/u,this.variableBuilder.pushAll(),c[0]=A,c[1]=C,h[0]=T/u,h[1]=(B+I.height)/u,this.variableBuilder.pushAll(),c[0]=A+k,c[1]=C,h[0]=(T+I.width)/u,h[1]=(B+I.height)/u,this.variableBuilder.pushAll(),A+=O}this.addToXIndex(p)}this.registerBatch(e)}}const O1=`#define PI 3.141593 -uniform View{mediump vec2 uViewOffset;mediump vec2 uViewScale;mediump vec2 uViewportSize;lowp float uDevicePixelRatio;lowp float uViewOpacity;bool uPickingEnabled;};/***Maps a coordinate on the unit scale to a normalized device coordinate.*(0,0)is at the bottom left corner.*/vec4 unitToNdc(vec2 coord){return vec4((coord*uViewScale+uViewOffset)*2.0-1.0,0.0,1.0);}vec4 unitToNdc(float x,float y){return unitToNdc(vec2(x,y));}vec4 pixelsToNdc(vec2 coord){return unitToNdc(coord/uViewportSize);}vec4 pixelsToNdc(float x,float y){return pixelsToNdc(vec2(x,y));}float linearstep(float edge0,float edge1,float x){return clamp((x-edge0)/(edge1-edge0),0.0,1.0);}/***Specialized linearstep for doing antialiasing*/float distanceToRatio(float d){return clamp(d*uDevicePixelRatio+0.5,0.0,1.0);}vec4 distanceToColor(float d,vec4 fill,vec4 stroke,float halfStrokeWidth){if(halfStrokeWidth>0.0){float sd=abs(d)-halfStrokeWidth;return mix(stroke,d<=0.0 ? fill : vec4(0.0),distanceToRatio(sd));}else{return fill*distanceToRatio(-d);}}`,VR="const float inf=1.0/0.0;vec3 getDiscreteColor(sampler2D s,int index){return texelFetch(s,ivec2(index % textureSize(s,0).x,0),0).rgb;}vec3 getInterpolatedColor(sampler2D s,float unitValue){return texture(s,vec2(unitValue,0.0)).rgb;}float clampToRange(float value,vec2 range){return clamp(value,min(range[0],range[1]),max(range[0],range[1]));}float scaleIdentity(float value){return value;}float scaleLinear(float value,vec2 domain,vec2 range){float domainSpan=domain[1]-domain[0];float rangeSpan=range[1]-range[0];return(value-domain[0])/domainSpan*rangeSpan+range[0];}float scaleLog(float value,vec2 domain,vec2 range,float base){return scaleLinear(log(value)/log(base),log(domain)/log(base),range);}float symlog(float value,float constant){return sign(value)*log(abs(value/constant)+1.0);}float scaleSymlog(float value,vec2 domain,vec2 range,float constant){return scaleLinear(symlog(value,constant),vec2(symlog(domain[0],constant),symlog(domain[1],constant)),range);}float scalePow(float value,vec2 domain,vec2 range,float exponent){return scaleLinear(pow(abs(value),exponent)*sign(value),pow(abs(domain),vec2(exponent))*sign(domain),range);}float scaleBand(float value,vec2 domainExtent,vec2 range,float paddingInner,float paddingOuter,float align,float band){float start=range[0];float stop=range[1];float rangeSpan=stop-start;float n=domainExtent[1]-domainExtent[0];paddingInner=int(n)>1 ? paddingInner : 0.0;float step=rangeSpan/max(1.0,n-paddingInner+paddingOuter*2.0);start+=(rangeSpan-step*(n-paddingInner))*align;float bandwidth=step*(1.0-paddingInner);return start+(value-domainExtent[0])*step+bandwidth*band;}float scaleBandHp(vec2 value,vec3 domainExtent,vec2 range,float paddingInner,float paddingOuter,float align,float band){float start=range[0];float stop=range[1];float rangeSpan=stop-start;vec2 domainStart=domainExtent.xy;float n=domainExtent[2];float step=rangeSpan/max(1.0,n-paddingInner+paddingOuter*2.0);start+=(rangeSpan-step*(n-paddingInner))*align;float bandwidth=step*(1.0-paddingInner);float hi=max(value[0]-domainStart[0],-inf);float lo=max(value[1]-domainStart[1],-inf);return dot(vec4(start,hi,lo,bandwidth),vec4(1.0,step,step,band));}",HR=`/***Describes where a sample facet should be shown. Interpolating between the*current and target positions/heights allows for transitioning between facet*configurations.*/struct SampleFacetPosition{float pos;float height;float targetPos;float targetHeight;};/***Trasition fraction[0,1]between the current and target configurations.*/uniform float uTransitionOffset; -#if !defined(SAMPLE_FACET_UNIFORM) && !defined(SAMPLE_FACET_TEXTURE) -SampleFacetPosition getSampleFacetPos(){return SampleFacetPosition(0.0,1.0,0.0,1.0);} -#elif defined(SAMPLE_FACET_UNIFORM) -/***Location and height of the band on the Y axis on a normalized[0,1]scale.*Elements: curr pos,curr height,target pos,target height*/uniform vec4 uSampleFacet;SampleFacetPosition getSampleFacetPos(){return SampleFacetPosition(1.0-uSampleFacet.x-uSampleFacet.y,uSampleFacet.y,1.0-uSampleFacet.z-uSampleFacet.w,uSampleFacet.w);} -#elif defined(SAMPLE_FACET_TEXTURE) -uniform sampler2D uSampleFacetTexture;SampleFacetPosition getSampleFacetPos(){vec4 texel=texelFetch(uSampleFacetTexture,ivec2(int(attr_facetIndex),0),0);return SampleFacetPosition(1.0-texel.r-texel.g,texel.g,1.0-texel.r-texel.g,texel.g);} -#endif -bool isFacetedSamples(SampleFacetPosition facetPos){return facetPos!=SampleFacetPosition(0.0,1.0,0.0,1.0);}bool isFacetedSamples(){return isFacetedSamples(getSampleFacetPos());}bool isInTransit(){return uTransitionOffset>0.0;}float getTransitionFraction(float xPos){return smoothstep(0.0,0.7+uTransitionOffset,(xPos-uTransitionOffset)*2.0);}vec2 applySampleFacet(vec2 pos){SampleFacetPosition facetPos=getSampleFacetPos();if(!isFacetedSamples(facetPos)){return pos;}else if(isInTransit()){vec2 interpolated=mix(vec2(facetPos.pos,facetPos.height),vec2(facetPos.targetPos,facetPos.targetHeight),getTransitionFraction(pos.x));return vec2(pos.x,interpolated[0]+pos.y*interpolated[1]);}else{return vec2(pos.x,facetPos.pos+pos.y*facetPos.height);}}float getSampleFacetHeight(vec2 pos){SampleFacetPosition facetPos=getSampleFacetPos();if(!isFacetedSamples(facetPos)){return 1.0;}else if(isInTransit()){return mix(facetPos.height,facetPos.targetHeight,getTransitionFraction(pos.x));}else{return facetPos.height;}}`,GR=`/**Based on concepts presented at:*https:*https:*/out highp vec4 vPickingColor;/***Passes the unique id to the fragment shader as a color if picking is enabled.*Returns true if picking is enabled.*/bool setupPicking(){if(uPickingEnabled){ -#ifdef uniqueId_DEFINED -int id=int(getScaled_uniqueId());vPickingColor=vec4(ivec4(id>>0,id>>8,id>>16,0xFF)&0xFF)/float(0xFF); -#else -vPickingColor=vec4(1.0); -#endif -return true;}return false;}`,jR="in highp vec4 vPickingColor;",Mu=Symbol("cacheMap");function yo(t,e,n){let r=Js(t).get(e);return r===void 0&&(r=n(e),Js(t).set(e,r)),r}function vv(t,e){Js(t).delete(e)}function Pu(t,e){const n=Js(t);for(const r of n.keys())r.startsWith(e)&&n.delete(r);Js(t).delete(e)}function Ev(t){t[Mu]=new Map}function Js(t){return t[Mu]||Ev(t),t[Mu]}function WR(t,e,n,r){const i=We(t)?t:t.name,a=!We(t)&&t.extent||[0,1];if(n===void 0&&!We(t)&&(n=t.count),i){const o=Lp(i);if(qt(o)){const s=Av(o,{extent:a,count:n});return Lc(e,{minMag:e.LINEAR,format:e.RGB,height:1,wrap:e.CLAMP_TO_EDGE},s,r)}else{if(en(o))return p0(o,e);throw new Error("Unknown scheme: "+i)}}}function ZR(t,e="rgb",n,r){const i=Ec(t,We(e)?e:e.type,We(e)?void 0:e.gamma),a=Av(i);return Lc(n,{minMag:n.LINEAR,format:n.RGB,height:1,wrap:n.CLAMP_TO_EDGE},a,r)}function YR(t,e,n,r){const i=Math.max(t.length,n||0),a=new Float32Array(i);for(let o=0;o<i;o++)a[o]=t[o%t.length];return Lc(e,{minMag:e.NEAREST,format:e.RED,internalFormat:e.R32F,height:1},a,r)}function p0(t,e,n,r){const i=Sv(t,n);return Lc(e,{minMag:e.NEAREST,format:e.RGB,height:1},i,r)}function Av(t,{extent:e=[0,1],reverse:n=!1,count:r=256}={}){const i=e[0],a=Tl(e)-i,o=Bs(r).map(s=>s/(r-1)).map(s=>i+s/a).map(t);return n&&o.reverse(),Sv(o)}function Sv(t,e){const n=Math.max(t.length,e||0),r=new Uint8Array(n*3);for(let i=0;i<n;i++){const a=fi(t[i%t.length]).rgb();r[i*3+0]=a.r,r[i*3+1]=a.g,r[i*3+2]=a.b}return r}class XR{constructor(e,n,r){this._container=e,this._sizeSource=n,this._shaderCache=new Map,this._listeners=[],this.rangeTextures=new WeakMap;const i=document.createElement("canvas");e.appendChild(i);const a=vR(i,{antialias:!0,depth:!1,premultipliedAlpha:!0});if(!a)throw new Error("Unable to initialize WebGL. Your browser or machine may not support it.");if(!No(a))throw new Error("Your web browser does not support WebGL 2.0. Chrome, Firefox, and Safari Tech Preview should work.");if(bv(a),a.blendFunc(a.ONE,a.ONE_MINUS_SRC_ALPHA),this.canvas=i,this.gl=a,this._pickingAttachmentOptions=[{format:a.RGBA,type:a.UNSIGNED_BYTE,minMag:a.LINEAR,wrap:a.CLAMP_TO_EDGE}],this._pickingBufferInfo=mR(a,this._pickingAttachmentOptions),a.bindFramebuffer(a.FRAMEBUFFER,null),this.adjustGl(),this._resizeObserver=new ResizeObserver(o=>{this.invalidateSize(),this._emit("resize")}),this._resizeObserver.observe(this._container),this._updateDpr(),this._clearColor=[0,0,0,0],r){const o=fi(r).rgb();this._clearColor=[o.r/255,o.g/255,o.b/255,o.opacity]}}invalidateSize(){this._logicalCanvasSize=void 0,this._updateDpr(),this.adjustGl()}_updateDpr(){this.dpr=window.devicePixelRatio}compileShader(e,n){const r="#version 300 es",i="precision mediump float;";en(n)&&(n=n.join(` - -`));const a=this.gl,o=n.replaceAll(/ {2,}|^\s*\/\/.*$/gm,"");let s=this._shaderCache.get(o);if(!s){const u=[r,i,n].join(` - -`);s=a.createShader(e),a.shaderSource(s,u),a.compileShader(s),this._shaderCache.set(o,s)}return s}adjustGl(){const e=this.getLogicalCanvasSize();this.canvas.style.width=`${e.width}px`,this.canvas.style.height=`${e.height}px`;const n=this.getPhysicalCanvasSize(e);this.canvas.width=n.width,this.canvas.height=n.height,bR(this.gl,this._pickingBufferInfo,this._pickingAttachmentOptions)}finalize(){this._resizeObserver.unobserve(this._container),this.canvas.remove()}getPhysicalCanvasSize(e){return e=e||this.getLogicalCanvasSize(),{width:e.width*this.dpr,height:e.height*this.dpr}}getLogicalCanvasSize(){var a;if(this._logicalCanvasSize)return this._logicalCanvasSize;const e=((a=this._sizeSource)==null?void 0:a.call(this))??{width:void 0,height:void 0},n=window.getComputedStyle(this._container,null),r=e.width??this._container.clientWidth-parseFloat(n.paddingLeft)-parseFloat(n.paddingRight),i=e.height??this._container.clientHeight-parseFloat(n.paddingTop)-parseFloat(n.paddingBottom);return this._logicalCanvasSize={width:r,height:i},this._logicalCanvasSize}addEventListener(e,n){this._listeners.push({type:e,listener:n})}_emit(e){for(const n of this._listeners)n.type===e&&n.listener()}readPickingPixel(e,n){const r=this.gl;e*=this.dpr,n*=this.dpr;const i=this.getPhysicalCanvasSize().height,a=new Uint8Array(4);return r.bindFramebuffer(r.FRAMEBUFFER,this._pickingBufferInfo.framebuffer),r.readPixels(e,i-n-1,1,1,r.RGBA,r.UNSIGNED_BYTE,a),r.bindFramebuffer(r.FRAMEBUFFER,null),a}clearAll(){const e=this.gl,{width:n,height:r}=this.getPhysicalCanvasSize();e.viewport(0,0,n,r),e.disable(e.SCISSOR_TEST),e.clearColor(...this._clearColor),e.clear(e.COLOR_BUFFER_BIT)}createRangeTexture(e,n=!1){const r=this.rangeTextures.get(e);if(!n&&r)return;function i(o,s){return hi(s.type)?s.domain().length:s.type=="threshold"?s.domain().length+1:s.type=="quantize"||s.type=="quantile"?o??4:o}const a=e.channel;if(Xi(a)){const o=e.getScaleProps(),s=e.getScale(),u=s.range();let l;if(o.scheme)if(s.type=="threshold"&&u)l=p0(u,this.gl,s.domain().length,r);else{let f=We(o.scheme)?void 0:o.scheme.count;f=i(f,s),l=WR(o.scheme,this.gl,f,r)}else vc(s.type)||wt(s.type)&&u.length>2?l=ZR(u,o.interpolate,this.gl,r):l=p0(u,this.gl,s.domain().length,r);this.rangeTextures.set(e,l)}else{const o=e.getScale();if(o.type==="ordinal"||La(o.type)){const s=Sc(a)?y_(a):l=>l,u=e.getScale().range();this.rangeTextures.set(e,YR(u.map(s),this.gl,o.domain().length,r))}}}}function KR(t,e="",n=0){const r=/ERROR:\s*\d+:(\d+)/gi,i=[...e.matchAll(r)],a=new Map(i.map((o,s)=>{const u=parseInt(o[1]),l=i[s+1],f=l?l.index:e.length,c=e.substring(o.index,f);return[u-1,c]}));return t.split(` -`).map((o,s)=>{const u=a.get(s);return`${s+1+n}: ${o}${u?` - -^^^ ${u}`:""}`}).join(` -`)}function JR(t,e,n){const r=t.createProgram();t.attachShader(r,e),t.attachShader(r,n),t.linkProgram(r);function i(){let a,o;if(!t.getProgramParameter(r,t.LINK_STATUS)){a=t.getProgramInfoLog(r);for(const u of[e,n])t.getShaderParameter(u,t.COMPILE_STATUS)||(a=t.getShaderInfoLog(u),o=KR(t.getShaderSource(u),a,0)+` -Error compiling: ${a}`,t.deleteShader(u));t.deleteProgram(r)}if(a)return{message:a,detail:o}}return{program:r,getProgramErrors:i}}function Lc(t,e,n,r){return r?P_(t,r,n,e):r=Ks(t,{...e,src:n}),r}function QR(...t){const e={get(n,r,i){for(const a of t){const s=a()[r];if(s!==void 0)return s}},has(n,r,i){for(const a of t){const o=a();if(r in o)return!0}return!1}};return new Proxy({},e)}function eD(t){return We(t)||Vt(t)||ec(t)}const tD="SAMPLE_FACET_UNIFORM",L1="SAMPLE_FACET_TEXTURE";class Hl{constructor(e){this.unitView=e,this.encoders=void 0,this.bufferInfo=void 0,this.programInfo=void 0,this.vertexArrayInfo=void 0,this.domainUniformInfo=void 0,this.viewUniformInfo=void 0,this.rangeMap=new nD,this.defaultProperties={get clip(){return["x","y"].map(n=>e.getScaleResolution(n)).some(n=>(n==null?void 0:n.isZoomable())??!1)},xOffset:0,yOffset:0,minBufferSize:0},this.properties=QR(typeof this.unitView.spec.mark=="object"?()=>this.unitView.spec.mark:()=>({}),()=>this.defaultProperties)}get opaque(){return!1}getAttributes(){throw new Error("Not implemented!")}getSupportedChannels(){return["sample","facetIndex","x","y","color","opacity","search","uniqueId"]}getDefaultEncoding(){const e={sample:void 0,uniqueId:void 0};return this.isPickingParticipant()&&(e.uniqueId={field:"_uniqueId"}),e}fixEncoding(e){return e}get encoding(){return yo(this,"encoding",()=>{const e=this.getDefaultEncoding(),n=this.unitView.getEncoding(),r=o=>{const s=this.properties[o];return eD(s)&&{value:s}},i=Object.fromEntries(this.getSupportedChannels().map(o=>[o,r(o)]).filter(o=>o[1].value!==void 0)),a=this.fixEncoding({...e,...i,...n});for(const o of Object.keys(a))this.getSupportedChannels().includes(o)||delete a[o];return a})}getContext(){return this.unitView.context}getType(){return this.unitView.getMarkType()}initializeData(){}initializeEncoders(){this.encoders=T4(this)}async initializeGraphics(){}updateGraphicsData(){}getSampleFacetMode(){if(this.encoders.facetIndex)return L1;if(this.unitView.getLayoutAncestors().find(e=>"samples"in e.spec))return tD}createAndLinkShaders(e,n,r=[]){const i=this.getAttributes();r.push("// view: "+this.unitView.getPathString()),this.domainUniforms=[];let a=[];const o=this.getSampleFacetMode();o&&r.push(`#define ${o}`);for(const h of i){let d;if(h in this.encoding)d=h;else continue;const p=this.encoding[d];if(p)if(Rn(p))a.push(TR(d,p.value));else{const m=sn(p)&&p.resolutionChannel||d,y=Ki(m)?this.unitView.getScaleResolution(m).getScale():Ac(),w=FR(d,y,p);a.push(w.glsl),w.domainUniform&&this.domainUniforms.push(w.domainUniform)}}const s=this.domainUniforms.length?`layout(std140) uniform Domains { -`+this.domainUniforms.map(h=>` ${h} -`).join("")+`}; - -`:"",l=[`precision highp float; -`,...r,O1,VR,s,...a,HR,GR,e],f=[...r,O1,jR,n],c=this.gl;this.programStatus=JR(c,this.glHelper.compileShader(c.VERTEX_SHADER,l),this.glHelper.compileShader(c.FRAGMENT_SHADER,f))}finalizeGraphicsInitialization(){const e=this.programStatus.getProgramErrors();if(e){e.detail&&console.warn(e.detail);const n=new Error("Cannot create shader program: "+e.message);throw n.view=this.unitView,n}this.programInfo=Jk(this.gl,this.programStatus.program),delete this.programStatus,this.domainUniforms.length&&(this.domainUniformInfo=T1(this.gl,this.programInfo,"Domains")),this.viewUniformInfo=T1(this.gl,this.programInfo,"View"),this.gl.useProgram(this.programInfo.program),this._setDatums(),Zt(this.programInfo,{uSampleFacet:[0,1,0,1],uTransitionOffset:0})}_setDatums(){for(const[e,n]of Object.entries(this.encoding))if(zl(n)){const r=this.encoders[e],i=r.indexer?r.indexer(n.datum):xf(r.scale.type)?_v(+n.datum):+n.datum;Zt(this.programInfo,{[ig+e]:i})}}deleteGraphicsData(){if(this.bufferInfo){const e=this.gl;for(let n=0;n<8;n++)e.disableVertexAttribArray(n);Object.values(this.bufferInfo.attribs).forEach(n=>this.gl.deleteBuffer(n.buffer)),this.bufferInfo.indices&&this.gl.deleteBuffer(this.bufferInfo.indices),this.bufferInfo=void 0}}updateBufferInfo(e){if(this.gl.bindVertexArray(null),this.bufferInfo&&e.vertexCount<=this.bufferInfo.allocatedVertices)for(const[n,r]of Object.entries(e.arrays))r.data&&f8(this.gl,this.bufferInfo.attribs[n],r.data,0);else this.deleteGraphicsData(),this.bufferInfo=d8(this.gl,e.arrays,{numElements:e.vertexCount}),this.bufferInfo.allocatedVertices=e.allocatedVertices,this.vertexArrayInfo=void 0}get glHelper(){return this.getContext().glHelper}get gl(){return this.glHelper.gl}onBeforeSampleAnimation(){}onAfterSampleAnimation(){}isReady(){return this.bufferInfo&&this.programInfo}isPickingParticipant(){if(this.properties.tooltip===null)return!1;for(const e of this.unitView.getLayoutAncestors())if(!e.isPickingSupported())return!1;return!0}prepareRender(e){const n=this.glHelper,r=this.gl,i=[];if(i.push(()=>{this.vertexArrayInfo||(this.vertexArrayInfo=yR(this.gl,this.programInfo,this.bufferInfo)),r.useProgram(this.programInfo.program)}),this.domainUniformInfo){for(const[o,s]of Object.entries(this.domainUniformInfo.setters)){const u=o.substring(yv.length),l=this.encoding[u],f=sn(l)&&l.resolutionChannel||u;if(Ki(f)){const c=this.unitView.getScaleResolution(f).getScale();i.push(()=>{const h=hi(c.type)?[0,c.domain().length]:c.domain();s(xf(c.type)?BR(h):h)})}}i.push(()=>F1(r,this.programInfo,this.domainUniformInfo))}for(const[o,s]of Object.entries(this.encoding))if(sn(s)){const u=sn(s)&&s.resolutionChannel||o;if(Ki(u)){const l=this.unitView.getScaleResolution(u),f=n.rangeTextures.get(l);f&&i.push(()=>Zt(this.programInfo,{[c0+o]:f}))}}this.getSampleFacetMode()==L1&&i.push(()=>{let o;for(const s of this.unitView.getLayoutAncestors())if(o=s.getSampleFacetTexture(),o)break;if(!o)throw new Error("No facet texture available. This is bug.");Zt(this.programInfo,{uSampleFacetTexture:o})});const a=(e.picking??!1)&&this.isPickingParticipant();return i.push(()=>I1(this.viewUniformInfo,{uViewOpacity:this.unitView.getEffectiveOpacity(),uPickingEnabled:a})),this.opaque||e.picking?i.push(()=>r.disable(r.BLEND)):i.push(()=>r.enable(r.BLEND)),i}prepareSampleFacetRendering(e){const n=e.sampleFacetRenderingOptions,r=this.programInfo.uniformSetters.uSampleFacet;if(n&&r){const i=n.locSize?n.locSize.location:0,a=n.locSize?n.locSize.size:1;if(i>1||i+a<0)return!1;const o=n.targetLocSize?n.targetLocSize.location:i,s=n.targetLocSize?n.targetLocSize.size:a;this.gl.uniform4f(r.location,i,a,o,s)}return!0}render(e){}createRenderCallback(e,n){var c;if(!this.bufferInfo){const h=new Error(`${this.getType()} mark has no data. This is bug.`);throw h.view=this.unitView,h}const r=this;let i;const a=(c=this.unitView.getScaleResolution("x"))==null?void 0:c.getScale(),o=a&&wt(a.type),s=["index","locus"].includes(a==null?void 0:a.type)?-1:0,u=[0,0];i=h=>{if(o&&h.xIndex){const d=a.domain(),p=h.xIndex(d[0]+s,d[1],u),m=p[0],y=p[1]-m;y>0&&e(m,y)}else e(h.offset,h.count)};const l=this.rangeMap.get(void 0).count==0?n.facetId:void 0,f=this.rangeMap.get(l);return n.sampleFacetRenderingOptions?function(){f.count&&r.prepareSampleFacetRendering(n)&&i(f)}:function(){f.count&&i(f)}}setViewport(e,n){e=e.flatten();const r=this.unitView.context.devicePixelRatio,i=this.gl,a=this.properties,o=this.glHelper.getLogicalCanvasSize(),s=.5,u=(a.xOffset??0)+s,l=(a.yOffset??0)+s;let f,c=e;if(a.clip!=="never"&&(a.clip||n)){let h=0,d=0,p;if(n){if(c=e.intersect(n).flatten(),!c.isDefined())return!1;p=[e.width/c.width,e.height/c.height],d=Math.max(0,e.y2-n.y2),h=Math.max(0,e.x2-n.x2)}else p=[1,1];const m=[c.x,o.height-c.y2,c.width,c.height].map(C=>C*r),y=m.map(C=>Math.round(C)),[w,A]=m.map((C,E)=>C-y[E]);i.viewport(...y),i.scissor(...y),i.enable(i.SCISSOR_TEST),f={uViewOffset:[(u+h+w/r)/c.width,-(l+d-A/r)/c.height],uViewScale:p}}else{if(!e.isDefined())return!1;i.viewport(0,0,o.width*r,o.height*r),i.disable(i.SCISSOR_TEST),f={uViewOffset:[(e.x+u)/o.width,(o.height-e.y-l-e.height)/o.height],uViewScale:[e.width/o.width,e.height/o.height]}}return I1(this.viewUniformInfo,{...f,uViewportSize:[e.width,e.height],uDevicePixelRatio:r}),F1(this.gl,this.programInfo,this.viewUniformInfo),!0}findDatumAt(e,n){}}class nD extends ea{constructor(){super([],JSON.stringify)}get(e){let n=super.get(e);return n===void 0&&(n={offset:0,count:0,xIndex:void 0},super.set(e,n)),n}migrateEntries(e){for(const[n,r]of e.entries())Object.assign(this.get(n),r)}}function g0(t,e){const n=R4(e);let r=t[e]&&{...t[e]},i=t[n]&&{...t[n]};if(!(Rn(r)||Rn(i))){if(r){if(!sn(t[e]))return;if(i){if(r.type!="quantitative"){const a=(1-(r.band||1))/2;r.band=a,i.band=-a}}else if(r.type=="quantitative")i={datum:0};else{i={...r};const a=(1-(r.band??1))/2;r.band=0+a,i.band=1-a}}else r={value:0},i={value:1};t[e]=r,t[n]=i}}function Cv(t,e){t.stroke||(e?t.stroke={value:null}:t.stroke={resolutionChannel:"color",...t.color}),Rn(t.stroke)&&t.stroke.value===null&&(t.strokeWidth={value:0}),t.strokeOpacity||(t.strokeOpacity={resolutionChannel:"opacity",...t.opacity})}function Tv(t,e){Rn(t.fill)&&t.fill.value===null?t.fillOpacity={value:0}:t.fill||(t.fill={resolutionChannel:"color",...t.color},!e&&!t.fillOpacity&&(t.fillOpacity={value:0})),t.fillOpacity||(e?t.fillOpacity={resolutionChannel:"opacity",...t.opacity}:t.fillOpacity={value:0})}class rD extends Hl{constructor(e){super(e),Object.defineProperties(this.defaultProperties,Object.getOwnPropertyDescriptors({x2:void 0,y2:void 0,filled:!0,color:"#4c78a8",opacity:1,strokeWidth:3,cornerRadius:0,minWidth:.5,minHeight:.5,minOpacity:1,tessellationZoomThreshold:10,tessellationTiles:35}))}getAttributes(){return["uniqueId","facetIndex","x","x2","y","y2","fill","stroke","fillOpacity","strokeOpacity","strokeWidth"]}getSupportedChannels(){return[...super.getSupportedChannels(),"x2","y2","fill","stroke","fillOpacity","strokeOpacity","strokeWidth"]}get opaque(){return yo(this,"opaque",()=>!this._isRoundedCorners()&&!this._isStroked()&&Rn(this.encoding.fillOpacity)&&this.encoding.fillOpacity.value==1&&this.properties.minOpacity==1)&&this.unitView.getEffectiveOpacity()==1}fixEncoding(e){return g0(e,"x"),g0(e,"y"),Cv(e,this.properties.filled),Tv(e,this.properties.filled),delete e.color,delete e.opacity,e}onBeforeSampleAnimation(){}onAfterSampleAnimation(){}_isRoundedCorners(){const e=this.properties;return e.cornerRadius||e.cornerRadiusBottomLeft||e.cornerRadiusBottomRight||e.cornerRadiusTopLeft||e.cornerRadiusTopRight}_isStroked(){const e=this.encoding.strokeWidth;return!(Rn(e)&&!e.value)}async initializeGraphics(){await super.initializeGraphics();const e=[];this._isRoundedCorners()&&e.push("ROUNDED_CORNERS"),this._isStroked()&&e.push("STROKED"),this.createAndLinkShaders(ER,AR,e.map(n=>"#define "+n))}finalizeGraphicsInitialization(){super.finalizeGraphicsInitialization(),this.gl.useProgram(this.programInfo.program);const e=this.properties;Zt(this.programInfo,{uMinSize:[e.minWidth,e.minHeight],uMinOpacity:e.minOpacity,uCornerRadii:[e.cornerRadiusTopRight??e.cornerRadius,e.cornerRadiusBottomRight??e.cornerRadius,e.cornerRadiusTopLeft??e.cornerRadius,e.cornerRadiusBottomLeft??e.cornerRadius]})}updateGraphicsData(){const e=this.unitView.getCollector(),n=e.getItemCount(),r=new MR({encoders:this.encoders,attributes:this.getAttributes(),numItems:n});r.addBatches(e.facetBatches);const i=r.toArrays();this.rangeMap.migrateEntries(i.rangeMap),this.updateBufferInfo(i)}prepareRender(e){const n=super.prepareRender(e);return n.push(()=>Oo(this.gl,this.programInfo,this.vertexArrayInfo)),n}render(e){const n=this.gl;return this.createRenderCallback((r,i)=>{ql(n,this.vertexArrayInfo,n.TRIANGLE_STRIP,i,r)},e)}findDatumAt(e,n){e=Jt(e);const r=this.unitView.getCollector().facetBatches.get(e);if(!r)return;const i=this.encoders,a=i.x.scale.type;if(hi(a)){const o=i.x.accessor;return r.find(s=>n==o(s))}else{const o=i.x.accessor,s=i.x2.accessor;return r.find(u=>n>=o(u)&&n<s(u))}}}const iD=`/***The stroke should only grow inwards,e.g,the diameter/outline is not affected by the stroke width.*Thus,a point that has a zero size has no visible stroke. This allows strokes to be used with*geometric zoom,etc.*/uniform bool uInwardStroke;uniform lowp float uMaxRelativePointDiameter;uniform float uScaleFactor;uniform float uMaxPointSize;uniform float uZoomLevel;uniform float uSemanticThreshold;out float vRadius;out float vRadiusWithPadding;out lowp vec4 vFillColor;out lowp vec4 vStrokeColor;out lowp float vShape;out lowp float vHalfStrokeWidth;out mat2 vRotationMatrix;float computeSemanticThresholdFactor(){return getScaled_semanticScore()>=uSemanticThreshold ? 1.0 : 0.0;}/***Computes a scaling factor for the points in a sample-faceted view.*/float getDownscaleFactor(vec2 pos){if(!isFacetedSamples()){return 1.0;}float sampleFacetHeight=getSampleFacetHeight(pos);float maxPointDiameter=sqrt(uMaxPointSize);float factor=sampleFacetHeight*uViewportSize.y*uMaxRelativePointDiameter;return clamp(0.0,maxPointDiameter,factor)/maxPointDiameter;}vec2 getDxDy(){ -#if defined(dx_DEFINED) || defined(dy_DEFINED) -return vec2(getScaled_dx(),getScaled_dy())/uViewportSize; -#else -return vec2(0.0,0.0); -#endif -}void main(void){float semanticThresholdFactor=computeSemanticThresholdFactor();if(semanticThresholdFactor<=0.0){gl_PointSize=0.0;gl_Position=vec4(100.0,0.0,0.0,0.0);return;}float size=getScaled_size();vec2 pos=vec2(getScaled_x(),getScaled_y())+getDxDy();gl_Position=unitToNdc(applySampleFacet(pos));float strokeWidth=getScaled_strokeWidth();float diameter=sqrt(size)*uScaleFactor*semanticThresholdFactor*getDownscaleFactor(pos);float opacity=uViewOpacity;if(strokeWidth<=0.0||uInwardStroke){float minDiameter=1.0/uDevicePixelRatio;if(diameter<minDiameter){opacity*=pow(diameter/minDiameter,2.5);diameter=minDiameter;}}float fillOpa=getScaled_fillOpacity()*opacity;float strokeOpa=getScaled_strokeOpacity()*opacity;vShape=getScaled_shape();bool circle=vShape==0.0;float angleInDegrees=getScaled_angle();float angle=-angleInDegrees*PI/180.0;float sinTheta=sin(angle);float cosTheta=cos(angle);vRotationMatrix=mat2(cosTheta,sinTheta,-sinTheta,cosTheta);float roomForRotation=circle ? 1.0 : sin(mod(angle,PI/2.0)+PI/4.0)/sin(PI/4.0);float aaPadding=1.0/uDevicePixelRatio;float rotationPadding=(diameter*roomForRotation)-diameter;float strokePadding=uInwardStroke ? 0.0 : strokeWidth*(circle ? 1.0 : sqrt(3.0));float padding=rotationPadding+strokePadding+aaPadding;gl_PointSize=(diameter+padding)*uDevicePixelRatio;vRadius=diameter/2.0;vRadiusWithPadding=vRadius+padding/2.0;vHalfStrokeWidth=strokeWidth/2.0;vFillColor=vec4(getScaled_fill()*fillOpa,fillOpa);vStrokeColor=vec4(getScaled_stroke()*strokeOpa,strokeOpa);setupPicking();}`,aD="const lowp vec4 white=vec4(1.0);const lowp vec4 black=vec4(0.0,0.0,0.0,1.0);uniform bool uInwardStroke;uniform float uGradientStrength;in float vRadius;in float vRadiusWithPadding;in lowp vec4 vFillColor;in lowp vec4 vStrokeColor;in lowp float vShape;in lowp float vHalfStrokeWidth;in mat2 vRotationMatrix;out lowp vec4 fragColor;const float CIRCLE=0.0;const float SQUARE=1.0;const float TRIANGLE_UP=2.0;const float CROSS=3.0;const float DIAMOND=4.0;const float TRIANGLE_DOWN=5.0;const float TRIANGLE_RIGHT=6.0;const float TRIANGLE_LEFT=7.0;float circle(vec2 p,float r){return length(p)-r;}float square(vec2 p,float r){p=abs(p);return max(p.x,p.y)-r;}float equilateralTriangle(vec2 p,float r,bool flip,bool swap){if(swap){p.xy=p.yx;}if(flip){p.y=-p.y;}float k=sqrt(3.0);float kr=k*r;p.y-=kr/2.0;return max((abs(p.x)*k+p.y)/2.0,-p.y-kr);}float crossShape(vec2 p,float r){p=abs(p);vec2 b=vec2(0.4,1.0)*r;vec2 v=abs(p)-b.xy;vec2 h=abs(p)-b.yx;return min(max(v.x,v.y),max(h.x,h.y));}float diamond(vec2 p,float r){p=abs(p);return(max(abs(p.x-p.y),abs(p.x+p.y))-r)/sqrt(2.0);}void main(){float d;vec2 p=vRotationMatrix*(2.0*gl_PointCoord-1.0)*vRadiusWithPadding;float r=vRadius;if(vShape==CIRCLE){d=circle(p,r);}else if(vShape==SQUARE){d=square(p,r);}else if(vShape==TRIANGLE_UP){d=equilateralTriangle(p,r,true,false);}else if(vShape==CROSS){d=crossShape(p,r);}else if(vShape==DIAMOND){d=diamond(p,r);}else if(vShape==TRIANGLE_DOWN){d=equilateralTriangle(p,r,false,false);}else if(vShape==TRIANGLE_RIGHT){d=equilateralTriangle(p,r,false,true);}else if(vShape==TRIANGLE_LEFT){d=equilateralTriangle(p,r,true,true);}else{d=0.0;}if(!uPickingEnabled){lowp vec4 fillColor=mix(vFillColor,white,-d*uGradientStrength/vRadius);fragColor=distanceToColor(d+(uInwardStroke ? vHalfStrokeWidth : 0.0),fillColor,vStrokeColor,vHalfStrokeWidth);}else if(d-vHalfStrokeWidth<=0.0){fragColor=vPickingColor;}else{discard;}}",fr=1,Si=2,ag=4,oD={};class Xe{get behavior(){return 0}constructor(){this.children=[],this.parent=void 0,this.completed=!1}reset(){this.completed=!1;for(const e of this.children)e.reset()}initialize(){}_updatePropagator(){this._propagate=Function("children",Bs(this.children.length).map(e=>`const child${e} = children[${e}];`).join(` -`)+`return function propagate(datum) {${Bs(this.children.length).map(e=>`child${e}.handle(datum);`).join(` -`)}}`)(this.children)}setParent(e){this.parent=e}addChild(e){if(e.parent)throw new Error("Cannot add the child! It already has a parent.");return this.children.push(e),e.setParent(this),this._updatePropagator(),this}adopt(e){e.parent&&e.parent.removeChild(e),this.addChild(e)}adoptChildrenOf(e){for(const n of e.children)this.adopt(n)}insertAsParent(e){if(this.isRoot())throw new Error("Cannot insert a new parent for a root node!");e.parent=this.parent,this.parent.children[this.parent.children.indexOf(this)]=e,this.parent._updatePropagator(),this.parent=void 0,e.addChild(this)}removeChild(e){const n=this.children.indexOf(e);if(n>-1)this.children.splice(n,1),e.parent=void 0,this._updatePropagator();else throw new Error("Trying to remove an unknown child node!")}excise(){if(this.isRoot())throw new Error("Cannot excise root node!");if(this.isTerminal())this.parent.removeChild(this);else if(this.children.length==1){const e=this.children[0];e.setParent(this.parent),this.parent.children[this.parent.children.indexOf(this)]=e,this.parent._updatePropagator(),this.setParent(void 0),this.children.length=0}else throw new Error("Cannot excise a node that has multiple children!")}isRoot(){return!this.parent}isBranching(){return this.children.length>1}isTerminal(){return this.children.length==0}visit(e){e(this);for(const n of this.children)n.visit(e);e.afterChildren&&e.afterChildren(this)}subtreeToString(e=0){const n=this.children.map(r=>r.subtreeToString(e+1)).join("");return`${" ".repeat(e*2)}* ${this.constructor.name}${("identifier"in this&&this.identifier?": "+this.identifier:"")??""} -${n}`}getGlobalObject(){return this.parent?this.parent.getGlobalObject():oD}handle(e){this._propagate(e)}complete(){this.completed=!0;for(const e of this.children)e.complete()}beginBatch(e){for(const n of this.children)n.beginBatch(e)}_propagate(e){}}function Fv(t){return t.type=="file"}function sD(t){return t.type=="facet"}class Iv extends Xe{constructor(e){super(),this.k=e.size||500,this.reset()}reset(){super.reset(),this.reservoir=[],this.W=void 0,this.ingester=this._initialIngester}_initialIngester(e){this.reservoir.push(e),this.reservoir.length==this.k&&(this.W=Math.exp(Math.log(Math.random())/this.k),this.i=this.k,this.next=this.i,this.ingester=this._finalIngester,this._setNextStop())}_finalIngester(e){++this.i==this.next&&(this.reservoir[Math.floor(Math.random()*this.k)]=e,this.W*=Math.exp(Math.log(Math.random())/this.k),this._setNextStop())}_setNextStop(){this.next+=Math.floor(Math.log(Math.random())/Math.log(1-this.W))+1}handle(e){this.ingester(e)}complete(){for(const e of this.reservoir)this._propagate(e);super.complete()}}function lD(t,e,n){const r=new Iv({type:"sample",size:t});for(const i of e)r.handle(n(i));return r.complete(),r.reservoir}const uD={};class fD extends Hl{constructor(e){super(e),Object.defineProperties(this.defaultProperties,Object.getOwnPropertyDescriptors({x:.5,y:.5,color:"#4c78a8",filled:!0,opacity:1,size:100,semanticScore:0,shape:"circle",strokeWidth:2,fillGradientStrength:0,dx:0,dy:0,angle:0,sampleFacetPadding:.1,semanticZoomFraction:.02}))}getAttributes(){return["inwardStroke","uniqueId","facetIndex","x","y","size","semanticScore","shape","strokeWidth","gradientStrength","dx","dy","fill","stroke","fillOpacity","strokeOpacity","angle"]}getSupportedChannels(){return[...super.getSupportedChannels(),"size","semanticScore","shape","strokeWidth","dx","dy","fill","stroke","fillOpacity","strokeOpacity","angle"]}getDefaultEncoding(){return{...super.getDefaultEncoding(),...uD}}fixEncoding(e){return Cv(e,this.properties.filled),Tv(e,this.properties.filled),delete e.color,delete e.opacity,e}initializeData(){super.initializeData();const e=this.unitView.getAccessor("semanticScore");e&&(this.sampledSemanticScores=Float32Array.from(lD(1e4,this.unitView.getCollector().getData(),e)),this.sampledSemanticScores.sort((n,r)=>n-r))}async initializeGraphics(){await super.initializeGraphics(),this.createAndLinkShaders(iD,aD)}finalizeGraphicsInitialization(){super.finalizeGraphicsInitialization(),this.gl.useProgram(this.programInfo.program);const e=this.properties;Zt(this.programInfo,{uInwardStroke:e.inwardStroke,uGradientStrength:e.fillGradientStrength,uMaxRelativePointDiameter:1-2*e.sampleFacetPadding})}updateGraphicsData(){const e=this.unitView.getCollector(),n=e.getItemCount(),r=new zR({encoders:this.encoders,attributes:this.getAttributes(),numItems:Math.max(n,this.properties.minBufferSize||0)});r.addBatches(e.facetBatches);const i=r.toArrays();this.rangeMap.migrateEntries(i.rangeMap),this.updateBufferInfo(i)}_getGeometricScaleFactor(){const e=Math.pow(2,this.properties.geometricZoomBound||0);return Math.pow(Math.min(1,this.unitView.getZoomLevel()/e),1/3)}_getMaxPointSize(){const e=this.encoders.size;return e.constant?e(null):e.scale.range().reduce((n,r)=>Math.max(n,r))}getSemanticThreshold(){if(this.sampledSemanticScores){const e=Math.max(0,1-this.properties.semanticZoomFraction*this.unitView.getZoomLevel());if(e<=0)return-1/0;if(e>=1)return 1/0;{const n=this.sampledSemanticScores;return Gw(n,e)}}else return-1}prepareRender(e){const n=super.prepareRender(e);return n.push(()=>Zt(this.programInfo,{uMaxPointSize:this._getMaxPointSize(),uScaleFactor:this._getGeometricScaleFactor(),uSemanticThreshold:this.getSemanticThreshold()})),n.push(()=>Oo(this.gl,this.programInfo,this.vertexArrayInfo)),n}render(e){const n=this.gl;return this.createRenderCallback((r,i)=>{i&&ql(n,this.vertexArrayInfo,n.POINTS,i,r)},e)}}const cD="const int BUTT=0;const int SQUARE=1;const int ROUND=2;in float pos;in float side;uniform float uMinLength;uniform mediump float uDashTextureSize;uniform lowp int uStrokeCap;out vec4 vColor;out float vSize;out float vNormalLengthInPixels;out highp vec2 vPosInPixels;void main(void){float pixelSize=1.0/uDevicePixelRatio;float size=getScaled_size();float opacity=getScaled_opacity()*uViewOpacity;if(size<pixelSize){opacity*=size/pixelSize;size=pixelSize;}vec2 a=applySampleFacet(vec2(getScaled_x(),getScaled_y()));vec2 b=applySampleFacet(vec2(getScaled_x2(),getScaled_y2()));vec2 tangent=b-a;float offset=0.0;float relativeDiff=0.0;if(uMinLength>0.0||uStrokeCap!=BUTT){float len=length(tangent*uViewportSize);float diff=max(0.0,uMinLength-len);if(uStrokeCap!=BUTT){diff+=size;}relativeDiff=diff/len;offset=relativeDiff*(pos-0.5);}vec2 p=pos<1.0? a+tangent*(pos+offset): b+tangent*offset;float aaPadding=pixelSize;vec2 normal=normalize(vec2(-tangent.y,tangent.x)/uViewportSize);p+=normal*side*(size+aaPadding)/uViewportSize;gl_Position=unitToNdc(p);vColor=vec4(getScaled_color()*opacity,opacity);vSize=size;vNormalLengthInPixels=side*(size+aaPadding);vPosInPixels=vec2(pos,(1.0-pos))*(1.0+relativeDiff)*length(tangent*uViewportSize)-vec2(uStrokeCap!=BUTT ? size/2.0 : 0.0);setupPicking();}",hD="const int BUTT=0;const int SQUARE=1;const int ROUND=2;uniform sampler2D uDashTexture;uniform float uDashTextureSize;uniform float uStrokeDashOffset;uniform lowp int uStrokeCap;in vec4 vColor;in float vSize;in vec2 vPosInPixels;in float vNormalLengthInPixels;out lowp vec4 fragColor;void main(void){float dpr=uDevicePixelRatio;float distanceFromEnd=-min(vPosInPixels[0],vPosInPixels[1]);float distance;if(distanceFromEnd>0.0&&uStrokeCap==ROUND){distance=length(vec2(distanceFromEnd,vNormalLengthInPixels));}else{distance=abs(vNormalLengthInPixels);}float opacity=clamp(((vSize/2.0-distance)*dpr),-0.5,0.5)+0.5;if(uDashTextureSize>0.0){float pos=(vPosInPixels[0]+uStrokeDashOffset)*dpr;float floored=floor(pos);vec2 texelPositions=(floored+vec2(0.5,1.5))/dpr/uDashTextureSize;opacity*=mix(texture(uDashTexture,vec2(texelPositions[0],0)).r,texture(uDashTexture,vec2(texelPositions[1],0)).r,clamp((pos-floored),0.0,1.0));}fragColor=vColor*opacity;if(uPickingEnabled){fragColor=vPickingColor;}}";class dD extends Hl{constructor(e){super(e),this.dashTextureSize=0,Object.defineProperties(this.defaultProperties,Object.getOwnPropertyDescriptors({x2:void 0,y2:void 0,size:1,color:"black",opacity:1,minLength:0,strokeDash:null,strokeDashOffset:0,strokeCap:"butt"}))}getAttributes(){return["uniqueId","facetIndex","x","x2","y","y2","size","color","opacity"]}getSupportedChannels(){return[...super.getSupportedChannels(),"x2","y2","size"]}fixEncoding(e){if(!(e.x&&e.y&&e.x2&&e.y2))if(e.x&&e.x2&&!e.y)e.y={value:.5},e.y2=e.y;else if(e.y&&e.y2&&!e.x)e.x={value:.5},e.x2=e.x;else if(e.x&&!e.y)e.y={value:0},e.y2={value:1},e.x2=e.x;else if(e.y&&!e.x)e.x={value:0},e.x2={value:1},e.y2=e.y;else if(e.x&&e.y&&e.y2)e.x2=e.x;else if(e.y&&e.x&&e.x2)e.y2=e.y;else if(e.y&&e.x)if(!e.x2&&sn(e.y)&&e.y.type=="quantitative")e.x2=e.x,e.y2={datum:0};else if(!e.y2&&sn(e.x)&&e.x.type=="quantitative")e.y2=e.y,e.x2={datum:0};else throw new Error("A bug!");else throw new Error("Invalid x and y encodings for rule mark: "+JSON.stringify(e));return e}async initializeGraphics(){if(await super.initializeGraphics(),this.properties.strokeDash){const e=this.gl,n=pD(this.properties.strokeDash);this.dashTexture=Ks(e,{mag:e.NEAREST,min:e.NEAREST,internalFormat:e.R8,format:e.RED,src:n,height:1}),this.dashTextureSize=n.length}this.createAndLinkShaders(cD,hD)}finalizeGraphicsInitialization(){super.finalizeGraphicsInitialization(),this.gl.useProgram(this.programInfo.program);const e=this.properties;Zt(this.programInfo,{uMinLength:e.minLength,uDashTextureSize:this.dashTextureSize,uStrokeCap:["butt","square","round"].indexOf(e.strokeCap)})}updateGraphicsData(){const e=this.unitView.getCollector(),n=e.getItemCount(),r=new PR({encoders:this.encoders,attributes:this.getAttributes(),numItems:Math.max(n,this.properties.minBufferSize||0)});r.addBatches(e.facetBatches);const i=r.toArrays();this.rangeMap.migrateEntries(i.rangeMap),this.updateBufferInfo(i)}prepareRender(e){const n=super.prepareRender(e);return this.dashTexture&&n.push(()=>Zt(this.programInfo,{uDashTexture:this.dashTexture,uStrokeDashOffset:this.properties.strokeDashOffset})),n.push(()=>Oo(this.gl,this.programInfo,this.vertexArrayInfo)),n}render(e){const n=this.gl;return this.createRenderCallback((r,i)=>ql(n,this.vertexArrayInfo,n.TRIANGLE_STRIP,i,r),e)}}function pD(t){if(t.length==0||t.length%2||t.findIndex(a=>Math.round(a)!=a||a<1||a>1e3)>=0)throw new Error("Invalid stroke dash pattern: "+JSON.stringify(t));const e=t.reduce((a,o)=>a+o),n=new Uint8Array(e);let r=!0,i=0;for(let a of t){for(;a;)n[i++]=r&&255||0,a--;r=!r}return n}const gD=`uniform float uSagittaScaleFactor;uniform float uMinSagittaLength;in vec2 strip;out vec4 vColor;out float vSize;out float vNormalLengthInPixels;void main(void){float pixelSize=1.0/uDevicePixelRatio;float opacity=getScaled_opacity()*uViewOpacity;vec2 a=vec2(getScaled_x(),getScaled_y())*uViewportSize;vec2 b=vec2(getScaled_x2(),getScaled_y2())*uViewportSize;vec2 chordVector=b-a;vec2 unitChordVector=normalize(chordVector);vec2 chordNormal=vec2(-unitChordVector.y,unitChordVector.x);float sagitta=max(length(chordVector)/2.0*uSagittaScaleFactor,uMinSagittaLength);bool compress=false;if(compress){float maxSagittaLen=length(chordNormal*uViewportSize);float maxChordLen=length(unitChordVector*uViewportSize);float threshold=maxSagittaLen*0.5;if(sagitta>threshold){float m=(maxSagittaLen-threshold)/(maxChordLen-threshold);sagitta=(sagitta-threshold)*m+threshold;}}vec2 controlOffset=chordNormal*sagitta/0.75;vec2 p1=a;vec2 p2=a+controlOffset;vec2 p3=b+controlOffset;vec2 p4=b;float t=smoothstep(0.0,1.0,strip.x);vec2 C1=p4-3.0*p3+3.0*p2-p1;vec2 C2=3.0*p3-6.0*p2+3.0*p1;vec2 C3=3.0*p2-3.0*p1;vec2 C4=p1;vec2 p;if(t==0.0){p=p1;}else if(t==1.0){p=p4;}else{p=C1*t*t*t+C2*t*t+C3*t+C4;}vec2 tangent=normalize(3.0*C1*t*t+2.0*C2*t+C3);vec2 normal=vec2(-tangent.y,tangent.x); -#ifdef size2_DEFINED -float mixedSize=mix(getScaled_size(),getScaled_size2(),t); -#else -float mixedSize=getScaled_size(); -#endif -if(mixedSize<pixelSize){opacity*=mixedSize/pixelSize;mixedSize=pixelSize;}float paddedSize=mixedSize+pixelSize;vNormalLengthInPixels=strip.y*paddedSize;p+=normal*vNormalLengthInPixels;gl_Position=pixelsToNdc(p); -#ifdef color2_DEFINED -vec3 color=mix(getScaled_color(),getScaled_color2(),t); -#else -vec3 color=getScaled_color(); -#endif -vColor=vec4(color*opacity,opacity);vSize=paddedSize;setupPicking();}`,mD="in lowp vec4 vColor;in float vSize;in float vNormalLengthInPixels;out lowp vec4 fragColor;void main(void){float dpr=uDevicePixelRatio;float distance=abs(vNormalLengthInPixels);float opacity=clamp(((vSize/2.0-distance)*dpr),0.0,1.0);fragColor=vColor*opacity;if(uPickingEnabled){fragColor=vPickingColor;}}";class bD extends Hl{constructor(e){super(e),Object.defineProperties(this.defaultProperties,Object.getOwnPropertyDescriptors({x:0,x2:void 0,y:0,y2:void 0,size:1,color:"black",opacity:1,segments:101,sagittaScaleFactor:1,minSagittaLength:1.5}))}getAttributes(){return["uniqueId","facetIndex","x","x2","y","y2","size","height","color","opacity"]}getSupportedChannels(){return[...super.getSupportedChannels(),"x2","y2","size"]}fixEncoding(e){return e.x||(e.x2=e.x),e.y2||(e.y2=e.y),e}async initializeGraphics(){await super.initializeGraphics(),this.createAndLinkShaders(gD,mD)}finalizeGraphicsInitialization(){super.finalizeGraphicsInitialization(),this.gl.useProgram(this.programInfo.program);const e=this.properties;Zt(this.programInfo,{uSagittaScaleFactor:e.sagittaScaleFactor,uMinSagittaLength:e.minSagittaLength})}updateGraphicsData(){const e=this.unitView.getCollector(),n=e.getItemCount(),r=new UR({encoders:this.encoders,attributes:this.getAttributes(),numItems:n});r.addBatches(e.facetBatches);const i=r.toArrays();i.arrays.strip={data:yD(this.properties.segments),numComponents:2},this.rangeMap.migrateEntries(i.rangeMap),this.arrays=Object.fromEntries(Object.entries(i.arrays).map(([a,o])=>[a,{...o,data:void 0}])),this.updateBufferInfo(i)}render(e){const n=this.gl;return this.createRenderCallback((r,i)=>{this.gl.bindVertexArray(this.vertexArrayInfo.vertexArrayObject);for(const a of Object.entries(this.bufferInfo.attribs)){const[o,s]=a;s.buffer&&s.numComponents&&s.divisor&&(s.offset=r*this.arrays[o].numComponents*4)}Oo(n,this.programInfo,this.bufferInfo),ql(n,this.bufferInfo,n.TRIANGLE_STRIP,(this.properties.segments+1)*2,0,i)},e)}}function yD(t){let e=0;const n=[];for(;e<=t;e++)n.push(e/t,.5),n.push(e/t,-.5);return n}const wD=`uniform float uSdfNumerator;uniform vec2 uD;in mediump vec2 vertexCoord;in lowp vec2 textureCoord;uniform vec4 uViewportEdgeFadeWidth;uniform vec4 uViewportEdgeFadeDistance;uniform bool uSqueeze;uniform bool uLogoLetter;in float width;uniform ivec2 uAlign; -#ifdef x2_DEFINED -uniform float uPaddingX;uniform bool uFlushX; -#endif -#ifdef y2_DEFINED -uniform float uPaddingY;uniform bool uFlushY; -#endif -out vec2 vTexCoord;out vec4 vColor;out float vSlope;out float vEdgeFadeOpacity;struct RangeResult{float pos;float scale;};float minValue(vec4 v){return min(min(v.x,v.y),min(v.z,v.w));}float maxValue(vec4 v){return max(max(v.x,v.y),max(v.z,v.w));}/***All measures are in[0,1]*/RangeResult positionInsideRange(float a,float b,float width,float padding,int align,bool flush){float span=b-a;float paddedWidth=width+2.0*padding;if(a>1.0||b<0.0){return RangeResult(0.0,0.0);}float extra=max(0.0,span-paddedWidth);float pos;if(align==0){float centre=a+b;if(flush){float leftOver=max(0.0,paddedWidth-centre);centre+=min(leftOver,extra);float rightOver=max(0.0,paddedWidth+centre-2.0);centre-=min(rightOver,extra);}pos=centre/2.0;}else if(align<0){float edge=a;if(flush){float over=max(0.0,-edge);edge+=min(over,extra);}pos=edge+padding;}else{float edge=b;if(flush){float over=max(0.0,edge-1.0);edge-=min(over,extra);}pos=edge-padding;}float scale=clamp((span-padding)/paddedWidth,0.0,1.0);return RangeResult(pos,scale);}vec2 calculateRotatedDimensions(float width,mat2 rotationMatrix){vec2 a=abs(rotationMatrix*vec2(width/2.0,0.5));vec2 b=abs(rotationMatrix*vec2(width/2.0,-0.5));return vec2(max(a.x,b.x),max(a.y,b.y))*2.0;}ivec2 fixAlignForAngle(ivec2 align,float angleInDegrees){float a=mod(angleInDegrees+45.0,360.0);int x=align.x;int y=-align.y;if(a<90.0){return ivec2(x,y);}else if(a<180.0){return ivec2(y,-x);}else if(a<270.0){return ivec2(-x,y);}else{return ivec2(-y,x);}}void main(void){float opacity=getScaled_opacity()*uViewOpacity;vec2 size=vec2(getScaled_size());float x=getScaled_x();float y=getScaled_y();float scale=1.0;float angleInDegrees=getScaled_angle();float angle=-angleInDegrees*PI/180.0;float sinTheta=sin(angle);float cosTheta=cos(angle);mat2 rotationMatrix=mat2(cosTheta,sinTheta,-sinTheta,cosTheta);vec2 flushSize=calculateRotatedDimensions(width,rotationMatrix); -#if defined(x2_DEFINED) || defined(y2_DEFINED) -ivec2 align=fixAlignForAngle(uAlign,angleInDegrees); -#else -ivec2 align=uAlign; -#endif -#ifdef x2_DEFINED -float x2=getScaled_x2();if(uLogoLetter){size.x=(x2-x)*uViewportSize.x;x+=(x2-x)/2.0;}else{float x2=getScaled_x2();RangeResult result=positionInsideRange(min(x,x2),max(x,x2),size.x*scale*flushSize.x/uViewportSize.x,uPaddingX/uViewportSize.x,align.x,uFlushX);x=result.pos;scale*=result.scale;} -#endif -vec2 pos=applySampleFacet(vec2(x,y)); -#ifdef y2_DEFINED -float y2=getScaled_y2();vec2 pos2=applySampleFacet(vec2(x,y2));if(uLogoLetter){size.y=(pos2.y-pos.y)*uViewportSize.y;pos.y+=(pos2.y-pos.y)/2.0;}else{RangeResult result=positionInsideRange(min(pos.y,pos2.y),max(pos.y,pos2.y),size.y*scale*flushSize.y/uViewportSize.y,uPaddingY/uViewportSize.y,align.y,uFlushY);pos.y=result.pos;scale*=result.scale;} -#endif -if(scale<1.0){if(uSqueeze){vec2 scaleFadeExtent=vec2(3.0,6.0)/size;if(scale<scaleFadeExtent[0]){gl_Position=vec4(0.0);return;}size*=scale;opacity*=linearstep(scaleFadeExtent[0],scaleFadeExtent[1],scale);}else if(scale<1.0){gl_Position=vec4(0.0);return;}}vec2 charPos=rotationMatrix*(vertexCoord*size+uD);vec2 unitPos=pos+charPos/uViewportSize;gl_Position=unitToNdc(unitPos);vSlope=max(1.0,min(size.x,size.y)/uSdfNumerator);vColor=vec4(getScaled_color()*opacity,opacity);vTexCoord=textureCoord;if(maxValue(uViewportEdgeFadeDistance)>-pow(10.0,10.0)){vEdgeFadeOpacity=minValue(((vec4(1.0,1.0,0.0,0.0)+vec4(-1.0,-1.0,1.0,1.0)*unitPos.yxyx)*uViewportSize.yxyx-uViewportEdgeFadeDistance)/uViewportEdgeFadeWidth);}else{vEdgeFadeOpacity=1.0;}setupPicking();}`,xD="uniform sampler2D uTexture;uniform bool uLogoLetter;in vec2 vTexCoord;in float vEdgeFadeOpacity;in vec4 vColor;in float vSlope;out lowp vec4 fragColor;float median(float r,float g,float b){return max(min(r,g),min(max(r,g),b));}void main(){vec3 c=texture(uTexture,vTexCoord).rgb;float sigDist=1.0-median(c.r,c.g,c.b);float slope=uLogoLetter? 0.7/length(vec2(dFdy(sigDist),dFdx(sigDist))): vSlope;float opa=clamp((sigDist-0.5)*slope+0.5,0.0,1.0);opa*=pow(clamp(vEdgeFadeOpacity,0.0,1.0),2.2);fragColor=vColor*opa;if(uPickingEnabled){fragColor=vPickingColor;}}",_D={left:-1,center:0,right:1},vD={top:-1,middle:0,bottom:1,alphabetic:1};class ED extends Hl{constructor(e){super(e),Object.defineProperties(this.defaultProperties,Object.getOwnPropertyDescriptors({x:.5,y:.5,x2:void 0,y2:void 0,text:"",size:11,color:"black",opacity:1,font:void 0,fontStyle:void 0,fontWeight:void 0,align:"center",baseline:"middle",dx:0,dy:0,angle:0,fitToBand:!1,squeeze:!0,paddingX:0,paddingY:0,flushX:!0,flushY:!0,logoLetters:!1,viewportEdgeFadeWidthTop:0,viewportEdgeFadeWidthRight:0,viewportEdgeFadeWidthBottom:0,viewportEdgeFadeWidthLeft:0,viewportEdgeFadeDistanceTop:-1/0,viewportEdgeFadeDistanceRight:-1/0,viewportEdgeFadeDistanceBottom:-1/0,viewportEdgeFadeDistanceLeft:-1/0})),this.font=this.properties.font?e.context.fontManager.getFont(this.properties.font,this.properties.fontStyle,this.properties.fontWeight):e.context.fontManager.getDefaultFont()}getAttributes(){return["uniqueId","facetIndex","x","x2","y","y2","color","size","opacity","angle"]}getSupportedChannels(){return[...super.getSupportedChannels(),"x2","y2","size","text","angle"]}fixEncoding(e){for(const n of Bo)this.properties.fitToBand&&g0(e,n);return e}async initializeGraphics(){await super.initializeGraphics(),this.createAndLinkShaders(wD,xD)}finalizeGraphicsInitialization(){super.finalizeGraphicsInitialization(),this.gl.useProgram(this.programInfo.program);const e=this.properties;Zt(this.programInfo,{uPaddingX:e.paddingX,uPaddingY:e.paddingY,uFlushX:!!e.flushX,uFlushY:!!e.flushY,uAlign:[_D[e.align],vD[e.baseline]],uD:[e.dx,-e.dy],uLogoLetter:!!e.logoLetters,uSqueeze:!!e.squeeze,uViewportEdgeFadeWidth:[e.viewportEdgeFadeWidthTop,e.viewportEdgeFadeWidthRight,e.viewportEdgeFadeWidthBottom,e.viewportEdgeFadeWidthLeft],uViewportEdgeFadeDistance:[e.viewportEdgeFadeDistanceTop,e.viewportEdgeFadeDistanceRight,e.viewportEdgeFadeDistanceBottom,e.viewportEdgeFadeDistanceLeft]})}updateGraphicsData(){const e=this.unitView.getCollector(),n=e.getData(),r=this.encoding,i=this.encoders.text.accessor||this.encoders.text;let a=0;const o="format"in r.text?gt(r.text.format):l=>l;for(const l of n){const f=o(i(l)),c=We(f)?f:f===null?"":""+f;a+=c&&c.length||0}const s=new qR({encoders:this.encoders,attributes:this.getAttributes(),properties:this.properties,fontMetrics:this.font.metrics,numCharacters:Math.max(a,this.properties.minBufferSize||0)});s.addBatches(e.facetBatches);const u=s.toArrays();this.rangeMap.migrateEntries(u.rangeMap),this.updateBufferInfo(u)}prepareRender(e){const n=super.prepareRender(e);let r=.35;this.properties.logoLetters&&(r/=2);const i=this.font.metrics.common.base/(this.unitView.context.devicePixelRatio/r);return n.push(()=>Zt(this.programInfo,{uTexture:this.font.texture,uSdfNumerator:i})),n.push(()=>Oo(this.gl,this.programInfo,this.vertexArrayInfo)),n}render(e){const n=this.gl;return this.createRenderCallback((r,i)=>ql(n,this.vertexArrayInfo,n.TRIANGLES,i,r),e)}}function M1(t,e,{spacing:n,devicePixelRatio:r,offset:i,reverse:a}={}){n=n||0,i=i||0;let o=0,s=0;for(const p of t)o+=vu(p.px)+(Sh(p)?0:n),s+=vu(p.grow);o-=n;const u=Math.max(0,e-o),l=r!==void 0?p=>Math.round(p*r)/r:p=>p,f=[],c=[],h=p=>{const m=f.length;if(!m)return;const y=(p?n:0)*(a?-1:1);d-=y;for(let w=0;w<m;w++)c.push({location:d+(w+1)/(m+1)*y,size:0});d+=y,f.length=0};let d=a?Math.max(e,o):0+i;if(t.length==1&&Sh(t[0]))return[{location:d,size:0}];for(let p=0;p<t.length;p++){const m=t[p];if(Sh(m))f.push(m);else{h(c.length>0);const y=vu(m.px)+(s?vu(m.grow)/s*u:0);a&&(d-=y),c.push({location:l(d),size:l(y)}),a?d-=n:d+=y+n}}return d+=a?n:-n,h(!1),c}function AD(t){let e=0,n=0;for(const r of t)e=Math.max(e,r.px??0),n=Math.max(n,r.grow??0);return{px:e,grow:n}}var gl,m0;const Wg=class Wg{constructor(e,n){ge(this,gl);this.width=e,this.height=n}addPadding(e){return se(this,gl,m0).call(this,e.width,e.height)}subtractPadding(e){return se(this,gl,m0).call(this,-e.width,-e.height)}};gl=new WeakSet,m0=function(e,n){return new Wg({px:(this.width.px??0)+e,grow:this.width.grow},{px:(this.height.px??0)+n,grow:this.height.grow})};let oa=Wg;const ms=Object.freeze({px:0,grow:0}),SD=new oa(ms,ms);function Sh(t){return!t.px&&!t.grow}function vu(t){return t||0}function CD(t){return t&&(Vt(t.px)||Vt(t.grow))}function kv(t){if(Nv(t))throw new Error("parseSizeDef does not accept step-based sizes.");if(CD(t))return t;if(Vt(t))return{px:t,grow:0};if(t==="container")return{px:0,grow:1};if(!t)return{px:0,grow:1};throw new Error(`Invalid sizeDef: ${t}`)}class yt{constructor(e,n,r,i){this.top=e||0,this.right=n||0,this.bottom=r||0,this.left=i||0}get width(){return this.left+this.right}get height(){return this.top+this.bottom}expand(e){return e<=0?this:new yt(this.top+e,this.right+e,this.bottom+e,this.left+e)}add(e){return new yt(this.top+e.top,this.right+e.right,this.bottom+e.bottom,this.left+e.left)}subtract(e){return new yt(this.top-e.top,this.right-e.right,this.bottom-e.bottom,this.left-e.left)}union(e){return new yt(Math.max(this.top,e.top),Math.max(this.right,e.right),Math.max(this.bottom,e.bottom),Math.max(this.left,e.left))}getHorizontal(){return new yt(0,this.right,0,this.left)}getVertical(){return new yt(this.top,0,this.bottom,0)}get horizontalTotal(){return this.left+this.right}get verticalTotal(){return this.top+this.bottom}static createFromConfig(e){return typeof e=="number"?this.createUniformPadding(e):e?this.createFromRecord(e):b0}static createFromRecord(e){return new yt(e.top,e.right,e.bottom,e.left)}static zero(){return b0}static createUniformPadding(e){return new yt(e,e,e,e)}}const b0=yt.createUniformPadding(0);Object.freeze(b0);const TD=/^([A-Za-z]+:)?\/\//;function FD(t,e){if(e&&TD.test(e))return e;const n=t();return n&&e?n.endsWith("/")?n+e:n+"/"+e:n??e}const Rv="VISIT_SKIP",bs="VISIT_STOP",P1=t=>t;var Qa,ml,bl,Vf,Bv,yl,y0;class Dv{constructor(e,n,r,i,a){ge(this,Vf);ge(this,yl);ge(this,Qa,{});ge(this,ml,{});ge(this,bl,{});Gt(this,"opacityFunction",P1);if(!e)throw new Error("View spec must be defined!");this.context=n,this.layoutParent=r,this.dataParent=i,this.name=e.name||a,this.spec=e,this.resolutions={scale:{},axis:{}},Ev(this),this.blockEncodingInheritance=!1,this.contributesToScaleDomain=!0,this.needsAxes={x:!1,y:!1}}getPadding(){return this._cache("size/padding",()=>yt.createFromConfig(this.spec.padding))}getOverhang(){return yt.zero()}getSize(){return this._cache("size/size",()=>this.isConfiguredVisible()?se(this,Vf,Bv).call(this):SD)}isConfiguredVisible(){return this.context.isViewConfiguredVisible(this)}isVisibleInSpec(){return this.spec.visible??!0}isVisible(){return this.getLayoutAncestors().every(e=>e.isConfiguredVisible())}getEffectiveOpacity(){var e;return this.opacityFunction(((e=this.layoutParent)==null?void 0:e.getEffectiveOpacity())??1)}getPathString(){return this.getLayoutAncestors().map(e=>e.name).reverse().join("/")}getLayoutAncestors(){return se(this,yl,y0).call(this,"layoutParent")}getDataAncestors(){return se(this,yl,y0).call(this,"dataParent")}handleBroadcast(e){for(const n of re(this,Qa)[e.type]||[])n(e)}_addBroadcastHandler(e,n){let r=re(this,Qa)[e];r||(r=[],re(this,Qa)[e]=r),r.push(n)}handleInteractionEvent(e,n,r){const i=r?re(this,ml):re(this,bl);for(const a of i[n.type]||[])a(e,n)}addInteractionEventListener(e,n,r){const i=r?re(this,ml):re(this,bl);let a=i[e];a||(a=[],i[e]=a),a.push(n)}visit(e){try{const n=e(this);if(e.postOrder&&e.postOrder(this),n!==bs)return n}catch(n){throw n.view=this,n}}getDescendants(){const e=[];return this.visit(n=>{e.push(n)}),e}onScalesResolved(){(!this.opacityFunction||this.opacityFunction===P1)&&(this.opacityFunction=kD(this))}onBeforeRender(){}render(e,n,r={}){}getEncoding(){const e=this.dataParent&&!this.blockEncodingInheritance?this.dataParent.getEncoding():{},n=this.spec.encoding||{},r={...e,...n};for(const[i,a]of Object.entries(r))a===null&&delete r[i];return r}getFacetAccessor(e){if(this.layoutParent)return this.layoutParent.getFacetAccessor(this)}getFacetFields(e){var r;const n=this.getEncoding().sample;return Pl(n)?[n.field]:(r=this.layoutParent)==null?void 0:r.getFacetFields(this)}getSampleFacetTexture(){}getScaleResolution(e){const n=aa(e);return this.getDataAncestors().map(r=>r.resolutions.scale[n]).find(r=>r)}getAxisResolution(e){const n=aa(e);return this.getDataAncestors().map(r=>r.resolutions.axis[n]).find(r=>r)}getConfiguredResolution(e,n){var r,i;return(i=(r=this.spec.resolve)==null?void 0:r[n])==null?void 0:i[e]}getConfiguredOrDefaultResolution(e,n){return this.getConfiguredResolution(e,n)??this.getConfiguredResolution("default",n)??this.getDefaultResolution(e,n)}getDefaultResolution(e,n){return"independent"}getBaseUrl(){return FD(()=>{var e;return(e=this.dataParent)==null?void 0:e.getBaseUrl()},this.spec.baseUrl)}isPickingSupported(){return!0}getTitleText(){const e=this.spec.title;if(e)return We(e)?e:e.text}_cache(e,n){return yo(this,e,n)}_invalidateCacheByPrefix(e,n="self"){switch(n){case"self":Pu(this,e);break;case"ancestors":for(const r of this.getLayoutAncestors())Pu(r,e);break;case"progeny":this.visit(r=>Pu(r,e));break}}invalidateSizeCache(){this._invalidateCacheByPrefix("size/","ancestors")}propagateInteractionEvent(e){}}Qa=new WeakMap,ml=new WeakMap,bl=new WeakMap,Vf=new WeakSet,Bv=function(){const e=n=>{var i;let r=this.spec[n];if(Nv(r)){const a=r.step,o=(i=this.getScaleResolution(n=="width"?"x":"y"))==null?void 0:i.getScale();if(o){let s=0;if(hi(o.type))s=o.domain().length;else if(["locus","index"].includes(o.type)){const l=o.domain();s=Tl(l)-l[0]}else throw new Error(`Cannot use step-based size with "${o.type}" scale!`);const u=o;return s=Bp(s,u.paddingInner(),u.paddingOuter()),{px:s*a,grow:0}}else throw new Error("Cannot use 'step' size with missing scale!")}else return(r&&kv(r))??{px:0,grow:1}};return this._cache("size/sizeFromSpec",()=>new oa(e("width"),e("height")))},yl=new WeakSet,y0=function(e){const n=[];let r=this;do n.push(r),r=r[e];while(r);return n};function ID(t){return"unitsPerPixel"in t}function kD(t){const e=t.spec.opacity;if(e!==void 0){if(Vt(e))return n=>n*e;if(ID(e)){const n=a=>{var s;const o=(s=t.getScaleResolution(a))==null?void 0:s.getScale();if(["linear","index","locus"].includes(o==null?void 0:o.type))return o},r=e.channel?n(e.channel):n("x")||n("y");if(!r)throw new Error("Cannot find a resolved quantitative scale for dynamic opacity!");const i=Sp().domain(e.unitsPerPixel).range(e.values).clamp(!0);return a=>{const s=tf(r.domain())/1e3;return i(s)*a}}}return n=>n}const Nv=t=>!!(t!=null&&t.step);class wo extends Dv{constructor(e,n,r,i,a){super(e,n,r,i,a),this.spec=e}*[Symbol.iterator](){}replaceChild(e,n){throw new Error("Not implemented")}visit(e){let n;try{n=e(this)}catch(r){throw r.view=this,r}if(n===bs)return n;if(n!==Rv){e.beforeChildren&&e.beforeChildren(this);for(const r of this){const i=r.visit(e);if(i===bs)return i}e.afterChildren&&e.afterChildren(this),e.postOrder&&e.postOrder(this)}}findDescendantByPath(e){for(const n of this)if(n.name===e[0]){if(e.length==1)return n;if(n instanceof wo)return n.findDescendantByPath(e.slice(1))}}findChildByName(e){for(const n of this)if(n.name===e)return n}findDescendantByName(e){let n;return this.visit(r=>{if(r.name==e)return n=r,bs}),n}getDefaultResolution(e,n){return"shared"}}const z1=1;function og(){let t=[0,1],e=[0,1],n=1,r=1,i=0,a=0,o=.5,s=0;const l=f=>(f+o-t[0])/n*r+e[0];return l.invert=f=>(f-e[0])/r*n+t[0]-o,l.domain=function(f){if(arguments.length){t=L3(f),n=t[1]-t[0];const c=t[0]===0&&t[0]===0;if(n<z1&&!c){n=z1;const h=(t[0]+t[1])/2;t[0]=h-n/2,t[1]=h+n/2}return l}else return t.slice()},l.range=function(f){return arguments.length?(e=[...f],r=e[1]-e[0],l):e},l.numberingOffset=function(f){return arguments.length?(s=f,l):s},l.padding=function(f){return arguments.length?(a=f,i=Math.min(1,f),l):i},l.paddingInner=function(f){return arguments.length?(i=Math.min(1,f),l):i},l.paddingOuter=function(f){return arguments.length?(a=f,l):a},l.align=function(f){return arguments.length?(o=Math.max(0,Math.min(1,f)),l):o},l.step=()=>r/n,l.bandwidth=()=>l.step(),l.ticks=f=>{const c=l.align(),h=l.numberingOffset();return af(t[0]-c+h,t[1]-c+h,Math.min(f,Math.ceil(n))).filter(Number.isInteger).map(d=>d-s)},l.tickFormat=(f,c)=>{if(c)throw new Error("Index scale's tickFormat does not support a specifier!");const d=ta(t[0],t[1],Math.min(f,Math.ceil(n)))<1e5?gt(","):gt(".3s");return p=>d(p+s)},l.copy=()=>og().domain(t).range(e).paddingInner(i).paddingOuter(a).numberingOffset(s),l}function RD(){const t=og().numberingOffset(1);let e;t.genome=function(r){return arguments.length?(e=r,t):e},t.ticks=r=>{if(!e)return[];const i=t.domain(),a=t.numberingOffset(),[o,s]=[Math.max(i[0],0),Math.min(i[1],e.totalSize-1)].map(f=>e.toChromosome(f)),u=Math.max(1,ta(i[0],i[1],r)),l=[];for(let f=o.index;f<=s.index;f++){const c=e.chromosomes[f],h=Math.max(c.continuousStart+u,i[0]-(i[0]-c.continuousStart)%u),d=Math.min(c.continuousEnd-u/4,i[1]+1);for(let p=h;p<=d;p+=u){const m=p-a;m>=i[0]&&m<i[1]&&l.push(m)}}return l},t.tickFormat=(r,i)=>{if(!e)return;if(i)throw new Error("Locus scale's tickFormat does not support a specifier!");const a=t.domain(),o=a[1]-a[0],s=t.numberingOffset(),l=ta(a[0],a[1],Math.min(r,Math.ceil(o)))<1e6?gt(","):gt(".3s"),f=c=>c-e.toChromosome(c).continuousStart;return c=>l(f(c)+s)};const n=t.copy;return t.copy=()=>n().genome(e),t}function DD(t){return t.type=="locus"}function _f(t,e,n){if(n=n||[],t.some(o=>o===null)){if(t.every(o=>o===null))return null;throw console.warn(t),new Error("Cannot merge objects with nulls!")}const r={},i=(o,s)=>o===s||Ra(o)&&Ra(s)||Ra(o)&&s===!0||o===!0&&Bn(s),a=o=>{for(let s in o){const u=o[s];if(!n.includes(s)&&u!==void 0)if(r[s]!==void 0&&!i(r[s],u))console.warn(`Conflicting property ${s} of ${e}: (${JSON.stringify(r[s])} and ${JSON.stringify(o[s])}). Using ${JSON.stringify(r[s])}.`);else{const l=r[s];if(Ra(l))Ra(u)&&(r[s]=_f([l,u],s));else if(Ra(u)){if(!(l===!0||l===void 0))throw new Error("Bug in merge! Target is: "+l);r[s]=_f([{},u],s)}else r[s]=u}}};for(const o of t)a(o);return r}function Ra(t){return Bn(t)&&!Array.isArray(t)}/*! - * Adapted from vega-encode: - * https://github.com/vega/vega/blob/master/packages/vega-encode/src/ticks.js - * - * Copyright (c) 2015-2018, University of Washington Interactive Data Lab - * All rights reserved. - * - * BSD-3-Clause License: https://github.com/vega/vega-lite/blob/master/LICENSE - */function $v(t,e,n){return Vt(e)&&n!=null&&(e=Math.min(e,~~(tf(t.domain())/n)||1)),Bn(e)&&(e.step,e=e.interval),e}function Ov(t,e,n){var r=t.range(),i=Math.floor(r[0]),a=Math.ceil(kn(r));if(i>a&&(r=a,a=i,i=r),e=e.filter(function(s){return s=t(s),i<=s&&s<=a}),n>0&&e.length>1){for(var o=[e[0],kn(e)];e.length>n&&e.length>=3;)e=e.filter(function(s,u){return!(u%2)});e.length<3&&(e=o)}return e}function BD(t,e){return t.bins?Ov(t,ND(t.bins,e)):t.ticks?t.ticks(e):t.domain()}function ND(t,e){var n=t.length,r=~~(n/(e||n));return r<2?t.slice():t.filter(function(i,a){return!(a%r)})}function $D(t,e,n){var r=t.tickFormat?t.tickFormat(e,n):n?gt(n):String;if(f_(t.type)){var i=LD(n);r=t.bins?i:OD(r,i)}return r}function OD(t,e){return function(n){return t(n)?e(n):""}}function LD(t){var e=ui(t||",");if(e.precision==null){switch(e.precision=12,e.type){case"%":e.precision-=2;break;case"e":e.precision-=1;break}return MD(gt(e),gt(".1f")(1)[1])}else return gt(e)}function MD(t,e){return function(n){var r=t(n),i=r.indexOf(e),a,o;if(i<0)return r;for(a=PD(r,i),o=a<r.length?r.slice(a):"";--a>i;)if(r[a]!=="0"){++a;break}return r.slice(0,a)+o}}function PD(t,e){var n=t.lastIndexOf("e"),r;if(n>0)return n;for(n=t.length;--n>e;)if(r=t.charCodeAt(n),r>=48&&r<=57)return n+1}/*! - * Adapted from vega-encode: - * https://github.com/vega/vega/blob/master/packages/vega-encode/src/Scale.js - * - * Copyright (c) 2015-2018, University of Washington Interactive Data Lab - * All rights reserved. - * - * BSD-3-Clause License: https://github.com/vega/vega-lite/blob/master/LICENSE - */const zD="locus",UD="index";var qD=5;function VD(t){const e=t.type;return!t.bins&&(e===go||e===Nl||e===$l)}function Lv(t){return wt(t)&&![nr,UD,zD].includes(t)}function Mv(t){return t||{warn:(e,...n)=>console.warn(e,...n)}}var HD=nf(["set","modified","clear","type","scheme","schemeExtent","schemeCount","domain","domainMin","domainMid","domainMax","domainRaw","domainImplicit","nice","zero","bins","range","rangeStep","round","reverse","interpolate","interpolateGamma","zoom","fp64","name"]);function Pv(t,e,n){n=Mv(n);for(const r in t)if(!HD[r]){if(r==="padding"&&Lv(e.type))continue;qt(e[r])?e[r](t[r]):n.warn("Unsupported scale property: "+r)}JD(e,t,KD(e,t,ZD(e,t,n)))}function GD(t,e){const n=jD(t),r=Ae(n);if(!r)throw new Error("Unknown scale type: "+n);const i=r();return!t.domain&&wt(i.type)&&(t.domain=[0,0]),Pv(t,i,e),i}function jD(t){var e=t.type,n="",r;return e===nr?nr+"-"+go:(WD(t)&&(r=t.rawDomain?t.rawDomain.length:t.domain?t.domain.length+ +(t.domainMid!=null):0,n=r===2?nr+"-":r===3?Do+"-":""),(n+e||go).toLowerCase())}function WD(t){const e=t.type;return wt(e)&&e!==n_&&e!==r_&&(t.scheme||t.range&&t.range.length&&t.range.every(We))}function ZD(t,e,n){if(!t.domain)return 0;n=Mv(n);var r=YD(t,e.domainRaw,n);if(r>-1)return r;var i=e.domain,a=t.type,o=e.zero||e.zero===void 0&&VD(t),s,u;return i?(Lv(a)&&e.padding&&i[0]!==kn(i)&&(i=XD(a,i,e.range,e.padding,e.exponent,e.constant)),(o||e.domainMin!=null||e.domainMax!=null||e.domainMid!=null)&&(s=(i=i.slice()).length-1||1,o&&(i[0]>0&&(i[0]=0),i[s]<0&&(i[s]=0)),e.domainMin!=null&&(i[0]=e.domainMin),e.domainMax!=null&&(i[s]=e.domainMax),e.domainMid!=null&&(u=e.domainMid,(u<i[0]||u>i[s])&&n.warn("Scale domainMid exceeds domain min or max.",u),i.splice(s,0,u))),t.domain(zv(a,i,n)),a===Np&&t.unknown(e.domainImplicit?Vd:void 0),e.nice&&t.nice&&t.nice(e.nice!==!0&&$v(t,e.nice)||null),i.length):0}function YD(t,e,n){return e?(t.domain(zv(t.type,e,n)),e.length):-1}function XD(t,e,n,r,i,a){var o=Math.abs(kn(n)-n[0]),s=o/(o-2*r),u=t===ci?Lw(e,null,s):t===$l?$d(e,null,s,.5):t===Nl?$d(e,null,s,i||1):t===_c?l3(e,null,s,a||1):Ow(e,null,s);return e=e.slice(),e[0]=u[0],e[e.length-1]=u[1],e}function zv(t,e,n){if(f_(t)){var r=Math.abs(e.reduce(function(i,a){return i+(a<0?-1:a>0?1:0)},0));r!==e.length&&n.warn("Log scale domain includes zero: "+tc(e))}return e}function KD(t,e,n){let r=e.bins;if(r&&!en(r)){const i=(r.start==null||r.stop==null)&&t.domain(),a=r.start==null?i[0]:r.start,o=r.stop==null?kn(i):r.stop,s=r.step;s||je("Scale bins parameter missing step property."),r=Bs(a,o+s,s)}return r?t.bins=r:t.bins&&delete t.bins,t.type===$p&&(r?!e.domain&&!e.domainRaw&&(t.domain(r),n=r.length):t.bins=t.domain()),n}function JD(t,e,n){var r=t.type,i=e.round||!1,a=e.range;if(e.rangeStep!=null)a=QD(r,e,n);else if(e.scheme&&(a=eB(r,e,n),qt(a))){if(t.interpolator)return t.interpolator(a);je(`Scale type ${r} does not support interpolating color schemes.`)}if(a&&vc(r))return t.interpolator(Ec(w0(a,e.reverse),e.interpolate,e.interpolateGamma));a&&e.interpolate&&t.interpolate?t.interpolate(c_(e.interpolate,e.interpolateGamma)):qt(t.round)?t.round(i):qt(t.rangeRound)&&t.interpolate(i?Dl:xi),a&&t.range(w0(a,e.reverse))}function QD(t,e,n){t!==o_&&t!==e0&&je("Only band and point scales support rangeStep.");var r=(e.paddingOuter!=null?e.paddingOuter:e.padding)||0,i=t===e0?1:(e.paddingInner!=null?e.paddingInner:e.padding)||0;return[0,e.rangeStep*Bp(n,i,r)]}function eB(t,e,n){var r=e.schemeExtent,i,a;return en(e.scheme)?a=Ec(e.scheme,e.interpolate,e.interpolateGamma):(i=e.scheme.toLowerCase(),a=Lp(i),a||je(`Unrecognized scheme name: ${e.scheme}`)),n=t===a_?n+1:t===$p?n-1:t===Qd||t===i_?+e.schemeCount||qD:n,vc(t)?U1(a,r,e.reverse):qt(a)?v4(U1(a,r),n):t===Np?a:a.slice(0,n)}function U1(t,e,n){return qt(t)&&(e||n)?_4(t,w0(e||[0,1],n)):t}function w0(t,e){return e?t.slice().reverse():t}const q1=gt(",d");function tB(t,e){return t.chrom+":"+q1(Math.floor(t.pos+1))+"-"+(t.chrom!=e.chrom?e.chrom+":":"")+q1(Math.ceil(e.pos))}const nB="https://genomespy.app/data/genomes/";class rB{constructor(e){if(this.config=e,!this.config.contigs&&typeof this.config.name!="string")throw new Error("No name has been defined for the genome assembly!");this.chromosomes=[],this.cumulativeChromPositions=new Map,this.chromosomesByName=new Map,this.startByIndex=[],this.totalSize=0,this.config.contigs&&this.setChromSizes(this.config.contigs)}get name(){return this.config.name}async load(e){if(!this.config.contigs){this.config.baseUrl?this.baseUrl=/^http(s)?/.test(this.config.baseUrl)?this.config.baseUrl:e+"/"+this.config.baseUrl:this.baseUrl=nB;try{this.setChromSizes(iB(await fc({baseURL:this.baseUrl}).load(`${this.config.name}/${this.name}.chrom.sizes`)))}catch(n){throw new Error(`Could not load chrom sizes: ${n.message}`)}}}hasChrPrefix(){return this.chromosomes.some(e=>e.name.startsWith("chr"))}setChromSizes(e){let n=0;this.startByIndex=[0];for(let r=0;r<e.length;r++){this.startByIndex.push(n);const i=e[r].size,a={...e[r],continuousStart:n,continuousEnd:n+i,continuousInterval:[n,n+i],index:r,number:r+1,odd:!(r&1)};this.chromosomes.push(a);const o=a.name.replace(/^chr/i,"");for(const s of["chr"+o,"CHR"+o,"Chr"+o,a.number,""+a.number,o,a.name])this.cumulativeChromPositions.set(s,n),this.chromosomesByName.set(s,a);n+=a.size}this.totalSize=n}getExtent(){return[0,this.totalSize]}toContinuous(e,n){let r=this.cumulativeChromPositions.get(e);if(r===void 0)throw new Error("Unknown chromosome/contig: "+e);return r+ +n}toChromosome(e){if(e>this.totalSize)return;e=Math.floor(e);const n=ko(this.startByIndex,e)-1;if(n>0&&n<=this.chromosomes.length)return this.chromosomes[n-1]}toChromosomal(e){const n=this.toChromosome(e);if(n)return{chrom:n.name,pos:Math.floor(e)-n.continuousStart}}getChromosome(e){return this.chromosomesByName.get(e)}formatInterval(e){return tB(...this.toChromosomalInterval(e))}toChromosomalInterval(e){const n=this.toChromosomal(e[0]+.5),r=this.toChromosomal(e[1]-.5);return r.pos+=1,[n,r]}toContinuousInterval(e){var i;let[n,r]=e;return r||(r=n),[this.toContinuous(n.chrom,n.pos??0),this.toContinuous(r.chrom,r.pos??((i=this.chromosomesByName.get(r.chrom))==null?void 0:i.size))]}toDiscreteChromosomeIntervals(e){const n=e[0],r=e[1],i=[];if(n.chrom===r.chrom)i.push({chrom:n.chrom,startPos:n.pos,endPos:r.pos});else{const a=this.chromosomes.findIndex(s=>s.name===n.chrom),o=this.chromosomes.findIndex(s=>s.name===r.chrom);i.push({chrom:n.chrom,startPos:n.pos,endPos:this.chromosomes[a].size});for(let s=a+1;s<o;s++)i.push({chrom:this.chromosomes[s].name,startPos:0,endPos:this.chromosomes[s].size});i.push({chrom:r.chrom,startPos:0,endPos:r.pos})}return i}continuousToDiscreteChromosomeIntervals(e){return this.toDiscreteChromosomeIntervals([this.toChromosomal(e[0]),this.toChromosomal(e[1])])}parseInterval(e){const n=e.match(/^(chr[0-9A-Z]+)(?::([0-9,]+)(?:-(?:(chr[0-9A-Z]+):)?([0-9,]+))?)?$/);if(n){const r=n[1];if(n.slice(2).every(s=>s===void 0)){const s=this.getChromosome(r);return s?[s.continuousStart,s.continuousEnd]:void 0}const i=n[3]||r,a=parseInt(n[2].replace(/,/g,"")),o=n[4]!==void 0?parseInt(n[4].replace(/,/g,"")):a;return[this.toContinuous(r,a-1),this.toContinuous(i,o)]}}}function iB(t){return KS(t).filter(e=>/^chr[0-9A-Z]+$/.test(e[0])).map(([e,n])=>({name:e,size:parseInt(n)}))}function Uv(t){return Bn(t)&&"chrom"in t}function aB(t){return t.every(Uv)}class Gl extends Array{constructor(){super(),this.type=void 0}extend(e){return this}extendAll(e){if(e instanceof Gl&&e.type!=this.type)throw new Error(`Cannot combine different types of domains: ${this.type} and ${e.type}`);for(const n of e)this.extend(n);return this}extendAllWithAccessor(e,n){for(const r of e)this.extend(n(r));return this}}class Ch extends Gl{constructor(){super(),this.type="quantitative"}extend(e){return e==null||Number.isNaN(e)?this:(e=+e,this.length?e<this[0]?this[0]=e:e>this[1]&&(this[1]=e):(this.push(e),this.push(e)),this)}}class qv extends Gl{constructor(){super(),this.type="ordinal",this.uniqueValues=new Set}extend(e){return e==null||Number.isNaN(e)?this:(this.uniqueValues.has(e)||(this.uniqueValues.add(e),this.push(e)),this)}}class Vv extends qv{constructor(){super(),this.type="nominal"}}class oB extends Gl{constructor(e){super();let n=0;for(let r=1;r<e.length;r++)n+=Math.sign(e[r]-e[r-1]);if(Math.abs(n)!=e.length-1)throw new Error("Piecewise domain must be strictly increasing or decreasing: "+JSON.stringify(e));e.forEach(r=>this.push(r))}extend(e){if(this.includes(e))return this;throw new Error("Piecewise domains are immutable and cannot be unioned!")}}const V1={quantitative:Ch,index:Ch,locus:Ch,nominal:Vv,ordinal:qv};function H1(t,e){if(t=="quantitative"&&sB(e)){const n=new oB(e);return n.type=t,n}else if(V1[t]){const n=new V1[t];return n.type=t,e&&n.extendAll(e),n}throw new Error("Unknown type: "+t)}function sB(t){return t&&t.length>0&&t.length!=2&&t.every(e=>typeof e=="number")}function lB(t){return((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2}function uB(t,e,n){return t*Math.pow(e/t,n)}Ae("index",og,["continuous"]);Ae("locus",RD,["continuous"]);Ae("null",Ac,[]);const G1="quantitative",Hv="ordinal",Gv="nominal",jv="locus",fB="index";var Ar,eo,ct,Zn,jr,Hf,Wv,to,zu,Sr,Ri,wl,x0,Gf,Zv,np,hB,xl,_0;class cB{constructor(e){ge(this,Zn);ge(this,Hf);ge(this,to);ge(this,Sr);ge(this,wl);ge(this,Gf);ge(this,np);ge(this,xl);ge(this,Ar,void 0);ge(this,eo,new Set);ge(this,ct,void 0);this.channel=e,this.members=[],this.type=null,this.name=void 0}addEventListener(e,n){if(e!="domain")throw new Error("Unsupported event type: "+e);re(this,eo).add(n)}removeEventListener(e,n){if(e!="domain")throw new Error("Unsupported event type: "+e);re(this,eo).delete(n)}pushUnitView(e,n){var o;const r=t0(e,n),i=r.type,a=(o=r==null?void 0:r.scale)==null?void 0:o.name;if(a){if(this.name!==void 0&&a!=this.name)throw new Error(`Shared scales have conflicting names: "${a}" vs. "${this.name}"!`);this.name=a}if(!this.type)this.type=i;else if(i!==this.type&&!gs(n))throw new Error(`Can not use shared scale for different data types: ${this.type} vs. ${i}. Use "resolve: independent" for channel ${this.channel}`);this.members.push({view:e,channel:n})}isExplicitDomain(){return!!this.getConfiguredDomain()}isDomainInitialized(){const e=re(this,ct);if(!e)return!1;const n=e.domain();return wt(e.type)?n.length>2||n.length==2&&(n[0]!==0||n[1]!==0):n.length>0}getScaleProps(){return yo(this,"scaleProps",()=>{const e=se(this,Hf,Wv).call(this);if(e===null||e.type=="null")return{type:"null"};const n={...se(this,Gf,Zv).call(this,this.type),...e};n.type||(n.type=dB(this.channel,this.type));const r=se(this,to,zu).call(this);return r&&r.length>0?n.domain=r:hi(n.type)&&(n.domain=new Vv),!n.domain&&n.domainMid!==void 0&&(n.domain=[n.domainMin??0,n.domainMax??1]),this.channel=="y"&&hi(n.type)&&n.reverse==null&&(n.reverse=!0),n.range&&n.scheme&&delete n.scheme,!("zoom"in n)&&["index","locus"].includes(n.type)&&(n.zoom=!0),pB(n,this.channel),n})}getConfiguredDomain(){return se(this,xl,_0).call(this,e=>gs(e.channel)?void 0:e.view.getConfiguredDomain(e.channel))}getDataDomain(){return se(this,xl,_0).call(this,e=>gs(e.channel)?void 0:e.view.extractDataDomain(e.channel))}reconfigure(){if(re(this,ct)&&re(this,ct).type!="null"){const e=this.isDomainInitialized(),n=re(this,ct).domain();vv(this,"scaleProps");const r=this.getScaleProps();if(Pv(r,re(this,ct)),wt(re(this,ct).type)&&qn(this,Ar,se(this,wl,x0).call(this)),!e){se(this,Zn,jr).call(this);return}const i=re(this,ct).domain();uf(i,n)||(this.isZoomable()?re(this,ct).domain(n):se(this,Sr,Ri).call(this)?(re(this,ct).domain(n),this.zoomTo(i,500)):se(this,Zn,jr).call(this))}}getScale(){if(re(this,ct))return re(this,ct);const e=this.getScaleProps(),n=GD(e);return qn(this,ct,n),DD(n)&&n.genome(this.getGenome()),wt(n.type)&&qn(this,Ar,se(this,wl,x0).call(this)),n}getDomain(){return this.getScale().domain()}getComplexDomain(){var e;return((e=this.getGenome())==null?void 0:e.toChromosomalInterval(this.getDomain()))??this.getDomain()}isZoomed(){return se(this,Sr,Ri).call(this)&&uf(se(this,to,zu).call(this),this.getDomain())}isZoomable(){return se(this,Sr,Ri).call(this)&&!!this.getScaleProps().zoom}zoom(e,n,r){if(!se(this,Sr,Ri).call(this))return!1;const i=this.getScale(),a=i.domain();let o=[...a],s=i.invert(n);switch(this.getScaleProps().reverse&&(r=-r),"align"in i&&(s+=i.align()),i.type){case"linear":case"index":case"locus":o=a3(o,r||0),o=Ow(o,s,e);break;case"log":o=o3(o,r||0),o=Lw(o,s,e);break;case"pow":case"sqrt":{const u=i;o=s3(o,r||0,u.exponent()),o=$d(o,s,e,u.exponent());break}default:throw new Error("Zooming is not implemented for: "+i.type)}return re(this,Ar)&&(o=u3(o,re(this,Ar)[0],re(this,Ar)[1])),[0,1].some(u=>o[u]!=a[u])?(i.domain(o),se(this,Zn,jr).call(this),!0):!1}async zoomTo(e,n=!1){var s;if(ec(n)&&(n=n?700:0),!se(this,Sr,Ri).call(this))throw new Error("Not a zoomable scale!");const r=this.fromComplexInterval(e),i=(s=this.members[0])==null?void 0:s.view.context.animator,a=this.getScale(),o=a.domain();if(n>0&&o.length==2){const u=o[1]-o[0],l=o[0]+u/2,f=r[1]-r[0],c=r[0]+f/2;await i.transition({duration:n,easingFunction:lB,onUpdate:h=>{const d=uB(u,f,h),p=(u-d)/(u-f),m=p*c+(1-p)*l;a.domain([m-d/2,m+d/2]),se(this,Zn,jr).call(this)}}),a.domain(r),se(this,Zn,jr).call(this)}else a.domain(r),i==null||i.requestRender(),se(this,Zn,jr).call(this)}resetZoom(){if(!se(this,Sr,Ri).call(this))throw new Error("Not a zoomable scale!");const e=this.getDomain(),n=se(this,to,zu).call(this);return[0,1].some(r=>n[r]!=e[r])?(re(this,ct).domain(n),se(this,Zn,jr).call(this),!0):!1}getZoomLevel(){return this.isZoomable()?tf(re(this,Ar))/tf(this.getScale().domain()):1}getGenome(){var n;if(this.type!=="locus")return;const e=(n=this.members[0].view.context.genomeStore)==null?void 0:n.getGenome();if(!e)throw new Error("No genome has been defined!");return e}invertToComplex(e){const n=this.getScale();if("invert"in n){const r=n.invert(e);return this.toComplex(r)}else throw new Error("The scale does not support inverting!")}toComplex(e){const n=this.getGenome();return n?n.toChromosomal(e):e}fromComplex(e){return Uv(e)?this.getGenome().toContinuous(e.chrom,e.pos):e}fromComplexInterval(e){return this.type==="locus"&&aB(e)?this.getGenome().toContinuousInterval(e):e}}Ar=new WeakMap,eo=new WeakMap,ct=new WeakMap,Zn=new WeakSet,jr=function(){for(const e of re(this,eo).values())e({type:"domain",scaleResolution:this})},Hf=new WeakSet,Wv=function(){return yo(this,"mergedScaleProps",()=>{const e=this.members.map(n=>t0(n.view,n.channel).scale).filter(n=>n!==void 0);return _f(e,"scale",["domain"])})},to=new WeakSet,zu=function(){return this.getConfiguredDomain()??(this.type==jv?this.getGenome().getExtent():this.getDataDomain())},Sr=new WeakSet,Ri=function(){const e=this.getScale().type;return wt(e)},wl=new WeakSet,x0=function(){const e=this.getScaleProps(),n=e.zoom;if(gB(n)&&en(n.extent))return this.fromComplexInterval(n.extent);if(n)return e.type=="locus"?this.getGenome().getExtent():re(this,ct).domain()},Gf=new WeakSet,Zv=function(e){const n=this.channel,r={};return this.isExplicitDomain()&&(r.zero=!1),Zs(n)?r.nice=!this.isExplicitDomain():Xi(n)?r.scheme=e==Gv?"tableau10":e==Hv?"blues":"viridis":Sc(n)?r.range=b_(n):n=="size"?r.range=[0,400]:n=="angle"&&(r.range=[0,360]),r},np=new WeakSet,hB=function(){return this.members.map(e=>e.view.getPathString()).join(", ")},xl=new WeakSet,_0=function(e){const n=this.members.filter(r=>!r.view.getLayoutAncestors().some(i=>!i.contributesToScaleDomain)).map(e).filter(r=>!!r);if(n.length)return n.reduce((r,i)=>r.extendAll(i))};function dB(t,e){if(e==fB||e==jv){if(g_(t))return e;throw new Error(`${t} does not support ${e} data type. Only positional channels do.`)}const n={x:["band","band","linear"],y:["band","band","linear"],size:[void 0,"point","linear"],opacity:[void 0,"point","linear"],fillOpacity:[void 0,"point","linear"],strokeOpacity:[void 0,"point","linear"],color:["ordinal","ordinal","linear"],fill:["ordinal","ordinal","linear"],stroke:["ordinal","ordinal","linear"],strokeWidth:[void 0,void 0,"linear"],shape:["ordinal","ordinal",void 0],dx:[void 0,void 0,"null"],dy:[void 0,void 0,"null"],angle:[void 0,void 0,"linear"]},i=["sample"].includes(t)?"null":n[t]?n[t][[Gv,Hv,G1].indexOf(e)]:e==G1?"linear":"ordinal";if(i===void 0)throw new Error(`Channel "${t}" is not compatible with "${e}" data type. Use of a proper scale may be needed.`);return i}function pB(t,e){Zs(e)&&t.type!=="ordinal"&&(t.range=[0,1]),e=="opacity"&&wt(t.type)&&(t.clamp=!0)}function gB(t){return Bn(t)}function v0(t){const e=new Set;function n(r){for(const i of Object.values(r.resolutions.scale))e.add(i)}for(const r of Jt(t)){r.visit(n);for(const i of r.getDataAncestors()){if(!i.contributesToScaleDomain)break;n(i)}}e.forEach(r=>r.reconfigure())}function Th(...t){for(const e of t)if(e!==void 0)return e}class mB{constructor(e){this.channel=e,this.members=[]}get scaleResolution(){var e;return(e=Tl(this.members))==null?void 0:e.view.getScaleResolution(this.channel)}pushUnitView(e,n){const r=e.getScaleResolution(this.channel);if(!r)throw new Error("Cannot find a scale resolution!");if(this.scaleResolution&&r!==this.scaleResolution)throw new Error("Shared axes must have a shared scale!");this.members.push({view:e,channel:n})}getAxisProps(){return yo(this,"axisProps",()=>{const e=this.members.map(n=>{const r=n.view.mark.encoding[n.channel];return"axis"in r&&r.axis});return e.length>0&&e.some(n=>n===null)?null:_f(e.filter(n=>n!==void 0),"axis",["title"])})}getTitle(){const e=a=>{var s;const o=t0(a.view,a.channel);if(!Rn(o))return{member:a,explicitTitle:Th("axis"in o?(s=o.axis)==null?void 0:s.title:void 0,o.title),implicitTitle:Th(Pl(o)?o.field:void 0,Mp(o)?o.expr:void 0)}},n=this.members.map(e),r=n.filter(a=>{var o;if(gs(a.member.channel)&&!a.explicitTitle){const s=aa(a.member.channel);return((o=n.find(u=>u.member.view==a.member.view&&u.member.channel==s))==null?void 0:o.explicitTitle)===void 0}return!0}),i=new Set(r.map(a=>Th(a.explicitTitle,a.implicitTitle)).filter(We));return i.size?[...i].join(", "):null}}const bB={point:fD,rect:rD,rule:dD,link:bD,text:ED};class Ct extends wo{constructor(e,n,r,i,a){super(e,n,r,i,a),this.spec=e;const o=bB[this.getMarkType()];if(o)this.mark=new o(this);else throw new Error(`No such mark: ${this.getMarkType()}`);this.coords=void 0,this.needsAxes={x:!0,y:!0}}render(e,n,r={}){this.isConfiguredVisible()&&(this.coords=n,e.pushView(this,n),e.renderMark(this.mark,r),e.popView(this))}getMarkType(){return typeof this.spec.mark=="object"?this.spec.mark.type:this.spec.mark}resolve(e){const n=this.mark.encoding;for(const[r,i]of Object.entries(n)){if(!sn(i))continue;const a=aa(i.resolutionChannel??r);if(!Ki(a)||e=="axis"&&!Zs(a))continue;let o=this;for(;(o.getConfiguredOrDefaultResolution(a,e)=="forced"||o.dataParent instanceof wo&&["shared","excluded","forced"].includes(o.dataParent.getConfiguredOrDefaultResolution(a,e)))&&o.getConfiguredOrDefaultResolution(a,e)!="excluded";)o=o.dataParent;e=="axis"&&Zs(r)&&g_(a)?(o.resolutions[e][a]||(o.resolutions[e][a]=new mB(a)),o.resolutions[e][a].pushUnitView(this,r)):e=="scale"&&Ki(r)&&(o.resolutions[e][a]||(o.resolutions[e][a]=new cB(a)),o.resolutions[e][a].pushUnitView(this,r))}}getAccessor(e){return this._cache("accessor/"+e,()=>{const n=this.mark.encoding;if(n&&n[e])return this.context.accessorFactory.createAccessor(n[e])})}getFacetAccessor(e){const n=this.getAccessor("sample");return n||super.getFacetAccessor(this)}getCollector(){return this.context.dataFlow.findCollectorByKey(this)}_validateDomainQuery(e){if(gs(e))throw new Error(`getDomain(${e}), must only be called for primary channels!`);const n=this.mark.encoding[e];if(!sn(n))throw new Error("The channel has no scale, cannot get domain!");return n}getConfiguredDomain(e){const n=this._validateDomainQuery(e),r=n&&n.scale&&n.scale.domain;if(r){const i=this.getScaleResolution(n.resolutionChannel??e);return H1(n.type??"nominal",i.fromComplexInterval(r))}}extractDataDomain(e){const r=this._validateDomainQuery(e).type??"nominal",i=s=>{let u;const l=this.mark.encoding[s];if(l){const f=this.context.accessorFactory.createAccessor(l);if(f)if(u=H1(r),f.constant)u.extend(f({}));else{const c=this.getCollector();c!=null&&c.completed&&c.visitData(h=>u.extend(f(h)))}}return u};let a=i(e);const o=Pp[e];if(o){const s=i(o);s&&a.extendAll(s)}return a}getZoomLevel(){const e=n=>{var r;return((r=this.getScaleResolution(n))==null?void 0:r.getZoomLevel())??1};return Bo.map(e).reduce((n,r)=>n*r,1)}propagateInteractionEvent(e){this.handleInteractionEvent(void 0,e,!0),e.target=this,!e.stopped&&this.handleInteractionEvent(void 0,e,!1)}getDefaultResolution(e,n){return e=="x"?"shared":"independent"}}class Yv extends Dv{constructor(e,n,r,i,a){super(e,n,r,i,a),this.spec=e}}function*sg(t,e=[]){for(const[n,r]of t.entries())if(r instanceof Map)for(const i of sg(r,[...e,n]))yield i;else yield[[...e,n],r]}class Xv extends Xe{get behavior(){return ag}constructor(e){super(),this.params=e??{type:"collect"},this.observers=[],this.facetBatches=void 0,this._init()}_init(){this._data=[],this.facetBatches=new ea([],JSON.stringify),this.facetBatches.set(void 0,this._data)}reset(){super.reset(),this._init()}handle(e){this._data.push(e)}beginBatch(e){sD(e)&&(this._data=[],this.facetBatches.set(Jt(e.facetId),this._data))}complete(){var i,a;const e=(i=this.params)==null?void 0:i.sort,n=e?Mw(e.field,e.order):void 0,r=o=>{n&&o.sort(n)};if((a=this.params.groupby)!=null&&a.length){if(this.facetBatches.size>1)throw new Error("TODO: Support faceted data!");const o=this.params.groupby.map(u=>De(u)),s=rc(this._data,...o);this.facetBatches.clear();for(const[u,l]of sg(s))this.facetBatches.set(u,l)}for(const o of this.facetBatches.values())r(o);if(this.children.length)for(const[o,s]of this.facetBatches.entries()){if(o){const u={type:"facet",facetId:o};for(const l of this.children)l.beginBatch(u)}for(const u of s)this._propagate(u)}super.complete();for(const o of this.observers)o(this)}getData(){switch(this._checkStatus(),this.facetBatches.size){case 0:return[];case 1:return[...this.facetBatches.values()][0];default:{const e=this.facetBatches;return{[Symbol.iterator]:function*(){for(const r of e.values())for(let i=0;i<r.length;i++)yield r[i]}}}}}visitData(e){this._checkStatus();for(const n of this.facetBatches.values())for(let r=0;r<n.length;r++)e(n[r])}getItemCount(){let e=0;for(const n of this.facetBatches.values())e+=n.length;return e}_checkStatus(){if(!this.completed)throw new Error("Data propagation is not completed! No data are available.")}}class vf{constructor(){this.ids=[],this.values=[],this.length=0}clear(){this.length=0}push(e,n){let r=this.length++;for(;r>0;){const i=r-1>>1,a=this.values[i];if(n>=a)break;this.ids[r]=this.ids[i],this.values[r]=a,r=i}this.ids[r]=e,this.values[r]=n}pop(){if(this.length===0)return;const e=this.ids[0];if(this.length--,this.length>0){const n=this.ids[0]=this.ids[this.length],r=this.values[0]=this.values[this.length],i=this.length>>1;let a=0;for(;a<i;){let o=(a<<1)+1;const s=o+1;let u=this.ids[o],l=this.values[o];const f=this.values[s];if(s<this.length&&f<l&&(o=s,u=this.ids[s],l=f),l>=r)break;this.ids[a]=u,this.values[a]=l,a=o}this.ids[a]=n,this.values[a]=r}return e}peek(){if(this.length!==0)return this.ids[0]}peekValue(){if(this.length!==0)return this.values[0]}shrink(){this.ids.length=this.values.length=this.length}}class yB extends Xe{get behavior(){return fr}constructor(e){super(),this.params=e,this.startAccessor=De(e.start),this.endAccessor=De(e.end),this.chromAccessor=e.chrom?De(e.chrom):n=>{},this.weightAccessor=e.weight?De(e.weight):n=>1,this.as={coverage:e.as||"coverage",start:e.asStart||e.start,end:e.asEnd||e.end,chrom:e.asChrom||e.chrom},this.createSegment=new Function("start","end","coverage","chrom","return {"+Object.entries(this.as).filter(([n,r])=>r).map(([n,r])=>`${JSON.stringify(r)}: ${n}`).join(", ")+"};"),this.ends=new vf}reset(){super.reset(),this.initialize()}initialize(){const e=this.as.coverage,n=this.as.end,r=this.as.chrom,i=this.startAccessor,a=this.endAccessor,o=this.chromAccessor,s=this.weightAccessor;let u,l,f,c=0,h;const d=this.ends;d.clear();const p=(y,w,A)=>{if(y==w)return;let C=!1;u&&(u[e]===A?(u[n]=w,C=!0):u[e]!=0&&this._propagate(u)),C||(u=this.createSegment(y,w,A,f))},m=()=>{let y;for(;(y=d.peekValue())!==void 0;)p(h,y,c),h=y,c-=d.pop();h=void 0,u&&(this._propagate(u),u=void 0)};this.handle=y=>{const w=i(y);let A;for(;(A=d.peekValue())!==void 0&&A<w;)p(h,A,c),h=A,c-=d.pop();if(r){let E=o(y);E!==l&&(m(),f=E,l=f)}h!==void 0&&p(h,w,c),h=w;const C=s(y);c+=C,d.push(C,a(y))},this.complete=()=>{m(),super.complete()}}}function wB(t,e,n=0,r=t.length){const i=new vf,a=r-n;let o;for(o=0;o<e&&o<a;o++)i.push(o,t[n+o]);for(;o<a;o++){const l=t[n+o];l>=i.peekValue()&&(i.push(o,l),i.pop())}const s=[];let u;for(;(u=i.pop())!==void 0;)s.push(n+u);return s.reverse()}class xB{constructor(e,n=-1/0,r=1/0){this.maxSize=e,this.lowerLimit=n,this.upperLimit=r;const i=this.maxSize*2+1;this.lowerLimits=new Float64Array(i),this.upperLimits=new Float64Array(i),this.lowerChildren=new Int32Array(i),this.upperChildren=new Int32Array(i),this.reset()}reset(){this.lowerLimits.fill(0),this.upperLimits.fill(0),this.lowerChildren.fill(0),this.upperChildren.fill(0),this.n=1,this.lowerLimits[0]=this.lowerLimit,this.upperLimits[0]=this.upperLimit}_findSlot(e,n,r=0){if(e>=this.lowerLimits[r]&&n<=this.upperLimits[r]){const i=this.lowerChildren[r];if(i){const a=this._findSlot(e,n,i);return a>=0?a:this._findSlot(e,n,this.upperChildren[r])}else return r}else return-1}reserve(e,n){if(n-e<=0)throw new Error("Cannot reserve an empty or negative-size slot!");if(this.n+1>this.lowerLimits.length)return!1;const r=this._findSlot(e,n);if(r<0)return!1;const i=this.n++,a=this.n++;return this.lowerLimits[i]=this.lowerLimits[r],this.upperLimits[i]=e,this.lowerLimits[a]=n,this.upperLimits[a]=this.upperLimits[r],this.lowerChildren[r]=i,this.upperChildren[r]=a,!0}}class _B extends Xe{get behavior(){return ag}constructor(e,n){if(super(),this.params=e,this._data=[],this.channel=e.channel??"x",!["x","y"].includes(this.channel))throw new Error("Invalid channel: "+this.channel);this.posAccessor=De(this.params.pos),this.posBisector=nc(this.posAccessor),this.scoreAccessor=De(this.params.score),this.widthAccessor=De(this.params.width),this.laneAccessor=this.params.lane?De(this.params.lane):i=>0,this.padding=this.params.padding??0,this.reservationMaps=new Map,this.resolution=n.getScaleResolution(this.channel);const r=()=>this._filterAndPropagate();this.schedule=()=>n.context.animator.requestTransition(r),this.resolution.addEventListener("domain",i=>this.schedule()),n._addBroadcastHandler("layoutComputed",()=>this.schedule())}complete(){const e=this.posAccessor;this._data.sort((n,r)=>e(n)-e(r)),this._scores=this._data.map(this.scoreAccessor);for(const n of new Set(this._data.map(this.laneAccessor)))this.reservationMaps.set(n,new xB(200));this.schedule(),super.complete()}_filterAndPropagate(){var o;super.reset();const e=this.resolution.getScale(),n=(o=this.resolution.members[0].view.coords)==null?void 0:o[this.channel=="x"?"width":"height"];if(!n)return;for(const s of this.reservationMaps.values())s.reset();const r=e.domain(),i=70,a=wB(this._scores,i,this.posBisector.left(this._data,r[0]),this.posBisector.right(this._data,r[1]));for(const s of a){const u=this._data[s],l=e(this.posAccessor(u))*n,f=this.widthAccessor(u)/2+this.padding;this.reservationMaps.get(this.laneAccessor(u)).reserve(l-f,l+f)&&this._propagate(u)}super.complete()}reset(){super.reset(),this._data=[],this.groups=new Map}handle(e){this._data.push(e)}}class vB extends Xe{constructor(e){super(),this.params=e,this.predicate=void 0}initialize(){this.predicate=bp(this.params.expr,this.getGlobalObject())}handle(e){this.predicate(e)&&this._propagate(e)}}class EB extends Xe{get behavior(){return fr}constructor(e){super();const n=e.index;if(e.fields){const r=Jt(e.fields).map(a=>De(a)),i=Jt(e.as||e.fields);if(r.length!==i.length)throw new Error(`Lengths of "fields" (${r.length}), and "as" (${i.length}) do not match!`);this.handle=a=>{const o=r.map((u,l)=>u(a)??[]),s=o[0].length;for(let u=0;u<s;u++){const l=Object.assign({},a);for(let f=0;f<r.length;f++)l[i[f]]=u<o[f].length?o[f][u]:null;n&&(l[n]=u),this._propagate(l)}}}else this.handle=r=>{for(let i=0;i<r.length;i++){const a=Object.assign({},r[i]);n&&(a[n]=i),this._propagate(a)}}}}const AB="0".charCodeAt(0);function*SB(t,e=","){const n=e.charCodeAt(0);let r=0;for(let i=0;i<t.length;i++){const a=t.charCodeAt(i);a==n?(yield r,r=0):r=r*10+a-AB}yield r}class CB extends Xe{get behavior(){return fr}constructor(e){super();const n=De(e.exons??"exons"),r=De(e.start??"start"),[i,a]=e.as||["exonStart","exonEnd"];this.handle=o=>{let s=r(o),u=s,l=!0;const f=n(o);for(const c of SB(f)){if(l)u=s+c;else{s=u+c;const h=Object.assign({},o);h[i]=u,h[a]=s,this._propagate(h)}l=!l}}}}class TB extends Xe{get behavior(){return fr}constructor(e){super();const n=Jt(e.field).map(a=>De(a)),r=Jt(e.separator),i=Jt(e.as||e.field);if(n.length!==r.length||n.length!==i.length)throw new Error(`Lengths of "separator" (${r.length}), "fields" (${n.length}), and "as" (${i.length}) do not match!`);this.handle=a=>{if(n.some(u=>!u(a)))return;const o=n.map((u,l)=>u(a).split(r[l]));FB(o,a);const s=o[0].length;for(let u=0;u<s;u++){const l=Object.assign({},a);for(let f=0;f<n.length;f++)l[i[f]]=o[f][u];this._propagate(l)}}}}function FB(t,e){const n=t.map(r=>r.length);if(!n.every(r=>r==n[0]))throw new Error("Mismatching number of elements in the fields to be split: "+JSON.stringify(e))}class IB extends Xe{get behavior(){return Si}constructor(e){super(),this.params=e,this.as=e.as,this.fn=void 0}initialize(){this.fn=bp(this.params.expr,this.getGlobalObject())}handle(e){e[this.as]=this.fn(e),this._propagate(e)}}class Kv extends Xe{get behavior(){return Si}constructor(e,n){super();const r=e.channel??"x";if(!["x","y"].includes(r))throw new Error("Invalid channel: "+r);const i=n.getScaleResolution(r).getGenome();if(!i)throw new Error("LinearizeGenomicCoordinate transform requires a locus scale!");const a=De(e.chrom),o=Jt(e.pos).map(p=>De(p)),s=Jt(e.as);if(o.length!=s.length)throw new Error('The number of "pos" and "as" elements must be equal!');const u=Jt(e.offset);let l;if(u.length==0)l=new Array(o.length).fill(0);else if(u.length==1)l=new Array(o.length).fill(u[0]);else if(u.length==o.length)l=u;else throw new Error(`Invalid "offset" parameter: ${JSON.stringify(e.offset)}!`);const f=new Function("datum","chromOffset","posAccessors",s.map((p,m)=>`datum[${JSON.stringify(p)}] = chromOffset + +posAccessors[${m}](datum) - ${l[m]};`).join(` -`));let c,h=0;const d=p=>{if(p!==c){if(h=i.cumulativeChromPositions.get(p),h===void 0)throw new Error("Unknown chromosome/contig: "+p);c=p}return h};this.handle=p=>{f(p,d(a(p)),o),this._propagate(p)}}}const kB=["Lato-Regular.png"],RB=[{id:87,width:53,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:43.491,chnl:15,x:0,y:0,page:0},{id:124,width:17,height:50,xoffset:0,yoffset:-32.193000000000005,xadvance:10.521,chnl:15,x:0,y:42,page:0},{id:40,width:20,height:49,xoffset:0,yoffset:-32.571000000000005,xadvance:11.214,chnl:15,x:0,y:94,page:0},{id:41,width:19,height:49,xoffset:0,yoffset:-32.571000000000005,xadvance:11.214,chnl:15,x:0,y:145,page:0},{id:36,width:32,height:49,xoffset:0,yoffset:-34.419000000000004,xadvance:24.360000000000003,chnl:15,x:0,y:196,page:0},{id:125,width:21,height:48,xoffset:0,yoffset:-32.193000000000005,xadvance:12.642000000000001,chnl:15,x:0,y:247,page:0},{id:91,width:22,height:48,xoffset:0,yoffset:-32.193000000000005,xadvance:12.852,chnl:15,x:0,y:297,page:0},{id:93,width:19,height:48,xoffset:0,yoffset:-32.193000000000005,xadvance:12.852,chnl:15,x:0,y:347,page:0},{id:123,width:21,height:48,xoffset:0,yoffset:-32.193000000000005,xadvance:12.642000000000001,chnl:15,x:0,y:397,page:0},{id:106,width:19,height:48,xoffset:0,yoffset:-30.639000000000003,xadvance:10.08,chnl:15,x:0,y:447,page:0},{id:81,width:43,height:47,xoffset:0,yoffset:-30.429000000000002,xadvance:33.621,chnl:15,x:21,y:447,page:0},{id:77,width:45,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:38.997,chnl:15,x:66,y:447,page:0},{id:64,width:43,height:44,xoffset:0,yoffset:-28.539,xadvance:35.133,chnl:15,x:23,y:397,page:0},{id:92,width:28,height:43,xoffset:0,yoffset:-30.933000000000003,xadvance:18.984,chnl:15,x:68,y:397,page:0},{id:47,width:28,height:43,xoffset:0,yoffset:-30.933000000000003,xadvance:18.984,chnl:15,x:98,y:397,page:0},{id:109,width:42,height:32,xoffset:0,yoffset:-21.609,xadvance:34.545,chnl:15,x:113,y:447,page:0},{id:119,width:42,height:31,xoffset:0,yoffset:-21.315,xadvance:32.991,chnl:15,x:157,y:447,page:0},{id:42,width:25,height:42,xoffset:0,yoffset:-31.626,xadvance:17.85,chnl:15,x:128,y:397,page:0},{id:37,width:42,height:41,xoffset:0,yoffset:-30.387,xadvance:33.663000000000004,chnl:15,x:155,y:397,page:0},{id:79,width:42,height:41,xoffset:0,yoffset:-30.429000000000002,xadvance:33.621,chnl:15,x:199,y:397,page:0},{id:102,width:24,height:41,xoffset:0,yoffset:-30.534000000000002,xadvance:14.721,chnl:15,x:243,y:397,page:0},{id:100,width:31,height:41,xoffset:0,yoffset:-30.933000000000003,xadvance:23.520000000000003,chnl:15,x:269,y:397,page:0},{id:98,width:32,height:41,xoffset:0,yoffset:-30.933000000000003,xadvance:23.520000000000003,chnl:15,x:302,y:397,page:0},{id:56,width:32,height:41,xoffset:0,yoffset:-30.429000000000002,xadvance:24.360000000000003,chnl:15,x:336,y:397,page:0},{id:38,width:40,height:41,xoffset:0,yoffset:-30.429000000000002,xadvance:29.904000000000003,chnl:15,x:370,y:397,page:0},{id:108,width:17,height:41,xoffset:0,yoffset:-30.933000000000003,xadvance:9.912,chnl:15,x:412,y:397,page:0},{id:107,width:31,height:41,xoffset:0,yoffset:-30.933000000000003,xadvance:21.336000000000002,chnl:15,x:431,y:397,page:0},{id:48,width:33,height:41,xoffset:0,yoffset:-30.429000000000002,xadvance:24.360000000000003,chnl:15,x:464,y:397,page:0},{id:71,width:38,height:41,xoffset:0,yoffset:-30.429000000000002,xadvance:30.681,chnl:15,x:21,y:347,page:0},{id:83,width:31,height:41,xoffset:0,yoffset:-30.429000000000002,xadvance:22.785,chnl:15,x:61,y:347,page:0},{id:63,width:27,height:41,xoffset:0,yoffset:-30.429000000000002,xadvance:18.795,chnl:15,x:94,y:347,page:0},{id:105,width:18,height:41,xoffset:0,yoffset:-30.639000000000003,xadvance:10.08,chnl:15,x:123,y:347,page:0},{id:51,width:32,height:41,xoffset:0,yoffset:-30.429000000000002,xadvance:24.360000000000003,chnl:15,x:143,y:347,page:0},{id:104,width:31,height:41,xoffset:0,yoffset:-30.933000000000003,xadvance:23.436,chnl:15,x:177,y:347,page:0},{id:67,width:37,height:41,xoffset:0,yoffset:-30.429000000000002,xadvance:28.056,chnl:15,x:210,y:347,page:0},{id:88,width:37,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:27.258000000000003,chnl:15,x:249,y:347,page:0},{id:68,width:40,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:31.941000000000003,chnl:15,x:288,y:347,page:0},{id:70,width:32,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:23.751,chnl:15,x:330,y:347,page:0},{id:34,width:23,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:15.561000000000002,chnl:15,x:364,y:347,page:0},{id:72,width:38,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:32.067,chnl:15,x:389,y:347,page:0},{id:73,width:18,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:11.760000000000002,chnl:15,x:429,y:347,page:0},{id:74,width:24,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:17.745,chnl:15,x:449,y:347,page:0},{id:75,width:38,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:27.825000000000003,chnl:15,x:24,y:297,page:0},{id:76,width:31,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:21.567,chnl:15,x:475,y:347,page:0},{id:66,width:35,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:27.153000000000002,chnl:15,x:64,y:297,page:0},{id:78,width:38,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:32.067,chnl:15,x:101,y:297,page:0},{id:33,width:18,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:11.298,chnl:15,x:141,y:297,page:0},{id:80,width:34,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:25.221,chnl:15,x:161,y:297,page:0},{id:65,width:38,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:28.434,chnl:15,x:197,y:297,page:0},{id:82,width:36,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:26.313000000000002,chnl:15,x:237,y:297,page:0},{id:35,width:33,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:24.360000000000003,chnl:15,x:275,y:297,page:0},{id:84,width:34,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:24.801000000000002,chnl:15,x:310,y:297,page:0},{id:85,width:37,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:30.891000000000002,chnl:15,x:346,y:297,page:0},{id:86,width:38,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:28.434,chnl:15,x:385,y:297,page:0},{id:39,width:16,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:8.568000000000001,chnl:15,x:425,y:297,page:0},{id:69,width:32,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:24.255000000000003,chnl:15,x:443,y:297,page:0},{id:89,width:36,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:26.208000000000002,chnl:15,x:23,y:247,page:0},{id:90,width:34,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:25.284000000000002,chnl:15,x:477,y:297,page:0},{id:49,width:31,height:40,xoffset:0,yoffset:-30.156000000000002,xadvance:24.360000000000003,chnl:15,x:61,y:247,page:0},{id:50,width:32,height:40,xoffset:0,yoffset:-30.429000000000002,xadvance:24.360000000000003,chnl:15,x:94,y:247,page:0},{id:57,width:32,height:40,xoffset:0,yoffset:-30.429000000000002,xadvance:24.360000000000003,chnl:15,x:128,y:247,page:0},{id:94,width:32,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:24.360000000000003,chnl:15,x:162,y:247,page:0},{id:96,width:21,height:40,xoffset:0,yoffset:-30.429000000000002,xadvance:16.8,chnl:15,x:196,y:247,page:0},{id:55,width:33,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:24.360000000000003,chnl:15,x:219,y:247,page:0},{id:54,width:33,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:24.360000000000003,chnl:15,x:254,y:247,page:0},{id:53,width:32,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:24.360000000000003,chnl:15,x:289,y:247,page:0},{id:52,width:33,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:24.360000000000003,chnl:15,x:323,y:247,page:0},{id:103,width:31,height:39,xoffset:0,yoffset:-21.630000000000003,xadvance:21.84,chnl:15,x:358,y:247,page:0},{id:112,width:32,height:39,xoffset:0,yoffset:-21.651,xadvance:23.541,chnl:15,x:391,y:247,page:0},{id:113,width:31,height:39,xoffset:0,yoffset:-21.651,xadvance:23.520000000000003,chnl:15,x:425,y:247,page:0},{id:116,width:25,height:39,xoffset:0,yoffset:-28.182000000000002,xadvance:15.057,chnl:15,x:458,y:247,page:0},{id:121,width:31,height:38,xoffset:0,yoffset:-21.273,xadvance:21.651,chnl:15,x:34,y:196,page:0},{id:59,width:18,height:36,xoffset:0,yoffset:-20.706,xadvance:10.983,chnl:15,x:485,y:247,page:0},{id:43,width:32,height:34,xoffset:0,yoffset:-24.486,xadvance:24.360000000000003,chnl:15,x:67,y:196,page:0},{id:60,width:30,height:33,xoffset:0,yoffset:-23.331000000000003,xadvance:24.360000000000003,chnl:15,x:101,y:196,page:0},{id:62,width:31,height:33,xoffset:0,yoffset:-23.331000000000003,xadvance:24.360000000000003,chnl:15,x:133,y:196,page:0},{id:117,width:30,height:32,xoffset:0,yoffset:-21.273,xadvance:23.415000000000003,chnl:15,x:166,y:196,page:0},{id:99,width:29,height:32,xoffset:0,yoffset:-21.609,xadvance:20.055,chnl:15,x:198,y:196,page:0},{id:110,width:31,height:32,xoffset:0,yoffset:-21.609,xadvance:23.436,chnl:15,x:229,y:196,page:0},{id:111,width:32,height:32,xoffset:0,yoffset:-21.609,xadvance:23.814,chnl:15,x:262,y:196,page:0},{id:126,width:32,height:26,xoffset:0,yoffset:-16.128,xadvance:24.360000000000003,chnl:15,x:201,y:447,page:0},{id:101,width:31,height:32,xoffset:0,yoffset:-21.609,xadvance:22.176000000000002,chnl:15,x:296,y:196,page:0},{id:114,width:25,height:32,xoffset:0,yoffset:-21.651,xadvance:15.288,chnl:15,x:329,y:196,page:0},{id:115,width:27,height:32,xoffset:0,yoffset:-21.609,xadvance:18.186,chnl:15,x:356,y:196,page:0},{id:97,width:28,height:32,xoffset:0,yoffset:-21.651,xadvance:20.874000000000002,chnl:15,x:385,y:196,page:0},{id:118,width:31,height:31,xoffset:0,yoffset:-21.273,xadvance:21.672,chnl:15,x:415,y:196,page:0},{id:61,width:31,height:29,xoffset:0,yoffset:-19.089000000000002,xadvance:24.360000000000003,chnl:15,x:448,y:196,page:0},{id:120,width:30,height:31,xoffset:0,yoffset:-21.273,xadvance:20.916,chnl:15,x:21,y:145,page:0},{id:58,width:18,height:31,xoffset:0,yoffset:-20.706,xadvance:10.5,chnl:15,x:53,y:145,page:0},{id:122,width:28,height:31,xoffset:0,yoffset:-21.273,xadvance:18.984,chnl:15,x:73,y:145,page:0},{id:95,width:28,height:16,xoffset:0,yoffset:0,xadvance:19.278000000000002,chnl:15,x:235,y:447,page:0},{id:45,width:23,height:24,xoffset:0,yoffset:-14.175,xadvance:15.603000000000002,chnl:15,x:481,y:196,page:0},{id:44,width:17,height:21,xoffset:0,yoffset:-4.956,xadvance:9.534,chnl:15,x:103,y:145,page:0},{id:46,width:18,height:15,xoffset:0,yoffset:-4.956,xadvance:9.912,chnl:15,x:0,y:497,page:0},{id:32,width:0,height:0,xoffset:0,yoffset:0,xadvance:10.752,chnl:15,x:20,y:497,page:0}],DB={face:"Lato Regular",size:42,bold:0,italic:0,charset:[" ","!",'"',"#","$","%","&","'","(",")","*","+",",","-",".","/","0","1","2","3","4","5","6","7","8","9",":",";","<","=",">","?","@","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","[","\\","]","^","_","`","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","{","|","}","~"],unicode:1,stretchH:100,smooth:1,aa:1,padding:[0,0,0,0],spacing:[2,2]},BB={lineHeight:50.400000000000006,base:41.454,scaleW:512,scaleH:512,pages:1,packed:0,alphaChnl:0,redChnl:0,greenChnl:0,blueChnl:0},NB=[],Jv={pages:kB,chars:RB,info:DB,common:BB,kernings:NB};class $B extends Xe{get behavior(){return Si}constructor(e){super();const n=d0(Jv),r=De(e.field),i=e.as,a=e.fontSize;this.handle=o=>{const s=r(o);s!==void 0?o[i]=n.measureWidth(s,a):o[i]=0,this._propagate(o)}}}const OB=65536;class LB extends Xe{get behavior(){return Si}constructor(e){super(),this.params=e}reset(){super.reset(),this.initialize()}initialize(){const e=this.params,n=e.as||"lane",r=Vt(e.spacing)?e.spacing:1,i=De(e.start),a=De(e.end);if(!e.preference!=!e.preferredOrder)throw new Error('Must specify both "preference" and "preferredOrder"');if(e.preference){const o=new Float64Array(OB),s=De(e.preference),u=e.preferredOrder;let l=1/0;this.handle=f=>{const c=i(f);c<l&&o.fill(-1/0),l=c;const h=u.indexOf(s(f));let d=-1;if(h>=0&&o[h]<c)d=h;else{const p=i(f);for(d=0;d<o.length&&!(o[d]<p);d++);if(d>=o.length)throw new Error("Out of lanes!")}o[d]=a(f)+r,f[n]=d,this._propagate(f)}}else{const o=new vf,s=new vf;let u=-1/0,l=0;this.handle=f=>{const c=i(f);for(;o.length&&(o.peekValue()<=c||c<u);){const d=o.pop();s.push(d,d)}u=c;let h=s.pop();h===void 0&&(h=l++),f[n]=h,this._propagate(f),o.push(h,a(f)+r)}}}}class MB extends Xe{get behavior(){return fr}constructor(e){if(super(),e.as&&e.as.length!=e.fields.length)throw new Error('"fields" and "as" have unequal lengths!');const n=e.fields.map(i=>De(i)),r=e.as?e.as:n.map(JS);this.handle=i=>{const a={};for(let o=0;o<n.length;o++)a[r[o]]=n[o](i);this._propagate(a)}}}class PB extends Xe{get behavior(){return Si}constructor(e){super();const n=new RegExp(e.regex),r=typeof e.as=="string"?[e.as]:e.as,i=De(e.field);this.handle=a=>{const o=i(a);if(We(o)){const s=o.match(n);if(s){if(s.length-1!=r.length)throw new Error('The number of RegEx groups and the length of "as" do not match!');for(let u=0;u<r.length;u++)a[r[u]]=s[u+1]}else if(e.skipInvalidInput)for(let u=0;u<r.length;u++)a[r[u]]=void 0;else throw new Error(`"${o}" does not match the given regex: ${n.toString()}`)}else if(!e.skipInvalidInput)throw new Error(`Trying to match a non-string field. Encountered type: ${typeof o}, field content: "${o}".`);this._propagate(a)}}}class zB extends Xe{get behavior(){return fr}constructor(e){super();const n=Jt(e.columnRegex).map(h=>new RegExp(h)),r=Jt(e.asValue);if(n.length!=r.length)throw new Error('Lengths of "columnRegex" and "as" are not equal!');const i=e.skipRegex?new RegExp(e.skipRegex):void 0,a=e.asKey||"sample";let o,s,u;const l=h=>{var y;const d=Object.keys(h),p=new Map;for(const[w,A]of n.entries())for(const C of d){const E=(y=A.exec(C))==null?void 0:y[1];if(E!==void 0){let k=p.get(E);k||(k=[],p.set(E,k)),k[w]=C}}o=[...p.entries()],s=d.filter(w=>!n.some(A=>A.test(w))&&!(i&&i.test(w)));const m=[...s.map(w=>JSON.stringify(w)+": datum["+JSON.stringify(w)+"]"),JSON.stringify(a)+": sampleId",...r.map(w=>JSON.stringify(w)+": null")];u=new Function("datum","sampleId",`return { -`+m.join(`, -`)+` -};`)},f=h=>{o||l(h);for(const[d,p]of o){const m=u(h,d);for(let y=0;y<p.length;y++)m[r[y]]=h[p[y]];this._propagate(m)}},c=h=>{l(h),f(h),this.handle=f};this.handle=c,this.beginBatch=h=>{Fv(h)&&(this.handle=c),super.beginBatch(h)}}}class UB extends Xe{get behavior(){return Si}constructor(e){super(),this.params=e,this.buffer=[]}reset(){this.buffer=[]}handle(e){this.buffer.push(e)}complete(){const e=this.params,n=e.as||["y0","y1"],r=e.sort?Mw(e.sort.field,e.sort.order):void 0,i=e.field?De(e.field):()=>1,a=e.groupby.map(f=>De(f)),o=U3(this.buffer,f=>a.map(c=>c(f)).join()).map(f=>f[1]);let s=f=>!0;if(e.baseField){const f=De(e.baseField);s=c=>f(c)!==null}let u,l;switch(e.offset){case"normalize":u=(f,c)=>f/c,l=(f,c)=>cu(f,c);break;case"center":u=(f,c)=>f-c/2,l=(f,c)=>cu(f,c);break;case"information":{const f=Math.log2(e.cardinality??4);u=(c,h)=>c/h,l=(c,h)=>{const p=cu(c,A=>+!s(A)),m=cu(c,h),y=m-p;let w=0;for(let A=0;A<c.length;A++){const C=c[A];if(s(C)){const E=h(C)/y;w-=E*Math.log2(E)}}return y/(f-(w+0))*(y/m)}}break;default:u=(f,c)=>f,l=(f,c)=>1}for(const f of o){r&&f.sort(r);const c=l(f,i);let h=0;for(const d of f){const p=h+i(d);s(d)&&(d[n[0]]=u(h,c),d[n[1]]=u(p,c),this._propagate(d),h=p)}}super.complete()}}class qB extends Xe{get behavior(){return fr}constructor(e){super();const n=De(e.field??"sequence"),[r,i]=e.as??["pos","sequence"];this.handle=a=>{const o=Object.assign({},a,{[i]:"",[r]:0}),s=n(a);for(let u=0;u<s.length;u++){const l=Object.assign({},o);l[r]=u,l[i]=s.charAt(u),this._propagate(l)}}}}class VB extends Xe{get behavior(){return fr}constructor(e){super(),this.params=e,this.buffer=[]}reset(){this.buffer=[]}handle(e){this.buffer.push(e)}complete(){const n=this.params.groupby,r=n.map(a=>De(a)),i=rc(this.buffer,...r);for(const[a,o]of sg(i)){const s={count:o.length};for(let u=0;u<n.length;u++)s[n[u]]=a[u];this._propagate(s)}super.complete()}}const HB="_uniqueId",j1=1e4,W1=[null];class Qv extends Xe{get behavior(){return Si}constructor(e){super(),this.params=e,this.as=e.as??HB,this._blocks=[],this._usedBlocks=0,this._id=-1}initialize(){}reset(){super.reset(),this._usedBlocks=0,this._id=-1}handle(e){e[this.as]=this._nextId(),this._propagate(e)}_nextId(){return++this._id%j1==0&&(this._id=this._getBlock()*j1),this._id}_getBlock(){return this._usedBlocks<this._blocks.length?this._blocks[this._usedBlocks++]:this._reserveBlock()}_reserveBlock(){const e=W1.length;return W1[e]=this,this._blocks.push(e),this._usedBlocks++,e}}const GB={aggregate:VB,collect:Xv,coverage:yB,filterScoredLabels:_B,filter:vB,flatten:EB,flattenCompressedExons:CB,flattenDelimited:TB,flattenSequence:qB,formula:IB,identifier:Qv,linearizeGenomicCoordinate:Kv,measureText:$B,pileup:LB,project:MB,regexExtract:PB,regexFold:zB,sample:Iv,stack:UB};function jB(t,e){const n=GB[t.type];if(n)return new n(t,e);throw new Error("Unknown transform: "+t.type)}function e2(t){if(!n2(t)&&!Z1(t))return;const e={...t.format};if(e.type??(e.type=Z1(t)&&WB(t.url)),e.parse??(e.parse="auto"),!e.type)throw new Error("Format for the data source was not defined and it could not be inferred: "+JSON.stringify(t));return e}function WB(t){var e;if(Array.isArray(t)&&(t=t[0]),t)return(e=t.match(/\.(csv|tsv|json)/))==null?void 0:e[1]}const t2=t=>typeof t!="object"?ZB:YB,ZB=t=>({data:t}),YB=t=>t;function Z1(t){return"url"in t}class jl extends Xe{get identifier(){}handle(e){throw new Error("Source does not handle incoming data!")}async load(){}}function n2(t){return"values"in t}class XB extends jl{constructor(e,n){var r;if(super(),this.params=e,typeof e.values=="string"&&!((r=e==null?void 0:e.format)!=null&&r.type))throw new Error("Data format type (csv, dsv, ...) must be specified if a string is provided!")}loadSynchronously(){const e=this.params.values;let n=[],r=i=>i;if(Array.isArray(e))e.length>0&&(n=e,r=t2(e[0]));else if(typeof e=="object")n=[e];else if(typeof e=="string")n=ux(e,e2(this.params));else throw new Error('"values" in data configuration is not an array, object, or a string!');this.reset(),this.beginBatch({type:"file"});for(const i of n)this._propagate(r(i));this.complete()}async load(){this.loadSynchronously()}}function KB(t){return"url"in t}class JB extends jl{constructor(e,n){super(),this.params=e,this.baseUrl=n==null?void 0:n.getBaseUrl()}get identifier(){return JSON.stringify({params:this.params,baseUrl:this.baseUrl})}async load(){const e=this.params.url,n=Array.isArray(e)?e:[e],r=async a=>fc({baseURL:this.baseUrl}).load(a).catch(o=>{throw new Error(`Cannot fetch: ${this.baseUrl}${a}: ${o.message}`)}),i=(a,o)=>{try{const s=ux(a,e2(this.params));this.beginBatch({type:"file",url:o});for(const u of s)this._propagate(u)}catch(s){throw new Error(`Cannot parse: ${o}: ${s.message}`)}};this.reset(),await Promise.all(n.map(a=>r(a).then(i))),this.complete()}}function QB(t){return"sequence"in t}class e5 extends jl{constructor(e,n){if(super(),this.sequence=e.sequence,!("start"in this.sequence))throw new Error("'start' is missing from sequence parameters!");if(!("stop"in this.sequence))throw new Error("'stop' is missing from sequence parameters!")}loadSynchronously(){const e=this.sequence.as||"data",n=this.sequence.step||1,r=this.sequence.stop;this.reset(),this.beginBatch({type:"file"});for(let i=this.sequence.start;i<r;i+=n)this._propagate({[e]:i});this.complete()}async load(){this.loadSynchronously()}}function t5(t,e,n){return n=(n-t)/(e-t),n=Math.max(0,Math.min(1,n)),n*n*(3-2*n)}class wa extends jl{constructor(e,n){if(super(),this.view=e,n){if(n!=="x"&&n!=="y")throw new Error(`Invalid channel specified for the dynamic data source: ${n}. Must be either "x" or "y"`)}else throw new Error('No channel has been specified for the dynamic data source. Must be either "x" or "y".');if(this.channel=n,this.scaleResolution=this.view.getScaleResolution(n),!this.scaleResolution){const i=[`The dynamic data source cannot find a resolved scale for channel "${n}".`];throw this.view instanceof Ct||i.push('Make sure the view has a "shared" scale resolution as it is not a unit view.'),new Error(i.join(" "))}const r=()=>{this.view.isVisible()&&this.onDomainChanged(this.scaleResolution.getDomain(),this.scaleResolution.getComplexDomain())};this.scaleResolution.addEventListener("domain",r),this.view.context.addBroadcastListener("layoutComputed",r)}getAxisLength(){const e=this.scaleResolution.members.map(n=>{var r;return(r=n.view.coords)==null?void 0:r[this.channel==="x"?"width":"height"]}).filter(n=>n>0);return e.length?e.reduce((n,r)=>Math.min(n,r),1e4):0}get genome(){return this.scaleResolution.getGenome()}async onDomainChanged(e,n){}requestRender(){this.view.context.animator.requestRender()}async load(){this.reset(),this.complete()}publishData(e){this.reset(),this.beginBatch({type:"file"});for(const n of e)this._propagate(n);this.complete(),v0(this.view),this.requestRender()}}class n5 extends wa{constructor(n,r){const i={axis:{},...n};super(r,i.channel);Gt(this,"ticks",[]);this.params=n}async onDomainChanged(){const n=this.scaleResolution.getScale(),r=this.params.axis,i=this.getAxisLength(),a=l=>25+60*t5(100,700,l),o=Vt(r.tickCount)?r.tickCount:Math.round(i/a(i)),s=$v(n,o,r.tickMinStep),u=r.values?Ov(n,r.values,s):BD(n,s);if(!uf(u,this.ticks)){this.ticks=u;const l=$D(n,o,r.format);this.publishData(u.map(f=>({value:f,label:l(f)})))}}}class r5 extends wa{constructor(e,n){super(n,e.channel)}async load(){this.publishData(this.genome.chromosomes)}}var Qt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function xa(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function i5(t){if(t.__esModule)return t;var e=t.default;if(typeof e=="function"){var n=function r(){return this instanceof r?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};n.prototype=e.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(t).forEach(function(r){var i=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(n,r,i.get?i:{enumerable:!0,get:function(){return t[r]}})}),n}var Je={},Mc={};Mc.byteLength=s5;Mc.toByteArray=u5;Mc.fromByteArray=h5;var Yn=[],rn=[],a5=typeof Uint8Array<"u"?Uint8Array:Array,Fh="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var Da=0,o5=Fh.length;Da<o5;++Da)Yn[Da]=Fh[Da],rn[Fh.charCodeAt(Da)]=Da;rn["-".charCodeAt(0)]=62;rn["_".charCodeAt(0)]=63;function r2(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=t.indexOf("=");n===-1&&(n=e);var r=n===e?0:4-n%4;return[n,r]}function s5(t){var e=r2(t),n=e[0],r=e[1];return(n+r)*3/4-r}function l5(t,e,n){return(e+n)*3/4-n}function u5(t){var e,n=r2(t),r=n[0],i=n[1],a=new a5(l5(t,r,i)),o=0,s=i>0?r-4:r,u;for(u=0;u<s;u+=4)e=rn[t.charCodeAt(u)]<<18|rn[t.charCodeAt(u+1)]<<12|rn[t.charCodeAt(u+2)]<<6|rn[t.charCodeAt(u+3)],a[o++]=e>>16&255,a[o++]=e>>8&255,a[o++]=e&255;return i===2&&(e=rn[t.charCodeAt(u)]<<2|rn[t.charCodeAt(u+1)]>>4,a[o++]=e&255),i===1&&(e=rn[t.charCodeAt(u)]<<10|rn[t.charCodeAt(u+1)]<<4|rn[t.charCodeAt(u+2)]>>2,a[o++]=e>>8&255,a[o++]=e&255),a}function f5(t){return Yn[t>>18&63]+Yn[t>>12&63]+Yn[t>>6&63]+Yn[t&63]}function c5(t,e,n){for(var r,i=[],a=e;a<n;a+=3)r=(t[a]<<16&16711680)+(t[a+1]<<8&65280)+(t[a+2]&255),i.push(f5(r));return i.join("")}function h5(t){for(var e,n=t.length,r=n%3,i=[],a=16383,o=0,s=n-r;o<s;o+=a)i.push(c5(t,o,o+a>s?s:o+a));return r===1?(e=t[n-1],i.push(Yn[e>>2]+Yn[e<<4&63]+"==")):r===2&&(e=(t[n-2]<<8)+t[n-1],i.push(Yn[e>>10]+Yn[e>>4&63]+Yn[e<<2&63]+"=")),i.join("")}var lg={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */lg.read=function(t,e,n,r,i){var a,o,s=i*8-r-1,u=(1<<s)-1,l=u>>1,f=-7,c=n?i-1:0,h=n?-1:1,d=t[e+c];for(c+=h,a=d&(1<<-f)-1,d>>=-f,f+=s;f>0;a=a*256+t[e+c],c+=h,f-=8);for(o=a&(1<<-f)-1,a>>=-f,f+=r;f>0;o=o*256+t[e+c],c+=h,f-=8);if(a===0)a=1-l;else{if(a===u)return o?NaN:(d?-1:1)*(1/0);o=o+Math.pow(2,r),a=a-l}return(d?-1:1)*o*Math.pow(2,a-r)};lg.write=function(t,e,n,r,i,a){var o,s,u,l=a*8-i-1,f=(1<<l)-1,c=f>>1,h=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,d=r?0:a-1,p=r?1:-1,m=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,o=f):(o=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-o))<1&&(o--,u*=2),o+c>=1?e+=h/u:e+=h*Math.pow(2,1-c),e*u>=2&&(o++,u/=2),o+c>=f?(s=0,o=f):o+c>=1?(s=(e*u-1)*Math.pow(2,i),o=o+c):(s=e*Math.pow(2,c-1)*Math.pow(2,i),o=0));i>=8;t[n+d]=s&255,d+=p,s/=256,i-=8);for(o=o<<i|s,l+=i;l>0;t[n+d]=o&255,d+=p,o/=256,l-=8);t[n+d-p]|=m*128};/*! - * The buffer module from node.js, for the browser. - * - * @author Feross Aboukhadijeh <https://feross.org> - * @license MIT - */(function(t){const e=Mc,n=lg,r=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=s,t.SlowBuffer=A,t.INSPECT_MAX_BYTES=50;const i=2147483647;t.kMaxLength=i,s.TYPED_ARRAY_SUPPORT=a(),!s.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function a(){try{const x=new Uint8Array(1),g={foo:function(){return 42}};return Object.setPrototypeOf(g,Uint8Array.prototype),Object.setPrototypeOf(x,g),x.foo()===42}catch{return!1}}Object.defineProperty(s.prototype,"parent",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.buffer}}),Object.defineProperty(s.prototype,"offset",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.byteOffset}});function o(x){if(x>i)throw new RangeError('The value "'+x+'" is invalid for option "size"');const g=new Uint8Array(x);return Object.setPrototypeOf(g,s.prototype),g}function s(x,g,b){if(typeof x=="number"){if(typeof g=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return c(x)}return u(x,g,b)}s.poolSize=8192;function u(x,g,b){if(typeof x=="string")return h(x,g);if(ArrayBuffer.isView(x))return p(x);if(x==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof x);if(mt(x,ArrayBuffer)||x&&mt(x.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(mt(x,SharedArrayBuffer)||x&&mt(x.buffer,SharedArrayBuffer)))return m(x,g,b);if(typeof x=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const F=x.valueOf&&x.valueOf();if(F!=null&&F!==x)return s.from(F,g,b);const $=y(x);if($)return $;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof x[Symbol.toPrimitive]=="function")return s.from(x[Symbol.toPrimitive]("string"),g,b);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof x)}s.from=function(x,g,b){return u(x,g,b)},Object.setPrototypeOf(s.prototype,Uint8Array.prototype),Object.setPrototypeOf(s,Uint8Array);function l(x){if(typeof x!="number")throw new TypeError('"size" argument must be of type number');if(x<0)throw new RangeError('The value "'+x+'" is invalid for option "size"')}function f(x,g,b){return l(x),x<=0?o(x):g!==void 0?typeof b=="string"?o(x).fill(g,b):o(x).fill(g):o(x)}s.alloc=function(x,g,b){return f(x,g,b)};function c(x){return l(x),o(x<0?0:w(x)|0)}s.allocUnsafe=function(x){return c(x)},s.allocUnsafeSlow=function(x){return c(x)};function h(x,g){if((typeof g!="string"||g==="")&&(g="utf8"),!s.isEncoding(g))throw new TypeError("Unknown encoding: "+g);const b=C(x,g)|0;let F=o(b);const $=F.write(x,g);return $!==b&&(F=F.slice(0,$)),F}function d(x){const g=x.length<0?0:w(x.length)|0,b=o(g);for(let F=0;F<g;F+=1)b[F]=x[F]&255;return b}function p(x){if(mt(x,Uint8Array)){const g=new Uint8Array(x);return m(g.buffer,g.byteOffset,g.byteLength)}return d(x)}function m(x,g,b){if(g<0||x.byteLength<g)throw new RangeError('"offset" is outside of buffer bounds');if(x.byteLength<g+(b||0))throw new RangeError('"length" is outside of buffer bounds');let F;return g===void 0&&b===void 0?F=new Uint8Array(x):b===void 0?F=new Uint8Array(x,g):F=new Uint8Array(x,g,b),Object.setPrototypeOf(F,s.prototype),F}function y(x){if(s.isBuffer(x)){const g=w(x.length)|0,b=o(g);return b.length===0||x.copy(b,0,0,g),b}if(x.length!==void 0)return typeof x.length!="number"||hr(x.length)?o(0):d(x);if(x.type==="Buffer"&&Array.isArray(x.data))return d(x.data)}function w(x){if(x>=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return x|0}function A(x){return+x!=x&&(x=0),s.alloc(+x)}s.isBuffer=function(g){return g!=null&&g._isBuffer===!0&&g!==s.prototype},s.compare=function(g,b){if(mt(g,Uint8Array)&&(g=s.from(g,g.offset,g.byteLength)),mt(b,Uint8Array)&&(b=s.from(b,b.offset,b.byteLength)),!s.isBuffer(g)||!s.isBuffer(b))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(g===b)return 0;let F=g.length,$=b.length;for(let P=0,V=Math.min(F,$);P<V;++P)if(g[P]!==b[P]){F=g[P],$=b[P];break}return F<$?-1:$<F?1:0},s.isEncoding=function(g){switch(String(g).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}},s.concat=function(g,b){if(!Array.isArray(g))throw new TypeError('"list" argument must be an Array of Buffers');if(g.length===0)return s.alloc(0);let F;if(b===void 0)for(b=0,F=0;F<g.length;++F)b+=g[F].length;const $=s.allocUnsafe(b);let P=0;for(F=0;F<g.length;++F){let V=g[F];if(mt(V,Uint8Array))P+V.length>$.length?(s.isBuffer(V)||(V=s.from(V)),V.copy($,P)):Uint8Array.prototype.set.call($,V,P);else if(s.isBuffer(V))V.copy($,P);else throw new TypeError('"list" argument must be an Array of Buffers');P+=V.length}return $};function C(x,g){if(s.isBuffer(x))return x.length;if(ArrayBuffer.isView(x)||mt(x,ArrayBuffer))return x.byteLength;if(typeof x!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof x);const b=x.length,F=arguments.length>2&&arguments[2]===!0;if(!F&&b===0)return 0;let $=!1;for(;;)switch(g){case"ascii":case"latin1":case"binary":return b;case"utf8":case"utf-8":return fe(x).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return b*2;case"hex":return b>>>1;case"base64":return Mr(x).length;default:if($)return F?-1:fe(x).length;g=(""+g).toLowerCase(),$=!0}}s.byteLength=C;function E(x,g,b){let F=!1;if((g===void 0||g<0)&&(g=0),g>this.length||((b===void 0||b>this.length)&&(b=this.length),b<=0)||(b>>>=0,g>>>=0,b<=g))return"";for(x||(x="utf8");;)switch(x){case"hex":return Ze(this,g,b);case"utf8":case"utf-8":return Q(this,g,b);case"ascii":return Se(this,g,b);case"latin1":case"binary":return Ke(this,g,b);case"base64":return ee(this,g,b);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Mn(this,g,b);default:if(F)throw new TypeError("Unknown encoding: "+x);x=(x+"").toLowerCase(),F=!0}}s.prototype._isBuffer=!0;function k(x,g,b){const F=x[g];x[g]=x[b],x[b]=F}s.prototype.swap16=function(){const g=this.length;if(g%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let b=0;b<g;b+=2)k(this,b,b+1);return this},s.prototype.swap32=function(){const g=this.length;if(g%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let b=0;b<g;b+=4)k(this,b,b+3),k(this,b+1,b+2);return this},s.prototype.swap64=function(){const g=this.length;if(g%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let b=0;b<g;b+=8)k(this,b,b+7),k(this,b+1,b+6),k(this,b+2,b+5),k(this,b+3,b+4);return this},s.prototype.toString=function(){const g=this.length;return g===0?"":arguments.length===0?Q(this,0,g):E.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(g){if(!s.isBuffer(g))throw new TypeError("Argument must be a Buffer");return this===g?!0:s.compare(this,g)===0},s.prototype.inspect=function(){let g="";const b=t.INSPECT_MAX_BYTES;return g=this.toString("hex",0,b).replace(/(.{2})/g,"$1 ").trim(),this.length>b&&(g+=" ... "),"<Buffer "+g+">"},r&&(s.prototype[r]=s.prototype.inspect),s.prototype.compare=function(g,b,F,$,P){if(mt(g,Uint8Array)&&(g=s.from(g,g.offset,g.byteLength)),!s.isBuffer(g))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof g);if(b===void 0&&(b=0),F===void 0&&(F=g?g.length:0),$===void 0&&($=0),P===void 0&&(P=this.length),b<0||F>g.length||$<0||P>this.length)throw new RangeError("out of range index");if($>=P&&b>=F)return 0;if($>=P)return-1;if(b>=F)return 1;if(b>>>=0,F>>>=0,$>>>=0,P>>>=0,this===g)return 0;let V=P-$,ce=F-b;const Oe=Math.min(V,ce),Re=this.slice($,P),ze=g.slice(b,F);for(let Ee=0;Ee<Oe;++Ee)if(Re[Ee]!==ze[Ee]){V=Re[Ee],ce=ze[Ee];break}return V<ce?-1:ce<V?1:0};function R(x,g,b,F,$){if(x.length===0)return-1;if(typeof b=="string"?(F=b,b=0):b>2147483647?b=2147483647:b<-2147483648&&(b=-2147483648),b=+b,hr(b)&&(b=$?0:x.length-1),b<0&&(b=x.length+b),b>=x.length){if($)return-1;b=x.length-1}else if(b<0)if($)b=0;else return-1;if(typeof g=="string"&&(g=s.from(g,F)),s.isBuffer(g))return g.length===0?-1:I(x,g,b,F,$);if(typeof g=="number")return g=g&255,typeof Uint8Array.prototype.indexOf=="function"?$?Uint8Array.prototype.indexOf.call(x,g,b):Uint8Array.prototype.lastIndexOf.call(x,g,b):I(x,[g],b,F,$);throw new TypeError("val must be string, number or Buffer")}function I(x,g,b,F,$){let P=1,V=x.length,ce=g.length;if(F!==void 0&&(F=String(F).toLowerCase(),F==="ucs2"||F==="ucs-2"||F==="utf16le"||F==="utf-16le")){if(x.length<2||g.length<2)return-1;P=2,V/=2,ce/=2,b/=2}function Oe(ze,Ee){return P===1?ze[Ee]:ze.readUInt16BE(Ee*P)}let Re;if($){let ze=-1;for(Re=b;Re<V;Re++)if(Oe(x,Re)===Oe(g,ze===-1?0:Re-ze)){if(ze===-1&&(ze=Re),Re-ze+1===ce)return ze*P}else ze!==-1&&(Re-=Re-ze),ze=-1}else for(b+ce>V&&(b=V-ce),Re=b;Re>=0;Re--){let ze=!0;for(let Ee=0;Ee<ce;Ee++)if(Oe(x,Re+Ee)!==Oe(g,Ee)){ze=!1;break}if(ze)return Re}return-1}s.prototype.includes=function(g,b,F){return this.indexOf(g,b,F)!==-1},s.prototype.indexOf=function(g,b,F){return R(this,g,b,F,!0)},s.prototype.lastIndexOf=function(g,b,F){return R(this,g,b,F,!1)};function O(x,g,b,F){b=Number(b)||0;const $=x.length-b;F?(F=Number(F),F>$&&(F=$)):F=$;const P=g.length;F>P/2&&(F=P/2);let V;for(V=0;V<F;++V){const ce=parseInt(g.substr(V*2,2),16);if(hr(ce))return V;x[b+V]=ce}return V}function T(x,g,b,F){return Pr(fe(g,x.length-b),x,b,F)}function B(x,g,b,F){return Pr(Rt(g),x,b,F)}function N(x,g,b,F){return Pr(Mr(g),x,b,F)}function J(x,g,b,F){return Pr(Lr(g,x.length-b),x,b,F)}s.prototype.write=function(g,b,F,$){if(b===void 0)$="utf8",F=this.length,b=0;else if(F===void 0&&typeof b=="string")$=b,F=this.length,b=0;else if(isFinite(b))b=b>>>0,isFinite(F)?(F=F>>>0,$===void 0&&($="utf8")):($=F,F=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const P=this.length-b;if((F===void 0||F>P)&&(F=P),g.length>0&&(F<0||b<0)||b>this.length)throw new RangeError("Attempt to write outside buffer bounds");$||($="utf8");let V=!1;for(;;)switch($){case"hex":return O(this,g,b,F);case"utf8":case"utf-8":return T(this,g,b,F);case"ascii":case"latin1":case"binary":return B(this,g,b,F);case"base64":return N(this,g,b,F);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return J(this,g,b,F);default:if(V)throw new TypeError("Unknown encoding: "+$);$=(""+$).toLowerCase(),V=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function ee(x,g,b){return g===0&&b===x.length?e.fromByteArray(x):e.fromByteArray(x.slice(g,b))}function Q(x,g,b){b=Math.min(x.length,b);const F=[];let $=g;for(;$<b;){const P=x[$];let V=null,ce=P>239?4:P>223?3:P>191?2:1;if($+ce<=b){let Oe,Re,ze,Ee;switch(ce){case 1:P<128&&(V=P);break;case 2:Oe=x[$+1],(Oe&192)===128&&(Ee=(P&31)<<6|Oe&63,Ee>127&&(V=Ee));break;case 3:Oe=x[$+1],Re=x[$+2],(Oe&192)===128&&(Re&192)===128&&(Ee=(P&15)<<12|(Oe&63)<<6|Re&63,Ee>2047&&(Ee<55296||Ee>57343)&&(V=Ee));break;case 4:Oe=x[$+1],Re=x[$+2],ze=x[$+3],(Oe&192)===128&&(Re&192)===128&&(ze&192)===128&&(Ee=(P&15)<<18|(Oe&63)<<12|(Re&63)<<6|ze&63,Ee>65535&&Ee<1114112&&(V=Ee))}}V===null?(V=65533,ce=1):V>65535&&(V-=65536,F.push(V>>>10&1023|55296),V=56320|V&1023),F.push(V),$+=ce}return be(F)}const he=4096;function be(x){const g=x.length;if(g<=he)return String.fromCharCode.apply(String,x);let b="",F=0;for(;F<g;)b+=String.fromCharCode.apply(String,x.slice(F,F+=he));return b}function Se(x,g,b){let F="";b=Math.min(x.length,b);for(let $=g;$<b;++$)F+=String.fromCharCode(x[$]&127);return F}function Ke(x,g,b){let F="";b=Math.min(x.length,b);for(let $=g;$<b;++$)F+=String.fromCharCode(x[$]);return F}function Ze(x,g,b){const F=x.length;(!g||g<0)&&(g=0),(!b||b<0||b>F)&&(b=F);let $="";for(let P=g;P<b;++P)$+=zr[x[P]];return $}function Mn(x,g,b){const F=x.slice(g,b);let $="";for(let P=0;P<F.length-1;P+=2)$+=String.fromCharCode(F[P]+F[P+1]*256);return $}s.prototype.slice=function(g,b){const F=this.length;g=~~g,b=b===void 0?F:~~b,g<0?(g+=F,g<0&&(g=0)):g>F&&(g=F),b<0?(b+=F,b<0&&(b=0)):b>F&&(b=F),b<g&&(b=g);const $=this.subarray(g,b);return Object.setPrototypeOf($,s.prototype),$};function ke(x,g,b){if(x%1!==0||x<0)throw new RangeError("offset is not uint");if(x+g>b)throw new RangeError("Trying to access beyond buffer length")}s.prototype.readUintLE=s.prototype.readUIntLE=function(g,b,F){g=g>>>0,b=b>>>0,F||ke(g,b,this.length);let $=this[g],P=1,V=0;for(;++V<b&&(P*=256);)$+=this[g+V]*P;return $},s.prototype.readUintBE=s.prototype.readUIntBE=function(g,b,F){g=g>>>0,b=b>>>0,F||ke(g,b,this.length);let $=this[g+--b],P=1;for(;b>0&&(P*=256);)$+=this[g+--b]*P;return $},s.prototype.readUint8=s.prototype.readUInt8=function(g,b){return g=g>>>0,b||ke(g,1,this.length),this[g]},s.prototype.readUint16LE=s.prototype.readUInt16LE=function(g,b){return g=g>>>0,b||ke(g,2,this.length),this[g]|this[g+1]<<8},s.prototype.readUint16BE=s.prototype.readUInt16BE=function(g,b){return g=g>>>0,b||ke(g,2,this.length),this[g]<<8|this[g+1]},s.prototype.readUint32LE=s.prototype.readUInt32LE=function(g,b){return g=g>>>0,b||ke(g,4,this.length),(this[g]|this[g+1]<<8|this[g+2]<<16)+this[g+3]*16777216},s.prototype.readUint32BE=s.prototype.readUInt32BE=function(g,b){return g=g>>>0,b||ke(g,4,this.length),this[g]*16777216+(this[g+1]<<16|this[g+2]<<8|this[g+3])},s.prototype.readBigUInt64LE=Dt(function(g){g=g>>>0,q(g,"offset");const b=this[g],F=this[g+7];(b===void 0||F===void 0)&&G(g,this.length-8);const $=b+this[++g]*2**8+this[++g]*2**16+this[++g]*2**24,P=this[++g]+this[++g]*2**8+this[++g]*2**16+F*2**24;return BigInt($)+(BigInt(P)<<BigInt(32))}),s.prototype.readBigUInt64BE=Dt(function(g){g=g>>>0,q(g,"offset");const b=this[g],F=this[g+7];(b===void 0||F===void 0)&&G(g,this.length-8);const $=b*2**24+this[++g]*2**16+this[++g]*2**8+this[++g],P=this[++g]*2**24+this[++g]*2**16+this[++g]*2**8+F;return(BigInt($)<<BigInt(32))+BigInt(P)}),s.prototype.readIntLE=function(g,b,F){g=g>>>0,b=b>>>0,F||ke(g,b,this.length);let $=this[g],P=1,V=0;for(;++V<b&&(P*=256);)$+=this[g+V]*P;return P*=128,$>=P&&($-=Math.pow(2,8*b)),$},s.prototype.readIntBE=function(g,b,F){g=g>>>0,b=b>>>0,F||ke(g,b,this.length);let $=b,P=1,V=this[g+--$];for(;$>0&&(P*=256);)V+=this[g+--$]*P;return P*=128,V>=P&&(V-=Math.pow(2,8*b)),V},s.prototype.readInt8=function(g,b){return g=g>>>0,b||ke(g,1,this.length),this[g]&128?(255-this[g]+1)*-1:this[g]},s.prototype.readInt16LE=function(g,b){g=g>>>0,b||ke(g,2,this.length);const F=this[g]|this[g+1]<<8;return F&32768?F|4294901760:F},s.prototype.readInt16BE=function(g,b){g=g>>>0,b||ke(g,2,this.length);const F=this[g+1]|this[g]<<8;return F&32768?F|4294901760:F},s.prototype.readInt32LE=function(g,b){return g=g>>>0,b||ke(g,4,this.length),this[g]|this[g+1]<<8|this[g+2]<<16|this[g+3]<<24},s.prototype.readInt32BE=function(g,b){return g=g>>>0,b||ke(g,4,this.length),this[g]<<24|this[g+1]<<16|this[g+2]<<8|this[g+3]},s.prototype.readBigInt64LE=Dt(function(g){g=g>>>0,q(g,"offset");const b=this[g],F=this[g+7];(b===void 0||F===void 0)&&G(g,this.length-8);const $=this[g+4]+this[g+5]*2**8+this[g+6]*2**16+(F<<24);return(BigInt($)<<BigInt(32))+BigInt(b+this[++g]*2**8+this[++g]*2**16+this[++g]*2**24)}),s.prototype.readBigInt64BE=Dt(function(g){g=g>>>0,q(g,"offset");const b=this[g],F=this[g+7];(b===void 0||F===void 0)&&G(g,this.length-8);const $=(b<<24)+this[++g]*2**16+this[++g]*2**8+this[++g];return(BigInt($)<<BigInt(32))+BigInt(this[++g]*2**24+this[++g]*2**16+this[++g]*2**8+F)}),s.prototype.readFloatLE=function(g,b){return g=g>>>0,b||ke(g,4,this.length),n.read(this,g,!0,23,4)},s.prototype.readFloatBE=function(g,b){return g=g>>>0,b||ke(g,4,this.length),n.read(this,g,!1,23,4)},s.prototype.readDoubleLE=function(g,b){return g=g>>>0,b||ke(g,8,this.length),n.read(this,g,!0,52,8)},s.prototype.readDoubleBE=function(g,b){return g=g>>>0,b||ke(g,8,this.length),n.read(this,g,!1,52,8)};function Pe(x,g,b,F,$,P){if(!s.isBuffer(x))throw new TypeError('"buffer" argument must be a Buffer instance');if(g>$||g<P)throw new RangeError('"value" argument is out of bounds');if(b+F>x.length)throw new RangeError("Index out of range")}s.prototype.writeUintLE=s.prototype.writeUIntLE=function(g,b,F,$){if(g=+g,b=b>>>0,F=F>>>0,!$){const ce=Math.pow(2,8*F)-1;Pe(this,g,b,F,ce,0)}let P=1,V=0;for(this[b]=g&255;++V<F&&(P*=256);)this[b+V]=g/P&255;return b+F},s.prototype.writeUintBE=s.prototype.writeUIntBE=function(g,b,F,$){if(g=+g,b=b>>>0,F=F>>>0,!$){const ce=Math.pow(2,8*F)-1;Pe(this,g,b,F,ce,0)}let P=F-1,V=1;for(this[b+P]=g&255;--P>=0&&(V*=256);)this[b+P]=g/V&255;return b+F},s.prototype.writeUint8=s.prototype.writeUInt8=function(g,b,F){return g=+g,b=b>>>0,F||Pe(this,g,b,1,255,0),this[b]=g&255,b+1},s.prototype.writeUint16LE=s.prototype.writeUInt16LE=function(g,b,F){return g=+g,b=b>>>0,F||Pe(this,g,b,2,65535,0),this[b]=g&255,this[b+1]=g>>>8,b+2},s.prototype.writeUint16BE=s.prototype.writeUInt16BE=function(g,b,F){return g=+g,b=b>>>0,F||Pe(this,g,b,2,65535,0),this[b]=g>>>8,this[b+1]=g&255,b+2},s.prototype.writeUint32LE=s.prototype.writeUInt32LE=function(g,b,F){return g=+g,b=b>>>0,F||Pe(this,g,b,4,4294967295,0),this[b+3]=g>>>24,this[b+2]=g>>>16,this[b+1]=g>>>8,this[b]=g&255,b+4},s.prototype.writeUint32BE=s.prototype.writeUInt32BE=function(g,b,F){return g=+g,b=b>>>0,F||Pe(this,g,b,4,4294967295,0),this[b]=g>>>24,this[b+1]=g>>>16,this[b+2]=g>>>8,this[b+3]=g&255,b+4};function kt(x,g,b,F,$){_(g,F,$,x,b,7);let P=Number(g&BigInt(4294967295));x[b++]=P,P=P>>8,x[b++]=P,P=P>>8,x[b++]=P,P=P>>8,x[b++]=P;let V=Number(g>>BigInt(32)&BigInt(4294967295));return x[b++]=V,V=V>>8,x[b++]=V,V=V>>8,x[b++]=V,V=V>>8,x[b++]=V,b}function xn(x,g,b,F,$){_(g,F,$,x,b,7);let P=Number(g&BigInt(4294967295));x[b+7]=P,P=P>>8,x[b+6]=P,P=P>>8,x[b+5]=P,P=P>>8,x[b+4]=P;let V=Number(g>>BigInt(32)&BigInt(4294967295));return x[b+3]=V,V=V>>8,x[b+2]=V,V=V>>8,x[b+1]=V,V=V>>8,x[b]=V,b+8}s.prototype.writeBigUInt64LE=Dt(function(g,b=0){return kt(this,g,b,BigInt(0),BigInt("0xffffffffffffffff"))}),s.prototype.writeBigUInt64BE=Dt(function(g,b=0){return xn(this,g,b,BigInt(0),BigInt("0xffffffffffffffff"))}),s.prototype.writeIntLE=function(g,b,F,$){if(g=+g,b=b>>>0,!$){const Oe=Math.pow(2,8*F-1);Pe(this,g,b,F,Oe-1,-Oe)}let P=0,V=1,ce=0;for(this[b]=g&255;++P<F&&(V*=256);)g<0&&ce===0&&this[b+P-1]!==0&&(ce=1),this[b+P]=(g/V>>0)-ce&255;return b+F},s.prototype.writeIntBE=function(g,b,F,$){if(g=+g,b=b>>>0,!$){const Oe=Math.pow(2,8*F-1);Pe(this,g,b,F,Oe-1,-Oe)}let P=F-1,V=1,ce=0;for(this[b+P]=g&255;--P>=0&&(V*=256);)g<0&&ce===0&&this[b+P+1]!==0&&(ce=1),this[b+P]=(g/V>>0)-ce&255;return b+F},s.prototype.writeInt8=function(g,b,F){return g=+g,b=b>>>0,F||Pe(this,g,b,1,127,-128),g<0&&(g=255+g+1),this[b]=g&255,b+1},s.prototype.writeInt16LE=function(g,b,F){return g=+g,b=b>>>0,F||Pe(this,g,b,2,32767,-32768),this[b]=g&255,this[b+1]=g>>>8,b+2},s.prototype.writeInt16BE=function(g,b,F){return g=+g,b=b>>>0,F||Pe(this,g,b,2,32767,-32768),this[b]=g>>>8,this[b+1]=g&255,b+2},s.prototype.writeInt32LE=function(g,b,F){return g=+g,b=b>>>0,F||Pe(this,g,b,4,2147483647,-2147483648),this[b]=g&255,this[b+1]=g>>>8,this[b+2]=g>>>16,this[b+3]=g>>>24,b+4},s.prototype.writeInt32BE=function(g,b,F){return g=+g,b=b>>>0,F||Pe(this,g,b,4,2147483647,-2147483648),g<0&&(g=4294967295+g+1),this[b]=g>>>24,this[b+1]=g>>>16,this[b+2]=g>>>8,this[b+3]=g&255,b+4},s.prototype.writeBigInt64LE=Dt(function(g,b=0){return kt(this,g,b,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),s.prototype.writeBigInt64BE=Dt(function(g,b=0){return xn(this,g,b,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Pn(x,g,b,F,$,P){if(b+F>x.length)throw new RangeError("Index out of range");if(b<0)throw new RangeError("Index out of range")}function M(x,g,b,F,$){return g=+g,b=b>>>0,$||Pn(x,g,b,4),n.write(x,g,b,F,23,4),b+4}s.prototype.writeFloatLE=function(g,b,F){return M(this,g,b,!0,F)},s.prototype.writeFloatBE=function(g,b,F){return M(this,g,b,!1,F)};function L(x,g,b,F,$){return g=+g,b=b>>>0,$||Pn(x,g,b,8),n.write(x,g,b,F,52,8),b+8}s.prototype.writeDoubleLE=function(g,b,F){return L(this,g,b,!0,F)},s.prototype.writeDoubleBE=function(g,b,F){return L(this,g,b,!1,F)},s.prototype.copy=function(g,b,F,$){if(!s.isBuffer(g))throw new TypeError("argument should be a Buffer");if(F||(F=0),!$&&$!==0&&($=this.length),b>=g.length&&(b=g.length),b||(b=0),$>0&&$<F&&($=F),$===F||g.length===0||this.length===0)return 0;if(b<0)throw new RangeError("targetStart out of bounds");if(F<0||F>=this.length)throw new RangeError("Index out of range");if($<0)throw new RangeError("sourceEnd out of bounds");$>this.length&&($=this.length),g.length-b<$-F&&($=g.length-b+F);const P=$-F;return this===g&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(b,F,$):Uint8Array.prototype.set.call(g,this.subarray(F,$),b),P},s.prototype.fill=function(g,b,F,$){if(typeof g=="string"){if(typeof b=="string"?($=b,b=0,F=this.length):typeof F=="string"&&($=F,F=this.length),$!==void 0&&typeof $!="string")throw new TypeError("encoding must be a string");if(typeof $=="string"&&!s.isEncoding($))throw new TypeError("Unknown encoding: "+$);if(g.length===1){const V=g.charCodeAt(0);($==="utf8"&&V<128||$==="latin1")&&(g=V)}}else typeof g=="number"?g=g&255:typeof g=="boolean"&&(g=Number(g));if(b<0||this.length<b||this.length<F)throw new RangeError("Out of range index");if(F<=b)return this;b=b>>>0,F=F===void 0?this.length:F>>>0,g||(g=0);let P;if(typeof g=="number")for(P=b;P<F;++P)this[P]=g;else{const V=s.isBuffer(g)?g:s.from(g,$),ce=V.length;if(ce===0)throw new TypeError('The value "'+g+'" is invalid for argument "value"');for(P=0;P<F-b;++P)this[P+b]=V[P%ce]}return this};const j={};function H(x,g,b){j[x]=class extends b{constructor(){super(),Object.defineProperty(this,"message",{value:g.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${x}]`,this.stack,delete this.name}get code(){return x}set code($){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:$,writable:!0})}toString(){return`${this.name} [${x}]: ${this.message}`}}}H("ERR_BUFFER_OUT_OF_BOUNDS",function(x){return x?`${x} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),H("ERR_INVALID_ARG_TYPE",function(x,g){return`The "${x}" argument must be of type number. Received type ${typeof g}`},TypeError),H("ERR_OUT_OF_RANGE",function(x,g,b){let F=`The value of "${x}" is out of range.`,$=b;return Number.isInteger(b)&&Math.abs(b)>2**32?$=Y(String(b)):typeof b=="bigint"&&($=String(b),(b>BigInt(2)**BigInt(32)||b<-(BigInt(2)**BigInt(32)))&&($=Y($)),$+="n"),F+=` It must be ${g}. Received ${$}`,F},RangeError);function Y(x){let g="",b=x.length;const F=x[0]==="-"?1:0;for(;b>=F+4;b-=3)g=`_${x.slice(b-3,b)}${g}`;return`${x.slice(0,b)}${g}`}function S(x,g,b){q(g,"offset"),(x[g]===void 0||x[g+b]===void 0)&&G(g,x.length-(b+1))}function _(x,g,b,F,$,P){if(x>b||x<g){const V=typeof g=="bigint"?"n":"";let ce;throw P>3?g===0||g===BigInt(0)?ce=`>= 0${V} and < 2${V} ** ${(P+1)*8}${V}`:ce=`>= -(2${V} ** ${(P+1)*8-1}${V}) and < 2 ** ${(P+1)*8-1}${V}`:ce=`>= ${g}${V} and <= ${b}${V}`,new j.ERR_OUT_OF_RANGE("value",ce,x)}S(F,$,P)}function q(x,g){if(typeof x!="number")throw new j.ERR_INVALID_ARG_TYPE(g,"number",x)}function G(x,g,b){throw Math.floor(x)!==x?(q(x,b),new j.ERR_OUT_OF_RANGE(b||"offset","an integer",x)):g<0?new j.ERR_BUFFER_OUT_OF_BOUNDS:new j.ERR_OUT_OF_RANGE(b||"offset",`>= ${b?1:0} and <= ${g}`,x)}const ue=/[^+/0-9A-Za-z-_]/g;function ne(x){if(x=x.split("=")[0],x=x.trim().replace(ue,""),x.length<2)return"";for(;x.length%4!==0;)x=x+"=";return x}function fe(x,g){g=g||1/0;let b;const F=x.length;let $=null;const P=[];for(let V=0;V<F;++V){if(b=x.charCodeAt(V),b>55295&&b<57344){if(!$){if(b>56319){(g-=3)>-1&&P.push(239,191,189);continue}else if(V+1===F){(g-=3)>-1&&P.push(239,191,189);continue}$=b;continue}if(b<56320){(g-=3)>-1&&P.push(239,191,189),$=b;continue}b=($-55296<<10|b-56320)+65536}else $&&(g-=3)>-1&&P.push(239,191,189);if($=null,b<128){if((g-=1)<0)break;P.push(b)}else if(b<2048){if((g-=2)<0)break;P.push(b>>6|192,b&63|128)}else if(b<65536){if((g-=3)<0)break;P.push(b>>12|224,b>>6&63|128,b&63|128)}else if(b<1114112){if((g-=4)<0)break;P.push(b>>18|240,b>>12&63|128,b>>6&63|128,b&63|128)}else throw new Error("Invalid code point")}return P}function Rt(x){const g=[];for(let b=0;b<x.length;++b)g.push(x.charCodeAt(b)&255);return g}function Lr(x,g){let b,F,$;const P=[];for(let V=0;V<x.length&&!((g-=2)<0);++V)b=x.charCodeAt(V),F=b>>8,$=b%256,P.push($),P.push(F);return P}function Mr(x){return e.toByteArray(ne(x))}function Pr(x,g,b,F){let $;for($=0;$<F&&!($+b>=g.length||$>=x.length);++$)g[$+b]=x[$];return $}function mt(x,g){return x instanceof g||x!=null&&x.constructor!=null&&x.constructor.name!=null&&x.constructor.name===g.name}function hr(x){return x!==x}const zr=function(){const x="0123456789abcdef",g=new Array(256);for(let b=0;b<16;++b){const F=b*16;for(let $=0;$<16;++$)g[F+$]=x[b]+x[$]}return g}();function Dt(x){return typeof BigInt>"u"?zn:x}function zn(){throw new Error("BigInt not supported")}})(Je);const Yt={},d5=Object.freeze(Object.defineProperty({__proto__:null,default:Yt},Symbol.toStringTag,{value:"Module"}));class Qn{async getBufferFromResponse(e){if(typeof e.buffer=="function")return e.buffer();if(typeof e.arrayBuffer=="function"){const n=await e.arrayBuffer();return Je.Buffer.from(n)}else throw new TypeError("invalid HTTP response object, has no buffer method, and no arrayBuffer method")}constructor(e,n={}){this.baseOverrides={},this.url=e;const r=n.fetch||globalThis.fetch.bind(globalThis);if(!r)throw new TypeError("no fetch function supplied, and none found in global environment");n.overrides&&(this.baseOverrides=n.overrides),this.fetchImplementation=r}async fetch(e,n){let r;try{r=await this.fetchImplementation(e,n)}catch(i){if(`${i}`.includes("Failed to fetch"))console.warn(`generic-filehandle: refetching ${e} to attempt to work around chrome CORS header caching bug`),r=await this.fetchImplementation(e,{...n,cache:"reload"});else throw i}return r}async read(e,n=0,r,i=0,a={}){const{headers:o={},signal:s,overrides:u={}}=a;r<1/0?o.range=`bytes=${i}-${i+r}`:r===1/0&&i!==0&&(o.range=`bytes=${i}-`);const l={...this.baseOverrides,...u,headers:{...o,...u.headers,...this.baseOverrides.headers},method:"GET",redirect:"follow",mode:"cors",signal:s},f=await this.fetch(this.url,l);if(!f.ok)throw new Error(`HTTP ${f.status} ${f.statusText} ${this.url}`);if(f.status===200&&i===0||f.status===206){const c=await this.getBufferFromResponse(f),h=c.copy(e,n,0,Math.min(r,c.length)),d=f.headers.get("content-range"),p=/\/(\d+)$/.exec(d||"");return p&&p[1]&&(this._stat={size:parseInt(p[1],10)}),{bytesRead:h,buffer:e}}throw f.status===200?new Error("${this.url} fetch returned status 200, expected 206"):new Error(`HTTP ${f.status} fetching ${this.url}`)}async readFile(e={}){let n,r;typeof e=="string"?(n=e,r={}):(n=e.encoding,r=e,delete r.encoding);const{headers:i={},signal:a,overrides:o={}}=r,s={headers:i,method:"GET",redirect:"follow",mode:"cors",signal:a,...this.baseOverrides,...o},u=await this.fetch(this.url,s);if(!u)throw new Error("generic-filehandle failed to fetch");if(u.status!==200)throw Object.assign(new Error(`HTTP ${u.status} fetching ${this.url}`),{status:u.status});if(n==="utf8")return u.text();if(n)throw new Error(`unsupported encoding: ${n}`);return this.getBufferFromResponse(u)}async stat(){if(!this._stat){const e=Je.Buffer.allocUnsafe(10);if(await this.read(e,0,10,0),!this._stat)throw new Error(`unable to determine size of file at ${this.url}`)}return this._stat}async close(){}}var Or={};(function(t){var e=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";function n(a,o){return Object.prototype.hasOwnProperty.call(a,o)}t.assign=function(a){for(var o=Array.prototype.slice.call(arguments,1);o.length;){var s=o.shift();if(s){if(typeof s!="object")throw new TypeError(s+"must be non-object");for(var u in s)n(s,u)&&(a[u]=s[u])}}return a},t.shrinkBuf=function(a,o){return a.length===o?a:a.subarray?a.subarray(0,o):(a.length=o,a)};var r={arraySet:function(a,o,s,u,l){if(o.subarray&&a.subarray){a.set(o.subarray(s,s+u),l);return}for(var f=0;f<u;f++)a[l+f]=o[s+f]},flattenChunks:function(a){var o,s,u,l,f,c;for(u=0,o=0,s=a.length;o<s;o++)u+=a[o].length;for(c=new Uint8Array(u),l=0,o=0,s=a.length;o<s;o++)f=a[o],c.set(f,l),l+=f.length;return c}},i={arraySet:function(a,o,s,u,l){for(var f=0;f<u;f++)a[l+f]=o[s+f]},flattenChunks:function(a){return[].concat.apply([],a)}};t.setTyped=function(a){a?(t.Buf8=Uint8Array,t.Buf16=Uint16Array,t.Buf32=Int32Array,t.assign(t,r)):(t.Buf8=Array,t.Buf16=Array,t.Buf32=Array,t.assign(t,i))},t.setTyped(e)})(Or);var Wl={},cr={},Lo={},p5=Or,g5=4,Y1=0,X1=1,m5=2;function Mo(t){for(var e=t.length;--e>=0;)t[e]=0}var b5=0,i2=1,y5=2,w5=3,x5=258,ug=29,Zl=256,Qs=Zl+1+ug,Ga=30,fg=19,a2=2*Qs+1,Mi=15,Ih=16,_5=7,cg=256,o2=16,s2=17,l2=18,E0=[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],Uu=[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],v5=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],u2=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],E5=512,_r=new Array((Qs+2)*2);Mo(_r);var ys=new Array(Ga*2);Mo(ys);var el=new Array(E5);Mo(el);var tl=new Array(x5-w5+1);Mo(tl);var hg=new Array(ug);Mo(hg);var Ef=new Array(Ga);Mo(Ef);function kh(t,e,n,r,i){this.static_tree=t,this.extra_bits=e,this.extra_base=n,this.elems=r,this.max_length=i,this.has_stree=t&&t.length}var f2,c2,h2;function Rh(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}function d2(t){return t<256?el[t]:el[256+(t>>>7)]}function nl(t,e){t.pending_buf[t.pending++]=e&255,t.pending_buf[t.pending++]=e>>>8&255}function Mt(t,e,n){t.bi_valid>Ih-n?(t.bi_buf|=e<<t.bi_valid&65535,nl(t,t.bi_buf),t.bi_buf=e>>Ih-t.bi_valid,t.bi_valid+=n-Ih):(t.bi_buf|=e<<t.bi_valid&65535,t.bi_valid+=n)}function Xn(t,e,n){Mt(t,n[e*2],n[e*2+1])}function p2(t,e){var n=0;do n|=t&1,t>>>=1,n<<=1;while(--e>0);return n>>>1}function A5(t){t.bi_valid===16?(nl(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=t.bi_buf&255,t.bi_buf>>=8,t.bi_valid-=8)}function S5(t,e){var n=e.dyn_tree,r=e.max_code,i=e.stat_desc.static_tree,a=e.stat_desc.has_stree,o=e.stat_desc.extra_bits,s=e.stat_desc.extra_base,u=e.stat_desc.max_length,l,f,c,h,d,p,m=0;for(h=0;h<=Mi;h++)t.bl_count[h]=0;for(n[t.heap[t.heap_max]*2+1]=0,l=t.heap_max+1;l<a2;l++)f=t.heap[l],h=n[n[f*2+1]*2+1]+1,h>u&&(h=u,m++),n[f*2+1]=h,!(f>r)&&(t.bl_count[h]++,d=0,f>=s&&(d=o[f-s]),p=n[f*2],t.opt_len+=p*(h+d),a&&(t.static_len+=p*(i[f*2+1]+d)));if(m!==0){do{for(h=u-1;t.bl_count[h]===0;)h--;t.bl_count[h]--,t.bl_count[h+1]+=2,t.bl_count[u]--,m-=2}while(m>0);for(h=u;h!==0;h--)for(f=t.bl_count[h];f!==0;)c=t.heap[--l],!(c>r)&&(n[c*2+1]!==h&&(t.opt_len+=(h-n[c*2+1])*n[c*2],n[c*2+1]=h),f--)}}function g2(t,e,n){var r=new Array(Mi+1),i=0,a,o;for(a=1;a<=Mi;a++)r[a]=i=i+n[a-1]<<1;for(o=0;o<=e;o++){var s=t[o*2+1];s!==0&&(t[o*2]=p2(r[s]++,s))}}function C5(){var t,e,n,r,i,a=new Array(Mi+1);for(n=0,r=0;r<ug-1;r++)for(hg[r]=n,t=0;t<1<<E0[r];t++)tl[n++]=r;for(tl[n-1]=r,i=0,r=0;r<16;r++)for(Ef[r]=i,t=0;t<1<<Uu[r];t++)el[i++]=r;for(i>>=7;r<Ga;r++)for(Ef[r]=i<<7,t=0;t<1<<Uu[r]-7;t++)el[256+i++]=r;for(e=0;e<=Mi;e++)a[e]=0;for(t=0;t<=143;)_r[t*2+1]=8,t++,a[8]++;for(;t<=255;)_r[t*2+1]=9,t++,a[9]++;for(;t<=279;)_r[t*2+1]=7,t++,a[7]++;for(;t<=287;)_r[t*2+1]=8,t++,a[8]++;for(g2(_r,Qs+1,a),t=0;t<Ga;t++)ys[t*2+1]=5,ys[t*2]=p2(t,5);f2=new kh(_r,E0,Zl+1,Qs,Mi),c2=new kh(ys,Uu,0,Ga,Mi),h2=new kh(new Array(0),v5,0,fg,_5)}function m2(t){var e;for(e=0;e<Qs;e++)t.dyn_ltree[e*2]=0;for(e=0;e<Ga;e++)t.dyn_dtree[e*2]=0;for(e=0;e<fg;e++)t.bl_tree[e*2]=0;t.dyn_ltree[cg*2]=1,t.opt_len=t.static_len=0,t.last_lit=t.matches=0}function b2(t){t.bi_valid>8?nl(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0}function T5(t,e,n,r){b2(t),r&&(nl(t,n),nl(t,~n)),p5.arraySet(t.pending_buf,t.window,e,n,t.pending),t.pending+=n}function K1(t,e,n,r){var i=e*2,a=n*2;return t[i]<t[a]||t[i]===t[a]&&r[e]<=r[n]}function Dh(t,e,n){for(var r=t.heap[n],i=n<<1;i<=t.heap_len&&(i<t.heap_len&&K1(e,t.heap[i+1],t.heap[i],t.depth)&&i++,!K1(e,r,t.heap[i],t.depth));)t.heap[n]=t.heap[i],n=i,i<<=1;t.heap[n]=r}function J1(t,e,n){var r,i,a=0,o,s;if(t.last_lit!==0)do r=t.pending_buf[t.d_buf+a*2]<<8|t.pending_buf[t.d_buf+a*2+1],i=t.pending_buf[t.l_buf+a],a++,r===0?Xn(t,i,e):(o=tl[i],Xn(t,o+Zl+1,e),s=E0[o],s!==0&&(i-=hg[o],Mt(t,i,s)),r--,o=d2(r),Xn(t,o,n),s=Uu[o],s!==0&&(r-=Ef[o],Mt(t,r,s)));while(a<t.last_lit);Xn(t,cg,e)}function A0(t,e){var n=e.dyn_tree,r=e.stat_desc.static_tree,i=e.stat_desc.has_stree,a=e.stat_desc.elems,o,s,u=-1,l;for(t.heap_len=0,t.heap_max=a2,o=0;o<a;o++)n[o*2]!==0?(t.heap[++t.heap_len]=u=o,t.depth[o]=0):n[o*2+1]=0;for(;t.heap_len<2;)l=t.heap[++t.heap_len]=u<2?++u:0,n[l*2]=1,t.depth[l]=0,t.opt_len--,i&&(t.static_len-=r[l*2+1]);for(e.max_code=u,o=t.heap_len>>1;o>=1;o--)Dh(t,n,o);l=a;do o=t.heap[1],t.heap[1]=t.heap[t.heap_len--],Dh(t,n,1),s=t.heap[1],t.heap[--t.heap_max]=o,t.heap[--t.heap_max]=s,n[l*2]=n[o*2]+n[s*2],t.depth[l]=(t.depth[o]>=t.depth[s]?t.depth[o]:t.depth[s])+1,n[o*2+1]=n[s*2+1]=l,t.heap[1]=l++,Dh(t,n,1);while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],S5(t,e),g2(n,u,t.bl_count)}function Q1(t,e,n){var r,i=-1,a,o=e[0*2+1],s=0,u=7,l=4;for(o===0&&(u=138,l=3),e[(n+1)*2+1]=65535,r=0;r<=n;r++)a=o,o=e[(r+1)*2+1],!(++s<u&&a===o)&&(s<l?t.bl_tree[a*2]+=s:a!==0?(a!==i&&t.bl_tree[a*2]++,t.bl_tree[o2*2]++):s<=10?t.bl_tree[s2*2]++:t.bl_tree[l2*2]++,s=0,i=a,o===0?(u=138,l=3):a===o?(u=6,l=3):(u=7,l=4))}function eb(t,e,n){var r,i=-1,a,o=e[0*2+1],s=0,u=7,l=4;for(o===0&&(u=138,l=3),r=0;r<=n;r++)if(a=o,o=e[(r+1)*2+1],!(++s<u&&a===o)){if(s<l)do Xn(t,a,t.bl_tree);while(--s!==0);else a!==0?(a!==i&&(Xn(t,a,t.bl_tree),s--),Xn(t,o2,t.bl_tree),Mt(t,s-3,2)):s<=10?(Xn(t,s2,t.bl_tree),Mt(t,s-3,3)):(Xn(t,l2,t.bl_tree),Mt(t,s-11,7));s=0,i=a,o===0?(u=138,l=3):a===o?(u=6,l=3):(u=7,l=4)}}function F5(t){var e;for(Q1(t,t.dyn_ltree,t.l_desc.max_code),Q1(t,t.dyn_dtree,t.d_desc.max_code),A0(t,t.bl_desc),e=fg-1;e>=3&&t.bl_tree[u2[e]*2+1]===0;e--);return t.opt_len+=3*(e+1)+5+5+4,e}function I5(t,e,n,r){var i;for(Mt(t,e-257,5),Mt(t,n-1,5),Mt(t,r-4,4),i=0;i<r;i++)Mt(t,t.bl_tree[u2[i]*2+1],3);eb(t,t.dyn_ltree,e-1),eb(t,t.dyn_dtree,n-1)}function k5(t){var e=4093624447,n;for(n=0;n<=31;n++,e>>>=1)if(e&1&&t.dyn_ltree[n*2]!==0)return Y1;if(t.dyn_ltree[9*2]!==0||t.dyn_ltree[10*2]!==0||t.dyn_ltree[13*2]!==0)return X1;for(n=32;n<Zl;n++)if(t.dyn_ltree[n*2]!==0)return X1;return Y1}var tb=!1;function R5(t){tb||(C5(),tb=!0),t.l_desc=new Rh(t.dyn_ltree,f2),t.d_desc=new Rh(t.dyn_dtree,c2),t.bl_desc=new Rh(t.bl_tree,h2),t.bi_buf=0,t.bi_valid=0,m2(t)}function y2(t,e,n,r){Mt(t,(b5<<1)+(r?1:0),3),T5(t,e,n,!0)}function D5(t){Mt(t,i2<<1,3),Xn(t,cg,_r),A5(t)}function B5(t,e,n,r){var i,a,o=0;t.level>0?(t.strm.data_type===m5&&(t.strm.data_type=k5(t)),A0(t,t.l_desc),A0(t,t.d_desc),o=F5(t),i=t.opt_len+3+7>>>3,a=t.static_len+3+7>>>3,a<=i&&(i=a)):i=a=n+5,n+4<=i&&e!==-1?y2(t,e,n,r):t.strategy===g5||a===i?(Mt(t,(i2<<1)+(r?1:0),3),J1(t,_r,ys)):(Mt(t,(y5<<1)+(r?1:0),3),I5(t,t.l_desc.max_code+1,t.d_desc.max_code+1,o+1),J1(t,t.dyn_ltree,t.dyn_dtree)),m2(t),r&&b2(t)}function N5(t,e,n){return t.pending_buf[t.d_buf+t.last_lit*2]=e>>>8&255,t.pending_buf[t.d_buf+t.last_lit*2+1]=e&255,t.pending_buf[t.l_buf+t.last_lit]=n&255,t.last_lit++,e===0?t.dyn_ltree[n*2]++:(t.matches++,e--,t.dyn_ltree[(tl[n]+Zl+1)*2]++,t.dyn_dtree[d2(e)*2]++),t.last_lit===t.lit_bufsize-1}Lo._tr_init=R5;Lo._tr_stored_block=y2;Lo._tr_flush_block=B5;Lo._tr_tally=N5;Lo._tr_align=D5;function $5(t,e,n,r){for(var i=t&65535|0,a=t>>>16&65535|0,o=0;n!==0;){o=n>2e3?2e3:n,n-=o;do i=i+e[r++]|0,a=a+i|0;while(--o);i%=65521,a%=65521}return i|a<<16|0}var w2=$5;function O5(){for(var t,e=[],n=0;n<256;n++){t=n;for(var r=0;r<8;r++)t=t&1?3988292384^t>>>1:t>>>1;e[n]=t}return e}var L5=O5();function M5(t,e,n,r){var i=L5,a=r+n;t^=-1;for(var o=r;o<a;o++)t=t>>>8^i[(t^e[o])&255];return t^-1}var x2=M5,dg={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"},St=Or,dn=Lo,_2=w2,Wr=x2,P5=dg,_a=0,z5=1,U5=3,ii=4,nb=5,Kn=0,rb=1,pn=-2,q5=-3,Bh=-5,V5=-1,H5=1,Eu=2,G5=3,j5=4,W5=0,Z5=2,Pc=8,Y5=9,X5=15,K5=8,J5=29,Q5=256,S0=Q5+1+J5,eN=30,tN=19,nN=2*S0+1,rN=15,de=3,ei=258,In=ei+de+1,iN=32,zc=42,C0=69,qu=73,Vu=91,Hu=103,Pi=113,ss=666,tt=1,Yl=2,sa=3,Po=4,aN=3;function ti(t,e){return t.msg=P5[e],e}function ib(t){return(t<<1)-(t>4?9:0)}function Kr(t){for(var e=t.length;--e>=0;)t[e]=0}function Zr(t){var e=t.state,n=e.pending;n>t.avail_out&&(n=t.avail_out),n!==0&&(St.arraySet(t.output,e.pending_buf,e.pending_out,n,t.next_out),t.next_out+=n,e.pending_out+=n,t.total_out+=n,t.avail_out-=n,e.pending-=n,e.pending===0&&(e.pending_out=0))}function pt(t,e){dn._tr_flush_block(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,Zr(t.strm)}function ye(t,e){t.pending_buf[t.pending++]=e}function ts(t,e){t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=e&255}function oN(t,e,n,r){var i=t.avail_in;return i>r&&(i=r),i===0?0:(t.avail_in-=i,St.arraySet(e,t.input,t.next_in,i,n),t.state.wrap===1?t.adler=_2(t.adler,e,i,n):t.state.wrap===2&&(t.adler=Wr(t.adler,e,i,n)),t.next_in+=i,t.total_in+=i,i)}function v2(t,e){var n=t.max_chain_length,r=t.strstart,i,a,o=t.prev_length,s=t.nice_match,u=t.strstart>t.w_size-In?t.strstart-(t.w_size-In):0,l=t.window,f=t.w_mask,c=t.prev,h=t.strstart+ei,d=l[r+o-1],p=l[r+o];t.prev_length>=t.good_match&&(n>>=2),s>t.lookahead&&(s=t.lookahead);do if(i=e,!(l[i+o]!==p||l[i+o-1]!==d||l[i]!==l[r]||l[++i]!==l[r+1])){r+=2,i++;do;while(l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&r<h);if(a=ei-(h-r),r=h-ei,a>o){if(t.match_start=e,o=a,a>=s)break;d=l[r+o-1],p=l[r+o]}}while((e=c[e&f])>u&&--n!==0);return o<=t.lookahead?o:t.lookahead}function la(t){var e=t.w_size,n,r,i,a,o;do{if(a=t.window_size-t.lookahead-t.strstart,t.strstart>=e+(e-In)){St.arraySet(t.window,t.window,e,e,0),t.match_start-=e,t.strstart-=e,t.block_start-=e,r=t.hash_size,n=r;do i=t.head[--n],t.head[n]=i>=e?i-e:0;while(--r);r=e,n=r;do i=t.prev[--n],t.prev[n]=i>=e?i-e:0;while(--r);a+=e}if(t.strm.avail_in===0)break;if(r=oN(t.strm,t.window,t.strstart+t.lookahead,a),t.lookahead+=r,t.lookahead+t.insert>=de)for(o=t.strstart-t.insert,t.ins_h=t.window[o],t.ins_h=(t.ins_h<<t.hash_shift^t.window[o+1])&t.hash_mask;t.insert&&(t.ins_h=(t.ins_h<<t.hash_shift^t.window[o+de-1])&t.hash_mask,t.prev[o&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=o,o++,t.insert--,!(t.lookahead+t.insert<de)););}while(t.lookahead<In&&t.strm.avail_in!==0)}function sN(t,e){var n=65535;for(n>t.pending_buf_size-5&&(n=t.pending_buf_size-5);;){if(t.lookahead<=1){if(la(t),t.lookahead===0&&e===_a)return tt;if(t.lookahead===0)break}t.strstart+=t.lookahead,t.lookahead=0;var r=t.block_start+n;if((t.strstart===0||t.strstart>=r)&&(t.lookahead=t.strstart-r,t.strstart=r,pt(t,!1),t.strm.avail_out===0)||t.strstart-t.block_start>=t.w_size-In&&(pt(t,!1),t.strm.avail_out===0))return tt}return t.insert=0,e===ii?(pt(t,!0),t.strm.avail_out===0?sa:Po):(t.strstart>t.block_start&&(pt(t,!1),t.strm.avail_out===0),tt)}function Nh(t,e){for(var n,r;;){if(t.lookahead<In){if(la(t),t.lookahead<In&&e===_a)return tt;if(t.lookahead===0)break}if(n=0,t.lookahead>=de&&(t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+de-1])&t.hash_mask,n=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),n!==0&&t.strstart-n<=t.w_size-In&&(t.match_length=v2(t,n)),t.match_length>=de)if(r=dn._tr_tally(t,t.strstart-t.match_start,t.match_length-de),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=de){t.match_length--;do t.strstart++,t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+de-1])&t.hash_mask,n=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart;while(--t.match_length!==0);t.strstart++}else t.strstart+=t.match_length,t.match_length=0,t.ins_h=t.window[t.strstart],t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+1])&t.hash_mask;else r=dn._tr_tally(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(r&&(pt(t,!1),t.strm.avail_out===0))return tt}return t.insert=t.strstart<de-1?t.strstart:de-1,e===ii?(pt(t,!0),t.strm.avail_out===0?sa:Po):t.last_lit&&(pt(t,!1),t.strm.avail_out===0)?tt:Yl}function Ba(t,e){for(var n,r,i;;){if(t.lookahead<In){if(la(t),t.lookahead<In&&e===_a)return tt;if(t.lookahead===0)break}if(n=0,t.lookahead>=de&&(t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+de-1])&t.hash_mask,n=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),t.prev_length=t.match_length,t.prev_match=t.match_start,t.match_length=de-1,n!==0&&t.prev_length<t.max_lazy_match&&t.strstart-n<=t.w_size-In&&(t.match_length=v2(t,n),t.match_length<=5&&(t.strategy===H5||t.match_length===de&&t.strstart-t.match_start>4096)&&(t.match_length=de-1)),t.prev_length>=de&&t.match_length<=t.prev_length){i=t.strstart+t.lookahead-de,r=dn._tr_tally(t,t.strstart-1-t.prev_match,t.prev_length-de),t.lookahead-=t.prev_length-1,t.prev_length-=2;do++t.strstart<=i&&(t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+de-1])&t.hash_mask,n=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart);while(--t.prev_length!==0);if(t.match_available=0,t.match_length=de-1,t.strstart++,r&&(pt(t,!1),t.strm.avail_out===0))return tt}else if(t.match_available){if(r=dn._tr_tally(t,0,t.window[t.strstart-1]),r&&pt(t,!1),t.strstart++,t.lookahead--,t.strm.avail_out===0)return tt}else t.match_available=1,t.strstart++,t.lookahead--}return t.match_available&&(r=dn._tr_tally(t,0,t.window[t.strstart-1]),t.match_available=0),t.insert=t.strstart<de-1?t.strstart:de-1,e===ii?(pt(t,!0),t.strm.avail_out===0?sa:Po):t.last_lit&&(pt(t,!1),t.strm.avail_out===0)?tt:Yl}function lN(t,e){for(var n,r,i,a,o=t.window;;){if(t.lookahead<=ei){if(la(t),t.lookahead<=ei&&e===_a)return tt;if(t.lookahead===0)break}if(t.match_length=0,t.lookahead>=de&&t.strstart>0&&(i=t.strstart-1,r=o[i],r===o[++i]&&r===o[++i]&&r===o[++i])){a=t.strstart+ei;do;while(r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&i<a);t.match_length=ei-(a-i),t.match_length>t.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=de?(n=dn._tr_tally(t,1,t.match_length-de),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(n=dn._tr_tally(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),n&&(pt(t,!1),t.strm.avail_out===0))return tt}return t.insert=0,e===ii?(pt(t,!0),t.strm.avail_out===0?sa:Po):t.last_lit&&(pt(t,!1),t.strm.avail_out===0)?tt:Yl}function uN(t,e){for(var n;;){if(t.lookahead===0&&(la(t),t.lookahead===0)){if(e===_a)return tt;break}if(t.match_length=0,n=dn._tr_tally(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,n&&(pt(t,!1),t.strm.avail_out===0))return tt}return t.insert=0,e===ii?(pt(t,!0),t.strm.avail_out===0?sa:Po):t.last_lit&&(pt(t,!1),t.strm.avail_out===0)?tt:Yl}function Hn(t,e,n,r,i){this.good_length=t,this.max_lazy=e,this.nice_length=n,this.max_chain=r,this.func=i}var za;za=[new Hn(0,0,0,0,sN),new Hn(4,4,8,4,Nh),new Hn(4,5,16,8,Nh),new Hn(4,6,32,32,Nh),new Hn(4,4,16,16,Ba),new Hn(8,16,32,32,Ba),new Hn(8,16,128,128,Ba),new Hn(8,32,128,256,Ba),new Hn(32,128,258,1024,Ba),new Hn(32,258,258,4096,Ba)];function fN(t){t.window_size=2*t.w_size,Kr(t.head),t.max_lazy_match=za[t.level].max_lazy,t.good_match=za[t.level].good_length,t.nice_match=za[t.level].nice_length,t.max_chain_length=za[t.level].max_chain,t.strstart=0,t.block_start=0,t.lookahead=0,t.insert=0,t.match_length=t.prev_length=de-1,t.match_available=0,t.ins_h=0}function cN(){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=Pc,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 St.Buf16(nN*2),this.dyn_dtree=new St.Buf16((2*eN+1)*2),this.bl_tree=new St.Buf16((2*tN+1)*2),Kr(this.dyn_ltree),Kr(this.dyn_dtree),Kr(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new St.Buf16(rN+1),this.heap=new St.Buf16(2*S0+1),Kr(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new St.Buf16(2*S0+1),Kr(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 E2(t){var e;return!t||!t.state?ti(t,pn):(t.total_in=t.total_out=0,t.data_type=Z5,e=t.state,e.pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=e.wrap?zc:Pi,t.adler=e.wrap===2?0:1,e.last_flush=_a,dn._tr_init(e),Kn)}function A2(t){var e=E2(t);return e===Kn&&fN(t.state),e}function hN(t,e){return!t||!t.state||t.state.wrap!==2?pn:(t.state.gzhead=e,Kn)}function S2(t,e,n,r,i,a){if(!t)return pn;var o=1;if(e===V5&&(e=6),r<0?(o=0,r=-r):r>15&&(o=2,r-=16),i<1||i>Y5||n!==Pc||r<8||r>15||e<0||e>9||a<0||a>j5)return ti(t,pn);r===8&&(r=9);var s=new cN;return t.state=s,s.strm=t,s.wrap=o,s.gzhead=null,s.w_bits=r,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+de-1)/de),s.window=new St.Buf8(s.w_size*2),s.head=new St.Buf16(s.hash_size),s.prev=new St.Buf16(s.w_size),s.lit_bufsize=1<<i+6,s.pending_buf_size=s.lit_bufsize*4,s.pending_buf=new St.Buf8(s.pending_buf_size),s.d_buf=1*s.lit_bufsize,s.l_buf=(1+2)*s.lit_bufsize,s.level=e,s.strategy=a,s.method=n,A2(t)}function dN(t,e){return S2(t,e,Pc,X5,K5,W5)}function pN(t,e){var n,r,i,a;if(!t||!t.state||e>nb||e<0)return t?ti(t,pn):pn;if(r=t.state,!t.output||!t.input&&t.avail_in!==0||r.status===ss&&e!==ii)return ti(t,t.avail_out===0?Bh:pn);if(r.strm=t,n=r.last_flush,r.last_flush=e,r.status===zc)if(r.wrap===2)t.adler=0,ye(r,31),ye(r,139),ye(r,8),r.gzhead?(ye(r,(r.gzhead.text?1:0)+(r.gzhead.hcrc?2:0)+(r.gzhead.extra?4:0)+(r.gzhead.name?8:0)+(r.gzhead.comment?16:0)),ye(r,r.gzhead.time&255),ye(r,r.gzhead.time>>8&255),ye(r,r.gzhead.time>>16&255),ye(r,r.gzhead.time>>24&255),ye(r,r.level===9?2:r.strategy>=Eu||r.level<2?4:0),ye(r,r.gzhead.os&255),r.gzhead.extra&&r.gzhead.extra.length&&(ye(r,r.gzhead.extra.length&255),ye(r,r.gzhead.extra.length>>8&255)),r.gzhead.hcrc&&(t.adler=Wr(t.adler,r.pending_buf,r.pending,0)),r.gzindex=0,r.status=C0):(ye(r,0),ye(r,0),ye(r,0),ye(r,0),ye(r,0),ye(r,r.level===9?2:r.strategy>=Eu||r.level<2?4:0),ye(r,aN),r.status=Pi);else{var o=Pc+(r.w_bits-8<<4)<<8,s=-1;r.strategy>=Eu||r.level<2?s=0:r.level<6?s=1:r.level===6?s=2:s=3,o|=s<<6,r.strstart!==0&&(o|=iN),o+=31-o%31,r.status=Pi,ts(r,o),r.strstart!==0&&(ts(r,t.adler>>>16),ts(r,t.adler&65535)),t.adler=1}if(r.status===C0)if(r.gzhead.extra){for(i=r.pending;r.gzindex<(r.gzhead.extra.length&65535)&&!(r.pending===r.pending_buf_size&&(r.gzhead.hcrc&&r.pending>i&&(t.adler=Wr(t.adler,r.pending_buf,r.pending-i,i)),Zr(t),i=r.pending,r.pending===r.pending_buf_size));)ye(r,r.gzhead.extra[r.gzindex]&255),r.gzindex++;r.gzhead.hcrc&&r.pending>i&&(t.adler=Wr(t.adler,r.pending_buf,r.pending-i,i)),r.gzindex===r.gzhead.extra.length&&(r.gzindex=0,r.status=qu)}else r.status=qu;if(r.status===qu)if(r.gzhead.name){i=r.pending;do{if(r.pending===r.pending_buf_size&&(r.gzhead.hcrc&&r.pending>i&&(t.adler=Wr(t.adler,r.pending_buf,r.pending-i,i)),Zr(t),i=r.pending,r.pending===r.pending_buf_size)){a=1;break}r.gzindex<r.gzhead.name.length?a=r.gzhead.name.charCodeAt(r.gzindex++)&255:a=0,ye(r,a)}while(a!==0);r.gzhead.hcrc&&r.pending>i&&(t.adler=Wr(t.adler,r.pending_buf,r.pending-i,i)),a===0&&(r.gzindex=0,r.status=Vu)}else r.status=Vu;if(r.status===Vu)if(r.gzhead.comment){i=r.pending;do{if(r.pending===r.pending_buf_size&&(r.gzhead.hcrc&&r.pending>i&&(t.adler=Wr(t.adler,r.pending_buf,r.pending-i,i)),Zr(t),i=r.pending,r.pending===r.pending_buf_size)){a=1;break}r.gzindex<r.gzhead.comment.length?a=r.gzhead.comment.charCodeAt(r.gzindex++)&255:a=0,ye(r,a)}while(a!==0);r.gzhead.hcrc&&r.pending>i&&(t.adler=Wr(t.adler,r.pending_buf,r.pending-i,i)),a===0&&(r.status=Hu)}else r.status=Hu;if(r.status===Hu&&(r.gzhead.hcrc?(r.pending+2>r.pending_buf_size&&Zr(t),r.pending+2<=r.pending_buf_size&&(ye(r,t.adler&255),ye(r,t.adler>>8&255),t.adler=0,r.status=Pi)):r.status=Pi),r.pending!==0){if(Zr(t),t.avail_out===0)return r.last_flush=-1,Kn}else if(t.avail_in===0&&ib(e)<=ib(n)&&e!==ii)return ti(t,Bh);if(r.status===ss&&t.avail_in!==0)return ti(t,Bh);if(t.avail_in!==0||r.lookahead!==0||e!==_a&&r.status!==ss){var u=r.strategy===Eu?uN(r,e):r.strategy===G5?lN(r,e):za[r.level].func(r,e);if((u===sa||u===Po)&&(r.status=ss),u===tt||u===sa)return t.avail_out===0&&(r.last_flush=-1),Kn;if(u===Yl&&(e===z5?dn._tr_align(r):e!==nb&&(dn._tr_stored_block(r,0,0,!1),e===U5&&(Kr(r.head),r.lookahead===0&&(r.strstart=0,r.block_start=0,r.insert=0))),Zr(t),t.avail_out===0))return r.last_flush=-1,Kn}return e!==ii?Kn:r.wrap<=0?rb:(r.wrap===2?(ye(r,t.adler&255),ye(r,t.adler>>8&255),ye(r,t.adler>>16&255),ye(r,t.adler>>24&255),ye(r,t.total_in&255),ye(r,t.total_in>>8&255),ye(r,t.total_in>>16&255),ye(r,t.total_in>>24&255)):(ts(r,t.adler>>>16),ts(r,t.adler&65535)),Zr(t),r.wrap>0&&(r.wrap=-r.wrap),r.pending!==0?Kn:rb)}function gN(t){var e;return!t||!t.state?pn:(e=t.state.status,e!==zc&&e!==C0&&e!==qu&&e!==Vu&&e!==Hu&&e!==Pi&&e!==ss?ti(t,pn):(t.state=null,e===Pi?ti(t,q5):Kn))}function mN(t,e){var n=e.length,r,i,a,o,s,u,l,f;if(!t||!t.state||(r=t.state,o=r.wrap,o===2||o===1&&r.status!==zc||r.lookahead))return pn;for(o===1&&(t.adler=_2(t.adler,e,n,0)),r.wrap=0,n>=r.w_size&&(o===0&&(Kr(r.head),r.strstart=0,r.block_start=0,r.insert=0),f=new St.Buf8(r.w_size),St.arraySet(f,e,n-r.w_size,r.w_size,0),e=f,n=r.w_size),s=t.avail_in,u=t.next_in,l=t.input,t.avail_in=n,t.next_in=0,t.input=e,la(r);r.lookahead>=de;){i=r.strstart,a=r.lookahead-(de-1);do r.ins_h=(r.ins_h<<r.hash_shift^r.window[i+de-1])&r.hash_mask,r.prev[i&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=i,i++;while(--a);r.strstart=i,r.lookahead=de-1,la(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=de-1,r.match_available=0,t.next_in=u,t.input=l,t.avail_in=s,r.wrap=o,Kn}cr.deflateInit=dN;cr.deflateInit2=S2;cr.deflateReset=A2;cr.deflateResetKeep=E2;cr.deflateSetHeader=hN;cr.deflate=pN;cr.deflateEnd=gN;cr.deflateSetDictionary=mN;cr.deflateInfo="pako deflate (from Nodeca project)";var va={},Uc=Or,C2=!0,T2=!0;try{String.fromCharCode.apply(null,[0])}catch{C2=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{T2=!1}var rl=new Uc.Buf8(256);for(var Gr=0;Gr<256;Gr++)rl[Gr]=Gr>=252?6:Gr>=248?5:Gr>=240?4:Gr>=224?3:Gr>=192?2:1;rl[254]=rl[254]=1;va.string2buf=function(t){var e,n,r,i,a,o=t.length,s=0;for(i=0;i<o;i++)n=t.charCodeAt(i),(n&64512)===55296&&i+1<o&&(r=t.charCodeAt(i+1),(r&64512)===56320&&(n=65536+(n-55296<<10)+(r-56320),i++)),s+=n<128?1:n<2048?2:n<65536?3:4;for(e=new Uc.Buf8(s),a=0,i=0;a<s;i++)n=t.charCodeAt(i),(n&64512)===55296&&i+1<o&&(r=t.charCodeAt(i+1),(r&64512)===56320&&(n=65536+(n-55296<<10)+(r-56320),i++)),n<128?e[a++]=n:n<2048?(e[a++]=192|n>>>6,e[a++]=128|n&63):n<65536?(e[a++]=224|n>>>12,e[a++]=128|n>>>6&63,e[a++]=128|n&63):(e[a++]=240|n>>>18,e[a++]=128|n>>>12&63,e[a++]=128|n>>>6&63,e[a++]=128|n&63);return e};function F2(t,e){if(e<65534&&(t.subarray&&T2||!t.subarray&&C2))return String.fromCharCode.apply(null,Uc.shrinkBuf(t,e));for(var n="",r=0;r<e;r++)n+=String.fromCharCode(t[r]);return n}va.buf2binstring=function(t){return F2(t,t.length)};va.binstring2buf=function(t){for(var e=new Uc.Buf8(t.length),n=0,r=e.length;n<r;n++)e[n]=t.charCodeAt(n);return e};va.buf2string=function(t,e){var n,r,i,a,o=e||t.length,s=new Array(o*2);for(r=0,n=0;n<o;){if(i=t[n++],i<128){s[r++]=i;continue}if(a=rl[i],a>4){s[r++]=65533,n+=a-1;continue}for(i&=a===2?31:a===3?15:7;a>1&&n<o;)i=i<<6|t[n++]&63,a--;if(a>1){s[r++]=65533;continue}i<65536?s[r++]=i:(i-=65536,s[r++]=55296|i>>10&1023,s[r++]=56320|i&1023)}return F2(s,r)};va.utf8border=function(t,e){var n;for(e=e||t.length,e>t.length&&(e=t.length),n=e-1;n>=0&&(t[n]&192)===128;)n--;return n<0||n===0?e:n+rl[t[n]]>e?n:e};function bN(){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}var I2=bN,ws=cr,xs=Or,T0=va,F0=dg,yN=I2,k2=Object.prototype.toString,wN=0,$h=4,ja=0,ab=1,ob=2,xN=-1,_N=0,vN=8;function ua(t){if(!(this instanceof ua))return new ua(t);this.options=xs.assign({level:xN,method:vN,chunkSize:16384,windowBits:15,memLevel:8,strategy:_N,to:""},t||{});var e=this.options;e.raw&&e.windowBits>0?e.windowBits=-e.windowBits:e.gzip&&e.windowBits>0&&e.windowBits<16&&(e.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new yN,this.strm.avail_out=0;var n=ws.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(n!==ja)throw new Error(F0[n]);if(e.header&&ws.deflateSetHeader(this.strm,e.header),e.dictionary){var r;if(typeof e.dictionary=="string"?r=T0.string2buf(e.dictionary):k2.call(e.dictionary)==="[object ArrayBuffer]"?r=new Uint8Array(e.dictionary):r=e.dictionary,n=ws.deflateSetDictionary(this.strm,r),n!==ja)throw new Error(F0[n]);this._dict_set=!0}}ua.prototype.push=function(t,e){var n=this.strm,r=this.options.chunkSize,i,a;if(this.ended)return!1;a=e===~~e?e:e===!0?$h:wN,typeof t=="string"?n.input=T0.string2buf(t):k2.call(t)==="[object ArrayBuffer]"?n.input=new Uint8Array(t):n.input=t,n.next_in=0,n.avail_in=n.input.length;do{if(n.avail_out===0&&(n.output=new xs.Buf8(r),n.next_out=0,n.avail_out=r),i=ws.deflate(n,a),i!==ab&&i!==ja)return this.onEnd(i),this.ended=!0,!1;(n.avail_out===0||n.avail_in===0&&(a===$h||a===ob))&&(this.options.to==="string"?this.onData(T0.buf2binstring(xs.shrinkBuf(n.output,n.next_out))):this.onData(xs.shrinkBuf(n.output,n.next_out)))}while((n.avail_in>0||n.avail_out===0)&&i!==ab);return a===$h?(i=ws.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===ja):(a===ob&&(this.onEnd(ja),n.avail_out=0),!0)};ua.prototype.onData=function(t){this.chunks.push(t)};ua.prototype.onEnd=function(t){t===ja&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=xs.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};function pg(t,e){var n=new ua(e);if(n.push(t,!0),n.err)throw n.msg||F0[n.err];return n.result}function EN(t,e){return e=e||{},e.raw=!0,pg(t,e)}function AN(t,e){return e=e||{},e.gzip=!0,pg(t,e)}Wl.Deflate=ua;Wl.deflate=pg;Wl.deflateRaw=EN;Wl.gzip=AN;var Xl={},$n={},Au=30,SN=12,CN=function(e,n){var r,i,a,o,s,u,l,f,c,h,d,p,m,y,w,A,C,E,k,R,I,O,T,B,N;r=e.state,i=e.next_in,B=e.input,a=i+(e.avail_in-5),o=e.next_out,N=e.output,s=o-(n-e.avail_out),u=o+(e.avail_out-257),l=r.dmax,f=r.wsize,c=r.whave,h=r.wnext,d=r.window,p=r.hold,m=r.bits,y=r.lencode,w=r.distcode,A=(1<<r.lenbits)-1,C=(1<<r.distbits)-1;e:do{m<15&&(p+=B[i++]<<m,m+=8,p+=B[i++]<<m,m+=8),E=y[p&A];t:for(;;){if(k=E>>>24,p>>>=k,m-=k,k=E>>>16&255,k===0)N[o++]=E&65535;else if(k&16){R=E&65535,k&=15,k&&(m<k&&(p+=B[i++]<<m,m+=8),R+=p&(1<<k)-1,p>>>=k,m-=k),m<15&&(p+=B[i++]<<m,m+=8,p+=B[i++]<<m,m+=8),E=w[p&C];n:for(;;){if(k=E>>>24,p>>>=k,m-=k,k=E>>>16&255,k&16){if(I=E&65535,k&=15,m<k&&(p+=B[i++]<<m,m+=8,m<k&&(p+=B[i++]<<m,m+=8)),I+=p&(1<<k)-1,I>l){e.msg="invalid distance too far back",r.mode=Au;break e}if(p>>>=k,m-=k,k=o-s,I>k){if(k=I-k,k>c&&r.sane){e.msg="invalid distance too far back",r.mode=Au;break e}if(O=0,T=d,h===0){if(O+=f-k,k<R){R-=k;do N[o++]=d[O++];while(--k);O=o-I,T=N}}else if(h<k){if(O+=f+h-k,k-=h,k<R){R-=k;do N[o++]=d[O++];while(--k);if(O=0,h<R){k=h,R-=k;do N[o++]=d[O++];while(--k);O=o-I,T=N}}}else if(O+=h-k,k<R){R-=k;do N[o++]=d[O++];while(--k);O=o-I,T=N}for(;R>2;)N[o++]=T[O++],N[o++]=T[O++],N[o++]=T[O++],R-=3;R&&(N[o++]=T[O++],R>1&&(N[o++]=T[O++]))}else{O=o-I;do N[o++]=N[O++],N[o++]=N[O++],N[o++]=N[O++],R-=3;while(R>2);R&&(N[o++]=N[O++],R>1&&(N[o++]=N[O++]))}}else if(k&64){e.msg="invalid distance code",r.mode=Au;break e}else{E=w[(E&65535)+(p&(1<<k)-1)];continue n}break}}else if(k&64)if(k&32){r.mode=SN;break e}else{e.msg="invalid literal/length code",r.mode=Au;break e}else{E=y[(E&65535)+(p&(1<<k)-1)];continue t}break}}while(i<a&&o<u);R=m>>3,i-=R,m-=R<<3,p&=(1<<m)-1,e.next_in=i,e.next_out=o,e.avail_in=i<a?5+(a-i):5-(i-a),e.avail_out=o<u?257+(u-o):257-(o-u),r.hold=p,r.bits=m},sb=Or,Na=15,lb=852,ub=592,fb=0,Oh=1,cb=2,TN=[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],FN=[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],IN=[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],kN=[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],RN=function(e,n,r,i,a,o,s,u){var l=u.bits,f=0,c=0,h=0,d=0,p=0,m=0,y=0,w=0,A=0,C=0,E,k,R,I,O,T=null,B=0,N,J=new sb.Buf16(Na+1),ee=new sb.Buf16(Na+1),Q=null,he=0,be,Se,Ke;for(f=0;f<=Na;f++)J[f]=0;for(c=0;c<i;c++)J[n[r+c]]++;for(p=l,d=Na;d>=1&&J[d]===0;d--);if(p>d&&(p=d),d===0)return a[o++]=1<<24|64<<16|0,a[o++]=1<<24|64<<16|0,u.bits=1,0;for(h=1;h<d&&J[h]===0;h++);for(p<h&&(p=h),w=1,f=1;f<=Na;f++)if(w<<=1,w-=J[f],w<0)return-1;if(w>0&&(e===fb||d!==1))return-1;for(ee[1]=0,f=1;f<Na;f++)ee[f+1]=ee[f]+J[f];for(c=0;c<i;c++)n[r+c]!==0&&(s[ee[n[r+c]]++]=c);if(e===fb?(T=Q=s,N=19):e===Oh?(T=TN,B-=257,Q=FN,he-=257,N=256):(T=IN,Q=kN,N=-1),C=0,c=0,f=h,O=o,m=p,y=0,R=-1,A=1<<p,I=A-1,e===Oh&&A>lb||e===cb&&A>ub)return 1;for(;;){be=f-y,s[c]<N?(Se=0,Ke=s[c]):s[c]>N?(Se=Q[he+s[c]],Ke=T[B+s[c]]):(Se=32+64,Ke=0),E=1<<f-y,k=1<<m,h=k;do k-=E,a[O+(C>>y)+k]=be<<24|Se<<16|Ke|0;while(k!==0);for(E=1<<f-1;C&E;)E>>=1;if(E!==0?(C&=E-1,C+=E):C=0,c++,--J[f]===0){if(f===d)break;f=n[r+s[c]]}if(f>p&&(C&I)!==R){for(y===0&&(y=p),O+=h,m=f-y,w=1<<m;m+y<d&&(w-=J[m+y],!(w<=0));)m++,w<<=1;if(A+=1<<m,e===Oh&&A>lb||e===cb&&A>ub)return 1;R=C&I,a[R]=p<<24|m<<16|O-o|0}}return C!==0&&(a[O+C]=f-y<<24|64<<16|0),u.bits=p,0},Xt=Or,I0=w2,Gn=x2,DN=CN,_s=RN,BN=0,R2=1,D2=2,hb=4,NN=5,Su=6,fa=0,$N=1,ON=2,gn=-2,B2=-3,N2=-4,LN=-5,db=8,$2=1,pb=2,gb=3,mb=4,bb=5,yb=6,wb=7,xb=8,_b=9,vb=10,Af=11,mr=12,Lh=13,Eb=14,Mh=15,Ab=16,Sb=17,Cb=18,Tb=19,Cu=20,Tu=21,Fb=22,Ib=23,kb=24,Rb=25,Db=26,Ph=27,Bb=28,Nb=29,qe=30,O2=31,MN=32,PN=852,zN=592,UN=15,qN=UN;function $b(t){return(t>>>24&255)+(t>>>8&65280)+((t&65280)<<8)+((t&255)<<24)}function VN(){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 Xt.Buf16(320),this.work=new Xt.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function L2(t){var e;return!t||!t.state?gn:(e=t.state,t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=e.wrap&1),e.mode=$2,e.last=0,e.havedict=0,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new Xt.Buf32(PN),e.distcode=e.distdyn=new Xt.Buf32(zN),e.sane=1,e.back=-1,fa)}function M2(t){var e;return!t||!t.state?gn:(e=t.state,e.wsize=0,e.whave=0,e.wnext=0,L2(t))}function P2(t,e){var n,r;return!t||!t.state||(r=t.state,e<0?(n=0,e=-e):(n=(e>>4)+1,e<48&&(e&=15)),e&&(e<8||e>15))?gn:(r.window!==null&&r.wbits!==e&&(r.window=null),r.wrap=n,r.wbits=e,M2(t))}function z2(t,e){var n,r;return t?(r=new VN,t.state=r,r.window=null,n=P2(t,e),n!==fa&&(t.state=null),n):gn}function HN(t){return z2(t,qN)}var Ob=!0,zh,Uh;function GN(t){if(Ob){var e;for(zh=new Xt.Buf32(512),Uh=new Xt.Buf32(32),e=0;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(_s(R2,t.lens,0,288,zh,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;_s(D2,t.lens,0,32,Uh,0,t.work,{bits:5}),Ob=!1}t.lencode=zh,t.lenbits=9,t.distcode=Uh,t.distbits=5}function U2(t,e,n,r){var i,a=t.state;return a.window===null&&(a.wsize=1<<a.wbits,a.wnext=0,a.whave=0,a.window=new Xt.Buf8(a.wsize)),r>=a.wsize?(Xt.arraySet(a.window,e,n-a.wsize,a.wsize,0),a.wnext=0,a.whave=a.wsize):(i=a.wsize-a.wnext,i>r&&(i=r),Xt.arraySet(a.window,e,n-r,i,a.wnext),r-=i,r?(Xt.arraySet(a.window,e,n-r,r,0),a.wnext=r,a.whave=a.wsize):(a.wnext+=i,a.wnext===a.wsize&&(a.wnext=0),a.whave<a.wsize&&(a.whave+=i))),0}function jN(t,e){var n,r,i,a,o,s,u,l,f,c,h,d,p,m,y=0,w,A,C,E,k,R,I,O,T=new Xt.Buf8(4),B,N,J=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!t||!t.state||!t.output||!t.input&&t.avail_in!==0)return gn;n=t.state,n.mode===mr&&(n.mode=Lh),o=t.next_out,i=t.output,u=t.avail_out,a=t.next_in,r=t.input,s=t.avail_in,l=n.hold,f=n.bits,c=s,h=u,O=fa;e:for(;;)switch(n.mode){case $2:if(n.wrap===0){n.mode=Lh;break}for(;f<16;){if(s===0)break e;s--,l+=r[a++]<<f,f+=8}if(n.wrap&2&&l===35615){n.check=0,T[0]=l&255,T[1]=l>>>8&255,n.check=Gn(n.check,T,2,0),l=0,f=0,n.mode=pb;break}if(n.flags=0,n.head&&(n.head.done=!1),!(n.wrap&1)||(((l&255)<<8)+(l>>8))%31){t.msg="incorrect header check",n.mode=qe;break}if((l&15)!==db){t.msg="unknown compression method",n.mode=qe;break}if(l>>>=4,f-=4,I=(l&15)+8,n.wbits===0)n.wbits=I;else if(I>n.wbits){t.msg="invalid window size",n.mode=qe;break}n.dmax=1<<I,t.adler=n.check=1,n.mode=l&512?vb:mr,l=0,f=0;break;case pb:for(;f<16;){if(s===0)break e;s--,l+=r[a++]<<f,f+=8}if(n.flags=l,(n.flags&255)!==db){t.msg="unknown compression method",n.mode=qe;break}if(n.flags&57344){t.msg="unknown header flags set",n.mode=qe;break}n.head&&(n.head.text=l>>8&1),n.flags&512&&(T[0]=l&255,T[1]=l>>>8&255,n.check=Gn(n.check,T,2,0)),l=0,f=0,n.mode=gb;case gb:for(;f<32;){if(s===0)break e;s--,l+=r[a++]<<f,f+=8}n.head&&(n.head.time=l),n.flags&512&&(T[0]=l&255,T[1]=l>>>8&255,T[2]=l>>>16&255,T[3]=l>>>24&255,n.check=Gn(n.check,T,4,0)),l=0,f=0,n.mode=mb;case mb:for(;f<16;){if(s===0)break e;s--,l+=r[a++]<<f,f+=8}n.head&&(n.head.xflags=l&255,n.head.os=l>>8),n.flags&512&&(T[0]=l&255,T[1]=l>>>8&255,n.check=Gn(n.check,T,2,0)),l=0,f=0,n.mode=bb;case bb:if(n.flags&1024){for(;f<16;){if(s===0)break e;s--,l+=r[a++]<<f,f+=8}n.length=l,n.head&&(n.head.extra_len=l),n.flags&512&&(T[0]=l&255,T[1]=l>>>8&255,n.check=Gn(n.check,T,2,0)),l=0,f=0}else n.head&&(n.head.extra=null);n.mode=yb;case yb:if(n.flags&1024&&(d=n.length,d>s&&(d=s),d&&(n.head&&(I=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Array(n.head.extra_len)),Xt.arraySet(n.head.extra,r,a,d,I)),n.flags&512&&(n.check=Gn(n.check,r,d,a)),s-=d,a+=d,n.length-=d),n.length))break e;n.length=0,n.mode=wb;case wb:if(n.flags&2048){if(s===0)break e;d=0;do I=r[a+d++],n.head&&I&&n.length<65536&&(n.head.name+=String.fromCharCode(I));while(I&&d<s);if(n.flags&512&&(n.check=Gn(n.check,r,d,a)),s-=d,a+=d,I)break e}else n.head&&(n.head.name=null);n.length=0,n.mode=xb;case xb:if(n.flags&4096){if(s===0)break e;d=0;do I=r[a+d++],n.head&&I&&n.length<65536&&(n.head.comment+=String.fromCharCode(I));while(I&&d<s);if(n.flags&512&&(n.check=Gn(n.check,r,d,a)),s-=d,a+=d,I)break e}else n.head&&(n.head.comment=null);n.mode=_b;case _b:if(n.flags&512){for(;f<16;){if(s===0)break e;s--,l+=r[a++]<<f,f+=8}if(l!==(n.check&65535)){t.msg="header crc mismatch",n.mode=qe;break}l=0,f=0}n.head&&(n.head.hcrc=n.flags>>9&1,n.head.done=!0),t.adler=n.check=0,n.mode=mr;break;case vb:for(;f<32;){if(s===0)break e;s--,l+=r[a++]<<f,f+=8}t.adler=n.check=$b(l),l=0,f=0,n.mode=Af;case Af:if(n.havedict===0)return t.next_out=o,t.avail_out=u,t.next_in=a,t.avail_in=s,n.hold=l,n.bits=f,ON;t.adler=n.check=1,n.mode=mr;case mr:if(e===NN||e===Su)break e;case Lh:if(n.last){l>>>=f&7,f-=f&7,n.mode=Ph;break}for(;f<3;){if(s===0)break e;s--,l+=r[a++]<<f,f+=8}switch(n.last=l&1,l>>>=1,f-=1,l&3){case 0:n.mode=Eb;break;case 1:if(GN(n),n.mode=Cu,e===Su){l>>>=2,f-=2;break e}break;case 2:n.mode=Sb;break;case 3:t.msg="invalid block type",n.mode=qe}l>>>=2,f-=2;break;case Eb:for(l>>>=f&7,f-=f&7;f<32;){if(s===0)break e;s--,l+=r[a++]<<f,f+=8}if((l&65535)!==(l>>>16^65535)){t.msg="invalid stored block lengths",n.mode=qe;break}if(n.length=l&65535,l=0,f=0,n.mode=Mh,e===Su)break e;case Mh:n.mode=Ab;case Ab:if(d=n.length,d){if(d>s&&(d=s),d>u&&(d=u),d===0)break e;Xt.arraySet(i,r,a,d,o),s-=d,a+=d,u-=d,o+=d,n.length-=d;break}n.mode=mr;break;case Sb:for(;f<14;){if(s===0)break e;s--,l+=r[a++]<<f,f+=8}if(n.nlen=(l&31)+257,l>>>=5,f-=5,n.ndist=(l&31)+1,l>>>=5,f-=5,n.ncode=(l&15)+4,l>>>=4,f-=4,n.nlen>286||n.ndist>30){t.msg="too many length or distance symbols",n.mode=qe;break}n.have=0,n.mode=Cb;case Cb:for(;n.have<n.ncode;){for(;f<3;){if(s===0)break e;s--,l+=r[a++]<<f,f+=8}n.lens[J[n.have++]]=l&7,l>>>=3,f-=3}for(;n.have<19;)n.lens[J[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,B={bits:n.lenbits},O=_s(BN,n.lens,0,19,n.lencode,0,n.work,B),n.lenbits=B.bits,O){t.msg="invalid code lengths set",n.mode=qe;break}n.have=0,n.mode=Tb;case Tb:for(;n.have<n.nlen+n.ndist;){for(;y=n.lencode[l&(1<<n.lenbits)-1],w=y>>>24,A=y>>>16&255,C=y&65535,!(w<=f);){if(s===0)break e;s--,l+=r[a++]<<f,f+=8}if(C<16)l>>>=w,f-=w,n.lens[n.have++]=C;else{if(C===16){for(N=w+2;f<N;){if(s===0)break e;s--,l+=r[a++]<<f,f+=8}if(l>>>=w,f-=w,n.have===0){t.msg="invalid bit length repeat",n.mode=qe;break}I=n.lens[n.have-1],d=3+(l&3),l>>>=2,f-=2}else if(C===17){for(N=w+3;f<N;){if(s===0)break e;s--,l+=r[a++]<<f,f+=8}l>>>=w,f-=w,I=0,d=3+(l&7),l>>>=3,f-=3}else{for(N=w+7;f<N;){if(s===0)break e;s--,l+=r[a++]<<f,f+=8}l>>>=w,f-=w,I=0,d=11+(l&127),l>>>=7,f-=7}if(n.have+d>n.nlen+n.ndist){t.msg="invalid bit length repeat",n.mode=qe;break}for(;d--;)n.lens[n.have++]=I}}if(n.mode===qe)break;if(n.lens[256]===0){t.msg="invalid code -- missing end-of-block",n.mode=qe;break}if(n.lenbits=9,B={bits:n.lenbits},O=_s(R2,n.lens,0,n.nlen,n.lencode,0,n.work,B),n.lenbits=B.bits,O){t.msg="invalid literal/lengths set",n.mode=qe;break}if(n.distbits=6,n.distcode=n.distdyn,B={bits:n.distbits},O=_s(D2,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,B),n.distbits=B.bits,O){t.msg="invalid distances set",n.mode=qe;break}if(n.mode=Cu,e===Su)break e;case Cu:n.mode=Tu;case Tu:if(s>=6&&u>=258){t.next_out=o,t.avail_out=u,t.next_in=a,t.avail_in=s,n.hold=l,n.bits=f,DN(t,h),o=t.next_out,i=t.output,u=t.avail_out,a=t.next_in,r=t.input,s=t.avail_in,l=n.hold,f=n.bits,n.mode===mr&&(n.back=-1);break}for(n.back=0;y=n.lencode[l&(1<<n.lenbits)-1],w=y>>>24,A=y>>>16&255,C=y&65535,!(w<=f);){if(s===0)break e;s--,l+=r[a++]<<f,f+=8}if(A&&!(A&240)){for(E=w,k=A,R=C;y=n.lencode[R+((l&(1<<E+k)-1)>>E)],w=y>>>24,A=y>>>16&255,C=y&65535,!(E+w<=f);){if(s===0)break e;s--,l+=r[a++]<<f,f+=8}l>>>=E,f-=E,n.back+=E}if(l>>>=w,f-=w,n.back+=w,n.length=C,A===0){n.mode=Db;break}if(A&32){n.back=-1,n.mode=mr;break}if(A&64){t.msg="invalid literal/length code",n.mode=qe;break}n.extra=A&15,n.mode=Fb;case Fb:if(n.extra){for(N=n.extra;f<N;){if(s===0)break e;s--,l+=r[a++]<<f,f+=8}n.length+=l&(1<<n.extra)-1,l>>>=n.extra,f-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=Ib;case Ib:for(;y=n.distcode[l&(1<<n.distbits)-1],w=y>>>24,A=y>>>16&255,C=y&65535,!(w<=f);){if(s===0)break e;s--,l+=r[a++]<<f,f+=8}if(!(A&240)){for(E=w,k=A,R=C;y=n.distcode[R+((l&(1<<E+k)-1)>>E)],w=y>>>24,A=y>>>16&255,C=y&65535,!(E+w<=f);){if(s===0)break e;s--,l+=r[a++]<<f,f+=8}l>>>=E,f-=E,n.back+=E}if(l>>>=w,f-=w,n.back+=w,A&64){t.msg="invalid distance code",n.mode=qe;break}n.offset=C,n.extra=A&15,n.mode=kb;case kb:if(n.extra){for(N=n.extra;f<N;){if(s===0)break e;s--,l+=r[a++]<<f,f+=8}n.offset+=l&(1<<n.extra)-1,l>>>=n.extra,f-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){t.msg="invalid distance too far back",n.mode=qe;break}n.mode=Rb;case Rb:if(u===0)break e;if(d=h-u,n.offset>d){if(d=n.offset-d,d>n.whave&&n.sane){t.msg="invalid distance too far back",n.mode=qe;break}d>n.wnext?(d-=n.wnext,p=n.wsize-d):p=n.wnext-d,d>n.length&&(d=n.length),m=n.window}else m=i,p=o-n.offset,d=n.length;d>u&&(d=u),u-=d,n.length-=d;do i[o++]=m[p++];while(--d);n.length===0&&(n.mode=Tu);break;case Db:if(u===0)break e;i[o++]=n.length,u--,n.mode=Tu;break;case Ph:if(n.wrap){for(;f<32;){if(s===0)break e;s--,l|=r[a++]<<f,f+=8}if(h-=u,t.total_out+=h,n.total+=h,h&&(t.adler=n.check=n.flags?Gn(n.check,i,h,o-h):I0(n.check,i,h,o-h)),h=u,(n.flags?l:$b(l))!==n.check){t.msg="incorrect data check",n.mode=qe;break}l=0,f=0}n.mode=Bb;case Bb:if(n.wrap&&n.flags){for(;f<32;){if(s===0)break e;s--,l+=r[a++]<<f,f+=8}if(l!==(n.total&4294967295)){t.msg="incorrect length check",n.mode=qe;break}l=0,f=0}n.mode=Nb;case Nb:O=$N;break e;case qe:O=B2;break e;case O2:return N2;case MN:default:return gn}return t.next_out=o,t.avail_out=u,t.next_in=a,t.avail_in=s,n.hold=l,n.bits=f,(n.wsize||h!==t.avail_out&&n.mode<qe&&(n.mode<Ph||e!==hb))&&U2(t,t.output,t.next_out,h-t.avail_out),c-=t.avail_in,h-=t.avail_out,t.total_in+=c,t.total_out+=h,n.total+=h,n.wrap&&h&&(t.adler=n.check=n.flags?Gn(n.check,i,h,t.next_out-h):I0(n.check,i,h,t.next_out-h)),t.data_type=n.bits+(n.last?64:0)+(n.mode===mr?128:0)+(n.mode===Cu||n.mode===Mh?256:0),(c===0&&h===0||e===hb)&&O===fa&&(O=LN),O}function WN(t){if(!t||!t.state)return gn;var e=t.state;return e.window&&(e.window=null),t.state=null,fa}function ZN(t,e){var n;return!t||!t.state||(n=t.state,!(n.wrap&2))?gn:(n.head=e,e.done=!1,fa)}function YN(t,e){var n=e.length,r,i,a;return!t||!t.state||(r=t.state,r.wrap!==0&&r.mode!==Af)?gn:r.mode===Af&&(i=1,i=I0(i,e,n,0),i!==r.check)?B2:(a=U2(t,e,n,n),a?(r.mode=O2,N2):(r.havedict=1,fa))}$n.inflateReset=M2;$n.inflateReset2=P2;$n.inflateResetKeep=L2;$n.inflateInit=HN;$n.inflateInit2=z2;$n.inflate=jN;$n.inflateEnd=WN;$n.inflateGetHeader=ZN;$n.inflateSetDictionary=YN;$n.inflateInfo="pako inflate (from Nodeca project)";var q2={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};function XN(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}var KN=XN,Wa=$n,vs=Or,Gu=va,Ye=q2,k0=dg,JN=I2,QN=KN,V2=Object.prototype.toString;function ca(t){if(!(this instanceof ca))return new ca(t);this.options=vs.assign({chunkSize:16384,windowBits:0,to:""},t||{});var e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,e.windowBits===0&&(e.windowBits=-15)),e.windowBits>=0&&e.windowBits<16&&!(t&&t.windowBits)&&(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&(e.windowBits&15||(e.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new JN,this.strm.avail_out=0;var n=Wa.inflateInit2(this.strm,e.windowBits);if(n!==Ye.Z_OK)throw new Error(k0[n]);if(this.header=new QN,Wa.inflateGetHeader(this.strm,this.header),e.dictionary&&(typeof e.dictionary=="string"?e.dictionary=Gu.string2buf(e.dictionary):V2.call(e.dictionary)==="[object ArrayBuffer]"&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(n=Wa.inflateSetDictionary(this.strm,e.dictionary),n!==Ye.Z_OK)))throw new Error(k0[n])}ca.prototype.push=function(t,e){var n=this.strm,r=this.options.chunkSize,i=this.options.dictionary,a,o,s,u,l,f=!1;if(this.ended)return!1;o=e===~~e?e:e===!0?Ye.Z_FINISH:Ye.Z_NO_FLUSH,typeof t=="string"?n.input=Gu.binstring2buf(t):V2.call(t)==="[object ArrayBuffer]"?n.input=new Uint8Array(t):n.input=t,n.next_in=0,n.avail_in=n.input.length;do{if(n.avail_out===0&&(n.output=new vs.Buf8(r),n.next_out=0,n.avail_out=r),a=Wa.inflate(n,Ye.Z_NO_FLUSH),a===Ye.Z_NEED_DICT&&i&&(a=Wa.inflateSetDictionary(this.strm,i)),a===Ye.Z_BUF_ERROR&&f===!0&&(a=Ye.Z_OK,f=!1),a!==Ye.Z_STREAM_END&&a!==Ye.Z_OK)return this.onEnd(a),this.ended=!0,!1;n.next_out&&(n.avail_out===0||a===Ye.Z_STREAM_END||n.avail_in===0&&(o===Ye.Z_FINISH||o===Ye.Z_SYNC_FLUSH))&&(this.options.to==="string"?(s=Gu.utf8border(n.output,n.next_out),u=n.next_out-s,l=Gu.buf2string(n.output,s),n.next_out=u,n.avail_out=r-u,u&&vs.arraySet(n.output,n.output,s,u,0),this.onData(l)):this.onData(vs.shrinkBuf(n.output,n.next_out))),n.avail_in===0&&n.avail_out===0&&(f=!0)}while((n.avail_in>0||n.avail_out===0)&&a!==Ye.Z_STREAM_END);return a===Ye.Z_STREAM_END&&(o=Ye.Z_FINISH),o===Ye.Z_FINISH?(a=Wa.inflateEnd(this.strm),this.onEnd(a),this.ended=!0,a===Ye.Z_OK):(o===Ye.Z_SYNC_FLUSH&&(this.onEnd(Ye.Z_OK),n.avail_out=0),!0)};ca.prototype.onData=function(t){this.chunks.push(t)};ca.prototype.onEnd=function(t){t===Ye.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=vs.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};function gg(t,e){var n=new ca(e);if(n.push(t,!0),n.err)throw n.msg||k0[n.err];return n.result}function e$(t,e){return e=e||{},e.raw=!0,gg(t,e)}Xl.Inflate=ca;Xl.inflate=gg;Xl.inflateRaw=e$;Xl.ungzip=gg;var t$=Or.assign,n$=Wl,r$=Xl,i$=q2,H2={};t$(H2,n$,r$,i$);var Sf=H2;async function xo(t){try{let e,n=0,r=0;const i=[];let a=0,o;do{const u=t.subarray(n);if(o=new Sf.Inflate,{strm:e}=o,o.push(u,Sf.Z_SYNC_FLUSH),o.err)throw new Error(o.msg);n+=e.next_in,i[r]=o.result,a+=i[r].length,r+=1}while(e.avail_in);const s=new Uint8Array(a);for(let u=0,l=0;u<i.length;u++)s.set(i[u],l),l+=i[u].length;return Je.Buffer.from(s)}catch(e){throw`${e}`.match(/incorrect header check/)?new Error("problem decompressing block: incorrect gzip header check"):e}}async function G2(t,e){try{let n;const{minv:r,maxv:i}=e;let a=r.blockPosition,o=r.dataPosition;const s=[],u=[],l=[];let f=0,c=0;do{const p=t.subarray(a-r.blockPosition),m=new Sf.Inflate;if({strm:n}=m,m.push(p,Sf.Z_SYNC_FLUSH),m.err)throw new Error(m.msg);const y=m.result;s.push(y);let w=y.length;u.push(a),l.push(o),s.length===1&&r.dataPosition&&(s[0]=s[0].subarray(r.dataPosition),w=s[0].length);const A=a;if(a+=n.next_in,o+=w,A>=i.blockPosition){s[c]=s[c].subarray(0,i.blockPosition===r.blockPosition?i.dataPosition-r.dataPosition+1:i.dataPosition+1),u.push(a),l.push(o),f+=s[c].length;break}f+=s[c].length,c++}while(n.avail_in);const h=new Uint8Array(f);for(let p=0,m=0;p<s.length;p++)h.set(s[p],m),m+=s[p].length;return{buffer:Je.Buffer.from(h),cpositions:u,dpositions:l}}catch(n){throw`${n}`.match(/incorrect header check/)?new Error("problem decompressing block: incorrect gzip header check"):n}}/** - * @license - * Copyright 2009 The Closure Library Authors - * Copyright 2020 Daniel Wirtz / The long.js Authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - */var ln=null;try{ln=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch{}function Me(t,e,n){this.low=t|0,this.high=e|0,this.unsigned=!!n}Me.prototype.__isLong__;Object.defineProperty(Me.prototype,"__isLong__",{value:!0});function Et(t){return(t&&t.__isLong__)===!0}function Lb(t){var e=Math.clz32(t&-t);return t?31-e:e}Me.isLong=Et;var Mb={},Pb={};function Ea(t,e){var n,r,i;return e?(t>>>=0,(i=0<=t&&t<256)&&(r=Pb[t],r)?r:(n=xe(t,0,!0),i&&(Pb[t]=n),n)):(t|=0,(i=-128<=t&&t<128)&&(r=Mb[t],r)?r:(n=xe(t,t<0?-1:0,!1),i&&(Mb[t]=n),n))}Me.fromInt=Ea;function un(t,e){if(isNaN(t))return e?Rr:Fn;if(e){if(t<0)return Rr;if(t>=j2)return Y2}else{if(t<=-Ub)return Pt;if(t+1>=Ub)return Z2}return t<0?un(-t,e).neg():xe(t%_o|0,t/_o|0,e)}Me.fromNumber=un;function xe(t,e,n){return new Me(t,e,n)}Me.fromBits=xe;var Cf=Math.pow;function mg(t,e,n){if(t.length===0)throw Error("empty string");if(typeof e=="number"?(n=e,e=!1):e=!!e,t==="NaN"||t==="Infinity"||t==="+Infinity"||t==="-Infinity")return e?Rr:Fn;if(n=n||10,n<2||36<n)throw RangeError("radix");var r;if((r=t.indexOf("-"))>0)throw Error("interior hyphen");if(r===0)return mg(t.substring(1),e,n).neg();for(var i=un(Cf(n,8)),a=Fn,o=0;o<t.length;o+=8){var s=Math.min(8,t.length-o),u=parseInt(t.substring(o,o+s),n);if(s<8){var l=un(Cf(n,s));a=a.mul(l).add(un(u))}else a=a.mul(i),a=a.add(un(u))}return a.unsigned=e,a}Me.fromString=mg;function On(t,e){return typeof t=="number"?un(t,e):typeof t=="string"?mg(t,e):xe(t.low,t.high,typeof e=="boolean"?e:t.unsigned)}Me.fromValue=On;var zb=65536,a$=1<<24,_o=zb*zb,j2=_o*_o,Ub=j2/2,qb=Ea(a$),Fn=Ea(0);Me.ZERO=Fn;var Rr=Ea(0,!0);Me.UZERO=Rr;var Ua=Ea(1);Me.ONE=Ua;var W2=Ea(1,!0);Me.UONE=W2;var R0=Ea(-1);Me.NEG_ONE=R0;var Z2=xe(-1,2147483647,!1);Me.MAX_VALUE=Z2;var Y2=xe(-1,-1,!0);Me.MAX_UNSIGNED_VALUE=Y2;var Pt=xe(0,-2147483648,!1);Me.MIN_VALUE=Pt;var W=Me.prototype;W.toInt=function(){return this.unsigned?this.low>>>0:this.low};W.toNumber=function(){return this.unsigned?(this.high>>>0)*_o+(this.low>>>0):this.high*_o+(this.low>>>0)};W.toString=function(e){if(e=e||10,e<2||36<e)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative())if(this.eq(Pt)){var n=un(e),r=this.div(n),i=r.mul(n).sub(this);return r.toString(e)+i.toInt().toString(e)}else return"-"+this.neg().toString(e);for(var a=un(Cf(e,6),this.unsigned),o=this,s="";;){var u=o.div(a),l=o.sub(u.mul(a)).toInt()>>>0,f=l.toString(e);if(o=u,o.isZero())return f+s;for(;f.length<6;)f="0"+f;s=""+f+s}};W.getHighBits=function(){return this.high};W.getHighBitsUnsigned=function(){return this.high>>>0};W.getLowBits=function(){return this.low};W.getLowBitsUnsigned=function(){return this.low>>>0};W.getNumBitsAbs=function(){if(this.isNegative())return this.eq(Pt)?64:this.neg().getNumBitsAbs();for(var e=this.high!=0?this.high:this.low,n=31;n>0&&!(e&1<<n);n--);return this.high!=0?n+33:n+1};W.isZero=function(){return this.high===0&&this.low===0};W.eqz=W.isZero;W.isNegative=function(){return!this.unsigned&&this.high<0};W.isPositive=function(){return this.unsigned||this.high>=0};W.isOdd=function(){return(this.low&1)===1};W.isEven=function(){return(this.low&1)===0};W.equals=function(e){return Et(e)||(e=On(e)),this.unsigned!==e.unsigned&&this.high>>>31===1&&e.high>>>31===1?!1:this.high===e.high&&this.low===e.low};W.eq=W.equals;W.notEquals=function(e){return!this.eq(e)};W.neq=W.notEquals;W.ne=W.notEquals;W.lessThan=function(e){return this.comp(e)<0};W.lt=W.lessThan;W.lessThanOrEqual=function(e){return this.comp(e)<=0};W.lte=W.lessThanOrEqual;W.le=W.lessThanOrEqual;W.greaterThan=function(e){return this.comp(e)>0};W.gt=W.greaterThan;W.greaterThanOrEqual=function(e){return this.comp(e)>=0};W.gte=W.greaterThanOrEqual;W.ge=W.greaterThanOrEqual;W.compare=function(e){if(Et(e)||(e=On(e)),this.eq(e))return 0;var n=this.isNegative(),r=e.isNegative();return n&&!r?-1:!n&&r?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1};W.comp=W.compare;W.negate=function(){return!this.unsigned&&this.eq(Pt)?Pt:this.not().add(Ua)};W.neg=W.negate;W.add=function(e){Et(e)||(e=On(e));var n=this.high>>>16,r=this.high&65535,i=this.low>>>16,a=this.low&65535,o=e.high>>>16,s=e.high&65535,u=e.low>>>16,l=e.low&65535,f=0,c=0,h=0,d=0;return d+=a+l,h+=d>>>16,d&=65535,h+=i+u,c+=h>>>16,h&=65535,c+=r+s,f+=c>>>16,c&=65535,f+=n+o,f&=65535,xe(h<<16|d,f<<16|c,this.unsigned)};W.subtract=function(e){return Et(e)||(e=On(e)),this.add(e.neg())};W.sub=W.subtract;W.multiply=function(e){if(this.isZero())return this;if(Et(e)||(e=On(e)),ln){var n=ln.mul(this.low,this.high,e.low,e.high);return xe(n,ln.get_high(),this.unsigned)}if(e.isZero())return this.unsigned?Rr:Fn;if(this.eq(Pt))return e.isOdd()?Pt:Fn;if(e.eq(Pt))return this.isOdd()?Pt:Fn;if(this.isNegative())return e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt(qb)&&e.lt(qb))return un(this.toNumber()*e.toNumber(),this.unsigned);var r=this.high>>>16,i=this.high&65535,a=this.low>>>16,o=this.low&65535,s=e.high>>>16,u=e.high&65535,l=e.low>>>16,f=e.low&65535,c=0,h=0,d=0,p=0;return p+=o*f,d+=p>>>16,p&=65535,d+=a*f,h+=d>>>16,d&=65535,d+=o*l,h+=d>>>16,d&=65535,h+=i*f,c+=h>>>16,h&=65535,h+=a*l,c+=h>>>16,h&=65535,h+=o*u,c+=h>>>16,h&=65535,c+=r*f+i*l+a*u+o*s,c&=65535,xe(d<<16|p,c<<16|h,this.unsigned)};W.mul=W.multiply;W.divide=function(e){if(Et(e)||(e=On(e)),e.isZero())throw Error("division by zero");if(ln){if(!this.unsigned&&this.high===-2147483648&&e.low===-1&&e.high===-1)return this;var n=(this.unsigned?ln.div_u:ln.div_s)(this.low,this.high,e.low,e.high);return xe(n,ln.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?Rr:Fn;var r,i,a;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return Rr;if(e.gt(this.shru(1)))return W2;a=Rr}else{if(this.eq(Pt)){if(e.eq(Ua)||e.eq(R0))return Pt;if(e.eq(Pt))return Ua;var o=this.shr(1);return r=o.div(e).shl(1),r.eq(Fn)?e.isNegative()?Ua:R0:(i=this.sub(e.mul(r)),a=r.add(i.div(e)),a)}else if(e.eq(Pt))return this.unsigned?Rr:Fn;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();a=Fn}for(i=this;i.gte(e);){r=Math.max(1,Math.floor(i.toNumber()/e.toNumber()));for(var s=Math.ceil(Math.log(r)/Math.LN2),u=s<=48?1:Cf(2,s-48),l=un(r),f=l.mul(e);f.isNegative()||f.gt(i);)r-=u,l=un(r,this.unsigned),f=l.mul(e);l.isZero()&&(l=Ua),a=a.add(l),i=i.sub(f)}return a};W.div=W.divide;W.modulo=function(e){if(Et(e)||(e=On(e)),ln){var n=(this.unsigned?ln.rem_u:ln.rem_s)(this.low,this.high,e.low,e.high);return xe(n,ln.get_high(),this.unsigned)}return this.sub(this.div(e).mul(e))};W.mod=W.modulo;W.rem=W.modulo;W.not=function(){return xe(~this.low,~this.high,this.unsigned)};W.countLeadingZeros=function(){return this.high?Math.clz32(this.high):Math.clz32(this.low)+32};W.clz=W.countLeadingZeros;W.countTrailingZeros=function(){return this.low?Lb(this.low):Lb(this.high)+32};W.ctz=W.countTrailingZeros;W.and=function(e){return Et(e)||(e=On(e)),xe(this.low&e.low,this.high&e.high,this.unsigned)};W.or=function(e){return Et(e)||(e=On(e)),xe(this.low|e.low,this.high|e.high,this.unsigned)};W.xor=function(e){return Et(e)||(e=On(e)),xe(this.low^e.low,this.high^e.high,this.unsigned)};W.shiftLeft=function(e){return Et(e)&&(e=e.toInt()),(e&=63)===0?this:e<32?xe(this.low<<e,this.high<<e|this.low>>>32-e,this.unsigned):xe(0,this.low<<e-32,this.unsigned)};W.shl=W.shiftLeft;W.shiftRight=function(e){return Et(e)&&(e=e.toInt()),(e&=63)===0?this:e<32?xe(this.low>>>e|this.high<<32-e,this.high>>e,this.unsigned):xe(this.high>>e-32,this.high>=0?0:-1,this.unsigned)};W.shr=W.shiftRight;W.shiftRightUnsigned=function(e){return Et(e)&&(e=e.toInt()),(e&=63)===0?this:e<32?xe(this.low>>>e|this.high<<32-e,this.high>>>e,this.unsigned):e===32?xe(this.high,0,this.unsigned):xe(this.high>>>e-32,0,this.unsigned)};W.shru=W.shiftRightUnsigned;W.shr_u=W.shiftRightUnsigned;W.rotateLeft=function(e){var n;return Et(e)&&(e=e.toInt()),(e&=63)===0?this:e===32?xe(this.high,this.low,this.unsigned):e<32?(n=32-e,xe(this.low<<e|this.high>>>n,this.high<<e|this.low>>>n,this.unsigned)):(e-=32,n=32-e,xe(this.high<<e|this.low>>>n,this.low<<e|this.high>>>n,this.unsigned))};W.rotl=W.rotateLeft;W.rotateRight=function(e){var n;return Et(e)&&(e=e.toInt()),(e&=63)===0?this:e===32?xe(this.high,this.low,this.unsigned):e<32?(n=32-e,xe(this.high<<n|this.low>>>e,this.low<<n|this.high>>>e,this.unsigned)):(e-=32,n=32-e,xe(this.low<<n|this.high>>>e,this.high<<n|this.low>>>e,this.unsigned))};W.rotr=W.rotateRight;W.toSigned=function(){return this.unsigned?xe(this.low,this.high,!1):this};W.toUnsigned=function(){return this.unsigned?this:xe(this.low,this.high,!0)};W.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()};W.toBytesLE=function(){var e=this.high,n=this.low;return[n&255,n>>>8&255,n>>>16&255,n>>>24,e&255,e>>>8&255,e>>>16&255,e>>>24]};W.toBytesBE=function(){var e=this.high,n=this.low;return[e>>>24,e>>>16&255,e>>>8&255,e&255,n>>>24,n>>>16&255,n>>>8&255,n&255]};Me.fromBytes=function(e,n,r){return r?Me.fromBytesLE(e,n):Me.fromBytesBE(e,n)};Me.fromBytesLE=function(e,n){return new Me(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,n)};Me.fromBytesBE=function(e,n){return new Me(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],n)};function Vb(t,e){return t.offset+t.lineBytes*Math.floor(e/t.lineLength)+e%t.lineLength}async function o$(t,e){const n=await t.readFile(e);if(!(n&&n.length))throw new Error("No data read from FASTA index (FAI) file");let r=0,i;const a=n.toString("utf8").split(/\r?\n/).filter(o=>/\S/.test(o)).map(o=>o.split(" ")).filter(o=>o[0]!=="").map(o=>((!i||i.name!==o[0])&&(i={name:o[0],id:r},r+=1),{id:i.id,name:o[0],length:+o[1],start:0,end:+o[1],offset:+o[2],lineLength:+o[3],lineBytes:+o[4]}));return{name:Object.fromEntries(a.map(o=>[o.name,o])),id:Object.fromEntries(a.map(o=>[o.id,o]))}}class s${constructor({fasta:e,fai:n,path:r,faiPath:i,chunkSizeLimit:a=1e6}){if(e)this.fasta=e;else if(r)this.fasta=new Yt(r);else throw new Error("Need to pass filehandle for fasta or path to localfile");if(n)this.fai=n;else if(i)this.fai=new Yt(i);else if(r)this.fai=new Yt(`${r}.fai`);else throw new Error("Need to pass filehandle for or path to localfile");this.chunkSizeLimit=a}async _getIndexes(e){return this.indexes||(this.indexes=o$(this.fai,e)),this.indexes}async getSequenceNames(e){return Object.keys((await this._getIndexes(e)).name)}async getSequenceSizes(e){const n={},r=await this._getIndexes(e),i=Object.values(r.id);for(let a=0;a<i.length;a+=1)n[i[a].name]=i[a].length;return n}async getSequenceSize(e,n){var r;return(r=(await this._getIndexes(n)).name[e])===null||r===void 0?void 0:r.length}async hasReferenceSequence(e,n){return!!(await this._getIndexes(n)).name[e]}async getResiduesById(e,n,r,i){const a=(await this._getIndexes(i)).id[e];if(a)return this._fetchFromIndexEntry(a,n,r,i)}async getResiduesByName(e,n,r,i){const a=(await this._getIndexes(i)).name[e];if(a)return this._fetchFromIndexEntry(a,n,r,i)}async getSequence(e,n,r,i){return this.getResiduesByName(e,n,r,i)}async _fetchFromIndexEntry(e,n=0,r,i){let a=r;if(n<0)throw new TypeError("regionStart cannot be less than 0");if((a===void 0||a>e.length)&&(a=e.length),n>=a)return"";const o=Vb(e,n),s=Vb(e,a)-o;if(s>this.chunkSizeLimit)throw new Error(`data size of ${s.toLocaleString()} bytes exceeded chunk size limit of ${this.chunkSizeLimit.toLocaleString()} bytes`);const u=Buffer.allocUnsafe(s);return await this.fasta.read(u,0,s,o,i),u.toString("utf8").replace(/\s+/g,"")}}function Kl(t){return class extends t{constructor(){super(...arguments);Gt(this,"lastQuantizedInterval",[0,0])}quantizeInterval(r,i){return[Math.max(Math.floor(r[0]/i-1)*i,0),Math.min(Math.ceil(r[1]/i+1)*i,this.genome.totalSize)]}checkAndUpdateLastInterval(r){return uf(this.lastQuantizedInterval,r)?!1:(this.lastQuantizedInterval=r,!0)}}}function Jl(t,e){return!e||/^(data:|([A-Za-z]+:)?\/\/)/.test(t)||t.startsWith("/")?t:(e.endsWith("/")||(e+="/"),e+t)}typeof window<"u"&&(window.Buffer=Je.Buffer);class l$ extends Kl(wa){constructor(e,n){const r={channel:"x",windowSize:7e3,...e};if(super(n,r.channel),this.params=r,!this.params.url)throw new Error("No URL provided for IndexedFastaSource");const i=a=>new Qn(Jl(a,this.view.getBaseUrl()));this.fasta=new s$({fasta:i(this.params.url),fai:i(this.params.indexUrl??this.params.url+".fai")})}async onDomainChanged(e){const n=this.params.windowSize;if(e[1]-e[0]>n)return;const r=this.quantizeInterval(e,n);if(this.checkAndUpdateLastInterval(r)){const i=this.genome.continuousToDiscreteChromosomeIntervals(r),a=await Promise.all(i.map(o=>this.fasta.getSequence(o.chrom,o.startPos,o.endPos).then(s=>({chrom:o.chrom,start:o.startPos,sequence:s}))));this.publishData(a)}}}const qc=BigInt(32);function u$(t,e,n){const r=+!!n,i=+!n;return BigInt(t.getInt32(e,n)*i+t.getInt32(e+4,n)*r)<<qc|BigInt(t.getUint32(e,n)*r+t.getUint32(e+4,n)*i)}function f$(t,e,n){const r=t.getUint32(e,n),i=t.getUint32(e+4,n),a=+!!n,o=+!n;return BigInt(r*o+i*a)<<qc|BigInt(r*a+i*o)}function c$(t,e,n,r){const i=Number(n>>qc),a=Number(n&BigInt(4294967295));r?(t.setInt32(e+4,i,r),t.setUint32(e,a,r)):(t.setInt32(e,i,r),t.setUint32(e+4,a,r))}function h$(t,e,n,r){const i=Number(n>>qc),a=Number(n&BigInt(4294967295));r?(t.setUint32(e+4,i,r),t.setUint32(e,a,r)):(t.setUint32(e,i,r),t.setUint32(e+4,a,r))}"getBigInt64"in DataView||(DataView.prototype.getBigInt64=function(t,e){return u$(this,t,e)});"getBigUint64"in DataView||(DataView.prototype.getBigUint64=function(t,e){return f$(this,t,e)});"setBigInt64"in DataView||(DataView.prototype.setBigInt64=function(t,e,n){c$(this,t,e,n)});"setBigUint64"in DataView||(DataView.prototype.setBigUint64=function(t,e,n){h$(this,t,e,n)});class d${constructor(e,n){this.code="",this.scopes=[["vars"]],this.bitFields=[],this.tmpVariableCount=0,this.references=new Map,this.imports=[],this.reverseImports=new Map,this.useContextVariables=!1,this.importPath=e,this.useContextVariables=n}generateVariable(e){const n=[...this.scopes[this.scopes.length-1]];return e&&n.push(e),n.join(".")}generateOption(e){switch(typeof e){case"number":return e.toString();case"string":return this.generateVariable(e);case"function":return`${this.addImport(e)}.call(${this.generateVariable()}, vars)`}}generateError(e){this.pushCode(`throw new Error(${e});`)}generateTmpVariable(){return"$tmp"+this.tmpVariableCount++}pushCode(e){this.code+=e+` -`}pushPath(e){e&&this.scopes[this.scopes.length-1].push(e)}popPath(e){e&&this.scopes[this.scopes.length-1].pop()}pushScope(e){this.scopes.push([e])}popScope(){this.scopes.pop()}addImport(e){if(!this.importPath)return`(${e})`;let n=this.reverseImports.get(e);return n||(n=this.imports.push(e)-1,this.reverseImports.set(e,n)),`${this.importPath}[${n}]`}addReference(e){this.references.has(e)||this.references.set(e,{resolved:!1,requested:!1})}markResolved(e){const n=this.references.get(e);n&&(n.resolved=!0)}markRequested(e){e.forEach(n=>{const r=this.references.get(n);r&&(r.requested=!0)})}getUnresolvedReferences(){return Array.from(this.references).filter(([e,n])=>!n.resolved&&!n.requested).map(([e,n])=>e)}}const En=new Map,ki="___parser_",An={uint8:1,uint16le:2,uint16be:2,uint32le:4,uint32be:4,int8:1,int16le:2,int16be:2,int32le:4,int32be:4,int64be:8,int64le:8,uint64be:8,uint64le:8,floatle:4,floatbe:4,doublele:8,doublebe:8},Fu={uint8:"Uint8",uint16le:"Uint16",uint16be:"Uint16",uint32le:"Uint32",uint32be:"Uint32",int8:"Int8",int16le:"Int16",int16be:"Int16",int32le:"Int32",int32be:"Int32",int64be:"BigInt64",int64le:"BigInt64",uint64be:"BigUint64",uint64le:"BigUint64",floatle:"Float32",floatbe:"Float32",doublele:"Float64",doublebe:"Float64"},Iu={uint8:!1,uint16le:!0,uint16be:!1,uint32le:!0,uint32be:!1,int8:!1,int16le:!0,int16be:!1,int32le:!0,int32be:!1,int64be:!1,int64le:!0,uint64be:!1,uint64le:!0,floatle:!0,floatbe:!1,doublele:!0,doublebe:!1};let Ce=class Sn{constructor(){this.varName="",this.type="",this.options={},this.endian="be",this.useContextVariables=!1}static start(){return new Sn}primitiveGenerateN(e,n){const r=Fu[e],i=Iu[e];n.pushCode(`${n.generateVariable(this.varName)} = dataView.get${r}(offset, ${i});`),n.pushCode(`offset += ${An[e]};`)}primitiveN(e,n,r){return this.setNextParser(e,n,r)}useThisEndian(e){return e+this.endian.toLowerCase()}uint8(e,n={}){return this.primitiveN("uint8",e,n)}uint16(e,n={}){return this.primitiveN(this.useThisEndian("uint16"),e,n)}uint16le(e,n={}){return this.primitiveN("uint16le",e,n)}uint16be(e,n={}){return this.primitiveN("uint16be",e,n)}uint32(e,n={}){return this.primitiveN(this.useThisEndian("uint32"),e,n)}uint32le(e,n={}){return this.primitiveN("uint32le",e,n)}uint32be(e,n={}){return this.primitiveN("uint32be",e,n)}int8(e,n={}){return this.primitiveN("int8",e,n)}int16(e,n={}){return this.primitiveN(this.useThisEndian("int16"),e,n)}int16le(e,n={}){return this.primitiveN("int16le",e,n)}int16be(e,n={}){return this.primitiveN("int16be",e,n)}int32(e,n={}){return this.primitiveN(this.useThisEndian("int32"),e,n)}int32le(e,n={}){return this.primitiveN("int32le",e,n)}int32be(e,n={}){return this.primitiveN("int32be",e,n)}bigIntVersionCheck(){if(!DataView.prototype.getBigInt64)throw new Error("BigInt64 is unsupported on this runtime")}int64(e,n={}){return this.bigIntVersionCheck(),this.primitiveN(this.useThisEndian("int64"),e,n)}int64be(e,n={}){return this.bigIntVersionCheck(),this.primitiveN("int64be",e,n)}int64le(e,n={}){return this.bigIntVersionCheck(),this.primitiveN("int64le",e,n)}uint64(e,n={}){return this.bigIntVersionCheck(),this.primitiveN(this.useThisEndian("uint64"),e,n)}uint64be(e,n={}){return this.bigIntVersionCheck(),this.primitiveN("uint64be",e,n)}uint64le(e,n={}){return this.bigIntVersionCheck(),this.primitiveN("uint64le",e,n)}floatle(e,n={}){return this.primitiveN("floatle",e,n)}floatbe(e,n={}){return this.primitiveN("floatbe",e,n)}doublele(e,n={}){return this.primitiveN("doublele",e,n)}doublebe(e,n={}){return this.primitiveN("doublebe",e,n)}bitN(e,n,r){return r.length=e,this.setNextParser("bit",n,r)}bit1(e,n={}){return this.bitN(1,e,n)}bit2(e,n={}){return this.bitN(2,e,n)}bit3(e,n={}){return this.bitN(3,e,n)}bit4(e,n={}){return this.bitN(4,e,n)}bit5(e,n={}){return this.bitN(5,e,n)}bit6(e,n={}){return this.bitN(6,e,n)}bit7(e,n={}){return this.bitN(7,e,n)}bit8(e,n={}){return this.bitN(8,e,n)}bit9(e,n={}){return this.bitN(9,e,n)}bit10(e,n={}){return this.bitN(10,e,n)}bit11(e,n={}){return this.bitN(11,e,n)}bit12(e,n={}){return this.bitN(12,e,n)}bit13(e,n={}){return this.bitN(13,e,n)}bit14(e,n={}){return this.bitN(14,e,n)}bit15(e,n={}){return this.bitN(15,e,n)}bit16(e,n={}){return this.bitN(16,e,n)}bit17(e,n={}){return this.bitN(17,e,n)}bit18(e,n={}){return this.bitN(18,e,n)}bit19(e,n={}){return this.bitN(19,e,n)}bit20(e,n={}){return this.bitN(20,e,n)}bit21(e,n={}){return this.bitN(21,e,n)}bit22(e,n={}){return this.bitN(22,e,n)}bit23(e,n={}){return this.bitN(23,e,n)}bit24(e,n={}){return this.bitN(24,e,n)}bit25(e,n={}){return this.bitN(25,e,n)}bit26(e,n={}){return this.bitN(26,e,n)}bit27(e,n={}){return this.bitN(27,e,n)}bit28(e,n={}){return this.bitN(28,e,n)}bit29(e,n={}){return this.bitN(29,e,n)}bit30(e,n={}){return this.bitN(30,e,n)}bit31(e,n={}){return this.bitN(31,e,n)}bit32(e,n={}){return this.bitN(32,e,n)}namely(e){return En.set(e,this),this.alias=e,this}skip(e,n={}){return this.seek(e,n)}seek(e,n={}){if(n.assert)throw new Error("assert option on seek is not allowed.");return this.setNextParser("seek","",{length:e})}string(e,n){if(!n.zeroTerminated&&!n.length&&!n.greedy)throw new Error("One of length, zeroTerminated, or greedy must be defined for string.");if((n.zeroTerminated||n.length)&&n.greedy)throw new Error("greedy is mutually exclusive with length and zeroTerminated for string.");if(n.stripNull&&!(n.length||n.greedy))throw new Error("length or greedy must be defined if stripNull is enabled.");return n.encoding=n.encoding||"utf8",this.setNextParser("string",e,n)}buffer(e,n){if(!n.length&&!n.readUntil)throw new Error("length or readUntil must be defined for buffer.");return this.setNextParser("buffer",e,n)}wrapped(e,n){if(typeof n!="object"&&typeof e=="object"&&(n=e,e=""),!n||!n.wrapper||!n.type)throw new Error("Both wrapper and type must be defined for wrapped.");if(!n.length&&!n.readUntil)throw new Error("length or readUntil must be defined for wrapped.");return this.setNextParser("wrapper",e,n)}array(e,n){if(!n.readUntil&&!n.length&&!n.lengthInBytes)throw new Error("One of readUntil, length and lengthInBytes must be defined for array.");if(!n.type)throw new Error("type is required for array.");if(typeof n.type=="string"&&!En.has(n.type)&&!(n.type in An))throw new Error(`Array element type "${n.type}" is unkown.`);return this.setNextParser("array",e,n)}choice(e,n){if(typeof n!="object"&&typeof e=="object"&&(n=e,e=""),!n)throw new Error("tag and choices are are required for choice.");if(!n.tag)throw new Error("tag is requird for choice.");if(!n.choices)throw new Error("choices is required for choice.");for(const r in n.choices){const i=parseInt(r,10),a=n.choices[i];if(isNaN(i))throw new Error(`Choice key "${r}" is not a number.`);if(typeof a=="string"&&!En.has(a)&&!(a in An))throw new Error(`Choice type "${a}" is unkown.`)}return this.setNextParser("choice",e,n)}nest(e,n){if(typeof n!="object"&&typeof e=="object"&&(n=e,e=""),!n||!n.type)throw new Error("type is required for nest.");if(!(n.type instanceof Sn)&&!En.has(n.type))throw new Error("type must be a known parser name or a Parser object.");if(!(n.type instanceof Sn)&&!e)throw new Error("type must be a Parser object if the variable name is omitted.");return this.setNextParser("nest",e,n)}pointer(e,n){if(!n.offset)throw new Error("offset is required for pointer.");if(!n.type)throw new Error("type is required for pointer.");if(typeof n.type=="string"&&!(n.type in An)&&!En.has(n.type))throw new Error(`Pointer type "${n.type}" is unkown.`);return this.setNextParser("pointer",e,n)}saveOffset(e,n={}){return this.setNextParser("saveOffset",e,n)}endianness(e){switch(e.toLowerCase()){case"little":this.endian="le";break;case"big":this.endian="be";break;default:throw new Error('endianness must be one of "little" or "big"')}return this}endianess(e){return this.endianness(e)}useContextVars(e=!0){return this.useContextVariables=e,this}create(e){if(!(e instanceof Function))throw new Error("Constructor must be a Function object.");return this.constructorFn=e,this}getContext(e){const n=new d$(e,this.useContextVariables);return n.pushCode("var dataView = new DataView(buffer.buffer, buffer.byteOffset, buffer.length);"),this.alias?(this.addAliasedCode(n),n.pushCode(`return ${ki+this.alias}(0).result;`)):this.addRawCode(n),n}getCode(){const e="imports";return this.getContext(e).code}addRawCode(e){e.pushCode("var offset = 0;"),e.pushCode(`var vars = ${this.constructorFn?"new constructorFn()":"{}"};`),e.pushCode("vars.$parent = null;"),e.pushCode("vars.$root = vars;"),this.generate(e),this.resolveReferences(e),e.pushCode("delete vars.$parent;"),e.pushCode("delete vars.$root;"),e.pushCode("return vars;")}addAliasedCode(e){return e.pushCode(`function ${ki+this.alias}(offset, context) {`),e.pushCode(`var vars = ${this.constructorFn?"new constructorFn()":"{}"};`),e.pushCode("var ctx = Object.assign({$parent: null, $root: vars}, context || {});"),e.pushCode("vars = Object.assign(vars, ctx);"),this.generate(e),e.markResolved(this.alias),this.resolveReferences(e),e.pushCode("Object.keys(ctx).forEach(function (item) { delete vars[item]; });"),e.pushCode("return { offset: offset, result: vars };"),e.pushCode("}"),e}resolveReferences(e){const n=e.getUnresolvedReferences();e.markRequested(n),n.forEach(r=>{var i;(i=En.get(r))===null||i===void 0||i.addAliasedCode(e)})}compile(){const e="imports",n=this.getContext(e);this.compiled=new Function(e,"TextDecoder",`return function (buffer, constructorFn) { ${n.code} };`)(n.imports,TextDecoder)}sizeOf(){let e=NaN;if(Object.keys(An).indexOf(this.type)>=0)e=An[this.type];else if(this.type==="string"&&typeof this.options.length=="number")e=this.options.length;else if(this.type==="buffer"&&typeof this.options.length=="number")e=this.options.length;else if(this.type==="array"&&typeof this.options.length=="number"){let n=NaN;typeof this.options.type=="string"?n=An[this.options.type]:this.options.type instanceof Sn&&(n=this.options.type.sizeOf()),e=this.options.length*n}else this.type==="seek"?e=this.options.length:this.type==="nest"?e=this.options.type.sizeOf():this.type||(e=0);return this.next&&(e+=this.next.sizeOf()),e}parse(e){return this.compiled||this.compile(),this.compiled(e,this.constructorFn)}setNextParser(e,n,r){const i=new Sn;return i.type=e,i.varName=n,i.options=r,i.endian=this.endian,this.head?this.head.next=i:this.next=i,this.head=i,this}generate(e){if(this.type){switch(this.type){case"uint8":case"uint16le":case"uint16be":case"uint32le":case"uint32be":case"int8":case"int16le":case"int16be":case"int32le":case"int32be":case"int64be":case"int64le":case"uint64be":case"uint64le":case"floatle":case"floatbe":case"doublele":case"doublebe":this.primitiveGenerateN(this.type,e);break;case"bit":this.generateBit(e);break;case"string":this.generateString(e);break;case"buffer":this.generateBuffer(e);break;case"seek":this.generateSeek(e);break;case"nest":this.generateNest(e);break;case"array":this.generateArray(e);break;case"choice":this.generateChoice(e);break;case"pointer":this.generatePointer(e);break;case"saveOffset":this.generateSaveOffset(e);break;case"wrapper":this.generateWrapper(e);break}this.type!=="bit"&&this.generateAssert(e)}const n=e.generateVariable(this.varName);return this.options.formatter&&this.type!=="bit"&&this.generateFormatter(e,n,this.options.formatter),this.generateNext(e)}generateAssert(e){if(!this.options.assert)return;const n=e.generateVariable(this.varName);switch(typeof this.options.assert){case"function":{const r=e.addImport(this.options.assert);e.pushCode(`if (!${r}.call(vars, ${n})) {`)}break;case"number":e.pushCode(`if (${this.options.assert} !== ${n}) {`);break;case"string":e.pushCode(`if (${JSON.stringify(this.options.assert)} !== ${n}) {`);break;default:throw new Error("assert option must be a string, number or a function.")}e.generateError(`"Assertion error: ${n} is " + ${JSON.stringify(this.options.assert.toString())}`),e.pushCode("}")}generateNext(e){return this.next&&(e=this.next.generate(e)),e}generateBit(e){const n=JSON.parse(JSON.stringify(this));if(n.options=this.options,n.generateAssert=this.generateAssert.bind(this),n.generateFormatter=this.generateFormatter.bind(this),n.varName=e.generateVariable(n.varName),e.bitFields.push(n),!this.next||this.next&&["bit","nest"].indexOf(this.next.type)<0){const r=e.generateTmpVariable();e.pushCode(`var ${r} = 0;`);const i=(f=0)=>{let c=0;for(let h=f;h<e.bitFields.length;h++){const d=e.bitFields[h].options.length;if(c+d>32)break;c+=d}return c},a=f=>(f<=8?(e.pushCode(`${r} = dataView.getUint8(offset);`),f=8):f<=16?(e.pushCode(`${r} = dataView.getUint16(offset);`),f=16):f<=24?(e.pushCode(`${r} = (dataView.getUint16(offset) << 8) | dataView.getUint8(offset + 2);`),f=24):(e.pushCode(`${r} = dataView.getUint32(offset);`),f=32),e.pushCode(`offset += ${f/8};`),f);let o=0;const s=this.endian==="be";let u=0,l=0;e.bitFields.forEach((f,c)=>{let h=f.options.length;if(h>l){if(l){const m=-1>>>32-l;e.pushCode(`${f.varName} = (${r} & 0x${m.toString(16)}) << ${h-l};`),h-=l}o=0,l=u=a(i(c)-l)}const d=s?u-o-h:o,p=-1>>>32-h;e.pushCode(`${f.varName} ${h<f.options.length?"|=":"="} ${r} >> ${d} & 0x${p.toString(16)};`),f.options.length===32&&e.pushCode(`${f.varName} >>>= 0`),f.options.assert&&f.generateAssert(e),f.options.formatter&&f.generateFormatter(e,f.varName,f.options.formatter),o+=h,l-=h}),e.bitFields=[]}}generateSeek(e){const n=e.generateOption(this.options.length);e.pushCode(`offset += ${n};`)}generateString(e){const n=e.generateVariable(this.varName),r=e.generateTmpVariable(),i=this.options.encoding,a=i.toLowerCase()==="hex",o='b => b.toString(16).padStart(2, "0")';if(this.options.length&&this.options.zeroTerminated){const s=this.options.length;e.pushCode(`var ${r} = offset;`),e.pushCode(`while(dataView.getUint8(offset++) !== 0 && offset - ${r} < ${s});`);const u=`offset - ${r} < ${s} ? offset - 1 : offset`;e.pushCode(a?`${n} = Array.from(buffer.subarray(${r}, ${u}), ${o}).join('');`:`${n} = new TextDecoder('${i}').decode(buffer.subarray(${r}, ${u}));`)}else if(this.options.length){const s=e.generateOption(this.options.length);e.pushCode(a?`${n} = Array.from(buffer.subarray(offset, offset + ${s}), ${o}).join('');`:`${n} = new TextDecoder('${i}').decode(buffer.subarray(offset, offset + ${s}));`),e.pushCode(`offset += ${s};`)}else this.options.zeroTerminated?(e.pushCode(`var ${r} = offset;`),e.pushCode("while(dataView.getUint8(offset++) !== 0);"),e.pushCode(a?`${n} = Array.from(buffer.subarray(${r}, offset - 1), ${o}).join('');`:`${n} = new TextDecoder('${i}').decode(buffer.subarray(${r}, offset - 1));`)):this.options.greedy&&(e.pushCode(`var ${r} = offset;`),e.pushCode("while(buffer.length > offset++);"),e.pushCode(a?`${n} = Array.from(buffer.subarray(${r}, offset), ${o}).join('');`:`${n} = new TextDecoder('${i}').decode(buffer.subarray(${r}, offset));`));this.options.stripNull&&e.pushCode(`${n} = ${n}.replace(/\\x00+$/g, '')`)}generateBuffer(e){const n=e.generateVariable(this.varName);if(typeof this.options.readUntil=="function"){const r=this.options.readUntil,i=e.generateTmpVariable(),a=e.generateTmpVariable();e.pushCode(`var ${i} = offset;`),e.pushCode(`var ${a} = 0;`),e.pushCode("while (offset < buffer.length) {"),e.pushCode(`${a} = dataView.getUint8(offset);`);const o=e.addImport(r);e.pushCode(`if (${o}.call(${e.generateVariable()}, ${a}, buffer.subarray(offset))) break;`),e.pushCode("offset += 1;"),e.pushCode("}"),e.pushCode(`${n} = buffer.subarray(${i}, offset);`)}else if(this.options.readUntil==="eof")e.pushCode(`${n} = buffer.subarray(offset);`);else{const r=e.generateOption(this.options.length);e.pushCode(`${n} = buffer.subarray(offset, offset + ${r});`),e.pushCode(`offset += ${r};`)}this.options.clone&&e.pushCode(`${n} = buffer.constructor.from(${n});`)}generateArray(e){const n=e.generateOption(this.options.length),r=e.generateOption(this.options.lengthInBytes),i=this.options.type,a=e.generateTmpVariable(),o=e.generateVariable(this.varName),s=e.generateTmpVariable(),u=this.options.key,l=typeof u=="string";if(l?e.pushCode(`${o} = {};`):e.pushCode(`${o} = [];`),typeof this.options.readUntil=="function"?e.pushCode("do {"):this.options.readUntil==="eof"?e.pushCode(`for (var ${a} = 0; offset < buffer.length; ${a}++) {`):r!==void 0?e.pushCode(`for (var ${a} = offset + ${r}; offset < ${a}; ) {`):e.pushCode(`for (var ${a} = ${n}; ${a} > 0; ${a}--) {`),typeof i=="string")if(En.get(i)){const f=e.generateTmpVariable();if(e.pushCode(`var ${f} = ${ki+i}(offset, {`),e.useContextVariables){const c=e.generateVariable();e.pushCode(`$parent: ${c},`),e.pushCode(`$root: ${c}.$root,`),!this.options.readUntil&&r===void 0&&e.pushCode(`$index: ${n} - ${a},`)}e.pushCode("});"),e.pushCode(`var ${s} = ${f}.result; offset = ${f}.offset;`),i!==this.alias&&e.addReference(i)}else{const f=Fu[i],c=Iu[i];e.pushCode(`var ${s} = dataView.get${f}(offset, ${c});`),e.pushCode(`offset += ${An[i]};`)}else if(i instanceof Sn){e.pushCode(`var ${s} = {};`);const f=e.generateVariable();e.pushScope(s),e.useContextVariables&&(e.pushCode(`${s}.$parent = ${f};`),e.pushCode(`${s}.$root = ${f}.$root;`),!this.options.readUntil&&r===void 0&&e.pushCode(`${s}.$index = ${n} - ${a};`)),i.generate(e),e.useContextVariables&&(e.pushCode(`delete ${s}.$parent;`),e.pushCode(`delete ${s}.$root;`),e.pushCode(`delete ${s}.$index;`)),e.popScope()}if(l?e.pushCode(`${o}[${s}.${u}] = ${s};`):e.pushCode(`${o}.push(${s});`),e.pushCode("}"),typeof this.options.readUntil=="function"){const f=this.options.readUntil,c=e.addImport(f);e.pushCode(`while (!${c}.call(${e.generateVariable()}, ${s}, buffer.subarray(offset)));`)}}generateChoiceCase(e,n,r){if(typeof r=="string"){const i=e.generateVariable(this.varName);if(En.has(r)){const a=e.generateTmpVariable();e.pushCode(`var ${a} = ${ki+r}(offset, {`),e.useContextVariables&&(e.pushCode(`$parent: ${i}.$parent,`),e.pushCode(`$root: ${i}.$root,`)),e.pushCode("});"),e.pushCode(`${i} = ${a}.result; offset = ${a}.offset;`),r!==this.alias&&e.addReference(r)}else{const a=Fu[r],o=Iu[r];e.pushCode(`${i} = dataView.get${a}(offset, ${o});`),e.pushCode(`offset += ${An[r]}`)}}else r instanceof Sn&&(e.pushPath(n),r.generate(e),e.popPath(n))}generateChoice(e){const n=e.generateOption(this.options.tag),r=e.generateVariable(this.varName);if(this.varName&&(e.pushCode(`${r} = {};`),e.useContextVariables)){const i=e.generateVariable();e.pushCode(`${r}.$parent = ${i};`),e.pushCode(`${r}.$root = ${i}.$root;`)}e.pushCode(`switch(${n}) {`);for(const i in this.options.choices){const a=parseInt(i,10),o=this.options.choices[a];e.pushCode(`case ${a}:`),this.generateChoiceCase(e,this.varName,o),e.pushCode("break;")}e.pushCode("default:"),this.options.defaultChoice?this.generateChoiceCase(e,this.varName,this.options.defaultChoice):e.generateError(`"Met undefined tag value " + ${n} + " at choice"`),e.pushCode("}"),this.varName&&e.useContextVariables&&(e.pushCode(`delete ${r}.$parent;`),e.pushCode(`delete ${r}.$root;`))}generateNest(e){const n=e.generateVariable(this.varName);if(this.options.type instanceof Sn){if(this.varName&&(e.pushCode(`${n} = {};`),e.useContextVariables)){const r=e.generateVariable();e.pushCode(`${n}.$parent = ${r};`),e.pushCode(`${n}.$root = ${r}.$root;`)}e.pushPath(this.varName),this.options.type.generate(e),e.popPath(this.varName),this.varName&&e.useContextVariables&&e.useContextVariables&&(e.pushCode(`delete ${n}.$parent;`),e.pushCode(`delete ${n}.$root;`))}else if(En.has(this.options.type)){const r=e.generateTmpVariable();if(e.pushCode(`var ${r} = ${ki+this.options.type}(offset, {`),e.useContextVariables){const i=e.generateVariable();e.pushCode(`$parent: ${i},`),e.pushCode(`$root: ${i}.$root,`)}e.pushCode("});"),e.pushCode(`${n} = ${r}.result; offset = ${r}.offset;`),this.options.type!==this.alias&&e.addReference(this.options.type)}}generateWrapper(e){const n=e.generateVariable(this.varName),r=e.generateTmpVariable();if(typeof this.options.readUntil=="function"){const u=this.options.readUntil,l=e.generateTmpVariable(),f=e.generateTmpVariable();e.pushCode(`var ${l} = offset;`),e.pushCode(`var ${f} = 0;`),e.pushCode("while (offset < buffer.length) {"),e.pushCode(`${f} = dataView.getUint8(offset);`);const c=e.addImport(u);e.pushCode(`if (${c}.call(${e.generateVariable()}, ${f}, buffer.subarray(offset))) break;`),e.pushCode("offset += 1;"),e.pushCode("}"),e.pushCode(`${r} = buffer.subarray(${l}, offset);`)}else if(this.options.readUntil==="eof")e.pushCode(`${r} = buffer.subarray(offset);`);else{const u=e.generateOption(this.options.length);e.pushCode(`${r} = buffer.subarray(offset, offset + ${u});`),e.pushCode(`offset += ${u};`)}this.options.clone&&e.pushCode(`${r} = buffer.constructor.from(${r});`);const i=e.generateTmpVariable(),a=e.generateTmpVariable(),o=e.generateTmpVariable(),s=e.addImport(this.options.wrapper);if(e.pushCode(`${r} = ${s}.call(this, ${r}).subarray(0);`),e.pushCode(`var ${i} = buffer;`),e.pushCode(`var ${a} = offset;`),e.pushCode(`var ${o} = dataView;`),e.pushCode(`buffer = ${r};`),e.pushCode("offset = 0;"),e.pushCode("dataView = new DataView(buffer.buffer, buffer.byteOffset, buffer.length);"),this.options.type instanceof Sn)this.varName&&e.pushCode(`${n} = {};`),e.pushPath(this.varName),this.options.type.generate(e),e.popPath(this.varName);else if(En.has(this.options.type)){const u=e.generateTmpVariable();e.pushCode(`var ${u} = ${ki+this.options.type}(0);`),e.pushCode(`${n} = ${u}.result;`),this.options.type!==this.alias&&e.addReference(this.options.type)}e.pushCode(`buffer = ${i};`),e.pushCode(`dataView = ${o};`),e.pushCode(`offset = ${a};`)}generateFormatter(e,n,r){if(typeof r=="function"){const i=e.addImport(r);e.pushCode(`${n} = ${i}.call(${e.generateVariable()}, ${n});`)}}generatePointer(e){const n=this.options.type,r=e.generateOption(this.options.offset),i=e.generateTmpVariable(),a=e.generateVariable(this.varName);if(e.pushCode(`var ${i} = offset;`),e.pushCode(`offset = ${r};`),this.options.type instanceof Sn){if(e.pushCode(`${a} = {};`),e.useContextVariables){const o=e.generateVariable();e.pushCode(`${a}.$parent = ${o};`),e.pushCode(`${a}.$root = ${o}.$root;`)}e.pushPath(this.varName),this.options.type.generate(e),e.popPath(this.varName),e.useContextVariables&&(e.pushCode(`delete ${a}.$parent;`),e.pushCode(`delete ${a}.$root;`))}else if(En.has(this.options.type)){const o=e.generateTmpVariable();if(e.pushCode(`var ${o} = ${ki+this.options.type}(offset, {`),e.useContextVariables){const s=e.generateVariable();e.pushCode(`$parent: ${s},`),e.pushCode(`$root: ${s}.$root,`)}e.pushCode("});"),e.pushCode(`${a} = ${o}.result; offset = ${o}.offset;`),this.options.type!==this.alias&&e.addReference(this.options.type)}else if(Object.keys(An).indexOf(this.options.type)>=0){const o=Fu[n],s=Iu[n];e.pushCode(`${a} = dataView.get${o}(offset, ${s});`),e.pushCode(`offset += ${An[n]};`)}e.pushCode(`offset = ${i};`)}generateSaveOffset(e){const n=e.generateVariable(this.varName);e.pushCode(`${n} = offset`)}};var X2={},bg={},ha={},Ql={};Object.defineProperty(Ql,"__esModule",{value:!0});function yg(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Hb(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function wg(t,e,n){return e&&Hb(t.prototype,e),n&&Hb(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function p$(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&D0(t,e)}function vo(t){return vo=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},vo(t)}function D0(t,e){return D0=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,i){return r.__proto__=i,r},D0(t,e)}function g$(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function ls(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function m$(t,e){if(e&&(typeof e=="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return ls(t)}function b$(t){var e=g$();return function(){var r=vo(t),i;if(e){var a=vo(this).constructor;i=Reflect.construct(r,arguments,a)}else i=r.apply(this,arguments);return m$(this,i)}}function y$(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&(t=vo(t),t!==null););return t}function ju(){return typeof Reflect<"u"&&Reflect.get?ju=Reflect.get.bind():ju=function(e,n,r){var i=y$(e,n);if(i){var a=Object.getOwnPropertyDescriptor(i,n);return a.get?a.get.call(arguments.length<3?e:r):a.value}},ju.apply(this,arguments)}var Gb=function(){function t(){yg(this,t),Object.defineProperty(this,"listeners",{value:{},writable:!0,configurable:!0})}return wg(t,[{key:"addEventListener",value:function(n,r,i){n in this.listeners||(this.listeners[n]=[]),this.listeners[n].push({callback:r,options:i})}},{key:"removeEventListener",value:function(n,r){if(n in this.listeners){for(var i=this.listeners[n],a=0,o=i.length;a<o;a++)if(i[a].callback===r){i.splice(a,1);return}}}},{key:"dispatchEvent",value:function(n){if(n.type in this.listeners){for(var r=this.listeners[n.type],i=r.slice(),a=0,o=i.length;a<o;a++){var s=i[a];try{s.callback.call(this,n)}catch(u){Promise.resolve().then(function(){throw u})}s.options&&s.options.once&&this.removeEventListener(n.type,s.callback)}return!n.defaultPrevented}}}]),t}(),xg=function(t){p$(n,t);var e=b$(n);function n(){var r;return yg(this,n),r=e.call(this),r.listeners||Gb.call(ls(r)),Object.defineProperty(ls(r),"aborted",{value:!1,writable:!0,configurable:!0}),Object.defineProperty(ls(r),"onabort",{value:null,writable:!0,configurable:!0}),Object.defineProperty(ls(r),"reason",{value:void 0,writable:!0,configurable:!0}),r}return wg(n,[{key:"toString",value:function(){return"[object AbortSignal]"}},{key:"dispatchEvent",value:function(i){i.type==="abort"&&(this.aborted=!0,typeof this.onabort=="function"&&this.onabort.call(this,i)),ju(vo(n.prototype),"dispatchEvent",this).call(this,i)}}]),n}(Gb),K2=function(){function t(){yg(this,t),Object.defineProperty(this,"signal",{value:new xg,writable:!0,configurable:!0})}return wg(t,[{key:"abort",value:function(n){var r;try{r=new Event("abort")}catch{typeof document<"u"?document.createEvent?(r=document.createEvent("Event"),r.initEvent("abort",!1,!1)):(r=document.createEventObject(),r.type="abort"):r={type:"abort",bubbles:!1,cancelable:!1}}var i=n;if(i===void 0)if(typeof document>"u")i=new Error("This operation was aborted"),i.name="AbortError";else try{i=new DOMException("signal is aborted without reason")}catch{i=new Error("This operation was aborted"),i.name="AbortError"}this.signal.reason=i,this.signal.dispatchEvent(r)}},{key:"toString",value:function(){return"[object AbortController]"}}]),t}();typeof Symbol<"u"&&Symbol.toStringTag&&(K2.prototype[Symbol.toStringTag]="AbortController",xg.prototype[Symbol.toStringTag]="AbortSignal");function w$(t){return t.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL?(console.log("__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL=true is set, will force install polyfill"),!0):typeof t.Request=="function"&&!t.Request.prototype.hasOwnProperty("signal")||!t.AbortController}function x$(t){typeof t=="function"&&(t={fetch:t});var e=t,n=e.fetch,r=e.Request,i=r===void 0?n.Request:r,a=e.AbortController,o=e.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL,s=o===void 0?!1:o;if(!w$({fetch:n,Request:i,AbortController:a,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:s}))return{fetch:n,Request:u};var u=i;(u&&!u.prototype.hasOwnProperty("signal")||s)&&(u=function(h,d){var p;d&&d.signal&&(p=d.signal,delete d.signal);var m=new i(h,d);return p&&Object.defineProperty(m,"signal",{writable:!1,enumerable:!1,configurable:!0,value:p}),m},u.prototype=i.prototype);var l=n,f=function(h,d){var p=u&&u.prototype.isPrototypeOf(h)?h.signal:d?d.signal:void 0;if(p){var m;try{m=new DOMException("Aborted","AbortError")}catch{m=new Error("Aborted"),m.name="AbortError"}if(p.aborted)return Promise.reject(m);var y=new Promise(function(w,A){p.addEventListener("abort",function(){return A(m)},{once:!0})});return d&&d.signal&&delete d.signal,Promise.race([y,l(h,d)])}return l(h,d)};return{fetch:f,Request:u}}Ql.AbortController=K2;Ql.AbortSignal=xg;Ql.abortableFetch=x$;Object.defineProperty(ha,"__esModule",{value:!0});ha.AbortSignal=ha.AbortController=void 0;const J2=Ql;var Tf=function(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof Qt<"u")return Qt;throw new Error("unable to locate global object")};let _$=typeof Tf().AbortController>"u"?J2.AbortController:Tf().AbortController;ha.AbortController=_$;let v$=typeof Tf().AbortController>"u"?J2.AbortSignal:Tf().AbortSignal;ha.AbortSignal=v$;var _g={};Object.defineProperty(_g,"__esModule",{value:!0});const E$=ha;class A${}class S${constructor(){this.signals=new Set,this.abortController=new E$.AbortController}addSignal(e=new A$){if(this.signal.aborted)throw new Error("cannot add a signal, already aborted!");this.signals.add(e),e.aborted?this.handleAborted(e):typeof e.addEventListener=="function"&&e.addEventListener("abort",()=>{this.handleAborted(e)})}handleAborted(e){this.signals.delete(e),this.signals.size===0&&this.abortController.abort()}get signal(){return this.abortController.signal}abort(){this.abortController.abort()}}_g.default=S$;var vg={};Object.defineProperty(vg,"__esModule",{value:!0});class C${constructor(){this.callbacks=new Set}addCallback(e=()=>{}){this.callbacks.add(e),e(this.currentMessage)}callback(e){this.currentMessage=e,this.callbacks.forEach(n=>{n(e)})}}vg.default=C$;var Q2=Qt&&Qt.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(bg,"__esModule",{value:!0});const T$=ha,F$=Q2(_g),I$=Q2(vg);class Ff{constructor({fill:e,cache:n}){if(typeof e!="function")throw new TypeError("must pass a fill function");if(typeof n!="object")throw new TypeError("must pass a cache object");if(typeof n.get!="function"||typeof n.set!="function"||typeof n.delete!="function")throw new TypeError("cache must implement get(key), set(key, val), and and delete(key)");this.cache=n,this.fillCallback=e}static isAbortException(e){return e.name==="AbortError"||e.code==="ERR_ABORTED"||e.message==="AbortError: aborted"||e.message==="Error: aborted"}evict(e,n){this.cache.get(e)===n&&this.cache.delete(e)}fill(e,n,r,i){const a=new F$.default,o=new I$.default;o.addCallback(i);const s={aborter:a,promise:this.fillCallback(n,a.signal,u=>{o.callback(u)}),settled:!1,statusReporter:o,get aborted(){return this.aborter.signal.aborted}};s.aborter.addSignal(r),s.aborter.signal.addEventListener("abort",()=>{s.settled||this.evict(e,s)}),s.promise.then(()=>{s.settled=!0},()=>{s.settled=!0,this.evict(e,s)}).catch(u=>{throw console.error(u),u}),this.cache.set(e,s)}static checkSinglePromise(e,n){function r(){if(n&&n.aborted)throw Object.assign(new Error("aborted"),{code:"ERR_ABORTED"})}return e.then(i=>(r(),i),i=>{throw r(),i})}has(e){return this.cache.has(e)}get(e,n,r,i){if(!r&&n instanceof T$.AbortSignal)throw new TypeError("second get argument appears to be an AbortSignal, perhaps you meant to pass `null` for the fill data?");const a=this.cache.get(e);return a?a.aborted&&!a.settled?(this.evict(e,a),this.get(e,n,r,i)):a.settled?a.promise:(a.aborter.addSignal(r),a.statusReporter.addCallback(i),Ff.checkSinglePromise(a.promise,r)):(this.fill(e,n,r,i),Ff.checkSinglePromise(this.cache.get(e).promise,r))}delete(e){const n=this.cache.get(e);n&&(n.settled||n.aborter.abort(),this.cache.delete(e))}clear(){const e=this.cache.keys();let n=0;for(let r=e.next();!r.done;r=e.next())this.delete(r.value),n+=1;return n}}bg.default=Ff;var k$=Qt&&Qt.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(X2,"__esModule",{value:!0});const R$=k$(bg);var Vc=X2.default=R$.default;let D$=class{constructor(e={}){if(!(e.maxSize&&e.maxSize>0))throw new TypeError("`maxSize` must be a number greater than 0");this.maxSize=e.maxSize,this.cache=new Map,this.oldCache=new Map,this._size=0}_set(e,n){this.cache.set(e,n),this._size++,this._size>=this.maxSize&&(this._size=0,this.oldCache=this.cache,this.cache=new Map)}get(e){if(this.cache.has(e))return this.cache.get(e);if(this.oldCache.has(e)){const n=this.oldCache.get(e);return this.oldCache.delete(e),this._set(e,n),n}}set(e,n){return this.cache.has(e)?this.cache.set(e,n):this._set(e,n),this}has(e){return this.cache.has(e)||this.oldCache.has(e)}peek(e){if(this.cache.has(e))return this.cache.get(e);if(this.oldCache.has(e))return this.oldCache.get(e)}delete(e){const n=this.cache.delete(e);return n&&this._size--,this.oldCache.delete(e)||n}clear(){this.cache.clear(),this.oldCache.clear(),this._size=0}*keys(){for(const[e]of this)yield e}*values(){for(const[,e]of this)yield e}*[Symbol.iterator](){for(const e of this.cache)yield e;for(const e of this.oldCache){const[n]=e;this.cache.has(n)||(yield e)}}get size(){let e=0;for(const n of this.oldCache.keys())this.cache.has(n)||e++;return this._size+e}};var B$=D$;const eE=xa(B$);class Jr{constructor(e,n){this.ranges=arguments.length===2?[{min:e,max:n}]:0 in e?Object.assign({},e):[e]}min(){return this.ranges[0].min}max(){return this.ranges[this.ranges.length-1].max}contains(e){for(let n=0;n<this.ranges.length;n+=1){const r=this.ranges[n];if(r.min<=e&&r.max>=e)return!0}return!1}isContiguous(){return this.ranges.length>1}getRanges(){return this.ranges.map(e=>new Jr(e.min,e.max))}toString(){return this.ranges.map(e=>`[${e.min}-${e.max}]`).join(",")}union(e){const n=this.getRanges().concat(e.getRanges()).sort(this.rangeOrder),r=[];let i=n[0];for(let a=1;a<n.length;a+=1){const o=n[a];o.min()>i.max()+1?(r.push(i),i=o):o.max()>i.max()&&(i=new Jr(i.min(),o.max()))}return r.push(i),r.length===1?r[0]:new Jr(r)}intersection(e){let n=this,r=e;const i=this.ranges(),a=r.ranges(),o=i.length,s=a.length;let u=0,l=0;const f=[];for(;u<o&&l<s;){n=i[u],r=a[l];const c=Math.max(n.min(),r.min()),h=Math.min(n.max(),r.max());h>=c&&f.push(new Jr(c,h)),n.max()>r.max()?l+=1:u+=1}if(f.length===0)throw new Error("found range of length 0");return f.length===1?f[0]:new Jr(f)}coverage(){let e=0;const n=this.ranges();for(const r of n)e+=r.max()-r.min()+1;return e}rangeOrder(e,n){let r=e,i=n;return arguments.length<2&&(i=r,r=this),r.min()<i.min()?-1:r.min()>i.min()?1:r.max()<i.max()?-1:i.max()>r.max()?1:0}}/*! pako 2.1.0 https://github.com/nodeca/pako @license (MIT AND Zlib) */const N$=4,jb=0,Wb=1,$$=2;function zo(t){let e=t.length;for(;--e>=0;)t[e]=0}const O$=0,tE=1,L$=2,M$=3,P$=258,Eg=29,eu=256,il=eu+1+Eg,Za=30,Ag=19,nE=2*il+1,zi=15,qh=16,z$=7,Sg=256,rE=16,iE=17,aE=18,B0=new Uint8Array([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]),Wu=new Uint8Array([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]),U$=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),oE=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),q$=512,vr=new Array((il+2)*2);zo(vr);const Es=new Array(Za*2);zo(Es);const al=new Array(q$);zo(al);const ol=new Array(P$-M$+1);zo(ol);const Cg=new Array(Eg);zo(Cg);const If=new Array(Za);zo(If);function Vh(t,e,n,r,i){this.static_tree=t,this.extra_bits=e,this.extra_base=n,this.elems=r,this.max_length=i,this.has_stree=t&&t.length}let sE,lE,uE;function Hh(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}const fE=t=>t<256?al[t]:al[256+(t>>>7)],sl=(t,e)=>{t.pending_buf[t.pending++]=e&255,t.pending_buf[t.pending++]=e>>>8&255},zt=(t,e,n)=>{t.bi_valid>qh-n?(t.bi_buf|=e<<t.bi_valid&65535,sl(t,t.bi_buf),t.bi_buf=e>>qh-t.bi_valid,t.bi_valid+=n-qh):(t.bi_buf|=e<<t.bi_valid&65535,t.bi_valid+=n)},Jn=(t,e,n)=>{zt(t,n[e*2],n[e*2+1])},cE=(t,e)=>{let n=0;do n|=t&1,t>>>=1,n<<=1;while(--e>0);return n>>>1},V$=t=>{t.bi_valid===16?(sl(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=t.bi_buf&255,t.bi_buf>>=8,t.bi_valid-=8)},H$=(t,e)=>{const n=e.dyn_tree,r=e.max_code,i=e.stat_desc.static_tree,a=e.stat_desc.has_stree,o=e.stat_desc.extra_bits,s=e.stat_desc.extra_base,u=e.stat_desc.max_length;let l,f,c,h,d,p,m=0;for(h=0;h<=zi;h++)t.bl_count[h]=0;for(n[t.heap[t.heap_max]*2+1]=0,l=t.heap_max+1;l<nE;l++)f=t.heap[l],h=n[n[f*2+1]*2+1]+1,h>u&&(h=u,m++),n[f*2+1]=h,!(f>r)&&(t.bl_count[h]++,d=0,f>=s&&(d=o[f-s]),p=n[f*2],t.opt_len+=p*(h+d),a&&(t.static_len+=p*(i[f*2+1]+d)));if(m!==0){do{for(h=u-1;t.bl_count[h]===0;)h--;t.bl_count[h]--,t.bl_count[h+1]+=2,t.bl_count[u]--,m-=2}while(m>0);for(h=u;h!==0;h--)for(f=t.bl_count[h];f!==0;)c=t.heap[--l],!(c>r)&&(n[c*2+1]!==h&&(t.opt_len+=(h-n[c*2+1])*n[c*2],n[c*2+1]=h),f--)}},hE=(t,e,n)=>{const r=new Array(zi+1);let i=0,a,o;for(a=1;a<=zi;a++)i=i+n[a-1]<<1,r[a]=i;for(o=0;o<=e;o++){let s=t[o*2+1];s!==0&&(t[o*2]=cE(r[s]++,s))}},G$=()=>{let t,e,n,r,i;const a=new Array(zi+1);for(n=0,r=0;r<Eg-1;r++)for(Cg[r]=n,t=0;t<1<<B0[r];t++)ol[n++]=r;for(ol[n-1]=r,i=0,r=0;r<16;r++)for(If[r]=i,t=0;t<1<<Wu[r];t++)al[i++]=r;for(i>>=7;r<Za;r++)for(If[r]=i<<7,t=0;t<1<<Wu[r]-7;t++)al[256+i++]=r;for(e=0;e<=zi;e++)a[e]=0;for(t=0;t<=143;)vr[t*2+1]=8,t++,a[8]++;for(;t<=255;)vr[t*2+1]=9,t++,a[9]++;for(;t<=279;)vr[t*2+1]=7,t++,a[7]++;for(;t<=287;)vr[t*2+1]=8,t++,a[8]++;for(hE(vr,il+1,a),t=0;t<Za;t++)Es[t*2+1]=5,Es[t*2]=cE(t,5);sE=new Vh(vr,B0,eu+1,il,zi),lE=new Vh(Es,Wu,0,Za,zi),uE=new Vh(new Array(0),U$,0,Ag,z$)},dE=t=>{let e;for(e=0;e<il;e++)t.dyn_ltree[e*2]=0;for(e=0;e<Za;e++)t.dyn_dtree[e*2]=0;for(e=0;e<Ag;e++)t.bl_tree[e*2]=0;t.dyn_ltree[Sg*2]=1,t.opt_len=t.static_len=0,t.sym_next=t.matches=0},pE=t=>{t.bi_valid>8?sl(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0},Zb=(t,e,n,r)=>{const i=e*2,a=n*2;return t[i]<t[a]||t[i]===t[a]&&r[e]<=r[n]},Gh=(t,e,n)=>{const r=t.heap[n];let i=n<<1;for(;i<=t.heap_len&&(i<t.heap_len&&Zb(e,t.heap[i+1],t.heap[i],t.depth)&&i++,!Zb(e,r,t.heap[i],t.depth));)t.heap[n]=t.heap[i],n=i,i<<=1;t.heap[n]=r},Yb=(t,e,n)=>{let r,i,a=0,o,s;if(t.sym_next!==0)do r=t.pending_buf[t.sym_buf+a++]&255,r+=(t.pending_buf[t.sym_buf+a++]&255)<<8,i=t.pending_buf[t.sym_buf+a++],r===0?Jn(t,i,e):(o=ol[i],Jn(t,o+eu+1,e),s=B0[o],s!==0&&(i-=Cg[o],zt(t,i,s)),r--,o=fE(r),Jn(t,o,n),s=Wu[o],s!==0&&(r-=If[o],zt(t,r,s)));while(a<t.sym_next);Jn(t,Sg,e)},N0=(t,e)=>{const n=e.dyn_tree,r=e.stat_desc.static_tree,i=e.stat_desc.has_stree,a=e.stat_desc.elems;let o,s,u=-1,l;for(t.heap_len=0,t.heap_max=nE,o=0;o<a;o++)n[o*2]!==0?(t.heap[++t.heap_len]=u=o,t.depth[o]=0):n[o*2+1]=0;for(;t.heap_len<2;)l=t.heap[++t.heap_len]=u<2?++u:0,n[l*2]=1,t.depth[l]=0,t.opt_len--,i&&(t.static_len-=r[l*2+1]);for(e.max_code=u,o=t.heap_len>>1;o>=1;o--)Gh(t,n,o);l=a;do o=t.heap[1],t.heap[1]=t.heap[t.heap_len--],Gh(t,n,1),s=t.heap[1],t.heap[--t.heap_max]=o,t.heap[--t.heap_max]=s,n[l*2]=n[o*2]+n[s*2],t.depth[l]=(t.depth[o]>=t.depth[s]?t.depth[o]:t.depth[s])+1,n[o*2+1]=n[s*2+1]=l,t.heap[1]=l++,Gh(t,n,1);while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],H$(t,e),hE(n,u,t.bl_count)},Xb=(t,e,n)=>{let r,i=-1,a,o=e[0*2+1],s=0,u=7,l=4;for(o===0&&(u=138,l=3),e[(n+1)*2+1]=65535,r=0;r<=n;r++)a=o,o=e[(r+1)*2+1],!(++s<u&&a===o)&&(s<l?t.bl_tree[a*2]+=s:a!==0?(a!==i&&t.bl_tree[a*2]++,t.bl_tree[rE*2]++):s<=10?t.bl_tree[iE*2]++:t.bl_tree[aE*2]++,s=0,i=a,o===0?(u=138,l=3):a===o?(u=6,l=3):(u=7,l=4))},Kb=(t,e,n)=>{let r,i=-1,a,o=e[0*2+1],s=0,u=7,l=4;for(o===0&&(u=138,l=3),r=0;r<=n;r++)if(a=o,o=e[(r+1)*2+1],!(++s<u&&a===o)){if(s<l)do Jn(t,a,t.bl_tree);while(--s!==0);else a!==0?(a!==i&&(Jn(t,a,t.bl_tree),s--),Jn(t,rE,t.bl_tree),zt(t,s-3,2)):s<=10?(Jn(t,iE,t.bl_tree),zt(t,s-3,3)):(Jn(t,aE,t.bl_tree),zt(t,s-11,7));s=0,i=a,o===0?(u=138,l=3):a===o?(u=6,l=3):(u=7,l=4)}},j$=t=>{let e;for(Xb(t,t.dyn_ltree,t.l_desc.max_code),Xb(t,t.dyn_dtree,t.d_desc.max_code),N0(t,t.bl_desc),e=Ag-1;e>=3&&t.bl_tree[oE[e]*2+1]===0;e--);return t.opt_len+=3*(e+1)+5+5+4,e},W$=(t,e,n,r)=>{let i;for(zt(t,e-257,5),zt(t,n-1,5),zt(t,r-4,4),i=0;i<r;i++)zt(t,t.bl_tree[oE[i]*2+1],3);Kb(t,t.dyn_ltree,e-1),Kb(t,t.dyn_dtree,n-1)},Z$=t=>{let e=4093624447,n;for(n=0;n<=31;n++,e>>>=1)if(e&1&&t.dyn_ltree[n*2]!==0)return jb;if(t.dyn_ltree[9*2]!==0||t.dyn_ltree[10*2]!==0||t.dyn_ltree[13*2]!==0)return Wb;for(n=32;n<eu;n++)if(t.dyn_ltree[n*2]!==0)return Wb;return jb};let Jb=!1;const Y$=t=>{Jb||(G$(),Jb=!0),t.l_desc=new Hh(t.dyn_ltree,sE),t.d_desc=new Hh(t.dyn_dtree,lE),t.bl_desc=new Hh(t.bl_tree,uE),t.bi_buf=0,t.bi_valid=0,dE(t)},gE=(t,e,n,r)=>{zt(t,(O$<<1)+(r?1:0),3),pE(t),sl(t,n),sl(t,~n),n&&t.pending_buf.set(t.window.subarray(e,e+n),t.pending),t.pending+=n},X$=t=>{zt(t,tE<<1,3),Jn(t,Sg,vr),V$(t)},K$=(t,e,n,r)=>{let i,a,o=0;t.level>0?(t.strm.data_type===$$&&(t.strm.data_type=Z$(t)),N0(t,t.l_desc),N0(t,t.d_desc),o=j$(t),i=t.opt_len+3+7>>>3,a=t.static_len+3+7>>>3,a<=i&&(i=a)):i=a=n+5,n+4<=i&&e!==-1?gE(t,e,n,r):t.strategy===N$||a===i?(zt(t,(tE<<1)+(r?1:0),3),Yb(t,vr,Es)):(zt(t,(L$<<1)+(r?1:0),3),W$(t,t.l_desc.max_code+1,t.d_desc.max_code+1,o+1),Yb(t,t.dyn_ltree,t.dyn_dtree)),dE(t),r&&pE(t)},J$=(t,e,n)=>(t.pending_buf[t.sym_buf+t.sym_next++]=e,t.pending_buf[t.sym_buf+t.sym_next++]=e>>8,t.pending_buf[t.sym_buf+t.sym_next++]=n,e===0?t.dyn_ltree[n*2]++:(t.matches++,e--,t.dyn_ltree[(ol[n]+eu+1)*2]++,t.dyn_dtree[fE(e)*2]++),t.sym_next===t.sym_end);var Q$=Y$,eO=gE,tO=K$,nO=J$,rO=X$,iO={_tr_init:Q$,_tr_stored_block:eO,_tr_flush_block:tO,_tr_tally:nO,_tr_align:rO};const aO=(t,e,n,r)=>{let i=t&65535|0,a=t>>>16&65535|0,o=0;for(;n!==0;){o=n>2e3?2e3:n,n-=o;do i=i+e[r++]|0,a=a+i|0;while(--o);i%=65521,a%=65521}return i|a<<16|0};var ll=aO;const oO=()=>{let t,e=[];for(var n=0;n<256;n++){t=n;for(var r=0;r<8;r++)t=t&1?3988292384^t>>>1:t>>>1;e[n]=t}return e},sO=new Uint32Array(oO()),lO=(t,e,n,r)=>{const i=sO,a=r+n;t^=-1;for(let o=r;o<a;o++)t=t>>>8^i[(t^e[o])&255];return t^-1};var at=lO,Eo={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"},tu={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:uO,_tr_stored_block:$0,_tr_flush_block:fO,_tr_tally:ai,_tr_align:cO}=iO,{Z_NO_FLUSH:oi,Z_PARTIAL_FLUSH:hO,Z_FULL_FLUSH:dO,Z_FINISH:an,Z_BLOCK:Qb,Z_OK:ht,Z_STREAM_END:ey,Z_STREAM_ERROR:ir,Z_DATA_ERROR:pO,Z_BUF_ERROR:jh,Z_DEFAULT_COMPRESSION:gO,Z_FILTERED:mO,Z_HUFFMAN_ONLY:ku,Z_RLE:bO,Z_FIXED:yO,Z_DEFAULT_STRATEGY:wO,Z_UNKNOWN:xO,Z_DEFLATED:Hc}=tu,_O=9,vO=15,EO=8,AO=29,SO=256,O0=SO+1+AO,CO=30,TO=19,FO=2*O0+1,IO=15,pe=3,ni=258,ar=ni+pe+1,kO=32,Ao=42,Tg=57,L0=69,M0=73,P0=91,z0=103,Ui=113,us=666,Tt=1,Uo=2,da=3,qo=4,RO=3,qi=(t,e)=>(t.msg=Eo[e],e),ty=t=>t*2-(t>4?9:0),Qr=t=>{let e=t.length;for(;--e>=0;)t[e]=0},DO=t=>{let e,n,r,i=t.w_size;e=t.hash_size,r=e;do n=t.head[--r],t.head[r]=n>=i?n-i:0;while(--e);e=i,r=e;do n=t.prev[--r],t.prev[r]=n>=i?n-i:0;while(--e)};let BO=(t,e,n)=>(e<<t.hash_shift^n)&t.hash_mask,si=BO;const jt=t=>{const e=t.state;let n=e.pending;n>t.avail_out&&(n=t.avail_out),n!==0&&(t.output.set(e.pending_buf.subarray(e.pending_out,e.pending_out+n),t.next_out),t.next_out+=n,e.pending_out+=n,t.total_out+=n,t.avail_out-=n,e.pending-=n,e.pending===0&&(e.pending_out=0))},Kt=(t,e)=>{fO(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,jt(t.strm)},ve=(t,e)=>{t.pending_buf[t.pending++]=e},ns=(t,e)=>{t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=e&255},U0=(t,e,n,r)=>{let i=t.avail_in;return i>r&&(i=r),i===0?0:(t.avail_in-=i,e.set(t.input.subarray(t.next_in,t.next_in+i),n),t.state.wrap===1?t.adler=ll(t.adler,e,i,n):t.state.wrap===2&&(t.adler=at(t.adler,e,i,n)),t.next_in+=i,t.total_in+=i,i)},mE=(t,e)=>{let n=t.max_chain_length,r=t.strstart,i,a,o=t.prev_length,s=t.nice_match;const u=t.strstart>t.w_size-ar?t.strstart-(t.w_size-ar):0,l=t.window,f=t.w_mask,c=t.prev,h=t.strstart+ni;let d=l[r+o-1],p=l[r+o];t.prev_length>=t.good_match&&(n>>=2),s>t.lookahead&&(s=t.lookahead);do if(i=e,!(l[i+o]!==p||l[i+o-1]!==d||l[i]!==l[r]||l[++i]!==l[r+1])){r+=2,i++;do;while(l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&r<h);if(a=ni-(h-r),r=h-ni,a>o){if(t.match_start=e,o=a,a>=s)break;d=l[r+o-1],p=l[r+o]}}while((e=c[e&f])>u&&--n!==0);return o<=t.lookahead?o:t.lookahead},So=t=>{const e=t.w_size;let n,r,i;do{if(r=t.window_size-t.lookahead-t.strstart,t.strstart>=e+(e-ar)&&(t.window.set(t.window.subarray(e,e+e-r),0),t.match_start-=e,t.strstart-=e,t.block_start-=e,t.insert>t.strstart&&(t.insert=t.strstart),DO(t),r+=e),t.strm.avail_in===0)break;if(n=U0(t.strm,t.window,t.strstart+t.lookahead,r),t.lookahead+=n,t.lookahead+t.insert>=pe)for(i=t.strstart-t.insert,t.ins_h=t.window[i],t.ins_h=si(t,t.ins_h,t.window[i+1]);t.insert&&(t.ins_h=si(t,t.ins_h,t.window[i+pe-1]),t.prev[i&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=i,i++,t.insert--,!(t.lookahead+t.insert<pe)););}while(t.lookahead<ar&&t.strm.avail_in!==0)},bE=(t,e)=>{let n=t.pending_buf_size-5>t.w_size?t.w_size:t.pending_buf_size-5,r,i,a,o=0,s=t.strm.avail_in;do{if(r=65535,a=t.bi_valid+42>>3,t.strm.avail_out<a||(a=t.strm.avail_out-a,i=t.strstart-t.block_start,r>i+t.strm.avail_in&&(r=i+t.strm.avail_in),r>a&&(r=a),r<n&&(r===0&&e!==an||e===oi||r!==i+t.strm.avail_in)))break;o=e===an&&r===i+t.strm.avail_in?1:0,$0(t,0,0,o),t.pending_buf[t.pending-4]=r,t.pending_buf[t.pending-3]=r>>8,t.pending_buf[t.pending-2]=~r,t.pending_buf[t.pending-1]=~r>>8,jt(t.strm),i&&(i>r&&(i=r),t.strm.output.set(t.window.subarray(t.block_start,t.block_start+i),t.strm.next_out),t.strm.next_out+=i,t.strm.avail_out-=i,t.strm.total_out+=i,t.block_start+=i,r-=i),r&&(U0(t.strm,t.strm.output,t.strm.next_out,r),t.strm.next_out+=r,t.strm.avail_out-=r,t.strm.total_out+=r)}while(o===0);return s-=t.strm.avail_in,s&&(s>=t.w_size?(t.matches=2,t.window.set(t.strm.input.subarray(t.strm.next_in-t.w_size,t.strm.next_in),0),t.strstart=t.w_size,t.insert=t.strstart):(t.window_size-t.strstart<=s&&(t.strstart-=t.w_size,t.window.set(t.window.subarray(t.w_size,t.w_size+t.strstart),0),t.matches<2&&t.matches++,t.insert>t.strstart&&(t.insert=t.strstart)),t.window.set(t.strm.input.subarray(t.strm.next_in-s,t.strm.next_in),t.strstart),t.strstart+=s,t.insert+=s>t.w_size-t.insert?t.w_size-t.insert:s),t.block_start=t.strstart),t.high_water<t.strstart&&(t.high_water=t.strstart),o?qo:e!==oi&&e!==an&&t.strm.avail_in===0&&t.strstart===t.block_start?Uo:(a=t.window_size-t.strstart,t.strm.avail_in>a&&t.block_start>=t.w_size&&(t.block_start-=t.w_size,t.strstart-=t.w_size,t.window.set(t.window.subarray(t.w_size,t.w_size+t.strstart),0),t.matches<2&&t.matches++,a+=t.w_size,t.insert>t.strstart&&(t.insert=t.strstart)),a>t.strm.avail_in&&(a=t.strm.avail_in),a&&(U0(t.strm,t.window,t.strstart,a),t.strstart+=a,t.insert+=a>t.w_size-t.insert?t.w_size-t.insert:a),t.high_water<t.strstart&&(t.high_water=t.strstart),a=t.bi_valid+42>>3,a=t.pending_buf_size-a>65535?65535:t.pending_buf_size-a,n=a>t.w_size?t.w_size:a,i=t.strstart-t.block_start,(i>=n||(i||e===an)&&e!==oi&&t.strm.avail_in===0&&i<=a)&&(r=i>a?a:i,o=e===an&&t.strm.avail_in===0&&r===i?1:0,$0(t,t.block_start,r,o),t.block_start+=r,jt(t.strm)),o?da:Tt)},Wh=(t,e)=>{let n,r;for(;;){if(t.lookahead<ar){if(So(t),t.lookahead<ar&&e===oi)return Tt;if(t.lookahead===0)break}if(n=0,t.lookahead>=pe&&(t.ins_h=si(t,t.ins_h,t.window[t.strstart+pe-1]),n=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),n!==0&&t.strstart-n<=t.w_size-ar&&(t.match_length=mE(t,n)),t.match_length>=pe)if(r=ai(t,t.strstart-t.match_start,t.match_length-pe),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=pe){t.match_length--;do t.strstart++,t.ins_h=si(t,t.ins_h,t.window[t.strstart+pe-1]),n=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart;while(--t.match_length!==0);t.strstart++}else t.strstart+=t.match_length,t.match_length=0,t.ins_h=t.window[t.strstart],t.ins_h=si(t,t.ins_h,t.window[t.strstart+1]);else r=ai(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(r&&(Kt(t,!1),t.strm.avail_out===0))return Tt}return t.insert=t.strstart<pe-1?t.strstart:pe-1,e===an?(Kt(t,!0),t.strm.avail_out===0?da:qo):t.sym_next&&(Kt(t,!1),t.strm.avail_out===0)?Tt:Uo},$a=(t,e)=>{let n,r,i;for(;;){if(t.lookahead<ar){if(So(t),t.lookahead<ar&&e===oi)return Tt;if(t.lookahead===0)break}if(n=0,t.lookahead>=pe&&(t.ins_h=si(t,t.ins_h,t.window[t.strstart+pe-1]),n=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),t.prev_length=t.match_length,t.prev_match=t.match_start,t.match_length=pe-1,n!==0&&t.prev_length<t.max_lazy_match&&t.strstart-n<=t.w_size-ar&&(t.match_length=mE(t,n),t.match_length<=5&&(t.strategy===mO||t.match_length===pe&&t.strstart-t.match_start>4096)&&(t.match_length=pe-1)),t.prev_length>=pe&&t.match_length<=t.prev_length){i=t.strstart+t.lookahead-pe,r=ai(t,t.strstart-1-t.prev_match,t.prev_length-pe),t.lookahead-=t.prev_length-1,t.prev_length-=2;do++t.strstart<=i&&(t.ins_h=si(t,t.ins_h,t.window[t.strstart+pe-1]),n=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart);while(--t.prev_length!==0);if(t.match_available=0,t.match_length=pe-1,t.strstart++,r&&(Kt(t,!1),t.strm.avail_out===0))return Tt}else if(t.match_available){if(r=ai(t,0,t.window[t.strstart-1]),r&&Kt(t,!1),t.strstart++,t.lookahead--,t.strm.avail_out===0)return Tt}else t.match_available=1,t.strstart++,t.lookahead--}return t.match_available&&(r=ai(t,0,t.window[t.strstart-1]),t.match_available=0),t.insert=t.strstart<pe-1?t.strstart:pe-1,e===an?(Kt(t,!0),t.strm.avail_out===0?da:qo):t.sym_next&&(Kt(t,!1),t.strm.avail_out===0)?Tt:Uo},NO=(t,e)=>{let n,r,i,a;const o=t.window;for(;;){if(t.lookahead<=ni){if(So(t),t.lookahead<=ni&&e===oi)return Tt;if(t.lookahead===0)break}if(t.match_length=0,t.lookahead>=pe&&t.strstart>0&&(i=t.strstart-1,r=o[i],r===o[++i]&&r===o[++i]&&r===o[++i])){a=t.strstart+ni;do;while(r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&i<a);t.match_length=ni-(a-i),t.match_length>t.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=pe?(n=ai(t,1,t.match_length-pe),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(n=ai(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),n&&(Kt(t,!1),t.strm.avail_out===0))return Tt}return t.insert=0,e===an?(Kt(t,!0),t.strm.avail_out===0?da:qo):t.sym_next&&(Kt(t,!1),t.strm.avail_out===0)?Tt:Uo},$O=(t,e)=>{let n;for(;;){if(t.lookahead===0&&(So(t),t.lookahead===0)){if(e===oi)return Tt;break}if(t.match_length=0,n=ai(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,n&&(Kt(t,!1),t.strm.avail_out===0))return Tt}return t.insert=0,e===an?(Kt(t,!0),t.strm.avail_out===0?da:qo):t.sym_next&&(Kt(t,!1),t.strm.avail_out===0)?Tt:Uo};function jn(t,e,n,r,i){this.good_length=t,this.max_lazy=e,this.nice_length=n,this.max_chain=r,this.func=i}const fs=[new jn(0,0,0,0,bE),new jn(4,4,8,4,Wh),new jn(4,5,16,8,Wh),new jn(4,6,32,32,Wh),new jn(4,4,16,16,$a),new jn(8,16,32,32,$a),new jn(8,16,128,128,$a),new jn(8,32,128,256,$a),new jn(32,128,258,1024,$a),new jn(32,258,258,4096,$a)],OO=t=>{t.window_size=2*t.w_size,Qr(t.head),t.max_lazy_match=fs[t.level].max_lazy,t.good_match=fs[t.level].good_length,t.nice_match=fs[t.level].nice_length,t.max_chain_length=fs[t.level].max_chain,t.strstart=0,t.block_start=0,t.lookahead=0,t.insert=0,t.match_length=t.prev_length=pe-1,t.match_available=0,t.ins_h=0};function LO(){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=Hc,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 Uint16Array(FO*2),this.dyn_dtree=new Uint16Array((2*CO+1)*2),this.bl_tree=new Uint16Array((2*TO+1)*2),Qr(this.dyn_ltree),Qr(this.dyn_dtree),Qr(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(IO+1),this.heap=new Uint16Array(2*O0+1),Qr(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*O0+1),Qr(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const nu=t=>{if(!t)return 1;const e=t.state;return!e||e.strm!==t||e.status!==Ao&&e.status!==Tg&&e.status!==L0&&e.status!==M0&&e.status!==P0&&e.status!==z0&&e.status!==Ui&&e.status!==us?1:0},yE=t=>{if(nu(t))return qi(t,ir);t.total_in=t.total_out=0,t.data_type=xO;const e=t.state;return e.pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=e.wrap===2?Tg:e.wrap?Ao:Ui,t.adler=e.wrap===2?0:1,e.last_flush=-2,uO(e),ht},wE=t=>{const e=yE(t);return e===ht&&OO(t.state),e},MO=(t,e)=>nu(t)||t.state.wrap!==2?ir:(t.state.gzhead=e,ht),xE=(t,e,n,r,i,a)=>{if(!t)return ir;let o=1;if(e===gO&&(e=6),r<0?(o=0,r=-r):r>15&&(o=2,r-=16),i<1||i>_O||n!==Hc||r<8||r>15||e<0||e>9||a<0||a>yO||r===8&&o!==1)return qi(t,ir);r===8&&(r=9);const s=new LO;return t.state=s,s.strm=t,s.status=Ao,s.wrap=o,s.gzhead=null,s.w_bits=r,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+pe-1)/pe),s.window=new Uint8Array(s.w_size*2),s.head=new Uint16Array(s.hash_size),s.prev=new Uint16Array(s.w_size),s.lit_bufsize=1<<i+6,s.pending_buf_size=s.lit_bufsize*4,s.pending_buf=new Uint8Array(s.pending_buf_size),s.sym_buf=s.lit_bufsize,s.sym_end=(s.lit_bufsize-1)*3,s.level=e,s.strategy=a,s.method=n,wE(t)},PO=(t,e)=>xE(t,e,Hc,vO,EO,wO),zO=(t,e)=>{if(nu(t)||e>Qb||e<0)return t?qi(t,ir):ir;const n=t.state;if(!t.output||t.avail_in!==0&&!t.input||n.status===us&&e!==an)return qi(t,t.avail_out===0?jh:ir);const r=n.last_flush;if(n.last_flush=e,n.pending!==0){if(jt(t),t.avail_out===0)return n.last_flush=-1,ht}else if(t.avail_in===0&&ty(e)<=ty(r)&&e!==an)return qi(t,jh);if(n.status===us&&t.avail_in!==0)return qi(t,jh);if(n.status===Ao&&n.wrap===0&&(n.status=Ui),n.status===Ao){let i=Hc+(n.w_bits-8<<4)<<8,a=-1;if(n.strategy>=ku||n.level<2?a=0:n.level<6?a=1:n.level===6?a=2:a=3,i|=a<<6,n.strstart!==0&&(i|=kO),i+=31-i%31,ns(n,i),n.strstart!==0&&(ns(n,t.adler>>>16),ns(n,t.adler&65535)),t.adler=1,n.status=Ui,jt(t),n.pending!==0)return n.last_flush=-1,ht}if(n.status===Tg){if(t.adler=0,ve(n,31),ve(n,139),ve(n,8),n.gzhead)ve(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)),ve(n,n.gzhead.time&255),ve(n,n.gzhead.time>>8&255),ve(n,n.gzhead.time>>16&255),ve(n,n.gzhead.time>>24&255),ve(n,n.level===9?2:n.strategy>=ku||n.level<2?4:0),ve(n,n.gzhead.os&255),n.gzhead.extra&&n.gzhead.extra.length&&(ve(n,n.gzhead.extra.length&255),ve(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(t.adler=at(t.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=L0;else if(ve(n,0),ve(n,0),ve(n,0),ve(n,0),ve(n,0),ve(n,n.level===9?2:n.strategy>=ku||n.level<2?4:0),ve(n,RO),n.status=Ui,jt(t),n.pending!==0)return n.last_flush=-1,ht}if(n.status===L0){if(n.gzhead.extra){let i=n.pending,a=(n.gzhead.extra.length&65535)-n.gzindex;for(;n.pending+a>n.pending_buf_size;){let s=n.pending_buf_size-n.pending;if(n.pending_buf.set(n.gzhead.extra.subarray(n.gzindex,n.gzindex+s),n.pending),n.pending=n.pending_buf_size,n.gzhead.hcrc&&n.pending>i&&(t.adler=at(t.adler,n.pending_buf,n.pending-i,i)),n.gzindex+=s,jt(t),n.pending!==0)return n.last_flush=-1,ht;i=0,a-=s}let o=new Uint8Array(n.gzhead.extra);n.pending_buf.set(o.subarray(n.gzindex,n.gzindex+a),n.pending),n.pending+=a,n.gzhead.hcrc&&n.pending>i&&(t.adler=at(t.adler,n.pending_buf,n.pending-i,i)),n.gzindex=0}n.status=M0}if(n.status===M0){if(n.gzhead.name){let i=n.pending,a;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>i&&(t.adler=at(t.adler,n.pending_buf,n.pending-i,i)),jt(t),n.pending!==0)return n.last_flush=-1,ht;i=0}n.gzindex<n.gzhead.name.length?a=n.gzhead.name.charCodeAt(n.gzindex++)&255:a=0,ve(n,a)}while(a!==0);n.gzhead.hcrc&&n.pending>i&&(t.adler=at(t.adler,n.pending_buf,n.pending-i,i)),n.gzindex=0}n.status=P0}if(n.status===P0){if(n.gzhead.comment){let i=n.pending,a;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>i&&(t.adler=at(t.adler,n.pending_buf,n.pending-i,i)),jt(t),n.pending!==0)return n.last_flush=-1,ht;i=0}n.gzindex<n.gzhead.comment.length?a=n.gzhead.comment.charCodeAt(n.gzindex++)&255:a=0,ve(n,a)}while(a!==0);n.gzhead.hcrc&&n.pending>i&&(t.adler=at(t.adler,n.pending_buf,n.pending-i,i))}n.status=z0}if(n.status===z0){if(n.gzhead.hcrc){if(n.pending+2>n.pending_buf_size&&(jt(t),n.pending!==0))return n.last_flush=-1,ht;ve(n,t.adler&255),ve(n,t.adler>>8&255),t.adler=0}if(n.status=Ui,jt(t),n.pending!==0)return n.last_flush=-1,ht}if(t.avail_in!==0||n.lookahead!==0||e!==oi&&n.status!==us){let i=n.level===0?bE(n,e):n.strategy===ku?$O(n,e):n.strategy===bO?NO(n,e):fs[n.level].func(n,e);if((i===da||i===qo)&&(n.status=us),i===Tt||i===da)return t.avail_out===0&&(n.last_flush=-1),ht;if(i===Uo&&(e===hO?cO(n):e!==Qb&&($0(n,0,0,!1),e===dO&&(Qr(n.head),n.lookahead===0&&(n.strstart=0,n.block_start=0,n.insert=0))),jt(t),t.avail_out===0))return n.last_flush=-1,ht}return e!==an?ht:n.wrap<=0?ey:(n.wrap===2?(ve(n,t.adler&255),ve(n,t.adler>>8&255),ve(n,t.adler>>16&255),ve(n,t.adler>>24&255),ve(n,t.total_in&255),ve(n,t.total_in>>8&255),ve(n,t.total_in>>16&255),ve(n,t.total_in>>24&255)):(ns(n,t.adler>>>16),ns(n,t.adler&65535)),jt(t),n.wrap>0&&(n.wrap=-n.wrap),n.pending!==0?ht:ey)},UO=t=>{if(nu(t))return ir;const e=t.state.status;return t.state=null,e===Ui?qi(t,pO):ht},qO=(t,e)=>{let n=e.length;if(nu(t))return ir;const r=t.state,i=r.wrap;if(i===2||i===1&&r.status!==Ao||r.lookahead)return ir;if(i===1&&(t.adler=ll(t.adler,e,n,0)),r.wrap=0,n>=r.w_size){i===0&&(Qr(r.head),r.strstart=0,r.block_start=0,r.insert=0);let u=new Uint8Array(r.w_size);u.set(e.subarray(n-r.w_size,n),0),e=u,n=r.w_size}const a=t.avail_in,o=t.next_in,s=t.input;for(t.avail_in=n,t.next_in=0,t.input=e,So(r);r.lookahead>=pe;){let u=r.strstart,l=r.lookahead-(pe-1);do r.ins_h=si(r,r.ins_h,r.window[u+pe-1]),r.prev[u&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=u,u++;while(--l);r.strstart=u,r.lookahead=pe-1,So(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=pe-1,r.match_available=0,t.next_in=o,t.input=s,t.avail_in=a,r.wrap=i,ht};var VO=PO,HO=xE,GO=wE,jO=yE,WO=MO,ZO=zO,YO=UO,XO=qO,KO="pako deflate (from Nodeca project)",As={deflateInit:VO,deflateInit2:HO,deflateReset:GO,deflateResetKeep:jO,deflateSetHeader:WO,deflate:ZO,deflateEnd:YO,deflateSetDictionary:XO,deflateInfo:KO};const JO=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var QO=function(t){const e=Array.prototype.slice.call(arguments,1);for(;e.length;){const n=e.shift();if(n){if(typeof n!="object")throw new TypeError(n+"must be non-object");for(const r in n)JO(n,r)&&(t[r]=n[r])}}return t},eL=t=>{let e=0;for(let r=0,i=t.length;r<i;r++)e+=t[r].length;const n=new Uint8Array(e);for(let r=0,i=0,a=t.length;r<a;r++){let o=t[r];n.set(o,i),i+=o.length}return n},Gc={assign:QO,flattenChunks:eL};let _E=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{_E=!1}const ul=new Uint8Array(256);for(let t=0;t<256;t++)ul[t]=t>=252?6:t>=248?5:t>=240?4:t>=224?3:t>=192?2:1;ul[254]=ul[254]=1;var tL=t=>{if(typeof TextEncoder=="function"&&TextEncoder.prototype.encode)return new TextEncoder().encode(t);let e,n,r,i,a,o=t.length,s=0;for(i=0;i<o;i++)n=t.charCodeAt(i),(n&64512)===55296&&i+1<o&&(r=t.charCodeAt(i+1),(r&64512)===56320&&(n=65536+(n-55296<<10)+(r-56320),i++)),s+=n<128?1:n<2048?2:n<65536?3:4;for(e=new Uint8Array(s),a=0,i=0;a<s;i++)n=t.charCodeAt(i),(n&64512)===55296&&i+1<o&&(r=t.charCodeAt(i+1),(r&64512)===56320&&(n=65536+(n-55296<<10)+(r-56320),i++)),n<128?e[a++]=n:n<2048?(e[a++]=192|n>>>6,e[a++]=128|n&63):n<65536?(e[a++]=224|n>>>12,e[a++]=128|n>>>6&63,e[a++]=128|n&63):(e[a++]=240|n>>>18,e[a++]=128|n>>>12&63,e[a++]=128|n>>>6&63,e[a++]=128|n&63);return e};const nL=(t,e)=>{if(e<65534&&t.subarray&&_E)return String.fromCharCode.apply(null,t.length===e?t:t.subarray(0,e));let n="";for(let r=0;r<e;r++)n+=String.fromCharCode(t[r]);return n};var rL=(t,e)=>{const n=e||t.length;if(typeof TextDecoder=="function"&&TextDecoder.prototype.decode)return new TextDecoder().decode(t.subarray(0,e));let r,i;const a=new Array(n*2);for(i=0,r=0;r<n;){let o=t[r++];if(o<128){a[i++]=o;continue}let s=ul[o];if(s>4){a[i++]=65533,r+=s-1;continue}for(o&=s===2?31:s===3?15:7;s>1&&r<n;)o=o<<6|t[r++]&63,s--;if(s>1){a[i++]=65533;continue}o<65536?a[i++]=o:(o-=65536,a[i++]=55296|o>>10&1023,a[i++]=56320|o&1023)}return nL(a,i)},iL=(t,e)=>{e=e||t.length,e>t.length&&(e=t.length);let n=e-1;for(;n>=0&&(t[n]&192)===128;)n--;return n<0||n===0?e:n+ul[t[n]]>e?n:e},fl={string2buf:tL,buf2string:rL,utf8border:iL};function aL(){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}var vE=aL;const EE=Object.prototype.toString,{Z_NO_FLUSH:oL,Z_SYNC_FLUSH:sL,Z_FULL_FLUSH:lL,Z_FINISH:uL,Z_OK:kf,Z_STREAM_END:fL,Z_DEFAULT_COMPRESSION:cL,Z_DEFAULT_STRATEGY:hL,Z_DEFLATED:dL}=tu;function Fg(t){this.options=Gc.assign({level:cL,method:dL,chunkSize:16384,windowBits:15,memLevel:8,strategy:hL},t||{});let e=this.options;e.raw&&e.windowBits>0?e.windowBits=-e.windowBits:e.gzip&&e.windowBits>0&&e.windowBits<16&&(e.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new vE,this.strm.avail_out=0;let n=As.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(n!==kf)throw new Error(Eo[n]);if(e.header&&As.deflateSetHeader(this.strm,e.header),e.dictionary){let r;if(typeof e.dictionary=="string"?r=fl.string2buf(e.dictionary):EE.call(e.dictionary)==="[object ArrayBuffer]"?r=new Uint8Array(e.dictionary):r=e.dictionary,n=As.deflateSetDictionary(this.strm,r),n!==kf)throw new Error(Eo[n]);this._dict_set=!0}}Fg.prototype.push=function(t,e){const n=this.strm,r=this.options.chunkSize;let i,a;if(this.ended)return!1;for(e===~~e?a=e:a=e===!0?uL:oL,typeof t=="string"?n.input=fl.string2buf(t):EE.call(t)==="[object ArrayBuffer]"?n.input=new Uint8Array(t):n.input=t,n.next_in=0,n.avail_in=n.input.length;;){if(n.avail_out===0&&(n.output=new Uint8Array(r),n.next_out=0,n.avail_out=r),(a===sL||a===lL)&&n.avail_out<=6){this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;continue}if(i=As.deflate(n,a),i===fL)return n.next_out>0&&this.onData(n.output.subarray(0,n.next_out)),i=As.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===kf;if(n.avail_out===0){this.onData(n.output);continue}if(a>0&&n.next_out>0){this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;continue}if(n.avail_in===0)break}return!0};Fg.prototype.onData=function(t){this.chunks.push(t)};Fg.prototype.onEnd=function(t){t===kf&&(this.result=Gc.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};const Ru=16209,pL=16191;var gL=function(e,n){let r,i,a,o,s,u,l,f,c,h,d,p,m,y,w,A,C,E,k,R,I,O,T,B;const N=e.state;r=e.next_in,T=e.input,i=r+(e.avail_in-5),a=e.next_out,B=e.output,o=a-(n-e.avail_out),s=a+(e.avail_out-257),u=N.dmax,l=N.wsize,f=N.whave,c=N.wnext,h=N.window,d=N.hold,p=N.bits,m=N.lencode,y=N.distcode,w=(1<<N.lenbits)-1,A=(1<<N.distbits)-1;e:do{p<15&&(d+=T[r++]<<p,p+=8,d+=T[r++]<<p,p+=8),C=m[d&w];t:for(;;){if(E=C>>>24,d>>>=E,p-=E,E=C>>>16&255,E===0)B[a++]=C&65535;else if(E&16){k=C&65535,E&=15,E&&(p<E&&(d+=T[r++]<<p,p+=8),k+=d&(1<<E)-1,d>>>=E,p-=E),p<15&&(d+=T[r++]<<p,p+=8,d+=T[r++]<<p,p+=8),C=y[d&A];n:for(;;){if(E=C>>>24,d>>>=E,p-=E,E=C>>>16&255,E&16){if(R=C&65535,E&=15,p<E&&(d+=T[r++]<<p,p+=8,p<E&&(d+=T[r++]<<p,p+=8)),R+=d&(1<<E)-1,R>u){e.msg="invalid distance too far back",N.mode=Ru;break e}if(d>>>=E,p-=E,E=a-o,R>E){if(E=R-E,E>f&&N.sane){e.msg="invalid distance too far back",N.mode=Ru;break e}if(I=0,O=h,c===0){if(I+=l-E,E<k){k-=E;do B[a++]=h[I++];while(--E);I=a-R,O=B}}else if(c<E){if(I+=l+c-E,E-=c,E<k){k-=E;do B[a++]=h[I++];while(--E);if(I=0,c<k){E=c,k-=E;do B[a++]=h[I++];while(--E);I=a-R,O=B}}}else if(I+=c-E,E<k){k-=E;do B[a++]=h[I++];while(--E);I=a-R,O=B}for(;k>2;)B[a++]=O[I++],B[a++]=O[I++],B[a++]=O[I++],k-=3;k&&(B[a++]=O[I++],k>1&&(B[a++]=O[I++]))}else{I=a-R;do B[a++]=B[I++],B[a++]=B[I++],B[a++]=B[I++],k-=3;while(k>2);k&&(B[a++]=B[I++],k>1&&(B[a++]=B[I++]))}}else if(E&64){e.msg="invalid distance code",N.mode=Ru;break e}else{C=y[(C&65535)+(d&(1<<E)-1)];continue n}break}}else if(E&64)if(E&32){N.mode=pL;break e}else{e.msg="invalid literal/length code",N.mode=Ru;break e}else{C=m[(C&65535)+(d&(1<<E)-1)];continue t}break}}while(r<i&&a<s);k=p>>3,r-=k,p-=k<<3,d&=(1<<p)-1,e.next_in=r,e.next_out=a,e.avail_in=r<i?5+(i-r):5-(r-i),e.avail_out=a<s?257+(s-a):257-(a-s),N.hold=d,N.bits=p};const Oa=15,ny=852,ry=592,iy=0,Zh=1,ay=2,mL=new Uint16Array([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]),bL=new Uint8Array([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]),yL=new Uint16Array([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]),wL=new Uint8Array([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]),xL=(t,e,n,r,i,a,o,s)=>{const u=s.bits;let l=0,f=0,c=0,h=0,d=0,p=0,m=0,y=0,w=0,A=0,C,E,k,R,I,O=null,T;const B=new Uint16Array(Oa+1),N=new Uint16Array(Oa+1);let J=null,ee,Q,he;for(l=0;l<=Oa;l++)B[l]=0;for(f=0;f<r;f++)B[e[n+f]]++;for(d=u,h=Oa;h>=1&&B[h]===0;h--);if(d>h&&(d=h),h===0)return i[a++]=1<<24|64<<16|0,i[a++]=1<<24|64<<16|0,s.bits=1,0;for(c=1;c<h&&B[c]===0;c++);for(d<c&&(d=c),y=1,l=1;l<=Oa;l++)if(y<<=1,y-=B[l],y<0)return-1;if(y>0&&(t===iy||h!==1))return-1;for(N[1]=0,l=1;l<Oa;l++)N[l+1]=N[l]+B[l];for(f=0;f<r;f++)e[n+f]!==0&&(o[N[e[n+f]]++]=f);if(t===iy?(O=J=o,T=20):t===Zh?(O=mL,J=bL,T=257):(O=yL,J=wL,T=0),A=0,f=0,l=c,I=a,p=d,m=0,k=-1,w=1<<d,R=w-1,t===Zh&&w>ny||t===ay&&w>ry)return 1;for(;;){ee=l-m,o[f]+1<T?(Q=0,he=o[f]):o[f]>=T?(Q=J[o[f]-T],he=O[o[f]-T]):(Q=32+64,he=0),C=1<<l-m,E=1<<p,c=E;do E-=C,i[I+(A>>m)+E]=ee<<24|Q<<16|he|0;while(E!==0);for(C=1<<l-1;A&C;)C>>=1;if(C!==0?(A&=C-1,A+=C):A=0,f++,--B[l]===0){if(l===h)break;l=e[n+o[f]]}if(l>d&&(A&R)!==k){for(m===0&&(m=d),I+=c,p=l-m,y=1<<p;p+m<h&&(y-=B[p+m],!(y<=0));)p++,y<<=1;if(w+=1<<p,t===Zh&&w>ny||t===ay&&w>ry)return 1;k=A&R,i[k]=d<<24|p<<16|I-a|0}}return A!==0&&(i[I+A]=l-m<<24|64<<16|0),s.bits=d,0};var Ss=xL;const _L=0,AE=1,SE=2,{Z_FINISH:oy,Z_BLOCK:vL,Z_TREES:Du,Z_OK:pa,Z_STREAM_END:EL,Z_NEED_DICT:AL,Z_STREAM_ERROR:mn,Z_DATA_ERROR:CE,Z_MEM_ERROR:TE,Z_BUF_ERROR:SL,Z_DEFLATED:sy}=tu,jc=16180,ly=16181,uy=16182,fy=16183,cy=16184,hy=16185,dy=16186,py=16187,gy=16188,my=16189,Rf=16190,br=16191,Yh=16192,by=16193,Xh=16194,yy=16195,wy=16196,xy=16197,_y=16198,Bu=16199,Nu=16200,vy=16201,Ey=16202,Ay=16203,Sy=16204,Cy=16205,Kh=16206,Ty=16207,Fy=16208,Ve=16209,FE=16210,IE=16211,CL=852,TL=592,FL=15,IL=FL,Iy=t=>(t>>>24&255)+(t>>>8&65280)+((t&65280)<<8)+((t&255)<<24);function kL(){this.strm=null,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 Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const Aa=t=>{if(!t)return 1;const e=t.state;return!e||e.strm!==t||e.mode<jc||e.mode>IE?1:0},kE=t=>{if(Aa(t))return mn;const e=t.state;return t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=e.wrap&1),e.mode=jc,e.last=0,e.havedict=0,e.flags=-1,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new Int32Array(CL),e.distcode=e.distdyn=new Int32Array(TL),e.sane=1,e.back=-1,pa},RE=t=>{if(Aa(t))return mn;const e=t.state;return e.wsize=0,e.whave=0,e.wnext=0,kE(t)},DE=(t,e)=>{let n;if(Aa(t))return mn;const r=t.state;return e<0?(n=0,e=-e):(n=(e>>4)+5,e<48&&(e&=15)),e&&(e<8||e>15)?mn:(r.window!==null&&r.wbits!==e&&(r.window=null),r.wrap=n,r.wbits=e,RE(t))},BE=(t,e)=>{if(!t)return mn;const n=new kL;t.state=n,n.strm=t,n.window=null,n.mode=jc;const r=DE(t,e);return r!==pa&&(t.state=null),r},RL=t=>BE(t,IL);let ky=!0,Jh,Qh;const DL=t=>{if(ky){Jh=new Int32Array(512),Qh=new Int32Array(32);let e=0;for(;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(Ss(AE,t.lens,0,288,Jh,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;Ss(SE,t.lens,0,32,Qh,0,t.work,{bits:5}),ky=!1}t.lencode=Jh,t.lenbits=9,t.distcode=Qh,t.distbits=5},NE=(t,e,n,r)=>{let i;const a=t.state;return a.window===null&&(a.wsize=1<<a.wbits,a.wnext=0,a.whave=0,a.window=new Uint8Array(a.wsize)),r>=a.wsize?(a.window.set(e.subarray(n-a.wsize,n),0),a.wnext=0,a.whave=a.wsize):(i=a.wsize-a.wnext,i>r&&(i=r),a.window.set(e.subarray(n-r,n-r+i),a.wnext),r-=i,r?(a.window.set(e.subarray(n-r,n),0),a.wnext=r,a.whave=a.wsize):(a.wnext+=i,a.wnext===a.wsize&&(a.wnext=0),a.whave<a.wsize&&(a.whave+=i))),0},BL=(t,e)=>{let n,r,i,a,o,s,u,l,f,c,h,d,p,m,y=0,w,A,C,E,k,R,I,O;const T=new Uint8Array(4);let B,N;const J=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(Aa(t)||!t.output||!t.input&&t.avail_in!==0)return mn;n=t.state,n.mode===br&&(n.mode=Yh),o=t.next_out,i=t.output,u=t.avail_out,a=t.next_in,r=t.input,s=t.avail_in,l=n.hold,f=n.bits,c=s,h=u,O=pa;e:for(;;)switch(n.mode){case jc:if(n.wrap===0){n.mode=Yh;break}for(;f<16;){if(s===0)break e;s--,l+=r[a++]<<f,f+=8}if(n.wrap&2&&l===35615){n.wbits===0&&(n.wbits=15),n.check=0,T[0]=l&255,T[1]=l>>>8&255,n.check=at(n.check,T,2,0),l=0,f=0,n.mode=ly;break}if(n.head&&(n.head.done=!1),!(n.wrap&1)||(((l&255)<<8)+(l>>8))%31){t.msg="incorrect header check",n.mode=Ve;break}if((l&15)!==sy){t.msg="unknown compression method",n.mode=Ve;break}if(l>>>=4,f-=4,I=(l&15)+8,n.wbits===0&&(n.wbits=I),I>15||I>n.wbits){t.msg="invalid window size",n.mode=Ve;break}n.dmax=1<<n.wbits,n.flags=0,t.adler=n.check=1,n.mode=l&512?my:br,l=0,f=0;break;case ly:for(;f<16;){if(s===0)break e;s--,l+=r[a++]<<f,f+=8}if(n.flags=l,(n.flags&255)!==sy){t.msg="unknown compression method",n.mode=Ve;break}if(n.flags&57344){t.msg="unknown header flags set",n.mode=Ve;break}n.head&&(n.head.text=l>>8&1),n.flags&512&&n.wrap&4&&(T[0]=l&255,T[1]=l>>>8&255,n.check=at(n.check,T,2,0)),l=0,f=0,n.mode=uy;case uy:for(;f<32;){if(s===0)break e;s--,l+=r[a++]<<f,f+=8}n.head&&(n.head.time=l),n.flags&512&&n.wrap&4&&(T[0]=l&255,T[1]=l>>>8&255,T[2]=l>>>16&255,T[3]=l>>>24&255,n.check=at(n.check,T,4,0)),l=0,f=0,n.mode=fy;case fy:for(;f<16;){if(s===0)break e;s--,l+=r[a++]<<f,f+=8}n.head&&(n.head.xflags=l&255,n.head.os=l>>8),n.flags&512&&n.wrap&4&&(T[0]=l&255,T[1]=l>>>8&255,n.check=at(n.check,T,2,0)),l=0,f=0,n.mode=cy;case cy:if(n.flags&1024){for(;f<16;){if(s===0)break e;s--,l+=r[a++]<<f,f+=8}n.length=l,n.head&&(n.head.extra_len=l),n.flags&512&&n.wrap&4&&(T[0]=l&255,T[1]=l>>>8&255,n.check=at(n.check,T,2,0)),l=0,f=0}else n.head&&(n.head.extra=null);n.mode=hy;case hy:if(n.flags&1024&&(d=n.length,d>s&&(d=s),d&&(n.head&&(I=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Uint8Array(n.head.extra_len)),n.head.extra.set(r.subarray(a,a+d),I)),n.flags&512&&n.wrap&4&&(n.check=at(n.check,r,d,a)),s-=d,a+=d,n.length-=d),n.length))break e;n.length=0,n.mode=dy;case dy:if(n.flags&2048){if(s===0)break e;d=0;do I=r[a+d++],n.head&&I&&n.length<65536&&(n.head.name+=String.fromCharCode(I));while(I&&d<s);if(n.flags&512&&n.wrap&4&&(n.check=at(n.check,r,d,a)),s-=d,a+=d,I)break e}else n.head&&(n.head.name=null);n.length=0,n.mode=py;case py:if(n.flags&4096){if(s===0)break e;d=0;do I=r[a+d++],n.head&&I&&n.length<65536&&(n.head.comment+=String.fromCharCode(I));while(I&&d<s);if(n.flags&512&&n.wrap&4&&(n.check=at(n.check,r,d,a)),s-=d,a+=d,I)break e}else n.head&&(n.head.comment=null);n.mode=gy;case gy:if(n.flags&512){for(;f<16;){if(s===0)break e;s--,l+=r[a++]<<f,f+=8}if(n.wrap&4&&l!==(n.check&65535)){t.msg="header crc mismatch",n.mode=Ve;break}l=0,f=0}n.head&&(n.head.hcrc=n.flags>>9&1,n.head.done=!0),t.adler=n.check=0,n.mode=br;break;case my:for(;f<32;){if(s===0)break e;s--,l+=r[a++]<<f,f+=8}t.adler=n.check=Iy(l),l=0,f=0,n.mode=Rf;case Rf:if(n.havedict===0)return t.next_out=o,t.avail_out=u,t.next_in=a,t.avail_in=s,n.hold=l,n.bits=f,AL;t.adler=n.check=1,n.mode=br;case br:if(e===vL||e===Du)break e;case Yh:if(n.last){l>>>=f&7,f-=f&7,n.mode=Kh;break}for(;f<3;){if(s===0)break e;s--,l+=r[a++]<<f,f+=8}switch(n.last=l&1,l>>>=1,f-=1,l&3){case 0:n.mode=by;break;case 1:if(DL(n),n.mode=Bu,e===Du){l>>>=2,f-=2;break e}break;case 2:n.mode=wy;break;case 3:t.msg="invalid block type",n.mode=Ve}l>>>=2,f-=2;break;case by:for(l>>>=f&7,f-=f&7;f<32;){if(s===0)break e;s--,l+=r[a++]<<f,f+=8}if((l&65535)!==(l>>>16^65535)){t.msg="invalid stored block lengths",n.mode=Ve;break}if(n.length=l&65535,l=0,f=0,n.mode=Xh,e===Du)break e;case Xh:n.mode=yy;case yy:if(d=n.length,d){if(d>s&&(d=s),d>u&&(d=u),d===0)break e;i.set(r.subarray(a,a+d),o),s-=d,a+=d,u-=d,o+=d,n.length-=d;break}n.mode=br;break;case wy:for(;f<14;){if(s===0)break e;s--,l+=r[a++]<<f,f+=8}if(n.nlen=(l&31)+257,l>>>=5,f-=5,n.ndist=(l&31)+1,l>>>=5,f-=5,n.ncode=(l&15)+4,l>>>=4,f-=4,n.nlen>286||n.ndist>30){t.msg="too many length or distance symbols",n.mode=Ve;break}n.have=0,n.mode=xy;case xy:for(;n.have<n.ncode;){for(;f<3;){if(s===0)break e;s--,l+=r[a++]<<f,f+=8}n.lens[J[n.have++]]=l&7,l>>>=3,f-=3}for(;n.have<19;)n.lens[J[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,B={bits:n.lenbits},O=Ss(_L,n.lens,0,19,n.lencode,0,n.work,B),n.lenbits=B.bits,O){t.msg="invalid code lengths set",n.mode=Ve;break}n.have=0,n.mode=_y;case _y:for(;n.have<n.nlen+n.ndist;){for(;y=n.lencode[l&(1<<n.lenbits)-1],w=y>>>24,A=y>>>16&255,C=y&65535,!(w<=f);){if(s===0)break e;s--,l+=r[a++]<<f,f+=8}if(C<16)l>>>=w,f-=w,n.lens[n.have++]=C;else{if(C===16){for(N=w+2;f<N;){if(s===0)break e;s--,l+=r[a++]<<f,f+=8}if(l>>>=w,f-=w,n.have===0){t.msg="invalid bit length repeat",n.mode=Ve;break}I=n.lens[n.have-1],d=3+(l&3),l>>>=2,f-=2}else if(C===17){for(N=w+3;f<N;){if(s===0)break e;s--,l+=r[a++]<<f,f+=8}l>>>=w,f-=w,I=0,d=3+(l&7),l>>>=3,f-=3}else{for(N=w+7;f<N;){if(s===0)break e;s--,l+=r[a++]<<f,f+=8}l>>>=w,f-=w,I=0,d=11+(l&127),l>>>=7,f-=7}if(n.have+d>n.nlen+n.ndist){t.msg="invalid bit length repeat",n.mode=Ve;break}for(;d--;)n.lens[n.have++]=I}}if(n.mode===Ve)break;if(n.lens[256]===0){t.msg="invalid code -- missing end-of-block",n.mode=Ve;break}if(n.lenbits=9,B={bits:n.lenbits},O=Ss(AE,n.lens,0,n.nlen,n.lencode,0,n.work,B),n.lenbits=B.bits,O){t.msg="invalid literal/lengths set",n.mode=Ve;break}if(n.distbits=6,n.distcode=n.distdyn,B={bits:n.distbits},O=Ss(SE,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,B),n.distbits=B.bits,O){t.msg="invalid distances set",n.mode=Ve;break}if(n.mode=Bu,e===Du)break e;case Bu:n.mode=Nu;case Nu:if(s>=6&&u>=258){t.next_out=o,t.avail_out=u,t.next_in=a,t.avail_in=s,n.hold=l,n.bits=f,gL(t,h),o=t.next_out,i=t.output,u=t.avail_out,a=t.next_in,r=t.input,s=t.avail_in,l=n.hold,f=n.bits,n.mode===br&&(n.back=-1);break}for(n.back=0;y=n.lencode[l&(1<<n.lenbits)-1],w=y>>>24,A=y>>>16&255,C=y&65535,!(w<=f);){if(s===0)break e;s--,l+=r[a++]<<f,f+=8}if(A&&!(A&240)){for(E=w,k=A,R=C;y=n.lencode[R+((l&(1<<E+k)-1)>>E)],w=y>>>24,A=y>>>16&255,C=y&65535,!(E+w<=f);){if(s===0)break e;s--,l+=r[a++]<<f,f+=8}l>>>=E,f-=E,n.back+=E}if(l>>>=w,f-=w,n.back+=w,n.length=C,A===0){n.mode=Cy;break}if(A&32){n.back=-1,n.mode=br;break}if(A&64){t.msg="invalid literal/length code",n.mode=Ve;break}n.extra=A&15,n.mode=vy;case vy:if(n.extra){for(N=n.extra;f<N;){if(s===0)break e;s--,l+=r[a++]<<f,f+=8}n.length+=l&(1<<n.extra)-1,l>>>=n.extra,f-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=Ey;case Ey:for(;y=n.distcode[l&(1<<n.distbits)-1],w=y>>>24,A=y>>>16&255,C=y&65535,!(w<=f);){if(s===0)break e;s--,l+=r[a++]<<f,f+=8}if(!(A&240)){for(E=w,k=A,R=C;y=n.distcode[R+((l&(1<<E+k)-1)>>E)],w=y>>>24,A=y>>>16&255,C=y&65535,!(E+w<=f);){if(s===0)break e;s--,l+=r[a++]<<f,f+=8}l>>>=E,f-=E,n.back+=E}if(l>>>=w,f-=w,n.back+=w,A&64){t.msg="invalid distance code",n.mode=Ve;break}n.offset=C,n.extra=A&15,n.mode=Ay;case Ay:if(n.extra){for(N=n.extra;f<N;){if(s===0)break e;s--,l+=r[a++]<<f,f+=8}n.offset+=l&(1<<n.extra)-1,l>>>=n.extra,f-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){t.msg="invalid distance too far back",n.mode=Ve;break}n.mode=Sy;case Sy:if(u===0)break e;if(d=h-u,n.offset>d){if(d=n.offset-d,d>n.whave&&n.sane){t.msg="invalid distance too far back",n.mode=Ve;break}d>n.wnext?(d-=n.wnext,p=n.wsize-d):p=n.wnext-d,d>n.length&&(d=n.length),m=n.window}else m=i,p=o-n.offset,d=n.length;d>u&&(d=u),u-=d,n.length-=d;do i[o++]=m[p++];while(--d);n.length===0&&(n.mode=Nu);break;case Cy:if(u===0)break e;i[o++]=n.length,u--,n.mode=Nu;break;case Kh:if(n.wrap){for(;f<32;){if(s===0)break e;s--,l|=r[a++]<<f,f+=8}if(h-=u,t.total_out+=h,n.total+=h,n.wrap&4&&h&&(t.adler=n.check=n.flags?at(n.check,i,h,o-h):ll(n.check,i,h,o-h)),h=u,n.wrap&4&&(n.flags?l:Iy(l))!==n.check){t.msg="incorrect data check",n.mode=Ve;break}l=0,f=0}n.mode=Ty;case Ty:if(n.wrap&&n.flags){for(;f<32;){if(s===0)break e;s--,l+=r[a++]<<f,f+=8}if(n.wrap&4&&l!==(n.total&4294967295)){t.msg="incorrect length check",n.mode=Ve;break}l=0,f=0}n.mode=Fy;case Fy:O=EL;break e;case Ve:O=CE;break e;case FE:return TE;case IE:default:return mn}return t.next_out=o,t.avail_out=u,t.next_in=a,t.avail_in=s,n.hold=l,n.bits=f,(n.wsize||h!==t.avail_out&&n.mode<Ve&&(n.mode<Kh||e!==oy))&&NE(t,t.output,t.next_out,h-t.avail_out),c-=t.avail_in,h-=t.avail_out,t.total_in+=c,t.total_out+=h,n.total+=h,n.wrap&4&&h&&(t.adler=n.check=n.flags?at(n.check,i,h,t.next_out-h):ll(n.check,i,h,t.next_out-h)),t.data_type=n.bits+(n.last?64:0)+(n.mode===br?128:0)+(n.mode===Bu||n.mode===Xh?256:0),(c===0&&h===0||e===oy)&&O===pa&&(O=SL),O},NL=t=>{if(Aa(t))return mn;let e=t.state;return e.window&&(e.window=null),t.state=null,pa},$L=(t,e)=>{if(Aa(t))return mn;const n=t.state;return n.wrap&2?(n.head=e,e.done=!1,pa):mn},OL=(t,e)=>{const n=e.length;let r,i,a;return Aa(t)||(r=t.state,r.wrap!==0&&r.mode!==Rf)?mn:r.mode===Rf&&(i=1,i=ll(i,e,n,0),i!==r.check)?CE:(a=NE(t,e,n,n),a?(r.mode=FE,TE):(r.havedict=1,pa))};var LL=RE,ML=DE,PL=kE,zL=RL,UL=BE,qL=BL,VL=NL,HL=$L,GL=OL,jL="pako inflate (from Nodeca project)",Er={inflateReset:LL,inflateReset2:ML,inflateResetKeep:PL,inflateInit:zL,inflateInit2:UL,inflate:qL,inflateEnd:VL,inflateGetHeader:HL,inflateSetDictionary:GL,inflateInfo:jL};function WL(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}var ZL=WL;const $E=Object.prototype.toString,{Z_NO_FLUSH:YL,Z_FINISH:XL,Z_OK:cl,Z_STREAM_END:ed,Z_NEED_DICT:td,Z_STREAM_ERROR:KL,Z_DATA_ERROR:Ry,Z_MEM_ERROR:JL}=tu;function ru(t){this.options=Gc.assign({chunkSize:1024*64,windowBits:15,to:""},t||{});const e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,e.windowBits===0&&(e.windowBits=-15)),e.windowBits>=0&&e.windowBits<16&&!(t&&t.windowBits)&&(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&(e.windowBits&15||(e.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new vE,this.strm.avail_out=0;let n=Er.inflateInit2(this.strm,e.windowBits);if(n!==cl)throw new Error(Eo[n]);if(this.header=new ZL,Er.inflateGetHeader(this.strm,this.header),e.dictionary&&(typeof e.dictionary=="string"?e.dictionary=fl.string2buf(e.dictionary):$E.call(e.dictionary)==="[object ArrayBuffer]"&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(n=Er.inflateSetDictionary(this.strm,e.dictionary),n!==cl)))throw new Error(Eo[n])}ru.prototype.push=function(t,e){const n=this.strm,r=this.options.chunkSize,i=this.options.dictionary;let a,o,s;if(this.ended)return!1;for(e===~~e?o=e:o=e===!0?XL:YL,$E.call(t)==="[object ArrayBuffer]"?n.input=new Uint8Array(t):n.input=t,n.next_in=0,n.avail_in=n.input.length;;){for(n.avail_out===0&&(n.output=new Uint8Array(r),n.next_out=0,n.avail_out=r),a=Er.inflate(n,o),a===td&&i&&(a=Er.inflateSetDictionary(n,i),a===cl?a=Er.inflate(n,o):a===Ry&&(a=td));n.avail_in>0&&a===ed&&n.state.wrap>0&&t[n.next_in]!==0;)Er.inflateReset(n),a=Er.inflate(n,o);switch(a){case KL:case Ry:case td:case JL:return this.onEnd(a),this.ended=!0,!1}if(s=n.avail_out,n.next_out&&(n.avail_out===0||a===ed))if(this.options.to==="string"){let u=fl.utf8border(n.output,n.next_out),l=n.next_out-u,f=fl.buf2string(n.output,u);n.next_out=l,n.avail_out=r-l,l&&n.output.set(n.output.subarray(u,u+l),0),this.onData(f)}else this.onData(n.output.length===n.next_out?n.output:n.output.subarray(0,n.next_out));if(!(a===cl&&s===0)){if(a===ed)return a=Er.inflateEnd(this.strm),this.onEnd(a),this.ended=!0,!0;if(n.avail_in===0)break}}return!0};ru.prototype.onData=function(t){this.chunks.push(t)};ru.prototype.onEnd=function(t){t===cl&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=Gc.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};function Ig(t,e){const n=new ru(e);if(n.push(t),n.err)throw n.msg||Eo[n.err];return n.result}function QL(t,e){return e=e||{},e.raw=!0,Ig(t,e)}var eM=ru,tM=Ig,nM=QL,rM=Ig,iM=tu,aM={Inflate:eM,inflate:tM,inflateRaw:nM,ungzip:rM,constants:iM};const{Inflate:Oz,inflate:Lz,inflateRaw:oM,ungzip:Mz}=aM;var sM=oM;function lM(t){return sM(t.subarray(2))}let uM=class extends Error{constructor(e){super(e),this.code="ERR_ABORTED"}};function fM(t){t.sort((i,a)=>Number(i.offset)-Number(a.offset));const e=[];let n,r;for(const i of t)n&&r&&Number(i.offset)-r<=2e3?(n.length=BigInt(Number(n.length)+Number(i.length)-r+Number(i.offset)),n.blocks.push(i)):e.push(n={blocks:[i],length:i.length,offset:i.offset}),r=Number(n.offset)+Number(n.length);return e}function $u(t){if(t&&t.aborted)if(typeof DOMException>"u"){const e=new uM("aborted");throw e.code="ERR_ABORTED",e}else throw new DOMException("aborted","AbortError")}const cM=1,hM=2,dM=3;function nd(t,e,n,r){return t<r&&e>=n}function pM(t){const e=t?"big":"little",n=new Ce().endianess(e).uint32("chromId").uint32("start").uint32("end").uint32("validCnt").floatle("minScore").floatle("maxScore").floatle("sumData").floatle("sumSqData").saveOffset("offset"),r=new Ce().endianess(e).uint8("isLeaf").skip(1).uint16("cnt").choice({tag:"isLeaf",choices:{1:new Ce().endianess(e).array("blocksToFetch",{length:"cnt",type:new Ce().endianess(e).uint32("startChrom").uint32("startBase").uint32("endChrom").uint32("endBase").uint64("blockOffset").uint64("blockSize").saveOffset("offset")}),0:new Ce().array("recurOffsets",{length:"cnt",type:new Ce().endianess(e).uint32("startChrom").uint32("startBase").uint32("endChrom").uint32("endBase").uint64("blockOffset").saveOffset("offset")})}}),i=new Ce().endianess(e).uint32("chromId").int32("start").int32("end").string("rest",{zeroTerminated:!0}).saveOffset("offset");return{bigWigParser:new Ce().endianess(e).skip(4).int32("blockStart").skip(4).uint32("itemStep").uint32("itemSpan").uint8("blockType").skip(1).uint16("itemCount").choice({tag:"blockType",choices:{[dM]:new Ce().array("items",{length:"itemCount",type:new Ce().floatle("score")}),[hM]:new Ce().array("items",{length:"itemCount",type:new Ce().endianess(e).int32("start").floatle("score")}),[cM]:new Ce().array("items",{length:"itemCount",type:new Ce().endianess(e).int32("start").int32("end").floatle("score")})}}),bigBedParser:i,summaryParser:n,leafParser:r}}class OE{constructor(e,n,r,i,a,o){if(this.bbi=e,this.refsByName=n,this.cirTreeOffset=r,this.isBigEndian=i,this.isCompressed=a,this.blockType=o,this.featureCache=new Vc({cache:new eE({maxSize:1e3}),fill:async(u,l)=>{const f=Number(u.length),c=Number(u.offset),{buffer:h}=await this.bbi.read(Je.Buffer.alloc(f),0,f,c,{signal:l});return h}}),!(r>=0))throw new Error("invalid cirTreeOffset!");const s=pM(i);this.leafParser=s.leafParser,this.bigBedParser=s.bigBedParser}async readWigData(e,n,r,i,a){try{const{refsByName:o,bbi:s,cirTreeOffset:u,isBigEndian:l}=this,f=o[e];f===void 0&&i.complete();const c={chrId:f,start:n,end:r};this.cirTreePromise||(this.cirTreePromise=s.read(Je.Buffer.alloc(48),0,48,Number(u),a));const{buffer:h}=await this.cirTreePromise,d=l?h.readUInt32BE(4):h.readUInt32LE(4);let p=[],m=0;const y=(E,k,R)=>{try{const I=E.subarray(k),O=this.leafParser.parse(I);if(O.blocksToFetch&&(p=p.concat(O.blocksToFetch.filter(T=>w(T)).map(T=>({offset:T.blockOffset,length:T.blockSize})))),O.recurOffsets){const T=O.recurOffsets.filter(B=>w(B)).map(B=>Number(B.blockOffset));T.length>0&&C(T,R+1)}}catch(I){i.error(I)}},w=E=>{const{startChrom:k,startBase:R,endChrom:I,endBase:O}=E;return(k<f||k===f&&R<=r)&&(I>f||I===f&&O>=n)},A=async(E,k,R)=>{try{const I=k.max()-k.min(),O=k.min(),T=await this.featureCache.get(`${I}_${O}`,{length:I,offset:O},a==null?void 0:a.signal);for(const B of E)k.contains(B)&&(y(T,B-O,R),m-=1,m===0&&this.readFeatures(i,p,{...a,request:c}))}catch(I){i.error(I)}},C=(E,k)=>{try{m+=E.length;const R=4+Number(d)*32;let I=new Jr(E[0],E[0]+R);for(let O=1;O<E.length;O+=1){const T=new Jr(E[O],E[O]+R);I=I.union(T)}I.getRanges().map(O=>A(E,O,k))}catch(R){i.error(R)}};return C([Number(u)+48],1)}catch(o){i.error(o)}}parseSummaryBlock(e,n,r){const i=[];let a=n;const o=new DataView(e.buffer,e.byteOffset,e.length);for(;a<e.byteLength;){const s=o.getUint32(a,!0);a+=4;const u=o.getUint32(a,!0);a+=4;const l=o.getUint32(a,!0);a+=4;const f=o.getUint32(a,!0);a+=4;const c=o.getFloat32(a,!0);a+=4;const h=o.getFloat32(a,!0);a+=4;const d=o.getFloat32(a,!0);a+=4,a+=4,(!r||s===r.chrId&&nd(u,l,r.start,r.end))&&i.push({start:u,end:l,maxScore:h,minScore:c,summary:!0,score:d/(f||1)})}return i}parseBigBedBlock(e,n,r,i){const a=[];let o=n;for(;o<e.byteLength;){const s=this.bigBedParser.parse(e.subarray(o));a.push({...s,uniqueId:`bb-${r+o}`}),o+=s.offset}return i?a.filter(s=>nd(s.start,s.end,i.start,i.end)):a}parseBigWigBlock(e,n,r){const i=e.subarray(n),a=new DataView(i.buffer,i.byteOffset,i.length);let o=0;o+=4;const s=a.getInt32(o,!0);o+=8;const u=a.getUint32(o,!0);o+=4;const l=a.getUint32(o,!0);o+=4;const f=a.getUint8(o);o+=2;const c=a.getUint16(o,!0);o+=2;const h=new Array(c);switch(f){case 1:{for(let d=0;d<c;d++){const p=a.getInt32(o,!0);o+=4;const m=a.getInt32(o,!0);o+=4;const y=a.getFloat32(o,!0);o+=4,h[d]={start:p,end:m,score:y}}break}case 2:{for(let d=0;d<c;d++){const p=a.getInt32(o,!0);o+=4;const m=a.getFloat32(o,!0);o+=4,h[d]={score:m,start:p,end:p+l}}break}case 3:{for(let d=0;d<c;d++){const p=a.getFloat32(o,!0);o+=4;const m=s+d*u;h[d]={score:p,start:m,end:m+l}}break}}return r?h.filter(d=>nd(d.start,d.end,r.start,r.end)):h}async readFeatures(e,n,r={}){try{const{blockType:i,isCompressed:a}=this,{signal:o,request:s}=r,u=fM(n);$u(o),await Promise.all(u.map(async l=>{$u(o);const{length:f,offset:c}=l,h=await this.featureCache.get(`${f}_${c}`,l,o);for(const d of l.blocks){$u(o);let p=Number(d.offset)-Number(l.offset),m=h;switch(a&&(m=lM(h.subarray(p)),p=0),$u(o),i){case"summary":{e.next(this.parseSummaryBlock(m,p,s));break}case"bigwig":{e.next(this.parseBigWigBlock(m,p,s));break}case"bigbed":{e.next(this.parseBigBedBlock(m,p,Number(d.offset)*256,s));break}default:console.warn(`Don't know what to do with ${i}`)}}})),e.complete()}catch(i){e.error(i)}}}var q0=function(t,e){return q0=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(n[i]=r[i])},q0(t,e)};function kg(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");q0(t,e);function n(){this.constructor=t}t.prototype=e===null?Object.create(e):(n.prototype=e.prototype,new n)}function gM(t,e,n,r){function i(a){return a instanceof n?a:new n(function(o){o(a)})}return new(n||(n=Promise))(function(a,o){function s(f){try{l(r.next(f))}catch(c){o(c)}}function u(f){try{l(r.throw(f))}catch(c){o(c)}}function l(f){f.done?a(f.value):i(f.value).then(s,u)}l((r=r.apply(t,e||[])).next())})}function LE(t,e){var n={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},r,i,a,o;return o={next:s(0),throw:s(1),return:s(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function s(l){return function(f){return u([l,f])}}function u(l){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,l[0]&&(n=0)),n;)try{if(r=1,i&&(a=l[0]&2?i.return:l[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,l[1])).done)return a;switch(i=0,a&&(l=[l[0]&2,a.value]),l[0]){case 0:case 1:a=l;break;case 4:return n.label++,{value:l[1],done:!1};case 5:n.label++,i=l[1],l=[0];continue;case 7:l=n.ops.pop(),n.trys.pop();continue;default:if(a=n.trys,!(a=a.length>0&&a[a.length-1])&&(l[0]===6||l[0]===2)){n=0;continue}if(l[0]===3&&(!a||l[1]>a[0]&&l[1]<a[3])){n.label=l[1];break}if(l[0]===6&&n.label<a[1]){n.label=a[1],a=l;break}if(a&&n.label<a[2]){n.label=a[2],n.ops.push(l);break}a[2]&&n.ops.pop(),n.trys.pop();continue}l=e.call(t,n)}catch(f){l=[6,f],i=0}finally{r=a=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}function hl(t){var e=typeof Symbol=="function"&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Df(t,e){var n=typeof Symbol=="function"&&t[Symbol.iterator];if(!n)return t;var r=n.call(t),i,a=[],o;try{for(;(e===void 0||e-- >0)&&!(i=r.next()).done;)a.push(i.value)}catch(s){o={error:s}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return a}function Bf(t,e,n){if(n||arguments.length===2)for(var r=0,i=e.length,a;r<i;r++)(a||!(r in e))&&(a||(a=Array.prototype.slice.call(e,0,r)),a[r]=e[r]);return t.concat(a||Array.prototype.slice.call(e))}function Ya(t){return this instanceof Ya?(this.v=t,this):new Ya(t)}function mM(t,e,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(t,e||[]),i,a=[];return i={},o("next"),o("throw"),o("return"),i[Symbol.asyncIterator]=function(){return this},i;function o(h){r[h]&&(i[h]=function(d){return new Promise(function(p,m){a.push([h,d,p,m])>1||s(h,d)})})}function s(h,d){try{u(r[h](d))}catch(p){c(a[0][3],p)}}function u(h){h.value instanceof Ya?Promise.resolve(h.value.v).then(l,f):c(a[0][2],h)}function l(h){s("next",h)}function f(h){s("throw",h)}function c(h,d){h(d),a.shift(),a.length&&s(a[0][0],a[0][1])}}function bM(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator],n;return e?e.call(t):(t=typeof hl=="function"?hl(t):t[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(a){n[a]=t[a]&&function(o){return new Promise(function(s,u){o=t[a](o),i(s,u,o.done,o.value)})}}function i(a,o,s,u){Promise.resolve(u).then(function(l){a({value:l,done:s})},o)}}function nt(t){return typeof t=="function"}function ME(t){var e=function(r){Error.call(r),r.stack=new Error().stack},n=t(e);return n.prototype=Object.create(Error.prototype),n.prototype.constructor=n,n}var rd=ME(function(t){return function(n){t(this),this.message=n?n.length+` errors occurred during unsubscription: -`+n.map(function(r,i){return i+1+") "+r.toString()}).join(` - `):"",this.name="UnsubscriptionError",this.errors=n}});function Dy(t,e){if(t){var n=t.indexOf(e);0<=n&&t.splice(n,1)}}var Rg=function(){function t(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}return t.prototype.unsubscribe=function(){var e,n,r,i,a;if(!this.closed){this.closed=!0;var o=this._parentage;if(o)if(this._parentage=null,Array.isArray(o))try{for(var s=hl(o),u=s.next();!u.done;u=s.next()){var l=u.value;l.remove(this)}}catch(m){e={error:m}}finally{try{u&&!u.done&&(n=s.return)&&n.call(s)}finally{if(e)throw e.error}}else o.remove(this);var f=this.initialTeardown;if(nt(f))try{f()}catch(m){a=m instanceof rd?m.errors:[m]}var c=this._finalizers;if(c){this._finalizers=null;try{for(var h=hl(c),d=h.next();!d.done;d=h.next()){var p=d.value;try{By(p)}catch(m){a=a??[],m instanceof rd?a=Bf(Bf([],Df(a)),Df(m.errors)):a.push(m)}}}catch(m){r={error:m}}finally{try{d&&!d.done&&(i=h.return)&&i.call(h)}finally{if(r)throw r.error}}}if(a)throw new rd(a)}},t.prototype.add=function(e){var n;if(e&&e!==this)if(this.closed)By(e);else{if(e instanceof t){if(e.closed||e._hasParent(this))return;e._addParent(this)}(this._finalizers=(n=this._finalizers)!==null&&n!==void 0?n:[]).push(e)}},t.prototype._hasParent=function(e){var n=this._parentage;return n===e||Array.isArray(n)&&n.includes(e)},t.prototype._addParent=function(e){var n=this._parentage;this._parentage=Array.isArray(n)?(n.push(e),n):n?[n,e]:e},t.prototype._removeParent=function(e){var n=this._parentage;n===e?this._parentage=null:Array.isArray(n)&&Dy(n,e)},t.prototype.remove=function(e){var n=this._finalizers;n&&Dy(n,e),e instanceof t&&e._removeParent(this)},t.EMPTY=function(){var e=new t;return e.closed=!0,e}(),t}();Rg.EMPTY;function PE(t){return t instanceof Rg||t&&"closed"in t&&nt(t.remove)&&nt(t.add)&&nt(t.unsubscribe)}function By(t){nt(t)?t():t.unsubscribe()}var zE={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},V0={setTimeout:function(t,e){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];var i=V0.delegate;return i!=null&&i.setTimeout?i.setTimeout.apply(i,Bf([t,e],Df(n))):setTimeout.apply(void 0,Bf([t,e],Df(n)))},clearTimeout:function(t){var e=V0.delegate;return((e==null?void 0:e.clearTimeout)||clearTimeout)(t)},delegate:void 0};function UE(t){V0.setTimeout(function(){throw t})}function Ny(){}function yM(t){t()}var Dg=function(t){kg(e,t);function e(n){var r=t.call(this)||this;return r.isStopped=!1,n?(r.destination=n,PE(n)&&n.add(r)):r.destination=vM,r}return e.create=function(n,r,i){return new Nf(n,r,i)},e.prototype.next=function(n){this.isStopped||this._next(n)},e.prototype.error=function(n){this.isStopped||(this.isStopped=!0,this._error(n))},e.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},e.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,t.prototype.unsubscribe.call(this),this.destination=null)},e.prototype._next=function(n){this.destination.next(n)},e.prototype._error=function(n){try{this.destination.error(n)}finally{this.unsubscribe()}},e.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},e}(Rg),wM=Function.prototype.bind;function id(t,e){return wM.call(t,e)}var xM=function(){function t(e){this.partialObserver=e}return t.prototype.next=function(e){var n=this.partialObserver;if(n.next)try{n.next(e)}catch(r){Ou(r)}},t.prototype.error=function(e){var n=this.partialObserver;if(n.error)try{n.error(e)}catch(r){Ou(r)}else Ou(e)},t.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(n){Ou(n)}},t}(),Nf=function(t){kg(e,t);function e(n,r,i){var a=t.call(this)||this,o;if(nt(n)||!n)o={next:n??void 0,error:r??void 0,complete:i??void 0};else{var s;a&&zE.useDeprecatedNextContext?(s=Object.create(n),s.unsubscribe=function(){return a.unsubscribe()},o={next:n.next&&id(n.next,s),error:n.error&&id(n.error,s),complete:n.complete&&id(n.complete,s)}):o=n}return a.destination=new xM(o),a}return e}(Dg);function Ou(t){UE(t)}function _M(t){throw t}var vM={closed:!0,next:Ny,error:_M,complete:Ny},Bg=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function qE(t){return t}function EM(t){return t.length===0?qE:t.length===1?t[0]:function(n){return t.reduce(function(r,i){return i(r)},n)}}var wn=function(){function t(e){e&&(this._subscribe=e)}return t.prototype.lift=function(e){var n=new t;return n.source=this,n.operator=e,n},t.prototype.subscribe=function(e,n,r){var i=this,a=SM(e)?e:new Nf(e,n,r);return yM(function(){var o=i,s=o.operator,u=o.source;a.add(s?s.call(a,u):u?i._subscribe(a):i._trySubscribe(a))}),a},t.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(n){e.error(n)}},t.prototype.forEach=function(e,n){var r=this;return n=$y(n),new n(function(i,a){var o=new Nf({next:function(s){try{e(s)}catch(u){a(u),o.unsubscribe()}},error:a,complete:i});r.subscribe(o)})},t.prototype._subscribe=function(e){var n;return(n=this.source)===null||n===void 0?void 0:n.subscribe(e)},t.prototype[Bg]=function(){return this},t.prototype.pipe=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return EM(e)(this)},t.prototype.toPromise=function(e){var n=this;return e=$y(e),new e(function(r,i){var a;n.subscribe(function(o){return a=o},function(o){return i(o)},function(){return r(a)})})},t.create=function(e){return new t(e)},t}();function $y(t){var e;return(e=t??zE.Promise)!==null&&e!==void 0?e:Promise}function AM(t){return t&&nt(t.next)&&nt(t.error)&&nt(t.complete)}function SM(t){return t&&t instanceof Dg||AM(t)&&PE(t)}function CM(t){return nt(t==null?void 0:t.lift)}function Vo(t){return function(e){if(CM(e))return e.lift(function(n){try{return t(n,this)}catch(r){this.error(r)}});throw new TypeError("Unable to lift unknown Observable type")}}function dl(t,e,n,r,i){return new TM(t,e,n,r,i)}var TM=function(t){kg(e,t);function e(n,r,i,a,o,s){var u=t.call(this,n)||this;return u.onFinalize=o,u.shouldUnsubscribe=s,u._next=r?function(l){try{r(l)}catch(f){n.error(f)}}:t.prototype._next,u._error=a?function(l){try{a(l)}catch(f){n.error(f)}finally{this.unsubscribe()}}:t.prototype._error,u._complete=i?function(){try{i()}catch(l){n.error(l)}finally{this.unsubscribe()}}:t.prototype._complete,u}return e.prototype.unsubscribe=function(){var n;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var r=this.closed;t.prototype.unsubscribe.call(this),!r&&((n=this.onFinalize)===null||n===void 0||n.call(this))}},e}(Dg),FM=new wn(function(t){return t.complete()});function IM(t){return t&&nt(t.schedule)}function VE(t){return t[t.length-1]}function kM(t){return IM(VE(t))?t.pop():void 0}function RM(t,e){return typeof VE(t)=="number"?t.pop():e}var HE=function(t){return t&&typeof t.length=="number"&&typeof t!="function"};function GE(t){return nt(t==null?void 0:t.then)}function jE(t){return nt(t[Bg])}function WE(t){return Symbol.asyncIterator&&nt(t==null?void 0:t[Symbol.asyncIterator])}function ZE(t){return new TypeError("You provided "+(t!==null&&typeof t=="object"?"an invalid object":"'"+t+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function DM(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var YE=DM();function XE(t){return nt(t==null?void 0:t[YE])}function KE(t){return mM(this,arguments,function(){var n,r,i,a;return LE(this,function(o){switch(o.label){case 0:n=t.getReader(),o.label=1;case 1:o.trys.push([1,,9,10]),o.label=2;case 2:return[4,Ya(n.read())];case 3:return r=o.sent(),i=r.value,a=r.done,a?[4,Ya(void 0)]:[3,5];case 4:return[2,o.sent()];case 5:return[4,Ya(i)];case 6:return[4,o.sent()];case 7:return o.sent(),[3,2];case 8:return[3,10];case 9:return n.releaseLock(),[7];case 10:return[2]}})})}function JE(t){return nt(t==null?void 0:t.getReader)}function Ho(t){if(t instanceof wn)return t;if(t!=null){if(jE(t))return BM(t);if(HE(t))return NM(t);if(GE(t))return $M(t);if(WE(t))return QE(t);if(XE(t))return OM(t);if(JE(t))return LM(t)}throw ZE(t)}function BM(t){return new wn(function(e){var n=t[Bg]();if(nt(n.subscribe))return n.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function NM(t){return new wn(function(e){for(var n=0;n<t.length&&!e.closed;n++)e.next(t[n]);e.complete()})}function $M(t){return new wn(function(e){t.then(function(n){e.closed||(e.next(n),e.complete())},function(n){return e.error(n)}).then(null,UE)})}function OM(t){return new wn(function(e){var n,r;try{for(var i=hl(t),a=i.next();!a.done;a=i.next()){var o=a.value;if(e.next(o),e.closed)return}}catch(s){n={error:s}}finally{try{a&&!a.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}e.complete()})}function QE(t){return new wn(function(e){MM(t,e).catch(function(n){return e.error(n)})})}function LM(t){return QE(KE(t))}function MM(t,e){var n,r,i,a;return gM(this,void 0,void 0,function(){var o,s;return LE(this,function(u){switch(u.label){case 0:u.trys.push([0,5,6,11]),n=bM(t),u.label=1;case 1:return[4,n.next()];case 2:if(r=u.sent(),!!r.done)return[3,4];if(o=r.value,e.next(o),e.closed)return[2];u.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return s=u.sent(),i={error:s},[3,11];case 6:return u.trys.push([6,,9,10]),r&&!r.done&&(a=n.return)?[4,a.call(n)]:[3,8];case 7:u.sent(),u.label=8;case 8:return[3,10];case 9:if(i)throw i.error;return[7];case 10:return[7];case 11:return e.complete(),[2]}})})}function li(t,e,n,r,i){r===void 0&&(r=0),i===void 0&&(i=!1);var a=e.schedule(function(){n(),i?t.add(this.schedule(null,r)):this.unsubscribe()},r);if(t.add(a),!i)return a}function eA(t,e){return e===void 0&&(e=0),Vo(function(n,r){n.subscribe(dl(r,function(i){return li(r,t,function(){return r.next(i)},e)},function(){return li(r,t,function(){return r.complete()},e)},function(i){return li(r,t,function(){return r.error(i)},e)}))})}function tA(t,e){return e===void 0&&(e=0),Vo(function(n,r){r.add(t.schedule(function(){return n.subscribe(r)},e))})}function PM(t,e){return Ho(t).pipe(tA(e),eA(e))}function zM(t,e){return Ho(t).pipe(tA(e),eA(e))}function UM(t,e){return new wn(function(n){var r=0;return e.schedule(function(){r===t.length?n.complete():(n.next(t[r++]),n.closed||this.schedule())})})}function qM(t,e){return new wn(function(n){var r;return li(n,e,function(){r=t[YE](),li(n,e,function(){var i,a,o;try{i=r.next(),a=i.value,o=i.done}catch(s){n.error(s);return}o?n.complete():n.next(a)},0,!0)}),function(){return nt(r==null?void 0:r.return)&&r.return()}})}function nA(t,e){if(!t)throw new Error("Iterable cannot be null");return new wn(function(n){li(n,e,function(){var r=t[Symbol.asyncIterator]();li(n,e,function(){r.next().then(function(i){i.done?n.complete():n.next(i.value)})},0,!0)})})}function VM(t,e){return nA(KE(t),e)}function HM(t,e){if(t!=null){if(jE(t))return PM(t,e);if(HE(t))return UM(t,e);if(GE(t))return zM(t,e);if(WE(t))return nA(t,e);if(XE(t))return qM(t,e);if(JE(t))return VM(t,e)}throw ZE(t)}function GM(t,e){return e?HM(t,e):Ho(t)}var jM=ME(function(t){return function(){t(this),this.name="EmptyError",this.message="no elements in sequence"}});function rA(t,e){var n=typeof e=="object";return new Promise(function(r,i){var a=new Nf({next:function(o){r(o),a.unsubscribe()},error:i,complete:function(){n?r(e.defaultValue):i(new jM)}});t.subscribe(a)})}function iA(t,e){return Vo(function(n,r){var i=0;n.subscribe(dl(r,function(a){r.next(t.call(e,a,i++))}))})}function WM(t,e,n,r,i,a,o,s){var u=[],l=0,f=0,c=!1,h=function(){c&&!u.length&&!l&&e.complete()},d=function(m){return l<r?p(m):u.push(m)},p=function(m){a&&e.next(m),l++;var y=!1;Ho(n(m,f++)).subscribe(dl(e,function(w){i==null||i(w),a?d(w):e.next(w)},function(){y=!0},void 0,function(){if(y)try{l--;for(var w=function(){var A=u.shift();o?li(e,o,function(){return p(A)}):p(A)};u.length&&l<r;)w();h()}catch(A){e.error(A)}}))};return t.subscribe(dl(e,d,function(){c=!0,h()})),function(){s==null||s()}}function aA(t,e,n){return n===void 0&&(n=1/0),nt(e)?aA(function(r,i){return iA(function(a,o){return e(r,a,i,o)})(Ho(t(r,i)))},n):(typeof e=="number"&&(n=e),Vo(function(r,i){return WM(r,i,t,n)}))}function ZM(t){return t===void 0&&(t=1/0),aA(qE,t)}function YM(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=kM(t),r=RM(t,1/0),i=t;return i.length?i.length===1?Ho(i[0]):ZM(r)(GM(i,n)):FM}function XM(t,e,n,r,i){return function(a,o){var s=n,u=e,l=0;a.subscribe(dl(o,function(f){var c=l++;u=s?t(u,f,c):(s=!0,f),r&&o.next(u)},i&&function(){s&&o.next(u),o.complete()}))}}function oA(t,e){return Vo(XM(t,e,arguments.length>=2,!1,!0))}var KM=function(t,e){return t.push(e),t};function JM(){return Vo(function(t,e){oA(KM,[])(t).subscribe(e)})}const Oy=-2003829722,ad=-2021002517;function QM(t){return new TextDecoder().decode(t)}function Ly(t){const e=t?"big":"little",n=new Ce().endianess(e).int32("magic").uint16("version").uint16("numZoomLevels").uint64("chromTreeOffset").uint64("unzoomedDataOffset").uint64("unzoomedIndexOffset").uint16("fieldCount").uint16("definedFieldCount").uint64("asOffset").uint64("totalSummaryOffset").uint32("uncompressBufSize").uint64("extHeaderOffset").array("zoomLevels",{length:"numZoomLevels",type:new Ce().endianess(e).uint32("reductionLevel").uint32("reserved").uint64("dataOffset").uint64("indexOffset")}),r=new Ce().endianess(e).uint64("basesCovered").doublele("scoreMin").doublele("scoreMax").doublele("scoreSum").doublele("scoreSumSquares"),i=new Ce().endianess(e).uint32("magic").uint32("blockSize").uint32("keySize").uint32("valSize").uint64("itemCount"),a=new Ce().endianess(e).uint8("isLeafNode").skip(1).uint16("cnt").saveOffset("offset");return{chromTreeParser:i,totalSummaryParser:r,headerParser:n,isLeafNode:a}}class sA{getHeader(e){return this.headerP||(this.headerP=this._getHeader(e).catch(n=>{throw this.headerP=void 0,n})),this.headerP}constructor(e){const{filehandle:n,renameRefSeqs:r=o=>o,path:i,url:a}=e;if(this.renameRefSeqs=r,n)this.bbi=n;else if(a)this.bbi=new Qn(a);else if(i)this.bbi=new Yt(i);else throw new Error("no file given")}async _getHeader(e){const n=await this._getMainHeader(e),r=await this._readChromTree(n,e);return{...n,...r}}async _getMainHeader(e,n=2e3){const{buffer:r}=await this.bbi.read(Je.Buffer.alloc(n),0,n,0,e),i=this._isBigEndian(r),a=Ly(i),o=a.headerParser.parse(r),{magic:s,asOffset:u,totalSummaryOffset:l}=o;if(o.fileType=s===ad?"bigbed":"bigwig",u>n||l>n)return this._getMainHeader(e,n*2);if(u){const f=Number(o.asOffset);o.autoSql=QM(r.subarray(f,r.indexOf(0,f)))}if(o.totalSummaryOffset>n-8*5)return this._getMainHeader(e,n*2);if(o.totalSummaryOffset){const f=r.subarray(Number(o.totalSummaryOffset)),c=a.totalSummaryParser.parse(f);o.totalSummary={...c,basesCovered:Number(c.basesCovered)}}return{...o,isBigEndian:i}}_isBigEndian(e){let n=e.readInt32LE(0);if(n===Oy||n===ad)return!1;if(n=e.readInt32BE(0),n===Oy||n===ad)return!0;throw new Error("not a BigWig/BigBed file")}async _readChromTree(e,n){const r=e.isBigEndian,i=r?"big":"little",a=[],o={};let s=Number(e.unzoomedDataOffset);const u=Number(e.chromTreeOffset);for(;s%4!==0;)s+=1;const l=s-u,{buffer:f}=await this.bbi.read(Je.Buffer.alloc(l),0,l,Number(u),n),c=Ly(r),{keySize:h}=c.chromTreeParser.parse(f),d=new Ce().endianess(i).string("key",{stripNull:!0,length:h}).uint32("refId").uint32("refSize").saveOffset("offset"),p=new Ce().endianess(i).skip(h).uint64("childOffset").saveOffset("offset"),m=32,y=async w=>{let A=w;if(A>=f.length)throw new Error("reading beyond end of buffer");const C=c.isLeafNode.parse(f.subarray(A)),{isLeafNode:E,cnt:k}=C;if(A+=C.offset,E)for(let R=0;R<k;R+=1){const I=d.parse(f.subarray(A));A+=I.offset;const{key:O,refId:T,refSize:B}=I,N={name:O,id:T,length:B};o[this.renameRefSeqs(O)]=T,a[T]=N}else{const R=[];for(let I=0;I<k;I+=1){const O=p.parse(f.subarray(A)),{childOffset:T}=O;A+=O.offset,R.push(y(Number(T)-Number(u)))}await Promise.all(R)}};return await y(m),{refsByName:o,refsByNumber:a}}async getUnzoomedView(e){const{unzoomedIndexOffset:n,refsByName:r,uncompressBufSize:i,isBigEndian:a,fileType:o}=await this.getHeader(e);return new OE(this.bbi,r,n,a,i>0,o)}async getFeatureStream(e,n,r,i){await this.getHeader(i);const a=this.renameRefSeqs(e);let o;const{basesPerSpan:s,scale:u}=i||{};return s?o=await this.getView(1/s,i):u?o=await this.getView(u,i):o=await this.getView(1,i),new wn(l=>{o.readWigData(a,n,r,l,i)})}async getFeatures(e,n,r,i){const a=await this.getFeatureStream(e,n,r,i);return(await rA(a.pipe(JM()))).flat()}}class eP extends sA{async getView(e,n){const{zoomLevels:r,refsByName:i,fileSize:a,isBigEndian:o,uncompressBufSize:s}=await this.getHeader(n),u=1/e;let l=r.length;a||(l-=1);for(let f=l;f>=0;f-=1){const c=r[f];if(c&&c.reductionLevel<=2*u){const h=Number(c.indexOffset);return new OE(this.bbi,i,h,o,s>0,"summary")}}return this.getUnzoomedView(n)}}function tP(t){return t.filter(e=>!!e)}class nP extends sA{constructor(){super(...arguments),this.readIndicesCache=new Vc({cache:new eE({maxSize:1}),fill:(e,n)=>this._readIndices({...e,signal:n})})}readIndices(e={}){const{signal:n,...r}=e;return this.readIndicesCache.get(JSON.stringify(r),e,n)}async getView(e,n){return this.getUnzoomedView(n)}async _readIndices(e){const{extHeaderOffset:n,isBigEndian:r}=await this.getHeader(e),{buffer:i}=await this.bbi.read(Je.Buffer.alloc(64),0,64,Number(n)),a=r?"big":"little",o=new Ce().endianess(a).uint16("size").uint16("count").uint64("offset").parse(i),{count:s,offset:u}=o;if(s===0)return[];const l=20,f=l*s,{buffer:c}=await this.bbi.read(Je.Buffer.alloc(f),0,f,Number(u)),h=new Ce().endianess(a).int16("type").int16("fieldcount").uint64("offset").skip(4).int16("field"),d=[];for(let p=0;p<s;p+=1)d.push(h.parse(c.subarray(p*l)));return d}async searchExtraIndexBlocks(e,n={}){const{isBigEndian:r}=await this.getHeader(n),i=await this.readIndices(n);if(i.length===0)return[];const a=i.map(async o=>{const{offset:s,field:u}=o,{buffer:l}=await this.bbi.read(Je.Buffer.alloc(32),0,32,Number(s),n),f=r?"big":"little",c=new Ce().endianess(f).int32("magic").int32("blockSize").int32("keySize").int32("valSize").uint64("itemCount"),{blockSize:h,keySize:d,valSize:p}=c.parse(l),m=new Ce().endianess(f).int8("nodeType").skip(1).int16("cnt").choice({tag:"nodeType",choices:{0:new Ce().array("leafkeys",{length:"cnt",type:new Ce().endianess(f).string("key",{length:d,stripNull:!0}).uint64("offset")}),1:new Ce().array("keys",{length:"cnt",type:new Ce().endianess(f).string("key",{length:d,stripNull:!0}).uint64("offset").uint32("length").uint32("reserved")})}}),y=async A=>{const C=Number(A),E=4+h*(d+p),{buffer:k}=await this.bbi.read(Je.Buffer.alloc(E),0,E,C,n),R=m.parse(k);if(R.leafkeys){let I;for(let O=0;O<R.leafkeys.length;O+=1){const{key:T}=R.leafkeys[O];if(e.localeCompare(T)<0&&I)return y(I);I=R.leafkeys[O].offset}return y(I)}for(let I=0;I<R.keys.length;I+=1)if(R.keys[I].key===e)return{...R.keys[I],field:u}},w=32;return y(Number(s)+w)});return tP(await Promise.all(a))}async searchExtraIndex(e,n={}){const r=await this.searchExtraIndexBlocks(e,n);if(r.length===0)return[];const i=await this.getUnzoomedView(n),a=r.map(s=>new wn(u=>{i.readFeatures(u,[s],n)}).pipe(oA((u,l)=>u.concat(l)),iA(u=>{for(const l of u)l.field=s.field;return u})));return(await rA(YM(...a))).filter(s=>{var u;return((u=s.rest)===null||u===void 0?void 0:u.split(" ")[(s.field||0)-3])===e})}}function Wc(t,e,n=!0){let r,i=o=>{};return function(...s){return new Promise((u,l)=>{const f=()=>{clearTimeout(r),i=c=>{},u(t(...s))};n&&i("debounced"),clearTimeout(r),i=l,r=window.setTimeout(f,e)})}}class rP extends Kl(wa){constructor(n,r){const i={pixelsPerBin:2,channel:"x",...n};super(r,i.channel);Gt(this,"reductionLevels",[]);Gt(this,"lastRequestId",0);if(this.params=i,!this.params.url)throw new Error("No URL provided for BigWigSource");this.bbi=new eP({filehandle:new Qn(Jl(this.params.url,this.view.getBaseUrl()))}),this.doDebouncedRequest=Wc(this.doRequest.bind(this),200,!1),this.headerPromise=this.bbi.getHeader(),this.headerPromise.then(a=>{this.reductionLevels=a.zoomLevels.map(o=>o.reductionLevel).reverse(),this.reductionLevels.push(1)})}async onDomainChanged(n){await this.headerPromise;const r=this.getAxisLength()||700,i=iP(n,r,this.reductionLevels),a=Math.max(i*r,5e3),o=this.quantizeInterval(n,a);this.checkAndUpdateLastInterval(o)&&this.doDebouncedRequest(o,i)}async doRequest(n,r){const i=await this.getFeatures(n,.5/r/this.params.pixelsPerBin);i.requestId<this.lastRequestId||this.publishData(i.features)}async getFeatures(n,r){let i=++this.lastRequestId;const a=new AbortController,o=this.genome.continuousToDiscreteChromosomeIntervals(n),s=await Promise.all(o.map(u=>this.bbi.getFeatures(u.chrom,u.startPos,u.endPos,{scale:r,signal:a.signal}).then(l=>l.map(f=>({chrom:u.chrom,start:f.start,end:f.end,score:f.score})))));return{requestId:i,abort:()=>a.abort(),features:s.flat()}}}function iP(t,e,n){const r=(t[1]-t[0])/e;return n.find(i=>i<r)??n.at(-1)}function aP(t,e){function n(){this.constructor=t}n.prototype=e.prototype,t.prototype=new n}function Co(t,e,n,r){this.message=t,this.expected=e,this.found=n,this.location=r,this.name="SyntaxError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,Co)}aP(Co,Error);Co.buildMessage=function(t,e){var n={literal:function(l){return'"'+i(l.text)+'"'},class:function(l){var f="",c;for(c=0;c<l.parts.length;c++)f+=l.parts[c]instanceof Array?a(l.parts[c][0])+"-"+a(l.parts[c][1]):a(l.parts[c]);return"["+(l.inverted?"^":"")+f+"]"},any:function(l){return"any character"},end:function(l){return"end of input"},other:function(l){return l.description}};function r(l){return l.charCodeAt(0).toString(16).toUpperCase()}function i(l){return l.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(f){return"\\x0"+r(f)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(f){return"\\x"+r(f)})}function a(l){return l.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(f){return"\\x0"+r(f)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(f){return"\\x"+r(f)})}function o(l){return n[l.type](l)}function s(l){var f=new Array(l.length),c,h;for(c=0;c<l.length;c++)f[c]=o(l[c]);if(f.sort(),f.length>0){for(c=1,h=1;c<f.length;c++)f[c-1]!==f[c]&&(f[h]=f[c],h++);f.length=h}switch(f.length){case 1:return f[0];case 2:return f[0]+" or "+f[1];default:return f.slice(0,-1).join(", ")+", or "+f[f.length-1]}}function u(l){return l?'"'+i(l)+'"':"end of input"}return"Expected "+s(t)+" but "+u(e)+" found."};function oP(t,e){e=e!==void 0?e:{};var n={},r={declaration:rm},i=rm,a="(",o=Fe("(",!1),s=")",u=Fe(")",!1),l=function(v,z,X,K){return{type:v,name:z,comment:X,fields:K}},f="simple",c=Fe("simple",!1),h="object",d=Fe("object",!1),p="table",m=Fe("table",!1),y="auto",w=Fe("auto",!1),A="primary",C=Fe("primary",!1),E="index",k=Fe("index",!1),R="unique",I=Fe("unique",!1),O=function(v,z){return z},T=function(v,z){return v.name&&z.unshift(v),z},B="#",N=Fe("#",!1),J=";",ee=Fe(";",!1),Q=function(v,z,X){return{type:v,name:z,comment:X}},he="[",be=Fe("[",!1),Se="]",Ke=Fe("]",!1),Ze=function(v,z,X,K){return{type:v,size:z,name:X,comment:K}},Mn=function(v,z,X,K){return{type:v,vals:z,name:X,comment:K}},ke=",",Pe=Fe(",",!1),kt=function(v,z){return z.unshift(v),z},xn="int",Pn=Fe("int",!1),M="uint",L=Fe("uint",!1),j="short",H=Fe("short",!1),Y="ushort",S=Fe("ushort",!1),_="byte",q=Fe("byte",!1),G="ubyte",ue=Fe("ubyte",!1),ne="float",fe=Fe("float",!1),Rt="char",Lr=Fe("char",!1),Mr="string",Pr=Fe("string",!1),mt="lstring",hr=Fe("lstring",!1),zr="enum",Dt=Fe("enum",!1),zn="double",x=Fe("double",!1),g="bigint",b=Fe("bigint",!1),F="set",$=Fe("set",!1),P=function(v,z){return v+" "+z},V=/^[a-zA-Z_]/,ce=Wo([["a","z"],["A","Z"],"_"],!1,!1),Oe=/^[a-zA-Z0-9_]/,Re=Wo([["a","z"],["A","Z"],["0","9"],"_"],!1,!1),ze=function(v){return Qg()},Ee=/^[^\n\r]/,Zg=Wo([` -`,"\r"],!0,!1),xS=function(v){return v.join("").replace(/^"/,"").replace(/"$/,"")},_S=em("integer"),Yg=/^[0-9]/,Xg=Wo([["0","9"]],!1,!1),vS=function(){return parseInt(Qg(),10)},ES=em("whitespace"),Kg=/^[ \t\n\r]/,Jg=Wo([" "," ",` -`,"\r"],!1,!1),D=0,At=0,ou=[{line:1,column:1}],Un=0,Xc=[],ae=0,su;if("startRule"in e){if(!(e.startRule in r))throw new Error(`Can't start parsing from rule "`+e.startRule+'".');i=r[e.startRule]}function Qg(){return t.substring(At,D)}function Fe(v,z){return{type:"literal",text:v,ignoreCase:z}}function Wo(v,z,X){return{type:"class",parts:v,inverted:z,ignoreCase:X}}function AS(){return{type:"end"}}function em(v){return{type:"other",description:v}}function tm(v){var z=ou[v],X;if(z)return z;for(X=v-1;!ou[X];)X--;for(z=ou[X],z={line:z.line,column:z.column};X<v;)t.charCodeAt(X)===10?(z.line++,z.column=1):z.column++,X++;return ou[v]=z,z}function nm(v,z){var X=tm(v),K=tm(z);return{start:{offset:v,line:X.line,column:X.column},end:{offset:z,line:K.line,column:K.column}}}function oe(v){D<Un||(D>Un&&(Un=D,Xc=[]),Xc.push(v))}function SS(v,z,X){return new Co(Co.buildMessage(v,z),v,z,X)}function rm(){var v,z,X,K,ie,Be,Ue,tn,Ur,dr,qr,pr,Vr,gr;return v=D,z=me(),z!==n?(X=im(),X!==n?(K=me(),K!==n?(ie=am(),ie!==n?(Be=me(),Be!==n?(Ue=lu(),Ue!==n?(tn=me(),tn!==n?(t.charCodeAt(D)===40?(Ur=a,D++):(Ur=n,ae===0&&oe(o)),Ur!==n?(dr=me(),dr!==n?(qr=CS(),qr!==n?(pr=me(),pr!==n?(t.charCodeAt(D)===41?(Vr=s,D++):(Vr=n,ae===0&&oe(u)),Vr!==n?(gr=me(),gr!==n?(At=v,z=l(X,ie,Ue,qr),v=z):(D=v,v=n)):(D=v,v=n)):(D=v,v=n)):(D=v,v=n)):(D=v,v=n)):(D=v,v=n)):(D=v,v=n)):(D=v,v=n)):(D=v,v=n)):(D=v,v=n)):(D=v,v=n)):(D=v,v=n)):(D=v,v=n),v}function im(){var v;return t.substr(D,6)===f?(v=f,D+=6):(v=n,ae===0&&oe(c)),v===n&&(t.substr(D,6)===h?(v=h,D+=6):(v=n,ae===0&&oe(d)),v===n&&(t.substr(D,5)===p?(v=p,D+=5):(v=n,ae===0&&oe(m)))),v}function am(){var v,z,X,K;return v=_n(),v===n&&(v=D,z=_n(),z!==n?(X=om(),X!==n?(z=[z,X],v=z):(D=v,v=n)):(D=v,v=n),v===n&&(v=D,z=_n(),z!==n?(t.substr(D,4)===y?(X=y,D+=4):(X=n,ae===0&&oe(w)),X!==n?(z=[z,X],v=z):(D=v,v=n)):(D=v,v=n),v===n&&(v=D,z=_n(),z!==n?(X=om(),X!==n?(t.substr(D,4)===y?(K=y,D+=4):(K=n,ae===0&&oe(w)),K!==n?(z=[z,X,K],v=z):(D=v,v=n)):(D=v,v=n)):(D=v,v=n)))),v}function om(){var v;return t.substr(D,7)===A?(v=A,D+=7):(v=n,ae===0&&oe(C)),v===n&&(t.substr(D,5)===E?(v=E,D+=5):(v=n,ae===0&&oe(k)),v===n&&(t.substr(D,6)===R?(v=R,D+=6):(v=n,ae===0&&oe(I)))),v}function lu(){var v;return v=sm(),v===n&&(v=me()),v}function CS(){var v,z,X,K,ie,Be,Ue;if(v=D,z=Kc(),z!==n)if(X=me(),X!==n){for(K=[],ie=D,Be=me(),Be!==n?(Ue=Kc(),Ue!==n?(At=ie,Be=O(z,Ue),ie=Be):(D=ie,ie=n)):(D=ie,ie=n);ie!==n;)K.push(ie),ie=D,Be=me(),Be!==n?(Ue=Kc(),Ue!==n?(At=ie,Be=O(z,Ue),ie=Be):(D=ie,ie=n)):(D=ie,ie=n);K!==n?(ie=me(),ie!==n?(At=v,z=T(z,K),v=z):(D=v,v=n)):(D=v,v=n)}else D=v,v=n;else D=v,v=n;return v}function TS(){var v;return t.charCodeAt(D)===35?(v=B,D++):(v=n,ae===0&&oe(N)),v}function FS(){var v,z,X,K,ie;return v=D,z=me(),z!==n?(X=TS(),X!==n?(K=sm(),K!==n?(ie=me(),ie!==n?(z=[z,X,K,ie],v=z):(D=v,v=n)):(D=v,v=n)):(D=v,v=n)):(D=v,v=n),v}function Kc(){var v,z,X,K,ie,Be,Ue,tn,Ur,dr,qr,pr,Vr,gr;return v=D,z=Jc(),z!==n?(X=me(),X!==n?(K=_n(),K!==n?(ie=me(),ie!==n?(t.charCodeAt(D)===59?(Be=J,D++):(Be=n,ae===0&&oe(ee)),Be!==n?(Ue=me(),Ue!==n?(tn=lu(),tn!==n?(At=v,z=Q(z,K,tn),v=z):(D=v,v=n)):(D=v,v=n)):(D=v,v=n)):(D=v,v=n)):(D=v,v=n)):(D=v,v=n)):(D=v,v=n),v===n&&(v=D,z=Jc(),z!==n?(X=me(),X!==n?(t.charCodeAt(D)===91?(K=he,D++):(K=n,ae===0&&oe(be)),K!==n?(ie=me(),ie!==n?(Be=kS(),Be!==n?(Ue=me(),Ue!==n?(t.charCodeAt(D)===93?(tn=Se,D++):(tn=n,ae===0&&oe(Ke)),tn!==n?(Ur=me(),Ur!==n?(dr=_n(),dr!==n?(qr=me(),qr!==n?(t.charCodeAt(D)===59?(pr=J,D++):(pr=n,ae===0&&oe(ee)),pr!==n?(Vr=me(),Vr!==n?(gr=lu(),gr!==n?(At=v,z=Ze(z,Be,dr,gr),v=z):(D=v,v=n)):(D=v,v=n)):(D=v,v=n)):(D=v,v=n)):(D=v,v=n)):(D=v,v=n)):(D=v,v=n)):(D=v,v=n)):(D=v,v=n)):(D=v,v=n)):(D=v,v=n)):(D=v,v=n)):(D=v,v=n),v===n&&(v=D,z=Jc(),z!==n?(X=me(),X!==n?(t.charCodeAt(D)===40?(K=a,D++):(K=n,ae===0&&oe(o)),K!==n?(ie=me(),ie!==n?(Be=IS(),Be!==n?(Ue=me(),Ue!==n?(t.charCodeAt(D)===41?(tn=s,D++):(tn=n,ae===0&&oe(u)),tn!==n?(Ur=me(),Ur!==n?(dr=_n(),dr!==n?(qr=me(),qr!==n?(t.charCodeAt(D)===59?(pr=J,D++):(pr=n,ae===0&&oe(ee)),pr!==n?(Vr=me(),Vr!==n?(gr=lu(),gr!==n?(At=v,z=Mn(z,Be,dr,gr),v=z):(D=v,v=n)):(D=v,v=n)):(D=v,v=n)):(D=v,v=n)):(D=v,v=n)):(D=v,v=n)):(D=v,v=n)):(D=v,v=n)):(D=v,v=n)):(D=v,v=n)):(D=v,v=n)):(D=v,v=n)):(D=v,v=n),v===n&&(v=FS()))),v}function IS(){var v,z,X,K,ie,Be,Ue;if(v=D,z=_n(),z!==n){for(X=[],K=D,t.charCodeAt(D)===44?(ie=ke,D++):(ie=n,ae===0&&oe(Pe)),ie!==n?(Be=me(),Be!==n?(Ue=_n(),Ue!==n?(At=K,ie=O(z,Ue),K=ie):(D=K,K=n)):(D=K,K=n)):(D=K,K=n);K!==n;)X.push(K),K=D,t.charCodeAt(D)===44?(ie=ke,D++):(ie=n,ae===0&&oe(Pe)),ie!==n?(Be=me(),Be!==n?(Ue=_n(),Ue!==n?(At=K,ie=O(z,Ue),K=ie):(D=K,K=n)):(D=K,K=n)):(D=K,K=n);X!==n?(At=v,z=kt(z,X),v=z):(D=v,v=n)}else D=v,v=n;return v}function Jc(){var v,z,X,K;return t.substr(D,3)===xn?(v=xn,D+=3):(v=n,ae===0&&oe(Pn)),v===n&&(t.substr(D,4)===M?(v=M,D+=4):(v=n,ae===0&&oe(L)),v===n&&(t.substr(D,5)===j?(v=j,D+=5):(v=n,ae===0&&oe(H)),v===n&&(t.substr(D,6)===Y?(v=Y,D+=6):(v=n,ae===0&&oe(S)),v===n&&(t.substr(D,4)===_?(v=_,D+=4):(v=n,ae===0&&oe(q)),v===n&&(t.substr(D,5)===G?(v=G,D+=5):(v=n,ae===0&&oe(ue)),v===n&&(t.substr(D,5)===ne?(v=ne,D+=5):(v=n,ae===0&&oe(fe)),v===n&&(t.substr(D,4)===Rt?(v=Rt,D+=4):(v=n,ae===0&&oe(Lr)),v===n&&(t.substr(D,6)===Mr?(v=Mr,D+=6):(v=n,ae===0&&oe(Pr)),v===n&&(t.substr(D,7)===mt?(v=mt,D+=7):(v=n,ae===0&&oe(hr)),v===n&&(t.substr(D,4)===zr?(v=zr,D+=4):(v=n,ae===0&&oe(Dt)),v===n&&(t.substr(D,6)===zn?(v=zn,D+=6):(v=n,ae===0&&oe(x)),v===n&&(t.substr(D,6)===g?(v=g,D+=6):(v=n,ae===0&&oe(b)),v===n&&(t.substr(D,3)===F?(v=F,D+=3):(v=n,ae===0&&oe($)),v===n&&(v=D,z=im(),z!==n?(X=me(),X!==n?(K=am(),K!==n?(At=v,z=P(z,K),v=z):(D=v,v=n)):(D=v,v=n)):(D=v,v=n))))))))))))))),v}function kS(){var v;return v=RS(),v===n&&(v=_n()),v}function _n(){var v,z,X,K,ie;if(v=D,z=D,V.test(t.charAt(D))?(X=t.charAt(D),D++):(X=n,ae===0&&oe(ce)),X!==n){for(K=[],Oe.test(t.charAt(D))?(ie=t.charAt(D),D++):(ie=n,ae===0&&oe(Re));ie!==n;)K.push(ie),Oe.test(t.charAt(D))?(ie=t.charAt(D),D++):(ie=n,ae===0&&oe(Re));K!==n?(X=[X,K],z=X):(D=z,z=n)}else D=z,z=n;return z!==n&&(At=v,z=ze()),v=z,v}function sm(){var v,z,X;for(v=D,z=[],Ee.test(t.charAt(D))?(X=t.charAt(D),D++):(X=n,ae===0&&oe(Zg));X!==n;)z.push(X),Ee.test(t.charAt(D))?(X=t.charAt(D),D++):(X=n,ae===0&&oe(Zg));return z!==n&&(At=v,z=xS(z)),v=z,v}function RS(){var v,z,X,K;if(ae++,v=D,z=me(),z!==n){if(X=[],Yg.test(t.charAt(D))?(K=t.charAt(D),D++):(K=n,ae===0&&oe(Xg)),K!==n)for(;K!==n;)X.push(K),Yg.test(t.charAt(D))?(K=t.charAt(D),D++):(K=n,ae===0&&oe(Xg));else X=n;X!==n?(At=v,z=vS(),v=z):(D=v,v=n)}else D=v,v=n;return ae--,v===n&&(z=n,ae===0&&oe(_S)),v}function me(){var v,z;for(ae++,v=[],Kg.test(t.charAt(D))?(z=t.charAt(D),D++):(z=n,ae===0&&oe(Jg));z!==n;)v.push(z),Kg.test(t.charAt(D))?(z=t.charAt(D),D++):(z=n,ae===0&&oe(Jg));return ae--,v===n&&(z=n,ae===0&&oe(ES)),v}if(su=i(),su!==n&&D===t.length)return su;throw su!==n&&D<t.length&&oe(AS()),SS(Xc,Un<t.length?t.charAt(Un):null,Un<t.length?nm(Un,Un+1):nm(Un,Un))}var lA={SyntaxError:Co,parse:oP};const sP=xa(lA),lP=`table bigChain -"bigChain pairwise alignment" - ( - string chrom; "Reference sequence chromosome or scaffold" - uint chromStart; "Start position in chromosome" - uint chromEnd; "End position in chromosome" - string name; "Name or ID of item, ideally both human readable and unique" - uint score; "Score (0-1000)" - char[1] strand; "+ or - for strand" - uint tSize; "size of target sequence" - string qName; "name of query sequence" - uint qSize; "size of query sequence" - uint qStart; "start of alignment on query sequence" - uint qEnd; "end of alignment on query sequence" - uint chainScore; "score from chain" - )`,uP=`table bigGenePred -"bigGenePred gene models" - ( - string chrom; "Reference sequence chromosome or scaffold" - uint chromStart; "Start position in chromosome" - uint chromEnd; "End position in chromosome" - string name; "Name or ID of item, ideally both human readable and unique" - uint score; "Score (0-1000)" - char[1] strand; "+ or - for strand" - uint thickStart; "Start of where display should be thick (start codon)" - uint thickEnd; "End of where display should be thick (stop codon)" - uint reserved; "RGB value (use R,G,B string in input file)" - int blockCount; "Number of blocks" - int[blockCount] blockSizes; "Comma separated list of block sizes" - int[blockCount] chromStarts; "Start positions relative to chromStart" - string name2; "Alternative/human readable name" - string cdsStartStat; "Status of CDS start annotation (none, unknown, incomplete, or complete)" - string cdsEndStat; "Status of CDS end annotation (none, unknown, incomplete, or complete)" - int[blockCount] exonFrames; "Exon frame {0,1,2}, or -1 if no frame for exon" - string type; "Transcript type" - string geneName; "Primary identifier for gene" - string geneName2; "Alternative/human readable gene name" - string geneType; "Gene type" - )`,fP=`table interact -"interaction between two regions" - ( - string chrom; "Chromosome (or contig, scaffold, etc.). For interchromosomal, use 2 records" - uint chromStart; "Start position of lower region. For interchromosomal, set to chromStart of this region" - uint chromEnd; "End position of upper region. For interchromosomal, set to chromEnd of this region" - string name; "Name of item, for display. Usually 'sourceName/targetName/exp' or empty" - uint score; "Score (0-1000)" - double value; "Strength of interaction or other data value. Typically basis for score" - string exp; "Experiment name (metadata for filtering). Use . if not applicable" - string color; "Item color. Specified as r,g,b or hexadecimal #RRGGBB or html color name, as in //www.w3.org/TR/css3-color/#html4. Use 0 and spectrum setting to shade by score" - string sourceChrom; "Chromosome of source region (directional) or lower region. For non-directional interchromosomal, chrom of this region." - uint sourceStart; "Start position in chromosome of source/lower/this region" - uint sourceEnd; "End position in chromosome of source/lower/this region" - string sourceName; "Identifier of source/lower/this region" - string sourceStrand; "Orientation of source/lower/this region: + or -. Use . if not applicable" - string targetChrom; "Chromosome of target region (directional) or upper region. For non-directional interchromosomal, chrom of other region" - uint targetStart; "Start position in chromosome of target/upper/this region" - uint targetEnd; "End position in chromosome of target/upper/this region" - string targetName; "Identifier of target/upper/this region" - string targetStrand; "Orientation of target/upper/this region: + or -. Use . if not applicable" - - )`,cP=`table bigLink -"bigLink pairwise alignment" - ( - string chrom; "Reference sequence chromosome or scaffold" - uint chromStart; "Start position in chromosome" - uint chromEnd; "End position in chromosome" - string name; "Name or ID of item, ideally both human readable and unique" - uint qStart; "start of alignment on query sequence" - )`,hP=`table bedMaf -"Bed3 with MAF block" - ( - string chrom; "Reference sequence chromosome or scaffold" - uint chromStart; "Start position in chromosome" - uint chromEnd; "End position in chromosome" - lstring mafBlock; "MAF block" - )`,dP=`table bigNarrowPeak -"BED6+4 Peaks of signal enrichment based on pooled, normalized (interpreted) data." -( - string chrom; "Reference sequence chromosome or scaffold" - uint chromStart; "Start position in chromosome" - uint chromEnd; "End position in chromosome" - string name; "Name given to a region (preferably unique). Use . if no name is assigned" - uint score; "Indicates how dark the peak will be displayed in the browser (0-1000) " - char[1] strand; "+ or - or . for unknown" - float signalValue; "Measurement of average enrichment for the region" - float pValue; "Statistical significance of signal value (-log10). Set to -1 if not used." - float qValue; "Statistical significance with multiple-test correction applied (FDR -log10). Set to -1 if not used." - int peak; "Point-source called for this peak; 0-based offset from chromStart. Set to -1 if no point-source called." -)`,pP=`table bigPsl -"bigPsl pairwise alignment" - ( - string chrom; "Reference sequence chromosome or scaffold" - uint chromStart; "Start position in chromosome" - uint chromEnd; "End position in chromosome" - string name; "Name or ID of item, ideally both human readable and unique" - uint score; "Score (0-1000)" - char[1] strand; "+ or - indicates whether the query aligns to the + or - strand on the reference" - uint thickStart; "Start of where display should be thick (start codon)" - uint thickEnd; "End of where display should be thick (stop codon)" - uint reserved; "RGB value (use R,G,B string in input file)" - int blockCount; "Number of blocks" - int[blockCount] blockSizes; "Comma separated list of block sizes" - int[blockCount] chromStarts; "Start positions relative to chromStart" - - uint oChromStart;"Start position in other chromosome" - uint oChromEnd; "End position in other chromosome" - char[1] oStrand; "+ or -, - means that psl was reversed into BED-compatible coordinates" - uint oChromSize; "Size of other chromosome." - int[blockCount] oChromStarts; "Start positions relative to oChromStart or from oChromStart+oChromSize depending on strand" - - lstring oSequence; "Sequence on other chrom (or empty)" - string oCDS; "CDS in NCBI format" - - uint chromSize;"Size of target chromosome" - - uint match; "Number of bases matched." - uint misMatch; " Number of bases that don't match " - uint repMatch; " Number of bases that match but are part of repeats " - uint nCount; " Number of 'N' bases " - uint seqType; "0=empty, 1=nucleotide, 2=amino_acid" - )`,gP=`table defaultBedSchema -"BED12" - ( - string chrom; "The name of the chromosome (e.g. chr3, chrY, chr2_random) or scaffold (e.g. scaffold10671)." - uint chromStart; "The starting position of the feature in the chromosome or scaffold. The first base in a chromosome is numbered 0." - uint chromEnd; "The ending position of the feature in the chromosome or scaffold. The chromEnd base is not included in the display of the feature. For example, the first 100 bases of a chromosome are defined as chromStart=0, chromEnd=100, and span the bases numbered 0-99." - string name; "Defines the name of the BED line." - float score; "Feature score, doesn't care about the 0-1000 limit as in bed" - char strand; "Defines the strand. Either '.' (=no strand) or '+' or '-'" - uint thickStart; "The starting position at which the feature is drawn thickly (for example, the start codon in gene displays). When there is no thick part, thickStart and thickEnd are usually set to the chromStart position." - uint thickEnd; "The ending position at which the feature is drawn thickly (for example the stop codon in gene displays)." - string itemRgb; "An RGB value of the form R,G,B (e.g. 255,0,0). " - uint blockCount; " The number of blocks (exons) in the BED line." - uint[blockCount] blockSizes; " A comma-separated list of the block sizes. The number of items in this list should correspond to blockCount." - uint[blockCount] blockStarts; "A comma-separated list of block starts. All of the blockStart positions should be calculated relative to chromStart. The number of items in this list should correspond to blockCount." - )`,mP=`table mafFrames -"codon frame assignment for MAF components" - ( - string chrom; "Reference sequence chromosome or scaffold" - uint chromStart; "Start range in chromosome" - uint chromEnd; "End range in chromosome" - string src; "Name of sequence source in MAF" - ubyte frame; "frame (0,1,2) for first base(+) or last bast(-)" - char[1] strand; "+ or -" - string name; "Name of gene used to define frame" - int prevFramePos; "target position of the previous base (in transcription direction) that continues this frame, or -1 if none, or frame not contiguous" - int nextFramePos; "target position of the next base (in transcription direction) that continues this frame, or -1 if none, or frame not contiguous" - ubyte isExonStart; "does this start the CDS portion of an exon?" - ubyte isExonEnd; "does this end the CDS portion of an exon?" - )`,bP=`table mafSummary -"Positions and scores for alignment blocks" - ( - string chrom; "Reference sequence chromosome or scaffold" - uint chromStart; "Start position in chromosome" - uint chromEnd; "End position in chromosome" - string src; "Sequence name or database of alignment" - float score; "Floating point score." - char[1] leftStatus; "Gap/break annotation for preceding block" - char[1] rightStatus; "Gap/break annotation for following block" - )`,yP=Object.freeze(Object.defineProperty({__proto__:null,bigChain:lP,bigGenePred:uP,bigInteract:fP,bigLink:cP,bigMaf:hP,bigNarrowPeak:dP,bigPsl:pP,defaultBedSchema:gP,mafFrames:mP,mafSummary:bP},Symbol.toStringTag,{value:"Module"})),od=Object.fromEntries(Object.entries(yP).map(([t,e])=>[t,lA.parse(e.trim())]));function sd(t){const e=["uint","int","float","long"];return{...t,fields:t.fields.map(n=>({...n,isArray:n.size&&n.type!=="char",arrayIsNumeric:n.size&&e.includes(n.type),isNumeric:!n.size&&e.includes(n.type)}))}}const wP={".":0,"-":-1,"+":1};function xP(t){var e;return t.length>=12&&!Number.isNaN(parseInt(t[9],10))&&((e=t[10])===null||e===void 0?void 0:e.split(",").filter(n=>!!n).length)===parseInt(t[9],10)}class _P{constructor(e={}){if(e.autoSql)this.autoSql=sd(sP.parse(e.autoSql));else if(e.type){if(!od[e.type])throw new Error("Type not found");this.autoSql=sd(od[e.type])}else this.autoSql=sd(od.defaultBedSchema),this.attemptDefaultBed=!0}parseLine(e,n={}){const{autoSql:r}=this,{uniqueId:i}=n,a=Array.isArray(e)?e:e.split(" ");let o={};if(!this.attemptDefaultBed||this.attemptDefaultBed&&xP(a))for(let s=0;s<r.fields.length;s++){const u=r.fields[s];let l=a[s];const{isNumeric:f,isArray:c,arrayIsNumeric:h,name:d}=u;if(l==null)break;if(l!=="."){if(f){const p=Number(l);l=Number.isNaN(p)?l:p}else c&&(l=l.split(","),l[l.length-1]===""&&l.pop(),h&&(l=l.map(p=>Number(p))));o[d]=l}}else{const s=["chrom","chromStart","chromEnd","name"];o=Object.fromEntries(a.map((u,l)=>[s[l]||"field"+l,u])),o.chromStart=+o.chromStart,o.chromEnd=+o.chromEnd,Number.isNaN(Number.parseFloat(o.field4))||(o.score=+o.field4,delete o.field4),(o.field5==="+"||o.field5==="-")&&(o.strand=o.field5,delete o.field5)}return i&&(o.uniqueId=i),o.strand=wP[o.strand]||0,o.chrom=decodeURIComponent(o.chrom),o}}class vP extends Kl(wa){constructor(n,r){const i={channel:"x",windowSize:1e6,...n};super(r,i.channel);Gt(this,"lastRequestId",0);Gt(this,"parser");if(this.params=i,!this.params.url)throw new Error("No URL provided for BigBedSource");this.bbi=new nP({filehandle:new Qn(Jl(this.params.url,this.view.getBaseUrl()))}),this.doDebouncedRequest=Wc(this.doRequest.bind(this),200,!1),this.headerPromise=this.bbi.getHeader(),this.headerPromise.then(a=>{this.parser=new _P({autoSql:a.autoSql})})}async onDomainChanged(n){const r=this.params.windowSize;if(n[1]-n[0]>r)return;const i=this.quantizeInterval(n,r);this.checkAndUpdateLastInterval(i)&&this.doDebouncedRequest(i)}async doRequest(n){const r=await this.getFeatures(n);r.requestId<this.lastRequestId||this.publishData(r.features)}async getFeatures(n){let r=++this.lastRequestId;const i=new AbortController,a=this.genome.continuousToDiscreteChromosomeIntervals(n),o=await Promise.all(a.map(s=>this.bbi.getFeatures(s.chrom,s.startPos,s.endPos,{signal:i.signal}).then(u=>u.map(l=>this.parser.parseLine(`${s.chrom} ${l.start} ${l.end} ${l.rest}`,{uniqueId:l.uniqueId})))));return{requestId:r,abort:()=>i.abort(),features:o.flat()}}}var EP=Ne,fn=null;try{fn=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch{}function Ne(t,e,n){this.low=t|0,this.high=e|0,this.unsigned=!!n}Ne.prototype.__isLong__;Object.defineProperty(Ne.prototype,"__isLong__",{value:!0});function Ht(t){return(t&&t.__isLong__)===!0}Ne.isLong=Ht;var My={},Py={};function Sa(t,e){var n,r,i;return e?(t>>>=0,(i=0<=t&&t<256)&&(r=Py[t],r)?r:(n=$e(t,(t|0)<0?-1:0,!0),i&&(Py[t]=n),n)):(t|=0,(i=-128<=t&&t<128)&&(r=My[t],r)?r:(n=$e(t,t<0?-1:0,!1),i&&(My[t]=n),n))}Ne.fromInt=Sa;function cn(t,e){if(isNaN(t))return e?Vi:hn;if(e){if(t<0)return Vi;if(t>=uA)return hA}else{if(t<=-Uy)return Ut;if(t+1>=Uy)return cA}return t<0?cn(-t,e).neg():$e(t%To|0,t/To|0,e)}Ne.fromNumber=cn;function $e(t,e,n){return new Ne(t,e,n)}Ne.fromBits=$e;var $f=Math.pow;function Ng(t,e,n){if(t.length===0)throw Error("empty string");if(t==="NaN"||t==="Infinity"||t==="+Infinity"||t==="-Infinity")return hn;if(typeof e=="number"?(n=e,e=!1):e=!!e,n=n||10,n<2||36<n)throw RangeError("radix");var r;if((r=t.indexOf("-"))>0)throw Error("interior hyphen");if(r===0)return Ng(t.substring(1),e,n).neg();for(var i=cn($f(n,8)),a=hn,o=0;o<t.length;o+=8){var s=Math.min(8,t.length-o),u=parseInt(t.substring(o,o+s),n);if(s<8){var l=cn($f(n,s));a=a.mul(l).add(cn(u))}else a=a.mul(i),a=a.add(cn(u))}return a.unsigned=e,a}Ne.fromString=Ng;function Ln(t,e){return typeof t=="number"?cn(t,e):typeof t=="string"?Ng(t,e):$e(t.low,t.high,typeof e=="boolean"?e:t.unsigned)}Ne.fromValue=Ln;var zy=65536,AP=1<<24,To=zy*zy,uA=To*To,Uy=uA/2,qy=Sa(AP),hn=Sa(0);Ne.ZERO=hn;var Vi=Sa(0,!0);Ne.UZERO=Vi;var qa=Sa(1);Ne.ONE=qa;var fA=Sa(1,!0);Ne.UONE=fA;var H0=Sa(-1);Ne.NEG_ONE=H0;var cA=$e(-1,2147483647,!1);Ne.MAX_VALUE=cA;var hA=$e(-1,-1,!0);Ne.MAX_UNSIGNED_VALUE=hA;var Ut=$e(0,-2147483648,!1);Ne.MIN_VALUE=Ut;var Z=Ne.prototype;Z.toInt=function(){return this.unsigned?this.low>>>0:this.low};Z.toNumber=function(){return this.unsigned?(this.high>>>0)*To+(this.low>>>0):this.high*To+(this.low>>>0)};Z.toString=function(e){if(e=e||10,e<2||36<e)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative())if(this.eq(Ut)){var n=cn(e),r=this.div(n),i=r.mul(n).sub(this);return r.toString(e)+i.toInt().toString(e)}else return"-"+this.neg().toString(e);for(var a=cn($f(e,6),this.unsigned),o=this,s="";;){var u=o.div(a),l=o.sub(u.mul(a)).toInt()>>>0,f=l.toString(e);if(o=u,o.isZero())return f+s;for(;f.length<6;)f="0"+f;s=""+f+s}};Z.getHighBits=function(){return this.high};Z.getHighBitsUnsigned=function(){return this.high>>>0};Z.getLowBits=function(){return this.low};Z.getLowBitsUnsigned=function(){return this.low>>>0};Z.getNumBitsAbs=function(){if(this.isNegative())return this.eq(Ut)?64:this.neg().getNumBitsAbs();for(var e=this.high!=0?this.high:this.low,n=31;n>0&&!(e&1<<n);n--);return this.high!=0?n+33:n+1};Z.isZero=function(){return this.high===0&&this.low===0};Z.eqz=Z.isZero;Z.isNegative=function(){return!this.unsigned&&this.high<0};Z.isPositive=function(){return this.unsigned||this.high>=0};Z.isOdd=function(){return(this.low&1)===1};Z.isEven=function(){return(this.low&1)===0};Z.equals=function(e){return Ht(e)||(e=Ln(e)),this.unsigned!==e.unsigned&&this.high>>>31===1&&e.high>>>31===1?!1:this.high===e.high&&this.low===e.low};Z.eq=Z.equals;Z.notEquals=function(e){return!this.eq(e)};Z.neq=Z.notEquals;Z.ne=Z.notEquals;Z.lessThan=function(e){return this.comp(e)<0};Z.lt=Z.lessThan;Z.lessThanOrEqual=function(e){return this.comp(e)<=0};Z.lte=Z.lessThanOrEqual;Z.le=Z.lessThanOrEqual;Z.greaterThan=function(e){return this.comp(e)>0};Z.gt=Z.greaterThan;Z.greaterThanOrEqual=function(e){return this.comp(e)>=0};Z.gte=Z.greaterThanOrEqual;Z.ge=Z.greaterThanOrEqual;Z.compare=function(e){if(Ht(e)||(e=Ln(e)),this.eq(e))return 0;var n=this.isNegative(),r=e.isNegative();return n&&!r?-1:!n&&r?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1};Z.comp=Z.compare;Z.negate=function(){return!this.unsigned&&this.eq(Ut)?Ut:this.not().add(qa)};Z.neg=Z.negate;Z.add=function(e){Ht(e)||(e=Ln(e));var n=this.high>>>16,r=this.high&65535,i=this.low>>>16,a=this.low&65535,o=e.high>>>16,s=e.high&65535,u=e.low>>>16,l=e.low&65535,f=0,c=0,h=0,d=0;return d+=a+l,h+=d>>>16,d&=65535,h+=i+u,c+=h>>>16,h&=65535,c+=r+s,f+=c>>>16,c&=65535,f+=n+o,f&=65535,$e(h<<16|d,f<<16|c,this.unsigned)};Z.subtract=function(e){return Ht(e)||(e=Ln(e)),this.add(e.neg())};Z.sub=Z.subtract;Z.multiply=function(e){if(this.isZero())return hn;if(Ht(e)||(e=Ln(e)),fn){var n=fn.mul(this.low,this.high,e.low,e.high);return $e(n,fn.get_high(),this.unsigned)}if(e.isZero())return hn;if(this.eq(Ut))return e.isOdd()?Ut:hn;if(e.eq(Ut))return this.isOdd()?Ut:hn;if(this.isNegative())return e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt(qy)&&e.lt(qy))return cn(this.toNumber()*e.toNumber(),this.unsigned);var r=this.high>>>16,i=this.high&65535,a=this.low>>>16,o=this.low&65535,s=e.high>>>16,u=e.high&65535,l=e.low>>>16,f=e.low&65535,c=0,h=0,d=0,p=0;return p+=o*f,d+=p>>>16,p&=65535,d+=a*f,h+=d>>>16,d&=65535,d+=o*l,h+=d>>>16,d&=65535,h+=i*f,c+=h>>>16,h&=65535,h+=a*l,c+=h>>>16,h&=65535,h+=o*u,c+=h>>>16,h&=65535,c+=r*f+i*l+a*u+o*s,c&=65535,$e(d<<16|p,c<<16|h,this.unsigned)};Z.mul=Z.multiply;Z.divide=function(e){if(Ht(e)||(e=Ln(e)),e.isZero())throw Error("division by zero");if(fn){if(!this.unsigned&&this.high===-2147483648&&e.low===-1&&e.high===-1)return this;var n=(this.unsigned?fn.div_u:fn.div_s)(this.low,this.high,e.low,e.high);return $e(n,fn.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?Vi:hn;var r,i,a;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return Vi;if(e.gt(this.shru(1)))return fA;a=Vi}else{if(this.eq(Ut)){if(e.eq(qa)||e.eq(H0))return Ut;if(e.eq(Ut))return qa;var o=this.shr(1);return r=o.div(e).shl(1),r.eq(hn)?e.isNegative()?qa:H0:(i=this.sub(e.mul(r)),a=r.add(i.div(e)),a)}else if(e.eq(Ut))return this.unsigned?Vi:hn;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();a=hn}for(i=this;i.gte(e);){r=Math.max(1,Math.floor(i.toNumber()/e.toNumber()));for(var s=Math.ceil(Math.log(r)/Math.LN2),u=s<=48?1:$f(2,s-48),l=cn(r),f=l.mul(e);f.isNegative()||f.gt(i);)r-=u,l=cn(r,this.unsigned),f=l.mul(e);l.isZero()&&(l=qa),a=a.add(l),i=i.sub(f)}return a};Z.div=Z.divide;Z.modulo=function(e){if(Ht(e)||(e=Ln(e)),fn){var n=(this.unsigned?fn.rem_u:fn.rem_s)(this.low,this.high,e.low,e.high);return $e(n,fn.get_high(),this.unsigned)}return this.sub(this.div(e).mul(e))};Z.mod=Z.modulo;Z.rem=Z.modulo;Z.not=function(){return $e(~this.low,~this.high,this.unsigned)};Z.and=function(e){return Ht(e)||(e=Ln(e)),$e(this.low&e.low,this.high&e.high,this.unsigned)};Z.or=function(e){return Ht(e)||(e=Ln(e)),$e(this.low|e.low,this.high|e.high,this.unsigned)};Z.xor=function(e){return Ht(e)||(e=Ln(e)),$e(this.low^e.low,this.high^e.high,this.unsigned)};Z.shiftLeft=function(e){return Ht(e)&&(e=e.toInt()),(e&=63)===0?this:e<32?$e(this.low<<e,this.high<<e|this.low>>>32-e,this.unsigned):$e(0,this.low<<e-32,this.unsigned)};Z.shl=Z.shiftLeft;Z.shiftRight=function(e){return Ht(e)&&(e=e.toInt()),(e&=63)===0?this:e<32?$e(this.low>>>e|this.high<<32-e,this.high>>e,this.unsigned):$e(this.high>>e-32,this.high>=0?0:-1,this.unsigned)};Z.shr=Z.shiftRight;Z.shiftRightUnsigned=function(e){if(Ht(e)&&(e=e.toInt()),e&=63,e===0)return this;var n=this.high;if(e<32){var r=this.low;return $e(r>>>e|n<<32-e,n>>>e,this.unsigned)}else return e===32?$e(n,0,this.unsigned):$e(n>>>e-32,0,this.unsigned)};Z.shru=Z.shiftRightUnsigned;Z.shr_u=Z.shiftRightUnsigned;Z.toSigned=function(){return this.unsigned?$e(this.low,this.high,!1):this};Z.toUnsigned=function(){return this.unsigned?this:$e(this.low,this.high,!0)};Z.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()};Z.toBytesLE=function(){var e=this.high,n=this.low;return[n&255,n>>>8&255,n>>>16&255,n>>>24,e&255,e>>>8&255,e>>>16&255,e>>>24]};Z.toBytesBE=function(){var e=this.high,n=this.low;return[e>>>24,e>>>16&255,e>>>8&255,e&255,n>>>24,n>>>16&255,n>>>8&255,n&255]};Ne.fromBytes=function(e,n,r){return r?Ne.fromBytesLE(e,n):Ne.fromBytesBE(e,n)};Ne.fromBytesLE=function(e,n){return new Ne(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,n)};Ne.fromBytesBE=function(e,n){return new Ne(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],n)};const Zc=xa(EP);let dA=class{constructor(e,n){this.blockPosition=e,this.dataPosition=n}toString(){return`${this.blockPosition}:${this.dataPosition}`}compareTo(e){return this.blockPosition-e.blockPosition||this.dataPosition-e.dataPosition}static min(...e){let n,r=0;for(;!n;r+=1)n=e[r];for(;r<e.length;r+=1)n.compareTo(e[r])>0&&(n=e[r]);return n}};function Xa(t,e=0,n=!1){if(n)throw new Error("big-endian virtual file offsets not implemented");return new dA(t[e+7]*1099511627776+t[e+6]*4294967296+t[e+5]*16777216+t[e+4]*65536+t[e+3]*256+t[e+2],t[e+1]<<8|t[e])}let Of=class{constructor(e,n,r,i=void 0){this.minv=e,this.maxv=n,this.bin=r,this._fetchedSize=i}toUniqueString(){return`${this.minv}..${this.maxv} (bin ${this.bin}, fetchedSize ${this.fetchedSize()})`}toString(){return this.toUniqueString()}compareTo(e){return this.minv.compareTo(e.minv)||this.maxv.compareTo(e.maxv)||this.bin-e.bin}fetchedSize(){return this._fetchedSize!==void 0?this._fetchedSize:this.maxv.blockPosition+65536-this.minv.blockPosition}},pA=class{constructor({filehandle:e,renameRefSeq:n=r=>r}){this.filehandle=e,this.renameRefSeq=n}_findFirstData(e,n){const r=e.firstDataLine;r?e.firstDataLine=r.compareTo(n)>0?n:r:e.firstDataLine=n}async parse(e={}){return this.setupP||(this.setupP=this._parse(e).catch(n=>{throw this.setupP=void 0,n})),this.setupP}async hasRefSeq(e,n={}){return!!((await this.parse(n)).indices[e]||{}).binIndex}};function SP(t){return new Promise(e=>setTimeout(e,t))}function gA(t){if(t.greaterThan(Number.MAX_SAFE_INTEGER)||t.lessThan(Number.MIN_SAFE_INTEGER))throw new Error("integer overflow");return t.toNumber()}function mA(t){if(t&&t.aborted){if(typeof DOMException<"u")throw new DOMException("aborted","AbortError");{const e=new Error("aborted");throw e.code="ERR_ABORTED",e}}}async function bA(t){await Promise.resolve(),mA(t)}function CP(t,e){return e.minv.blockPosition-t.maxv.blockPosition<65e3&&e.maxv.blockPosition-t.minv.blockPosition<5e6}function TP(t={}){return"aborted"in t?{signal:t}:t}function yA(t,e){const n=[];let r=null;return t.length===0?t:(t.sort((i,a)=>{const o=i.minv.blockPosition-a.minv.blockPosition;return o!==0?o:i.minv.dataPosition-a.minv.dataPosition}),t.forEach(i=>{(!e||i.maxv.compareTo(e)>0)&&(r===null?(n.push(i),r=i):CP(r,i)?i.maxv.compareTo(r.maxv)>0&&(r.maxv=i.maxv):(n.push(i),r=i))}),n)}const FP=21578050;function IP(t,e){return t-t%e}function kP(t,e){return t-t%e+e}class rs extends pA{parsePseudoBin(e,n){return{lineCount:gA(Zc.fromBytesLE(Array.prototype.slice.call(e,n+16,n+24),!0))}}async lineCount(e,n={}){const i=(await this.parse(n)).indices[e];if(!i)return-1;const a=i.stats||{};return a.lineCount===void 0?-1:a.lineCount}fetchBai(e={}){return this.baiP||(this.baiP=this.filehandle.readFile(e).catch(n=>{throw this.baiP=void 0,n})),this.baiP}async _parse(){const e={bai:!0,maxBlockSize:65536},n=await this.fetchBai();if(n.readUInt32LE(0)!==FP)throw new Error("Not a BAI file");e.refCount=n.readInt32LE(4);const i=((1<<(5+1)*3)-1)/7;e.indices=new Array(e.refCount);let a=8;for(let o=0;o<e.refCount;o+=1){const s=n.readInt32LE(a);let u;a+=4;const l={};for(let h=0;h<s;h+=1){const d=n.readUInt32LE(a);if(a+=4,d===i+1)a+=4,u=this.parsePseudoBin(n,a),a+=32;else{if(d>i+1)throw new Error("bai index contains too many bins, please use CSI");{const p=n.readInt32LE(a);a+=4;const m=new Array(p);for(let y=0;y<p;y+=1){const w=Xa(n,a),A=Xa(n,a+8);a+=16,this._findFirstData(e,w),m[y]=new Of(w,A,d)}l[d]=m}}}const f=n.readInt32LE(a);a+=4;const c=new Array(f);for(let h=0;h<f;h+=1)c[h]=Xa(n,a),a+=8,this._findFirstData(e,c[h]);e.indices[o]={binIndex:l,linearIndex:c,stats:u}}return e}async indexCov(e,n,r,i={}){const o=n!==void 0,u=(await this.parse(i)).indices[e];if(!u)return[];const{linearIndex:l=[],stats:f}=u;if(!l.length)return[];const c=r!==void 0?kP(r,16384):(l.length-1)*16384,h=n!==void 0?IP(n,16384):0;let d;o?d=new Array((c-h)/16384):d=new Array(l.length-1);const p=l[l.length-1].blockPosition;if(c>(l.length-1)*16384)throw new Error("query outside of range of linear index");let m=l[h/16384].blockPosition;for(let y=h/16384,w=0;y<c/16384;y++,w++)d[w]={score:l[y+1].blockPosition-m,start:y*16384,end:y*16384+16384},m=l[y+1].blockPosition;return d.map(y=>({...y,score:y.score*f.lineCount/p}))}reg2bins(e,n){return n-=1,[[0,0],[1+(e>>26),1+(n>>26)],[9+(e>>23),9+(n>>23)],[73+(e>>20),73+(n>>20)],[585+(e>>17),585+(n>>17)],[4681+(e>>14),4681+(n>>14)]]}async blocksForRange(e,n,r,i={}){n<0&&(n=0);const a=await this.parse(i);if(!a)return[];const o=a.indices[e];if(!o)return[];const s=this.reg2bins(n,r),u=[];for(const[d,p]of s)for(let m=d;m<=p;m++)if(o.binIndex[m]){const y=o.binIndex[m];for(let w=0;w<y.length;++w)u.push(new Of(y[w].minv,y[w].maxv,m))}const l=o.linearIndex.length;let f=null;const c=Math.min(n>>14,l-1),h=Math.min(r>>14,l-1);for(let d=c;d<=h;++d){const p=o.linearIndex[d];p&&(!f||p.compareTo(f)<0)&&(f=p)}return yA(u,f)}}const RP=21582659,DP=38359875;function BP(t,e){return t*2**e}function Vy(t,e){return Math.floor(t/2**e)}let ld=class extends pA{constructor(e){super(e),this.maxBinNumber=0,this.depth=0,this.minShift=0}async lineCount(e){const n=await this.parse();if(!n||!n.indices[e])return-1;const{stats:i}=n.indices[e];return i?i.lineCount:-1}async indexCov(){return[]}parseAuxData(e,n,r){if(r<30)return{};const i={};if(i.formatFlags=e.readInt32LE(n),i.coordinateType=i.formatFlags&65536?"zero-based-half-open":"1-based-closed",i.format={0:"generic",1:"SAM",2:"VCF"}[i.formatFlags&15],!i.format)throw new Error(`invalid Tabix preset format flags ${i.formatFlags}`);i.columnNumbers={ref:e.readInt32LE(n+4),start:e.readInt32LE(n+8),end:e.readInt32LE(n+12)},i.metaValue=e.readInt32LE(n+16),i.metaChar=i.metaValue?String.fromCharCode(i.metaValue):"",i.skipLines=e.readInt32LE(n+20);const a=e.readInt32LE(n+24);return Object.assign(i,this._parseNameBytes(e.subarray(n+28,n+28+a))),i}_parseNameBytes(e){let n=0,r=0;const i=[],a={};for(let o=0;o<e.length;o+=1)if(!e[o]){if(r<o){let s=e.toString("utf8",r,o);s=this.renameRefSeq(s),i[n]=s,a[s]=n}r=o+1,n+=1}return{refNameToId:a,refIdToName:i}}async _parse(e){const n={csi:!0,maxBlockSize:65536},r=await this.filehandle.readFile(e),i=await xo(r);if(i.readUInt32LE(0)===RP)n.csiVersion=1;else if(i.readUInt32LE(0)===DP)n.csiVersion=2;else throw new Error("Not a CSI file");this.minShift=i.readInt32LE(4),this.depth=i.readInt32LE(8),this.maxBinNumber=((1<<(this.depth+1)*3)-1)/7;const a=i.readInt32LE(12);a&&Object.assign(n,this.parseAuxData(i,16,a)),n.refCount=i.readInt32LE(16+a),n.indices=new Array(n.refCount);let o=16+a+4;for(let s=0;s<n.refCount;s+=1){await bA(e.signal);const u=i.readInt32LE(o);o+=4;const l={};let f;for(let c=0;c<u;c+=1){const h=i.readUInt32LE(o);if(h>this.maxBinNumber)f=this.parsePseudoBin(i,o+4),o+=4+8+4+16+16;else{const d=Xa(i,o+4);this._findFirstData(n,d);const p=i.readInt32LE(o+12);o+=16;const m=new Array(p);for(let y=0;y<p;y+=1){const w=Xa(i,o),A=Xa(i,o+8);o+=16,m[y]=new Of(w,A,h)}l[h]=m}}n.indices[s]={binIndex:l,stats:f}}return n}parsePseudoBin(e,n){return{lineCount:gA(Zc.fromBytesLE(Array.prototype.slice.call(e,n+28,n+36),!0))}}async blocksForRange(e,n,r,i={}){n<0&&(n=0);const a=await this.parse(i),o=a==null?void 0:a.indices[e];if(!o)return[];const s=this.reg2bins(n,r),u=[];for(const[l,f]of s)for(let c=l;c<=f;c++)if(o.binIndex[c]){const h=o.binIndex[c];for(let d=0;d<h.length;++d)u.push(new Of(h[d].minv,h[d].maxv,c))}return yA(u,new dA(0,0))}reg2bins(e,n){e-=1,e<1&&(e=1),n>2**50&&(n=2**34),n-=1;let r=0,i=0,a=this.minShift+this.depth*3;const o=[];for(;r<=this.depth;a-=3,i+=BP(1,r*3),r+=1){const s=i+Vy(e,a),u=i+Vy(n,a);if(u-s+o.length>this.maxBinNumber)throw new Error(`query ${e}-${n} is too large for current binning scheme (shift ${this.minShift}, depth ${this.depth}), try a smaller query or a coarser index binning scheme`);o.push([s,u])}return o}};var Yr=Je.Buffer,G0=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];typeof Int32Array<"u"&&(G0=new Int32Array(G0));function wA(t){if(Yr.isBuffer(t))return t;var e=typeof Yr.alloc=="function"&&typeof Yr.from=="function";if(typeof t=="number")return e?Yr.alloc(t):new Yr(t);if(typeof t=="string")return e?Yr.from(t):new Yr(t);throw new Error("input must be buffer, number, or string, received "+typeof t)}function NP(t){var e=wA(4);return e.writeInt32BE(t,0),e}function $g(t,e){t=wA(t),Yr.isBuffer(e)&&(e=e.readUInt32BE(0));for(var n=~~e^-1,r=0;r<t.length;r++)n=G0[(n^t[r])&255]^n>>>8;return n^-1}function Og(){return NP($g.apply(null,arguments))}Og.signed=function(){return $g.apply(null,arguments)};Og.unsigned=function(){return $g.apply(null,arguments)>>>0};var $P=Og;const OP=xa($P);var ud,Hy;function LP(){if(Hy)return ud;Hy=1;var t=function(r,i){return Object.prototype.hasOwnProperty.call(r,i)},e=function(r,i){return Object.prototype.propertyIsEnumerable.call(r,i)};function n(r){if(r==null)throw new TypeError("Cannot convert undefined or null to object");var i=[];for(var a in r)t(r,a)&&e(r,a)&&i.push([a,r[a]]);return i}return ud=n,ud}var MP=typeof Object.entries=="function"?Object.entries:LP();const PP=xa(MP);let zP=class{constructor(e={}){if(!(e.maxSize&&e.maxSize>0))throw new TypeError("`maxSize` must be a number greater than 0");this.maxSize=e.maxSize,this.cache=new Map,this.oldCache=new Map,this._size=0}_set(e,n){this.cache.set(e,n),this._size++,this._size>=this.maxSize&&(this._size=0,this.oldCache=this.cache,this.cache=new Map)}get(e){if(this.cache.has(e))return this.cache.get(e);if(this.oldCache.has(e)){const n=this.oldCache.get(e);return this._set(e,n),n}}set(e,n){return this.cache.has(e)?this.cache.set(e,n):this._set(e,n),this}has(e){return this.cache.has(e)||this.oldCache.has(e)}peek(e){if(this.cache.has(e))return this.cache.get(e);if(this.oldCache.has(e))return this.oldCache.get(e)}delete(e){const n=this.cache.delete(e);return n&&this._size--,this.oldCache.delete(e)||n}clear(){this.cache.clear(),this.oldCache.clear(),this._size=0}*keys(){for(const[e]of this)yield e}*values(){for(const[,e]of this)yield e}*[Symbol.iterator](){for(const e of this.cache)yield e;for(const e of this.oldCache){const[n]=e;this.cache.has(n)||(yield e)}}get size(){let e=0;for(const n of this.oldCache.keys())this.cache.has(n)||e++;return this._size+e}};var UP=zP;const qP=xa(UP),nn={BAM_FPAIRED:1,BAM_FPROPER_PAIR:2,BAM_FUNMAP:4,BAM_FMUNMAP:8,BAM_FREVERSE:16,BAM_FMREVERSE:32,BAM_FREAD1:64,BAM_FREAD2:128,BAM_FSECONDARY:256,BAM_FQCFAIL:512,BAM_FDUP:1024,BAM_FSUPPLEMENTARY:2048},Gy="=ACMGRSVTWYHKDBN".split(""),is="MIDNSHP=X???????".split("");class VP{constructor(e){this.data={},this._tagList=[],this._allTagsParsed=!1;const{bytes:n,fileOffset:r}=e,{byteArray:i,start:a}=n;this.data={},this.bytes=n,this._id=r,this._refID=i.readInt32LE(a+4),this.data.start=i.readInt32LE(a+8),this.flags=(i.readInt32LE(a+16)&4294901760)>>16}get(e){return this[e]?this.data[e]?this.data[e]:(this.data[e]=this[e](),this.data[e]):this._get(e.toLowerCase())}end(){return this.get("start")+this.get("length_on_ref")}seq_id(){return this._refID}_get(e){return e in this.data?this.data[e]:(this.data[e]=this._parseTag(e),this.data[e])}_tags(){this._parseAllTags();let e=["seq"];this.isSegmentUnmapped()||e.push("start","end","strand","score","qual","MQ","CIGAR","length_on_ref","template_length"),this.isPaired()&&e.push("next_segment_position","pair_orientation"),e=e.concat(this._tagList||[]),Object.keys(this.data).forEach(r=>{r[0]!=="_"&&r!=="next_seq_id"&&e.push(r)});const n={};return e.filter(r=>{if(r in this.data&&this.data[r]===void 0||r==="CG"||r==="cg")return!1;const i=r.toLowerCase(),a=n[i];return n[i]=!0,!a})}parent(){}children(){return this.get("subfeatures")}id(){return this._id}mq(){const e=(this.get("_bin_mq_nl")&65280)>>8;return e===255?void 0:e}score(){return this.get("mq")}qual(){var e;return(e=this.qualRaw())===null||e===void 0?void 0:e.join(" ")}qualRaw(){if(this.isSegmentUnmapped())return;const{start:e,byteArray:n}=this.bytes,r=e+36+this.get("_l_read_name")+this.get("_n_cigar_op")*4+this.get("_seq_bytes"),i=this.get("seq_length");return n.subarray(r,r+i)}strand(){return this.isReverseComplemented()?-1:1}multi_segment_next_segment_strand(){if(!this.isMateUnmapped())return this.isMateReverseComplemented()?-1:1}name(){return this.get("_read_name")}_read_name(){const e=this.get("_l_read_name"),{byteArray:n,start:r}=this.bytes;return n.toString("ascii",r+36,r+36+e-1)}_parseTag(e){if(this._allTagsParsed)return;const{byteArray:n,start:r}=this.bytes;let i=this._tagOffset||r+36+this.get("_l_read_name")+this.get("_n_cigar_op")*4+this.get("_seq_bytes")+this.get("seq_length");const a=this.bytes.end;let o;for(;i<a&&o!==e;){const s=String.fromCharCode(n[i],n[i+1]);o=s.toLowerCase();const u=String.fromCharCode(n[i+2]);i+=3;let l;switch(u){case"A":l=String.fromCharCode(n[i]),i+=1;break;case"i":l=n.readInt32LE(i),i+=4;break;case"I":l=n.readUInt32LE(i),i+=4;break;case"c":l=n.readInt8(i),i+=1;break;case"C":l=n.readUInt8(i),i+=1;break;case"s":l=n.readInt16LE(i),i+=2;break;case"S":l=n.readUInt16LE(i),i+=2;break;case"f":l=n.readFloatLE(i),i+=4;break;case"Z":case"H":for(l="";i<=a;){const f=n[i++];if(f===0)break;l+=String.fromCharCode(f)}break;case"B":{l="";const f=n[i++],c=String.fromCharCode(f),h=n.readInt32LE(i);if(i+=4,c==="i")if(s==="CG")for(let d=0;d<h;d++){const p=n.readInt32LE(i),m=p>>4,y=is[p&15];l+=m+y,i+=4}else for(let d=0;d<h;d++)l+=n.readInt32LE(i),d+1<h&&(l+=","),i+=4;if(c==="I")if(s==="CG")for(let d=0;d<h;d++){const p=n.readUInt32LE(i),m=p>>4,y=is[p&15];l+=m+y,i+=4}else for(let d=0;d<h;d++)l+=n.readUInt32LE(i),d+1<h&&(l+=","),i+=4;if(c==="s")for(let d=0;d<h;d++)l+=n.readInt16LE(i),d+1<h&&(l+=","),i+=2;if(c==="S")for(let d=0;d<h;d++)l+=n.readUInt16LE(i),d+1<h&&(l+=","),i+=2;if(c==="c")for(let d=0;d<h;d++)l+=n.readInt8(i),d+1<h&&(l+=","),i+=1;if(c==="C")for(let d=0;d<h;d++)l+=n.readUInt8(i),d+1<h&&(l+=","),i+=1;if(c==="f")for(let d=0;d<h;d++)l+=n.readFloatLE(i),d+1<h&&(l+=","),i+=4;break}default:console.warn(`Unknown BAM tag type '${u}', tags may be incomplete`),l=void 0,i=a}if(this._tagOffset=i,this._tagList.push(s),o===e)return l;this.data[o]=l}this._allTagsParsed=!0}_parseAllTags(){this._parseTag("")}_parseCigar(e){return e.match(/\d+\D/g).map(n=>[n.match(/\D/)[0].toUpperCase(),parseInt(n,10)])}isPaired(){return!!(this.flags&nn.BAM_FPAIRED)}isProperlyPaired(){return!!(this.flags&nn.BAM_FPROPER_PAIR)}isSegmentUnmapped(){return!!(this.flags&nn.BAM_FUNMAP)}isMateUnmapped(){return!!(this.flags&nn.BAM_FMUNMAP)}isReverseComplemented(){return!!(this.flags&nn.BAM_FREVERSE)}isMateReverseComplemented(){return!!(this.flags&nn.BAM_FMREVERSE)}isRead1(){return!!(this.flags&nn.BAM_FREAD1)}isRead2(){return!!(this.flags&nn.BAM_FREAD2)}isSecondary(){return!!(this.flags&nn.BAM_FSECONDARY)}isFailedQc(){return!!(this.flags&nn.BAM_FQCFAIL)}isDuplicate(){return!!(this.flags&nn.BAM_FDUP)}isSupplementary(){return!!(this.flags&nn.BAM_FSUPPLEMENTARY)}cigar(){if(this.isSegmentUnmapped())return;const{byteArray:e,start:n}=this.bytes,r=this.get("_n_cigar_op");let i=n+36+this.get("_l_read_name");const a=this.get("seq_length");let o="",s=0,u=e.readInt32LE(i),l=u>>4,f=is[u&15];if(f==="S"&&l===a)return i+=4,u=e.readInt32LE(i),l=u>>4,f=is[u&15],f!=="N"&&console.warn("CG tag with no N tag"),this.data.length_on_ref=l,this.get("CG");for(let c=0;c<r;++c)u=e.readInt32LE(i),l=u>>4,f=is[u&15],o+=l+f,f!=="H"&&f!=="S"&&f!=="I"&&(s+=l),i+=4;return this.data.length_on_ref=s,o}_flags(){}length_on_ref(){return this.data.length_on_ref?this.data.length_on_ref:(this.get("cigar"),this.data.length_on_ref)}_n_cigar_op(){return this.get("_flag_nc")&65535}_l_read_name(){return this.get("_bin_mq_nl")&255}_seq_bytes(){return this.get("seq_length")+1>>1}getReadBases(){return this.seq()}seq(){const{byteArray:e,start:n}=this.bytes,r=n+36+this.get("_l_read_name")+this.get("_n_cigar_op")*4,i=this.get("_seq_bytes"),a=this.get("seq_length");let o="",s=0;for(let u=0;u<i;++u){const l=e[r+u];o+=Gy[(l&240)>>4],s++,s<a&&(o+=Gy[l&15],s++)}return o}getPairOrientation(){if(!this.isSegmentUnmapped()&&!this.isMateUnmapped()&&this._refID===this._next_refid()){const e=this.isReverseComplemented()?"R":"F",n=this.isMateReverseComplemented()?"R":"F";let r=" ",i=" ";this.isRead1()?(r="1",i="2"):this.isRead2()&&(r="2",i="1");const a=[];return this.template_length()>0?(a[0]=e,a[1]=r,a[2]=n,a[3]=i):(a[2]=e,a[3]=r,a[0]=n,a[1]=i),a.join("")}return null}_bin_mq_nl(){return this.bytes.byteArray.readInt32LE(this.bytes.start+12)}_flag_nc(){return this.bytes.byteArray.readInt32LE(this.bytes.start+16)}seq_length(){return this.bytes.byteArray.readInt32LE(this.bytes.start+20)}_next_refid(){return this.bytes.byteArray.readInt32LE(this.bytes.start+24)}_next_pos(){return this.bytes.byteArray.readInt32LE(this.bytes.start+28)}template_length(){return this.bytes.byteArray.readInt32LE(this.bytes.start+32)}toJSON(){const e={};return Object.keys(this).forEach(n=>{n.charAt(0)==="_"||n==="bytes"||(e[n]=this[n])}),e}}function HP(t){const e=t.split(/\r?\n/),n=[];return e.forEach(r=>{const[i,...a]=r.split(/\t/),o=a.map(s=>{const[u,l]=s.split(":",2);return{tag:u,value:l}});i&&n.push({tag:i.substr(1),data:o})}),n}const GP=21840194,fd=65536;function cd(t){return[].concat(...t)}async function jP(t){const e=[];for await(const n of t)e.push(n);return e}class WP{constructor({bamFilehandle:e,bamPath:n,bamUrl:r,baiPath:i,baiFilehandle:a,baiUrl:o,csiPath:s,csiFilehandle:u,csiUrl:l,fetchSizeLimit:f,chunkSizeLimit:c,yieldThreadTime:h=100,renameRefSeqs:d=p=>p}){if(this.featureCache=new Vc({cache:new qP({maxSize:50}),fill:async({chunk:p,opts:m},y)=>{const{data:w,cpositions:A,dpositions:C}=await this._readChunk({chunk:p,opts:{...m,signal:y}});return await this.readBamFeatures(w,A,C,p)}}),this.renameRefSeq=d,e)this.bam=e;else if(n)this.bam=new Yt(n);else if(r)this.bam=new Qn(r);else throw new Error("unable to initialize bam");if(u)this.index=new ld({filehandle:u});else if(s)this.index=new ld({filehandle:new Yt(s)});else if(l)this.index=new ld({filehandle:new Qn(l)});else if(a)this.index=new rs({filehandle:a});else if(i)this.index=new rs({filehandle:new Yt(i)});else if(o)this.index=new rs({filehandle:new Qn(o)});else if(n)this.index=new rs({filehandle:new Yt(`${n}.bai`)});else if(r)this.index=new rs({filehandle:new Qn(`${r}.bai`)});else throw new Error("unable to infer index format");this.fetchSizeLimit=f||5e8,this.chunkSizeLimit=c||3e8,this.yieldThreadTime=h}async getHeader(e={}){const n=TP(e),r=await this.index.parse(n),i=r.firstDataLine?r.firstDataLine.blockPosition+65535:void 0;let a;if(i){const f=await this.bam.read(Buffer.alloc(i+fd),0,i+fd,0,n),{bytesRead:c}=f;if({buffer:a}=f,!c)throw new Error("Error reading header");c<i?a=a.subarray(0,c):a=a.subarray(0,i)}else a=await this.bam.readFile(n);const o=await xo(a);if(o.readInt32LE(0)!==GP)throw new Error("Not a BAM file");const s=o.readInt32LE(4);this.header=o.toString("utf8",8,8+s);const{chrToIndex:u,indexToChr:l}=await this._readRefSeqs(s+8,65535,n);return this.chrToIndex=u,this.indexToChr=l,HP(this.header)}async getHeaderText(e={}){return await this.getHeader(e),this.header}async _readRefSeqs(e,n,r={}){if(e>n)return this._readRefSeqs(e,n*2,r);const i=n+fd,{bytesRead:a,buffer:o}=await this.bam.read(Buffer.alloc(i),0,n,0,r);if(!a)throw new Error("Error reading refseqs from header");const s=await xo(o.subarray(0,Math.min(a,n))),u=s.readInt32LE(e);let l=e+4;const f={},c=[];for(let h=0;h<u;h+=1){const d=s.readInt32LE(l),p=this.renameRefSeq(s.toString("utf8",l+4,l+4+d-1)),m=s.readInt32LE(l+d+4);if(f[p]=h,c.push({refName:p,length:m}),l=l+8+d,l>s.length)return console.warn(`BAM header is very big. Re-fetching ${n} bytes.`),this._readRefSeqs(e,n*2,r)}return{chrToIndex:f,indexToChr:c}}async getRecordsForRange(e,n,r,i={viewAsPairs:!1,pairAcrossChr:!1,maxInsertSize:2e5}){return cd(await jP(this.streamRecordsForRange(e,n,r,i)))}async*streamRecordsForRange(e,n,r,i={}){const{signal:a}=i,o=this.chrToIndex&&this.chrToIndex[e];let s;if(!(o>=0))s=[];else if(s=await this.index.blocksForRange(o,n-1,r,i),!s)throw new Error("Error in index fetch");for(let l=0;l<s.length;l+=1){await bA(a);const f=s[l].fetchedSize();if(f>this.chunkSizeLimit)throw new Error(`Too many BAM features. BAM chunk size ${f} bytes exceeds chunkSizeLimit of ${this.chunkSizeLimit}`)}const u=s.map(l=>l.fetchedSize()).reduce((l,f)=>l+f,0);if(u>this.fetchSizeLimit)throw new Error(`data size of ${u.toLocaleString()} bytes exceeded fetch size limit of ${this.fetchSizeLimit.toLocaleString()} bytes`);yield*this._fetchChunkFeatures(s,o,n,r,i)}async*_fetchChunkFeatures(e,n,r,i,a){const{viewAsPairs:o=!1}=a,s=[];let u=!1;for(let l=0;l<e.length;l++){const f=e[l],c=await this.featureCache.get(f.toString(),{chunk:f,opts:a},a.signal),h=[];for(let d=0;d<c.length;d+=1){const p=c[d];if(p.seq_id()===n)if(p.get("start")>=i){u=!0;break}else p.get("end")>=r&&h.push(p)}if(s.push(h),yield h,u)break}mA(a.signal),o&&(yield this.fetchPairs(n,s,a))}async fetchPairs(e,n,r){const{pairAcrossChr:i=!1,maxInsertSize:a=2e5}=r,o={},s={};n.map(h=>{const d={};for(let p=0;p<h.length;p++){const m=h[p].name(),y=h[p].id();d[m]||(d[m]=0),d[m]++,s[y]=1}PP(d).forEach(([p,m])=>{m===1&&(o[p]=!0)})});const u=[];n.map(h=>{for(let d=0;d<h.length;d++){const p=h[d],m=p.name(),y=p.get("start"),w=p._next_pos(),A=p._next_refid();o[m]&&(i||A===e&&Math.abs(y-w)<a)&&u.push(this.index.blocksForRange(A,w,w+1,r))}});const l=cd(await Promise.all(u)).sort().filter((h,d,p)=>!d||h.toString()!==p[d-1].toString()),f=l.map(h=>h.fetchedSize()).reduce((h,d)=>h+d,0);if(f>this.fetchSizeLimit)throw new Error(`data size of ${f.toLocaleString()} bytes exceeded fetch size limit of ${this.fetchSizeLimit.toLocaleString()} bytes`);const c=l.map(async h=>{const{data:d,cpositions:p,dpositions:m,chunk:y}=await this._readChunk({chunk:h,opts:r}),w=await this.readBamFeatures(d,p,m,y),A=[];for(let C=0;C<w.length;C+=1){const E=w[C];o[E.get("name")]&&!s[E.id()]&&A.push(E)}return A});return cd(await Promise.all(c))}async _readChunk({chunk:e,opts:n}){const r=e.fetchedSize(),{buffer:i,bytesRead:a}=await this.bam.read(Buffer.alloc(r),0,r,e.minv.blockPosition,n),{buffer:o,cpositions:s,dpositions:u}=await G2(i.subarray(0,Math.min(a,r)),e);return{data:o,cpositions:s,dpositions:u,chunk:e}}async readBamFeatures(e,n,r,i){let a=0;const o=[];let s=0,u=+Date.now();for(;a+4<e.length;){const l=e.readInt32LE(a),f=a+4+l-1;if(r){for(;a+i.minv.dataPosition>=r[s++];);s--}if(f<e.length){const c=new VP({bytes:{byteArray:e,start:a,end:f},fileOffset:n?n[s]*256+(a-r[s])+i.minv.dataPosition+1:OP.signed(e.slice(a,f))});o.push(c),this.yieldThreadTime&&+Date.now()-u>this.yieldThreadTime&&(await SP(1),u=+Date.now())}a=f+1}return o}async hasRefSeq(e){const n=this.chrToIndex&&this.chrToIndex[e];return this.index.hasRefSeq(n)}async lineCount(e){const n=this.chrToIndex&&this.chrToIndex[e];return this.index.lineCount(n)}async indexCov(e,n,r){await this.index.parse();const i=this.chrToIndex&&this.chrToIndex[e];return this.index.indexCov(i,n,r)}async blocksForRange(e,n,r,i){await this.index.parse();const a=this.chrToIndex&&this.chrToIndex[e];return this.index.blocksForRange(a,n,r,i)}}(function(){(function(t){(function(e){var n={searchParams:"URLSearchParams"in t,iterable:"Symbol"in t&&"iterator"in Symbol,blob:"FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch{return!1}}(),formData:"FormData"in t,arrayBuffer:"ArrayBuffer"in t};function r(T){return T&&DataView.prototype.isPrototypeOf(T)}if(n.arrayBuffer)var i=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],a=ArrayBuffer.isView||function(T){return T&&i.indexOf(Object.prototype.toString.call(T))>-1};function o(T){if(typeof T!="string"&&(T=String(T)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(T))throw new TypeError("Invalid character in header field name");return T.toLowerCase()}function s(T){return typeof T!="string"&&(T=String(T)),T}function u(T){var B={next:function(){var N=T.shift();return{done:N===void 0,value:N}}};return n.iterable&&(B[Symbol.iterator]=function(){return B}),B}function l(T){this.map={},T instanceof l?T.forEach(function(B,N){this.append(N,B)},this):Array.isArray(T)?T.forEach(function(B){this.append(B[0],B[1])},this):T&&Object.getOwnPropertyNames(T).forEach(function(B){this.append(B,T[B])},this)}l.prototype.append=function(T,B){T=o(T),B=s(B);var N=this.map[T];this.map[T]=N?N+", "+B:B},l.prototype.delete=function(T){delete this.map[o(T)]},l.prototype.get=function(T){return T=o(T),this.has(T)?this.map[T]:null},l.prototype.has=function(T){return this.map.hasOwnProperty(o(T))},l.prototype.set=function(T,B){this.map[o(T)]=s(B)},l.prototype.forEach=function(T,B){for(var N in this.map)this.map.hasOwnProperty(N)&&T.call(B,this.map[N],N,this)},l.prototype.keys=function(){var T=[];return this.forEach(function(B,N){T.push(N)}),u(T)},l.prototype.values=function(){var T=[];return this.forEach(function(B){T.push(B)}),u(T)},l.prototype.entries=function(){var T=[];return this.forEach(function(B,N){T.push([N,B])}),u(T)},n.iterable&&(l.prototype[Symbol.iterator]=l.prototype.entries);function f(T){if(T.bodyUsed)return Promise.reject(new TypeError("Already read"));T.bodyUsed=!0}function c(T){return new Promise(function(B,N){T.onload=function(){B(T.result)},T.onerror=function(){N(T.error)}})}function h(T){var B=new FileReader,N=c(B);return B.readAsArrayBuffer(T),N}function d(T){var B=new FileReader,N=c(B);return B.readAsText(T),N}function p(T){for(var B=new Uint8Array(T),N=new Array(B.length),J=0;J<B.length;J++)N[J]=String.fromCharCode(B[J]);return N.join("")}function m(T){if(T.slice)return T.slice(0);var B=new Uint8Array(T.byteLength);return B.set(new Uint8Array(T)),B.buffer}function y(){return this.bodyUsed=!1,this._initBody=function(T){this._bodyInit=T,T?typeof T=="string"?this._bodyText=T:n.blob&&Blob.prototype.isPrototypeOf(T)?this._bodyBlob=T:n.formData&&FormData.prototype.isPrototypeOf(T)?this._bodyFormData=T:n.searchParams&&URLSearchParams.prototype.isPrototypeOf(T)?this._bodyText=T.toString():n.arrayBuffer&&n.blob&&r(T)?(this._bodyArrayBuffer=m(T.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):n.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(T)||a(T))?this._bodyArrayBuffer=m(T):this._bodyText=T=Object.prototype.toString.call(T):this._bodyText="",this.headers.get("content-type")||(typeof T=="string"?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):n.searchParams&&URLSearchParams.prototype.isPrototypeOf(T)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},n.blob&&(this.blob=function(){var T=f(this);if(T)return T;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?f(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(h)}),this.text=function(){var T=f(this);if(T)return T;if(this._bodyBlob)return d(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(p(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},n.formData&&(this.formData=function(){return this.text().then(E)}),this.json=function(){return this.text().then(JSON.parse)},this}var w=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function A(T){var B=T.toUpperCase();return w.indexOf(B)>-1?B:T}function C(T,B){B=B||{};var N=B.body;if(T instanceof C){if(T.bodyUsed)throw new TypeError("Already read");this.url=T.url,this.credentials=T.credentials,B.headers||(this.headers=new l(T.headers)),this.method=T.method,this.mode=T.mode,this.signal=T.signal,!N&&T._bodyInit!=null&&(N=T._bodyInit,T.bodyUsed=!0)}else this.url=String(T);if(this.credentials=B.credentials||this.credentials||"same-origin",(B.headers||!this.headers)&&(this.headers=new l(B.headers)),this.method=A(B.method||this.method||"GET"),this.mode=B.mode||this.mode||null,this.signal=B.signal||this.signal,this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&N)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(N)}C.prototype.clone=function(){return new C(this,{body:this._bodyInit})};function E(T){var B=new FormData;return T.trim().split("&").forEach(function(N){if(N){var J=N.split("="),ee=J.shift().replace(/\+/g," "),Q=J.join("=").replace(/\+/g," ");B.append(decodeURIComponent(ee),decodeURIComponent(Q))}}),B}function k(T){var B=new l,N=T.replace(/\r?\n[\t ]+/g," ");return N.split(/\r?\n/).forEach(function(J){var ee=J.split(":"),Q=ee.shift().trim();if(Q){var he=ee.join(":").trim();B.append(Q,he)}}),B}y.call(C.prototype);function R(T,B){B||(B={}),this.type="default",this.status=B.status===void 0?200:B.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in B?B.statusText:"OK",this.headers=new l(B.headers),this.url=B.url||"",this._initBody(T)}y.call(R.prototype),R.prototype.clone=function(){return new R(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new l(this.headers),url:this.url})},R.error=function(){var T=new R(null,{status:0,statusText:""});return T.type="error",T};var I=[301,302,303,307,308];R.redirect=function(T,B){if(I.indexOf(B)===-1)throw new RangeError("Invalid status code");return new R(null,{status:B,headers:{location:T}})},e.DOMException=t.DOMException;try{new e.DOMException}catch{e.DOMException=function(B,N){this.message=B,this.name=N;var J=Error(B);this.stack=J.stack},e.DOMException.prototype=Object.create(Error.prototype),e.DOMException.prototype.constructor=e.DOMException}function O(T,B){return new Promise(function(N,J){var ee=new C(T,B);if(ee.signal&&ee.signal.aborted)return J(new e.DOMException("Aborted","AbortError"));var Q=new XMLHttpRequest;function he(){Q.abort()}Q.onload=function(){var be={status:Q.status,statusText:Q.statusText,headers:k(Q.getAllResponseHeaders()||"")};be.url="responseURL"in Q?Q.responseURL:be.headers.get("X-Request-URL");var Se="response"in Q?Q.response:Q.responseText;N(new R(Se,be))},Q.onerror=function(){J(new TypeError("Network request failed"))},Q.ontimeout=function(){J(new TypeError("Network request failed"))},Q.onabort=function(){J(new e.DOMException("Aborted","AbortError"))},Q.open(ee.method,ee.url,!0),ee.credentials==="include"?Q.withCredentials=!0:ee.credentials==="omit"&&(Q.withCredentials=!1),"responseType"in Q&&n.blob&&(Q.responseType="blob"),ee.headers.forEach(function(be,Se){Q.setRequestHeader(Se,be)}),ee.signal&&(ee.signal.addEventListener("abort",he),Q.onreadystatechange=function(){Q.readyState===4&&ee.signal.removeEventListener("abort",he)}),Q.send(typeof ee._bodyInit>"u"?null:ee._bodyInit)})}return O.polyfill=!0,t.fetch||(t.fetch=O,t.Headers=l,t.Request=C,t.Response=R),e.Headers=l,e.Request=C,e.Response=R,e.fetch=O,Object.defineProperty(e,"__esModule",{value:!0}),e})({})})(typeof self<"u"?self:Qt)})();class ZP extends Kl(wa){constructor(n,r){const i={channel:"x",windowSize:2e4,...n};super(r,i.channel);Gt(this,"lastRequestId",0);Gt(this,"chrPrefixFixer",n=>n);if(this.params=i,!this.params.url)throw new Error("No URL provided for BamSource");const a=o=>new Qn(Jl(o,this.view.getBaseUrl()));this.bam=new WP({bamFilehandle:a(this.params.url),baiFilehandle:a(this.params.indexUrl??this.params.url+".bai")}),this.headerPromise=this.bam.getHeader(),this.headerPromise.then(o=>{var l,f;const s=this.genome.hasChrPrefix(),u=(f=(l=this.bam.indexToChr)==null?void 0:l[0])==null?void 0:f.refName.startsWith("chr");s&&!u?this.chrPrefixFixer=c=>c.replace("chr",""):!s&&u&&(this.chrPrefixFixer=c=>"chr"+c)})}async onDomainChanged(n){const r=this.params.windowSize;if(n[1]-n[0]>r)return;await this.headerPromise;const i=this.quantizeInterval(n,r);if(this.checkAndUpdateLastInterval(i)){const a=this.genome.continuousToDiscreteChromosomeIntervals(i),o=await Promise.all(a.map(s=>this.bam.getRecordsForRange(this.chrPrefixFixer(s.chrom),s.startPos,s.endPos).then(u=>u.map(l=>({chrom:s.chrom,start:l.get("start"),end:l.get("end"),name:l.get("name"),MD:l.get("MD"),cigar:l.get("cigar"),mapq:l.get("mq"),strand:l.get("strand")===1?"+":"-"})))));this.publishData(o.flat())}}}var Lg={exports:{}},Ka=typeof Reflect=="object"?Reflect:null,jy=Ka&&typeof Ka.apply=="function"?Ka.apply:function(e,n,r){return Function.prototype.apply.call(e,n,r)},Zu;Ka&&typeof Ka.ownKeys=="function"?Zu=Ka.ownKeys:Object.getOwnPropertySymbols?Zu=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Zu=function(e){return Object.getOwnPropertyNames(e)};function YP(t){console&&console.warn&&console.warn(t)}var xA=Number.isNaN||function(e){return e!==e};function Ie(){Ie.init.call(this)}Lg.exports=Ie;Lg.exports.once=QP;Ie.EventEmitter=Ie;Ie.prototype._events=void 0;Ie.prototype._eventsCount=0;Ie.prototype._maxListeners=void 0;var Wy=10;function Yc(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(Ie,"defaultMaxListeners",{enumerable:!0,get:function(){return Wy},set:function(t){if(typeof t!="number"||t<0||xA(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");Wy=t}});Ie.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};Ie.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||xA(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function _A(t){return t._maxListeners===void 0?Ie.defaultMaxListeners:t._maxListeners}Ie.prototype.getMaxListeners=function(){return _A(this)};Ie.prototype.emit=function(e){for(var n=[],r=1;r<arguments.length;r++)n.push(arguments[r]);var i=e==="error",a=this._events;if(a!==void 0)i=i&&a.error===void 0;else if(!i)return!1;if(i){var o;if(n.length>0&&(o=n[0]),o instanceof Error)throw o;var s=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw s.context=o,s}var u=a[e];if(u===void 0)return!1;if(typeof u=="function")jy(u,this,n);else for(var l=u.length,f=CA(u,l),r=0;r<l;++r)jy(f[r],this,n);return!0};function vA(t,e,n,r){var i,a,o;if(Yc(n),a=t._events,a===void 0?(a=t._events=Object.create(null),t._eventsCount=0):(a.newListener!==void 0&&(t.emit("newListener",e,n.listener?n.listener:n),a=t._events),o=a[e]),o===void 0)o=a[e]=n,++t._eventsCount;else if(typeof o=="function"?o=a[e]=r?[n,o]:[o,n]:r?o.unshift(n):o.push(n),i=_A(t),i>0&&o.length>i&&!o.warned){o.warned=!0;var s=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");s.name="MaxListenersExceededWarning",s.emitter=t,s.type=e,s.count=o.length,YP(s)}return t}Ie.prototype.addListener=function(e,n){return vA(this,e,n,!1)};Ie.prototype.on=Ie.prototype.addListener;Ie.prototype.prependListener=function(e,n){return vA(this,e,n,!0)};function XP(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function EA(t,e,n){var r={fired:!1,wrapFn:void 0,target:t,type:e,listener:n},i=XP.bind(r);return i.listener=n,r.wrapFn=i,i}Ie.prototype.once=function(e,n){return Yc(n),this.on(e,EA(this,e,n)),this};Ie.prototype.prependOnceListener=function(e,n){return Yc(n),this.prependListener(e,EA(this,e,n)),this};Ie.prototype.removeListener=function(e,n){var r,i,a,o,s;if(Yc(n),i=this._events,i===void 0)return this;if(r=i[e],r===void 0)return this;if(r===n||r.listener===n)--this._eventsCount===0?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,r.listener||n));else if(typeof r!="function"){for(a=-1,o=r.length-1;o>=0;o--)if(r[o]===n||r[o].listener===n){s=r[o].listener,a=o;break}if(a<0)return this;a===0?r.shift():KP(r,a),r.length===1&&(i[e]=r[0]),i.removeListener!==void 0&&this.emit("removeListener",e,s||n)}return this};Ie.prototype.off=Ie.prototype.removeListener;Ie.prototype.removeAllListeners=function(e){var n,r,i;if(r=this._events,r===void 0)return this;if(r.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):r[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete r[e]),this;if(arguments.length===0){var a=Object.keys(r),o;for(i=0;i<a.length;++i)o=a[i],o!=="removeListener"&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(n=r[e],typeof n=="function")this.removeListener(e,n);else if(n!==void 0)for(i=n.length-1;i>=0;i--)this.removeListener(e,n[i]);return this};function AA(t,e,n){var r=t._events;if(r===void 0)return[];var i=r[e];return i===void 0?[]:typeof i=="function"?n?[i.listener||i]:[i]:n?JP(i):CA(i,i.length)}Ie.prototype.listeners=function(e){return AA(this,e,!0)};Ie.prototype.rawListeners=function(e){return AA(this,e,!1)};Ie.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):SA.call(t,e)};Ie.prototype.listenerCount=SA;function SA(t){var e=this._events;if(e!==void 0){var n=e[t];if(typeof n=="function")return 1;if(n!==void 0)return n.length}return 0}Ie.prototype.eventNames=function(){return this._eventsCount>0?Zu(this._events):[]};function CA(t,e){for(var n=new Array(e),r=0;r<e;++r)n[r]=t[r];return n}function KP(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function JP(t){for(var e=new Array(t.length),n=0;n<e.length;++n)e[n]=t[n].listener||t[n];return e}function QP(t,e){return new Promise(function(n,r){function i(o){t.removeListener(e,a),r(o)}function a(){typeof t.removeListener=="function"&&t.removeListener("error",i),n([].slice.call(arguments))}TA(t,e,a,{once:!0}),e!=="error"&&e7(t,i,{once:!0})})}function e7(t,e,n){typeof t.on=="function"&&TA(t,"error",e,n)}function TA(t,e,n,r){if(typeof t.on=="function")r.once?t.once(e,n):t.on(e,n);else if(typeof t.addEventListener=="function")t.addEventListener(e,function i(a){r.once&&t.removeEventListener(e,i),n(a)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t)}var Mg=Lg.exports,j0={exports:{}};typeof Object.create=="function"?j0.exports=function(e,n){n&&(e.super_=n,e.prototype=Object.create(n.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:j0.exports=function(e,n){if(n){e.super_=n;var r=function(){};r.prototype=n.prototype,e.prototype=new r,e.prototype.constructor=e}};var Go=j0.exports,hd,Zy;function FA(){return Zy||(Zy=1,hd=Mg.EventEmitter),hd}const IA=i5(d5);var dd,Yy;function t7(){if(Yy)return dd;Yy=1;function t(p,m){var y=Object.keys(p);if(Object.getOwnPropertySymbols){var w=Object.getOwnPropertySymbols(p);m&&(w=w.filter(function(A){return Object.getOwnPropertyDescriptor(p,A).enumerable})),y.push.apply(y,w)}return y}function e(p){for(var m=1;m<arguments.length;m++){var y=arguments[m]!=null?arguments[m]:{};m%2?t(Object(y),!0).forEach(function(w){n(p,w,y[w])}):Object.getOwnPropertyDescriptors?Object.defineProperties(p,Object.getOwnPropertyDescriptors(y)):t(Object(y)).forEach(function(w){Object.defineProperty(p,w,Object.getOwnPropertyDescriptor(y,w))})}return p}function n(p,m,y){return m=o(m),m in p?Object.defineProperty(p,m,{value:y,enumerable:!0,configurable:!0,writable:!0}):p[m]=y,p}function r(p,m){if(!(p instanceof m))throw new TypeError("Cannot call a class as a function")}function i(p,m){for(var y=0;y<m.length;y++){var w=m[y];w.enumerable=w.enumerable||!1,w.configurable=!0,"value"in w&&(w.writable=!0),Object.defineProperty(p,o(w.key),w)}}function a(p,m,y){return m&&i(p.prototype,m),y&&i(p,y),Object.defineProperty(p,"prototype",{writable:!1}),p}function o(p){var m=s(p,"string");return typeof m=="symbol"?m:String(m)}function s(p,m){if(typeof p!="object"||p===null)return p;var y=p[Symbol.toPrimitive];if(y!==void 0){var w=y.call(p,m||"default");if(typeof w!="object")return w;throw new TypeError("@@toPrimitive must return a primitive value.")}return(m==="string"?String:Number)(p)}var u=Je,l=u.Buffer,f=IA,c=f.inspect,h=c&&c.custom||"inspect";function d(p,m,y){l.prototype.copy.call(p,m,y)}return dd=function(){function p(){r(this,p),this.head=null,this.tail=null,this.length=0}return a(p,[{key:"push",value:function(y){var w={data:y,next:null};this.length>0?this.tail.next=w:this.head=w,this.tail=w,++this.length}},{key:"unshift",value:function(y){var w={data:y,next:this.head};this.length===0&&(this.tail=w),this.head=w,++this.length}},{key:"shift",value:function(){if(this.length!==0){var y=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,y}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(y){if(this.length===0)return"";for(var w=this.head,A=""+w.data;w=w.next;)A+=y+w.data;return A}},{key:"concat",value:function(y){if(this.length===0)return l.alloc(0);for(var w=l.allocUnsafe(y>>>0),A=this.head,C=0;A;)d(A.data,w,C),C+=A.data.length,A=A.next;return w}},{key:"consume",value:function(y,w){var A;return y<this.head.data.length?(A=this.head.data.slice(0,y),this.head.data=this.head.data.slice(y)):y===this.head.data.length?A=this.shift():A=w?this._getString(y):this._getBuffer(y),A}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(y){var w=this.head,A=1,C=w.data;for(y-=C.length;w=w.next;){var E=w.data,k=y>E.length?E.length:y;if(k===E.length?C+=E:C+=E.slice(0,y),y-=k,y===0){k===E.length?(++A,w.next?this.head=w.next:this.head=this.tail=null):(this.head=w,w.data=E.slice(k));break}++A}return this.length-=A,C}},{key:"_getBuffer",value:function(y){var w=l.allocUnsafe(y),A=this.head,C=1;for(A.data.copy(w),y-=A.data.length;A=A.next;){var E=A.data,k=y>E.length?E.length:y;if(E.copy(w,w.length-y,0,k),y-=k,y===0){k===E.length?(++C,A.next?this.head=A.next:this.head=this.tail=null):(this.head=A,A.data=E.slice(k));break}++C}return this.length-=C,w}},{key:h,value:function(y,w){return c(this,e(e({},w),{},{depth:0,customInspect:!1}))}}]),p}(),dd}var pd,Xy;function kA(){if(Xy)return pd;Xy=1;function t(o,s){var u=this,l=this._readableState&&this._readableState.destroyed,f=this._writableState&&this._writableState.destroyed;return l||f?(s?s(o):o&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,process.nextTick(i,this,o)):process.nextTick(i,this,o)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(o||null,function(c){!s&&c?u._writableState?u._writableState.errorEmitted?process.nextTick(n,u):(u._writableState.errorEmitted=!0,process.nextTick(e,u,c)):process.nextTick(e,u,c):s?(process.nextTick(n,u),s(c)):process.nextTick(n,u)}),this)}function e(o,s){i(o,s),n(o)}function n(o){o._writableState&&!o._writableState.emitClose||o._readableState&&!o._readableState.emitClose||o.emit("close")}function r(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}function i(o,s){o.emit("error",s)}function a(o,s){var u=o._readableState,l=o._writableState;u&&u.autoDestroy||l&&l.autoDestroy?o.destroy(s):o.emit("error",s)}return pd={destroy:t,undestroy:r,errorOrDestroy:a},pd}var gd={},Ky;function jo(){if(Ky)return gd;Ky=1;function t(s,u){s.prototype=Object.create(u.prototype),s.prototype.constructor=s,s.__proto__=u}var e={};function n(s,u,l){l||(l=Error);function f(h,d,p){return typeof u=="string"?u:u(h,d,p)}var c=function(h){t(d,h);function d(p,m,y){return h.call(this,f(p,m,y))||this}return d}(l);c.prototype.name=l.name,c.prototype.code=s,e[s]=c}function r(s,u){if(Array.isArray(s)){var l=s.length;return s=s.map(function(f){return String(f)}),l>2?"one of ".concat(u," ").concat(s.slice(0,l-1).join(", "),", or ")+s[l-1]:l===2?"one of ".concat(u," ").concat(s[0]," or ").concat(s[1]):"of ".concat(u," ").concat(s[0])}else return"of ".concat(u," ").concat(String(s))}function i(s,u,l){return s.substr(!l||l<0?0:+l,u.length)===u}function a(s,u,l){return(l===void 0||l>s.length)&&(l=s.length),s.substring(l-u.length,l)===u}function o(s,u,l){return typeof l!="number"&&(l=0),l+u.length>s.length?!1:s.indexOf(u,l)!==-1}return n("ERR_INVALID_OPT_VALUE",function(s,u){return'The value "'+u+'" is invalid for option "'+s+'"'},TypeError),n("ERR_INVALID_ARG_TYPE",function(s,u,l){var f;typeof u=="string"&&i(u,"not ")?(f="must not be",u=u.replace(/^not /,"")):f="must be";var c;if(a(s," argument"))c="The ".concat(s," ").concat(f," ").concat(r(u,"type"));else{var h=o(s,".")?"property":"argument";c='The "'.concat(s,'" ').concat(h," ").concat(f," ").concat(r(u,"type"))}return c+=". Received type ".concat(typeof l),c},TypeError),n("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),n("ERR_METHOD_NOT_IMPLEMENTED",function(s){return"The "+s+" method is not implemented"}),n("ERR_STREAM_PREMATURE_CLOSE","Premature close"),n("ERR_STREAM_DESTROYED",function(s){return"Cannot call "+s+" after a stream was destroyed"}),n("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),n("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),n("ERR_STREAM_WRITE_AFTER_END","write after end"),n("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),n("ERR_UNKNOWN_ENCODING",function(s){return"Unknown encoding: "+s},TypeError),n("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),gd.codes=e,gd}var md,Jy;function RA(){if(Jy)return md;Jy=1;var t=jo().codes.ERR_INVALID_OPT_VALUE;function e(r,i,a){return r.highWaterMark!=null?r.highWaterMark:i?r[a]:null}function n(r,i,a,o){var s=e(i,o,a);if(s!=null){if(!(isFinite(s)&&Math.floor(s)===s)||s<0){var u=o?a:"highWaterMark";throw new t(u,s)}return Math.floor(s)}return r.objectMode?16:16*1024}return md={getHighWaterMark:n},md}var bd,Qy;function n7(){if(Qy)return bd;Qy=1,bd=t;function t(n,r){if(e("noDeprecation"))return n;var i=!1;function a(){if(!i){if(e("throwDeprecation"))throw new Error(r);e("traceDeprecation")?console.trace(r):console.warn(r),i=!0}return n.apply(this,arguments)}return a}function e(n){try{if(!Qt.localStorage)return!1}catch{return!1}var r=Qt.localStorage[n];return r==null?!1:String(r).toLowerCase()==="true"}return bd}var yd,ew;function DA(){if(ew)return yd;ew=1,yd=O;function t(M){var L=this;this.next=null,this.entry=null,this.finish=function(){Pn(L,M)}}var e;O.WritableState=R;var n={deprecate:n7()},r=FA(),i=Je.Buffer,a=(typeof Qt<"u"?Qt:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function o(M){return i.from(M)}function s(M){return i.isBuffer(M)||M instanceof a}var u=kA(),l=RA(),f=l.getHighWaterMark,c=jo().codes,h=c.ERR_INVALID_ARG_TYPE,d=c.ERR_METHOD_NOT_IMPLEMENTED,p=c.ERR_MULTIPLE_CALLBACK,m=c.ERR_STREAM_CANNOT_PIPE,y=c.ERR_STREAM_DESTROYED,w=c.ERR_STREAM_NULL_VALUES,A=c.ERR_STREAM_WRITE_AFTER_END,C=c.ERR_UNKNOWN_ENCODING,E=u.errorOrDestroy;Go(O,r);function k(){}function R(M,L,j){e=e||Fo(),M=M||{},typeof j!="boolean"&&(j=L instanceof e),this.objectMode=!!M.objectMode,j&&(this.objectMode=this.objectMode||!!M.writableObjectMode),this.highWaterMark=f(this,M,"writableHighWaterMark",j),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var H=M.decodeStrings===!1;this.decodeStrings=!H,this.defaultEncoding=M.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(Y){be(L,Y)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=M.emitClose!==!1,this.autoDestroy=!!M.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new t(this)}R.prototype.getBuffer=function(){for(var L=this.bufferedRequest,j=[];L;)j.push(L),L=L.next;return j},function(){try{Object.defineProperty(R.prototype,"buffer",{get:n.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch{}}();var I;typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(I=Function.prototype[Symbol.hasInstance],Object.defineProperty(O,Symbol.hasInstance,{value:function(L){return I.call(this,L)?!0:this!==O?!1:L&&L._writableState instanceof R}})):I=function(L){return L instanceof this};function O(M){e=e||Fo();var L=this instanceof e;if(!L&&!I.call(O,this))return new O(M);this._writableState=new R(M,this,L),this.writable=!0,M&&(typeof M.write=="function"&&(this._write=M.write),typeof M.writev=="function"&&(this._writev=M.writev),typeof M.destroy=="function"&&(this._destroy=M.destroy),typeof M.final=="function"&&(this._final=M.final)),r.call(this)}O.prototype.pipe=function(){E(this,new m)};function T(M,L){var j=new A;E(M,j),process.nextTick(L,j)}function B(M,L,j,H){var Y;return j===null?Y=new w:typeof j!="string"&&!L.objectMode&&(Y=new h("chunk",["string","Buffer"],j)),Y?(E(M,Y),process.nextTick(H,Y),!1):!0}O.prototype.write=function(M,L,j){var H=this._writableState,Y=!1,S=!H.objectMode&&s(M);return S&&!i.isBuffer(M)&&(M=o(M)),typeof L=="function"&&(j=L,L=null),S?L="buffer":L||(L=H.defaultEncoding),typeof j!="function"&&(j=k),H.ending?T(this,j):(S||B(this,H,M,j))&&(H.pendingcb++,Y=J(this,H,S,M,L,j)),Y},O.prototype.cork=function(){this._writableState.corked++},O.prototype.uncork=function(){var M=this._writableState;M.corked&&(M.corked--,!M.writing&&!M.corked&&!M.bufferProcessing&&M.bufferedRequest&&Ze(this,M))},O.prototype.setDefaultEncoding=function(L){if(typeof L=="string"&&(L=L.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((L+"").toLowerCase())>-1))throw new C(L);return this._writableState.defaultEncoding=L,this},Object.defineProperty(O.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});function N(M,L,j){return!M.objectMode&&M.decodeStrings!==!1&&typeof L=="string"&&(L=i.from(L,j)),L}Object.defineProperty(O.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function J(M,L,j,H,Y,S){if(!j){var _=N(L,H,Y);H!==_&&(j=!0,Y="buffer",H=_)}var q=L.objectMode?1:H.length;L.length+=q;var G=L.length<L.highWaterMark;if(G||(L.needDrain=!0),L.writing||L.corked){var ue=L.lastBufferedRequest;L.lastBufferedRequest={chunk:H,encoding:Y,isBuf:j,callback:S,next:null},ue?ue.next=L.lastBufferedRequest:L.bufferedRequest=L.lastBufferedRequest,L.bufferedRequestCount+=1}else ee(M,L,!1,q,H,Y,S);return G}function ee(M,L,j,H,Y,S,_){L.writelen=H,L.writecb=_,L.writing=!0,L.sync=!0,L.destroyed?L.onwrite(new y("write")):j?M._writev(Y,L.onwrite):M._write(Y,S,L.onwrite),L.sync=!1}function Q(M,L,j,H,Y){--L.pendingcb,j?(process.nextTick(Y,H),process.nextTick(kt,M,L),M._writableState.errorEmitted=!0,E(M,H)):(Y(H),M._writableState.errorEmitted=!0,E(M,H),kt(M,L))}function he(M){M.writing=!1,M.writecb=null,M.length-=M.writelen,M.writelen=0}function be(M,L){var j=M._writableState,H=j.sync,Y=j.writecb;if(typeof Y!="function")throw new p;if(he(j),L)Q(M,j,H,L,Y);else{var S=Mn(j)||M.destroyed;!S&&!j.corked&&!j.bufferProcessing&&j.bufferedRequest&&Ze(M,j),H?process.nextTick(Se,M,j,S,Y):Se(M,j,S,Y)}}function Se(M,L,j,H){j||Ke(M,L),L.pendingcb--,H(),kt(M,L)}function Ke(M,L){L.length===0&&L.needDrain&&(L.needDrain=!1,M.emit("drain"))}function Ze(M,L){L.bufferProcessing=!0;var j=L.bufferedRequest;if(M._writev&&j&&j.next){var H=L.bufferedRequestCount,Y=new Array(H),S=L.corkedRequestsFree;S.entry=j;for(var _=0,q=!0;j;)Y[_]=j,j.isBuf||(q=!1),j=j.next,_+=1;Y.allBuffers=q,ee(M,L,!0,L.length,Y,"",S.finish),L.pendingcb++,L.lastBufferedRequest=null,S.next?(L.corkedRequestsFree=S.next,S.next=null):L.corkedRequestsFree=new t(L),L.bufferedRequestCount=0}else{for(;j;){var G=j.chunk,ue=j.encoding,ne=j.callback,fe=L.objectMode?1:G.length;if(ee(M,L,!1,fe,G,ue,ne),j=j.next,L.bufferedRequestCount--,L.writing)break}j===null&&(L.lastBufferedRequest=null)}L.bufferedRequest=j,L.bufferProcessing=!1}O.prototype._write=function(M,L,j){j(new d("_write()"))},O.prototype._writev=null,O.prototype.end=function(M,L,j){var H=this._writableState;return typeof M=="function"?(j=M,M=null,L=null):typeof L=="function"&&(j=L,L=null),M!=null&&this.write(M,L),H.corked&&(H.corked=1,this.uncork()),H.ending||xn(this,H,j),this},Object.defineProperty(O.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function Mn(M){return M.ending&&M.length===0&&M.bufferedRequest===null&&!M.finished&&!M.writing}function ke(M,L){M._final(function(j){L.pendingcb--,j&&E(M,j),L.prefinished=!0,M.emit("prefinish"),kt(M,L)})}function Pe(M,L){!L.prefinished&&!L.finalCalled&&(typeof M._final=="function"&&!L.destroyed?(L.pendingcb++,L.finalCalled=!0,process.nextTick(ke,M,L)):(L.prefinished=!0,M.emit("prefinish")))}function kt(M,L){var j=Mn(L);if(j&&(Pe(M,L),L.pendingcb===0&&(L.finished=!0,M.emit("finish"),L.autoDestroy))){var H=M._readableState;(!H||H.autoDestroy&&H.endEmitted)&&M.destroy()}return j}function xn(M,L,j){L.ending=!0,kt(M,L),j&&(L.finished?process.nextTick(j):M.once("finish",j)),L.ended=!0,M.writable=!1}function Pn(M,L,j){var H=M.entry;for(M.entry=null;H;){var Y=H.callback;L.pendingcb--,Y(j),H=H.next}L.corkedRequestsFree.next=M}return Object.defineProperty(O.prototype,"destroyed",{enumerable:!1,get:function(){return this._writableState===void 0?!1:this._writableState.destroyed},set:function(L){this._writableState&&(this._writableState.destroyed=L)}}),O.prototype.destroy=u.destroy,O.prototype._undestroy=u.undestroy,O.prototype._destroy=function(M,L){L(M)},yd}var wd,tw;function Fo(){if(tw)return wd;tw=1;var t=Object.keys||function(l){var f=[];for(var c in l)f.push(c);return f};wd=o;var e=BA(),n=DA();Go(o,e);for(var r=t(n.prototype),i=0;i<r.length;i++){var a=r[i];o.prototype[a]||(o.prototype[a]=n.prototype[a])}function o(l){if(!(this instanceof o))return new o(l);e.call(this,l),n.call(this,l),this.allowHalfOpen=!0,l&&(l.readable===!1&&(this.readable=!1),l.writable===!1&&(this.writable=!1),l.allowHalfOpen===!1&&(this.allowHalfOpen=!1,this.once("end",s)))}Object.defineProperty(o.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(o.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(o.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function s(){this._writableState.ended||process.nextTick(u,this)}function u(l){l.end()}return Object.defineProperty(o.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0||this._writableState===void 0?!1:this._readableState.destroyed&&this._writableState.destroyed},set:function(f){this._readableState===void 0||this._writableState===void 0||(this._readableState.destroyed=f,this._writableState.destroyed=f)}}),wd}var W0={},Z0={exports:{}};/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */(function(t,e){var n=Je,r=n.Buffer;function i(o,s){for(var u in o)s[u]=o[u]}r.from&&r.alloc&&r.allocUnsafe&&r.allocUnsafeSlow?t.exports=n:(i(n,e),e.Buffer=a);function a(o,s,u){return r(o,s,u)}a.prototype=Object.create(r.prototype),i(r,a),a.from=function(o,s,u){if(typeof o=="number")throw new TypeError("Argument must not be a number");return r(o,s,u)},a.alloc=function(o,s,u){if(typeof o!="number")throw new TypeError("Argument must be a number");var l=r(o);return s!==void 0?typeof u=="string"?l.fill(s,u):l.fill(s):l.fill(0),l},a.allocUnsafe=function(o){if(typeof o!="number")throw new TypeError("Argument must be a number");return r(o)},a.allocUnsafeSlow=function(o){if(typeof o!="number")throw new TypeError("Argument must be a number");return n.SlowBuffer(o)}})(Z0,Z0.exports);var r7=Z0.exports,Pg=r7.Buffer,nw=Pg.isEncoding||function(t){switch(t=""+t,t&&t.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 i7(t){if(!t)return"utf8";for(var e;;)switch(t){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return t;default:if(e)return;t=(""+t).toLowerCase(),e=!0}}function a7(t){var e=i7(t);if(typeof e!="string"&&(Pg.isEncoding===nw||!nw(t)))throw new Error("Unknown encoding: "+t);return e||t}var o7=W0.StringDecoder=iu;function iu(t){this.encoding=a7(t);var e;switch(this.encoding){case"utf16le":this.text=h7,this.end=d7,e=4;break;case"utf8":this.fillLast=u7,e=4;break;case"base64":this.text=p7,this.end=g7,e=3;break;default:this.write=m7,this.end=b7;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=Pg.allocUnsafe(e)}iu.prototype.write=function(t){if(t.length===0)return"";var e,n;if(this.lastNeed){if(e=this.fillLast(t),e===void 0)return"";n=this.lastNeed,this.lastNeed=0}else n=0;return n<t.length?e?e+this.text(t,n):this.text(t,n):e||""};iu.prototype.end=c7;iu.prototype.text=f7;iu.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length};function xd(t){return t<=127?0:t>>5===6?2:t>>4===14?3:t>>3===30?4:t>>6===2?-1:-2}function s7(t,e,n){var r=e.length-1;if(r<n)return 0;var i=xd(e[r]);return i>=0?(i>0&&(t.lastNeed=i-1),i):--r<n||i===-2?0:(i=xd(e[r]),i>=0?(i>0&&(t.lastNeed=i-2),i):--r<n||i===-2?0:(i=xd(e[r]),i>=0?(i>0&&(i===2?i=0:t.lastNeed=i-3),i):0))}function l7(t,e,n){if((e[0]&192)!==128)return t.lastNeed=0,"�";if(t.lastNeed>1&&e.length>1){if((e[1]&192)!==128)return t.lastNeed=1,"�";if(t.lastNeed>2&&e.length>2&&(e[2]&192)!==128)return t.lastNeed=2,"�"}}function u7(t){var e=this.lastTotal-this.lastNeed,n=l7(this,t);if(n!==void 0)return n;if(this.lastNeed<=t.length)return t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,e,0,t.length),this.lastNeed-=t.length}function f7(t,e){var n=s7(this,t,e);if(!this.lastNeed)return t.toString("utf8",e);this.lastTotal=n;var r=t.length-(n-this.lastNeed);return t.copy(this.lastChar,0,r),t.toString("utf8",e,r)}function c7(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+"�":e}function h7(t,e){if((t.length-e)%2===0){var n=t.toString("utf16le",e);if(n){var r=n.charCodeAt(n.length-1);if(r>=55296&&r<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],n.slice(0,-1)}return n}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString("utf16le",e,t.length-1)}function d7(t){var e=t&&t.length?this.write(t):"";if(this.lastNeed){var n=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,n)}return e}function p7(t,e){var n=(t.length-e)%3;return n===0?t.toString("base64",e):(this.lastNeed=3-n,this.lastTotal=3,n===1?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString("base64",e,t.length-n))}function g7(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function m7(t){return t.toString(this.encoding)}function b7(t){return t&&t.length?this.write(t):""}var _d,rw;function zg(){if(rw)return _d;rw=1;var t=jo().codes.ERR_STREAM_PREMATURE_CLOSE;function e(a){var o=!1;return function(){if(!o){o=!0;for(var s=arguments.length,u=new Array(s),l=0;l<s;l++)u[l]=arguments[l];a.apply(this,u)}}}function n(){}function r(a){return a.setHeader&&typeof a.abort=="function"}function i(a,o,s){if(typeof o=="function")return i(a,null,o);o||(o={}),s=e(s||n);var u=o.readable||o.readable!==!1&&a.readable,l=o.writable||o.writable!==!1&&a.writable,f=function(){a.writable||h()},c=a._writableState&&a._writableState.finished,h=function(){l=!1,c=!0,u||s.call(a)},d=a._readableState&&a._readableState.endEmitted,p=function(){u=!1,d=!0,l||s.call(a)},m=function(C){s.call(a,C)},y=function(){var C;if(u&&!d)return(!a._readableState||!a._readableState.ended)&&(C=new t),s.call(a,C);if(l&&!c)return(!a._writableState||!a._writableState.ended)&&(C=new t),s.call(a,C)},w=function(){a.req.on("finish",h)};return r(a)?(a.on("complete",h),a.on("abort",y),a.req?w():a.on("request",w)):l&&!a._writableState&&(a.on("end",f),a.on("close",f)),a.on("end",p),a.on("finish",h),o.error!==!1&&a.on("error",m),a.on("close",y),function(){a.removeListener("complete",h),a.removeListener("abort",y),a.removeListener("request",w),a.req&&a.req.removeListener("finish",h),a.removeListener("end",f),a.removeListener("close",f),a.removeListener("finish",h),a.removeListener("end",p),a.removeListener("error",m),a.removeListener("close",y)}}return _d=i,_d}var vd,iw;function y7(){if(iw)return vd;iw=1;var t;function e(C,E,k){return E=n(E),E in C?Object.defineProperty(C,E,{value:k,enumerable:!0,configurable:!0,writable:!0}):C[E]=k,C}function n(C){var E=r(C,"string");return typeof E=="symbol"?E:String(E)}function r(C,E){if(typeof C!="object"||C===null)return C;var k=C[Symbol.toPrimitive];if(k!==void 0){var R=k.call(C,E||"default");if(typeof R!="object")return R;throw new TypeError("@@toPrimitive must return a primitive value.")}return(E==="string"?String:Number)(C)}var i=zg(),a=Symbol("lastResolve"),o=Symbol("lastReject"),s=Symbol("error"),u=Symbol("ended"),l=Symbol("lastPromise"),f=Symbol("handlePromise"),c=Symbol("stream");function h(C,E){return{value:C,done:E}}function d(C){var E=C[a];if(E!==null){var k=C[c].read();k!==null&&(C[l]=null,C[a]=null,C[o]=null,E(h(k,!1)))}}function p(C){process.nextTick(d,C)}function m(C,E){return function(k,R){C.then(function(){if(E[u]){k(h(void 0,!0));return}E[f](k,R)},R)}}var y=Object.getPrototypeOf(function(){}),w=Object.setPrototypeOf((t={get stream(){return this[c]},next:function(){var E=this,k=this[s];if(k!==null)return Promise.reject(k);if(this[u])return Promise.resolve(h(void 0,!0));if(this[c].destroyed)return new Promise(function(T,B){process.nextTick(function(){E[s]?B(E[s]):T(h(void 0,!0))})});var R=this[l],I;if(R)I=new Promise(m(R,this));else{var O=this[c].read();if(O!==null)return Promise.resolve(h(O,!1));I=new Promise(this[f])}return this[l]=I,I}},e(t,Symbol.asyncIterator,function(){return this}),e(t,"return",function(){var E=this;return new Promise(function(k,R){E[c].destroy(null,function(I){if(I){R(I);return}k(h(void 0,!0))})})}),t),y),A=function(E){var k,R=Object.create(w,(k={},e(k,c,{value:E,writable:!0}),e(k,a,{value:null,writable:!0}),e(k,o,{value:null,writable:!0}),e(k,s,{value:null,writable:!0}),e(k,u,{value:E._readableState.endEmitted,writable:!0}),e(k,f,{value:function(O,T){var B=R[c].read();B?(R[l]=null,R[a]=null,R[o]=null,O(h(B,!1))):(R[a]=O,R[o]=T)},writable:!0}),k));return R[l]=null,i(E,function(I){if(I&&I.code!=="ERR_STREAM_PREMATURE_CLOSE"){var O=R[o];O!==null&&(R[l]=null,R[a]=null,R[o]=null,O(I)),R[s]=I;return}var T=R[a];T!==null&&(R[l]=null,R[a]=null,R[o]=null,T(h(void 0,!0))),R[u]=!0}),E.on("readable",p.bind(null,R)),R};return vd=A,vd}var Ed,aw;function w7(){return aw||(aw=1,Ed=function(){throw new Error("Readable.from is not available in the browser")}),Ed}var Ad,ow;function BA(){if(ow)return Ad;ow=1,Ad=T;var t;T.ReadableState=O,Mg.EventEmitter;var e=function(_,q){return _.listeners(q).length},n=FA(),r=Je.Buffer,i=(typeof Qt<"u"?Qt:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function a(S){return r.from(S)}function o(S){return r.isBuffer(S)||S instanceof i}var s=IA,u;s&&s.debuglog?u=s.debuglog("stream"):u=function(){};var l=t7(),f=kA(),c=RA(),h=c.getHighWaterMark,d=jo().codes,p=d.ERR_INVALID_ARG_TYPE,m=d.ERR_STREAM_PUSH_AFTER_EOF,y=d.ERR_METHOD_NOT_IMPLEMENTED,w=d.ERR_STREAM_UNSHIFT_AFTER_END_EVENT,A,C,E;Go(T,n);var k=f.errorOrDestroy,R=["error","close","destroy","pause","resume"];function I(S,_,q){if(typeof S.prependListener=="function")return S.prependListener(_,q);!S._events||!S._events[_]?S.on(_,q):Array.isArray(S._events[_])?S._events[_].unshift(q):S._events[_]=[q,S._events[_]]}function O(S,_,q){t=t||Fo(),S=S||{},typeof q!="boolean"&&(q=_ instanceof t),this.objectMode=!!S.objectMode,q&&(this.objectMode=this.objectMode||!!S.readableObjectMode),this.highWaterMark=h(this,S,"readableHighWaterMark",q),this.buffer=new l,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.paused=!0,this.emitClose=S.emitClose!==!1,this.autoDestroy=!!S.autoDestroy,this.destroyed=!1,this.defaultEncoding=S.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,S.encoding&&(A||(A=W0.StringDecoder),this.decoder=new A(S.encoding),this.encoding=S.encoding)}function T(S){if(t=t||Fo(),!(this instanceof T))return new T(S);var _=this instanceof t;this._readableState=new O(S,this,_),this.readable=!0,S&&(typeof S.read=="function"&&(this._read=S.read),typeof S.destroy=="function"&&(this._destroy=S.destroy)),n.call(this)}Object.defineProperty(T.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0?!1:this._readableState.destroyed},set:function(_){this._readableState&&(this._readableState.destroyed=_)}}),T.prototype.destroy=f.destroy,T.prototype._undestroy=f.undestroy,T.prototype._destroy=function(S,_){_(S)},T.prototype.push=function(S,_){var q=this._readableState,G;return q.objectMode?G=!0:typeof S=="string"&&(_=_||q.defaultEncoding,_!==q.encoding&&(S=r.from(S,_),_=""),G=!0),B(this,S,_,!1,G)},T.prototype.unshift=function(S){return B(this,S,null,!0,!1)};function B(S,_,q,G,ue){u("readableAddChunk",_);var ne=S._readableState;if(_===null)ne.reading=!1,be(S,ne);else{var fe;if(ue||(fe=J(ne,_)),fe)k(S,fe);else if(ne.objectMode||_&&_.length>0)if(typeof _!="string"&&!ne.objectMode&&Object.getPrototypeOf(_)!==r.prototype&&(_=a(_)),G)ne.endEmitted?k(S,new w):N(S,ne,_,!0);else if(ne.ended)k(S,new m);else{if(ne.destroyed)return!1;ne.reading=!1,ne.decoder&&!q?(_=ne.decoder.write(_),ne.objectMode||_.length!==0?N(S,ne,_,!1):Ze(S,ne)):N(S,ne,_,!1)}else G||(ne.reading=!1,Ze(S,ne))}return!ne.ended&&(ne.length<ne.highWaterMark||ne.length===0)}function N(S,_,q,G){_.flowing&&_.length===0&&!_.sync?(_.awaitDrain=0,S.emit("data",q)):(_.length+=_.objectMode?1:q.length,G?_.buffer.unshift(q):_.buffer.push(q),_.needReadable&&Se(S)),Ze(S,_)}function J(S,_){var q;return!o(_)&&typeof _!="string"&&_!==void 0&&!S.objectMode&&(q=new p("chunk",["string","Buffer","Uint8Array"],_)),q}T.prototype.isPaused=function(){return this._readableState.flowing===!1},T.prototype.setEncoding=function(S){A||(A=W0.StringDecoder);var _=new A(S);this._readableState.decoder=_,this._readableState.encoding=this._readableState.decoder.encoding;for(var q=this._readableState.buffer.head,G="";q!==null;)G+=_.write(q.data),q=q.next;return this._readableState.buffer.clear(),G!==""&&this._readableState.buffer.push(G),this._readableState.length=G.length,this};var ee=1073741824;function Q(S){return S>=ee?S=ee:(S--,S|=S>>>1,S|=S>>>2,S|=S>>>4,S|=S>>>8,S|=S>>>16,S++),S}function he(S,_){return S<=0||_.length===0&&_.ended?0:_.objectMode?1:S!==S?_.flowing&&_.length?_.buffer.head.data.length:_.length:(S>_.highWaterMark&&(_.highWaterMark=Q(S)),S<=_.length?S:_.ended?_.length:(_.needReadable=!0,0))}T.prototype.read=function(S){u("read",S),S=parseInt(S,10);var _=this._readableState,q=S;if(S!==0&&(_.emittedReadable=!1),S===0&&_.needReadable&&((_.highWaterMark!==0?_.length>=_.highWaterMark:_.length>0)||_.ended))return u("read: emitReadable",_.length,_.ended),_.length===0&&_.ended?j(this):Se(this),null;if(S=he(S,_),S===0&&_.ended)return _.length===0&&j(this),null;var G=_.needReadable;u("need readable",G),(_.length===0||_.length-S<_.highWaterMark)&&(G=!0,u("length less than watermark",G)),_.ended||_.reading?(G=!1,u("reading or ended",G)):G&&(u("do read"),_.reading=!0,_.sync=!0,_.length===0&&(_.needReadable=!0),this._read(_.highWaterMark),_.sync=!1,_.reading||(S=he(q,_)));var ue;return S>0?ue=L(S,_):ue=null,ue===null?(_.needReadable=_.length<=_.highWaterMark,S=0):(_.length-=S,_.awaitDrain=0),_.length===0&&(_.ended||(_.needReadable=!0),q!==S&&_.ended&&j(this)),ue!==null&&this.emit("data",ue),ue};function be(S,_){if(u("onEofChunk"),!_.ended){if(_.decoder){var q=_.decoder.end();q&&q.length&&(_.buffer.push(q),_.length+=_.objectMode?1:q.length)}_.ended=!0,_.sync?Se(S):(_.needReadable=!1,_.emittedReadable||(_.emittedReadable=!0,Ke(S)))}}function Se(S){var _=S._readableState;u("emitReadable",_.needReadable,_.emittedReadable),_.needReadable=!1,_.emittedReadable||(u("emitReadable",_.flowing),_.emittedReadable=!0,process.nextTick(Ke,S))}function Ke(S){var _=S._readableState;u("emitReadable_",_.destroyed,_.length,_.ended),!_.destroyed&&(_.length||_.ended)&&(S.emit("readable"),_.emittedReadable=!1),_.needReadable=!_.flowing&&!_.ended&&_.length<=_.highWaterMark,M(S)}function Ze(S,_){_.readingMore||(_.readingMore=!0,process.nextTick(Mn,S,_))}function Mn(S,_){for(;!_.reading&&!_.ended&&(_.length<_.highWaterMark||_.flowing&&_.length===0);){var q=_.length;if(u("maybeReadMore read 0"),S.read(0),q===_.length)break}_.readingMore=!1}T.prototype._read=function(S){k(this,new y("_read()"))},T.prototype.pipe=function(S,_){var q=this,G=this._readableState;switch(G.pipesCount){case 0:G.pipes=S;break;case 1:G.pipes=[G.pipes,S];break;default:G.pipes.push(S);break}G.pipesCount+=1,u("pipe count=%d opts=%j",G.pipesCount,_);var ue=(!_||_.end!==!1)&&S!==process.stdout&&S!==process.stderr,ne=ue?Rt:zn;G.endEmitted?process.nextTick(ne):q.once("end",ne),S.on("unpipe",fe);function fe(x,g){u("onunpipe"),x===q&&g&&g.hasUnpiped===!1&&(g.hasUnpiped=!0,Pr())}function Rt(){u("onend"),S.end()}var Lr=ke(q);S.on("drain",Lr);var Mr=!1;function Pr(){u("cleanup"),S.removeListener("close",zr),S.removeListener("finish",Dt),S.removeListener("drain",Lr),S.removeListener("error",hr),S.removeListener("unpipe",fe),q.removeListener("end",Rt),q.removeListener("end",zn),q.removeListener("data",mt),Mr=!0,G.awaitDrain&&(!S._writableState||S._writableState.needDrain)&&Lr()}q.on("data",mt);function mt(x){u("ondata");var g=S.write(x);u("dest.write",g),g===!1&&((G.pipesCount===1&&G.pipes===S||G.pipesCount>1&&Y(G.pipes,S)!==-1)&&!Mr&&(u("false write response, pause",G.awaitDrain),G.awaitDrain++),q.pause())}function hr(x){u("onerror",x),zn(),S.removeListener("error",hr),e(S,"error")===0&&k(S,x)}I(S,"error",hr);function zr(){S.removeListener("finish",Dt),zn()}S.once("close",zr);function Dt(){u("onfinish"),S.removeListener("close",zr),zn()}S.once("finish",Dt);function zn(){u("unpipe"),q.unpipe(S)}return S.emit("pipe",q),G.flowing||(u("pipe resume"),q.resume()),S};function ke(S){return function(){var q=S._readableState;u("pipeOnDrain",q.awaitDrain),q.awaitDrain&&q.awaitDrain--,q.awaitDrain===0&&e(S,"data")&&(q.flowing=!0,M(S))}}T.prototype.unpipe=function(S){var _=this._readableState,q={hasUnpiped:!1};if(_.pipesCount===0)return this;if(_.pipesCount===1)return S&&S!==_.pipes?this:(S||(S=_.pipes),_.pipes=null,_.pipesCount=0,_.flowing=!1,S&&S.emit("unpipe",this,q),this);if(!S){var G=_.pipes,ue=_.pipesCount;_.pipes=null,_.pipesCount=0,_.flowing=!1;for(var ne=0;ne<ue;ne++)G[ne].emit("unpipe",this,{hasUnpiped:!1});return this}var fe=Y(_.pipes,S);return fe===-1?this:(_.pipes.splice(fe,1),_.pipesCount-=1,_.pipesCount===1&&(_.pipes=_.pipes[0]),S.emit("unpipe",this,q),this)},T.prototype.on=function(S,_){var q=n.prototype.on.call(this,S,_),G=this._readableState;return S==="data"?(G.readableListening=this.listenerCount("readable")>0,G.flowing!==!1&&this.resume()):S==="readable"&&!G.endEmitted&&!G.readableListening&&(G.readableListening=G.needReadable=!0,G.flowing=!1,G.emittedReadable=!1,u("on readable",G.length,G.reading),G.length?Se(this):G.reading||process.nextTick(kt,this)),q},T.prototype.addListener=T.prototype.on,T.prototype.removeListener=function(S,_){var q=n.prototype.removeListener.call(this,S,_);return S==="readable"&&process.nextTick(Pe,this),q},T.prototype.removeAllListeners=function(S){var _=n.prototype.removeAllListeners.apply(this,arguments);return(S==="readable"||S===void 0)&&process.nextTick(Pe,this),_};function Pe(S){var _=S._readableState;_.readableListening=S.listenerCount("readable")>0,_.resumeScheduled&&!_.paused?_.flowing=!0:S.listenerCount("data")>0&&S.resume()}function kt(S){u("readable nexttick read 0"),S.read(0)}T.prototype.resume=function(){var S=this._readableState;return S.flowing||(u("resume"),S.flowing=!S.readableListening,xn(this,S)),S.paused=!1,this};function xn(S,_){_.resumeScheduled||(_.resumeScheduled=!0,process.nextTick(Pn,S,_))}function Pn(S,_){u("resume",_.reading),_.reading||S.read(0),_.resumeScheduled=!1,S.emit("resume"),M(S),_.flowing&&!_.reading&&S.read(0)}T.prototype.pause=function(){return u("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(u("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this};function M(S){var _=S._readableState;for(u("flow",_.flowing);_.flowing&&S.read()!==null;);}T.prototype.wrap=function(S){var _=this,q=this._readableState,G=!1;S.on("end",function(){if(u("wrapped end"),q.decoder&&!q.ended){var fe=q.decoder.end();fe&&fe.length&&_.push(fe)}_.push(null)}),S.on("data",function(fe){if(u("wrapped data"),q.decoder&&(fe=q.decoder.write(fe)),!(q.objectMode&&fe==null)&&!(!q.objectMode&&(!fe||!fe.length))){var Rt=_.push(fe);Rt||(G=!0,S.pause())}});for(var ue in S)this[ue]===void 0&&typeof S[ue]=="function"&&(this[ue]=function(Rt){return function(){return S[Rt].apply(S,arguments)}}(ue));for(var ne=0;ne<R.length;ne++)S.on(R[ne],this.emit.bind(this,R[ne]));return this._read=function(fe){u("wrapped _read",fe),G&&(G=!1,S.resume())},this},typeof Symbol=="function"&&(T.prototype[Symbol.asyncIterator]=function(){return C===void 0&&(C=y7()),C(this)}),Object.defineProperty(T.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(T.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(T.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(_){this._readableState&&(this._readableState.flowing=_)}}),T._fromList=L,Object.defineProperty(T.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}});function L(S,_){if(_.length===0)return null;var q;return _.objectMode?q=_.buffer.shift():!S||S>=_.length?(_.decoder?q=_.buffer.join(""):_.buffer.length===1?q=_.buffer.first():q=_.buffer.concat(_.length),_.buffer.clear()):q=_.buffer.consume(S,_.decoder),q}function j(S){var _=S._readableState;u("endReadable",_.endEmitted),_.endEmitted||(_.ended=!0,process.nextTick(H,_,S))}function H(S,_){if(u("endReadableNT",S.endEmitted,S.length),!S.endEmitted&&S.length===0&&(S.endEmitted=!0,_.readable=!1,_.emit("end"),S.autoDestroy)){var q=_._writableState;(!q||q.autoDestroy&&q.finished)&&_.destroy()}}typeof Symbol=="function"&&(T.from=function(S,_){return E===void 0&&(E=w7()),E(T,S,_)});function Y(S,_){for(var q=0,G=S.length;q<G;q++)if(S[q]===_)return q;return-1}return Ad}var Sd,sw;function NA(){if(sw)return Sd;sw=1,Sd=s;var t=jo().codes,e=t.ERR_METHOD_NOT_IMPLEMENTED,n=t.ERR_MULTIPLE_CALLBACK,r=t.ERR_TRANSFORM_ALREADY_TRANSFORMING,i=t.ERR_TRANSFORM_WITH_LENGTH_0,a=Fo();Go(s,a);function o(f,c){var h=this._transformState;h.transforming=!1;var d=h.writecb;if(d===null)return this.emit("error",new n);h.writechunk=null,h.writecb=null,c!=null&&this.push(c),d(f);var p=this._readableState;p.reading=!1,(p.needReadable||p.length<p.highWaterMark)&&this._read(p.highWaterMark)}function s(f){if(!(this instanceof s))return new s(f);a.call(this,f),this._transformState={afterTransform:o.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,f&&(typeof f.transform=="function"&&(this._transform=f.transform),typeof f.flush=="function"&&(this._flush=f.flush)),this.on("prefinish",u)}function u(){var f=this;typeof this._flush=="function"&&!this._readableState.destroyed?this._flush(function(c,h){l(f,c,h)}):l(this,null,null)}s.prototype.push=function(f,c){return this._transformState.needTransform=!1,a.prototype.push.call(this,f,c)},s.prototype._transform=function(f,c,h){h(new e("_transform()"))},s.prototype._write=function(f,c,h){var d=this._transformState;if(d.writecb=h,d.writechunk=f,d.writeencoding=c,!d.transforming){var p=this._readableState;(d.needTransform||p.needReadable||p.length<p.highWaterMark)&&this._read(p.highWaterMark)}},s.prototype._read=function(f){var c=this._transformState;c.writechunk!==null&&!c.transforming?(c.transforming=!0,this._transform(c.writechunk,c.writeencoding,c.afterTransform)):c.needTransform=!0},s.prototype._destroy=function(f,c){a.prototype._destroy.call(this,f,function(h){c(h)})};function l(f,c,h){if(c)return f.emit("error",c);if(h!=null&&f.push(h),f._writableState.length)throw new i;if(f._transformState.transforming)throw new r;return f.push(null)}return Sd}var Cd,lw;function x7(){if(lw)return Cd;lw=1,Cd=e;var t=NA();Go(e,t);function e(n){if(!(this instanceof e))return new e(n);t.call(this,n)}return e.prototype._transform=function(n,r,i){i(null,n)},Cd}var Td,uw;function _7(){if(uw)return Td;uw=1;var t;function e(h){var d=!1;return function(){d||(d=!0,h.apply(void 0,arguments))}}var n=jo().codes,r=n.ERR_MISSING_ARGS,i=n.ERR_STREAM_DESTROYED;function a(h){if(h)throw h}function o(h){return h.setHeader&&typeof h.abort=="function"}function s(h,d,p,m){m=e(m);var y=!1;h.on("close",function(){y=!0}),t===void 0&&(t=zg()),t(h,{readable:d,writable:p},function(A){if(A)return m(A);y=!0,m()});var w=!1;return function(A){if(!y&&!w){if(w=!0,o(h))return h.abort();if(typeof h.destroy=="function")return h.destroy();m(A||new i("pipe"))}}}function u(h){h()}function l(h,d){return h.pipe(d)}function f(h){return!h.length||typeof h[h.length-1]!="function"?a:h.pop()}function c(){for(var h=arguments.length,d=new Array(h),p=0;p<h;p++)d[p]=arguments[p];var m=f(d);if(Array.isArray(d[0])&&(d=d[0]),d.length<2)throw new r("streams");var y,w=d.map(function(A,C){var E=C<d.length-1,k=C>0;return s(A,E,k,function(R){y||(y=R),R&&w.forEach(u),!E&&(w.forEach(u),m(y))})});return d.reduce(l)}return Td=c,Td}var $A=bn,Ug=Mg.EventEmitter,v7=Go;v7(bn,Ug);bn.Readable=BA();bn.Writable=DA();bn.Duplex=Fo();bn.Transform=NA();bn.PassThrough=x7();bn.finished=zg();bn.pipeline=_7();bn.Stream=bn;function bn(){Ug.call(this)}bn.prototype.pipe=function(t,e){var n=this;function r(f){t.writable&&t.write(f)===!1&&n.pause&&n.pause()}n.on("data",r);function i(){n.readable&&n.resume&&n.resume()}t.on("drain",i),!t._isStdio&&(!e||e.end!==!1)&&(n.on("end",o),n.on("close",s));var a=!1;function o(){a||(a=!0,t.end())}function s(){a||(a=!0,typeof t.destroy=="function"&&t.destroy())}function u(f){if(l(),Ug.listenerCount(this,"error")===0)throw f}n.on("error",u),t.on("error",u);function l(){n.removeListener("data",r),t.removeListener("drain",i),n.removeListener("end",o),n.removeListener("close",s),n.removeListener("error",u),t.removeListener("error",u),n.removeListener("end",l),n.removeListener("close",l),t.removeListener("close",l)}return n.on("end",l),n.on("close",l),t.on("close",l),t.emit("pipe",n),t};function Cs(t){return t.replace(/%([0-9A-Fa-f]{2})/g,(e,n)=>String.fromCharCode(parseInt(n,16)))}function OA(t,e){return String(e).replace(t,n=>`%${n.charCodeAt(0).toString(16).toUpperCase().padStart(2,"0")}`)}function cs(t){return OA(/[\n;\r\t=%&,\x00-\x1f\x7f-\xff]/g,t)}function wr(t){return OA(/[\n\r\t%\x00-\x1f\x7f-\xff]/g,t)}function LA(t){if(!(t&&t.length)||t===".")return{};const e={};return t.replace(/\r?\n$/,"").split(";").forEach(n=>{const r=n.split("=",2);if(!(r[1]&&r[1].length))return;r[0]=r[0].trim();let i=e[r[0].trim()];i||(i=[],e[r[0]]=i),i.push(...r[1].split(",").map(a=>a.trim()).map(Cs))}),e}function MA(t){const e=t.split(" ").map(r=>r==="."||r===""?null:r);return{seq_id:e[0]&&Cs(e[0]),source:e[1]&&Cs(e[1]),type:e[2]&&Cs(e[2]),start:e[3]===null?null:parseInt(e[3],10),end:e[4]===null?null:parseInt(e[4],10),score:e[5]===null?null:parseFloat(e[5]),strand:e[6],phase:e[7],attributes:e[8]===null?null:LA(e[8])}}function PA(t){const e=/^\s*##\s*(\S+)\s*(.*)/.exec(t);if(!e)return null;const[,n]=e;let[,,r]=e;const i={directive:n};if(r.length&&(r=r.replace(/\r?\n$/,""),i.value=r),n==="sequence-region"){const a=r.split(/\s+/,3);return{...i,seq_id:a[0],start:a[1]&&a[1].replace(/\D/g,""),end:a[2]&&a[2].replace(/\D/g,"")}}else if(n==="genome-build"){const[a,o]=r.split(/\s+/,2);return{...i,source:a,buildName:o}}return i}function zA(t){const e=[];return Object.entries(t).forEach(([n,r])=>{if(!r)return;let i;r.hasOwnProperty("toString")?i=cs(r.toString()):Array.isArray(r)?i=r.map(cs).join(","):i=cs(r),e.push(`${cs(n)}=${i}`)}),e.length?e.join(";"):"."}function E7(t,e){const n=t.attributes===null||t.attributes===void 0?".":zA(t.attributes),i=`${[t.seq_id===null?".":wr(t.seq_id),t.source===null?".":wr(t.source),t.type===null?".":wr(t.type),t.start===null?".":wr(t.start),t.end===null?".":wr(t.end),t.score===null?".":wr(t.score),t.strand===null?".":wr(t.strand),t.phase===null?".":wr(t.phase),n].join(" ")} -`;return e[i]?"":(e[i]=!0,i)}function Yu(t,e){if(Array.isArray(t))return t.map(r=>Yu(r,e)).join("");const n=[E7(t,e)];return A7(t)&&n.push(...t.child_features.map(r=>Yu(r,e)),...t.derived_features.map(r=>Yu(r,e))),n.join("")}function UA(t){return Yu(t,{})}function qA(t){let e=`##${t.directive}`;return t.value&&(e+=` ${t.value}`),e+=` -`,e}function VA(t){return`# ${t.comment} -`}function qg(t){return`>${t.id}${t.description?` ${t.description}`:""} -${t.sequence} -`}function Lf(t){function e(n){return"attributes"in n?UA(n):"directive"in n?qA(n):"sequence"in n?qg(n):"comment"in n?VA(n):`# (invalid item found during format) -`}return Array.isArray(t)?t.map(e):e(t)}function A7(t){return t.child_features!==void 0&&t.derived_features!==void 0}const S7=Object.freeze(Object.defineProperty({__proto__:null,escape:cs,escapeColumn:wr,formatAttributes:zA,formatComment:VA,formatDirective:qA,formatFeature:UA,formatItem:Lf,formatSequence:qg,parseAttributes:LA,parseDirective:PA,parseFeature:MA,unescape:Cs},Symbol.toStringTag,{value:"Module"})),fw={Parent:"child_features",Derives_from:"derived_features"};class cw{constructor(e){this.seqCallback=e,this.currentSequence=void 0}addLine(e){const n=/^>\s*(\S+)\s*(.*)/.exec(e);n?(this._flush(),this.currentSequence={id:n[1],sequence:""},n[2]&&(this.currentSequence.description=n[2].trim())):this.currentSequence&&/\S/.test(e)&&(this.currentSequence.sequence+=e.replace(/\s/g,""))}_flush(){this.currentSequence&&this.seqCallback(this.currentSequence)}finish(){this._flush()}}class HA{constructor(e){this.fastaParser=void 0,this.eof=!1,this.lineNumber=0,this._underConstructionTopLevel=[],this._underConstructionById={},this._completedReferences={},this._underConstructionOrphans={};const n=()=>{};this.featureCallback=e.featureCallback||n,this.endCallback=e.endCallback||n,this.commentCallback=e.commentCallback||n,this.errorCallback=e.errorCallback||n,this.directiveCallback=e.directiveCallback||n,this.sequenceCallback=e.sequenceCallback||n,this.disableDerivesFromReferences=e.disableDerivesFromReferences||!1,this.bufferSize=e.bufferSize===void 0?1e3:e.bufferSize}addLine(e){if(this.fastaParser){this.fastaParser.addLine(e);return}if(this.eof)return;if(this.lineNumber+=1,/^\s*[^#\s>]/.test(e)){this._bufferLine(e);return}const n=/^\s*(#+)(.*)/.exec(e);if(n){const[,r]=n;let[,,i]=n;if(r.length===3)this._emitAllUnderConstructionFeatures();else if(r.length===2){const a=PA(e);a&&(a.directive==="FASTA"?(this._emitAllUnderConstructionFeatures(),this.eof=!0,this.fastaParser=new cw(this.sequenceCallback)):this._emitItem(a))}else i=i.replace(/\s*/,""),this._emitItem({comment:i})}else if(!/^\s*$/.test(e))if(/^\s*>/.test(e))this._emitAllUnderConstructionFeatures(),this.eof=!0,this.fastaParser=new cw(this.sequenceCallback),this.fastaParser.addLine(e);else{const r=e.replace(/\r?\n?$/g,"");throw new Error(`GFF3 parse error. Cannot parse '${r}'.`)}}finish(){this._emitAllUnderConstructionFeatures(),this.fastaParser&&this.fastaParser.finish(),this.endCallback()}_emitItem(e){Array.isArray(e)?this.featureCallback(e):"directive"in e?this.directiveCallback(e):"comment"in e&&this.commentCallback(e)}_enforceBufferSizeLimit(e=0){const n=r=>{r&&Array.isArray(r)&&r[0].attributes&&r[0].attributes.ID&&r[0].attributes.ID[0]&&(r[0].attributes.ID.forEach(a=>{delete this._underConstructionById[a],delete this._completedReferences[a]}),r.forEach(a=>{a.child_features&&a.child_features.forEach(o=>n(o)),a.derived_features&&a.derived_features.forEach(o=>n(o))}))};for(;this._underConstructionTopLevel.length+e>this.bufferSize;){const r=this._underConstructionTopLevel.shift();r&&(this._emitItem(r),n(r))}}_emitAllUnderConstructionFeatures(){if(this._underConstructionTopLevel.forEach(this._emitItem.bind(this)),this._underConstructionTopLevel=[],this._underConstructionById={},this._completedReferences={},Array.from(Object.values(this._underConstructionOrphans)).length)throw new Error(`some features reference other features that do not exist in the file (or in the same '###' scope). ${Object.keys(this._underConstructionOrphans)}`)}_bufferLine(e){var n,r,i;const o={...MA(e),child_features:[],derived_features:[]},s=((n=o.attributes)===null||n===void 0?void 0:n.ID)||[],u=((r=o.attributes)===null||r===void 0?void 0:r.Parent)||[],l=this.disableDerivesFromReferences?[]:((i=o.attributes)===null||i===void 0?void 0:i.Derives_from)||[];if(!s.length&&!u.length&&!l.length){this._emitItem([o]);return}let f;s.forEach(c=>{const h=this._underConstructionById[c];h?(h[h.length-1].type!==o.type&&this._parseError(`multi-line feature "${c}" has inconsistent types: "${o.type}", "${h[h.length-1].type}"`),h.push(o),f=h):(f=[o],this._enforceBufferSizeLimit(1),!u.length&&!l.length&&this._underConstructionTopLevel.push(f),this._underConstructionById[c]=f,this._resolveReferencesTo(f,c))}),this._resolveReferencesFrom(f||[o],{Parent:u,Derives_from:l},s)}_resolveReferencesTo(e,n){const r=this._underConstructionOrphans[n];r&&(e.forEach(i=>{i.child_features.push(...r.Parent)}),e.forEach(i=>{i.derived_features.push(...r.Derives_from)}),delete this._underConstructionOrphans[n])}_parseError(e){this.eof=!0,this.errorCallback(`${this.lineNumber}: ${e}`)}_resolveReferencesFrom(e,n,r){function i(a,o,s){let u=a[o];u||(u={},a[o]=u);const l=u[s]||!1;return u[s]=!0,l}n.Parent.forEach(a=>{const o=this._underConstructionById[a];if(o){const s=fw.Parent;r.filter(u=>i(this._completedReferences,u,`Parent,${a}`)).length||o.forEach(u=>{u[s].push(e)})}else{let s=this._underConstructionOrphans[a];s||(s={Parent:[],Derives_from:[]},this._underConstructionOrphans[a]=s),s.Parent.push(e)}}),n.Derives_from.forEach(a=>{const o=this._underConstructionById[a];if(o){const s=fw.Derives_from;r.filter(u=>i(this._completedReferences,u,`Derives_from,${a}`)).length||o.forEach(u=>{u[s].push(e)})}else{let s=this._underConstructionOrphans[a];s||(s={Parent:[],Derives_from:[]},this._underConstructionOrphans[a]=s),s.Derives_from.push(e)}})}}function Y0(t){process&&process.nextTick?process.nextTick(t):t()}function GA(t){const e={encoding:"utf8",parseFeatures:!0,parseDirectives:!1,parseSequences:!0,parseComments:!1,bufferSize:1e3,disableDerivesFromReferences:!1,...t};return t.parseAll&&(e.parseFeatures=!0,e.parseDirectives=!0,e.parseComments=!0,e.parseSequences=!0),e}class C7 extends $A.Transform{constructor(e={}){super({objectMode:!0}),this.textBuffer="";const n=GA(e);this.encoding=e.encoding||"utf8",this.decoder=new o7;const r=this.push.bind(this);this.parser=new HA({featureCallback:n.parseFeatures?r:void 0,directiveCallback:n.parseDirectives?r:void 0,commentCallback:n.parseComments?r:void 0,sequenceCallback:n.parseSequences?r:void 0,errorCallback:i=>this.emit("error",i),bufferSize:n.bufferSize,disableDerivesFromReferences:n.disableDerivesFromReferences})}_addLine(e){e&&this.parser.addLine(e)}_nextText(e){const n=(this.textBuffer+e).split(/\r?\n/);this.textBuffer=n.pop()||"",n.forEach(r=>this._addLine(r))}_transform(e,n,r){this._nextText(this.decoder.write(e)),Y0(r)}_flush(e){this.decoder.end&&this._nextText(this.decoder.end()),this.textBuffer!=null&&this._addLine(this.textBuffer),this.parser.finish(),Y0(e)}}function T7(t={}){return new C7(t)}function F7(t,e={}){if(!t)return[];const n=GA(e),r=[],i=r.push.bind(r),a=new HA({featureCallback:n.parseFeatures?i:void 0,directiveCallback:n.parseDirectives?i:void 0,commentCallback:n.parseComments?i:void 0,sequenceCallback:n.parseSequences?i:void 0,disableDerivesFromReferences:n.disableDerivesFromReferences||!1,bufferSize:1/0,errorCallback:o=>{throw o}});return t.split(/\r?\n/).forEach(a.addLine.bind(a)),a.finish(),r}function I7(t){const e=[],n=[];t.forEach(i=>{"sequence"in i?n.push(i):e.push(i)});let r=e.map(Lf).join("");return n.length&&(r+=`##FASTA -`,r+=n.map(qg).join("")),r}class jA extends $A.Transform{constructor(e={}){super(Object.assign(e,{objectMode:!0})),this.linesSinceLastSyncMark=0,this.haveWeEmittedData=!1,this.fastaMode=!1,this.minLinesBetweenSyncMarks=e.minSyncLines||100,this.insertVersionDirective=e.insertVersionDirective||!1}_transform(e,n,r){let i;if(!this.haveWeEmittedData&&this.insertVersionDirective){const a=Array.isArray(e)?e[0]:e;"directive"in a&&a.directive!=="gff-version"&&this.push(`##gff-version 3 -`)}if("sequence"in e&&!this.fastaMode&&(this.push(`##FASTA -`),this.fastaMode=!0),Array.isArray(e)?i=e.map(Lf).join(""):i=Lf(e),this.push(i),this.linesSinceLastSyncMark>=this.minLinesBetweenSyncMarks)this.push(`### -`),this.linesSinceLastSyncMark=0;else{let a=0;for(let o=0;o<i.length;o+=1)i[o]===` -`&&(a+=1);this.linesSinceLastSyncMark+=a}this.haveWeEmittedData=!0,Y0(r)}}function k7(t={}){return new jA(t)}function R7(t,e,n={}){const r={insertVersionDirective:!0,...n};return new Promise((i,a)=>{t.pipe(new jA(r)).on("end",()=>i(null)).on("error",a).pipe(e)})}const D7={parseStream:T7,parseStringSync:F7,formatSync:I7,formatStream:k7,formatFile:R7,util:S7};class B7{constructor(e={}){if(!(e.maxSize&&e.maxSize>0))throw new TypeError("`maxSize` must be a number greater than 0");this.maxSize=e.maxSize,this.cache=new Map,this.oldCache=new Map,this._size=0}_set(e,n){this.cache.set(e,n),this._size++,this._size>=this.maxSize&&(this._size=0,this.oldCache=this.cache,this.cache=new Map)}get(e){if(this.cache.has(e))return this.cache.get(e);if(this.oldCache.has(e)){const n=this.oldCache.get(e);return this.oldCache.delete(e),this._set(e,n),n}}set(e,n){return this.cache.has(e)?this.cache.set(e,n):this._set(e,n),this}has(e){return this.cache.has(e)||this.oldCache.has(e)}peek(e){if(this.cache.has(e))return this.cache.get(e);if(this.oldCache.has(e))return this.oldCache.get(e)}delete(e){const n=this.cache.delete(e);return n&&this._size--,this.oldCache.delete(e)||n}clear(){this.cache.clear(),this.oldCache.clear(),this._size=0}*keys(){for(const[e]of this)yield e}*values(){for(const[,e]of this)yield e}*[Symbol.iterator](){for(const e of this.cache)yield e;for(const e of this.oldCache){const[n]=e;this.cache.has(n)||(yield e)}}get size(){let e=0;for(const n of this.oldCache.keys())this.cache.has(n)||e++;return this._size+e}}var N7=B7;const $7=xa(N7);function WA(t){if(t.greaterThan(Number.MAX_SAFE_INTEGER)||t.lessThan(Number.MIN_SAFE_INTEGER))throw new Error("integer overflow");return t.toNumber()}class O7 extends Error{}function Di(t){if(t&&t.aborted){if(typeof DOMException<"u")throw new DOMException("aborted","AbortError");{const e=new O7("aborted");throw e.code="ERR_ABORTED",e}}}function L7(t,e){return e.minv.blockPosition-t.maxv.blockPosition<65e3&&e.maxv.blockPosition-t.minv.blockPosition<5e6}function ZA(t,e){const n=[];let r=null;return t.length===0?t:(t.sort(function(i,a){const o=i.minv.blockPosition-a.minv.blockPosition;return o!==0?o:i.minv.dataPosition-a.minv.dataPosition}),t.forEach(i=>{(!e||i.maxv.compareTo(e)>0)&&(r===null?(n.push(i),r=i):L7(r,i)?i.maxv.compareTo(r.maxv)>0&&(r.maxv=i.maxv):(n.push(i),r=i))}),n)}class Vg{constructor(e,n){this.blockPosition=e,this.dataPosition=n}toString(){return`${this.blockPosition}:${this.dataPosition}`}compareTo(e){return this.blockPosition-e.blockPosition||this.dataPosition-e.dataPosition}static min(...e){let n,r=0;for(;!n;r+=1)n=e[r];for(;r<e.length;r+=1)n.compareTo(e[r])>0&&(n=e[r]);return n}}function Ja(t,e=0,n=!1){if(n)throw new Error("big-endian virtual file offsets not implemented");return new Vg(t[e+7]*1099511627776+t[e+6]*4294967296+t[e+5]*16777216+t[e+4]*65536+t[e+3]*256+t[e+2],t[e+1]<<8|t[e])}class Mf{constructor(e,n,r,i=void 0){this.minv=e,this.maxv=n,this.bin=r,this._fetchedSize=i}toUniqueString(){return`${this.minv}..${this.maxv} (bin ${this.bin}, fetchedSize ${this.fetchedSize()})`}toString(){return this.toUniqueString()}compareTo(e){return this.minv.compareTo(e.minv)||this.maxv.compareTo(e.maxv)||this.bin-e.bin}fetchedSize(){return this._fetchedSize!==void 0?this._fetchedSize:this.maxv.blockPosition+65536-this.minv.blockPosition}}class YA{constructor({filehandle:e,renameRefSeqs:n=r=>r}){this.filehandle=e,this.renameRefSeq=n}async getMetadata(e={}){const{indices:n,...r}=await this.parse(e);return r}_findFirstData(e,n){return e?e.compareTo(n)>0?n:e:n}async parse(e={}){return this.parseP||(this.parseP=this._parse(e).catch(n=>{throw this.parseP=void 0,n})),this.parseP}async hasRefSeq(e,n={}){return!!((await this.parse(n)).indices[e]||{}).binIndex}}const M7=21578324,hw=14;function P7(t,e){return t+=1,e-=1,[[0,0],[1+(t>>26),1+(e>>26)],[9+(t>>23),9+(e>>23)],[73+(t>>20),73+(e>>20)],[585+(t>>17),585+(e>>17)],[4681+(t>>14),4681+(e>>14)]]}class Fd extends YA{async lineCount(e,n={}){const r=await this.parse(n);if(!r)return-1;const i=r.refNameToId[e];if(!r.indices[i])return-1;const{stats:o}=r.indices[i];return o?o.lineCount:-1}async _parse(e={}){const n=await this.filehandle.readFile(e),r=await xo(n);if(Di(e.signal),r.readUInt32LE(0)!==M7)throw new Error("Not a TBI file");const i=r.readInt32LE(4),a=r.readInt32LE(8),o=a&65536?"zero-based-half-open":"1-based-closed",u={0:"generic",1:"SAM",2:"VCF"}[a&15];if(!u)throw new Error(`invalid Tabix preset format flags ${a}`);const l={ref:r.readInt32LE(12),start:r.readInt32LE(16),end:r.readInt32LE(20)},f=r.readInt32LE(24),c=5,h=((1<<(c+1)*3)-1)/7,d=2**(14+c*3),p=f?String.fromCharCode(f):null,m=r.readInt32LE(28),y=r.readInt32LE(32),{refNameToId:w,refIdToName:A}=this._parseNameBytes(r.slice(36,36+y));let C=36+y,E;return{indices:new Array(i).fill(0).map(()=>{const R=r.readInt32LE(C);C+=4;const I={};let O;for(let N=0;N<R;N+=1){const J=r.readUInt32LE(C);if(C+=4,J>h+1)throw new Error("tabix index contains too many bins, please use a CSI index");if(J===h+1){const ee=r.readInt32LE(C);C+=4,ee===2&&(O=this.parsePseudoBin(r,C)),C+=16*ee}else{const ee=r.readInt32LE(C);C+=4;const Q=new Array(ee);for(let he=0;he<ee;he+=1){const be=Ja(r,C),Se=Ja(r,C+8);C+=16,E=this._findFirstData(E,be),Q[he]=new Mf(be,Se,J)}I[J]=Q}}const T=r.readInt32LE(C);C+=4;const B=new Array(T);for(let N=0;N<T;N+=1)B[N]=Ja(r,C),C+=8,E=this._findFirstData(E,B[N]);return{binIndex:I,linearIndex:B,stats:O}}),metaChar:p,maxBinNumber:h,maxRefLength:d,skipLines:m,firstDataLine:E,columnNumbers:l,coordinateType:o,format:u,refIdToName:A,refNameToId:w,maxBlockSize:65536}}parsePseudoBin(e,n){return{lineCount:WA(Zc.fromBytesLE(e.slice(n+16,n+24),!0))}}_parseNameBytes(e){let n=0,r=0;const i=[],a={};for(let o=0;o<e.length;o+=1)if(!e[o]){if(r<o){let s=e.toString("utf8",r,o);s=this.renameRefSeq(s),i[n]=s,a[s]=n}r=o+1,n+=1}return{refNameToId:a,refIdToName:i}}async blocksForRange(e,n,r,i={}){n<0&&(n=0);const a=await this.parse(i);if(!a)return[];const o=a.refNameToId[e],s=a.indices[o];if(!s)return[];(s.linearIndex.length?s.linearIndex[n>>hw>=s.linearIndex.length?s.linearIndex.length-1:n>>hw]:new Vg(0,0))||console.warn("querying outside of possible tabix range");const l=P7(n,r),f=[];for(const[m,y]of l)for(let w=m;w<=y;w++)if(s.binIndex[w]){const A=s.binIndex[w];for(let C=0;C<A.length;++C)f.push(new Mf(A[C].minv,A[C].maxv,w))}const c=s.linearIndex.length;let h=null;const d=Math.min(n>>14,c-1),p=Math.min(r>>14,c-1);for(let m=d;m<=p;++m){const y=s.linearIndex[m];y&&(!h||y.compareTo(h)<0)&&(h=y)}return ZA(f,h)}}const z7=21582659,U7=38359875;function q7(t,e){return t*2**e}function dw(t,e){return Math.floor(t/2**e)}class pw extends YA{constructor(e){super(e),this.maxBinNumber=0,this.depth=0,this.minShift=0}async lineCount(e,n={}){const r=await this.parse(n);if(!r)return-1;const i=r.refNameToId[e];if(!r.indices[i])return-1;const{stats:o}=r.indices[i];return o?o.lineCount:-1}async indexCov(){throw new Error("CSI indexes do not support indexcov")}parseAuxData(e,n){const r=e.readInt32LE(n),i=r&65536?"zero-based-half-open":"1-based-closed",a={0:"generic",1:"SAM",2:"VCF"}[r&15];if(!a)throw new Error(`invalid Tabix preset format flags ${r}`);const o={ref:e.readInt32LE(n+4),start:e.readInt32LE(n+8),end:e.readInt32LE(n+12)},s=e.readInt32LE(n+16),u=s?String.fromCharCode(s):null,l=e.readInt32LE(n+20),f=e.readInt32LE(n+24),{refIdToName:c,refNameToId:h}=this._parseNameBytes(e.slice(n+28,n+28+f));return{refIdToName:c,refNameToId:h,skipLines:l,metaChar:u,columnNumbers:o,format:a,coordinateType:i}}_parseNameBytes(e){let n=0,r=0;const i=[],a={};for(let o=0;o<e.length;o+=1)if(!e[o]){if(r<o){let s=e.toString("utf8",r,o);s=this.renameRefSeq(s),i[n]=s,a[s]=n}r=o+1,n+=1}return{refNameToId:a,refIdToName:i}}async _parse(e={}){const n=await xo(await this.filehandle.readFile(e));let r;if(n.readUInt32LE(0)===z7)r=1;else if(n.readUInt32LE(0)===U7)r=2;else throw new Error("Not a CSI file");this.minShift=n.readInt32LE(4),this.depth=n.readInt32LE(8),this.maxBinNumber=((1<<(this.depth+1)*3)-1)/7;const i=2**(this.minShift+this.depth*3),a=n.readInt32LE(12),o=a&&a>=30?this.parseAuxData(n,16):{refIdToName:[],refNameToId:{},metaChar:null,columnNumbers:{ref:0,start:1,end:2},coordinateType:"zero-based-half-open",format:"generic"},s=n.readInt32LE(16+a);let u,l=16+a+4;const f=new Array(s).fill(0).map(()=>{const c=n.readInt32LE(l);l+=4;const h={};let d;for(let p=0;p<c;p+=1){const m=n.readUInt32LE(l);if(m>this.maxBinNumber)d=this.parsePseudoBin(n,l+4),l+=4+8+4+16+16;else{const y=Ja(n,l+4);u=this._findFirstData(u,y);const w=n.readInt32LE(l+12);l+=16;const A=new Array(w);for(let C=0;C<w;C+=1){const E=Ja(n,l),k=Ja(n,l+8);l+=16,A[C]=new Mf(E,k,m)}h[m]=A}}return{binIndex:h,stats:d}});return{...o,csi:!0,refCount:s,maxBlockSize:65536,firstDataLine:u,csiVersion:r,indices:f,depth:this.depth,maxBinNumber:this.maxBinNumber,maxRefLength:i}}parsePseudoBin(e,n){return{lineCount:WA(Zc.fromBytesLE(e.slice(n+28,n+36),!0))}}async blocksForRange(e,n,r,i={}){n<0&&(n=0);const a=await this.parse(i);if(!a)return[];const o=a.refNameToId[e],s=a.indices[o];if(!s)return[];const u=this.reg2bins(n,r),l=[];for(const[f,c]of u)for(let h=f;h<=c;h++)if(s.binIndex[h]){const d=s.binIndex[h];for(let p=0;p<d.length;++p)l.push(new Mf(d[p].minv,d[p].maxv,h))}return ZA(l,new Vg(0,0))}reg2bins(e,n){e-=1,e<1&&(e=1),n>2**50&&(n=2**34),n-=1;let r=0,i=0,a=this.minShift+this.depth*3;const o=[];for(;r<=this.depth;a-=3,i+=q7(1,r*3),r+=1){const s=i+dw(e,a),u=i+dw(n,a);if(u-s+o.length>this.maxBinNumber)throw new Error(`query ${e}-${n} is too large for current binning scheme (shift ${this.minShift}, depth ${this.depth}), try a smaller query or a coarser index binning scheme`);o.push([s,u])}return o}}const Id=typeof TextDecoder<"u"?new TextDecoder("utf-8"):void 0;function V7(t){return new Promise(e=>setTimeout(e,t))}class H7{constructor({path:e,filehandle:n,tbiPath:r,tbiFilehandle:i,csiPath:a,csiFilehandle:o,yieldTime:s=500,chunkSizeLimit:u=5e7,renameRefSeqs:l=c=>c,chunkCacheSize:f=5*2**20}){if(n)this.filehandle=n;else if(e)this.filehandle=new Yt(e);else throw new TypeError("must provide either filehandle or path");if(i)this.index=new Fd({filehandle:i,renameRefSeqs:l});else if(o)this.index=new pw({filehandle:o,renameRefSeqs:l});else if(r)this.index=new Fd({filehandle:new Yt(r),renameRefSeqs:l});else if(a)this.index=new pw({filehandle:new Yt(a),renameRefSeqs:l});else if(e)this.index=new Fd({filehandle:new Yt(`${e}.tbi`),renameRefSeqs:l});else throw new TypeError("must provide one of tbiFilehandle, tbiPath, csiFilehandle, or csiPath");this.chunkSizeLimit=u,this.renameRefSeq=l,this.yieldTime=s,this.chunkCache=new Vc({cache:new $7({maxSize:Math.floor(f/65536)}),fill:(c,h)=>this.readChunk(c,{signal:h})})}async getLines(e,n,r,i){let a,o={},s;if(typeof i>"u")throw new TypeError("line callback must be provided");if(typeof i=="function"?s=i:(o=i,s=i.lineCallback),e===void 0)throw new TypeError("must provide a reference sequence name");if(!s)throw new TypeError("line callback must be provided");const u=await this.index.getMetadata(o);if(Di(a),n||(n=0),r||(r=u.maxRefLength),!(n<=r))throw new TypeError("invalid start and end coordinates. start must be less than or equal to end");if(n===r)return;const l=await this.index.blocksForRange(e,n,r,o);Di(a);for(let c=0;c<l.length;c+=1){const h=l[c].fetchedSize();if(h>this.chunkSizeLimit)throw new Error(`Too much data. Chunk size ${h.toLocaleString()} bytes exceeds chunkSizeLimit of ${this.chunkSizeLimit.toLocaleString()}.`)}let f=Date.now();for(let c=0;c<l.length;c+=1){let h;const d=l[c],{buffer:p,cpositions:m,dpositions:y}=await this.chunkCache.get(d.toString(),d);Di(a);let w=0,A=0;for(;w<p.length;){const C=p.indexOf(` -`,w);if(C===-1)break;const E=p.slice(w,C),k=(Id==null?void 0:Id.decode(E))||E.toString();if(y){for(;w+d.minv.dataPosition>=y[A++];);A--}const{startCoordinate:R,overlaps:I}=this.checkLine(u,e,n,r,k);if(h!==void 0&&R!==void 0&&h>R)throw new Error(`Lines not sorted by start coordinate (${h} > ${R}), this file is not usable with Tabix.`);if(h=R,I)s(k.trim(),m[A]*256+(w-y[A])+d.minv.dataPosition+1);else if(R!==void 0&&R>=r)return;this.yieldTime&&f-Date.now()>this.yieldTime&&(f=Date.now(),Di(a),await V7(1)),w=C+1}}}async getMetadata(e={}){return this.index.getMetadata(e)}async getHeaderBuffer(e={}){const{firstDataLine:n,metaChar:r,maxBlockSize:i}=await this.getMetadata(e);Di(e.signal);const a=((n==null?void 0:n.blockPosition)||0)+i;let o=await this._readRegion(0,a,e);Di(e.signal);try{o=await xo(o)}catch(s){throw console.error(s),new Error(`error decompressing block ${s.code} at 0 (length ${a}) ${s}`)}if(r){let s=-1;const u=` -`.charCodeAt(0),l=r.charCodeAt(0);for(let f=0;f<o.length&&!(f===s+1&&o[f]!==l);f+=1)o[f]===u&&(s=f);o=o.slice(0,s+1)}return o}async getHeader(e={}){return(await this.getHeaderBuffer(e)).toString("utf8")}async getReferenceSequenceNames(e={}){return(await this.getMetadata(e)).refIdToName}checkLine(e,n,r,i,a){const{columnNumbers:o,metaChar:s,coordinateType:u,format:l}=e;if(a.charAt(0)===s)return{overlaps:!1};let{ref:f,start:c,end:h}=o;f||(f=0),c||(c=0),h||(h=0),l==="VCF"&&(h=8);const d=Math.max(f,c,h);let p=1,m=0,y="",w=-1/0;for(let A=0;A<a.length+1;A+=1)if(a[A]===" "||A===a.length){if(p===f){if(this.renameRefSeq(a.slice(m,A))!==n)return{overlaps:!1}}else if(p===c){if(w=parseInt(a.slice(m,A),10),u==="1-based-closed"&&(w-=1),w>=i)return{startCoordinate:w,overlaps:!1};if((h===0||h===c)&&w+1<=r)return{startCoordinate:w,overlaps:!1}}else if(l==="VCF"&&p===4)y=a.slice(m,A);else if(p===h){let C;if(l==="VCF"?C=this._getVcfEnd(w,y,a.slice(m,A)):C=parseInt(a.slice(m,A),10),C<=r)return{overlaps:!1}}if(m=A+1,p+=1,p>d)break}return{startCoordinate:w,overlaps:!0}}_getVcfEnd(e,n,r){let i=e+n.length;const a=r.indexOf("SVTYPE=TRA")!==-1;if(r[0]!=="."&&!a){let o=";";for(let s=0;s<r.length;s+=1){if(o===";"&&r.slice(s,s+4)==="END="){let u=r.indexOf(";",s);u===-1&&(u=r.length),i=parseInt(r.slice(s+4,u),10);break}o=r[s]}}else if(a)return e+1;return i}async lineCount(e,n={}){return this.index.lineCount(e,n)}async _readRegion(e,n,r={}){const i=Je.Buffer.alloc(n),{bytesRead:a,buffer:o}=await this.filehandle.read(i,0,n,e,r);return o.slice(0,a)}async readChunk(e,n={}){const r=await this._readRegion(e.minv.blockPosition,e.fetchedSize(),n);try{return G2(r,e)}catch(i){throw new Error(`error decompressing c ${e.toString()} ${i}`)}}}class G7 extends Kl(wa){constructor(n,r){const i={channel:"x",windowSize:3e6,debounceDomainChange:200,...n};super(r,i.channel);Gt(this,"lastRequestId",0);Gt(this,"tbiIndex");if(this.params=i,!this.params.url)throw new Error("No URL provided for TabixSource");const a=o=>new Qn(Jl(o,this.view.getBaseUrl()));this.tbiIndex=new H7({filehandle:a(this.params.url),tbiFilehandle:a(this.params.indexUrl??this.params.url+".tbi")}),this.params.debounceDomainChange>0&&(this.onDomainChanged=Wc(this.onDomainChanged.bind(this),this.params.debounceDomainChange,!1))}async onDomainChanged(n){const r=this.params.windowSize;if(n[1]-n[0]>r)return;const i=this.quantizeInterval(n,r);this.checkAndUpdateLastInterval(i)&&this.doRequest(i)}async doRequest(n){const r=await this.getFeatures(n);r.requestId<this.lastRequestId||this.publishData(r.features)}async getFeatures(n){let r=++this.lastRequestId;const i=new AbortController,a=this.genome.continuousToDiscreteChromosomeIntervals(n),o=await Promise.all(a.map(async s=>{const u=[];return await this.tbiIndex.getLines(s.chrom,s.startPos,s.endPos,{lineCallback:l=>{u.push(l)},signal:i.signal}),this._parseFeatures(u)}));return{requestId:r,abort:()=>i.abort(),features:o.flat()}}_parseFeatures(n){return[]}}class j7 extends G7{_parseFeatures(e){return D7.parseStringSync(e.join(` -`),{parseSequences:!1})}}function W7(t,e){if(n2(t))return new XB(t,e);if(KB(t))return new JB(t,e);if(QB(t))return new e5(t,e);if(Z7(t))return n9(t.lazy,e);throw new Error("Cannot figure out the data source type: "+JSON.stringify(t))}function Z7(t){return"lazy"in t}function Y7(t){return(t==null?void 0:t.type)=="axisTicks"}function X7(t){return(t==null?void 0:t.type)=="axisGenome"}function K7(t){return(t==null?void 0:t.type)=="indexedFasta"}function J7(t){return(t==null?void 0:t.type)=="bigwig"}function Q7(t){return(t==null?void 0:t.type)=="bigbed"}function e9(t){return(t==null?void 0:t.type)=="bam"}function t9(t){return(t==null?void 0:t.type)=="gff3"}function n9(t,e){if(Y7(t))return new n5(t,e);if(X7(t))return new r5(t,e);if(K7(t))return new l$(t,e);if(J7(t))return new rP(t,e);if(Q7(t))return new vP(t,e);if(e9(t))return new ZP(t,e);if(t9(t))return new j7(t,e);throw new Error("Cannot figure out the data source type: "+JSON.stringify(t))}function r9(t){const e=Object.keys(t).filter(r=>typeof r=="string"),n=new Function("source","return { "+e.map(r=>JSON.stringify(r)).map(r=>`${r}: source[${r}]`).join(`, -`)+" };");return n.properties=e,n}class Pf extends Xe{get behavior(){return fr}constructor(){super();const e=n=>{const r=r9(n);this.handle=i=>this._propagate(r(i)),this.handle(n)};this.handle=e,this.beginBatch=n=>{Fv(n)&&(this.handle=e),super.beginBatch(n)}}}function i9(t){return"name"in t}var _l;class XA extends jl{constructor(n,r,i){super();ge(this,_l,void 0);this.provider=i,this.params=n}get identifier(){return this.params.name}updateDynamicData(n){qn(this,_l,n),this.loadSynchronously()}loadSynchronously(){const n=re(this,_l)??this.provider(this.params.name)??[];let r=i=>i;if(Array.isArray(n))n.length>0&&(r=t2(n[0]));else throw new Error(`Named data "${this.params.name}" is not an array!`);this.reset(),this.beginBatch({type:"file"});for(const i of n)this._propagate(r(i));this.complete()}async load(){this.loadSynchronously()}}_l=new WeakMap;class KA{constructor(){this._dataSourcesByHost=new Map,this._collectorsByHost=new Map,this._observers=new Map}get dataSources(){return[...new Set(this._dataSourcesByHost.values()).values()]}get collectors(){return[...this._collectorsByHost.values()]}addObserver(e,n){let r=this._observers.get(n);r||(r=[],this._observers.set(n,r)),r.push(e)}_relayObserverCallback(e,n){const r=this._observers.get(n);if(r)for(const i of r)i(e)}addDataSource(e,n){this._dataSourcesByHost.set(n,e)}findDataSourceByKey(e){return this._dataSourcesByHost.get(e)}findNamedDataSource(e){let n,r=[];for(const[i,a]of this._dataSourcesByHost.entries())if(a instanceof XA&&e==a.identifier){if(n&&n!==a)throw new Error(`Found multiple instances of named data: ${e}. Data flow optimization is broken (it's a bug).`);n=a,r.push(i)}if(n)return{dataSource:n,hosts:r}}addCollector(e,n){this._collectorsByHost.set(n,e),e.observers.push(r=>this._relayObserverCallback(r,n))}findCollectorByKey(e){return this._collectorsByHost.get(e)}initialize(){for(const e of this.dataSources)e.visit(n=>n.initialize())}}function a9(t,e){const n=new Map,r=[];for(const i of t)n.set(i,{ref:i,children:[]});for(const i of n.values()){const a=n.get(e(i.ref));a?a.children.push(i):r.push(i)}return r}function JA(t,e,n){var i,a;const r=(i=e.preOrder)==null?void 0:i.call(e,t);if(r)return r;for(const o of n(t)){const s=JA(o,e,n);if(s==="stop")return s}return(a=e.postOrder)==null?void 0:a.call(e,t)}function o9(t,e){return JA(t,e,n=>n.children)}function s9(t,e){const n=[];let r;const i=e??new KA,a=[];function o(c,h=()=>{}){if(!r)throw h()||new Error("Cannot append data flow node, no parent exist!");return r.addChild(c),r=c,c}function s(c,h){return o(c,()=>new Error(`Cannot append a transform because no (inherited) data are available! ${h?JSON.stringify(h):""}`))}function u(c,h){for(const d of c){let p;try{p=jB(d,h)}catch(m){throw console.warn(m),new Error(`Cannot initialize "${d.type}" transform: ${m}`)}p.behavior&Si&&s(new Pf),s(p)}}const l=c=>{if(n.push(r),c.spec.data){const h=i9(c.spec.data)?new XA(c.spec.data,c,c.context.getNamedDataFromProvider):W7(c.spec.data,c);r=h,i.addDataSource(h,c)}if(c.spec.transform&&u(c.spec.transform,c),c instanceof Ct){if(!r)throw new Error(`A unit view (${c.getPathString()}) has no (inherited) data source`);const h=l9(c);if(h){a.push(h.rewrite);for(const p of h.transforms)s(p)}c.mark.isPickingParticipant()&&(s(new Pf),s(new Qv({type:"identifier"})));const d=new Xv({type:"collect",groupby:c.getFacetFields(),sort:u9(c,h==null?void 0:h.rewrittenEncoding)});o(d),i.addCollector(d,c)}},f=a9(t.getDescendants(),c=>c.dataParent);for(const c of f)o9(c,{preOrder:h=>l(h.ref),postOrder:()=>{r=n.pop()}});return a.forEach(c=>c()),i}function l9(t){var a;const e=[],n={},r=[];for(const[o,s]of Object.entries(t.getEncoding())){const u=o;Zs(u)&&p_(s)&&r.push({channel:u,chromPosDef:s})}const i=rc(r,o=>aa(o.channel),o=>o.chromPosDef.chrom);for(const[o,s]of i.entries())for(const[u,l]of s.entries()){const f=[],c=[],h=[];for(const{channel:d,chromPosDef:p}of l){const m=A=>A.replace(/[^A-Za-z0-9_]/g,""),y=["_linearized_",m(p.chrom),"_",m(p.pos)].join(""),w={...((a=t.spec.encoding)==null?void 0:a[d])??t.getEncoding()[d]??{},field:y};delete w.chrom,delete w.pos,!w.type&&p.type&&(w.type=p.type),n[d]=w,f.push(p.pos),h.push(p.offset??0),c.push(y)}e.push(new Pf),e.push(new Kv({type:"linearizeGenomicCoordinate",channel:o,chrom:u,pos:f,offset:h,as:c},t))}return e.length?{transforms:e,rewrittenEncoding:n,rewrite:()=>{t.spec.encoding={...t.spec.encoding,...n},vv(t.mark,"encoding")}}:void 0}function u9(t,e){var r;const n={...t.getEncoding(),...e}.x;if(sn(n)&&(r=t.getScaleResolution("x"))!=null&&r.isZoomable()){if(Pl(n))return{field:n.field};if(!zl(n))throw new Error("A zoomable x channel must be mapped to a field.")}}function QA(t,e=void 0){if(t.parent!==e)return!1;for(const n of t.children)if(!QA(n,t))return!1;return!0}function X0(t,e=!1){if(t.behavior&ag&&(e=!0),t instanceof Pf)if(e)e=!1;else{const n=t.children[0];t.excise(),n&&X0(n,e);return}t.behavior&fr&&(e=!1);for(let n=0,r=t.children.length;n<r;n++)X0(t.children[n],e||r>1)}function f9(t){const e=[...t._dataSourcesByHost.entries()],n=new Map;for(const r of e){const i=r[1];i.identifier&&!n.has(i.identifier)&&n.set(i.identifier,i)}t._dataSourcesByHost.clear();for(let[r,i]of e){const a=n.get(i.identifier);a&&(a.adoptChildrenOf(i),i=a),t.addDataSource(i,r)}}function c9(t){if(X0(t),!QA(t))throw new Error("Encountered a bug! There's a problem in the data flow structure.")}function h9(t){for(const e of t.dataSources)c9(e);f9(t)}function d9(t){t.visit(n=>{n instanceof Ct&&n.resolve("scale")});const e=new Set;t.visit(n=>{for(const r of Object.values(n.resolutions.scale)){const i=r.name;if(i&&e.has(i))throw new Error(`The same scale name "${i}" occurs in multiple scale resolutions!`);e.add(i)}}),t.visit(n=>{n instanceof Ct&&n.resolve("axis")}),t.visit(n=>n.onScalesResolved())}function p9(t){for(const e of Bo){const n=t.getScaleResolution(e);n&&!n.name&&n.isZoomable()&&(n.name=`${e}_at_root`)}}async function g9(t,e,n){var o;if(!t.import.url)throw new Error("Cannot import, not an import spec: "+JSON.stringify(t));const r=fc({baseURL:e}),i=t.import.url,a=JSON.parse(await r.load(i).catch(s=>{throw new Error(`Could not load imported view spec: ${i} -Reason: ${s.message}`)}));if(n.isViewSpec(a))return a.baseUrl=(o=i.match(/^[^?#]*\//))==null?void 0:o[0],a;throw new Error(`The imported spec "${i}" is not a view spec: ${JSON.stringify(t)}`)}async function eS(t){const e=[];t.visit(n=>{if(n instanceof Yv)return e.push(n),Rv});for(const n of e){const r=n.context,i=await g9(n.spec,n.getBaseUrl(),r),a=r.createView(i,n.layoutParent,n.dataParent,n.name);n.layoutParent.replaceChild(n,a),await eS(a)}}function m9(t){const e=t.getSize().addPadding(t.getOverhang()),n=r=>r.grow>0?void 0:r.px;return{width:n(e.width),height:n(e.height)}}function yr(t){return()=>t}const Wn=class Wn{static create(e,n,r,i){return new Wn(yr(e),yr(n),yr(r),yr(i))}_offset(e,n){const r=this["_"+e];if(n===0)return r;switch(typeof n){case"number":return()=>r()+n;case"function":return()=>r()+n();default:throw new Error("Not a number of function")}}_passThrough(e){return this._offset(e,0)}constructor(e,n,r,i){this._x=e,this._y=n,this._width=r,this._height=i}get x(){return this._x()}get y(){return this._y()}get width(){return this._width()}get height(){return this._height()}get x2(){return this._x()+this._width()}get y2(){return this._y()+this._height()}equals(e){return e?this===e||this.x===e.x&&this.y===e.y&&this.width===e.width&&this.height===e.height:!1}modify(e){if(!Object.keys(e).length)return this;const n=r=>{const i=e[r];return typeof i=="number"?yr(i):typeof i=="function"?i:this._passThrough(r)};return new Wn(n("x"),n("y"),n("width"),n("height"))}translate(e,n){return e===0&&n===0?this:new Wn(this._offset("x",e),this._offset("y",n),this._passThrough("width"),this._passThrough("height"))}translateBy(e){return this.translate(e.x,e.y)}expand(e,n=1){return e.left==0&&e.top==0&&e.right==0&&e.bottom==0?this:new Wn(e.left?this._offset("x",-e.left*n):this._passThrough("x"),e.top?this._offset("y",-e.top*n):this._passThrough("y"),e.width?this._offset("width",e.width*n):this._passThrough("width"),e.height?this._offset("height",e.height*n):this._passThrough("height"))}shrink(e){return this.expand(e,-1)}intersect(e){return this===e?this:new Wn(()=>Math.max(this.x,e.x),()=>Math.max(this.y,e.y),()=>Math.min(this.x2,e.x2)-Math.max(this.x,e.x),()=>Math.min(this.y2,e.y2)-Math.max(this.y,e.y))}isDefined(){return this.width>=0&&this.height>=0}flatten(){return new Wn(yr(this.x),yr(this.y),yr(this.width),yr(this.height))}containsPoint(e,n){return e>=this.x&&e<this.x2&&n>=this.y&&n<this.y2}normalizePoint(e,n){return{x:(e-this.x)/this.width,y:(n-this.y)/this.height}}toString(){return`Rectangle: x: ${this.x}, y: ${this.y}, width: ${this.width}, height: ${this.height}`}toRoundedString(){return`Rectangle: x: ${Math.round(this.x)}, y: ${Math.round(this.y)}, width: ${Math.round(this.width)}, height: ${Math.round(this.height)}`}};Gt(Wn,"ZERO",Wn.create(0,0,0,0));let pl=Wn;class tS{constructor(e){this.globalOptions=e}pushView(e,n){}popView(e){}renderMark(e,n){}}class gw extends tS{constructor(e,n){super(e),this.webGLHelper=n,this.buffer=[],this.coords=void 0,this.views=new Set}pushView(e,n){this.views.add(e),this.coords=n}renderMark(e,n){if(this.globalOptions.picking&&!e.isPickingParticipant())return;const r=e.render(n);r&&this.buffer.push({mark:e,callback:r,coords:this.coords,clipRect:n.clipRect})}render(){if(this.batch||this._buildBatch(),this.batch.length==0)return;const e=this.webGLHelper.gl,n=this.globalOptions.picking;e.bindFramebuffer(e.FRAMEBUFFER,n?this.webGLHelper._pickingBufferInfo.framebuffer:null),this.webGLHelper.clearAll();for(const r of this.views)r.onBeforeRender();for(const r of this.batch)r();n&&e.bindFramebuffer(e.FRAMEBUFFER,null)}_buildBatch(){this.batch=[];let e=!0,n=!0;const r=o=>()=>{e&&o()},i=o=>()=>{e&&n&&o()},a=rc(this.buffer.reverse(),o=>o.mark);for(const[o,s]of[...a.entries()].reverse()){if(!o.isReady())continue;this.batch.push(()=>{e=o.unitView.getEffectiveOpacity()>0}),this.batch.push(...o.prepareRender(this.globalOptions).map(l=>r(l)));let u;for(const l of s){const f=l.coords;f.equals(u)||this.batch.push(r(()=>{n=o.setViewport(f,l.clipRect)})),this.batch.push(i(l.callback)),u=l.coords}}}}class b9 extends tS{constructor(...e){super({}),this.contexts=e}pushView(e,n){for(const r of this.contexts)r.pushView(e,n)}popView(e){for(const n of this.contexts)n.popView(e)}renderMark(e,n){for(const r of this.contexts)r.renderMark(e,n)}}class y9{constructor(e,n){this.point=e,this.uiEvent=n,this.stopped=!1,this.target=void 0}stopPropagation(){this.stopped=!0}get type(){return this.uiEvent.type}}class w9{constructor(e,n){this.x=e,this.y=n}equals(e){return e?e===this||e.x===this.x&&e.y===this.y:!1}}const x9=t=>new Promise(e=>setTimeout(e,t));function _9(t){const e=t.requestAnimationFrame||window.requestAnimationFrame,n=t.signal,r=()=>new Promise((i,a)=>{if(n!=null&&n.aborted)return a("aborted");const o=performance.now(),s=o+(t.duration||1e3),u=typeof t.from=="number"?t.from:0,l=typeof t.to=="number"?t.to:1,f=t.easingFunction||(m=>m),c=m=>(m-o)/(s-o),h=m=>m*(l-u)+u,d=m=>Math.max(0,Math.min(1,m)),p=m=>{n!=null&&n.aborted?a("aborted"):(t.onUpdate(h(f(d(c(m))))),m<s?e(p):(t.onUpdate(h(f(1))),i()))};e(p)});return t.delay?n!=null&&n.aborted?Promise.reject("aborted"):x9(t.delay).then(r):r()}class v9{constructor(e){this._renderCallback=e,this._renderRequested=!1,this._warn=!1,this.transitions=[]}requestTransition(e){this.cancelTransition(e),this.transitions.push(e),this.requestRender()}cancelTransition(e){const n=this.transitions.indexOf(e);n>=0&&this.transitions.splice(n,1)}requestRender(){this._renderRequested?this._warn&&console.warn("Render already requested!"):(this._renderRequested=!0,window.requestAnimationFrame(e=>{this._renderRequested=!1;const n=this.transitions;this.transitions=[];let r;for(;r=n.shift();)r(e);this._renderCallback(e)}))}transition(e){return _9({requestAnimationFrame:n=>this.requestTransition(n),...e})}}class E9{constructor(e){this.genomes=new Map,this.baseUrl=e}async initialize(e){const n=new rB(e);return this.genomes.set(n.name,n),Promise.all([...this.genomes.values()].map(r=>r.load(this.baseUrl)))}getGenome(e){if(!this.genomes.size)throw new Error("No genomes have been configured!");if(e){const n=this.genomes.get(e);if(!n)throw new Error(`No genome with the name ${e} has been configured!`);return n}else{if(this.genomes.size>1)throw new Error("Cannot pick a default genome! More than one have been configured!");return this.genomes.values().next().value}}}const A9=""+new URL("Lato-Regular-e459d1f9.png",import.meta.url).href,S9={thin:100,light:300,regular:400,normal:400,medium:500,bold:700,black:900};class C9{constructor(e){this._webGLHelper=e,this.fontRepository="https://raw.githubusercontent.com/etiennepinchon/aframe-fonts/master/fonts/",this._fonts=new ea([],JSON.stringify),this._metadataPromises=new Map,this._fontPromises=new Map,this._promises=[],this._defaultFontEntry={metrics:d0(Jv),texture:e?this._createTextureNow(A9):void 0}}async waitUntilReady(){await Promise.all(this._promises)}getFont(e,n="normal",r="regular"){if(We(r)&&(r=S9[r.toLowerCase()],!r))throw new Error("Unknown font weight: "+r);const i={family:e,style:n,weight:r};let a=this._fonts.get(i);return a||(a={metrics:void 0,texture:void 0},this._fonts.set(i,a),this._promises.push(this._loadFontEntry(a,i))),a}async _loadFontEntry(e,n){try{const r=await this._loadMetadata(n.family),i=F9(r,n),a=this.fontRepository+mw(n.family)+"/"+i.replace(/\.\w+/,""),o=this._createTexture(a+".png"),s=this._loadFont(a+".json");e.texture=await o,e.metrics=await s}catch(r){console.log("Cannot load font. Using default.",r),e.metrics=this._defaultFontEntry.metrics,e.texture=this._defaultFontEntry.texture}}_loadFont(e){let n=this._fontPromises.get(e);return n||(n=fetch(e).then(r=>{if(!r.ok)throw new Error("Could not load font: "+r.status);return r}).then(r=>r.json()).then(r=>d0(r)),this._fontPromises.set(e,n)),n}_loadMetadata(e){const n=mw(e);let r=this._metadataPromises.get(n);return r||(r=fetch(this.fontRepository+n+"/METADATA.pb").then(i=>{if(!i.ok)throw new Error("Could not load font metadata: "+i.status);return i}).then(i=>i.text()).then(i=>T9(i)).catch(i=>{console.warn(i)}),this._metadataPromises.set(n,r)),r}getDefaultFont(){return this._defaultFontEntry}_createTexture(e){const n=this._webGLHelper.gl;return new Promise((r,i)=>{Ks(n,{src:e,min:n.LINEAR},(a,o,s)=>{a?i(a):r(o)})})}_createTextureNow(e){const n=this._webGLHelper.gl;let r;const i=new Promise((a,o)=>{r=Ks(n,{src:e,min:n.LINEAR},(s,u,l)=>{s?o(s):a(u)})});return this._promises.push(i),r}}function mw(t){return t.toLowerCase().replaceAll(/[^\w]/g,"")}function T9(t){const e=t.split(` -`),n=[];let r;for(const i of e)if(i.startsWith("fonts {")&&(r={name:void 0,style:void 0,weight:void 0,filename:void 0,post_script_name:void 0,full_name:void 0,copyright:void 0}),i.startsWith("}")&&(n.push(r),r=void 0),r){let a=i.match(/^\s*([A-Za-z_]+):[ ]?"(.*)"$/);if(a){const o=a[1];r[o]=a[2]}if(a=i.match(/^\s*([A-Za-z_]+):[ ]?(\d+)$/),a){const o=a[1];r[o]=+a[2]}}return n}function F9(t,e){let n,r=Number.POSITIVE_INFINITY;for(const i of t)if(e.family.localeCompare(i.name,void 0,{sensitivity:"accent"})==0&&e.style==i.style){const a=Math.abs(e.weight-i.weight);a<r&&(r=a,n=i)}return n==null?void 0:n.filename}function I9(t,e){const n=[];let r;for(const i of t.split(` -`))if(i.startsWith(">"))r={identifier:i.match(/>(\S+)/)[1],sequence:""},n.push(r);else if(r)r.sequence+=i.trim();else throw new Error("Invalid fasta file!");return n}class k9{constructor(e,n){this.animator=e,this.disabled=!!n,this.damping=.015,this.acceleration=.3,this.accelerationThreshold=100,this.lowerLimit=.5,this.loop=!1,this.momentum=0,this.timestamp=0,this.callback=null,this._transitionCallback=this.animate.bind(this),this.clear()}clear(){this.momentum=0,this.timestamp=null,this.loop=null,this.callback=null}cancel(){this.loop&&(this.animator.cancelTransition(this._transitionCallback),this.clear())}setMomentum(e,n){if(this.disabled){n(e);return}e*this.momentum<0?this.momentum=0:Math.abs(e)>this.accelerationThreshold?this.momentum=y3([this.momentum,e],this.acceleration):this.momentum=e,this.callback=n,this.loop||this.animate()}animate(e){this.callback(this.momentum);const n=e-this.timestamp||0;this.timestamp=e;const r=Math.abs(this.momentum);this.momentum=Math.sign(this.momentum)*Math.max(0,r-((r*this.damping)**1.5+.04)*n),Math.abs(this.momentum)>this.lowerLimit?(this.loop=!0,this.animator.requestTransition(this._transitionCallback)):this.clear()}}function R9(t){const e={},n=["string","number","boolean"],r=["wheelDelta","wheelDeltaX","wheelDeltaY"];for(const i in t){const a=i;!r.includes(i)&&n.includes(typeof t[a])&&(e[a]=t[a])}return e}const bw=new Map;async function D9(t,e,n){const r=t.symbol;let i=bw.get(r)??await $9(t.symbol);return i?(bw.set(r,i),ot`<div class="title"><strong>${i.name}</strong> ${i.description}</div><p class="summary">${i.summary}</p><p class="source">Source: NCBI RefSeq Gene</p>`):null}async function B9(t){console.log("Searching: "+t);const e={mode:"cors"},r=(await fetch(`https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=gene&term=${t}[GENE]&sort=relevance&retmode=json`,e).then(i=>i.json())).esearchresult.idlist[0];return r?(await fetch(`https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esummary.fcgi?db=gene&id=${r}&retmode=json`,e).then(o=>o.json())).result[r]:null}const N9=Wc(B9,500);function $9(t){return N9(t)}const O9=gt(".4~r"),L9=gt(".4~e");function nS(t){return t==null?ot`<span class="na">NA</span>`:We(t)?t.substring(0,30):Number.isInteger(t)?""+t:Vt(t)?Math.abs(t)>Math.pow(10,8)||Math.abs(t)<Math.pow(10,-8)?L9(t):O9(t):ec(t)?t?"True":"False":en(t)?ot`${t.map((e,n)=>[nS(e),n<t.length-1?", ":et])}`:"?"+typeof t+" "+t}async function M9(t,e,n){const r=(u,l)=>{var f;for(const[c,h]of Object.entries(e.encoders))if((f=h==null?void 0:h.accessor)!=null&&f.fields.includes(u))switch(c){case"color":case"fill":case"stroke":return ot`<span class="color-legend" style="${`background-color: ${h(l)}`}"></span>`}return""},i=Object.entries(t).filter(([u,l])=>!u.startsWith("_"));if(i.length===0)return;const a=ot`<table class="attributes">${i.map(([u,l])=>ot`<tr><th>${u}</th><td>${nS(l)} ${r(u,t)}</td></tr>`)}</table>`,o=e.unitView.getTitleText(),s=o?ot`<div class="title"><strong>${o}</strong></div>`:"";return ot`${s}${a}`}class au extends wo{constructor(e,n,r,i,a){super(e,n,r,i,a),this.spec=e,this.children=(e.layer||[]).map((o,s)=>{if(dS(o)||hS(o))return n.createView(o,this,this,"layer"+s);throw new Error("LayerView accepts only unit or layer specs as children!")}),this.needsAxes={x:!0,y:!0}}*[Symbol.iterator](){for(const e of this.children)yield e}render(e,n,r={}){if(this.isConfiguredVisible()){e.pushView(this,n);for(const i of this.children)i.render(e,n,r);e.popView(this)}}propagateInteractionEvent(e){this.handleInteractionEvent(void 0,e,!0);for(let n=this.children.length-1;n>=0;n--)if(this.children[n].propagateInteractionEvent(e),e.stopped)return;this.handleInteractionEvent(void 0,e,!1)}}class yw{constructor(e,n){this.n=e,this.maxCols=n??1/0}get nRows(){return this.maxCols==1/0?1:Math.ceil(this.n/this.maxCols)}get nCols(){return Math.min(this.n,this.maxCols)}get rowIndices(){const e=[],n=this.nCols,r=this.nRows;for(let i=0;i<r;i++){const a=[];e.push(a);for(let o=0;o<n;o++){const s=i*n+o;s<this.n&&a.push(s)}}return e}get colIndices(){const e=[],n=this.nCols,r=this.nRows;for(let i=0;i<n;i++){const a=[];e.push(a);for(let o=0;o<r;o++){const s=o*n+i;s<this.n&&a.push(s)}}return e}getCellIndex(e,n){let r=0;if(this.maxCols==1/0)r=n==0?e:void 0;else{if(e>=this.maxCols)return;r=n*this.nCols+e}return r<this.n?r:void 0}getCellCoords(e){if(!(e<0||e>=this.n))return[e%this.nCols,Math.floor(e/this.nCols)]}}const P9="chromosome_ticks_and_labels",z9={x:"width",y:"height"};function K0(t){return t=="x"?"y":"x"}const zf={x:["bottom","top"],y:["left","right"]},Hg=Object.fromEntries(Object.entries(zf).map(([t,e])=>e.map(n=>[n,t])).flat(1));function gi(t){return Hg[t]}class rS extends au{constructor(e,n,r,i,a){const o=n=="locus",s={...o?q9:iS,...U9(n,e),...e};super(o?V9(s,n):aS(s,n),r,i,a,`axis_${e.orient}`),this.axisProps=s,this.blockEncodingInheritance=!0,this.contributesToScaleDomain=!1}getSize(){const e={px:this.getPerpendicularSize()},n={grow:1};return Hg[this.axisProps.orient]=="x"?new oa(n,e):new oa(e,n)}getPerpendicularSize(){return Gg(this.axisProps)}isPickingSupported(){return!1}}function Gg(t){const e=gi(t.orient);let n=t.ticks&&t.tickSize||0;return t.labels&&(n+=t.labelPadding,e=="x"?n+=t.labelFontSize:n+=30),t.title&&(n+=t.titlePadding+t.titleFontSize),n=Math.min(t.maxExtent||1/0,Math.max(t.minExtent||0,n)),n}const iS={values:null,minExtent:20,maxExtent:1/0,offset:0,domain:!0,domainWidth:1,domainColor:"gray",domainDash:null,domainDashOffset:0,domainCap:"square",ticks:!0,tickSize:5,tickWidth:1,tickColor:"gray",tickDash:null,tickDashOffset:0,tickCap:"square",tickCount:null,tickMinStep:null,labels:!0,labelAlign:"center",labelBaseline:"middle",labelPadding:4,labelFontSize:10,labelLimit:180,labelColor:"black",format:null,titleColor:"black",titleFont:"sans-serif",titleFontSize:10,titlePadding:3};function U9(t,e){const n=e.orient,r=t=="nominal"||t=="ordinal";let i="center",a="middle",o=e.labelAngle??((n=="top"||n=="bottom")&&r?-90:0);switch(n){case"left":i="right";break;case"right":i="left";break;case"top":case"bottom":Math.abs(o)>30?(i=o>0==(n=="bottom")?"left":"right",a="middle"):a=n=="top"?"alphabetic":"top";break}return{labelAlign:i,labelAngle:o,labelBaseline:a}}function aS(t,e){const n={...t,extent:Gg(t)},r=gi(n.orient),i=K0(r),a=n.orient=="bottom"||n.orient=="right"?1:-1,o=n.orient=="bottom"||n.orient=="left"?1:0,s=()=>({name:"domain",data:{values:[0]},mark:{type:"rule",clip:!1,strokeDash:n.domainDash,strokeCap:n.domainCap,color:n.domainColor,[i]:o,size:n.domainWidth}}),u=()=>({name:"labels",mark:{type:"text",clip:!1,align:n.labelAlign,angle:n.labelAngle,baseline:n.labelBaseline,[i+"Offset"]:(n.tickSize+n.labelPadding)*a,[i]:o,size:n.labelFontSize,color:n.labelColor,minBufferSize:1500},encoding:{[r]:{field:"value",type:e},text:{field:"label"}}}),l=()=>({name:"ticks",mark:{type:"rule",clip:!1,strokeDash:n.tickDash,strokeCap:n.tickCap,color:n.tickColor,size:n.tickWidth,minBufferSize:300},encoding:{[i]:{value:o},[i+"2"]:{value:o-n.tickSize/n.extent*(o?1:-1)}}}),f=()=>({name:"title",data:{values:[0]},mark:{type:"text",clip:!1,align:"center",baseline:n.orient=="bottom"?"bottom":"top",angle:[0,90,0,-90][["top","right","bottom","left"].indexOf(n.orient)],text:n.title,color:n.titleColor,[r]:.5,[i]:1-o}}),c=()=>{const d={name:"ticks_and_labels",encoding:{[r]:{field:"value",type:e}},layer:[]};return n.ticks&&d.layer.push(l()),n.labels&&d.layer.push(u()),d},h={resolve:{scale:{[r]:"forced"}},[z9[K0(r)]]:n.extent,data:{lazy:{type:"axisTicks",channel:r,axis:t}},layer:[]};return n.domain&&h.layer.push(s()),(n.ticks||n.labels)&&h.layer.push(c()),n.title&&h.layer.push(f()),h}const q9={...iS,chromTicks:!0,chromTickSize:18,chromTickWidth:1,chromTickColor:"#989898",chromTickDash:[4,2],chromTickDashOffset:1,chromLabels:!0,chromLabelFontSize:13,chromLabelFontWeight:"normal",chromLabelFontStyle:"normal",chromLabelColor:"black",chromLabelAlign:"left",chromLabelPadding:7};function V9(t,e){const n={...t,extent:Gg(t)},r=gi(n.orient),i=K0(r),a=n.orient=="bottom"||n.orient=="left"?1:0,o=()=>({name:"chromosome_ticks",mark:{type:"rule",strokeDash:t.chromTickDash,strokeDashOffset:t.chromTickDashOffset,[i]:a,[i+"2"]:a-n.chromTickSize/n.extent*(a?1:-1),color:t.chromTickColor,size:n.chromTickWidth}}),s=()=>{let f;switch(n.orient){case"top":f={y:0,angle:0,paddingX:4,dy:-n.chromLabelPadding,viewportEdgeFadeWidthLeft:20,viewportEdgeFadeWidthRight:20,viewportEdgeFadeDistanceRight:-10,viewportEdgeFadeDistanceLeft:-20};break;case"bottom":f={y:1,angle:0,paddingX:4,dy:n.chromLabelPadding+n.chromLabelFontSize*.73,viewportEdgeFadeWidthLeft:20,viewportEdgeFadeWidthRight:20,viewportEdgeFadeDistanceRight:-10,viewportEdgeFadeDistanceLeft:-20};break;case"left":f={x:1,angle:-90,paddingY:4,dy:-n.chromLabelPadding,viewportEdgeFadeWidthBottom:20,viewportEdgeFadeWidthTop:20,viewportEdgeFadeDistanceBottom:-20,viewportEdgeFadeDistanceTop:-10};break;case"right":f={x:0,angle:90,align:"right",paddingY:4,dy:-n.chromLabelPadding};break;default:f={}}return{name:"chromosome_labels",mark:{type:"text",size:n.chromLabelFontSize,font:n.chromLabelFont,fontWeight:n.chromLabelFontWeight,fontStyle:n.chromLabelFontStyle,color:n.chromLabelColor,align:t.chromLabelAlign,baseline:"alphabetic",clip:!1,...f},encoding:{[r+"2"]:{field:"continuousEnd",type:e},text:{field:"name"}}}};let u;switch(n.orient){case"bottom":case"top":u={};break;case"left":u={labelAngle:-90,labelAlign:"center",labelPadding:6};break;case"right":u={labelAngle:90,labelAlign:"center",labelPadding:6};break;default:u={}}const l=aS({...t,...u},e);if(t.chromTicks||t.chromLabels){const f={name:P9,data:{lazy:{type:"axisGenome",channel:gi(n.orient)}},encoding:{[r]:{field:"continuousStart",type:e,band:0}},layer:[]};if(t.chromTicks&&f.layer.push(o()),t.chromLabels){f.layer.push(s());let c;l.layer.filter(h=>h.name=="ticks_and_labels").forEach(h=>h.layer.filter(d=>d.name=="labels").forEach(d=>{c=d.mark})),c&&(n.orient=="top"||n.orient=="bottom"?(c.viewportEdgeFadeWidthLeft=30,c.viewportEdgeFadeDistanceLeft=40):(c.viewportEdgeFadeWidthBottom=30,c.viewportEdgeFadeDistanceBottom=40))}l.layer.push(f)}return l}class H9 extends au{constructor(e,n,r,i,a){const s={...n=="locus"?G9:oS,...e};super(Y9(s,n),r,i,a,`axisGrid_${e.orient}`),this.axisProps=s,this.blockEncodingInheritance=!0,this.contributesToScaleDomain=!1}getOrient(){return this.axisProps.orient}isPickingSupported(){return!1}}const oS={values:null,grid:!1,gridCap:"butt",gridColor:"lightgray",gridDash:null,gridOpacity:1,gridWidth:1,tickCount:null,tickMinStep:null},G9={...oS,chromGrid:!1,chromGridCap:"butt",chromGridColor:"gray",chromGridDash:[1,5],chromGridOpacity:1,chromGridWidth:1};function j9(t,e){const n=t,r=gi(n.orient);return{name:"grid_lines",data:{lazy:{type:"axisTicks",channel:r,axis:t}},mark:{type:"rule",strokeDash:n.gridDash,strokeCap:n.gridCap,color:n.gridColor,size:n.gridWidth,opacity:n.gridOpacity,minBufferSize:300},encoding:{[r]:{field:"value",type:e}}}}function W9(t,e){const n=t,r=gi(n.orient);return{name:"chromosome_lines",data:{lazy:{type:"axisGenome",channel:r}},mark:{type:"rule",strokeDash:n.chromGridDash,strokeCap:n.chromGridCap,color:n.chromGridColor,size:n.chromGridWidth,opacity:n.chromGridOpacity},encoding:{[r]:{field:"continuousStart",type:e,band:0}}}}function Z9(t,e){const n=t,r=gi(n.orient);return{name:"chromosome_fill",data:{lazy:{type:"axisGenome",channel:r}},mark:{type:"rect"},encoding:{[r]:{field:"continuousStart",type:e,band:0},[r+"2"]:{field:"continuousEnd",band:0},fill:{field:"odd",type:"nominal",scale:{domain:[!1,!0],range:[n.chromGridFillEven??"white",n.chromGridFillOdd??"white"]}},opacity:{field:"odd",type:"nominal",scale:{type:"ordinal",domain:[!1,!0],range:[n.chromGridFillEven?1:0,n.chromGridFillOdd?1:0]}}}}}function Y9(t,e){const n={...t},r=[];return n.chromGrid&&(n.chromGridFillOdd||n.chromGridFillEven)&&r.push(Z9(n,e)),n.chromGrid&&n.chromGridOpacity>0&&r.push(W9(n,e)),n.grid&&n.gridOpacity>0&&r.push(j9(n,e)),{name:"grid_layers",configurableVisibility:!1,resolve:{scale:{[gi(t.orient)]:"forced",fill:"independent",opacity:"independent"}},layer:r}}const ww={anchor:"middle",frame:"group",offset:10,orient:"top",align:void 0,angle:0,baseline:"alphabetic",dx:0,dy:0,color:void 0,font:void 0,fontSize:12,fontStyle:"normal",fontWeight:"normal"},X9={orient:"left",anchor:"middle",align:"right",baseline:"middle",angle:0,fontSize:12},K9={orient:"top",anchor:"start",align:"left",baseline:"top",offset:-10,dx:10,fontSize:12},J9={start:0,middle:.5,end:1},Q9={start:"left",middle:"center",end:"right"};function ez(t){if(!t)return;const e=We(t)?{text:t}:t;if(!e.text||e.orient=="none")return;const n={"track-title":X9,overlay:K9}[e.style]??{},r={...ww,...n,...e};let i={},a={x:0,y:0};const o=J9[r.anchor??"middle"];switch(r.orient){case"top":a={x:o,y:1},i={baseline:"alphabetic",angle:0};break;case"right":a={x:1,y:1-o},i={baseline:"alphabetic",angle:90};break;case"bottom":a={x:o,y:0},i={baseline:"top",angle:0};break;case"left":a={x:0,y:o},i={baseline:"alphabetic",angle:-90};break}const s={...ww,...i,...n,...e},u={xOffset:0,yOffset:0};switch(r.orient){case"top":u.yOffset=-s.offset;break;case"right":u.xOffset=s.offset;break;case"bottom":u.yOffset=s.offset;break;case"left":u.xOffset=-s.offset;break}return{configurableVisibility:!1,data:{values:[{}]},mark:{type:"text",tooltip:null,clip:!1,...a,...u,text:s.text,align:s.align??Q9[s.anchor],angle:s.angle,baseline:s.baseline,dx:s.dx,dy:s.dy,color:s.color,font:s.font,size:s.fontSize,fontStyle:s.fontStyle,fontWeight:s.fontWeight}}}function tz(t,e,n,r){if(t.type=="wheel"){t.uiEvent.preventDefault();const i=t.uiEvent,a=i.deltaMode?120:1;let{x:o,y:s}=t.point;if(r){const u=r.mark.encoders;u.x&&!u.x2&&!u.x.constantValue&&(o=+u.x(r.datum)*e.width+e.x),u.y&&!u.y2&&!u.y.constantValue&&(s=(1-+u.y(r.datum))*e.height+e.y)}Math.abs(i.deltaX)<Math.abs(i.deltaY)?n({x:o,y:s,xDelta:0,yDelta:0,zDelta:i.deltaY*a/300}):n({x:o,y:s,xDelta:-i.deltaX*a,yDelta:0,zDelta:0})}else if(t.type=="mousedown"&&t.uiEvent.button===0){const i=t.uiEvent;i.preventDefault();let a=i;const o=u=>{n({x:a.clientX,y:a.clientY,xDelta:u.clientX-a.clientX,yDelta:u.clientY-a.clientY,zDelta:0}),a=u},s=u=>{document.removeEventListener("mousemove",o),document.removeEventListener("mouseup",s)};document.addEventListener("mouseup",s,!1),document.addEventListener("mousemove",o,!1)}}var no,ro,Wt,Gi,io,Cr,Bi,jf,lS,Wf,uS,ji,hs,vl,J0,El,Q0,Al,ep,Zf,fS,ao,Xu,Yf,cS;class sS extends wo{constructor(n,r,i,a,o,s){super(n,r,i,a,o);ge(this,Cr);ge(this,jf);ge(this,Wf);ge(this,ji);ge(this,vl);ge(this,El);ge(this,Al);ge(this,Zf);ge(this,ao);ge(this,Yf);ge(this,no,1/0);ge(this,ro,10);ge(this,Wt,[]);ge(this,Gi,{});ge(this,io,0);this.spec=n,qn(this,ro,n.spacing??10),qn(this,no,s),qn(this,Wt,[]),this.wrappingFacet=!1,this._createChildren()}_createChildren(){}appendChild(n){n.layoutParent??(n.layoutParent=this),re(this,Wt).push(new _w(n,this,re(this,io))),lm(this,io)._++}setChildren(n){qn(this,Wt,[]);for(const r of n)this.appendChild(r)}replaceChild(n,r){const i=re(this,Wt).findIndex(a=>a.view==n);if(i>=0)re(this,Wt)[i]=new _w(r,this,re(this,io));else throw new Error("Not my child view!")}get children(){return re(this,Wt).map(n=>n.view)}get childCount(){return re(this,Wt).length}onScalesResolved(){super.onScalesResolved(),se(this,Wf,uS).call(this)}*[Symbol.iterator](){for(const n of re(this,Wt))yield*n.getChildren();for(const n of Object.values(re(this,Gi)))yield n}getOverhang(){return se(this,Zf,fS).call(this).union(se(this,ao,Xu).call(this))}getSize(){return this._cache("size",()=>new oa(se(this,El,Q0).call(this,"column"),se(this,El,Q0).call(this,"row")).addPadding(se(this,ao,Xu).call(this)))}render(n,r,i={}){if(!this.isConfiguredVisible())return;this.layoutParent||(r=r.shrink(this.getPadding())),r=r.shrink(se(this,ao,Xu).call(this)),n.pushView(this,r);const a={devicePixelRatio:this.context.devicePixelRatio},o=M1(se(this,vl,J0).call(this,"column"),r.width,a),s=M1(se(this,vl,J0).call(this,"row"),r.height,a),u=new yw(re(this,Cr,Bi).length,re(this,no)??1/0);for(const[l,f]of re(this,Cr,Bi).entries()){const{view:c,axes:h,gridLines:d,background:p,backgroundStroke:m,title:y}=f,[w,A]=u.getCellCoords(l),C=o[se(this,Al,ep).call(this,"column",w)],E=s[se(this,Al,ep).call(this,"row",A)],k=c.getSize(),R=c.getOverhang(),I=C.location-R.left,O=E.location-R.top,T=(k.width.grow?C.size:k.width.px)+R.width,B=(k.height.grow?E.size:k.height.px)+R.height,N=new pl(()=>r.x+I,()=>r.y+O,()=>T,()=>B);f.coords=N;const J=i.clipRect?N.intersect(i.clipRect):N;p==null||p.render(n,J,{...i,clipRect:void 0});for(const Q of Object.values(d))Q.render(n,N,i);const ee=az(c);ee&&c.render(n,N,i),m==null||m.render(n,J,{...i,clipRect:void 0});for(const[Q,he]of Object.entries(h))he.render(n,xw(N,Q,he),i);for(const Q of Object.values(re(this,Gi))){const be=Q.axisProps.orient;(be=="left"&&w==0||be=="right"&&w==u.nCols-1||be=="top"&&A==0||be=="bottom"&&A==u.nRows-1)&&Q.render(n,xw(N.shrink(f.view.getOverhang()),be,Q),i)}ee||c.render(n,N,i),y==null||y.render(n,N,i)}n.popView(this)}propagateInteractionEvent(n){if(this.handleInteractionEvent(void 0,n,!0),n.stopped)return;const r=re(this,Cr,Bi).find(a=>a.coords.containsPoint(n.point.x,n.point.y)),i=r==null?void 0:r.view;i&&(i.propagateInteractionEvent(n),(i instanceof Ct||i instanceof au)&&tz(n,r.coords,a=>se(this,Yf,cS).call(this,r.coords,r.view,a),this.context.getCurrentHover())),!n.stopped&&this.handleInteractionEvent(void 0,n,!1)}getDefaultResolution(n,r){return"independent"}}no=new WeakMap,ro=new WeakMap,Wt=new WeakMap,Gi=new WeakMap,io=new WeakMap,Cr=new WeakSet,Bi=function(){return re(this,Wt).filter(n=>n.view.isConfiguredVisible())},jf=new WeakSet,lS=function(){return new yw(re(this,Cr,Bi).length,re(this,no)??1/0)},Wf=new WeakSet,uS=function(){for(const n of Bo){const r=this.resolutions.axis[n];if(r){const i=r.getAxisProps();if(i){const a={title:r.getTitle(),orient:zf[n][0],...i},o=new rS(a,r.scaleResolution.type,this.context,this,this);re(this,Gi)[n]=o,o.visit(s=>{s instanceof Ct&&s.resolve("scale")})}}}for(const n of re(this,Wt))n.createAxes()},ji=new WeakSet,hs=function(n){const r=n=="column"?"width":"height",i=(a,o)=>a.map(s=>{const l=re(this,Cr,Bi)[s].getOverhangAndPadding();return n=="column"?o?l.right:l.left:o?l.bottom:l.top}).reduce((s,u)=>Math.max(s,u),0);return this._cache(`size/directionSizes/${n}`,()=>re(this,jf,lS)[n=="column"?"colIndices":"rowIndices"].map(a=>({axisBefore:i(a,0),axisAfter:i(a,1),view:AD(a.map(o=>re(this,Cr,Bi)[o].view.getSize()[r]))})))},vl=new WeakSet,J0=function(n){const r=se(this,ji,hs).call(this,n),i=[];i.push(ms);for(const[a,o]of r.entries())a>0&&i.push({px:re(this,ro),grow:0}),(a==0||this.wrappingFacet)&&i.push(ms),i.push({px:o.axisBefore,grow:0}),i.push(o.view),i.push({px:o.axisAfter,grow:0}),(a==r.length-1||this.wrappingFacet)&&i.push(ms);return i},El=new WeakSet,Q0=function(n){let r=0,i=0;const a=(n=="row"&&this.spec.height)??(n=="column"&&this.spec.width);if(a||a===0)return kv(a);const o=se(this,ji,hs).call(this,n);for(const[s,u]of o.entries())s>0&&(i+=re(this,ro)),(s==0||this.wrappingFacet)&&(i+=0),i+=u.axisBefore,i+=u.view.px??0,r+=u.view.grow??0,i+=u.axisAfter,(s==o.length-1||this.wrappingFacet)&&(i+=0);return{px:i,grow:r}},Al=new WeakSet,ep=function(n,r){return n=="row"&&this.wrappingFacet?1+6*r+2:2+4*r+1},Zf=new WeakSet,fS=function(){const n=se(this,ji,hs).call(this,"column"),r=se(this,ji,hs).call(this,"row");return!n.length||!r.length?yt.zero():new yt(r.at(0).axisBefore,n.at(-1).axisAfter,r.at(-1).axisAfter,n.at(0).axisBefore)},ao=new WeakSet,Xu=function(){const n=r=>{const i=Hg[r],a=re(this,Gi)[i];return(a==null?void 0:a.axisProps.orient)!==r?0:Math.max(a.getPerpendicularSize()+a.axisProps.offset,0)};return new yt(n("top"),n("right"),n("bottom"),n("left"))},Yf=new WeakSet,cS=function(n,r,i){for(const[a,o]of Object.entries(iz(r))){if(o.size<=0)continue;const s=n.normalizePoint(i.x,i.y),u=n.normalizePoint(i.x+i.xDelta,i.y+i.yDelta),l={x:u.x-s.x,y:u.y-s.y};for(const f of o)f.zoom(2**i.zDelta,a=="y"?1-s[a]:s[a],a=="x"?l.x:-l.y)}this.context.animator.requestRender()};function nz(t){if(!(!t||!t.fill||t.fillOpacity===0))return{configurableVisibility:!1,data:{values:[{}]},mark:{color:t.fill,opacity:t.fillOpacity??1,type:"rect",clip:!1,tooltip:null,minHeight:1,minOpacity:0}}}function rz(t){if(!(!t||!t.stroke||t.strokeWidth===0||t.strokeOpacity===0))return{configurableVisibility:!1,resolve:{scale:{x:"excluded",y:"excluded"},axis:{x:"excluded",y:"excluded"}},data:{values:[{x:0,y:0,x2:1,y2:0},{x:1,y:0,x2:1,y2:1},{x:1,y:1,x2:0,y2:1},{x:0,y:1,x2:0,y2:0}]},mark:{size:t.strokeWidth??1,color:t.stroke??"lightgray",strokeCap:"square",strokeOpacity:t.strokeOpacity??1,type:"rule",clip:!1,tooltip:null},encoding:{x:{field:"x",type:"quantitative",scale:null},y:{field:"y",type:"quantitative",scale:null},x2:{field:"x2"},y2:{field:"y2"}}}}function iz(t){const e={x:new Set,y:new Set};return t.visit(n=>{for(const[r,i]of Object.entries(e)){const a=n.getScaleResolution(r);a&&a.isZoomable()&&i.add(a)}}),e}function az(t){let e=!0;return t.visit(n=>{n instanceof Ct&&e&&(e=n.mark.properties.clip===!0)}),e}function xw(t,e,n){const r=n.axisProps,i=n.getPerpendicularSize();if(e=="bottom")return t.translate(0,t.height+r.offset).modify({height:i});if(e=="top")return t.translate(0,-i-r.offset).modify({height:i});if(e=="left")return t.translate(-i-r.offset,0).modify({width:i});if(e=="right")return t.translate(t.width+r.offset,0).modify({width:i})}class _w{constructor(e,n,r){if(this.layoutParent=n,this.view=e,this.serial=r,this.background=void 0,this.backgroundStroke=void 0,this.axes={},this.gridLines={},this.title=void 0,this.coords=pl.ZERO,e.needsAxes.x||e.needsAxes.y){const i=e.spec,a="view"in i?i==null?void 0:i.view:void 0,o=nz(a);o&&(this.background=new Ct(o,n.context,n,e,"background"+r),this.background.blockEncodingInheritance=!0);const s=rz(a);s&&(this.backgroundStroke=new Ct(s,n.context,n,e,"backgroundStroke"+r),this.backgroundStroke.blockEncodingInheritance=!0);const u=ez(e.spec.title);if(u){const l=new Ct(u,n.context,n,e,"title"+r);l.blockEncodingInheritance=!0,this.title=l}}}*getChildren(){this.background&&(yield this.background),this.backgroundStroke&&(yield this.backgroundStroke),this.title&&(yield this.title),yield*Object.values(this.axes),yield*Object.values(this.gridLines),yield this.view}createAxes(){const{view:e,axes:n,gridLines:r}=this,i=(s,u)=>{const l=s.getAxisProps();if(l===null)return;const f=l?{...l}:{};if(!f.orient){for(const c of zf[u])if(!n[c]){f.orient=c;break}if(!f.orient)throw new Error("No slots available for an axis! Perhaps a LayerView has more than two children?")}if(f.title??(f.title=s.getTitle()),!zf[u].includes(f.orient))throw new Error(`Invalid axis orientation "${f.orient}" on channel "${u}"!`);return f},a=(s,u,l)=>{const f=i(s,u);if(f){if(n[f.orient])throw new Error(`An axis with the orient "${f.orient}" already exists!`);n[f.orient]=new rS(f,s.scaleResolution.type,this.layoutParent.context,this.layoutParent,l)}},o=(s,u,l)=>{const f=i(s,u);f&&(f.grid||f.chromGrid)&&(r[f.orient]=new H9(f,s.scaleResolution.type,this.layoutParent.context,this.layoutParent,l))};for(const s of["x","y"])if(e.needsAxes[s]){const u=e.resolutions.axis[s];if(!u)continue;a(u,s,e)}for(const s of["x","y"])if(e.needsAxes[s]){const u=e.getAxisResolution(s);if(!u)continue;o(u,s,e)}if(e instanceof au){for(const s of e.children)for(const[u,l]of Object.entries(s.resolutions.axis)){const f=l.getAxisProps();f&&f.orient&&a(l,u,s)}for(const s of e.children)for(const[u,l]of Object.entries(s.resolutions.axis)){const f=l.getAxisProps();f&&!f.orient&&a(l,u,s)}}[...Object.values(n),...Object.values(r)].forEach(s=>s.visit(u=>{u instanceof Ct&&u.resolve("scale")}))}getOverhang(){const e=n=>{const r=this.axes[n];return r?Math.max(r.getPerpendicularSize()+r.axisProps.offset,0):0};return new yt(e("top"),e("right"),e("bottom"),e("left")).add(this.view.getOverhang())}getOverhangAndPadding(){return this.getOverhang().add(this.view.getPadding())}}class kd extends sS{constructor(e,n,r,i,a){super(e,n,r,i,a,tp(e)?e.columns:Ku(e)?1:1/0),this.spec=e}_createChildren(){const e=this.spec,n=tp(e)?e.concat:Ku(e)?e.vconcat:e.hconcat;this.setChildren(n.map((r,i)=>this.context.createView(r,this,this,"grid"+i)))}getDefaultResolution(e,n){if(n=="axis")return"independent";if(Ku(this.spec)&&e==="x"||pS(this.spec)&&e==="y"){const r=new Set(this.children.map(i=>i.getEncoding()[e]).filter(i=>i).map(i=>"type"in i&&i.type).filter(i=>i));return r.size===1&&(r.has("index")||r.has("locus"))?"shared":"independent"}else return"independent"}}class oz{constructor(){this.types=[];const e=n=>(r,i,a,o,s)=>new n(r,i,a,o,r.name??s);this.addViewType(sz,e(Yv)),this.addViewType(dS,e(au)),this.addViewType(hS,e(Ct)),this.addViewType(Ku,e(kd)),this.addViewType(pS,e(kd)),this.addViewType(tp,e(kd))}addViewType(e,n){this.types.push({specGuard:e,factory:n})}createView(e,n,r,i,a){const o=this.types.find(s=>s.specGuard(e));if(o)return o.factory(e,n,r,i,a??"unnamed");throw new Error("Invalid spec, cannot figure out the view type from the properties: "+JSON.stringify([...Object.keys(e)]))}isViewSpec(e){const n=this.types.filter(r=>r.specGuard(e));if(n.length>1)throw new Error("Ambiguous spec. Cannot create a view!");return n.length==1}}function hS(t){return"mark"in t&&(We(t.mark)||Bn(t.mark))}function dS(t){return"layer"in t&&Bn(t.layer)}function sz(t){return"import"in t}function Ku(t){return"vconcat"in t&&en(t.vconcat)}function pS(t){return"hconcat"in t&&en(t.hconcat)}function tp(t){return"concat"in t&&en(t.concat)}class lz extends sS{constructor(e,n){super({vconcat:[]},e,void 0,void 0,"implicitRoot",1),n.layoutParent=this,n.dataParent=this,this.appendChild(n)}}lx("fasta",I9);class uz{constructor(e,n,r={}){this.container=e;const i=document.createElement("style");i.innerHTML=H6,e.appendChild(i),this.spec=n,this.accessorFactory=new D4,this.viewFactory=new oz,this.namedDataProviders=[],this.animator=new v9(()=>this.renderAll()),this.genomeStore=void 0,this.viewVisibilityPredicate=a=>a.isVisibleInSpec(),this._renderingContext=void 0,this._pickingContext=void 0,this._dirtyPickingBuffer=!1,this._currentHover=void 0,this._wheelInertia=new k9(this.animator),this._keyboardListeners=new Map,this._eventListeners=new Map,this._extraBroadcastListeners=new Map,this.tooltipHandlers={default:M9,refseqgene:D9,...r.tooltipHandlers??{}},this.viewRoot=void 0}registerNamedDataProvider(e){this.namedDataProviders.unshift(e)}getNamedDataFromProvider(e){for(const n of this.namedDataProviders){const r=n(e);if(r)return r}}updateNamedData(e,n){const r=this.viewRoot.context.dataFlow.findNamedDataSource(e);if(!r)throw new Error("No such named data source: "+e);r.dataSource.updateDynamicData(n),v0(r.hosts),this.animator.requestRender()}broadcast(e,n){var i;const r={type:e,payload:n};this.viewRoot.visit(a=>a.handleBroadcast(r)),(i=this._extraBroadcastListeners.get(e))==null||i.forEach(a=>a(r))}_prepareContainer(){this.container.classList.add("genome-spy"),this.container.classList.add("loading"),this._glHelper=new XR(this.container,()=>this.viewRoot?m9(this.viewRoot):{width:void 0,height:void 0},this.spec.background),this.loadingMessageElement=document.createElement("div"),this.loadingMessageElement.className="loading-message",this.loadingMessageElement.innerHTML='<div class="message">Loading<span class="ellipsis">...</span></div>',this.container.appendChild(this.loadingMessageElement),this.tooltip=new j6(this.container),this.loadingMessageElement.querySelector(".message").addEventListener("transitionend",()=>{this.loadingMessageElement.style.display="none"})}destroy(){this.container.classList.remove("genome-spy"),this.container.classList.remove("loading");for(const[e,n]of this._keyboardListeners)for(const r of n)document.removeEventListener(e,r);for(this._glHelper.finalize();this.container.firstChild;)this.container.firstChild.remove()}async _prepareViewsAndData(){this.spec.genome&&(this.genomeStore=new E9(this.spec.baseUrl),await this.genomeStore.initialize(this.spec.genome));const e=this,n={dataFlow:new KA,accessorFactory:this.accessorFactory,glHelper:this._glHelper,animator:this.animator,genomeStore:this.genomeStore,fontManager:new C9(this._glHelper),get devicePixelRatio(){return e._glHelper.dpr},requestLayoutReflow:()=>{},updateTooltip:this.updateTooltip.bind(this),getNamedDataFromProvider:this.getNamedDataFromProvider.bind(this),getCurrentHover:()=>this._currentHover,addKeyboardListener:(s,u)=>{document.addEventListener(s,u);let l=this._keyboardListeners.get(s);l||(l=[],this._keyboardListeners.set(s,l)),l.push(u)},addBroadcastListener(s,u){const l=e._extraBroadcastListeners;let f=l.get(s);f||(f=new Set,l.set(s,f)),f.add(u)},removeBroadcastListener(s,u){var f;(f=e._extraBroadcastListeners.get(s))==null||f.delete(u)},isViewConfiguredVisible:e.viewVisibilityPredicate,isViewSpec:s=>e.viewFactory.isViewSpec(s),createView:function(s,u,l,f){return e.viewFactory.createView(s,n,u,l,f)}},r=this.spec;r.datasets&&this.registerNamedDataProvider(s=>r.datasets[s]),this.viewRoot=n.createView(r,null,null,"viewRoot"),await eS(this.viewRoot),(this.viewRoot.needsAxes.x||this.viewRoot.needsAxes.y)&&(this.viewRoot=new lz(n,this.viewRoot)),d9(this.viewRoot),p9(this.viewRoot),this._glHelper.invalidateSize();const i=[];this.viewRoot.visit(s=>{s instanceof Ct&&i.push(s)});const a=s9(this.viewRoot,n.dataFlow);h9(a),this.broadcast("dataFlowBuilt",a),i.forEach(s=>s.mark.initializeEncoders());const o=Promise.all(i.map(s=>s.mark.initializeGraphics()));for(const s of i)a.addObserver(u=>{s.mark.initializeData(),s.mark.updateGraphicsData()},s);await n.fontManager.waitUntilReady(),a.initialize(),await Promise.all(a.dataSources.map(s=>s.load())),v0(this.viewRoot),this.broadcast("dataLoaded"),await o,this.viewRoot.visit(s=>{for(const u of Object.values(s.resolutions.scale))this._glHelper.createRangeTexture(u)});for(const s of i)s.mark.finalizeGraphicsInitialization();n.requestLayoutReflow=this.computeLayout.bind(this),this.viewRoot.visit(s=>Pu(s,"size")),this._glHelper.invalidateSize()}async launch(){try{return this._prepareContainer(),await this._prepareViewsAndData(),this.registerMouseEvents(),this.computeLayout(),this.animator.requestRender(),this._glHelper.addEventListener("resize",()=>{this.computeLayout(),this.renderAll()}),!0}catch(e){const n=`${e.view?`At "${e.view.getPathString()}": `:""}${e.toString()}`;return console.error(e.stack),fz(this.container,n),!1}finally{this.container.classList.remove("loading"),window.setTimeout(()=>{this.loadingMessageElement.style.display="none"},2e3)}}registerMouseEvents(){const e=this._glHelper.canvas,n=r=>{var i;if(r instanceof MouseEvent){r.type=="mousemove"&&(this.tooltip.handleMouseMove(r),this._tooltipUpdateRequested=!1,r.buttons==0&&this.renderPickingFramebuffer());const a=e.getBoundingClientRect(),o=new w9(r.clientX-a.left-e.clientLeft,r.clientY-a.top-e.clientTop),s=u=>{this.viewRoot.propagateInteractionEvent(new y9(o,u)),this._tooltipUpdateRequested||this.tooltip.clear()};if(r.type!="wheel"&&this._wheelInertia.cancel(),r.type=="mousemove")this._handlePicking(o.x,o.y);else if(r.type=="mousedown"||r.type=="mouseup")this.renderPickingFramebuffer();else if(r.type=="wheel"){this._tooltipUpdateRequested=!1;const u=r;if(Math.abs(u.deltaX)>Math.abs(u.deltaY))this._currentHover=null,this._wheelInertia.cancel();else{const l=R9(u);this._wheelInertia.setMomentum(u.deltaY*(u.deltaMode?80:1),f=>{const c=new WheelEvent("wheel",{...l,deltaMode:0,deltaX:0,deltaY:f});s(c)}),u.preventDefault();return}}if(r.type=="click"){const u=this._currentHover?{type:r.type,viewPath:this._currentHover.mark.unitView.getLayoutAncestors().map(l=>l.name).reverse(),datum:this._currentHover.datum}:{type:r.type,viewPath:null,datum:null};(i=this._eventListeners.get("click"))==null||i.forEach(l=>l(u))}s(r)}};["mousedown","mouseup","wheel","click","mousemove","gesturechange","contextmenu"].forEach(r=>e.addEventListener(r,n)),e.addEventListener("mousedown",()=>{document.addEventListener("mouseup",()=>this.tooltip.popEnabledState(),{once:!0}),this.tooltip.pushEnabledState(!1)}),e.addEventListener("dragstart",r=>r.stopPropagation())}_handlePicking(e,n){var a;const r=this._glHelper.readPickingPixel(e,n),i=r[0]|r[1]<<8|r[2]<<16;if(i==0){this._currentHover=null;return}if(i!==((a=this._currentHover)==null?void 0:a.uniqueId)&&(this._currentHover=null),this._currentHover||this.viewRoot.visit(o=>{if(o instanceof Ct){if(o.mark.isPickingParticipant()){const s=o.mark.encoders.uniqueId.accessor;o.getCollector().visitData(u=>{s(u)==i&&(this._currentHover={mark:o.mark,datum:u,uniqueId:i})})}if(this._currentHover)return bs}}),this._currentHover){const o=this._currentHover.mark;this.updateTooltip(this._currentHover.datum,async s=>{if(!o.isPickingParticipant())return;const u=o.properties.tooltip;if(u!==null){const l=(u==null?void 0:u.handler)??"default",f=this.tooltipHandlers[l];if(!f)throw new Error("No such tooltip handler: "+l);return f(s,o,u==null?void 0:u.params)}})}}updateTooltip(e,n){if(!this._tooltipUpdateRequested||!e)this.tooltip.updateWithDatum(e,n),this._tooltipUpdateRequested=!0;else throw new Error("Tooltip has already been updated! Duplicate event handler?")}computeLayout(){const e=this.viewRoot;if(!e)return;this.broadcast("layout");const n=this._glHelper.getLogicalCanvasSize();if(isNaN(n.width)||isNaN(n.height)){console.log(`NaN in canvas size: ${n.width}x${n.height}. Skipping computeLayout().`);return}this._renderingContext=new gw({picking:!1},this._glHelper),this._pickingContext=new gw({picking:!0},this._glHelper),e.render(new b9(this._renderingContext,this._pickingContext),pl.create(0,0,n.width,n.height)),this.broadcast("layoutComputed")}renderAll(){var e;(e=this._renderingContext)==null||e.render(),this._dirtyPickingBuffer=!0}renderPickingFramebuffer(){this._dirtyPickingBuffer&&(this._pickingContext.render(),this._dirtyPickingBuffer=!1)}getSearchableViews(){const e=[];return this.viewRoot.visit(n=>{n instanceof Ct&&n.getAccessor("search")&&e.push(n)}),e}getNamedScaleResolutions(){const e=new Map;return this.viewRoot.visit(n=>{for(const r of Object.values(n.resolutions.scale))r.name&&e.set(r.name,r)}),e}}function fz(t,e){const n=document.createElement("div");n.className="message-box";const r=document.createElement("div");r.textContent=e,n.appendChild(r),t.appendChild(n)}async function cz(t,e,n={}){let r;if(We(t)){if(r=document.querySelector(t),!r)throw new Error(`No such element: ${t}`)}else if(t instanceof HTMLElement)r=t;else throw new Error(`Invalid element: ${t}`);let i;try{const a=Bn(e)?e:await dz(e);if(a.baseUrl??(a.baseUrl=""),a.width??(a.width="container"),a.padding??(a.padding=10),r==document.body){const o=document.createElement("div");o.style.position="fixed",o.style.inset="0",o.style.overflow="hidden",r.appendChild(o),r=o}i=new uz(r,a,n),hz(i,n),await i.launch()}catch(a){r.innerText=a.toString(),console.error(a)}return{finalize(){for(i.destroy();r.firstChild;)r.firstChild.remove()},addEventListener(a,o){const s=i._eventListeners;let u=s.get(a);u||(u=new Set,s.set(a,u)),u.add(o)},removeEventListener(a,o){var u;(u=i._eventListeners.get(a))==null||u.delete(o)},getScaleResolutionByName(a){return i.getNamedScaleResolutions().get(a)},updateNamedData:i.updateNamedData.bind(i)}}function hz(t,e){e.namedDataProvider&&t.registerNamedDataProvider(e.namedDataProvider)}async function dz(t){let e;try{e=JSON.parse(await fc().load(t))}catch(n){throw new Error(`Could not load or parse configuration: ${t}, reason: ${n.message}`)}if(!e.baseUrl){const n=t.match(/^[^?#]*\//);e.baseUrl=n&&n[0]||"./"}return e}function*pz(t){const r=t.length;let i=0,a=i;for(;i<r;){const o=t.charCodeAt(i++);let s;if(o===10?s=t.substring(a,i-1):o===13?(s=t.substring(a,i-1),t.charCodeAt(i+1)===10&&i++):i===r&&(s=t.substring(a,i-1)),s!==void 0&&(yield s,s=void 0,a=i,i>=r))return s}}function gz(t){return new Promise((e,n)=>{let r=new FileReader;r.onload=()=>e(r.result),r.onerror=n,r.readAsText(t)})}function vw(){return new Promise((t,e)=>window.requestAnimationFrame(()=>window.requestAnimationFrame(t)))}async function gS(t){return{name:t.name,size:t.size,textContent:await gz(t)}}async function mz(t){const n=await(await fetch(t)).text();return{name:t.match(/[^/]*$/)[0],size:n.length,textContent:n}}const xt={HETS:{name:"HETS",title:"Allelic counts",example:"tumor.hets.tsv",column:"REF_COUNT"},CR:{name:"CR",title:"Denoised copy ratios",example:"tumor.denoisedCR.tsv",column:"LOG2_COPY_RATIO"},SEG:{name:"SEG",title:"Modeled segments",example:"tumor.modelFinal.seg",column:"LOG2_COPY_RATIO_POSTERIOR_50"},DICT:{name:"DICT",title:"Sequence dictionary",example:"GRCh38.d1.vd1.fa.dict",column:void 0}};function bz(t){const e=yz(t);if(typeof e=="string"&&e!==""){const n=e.split(" ");for(const r of Object.values(xt))if(r.column&&n.includes(r.column))return r}else if(t[0]==="@")return xt.DICT}function yz(t,e="@"){for(const n of pz(t))if(typeof e=="string"&&n[0]!==e)return n}const Rd=t=>t!==""?+t:null,wz={[xt.HETS.name]:t=>{const e=+t.ALT_COUNT,n=+t.REF_COUNT;return{contig:t.CONTIG,pos:+t.POSITION,baf:e/(n+e)}},[xt.CR.name]:t=>{const e=+t.START,n=+t.END;return{contig:t.CONTIG,start:e,end:n,pos:(e-1+n)/2,logR:Rd(t.LOG2_COPY_RATIO)}},[xt.SEG.name]:t=>({contig:t.CONTIG,start:+t.START,end:+t.END,NUM_POINTS_COPY_RATIO:+t.NUM_POINTS_COPY_RATIO,NUM_POINTS_ALLELE_FRACTION:+t.NUM_POINTS_ALLELE_FRACTION,LOG2_COPY_RATIO_POSTERIOR_10:+t.LOG2_COPY_RATIO_POSTERIOR_10,LOG2_COPY_RATIO_POSTERIOR_50:Rd(t.LOG2_COPY_RATIO_POSTERIOR_50),LOG2_COPY_RATIO_POSTERIOR_90:+t.LOG2_COPY_RATIO_POSTERIOR_90,MINOR_ALLELE_FRACTION_POSTERIOR_10:+t.MINOR_ALLELE_FRACTION_POSTERIOR_10,MINOR_ALLELE_FRACTION_POSTERIOR_50:Rd(t.MINOR_ALLELE_FRACTION_POSTERIOR_50),MINOR_ALLELE_FRACTION_POSTERIOR_90:+t.MINOR_ALLELE_FRACTION_POSTERIOR_90})},xz=t=>({name:"ideogram-track",height:24,data:{url:`https://genomespy.app/data/genomes/${t}/cytoBand.${t}.tsv`},transform:[{type:"filter",expr:"!test(/_/, datum.chrom)"}],encoding:{x:{chrom:"chrom",pos:"chromStart",type:"locus",axis:null},x2:{chrom:"chrom",pos:"chromEnd"}},resolve:{scale:{color:"independent"}},layer:[{title:"Cytoband",mark:"rect",encoding:{color:{field:"gieStain",type:"nominal",scale:{domain:["gneg","gpos25","gpos50","gpos75","gpos100","acen","stalk","gvar"],range:["#f0f0f0","#e0e0e0","#d0d0d0","#c0c0c0","#a0a0a0","#cc4444","#338833","#000000"]}},squeeze:{expr:"datum.gieStain == 'acen' ? (test(/^p/, datum.name) ? 'p' : 'q') : null",type:"nominal",scale:{domain:["p","q"],range:["right","left"]}}}},{mark:{type:"text",align:"center",baseline:"middle",paddingX:4,tooltip:null},encoding:{color:{field:"gieStain",type:"nominal",scale:{domain:["gneg","gpos25","gpos50","gpos75","gpos100","acen","stalk","gvar"],range:["black","black","black","black","black","black","white","white"]}},text:{field:"name",type:"nominal"}}},{transform:[{type:"filter",expr:"datum.chromStart == 0 && datum.chrom != 'chr1'"}],encoding:{x2:null},mark:{type:"rule",color:"#a0a0a0",strokeDash:[3,3],strokeDashOffset:2}}]}),_z=t=>({description:"Windowed GC content computed from the reference genome. Extracted with GATK AnnotateIntervals",height:50,view:{fill:Hi.BACKGROUD,stroke:"gray"},data:{url:`https://genomespy.app/tracks/gc-content/gc-intervals.${t}.tsv`},mark:{type:"rect",minWidth:.5,minOpacity:1},encoding:{x:{chrom:"CONTIG",pos:"START",offset:-1,type:"locus"},x2:{chrom:"CONTIG",pos:"END"},y:{field:"GC_CONTENT",type:"quantitative",scale:{domain:[.3,.7]},title:"GC cont.",axis:{maxExtent:40}}}}),vz=t=>({name:"refseq-track",height:{step:23},data:{url:`https://genomespy.app/data/genomes/${t}/refSeq_genes_scored_compressed.${t}.tsv`,format:{parse:{symbol:"string",chrom:"string",start:"integer",length:"integer",strand:"string",score:"integer",exons:"string"}}},transform:[{type:"linearizeGenomicCoordinate",chrom:"chrom",pos:"start",as:"_start"},{type:"formula",expr:"datum._start + datum.length",as:"_end"},{type:"formula",expr:"datum._start + datum.length / 2",as:"_centroid"},{type:"collect",sort:{field:["_start"]}},{type:"pileup",start:"_start",end:"_end",as:"_lane",preference:"strand",preferredOrder:["-","+"]},{type:"filter",expr:"datum._lane < 3"}],encoding:{y:{field:"_lane",type:"ordinal",scale:{type:"index",align:0,paddingInner:.4,paddingOuter:.2,domain:[0,3],reverse:!0,zoom:!1},axis:null}},layer:[{name:"transcripts",opacity:{unitsPerPixel:[1e5,4e4],values:[0,1]},encoding:{color:{value:"#909090"}},layer:[{name:"exons",transform:[{type:"project",fields:["_lane","_start","exons"]},{type:"flattenCompressedExons",start:"_start"}],mark:{type:"rect",minOpacity:.2,minWidth:.5,tooltip:null},encoding:{x:{field:"exonStart",type:"locus"},x2:{field:"exonEnd"}}},{name:"bodies",title:"Gene annotations",mark:{type:"rule",minLength:.5,size:1,tooltip:null},encoding:{x:{field:"_start",type:"locus",axis:null},x2:{field:"_end"},search:{field:"symbol"}}}]},{name:"symbols",transform:[{type:"measureText",fontSize:11,field:"symbol",as:"_textWidth"},{type:"filterScoredLabels",lane:"_lane",score:"score",width:"_textWidth",pos:"_centroid",padding:5}],layer:[{name:"labels",mark:{type:"text",size:11,yOffset:7,tooltip:{handler:"refseqgene"}},encoding:{x:{field:"_centroid",type:"locus"},text:{field:"symbol"}}},{name:"arrows",opacity:{unitsPerPixel:[1e5,4e4],values:[0,1]},mark:{type:"point",yOffset:7,size:50,tooltip:null},encoding:{x:{field:"_centroid",type:"locus"},dx:{expr:"(datum._textWidth / 2 + 5) * (datum.strand == '-' ? -1 : 1)",type:"quantitative",scale:null},color:{value:"black"},shape:{field:"strand",type:"nominal",scale:{domain:["-","+"],range:["triangle-left","triangle-right"]}}}}]}]}),Hi={INTERVAL:"#f70",RULE:"black",POINT:"#49A0F2",BACKGROUD:"#f8f8f8"};function Dd(t,{lower:e,upper:n}){const r=[];return e&&n&&r.push({mark:{type:"rect",minWidth:2,minOpacity:1},encoding:{y:{field:e,type:"quantitative",title:null},y2:{field:n},color:{value:Hi.INTERVAL},opacity:{value:.3}}}),r.push({mark:{type:"rule",size:3,minLength:3},encoding:{y:{field:t,type:"quantitative",title:null},color:{value:Hi.RULE}}}),r}function Ew(t){return Math.max(0,Math.log((t-1e3)/4)/Math.log(3))||0}function Ez(t,e){const n=u=>{const l=t.get(u),f=l?l.data:[];if(/^hg\d+/.test(e)){let c;const h=d=>{const p=d.contig;return p===c?!0:/^(chr)?(\d{1,2}|[XY])$/.test(p)?(c=p,!0):(c="",!1)};return f.filter(h)}return f},r=e?{name:e}:{contigs:t.get(xt.DICT).data},[i,a,o]=[xt.SEG,xt.CR,xt.HETS].map(n),s=(u,l)=>u?[l(u)]:[];return{genome:r,data:{values:i},resolve:{scale:{x:"shared"},axis:{x:"independent"}},vconcat:[...s(e,xz),{resolve:{scale:{x:"shared"},axis:{x:"shared"}},encoding:{x:{chrom:"contig",pos:"start",type:"locus",offset:-1,axis:{title:null}},x2:{chrom:"contig",pos:"end"}},vconcat:[...s(e,_z),{name:"logRTrack",view:{fill:Hi.BACKGROUD,stroke:"gray"},layer:[{data:{values:a},transform:[{type:"filter",expr:"!isNaN(datum.logR) && datum.logR > -3"}],mark:{type:"point",tooltip:null,geometricZoomBound:Ew(a.length)},encoding:{x:{chrom:"contig",pos:"pos",type:"locus",axis:{grid:!0,gridDash:[1,5],chromGrid:!0}},y:{field:"logR",type:"quantitative",title:"Log2 copy ratio",scale:{},axis:{maxExtent:40}},color:{value:Hi.POINT},size:{value:150},opacity:{value:.25},strokeWidth:{value:0}}},{transform:[{type:"filter",expr:"datum.LOG2_COPY_RATIO_POSTERIOR_50 > -3"}],layer:Dd("LOG2_COPY_RATIO_POSTERIOR_50",{lower:"LOG2_COPY_RATIO_POSTERIOR_10",upper:"LOG2_COPY_RATIO_POSTERIOR_90"})}]},{name:"bafTrack",view:{fill:Hi.BACKGROUD,stroke:"gray"},layer:[{data:{values:o},mark:{type:"point",tooltip:null,geometricZoomBound:Ew(o.length)},encoding:{x:{chrom:"contig",pos:"pos",offset:-.5,type:"locus",axis:{grid:!0,gridDash:[1,5],chromGrid:!0}},y:{field:"baf",type:"quantitative",title:"Minor allele fraction",scale:{domain:[0,1]},axis:{maxExtent:40}},color:{value:Hi.POINT},size:{value:150},opacity:{value:.3},strokeWidth:{value:0}}},{layer:[{layer:Dd("MINOR_ALLELE_FRACTION_POSTERIOR_50",{lower:"MINOR_ALLELE_FRACTION_POSTERIOR_10",upper:"MINOR_ALLELE_FRACTION_POSTERIOR_90"})},{transform:[10,50,90].map(u=>`MINOR_ALLELE_FRACTION_POSTERIOR_${u}`).map(u=>({type:"formula",expr:`1 - datum.${u}`,as:u})),layer:Dd("MINOR_ALLELE_FRACTION_POSTERIOR_50",{lower:"MINOR_ALLELE_FRACTION_POSTERIOR_10",upper:"MINOR_ALLELE_FRACTION_POSTERIOR_90"})}]}]}]},...s(e,vz)]}}const Az="data:image/gif;base64,R0lGODlhIAAgAPMAAP///wAAAMbGxoSEhLa2tpqamjY2NlZWVtjY2OTk5Ly8vB4eHgQEBAAAAAAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh/hpDcmVhdGVkIHdpdGggYWpheGxvYWQuaW5mbwAh+QQJCgAAACwAAAAAIAAgAAAE5xDISWlhperN52JLhSSdRgwVo1ICQZRUsiwHpTJT4iowNS8vyW2icCF6k8HMMBkCEDskxTBDAZwuAkkqIfxIQyhBQBFvAQSDITM5VDW6XNE4KagNh6Bgwe60smQUB3d4Rz1ZBApnFASDd0hihh12BkE9kjAJVlycXIg7CQIFA6SlnJ87paqbSKiKoqusnbMdmDC2tXQlkUhziYtyWTxIfy6BE8WJt5YJvpJivxNaGmLHT0VnOgSYf0dZXS7APdpB309RnHOG5gDqXGLDaC457D1zZ/V/nmOM82XiHRLYKhKP1oZmADdEAAAh+QQJCgAAACwAAAAAIAAgAAAE6hDISWlZpOrNp1lGNRSdRpDUolIGw5RUYhhHukqFu8DsrEyqnWThGvAmhVlteBvojpTDDBUEIFwMFBRAmBkSgOrBFZogCASwBDEY/CZSg7GSE0gSCjQBMVG023xWBhklAnoEdhQEfyNqMIcKjhRsjEdnezB+A4k8gTwJhFuiW4dokXiloUepBAp5qaKpp6+Ho7aWW54wl7obvEe0kRuoplCGepwSx2jJvqHEmGt6whJpGpfJCHmOoNHKaHx61WiSR92E4lbFoq+B6QDtuetcaBPnW6+O7wDHpIiK9SaVK5GgV543tzjgGcghAgAh+QQJCgAAACwAAAAAIAAgAAAE7hDISSkxpOrN5zFHNWRdhSiVoVLHspRUMoyUakyEe8PTPCATW9A14E0UvuAKMNAZKYUZCiBMuBakSQKG8G2FzUWox2AUtAQFcBKlVQoLgQReZhQlCIJesQXI5B0CBnUMOxMCenoCfTCEWBsJColTMANldx15BGs8B5wlCZ9Po6OJkwmRpnqkqnuSrayqfKmqpLajoiW5HJq7FL1Gr2mMMcKUMIiJgIemy7xZtJsTmsM4xHiKv5KMCXqfyUCJEonXPN2rAOIAmsfB3uPoAK++G+w48edZPK+M6hLJpQg484enXIdQFSS1u6UhksENEQAAIfkECQoAAAAsAAAAACAAIAAABOcQyEmpGKLqzWcZRVUQnZYg1aBSh2GUVEIQ2aQOE+G+cD4ntpWkZQj1JIiZIogDFFyHI0UxQwFugMSOFIPJftfVAEoZLBbcLEFhlQiqGp1Vd140AUklUN3eCA51C1EWMzMCezCBBmkxVIVHBWd3HHl9JQOIJSdSnJ0TDKChCwUJjoWMPaGqDKannasMo6WnM562R5YluZRwur0wpgqZE7NKUm+FNRPIhjBJxKZteWuIBMN4zRMIVIhffcgojwCF117i4nlLnY5ztRLsnOk+aV+oJY7V7m76PdkS4trKcdg0Zc0tTcKkRAAAIfkECQoAAAAsAAAAACAAIAAABO4QyEkpKqjqzScpRaVkXZWQEximw1BSCUEIlDohrft6cpKCk5xid5MNJTaAIkekKGQkWyKHkvhKsR7ARmitkAYDYRIbUQRQjWBwJRzChi9CRlBcY1UN4g0/VNB0AlcvcAYHRyZPdEQFYV8ccwR5HWxEJ02YmRMLnJ1xCYp0Y5idpQuhopmmC2KgojKasUQDk5BNAwwMOh2RtRq5uQuPZKGIJQIGwAwGf6I0JXMpC8C7kXWDBINFMxS4DKMAWVWAGYsAdNqW5uaRxkSKJOZKaU3tPOBZ4DuK2LATgJhkPJMgTwKCdFjyPHEnKxFCDhEAACH5BAkKAAAALAAAAAAgACAAAATzEMhJaVKp6s2nIkolIJ2WkBShpkVRWqqQrhLSEu9MZJKK9y1ZrqYK9WiClmvoUaF8gIQSNeF1Er4MNFn4SRSDARWroAIETg1iVwuHjYB1kYc1mwruwXKC9gmsJXliGxc+XiUCby9ydh1sOSdMkpMTBpaXBzsfhoc5l58Gm5yToAaZhaOUqjkDgCWNHAULCwOLaTmzswadEqggQwgHuQsHIoZCHQMMQgQGubVEcxOPFAcMDAYUA85eWARmfSRQCdcMe0zeP1AAygwLlJtPNAAL19DARdPzBOWSm1brJBi45soRAWQAAkrQIykShQ9wVhHCwCQCACH5BAkKAAAALAAAAAAgACAAAATrEMhJaVKp6s2nIkqFZF2VIBWhUsJaTokqUCoBq+E71SRQeyqUToLA7VxF0JDyIQh/MVVPMt1ECZlfcjZJ9mIKoaTl1MRIl5o4CUKXOwmyrCInCKqcWtvadL2SYhyASyNDJ0uIiRMDjI0Fd30/iI2UA5GSS5UDj2l6NoqgOgN4gksEBgYFf0FDqKgHnyZ9OX8HrgYHdHpcHQULXAS2qKpENRg7eAMLC7kTBaixUYFkKAzWAAnLC7FLVxLWDBLKCwaKTULgEwbLA4hJtOkSBNqITT3xEgfLpBtzE/jiuL04RGEBgwWhShRgQExHBAAh+QQJCgAAACwAAAAAIAAgAAAE7xDISWlSqerNpyJKhWRdlSAVoVLCWk6JKlAqAavhO9UkUHsqlE6CwO1cRdCQ8iEIfzFVTzLdRAmZX3I2SfZiCqGk5dTESJeaOAlClzsJsqwiJwiqnFrb2nS9kmIcgEsjQydLiIlHehhpejaIjzh9eomSjZR+ipslWIRLAgMDOR2DOqKogTB9pCUJBagDBXR6XB0EBkIIsaRsGGMMAxoDBgYHTKJiUYEGDAzHC9EACcUGkIgFzgwZ0QsSBcXHiQvOwgDdEwfFs0sDzt4S6BK4xYjkDOzn0unFeBzOBijIm1Dgmg5YFQwsCMjp1oJ8LyIAACH5BAkKAAAALAAAAAAgACAAAATwEMhJaVKp6s2nIkqFZF2VIBWhUsJaTokqUCoBq+E71SRQeyqUToLA7VxF0JDyIQh/MVVPMt1ECZlfcjZJ9mIKoaTl1MRIl5o4CUKXOwmyrCInCKqcWtvadL2SYhyASyNDJ0uIiUd6GGl6NoiPOH16iZKNlH6KmyWFOggHhEEvAwwMA0N9GBsEC6amhnVcEwavDAazGwIDaH1ipaYLBUTCGgQDA8NdHz0FpqgTBwsLqAbWAAnIA4FWKdMLGdYGEgraigbT0OITBcg5QwPT4xLrROZL6AuQAPUS7bxLpoWidY0JtxLHKhwwMJBTHgPKdEQAACH5BAkKAAAALAAAAAAgACAAAATrEMhJaVKp6s2nIkqFZF2VIBWhUsJaTokqUCoBq+E71SRQeyqUToLA7VxF0JDyIQh/MVVPMt1ECZlfcjZJ9mIKoaTl1MRIl5o4CUKXOwmyrCInCKqcWtvadL2SYhyASyNDJ0uIiUd6GAULDJCRiXo1CpGXDJOUjY+Yip9DhToJA4RBLwMLCwVDfRgbBAaqqoZ1XBMHswsHtxtFaH1iqaoGNgAIxRpbFAgfPQSqpbgGBqUD1wBXeCYp1AYZ19JJOYgH1KwA4UBvQwXUBxPqVD9L3sbp2BNk2xvvFPJd+MFCN6HAAIKgNggY0KtEBAAh+QQJCgAAACwAAAAAIAAgAAAE6BDISWlSqerNpyJKhWRdlSAVoVLCWk6JKlAqAavhO9UkUHsqlE6CwO1cRdCQ8iEIfzFVTzLdRAmZX3I2SfYIDMaAFdTESJeaEDAIMxYFqrOUaNW4E4ObYcCXaiBVEgULe0NJaxxtYksjh2NLkZISgDgJhHthkpU4mW6blRiYmZOlh4JWkDqILwUGBnE6TYEbCgevr0N1gH4At7gHiRpFaLNrrq8HNgAJA70AWxQIH1+vsYMDAzZQPC9VCNkDWUhGkuE5PxJNwiUK4UfLzOlD4WvzAHaoG9nxPi5d+jYUqfAhhykOFwJWiAAAIfkECQoAAAAsAAAAACAAIAAABPAQyElpUqnqzaciSoVkXVUMFaFSwlpOCcMYlErAavhOMnNLNo8KsZsMZItJEIDIFSkLGQoQTNhIsFehRww2CQLKF0tYGKYSg+ygsZIuNqJksKgbfgIGepNo2cIUB3V1B3IvNiBYNQaDSTtfhhx0CwVPI0UJe0+bm4g5VgcGoqOcnjmjqDSdnhgEoamcsZuXO1aWQy8KAwOAuTYYGwi7w5h+Kr0SJ8MFihpNbx+4Erq7BYBuzsdiH1jCAzoSfl0rVirNbRXlBBlLX+BP0XJLAPGzTkAuAOqb0WT5AH7OcdCm5B8TgRwSRKIHQtaLCwg1RAAAOwAAAAAAAAAAAA==";const mS=["hg38","hg19"],Io=new Map;let Ji=mS[0],Ts,Uf=!1,qf=!1,Fs=!1;Nr();function Sz(){const t=r=>{const i=Io.get(r);return ot`<tr><td>${r.title}</td>${i?ot`<td class="status okay"><span class="icon">✔</span></td><td>${i.name}</td><td>${i.data?`${i.data.length} records`:"Parsing..."}</td>`:ot`<td class="status"><span class="icon">✗</span></td><td>Missing. <span class="example-file">Example: ${r.example}</span></td><td></td>`}</tr>`},e=()=>ot`<div class="btn-group" role="group">${mS.map(r=>ot`<button type="button" @click="${()=>Aw(r)}" class="btn btn-secondary ${Ji===r?"active":""}">${r}</button>`)} <button type="button" @click="${()=>Aw(void 0)}" class="btn btn-secondary ${Ji?"":"active"}">.dict file</button></div>`;return ot`${(()=>ot`<div @dragenter="${Bd}" @dragover="${Bd}" @dragleave="${Bd}" @drop="${Tz}" class="${mm({"drop-zone":!0,dragging:Uf,"active-panel":!qf})}"><div class="file-box"><h2>1. Choose a genome assembly or a sequence dictionary</h2><p>Choosing a genome assembly instead of a sequence dictionary activates cytoband, GC content, and RefSeq gene tracks.</p>${e()}<h2>2. Select files</h2><p>Please provide at least one of the following files to start visualizing. File types are detected from the TSV header row.</p><p>N.B. All data processing takes place in your web browser. Nothing is uploaded anywhere.</p><table class="file-table">${Object.values(xt).filter(r=>r!==xt.DICT||!Ji).map(t)}</table><input type="file" multiple="multiple" accept=".tsv,.seg" id="fileInput" @change="${Fz}" style="display:none"><div class="upload-button-wrapper"><button class="btn" style="margin-right:1em" @click="${r=>{document.getElementById("fileInput").click(),r.preventDefault(),r.stopPropagation()}}">Choose files</button> or drag and drop here.</div><h3>No files to play with?</h3><p>Try the example data sets:</p><div class="example-data-buttons"><button class="btn" ?disabled="${Fs}" @click="${()=>Sw("sample-subset")}">Load small data set</button> <button class="btn" ?disabled="${Fs}" @click="${()=>Sw("sample")}">Load full data set</button> ${Fs?ot`<span class="loading"><img src="${Az}" alt="" width="16" height="16"> <span>Loading...</span></span>`:""}</div><h2>3. Explore the data</h2>Zoom with the mouse wheel or touchpad, pan by dragging or with the touchpad. Hover an item to get details.<div class="buttons"><button ?disabled="${!bS()}" @click="${yS}" class="btn btn-lg">Let's visualize!</button></div></div></div>`)()}<div id="genome-spy-container" class="${mm({"active-panel":!!qf})}"></div>`}function Cz(){return ot`<div class="buttons ${Ts?"visible":"hidden"}"><button @click="${wS}">⇐ Back to files</button></div>`}function Bd(t){t.stopPropagation(),t.preventDefault(),t.type==="dragleave"?Uf=!1:Uf=!0,Nr()}async function Tz(t){t.stopPropagation(),t.preventDefault(),Uf=!1;const n=[...t.dataTransfer.files];jg(await Promise.all(n.map(gS)))}function bS(){const t=new Map([...Io.entries()].filter(e=>e[0]!==xt.DICT));return t.size>0&&[...t.values()].every(e=>e.data)&&(Ji||Io.has(xt.DICT))}function Nr(){Qu(Sz(),document.querySelector("main")),Qu(Cz(),document.querySelector("header .toolbar"))}async function yS(){wS();const t=Ez(Io,Ji);qf=!0,Nr(),Ts=await cz(document.querySelector("#genome-spy-container"),t),Nr()}function wS(){Ts&&(Ts.finalize(),Ts=void 0),qf=!1,Nr()}function Aw(t){Ji=t,Nr()}async function Fz(t){const e=[...t.target.files];jg(await Promise.all(e.map(gS)))}async function Sw(t){const e="https://data.genomespy.app/sample-data/segment-model-spy/";Fs=!0,Nr();const r=[".hets.tsv",".denoisedCR.tsv",".modelFinal.seg"].map(i=>e+t+i);try{jg(await Promise.all(r.map(mz)))}catch{alert("Failed to load example data. Please try again later.")}Fs=!1}async function jg(t){const e=[];for(const n of t){const r=n.textContent,i=bz(r);i?(e.push({file:n,textContent:r,type:i}),Io.set(i,{name:n.name,data:null})):alert(`Cannot recognise this file: ${n.name}.`),i===xt.DICT&&(Ji=void 0)}for(const n of e){Nr(),await vw();let r=[];n.type!==xt.DICT?r=Dw(" ",{comment:"@"}).parse(n.textContent,wz[n.type.name]):r=Iz(n.textContent),Io.set(n.type,{name:n.file.name,data:r})}await vw(),Nr(),new Set(e.filter(n=>n.type!==xt.DICT)).size===3&&bS()&&yS()}function Iz(t){throw new Error("Function not implemented.")} diff --git a/segmentmodel/assets/index-396a8699.js b/segmentmodel/assets/index-396a8699.js new file mode 100644 index 0000000..bcbcb3f --- /dev/null +++ b/segmentmodel/assets/index-396a8699.js @@ -0,0 +1,4 @@ +import{b as Q}from"./index-462333f7.js";import{_ as Yn,L as Kn}from"./index-d89cadd6.js";import{L as nr}from"./__vite-browser-external-d053bc6e.js";import{R as ir}from"./remoteFile-1948951e.js";import"./_commonjsHelpers-de833af9.js";const lt=BigInt(32);function rr(e,n,t){const i=+!!t,r=+!t;return BigInt(e.getInt32(n,t)*r+e.getInt32(n+4,t)*i)<<lt|BigInt(e.getUint32(n,t)*i+e.getUint32(n+4,t)*r)}function ar(e,n,t){const i=e.getUint32(n,t),r=e.getUint32(n+4,t),a=+!!t,o=+!t;return BigInt(i*o+r*a)<<lt|BigInt(i*a+r*o)}function or(e,n,t,i){const r=Number(t>>lt),a=Number(t&BigInt(4294967295));i?(e.setInt32(n+4,r,i),e.setUint32(n,a,i)):(e.setInt32(n,r,i),e.setUint32(n+4,a,i))}function sr(e,n,t,i){const r=Number(t>>lt),a=Number(t&BigInt(4294967295));i?(e.setUint32(n+4,r,i),e.setUint32(n,a,i)):(e.setUint32(n,r,i),e.setUint32(n+4,a,i))}"getBigInt64"in DataView||(DataView.prototype.getBigInt64=function(e,n){return rr(this,e,n)});"getBigUint64"in DataView||(DataView.prototype.getBigUint64=function(e,n){return ar(this,e,n)});"setBigInt64"in DataView||(DataView.prototype.setBigInt64=function(e,n,t){or(this,e,n,t)});"setBigUint64"in DataView||(DataView.prototype.setBigUint64=function(e,n,t){sr(this,e,n,t)});class fr{constructor(n,t){this.code="",this.scopes=[["vars"]],this.bitFields=[],this.tmpVariableCount=0,this.references=new Map,this.imports=[],this.reverseImports=new Map,this.useContextVariables=!1,this.importPath=n,this.useContextVariables=t}generateVariable(n){const t=[...this.scopes[this.scopes.length-1]];return n&&t.push(n),t.join(".")}generateOption(n){switch(typeof n){case"number":return n.toString();case"string":return this.generateVariable(n);case"function":return`${this.addImport(n)}.call(${this.generateVariable()}, vars)`}}generateError(n){this.pushCode(`throw new Error(${n});`)}generateTmpVariable(){return"$tmp"+this.tmpVariableCount++}pushCode(n){this.code+=n+` +`}pushPath(n){n&&this.scopes[this.scopes.length-1].push(n)}popPath(n){n&&this.scopes[this.scopes.length-1].pop()}pushScope(n){this.scopes.push([n])}popScope(){this.scopes.pop()}addImport(n){if(!this.importPath)return`(${n})`;let t=this.reverseImports.get(n);return t||(t=this.imports.push(n)-1,this.reverseImports.set(n,t)),`${this.importPath}[${t}]`}addReference(n){this.references.has(n)||this.references.set(n,{resolved:!1,requested:!1})}markResolved(n){const t=this.references.get(n);t&&(t.resolved=!0)}markRequested(n){n.forEach(t=>{const i=this.references.get(t);i&&(i.requested=!0)})}getUnresolvedReferences(){return Array.from(this.references).filter(([n,t])=>!t.resolved&&!t.requested).map(([n,t])=>n)}}const Z=new Map,oe="___parser_",M={uint8:1,uint16le:2,uint16be:2,uint32le:4,uint32be:4,int8:1,int16le:2,int16be:2,int32le:4,int32be:4,int64be:8,int64le:8,uint64be:8,uint64le:8,floatle:4,floatbe:4,doublele:8,doublebe:8},Ye={uint8:"Uint8",uint16le:"Uint16",uint16be:"Uint16",uint32le:"Uint32",uint32be:"Uint32",int8:"Int8",int16le:"Int16",int16be:"Int16",int32le:"Int32",int32be:"Int32",int64be:"BigInt64",int64le:"BigInt64",uint64be:"BigUint64",uint64le:"BigUint64",floatle:"Float32",floatbe:"Float32",doublele:"Float64",doublebe:"Float64"},Ke={uint8:!1,uint16le:!0,uint16be:!1,uint32le:!0,uint32be:!1,int8:!1,int16le:!0,int16be:!1,int32le:!0,int32be:!1,int64be:!1,int64le:!0,uint64be:!1,uint64le:!0,floatle:!0,floatbe:!1,doublele:!0,doublebe:!1};class x{constructor(){this.varName="",this.type="",this.options={},this.endian="be",this.useContextVariables=!1}static start(){return new x}primitiveGenerateN(n,t){const i=Ye[n],r=Ke[n];t.pushCode(`${t.generateVariable(this.varName)} = dataView.get${i}(offset, ${r});`),t.pushCode(`offset += ${M[n]};`)}primitiveN(n,t,i){return this.setNextParser(n,t,i)}useThisEndian(n){return n+this.endian.toLowerCase()}uint8(n,t={}){return this.primitiveN("uint8",n,t)}uint16(n,t={}){return this.primitiveN(this.useThisEndian("uint16"),n,t)}uint16le(n,t={}){return this.primitiveN("uint16le",n,t)}uint16be(n,t={}){return this.primitiveN("uint16be",n,t)}uint32(n,t={}){return this.primitiveN(this.useThisEndian("uint32"),n,t)}uint32le(n,t={}){return this.primitiveN("uint32le",n,t)}uint32be(n,t={}){return this.primitiveN("uint32be",n,t)}int8(n,t={}){return this.primitiveN("int8",n,t)}int16(n,t={}){return this.primitiveN(this.useThisEndian("int16"),n,t)}int16le(n,t={}){return this.primitiveN("int16le",n,t)}int16be(n,t={}){return this.primitiveN("int16be",n,t)}int32(n,t={}){return this.primitiveN(this.useThisEndian("int32"),n,t)}int32le(n,t={}){return this.primitiveN("int32le",n,t)}int32be(n,t={}){return this.primitiveN("int32be",n,t)}bigIntVersionCheck(){if(!DataView.prototype.getBigInt64)throw new Error("BigInt64 is unsupported on this runtime")}int64(n,t={}){return this.bigIntVersionCheck(),this.primitiveN(this.useThisEndian("int64"),n,t)}int64be(n,t={}){return this.bigIntVersionCheck(),this.primitiveN("int64be",n,t)}int64le(n,t={}){return this.bigIntVersionCheck(),this.primitiveN("int64le",n,t)}uint64(n,t={}){return this.bigIntVersionCheck(),this.primitiveN(this.useThisEndian("uint64"),n,t)}uint64be(n,t={}){return this.bigIntVersionCheck(),this.primitiveN("uint64be",n,t)}uint64le(n,t={}){return this.bigIntVersionCheck(),this.primitiveN("uint64le",n,t)}floatle(n,t={}){return this.primitiveN("floatle",n,t)}floatbe(n,t={}){return this.primitiveN("floatbe",n,t)}doublele(n,t={}){return this.primitiveN("doublele",n,t)}doublebe(n,t={}){return this.primitiveN("doublebe",n,t)}bitN(n,t,i){return i.length=n,this.setNextParser("bit",t,i)}bit1(n,t={}){return this.bitN(1,n,t)}bit2(n,t={}){return this.bitN(2,n,t)}bit3(n,t={}){return this.bitN(3,n,t)}bit4(n,t={}){return this.bitN(4,n,t)}bit5(n,t={}){return this.bitN(5,n,t)}bit6(n,t={}){return this.bitN(6,n,t)}bit7(n,t={}){return this.bitN(7,n,t)}bit8(n,t={}){return this.bitN(8,n,t)}bit9(n,t={}){return this.bitN(9,n,t)}bit10(n,t={}){return this.bitN(10,n,t)}bit11(n,t={}){return this.bitN(11,n,t)}bit12(n,t={}){return this.bitN(12,n,t)}bit13(n,t={}){return this.bitN(13,n,t)}bit14(n,t={}){return this.bitN(14,n,t)}bit15(n,t={}){return this.bitN(15,n,t)}bit16(n,t={}){return this.bitN(16,n,t)}bit17(n,t={}){return this.bitN(17,n,t)}bit18(n,t={}){return this.bitN(18,n,t)}bit19(n,t={}){return this.bitN(19,n,t)}bit20(n,t={}){return this.bitN(20,n,t)}bit21(n,t={}){return this.bitN(21,n,t)}bit22(n,t={}){return this.bitN(22,n,t)}bit23(n,t={}){return this.bitN(23,n,t)}bit24(n,t={}){return this.bitN(24,n,t)}bit25(n,t={}){return this.bitN(25,n,t)}bit26(n,t={}){return this.bitN(26,n,t)}bit27(n,t={}){return this.bitN(27,n,t)}bit28(n,t={}){return this.bitN(28,n,t)}bit29(n,t={}){return this.bitN(29,n,t)}bit30(n,t={}){return this.bitN(30,n,t)}bit31(n,t={}){return this.bitN(31,n,t)}bit32(n,t={}){return this.bitN(32,n,t)}namely(n){return Z.set(n,this),this.alias=n,this}skip(n,t={}){return this.seek(n,t)}seek(n,t={}){if(t.assert)throw new Error("assert option on seek is not allowed.");return this.setNextParser("seek","",{length:n})}string(n,t){if(!t.zeroTerminated&&!t.length&&!t.greedy)throw new Error("One of length, zeroTerminated, or greedy must be defined for string.");if((t.zeroTerminated||t.length)&&t.greedy)throw new Error("greedy is mutually exclusive with length and zeroTerminated for string.");if(t.stripNull&&!(t.length||t.greedy))throw new Error("length or greedy must be defined if stripNull is enabled.");return t.encoding=t.encoding||"utf8",this.setNextParser("string",n,t)}buffer(n,t){if(!t.length&&!t.readUntil)throw new Error("length or readUntil must be defined for buffer.");return this.setNextParser("buffer",n,t)}wrapped(n,t){if(typeof t!="object"&&typeof n=="object"&&(t=n,n=""),!t||!t.wrapper||!t.type)throw new Error("Both wrapper and type must be defined for wrapped.");if(!t.length&&!t.readUntil)throw new Error("length or readUntil must be defined for wrapped.");return this.setNextParser("wrapper",n,t)}array(n,t){if(!t.readUntil&&!t.length&&!t.lengthInBytes)throw new Error("One of readUntil, length and lengthInBytes must be defined for array.");if(!t.type)throw new Error("type is required for array.");if(typeof t.type=="string"&&!Z.has(t.type)&&!(t.type in M))throw new Error(`Array element type "${t.type}" is unkown.`);return this.setNextParser("array",n,t)}choice(n,t){if(typeof t!="object"&&typeof n=="object"&&(t=n,n=""),!t)throw new Error("tag and choices are are required for choice.");if(!t.tag)throw new Error("tag is requird for choice.");if(!t.choices)throw new Error("choices is required for choice.");for(const i in t.choices){const r=parseInt(i,10),a=t.choices[r];if(isNaN(r))throw new Error(`Choice key "${i}" is not a number.`);if(typeof a=="string"&&!Z.has(a)&&!(a in M))throw new Error(`Choice type "${a}" is unkown.`)}return this.setNextParser("choice",n,t)}nest(n,t){if(typeof t!="object"&&typeof n=="object"&&(t=n,n=""),!t||!t.type)throw new Error("type is required for nest.");if(!(t.type instanceof x)&&!Z.has(t.type))throw new Error("type must be a known parser name or a Parser object.");if(!(t.type instanceof x)&&!n)throw new Error("type must be a Parser object if the variable name is omitted.");return this.setNextParser("nest",n,t)}pointer(n,t){if(!t.offset)throw new Error("offset is required for pointer.");if(!t.type)throw new Error("type is required for pointer.");if(typeof t.type=="string"&&!(t.type in M)&&!Z.has(t.type))throw new Error(`Pointer type "${t.type}" is unkown.`);return this.setNextParser("pointer",n,t)}saveOffset(n,t={}){return this.setNextParser("saveOffset",n,t)}endianness(n){switch(n.toLowerCase()){case"little":this.endian="le";break;case"big":this.endian="be";break;default:throw new Error('endianness must be one of "little" or "big"')}return this}endianess(n){return this.endianness(n)}useContextVars(n=!0){return this.useContextVariables=n,this}create(n){if(!(n instanceof Function))throw new Error("Constructor must be a Function object.");return this.constructorFn=n,this}getContext(n){const t=new fr(n,this.useContextVariables);return t.pushCode("var dataView = new DataView(buffer.buffer, buffer.byteOffset, buffer.length);"),this.alias?(this.addAliasedCode(t),t.pushCode(`return ${oe+this.alias}(0).result;`)):this.addRawCode(t),t}getCode(){const n="imports";return this.getContext(n).code}addRawCode(n){n.pushCode("var offset = 0;"),n.pushCode(`var vars = ${this.constructorFn?"new constructorFn()":"{}"};`),n.pushCode("vars.$parent = null;"),n.pushCode("vars.$root = vars;"),this.generate(n),this.resolveReferences(n),n.pushCode("delete vars.$parent;"),n.pushCode("delete vars.$root;"),n.pushCode("return vars;")}addAliasedCode(n){return n.pushCode(`function ${oe+this.alias}(offset, context) {`),n.pushCode(`var vars = ${this.constructorFn?"new constructorFn()":"{}"};`),n.pushCode("var ctx = Object.assign({$parent: null, $root: vars}, context || {});"),n.pushCode("vars = Object.assign(vars, ctx);"),this.generate(n),n.markResolved(this.alias),this.resolveReferences(n),n.pushCode("Object.keys(ctx).forEach(function (item) { delete vars[item]; });"),n.pushCode("return { offset: offset, result: vars };"),n.pushCode("}"),n}resolveReferences(n){const t=n.getUnresolvedReferences();n.markRequested(t),t.forEach(i=>{var r;(r=Z.get(i))===null||r===void 0||r.addAliasedCode(n)})}compile(){const n="imports",t=this.getContext(n);this.compiled=new Function(n,"TextDecoder",`return function (buffer, constructorFn) { ${t.code} };`)(t.imports,TextDecoder)}sizeOf(){let n=NaN;if(Object.keys(M).indexOf(this.type)>=0)n=M[this.type];else if(this.type==="string"&&typeof this.options.length=="number")n=this.options.length;else if(this.type==="buffer"&&typeof this.options.length=="number")n=this.options.length;else if(this.type==="array"&&typeof this.options.length=="number"){let t=NaN;typeof this.options.type=="string"?t=M[this.options.type]:this.options.type instanceof x&&(t=this.options.type.sizeOf()),n=this.options.length*t}else this.type==="seek"?n=this.options.length:this.type==="nest"?n=this.options.type.sizeOf():this.type||(n=0);return this.next&&(n+=this.next.sizeOf()),n}parse(n){return this.compiled||this.compile(),this.compiled(n,this.constructorFn)}setNextParser(n,t,i){const r=new x;return r.type=n,r.varName=t,r.options=i,r.endian=this.endian,this.head?this.head.next=r:this.next=r,this.head=r,this}generate(n){if(this.type){switch(this.type){case"uint8":case"uint16le":case"uint16be":case"uint32le":case"uint32be":case"int8":case"int16le":case"int16be":case"int32le":case"int32be":case"int64be":case"int64le":case"uint64be":case"uint64le":case"floatle":case"floatbe":case"doublele":case"doublebe":this.primitiveGenerateN(this.type,n);break;case"bit":this.generateBit(n);break;case"string":this.generateString(n);break;case"buffer":this.generateBuffer(n);break;case"seek":this.generateSeek(n);break;case"nest":this.generateNest(n);break;case"array":this.generateArray(n);break;case"choice":this.generateChoice(n);break;case"pointer":this.generatePointer(n);break;case"saveOffset":this.generateSaveOffset(n);break;case"wrapper":this.generateWrapper(n);break}this.type!=="bit"&&this.generateAssert(n)}const t=n.generateVariable(this.varName);return this.options.formatter&&this.type!=="bit"&&this.generateFormatter(n,t,this.options.formatter),this.generateNext(n)}generateAssert(n){if(!this.options.assert)return;const t=n.generateVariable(this.varName);switch(typeof this.options.assert){case"function":{const i=n.addImport(this.options.assert);n.pushCode(`if (!${i}.call(vars, ${t})) {`)}break;case"number":n.pushCode(`if (${this.options.assert} !== ${t}) {`);break;case"string":n.pushCode(`if (${JSON.stringify(this.options.assert)} !== ${t}) {`);break;default:throw new Error("assert option must be a string, number or a function.")}n.generateError(`"Assertion error: ${t} is " + ${JSON.stringify(this.options.assert.toString())}`),n.pushCode("}")}generateNext(n){return this.next&&(n=this.next.generate(n)),n}generateBit(n){const t=JSON.parse(JSON.stringify(this));if(t.options=this.options,t.generateAssert=this.generateAssert.bind(this),t.generateFormatter=this.generateFormatter.bind(this),t.varName=n.generateVariable(t.varName),n.bitFields.push(t),!this.next||this.next&&["bit","nest"].indexOf(this.next.type)<0){const i=n.generateTmpVariable();n.pushCode(`var ${i} = 0;`);const r=(l=0)=>{let d=0;for(let c=l;c<n.bitFields.length;c++){const h=n.bitFields[c].options.length;if(d+h>32)break;d+=h}return d},a=l=>(l<=8?(n.pushCode(`${i} = dataView.getUint8(offset);`),l=8):l<=16?(n.pushCode(`${i} = dataView.getUint16(offset);`),l=16):l<=24?(n.pushCode(`${i} = (dataView.getUint16(offset) << 8) | dataView.getUint8(offset + 2);`),l=24):(n.pushCode(`${i} = dataView.getUint32(offset);`),l=32),n.pushCode(`offset += ${l/8};`),l);let o=0;const f=this.endian==="be";let u=0,s=0;n.bitFields.forEach((l,d)=>{let c=l.options.length;if(c>s){if(s){const g=-1>>>32-s;n.pushCode(`${l.varName} = (${i} & 0x${g.toString(16)}) << ${c-s};`),c-=s}o=0,s=u=a(r(d)-s)}const h=f?u-o-c:o,_=-1>>>32-c;n.pushCode(`${l.varName} ${c<l.options.length?"|=":"="} ${i} >> ${h} & 0x${_.toString(16)};`),l.options.length===32&&n.pushCode(`${l.varName} >>>= 0`),l.options.assert&&l.generateAssert(n),l.options.formatter&&l.generateFormatter(n,l.varName,l.options.formatter),o+=c,s-=c}),n.bitFields=[]}}generateSeek(n){const t=n.generateOption(this.options.length);n.pushCode(`offset += ${t};`)}generateString(n){const t=n.generateVariable(this.varName),i=n.generateTmpVariable(),r=this.options.encoding,a=r.toLowerCase()==="hex",o='b => b.toString(16).padStart(2, "0")';if(this.options.length&&this.options.zeroTerminated){const f=this.options.length;n.pushCode(`var ${i} = offset;`),n.pushCode(`while(dataView.getUint8(offset++) !== 0 && offset - ${i} < ${f});`);const u=`offset - ${i} < ${f} ? offset - 1 : offset`;n.pushCode(a?`${t} = Array.from(buffer.subarray(${i}, ${u}), ${o}).join('');`:`${t} = new TextDecoder('${r}').decode(buffer.subarray(${i}, ${u}));`)}else if(this.options.length){const f=n.generateOption(this.options.length);n.pushCode(a?`${t} = Array.from(buffer.subarray(offset, offset + ${f}), ${o}).join('');`:`${t} = new TextDecoder('${r}').decode(buffer.subarray(offset, offset + ${f}));`),n.pushCode(`offset += ${f};`)}else this.options.zeroTerminated?(n.pushCode(`var ${i} = offset;`),n.pushCode("while(dataView.getUint8(offset++) !== 0);"),n.pushCode(a?`${t} = Array.from(buffer.subarray(${i}, offset - 1), ${o}).join('');`:`${t} = new TextDecoder('${r}').decode(buffer.subarray(${i}, offset - 1));`)):this.options.greedy&&(n.pushCode(`var ${i} = offset;`),n.pushCode("while(buffer.length > offset++);"),n.pushCode(a?`${t} = Array.from(buffer.subarray(${i}, offset), ${o}).join('');`:`${t} = new TextDecoder('${r}').decode(buffer.subarray(${i}, offset));`));this.options.stripNull&&n.pushCode(`${t} = ${t}.replace(/\\x00+$/g, '')`)}generateBuffer(n){const t=n.generateVariable(this.varName);if(typeof this.options.readUntil=="function"){const i=this.options.readUntil,r=n.generateTmpVariable(),a=n.generateTmpVariable();n.pushCode(`var ${r} = offset;`),n.pushCode(`var ${a} = 0;`),n.pushCode("while (offset < buffer.length) {"),n.pushCode(`${a} = dataView.getUint8(offset);`);const o=n.addImport(i);n.pushCode(`if (${o}.call(${n.generateVariable()}, ${a}, buffer.subarray(offset))) break;`),n.pushCode("offset += 1;"),n.pushCode("}"),n.pushCode(`${t} = buffer.subarray(${r}, offset);`)}else if(this.options.readUntil==="eof")n.pushCode(`${t} = buffer.subarray(offset);`);else{const i=n.generateOption(this.options.length);n.pushCode(`${t} = buffer.subarray(offset, offset + ${i});`),n.pushCode(`offset += ${i};`)}this.options.clone&&n.pushCode(`${t} = buffer.constructor.from(${t});`)}generateArray(n){const t=n.generateOption(this.options.length),i=n.generateOption(this.options.lengthInBytes),r=this.options.type,a=n.generateTmpVariable(),o=n.generateVariable(this.varName),f=n.generateTmpVariable(),u=this.options.key,s=typeof u=="string";if(s?n.pushCode(`${o} = {};`):n.pushCode(`${o} = [];`),typeof this.options.readUntil=="function"?n.pushCode("do {"):this.options.readUntil==="eof"?n.pushCode(`for (var ${a} = 0; offset < buffer.length; ${a}++) {`):i!==void 0?n.pushCode(`for (var ${a} = offset + ${i}; offset < ${a}; ) {`):n.pushCode(`for (var ${a} = ${t}; ${a} > 0; ${a}--) {`),typeof r=="string")if(Z.get(r)){const l=n.generateTmpVariable();if(n.pushCode(`var ${l} = ${oe+r}(offset, {`),n.useContextVariables){const d=n.generateVariable();n.pushCode(`$parent: ${d},`),n.pushCode(`$root: ${d}.$root,`),!this.options.readUntil&&i===void 0&&n.pushCode(`$index: ${t} - ${a},`)}n.pushCode("});"),n.pushCode(`var ${f} = ${l}.result; offset = ${l}.offset;`),r!==this.alias&&n.addReference(r)}else{const l=Ye[r],d=Ke[r];n.pushCode(`var ${f} = dataView.get${l}(offset, ${d});`),n.pushCode(`offset += ${M[r]};`)}else if(r instanceof x){n.pushCode(`var ${f} = {};`);const l=n.generateVariable();n.pushScope(f),n.useContextVariables&&(n.pushCode(`${f}.$parent = ${l};`),n.pushCode(`${f}.$root = ${l}.$root;`),!this.options.readUntil&&i===void 0&&n.pushCode(`${f}.$index = ${t} - ${a};`)),r.generate(n),n.useContextVariables&&(n.pushCode(`delete ${f}.$parent;`),n.pushCode(`delete ${f}.$root;`),n.pushCode(`delete ${f}.$index;`)),n.popScope()}if(s?n.pushCode(`${o}[${f}.${u}] = ${f};`):n.pushCode(`${o}.push(${f});`),n.pushCode("}"),typeof this.options.readUntil=="function"){const l=this.options.readUntil,d=n.addImport(l);n.pushCode(`while (!${d}.call(${n.generateVariable()}, ${f}, buffer.subarray(offset)));`)}}generateChoiceCase(n,t,i){if(typeof i=="string"){const r=n.generateVariable(this.varName);if(Z.has(i)){const a=n.generateTmpVariable();n.pushCode(`var ${a} = ${oe+i}(offset, {`),n.useContextVariables&&(n.pushCode(`$parent: ${r}.$parent,`),n.pushCode(`$root: ${r}.$root,`)),n.pushCode("});"),n.pushCode(`${r} = ${a}.result; offset = ${a}.offset;`),i!==this.alias&&n.addReference(i)}else{const a=Ye[i],o=Ke[i];n.pushCode(`${r} = dataView.get${a}(offset, ${o});`),n.pushCode(`offset += ${M[i]}`)}}else i instanceof x&&(n.pushPath(t),i.generate(n),n.popPath(t))}generateChoice(n){const t=n.generateOption(this.options.tag),i=n.generateVariable(this.varName);if(this.varName&&(n.pushCode(`${i} = {};`),n.useContextVariables)){const r=n.generateVariable();n.pushCode(`${i}.$parent = ${r};`),n.pushCode(`${i}.$root = ${r}.$root;`)}n.pushCode(`switch(${t}) {`);for(const r in this.options.choices){const a=parseInt(r,10),o=this.options.choices[a];n.pushCode(`case ${a}:`),this.generateChoiceCase(n,this.varName,o),n.pushCode("break;")}n.pushCode("default:"),this.options.defaultChoice?this.generateChoiceCase(n,this.varName,this.options.defaultChoice):n.generateError(`"Met undefined tag value " + ${t} + " at choice"`),n.pushCode("}"),this.varName&&n.useContextVariables&&(n.pushCode(`delete ${i}.$parent;`),n.pushCode(`delete ${i}.$root;`))}generateNest(n){const t=n.generateVariable(this.varName);if(this.options.type instanceof x){if(this.varName&&(n.pushCode(`${t} = {};`),n.useContextVariables)){const i=n.generateVariable();n.pushCode(`${t}.$parent = ${i};`),n.pushCode(`${t}.$root = ${i}.$root;`)}n.pushPath(this.varName),this.options.type.generate(n),n.popPath(this.varName),this.varName&&n.useContextVariables&&n.useContextVariables&&(n.pushCode(`delete ${t}.$parent;`),n.pushCode(`delete ${t}.$root;`))}else if(Z.has(this.options.type)){const i=n.generateTmpVariable();if(n.pushCode(`var ${i} = ${oe+this.options.type}(offset, {`),n.useContextVariables){const r=n.generateVariable();n.pushCode(`$parent: ${r},`),n.pushCode(`$root: ${r}.$root,`)}n.pushCode("});"),n.pushCode(`${t} = ${i}.result; offset = ${i}.offset;`),this.options.type!==this.alias&&n.addReference(this.options.type)}}generateWrapper(n){const t=n.generateVariable(this.varName),i=n.generateTmpVariable();if(typeof this.options.readUntil=="function"){const u=this.options.readUntil,s=n.generateTmpVariable(),l=n.generateTmpVariable();n.pushCode(`var ${s} = offset;`),n.pushCode(`var ${l} = 0;`),n.pushCode("while (offset < buffer.length) {"),n.pushCode(`${l} = dataView.getUint8(offset);`);const d=n.addImport(u);n.pushCode(`if (${d}.call(${n.generateVariable()}, ${l}, buffer.subarray(offset))) break;`),n.pushCode("offset += 1;"),n.pushCode("}"),n.pushCode(`${i} = buffer.subarray(${s}, offset);`)}else if(this.options.readUntil==="eof")n.pushCode(`${i} = buffer.subarray(offset);`);else{const u=n.generateOption(this.options.length);n.pushCode(`${i} = buffer.subarray(offset, offset + ${u});`),n.pushCode(`offset += ${u};`)}this.options.clone&&n.pushCode(`${i} = buffer.constructor.from(${i});`);const r=n.generateTmpVariable(),a=n.generateTmpVariable(),o=n.generateTmpVariable(),f=n.addImport(this.options.wrapper);if(n.pushCode(`${i} = ${f}.call(this, ${i}).subarray(0);`),n.pushCode(`var ${r} = buffer;`),n.pushCode(`var ${a} = offset;`),n.pushCode(`var ${o} = dataView;`),n.pushCode(`buffer = ${i};`),n.pushCode("offset = 0;"),n.pushCode("dataView = new DataView(buffer.buffer, buffer.byteOffset, buffer.length);"),this.options.type instanceof x)this.varName&&n.pushCode(`${t} = {};`),n.pushPath(this.varName),this.options.type.generate(n),n.popPath(this.varName);else if(Z.has(this.options.type)){const u=n.generateTmpVariable();n.pushCode(`var ${u} = ${oe+this.options.type}(0);`),n.pushCode(`${t} = ${u}.result;`),this.options.type!==this.alias&&n.addReference(this.options.type)}n.pushCode(`buffer = ${r};`),n.pushCode(`dataView = ${o};`),n.pushCode(`offset = ${a};`)}generateFormatter(n,t,i){if(typeof i=="function"){const r=n.addImport(i);n.pushCode(`${t} = ${r}.call(${n.generateVariable()}, ${t});`)}}generatePointer(n){const t=this.options.type,i=n.generateOption(this.options.offset),r=n.generateTmpVariable(),a=n.generateVariable(this.varName);if(n.pushCode(`var ${r} = offset;`),n.pushCode(`offset = ${i};`),this.options.type instanceof x){if(n.pushCode(`${a} = {};`),n.useContextVariables){const o=n.generateVariable();n.pushCode(`${a}.$parent = ${o};`),n.pushCode(`${a}.$root = ${o}.$root;`)}n.pushPath(this.varName),this.options.type.generate(n),n.popPath(this.varName),n.useContextVariables&&(n.pushCode(`delete ${a}.$parent;`),n.pushCode(`delete ${a}.$root;`))}else if(Z.has(this.options.type)){const o=n.generateTmpVariable();if(n.pushCode(`var ${o} = ${oe+this.options.type}(offset, {`),n.useContextVariables){const f=n.generateVariable();n.pushCode(`$parent: ${f},`),n.pushCode(`$root: ${f}.$root,`)}n.pushCode("});"),n.pushCode(`${a} = ${o}.result; offset = ${o}.offset;`),this.options.type!==this.alias&&n.addReference(this.options.type)}else if(Object.keys(M).indexOf(this.options.type)>=0){const o=Ye[t],f=Ke[t];n.pushCode(`${a} = dataView.get${o}(offset, ${f});`),n.pushCode(`offset += ${M[t]};`)}n.pushCode(`offset = ${r};`)}generateSaveOffset(n){const t=n.generateVariable(this.varName);n.pushCode(`${t} = offset`)}}class q{constructor(n,t){this.ranges=arguments.length===2?[{min:n,max:t}]:0 in n?Object.assign({},n):[n]}min(){return this.ranges[0].min}max(){return this.ranges[this.ranges.length-1].max}contains(n){for(let t=0;t<this.ranges.length;t+=1){const i=this.ranges[t];if(i.min<=n&&i.max>=n)return!0}return!1}isContiguous(){return this.ranges.length>1}getRanges(){return this.ranges.map(n=>new q(n.min,n.max))}toString(){return this.ranges.map(n=>`[${n.min}-${n.max}]`).join(",")}union(n){const t=this.getRanges().concat(n.getRanges()).sort(this.rangeOrder),i=[];let r=t[0];for(let a=1;a<t.length;a+=1){const o=t[a];o.min()>r.max()+1?(i.push(r),r=o):o.max()>r.max()&&(r=new q(r.min(),o.max()))}return i.push(r),i.length===1?i[0]:new q(i)}intersection(n){let t=this,i=n;const r=this.ranges(),a=i.ranges(),o=r.length,f=a.length;let u=0,s=0;const l=[];for(;u<o&&s<f;){t=r[u],i=a[s];const d=Math.max(t.min(),i.min()),c=Math.min(t.max(),i.max());c>=d&&l.push(new q(d,c)),t.max()>i.max()?s+=1:u+=1}if(l.length===0)throw new Error("found range of length 0");return l.length===1?l[0]:new q(l)}coverage(){let n=0;const t=this.ranges();for(const i of t)n+=i.max()-i.min()+1;return n}rangeOrder(n,t){let i=n,r=t;return arguments.length<2&&(r=i,i=this),i.min()<r.min()?-1:i.min()>r.min()?1:i.max()<r.max()?-1:r.max()>i.max()?1:0}}/*! pako 2.1.0 https://github.com/nodeca/pako @license (MIT AND Zlib) */const lr=4,en=0,tn=1,ur=2;function ye(e){let n=e.length;for(;--n>=0;)e[n]=0}const hr=0,Wn=1,cr=2,dr=3,pr=258,Zt=29,Pe=256,Ae=Pe+1+Zt,_e=30,Mt=19,Xn=2*Ae+1,se=15,dt=16,_r=7,Ht=256,qn=16,Jn=17,Qn=18,At=new Uint8Array([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]),nt=new Uint8Array([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]),br=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),ei=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),gr=512,W=new Array((Ae+2)*2);ye(W);const Ne=new Array(_e*2);ye(Ne);const Oe=new Array(gr);ye(Oe);const ze=new Array(pr-dr+1);ye(ze);const jt=new Array(Zt);ye(jt);const it=new Array(_e);ye(it);function pt(e,n,t,i,r){this.static_tree=e,this.extra_bits=n,this.extra_base=t,this.elems=i,this.max_length=r,this.has_stree=e&&e.length}let ti,ni,ii;function _t(e,n){this.dyn_tree=e,this.max_code=0,this.stat_desc=n}const ri=e=>e<256?Oe[e]:Oe[256+(e>>>7)],Re=(e,n)=>{e.pending_buf[e.pending++]=n&255,e.pending_buf[e.pending++]=n>>>8&255},U=(e,n,t)=>{e.bi_valid>dt-t?(e.bi_buf|=n<<e.bi_valid&65535,Re(e,e.bi_buf),e.bi_buf=n>>dt-e.bi_valid,e.bi_valid+=t-dt):(e.bi_buf|=n<<e.bi_valid&65535,e.bi_valid+=t)},j=(e,n,t)=>{U(e,t[n*2],t[n*2+1])},ai=(e,n)=>{let t=0;do t|=e&1,e>>>=1,t<<=1;while(--n>0);return t>>>1},wr=e=>{e.bi_valid===16?(Re(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)},mr=(e,n)=>{const t=n.dyn_tree,i=n.max_code,r=n.stat_desc.static_tree,a=n.stat_desc.has_stree,o=n.stat_desc.extra_bits,f=n.stat_desc.extra_base,u=n.stat_desc.max_length;let s,l,d,c,h,_,g=0;for(c=0;c<=se;c++)e.bl_count[c]=0;for(t[e.heap[e.heap_max]*2+1]=0,s=e.heap_max+1;s<Xn;s++)l=e.heap[s],c=t[t[l*2+1]*2+1]+1,c>u&&(c=u,g++),t[l*2+1]=c,!(l>i)&&(e.bl_count[c]++,h=0,l>=f&&(h=o[l-f]),_=t[l*2],e.opt_len+=_*(c+h),a&&(e.static_len+=_*(r[l*2+1]+h)));if(g!==0){do{for(c=u-1;e.bl_count[c]===0;)c--;e.bl_count[c]--,e.bl_count[c+1]+=2,e.bl_count[u]--,g-=2}while(g>0);for(c=u;c!==0;c--)for(l=e.bl_count[c];l!==0;)d=e.heap[--s],!(d>i)&&(t[d*2+1]!==c&&(e.opt_len+=(c-t[d*2+1])*t[d*2],t[d*2+1]=c),l--)}},oi=(e,n,t)=>{const i=new Array(se+1);let r=0,a,o;for(a=1;a<=se;a++)r=r+t[a-1]<<1,i[a]=r;for(o=0;o<=n;o++){let f=e[o*2+1];f!==0&&(e[o*2]=ai(i[f]++,f))}},yr=()=>{let e,n,t,i,r;const a=new Array(se+1);for(t=0,i=0;i<Zt-1;i++)for(jt[i]=t,e=0;e<1<<At[i];e++)ze[t++]=i;for(ze[t-1]=i,r=0,i=0;i<16;i++)for(it[i]=r,e=0;e<1<<nt[i];e++)Oe[r++]=i;for(r>>=7;i<_e;i++)for(it[i]=r<<7,e=0;e<1<<nt[i]-7;e++)Oe[256+r++]=i;for(n=0;n<=se;n++)a[n]=0;for(e=0;e<=143;)W[e*2+1]=8,e++,a[8]++;for(;e<=255;)W[e*2+1]=9,e++,a[9]++;for(;e<=279;)W[e*2+1]=7,e++,a[7]++;for(;e<=287;)W[e*2+1]=8,e++,a[8]++;for(oi(W,Ae+1,a),e=0;e<_e;e++)Ne[e*2+1]=5,Ne[e*2]=ai(e,5);ti=new pt(W,At,Pe+1,Ae,se),ni=new pt(Ne,nt,0,_e,se),ii=new pt(new Array(0),br,0,Mt,_r)},si=e=>{let n;for(n=0;n<Ae;n++)e.dyn_ltree[n*2]=0;for(n=0;n<_e;n++)e.dyn_dtree[n*2]=0;for(n=0;n<Mt;n++)e.bl_tree[n*2]=0;e.dyn_ltree[Ht*2]=1,e.opt_len=e.static_len=0,e.sym_next=e.matches=0},fi=e=>{e.bi_valid>8?Re(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},nn=(e,n,t,i)=>{const r=n*2,a=t*2;return e[r]<e[a]||e[r]===e[a]&&i[n]<=i[t]},bt=(e,n,t)=>{const i=e.heap[t];let r=t<<1;for(;r<=e.heap_len&&(r<e.heap_len&&nn(n,e.heap[r+1],e.heap[r],e.depth)&&r++,!nn(n,i,e.heap[r],e.depth));)e.heap[t]=e.heap[r],t=r,r<<=1;e.heap[t]=i},rn=(e,n,t)=>{let i,r,a=0,o,f;if(e.sym_next!==0)do i=e.pending_buf[e.sym_buf+a++]&255,i+=(e.pending_buf[e.sym_buf+a++]&255)<<8,r=e.pending_buf[e.sym_buf+a++],i===0?j(e,r,n):(o=ze[r],j(e,o+Pe+1,n),f=At[o],f!==0&&(r-=jt[o],U(e,r,f)),i--,o=ri(i),j(e,o,t),f=nt[o],f!==0&&(i-=it[o],U(e,i,f)));while(a<e.sym_next);j(e,Ht,n)},Ot=(e,n)=>{const t=n.dyn_tree,i=n.stat_desc.static_tree,r=n.stat_desc.has_stree,a=n.stat_desc.elems;let o,f,u=-1,s;for(e.heap_len=0,e.heap_max=Xn,o=0;o<a;o++)t[o*2]!==0?(e.heap[++e.heap_len]=u=o,e.depth[o]=0):t[o*2+1]=0;for(;e.heap_len<2;)s=e.heap[++e.heap_len]=u<2?++u:0,t[s*2]=1,e.depth[s]=0,e.opt_len--,r&&(e.static_len-=i[s*2+1]);for(n.max_code=u,o=e.heap_len>>1;o>=1;o--)bt(e,t,o);s=a;do o=e.heap[1],e.heap[1]=e.heap[e.heap_len--],bt(e,t,1),f=e.heap[1],e.heap[--e.heap_max]=o,e.heap[--e.heap_max]=f,t[s*2]=t[o*2]+t[f*2],e.depth[s]=(e.depth[o]>=e.depth[f]?e.depth[o]:e.depth[f])+1,t[o*2+1]=t[f*2+1]=s,e.heap[1]=s++,bt(e,t,1);while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],mr(e,n),oi(t,u,e.bl_count)},an=(e,n,t)=>{let i,r=-1,a,o=n[0*2+1],f=0,u=7,s=4;for(o===0&&(u=138,s=3),n[(t+1)*2+1]=65535,i=0;i<=t;i++)a=o,o=n[(i+1)*2+1],!(++f<u&&a===o)&&(f<s?e.bl_tree[a*2]+=f:a!==0?(a!==r&&e.bl_tree[a*2]++,e.bl_tree[qn*2]++):f<=10?e.bl_tree[Jn*2]++:e.bl_tree[Qn*2]++,f=0,r=a,o===0?(u=138,s=3):a===o?(u=6,s=3):(u=7,s=4))},on=(e,n,t)=>{let i,r=-1,a,o=n[0*2+1],f=0,u=7,s=4;for(o===0&&(u=138,s=3),i=0;i<=t;i++)if(a=o,o=n[(i+1)*2+1],!(++f<u&&a===o)){if(f<s)do j(e,a,e.bl_tree);while(--f!==0);else a!==0?(a!==r&&(j(e,a,e.bl_tree),f--),j(e,qn,e.bl_tree),U(e,f-3,2)):f<=10?(j(e,Jn,e.bl_tree),U(e,f-3,3)):(j(e,Qn,e.bl_tree),U(e,f-11,7));f=0,r=a,o===0?(u=138,s=3):a===o?(u=6,s=3):(u=7,s=4)}},vr=e=>{let n;for(an(e,e.dyn_ltree,e.l_desc.max_code),an(e,e.dyn_dtree,e.d_desc.max_code),Ot(e,e.bl_desc),n=Mt-1;n>=3&&e.bl_tree[ei[n]*2+1]===0;n--);return e.opt_len+=3*(n+1)+5+5+4,n},kr=(e,n,t,i)=>{let r;for(U(e,n-257,5),U(e,t-1,5),U(e,i-4,4),r=0;r<i;r++)U(e,e.bl_tree[ei[r]*2+1],3);on(e,e.dyn_ltree,n-1),on(e,e.dyn_dtree,t-1)},$r=e=>{let n=4093624447,t;for(t=0;t<=31;t++,n>>>=1)if(n&1&&e.dyn_ltree[t*2]!==0)return en;if(e.dyn_ltree[9*2]!==0||e.dyn_ltree[10*2]!==0||e.dyn_ltree[13*2]!==0)return tn;for(t=32;t<Pe;t++)if(e.dyn_ltree[t*2]!==0)return tn;return en};let sn=!1;const Er=e=>{sn||(yr(),sn=!0),e.l_desc=new _t(e.dyn_ltree,ti),e.d_desc=new _t(e.dyn_dtree,ni),e.bl_desc=new _t(e.bl_tree,ii),e.bi_buf=0,e.bi_valid=0,si(e)},li=(e,n,t,i)=>{U(e,(hr<<1)+(i?1:0),3),fi(e),Re(e,t),Re(e,~t),t&&e.pending_buf.set(e.window.subarray(n,n+t),e.pending),e.pending+=t},Cr=e=>{U(e,Wn<<1,3),j(e,Ht,W),wr(e)},Sr=(e,n,t,i)=>{let r,a,o=0;e.level>0?(e.strm.data_type===ur&&(e.strm.data_type=$r(e)),Ot(e,e.l_desc),Ot(e,e.d_desc),o=vr(e),r=e.opt_len+3+7>>>3,a=e.static_len+3+7>>>3,a<=r&&(r=a)):r=a=t+5,t+4<=r&&n!==-1?li(e,n,t,i):e.strategy===lr||a===r?(U(e,(Wn<<1)+(i?1:0),3),rn(e,W,Ne)):(U(e,(cr<<1)+(i?1:0),3),kr(e,e.l_desc.max_code+1,e.d_desc.max_code+1,o+1),rn(e,e.dyn_ltree,e.dyn_dtree)),si(e),i&&fi(e)},xr=(e,n,t)=>(e.pending_buf[e.sym_buf+e.sym_next++]=n,e.pending_buf[e.sym_buf+e.sym_next++]=n>>8,e.pending_buf[e.sym_buf+e.sym_next++]=t,n===0?e.dyn_ltree[t*2]++:(e.matches++,n--,e.dyn_ltree[(ze[t]+Pe+1)*2]++,e.dyn_dtree[ri(n)*2]++),e.sym_next===e.sym_end);var Nr=Er,Ir=li,Tr=Sr,Ar=xr,Or=Cr,zr={_tr_init:Nr,_tr_stored_block:Ir,_tr_flush_block:Tr,_tr_tally:Ar,_tr_align:Or};const Rr=(e,n,t,i)=>{let r=e&65535|0,a=e>>>16&65535|0,o=0;for(;t!==0;){o=t>2e3?2e3:t,t-=o;do r=r+n[i++]|0,a=a+r|0;while(--o);r%=65521,a%=65521}return r|a<<16|0};var Be=Rr;const Br=()=>{let e,n=[];for(var t=0;t<256;t++){e=t;for(var i=0;i<8;i++)e=e&1?3988292384^e>>>1:e>>>1;n[t]=e}return n},Ur=new Uint32Array(Br()),Dr=(e,n,t,i)=>{const r=Ur,a=i+t;e^=-1;for(let o=i;o<a;o++)e=e>>>8^r[(e^n[o])&255];return e^-1};var z=Dr,ge={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"},Ze={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:Vr,_tr_stored_block:zt,_tr_flush_block:Lr,_tr_tally:te,_tr_align:Fr}=zr,{Z_NO_FLUSH:ne,Z_PARTIAL_FLUSH:Pr,Z_FULL_FLUSH:Zr,Z_FINISH:L,Z_BLOCK:fn,Z_OK:R,Z_STREAM_END:ln,Z_STREAM_ERROR:G,Z_DATA_ERROR:Mr,Z_BUF_ERROR:gt,Z_DEFAULT_COMPRESSION:Hr,Z_FILTERED:jr,Z_HUFFMAN_ONLY:We,Z_RLE:Gr,Z_FIXED:Yr,Z_DEFAULT_STRATEGY:Kr,Z_UNKNOWN:Wr,Z_DEFLATED:ut}=Ze,Xr=9,qr=15,Jr=8,Qr=29,ea=256,Rt=ea+1+Qr,ta=30,na=19,ia=2*Rt+1,ra=15,I=3,ee=258,Y=ee+I+1,aa=32,we=42,Gt=57,Bt=69,Ut=73,Dt=91,Vt=103,fe=113,Se=666,B=1,ve=2,ue=3,ke=4,oa=3,le=(e,n)=>(e.msg=ge[n],n),un=e=>e*2-(e>4?9:0),J=e=>{let n=e.length;for(;--n>=0;)e[n]=0},sa=e=>{let n,t,i,r=e.w_size;n=e.hash_size,i=n;do t=e.head[--i],e.head[i]=t>=r?t-r:0;while(--n);n=r,i=n;do t=e.prev[--i],e.prev[i]=t>=r?t-r:0;while(--n)};let fa=(e,n,t)=>(n<<e.hash_shift^t)&e.hash_mask,ie=fa;const D=e=>{const n=e.state;let t=n.pending;t>e.avail_out&&(t=e.avail_out),t!==0&&(e.output.set(n.pending_buf.subarray(n.pending_out,n.pending_out+t),e.next_out),e.next_out+=t,n.pending_out+=t,e.total_out+=t,e.avail_out-=t,n.pending-=t,n.pending===0&&(n.pending_out=0))},V=(e,n)=>{Lr(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,n),e.block_start=e.strstart,D(e.strm)},T=(e,n)=>{e.pending_buf[e.pending++]=n},Ce=(e,n)=>{e.pending_buf[e.pending++]=n>>>8&255,e.pending_buf[e.pending++]=n&255},Lt=(e,n,t,i)=>{let r=e.avail_in;return r>i&&(r=i),r===0?0:(e.avail_in-=r,n.set(e.input.subarray(e.next_in,e.next_in+r),t),e.state.wrap===1?e.adler=Be(e.adler,n,r,t):e.state.wrap===2&&(e.adler=z(e.adler,n,r,t)),e.next_in+=r,e.total_in+=r,r)},ui=(e,n)=>{let t=e.max_chain_length,i=e.strstart,r,a,o=e.prev_length,f=e.nice_match;const u=e.strstart>e.w_size-Y?e.strstart-(e.w_size-Y):0,s=e.window,l=e.w_mask,d=e.prev,c=e.strstart+ee;let h=s[i+o-1],_=s[i+o];e.prev_length>=e.good_match&&(t>>=2),f>e.lookahead&&(f=e.lookahead);do if(r=n,!(s[r+o]!==_||s[r+o-1]!==h||s[r]!==s[i]||s[++r]!==s[i+1])){i+=2,r++;do;while(s[++i]===s[++r]&&s[++i]===s[++r]&&s[++i]===s[++r]&&s[++i]===s[++r]&&s[++i]===s[++r]&&s[++i]===s[++r]&&s[++i]===s[++r]&&s[++i]===s[++r]&&i<c);if(a=ee-(c-i),i=c-ee,a>o){if(e.match_start=n,o=a,a>=f)break;h=s[i+o-1],_=s[i+o]}}while((n=d[n&l])>u&&--t!==0);return o<=e.lookahead?o:e.lookahead},me=e=>{const n=e.w_size;let t,i,r;do{if(i=e.window_size-e.lookahead-e.strstart,e.strstart>=n+(n-Y)&&(e.window.set(e.window.subarray(n,n+n-i),0),e.match_start-=n,e.strstart-=n,e.block_start-=n,e.insert>e.strstart&&(e.insert=e.strstart),sa(e),i+=n),e.strm.avail_in===0)break;if(t=Lt(e.strm,e.window,e.strstart+e.lookahead,i),e.lookahead+=t,e.lookahead+e.insert>=I)for(r=e.strstart-e.insert,e.ins_h=e.window[r],e.ins_h=ie(e,e.ins_h,e.window[r+1]);e.insert&&(e.ins_h=ie(e,e.ins_h,e.window[r+I-1]),e.prev[r&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=r,r++,e.insert--,!(e.lookahead+e.insert<I)););}while(e.lookahead<Y&&e.strm.avail_in!==0)},hi=(e,n)=>{let t=e.pending_buf_size-5>e.w_size?e.w_size:e.pending_buf_size-5,i,r,a,o=0,f=e.strm.avail_in;do{if(i=65535,a=e.bi_valid+42>>3,e.strm.avail_out<a||(a=e.strm.avail_out-a,r=e.strstart-e.block_start,i>r+e.strm.avail_in&&(i=r+e.strm.avail_in),i>a&&(i=a),i<t&&(i===0&&n!==L||n===ne||i!==r+e.strm.avail_in)))break;o=n===L&&i===r+e.strm.avail_in?1:0,zt(e,0,0,o),e.pending_buf[e.pending-4]=i,e.pending_buf[e.pending-3]=i>>8,e.pending_buf[e.pending-2]=~i,e.pending_buf[e.pending-1]=~i>>8,D(e.strm),r&&(r>i&&(r=i),e.strm.output.set(e.window.subarray(e.block_start,e.block_start+r),e.strm.next_out),e.strm.next_out+=r,e.strm.avail_out-=r,e.strm.total_out+=r,e.block_start+=r,i-=r),i&&(Lt(e.strm,e.strm.output,e.strm.next_out,i),e.strm.next_out+=i,e.strm.avail_out-=i,e.strm.total_out+=i)}while(o===0);return f-=e.strm.avail_in,f&&(f>=e.w_size?(e.matches=2,e.window.set(e.strm.input.subarray(e.strm.next_in-e.w_size,e.strm.next_in),0),e.strstart=e.w_size,e.insert=e.strstart):(e.window_size-e.strstart<=f&&(e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,e.insert>e.strstart&&(e.insert=e.strstart)),e.window.set(e.strm.input.subarray(e.strm.next_in-f,e.strm.next_in),e.strstart),e.strstart+=f,e.insert+=f>e.w_size-e.insert?e.w_size-e.insert:f),e.block_start=e.strstart),e.high_water<e.strstart&&(e.high_water=e.strstart),o?ke:n!==ne&&n!==L&&e.strm.avail_in===0&&e.strstart===e.block_start?ve:(a=e.window_size-e.strstart,e.strm.avail_in>a&&e.block_start>=e.w_size&&(e.block_start-=e.w_size,e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,a+=e.w_size,e.insert>e.strstart&&(e.insert=e.strstart)),a>e.strm.avail_in&&(a=e.strm.avail_in),a&&(Lt(e.strm,e.window,e.strstart,a),e.strstart+=a,e.insert+=a>e.w_size-e.insert?e.w_size-e.insert:a),e.high_water<e.strstart&&(e.high_water=e.strstart),a=e.bi_valid+42>>3,a=e.pending_buf_size-a>65535?65535:e.pending_buf_size-a,t=a>e.w_size?e.w_size:a,r=e.strstart-e.block_start,(r>=t||(r||n===L)&&n!==ne&&e.strm.avail_in===0&&r<=a)&&(i=r>a?a:r,o=n===L&&e.strm.avail_in===0&&i===r?1:0,zt(e,e.block_start,i,o),e.block_start+=i,D(e.strm)),o?ue:B)},wt=(e,n)=>{let t,i;for(;;){if(e.lookahead<Y){if(me(e),e.lookahead<Y&&n===ne)return B;if(e.lookahead===0)break}if(t=0,e.lookahead>=I&&(e.ins_h=ie(e,e.ins_h,e.window[e.strstart+I-1]),t=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),t!==0&&e.strstart-t<=e.w_size-Y&&(e.match_length=ui(e,t)),e.match_length>=I)if(i=te(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=ie(e,e.ins_h,e.window[e.strstart+I-1]),t=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=ie(e,e.ins_h,e.window[e.strstart+1]);else i=te(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(i&&(V(e,!1),e.strm.avail_out===0))return B}return e.insert=e.strstart<I-1?e.strstart:I-1,n===L?(V(e,!0),e.strm.avail_out===0?ue:ke):e.sym_next&&(V(e,!1),e.strm.avail_out===0)?B:ve},de=(e,n)=>{let t,i,r;for(;;){if(e.lookahead<Y){if(me(e),e.lookahead<Y&&n===ne)return B;if(e.lookahead===0)break}if(t=0,e.lookahead>=I&&(e.ins_h=ie(e,e.ins_h,e.window[e.strstart+I-1]),t=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,t!==0&&e.prev_length<e.max_lazy_match&&e.strstart-t<=e.w_size-Y&&(e.match_length=ui(e,t),e.match_length<=5&&(e.strategy===jr||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){r=e.strstart+e.lookahead-I,i=te(e,e.strstart-1-e.prev_match,e.prev_length-I),e.lookahead-=e.prev_length-1,e.prev_length-=2;do++e.strstart<=r&&(e.ins_h=ie(e,e.ins_h,e.window[e.strstart+I-1]),t=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++,i&&(V(e,!1),e.strm.avail_out===0))return B}else if(e.match_available){if(i=te(e,0,e.window[e.strstart-1]),i&&V(e,!1),e.strstart++,e.lookahead--,e.strm.avail_out===0)return B}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(i=te(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<I-1?e.strstart:I-1,n===L?(V(e,!0),e.strm.avail_out===0?ue:ke):e.sym_next&&(V(e,!1),e.strm.avail_out===0)?B:ve},la=(e,n)=>{let t,i,r,a;const o=e.window;for(;;){if(e.lookahead<=ee){if(me(e),e.lookahead<=ee&&n===ne)return B;if(e.lookahead===0)break}if(e.match_length=0,e.lookahead>=I&&e.strstart>0&&(r=e.strstart-1,i=o[r],i===o[++r]&&i===o[++r]&&i===o[++r])){a=e.strstart+ee;do;while(i===o[++r]&&i===o[++r]&&i===o[++r]&&i===o[++r]&&i===o[++r]&&i===o[++r]&&i===o[++r]&&i===o[++r]&&r<a);e.match_length=ee-(a-r),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=I?(t=te(e,1,e.match_length-I),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(t=te(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),t&&(V(e,!1),e.strm.avail_out===0))return B}return e.insert=0,n===L?(V(e,!0),e.strm.avail_out===0?ue:ke):e.sym_next&&(V(e,!1),e.strm.avail_out===0)?B:ve},ua=(e,n)=>{let t;for(;;){if(e.lookahead===0&&(me(e),e.lookahead===0)){if(n===ne)return B;break}if(e.match_length=0,t=te(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,t&&(V(e,!1),e.strm.avail_out===0))return B}return e.insert=0,n===L?(V(e,!0),e.strm.avail_out===0?ue:ke):e.sym_next&&(V(e,!1),e.strm.avail_out===0)?B:ve};function H(e,n,t,i,r){this.good_length=e,this.max_lazy=n,this.nice_length=t,this.max_chain=i,this.func=r}const xe=[new H(0,0,0,0,hi),new H(4,4,8,4,wt),new H(4,5,16,8,wt),new H(4,6,32,32,wt),new H(4,4,16,16,de),new H(8,16,32,32,de),new H(8,16,128,128,de),new H(8,32,128,256,de),new H(32,128,258,1024,de),new H(32,258,258,4096,de)],ha=e=>{e.window_size=2*e.w_size,J(e.head),e.max_lazy_match=xe[e.level].max_lazy,e.good_match=xe[e.level].good_length,e.nice_match=xe[e.level].nice_length,e.max_chain_length=xe[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 ca(){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=ut,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 Uint16Array(ia*2),this.dyn_dtree=new Uint16Array((2*ta+1)*2),this.bl_tree=new Uint16Array((2*na+1)*2),J(this.dyn_ltree),J(this.dyn_dtree),J(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(ra+1),this.heap=new Uint16Array(2*Rt+1),J(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*Rt+1),J(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const Me=e=>{if(!e)return 1;const n=e.state;return!n||n.strm!==e||n.status!==we&&n.status!==Gt&&n.status!==Bt&&n.status!==Ut&&n.status!==Dt&&n.status!==Vt&&n.status!==fe&&n.status!==Se?1:0},ci=e=>{if(Me(e))return le(e,G);e.total_in=e.total_out=0,e.data_type=Wr;const n=e.state;return n.pending=0,n.pending_out=0,n.wrap<0&&(n.wrap=-n.wrap),n.status=n.wrap===2?Gt:n.wrap?we:fe,e.adler=n.wrap===2?0:1,n.last_flush=-2,Vr(n),R},di=e=>{const n=ci(e);return n===R&&ha(e.state),n},da=(e,n)=>Me(e)||e.state.wrap!==2?G:(e.state.gzhead=n,R),pi=(e,n,t,i,r,a)=>{if(!e)return G;let o=1;if(n===Hr&&(n=6),i<0?(o=0,i=-i):i>15&&(o=2,i-=16),r<1||r>Xr||t!==ut||i<8||i>15||n<0||n>9||a<0||a>Yr||i===8&&o!==1)return le(e,G);i===8&&(i=9);const f=new ca;return e.state=f,f.strm=e,f.status=we,f.wrap=o,f.gzhead=null,f.w_bits=i,f.w_size=1<<f.w_bits,f.w_mask=f.w_size-1,f.hash_bits=r+7,f.hash_size=1<<f.hash_bits,f.hash_mask=f.hash_size-1,f.hash_shift=~~((f.hash_bits+I-1)/I),f.window=new Uint8Array(f.w_size*2),f.head=new Uint16Array(f.hash_size),f.prev=new Uint16Array(f.w_size),f.lit_bufsize=1<<r+6,f.pending_buf_size=f.lit_bufsize*4,f.pending_buf=new Uint8Array(f.pending_buf_size),f.sym_buf=f.lit_bufsize,f.sym_end=(f.lit_bufsize-1)*3,f.level=n,f.strategy=a,f.method=t,di(e)},pa=(e,n)=>pi(e,n,ut,qr,Jr,Kr),_a=(e,n)=>{if(Me(e)||n>fn||n<0)return e?le(e,G):G;const t=e.state;if(!e.output||e.avail_in!==0&&!e.input||t.status===Se&&n!==L)return le(e,e.avail_out===0?gt:G);const i=t.last_flush;if(t.last_flush=n,t.pending!==0){if(D(e),e.avail_out===0)return t.last_flush=-1,R}else if(e.avail_in===0&&un(n)<=un(i)&&n!==L)return le(e,gt);if(t.status===Se&&e.avail_in!==0)return le(e,gt);if(t.status===we&&t.wrap===0&&(t.status=fe),t.status===we){let r=ut+(t.w_bits-8<<4)<<8,a=-1;if(t.strategy>=We||t.level<2?a=0:t.level<6?a=1:t.level===6?a=2:a=3,r|=a<<6,t.strstart!==0&&(r|=aa),r+=31-r%31,Ce(t,r),t.strstart!==0&&(Ce(t,e.adler>>>16),Ce(t,e.adler&65535)),e.adler=1,t.status=fe,D(e),t.pending!==0)return t.last_flush=-1,R}if(t.status===Gt){if(e.adler=0,T(t,31),T(t,139),T(t,8),t.gzhead)T(t,(t.gzhead.text?1:0)+(t.gzhead.hcrc?2:0)+(t.gzhead.extra?4:0)+(t.gzhead.name?8:0)+(t.gzhead.comment?16:0)),T(t,t.gzhead.time&255),T(t,t.gzhead.time>>8&255),T(t,t.gzhead.time>>16&255),T(t,t.gzhead.time>>24&255),T(t,t.level===9?2:t.strategy>=We||t.level<2?4:0),T(t,t.gzhead.os&255),t.gzhead.extra&&t.gzhead.extra.length&&(T(t,t.gzhead.extra.length&255),T(t,t.gzhead.extra.length>>8&255)),t.gzhead.hcrc&&(e.adler=z(e.adler,t.pending_buf,t.pending,0)),t.gzindex=0,t.status=Bt;else if(T(t,0),T(t,0),T(t,0),T(t,0),T(t,0),T(t,t.level===9?2:t.strategy>=We||t.level<2?4:0),T(t,oa),t.status=fe,D(e),t.pending!==0)return t.last_flush=-1,R}if(t.status===Bt){if(t.gzhead.extra){let r=t.pending,a=(t.gzhead.extra.length&65535)-t.gzindex;for(;t.pending+a>t.pending_buf_size;){let f=t.pending_buf_size-t.pending;if(t.pending_buf.set(t.gzhead.extra.subarray(t.gzindex,t.gzindex+f),t.pending),t.pending=t.pending_buf_size,t.gzhead.hcrc&&t.pending>r&&(e.adler=z(e.adler,t.pending_buf,t.pending-r,r)),t.gzindex+=f,D(e),t.pending!==0)return t.last_flush=-1,R;r=0,a-=f}let o=new Uint8Array(t.gzhead.extra);t.pending_buf.set(o.subarray(t.gzindex,t.gzindex+a),t.pending),t.pending+=a,t.gzhead.hcrc&&t.pending>r&&(e.adler=z(e.adler,t.pending_buf,t.pending-r,r)),t.gzindex=0}t.status=Ut}if(t.status===Ut){if(t.gzhead.name){let r=t.pending,a;do{if(t.pending===t.pending_buf_size){if(t.gzhead.hcrc&&t.pending>r&&(e.adler=z(e.adler,t.pending_buf,t.pending-r,r)),D(e),t.pending!==0)return t.last_flush=-1,R;r=0}t.gzindex<t.gzhead.name.length?a=t.gzhead.name.charCodeAt(t.gzindex++)&255:a=0,T(t,a)}while(a!==0);t.gzhead.hcrc&&t.pending>r&&(e.adler=z(e.adler,t.pending_buf,t.pending-r,r)),t.gzindex=0}t.status=Dt}if(t.status===Dt){if(t.gzhead.comment){let r=t.pending,a;do{if(t.pending===t.pending_buf_size){if(t.gzhead.hcrc&&t.pending>r&&(e.adler=z(e.adler,t.pending_buf,t.pending-r,r)),D(e),t.pending!==0)return t.last_flush=-1,R;r=0}t.gzindex<t.gzhead.comment.length?a=t.gzhead.comment.charCodeAt(t.gzindex++)&255:a=0,T(t,a)}while(a!==0);t.gzhead.hcrc&&t.pending>r&&(e.adler=z(e.adler,t.pending_buf,t.pending-r,r))}t.status=Vt}if(t.status===Vt){if(t.gzhead.hcrc){if(t.pending+2>t.pending_buf_size&&(D(e),t.pending!==0))return t.last_flush=-1,R;T(t,e.adler&255),T(t,e.adler>>8&255),e.adler=0}if(t.status=fe,D(e),t.pending!==0)return t.last_flush=-1,R}if(e.avail_in!==0||t.lookahead!==0||n!==ne&&t.status!==Se){let r=t.level===0?hi(t,n):t.strategy===We?ua(t,n):t.strategy===Gr?la(t,n):xe[t.level].func(t,n);if((r===ue||r===ke)&&(t.status=Se),r===B||r===ue)return e.avail_out===0&&(t.last_flush=-1),R;if(r===ve&&(n===Pr?Fr(t):n!==fn&&(zt(t,0,0,!1),n===Zr&&(J(t.head),t.lookahead===0&&(t.strstart=0,t.block_start=0,t.insert=0))),D(e),e.avail_out===0))return t.last_flush=-1,R}return n!==L?R:t.wrap<=0?ln:(t.wrap===2?(T(t,e.adler&255),T(t,e.adler>>8&255),T(t,e.adler>>16&255),T(t,e.adler>>24&255),T(t,e.total_in&255),T(t,e.total_in>>8&255),T(t,e.total_in>>16&255),T(t,e.total_in>>24&255)):(Ce(t,e.adler>>>16),Ce(t,e.adler&65535)),D(e),t.wrap>0&&(t.wrap=-t.wrap),t.pending!==0?R:ln)},ba=e=>{if(Me(e))return G;const n=e.state.status;return e.state=null,n===fe?le(e,Mr):R},ga=(e,n)=>{let t=n.length;if(Me(e))return G;const i=e.state,r=i.wrap;if(r===2||r===1&&i.status!==we||i.lookahead)return G;if(r===1&&(e.adler=Be(e.adler,n,t,0)),i.wrap=0,t>=i.w_size){r===0&&(J(i.head),i.strstart=0,i.block_start=0,i.insert=0);let u=new Uint8Array(i.w_size);u.set(n.subarray(t-i.w_size,t),0),n=u,t=i.w_size}const a=e.avail_in,o=e.next_in,f=e.input;for(e.avail_in=t,e.next_in=0,e.input=n,me(i);i.lookahead>=I;){let u=i.strstart,s=i.lookahead-(I-1);do i.ins_h=ie(i,i.ins_h,i.window[u+I-1]),i.prev[u&i.w_mask]=i.head[i.ins_h],i.head[i.ins_h]=u,u++;while(--s);i.strstart=u,i.lookahead=I-1,me(i)}return i.strstart+=i.lookahead,i.block_start=i.strstart,i.insert=i.lookahead,i.lookahead=0,i.match_length=i.prev_length=I-1,i.match_available=0,e.next_in=o,e.input=f,e.avail_in=a,i.wrap=r,R};var wa=pa,ma=pi,ya=di,va=ci,ka=da,$a=_a,Ea=ba,Ca=ga,Sa="pako deflate (from Nodeca project)",Ie={deflateInit:wa,deflateInit2:ma,deflateReset:ya,deflateResetKeep:va,deflateSetHeader:ka,deflate:$a,deflateEnd:Ea,deflateSetDictionary:Ca,deflateInfo:Sa};const xa=(e,n)=>Object.prototype.hasOwnProperty.call(e,n);var Na=function(e){const n=Array.prototype.slice.call(arguments,1);for(;n.length;){const t=n.shift();if(t){if(typeof t!="object")throw new TypeError(t+"must be non-object");for(const i in t)xa(t,i)&&(e[i]=t[i])}}return e},Ia=e=>{let n=0;for(let i=0,r=e.length;i<r;i++)n+=e[i].length;const t=new Uint8Array(n);for(let i=0,r=0,a=e.length;i<a;i++){let o=e[i];t.set(o,r),r+=o.length}return t},ht={assign:Na,flattenChunks:Ia};let _i=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{_i=!1}const Ue=new Uint8Array(256);for(let e=0;e<256;e++)Ue[e]=e>=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;Ue[254]=Ue[254]=1;var Ta=e=>{if(typeof TextEncoder=="function"&&TextEncoder.prototype.encode)return new TextEncoder().encode(e);let n,t,i,r,a,o=e.length,f=0;for(r=0;r<o;r++)t=e.charCodeAt(r),(t&64512)===55296&&r+1<o&&(i=e.charCodeAt(r+1),(i&64512)===56320&&(t=65536+(t-55296<<10)+(i-56320),r++)),f+=t<128?1:t<2048?2:t<65536?3:4;for(n=new Uint8Array(f),a=0,r=0;a<f;r++)t=e.charCodeAt(r),(t&64512)===55296&&r+1<o&&(i=e.charCodeAt(r+1),(i&64512)===56320&&(t=65536+(t-55296<<10)+(i-56320),r++)),t<128?n[a++]=t:t<2048?(n[a++]=192|t>>>6,n[a++]=128|t&63):t<65536?(n[a++]=224|t>>>12,n[a++]=128|t>>>6&63,n[a++]=128|t&63):(n[a++]=240|t>>>18,n[a++]=128|t>>>12&63,n[a++]=128|t>>>6&63,n[a++]=128|t&63);return n};const Aa=(e,n)=>{if(n<65534&&e.subarray&&_i)return String.fromCharCode.apply(null,e.length===n?e:e.subarray(0,n));let t="";for(let i=0;i<n;i++)t+=String.fromCharCode(e[i]);return t};var Oa=(e,n)=>{const t=n||e.length;if(typeof TextDecoder=="function"&&TextDecoder.prototype.decode)return new TextDecoder().decode(e.subarray(0,n));let i,r;const a=new Array(t*2);for(r=0,i=0;i<t;){let o=e[i++];if(o<128){a[r++]=o;continue}let f=Ue[o];if(f>4){a[r++]=65533,i+=f-1;continue}for(o&=f===2?31:f===3?15:7;f>1&&i<t;)o=o<<6|e[i++]&63,f--;if(f>1){a[r++]=65533;continue}o<65536?a[r++]=o:(o-=65536,a[r++]=55296|o>>10&1023,a[r++]=56320|o&1023)}return Aa(a,r)},za=(e,n)=>{n=n||e.length,n>e.length&&(n=e.length);let t=n-1;for(;t>=0&&(e[t]&192)===128;)t--;return t<0||t===0?n:t+Ue[e[t]]>n?t:n},De={string2buf:Ta,buf2string:Oa,utf8border:za};function Ra(){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}var bi=Ra;const gi=Object.prototype.toString,{Z_NO_FLUSH:Ba,Z_SYNC_FLUSH:Ua,Z_FULL_FLUSH:Da,Z_FINISH:Va,Z_OK:rt,Z_STREAM_END:La,Z_DEFAULT_COMPRESSION:Fa,Z_DEFAULT_STRATEGY:Pa,Z_DEFLATED:Za}=Ze;function Yt(e){this.options=ht.assign({level:Fa,method:Za,chunkSize:16384,windowBits:15,memLevel:8,strategy:Pa},e||{});let n=this.options;n.raw&&n.windowBits>0?n.windowBits=-n.windowBits:n.gzip&&n.windowBits>0&&n.windowBits<16&&(n.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new bi,this.strm.avail_out=0;let t=Ie.deflateInit2(this.strm,n.level,n.method,n.windowBits,n.memLevel,n.strategy);if(t!==rt)throw new Error(ge[t]);if(n.header&&Ie.deflateSetHeader(this.strm,n.header),n.dictionary){let i;if(typeof n.dictionary=="string"?i=De.string2buf(n.dictionary):gi.call(n.dictionary)==="[object ArrayBuffer]"?i=new Uint8Array(n.dictionary):i=n.dictionary,t=Ie.deflateSetDictionary(this.strm,i),t!==rt)throw new Error(ge[t]);this._dict_set=!0}}Yt.prototype.push=function(e,n){const t=this.strm,i=this.options.chunkSize;let r,a;if(this.ended)return!1;for(n===~~n?a=n:a=n===!0?Va:Ba,typeof e=="string"?t.input=De.string2buf(e):gi.call(e)==="[object ArrayBuffer]"?t.input=new Uint8Array(e):t.input=e,t.next_in=0,t.avail_in=t.input.length;;){if(t.avail_out===0&&(t.output=new Uint8Array(i),t.next_out=0,t.avail_out=i),(a===Ua||a===Da)&&t.avail_out<=6){this.onData(t.output.subarray(0,t.next_out)),t.avail_out=0;continue}if(r=Ie.deflate(t,a),r===La)return t.next_out>0&&this.onData(t.output.subarray(0,t.next_out)),r=Ie.deflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===rt;if(t.avail_out===0){this.onData(t.output);continue}if(a>0&&t.next_out>0){this.onData(t.output.subarray(0,t.next_out)),t.avail_out=0;continue}if(t.avail_in===0)break}return!0};Yt.prototype.onData=function(e){this.chunks.push(e)};Yt.prototype.onEnd=function(e){e===rt&&(this.result=ht.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};const Xe=16209,Ma=16191;var Ha=function(n,t){let i,r,a,o,f,u,s,l,d,c,h,_,g,k,y,E,C,p,$,S,b,w,m,v;const N=n.state;i=n.next_in,m=n.input,r=i+(n.avail_in-5),a=n.next_out,v=n.output,o=a-(t-n.avail_out),f=a+(n.avail_out-257),u=N.dmax,s=N.wsize,l=N.whave,d=N.wnext,c=N.window,h=N.hold,_=N.bits,g=N.lencode,k=N.distcode,y=(1<<N.lenbits)-1,E=(1<<N.distbits)-1;e:do{_<15&&(h+=m[i++]<<_,_+=8,h+=m[i++]<<_,_+=8),C=g[h&y];t:for(;;){if(p=C>>>24,h>>>=p,_-=p,p=C>>>16&255,p===0)v[a++]=C&65535;else if(p&16){$=C&65535,p&=15,p&&(_<p&&(h+=m[i++]<<_,_+=8),$+=h&(1<<p)-1,h>>>=p,_-=p),_<15&&(h+=m[i++]<<_,_+=8,h+=m[i++]<<_,_+=8),C=k[h&E];n:for(;;){if(p=C>>>24,h>>>=p,_-=p,p=C>>>16&255,p&16){if(S=C&65535,p&=15,_<p&&(h+=m[i++]<<_,_+=8,_<p&&(h+=m[i++]<<_,_+=8)),S+=h&(1<<p)-1,S>u){n.msg="invalid distance too far back",N.mode=Xe;break e}if(h>>>=p,_-=p,p=a-o,S>p){if(p=S-p,p>l&&N.sane){n.msg="invalid distance too far back",N.mode=Xe;break e}if(b=0,w=c,d===0){if(b+=s-p,p<$){$-=p;do v[a++]=c[b++];while(--p);b=a-S,w=v}}else if(d<p){if(b+=s+d-p,p-=d,p<$){$-=p;do v[a++]=c[b++];while(--p);if(b=0,d<$){p=d,$-=p;do v[a++]=c[b++];while(--p);b=a-S,w=v}}}else if(b+=d-p,p<$){$-=p;do v[a++]=c[b++];while(--p);b=a-S,w=v}for(;$>2;)v[a++]=w[b++],v[a++]=w[b++],v[a++]=w[b++],$-=3;$&&(v[a++]=w[b++],$>1&&(v[a++]=w[b++]))}else{b=a-S;do v[a++]=v[b++],v[a++]=v[b++],v[a++]=v[b++],$-=3;while($>2);$&&(v[a++]=v[b++],$>1&&(v[a++]=v[b++]))}}else if(p&64){n.msg="invalid distance code",N.mode=Xe;break e}else{C=k[(C&65535)+(h&(1<<p)-1)];continue n}break}}else if(p&64)if(p&32){N.mode=Ma;break e}else{n.msg="invalid literal/length code",N.mode=Xe;break e}else{C=g[(C&65535)+(h&(1<<p)-1)];continue t}break}}while(i<r&&a<f);$=_>>3,i-=$,_-=$<<3,h&=(1<<_)-1,n.next_in=i,n.next_out=a,n.avail_in=i<r?5+(r-i):5-(i-r),n.avail_out=a<f?257+(f-a):257-(a-f),N.hold=h,N.bits=_};const pe=15,hn=852,cn=592,dn=0,mt=1,pn=2,ja=new Uint16Array([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]),Ga=new Uint8Array([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]),Ya=new Uint16Array([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]),Ka=new Uint8Array([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]),Wa=(e,n,t,i,r,a,o,f)=>{const u=f.bits;let s=0,l=0,d=0,c=0,h=0,_=0,g=0,k=0,y=0,E=0,C,p,$,S,b,w=null,m;const v=new Uint16Array(pe+1),N=new Uint16Array(pe+1);let ae=null,Qt,je,Ge;for(s=0;s<=pe;s++)v[s]=0;for(l=0;l<i;l++)v[n[t+l]]++;for(h=u,c=pe;c>=1&&v[c]===0;c--);if(h>c&&(h=c),c===0)return r[a++]=1<<24|64<<16|0,r[a++]=1<<24|64<<16|0,f.bits=1,0;for(d=1;d<c&&v[d]===0;d++);for(h<d&&(h=d),k=1,s=1;s<=pe;s++)if(k<<=1,k-=v[s],k<0)return-1;if(k>0&&(e===dn||c!==1))return-1;for(N[1]=0,s=1;s<pe;s++)N[s+1]=N[s]+v[s];for(l=0;l<i;l++)n[t+l]!==0&&(o[N[n[t+l]]++]=l);if(e===dn?(w=ae=o,m=20):e===mt?(w=ja,ae=Ga,m=257):(w=Ya,ae=Ka,m=0),E=0,l=0,s=d,b=a,_=h,g=0,$=-1,y=1<<h,S=y-1,e===mt&&y>hn||e===pn&&y>cn)return 1;for(;;){Qt=s-g,o[l]+1<m?(je=0,Ge=o[l]):o[l]>=m?(je=ae[o[l]-m],Ge=w[o[l]-m]):(je=32+64,Ge=0),C=1<<s-g,p=1<<_,d=p;do p-=C,r[b+(E>>g)+p]=Qt<<24|je<<16|Ge|0;while(p!==0);for(C=1<<s-1;E&C;)C>>=1;if(C!==0?(E&=C-1,E+=C):E=0,l++,--v[s]===0){if(s===c)break;s=n[t+o[l]]}if(s>h&&(E&S)!==$){for(g===0&&(g=h),b+=d,_=s-g,k=1<<_;_+g<c&&(k-=v[_+g],!(k<=0));)_++,k<<=1;if(y+=1<<_,e===mt&&y>hn||e===pn&&y>cn)return 1;$=E&S,r[$]=h<<24|_<<16|b-a|0}}return E!==0&&(r[b+E]=s-g<<24|64<<16|0),f.bits=h,0};var Te=Wa;const Xa=0,wi=1,mi=2,{Z_FINISH:_n,Z_BLOCK:qa,Z_TREES:qe,Z_OK:he,Z_STREAM_END:Ja,Z_NEED_DICT:Qa,Z_STREAM_ERROR:F,Z_DATA_ERROR:yi,Z_MEM_ERROR:vi,Z_BUF_ERROR:eo,Z_DEFLATED:bn}=Ze,ct=16180,gn=16181,wn=16182,mn=16183,yn=16184,vn=16185,kn=16186,$n=16187,En=16188,Cn=16189,at=16190,K=16191,yt=16192,Sn=16193,vt=16194,xn=16195,Nn=16196,In=16197,Tn=16198,Je=16199,Qe=16200,An=16201,On=16202,zn=16203,Rn=16204,Bn=16205,kt=16206,Un=16207,Dn=16208,A=16209,ki=16210,$i=16211,to=852,no=592,io=15,ro=io,Vn=e=>(e>>>24&255)+(e>>>8&65280)+((e&65280)<<8)+((e&255)<<24);function ao(){this.strm=null,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 Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const ce=e=>{if(!e)return 1;const n=e.state;return!n||n.strm!==e||n.mode<ct||n.mode>$i?1:0},Ei=e=>{if(ce(e))return F;const n=e.state;return e.total_in=e.total_out=n.total=0,e.msg="",n.wrap&&(e.adler=n.wrap&1),n.mode=ct,n.last=0,n.havedict=0,n.flags=-1,n.dmax=32768,n.head=null,n.hold=0,n.bits=0,n.lencode=n.lendyn=new Int32Array(to),n.distcode=n.distdyn=new Int32Array(no),n.sane=1,n.back=-1,he},Ci=e=>{if(ce(e))return F;const n=e.state;return n.wsize=0,n.whave=0,n.wnext=0,Ei(e)},Si=(e,n)=>{let t;if(ce(e))return F;const i=e.state;return n<0?(t=0,n=-n):(t=(n>>4)+5,n<48&&(n&=15)),n&&(n<8||n>15)?F:(i.window!==null&&i.wbits!==n&&(i.window=null),i.wrap=t,i.wbits=n,Ci(e))},xi=(e,n)=>{if(!e)return F;const t=new ao;e.state=t,t.strm=e,t.window=null,t.mode=ct;const i=Si(e,n);return i!==he&&(e.state=null),i},oo=e=>xi(e,ro);let Ln=!0,$t,Et;const so=e=>{if(Ln){$t=new Int32Array(512),Et=new Int32Array(32);let n=0;for(;n<144;)e.lens[n++]=8;for(;n<256;)e.lens[n++]=9;for(;n<280;)e.lens[n++]=7;for(;n<288;)e.lens[n++]=8;for(Te(wi,e.lens,0,288,$t,0,e.work,{bits:9}),n=0;n<32;)e.lens[n++]=5;Te(mi,e.lens,0,32,Et,0,e.work,{bits:5}),Ln=!1}e.lencode=$t,e.lenbits=9,e.distcode=Et,e.distbits=5},Ni=(e,n,t,i)=>{let r;const a=e.state;return a.window===null&&(a.wsize=1<<a.wbits,a.wnext=0,a.whave=0,a.window=new Uint8Array(a.wsize)),i>=a.wsize?(a.window.set(n.subarray(t-a.wsize,t),0),a.wnext=0,a.whave=a.wsize):(r=a.wsize-a.wnext,r>i&&(r=i),a.window.set(n.subarray(t-i,t-i+r),a.wnext),i-=r,i?(a.window.set(n.subarray(t-i,t),0),a.wnext=i,a.whave=a.wsize):(a.wnext+=r,a.wnext===a.wsize&&(a.wnext=0),a.whave<a.wsize&&(a.whave+=r))),0},fo=(e,n)=>{let t,i,r,a,o,f,u,s,l,d,c,h,_,g,k=0,y,E,C,p,$,S,b,w;const m=new Uint8Array(4);let v,N;const ae=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(ce(e)||!e.output||!e.input&&e.avail_in!==0)return F;t=e.state,t.mode===K&&(t.mode=yt),o=e.next_out,r=e.output,u=e.avail_out,a=e.next_in,i=e.input,f=e.avail_in,s=t.hold,l=t.bits,d=f,c=u,w=he;e:for(;;)switch(t.mode){case ct:if(t.wrap===0){t.mode=yt;break}for(;l<16;){if(f===0)break e;f--,s+=i[a++]<<l,l+=8}if(t.wrap&2&&s===35615){t.wbits===0&&(t.wbits=15),t.check=0,m[0]=s&255,m[1]=s>>>8&255,t.check=z(t.check,m,2,0),s=0,l=0,t.mode=gn;break}if(t.head&&(t.head.done=!1),!(t.wrap&1)||(((s&255)<<8)+(s>>8))%31){e.msg="incorrect header check",t.mode=A;break}if((s&15)!==bn){e.msg="unknown compression method",t.mode=A;break}if(s>>>=4,l-=4,b=(s&15)+8,t.wbits===0&&(t.wbits=b),b>15||b>t.wbits){e.msg="invalid window size",t.mode=A;break}t.dmax=1<<t.wbits,t.flags=0,e.adler=t.check=1,t.mode=s&512?Cn:K,s=0,l=0;break;case gn:for(;l<16;){if(f===0)break e;f--,s+=i[a++]<<l,l+=8}if(t.flags=s,(t.flags&255)!==bn){e.msg="unknown compression method",t.mode=A;break}if(t.flags&57344){e.msg="unknown header flags set",t.mode=A;break}t.head&&(t.head.text=s>>8&1),t.flags&512&&t.wrap&4&&(m[0]=s&255,m[1]=s>>>8&255,t.check=z(t.check,m,2,0)),s=0,l=0,t.mode=wn;case wn:for(;l<32;){if(f===0)break e;f--,s+=i[a++]<<l,l+=8}t.head&&(t.head.time=s),t.flags&512&&t.wrap&4&&(m[0]=s&255,m[1]=s>>>8&255,m[2]=s>>>16&255,m[3]=s>>>24&255,t.check=z(t.check,m,4,0)),s=0,l=0,t.mode=mn;case mn:for(;l<16;){if(f===0)break e;f--,s+=i[a++]<<l,l+=8}t.head&&(t.head.xflags=s&255,t.head.os=s>>8),t.flags&512&&t.wrap&4&&(m[0]=s&255,m[1]=s>>>8&255,t.check=z(t.check,m,2,0)),s=0,l=0,t.mode=yn;case yn:if(t.flags&1024){for(;l<16;){if(f===0)break e;f--,s+=i[a++]<<l,l+=8}t.length=s,t.head&&(t.head.extra_len=s),t.flags&512&&t.wrap&4&&(m[0]=s&255,m[1]=s>>>8&255,t.check=z(t.check,m,2,0)),s=0,l=0}else t.head&&(t.head.extra=null);t.mode=vn;case vn:if(t.flags&1024&&(h=t.length,h>f&&(h=f),h&&(t.head&&(b=t.head.extra_len-t.length,t.head.extra||(t.head.extra=new Uint8Array(t.head.extra_len)),t.head.extra.set(i.subarray(a,a+h),b)),t.flags&512&&t.wrap&4&&(t.check=z(t.check,i,h,a)),f-=h,a+=h,t.length-=h),t.length))break e;t.length=0,t.mode=kn;case kn:if(t.flags&2048){if(f===0)break e;h=0;do b=i[a+h++],t.head&&b&&t.length<65536&&(t.head.name+=String.fromCharCode(b));while(b&&h<f);if(t.flags&512&&t.wrap&4&&(t.check=z(t.check,i,h,a)),f-=h,a+=h,b)break e}else t.head&&(t.head.name=null);t.length=0,t.mode=$n;case $n:if(t.flags&4096){if(f===0)break e;h=0;do b=i[a+h++],t.head&&b&&t.length<65536&&(t.head.comment+=String.fromCharCode(b));while(b&&h<f);if(t.flags&512&&t.wrap&4&&(t.check=z(t.check,i,h,a)),f-=h,a+=h,b)break e}else t.head&&(t.head.comment=null);t.mode=En;case En:if(t.flags&512){for(;l<16;){if(f===0)break e;f--,s+=i[a++]<<l,l+=8}if(t.wrap&4&&s!==(t.check&65535)){e.msg="header crc mismatch",t.mode=A;break}s=0,l=0}t.head&&(t.head.hcrc=t.flags>>9&1,t.head.done=!0),e.adler=t.check=0,t.mode=K;break;case Cn:for(;l<32;){if(f===0)break e;f--,s+=i[a++]<<l,l+=8}e.adler=t.check=Vn(s),s=0,l=0,t.mode=at;case at:if(t.havedict===0)return e.next_out=o,e.avail_out=u,e.next_in=a,e.avail_in=f,t.hold=s,t.bits=l,Qa;e.adler=t.check=1,t.mode=K;case K:if(n===qa||n===qe)break e;case yt:if(t.last){s>>>=l&7,l-=l&7,t.mode=kt;break}for(;l<3;){if(f===0)break e;f--,s+=i[a++]<<l,l+=8}switch(t.last=s&1,s>>>=1,l-=1,s&3){case 0:t.mode=Sn;break;case 1:if(so(t),t.mode=Je,n===qe){s>>>=2,l-=2;break e}break;case 2:t.mode=Nn;break;case 3:e.msg="invalid block type",t.mode=A}s>>>=2,l-=2;break;case Sn:for(s>>>=l&7,l-=l&7;l<32;){if(f===0)break e;f--,s+=i[a++]<<l,l+=8}if((s&65535)!==(s>>>16^65535)){e.msg="invalid stored block lengths",t.mode=A;break}if(t.length=s&65535,s=0,l=0,t.mode=vt,n===qe)break e;case vt:t.mode=xn;case xn:if(h=t.length,h){if(h>f&&(h=f),h>u&&(h=u),h===0)break e;r.set(i.subarray(a,a+h),o),f-=h,a+=h,u-=h,o+=h,t.length-=h;break}t.mode=K;break;case Nn:for(;l<14;){if(f===0)break e;f--,s+=i[a++]<<l,l+=8}if(t.nlen=(s&31)+257,s>>>=5,l-=5,t.ndist=(s&31)+1,s>>>=5,l-=5,t.ncode=(s&15)+4,s>>>=4,l-=4,t.nlen>286||t.ndist>30){e.msg="too many length or distance symbols",t.mode=A;break}t.have=0,t.mode=In;case In:for(;t.have<t.ncode;){for(;l<3;){if(f===0)break e;f--,s+=i[a++]<<l,l+=8}t.lens[ae[t.have++]]=s&7,s>>>=3,l-=3}for(;t.have<19;)t.lens[ae[t.have++]]=0;if(t.lencode=t.lendyn,t.lenbits=7,v={bits:t.lenbits},w=Te(Xa,t.lens,0,19,t.lencode,0,t.work,v),t.lenbits=v.bits,w){e.msg="invalid code lengths set",t.mode=A;break}t.have=0,t.mode=Tn;case Tn:for(;t.have<t.nlen+t.ndist;){for(;k=t.lencode[s&(1<<t.lenbits)-1],y=k>>>24,E=k>>>16&255,C=k&65535,!(y<=l);){if(f===0)break e;f--,s+=i[a++]<<l,l+=8}if(C<16)s>>>=y,l-=y,t.lens[t.have++]=C;else{if(C===16){for(N=y+2;l<N;){if(f===0)break e;f--,s+=i[a++]<<l,l+=8}if(s>>>=y,l-=y,t.have===0){e.msg="invalid bit length repeat",t.mode=A;break}b=t.lens[t.have-1],h=3+(s&3),s>>>=2,l-=2}else if(C===17){for(N=y+3;l<N;){if(f===0)break e;f--,s+=i[a++]<<l,l+=8}s>>>=y,l-=y,b=0,h=3+(s&7),s>>>=3,l-=3}else{for(N=y+7;l<N;){if(f===0)break e;f--,s+=i[a++]<<l,l+=8}s>>>=y,l-=y,b=0,h=11+(s&127),s>>>=7,l-=7}if(t.have+h>t.nlen+t.ndist){e.msg="invalid bit length repeat",t.mode=A;break}for(;h--;)t.lens[t.have++]=b}}if(t.mode===A)break;if(t.lens[256]===0){e.msg="invalid code -- missing end-of-block",t.mode=A;break}if(t.lenbits=9,v={bits:t.lenbits},w=Te(wi,t.lens,0,t.nlen,t.lencode,0,t.work,v),t.lenbits=v.bits,w){e.msg="invalid literal/lengths set",t.mode=A;break}if(t.distbits=6,t.distcode=t.distdyn,v={bits:t.distbits},w=Te(mi,t.lens,t.nlen,t.ndist,t.distcode,0,t.work,v),t.distbits=v.bits,w){e.msg="invalid distances set",t.mode=A;break}if(t.mode=Je,n===qe)break e;case Je:t.mode=Qe;case Qe:if(f>=6&&u>=258){e.next_out=o,e.avail_out=u,e.next_in=a,e.avail_in=f,t.hold=s,t.bits=l,Ha(e,c),o=e.next_out,r=e.output,u=e.avail_out,a=e.next_in,i=e.input,f=e.avail_in,s=t.hold,l=t.bits,t.mode===K&&(t.back=-1);break}for(t.back=0;k=t.lencode[s&(1<<t.lenbits)-1],y=k>>>24,E=k>>>16&255,C=k&65535,!(y<=l);){if(f===0)break e;f--,s+=i[a++]<<l,l+=8}if(E&&!(E&240)){for(p=y,$=E,S=C;k=t.lencode[S+((s&(1<<p+$)-1)>>p)],y=k>>>24,E=k>>>16&255,C=k&65535,!(p+y<=l);){if(f===0)break e;f--,s+=i[a++]<<l,l+=8}s>>>=p,l-=p,t.back+=p}if(s>>>=y,l-=y,t.back+=y,t.length=C,E===0){t.mode=Bn;break}if(E&32){t.back=-1,t.mode=K;break}if(E&64){e.msg="invalid literal/length code",t.mode=A;break}t.extra=E&15,t.mode=An;case An:if(t.extra){for(N=t.extra;l<N;){if(f===0)break e;f--,s+=i[a++]<<l,l+=8}t.length+=s&(1<<t.extra)-1,s>>>=t.extra,l-=t.extra,t.back+=t.extra}t.was=t.length,t.mode=On;case On:for(;k=t.distcode[s&(1<<t.distbits)-1],y=k>>>24,E=k>>>16&255,C=k&65535,!(y<=l);){if(f===0)break e;f--,s+=i[a++]<<l,l+=8}if(!(E&240)){for(p=y,$=E,S=C;k=t.distcode[S+((s&(1<<p+$)-1)>>p)],y=k>>>24,E=k>>>16&255,C=k&65535,!(p+y<=l);){if(f===0)break e;f--,s+=i[a++]<<l,l+=8}s>>>=p,l-=p,t.back+=p}if(s>>>=y,l-=y,t.back+=y,E&64){e.msg="invalid distance code",t.mode=A;break}t.offset=C,t.extra=E&15,t.mode=zn;case zn:if(t.extra){for(N=t.extra;l<N;){if(f===0)break e;f--,s+=i[a++]<<l,l+=8}t.offset+=s&(1<<t.extra)-1,s>>>=t.extra,l-=t.extra,t.back+=t.extra}if(t.offset>t.dmax){e.msg="invalid distance too far back",t.mode=A;break}t.mode=Rn;case Rn:if(u===0)break e;if(h=c-u,t.offset>h){if(h=t.offset-h,h>t.whave&&t.sane){e.msg="invalid distance too far back",t.mode=A;break}h>t.wnext?(h-=t.wnext,_=t.wsize-h):_=t.wnext-h,h>t.length&&(h=t.length),g=t.window}else g=r,_=o-t.offset,h=t.length;h>u&&(h=u),u-=h,t.length-=h;do r[o++]=g[_++];while(--h);t.length===0&&(t.mode=Qe);break;case Bn:if(u===0)break e;r[o++]=t.length,u--,t.mode=Qe;break;case kt:if(t.wrap){for(;l<32;){if(f===0)break e;f--,s|=i[a++]<<l,l+=8}if(c-=u,e.total_out+=c,t.total+=c,t.wrap&4&&c&&(e.adler=t.check=t.flags?z(t.check,r,c,o-c):Be(t.check,r,c,o-c)),c=u,t.wrap&4&&(t.flags?s:Vn(s))!==t.check){e.msg="incorrect data check",t.mode=A;break}s=0,l=0}t.mode=Un;case Un:if(t.wrap&&t.flags){for(;l<32;){if(f===0)break e;f--,s+=i[a++]<<l,l+=8}if(t.wrap&4&&s!==(t.total&4294967295)){e.msg="incorrect length check",t.mode=A;break}s=0,l=0}t.mode=Dn;case Dn:w=Ja;break e;case A:w=yi;break e;case ki:return vi;case $i:default:return F}return e.next_out=o,e.avail_out=u,e.next_in=a,e.avail_in=f,t.hold=s,t.bits=l,(t.wsize||c!==e.avail_out&&t.mode<A&&(t.mode<kt||n!==_n))&&Ni(e,e.output,e.next_out,c-e.avail_out),d-=e.avail_in,c-=e.avail_out,e.total_in+=d,e.total_out+=c,t.total+=c,t.wrap&4&&c&&(e.adler=t.check=t.flags?z(t.check,r,c,e.next_out-c):Be(t.check,r,c,e.next_out-c)),e.data_type=t.bits+(t.last?64:0)+(t.mode===K?128:0)+(t.mode===Je||t.mode===vt?256:0),(d===0&&c===0||n===_n)&&w===he&&(w=eo),w},lo=e=>{if(ce(e))return F;let n=e.state;return n.window&&(n.window=null),e.state=null,he},uo=(e,n)=>{if(ce(e))return F;const t=e.state;return t.wrap&2?(t.head=n,n.done=!1,he):F},ho=(e,n)=>{const t=n.length;let i,r,a;return ce(e)||(i=e.state,i.wrap!==0&&i.mode!==at)?F:i.mode===at&&(r=1,r=Be(r,n,t,0),r!==i.check)?yi:(a=Ni(e,n,t,t),a?(i.mode=ki,vi):(i.havedict=1,he))};var co=Ci,po=Si,_o=Ei,bo=oo,go=xi,wo=fo,mo=lo,yo=uo,vo=ho,ko="pako inflate (from Nodeca project)",X={inflateReset:co,inflateReset2:po,inflateResetKeep:_o,inflateInit:bo,inflateInit2:go,inflate:wo,inflateEnd:mo,inflateGetHeader:yo,inflateSetDictionary:vo,inflateInfo:ko};function $o(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}var Eo=$o;const Ii=Object.prototype.toString,{Z_NO_FLUSH:Co,Z_FINISH:So,Z_OK:Ve,Z_STREAM_END:Ct,Z_NEED_DICT:St,Z_STREAM_ERROR:xo,Z_DATA_ERROR:Fn,Z_MEM_ERROR:No}=Ze;function He(e){this.options=ht.assign({chunkSize:1024*64,windowBits:15,to:""},e||{});const n=this.options;n.raw&&n.windowBits>=0&&n.windowBits<16&&(n.windowBits=-n.windowBits,n.windowBits===0&&(n.windowBits=-15)),n.windowBits>=0&&n.windowBits<16&&!(e&&e.windowBits)&&(n.windowBits+=32),n.windowBits>15&&n.windowBits<48&&(n.windowBits&15||(n.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new bi,this.strm.avail_out=0;let t=X.inflateInit2(this.strm,n.windowBits);if(t!==Ve)throw new Error(ge[t]);if(this.header=new Eo,X.inflateGetHeader(this.strm,this.header),n.dictionary&&(typeof n.dictionary=="string"?n.dictionary=De.string2buf(n.dictionary):Ii.call(n.dictionary)==="[object ArrayBuffer]"&&(n.dictionary=new Uint8Array(n.dictionary)),n.raw&&(t=X.inflateSetDictionary(this.strm,n.dictionary),t!==Ve)))throw new Error(ge[t])}He.prototype.push=function(e,n){const t=this.strm,i=this.options.chunkSize,r=this.options.dictionary;let a,o,f;if(this.ended)return!1;for(n===~~n?o=n:o=n===!0?So:Co,Ii.call(e)==="[object ArrayBuffer]"?t.input=new Uint8Array(e):t.input=e,t.next_in=0,t.avail_in=t.input.length;;){for(t.avail_out===0&&(t.output=new Uint8Array(i),t.next_out=0,t.avail_out=i),a=X.inflate(t,o),a===St&&r&&(a=X.inflateSetDictionary(t,r),a===Ve?a=X.inflate(t,o):a===Fn&&(a=St));t.avail_in>0&&a===Ct&&t.state.wrap>0&&e[t.next_in]!==0;)X.inflateReset(t),a=X.inflate(t,o);switch(a){case xo:case Fn:case St:case No:return this.onEnd(a),this.ended=!0,!1}if(f=t.avail_out,t.next_out&&(t.avail_out===0||a===Ct))if(this.options.to==="string"){let u=De.utf8border(t.output,t.next_out),s=t.next_out-u,l=De.buf2string(t.output,u);t.next_out=s,t.avail_out=i-s,s&&t.output.set(t.output.subarray(u,u+s),0),this.onData(l)}else this.onData(t.output.length===t.next_out?t.output:t.output.subarray(0,t.next_out));if(!(a===Ve&&f===0)){if(a===Ct)return a=X.inflateEnd(this.strm),this.onEnd(a),this.ended=!0,!0;if(t.avail_in===0)break}}return!0};He.prototype.onData=function(e){this.chunks.push(e)};He.prototype.onEnd=function(e){e===Ve&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=ht.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function Kt(e,n){const t=new He(n);if(t.push(e),t.err)throw t.msg||ge[t.err];return t.result}function Io(e,n){return n=n||{},n.raw=!0,Kt(e,n)}var To=He,Ao=Kt,Oo=Io,zo=Kt,Ro=Ze,Bo={Inflate:To,inflate:Ao,inflateRaw:Oo,ungzip:zo,constants:Ro};const{Inflate:Us,inflate:Ds,inflateRaw:Uo,ungzip:Vs}=Bo;var Do=Uo;function Vo(e){return Do(e.subarray(2))}class Lo extends Error{constructor(n){super(n),this.code="ERR_ABORTED"}}function Fo(e){e.sort((r,a)=>Number(r.offset)-Number(a.offset));const n=[];let t,i;for(const r of e)t&&i&&Number(r.offset)-i<=2e3?(t.length=BigInt(Number(t.length)+Number(r.length)-i+Number(r.offset)),t.blocks.push(r)):n.push(t={blocks:[r],length:r.length,offset:r.offset}),i=Number(t.offset)+Number(t.length);return n}function et(e){if(e&&e.aborted)if(typeof DOMException>"u"){const n=new Lo("aborted");throw n.code="ERR_ABORTED",n}else throw new DOMException("aborted","AbortError")}const Po=1,Zo=2,Mo=3;function xt(e,n,t,i){return e<i&&n>=t}function Ho(e){const n=e?"big":"little",t=new x().endianess(n).uint32("chromId").uint32("start").uint32("end").uint32("validCnt").floatle("minScore").floatle("maxScore").floatle("sumData").floatle("sumSqData").saveOffset("offset"),i=new x().endianess(n).uint8("isLeaf").skip(1).uint16("cnt").choice({tag:"isLeaf",choices:{1:new x().endianess(n).array("blocksToFetch",{length:"cnt",type:new x().endianess(n).uint32("startChrom").uint32("startBase").uint32("endChrom").uint32("endBase").uint64("blockOffset").uint64("blockSize").saveOffset("offset")}),0:new x().array("recurOffsets",{length:"cnt",type:new x().endianess(n).uint32("startChrom").uint32("startBase").uint32("endChrom").uint32("endBase").uint64("blockOffset").saveOffset("offset")})}}),r=new x().endianess(n).uint32("chromId").int32("start").int32("end").string("rest",{zeroTerminated:!0}).saveOffset("offset");return{bigWigParser:new x().endianess(n).skip(4).int32("blockStart").skip(4).uint32("itemStep").uint32("itemSpan").uint8("blockType").skip(1).uint16("itemCount").choice({tag:"blockType",choices:{[Mo]:new x().array("items",{length:"itemCount",type:new x().floatle("score")}),[Zo]:new x().array("items",{length:"itemCount",type:new x().endianess(n).int32("start").floatle("score")}),[Po]:new x().array("items",{length:"itemCount",type:new x().endianess(n).int32("start").int32("end").floatle("score")})}}),bigBedParser:r,summaryParser:t,leafParser:i}}class Ti{constructor(n,t,i,r,a,o){if(this.bbi=n,this.refsByName=t,this.cirTreeOffset=i,this.isBigEndian=r,this.isCompressed=a,this.blockType=o,this.featureCache=new Yn({cache:new Kn({maxSize:1e3}),fill:async(u,s)=>{const l=Number(u.length),d=Number(u.offset),{buffer:c}=await this.bbi.read(Q.Buffer.alloc(l),0,l,d,{signal:s});return c}}),!(i>=0))throw new Error("invalid cirTreeOffset!");const f=Ho(r);this.leafParser=f.leafParser,this.bigBedParser=f.bigBedParser}async readWigData(n,t,i,r,a){try{const{refsByName:o,bbi:f,cirTreeOffset:u,isBigEndian:s}=this,l=o[n];l===void 0&&r.complete();const d={chrId:l,start:t,end:i};this.cirTreePromise||(this.cirTreePromise=f.read(Q.Buffer.alloc(48),0,48,Number(u),a));const{buffer:c}=await this.cirTreePromise,h=s?c.readUInt32BE(4):c.readUInt32LE(4);let _=[],g=0;const k=(p,$,S)=>{try{const b=p.subarray($),w=this.leafParser.parse(b);if(w.blocksToFetch&&(_=_.concat(w.blocksToFetch.filter(m=>y(m)).map(m=>({offset:m.blockOffset,length:m.blockSize})))),w.recurOffsets){const m=w.recurOffsets.filter(v=>y(v)).map(v=>Number(v.blockOffset));m.length>0&&C(m,S+1)}}catch(b){r.error(b)}},y=p=>{const{startChrom:$,startBase:S,endChrom:b,endBase:w}=p;return($<l||$===l&&S<=i)&&(b>l||b===l&&w>=t)},E=async(p,$,S)=>{try{const b=$.max()-$.min(),w=$.min(),m=await this.featureCache.get(`${b}_${w}`,{length:b,offset:w},a==null?void 0:a.signal);for(const v of p)$.contains(v)&&(k(m,v-w,S),g-=1,g===0&&this.readFeatures(r,_,{...a,request:d}))}catch(b){r.error(b)}},C=(p,$)=>{try{g+=p.length;const S=4+Number(h)*32;let b=new q(p[0],p[0]+S);for(let w=1;w<p.length;w+=1){const m=new q(p[w],p[w]+S);b=b.union(m)}b.getRanges().map(w=>E(p,w,$))}catch(S){r.error(S)}};return C([Number(u)+48],1)}catch(o){r.error(o)}}parseSummaryBlock(n,t,i){const r=[];let a=t;const o=new DataView(n.buffer,n.byteOffset,n.length);for(;a<n.byteLength;){const f=o.getUint32(a,!0);a+=4;const u=o.getUint32(a,!0);a+=4;const s=o.getUint32(a,!0);a+=4;const l=o.getUint32(a,!0);a+=4;const d=o.getFloat32(a,!0);a+=4;const c=o.getFloat32(a,!0);a+=4;const h=o.getFloat32(a,!0);a+=4,a+=4,(!i||f===i.chrId&&xt(u,s,i.start,i.end))&&r.push({start:u,end:s,maxScore:c,minScore:d,summary:!0,score:h/(l||1)})}return r}parseBigBedBlock(n,t,i,r){const a=[];let o=t;for(;o<n.byteLength;){const f=this.bigBedParser.parse(n.subarray(o));a.push({...f,uniqueId:`bb-${i+o}`}),o+=f.offset}return r?a.filter(f=>xt(f.start,f.end,r.start,r.end)):a}parseBigWigBlock(n,t,i){const r=n.subarray(t),a=new DataView(r.buffer,r.byteOffset,r.length);let o=0;o+=4;const f=a.getInt32(o,!0);o+=8;const u=a.getUint32(o,!0);o+=4;const s=a.getUint32(o,!0);o+=4;const l=a.getUint8(o);o+=2;const d=a.getUint16(o,!0);o+=2;const c=new Array(d);switch(l){case 1:{for(let h=0;h<d;h++){const _=a.getInt32(o,!0);o+=4;const g=a.getInt32(o,!0);o+=4;const k=a.getFloat32(o,!0);o+=4,c[h]={start:_,end:g,score:k}}break}case 2:{for(let h=0;h<d;h++){const _=a.getInt32(o,!0);o+=4;const g=a.getFloat32(o,!0);o+=4,c[h]={score:g,start:_,end:_+s}}break}case 3:{for(let h=0;h<d;h++){const _=a.getFloat32(o,!0);o+=4;const g=f+h*u;c[h]={score:_,start:g,end:g+s}}break}}return i?c.filter(h=>xt(h.start,h.end,i.start,i.end)):c}async readFeatures(n,t,i={}){try{const{blockType:r,isCompressed:a}=this,{signal:o,request:f}=i,u=Fo(t);et(o),await Promise.all(u.map(async s=>{et(o);const{length:l,offset:d}=s,c=await this.featureCache.get(`${l}_${d}`,s,o);for(const h of s.blocks){et(o);let _=Number(h.offset)-Number(s.offset),g=c;switch(a&&(g=Vo(c.subarray(_)),_=0),et(o),r){case"summary":{n.next(this.parseSummaryBlock(g,_,f));break}case"bigwig":{n.next(this.parseBigWigBlock(g,_,f));break}case"bigbed":{n.next(this.parseBigBedBlock(g,_,Number(h.offset)*256,f));break}default:console.warn(`Don't know what to do with ${r}`)}}})),n.complete()}catch(r){n.error(r)}}}var Ft=function(e,n){return Ft=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,i){t.__proto__=i}||function(t,i){for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&(t[r]=i[r])},Ft(e,n)};function Wt(e,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");Ft(e,n);function t(){this.constructor=e}e.prototype=n===null?Object.create(n):(t.prototype=n.prototype,new t)}function jo(e,n,t,i){function r(a){return a instanceof t?a:new t(function(o){o(a)})}return new(t||(t=Promise))(function(a,o){function f(l){try{s(i.next(l))}catch(d){o(d)}}function u(l){try{s(i.throw(l))}catch(d){o(d)}}function s(l){l.done?a(l.value):r(l.value).then(f,u)}s((i=i.apply(e,n||[])).next())})}function Ai(e,n){var t={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},i,r,a,o;return o={next:f(0),throw:f(1),return:f(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function f(s){return function(l){return u([s,l])}}function u(s){if(i)throw new TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(t=0)),t;)try{if(i=1,r&&(a=s[0]&2?r.return:s[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,s[1])).done)return a;switch(r=0,a&&(s=[s[0]&2,a.value]),s[0]){case 0:case 1:a=s;break;case 4:return t.label++,{value:s[1],done:!1};case 5:t.label++,r=s[1],s=[0];continue;case 7:s=t.ops.pop(),t.trys.pop();continue;default:if(a=t.trys,!(a=a.length>0&&a[a.length-1])&&(s[0]===6||s[0]===2)){t=0;continue}if(s[0]===3&&(!a||s[1]>a[0]&&s[1]<a[3])){t.label=s[1];break}if(s[0]===6&&t.label<a[1]){t.label=a[1],a=s;break}if(a&&t.label<a[2]){t.label=a[2],t.ops.push(s);break}a[2]&&t.ops.pop(),t.trys.pop();continue}s=n.call(e,t)}catch(l){s=[6,l],r=0}finally{i=a=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}}function Le(e){var n=typeof Symbol=="function"&&Symbol.iterator,t=n&&e[n],i=0;if(t)return t.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&i>=e.length&&(e=void 0),{value:e&&e[i++],done:!e}}};throw new TypeError(n?"Object is not iterable.":"Symbol.iterator is not defined.")}function ot(e,n){var t=typeof Symbol=="function"&&e[Symbol.iterator];if(!t)return e;var i=t.call(e),r,a=[],o;try{for(;(n===void 0||n-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(f){o={error:f}}finally{try{r&&!r.done&&(t=i.return)&&t.call(i)}finally{if(o)throw o.error}}return a}function st(e,n,t){if(t||arguments.length===2)for(var i=0,r=n.length,a;i<r;i++)(a||!(i in n))&&(a||(a=Array.prototype.slice.call(n,0,i)),a[i]=n[i]);return e.concat(a||Array.prototype.slice.call(n))}function be(e){return this instanceof be?(this.v=e,this):new be(e)}function Go(e,n,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i=t.apply(e,n||[]),r,a=[];return r={},o("next"),o("throw"),o("return"),r[Symbol.asyncIterator]=function(){return this},r;function o(c){i[c]&&(r[c]=function(h){return new Promise(function(_,g){a.push([c,h,_,g])>1||f(c,h)})})}function f(c,h){try{u(i[c](h))}catch(_){d(a[0][3],_)}}function u(c){c.value instanceof be?Promise.resolve(c.value.v).then(s,l):d(a[0][2],c)}function s(c){f("next",c)}function l(c){f("throw",c)}function d(c,h){c(h),a.shift(),a.length&&f(a[0][0],a[0][1])}}function Yo(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=e[Symbol.asyncIterator],t;return n?n.call(e):(e=typeof Le=="function"?Le(e):e[Symbol.iterator](),t={},i("next"),i("throw"),i("return"),t[Symbol.asyncIterator]=function(){return this},t);function i(a){t[a]=e[a]&&function(o){return new Promise(function(f,u){o=e[a](o),r(f,u,o.done,o.value)})}}function r(a,o,f,u){Promise.resolve(u).then(function(s){a({value:s,done:f})},o)}}function O(e){return typeof e=="function"}function Oi(e){var n=function(i){Error.call(i),i.stack=new Error().stack},t=e(n);return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}var Nt=Oi(function(e){return function(t){e(this),this.message=t?t.length+` errors occurred during unsubscription: +`+t.map(function(i,r){return r+1+") "+i.toString()}).join(` + `):"",this.name="UnsubscriptionError",this.errors=t}});function Pn(e,n){if(e){var t=e.indexOf(n);0<=t&&e.splice(t,1)}}var Xt=function(){function e(n){this.initialTeardown=n,this.closed=!1,this._parentage=null,this._finalizers=null}return e.prototype.unsubscribe=function(){var n,t,i,r,a;if(!this.closed){this.closed=!0;var o=this._parentage;if(o)if(this._parentage=null,Array.isArray(o))try{for(var f=Le(o),u=f.next();!u.done;u=f.next()){var s=u.value;s.remove(this)}}catch(g){n={error:g}}finally{try{u&&!u.done&&(t=f.return)&&t.call(f)}finally{if(n)throw n.error}}else o.remove(this);var l=this.initialTeardown;if(O(l))try{l()}catch(g){a=g instanceof Nt?g.errors:[g]}var d=this._finalizers;if(d){this._finalizers=null;try{for(var c=Le(d),h=c.next();!h.done;h=c.next()){var _=h.value;try{Zn(_)}catch(g){a=a??[],g instanceof Nt?a=st(st([],ot(a)),ot(g.errors)):a.push(g)}}}catch(g){i={error:g}}finally{try{h&&!h.done&&(r=c.return)&&r.call(c)}finally{if(i)throw i.error}}}if(a)throw new Nt(a)}},e.prototype.add=function(n){var t;if(n&&n!==this)if(this.closed)Zn(n);else{if(n instanceof e){if(n.closed||n._hasParent(this))return;n._addParent(this)}(this._finalizers=(t=this._finalizers)!==null&&t!==void 0?t:[]).push(n)}},e.prototype._hasParent=function(n){var t=this._parentage;return t===n||Array.isArray(t)&&t.includes(n)},e.prototype._addParent=function(n){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(n),t):t?[t,n]:n},e.prototype._removeParent=function(n){var t=this._parentage;t===n?this._parentage=null:Array.isArray(t)&&Pn(t,n)},e.prototype.remove=function(n){var t=this._finalizers;t&&Pn(t,n),n instanceof e&&n._removeParent(this)},e.EMPTY=function(){var n=new e;return n.closed=!0,n}(),e}();Xt.EMPTY;function zi(e){return e instanceof Xt||e&&"closed"in e&&O(e.remove)&&O(e.add)&&O(e.unsubscribe)}function Zn(e){O(e)?e():e.unsubscribe()}var Ri={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},Pt={setTimeout:function(e,n){for(var t=[],i=2;i<arguments.length;i++)t[i-2]=arguments[i];var r=Pt.delegate;return r!=null&&r.setTimeout?r.setTimeout.apply(r,st([e,n],ot(t))):setTimeout.apply(void 0,st([e,n],ot(t)))},clearTimeout:function(e){var n=Pt.delegate;return((n==null?void 0:n.clearTimeout)||clearTimeout)(e)},delegate:void 0};function Bi(e){Pt.setTimeout(function(){throw e})}function Mn(){}function Ko(e){e()}var qt=function(e){Wt(n,e);function n(t){var i=e.call(this)||this;return i.isStopped=!1,t?(i.destination=t,zi(t)&&t.add(i)):i.destination=Jo,i}return n.create=function(t,i,r){return new ft(t,i,r)},n.prototype.next=function(t){this.isStopped||this._next(t)},n.prototype.error=function(t){this.isStopped||(this.isStopped=!0,this._error(t))},n.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},n.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},n.prototype._next=function(t){this.destination.next(t)},n.prototype._error=function(t){try{this.destination.error(t)}finally{this.unsubscribe()}},n.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},n}(Xt),Wo=Function.prototype.bind;function It(e,n){return Wo.call(e,n)}var Xo=function(){function e(n){this.partialObserver=n}return e.prototype.next=function(n){var t=this.partialObserver;if(t.next)try{t.next(n)}catch(i){tt(i)}},e.prototype.error=function(n){var t=this.partialObserver;if(t.error)try{t.error(n)}catch(i){tt(i)}else tt(n)},e.prototype.complete=function(){var n=this.partialObserver;if(n.complete)try{n.complete()}catch(t){tt(t)}},e}(),ft=function(e){Wt(n,e);function n(t,i,r){var a=e.call(this)||this,o;if(O(t)||!t)o={next:t??void 0,error:i??void 0,complete:r??void 0};else{var f;a&&Ri.useDeprecatedNextContext?(f=Object.create(t),f.unsubscribe=function(){return a.unsubscribe()},o={next:t.next&&It(t.next,f),error:t.error&&It(t.error,f),complete:t.complete&&It(t.complete,f)}):o=t}return a.destination=new Xo(o),a}return n}(qt);function tt(e){Bi(e)}function qo(e){throw e}var Jo={closed:!0,next:Mn,error:qo,complete:Mn},Jt=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function Ui(e){return e}function Qo(e){return e.length===0?Ui:e.length===1?e[0]:function(t){return e.reduce(function(i,r){return r(i)},t)}}var P=function(){function e(n){n&&(this._subscribe=n)}return e.prototype.lift=function(n){var t=new e;return t.source=this,t.operator=n,t},e.prototype.subscribe=function(n,t,i){var r=this,a=ts(n)?n:new ft(n,t,i);return Ko(function(){var o=r,f=o.operator,u=o.source;a.add(f?f.call(a,u):u?r._subscribe(a):r._trySubscribe(a))}),a},e.prototype._trySubscribe=function(n){try{return this._subscribe(n)}catch(t){n.error(t)}},e.prototype.forEach=function(n,t){var i=this;return t=Hn(t),new t(function(r,a){var o=new ft({next:function(f){try{n(f)}catch(u){a(u),o.unsubscribe()}},error:a,complete:r});i.subscribe(o)})},e.prototype._subscribe=function(n){var t;return(t=this.source)===null||t===void 0?void 0:t.subscribe(n)},e.prototype[Jt]=function(){return this},e.prototype.pipe=function(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];return Qo(n)(this)},e.prototype.toPromise=function(n){var t=this;return n=Hn(n),new n(function(i,r){var a;t.subscribe(function(o){return a=o},function(o){return r(o)},function(){return i(a)})})},e.create=function(n){return new e(n)},e}();function Hn(e){var n;return(n=e??Ri.Promise)!==null&&n!==void 0?n:Promise}function es(e){return e&&O(e.next)&&O(e.error)&&O(e.complete)}function ts(e){return e&&e instanceof qt||es(e)&&zi(e)}function ns(e){return O(e==null?void 0:e.lift)}function $e(e){return function(n){if(ns(n))return n.lift(function(t){try{return e(t,this)}catch(i){this.error(i)}});throw new TypeError("Unable to lift unknown Observable type")}}function Fe(e,n,t,i,r){return new is(e,n,t,i,r)}var is=function(e){Wt(n,e);function n(t,i,r,a,o,f){var u=e.call(this,t)||this;return u.onFinalize=o,u.shouldUnsubscribe=f,u._next=i?function(s){try{i(s)}catch(l){t.error(l)}}:e.prototype._next,u._error=a?function(s){try{a(s)}catch(l){t.error(l)}finally{this.unsubscribe()}}:e.prototype._error,u._complete=r?function(){try{r()}catch(s){t.error(s)}finally{this.unsubscribe()}}:e.prototype._complete,u}return n.prototype.unsubscribe=function(){var t;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var i=this.closed;e.prototype.unsubscribe.call(this),!i&&((t=this.onFinalize)===null||t===void 0||t.call(this))}},n}(qt),rs=new P(function(e){return e.complete()});function as(e){return e&&O(e.schedule)}function Di(e){return e[e.length-1]}function os(e){return as(Di(e))?e.pop():void 0}function ss(e,n){return typeof Di(e)=="number"?e.pop():n}var Vi=function(e){return e&&typeof e.length=="number"&&typeof e!="function"};function Li(e){return O(e==null?void 0:e.then)}function Fi(e){return O(e[Jt])}function Pi(e){return Symbol.asyncIterator&&O(e==null?void 0:e[Symbol.asyncIterator])}function Zi(e){return new TypeError("You provided "+(e!==null&&typeof e=="object"?"an invalid object":"'"+e+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function fs(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var Mi=fs();function Hi(e){return O(e==null?void 0:e[Mi])}function ji(e){return Go(this,arguments,function(){var t,i,r,a;return Ai(this,function(o){switch(o.label){case 0:t=e.getReader(),o.label=1;case 1:o.trys.push([1,,9,10]),o.label=2;case 2:return[4,be(t.read())];case 3:return i=o.sent(),r=i.value,a=i.done,a?[4,be(void 0)]:[3,5];case 4:return[2,o.sent()];case 5:return[4,be(r)];case 6:return[4,o.sent()];case 7:return o.sent(),[3,2];case 8:return[3,10];case 9:return t.releaseLock(),[7];case 10:return[2]}})})}function Gi(e){return O(e==null?void 0:e.getReader)}function Ee(e){if(e instanceof P)return e;if(e!=null){if(Fi(e))return ls(e);if(Vi(e))return us(e);if(Li(e))return hs(e);if(Pi(e))return Yi(e);if(Hi(e))return cs(e);if(Gi(e))return ds(e)}throw Zi(e)}function ls(e){return new P(function(n){var t=e[Jt]();if(O(t.subscribe))return t.subscribe(n);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function us(e){return new P(function(n){for(var t=0;t<e.length&&!n.closed;t++)n.next(e[t]);n.complete()})}function hs(e){return new P(function(n){e.then(function(t){n.closed||(n.next(t),n.complete())},function(t){return n.error(t)}).then(null,Bi)})}function cs(e){return new P(function(n){var t,i;try{for(var r=Le(e),a=r.next();!a.done;a=r.next()){var o=a.value;if(n.next(o),n.closed)return}}catch(f){t={error:f}}finally{try{a&&!a.done&&(i=r.return)&&i.call(r)}finally{if(t)throw t.error}}n.complete()})}function Yi(e){return new P(function(n){ps(e,n).catch(function(t){return n.error(t)})})}function ds(e){return Yi(ji(e))}function ps(e,n){var t,i,r,a;return jo(this,void 0,void 0,function(){var o,f;return Ai(this,function(u){switch(u.label){case 0:u.trys.push([0,5,6,11]),t=Yo(e),u.label=1;case 1:return[4,t.next()];case 2:if(i=u.sent(),!!i.done)return[3,4];if(o=i.value,n.next(o),n.closed)return[2];u.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return f=u.sent(),r={error:f},[3,11];case 6:return u.trys.push([6,,9,10]),i&&!i.done&&(a=t.return)?[4,a.call(t)]:[3,8];case 7:u.sent(),u.label=8;case 8:return[3,10];case 9:if(r)throw r.error;return[7];case 10:return[7];case 11:return n.complete(),[2]}})})}function re(e,n,t,i,r){i===void 0&&(i=0),r===void 0&&(r=!1);var a=n.schedule(function(){t(),r?e.add(this.schedule(null,i)):this.unsubscribe()},i);if(e.add(a),!r)return a}function Ki(e,n){return n===void 0&&(n=0),$e(function(t,i){t.subscribe(Fe(i,function(r){return re(i,e,function(){return i.next(r)},n)},function(){return re(i,e,function(){return i.complete()},n)},function(r){return re(i,e,function(){return i.error(r)},n)}))})}function Wi(e,n){return n===void 0&&(n=0),$e(function(t,i){i.add(e.schedule(function(){return t.subscribe(i)},n))})}function _s(e,n){return Ee(e).pipe(Wi(n),Ki(n))}function bs(e,n){return Ee(e).pipe(Wi(n),Ki(n))}function gs(e,n){return new P(function(t){var i=0;return n.schedule(function(){i===e.length?t.complete():(t.next(e[i++]),t.closed||this.schedule())})})}function ws(e,n){return new P(function(t){var i;return re(t,n,function(){i=e[Mi](),re(t,n,function(){var r,a,o;try{r=i.next(),a=r.value,o=r.done}catch(f){t.error(f);return}o?t.complete():t.next(a)},0,!0)}),function(){return O(i==null?void 0:i.return)&&i.return()}})}function Xi(e,n){if(!e)throw new Error("Iterable cannot be null");return new P(function(t){re(t,n,function(){var i=e[Symbol.asyncIterator]();re(t,n,function(){i.next().then(function(r){r.done?t.complete():t.next(r.value)})},0,!0)})})}function ms(e,n){return Xi(ji(e),n)}function ys(e,n){if(e!=null){if(Fi(e))return _s(e,n);if(Vi(e))return gs(e,n);if(Li(e))return bs(e,n);if(Pi(e))return Xi(e,n);if(Hi(e))return ws(e,n);if(Gi(e))return ms(e,n)}throw Zi(e)}function vs(e,n){return n?ys(e,n):Ee(e)}var ks=Oi(function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}});function qi(e,n){var t=typeof n=="object";return new Promise(function(i,r){var a=new ft({next:function(o){i(o),a.unsubscribe()},error:r,complete:function(){t?i(n.defaultValue):r(new ks)}});e.subscribe(a)})}function Ji(e,n){return $e(function(t,i){var r=0;t.subscribe(Fe(i,function(a){i.next(e.call(n,a,r++))}))})}function $s(e,n,t,i,r,a,o,f){var u=[],s=0,l=0,d=!1,c=function(){d&&!u.length&&!s&&n.complete()},h=function(g){return s<i?_(g):u.push(g)},_=function(g){a&&n.next(g),s++;var k=!1;Ee(t(g,l++)).subscribe(Fe(n,function(y){r==null||r(y),a?h(y):n.next(y)},function(){k=!0},void 0,function(){if(k)try{s--;for(var y=function(){var E=u.shift();o?re(n,o,function(){return _(E)}):_(E)};u.length&&s<i;)y();c()}catch(E){n.error(E)}}))};return e.subscribe(Fe(n,h,function(){d=!0,c()})),function(){f==null||f()}}function Qi(e,n,t){return t===void 0&&(t=1/0),O(n)?Qi(function(i,r){return Ji(function(a,o){return n(i,a,r,o)})(Ee(e(i,r)))},t):(typeof n=="number"&&(t=n),$e(function(i,r){return $s(i,r,e,t)}))}function Es(e){return e===void 0&&(e=1/0),Qi(Ui,e)}function Cs(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var t=os(e),i=ss(e,1/0),r=e;return r.length?r.length===1?Ee(r[0]):Es(i)(vs(r,t)):rs}function Ss(e,n,t,i,r){return function(a,o){var f=t,u=n,s=0;a.subscribe(Fe(o,function(l){var d=s++;u=f?e(u,l,d):(f=!0,l),i&&o.next(u)},r&&function(){f&&o.next(u),o.complete()}))}}function er(e,n){return $e(Ss(e,n,arguments.length>=2,!1,!0))}var xs=function(e,n){return e.push(n),e};function Ns(){return $e(function(e,n){er(xs,[])(e).subscribe(n)})}const jn=-2003829722,Tt=-2021002517;function Is(e){return new TextDecoder().decode(e)}function Gn(e){const n=e?"big":"little",t=new x().endianess(n).int32("magic").uint16("version").uint16("numZoomLevels").uint64("chromTreeOffset").uint64("unzoomedDataOffset").uint64("unzoomedIndexOffset").uint16("fieldCount").uint16("definedFieldCount").uint64("asOffset").uint64("totalSummaryOffset").uint32("uncompressBufSize").uint64("extHeaderOffset").array("zoomLevels",{length:"numZoomLevels",type:new x().endianess(n).uint32("reductionLevel").uint32("reserved").uint64("dataOffset").uint64("indexOffset")}),i=new x().endianess(n).uint64("basesCovered").doublele("scoreMin").doublele("scoreMax").doublele("scoreSum").doublele("scoreSumSquares"),r=new x().endianess(n).uint32("magic").uint32("blockSize").uint32("keySize").uint32("valSize").uint64("itemCount"),a=new x().endianess(n).uint8("isLeafNode").skip(1).uint16("cnt").saveOffset("offset");return{chromTreeParser:r,totalSummaryParser:i,headerParser:t,isLeafNode:a}}class tr{getHeader(n){return this.headerP||(this.headerP=this._getHeader(n).catch(t=>{throw this.headerP=void 0,t})),this.headerP}constructor(n){const{filehandle:t,renameRefSeqs:i=o=>o,path:r,url:a}=n;if(this.renameRefSeqs=i,t)this.bbi=t;else if(a)this.bbi=new ir(a);else if(r)this.bbi=new nr(r);else throw new Error("no file given")}async _getHeader(n){const t=await this._getMainHeader(n),i=await this._readChromTree(t,n);return{...t,...i}}async _getMainHeader(n,t=2e3){const{buffer:i}=await this.bbi.read(Q.Buffer.alloc(t),0,t,0,n),r=this._isBigEndian(i),a=Gn(r),o=a.headerParser.parse(i),{magic:f,asOffset:u,totalSummaryOffset:s}=o;if(o.fileType=f===Tt?"bigbed":"bigwig",u>t||s>t)return this._getMainHeader(n,t*2);if(u){const l=Number(o.asOffset);o.autoSql=Is(i.subarray(l,i.indexOf(0,l)))}if(o.totalSummaryOffset>t-8*5)return this._getMainHeader(n,t*2);if(o.totalSummaryOffset){const l=i.subarray(Number(o.totalSummaryOffset)),d=a.totalSummaryParser.parse(l);o.totalSummary={...d,basesCovered:Number(d.basesCovered)}}return{...o,isBigEndian:r}}_isBigEndian(n){let t=n.readInt32LE(0);if(t===jn||t===Tt)return!1;if(t=n.readInt32BE(0),t===jn||t===Tt)return!0;throw new Error("not a BigWig/BigBed file")}async _readChromTree(n,t){const i=n.isBigEndian,r=i?"big":"little",a=[],o={};let f=Number(n.unzoomedDataOffset);const u=Number(n.chromTreeOffset);for(;f%4!==0;)f+=1;const s=f-u,{buffer:l}=await this.bbi.read(Q.Buffer.alloc(s),0,s,Number(u),t),d=Gn(i),{keySize:c}=d.chromTreeParser.parse(l),h=new x().endianess(r).string("key",{stripNull:!0,length:c}).uint32("refId").uint32("refSize").saveOffset("offset"),_=new x().endianess(r).skip(c).uint64("childOffset").saveOffset("offset"),g=32,k=async y=>{let E=y;if(E>=l.length)throw new Error("reading beyond end of buffer");const C=d.isLeafNode.parse(l.subarray(E)),{isLeafNode:p,cnt:$}=C;if(E+=C.offset,p)for(let S=0;S<$;S+=1){const b=h.parse(l.subarray(E));E+=b.offset;const{key:w,refId:m,refSize:v}=b,N={name:w,id:m,length:v};o[this.renameRefSeqs(w)]=m,a[m]=N}else{const S=[];for(let b=0;b<$;b+=1){const w=_.parse(l.subarray(E)),{childOffset:m}=w;E+=w.offset,S.push(k(Number(m)-Number(u)))}await Promise.all(S)}};return await k(g),{refsByName:o,refsByNumber:a}}async getUnzoomedView(n){const{unzoomedIndexOffset:t,refsByName:i,uncompressBufSize:r,isBigEndian:a,fileType:o}=await this.getHeader(n);return new Ti(this.bbi,i,t,a,r>0,o)}async getFeatureStream(n,t,i,r){await this.getHeader(r);const a=this.renameRefSeqs(n);let o;const{basesPerSpan:f,scale:u}=r||{};return f?o=await this.getView(1/f,r):u?o=await this.getView(u,r):o=await this.getView(1,r),new P(s=>{o.readWigData(a,t,i,s,r)})}async getFeatures(n,t,i,r){const a=await this.getFeatureStream(n,t,i,r);return(await qi(a.pipe(Ns()))).flat()}}class Ls extends tr{async getView(n,t){const{zoomLevels:i,refsByName:r,fileSize:a,isBigEndian:o,uncompressBufSize:f}=await this.getHeader(t),u=1/n;let s=i.length;a||(s-=1);for(let l=s;l>=0;l-=1){const d=i[l];if(d&&d.reductionLevel<=2*u){const c=Number(d.indexOffset);return new Ti(this.bbi,r,c,o,f>0,"summary")}}return this.getUnzoomedView(t)}}function Ts(e){return e.filter(n=>!!n)}class Fs extends tr{constructor(){super(...arguments),this.readIndicesCache=new Yn({cache:new Kn({maxSize:1}),fill:(n,t)=>this._readIndices({...n,signal:t})})}readIndices(n={}){const{signal:t,...i}=n;return this.readIndicesCache.get(JSON.stringify(i),n,t)}async getView(n,t){return this.getUnzoomedView(t)}async _readIndices(n){const{extHeaderOffset:t,isBigEndian:i}=await this.getHeader(n),{buffer:r}=await this.bbi.read(Q.Buffer.alloc(64),0,64,Number(t)),a=i?"big":"little",o=new x().endianess(a).uint16("size").uint16("count").uint64("offset").parse(r),{count:f,offset:u}=o;if(f===0)return[];const s=20,l=s*f,{buffer:d}=await this.bbi.read(Q.Buffer.alloc(l),0,l,Number(u)),c=new x().endianess(a).int16("type").int16("fieldcount").uint64("offset").skip(4).int16("field"),h=[];for(let _=0;_<f;_+=1)h.push(c.parse(d.subarray(_*s)));return h}async searchExtraIndexBlocks(n,t={}){const{isBigEndian:i}=await this.getHeader(t),r=await this.readIndices(t);if(r.length===0)return[];const a=r.map(async o=>{const{offset:f,field:u}=o,{buffer:s}=await this.bbi.read(Q.Buffer.alloc(32),0,32,Number(f),t),l=i?"big":"little",d=new x().endianess(l).int32("magic").int32("blockSize").int32("keySize").int32("valSize").uint64("itemCount"),{blockSize:c,keySize:h,valSize:_}=d.parse(s),g=new x().endianess(l).int8("nodeType").skip(1).int16("cnt").choice({tag:"nodeType",choices:{0:new x().array("leafkeys",{length:"cnt",type:new x().endianess(l).string("key",{length:h,stripNull:!0}).uint64("offset")}),1:new x().array("keys",{length:"cnt",type:new x().endianess(l).string("key",{length:h,stripNull:!0}).uint64("offset").uint32("length").uint32("reserved")})}}),k=async E=>{const C=Number(E),p=4+c*(h+_),{buffer:$}=await this.bbi.read(Q.Buffer.alloc(p),0,p,C,t),S=g.parse($);if(S.leafkeys){let b;for(let w=0;w<S.leafkeys.length;w+=1){const{key:m}=S.leafkeys[w];if(n.localeCompare(m)<0&&b)return k(b);b=S.leafkeys[w].offset}return k(b)}for(let b=0;b<S.keys.length;b+=1)if(S.keys[b].key===n)return{...S.keys[b],field:u}},y=32;return k(Number(f)+y)});return Ts(await Promise.all(a))}async searchExtraIndex(n,t={}){const i=await this.searchExtraIndexBlocks(n,t);if(i.length===0)return[];const r=await this.getUnzoomedView(t),a=i.map(f=>new P(u=>{r.readFeatures(u,[f],t)}).pipe(er((u,s)=>u.concat(s)),Ji(u=>{for(const s of u)s.field=f.field;return u})));return(await qi(Cs(...a))).filter(f=>{var u;return((u=f.rest)===null||u===void 0?void 0:u.split(" ")[(f.field||0)-3])===n})}}export{Fs as BigBed,Ls as BigWig}; diff --git a/segmentmodel/assets/index-462333f7.js b/segmentmodel/assets/index-462333f7.js new file mode 100644 index 0000000..06ebfdd --- /dev/null +++ b/segmentmodel/assets/index-462333f7.js @@ -0,0 +1,6 @@ +import{g as _r}from"./_commonjsHelpers-de833af9.js";function Sr(c,f){for(var s=0;s<f.length;s++){const w=f[s];if(typeof w!="string"&&!Array.isArray(w)){for(const y in w)if(y!=="default"&&!(y in c)){const l=Object.getOwnPropertyDescriptor(w,y);l&&Object.defineProperty(c,y,l.get?l:{enumerable:!0,get:()=>w[y]})}}}return Object.freeze(Object.defineProperty(c,Symbol.toStringTag,{value:"Module"}))}var V={},j={};j.byteLength=Nr;j.toByteArray=kr;j.fromByteArray=Pr;var _=[],R=[],Lr=typeof Uint8Array<"u"?Uint8Array:Array,H="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var k=0,br=H.length;k<br;++k)_[k]=H[k],R[H.charCodeAt(k)]=k;R["-".charCodeAt(0)]=62;R["_".charCodeAt(0)]=63;function hr(c){var f=c.length;if(f%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var s=c.indexOf("=");s===-1&&(s=f);var w=s===f?0:4-s%4;return[s,w]}function Nr(c){var f=hr(c),s=f[0],w=f[1];return(s+w)*3/4-w}function Mr(c,f,s){return(f+s)*3/4-s}function kr(c){var f,s=hr(c),w=s[0],y=s[1],l=new Lr(Mr(c,w,y)),p=0,o=y>0?w-4:w,B;for(B=0;B<o;B+=4)f=R[c.charCodeAt(B)]<<18|R[c.charCodeAt(B+1)]<<12|R[c.charCodeAt(B+2)]<<6|R[c.charCodeAt(B+3)],l[p++]=f>>16&255,l[p++]=f>>8&255,l[p++]=f&255;return y===2&&(f=R[c.charCodeAt(B)]<<2|R[c.charCodeAt(B+1)]>>4,l[p++]=f&255),y===1&&(f=R[c.charCodeAt(B)]<<10|R[c.charCodeAt(B+1)]<<4|R[c.charCodeAt(B+2)]>>2,l[p++]=f>>8&255,l[p++]=f&255),l}function Dr(c){return _[c>>18&63]+_[c>>12&63]+_[c>>6&63]+_[c&63]}function $r(c,f,s){for(var w,y=[],l=f;l<s;l+=3)w=(c[l]<<16&16711680)+(c[l+1]<<8&65280)+(c[l+2]&255),y.push(Dr(w));return y.join("")}function Pr(c){for(var f,s=c.length,w=s%3,y=[],l=16383,p=0,o=s-w;p<o;p+=l)y.push($r(c,p,p+l>o?o:p+l));return w===1?(f=c[s-1],y.push(_[f>>2]+_[f<<4&63]+"==")):w===2&&(f=(c[s-2]<<8)+c[s-1],y.push(_[f>>10]+_[f>>4&63]+_[f<<2&63]+"=")),y.join("")}var X={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */X.read=function(c,f,s,w,y){var l,p,o=y*8-w-1,B=(1<<o)-1,T=B>>1,I=-7,F=s?y-1:0,S=s?-1:1,A=c[f+F];for(F+=S,l=A&(1<<-I)-1,A>>=-I,I+=o;I>0;l=l*256+c[f+F],F+=S,I-=8);for(p=l&(1<<-I)-1,l>>=-I,I+=w;I>0;p=p*256+c[f+F],F+=S,I-=8);if(l===0)l=1-T;else{if(l===B)return p?NaN:(A?-1:1)*(1/0);p=p+Math.pow(2,w),l=l-T}return(A?-1:1)*p*Math.pow(2,l-w)};X.write=function(c,f,s,w,y,l){var p,o,B,T=l*8-y-1,I=(1<<T)-1,F=I>>1,S=y===23?Math.pow(2,-24)-Math.pow(2,-77):0,A=w?0:l-1,D=w?1:-1,$=f<0||f===0&&1/f<0?1:0;for(f=Math.abs(f),isNaN(f)||f===1/0?(o=isNaN(f)?1:0,p=I):(p=Math.floor(Math.log(f)/Math.LN2),f*(B=Math.pow(2,-p))<1&&(p--,B*=2),p+F>=1?f+=S/B:f+=S*Math.pow(2,1-F),f*B>=2&&(p++,B/=2),p+F>=I?(o=0,p=I):p+F>=1?(o=(f*B-1)*Math.pow(2,y),p=p+F):(o=f*Math.pow(2,F-1)*Math.pow(2,y),p=0));y>=8;c[s+A]=o&255,A+=D,o/=256,y-=8);for(p=p<<y|o,T+=y;T>0;c[s+A]=p&255,A+=D,p/=256,T-=8);c[s+A-D]|=$*128};/*! + * The buffer module from node.js, for the browser. + * + * @author Feross Aboukhadijeh <https://feross.org> + * @license MIT + */(function(c){const f=j,s=X,w=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;c.Buffer=o,c.SlowBuffer=cr,c.INSPECT_MAX_BYTES=50;const y=2147483647;c.kMaxLength=y,o.TYPED_ARRAY_SUPPORT=l(),!o.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function l(){try{const i=new Uint8Array(1),r={foo:function(){return 42}};return Object.setPrototypeOf(r,Uint8Array.prototype),Object.setPrototypeOf(i,r),i.foo()===42}catch{return!1}}Object.defineProperty(o.prototype,"parent",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.buffer}}),Object.defineProperty(o.prototype,"offset",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.byteOffset}});function p(i){if(i>y)throw new RangeError('The value "'+i+'" is invalid for option "size"');const r=new Uint8Array(i);return Object.setPrototypeOf(r,o.prototype),r}function o(i,r,t){if(typeof i=="number"){if(typeof r=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return F(i)}return B(i,r,t)}o.poolSize=8192;function B(i,r,t){if(typeof i=="string")return S(i,r);if(ArrayBuffer.isView(i))return D(i);if(i==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof i);if(C(i,ArrayBuffer)||i&&C(i.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(C(i,SharedArrayBuffer)||i&&C(i.buffer,SharedArrayBuffer)))return $(i,r,t);if(typeof i=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const n=i.valueOf&&i.valueOf();if(n!=null&&n!==i)return o.from(n,r,t);const e=fr(i);if(e)return e;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof i[Symbol.toPrimitive]=="function")return o.from(i[Symbol.toPrimitive]("string"),r,t);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof i)}o.from=function(i,r,t){return B(i,r,t)},Object.setPrototypeOf(o.prototype,Uint8Array.prototype),Object.setPrototypeOf(o,Uint8Array);function T(i){if(typeof i!="number")throw new TypeError('"size" argument must be of type number');if(i<0)throw new RangeError('The value "'+i+'" is invalid for option "size"')}function I(i,r,t){return T(i),i<=0?p(i):r!==void 0?typeof t=="string"?p(i).fill(r,t):p(i).fill(r):p(i)}o.alloc=function(i,r,t){return I(i,r,t)};function F(i){return T(i),p(i<0?0:G(i)|0)}o.allocUnsafe=function(i){return F(i)},o.allocUnsafeSlow=function(i){return F(i)};function S(i,r){if((typeof r!="string"||r==="")&&(r="utf8"),!o.isEncoding(r))throw new TypeError("Unknown encoding: "+r);const t=z(i,r)|0;let n=p(t);const e=n.write(i,r);return e!==t&&(n=n.slice(0,e)),n}function A(i){const r=i.length<0?0:G(i.length)|0,t=p(r);for(let n=0;n<r;n+=1)t[n]=i[n]&255;return t}function D(i){if(C(i,Uint8Array)){const r=new Uint8Array(i);return $(r.buffer,r.byteOffset,r.byteLength)}return A(i)}function $(i,r,t){if(r<0||i.byteLength<r)throw new RangeError('"offset" is outside of buffer bounds');if(i.byteLength<r+(t||0))throw new RangeError('"length" is outside of buffer bounds');let n;return r===void 0&&t===void 0?n=new Uint8Array(i):t===void 0?n=new Uint8Array(i,r):n=new Uint8Array(i,r,t),Object.setPrototypeOf(n,o.prototype),n}function fr(i){if(o.isBuffer(i)){const r=G(i.length)|0,t=p(r);return t.length===0||i.copy(t,0,0,r),t}if(i.length!==void 0)return typeof i.length!="number"||q(i.length)?p(0):A(i);if(i.type==="Buffer"&&Array.isArray(i.data))return A(i.data)}function G(i){if(i>=y)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+y.toString(16)+" bytes");return i|0}function cr(i){return+i!=i&&(i=0),o.alloc(+i)}o.isBuffer=function(r){return r!=null&&r._isBuffer===!0&&r!==o.prototype},o.compare=function(r,t){if(C(r,Uint8Array)&&(r=o.from(r,r.offset,r.byteLength)),C(t,Uint8Array)&&(t=o.from(t,t.offset,t.byteLength)),!o.isBuffer(r)||!o.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(r===t)return 0;let n=r.length,e=t.length;for(let u=0,h=Math.min(n,e);u<h;++u)if(r[u]!==t[u]){n=r[u],e=t[u];break}return n<e?-1:e<n?1:0},o.isEncoding=function(r){switch(String(r).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}},o.concat=function(r,t){if(!Array.isArray(r))throw new TypeError('"list" argument must be an Array of Buffers');if(r.length===0)return o.alloc(0);let n;if(t===void 0)for(t=0,n=0;n<r.length;++n)t+=r[n].length;const e=o.allocUnsafe(t);let u=0;for(n=0;n<r.length;++n){let h=r[n];if(C(h,Uint8Array))u+h.length>e.length?(o.isBuffer(h)||(h=o.from(h)),h.copy(e,u)):Uint8Array.prototype.set.call(e,h,u);else if(o.isBuffer(h))h.copy(e,u);else throw new TypeError('"list" argument must be an Array of Buffers');u+=h.length}return e};function z(i,r){if(o.isBuffer(i))return i.length;if(ArrayBuffer.isView(i)||C(i,ArrayBuffer))return i.byteLength;if(typeof i!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof i);const t=i.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&t===0)return 0;let e=!1;for(;;)switch(r){case"ascii":case"latin1":case"binary":return t;case"utf8":case"utf-8":return W(i).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return t*2;case"hex":return t>>>1;case"base64":return ur(i).length;default:if(e)return n?-1:W(i).length;r=(""+r).toLowerCase(),e=!0}}o.byteLength=z;function pr(i,r,t){let n=!1;if((r===void 0||r<0)&&(r=0),r>this.length||((t===void 0||t>this.length)&&(t=this.length),t<=0)||(t>>>=0,r>>>=0,t<=r))return"";for(i||(i="utf8");;)switch(i){case"hex":return gr(this,r,t);case"utf8":case"utf-8":return Z(this,r,t);case"ascii":return Er(this,r,t);case"latin1":case"binary":return dr(this,r,t);case"base64":return xr(this,r,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return mr(this,r,t);default:if(n)throw new TypeError("Unknown encoding: "+i);i=(i+"").toLowerCase(),n=!0}}o.prototype._isBuffer=!0;function b(i,r,t){const n=i[r];i[r]=i[t],i[t]=n}o.prototype.swap16=function(){const r=this.length;if(r%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let t=0;t<r;t+=2)b(this,t,t+1);return this},o.prototype.swap32=function(){const r=this.length;if(r%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let t=0;t<r;t+=4)b(this,t,t+3),b(this,t+1,t+2);return this},o.prototype.swap64=function(){const r=this.length;if(r%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let t=0;t<r;t+=8)b(this,t,t+7),b(this,t+1,t+6),b(this,t+2,t+5),b(this,t+3,t+4);return this},o.prototype.toString=function(){const r=this.length;return r===0?"":arguments.length===0?Z(this,0,r):pr.apply(this,arguments)},o.prototype.toLocaleString=o.prototype.toString,o.prototype.equals=function(r){if(!o.isBuffer(r))throw new TypeError("Argument must be a Buffer");return this===r?!0:o.compare(this,r)===0},o.prototype.inspect=function(){let r="";const t=c.INSPECT_MAX_BYTES;return r=this.toString("hex",0,t).replace(/(.{2})/g,"$1 ").trim(),this.length>t&&(r+=" ... "),"<Buffer "+r+">"},w&&(o.prototype[w]=o.prototype.inspect),o.prototype.compare=function(r,t,n,e,u){if(C(r,Uint8Array)&&(r=o.from(r,r.offset,r.byteLength)),!o.isBuffer(r))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof r);if(t===void 0&&(t=0),n===void 0&&(n=r?r.length:0),e===void 0&&(e=0),u===void 0&&(u=this.length),t<0||n>r.length||e<0||u>this.length)throw new RangeError("out of range index");if(e>=u&&t>=n)return 0;if(e>=u)return-1;if(t>=n)return 1;if(t>>>=0,n>>>=0,e>>>=0,u>>>=0,this===r)return 0;let h=u-e,a=n-t;const d=Math.min(h,a),E=this.slice(e,u),g=r.slice(t,n);for(let x=0;x<d;++x)if(E[x]!==g[x]){h=E[x],a=g[x];break}return h<a?-1:a<h?1:0};function J(i,r,t,n,e){if(i.length===0)return-1;if(typeof t=="string"?(n=t,t=0):t>2147483647?t=2147483647:t<-2147483648&&(t=-2147483648),t=+t,q(t)&&(t=e?0:i.length-1),t<0&&(t=i.length+t),t>=i.length){if(e)return-1;t=i.length-1}else if(t<0)if(e)t=0;else return-1;if(typeof r=="string"&&(r=o.from(r,n)),o.isBuffer(r))return r.length===0?-1:K(i,r,t,n,e);if(typeof r=="number")return r=r&255,typeof Uint8Array.prototype.indexOf=="function"?e?Uint8Array.prototype.indexOf.call(i,r,t):Uint8Array.prototype.lastIndexOf.call(i,r,t):K(i,[r],t,n,e);throw new TypeError("val must be string, number or Buffer")}function K(i,r,t,n,e){let u=1,h=i.length,a=r.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(i.length<2||r.length<2)return-1;u=2,h/=2,a/=2,t/=2}function d(g,x){return u===1?g[x]:g.readUInt16BE(x*u)}let E;if(e){let g=-1;for(E=t;E<h;E++)if(d(i,E)===d(r,g===-1?0:E-g)){if(g===-1&&(g=E),E-g+1===a)return g*u}else g!==-1&&(E-=E-g),g=-1}else for(t+a>h&&(t=h-a),E=t;E>=0;E--){let g=!0;for(let x=0;x<a;x++)if(d(i,E+x)!==d(r,x)){g=!1;break}if(g)return E}return-1}o.prototype.includes=function(r,t,n){return this.indexOf(r,t,n)!==-1},o.prototype.indexOf=function(r,t,n){return J(this,r,t,n,!0)},o.prototype.lastIndexOf=function(r,t,n){return J(this,r,t,n,!1)};function sr(i,r,t,n){t=Number(t)||0;const e=i.length-t;n?(n=Number(n),n>e&&(n=e)):n=e;const u=r.length;n>u/2&&(n=u/2);let h;for(h=0;h<n;++h){const a=parseInt(r.substr(h*2,2),16);if(q(a))return h;i[t+h]=a}return h}function lr(i,r,t,n){return O(W(r,i.length-t),i,t,n)}function ar(i,r,t,n){return O(Ur(r),i,t,n)}function yr(i,r,t,n){return O(ur(r),i,t,n)}function wr(i,r,t,n){return O(Rr(r,i.length-t),i,t,n)}o.prototype.write=function(r,t,n,e){if(t===void 0)e="utf8",n=this.length,t=0;else if(n===void 0&&typeof t=="string")e=t,n=this.length,t=0;else if(isFinite(t))t=t>>>0,isFinite(n)?(n=n>>>0,e===void 0&&(e="utf8")):(e=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const u=this.length-t;if((n===void 0||n>u)&&(n=u),r.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");e||(e="utf8");let h=!1;for(;;)switch(e){case"hex":return sr(this,r,t,n);case"utf8":case"utf-8":return lr(this,r,t,n);case"ascii":case"latin1":case"binary":return ar(this,r,t,n);case"base64":return yr(this,r,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return wr(this,r,t,n);default:if(h)throw new TypeError("Unknown encoding: "+e);e=(""+e).toLowerCase(),h=!0}},o.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function xr(i,r,t){return r===0&&t===i.length?f.fromByteArray(i):f.fromByteArray(i.slice(r,t))}function Z(i,r,t){t=Math.min(i.length,t);const n=[];let e=r;for(;e<t;){const u=i[e];let h=null,a=u>239?4:u>223?3:u>191?2:1;if(e+a<=t){let d,E,g,x;switch(a){case 1:u<128&&(h=u);break;case 2:d=i[e+1],(d&192)===128&&(x=(u&31)<<6|d&63,x>127&&(h=x));break;case 3:d=i[e+1],E=i[e+2],(d&192)===128&&(E&192)===128&&(x=(u&15)<<12|(d&63)<<6|E&63,x>2047&&(x<55296||x>57343)&&(h=x));break;case 4:d=i[e+1],E=i[e+2],g=i[e+3],(d&192)===128&&(E&192)===128&&(g&192)===128&&(x=(u&15)<<18|(d&63)<<12|(E&63)<<6|g&63,x>65535&&x<1114112&&(h=x))}}h===null?(h=65533,a=1):h>65535&&(h-=65536,n.push(h>>>10&1023|55296),h=56320|h&1023),n.push(h),e+=a}return Br(n)}const Q=4096;function Br(i){const r=i.length;if(r<=Q)return String.fromCharCode.apply(String,i);let t="",n=0;for(;n<r;)t+=String.fromCharCode.apply(String,i.slice(n,n+=Q));return t}function Er(i,r,t){let n="";t=Math.min(i.length,t);for(let e=r;e<t;++e)n+=String.fromCharCode(i[e]&127);return n}function dr(i,r,t){let n="";t=Math.min(i.length,t);for(let e=r;e<t;++e)n+=String.fromCharCode(i[e]);return n}function gr(i,r,t){const n=i.length;(!r||r<0)&&(r=0),(!t||t<0||t>n)&&(t=n);let e="";for(let u=r;u<t;++u)e+=Tr[i[u]];return e}function mr(i,r,t){const n=i.slice(r,t);let e="";for(let u=0;u<n.length-1;u+=2)e+=String.fromCharCode(n[u]+n[u+1]*256);return e}o.prototype.slice=function(r,t){const n=this.length;r=~~r,t=t===void 0?n:~~t,r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),t<r&&(t=r);const e=this.subarray(r,t);return Object.setPrototypeOf(e,o.prototype),e};function m(i,r,t){if(i%1!==0||i<0)throw new RangeError("offset is not uint");if(i+r>t)throw new RangeError("Trying to access beyond buffer length")}o.prototype.readUintLE=o.prototype.readUIntLE=function(r,t,n){r=r>>>0,t=t>>>0,n||m(r,t,this.length);let e=this[r],u=1,h=0;for(;++h<t&&(u*=256);)e+=this[r+h]*u;return e},o.prototype.readUintBE=o.prototype.readUIntBE=function(r,t,n){r=r>>>0,t=t>>>0,n||m(r,t,this.length);let e=this[r+--t],u=1;for(;t>0&&(u*=256);)e+=this[r+--t]*u;return e},o.prototype.readUint8=o.prototype.readUInt8=function(r,t){return r=r>>>0,t||m(r,1,this.length),this[r]},o.prototype.readUint16LE=o.prototype.readUInt16LE=function(r,t){return r=r>>>0,t||m(r,2,this.length),this[r]|this[r+1]<<8},o.prototype.readUint16BE=o.prototype.readUInt16BE=function(r,t){return r=r>>>0,t||m(r,2,this.length),this[r]<<8|this[r+1]},o.prototype.readUint32LE=o.prototype.readUInt32LE=function(r,t){return r=r>>>0,t||m(r,4,this.length),(this[r]|this[r+1]<<8|this[r+2]<<16)+this[r+3]*16777216},o.prototype.readUint32BE=o.prototype.readUInt32BE=function(r,t){return r=r>>>0,t||m(r,4,this.length),this[r]*16777216+(this[r+1]<<16|this[r+2]<<8|this[r+3])},o.prototype.readBigUInt64LE=L(function(r){r=r>>>0,M(r,"offset");const t=this[r],n=this[r+7];(t===void 0||n===void 0)&&P(r,this.length-8);const e=t+this[++r]*2**8+this[++r]*2**16+this[++r]*2**24,u=this[++r]+this[++r]*2**8+this[++r]*2**16+n*2**24;return BigInt(e)+(BigInt(u)<<BigInt(32))}),o.prototype.readBigUInt64BE=L(function(r){r=r>>>0,M(r,"offset");const t=this[r],n=this[r+7];(t===void 0||n===void 0)&&P(r,this.length-8);const e=t*2**24+this[++r]*2**16+this[++r]*2**8+this[++r],u=this[++r]*2**24+this[++r]*2**16+this[++r]*2**8+n;return(BigInt(e)<<BigInt(32))+BigInt(u)}),o.prototype.readIntLE=function(r,t,n){r=r>>>0,t=t>>>0,n||m(r,t,this.length);let e=this[r],u=1,h=0;for(;++h<t&&(u*=256);)e+=this[r+h]*u;return u*=128,e>=u&&(e-=Math.pow(2,8*t)),e},o.prototype.readIntBE=function(r,t,n){r=r>>>0,t=t>>>0,n||m(r,t,this.length);let e=t,u=1,h=this[r+--e];for(;e>0&&(u*=256);)h+=this[r+--e]*u;return u*=128,h>=u&&(h-=Math.pow(2,8*t)),h},o.prototype.readInt8=function(r,t){return r=r>>>0,t||m(r,1,this.length),this[r]&128?(255-this[r]+1)*-1:this[r]},o.prototype.readInt16LE=function(r,t){r=r>>>0,t||m(r,2,this.length);const n=this[r]|this[r+1]<<8;return n&32768?n|4294901760:n},o.prototype.readInt16BE=function(r,t){r=r>>>0,t||m(r,2,this.length);const n=this[r+1]|this[r]<<8;return n&32768?n|4294901760:n},o.prototype.readInt32LE=function(r,t){return r=r>>>0,t||m(r,4,this.length),this[r]|this[r+1]<<8|this[r+2]<<16|this[r+3]<<24},o.prototype.readInt32BE=function(r,t){return r=r>>>0,t||m(r,4,this.length),this[r]<<24|this[r+1]<<16|this[r+2]<<8|this[r+3]},o.prototype.readBigInt64LE=L(function(r){r=r>>>0,M(r,"offset");const t=this[r],n=this[r+7];(t===void 0||n===void 0)&&P(r,this.length-8);const e=this[r+4]+this[r+5]*2**8+this[r+6]*2**16+(n<<24);return(BigInt(e)<<BigInt(32))+BigInt(t+this[++r]*2**8+this[++r]*2**16+this[++r]*2**24)}),o.prototype.readBigInt64BE=L(function(r){r=r>>>0,M(r,"offset");const t=this[r],n=this[r+7];(t===void 0||n===void 0)&&P(r,this.length-8);const e=(t<<24)+this[++r]*2**16+this[++r]*2**8+this[++r];return(BigInt(e)<<BigInt(32))+BigInt(this[++r]*2**24+this[++r]*2**16+this[++r]*2**8+n)}),o.prototype.readFloatLE=function(r,t){return r=r>>>0,t||m(r,4,this.length),s.read(this,r,!0,23,4)},o.prototype.readFloatBE=function(r,t){return r=r>>>0,t||m(r,4,this.length),s.read(this,r,!1,23,4)},o.prototype.readDoubleLE=function(r,t){return r=r>>>0,t||m(r,8,this.length),s.read(this,r,!0,52,8)},o.prototype.readDoubleBE=function(r,t){return r=r>>>0,t||m(r,8,this.length),s.read(this,r,!1,52,8)};function U(i,r,t,n,e,u){if(!o.isBuffer(i))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>e||r<u)throw new RangeError('"value" argument is out of bounds');if(t+n>i.length)throw new RangeError("Index out of range")}o.prototype.writeUintLE=o.prototype.writeUIntLE=function(r,t,n,e){if(r=+r,t=t>>>0,n=n>>>0,!e){const a=Math.pow(2,8*n)-1;U(this,r,t,n,a,0)}let u=1,h=0;for(this[t]=r&255;++h<n&&(u*=256);)this[t+h]=r/u&255;return t+n},o.prototype.writeUintBE=o.prototype.writeUIntBE=function(r,t,n,e){if(r=+r,t=t>>>0,n=n>>>0,!e){const a=Math.pow(2,8*n)-1;U(this,r,t,n,a,0)}let u=n-1,h=1;for(this[t+u]=r&255;--u>=0&&(h*=256);)this[t+u]=r/h&255;return t+n},o.prototype.writeUint8=o.prototype.writeUInt8=function(r,t,n){return r=+r,t=t>>>0,n||U(this,r,t,1,255,0),this[t]=r&255,t+1},o.prototype.writeUint16LE=o.prototype.writeUInt16LE=function(r,t,n){return r=+r,t=t>>>0,n||U(this,r,t,2,65535,0),this[t]=r&255,this[t+1]=r>>>8,t+2},o.prototype.writeUint16BE=o.prototype.writeUInt16BE=function(r,t,n){return r=+r,t=t>>>0,n||U(this,r,t,2,65535,0),this[t]=r>>>8,this[t+1]=r&255,t+2},o.prototype.writeUint32LE=o.prototype.writeUInt32LE=function(r,t,n){return r=+r,t=t>>>0,n||U(this,r,t,4,4294967295,0),this[t+3]=r>>>24,this[t+2]=r>>>16,this[t+1]=r>>>8,this[t]=r&255,t+4},o.prototype.writeUint32BE=o.prototype.writeUInt32BE=function(r,t,n){return r=+r,t=t>>>0,n||U(this,r,t,4,4294967295,0),this[t]=r>>>24,this[t+1]=r>>>16,this[t+2]=r>>>8,this[t+3]=r&255,t+4};function v(i,r,t,n,e){or(r,n,e,i,t,7);let u=Number(r&BigInt(4294967295));i[t++]=u,u=u>>8,i[t++]=u,u=u>>8,i[t++]=u,u=u>>8,i[t++]=u;let h=Number(r>>BigInt(32)&BigInt(4294967295));return i[t++]=h,h=h>>8,i[t++]=h,h=h>>8,i[t++]=h,h=h>>8,i[t++]=h,t}function rr(i,r,t,n,e){or(r,n,e,i,t,7);let u=Number(r&BigInt(4294967295));i[t+7]=u,u=u>>8,i[t+6]=u,u=u>>8,i[t+5]=u,u=u>>8,i[t+4]=u;let h=Number(r>>BigInt(32)&BigInt(4294967295));return i[t+3]=h,h=h>>8,i[t+2]=h,h=h>>8,i[t+1]=h,h=h>>8,i[t]=h,t+8}o.prototype.writeBigUInt64LE=L(function(r,t=0){return v(this,r,t,BigInt(0),BigInt("0xffffffffffffffff"))}),o.prototype.writeBigUInt64BE=L(function(r,t=0){return rr(this,r,t,BigInt(0),BigInt("0xffffffffffffffff"))}),o.prototype.writeIntLE=function(r,t,n,e){if(r=+r,t=t>>>0,!e){const d=Math.pow(2,8*n-1);U(this,r,t,n,d-1,-d)}let u=0,h=1,a=0;for(this[t]=r&255;++u<n&&(h*=256);)r<0&&a===0&&this[t+u-1]!==0&&(a=1),this[t+u]=(r/h>>0)-a&255;return t+n},o.prototype.writeIntBE=function(r,t,n,e){if(r=+r,t=t>>>0,!e){const d=Math.pow(2,8*n-1);U(this,r,t,n,d-1,-d)}let u=n-1,h=1,a=0;for(this[t+u]=r&255;--u>=0&&(h*=256);)r<0&&a===0&&this[t+u+1]!==0&&(a=1),this[t+u]=(r/h>>0)-a&255;return t+n},o.prototype.writeInt8=function(r,t,n){return r=+r,t=t>>>0,n||U(this,r,t,1,127,-128),r<0&&(r=255+r+1),this[t]=r&255,t+1},o.prototype.writeInt16LE=function(r,t,n){return r=+r,t=t>>>0,n||U(this,r,t,2,32767,-32768),this[t]=r&255,this[t+1]=r>>>8,t+2},o.prototype.writeInt16BE=function(r,t,n){return r=+r,t=t>>>0,n||U(this,r,t,2,32767,-32768),this[t]=r>>>8,this[t+1]=r&255,t+2},o.prototype.writeInt32LE=function(r,t,n){return r=+r,t=t>>>0,n||U(this,r,t,4,2147483647,-2147483648),this[t]=r&255,this[t+1]=r>>>8,this[t+2]=r>>>16,this[t+3]=r>>>24,t+4},o.prototype.writeInt32BE=function(r,t,n){return r=+r,t=t>>>0,n||U(this,r,t,4,2147483647,-2147483648),r<0&&(r=4294967295+r+1),this[t]=r>>>24,this[t+1]=r>>>16,this[t+2]=r>>>8,this[t+3]=r&255,t+4},o.prototype.writeBigInt64LE=L(function(r,t=0){return v(this,r,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),o.prototype.writeBigInt64BE=L(function(r,t=0){return rr(this,r,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function tr(i,r,t,n,e,u){if(t+n>i.length)throw new RangeError("Index out of range");if(t<0)throw new RangeError("Index out of range")}function ir(i,r,t,n,e){return r=+r,t=t>>>0,e||tr(i,r,t,4),s.write(i,r,t,n,23,4),t+4}o.prototype.writeFloatLE=function(r,t,n){return ir(this,r,t,!0,n)},o.prototype.writeFloatBE=function(r,t,n){return ir(this,r,t,!1,n)};function nr(i,r,t,n,e){return r=+r,t=t>>>0,e||tr(i,r,t,8),s.write(i,r,t,n,52,8),t+8}o.prototype.writeDoubleLE=function(r,t,n){return nr(this,r,t,!0,n)},o.prototype.writeDoubleBE=function(r,t,n){return nr(this,r,t,!1,n)},o.prototype.copy=function(r,t,n,e){if(!o.isBuffer(r))throw new TypeError("argument should be a Buffer");if(n||(n=0),!e&&e!==0&&(e=this.length),t>=r.length&&(t=r.length),t||(t=0),e>0&&e<n&&(e=n),e===n||r.length===0||this.length===0)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("sourceEnd out of bounds");e>this.length&&(e=this.length),r.length-t<e-n&&(e=r.length-t+n);const u=e-n;return this===r&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(t,n,e):Uint8Array.prototype.set.call(r,this.subarray(n,e),t),u},o.prototype.fill=function(r,t,n,e){if(typeof r=="string"){if(typeof t=="string"?(e=t,t=0,n=this.length):typeof n=="string"&&(e=n,n=this.length),e!==void 0&&typeof e!="string")throw new TypeError("encoding must be a string");if(typeof e=="string"&&!o.isEncoding(e))throw new TypeError("Unknown encoding: "+e);if(r.length===1){const h=r.charCodeAt(0);(e==="utf8"&&h<128||e==="latin1")&&(r=h)}}else typeof r=="number"?r=r&255:typeof r=="boolean"&&(r=Number(r));if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;t=t>>>0,n=n===void 0?this.length:n>>>0,r||(r=0);let u;if(typeof r=="number")for(u=t;u<n;++u)this[u]=r;else{const h=o.isBuffer(r)?r:o.from(r,e),a=h.length;if(a===0)throw new TypeError('The value "'+r+'" is invalid for argument "value"');for(u=0;u<n-t;++u)this[u+t]=h[u%a]}return this};const N={};function Y(i,r,t){N[i]=class extends t{constructor(){super(),Object.defineProperty(this,"message",{value:r.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${i}]`,this.stack,delete this.name}get code(){return i}set code(e){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:e,writable:!0})}toString(){return`${this.name} [${i}]: ${this.message}`}}}Y("ERR_BUFFER_OUT_OF_BOUNDS",function(i){return i?`${i} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),Y("ERR_INVALID_ARG_TYPE",function(i,r){return`The "${i}" argument must be of type number. Received type ${typeof r}`},TypeError),Y("ERR_OUT_OF_RANGE",function(i,r,t){let n=`The value of "${i}" is out of range.`,e=t;return Number.isInteger(t)&&Math.abs(t)>2**32?e=er(String(t)):typeof t=="bigint"&&(e=String(t),(t>BigInt(2)**BigInt(32)||t<-(BigInt(2)**BigInt(32)))&&(e=er(e)),e+="n"),n+=` It must be ${r}. Received ${e}`,n},RangeError);function er(i){let r="",t=i.length;const n=i[0]==="-"?1:0;for(;t>=n+4;t-=3)r=`_${i.slice(t-3,t)}${r}`;return`${i.slice(0,t)}${r}`}function Ir(i,r,t){M(r,"offset"),(i[r]===void 0||i[r+t]===void 0)&&P(r,i.length-(t+1))}function or(i,r,t,n,e,u){if(i>t||i<r){const h=typeof r=="bigint"?"n":"";let a;throw u>3?r===0||r===BigInt(0)?a=`>= 0${h} and < 2${h} ** ${(u+1)*8}${h}`:a=`>= -(2${h} ** ${(u+1)*8-1}${h}) and < 2 ** ${(u+1)*8-1}${h}`:a=`>= ${r}${h} and <= ${t}${h}`,new N.ERR_OUT_OF_RANGE("value",a,i)}Ir(n,e,u)}function M(i,r){if(typeof i!="number")throw new N.ERR_INVALID_ARG_TYPE(r,"number",i)}function P(i,r,t){throw Math.floor(i)!==i?(M(i,t),new N.ERR_OUT_OF_RANGE(t||"offset","an integer",i)):r<0?new N.ERR_BUFFER_OUT_OF_BOUNDS:new N.ERR_OUT_OF_RANGE(t||"offset",`>= ${t?1:0} and <= ${r}`,i)}const Fr=/[^+/0-9A-Za-z-_]/g;function Ar(i){if(i=i.split("=")[0],i=i.trim().replace(Fr,""),i.length<2)return"";for(;i.length%4!==0;)i=i+"=";return i}function W(i,r){r=r||1/0;let t;const n=i.length;let e=null;const u=[];for(let h=0;h<n;++h){if(t=i.charCodeAt(h),t>55295&&t<57344){if(!e){if(t>56319){(r-=3)>-1&&u.push(239,191,189);continue}else if(h+1===n){(r-=3)>-1&&u.push(239,191,189);continue}e=t;continue}if(t<56320){(r-=3)>-1&&u.push(239,191,189),e=t;continue}t=(e-55296<<10|t-56320)+65536}else e&&(r-=3)>-1&&u.push(239,191,189);if(e=null,t<128){if((r-=1)<0)break;u.push(t)}else if(t<2048){if((r-=2)<0)break;u.push(t>>6|192,t&63|128)}else if(t<65536){if((r-=3)<0)break;u.push(t>>12|224,t>>6&63|128,t&63|128)}else if(t<1114112){if((r-=4)<0)break;u.push(t>>18|240,t>>12&63|128,t>>6&63|128,t&63|128)}else throw new Error("Invalid code point")}return u}function Ur(i){const r=[];for(let t=0;t<i.length;++t)r.push(i.charCodeAt(t)&255);return r}function Rr(i,r){let t,n,e;const u=[];for(let h=0;h<i.length&&!((r-=2)<0);++h)t=i.charCodeAt(h),n=t>>8,e=t%256,u.push(e),u.push(n);return u}function ur(i){return f.toByteArray(Ar(i))}function O(i,r,t,n){let e;for(e=0;e<n&&!(e+t>=r.length||e>=i.length);++e)r[e+t]=i[e];return e}function C(i,r){return i instanceof r||i!=null&&i.constructor!=null&&i.constructor.name!=null&&i.constructor.name===r.name}function q(i){return i!==i}const Tr=function(){const i="0123456789abcdef",r=new Array(256);for(let t=0;t<16;++t){const n=t*16;for(let e=0;e<16;++e)r[n+e]=i[t]+i[e]}return r}();function L(i){return typeof BigInt>"u"?Cr:i}function Cr(){throw new Error("BigInt not supported")}})(V);const Or=_r(V),Yr=Sr({__proto__:null,default:Or},[V]);export{V as b,Yr as i}; diff --git a/segmentmodel/assets/index-4e587624.js b/segmentmodel/assets/index-4e587624.js new file mode 100644 index 0000000..2945652 --- /dev/null +++ b/segmentmodel/assets/index-4e587624.js @@ -0,0 +1,3 @@ +import{_ as J,L as K}from"./index-d89cadd6.js";import{b as Q}from"./index-462333f7.js";import{L as N}from"./__vite-browser-external-d053bc6e.js";import{u as z,L as G,a as W}from"./long-c1fdf4ae.js";import"./_commonjsHelpers-de833af9.js";function H(a){if(a.greaterThan(Number.MAX_SAFE_INTEGER)||a.lessThan(Number.MIN_SAFE_INTEGER))throw new Error("integer overflow");return a.toNumber()}class Z extends Error{}function L(a){if(a&&a.aborted){if(typeof DOMException<"u")throw new DOMException("aborted","AbortError");{const e=new Z("aborted");throw e.code="ERR_ABORTED",e}}}function ee(a,e){return e.minv.blockPosition-a.maxv.blockPosition<65e3&&e.maxv.blockPosition-a.minv.blockPosition<5e6}function j(a,e){const t=[];let n=null;return a.length===0?a:(a.sort(function(r,i){const o=r.minv.blockPosition-i.minv.blockPosition;return o!==0?o:r.minv.dataPosition-i.minv.dataPosition}),a.forEach(r=>{(!e||r.maxv.compareTo(e)>0)&&(n===null?(t.push(r),n=r):ee(n,r)?r.maxv.compareTo(n.maxv)>0&&(n.maxv=r.maxv):(t.push(r),n=r))}),t)}class ${constructor(e,t){this.blockPosition=e,this.dataPosition=t}toString(){return`${this.blockPosition}:${this.dataPosition}`}compareTo(e){return this.blockPosition-e.blockPosition||this.dataPosition-e.dataPosition}static min(...e){let t,n=0;for(;!t;n+=1)t=e[n];for(;n<e.length;n+=1)t.compareTo(e[n])>0&&(t=e[n]);return t}}function v(a,e=0,t=!1){if(t)throw new Error("big-endian virtual file offsets not implemented");return new $(a[e+7]*1099511627776+a[e+6]*4294967296+a[e+5]*16777216+a[e+4]*65536+a[e+3]*256+a[e+2],a[e+1]<<8|a[e])}class P{constructor(e,t,n,r=void 0){this.minv=e,this.maxv=t,this.bin=n,this._fetchedSize=r}toUniqueString(){return`${this.minv}..${this.maxv} (bin ${this.bin}, fetchedSize ${this.fetchedSize()})`}toString(){return this.toUniqueString()}compareTo(e){return this.minv.compareTo(e.minv)||this.maxv.compareTo(e.maxv)||this.bin-e.bin}fetchedSize(){return this._fetchedSize!==void 0?this._fetchedSize:this.maxv.blockPosition+65536-this.minv.blockPosition}}class X{constructor({filehandle:e,renameRefSeqs:t=n=>n}){this.filehandle=e,this.renameRefSeq=t}async getMetadata(e={}){const{indices:t,...n}=await this.parse(e);return n}_findFirstData(e,t){return e?e.compareTo(t)>0?t:e:t}async parse(e={}){return this.parseP||(this.parseP=this._parse(e).catch(t=>{throw this.parseP=void 0,t})),this.parseP}async hasRefSeq(e,t={}){return!!((await this.parse(t)).indices[e]||{}).binIndex}}const te=21578324,O=14;function ne(a,e){return a+=1,e-=1,[[0,0],[1+(a>>26),1+(e>>26)],[9+(a>>23),9+(e>>23)],[73+(a>>20),73+(e>>20)],[585+(a>>17),585+(e>>17)],[4681+(a>>14),4681+(e>>14)]]}class A extends X{async lineCount(e,t={}){const n=await this.parse(t);if(!n)return-1;const r=n.refNameToId[e];if(!n.indices[r])return-1;const{stats:o}=n.indices[r];return o?o.lineCount:-1}async _parse(e={}){const t=await this.filehandle.readFile(e),n=await z(t);if(L(e.signal),n.readUInt32LE(0)!==te)throw new Error("Not a TBI file");const r=n.readInt32LE(4),i=n.readInt32LE(8),o=i&65536?"zero-based-half-open":"1-based-closed",u={0:"generic",1:"SAM",2:"VCF"}[i&15];if(!u)throw new Error(`invalid Tabix preset format flags ${i}`);const c={ref:n.readInt32LE(12),start:n.readInt32LE(16),end:n.readInt32LE(20)},h=n.readInt32LE(24),f=5,l=((1<<(f+1)*3)-1)/7,b=2**(14+f*3),x=h?String.fromCharCode(h):null,w=n.readInt32LE(28),I=n.readInt32LE(32),{refNameToId:m,refIdToName:p}=this._parseNameBytes(n.slice(36,36+I));let d=36+I,g;return{indices:new Array(r).fill(0).map(()=>{const E=n.readInt32LE(d);d+=4;const k={};let R;for(let C=0;C<E;C+=1){const y=n.readUInt32LE(d);if(d+=4,y>l+1)throw new Error("tabix index contains too many bins, please use a CSI index");if(y===l+1){const S=n.readInt32LE(d);d+=4,S===2&&(R=this.parsePseudoBin(n,d)),d+=16*S}else{const S=n.readInt32LE(d);d+=4;const M=new Array(S);for(let B=0;B<S;B+=1){const V=v(n,d),Y=v(n,d+8);d+=16,g=this._findFirstData(g,V),M[B]=new P(V,Y,y)}k[y]=M}}const F=n.readInt32LE(d);d+=4;const _=new Array(F);for(let C=0;C<F;C+=1)_[C]=v(n,d),d+=8,g=this._findFirstData(g,_[C]);return{binIndex:k,linearIndex:_,stats:R}}),metaChar:x,maxBinNumber:l,maxRefLength:b,skipLines:w,firstDataLine:g,columnNumbers:c,coordinateType:o,format:u,refIdToName:p,refNameToId:m,maxBlockSize:65536}}parsePseudoBin(e,t){return{lineCount:H(G.fromBytesLE(e.slice(t+16,t+24),!0))}}_parseNameBytes(e){let t=0,n=0;const r=[],i={};for(let o=0;o<e.length;o+=1)if(!e[o]){if(n<o){let s=e.toString("utf8",n,o);s=this.renameRefSeq(s),r[t]=s,i[s]=t}n=o+1,t+=1}return{refNameToId:i,refIdToName:r}}async blocksForRange(e,t,n,r={}){t<0&&(t=0);const i=await this.parse(r);if(!i)return[];const o=i.refNameToId[e],s=i.indices[o];if(!s)return[];(s.linearIndex.length?s.linearIndex[t>>O>=s.linearIndex.length?s.linearIndex.length-1:t>>O]:new $(0,0))||console.warn("querying outside of possible tabix range");const c=ne(t,n),h=[];for(const[w,I]of c)for(let m=w;m<=I;m++)if(s.binIndex[m]){const p=s.binIndex[m];for(let d=0;d<p.length;++d)h.push(new P(p[d].minv,p[d].maxv,m))}const f=s.linearIndex.length;let l=null;const b=Math.min(t>>14,f-1),x=Math.min(n>>14,f-1);for(let w=b;w<=x;++w){const I=s.linearIndex[w];I&&(!l||I.compareTo(l)<0)&&(l=I)}return j(h,l)}}const ie=21582659,re=38359875;function oe(a,e){return a*2**e}function q(a,e){return Math.floor(a/2**e)}class U extends X{constructor(e){super(e),this.maxBinNumber=0,this.depth=0,this.minShift=0}async lineCount(e,t={}){const n=await this.parse(t);if(!n)return-1;const r=n.refNameToId[e];if(!n.indices[r])return-1;const{stats:o}=n.indices[r];return o?o.lineCount:-1}async indexCov(){throw new Error("CSI indexes do not support indexcov")}parseAuxData(e,t){const n=e.readInt32LE(t),r=n&65536?"zero-based-half-open":"1-based-closed",i={0:"generic",1:"SAM",2:"VCF"}[n&15];if(!i)throw new Error(`invalid Tabix preset format flags ${n}`);const o={ref:e.readInt32LE(t+4),start:e.readInt32LE(t+8),end:e.readInt32LE(t+12)},s=e.readInt32LE(t+16),u=s?String.fromCharCode(s):null,c=e.readInt32LE(t+20),h=e.readInt32LE(t+24),{refIdToName:f,refNameToId:l}=this._parseNameBytes(e.slice(t+28,t+28+h));return{refIdToName:f,refNameToId:l,skipLines:c,metaChar:u,columnNumbers:o,format:i,coordinateType:r}}_parseNameBytes(e){let t=0,n=0;const r=[],i={};for(let o=0;o<e.length;o+=1)if(!e[o]){if(n<o){let s=e.toString("utf8",n,o);s=this.renameRefSeq(s),r[t]=s,i[s]=t}n=o+1,t+=1}return{refNameToId:i,refIdToName:r}}async _parse(e={}){const t=await z(await this.filehandle.readFile(e));let n;if(t.readUInt32LE(0)===ie)n=1;else if(t.readUInt32LE(0)===re)n=2;else throw new Error("Not a CSI file");this.minShift=t.readInt32LE(4),this.depth=t.readInt32LE(8),this.maxBinNumber=((1<<(this.depth+1)*3)-1)/7;const r=2**(this.minShift+this.depth*3),i=t.readInt32LE(12),o=i&&i>=30?this.parseAuxData(t,16):{refIdToName:[],refNameToId:{},metaChar:null,columnNumbers:{ref:0,start:1,end:2},coordinateType:"zero-based-half-open",format:"generic"},s=t.readInt32LE(16+i);let u,c=16+i+4;const h=new Array(s).fill(0).map(()=>{const f=t.readInt32LE(c);c+=4;const l={};let b;for(let x=0;x<f;x+=1){const w=t.readUInt32LE(c);if(w>this.maxBinNumber)b=this.parsePseudoBin(t,c+4),c+=4+8+4+16+16;else{const I=v(t,c+4);u=this._findFirstData(u,I);const m=t.readInt32LE(c+12);c+=16;const p=new Array(m);for(let d=0;d<m;d+=1){const g=v(t,c),T=v(t,c+8);c+=16,p[d]=new P(g,T,w)}l[w]=p}}return{binIndex:l,stats:b}});return{...o,csi:!0,refCount:s,maxBlockSize:65536,firstDataLine:u,csiVersion:n,indices:h,depth:this.depth,maxBinNumber:this.maxBinNumber,maxRefLength:r}}parsePseudoBin(e,t){return{lineCount:H(G.fromBytesLE(e.slice(t+28,t+36),!0))}}async blocksForRange(e,t,n,r={}){t<0&&(t=0);const i=await this.parse(r);if(!i)return[];const o=i.refNameToId[e],s=i.indices[o];if(!s)return[];const u=this.reg2bins(t,n),c=[];for(const[h,f]of u)for(let l=h;l<=f;l++)if(s.binIndex[l]){const b=s.binIndex[l];for(let x=0;x<b.length;++x)c.push(new P(b[x].minv,b[x].maxv,l))}return j(c,new $(0,0))}reg2bins(e,t){e-=1,e<1&&(e=1),t>2**50&&(t=2**34),t-=1;let n=0,r=0,i=this.minShift+this.depth*3;const o=[];for(;n<=this.depth;i-=3,r+=oe(1,n*3),n+=1){const s=r+q(e,i),u=r+q(t,i);if(u-s+o.length>this.maxBinNumber)throw new Error(`query ${e}-${t} is too large for current binning scheme (shift ${this.minShift}, depth ${this.depth}), try a smaller query or a coarser index binning scheme`);o.push([s,u])}return o}}const D=typeof TextDecoder<"u"?new TextDecoder("utf-8"):void 0;function se(a){return new Promise(e=>setTimeout(e,a))}class he{constructor({path:e,filehandle:t,tbiPath:n,tbiFilehandle:r,csiPath:i,csiFilehandle:o,yieldTime:s=500,chunkSizeLimit:u=5e7,renameRefSeqs:c=f=>f,chunkCacheSize:h=5*2**20}){if(t)this.filehandle=t;else if(e)this.filehandle=new N(e);else throw new TypeError("must provide either filehandle or path");if(r)this.index=new A({filehandle:r,renameRefSeqs:c});else if(o)this.index=new U({filehandle:o,renameRefSeqs:c});else if(n)this.index=new A({filehandle:new N(n),renameRefSeqs:c});else if(i)this.index=new U({filehandle:new N(i),renameRefSeqs:c});else if(e)this.index=new A({filehandle:new N(`${e}.tbi`),renameRefSeqs:c});else throw new TypeError("must provide one of tbiFilehandle, tbiPath, csiFilehandle, or csiPath");this.chunkSizeLimit=u,this.renameRefSeq=c,this.yieldTime=s,this.chunkCache=new J({cache:new K({maxSize:Math.floor(h/65536)}),fill:(f,l)=>this.readChunk(f,{signal:l})})}async getLines(e,t,n,r){let i,o={},s;if(typeof r>"u")throw new TypeError("line callback must be provided");if(typeof r=="function"?s=r:(o=r,s=r.lineCallback),e===void 0)throw new TypeError("must provide a reference sequence name");if(!s)throw new TypeError("line callback must be provided");const u=await this.index.getMetadata(o);if(L(i),t||(t=0),n||(n=u.maxRefLength),!(t<=n))throw new TypeError("invalid start and end coordinates. start must be less than or equal to end");if(t===n)return;const c=await this.index.blocksForRange(e,t,n,o);L(i);for(let f=0;f<c.length;f+=1){const l=c[f].fetchedSize();if(l>this.chunkSizeLimit)throw new Error(`Too much data. Chunk size ${l.toLocaleString()} bytes exceeds chunkSizeLimit of ${this.chunkSizeLimit.toLocaleString()}.`)}let h=Date.now();for(let f=0;f<c.length;f+=1){let l;const b=c[f],{buffer:x,cpositions:w,dpositions:I}=await this.chunkCache.get(b.toString(),b);L(i);let m=0,p=0;for(;m<x.length;){const d=x.indexOf(` +`,m);if(d===-1)break;const g=x.slice(m,d),T=(D==null?void 0:D.decode(g))||g.toString();if(I){for(;m+b.minv.dataPosition>=I[p++];);p--}const{startCoordinate:E,overlaps:k}=this.checkLine(u,e,t,n,T);if(l!==void 0&&E!==void 0&&l>E)throw new Error(`Lines not sorted by start coordinate (${l} > ${E}), this file is not usable with Tabix.`);if(l=E,k)s(T.trim(),w[p]*256+(m-I[p])+b.minv.dataPosition+1);else if(E!==void 0&&E>=n)return;this.yieldTime&&h-Date.now()>this.yieldTime&&(h=Date.now(),L(i),await se(1)),m=d+1}}}async getMetadata(e={}){return this.index.getMetadata(e)}async getHeaderBuffer(e={}){const{firstDataLine:t,metaChar:n,maxBlockSize:r}=await this.getMetadata(e);L(e.signal);const i=((t==null?void 0:t.blockPosition)||0)+r;let o=await this._readRegion(0,i,e);L(e.signal);try{o=await z(o)}catch(s){throw console.error(s),new Error(`error decompressing block ${s.code} at 0 (length ${i}) ${s}`)}if(n){let s=-1;const u=` +`.charCodeAt(0),c=n.charCodeAt(0);for(let h=0;h<o.length&&!(h===s+1&&o[h]!==c);h+=1)o[h]===u&&(s=h);o=o.slice(0,s+1)}return o}async getHeader(e={}){return(await this.getHeaderBuffer(e)).toString("utf8")}async getReferenceSequenceNames(e={}){return(await this.getMetadata(e)).refIdToName}checkLine(e,t,n,r,i){const{columnNumbers:o,metaChar:s,coordinateType:u,format:c}=e;if(i.charAt(0)===s)return{overlaps:!1};let{ref:h,start:f,end:l}=o;h||(h=0),f||(f=0),l||(l=0),c==="VCF"&&(l=8);const b=Math.max(h,f,l);let x=1,w=0,I="",m=-1/0;for(let p=0;p<i.length+1;p+=1)if(i[p]===" "||p===i.length){if(x===h){if(this.renameRefSeq(i.slice(w,p))!==t)return{overlaps:!1}}else if(x===f){if(m=parseInt(i.slice(w,p),10),u==="1-based-closed"&&(m-=1),m>=r)return{startCoordinate:m,overlaps:!1};if((l===0||l===f)&&m+1<=n)return{startCoordinate:m,overlaps:!1}}else if(c==="VCF"&&x===4)I=i.slice(w,p);else if(x===l){let d;if(c==="VCF"?d=this._getVcfEnd(m,I,i.slice(w,p)):d=parseInt(i.slice(w,p),10),d<=n)return{overlaps:!1}}if(w=p+1,x+=1,x>b)break}return{startCoordinate:m,overlaps:!0}}_getVcfEnd(e,t,n){let r=e+t.length;const i=n.indexOf("SVTYPE=TRA")!==-1;if(n[0]!=="."&&!i){let o=";";for(let s=0;s<n.length;s+=1){if(o===";"&&n.slice(s,s+4)==="END="){let u=n.indexOf(";",s);u===-1&&(u=n.length),r=parseInt(n.slice(s+4,u),10);break}o=n[s]}}else if(i)return e+1;return r}async lineCount(e,t={}){return this.index.lineCount(e,t)}async _readRegion(e,t,n={}){const r=Q.Buffer.alloc(t),{bytesRead:i,buffer:o}=await this.filehandle.read(r,0,t,e,n);return o.slice(0,i)}async readChunk(e,t={}){const n=await this._readRegion(e.minv.blockPosition,e.fetchedSize(),t);try{return W(n,e)}catch(r){throw new Error(`error decompressing c ${e.toString()} ${r}`)}}}export{U as CSI,A as TBI,he as TabixIndexedFile}; diff --git a/segmentmodel/assets/index-5c802462.js b/segmentmodel/assets/index-5c802462.js new file mode 100644 index 0000000..1a55d81 --- /dev/null +++ b/segmentmodel/assets/index-5c802462.js @@ -0,0 +1 @@ +import{L as d}from"./__vite-browser-external-d053bc6e.js";import{R as b}from"./remoteFile-1948951e.js";import{b as i}from"./index-462333f7.js";import"./_commonjsHelpers-de833af9.js";function a(o){const r=new FileReader;return new Promise((n,e)=>{r.onerror=()=>{r.abort(),e(new Error("problem reading blob"))},r.onabort=()=>{e(new Error("blob reading was aborted"))},r.onload=()=>{r.result&&typeof r.result!="string"?n(r.result):e(new Error("unknown error reading blob"))},r.readAsArrayBuffer(o)})}function c(o){const r=new FileReader;return new Promise((n,e)=>{r.onerror=()=>{r.abort(),e(new Error("problem reading blob"))},r.onabort=()=>{e(new Error("blob reading was aborted"))},r.onload=()=>{r.result&&typeof r.result=="string"?n(r.result):e(new Error("unknown error reading blob"))},r.readAsText(o)})}class E{constructor(r){this.blob=r,this.size=r.size}async read(r,n=0,e,f=0){if(!e)return{bytesRead:0,buffer:r};const t=f,u=t+e,l=await a(this.blob.slice(t,u)),s=i.Buffer.from(l);return{bytesRead:s.copy(r,n),buffer:s}}async readFile(r){let n;if(typeof r=="string"?n=r:n=r&&r.encoding,n==="utf8")return c(this.blob);if(n)throw new Error(`unsupported encoding: ${n}`);const e=await a(this.blob);return i.Buffer.from(e)}async stat(){return{size:this.size}}async close(){}}function w(o,r={}){return new b(o,r)}function R(o,r,n,e={}){if(n!==void 0)return n;if(o!==void 0)return w(o,e);if(r!==void 0)return new d(r,e);throw new Error("no url, path, or filehandle provided, cannot open")}export{E as BlobFile,d as LocalFile,b as RemoteFile,w as fromUrl,R as open}; diff --git a/segmentmodel/assets/index-7a37a249.js b/segmentmodel/assets/index-7a37a249.js new file mode 100644 index 0000000..807e6af --- /dev/null +++ b/segmentmodel/assets/index-7a37a249.js @@ -0,0 +1,162 @@ +import{g as vt}from"./_commonjsHelpers-de833af9.js";function xt(s,h){function t(){this.constructor=s}t.prototype=h.prototype,s.prototype=new t}function I(s,h,t,y){this.message=s,this.expected=h,this.found=t,this.location=y,this.name="SyntaxError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,I)}xt(I,Error);I.buildMessage=function(s,h){var t={literal:function(f){return'"'+F(f.text)+'"'},class:function(f){var m="",S;for(S=0;S<f.parts.length;S++)m+=f.parts[S]instanceof Array?A(f.parts[S][0])+"-"+A(f.parts[S][1]):A(f.parts[S]);return"["+(f.inverted?"^":"")+m+"]"},any:function(f){return"any character"},end:function(f){return"end of input"},other:function(f){return f.description}};function y(f){return f.charCodeAt(0).toString(16).toUpperCase()}function F(f){return f.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(m){return"\\x0"+y(m)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(m){return"\\x"+y(m)})}function A(f){return f.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(m){return"\\x0"+y(m)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(m){return"\\x"+y(m)})}function p(f){return t[f.type](f)}function k(f){var m=new Array(f.length),S,v;for(S=0;S<f.length;S++)m[S]=p(f[S]);if(m.sort(),m.length>0){for(S=1,v=1;S<m.length;S++)m[S-1]!==m[S]&&(m[v]=m[S],v++);m.length=v}switch(m.length){case 1:return m[0];case 2:return m[0]+" or "+m[1];default:return m.slice(0,-1).join(", ")+", or "+m[m.length-1]}}function D(f){return f?'"'+F(f)+'"':"end of input"}return"Expected "+k(s)+" but "+D(h)+" found."};function qt(s,h){h=h!==void 0?h:{};var t={},y={declaration:Ne},F=Ne,A="(",p=g("(",!1),k=")",D=g(")",!1),f=function(e,o,i,n){return{type:e,name:o,comment:i,fields:n}},m="simple",S=g("simple",!1),v="object",O=g("object",!1),B="table",Be=g("table",!1),G="auto",H=g("auto",!1),J="primary",Ie=g("primary",!1),K="index",Pe=g("index",!1),ee="unique",Ge=g("unique",!1),_=function(e,o){return o},_e=function(e,o){return e.name&&o.unshift(e),o},Me="#",je=g("#",!1),U=";",V=g(";",!1),Le=function(e,o,i){return{type:e,name:o,comment:i}},Oe="[",Ue=g("[",!1),Ve="]",Ze=g("]",!1),Qe=function(e,o,i,n){return{type:e,size:o,name:i,comment:n}},We=function(e,o,i,n){return{type:e,vals:o,name:i,comment:n}},te=",",re=g(",",!1),Xe=function(e,o){return o.unshift(e),o},oe="int",Ye=g("int",!1),ie="uint",He=g("uint",!1),se="short",Je=g("short",!1),ne="ushort",Ke=g("ushort",!1),ae="byte",et=g("byte",!1),ce="ubyte",tt=g("ubyte",!1),fe="float",rt=g("float",!1),le="char",ot=g("char",!1),ue="string",it=g("string",!1),he="lstring",st=g("lstring",!1),me="enum",nt=g("enum",!1),ge="double",at=g("double",!1),pe="bigint",ct=g("bigint",!1),de="set",ft=g("set",!1),lt=function(e,o){return e+" "+o},ut=/^[a-zA-Z_]/,ht=P([["a","z"],["A","Z"],"_"],!1,!1),be=/^[a-zA-Z0-9_]/,Se=P([["a","z"],["A","Z"],["0","9"],"_"],!1,!1),mt=function(e){return we()},$e=/^[^\n\r]/,ye=P([` +`,"\r"],!0,!1),gt=function(e){return e.join("").replace(/^"/,"").replace(/"$/,"")},pt=ve("integer"),Ee=/^[0-9]/,ke=P([["0","9"]],!1,!1),dt=function(){return parseInt(we(),10)},bt=ve("whitespace"),Ce=/^[ \t\n\r]/,Ae=P([" "," ",` +`,"\r"],!1,!1),r=0,$=0,M=[{line:1,column:1}],w=0,Z=[],c=0,j;if("startRule"in h){if(!(h.startRule in y))throw new Error(`Can't start parsing from rule "`+h.startRule+'".');F=y[h.startRule]}function we(){return s.substring($,r)}function g(e,o){return{type:"literal",text:e,ignoreCase:o}}function P(e,o,i){return{type:"class",parts:e,inverted:o,ignoreCase:i}}function St(){return{type:"end"}}function ve(e){return{type:"other",description:e}}function xe(e){var o=M[e],i;if(o)return o;for(i=e-1;!M[i];)i--;for(o=M[i],o={line:o.line,column:o.column};i<e;)s.charCodeAt(i)===10?(o.line++,o.column=1):o.column++,i++;return M[e]=o,o}function qe(e,o){var i=xe(e),n=xe(o);return{start:{offset:e,line:i.line,column:i.column},end:{offset:o,line:n.line,column:n.column}}}function l(e){r<w||(r>w&&(w=r,Z=[]),Z.push(e))}function $t(e,o,i){return new I(I.buildMessage(e,o),e,o,i)}function Ne(){var e,o,i,n,a,d,b,E,R,x,T,q,z,N;return e=r,o=u(),o!==t?(i=Fe(),i!==t?(n=u(),n!==t?(a=De(),a!==t?(d=u(),d!==t?(b=L(),b!==t?(E=u(),E!==t?(s.charCodeAt(r)===40?(R=A,r++):(R=t,c===0&&l(p)),R!==t?(x=u(),x!==t?(T=yt(),T!==t?(q=u(),q!==t?(s.charCodeAt(r)===41?(z=k,r++):(z=t,c===0&&l(D)),z!==t?(N=u(),N!==t?($=e,o=f(i,a,b,T),e=o):(r=e,e=t)):(r=e,e=t)):(r=e,e=t)):(r=e,e=t)):(r=e,e=t)):(r=e,e=t)):(r=e,e=t)):(r=e,e=t)):(r=e,e=t)):(r=e,e=t)):(r=e,e=t)):(r=e,e=t)):(r=e,e=t),e}function Fe(){var e;return s.substr(r,6)===m?(e=m,r+=6):(e=t,c===0&&l(S)),e===t&&(s.substr(r,6)===v?(e=v,r+=6):(e=t,c===0&&l(O)),e===t&&(s.substr(r,5)===B?(e=B,r+=5):(e=t,c===0&&l(Be)))),e}function De(){var e,o,i,n;return e=C(),e===t&&(e=r,o=C(),o!==t?(i=Re(),i!==t?(o=[o,i],e=o):(r=e,e=t)):(r=e,e=t),e===t&&(e=r,o=C(),o!==t?(s.substr(r,4)===G?(i=G,r+=4):(i=t,c===0&&l(H)),i!==t?(o=[o,i],e=o):(r=e,e=t)):(r=e,e=t),e===t&&(e=r,o=C(),o!==t?(i=Re(),i!==t?(s.substr(r,4)===G?(n=G,r+=4):(n=t,c===0&&l(H)),n!==t?(o=[o,i,n],e=o):(r=e,e=t)):(r=e,e=t)):(r=e,e=t)))),e}function Re(){var e;return s.substr(r,7)===J?(e=J,r+=7):(e=t,c===0&&l(Ie)),e===t&&(s.substr(r,5)===K?(e=K,r+=5):(e=t,c===0&&l(Pe)),e===t&&(s.substr(r,6)===ee?(e=ee,r+=6):(e=t,c===0&&l(Ge)))),e}function L(){var e;return e=Te(),e===t&&(e=u()),e}function yt(){var e,o,i,n,a,d,b;if(e=r,o=Q(),o!==t)if(i=u(),i!==t){for(n=[],a=r,d=u(),d!==t?(b=Q(),b!==t?($=a,d=_(o,b),a=d):(r=a,a=t)):(r=a,a=t);a!==t;)n.push(a),a=r,d=u(),d!==t?(b=Q(),b!==t?($=a,d=_(o,b),a=d):(r=a,a=t)):(r=a,a=t);n!==t?(a=u(),a!==t?($=e,o=_e(o,n),e=o):(r=e,e=t)):(r=e,e=t)}else r=e,e=t;else r=e,e=t;return e}function Et(){var e;return s.charCodeAt(r)===35?(e=Me,r++):(e=t,c===0&&l(je)),e}function kt(){var e,o,i,n,a;return e=r,o=u(),o!==t?(i=Et(),i!==t?(n=Te(),n!==t?(a=u(),a!==t?(o=[o,i,n,a],e=o):(r=e,e=t)):(r=e,e=t)):(r=e,e=t)):(r=e,e=t),e}function Q(){var e,o,i,n,a,d,b,E,R,x,T,q,z,N;return e=r,o=W(),o!==t?(i=u(),i!==t?(n=C(),n!==t?(a=u(),a!==t?(s.charCodeAt(r)===59?(d=U,r++):(d=t,c===0&&l(V)),d!==t?(b=u(),b!==t?(E=L(),E!==t?($=e,o=Le(o,n,E),e=o):(r=e,e=t)):(r=e,e=t)):(r=e,e=t)):(r=e,e=t)):(r=e,e=t)):(r=e,e=t)):(r=e,e=t),e===t&&(e=r,o=W(),o!==t?(i=u(),i!==t?(s.charCodeAt(r)===91?(n=Oe,r++):(n=t,c===0&&l(Ue)),n!==t?(a=u(),a!==t?(d=At(),d!==t?(b=u(),b!==t?(s.charCodeAt(r)===93?(E=Ve,r++):(E=t,c===0&&l(Ze)),E!==t?(R=u(),R!==t?(x=C(),x!==t?(T=u(),T!==t?(s.charCodeAt(r)===59?(q=U,r++):(q=t,c===0&&l(V)),q!==t?(z=u(),z!==t?(N=L(),N!==t?($=e,o=Qe(o,d,x,N),e=o):(r=e,e=t)):(r=e,e=t)):(r=e,e=t)):(r=e,e=t)):(r=e,e=t)):(r=e,e=t)):(r=e,e=t)):(r=e,e=t)):(r=e,e=t)):(r=e,e=t)):(r=e,e=t)):(r=e,e=t)):(r=e,e=t),e===t&&(e=r,o=W(),o!==t?(i=u(),i!==t?(s.charCodeAt(r)===40?(n=A,r++):(n=t,c===0&&l(p)),n!==t?(a=u(),a!==t?(d=Ct(),d!==t?(b=u(),b!==t?(s.charCodeAt(r)===41?(E=k,r++):(E=t,c===0&&l(D)),E!==t?(R=u(),R!==t?(x=C(),x!==t?(T=u(),T!==t?(s.charCodeAt(r)===59?(q=U,r++):(q=t,c===0&&l(V)),q!==t?(z=u(),z!==t?(N=L(),N!==t?($=e,o=We(o,d,x,N),e=o):(r=e,e=t)):(r=e,e=t)):(r=e,e=t)):(r=e,e=t)):(r=e,e=t)):(r=e,e=t)):(r=e,e=t)):(r=e,e=t)):(r=e,e=t)):(r=e,e=t)):(r=e,e=t)):(r=e,e=t)):(r=e,e=t),e===t&&(e=kt()))),e}function Ct(){var e,o,i,n,a,d,b;if(e=r,o=C(),o!==t){for(i=[],n=r,s.charCodeAt(r)===44?(a=te,r++):(a=t,c===0&&l(re)),a!==t?(d=u(),d!==t?(b=C(),b!==t?($=n,a=_(o,b),n=a):(r=n,n=t)):(r=n,n=t)):(r=n,n=t);n!==t;)i.push(n),n=r,s.charCodeAt(r)===44?(a=te,r++):(a=t,c===0&&l(re)),a!==t?(d=u(),d!==t?(b=C(),b!==t?($=n,a=_(o,b),n=a):(r=n,n=t)):(r=n,n=t)):(r=n,n=t);i!==t?($=e,o=Xe(o,i),e=o):(r=e,e=t)}else r=e,e=t;return e}function W(){var e,o,i,n;return s.substr(r,3)===oe?(e=oe,r+=3):(e=t,c===0&&l(Ye)),e===t&&(s.substr(r,4)===ie?(e=ie,r+=4):(e=t,c===0&&l(He)),e===t&&(s.substr(r,5)===se?(e=se,r+=5):(e=t,c===0&&l(Je)),e===t&&(s.substr(r,6)===ne?(e=ne,r+=6):(e=t,c===0&&l(Ke)),e===t&&(s.substr(r,4)===ae?(e=ae,r+=4):(e=t,c===0&&l(et)),e===t&&(s.substr(r,5)===ce?(e=ce,r+=5):(e=t,c===0&&l(tt)),e===t&&(s.substr(r,5)===fe?(e=fe,r+=5):(e=t,c===0&&l(rt)),e===t&&(s.substr(r,4)===le?(e=le,r+=4):(e=t,c===0&&l(ot)),e===t&&(s.substr(r,6)===ue?(e=ue,r+=6):(e=t,c===0&&l(it)),e===t&&(s.substr(r,7)===he?(e=he,r+=7):(e=t,c===0&&l(st)),e===t&&(s.substr(r,4)===me?(e=me,r+=4):(e=t,c===0&&l(nt)),e===t&&(s.substr(r,6)===ge?(e=ge,r+=6):(e=t,c===0&&l(at)),e===t&&(s.substr(r,6)===pe?(e=pe,r+=6):(e=t,c===0&&l(ct)),e===t&&(s.substr(r,3)===de?(e=de,r+=3):(e=t,c===0&&l(ft)),e===t&&(e=r,o=Fe(),o!==t?(i=u(),i!==t?(n=De(),n!==t?($=e,o=lt(o,n),e=o):(r=e,e=t)):(r=e,e=t)):(r=e,e=t))))))))))))))),e}function At(){var e;return e=wt(),e===t&&(e=C()),e}function C(){var e,o,i,n,a;if(e=r,o=r,ut.test(s.charAt(r))?(i=s.charAt(r),r++):(i=t,c===0&&l(ht)),i!==t){for(n=[],be.test(s.charAt(r))?(a=s.charAt(r),r++):(a=t,c===0&&l(Se));a!==t;)n.push(a),be.test(s.charAt(r))?(a=s.charAt(r),r++):(a=t,c===0&&l(Se));n!==t?(i=[i,n],o=i):(r=o,o=t)}else r=o,o=t;return o!==t&&($=e,o=mt()),e=o,e}function Te(){var e,o,i;for(e=r,o=[],$e.test(s.charAt(r))?(i=s.charAt(r),r++):(i=t,c===0&&l(ye));i!==t;)o.push(i),$e.test(s.charAt(r))?(i=s.charAt(r),r++):(i=t,c===0&&l(ye));return o!==t&&($=e,o=gt(o)),e=o,e}function wt(){var e,o,i,n;if(c++,e=r,o=u(),o!==t){if(i=[],Ee.test(s.charAt(r))?(n=s.charAt(r),r++):(n=t,c===0&&l(ke)),n!==t)for(;n!==t;)i.push(n),Ee.test(s.charAt(r))?(n=s.charAt(r),r++):(n=t,c===0&&l(ke));else i=t;i!==t?($=e,o=dt(),e=o):(r=e,e=t)}else r=e,e=t;return c--,e===t&&(o=t,c===0&&l(pt)),e}function u(){var e,o;for(c++,e=[],Ce.test(s.charAt(r))?(o=s.charAt(r),r++):(o=t,c===0&&l(Ae));o!==t;)e.push(o),Ce.test(s.charAt(r))?(o=s.charAt(r),r++):(o=t,c===0&&l(Ae));return c--,e===t&&(o=t,c===0&&l(bt)),e}if(j=F(),j!==t&&r===s.length)return j;throw j!==t&&r<s.length&&l(St()),$t(Z,w<s.length?s.charAt(w):null,w<s.length?qe(w,w+1):qe(w,w))}var ze={SyntaxError:I,parse:qt};const Nt=vt(ze),Ft=`table bigChain +"bigChain pairwise alignment" + ( + string chrom; "Reference sequence chromosome or scaffold" + uint chromStart; "Start position in chromosome" + uint chromEnd; "End position in chromosome" + string name; "Name or ID of item, ideally both human readable and unique" + uint score; "Score (0-1000)" + char[1] strand; "+ or - for strand" + uint tSize; "size of target sequence" + string qName; "name of query sequence" + uint qSize; "size of query sequence" + uint qStart; "start of alignment on query sequence" + uint qEnd; "end of alignment on query sequence" + uint chainScore; "score from chain" + )`,Dt=`table bigGenePred +"bigGenePred gene models" + ( + string chrom; "Reference sequence chromosome or scaffold" + uint chromStart; "Start position in chromosome" + uint chromEnd; "End position in chromosome" + string name; "Name or ID of item, ideally both human readable and unique" + uint score; "Score (0-1000)" + char[1] strand; "+ or - for strand" + uint thickStart; "Start of where display should be thick (start codon)" + uint thickEnd; "End of where display should be thick (stop codon)" + uint reserved; "RGB value (use R,G,B string in input file)" + int blockCount; "Number of blocks" + int[blockCount] blockSizes; "Comma separated list of block sizes" + int[blockCount] chromStarts; "Start positions relative to chromStart" + string name2; "Alternative/human readable name" + string cdsStartStat; "Status of CDS start annotation (none, unknown, incomplete, or complete)" + string cdsEndStat; "Status of CDS end annotation (none, unknown, incomplete, or complete)" + int[blockCount] exonFrames; "Exon frame {0,1,2}, or -1 if no frame for exon" + string type; "Transcript type" + string geneName; "Primary identifier for gene" + string geneName2; "Alternative/human readable gene name" + string geneType; "Gene type" + )`,Rt=`table interact +"interaction between two regions" + ( + string chrom; "Chromosome (or contig, scaffold, etc.). For interchromosomal, use 2 records" + uint chromStart; "Start position of lower region. For interchromosomal, set to chromStart of this region" + uint chromEnd; "End position of upper region. For interchromosomal, set to chromEnd of this region" + string name; "Name of item, for display. Usually 'sourceName/targetName/exp' or empty" + uint score; "Score (0-1000)" + double value; "Strength of interaction or other data value. Typically basis for score" + string exp; "Experiment name (metadata for filtering). Use . if not applicable" + string color; "Item color. Specified as r,g,b or hexadecimal #RRGGBB or html color name, as in //www.w3.org/TR/css3-color/#html4. Use 0 and spectrum setting to shade by score" + string sourceChrom; "Chromosome of source region (directional) or lower region. For non-directional interchromosomal, chrom of this region." + uint sourceStart; "Start position in chromosome of source/lower/this region" + uint sourceEnd; "End position in chromosome of source/lower/this region" + string sourceName; "Identifier of source/lower/this region" + string sourceStrand; "Orientation of source/lower/this region: + or -. Use . if not applicable" + string targetChrom; "Chromosome of target region (directional) or upper region. For non-directional interchromosomal, chrom of other region" + uint targetStart; "Start position in chromosome of target/upper/this region" + uint targetEnd; "End position in chromosome of target/upper/this region" + string targetName; "Identifier of target/upper/this region" + string targetStrand; "Orientation of target/upper/this region: + or -. Use . if not applicable" + + )`,Tt=`table bigLink +"bigLink pairwise alignment" + ( + string chrom; "Reference sequence chromosome or scaffold" + uint chromStart; "Start position in chromosome" + uint chromEnd; "End position in chromosome" + string name; "Name or ID of item, ideally both human readable and unique" + uint qStart; "start of alignment on query sequence" + )`,zt=`table bedMaf +"Bed3 with MAF block" + ( + string chrom; "Reference sequence chromosome or scaffold" + uint chromStart; "Start position in chromosome" + uint chromEnd; "End position in chromosome" + lstring mafBlock; "MAF block" + )`,Bt=`table bigNarrowPeak +"BED6+4 Peaks of signal enrichment based on pooled, normalized (interpreted) data." +( + string chrom; "Reference sequence chromosome or scaffold" + uint chromStart; "Start position in chromosome" + uint chromEnd; "End position in chromosome" + string name; "Name given to a region (preferably unique). Use . if no name is assigned" + uint score; "Indicates how dark the peak will be displayed in the browser (0-1000) " + char[1] strand; "+ or - or . for unknown" + float signalValue; "Measurement of average enrichment for the region" + float pValue; "Statistical significance of signal value (-log10). Set to -1 if not used." + float qValue; "Statistical significance with multiple-test correction applied (FDR -log10). Set to -1 if not used." + int peak; "Point-source called for this peak; 0-based offset from chromStart. Set to -1 if no point-source called." +)`,It=`table bigPsl +"bigPsl pairwise alignment" + ( + string chrom; "Reference sequence chromosome or scaffold" + uint chromStart; "Start position in chromosome" + uint chromEnd; "End position in chromosome" + string name; "Name or ID of item, ideally both human readable and unique" + uint score; "Score (0-1000)" + char[1] strand; "+ or - indicates whether the query aligns to the + or - strand on the reference" + uint thickStart; "Start of where display should be thick (start codon)" + uint thickEnd; "End of where display should be thick (stop codon)" + uint reserved; "RGB value (use R,G,B string in input file)" + int blockCount; "Number of blocks" + int[blockCount] blockSizes; "Comma separated list of block sizes" + int[blockCount] chromStarts; "Start positions relative to chromStart" + + uint oChromStart;"Start position in other chromosome" + uint oChromEnd; "End position in other chromosome" + char[1] oStrand; "+ or -, - means that psl was reversed into BED-compatible coordinates" + uint oChromSize; "Size of other chromosome." + int[blockCount] oChromStarts; "Start positions relative to oChromStart or from oChromStart+oChromSize depending on strand" + + lstring oSequence; "Sequence on other chrom (or empty)" + string oCDS; "CDS in NCBI format" + + uint chromSize;"Size of target chromosome" + + uint match; "Number of bases matched." + uint misMatch; " Number of bases that don't match " + uint repMatch; " Number of bases that match but are part of repeats " + uint nCount; " Number of 'N' bases " + uint seqType; "0=empty, 1=nucleotide, 2=amino_acid" + )`,Pt=`table defaultBedSchema +"BED12" + ( + string chrom; "The name of the chromosome (e.g. chr3, chrY, chr2_random) or scaffold (e.g. scaffold10671)." + uint chromStart; "The starting position of the feature in the chromosome or scaffold. The first base in a chromosome is numbered 0." + uint chromEnd; "The ending position of the feature in the chromosome or scaffold. The chromEnd base is not included in the display of the feature. For example, the first 100 bases of a chromosome are defined as chromStart=0, chromEnd=100, and span the bases numbered 0-99." + string name; "Defines the name of the BED line." + float score; "Feature score, doesn't care about the 0-1000 limit as in bed" + char strand; "Defines the strand. Either '.' (=no strand) or '+' or '-'" + uint thickStart; "The starting position at which the feature is drawn thickly (for example, the start codon in gene displays). When there is no thick part, thickStart and thickEnd are usually set to the chromStart position." + uint thickEnd; "The ending position at which the feature is drawn thickly (for example the stop codon in gene displays)." + string itemRgb; "An RGB value of the form R,G,B (e.g. 255,0,0). " + uint blockCount; " The number of blocks (exons) in the BED line." + uint[blockCount] blockSizes; " A comma-separated list of the block sizes. The number of items in this list should correspond to blockCount." + uint[blockCount] blockStarts; "A comma-separated list of block starts. All of the blockStart positions should be calculated relative to chromStart. The number of items in this list should correspond to blockCount." + )`,Gt=`table mafFrames +"codon frame assignment for MAF components" + ( + string chrom; "Reference sequence chromosome or scaffold" + uint chromStart; "Start range in chromosome" + uint chromEnd; "End range in chromosome" + string src; "Name of sequence source in MAF" + ubyte frame; "frame (0,1,2) for first base(+) or last bast(-)" + char[1] strand; "+ or -" + string name; "Name of gene used to define frame" + int prevFramePos; "target position of the previous base (in transcription direction) that continues this frame, or -1 if none, or frame not contiguous" + int nextFramePos; "target position of the next base (in transcription direction) that continues this frame, or -1 if none, or frame not contiguous" + ubyte isExonStart; "does this start the CDS portion of an exon?" + ubyte isExonEnd; "does this end the CDS portion of an exon?" + )`,_t=`table mafSummary +"Positions and scores for alignment blocks" + ( + string chrom; "Reference sequence chromosome or scaffold" + uint chromStart; "Start position in chromosome" + uint chromEnd; "End position in chromosome" + string src; "Sequence name or database of alignment" + float score; "Floating point score." + char[1] leftStatus; "Gap/break annotation for preceding block" + char[1] rightStatus; "Gap/break annotation for following block" + )`,Mt=Object.freeze(Object.defineProperty({__proto__:null,bigChain:Ft,bigGenePred:Dt,bigInteract:Rt,bigLink:Tt,bigMaf:zt,bigNarrowPeak:Bt,bigPsl:It,defaultBedSchema:Pt,mafFrames:Gt,mafSummary:_t},Symbol.toStringTag,{value:"Module"})),X=Object.fromEntries(Object.entries(Mt).map(([s,h])=>[s,ze.parse(h.trim())]));function Y(s){const h=["uint","int","float","long"];return{...s,fields:s.fields.map(t=>({...t,isArray:t.size&&t.type!=="char",arrayIsNumeric:t.size&&h.includes(t.type),isNumeric:!t.size&&h.includes(t.type)}))}}const jt={".":0,"-":-1,"+":1};function Lt(s){var h;return s.length>=12&&!Number.isNaN(parseInt(s[9],10))&&((h=s[10])===null||h===void 0?void 0:h.split(",").filter(t=>!!t).length)===parseInt(s[9],10)}class Ut{constructor(h={}){if(h.autoSql)this.autoSql=Y(Nt.parse(h.autoSql));else if(h.type){if(!X[h.type])throw new Error("Type not found");this.autoSql=Y(X[h.type])}else this.autoSql=Y(X.defaultBedSchema),this.attemptDefaultBed=!0}parseLine(h,t={}){const{autoSql:y}=this,{uniqueId:F}=t,A=Array.isArray(h)?h:h.split(" ");let p={};if(!this.attemptDefaultBed||this.attemptDefaultBed&&Lt(A))for(let k=0;k<y.fields.length;k++){const D=y.fields[k];let f=A[k];const{isNumeric:m,isArray:S,arrayIsNumeric:v,name:O}=D;if(f==null)break;if(f!=="."){if(m){const B=Number(f);f=Number.isNaN(B)?f:B}else S&&(f=f.split(","),f[f.length-1]===""&&f.pop(),v&&(f=f.map(B=>Number(B))));p[O]=f}}else{const k=["chrom","chromStart","chromEnd","name"];p=Object.fromEntries(A.map((D,f)=>[k[f]||"field"+f,D])),p.chromStart=+p.chromStart,p.chromEnd=+p.chromEnd,Number.isNaN(Number.parseFloat(p.field4))||(p.score=+p.field4,delete p.field4),(p.field5==="+"||p.field5==="-")&&(p.strand=p.field5,delete p.field5)}return F&&(p.uniqueId=F),p.strand=jt[p.strand]||0,p.chrom=decodeURIComponent(p.chrom),p}}export{Ut as default}; diff --git a/segmentmodel/assets/index-a6f09c33.js b/segmentmodel/assets/index-a6f09c33.js new file mode 100644 index 0000000..ef73635 --- /dev/null +++ b/segmentmodel/assets/index-a6f09c33.js @@ -0,0 +1,258 @@ +var Rp=Object.defineProperty;var Mp=(t,e,n)=>e in t?Rp(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var fe=(t,e,n)=>(Mp(t,typeof e!="symbol"?e+"":e,n),n),jo=(t,e,n)=>{if(!e.has(t))throw TypeError("Cannot "+n)};var S=(t,e,n)=>(jo(t,e,"read from private field"),n?n.call(t):e.get(t)),M=(t,e,n)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,n)},he=(t,e,n,r)=>(jo(t,e,"write to private field"),r?r.call(t,n):e.set(t,n),n);var Ou=(t,e,n,r)=>({set _(i){he(t,e,i,n)},get _(){return S(t,e,r)}}),I=(t,e,n)=>(jo(t,e,"access private method"),n);(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const s of i)if(s.type==="childList")for(const o of s.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(i){const s={};return i.integrity&&(s.integrity=i.integrity),i.referrerPolicy&&(s.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?s.credentials="include":i.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function r(i){if(i.ep)return;i.ep=!0;const s=n(i);fetch(i.href,s)}})();/** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + */const Pr=globalThis,Cs=Pr.trustedTypes,Pu=Cs?Cs.createPolicy("lit-html",{createHTML:t=>t}):void 0,Bf="$lit$",_t=`lit$${(Math.random()+"").slice(9)}$`,kf="?"+_t,Bp=`<${kf}>`,Cn=document,Hr=()=>Cn.createComment(""),qr=t=>t===null||typeof t!="object"&&typeof t!="function",Of=Array.isArray,kp=t=>Of(t)||typeof(t==null?void 0:t[Symbol.iterator])=="function",Yo=`[ +\f\r]`,Sr=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Lu=/-->/g,Nu=/>/g,Qt=RegExp(`>|${Yo}(?:([^\\s"'>=/]+)(${Yo}*=${Yo}*(?:[^ +\f\r"'\`<>=]|("|')|))|$)`,"g"),zu=/'/g,Uu=/"/g,Pf=/^(?:script|style|textarea|title)$/i,Op=t=>(e,...n)=>({_$litType$:t,strings:e,values:n}),te=Op(1),ir=Symbol.for("lit-noChange"),J=Symbol.for("lit-nothing"),$u=new WeakMap,on=Cn.createTreeWalker(Cn,129);function Lf(t,e){if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return Pu!==void 0?Pu.createHTML(e):e}const Pp=(t,e)=>{const n=t.length-1,r=[];let i,s=e===2?"<svg>":"",o=Sr;for(let a=0;a<n;a++){const c=t[a];let u,f,l=-1,h=0;for(;h<c.length&&(o.lastIndex=h,f=o.exec(c),f!==null);)h=o.lastIndex,o===Sr?f[1]==="!--"?o=Lu:f[1]!==void 0?o=Nu:f[2]!==void 0?(Pf.test(f[2])&&(i=RegExp("</"+f[2],"g")),o=Qt):f[3]!==void 0&&(o=Qt):o===Qt?f[0]===">"?(o=i??Sr,l=-1):f[1]===void 0?l=-2:(l=o.lastIndex-f[2].length,u=f[1],o=f[3]===void 0?Qt:f[3]==='"'?Uu:zu):o===Uu||o===zu?o=Qt:o===Lu||o===Nu?o=Sr:(o=Qt,i=void 0);const p=o===Qt&&t[a+1].startsWith("/>")?" ":"";s+=o===Sr?c+Bp:l>=0?(r.push(u),c.slice(0,l)+Bf+c.slice(l)+_t+p):c+_t+(l===-2?a:p)}return[Lf(t,s+(t[n]||"<?>")+(e===2?"</svg>":"")),r]};class Wr{constructor({strings:e,_$litType$:n},r){let i;this.parts=[];let s=0,o=0;const a=e.length-1,c=this.parts,[u,f]=Pp(e,n);if(this.el=Wr.createElement(u,r),on.currentNode=this.el.content,n===2){const l=this.el.content.firstChild;l.replaceWith(...l.childNodes)}for(;(i=on.nextNode())!==null&&c.length<a;){if(i.nodeType===1){if(i.hasAttributes())for(const l of i.getAttributeNames())if(l.endsWith(Bf)){const h=f[o++],p=i.getAttribute(l).split(_t),d=/([.?@])?(.*)/.exec(h);c.push({type:1,index:s,name:d[2],strings:p,ctor:d[1]==="."?Np:d[1]==="?"?zp:d[1]==="@"?Up:ro}),i.removeAttribute(l)}else l.startsWith(_t)&&(c.push({type:6,index:s}),i.removeAttribute(l));if(Pf.test(i.tagName)){const l=i.textContent.split(_t),h=l.length-1;if(h>0){i.textContent=Cs?Cs.emptyScript:"";for(let p=0;p<h;p++)i.append(l[p],Hr()),on.nextNode(),c.push({type:2,index:++s});i.append(l[h],Hr())}}}else if(i.nodeType===8)if(i.data===kf)c.push({type:2,index:s});else{let l=-1;for(;(l=i.data.indexOf(_t,l+1))!==-1;)c.push({type:7,index:s}),l+=_t.length-1}s++}}static createElement(e,n){const r=Cn.createElement("template");return r.innerHTML=e,r}}function sr(t,e,n=t,r){var o,a;if(e===ir)return e;let i=r!==void 0?(o=n._$Co)==null?void 0:o[r]:n._$Cl;const s=qr(e)?void 0:e._$litDirective$;return(i==null?void 0:i.constructor)!==s&&((a=i==null?void 0:i._$AO)==null||a.call(i,!1),s===void 0?i=void 0:(i=new s(t),i._$AT(t,n,r)),r!==void 0?(n._$Co??(n._$Co=[]))[r]=i:n._$Cl=i),i!==void 0&&(e=sr(t,i._$AS(t,e.values),i,r)),e}class Lp{constructor(e,n){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=n}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){const{el:{content:n},parts:r}=this._$AD,i=((e==null?void 0:e.creationScope)??Cn).importNode(n,!0);on.currentNode=i;let s=on.nextNode(),o=0,a=0,c=r[0];for(;c!==void 0;){if(o===c.index){let u;c.type===2?u=new Ii(s,s.nextSibling,this,e):c.type===1?u=new c.ctor(s,c.name,c.strings,this,e):c.type===6&&(u=new $p(s,this,e)),this._$AV.push(u),c=r[++a]}o!==(c==null?void 0:c.index)&&(s=on.nextNode(),o++)}return on.currentNode=Cn,i}p(e){let n=0;for(const r of this._$AV)r!==void 0&&(r.strings!==void 0?(r._$AI(e,r,n),n+=r.strings.length-2):r._$AI(e[n])),n++}}class Ii{get _$AU(){var e;return((e=this._$AM)==null?void 0:e._$AU)??this._$Cv}constructor(e,n,r,i){this.type=2,this._$AH=J,this._$AN=void 0,this._$AA=e,this._$AB=n,this._$AM=r,this.options=i,this._$Cv=(i==null?void 0:i.isConnected)??!0}get parentNode(){let e=this._$AA.parentNode;const n=this._$AM;return n!==void 0&&(e==null?void 0:e.nodeType)===11&&(e=n.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,n=this){e=sr(this,e,n),qr(e)?e===J||e==null||e===""?(this._$AH!==J&&this._$AR(),this._$AH=J):e!==this._$AH&&e!==ir&&this._(e):e._$litType$!==void 0?this.g(e):e.nodeType!==void 0?this.$(e):kp(e)?this.T(e):this._(e)}k(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}$(e){this._$AH!==e&&(this._$AR(),this._$AH=this.k(e))}_(e){this._$AH!==J&&qr(this._$AH)?this._$AA.nextSibling.data=e:this.$(Cn.createTextNode(e)),this._$AH=e}g(e){var s;const{values:n,_$litType$:r}=e,i=typeof r=="number"?this._$AC(e):(r.el===void 0&&(r.el=Wr.createElement(Lf(r.h,r.h[0]),this.options)),r);if(((s=this._$AH)==null?void 0:s._$AD)===i)this._$AH.p(n);else{const o=new Lp(i,this),a=o.u(this.options);o.p(n),this.$(a),this._$AH=o}}_$AC(e){let n=$u.get(e.strings);return n===void 0&&$u.set(e.strings,n=new Wr(e)),n}T(e){Of(this._$AH)||(this._$AH=[],this._$AR());const n=this._$AH;let r,i=0;for(const s of e)i===n.length?n.push(r=new Ii(this.k(Hr()),this.k(Hr()),this,this.options)):r=n[i],r._$AI(s),i++;i<n.length&&(this._$AR(r&&r._$AB.nextSibling,i),n.length=i)}_$AR(e=this._$AA.nextSibling,n){var r;for((r=this._$AP)==null?void 0:r.call(this,!1,!0,n);e&&e!==this._$AB;){const i=e.nextSibling;e.remove(),e=i}}setConnected(e){var n;this._$AM===void 0&&(this._$Cv=e,(n=this._$AP)==null||n.call(this,e))}}class ro{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,n,r,i,s){this.type=1,this._$AH=J,this._$AN=void 0,this.element=e,this.name=n,this._$AM=i,this.options=s,r.length>2||r[0]!==""||r[1]!==""?(this._$AH=Array(r.length-1).fill(new String),this.strings=r):this._$AH=J}_$AI(e,n=this,r,i){const s=this.strings;let o=!1;if(s===void 0)e=sr(this,e,n,0),o=!qr(e)||e!==this._$AH&&e!==ir,o&&(this._$AH=e);else{const a=e;let c,u;for(e=s[0],c=0;c<s.length-1;c++)u=sr(this,a[r+c],n,c),u===ir&&(u=this._$AH[c]),o||(o=!qr(u)||u!==this._$AH[c]),u===J?e=J:e!==J&&(e+=(u??"")+s[c+1]),this._$AH[c]=u}o&&!i&&this.O(e)}O(e){e===J?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}}class Np extends ro{constructor(){super(...arguments),this.type=3}O(e){this.element[this.name]=e===J?void 0:e}}class zp extends ro{constructor(){super(...arguments),this.type=4}O(e){this.element.toggleAttribute(this.name,!!e&&e!==J)}}class Up extends ro{constructor(e,n,r,i,s){super(e,n,r,i,s),this.type=5}_$AI(e,n=this){if((e=sr(this,e,n,0)??J)===ir)return;const r=this._$AH,i=e===J&&r!==J||e.capture!==r.capture||e.once!==r.once||e.passive!==r.passive,s=e!==J&&(r===J||i);i&&this.element.removeEventListener(this.name,this,r),s&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){var n;typeof this._$AH=="function"?this._$AH.call(((n=this.options)==null?void 0:n.host)??this.element,e):this._$AH.handleEvent(e)}}class $p{constructor(e,n,r){this.element=e,this.type=6,this._$AN=void 0,this._$AM=n,this.options=r}get _$AU(){return this._$AM._$AU}_$AI(e){sr(this,e)}}const Xo=Pr.litHtmlPolyfillSupport;Xo==null||Xo(Wr,Ii),(Pr.litHtmlVersions??(Pr.litHtmlVersions=[])).push("3.1.0");const Ss=(t,e,n)=>{const r=(n==null?void 0:n.renderBefore)??e;let i=r._$litPart$;if(i===void 0){const s=(n==null?void 0:n.renderBefore)??null;r._$litPart$=i=new Ii(e.insertBefore(Hr(),s),s,void 0,n??{})}return i._$AI(t),i};/** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + */const Vp={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},Gp=t=>(...e)=>({_$litDirective$:t,values:e});class Hp{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,n,r){this._$Ct=e,this._$AM=n,this._$Ci=r}_$AS(e,n){return this.update(e,n)}update(e,n){return this.render(...n)}}/** + * @license + * Copyright 2018 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + */const Vu=Gp(class extends Hp{constructor(t){var e;if(super(t),t.type!==Vp.ATTRIBUTE||t.name!=="class"||((e=t.strings)==null?void 0:e.length)>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(t){return" "+Object.keys(t).filter(e=>t[e]).join(" ")+" "}update(t,[e]){var r,i;if(this.it===void 0){this.it=new Set,t.strings!==void 0&&(this.st=new Set(t.strings.join(" ").split(/\s/).filter(s=>s!=="")));for(const s in e)e[s]&&!((r=this.st)!=null&&r.has(s))&&this.it.add(s);return this.render(e)}const n=t.element.classList;for(const s of this.it)s in e||(n.remove(s),this.it.delete(s));for(const s in e){const o=!!e[s];o===this.it.has(s)||(i=this.st)!=null&&i.has(s)||(o?(n.add(s),this.it.add(s)):(n.remove(s),this.it.delete(s)))}return ir}});var Gu={},is={},Ko=34,en=10,ss=13;function Nf(t){return new Function("d","return {"+t.map(function(e,n){return JSON.stringify(e)+": d["+n+'] || ""'}).join(",")+"}")}function qp(t,e){var n=Nf(t);return function(r,i){return e(n(r),i,t)}}function Hu(t){var e=Object.create(null),n=[];return t.forEach(function(r){for(var i in r)i in e||n.push(e[i]=i)}),n}function Ee(t,e){var n=t+"",r=n.length;return r<e?new Array(e-r+1).join(0)+n:n}function Wp(t){return t<0?"-"+Ee(-t,6):t>9999?"+"+Ee(t,6):Ee(t,4)}function jp(t){var e=t.getUTCHours(),n=t.getUTCMinutes(),r=t.getUTCSeconds(),i=t.getUTCMilliseconds();return isNaN(t)?"Invalid Date":Wp(t.getUTCFullYear())+"-"+Ee(t.getUTCMonth()+1,2)+"-"+Ee(t.getUTCDate(),2)+(i?"T"+Ee(e,2)+":"+Ee(n,2)+":"+Ee(r,2)+"."+Ee(i,3)+"Z":r?"T"+Ee(e,2)+":"+Ee(n,2)+":"+Ee(r,2)+"Z":n||e?"T"+Ee(e,2)+":"+Ee(n,2)+"Z":"")}function zf(t,e){var n=new RegExp('["'+t+` +\r]`),r=t.charCodeAt(0);function i(h,p){var d,m,g=s(h,function(x,b){if(d)return d(x,b-1);m=x,d=p?qp(x,p):Nf(x)});return g.columns=m||[],g}function s(h,p){var d=[],m=h.length,g=0,x=0,b,A=m<=0,E=!1,F=!0,C=e?e.comment:void 0;h.charCodeAt(m-1)===en&&--m,h.charCodeAt(m-1)===ss&&--m;function w(){if(A)return is;if(E)return E=!1,F=!0,Gu;if(F&&C){for(;;){let ee=0;for(;ee<C.length&&C.charAt(ee)===h.charAt(ee+g);)ee++;if(ee!==C.length)break;for(g+=ee;g<m&&(_=h.charCodeAt(g++),_!==en);)if(_===ss){h.charCodeAt(g)===en&&++g;break}}if(g>=m)return is}F=!1;var Y,j=g,_;if(h.charCodeAt(j)===Ko){for(;g++<m&&h.charCodeAt(g)!==Ko||h.charCodeAt(++g)===Ko;);return(Y=g)>=m?A=!0:(_=h.charCodeAt(g++))===en?E=!0:_===ss&&(E=!0,h.charCodeAt(g)===en&&++g),h.slice(j+1,Y-1).replace(/""/g,'"')}for(;g<m;){if((_=h.charCodeAt(Y=g++))===en)E=!0;else if(_===ss)E=!0,h.charCodeAt(g)===en&&++g;else if(_!==r)continue;return h.slice(j,Y)}return A=!0,h.slice(j,m)}for(;(b=w())!==is;){for(var L=[];b!==Gu&&b!==is;)L.push(b),b=w();p&&(L=p(L,x++))==null||d.push(L)}return d}function o(h,p){return h.map(function(d){return p.map(function(m){return l(d[m])}).join(t)})}function a(h,p){return p==null&&(p=Hu(h)),[p.map(l).join(t)].concat(o(h,p)).join(` +`)}function c(h,p){return p==null&&(p=Hu(h)),o(h,p).join(` +`)}function u(h){return h.map(f).join(` +`)}function f(h){return h.map(l).join(t)}function l(h){return h==null?"":h instanceof Date?jp(h):n.test(h+="")?'"'+h.replace(/"/g,'""')+'"':h}return{parse:i,parseRows:s,format:a,formatBody:c,formatRows:u,formatRow:f,formatValue:l}}var Yp=zf(" "),Xp=Yp.parseRows;function Ut(t,e,n){return t.fields=e||[],t.fname=n,t}function Kp(t){return t==null?null:t.fname}function Uf(t){return t==null?null:t.fields}function Jp(t){return t.length===1?Zp(t[0]):Qp(t)}const Zp=t=>function(e){return e[t]},Qp=t=>{const e=t.length;return function(n){for(let r=0;r<e;++r)n=n[t[r]];return n}};function W(t){throw Error(t)}function em(t){const e=[],n=t.length;let r=null,i=0,s="",o,a,c;t=t+"";function u(){e.push(s+t.substring(o,a)),s="",o=a+1}for(o=a=0;a<n;++a)if(c=t[a],c==="\\")s+=t.substring(o,a++),o=a;else if(c===r)u(),r=null,i=-1;else{if(r)continue;o===i&&c==='"'||o===i&&c==="'"?(o=a+1,r=c):c==="."&&!i?a>o?u():o=a+1:c==="["?(a>o&&u(),i=o=a+1):c==="]"&&(i||W("Access path missing open bracket: "+t),i>0&&u(),i=0,o=a+1)}return i&&W("Access path missing closing bracket: "+t),r&&W("Access path missing closing quote: "+t),a>o&&(a++,u()),e}function io(t,e,n){const r=em(t);return t=r.length===1?r[0]:t,Ut((n&&n.get||Jp)(r),[t],e||t)}io("id");const so=Ut(t=>t,[],"identity");Ut(()=>0,[],"zero");Ut(()=>1,[],"one");Ut(()=>!0,[],"true");Ut(()=>!1,[],"false");var Me=Array.isArray;function Re(t){return t===Object(t)}function Ye(t){return t[t.length-1]}function jr(t){return t==null||t===""?null:+t}const $f=t=>e=>t*Math.exp(e),Vf=t=>e=>Math.log(t*e),tm=t=>e=>Math.sign(e)*Math.log1p(Math.abs(e/t)),nm=t=>e=>Math.sign(e)*Math.expm1(Math.abs(e))*t,Fs=t=>e=>e<0?-Math.pow(-e,t):Math.pow(e,t);function Tc(t,e,n,r){const i=n(t[0]),s=n(Ye(t)),o=(s-i)*e;return[r(i-o),r(s-o)]}function rm(t,e){return Tc(t,e,jr,so)}function im(t,e){var n=Math.sign(t[0]);return Tc(t,e,Vf(n),$f(n))}function sm(t,e,n){return Tc(t,e,Fs(n),Fs(1/n))}function oo(t,e,n,r,i){const s=r(t[0]),o=r(Ye(t)),a=e!=null?r(e):(s+o)/2;return[i(a+(s-a)*n),i(a+(o-a)*n)]}function Gf(t,e,n){return oo(t,e,n,jr,so)}function Hf(t,e,n){const r=Math.sign(t[0]);return oo(t,e,n,Vf(r),$f(r))}function Da(t,e,n,r){return oo(t,e,n,Fs(r),Fs(1/r))}function om(t,e,n,r){return oo(t,e,n,tm(r),nm(r))}function Ia(t){return t!=null?Me(t)?t:[t]:[]}function am(t,e,n){let r=t[0],i=t[1],s;return i<r&&(s=i,i=r,r=s),s=i-r,s>=n-e?[e,n]:[r=Math.min(Math.max(r,e),n-s),r+s]}function Ie(t){return typeof t=="function"}const cm="descending";function qf(t,e,n){n=n||{},e=Ia(e)||[];const r=[],i=[],s={},o=n.comparator||um;return Ia(t).forEach((a,c)=>{a!=null&&(r.push(e[c]===cm?-1:1),i.push(a=Ie(a)?a:io(a,null,n)),(Uf(a)||[]).forEach(u=>s[u]=1))}),i.length===0?null:Ut(o(i,r),Object.keys(s))}const Wf=(t,e)=>(t<e||t==null)&&e!=null?-1:(t>e||e==null)&&t!=null?1:(e=e instanceof Date?+e:e,(t=t instanceof Date?+t:t)!==t&&e===e?-1:e!==e&&t===t?1:0),um=(t,e)=>t.length===1?lm(t[0],e[0]):fm(t,e,t.length),lm=(t,e)=>function(n,r){return Wf(t(n),t(r))*e},fm=(t,e,n)=>(e.push(0),function(r,i){let s,o=0,a=-1;for(;o===0&&++a<n;)s=t[a],o=Wf(s(r),s(i));return o*e[a]});function hm(t){return Ie(t)?t:()=>t}function Dc(t){for(let e,n,r=1,i=arguments.length;r<i;++r){e=arguments[r];for(n in e)t[n]=e[n]}return t}const dm=Object.prototype.hasOwnProperty;function qn(t,e){return dm.call(t,e)}function _i(t){return typeof t=="boolean"}function pm(t){return Object.prototype.toString.call(t)==="[object Date]"}function mm(t){return t&&Ie(t[Symbol.iterator])}function be(t){return typeof t=="number"}function gm(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function V(t){return typeof t=="string"}function jf(t,e){const n=t[0],r=Ye(t),i=+e;return i?i===1?r:n+i*(r-n):n}function Ts(t){return t&&Ye(t)-t[0]||0}function ao(t){return Me(t)?"["+t.map(ao)+"]":Re(t)||V(t)?JSON.stringify(t).replace("\u2028","\\u2028").replace("\u2029","\\u2029"):t}function xm(t){return t==null||t===""?null:!t||t==="false"||t==="0"?!1:!!t}const ym=t=>be(t)||pm(t)?t:Date.parse(t);function bm(t,e){return e=e||ym,t==null||t===""?null:e(t)}function Am(t){return t==null||t===""?null:t+""}function Ds(t){const e={},n=t.length;for(let r=0;r<n;++r)e[t[r]]=!0;return e}var qu={},Jo={},Zo=34,Fr=10,Qo=13;function Yf(t){return new Function("d","return {"+t.map(function(e,n){return JSON.stringify(e)+": d["+n+'] || ""'}).join(",")+"}")}function wm(t,e){var n=Yf(t);return function(r,i){return e(n(r),i,t)}}function Wu(t){var e=Object.create(null),n=[];return t.forEach(function(r){for(var i in r)i in e||n.push(e[i]=i)}),n}function Ce(t,e){var n=t+"",r=n.length;return r<e?new Array(e-r+1).join(0)+n:n}function vm(t){return t<0?"-"+Ce(-t,6):t>9999?"+"+Ce(t,6):Ce(t,4)}function Em(t){var e=t.getUTCHours(),n=t.getUTCMinutes(),r=t.getUTCSeconds(),i=t.getUTCMilliseconds();return isNaN(t)?"Invalid Date":vm(t.getUTCFullYear())+"-"+Ce(t.getUTCMonth()+1,2)+"-"+Ce(t.getUTCDate(),2)+(i?"T"+Ce(e,2)+":"+Ce(n,2)+":"+Ce(r,2)+"."+Ce(i,3)+"Z":r?"T"+Ce(e,2)+":"+Ce(n,2)+":"+Ce(r,2)+"Z":n||e?"T"+Ce(e,2)+":"+Ce(n,2)+"Z":"")}function Cm(t){var e=new RegExp('["'+t+` +\r]`),n=t.charCodeAt(0);function r(l,h){var p,d,m=i(l,function(g,x){if(p)return p(g,x-1);d=g,p=h?wm(g,h):Yf(g)});return m.columns=d||[],m}function i(l,h){var p=[],d=l.length,m=0,g=0,x,b=d<=0,A=!1;l.charCodeAt(d-1)===Fr&&--d,l.charCodeAt(d-1)===Qo&&--d;function E(){if(b)return Jo;if(A)return A=!1,qu;var C,w=m,L;if(l.charCodeAt(w)===Zo){for(;m++<d&&l.charCodeAt(m)!==Zo||l.charCodeAt(++m)===Zo;);return(C=m)>=d?b=!0:(L=l.charCodeAt(m++))===Fr?A=!0:L===Qo&&(A=!0,l.charCodeAt(m)===Fr&&++m),l.slice(w+1,C-1).replace(/""/g,'"')}for(;m<d;){if((L=l.charCodeAt(C=m++))===Fr)A=!0;else if(L===Qo)A=!0,l.charCodeAt(m)===Fr&&++m;else if(L!==n)continue;return l.slice(w,C)}return b=!0,l.slice(w,d)}for(;(x=E())!==Jo;){for(var F=[];x!==qu&&x!==Jo;)F.push(x),x=E();h&&(F=h(F,g++))==null||p.push(F)}return p}function s(l,h){return l.map(function(p){return h.map(function(d){return f(p[d])}).join(t)})}function o(l,h){return h==null&&(h=Wu(l)),[h.map(f).join(t)].concat(s(l,h)).join(` +`)}function a(l,h){return h==null&&(h=Wu(l)),s(l,h).join(` +`)}function c(l){return l.map(u).join(` +`)}function u(l){return l.map(f).join(t)}function f(l){return l==null?"":l instanceof Date?Em(l):e.test(l+="")?'"'+l.replace(/"/g,'""')+'"':l}return{parse:r,parseRows:i,format:o,formatBody:a,formatRows:c,formatRow:u,formatValue:f}}function Sm(t){return t}function Fm(t){if(t==null)return Sm;var e,n,r=t.scale[0],i=t.scale[1],s=t.translate[0],o=t.translate[1];return function(a,c){c||(e=n=0);var u=2,f=a.length,l=new Array(f);for(l[0]=(e+=a[0])*r+s,l[1]=(n+=a[1])*i+o;u<f;)l[u]=a[u],++u;return l}}function Tm(t,e){for(var n,r=t.length,i=r-e;i<--r;)n=t[i],t[i++]=t[r],t[r]=n}function Dm(t,e){return typeof e=="string"&&(e=t.objects[e]),e.type==="GeometryCollection"?{type:"FeatureCollection",features:e.geometries.map(function(n){return ju(t,n)})}:ju(t,e)}function ju(t,e){var n=e.id,r=e.bbox,i=e.properties==null?{}:e.properties,s=Xf(t,e);return n==null&&r==null?{type:"Feature",properties:i,geometry:s}:r==null?{type:"Feature",id:n,properties:i,geometry:s}:{type:"Feature",id:n,bbox:r,properties:i,geometry:s}}function Xf(t,e){var n=Fm(t.transform),r=t.arcs;function i(f,l){l.length&&l.pop();for(var h=r[f<0?~f:f],p=0,d=h.length;p<d;++p)l.push(n(h[p],p));f<0&&Tm(l,d)}function s(f){return n(f)}function o(f){for(var l=[],h=0,p=f.length;h<p;++h)i(f[h],l);return l.length<2&&l.push(l[0]),l}function a(f){for(var l=o(f);l.length<4;)l.push(l[0]);return l}function c(f){return f.map(a)}function u(f){var l=f.type,h;switch(l){case"GeometryCollection":return{type:l,geometries:f.geometries.map(u)};case"Point":h=s(f.coordinates);break;case"MultiPoint":h=f.coordinates.map(s);break;case"LineString":h=o(f.arcs);break;case"MultiLineString":h=f.arcs.map(o);break;case"Polygon":h=c(f.arcs);break;case"MultiPolygon":h=f.arcs.map(c);break;default:return null}return{type:l,coordinates:h}}return u(e)}function Im(t,e){var n={},r={},i={},s=[],o=-1;e.forEach(function(u,f){var l=t.arcs[u<0?~u:u],h;l.length<3&&!l[1][0]&&!l[1][1]&&(h=e[++o],e[o]=u,e[f]=h)}),e.forEach(function(u){var f=a(u),l=f[0],h=f[1],p,d;if(p=i[l])if(delete i[p.end],p.push(u),p.end=h,d=r[h]){delete r[d.start];var m=d===p?p:p.concat(d);r[m.start=p.start]=i[m.end=d.end]=m}else r[p.start]=i[p.end]=p;else if(p=r[h])if(delete r[p.start],p.unshift(u),p.start=l,d=i[l]){delete i[d.end];var g=d===p?p:d.concat(p);r[g.start=d.start]=i[g.end=p.end]=g}else r[p.start]=i[p.end]=p;else p=[u],r[p.start=l]=i[p.end=h]=p});function a(u){var f=t.arcs[u<0?~u:u],l=f[0],h;return t.transform?(h=[0,0],f.forEach(function(p){h[0]+=p[0],h[1]+=p[1]})):h=f[f.length-1],u<0?[h,l]:[l,h]}function c(u,f){for(var l in u){var h=u[l];delete f[h.start],delete h.start,delete h.end,h.forEach(function(p){n[p<0?~p:p]=1}),s.push(h)}}return c(i,r),c(r,i),e.forEach(function(u){n[u<0?~u:u]||s.push([u])}),s}function _m(t){return Xf(t,Rm.apply(this,arguments))}function Rm(t,e,n){var r,i,s;if(arguments.length>1)r=Mm(t,e,n);else for(i=0,r=new Array(s=t.arcs.length);i<s;++i)r[i]=i;return{type:"MultiLineString",arcs:Im(t,r)}}function Mm(t,e,n){var r=[],i=[],s;function o(l){var h=l<0?~l:l;(i[h]||(i[h]=[])).push({i:l,g:s})}function a(l){l.forEach(o)}function c(l){l.forEach(a)}function u(l){l.forEach(c)}function f(l){switch(s=l,l.type){case"GeometryCollection":l.geometries.forEach(f);break;case"LineString":a(l.arcs);break;case"MultiLineString":case"Polygon":c(l.arcs);break;case"MultiPolygon":u(l.arcs);break}}return f(e),i.forEach(n==null?function(l){r.push(l[0].i)}:function(l){n(l[0].g,l[l.length-1].g)&&r.push(l[0].i)}),r}function Lr(t,e){return t==null||e==null?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function Bm(t,e){return t==null||e==null?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function co(t){let e,n,r;t.length!==2?(e=Lr,n=(a,c)=>Lr(t(a),c),r=(a,c)=>t(a)-c):(e=t===Lr||t===Bm?t:km,n=t,r=t);function i(a,c,u=0,f=a.length){if(u<f){if(e(c,c)!==0)return f;do{const l=u+f>>>1;n(a[l],c)<0?u=l+1:f=l}while(u<f)}return u}function s(a,c,u=0,f=a.length){if(u<f){if(e(c,c)!==0)return f;do{const l=u+f>>>1;n(a[l],c)<=0?u=l+1:f=l}while(u<f)}return u}function o(a,c,u=0,f=a.length){const l=i(a,c,u,f-1);return l>u&&r(a[l-1],c)>-r(a[l],c)?l-1:l}return{left:i,center:o,right:s}}function km(){return 0}function Kf(t){return t===null?NaN:+t}const Jf=co(Lr),_a=Jf.right;Jf.left;co(Kf).center;const gr=_a;function Om(t,e){let n,r;if(e===void 0)for(const i of t)i!=null&&(n===void 0?i>=i&&(n=r=i):(n>i&&(n=i),r<i&&(r=i)));else{let i=-1;for(let s of t)(s=e(s,++i,t))!=null&&(n===void 0?s>=s&&(n=r=s):(n>s&&(n=s),r<s&&(r=s)))}return[n,r]}class Sn extends Map{constructor(e,n=Nm){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:n}}),e!=null)for(const[r,i]of e)this.set(r,i)}get(e){return super.get(Yu(this,e))}has(e){return super.has(Yu(this,e))}set(e,n){return super.set(Pm(this,e),n)}delete(e){return super.delete(Lm(this,e))}}function Yu({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):n}function Pm({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):(t.set(r,n),n)}function Lm({_intern:t,_key:e},n){const r=e(n);return t.has(r)&&(n=t.get(r),t.delete(r)),n}function Nm(t){return t!==null&&typeof t=="object"?t.valueOf():t}function Ra(t){return t}function uo(t,...e){return Zf(t,Ra,Ra,e)}function zm(t,...e){return Zf(t,Array.from,Ra,e)}function Zf(t,e,n,r){return function i(s,o){if(o>=r.length)return n(s);const a=new Sn,c=r[o++];let u=-1;for(const f of s){const l=c(f,++u,s),h=a.get(l);h?h.push(f):a.set(l,[f])}for(const[f,l]of a)a.set(f,i(l,o));return e(a)}(t,0)}const Um=Math.sqrt(50),$m=Math.sqrt(10),Vm=Math.sqrt(2);function Is(t,e,n){const r=(e-t)/Math.max(0,n),i=Math.floor(Math.log10(r)),s=r/Math.pow(10,i),o=s>=Um?10:s>=$m?5:s>=Vm?2:1;let a,c,u;return i<0?(u=Math.pow(10,-i)/o,a=Math.round(t*u),c=Math.round(e*u),a/u<t&&++a,c/u>e&&--c,u=-u):(u=Math.pow(10,i)*o,a=Math.round(t/u),c=Math.round(e/u),a*u<t&&++a,c*u>e&&--c),c<a&&.5<=n&&n<2?Is(t,e,n*2):[a,c,u]}function _s(t,e,n){if(e=+e,t=+t,n=+n,!(n>0))return[];if(t===e)return[t];const r=e<t,[i,s,o]=r?Is(e,t,n):Is(t,e,n);if(!(s>=i))return[];const a=s-i+1,c=new Array(a);if(r)if(o<0)for(let u=0;u<a;++u)c[u]=(s-u)/-o;else for(let u=0;u<a;++u)c[u]=(s-u)*o;else if(o<0)for(let u=0;u<a;++u)c[u]=(i+u)/-o;else for(let u=0;u<a;++u)c[u]=(i+u)*o;return c}function Ma(t,e,n){return e=+e,t=+t,n=+n,Is(t,e,n)[2]}function Fn(t,e,n){e=+e,t=+t,n=+n;const r=e<t,i=r?Ma(e,t,n):Ma(t,e,n);return(r?-1:1)*(i<0?1/-i:i)}function Qf(t,e,n=Kf){if(!(!(r=t.length)||isNaN(e=+e))){if(e<=0||r<2)return+n(t[0],0,t);if(e>=1)return+n(t[r-1],r-1,t);var r,i=(r-1)*e,s=Math.floor(i),o=+n(t[s],s,t),a=+n(t[s+1],s+1,t);return o+(a-o)*(i-s)}}function Yr(t,e,n){t=+t,e=+e,n=(i=arguments.length)<2?(e=t,t=0,1):i<3?1:+n;for(var r=-1,i=Math.max(0,Math.ceil((e-t)/n))|0,s=new Array(i);++r<i;)s[r]=t+r*n;return s}function os(t,e){let n=0;if(e===void 0)for(let r of t)(r=+r)&&(n+=r);else{let r=-1;for(let i of t)(i=+e(i,++r,t))&&(n+=i)}return n}function Gm(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)}function Rs(t,e){if((n=(t=e?t.toExponential(e-1):t.toExponential()).indexOf("e"))<0)return null;var n,r=t.slice(0,n);return[r.length>1?r[0]+r.slice(2):r,+t.slice(n+1)]}function or(t){return t=Rs(Math.abs(t)),t?t[1]:NaN}function Hm(t,e){return function(n,r){for(var i=n.length,s=[],o=0,a=t[0],c=0;i>0&&a>0&&(c+a+1>r&&(a=Math.max(1,r-c)),s.push(n.substring(i-=a,i+a)),!((c+=a+1)>r));)a=t[o=(o+1)%t.length];return s.reverse().join(e)}}function qm(t){return function(e){return e.replace(/[0-9]/g,function(n){return t[+n]})}}var Wm=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function Mt(t){if(!(e=Wm.exec(t)))throw new Error("invalid format: "+t);var e;return new Ic({fill:e[1],align:e[2],sign:e[3],symbol:e[4],zero:e[5],width:e[6],comma:e[7],precision:e[8]&&e[8].slice(1),trim:e[9],type:e[10]})}Mt.prototype=Ic.prototype;function Ic(t){this.fill=t.fill===void 0?" ":t.fill+"",this.align=t.align===void 0?">":t.align+"",this.sign=t.sign===void 0?"-":t.sign+"",this.symbol=t.symbol===void 0?"":t.symbol+"",this.zero=!!t.zero,this.width=t.width===void 0?void 0:+t.width,this.comma=!!t.comma,this.precision=t.precision===void 0?void 0:+t.precision,this.trim=!!t.trim,this.type=t.type===void 0?"":t.type+""}Ic.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===void 0?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===void 0?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type};function jm(t){e:for(var e=t.length,n=1,r=-1,i;n<e;++n)switch(t[n]){case".":r=i=n;break;case"0":r===0&&(r=n),i=n;break;default:if(!+t[n])break e;r>0&&(r=0);break}return r>0?t.slice(0,r)+t.slice(i+1):t}var eh;function Ym(t,e){var n=Rs(t,e);if(!n)return t+"";var r=n[0],i=n[1],s=i-(eh=Math.max(-8,Math.min(8,Math.floor(i/3)))*3)+1,o=r.length;return s===o?r:s>o?r+new Array(s-o+1).join("0"):s>0?r.slice(0,s)+"."+r.slice(s):"0."+new Array(1-s).join("0")+Rs(t,Math.max(0,e+s-1))[0]}function Xu(t,e){var n=Rs(t,e);if(!n)return t+"";var r=n[0],i=n[1];return i<0?"0."+new Array(-i).join("0")+r:r.length>i+1?r.slice(0,i+1)+"."+r.slice(i+1):r+new Array(i-r.length+2).join("0")}const Ku={"%":(t,e)=>(t*100).toFixed(e),b:t=>Math.round(t).toString(2),c:t=>t+"",d:Gm,e:(t,e)=>t.toExponential(e),f:(t,e)=>t.toFixed(e),g:(t,e)=>t.toPrecision(e),o:t=>Math.round(t).toString(8),p:(t,e)=>Xu(t*100,e),r:Xu,s:Ym,X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function Ju(t){return t}var Zu=Array.prototype.map,Qu=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function Xm(t){var e=t.grouping===void 0||t.thousands===void 0?Ju:Hm(Zu.call(t.grouping,Number),t.thousands+""),n=t.currency===void 0?"":t.currency[0]+"",r=t.currency===void 0?"":t.currency[1]+"",i=t.decimal===void 0?".":t.decimal+"",s=t.numerals===void 0?Ju:qm(Zu.call(t.numerals,String)),o=t.percent===void 0?"%":t.percent+"",a=t.minus===void 0?"−":t.minus+"",c=t.nan===void 0?"NaN":t.nan+"";function u(l){l=Mt(l);var h=l.fill,p=l.align,d=l.sign,m=l.symbol,g=l.zero,x=l.width,b=l.comma,A=l.precision,E=l.trim,F=l.type;F==="n"?(b=!0,F="g"):Ku[F]||(A===void 0&&(A=12),E=!0,F="g"),(g||h==="0"&&p==="=")&&(g=!0,h="0",p="=");var C=m==="$"?n:m==="#"&&/[boxX]/.test(F)?"0"+F.toLowerCase():"",w=m==="$"?r:/[%p]/.test(F)?o:"",L=Ku[F],Y=/[defgprs%]/.test(F);A=A===void 0?6:/[gprs]/.test(F)?Math.max(1,Math.min(21,A)):Math.max(0,Math.min(20,A));function j(_){var ee=C,le=w,Ve,Kt,lt;if(F==="c")le=L(_)+le,_="";else{_=+_;var ft=_<0||1/_<0;if(_=isNaN(_)?c:L(Math.abs(_),A),E&&(_=jm(_)),ft&&+_==0&&d!=="+"&&(ft=!1),ee=(ft?d==="("?d:a:d==="-"||d==="("?"":d)+ee,le=(F==="s"?Qu[8+eh/3]:"")+le+(ft&&d==="("?")":""),Y){for(Ve=-1,Kt=_.length;++Ve<Kt;)if(lt=_.charCodeAt(Ve),48>lt||lt>57){le=(lt===46?i+_.slice(Ve+1):_.slice(Ve))+le,_=_.slice(0,Ve);break}}}b&&!g&&(_=e(_,1/0));var Tt=ee.length+_.length+le.length,Be=Tt<x?new Array(x-Tt+1).join(h):"";switch(b&&g&&(_=e(Be+_,Be.length?x-le.length:1/0),Be=""),p){case"<":_=ee+_+le+Be;break;case"=":_=ee+Be+_+le;break;case"^":_=Be.slice(0,Tt=Be.length>>1)+ee+_+le+Be.slice(Tt);break;default:_=Be+ee+_+le;break}return s(_)}return j.toString=function(){return l+""},j}function f(l,h){var p=u((l=Mt(l),l.type="f",l)),d=Math.max(-8,Math.min(8,Math.floor(or(h)/3)))*3,m=Math.pow(10,-d),g=Qu[8+d/3];return function(x){return p(m*x)+g}}return{format:u,formatPrefix:f}}var as,ue,_c;Km({thousands:",",grouping:[3],currency:["$",""]});function Km(t){return as=Xm(t),ue=as.format,_c=as.formatPrefix,as}function th(t){return Math.max(0,-or(Math.abs(t)))}function nh(t,e){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(or(e)/3)))*3-or(Math.abs(t)))}function rh(t,e){return t=Math.abs(t),e=Math.abs(e)-t,Math.max(0,or(e)-or(t))+1}const ea=new Date,ta=new Date;function Z(t,e,n,r){function i(s){return t(s=arguments.length===0?new Date:new Date(+s)),s}return i.floor=s=>(t(s=new Date(+s)),s),i.ceil=s=>(t(s=new Date(s-1)),e(s,1),t(s),s),i.round=s=>{const o=i(s),a=i.ceil(s);return s-o<a-s?o:a},i.offset=(s,o)=>(e(s=new Date(+s),o==null?1:Math.floor(o)),s),i.range=(s,o,a)=>{const c=[];if(s=i.ceil(s),a=a==null?1:Math.floor(a),!(s<o)||!(a>0))return c;let u;do c.push(u=new Date(+s)),e(s,a),t(s);while(u<s&&s<o);return c},i.filter=s=>Z(o=>{if(o>=o)for(;t(o),!s(o);)o.setTime(o-1)},(o,a)=>{if(o>=o)if(a<0)for(;++a<=0;)for(;e(o,-1),!s(o););else for(;--a>=0;)for(;e(o,1),!s(o););}),n&&(i.count=(s,o)=>(ea.setTime(+s),ta.setTime(+o),t(ea),t(ta),Math.floor(n(ea,ta))),i.every=s=>(s=Math.floor(s),!isFinite(s)||!(s>0)?null:s>1?i.filter(r?o=>r(o)%s===0:o=>i.count(0,o)%s===0):i)),i}const ar=Z(()=>{},(t,e)=>{t.setTime(+t+e)},(t,e)=>e-t);ar.every=t=>(t=Math.floor(t),!isFinite(t)||!(t>0)?null:t>1?Z(e=>{e.setTime(Math.floor(e/t)*t)},(e,n)=>{e.setTime(+e+n*t)},(e,n)=>(n-e)/t):ar);ar.range;const yt=1e3,Ue=yt*60,bt=Ue*60,Et=bt*24,Rc=Et*7,el=Et*30,na=Et*365,At=Z(t=>{t.setTime(t-t.getMilliseconds())},(t,e)=>{t.setTime(+t+e*yt)},(t,e)=>(e-t)/yt,t=>t.getUTCSeconds());At.range;const lo=Z(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*yt)},(t,e)=>{t.setTime(+t+e*Ue)},(t,e)=>(e-t)/Ue,t=>t.getMinutes());lo.range;const fo=Z(t=>{t.setUTCSeconds(0,0)},(t,e)=>{t.setTime(+t+e*Ue)},(t,e)=>(e-t)/Ue,t=>t.getUTCMinutes());fo.range;const ho=Z(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*yt-t.getMinutes()*Ue)},(t,e)=>{t.setTime(+t+e*bt)},(t,e)=>(e-t)/bt,t=>t.getHours());ho.range;const po=Z(t=>{t.setUTCMinutes(0,0,0)},(t,e)=>{t.setTime(+t+e*bt)},(t,e)=>(e-t)/bt,t=>t.getUTCHours());po.range;const Rt=Z(t=>t.setHours(0,0,0,0),(t,e)=>t.setDate(t.getDate()+e),(t,e)=>(e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*Ue)/Et,t=>t.getDate()-1);Rt.range;const xn=Z(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/Et,t=>t.getUTCDate()-1);xn.range;const ih=Z(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/Et,t=>Math.floor(t/Et));ih.range;function Bn(t){return Z(e=>{e.setDate(e.getDate()-(e.getDay()+7-t)%7),e.setHours(0,0,0,0)},(e,n)=>{e.setDate(e.getDate()+n*7)},(e,n)=>(n-e-(n.getTimezoneOffset()-e.getTimezoneOffset())*Ue)/Rc)}const Ri=Bn(0),Ms=Bn(1),Jm=Bn(2),Zm=Bn(3),cr=Bn(4),Qm=Bn(5),eg=Bn(6);Ri.range;Ms.range;Jm.range;Zm.range;cr.range;Qm.range;eg.range;function kn(t){return Z(e=>{e.setUTCDate(e.getUTCDate()-(e.getUTCDay()+7-t)%7),e.setUTCHours(0,0,0,0)},(e,n)=>{e.setUTCDate(e.getUTCDate()+n*7)},(e,n)=>(n-e)/Rc)}const Mi=kn(0),Bs=kn(1),tg=kn(2),ng=kn(3),ur=kn(4),rg=kn(5),ig=kn(6);Mi.range;Bs.range;tg.range;ng.range;ur.range;rg.range;ig.range;const Xr=Z(t=>{t.setDate(1),t.setHours(0,0,0,0)},(t,e)=>{t.setMonth(t.getMonth()+e)},(t,e)=>e.getMonth()-t.getMonth()+(e.getFullYear()-t.getFullYear())*12,t=>t.getMonth());Xr.range;const Kr=Z(t=>{t.setUTCDate(1),t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCMonth(t.getUTCMonth()+e)},(t,e)=>e.getUTCMonth()-t.getUTCMonth()+(e.getUTCFullYear()-t.getUTCFullYear())*12,t=>t.getUTCMonth());Kr.range;const st=Z(t=>{t.setMonth(0,1),t.setHours(0,0,0,0)},(t,e)=>{t.setFullYear(t.getFullYear()+e)},(t,e)=>e.getFullYear()-t.getFullYear(),t=>t.getFullYear());st.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:Z(e=>{e.setFullYear(Math.floor(e.getFullYear()/t)*t),e.setMonth(0,1),e.setHours(0,0,0,0)},(e,n)=>{e.setFullYear(e.getFullYear()+n*t)});st.range;const ot=Z(t=>{t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCFullYear(t.getUTCFullYear()+e)},(t,e)=>e.getUTCFullYear()-t.getUTCFullYear(),t=>t.getUTCFullYear());ot.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:Z(e=>{e.setUTCFullYear(Math.floor(e.getUTCFullYear()/t)*t),e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0)},(e,n)=>{e.setUTCFullYear(e.getUTCFullYear()+n*t)});ot.range;function sh(t,e,n,r,i,s){const o=[[At,1,yt],[At,5,5*yt],[At,15,15*yt],[At,30,30*yt],[s,1,Ue],[s,5,5*Ue],[s,15,15*Ue],[s,30,30*Ue],[i,1,bt],[i,3,3*bt],[i,6,6*bt],[i,12,12*bt],[r,1,Et],[r,2,2*Et],[n,1,Rc],[e,1,el],[e,3,3*el],[t,1,na]];function a(u,f,l){const h=f<u;h&&([u,f]=[f,u]);const p=l&&typeof l.range=="function"?l:c(u,f,l),d=p?p.range(u,+f+1):[];return h?d.reverse():d}function c(u,f,l){const h=Math.abs(f-u)/l,p=co(([,,g])=>g).right(o,h);if(p===o.length)return t.every(Fn(u/na,f/na,l));if(p===0)return ar.every(Math.max(Fn(u,f,l),1));const[d,m]=o[h/o[p-1][2]<o[p][2]/h?p-1:p];return d.every(m)}return[a,c]}const[sg,og]=sh(ot,Kr,Mi,ih,po,fo),[ag,cg]=sh(st,Xr,Ri,Rt,ho,lo),Jr="year",Zr="quarter",Qr="month",ei="week",ti="date",mo="day",Mc="dayofyear",ni="hours",ri="minutes",ii="seconds",go="milliseconds",ug=[Jr,Zr,Qr,ei,ti,mo,Mc,ni,ri,ii,go];ug.reduce((t,e,n)=>(t[e]=1+n,t),{});const lg={[Jr]:st,[Zr]:Xr.every(3),[Qr]:Xr,[ei]:Ri,[ti]:Rt,[mo]:Rt,[Mc]:Rt,[ni]:ho,[ri]:lo,[ii]:At,[go]:ar},fg={[Jr]:ot,[Zr]:Kr.every(3),[Qr]:Kr,[ei]:Mi,[ti]:xn,[mo]:xn,[Mc]:xn,[ni]:po,[ri]:fo,[ii]:At,[go]:ar};function hg(t){return lg[t]}function dg(t){return fg[t]}function ra(t){if(0<=t.y&&t.y<100){var e=new Date(-1,t.m,t.d,t.H,t.M,t.S,t.L);return e.setFullYear(t.y),e}return new Date(t.y,t.m,t.d,t.H,t.M,t.S,t.L)}function ia(t){if(0<=t.y&&t.y<100){var e=new Date(Date.UTC(-1,t.m,t.d,t.H,t.M,t.S,t.L));return e.setUTCFullYear(t.y),e}return new Date(Date.UTC(t.y,t.m,t.d,t.H,t.M,t.S,t.L))}function Tr(t,e,n){return{y:t,m:e,d:n,H:0,M:0,S:0,L:0}}function oh(t){var e=t.dateTime,n=t.date,r=t.time,i=t.periods,s=t.days,o=t.shortDays,a=t.months,c=t.shortMonths,u=Dr(i),f=Ir(i),l=Dr(s),h=Ir(s),p=Dr(o),d=Ir(o),m=Dr(a),g=Ir(a),x=Dr(c),b=Ir(c),A={a:ft,A:Tt,b:Be,B:ke,c:null,d:ol,e:ol,f:Pg,g:Wg,G:Yg,H:Bg,I:kg,j:Og,L:ah,m:Lg,M:Ng,p:ns,q:Jt,Q:ul,s:ll,S:zg,u:Ug,U:$g,V:Vg,w:Gg,W:Hg,x:null,X:null,y:qg,Y:jg,Z:Xg,"%":cl},E={a:Er,A:rs,b:oe,B:Ze,c:null,d:al,e:al,f:Qg,g:u1,G:f1,H:Kg,I:Jg,j:Zg,L:uh,m:e1,M:t1,p:Ge,q:Cr,Q:ul,s:ll,S:n1,u:r1,U:i1,V:s1,w:o1,W:a1,x:null,X:null,y:c1,Y:l1,Z:h1,"%":cl},F={a:j,A:_,b:ee,B:le,c:Ve,d:il,e:il,f:Ig,g:rl,G:nl,H:sl,I:sl,j:Sg,L:Dg,m:Cg,M:Fg,p:Y,q:Eg,Q:Rg,s:Mg,S:Tg,u:yg,U:bg,V:Ag,w:xg,W:wg,x:Kt,X:lt,y:rl,Y:nl,Z:vg,"%":_g};A.x=C(n,A),A.X=C(r,A),A.c=C(e,A),E.x=C(n,E),E.X=C(r,E),E.c=C(e,E);function C(T,B){return function(k){var v=[],ve=-1,$=0,Oe=T.length,Pe,Zt,ku;for(k instanceof Date||(k=new Date(+k));++ve<Oe;)T.charCodeAt(ve)===37&&(v.push(T.slice($,ve)),(Zt=tl[Pe=T.charAt(++ve)])!=null?Pe=T.charAt(++ve):Zt=Pe==="e"?" ":"0",(ku=B[Pe])&&(Pe=ku(k,Zt)),v.push(Pe),$=ve+1);return v.push(T.slice($,ve)),v.join("")}}function w(T,B){return function(k){var v=Tr(1900,void 0,1),ve=L(v,T,k+="",0),$,Oe;if(ve!=k.length)return null;if("Q"in v)return new Date(v.Q);if("s"in v)return new Date(v.s*1e3+("L"in v?v.L:0));if(B&&!("Z"in v)&&(v.Z=0),"p"in v&&(v.H=v.H%12+v.p*12),v.m===void 0&&(v.m="q"in v?v.q:0),"V"in v){if(v.V<1||v.V>53)return null;"w"in v||(v.w=1),"Z"in v?($=ia(Tr(v.y,0,1)),Oe=$.getUTCDay(),$=Oe>4||Oe===0?Bs.ceil($):Bs($),$=xn.offset($,(v.V-1)*7),v.y=$.getUTCFullYear(),v.m=$.getUTCMonth(),v.d=$.getUTCDate()+(v.w+6)%7):($=ra(Tr(v.y,0,1)),Oe=$.getDay(),$=Oe>4||Oe===0?Ms.ceil($):Ms($),$=Rt.offset($,(v.V-1)*7),v.y=$.getFullYear(),v.m=$.getMonth(),v.d=$.getDate()+(v.w+6)%7)}else("W"in v||"U"in v)&&("w"in v||(v.w="u"in v?v.u%7:"W"in v?1:0),Oe="Z"in v?ia(Tr(v.y,0,1)).getUTCDay():ra(Tr(v.y,0,1)).getDay(),v.m=0,v.d="W"in v?(v.w+6)%7+v.W*7-(Oe+5)%7:v.w+v.U*7-(Oe+6)%7);return"Z"in v?(v.H+=v.Z/100|0,v.M+=v.Z%100,ia(v)):ra(v)}}function L(T,B,k,v){for(var ve=0,$=B.length,Oe=k.length,Pe,Zt;ve<$;){if(v>=Oe)return-1;if(Pe=B.charCodeAt(ve++),Pe===37){if(Pe=B.charAt(ve++),Zt=F[Pe in tl?B.charAt(ve++):Pe],!Zt||(v=Zt(T,k,v))<0)return-1}else if(Pe!=k.charCodeAt(v++))return-1}return v}function Y(T,B,k){var v=u.exec(B.slice(k));return v?(T.p=f.get(v[0].toLowerCase()),k+v[0].length):-1}function j(T,B,k){var v=p.exec(B.slice(k));return v?(T.w=d.get(v[0].toLowerCase()),k+v[0].length):-1}function _(T,B,k){var v=l.exec(B.slice(k));return v?(T.w=h.get(v[0].toLowerCase()),k+v[0].length):-1}function ee(T,B,k){var v=x.exec(B.slice(k));return v?(T.m=b.get(v[0].toLowerCase()),k+v[0].length):-1}function le(T,B,k){var v=m.exec(B.slice(k));return v?(T.m=g.get(v[0].toLowerCase()),k+v[0].length):-1}function Ve(T,B,k){return L(T,e,B,k)}function Kt(T,B,k){return L(T,n,B,k)}function lt(T,B,k){return L(T,r,B,k)}function ft(T){return o[T.getDay()]}function Tt(T){return s[T.getDay()]}function Be(T){return c[T.getMonth()]}function ke(T){return a[T.getMonth()]}function ns(T){return i[+(T.getHours()>=12)]}function Jt(T){return 1+~~(T.getMonth()/3)}function Er(T){return o[T.getUTCDay()]}function rs(T){return s[T.getUTCDay()]}function oe(T){return c[T.getUTCMonth()]}function Ze(T){return a[T.getUTCMonth()]}function Ge(T){return i[+(T.getUTCHours()>=12)]}function Cr(T){return 1+~~(T.getUTCMonth()/3)}return{format:function(T){var B=C(T+="",A);return B.toString=function(){return T},B},parse:function(T){var B=w(T+="",!1);return B.toString=function(){return T},B},utcFormat:function(T){var B=C(T+="",E);return B.toString=function(){return T},B},utcParse:function(T){var B=w(T+="",!0);return B.toString=function(){return T},B}}}var tl={"-":"",_:" ",0:"0"},se=/^\s*\d+/,pg=/^%/,mg=/[\\^$*+?|[\]().{}]/g;function P(t,e,n){var r=t<0?"-":"",i=(r?-t:t)+"",s=i.length;return r+(s<n?new Array(n-s+1).join(e)+i:i)}function gg(t){return t.replace(mg,"\\$&")}function Dr(t){return new RegExp("^(?:"+t.map(gg).join("|")+")","i")}function Ir(t){return new Map(t.map((e,n)=>[e.toLowerCase(),n]))}function xg(t,e,n){var r=se.exec(e.slice(n,n+1));return r?(t.w=+r[0],n+r[0].length):-1}function yg(t,e,n){var r=se.exec(e.slice(n,n+1));return r?(t.u=+r[0],n+r[0].length):-1}function bg(t,e,n){var r=se.exec(e.slice(n,n+2));return r?(t.U=+r[0],n+r[0].length):-1}function Ag(t,e,n){var r=se.exec(e.slice(n,n+2));return r?(t.V=+r[0],n+r[0].length):-1}function wg(t,e,n){var r=se.exec(e.slice(n,n+2));return r?(t.W=+r[0],n+r[0].length):-1}function nl(t,e,n){var r=se.exec(e.slice(n,n+4));return r?(t.y=+r[0],n+r[0].length):-1}function rl(t,e,n){var r=se.exec(e.slice(n,n+2));return r?(t.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function vg(t,e,n){var r=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(e.slice(n,n+6));return r?(t.Z=r[1]?0:-(r[2]+(r[3]||"00")),n+r[0].length):-1}function Eg(t,e,n){var r=se.exec(e.slice(n,n+1));return r?(t.q=r[0]*3-3,n+r[0].length):-1}function Cg(t,e,n){var r=se.exec(e.slice(n,n+2));return r?(t.m=r[0]-1,n+r[0].length):-1}function il(t,e,n){var r=se.exec(e.slice(n,n+2));return r?(t.d=+r[0],n+r[0].length):-1}function Sg(t,e,n){var r=se.exec(e.slice(n,n+3));return r?(t.m=0,t.d=+r[0],n+r[0].length):-1}function sl(t,e,n){var r=se.exec(e.slice(n,n+2));return r?(t.H=+r[0],n+r[0].length):-1}function Fg(t,e,n){var r=se.exec(e.slice(n,n+2));return r?(t.M=+r[0],n+r[0].length):-1}function Tg(t,e,n){var r=se.exec(e.slice(n,n+2));return r?(t.S=+r[0],n+r[0].length):-1}function Dg(t,e,n){var r=se.exec(e.slice(n,n+3));return r?(t.L=+r[0],n+r[0].length):-1}function Ig(t,e,n){var r=se.exec(e.slice(n,n+6));return r?(t.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function _g(t,e,n){var r=pg.exec(e.slice(n,n+1));return r?n+r[0].length:-1}function Rg(t,e,n){var r=se.exec(e.slice(n));return r?(t.Q=+r[0],n+r[0].length):-1}function Mg(t,e,n){var r=se.exec(e.slice(n));return r?(t.s=+r[0],n+r[0].length):-1}function ol(t,e){return P(t.getDate(),e,2)}function Bg(t,e){return P(t.getHours(),e,2)}function kg(t,e){return P(t.getHours()%12||12,e,2)}function Og(t,e){return P(1+Rt.count(st(t),t),e,3)}function ah(t,e){return P(t.getMilliseconds(),e,3)}function Pg(t,e){return ah(t,e)+"000"}function Lg(t,e){return P(t.getMonth()+1,e,2)}function Ng(t,e){return P(t.getMinutes(),e,2)}function zg(t,e){return P(t.getSeconds(),e,2)}function Ug(t){var e=t.getDay();return e===0?7:e}function $g(t,e){return P(Ri.count(st(t)-1,t),e,2)}function ch(t){var e=t.getDay();return e>=4||e===0?cr(t):cr.ceil(t)}function Vg(t,e){return t=ch(t),P(cr.count(st(t),t)+(st(t).getDay()===4),e,2)}function Gg(t){return t.getDay()}function Hg(t,e){return P(Ms.count(st(t)-1,t),e,2)}function qg(t,e){return P(t.getFullYear()%100,e,2)}function Wg(t,e){return t=ch(t),P(t.getFullYear()%100,e,2)}function jg(t,e){return P(t.getFullYear()%1e4,e,4)}function Yg(t,e){var n=t.getDay();return t=n>=4||n===0?cr(t):cr.ceil(t),P(t.getFullYear()%1e4,e,4)}function Xg(t){var e=t.getTimezoneOffset();return(e>0?"-":(e*=-1,"+"))+P(e/60|0,"0",2)+P(e%60,"0",2)}function al(t,e){return P(t.getUTCDate(),e,2)}function Kg(t,e){return P(t.getUTCHours(),e,2)}function Jg(t,e){return P(t.getUTCHours()%12||12,e,2)}function Zg(t,e){return P(1+xn.count(ot(t),t),e,3)}function uh(t,e){return P(t.getUTCMilliseconds(),e,3)}function Qg(t,e){return uh(t,e)+"000"}function e1(t,e){return P(t.getUTCMonth()+1,e,2)}function t1(t,e){return P(t.getUTCMinutes(),e,2)}function n1(t,e){return P(t.getUTCSeconds(),e,2)}function r1(t){var e=t.getUTCDay();return e===0?7:e}function i1(t,e){return P(Mi.count(ot(t)-1,t),e,2)}function lh(t){var e=t.getUTCDay();return e>=4||e===0?ur(t):ur.ceil(t)}function s1(t,e){return t=lh(t),P(ur.count(ot(t),t)+(ot(t).getUTCDay()===4),e,2)}function o1(t){return t.getUTCDay()}function a1(t,e){return P(Bs.count(ot(t)-1,t),e,2)}function c1(t,e){return P(t.getUTCFullYear()%100,e,2)}function u1(t,e){return t=lh(t),P(t.getUTCFullYear()%100,e,2)}function l1(t,e){return P(t.getUTCFullYear()%1e4,e,4)}function f1(t,e){var n=t.getUTCDay();return t=n>=4||n===0?ur(t):ur.ceil(t),P(t.getUTCFullYear()%1e4,e,4)}function h1(){return"+0000"}function cl(){return"%"}function ul(t){return+t}function ll(t){return Math.floor(+t/1e3)}var Nn,Bc,fh,kc,hh;d1({dateTime:"%x, %X",date:"%-m/%-d/%Y",time:"%-I:%M:%S %p",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});function d1(t){return Nn=oh(t),Bc=Nn.format,fh=Nn.parse,kc=Nn.utcFormat,hh=Nn.utcParse,Nn}function Mr(t){const e={};return n=>e[n]||(e[n]=t(n))}function p1(t,e){return n=>{const r=t(n),i=r.indexOf(e);if(i<0)return r;let s=m1(r,i);const o=s<r.length?r.slice(s):"";for(;--s>i;)if(r[s]!=="0"){++s;break}return r.slice(0,s)+o}}function m1(t,e){let n=t.lastIndexOf("e"),r;if(n>0)return n;for(n=t.length;--n>e;)if(r=t.charCodeAt(n),r>=48&&r<=57)return n+1}function g1(t){const e=Mr(t.format),n=t.formatPrefix;return{format:e,formatPrefix:n,formatFloat(r){const i=Mt(r||",");if(i.precision==null){switch(i.precision=12,i.type){case"%":i.precision-=2;break;case"e":i.precision-=1;break}return p1(e(i),e(".1f")(1)[1])}else return e(i)},formatSpan(r,i,s,o){o=Mt(o??",f");const a=Fn(r,i,s),c=Math.max(Math.abs(r),Math.abs(i));let u;if(o.precision==null)switch(o.type){case"s":return isNaN(u=nh(a,c))||(o.precision=u),n(o,c);case"":case"e":case"g":case"p":case"r":{isNaN(u=rh(a,c))||(o.precision=u-(o.type==="e"));break}case"f":case"%":{isNaN(u=th(a))||(o.precision=u-(o.type==="%")*2);break}}return e(o)}}}x1();function x1(){return g1({format:ue,formatPrefix:_c})}function fl(t,e,n){n=n||{},Re(n)||W(`Invalid time multi-format specifier: ${n}`);const r=e(ii),i=e(ri),s=e(ni),o=e(ti),a=e(ei),c=e(Qr),u=e(Zr),f=e(Jr),l=t(n[go]||".%L"),h=t(n[ii]||":%S"),p=t(n[ri]||"%I:%M"),d=t(n[ni]||"%I %p"),m=t(n[ti]||n[mo]||"%a %d"),g=t(n[ei]||"%b %d"),x=t(n[Qr]||"%B"),b=t(n[Zr]||"%B"),A=t(n[Jr]||"%Y");return E=>(r(E)<E?l:i(E)<E?h:s(E)<E?p:o(E)<E?d:c(E)<E?a(E)<E?m:g:f(E)<E?u(E)<E?x:b:A)(E)}function dh(t){const e=Mr(t.format),n=Mr(t.utcFormat);return{timeFormat:r=>V(r)?e(r):fl(e,hg,r),utcFormat:r=>V(r)?n(r):fl(n,dg,r),timeParse:Mr(t.parse),utcParse:Mr(t.utcParse)}}let Ba;y1();function y1(){return Ba=dh({format:Bc,parse:fh,utcFormat:kc,utcParse:hh})}function b1(t){return dh(oh(t))}function A1(t){return arguments.length?Ba=b1(t):Ba}const w1=/^(data:|([A-Za-z]+:)?\/\/)/,v1=/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp|file|data):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i,E1=/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205f\u3000]/g,hl="file://";function C1(t,e){return n=>({options:n||{},sanitize:F1,load:S1,fileAccess:!!e,file:T1(e),http:I1(t)})}async function S1(t,e){const n=await this.sanitize(t,e),r=n.href;return n.localFile?this.file(r):this.http(r,e)}async function F1(t,e){e=Dc({},this.options,e);const n=this.fileAccess,r={href:null};let i,s,o;const a=v1.test(t.replace(E1,""));(t==null||typeof t!="string"||!a)&&W("Sanitize failure, invalid URI: "+ao(t));const c=w1.test(t);return(o=e.baseURL)&&!c&&(!t.startsWith("/")&&!o.endsWith("/")&&(t="/"+t),t=o+t),s=(i=t.startsWith(hl))||e.mode==="file"||e.mode!=="http"&&!c&&n,i?t=t.slice(hl.length):t.startsWith("//")&&(e.defaultProtocol==="file"?(t=t.slice(2),s=!0):t=(e.defaultProtocol||"http")+":"+t),Object.defineProperty(r,"localFile",{value:!!s}),r.href=t,e.target&&(r.target=e.target+""),e.rel&&(r.rel=e.rel+""),e.context==="image"&&e.crossOrigin&&(r.crossOrigin=e.crossOrigin+""),r}function T1(t){return t?e=>new Promise((n,r)=>{t.readFile(e,(i,s)=>{i?r(i):n(s)})}):D1}async function D1(){W("No file system access.")}function I1(t){return t?async function(e,n){const r=Dc({},this.options.http,n),i=n&&n.response,s=await t(e,r);return s.ok?Ie(s[i])?s[i]():s.text():W(s.status+""+s.statusText)}:_1}async function _1(){W("No HTTP fetch method available.")}const R1=t=>t!=null&&t===t,M1=t=>t==="true"||t==="false"||t===!0||t===!1,B1=t=>!Number.isNaN(Date.parse(t)),ph=t=>!Number.isNaN(+t)&&!(t instanceof Date),k1=t=>ph(t)&&Number.isInteger(+t),dl={boolean:xm,integer:jr,number:jr,date:bm,string:Am,unknown:so},cs=[M1,k1,ph,B1],O1=["boolean","integer","number","date"];function P1(t,e){if(!t||!t.length)return"unknown";const n=t.length,r=cs.length,i=cs.map((s,o)=>o+1);for(let s=0,o=0,a,c;s<n;++s)for(c=e?t[s][e]:t[s],a=0;a<r;++a)if(i[a]&&R1(c)&&!cs[a](c)&&(i[a]=0,++o,o===cs.length))return"string";return O1[i.reduce((s,o)=>s===0?o:s,0)-1]}function L1(t,e){return e.reduce((n,r)=>(n[r]=P1(t,r),n),{})}function pl(t){const e=function(n,r){const i={delimiter:t};return Oc(n,r?Dc(r,i):i)};return e.responseType="text",e}function Oc(t,e){return e.header&&(t=e.header.map(ao).join(e.delimiter)+` +`+t),Cm(e.delimiter).parse(t+"")}Oc.responseType="text";function N1(t){return typeof Buffer=="function"&&Ie(Buffer.isBuffer)?Buffer.isBuffer(t):!1}function Pc(t,e){const n=e&&e.property?io(e.property):so;return Re(t)&&!N1(t)?z1(n(t),e):n(JSON.parse(t))}Pc.responseType="json";function z1(t,e){return!Me(t)&&mm(t)&&(t=[...t]),e&&e.copy?JSON.parse(JSON.stringify(t)):t}const U1={interior:(t,e)=>t!==e,exterior:(t,e)=>t===e};function mh(t,e){let n,r,i,s;return t=Pc(t,e),e&&e.feature?(n=Dm,i=e.feature):e&&e.mesh?(n=_m,i=e.mesh,s=U1[e.filter]):W("Missing TopoJSON feature or mesh parameter."),r=(r=t.objects[i])?n(t,r,s):W("Invalid TopoJSON object: "+i),r&&r.features||[r]}mh.responseType="json";const sa={dsv:Oc,csv:pl(","),tsv:pl(" "),json:Pc,topojson:mh};function gh(t,e){return arguments.length>1?(sa[t]=e,this):qn(sa,t)?sa[t]:null}function xh(t,e,n,r){e=e||{};const i=gh(e.type||"json");return i||W("Unknown data format type: "+e.type),t=i(t,e),e.parse&&$1(t,e.parse,n,r),qn(t,"columns")&&delete t.columns,t}function $1(t,e,n,r){if(!t.length)return;const i=A1();n=n||i.timeParse,r=r||i.utcParse;let s=t.columns||Object.keys(t[0]),o,a,c,u,f,l;e==="auto"&&(e=L1(t,s)),s=Object.keys(e);const h=s.map(p=>{const d=e[p];let m,g;if(d&&(d.startsWith("date:")||d.startsWith("utc:")))return m=d.split(/:(.+)?/,2),g=m[1],(g[0]==="'"&&g[g.length-1]==="'"||g[0]==='"'&&g[g.length-1]==='"')&&(g=g.slice(1,-1)),(m[0]==="utc"?r:n)(g);if(!dl[d])throw Error("Illegal format pattern: "+p+":"+d);return dl[d]});for(c=0,f=t.length,l=s.length;c<f;++c)for(o=t[c],u=0;u<l;++u)a=s[u],o[a]=h[u](o[a])}const xo=C1(typeof fetch<"u"&&fetch,null),V1=`.genome-spy { + font-family: system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; + position: relative; +} +.genome-spy canvas { + transform: scale(1, 1); + opacity: 1; + transition: transform 0.6s, opacity 0.6s; +} +.genome-spy .loading-message { + position: absolute; + top: 0; + bottom: 0; + left: 0; + right: 0; + display: flex; + align-items: center; + justify-content: center; +} +.genome-spy .loading-message .message { + color: #666; + opacity: 0; + transition: opacity 0.7s; +} +.genome-spy.loading canvas { + transform: scale(0.95, 0.95); + opacity: 0; +} +.genome-spy.loading .loading-message .message { + opacity: 1; +} +.genome-spy.loading .ellipsis { + animation: blinker 1s linear infinite; +} +@keyframes blinker { + 50% { + opacity: 0; + } +} +.genome-spy .tooltip { + position: absolute; + max-width: 450px; + overflow: hidden; + background: #f6f6f6; + padding: 10px; + font-size: 13px; + box-shadow: 0px 3px 15px 0px rgba(0, 0, 0, 0.21); + pointer-events: none; + z-index: 100; +} +.genome-spy .tooltip > :last-child { + margin-bottom: 0; +} +.genome-spy .tooltip > .title { + padding-bottom: 5px; + margin-bottom: 5px; + border-bottom: 1px dashed #b6b6b6; +} +.genome-spy .tooltip .summary { + font-size: 12px; +} +.genome-spy .tooltip table { + border-collapse: collapse; +} +.genome-spy .tooltip table:first-child { + margin-top: 0; +} +.genome-spy .tooltip table th, +.genome-spy .tooltip table td { + padding: 2px 0.4em; + vertical-align: top; +} +.genome-spy .tooltip table th:first-child, +.genome-spy .tooltip table td:first-child { + padding-left: 0; +} +.genome-spy .tooltip table th { + text-align: left; + font-weight: bold; +} +.genome-spy .tooltip .color-legend { + display: inline-block; + width: 0.8em; + height: 0.8em; + margin-left: 0.4em; + box-shadow: 0px 0px 3px 1px white; +} +.genome-spy .tooltip .attributes .hovered { + background-color: #e0e0e0; +} +.genome-spy .tooltip .na { + color: #aaa; + font-style: italic; + font-size: 80%; +} +.genome-spy .gene-track-tooltip .summary { + font-size: 90%; +} +.genome-spy .message-box { + display: flex; + align-items: center; + justify-content: center; + position: absolute; + top: 0; + height: 100%; + width: 100%; +} +.genome-spy .message-box > div { + border: 1px solid red; + padding: 10px; + background: #fff0f0; +}`;function G1(t,e){var n=t.getBoundingClientRect();return[e.clientX-n.left-t.clientLeft,e.clientY-n.top-t.clientTop]}function ks(t,e){return t.length==e.length&&t.every((n,r)=>t[r]===e[r])}function ze(t){return Array.isArray(t)?t:typeof t<"u"?[t]:[]}function Bi(t){return t[t.length-1]}class H1{constructor(e){this.container=e,this.element=document.createElement("div"),this.element.className="tooltip",this._visible=!0,this.container.appendChild(this.element),this._previousTooltipDatum=void 0,this.enabledStack=[!0],this._penaltyUntil=0,this._lastCoords=void 0,this._previousMove=0,this.clear()}set visible(e){e!=this._visible&&(this.element.style.display=e?null:"none",this._visible=e)}get visible(){return this._visible}get enabled(){return Bi(this.enabledStack)??!0}pushEnabledState(e){this.enabledStack.push(e),e||(this.visible=!1)}popEnabledState(){this.enabledStack.pop()}handleMouseMove(e){this.mouseCoords=G1(this.container,e);const n=performance.now();!this.visible&&!this._isPenalty()&&n-this._previousMove>500&&(this._penaltyUntil=n+70),this._lastCoords&&q1(this.mouseCoords,this._lastCoords)>20&&(this._penaltyUntil=n+400),this._lastCoords=this.mouseCoords,this.visible&&this.updatePlacement(),this._previousMove=n}updatePlacement(){const[n,r]=this.mouseCoords;let i=n+20;i>this.container.clientWidth-this.element.offsetWidth&&(i=n-20-this.element.offsetWidth),this.element.style.left=i+"px",this.element.style.top=Math.min(r+20,this.container.clientHeight-this.element.offsetHeight)+"px"}setContent(e){if(!e||!this.enabled||this._isPenalty()){this.visible&&(Ss("",this.element),this.visible=!1),this._previousTooltipDatum=void 0;return}Ss(e,this.element),this.visible=!0,this.updatePlacement()}clear(){this._previousTooltipDatum=void 0,this.setContent(void 0)}updateWithDatum(e,n){e!==this._previousTooltipDatum&&(this._previousTooltipDatum=e,n||(n=r=>Promise.resolve(te`${JSON.stringify(r)}`)),n(e).then(r=>this.setContent(r)).catch(r=>{if(r!=="debounced")throw r}))}_isPenalty(){return this._penaltyUntil&&this._penaltyUntil>performance.now()}}function q1(t,e){let n=0;for(let r=0;r<t.length;r++)n+=(t[r]-e[r])**2;return Math.sqrt(n)}const W1="RawCode",j1="Literal",Y1="Property",X1="Identifier",K1="ArrayExpression",J1="BinaryExpression",Z1="CallExpression",Q1="ConditionalExpression",ex="LogicalExpression",tx="MemberExpression",nx="ObjectExpression",rx="UnaryExpression";function Je(t){this.type=t}Je.prototype.visit=function(t){let e,n,r;if(t(this))return 1;for(e=ix(this),n=0,r=e.length;n<r;++n)if(e[n].visit(t))return 1};function ix(t){switch(t.type){case K1:return t.elements;case J1:case ex:return[t.left,t.right];case Z1:return[t.callee].concat(t.arguments);case Q1:return[t.test,t.consequent,t.alternate];case tx:return[t.object,t.property];case nx:return t.properties;case Y1:return[t.key,t.value];case rx:return[t.argument];case X1:case j1:case W1:default:return[]}}var at,D,y,xe,z,yo=1,ki=2,Tn=3,$t=4,bo=5,On=6,Se=7,Oi=8,sx=9;at={};at[yo]="Boolean";at[ki]="<end>";at[Tn]="Identifier";at[$t]="Keyword";at[bo]="Null";at[On]="Numeric";at[Se]="Punctuator";at[Oi]="String";at[sx]="RegularExpression";var ox="ArrayExpression",ax="BinaryExpression",cx="CallExpression",ux="ConditionalExpression",yh="Identifier",lx="Literal",fx="LogicalExpression",hx="MemberExpression",dx="ObjectExpression",px="Property",mx="UnaryExpression",ne="Unexpected token %0",gx="Unexpected number",xx="Unexpected string",yx="Unexpected identifier",bx="Unexpected reserved word",Ax="Unexpected end of input",ka="Invalid regular expression",oa="Invalid regular expression: missing /",bh="Octal literals are not allowed in strict mode.",wx="Duplicate data property in object literal not allowed in strict mode",ce="ILLEGAL",si="Disabled.",vx=new RegExp("[\\xAA\\xB5\\xBA\\xC0-\\xD6\\xD8-\\xF6\\xF8-\\u02C1\\u02C6-\\u02D1\\u02E0-\\u02E4\\u02EC\\u02EE\\u0370-\\u0374\\u0376\\u0377\\u037A-\\u037D\\u037F\\u0386\\u0388-\\u038A\\u038C\\u038E-\\u03A1\\u03A3-\\u03F5\\u03F7-\\u0481\\u048A-\\u052F\\u0531-\\u0556\\u0559\\u0561-\\u0587\\u05D0-\\u05EA\\u05F0-\\u05F2\\u0620-\\u064A\\u066E\\u066F\\u0671-\\u06D3\\u06D5\\u06E5\\u06E6\\u06EE\\u06EF\\u06FA-\\u06FC\\u06FF\\u0710\\u0712-\\u072F\\u074D-\\u07A5\\u07B1\\u07CA-\\u07EA\\u07F4\\u07F5\\u07FA\\u0800-\\u0815\\u081A\\u0824\\u0828\\u0840-\\u0858\\u08A0-\\u08B2\\u0904-\\u0939\\u093D\\u0950\\u0958-\\u0961\\u0971-\\u0980\\u0985-\\u098C\\u098F\\u0990\\u0993-\\u09A8\\u09AA-\\u09B0\\u09B2\\u09B6-\\u09B9\\u09BD\\u09CE\\u09DC\\u09DD\\u09DF-\\u09E1\\u09F0\\u09F1\\u0A05-\\u0A0A\\u0A0F\\u0A10\\u0A13-\\u0A28\\u0A2A-\\u0A30\\u0A32\\u0A33\\u0A35\\u0A36\\u0A38\\u0A39\\u0A59-\\u0A5C\\u0A5E\\u0A72-\\u0A74\\u0A85-\\u0A8D\\u0A8F-\\u0A91\\u0A93-\\u0AA8\\u0AAA-\\u0AB0\\u0AB2\\u0AB3\\u0AB5-\\u0AB9\\u0ABD\\u0AD0\\u0AE0\\u0AE1\\u0B05-\\u0B0C\\u0B0F\\u0B10\\u0B13-\\u0B28\\u0B2A-\\u0B30\\u0B32\\u0B33\\u0B35-\\u0B39\\u0B3D\\u0B5C\\u0B5D\\u0B5F-\\u0B61\\u0B71\\u0B83\\u0B85-\\u0B8A\\u0B8E-\\u0B90\\u0B92-\\u0B95\\u0B99\\u0B9A\\u0B9C\\u0B9E\\u0B9F\\u0BA3\\u0BA4\\u0BA8-\\u0BAA\\u0BAE-\\u0BB9\\u0BD0\\u0C05-\\u0C0C\\u0C0E-\\u0C10\\u0C12-\\u0C28\\u0C2A-\\u0C39\\u0C3D\\u0C58\\u0C59\\u0C60\\u0C61\\u0C85-\\u0C8C\\u0C8E-\\u0C90\\u0C92-\\u0CA8\\u0CAA-\\u0CB3\\u0CB5-\\u0CB9\\u0CBD\\u0CDE\\u0CE0\\u0CE1\\u0CF1\\u0CF2\\u0D05-\\u0D0C\\u0D0E-\\u0D10\\u0D12-\\u0D3A\\u0D3D\\u0D4E\\u0D60\\u0D61\\u0D7A-\\u0D7F\\u0D85-\\u0D96\\u0D9A-\\u0DB1\\u0DB3-\\u0DBB\\u0DBD\\u0DC0-\\u0DC6\\u0E01-\\u0E30\\u0E32\\u0E33\\u0E40-\\u0E46\\u0E81\\u0E82\\u0E84\\u0E87\\u0E88\\u0E8A\\u0E8D\\u0E94-\\u0E97\\u0E99-\\u0E9F\\u0EA1-\\u0EA3\\u0EA5\\u0EA7\\u0EAA\\u0EAB\\u0EAD-\\u0EB0\\u0EB2\\u0EB3\\u0EBD\\u0EC0-\\u0EC4\\u0EC6\\u0EDC-\\u0EDF\\u0F00\\u0F40-\\u0F47\\u0F49-\\u0F6C\\u0F88-\\u0F8C\\u1000-\\u102A\\u103F\\u1050-\\u1055\\u105A-\\u105D\\u1061\\u1065\\u1066\\u106E-\\u1070\\u1075-\\u1081\\u108E\\u10A0-\\u10C5\\u10C7\\u10CD\\u10D0-\\u10FA\\u10FC-\\u1248\\u124A-\\u124D\\u1250-\\u1256\\u1258\\u125A-\\u125D\\u1260-\\u1288\\u128A-\\u128D\\u1290-\\u12B0\\u12B2-\\u12B5\\u12B8-\\u12BE\\u12C0\\u12C2-\\u12C5\\u12C8-\\u12D6\\u12D8-\\u1310\\u1312-\\u1315\\u1318-\\u135A\\u1380-\\u138F\\u13A0-\\u13F4\\u1401-\\u166C\\u166F-\\u167F\\u1681-\\u169A\\u16A0-\\u16EA\\u16EE-\\u16F8\\u1700-\\u170C\\u170E-\\u1711\\u1720-\\u1731\\u1740-\\u1751\\u1760-\\u176C\\u176E-\\u1770\\u1780-\\u17B3\\u17D7\\u17DC\\u1820-\\u1877\\u1880-\\u18A8\\u18AA\\u18B0-\\u18F5\\u1900-\\u191E\\u1950-\\u196D\\u1970-\\u1974\\u1980-\\u19AB\\u19C1-\\u19C7\\u1A00-\\u1A16\\u1A20-\\u1A54\\u1AA7\\u1B05-\\u1B33\\u1B45-\\u1B4B\\u1B83-\\u1BA0\\u1BAE\\u1BAF\\u1BBA-\\u1BE5\\u1C00-\\u1C23\\u1C4D-\\u1C4F\\u1C5A-\\u1C7D\\u1CE9-\\u1CEC\\u1CEE-\\u1CF1\\u1CF5\\u1CF6\\u1D00-\\u1DBF\\u1E00-\\u1F15\\u1F18-\\u1F1D\\u1F20-\\u1F45\\u1F48-\\u1F4D\\u1F50-\\u1F57\\u1F59\\u1F5B\\u1F5D\\u1F5F-\\u1F7D\\u1F80-\\u1FB4\\u1FB6-\\u1FBC\\u1FBE\\u1FC2-\\u1FC4\\u1FC6-\\u1FCC\\u1FD0-\\u1FD3\\u1FD6-\\u1FDB\\u1FE0-\\u1FEC\\u1FF2-\\u1FF4\\u1FF6-\\u1FFC\\u2071\\u207F\\u2090-\\u209C\\u2102\\u2107\\u210A-\\u2113\\u2115\\u2119-\\u211D\\u2124\\u2126\\u2128\\u212A-\\u212D\\u212F-\\u2139\\u213C-\\u213F\\u2145-\\u2149\\u214E\\u2160-\\u2188\\u2C00-\\u2C2E\\u2C30-\\u2C5E\\u2C60-\\u2CE4\\u2CEB-\\u2CEE\\u2CF2\\u2CF3\\u2D00-\\u2D25\\u2D27\\u2D2D\\u2D30-\\u2D67\\u2D6F\\u2D80-\\u2D96\\u2DA0-\\u2DA6\\u2DA8-\\u2DAE\\u2DB0-\\u2DB6\\u2DB8-\\u2DBE\\u2DC0-\\u2DC6\\u2DC8-\\u2DCE\\u2DD0-\\u2DD6\\u2DD8-\\u2DDE\\u2E2F\\u3005-\\u3007\\u3021-\\u3029\\u3031-\\u3035\\u3038-\\u303C\\u3041-\\u3096\\u309D-\\u309F\\u30A1-\\u30FA\\u30FC-\\u30FF\\u3105-\\u312D\\u3131-\\u318E\\u31A0-\\u31BA\\u31F0-\\u31FF\\u3400-\\u4DB5\\u4E00-\\u9FCC\\uA000-\\uA48C\\uA4D0-\\uA4FD\\uA500-\\uA60C\\uA610-\\uA61F\\uA62A\\uA62B\\uA640-\\uA66E\\uA67F-\\uA69D\\uA6A0-\\uA6EF\\uA717-\\uA71F\\uA722-\\uA788\\uA78B-\\uA78E\\uA790-\\uA7AD\\uA7B0\\uA7B1\\uA7F7-\\uA801\\uA803-\\uA805\\uA807-\\uA80A\\uA80C-\\uA822\\uA840-\\uA873\\uA882-\\uA8B3\\uA8F2-\\uA8F7\\uA8FB\\uA90A-\\uA925\\uA930-\\uA946\\uA960-\\uA97C\\uA984-\\uA9B2\\uA9CF\\uA9E0-\\uA9E4\\uA9E6-\\uA9EF\\uA9FA-\\uA9FE\\uAA00-\\uAA28\\uAA40-\\uAA42\\uAA44-\\uAA4B\\uAA60-\\uAA76\\uAA7A\\uAA7E-\\uAAAF\\uAAB1\\uAAB5\\uAAB6\\uAAB9-\\uAABD\\uAAC0\\uAAC2\\uAADB-\\uAADD\\uAAE0-\\uAAEA\\uAAF2-\\uAAF4\\uAB01-\\uAB06\\uAB09-\\uAB0E\\uAB11-\\uAB16\\uAB20-\\uAB26\\uAB28-\\uAB2E\\uAB30-\\uAB5A\\uAB5C-\\uAB5F\\uAB64\\uAB65\\uABC0-\\uABE2\\uAC00-\\uD7A3\\uD7B0-\\uD7C6\\uD7CB-\\uD7FB\\uF900-\\uFA6D\\uFA70-\\uFAD9\\uFB00-\\uFB06\\uFB13-\\uFB17\\uFB1D\\uFB1F-\\uFB28\\uFB2A-\\uFB36\\uFB38-\\uFB3C\\uFB3E\\uFB40\\uFB41\\uFB43\\uFB44\\uFB46-\\uFBB1\\uFBD3-\\uFD3D\\uFD50-\\uFD8F\\uFD92-\\uFDC7\\uFDF0-\\uFDFB\\uFE70-\\uFE74\\uFE76-\\uFEFC\\uFF21-\\uFF3A\\uFF41-\\uFF5A\\uFF66-\\uFFBE\\uFFC2-\\uFFC7\\uFFCA-\\uFFCF\\uFFD2-\\uFFD7\\uFFDA-\\uFFDC]"),Ex=new RegExp("[\\xAA\\xB5\\xBA\\xC0-\\xD6\\xD8-\\xF6\\xF8-\\u02C1\\u02C6-\\u02D1\\u02E0-\\u02E4\\u02EC\\u02EE\\u0300-\\u0374\\u0376\\u0377\\u037A-\\u037D\\u037F\\u0386\\u0388-\\u038A\\u038C\\u038E-\\u03A1\\u03A3-\\u03F5\\u03F7-\\u0481\\u0483-\\u0487\\u048A-\\u052F\\u0531-\\u0556\\u0559\\u0561-\\u0587\\u0591-\\u05BD\\u05BF\\u05C1\\u05C2\\u05C4\\u05C5\\u05C7\\u05D0-\\u05EA\\u05F0-\\u05F2\\u0610-\\u061A\\u0620-\\u0669\\u066E-\\u06D3\\u06D5-\\u06DC\\u06DF-\\u06E8\\u06EA-\\u06FC\\u06FF\\u0710-\\u074A\\u074D-\\u07B1\\u07C0-\\u07F5\\u07FA\\u0800-\\u082D\\u0840-\\u085B\\u08A0-\\u08B2\\u08E4-\\u0963\\u0966-\\u096F\\u0971-\\u0983\\u0985-\\u098C\\u098F\\u0990\\u0993-\\u09A8\\u09AA-\\u09B0\\u09B2\\u09B6-\\u09B9\\u09BC-\\u09C4\\u09C7\\u09C8\\u09CB-\\u09CE\\u09D7\\u09DC\\u09DD\\u09DF-\\u09E3\\u09E6-\\u09F1\\u0A01-\\u0A03\\u0A05-\\u0A0A\\u0A0F\\u0A10\\u0A13-\\u0A28\\u0A2A-\\u0A30\\u0A32\\u0A33\\u0A35\\u0A36\\u0A38\\u0A39\\u0A3C\\u0A3E-\\u0A42\\u0A47\\u0A48\\u0A4B-\\u0A4D\\u0A51\\u0A59-\\u0A5C\\u0A5E\\u0A66-\\u0A75\\u0A81-\\u0A83\\u0A85-\\u0A8D\\u0A8F-\\u0A91\\u0A93-\\u0AA8\\u0AAA-\\u0AB0\\u0AB2\\u0AB3\\u0AB5-\\u0AB9\\u0ABC-\\u0AC5\\u0AC7-\\u0AC9\\u0ACB-\\u0ACD\\u0AD0\\u0AE0-\\u0AE3\\u0AE6-\\u0AEF\\u0B01-\\u0B03\\u0B05-\\u0B0C\\u0B0F\\u0B10\\u0B13-\\u0B28\\u0B2A-\\u0B30\\u0B32\\u0B33\\u0B35-\\u0B39\\u0B3C-\\u0B44\\u0B47\\u0B48\\u0B4B-\\u0B4D\\u0B56\\u0B57\\u0B5C\\u0B5D\\u0B5F-\\u0B63\\u0B66-\\u0B6F\\u0B71\\u0B82\\u0B83\\u0B85-\\u0B8A\\u0B8E-\\u0B90\\u0B92-\\u0B95\\u0B99\\u0B9A\\u0B9C\\u0B9E\\u0B9F\\u0BA3\\u0BA4\\u0BA8-\\u0BAA\\u0BAE-\\u0BB9\\u0BBE-\\u0BC2\\u0BC6-\\u0BC8\\u0BCA-\\u0BCD\\u0BD0\\u0BD7\\u0BE6-\\u0BEF\\u0C00-\\u0C03\\u0C05-\\u0C0C\\u0C0E-\\u0C10\\u0C12-\\u0C28\\u0C2A-\\u0C39\\u0C3D-\\u0C44\\u0C46-\\u0C48\\u0C4A-\\u0C4D\\u0C55\\u0C56\\u0C58\\u0C59\\u0C60-\\u0C63\\u0C66-\\u0C6F\\u0C81-\\u0C83\\u0C85-\\u0C8C\\u0C8E-\\u0C90\\u0C92-\\u0CA8\\u0CAA-\\u0CB3\\u0CB5-\\u0CB9\\u0CBC-\\u0CC4\\u0CC6-\\u0CC8\\u0CCA-\\u0CCD\\u0CD5\\u0CD6\\u0CDE\\u0CE0-\\u0CE3\\u0CE6-\\u0CEF\\u0CF1\\u0CF2\\u0D01-\\u0D03\\u0D05-\\u0D0C\\u0D0E-\\u0D10\\u0D12-\\u0D3A\\u0D3D-\\u0D44\\u0D46-\\u0D48\\u0D4A-\\u0D4E\\u0D57\\u0D60-\\u0D63\\u0D66-\\u0D6F\\u0D7A-\\u0D7F\\u0D82\\u0D83\\u0D85-\\u0D96\\u0D9A-\\u0DB1\\u0DB3-\\u0DBB\\u0DBD\\u0DC0-\\u0DC6\\u0DCA\\u0DCF-\\u0DD4\\u0DD6\\u0DD8-\\u0DDF\\u0DE6-\\u0DEF\\u0DF2\\u0DF3\\u0E01-\\u0E3A\\u0E40-\\u0E4E\\u0E50-\\u0E59\\u0E81\\u0E82\\u0E84\\u0E87\\u0E88\\u0E8A\\u0E8D\\u0E94-\\u0E97\\u0E99-\\u0E9F\\u0EA1-\\u0EA3\\u0EA5\\u0EA7\\u0EAA\\u0EAB\\u0EAD-\\u0EB9\\u0EBB-\\u0EBD\\u0EC0-\\u0EC4\\u0EC6\\u0EC8-\\u0ECD\\u0ED0-\\u0ED9\\u0EDC-\\u0EDF\\u0F00\\u0F18\\u0F19\\u0F20-\\u0F29\\u0F35\\u0F37\\u0F39\\u0F3E-\\u0F47\\u0F49-\\u0F6C\\u0F71-\\u0F84\\u0F86-\\u0F97\\u0F99-\\u0FBC\\u0FC6\\u1000-\\u1049\\u1050-\\u109D\\u10A0-\\u10C5\\u10C7\\u10CD\\u10D0-\\u10FA\\u10FC-\\u1248\\u124A-\\u124D\\u1250-\\u1256\\u1258\\u125A-\\u125D\\u1260-\\u1288\\u128A-\\u128D\\u1290-\\u12B0\\u12B2-\\u12B5\\u12B8-\\u12BE\\u12C0\\u12C2-\\u12C5\\u12C8-\\u12D6\\u12D8-\\u1310\\u1312-\\u1315\\u1318-\\u135A\\u135D-\\u135F\\u1380-\\u138F\\u13A0-\\u13F4\\u1401-\\u166C\\u166F-\\u167F\\u1681-\\u169A\\u16A0-\\u16EA\\u16EE-\\u16F8\\u1700-\\u170C\\u170E-\\u1714\\u1720-\\u1734\\u1740-\\u1753\\u1760-\\u176C\\u176E-\\u1770\\u1772\\u1773\\u1780-\\u17D3\\u17D7\\u17DC\\u17DD\\u17E0-\\u17E9\\u180B-\\u180D\\u1810-\\u1819\\u1820-\\u1877\\u1880-\\u18AA\\u18B0-\\u18F5\\u1900-\\u191E\\u1920-\\u192B\\u1930-\\u193B\\u1946-\\u196D\\u1970-\\u1974\\u1980-\\u19AB\\u19B0-\\u19C9\\u19D0-\\u19D9\\u1A00-\\u1A1B\\u1A20-\\u1A5E\\u1A60-\\u1A7C\\u1A7F-\\u1A89\\u1A90-\\u1A99\\u1AA7\\u1AB0-\\u1ABD\\u1B00-\\u1B4B\\u1B50-\\u1B59\\u1B6B-\\u1B73\\u1B80-\\u1BF3\\u1C00-\\u1C37\\u1C40-\\u1C49\\u1C4D-\\u1C7D\\u1CD0-\\u1CD2\\u1CD4-\\u1CF6\\u1CF8\\u1CF9\\u1D00-\\u1DF5\\u1DFC-\\u1F15\\u1F18-\\u1F1D\\u1F20-\\u1F45\\u1F48-\\u1F4D\\u1F50-\\u1F57\\u1F59\\u1F5B\\u1F5D\\u1F5F-\\u1F7D\\u1F80-\\u1FB4\\u1FB6-\\u1FBC\\u1FBE\\u1FC2-\\u1FC4\\u1FC6-\\u1FCC\\u1FD0-\\u1FD3\\u1FD6-\\u1FDB\\u1FE0-\\u1FEC\\u1FF2-\\u1FF4\\u1FF6-\\u1FFC\\u200C\\u200D\\u203F\\u2040\\u2054\\u2071\\u207F\\u2090-\\u209C\\u20D0-\\u20DC\\u20E1\\u20E5-\\u20F0\\u2102\\u2107\\u210A-\\u2113\\u2115\\u2119-\\u211D\\u2124\\u2126\\u2128\\u212A-\\u212D\\u212F-\\u2139\\u213C-\\u213F\\u2145-\\u2149\\u214E\\u2160-\\u2188\\u2C00-\\u2C2E\\u2C30-\\u2C5E\\u2C60-\\u2CE4\\u2CEB-\\u2CF3\\u2D00-\\u2D25\\u2D27\\u2D2D\\u2D30-\\u2D67\\u2D6F\\u2D7F-\\u2D96\\u2DA0-\\u2DA6\\u2DA8-\\u2DAE\\u2DB0-\\u2DB6\\u2DB8-\\u2DBE\\u2DC0-\\u2DC6\\u2DC8-\\u2DCE\\u2DD0-\\u2DD6\\u2DD8-\\u2DDE\\u2DE0-\\u2DFF\\u2E2F\\u3005-\\u3007\\u3021-\\u302F\\u3031-\\u3035\\u3038-\\u303C\\u3041-\\u3096\\u3099\\u309A\\u309D-\\u309F\\u30A1-\\u30FA\\u30FC-\\u30FF\\u3105-\\u312D\\u3131-\\u318E\\u31A0-\\u31BA\\u31F0-\\u31FF\\u3400-\\u4DB5\\u4E00-\\u9FCC\\uA000-\\uA48C\\uA4D0-\\uA4FD\\uA500-\\uA60C\\uA610-\\uA62B\\uA640-\\uA66F\\uA674-\\uA67D\\uA67F-\\uA69D\\uA69F-\\uA6F1\\uA717-\\uA71F\\uA722-\\uA788\\uA78B-\\uA78E\\uA790-\\uA7AD\\uA7B0\\uA7B1\\uA7F7-\\uA827\\uA840-\\uA873\\uA880-\\uA8C4\\uA8D0-\\uA8D9\\uA8E0-\\uA8F7\\uA8FB\\uA900-\\uA92D\\uA930-\\uA953\\uA960-\\uA97C\\uA980-\\uA9C0\\uA9CF-\\uA9D9\\uA9E0-\\uA9FE\\uAA00-\\uAA36\\uAA40-\\uAA4D\\uAA50-\\uAA59\\uAA60-\\uAA76\\uAA7A-\\uAAC2\\uAADB-\\uAADD\\uAAE0-\\uAAEF\\uAAF2-\\uAAF6\\uAB01-\\uAB06\\uAB09-\\uAB0E\\uAB11-\\uAB16\\uAB20-\\uAB26\\uAB28-\\uAB2E\\uAB30-\\uAB5A\\uAB5C-\\uAB5F\\uAB64\\uAB65\\uABC0-\\uABEA\\uABEC\\uABED\\uABF0-\\uABF9\\uAC00-\\uD7A3\\uD7B0-\\uD7C6\\uD7CB-\\uD7FB\\uF900-\\uFA6D\\uFA70-\\uFAD9\\uFB00-\\uFB06\\uFB13-\\uFB17\\uFB1D-\\uFB28\\uFB2A-\\uFB36\\uFB38-\\uFB3C\\uFB3E\\uFB40\\uFB41\\uFB43\\uFB44\\uFB46-\\uFBB1\\uFBD3-\\uFD3D\\uFD50-\\uFD8F\\uFD92-\\uFDC7\\uFDF0-\\uFDFB\\uFE00-\\uFE0F\\uFE20-\\uFE2D\\uFE33\\uFE34\\uFE4D-\\uFE4F\\uFE70-\\uFE74\\uFE76-\\uFEFC\\uFF10-\\uFF19\\uFF21-\\uFF3A\\uFF3F\\uFF41-\\uFF5A\\uFF66-\\uFFBE\\uFFC2-\\uFFC7\\uFFCA-\\uFFCF\\uFFD2-\\uFFD7\\uFFDA-\\uFFDC]");function Ao(t,e){if(!t)throw new Error("ASSERT: "+e)}function dt(t){return t>=48&&t<=57}function Lc(t){return"0123456789abcdefABCDEF".indexOf(t)>=0}function Nr(t){return"01234567".indexOf(t)>=0}function Cx(t){return t===32||t===9||t===11||t===12||t===160||t>=5760&&[5760,6158,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279].indexOf(t)>=0}function oi(t){return t===10||t===13||t===8232||t===8233}function Pi(t){return t===36||t===95||t>=65&&t<=90||t>=97&&t<=122||t===92||t>=128&&vx.test(String.fromCharCode(t))}function Os(t){return t===36||t===95||t>=65&&t<=90||t>=97&&t<=122||t>=48&&t<=57||t===92||t>=128&&Ex.test(String.fromCharCode(t))}const Sx={if:1,in:1,do:1,var:1,for:1,new:1,try:1,let:1,this:1,else:1,case:1,void:1,with:1,enum:1,while:1,break:1,catch:1,throw:1,const:1,yield:1,class:1,super:1,return:1,typeof:1,delete:1,switch:1,export:1,import:1,public:1,static:1,default:1,finally:1,extends:1,package:1,private:1,function:1,continue:1,debugger:1,interface:1,protected:1,instanceof:1,implements:1};function Ah(){for(;y<xe;){const t=D.charCodeAt(y);if(Cx(t)||oi(t))++y;else break}}function Oa(t){var e,n,r,i=0;for(n=t==="u"?4:2,e=0;e<n;++e)y<xe&&Lc(D[y])?(r=D[y++],i=i*16+"0123456789abcdef".indexOf(r.toLowerCase())):O({},ne,ce);return String.fromCharCode(i)}function Fx(){var t,e,n,r;for(t=D[y],e=0,t==="}"&&O({},ne,ce);y<xe&&(t=D[y++],!!Lc(t));)e=e*16+"0123456789abcdef".indexOf(t.toLowerCase());return(e>1114111||t!=="}")&&O({},ne,ce),e<=65535?String.fromCharCode(e):(n=(e-65536>>10)+55296,r=(e-65536&1023)+56320,String.fromCharCode(n,r))}function wh(){var t,e;for(t=D.charCodeAt(y++),e=String.fromCharCode(t),t===92&&(D.charCodeAt(y)!==117&&O({},ne,ce),++y,t=Oa("u"),(!t||t==="\\"||!Pi(t.charCodeAt(0)))&&O({},ne,ce),e=t);y<xe&&(t=D.charCodeAt(y),!!Os(t));)++y,e+=String.fromCharCode(t),t===92&&(e=e.substr(0,e.length-1),D.charCodeAt(y)!==117&&O({},ne,ce),++y,t=Oa("u"),(!t||t==="\\"||!Os(t.charCodeAt(0)))&&O({},ne,ce),e+=t);return e}function Tx(){var t,e;for(t=y++;y<xe;){if(e=D.charCodeAt(y),e===92)return y=t,wh();if(Os(e))++y;else break}return D.slice(t,y)}function Dx(){var t,e,n;return t=y,e=D.charCodeAt(y)===92?wh():Tx(),e.length===1?n=Tn:Sx.hasOwnProperty(e)?n=$t:e==="null"?n=bo:e==="true"||e==="false"?n=yo:n=Tn,{type:n,value:e,start:t,end:y}}function aa(){var t=y,e=D.charCodeAt(y),n,r=D[y],i,s,o;switch(e){case 46:case 40:case 41:case 59:case 44:case 123:case 125:case 91:case 93:case 58:case 63:case 126:return++y,{type:Se,value:String.fromCharCode(e),start:t,end:y};default:if(n=D.charCodeAt(y+1),n===61)switch(e){case 43:case 45:case 47:case 60:case 62:case 94:case 124:case 37:case 38:case 42:return y+=2,{type:Se,value:String.fromCharCode(e)+String.fromCharCode(n),start:t,end:y};case 33:case 61:return y+=2,D.charCodeAt(y)===61&&++y,{type:Se,value:D.slice(t,y),start:t,end:y}}}if(o=D.substr(y,4),o===">>>=")return y+=4,{type:Se,value:o,start:t,end:y};if(s=o.substr(0,3),s===">>>"||s==="<<="||s===">>=")return y+=3,{type:Se,value:s,start:t,end:y};if(i=s.substr(0,2),r===i[1]&&"+-<>&|".indexOf(r)>=0||i==="=>")return y+=2,{type:Se,value:i,start:t,end:y};if(i==="//"&&O({},ne,ce),"<>=!+-*%&|^/".indexOf(r)>=0)return++y,{type:Se,value:r,start:t,end:y};O({},ne,ce)}function Ix(t){let e="";for(;y<xe&&Lc(D[y]);)e+=D[y++];return e.length===0&&O({},ne,ce),Pi(D.charCodeAt(y))&&O({},ne,ce),{type:On,value:parseInt("0x"+e,16),start:t,end:y}}function _x(t){let e="0"+D[y++];for(;y<xe&&Nr(D[y]);)e+=D[y++];return(Pi(D.charCodeAt(y))||dt(D.charCodeAt(y)))&&O({},ne,ce),{type:On,value:parseInt(e,8),octal:!0,start:t,end:y}}function ml(){var t,e,n;if(n=D[y],Ao(dt(n.charCodeAt(0))||n===".","Numeric literal must start with a decimal digit or a decimal point"),e=y,t="",n!=="."){if(t=D[y++],n=D[y],t==="0"){if(n==="x"||n==="X")return++y,Ix(e);if(Nr(n))return _x(e);n&&dt(n.charCodeAt(0))&&O({},ne,ce)}for(;dt(D.charCodeAt(y));)t+=D[y++];n=D[y]}if(n==="."){for(t+=D[y++];dt(D.charCodeAt(y));)t+=D[y++];n=D[y]}if(n==="e"||n==="E")if(t+=D[y++],n=D[y],(n==="+"||n==="-")&&(t+=D[y++]),dt(D.charCodeAt(y)))for(;dt(D.charCodeAt(y));)t+=D[y++];else O({},ne,ce);return Pi(D.charCodeAt(y))&&O({},ne,ce),{type:On,value:parseFloat(t),start:e,end:y}}function Rx(){var t="",e,n,r,i,s=!1;for(e=D[y],Ao(e==="'"||e==='"',"String literal must starts with a quote"),n=y,++y;y<xe;)if(r=D[y++],r===e){e="";break}else if(r==="\\")if(r=D[y++],!r||!oi(r.charCodeAt(0)))switch(r){case"u":case"x":D[y]==="{"?(++y,t+=Fx()):t+=Oa(r);break;case"n":t+=` +`;break;case"r":t+="\r";break;case"t":t+=" ";break;case"b":t+="\b";break;case"f":t+="\f";break;case"v":t+="\v";break;default:Nr(r)?(i="01234567".indexOf(r),i!==0&&(s=!0),y<xe&&Nr(D[y])&&(s=!0,i=i*8+"01234567".indexOf(D[y++]),"0123".indexOf(r)>=0&&y<xe&&Nr(D[y])&&(i=i*8+"01234567".indexOf(D[y++]))),t+=String.fromCharCode(i)):t+=r;break}else r==="\r"&&D[y]===` +`&&++y;else{if(oi(r.charCodeAt(0)))break;t+=r}return e!==""&&O({},ne,ce),{type:Oi,value:t,octal:s,start:n,end:y}}function Mx(t,e){let n=t;e.indexOf("u")>=0&&(n=n.replace(/\\u\{([0-9a-fA-F]+)\}/g,(r,i)=>{if(parseInt(i,16)<=1114111)return"x";O({},ka)}).replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,"x"));try{new RegExp(n)}catch{O({},ka)}try{return new RegExp(t,e)}catch{return null}}function Bx(){var t,e,n,r,i;for(t=D[y],Ao(t==="/","Regular expression literal must start with a slash"),e=D[y++],n=!1,r=!1;y<xe;)if(t=D[y++],e+=t,t==="\\")t=D[y++],oi(t.charCodeAt(0))&&O({},oa),e+=t;else if(oi(t.charCodeAt(0)))O({},oa);else if(n)t==="]"&&(n=!1);else if(t==="/"){r=!0;break}else t==="["&&(n=!0);return r||O({},oa),i=e.substr(1,e.length-2),{value:i,literal:e}}function kx(){var t,e,n;for(e="",n="";y<xe&&(t=D[y],!!Os(t.charCodeAt(0)));)++y,t==="\\"&&y<xe?O({},ne,ce):(n+=t,e+=t);return n.search(/[^gimuy]/g)>=0&&O({},ka,n),{value:n,literal:e}}function Ox(){var t,e,n,r;return z=null,Ah(),t=y,e=Bx(),n=kx(),r=Mx(e.value,n.value),{literal:e.literal+n.literal,value:r,regex:{pattern:e.value,flags:n.value},start:t,end:y}}function Px(t){return t.type===Tn||t.type===$t||t.type===yo||t.type===bo}function vh(){if(Ah(),y>=xe)return{type:ki,start:y,end:y};const t=D.charCodeAt(y);return Pi(t)?Dx():t===40||t===41||t===59?aa():t===39||t===34?Rx():t===46?dt(D.charCodeAt(y+1))?ml():aa():dt(t)?ml():aa()}function Fe(){const t=z;return y=t.end,z=vh(),y=t.end,t}function Eh(){const t=y;z=vh(),y=t}function Lx(t){const e=new Je(ox);return e.elements=t,e}function gl(t,e,n){const r=new Je(t==="||"||t==="&&"?fx:ax);return r.operator=t,r.left=e,r.right=n,r}function Nx(t,e){const n=new Je(cx);return n.callee=t,n.arguments=e,n}function zx(t,e,n){const r=new Je(ux);return r.test=t,r.consequent=e,r.alternate=n,r}function Nc(t){const e=new Je(yh);return e.name=t,e}function Br(t){const e=new Je(lx);return e.value=t.value,e.raw=D.slice(t.start,t.end),t.regex&&(e.raw==="//"&&(e.raw="/(?:)/"),e.regex=t.regex),e}function xl(t,e,n){const r=new Je(hx);return r.computed=t==="[",r.object=e,r.property=n,r.computed||(n.member=!0),r}function Ux(t){const e=new Je(dx);return e.properties=t,e}function yl(t,e,n){const r=new Je(px);return r.key=e,r.value=n,r.kind=t,r}function $x(t,e){const n=new Je(mx);return n.operator=t,n.argument=e,n.prefix=!0,n}function O(t,e){var n,r=Array.prototype.slice.call(arguments,2),i=e.replace(/%(\d)/g,(s,o)=>(Ao(o<r.length,"Message reference must be in range"),r[o]));throw n=new Error(i),n.index=y,n.description=i,n}function wo(t){t.type===ki&&O(t,Ax),t.type===On&&O(t,gx),t.type===Oi&&O(t,xx),t.type===Tn&&O(t,yx),t.type===$t&&O(t,bx),O(t,ne,t.value)}function ye(t){const e=Fe();(e.type!==Se||e.value!==t)&&wo(e)}function G(t){return z.type===Se&&z.value===t}function ca(t){return z.type===$t&&z.value===t}function Vx(){const t=[];for(y=z.start,ye("[");!G("]");)G(",")?(Fe(),t.push(null)):(t.push(Dn()),G("]")||ye(","));return Fe(),Lx(t)}function bl(){y=z.start;const t=Fe();return t.type===Oi||t.type===On?(t.octal&&O(t,bh),Br(t)):Nc(t.value)}function Gx(){var t,e,n,r;if(y=z.start,t=z,t.type===Tn)return n=bl(),ye(":"),r=Dn(),yl("init",n,r);if(t.type===ki||t.type===Se)wo(t);else return e=bl(),ye(":"),r=Dn(),yl("init",e,r)}function Hx(){var t=[],e,n,r,i={},s=String;for(y=z.start,ye("{");!G("}");)e=Gx(),e.key.type===yh?n=e.key.name:n=s(e.key.value),r="$"+n,Object.prototype.hasOwnProperty.call(i,r)?O({},wx):i[r]=!0,t.push(e),G("}")||ye(",");return ye("}"),Ux(t)}function qx(){ye("(");const t=zc();return ye(")"),t}const Wx={if:1};function jx(){var t,e,n;if(G("("))return qx();if(G("["))return Vx();if(G("{"))return Hx();if(t=z.type,y=z.start,t===Tn||Wx[z.value])n=Nc(Fe().value);else if(t===Oi||t===On)z.octal&&O(z,bh),n=Br(Fe());else{if(t===$t)throw new Error(si);t===yo?(e=Fe(),e.value=e.value==="true",n=Br(e)):t===bo?(e=Fe(),e.value=null,n=Br(e)):G("/")||G("/=")?(n=Br(Ox()),Eh()):wo(Fe())}return n}function Yx(){const t=[];if(ye("("),!G(")"))for(;y<xe&&(t.push(Dn()),!G(")"));)ye(",");return ye(")"),t}function Xx(){y=z.start;const t=Fe();return Px(t)||wo(t),Nc(t.value)}function Kx(){return ye("."),Xx()}function Jx(){ye("[");const t=zc();return ye("]"),t}function Zx(){var t,e,n;for(t=jx();;)if(G("."))n=Kx(),t=xl(".",t,n);else if(G("("))e=Yx(),t=Nx(t,e);else if(G("["))n=Jx(),t=xl("[",t,n);else break;return t}function Al(){const t=Zx();if(z.type===Se&&(G("++")||G("--")))throw new Error(si);return t}function ys(){var t,e;if(z.type!==Se&&z.type!==$t)e=Al();else{if(G("++")||G("--"))throw new Error(si);if(G("+")||G("-")||G("~")||G("!"))t=Fe(),e=ys(),e=$x(t.value,e);else{if(ca("delete")||ca("void")||ca("typeof"))throw new Error(si);e=Al()}}return e}function wl(t){let e=0;if(t.type!==Se&&t.type!==$t)return 0;switch(t.value){case"||":e=1;break;case"&&":e=2;break;case"|":e=3;break;case"^":e=4;break;case"&":e=5;break;case"==":case"!=":case"===":case"!==":e=6;break;case"<":case">":case"<=":case">=":case"instanceof":case"in":e=7;break;case"<<":case">>":case">>>":e=8;break;case"+":case"-":e=9;break;case"*":case"/":case"%":e=11;break}return e}function Qx(){var t,e,n,r,i,s,o,a,c,u;if(t=z,c=ys(),r=z,i=wl(r),i===0)return c;for(r.prec=i,Fe(),e=[t,z],o=ys(),s=[c,r,o];(i=wl(z))>0;){for(;s.length>2&&i<=s[s.length-2].prec;)o=s.pop(),a=s.pop().value,c=s.pop(),e.pop(),n=gl(a,c,o),s.push(n);r=Fe(),r.prec=i,s.push(r),e.push(z),n=ys(),s.push(n)}for(u=s.length-1,n=s[u],e.pop();u>1;)e.pop(),n=gl(s[u-1].value,s[u-2],n),u-=2;return n}function Dn(){var t,e,n;return t=Qx(),G("?")&&(Fe(),e=Dn(),ye(":"),n=Dn(),t=zx(t,e,n)),t}function zc(){const t=Dn();if(G(","))throw new Error(si);return t}function ey(t){D=t,y=0,xe=D.length,z=null,Eh();const e=zc();if(z.type!==ki)throw new Error("Unexpect token after expression.");return e}var ty={NaN:"NaN",E:"Math.E",LN2:"Math.LN2",LN10:"Math.LN10",LOG2E:"Math.LOG2E",LOG10E:"Math.LOG10E",PI:"Math.PI",SQRT1_2:"Math.SQRT1_2",SQRT2:"Math.SQRT2",MIN_VALUE:"Number.MIN_VALUE",MAX_VALUE:"Number.MAX_VALUE"};function Ch(t){function e(o,a,c,u){let f=t(a[0]);return c&&(f=c+"("+f+")",c.lastIndexOf("new ",0)===0&&(f="("+f+")")),f+"."+o+(u<0?"":u===0?"()":"("+a.slice(1).map(t).join(",")+")")}function n(o,a,c){return u=>e(o,u,a,c)}const r="new Date",i="String",s="RegExp";return{isNaN:"Number.isNaN",isFinite:"Number.isFinite",abs:"Math.abs",acos:"Math.acos",asin:"Math.asin",atan:"Math.atan",atan2:"Math.atan2",ceil:"Math.ceil",cos:"Math.cos",exp:"Math.exp",floor:"Math.floor",hypot:"Math.hypot",log:"Math.log",max:"Math.max",min:"Math.min",pow:"Math.pow",random:"Math.random",round:"Math.round",sin:"Math.sin",sqrt:"Math.sqrt",tan:"Math.tan",clamp:function(o){o.length<3&&W("Missing arguments to clamp function."),o.length>3&&W("Too many arguments to clamp function.");const a=o.map(t);return"Math.max("+a[1]+", Math.min("+a[2]+","+a[0]+"))"},now:"Date.now",utc:"Date.UTC",datetime:r,date:n("getDate",r,0),day:n("getDay",r,0),year:n("getFullYear",r,0),month:n("getMonth",r,0),hours:n("getHours",r,0),minutes:n("getMinutes",r,0),seconds:n("getSeconds",r,0),milliseconds:n("getMilliseconds",r,0),time:n("getTime",r,0),timezoneoffset:n("getTimezoneOffset",r,0),utcdate:n("getUTCDate",r,0),utcday:n("getUTCDay",r,0),utcyear:n("getUTCFullYear",r,0),utcmonth:n("getUTCMonth",r,0),utchours:n("getUTCHours",r,0),utcminutes:n("getUTCMinutes",r,0),utcseconds:n("getUTCSeconds",r,0),utcmilliseconds:n("getUTCMilliseconds",r,0),length:n("length",null,-1),parseFloat:"parseFloat",parseInt:"parseInt",upper:n("toUpperCase",i,0),lower:n("toLowerCase",i,0),substring:n("substring",i),split:n("split",i),trim:n("trim",i,0),regexp:s,test:n("test",s),if:function(o){o.length<3&&W("Missing arguments to if function."),o.length>3&&W("Too many arguments to if function.");const a=o.map(t);return"("+a[0]+"?"+a[1]+":"+a[2]+")"}}}function ny(t){const e=t&&t.length-1;return e&&(t[0]==='"'&&t[e]==='"'||t[0]==="'"&&t[e]==="'")?t.slice(1,-1):t}function ry(t){t=t||{};const e=t.allowed?Ds(t.allowed):{},n=t.forbidden?Ds(t.forbidden):{},r=t.constants||ty,i=(t.functions||Ch)(l),s=t.globalvar,o=t.fieldvar,a=Ie(s)?s:d=>`${s}["${d}"]`;let c={},u={},f=0;function l(d){if(V(d))return d;const m=h[d.type];return m==null&&W("Unsupported type: "+d.type),m(d)}const h={Literal:d=>d.raw,Identifier:d=>{const m=d.name;return f>0?m:qn(n,m)?W("Illegal identifier: "+m):qn(r,m)?r[m]:qn(e,m)?m:(c[m]=1,a(m))},MemberExpression:d=>{const m=!d.computed,g=l(d.object);m&&(f+=1);const x=l(d.property);return g===o&&(u[ny(x)]=1),m&&(f-=1),g+(m?"."+x:"["+x+"]")},CallExpression:d=>{d.callee.type!=="Identifier"&&W("Illegal callee type: "+d.callee.type);const m=d.callee.name,g=d.arguments,x=qn(i,m)&&i[m];return x||W("Unrecognized function: "+m),Ie(x)?x(g):x+"("+g.map(l).join(",")+")"},ArrayExpression:d=>"["+d.elements.map(l).join(",")+"]",BinaryExpression:d=>"("+l(d.left)+" "+d.operator+" "+l(d.right)+")",UnaryExpression:d=>"("+d.operator+l(d.argument)+")",ConditionalExpression:d=>"("+l(d.test)+"?"+l(d.consequent)+":"+l(d.alternate)+")",LogicalExpression:d=>"("+l(d.left)+d.operator+l(d.right)+")",ObjectExpression:d=>"{"+d.properties.map(l).join(",")+"}",Property:d=>{f+=1;const m=l(d.key);return f-=1,m+":"+l(d.value)}};function p(d){const m={code:l(d),globals:Object.keys(c),fields:Object.keys(u)};return c={},u={},m}return p.functions=i,p.constants=r,p}function Sh(t,e,n){return n=(n-t)/(e-t),n=Math.max(0,Math.min(1,n)),n*n*(3-2*n)}function ai(t,e=0,n=1){return Math.max(e,Math.min(n,t))}function iy(t,e,n){return ai((n-t)/(e-t),0,1)}const Fh={clamp:ai,isArray:Me,isBoolean:_i,isDefined(t){return t!==void 0},isNumber:be,isObject:Re,isRegExp:gm,isString:V,isValid(t){return t!=null&&t===t},lerp:jf,linearstep:iy,smoothstep:Sh};function sy(t){const e=Ch(t);for(const n in Fh)e[n]=`this.${n}`;return e}const oy=ry({forbidden:[],allowed:["datum"],globalvar:"globalObject",fieldvar:"datum",functions:sy});function vo(t,e={}){try{const n=ey(t),r=oy(n),i=Function("datum","globalObject",`"use strict"; return (${r.code});`).bind(Fh),s=o=>i(o,e);return s.fields=r.fields,s.globals=r.globals,s.code=r.code,s}catch(n){throw new Error(`Invalid expression: ${t}, ${n.message}`)}}function ct(t,e){switch(arguments.length){case 0:break;case 1:this.range(t);break;default:this.range(e).domain(t);break}return this}function Vt(t,e){switch(arguments.length){case 0:break;case 1:{typeof t=="function"?this.interpolator(t):this.range(t);break}default:{this.domain(t),typeof e=="function"?this.interpolator(e):this.range(e);break}}return this}const Pa=Symbol("implicit");function Uc(){var t=new Sn,e=[],n=[],r=Pa;function i(s){let o=t.get(s);if(o===void 0){if(r!==Pa)return r;t.set(s,o=e.push(s)-1)}return n[o%n.length]}return i.domain=function(s){if(!arguments.length)return e.slice();e=[],t=new Sn;for(const o of s)t.has(o)||t.set(o,e.push(o)-1);return i},i.range=function(s){return arguments.length?(n=Array.from(s),i):n.slice()},i.unknown=function(s){return arguments.length?(r=s,i):r},i.copy=function(){return Uc(e,n).unknown(r)},ct.apply(i,arguments),i}function xr(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function Li(t,e){var n=Object.create(t.prototype);for(var r in e)n[r]=e[r];return n}function Gt(){}var In=.7,lr=1/In,jn="\\s*([+-]?\\d+)\\s*",ci="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",tt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",ay=/^#([0-9a-f]{3,8})$/,cy=new RegExp(`^rgb\\(${jn},${jn},${jn}\\)$`),uy=new RegExp(`^rgb\\(${tt},${tt},${tt}\\)$`),ly=new RegExp(`^rgba\\(${jn},${jn},${jn},${ci}\\)$`),fy=new RegExp(`^rgba\\(${tt},${tt},${tt},${ci}\\)$`),hy=new RegExp(`^hsl\\(${ci},${tt},${tt}\\)$`),dy=new RegExp(`^hsla\\(${ci},${tt},${tt},${ci}\\)$`),vl={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};xr(Gt,Bt,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:El,formatHex:El,formatHex8:py,formatHsl:my,formatRgb:Cl,toString:Cl});function El(){return this.rgb().formatHex()}function py(){return this.rgb().formatHex8()}function my(){return Th(this).formatHsl()}function Cl(){return this.rgb().formatRgb()}function Bt(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=ay.exec(t))?(n=e[1].length,e=parseInt(e[1],16),n===6?Sl(e):n===3?new re(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):n===8?us(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):n===4?us(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|e&240,((e&15)<<4|e&15)/255):null):(e=cy.exec(t))?new re(e[1],e[2],e[3],1):(e=uy.exec(t))?new re(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=ly.exec(t))?us(e[1],e[2],e[3],e[4]):(e=fy.exec(t))?us(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=hy.exec(t))?Dl(e[1],e[2]/100,e[3]/100,1):(e=dy.exec(t))?Dl(e[1],e[2]/100,e[3]/100,e[4]):vl.hasOwnProperty(t)?Sl(vl[t]):t==="transparent"?new re(NaN,NaN,NaN,0):null}function Sl(t){return new re(t>>16&255,t>>8&255,t&255,1)}function us(t,e,n,r){return r<=0&&(t=e=n=NaN),new re(t,e,n,r)}function $c(t){return t instanceof Gt||(t=Bt(t)),t?(t=t.rgb(),new re(t.r,t.g,t.b,t.opacity)):new re}function Ps(t,e,n,r){return arguments.length===1?$c(t):new re(t,e,n,r??1)}function re(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}xr(re,Ps,Li(Gt,{brighter(t){return t=t==null?lr:Math.pow(lr,t),new re(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?In:Math.pow(In,t),new re(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new re(yn(this.r),yn(this.g),yn(this.b),Ls(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:Fl,formatHex:Fl,formatHex8:gy,formatRgb:Tl,toString:Tl}));function Fl(){return`#${an(this.r)}${an(this.g)}${an(this.b)}`}function gy(){return`#${an(this.r)}${an(this.g)}${an(this.b)}${an((isNaN(this.opacity)?1:this.opacity)*255)}`}function Tl(){const t=Ls(this.opacity);return`${t===1?"rgb(":"rgba("}${yn(this.r)}, ${yn(this.g)}, ${yn(this.b)}${t===1?")":`, ${t})`}`}function Ls(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function yn(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function an(t){return t=yn(t),(t<16?"0":"")+t.toString(16)}function Dl(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new je(t,e,n,r)}function Th(t){if(t instanceof je)return new je(t.h,t.s,t.l,t.opacity);if(t instanceof Gt||(t=Bt(t)),!t)return new je;if(t instanceof je)return t;t=t.rgb();var e=t.r/255,n=t.g/255,r=t.b/255,i=Math.min(e,n,r),s=Math.max(e,n,r),o=NaN,a=s-i,c=(s+i)/2;return a?(e===s?o=(n-r)/a+(n<r)*6:n===s?o=(r-e)/a+2:o=(e-n)/a+4,a/=c<.5?s+i:2-s-i,o*=60):a=c>0&&c<1?0:o,new je(o,a,c,t.opacity)}function La(t,e,n,r){return arguments.length===1?Th(t):new je(t,e,n,r??1)}function je(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}xr(je,La,Li(Gt,{brighter(t){return t=t==null?lr:Math.pow(lr,t),new je(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?In:Math.pow(In,t),new je(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+(this.h<0)*360,e=isNaN(t)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*e,i=2*n-r;return new re(ua(t>=240?t-240:t+120,i,r),ua(t,i,r),ua(t<120?t+240:t-120,i,r),this.opacity)},clamp(){return new je(Il(this.h),ls(this.s),ls(this.l),Ls(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const t=Ls(this.opacity);return`${t===1?"hsl(":"hsla("}${Il(this.h)}, ${ls(this.s)*100}%, ${ls(this.l)*100}%${t===1?")":`, ${t})`}`}}));function Il(t){return t=(t||0)%360,t<0?t+360:t}function ls(t){return Math.max(0,Math.min(1,t||0))}function ua(t,e,n){return(t<60?e+(n-e)*t/60:t<180?n:t<240?e+(n-e)*(240-t)/60:e)*255}const Dh=Math.PI/180,Ih=180/Math.PI,Ns=18,_h=.96422,Rh=1,Mh=.82521,Bh=4/29,Yn=6/29,kh=3*Yn*Yn,xy=Yn*Yn*Yn;function Oh(t){if(t instanceof nt)return new nt(t.l,t.a,t.b,t.opacity);if(t instanceof wt)return Ph(t);t instanceof re||(t=$c(t));var e=da(t.r),n=da(t.g),r=da(t.b),i=la((.2225045*e+.7168786*n+.0606169*r)/Rh),s,o;return e===n&&n===r?s=o=i:(s=la((.4360747*e+.3850649*n+.1430804*r)/_h),o=la((.0139322*e+.0971045*n+.7141733*r)/Mh)),new nt(116*i-16,500*(s-i),200*(i-o),t.opacity)}function Na(t,e,n,r){return arguments.length===1?Oh(t):new nt(t,e,n,r??1)}function nt(t,e,n,r){this.l=+t,this.a=+e,this.b=+n,this.opacity=+r}xr(nt,Na,Li(Gt,{brighter(t){return new nt(this.l+Ns*(t??1),this.a,this.b,this.opacity)},darker(t){return new nt(this.l-Ns*(t??1),this.a,this.b,this.opacity)},rgb(){var t=(this.l+16)/116,e=isNaN(this.a)?t:t+this.a/500,n=isNaN(this.b)?t:t-this.b/200;return e=_h*fa(e),t=Rh*fa(t),n=Mh*fa(n),new re(ha(3.1338561*e-1.6168667*t-.4906146*n),ha(-.9787684*e+1.9161415*t+.033454*n),ha(.0719453*e-.2289914*t+1.4052427*n),this.opacity)}}));function la(t){return t>xy?Math.pow(t,1/3):t/kh+Bh}function fa(t){return t>Yn?t*t*t:kh*(t-Bh)}function ha(t){return 255*(t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055)}function da(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function yy(t){if(t instanceof wt)return new wt(t.h,t.c,t.l,t.opacity);if(t instanceof nt||(t=Oh(t)),t.a===0&&t.b===0)return new wt(NaN,0<t.l&&t.l<100?0:NaN,t.l,t.opacity);var e=Math.atan2(t.b,t.a)*Ih;return new wt(e<0?e+360:e,Math.sqrt(t.a*t.a+t.b*t.b),t.l,t.opacity)}function za(t,e,n,r){return arguments.length===1?yy(t):new wt(t,e,n,r??1)}function wt(t,e,n,r){this.h=+t,this.c=+e,this.l=+n,this.opacity=+r}function Ph(t){if(isNaN(t.h))return new nt(t.l,0,0,t.opacity);var e=t.h*Dh;return new nt(t.l,Math.cos(e)*t.c,Math.sin(e)*t.c,t.opacity)}xr(wt,za,Li(Gt,{brighter(t){return new wt(this.h,this.c,this.l+Ns*(t??1),this.opacity)},darker(t){return new wt(this.h,this.c,this.l-Ns*(t??1),this.opacity)},rgb(){return Ph(this).rgb()}}));var Lh=-.14861,Vc=1.78277,Gc=-.29227,Eo=-.90649,ui=1.97294,_l=ui*Eo,Rl=ui*Vc,Ml=Vc*Gc-Eo*Lh;function by(t){if(t instanceof bn)return new bn(t.h,t.s,t.l,t.opacity);t instanceof re||(t=$c(t));var e=t.r/255,n=t.g/255,r=t.b/255,i=(Ml*r+_l*e-Rl*n)/(Ml+_l-Rl),s=r-i,o=(ui*(n-i)-Gc*s)/Eo,a=Math.sqrt(o*o+s*s)/(ui*i*(1-i)),c=a?Math.atan2(o,s)*Ih-120:NaN;return new bn(c<0?c+360:c,a,i,t.opacity)}function Ua(t,e,n,r){return arguments.length===1?by(t):new bn(t,e,n,r??1)}function bn(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}xr(bn,Ua,Li(Gt,{brighter(t){return t=t==null?lr:Math.pow(lr,t),new bn(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?In:Math.pow(In,t),new bn(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=isNaN(this.h)?0:(this.h+120)*Dh,e=+this.l,n=isNaN(this.s)?0:this.s*e*(1-e),r=Math.cos(t),i=Math.sin(t);return new re(255*(e+n*(Lh*r+Vc*i)),255*(e+n*(Gc*r+Eo*i)),255*(e+n*(ui*r)),this.opacity)}}));function Nh(t,e,n,r,i){var s=t*t,o=s*t;return((1-3*t+3*s-o)*e+(4-6*s+3*o)*n+(1+3*t+3*s-3*o)*r+o*i)/6}function zh(t){var e=t.length-1;return function(n){var r=n<=0?n=0:n>=1?(n=1,e-1):Math.floor(n*e),i=t[r],s=t[r+1],o=r>0?t[r-1]:2*i-s,a=r<e-1?t[r+2]:2*s-i;return Nh((n-r/e)*e,o,i,s,a)}}function Uh(t){var e=t.length;return function(n){var r=Math.floor(((n%=1)<0?++n:n)*e),i=t[(r+e-1)%e],s=t[r%e],o=t[(r+1)%e],a=t[(r+2)%e];return Nh((n-r/e)*e,i,s,o,a)}}const Co=t=>()=>t;function $h(t,e){return function(n){return t+n*e}}function Ay(t,e,n){return t=Math.pow(t,n),e=Math.pow(e,n)-t,n=1/n,function(r){return Math.pow(t+r*e,n)}}function So(t,e){var n=e-t;return n?$h(t,n>180||n<-180?n-360*Math.round(n/360):n):Co(isNaN(t)?e:t)}function wy(t){return(t=+t)==1?ie:function(e,n){return n-e?Ay(e,n,t):Co(isNaN(e)?n:e)}}function ie(t,e){var n=e-t;return n?$h(t,n):Co(isNaN(t)?e:t)}const $a=function t(e){var n=wy(e);function r(i,s){var o=n((i=Ps(i)).r,(s=Ps(s)).r),a=n(i.g,s.g),c=n(i.b,s.b),u=ie(i.opacity,s.opacity);return function(f){return i.r=o(f),i.g=a(f),i.b=c(f),i.opacity=u(f),i+""}}return r.gamma=t,r}(1);function Vh(t){return function(e){var n=e.length,r=new Array(n),i=new Array(n),s=new Array(n),o,a;for(o=0;o<n;++o)a=Ps(e[o]),r[o]=a.r||0,i[o]=a.g||0,s[o]=a.b||0;return r=t(r),i=t(i),s=t(s),a.opacity=1,function(c){return a.r=r(c),a.g=i(c),a.b=s(c),a+""}}}var vy=Vh(zh),Ey=Vh(Uh);function Hc(t,e){e||(e=[]);var n=t?Math.min(e.length,t.length):0,r=e.slice(),i;return function(s){for(i=0;i<n;++i)r[i]=t[i]*(1-s)+e[i]*s;return r}}function Gh(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function Cy(t,e){return(Gh(e)?Hc:Hh)(t,e)}function Hh(t,e){var n=e?e.length:0,r=t?Math.min(n,t.length):0,i=new Array(r),s=new Array(n),o;for(o=0;o<r;++o)i[o]=Ht(t[o],e[o]);for(;o<n;++o)s[o]=e[o];return function(a){for(o=0;o<r;++o)s[o]=i[o](a);return s}}function qh(t,e){var n=new Date;return t=+t,e=+e,function(r){return n.setTime(t*(1-r)+e*r),n}}function We(t,e){return t=+t,e=+e,function(n){return t*(1-n)+e*n}}function Wh(t,e){var n={},r={},i;(t===null||typeof t!="object")&&(t={}),(e===null||typeof e!="object")&&(e={});for(i in e)i in t?n[i]=Ht(t[i],e[i]):r[i]=e[i];return function(s){for(i in n)r[i]=n[i](s);return r}}var Va=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,pa=new RegExp(Va.source,"g");function Sy(t){return function(){return t}}function Fy(t){return function(e){return t(e)+""}}function jh(t,e){var n=Va.lastIndex=pa.lastIndex=0,r,i,s,o=-1,a=[],c=[];for(t=t+"",e=e+"";(r=Va.exec(t))&&(i=pa.exec(e));)(s=i.index)>n&&(s=e.slice(n,s),a[o]?a[o]+=s:a[++o]=s),(r=r[0])===(i=i[0])?a[o]?a[o]+=i:a[++o]=i:(a[++o]=null,c.push({i:o,x:We(r,i)})),n=pa.lastIndex;return n<e.length&&(s=e.slice(n),a[o]?a[o]+=s:a[++o]=s),a.length<2?c[0]?Fy(c[0].x):Sy(e):(e=c.length,function(u){for(var f=0,l;f<e;++f)a[(l=c[f]).i]=l.x(u);return a.join("")})}function Ht(t,e){var n=typeof e,r;return e==null||n==="boolean"?Co(e):(n==="number"?We:n==="string"?(r=Bt(e))?(e=r,$a):jh:e instanceof Bt?$a:e instanceof Date?qh:Gh(e)?Hc:Array.isArray(e)?Hh:typeof e.valueOf!="function"&&typeof e.toString!="function"||isNaN(e)?Wh:We)(t,e)}function Ty(t){var e=t.length;return function(n){return t[Math.max(0,Math.min(e-1,Math.floor(n*e)))]}}function Dy(t,e){var n=So(+t,+e);return function(r){var i=n(r);return i-360*Math.floor(i/360)}}function Ni(t,e){return t=+t,e=+e,function(n){return Math.round(t*(1-n)+e*n)}}var Bl=180/Math.PI,Ga={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Yh(t,e,n,r,i,s){var o,a,c;return(o=Math.sqrt(t*t+e*e))&&(t/=o,e/=o),(c=t*n+e*r)&&(n-=t*c,r-=e*c),(a=Math.sqrt(n*n+r*r))&&(n/=a,r/=a,c/=a),t*r<e*n&&(t=-t,e=-e,c=-c,o=-o),{translateX:i,translateY:s,rotate:Math.atan2(e,t)*Bl,skewX:Math.atan(c)*Bl,scaleX:o,scaleY:a}}var fs;function Iy(t){const e=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(t+"");return e.isIdentity?Ga:Yh(e.a,e.b,e.c,e.d,e.e,e.f)}function _y(t){return t==null||(fs||(fs=document.createElementNS("http://www.w3.org/2000/svg","g")),fs.setAttribute("transform",t),!(t=fs.transform.baseVal.consolidate()))?Ga:(t=t.matrix,Yh(t.a,t.b,t.c,t.d,t.e,t.f))}function Xh(t,e,n,r){function i(u){return u.length?u.pop()+" ":""}function s(u,f,l,h,p,d){if(u!==l||f!==h){var m=p.push("translate(",null,e,null,n);d.push({i:m-4,x:We(u,l)},{i:m-2,x:We(f,h)})}else(l||h)&&p.push("translate("+l+e+h+n)}function o(u,f,l,h){u!==f?(u-f>180?f+=360:f-u>180&&(u+=360),h.push({i:l.push(i(l)+"rotate(",null,r)-2,x:We(u,f)})):f&&l.push(i(l)+"rotate("+f+r)}function a(u,f,l,h){u!==f?h.push({i:l.push(i(l)+"skewX(",null,r)-2,x:We(u,f)}):f&&l.push(i(l)+"skewX("+f+r)}function c(u,f,l,h,p,d){if(u!==l||f!==h){var m=p.push(i(p)+"scale(",null,",",null,")");d.push({i:m-4,x:We(u,l)},{i:m-2,x:We(f,h)})}else(l!==1||h!==1)&&p.push(i(p)+"scale("+l+","+h+")")}return function(u,f){var l=[],h=[];return u=t(u),f=t(f),s(u.translateX,u.translateY,f.translateX,f.translateY,l,h),o(u.rotate,f.rotate,l,h),a(u.skewX,f.skewX,l,h),c(u.scaleX,u.scaleY,f.scaleX,f.scaleY,l,h),u=f=null,function(p){for(var d=-1,m=h.length,g;++d<m;)l[(g=h[d]).i]=g.x(p);return l.join("")}}}var Ry=Xh(Iy,"px, ","px)","deg)"),My=Xh(_y,", ",")",")"),By=1e-12;function kl(t){return((t=Math.exp(t))+1/t)/2}function ky(t){return((t=Math.exp(t))-1/t)/2}function Oy(t){return((t=Math.exp(2*t))-1)/(t+1)}const Py=function t(e,n,r){function i(s,o){var a=s[0],c=s[1],u=s[2],f=o[0],l=o[1],h=o[2],p=f-a,d=l-c,m=p*p+d*d,g,x;if(m<By)x=Math.log(h/u)/e,g=function(w){return[a+w*p,c+w*d,u*Math.exp(e*w*x)]};else{var b=Math.sqrt(m),A=(h*h-u*u+r*m)/(2*u*n*b),E=(h*h-u*u-r*m)/(2*h*n*b),F=Math.log(Math.sqrt(A*A+1)-A),C=Math.log(Math.sqrt(E*E+1)-E);x=(C-F)/e,g=function(w){var L=w*x,Y=kl(F),j=u/(n*b)*(Y*Oy(e*L+F)-ky(F));return[a+j*p,c+j*d,u*Y/kl(e*L+F)]}}return g.duration=x*1e3*e/Math.SQRT2,g}return i.rho=function(s){var o=Math.max(.001,+s),a=o*o,c=a*a;return t(o,a,c)},i}(Math.SQRT2,2,4);function Kh(t){return function(e,n){var r=t((e=La(e)).h,(n=La(n)).h),i=ie(e.s,n.s),s=ie(e.l,n.l),o=ie(e.opacity,n.opacity);return function(a){return e.h=r(a),e.s=i(a),e.l=s(a),e.opacity=o(a),e+""}}}const Ly=Kh(So);var Ny=Kh(ie);function zy(t,e){var n=ie((t=Na(t)).l,(e=Na(e)).l),r=ie(t.a,e.a),i=ie(t.b,e.b),s=ie(t.opacity,e.opacity);return function(o){return t.l=n(o),t.a=r(o),t.b=i(o),t.opacity=s(o),t+""}}function Jh(t){return function(e,n){var r=t((e=za(e)).h,(n=za(n)).h),i=ie(e.c,n.c),s=ie(e.l,n.l),o=ie(e.opacity,n.opacity);return function(a){return e.h=r(a),e.c=i(a),e.l=s(a),e.opacity=o(a),e+""}}}const Uy=Jh(So);var $y=Jh(ie);function Zh(t){return function e(n){n=+n;function r(i,s){var o=t((i=Ua(i)).h,(s=Ua(s)).h),a=ie(i.s,s.s),c=ie(i.l,s.l),u=ie(i.opacity,s.opacity);return function(f){return i.h=o(f),i.s=a(f),i.l=c(Math.pow(f,n)),i.opacity=u(f),i+""}}return r.gamma=e,r}(1)}const Vy=Zh(So);var Gy=Zh(ie);function qc(t,e){e===void 0&&(e=t,t=Ht);for(var n=0,r=e.length-1,i=e[0],s=new Array(r<0?0:r);n<r;)s[n]=t(i,i=e[++n]);return function(o){var a=Math.max(0,Math.min(r-1,Math.floor(o*=r)));return s[a](o-a)}}function Hy(t,e){for(var n=new Array(e),r=0;r<e;++r)n[r]=t(r/(e-1));return n}const qy=Object.freeze(Object.defineProperty({__proto__:null,interpolate:Ht,interpolateArray:Cy,interpolateBasis:zh,interpolateBasisClosed:Uh,interpolateCubehelix:Vy,interpolateCubehelixLong:Gy,interpolateDate:qh,interpolateDiscrete:Ty,interpolateHcl:Uy,interpolateHclLong:$y,interpolateHsl:Ly,interpolateHslLong:Ny,interpolateHue:Dy,interpolateLab:zy,interpolateNumber:We,interpolateNumberArray:Hc,interpolateObject:Wh,interpolateRgb:$a,interpolateRgbBasis:vy,interpolateRgbBasisClosed:Ey,interpolateRound:Ni,interpolateString:jh,interpolateTransformCss:Ry,interpolateTransformSvg:My,interpolateZoom:Py,piecewise:qc,quantize:Hy},Symbol.toStringTag,{value:"Module"}));function Wy(t){return function(){return t}}function Ha(t){return+t}var Ol=[0,1];function Te(t){return t}function qa(t,e){return(e-=t=+t)?function(n){return(n-t)/e}:Wy(isNaN(e)?NaN:.5)}function jy(t,e){var n;return t>e&&(n=t,t=e,e=n),function(r){return Math.max(t,Math.min(e,r))}}function Yy(t,e,n){var r=t[0],i=t[1],s=e[0],o=e[1];return i<r?(r=qa(i,r),s=n(o,s)):(r=qa(r,i),s=n(s,o)),function(a){return s(r(a))}}function Xy(t,e,n){var r=Math.min(t.length,e.length)-1,i=new Array(r),s=new Array(r),o=-1;for(t[r]<t[0]&&(t=t.slice().reverse(),e=e.slice().reverse());++o<r;)i[o]=qa(t[o],t[o+1]),s[o]=n(e[o],e[o+1]);return function(a){var c=gr(t,a,1,r)-1;return s[c](i[c](a))}}function zi(t,e){return e.domain(t.domain()).range(t.range()).interpolate(t.interpolate()).clamp(t.clamp()).unknown(t.unknown())}function Fo(){var t=Ol,e=Ol,n=Ht,r,i,s,o=Te,a,c,u;function f(){var h=Math.min(t.length,e.length);return o!==Te&&(o=jy(t[0],t[h-1])),a=h>2?Xy:Yy,c=u=null,l}function l(h){return h==null||isNaN(h=+h)?s:(c||(c=a(t.map(r),e,n)))(r(o(h)))}return l.invert=function(h){return o(i((u||(u=a(e,t.map(r),We)))(h)))},l.domain=function(h){return arguments.length?(t=Array.from(h,Ha),f()):t.slice()},l.range=function(h){return arguments.length?(e=Array.from(h),f()):e.slice()},l.rangeRound=function(h){return e=Array.from(h),n=Ni,f()},l.clamp=function(h){return arguments.length?(o=h?!0:Te,f()):o!==Te},l.interpolate=function(h){return arguments.length?(n=h,f()):n},l.unknown=function(h){return arguments.length?(s=h,l):s},function(h,p){return r=h,i=p,f()}}function Qh(){return Fo()(Te,Te)}function e0(t,e,n,r){var i=Fn(t,e,n),s;switch(r=Mt(r??",f"),r.type){case"s":{var o=Math.max(Math.abs(t),Math.abs(e));return r.precision==null&&!isNaN(s=nh(i,o))&&(r.precision=s),_c(r,o)}case"":case"e":case"g":case"p":case"r":{r.precision==null&&!isNaN(s=rh(i,Math.max(Math.abs(t),Math.abs(e))))&&(r.precision=s-(r.type==="e"));break}case"f":case"%":{r.precision==null&&!isNaN(s=th(i))&&(r.precision=s-(r.type==="%")*2);break}}return ue(r)}function Pn(t){var e=t.domain;return t.ticks=function(n){var r=e();return _s(r[0],r[r.length-1],n??10)},t.tickFormat=function(n,r){var i=e();return e0(i[0],i[i.length-1],n??10,r)},t.nice=function(n){n==null&&(n=10);var r=e(),i=0,s=r.length-1,o=r[i],a=r[s],c,u,f=10;for(a<o&&(u=o,o=a,a=u,u=i,i=s,s=u);f-- >0;){if(u=Ma(o,a,n),u===c)return r[i]=o,r[s]=a,e(r);if(u>0)o=Math.floor(o/u)*u,a=Math.ceil(a/u)*u;else if(u<0)o=Math.ceil(o*u)/u,a=Math.floor(a*u)/u;else break;c=u}return t},t}function t0(){var t=Qh();return t.copy=function(){return zi(t,t0())},ct.apply(t,arguments),Pn(t)}function n0(t){var e;function n(r){return r==null||isNaN(r=+r)?e:r}return n.invert=n,n.domain=n.range=function(r){return arguments.length?(t=Array.from(r,Ha),n):t.slice()},n.unknown=function(r){return arguments.length?(e=r,n):e},n.copy=function(){return n0(t).unknown(e)},t=arguments.length?Array.from(t,Ha):[0,1],Pn(n)}function r0(t,e){t=t.slice();var n=0,r=t.length-1,i=t[n],s=t[r],o;return s<i&&(o=n,n=r,r=o,o=i,i=s,s=o),t[n]=e.floor(i),t[r]=e.ceil(s),t}function Pl(t){return Math.log(t)}function Ll(t){return Math.exp(t)}function Ky(t){return-Math.log(-t)}function Jy(t){return-Math.exp(-t)}function Zy(t){return isFinite(t)?+("1e"+t):t<0?0:t}function Qy(t){return t===10?Zy:t===Math.E?Math.exp:e=>Math.pow(t,e)}function eb(t){return t===Math.E?Math.log:t===10&&Math.log10||t===2&&Math.log2||(t=Math.log(t),e=>Math.log(e)/t)}function Nl(t){return(e,n)=>-t(-e,n)}function Wc(t){const e=t(Pl,Ll),n=e.domain;let r=10,i,s;function o(){return i=eb(r),s=Qy(r),n()[0]<0?(i=Nl(i),s=Nl(s),t(Ky,Jy)):t(Pl,Ll),e}return e.base=function(a){return arguments.length?(r=+a,o()):r},e.domain=function(a){return arguments.length?(n(a),o()):n()},e.ticks=a=>{const c=n();let u=c[0],f=c[c.length-1];const l=f<u;l&&([u,f]=[f,u]);let h=i(u),p=i(f),d,m;const g=a==null?10:+a;let x=[];if(!(r%1)&&p-h<g){if(h=Math.floor(h),p=Math.ceil(p),u>0){for(;h<=p;++h)for(d=1;d<r;++d)if(m=h<0?d/s(-h):d*s(h),!(m<u)){if(m>f)break;x.push(m)}}else for(;h<=p;++h)for(d=r-1;d>=1;--d)if(m=h>0?d/s(-h):d*s(h),!(m<u)){if(m>f)break;x.push(m)}x.length*2<g&&(x=_s(u,f,g))}else x=_s(h,p,Math.min(p-h,g)).map(s);return l?x.reverse():x},e.tickFormat=(a,c)=>{if(a==null&&(a=10),c==null&&(c=r===10?"s":","),typeof c!="function"&&(!(r%1)&&(c=Mt(c)).precision==null&&(c.trim=!0),c=ue(c)),a===1/0)return c;const u=Math.max(1,r*a/e.ticks().length);return f=>{let l=f/s(Math.round(i(f)));return l*r<r-.5&&(l*=r),l<=u?c(f):""}},e.nice=()=>n(r0(n(),{floor:a=>s(Math.floor(i(a))),ceil:a=>s(Math.ceil(i(a)))})),e}function jc(){const t=Wc(Fo()).domain([1,10]);return t.copy=()=>zi(t,jc()).base(t.base()),ct.apply(t,arguments),t}function zl(t){return function(e){return Math.sign(e)*Math.log1p(Math.abs(e/t))}}function Ul(t){return function(e){return Math.sign(e)*Math.expm1(Math.abs(e))*t}}function Yc(t){var e=1,n=t(zl(e),Ul(e));return n.constant=function(r){return arguments.length?t(zl(e=+r),Ul(e)):e},Pn(n)}function i0(){var t=Yc(Fo());return t.copy=function(){return zi(t,i0()).constant(t.constant())},ct.apply(t,arguments)}function $l(t){return function(e){return e<0?-Math.pow(-e,t):Math.pow(e,t)}}function tb(t){return t<0?-Math.sqrt(-t):Math.sqrt(t)}function nb(t){return t<0?-t*t:t*t}function Xc(t){var e=t(Te,Te),n=1;function r(){return n===1?t(Te,Te):n===.5?t(tb,nb):t($l(n),$l(1/n))}return e.exponent=function(i){return arguments.length?(n=+i,r()):n},Pn(e)}function Kc(){var t=Xc(Fo());return t.copy=function(){return zi(t,Kc()).exponent(t.exponent())},ct.apply(t,arguments),t}function rb(){return Kc.apply(null,arguments).exponent(.5)}function s0(){var t=[],e=[],n=[],r;function i(){var o=0,a=Math.max(1,e.length);for(n=new Array(a-1);++o<a;)n[o-1]=Qf(t,o/a);return s}function s(o){return o==null||isNaN(o=+o)?r:e[gr(n,o)]}return s.invertExtent=function(o){var a=e.indexOf(o);return a<0?[NaN,NaN]:[a>0?n[a-1]:t[0],a<n.length?n[a]:t[t.length-1]]},s.domain=function(o){if(!arguments.length)return t.slice();t=[];for(let a of o)a!=null&&!isNaN(a=+a)&&t.push(a);return t.sort(Lr),i()},s.range=function(o){return arguments.length?(e=Array.from(o),i()):e.slice()},s.unknown=function(o){return arguments.length?(r=o,s):r},s.quantiles=function(){return n.slice()},s.copy=function(){return s0().domain(t).range(e).unknown(r)},ct.apply(s,arguments)}function o0(){var t=0,e=1,n=1,r=[.5],i=[0,1],s;function o(c){return c!=null&&c<=c?i[gr(r,c,0,n)]:s}function a(){var c=-1;for(r=new Array(n);++c<n;)r[c]=((c+1)*e-(c-n)*t)/(n+1);return o}return o.domain=function(c){return arguments.length?([t,e]=c,t=+t,e=+e,a()):[t,e]},o.range=function(c){return arguments.length?(n=(i=Array.from(c)).length-1,a()):i.slice()},o.invertExtent=function(c){var u=i.indexOf(c);return u<0?[NaN,NaN]:u<1?[t,r[0]]:u>=n?[r[n-1],e]:[r[u-1],r[u]]},o.unknown=function(c){return arguments.length&&(s=c),o},o.thresholds=function(){return r.slice()},o.copy=function(){return o0().domain([t,e]).range(i).unknown(s)},ct.apply(Pn(o),arguments)}function a0(){var t=[.5],e=[0,1],n,r=1;function i(s){return s!=null&&s<=s?e[gr(t,s,0,r)]:n}return i.domain=function(s){return arguments.length?(t=Array.from(s),r=Math.min(t.length,e.length-1),i):t.slice()},i.range=function(s){return arguments.length?(e=Array.from(s),r=Math.min(t.length,e.length-1),i):e.slice()},i.invertExtent=function(s){var o=e.indexOf(s);return[t[o-1],t[o]]},i.unknown=function(s){return arguments.length?(n=s,i):n},i.copy=function(){return a0().domain(t).range(e).unknown(n)},ct.apply(i,arguments)}function ib(t){return new Date(t)}function sb(t){return t instanceof Date?+t:+new Date(+t)}function Jc(t,e,n,r,i,s,o,a,c,u){var f=Qh(),l=f.invert,h=f.domain,p=u(".%L"),d=u(":%S"),m=u("%I:%M"),g=u("%I %p"),x=u("%a %d"),b=u("%b %d"),A=u("%B"),E=u("%Y");function F(C){return(c(C)<C?p:a(C)<C?d:o(C)<C?m:s(C)<C?g:r(C)<C?i(C)<C?x:b:n(C)<C?A:E)(C)}return f.invert=function(C){return new Date(l(C))},f.domain=function(C){return arguments.length?h(Array.from(C,sb)):h().map(ib)},f.ticks=function(C){var w=h();return t(w[0],w[w.length-1],C??10)},f.tickFormat=function(C,w){return w==null?F:u(w)},f.nice=function(C){var w=h();return(!C||typeof C.range!="function")&&(C=e(w[0],w[w.length-1],C??10)),C?h(r0(w,C)):f},f.copy=function(){return zi(f,Jc(t,e,n,r,i,s,o,a,c,u))},f}function ob(){return ct.apply(Jc(ag,cg,st,Xr,Ri,Rt,ho,lo,At,Bc).domain([new Date(2e3,0,1),new Date(2e3,0,2)]),arguments)}function ab(){return ct.apply(Jc(sg,og,ot,Kr,Mi,xn,po,fo,At,kc).domain([Date.UTC(2e3,0,1),Date.UTC(2e3,0,2)]),arguments)}function To(){var t=0,e=1,n,r,i,s,o=Te,a=!1,c;function u(l){return l==null||isNaN(l=+l)?c:o(i===0?.5:(l=(s(l)-n)*i,a?Math.max(0,Math.min(1,l)):l))}u.domain=function(l){return arguments.length?([t,e]=l,n=s(t=+t),r=s(e=+e),i=n===r?0:1/(r-n),u):[t,e]},u.clamp=function(l){return arguments.length?(a=!!l,u):a},u.interpolator=function(l){return arguments.length?(o=l,u):o};function f(l){return function(h){var p,d;return arguments.length?([p,d]=h,o=l(p,d),u):[o(0),o(1)]}}return u.range=f(Ht),u.rangeRound=f(Ni),u.unknown=function(l){return arguments.length?(c=l,u):c},function(l){return s=l,n=l(t),r=l(e),i=n===r?0:1/(r-n),u}}function qt(t,e){return e.domain(t.domain()).interpolator(t.interpolator()).clamp(t.clamp()).unknown(t.unknown())}function Zc(){var t=Pn(To()(Te));return t.copy=function(){return qt(t,Zc())},Vt.apply(t,arguments)}function c0(){var t=Wc(To()).domain([1,10]);return t.copy=function(){return qt(t,c0()).base(t.base())},Vt.apply(t,arguments)}function u0(){var t=Yc(To());return t.copy=function(){return qt(t,u0()).constant(t.constant())},Vt.apply(t,arguments)}function Qc(){var t=Xc(To());return t.copy=function(){return qt(t,Qc()).exponent(t.exponent())},Vt.apply(t,arguments)}function cb(){return Qc.apply(null,arguments).exponent(.5)}function Do(){var t=0,e=.5,n=1,r=1,i,s,o,a,c,u=Te,f,l=!1,h;function p(m){return isNaN(m=+m)?h:(m=.5+((m=+f(m))-s)*(r*m<r*s?a:c),u(l?Math.max(0,Math.min(1,m)):m))}p.domain=function(m){return arguments.length?([t,e,n]=m,i=f(t=+t),s=f(e=+e),o=f(n=+n),a=i===s?0:.5/(s-i),c=s===o?0:.5/(o-s),r=s<i?-1:1,p):[t,e,n]},p.clamp=function(m){return arguments.length?(l=!!m,p):l},p.interpolator=function(m){return arguments.length?(u=m,p):u};function d(m){return function(g){var x,b,A;return arguments.length?([x,b,A]=g,u=qc(m,[x,b,A]),p):[u(0),u(.5),u(1)]}}return p.range=d(Ht),p.rangeRound=d(Ni),p.unknown=function(m){return arguments.length?(h=m,p):h},function(m){return f=m,i=m(t),s=m(e),o=m(n),a=i===s?0:.5/(s-i),c=s===o?0:.5/(o-s),r=s<i?-1:1,p}}function l0(){var t=Pn(Do()(Te));return t.copy=function(){return qt(t,l0())},Vt.apply(t,arguments)}function f0(){var t=Wc(Do()).domain([.1,1,10]);return t.copy=function(){return qt(t,f0()).base(t.base())},Vt.apply(t,arguments)}function h0(){var t=Yc(Do());return t.copy=function(){return qt(t,h0()).constant(t.constant())},Vt.apply(t,arguments)}function eu(){var t=Xc(Do());return t.copy=function(){return qt(t,eu()).exponent(t.exponent())},Vt.apply(t,arguments)}function ub(){return eu.apply(null,arguments).exponent(.5)}function tu(t,e,n){const r=t-e+n*2;return t?r>0?r:1:0}const lb="identity",fr="linear",kt="log",Ui="pow",$i="sqrt",Io="symlog",d0="time",p0="utc",rt="sequential",yr="diverging",Wa="quantile",m0="quantize",g0="threshold",nu="ordinal",ja="point",x0="band",ru="bin-ordinal",Q="continuous",Vi="discrete",Gi="discretizing",$e="interpolating",y0="temporal";function fb(t){return function(e){let n=e[0],r=e[1],i;return r<n&&(i=n,n=r,r=i),[t.invert(n),t.invert(r)]}}function hb(t){return function(e){const n=t.range();let r=e[0],i=e[1],s=-1,o,a,c,u;for(i<r&&(a=r,r=i,i=a),c=0,u=n.length;c<u;++c)n[c]>=r&&n[c]<=i&&(s<0&&(s=c),o=c);if(!(s<0))return r=t.invertExtent(n[s]),i=t.invertExtent(n[o]),[r[0]===void 0?r[1]:r[0],i[1]===void 0?i[0]:i[1]]}}function iu(){const t=Uc().unknown(void 0),e=t.domain,n=t.range;let r=[0,1],i,s,o=!1,a=0,c=0,u=.5;delete t.unknown;function f(){const l=e().length,h=r[1]<r[0],p=r[1-h],d=tu(l,a,c);let m=r[h-0];i=(p-m)/(d||1),o&&(i=Math.floor(i)),m+=(p-m-i*(l-a))*u,s=i*(1-a),o&&(m=Math.round(m),s=Math.round(s));const g=Yr(l).map(x=>m+i*x);return n(h?g.reverse():g)}return t.domain=function(l){return arguments.length?(e(l),f()):e()},t.range=function(l){return arguments.length?(r=[+l[0],+l[1]],f()):r.slice()},t.rangeRound=function(l){return r=[+l[0],+l[1]],o=!0,f()},t.bandwidth=function(){return s},t.step=function(){return i},t.round=function(l){return arguments.length?(o=!!l,f()):o},t.padding=function(l){return arguments.length?(c=Math.max(0,Math.min(1,l)),a=c,f()):a},t.paddingInner=function(l){return arguments.length?(a=Math.max(0,Math.min(1,l)),f()):a},t.paddingOuter=function(l){return arguments.length?(c=Math.max(0,Math.min(1,l)),f()):c},t.align=function(l){return arguments.length?(u=Math.max(0,Math.min(1,l)),f()):u},t.invertRange=function(l){if(l[0]==null||l[1]==null)return;const h=r[1]<r[0],p=h?n().reverse():n(),d=p.length-1;let m=+l[0],g=+l[1],x,b,A;if(!(m!==m||g!==g)&&(g<m&&(A=m,m=g,g=A),!(g<p[0]||m>r[1-h])))return x=Math.max(0,_a(p,m)-1),b=m===g?x:_a(p,g)-1,m-p[x]>s+1e-10&&++x,h&&(A=x,x=d-b,b=d-A),x>b?void 0:e().slice(x,b+1)},t.invert=function(l){const h=t.invertRange([l,l]);return h&&h[0]},t.copy=function(){return iu().domain(e()).range(r).round(o).paddingInner(a).paddingOuter(c).align(u)},f()}function b0(t){const e=t.copy;return t.padding=t.paddingOuter,delete t.paddingInner,t.copy=function(){return b0(e())},t}function db(){return b0(iu().paddingInner(1))}var pb=Array.prototype.map;function mb(t){return pb.call(t,jr)}const gb=Array.prototype.slice;function A0(){let t=[],e=[];function n(r){return r==null||r!==r?void 0:e[(gr(t,r)-1)%e.length]}return n.domain=function(r){return arguments.length?(t=mb(r),n):t.slice()},n.range=function(r){return arguments.length?(e=gb.call(r),n):e.slice()},n.tickFormat=function(r,i){return e0(t[0],Ye(t),r??10,i)},n.copy=function(){return A0().domain(n.domain()).range(n.range())},n}const zs=new Map,xb=Symbol("vega_scale");function yb(t){return t[xb]=!0,t}function bb(t,e,n){const r=function(){const s=e();return s.invertRange||(s.invertRange=s.invert?fb(s):s.invertExtent?hb(s):void 0),s.type=t,yb(s)};return r.metadata=Ds(Ia(n)),r}function N(t,e,n){return arguments.length>1?(zs.set(t,bb(t,e,n)),this):Ab(t)?zs.get(t):void 0}N(lb,n0);N(fr,t0,Q);N(kt,jc,[Q,kt]);N(Ui,Kc,Q);N($i,rb,Q);N(Io,i0,Q);N(d0,ob,[Q,y0]);N(p0,ab,[Q,y0]);N(rt,Zc,[Q,$e]);N(`${rt}-${fr}`,Zc,[Q,$e]);N(`${rt}-${kt}`,c0,[Q,$e,kt]);N(`${rt}-${Ui}`,Qc,[Q,$e]);N(`${rt}-${$i}`,cb,[Q,$e]);N(`${rt}-${Io}`,u0,[Q,$e]);N(`${yr}-${fr}`,l0,[Q,$e]);N(`${yr}-${kt}`,f0,[Q,$e,kt]);N(`${yr}-${Ui}`,eu,[Q,$e]);N(`${yr}-${$i}`,ub,[Q,$e]);N(`${yr}-${Io}`,h0,[Q,$e]);N(Wa,s0,[Gi,Wa]);N(m0,o0,Gi);N(g0,a0,Gi);N(ru,A0,[Vi,Gi]);N(nu,Uc,Vi);N(x0,iu,Vi);N(ja,db,Vi);function Ab(t){return zs.has(t)}function Hi(t,e){const n=zs.get(t);return n&&n.metadata[e]}function me(t){return Hi(t,Q)}function Ot(t){return Hi(t,Vi)}function Hn(t){return Hi(t,Gi)}function w0(t){return Hi(t,kt)}function _o(t){return Hi(t,$e)}function wb(t,e){const n=e[0],r=Ye(e)-n;return function(i){return t(n+i*r)}}function Ro(t,e,n){return qc(v0(e||"rgb",n),t)}function vb(t,e){const n=new Array(e),r=e+1;for(let i=0;i<e;)n[i]=t(++i/r);return n}function v0(t,e){const n=qy[Eb(t)];return e!=null&&n&&n.gamma?n.gamma(e):n}function Eb(t){return"interpolate"+t.toLowerCase().split("-").map(e=>e[0].toUpperCase()+e.slice(1)).join("")}const Cb={blues:"cfe1f2bed8eca8cee58fc1de74b2d75ba3cf4592c63181bd206fb2125ca40a4a90",greens:"d3eecdc0e6baabdda594d3917bc77d60ba6c46ab5e329a512089430e7735036429",greys:"e2e2e2d4d4d4c4c4c4b1b1b19d9d9d8888887575756262624d4d4d3535351e1e1e",oranges:"fdd8b3fdc998fdb87bfda55efc9244f87f2cf06b18e4580bd14904b93d029f3303",purples:"e2e1efd4d4e8c4c5e0b4b3d6a3a0cc928ec3827cb97566ae684ea25c3696501f8c",reds:"fdc9b4fcb49afc9e80fc8767fa7051f6573fec3f2fdc2a25c81b1db21218970b13",blueGreen:"d5efedc1e8e0a7ddd18bd2be70c6a958ba9144ad77319c5d2089460e7736036429",bluePurple:"ccddecbad0e4a8c2dd9ab0d4919cc98d85be8b6db28a55a6873c99822287730f71",greenBlue:"d3eecec5e8c3b1e1bb9bd8bb82cec269c2ca51b2cd3c9fc7288abd1675b10b60a1",orangeRed:"fddcaffdcf9bfdc18afdad77fb9562f67d53ee6545e24932d32d1ebf130da70403",purpleBlue:"dbdaebc8cee4b1c3de97b7d87bacd15b9fc93a90c01e7fb70b70ab056199045281",purpleBlueGreen:"dbd8eac8cee4b0c3de93b7d872acd1549fc83892bb1c88a3097f8702736b016353",purpleRed:"dcc9e2d3b3d7ce9eccd186c0da6bb2e14da0e23189d91e6fc61159ab07498f023a",redPurple:"fccfccfcbec0faa9b8f98faff571a5ec539ddb3695c41b8aa908808d0179700174",yellowGreen:"e4f4acd1eca0b9e2949ed68880c97c62bb6e47aa5e3297502083440e723b036034",yellowOrangeBrown:"feeaa1fedd84fecc63feb746fca031f68921eb7215db5e0bc54c05ab3d038f3204",yellowOrangeRed:"fee087fed16ffebd59fea849fd903efc7335f9522bee3423de1b20ca0b22af0225",blueOrange:"134b852f78b35da2cb9dcae1d2e5eff2f0ebfce0bafbbf74e8932fc5690d994a07",brownBlueGreen:"704108a0651ac79548e3c78af3e6c6eef1eac9e9e48ed1c74da79e187a72025147",purpleGreen:"5b1667834792a67fb6c9aed3e6d6e8eff0efd9efd5aedda971bb75368e490e5e29",purpleOrange:"4114696647968f83b7b9b4d6dadbebf3eeeafce0bafbbf74e8932fc5690d994a07",redBlue:"8c0d25bf363adf745ef4ae91fbdbc9f2efeed2e5ef9dcae15da2cb2f78b3134b85",redGrey:"8c0d25bf363adf745ef4ae91fcdccbfaf4f1e2e2e2c0c0c0969696646464343434",yellowGreenBlue:"eff9bddbf1b4bde5b594d5b969c5be45b4c22c9ec02182b82163aa23479c1c3185",redYellowBlue:"a50026d4322cf16e43fcac64fedd90faf8c1dcf1ecabd6e875abd04a74b4313695",redYellowGreen:"a50026d4322cf16e43fcac63fedd8df9f7aed7ee8ea4d86e64bc6122964f006837",pinkYellowGreen:"8e0152c0267edd72adf0b3d6faddedf5f3efe1f2cab6de8780bb474f9125276419",spectral:"9e0142d13c4bf0704afcac63fedd8dfbf8b0e0f3a1a9dda269bda94288b55e4fa2",viridis:"440154470e61481a6c482575472f7d443a834144873d4e8a39568c35608d31688e2d708e2a788e27818e23888e21918d1f988b1fa08822a8842ab07f35b77943bf7154c56866cc5d7ad1518fd744a5db36bcdf27d2e21be9e51afde725",magma:"0000040404130b0924150e3720114b2c11603b0f704a107957157e651a80721f817f24828c29819a2e80a8327db6377ac43c75d1426fde4968e95462f1605df76f5cfa7f5efc8f65fe9f6dfeaf78febf84fece91fddea0fcedaffcfdbf",inferno:"0000040403130c0826170c3b240c4f330a5f420a68500d6c5d126e6b176e781c6d86216b932667a12b62ae305cbb3755c73e4cd24644dd513ae65c30ed6925f3771af8850ffb9506fca50afcb519fac62df6d645f2e661f3f484fcffa4",plasma:"0d088723069033059742039d5002a25d01a66a00a87801a88405a7900da49c179ea72198b12a90ba3488c33d80cb4779d35171da5a69e16462e76e5bed7953f2834cf68f44fa9a3dfca636fdb32ffec029fcce25f9dc24f5ea27f0f921",cividis:"00205100235800265d002961012b65042e670831690d346b11366c16396d1c3c6e213f6e26426e2c456e31476e374a6e3c4d6e42506e47536d4c566d51586e555b6e5a5e6e5e616e62646f66676f6a6a706e6d717270717573727976737c79747f7c75827f758682768985778c8877908b78938e789691789a94789e9778a19b78a59e77a9a177aea575b2a874b6ab73bbaf71c0b26fc5b66dc9b96acebd68d3c065d8c462ddc85fe2cb5ce7cf58ebd355f0d652f3da4ff7de4cfae249fce647",rainbow:"6e40aa883eb1a43db3bf3cafd83fa4ee4395fe4b83ff576eff6659ff7847ff8c38f3a130e2b72fcfcc36bee044aff05b8ff4576ff65b52f6673af27828ea8d1ddfa319d0b81cbecb23abd82f96e03d82e14c6edb5a5dd0664dbf6e40aa",sinebow:"ff4040fc582af47218e78d0bd5a703bfbf00a7d5038de70b72f41858fc2a40ff402afc5818f4720be78d03d5a700bfbf03a7d50b8de71872f42a58fc4040ff582afc7218f48d0be7a703d5bf00bfd503a7e70b8df41872fc2a58ff4040",turbo:"23171b32204a3e2a71453493493eae4b49c54a53d7485ee44569ee4074f53c7ff8378af93295f72e9ff42ba9ef28b3e926bce125c5d925cdcf27d5c629dcbc2de3b232e9a738ee9d3ff39347f68950f9805afc7765fd6e70fe667cfd5e88fc5795fb51a1f84badf545b9f140c5ec3cd0e637dae034e4d931ecd12ef4c92bfac029ffb626ffad24ffa223ff9821ff8d1fff821dff771cfd6c1af76118f05616e84b14df4111d5380fcb2f0dc0260ab61f07ac1805a313029b0f00950c00910b00",browns:"eedbbdecca96e9b97ae4a865dc9856d18954c7784cc0673fb85536ad44339f3632",tealBlues:"bce4d89dd3d181c3cb65b3c245a2b9368fae347da0306a932c5985",teals:"bbdfdfa2d4d58ac9c975bcbb61b0af4da5a43799982b8b8c1e7f7f127273006667",warmGreys:"dcd4d0cec5c1c0b8b4b3aaa7a59c9998908c8b827f7e7673726866665c5a59504e",goldGreen:"f4d166d5ca60b6c35c98bb597cb25760a6564b9c533f8f4f33834a257740146c36",goldOrange:"f4d166f8be5cf8aa4cf5983bf3852aef701be2621fd65322c54923b142239e3a26",goldRed:"f4d166f6be59f9aa51fc964ef6834bee734ae56249db5247cf4244c43141b71d3e",lightGreyRed:"efe9e6e1dad7d5cbc8c8bdb9bbaea9cd967ddc7b43e15f19df4011dc000b",lightGreyTeal:"e4eaead6dcddc8ced2b7c2c7a6b4bc64b0bf22a6c32295c11f85be1876bc",lightMulti:"e0f1f2c4e9d0b0de9fd0e181f6e072f6c053f3993ef77440ef4a3c",lightOrange:"f2e7daf7d5baf9c499fab184fa9c73f68967ef7860e8645bde515bd43d5b",lightTealBlue:"e3e9e0c0dccf9aceca7abfc859afc0389fb9328dad2f7ca0276b95255988",darkBlue:"3232322d46681a5c930074af008cbf05a7ce25c0dd38daed50f3faffffff",darkGold:"3c3c3c584b37725e348c7631ae8b2bcfa424ecc31ef9de30fff184ffffff",darkGreen:"3a3a3a215748006f4d048942489e4276b340a6c63dd2d836ffeb2cffffaa",darkMulti:"3737371f5287197d8c29a86995ce3fffe800ffffff",darkRed:"3434347036339e3c38cc4037e75d1eec8620eeab29f0ce32ffeb2c"},Sb={category10:"1f77b4ff7f0e2ca02cd627289467bd8c564be377c27f7f7fbcbd2217becf",category20:"1f77b4aec7e8ff7f0effbb782ca02c98df8ad62728ff98969467bdc5b0d58c564bc49c94e377c2f7b6d27f7f7fc7c7c7bcbd22dbdb8d17becf9edae5",category20b:"393b795254a36b6ecf9c9ede6379398ca252b5cf6bcedb9c8c6d31bd9e39e7ba52e7cb94843c39ad494ad6616be7969c7b4173a55194ce6dbdde9ed6",category20c:"3182bd6baed69ecae1c6dbefe6550dfd8d3cfdae6bfdd0a231a35474c476a1d99bc7e9c0756bb19e9ac8bcbddcdadaeb636363969696bdbdbdd9d9d9",tableau10:"4c78a8f58518e4575672b7b254a24beeca3bb279a2ff9da69d755dbab0ac",tableau20:"4c78a89ecae9f58518ffbf7954a24b88d27ab79a20f2cf5b43989483bcb6e45756ff9d9879706ebab0acd67195fcbfd2b279a2d6a5c99e765fd8b5a5",accent:"7fc97fbeaed4fdc086ffff99386cb0f0027fbf5b17666666",dark2:"1b9e77d95f027570b3e7298a66a61ee6ab02a6761d666666",paired:"a6cee31f78b4b2df8a33a02cfb9a99e31a1cfdbf6fff7f00cab2d66a3d9affff99b15928",pastel1:"fbb4aeb3cde3ccebc5decbe4fed9a6ffffcce5d8bdfddaecf2f2f2",pastel2:"b3e2cdfdcdaccbd5e8f4cae4e6f5c9fff2aef1e2cccccccc",set1:"e41a1c377eb84daf4a984ea3ff7f00ffff33a65628f781bf999999",set2:"66c2a5fc8d628da0cbe78ac3a6d854ffd92fe5c494b3b3b3",set3:"8dd3c7ffffb3bebadafb807280b1d3fdb462b3de69fccde5d9d9d9bc80bdccebc5ffed6f"};function E0(t){const e=t.length/6|0,n=new Array(e);for(let r=0;r<e;)n[r]="#"+t.slice(r*6,++r*6);return n}function C0(t,e){for(const n in t)su(n,e(t[n]))}const Vl={};C0(Sb,E0);C0(Cb,t=>Ro(E0(t)));function su(t,e){return t=t&&t.toLowerCase(),arguments.length>1?(Vl[t]=e,this):Vl[t]}function Fb(){let t=0;const e=new Map,n=r=>{let i=e.get(r);return i===void 0&&(i=t++,e.set(r,i)),i};return n.addAll=r=>{for(const i of r)n(i)},n.invert=r=>{for(const i of e.entries())if(i[1]==r)return i[0]},n.domain=()=>[...e.keys()],n}function Mo(){const t=e=>e;return t.invert=e=>e,t.copy=Mo,t.invertRange=()=>{},t.type="null",t}function Tb(t,e){const n={};e||(e=t.encoding);for(const[r,i]of Object.entries(e)){if(!i)continue;const s=((De(i)&&i.resolutionChannel)??(wn(r)&&r))||void 0,o=t.unitView.getScaleResolution(s);n[r]=Db(e[r],o==null?void 0:o.getScale(),t.unitView.getAccessor(r),r)}return n}function Db(t,e,n,r){let i;if(Xe(t)){const s=t.value;i=o=>s,i.constant=!0,i.constantValue=!0,i.accessor=void 0}else if(n)if(r=="text")i=s=>{},i.accessor=n,i.constant=n.constant;else{if(!e)if(!wn(r))e=Mo();else throw new Error(`Missing scale! "${r}": ${JSON.stringify(t)}`);if(i=s=>e(n(s)),Ot(e.type)){const s=Fb();s.addAll(e.domain()),i.indexer=s}i.constant=n.constant,i.accessor=n,i.scale=e}else throw new Error(`Missing value or accessor (field, expr, datum) on channel "${r}": ${JSON.stringify(t)}`);return i.invert=e?s=>e.invert(s):s=>{throw new Error("No scale available, cannot invert: "+JSON.stringify(t))},i.channelDef=t,i.applyMetadata=s=>{for(const o in i)o in i&&(s[o]=i[o]);return s},i}function Xe(t){return t&&"value"in t}function qi(t){return t&&"field"in t}function Wi(t){return t&&"datum"in t}function De(t){return qi(t)||Wi(t)||ou(t)||S0(t)}function Ya(t,e){const n=t.mark.encoding[e];if(De(n))return n;throw new Error("Not a channel def with scale!")}function S0(t){return t&&"chrom"in t}function ou(t){return t&&"expr"in t}const br=["x","y"],Ib=["x2","y2"],_b=[...br,...Ib];function F0(t){return br.includes(t)}function li(t){return _b.includes(t)}const au={x:"x2",y:"y2"},T0=Object.fromEntries(Object.entries(au).map(t=>[t[1],t[0]]));function zr(t){return t in T0}function Rb(t){const e=au[t];if(e)return e;throw new Error(`${t} has no secondary channel!`)}function _n(t){return T0[t]??t}function An(t){return["color","fill","stroke"].includes(_n(t))}function Bo(t){return["shape","squeeze"].includes(t)}function wn(t){return["x","y","x2","y2","color","fill","stroke","opacity","fillOpacity","strokeOpacity","strokeWidth","size","shape","angle","dx","dy","sample"].includes(t)}function Mb(t){switch(t){case"shape":return["circle","square","cross","diamond","triangle-up","triangle-right","triangle-down","triangle-left","tick-up","tick-right","tick-down","tick-left"]}}function D0(t){if(!Bo(t))throw new Error("Not a discrete channel: "+t);const e=new Map(Mb(t).map((n,r)=>[n,r]));return n=>{const r=e.get(n);if(r!==void 0)return r;throw new Error(`Invalid value for "${t}" channel: ${n}`)}}function U(t,e=t){if(/^[A-Za-z0-9_]+$/.test(t)){const n=new Function("datum",`return datum[${JSON.stringify(t)}]`);return Ut(n,[t],e)}else return io(t)}class Bb{constructor(){this.accessorCreators=[],this.register(e=>{if(qi(e))try{const n=U(e.field);return n.constant=!1,n.fields=Uf(n),n}catch(n){throw new Error(`Invalid field definition: ${n.message}`)}}),this.register(e=>ou(e)?kb(e.expr):void 0),this.register(e=>{if(Wi(e)){const r=hm(e.datum);return r.constant=!0,r.fields=[],r}})}register(e){this.accessorCreators.push(e)}createAccessor(e){for(const n of this.accessorCreators){const r=n(e);if(r)return r}}}function kb(t){const n=vo(t);return n.constant=n.fields.length==0,n}/* @license twgl.js 4.24.0 Copyright (c) 2015, Gregg Tavares All Rights Reserved. +Available via the MIT license. +see: http://github.com/greggman/twgl.js for details */const cu=5120,fi=5121,uu=5122,lu=5123,fu=5124,hu=5125,du=5126,Ob=32819,Pb=32820,Lb=33635,Nb=5131,zb=33640,Ub=35899,$b=35902,Vb=36269,Gb=34042,I0={};{const t=I0;t[cu]=Int8Array,t[fi]=Uint8Array,t[uu]=Int16Array,t[lu]=Uint16Array,t[fu]=Int32Array,t[hu]=Uint32Array,t[du]=Float32Array,t[Ob]=Uint16Array,t[Pb]=Uint16Array,t[Lb]=Uint16Array,t[Nb]=Uint16Array,t[zb]=Uint32Array,t[Ub]=Uint32Array,t[$b]=Uint32Array,t[Vb]=Uint32Array,t[Gb]=Uint32Array}function pu(t){if(t instanceof Int8Array)return cu;if(t instanceof Uint8Array||t instanceof Uint8ClampedArray)return fi;if(t instanceof Int16Array)return uu;if(t instanceof Uint16Array)return lu;if(t instanceof Int32Array)return fu;if(t instanceof Uint32Array)return hu;if(t instanceof Float32Array)return du;throw new Error("unsupported typed array type")}function Hb(t){if(t===Int8Array)return cu;if(t===Uint8Array||t===Uint8ClampedArray)return fi;if(t===Int16Array)return uu;if(t===Uint16Array)return lu;if(t===Int32Array)return fu;if(t===Uint32Array)return hu;if(t===Float32Array)return du;throw new Error("unsupported typed array type")}function qb(t){const e=I0[t];if(!e)throw new Error("unknown gl type");return e}const Us=typeof SharedArrayBuffer<"u"?function(e){return e&&e.buffer&&(e.buffer instanceof ArrayBuffer||e.buffer instanceof SharedArrayBuffer)}:function(e){return e&&e.buffer&&e.buffer instanceof ArrayBuffer};function Wb(...t){console.error(...t)}function _0(...t){console.warn(...t)}function jb(t,e){return typeof WebGLBuffer<"u"&&e instanceof WebGLBuffer}function R0(t,e){return typeof WebGLRenderbuffer<"u"&&e instanceof WebGLRenderbuffer}function ko(t,e){return typeof WebGLTexture<"u"&&e instanceof WebGLTexture}function Yb(t,e){return typeof WebGLSampler<"u"&&e instanceof WebGLSampler}const M0=35044,it=34962,Xb=34963,Kb=34660,Jb=5120,Zb=5121,Qb=5122,e2=5123,t2=5124,n2=5125,r2=5126,B0={attribPrefix:""};function k0(t,e,n,r,i){t.bindBuffer(e,n),t.bufferData(e,r,i||M0)}function O0(t,e,n,r){if(jb(t,e))return e;n=n||it;const i=t.createBuffer();return k0(t,n,i,e,r),i}function P0(t){return t==="indices"}function i2(t){return t instanceof Int8Array||t instanceof Uint8Array}function s2(t){return t===Int8Array||t===Uint8Array}function o2(t){return t.length?t:t.data}const a2=/coord|texture/i,c2=/color|colour/i;function L0(t,e){let n;if(a2.test(t)?n=2:c2.test(t)?n=4:n=3,e%n>0)throw new Error(`Can not guess numComponents for attribute '${t}'. Tried ${n} but ${e} values is not evenly divisible by ${n}. You should specify it.`);return n}function u2(t,e){return t.numComponents||t.size||L0(e,o2(t).length)}function mu(t,e){if(Us(t))return t;if(Us(t.data))return t.data;Array.isArray(t)&&(t={data:t});let n=t.type;return n||(P0(e)?n=Uint16Array:n=Float32Array),new n(t.data)}function l2(t,e){const n={};return Object.keys(e).forEach(function(r){if(!P0(r)){const i=e[r],s=i.attrib||i.name||i.attribName||B0.attribPrefix+r;if(i.value){if(!Array.isArray(i.value)&&!Us(i.value))throw new Error("array.value is not array or typedarray");n[s]={value:i.value}}else{let o,a,c,u;if(i.buffer&&i.buffer instanceof WebGLBuffer)o=i.buffer,u=i.numComponents||i.size,a=i.type,c=i.normalize;else if(typeof i=="number"||typeof i.data=="number"){const f=i.data||i,l=i.type||Float32Array,h=f*l.BYTES_PER_ELEMENT;a=Hb(l),c=i.normalize!==void 0?i.normalize:s2(l),u=i.numComponents||i.size||L0(r,f),o=t.createBuffer(),t.bindBuffer(it,o),t.bufferData(it,h,i.drawType||M0)}else{const f=mu(i,r);o=O0(t,f,void 0,i.drawType),a=pu(f),c=i.normalize!==void 0?i.normalize:i2(f),u=u2(i,r)}n[s]={buffer:o,numComponents:u,type:a,normalize:c,stride:i.stride||0,offset:i.offset||0,divisor:i.divisor===void 0?void 0:i.divisor,drawType:i.drawType}}}}),t.bindBuffer(it,null),n}function f2(t,e,n,r){n=mu(n),r!==void 0?(t.bindBuffer(it,e.buffer),t.bufferSubData(it,r,n)):k0(t,it,e.buffer,n,e.drawType)}function h2(t,e){return e===Jb||e===Zb?1:e===Qb||e===e2?2:e===t2||e===n2||e===r2?4:0}const ma=["position","positions","a_position"];function d2(t,e){let n,r;for(r=0;r<ma.length&&(n=ma[r],!(n in e||(n=B0.attribPrefix+n,n in e)));++r);r===ma.length&&(n=Object.keys(e)[0]);const i=e[n];if(!i.buffer)return 1;t.bindBuffer(it,i.buffer);const s=t.getBufferParameter(it,Kb);t.bindBuffer(it,null);const o=h2(t,i.type),a=s/o,c=i.numComponents||i.size,u=a/c;if(u%1!==0)throw new Error(`numComponents ${c} not correct for length ${length}`);return u}function p2(t,e,n){const r=l2(t,e),i=Object.assign({},n||{});i.attribs=Object.assign({},n?n.attribs:{},r);const s=e.indices;if(s){const o=mu(s,"indices");i.indices=O0(t,o,Xb),i.numElements=o.length,i.elementType=pu(o)}else i.numElements||(i.numElements=d2(t,i.attribs));return i}function Ar(t){return!!t.texStorage2D}const Xa=function(){const t={},e={};function n(r){const i=r.constructor.name;if(!t[i]){for(const s in r)if(typeof r[s]=="number"){const o=e[r[s]];e[r[s]]=o?`${o} | ${s}`:s}t[i]=!0}}return function(i,s){return n(i),e[s]||(typeof s=="number"?`0x${s.toString(16)}`:s)}}(),Wt={textureColor:new Uint8Array([128,192,255,255]),textureOptions:{},crossOrigin:void 0},hr=Us,N0=function(){let t;return function(){return t=t||(typeof document<"u"&&document.createElement?document.createElement("canvas").getContext("2d"):null),t}}(),Gl=6406,Qe=6407,q=6408,Hl=6409,ql=6410,_r=6402,Wl=34041,$s=33071,m2=9728,g2=9729,Ft=3553,Ct=34067,Pt=32879,Lt=35866,Oo=34069,x2=34070,y2=34071,b2=34072,A2=34073,w2=34074,Ka=10241,Ja=10240,Vs=10242,Gs=10243,jl=32882,v2=33082,E2=33083,C2=33084,S2=33085,gu=3317,z0=3314,U0=32878,$0=3316,V0=3315,G0=32877,F2=37443,T2=37441,D2=37440,I2=33321,_2=36756,R2=33325,M2=33326,B2=33330,k2=33329,O2=33338,P2=33337,L2=33340,N2=33339,z2=33323,U2=36757,$2=33327,V2=33328,G2=33336,H2=33335,q2=33332,W2=33331,j2=33334,Y2=33333,X2=32849,K2=35905,J2=36194,Z2=36758,Q2=35898,eA=35901,tA=34843,nA=34837,rA=36221,iA=36239,sA=36215,oA=36233,aA=36209,cA=36227,uA=32856,lA=35907,fA=36759,hA=32855,dA=32854,pA=32857,mA=34842,gA=34836,xA=36220,yA=36238,bA=36975,AA=36214,wA=36232,vA=36226,EA=36208,CA=33189,SA=33190,FA=36012,TA=36013,DA=35056,Dt=5120,H=5121,hs=5122,zn=5123,ds=5124,tn=5125,de=5126,Yl=32819,Xl=32820,Kl=33635,He=5131,Rr=36193,ga=33640,IA=35899,_A=35902,RA=36269,MA=34042,ps=33319,Un=33320,ms=6403,$n=36244,Vn=36248,nn=36249;let xa;function Po(t){if(!xa){const e={};e[Gl]={textureFormat:Gl,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[1,2,2,4],type:[H,He,Rr,de]},e[Hl]={textureFormat:Hl,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[1,2,2,4],type:[H,He,Rr,de]},e[ql]={textureFormat:ql,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[2,4,4,8],type:[H,He,Rr,de]},e[Qe]={textureFormat:Qe,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[3,6,6,12,2],type:[H,He,Rr,de,Kl]},e[q]={textureFormat:q,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4,8,8,16,2,2],type:[H,He,Rr,de,Yl,Xl]},e[_r]={textureFormat:_r,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2,4],type:[tn,zn]},e[I2]={textureFormat:ms,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[1],type:[H]},e[_2]={textureFormat:ms,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[1],type:[Dt]},e[R2]={textureFormat:ms,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[4,2],type:[de,He]},e[M2]={textureFormat:ms,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[4],type:[de]},e[B2]={textureFormat:$n,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[1],type:[H]},e[k2]={textureFormat:$n,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[1],type:[Dt]},e[q2]={textureFormat:$n,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2],type:[zn]},e[W2]={textureFormat:$n,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2],type:[hs]},e[j2]={textureFormat:$n,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[tn]},e[Y2]={textureFormat:$n,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[ds]},e[z2]={textureFormat:ps,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[2],type:[H]},e[U2]={textureFormat:ps,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[2],type:[Dt]},e[$2]={textureFormat:ps,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[8,4],type:[de,He]},e[V2]={textureFormat:ps,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[8],type:[de]},e[G2]={textureFormat:Un,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2],type:[H]},e[H2]={textureFormat:Un,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2],type:[Dt]},e[O2]={textureFormat:Un,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[zn]},e[P2]={textureFormat:Un,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[hs]},e[L2]={textureFormat:Un,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[8],type:[tn]},e[N2]={textureFormat:Un,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[8],type:[ds]},e[X2]={textureFormat:Qe,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[3],type:[H]},e[K2]={textureFormat:Qe,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[3],type:[H]},e[J2]={textureFormat:Qe,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[3,2],type:[H,Kl]},e[Z2]={textureFormat:Qe,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[3],type:[Dt]},e[Q2]={textureFormat:Qe,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[12,6,4],type:[de,He,IA]},e[eA]={textureFormat:Qe,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[12,6,4],type:[de,He,_A]},e[tA]={textureFormat:Qe,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[12,6],type:[de,He]},e[nA]={textureFormat:Qe,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[12],type:[de]},e[rA]={textureFormat:Vn,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[3],type:[H]},e[iA]={textureFormat:Vn,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[3],type:[Dt]},e[sA]={textureFormat:Vn,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[6],type:[zn]},e[oA]={textureFormat:Vn,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[6],type:[hs]},e[aA]={textureFormat:Vn,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[12],type:[tn]},e[cA]={textureFormat:Vn,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[12],type:[ds]},e[uA]={textureFormat:q,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4],type:[H]},e[lA]={textureFormat:q,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4],type:[H]},e[fA]={textureFormat:q,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[4],type:[Dt]},e[hA]={textureFormat:q,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4,2,4],type:[H,Xl,ga]},e[dA]={textureFormat:q,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4,2],type:[H,Yl]},e[pA]={textureFormat:q,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4],type:[ga]},e[mA]={textureFormat:q,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[16,8],type:[de,He]},e[gA]={textureFormat:q,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[16],type:[de]},e[xA]={textureFormat:nn,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[H]},e[yA]={textureFormat:nn,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[Dt]},e[bA]={textureFormat:nn,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[ga]},e[AA]={textureFormat:nn,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[8],type:[zn]},e[wA]={textureFormat:nn,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[8],type:[hs]},e[vA]={textureFormat:nn,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[16],type:[ds]},e[EA]={textureFormat:nn,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[16],type:[tn]},e[CA]={textureFormat:_r,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2,4],type:[zn,tn]},e[SA]={textureFormat:_r,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[tn]},e[FA]={textureFormat:_r,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[de]},e[DA]={textureFormat:Wl,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[MA]},e[TA]={textureFormat:Wl,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[RA]},Object.keys(e).forEach(function(n){const r=e[n];r.bytesPerElementMap={},r.bytesPerElement.forEach(function(i,s){const o=r.type[s];r.bytesPerElementMap[o]=i})}),xa=e}return xa[t]}function BA(t,e){const n=Po(t);if(!n)throw"unknown internal format";const r=n.bytesPerElementMap[e];if(r===void 0)throw"unknown internal format";return r}function wr(t){const e=Po(t);if(!e)throw"unknown internal format";return{format:e.textureFormat,type:e.type[0]}}function Jl(t){return(t&t-1)===0}function kA(t,e,n,r){if(!Ar(t))return Jl(e)&&Jl(n);const i=Po(r);if(!i)throw"unknown internal format";return i.colorRenderable&&i.textureFilterable}function OA(t){const e=Po(t);if(!e)throw"unknown internal format";return e.textureFilterable}function H0(t,e,n){return hr(e)?pu(e):n||H}function gs(t,e,n,r,i){if(i%1!==0)throw"can't guess dimensions";if(!n&&!r){const s=Math.sqrt(i/(e===Ct?6:1));s%1===0?(n=s,r=s):(n=i,r=1)}else if(r){if(!n&&(n=i/r,n%1))throw"can't guess dimensions"}else if(r=i/n,r%1)throw"can't guess dimensions";return{width:n,height:r}}function dr(t,e){e.colorspaceConversion!==void 0&&t.pixelStorei(F2,e.colorspaceConversion),e.premultiplyAlpha!==void 0&&t.pixelStorei(T2,e.premultiplyAlpha),e.flipY!==void 0&&t.pixelStorei(D2,e.flipY)}function q0(t){t.pixelStorei(gu,4),Ar(t)&&(t.pixelStorei(z0,0),t.pixelStorei(U0,0),t.pixelStorei($0,0),t.pixelStorei(V0,0),t.pixelStorei(G0,0))}function PA(t,e,n,r){r.minMag&&(n.call(t,e,Ka,r.minMag),n.call(t,e,Ja,r.minMag)),r.min&&n.call(t,e,Ka,r.min),r.mag&&n.call(t,e,Ja,r.mag),r.wrap&&(n.call(t,e,Vs,r.wrap),n.call(t,e,Gs,r.wrap),(e===Pt||Yb(t,e))&&n.call(t,e,jl,r.wrap)),r.wrapR&&n.call(t,e,jl,r.wrapR),r.wrapS&&n.call(t,e,Vs,r.wrapS),r.wrapT&&n.call(t,e,Gs,r.wrapT),r.minLod&&n.call(t,e,v2,r.minLod),r.maxLod&&n.call(t,e,E2,r.maxLod),r.baseLevel&&n.call(t,e,C2,r.baseLevel),r.maxLevel&&n.call(t,e,S2,r.maxLevel)}function W0(t,e,n){const r=n.target||Ft;t.bindTexture(r,e),PA(t,r,t.texParameteri,n)}function LA(t){return t=t||Wt.textureColor,hr(t)?t:new Uint8Array([t[0]*255,t[1]*255,t[2]*255,t[3]*255])}function Za(t,e,n,r,i,s){n=n||Wt.textureOptions,s=s||q;const o=n.target||Ft;if(r=r||n.width,i=i||n.height,t.bindTexture(o,e),kA(t,r,i,s))t.generateMipmap(o);else{const a=OA(s)?g2:m2;t.texParameteri(o,Ka,a),t.texParameteri(o,Ja,a),t.texParameteri(o,Vs,$s),t.texParameteri(o,Gs,$s)}}function hi(t){return t.auto===!0||t.auto===void 0&&t.level===void 0}function Qa(t,e){return e=e||{},e.cubeFaceOrder||[Oo,x2,y2,b2,A2,w2]}function ec(t,e){const r=Qa(t,e).map(function(i,s){return{face:i,ndx:s}});return r.sort(function(i,s){return i.face-s.face}),r}function j0(t,e,n,r){r=r||Wt.textureOptions;const i=r.target||Ft,s=r.level||0;let o=n.width,a=n.height;const c=r.internalFormat||r.format||q,u=wr(c),f=r.format||u.format,l=r.type||u.type;if(dr(t,r),t.bindTexture(i,e),i===Ct){const h=n.width,p=n.height;let d,m;if(h/6===p)d=p,m=[0,0,1,0,2,0,3,0,4,0,5,0];else if(p/6===h)d=h,m=[0,0,0,1,0,2,0,3,0,4,0,5];else if(h/3===p/2)d=h/3,m=[0,0,1,0,2,0,0,1,1,1,2,1];else if(h/2===p/3)d=h/2,m=[0,0,1,0,0,1,1,1,0,2,1,2];else throw"can't figure out cube map from element: "+(n.src?n.src:n.nodeName);const g=N0();g?(g.canvas.width=d,g.canvas.height=d,o=d,a=d,ec(t,r).forEach(function(x){const b=m[x.ndx*2+0]*d,A=m[x.ndx*2+1]*d;g.drawImage(n,b,A,d,d,0,0,d,d),t.texImage2D(x.face,s,c,f,l,g.canvas)}),g.canvas.width=1,g.canvas.height=1):typeof createImageBitmap<"u"&&(o=d,a=d,ec(t,r).forEach(function(x){const b=m[x.ndx*2+0]*d,A=m[x.ndx*2+1]*d;t.texImage2D(x.face,s,c,d,d,0,f,l,null),createImageBitmap(n,b,A,d,d,{premultiplyAlpha:"none",colorSpaceConversion:"none"}).then(function(E){dr(t,r),t.bindTexture(i,e),t.texImage2D(x.face,s,c,f,l,E),hi(r)&&Za(t,e,r,o,a,c)})}))}else if(i===Pt||i===Lt){const h=Math.min(n.width,n.height),p=Math.max(n.width,n.height),d=p/h;if(d%1!==0)throw"can not compute 3D dimensions of element";const m=n.width===p?1:0,g=n.height===p?1:0;t.pixelStorei(gu,1),t.pixelStorei(z0,n.width),t.pixelStorei(U0,0),t.pixelStorei(G0,0),t.texImage3D(i,s,c,h,h,h,0,f,l,null);for(let x=0;x<d;++x){const b=x*h*m,A=x*h*g;t.pixelStorei($0,b),t.pixelStorei(V0,A),t.texSubImage3D(i,s,0,0,x,h,h,1,f,l,n)}q0(t)}else t.texImage2D(i,s,c,f,l,n);hi(r)&&Za(t,e,r,o,a,c),W0(t,e,r)}function ji(){}function NA(t){if(typeof document<"u"){const e=document.createElement("a");return e.href=t,e.hostname===location.hostname&&e.port===location.port&&e.protocol===location.protocol}else{const e=new URL(location.href).origin;return new URL(t,location.href).origin===e}}function zA(t,e){return e===void 0&&!NA(t)?"anonymous":e}function UA(t,e,n){n=n||ji;let r;if(e=e!==void 0?e:Wt.crossOrigin,e=zA(t,e),typeof Image<"u"){r=new Image,e!==void 0&&(r.crossOrigin=e);const i=function(){r.removeEventListener("error",s),r.removeEventListener("load",o),r=null},s=function(){const c="couldn't load image: "+t;Wb(c),n(c,r),i()},o=function(){n(null,r),i()};return r.addEventListener("error",s),r.addEventListener("load",o),r.src=t,r}else if(typeof ImageBitmap<"u"){let i,s;const o=function(){n(i,s)},a={};e&&(a.mode="cors"),fetch(t,a).then(function(c){if(!c.ok)throw c;return c.blob()}).then(function(c){return createImageBitmap(c,{premultiplyAlpha:"none",colorSpaceConversion:"none"})}).then(function(c){s=c,setTimeout(o)}).catch(function(c){i=c,setTimeout(o)}),r=null}return r}function Y0(t){return typeof ImageBitmap<"u"&&t instanceof ImageBitmap||typeof ImageData<"u"&&t instanceof ImageData||typeof HTMLElement<"u"&&t instanceof HTMLElement}function xu(t,e,n){return Y0(t)?(setTimeout(function(){n(null,t)}),t):UA(t,e,n)}function yu(t,e,n){n=n||Wt.textureOptions;const r=n.target||Ft;if(t.bindTexture(r,e),n.color===!1)return;const i=LA(n.color);if(r===Ct)for(let s=0;s<6;++s)t.texImage2D(Oo+s,0,q,1,1,0,q,H,i);else r===Pt||r===Lt?t.texImage3D(r,0,q,1,1,1,0,q,H,i):t.texImage2D(r,0,q,1,1,0,q,H,i)}function $A(t,e,n,r){return r=r||ji,n=n||Wt.textureOptions,yu(t,e,n),n=Object.assign({},n),xu(n.src,n.crossOrigin,function(s,o){s?r(s,e,o):(j0(t,e,o,n),r(null,e,o))})}function VA(t,e,n,r){r=r||ji;const i=n.src;if(i.length!==6)throw"there must be 6 urls for a cubemap";const s=n.level||0,o=n.internalFormat||n.format||q,a=wr(o),c=n.format||a.format,u=n.type||H,f=n.target||Ft;if(f!==Ct)throw"target must be TEXTURE_CUBE_MAP";yu(t,e,n),n=Object.assign({},n);let l=6;const h=[],p=Qa(t,n);let d;function m(g){return function(x,b){--l,x?h.push(x):b.width!==b.height?h.push("cubemap face img is not a square: "+b.src):(dr(t,n),t.bindTexture(f,e),l===5?Qa().forEach(function(A){t.texImage2D(A,s,o,c,u,b)}):t.texImage2D(g,s,o,c,u,b),hi(n)&&t.generateMipmap(f)),l===0&&r(h.length?h:void 0,e,d)}}d=i.map(function(g,x){return xu(g,n.crossOrigin,m(p[x]))})}function GA(t,e,n,r){r=r||ji;const i=n.src,s=n.internalFormat||n.format||q,o=wr(s),a=n.format||o.format,c=n.type||H,u=n.target||Lt;if(u!==Pt&&u!==Lt)throw"target must be TEXTURE_3D or TEXTURE_2D_ARRAY";yu(t,e,n),n=Object.assign({},n);let f=i.length;const l=[];let h;const p=n.level||0;let d=n.width,m=n.height;const g=i.length;let x=!0;function b(A){return function(E,F){if(--f,E)l.push(E);else{if(dr(t,n),t.bindTexture(u,e),x){x=!1,d=n.width||F.width,m=n.height||F.height,t.texImage3D(u,p,s,d,m,g,0,a,c,null);for(let C=0;C<g;++C)t.texSubImage3D(u,p,0,0,C,d,m,1,a,c,F)}else{let C=F,w;(F.width!==d||F.height!==m)&&(w=N0(),C=w.canvas,w.canvas.width=d,w.canvas.height=m,w.drawImage(F,0,0,d,m)),t.texSubImage3D(u,p,0,0,A,d,m,1,a,c,C),w&&C===w.canvas&&(w.canvas.width=0,w.canvas.height=0)}hi(n)&&t.generateMipmap(u)}f===0&&r(l.length?l:void 0,e,h)}}h=i.map(function(A,E){return xu(A,n.crossOrigin,b(E))})}function X0(t,e,n,r){r=r||Wt.textureOptions;const i=r.target||Ft;t.bindTexture(i,e);let s=r.width,o=r.height,a=r.depth;const c=r.level||0,u=r.internalFormat||r.format||q,f=wr(u),l=r.format||f.format,h=r.type||H0(t,n,f.type);if(hr(n))n instanceof Uint8ClampedArray&&(n=new Uint8Array(n.buffer));else{const g=qb(h);n=new g(n)}const p=BA(u,h),d=n.byteLength/p;if(d%1)throw"length wrong size for format: "+Xa(t,l);let m;if(i===Pt||i===Lt)if(!s&&!o&&!a){const g=Math.cbrt(d);if(g%1!==0)throw"can't guess cube size of array of numElements: "+d;s=g,o=g,a=g}else s&&(!o||!a)?(m=gs(t,i,o,a,d/s),o=m.width,a=m.height):o&&(!s||!a)?(m=gs(t,i,s,a,d/o),s=m.width,a=m.height):(m=gs(t,i,s,o,d/a),s=m.width,o=m.height);else m=gs(t,i,s,o,d),s=m.width,o=m.height;if(q0(t),t.pixelStorei(gu,r.unpackAlignment||1),dr(t,r),i===Ct){const g=p/n.BYTES_PER_ELEMENT,x=d/6*g;ec(t,r).forEach(b=>{const A=x*b.ndx,E=n.subarray(A,A+x);t.texImage2D(b.face,c,u,s,o,0,l,h,E)})}else i===Pt||i===Lt?t.texImage3D(i,c,u,s,o,a,0,l,h,n):t.texImage2D(i,c,u,s,o,0,l,h,n);return{width:s,height:o,depth:a,type:h}}function HA(t,e,n){const r=n.target||Ft;t.bindTexture(r,e);const i=n.level||0,s=n.internalFormat||n.format||q,o=wr(s),a=n.format||o.format,c=n.type||o.type;if(dr(t,n),r===Ct)for(let u=0;u<6;++u)t.texImage2D(Oo+u,i,s,n.width,n.height,0,a,c,null);else r===Pt||r===Lt?t.texImage3D(r,i,s,n.width,n.height,n.depth,0,a,c,null):t.texImage2D(r,i,s,n.width,n.height,0,a,c,null)}function di(t,e,n){n=n||ji,e=e||Wt.textureOptions;const r=t.createTexture(),i=e.target||Ft;let s=e.width||1,o=e.height||1;const a=e.internalFormat||q;t.bindTexture(i,r),i===Ct&&(t.texParameteri(i,Vs,$s),t.texParameteri(i,Gs,$s));let c=e.src;if(c)if(typeof c=="function"&&(c=c(t,e)),typeof c=="string")$A(t,r,e,n);else if(hr(c)||Array.isArray(c)&&(typeof c[0]=="number"||Array.isArray(c[0])||hr(c[0]))){const u=X0(t,r,c,e);s=u.width,o=u.height}else Array.isArray(c)&&(typeof c[0]=="string"||Y0(c[0]))?i===Ct?VA(t,r,e,n):GA(t,r,e,n):(j0(t,r,c,e),s=c.width,o=c.height);else HA(t,r,e);return hi(e)&&Za(t,r,e,s,o,a),W0(t,r,e),r}function qA(t,e,n,r,i,s){r=r||n.width,i=i||n.height,s=s||n.depth;const o=n.target||Ft;t.bindTexture(o,e);const a=n.level||0,c=n.internalFormat||n.format||q,u=wr(c),f=n.format||u.format;let l;const h=n.src;if(h&&(hr(h)||Array.isArray(h)&&typeof h[0]=="number")?l=n.type||H0(t,h,u.type):l=n.type||u.type,o===Ct)for(let p=0;p<6;++p)t.texImage2D(Oo+p,a,c,r,i,0,f,l,null);else o===Pt||o===Lt?t.texImage3D(o,a,c,r,i,s,0,f,l,null):t.texImage2D(o,a,c,r,i,0,f,l,null)}const WA=_0,Hs=33984,jA=35048,Lo=34962,YA=34963,bu=35345,K0=35718,XA=35721,KA=35971,JA=35382,ZA=35396,QA=35398,ew=35392,tw=35395,No=5126,J0=35664,Z0=35665,Q0=35666,Au=5124,ed=35667,td=35668,nd=35669,rd=35670,id=35671,sd=35672,od=35673,ad=35674,cd=35675,ud=35676,nw=35678,rw=35680,iw=35679,sw=35682,ow=35685,aw=35686,cw=35687,uw=35688,lw=35689,fw=35690,hw=36289,dw=36292,pw=36293,wu=5125,ld=36294,fd=36295,hd=36296,mw=36298,gw=36299,xw=36300,yw=36303,bw=36306,Aw=36307,ww=36308,vw=36311,zo=3553,Uo=34067,vu=32879,$o=35866,R={};function dd(t,e){return R[e].bindPoint}function Ew(t,e){return function(n){t.uniform1f(e,n)}}function Cw(t,e){return function(n){t.uniform1fv(e,n)}}function Sw(t,e){return function(n){t.uniform2fv(e,n)}}function Fw(t,e){return function(n){t.uniform3fv(e,n)}}function Tw(t,e){return function(n){t.uniform4fv(e,n)}}function pd(t,e){return function(n){t.uniform1i(e,n)}}function md(t,e){return function(n){t.uniform1iv(e,n)}}function gd(t,e){return function(n){t.uniform2iv(e,n)}}function xd(t,e){return function(n){t.uniform3iv(e,n)}}function yd(t,e){return function(n){t.uniform4iv(e,n)}}function Dw(t,e){return function(n){t.uniform1ui(e,n)}}function Iw(t,e){return function(n){t.uniform1uiv(e,n)}}function _w(t,e){return function(n){t.uniform2uiv(e,n)}}function Rw(t,e){return function(n){t.uniform3uiv(e,n)}}function Mw(t,e){return function(n){t.uniform4uiv(e,n)}}function Bw(t,e){return function(n){t.uniformMatrix2fv(e,!1,n)}}function kw(t,e){return function(n){t.uniformMatrix3fv(e,!1,n)}}function Ow(t,e){return function(n){t.uniformMatrix4fv(e,!1,n)}}function Pw(t,e){return function(n){t.uniformMatrix2x3fv(e,!1,n)}}function Lw(t,e){return function(n){t.uniformMatrix3x2fv(e,!1,n)}}function Nw(t,e){return function(n){t.uniformMatrix2x4fv(e,!1,n)}}function zw(t,e){return function(n){t.uniformMatrix4x2fv(e,!1,n)}}function Uw(t,e){return function(n){t.uniformMatrix3x4fv(e,!1,n)}}function $w(t,e){return function(n){t.uniformMatrix4x3fv(e,!1,n)}}function Ae(t,e,n,r){const i=dd(t,e);return Ar(t)?function(s){let o,a;ko(t,s)?(o=s,a=null):(o=s.texture,a=s.sampler),t.uniform1i(r,n),t.activeTexture(Hs+n),t.bindTexture(i,o),t.bindSampler(n,a)}:function(s){t.uniform1i(r,n),t.activeTexture(Hs+n),t.bindTexture(i,s)}}function we(t,e,n,r,i){const s=dd(t,e),o=new Int32Array(i);for(let a=0;a<i;++a)o[a]=n+a;return Ar(t)?function(a){t.uniform1iv(r,o),a.forEach(function(c,u){t.activeTexture(Hs+o[u]);let f,l;ko(t,c)?(f=c,l=null):(f=c.texture,l=c.sampler),t.bindSampler(n,l),t.bindTexture(s,f)})}:function(a){t.uniform1iv(r,o),a.forEach(function(c,u){t.activeTexture(Hs+o[u]),t.bindTexture(s,c)})}}R[No]={Type:Float32Array,size:4,setter:Ew,arraySetter:Cw};R[J0]={Type:Float32Array,size:8,setter:Sw,cols:2};R[Z0]={Type:Float32Array,size:12,setter:Fw,cols:3};R[Q0]={Type:Float32Array,size:16,setter:Tw,cols:4};R[Au]={Type:Int32Array,size:4,setter:pd,arraySetter:md};R[ed]={Type:Int32Array,size:8,setter:gd,cols:2};R[td]={Type:Int32Array,size:12,setter:xd,cols:3};R[nd]={Type:Int32Array,size:16,setter:yd,cols:4};R[wu]={Type:Uint32Array,size:4,setter:Dw,arraySetter:Iw};R[ld]={Type:Uint32Array,size:8,setter:_w,cols:2};R[fd]={Type:Uint32Array,size:12,setter:Rw,cols:3};R[hd]={Type:Uint32Array,size:16,setter:Mw,cols:4};R[rd]={Type:Uint32Array,size:4,setter:pd,arraySetter:md};R[id]={Type:Uint32Array,size:8,setter:gd,cols:2};R[sd]={Type:Uint32Array,size:12,setter:xd,cols:3};R[od]={Type:Uint32Array,size:16,setter:yd,cols:4};R[ad]={Type:Float32Array,size:32,setter:Bw,rows:2,cols:2};R[cd]={Type:Float32Array,size:48,setter:kw,rows:3,cols:3};R[ud]={Type:Float32Array,size:64,setter:Ow,rows:4,cols:4};R[ow]={Type:Float32Array,size:32,setter:Pw,rows:2,cols:3};R[aw]={Type:Float32Array,size:32,setter:Nw,rows:2,cols:4};R[cw]={Type:Float32Array,size:48,setter:Lw,rows:3,cols:2};R[uw]={Type:Float32Array,size:48,setter:Uw,rows:3,cols:4};R[lw]={Type:Float32Array,size:64,setter:zw,rows:4,cols:2};R[fw]={Type:Float32Array,size:64,setter:$w,rows:4,cols:3};R[nw]={Type:null,size:0,setter:Ae,arraySetter:we,bindPoint:zo};R[rw]={Type:null,size:0,setter:Ae,arraySetter:we,bindPoint:Uo};R[iw]={Type:null,size:0,setter:Ae,arraySetter:we,bindPoint:vu};R[sw]={Type:null,size:0,setter:Ae,arraySetter:we,bindPoint:zo};R[hw]={Type:null,size:0,setter:Ae,arraySetter:we,bindPoint:$o};R[dw]={Type:null,size:0,setter:Ae,arraySetter:we,bindPoint:$o};R[pw]={Type:null,size:0,setter:Ae,arraySetter:we,bindPoint:Uo};R[mw]={Type:null,size:0,setter:Ae,arraySetter:we,bindPoint:zo};R[gw]={Type:null,size:0,setter:Ae,arraySetter:we,bindPoint:vu};R[xw]={Type:null,size:0,setter:Ae,arraySetter:we,bindPoint:Uo};R[yw]={Type:null,size:0,setter:Ae,arraySetter:we,bindPoint:$o};R[bw]={Type:null,size:0,setter:Ae,arraySetter:we,bindPoint:zo};R[Aw]={Type:null,size:0,setter:Ae,arraySetter:we,bindPoint:vu};R[ww]={Type:null,size:0,setter:Ae,arraySetter:we,bindPoint:Uo};R[vw]={Type:null,size:0,setter:Ae,arraySetter:we,bindPoint:$o};function Vo(t,e){return function(n){if(n.value)switch(t.disableVertexAttribArray(e),n.value.length){case 4:t.vertexAttrib4fv(e,n.value);break;case 3:t.vertexAttrib3fv(e,n.value);break;case 2:t.vertexAttrib2fv(e,n.value);break;case 1:t.vertexAttrib1fv(e,n.value);break;default:throw new Error("the length of a float constant value must be between 1 and 4!")}else t.bindBuffer(Lo,n.buffer),t.enableVertexAttribArray(e),t.vertexAttribPointer(e,n.numComponents||n.size,n.type||No,n.normalize||!1,n.stride||0,n.offset||0),n.divisor!==void 0&&t.vertexAttribDivisor(e,n.divisor)}}function jt(t,e){return function(n){if(n.value)if(t.disableVertexAttribArray(e),n.value.length===4)t.vertexAttrib4iv(e,n.value);else throw new Error("The length of an integer constant value must be 4!");else t.bindBuffer(Lo,n.buffer),t.enableVertexAttribArray(e),t.vertexAttribIPointer(e,n.numComponents||n.size,n.type||Au,n.stride||0,n.offset||0),n.divisor!==void 0&&t.vertexAttribDivisor(e,n.divisor)}}function Go(t,e){return function(n){if(n.value)if(t.disableVertexAttribArray(e),n.value.length===4)t.vertexAttrib4uiv(e,n.value);else throw new Error("The length of an unsigned integer constant value must be 4!");else t.bindBuffer(Lo,n.buffer),t.enableVertexAttribArray(e),t.vertexAttribIPointer(e,n.numComponents||n.size,n.type||wu,n.stride||0,n.offset||0),n.divisor!==void 0&&t.vertexAttribDivisor(e,n.divisor)}}function Eu(t,e,n){const r=n.size,i=n.count;return function(s){t.bindBuffer(Lo,s.buffer);const o=s.size||s.numComponents||r,a=o/i,c=s.type||No,f=R[c].size*o,l=s.normalize||!1,h=s.offset||0,p=f/i;for(let d=0;d<i;++d)t.enableVertexAttribArray(e+d),t.vertexAttribPointer(e+d,a,c,l,f,h+p*d),s.divisor!==void 0&&t.vertexAttribDivisor(e+d,s.divisor)}}const K={};K[No]={size:4,setter:Vo};K[J0]={size:8,setter:Vo};K[Z0]={size:12,setter:Vo};K[Q0]={size:16,setter:Vo};K[Au]={size:4,setter:jt};K[ed]={size:8,setter:jt};K[td]={size:12,setter:jt};K[nd]={size:16,setter:jt};K[wu]={size:4,setter:Go};K[ld]={size:8,setter:Go};K[fd]={size:12,setter:Go};K[hd]={size:16,setter:Go};K[rd]={size:4,setter:jt};K[id]={size:8,setter:jt};K[sd]={size:12,setter:jt};K[od]={size:16,setter:jt};K[ad]={size:4,setter:Eu,count:2};K[cd]={size:9,setter:Eu,count:3};K[ud]={size:16,setter:Eu,count:4};function bd(t){const e=t.name;return e.startsWith("gl_")||e.startsWith("webgl_")}const Vw=/(\.|\[|]|\w+)/g,Gw=t=>t>="0"&&t<="9";function Ad(t,e,n,r){const i=t.split(Vw).filter(a=>a!=="");let s=0,o="";for(;;){const a=i[s++];o+=a;const c=Gw(a[0]),u=c?parseInt(a):a;if(c&&(o+=i[s++]),s===i.length){n[u]=e;break}else{const l=i[s++],h=l==="[",p=n[u]||(h?[]:{});n[u]=p,n=p,r[o]=r[o]||function(d){return function(m){vd(d,m)}}(p),o+=l}}}function Hw(t,e){let n=0;function r(a,c,u){const f=c.name.endsWith("[0]"),l=c.type,h=R[l];if(!h)throw new Error(`unknown type: 0x${l.toString(16)}`);let p;if(h.bindPoint){const d=n;n+=c.size,f?p=h.arraySetter(t,l,d,u,c.size):p=h.setter(t,l,d,u,c.size)}else h.arraySetter&&f?p=h.arraySetter(t,u):p=h.setter(t,u);return p.location=u,p}const i={},s={},o=t.getProgramParameter(e,K0);for(let a=0;a<o;++a){const c=t.getActiveUniform(e,a);if(bd(c))continue;let u=c.name;u.endsWith("[0]")&&(u=u.substr(0,u.length-3));const f=t.getUniformLocation(e,c.name);if(f){const l=r(e,c,f);i[u]=l,Ad(u,l,s,i)}}return i}function qw(t,e){const n={},r=t.getProgramParameter(e,KA);for(let i=0;i<r;++i){const s=t.getTransformFeedbackVarying(e,i);n[s.name]={index:i,type:s.type,size:s.size}}return n}function Ww(t,e){const n=t.getProgramParameter(e,K0),r=[],i=[];for(let a=0;a<n;++a){i.push(a),r.push({});const c=t.getActiveUniform(e,a);r[a].name=c.name}[["UNIFORM_TYPE","type"],["UNIFORM_SIZE","size"],["UNIFORM_BLOCK_INDEX","blockNdx"],["UNIFORM_OFFSET","offset"]].forEach(function(a){const c=a[0],u=a[1];t.getActiveUniforms(e,i,t[c]).forEach(function(f,l){r[l][u]=f})});const s={},o=t.getProgramParameter(e,JA);for(let a=0;a<o;++a){const c=t.getActiveUniformBlockName(e,a),u={index:t.getUniformBlockIndex(e,c),usedByVertexShader:t.getActiveUniformBlockParameter(e,a,ZA),usedByFragmentShader:t.getActiveUniformBlockParameter(e,a,QA),size:t.getActiveUniformBlockParameter(e,a,ew),uniformIndices:t.getActiveUniformBlockParameter(e,a,tw)};u.used=u.usedByVertexShader||u.usedByFragmentShader,s[c]=u}return{blockSpecs:s,uniformData:r}}const Zl=/\[\d+\]\.$/,jw=(t,e)=>((t+(e-1))/e|0)*e;function Yw(t,e,n,r){if(e||n){r=r||1;const s=t.length/4;return function(o){let a=0,c=0;for(let u=0;u<s;++u){for(let f=0;f<r;++f)t[a++]=o[c++];a+=4-r}}}else return function(i){i.length?t.set(i):t[0]=i}}function Xw(t,e,n,r){const i=n.blockSpecs,s=n.uniformData,o=i[r];if(!o)return WA("no uniform block object named:",r),{name:r,uniforms:{}};const a=new ArrayBuffer(o.size),c=t.createBuffer(),u=o.index;t.bindBuffer(bu,c),t.uniformBlockBinding(e,o.index,u);let f=r+".";Zl.test(f)&&(f=f.replace(Zl,"."));const l={},h={},p={};return o.uniformIndices.forEach(function(d){const m=s[d];let g=m.name;g.startsWith(f)&&(g=g.substr(f.length));const x=g.endsWith("[0]");x&&(g=g.substr(0,g.length-3));const b=R[m.type],A=b.Type,E=x?jw(b.size,16)*m.size:b.size*m.size,F=new A(a,m.offset,E/A.BYTES_PER_ELEMENT);l[g]=F;const C=Yw(F,x,b.rows,b.cols);h[g]=C,Ad(g,C,p,h)}),{name:r,array:a,asFloat:new Float32Array(a),buffer:c,uniforms:l,setters:h}}function ya(t,e,n){return Xw(t,e.program,e.uniformBlockSpec,n)}function wd(t,e,n){const i=(e.uniformBlockSpec||e).blockSpecs[n.name];if(i){const s=i.index;return t.bindBufferRange(bu,s,n.buffer,n.offset||0,n.array.byteLength),!0}return!1}function ba(t,e,n){wd(t,e,n)&&t.bufferData(bu,n.array,jA)}function Rn(t,e){const n=t.setters;for(const r in e){const i=n[r];if(i){const s=e[r];i(s)}}}function vd(t,e){for(const n in e){const r=t[n];typeof r=="function"?r(e[n]):vd(t[n],e[n])}}function cn(t,...e){const n=t.uniformSetters||t,r=e.length;for(let i=0;i<r;++i){const s=e[i];if(Array.isArray(s)){const o=s.length;for(let a=0;a<o;++a)cn(n,s[a])}else for(const o in s){const a=n[o];a&&a(s[o])}}}function Kw(t,e){const n={},r=t.getProgramParameter(e,XA);for(let i=0;i<r;++i){const s=t.getActiveAttrib(e,i);if(bd(s))continue;const o=t.getAttribLocation(e,s.name),a=K[s.type],c=a.setter(t,o,a);c.location=o,n[s.name]=c}return n}function Jw(t,e){for(const n in e){const r=t[n];r&&r(e[n])}}function vr(t,e,n){n.vertexArrayObject?t.bindVertexArray(n.vertexArrayObject):(Jw(e.attribSetters||e,n.attribs),n.indices&&t.bindBuffer(YA,n.indices))}function Zw(t,e){const n=Hw(t,e),r=Kw(t,e),i={program:e,uniformSetters:n,attribSetters:r};return Ar(t)&&(i.uniformBlockSpec=Ww(t,e),i.transformFeedbackInfo=qw(t,e)),i}const Qw=4,Ql=5123;function Yi(t,e,n,r,i,s){n=n===void 0?Qw:n;const o=e.indices,a=e.elementType,c=r===void 0?e.numElements:r;i=i===void 0?0:i,a||o?s!==void 0?t.drawElementsInstanced(n,c,a===void 0?Ql:e.elementType,i,s):t.drawElements(n,c,a===void 0?Ql:e.elementType,i):s!==void 0?t.drawArraysInstanced(n,i,c,s):t.drawArrays(n,i,c)}const ev=36160,un=36161,tv=3553,nv=5121,rv=6402,iv=6408,sv=33190,ov=36012,av=35056,cv=36013,uv=32854,lv=32855,fv=36194,Ed=33189,Cd=6401,Sd=36168,Cu=34041,tc=36064,Ho=36096,Fd=36128,Su=33306,nc=33071,rc=9729,Td=[{format:iv,type:nv,min:rc,wrap:nc},{format:Cu}],Ke={};Ke[Cu]=Su;Ke[Cd]=Fd;Ke[Sd]=Fd;Ke[rv]=Ho;Ke[Ed]=Ho;Ke[sv]=Ho;Ke[ov]=Ho;Ke[av]=Su;Ke[cv]=Su;function hv(t,e){return Ke[t]||Ke[e]}const Yt={};Yt[uv]=!0;Yt[lv]=!0;Yt[fv]=!0;Yt[Cu]=!0;Yt[Ed]=!0;Yt[Cd]=!0;Yt[Sd]=!0;function dv(t){return Yt[t]}const pv=32;function mv(t){return t>=tc&&t<tc+pv}function gv(t,e,n,r){const i=ev,s=t.createFramebuffer();t.bindFramebuffer(i,s),n=n||t.drawingBufferWidth,r=r||t.drawingBufferHeight,e=e||Td;const o=[],a={framebuffer:s,attachments:[],width:n,height:r};return e.forEach(function(c,u){let f=c.attachment;const l=c.samples,h=c.format;let p=c.attachmentPoint||hv(h,c.internalFormat);if(p||(p=tc+u),mv(p)&&o.push(p),!f)if(l!==void 0||dv(h))f=t.createRenderbuffer(),t.bindRenderbuffer(un,f),l>1?t.renderbufferStorageMultisample(un,l,h,n,r):t.renderbufferStorage(un,h,n,r);else{const d=Object.assign({},c);d.width=n,d.height=r,d.auto===void 0&&(d.auto=!1,d.min=d.min||d.minMag||rc,d.mag=d.mag||d.minMag||rc,d.wrapS=d.wrapS||d.wrap||nc,d.wrapT=d.wrapT||d.wrap||nc),f=di(t,d)}if(R0(t,f))t.framebufferRenderbuffer(i,p,un,f);else if(ko(t,f))c.layer!==void 0?t.framebufferTextureLayer(i,p,f,c.level||0,c.layer):t.framebufferTexture2D(i,p,c.target||tv,f,c.level||0);else throw new Error("unknown attachment type");a.attachments.push(f)}),t.drawBuffers&&t.drawBuffers(o),a}function xv(t,e,n,r,i){r=r||t.drawingBufferWidth,i=i||t.drawingBufferHeight,e.width=r,e.height=i,n=n||Td,n.forEach(function(s,o){const a=e.attachments[o],c=s.format,u=s.samples;if(u!==void 0||R0(t,a))t.bindRenderbuffer(un,a),u>1?t.renderbufferStorageMultisample(un,u,c,r,i):t.renderbufferStorage(un,c,r,i);else if(ko(t,a))qA(t,a,s,r,i);else throw new Error("unknown attachment type")})}function yv(t,e,n){const r=t.createVertexArray();return t.bindVertexArray(r),e.length||(e=[e]),e.forEach(function(i){vr(t,i,n)}),t.bindVertexArray(null),{numElements:n.numElements,elementType:n.elementType,vertexArrayObject:r}}const bv=/^(.*?)_/;function Av(t,e){Xa(t,0);const n=t.getExtension(e);if(n){const r={},i=bv.exec(e)[1],s="_"+i;for(const o in n){const a=n[o],c=typeof a=="function",u=c?i:s;let f=o;o.endsWith(u)&&(f=o.substring(0,o.length-u.length)),t[f]!==void 0?!c&&t[f]!==a&&_0(f,t[f],a,o):c?t[f]=function(l){return function(){return l.apply(n,arguments)}}(a):(t[f]=a,r[f]=a)}r.constructor={name:n.constructor.name},Xa(r,0)}return n}const ef=["ANGLE_instanced_arrays","EXT_blend_minmax","EXT_color_buffer_float","EXT_color_buffer_half_float","EXT_disjoint_timer_query","EXT_disjoint_timer_query_webgl2","EXT_frag_depth","EXT_sRGB","EXT_shader_texture_lod","EXT_texture_filter_anisotropic","OES_element_index_uint","OES_standard_derivatives","OES_texture_float","OES_texture_float_linear","OES_texture_half_float","OES_texture_half_float_linear","OES_vertex_array_object","WEBGL_color_buffer_float","WEBGL_compressed_texture_atc","WEBGL_compressed_texture_etc1","WEBGL_compressed_texture_pvrtc","WEBGL_compressed_texture_s3tc","WEBGL_compressed_texture_s3tc_srgb","WEBGL_depth_texture","WEBGL_draw_buffers"];function Dd(t){for(let e=0;e<ef.length;++e)Av(t,ef[e])}function wv(t,e){const n=["webgl2","webgl","experimental-webgl"];let r=null;for(let i=0;i<n.length;++i)if(r=t.getContext(n[i],e),r){Dd(r);break}return r}function vv(t,e){return wv(t,e)}const Ev=`uniform Mark{uniform float uMinWidth;uniform float uMinHeight;uniform float uMinOpacity;uniform float uCornerRadiusTopRight;uniform float uCornerRadiusBottomRight;uniform float uCornerRadiusTopLeft;uniform float uCornerRadiusBottomLeft;};/***The vertex position wrt the rectangle specified by(x,x2,y,y2).*[0,0]=[x,y],[1,1]=[x2,y2].*The x or y component may contain fractional values if the rectangle*have been tessellated.*/in vec2 frac;out lowp vec4 vFillColor;out lowp vec4 vStrokeColor;out float vHalfStrokeWidth;out vec4 vCornerRadii; +#if defined(ROUNDED_CORNERS) || defined(STROKED) +out vec2 vPosInPixels; +#endif +out vec2 vHalfSizeInPixels;/***Clamps the minimumSize and returns an opacity that reflects the amount of clamping.*/float clampMinSize(inout float pos,float frac,float size,float minSize){if(minSize>0.0&&abs(size)<minSize){pos+=(frac-0.5)*(minSize*sign(size)-size);return abs(size)/minSize;}return 1.0;}void sort(inout float a,inout float b){if(a>b){float tmp=b;b=a;a=tmp;}}void main(void){vec2 normalizedMinSize=vec2(uMinWidth,uMinHeight)/uViewportSize;vec4 cornerRadii=vec4(uCornerRadiusTopRight,uCornerRadiusBottomRight,uCornerRadiusBottomLeft,uCornerRadiusTopLeft);float x=getScaled_x();float x2=getScaled_x2();float y=getScaled_y();float y2=getScaled_y2();sort(x,x2);sort(y,y2);float clampMargin=1.0;vec2 pos1=vec2(clamp(x,0.0-clampMargin,1.0+clampMargin),y);vec2 pos2=vec2(clamp(x2,0.0-clampMargin,1.0+clampMargin),y2);vec2 size=pos2-pos1;if(size.x<=0.0||size.y<=0.0){gl_Position=vec4(0.0,0.0,0.0,1.0);return;}vec2 pos=pos1+frac*size;size.y*=getSampleFacetHeight(pos);float opaFactor=uViewOpacity*max(uMinOpacity,clampMinSize(pos.x,frac.x,size.x,normalizedMinSize.x)*clampMinSize(pos.y,frac.y,size.y,normalizedMinSize.y));pos=applySampleFacet(pos); +#if defined(ROUNDED_CORNERS) || defined(STROKED) +float aaPadding=1.0/uDevicePixelRatio;float strokeWidth=getScaled_strokeWidth();float strokeOpacity=getScaled_strokeOpacity()*opaFactor;vec2 centeredFrac=frac-0.5;vec2 expand=centeredFrac*(strokeWidth+aaPadding)/uViewportSize;pos+=expand;vec2 sizeInPixels=size*uViewportSize;vPosInPixels=(centeredFrac+expand/size)*sizeInPixels;vHalfSizeInPixels=sizeInPixels/2.0;vCornerRadii=min(cornerRadii,min(vHalfSizeInPixels.x,vHalfSizeInPixels.y));vHalfStrokeWidth=strokeWidth/2.0;vStrokeColor=vec4(getScaled_stroke()*strokeOpacity,strokeOpacity); +#endif +gl_Position=unitToNdc(pos);float fillOpacity=getScaled_fillOpacity()*opaFactor;vFillColor=vec4(getScaled_fill()*fillOpacity,fillOpacity);setupPicking();}`,Cv=`#if defined(ROUNDED_CORNERS) || defined(STROKED) +in vec2 vPosInPixels; +#endif +in vec2 vHalfSizeInPixels;in lowp vec4 vFillColor;in lowp vec4 vStrokeColor;in float vHalfStrokeWidth;in vec4 vCornerRadii;out lowp vec4 fragColor;float sdRoundedBox(vec2 p,vec2 b,vec4 r){r.xy=p.x>0.0 ? r.xy : r.zw;r.x=p.y>0.0 ? r.x : r.y;vec2 q=abs(p)-b+r.x;return min(max(q.x,q.y),0.0)+length(max(q,0.0))-r.x;}float sdSharpBox(vec2 p,vec2 b){vec2 q=abs(p)-b;return max(q.x,q.y);}void main(void){ +#if defined(ROUNDED_CORNERS) || defined(STROKED) +#ifdef ROUNDED_CORNERS +float d=sdRoundedBox(vPosInPixels,vHalfSizeInPixels,vCornerRadii); +#else +float d=sdSharpBox(vPosInPixels,vHalfSizeInPixels); +#endif +fragColor=distanceToColor(d,vFillColor,vStrokeColor,vHalfStrokeWidth);if(fragColor.a==0.0){discard;} +#else +fragColor=vFillColor; +#endif +if(uPickingEnabled){fragColor=vPickingColor;}}`,Fu="attr_",Id="uDomain_",Sv="range_",tf="scale_",_d="getScaled_",ic="uRangeTexture_",nf=3402823466e29;function Fv(t){const e=t.match(/^(?:(\w+)-)?(\w+)$/);if(!e)throw new Error("Not a scale type: "+t);return{family:e[1]||"continuous",transform:e[2]}}function Tv(t,e){let n;if(Bo(t))n=ln(D0(t)(e));else if(V(e))if(An(t))n=Iv(e);else throw new Error(`String values are not supported on the "${t}" channel: ${e}`);else if(_i(e))n=ln(e?1:0);else if(e===null)if(An(t))n=ln([0,0,0]);else throw new Error(`null value is not supported on the "${t}" chanel.`);else n=ln(e);return` +#define ${t}_DEFINED +${n.type} ${_d}${t}() { + // Constant value + return ${n}; +}`}function Dv(t,e,n){if(Xe(n))throw new Error(`Cannot create scale for "value": ${JSON.stringify(n)}`);if(!e)throw new Error("Scale is undefined");const r=_n(t),i=Fu+t,s=Id+r,o=Sv+r,a=qs(e.type),c=a?"vec2":"float",u=e.domain?e.domain().length:void 0;let f;const l=[];l.push(""),l.push("/".repeat(70)),l.push(`// Channel: ${t}`),l.push(""),l.push(`#define ${t}_DEFINED`);const{transform:h}=Fv(e.type),p=(w,...L)=>_v.apply(null,[w,"value",...L]);let d;switch(h){case"linear":d=p("scaleLinear","domain",o);break;case"log":d=p("scaleLog","domain",o,e.base());break;case"symlog":d=p("scaleSymlog","domain",o,e.constant());break;case"pow":case"sqrt":d=p("scalePow","domain",o,e.exponent());break;case"index":case"locus":d=p("scaleBandHp","domain",o,e.paddingInner(),e.paddingOuter(),e.align(),n.band??.5);break;case"point":case"band":d=p("scaleBand","domain",o,e.paddingInner(),e.paddingOuter(),e.align(),n.band??.5);break;case"ordinal":case"null":case"identity":d=p("scaleIdentity");break;case"threshold":break;default:throw new Error(`Unsupported scale type: ${e.type}! ${t}: ${JSON.stringify(n)}`)}const m=_o(e.type)||me(e.type)&&An(t)?[0,1]:e.range?e.range():void 0;if(m&&t==r&&m.length&&m.every(be)){const w=rf(m);l.push(`const ${w.type} ${o} = ${w};`)}const g=An(t)?"vec3":"float";let x;if(An(t)){const w=ic+r;if(t==r&&l.push(`uniform sampler2D ${w};`),me(e.type))x=`getInterpolatedColor(${w}, transformed)`;else if(Ot(e.type)||Hn(e.type))x=`getDiscreteColor(${w}, int(transformed))`;else throw new Error("Problem with color scale!")}else if(e.type==="ordinal"||Hn(e.type)){const w=ic+r;t==r&&l.push(`uniform sampler2D ${w};`),x=`getDiscreteColor(${w}, int(transformed)).r`}Wi(n)?l.push(`uniform highp ${c} ${i};`):l.push(`in highp ${c} ${i};`);const b=[],A=me(e.type)&&u>2,E=Hn(e.type)||A;if(b.push("int slot = 0;"),E){const w=s;b.push(A?`while (slot < ${w}.length() - 2 && value >= ${w}[slot + 1]) { slot++; }`:`while (slot < ${w}.length() && value >= ${w}[slot]) { slot++; }`)}const F=me(e.type)||Hn(e.type)||["band","point"].includes(e.type);if(d){const w=s;F&&(a?b.push(`vec3 domain = ${w};`):b.push(`vec2 domain = vec2(${w}[slot], ${w}[slot + 1]);`)),b.push(`float transformed = ${d};`),A&&b.push(`transformed = (float(slot) + transformed) / (float(${w}.length() - 1));`)}else b.push("float transformed = float(slot);");"clamp"in e&&e.clamp()&&b.push(`transformed = clampToRange(transformed, ${rf(m)});`),b.push(`return ${x??"transformed"};`),l.push(` +${g} ${tf}${t}(${c} value) { +${b.map(w=>` ${w} +`).join("")} +}`),l.push(` +${g} ${_d}${t}() { + return ${tf}${t}(${i}); +}`);const C=l.join(` +`);if(F&&t==r){const w=me(e.type)||Hn(e.type)?u:2;f=a?`highp vec3 ${s};`:`mediump float ${s}[${w}];`}return{glsl:C,domainUniform:f}}function sc(t){if(!be(t))throw new Error(`Not a number: ${t}`);if(t==1/0)return""+nf;if(t==-1/0)return""+-nf;{let e=`${t}`;return/^(-)?\d+$/.test(e)&&(e+=".0"),e}}function ln(t){typeof t=="number"&&(t=[t]);const e=t.length;if(e<1||e>4)throw new Error("Invalid number of components: "+e);let n,r;return e>1?(n=`vec${e}`,r=`${n}(${t.map(sc).join(", ")})`):(n="float",r=sc(t[0])),Object.assign(r,{type:n,numComponents:e})}function Iv(t){const e=Bt(t).rgb();return ln([e.r,e.g,e.b].map(n=>n/255))}function rf(t){return ln([t[0],Bi(t)])}function _v(t,...e){const n=[];for(const r of e)be(r)?n.push(sc(r)):Me(r)?n.push(ln(r)):n.push(r);return`${t}(${n.join(", ")})`}function qs(t){return t=="index"||t=="locus"}const Rd=2**11,Rv=Rd-1;function Md(t,e=[]){const n=t&Rv,r=t-n;return e[0]=r,e[1]=n,e}function Mv(t){const e=t%Rd;return[t-e,e]}function Bv(t){return[...Mv(t[0]),t[1]-t[0]]}class kv{constructor(e){this.size=e,this.arrays={},this.pushers=[],this.dataUpdaters=[],this.vertexCount=0}addConverter(e,n){const r=this.createUpdater(Fu+e,n.numComponents||1,n.arrayReference),i=n.f;this.dataUpdaters.push(n.arrayReference?s=>r(i(s)):s=>r(i(s)))}createUpdater(e,n,r){if(!be(this.size))throw new Error("The number of vertices must be defined!");let i,s,o=0;const a=new Float32Array(this.size*n);if(this.arrays[e]={data:a,numComponents:n},n==1){let c=0;const u=f=>{c=+f};i=()=>{a[o++]=c},s=u}else{let c=r??[0];const u=r?f=>{}:f=>{c=f};switch(n){case 1:break;case 2:i=()=>{a[o++]=c[0],a[o++]=c[1]},s=u;break;case 3:i=()=>{a[o++]=c[0],a[o++]=c[1],a[o++]=c[2]},s=u;break;case 4:i=()=>{a[o++]=c[0],a[o++]=c[1],a[o++]=c[2],a[o++]=c[3]},s=u;break;default:throw new Error("Invalid numComponents: "+n)}}return this.pushers.push(i),s}_unrollPushAll(){let e="",n="";for(let i=0;i<this.pushers.length;i++)e+=`const p${i} = that.pushers[${i}]; +`,n+=`p${i}(); +`;const r=new Function("that",`${e} + + return function unrolledPushAll() { + ${n} + that.vertexCount++; + }; + `);this.pushAll=r(this)}pushAll(){this.size>1e5?this._unrollPushAll():this.pushAll=()=>{for(let n=0;n<this.pushers.length;n++)this.pushers[n]();this.vertexCount++},this.pushAll()}updateFromDatum(e){for(let n=0;n<this.dataUpdaters.length;n++)this.dataUpdaters[n](e)}pushFromDatum(e){this.updateFromDatum(e),this.pushAll()}}const Wn=5,Aa=127;function oc(t){const e=[];for(let d=0;d<=Aa;d++)e.push(void 0);const n=new Map;for(const d of t.chars)d.id<=Aa?e[d.id]=d:n.set(d.id,d);const r=8722;n.has(r)||n.set(r,e["-".charCodeAt(0)]);function i(d){return(d<=Aa?e[d]:n.get(d))||e[63]}function s(d){return i(d.charCodeAt(0))}const o=t.common.base,a=s("x"),c=s("X"),u=s("q"),f=a.height-Wn*2,l=c.height-Wn*2,h=u.height-a.height+u.yoffset-a.yoffset;function p(d,m=1){let g=0;for(let x=0;x<d.length;x++)g+=i(d.charCodeAt(x)).xadvance;return g/o*m}return{measureWidth:p,getCharByCode:i,getChar:s,xHeight:f,capHeight:l,descent:h,common:t.common}}const sf=2**31-1,Ov=-(2**31);function Pv(t,e,n,r=n){const i=new Int32Array(t);i.fill(sf);let s=Ov,o=!1;const a=new Int32Array(t),c=e[0],f=(e[1]-e[0])/t,l=(g,x)=>{const b=(g-c)/f,A=Math.floor(b);return ai(x&&A==b?A-1:A,0,t-1)};function h(g,x,b){x>s?s=x:o||(o=!0,console.debug("Items are not ordered properly. Disabling binned index."));const A=n(g),E=l(A,!1);i[E]>x&&(i[E]=x),a[E]<b&&(a[E]=b)}function p(g,x,b){x>s?s=x:o||(o=!0,console.debug("Items are not ordered properly. Disabling binned index."));const A=n(g),E=r(g),F=l(A,!1),C=l(E,!0);for(let w=F;w<=C;w++)i[w]>x&&(i[w]=x),a[w]<b&&(a[w]=b)}const d=(g,x,b=[0,0])=>{const A=l(g,!1),E=l(x,!0),F=i[A],C=Math.max(a[E],F);return b[0]=F,b[1]=C,b},m=()=>{for(let x=1;x<a.length;x++)a[x]<a[x-1]&&(a[x]=a[x-1]);let g=!0;for(let x=i.length-1;x>0;x--)g&&i[x]==sf?(i[x]=a[x],g=!1):i[x-1]>i[x]&&(i[x-1]=i[x]);return d};if(h.getIndex=m,p.getIndex=m,!o)return n==r?h:p}class Xi{constructor({encoders:e,numVertices:n=void 0,attributes:r=[]}){this.encoders=e,this.variableEncoders=Object.fromEntries(Object.entries(e).filter(([i,s])=>r.includes(i)&&s&&s.scale&&!s.constant)),this.allocatedVertices=n,this.variableBuilder=new kv(n);for(const[i,s]of Object.entries(this.variableEncoders)){const o=s.accessor,a=[0,0],c=qs(s.scale.type),u=s.indexer,f=u?l=>u(o(l)):c?l=>Md(o(l),a):o;this.variableBuilder.addConverter(i,{f,numComponents:c?2:1,arrayReference:c?a:void 0})}this.lastOffset=0,this.rangeMap=new Sn([],JSON.stringify)}registerBatch(e){var s;const n=this.lastOffset,r=this.variableBuilder.vertexCount,i=r-n;i&&this.rangeMap.set(e,{offset:n,count:i,xIndex:(s=this.xIndexer)==null?void 0:s.getIndex()}),this.lastOffset=r}addBatches(e){for(const[n,r]of e)this.addBatch(n,r)}addBatch(e,n,r=0,i=n.length){this.prepareXIndexer(n,r,i);for(let s=r;s<i;s++){const o=n[s];this.variableBuilder.pushFromDatum(o),this.addToXIndex(o)}this.registerBatch(e)}prepareXIndexer(e,n=0,r=n+e.length){const i=()=>{this.addToXIndex=c=>{},this.xIndexer=void 0};if(!e.length||r-n<0){i();return}const s=c=>{var u;return c&&me((u=c.scale)==null?void 0:u.type)&&c},o=s(this.variableEncoders.x),a=s(this.variableEncoders.x2);if(o){const c=o.accessor,u=a?a.accessor:c,f=[c(e[n]),u(e[r-1])];if(f[1]>f[0]){this.xIndexer=Pv(50,f,c,u);let l=this.variableBuilder.vertexCount;this.addToXIndex=h=>{let p=this.variableBuilder.vertexCount;this.xIndexer(h,l,p),l=p}}else i()}else i()}addToXIndex(e){}toArrays(){return{arrays:this.variableBuilder.arrays,vertexCount:this.variableBuilder.vertexCount,allocatedVertices:this.allocatedVertices,rangeMap:this.rangeMap}}}class Lv extends Xi{constructor({encoders:e,attributes:n,tessellationThreshold:r=1/0,visibleRange:i=[-1/0,1/0],numItems:s}){super({encoders:e,attributes:n,numVertices:r==1/0?s*6:void 0}),this.visibleRange=i,this.tessellationThreshold=r||1/0,this.updateFrac=this.variableBuilder.createUpdater("frac",2)}addBatch(e,n,r=0,i=n.length){if(i<=r)return;const s=this.encoders,[o,a]=this.visibleRange,c=h=>h.accessor||(p=>0),u=c(s.x),f=c(s.x2);this.prepareXIndexer(n,r,i);const l=[0,0];this.updateFrac(l);for(let h=r;h<i;h++){const p=n[h];let d=u(p),m=f(p);if(d>m&&([d,m]=[m,d]),m<o||d>a)continue;d<o&&(d=o),m>a&&(m=a),this.variableBuilder.updateFromDatum(p),l[0]=0,l[1]=0;const g=1;this.variableBuilder.pushAll();for(let x=0;x<=g;x++)l[0]=x/g,l[1]=0,this.variableBuilder.pushAll(),l[1]=1,this.variableBuilder.pushAll();this.variableBuilder.pushAll(),this.addToXIndex(p)}this.registerBatch(e)}}class Nv extends Xi{constructor({encoders:e,attributes:n,tessellationThreshold:r=1/0,visibleRange:i=[-1/0,1/0],numItems:s}){super({encoders:e,attributes:n,numVertices:r==1/0?s*6:void 0}),this.visibleRange=i,this.tessellationThreshold=r||1/0,this.updateSide=this.variableBuilder.createUpdater("side",1),this.updatePos=this.variableBuilder.createUpdater("pos",1)}addBatch(e,n,r=0,i=n.length){this.prepareXIndexer(n,r,i);for(let s=r;s<i;s++){const o=n[s];this.variableBuilder.updateFromDatum(o),this.updateSide(-.5),this.updatePos(0),this.variableBuilder.pushAll();const a=1;for(let c=0;c<=a;c++)this.updatePos(c/a),this.updateSide(-.5),this.variableBuilder.pushAll(),this.updateSide(.5),this.variableBuilder.pushAll();this.variableBuilder.pushAll(),this.addToXIndex(o)}this.registerBatch(e)}}class zv extends Xi{constructor({encoders:e,attributes:n,numItems:r=void 0}){super({encoders:e,attributes:n,numVertices:r})}}class Uv extends Xi{constructor({encoders:e,attributes:n,numItems:r=void 0}){super({encoders:e,attributes:n,numVertices:r})}toArrays(){const e=this.variableBuilder.arrays;for(let n of Object.values(e))n.divisor=1;return super.toArrays()}}class $v extends Xi{constructor({encoders:e,attributes:n,fontMetrics:r,properties:i,numCharacters:s=void 0}){super({encoders:e,attributes:n,numVertices:s*6}),this.metadata=r,this.metrics=r,this.properties=i;const a=e.text.channelDef;this.numberFormat=!Xe(a)&&"format"in a&&a.format?ue(a.format):c=>c,this.updateVertexCoord=this.variableBuilder.createUpdater("vertexCoord",2),this.updateTextureCoord=this.variableBuilder.createUpdater("textureCoord",2),this.updateWidth=this.variableBuilder.createUpdater("width",1)}addBatch(e,n,r=0,i=n.length){const s=this.properties.align||"left",o=this.properties.logoLetters??!1,a=this.metadata.common.base,c=this.metadata.common.scaleH;let u=-Wn;switch(this.properties.baseline){case"top":u+=this.metrics.capHeight;break;case"middle":u+=this.metrics.capHeight/2;break;case"bottom":u-=this.metrics.descent;break}const f=this.encoders.text.accessor||this.encoders.text,l=[0,0];this.updateVertexCoord(l);const h=[0,0];this.updateTextureCoord(h),this.prepareXIndexer(n,r,i);for(let p=r;p<i;p++){const d=n[p],m=this.numberFormat(f(d)),g=V(m)?m:m===null?"":""+m;if(g.length==0)continue;this.variableBuilder.updateFromDatum(d);const x=o?g.length:this.metrics.measureWidth(g);this.updateWidth(x);let b=s=="right"?-x:s=="center"?-x/2:0;if(!o){const C=this.metrics.getCharByCode(g.charCodeAt(0));b-=(C.width-C.xadvance)/a/2}let A=-.5,E=1,F=1;for(let C=0;C<g.length;C++){const w=this.metrics.getCharByCode(g.charCodeAt(C)),L=o?1:w.xadvance/a;if(w.id==32){b+=L;continue}o?(F=(w.width+Wn*2)/w.width,b=-F/2,E=(w.height+Wn*2)/w.height,A=-.5-Wn/w.height):(E=w.height/a,A=-(w.height+w.yoffset+u)/a,F=w.width/a);const Y=w.x,j=w.y;l[0]=b,l[1]=A+E,h[0]=Y/c,h[1]=j/c,this.variableBuilder.pushAll(),l[0]=b+F,l[1]=A+E,h[0]=(Y+w.width)/c,h[1]=j/c,this.variableBuilder.pushAll(),l[0]=b,l[1]=A,h[0]=Y/c,h[1]=(j+w.height)/c,this.variableBuilder.pushAll(),l[0]=b+F,l[1]=A+E,h[0]=(Y+w.width)/c,h[1]=j/c,this.variableBuilder.pushAll(),l[0]=b,l[1]=A,h[0]=Y/c,h[1]=(j+w.height)/c,this.variableBuilder.pushAll(),l[0]=b+F,l[1]=A,h[0]=(Y+w.width)/c,h[1]=(j+w.height)/c,this.variableBuilder.pushAll(),b+=L}this.addToXIndex(d)}this.registerBatch(e)}}const of=`#define PI 3.141593 +uniform View{mediump vec2 uViewOffset;mediump vec2 uViewScale;mediump vec2 uViewportSize;lowp float uDevicePixelRatio;lowp float uViewOpacity;bool uPickingEnabled;};/***Maps a coordinate on the unit scale to a normalized device coordinate.*(0,0)is at the bottom left corner.*/vec4 unitToNdc(vec2 coord){return vec4((coord*uViewScale+uViewOffset)*2.0-1.0,0.0,1.0);}vec4 unitToNdc(float x,float y){return unitToNdc(vec2(x,y));}vec4 pixelsToNdc(vec2 coord){return unitToNdc(coord/uViewportSize);}vec4 pixelsToNdc(float x,float y){return pixelsToNdc(vec2(x,y));}float linearstep(float edge0,float edge1,float x){return clamp((x-edge0)/(edge1-edge0),0.0,1.0);}/***Specialized linearstep for doing antialiasing*/float distanceToRatio(float d){return clamp(d*uDevicePixelRatio+0.5,0.0,1.0);}vec4 distanceToColor(float d,vec4 fill,vec4 stroke,float halfStrokeWidth){if(halfStrokeWidth>0.0){float sd=abs(d)-halfStrokeWidth;return mix(stroke,d<=0.0 ? fill : vec4(0.0),distanceToRatio(sd));}else{return fill*distanceToRatio(-d);}}`,Vv="uniform highp float uZero;vec3 getDiscreteColor(sampler2D s,int index){return texelFetch(s,ivec2(index % textureSize(s,0).x,0),0).rgb;}vec3 getInterpolatedColor(sampler2D s,float unitValue){return texture(s,vec2(unitValue,0.0)).rgb;}float clampToRange(float value,vec2 range){return clamp(value,min(range[0],range[1]),max(range[0],range[1]));}float scaleIdentity(float value){return value;}float scaleLinear(float value,vec2 domain,vec2 range){float domainSpan=domain[1]-domain[0];float rangeSpan=range[1]-range[0];return(value-domain[0])/domainSpan*rangeSpan+range[0];}float scaleLog(float value,vec2 domain,vec2 range,float base){return scaleLinear(log(value)/log(base),log(domain)/log(base),range);}float symlog(float value,float constant){return sign(value)*log(abs(value/constant)+1.0);}float scaleSymlog(float value,vec2 domain,vec2 range,float constant){return scaleLinear(symlog(value,constant),vec2(symlog(domain[0],constant),symlog(domain[1],constant)),range);}float scalePow(float value,vec2 domain,vec2 range,float exponent){return scaleLinear(pow(abs(value),exponent)*sign(value),pow(abs(domain),vec2(exponent))*sign(domain),range);}float scaleBand(float value,vec2 domainExtent,vec2 range,float paddingInner,float paddingOuter,float align,float band){float start=range[0];float stop=range[1];float rangeSpan=stop-start;float n=domainExtent[1]-domainExtent[0];paddingInner=int(n)>1 ? paddingInner : 0.0;float step=rangeSpan/max(1.0,n-paddingInner+paddingOuter*2.0);start+=(rangeSpan-step*(n-paddingInner))*align;float bandwidth=step*(1.0-paddingInner);return start+(value-domainExtent[0])*step+bandwidth*band;}float scaleBandHp(vec2 value,vec3 domainExtent,vec2 range,float paddingInner,float paddingOuter,float align,float band){float start=range[0];float stop=range[1];float rangeSpan=stop-start;vec2 domainStart=domainExtent.xy;float n=domainExtent[2];float step=rangeSpan/max(1.0,n-paddingInner+paddingOuter*2.0);start+=(rangeSpan-step*(n-paddingInner))*align;float bandwidth=step*(1.0-paddingInner);float inf=1.0/uZero;float hi=max(value[0]-domainStart[0],-inf);float lo=max(value[1]-domainStart[1],-inf);return dot(vec4(start,hi,lo,bandwidth),vec4(1.0,step,step,band));}",Gv=`/***Describes where a sample facet should be shown. Interpolating between the*current and target positions/heights allows for transitioning between facet*configurations.*/struct SampleFacetPosition{float pos;float height;float targetPos;float targetHeight;};/***Trasition fraction[0,1]between the current and target configurations.*/uniform float uTransitionOffset; +#if !defined(SAMPLE_FACET_UNIFORM) && !defined(SAMPLE_FACET_TEXTURE) +SampleFacetPosition getSampleFacetPos(){return SampleFacetPosition(0.0,1.0,0.0,1.0);} +#elif defined(SAMPLE_FACET_UNIFORM) +/***Location and height of the band on the Y axis on a normalized[0,1]scale.*Elements: curr pos,curr height,target pos,target height*/uniform vec4 uSampleFacet;SampleFacetPosition getSampleFacetPos(){return SampleFacetPosition(1.0-uSampleFacet.x-uSampleFacet.y,uSampleFacet.y,1.0-uSampleFacet.z-uSampleFacet.w,uSampleFacet.w);} +#elif defined(SAMPLE_FACET_TEXTURE) +uniform sampler2D uSampleFacetTexture;SampleFacetPosition getSampleFacetPos(){vec4 texel=texelFetch(uSampleFacetTexture,ivec2(int(attr_facetIndex),0),0);return SampleFacetPosition(1.0-texel.r-texel.g,texel.g,1.0-texel.r-texel.g,texel.g);} +#endif +bool isFacetedSamples(SampleFacetPosition facetPos){return facetPos!=SampleFacetPosition(0.0,1.0,0.0,1.0);}bool isFacetedSamples(){return isFacetedSamples(getSampleFacetPos());}bool isInTransit(){return uTransitionOffset>0.0;}float getTransitionFraction(float xPos){return smoothstep(0.0,0.7+uTransitionOffset,(xPos-uTransitionOffset)*2.0);}vec2 applySampleFacet(vec2 pos){SampleFacetPosition facetPos=getSampleFacetPos();if(!isFacetedSamples(facetPos)){return pos;}else if(isInTransit()){vec2 interpolated=mix(vec2(facetPos.pos,facetPos.height),vec2(facetPos.targetPos,facetPos.targetHeight),getTransitionFraction(pos.x));return vec2(pos.x,interpolated[0]+pos.y*interpolated[1]);}else{return vec2(pos.x,facetPos.pos+pos.y*facetPos.height);}}float getSampleFacetHeight(vec2 pos){SampleFacetPosition facetPos=getSampleFacetPos();if(!isFacetedSamples(facetPos)){return 1.0;}else if(isInTransit()){return mix(facetPos.height,facetPos.targetHeight,getTransitionFraction(pos.x));}else{return facetPos.height;}}`,Hv=`/**Based on concepts presented at:*https:*https:*/out highp vec4 vPickingColor;/***Passes the unique id to the fragment shader as a color if picking is enabled.*Returns true if picking is enabled.*/bool setupPicking(){if(uPickingEnabled){ +#ifdef uniqueId_DEFINED +int id=int(getScaled_uniqueId());vPickingColor=vec4(ivec4(id>>0,id>>8,id>>16,0xFF)&0xFF)/float(0xFF); +#else +vPickingColor=vec4(1.0); +#endif +return true;}return false;}`,qv="in highp vec4 vPickingColor;",bs=Symbol("cacheMap");function pr(t,e,n){let r=pi(t).get(e);return r===void 0&&(r=n(e),pi(t).set(e,r)),r}function Bd(t,e){pi(t).delete(e)}function As(t,e){const n=pi(t);for(const r of n.keys())r.startsWith(e)&&n.delete(r);pi(t).delete(e)}function kd(t){t[bs]=new Map}function pi(t){return t[bs]||kd(t),t[bs]}function Wv(t,e,n,r){const i=V(t)?t:t.name,s=!V(t)&&t.extent||[0,1];if(n===void 0&&!V(t)&&(n=t.count),i){const o=su(i);if(Ie(o)){const a=Od(o,{extent:s,count:n});return qo(e,{minMag:e.LINEAR,format:e.RGB,height:1,wrap:e.CLAMP_TO_EDGE},a,r)}else{if(Me(o))return ac(o,e);throw new Error("Unknown scheme: "+i)}}}function jv(t,e="rgb",n,r){const i=Ro(t,V(e)?e:e.type,V(e)?void 0:e.gamma),s=Od(i);return qo(n,{minMag:n.LINEAR,format:n.RGB,height:1,wrap:n.CLAMP_TO_EDGE},s,r)}function Yv(t,e,n,r){const i=Math.max(t.length,n||0),s=new Float32Array(i);for(let o=0;o<i;o++)s[o]=t[o%t.length];return qo(e,{minMag:e.NEAREST,format:e.RED,internalFormat:e.R32F,height:1},s,r)}function ac(t,e,n,r){const i=Pd(t,n);return qo(e,{minMag:e.NEAREST,format:e.RGB,height:1},i,r)}function Od(t,{extent:e=[0,1],reverse:n=!1,count:r=256}={}){const i=e[0],s=Bi(e)-i,o=Yr(r).map(a=>a/(r-1)).map(a=>i+a/s).map(t);return n&&o.reverse(),Pd(o)}function Pd(t,e){const n=Math.max(t.length,e||0),r=new Uint8Array(n*3);for(let i=0;i<n;i++){const s=Bt(t[i%t.length]).rgb();r[i*3+0]=s.r,r[i*3+1]=s.g,r[i*3+2]=s.b}return r}class Xv{constructor(e,n,r){this._container=e,this._sizeSource=n,this._shaderCache=new Map,this._listeners=[],this.rangeTextures=new WeakMap;const i=document.createElement("canvas");e.appendChild(i);const s=vv(i,{antialias:!0,depth:!1,premultipliedAlpha:!0});if(!s)throw new Error("Unable to initialize WebGL. Your browser or machine may not support it.");if(!Ar(s))throw new Error("Your web browser does not support WebGL 2.0. Chrome, Firefox, and Safari Tech Preview should work.");if(Dd(s),s.blendFunc(s.ONE,s.ONE_MINUS_SRC_ALPHA),this.canvas=i,this.gl=s,this._pickingAttachmentOptions=[{format:s.RGBA,type:s.UNSIGNED_BYTE,minMag:s.LINEAR,wrap:s.CLAMP_TO_EDGE}],this._pickingBufferInfo=gv(s,this._pickingAttachmentOptions),s.bindFramebuffer(s.FRAMEBUFFER,null),this.adjustGl(),this._resizeObserver=new ResizeObserver(o=>{this.invalidateSize(),this._emit("resize")}),this._resizeObserver.observe(this._container),this._updateDpr(),this._clearColor=[0,0,0,0],r){const o=Bt(r).rgb();this._clearColor=[o.r/255,o.g/255,o.b/255,o.opacity]}}invalidateSize(){this._logicalCanvasSize=void 0,this._updateDpr(),this.adjustGl()}_updateDpr(){this.dpr=window.devicePixelRatio}compileShader(e,n){const r="#version 300 es",i="precision mediump float;";Me(n)&&(n=n.join(` + +`));const s=this.gl,o=n.replaceAll(/ {2,}|^\s*\/\/.*$/gm,"");let a=this._shaderCache.get(o);if(!a){const c=[r,i,n].join(` + +`);a=s.createShader(e),s.shaderSource(a,c),s.compileShader(a),this._shaderCache.set(o,a)}return a}adjustGl(){const e=this.getLogicalCanvasSize();this.canvas.style.width=`${e.width}px`,this.canvas.style.height=`${e.height}px`;const n=this.getPhysicalCanvasSize(e);this.canvas.width=n.width,this.canvas.height=n.height,xv(this.gl,this._pickingBufferInfo,this._pickingAttachmentOptions)}finalize(){this._resizeObserver.unobserve(this._container),this.canvas.remove()}getPhysicalCanvasSize(e){return e=e||this.getLogicalCanvasSize(),{width:e.width*this.dpr,height:e.height*this.dpr}}getLogicalCanvasSize(){var s;if(this._logicalCanvasSize)return this._logicalCanvasSize;const e=((s=this._sizeSource)==null?void 0:s.call(this))??{width:void 0,height:void 0},n=window.getComputedStyle(this._container,null),r=e.width??this._container.clientWidth-parseFloat(n.paddingLeft)-parseFloat(n.paddingRight),i=e.height??this._container.clientHeight-parseFloat(n.paddingTop)-parseFloat(n.paddingBottom);return this._logicalCanvasSize={width:r,height:i},this._logicalCanvasSize}addEventListener(e,n){this._listeners.push({type:e,listener:n})}_emit(e){for(const n of this._listeners)n.type===e&&n.listener()}readPickingPixel(e,n){const r=this.gl;e*=this.dpr,n*=this.dpr;const i=this.getPhysicalCanvasSize().height,s=new Uint8Array(4);return r.bindFramebuffer(r.FRAMEBUFFER,this._pickingBufferInfo.framebuffer),r.readPixels(e,i-n-1,1,1,r.RGBA,r.UNSIGNED_BYTE,s),r.bindFramebuffer(r.FRAMEBUFFER,null),s}clearAll(){const e=this.gl,{width:n,height:r}=this.getPhysicalCanvasSize();e.viewport(0,0,n,r),e.disable(e.SCISSOR_TEST),e.clearColor(...this._clearColor),e.clear(e.COLOR_BUFFER_BIT)}createRangeTexture(e,n=!1){const r=this.rangeTextures.get(e);if(!n&&r)return;function i(o,a){return Ot(a.type)?a.domain().length:a.type=="threshold"?a.domain().length+1:a.type=="quantize"||a.type=="quantile"?o??4:o}const s=e.channel;if(An(s)){const o=e.getScaleProps(),a=e.getScale(),c=a.range();let u;if(o.scheme)if(a.type=="threshold"&&c)u=ac(c,this.gl,a.domain().length,r);else{let f=V(o.scheme)?void 0:o.scheme.count;f=i(f,a),u=Wv(o.scheme,this.gl,f,r)}else _o(a.type)||me(a.type)&&c.length>2?u=jv(c,o.interpolate,this.gl,r):u=ac(c,this.gl,a.domain().length,r);this.rangeTextures.set(e,u)}else{const o=e.getScale();if(o.type==="ordinal"||Hn(o.type)){const a=Bo(s)?D0(s):u=>u,c=e.getScale().range();this.rangeTextures.set(e,Yv(c.map(a),this.gl,o.domain().length,r))}}}}function Kv(t,e="",n=0){const r=/ERROR:\s*\d+:(\d+)/gi,i=[...e.matchAll(r)],s=new Map(i.map((o,a)=>{const c=parseInt(o[1]),u=i[a+1],f=u?u.index:e.length,l=e.substring(o.index,f);return[c-1,l]}));return t.split(` +`).map((o,a)=>{const c=s.get(a);return`${a+1+n}: ${o}${c?` + +^^^ ${c}`:""}`}).join(` +`)}function Jv(t,e,n){const r=t.createProgram();t.attachShader(r,e),t.attachShader(r,n),t.linkProgram(r);function i(){let s,o;if(!t.getProgramParameter(r,t.LINK_STATUS)){s=t.getProgramInfoLog(r);for(const c of[e,n])t.getShaderParameter(c,t.COMPILE_STATUS)||(s=t.getShaderInfoLog(c),o=Kv(t.getShaderSource(c),s,0)+` +Error compiling: ${s}`,t.deleteShader(c));t.deleteProgram(r)}if(s)return{message:s,detail:o}}return{program:r,getProgramErrors:i}}function qo(t,e,n,r){return r?X0(t,r,n,e):r=di(t,{...e,src:n}),r}function Zv(...t){const e={get(n,r,i){for(const s of t){const a=s()[r];if(a!==void 0)return a}},has(n,r,i){for(const s of t){const o=s();if(r in o)return!0}return!1}};return new Proxy({},e)}function Qv(t){return V(t)||be(t)||_i(t)}class vn extends Error{constructor(e,n){super(e),this.name="ViewError",this.view=n}}const eE="SAMPLE_FACET_UNIFORM",af="SAMPLE_FACET_TEXTURE";class Ki{constructor(e){this.unitView=e,this.encoders=void 0,this.bufferInfo=void 0,this.programInfo=void 0,this.vertexArrayInfo=void 0,this.domainUniformInfo=void 0,this.viewUniformInfo=void 0,this.markUniformInfo=void 0,this.markUniformsAltered=!0,this.rangeMap=new tE,this.defaultProperties={get clip(){return["x","y"].map(n=>e.getScaleResolution(n)).some(n=>(n==null?void 0:n.isZoomable())??!1)},xOffset:0,yOffset:0,minBufferSize:0},this.properties=Zv(typeof this.unitView.spec.mark=="object"?()=>this.unitView.spec.mark:()=>({}),()=>this.defaultProperties)}get opaque(){return!1}getAttributes(){throw new Error("Not implemented!")}getSupportedChannels(){return["sample","facetIndex","x","y","color","opacity","search","uniqueId"]}getDefaultEncoding(){const e={sample:void 0,uniqueId:void 0};return this.isPickingParticipant()&&(e.uniqueId={field:"_uniqueId"}),e}fixEncoding(e){return e}get encoding(){return pr(this,"encoding",()=>{const e=this.getDefaultEncoding(),n=this.unitView.getEncoding(),r=o=>{const a=this.properties[o];return Qv(a)&&{value:a}},i=Object.fromEntries(this.getSupportedChannels().map(o=>[o,r(o)]).filter(o=>o[1].value!==void 0)),s=this.fixEncoding({...e,...i,...n});for(const o of Object.keys(s))this.getSupportedChannels().includes(o)||delete s[o];return s})}getContext(){return this.unitView.context}getType(){return this.unitView.getMarkType()}initializeData(){}initializeEncoders(){this.encoders=Tb(this)}async initializeGraphics(){}updateGraphicsData(){}getSampleFacetMode(){if(this.encoders.facetIndex)return af;if(this.unitView.getLayoutAncestors().find(e=>"samples"in e.spec))return eE}createAndLinkShaders(e,n,r=[]){const i=this.getAttributes(),s="// view: "+this.unitView.getPathString();this.domainUniforms=[];let o=[];const a=this.getSampleFacetMode();a&&r.push(`#define ${a}`);for(const p of i){let d;if(p in this.encoding)d=p;else continue;const m=this.encoding[d];if(m)if(Xe(m))o.push(Tv(d,m.value));else{const g=De(m)&&m.resolutionChannel||d,x=wn(g)?this.unitView.getScaleResolution(g).getScale():Mo(),b=Dv(d,x,m);o.push(b.glsl),b.domainUniform&&this.domainUniforms.push(b.domainUniform)}}const c=this.domainUniforms.length?`layout(std140) uniform Domains { +`+this.domainUniforms.map(p=>` ${p} +`).join("")+`}; + +`:"",f=[`precision highp float; +`,s,...r,of,Vv,c,...o,Gv,Hv,e],l=[s,...r,of,qv,n],h=this.gl;this.programStatus=Jv(h,this.glHelper.compileShader(h.VERTEX_SHADER,f),this.glHelper.compileShader(h.FRAGMENT_SHADER,l))}finalizeGraphicsInitialization(){const e=this.programStatus.getProgramErrors();if(e){e.detail&&console.warn(e.detail);const n=new Error("Cannot create shader program: "+e.message);throw n.view=this.unitView,n}this.programInfo=Zw(this.gl,this.programStatus.program),delete this.programStatus,this.domainUniforms.length&&(this.domainUniformInfo=ya(this.gl,this.programInfo,"Domains")),this.viewUniformInfo=ya(this.gl,this.programInfo,"View"),this.markUniformInfo=ya(this.gl,this.programInfo,"Mark"),this.gl.useProgram(this.programInfo.program),this._setDatums(),cn(this.programInfo,{uSampleFacet:[0,1,0,1],uTransitionOffset:0,uZero:0})}registerMarkUniform(e,n,r=i=>i){const i=this.markUniformInfo.setters[e];if(Ld(n)){const s=this.unitView.context.paramBroker.createExpression(n.expr),o=()=>{i(r(s(null))),this.markUniformsAltered=!0};s.addListener(o),o()}else i(r(n)),this.markUniformsAltered=!0}_setDatums(){for(const[e,n]of Object.entries(this.encoding))if(Wi(n)){const r=this.encoders[e],i=r.indexer?r.indexer(n.datum):qs(r.scale.type)?Md(+n.datum):+n.datum;cn(this.programInfo,{[Fu+e]:i})}}deleteGraphicsData(){if(this.bufferInfo){const e=this.gl;for(let n=0;n<8;n++)e.disableVertexAttribArray(n);Object.values(this.bufferInfo.attribs).forEach(n=>this.gl.deleteBuffer(n.buffer)),this.bufferInfo.indices&&this.gl.deleteBuffer(this.bufferInfo.indices),this.bufferInfo=void 0}}updateBufferInfo(e){if(this.gl.bindVertexArray(null),this.bufferInfo&&e.vertexCount<=this.bufferInfo.allocatedVertices)for(const[n,r]of Object.entries(e.arrays))r.data&&f2(this.gl,this.bufferInfo.attribs[n],r.data,0);else this.deleteGraphicsData(),this.bufferInfo=p2(this.gl,e.arrays,{numElements:e.vertexCount}),this.bufferInfo.allocatedVertices=e.allocatedVertices,this.vertexArrayInfo=void 0}get glHelper(){return this.getContext().glHelper}get gl(){return this.glHelper.gl}onBeforeSampleAnimation(){}onAfterSampleAnimation(){}isReady(){return this.bufferInfo&&this.programInfo}isPickingParticipant(){if(this.properties.tooltip===null)return!1;for(const e of this.unitView.getLayoutAncestors())if(!e.isPickingSupported())return!1;return!0}bindOrSetMarkUniformBlock(){this.markUniformsAltered?(ba(this.gl,this.programInfo,this.markUniformInfo),this.markUniformsAltered=!1):wd(this.gl,this.programInfo,this.markUniformInfo)}prepareRender(e){const n=this.glHelper,r=this.gl,i=[];if(i.push(()=>{this.vertexArrayInfo||(this.vertexArrayInfo=yv(this.gl,this.programInfo,this.bufferInfo)),r.useProgram(this.programInfo.program)}),this.domainUniformInfo){for(const[o,a]of Object.entries(this.domainUniformInfo.setters)){const c=o.substring(Id.length),u=this.encoding[c],f=De(u)&&u.resolutionChannel||c;if(wn(f)){const l=this.unitView.getScaleResolution(f).getScale();i.push(()=>{const h=Ot(l.type)?[0,l.domain().length]:l.domain();a(qs(l.type)?Bv(h):h)})}}i.push(()=>ba(r,this.programInfo,this.domainUniformInfo))}for(const[o,a]of Object.entries(this.encoding))if(De(a)){const c=De(a)&&a.resolutionChannel||o;if(wn(c)){const u=this.unitView.getScaleResolution(c),f=n.rangeTextures.get(u);f&&i.push(()=>cn(this.programInfo,{[ic+o]:f}))}}this.getSampleFacetMode()==af&&i.push(()=>{let o;for(const a of this.unitView.getLayoutAncestors())if(o=a.getSampleFacetTexture(),o)break;if(!o)throw new Error("No facet texture available. This is bug.");cn(this.programInfo,{uSampleFacetTexture:o})});const s=(e.picking??!1)&&this.isPickingParticipant();return i.push(()=>Rn(this.viewUniformInfo,{uViewOpacity:this.unitView.getEffectiveOpacity(),uPickingEnabled:s})),this.opaque||e.picking?i.push(()=>r.disable(r.BLEND)):i.push(()=>r.enable(r.BLEND)),i}prepareSampleFacetRendering(e){const n=e.sampleFacetRenderingOptions,r=this.programInfo.uniformSetters.uSampleFacet;if(n&&r){const i=n.locSize?n.locSize.location:0,s=n.locSize?n.locSize.size:1;if(i>1||i+s<0)return!1;const o=n.targetLocSize?n.targetLocSize.location:i,a=n.targetLocSize?n.targetLocSize.size:s;this.gl.uniform4f(r.location,i,s,o,a)}return!0}render(e){}createRenderCallback(e,n){var l;if(!this.bufferInfo)throw new vn(`${this.getType()} mark has no data. This is bug.`,this.unitView);const r=this;let i;const s=(l=this.unitView.getScaleResolution("x"))==null?void 0:l.getScale(),o=s&&me(s.type),a=["index","locus"].includes(s==null?void 0:s.type)?-1:0,c=[0,0];i=h=>{if(o&&h.xIndex){const p=s.domain(),d=h.xIndex(p[0]+a,p[1],c),m=d[0],g=d[1]-m;g>0&&e(m,g)}else e(h.offset,h.count)};const u=this.rangeMap.get(void 0).count==0?n.facetId:void 0,f=this.rangeMap.get(u);return n.sampleFacetRenderingOptions?function(){f.count&&r.prepareSampleFacetRendering(n)&&i(f)}:function(){f.count&&i(f)}}setViewport(e,n){e=e.flatten();const r=this.unitView.context.devicePixelRatio,i=this.gl,s=this.properties,o=this.glHelper.getLogicalCanvasSize(),a=.5,c=(s.xOffset??0)+a,u=(s.yOffset??0)+a;let f,l=e;if(s.clip!=="never"&&(s.clip||n)){let h=0,p=0,d;if(n){if(l=e.intersect(n).flatten(),!l.isDefined())return!1;d=[e.width/l.width,e.height/l.height],p=Math.max(0,e.y2-n.y2),h=Math.min(0,e.x-n.x)}else d=[1,1];const m=[l.x,o.height-l.y2,l.width,l.height].map(A=>A*r),g=m.map(A=>Math.round(A)),[x,b]=m.map((A,E)=>A-g[E]);i.viewport(...g),i.scissor(...g),i.enable(i.SCISSOR_TEST),f={uViewOffset:[(c+h+x/r)/l.width,-(u+p-b/r)/l.height],uViewScale:d}}else{if(!e.isDefined())return!1;i.viewport(0,0,o.width*r,o.height*r),i.disable(i.SCISSOR_TEST),f={uViewOffset:[(e.x+c)/o.width,(o.height-e.y-u-e.height)/o.height],uViewScale:[e.width/o.width,e.height/o.height]}}return Rn(this.viewUniformInfo,{...f,uViewportSize:[e.width,e.height],uDevicePixelRatio:r}),ba(this.gl,this.programInfo,this.viewUniformInfo),!0}findDatumAt(e,n){}}class tE extends Sn{constructor(){super([],JSON.stringify)}get(e){let n=super.get(e);return n===void 0&&(n={offset:0,count:0,xIndex:void 0},super.set(e,n)),n}migrateEntries(e){for(const[n,r]of e.entries())Object.assign(this.get(n),r)}}function Ld(t){return typeof t=="object"&&"expr"in t&&V(t.expr)}function cc(t,e){const n=Rb(e);let r=t[e]&&{...t[e]},i=t[n]&&{...t[n]};if(!(Xe(r)||Xe(i))){if(r){if(!De(t[e]))return;if(i){if(r.type!="quantitative"){const s=(1-(r.band||1))/2;r.band=s,i.band=-s}}else if(r.type=="quantitative")i={datum:0};else{i={...r};const s=(1-(r.band??1))/2;r.band=0+s,i.band=1-s}}else r={value:0},i={value:1};t[e]=r,t[n]=i}}function Nd(t,e){t.stroke||(e?t.stroke={value:null}:t.stroke={resolutionChannel:"color",...t.color}),Xe(t.stroke)&&t.stroke.value===null&&(t.strokeWidth={value:0}),t.strokeOpacity||(t.strokeOpacity={resolutionChannel:"opacity",...t.opacity})}function zd(t,e){Xe(t.fill)&&t.fill.value===null?t.fillOpacity={value:0}:t.fill||(t.fill={resolutionChannel:"color",...t.color},!e&&!t.fillOpacity&&(t.fillOpacity={value:0})),t.fillOpacity||(e?t.fillOpacity={resolutionChannel:"opacity",...t.opacity}:t.fillOpacity={value:0})}var mi,uc,gi,lc;class nE extends Ki{constructor(n){super(n);M(this,mi);M(this,gi);Object.defineProperties(this.defaultProperties,Object.getOwnPropertyDescriptors({x2:void 0,y2:void 0,filled:!0,color:"#4c78a8",opacity:1,strokeWidth:3,cornerRadius:0,minWidth:.5,minHeight:.5,minOpacity:1,tessellationZoomThreshold:10,tessellationTiles:35}))}getAttributes(){return["uniqueId","facetIndex","x","x2","y","y2","fill","stroke","fillOpacity","strokeOpacity","strokeWidth"]}getSupportedChannels(){return[...super.getSupportedChannels(),"x2","y2","fill","stroke","fillOpacity","strokeOpacity","strokeWidth"]}get opaque(){return pr(this,"opaque",()=>!I(this,mi,uc).call(this)&&!I(this,gi,lc).call(this)&&Xe(this.encoding.fillOpacity)&&this.encoding.fillOpacity.value==1&&this.properties.minOpacity==1)&&this.unitView.getEffectiveOpacity()==1}fixEncoding(n){return cc(n,"x"),cc(n,"y"),Nd(n,this.properties.filled),zd(n,this.properties.filled),delete n.color,delete n.opacity,n}onBeforeSampleAnimation(){}onAfterSampleAnimation(){}async initializeGraphics(){await super.initializeGraphics();const n=[];I(this,mi,uc).call(this)&&n.push("ROUNDED_CORNERS"),I(this,gi,lc).call(this)&&n.push("STROKED"),this.createAndLinkShaders(Ev,Cv,n.map(r=>"#define "+r))}finalizeGraphicsInitialization(){super.finalizeGraphicsInitialization(),this.gl.useProgram(this.programInfo.program);const n=this.properties;this.registerMarkUniform("uMinWidth",n.minWidth),this.registerMarkUniform("uMinHeight",n.minHeight),this.registerMarkUniform("uMinOpacity",n.minOpacity),this.registerMarkUniform("uCornerRadiusTopRight",n.cornerRadiusTopRight??n.cornerRadius??0),this.registerMarkUniform("uCornerRadiusBottomRight",n.cornerRadiusBottomRight??n.cornerRadius??0),this.registerMarkUniform("uCornerRadiusTopLeft",n.cornerRadiusTopLeft??n.cornerRadius??0),this.registerMarkUniform("uCornerRadiusBottomLeft",n.cornerRadiusBottomLeft??n.cornerRadius??0)}updateGraphicsData(){const n=this.unitView.getCollector(),r=n.getItemCount(),i=new Lv({encoders:this.encoders,attributes:this.getAttributes(),numItems:r});i.addBatches(n.facetBatches);const s=i.toArrays();this.rangeMap.migrateEntries(s.rangeMap),this.updateBufferInfo(s)}prepareRender(n){const r=super.prepareRender(n);return r.push(()=>this.bindOrSetMarkUniformBlock()),r.push(()=>vr(this.gl,this.programInfo,this.vertexArrayInfo)),r}render(n){const r=this.gl;return this.createRenderCallback((i,s)=>{Yi(r,this.vertexArrayInfo,r.TRIANGLE_STRIP,s,i)},n)}findDatumAt(n,r){n=ze(n);const i=this.unitView.getCollector().facetBatches.get(n);if(!i)return;const s=this.encoders,o=s.x.scale.type;if(Ot(o)){const a=s.x.accessor;return i.find(c=>r==a(c))}else{const a=s.x.accessor,c=s.x2.accessor;return i.find(u=>r>=a(u)&&r<c(u))}}}mi=new WeakSet,uc=function(){const n=this.properties;return n.cornerRadius||n.cornerRadiusBottomLeft||n.cornerRadiusBottomRight||n.cornerRadiusTopLeft||n.cornerRadiusTopRight},gi=new WeakSet,lc=function(){const n=this.encoding.strokeWidth;return!(Xe(n)&&!n.value)};const rE=`out float vRadius;out float vRadiusWithPadding;out lowp vec4 vFillColor;out lowp vec4 vStrokeColor;out lowp float vShape;out lowp float vHalfStrokeWidth;out mat2 vRotationMatrix;const float CIRCLE=0.0;const float SQUARE=1.0;const float CROSS=2.0;const float DIAMOND=3.0;const float TRIANGLE_UP=4.0;const float TRIANGLE_RIGHT=5.0;const float TRIANGLE_DOWN=6.0;const float TRIANGLE_LEFT=7.0;const float TICK_UP=8.0;const float TICK_RIGHT=9.0;const float TICK_DOWN=10.0;const float TICK_LEFT=11.0;float computeSemanticThresholdFactor(){return getScaled_semanticScore()>=uSemanticThreshold ? 1.0 : 0.0;}/***Computes a scaling factor for the points in a sample-faceted view.*/float getDownscaleFactor(vec2 pos){if(!isFacetedSamples()){return 1.0;}float sampleFacetHeight=getSampleFacetHeight(pos);float maxPointDiameter=sqrt(uMaxPointSize);float factor=sampleFacetHeight*uViewportSize.y*uMaxRelativePointDiameter;return clamp(0.0,maxPointDiameter,factor)/maxPointDiameter;}vec2 getDxDy(){ +#if defined(dx_DEFINED) || defined(dy_DEFINED) +return vec2(getScaled_dx(),getScaled_dy())/uViewportSize; +#else +return vec2(0.0,0.0); +#endif +}void main(void){float shapeAngle=0.0;float semanticThresholdFactor=computeSemanticThresholdFactor();if(semanticThresholdFactor<=0.0){gl_PointSize=0.0;gl_Position=vec4(100.0,0.0,0.0,0.0);return;}float size=getScaled_size();vec2 pos=vec2(getScaled_x(),getScaled_y())+getDxDy();gl_Position=unitToNdc(applySampleFacet(pos));float strokeWidth=getScaled_strokeWidth();float diameter=sqrt(size)*uScaleFactor*semanticThresholdFactor*getDownscaleFactor(pos);float opacity=uViewOpacity;if(strokeWidth<=0.0||uInwardStroke){float minDiameter=1.0/uDevicePixelRatio;if(diameter<minDiameter){opacity*=pow(diameter/minDiameter,2.5);diameter=minDiameter;}}float fillOpa=getScaled_fillOpacity()*opacity;float strokeOpa=getScaled_strokeOpacity()*opacity;vShape=getScaled_shape();bool circle=vShape==0.0;if(vShape>TICK_UP&&vShape<=TICK_LEFT){shapeAngle=(vShape-TICK_UP)*90.0;vShape=TICK_UP;}else if(vShape>TRIANGLE_UP&&vShape<=TRIANGLE_LEFT){shapeAngle=(vShape-TRIANGLE_UP)*90.0;vShape=TRIANGLE_UP;}float angleInDegrees=getScaled_angle();float angle=-(shapeAngle+angleInDegrees)*PI/180.0;float sinTheta=sin(angle);float cosTheta=cos(angle);vRotationMatrix=mat2(cosTheta,sinTheta,-sinTheta,cosTheta);float roomForRotation=circle ? 1.0 : sin(mod(angle,PI/2.0)+PI/4.0)/sin(PI/4.0);float aaPadding=1.0/uDevicePixelRatio;float rotationPadding=(diameter*roomForRotation)-diameter;float strokePadding=uInwardStroke ? 0.0 : strokeWidth*(circle ? 1.0 : sqrt(3.0));float padding=rotationPadding+strokePadding+aaPadding;gl_PointSize=(diameter+padding)*uDevicePixelRatio;vRadius=diameter/2.0;vRadiusWithPadding=vRadius+padding/2.0;vHalfStrokeWidth=strokeWidth/2.0;vFillColor=vec4(getScaled_fill()*fillOpa,fillOpa);vStrokeColor=vec4(getScaled_stroke()*strokeOpa,strokeOpa);setupPicking();}`,iE="const lowp vec4 white=vec4(1.0);const lowp vec4 black=vec4(0.0,0.0,0.0,1.0);in float vRadius;in float vRadiusWithPadding;in lowp vec4 vFillColor;in lowp vec4 vStrokeColor;in lowp float vShape;in lowp float vHalfStrokeWidth;in mat2 vRotationMatrix;out lowp vec4 fragColor;const float CIRCLE=0.0;const float SQUARE=1.0;const float CROSS=2.0;const float DIAMOND=3.0;const float TRIANGLE_UP=4.0;const float TICK_UP=8.0;float circle(vec2 p,float r){return length(p)-r;}float square(vec2 p,float r){p=abs(p);return max(p.x,p.y)-r;}float tickUp(vec2 p,float r){float halfR=r*0.5;p.y+=halfR;p=abs(p);return max(p.x-r*0.15,p.y-halfR);}float equilateralTriangle(vec2 p,float r){p.y=-p.y;float k=sqrt(3.0);float kr=k*r;p.y-=kr/2.0;return max((abs(p.x)*k+p.y)/2.0,-p.y-kr);}float crossShape(vec2 p,float r){p=abs(p);vec2 b=vec2(0.4,1.0)*r;vec2 v=abs(p)-b.xy;vec2 h=abs(p)-b.yx;return min(max(v.x,v.y),max(h.x,h.y));}float diamond(vec2 p,float r){p=abs(p);return(max(abs(p.x-p.y),abs(p.x+p.y))-r)/sqrt(2.0);}void main(){float d;vec2 p=vRotationMatrix*(2.0*gl_PointCoord-1.0)*vRadiusWithPadding;float r=vRadius;if(vShape==CIRCLE){d=circle(p,r);}else if(vShape==SQUARE){d=square(p,r);}else if(vShape==CROSS){d=crossShape(p,r);}else if(vShape==DIAMOND){d=diamond(p,r);}else if(vShape==TRIANGLE_UP){d=equilateralTriangle(p,r);}else if(vShape==TICK_UP){d=tickUp(p,r);}else{d=0.0;}if(!uPickingEnabled){lowp vec4 fillColor=mix(vFillColor,white,-d*uGradientStrength/vRadius);fragColor=distanceToColor(d+(uInwardStroke ? vHalfStrokeWidth : 0.0),fillColor,vStrokeColor,vHalfStrokeWidth);}else if(d-vHalfStrokeWidth<=0.0){fragColor=vPickingColor;}else{discard;}}",sE="uniform Mark{/***The stroke should only grow inwards,e.g,the diameter/outline is not affected by the stroke width.*Thus,a point that has a zero size has no visible stroke. This allows strokes to be used with*geometric zoom,etc.*/uniform bool uInwardStroke;uniform lowp float uMaxRelativePointDiameter;uniform mediump float uScaleFactor;uniform mediump float uMaxPointSize;uniform mediump float uZoomLevel;uniform highp float uSemanticThreshold;uniform mediump float uGradientStrength;};",ut=1,Xt=2,Tu=4,oE={};class X{get behavior(){return 0}constructor(){this.children=[],this.parent=void 0,this.completed=!1}reset(){this.completed=!1;for(const e of this.children)e.reset()}initialize(){}_updatePropagator(){this._propagate=Function("children",Yr(this.children.length).map(e=>`const child${e} = children[${e}];`).join(` +`)+`return function propagate(datum) {${Yr(this.children.length).map(e=>`child${e}.handle(datum);`).join(` +`)}}`)(this.children)}setParent(e){this.parent=e}addChild(e){if(e.parent)throw new Error("Cannot add the child! It already has a parent.");return this.children.push(e),e.setParent(this),this._updatePropagator(),this}adopt(e){e.parent&&e.parent.removeChild(e),this.addChild(e)}adoptChildrenOf(e){for(const n of e.children)this.adopt(n)}insertAsParent(e){if(this.isRoot())throw new Error("Cannot insert a new parent for a root node!");e.parent=this.parent,this.parent.children[this.parent.children.indexOf(this)]=e,this.parent._updatePropagator(),this.parent=void 0,e.addChild(this)}removeChild(e){const n=this.children.indexOf(e);if(n>-1)this.children.splice(n,1),e.parent=void 0,this._updatePropagator();else throw new Error("Trying to remove an unknown child node!")}excise(){if(this.isRoot())throw new Error("Cannot excise root node!");if(this.isTerminal())this.parent.removeChild(this);else if(this.children.length==1){const e=this.children[0];e.setParent(this.parent),this.parent.children[this.parent.children.indexOf(this)]=e,this.parent._updatePropagator(),this.setParent(void 0),this.children.length=0}else throw new Error("Cannot excise a node that has multiple children!")}isRoot(){return!this.parent}isBranching(){return this.children.length>1}isTerminal(){return this.children.length==0}visit(e){e(this);for(const n of this.children)n.visit(e);e.afterChildren&&e.afterChildren(this)}subtreeToString(e=0){const n=this.children.map(r=>r.subtreeToString(e+1)).join("");return`${" ".repeat(e*2)}* ${this.constructor.name}${("identifier"in this&&this.identifier?": "+this.identifier:"")??""} +${n}`}getGlobalObject(){return this.parent?this.parent.getGlobalObject():oE}handle(e){this._propagate(e)}complete(){this.completed=!0;for(const e of this.children)e.complete()}beginBatch(e){for(const n of this.children)n.beginBatch(e)}_propagate(e){}}function Ud(t){return t.type=="file"}function aE(t){return t.type=="facet"}class $d extends X{constructor(e){super(),this.k=e.size||500,this.reset()}reset(){super.reset(),this.reservoir=[],this.W=void 0,this.ingester=this._initialIngester}_initialIngester(e){this.reservoir.push(e),this.reservoir.length==this.k&&(this.W=Math.exp(Math.log(Math.random())/this.k),this.i=this.k,this.next=this.i,this.ingester=this._finalIngester,this._setNextStop())}_finalIngester(e){++this.i==this.next&&(this.reservoir[Math.floor(Math.random()*this.k)]=e,this.W*=Math.exp(Math.log(Math.random())/this.k),this._setNextStop())}_setNextStop(){this.next+=Math.floor(Math.log(Math.random())/Math.log(1-this.W))+1}handle(e){this.ingester(e)}complete(){for(const e of this.reservoir)this._propagate(e);super.complete()}}function cE(t,e,n){const r=new $d({type:"sample",size:t});for(const i of e)r.handle(n(i));return r.complete(),r.reservoir}const uE={};class lE extends Ki{constructor(e){super(e),Object.defineProperties(this.defaultProperties,Object.getOwnPropertyDescriptors({x:.5,y:.5,color:"#4c78a8",filled:!0,opacity:1,size:100,semanticScore:0,shape:"circle",strokeWidth:2,fillGradientStrength:0,dx:0,dy:0,angle:0,sampleFacetPadding:.1,semanticZoomFraction:.02}))}getAttributes(){return["inwardStroke","uniqueId","facetIndex","x","y","size","semanticScore","shape","strokeWidth","gradientStrength","dx","dy","fill","stroke","fillOpacity","strokeOpacity","angle"]}getSupportedChannels(){return[...super.getSupportedChannels(),"size","semanticScore","shape","strokeWidth","dx","dy","fill","stroke","fillOpacity","strokeOpacity","angle"]}getDefaultEncoding(){return{...super.getDefaultEncoding(),...uE}}fixEncoding(e){return Nd(e,this.properties.filled),zd(e,this.properties.filled),delete e.color,delete e.opacity,e}initializeData(){super.initializeData();const e=this.unitView.getAccessor("semanticScore");e&&(this.sampledSemanticScores=Float32Array.from(cE(1e4,this.unitView.getCollector().getData(),e)),this.sampledSemanticScores.sort((n,r)=>n-r))}async initializeGraphics(){await super.initializeGraphics(),this.createAndLinkShaders(rE,iE,[sE])}finalizeGraphicsInitialization(){super.finalizeGraphicsInitialization(),this.gl.useProgram(this.programInfo.program);const e=this.properties;Rn(this.markUniformInfo,{uInwardStroke:!!e.inwardStroke,uGradientStrength:+e.fillGradientStrength,uMaxRelativePointDiameter:1-2*e.sampleFacetPadding})}updateGraphicsData(){const e=this.unitView.getCollector(),n=e.getItemCount(),r=new zv({encoders:this.encoders,attributes:this.getAttributes(),numItems:Math.max(n,this.properties.minBufferSize||0)});r.addBatches(e.facetBatches);const i=r.toArrays();this.rangeMap.migrateEntries(i.rangeMap),this.updateBufferInfo(i)}_getGeometricScaleFactor(){const e=Math.pow(2,this.properties.geometricZoomBound||0);return Math.pow(Math.min(1,this.unitView.getZoomLevel()/e),1/3)}_getMaxPointSize(){const e=this.encoders.size;return e.constant?e(null):e.scale.range().reduce((n,r)=>Math.max(n,r))}getSemanticThreshold(){if(this.sampledSemanticScores){const e=Math.max(0,1-this.properties.semanticZoomFraction*this.unitView.getZoomLevel());if(e<=0)return-1/0;if(e>=1)return 1/0;{const n=this.sampledSemanticScores;return Qf(n,e)}}else return-1}prepareRender(e){const n=super.prepareRender(e);return n.push(()=>{Rn(this.markUniformInfo,{uMaxPointSize:this._getMaxPointSize(),uScaleFactor:this._getGeometricScaleFactor(),uSemanticThreshold:this.getSemanticThreshold()}),this.markUniformsAltered=!0}),n.push(()=>this.bindOrSetMarkUniformBlock()),n.push(()=>vr(this.gl,this.programInfo,this.vertexArrayInfo)),n}render(e){const n=this.gl;return this.createRenderCallback((r,i)=>{i&&Yi(n,this.vertexArrayInfo,n.POINTS,i,r)},e)}}const fE="const int BUTT=0;const int SQUARE=1;const int ROUND=2;in float pos;in float side;out vec4 vColor;out float vSize;out float vNormalLengthInPixels;out highp vec2 vPosInPixels;void main(void){float pixelSize=1.0/uDevicePixelRatio;float size=getScaled_size();float opacity=getScaled_opacity()*uViewOpacity;if(size<pixelSize){opacity*=size/pixelSize;size=pixelSize;}vec2 a=applySampleFacet(vec2(getScaled_x(),getScaled_y()));vec2 b=applySampleFacet(vec2(getScaled_x2(),getScaled_y2()));vec2 tangent=b-a;float offset=0.0;float relativeDiff=0.0;if(uMinLength>0.0||uStrokeCap!=BUTT){float len=length(tangent*uViewportSize);float diff=max(0.0,uMinLength-len);if(uStrokeCap!=BUTT){diff+=size;}relativeDiff=diff/len;offset=relativeDiff*(pos-0.5);}vec2 p=pos<1.0? a+tangent*(pos+offset): b+tangent*offset;float aaPadding=pixelSize;vec2 normal=normalize(vec2(-tangent.y,tangent.x)/uViewportSize);p+=normal*side*(size+aaPadding)/uViewportSize;gl_Position=unitToNdc(p);vColor=vec4(getScaled_color()*opacity,opacity);vSize=size;vNormalLengthInPixels=side*(size+aaPadding);vPosInPixels=vec2(pos,(1.0-pos))*(1.0+relativeDiff)*length(tangent*uViewportSize)-vec2(uStrokeCap!=BUTT ? size/2.0 : 0.0);setupPicking();}",hE="const int BUTT=0;const int SQUARE=1;const int ROUND=2;uniform sampler2D uDashTexture;in vec4 vColor;in float vSize;in vec2 vPosInPixels;in float vNormalLengthInPixels;out lowp vec4 fragColor;void main(void){float dpr=uDevicePixelRatio;float distanceFromEnd=-min(vPosInPixels[0],vPosInPixels[1]);float distance;if(distanceFromEnd>0.0&&uStrokeCap==ROUND){distance=length(vec2(distanceFromEnd,vNormalLengthInPixels));}else{distance=abs(vNormalLengthInPixels);}float opacity=clamp(((vSize/2.0-distance)*dpr),-0.5,0.5)+0.5;if(uDashTextureSize>0.0){float pos=(vPosInPixels[0]+uStrokeDashOffset)*dpr;float floored=floor(pos);vec2 texelPositions=(floored+vec2(0.5,1.5))/dpr/uDashTextureSize;opacity*=mix(texture(uDashTexture,vec2(texelPositions[0],0)).r,texture(uDashTexture,vec2(texelPositions[1],0)).r,clamp((pos-floored),0.0,1.0));}fragColor=vColor*opacity;if(uPickingEnabled){fragColor=vPickingColor;}}",dE="uniform Mark{uniform mediump float uMinLength;uniform mediump float uDashTextureSize;uniform lowp int uStrokeCap;uniform mediump float uStrokeDashOffset;};";class pE extends Ki{constructor(e){super(e),this.dashTextureSize=0,Object.defineProperties(this.defaultProperties,Object.getOwnPropertyDescriptors({x2:void 0,y2:void 0,size:1,color:"black",opacity:1,minLength:0,strokeDash:null,strokeDashOffset:0,strokeCap:"butt"}))}getAttributes(){return["uniqueId","facetIndex","x","x2","y","y2","size","color","opacity"]}getSupportedChannels(){return[...super.getSupportedChannels(),"x2","y2","size"]}fixEncoding(e){if(!(e.x&&e.y&&e.x2&&e.y2))if(e.x&&e.x2&&!e.y)e.y={value:.5},e.y2=e.y;else if(e.y&&e.y2&&!e.x)e.x={value:.5},e.x2=e.x;else if(e.x&&!e.y)e.y={value:0},e.y2={value:1},e.x2=e.x;else if(e.y&&!e.x)e.x={value:0},e.x2={value:1},e.y2=e.y;else if(e.x&&e.y&&e.y2)e.x2=e.x;else if(e.y&&e.x&&e.x2)e.y2=e.y;else if(e.y&&e.x)if(!e.x2&&De(e.y)&&e.y.type=="quantitative")e.x2=e.x,e.y2={datum:0};else if(!e.y2&&De(e.x)&&e.x.type=="quantitative")e.y2=e.y,e.x2={datum:0};else throw new Error("A bug!");else throw new Error("Invalid x and y encodings for rule mark: "+JSON.stringify(e));return e}async initializeGraphics(){if(await super.initializeGraphics(),this.properties.strokeDash){const e=this.gl,n=mE(this.properties.strokeDash);this.dashTexture=di(e,{mag:e.NEAREST,min:e.NEAREST,internalFormat:e.R8,format:e.RED,src:n,height:1}),this.dashTextureSize=n.length}this.createAndLinkShaders(fE,hE,[dE])}finalizeGraphicsInitialization(){super.finalizeGraphicsInitialization(),this.gl.useProgram(this.programInfo.program);const e=this.properties;this.registerMarkUniform("uMinLength",e.minLength),this.registerMarkUniform("uStrokeCap",e.strokeCap??"butt",n=>["butt","square","round"].indexOf(n)),Rn(this.markUniformInfo,{uDashTextureSize:+this.dashTextureSize}),this.markUniformsAltered=!0}updateGraphicsData(){const e=this.unitView.getCollector(),n=e.getItemCount(),r=new Nv({encoders:this.encoders,attributes:this.getAttributes(),numItems:Math.max(n,this.properties.minBufferSize||0)});r.addBatches(e.facetBatches);const i=r.toArrays();this.rangeMap.migrateEntries(i.rangeMap),this.updateBufferInfo(i)}prepareRender(e){const n=super.prepareRender(e);return n.push(()=>this.bindOrSetMarkUniformBlock()),this.dashTexture&&n.push(()=>cn(this.programInfo,{uDashTexture:this.dashTexture})),n.push(()=>vr(this.gl,this.programInfo,this.vertexArrayInfo)),n}render(e){const n=this.gl;return this.createRenderCallback((r,i)=>Yi(n,this.vertexArrayInfo,n.TRIANGLE_STRIP,i,r),e)}}function mE(t){if(t.length==0||t.length%2||t.findIndex(s=>Math.round(s)!=s||s<1||s>1e3)>=0)throw new Error("Invalid stroke dash pattern: "+JSON.stringify(t));const e=t.reduce((s,o)=>s+o),n=new Uint8Array(e);let r=!0,i=0;for(let s of t){for(;s;)n[i++]=r&&255||0,s--;r=!r}return n}const gE="uniform Mark{uniform float uArcHeightFactor;uniform float uMinArcHeight;uniform float uMinPickingSize;uniform int uShape;uniform int uOrient;uniform bool uClampApex;uniform float uMaxChordLength;uniform vec2 uArcFadingDistance;};in vec2 strip;out vec4 vColor;out float vSize;out float vNormalLengthInPixels;const int SHAPE_ARC=0;const int SHAPE_DOME=1;const int SHAPE_DIAGONAL=2;const int SHAPE_LINE=3;const int ORIENT_VERTICAL=0;const int ORIENT_HORIZONTAL=1;float distanceFromLine(vec2 pointOnLine1,vec2 pointOnLine2,vec2 point){vec2 a=point-pointOnLine1;vec2 b=pointOnLine2-pointOnLine1;vec2 proj=dot(a,b)/dot(b,b)*b;return length(a-proj);}bool isInsideViewport(vec2 point,float marginFactor){vec2 margin=uViewportSize*vec2(marginFactor);return point.x>=-margin.x&&point.x<=uViewportSize.x+margin.x&&point.y>=-margin.y&&point.y<=uViewportSize.y+margin.y;}void main(void){float pixelSize=1.0/uDevicePixelRatio;float opacity=getScaled_opacity()*uViewOpacity;vec2 p1,p2,p3,p4;vec2 a=applySampleFacet(vec2(getScaled_x(),getScaled_y()))*uViewportSize;vec2 b=applySampleFacet(vec2(getScaled_x2(),getScaled_y2()))*uViewportSize;if(uShape<=SHAPE_DOME){if(uShape==SHAPE_DOME){vec2 height=vec2(0.0);if(uOrient==ORIENT_VERTICAL){p1=vec2(min(a.x,b.x),b.y);p4=vec2(max(a.x,b.x),b.y);height=vec2(0.0,a.y-b.y);if(uClampApex){if(p4.x>0.0){p1.x=max(p1.x,-p4.x);}if(p1.x<uViewportSize.x){p4.x=min(p4.x,2.0*uViewportSize.x-p1.x);}}}else{p1=vec2(b.x,min(a.y,b.y));p4=vec2(b.x,max(a.y,b.y));height=vec2(a.x-b.x,0.0);if(uClampApex){if(p4.y>0.0){p1.y=max(p1.y,-p4.y);}if(p1.y<uViewportSize.y){p4.y=min(p4.y,2.0*uViewportSize.y-p1.y);}}}vec2 controlOffset=height/0.75;p2=p1+controlOffset;p3=p4+controlOffset;}if(uShape==SHAPE_ARC){p1=a;p4=b;vec2 chordVector=p4-p1;vec2 unitChordVector=normalize(chordVector);vec2 chordNormal=vec2(-unitChordVector.y,unitChordVector.x);float chordLength=length(chordVector);if(chordLength>uMaxChordLength){if(isInsideViewport(p1,2.0)){chordLength=uMaxChordLength;p4=p1+unitChordVector*uMaxChordLength;}else if(isInsideViewport(p4,2.0)){chordLength=uMaxChordLength;p1=p4-unitChordVector*uMaxChordLength;}}float height=max(chordLength/2.0*uArcHeightFactor,uMinArcHeight);vec2 controlOffset=chordNormal*height/0.75;p2=p1+controlOffset;p3=p4+controlOffset;}}else if(uShape==SHAPE_DIAGONAL){if(uOrient==ORIENT_VERTICAL){p1=a;p2=vec2(a.x,(a.y+b.y)/2.0);p3=vec2(b.x,(a.y+b.y)/2.0);p4=b;}else{p1=a;p2=vec2((a.x+b.x)/2.0,a.y);p3=vec2((a.x+b.x)/2.0,b.y);p4=b;}}else if(uShape==SHAPE_LINE){p1=a;p2=(a+b)/2.0;p3=p2;p4=b;}float t=smoothstep(0.0,1.0,strip.x);vec2 C1=p4-3.0*p3+3.0*p2-p1;vec2 C2=3.0*p3-6.0*p2+3.0*p1;vec2 C3=3.0*p2-3.0*p1;vec2 C4=p1;vec2 p;if(t==0.0){p=p1;}else if(t==1.0){p=p4;}else{p=C1*t*t*t+C2*t*t+C3*t+C4;}vec2 tangent=normalize(3.0*C1*t*t+2.0*C2*t+C3);vec2 normal=vec2(-tangent.y,tangent.x);float size=getScaled_size();if(size<pixelSize){opacity*=size/pixelSize;size=pixelSize;}float paddedSize=uPickingEnabled? max(size,uMinPickingSize): size+pixelSize;vNormalLengthInPixels=strip.y*paddedSize;if(uShape==SHAPE_ARC&&uArcFadingDistance[0]>0.0&&uArcFadingDistance[1]>0.0){float d=distanceFromLine(p1,p4,p);float distanceOpacity=smoothstep(uArcFadingDistance[1],uArcFadingDistance[0],d);opacity*=distanceOpacity;if(distanceOpacity<=0.0){vNormalLengthInPixels=0.0;}}p+=normal*vNormalLengthInPixels;gl_Position=pixelsToNdc(p);vec3 color=getScaled_color();vColor=vec4(color*opacity,opacity);vSize=paddedSize;setupPicking();}",xE="in vec4 vColor;in float vSize;in float vNormalLengthInPixels;out lowp vec4 fragColor;void main(void){float dpr=uDevicePixelRatio;float distance=abs(vNormalLengthInPixels);float opacity=clamp(((vSize/2.0-distance)*dpr),0.0,1.0);fragColor=vColor*opacity;if(uPickingEnabled){fragColor=vPickingColor;}}",yE=["arc","dome","diagonal","line"],bE=["vertical","horizontal"];class AE extends Ki{constructor(e){super(e),Object.defineProperties(this.defaultProperties,Object.getOwnPropertyDescriptors({x:0,x2:void 0,y:0,y2:void 0,size:1,color:"black",opacity:1,segments:101,arcHeightFactor:1,minArcHeight:1.5,minPickingSize:3,clampApex:!1,maxChordLength:5e4,arcFadingDistance:!1,linkShape:"arc",orient:"vertical"}))}getAttributes(){return["uniqueId","facetIndex","x","x2","y","y2","size","height","color","opacity"]}getSupportedChannels(){return[...super.getSupportedChannels(),"x2","y2","size"]}fixEncoding(e){return e.x2||(De(e.x)?e.x2={datum:0}:e.x2=e.x),e.y2||(De(e.y)?e.y2={datum:0}:e.y2=e.y),e}async initializeGraphics(){await super.initializeGraphics(),this.createAndLinkShaders(gE,xE)}finalizeGraphicsInitialization(){super.finalizeGraphicsInitialization(),this.gl.useProgram(this.programInfo.program);const e=this.properties;this.registerMarkUniform("uArcFadingDistance",e.arcFadingDistance,n=>n||[0,0]),this.registerMarkUniform("uArcHeightFactor",e.arcHeightFactor),this.registerMarkUniform("uMinArcHeight",e.minArcHeight),this.registerMarkUniform("uMinPickingSize",e.minPickingSize),this.registerMarkUniform("uShape",e.linkShape,n=>yE.indexOf(n)),this.registerMarkUniform("uOrient",e.orient,n=>bE.indexOf(n)),this.registerMarkUniform("uClampApex",e.clampApex,n=>!!n),this.registerMarkUniform("uMaxChordLength",e.maxChordLength)}updateGraphicsData(){const e=this.unitView.getCollector(),n=e.getItemCount(),r=new Uv({encoders:this.encoders,attributes:this.getAttributes(),numItems:n});r.addBatches(e.facetBatches);const i=r.toArrays();i.arrays.strip={data:wE(this.properties.segments),numComponents:2},this.rangeMap.migrateEntries(i.rangeMap),this.arrays=Object.fromEntries(Object.entries(i.arrays).map(([s,o])=>[s,{...o,data:void 0}])),this.updateBufferInfo(i)}prepareRender(e){const n=super.prepareRender(e);return n.push(()=>this.bindOrSetMarkUniformBlock()),n}render(e){const n=this.gl;return this.createRenderCallback((r,i)=>{this.gl.bindVertexArray(this.vertexArrayInfo.vertexArrayObject);for(const s of Object.entries(this.bufferInfo.attribs)){const[o,a]=s;a.buffer&&a.numComponents&&a.divisor&&(a.offset=r*this.arrays[o].numComponents*4)}vr(n,this.programInfo,this.bufferInfo),Yi(n,this.bufferInfo,n.TRIANGLE_STRIP,(this.properties.segments+1)*2,0,i)},e)}}function wE(t){let e=0;const n=[];for(;e<=t;e++)n.push(e/t,.5),n.push(e/t,-.5);return n}const vE=`in mediump vec2 vertexCoord;in lowp vec2 textureCoord;in float width;out vec2 vTexCoord;out vec4 vColor;out float vSlope;out float vEdgeFadeOpacity;struct RangeResult{float pos;float scale;};float minValue(vec4 v){return min(min(v.x,v.y),min(v.z,v.w));}float maxValue(vec4 v){return max(max(v.x,v.y),max(v.z,v.w));}/***All measures are in[0,1]*/RangeResult positionInsideRange(float a,float b,float width,float padding,int align,bool flush){float span=b-a;float paddedWidth=width+2.0*padding;if(a>1.0||b<0.0){return RangeResult(0.0,0.0);}float extra=max(0.0,span-paddedWidth);float pos;if(align==0){float centre=a+b;if(flush){float leftOver=max(0.0,paddedWidth-centre);centre+=min(leftOver,extra);float rightOver=max(0.0,paddedWidth+centre-2.0);centre-=min(rightOver,extra);}pos=centre/2.0;}else if(align<0){float edge=a;if(flush){float over=max(0.0,-edge);edge+=min(over,extra);}pos=edge+padding;}else{float edge=b;if(flush){float over=max(0.0,edge-1.0);edge-=min(over,extra);}pos=edge-padding;}float scale=clamp((span-padding)/paddedWidth,0.0,1.0);return RangeResult(pos,scale);}vec2 calculateRotatedDimensions(float width,mat2 rotationMatrix){vec2 a=abs(rotationMatrix*vec2(width/2.0,0.5));vec2 b=abs(rotationMatrix*vec2(width/2.0,-0.5));return vec2(max(a.x,b.x),max(a.y,b.y))*2.0;}ivec2 fixAlignForAngle(ivec2 align,float angleInDegrees){float a=mod(angleInDegrees+45.0,360.0);int x=align.x;int y=-align.y;if(a<90.0){return ivec2(x,y);}else if(a<180.0){return ivec2(y,-x);}else if(a<270.0){return ivec2(-x,y);}else{return ivec2(-y,x);}}void main(void){float opacity=getScaled_opacity()*uViewOpacity;vec2 size=vec2(getScaled_size());float x=getScaled_x();float y=getScaled_y();float scale=1.0;float angleInDegrees=getScaled_angle();float angle=-angleInDegrees*PI/180.0;float sinTheta=sin(angle);float cosTheta=cos(angle);mat2 rotationMatrix=mat2(cosTheta,sinTheta,-sinTheta,cosTheta);vec2 flushSize=calculateRotatedDimensions(width,rotationMatrix); +#if defined(x2_DEFINED) || defined(y2_DEFINED) +ivec2 align=fixAlignForAngle(uAlign,angleInDegrees); +#else +ivec2 align=uAlign; +#endif +#ifdef x2_DEFINED +float x2=getScaled_x2();if(uLogoLetter){size.x=(x2-x)*uViewportSize.x;x+=(x2-x)/2.0;}else{float x2=getScaled_x2();RangeResult result=positionInsideRange(min(x,x2),max(x,x2),size.x*scale*flushSize.x/uViewportSize.x,uPaddingX/uViewportSize.x,align.x,uFlushX);x=result.pos;scale*=result.scale;} +#endif +vec2 pos=applySampleFacet(vec2(x,y)); +#ifdef y2_DEFINED +float y2=getScaled_y2();vec2 pos2=applySampleFacet(vec2(x,y2));if(uLogoLetter){size.y=(pos2.y-pos.y)*uViewportSize.y;pos.y+=(pos2.y-pos.y)/2.0;}else{RangeResult result=positionInsideRange(min(pos.y,pos2.y),max(pos.y,pos2.y),size.y*scale*flushSize.y/uViewportSize.y,uPaddingY/uViewportSize.y,align.y,uFlushY);pos.y=result.pos;scale*=result.scale;} +#endif +if(scale<1.0){if(uSqueeze){vec2 scaleFadeExtent=vec2(3.0,6.0)/size;if(scale<scaleFadeExtent[0]){gl_Position=vec4(0.0);return;}size*=scale;opacity*=linearstep(scaleFadeExtent[0],scaleFadeExtent[1],scale);}else if(scale<1.0){gl_Position=vec4(0.0);return;}}vec2 charPos=rotationMatrix*(vertexCoord*size+uD);vec2 unitPos=pos+charPos/uViewportSize;gl_Position=unitToNdc(unitPos);vSlope=max(1.0,min(size.x,size.y)/uSdfNumerator);vColor=vec4(getScaled_color()*opacity,opacity);vTexCoord=textureCoord;if(maxValue(uViewportEdgeFadeDistance)>-pow(10.0,10.0)){vEdgeFadeOpacity=minValue(((vec4(1.0,1.0,0.0,0.0)+vec4(-1.0,-1.0,1.0,1.0)*unitPos.yxyx)*uViewportSize.yxyx-uViewportEdgeFadeDistance)/uViewportEdgeFadeWidth);}else{vEdgeFadeOpacity=1.0;}setupPicking();}`,EE="uniform sampler2D uTexture;in vec2 vTexCoord;in float vEdgeFadeOpacity;in vec4 vColor;in float vSlope;out lowp vec4 fragColor;float median(float r,float g,float b){return max(min(r,g),min(max(r,g),b));}void main(){vec3 c=texture(uTexture,vTexCoord).rgb;float sigDist=1.0-median(c.r,c.g,c.b);float slope=uLogoLetter? 0.7/length(vec2(dFdy(sigDist),dFdx(sigDist))): vSlope;float opa=clamp((sigDist-0.5)*slope+0.5,0.0,1.0);opa*=pow(clamp(vEdgeFadeOpacity,0.0,1.0),2.2);fragColor=vColor*opa;if(uPickingEnabled){fragColor=vPickingColor;}}",CE="uniform Mark{uniform mediump float uSdfNumerator;uniform mediump vec2 uD;uniform mediump vec4 uViewportEdgeFadeWidth;uniform mediump vec4 uViewportEdgeFadeDistance;uniform bool uSqueeze;uniform bool uLogoLetter;uniform lowp ivec2 uAlign;uniform mediump float uPaddingX;uniform bool uFlushX;uniform mediump float uPaddingY;uniform bool uFlushY;};",SE={left:-1,center:0,right:1},FE={top:-1,middle:0,bottom:1,alphabetic:1};class TE extends Ki{constructor(e){super(e),Object.defineProperties(this.defaultProperties,Object.getOwnPropertyDescriptors({x:.5,y:.5,x2:void 0,y2:void 0,text:"",size:11,color:"black",opacity:1,font:void 0,fontStyle:void 0,fontWeight:void 0,align:"center",baseline:"middle",dx:0,dy:0,angle:0,fitToBand:!1,squeeze:!0,paddingX:0,paddingY:0,flushX:!0,flushY:!0,logoLetters:!1,viewportEdgeFadeWidthTop:0,viewportEdgeFadeWidthRight:0,viewportEdgeFadeWidthBottom:0,viewportEdgeFadeWidthLeft:0,viewportEdgeFadeDistanceTop:-1/0,viewportEdgeFadeDistanceRight:-1/0,viewportEdgeFadeDistanceBottom:-1/0,viewportEdgeFadeDistanceLeft:-1/0})),this.font=this.properties.font?e.context.fontManager.getFont(this.properties.font,this.properties.fontStyle,this.properties.fontWeight):e.context.fontManager.getDefaultFont()}getAttributes(){return["uniqueId","facetIndex","x","x2","y","y2","color","size","opacity","angle"]}getSupportedChannels(){return[...super.getSupportedChannels(),"x2","y2","size","text","angle"]}fixEncoding(e){for(const n of br)this.properties.fitToBand&&cc(e,n);return e}async initializeGraphics(){await super.initializeGraphics(),this.createAndLinkShaders(vE,EE,[CE])}finalizeGraphicsInitialization(){super.finalizeGraphicsInitialization(),this.gl.useProgram(this.programInfo.program);const e=this.properties;Rn(this.markUniformInfo,{uPaddingX:e.paddingX,uPaddingY:e.paddingY,uFlushX:!!e.flushX,uFlushY:!!e.flushY,uAlign:[SE[e.align],FE[e.baseline]],uD:[e.dx,-e.dy],uLogoLetter:!!e.logoLetters,uSqueeze:!!e.squeeze,uViewportEdgeFadeWidth:[e.viewportEdgeFadeWidthTop,e.viewportEdgeFadeWidthRight,e.viewportEdgeFadeWidthBottom,e.viewportEdgeFadeWidthLeft],uViewportEdgeFadeDistance:[e.viewportEdgeFadeDistanceTop,e.viewportEdgeFadeDistanceRight,e.viewportEdgeFadeDistanceBottom,e.viewportEdgeFadeDistanceLeft]})}updateGraphicsData(){const e=this.unitView.getCollector(),n=e.getData(),r=this.encoding,i=this.encoders.text.accessor||this.encoders.text;let s=0;const o="format"in r.text?ue(r.text.format):u=>u;for(const u of n){const f=o(i(u)),l=V(f)?f:f===null?"":""+f;s+=l&&l.length||0}const a=new $v({encoders:this.encoders,attributes:this.getAttributes(),properties:this.properties,fontMetrics:this.font.metrics,numCharacters:Math.max(s,this.properties.minBufferSize||0)});a.addBatches(e.facetBatches);const c=a.toArrays();this.rangeMap.migrateEntries(c.rangeMap),this.updateBufferInfo(c)}prepareRender(e){const n=super.prepareRender(e);let r=.35;this.properties.logoLetters&&(r/=2);const i=this.font.metrics.common.base/(this.unitView.context.devicePixelRatio/r);return n.push(()=>{Rn(this.markUniformInfo,{uSdfNumerator:i}),this.markUniformsAltered=!0,cn(this.programInfo,{uTexture:this.font.texture})}),n.push(()=>this.bindOrSetMarkUniformBlock()),n.push(()=>vr(this.gl,this.programInfo,this.vertexArrayInfo)),n}render(e){const n=this.gl;return this.createRenderCallback((r,i)=>Yi(n,this.vertexArrayInfo,n.TRIANGLES,i,r),e)}}function cf(t,e,{spacing:n,devicePixelRatio:r,offset:i,reverse:s}={}){n=n||0,i=i||0;let o=0,a=0;for(const d of t)o+=xs(d.px)+(wa(d)?0:n),a+=xs(d.grow);o-=n;const c=Math.max(0,e-o),u=r!==void 0?d=>Math.round(d*r)/r:d=>d,f=[],l=[],h=d=>{const m=f.length;if(!m)return;const g=(d?n:0)*(s?-1:1);p-=g;for(let x=0;x<m;x++)l.push({location:p+(x+1)/(m+1)*g,size:0});p+=g,f.length=0};let p=s?Math.max(e,o):0+i;if(t.length==1&&wa(t[0]))return[{location:p,size:0}];for(let d=0;d<t.length;d++){const m=t[d];if(wa(m))f.push(m);else{h(l.length>0);const g=xs(m.px)+(a?xs(m.grow)/a*c:0);s&&(p-=g),l.push({location:u(p),size:u(g)}),s?p-=n:p+=g+n}}return p+=s?n:-n,h(!1),l}function DE(t){let e=0,n=0;for(const r of t)e=Math.max(e,r.px??0),n=Math.max(n,r.grow??0);return{px:e,grow:n}}var xi,fc;const Bu=class Bu{constructor(e,n){M(this,xi);this.width=e,this.height=n}addPadding(e){return I(this,xi,fc).call(this,e.width,e.height)}subtractPadding(e){return I(this,xi,fc).call(this,-e.width,-e.height)}};xi=new WeakSet,fc=function(e,n){return new Bu({px:(this.width.px??0)+e,grow:this.width.grow},{px:(this.height.px??0)+n,grow:this.height.grow})};let Nt=Bu;const Ur=Object.freeze({px:0,grow:0}),uf=new Nt(Ur,Ur);function wa(t){return!t.px&&!t.grow}function xs(t){return t||0}function IE(t){return t&&(be(t.px)||be(t.grow))}function Vd(t){if(Gd(t))throw new Error("parseSizeDef does not accept step-based sizes.");if(IE(t))return t;if(be(t))return{px:t,grow:0};if(t==="container")return{px:0,grow:1};if(!t)return{px:0,grow:1};throw new Error(`Invalid sizeDef: ${t}`)}class pe{constructor(e,n,r,i){this.top=e||0,this.right=n||0,this.bottom=r||0,this.left=i||0}get width(){return this.left+this.right}get height(){return this.top+this.bottom}expand(e){return e<=0?this:new pe(this.top+e,this.right+e,this.bottom+e,this.left+e)}add(e){return new pe(this.top+e.top,this.right+e.right,this.bottom+e.bottom,this.left+e.left)}subtract(e){return new pe(this.top-e.top,this.right-e.right,this.bottom-e.bottom,this.left-e.left)}union(e){return new pe(Math.max(this.top,e.top),Math.max(this.right,e.right),Math.max(this.bottom,e.bottom),Math.max(this.left,e.left))}getHorizontal(){return new pe(0,this.right,0,this.left)}getVertical(){return new pe(this.top,0,this.bottom,0)}get horizontalTotal(){return this.left+this.right}get verticalTotal(){return this.top+this.bottom}static createFromConfig(e){return typeof e=="number"?this.createUniformPadding(e):e?this.createFromRecord(e):hc}static createFromRecord(e){return new pe(e.top,e.right,e.bottom,e.left)}static zero(){return hc}static createUniformPadding(e){return new pe(e,e,e,e)}}const hc=pe.createUniformPadding(0);Object.freeze(hc);const _E=/^([A-Za-z]+:)?\/\//;function RE(t,e){if(e&&_E.test(e))return e;const n=t();return n&&e?n.endsWith("/")?n+e:n+"/"+e:n??e}const ME="VISIT_SKIP",$r="VISIT_STOP",lf=t=>t;var Xn,yi,bi,hn,kr,Ai,dc;class BE{constructor(e,n,r,i,s,o={}){M(this,hn);M(this,Ai);M(this,Xn,{});M(this,yi,{});M(this,bi,{});fe(this,"opacityFunction",lf);if(!e)throw new Error("View spec must be defined!");this.context=n,this.layoutParent=r,this.dataParent=i,this.name=e.name||s,this.spec=e,this.resolutions={scale:{},axis:{}},kd(this),this.options={blockEncodingInheritance:!1,contributesToScaleDomain:!0,...o},this.needsAxes={x:!1,y:!1}}getPadding(){return this._cache("size/padding",()=>pe.createFromConfig(this.spec.padding))}getOverhang(){return pe.zero()}isScrollable(){return this.spec.viewportWidth!=null||this.spec.viewportHeight!=null}getSize(){return this._cache("size/size",()=>this.isConfiguredVisible()?new Nt(I(this,hn,kr).call(this,"width"),I(this,hn,kr).call(this,"height")):uf)}getViewportSize(){if(!this.isScrollable())return this.getSize();if(!this.isConfiguredVisible())return uf;const e=this.getSize();return new Nt(I(this,hn,kr).call(this,"viewportWidth")??e.width,I(this,hn,kr).call(this,"viewportHeight")??e.height)}isConfiguredVisible(){return this.context.isViewConfiguredVisible(this)}isVisibleInSpec(){return this.spec.visible??!0}isVisible(){return this.getLayoutAncestors().every(e=>e.isConfiguredVisible())}getEffectiveOpacity(){var e;return this.opacityFunction(((e=this.layoutParent)==null?void 0:e.getEffectiveOpacity())??1)}getPathString(){return this.getLayoutAncestors().map(e=>e.name).reverse().join("/")}getLayoutAncestors(){return I(this,Ai,dc).call(this,"layoutParent")}getDataAncestors(){return I(this,Ai,dc).call(this,"dataParent")}handleBroadcast(e){for(const n of S(this,Xn)[e.type]||[])n(e)}_addBroadcastHandler(e,n){let r=S(this,Xn)[e];r||(r=[],S(this,Xn)[e]=r),r.push(n)}handleInteractionEvent(e,n,r){const i=r?S(this,yi):S(this,bi);for(const s of i[n.type]||[])s(e,n)}addInteractionEventListener(e,n,r){const i=r?S(this,yi):S(this,bi);let s=i[e];s||(s=[],i[e]=s),s.push(n)}visit(e){try{const n=e(this);if(e.postOrder&&e.postOrder(this),n!==$r)return n}catch(n){throw n.view=this,n}}getDescendants(){const e=[];return this.visit(n=>{e.push(n)}),e}configureViewOpacity(){(!this.opacityFunction||this.opacityFunction===lf)&&(this.opacityFunction=OE(this))}onBeforeRender(){}render(e,n,r={}){}getEncoding(){const e=this.dataParent&&!this.options.blockEncodingInheritance?this.dataParent.getEncoding():{},n=this.spec.encoding||{},r={...e,...n};for(const[i,s]of Object.entries(r))s===null&&delete r[i];return r}getFacetAccessor(e){if(this.layoutParent)return this.layoutParent.getFacetAccessor(this)}getFacetFields(e){var r;const n=this.getEncoding().sample;return qi(n)?[n.field]:(r=this.layoutParent)==null?void 0:r.getFacetFields(this)}getSampleFacetTexture(){}getScaleResolution(e){const n=_n(e);return this.getDataAncestors().map(r=>r.resolutions.scale[n]).find(r=>r)}getAxisResolution(e){const n=_n(e);return this.getDataAncestors().map(r=>r.resolutions.axis[n]).find(r=>r)}getConfiguredResolution(e,n){var r,i;return(i=(r=this.spec.resolve)==null?void 0:r[n])==null?void 0:i[e]}getConfiguredOrDefaultResolution(e,n){return this.getConfiguredResolution(e,n)??this.getConfiguredResolution("default",n)??this.getDefaultResolution(e,n)}getDefaultResolution(e,n){return"independent"}getBaseUrl(){return RE(()=>{var e;return(e=this.dataParent)==null?void 0:e.getBaseUrl()},this.spec.baseUrl)}isPickingSupported(){return!0}getTitleText(){const e=this.spec.title;if(e)return V(e)?e:e.text}_cache(e,n){return pr(this,e,n)}_invalidateCacheByPrefix(e,n="self"){switch(n){case"self":As(this,e);break;case"ancestors":for(const r of this.getLayoutAncestors())As(r,e);break;case"progeny":this.visit(r=>As(r,e));break}}invalidateSizeCache(){this._invalidateCacheByPrefix("size/","ancestors")}propagateInteractionEvent(e){}}Xn=new WeakMap,yi=new WeakMap,bi=new WeakMap,hn=new WeakSet,kr=function(e){var i;let n=this.spec[e];const r=e=="viewportWidth"||e=="viewportHeight";if(Gd(n)){if(r)throw new vn(`Cannot use step-based size with "${e}"!`,this);const s=n.step,o=(i=this.getScaleResolution(e=="width"?"x":"y"))==null?void 0:i.getScale();if(o){let a=0;if(Ot(o.type))a=o.domain().length;else if(["locus","index"].includes(o.type)){const u=o.domain();a=Bi(u)-u[0]}else throw new vn(`Cannot use step-based size with "${o.type}" scale!`,this);const c=o;return a=tu(a,c.paddingInner(),c.paddingOuter()),{px:a*s,grow:0}}else throw new vn("Cannot use 'step' size with missing scale!",this)}else return(n&&Vd(n))??(r?void 0:{px:0,grow:1})},Ai=new WeakSet,dc=function(e){const n=[];let r=this;do n.push(r),r=r[e];while(r);return n};function kE(t){return"unitsPerPixel"in t}function OE(t){const e=t.spec.opacity;if(e!==void 0){if(be(e))return n=>n*e;if(kE(e)){const n=s=>{var a;const o=(a=t.getScaleResolution(s))==null?void 0:a.getScale();if(["linear","index","locus"].includes(o==null?void 0:o.type))return o},r=e.channel?n(e.channel):n("x")??n("y");if(!r)throw new vn("Cannot find a resolved quantitative scale for dynamic opacity!",t);const i=jc().domain(e.unitsPerPixel).range(e.values).clamp(!0);return s=>{const a=Ts(r.domain())/1e3;return i(a)*s}}else if(Ld(e)){const n=t.context.paramBroker.createExpression(e.expr);return r=>n(null)*r}}return n=>n}const Gd=t=>!!(t!=null&&t.step);class Mn extends BE{constructor(e,n,r,i,s,o){super(e,n,r,i,s,o),this.spec=e}async initializeChildren(){}*[Symbol.iterator](){}replaceChild(e,n){throw new Error("Not implemented")}visit(e){let n;try{n=e(this)}catch(r){throw r.view=this,r}if(n===$r)return n;if(n!==ME){e.beforeChildren&&e.beforeChildren(this);for(const r of this){const i=r.visit(e);if(i===$r)return i}e.afterChildren&&e.afterChildren(this),e.postOrder&&e.postOrder(this)}}findDescendantByPath(e){for(const n of this)if(n.name===e[0]){if(e.length==1)return n;if(n instanceof Mn)return n.findDescendantByPath(e.slice(1))}}findChildByName(e){for(const n of this)if(n.name===e)return n}findDescendantByName(e){let n;return this.visit(r=>{if(r.name==e)return n=r,$r}),n}getDefaultResolution(e,n){return"shared"}}const ff=1;function Du(){let t=[0,1],e=[0,1],n=1,r=1,i=0,s=0,o=.5,a=0;const u=f=>(f+o-t[0])/n*r+e[0];return u.invert=f=>(f-e[0])/r*n+t[0]-o,u.domain=function(f){if(arguments.length){t=Om(f),n=t[1]-t[0];const l=t[0]===0&&t[0]===0;if(n<ff&&!l){n=ff;const h=(t[0]+t[1])/2;t[0]=h-n/2,t[1]=h+n/2}return u}else return t.slice()},u.range=function(f){return arguments.length?(e=[...f],r=e[1]-e[0],u):e},u.numberingOffset=function(f){return arguments.length?(a=f,u):a},u.padding=function(f){return arguments.length?(s=f,i=Math.min(1,f),u):i},u.paddingInner=function(f){return arguments.length?(i=Math.min(1,f),u):i},u.paddingOuter=function(f){return arguments.length?(s=f,u):s},u.align=function(f){return arguments.length?(o=Math.max(0,Math.min(1,f)),u):o},u.step=()=>r/n,u.bandwidth=()=>u.step(),u.ticks=f=>{const l=u.align(),h=u.numberingOffset();return _s(t[0]-l+h,t[1]-l+h,Math.min(f,Math.ceil(n))).filter(Number.isInteger).map(p=>p-a)},u.tickFormat=(f,l)=>{if(l)throw new Error("Index scale's tickFormat does not support a specifier!");const p=Fn(t[0],t[1],Math.min(f,Math.ceil(n)))<1e5?ue(","):ue(".3s");return d=>p(d+a)},u.copy=()=>Du().domain(t).range(e).paddingInner(i).paddingOuter(s).numberingOffset(a),u}function PE(){const t=Du().numberingOffset(1);let e;t.genome=function(r){return arguments.length?(e=r,t):e},t.ticks=r=>{if(!e)return[];const i=t.domain(),s=t.numberingOffset(),[o,a]=[Math.max(i[0],0),Math.min(i[1],e.totalSize-1)].map(f=>e.toChromosome(f)),c=Math.max(1,Fn(i[0],i[1],r)),u=[];for(let f=o.index;f<=a.index;f++){const l=e.chromosomes[f],h=Math.max(l.continuousStart+c,i[0]-(i[0]-l.continuousStart)%c),p=Math.min(l.continuousEnd-c/4,i[1]+1);for(let d=h;d<=p;d+=c){const m=d-s;m>=i[0]&&m<i[1]&&u.push(m)}}return u},t.tickFormat=(r,i)=>{if(!e)return;if(i)throw new Error("Locus scale's tickFormat does not support a specifier!");const s=t.domain(),o=s[1]-s[0],a=t.numberingOffset(),u=Fn(s[0],s[1],Math.min(r,Math.ceil(o)))<1e6?ue(","):ue(".3s"),f=l=>l-e.toChromosome(l).continuousStart;return l=>u(f(l)+a)};const n=t.copy;return t.copy=()=>n().genome(e),t}function LE(t){return t.type=="locus"}function Ws(t,e,n){if(n=n||[],t.some(o=>o===null)){if(t.every(o=>o===null))return null;throw console.warn(t),new Error("Cannot merge objects with nulls!")}const r={},i=(o,a)=>o===a||Gn(o)&&Gn(a)||Gn(o)&&a===!0||o===!0&&Re(a),s=o=>{for(let a in o){const c=o[a];if(!n.includes(a)&&c!==void 0)if(r[a]!==void 0&&!i(r[a],c))console.warn(`Conflicting property ${a} of ${e}: (${JSON.stringify(r[a])} and ${JSON.stringify(o[a])}). Using ${JSON.stringify(r[a])}.`);else{const u=r[a];if(Gn(u))Gn(c)&&(r[a]=Ws([u,c],a));else if(Gn(c)){if(!(u===!0||u===void 0))throw new Error("Bug in merge! Target is: "+u);r[a]=Ws([{},c],a)}else r[a]=c}}};for(const o of t)s(o);return r}function Gn(t){return Re(t)&&!Array.isArray(t)}/*! + * Adapted from vega-encode: + * https://github.com/vega/vega/blob/master/packages/vega-encode/src/ticks.js + * + * Copyright (c) 2015-2018, University of Washington Interactive Data Lab + * All rights reserved. + * + * BSD-3-Clause License: https://github.com/vega/vega-lite/blob/master/LICENSE + */function Hd(t,e,n){return be(e)&&n!=null&&(e=Math.min(e,~~(Ts(t.domain())/n)||1)),Re(e)&&(e.step,e=e.interval),e}function qd(t,e,n){var r=t.range(),i=Math.floor(r[0]),s=Math.ceil(Ye(r));if(i>s&&(r=s,s=i,i=r),e=e.filter(function(a){return a=t(a),i<=a&&a<=s}),n>0&&e.length>1){for(var o=[e[0],Ye(e)];e.length>n&&e.length>=3;)e=e.filter(function(a,c){return!(c%2)});e.length<3&&(e=o)}return e}function NE(t,e){return t.bins?qd(t,zE(t.bins,e)):t.ticks?t.ticks(e):t.domain()}function zE(t,e){var n=t.length,r=~~(n/(e||n));return r<2?t.slice():t.filter(function(i,s){return!(s%r)})}function UE(t,e,n){var r=t.tickFormat?t.tickFormat(e,n):n?ue(n):String;if(w0(t.type)){var i=VE(n);r=t.bins?i:$E(r,i)}return r}function $E(t,e){return function(n){return t(n)?e(n):""}}function VE(t){var e=Mt(t||",");if(e.precision==null){switch(e.precision=12,e.type){case"%":e.precision-=2;break;case"e":e.precision-=1;break}return GE(ue(e),ue(".1f")(1)[1])}else return ue(e)}function GE(t,e){return function(n){var r=t(n),i=r.indexOf(e),s,o;if(i<0)return r;for(s=HE(r,i),o=s<r.length?r.slice(s):"";--s>i;)if(r[s]!=="0"){++s;break}return r.slice(0,s)+o}}function HE(t,e){var n=t.lastIndexOf("e"),r;if(n>0)return n;for(n=t.length;--n>e;)if(r=t.charCodeAt(n),r>=48&&r<=57)return n+1}/*! + * Adapted from vega-encode: + * https://github.com/vega/vega/blob/master/packages/vega-encode/src/Scale.js + * + * Copyright (c) 2015-2018, University of Washington Interactive Data Lab + * All rights reserved. + * + * BSD-3-Clause License: https://github.com/vega/vega-lite/blob/master/LICENSE + */const qE="locus",WE="index";var jE=5;function YE(t){const e=t.type;return!t.bins&&(e===fr||e===Ui||e===$i)}function Wd(t){return me(t)&&![rt,WE,qE].includes(t)}function jd(t){return t||{warn:(e,...n)=>console.warn(e,...n)}}var XE=Ds(["set","modified","clear","type","scheme","schemeExtent","schemeCount","domain","domainMin","domainMid","domainMax","domainRaw","domainImplicit","nice","zero","bins","range","rangeStep","round","reverse","interpolate","interpolateGamma","zoom","fp64","name"]);function Yd(t,e,n){n=jd(n);for(const r in t)if(!XE[r]){if(r==="padding"&&Wd(e.type))continue;Ie(e[r])?e[r](t[r]):n.warn("Unsupported scale property: "+r)}rC(e,t,nC(e,t,QE(e,t,n)))}function KE(t,e){const n=JE(t),r=N(n);if(!r)throw new Error("Unknown scale type: "+n);const i=r();return!t.domain&&me(i.type)&&(t.domain=[0,0]),Yd(t,i,e),i}function JE(t){var e=t.type,n="",r;return e===rt?rt+"-"+fr:(ZE(t)&&(r=t.rawDomain?t.rawDomain.length:t.domain?t.domain.length+ +(t.domainMid!=null):0,n=r===2?rt+"-":r===3?yr+"-":""),(n+e||fr).toLowerCase())}function ZE(t){const e=t.type;return me(e)&&e!==d0&&e!==p0&&(t.scheme||t.range&&t.range.length&&t.range.every(V))}function QE(t,e,n){if(!t.domain)return 0;n=jd(n);var r=eC(t,e.domainRaw,n);if(r>-1)return r;var i=e.domain,s=t.type,o=e.zero||e.zero===void 0&&YE(t),a,c;return i?(Wd(s)&&e.padding&&i[0]!==Ye(i)&&(i=tC(s,i,e.range,e.padding,e.exponent,e.constant)),(o||e.domainMin!=null||e.domainMax!=null||e.domainMid!=null)&&(a=(i=i.slice()).length-1||1,o&&(i[0]>0&&(i[0]=0),i[a]<0&&(i[a]=0)),e.domainMin!=null&&(i[0]=e.domainMin),e.domainMax!=null&&(i[a]=e.domainMax),e.domainMid!=null&&(c=e.domainMid,(c<i[0]||c>i[a])&&n.warn("Scale domainMid exceeds domain min or max.",c),i.splice(a,0,c))),t.domain(Xd(s,i,n)),s===nu&&t.unknown(e.domainImplicit?Pa:void 0),e.nice&&t.nice&&t.nice(e.nice!==!0&&Hd(t,e.nice)||null),i.length):0}function eC(t,e,n){return e?(t.domain(Xd(t.type,e,n)),e.length):-1}function tC(t,e,n,r,i,s){var o=Math.abs(Ye(n)-n[0]),a=o/(o-2*r),c=t===kt?Hf(e,null,a):t===$i?Da(e,null,a,.5):t===Ui?Da(e,null,a,i||1):t===Io?om(e,null,a,s||1):Gf(e,null,a);return e=e.slice(),e[0]=c[0],e[e.length-1]=c[1],e}function Xd(t,e,n){if(w0(t)){var r=Math.abs(e.reduce(function(i,s){return i+(s<0?-1:s>0?1:0)},0));r!==e.length&&n.warn("Log scale domain includes zero: "+ao(e))}return e}function nC(t,e,n){let r=e.bins;if(r&&!Me(r)){const i=(r.start==null||r.stop==null)&&t.domain(),s=r.start==null?i[0]:r.start,o=r.stop==null?Ye(i):r.stop,a=r.step;a||W("Scale bins parameter missing step property."),r=Yr(s,o+a,a)}return r?t.bins=r:t.bins&&delete t.bins,t.type===ru&&(r?!e.domain&&!e.domainRaw&&(t.domain(r),n=r.length):t.bins=t.domain()),n}function rC(t,e,n){var r=t.type,i=e.round||!1,s=e.range;if(e.rangeStep!=null)s=iC(r,e,n);else if(e.scheme&&(s=sC(r,e,n),Ie(s))){if(t.interpolator)return t.interpolator(s);W(`Scale type ${r} does not support interpolating color schemes.`)}if(s&&_o(r))return t.interpolator(Ro(pc(s,e.reverse),e.interpolate,e.interpolateGamma));s&&e.interpolate&&t.interpolate?t.interpolate(v0(e.interpolate,e.interpolateGamma)):Ie(t.round)?t.round(i):Ie(t.rangeRound)&&t.interpolate(i?Ni:Ht),s&&t.range(pc(s,e.reverse))}function iC(t,e,n){t!==x0&&t!==ja&&W("Only band and point scales support rangeStep.");var r=(e.paddingOuter!=null?e.paddingOuter:e.padding)||0,i=t===ja?1:(e.paddingInner!=null?e.paddingInner:e.padding)||0;return[0,e.rangeStep*tu(n,i,r)]}function sC(t,e,n){var r=e.schemeExtent,i,s;return Me(e.scheme)?s=Ro(e.scheme,e.interpolate,e.interpolateGamma):(i=e.scheme.toLowerCase(),s=su(i),s||W(`Unrecognized scheme name: ${e.scheme}`)),n=t===g0?n+1:t===ru?n-1:t===Wa||t===m0?+e.schemeCount||jE:n,_o(t)?hf(s,r,e.reverse):Ie(s)?vb(hf(s,r),n):t===nu?s:s.slice(0,n)}function hf(t,e,n){return Ie(t)&&(e||n)?wb(t,pc(e||[0,1],n)):t}function pc(t,e){return e?t.slice().reverse():t}const df=ue(",d");function oC(t,e){return t.chrom+":"+df(Math.floor(t.pos+1))+"-"+(t.chrom!=e.chrom?e.chrom+":":"")+df(Math.ceil(e.pos))}const aC="https://genomespy.app/data/genomes/";class cC{constructor(e){if(this.config=e,!this.config.contigs&&typeof this.config.name!="string")throw new Error("No name has been defined for the genome assembly!");this.chromosomes=[],this.cumulativeChromPositions=new Map,this.chromosomesByName=new Map,this.startByIndex=[],this.totalSize=0,this.config.contigs&&this.setChromSizes(this.config.contigs)}get name(){return this.config.name}async load(e){if(!this.config.contigs){this.config.baseUrl?this.baseUrl=/^http(s)?/.test(this.config.baseUrl)?this.config.baseUrl:e+"/"+this.config.baseUrl:this.baseUrl=aC;try{this.setChromSizes(uC(await xo({baseURL:this.baseUrl}).load(`${this.config.name}/${this.name}.chrom.sizes`)))}catch(n){throw new Error(`Could not load chrom sizes: ${n.message}`)}}}hasChrPrefix(){return this.chromosomes.some(e=>e.name.startsWith("chr"))}setChromSizes(e){let n=0;this.startByIndex=[0];for(let r=0;r<e.length;r++){this.startByIndex.push(n);const i=e[r].size,s={...e[r],continuousStart:n,continuousEnd:n+i,continuousInterval:[n,n+i],index:r,number:r+1,odd:!(r&1)};this.chromosomes.push(s);const o=s.name.replace(/^chr/i,"");for(const a of["chr"+o,"CHR"+o,"Chr"+o,s.number,""+s.number,o,s.name])this.cumulativeChromPositions.set(a,n),this.chromosomesByName.set(a,s);n+=s.size}this.totalSize=n}getExtent(){return[0,this.totalSize]}toContinuous(e,n){let r=this.cumulativeChromPositions.get(e);if(r===void 0)throw new Error("Unknown chromosome/contig: "+e);return r+ +n}toChromosome(e){if(e>this.totalSize)return;e=Math.floor(e);const n=gr(this.startByIndex,e)-1;if(n>0&&n<=this.chromosomes.length)return this.chromosomes[n-1]}toChromosomal(e){const n=this.toChromosome(e);if(n)return{chrom:n.name,pos:Math.floor(e)-n.continuousStart}}getChromosome(e){return this.chromosomesByName.get(e)}formatInterval(e){return oC(...this.toChromosomalInterval(e))}toChromosomalInterval(e){const n=this.toChromosomal(e[0]+.5),r=this.toChromosomal(e[1]-.5);return r.pos+=1,[n,r]}toContinuousInterval(e){var i;let[n,r]=e;return r||(r=n),[this.toContinuous(n.chrom,n.pos??0),this.toContinuous(r.chrom,r.pos??((i=this.chromosomesByName.get(r.chrom))==null?void 0:i.size))]}toDiscreteChromosomeIntervals(e){const n=e[0],r=e[1],i=[];if(n.chrom===r.chrom)i.push({chrom:n.chrom,startPos:n.pos,endPos:r.pos});else{const s=this.chromosomes.findIndex(a=>a.name===n.chrom),o=this.chromosomes.findIndex(a=>a.name===r.chrom);i.push({chrom:n.chrom,startPos:n.pos,endPos:this.chromosomes[s].size});for(let a=s+1;a<o;a++)i.push({chrom:this.chromosomes[a].name,startPos:0,endPos:this.chromosomes[a].size});i.push({chrom:r.chrom,startPos:0,endPos:r.pos})}return i}continuousToDiscreteChromosomeIntervals(e){return this.toDiscreteChromosomeIntervals([this.toChromosomal(e[0]),this.toChromosomal(e[1])])}parseInterval(e){const n=e.match(/^(chr[0-9A-Z]+)(?::([0-9,]+)(?:-(?:(chr[0-9A-Z]+):)?([0-9,]+))?)?$/);if(n){const r=n[1];if(n.slice(2).every(a=>a===void 0)){const a=this.getChromosome(r);return a?[a.continuousStart,a.continuousEnd]:void 0}const i=n[3]||r,s=parseInt(n[2].replace(/,/g,"")),o=n[4]!==void 0?parseInt(n[4].replace(/,/g,"")):s;return[this.toContinuous(r,s-1),this.toContinuous(i,o)]}}}function uC(t){return Xp(t).filter(e=>/^chr[0-9A-Z]+$/.test(e[0])).map(([e,n])=>({name:e,size:parseInt(n)}))}function Kd(t){return Re(t)&&"chrom"in t}function lC(t){return t.every(Kd)}class Ji extends Array{constructor(){super(),this.type=void 0}extend(e){return this}extendAll(e){if(e instanceof Ji&&e.type!=this.type)throw new Error(`Cannot combine different types of domains: ${this.type} and ${e.type}`);for(const n of e)this.extend(n);return this}extendAllWithAccessor(e,n){for(const r of e)this.extend(n(r));return this}}class va extends Ji{constructor(){super(),this.type="quantitative"}extend(e){return e==null||Number.isNaN(e)?this:(e=+e,this.length?e<this[0]?this[0]=e:e>this[1]&&(this[1]=e):(this.push(e),this.push(e)),this)}}class Jd extends Ji{constructor(){super(),this.type="ordinal",this.uniqueValues=new Set}extend(e){return e==null||Number.isNaN(e)?this:(this.uniqueValues.has(e)||(this.uniqueValues.add(e),this.push(e)),this)}}class Zd extends Jd{constructor(){super(),this.type="nominal"}}class fC extends Ji{constructor(e){super();let n=0;for(let r=1;r<e.length;r++)n+=Math.sign(e[r]-e[r-1]);if(Math.abs(n)!=e.length-1)throw new Error("Piecewise domain must be strictly increasing or decreasing: "+JSON.stringify(e));e.forEach(r=>this.push(r))}extend(e){if(this.includes(e))return this;throw new Error("Piecewise domains are immutable and cannot be unioned!")}}const pf={quantitative:va,index:va,locus:va,nominal:Zd,ordinal:Jd};function mf(t,e){if(t=="quantitative"&&hC(e)){const n=new fC(e);return n.type=t,n}else if(pf[t]){const n=new pf[t];return n.type=t,e&&n.extendAll(e),n}throw new Error("Unknown type: "+t)}function hC(t){return t&&t.length>0&&t.length!=2&&t.every(e=>typeof e=="number")}function dC(t){return((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2}function pC(t,e,n){return t*Math.pow(e/t,n)}N("index",Du,["continuous"]);N("locus",PE,["continuous"]);N("null",Mo,[]);const gf="quantitative",Qd="ordinal",ep="nominal",tp="locus",mC="index";var pt,Kn,ae,et,It,Zs,np,Jn,ws,mt,rn,wi,mc,Qs,rp,Fc,xC,vi,gc;class gC{constructor(e){M(this,et);M(this,Zs);M(this,Jn);M(this,mt);M(this,wi);M(this,Qs);M(this,Fc);M(this,vi);M(this,pt,void 0);M(this,Kn,new Set);M(this,ae,void 0);this.channel=e,this.members=[],this.type=null,this.name=void 0}addEventListener(e,n){if(e!="domain")throw new Error("Unsupported event type: "+e);S(this,Kn).add(n)}removeEventListener(e,n){if(e!="domain")throw new Error("Unsupported event type: "+e);S(this,Kn).delete(n)}pushUnitView(e,n){var o;const r=Ya(e,n),i=r.type,s=(o=r==null?void 0:r.scale)==null?void 0:o.name;if(s){if(this.name!==void 0&&s!=this.name)throw new Error(`Shared scales have conflicting names: "${s}" vs. "${this.name}"!`);this.name=s}if(!this.type)this.type=i;else if(i!==this.type&&!zr(n))throw new Error(`Can not use shared scale for different data types: ${this.type} vs. ${i}. Use "resolve: independent" for channel ${this.channel}`);this.members.push({view:e,channel:n})}isExplicitDomain(){return!!this.getConfiguredDomain()}isDomainInitialized(){const e=S(this,ae);if(!e)return!1;const n=e.domain();return me(e.type)?n.length>2||n.length==2&&(n[0]!==0||n[1]!==0):n.length>0}getScaleProps(){return pr(this,"scaleProps",()=>{const e=I(this,Zs,np).call(this);if(e===null||e.type=="null")return{type:"null"};const n={...I(this,Qs,rp).call(this,this.type),...e};n.type||(n.type=yC(this.channel,this.type));const r=I(this,Jn,ws).call(this);return r&&r.length>0?n.domain=r:Ot(n.type)&&(n.domain=new Zd),!n.domain&&n.domainMid!==void 0&&(n.domain=[n.domainMin??0,n.domainMax??1]),this.channel=="y"&&Ot(n.type)&&n.reverse==null&&(n.reverse=!0),n.range&&n.scheme&&delete n.scheme,!("zoom"in n)&&["index","locus"].includes(n.type)&&(n.zoom=!0),bC(n,this.channel),n})}getConfiguredDomain(){return I(this,vi,gc).call(this,e=>zr(e.channel)?void 0:e.view.getConfiguredDomain(e.channel))}getDataDomain(){return I(this,vi,gc).call(this,e=>zr(e.channel)?void 0:e.view.extractDataDomain(e.channel))}reconfigure(){if(S(this,ae)&&S(this,ae).type!="null"){const e=this.isDomainInitialized(),n=S(this,ae).domain();Bd(this,"scaleProps");const r=this.getScaleProps();if(Yd(r,S(this,ae)),me(S(this,ae).type)&&he(this,pt,I(this,wi,mc).call(this)),!e){I(this,et,It).call(this);return}const i=S(this,ae).domain();ks(i,n)||(this.isZoomable()?S(this,ae).domain(n):I(this,mt,rn).call(this)?(S(this,ae).domain(n),this.zoomTo(i,500)):I(this,et,It).call(this))}}getScale(){if(S(this,ae))return S(this,ae);const e=this.getScaleProps(),n=KE(e);return he(this,ae,n),LE(n)&&n.genome(this.getGenome()),me(n.type)&&he(this,pt,I(this,wi,mc).call(this)),n}getDomain(){return this.getScale().domain()}getComplexDomain(){var e;return((e=this.getGenome())==null?void 0:e.toChromosomalInterval(this.getDomain()))??this.getDomain()}isZoomed(){return I(this,mt,rn).call(this)&&ks(I(this,Jn,ws).call(this),this.getDomain())}isZoomable(){return I(this,mt,rn).call(this)&&!!this.getScaleProps().zoom}zoom(e,n,r){if(!I(this,mt,rn).call(this))return!1;const i=this.getScale(),s=i.domain();let o=[...s],a=i.invert(n);switch(this.getScaleProps().reverse&&(r=-r),"align"in i&&(a+=i.align()),i.type){case"linear":case"index":case"locus":o=rm(o,r||0),o=Gf(o,a,e);break;case"log":o=im(o,r||0),o=Hf(o,a,e);break;case"pow":case"sqrt":{const c=i;o=sm(o,r||0,c.exponent()),o=Da(o,a,e,c.exponent());break}default:throw new Error("Zooming is not implemented for: "+i.type)}return S(this,pt)&&(o=am(o,S(this,pt)[0],S(this,pt)[1])),[0,1].some(c=>o[c]!=s[c])?(i.domain(o),I(this,et,It).call(this),!0):!1}async zoomTo(e,n=!1){var a;if(_i(n)&&(n=n?700:0),!I(this,mt,rn).call(this))throw new Error("Not a zoomable scale!");const r=this.fromComplexInterval(e),i=(a=this.members[0])==null?void 0:a.view.context.animator,s=this.getScale(),o=s.domain();if(n>0&&o.length==2){const c=o[1]-o[0],u=o[0]+c/2,f=r[1]-r[0],l=r[0]+f/2;await i.transition({duration:n,easingFunction:dC,onUpdate:h=>{const p=pC(c,f,h),d=(c-p)/(c-f),m=d*l+(1-d)*u;s.domain([m-p/2,m+p/2]),I(this,et,It).call(this)}}),s.domain(r),I(this,et,It).call(this)}else s.domain(r),i==null||i.requestRender(),I(this,et,It).call(this)}resetZoom(){if(!I(this,mt,rn).call(this))throw new Error("Not a zoomable scale!");const e=this.getDomain(),n=I(this,Jn,ws).call(this);return[0,1].some(r=>n[r]!=e[r])?(S(this,ae).domain(n),I(this,et,It).call(this),!0):!1}getZoomLevel(){return this.isZoomable()?Ts(S(this,pt))/Ts(this.getScale().domain()):1}getGenome(){var n;if(this.type!=="locus")return;const e=(n=this.members[0].view.context.genomeStore)==null?void 0:n.getGenome();if(!e)throw new Error("No genome has been defined!");return e}invertToComplex(e){const n=this.getScale();if("invert"in n){const r=n.invert(e);return this.toComplex(r)}else throw new Error("The scale does not support inverting!")}toComplex(e){const n=this.getGenome();return n?n.toChromosomal(e):e}fromComplex(e){return Kd(e)?this.getGenome().toContinuous(e.chrom,e.pos):e}fromComplexInterval(e){return this.type==="locus"&&lC(e)?this.getGenome().toContinuousInterval(e):e}}pt=new WeakMap,Kn=new WeakMap,ae=new WeakMap,et=new WeakSet,It=function(){for(const e of S(this,Kn).values())e({type:"domain",scaleResolution:this})},Zs=new WeakSet,np=function(){return pr(this,"mergedScaleProps",()=>{const e=this.members.map(n=>Ya(n.view,n.channel).scale).filter(n=>n!==void 0);return Ws(e,"scale",["domain"])})},Jn=new WeakSet,ws=function(){return this.getConfiguredDomain()??(this.type==tp?this.getGenome().getExtent():this.getDataDomain())},mt=new WeakSet,rn=function(){const e=this.getScale().type;return me(e)},wi=new WeakSet,mc=function(){const e=this.getScaleProps(),n=e.zoom;if(AC(n)&&Me(n.extent))return this.fromComplexInterval(n.extent);if(n)return e.type=="locus"?this.getGenome().getExtent():S(this,ae).domain()},Qs=new WeakSet,rp=function(e){const n=this.channel,r={};return this.isExplicitDomain()&&(r.zero=!1),li(n)?r.nice=!this.isExplicitDomain():An(n)?r.scheme=e==ep?"tableau10":e==Qd?"blues":"viridis":Bo(n)?r.range=n=="shape"?["circle","square","triangle-up","cross","diamond"]:[]:n=="size"?r.range=[0,400]:n=="angle"&&(r.range=[0,360]),r},Fc=new WeakSet,xC=function(){return this.members.map(e=>e.view.getPathString()).join(", ")},vi=new WeakSet,gc=function(e){const n=this.members.filter(r=>!r.view.getLayoutAncestors().some(i=>!i.options.contributesToScaleDomain)).map(e).filter(r=>!!r);if(n.length)return n.reduce((r,i)=>r.extendAll(i))};function yC(t,e){if(e==mC||e==tp){if(F0(t))return e;throw new Error(`${t} does not support ${e} data type. Only positional channels do.`)}const n={x:["band","band","linear"],y:["band","band","linear"],size:[void 0,"point","linear"],opacity:[void 0,"point","linear"],fillOpacity:[void 0,"point","linear"],strokeOpacity:[void 0,"point","linear"],color:["ordinal","ordinal","linear"],fill:["ordinal","ordinal","linear"],stroke:["ordinal","ordinal","linear"],strokeWidth:[void 0,void 0,"linear"],shape:["ordinal","ordinal",void 0],dx:[void 0,void 0,"null"],dy:[void 0,void 0,"null"],angle:[void 0,void 0,"linear"]},i=["sample"].includes(t)?"null":n[t]?n[t][[ep,Qd,gf].indexOf(e)]:e==gf?"linear":"ordinal";if(i===void 0)throw new Error(`Channel "${t}" is not compatible with "${e}" data type. Use of a proper scale may be needed.`);return i}function bC(t,e){li(e)&&t.type!=="ordinal"&&(t.range=[0,1]),e=="opacity"&&me(t.type)&&(t.clamp=!0)}function AC(t){return Re(t)}function xc(t){const e=new Set;function n(r){for(const i of Object.values(r.resolutions.scale))e.add(i)}for(const r of ze(t)){r.visit(n);for(const i of r.getDataAncestors()){if(!i.options.contributesToScaleDomain)break;n(i)}}e.forEach(r=>r.reconfigure())}function Ea(...t){for(const e of t)if(e!==void 0)return e}class wC{constructor(e){this.channel=e,this.members=[]}get scaleResolution(){var e;return(e=Bi(this.members))==null?void 0:e.view.getScaleResolution(this.channel)}pushUnitView(e,n){const r=e.getScaleResolution(this.channel);if(!r)throw new Error("Cannot find a scale resolution!");if(this.scaleResolution&&r!==this.scaleResolution)throw new Error("Shared axes must have a shared scale!");this.members.push({view:e,channel:n})}getAxisProps(){return pr(this,"axisProps",()=>{const e=this.members.map(n=>{const r=n.view.mark.encoding[n.channel];return"axis"in r&&r.axis});return e.length>0&&e.some(n=>n===null)?null:Ws(e.filter(n=>n!==void 0),"axis",["title"])})}getTitle(){const e=s=>{var a;const o=Ya(s.view,s.channel);if(!Xe(o))return{member:s,explicitTitle:Ea("axis"in o?(a=o.axis)==null?void 0:a.title:void 0,o.title),implicitTitle:Ea(qi(o)?o.field:void 0,ou(o)?o.expr:void 0)}},n=this.members.map(e),r=n.filter(s=>{var o;if(zr(s.member.channel)&&!s.explicitTitle){const a=_n(s.member.channel);return((o=n.find(c=>c.member.view==s.member.view&&c.member.channel==a))==null?void 0:o.explicitTitle)===void 0}return!0}),i=new Set(r.map(s=>Ea(s.explicitTitle,s.implicitTitle)).filter(V));return i.size?[...i].join(", "):null}}const vC={point:lE,rect:nE,rule:pE,link:AE,text:TE};class Ne extends Mn{constructor(e,n,r,i,s,o){super(e,n,r,i,s,o),this.spec=e;const a=vC[this.getMarkType()];if(a)this.mark=new a(this);else throw new Error(`No such mark: ${this.getMarkType()}`);this.resolve(),this.coords=void 0,this.needsAxes={x:!0,y:!0}}render(e,n,r={}){this.isConfiguredVisible()&&(this.coords=n,e.pushView(this,n),e.renderMark(this.mark,r),e.popView(this))}getMarkType(){return typeof this.spec.mark=="object"?this.spec.mark.type:this.spec.mark}resolve(e){e||(this.resolve("scale"),this.resolve("axis"));const n=this.mark.encoding;for(const[r,i]of Object.entries(n)){if(!De(i))continue;const s=_n(i.resolutionChannel??r);if(!wn(s)||e=="axis"&&!li(s))continue;let o=this;for(;(o.getConfiguredOrDefaultResolution(s,e)=="forced"||o.dataParent instanceof Mn&&["shared","excluded","forced"].includes(o.dataParent.getConfiguredOrDefaultResolution(s,e)))&&o.getConfiguredOrDefaultResolution(s,e)!="excluded";)o=o.dataParent;e=="axis"&&li(r)&&F0(s)?(o.resolutions[e][s]||(o.resolutions[e][s]=new wC(s)),o.resolutions[e][s].pushUnitView(this,r)):e=="scale"&&wn(r)&&(o.resolutions[e][s]||(o.resolutions[e][s]=new gC(s)),o.resolutions[e][s].pushUnitView(this,r))}}getAccessor(e){return this._cache("accessor/"+e,()=>{const n=this.mark.encoding;if(n&&n[e])return this.context.accessorFactory.createAccessor(n[e])})}getFacetAccessor(e){const n=this.getAccessor("sample");return n||super.getFacetAccessor(this)}getCollector(){return this.context.dataFlow.findCollectorByKey(this)}_validateDomainQuery(e){if(zr(e))throw new Error(`getDomain(${e}), must only be called for primary channels!`);const n=this.mark.encoding[e];if(!De(n))throw new Error("The channel has no scale, cannot get domain!");return n}getConfiguredDomain(e){const n=this._validateDomainQuery(e),r=n&&n.scale&&n.scale.domain;if(r){const i=this.getScaleResolution(n.resolutionChannel??e);return mf(n.type??"nominal",i.fromComplexInterval(r))}}extractDataDomain(e){const r=this._validateDomainQuery(e).type??"nominal",i=a=>{let c;const u=this.mark.encoding[a];if(u){const f=this.context.accessorFactory.createAccessor(u);if(f)if(c=mf(r),f.constant)c.extend(f({}));else{const l=this.getCollector();l!=null&&l.completed&&l.visitData(h=>c.extend(f(h)))}}return c};let s=i(e);const o=au[e];if(o){const a=i(o);a&&s.extendAll(a)}return s}getZoomLevel(){const e=n=>{var r;return((r=this.getScaleResolution(n))==null?void 0:r.getZoomLevel())??1};return br.map(e).reduce((n,r)=>n*r,1)}propagateInteractionEvent(e){this.handleInteractionEvent(void 0,e,!0),e.target=this,!e.stopped&&this.handleInteractionEvent(void 0,e,!1)}getDefaultResolution(e,n){return e=="x"?"shared":"independent"}}function*Iu(t,e=[]){for(const[n,r]of t.entries())if(r instanceof Map)for(const i of Iu(r,[...e,n]))yield i;else yield[[...e,n],r]}class ip extends X{get behavior(){return Tu}constructor(e){super(),this.params=e??{type:"collect"},this.observers=[],this.facetBatches=void 0,this._init()}_init(){this._data=[],this.facetBatches=new Sn([],JSON.stringify),this.facetBatches.set(void 0,this._data)}reset(){super.reset(),this._init()}handle(e){this._data.push(e)}beginBatch(e){aE(e)&&(this._data=[],this.facetBatches.set(ze(e.facetId),this._data))}complete(){var i,s;const e=(i=this.params)==null?void 0:i.sort,n=e?qf(e.field,e.order):void 0,r=o=>{n&&o.sort(n)};if((s=this.params.groupby)!=null&&s.length){if(this.facetBatches.size>1)throw new Error("TODO: Support faceted data!");const o=this.params.groupby.map(c=>U(c)),a=uo(this._data,...o);this.facetBatches.clear();for(const[c,u]of Iu(a))this.facetBatches.set(c,u)}for(const o of this.facetBatches.values())r(o);if(this.children.length)for(const[o,a]of this.facetBatches.entries()){if(o){const c={type:"facet",facetId:o};for(const u of this.children)u.beginBatch(c)}for(const c of a)this._propagate(c)}super.complete();for(const o of this.observers)o(this)}getData(){switch(this._checkStatus(),this.facetBatches.size){case 0:return[];case 1:return[...this.facetBatches.values()][0];default:{const e=this.facetBatches;return{[Symbol.iterator]:function*(){for(const r of e.values())for(let i=0;i<r.length;i++)yield r[i]}}}}}visitData(e){this._checkStatus();for(const n of this.facetBatches.values())for(let r=0;r<n.length;r++)e(n[r])}getItemCount(){let e=0;for(const n of this.facetBatches.values())e+=n.length;return e}_checkStatus(){if(!this.completed)throw new Error("Data propagation is not completed! No data are available.")}}class js{constructor(){this.ids=[],this.values=[],this.length=0}clear(){this.length=0}push(e,n){let r=this.length++;for(;r>0;){const i=r-1>>1,s=this.values[i];if(n>=s)break;this.ids[r]=this.ids[i],this.values[r]=s,r=i}this.ids[r]=e,this.values[r]=n}pop(){if(this.length===0)return;const e=this.ids[0];if(this.length--,this.length>0){const n=this.ids[0]=this.ids[this.length],r=this.values[0]=this.values[this.length],i=this.length>>1;let s=0;for(;s<i;){let o=(s<<1)+1;const a=o+1;let c=this.ids[o],u=this.values[o];const f=this.values[a];if(a<this.length&&f<u&&(o=a,c=this.ids[a],u=f),u>=r)break;this.ids[s]=c,this.values[s]=u,s=o}this.ids[s]=n,this.values[s]=r}return e}peek(){if(this.length!==0)return this.ids[0]}peekValue(){if(this.length!==0)return this.values[0]}shrink(){this.ids.length=this.values.length=this.length}}class EC extends X{get behavior(){return ut}constructor(e){super(),this.params=e,this.startAccessor=U(e.start),this.endAccessor=U(e.end),this.chromAccessor=e.chrom?U(e.chrom):n=>{},this.weightAccessor=e.weight?U(e.weight):n=>1,this.as={coverage:e.as||"coverage",start:e.asStart||e.start,end:e.asEnd||e.end,chrom:e.asChrom||e.chrom},this.createSegment=new Function("start","end","coverage","chrom","return {"+Object.entries(this.as).filter(([n,r])=>r).map(([n,r])=>`${JSON.stringify(r)}: ${n}`).join(", ")+"};"),this.ends=new js}reset(){super.reset(),this.initialize()}initialize(){const e=this.as.coverage,n=this.as.end,r=this.as.chrom,i=this.startAccessor,s=this.endAccessor,o=this.chromAccessor,a=this.weightAccessor;let c,u,f,l=0,h;const p=this.ends;p.clear();const d=(g,x,b)=>{if(g==x)return;let A=!1;c&&(c[e]===b?(c[n]=x,A=!0):c[e]!=0&&this._propagate(c)),A||(c=this.createSegment(g,x,b,f))},m=()=>{let g;for(;(g=p.peekValue())!==void 0;)d(h,g,l),h=g,l-=p.pop();h=void 0,c&&(this._propagate(c),c=void 0)};this.handle=g=>{const x=i(g);let b;for(;(b=p.peekValue())!==void 0&&b<x;)d(h,b,l),h=b,l-=p.pop();if(r){let E=o(g);E!==u&&(m(),f=E,u=f)}h!==void 0&&d(h,x,l),h=x;const A=a(g);l+=A,p.push(A,s(g))},this.complete=()=>{m(),super.complete()}}}function CC(t,e,n=0,r=t.length){const i=new js,s=r-n;let o;for(o=0;o<e&&o<s;o++)i.push(o,t[n+o]);for(;o<s;o++){const u=t[n+o];u>=i.peekValue()&&(i.push(o,u),i.pop())}const a=[];let c;for(;(c=i.pop())!==void 0;)a.push(n+c);return a.reverse()}class SC{constructor(e,n=-1/0,r=1/0){this.maxSize=e,this.lowerLimit=n,this.upperLimit=r;const i=this.maxSize*2+1;this.lowerLimits=new Float64Array(i),this.upperLimits=new Float64Array(i),this.lowerChildren=new Int32Array(i),this.upperChildren=new Int32Array(i),this.reset()}reset(){this.lowerLimits.fill(0),this.upperLimits.fill(0),this.lowerChildren.fill(0),this.upperChildren.fill(0),this.n=1,this.lowerLimits[0]=this.lowerLimit,this.upperLimits[0]=this.upperLimit}_findSlot(e,n,r=0){if(e>=this.lowerLimits[r]&&n<=this.upperLimits[r]){const i=this.lowerChildren[r];if(i){const s=this._findSlot(e,n,i);return s>=0?s:this._findSlot(e,n,this.upperChildren[r])}else return r}else return-1}reserve(e,n){if(n-e<=0)throw new Error("Cannot reserve an empty or negative-size slot!");if(this.n+1>this.lowerLimits.length)return!1;const r=this._findSlot(e,n);if(r<0)return!1;const i=this.n++,s=this.n++;return this.lowerLimits[i]=this.lowerLimits[r],this.upperLimits[i]=e,this.lowerLimits[s]=n,this.upperLimits[s]=this.upperLimits[r],this.lowerChildren[r]=i,this.upperChildren[r]=s,!0}}class FC extends X{get behavior(){return Tu}constructor(e,n){if(super(),this.params=e,this._data=[],this.channel=e.channel??"x",!["x","y"].includes(this.channel))throw new Error("Invalid channel: "+this.channel);this.posAccessor=U(this.params.pos),this.posBisector=co(this.posAccessor),this.scoreAccessor=U(this.params.score),this.widthAccessor=U(this.params.width),this.laneAccessor=this.params.lane?U(this.params.lane):i=>0,this.padding=this.params.padding??0,this.reservationMaps=new Map,this.resolution=n.getScaleResolution(this.channel);const r=()=>this._filterAndPropagate();this.schedule=()=>n.context.animator.requestTransition(r),this.resolution.addEventListener("domain",i=>this.schedule()),n._addBroadcastHandler("layoutComputed",()=>this.schedule())}complete(){const e=this.posAccessor;this._data.sort((n,r)=>e(n)-e(r)),this._scores=this._data.map(this.scoreAccessor);for(const n of new Set(this._data.map(this.laneAccessor)))this.reservationMaps.set(n,new SC(200));this.schedule(),super.complete()}_filterAndPropagate(){var o;super.reset();const e=this.resolution.getScale(),n=(o=this.resolution.members[0].view.coords)==null?void 0:o[this.channel=="x"?"width":"height"];if(!n)return;for(const a of this.reservationMaps.values())a.reset();const r=e.domain(),i=70,s=CC(this._scores,i,this.posBisector.left(this._data,r[0]),this.posBisector.right(this._data,r[1]));for(const a of s){const c=this._data[a],u=e(this.posAccessor(c))*n,f=this.widthAccessor(c)/2+this.padding;this.reservationMaps.get(this.laneAccessor(c)).reserve(u-f,u+f)&&this._propagate(c)}super.complete()}reset(){super.reset(),this._data=[],this.groups=new Map}handle(e){this._data.push(e)}}class TC extends X{constructor(e){super(),this.params=e,this.predicate=void 0}initialize(){this.predicate=vo(this.params.expr,this.getGlobalObject())}handle(e){this.predicate(e)&&this._propagate(e)}}class DC extends X{get behavior(){return ut}constructor(e){super();const n=e.index;if(e.fields){const r=ze(e.fields).map(s=>U(s)),i=ze(e.as||e.fields);if(r.length!==i.length)throw new Error(`Lengths of "fields" (${r.length}), and "as" (${i.length}) do not match!`);this.handle=s=>{const o=r.map((c,u)=>c(s)??[]),a=o[0].length;for(let c=0;c<a;c++){const u=Object.assign({},s);for(let f=0;f<r.length;f++)u[i[f]]=c<o[f].length?o[f][c]:null;n&&(u[n]=c),this._propagate(u)}}}else this.handle=r=>{for(let i=0;i<r.length;i++){const s=Object.assign({},r[i]);n&&(s[n]=i),this._propagate(s)}}}}const IC="0".charCodeAt(0);function*_C(t,e=","){const n=e.charCodeAt(0);let r=0;for(let i=0;i<t.length;i++){const s=t.charCodeAt(i);s==n?(yield r,r=0):r=r*10+s-IC}yield r}class RC extends X{get behavior(){return ut}constructor(e){super();const n=U(e.exons??"exons"),r=U(e.start??"start"),[i,s]=e.as||["exonStart","exonEnd"];this.handle=o=>{let a=r(o),c=a,u=!0;const f=n(o);for(const l of _C(f)){if(u)c=a+l;else{a=c+l;const h=Object.assign({},o);h[i]=c,h[s]=a,this._propagate(h)}u=!u}}}}class MC extends X{get behavior(){return ut}constructor(e){super();const n=ze(e.field).map(s=>U(s)),r=ze(e.separator),i=ze(e.as||e.field);if(n.length!==r.length||n.length!==i.length)throw new Error(`Lengths of "separator" (${r.length}), "fields" (${n.length}), and "as" (${i.length}) do not match!`);this.handle=s=>{if(n.some(c=>!c(s)))return;const o=n.map((c,u)=>c(s).split(r[u]));BC(o,s);const a=o[0].length;for(let c=0;c<a;c++){const u=Object.assign({},s);for(let f=0;f<n.length;f++)u[i[f]]=o[f][c];this._propagate(u)}}}}function BC(t,e){const n=t.map(r=>r.length);if(!n.every(r=>r==n[0]))throw new Error("Mismatching number of elements in the fields to be split: "+JSON.stringify(e))}class kC extends X{get behavior(){return Xt}constructor(e){super(),this.params=e,this.as=e.as,this.fn=void 0}initialize(){this.fn=vo(this.params.expr,this.getGlobalObject())}handle(e){e[this.as]=this.fn(e),this._propagate(e)}}class sp extends X{get behavior(){return Xt}constructor(e,n){super();const r=e.channel??"x";if(!["x","y"].includes(r))throw new Error("Invalid channel: "+r);const i=n.getScaleResolution(r).getGenome();if(!i)throw new Error("LinearizeGenomicCoordinate transform requires a locus scale!");const s=U(e.chrom),o=ze(e.pos).map(d=>U(d)),a=ze(e.as);if(o.length!=a.length)throw new Error('The number of "pos" and "as" elements must be equal!');const c=ze(e.offset);let u;if(c.length==0)u=new Array(o.length).fill(0);else if(c.length==1)u=new Array(o.length).fill(c[0]);else if(c.length==o.length)u=c;else throw new Error(`Invalid "offset" parameter: ${JSON.stringify(e.offset)}!`);const f=new Function("datum","chromOffset","posAccessors",a.map((d,m)=>`datum[${JSON.stringify(d)}] = chromOffset + +posAccessors[${m}](datum) - ${u[m]};`).join(` +`));let l,h=0;const p=d=>{if(d!==l){if(h=i.cumulativeChromPositions.get(d),h===void 0)throw new Error("Unknown chromosome/contig: "+d);l=d}return h};this.handle=d=>{f(d,p(s(d)),o),this._propagate(d)}}}const OC=["Lato-Regular.png"],PC=[{id:87,width:53,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:43.491,chnl:15,x:0,y:0,page:0},{id:124,width:17,height:50,xoffset:0,yoffset:-32.193000000000005,xadvance:10.521,chnl:15,x:0,y:42,page:0},{id:40,width:20,height:49,xoffset:0,yoffset:-32.571000000000005,xadvance:11.214,chnl:15,x:0,y:94,page:0},{id:41,width:19,height:49,xoffset:0,yoffset:-32.571000000000005,xadvance:11.214,chnl:15,x:0,y:145,page:0},{id:36,width:32,height:49,xoffset:0,yoffset:-34.419000000000004,xadvance:24.360000000000003,chnl:15,x:0,y:196,page:0},{id:125,width:21,height:48,xoffset:0,yoffset:-32.193000000000005,xadvance:12.642000000000001,chnl:15,x:0,y:247,page:0},{id:91,width:22,height:48,xoffset:0,yoffset:-32.193000000000005,xadvance:12.852,chnl:15,x:0,y:297,page:0},{id:93,width:19,height:48,xoffset:0,yoffset:-32.193000000000005,xadvance:12.852,chnl:15,x:0,y:347,page:0},{id:123,width:21,height:48,xoffset:0,yoffset:-32.193000000000005,xadvance:12.642000000000001,chnl:15,x:0,y:397,page:0},{id:106,width:19,height:48,xoffset:0,yoffset:-30.639000000000003,xadvance:10.08,chnl:15,x:0,y:447,page:0},{id:81,width:43,height:47,xoffset:0,yoffset:-30.429000000000002,xadvance:33.621,chnl:15,x:21,y:447,page:0},{id:77,width:45,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:38.997,chnl:15,x:66,y:447,page:0},{id:64,width:43,height:44,xoffset:0,yoffset:-28.539,xadvance:35.133,chnl:15,x:23,y:397,page:0},{id:92,width:28,height:43,xoffset:0,yoffset:-30.933000000000003,xadvance:18.984,chnl:15,x:68,y:397,page:0},{id:47,width:28,height:43,xoffset:0,yoffset:-30.933000000000003,xadvance:18.984,chnl:15,x:98,y:397,page:0},{id:109,width:42,height:32,xoffset:0,yoffset:-21.609,xadvance:34.545,chnl:15,x:113,y:447,page:0},{id:119,width:42,height:31,xoffset:0,yoffset:-21.315,xadvance:32.991,chnl:15,x:157,y:447,page:0},{id:42,width:25,height:42,xoffset:0,yoffset:-31.626,xadvance:17.85,chnl:15,x:128,y:397,page:0},{id:37,width:42,height:41,xoffset:0,yoffset:-30.387,xadvance:33.663000000000004,chnl:15,x:155,y:397,page:0},{id:79,width:42,height:41,xoffset:0,yoffset:-30.429000000000002,xadvance:33.621,chnl:15,x:199,y:397,page:0},{id:102,width:24,height:41,xoffset:0,yoffset:-30.534000000000002,xadvance:14.721,chnl:15,x:243,y:397,page:0},{id:100,width:31,height:41,xoffset:0,yoffset:-30.933000000000003,xadvance:23.520000000000003,chnl:15,x:269,y:397,page:0},{id:98,width:32,height:41,xoffset:0,yoffset:-30.933000000000003,xadvance:23.520000000000003,chnl:15,x:302,y:397,page:0},{id:56,width:32,height:41,xoffset:0,yoffset:-30.429000000000002,xadvance:24.360000000000003,chnl:15,x:336,y:397,page:0},{id:38,width:40,height:41,xoffset:0,yoffset:-30.429000000000002,xadvance:29.904000000000003,chnl:15,x:370,y:397,page:0},{id:108,width:17,height:41,xoffset:0,yoffset:-30.933000000000003,xadvance:9.912,chnl:15,x:412,y:397,page:0},{id:107,width:31,height:41,xoffset:0,yoffset:-30.933000000000003,xadvance:21.336000000000002,chnl:15,x:431,y:397,page:0},{id:48,width:33,height:41,xoffset:0,yoffset:-30.429000000000002,xadvance:24.360000000000003,chnl:15,x:464,y:397,page:0},{id:71,width:38,height:41,xoffset:0,yoffset:-30.429000000000002,xadvance:30.681,chnl:15,x:21,y:347,page:0},{id:83,width:31,height:41,xoffset:0,yoffset:-30.429000000000002,xadvance:22.785,chnl:15,x:61,y:347,page:0},{id:63,width:27,height:41,xoffset:0,yoffset:-30.429000000000002,xadvance:18.795,chnl:15,x:94,y:347,page:0},{id:105,width:18,height:41,xoffset:0,yoffset:-30.639000000000003,xadvance:10.08,chnl:15,x:123,y:347,page:0},{id:51,width:32,height:41,xoffset:0,yoffset:-30.429000000000002,xadvance:24.360000000000003,chnl:15,x:143,y:347,page:0},{id:104,width:31,height:41,xoffset:0,yoffset:-30.933000000000003,xadvance:23.436,chnl:15,x:177,y:347,page:0},{id:67,width:37,height:41,xoffset:0,yoffset:-30.429000000000002,xadvance:28.056,chnl:15,x:210,y:347,page:0},{id:88,width:37,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:27.258000000000003,chnl:15,x:249,y:347,page:0},{id:68,width:40,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:31.941000000000003,chnl:15,x:288,y:347,page:0},{id:70,width:32,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:23.751,chnl:15,x:330,y:347,page:0},{id:34,width:23,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:15.561000000000002,chnl:15,x:364,y:347,page:0},{id:72,width:38,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:32.067,chnl:15,x:389,y:347,page:0},{id:73,width:18,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:11.760000000000002,chnl:15,x:429,y:347,page:0},{id:74,width:24,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:17.745,chnl:15,x:449,y:347,page:0},{id:75,width:38,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:27.825000000000003,chnl:15,x:24,y:297,page:0},{id:76,width:31,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:21.567,chnl:15,x:475,y:347,page:0},{id:66,width:35,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:27.153000000000002,chnl:15,x:64,y:297,page:0},{id:78,width:38,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:32.067,chnl:15,x:101,y:297,page:0},{id:33,width:18,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:11.298,chnl:15,x:141,y:297,page:0},{id:80,width:34,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:25.221,chnl:15,x:161,y:297,page:0},{id:65,width:38,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:28.434,chnl:15,x:197,y:297,page:0},{id:82,width:36,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:26.313000000000002,chnl:15,x:237,y:297,page:0},{id:35,width:33,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:24.360000000000003,chnl:15,x:275,y:297,page:0},{id:84,width:34,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:24.801000000000002,chnl:15,x:310,y:297,page:0},{id:85,width:37,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:30.891000000000002,chnl:15,x:346,y:297,page:0},{id:86,width:38,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:28.434,chnl:15,x:385,y:297,page:0},{id:39,width:16,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:8.568000000000001,chnl:15,x:425,y:297,page:0},{id:69,width:32,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:24.255000000000003,chnl:15,x:443,y:297,page:0},{id:89,width:36,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:26.208000000000002,chnl:15,x:23,y:247,page:0},{id:90,width:34,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:25.284000000000002,chnl:15,x:477,y:297,page:0},{id:49,width:31,height:40,xoffset:0,yoffset:-30.156000000000002,xadvance:24.360000000000003,chnl:15,x:61,y:247,page:0},{id:50,width:32,height:40,xoffset:0,yoffset:-30.429000000000002,xadvance:24.360000000000003,chnl:15,x:94,y:247,page:0},{id:57,width:32,height:40,xoffset:0,yoffset:-30.429000000000002,xadvance:24.360000000000003,chnl:15,x:128,y:247,page:0},{id:94,width:32,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:24.360000000000003,chnl:15,x:162,y:247,page:0},{id:96,width:21,height:40,xoffset:0,yoffset:-30.429000000000002,xadvance:16.8,chnl:15,x:196,y:247,page:0},{id:55,width:33,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:24.360000000000003,chnl:15,x:219,y:247,page:0},{id:54,width:33,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:24.360000000000003,chnl:15,x:254,y:247,page:0},{id:53,width:32,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:24.360000000000003,chnl:15,x:289,y:247,page:0},{id:52,width:33,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:24.360000000000003,chnl:15,x:323,y:247,page:0},{id:103,width:31,height:39,xoffset:0,yoffset:-21.630000000000003,xadvance:21.84,chnl:15,x:358,y:247,page:0},{id:112,width:32,height:39,xoffset:0,yoffset:-21.651,xadvance:23.541,chnl:15,x:391,y:247,page:0},{id:113,width:31,height:39,xoffset:0,yoffset:-21.651,xadvance:23.520000000000003,chnl:15,x:425,y:247,page:0},{id:116,width:25,height:39,xoffset:0,yoffset:-28.182000000000002,xadvance:15.057,chnl:15,x:458,y:247,page:0},{id:121,width:31,height:38,xoffset:0,yoffset:-21.273,xadvance:21.651,chnl:15,x:34,y:196,page:0},{id:59,width:18,height:36,xoffset:0,yoffset:-20.706,xadvance:10.983,chnl:15,x:485,y:247,page:0},{id:43,width:32,height:34,xoffset:0,yoffset:-24.486,xadvance:24.360000000000003,chnl:15,x:67,y:196,page:0},{id:60,width:30,height:33,xoffset:0,yoffset:-23.331000000000003,xadvance:24.360000000000003,chnl:15,x:101,y:196,page:0},{id:62,width:31,height:33,xoffset:0,yoffset:-23.331000000000003,xadvance:24.360000000000003,chnl:15,x:133,y:196,page:0},{id:117,width:30,height:32,xoffset:0,yoffset:-21.273,xadvance:23.415000000000003,chnl:15,x:166,y:196,page:0},{id:99,width:29,height:32,xoffset:0,yoffset:-21.609,xadvance:20.055,chnl:15,x:198,y:196,page:0},{id:110,width:31,height:32,xoffset:0,yoffset:-21.609,xadvance:23.436,chnl:15,x:229,y:196,page:0},{id:111,width:32,height:32,xoffset:0,yoffset:-21.609,xadvance:23.814,chnl:15,x:262,y:196,page:0},{id:126,width:32,height:26,xoffset:0,yoffset:-16.128,xadvance:24.360000000000003,chnl:15,x:201,y:447,page:0},{id:101,width:31,height:32,xoffset:0,yoffset:-21.609,xadvance:22.176000000000002,chnl:15,x:296,y:196,page:0},{id:114,width:25,height:32,xoffset:0,yoffset:-21.651,xadvance:15.288,chnl:15,x:329,y:196,page:0},{id:115,width:27,height:32,xoffset:0,yoffset:-21.609,xadvance:18.186,chnl:15,x:356,y:196,page:0},{id:97,width:28,height:32,xoffset:0,yoffset:-21.651,xadvance:20.874000000000002,chnl:15,x:385,y:196,page:0},{id:118,width:31,height:31,xoffset:0,yoffset:-21.273,xadvance:21.672,chnl:15,x:415,y:196,page:0},{id:61,width:31,height:29,xoffset:0,yoffset:-19.089000000000002,xadvance:24.360000000000003,chnl:15,x:448,y:196,page:0},{id:120,width:30,height:31,xoffset:0,yoffset:-21.273,xadvance:20.916,chnl:15,x:21,y:145,page:0},{id:58,width:18,height:31,xoffset:0,yoffset:-20.706,xadvance:10.5,chnl:15,x:53,y:145,page:0},{id:122,width:28,height:31,xoffset:0,yoffset:-21.273,xadvance:18.984,chnl:15,x:73,y:145,page:0},{id:95,width:28,height:16,xoffset:0,yoffset:0,xadvance:19.278000000000002,chnl:15,x:235,y:447,page:0},{id:45,width:23,height:24,xoffset:0,yoffset:-14.175,xadvance:15.603000000000002,chnl:15,x:481,y:196,page:0},{id:44,width:17,height:21,xoffset:0,yoffset:-4.956,xadvance:9.534,chnl:15,x:103,y:145,page:0},{id:46,width:18,height:15,xoffset:0,yoffset:-4.956,xadvance:9.912,chnl:15,x:0,y:497,page:0},{id:32,width:0,height:0,xoffset:0,yoffset:0,xadvance:10.752,chnl:15,x:20,y:497,page:0}],LC={face:"Lato Regular",size:42,bold:0,italic:0,charset:[" ","!",'"',"#","$","%","&","'","(",")","*","+",",","-",".","/","0","1","2","3","4","5","6","7","8","9",":",";","<","=",">","?","@","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","[","\\","]","^","_","`","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","{","|","}","~"],unicode:1,stretchH:100,smooth:1,aa:1,padding:[0,0,0,0],spacing:[2,2]},NC={lineHeight:50.400000000000006,base:41.454,scaleW:512,scaleH:512,pages:1,packed:0,alphaChnl:0,redChnl:0,greenChnl:0,blueChnl:0},zC=[],op={pages:OC,chars:PC,info:LC,common:NC,kernings:zC};class UC extends X{get behavior(){return Xt}constructor(e){super();const n=oc(op),r=U(e.field),i=e.as,s=e.fontSize;this.handle=o=>{const a=r(o);a!==void 0?o[i]=n.measureWidth(a,s):o[i]=0,this._propagate(o)}}}const $C=65536;class VC extends X{get behavior(){return Xt}constructor(e){super(),this.params=e}reset(){super.reset(),this.initialize()}initialize(){const e=this.params,n=e.as||"lane",r=be(e.spacing)?e.spacing:1,i=U(e.start),s=U(e.end);if(!e.preference!=!e.preferredOrder)throw new Error('Must specify both "preference" and "preferredOrder"');if(e.preference){const o=new Float64Array($C),a=U(e.preference),c=e.preferredOrder;let u=1/0;this.handle=f=>{const l=i(f);l<u&&o.fill(-1/0),u=l;const h=c.indexOf(a(f));let p=-1;if(h>=0&&o[h]<l)p=h;else{const d=i(f);for(p=0;p<o.length&&!(o[p]<d);p++);if(p>=o.length)throw new Error("Out of lanes!")}o[p]=s(f)+r,f[n]=p,this._propagate(f)}}else{const o=new js,a=new js;let c=-1/0,u=0;this.handle=f=>{const l=i(f);for(;o.length&&(o.peekValue()<=l||l<c);){const p=o.pop();a.push(p,p)}c=l;let h=a.pop();h===void 0&&(h=u++),f[n]=h,this._propagate(f),o.push(h,s(f)+r)}}}}class GC extends X{get behavior(){return ut}constructor(e){if(super(),e.as&&e.as.length!=e.fields.length)throw new Error('"fields" and "as" have unequal lengths!');const n=e.fields.map(i=>U(i)),r=e.as?e.as:n.map(Kp);this.handle=i=>{const s={};for(let o=0;o<n.length;o++)s[r[o]]=n[o](i);this._propagate(s)}}}class HC extends X{get behavior(){return Xt}constructor(e){super();const n=new RegExp(e.regex),r=typeof e.as=="string"?[e.as]:e.as,i=U(e.field);this.handle=s=>{const o=i(s);if(V(o)){const a=o.match(n);if(a){if(a.length-1!=r.length)throw new Error('The number of RegEx groups and the length of "as" do not match!');for(let c=0;c<r.length;c++)s[r[c]]=a[c+1]}else if(e.skipInvalidInput)for(let c=0;c<r.length;c++)s[r[c]]=void 0;else throw new Error(`"${o}" does not match the given regex: ${n.toString()}`)}else if(!e.skipInvalidInput)throw new Error(`Trying to match a non-string field. Encountered type: ${typeof o}, field content: "${o}".`);this._propagate(s)}}}class qC extends X{get behavior(){return ut}constructor(e){super();const n=ze(e.columnRegex).map(h=>new RegExp(h)),r=ze(e.asValue);if(n.length!=r.length)throw new Error('Lengths of "columnRegex" and "as" are not equal!');const i=e.skipRegex?new RegExp(e.skipRegex):void 0,s=e.asKey||"sample";let o,a,c;const u=h=>{var g;const p=Object.keys(h),d=new Map;for(const[x,b]of n.entries())for(const A of p){const E=(g=b.exec(A))==null?void 0:g[1];if(E!==void 0){let F=d.get(E);F||(F=[],d.set(E,F)),F[x]=A}}o=[...d.entries()],a=p.filter(x=>!n.some(b=>b.test(x))&&!(i&&i.test(x)));const m=[...a.map(x=>JSON.stringify(x)+": datum["+JSON.stringify(x)+"]"),JSON.stringify(s)+": sampleId",...r.map(x=>JSON.stringify(x)+": null")];c=new Function("datum","sampleId",`return { +`+m.join(`, +`)+` +};`)},f=h=>{o||u(h);for(const[p,d]of o){const m=c(h,p);for(let g=0;g<d.length;g++)m[r[g]]=h[d[g]];this._propagate(m)}},l=h=>{u(h),f(h),this.handle=f};this.handle=l,this.beginBatch=h=>{Ud(h)&&(this.handle=l),super.beginBatch(h)}}}class WC extends X{get behavior(){return Xt}constructor(e){super(),this.params=e,this.buffer=[]}reset(){this.buffer=[]}handle(e){this.buffer.push(e)}complete(){const e=this.params,n=e.as||["y0","y1"],r=e.sort?qf(e.sort.field,e.sort.order):void 0,i=e.field?U(e.field):()=>1,s=e.groupby.map(f=>U(f)),o=zm(this.buffer,f=>s.map(l=>l(f)).join()).map(f=>f[1]);let a=f=>!0;if(e.baseField){const f=U(e.baseField);a=l=>f(l)!==null}let c,u;switch(e.offset){case"normalize":c=(f,l)=>f/l,u=(f,l)=>os(f,l);break;case"center":c=(f,l)=>f-l/2,u=(f,l)=>os(f,l);break;case"information":{const f=Math.log2(e.cardinality??4);c=(l,h)=>l/h,u=(l,h)=>{const d=os(l,b=>+!a(b)),m=os(l,h),g=m-d;let x=0;for(let b=0;b<l.length;b++){const A=l[b];if(a(A)){const E=h(A)/g;x-=E*Math.log2(E)}}return g/(f-(x+0))*(g/m)}}break;default:c=(f,l)=>f,u=(f,l)=>1}for(const f of o){r&&f.sort(r);const l=u(f,i);let h=0;for(const p of f){const d=h+i(p);a(p)&&(p[n[0]]=c(h,l),p[n[1]]=c(d,l),this._propagate(p),h=d)}}super.complete()}}class jC extends X{get behavior(){return ut}constructor(e){super();const n=U(e.field??"sequence"),[r,i]=e.as??["pos","sequence"];this.handle=s=>{const o=Object.assign({},s,{[i]:"",[r]:0}),a=n(s);for(let c=0;c<a.length;c++){const u=Object.assign({},o);u[r]=c,u[i]=a.charAt(c),this._propagate(u)}}}}class YC extends X{get behavior(){return ut}constructor(e){super(),this.params=e,this.buffer=[]}reset(){this.buffer=[]}handle(e){this.buffer.push(e)}complete(){const n=this.params.groupby,r=n.map(s=>U(s)),i=uo(this.buffer,...r);for(const[s,o]of Iu(i)){const a={count:o.length};for(let c=0;c<n.length;c++)a[n[c]]=s[c];this._propagate(a)}super.complete()}}const XC="_uniqueId",xf=1e4,yf=[null];class ap extends X{get behavior(){return Xt}constructor(e){super(),this.params=e,this.as=e.as??XC,this._blocks=[],this._usedBlocks=0,this._id=-1}initialize(){}reset(){super.reset(),this._usedBlocks=0,this._id=-1}handle(e){e[this.as]=this._nextId(),this._propagate(e)}_nextId(){return++this._id%xf==0&&(this._id=this._getBlock()*xf),this._id}_getBlock(){return this._usedBlocks<this._blocks.length?this._blocks[this._usedBlocks++]:this._reserveBlock()}_reserveBlock(){const e=yf.length;return yf[e]=this,this._blocks.push(e),this._usedBlocks++,e}}const KC={aggregate:YC,collect:ip,coverage:EC,filterScoredLabels:FC,filter:TC,flatten:DC,flattenCompressedExons:RC,flattenDelimited:MC,flattenSequence:jC,formula:kC,identifier:ap,linearizeGenomicCoordinate:sp,measureText:UC,pileup:VC,project:GC,regexExtract:HC,regexFold:qC,sample:$d,stack:WC};function JC(t,e){const n=KC[t.type];if(n)return new n(t,e);throw new Error("Unknown transform: "+t.type)}function cp(t){if(!lp(t)&&!bf(t))return;const e={...t.format};if(e.type??(e.type=bf(t)&&ZC(t.url)),e.parse??(e.parse="auto"),!e.type)throw new Error("Format for the data source was not defined and it could not be inferred: "+JSON.stringify(t));return e}function ZC(t){var e;if(Array.isArray(t)&&(t=t[0]),t)return(e=t.match(/\.(csv|tsv|json)/))==null?void 0:e[1]}const up=t=>typeof t!="object"?QC:eS,QC=t=>({data:t}),eS=t=>t;function bf(t){return"url"in t}class Zi extends X{get identifier(){}handle(e){throw new Error("Source does not handle incoming data!")}async load(){}}function lp(t){return"values"in t}class tS extends Zi{constructor(e,n){var r;if(super(),this.params=e,typeof e.values=="string"&&!((r=e==null?void 0:e.format)!=null&&r.type))throw new Error("Data format type (csv, dsv, ...) must be specified if a string is provided!")}loadSynchronously(){const e=this.params.values;let n=[],r=i=>i;if(Array.isArray(e))e.length>0&&(n=e,r=up(e[0]));else if(typeof e=="object")n=[e];else if(typeof e=="string")n=xh(e,cp(this.params));else throw new Error('"values" in data configuration is not an array, object, or a string!');this.reset(),this.beginBatch({type:"file"});for(const i of n)this._propagate(r(i));this.complete()}async load(){this.loadSynchronously()}}function nS(t){return"url"in t}class rS extends Zi{constructor(e,n){super(),this.params=e,this.baseUrl=n==null?void 0:n.getBaseUrl()}get identifier(){return JSON.stringify({params:this.params,baseUrl:this.baseUrl})}async load(){const e=this.params.url,n=Array.isArray(e)?e:[e],r=async s=>xo({baseURL:this.baseUrl}).load(s).catch(o=>{throw new Error(`Cannot fetch: ${this.baseUrl}${s}: ${o.message}`)}),i=(s,o)=>{try{const a=xh(s,cp(this.params));this.beginBatch({type:"file",url:o});for(const c of a)this._propagate(c)}catch(a){throw new Error(`Cannot parse: ${o}: ${a.message}`)}};this.reset(),await Promise.all(n.map(s=>r(s).then(i))),this.complete()}}function iS(t){return"sequence"in t}class sS extends Zi{constructor(e,n){if(super(),this.sequence=e.sequence,!("start"in this.sequence))throw new Error("'start' is missing from sequence parameters!");if(!("stop"in this.sequence))throw new Error("'stop' is missing from sequence parameters!")}loadSynchronously(){const e=this.sequence.as||"data",n=this.sequence.step||1,r=this.sequence.stop;this.reset(),this.beginBatch({type:"file"});for(let i=this.sequence.start;i<r;i+=n)this._propagate({[e]:i});this.complete()}async load(){this.loadSynchronously()}}class Ln extends Zi{constructor(e,n){if(super(),this.view=e,n){if(n!=="x"&&n!=="y")throw new Error(`Invalid channel specified for the dynamic data source: ${n}. Must be either "x" or "y"`)}else throw new Error('No channel has been specified for the dynamic data source. Must be either "x" or "y".');if(this.channel=n,this.scaleResolution=this.view.getScaleResolution(n),!this.scaleResolution){const i=[`The dynamic data source cannot find a resolved scale for channel "${n}".`];throw this.view instanceof Ne||i.push('Make sure the view has a "shared" scale resolution as it is not a unit view.'),new Error(i.join(" "))}const r=()=>{this.view.isVisible()&&this.onDomainChanged(this.scaleResolution.getDomain(),this.scaleResolution.getComplexDomain())};this.scaleResolution.addEventListener("domain",r),this.view.context.addBroadcastListener("layoutComputed",r)}getAxisLength(){const e=this.scaleResolution.members.map(n=>{var r;return(r=n.view.coords)==null?void 0:r[this.channel==="x"?"width":"height"]}).filter(n=>n>0);return e.length?e.reduce((n,r)=>Math.min(n,r),1e4):0}get genome(){return this.scaleResolution.getGenome()}async onDomainChanged(e,n){}requestRender(){this.view.context.animator.requestRender()}async load(){this.reset(),this.complete()}publishData(e){this.reset(),this.beginBatch({type:"file"});for(const n of e)this._propagate(n);this.complete(),xc(this.view),this.requestRender()}}class oS extends Ln{constructor(n,r){const i={axis:{},...n};super(r,i.channel);fe(this,"ticks",[]);this.params=n}async onDomainChanged(){const n=this.scaleResolution.getScale(),r=this.params.axis,i=this.getAxisLength(),s=u=>25+60*Sh(100,700,u),o=be(r.tickCount)?r.tickCount:Math.round(i/s(i)),a=Hd(n,o,r.tickMinStep),c=r.values?qd(n,r.values,a):NE(n,a);if(!ks(c,this.ticks)){this.ticks=c;const u=UE(n,o,r.format);this.publishData(c.map(f=>({value:f,label:u(f)})))}}}class aS extends Ln{constructor(e,n){super(n,e.channel)}async load(){this.publishData(this.genome.chromosomes)}}const cS="modulepreload",uS=function(t,e){return new URL(t,e).href},Af={},_e=function(e,n,r){if(!n||n.length===0)return e();const i=document.getElementsByTagName("link");return Promise.all(n.map(s=>{if(s=uS(s,r),s in Af)return;Af[s]=!0;const o=s.endsWith(".css"),a=o?'[rel="stylesheet"]':"";if(!!r)for(let f=i.length-1;f>=0;f--){const l=i[f];if(l.href===s&&(!o||l.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${s}"]${a}`))return;const u=document.createElement("link");if(u.rel=o?"stylesheet":cS,o||(u.as="script",u.crossOrigin=""),u.href=s,document.head.appendChild(u),o)return new Promise((f,l)=>{u.addEventListener("load",f),u.addEventListener("error",()=>l(new Error(`Unable to preload CSS for ${s}`)))})})).then(()=>e()).catch(s=>{const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=s,window.dispatchEvent(o),!o.defaultPrevented)throw s})};function Qi(t){return class extends t{constructor(){super(...arguments);fe(this,"lastQuantizedInterval",[0,0])}quantizeInterval(r,i){return[Math.max(Math.floor(r[0]/i-1)*i,0),Math.min(Math.ceil(r[1]/i+1)*i,this.genome.totalSize)]}checkAndUpdateLastInterval(r){return ks(this.lastQuantizedInterval,r)?!1:(this.lastQuantizedInterval=r,!0)}}}function es(t,e){return!e||/^(data:|([A-Za-z]+:)?\/\/)/.test(t)||t.startsWith("/")?t:(e.endsWith("/")||(e+="/"),e+t)}class lS extends Qi(Ln){constructor(e,n){const r={channel:"x",windowSize:7e3,...e};if(super(n,r.channel),this.params=r,!this.params.url)throw new Error("No URL provided for IndexedFastaSource");this.initializedPromise=new Promise(i=>{Promise.all([_e(()=>import("./index-462333f7.js").then(s=>s.i),["./index-462333f7.js","./_commonjsHelpers-de833af9.js"],import.meta.url),_e(()=>import("./index-f8b9b7f4.js"),["./index-f8b9b7f4.js","./__vite-browser-external-d053bc6e.js","./index-462333f7.js","./_commonjsHelpers-de833af9.js","./long-c1fdf4ae.js"],import.meta.url),_e(()=>import("./index-5c802462.js"),["./index-5c802462.js","./__vite-browser-external-d053bc6e.js","./remoteFile-1948951e.js","./index-462333f7.js","./_commonjsHelpers-de833af9.js"],import.meta.url)]).then(([{Buffer:s},{IndexedFasta:o},{RemoteFile:a}])=>{typeof window<"u"&&(window.Buffer??(window.Buffer=s));const c=u=>new a(es(u,this.view.getBaseUrl()));this.fasta=new o({fasta:c(this.params.url),fai:c(this.params.indexUrl??this.params.url+".fai")}),i()})})}async onDomainChanged(e){const n=this.params.windowSize;if(e[1]-e[0]>n)return;await this.initializedPromise;const r=this.quantizeInterval(e,n);if(this.checkAndUpdateLastInterval(r)){const i=this.genome.continuousToDiscreteChromosomeIntervals(r),s=await Promise.all(i.map(o=>this.fasta.getSequence(o.chrom,o.startPos,o.endPos).then(a=>({chrom:o.chrom,start:o.startPos,sequence:a}))));this.publishData(s)}}}function Wo(t,e,n=!0){let r,i=o=>{};return function(...a){return new Promise((c,u)=>{const f=()=>{clearTimeout(r),i=l=>{},c(t(...a))};n&&i("debounced"),clearTimeout(r),i=u,r=window.setTimeout(f,e)})}}class fS extends Qi(Ln){constructor(n,r){const i={pixelsPerBin:2,channel:"x",...n};super(r,i.channel);fe(this,"reductionLevels",[]);fe(this,"lastRequestId",0);fe(this,"bbi");if(this.params=i,!this.params.url)throw new Error("No URL provided for BigWigSource");this.doDebouncedRequest=Wo(this.doRequest.bind(this),200,!1),this.initializedPromise=new Promise(s=>{Promise.all([_e(()=>import("./index-396a8699.js"),["./index-396a8699.js","./index-462333f7.js","./_commonjsHelpers-de833af9.js","./index-d89cadd6.js","./__vite-browser-external-d053bc6e.js","./remoteFile-1948951e.js"],import.meta.url),_e(()=>import("./index-5c802462.js"),["./index-5c802462.js","./__vite-browser-external-d053bc6e.js","./remoteFile-1948951e.js","./index-462333f7.js","./_commonjsHelpers-de833af9.js"],import.meta.url)]).then(([{BigWig:o},{RemoteFile:a}])=>{this.bbi=new o({filehandle:new a(es(this.params.url,this.view.getBaseUrl()))}),this.bbi.getHeader().then(c=>{this.reductionLevels=c.zoomLevels.map(u=>u.reductionLevel).reverse(),this.reductionLevels.push(1),s()})})})}async onDomainChanged(n){await this.initializedPromise;const r=this.getAxisLength()||700,i=hS(n,r,this.reductionLevels),s=Math.max(i*r,5e3),o=this.quantizeInterval(n,s);this.checkAndUpdateLastInterval(o)&&this.doDebouncedRequest(o,i)}async doRequest(n,r){const i=await this.getFeatures(n,.5/r/this.params.pixelsPerBin);i.requestId<this.lastRequestId||this.publishData(i.features)}async getFeatures(n,r){let i=++this.lastRequestId;const s=new AbortController,o=this.genome.continuousToDiscreteChromosomeIntervals(n),a=await Promise.all(o.map(c=>this.bbi.getFeatures(c.chrom,c.startPos,c.endPos,{scale:r,signal:s.signal}).then(u=>u.map(f=>({chrom:c.chrom,start:f.start,end:f.end,score:f.score})))));return{requestId:i,abort:()=>s.abort(),features:a.flat()}}}function hS(t,e,n){const r=(t[1]-t[0])/e;return n.find(i=>i<r)??n.at(-1)}class dS extends Qi(Ln){constructor(n,r){const i={channel:"x",windowSize:1e6,...n};super(r,i.channel);fe(this,"lastRequestId",0);fe(this,"parser");fe(this,"bbi");if(this.params=i,!this.params.url)throw new Error("No URL provided for BigBedSource");this.doDebouncedRequest=Wo(this.doRequest.bind(this),200,!1),this.initializedPromise=new Promise(s=>{Promise.all([_e(()=>import("./index-7a37a249.js"),["./index-7a37a249.js","./_commonjsHelpers-de833af9.js"],import.meta.url),_e(()=>import("./index-396a8699.js"),["./index-396a8699.js","./index-462333f7.js","./_commonjsHelpers-de833af9.js","./index-d89cadd6.js","./__vite-browser-external-d053bc6e.js","./remoteFile-1948951e.js"],import.meta.url),_e(()=>import("./index-5c802462.js"),["./index-5c802462.js","./__vite-browser-external-d053bc6e.js","./remoteFile-1948951e.js","./index-462333f7.js","./_commonjsHelpers-de833af9.js"],import.meta.url)]).then(([o,{BigBed:a},{RemoteFile:c}])=>{const u=o.default;this.bbi=new a({filehandle:new c(es(this.params.url,this.view.getBaseUrl()))}),this.headerPromise=this.bbi.getHeader(),this.headerPromise.then(async f=>{this.parser=new u({autoSql:f.autoSql}),s()})})})}async onDomainChanged(n){await this.initializedPromise;const r=this.params.windowSize;if(n[1]-n[0]>r)return;const i=this.quantizeInterval(n,r);this.checkAndUpdateLastInterval(i)&&this.doDebouncedRequest(i)}async doRequest(n){const r=await this.getFeatures(n);r.requestId<this.lastRequestId||this.publishData(r.features)}async getFeatures(n){let r=++this.lastRequestId;const i=new AbortController,s=this.genome.continuousToDiscreteChromosomeIntervals(n),o=await Promise.all(s.map(a=>this.bbi.getFeatures(a.chrom,a.startPos,a.endPos,{signal:i.signal}).then(c=>c.map(u=>this.parser.parseLine(`${a.chrom} ${u.start} ${u.end} ${u.rest}`,{uniqueId:u.uniqueId})))));return{requestId:r,abort:()=>i.abort(),features:o.flat()}}}class pS extends Qi(Ln){constructor(n,r){const i={channel:"x",windowSize:2e4,...n};super(r,i.channel);fe(this,"lastRequestId",0);fe(this,"bam");fe(this,"chrPrefixFixer",n=>n);if(this.params=i,!this.params.url)throw new Error("No URL provided for BamSource");this.initializedPromise=new Promise(s=>{Promise.all([_e(()=>import("./index-234835b1.js"),["./index-234835b1.js","./long-c1fdf4ae.js","./index-462333f7.js","./_commonjsHelpers-de833af9.js","./__vite-browser-external-d053bc6e.js","./remoteFile-1948951e.js","./index-d89cadd6.js"],import.meta.url),_e(()=>import("./index-5c802462.js"),["./index-5c802462.js","./__vite-browser-external-d053bc6e.js","./remoteFile-1948951e.js","./index-462333f7.js","./_commonjsHelpers-de833af9.js"],import.meta.url)]).then(([{BamFile:o},{RemoteFile:a}])=>{const c=u=>new a(es(u,this.view.getBaseUrl()));this.bam=new o({bamFilehandle:c(this.params.url),baiFilehandle:c(this.params.indexUrl??this.params.url+".bai")}),this.bam.getHeader().then(u=>{var h,p;const f=this.genome.hasChrPrefix(),l=(p=(h=this.bam.indexToChr)==null?void 0:h[0])==null?void 0:p.refName.startsWith("chr");f&&!l?this.chrPrefixFixer=d=>d.replace("chr",""):!f&&l&&(this.chrPrefixFixer=d=>"chr"+d),s()})})})}async onDomainChanged(n){const r=this.params.windowSize;if(n[1]-n[0]>r)return;await this.initializedPromise;const i=this.quantizeInterval(n,r);if(this.checkAndUpdateLastInterval(i)){const s=this.genome.continuousToDiscreteChromosomeIntervals(i),o=await Promise.all(s.map(a=>this.bam.getRecordsForRange(this.chrPrefixFixer(a.chrom),a.startPos,a.endPos).then(c=>c.map(u=>({chrom:a.chrom,start:u.get("start"),end:u.get("end"),name:u.get("name"),MD:u.get("MD"),cigar:u.get("cigar"),mapq:u.get("mq"),strand:u.get("strand")===1?"+":"-"})))));this.publishData(o.flat())}}}class mS extends Qi(Ln){constructor(n,r){const i={channel:"x",windowSize:3e6,debounceDomainChange:200,...n};super(r,i.channel);fe(this,"lastRequestId",0);fe(this,"tbiIndex");if(this.params=i,!this.params.url)throw new Error("No URL provided for TabixSource");this.params.debounceDomainChange>0&&(this.onDomainChanged=Wo(this.onDomainChanged.bind(this),this.params.debounceDomainChange,!1)),this.initializedPromise=new Promise(s=>{Promise.all([_e(()=>import("./index-462333f7.js").then(o=>o.i),["./index-462333f7.js","./_commonjsHelpers-de833af9.js"],import.meta.url),_e(()=>import("./index-4e587624.js"),["./index-4e587624.js","./index-d89cadd6.js","./_commonjsHelpers-de833af9.js","./index-462333f7.js","./__vite-browser-external-d053bc6e.js","./long-c1fdf4ae.js"],import.meta.url),_e(()=>import("./index-5c802462.js"),["./index-5c802462.js","./__vite-browser-external-d053bc6e.js","./remoteFile-1948951e.js","./index-462333f7.js","./_commonjsHelpers-de833af9.js"],import.meta.url)]).then(([{Buffer:o},{TabixIndexedFile:a},{RemoteFile:c}])=>{typeof window<"u"&&(window.Buffer??(window.Buffer=o));const u=f=>new c(es(f,this.view.getBaseUrl()));this.tbiIndex=new a({filehandle:u(this.params.url),tbiFilehandle:u(this.params.indexUrl??this.params.url+".tbi")}),s()})})}async onDomainChanged(n){const r=this.params.windowSize;if(n[1]-n[0]>r)return;const i=this.quantizeInterval(n,r);this.checkAndUpdateLastInterval(i)&&this.doRequest(i)}async doRequest(n){const r=await this.getFeatures(n);r.requestId<this.lastRequestId||this.publishData(r.features)}async getFeatures(n){await this.initializedPromise;let r=++this.lastRequestId;const i=new AbortController,s=this.genome.continuousToDiscreteChromosomeIntervals(n),o=await Promise.all(s.map(async a=>{const c=[];return await this.tbiIndex.getLines(a.chrom,a.startPos,a.endPos,{lineCallback:u=>{c.push(u)},signal:i.signal}),this._parseFeatures(c)}));return{requestId:r,abort:()=>i.abort(),features:o.flat()}}_parseFeatures(n){return[]}}var Ei;class gS extends mS{constructor(n,r){super(n,r);M(this,Ei,void 0);_e(()=>import("./index-ba6a6d03.js"),["./index-ba6a6d03.js","./_commonjsHelpers-de833af9.js","./index-462333f7.js","./__vite-browser-external-d053bc6e.js"],import.meta.url).then(i=>{he(this,Ei,i.default)})}_parseFeatures(n){var i;return(i=S(this,Ei))==null?void 0:i.parseStringSync(n.join(` +`),{parseSequences:!1})}}Ei=new WeakMap;function xS(t,e){if(lp(t))return new tS(t,e);if(nS(t))return new rS(t,e);if(iS(t))return new sS(t,e);if(yS(t))return FS(t.lazy,e);throw new Error("Cannot figure out the data source type: "+JSON.stringify(t))}function yS(t){return"lazy"in t}function bS(t){return(t==null?void 0:t.type)=="axisTicks"}function AS(t){return(t==null?void 0:t.type)=="axisGenome"}function wS(t){return(t==null?void 0:t.type)=="indexedFasta"}function vS(t){return(t==null?void 0:t.type)=="bigwig"}function ES(t){return(t==null?void 0:t.type)=="bigbed"}function CS(t){return(t==null?void 0:t.type)=="bam"}function SS(t){return(t==null?void 0:t.type)=="gff3"}function FS(t,e){if(bS(t))return new oS(t,e);if(AS(t))return new aS(t,e);if(wS(t))return new lS(t,e);if(vS(t))return new fS(t,e);if(ES(t))return new dS(t,e);if(CS(t))return new pS(t,e);if(SS(t))return new gS(t,e);throw new Error("Cannot figure out the data source type: "+JSON.stringify(t))}function TS(t){const e=Object.keys(t).filter(r=>typeof r=="string"),n=new Function("source","return { "+e.map(r=>JSON.stringify(r)).map(r=>`${r}: source[${r}]`).join(`, +`)+" };");return n.properties=e,n}class Ys extends X{get behavior(){return ut}constructor(){super();const e=n=>{const r=TS(n);this.handle=i=>this._propagate(r(i)),this.handle(n)};this.handle=e,this.beginBatch=n=>{Ud(n)&&(this.handle=e),super.beginBatch(n)}}}function DS(t){return"name"in t}var Ci;class fp extends Zi{constructor(n,r,i){super();M(this,Ci,void 0);this.provider=i,this.params=n}get identifier(){return this.params.name}updateDynamicData(n){he(this,Ci,n),this.loadSynchronously()}loadSynchronously(){const n=S(this,Ci)??this.provider(this.params.name)??[];let r=i=>i;if(Array.isArray(n))n.length>0&&(r=up(n[0]));else throw new Error(`Named data "${this.params.name}" is not an array!`);this.reset(),this.beginBatch({type:"file"});for(const i of n)this._propagate(r(i));this.complete()}async load(){this.loadSynchronously()}}Ci=new WeakMap;class hp{constructor(){this._dataSourcesByHost=new Map,this._collectorsByHost=new Map,this._observers=new Map}get dataSources(){return[...new Set(this._dataSourcesByHost.values()).values()]}get collectors(){return[...this._collectorsByHost.values()]}addObserver(e,n){let r=this._observers.get(n);r||(r=[],this._observers.set(n,r)),r.push(e)}_relayObserverCallback(e,n){const r=this._observers.get(n);if(r)for(const i of r)i(e)}addDataSource(e,n){this._dataSourcesByHost.set(n,e)}findDataSourceByKey(e){return this._dataSourcesByHost.get(e)}findNamedDataSource(e){let n,r=[];for(const[i,s]of this._dataSourcesByHost.entries())if(s instanceof fp&&e==s.identifier){if(n&&n!==s)throw new Error(`Found multiple instances of named data: ${e}. Data flow optimization is broken (it's a bug).`);n=s,r.push(i)}if(n)return{dataSource:n,hosts:r}}addCollector(e,n){this._collectorsByHost.set(n,e),e.observers.push(r=>this._relayObserverCallback(r,n))}findCollectorByKey(e){return this._collectorsByHost.get(e)}initialize(){for(const e of this.dataSources)e.visit(n=>n.initialize())}}function IS(t,e){const n=new Map,r=[];for(const i of t)n.set(i,{ref:i,children:[]});for(const i of n.values()){const s=n.get(e(i.ref));s?s.children.push(i):r.push(i)}return r}function dp(t,e,n){var i,s;const r=(i=e.preOrder)==null?void 0:i.call(e,t);if(r)return r;for(const o of n(t)){const a=dp(o,e,n);if(a==="stop")return a}return(s=e.postOrder)==null?void 0:s.call(e,t)}function _S(t,e){return dp(t,e,n=>n.children)}function RS(t,e){const n=[];let r;const i=e??new hp,s=[];function o(l,h=()=>{}){if(!r)throw h()||new Error("Cannot append data flow node, no parent exist!");return r.addChild(l),r=l,l}function a(l,h){return o(l,()=>new Error(`Cannot append a transform because no (inherited) data are available! ${h?JSON.stringify(h):""}`))}function c(l,h){for(const p of l){let d;try{d=JC(p,h)}catch(m){throw console.warn(m),new Error(`Cannot initialize "${p.type}" transform: ${m}`)}d.behavior&Xt&&a(new Ys),a(d)}}const u=l=>{if(n.push(r),l.spec.data){const h=DS(l.spec.data)?new fp(l.spec.data,l,l.context.getNamedDataFromProvider):xS(l.spec.data,l);r=h,i.addDataSource(h,l)}if(l.spec.transform&&c(l.spec.transform,l),l instanceof Ne){if(!r)throw new Error(`A unit view (${l.getPathString()}) has no (inherited) data source`);const h=MS(l);if(h){s.push(h.rewrite);for(const d of h.transforms)a(d)}l.mark.isPickingParticipant()&&(a(new Ys),a(new ap({type:"identifier"})));const p=new ip({type:"collect",groupby:l.getFacetFields(),sort:BS(l,h==null?void 0:h.rewrittenEncoding)});o(p),i.addCollector(p,l)}},f=IS(t.getDescendants(),l=>l.dataParent);for(const l of f)_S(l,{preOrder:h=>u(h.ref),postOrder:()=>{r=n.pop()}});return s.forEach(l=>l()),i}function MS(t){var s;const e=[],n={},r=[];for(const[o,a]of Object.entries(t.getEncoding())){const c=o;li(c)&&S0(a)&&r.push({channel:c,chromPosDef:a})}const i=uo(r,o=>_n(o.channel),o=>o.chromPosDef.chrom);for(const[o,a]of i.entries())for(const[c,u]of a.entries()){const f=[],l=[],h=[];for(const{channel:p,chromPosDef:d}of u){const m=b=>b.replace(/[^A-Za-z0-9_]/g,""),g=["_linearized_",m(d.chrom),"_",m(d.pos)].join(""),x={...((s=t.spec.encoding)==null?void 0:s[p])??t.getEncoding()[p]??{},field:g};delete x.chrom,delete x.pos,!x.type&&d.type&&(x.type=d.type),n[p]=x,f.push(d.pos),h.push(d.offset??0),l.push(g)}e.push(new Ys),e.push(new sp({type:"linearizeGenomicCoordinate",channel:o,chrom:c,pos:f,offset:h,as:l},t))}return e.length?{transforms:e,rewrittenEncoding:n,rewrite:()=>{t.spec.encoding={...t.spec.encoding,...n},Bd(t.mark,"encoding")}}:void 0}function BS(t,e){var r;const n={...t.getEncoding(),...e}.x;if(De(n)&&(r=t.getScaleResolution("x"))!=null&&r.isZoomable()){if(qi(n))return{field:n.field};if(!Wi(n))throw new Error("A zoomable x channel must be mapped to a field.")}}function pp(t,e=void 0){if(t.parent!==e)return!1;for(const n of t.children)if(!pp(n,t))return!1;return!0}function yc(t,e=!1){if(t.behavior&Tu&&(e=!0),t instanceof Ys)if(e)e=!1;else{const n=t.children[0];t.excise(),n&&yc(n,e);return}t.behavior&ut&&(e=!1);for(let n=0,r=t.children.length;n<r;n++)yc(t.children[n],e||r>1)}function kS(t){const e=[...t._dataSourcesByHost.entries()],n=new Map;for(const r of e){const i=r[1];i.identifier&&!n.has(i.identifier)&&n.set(i.identifier,i)}t._dataSourcesByHost.clear();for(let[r,i]of e){const s=n.get(i.identifier);s&&(s.adoptChildrenOf(i),i=s),t.addDataSource(i,r)}}function OS(t){if(yc(t),!pp(t))throw new Error("Encountered a bug! There's a problem in the data flow structure.")}function PS(t){for(const e of t.dataSources)OS(e);kS(t)}function LS(t){const e=new Set;t.visit(n=>{for(const r of Object.values(n.resolutions.scale)){const i=r.name;if(i&&e.has(i))throw new Error(`The same scale name "${i}" occurs in multiple scale resolutions!`);e.add(i)}})}function NS(t){for(const e of br){const n=t.getScaleResolution(e);n&&!n.name&&n.isZoomable()&&(n.name=`${e}_at_root`)}}async function zS(t,e,n){var o;if(!t.import.url)throw new Error("Cannot import, not an import spec: "+JSON.stringify(t));const r=xo({baseURL:e}),i=t.import.url,s=JSON.parse(await r.load(i).catch(a=>{throw new Error(`Could not load imported view spec: ${i} +Reason: ${a.message}`)}));if(n.isViewSpec(s))return s.baseUrl=(o=i.match(/^[^?#]*\//))==null?void 0:o[0],s;throw new Error(`The imported spec "${i}" is not a view spec: ${JSON.stringify(t)}`)}function US(t){const e=t.getSize().addPadding(t.getOverhang()),n=r=>r.grow>0?void 0:r.px;return{width:n(e.width),height:n(e.height)}}function ht(t){return()=>t}const qe=class qe{static create(e,n,r,i){return new qe(ht(e),ht(n),ht(r),ht(i))}_offset(e,n){const r=this["_"+e];if(n===0)return r;switch(typeof n){case"number":return()=>r()+n;case"function":return()=>r()+n();default:throw new Error("Not a number of function")}}_passThrough(e){return this._offset(e,0)}constructor(e,n,r,i){this._x=e,this._y=n,this._width=r,this._height=i}get x(){return this._x()}get y(){return this._y()}get width(){return this._width()}get height(){return this._height()}get x2(){return this._x()+this._width()}get y2(){return this._y()+this._height()}equals(e){return e?this===e||this.x===e.x&&this.y===e.y&&this.width===e.width&&this.height===e.height:!1}modify(e){if(!Object.keys(e).length)return this;const n=r=>{const i=e[r];return typeof i=="number"?ht(i):typeof i=="function"?i:this._passThrough(r)};return new qe(n("x"),n("y"),n("width"),n("height"))}translate(e,n){return e===0&&n===0?this:new qe(this._offset("x",e),this._offset("y",n),this._passThrough("width"),this._passThrough("height"))}translateBy(e){return this.translate(e.x,e.y)}expand(e,n=1){return e.left==0&&e.top==0&&e.right==0&&e.bottom==0?this:new qe(e.left?this._offset("x",-e.left*n):this._passThrough("x"),e.top?this._offset("y",-e.top*n):this._passThrough("y"),e.width?this._offset("width",e.width*n):this._passThrough("width"),e.height?this._offset("height",e.height*n):this._passThrough("height"))}shrink(e){return this.expand(e,-1)}intersect(e){return this===e||e==null?this:new qe(()=>Math.max(this.x,e.x),()=>Math.max(this.y,e.y),()=>Math.min(this.x2,e.x2)-Math.max(this.x,e.x),()=>Math.min(this.y2,e.y2)-Math.max(this.y,e.y))}union(e){return this===e||e==null?this:new qe(()=>Math.min(this.x,e.x),()=>Math.min(this.y,e.y),()=>Math.max(this.x2,e.x2)-Math.min(this.x,e.x),()=>Math.max(this.y2,e.y2)-Math.min(this.y,e.y))}isDefined(){return this.width>=0&&this.height>=0}flatten(){return new qe(ht(this.x),ht(this.y),ht(this.width),ht(this.height))}containsPoint(e,n){return e>=this.x&&e<this.x2&&n>=this.y&&n<this.y2}normalizePoint(e,n){return{x:(e-this.x)/this.width,y:(n-this.y)/this.height}}toString(){return`Rectangle: x: ${this.x}, y: ${this.y}, width: ${this.width}, height: ${this.height}`}toRoundedString(){return`Rectangle: x: ${Math.round(this.x)}, y: ${Math.round(this.y)}, width: ${Math.round(this.width)}, height: ${Math.round(this.height)}`}};fe(qe,"ZERO",qe.create(0,0,0,0));let vt=qe;class mp{constructor(e){this.globalOptions=e}pushView(e,n){}popView(e){}renderMark(e,n){}}class wf extends mp{constructor(e,n){super(e),this.webGLHelper=n,this.buffer=[],this.coords=void 0,this.views=new Set}pushView(e,n){this.views.add(e),this.coords=n}renderMark(e,n){if(this.globalOptions.picking&&!e.isPickingParticipant())return;const r=e.render(n);r&&this.buffer.push({mark:e,callback:r,coords:this.coords,clipRect:n.clipRect})}render(){if(this.batch||this._buildBatch(),this.batch.length==0)return;const e=this.webGLHelper.gl,n=this.globalOptions.picking;e.bindFramebuffer(e.FRAMEBUFFER,n?this.webGLHelper._pickingBufferInfo.framebuffer:null),this.webGLHelper.clearAll();for(const r of this.views)r.onBeforeRender();for(const r of this.batch)r();n&&e.bindFramebuffer(e.FRAMEBUFFER,null)}_buildBatch(){this.batch=[];let e=!0,n=!0;const r=o=>()=>{e&&o()},i=o=>()=>{e&&n&&o()},s=uo(this.buffer.reverse(),o=>o.mark);for(const[o,a]of[...s.entries()].reverse()){if(!o.isReady())continue;this.batch.push(()=>{e=o.unitView.getEffectiveOpacity()>0}),this.batch.push(...o.prepareRender(this.globalOptions).map(u=>r(u)));let c;for(const u of a){const f=u.coords;f.equals(c)||this.batch.push(r(()=>{n=o.setViewport(f,u.clipRect)})),this.batch.push(i(u.callback)),c=u.coords}}}}class $S extends mp{constructor(...e){super({}),this.contexts=e}pushView(e,n){for(const r of this.contexts)r.pushView(e,n)}popView(e){for(const n of this.contexts)n.popView(e)}renderMark(e,n){for(const r of this.contexts)r.renderMark(e,n)}}class VS{constructor(e,n){this.point=e,this.uiEvent=n,this.stopped=!1,this.target=void 0}stopPropagation(){this.stopped=!0}get type(){return this.uiEvent.type}}class GS{constructor(e,n){this.x=e,this.y=n}equals(e){return e?e===this||e.x===this.x&&e.y===this.y:!1}}const HS=t=>new Promise(e=>setTimeout(e,t));function qS(t){const e=t.requestAnimationFrame||window.requestAnimationFrame,n=t.signal,r=()=>new Promise((i,s)=>{if(n!=null&&n.aborted)return s("aborted");const o=performance.now(),a=o+(t.duration||1e3),c=typeof t.from=="number"?t.from:0,u=typeof t.to=="number"?t.to:1,f=t.easingFunction||(m=>m),l=m=>(m-o)/(a-o),h=m=>m*(u-c)+c,p=m=>Math.max(0,Math.min(1,m)),d=m=>{n!=null&&n.aborted?s("aborted"):(t.onUpdate(h(f(p(l(m))))),m<a?e(d):(t.onUpdate(h(f(1))),i()))};e(d)});return t.delay?n!=null&&n.aborted?Promise.reject("aborted"):HS(t.delay).then(r):r()}class WS{constructor(e){this._renderCallback=e,this._renderRequested=!1,this._warn=!1,this.transitions=[]}requestTransition(e){this.cancelTransition(e),this.transitions.push(e),this.requestRender()}cancelTransition(e){const n=this.transitions.indexOf(e);n>=0&&this.transitions.splice(n,1)}requestRender(){this._renderRequested?this._warn&&console.warn("Render already requested!"):(this._renderRequested=!0,window.requestAnimationFrame(e=>{this._renderRequested=!1;const n=this.transitions;this.transitions=[];let r;for(;r=n.shift();)r(e);this._renderCallback(e)}))}transition(e){return qS({requestAnimationFrame:n=>this.requestTransition(n),...e})}}class jS{constructor(e){this.genomes=new Map,this.baseUrl=e}async initialize(e){const n=new cC(e);return this.genomes.set(n.name,n),Promise.all([...this.genomes.values()].map(r=>r.load(this.baseUrl)))}getGenome(e){if(!this.genomes.size)throw new Error("No genomes have been configured!");if(e){const n=this.genomes.get(e);if(!n)throw new Error(`No genome with the name ${e} has been configured!`);return n}else{if(this.genomes.size>1)throw new Error("Cannot pick a default genome! More than one have been configured!");return this.genomes.values().next().value}}}const YS=""+new URL("Lato-Regular-e459d1f9.png",import.meta.url).href,XS={thin:100,light:300,regular:400,normal:400,medium:500,bold:700,black:900};class KS{constructor(e){this._webGLHelper=e,this.fontRepository="https://raw.githubusercontent.com/etiennepinchon/aframe-fonts/master/fonts/",this._fonts=new Sn([],JSON.stringify),this._metadataPromises=new Map,this._fontPromises=new Map,this._promises=[],this._defaultFontEntry={metrics:oc(op),texture:e?this._createTextureNow(YS):void 0}}async waitUntilReady(){await Promise.all(this._promises)}getFont(e,n="normal",r="regular"){if(V(r)&&(r=XS[r.toLowerCase()],!r))throw new Error("Unknown font weight: "+r);const i={family:e,style:n,weight:r};let s=this._fonts.get(i);return s||(s={metrics:void 0,texture:void 0},this._fonts.set(i,s),this._promises.push(this._loadFontEntry(s,i))),s}async _loadFontEntry(e,n){try{const r=await this._loadMetadata(n.family),i=ZS(r,n),s=this.fontRepository+vf(n.family)+"/"+i.replace(/\.\w+/,""),o=this._createTexture(s+".png"),a=this._loadFont(s+".json");e.texture=await o,e.metrics=await a}catch(r){console.log("Cannot load font. Using default.",r),e.metrics=this._defaultFontEntry.metrics,e.texture=this._defaultFontEntry.texture}}_loadFont(e){let n=this._fontPromises.get(e);return n||(n=fetch(e).then(r=>{if(!r.ok)throw new Error("Could not load font: "+r.status);return r}).then(r=>r.json()).then(r=>oc(r)),this._fontPromises.set(e,n)),n}_loadMetadata(e){const n=vf(e);let r=this._metadataPromises.get(n);return r||(r=fetch(this.fontRepository+n+"/METADATA.pb").then(i=>{if(!i.ok)throw new Error("Could not load font metadata: "+i.status);return i}).then(i=>i.text()).then(i=>JS(i)).catch(i=>{console.warn(i)}),this._metadataPromises.set(n,r)),r}getDefaultFont(){return this._defaultFontEntry}_createTexture(e){const n=this._webGLHelper.gl;return new Promise((r,i)=>{di(n,{src:e,min:n.LINEAR},(s,o,a)=>{s?i(s):r(o)})})}_createTextureNow(e){const n=this._webGLHelper.gl;let r;const i=new Promise((s,o)=>{r=di(n,{src:e,min:n.LINEAR},(a,c,u)=>{a?o(a):s(c)})});return this._promises.push(i),r}}function vf(t){return t.toLowerCase().replaceAll(/[^\w]/g,"")}function JS(t){const e=t.split(` +`),n=[];let r;for(const i of e)if(i.startsWith("fonts {")&&(r={name:void 0,style:void 0,weight:void 0,filename:void 0,post_script_name:void 0,full_name:void 0,copyright:void 0}),i.startsWith("}")&&(n.push(r),r=void 0),r){let s=i.match(/^\s*([A-Za-z_]+):[ ]?"(.*)"$/);if(s){const o=s[1];r[o]=s[2]}if(s=i.match(/^\s*([A-Za-z_]+):[ ]?(\d+)$/),s){const o=s[1];r[o]=+s[2]}}return n}function ZS(t,e){let n,r=Number.POSITIVE_INFINITY;for(const i of t)if(e.family.localeCompare(i.name,void 0,{sensitivity:"accent"})==0&&e.style==i.style){const s=Math.abs(e.weight-i.weight);s<r&&(r=s,n=i)}return n==null?void 0:n.filename}function QS(t,e){const n=[];let r;for(const i of t.split(` +`))if(i.startsWith(">"))r={identifier:i.match(/>(\S+)/)[1],sequence:""},n.push(r);else if(r)r.sequence+=i.trim();else throw new Error("Invalid fasta file!");return n}class e3{constructor(e,n){this.animator=e,this.disabled=!!n,this.damping=.015,this.acceleration=.3,this.accelerationThreshold=100,this.lowerLimit=.5,this.loop=!1,this.momentum=0,this.timestamp=0,this.callback=null,this._transitionCallback=this.animate.bind(this),this.clear()}clear(){this.momentum=0,this.timestamp=null,this.loop=null,this.callback=null}cancel(){this.loop&&(this.animator.cancelTransition(this._transitionCallback),this.clear())}setMomentum(e,n){if(this.disabled){n(e);return}e*this.momentum<0?this.momentum=0:Math.abs(e)>this.accelerationThreshold?this.momentum=jf([this.momentum,e],this.acceleration):this.momentum=e,this.callback=n,this.loop||this.animate()}animate(e){this.callback(this.momentum);const n=e-this.timestamp||0;this.timestamp=e;const r=Math.abs(this.momentum);this.momentum=Math.sign(this.momentum)*Math.max(0,r-((r*this.damping)**1.5+.04)*n),Math.abs(this.momentum)>this.lowerLimit?(this.loop=!0,this.animator.requestTransition(this._transitionCallback)):this.clear()}}function t3(t){const e={},n=["string","number","boolean"],r=["wheelDelta","wheelDeltaX","wheelDeltaY"];for(const i in t){const s=i;!r.includes(i)&&n.includes(typeof t[s])&&(e[s]=t[s])}return e}const Ef=new Map;async function n3(t,e,n){const r=t.symbol;let i=Ef.get(r)??await s3(t.symbol);return i?(Ef.set(r,i),te`<div class="title"><strong>${i.name}</strong> ${i.description}</div><p class="summary">${i.summary}</p><p class="source">Source: NCBI RefSeq Gene</p>`):null}async function r3(t){console.log("Searching: "+t);const e={mode:"cors"},r=(await fetch(`https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=gene&term=${t}[GENE]&sort=relevance&retmode=json`,e).then(i=>i.json())).esearchresult.idlist[0];return r?(await fetch(`https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esummary.fcgi?db=gene&id=${r}&retmode=json`,e).then(o=>o.json())).result[r]:null}const i3=Wo(r3,500);function s3(t){return i3(t)}const o3=ue(".4~r"),a3=ue(".4~e");function gp(t){return t==null?te`<span class="na">NA</span>`:V(t)?t.substring(0,30):Number.isInteger(t)?""+t:be(t)?Math.abs(t)>Math.pow(10,8)||Math.abs(t)<Math.pow(10,-8)?a3(t):o3(t):_i(t)?t?"True":"False":Me(t)?te`${t.map((e,n)=>[gp(e),n<t.length-1?", ":J])}`:"?"+typeof t+" "+t}async function c3(t,e,n){const r=(c,u)=>{var f;for(const[l,h]of Object.entries(e.encoders))if((f=h==null?void 0:h.accessor)!=null&&f.fields.includes(c))switch(l){case"color":case"fill":case"stroke":return te`<span class="color-legend" style="${`background-color: ${h(u)}`}"></span>`}return""},i=Object.entries(t).filter(([c,u])=>!c.startsWith("_"));if(i.length===0)return;const s=te`<table class="attributes">${i.map(([c,u])=>te`<tr><th>${c}</th><td>${gp(u)} ${r(c,t)}</td></tr>`)}</table>`,o=e.unitView.getTitleText(),a=o?te`<div class="title"><strong>${o}</strong></div>`:"";return te`${a}${s}`}var gt;class ts extends Mn{constructor(n,r,i,s,o,a){super(n,r,i,s,o,a);M(this,gt,[]);this.spec=n,this.needsAxes={x:!0,y:!0}}async initializeChildren(){he(this,gt,await Promise.all(this.spec.layer.map((n,r)=>this.context.createOrImportView(n,this,this,"grid"+r,i=>{if(!Cc(i)&&!Ec(i))throw new vn("LayerView accepts only unit or layer specs as children!",this)}))))}get children(){return S(this,gt).slice()}*[Symbol.iterator](){for(const n of S(this,gt))yield n}render(n,r,i={}){if(this.isConfiguredVisible()){n.pushView(this,r);for(const s of S(this,gt))s.render(n,r,i);n.popView(this)}}propagateInteractionEvent(n){this.handleInteractionEvent(void 0,n,!0);for(let r=S(this,gt).length-1;r>=0;r--)if(S(this,gt)[r].propagateInteractionEvent(n),n.stopped)return;this.handleInteractionEvent(void 0,n,!1)}}gt=new WeakMap;class Cf{constructor(e,n){this.n=e,this.maxCols=n??1/0}get nRows(){return this.maxCols==1/0?1:Math.ceil(this.n/this.maxCols)}get nCols(){return Math.min(this.n,this.maxCols)}get rowIndices(){const e=[],n=this.nCols,r=this.nRows;for(let i=0;i<r;i++){const s=[];e.push(s);for(let o=0;o<n;o++){const a=i*n+o;a<this.n&&s.push(a)}}return e}get colIndices(){const e=[],n=this.nCols,r=this.nRows;for(let i=0;i<n;i++){const s=[];e.push(s);for(let o=0;o<r;o++){const a=o*n+i;a<this.n&&s.push(a)}}return e}getCellIndex(e,n){let r=0;if(this.maxCols==1/0)r=n==0?e:void 0;else{if(e>=this.maxCols)return;r=n*this.nCols+e}return r<this.n?r:void 0}getCellCoords(e){if(!(e<0||e>=this.n))return[e%this.nCols,Math.floor(e/this.nCols)]}}const u3="chromosome_ticks_and_labels",l3={x:"width",y:"height"};function bc(t){return t=="x"?"y":"x"}const Xs={x:["bottom","top"],y:["left","right"]},_u=Object.fromEntries(Object.entries(Xs).map(([t,e])=>e.map(n=>[n,t])).flat(1));function zt(t){return _u[t]}class xp extends ts{constructor(e,n,r,i,s,o){const a=n=="locus",c={...a?h3:yp,...f3(n,e),...e};super(a?d3(c,n):bp(c,n),r,i,s,`axis_${e.orient}`,{blockEncodingInheritance:!0,contributesToScaleDomain:!1,...o}),this.axisProps=c}getSize(){const e={px:this.getPerpendicularSize()},n={grow:1};return _u[this.axisProps.orient]=="x"?new Nt(n,e):new Nt(e,n)}getPerpendicularSize(){return Ru(this.axisProps)}isPickingSupported(){return!1}}function Ru(t){const e=zt(t.orient);let n=t.ticks&&t.tickSize||0;return t.labels&&(n+=t.labelPadding,e=="x"?n+=t.labelFontSize:n+=30),t.title&&(n+=t.titlePadding+t.titleFontSize),n=Math.min(t.maxExtent||1/0,Math.max(t.minExtent||0,n)),n}const yp={values:null,minExtent:20,maxExtent:1/0,offset:0,domain:!0,domainWidth:1,domainColor:"gray",domainDash:null,domainDashOffset:0,domainCap:"square",ticks:!0,tickSize:5,tickWidth:1,tickColor:"gray",tickDash:null,tickDashOffset:0,tickCap:"square",tickCount:null,tickMinStep:null,labels:!0,labelAlign:"center",labelBaseline:"middle",labelPadding:4,labelFontSize:10,labelLimit:180,labelColor:"black",format:null,titleColor:"black",titleFont:"sans-serif",titleFontSize:10,titlePadding:3};function f3(t,e){const n=e.orient,r=t=="nominal"||t=="ordinal";let i="center",s="middle",o=e.labelAngle??((n=="top"||n=="bottom")&&r?-90:0);switch(n){case"left":i="right";break;case"right":i="left";break;case"top":case"bottom":Math.abs(o)>30?(i=o>0==(n=="bottom")?"left":"right",s="middle"):s=n=="top"?"alphabetic":"top";break}return{labelAlign:i,labelAngle:o,labelBaseline:s}}function bp(t,e){const n={...t,extent:Ru(t)},r=zt(n.orient),i=bc(r),s=n.orient=="bottom"||n.orient=="right"?1:-1,o=n.orient=="bottom"||n.orient=="left"?1:0,a=()=>({name:"domain",data:{values:[0]},mark:{type:"rule",clip:!1,strokeDash:n.domainDash,strokeCap:n.domainCap,color:n.domainColor,[i]:o,size:n.domainWidth}}),c=()=>({name:"labels",mark:{type:"text",clip:!1,align:n.labelAlign,angle:n.labelAngle,baseline:n.labelBaseline,[i+"Offset"]:(n.tickSize+n.labelPadding)*s,[i]:o,size:n.labelFontSize,color:n.labelColor,minBufferSize:1500},encoding:{[r]:{field:"value",type:e},text:{field:"label"}}}),u=()=>({name:"ticks",mark:{type:"rule",clip:!1,strokeDash:n.tickDash,strokeCap:n.tickCap,color:n.tickColor,size:n.tickWidth,minBufferSize:300},encoding:{[i]:{value:o},[i+"2"]:{value:o-n.tickSize/n.extent*(o?1:-1)}}}),f=()=>({name:"title",data:{values:[0]},mark:{type:"text",clip:!1,align:"center",baseline:n.orient=="bottom"?"bottom":"top",angle:[0,90,0,-90][["top","right","bottom","left"].indexOf(n.orient)],text:n.title,color:n.titleColor,[r]:.5,[i]:1-o}}),l=()=>{const p={name:"ticks_and_labels",encoding:{[r]:{field:"value",type:e}},layer:[]};return n.ticks&&p.layer.push(u()),n.labels&&p.layer.push(c()),p},h={resolve:{scale:{[r]:"forced"}},[l3[bc(r)]]:n.extent,data:{lazy:{type:"axisTicks",channel:r,axis:t}},layer:[]};return n.domain&&h.layer.push(a()),(n.ticks||n.labels)&&h.layer.push(l()),n.title&&h.layer.push(f()),h}const h3={...yp,chromTicks:!0,chromTickSize:18,chromTickWidth:1,chromTickColor:"#989898",chromTickDash:[4,2],chromTickDashOffset:1,chromLabels:!0,chromLabelFontSize:13,chromLabelFontWeight:"normal",chromLabelFontStyle:"normal",chromLabelColor:"black",chromLabelAlign:"left",chromLabelPadding:7};function d3(t,e){const n={...t,extent:Ru(t)},r=zt(n.orient),i=bc(r),s=n.orient=="bottom"||n.orient=="left"?1:0,o=()=>({name:"chromosome_ticks",mark:{type:"rule",strokeDash:t.chromTickDash,strokeDashOffset:t.chromTickDashOffset,[i]:s,[i+"2"]:s-n.chromTickSize/n.extent*(s?1:-1),color:t.chromTickColor,size:n.chromTickWidth}}),a=()=>{let f;switch(n.orient){case"top":f={y:0,angle:0,paddingX:4,dy:-n.chromLabelPadding,viewportEdgeFadeWidthLeft:20,viewportEdgeFadeWidthRight:20,viewportEdgeFadeDistanceRight:-10,viewportEdgeFadeDistanceLeft:-20};break;case"bottom":f={y:1,angle:0,paddingX:4,dy:n.chromLabelPadding+n.chromLabelFontSize*.73,viewportEdgeFadeWidthLeft:20,viewportEdgeFadeWidthRight:20,viewportEdgeFadeDistanceRight:-10,viewportEdgeFadeDistanceLeft:-20};break;case"left":f={x:1,angle:-90,paddingY:4,dy:-n.chromLabelPadding,viewportEdgeFadeWidthBottom:20,viewportEdgeFadeWidthTop:20,viewportEdgeFadeDistanceBottom:-20,viewportEdgeFadeDistanceTop:-10};break;case"right":f={x:0,angle:90,align:"right",paddingY:4,dy:-n.chromLabelPadding};break;default:f={}}return{name:"chromosome_labels",mark:{type:"text",size:n.chromLabelFontSize,font:n.chromLabelFont,fontWeight:n.chromLabelFontWeight,fontStyle:n.chromLabelFontStyle,color:n.chromLabelColor,align:t.chromLabelAlign,baseline:"alphabetic",clip:!1,...f},encoding:{[r+"2"]:{field:"continuousEnd",type:e},text:{field:"name"}}}};let c;switch(n.orient){case"bottom":case"top":c={};break;case"left":c={labelAngle:-90,labelAlign:"center",labelPadding:6};break;case"right":c={labelAngle:90,labelAlign:"center",labelPadding:6};break;default:c={}}const u=bp({...t,...c},e);if(t.chromTicks||t.chromLabels){const f={name:u3,data:{lazy:{type:"axisGenome",channel:zt(n.orient)}},encoding:{[r]:{field:"continuousStart",type:e,band:0}},layer:[]};if(t.chromTicks&&f.layer.push(o()),t.chromLabels){f.layer.push(a());let l;u.layer.filter(h=>h.name=="ticks_and_labels").forEach(h=>h.layer.filter(p=>p.name=="labels").forEach(p=>{l=p.mark})),l&&(n.orient=="top"||n.orient=="bottom"?(l.viewportEdgeFadeWidthLeft=30,l.viewportEdgeFadeDistanceLeft=40):(l.viewportEdgeFadeWidthBottom=30,l.viewportEdgeFadeDistanceBottom=40))}u.layer.push(f)}return u}class p3 extends ts{constructor(e,n,r,i,s,o){const c={...n=="locus"?m3:Ap,...e};super(b3(c,n),r,i,s,`axisGrid_${e.orient}`,{blockEncodingInheritance:!0,contributesToScaleDomain:!1,...o}),this.axisProps=c}getOrient(){return this.axisProps.orient}isPickingSupported(){return!1}}const Ap={values:null,grid:!1,gridCap:"butt",gridColor:"lightgray",gridDash:null,gridOpacity:1,gridWidth:1,tickCount:null,tickMinStep:null},m3={...Ap,chromGrid:!1,chromGridCap:"butt",chromGridColor:"gray",chromGridDash:[1,5],chromGridOpacity:1,chromGridWidth:1};function g3(t,e){const n=t,r=zt(n.orient);return{name:"grid_lines",data:{lazy:{type:"axisTicks",channel:r,axis:t}},mark:{type:"rule",strokeDash:n.gridDash,strokeCap:n.gridCap,color:n.gridColor,size:n.gridWidth,opacity:n.gridOpacity,minBufferSize:300},encoding:{[r]:{field:"value",type:e}}}}function x3(t,e){const n=t,r=zt(n.orient);return{name:"chromosome_lines",data:{lazy:{type:"axisGenome",channel:r}},mark:{type:"rule",strokeDash:n.chromGridDash,strokeCap:n.chromGridCap,color:n.chromGridColor,size:n.chromGridWidth,opacity:n.chromGridOpacity},encoding:{[r]:{field:"continuousStart",type:e,band:0}}}}function y3(t,e){const n=t,r=zt(n.orient);return{name:"chromosome_fill",data:{lazy:{type:"axisGenome",channel:r}},mark:{type:"rect"},encoding:{[r]:{field:"continuousStart",type:e,band:0},[r+"2"]:{field:"continuousEnd",band:0},fill:{field:"odd",type:"nominal",scale:{domain:[!1,!0],range:[n.chromGridFillEven??"white",n.chromGridFillOdd??"white"]}},opacity:{field:"odd",type:"nominal",scale:{type:"ordinal",domain:[!1,!0],range:[n.chromGridFillEven?1:0,n.chromGridFillOdd?1:0]}}}}}function b3(t,e){const n={...t},r=[];return n.chromGrid&&(n.chromGridFillOdd||n.chromGridFillEven)&&r.push(y3(n,e)),n.chromGrid&&n.chromGridOpacity>0&&r.push(x3(n,e)),n.grid&&n.gridOpacity>0&&r.push(g3(n,e)),{name:"grid_layers",configurableVisibility:!1,resolve:{scale:{[zt(t.orient)]:"forced",fill:"independent",opacity:"independent"}},layer:r}}const Sf={anchor:"middle",frame:"group",offset:10,orient:"top",align:void 0,angle:0,baseline:"alphabetic",dx:0,dy:0,color:void 0,font:void 0,fontSize:12,fontStyle:"normal",fontWeight:"normal"},A3={orient:"left",anchor:"middle",align:"right",baseline:"middle",angle:0,fontSize:12},w3={orient:"top",anchor:"start",align:"left",baseline:"top",offset:-10,dx:10,fontSize:12},v3={start:0,middle:.5,end:1},E3={start:"left",middle:"center",end:"right"};function C3(t){if(!t)return;const e=V(t)?{text:t}:t;if(!e.text||e.orient=="none")return;const n={"track-title":A3,overlay:w3}[e.style]??{},r={...Sf,...n,...e};let i={},s={x:0,y:0};const o=v3[r.anchor??"middle"];switch(r.orient){case"top":s={x:o,y:1},i={baseline:"alphabetic",angle:0};break;case"right":s={x:1,y:1-o},i={baseline:"alphabetic",angle:90};break;case"bottom":s={x:o,y:0},i={baseline:"top",angle:0};break;case"left":s={x:0,y:o},i={baseline:"alphabetic",angle:-90};break}const a={...Sf,...i,...n,...e},c={xOffset:0,yOffset:0};switch(r.orient){case"top":c.yOffset=-a.offset;break;case"right":c.xOffset=a.offset;break;case"bottom":c.yOffset=a.offset;break;case"left":c.xOffset=-a.offset;break}return{configurableVisibility:!1,data:{values:[{}]},mark:{type:"text",tooltip:null,clip:!1,...s,...c,text:a.text,align:a.align??E3[a.anchor],angle:a.angle,baseline:a.baseline,dx:a.dx,dy:a.dy,color:a.color,font:a.font,size:a.fontSize,fontStyle:a.fontStyle,fontWeight:a.fontWeight}}}function S3(t,e,n,r){if(t.type=="wheel"){t.uiEvent.preventDefault();const i=t.uiEvent,s=i.deltaMode?120:1;let{x:o,y:a}=t.point;if(r){const c=r.mark.encoders;c.x&&!c.x2&&!c.x.constantValue&&(o=+c.x(r.datum)*e.width+e.x),c.y&&!c.y2&&!c.y.constantValue&&(a=(1-+c.y(r.datum))*e.height+e.y)}Math.abs(i.deltaX)<Math.abs(i.deltaY)?n({x:o,y:a,xDelta:0,yDelta:0,zDelta:i.deltaY*s/300}):n({x:o,y:a,xDelta:-i.deltaX*s,yDelta:0,zDelta:0})}else if(t.type=="mousedown"&&t.uiEvent.button===0){const i=t.uiEvent;i.preventDefault();let s=i;const o=c=>{n({x:s.clientX,y:s.clientY,xDelta:c.clientX-s.clientX,yDelta:c.clientY-s.clientY,zDelta:0}),s=c},a=c=>{document.removeEventListener("mousemove",o),document.removeEventListener("mouseup",a)};document.addEventListener("mouseup",a,!1),document.addEventListener("mousemove",o,!1)}}var Zn,Qn,Le,dn,er,xt,sn,eo,wp,pn,Or,Si,Ac,Fi,wc,Ti,vc,to,vp,tr,vs,no,Ep;class F3 extends Mn{constructor(n,r,i,s,o,a,c){super(n,r,i,s,o,c);M(this,xt);M(this,eo);M(this,pn);M(this,Si);M(this,Fi);M(this,Ti);M(this,to);M(this,tr);M(this,no);M(this,Zn,1/0);M(this,Qn,10);M(this,Le,[]);M(this,dn,{});M(this,er,0);this.spec=n,he(this,Qn,n.spacing??10),he(this,Zn,a),he(this,Le,[]),this.wrappingFacet=!1}appendChild(n){n.layoutParent??(n.layoutParent=this),S(this,Le).push(new Tf(n,this,S(this,er))),Ou(this,er)._++}setChildren(n){he(this,Le,[]);for(const r of n)this.appendChild(r)}replaceChild(n,r){const i=S(this,Le).findIndex(s=>s.view==n);if(i>=0)S(this,Le)[i]=new Tf(r,this,S(this,er));else throw new Error("Not my child view!")}get children(){return S(this,Le).map(n=>n.view)}get childCount(){return S(this,Le).length}async createAxes(){const n=[];for(const r of br){const i=this.resolutions.axis[r];if(i){const s=i.getAxisProps();if(s){const o={title:i.getTitle(),orient:Xs[r][0],...s},a=new xp(o,i.scaleResolution.type,this.context,this,this);n.push(a.initializeChildren()),S(this,dn)[r]=a}}}return Promise.all([...n,...S(this,Le).map(r=>r.createAxes())])}*[Symbol.iterator](){for(const n of S(this,Le))yield*n.getChildren();for(const n of Object.values(S(this,dn)))yield n}getOverhang(){return I(this,to,vp).call(this).union(I(this,tr,vs).call(this))}getSize(){return this._cache("size",()=>new Nt(I(this,Fi,wc).call(this,"column"),I(this,Fi,wc).call(this,"row")).addPadding(I(this,tr,vs).call(this)))}render(n,r,i={}){if(!this.isConfiguredVisible())return;this.layoutParent||(r=r.shrink(this.getPadding())),r=r.shrink(I(this,tr,vs).call(this)),n.pushView(this,r);const s={devicePixelRatio:this.context.devicePixelRatio},o=cf(I(this,Si,Ac).call(this,"column"),r.width,s),a=cf(I(this,Si,Ac).call(this,"row"),r.height,s),c=new Cf(S(this,xt,sn).length,S(this,Zn)??1/0),u=f=>Math.round(f*devicePixelRatio)/devicePixelRatio;for(const[f,l]of S(this,xt,sn).entries()){const{view:h,axes:p,gridLines:d,background:m,backgroundStroke:g,title:x}=l,[b,A]=c.getCellCoords(f),E=o[I(this,Ti,vc).call(this,"column",b)],F=a[I(this,Ti,vc).call(this,"row",A)],C=h.getViewportSize(),w=h.getSize(),L=h.getOverhang(),Y=E.location-L.left,j=F.location-L.top,_=(oe,Ze)=>(oe[Ze].grow?(Ze=="width"?E:F).size:oe[Ze].px)+L[Ze],ee=_(C,"width"),le=_(C,"height"),Ve=_(w,"width"),Kt=_(w,"height"),lt=l.scrollbars.horizontal,ft=l.scrollbars.vertical,Tt=lt?()=>u(lt.viewportOffset):()=>0,Be=ft?()=>u(ft.viewportOffset):()=>0,ke=new vt(()=>r.x+Y,()=>r.y+j,()=>ee,()=>le),ns=h.isScrollable(),Jt=ns?new vt(()=>r.x+Y-Tt(),()=>r.y+j-Be(),()=>Ve,()=>Kt):ke;l.coords=ke;const Er=i.clipRect?ke.intersect(i.clipRect):ke;m==null||m.render(n,Er,{...i,clipRect:void 0});for(const oe of Object.values(d))oe.render(n,ke,i);const rs=_3(h)||ns;rs&&h.render(n,Jt,{...i,clipRect:Er}),g==null||g.render(n,Er,{...i,clipRect:void 0});for(const[oe,Ze]of Object.entries(p)){const Ge=oe=="left"||oe=="right"?"vertical":"horizontal",Cr=l.scrollbars[Ge],T=Cr?ke.modify(Ge=="vertical"?{y:()=>Jt.y,height:Kt}:{x:()=>Jt.x,width:Ve}):ke,B=Ff(T,oe,Ze);let k=i.clipRect;Cr&&(k=B.intersect(k).intersect(Cr?ke.modify(Ge=="vertical"?{x:-1e5,width:2e5}:{y:-1e5,height:2e5}):void 0)),Ze.render(n,B,{...i,clipRect:k})}for(const oe of Object.values(S(this,dn))){const Ge=oe.axisProps.orient;(Ge=="left"&&b==0||Ge=="right"&&b==c.nCols-1||Ge=="top"&&A==0||Ge=="bottom"&&A==c.nRows-1)&&oe.render(n,Ff(ke.shrink(l.view.getOverhang()),Ge,oe),i)}rs||h.render(n,Jt,i);for(const oe of Object.values(l.scrollbars))oe.updateScrollbar(ke,Jt),oe.render(n,r,i);x==null||x.render(n,ke,i)}n.popView(this)}propagateInteractionEvent(n){if(this.handleInteractionEvent(void 0,n,!0),n.stopped)return;const r=S(this,xt,sn).find(s=>s.coords.containsPoint(n.point.x,n.point.y));for(const s of Object.values((r==null?void 0:r.scrollbars)??{}))if(s.coords.containsPoint(n.point.x,n.point.y)&&(s.propagateInteractionEvent(n),n.stopped))return;const i=r==null?void 0:r.view;i&&(i.propagateInteractionEvent(n),(i instanceof Ne||i instanceof ts)&&S3(n,r.coords,s=>I(this,no,Ep).call(this,r.coords,r.view,s),this.context.getCurrentHover())),!n.stopped&&this.handleInteractionEvent(void 0,n,!1)}getDefaultResolution(n,r){return"independent"}}Zn=new WeakMap,Qn=new WeakMap,Le=new WeakMap,dn=new WeakMap,er=new WeakMap,xt=new WeakSet,sn=function(){return S(this,Le).filter(n=>n.view.isConfiguredVisible())},eo=new WeakSet,wp=function(){return new Cf(S(this,xt,sn).length,S(this,Zn)??1/0)},pn=new WeakSet,Or=function(n){const r=n=="column"?"width":"height",i=(s,o)=>s.map(a=>{const u=S(this,xt,sn)[a].getOverhangAndPadding();return n=="column"?o?u.right:u.left:o?u.bottom:u.top}).reduce((a,c)=>Math.max(a,c),0);return this._cache(`size/directionSizes/${n}`,()=>S(this,eo,wp)[n=="column"?"colIndices":"rowIndices"].map(s=>({axisBefore:i(s,0),axisAfter:i(s,1),view:DE(s.map(o=>S(this,xt,sn)[o].view.getViewportSize()[r]))})))},Si=new WeakSet,Ac=function(n){const r=I(this,pn,Or).call(this,n),i=[];i.push(Ur);for(const[s,o]of r.entries())s>0&&i.push({px:S(this,Qn),grow:0}),(s==0||this.wrappingFacet)&&i.push(Ur),i.push({px:o.axisBefore,grow:0}),i.push(o.view),i.push({px:o.axisAfter,grow:0}),(s==r.length-1||this.wrappingFacet)&&i.push(Ur);return i},Fi=new WeakSet,wc=function(n){let r=0,i=0;const s=n=="row"?this.spec.height:this.spec.width;if(s||s===0)return Vd(s);const o=I(this,pn,Or).call(this,n);for(const[a,c]of o.entries())a>0&&(i+=S(this,Qn)),(a==0||this.wrappingFacet)&&(i+=0),i+=c.axisBefore,i+=c.view.px??0,r+=c.view.grow??0,i+=c.axisAfter,(a==o.length-1||this.wrappingFacet)&&(i+=0);return{px:i,grow:r}},Ti=new WeakSet,vc=function(n,r){return n=="row"&&this.wrappingFacet?1+6*r+2:2+4*r+1},to=new WeakSet,vp=function(){const n=I(this,pn,Or).call(this,"column"),r=I(this,pn,Or).call(this,"row");return!n.length||!r.length?pe.zero():new pe(r.at(0).axisBefore,n.at(-1).axisAfter,r.at(-1).axisAfter,n.at(0).axisBefore)},tr=new WeakSet,vs=function(){const n=r=>{const i=_u[r],s=S(this,dn)[i];return(s==null?void 0:s.axisProps.orient)!==r?0:Math.max(s.getPerpendicularSize()+s.axisProps.offset,0)};return new pe(n("top"),n("right"),n("bottom"),n("left"))},no=new WeakSet,Ep=function(n,r,i){for(const[s,o]of Object.entries(I3(r))){if(o.size<=0)continue;const a=n.normalizePoint(i.x,i.y),c=n.normalizePoint(i.x+i.xDelta,i.y+i.yDelta),u={x:c.x-a.x,y:c.y-a.y};for(const f of o)f.zoom(2**i.zDelta,s=="y"?1-a[s]:a[s],s=="x"?u.x:-u.y)}this.context.animator.requestRender()};function T3(t){if(!(!t||!t.fill||t.fillOpacity===0))return{configurableVisibility:!1,data:{values:[{}]},mark:{color:t.fill,opacity:t.fillOpacity??1,type:"rect",clip:!1,tooltip:null,minHeight:1,minOpacity:0}}}function D3(t){if(!(!t||!t.stroke||t.strokeWidth===0||t.strokeOpacity===0))return{configurableVisibility:!1,resolve:{scale:{x:"excluded",y:"excluded"},axis:{x:"excluded",y:"excluded"}},data:{values:[{x:0,y:0,x2:1,y2:0},{x:1,y:0,x2:1,y2:1},{x:1,y:1,x2:0,y2:1},{x:0,y:1,x2:0,y2:0}]},mark:{size:t.strokeWidth??1,color:t.stroke??"lightgray",strokeCap:"square",strokeOpacity:t.strokeOpacity??1,type:"rule",clip:!1,tooltip:null},encoding:{x:{field:"x",type:"quantitative",scale:null},y:{field:"y",type:"quantitative",scale:null},x2:{field:"x2"},y2:{field:"y2"}}}}function I3(t){const e={x:new Set,y:new Set};return t.visit(n=>{for(const[r,i]of Object.entries(e)){const s=n.getScaleResolution(r);s&&s.isZoomable()&&i.add(s)}}),e}function _3(t){let e=!0;return t.visit(n=>{n instanceof Ne&&e&&(e=n.mark.properties.clip===!0)}),e}function Ff(t,e,n){const r=n.axisProps,i=n.getPerpendicularSize();if(e=="bottom")return t.translate(0,t.height+r.offset).modify({height:i});if(e=="top")return t.translate(0,-i-r.offset).modify({height:i});if(e=="left")return t.translate(-i-r.offset,0).modify({width:i});if(e=="right")return t.translate(t.width+r.offset,0).modify({width:i})}class Tf{constructor(e,n,r){if(this.layoutParent=n,this.view=e,this.serial=r,this.background=void 0,this.backgroundStroke=void 0,this.axes={},this.gridLines={},this.scrollbars={},this.title=void 0,this.coords=vt.ZERO,e.needsAxes.x||e.needsAxes.y){const i=e.spec,s="view"in i?i==null?void 0:i.view:void 0,o=T3(s);o&&(this.background=new Ne(o,n.context,n,e,"background"+r,{blockEncodingInheritance:!0}));const a=D3(s);a&&(this.backgroundStroke=new Ne(a,n.context,n,e,"backgroundStroke"+r,{blockEncodingInheritance:!0}));const c=C3(e.spec.title);if(c){const u=new Ne(c,n.context,n,e,"title"+r,{blockEncodingInheritance:!0});this.title=u}}e.spec.viewportWidth!=null&&(this.scrollbars.horizontal=new Df(this,"horizontal")),e.spec.viewportHeight!=null&&(this.scrollbars.vertical=new Df(this,"vertical"))}*getChildren(){this.background&&(yield this.background),this.backgroundStroke&&(yield this.backgroundStroke),this.title&&(yield this.title),yield*Object.values(this.axes),yield*Object.values(this.gridLines),yield this.view,yield*Object.values(this.scrollbars)}async createAxes(){const{view:e,axes:n,gridLines:r}=this,i=(a,c)=>{const u=a.getAxisProps();if(u===null)return;const f=u?{...u}:{};if(!f.orient){for(const l of Xs[c])if(!n[l]){f.orient=l;break}if(!f.orient)throw new Error("No slots available for an axis! Perhaps a LayerView has more than two children?")}if(f.title??(f.title=a.getTitle()),!Xs[c].includes(f.orient))throw new Error(`Invalid axis orientation "${f.orient}" on channel "${c}"!`);return f},s=async(a,c,u)=>{const f=i(a,c);if(f){if(n[f.orient])throw new Error(`An axis with the orient "${f.orient}" already exists!`);const l=new xp(f,a.scaleResolution.type,this.layoutParent.context,this.layoutParent,u);n[f.orient]=l,await l.initializeChildren()}},o=async(a,c,u)=>{const f=i(a,c);if(f&&(f.grid||f.chromGrid)){const l=new p3(f,a.scaleResolution.type,this.layoutParent.context,this.layoutParent,u);r[f.orient]=l,await l.initializeChildren()}};for(const a of["x","y"])if(e.needsAxes[a]){const c=e.resolutions.axis[a];if(!c)continue;await s(c,a,e)}for(const a of["x","y"])if(e.needsAxes[a]){const c=e.getAxisResolution(a);if(!c)continue;await o(c,a,e)}if(e instanceof ts){for(const a of e)for(const[c,u]of Object.entries(a.resolutions.axis)){const f=u.getAxisProps();f&&f.orient&&await s(u,c,a)}for(const a of e)for(const[c,u]of Object.entries(a.resolutions.axis)){const f=u.getAxisProps();f&&!f.orient&&await s(u,c,a)}}[...Object.values(n),...Object.values(r)].forEach(a=>a.visit(c=>{c instanceof Ne&&c.resolve("scale")}))}getOverhang(){const e=n=>{const r=this.axes[n];return r?Math.max(r.getPerpendicularSize()+r.axisProps.offset,0):0};return new pe(e("top"),e("right"),e("bottom"),e("left")).add(this.view.getOverhang())}getOverhangAndPadding(){return this.getOverhang().add(this.view.getPadding())}}class Df extends Ne{constructor(e,n){const r={scrollbarSize:8,scrollbarPadding:2};super({data:{values:[{}]},mark:{type:"rect",fill:"#b0b0b0",fillOpacity:.6,stroke:"white",strokeWidth:1,strokeOpacity:1,cornerRadius:5,clip:!1},configurableVisibility:!1},e.layoutParent.context,e.layoutParent,e.view,"scrollbar-"+n,{blockEncodingInheritance:!0}),this.config=r,this.scrollDirection=n,this.viewportOffset=0,this.maxScrollOffset=0,this.scrollbarCoords=vt.ZERO,this.addInteractionEventListener("mousedown",(i,s)=>{if(s.stopPropagation(),this.maxScrollOffset<=0)return;const o=h=>n=="vertical"?h.clientY:h.clientX,a=s.uiEvent;a.preventDefault();const c=this.getScrollOffset(),u=o(a),f=h=>{const p=ai(o(h)-u+c,0,this.maxScrollOffset);this.viewportOffset=p/this.maxScrollOffset*this.maxViewportOffset,this.context.animator.requestRender()},l=()=>{document.removeEventListener("mousemove",f),document.removeEventListener("mouseup",l)};document.addEventListener("mouseup",l,!1),document.addEventListener("mousemove",f,!1)})}getScrollOffset(){return this.viewportOffset/this.maxViewportOffset*this.maxScrollOffset}render(e,n,r){super.render(e,this.scrollbarCoords,r)}updateScrollbar(e,n){const r=this.config.scrollbarPadding,i=this.config.scrollbarSize,s=this.scrollDirection=="horizontal"?"width":"height",o=Math.min(1,e[s]/n[s]),a=e[s]-2*r,c=o*a;this.maxScrollOffset=a-c,this.maxViewportOffset=n[s]-e[s],this.viewportOffset=ai(this.viewportOffset,0,this.maxViewportOffset),this.scrollbarCoords=this.scrollDirection=="vertical"?new vt(()=>e.x+e.width-i-r,()=>e.y+r+this.getScrollOffset(),()=>i,()=>c):new vt(()=>e.x+r+this.getScrollOffset(),()=>e.y+e.height-i-r,()=>c,()=>i)}}class Ca extends F3{constructor(e,n,r,i,s){super(e,n,r,i,s,Sc(e)?e.columns:Es(e)?1:1/0),this.spec=e}async initializeChildren(){const e=this.spec,n=Sc(e)?e.concat:Es(e)?e.vconcat:e.hconcat;this.setChildren(await Promise.all(n.map((r,i)=>this.context.createOrImportView(r,this,this,"grid"+i)))),await this.createAxes()}getDefaultResolution(e,n){return n=="axis"?"independent":Es(this.spec)&&e==="x"||Sp(this.spec)&&e==="y"?"shared":"independent"}}const Cp="viewRoot";var nr;class R3{constructor(e={}){M(this,nr,new Map);this.options={allowImport:!0,wrapRoot:!0,...e};const n=r=>(i,s,o,a,c)=>new r(i,s,o,a,i.name??c);this.addViewType(Cc,n(ts)),this.addViewType(Ec,n(Ne)),this.addViewType(Es,n(Ca)),this.addViewType(Sp,n(Ca)),this.addViewType(Sc,n(Ca)),this.addViewType(B3,()=>{throw new Error("SampleView is not supported by the @genome-spy/core package. Use @genome-spy/app instead!")})}addViewType(e,n){S(this,nr).set(e,n)}createView(e,n,r,i,s){for(const[o,a]of S(this,nr))if(o(e))return a(e,n,r,i,s);throw new Error("Invalid spec, cannot figure out the view type from the properties: "+JSON.stringify([...Object.keys(e)]))}isViewSpec(e){const n=[...S(this,nr).keys()].filter(r=>r(e));if(n.length>1)throw new Error("Ambiguous spec. Cannot create a view!");return n.length==1}async createOrImportView(e,n,r,i,s,o){let a;if(M3(e))if(this.options.allowImport)a=await zS(e,i.getBaseUrl(),n),o&&o(a);else throw new vn("Importing views is not allowed!",r);else a=e;!i&&this.options.wrapRoot&&(Ec(a)||Cc(a))&&s===Cp&&(a={name:"implicitRoot",vconcat:[a]});const c=this.createView(a,n,r,i,s);return c instanceof Mn&&await c.initializeChildren(),c}}nr=new WeakMap;function Ec(t){return"mark"in t&&(V(t.mark)||Re(t.mark))}function Cc(t){return"layer"in t&&Re(t.layer)}function M3(t){return"import"in t}function Es(t){return"vconcat"in t&&Me(t.vconcat)}function Sp(t){return"hconcat"in t&&Me(t.hconcat)}function Sc(t){return"concat"in t&&Me(t.concat)}function B3(t){return"samples"in t&&Re(t.samples)&&"spec"in t&&Re(t.spec)}var rr,mn,Di,gn;class k3{constructor(){M(this,rr,void 0);M(this,mn,void 0);M(this,Di,void 0);M(this,gn,void 0);he(this,rr,new Map),he(this,mn,new Set),he(this,gn,new Map),he(this,Di,new Proxy(S(this,rr),{get(e,n){return V(n)?e.get(n):void 0}}))}allocateSetter(e){if(S(this,mn).has(e))throw new Error("Setter already allocated for parameter: "+e);return S(this,mn).add(e),n=>{S(this,rr).set(e,n);const r=S(this,gn).get(e);if(r)for(const i of r)i()}}createExpression(e){const n=vo(e,S(this,Di));for(const r of n.globals)if(!S(this,mn).has(r))throw new Error(`Unknown variable "${r}" in expression: ${e}`);return n.addListener=r=>{for(const i of n.globals){const s=S(this,gn).get(i)??new Set;S(this,gn).set(i,s),s.add(r)}},n}}rr=new WeakMap,mn=new WeakMap,Di=new WeakMap,gn=new WeakMap;gh("fasta",QS);class O3{constructor(e,n,r={}){this.container=e;const i=document.createElement("style");i.innerHTML=V1,e.appendChild(i),this.spec=n,this.accessorFactory=new Bb,this.viewFactory=new R3,this.namedDataProviders=[],this.animator=new WS(()=>this.renderAll()),this.genomeStore=void 0,this.viewVisibilityPredicate=s=>s.isVisibleInSpec(),this._renderingContext=void 0,this._pickingContext=void 0,this._dirtyPickingBuffer=!1,this._currentHover=void 0,this._wheelInertia=new e3(this.animator),this._keyboardListeners=new Map,this._eventListeners=new Map,this._extraBroadcastListeners=new Map,this.tooltipHandlers={default:c3,refseqgene:n3,...r.tooltipHandlers??{}},this.viewRoot=void 0,this._paramBroker=new k3}registerNamedDataProvider(e){this.namedDataProviders.unshift(e)}getNamedDataFromProvider(e){for(const n of this.namedDataProviders){const r=n(e);if(r)return r}}updateNamedData(e,n){const r=this.viewRoot.context.dataFlow.findNamedDataSource(e);if(!r)throw new Error("No such named data source: "+e);r.dataSource.updateDynamicData(n),xc(r.hosts),this.animator.requestRender()}broadcast(e,n){var i;const r={type:e,payload:n};this.viewRoot.visit(s=>s.handleBroadcast(r)),(i=this._extraBroadcastListeners.get(e))==null||i.forEach(s=>s(r))}_prepareContainer(){this.container.classList.add("genome-spy"),this.container.classList.add("loading"),this._glHelper=new Xv(this.container,()=>this.viewRoot?US(this.viewRoot):{width:void 0,height:void 0},this.spec.background),this.loadingMessageElement=document.createElement("div"),this.loadingMessageElement.className="loading-message",this.loadingMessageElement.innerHTML='<div class="message">Loading<span class="ellipsis">...</span></div>',this.container.appendChild(this.loadingMessageElement),this.tooltip=new H1(this.container),this.loadingMessageElement.querySelector(".message").addEventListener("transitionend",()=>{this.loadingMessageElement.style.display="none"})}destroy(){this.container.classList.remove("genome-spy"),this.container.classList.remove("loading");for(const[e,n]of this._keyboardListeners)for(const r of n)document.removeEventListener(e,r);for(this._glHelper.finalize();this.container.firstChild;)this.container.firstChild.remove()}async _prepareViewsAndData(){this.spec.genome&&(this.genomeStore=new jS(this.spec.baseUrl),await this.genomeStore.initialize(this.spec.genome));const e=this,n={dataFlow:new hp,accessorFactory:this.accessorFactory,glHelper:this._glHelper,animator:this.animator,genomeStore:this.genomeStore,fontManager:new KS(this._glHelper),get devicePixelRatio(){return e._glHelper.dpr},paramBroker:this._paramBroker,requestLayoutReflow:()=>{},updateTooltip:this.updateTooltip.bind(this),getNamedDataFromProvider:this.getNamedDataFromProvider.bind(this),getCurrentHover:()=>this._currentHover,addKeyboardListener:(c,u)=>{document.addEventListener(c,u);let f=this._keyboardListeners.get(c);f||(f=[],this._keyboardListeners.set(c,f)),f.push(u)},addBroadcastListener(c,u){const f=e._extraBroadcastListeners;let l=f.get(c);l||(l=new Set,f.set(c,l)),l.add(u)},removeBroadcastListener(c,u){var l;(l=e._extraBroadcastListeners.get(c))==null||l.delete(u)},isViewConfiguredVisible:e.viewVisibilityPredicate,isViewSpec:c=>e.viewFactory.isViewSpec(c),createView:function(c,u,f,l){return e.viewFactory.createView(c,n,u,f,l)},createOrImportView:async function(c,u,f,l,h){return e.viewFactory.createOrImportView(c,n,u,f,l,h)}},r=this.spec;r.datasets&&this.registerNamedDataProvider(c=>r.datasets[c]),this.viewRoot=await n.createOrImportView(r,null,null,Cp),LS(this.viewRoot),NS(this.viewRoot);const i=this.viewRoot.getDescendants();i.forEach(c=>c.configureViewOpacity()),this._glHelper.invalidateSize();const s=i.filter(c=>c instanceof Ne),o=RS(this.viewRoot,n.dataFlow);PS(o),this.broadcast("dataFlowBuilt",o),s.forEach(c=>c.mark.initializeEncoders());const a=Promise.all(s.map(c=>c.mark.initializeGraphics()));for(const c of s)o.addObserver(u=>{c.mark.initializeData(),c.mark.updateGraphicsData()},c);await n.fontManager.waitUntilReady(),o.initialize(),await Promise.all(o.dataSources.map(c=>c.load())),xc(this.viewRoot),this.broadcast("dataLoaded"),await a,this.viewRoot.visit(c=>{for(const u of Object.values(c.resolutions.scale))this._glHelper.createRangeTexture(u)});for(const c of s)c.mark.finalizeGraphicsInitialization();n.requestLayoutReflow=this.computeLayout.bind(this),this.viewRoot.visit(c=>As(c,"size")),this._glHelper.invalidateSize()}async launch(){try{return this._prepareContainer(),await this._prepareViewsAndData(),this.registerMouseEvents(),this.computeLayout(),this.animator.requestRender(),this._glHelper.addEventListener("resize",()=>{this.computeLayout(),this.renderAll()}),!0}catch(e){const n=`${e.view?`At "${e.view.getPathString()}": `:""}${e.toString()}`;return console.error(e.stack),P3(this.container,n),!1}finally{this.container.classList.remove("loading"),window.setTimeout(()=>{this.loadingMessageElement.style.display="none"},2e3)}}registerMouseEvents(){const e=this._glHelper.canvas,n=r=>{var i;if(r instanceof MouseEvent){r.type=="mousemove"&&(this.tooltip.handleMouseMove(r),this._tooltipUpdateRequested=!1,r.buttons==0&&this.renderPickingFramebuffer());const s=e.getBoundingClientRect(),o=new GS(r.clientX-s.left-e.clientLeft,r.clientY-s.top-e.clientTop),a=c=>{this.viewRoot.propagateInteractionEvent(new VS(o,c)),this._tooltipUpdateRequested||this.tooltip.clear()};if(r.type!="wheel"&&this._wheelInertia.cancel(),r.type=="mousemove")this._handlePicking(o.x,o.y);else if(r.type=="mousedown"||r.type=="mouseup")this.renderPickingFramebuffer();else if(r.type=="wheel"){this._tooltipUpdateRequested=!1;const c=r;if(Math.abs(c.deltaX)>Math.abs(c.deltaY))this._currentHover=null,this._wheelInertia.cancel();else{const u=t3(c);this._wheelInertia.setMomentum(c.deltaY*(c.deltaMode?80:1),f=>{const l=new WheelEvent("wheel",{...u,deltaMode:0,deltaX:0,deltaY:f});a(l)}),c.preventDefault();return}}if(r.type=="click"){const c=this._currentHover?{type:r.type,viewPath:this._currentHover.mark.unitView.getLayoutAncestors().map(u=>u.name).reverse(),datum:this._currentHover.datum}:{type:r.type,viewPath:null,datum:null};(i=this._eventListeners.get("click"))==null||i.forEach(u=>u(c))}a(r)}};["mousedown","mouseup","wheel","click","mousemove","gesturechange","contextmenu"].forEach(r=>e.addEventListener(r,n)),e.addEventListener("mousedown",()=>{document.addEventListener("mouseup",()=>this.tooltip.popEnabledState(),{once:!0}),this.tooltip.pushEnabledState(!1)}),e.addEventListener("dragstart",r=>r.stopPropagation())}_handlePicking(e,n){var s;const r=this._glHelper.readPickingPixel(e,n),i=r[0]|r[1]<<8|r[2]<<16;if(i==0){this._currentHover=null;return}if(i!==((s=this._currentHover)==null?void 0:s.uniqueId)&&(this._currentHover=null),this._currentHover||this.viewRoot.visit(o=>{if(o instanceof Ne){if(o.mark.isPickingParticipant()){const a=o.mark.encoders.uniqueId.accessor;o.getCollector().visitData(c=>{a(c)==i&&(this._currentHover={mark:o.mark,datum:c,uniqueId:i})})}if(this._currentHover)return $r}}),this._currentHover){const o=this._currentHover.mark;this.updateTooltip(this._currentHover.datum,async a=>{if(!o.isPickingParticipant())return;const c=o.properties.tooltip;if(c!==null){const u=(c==null?void 0:c.handler)??"default",f=this.tooltipHandlers[u];if(!f)throw new Error("No such tooltip handler: "+u);return f(a,o,c==null?void 0:c.params)}})}}updateTooltip(e,n){if(!this._tooltipUpdateRequested||!e)this.tooltip.updateWithDatum(e,n),this._tooltipUpdateRequested=!0;else throw new Error("Tooltip has already been updated! Duplicate event handler?")}computeLayout(){const e=this.viewRoot;if(!e)return;this.broadcast("layout");const n=this._glHelper.getLogicalCanvasSize();if(isNaN(n.width)||isNaN(n.height)){console.log(`NaN in canvas size: ${n.width}x${n.height}. Skipping computeLayout().`);return}this._renderingContext=new wf({picking:!1},this._glHelper),this._pickingContext=new wf({picking:!0},this._glHelper),e.render(new $S(this._renderingContext,this._pickingContext),vt.create(0,0,n.width,n.height)),this.broadcast("layoutComputed")}renderAll(){var e;(e=this._renderingContext)==null||e.render(),this._dirtyPickingBuffer=!0}renderPickingFramebuffer(){this._dirtyPickingBuffer&&(this._pickingContext.render(),this._dirtyPickingBuffer=!1)}getSearchableViews(){const e=[];return this.viewRoot.visit(n=>{n instanceof Ne&&n.getAccessor("search")&&e.push(n)}),e}getNamedScaleResolutions(){const e=new Map;return this.viewRoot.visit(n=>{for(const r of Object.values(n.resolutions.scale))r.name&&e.set(r.name,r)}),e}}function P3(t,e){const n=document.createElement("div");n.className="message-box";const r=document.createElement("div");r.textContent=e,n.appendChild(r),t.appendChild(n)}async function L3(t,e,n={}){let r;if(V(t)){if(r=document.querySelector(t),!r)throw new Error(`No such element: ${t}`)}else if(t instanceof HTMLElement)r=t;else throw new Error(`Invalid element: ${t}`);let i;try{const s=Re(e)?e:await z3(e);if(s.baseUrl??(s.baseUrl=""),s.width??(s.width="container"),s.padding??(s.padding=10),r==document.body){const o=document.createElement("div");o.style.position="fixed",o.style.inset="0",o.style.overflow="hidden",r.appendChild(o),r=o}i=new O3(r,s,n),N3(i,n),await i.launch()}catch(s){r.innerText=s.toString(),console.error(s)}return{finalize(){for(i.destroy();r.firstChild;)r.firstChild.remove()},addEventListener(s,o){const a=i._eventListeners;let c=a.get(s);c||(c=new Set,a.set(s,c)),c.add(o)},removeEventListener(s,o){var c;(c=i._eventListeners.get(s))==null||c.delete(o)},getScaleResolutionByName(s){return i.getNamedScaleResolutions().get(s)},updateNamedData:i.updateNamedData.bind(i)}}function N3(t,e){e.namedDataProvider&&t.registerNamedDataProvider(e.namedDataProvider)}async function z3(t){let e;try{e=JSON.parse(await xo().load(t))}catch(n){throw new Error(`Could not load or parse configuration: ${t}, reason: ${n.message}`)}if(!e.baseUrl){const n=t.match(/^[^?#]*\//);e.baseUrl=n&&n[0]||"./"}return e}function*U3(t){const r=t.length;let i=0,s=i;for(;i<r;){const o=t.charCodeAt(i++);let a;if(o===10?a=t.substring(s,i-1):o===13?(a=t.substring(s,i-1),t.charCodeAt(i+1)===10&&i++):i===r&&(a=t.substring(s,i-1)),a!==void 0&&(yield a,a=void 0,s=i,i>=r))return a}}function $3(t){return new Promise((e,n)=>{let r=new FileReader;r.onload=()=>e(r.result),r.onerror=n,r.readAsText(t)})}function If(){return new Promise((t,e)=>window.requestAnimationFrame(()=>window.requestAnimationFrame(t)))}async function Fp(t){return{name:t.name,size:t.size,textContent:await $3(t)}}async function V3(t){const n=await(await fetch(t)).text();return{name:t.match(/[^/]*$/)[0],size:n.length,textContent:n}}const ge={HETS:{name:"HETS",title:"Allelic counts",example:"tumor.hets.tsv",column:"REF_COUNT"},CR:{name:"CR",title:"Denoised copy ratios",example:"tumor.denoisedCR.tsv",column:"LOG2_COPY_RATIO"},SEG:{name:"SEG",title:"Modeled segments",example:"tumor.modelFinal.seg",column:"LOG2_COPY_RATIO_POSTERIOR_50"},DICT:{name:"DICT",title:"Sequence dictionary",example:"GRCh38.d1.vd1.fa.dict",column:void 0}};function G3(t){const e=H3(t);if(typeof e=="string"&&e!==""){const n=e.split(" ");for(const r of Object.values(ge))if(r.column&&n.includes(r.column))return r}else if(t[0]==="@")return ge.DICT}function H3(t,e="@"){for(const n of U3(t))if(typeof e=="string"&&n[0]!==e)return n}const Sa=t=>t!==""?+t:null,q3={[ge.HETS.name]:t=>{const e=+t.ALT_COUNT,n=+t.REF_COUNT;return{contig:t.CONTIG,pos:+t.POSITION,baf:e/(n+e)}},[ge.CR.name]:t=>{const e=+t.START,n=+t.END;return{contig:t.CONTIG,start:e,end:n,pos:(e-1+n)/2,logR:Sa(t.LOG2_COPY_RATIO)}},[ge.SEG.name]:t=>({contig:t.CONTIG,start:+t.START,end:+t.END,NUM_POINTS_COPY_RATIO:+t.NUM_POINTS_COPY_RATIO,NUM_POINTS_ALLELE_FRACTION:+t.NUM_POINTS_ALLELE_FRACTION,LOG2_COPY_RATIO_POSTERIOR_10:+t.LOG2_COPY_RATIO_POSTERIOR_10,LOG2_COPY_RATIO_POSTERIOR_50:Sa(t.LOG2_COPY_RATIO_POSTERIOR_50),LOG2_COPY_RATIO_POSTERIOR_90:+t.LOG2_COPY_RATIO_POSTERIOR_90,MINOR_ALLELE_FRACTION_POSTERIOR_10:+t.MINOR_ALLELE_FRACTION_POSTERIOR_10,MINOR_ALLELE_FRACTION_POSTERIOR_50:Sa(t.MINOR_ALLELE_FRACTION_POSTERIOR_50),MINOR_ALLELE_FRACTION_POSTERIOR_90:+t.MINOR_ALLELE_FRACTION_POSTERIOR_90})},W3=t=>({name:"ideogram-track",view:{stroke:"black"},height:24,data:{url:`https://genomespy.app/data/genomes/${t}/cytoBand.${t}.tsv`},transform:[{type:"filter",expr:"!test(/_/, datum.chrom)"}],encoding:{x:{chrom:"chrom",pos:"chromStart",type:"locus",axis:null},x2:{chrom:"chrom",pos:"chromEnd"}},resolve:{scale:{color:"independent"}},layer:[{title:"Cytoband",mark:"rect",encoding:{color:{field:"gieStain",type:"nominal",scale:{domain:["gneg","gpos25","gpos50","gpos75","gpos100","acen","stalk","gvar"],range:["#f0f0f0","#e0e0e0","#d0d0d0","#c0c0c0","#a0a0a0","#cc4444","#338833","#000000"]}},squeeze:{expr:"datum.gieStain == 'acen' ? (test(/^p/, datum.name) ? 'p' : 'q') : null",type:"nominal",scale:{domain:["p","q"],range:["right","left"]}}}},{mark:{type:"text",align:"center",baseline:"middle",paddingX:4,tooltip:null},encoding:{color:{field:"gieStain",type:"nominal",scale:{domain:["gneg","gpos25","gpos50","gpos75","gpos100","acen","stalk","gvar"],range:["black","black","black","black","black","black","white","white"]}},text:{field:"name",type:"nominal"}}},{transform:[{type:"filter",expr:"datum.chromStart == 0 && datum.chrom != 'chr1'"}],encoding:{x2:null},mark:{type:"rule",color:"#a0a0a0",strokeDash:[3,3],strokeDashOffset:2}}]}),j3=t=>({description:"Windowed GC content computed from the reference genome. Extracted with GATK AnnotateIntervals",height:50,view:{fill:fn.BACKGROUD,stroke:"gray"},data:{url:`https://genomespy.app/tracks/gc-content/gc-intervals.${t}.tsv`},mark:{type:"rect",minWidth:.5,minOpacity:1},encoding:{x:{chrom:"CONTIG",pos:"START",offset:-1,type:"locus"},x2:{chrom:"CONTIG",pos:"END"},y:{field:"GC_CONTENT",type:"quantitative",scale:{domain:[.3,.7]},title:"GC cont.",axis:{maxExtent:40}}}}),Y3=t=>({name:"refseq-track",height:{step:23},data:{url:`https://genomespy.app/data/genomes/${t}/refSeq_genes_scored_compressed.${t}.tsv`,format:{parse:{symbol:"string",chrom:"string",start:"integer",length:"integer",strand:"string",score:"integer",exons:"string"}}},transform:[{type:"linearizeGenomicCoordinate",chrom:"chrom",pos:"start",as:"_start"},{type:"formula",expr:"datum._start + datum.length",as:"_end"},{type:"formula",expr:"datum._start + datum.length / 2",as:"_centroid"},{type:"collect",sort:{field:["_start"]}},{type:"pileup",start:"_start",end:"_end",as:"_lane",preference:"strand",preferredOrder:["-","+"]},{type:"filter",expr:"datum._lane < 3"}],encoding:{y:{field:"_lane",type:"ordinal",scale:{type:"index",align:0,paddingInner:.4,paddingOuter:.2,domain:[0,3],reverse:!0,zoom:!1},axis:null}},layer:[{name:"transcripts",opacity:{unitsPerPixel:[1e5,4e4],values:[0,1]},encoding:{color:{value:"#909090"}},layer:[{name:"exons",transform:[{type:"project",fields:["_lane","_start","exons"]},{type:"flattenCompressedExons",start:"_start"}],mark:{type:"rect",minOpacity:.2,minWidth:.5,tooltip:null},encoding:{x:{field:"exonStart",type:"locus"},x2:{field:"exonEnd"}}},{name:"bodies",title:"Gene annotations",mark:{type:"rule",minLength:.5,size:1,tooltip:null},encoding:{x:{field:"_start",type:"locus",axis:null},x2:{field:"_end"},search:{field:"symbol"}}}]},{name:"symbols",transform:[{type:"measureText",fontSize:11,field:"symbol",as:"_textWidth"},{type:"filterScoredLabels",lane:"_lane",score:"score",width:"_textWidth",pos:"_centroid",padding:5}],layer:[{name:"labels",mark:{type:"text",size:11,yOffset:7,tooltip:{handler:"refseqgene"}},encoding:{x:{field:"_centroid",type:"locus"},text:{field:"symbol"}}},{name:"arrows",opacity:{unitsPerPixel:[1e5,4e4],values:[0,1]},mark:{type:"point",yOffset:7,size:50,tooltip:null},encoding:{x:{field:"_centroid",type:"locus"},dx:{expr:"(datum._textWidth / 2 + 5) * (datum.strand == '-' ? -1 : 1)",type:"quantitative",scale:null},color:{value:"black"},shape:{field:"strand",type:"nominal",scale:{domain:["-","+"],range:["triangle-left","triangle-right"]}}}}]}]}),fn={INTERVAL:"#f70",RULE:"black",POINT:"#49A0F2",BACKGROUD:"#f8f8f8"};function Fa(t,{lower:e,upper:n}){const r=[];return e&&n&&r.push({mark:{type:"rect",minWidth:2,minOpacity:1},encoding:{y:{field:e,type:"quantitative",title:null},y2:{field:n},color:{value:fn.INTERVAL},opacity:{value:.3}}}),r.push({mark:{type:"rule",size:3,minLength:3},encoding:{y:{field:t,type:"quantitative",title:null},color:{value:fn.RULE}}}),r}function _f(t){return Math.max(0,Math.log((t-1e3)/4)/Math.log(3))||0}function X3(t,e){const n=c=>{const u=t.get(c),f=u?u.data:[];if(/^hg\d+/.test(e)){let l;const h=p=>{const d=p.contig;return d===l?!0:/^(chr)?(\d{1,2}|[XY])$/.test(d)?(l=d,!0):(l="",!1)};return f.filter(h)}return f},r=e?{name:e}:{contigs:t.get(ge.DICT).data},[i,s,o]=[ge.SEG,ge.CR,ge.HETS].map(n),a=(c,u)=>c?[u(c)]:[];return{genome:r,data:{values:i},resolve:{scale:{x:"shared"},axis:{x:"independent"}},vconcat:[...a(e,W3),{resolve:{scale:{x:"shared"},axis:{x:"shared"}},encoding:{x:{chrom:"contig",pos:"start",type:"locus",offset:-1,axis:{title:null}},x2:{chrom:"contig",pos:"end"}},vconcat:[...a(e,j3),{name:"logRTrack",view:{fill:fn.BACKGROUD,stroke:"gray"},layer:[{data:{values:s},transform:[{type:"filter",expr:"!isNaN(datum.logR) && datum.logR > -3"}],mark:{type:"point",tooltip:null,geometricZoomBound:_f(s.length)},encoding:{x:{chrom:"contig",pos:"pos",type:"locus",axis:{grid:!0,gridDash:[1,5],chromGrid:!0}},y:{field:"logR",type:"quantitative",title:"Log2 copy ratio",scale:{},axis:{maxExtent:40}},color:{value:fn.POINT},size:{value:150},opacity:{value:.25},strokeWidth:{value:0}}},{transform:[{type:"filter",expr:"datum.LOG2_COPY_RATIO_POSTERIOR_50 > -3"}],layer:Fa("LOG2_COPY_RATIO_POSTERIOR_50",{lower:"LOG2_COPY_RATIO_POSTERIOR_10",upper:"LOG2_COPY_RATIO_POSTERIOR_90"})}]},{name:"bafTrack",view:{fill:fn.BACKGROUD,stroke:"gray"},layer:[{data:{values:o},mark:{type:"point",tooltip:null,geometricZoomBound:_f(o.length)},encoding:{x:{chrom:"contig",pos:"pos",offset:-.5,type:"locus",axis:{grid:!0,gridDash:[1,5],chromGrid:!0}},y:{field:"baf",type:"quantitative",title:"Minor allele fraction",scale:{domain:[0,1]},axis:{maxExtent:40}},color:{value:fn.POINT},size:{value:150},opacity:{value:.3},strokeWidth:{value:0}}},{layer:[{layer:Fa("MINOR_ALLELE_FRACTION_POSTERIOR_50",{lower:"MINOR_ALLELE_FRACTION_POSTERIOR_10",upper:"MINOR_ALLELE_FRACTION_POSTERIOR_90"})},{transform:[10,50,90].map(c=>`MINOR_ALLELE_FRACTION_POSTERIOR_${c}`).map(c=>({type:"formula",expr:`1 - datum.${c}`,as:c})),layer:Fa("MINOR_ALLELE_FRACTION_POSTERIOR_50",{lower:"MINOR_ALLELE_FRACTION_POSTERIOR_10",upper:"MINOR_ALLELE_FRACTION_POSTERIOR_90"})}]}]}]},...a(e,Y3)]}}const K3="data:image/gif;base64,R0lGODlhIAAgAPMAAP///wAAAMbGxoSEhLa2tpqamjY2NlZWVtjY2OTk5Ly8vB4eHgQEBAAAAAAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh/hpDcmVhdGVkIHdpdGggYWpheGxvYWQuaW5mbwAh+QQJCgAAACwAAAAAIAAgAAAE5xDISWlhperN52JLhSSdRgwVo1ICQZRUsiwHpTJT4iowNS8vyW2icCF6k8HMMBkCEDskxTBDAZwuAkkqIfxIQyhBQBFvAQSDITM5VDW6XNE4KagNh6Bgwe60smQUB3d4Rz1ZBApnFASDd0hihh12BkE9kjAJVlycXIg7CQIFA6SlnJ87paqbSKiKoqusnbMdmDC2tXQlkUhziYtyWTxIfy6BE8WJt5YJvpJivxNaGmLHT0VnOgSYf0dZXS7APdpB309RnHOG5gDqXGLDaC457D1zZ/V/nmOM82XiHRLYKhKP1oZmADdEAAAh+QQJCgAAACwAAAAAIAAgAAAE6hDISWlZpOrNp1lGNRSdRpDUolIGw5RUYhhHukqFu8DsrEyqnWThGvAmhVlteBvojpTDDBUEIFwMFBRAmBkSgOrBFZogCASwBDEY/CZSg7GSE0gSCjQBMVG023xWBhklAnoEdhQEfyNqMIcKjhRsjEdnezB+A4k8gTwJhFuiW4dokXiloUepBAp5qaKpp6+Ho7aWW54wl7obvEe0kRuoplCGepwSx2jJvqHEmGt6whJpGpfJCHmOoNHKaHx61WiSR92E4lbFoq+B6QDtuetcaBPnW6+O7wDHpIiK9SaVK5GgV543tzjgGcghAgAh+QQJCgAAACwAAAAAIAAgAAAE7hDISSkxpOrN5zFHNWRdhSiVoVLHspRUMoyUakyEe8PTPCATW9A14E0UvuAKMNAZKYUZCiBMuBakSQKG8G2FzUWox2AUtAQFcBKlVQoLgQReZhQlCIJesQXI5B0CBnUMOxMCenoCfTCEWBsJColTMANldx15BGs8B5wlCZ9Po6OJkwmRpnqkqnuSrayqfKmqpLajoiW5HJq7FL1Gr2mMMcKUMIiJgIemy7xZtJsTmsM4xHiKv5KMCXqfyUCJEonXPN2rAOIAmsfB3uPoAK++G+w48edZPK+M6hLJpQg484enXIdQFSS1u6UhksENEQAAIfkECQoAAAAsAAAAACAAIAAABOcQyEmpGKLqzWcZRVUQnZYg1aBSh2GUVEIQ2aQOE+G+cD4ntpWkZQj1JIiZIogDFFyHI0UxQwFugMSOFIPJftfVAEoZLBbcLEFhlQiqGp1Vd140AUklUN3eCA51C1EWMzMCezCBBmkxVIVHBWd3HHl9JQOIJSdSnJ0TDKChCwUJjoWMPaGqDKannasMo6WnM562R5YluZRwur0wpgqZE7NKUm+FNRPIhjBJxKZteWuIBMN4zRMIVIhffcgojwCF117i4nlLnY5ztRLsnOk+aV+oJY7V7m76PdkS4trKcdg0Zc0tTcKkRAAAIfkECQoAAAAsAAAAACAAIAAABO4QyEkpKqjqzScpRaVkXZWQEximw1BSCUEIlDohrft6cpKCk5xid5MNJTaAIkekKGQkWyKHkvhKsR7ARmitkAYDYRIbUQRQjWBwJRzChi9CRlBcY1UN4g0/VNB0AlcvcAYHRyZPdEQFYV8ccwR5HWxEJ02YmRMLnJ1xCYp0Y5idpQuhopmmC2KgojKasUQDk5BNAwwMOh2RtRq5uQuPZKGIJQIGwAwGf6I0JXMpC8C7kXWDBINFMxS4DKMAWVWAGYsAdNqW5uaRxkSKJOZKaU3tPOBZ4DuK2LATgJhkPJMgTwKCdFjyPHEnKxFCDhEAACH5BAkKAAAALAAAAAAgACAAAATzEMhJaVKp6s2nIkolIJ2WkBShpkVRWqqQrhLSEu9MZJKK9y1ZrqYK9WiClmvoUaF8gIQSNeF1Er4MNFn4SRSDARWroAIETg1iVwuHjYB1kYc1mwruwXKC9gmsJXliGxc+XiUCby9ydh1sOSdMkpMTBpaXBzsfhoc5l58Gm5yToAaZhaOUqjkDgCWNHAULCwOLaTmzswadEqggQwgHuQsHIoZCHQMMQgQGubVEcxOPFAcMDAYUA85eWARmfSRQCdcMe0zeP1AAygwLlJtPNAAL19DARdPzBOWSm1brJBi45soRAWQAAkrQIykShQ9wVhHCwCQCACH5BAkKAAAALAAAAAAgACAAAATrEMhJaVKp6s2nIkqFZF2VIBWhUsJaTokqUCoBq+E71SRQeyqUToLA7VxF0JDyIQh/MVVPMt1ECZlfcjZJ9mIKoaTl1MRIl5o4CUKXOwmyrCInCKqcWtvadL2SYhyASyNDJ0uIiRMDjI0Fd30/iI2UA5GSS5UDj2l6NoqgOgN4gksEBgYFf0FDqKgHnyZ9OX8HrgYHdHpcHQULXAS2qKpENRg7eAMLC7kTBaixUYFkKAzWAAnLC7FLVxLWDBLKCwaKTULgEwbLA4hJtOkSBNqITT3xEgfLpBtzE/jiuL04RGEBgwWhShRgQExHBAAh+QQJCgAAACwAAAAAIAAgAAAE7xDISWlSqerNpyJKhWRdlSAVoVLCWk6JKlAqAavhO9UkUHsqlE6CwO1cRdCQ8iEIfzFVTzLdRAmZX3I2SfZiCqGk5dTESJeaOAlClzsJsqwiJwiqnFrb2nS9kmIcgEsjQydLiIlHehhpejaIjzh9eomSjZR+ipslWIRLAgMDOR2DOqKogTB9pCUJBagDBXR6XB0EBkIIsaRsGGMMAxoDBgYHTKJiUYEGDAzHC9EACcUGkIgFzgwZ0QsSBcXHiQvOwgDdEwfFs0sDzt4S6BK4xYjkDOzn0unFeBzOBijIm1Dgmg5YFQwsCMjp1oJ8LyIAACH5BAkKAAAALAAAAAAgACAAAATwEMhJaVKp6s2nIkqFZF2VIBWhUsJaTokqUCoBq+E71SRQeyqUToLA7VxF0JDyIQh/MVVPMt1ECZlfcjZJ9mIKoaTl1MRIl5o4CUKXOwmyrCInCKqcWtvadL2SYhyASyNDJ0uIiUd6GGl6NoiPOH16iZKNlH6KmyWFOggHhEEvAwwMA0N9GBsEC6amhnVcEwavDAazGwIDaH1ipaYLBUTCGgQDA8NdHz0FpqgTBwsLqAbWAAnIA4FWKdMLGdYGEgraigbT0OITBcg5QwPT4xLrROZL6AuQAPUS7bxLpoWidY0JtxLHKhwwMJBTHgPKdEQAACH5BAkKAAAALAAAAAAgACAAAATrEMhJaVKp6s2nIkqFZF2VIBWhUsJaTokqUCoBq+E71SRQeyqUToLA7VxF0JDyIQh/MVVPMt1ECZlfcjZJ9mIKoaTl1MRIl5o4CUKXOwmyrCInCKqcWtvadL2SYhyASyNDJ0uIiUd6GAULDJCRiXo1CpGXDJOUjY+Yip9DhToJA4RBLwMLCwVDfRgbBAaqqoZ1XBMHswsHtxtFaH1iqaoGNgAIxRpbFAgfPQSqpbgGBqUD1wBXeCYp1AYZ19JJOYgH1KwA4UBvQwXUBxPqVD9L3sbp2BNk2xvvFPJd+MFCN6HAAIKgNggY0KtEBAAh+QQJCgAAACwAAAAAIAAgAAAE6BDISWlSqerNpyJKhWRdlSAVoVLCWk6JKlAqAavhO9UkUHsqlE6CwO1cRdCQ8iEIfzFVTzLdRAmZX3I2SfYIDMaAFdTESJeaEDAIMxYFqrOUaNW4E4ObYcCXaiBVEgULe0NJaxxtYksjh2NLkZISgDgJhHthkpU4mW6blRiYmZOlh4JWkDqILwUGBnE6TYEbCgevr0N1gH4At7gHiRpFaLNrrq8HNgAJA70AWxQIH1+vsYMDAzZQPC9VCNkDWUhGkuE5PxJNwiUK4UfLzOlD4WvzAHaoG9nxPi5d+jYUqfAhhykOFwJWiAAAIfkECQoAAAAsAAAAACAAIAAABPAQyElpUqnqzaciSoVkXVUMFaFSwlpOCcMYlErAavhOMnNLNo8KsZsMZItJEIDIFSkLGQoQTNhIsFehRww2CQLKF0tYGKYSg+ygsZIuNqJksKgbfgIGepNo2cIUB3V1B3IvNiBYNQaDSTtfhhx0CwVPI0UJe0+bm4g5VgcGoqOcnjmjqDSdnhgEoamcsZuXO1aWQy8KAwOAuTYYGwi7w5h+Kr0SJ8MFihpNbx+4Erq7BYBuzsdiH1jCAzoSfl0rVirNbRXlBBlLX+BP0XJLAPGzTkAuAOqb0WT5AH7OcdCm5B8TgRwSRKIHQtaLCwg1RAAAOwAAAAAAAAAAAA==";const Tp=["hg38","hg19"],mr=new Map;let En=Tp[0],Vr,Ks=!1,Js=!1,Gr=!1;St();function J3(){const t=r=>{const i=mr.get(r);return te`<tr><td>${r.title}</td>${i?te`<td class="status okay"><span class="icon">✔</span></td><td>${i.name}</td><td>${i.data?`${i.data.length} records`:"Parsing..."}</td>`:te`<td class="status"><span class="icon">✗</span></td><td>Missing. <span class="example-file">Example: ${r.example}</span></td><td></td>`}</tr>`},e=()=>te`<div class="btn-group" role="group">${Tp.map(r=>te`<button type="button" @click="${()=>Rf(r)}" class="btn btn-secondary ${En===r?"active":""}">${r}</button>`)} <button type="button" @click="${()=>Rf(void 0)}" class="btn btn-secondary ${En?"":"active"}">.dict file</button></div>`;return te`${(()=>te`<div @dragenter="${Ta}" @dragover="${Ta}" @dragleave="${Ta}" @drop="${Q3}" class="${Vu({"drop-zone":!0,dragging:Ks,"active-panel":!Js})}"><div class="file-box"><h2>1. Choose a genome assembly or a sequence dictionary</h2><p>Choosing a genome assembly instead of a sequence dictionary activates cytoband, GC content, and RefSeq gene tracks.</p>${e()}<h2>2. Select files</h2><p>Please provide at least one of the following files to start visualizing. File types are detected from the TSV header row.</p><p>N.B. All data processing takes place in your web browser. Nothing is uploaded anywhere.</p><table class="file-table">${Object.values(ge).filter(r=>r!==ge.DICT||!En).map(t)}</table><input type="file" multiple="multiple" accept=".tsv,.seg" id="fileInput" @change="${eF}" style="display:none"><div class="upload-button-wrapper"><button class="btn" style="margin-right:1em" @click="${r=>{document.getElementById("fileInput").click(),r.preventDefault(),r.stopPropagation()}}">Choose files</button> or drag and drop here.</div><h3>No files to play with?</h3><p>Try the example data sets:</p><div class="example-data-buttons"><button class="btn" ?disabled="${Gr}" @click="${()=>Mf("sample-subset")}">Load small data set</button> <button class="btn" ?disabled="${Gr}" @click="${()=>Mf("sample")}">Load full data set</button> ${Gr?te`<span class="loading"><img src="${K3}" alt="" width="16" height="16"> <span>Loading...</span></span>`:""}</div><h2>3. Explore the data</h2>Zoom with the mouse wheel or touchpad, pan by dragging or with the touchpad. Hover an item to get details.<div class="buttons"><button ?disabled="${!Dp()}" @click="${Ip}" class="btn btn-lg">Let's visualize!</button></div></div></div>`)()}<div id="genome-spy-container" class="${Vu({"active-panel":!!Js})}"></div>`}function Z3(){return te`<div class="buttons ${Vr?"visible":"hidden"}"><button @click="${_p}">⇐ Back to files</button></div>`}function Ta(t){t.stopPropagation(),t.preventDefault(),t.type==="dragleave"?Ks=!1:Ks=!0,St()}async function Q3(t){t.stopPropagation(),t.preventDefault(),Ks=!1;const n=[...t.dataTransfer.files];Mu(await Promise.all(n.map(Fp)))}function Dp(){const t=new Map([...mr.entries()].filter(e=>e[0]!==ge.DICT));return t.size>0&&[...t.values()].every(e=>e.data)&&(En||mr.has(ge.DICT))}function St(){Ss(J3(),document.querySelector("main")),Ss(Z3(),document.querySelector("header .toolbar"))}async function Ip(){_p();const t=X3(mr,En);Js=!0,St(),Vr=await L3(document.querySelector("#genome-spy-container"),t),St()}function _p(){Vr&&(Vr.finalize(),Vr=void 0),Js=!1,St()}function Rf(t){En=t,St()}async function eF(t){const e=[...t.target.files];Mu(await Promise.all(e.map(Fp)))}async function Mf(t){const e="https://data.genomespy.app/sample-data/segment-model-spy/";Gr=!0,St();const r=[".hets.tsv",".denoisedCR.tsv",".modelFinal.seg"].map(i=>e+t+i);try{Mu(await Promise.all(r.map(V3)))}catch{alert("Failed to load example data. Please try again later.")}Gr=!1}async function Mu(t){const e=[];for(const n of t){const r=n.textContent,i=G3(r);i?(e.push({file:n,textContent:r,type:i}),mr.set(i,{name:n.name,data:null})):alert(`Cannot recognise this file: ${n.name}.`),i===ge.DICT&&(En=void 0)}for(const n of e){St(),await If();let r=[];n.type!==ge.DICT?r=zf(" ",{comment:"@"}).parse(n.textContent,q3[n.type.name]):r=tF(n.textContent),mr.set(n.type,{name:n.file.name,data:r})}await If(),St(),new Set(e.filter(n=>n.type!==ge.DICT)).size===3&&Dp()&&Ip()}function tF(t){throw new Error("Function not implemented.")} diff --git a/segmentmodel/assets/index-ac9fab48.css b/segmentmodel/assets/index-ac9fab48.css deleted file mode 100644 index c35f0a3..0000000 --- a/segmentmodel/assets/index-ac9fab48.css +++ /dev/null @@ -1 +0,0 @@ -@import"https://fonts.googleapis.com/css?family=Nunito&display=swap";body{position:absolute;margin:0;top:0;bottom:0;left:0;right:0;display:flex;flex-direction:column;font-family:Nunito,sans-serif;font-size:15px}header{position:relative;padding:10px 10px 0}header .toolbar{position:absolute;right:10px;top:10px;bottom:20px}header .buttons{display:flex;margin:0;transition:visibility 1s,opacity 1s,transform 1s}header .buttons.hidden{visibility:hidden;opacity:0;transform:translate(30px)}header .buttons button{border:0;background:none;font-size:14px;border:2px solid #666;border-radius:4px}h1{margin:0;font-size:160%;border-bottom:2px solid black}h1 .main-title{position:relative}h1 .main-title .beta{position:absolute;font-size:13px;transform:translate(-1.6em,-.4em) rotate(20deg)}h1 small{font-size:55%;margin-left:.5em}h2,h3{margin-bottom:.4em;margin-top:1em}p{margin:.3em 0}a{color:#000}main{margin:0;flex-grow:1;position:relative}main .drop-zone{border-radius:10px;border:4px solid transparent}main .drop-zone.dragging{background-color:#f4f4f4;border:4px dashed #ccc}main>div{position:absolute!important;left:0;right:0;top:0;bottom:0;visibility:hidden}main>div.active-panel{visibility:visible}.file-box{max-width:900px;margin-left:auto;margin-right:auto}.example-data-buttons{display:flex;gap:.25em;align-items:center}.example-data-buttons .loading{display:flex;margin-left:1em;gap:.5em;align-items:center}footer{font-size:70%;padding:6px 10px}.upload-button-wrapper{margin:1em 0}.file-table{margin-top:1em;margin-left:1em;border-collapse:collapse}.file-table td{padding-right:.6em}.file-table .status{text-align:center;padding-right:.1em;width:1em}.file-table .okay{color:#5a2}.file-table .example-file{color:#bbb}.buttons{display:flex;align-items:center;justify-content:center;margin:2em 0}.btn{background-color:#548fcc;padding:8px 1em;color:#fff;border:0;border-radius:3px;font-weight:700;font-size:13px;transition:color .2s,background-color .2s}.btn:disabled{background-color:#eee;color:#ccc}.btn:focus{outline:none;box-shadow:0 0 4px #0af}.btn:hover:not(:disabled):not(.active){background-color:#4082c6}.btn:active:not(:disabled):not(.active){box-shadow:0 0 4px #0af,inset 0 3px 3px #0003;background-color:#3675b7}.btn.active{background-color:#2b5c8f;text-shadow:0 0 3px rgba(0,0,0,.5)}.btn.btn-lg{transition:color 1s,background-color 1s;font-size:22px;border-radius:4px;padding:.6em 1em}.btn-group{display:flex}.btn-group .btn:not(:first-child){border-top-left-radius:0;border-bottom-left-radius:0}.btn-group .btn:not(:last-child){border-top-right-radius:0;border-bottom-right-radius:0}.btn-group .btn:not(:last-child){border-right:1px solid #7ba9d8}.genome-spy .tooltip{max-width:initial} diff --git a/segmentmodel/assets/index-ba6a6d03.js b/segmentmodel/assets/index-ba6a6d03.js new file mode 100644 index 0000000..0c8e9a3 --- /dev/null +++ b/segmentmodel/assets/index-ba6a6d03.js @@ -0,0 +1,12 @@ +import{a as Gt,c as X}from"./_commonjsHelpers-de833af9.js";import{b as he}from"./index-462333f7.js";import{_ as Kt}from"./__vite-browser-external-d053bc6e.js";var $e={exports:{}},z=typeof Reflect=="object"?Reflect:null,Qe=z&&typeof z.apply=="function"?z.apply:function(e,r,a){return Function.prototype.apply.call(e,r,a)},le;z&&typeof z.ownKeys=="function"?le=z.ownKeys:Object.getOwnPropertySymbols?le=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:le=function(e){return Object.getOwnPropertyNames(e)};function Yt(t){console&&console.warn&&console.warn(t)}var gt=Number.isNaN||function(e){return e!==e};function k(){k.init.call(this)}$e.exports=k;$e.exports.once=Qt;k.EventEmitter=k;k.prototype._events=void 0;k.prototype._eventsCount=0;k.prototype._maxListeners=void 0;var Ze=10;function pe(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(k,"defaultMaxListeners",{enumerable:!0,get:function(){return Ze},set:function(t){if(typeof t!="number"||t<0||gt(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");Ze=t}});k.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};k.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||gt(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function yt(t){return t._maxListeners===void 0?k.defaultMaxListeners:t._maxListeners}k.prototype.getMaxListeners=function(){return yt(this)};k.prototype.emit=function(e){for(var r=[],a=1;a<arguments.length;a++)r.push(arguments[a]);var o=e==="error",s=this._events;if(s!==void 0)o=o&&s.error===void 0;else if(!o)return!1;if(o){var f;if(r.length>0&&(f=r[0]),f instanceof Error)throw f;var u=new Error("Unhandled error."+(f?" ("+f.message+")":""));throw u.context=f,u}var l=s[e];if(l===void 0)return!1;if(typeof l=="function")Qe(l,this,r);else for(var h=l.length,g=Rt(l,h),a=0;a<h;++a)Qe(g[a],this,r);return!0};function wt(t,e,r,a){var o,s,f;if(pe(r),s=t._events,s===void 0?(s=t._events=Object.create(null),t._eventsCount=0):(s.newListener!==void 0&&(t.emit("newListener",e,r.listener?r.listener:r),s=t._events),f=s[e]),f===void 0)f=s[e]=r,++t._eventsCount;else if(typeof f=="function"?f=s[e]=a?[r,f]:[f,r]:a?f.unshift(r):f.push(r),o=yt(t),o>0&&f.length>o&&!f.warned){f.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+f.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=t,u.type=e,u.count=f.length,Yt(u)}return t}k.prototype.addListener=function(e,r){return wt(this,e,r,!1)};k.prototype.on=k.prototype.addListener;k.prototype.prependListener=function(e,r){return wt(this,e,r,!0)};function zt(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function mt(t,e,r){var a={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},o=zt.bind(a);return o.listener=r,a.wrapFn=o,o}k.prototype.once=function(e,r){return pe(r),this.on(e,mt(this,e,r)),this};k.prototype.prependOnceListener=function(e,r){return pe(r),this.prependListener(e,mt(this,e,r)),this};k.prototype.removeListener=function(e,r){var a,o,s,f,u;if(pe(r),o=this._events,o===void 0)return this;if(a=o[e],a===void 0)return this;if(a===r||a.listener===r)--this._eventsCount===0?this._events=Object.create(null):(delete o[e],o.removeListener&&this.emit("removeListener",e,a.listener||r));else if(typeof a!="function"){for(s=-1,f=a.length-1;f>=0;f--)if(a[f]===r||a[f].listener===r){u=a[f].listener,s=f;break}if(s<0)return this;s===0?a.shift():Xt(a,s),a.length===1&&(o[e]=a[0]),o.removeListener!==void 0&&this.emit("removeListener",e,u||r)}return this};k.prototype.off=k.prototype.removeListener;k.prototype.removeAllListeners=function(e){var r,a,o;if(a=this._events,a===void 0)return this;if(a.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):a[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete a[e]),this;if(arguments.length===0){var s=Object.keys(a),f;for(o=0;o<s.length;++o)f=s[o],f!=="removeListener"&&this.removeAllListeners(f);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(r=a[e],typeof r=="function")this.removeListener(e,r);else if(r!==void 0)for(o=r.length-1;o>=0;o--)this.removeListener(e,r[o]);return this};function Et(t,e,r){var a=t._events;if(a===void 0)return[];var o=a[e];return o===void 0?[]:typeof o=="function"?r?[o.listener||o]:[o]:r?Jt(o):Rt(o,o.length)}k.prototype.listeners=function(e){return Et(this,e,!0)};k.prototype.rawListeners=function(e){return Et(this,e,!1)};k.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):St.call(t,e)};k.prototype.listenerCount=St;function St(t){var e=this._events;if(e!==void 0){var r=e[t];if(typeof r=="function")return 1;if(r!==void 0)return r.length}return 0}k.prototype.eventNames=function(){return this._eventsCount>0?le(this._events):[]};function Rt(t,e){for(var r=new Array(e),a=0;a<e;++a)r[a]=t[a];return r}function Xt(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function Jt(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}function Qt(t,e){return new Promise(function(r,a){function o(f){t.removeListener(e,s),a(f)}function s(){typeof t.removeListener=="function"&&t.removeListener("error",o),r([].slice.call(arguments))}Lt(t,e,s,{once:!0}),e!=="error"&&Zt(t,o,{once:!0})})}function Zt(t,e,r){typeof t.on=="function"&&Lt(t,"error",e,r)}function Lt(t,e,r,a){if(typeof t.on=="function")a.once?t.once(e,r):t.on(e,r);else if(typeof t.addEventListener=="function")t.addEventListener(e,function o(s){a.once&&t.removeEventListener(e,o),r(s)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t)}var Ve=$e.exports,Be={exports:{}};typeof Object.create=="function"?Be.exports=function(e,r){r&&(e.super_=r,e.prototype=Object.create(r.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:Be.exports=function(e,r){if(r){e.super_=r;var a=function(){};a.prototype=r.prototype,e.prototype=new a,e.prototype.constructor=e}};var Q=Be.exports,Re,et;function Tt(){return et||(et=1,Re=Ve.EventEmitter),Re}const Ct=Gt(Kt);var Le,tt;function er(){if(tt)return Le;tt=1;function t(m,S){var b=Object.keys(m);if(Object.getOwnPropertySymbols){var w=Object.getOwnPropertySymbols(m);S&&(w=w.filter(function(T){return Object.getOwnPropertyDescriptor(m,T).enumerable})),b.push.apply(b,w)}return b}function e(m){for(var S=1;S<arguments.length;S++){var b=arguments[S]!=null?arguments[S]:{};S%2?t(Object(b),!0).forEach(function(w){r(m,w,b[w])}):Object.getOwnPropertyDescriptors?Object.defineProperties(m,Object.getOwnPropertyDescriptors(b)):t(Object(b)).forEach(function(w){Object.defineProperty(m,w,Object.getOwnPropertyDescriptor(b,w))})}return m}function r(m,S,b){return S=f(S),S in m?Object.defineProperty(m,S,{value:b,enumerable:!0,configurable:!0,writable:!0}):m[S]=b,m}function a(m,S){if(!(m instanceof S))throw new TypeError("Cannot call a class as a function")}function o(m,S){for(var b=0;b<S.length;b++){var w=S[b];w.enumerable=w.enumerable||!1,w.configurable=!0,"value"in w&&(w.writable=!0),Object.defineProperty(m,f(w.key),w)}}function s(m,S,b){return S&&o(m.prototype,S),b&&o(m,b),Object.defineProperty(m,"prototype",{writable:!1}),m}function f(m){var S=u(m,"string");return typeof S=="symbol"?S:String(S)}function u(m,S){if(typeof m!="object"||m===null)return m;var b=m[Symbol.toPrimitive];if(b!==void 0){var w=b.call(m,S||"default");if(typeof w!="object")return w;throw new TypeError("@@toPrimitive must return a primitive value.")}return(S==="string"?String:Number)(m)}var l=he,h=l.Buffer,g=Ct,y=g.inspect,_=y&&y.custom||"inspect";function M(m,S,b){h.prototype.copy.call(m,S,b)}return Le=function(){function m(){a(this,m),this.head=null,this.tail=null,this.length=0}return s(m,[{key:"push",value:function(b){var w={data:b,next:null};this.length>0?this.tail.next=w:this.head=w,this.tail=w,++this.length}},{key:"unshift",value:function(b){var w={data:b,next:this.head};this.length===0&&(this.tail=w),this.head=w,++this.length}},{key:"shift",value:function(){if(this.length!==0){var b=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,b}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(b){if(this.length===0)return"";for(var w=this.head,T=""+w.data;w=w.next;)T+=b+w.data;return T}},{key:"concat",value:function(b){if(this.length===0)return h.alloc(0);for(var w=h.allocUnsafe(b>>>0),T=this.head,L=0;T;)M(T.data,w,L),L+=T.data.length,T=T.next;return w}},{key:"consume",value:function(b,w){var T;return b<this.head.data.length?(T=this.head.data.slice(0,b),this.head.data=this.head.data.slice(b)):b===this.head.data.length?T=this.shift():T=w?this._getString(b):this._getBuffer(b),T}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(b){var w=this.head,T=1,L=w.data;for(b-=L.length;w=w.next;){var R=w.data,A=b>R.length?R.length:b;if(A===R.length?L+=R:L+=R.slice(0,b),b-=A,b===0){A===R.length?(++T,w.next?this.head=w.next:this.head=this.tail=null):(this.head=w,w.data=R.slice(A));break}++T}return this.length-=T,L}},{key:"_getBuffer",value:function(b){var w=h.allocUnsafe(b),T=this.head,L=1;for(T.data.copy(w),b-=T.data.length;T=T.next;){var R=T.data,A=b>R.length?R.length:b;if(R.copy(w,w.length-b,0,A),b-=A,b===0){A===R.length?(++L,T.next?this.head=T.next:this.head=this.tail=null):(this.head=T,T.data=R.slice(A));break}++L}return this.length-=L,w}},{key:_,value:function(b,w){return y(this,e(e({},w),{},{depth:0,customInspect:!1}))}}]),m}(),Le}var Te,rt;function At(){if(rt)return Te;rt=1;function t(f,u){var l=this,h=this._readableState&&this._readableState.destroyed,g=this._writableState&&this._writableState.destroyed;return h||g?(u?u(f):f&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,process.nextTick(o,this,f)):process.nextTick(o,this,f)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(f||null,function(y){!u&&y?l._writableState?l._writableState.errorEmitted?process.nextTick(r,l):(l._writableState.errorEmitted=!0,process.nextTick(e,l,y)):process.nextTick(e,l,y):u?(process.nextTick(r,l),u(y)):process.nextTick(r,l)}),this)}function e(f,u){o(f,u),r(f)}function r(f){f._writableState&&!f._writableState.emitClose||f._readableState&&!f._readableState.emitClose||f.emit("close")}function a(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}function o(f,u){f.emit("error",u)}function s(f,u){var l=f._readableState,h=f._writableState;l&&l.autoDestroy||h&&h.autoDestroy?f.destroy(u):f.emit("error",u)}return Te={destroy:t,undestroy:a,errorOrDestroy:s},Te}var Ce={},nt;function Z(){if(nt)return Ce;nt=1;function t(u,l){u.prototype=Object.create(l.prototype),u.prototype.constructor=u,u.__proto__=l}var e={};function r(u,l,h){h||(h=Error);function g(_,M,m){return typeof l=="string"?l:l(_,M,m)}var y=function(_){t(M,_);function M(m,S,b){return _.call(this,g(m,S,b))||this}return M}(h);y.prototype.name=h.name,y.prototype.code=u,e[u]=y}function a(u,l){if(Array.isArray(u)){var h=u.length;return u=u.map(function(g){return String(g)}),h>2?"one of ".concat(l," ").concat(u.slice(0,h-1).join(", "),", or ")+u[h-1]:h===2?"one of ".concat(l," ").concat(u[0]," or ").concat(u[1]):"of ".concat(l," ").concat(u[0])}else return"of ".concat(l," ").concat(String(u))}function o(u,l,h){return u.substr(!h||h<0?0:+h,l.length)===l}function s(u,l,h){return(h===void 0||h>u.length)&&(h=u.length),u.substring(h-l.length,h)===l}function f(u,l,h){return typeof h!="number"&&(h=0),h+l.length>u.length?!1:u.indexOf(l,h)!==-1}return r("ERR_INVALID_OPT_VALUE",function(u,l){return'The value "'+l+'" is invalid for option "'+u+'"'},TypeError),r("ERR_INVALID_ARG_TYPE",function(u,l,h){var g;typeof l=="string"&&o(l,"not ")?(g="must not be",l=l.replace(/^not /,"")):g="must be";var y;if(s(u," argument"))y="The ".concat(u," ").concat(g," ").concat(a(l,"type"));else{var _=f(u,".")?"property":"argument";y='The "'.concat(u,'" ').concat(_," ").concat(g," ").concat(a(l,"type"))}return y+=". Received type ".concat(typeof h),y},TypeError),r("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),r("ERR_METHOD_NOT_IMPLEMENTED",function(u){return"The "+u+" method is not implemented"}),r("ERR_STREAM_PREMATURE_CLOSE","Premature close"),r("ERR_STREAM_DESTROYED",function(u){return"Cannot call "+u+" after a stream was destroyed"}),r("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),r("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),r("ERR_STREAM_WRITE_AFTER_END","write after end"),r("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),r("ERR_UNKNOWN_ENCODING",function(u){return"Unknown encoding: "+u},TypeError),r("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),Ce.codes=e,Ce}var Ae,it;function Mt(){if(it)return Ae;it=1;var t=Z().codes.ERR_INVALID_OPT_VALUE;function e(a,o,s){return a.highWaterMark!=null?a.highWaterMark:o?a[s]:null}function r(a,o,s,f){var u=e(o,f,s);if(u!=null){if(!(isFinite(u)&&Math.floor(u)===u)||u<0){var l=f?s:"highWaterMark";throw new t(l,u)}return Math.floor(u)}return a.objectMode?16:16*1024}return Ae={getHighWaterMark:r},Ae}var Me,at;function tr(){if(at)return Me;at=1,Me=t;function t(r,a){if(e("noDeprecation"))return r;var o=!1;function s(){if(!o){if(e("throwDeprecation"))throw new Error(a);e("traceDeprecation")?console.trace(a):console.warn(a),o=!0}return r.apply(this,arguments)}return s}function e(r){try{if(!X.localStorage)return!1}catch{return!1}var a=X.localStorage[r];return a==null?!1:String(a).toLowerCase()==="true"}return Me}var Oe,st;function Ot(){if(st)return Oe;st=1,Oe=N;function t(c){var d=this;this.next=null,this.entry=null,this.finish=function(){we(d,c)}}var e;N.WritableState=O;var r={deprecate:tr()},a=Tt(),o=he.Buffer,s=(typeof X<"u"?X:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function f(c){return o.from(c)}function u(c){return o.isBuffer(c)||c instanceof s}var l=At(),h=Mt(),g=h.getHighWaterMark,y=Z().codes,_=y.ERR_INVALID_ARG_TYPE,M=y.ERR_METHOD_NOT_IMPLEMENTED,m=y.ERR_MULTIPLE_CALLBACK,S=y.ERR_STREAM_CANNOT_PIPE,b=y.ERR_STREAM_DESTROYED,w=y.ERR_STREAM_NULL_VALUES,T=y.ERR_STREAM_WRITE_AFTER_END,L=y.ERR_UNKNOWN_ENCODING,R=l.errorOrDestroy;Q(N,a);function A(){}function O(c,d,v){e=e||J(),c=c||{},typeof v!="boolean"&&(v=d instanceof e),this.objectMode=!!c.objectMode,v&&(this.objectMode=this.objectMode||!!c.writableObjectMode),this.highWaterMark=g(this,c,"writableHighWaterMark",v),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var C=c.decodeStrings===!1;this.decodeStrings=!C,this.defaultEncoding=c.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(P){be(d,P)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=c.emitClose!==!1,this.autoDestroy=!!c.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new t(this)}O.prototype.getBuffer=function(){for(var d=this.bufferedRequest,v=[];d;)v.push(d),d=d.next;return v},function(){try{Object.defineProperty(O.prototype,"buffer",{get:r.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch{}}();var I;typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(I=Function.prototype[Symbol.hasInstance],Object.defineProperty(N,Symbol.hasInstance,{value:function(d){return I.call(this,d)?!0:this!==N?!1:d&&d._writableState instanceof O}})):I=function(d){return d instanceof this};function N(c){e=e||J();var d=this instanceof e;if(!d&&!I.call(N,this))return new N(c);this._writableState=new O(c,this,d),this.writable=!0,c&&(typeof c.write=="function"&&(this._write=c.write),typeof c.writev=="function"&&(this._writev=c.writev),typeof c.destroy=="function"&&(this._destroy=c.destroy),typeof c.final=="function"&&(this._final=c.final)),a.call(this)}N.prototype.pipe=function(){R(this,new S)};function D(c,d){var v=new T;R(c,v),process.nextTick(d,v)}function B(c,d,v,C){var P;return v===null?P=new w:typeof v!="string"&&!d.objectMode&&(P=new _("chunk",["string","Buffer"],v)),P?(R(c,P),process.nextTick(C,P),!1):!0}N.prototype.write=function(c,d,v){var C=this._writableState,P=!1,n=!C.objectMode&&u(c);return n&&!o.isBuffer(c)&&(c=f(c)),typeof d=="function"&&(v=d,d=null),n?d="buffer":d||(d=C.defaultEncoding),typeof v!="function"&&(v=A),C.ending?D(this,v):(n||B(this,C,c,v))&&(C.pendingcb++,P=ve(this,C,n,c,d,v)),P},N.prototype.cork=function(){this._writableState.corked++},N.prototype.uncork=function(){var c=this._writableState;c.corked&&(c.corked--,!c.writing&&!c.corked&&!c.bufferProcessing&&c.bufferedRequest&&V(this,c))},N.prototype.setDefaultEncoding=function(d){if(typeof d=="string"&&(d=d.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((d+"").toLowerCase())>-1))throw new L(d);return this._writableState.defaultEncoding=d,this},Object.defineProperty(N.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});function ee(c,d,v){return!c.objectMode&&c.decodeStrings!==!1&&typeof d=="string"&&(d=o.from(d,v)),d}Object.defineProperty(N.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function ve(c,d,v,C,P,n){if(!v){var i=ee(d,C,P);C!==i&&(v=!0,P="buffer",C=i)}var p=d.objectMode?1:C.length;d.length+=p;var E=d.length<d.highWaterMark;if(E||(d.needDrain=!0),d.writing||d.corked){var j=d.lastBufferedRequest;d.lastBufferedRequest={chunk:C,encoding:P,isBuf:v,callback:n,next:null},j?j.next=d.lastBufferedRequest:d.bufferedRequest=d.lastBufferedRequest,d.bufferedRequestCount+=1}else $(c,d,!1,p,C,P,n);return E}function $(c,d,v,C,P,n,i){d.writelen=C,d.writecb=i,d.writing=!0,d.sync=!0,d.destroyed?d.onwrite(new b("write")):v?c._writev(P,d.onwrite):c._write(P,n,d.onwrite),d.sync=!1}function _e(c,d,v,C,P){--d.pendingcb,v?(process.nextTick(P,C),process.nextTick(H,c,d),c._writableState.errorEmitted=!0,R(c,C)):(P(C),c._writableState.errorEmitted=!0,R(c,C),H(c,d))}function ae(c){c.writing=!1,c.writecb=null,c.length-=c.writelen,c.writelen=0}function be(c,d){var v=c._writableState,C=v.sync,P=v.writecb;if(typeof P!="function")throw new m;if(ae(v),d)_e(c,v,C,d,P);else{var n=oe(v)||c.destroyed;!n&&!v.corked&&!v.bufferProcessing&&v.bufferedRequest&&V(c,v),C?process.nextTick(U,c,v,n,P):U(c,v,n,P)}}function U(c,d,v,C){v||se(c,d),d.pendingcb--,C(),H(c,d)}function se(c,d){d.length===0&&d.needDrain&&(d.needDrain=!1,c.emit("drain"))}function V(c,d){d.bufferProcessing=!0;var v=d.bufferedRequest;if(c._writev&&v&&v.next){var C=d.bufferedRequestCount,P=new Array(C),n=d.corkedRequestsFree;n.entry=v;for(var i=0,p=!0;v;)P[i]=v,v.isBuf||(p=!1),v=v.next,i+=1;P.allBuffers=p,$(c,d,!0,d.length,P,"",n.finish),d.pendingcb++,d.lastBufferedRequest=null,n.next?(d.corkedRequestsFree=n.next,n.next=null):d.corkedRequestsFree=new t(d),d.bufferedRequestCount=0}else{for(;v;){var E=v.chunk,j=v.encoding,x=v.callback,q=d.objectMode?1:E.length;if($(c,d,!1,q,E,j,x),v=v.next,d.bufferedRequestCount--,d.writing)break}v===null&&(d.lastBufferedRequest=null)}d.bufferedRequest=v,d.bufferProcessing=!1}N.prototype._write=function(c,d,v){v(new M("_write()"))},N.prototype._writev=null,N.prototype.end=function(c,d,v){var C=this._writableState;return typeof c=="function"?(v=c,c=null,d=null):typeof d=="function"&&(v=d,d=null),c!=null&&this.write(c,d),C.corked&&(C.corked=1,this.uncork()),C.ending||ye(this,C,v),this},Object.defineProperty(N.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function oe(c){return c.ending&&c.length===0&&c.bufferedRequest===null&&!c.finished&&!c.writing}function ge(c,d){c._final(function(v){d.pendingcb--,v&&R(c,v),d.prefinished=!0,c.emit("prefinish"),H(c,d)})}function fe(c,d){!d.prefinished&&!d.finalCalled&&(typeof c._final=="function"&&!d.destroyed?(d.pendingcb++,d.finalCalled=!0,process.nextTick(ge,c,d)):(d.prefinished=!0,c.emit("prefinish")))}function H(c,d){var v=oe(d);if(v&&(fe(c,d),d.pendingcb===0&&(d.finished=!0,c.emit("finish"),d.autoDestroy))){var C=c._readableState;(!C||C.autoDestroy&&C.endEmitted)&&c.destroy()}return v}function ye(c,d,v){d.ending=!0,H(c,d),v&&(d.finished?process.nextTick(v):c.once("finish",v)),d.ended=!0,c.writable=!1}function we(c,d,v){var C=c.entry;for(c.entry=null;C;){var P=C.callback;d.pendingcb--,P(v),C=C.next}d.corkedRequestsFree.next=c}return Object.defineProperty(N.prototype,"destroyed",{enumerable:!1,get:function(){return this._writableState===void 0?!1:this._writableState.destroyed},set:function(d){this._writableState&&(this._writableState.destroyed=d)}}),N.prototype.destroy=l.destroy,N.prototype._undestroy=l.undestroy,N.prototype._destroy=function(c,d){d(c)},Oe}var De,ot;function J(){if(ot)return De;ot=1;var t=Object.keys||function(h){var g=[];for(var y in h)g.push(y);return g};De=f;var e=Dt(),r=Ot();Q(f,e);for(var a=t(r.prototype),o=0;o<a.length;o++){var s=a[o];f.prototype[s]||(f.prototype[s]=r.prototype[s])}function f(h){if(!(this instanceof f))return new f(h);e.call(this,h),r.call(this,h),this.allowHalfOpen=!0,h&&(h.readable===!1&&(this.readable=!1),h.writable===!1&&(this.writable=!1),h.allowHalfOpen===!1&&(this.allowHalfOpen=!1,this.once("end",u)))}Object.defineProperty(f.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(f.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(f.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function u(){this._writableState.ended||process.nextTick(l,this)}function l(h){h.end()}return Object.defineProperty(f.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0||this._writableState===void 0?!1:this._readableState.destroyed&&this._writableState.destroyed},set:function(g){this._readableState===void 0||this._writableState===void 0||(this._readableState.destroyed=g,this._writableState.destroyed=g)}}),De}var We={},Ue={exports:{}};/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */(function(t,e){var r=he,a=r.Buffer;function o(f,u){for(var l in f)u[l]=f[l]}a.from&&a.alloc&&a.allocUnsafe&&a.allocUnsafeSlow?t.exports=r:(o(r,e),e.Buffer=s);function s(f,u,l){return a(f,u,l)}s.prototype=Object.create(a.prototype),o(a,s),s.from=function(f,u,l){if(typeof f=="number")throw new TypeError("Argument must not be a number");return a(f,u,l)},s.alloc=function(f,u,l){if(typeof f!="number")throw new TypeError("Argument must be a number");var h=a(f);return u!==void 0?typeof l=="string"?h.fill(u,l):h.fill(u):h.fill(0),h},s.allocUnsafe=function(f){if(typeof f!="number")throw new TypeError("Argument must be a number");return a(f)},s.allocUnsafeSlow=function(f){if(typeof f!="number")throw new TypeError("Argument must be a number");return r.SlowBuffer(f)}})(Ue,Ue.exports);var rr=Ue.exports,Ge=rr.Buffer,ft=Ge.isEncoding||function(t){switch(t=""+t,t&&t.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 nr(t){if(!t)return"utf8";for(var e;;)switch(t){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return t;default:if(e)return;t=(""+t).toLowerCase(),e=!0}}function ir(t){var e=nr(t);if(typeof e!="string"&&(Ge.isEncoding===ft||!ft(t)))throw new Error("Unknown encoding: "+t);return e||t}var ar=We.StringDecoder=ie;function ie(t){this.encoding=ir(t);var e;switch(this.encoding){case"utf16le":this.text=dr,this.end=cr,e=4;break;case"utf8":this.fillLast=fr,e=4;break;case"base64":this.text=hr,this.end=pr,e=3;break;default:this.write=vr,this.end=_r;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=Ge.allocUnsafe(e)}ie.prototype.write=function(t){if(t.length===0)return"";var e,r;if(this.lastNeed){if(e=this.fillLast(t),e===void 0)return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r<t.length?e?e+this.text(t,r):this.text(t,r):e||""};ie.prototype.end=lr;ie.prototype.text=ur;ie.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length};function xe(t){return t<=127?0:t>>5===6?2:t>>4===14?3:t>>3===30?4:t>>6===2?-1:-2}function sr(t,e,r){var a=e.length-1;if(a<r)return 0;var o=xe(e[a]);return o>=0?(o>0&&(t.lastNeed=o-1),o):--a<r||o===-2?0:(o=xe(e[a]),o>=0?(o>0&&(t.lastNeed=o-2),o):--a<r||o===-2?0:(o=xe(e[a]),o>=0?(o>0&&(o===2?o=0:t.lastNeed=o-3),o):0))}function or(t,e,r){if((e[0]&192)!==128)return t.lastNeed=0,"�";if(t.lastNeed>1&&e.length>1){if((e[1]&192)!==128)return t.lastNeed=1,"�";if(t.lastNeed>2&&e.length>2&&(e[2]&192)!==128)return t.lastNeed=2,"�"}}function fr(t){var e=this.lastTotal-this.lastNeed,r=or(this,t);if(r!==void 0)return r;if(this.lastNeed<=t.length)return t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,e,0,t.length),this.lastNeed-=t.length}function ur(t,e){var r=sr(this,t,e);if(!this.lastNeed)return t.toString("utf8",e);this.lastTotal=r;var a=t.length-(r-this.lastNeed);return t.copy(this.lastChar,0,a),t.toString("utf8",e,a)}function lr(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+"�":e}function dr(t,e){if((t.length-e)%2===0){var r=t.toString("utf16le",e);if(r){var a=r.charCodeAt(r.length-1);if(a>=55296&&a<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString("utf16le",e,t.length-1)}function cr(t){var e=t&&t.length?this.write(t):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,r)}return e}function hr(t,e){var r=(t.length-e)%3;return r===0?t.toString("base64",e):(this.lastNeed=3-r,this.lastTotal=3,r===1?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString("base64",e,t.length-r))}function pr(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function vr(t){return t.toString(this.encoding)}function _r(t){return t&&t.length?this.write(t):""}var Pe,ut;function Ke(){if(ut)return Pe;ut=1;var t=Z().codes.ERR_STREAM_PREMATURE_CLOSE;function e(s){var f=!1;return function(){if(!f){f=!0;for(var u=arguments.length,l=new Array(u),h=0;h<u;h++)l[h]=arguments[h];s.apply(this,l)}}}function r(){}function a(s){return s.setHeader&&typeof s.abort=="function"}function o(s,f,u){if(typeof f=="function")return o(s,null,f);f||(f={}),u=e(u||r);var l=f.readable||f.readable!==!1&&s.readable,h=f.writable||f.writable!==!1&&s.writable,g=function(){s.writable||_()},y=s._writableState&&s._writableState.finished,_=function(){h=!1,y=!0,l||u.call(s)},M=s._readableState&&s._readableState.endEmitted,m=function(){l=!1,M=!0,h||u.call(s)},S=function(L){u.call(s,L)},b=function(){var L;if(l&&!M)return(!s._readableState||!s._readableState.ended)&&(L=new t),u.call(s,L);if(h&&!y)return(!s._writableState||!s._writableState.ended)&&(L=new t),u.call(s,L)},w=function(){s.req.on("finish",_)};return a(s)?(s.on("complete",_),s.on("abort",b),s.req?w():s.on("request",w)):h&&!s._writableState&&(s.on("end",g),s.on("close",g)),s.on("end",m),s.on("finish",_),f.error!==!1&&s.on("error",S),s.on("close",b),function(){s.removeListener("complete",_),s.removeListener("abort",b),s.removeListener("request",w),s.req&&s.req.removeListener("finish",_),s.removeListener("end",g),s.removeListener("close",g),s.removeListener("finish",_),s.removeListener("end",m),s.removeListener("error",S),s.removeListener("close",b)}}return Pe=o,Pe}var Ne,lt;function br(){if(lt)return Ne;lt=1;var t;function e(L,R,A){return R=r(R),R in L?Object.defineProperty(L,R,{value:A,enumerable:!0,configurable:!0,writable:!0}):L[R]=A,L}function r(L){var R=a(L,"string");return typeof R=="symbol"?R:String(R)}function a(L,R){if(typeof L!="object"||L===null)return L;var A=L[Symbol.toPrimitive];if(A!==void 0){var O=A.call(L,R||"default");if(typeof O!="object")return O;throw new TypeError("@@toPrimitive must return a primitive value.")}return(R==="string"?String:Number)(L)}var o=Ke(),s=Symbol("lastResolve"),f=Symbol("lastReject"),u=Symbol("error"),l=Symbol("ended"),h=Symbol("lastPromise"),g=Symbol("handlePromise"),y=Symbol("stream");function _(L,R){return{value:L,done:R}}function M(L){var R=L[s];if(R!==null){var A=L[y].read();A!==null&&(L[h]=null,L[s]=null,L[f]=null,R(_(A,!1)))}}function m(L){process.nextTick(M,L)}function S(L,R){return function(A,O){L.then(function(){if(R[l]){A(_(void 0,!0));return}R[g](A,O)},O)}}var b=Object.getPrototypeOf(function(){}),w=Object.setPrototypeOf((t={get stream(){return this[y]},next:function(){var R=this,A=this[u];if(A!==null)return Promise.reject(A);if(this[l])return Promise.resolve(_(void 0,!0));if(this[y].destroyed)return new Promise(function(D,B){process.nextTick(function(){R[u]?B(R[u]):D(_(void 0,!0))})});var O=this[h],I;if(O)I=new Promise(S(O,this));else{var N=this[y].read();if(N!==null)return Promise.resolve(_(N,!1));I=new Promise(this[g])}return this[h]=I,I}},e(t,Symbol.asyncIterator,function(){return this}),e(t,"return",function(){var R=this;return new Promise(function(A,O){R[y].destroy(null,function(I){if(I){O(I);return}A(_(void 0,!0))})})}),t),b),T=function(R){var A,O=Object.create(w,(A={},e(A,y,{value:R,writable:!0}),e(A,s,{value:null,writable:!0}),e(A,f,{value:null,writable:!0}),e(A,u,{value:null,writable:!0}),e(A,l,{value:R._readableState.endEmitted,writable:!0}),e(A,g,{value:function(N,D){var B=O[y].read();B?(O[h]=null,O[s]=null,O[f]=null,N(_(B,!1))):(O[s]=N,O[f]=D)},writable:!0}),A));return O[h]=null,o(R,function(I){if(I&&I.code!=="ERR_STREAM_PREMATURE_CLOSE"){var N=O[f];N!==null&&(O[h]=null,O[s]=null,O[f]=null,N(I)),O[u]=I;return}var D=O[s];D!==null&&(O[h]=null,O[s]=null,O[f]=null,D(_(void 0,!0))),O[l]=!0}),R.on("readable",m.bind(null,O)),O};return Ne=T,Ne}var ke,dt;function gr(){return dt||(dt=1,ke=function(){throw new Error("Readable.from is not available in the browser")}),ke}var qe,ct;function Dt(){if(ct)return qe;ct=1,qe=D;var t;D.ReadableState=N,Ve.EventEmitter;var e=function(i,p){return i.listeners(p).length},r=Tt(),a=he.Buffer,o=(typeof X<"u"?X:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function s(n){return a.from(n)}function f(n){return a.isBuffer(n)||n instanceof o}var u=Ct,l;u&&u.debuglog?l=u.debuglog("stream"):l=function(){};var h=er(),g=At(),y=Mt(),_=y.getHighWaterMark,M=Z().codes,m=M.ERR_INVALID_ARG_TYPE,S=M.ERR_STREAM_PUSH_AFTER_EOF,b=M.ERR_METHOD_NOT_IMPLEMENTED,w=M.ERR_STREAM_UNSHIFT_AFTER_END_EVENT,T,L,R;Q(D,r);var A=g.errorOrDestroy,O=["error","close","destroy","pause","resume"];function I(n,i,p){if(typeof n.prependListener=="function")return n.prependListener(i,p);!n._events||!n._events[i]?n.on(i,p):Array.isArray(n._events[i])?n._events[i].unshift(p):n._events[i]=[p,n._events[i]]}function N(n,i,p){t=t||J(),n=n||{},typeof p!="boolean"&&(p=i instanceof t),this.objectMode=!!n.objectMode,p&&(this.objectMode=this.objectMode||!!n.readableObjectMode),this.highWaterMark=_(this,n,"readableHighWaterMark",p),this.buffer=new h,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.paused=!0,this.emitClose=n.emitClose!==!1,this.autoDestroy=!!n.autoDestroy,this.destroyed=!1,this.defaultEncoding=n.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,n.encoding&&(T||(T=We.StringDecoder),this.decoder=new T(n.encoding),this.encoding=n.encoding)}function D(n){if(t=t||J(),!(this instanceof D))return new D(n);var i=this instanceof t;this._readableState=new N(n,this,i),this.readable=!0,n&&(typeof n.read=="function"&&(this._read=n.read),typeof n.destroy=="function"&&(this._destroy=n.destroy)),r.call(this)}Object.defineProperty(D.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0?!1:this._readableState.destroyed},set:function(i){this._readableState&&(this._readableState.destroyed=i)}}),D.prototype.destroy=g.destroy,D.prototype._undestroy=g.undestroy,D.prototype._destroy=function(n,i){i(n)},D.prototype.push=function(n,i){var p=this._readableState,E;return p.objectMode?E=!0:typeof n=="string"&&(i=i||p.defaultEncoding,i!==p.encoding&&(n=a.from(n,i),i=""),E=!0),B(this,n,i,!1,E)},D.prototype.unshift=function(n){return B(this,n,null,!0,!1)};function B(n,i,p,E,j){l("readableAddChunk",i);var x=n._readableState;if(i===null)x.reading=!1,be(n,x);else{var q;if(j||(q=ve(x,i)),q)A(n,q);else if(x.objectMode||i&&i.length>0)if(typeof i!="string"&&!x.objectMode&&Object.getPrototypeOf(i)!==a.prototype&&(i=s(i)),E)x.endEmitted?A(n,new w):ee(n,x,i,!0);else if(x.ended)A(n,new S);else{if(x.destroyed)return!1;x.reading=!1,x.decoder&&!p?(i=x.decoder.write(i),x.objectMode||i.length!==0?ee(n,x,i,!1):V(n,x)):ee(n,x,i,!1)}else E||(x.reading=!1,V(n,x))}return!x.ended&&(x.length<x.highWaterMark||x.length===0)}function ee(n,i,p,E){i.flowing&&i.length===0&&!i.sync?(i.awaitDrain=0,n.emit("data",p)):(i.length+=i.objectMode?1:p.length,E?i.buffer.unshift(p):i.buffer.push(p),i.needReadable&&U(n)),V(n,i)}function ve(n,i){var p;return!f(i)&&typeof i!="string"&&i!==void 0&&!n.objectMode&&(p=new m("chunk",["string","Buffer","Uint8Array"],i)),p}D.prototype.isPaused=function(){return this._readableState.flowing===!1},D.prototype.setEncoding=function(n){T||(T=We.StringDecoder);var i=new T(n);this._readableState.decoder=i,this._readableState.encoding=this._readableState.decoder.encoding;for(var p=this._readableState.buffer.head,E="";p!==null;)E+=i.write(p.data),p=p.next;return this._readableState.buffer.clear(),E!==""&&this._readableState.buffer.push(E),this._readableState.length=E.length,this};var $=1073741824;function _e(n){return n>=$?n=$:(n--,n|=n>>>1,n|=n>>>2,n|=n>>>4,n|=n>>>8,n|=n>>>16,n++),n}function ae(n,i){return n<=0||i.length===0&&i.ended?0:i.objectMode?1:n!==n?i.flowing&&i.length?i.buffer.head.data.length:i.length:(n>i.highWaterMark&&(i.highWaterMark=_e(n)),n<=i.length?n:i.ended?i.length:(i.needReadable=!0,0))}D.prototype.read=function(n){l("read",n),n=parseInt(n,10);var i=this._readableState,p=n;if(n!==0&&(i.emittedReadable=!1),n===0&&i.needReadable&&((i.highWaterMark!==0?i.length>=i.highWaterMark:i.length>0)||i.ended))return l("read: emitReadable",i.length,i.ended),i.length===0&&i.ended?v(this):U(this),null;if(n=ae(n,i),n===0&&i.ended)return i.length===0&&v(this),null;var E=i.needReadable;l("need readable",E),(i.length===0||i.length-n<i.highWaterMark)&&(E=!0,l("length less than watermark",E)),i.ended||i.reading?(E=!1,l("reading or ended",E)):E&&(l("do read"),i.reading=!0,i.sync=!0,i.length===0&&(i.needReadable=!0),this._read(i.highWaterMark),i.sync=!1,i.reading||(n=ae(p,i)));var j;return n>0?j=d(n,i):j=null,j===null?(i.needReadable=i.length<=i.highWaterMark,n=0):(i.length-=n,i.awaitDrain=0),i.length===0&&(i.ended||(i.needReadable=!0),p!==n&&i.ended&&v(this)),j!==null&&this.emit("data",j),j};function be(n,i){if(l("onEofChunk"),!i.ended){if(i.decoder){var p=i.decoder.end();p&&p.length&&(i.buffer.push(p),i.length+=i.objectMode?1:p.length)}i.ended=!0,i.sync?U(n):(i.needReadable=!1,i.emittedReadable||(i.emittedReadable=!0,se(n)))}}function U(n){var i=n._readableState;l("emitReadable",i.needReadable,i.emittedReadable),i.needReadable=!1,i.emittedReadable||(l("emitReadable",i.flowing),i.emittedReadable=!0,process.nextTick(se,n))}function se(n){var i=n._readableState;l("emitReadable_",i.destroyed,i.length,i.ended),!i.destroyed&&(i.length||i.ended)&&(n.emit("readable"),i.emittedReadable=!1),i.needReadable=!i.flowing&&!i.ended&&i.length<=i.highWaterMark,c(n)}function V(n,i){i.readingMore||(i.readingMore=!0,process.nextTick(oe,n,i))}function oe(n,i){for(;!i.reading&&!i.ended&&(i.length<i.highWaterMark||i.flowing&&i.length===0);){var p=i.length;if(l("maybeReadMore read 0"),n.read(0),p===i.length)break}i.readingMore=!1}D.prototype._read=function(n){A(this,new b("_read()"))},D.prototype.pipe=function(n,i){var p=this,E=this._readableState;switch(E.pipesCount){case 0:E.pipes=n;break;case 1:E.pipes=[E.pipes,n];break;default:E.pipes.push(n);break}E.pipesCount+=1,l("pipe count=%d opts=%j",E.pipesCount,i);var j=(!i||i.end!==!1)&&n!==process.stdout&&n!==process.stderr,x=j?G:te;E.endEmitted?process.nextTick(x):p.once("end",x),n.on("unpipe",q);function q(K,Y){l("onunpipe"),K===p&&Y&&Y.hasUnpiped===!1&&(Y.hasUnpiped=!0,Vt())}function G(){l("onend"),n.end()}var ue=ge(p);n.on("drain",ue);var Xe=!1;function Vt(){l("cleanup"),n.removeListener("close",Ee),n.removeListener("finish",Se),n.removeListener("drain",ue),n.removeListener("error",me),n.removeListener("unpipe",q),p.removeListener("end",G),p.removeListener("end",te),p.removeListener("data",Je),Xe=!0,E.awaitDrain&&(!n._writableState||n._writableState.needDrain)&&ue()}p.on("data",Je);function Je(K){l("ondata");var Y=n.write(K);l("dest.write",Y),Y===!1&&((E.pipesCount===1&&E.pipes===n||E.pipesCount>1&&P(E.pipes,n)!==-1)&&!Xe&&(l("false write response, pause",E.awaitDrain),E.awaitDrain++),p.pause())}function me(K){l("onerror",K),te(),n.removeListener("error",me),e(n,"error")===0&&A(n,K)}I(n,"error",me);function Ee(){n.removeListener("finish",Se),te()}n.once("close",Ee);function Se(){l("onfinish"),n.removeListener("close",Ee),te()}n.once("finish",Se);function te(){l("unpipe"),p.unpipe(n)}return n.emit("pipe",p),E.flowing||(l("pipe resume"),p.resume()),n};function ge(n){return function(){var p=n._readableState;l("pipeOnDrain",p.awaitDrain),p.awaitDrain&&p.awaitDrain--,p.awaitDrain===0&&e(n,"data")&&(p.flowing=!0,c(n))}}D.prototype.unpipe=function(n){var i=this._readableState,p={hasUnpiped:!1};if(i.pipesCount===0)return this;if(i.pipesCount===1)return n&&n!==i.pipes?this:(n||(n=i.pipes),i.pipes=null,i.pipesCount=0,i.flowing=!1,n&&n.emit("unpipe",this,p),this);if(!n){var E=i.pipes,j=i.pipesCount;i.pipes=null,i.pipesCount=0,i.flowing=!1;for(var x=0;x<j;x++)E[x].emit("unpipe",this,{hasUnpiped:!1});return this}var q=P(i.pipes,n);return q===-1?this:(i.pipes.splice(q,1),i.pipesCount-=1,i.pipesCount===1&&(i.pipes=i.pipes[0]),n.emit("unpipe",this,p),this)},D.prototype.on=function(n,i){var p=r.prototype.on.call(this,n,i),E=this._readableState;return n==="data"?(E.readableListening=this.listenerCount("readable")>0,E.flowing!==!1&&this.resume()):n==="readable"&&!E.endEmitted&&!E.readableListening&&(E.readableListening=E.needReadable=!0,E.flowing=!1,E.emittedReadable=!1,l("on readable",E.length,E.reading),E.length?U(this):E.reading||process.nextTick(H,this)),p},D.prototype.addListener=D.prototype.on,D.prototype.removeListener=function(n,i){var p=r.prototype.removeListener.call(this,n,i);return n==="readable"&&process.nextTick(fe,this),p},D.prototype.removeAllListeners=function(n){var i=r.prototype.removeAllListeners.apply(this,arguments);return(n==="readable"||n===void 0)&&process.nextTick(fe,this),i};function fe(n){var i=n._readableState;i.readableListening=n.listenerCount("readable")>0,i.resumeScheduled&&!i.paused?i.flowing=!0:n.listenerCount("data")>0&&n.resume()}function H(n){l("readable nexttick read 0"),n.read(0)}D.prototype.resume=function(){var n=this._readableState;return n.flowing||(l("resume"),n.flowing=!n.readableListening,ye(this,n)),n.paused=!1,this};function ye(n,i){i.resumeScheduled||(i.resumeScheduled=!0,process.nextTick(we,n,i))}function we(n,i){l("resume",i.reading),i.reading||n.read(0),i.resumeScheduled=!1,n.emit("resume"),c(n),i.flowing&&!i.reading&&n.read(0)}D.prototype.pause=function(){return l("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(l("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this};function c(n){var i=n._readableState;for(l("flow",i.flowing);i.flowing&&n.read()!==null;);}D.prototype.wrap=function(n){var i=this,p=this._readableState,E=!1;n.on("end",function(){if(l("wrapped end"),p.decoder&&!p.ended){var q=p.decoder.end();q&&q.length&&i.push(q)}i.push(null)}),n.on("data",function(q){if(l("wrapped data"),p.decoder&&(q=p.decoder.write(q)),!(p.objectMode&&q==null)&&!(!p.objectMode&&(!q||!q.length))){var G=i.push(q);G||(E=!0,n.pause())}});for(var j in n)this[j]===void 0&&typeof n[j]=="function"&&(this[j]=function(G){return function(){return n[G].apply(n,arguments)}}(j));for(var x=0;x<O.length;x++)n.on(O[x],this.emit.bind(this,O[x]));return this._read=function(q){l("wrapped _read",q),E&&(E=!1,n.resume())},this},typeof Symbol=="function"&&(D.prototype[Symbol.asyncIterator]=function(){return L===void 0&&(L=br()),L(this)}),Object.defineProperty(D.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(D.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(D.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(i){this._readableState&&(this._readableState.flowing=i)}}),D._fromList=d,Object.defineProperty(D.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}});function d(n,i){if(i.length===0)return null;var p;return i.objectMode?p=i.buffer.shift():!n||n>=i.length?(i.decoder?p=i.buffer.join(""):i.buffer.length===1?p=i.buffer.first():p=i.buffer.concat(i.length),i.buffer.clear()):p=i.buffer.consume(n,i.decoder),p}function v(n){var i=n._readableState;l("endReadable",i.endEmitted),i.endEmitted||(i.ended=!0,process.nextTick(C,i,n))}function C(n,i){if(l("endReadableNT",n.endEmitted,n.length),!n.endEmitted&&n.length===0&&(n.endEmitted=!0,i.readable=!1,i.emit("end"),n.autoDestroy)){var p=i._writableState;(!p||p.autoDestroy&&p.finished)&&i.destroy()}}typeof Symbol=="function"&&(D.from=function(n,i){return R===void 0&&(R=gr()),R(D,n,i)});function P(n,i){for(var p=0,E=n.length;p<E;p++)if(n[p]===i)return p;return-1}return qe}var je,ht;function xt(){if(ht)return je;ht=1,je=u;var t=Z().codes,e=t.ERR_METHOD_NOT_IMPLEMENTED,r=t.ERR_MULTIPLE_CALLBACK,a=t.ERR_TRANSFORM_ALREADY_TRANSFORMING,o=t.ERR_TRANSFORM_WITH_LENGTH_0,s=J();Q(u,s);function f(g,y){var _=this._transformState;_.transforming=!1;var M=_.writecb;if(M===null)return this.emit("error",new r);_.writechunk=null,_.writecb=null,y!=null&&this.push(y),M(g);var m=this._readableState;m.reading=!1,(m.needReadable||m.length<m.highWaterMark)&&this._read(m.highWaterMark)}function u(g){if(!(this instanceof u))return new u(g);s.call(this,g),this._transformState={afterTransform:f.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,g&&(typeof g.transform=="function"&&(this._transform=g.transform),typeof g.flush=="function"&&(this._flush=g.flush)),this.on("prefinish",l)}function l(){var g=this;typeof this._flush=="function"&&!this._readableState.destroyed?this._flush(function(y,_){h(g,y,_)}):h(this,null,null)}u.prototype.push=function(g,y){return this._transformState.needTransform=!1,s.prototype.push.call(this,g,y)},u.prototype._transform=function(g,y,_){_(new e("_transform()"))},u.prototype._write=function(g,y,_){var M=this._transformState;if(M.writecb=_,M.writechunk=g,M.writeencoding=y,!M.transforming){var m=this._readableState;(M.needTransform||m.needReadable||m.length<m.highWaterMark)&&this._read(m.highWaterMark)}},u.prototype._read=function(g){var y=this._transformState;y.writechunk!==null&&!y.transforming?(y.transforming=!0,this._transform(y.writechunk,y.writeencoding,y.afterTransform)):y.needTransform=!0},u.prototype._destroy=function(g,y){s.prototype._destroy.call(this,g,function(_){y(_)})};function h(g,y,_){if(y)return g.emit("error",y);if(_!=null&&g.push(_),g._writableState.length)throw new o;if(g._transformState.transforming)throw new a;return g.push(null)}return je}var Ie,pt;function yr(){if(pt)return Ie;pt=1,Ie=e;var t=xt();Q(e,t);function e(r){if(!(this instanceof e))return new e(r);t.call(this,r)}return e.prototype._transform=function(r,a,o){o(null,r)},Ie}var Fe,vt;function wr(){if(vt)return Fe;vt=1;var t;function e(_){var M=!1;return function(){M||(M=!0,_.apply(void 0,arguments))}}var r=Z().codes,a=r.ERR_MISSING_ARGS,o=r.ERR_STREAM_DESTROYED;function s(_){if(_)throw _}function f(_){return _.setHeader&&typeof _.abort=="function"}function u(_,M,m,S){S=e(S);var b=!1;_.on("close",function(){b=!0}),t===void 0&&(t=Ke()),t(_,{readable:M,writable:m},function(T){if(T)return S(T);b=!0,S()});var w=!1;return function(T){if(!b&&!w){if(w=!0,f(_))return _.abort();if(typeof _.destroy=="function")return _.destroy();S(T||new o("pipe"))}}}function l(_){_()}function h(_,M){return _.pipe(M)}function g(_){return!_.length||typeof _[_.length-1]!="function"?s:_.pop()}function y(){for(var _=arguments.length,M=new Array(_),m=0;m<_;m++)M[m]=arguments[m];var S=g(M);if(Array.isArray(M[0])&&(M=M[0]),M.length<2)throw new a("streams");var b,w=M.map(function(T,L){var R=L<M.length-1,A=L>0;return u(T,R,A,function(O){b||(b=O),O&&w.forEach(l),!R&&(w.forEach(l),S(b))})});return M.reduce(h)}return Fe=y,Fe}var Pt=F,Ye=Ve.EventEmitter,mr=Q;mr(F,Ye);F.Readable=Dt();F.Writable=Ot();F.Duplex=J();F.Transform=xt();F.PassThrough=yr();F.finished=Ke();F.pipeline=wr();F.Stream=F;function F(){Ye.call(this)}F.prototype.pipe=function(t,e){var r=this;function a(g){t.writable&&t.write(g)===!1&&r.pause&&r.pause()}r.on("data",a);function o(){r.readable&&r.resume&&r.resume()}t.on("drain",o),!t._isStdio&&(!e||e.end!==!1)&&(r.on("end",f),r.on("close",u));var s=!1;function f(){s||(s=!0,t.end())}function u(){s||(s=!0,typeof t.destroy=="function"&&t.destroy())}function l(g){if(h(),Ye.listenerCount(this,"error")===0)throw g}r.on("error",l),t.on("error",l);function h(){r.removeListener("data",a),t.removeListener("drain",o),r.removeListener("end",f),r.removeListener("close",u),r.removeListener("error",l),t.removeListener("error",l),r.removeListener("end",h),r.removeListener("close",h),t.removeListener("close",h)}return r.on("end",h),r.on("close",h),t.on("close",h),t.emit("pipe",r),t};function ne(t){return t.replace(/%([0-9A-Fa-f]{2})/g,(e,r)=>String.fromCharCode(parseInt(r,16)))}function Nt(t,e){return String(e).replace(t,r=>`%${r.charCodeAt(0).toString(16).toUpperCase().padStart(2,"0")}`)}function re(t){return Nt(/[\n;\r\t=%&,\x00-\x1f\x7f-\xff]/g,t)}function W(t){return Nt(/[\n\r\t%\x00-\x1f\x7f-\xff]/g,t)}function kt(t){if(!(t&&t.length)||t===".")return{};const e={};return t.replace(/\r?\n$/,"").split(";").forEach(r=>{const a=r.split("=",2);if(!(a[1]&&a[1].length))return;a[0]=a[0].trim();let o=e[a[0].trim()];o||(o=[],e[a[0]]=o),o.push(...a[1].split(",").map(s=>s.trim()).map(ne))}),e}function qt(t){const e=t.split(" ").map(a=>a==="."||a===""?null:a);return{seq_id:e[0]&&ne(e[0]),source:e[1]&&ne(e[1]),type:e[2]&&ne(e[2]),start:e[3]===null?null:parseInt(e[3],10),end:e[4]===null?null:parseInt(e[4],10),score:e[5]===null?null:parseFloat(e[5]),strand:e[6],phase:e[7],attributes:e[8]===null?null:kt(e[8])}}function jt(t){const e=/^\s*##\s*(\S+)\s*(.*)/.exec(t);if(!e)return null;const[,r]=e;let[,,a]=e;const o={directive:r};if(a.length&&(a=a.replace(/\r?\n$/,""),o.value=a),r==="sequence-region"){const s=a.split(/\s+/,3);return{...o,seq_id:s[0],start:s[1]&&s[1].replace(/\D/g,""),end:s[2]&&s[2].replace(/\D/g,"")}}else if(r==="genome-build"){const[s,f]=a.split(/\s+/,2);return{...o,source:s,buildName:f}}return o}function It(t){const e=[];return Object.entries(t).forEach(([r,a])=>{if(!a)return;let o;a.hasOwnProperty("toString")?o=re(a.toString()):Array.isArray(a)?o=a.map(re).join(","):o=re(a),e.push(`${re(r)}=${o}`)}),e.length?e.join(";"):"."}function Er(t,e){const r=t.attributes===null||t.attributes===void 0?".":It(t.attributes),o=`${[t.seq_id===null?".":W(t.seq_id),t.source===null?".":W(t.source),t.type===null?".":W(t.type),t.start===null?".":W(t.start),t.end===null?".":W(t.end),t.score===null?".":W(t.score),t.strand===null?".":W(t.strand),t.phase===null?".":W(t.phase),r].join(" ")} +`;return e[o]?"":(e[o]=!0,o)}function de(t,e){if(Array.isArray(t))return t.map(a=>de(a,e)).join("");const r=[Er(t,e)];return Sr(t)&&r.push(...t.child_features.map(a=>de(a,e)),...t.derived_features.map(a=>de(a,e))),r.join("")}function Ft(t){return de(t,{})}function Bt(t){let e=`##${t.directive}`;return t.value&&(e+=` ${t.value}`),e+=` +`,e}function Wt(t){return`# ${t.comment} +`}function ze(t){return`>${t.id}${t.description?` ${t.description}`:""} +${t.sequence} +`}function ce(t){function e(r){return"attributes"in r?Ft(r):"directive"in r?Bt(r):"sequence"in r?ze(r):"comment"in r?Wt(r):`# (invalid item found during format) +`}return Array.isArray(t)?t.map(e):e(t)}function Sr(t){return t.child_features!==void 0&&t.derived_features!==void 0}const Rr=Object.freeze(Object.defineProperty({__proto__:null,escape:re,escapeColumn:W,formatAttributes:It,formatComment:Wt,formatDirective:Bt,formatFeature:Ft,formatItem:ce,formatSequence:ze,parseAttributes:kt,parseDirective:jt,parseFeature:qt,unescape:ne},Symbol.toStringTag,{value:"Module"})),_t={Parent:"child_features",Derives_from:"derived_features"};class bt{constructor(e){this.seqCallback=e,this.currentSequence=void 0}addLine(e){const r=/^>\s*(\S+)\s*(.*)/.exec(e);r?(this._flush(),this.currentSequence={id:r[1],sequence:""},r[2]&&(this.currentSequence.description=r[2].trim())):this.currentSequence&&/\S/.test(e)&&(this.currentSequence.sequence+=e.replace(/\s/g,""))}_flush(){this.currentSequence&&this.seqCallback(this.currentSequence)}finish(){this._flush()}}class Ut{constructor(e){this.fastaParser=void 0,this.eof=!1,this.lineNumber=0,this._underConstructionTopLevel=[],this._underConstructionById={},this._completedReferences={},this._underConstructionOrphans={};const r=()=>{};this.featureCallback=e.featureCallback||r,this.endCallback=e.endCallback||r,this.commentCallback=e.commentCallback||r,this.errorCallback=e.errorCallback||r,this.directiveCallback=e.directiveCallback||r,this.sequenceCallback=e.sequenceCallback||r,this.disableDerivesFromReferences=e.disableDerivesFromReferences||!1,this.bufferSize=e.bufferSize===void 0?1e3:e.bufferSize}addLine(e){if(this.fastaParser){this.fastaParser.addLine(e);return}if(this.eof)return;if(this.lineNumber+=1,/^\s*[^#\s>]/.test(e)){this._bufferLine(e);return}const r=/^\s*(#+)(.*)/.exec(e);if(r){const[,a]=r;let[,,o]=r;if(a.length===3)this._emitAllUnderConstructionFeatures();else if(a.length===2){const s=jt(e);s&&(s.directive==="FASTA"?(this._emitAllUnderConstructionFeatures(),this.eof=!0,this.fastaParser=new bt(this.sequenceCallback)):this._emitItem(s))}else o=o.replace(/\s*/,""),this._emitItem({comment:o})}else if(!/^\s*$/.test(e))if(/^\s*>/.test(e))this._emitAllUnderConstructionFeatures(),this.eof=!0,this.fastaParser=new bt(this.sequenceCallback),this.fastaParser.addLine(e);else{const a=e.replace(/\r?\n?$/g,"");throw new Error(`GFF3 parse error. Cannot parse '${a}'.`)}}finish(){this._emitAllUnderConstructionFeatures(),this.fastaParser&&this.fastaParser.finish(),this.endCallback()}_emitItem(e){Array.isArray(e)?this.featureCallback(e):"directive"in e?this.directiveCallback(e):"comment"in e&&this.commentCallback(e)}_enforceBufferSizeLimit(e=0){const r=a=>{a&&Array.isArray(a)&&a[0].attributes&&a[0].attributes.ID&&a[0].attributes.ID[0]&&(a[0].attributes.ID.forEach(s=>{delete this._underConstructionById[s],delete this._completedReferences[s]}),a.forEach(s=>{s.child_features&&s.child_features.forEach(f=>r(f)),s.derived_features&&s.derived_features.forEach(f=>r(f))}))};for(;this._underConstructionTopLevel.length+e>this.bufferSize;){const a=this._underConstructionTopLevel.shift();a&&(this._emitItem(a),r(a))}}_emitAllUnderConstructionFeatures(){if(this._underConstructionTopLevel.forEach(this._emitItem.bind(this)),this._underConstructionTopLevel=[],this._underConstructionById={},this._completedReferences={},Array.from(Object.values(this._underConstructionOrphans)).length)throw new Error(`some features reference other features that do not exist in the file (or in the same '###' scope). ${Object.keys(this._underConstructionOrphans)}`)}_bufferLine(e){var r,a,o;const f={...qt(e),child_features:[],derived_features:[]},u=((r=f.attributes)===null||r===void 0?void 0:r.ID)||[],l=((a=f.attributes)===null||a===void 0?void 0:a.Parent)||[],h=this.disableDerivesFromReferences?[]:((o=f.attributes)===null||o===void 0?void 0:o.Derives_from)||[];if(!u.length&&!l.length&&!h.length){this._emitItem([f]);return}let g;u.forEach(y=>{const _=this._underConstructionById[y];_?(_[_.length-1].type!==f.type&&this._parseError(`multi-line feature "${y}" has inconsistent types: "${f.type}", "${_[_.length-1].type}"`),_.push(f),g=_):(g=[f],this._enforceBufferSizeLimit(1),!l.length&&!h.length&&this._underConstructionTopLevel.push(g),this._underConstructionById[y]=g,this._resolveReferencesTo(g,y))}),this._resolveReferencesFrom(g||[f],{Parent:l,Derives_from:h},u)}_resolveReferencesTo(e,r){const a=this._underConstructionOrphans[r];a&&(e.forEach(o=>{o.child_features.push(...a.Parent)}),e.forEach(o=>{o.derived_features.push(...a.Derives_from)}),delete this._underConstructionOrphans[r])}_parseError(e){this.eof=!0,this.errorCallback(`${this.lineNumber}: ${e}`)}_resolveReferencesFrom(e,r,a){function o(s,f,u){let l=s[f];l||(l={},s[f]=l);const h=l[u]||!1;return l[u]=!0,h}r.Parent.forEach(s=>{const f=this._underConstructionById[s];if(f){const u=_t.Parent;a.filter(l=>o(this._completedReferences,l,`Parent,${s}`)).length||f.forEach(l=>{l[u].push(e)})}else{let u=this._underConstructionOrphans[s];u||(u={Parent:[],Derives_from:[]},this._underConstructionOrphans[s]=u),u.Parent.push(e)}}),r.Derives_from.forEach(s=>{const f=this._underConstructionById[s];if(f){const u=_t.Derives_from;a.filter(l=>o(this._completedReferences,l,`Derives_from,${s}`)).length||f.forEach(l=>{l[u].push(e)})}else{let u=this._underConstructionOrphans[s];u||(u={Parent:[],Derives_from:[]},this._underConstructionOrphans[s]=u),u.Derives_from.push(e)}})}}function He(t){process&&process.nextTick?process.nextTick(t):t()}function Ht(t){const e={encoding:"utf8",parseFeatures:!0,parseDirectives:!1,parseSequences:!0,parseComments:!1,bufferSize:1e3,disableDerivesFromReferences:!1,...t};return t.parseAll&&(e.parseFeatures=!0,e.parseDirectives=!0,e.parseComments=!0,e.parseSequences=!0),e}class Lr extends Pt.Transform{constructor(e={}){super({objectMode:!0}),this.textBuffer="";const r=Ht(e);this.encoding=e.encoding||"utf8",this.decoder=new ar;const a=this.push.bind(this);this.parser=new Ut({featureCallback:r.parseFeatures?a:void 0,directiveCallback:r.parseDirectives?a:void 0,commentCallback:r.parseComments?a:void 0,sequenceCallback:r.parseSequences?a:void 0,errorCallback:o=>this.emit("error",o),bufferSize:r.bufferSize,disableDerivesFromReferences:r.disableDerivesFromReferences})}_addLine(e){e&&this.parser.addLine(e)}_nextText(e){const r=(this.textBuffer+e).split(/\r?\n/);this.textBuffer=r.pop()||"",r.forEach(a=>this._addLine(a))}_transform(e,r,a){this._nextText(this.decoder.write(e)),He(a)}_flush(e){this.decoder.end&&this._nextText(this.decoder.end()),this.textBuffer!=null&&this._addLine(this.textBuffer),this.parser.finish(),He(e)}}function Tr(t={}){return new Lr(t)}function Cr(t,e={}){if(!t)return[];const r=Ht(e),a=[],o=a.push.bind(a),s=new Ut({featureCallback:r.parseFeatures?o:void 0,directiveCallback:r.parseDirectives?o:void 0,commentCallback:r.parseComments?o:void 0,sequenceCallback:r.parseSequences?o:void 0,disableDerivesFromReferences:r.disableDerivesFromReferences||!1,bufferSize:1/0,errorCallback:f=>{throw f}});return t.split(/\r?\n/).forEach(s.addLine.bind(s)),s.finish(),a}function Ar(t){const e=[],r=[];t.forEach(o=>{"sequence"in o?r.push(o):e.push(o)});let a=e.map(ce).join("");return r.length&&(a+=`##FASTA +`,a+=r.map(ze).join("")),a}class $t extends Pt.Transform{constructor(e={}){super(Object.assign(e,{objectMode:!0})),this.linesSinceLastSyncMark=0,this.haveWeEmittedData=!1,this.fastaMode=!1,this.minLinesBetweenSyncMarks=e.minSyncLines||100,this.insertVersionDirective=e.insertVersionDirective||!1}_transform(e,r,a){let o;if(!this.haveWeEmittedData&&this.insertVersionDirective){const s=Array.isArray(e)?e[0]:e;"directive"in s&&s.directive!=="gff-version"&&this.push(`##gff-version 3 +`)}if("sequence"in e&&!this.fastaMode&&(this.push(`##FASTA +`),this.fastaMode=!0),Array.isArray(e)?o=e.map(ce).join(""):o=ce(e),this.push(o),this.linesSinceLastSyncMark>=this.minLinesBetweenSyncMarks)this.push(`### +`),this.linesSinceLastSyncMark=0;else{let s=0;for(let f=0;f<o.length;f+=1)o[f]===` +`&&(s+=1);this.linesSinceLastSyncMark+=s}this.haveWeEmittedData=!0,He(a)}}function Mr(t={}){return new $t(t)}function Or(t,e,r={}){const a={insertVersionDirective:!0,...r};return new Promise((o,s)=>{t.pipe(new $t(a)).on("end",()=>o(null)).on("error",s).pipe(e)})}const Nr={parseStream:Tr,parseStringSync:Cr,formatSync:Ar,formatStream:Mr,formatFile:Or,util:Rr};export{Nr as default}; diff --git a/segmentmodel/assets/index-bb96b7b2.css b/segmentmodel/assets/index-bb96b7b2.css new file mode 100644 index 0000000..e571d43 --- /dev/null +++ b/segmentmodel/assets/index-bb96b7b2.css @@ -0,0 +1 @@ +@import"https://fonts.googleapis.com/css2?family=Nunito&display=swap";body{position:absolute;margin:0;top:0;bottom:0;left:0;right:0;display:flex;flex-direction:column;font-family:Nunito,sans-serif;font-size:15px}header{position:relative;padding:10px 10px 0}header .toolbar{position:absolute;right:10px;top:10px;bottom:20px}header .buttons{display:flex;margin:0;transition:visibility 1s,opacity 1s,transform 1s}header .buttons.hidden{visibility:hidden;opacity:0;transform:translate(30px)}header .buttons button{border:0;background:none;font-size:14px;border:2px solid #666;border-radius:4px}h1{margin:0;font-size:160%;border-bottom:2px solid black}h1 .main-title{position:relative}h1 .main-title .beta{position:absolute;font-size:13px;transform:translate(-1.6em,-.4em) rotate(20deg)}h1 small{font-size:55%;margin-left:.5em}h2,h3{margin-bottom:.4em;margin-top:1em}h1,h2,h3{font-weight:400}p{margin:.3em 0}a{color:#000}main{margin:0;flex-grow:1;position:relative}main .drop-zone{border-radius:10px;border:4px solid transparent}main .drop-zone.dragging{background-color:#f4f4f4;border:4px dashed #ccc}main>div{position:absolute!important;left:0;right:0;top:0;bottom:0;visibility:hidden}main>div.active-panel{visibility:visible}.file-box{max-width:900px;margin-left:auto;margin-right:auto}.example-data-buttons{display:flex;gap:.25em;align-items:center}.example-data-buttons .loading{display:flex;margin-left:1em;gap:.5em;align-items:center}footer{font-size:70%;padding:6px 10px}.upload-button-wrapper{margin:1em 0}.file-table{margin-top:1em;margin-left:1em;border-collapse:collapse}.file-table td{padding-right:.6em}.file-table .status{text-align:center;padding-right:.1em;width:1em}.file-table .okay{color:#5a2}.file-table .example-file{color:#bbb}.buttons{display:flex;align-items:center;justify-content:center;margin:2em 0}.btn{background-color:#548fcc;padding:8px 1em;color:#fff;border:0;border-radius:3px;font-weight:700;font-size:13px;transition:color .2s,background-color .2s}.btn:disabled{background-color:#eee;color:#ccc}.btn:focus{outline:none;box-shadow:0 0 4px #0af}.btn:hover:not(:disabled):not(.active){background-color:#4082c6}.btn:active:not(:disabled):not(.active){box-shadow:0 0 4px #0af,inset 0 3px 3px #0003;background-color:#3675b7}.btn.active{background-color:#2b5c8f;text-shadow:0 0 3px rgba(0,0,0,.5)}.btn.btn-lg{transition:color 1s,background-color 1s;font-size:22px;border-radius:4px;padding:.6em 1em}.btn-group{display:flex}.btn-group .btn:not(:first-child){border-top-left-radius:0;border-bottom-left-radius:0}.btn-group .btn:not(:last-child){border-top-right-radius:0;border-bottom-right-radius:0}.btn-group .btn:not(:last-child){border-right:1px solid #7ba9d8}.genome-spy .tooltip{max-width:initial} diff --git a/segmentmodel/assets/index-d89cadd6.js b/segmentmodel/assets/index-d89cadd6.js new file mode 100644 index 0000000..d90f395 --- /dev/null +++ b/segmentmodel/assets/index-d89cadd6.js @@ -0,0 +1 @@ +import{c as b,g as D}from"./_commonjsHelpers-de833af9.js";var T={},m={},h={},y={};Object.defineProperty(y,"__esModule",{value:!0});function A(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}function P(r,e){for(var t=0;t<e.length;t++){var o=e[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(r,o.key,o)}}function E(r,e,t){return e&&P(r.prototype,e),t&&P(r,t),Object.defineProperty(r,"prototype",{writable:!1}),r}function B(r,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),Object.defineProperty(r,"prototype",{writable:!1}),e&&w(r,e)}function p(r){return p=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},p(r)}function w(r,e){return w=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(o,n){return o.__proto__=n,o},w(r,e)}function $(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function g(r){if(r===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return r}function Y(r,e){if(e&&(typeof e=="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return g(r)}function G(r){var e=$();return function(){var o=p(r),n;if(e){var a=p(this).constructor;n=Reflect.construct(o,arguments,a)}else n=o.apply(this,arguments);return Y(this,n)}}function U(r,e){for(;!Object.prototype.hasOwnProperty.call(r,e)&&(r=p(r),r!==null););return r}function v(){return typeof Reflect<"u"&&Reflect.get?v=Reflect.get.bind():v=function(e,t,o){var n=U(e,t);if(n){var a=Object.getOwnPropertyDescriptor(n,t);return a.get?a.get.call(arguments.length<3?e:o):a.value}},v.apply(this,arguments)}var j=function(){function r(){A(this,r),Object.defineProperty(this,"listeners",{value:{},writable:!0,configurable:!0})}return E(r,[{key:"addEventListener",value:function(t,o,n){t in this.listeners||(this.listeners[t]=[]),this.listeners[t].push({callback:o,options:n})}},{key:"removeEventListener",value:function(t,o){if(t in this.listeners){for(var n=this.listeners[t],a=0,c=n.length;a<c;a++)if(n[a].callback===o){n.splice(a,1);return}}}},{key:"dispatchEvent",value:function(t){if(t.type in this.listeners){for(var o=this.listeners[t.type],n=o.slice(),a=0,c=n.length;a<c;a++){var i=n[a];try{i.callback.call(this,t)}catch(l){Promise.resolve().then(function(){throw l})}i.options&&i.options.once&&this.removeEventListener(t.type,i.callback)}return!t.defaultPrevented}}}]),r}(),R=function(r){B(t,r);var e=G(t);function t(){var o;return A(this,t),o=e.call(this),o.listeners||j.call(g(o)),Object.defineProperty(g(o),"aborted",{value:!1,writable:!0,configurable:!0}),Object.defineProperty(g(o),"onabort",{value:null,writable:!0,configurable:!0}),Object.defineProperty(g(o),"reason",{value:void 0,writable:!0,configurable:!0}),o}return E(t,[{key:"toString",value:function(){return"[object AbortSignal]"}},{key:"dispatchEvent",value:function(n){n.type==="abort"&&(this.aborted=!0,typeof this.onabort=="function"&&this.onabort.call(this,n)),v(p(t.prototype),"dispatchEvent",this).call(this,n)}}]),t}(j),k=function(){function r(){A(this,r),Object.defineProperty(this,"signal",{value:new R,writable:!0,configurable:!0})}return E(r,[{key:"abort",value:function(t){var o;try{o=new Event("abort")}catch{typeof document<"u"?document.createEvent?(o=document.createEvent("Event"),o.initEvent("abort",!1,!1)):(o=document.createEventObject(),o.type="abort"):o={type:"abort",bubbles:!1,cancelable:!1}}var n=t;if(n===void 0)if(typeof document>"u")n=new Error("This operation was aborted"),n.name="AbortError";else try{n=new DOMException("signal is aborted without reason")}catch{n=new Error("This operation was aborted"),n.name="AbortError"}this.signal.reason=n,this.signal.dispatchEvent(o)}},{key:"toString",value:function(){return"[object AbortController]"}}]),r}();typeof Symbol<"u"&&Symbol.toStringTag&&(k.prototype[Symbol.toStringTag]="AbortController",R.prototype[Symbol.toStringTag]="AbortSignal");function Q(r){return r.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL?(console.log("__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL=true is set, will force install polyfill"),!0):typeof r.Request=="function"&&!r.Request.prototype.hasOwnProperty("signal")||!r.AbortController}function H(r){typeof r=="function"&&(r={fetch:r});var e=r,t=e.fetch,o=e.Request,n=o===void 0?t.Request:o,a=e.AbortController,c=e.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL,i=c===void 0?!1:c;if(!Q({fetch:t,Request:n,AbortController:a,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:i}))return{fetch:t,Request:l};var l=n;(l&&!l.prototype.hasOwnProperty("signal")||i)&&(l=function(d,s){var f;s&&s.signal&&(f=s.signal,delete s.signal);var u=new n(d,s);return f&&Object.defineProperty(u,"signal",{writable:!1,enumerable:!1,configurable:!0,value:f}),u},l.prototype=n.prototype);var L=t,N=function(d,s){var f=l&&l.prototype.isPrototypeOf(d)?d.signal:s?s.signal:void 0;if(f){var u;try{u=new DOMException("Aborted","AbortError")}catch{u=new Error("Aborted"),u.name="AbortError"}if(f.aborted)return Promise.reject(u);var q=new Promise(function(I,x){f.addEventListener("abort",function(){return x(u)},{once:!0})});return s&&s.signal&&delete s.signal,Promise.race([q,L(d,s)])}return L(d,s)};return{fetch:N,Request:l}}y.AbortController=k;y.AbortSignal=R;y.abortableFetch=H;Object.defineProperty(h,"__esModule",{value:!0});h.AbortSignal=h.AbortController=void 0;const F=y;var _=function(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof b<"u")return b;throw new Error("unable to locate global object")};let J=typeof _().AbortController>"u"?F.AbortController:_().AbortController;h.AbortController=J;let K=typeof _().AbortController>"u"?F.AbortSignal:_().AbortSignal;h.AbortSignal=K;var S={};Object.defineProperty(S,"__esModule",{value:!0});const V=h;class W{}class X{constructor(){this.signals=new Set,this.abortController=new V.AbortController}addSignal(e=new W){if(this.signal.aborted)throw new Error("cannot add a signal, already aborted!");this.signals.add(e),e.aborted?this.handleAborted(e):typeof e.addEventListener=="function"&&e.addEventListener("abort",()=>{this.handleAborted(e)})}handleAborted(e){this.signals.delete(e),this.signals.size===0&&this.abortController.abort()}get signal(){return this.abortController.signal}abort(){this.abortController.abort()}}S.default=X;var C={};Object.defineProperty(C,"__esModule",{value:!0});class Z{constructor(){this.callbacks=new Set}addCallback(e=()=>{}){this.callbacks.add(e),e(this.currentMessage)}callback(e){this.currentMessage=e,this.callbacks.forEach(t=>{t(e)})}}C.default=Z;var z=b&&b.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(m,"__esModule",{value:!0});const ee=h,te=z(S),re=z(C);class O{constructor({fill:e,cache:t}){if(typeof e!="function")throw new TypeError("must pass a fill function");if(typeof t!="object")throw new TypeError("must pass a cache object");if(typeof t.get!="function"||typeof t.set!="function"||typeof t.delete!="function")throw new TypeError("cache must implement get(key), set(key, val), and and delete(key)");this.cache=t,this.fillCallback=e}static isAbortException(e){return e.name==="AbortError"||e.code==="ERR_ABORTED"||e.message==="AbortError: aborted"||e.message==="Error: aborted"}evict(e,t){this.cache.get(e)===t&&this.cache.delete(e)}fill(e,t,o,n){const a=new te.default,c=new re.default;c.addCallback(n);const i={aborter:a,promise:this.fillCallback(t,a.signal,l=>{c.callback(l)}),settled:!1,statusReporter:c,get aborted(){return this.aborter.signal.aborted}};i.aborter.addSignal(o),i.aborter.signal.addEventListener("abort",()=>{i.settled||this.evict(e,i)}),i.promise.then(()=>{i.settled=!0},()=>{i.settled=!0,this.evict(e,i)}).catch(l=>{throw console.error(l),l}),this.cache.set(e,i)}static checkSinglePromise(e,t){function o(){if(t&&t.aborted)throw Object.assign(new Error("aborted"),{code:"ERR_ABORTED"})}return e.then(n=>(o(),n),n=>{throw o(),n})}has(e){return this.cache.has(e)}get(e,t,o,n){if(!o&&t instanceof ee.AbortSignal)throw new TypeError("second get argument appears to be an AbortSignal, perhaps you meant to pass `null` for the fill data?");const a=this.cache.get(e);return a?a.aborted&&!a.settled?(this.evict(e,a),this.get(e,t,o,n)):a.settled?a.promise:(a.aborter.addSignal(o),a.statusReporter.addCallback(n),O.checkSinglePromise(a.promise,o)):(this.fill(e,t,o,n),O.checkSinglePromise(this.cache.get(e).promise,o))}delete(e){const t=this.cache.get(e);t&&(t.settled||t.aborter.abort(),this.cache.delete(e))}clear(){const e=this.cache.keys();let t=0;for(let o=e.next();!o.done;o=e.next())this.delete(o.value),t+=1;return t}}m.default=O;var oe=b&&b.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(T,"__esModule",{value:!0});const ne=oe(m);var se=T.default=ne.default;class ae{constructor(e={}){if(!(e.maxSize&&e.maxSize>0))throw new TypeError("`maxSize` must be a number greater than 0");this.maxSize=e.maxSize,this.cache=new Map,this.oldCache=new Map,this._size=0}_set(e,t){this.cache.set(e,t),this._size++,this._size>=this.maxSize&&(this._size=0,this.oldCache=this.cache,this.cache=new Map)}get(e){if(this.cache.has(e))return this.cache.get(e);if(this.oldCache.has(e)){const t=this.oldCache.get(e);return this.oldCache.delete(e),this._set(e,t),t}}set(e,t){return this.cache.has(e)?this.cache.set(e,t):this._set(e,t),this}has(e){return this.cache.has(e)||this.oldCache.has(e)}peek(e){if(this.cache.has(e))return this.cache.get(e);if(this.oldCache.has(e))return this.oldCache.get(e)}delete(e){const t=this.cache.delete(e);return t&&this._size--,this.oldCache.delete(e)||t}clear(){this.cache.clear(),this.oldCache.clear(),this._size=0}*keys(){for(const[e]of this)yield e}*values(){for(const[,e]of this)yield e}*[Symbol.iterator](){for(const e of this.cache)yield e;for(const e of this.oldCache){const[t]=e;this.cache.has(t)||(yield e)}}get size(){let e=0;for(const t of this.oldCache.keys())this.cache.has(t)||e++;return this._size+e}}var ie=ae;const ce=D(ie);export{ce as L,se as _}; diff --git a/segmentmodel/assets/index-f8b9b7f4.js b/segmentmodel/assets/index-f8b9b7f4.js new file mode 100644 index 0000000..0d064b8 --- /dev/null +++ b/segmentmodel/assets/index-f8b9b7f4.js @@ -0,0 +1,2 @@ +import{L as g}from"./__vite-browser-external-d053bc6e.js";import{b as w}from"./index-462333f7.js";import{L as x,u as E}from"./long-c1fdf4ae.js";import"./_commonjsHelpers-de833af9.js";const m=1;class _{constructor({filehandle:e,path:t}){if(e)this.filehandle=e;else if(t)this.filehandle=new g(t);else throw new TypeError("either filehandle or path must be defined")}_readLongWithOverflow(e,t=0,i=!0){const n=x.fromBytesLE(e.slice(t,t+8),i);if(n.greaterThan(Number.MAX_SAFE_INTEGER)||n.lessThan(Number.MIN_SAFE_INTEGER))throw new TypeError("integer overflow");return n.toNumber()}_getIndex(){return this.index||(this.index=this._readIndex()),this.index}async _readIndex(){let e=w.Buffer.allocUnsafe(8);await this.filehandle.read(e,0,8,0);const t=this._readLongWithOverflow(e,0,!0);if(!t)return[[0,0]];const i=new Array(t+1);i[0]=[0,0];const n=8*2*t;if(n>Number.MAX_SAFE_INTEGER)throw new TypeError("integer overflow");e=w.Buffer.allocUnsafe(n),await this.filehandle.read(e,0,n,8);for(let s=0;s<t;s+=1){const r=this._readLongWithOverflow(e,s*16),a=this._readLongWithOverflow(e,s*16+8);i[s+1]=[r,a]}return i}async getLastBlock(){const e=await this._getIndex();if(e.length)return e[e.length-1]}async getRelevantBlocksForRead(e,t){const i=t+e;if(e===0)return[];const n=await this._getIndex(),s=[],r=(h,u)=>{const p=h[m],b=u?u[m]:1/0;return p<=t&&b>t?0:p<t?-1:1};let a=0,f=n.length-1,o=Math.floor(n.length/2),d=r(n[o],n[o+1]);for(;d!==0;)d>0?f=o-1:d<0&&(a=o+1),o=Math.ceil((f-a)/2)+a,d=r(n[o],n[o+1]);s.push(n[o]);let c=o+1;for(;c<n.length&&(s.push(n[c]),!(n[c][m]>=i));c+=1);return s[s.length-1][m]<i&&s.push([]),s}}class y{constructor({filehandle:e,path:t,gziFilehandle:i,gziPath:n}){if(e)this.filehandle=e;else if(t)this.filehandle=new g(t);else throw new TypeError("either filehandle or path must be defined");if(!i&&!n&&!t)throw new TypeError("either gziFilehandle or gziPath must be defined");this.gzi=new _({filehandle:i,path:!i&&!n&&t?n:`${t}.gzi`})}async stat(){const e=await this.filehandle.stat();return Object.assign(e,{size:await this.getUncompressedFileSize(),blocks:void 0,blksize:void 0})}async getUncompressedFileSize(){const[,e]=await this.gzi.getLastBlock(),{size:t}=await this.filehandle.stat(),i=w.Buffer.allocUnsafe(4),{bytesRead:n}=await this.filehandle.read(i,0,4,t-28-4);if(n!==4)throw new Error("read error");const s=i.readUInt32LE(0);return e+s}async _readAndUncompressBlock(e,[t],[i]){let n=i;n||(n=(await this.filehandle.stat()).size);const s=n-t;return await this.filehandle.read(e,0,s,t),await E(e.slice(0,s))}async read(e,t,i,n){const s=await this.gzi.getRelevantBlocksForRead(i,n),r=w.Buffer.allocUnsafe(32768*2);let a=t,f=0;for(let o=0;o<s.length-1;o+=1){const d=await this._readAndUncompressBlock(r,s[o],s[o+1]),[,c]=s[o],h=c>=n?0:n-c,u=Math.min(n+i,c+d.length)-c;h>=0&&h<d.length&&(d.copy(e,a,h,u),a+=u-h,f+=u-h)}return{bytesRead:f,buffer:e}}}function S(l,e){return l.offset+l.lineBytes*Math.floor(e/l.lineLength)+e%l.lineLength}async function I(l,e){const t=await l.readFile(e);if(!(t&&t.length))throw new Error("No data read from FASTA index (FAI) file");let i=0,n;const s=t.toString("utf8").split(/\r?\n/).filter(r=>/\S/.test(r)).map(r=>r.split(" ")).filter(r=>r[0]!=="").map(r=>((!n||n.name!==r[0])&&(n={name:r[0],id:i},i+=1),{id:n.id,name:r[0],length:+r[1],start:0,end:+r[1],offset:+r[2],lineLength:+r[3],lineBytes:+r[4]}));return{name:Object.fromEntries(s.map(r=>[r.name,r])),id:Object.fromEntries(s.map(r=>[r.id,r]))}}class B{constructor({fasta:e,fai:t,path:i,faiPath:n,chunkSizeLimit:s=1e6}){if(e)this.fasta=e;else if(i)this.fasta=new g(i);else throw new Error("Need to pass filehandle for fasta or path to localfile");if(t)this.fai=t;else if(n)this.fai=new g(n);else if(i)this.fai=new g(`${i}.fai`);else throw new Error("Need to pass filehandle for or path to localfile");this.chunkSizeLimit=s}async _getIndexes(e){return this.indexes||(this.indexes=I(this.fai,e)),this.indexes}async getSequenceNames(e){return Object.keys((await this._getIndexes(e)).name)}async getSequenceSizes(e){const t={},i=await this._getIndexes(e),n=Object.values(i.id);for(let s=0;s<n.length;s+=1)t[n[s].name]=n[s].length;return t}async getSequenceSize(e,t){var i;return(i=(await this._getIndexes(t)).name[e])===null||i===void 0?void 0:i.length}async hasReferenceSequence(e,t){return!!(await this._getIndexes(t)).name[e]}async getResiduesById(e,t,i,n){const s=(await this._getIndexes(n)).id[e];if(s)return this._fetchFromIndexEntry(s,t,i,n)}async getResiduesByName(e,t,i,n){const s=(await this._getIndexes(n)).name[e];if(s)return this._fetchFromIndexEntry(s,t,i,n)}async getSequence(e,t,i,n){return this.getResiduesByName(e,t,i,n)}async _fetchFromIndexEntry(e,t=0,i,n){let s=i;if(t<0)throw new TypeError("regionStart cannot be less than 0");if((s===void 0||s>e.length)&&(s=e.length),t>=s)return"";const r=S(e,t),a=S(e,s)-r;if(a>this.chunkSizeLimit)throw new Error(`data size of ${a.toLocaleString()} bytes exceeded chunk size limit of ${this.chunkSizeLimit.toLocaleString()} bytes`);const f=Buffer.allocUnsafe(a);return await this.fasta.read(f,0,a,r,n),f.toString("utf8").replace(/\s+/g,"")}}class O extends B{constructor({fasta:e,path:t,fai:i,faiPath:n,gzi:s,gziPath:r,chunkSizeLimit:a}){super({fasta:e,path:t,fai:i,faiPath:n,chunkSizeLimit:a}),e&&s?this.fasta=new y({filehandle:e,gziFilehandle:s}):t&&r&&(this.fasta=new y({path:t,gziPath:r}))}}function L(l){return l.split(">").filter(e=>/\S/.test(e)).map(e=>{const[t,...i]=e.split(` +`),[n,...s]=t.split(" "),r=i.join("").replace(/\s/g,"");return{id:n,description:s.join(" "),sequence:r}})}class v{constructor({fasta:e,path:t}){if(e)this.fasta=e;else if(t)this.fasta=new g(t);else throw new Error("Need to pass fasta or path");this.data=this.fasta.readFile().then(i=>{const n=i.toString("utf8");return L(n)})}async fetch(e,t,i){const s=(await this.data).find(a=>a.id===e),r=i-t;if(!s)throw new Error(`no sequence with id ${e} exists`);return s.sequence.substr(t,r)}async getSequenceNames(){return(await this.data).map(t=>t.id)}}export{O as BgzipIndexedFasta,v as FetchableSmallFasta,B as IndexedFasta,L as parseSmallFasta}; diff --git a/segmentmodel/assets/long-c1fdf4ae.js b/segmentmodel/assets/long-c1fdf4ae.js new file mode 100644 index 0000000..38b4a50 --- /dev/null +++ b/segmentmodel/assets/long-c1fdf4ae.js @@ -0,0 +1 @@ +import{b as Pi}from"./index-462333f7.js";import{g as Da}from"./_commonjsHelpers-de833af9.js";var re={};(function(e){var i=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";function t(n,h){return Object.prototype.hasOwnProperty.call(n,h)}e.assign=function(n){for(var h=Array.prototype.slice.call(arguments,1);h.length;){var f=h.shift();if(f){if(typeof f!="object")throw new TypeError(f+"must be non-object");for(var _ in f)t(f,_)&&(n[_]=f[_])}}return n},e.shrinkBuf=function(n,h){return n.length===h?n:n.subarray?n.subarray(0,h):(n.length=h,n)};var a={arraySet:function(n,h,f,_,l){if(h.subarray&&n.subarray){n.set(h.subarray(f,f+_),l);return}for(var o=0;o<_;o++)n[l+o]=h[f+o]},flattenChunks:function(n){var h,f,_,l,o,v;for(_=0,h=0,f=n.length;h<f;h++)_+=n[h].length;for(v=new Uint8Array(_),l=0,h=0,f=n.length;h<f;h++)o=n[h],v.set(o,l),l+=o.length;return v}},r={arraySet:function(n,h,f,_,l){for(var o=0;o<_;o++)n[l+o]=h[f+o]},flattenChunks:function(n){return[].concat.apply([],n)}};e.setTyped=function(n){n?(e.Buf8=Uint8Array,e.Buf16=Uint16Array,e.Buf32=Int32Array,e.assign(e,a)):(e.Buf8=Array,e.Buf16=Array,e.Buf32=Array,e.assign(e,r))},e.setTyped(i)})(re);var qe={},ie={},Ze={},Ra=re,Ba=4,jt=0,Vt=1,Ca=2;function Ie(e){for(var i=e.length;--i>=0;)e[i]=0}var Ua=0,Ki=1,$a=2,Ma=3,Ha=258,$t=29,Ge=256,He=Ge+1+$t,Ne=30,Mt=19,Yi=2*He+1,se=15,bt=16,Pa=7,Ht=256,Xi=16,qi=17,Gi=18,Ot=[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],ft=[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],Ka=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],Wi=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],Ya=512,ne=new Array((He+2)*2);Ie(ne);var Be=new Array(Ne*2);Ie(Be);var Pe=new Array(Ya);Ie(Pe);var Ke=new Array(Ha-Ma+1);Ie(Ke);var Pt=new Array($t);Ie(Pt);var ut=new Array(Ne);Ie(ut);function pt(e,i,t,a,r){this.static_tree=e,this.extra_bits=i,this.extra_base=t,this.elems=a,this.max_length=r,this.has_stree=e&&e.length}var ji,Vi,Ji;function xt(e,i){this.dyn_tree=e,this.max_code=0,this.stat_desc=i}function Qi(e){return e<256?Pe[e]:Pe[256+(e>>>7)]}function Ye(e,i){e.pending_buf[e.pending++]=i&255,e.pending_buf[e.pending++]=i>>>8&255}function C(e,i,t){e.bi_valid>bt-t?(e.bi_buf|=i<<e.bi_valid&65535,Ye(e,e.bi_buf),e.bi_buf=i>>bt-e.bi_valid,e.bi_valid+=t-bt):(e.bi_buf|=i<<e.bi_valid&65535,e.bi_valid+=t)}function ee(e,i,t){C(e,t[i*2],t[i*2+1])}function ea(e,i){var t=0;do t|=e&1,e>>>=1,t<<=1;while(--i>0);return t>>>1}function Xa(e){e.bi_valid===16?(Ye(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 qa(e,i){var t=i.dyn_tree,a=i.max_code,r=i.stat_desc.static_tree,n=i.stat_desc.has_stree,h=i.stat_desc.extra_bits,f=i.stat_desc.extra_base,_=i.stat_desc.max_length,l,o,v,d,u,g,w=0;for(d=0;d<=se;d++)e.bl_count[d]=0;for(t[e.heap[e.heap_max]*2+1]=0,l=e.heap_max+1;l<Yi;l++)o=e.heap[l],d=t[t[o*2+1]*2+1]+1,d>_&&(d=_,w++),t[o*2+1]=d,!(o>a)&&(e.bl_count[d]++,u=0,o>=f&&(u=h[o-f]),g=t[o*2],e.opt_len+=g*(d+u),n&&(e.static_len+=g*(r[o*2+1]+u)));if(w!==0){do{for(d=_-1;e.bl_count[d]===0;)d--;e.bl_count[d]--,e.bl_count[d+1]+=2,e.bl_count[_]--,w-=2}while(w>0);for(d=_;d!==0;d--)for(o=e.bl_count[d];o!==0;)v=e.heap[--l],!(v>a)&&(t[v*2+1]!==d&&(e.opt_len+=(d-t[v*2+1])*t[v*2],t[v*2+1]=d),o--)}}function ta(e,i,t){var a=new Array(se+1),r=0,n,h;for(n=1;n<=se;n++)a[n]=r=r+t[n-1]<<1;for(h=0;h<=i;h++){var f=e[h*2+1];f!==0&&(e[h*2]=ea(a[f]++,f))}}function Ga(){var e,i,t,a,r,n=new Array(se+1);for(t=0,a=0;a<$t-1;a++)for(Pt[a]=t,e=0;e<1<<Ot[a];e++)Ke[t++]=a;for(Ke[t-1]=a,r=0,a=0;a<16;a++)for(ut[a]=r,e=0;e<1<<ft[a];e++)Pe[r++]=a;for(r>>=7;a<Ne;a++)for(ut[a]=r<<7,e=0;e<1<<ft[a]-7;e++)Pe[256+r++]=a;for(i=0;i<=se;i++)n[i]=0;for(e=0;e<=143;)ne[e*2+1]=8,e++,n[8]++;for(;e<=255;)ne[e*2+1]=9,e++,n[9]++;for(;e<=279;)ne[e*2+1]=7,e++,n[7]++;for(;e<=287;)ne[e*2+1]=8,e++,n[8]++;for(ta(ne,He+1,n),e=0;e<Ne;e++)Be[e*2+1]=5,Be[e*2]=ea(e,5);ji=new pt(ne,Ot,Ge+1,He,se),Vi=new pt(Be,ft,0,Ne,se),Ji=new pt(new Array(0),Ka,0,Mt,Pa)}function ia(e){var i;for(i=0;i<He;i++)e.dyn_ltree[i*2]=0;for(i=0;i<Ne;i++)e.dyn_dtree[i*2]=0;for(i=0;i<Mt;i++)e.bl_tree[i*2]=0;e.dyn_ltree[Ht*2]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0}function aa(e){e.bi_valid>8?Ye(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 Wa(e,i,t,a){aa(e),a&&(Ye(e,t),Ye(e,~t)),Ra.arraySet(e.pending_buf,e.window,i,t,e.pending),e.pending+=t}function Jt(e,i,t,a){var r=i*2,n=t*2;return e[r]<e[n]||e[r]===e[n]&&a[i]<=a[t]}function kt(e,i,t){for(var a=e.heap[t],r=t<<1;r<=e.heap_len&&(r<e.heap_len&&Jt(i,e.heap[r+1],e.heap[r],e.depth)&&r++,!Jt(i,a,e.heap[r],e.depth));)e.heap[t]=e.heap[r],t=r,r<<=1;e.heap[t]=a}function Qt(e,i,t){var a,r,n=0,h,f;if(e.last_lit!==0)do a=e.pending_buf[e.d_buf+n*2]<<8|e.pending_buf[e.d_buf+n*2+1],r=e.pending_buf[e.l_buf+n],n++,a===0?ee(e,r,i):(h=Ke[r],ee(e,h+Ge+1,i),f=Ot[h],f!==0&&(r-=Pt[h],C(e,r,f)),a--,h=Qi(a),ee(e,h,t),f=ft[h],f!==0&&(a-=ut[h],C(e,a,f)));while(n<e.last_lit);ee(e,Ht,i)}function Zt(e,i){var t=i.dyn_tree,a=i.stat_desc.static_tree,r=i.stat_desc.has_stree,n=i.stat_desc.elems,h,f,_=-1,l;for(e.heap_len=0,e.heap_max=Yi,h=0;h<n;h++)t[h*2]!==0?(e.heap[++e.heap_len]=_=h,e.depth[h]=0):t[h*2+1]=0;for(;e.heap_len<2;)l=e.heap[++e.heap_len]=_<2?++_:0,t[l*2]=1,e.depth[l]=0,e.opt_len--,r&&(e.static_len-=a[l*2+1]);for(i.max_code=_,h=e.heap_len>>1;h>=1;h--)kt(e,t,h);l=n;do h=e.heap[1],e.heap[1]=e.heap[e.heap_len--],kt(e,t,1),f=e.heap[1],e.heap[--e.heap_max]=h,e.heap[--e.heap_max]=f,t[l*2]=t[h*2]+t[f*2],e.depth[l]=(e.depth[h]>=e.depth[f]?e.depth[h]:e.depth[f])+1,t[h*2+1]=t[f*2+1]=l,e.heap[1]=l++,kt(e,t,1);while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],qa(e,i),ta(t,_,e.bl_count)}function ei(e,i,t){var a,r=-1,n,h=i[0*2+1],f=0,_=7,l=4;for(h===0&&(_=138,l=3),i[(t+1)*2+1]=65535,a=0;a<=t;a++)n=h,h=i[(a+1)*2+1],!(++f<_&&n===h)&&(f<l?e.bl_tree[n*2]+=f:n!==0?(n!==r&&e.bl_tree[n*2]++,e.bl_tree[Xi*2]++):f<=10?e.bl_tree[qi*2]++:e.bl_tree[Gi*2]++,f=0,r=n,h===0?(_=138,l=3):n===h?(_=6,l=3):(_=7,l=4))}function ti(e,i,t){var a,r=-1,n,h=i[0*2+1],f=0,_=7,l=4;for(h===0&&(_=138,l=3),a=0;a<=t;a++)if(n=h,h=i[(a+1)*2+1],!(++f<_&&n===h)){if(f<l)do ee(e,n,e.bl_tree);while(--f!==0);else n!==0?(n!==r&&(ee(e,n,e.bl_tree),f--),ee(e,Xi,e.bl_tree),C(e,f-3,2)):f<=10?(ee(e,qi,e.bl_tree),C(e,f-3,3)):(ee(e,Gi,e.bl_tree),C(e,f-11,7));f=0,r=n,h===0?(_=138,l=3):n===h?(_=6,l=3):(_=7,l=4)}}function ja(e){var i;for(ei(e,e.dyn_ltree,e.l_desc.max_code),ei(e,e.dyn_dtree,e.d_desc.max_code),Zt(e,e.bl_desc),i=Mt-1;i>=3&&e.bl_tree[Wi[i]*2+1]===0;i--);return e.opt_len+=3*(i+1)+5+5+4,i}function Va(e,i,t,a){var r;for(C(e,i-257,5),C(e,t-1,5),C(e,a-4,4),r=0;r<a;r++)C(e,e.bl_tree[Wi[r]*2+1],3);ti(e,e.dyn_ltree,i-1),ti(e,e.dyn_dtree,t-1)}function Ja(e){var i=4093624447,t;for(t=0;t<=31;t++,i>>>=1)if(i&1&&e.dyn_ltree[t*2]!==0)return jt;if(e.dyn_ltree[9*2]!==0||e.dyn_ltree[10*2]!==0||e.dyn_ltree[13*2]!==0)return Vt;for(t=32;t<Ge;t++)if(e.dyn_ltree[t*2]!==0)return Vt;return jt}var ii=!1;function Qa(e){ii||(Ga(),ii=!0),e.l_desc=new xt(e.dyn_ltree,ji),e.d_desc=new xt(e.dyn_dtree,Vi),e.bl_desc=new xt(e.bl_tree,Ji),e.bi_buf=0,e.bi_valid=0,ia(e)}function na(e,i,t,a){C(e,(Ua<<1)+(a?1:0),3),Wa(e,i,t,!0)}function en(e){C(e,Ki<<1,3),ee(e,Ht,ne),Xa(e)}function tn(e,i,t,a){var r,n,h=0;e.level>0?(e.strm.data_type===Ca&&(e.strm.data_type=Ja(e)),Zt(e,e.l_desc),Zt(e,e.d_desc),h=ja(e),r=e.opt_len+3+7>>>3,n=e.static_len+3+7>>>3,n<=r&&(r=n)):r=n=t+5,t+4<=r&&i!==-1?na(e,i,t,a):e.strategy===Ba||n===r?(C(e,(Ki<<1)+(a?1:0),3),Qt(e,ne,Be)):(C(e,($a<<1)+(a?1:0),3),Va(e,e.l_desc.max_code+1,e.d_desc.max_code+1,h+1),Qt(e,e.dyn_ltree,e.dyn_dtree)),ia(e),a&&aa(e)}function an(e,i,t){return e.pending_buf[e.d_buf+e.last_lit*2]=i>>>8&255,e.pending_buf[e.d_buf+e.last_lit*2+1]=i&255,e.pending_buf[e.l_buf+e.last_lit]=t&255,e.last_lit++,i===0?e.dyn_ltree[t*2]++:(e.matches++,i--,e.dyn_ltree[(Ke[t]+Ge+1)*2]++,e.dyn_dtree[Qi(i)*2]++),e.last_lit===e.lit_bufsize-1}Ze._tr_init=Qa;Ze._tr_stored_block=na;Ze._tr_flush_block=tn;Ze._tr_tally=an;Ze._tr_align=en;function nn(e,i,t,a){for(var r=e&65535|0,n=e>>>16&65535|0,h=0;t!==0;){h=t>2e3?2e3:t,t-=h;do r=r+i[a++]|0,n=n+r|0;while(--h);r%=65521,n%=65521}return r|n<<16|0}var ra=nn;function rn(){for(var e,i=[],t=0;t<256;t++){e=t;for(var a=0;a<8;a++)e=e&1?3988292384^e>>>1:e>>>1;i[t]=e}return i}var fn=rn();function hn(e,i,t,a){var r=fn,n=a+t;e^=-1;for(var h=a;h<n;h++)e=e>>>8^r[(e^i[h])&255];return e^-1}var fa=hn,Kt={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"},B=re,Y=Ze,ha=ra,he=fa,ln=Kt,ke=0,on=1,_n=3,de=4,ai=5,te=0,ni=1,X=-2,un=-3,Et=-5,dn=-1,sn=1,tt=2,cn=3,vn=4,gn=0,wn=2,vt=8,bn=9,pn=15,xn=8,kn=29,En=256,It=En+1+kn,Sn=30,yn=19,mn=2*It+1,Fn=15,S=3,_e=258,W=_e+S+1,Tn=32,gt=42,Lt=69,ht=73,lt=91,ot=103,ce=113,Re=666,D=1,We=2,ge=3,Le=4,Nn=3;function ue(e,i){return e.msg=ln[i],i}function ri(e){return(e<<1)-(e>4?9:0)}function oe(e){for(var i=e.length;--i>=0;)e[i]=0}function le(e){var i=e.state,t=i.pending;t>e.avail_out&&(t=e.avail_out),t!==0&&(B.arraySet(e.output,i.pending_buf,i.pending_out,t,e.next_out),e.next_out+=t,i.pending_out+=t,e.total_out+=t,e.avail_out-=t,i.pending-=t,i.pending===0&&(i.pending_out=0))}function R(e,i){Y._tr_flush_block(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,i),e.block_start=e.strstart,le(e.strm)}function F(e,i){e.pending_buf[e.pending++]=i}function De(e,i){e.pending_buf[e.pending++]=i>>>8&255,e.pending_buf[e.pending++]=i&255}function zn(e,i,t,a){var r=e.avail_in;return r>a&&(r=a),r===0?0:(e.avail_in-=r,B.arraySet(i,e.input,e.next_in,r,t),e.state.wrap===1?e.adler=ha(e.adler,i,r,t):e.state.wrap===2&&(e.adler=he(e.adler,i,r,t)),e.next_in+=r,e.total_in+=r,r)}function la(e,i){var t=e.max_chain_length,a=e.strstart,r,n,h=e.prev_length,f=e.nice_match,_=e.strstart>e.w_size-W?e.strstart-(e.w_size-W):0,l=e.window,o=e.w_mask,v=e.prev,d=e.strstart+_e,u=l[a+h-1],g=l[a+h];e.prev_length>=e.good_match&&(t>>=2),f>e.lookahead&&(f=e.lookahead);do if(r=i,!(l[r+h]!==g||l[r+h-1]!==u||l[r]!==l[a]||l[++r]!==l[a+1])){a+=2,r++;do;while(l[++a]===l[++r]&&l[++a]===l[++r]&&l[++a]===l[++r]&&l[++a]===l[++r]&&l[++a]===l[++r]&&l[++a]===l[++r]&&l[++a]===l[++r]&&l[++a]===l[++r]&&a<d);if(n=_e-(d-a),a=d-_e,n>h){if(e.match_start=i,h=n,n>=f)break;u=l[a+h-1],g=l[a+h]}}while((i=v[i&o])>_&&--t!==0);return h<=e.lookahead?h:e.lookahead}function we(e){var i=e.w_size,t,a,r,n,h;do{if(n=e.window_size-e.lookahead-e.strstart,e.strstart>=i+(i-W)){B.arraySet(e.window,e.window,i,i,0),e.match_start-=i,e.strstart-=i,e.block_start-=i,a=e.hash_size,t=a;do r=e.head[--t],e.head[t]=r>=i?r-i:0;while(--a);a=i,t=a;do r=e.prev[--t],e.prev[t]=r>=i?r-i:0;while(--a);n+=i}if(e.strm.avail_in===0)break;if(a=zn(e.strm,e.window,e.strstart+e.lookahead,n),e.lookahead+=a,e.lookahead+e.insert>=S)for(h=e.strstart-e.insert,e.ins_h=e.window[h],e.ins_h=(e.ins_h<<e.hash_shift^e.window[h+1])&e.hash_mask;e.insert&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[h+S-1])&e.hash_mask,e.prev[h&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=h,h++,e.insert--,!(e.lookahead+e.insert<S)););}while(e.lookahead<W&&e.strm.avail_in!==0)}function An(e,i){var t=65535;for(t>e.pending_buf_size-5&&(t=e.pending_buf_size-5);;){if(e.lookahead<=1){if(we(e),e.lookahead===0&&i===ke)return D;if(e.lookahead===0)break}e.strstart+=e.lookahead,e.lookahead=0;var a=e.block_start+t;if((e.strstart===0||e.strstart>=a)&&(e.lookahead=e.strstart-a,e.strstart=a,R(e,!1),e.strm.avail_out===0)||e.strstart-e.block_start>=e.w_size-W&&(R(e,!1),e.strm.avail_out===0))return D}return e.insert=0,i===de?(R(e,!0),e.strm.avail_out===0?ge:Le):(e.strstart>e.block_start&&(R(e,!1),e.strm.avail_out===0),D)}function St(e,i){for(var t,a;;){if(e.lookahead<W){if(we(e),e.lookahead<W&&i===ke)return D;if(e.lookahead===0)break}if(t=0,e.lookahead>=S&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+S-1])&e.hash_mask,t=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),t!==0&&e.strstart-t<=e.w_size-W&&(e.match_length=la(e,t)),e.match_length>=S)if(a=Y._tr_tally(e,e.strstart-e.match_start,e.match_length-S),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=S){e.match_length--;do e.strstart++,e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+S-1])&e.hash_mask,t=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 a=Y._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(a&&(R(e,!1),e.strm.avail_out===0))return D}return e.insert=e.strstart<S-1?e.strstart:S-1,i===de?(R(e,!0),e.strm.avail_out===0?ge:Le):e.last_lit&&(R(e,!1),e.strm.avail_out===0)?D:We}function ye(e,i){for(var t,a,r;;){if(e.lookahead<W){if(we(e),e.lookahead<W&&i===ke)return D;if(e.lookahead===0)break}if(t=0,e.lookahead>=S&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+S-1])&e.hash_mask,t=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=S-1,t!==0&&e.prev_length<e.max_lazy_match&&e.strstart-t<=e.w_size-W&&(e.match_length=la(e,t),e.match_length<=5&&(e.strategy===sn||e.match_length===S&&e.strstart-e.match_start>4096)&&(e.match_length=S-1)),e.prev_length>=S&&e.match_length<=e.prev_length){r=e.strstart+e.lookahead-S,a=Y._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-S),e.lookahead-=e.prev_length-1,e.prev_length-=2;do++e.strstart<=r&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+S-1])&e.hash_mask,t=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=S-1,e.strstart++,a&&(R(e,!1),e.strm.avail_out===0))return D}else if(e.match_available){if(a=Y._tr_tally(e,0,e.window[e.strstart-1]),a&&R(e,!1),e.strstart++,e.lookahead--,e.strm.avail_out===0)return D}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(a=Y._tr_tally(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<S-1?e.strstart:S-1,i===de?(R(e,!0),e.strm.avail_out===0?ge:Le):e.last_lit&&(R(e,!1),e.strm.avail_out===0)?D:We}function On(e,i){for(var t,a,r,n,h=e.window;;){if(e.lookahead<=_e){if(we(e),e.lookahead<=_e&&i===ke)return D;if(e.lookahead===0)break}if(e.match_length=0,e.lookahead>=S&&e.strstart>0&&(r=e.strstart-1,a=h[r],a===h[++r]&&a===h[++r]&&a===h[++r])){n=e.strstart+_e;do;while(a===h[++r]&&a===h[++r]&&a===h[++r]&&a===h[++r]&&a===h[++r]&&a===h[++r]&&a===h[++r]&&a===h[++r]&&r<n);e.match_length=_e-(n-r),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=S?(t=Y._tr_tally(e,1,e.match_length-S),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(t=Y._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),t&&(R(e,!1),e.strm.avail_out===0))return D}return e.insert=0,i===de?(R(e,!0),e.strm.avail_out===0?ge:Le):e.last_lit&&(R(e,!1),e.strm.avail_out===0)?D:We}function Zn(e,i){for(var t;;){if(e.lookahead===0&&(we(e),e.lookahead===0)){if(i===ke)return D;break}if(e.match_length=0,t=Y._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,t&&(R(e,!1),e.strm.avail_out===0))return D}return e.insert=0,i===de?(R(e,!0),e.strm.avail_out===0?ge:Le):e.last_lit&&(R(e,!1),e.strm.avail_out===0)?D:We}function J(e,i,t,a,r){this.good_length=e,this.max_lazy=i,this.nice_length=t,this.max_chain=a,this.func=r}var Fe;Fe=[new J(0,0,0,0,An),new J(4,4,8,4,St),new J(4,5,16,8,St),new J(4,6,32,32,St),new J(4,4,16,16,ye),new J(8,16,32,32,ye),new J(8,16,128,128,ye),new J(8,32,128,256,ye),new J(32,128,258,1024,ye),new J(32,258,258,4096,ye)];function In(e){e.window_size=2*e.w_size,oe(e.head),e.max_lazy_match=Fe[e.level].max_lazy,e.good_match=Fe[e.level].good_length,e.nice_match=Fe[e.level].nice_length,e.max_chain_length=Fe[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=S-1,e.match_available=0,e.ins_h=0}function Ln(){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=vt,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 B.Buf16(mn*2),this.dyn_dtree=new B.Buf16((2*Sn+1)*2),this.bl_tree=new B.Buf16((2*yn+1)*2),oe(this.dyn_ltree),oe(this.dyn_dtree),oe(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new B.Buf16(Fn+1),this.heap=new B.Buf16(2*It+1),oe(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new B.Buf16(2*It+1),oe(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 oa(e){var i;return!e||!e.state?ue(e,X):(e.total_in=e.total_out=0,e.data_type=wn,i=e.state,i.pending=0,i.pending_out=0,i.wrap<0&&(i.wrap=-i.wrap),i.status=i.wrap?gt:ce,e.adler=i.wrap===2?0:1,i.last_flush=ke,Y._tr_init(i),te)}function _a(e){var i=oa(e);return i===te&&In(e.state),i}function Dn(e,i){return!e||!e.state||e.state.wrap!==2?X:(e.state.gzhead=i,te)}function ua(e,i,t,a,r,n){if(!e)return X;var h=1;if(i===dn&&(i=6),a<0?(h=0,a=-a):a>15&&(h=2,a-=16),r<1||r>bn||t!==vt||a<8||a>15||i<0||i>9||n<0||n>vn)return ue(e,X);a===8&&(a=9);var f=new Ln;return e.state=f,f.strm=e,f.wrap=h,f.gzhead=null,f.w_bits=a,f.w_size=1<<f.w_bits,f.w_mask=f.w_size-1,f.hash_bits=r+7,f.hash_size=1<<f.hash_bits,f.hash_mask=f.hash_size-1,f.hash_shift=~~((f.hash_bits+S-1)/S),f.window=new B.Buf8(f.w_size*2),f.head=new B.Buf16(f.hash_size),f.prev=new B.Buf16(f.w_size),f.lit_bufsize=1<<r+6,f.pending_buf_size=f.lit_bufsize*4,f.pending_buf=new B.Buf8(f.pending_buf_size),f.d_buf=1*f.lit_bufsize,f.l_buf=(1+2)*f.lit_bufsize,f.level=i,f.strategy=n,f.method=t,_a(e)}function Rn(e,i){return ua(e,i,vt,pn,xn,gn)}function Bn(e,i){var t,a,r,n;if(!e||!e.state||i>ai||i<0)return e?ue(e,X):X;if(a=e.state,!e.output||!e.input&&e.avail_in!==0||a.status===Re&&i!==de)return ue(e,e.avail_out===0?Et:X);if(a.strm=e,t=a.last_flush,a.last_flush=i,a.status===gt)if(a.wrap===2)e.adler=0,F(a,31),F(a,139),F(a,8),a.gzhead?(F(a,(a.gzhead.text?1:0)+(a.gzhead.hcrc?2:0)+(a.gzhead.extra?4:0)+(a.gzhead.name?8:0)+(a.gzhead.comment?16:0)),F(a,a.gzhead.time&255),F(a,a.gzhead.time>>8&255),F(a,a.gzhead.time>>16&255),F(a,a.gzhead.time>>24&255),F(a,a.level===9?2:a.strategy>=tt||a.level<2?4:0),F(a,a.gzhead.os&255),a.gzhead.extra&&a.gzhead.extra.length&&(F(a,a.gzhead.extra.length&255),F(a,a.gzhead.extra.length>>8&255)),a.gzhead.hcrc&&(e.adler=he(e.adler,a.pending_buf,a.pending,0)),a.gzindex=0,a.status=Lt):(F(a,0),F(a,0),F(a,0),F(a,0),F(a,0),F(a,a.level===9?2:a.strategy>=tt||a.level<2?4:0),F(a,Nn),a.status=ce);else{var h=vt+(a.w_bits-8<<4)<<8,f=-1;a.strategy>=tt||a.level<2?f=0:a.level<6?f=1:a.level===6?f=2:f=3,h|=f<<6,a.strstart!==0&&(h|=Tn),h+=31-h%31,a.status=ce,De(a,h),a.strstart!==0&&(De(a,e.adler>>>16),De(a,e.adler&65535)),e.adler=1}if(a.status===Lt)if(a.gzhead.extra){for(r=a.pending;a.gzindex<(a.gzhead.extra.length&65535)&&!(a.pending===a.pending_buf_size&&(a.gzhead.hcrc&&a.pending>r&&(e.adler=he(e.adler,a.pending_buf,a.pending-r,r)),le(e),r=a.pending,a.pending===a.pending_buf_size));)F(a,a.gzhead.extra[a.gzindex]&255),a.gzindex++;a.gzhead.hcrc&&a.pending>r&&(e.adler=he(e.adler,a.pending_buf,a.pending-r,r)),a.gzindex===a.gzhead.extra.length&&(a.gzindex=0,a.status=ht)}else a.status=ht;if(a.status===ht)if(a.gzhead.name){r=a.pending;do{if(a.pending===a.pending_buf_size&&(a.gzhead.hcrc&&a.pending>r&&(e.adler=he(e.adler,a.pending_buf,a.pending-r,r)),le(e),r=a.pending,a.pending===a.pending_buf_size)){n=1;break}a.gzindex<a.gzhead.name.length?n=a.gzhead.name.charCodeAt(a.gzindex++)&255:n=0,F(a,n)}while(n!==0);a.gzhead.hcrc&&a.pending>r&&(e.adler=he(e.adler,a.pending_buf,a.pending-r,r)),n===0&&(a.gzindex=0,a.status=lt)}else a.status=lt;if(a.status===lt)if(a.gzhead.comment){r=a.pending;do{if(a.pending===a.pending_buf_size&&(a.gzhead.hcrc&&a.pending>r&&(e.adler=he(e.adler,a.pending_buf,a.pending-r,r)),le(e),r=a.pending,a.pending===a.pending_buf_size)){n=1;break}a.gzindex<a.gzhead.comment.length?n=a.gzhead.comment.charCodeAt(a.gzindex++)&255:n=0,F(a,n)}while(n!==0);a.gzhead.hcrc&&a.pending>r&&(e.adler=he(e.adler,a.pending_buf,a.pending-r,r)),n===0&&(a.status=ot)}else a.status=ot;if(a.status===ot&&(a.gzhead.hcrc?(a.pending+2>a.pending_buf_size&&le(e),a.pending+2<=a.pending_buf_size&&(F(a,e.adler&255),F(a,e.adler>>8&255),e.adler=0,a.status=ce)):a.status=ce),a.pending!==0){if(le(e),e.avail_out===0)return a.last_flush=-1,te}else if(e.avail_in===0&&ri(i)<=ri(t)&&i!==de)return ue(e,Et);if(a.status===Re&&e.avail_in!==0)return ue(e,Et);if(e.avail_in!==0||a.lookahead!==0||i!==ke&&a.status!==Re){var _=a.strategy===tt?Zn(a,i):a.strategy===cn?On(a,i):Fe[a.level].func(a,i);if((_===ge||_===Le)&&(a.status=Re),_===D||_===ge)return e.avail_out===0&&(a.last_flush=-1),te;if(_===We&&(i===on?Y._tr_align(a):i!==ai&&(Y._tr_stored_block(a,0,0,!1),i===_n&&(oe(a.head),a.lookahead===0&&(a.strstart=0,a.block_start=0,a.insert=0))),le(e),e.avail_out===0))return a.last_flush=-1,te}return i!==de?te:a.wrap<=0?ni:(a.wrap===2?(F(a,e.adler&255),F(a,e.adler>>8&255),F(a,e.adler>>16&255),F(a,e.adler>>24&255),F(a,e.total_in&255),F(a,e.total_in>>8&255),F(a,e.total_in>>16&255),F(a,e.total_in>>24&255)):(De(a,e.adler>>>16),De(a,e.adler&65535)),le(e),a.wrap>0&&(a.wrap=-a.wrap),a.pending!==0?te:ni)}function Cn(e){var i;return!e||!e.state?X:(i=e.state.status,i!==gt&&i!==Lt&&i!==ht&&i!==lt&&i!==ot&&i!==ce&&i!==Re?ue(e,X):(e.state=null,i===ce?ue(e,un):te))}function Un(e,i){var t=i.length,a,r,n,h,f,_,l,o;if(!e||!e.state||(a=e.state,h=a.wrap,h===2||h===1&&a.status!==gt||a.lookahead))return X;for(h===1&&(e.adler=ha(e.adler,i,t,0)),a.wrap=0,t>=a.w_size&&(h===0&&(oe(a.head),a.strstart=0,a.block_start=0,a.insert=0),o=new B.Buf8(a.w_size),B.arraySet(o,i,t-a.w_size,a.w_size,0),i=o,t=a.w_size),f=e.avail_in,_=e.next_in,l=e.input,e.avail_in=t,e.next_in=0,e.input=i,we(a);a.lookahead>=S;){r=a.strstart,n=a.lookahead-(S-1);do a.ins_h=(a.ins_h<<a.hash_shift^a.window[r+S-1])&a.hash_mask,a.prev[r&a.w_mask]=a.head[a.ins_h],a.head[a.ins_h]=r,r++;while(--n);a.strstart=r,a.lookahead=S-1,we(a)}return a.strstart+=a.lookahead,a.block_start=a.strstart,a.insert=a.lookahead,a.lookahead=0,a.match_length=a.prev_length=S-1,a.match_available=0,e.next_in=_,e.input=l,e.avail_in=f,a.wrap=h,te}ie.deflateInit=Rn;ie.deflateInit2=ua;ie.deflateReset=_a;ie.deflateResetKeep=oa;ie.deflateSetHeader=Dn;ie.deflate=Bn;ie.deflateEnd=Cn;ie.deflateSetDictionary=Un;ie.deflateInfo="pako deflate (from Nodeca project)";var Ee={},wt=re,da=!0,sa=!0;try{String.fromCharCode.apply(null,[0])}catch{da=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{sa=!1}var Xe=new wt.Buf8(256);for(var fe=0;fe<256;fe++)Xe[fe]=fe>=252?6:fe>=248?5:fe>=240?4:fe>=224?3:fe>=192?2:1;Xe[254]=Xe[254]=1;Ee.string2buf=function(e){var i,t,a,r,n,h=e.length,f=0;for(r=0;r<h;r++)t=e.charCodeAt(r),(t&64512)===55296&&r+1<h&&(a=e.charCodeAt(r+1),(a&64512)===56320&&(t=65536+(t-55296<<10)+(a-56320),r++)),f+=t<128?1:t<2048?2:t<65536?3:4;for(i=new wt.Buf8(f),n=0,r=0;n<f;r++)t=e.charCodeAt(r),(t&64512)===55296&&r+1<h&&(a=e.charCodeAt(r+1),(a&64512)===56320&&(t=65536+(t-55296<<10)+(a-56320),r++)),t<128?i[n++]=t:t<2048?(i[n++]=192|t>>>6,i[n++]=128|t&63):t<65536?(i[n++]=224|t>>>12,i[n++]=128|t>>>6&63,i[n++]=128|t&63):(i[n++]=240|t>>>18,i[n++]=128|t>>>12&63,i[n++]=128|t>>>6&63,i[n++]=128|t&63);return i};function ca(e,i){if(i<65534&&(e.subarray&&sa||!e.subarray&&da))return String.fromCharCode.apply(null,wt.shrinkBuf(e,i));for(var t="",a=0;a<i;a++)t+=String.fromCharCode(e[a]);return t}Ee.buf2binstring=function(e){return ca(e,e.length)};Ee.binstring2buf=function(e){for(var i=new wt.Buf8(e.length),t=0,a=i.length;t<a;t++)i[t]=e.charCodeAt(t);return i};Ee.buf2string=function(e,i){var t,a,r,n,h=i||e.length,f=new Array(h*2);for(a=0,t=0;t<h;){if(r=e[t++],r<128){f[a++]=r;continue}if(n=Xe[r],n>4){f[a++]=65533,t+=n-1;continue}for(r&=n===2?31:n===3?15:7;n>1&&t<h;)r=r<<6|e[t++]&63,n--;if(n>1){f[a++]=65533;continue}r<65536?f[a++]=r:(r-=65536,f[a++]=55296|r>>10&1023,f[a++]=56320|r&1023)}return ca(f,a)};Ee.utf8border=function(e,i){var t;for(i=i||e.length,i>e.length&&(i=e.length),t=i-1;t>=0&&(e[t]&192)===128;)t--;return t<0||t===0?i:t+Xe[e[t]]>i?t:i};function $n(){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}var va=$n,Ce=ie,Ue=re,Dt=Ee,Rt=Kt,Mn=va,ga=Object.prototype.toString,Hn=0,yt=4,ze=0,fi=1,hi=2,Pn=-1,Kn=0,Yn=8;function be(e){if(!(this instanceof be))return new be(e);this.options=Ue.assign({level:Pn,method:Yn,chunkSize:16384,windowBits:15,memLevel:8,strategy:Kn,to:""},e||{});var i=this.options;i.raw&&i.windowBits>0?i.windowBits=-i.windowBits:i.gzip&&i.windowBits>0&&i.windowBits<16&&(i.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Mn,this.strm.avail_out=0;var t=Ce.deflateInit2(this.strm,i.level,i.method,i.windowBits,i.memLevel,i.strategy);if(t!==ze)throw new Error(Rt[t]);if(i.header&&Ce.deflateSetHeader(this.strm,i.header),i.dictionary){var a;if(typeof i.dictionary=="string"?a=Dt.string2buf(i.dictionary):ga.call(i.dictionary)==="[object ArrayBuffer]"?a=new Uint8Array(i.dictionary):a=i.dictionary,t=Ce.deflateSetDictionary(this.strm,a),t!==ze)throw new Error(Rt[t]);this._dict_set=!0}}be.prototype.push=function(e,i){var t=this.strm,a=this.options.chunkSize,r,n;if(this.ended)return!1;n=i===~~i?i:i===!0?yt:Hn,typeof e=="string"?t.input=Dt.string2buf(e):ga.call(e)==="[object ArrayBuffer]"?t.input=new Uint8Array(e):t.input=e,t.next_in=0,t.avail_in=t.input.length;do{if(t.avail_out===0&&(t.output=new Ue.Buf8(a),t.next_out=0,t.avail_out=a),r=Ce.deflate(t,n),r!==fi&&r!==ze)return this.onEnd(r),this.ended=!0,!1;(t.avail_out===0||t.avail_in===0&&(n===yt||n===hi))&&(this.options.to==="string"?this.onData(Dt.buf2binstring(Ue.shrinkBuf(t.output,t.next_out))):this.onData(Ue.shrinkBuf(t.output,t.next_out)))}while((t.avail_in>0||t.avail_out===0)&&r!==fi);return n===yt?(r=Ce.deflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===ze):(n===hi&&(this.onEnd(ze),t.avail_out=0),!0)};be.prototype.onData=function(e){this.chunks.push(e)};be.prototype.onEnd=function(e){e===ze&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=Ue.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function Yt(e,i){var t=new be(i);if(t.push(e,!0),t.err)throw t.msg||Rt[t.err];return t.result}function Xn(e,i){return i=i||{},i.raw=!0,Yt(e,i)}function qn(e,i){return i=i||{},i.gzip=!0,Yt(e,i)}qe.Deflate=be;qe.deflate=Yt;qe.deflateRaw=Xn;qe.gzip=qn;var je={},j={},it=30,Gn=12,Wn=function(i,t){var a,r,n,h,f,_,l,o,v,d,u,g,w,k,b,N,z,E,c,T,y,p,m,I,x;a=i.state,r=i.next_in,I=i.input,n=r+(i.avail_in-5),h=i.next_out,x=i.output,f=h-(t-i.avail_out),_=h+(i.avail_out-257),l=a.dmax,o=a.wsize,v=a.whave,d=a.wnext,u=a.window,g=a.hold,w=a.bits,k=a.lencode,b=a.distcode,N=(1<<a.lenbits)-1,z=(1<<a.distbits)-1;e:do{w<15&&(g+=I[r++]<<w,w+=8,g+=I[r++]<<w,w+=8),E=k[g&N];t:for(;;){if(c=E>>>24,g>>>=c,w-=c,c=E>>>16&255,c===0)x[h++]=E&65535;else if(c&16){T=E&65535,c&=15,c&&(w<c&&(g+=I[r++]<<w,w+=8),T+=g&(1<<c)-1,g>>>=c,w-=c),w<15&&(g+=I[r++]<<w,w+=8,g+=I[r++]<<w,w+=8),E=b[g&z];i:for(;;){if(c=E>>>24,g>>>=c,w-=c,c=E>>>16&255,c&16){if(y=E&65535,c&=15,w<c&&(g+=I[r++]<<w,w+=8,w<c&&(g+=I[r++]<<w,w+=8)),y+=g&(1<<c)-1,y>l){i.msg="invalid distance too far back",a.mode=it;break e}if(g>>>=c,w-=c,c=h-f,y>c){if(c=y-c,c>v&&a.sane){i.msg="invalid distance too far back",a.mode=it;break e}if(p=0,m=u,d===0){if(p+=o-c,c<T){T-=c;do x[h++]=u[p++];while(--c);p=h-y,m=x}}else if(d<c){if(p+=o+d-c,c-=d,c<T){T-=c;do x[h++]=u[p++];while(--c);if(p=0,d<T){c=d,T-=c;do x[h++]=u[p++];while(--c);p=h-y,m=x}}}else if(p+=d-c,c<T){T-=c;do x[h++]=u[p++];while(--c);p=h-y,m=x}for(;T>2;)x[h++]=m[p++],x[h++]=m[p++],x[h++]=m[p++],T-=3;T&&(x[h++]=m[p++],T>1&&(x[h++]=m[p++]))}else{p=h-y;do x[h++]=x[p++],x[h++]=x[p++],x[h++]=x[p++],T-=3;while(T>2);T&&(x[h++]=x[p++],T>1&&(x[h++]=x[p++]))}}else if(c&64){i.msg="invalid distance code",a.mode=it;break e}else{E=b[(E&65535)+(g&(1<<c)-1)];continue i}break}}else if(c&64)if(c&32){a.mode=Gn;break e}else{i.msg="invalid literal/length code",a.mode=it;break e}else{E=k[(E&65535)+(g&(1<<c)-1)];continue t}break}}while(r<n&&h<_);T=w>>3,r-=T,w-=T<<3,g&=(1<<w)-1,i.next_in=r,i.next_out=h,i.avail_in=r<n?5+(n-r):5-(r-n),i.avail_out=h<_?257+(_-h):257-(h-_),a.hold=g,a.bits=w},li=re,me=15,oi=852,_i=592,ui=0,mt=1,di=2,jn=[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],Vn=[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],Jn=[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],Qn=[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],er=function(i,t,a,r,n,h,f,_){var l=_.bits,o=0,v=0,d=0,u=0,g=0,w=0,k=0,b=0,N=0,z=0,E,c,T,y,p,m=null,I=0,x,G=new li.Buf16(me+1),Ve=new li.Buf16(me+1),Je=null,Gt=0,Wt,Qe,et;for(o=0;o<=me;o++)G[o]=0;for(v=0;v<r;v++)G[t[a+v]]++;for(g=l,u=me;u>=1&&G[u]===0;u--);if(g>u&&(g=u),u===0)return n[h++]=1<<24|64<<16|0,n[h++]=1<<24|64<<16|0,_.bits=1,0;for(d=1;d<u&&G[d]===0;d++);for(g<d&&(g=d),b=1,o=1;o<=me;o++)if(b<<=1,b-=G[o],b<0)return-1;if(b>0&&(i===ui||u!==1))return-1;for(Ve[1]=0,o=1;o<me;o++)Ve[o+1]=Ve[o]+G[o];for(v=0;v<r;v++)t[a+v]!==0&&(f[Ve[t[a+v]]++]=v);if(i===ui?(m=Je=f,x=19):i===mt?(m=jn,I-=257,Je=Vn,Gt-=257,x=256):(m=Jn,Je=Qn,x=-1),z=0,v=0,o=d,p=h,w=g,k=0,T=-1,N=1<<g,y=N-1,i===mt&&N>oi||i===di&&N>_i)return 1;for(;;){Wt=o-k,f[v]<x?(Qe=0,et=f[v]):f[v]>x?(Qe=Je[Gt+f[v]],et=m[I+f[v]]):(Qe=32+64,et=0),E=1<<o-k,c=1<<w,d=c;do c-=E,n[p+(z>>k)+c]=Wt<<24|Qe<<16|et|0;while(c!==0);for(E=1<<o-1;z&E;)E>>=1;if(E!==0?(z&=E-1,z+=E):z=0,v++,--G[o]===0){if(o===u)break;o=t[a+f[v]]}if(o>g&&(z&y)!==T){for(k===0&&(k=g),p+=d,w=o-k,b=1<<w;w+k<u&&(b-=G[w+k],!(b<=0));)w++,b<<=1;if(N+=1<<w,i===mt&&N>oi||i===di&&N>_i)return 1;T=z&y,n[T]=g<<24|w<<16|p-h|0}}return z!==0&&(n[p+z]=o-k<<24|64<<16|0),_.bits=g,0},M=re,Bt=ra,Q=fa,tr=Wn,$e=er,ir=0,wa=1,ba=2,si=4,ar=5,at=6,pe=0,nr=1,rr=2,q=-2,pa=-3,xa=-4,fr=-5,ci=8,ka=1,vi=2,gi=3,wi=4,bi=5,pi=6,xi=7,ki=8,Ei=9,Si=10,dt=11,ae=12,Ft=13,yi=14,Tt=15,mi=16,Fi=17,Ti=18,Ni=19,nt=20,rt=21,zi=22,Ai=23,Oi=24,Zi=25,Ii=26,Nt=27,Li=28,Di=29,Z=30,Ea=31,hr=32,lr=852,or=592,_r=15,ur=_r;function Ri(e){return(e>>>24&255)+(e>>>8&65280)+((e&65280)<<8)+((e&255)<<24)}function dr(){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 M.Buf16(320),this.work=new M.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function Sa(e){var i;return!e||!e.state?q:(i=e.state,e.total_in=e.total_out=i.total=0,e.msg="",i.wrap&&(e.adler=i.wrap&1),i.mode=ka,i.last=0,i.havedict=0,i.dmax=32768,i.head=null,i.hold=0,i.bits=0,i.lencode=i.lendyn=new M.Buf32(lr),i.distcode=i.distdyn=new M.Buf32(or),i.sane=1,i.back=-1,pe)}function ya(e){var i;return!e||!e.state?q:(i=e.state,i.wsize=0,i.whave=0,i.wnext=0,Sa(e))}function ma(e,i){var t,a;return!e||!e.state||(a=e.state,i<0?(t=0,i=-i):(t=(i>>4)+1,i<48&&(i&=15)),i&&(i<8||i>15))?q:(a.window!==null&&a.wbits!==i&&(a.window=null),a.wrap=t,a.wbits=i,ya(e))}function Fa(e,i){var t,a;return e?(a=new dr,e.state=a,a.window=null,t=ma(e,i),t!==pe&&(e.state=null),t):q}function sr(e){return Fa(e,ur)}var Bi=!0,zt,At;function cr(e){if(Bi){var i;for(zt=new M.Buf32(512),At=new M.Buf32(32),i=0;i<144;)e.lens[i++]=8;for(;i<256;)e.lens[i++]=9;for(;i<280;)e.lens[i++]=7;for(;i<288;)e.lens[i++]=8;for($e(wa,e.lens,0,288,zt,0,e.work,{bits:9}),i=0;i<32;)e.lens[i++]=5;$e(ba,e.lens,0,32,At,0,e.work,{bits:5}),Bi=!1}e.lencode=zt,e.lenbits=9,e.distcode=At,e.distbits=5}function Ta(e,i,t,a){var r,n=e.state;return n.window===null&&(n.wsize=1<<n.wbits,n.wnext=0,n.whave=0,n.window=new M.Buf8(n.wsize)),a>=n.wsize?(M.arraySet(n.window,i,t-n.wsize,n.wsize,0),n.wnext=0,n.whave=n.wsize):(r=n.wsize-n.wnext,r>a&&(r=a),M.arraySet(n.window,i,t-a,r,n.wnext),a-=r,a?(M.arraySet(n.window,i,t-a,a,0),n.wnext=a,n.whave=n.wsize):(n.wnext+=r,n.wnext===n.wsize&&(n.wnext=0),n.whave<n.wsize&&(n.whave+=r))),0}function vr(e,i){var t,a,r,n,h,f,_,l,o,v,d,u,g,w,k=0,b,N,z,E,c,T,y,p,m=new M.Buf8(4),I,x,G=[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 q;t=e.state,t.mode===ae&&(t.mode=Ft),h=e.next_out,r=e.output,_=e.avail_out,n=e.next_in,a=e.input,f=e.avail_in,l=t.hold,o=t.bits,v=f,d=_,p=pe;e:for(;;)switch(t.mode){case ka:if(t.wrap===0){t.mode=Ft;break}for(;o<16;){if(f===0)break e;f--,l+=a[n++]<<o,o+=8}if(t.wrap&2&&l===35615){t.check=0,m[0]=l&255,m[1]=l>>>8&255,t.check=Q(t.check,m,2,0),l=0,o=0,t.mode=vi;break}if(t.flags=0,t.head&&(t.head.done=!1),!(t.wrap&1)||(((l&255)<<8)+(l>>8))%31){e.msg="incorrect header check",t.mode=Z;break}if((l&15)!==ci){e.msg="unknown compression method",t.mode=Z;break}if(l>>>=4,o-=4,y=(l&15)+8,t.wbits===0)t.wbits=y;else if(y>t.wbits){e.msg="invalid window size",t.mode=Z;break}t.dmax=1<<y,e.adler=t.check=1,t.mode=l&512?Si:ae,l=0,o=0;break;case vi:for(;o<16;){if(f===0)break e;f--,l+=a[n++]<<o,o+=8}if(t.flags=l,(t.flags&255)!==ci){e.msg="unknown compression method",t.mode=Z;break}if(t.flags&57344){e.msg="unknown header flags set",t.mode=Z;break}t.head&&(t.head.text=l>>8&1),t.flags&512&&(m[0]=l&255,m[1]=l>>>8&255,t.check=Q(t.check,m,2,0)),l=0,o=0,t.mode=gi;case gi:for(;o<32;){if(f===0)break e;f--,l+=a[n++]<<o,o+=8}t.head&&(t.head.time=l),t.flags&512&&(m[0]=l&255,m[1]=l>>>8&255,m[2]=l>>>16&255,m[3]=l>>>24&255,t.check=Q(t.check,m,4,0)),l=0,o=0,t.mode=wi;case wi:for(;o<16;){if(f===0)break e;f--,l+=a[n++]<<o,o+=8}t.head&&(t.head.xflags=l&255,t.head.os=l>>8),t.flags&512&&(m[0]=l&255,m[1]=l>>>8&255,t.check=Q(t.check,m,2,0)),l=0,o=0,t.mode=bi;case bi:if(t.flags&1024){for(;o<16;){if(f===0)break e;f--,l+=a[n++]<<o,o+=8}t.length=l,t.head&&(t.head.extra_len=l),t.flags&512&&(m[0]=l&255,m[1]=l>>>8&255,t.check=Q(t.check,m,2,0)),l=0,o=0}else t.head&&(t.head.extra=null);t.mode=pi;case pi:if(t.flags&1024&&(u=t.length,u>f&&(u=f),u&&(t.head&&(y=t.head.extra_len-t.length,t.head.extra||(t.head.extra=new Array(t.head.extra_len)),M.arraySet(t.head.extra,a,n,u,y)),t.flags&512&&(t.check=Q(t.check,a,u,n)),f-=u,n+=u,t.length-=u),t.length))break e;t.length=0,t.mode=xi;case xi:if(t.flags&2048){if(f===0)break e;u=0;do y=a[n+u++],t.head&&y&&t.length<65536&&(t.head.name+=String.fromCharCode(y));while(y&&u<f);if(t.flags&512&&(t.check=Q(t.check,a,u,n)),f-=u,n+=u,y)break e}else t.head&&(t.head.name=null);t.length=0,t.mode=ki;case ki:if(t.flags&4096){if(f===0)break e;u=0;do y=a[n+u++],t.head&&y&&t.length<65536&&(t.head.comment+=String.fromCharCode(y));while(y&&u<f);if(t.flags&512&&(t.check=Q(t.check,a,u,n)),f-=u,n+=u,y)break e}else t.head&&(t.head.comment=null);t.mode=Ei;case Ei:if(t.flags&512){for(;o<16;){if(f===0)break e;f--,l+=a[n++]<<o,o+=8}if(l!==(t.check&65535)){e.msg="header crc mismatch",t.mode=Z;break}l=0,o=0}t.head&&(t.head.hcrc=t.flags>>9&1,t.head.done=!0),e.adler=t.check=0,t.mode=ae;break;case Si:for(;o<32;){if(f===0)break e;f--,l+=a[n++]<<o,o+=8}e.adler=t.check=Ri(l),l=0,o=0,t.mode=dt;case dt:if(t.havedict===0)return e.next_out=h,e.avail_out=_,e.next_in=n,e.avail_in=f,t.hold=l,t.bits=o,rr;e.adler=t.check=1,t.mode=ae;case ae:if(i===ar||i===at)break e;case Ft:if(t.last){l>>>=o&7,o-=o&7,t.mode=Nt;break}for(;o<3;){if(f===0)break e;f--,l+=a[n++]<<o,o+=8}switch(t.last=l&1,l>>>=1,o-=1,l&3){case 0:t.mode=yi;break;case 1:if(cr(t),t.mode=nt,i===at){l>>>=2,o-=2;break e}break;case 2:t.mode=Fi;break;case 3:e.msg="invalid block type",t.mode=Z}l>>>=2,o-=2;break;case yi:for(l>>>=o&7,o-=o&7;o<32;){if(f===0)break e;f--,l+=a[n++]<<o,o+=8}if((l&65535)!==(l>>>16^65535)){e.msg="invalid stored block lengths",t.mode=Z;break}if(t.length=l&65535,l=0,o=0,t.mode=Tt,i===at)break e;case Tt:t.mode=mi;case mi:if(u=t.length,u){if(u>f&&(u=f),u>_&&(u=_),u===0)break e;M.arraySet(r,a,n,u,h),f-=u,n+=u,_-=u,h+=u,t.length-=u;break}t.mode=ae;break;case Fi:for(;o<14;){if(f===0)break e;f--,l+=a[n++]<<o,o+=8}if(t.nlen=(l&31)+257,l>>>=5,o-=5,t.ndist=(l&31)+1,l>>>=5,o-=5,t.ncode=(l&15)+4,l>>>=4,o-=4,t.nlen>286||t.ndist>30){e.msg="too many length or distance symbols",t.mode=Z;break}t.have=0,t.mode=Ti;case Ti:for(;t.have<t.ncode;){for(;o<3;){if(f===0)break e;f--,l+=a[n++]<<o,o+=8}t.lens[G[t.have++]]=l&7,l>>>=3,o-=3}for(;t.have<19;)t.lens[G[t.have++]]=0;if(t.lencode=t.lendyn,t.lenbits=7,I={bits:t.lenbits},p=$e(ir,t.lens,0,19,t.lencode,0,t.work,I),t.lenbits=I.bits,p){e.msg="invalid code lengths set",t.mode=Z;break}t.have=0,t.mode=Ni;case Ni:for(;t.have<t.nlen+t.ndist;){for(;k=t.lencode[l&(1<<t.lenbits)-1],b=k>>>24,N=k>>>16&255,z=k&65535,!(b<=o);){if(f===0)break e;f--,l+=a[n++]<<o,o+=8}if(z<16)l>>>=b,o-=b,t.lens[t.have++]=z;else{if(z===16){for(x=b+2;o<x;){if(f===0)break e;f--,l+=a[n++]<<o,o+=8}if(l>>>=b,o-=b,t.have===0){e.msg="invalid bit length repeat",t.mode=Z;break}y=t.lens[t.have-1],u=3+(l&3),l>>>=2,o-=2}else if(z===17){for(x=b+3;o<x;){if(f===0)break e;f--,l+=a[n++]<<o,o+=8}l>>>=b,o-=b,y=0,u=3+(l&7),l>>>=3,o-=3}else{for(x=b+7;o<x;){if(f===0)break e;f--,l+=a[n++]<<o,o+=8}l>>>=b,o-=b,y=0,u=11+(l&127),l>>>=7,o-=7}if(t.have+u>t.nlen+t.ndist){e.msg="invalid bit length repeat",t.mode=Z;break}for(;u--;)t.lens[t.have++]=y}}if(t.mode===Z)break;if(t.lens[256]===0){e.msg="invalid code -- missing end-of-block",t.mode=Z;break}if(t.lenbits=9,I={bits:t.lenbits},p=$e(wa,t.lens,0,t.nlen,t.lencode,0,t.work,I),t.lenbits=I.bits,p){e.msg="invalid literal/lengths set",t.mode=Z;break}if(t.distbits=6,t.distcode=t.distdyn,I={bits:t.distbits},p=$e(ba,t.lens,t.nlen,t.ndist,t.distcode,0,t.work,I),t.distbits=I.bits,p){e.msg="invalid distances set",t.mode=Z;break}if(t.mode=nt,i===at)break e;case nt:t.mode=rt;case rt:if(f>=6&&_>=258){e.next_out=h,e.avail_out=_,e.next_in=n,e.avail_in=f,t.hold=l,t.bits=o,tr(e,d),h=e.next_out,r=e.output,_=e.avail_out,n=e.next_in,a=e.input,f=e.avail_in,l=t.hold,o=t.bits,t.mode===ae&&(t.back=-1);break}for(t.back=0;k=t.lencode[l&(1<<t.lenbits)-1],b=k>>>24,N=k>>>16&255,z=k&65535,!(b<=o);){if(f===0)break e;f--,l+=a[n++]<<o,o+=8}if(N&&!(N&240)){for(E=b,c=N,T=z;k=t.lencode[T+((l&(1<<E+c)-1)>>E)],b=k>>>24,N=k>>>16&255,z=k&65535,!(E+b<=o);){if(f===0)break e;f--,l+=a[n++]<<o,o+=8}l>>>=E,o-=E,t.back+=E}if(l>>>=b,o-=b,t.back+=b,t.length=z,N===0){t.mode=Ii;break}if(N&32){t.back=-1,t.mode=ae;break}if(N&64){e.msg="invalid literal/length code",t.mode=Z;break}t.extra=N&15,t.mode=zi;case zi:if(t.extra){for(x=t.extra;o<x;){if(f===0)break e;f--,l+=a[n++]<<o,o+=8}t.length+=l&(1<<t.extra)-1,l>>>=t.extra,o-=t.extra,t.back+=t.extra}t.was=t.length,t.mode=Ai;case Ai:for(;k=t.distcode[l&(1<<t.distbits)-1],b=k>>>24,N=k>>>16&255,z=k&65535,!(b<=o);){if(f===0)break e;f--,l+=a[n++]<<o,o+=8}if(!(N&240)){for(E=b,c=N,T=z;k=t.distcode[T+((l&(1<<E+c)-1)>>E)],b=k>>>24,N=k>>>16&255,z=k&65535,!(E+b<=o);){if(f===0)break e;f--,l+=a[n++]<<o,o+=8}l>>>=E,o-=E,t.back+=E}if(l>>>=b,o-=b,t.back+=b,N&64){e.msg="invalid distance code",t.mode=Z;break}t.offset=z,t.extra=N&15,t.mode=Oi;case Oi:if(t.extra){for(x=t.extra;o<x;){if(f===0)break e;f--,l+=a[n++]<<o,o+=8}t.offset+=l&(1<<t.extra)-1,l>>>=t.extra,o-=t.extra,t.back+=t.extra}if(t.offset>t.dmax){e.msg="invalid distance too far back",t.mode=Z;break}t.mode=Zi;case Zi:if(_===0)break e;if(u=d-_,t.offset>u){if(u=t.offset-u,u>t.whave&&t.sane){e.msg="invalid distance too far back",t.mode=Z;break}u>t.wnext?(u-=t.wnext,g=t.wsize-u):g=t.wnext-u,u>t.length&&(u=t.length),w=t.window}else w=r,g=h-t.offset,u=t.length;u>_&&(u=_),_-=u,t.length-=u;do r[h++]=w[g++];while(--u);t.length===0&&(t.mode=rt);break;case Ii:if(_===0)break e;r[h++]=t.length,_--,t.mode=rt;break;case Nt:if(t.wrap){for(;o<32;){if(f===0)break e;f--,l|=a[n++]<<o,o+=8}if(d-=_,e.total_out+=d,t.total+=d,d&&(e.adler=t.check=t.flags?Q(t.check,r,d,h-d):Bt(t.check,r,d,h-d)),d=_,(t.flags?l:Ri(l))!==t.check){e.msg="incorrect data check",t.mode=Z;break}l=0,o=0}t.mode=Li;case Li:if(t.wrap&&t.flags){for(;o<32;){if(f===0)break e;f--,l+=a[n++]<<o,o+=8}if(l!==(t.total&4294967295)){e.msg="incorrect length check",t.mode=Z;break}l=0,o=0}t.mode=Di;case Di:p=nr;break e;case Z:p=pa;break e;case Ea:return xa;case hr:default:return q}return e.next_out=h,e.avail_out=_,e.next_in=n,e.avail_in=f,t.hold=l,t.bits=o,(t.wsize||d!==e.avail_out&&t.mode<Z&&(t.mode<Nt||i!==si))&&Ta(e,e.output,e.next_out,d-e.avail_out),v-=e.avail_in,d-=e.avail_out,e.total_in+=v,e.total_out+=d,t.total+=d,t.wrap&&d&&(e.adler=t.check=t.flags?Q(t.check,r,d,e.next_out-d):Bt(t.check,r,d,e.next_out-d)),e.data_type=t.bits+(t.last?64:0)+(t.mode===ae?128:0)+(t.mode===nt||t.mode===Tt?256:0),(v===0&&d===0||i===si)&&p===pe&&(p=fr),p}function gr(e){if(!e||!e.state)return q;var i=e.state;return i.window&&(i.window=null),e.state=null,pe}function wr(e,i){var t;return!e||!e.state||(t=e.state,!(t.wrap&2))?q:(t.head=i,i.done=!1,pe)}function br(e,i){var t=i.length,a,r,n;return!e||!e.state||(a=e.state,a.wrap!==0&&a.mode!==dt)?q:a.mode===dt&&(r=1,r=Bt(r,i,t,0),r!==a.check)?pa:(n=Ta(e,i,t,t),n?(a.mode=Ea,xa):(a.havedict=1,pe))}j.inflateReset=ya;j.inflateReset2=ma;j.inflateResetKeep=Sa;j.inflateInit=sr;j.inflateInit2=Fa;j.inflate=vr;j.inflateEnd=gr;j.inflateGetHeader=wr;j.inflateSetDictionary=br;j.inflateInfo="pako inflate (from Nodeca project)";var Na={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};function pr(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}var xr=pr,Ae=j,Me=re,_t=Ee,L=Na,Ct=Kt,kr=va,Er=xr,za=Object.prototype.toString;function xe(e){if(!(this instanceof xe))return new xe(e);this.options=Me.assign({chunkSize:16384,windowBits:0,to:""},e||{});var i=this.options;i.raw&&i.windowBits>=0&&i.windowBits<16&&(i.windowBits=-i.windowBits,i.windowBits===0&&(i.windowBits=-15)),i.windowBits>=0&&i.windowBits<16&&!(e&&e.windowBits)&&(i.windowBits+=32),i.windowBits>15&&i.windowBits<48&&(i.windowBits&15||(i.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new kr,this.strm.avail_out=0;var t=Ae.inflateInit2(this.strm,i.windowBits);if(t!==L.Z_OK)throw new Error(Ct[t]);if(this.header=new Er,Ae.inflateGetHeader(this.strm,this.header),i.dictionary&&(typeof i.dictionary=="string"?i.dictionary=_t.string2buf(i.dictionary):za.call(i.dictionary)==="[object ArrayBuffer]"&&(i.dictionary=new Uint8Array(i.dictionary)),i.raw&&(t=Ae.inflateSetDictionary(this.strm,i.dictionary),t!==L.Z_OK)))throw new Error(Ct[t])}xe.prototype.push=function(e,i){var t=this.strm,a=this.options.chunkSize,r=this.options.dictionary,n,h,f,_,l,o=!1;if(this.ended)return!1;h=i===~~i?i:i===!0?L.Z_FINISH:L.Z_NO_FLUSH,typeof e=="string"?t.input=_t.binstring2buf(e):za.call(e)==="[object ArrayBuffer]"?t.input=new Uint8Array(e):t.input=e,t.next_in=0,t.avail_in=t.input.length;do{if(t.avail_out===0&&(t.output=new Me.Buf8(a),t.next_out=0,t.avail_out=a),n=Ae.inflate(t,L.Z_NO_FLUSH),n===L.Z_NEED_DICT&&r&&(n=Ae.inflateSetDictionary(this.strm,r)),n===L.Z_BUF_ERROR&&o===!0&&(n=L.Z_OK,o=!1),n!==L.Z_STREAM_END&&n!==L.Z_OK)return this.onEnd(n),this.ended=!0,!1;t.next_out&&(t.avail_out===0||n===L.Z_STREAM_END||t.avail_in===0&&(h===L.Z_FINISH||h===L.Z_SYNC_FLUSH))&&(this.options.to==="string"?(f=_t.utf8border(t.output,t.next_out),_=t.next_out-f,l=_t.buf2string(t.output,f),t.next_out=_,t.avail_out=a-_,_&&Me.arraySet(t.output,t.output,f,_,0),this.onData(l)):this.onData(Me.shrinkBuf(t.output,t.next_out))),t.avail_in===0&&t.avail_out===0&&(o=!0)}while((t.avail_in>0||t.avail_out===0)&&n!==L.Z_STREAM_END);return n===L.Z_STREAM_END&&(h=L.Z_FINISH),h===L.Z_FINISH?(n=Ae.inflateEnd(this.strm),this.onEnd(n),this.ended=!0,n===L.Z_OK):(h===L.Z_SYNC_FLUSH&&(this.onEnd(L.Z_OK),t.avail_out=0),!0)};xe.prototype.onData=function(e){this.chunks.push(e)};xe.prototype.onEnd=function(e){e===L.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=Me.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function Xt(e,i){var t=new xe(i);if(t.push(e,!0),t.err)throw t.msg||Ct[t.err];return t.result}function Sr(e,i){return i=i||{},i.raw=!0,Xt(e,i)}je.Inflate=xe;je.inflate=Xt;je.inflateRaw=Sr;je.ungzip=Xt;var yr=re.assign,mr=qe,Fr=je,Tr=Na,Aa={};yr(Aa,mr,Fr,Tr);var st=Aa;async function Zr(e){try{let i,t=0,a=0;const r=[];let n=0,h;do{const _=e.subarray(t);if(h=new st.Inflate,{strm:i}=h,h.push(_,st.Z_SYNC_FLUSH),h.err)throw new Error(h.msg);t+=i.next_in,r[a]=h.result,n+=r[a].length,a+=1}while(i.avail_in);const f=new Uint8Array(n);for(let _=0,l=0;_<r.length;_++)f.set(r[_],l),l+=r[_].length;return Pi.Buffer.from(f)}catch(i){throw`${i}`.match(/incorrect header check/)?new Error("problem decompressing block: incorrect gzip header check"):i}}async function Ir(e,i){try{let t;const{minv:a,maxv:r}=i;let n=a.blockPosition,h=a.dataPosition;const f=[],_=[],l=[];let o=0,v=0;do{const g=e.subarray(n-a.blockPosition),w=new st.Inflate;if({strm:t}=w,w.push(g,st.Z_SYNC_FLUSH),w.err)throw new Error(w.msg);const k=w.result;f.push(k);let b=k.length;_.push(n),l.push(h),f.length===1&&a.dataPosition&&(f[0]=f[0].subarray(a.dataPosition),b=f[0].length);const N=n;if(n+=t.next_in,h+=b,N>=r.blockPosition){f[v]=f[v].subarray(0,r.blockPosition===a.blockPosition?r.dataPosition-a.dataPosition+1:r.dataPosition+1),_.push(n),l.push(h),o+=f[v].length;break}o+=f[v].length,v++}while(t.avail_in);const d=new Uint8Array(o);for(let g=0,w=0;g<f.length;g++)d.set(f[g],w),w+=f[g].length;return{buffer:Pi.Buffer.from(d),cpositions:_,dpositions:l}}catch(t){throw`${t}`.match(/incorrect header check/)?new Error("problem decompressing block: incorrect gzip header check"):t}}var Nr=A,H=null;try{H=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch{}function A(e,i,t){this.low=e|0,this.high=i|0,this.unsigned=!!t}A.prototype.__isLong__;Object.defineProperty(A.prototype,"__isLong__",{value:!0});function $(e){return(e&&e.__isLong__)===!0}A.isLong=$;var Ci={},Ui={};function Se(e,i){var t,a,r;return i?(e>>>=0,(r=0<=e&&e<256)&&(a=Ui[e],a)?a:(t=O(e,(e|0)<0?-1:0,!0),r&&(Ui[e]=t),t)):(e|=0,(r=-128<=e&&e<128)&&(a=Ci[e],a)?a:(t=O(e,e<0?-1:0,!1),r&&(Ci[e]=t),t))}A.fromInt=Se;function P(e,i){if(isNaN(e))return i?ve:K;if(i){if(e<0)return ve;if(e>=Oa)return La}else{if(e<=-Mi)return U;if(e+1>=Mi)return Ia}return e<0?P(-e,i).neg():O(e%Oe|0,e/Oe|0,i)}A.fromNumber=P;function O(e,i,t){return new A(e,i,t)}A.fromBits=O;var ct=Math.pow;function qt(e,i,t){if(e.length===0)throw Error("empty string");if(e==="NaN"||e==="Infinity"||e==="+Infinity"||e==="-Infinity")return K;if(typeof i=="number"?(t=i,i=!1):i=!!i,t=t||10,t<2||36<t)throw RangeError("radix");var a;if((a=e.indexOf("-"))>0)throw Error("interior hyphen");if(a===0)return qt(e.substring(1),i,t).neg();for(var r=P(ct(t,8)),n=K,h=0;h<e.length;h+=8){var f=Math.min(8,e.length-h),_=parseInt(e.substring(h,h+f),t);if(f<8){var l=P(ct(t,f));n=n.mul(l).add(P(_))}else n=n.mul(r),n=n.add(P(_))}return n.unsigned=i,n}A.fromString=qt;function V(e,i){return typeof e=="number"?P(e,i):typeof e=="string"?qt(e,i):O(e.low,e.high,typeof i=="boolean"?i:e.unsigned)}A.fromValue=V;var $i=65536,zr=1<<24,Oe=$i*$i,Oa=Oe*Oe,Mi=Oa/2,Hi=Se(zr),K=Se(0);A.ZERO=K;var ve=Se(0,!0);A.UZERO=ve;var Te=Se(1);A.ONE=Te;var Za=Se(1,!0);A.UONE=Za;var Ut=Se(-1);A.NEG_ONE=Ut;var Ia=O(-1,2147483647,!1);A.MAX_VALUE=Ia;var La=O(-1,-1,!0);A.MAX_UNSIGNED_VALUE=La;var U=O(0,-2147483648,!1);A.MIN_VALUE=U;var s=A.prototype;s.toInt=function(){return this.unsigned?this.low>>>0:this.low};s.toNumber=function(){return this.unsigned?(this.high>>>0)*Oe+(this.low>>>0):this.high*Oe+(this.low>>>0)};s.toString=function(i){if(i=i||10,i<2||36<i)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative())if(this.eq(U)){var t=P(i),a=this.div(t),r=a.mul(t).sub(this);return a.toString(i)+r.toInt().toString(i)}else return"-"+this.neg().toString(i);for(var n=P(ct(i,6),this.unsigned),h=this,f="";;){var _=h.div(n),l=h.sub(_.mul(n)).toInt()>>>0,o=l.toString(i);if(h=_,h.isZero())return o+f;for(;o.length<6;)o="0"+o;f=""+o+f}};s.getHighBits=function(){return this.high};s.getHighBitsUnsigned=function(){return this.high>>>0};s.getLowBits=function(){return this.low};s.getLowBitsUnsigned=function(){return this.low>>>0};s.getNumBitsAbs=function(){if(this.isNegative())return this.eq(U)?64:this.neg().getNumBitsAbs();for(var i=this.high!=0?this.high:this.low,t=31;t>0&&!(i&1<<t);t--);return this.high!=0?t+33:t+1};s.isZero=function(){return this.high===0&&this.low===0};s.eqz=s.isZero;s.isNegative=function(){return!this.unsigned&&this.high<0};s.isPositive=function(){return this.unsigned||this.high>=0};s.isOdd=function(){return(this.low&1)===1};s.isEven=function(){return(this.low&1)===0};s.equals=function(i){return $(i)||(i=V(i)),this.unsigned!==i.unsigned&&this.high>>>31===1&&i.high>>>31===1?!1:this.high===i.high&&this.low===i.low};s.eq=s.equals;s.notEquals=function(i){return!this.eq(i)};s.neq=s.notEquals;s.ne=s.notEquals;s.lessThan=function(i){return this.comp(i)<0};s.lt=s.lessThan;s.lessThanOrEqual=function(i){return this.comp(i)<=0};s.lte=s.lessThanOrEqual;s.le=s.lessThanOrEqual;s.greaterThan=function(i){return this.comp(i)>0};s.gt=s.greaterThan;s.greaterThanOrEqual=function(i){return this.comp(i)>=0};s.gte=s.greaterThanOrEqual;s.ge=s.greaterThanOrEqual;s.compare=function(i){if($(i)||(i=V(i)),this.eq(i))return 0;var t=this.isNegative(),a=i.isNegative();return t&&!a?-1:!t&&a?1:this.unsigned?i.high>>>0>this.high>>>0||i.high===this.high&&i.low>>>0>this.low>>>0?-1:1:this.sub(i).isNegative()?-1:1};s.comp=s.compare;s.negate=function(){return!this.unsigned&&this.eq(U)?U:this.not().add(Te)};s.neg=s.negate;s.add=function(i){$(i)||(i=V(i));var t=this.high>>>16,a=this.high&65535,r=this.low>>>16,n=this.low&65535,h=i.high>>>16,f=i.high&65535,_=i.low>>>16,l=i.low&65535,o=0,v=0,d=0,u=0;return u+=n+l,d+=u>>>16,u&=65535,d+=r+_,v+=d>>>16,d&=65535,v+=a+f,o+=v>>>16,v&=65535,o+=t+h,o&=65535,O(d<<16|u,o<<16|v,this.unsigned)};s.subtract=function(i){return $(i)||(i=V(i)),this.add(i.neg())};s.sub=s.subtract;s.multiply=function(i){if(this.isZero())return K;if($(i)||(i=V(i)),H){var t=H.mul(this.low,this.high,i.low,i.high);return O(t,H.get_high(),this.unsigned)}if(i.isZero())return K;if(this.eq(U))return i.isOdd()?U:K;if(i.eq(U))return this.isOdd()?U:K;if(this.isNegative())return i.isNegative()?this.neg().mul(i.neg()):this.neg().mul(i).neg();if(i.isNegative())return this.mul(i.neg()).neg();if(this.lt(Hi)&&i.lt(Hi))return P(this.toNumber()*i.toNumber(),this.unsigned);var a=this.high>>>16,r=this.high&65535,n=this.low>>>16,h=this.low&65535,f=i.high>>>16,_=i.high&65535,l=i.low>>>16,o=i.low&65535,v=0,d=0,u=0,g=0;return g+=h*o,u+=g>>>16,g&=65535,u+=n*o,d+=u>>>16,u&=65535,u+=h*l,d+=u>>>16,u&=65535,d+=r*o,v+=d>>>16,d&=65535,d+=n*l,v+=d>>>16,d&=65535,d+=h*_,v+=d>>>16,d&=65535,v+=a*o+r*l+n*_+h*f,v&=65535,O(u<<16|g,v<<16|d,this.unsigned)};s.mul=s.multiply;s.divide=function(i){if($(i)||(i=V(i)),i.isZero())throw Error("division by zero");if(H){if(!this.unsigned&&this.high===-2147483648&&i.low===-1&&i.high===-1)return this;var t=(this.unsigned?H.div_u:H.div_s)(this.low,this.high,i.low,i.high);return O(t,H.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?ve:K;var a,r,n;if(this.unsigned){if(i.unsigned||(i=i.toUnsigned()),i.gt(this))return ve;if(i.gt(this.shru(1)))return Za;n=ve}else{if(this.eq(U)){if(i.eq(Te)||i.eq(Ut))return U;if(i.eq(U))return Te;var h=this.shr(1);return a=h.div(i).shl(1),a.eq(K)?i.isNegative()?Te:Ut:(r=this.sub(i.mul(a)),n=a.add(r.div(i)),n)}else if(i.eq(U))return this.unsigned?ve:K;if(this.isNegative())return i.isNegative()?this.neg().div(i.neg()):this.neg().div(i).neg();if(i.isNegative())return this.div(i.neg()).neg();n=K}for(r=this;r.gte(i);){a=Math.max(1,Math.floor(r.toNumber()/i.toNumber()));for(var f=Math.ceil(Math.log(a)/Math.LN2),_=f<=48?1:ct(2,f-48),l=P(a),o=l.mul(i);o.isNegative()||o.gt(r);)a-=_,l=P(a,this.unsigned),o=l.mul(i);l.isZero()&&(l=Te),n=n.add(l),r=r.sub(o)}return n};s.div=s.divide;s.modulo=function(i){if($(i)||(i=V(i)),H){var t=(this.unsigned?H.rem_u:H.rem_s)(this.low,this.high,i.low,i.high);return O(t,H.get_high(),this.unsigned)}return this.sub(this.div(i).mul(i))};s.mod=s.modulo;s.rem=s.modulo;s.not=function(){return O(~this.low,~this.high,this.unsigned)};s.and=function(i){return $(i)||(i=V(i)),O(this.low&i.low,this.high&i.high,this.unsigned)};s.or=function(i){return $(i)||(i=V(i)),O(this.low|i.low,this.high|i.high,this.unsigned)};s.xor=function(i){return $(i)||(i=V(i)),O(this.low^i.low,this.high^i.high,this.unsigned)};s.shiftLeft=function(i){return $(i)&&(i=i.toInt()),(i&=63)===0?this:i<32?O(this.low<<i,this.high<<i|this.low>>>32-i,this.unsigned):O(0,this.low<<i-32,this.unsigned)};s.shl=s.shiftLeft;s.shiftRight=function(i){return $(i)&&(i=i.toInt()),(i&=63)===0?this:i<32?O(this.low>>>i|this.high<<32-i,this.high>>i,this.unsigned):O(this.high>>i-32,this.high>=0?0:-1,this.unsigned)};s.shr=s.shiftRight;s.shiftRightUnsigned=function(i){if($(i)&&(i=i.toInt()),i&=63,i===0)return this;var t=this.high;if(i<32){var a=this.low;return O(a>>>i|t<<32-i,t>>>i,this.unsigned)}else return i===32?O(t,0,this.unsigned):O(t>>>i-32,0,this.unsigned)};s.shru=s.shiftRightUnsigned;s.shr_u=s.shiftRightUnsigned;s.toSigned=function(){return this.unsigned?O(this.low,this.high,!1):this};s.toUnsigned=function(){return this.unsigned?this:O(this.low,this.high,!0)};s.toBytes=function(i){return i?this.toBytesLE():this.toBytesBE()};s.toBytesLE=function(){var i=this.high,t=this.low;return[t&255,t>>>8&255,t>>>16&255,t>>>24,i&255,i>>>8&255,i>>>16&255,i>>>24]};s.toBytesBE=function(){var i=this.high,t=this.low;return[i>>>24,i>>>16&255,i>>>8&255,i&255,t>>>24,t>>>16&255,t>>>8&255,t&255]};A.fromBytes=function(i,t,a){return a?A.fromBytesLE(i,t):A.fromBytesBE(i,t)};A.fromBytesLE=function(i,t){return new A(i[0]|i[1]<<8|i[2]<<16|i[3]<<24,i[4]|i[5]<<8|i[6]<<16|i[7]<<24,t)};A.fromBytesBE=function(i,t){return new A(i[4]<<24|i[5]<<16|i[6]<<8|i[7],i[0]<<24|i[1]<<16|i[2]<<8|i[3],t)};const Lr=Da(Nr);export{Lr as L,Ir as a,Zr as u}; diff --git a/segmentmodel/assets/remoteFile-1948951e.js b/segmentmodel/assets/remoteFile-1948951e.js new file mode 100644 index 0000000..f389619 --- /dev/null +++ b/segmentmodel/assets/remoteFile-1948951e.js @@ -0,0 +1 @@ +import{b as d}from"./index-462333f7.js";class b{async getBufferFromResponse(e){if(typeof e.buffer=="function")return e.buffer();if(typeof e.arrayBuffer=="function"){const t=await e.arrayBuffer();return d.Buffer.from(t)}else throw new TypeError("invalid HTTP response object, has no buffer method, and no arrayBuffer method")}constructor(e,t={}){this.baseOverrides={},this.url=e;const r=t.fetch||globalThis.fetch.bind(globalThis);if(!r)throw new TypeError("no fetch function supplied, and none found in global environment");t.overrides&&(this.baseOverrides=t.overrides),this.fetchImplementation=r}async fetch(e,t){let r;try{r=await this.fetchImplementation(e,t)}catch(s){if(`${s}`.includes("Failed to fetch"))console.warn(`generic-filehandle: refetching ${e} to attempt to work around chrome CORS header caching bug`),r=await this.fetchImplementation(e,{...t,cache:"reload"});else throw s}return r}async read(e,t=0,r,s=0,o={}){const{headers:i={},signal:f,overrides:a={}}=o;r<1/0?i.range=`bytes=${s}-${s+r}`:r===1/0&&s!==0&&(i.range=`bytes=${s}-`);const u={...this.baseOverrides,...a,headers:{...i,...a.headers,...this.baseOverrides.headers},method:"GET",redirect:"follow",mode:"cors",signal:f},n=await this.fetch(this.url,u);if(!n.ok)throw new Error(`HTTP ${n.status} ${n.statusText} ${this.url}`);if(n.status===200&&s===0||n.status===206){const c=await this.getBufferFromResponse(n),l=c.copy(e,t,0,Math.min(r,c.length)),w=n.headers.get("content-range"),h=/\/(\d+)$/.exec(w||"");return h&&h[1]&&(this._stat={size:parseInt(h[1],10)}),{bytesRead:l,buffer:e}}throw n.status===200?new Error("${this.url} fetch returned status 200, expected 206"):new Error(`HTTP ${n.status} fetching ${this.url}`)}async readFile(e={}){let t,r;typeof e=="string"?(t=e,r={}):(t=e.encoding,r=e,delete r.encoding);const{headers:s={},signal:o,overrides:i={}}=r,f={headers:s,method:"GET",redirect:"follow",mode:"cors",signal:o,...this.baseOverrides,...i},a=await this.fetch(this.url,f);if(!a)throw new Error("generic-filehandle failed to fetch");if(a.status!==200)throw Object.assign(new Error(`HTTP ${a.status} fetching ${this.url}`),{status:a.status});if(t==="utf8")return a.text();if(t)throw new Error(`unsupported encoding: ${t}`);return this.getBufferFromResponse(a)}async stat(){if(!this._stat){const e=d.Buffer.allocUnsafe(10);if(await this.read(e,0,10,0),!this._stat)throw new Error(`unable to determine size of file at ${this.url}`)}return this._stat}async close(){}}export{b as R}; diff --git a/segmentmodel/index.html b/segmentmodel/index.html index ef418ec..955d581 100644 --- a/segmentmodel/index.html +++ b/segmentmodel/index.html @@ -10,8 +10,8 @@ <meta property="og:description" content="Visualize GATK CNV segment models interactively" /> <meta property="og:image" content="https://genomespy.app/segmentmodel/screenshot.png" /> <meta property="og:url" content="https://genomespy.app/segmentmodel/" /> - <script type="module" crossorigin src="./assets/index-25a06bb0.js"></script> - <link rel="stylesheet" href="./assets/index-ac9fab48.css"> + <script type="module" crossorigin src="./assets/index-a6f09c33.js"></script> + <link rel="stylesheet" href="./assets/index-bb96b7b2.css"> </head> <body> @@ -32,7 +32,7 @@ <h1> <footer> <span> © - <a href="https://twitter.com/KariLavikka">Kari Lavikka</a> 2020-2023. + <a href="https://twitter.com/KariLavikka">Kari Lavikka</a> 2020-2024. Developed in <a href="https://www.helsinki.fi/en/researchgroups/systems-biology-of-drug-resistance-in-cancer">The Systems Biology of Drug Resistance in Cancer group</a>