From a27a9d9c59b9031f0f88aef186e07d0ccb01a42f Mon Sep 17 00:00:00 2001 From: Kari Lavikka Date: Mon, 24 Jun 2024 18:09:18 +0300 Subject: [PATCH] update SegmentModel Spy --- .../assets/90-ring-with-bg-3f133867.svg | 1 + .../assets/genomespy-favicon-0a77c5ab.svg | 34 -- .../assets/genomespy-favicon-3444eaf0.svg | 1 + segmentmodel/assets/index-396a8699.js | 4 - segmentmodel/assets/index-4e587624.js | 3 - segmentmodel/assets/index-712d95de.js | 4 + segmentmodel/assets/index-785cda83.js | 522 ++++++++++++++++++ segmentmodel/assets/index-9e6f36fd.js | 3 + segmentmodel/assets/index-a6f09c33.js | 258 --------- segmentmodel/index.html | 2 +- 10 files changed, 532 insertions(+), 300 deletions(-) create mode 100644 segmentmodel/assets/90-ring-with-bg-3f133867.svg delete mode 100644 segmentmodel/assets/genomespy-favicon-0a77c5ab.svg create mode 100644 segmentmodel/assets/genomespy-favicon-3444eaf0.svg delete mode 100644 segmentmodel/assets/index-396a8699.js delete mode 100644 segmentmodel/assets/index-4e587624.js create mode 100644 segmentmodel/assets/index-712d95de.js create mode 100644 segmentmodel/assets/index-785cda83.js create mode 100644 segmentmodel/assets/index-9e6f36fd.js delete mode 100644 segmentmodel/assets/index-a6f09c33.js diff --git a/segmentmodel/assets/90-ring-with-bg-3f133867.svg b/segmentmodel/assets/90-ring-with-bg-3f133867.svg new file mode 100644 index 0000000..89e51c1 --- /dev/null +++ b/segmentmodel/assets/90-ring-with-bg-3f133867.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/segmentmodel/assets/genomespy-favicon-0a77c5ab.svg b/segmentmodel/assets/genomespy-favicon-0a77c5ab.svg deleted file mode 100644 index da3f13f..0000000 --- a/segmentmodel/assets/genomespy-favicon-0a77c5ab.svg +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/segmentmodel/assets/genomespy-favicon-3444eaf0.svg b/segmentmodel/assets/genomespy-favicon-3444eaf0.svg new file mode 100644 index 0000000..8ef1180 --- /dev/null +++ b/segmentmodel/assets/genomespy-favicon-3444eaf0.svg @@ -0,0 +1 @@ + diff --git a/segmentmodel/assets/index-396a8699.js b/segmentmodel/assets/index-396a8699.js deleted file mode 100644 index bcbcb3f..0000000 --- a/segmentmodel/assets/index-396a8699.js +++ /dev/null @@ -1,4 +0,0 @@ -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),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;c32)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> ${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=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;ar.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=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.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<>dt-e.bi_valid,e.bi_valid+=t-dt):(e.bi_buf|=n<{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;su&&(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>=7;i<_e;i++)for(it[i]=r<<7,e=0;e<1<{let n;for(n=0;n{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]{const i=e.heap[t];let r=t<<1;for(;r<=e.heap_len&&(r{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{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>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{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{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{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{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>>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<{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]&&io){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{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_outr+e.strm.avail_in&&(i=r+e.strm.avail_in),i>a&&(i=a),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_watera&&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>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=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{let t,i,r;for(;;){if(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_length4096)&&(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{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]&&re.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<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.gzindexr&&(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.gzindexr&&(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=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>>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{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;i4){a[r++]=65533,i+=f-1;continue}for(o&=f===2?31:f===3?15:7;f>1&&i1){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<>>24,h>>>=p,_-=p,p=C>>>16&255,p===0)v[a++]=C&65535;else if(p&16){$=C&65535,p&=15,p&&(_>>=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,_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(d2;)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<>3,i-=$,_-=$<<3,h&=(1<<_)-1,n.next_in=i,n.next_out=a,n.avail_in=i{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=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;d0&&(e===dn||c!==1))return-1;for(N[1]=0,s=1;shn||e===pn&&y>cn)return 1;for(;;){Qt=s-g,o[l]+1=m?(je=ae[o[l]-m],Ge=w[o[l]-m]):(je=32+64,Ge=0),C=1<>g)+p]=Qt<<24|je<<16|Ge|0;while(p!==0);for(C=1<>=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<<_;_+ghn||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$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.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{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++]<>>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<>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++]<>>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++]<>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++]<>>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>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&7,l-=l&7,t.mode=kt;break}for(;l<3;){if(f===0)break e;f--,s+=i[a++]<>>=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++]<>>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++]<>>=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>>=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>>24,E=k>>>16&255,C=k&65535,!(y<=l);){if(f===0)break e;f--,s+=i[a++]<>>=y,l-=y,t.lens[t.have++]=C;else{if(C===16){for(N=y+2;l>>=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>>=y,l-=y,b=0,h=3+(s&7),s>>>=3,l-=3}else{for(N=y+7;l>>=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<>>24,E=k>>>16&255,C=k&65535,!(y<=l);){if(f===0)break e;f--,s+=i[a++]<>p)],y=k>>>24,E=k>>>16&255,C=k&65535,!(p+y<=l);){if(f===0)break e;f--,s+=i[a++]<>>=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>>=t.extra,l-=t.extra,t.back+=t.extra}t.was=t.length,t.mode=On;case On:for(;k=t.distcode[s&(1<>>24,E=k>>>16&255,C=k&65535,!(y<=l);){if(f===0)break e;f--,s+=i[a++]<>p)],y=k>>>24,E=k>>>16&255,C=k&65535,!(p+y<=l);){if(f===0)break e;f--,s+=i[a++]<>>=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>>=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++]<{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=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||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;wE(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(;axt(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;hxt(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]=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;i1||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=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;_{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;wnew 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-4e587624.js b/segmentmodel/assets/index-4e587624.js deleted file mode 100644 index 2945652..0000000 --- a/segmentmodel/assets/index-4e587624.js +++ /dev/null @@ -1,3 +0,0 @@ -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(;n0&&(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;Cl+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>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>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=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;xthis.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;d2**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;fthis.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=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=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>lt),r=Number(t&BigInt(4294967295));i?(e.setInt32(n+4,a,i),e.setUint32(n,r,i)):(e.setInt32(n,a,i),e.setUint32(n+4,r,i))}function sr(e,n,t,i){const a=Number(t>>lt),r=Number(t&BigInt(4294967295));i?(e.setUint32(n+4,a,i),e.setUint32(n,r,i)):(e.setUint32(n,a,i),e.setUint32(n+4,r,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,ae="___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 S{constructor(){this.varName="",this.type="",this.options={},this.endian="be",this.useContextVariables=!1}static start(){return new S}primitiveGenerateN(n,t){const i=Ye[n],a=Ke[n];t.pushCode(`${t.generateVariable(this.varName)} = dataView.get${i}(offset, ${a});`),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 a=parseInt(i,10),r=t.choices[a];if(isNaN(a))throw new Error(`Choice key "${i}" is not a number.`);if(typeof r=="string"&&!Z.has(r)&&!(r in M))throw new Error(`Choice type "${r}" 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 S)&&!Z.has(t.type))throw new Error("type must be a known parser name or a Parser object.");if(!(t.type instanceof S)&&!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 ${ae+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 ${ae+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 a;(a=Z.get(i))===null||a===void 0||a.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 S&&(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 a=new S;return a.type=n,a.varName=t,a.options=i,a.endian=this.endian,this.head?this.head.next=a:this.next=a,this.head=a,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 a=(l=0)=>{let p=0;for(let c=l;c32)break;p+=h}return p},r=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,p)=>{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=r(a(p)-s)}const h=f?u-o-c:o,_=-1>>>32-c;n.pushCode(`${l.varName} ${c> ${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(),a=this.options.encoding,r=a.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(r?`${t} = Array.from(buffer.subarray(${i}, ${u}), ${o}).join('');`:`${t} = new TextDecoder('${a}').decode(buffer.subarray(${i}, ${u}));`)}else if(this.options.length){const f=n.generateOption(this.options.length);n.pushCode(r?`${t} = Array.from(buffer.subarray(offset, offset + ${f}), ${o}).join('');`:`${t} = new TextDecoder('${a}').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(r?`${t} = Array.from(buffer.subarray(${i}, offset - 1), ${o}).join('');`:`${t} = new TextDecoder('${a}').decode(buffer.subarray(${i}, offset - 1));`)):this.options.greedy&&(n.pushCode(`var ${i} = offset;`),n.pushCode("while(buffer.length > offset++);"),n.pushCode(r?`${t} = Array.from(buffer.subarray(${i}, offset), ${o}).join('');`:`${t} = new TextDecoder('${a}').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,a=n.generateTmpVariable(),r=n.generateTmpVariable();n.pushCode(`var ${a} = offset;`),n.pushCode(`var ${r} = 0;`),n.pushCode("while (offset < buffer.length) {"),n.pushCode(`${r} = dataView.getUint8(offset);`);const o=n.addImport(i);n.pushCode(`if (${o}.call(${n.generateVariable()}, ${r}, buffer.subarray(offset))) break;`),n.pushCode("offset += 1;"),n.pushCode("}"),n.pushCode(`${t} = buffer.subarray(${a}, 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),a=this.options.type,r=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 ${r} = 0; offset < buffer.length; ${r}++) {`):i!==void 0?n.pushCode(`for (var ${r} = offset + ${i}; offset < ${r}; ) {`):n.pushCode(`for (var ${r} = ${t}; ${r} > 0; ${r}--) {`),typeof a=="string")if(Z.get(a)){const l=n.generateTmpVariable();if(n.pushCode(`var ${l} = ${ae+a}(offset, {`),n.useContextVariables){const p=n.generateVariable();n.pushCode(`$parent: ${p},`),n.pushCode(`$root: ${p}.$root,`),!this.options.readUntil&&i===void 0&&n.pushCode(`$index: ${t} - ${r},`)}n.pushCode("});"),n.pushCode(`var ${f} = ${l}.result; offset = ${l}.offset;`),a!==this.alias&&n.addReference(a)}else{const l=Ye[a],p=Ke[a];n.pushCode(`var ${f} = dataView.get${l}(offset, ${p});`),n.pushCode(`offset += ${M[a]};`)}else if(a instanceof S){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} - ${r};`)),a.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,p=n.addImport(l);n.pushCode(`while (!${p}.call(${n.generateVariable()}, ${f}, buffer.subarray(offset)));`)}}generateChoiceCase(n,t,i){if(typeof i=="string"){const a=n.generateVariable(this.varName);if(Z.has(i)){const r=n.generateTmpVariable();n.pushCode(`var ${r} = ${ae+i}(offset, {`),n.useContextVariables&&(n.pushCode(`$parent: ${a}.$parent,`),n.pushCode(`$root: ${a}.$root,`)),n.pushCode("});"),n.pushCode(`${a} = ${r}.result; offset = ${r}.offset;`),i!==this.alias&&n.addReference(i)}else{const r=Ye[i],o=Ke[i];n.pushCode(`${a} = dataView.get${r}(offset, ${o});`),n.pushCode(`offset += ${M[i]}`)}}else i instanceof S&&(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 a=n.generateVariable();n.pushCode(`${i}.$parent = ${a};`),n.pushCode(`${i}.$root = ${a}.$root;`)}n.pushCode(`switch(${t}) {`);for(const a in this.options.choices){const r=parseInt(a,10),o=this.options.choices[r];n.pushCode(`case ${r}:`),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 S){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} = ${ae+this.options.type}(offset, {`),n.useContextVariables){const a=n.generateVariable();n.pushCode(`$parent: ${a},`),n.pushCode(`$root: ${a}.$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 p=n.addImport(u);n.pushCode(`if (${p}.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 a=n.generateTmpVariable(),r=n.generateTmpVariable(),o=n.generateTmpVariable(),f=n.addImport(this.options.wrapper);if(n.pushCode(`${i} = ${f}.call(this, ${i}).subarray(0);`),n.pushCode(`var ${a} = buffer;`),n.pushCode(`var ${r} = 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 S)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} = ${ae+this.options.type}(0);`),n.pushCode(`${t} = ${u}.result;`),this.options.type!==this.alias&&n.addReference(this.options.type)}n.pushCode(`buffer = ${a};`),n.pushCode(`dataView = ${o};`),n.pushCode(`offset = ${r};`)}generateFormatter(n,t,i){if(typeof i=="function"){const a=n.addImport(i);n.pushCode(`${t} = ${a}.call(${n.generateVariable()}, ${t});`)}}generatePointer(n){const t=this.options.type,i=n.generateOption(this.options.offset),a=n.generateTmpVariable(),r=n.generateVariable(this.varName);if(n.pushCode(`var ${a} = offset;`),n.pushCode(`offset = ${i};`),this.options.type instanceof S){if(n.pushCode(`${r} = {};`),n.useContextVariables){const o=n.generateVariable();n.pushCode(`${r}.$parent = ${o};`),n.pushCode(`${r}.$root = ${o}.$root;`)}n.pushPath(this.varName),this.options.type.generate(n),n.popPath(this.varName),n.useContextVariables&&(n.pushCode(`delete ${r}.$parent;`),n.pushCode(`delete ${r}.$root;`))}else if(Z.has(this.options.type)){const o=n.generateTmpVariable();if(n.pushCode(`var ${o} = ${ae+this.options.type}(offset, {`),n.useContextVariables){const f=n.generateVariable();n.pushCode(`$parent: ${f},`),n.pushCode(`$root: ${f}.$root,`)}n.pushCode("});"),n.pushCode(`${r} = ${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(`${r} = dataView.get${o}(offset, ${f});`),n.pushCode(`offset += ${M[t]};`)}n.pushCode(`offset = ${a};`)}generateSaveOffset(n){const t=n.generateVariable(this.varName);n.pushCode(`${t} = offset`)}}class pe{constructor(n){this.ranges=n}get min(){return this.ranges[0].min}get max(){return this.ranges[this.ranges.length-1].max}contains(n){for(const t of this.ranges)if(t.min<=n&&t.max>=n)return!0;return!1}isContiguous(){return this.ranges.length>1}getRanges(){return this.ranges.map(n=>new pe([{min:n.min,max:n.max}]))}toString(){return this.ranges.map(n=>`[${n.min}-${n.max}]`).join(",")}union(n){const t=[...this.getRanges(),...n.getRanges()].sort((r,o)=>r.mino.min?1:r.maxr.max?1:0),i=[];let a=t[0];for(const r of t)r.min>a.max+1?(i.push(a),a=r):r.max>a.max&&(a=new pe([{min:a.min,max:r.max}]));return i.push(a),i.length===1?i[0]:new pe(i)}}/*! 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,oe=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 xe=new Array(_e*2);ye(xe);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,a){this.static_tree=e,this.extra_bits=n,this.extra_base=t,this.elems=i,this.max_length=a,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<>dt-e.bi_valid,e.bi_valid+=t-dt):(e.bi_buf|=n<{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,a=n.stat_desc.static_tree,r=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,p,c,h,_,g=0;for(c=0;c<=oe;c++)e.bl_count[c]=0;for(t[e.heap[e.heap_max]*2+1]=0,s=e.heap_max+1;su&&(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),r&&(e.static_len+=_*(a[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;)p=e.heap[--s],!(p>i)&&(t[p*2+1]!==c&&(e.opt_len+=(c-t[p*2+1])*t[p*2],t[p*2+1]=c),l--)}},oi=(e,n,t)=>{const i=new Array(oe+1);let a=0,r,o;for(r=1;r<=oe;r++)a=a+t[r-1]<<1,i[r]=a;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,a;const r=new Array(oe+1);for(t=0,i=0;i>=7;i<_e;i++)for(it[i]=a<<7,e=0;e<1<{let n;for(n=0;n{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 a=n*2,r=t*2;return e[a]{const i=e.heap[t];let a=t<<1;for(;a<=e.heap_len&&(a{let i,a,r=0,o,f;if(e.sym_next!==0)do i=e.pending_buf[e.sym_buf+r++]&255,i+=(e.pending_buf[e.sym_buf+r++]&255)<<8,a=e.pending_buf[e.sym_buf+r++],i===0?j(e,a,n):(o=ze[a],j(e,o+Pe+1,n),f=At[o],f!==0&&(a-=jt[o],U(e,a,f)),i--,o=ri(i),j(e,o,t),f=nt[o],f!==0&&(i-=it[o],U(e,i,f)));while(r{const t=n.dyn_tree,i=n.stat_desc.static_tree,a=n.stat_desc.has_stree,r=n.stat_desc.elems;let o,f,u=-1,s;for(e.heap_len=0,e.heap_max=Xn,o=0;o>1;o>=1;o--)bt(e,t,o);s=r;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,a=-1,r,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++)r=o,o=n[(i+1)*2+1],!(++f{let i,a=-1,r,o=n[0*2+1],f=0,u=7,s=4;for(o===0&&(u=138,s=3),i=0;i<=t;i++)if(r=o,o=n[(i+1)*2+1],!(++f{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 a;for(U(e,n-257,5),U(e,t-1,5),U(e,i-4,4),a=0;a{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{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 a,r,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),a=e.opt_len+3+7>>>3,r=e.static_len+3+7>>>3,r<=a&&(a=r)):a=r=t+5,t+4<=a&&n!==-1?li(e,n,t,i):e.strategy===lr||r===a?(U(e,(Wn<<1)+(i?1:0),3),rn(e,W,xe)):(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)},Nr=(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 xr=Er,Ir=li,Tr=Sr,Ar=Nr,Or=Cr,zr={_tr_init:xr,_tr_stored_block:Ir,_tr_flush_block:Tr,_tr_tally:Ar,_tr_align:Or};const Rr=(e,n,t,i)=>{let a=e&65535|0,r=e>>>16&65535|0,o=0;for(;t!==0;){o=t>2e3?2e3:t,t-=o;do a=a+n[i++]|0,r=r+a|0;while(--o);a%=65521,r%=65521}return a|r<<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 a=Ur,r=i+t;e^=-1;for(let o=i;o>>8^a[(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:ee,_tr_align:Fr}=zr,{Z_NO_FLUSH:te,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,Q=258,Y=Q+I+1,aa=32,we=42,Gt=57,Bt=69,Ut=73,Dt=91,Vt=103,se=113,Se=666,B=1,ve=2,le=3,ke=4,oa=3,fe=(e,n)=>(e.msg=ge[n],n),un=e=>e*2-(e>4?9:0),q=e=>{let n=e.length;for(;--n>=0;)e[n]=0},sa=e=>{let n,t,i,a=e.w_size;n=e.hash_size,i=n;do t=e.head[--i],e.head[i]=t>=a?t-a:0;while(--n);n=a,i=n;do t=e.prev[--i],e.prev[i]=t>=a?t-a:0;while(--n)};let fa=(e,n,t)=>(n<{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 a=e.avail_in;return a>i&&(a=i),a===0?0:(e.avail_in-=a,n.set(e.input.subarray(e.next_in,e.next_in+a),t),e.state.wrap===1?e.adler=Be(e.adler,n,a,t):e.state.wrap===2&&(e.adler=z(e.adler,n,a,t)),e.next_in+=a,e.total_in+=a,a)},ui=(e,n)=>{let t=e.max_chain_length,i=e.strstart,a,r,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,p=e.prev,c=e.strstart+Q;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(a=n,!(s[a+o]!==_||s[a+o-1]!==h||s[a]!==s[i]||s[++a]!==s[i+1])){i+=2,a++;do;while(s[++i]===s[++a]&&s[++i]===s[++a]&&s[++i]===s[++a]&&s[++i]===s[++a]&&s[++i]===s[++a]&&s[++i]===s[++a]&&s[++i]===s[++a]&&s[++i]===s[++a]&&io){if(e.match_start=n,o=r,r>=f)break;h=s[i+o-1],_=s[i+o]}}while((n=p[n&l])>u&&--t!==0);return o<=e.lookahead?o:e.lookahead},me=e=>{const n=e.w_size;let t,i,a;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(a=e.strstart-e.insert,e.ins_h=e.window[a],e.ins_h=ne(e,e.ins_h,e.window[a+1]);e.insert&&(e.ins_h=ne(e,e.ins_h,e.window[a+I-1]),e.prev[a&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=a,a++,e.insert--,!(e.lookahead+e.insert{let t=e.pending_buf_size-5>e.w_size?e.w_size:e.pending_buf_size-5,i,a,r,o=0,f=e.strm.avail_in;do{if(i=65535,r=e.bi_valid+42>>3,e.strm.avail_outa+e.strm.avail_in&&(i=a+e.strm.avail_in),i>r&&(i=r),i>8,e.pending_buf[e.pending-2]=~i,e.pending_buf[e.pending-1]=~i>>8,D(e.strm),a&&(a>i&&(a=i),e.strm.output.set(e.window.subarray(e.block_start,e.block_start+a),e.strm.next_out),e.strm.next_out+=a,e.strm.avail_out-=a,e.strm.total_out+=a,e.block_start+=a,i-=a),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_waterr&&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++,r+=e.w_size,e.insert>e.strstart&&(e.insert=e.strstart)),r>e.strm.avail_in&&(r=e.strm.avail_in),r&&(Lt(e.strm,e.window,e.strstart,r),e.strstart+=r,e.insert+=r>e.w_size-e.insert?e.w_size-e.insert:r),e.high_water>3,r=e.pending_buf_size-r>65535?65535:e.pending_buf_size-r,t=r>e.w_size?e.w_size:r,a=e.strstart-e.block_start,(a>=t||(a||n===L)&&n!==te&&e.strm.avail_in===0&&a<=r)&&(i=a>r?r:a,o=n===L&&e.strm.avail_in===0&&i===a?1:0,zt(e,e.block_start,i,o),e.block_start+=i,D(e.strm)),o?le:B)},wt=(e,n)=>{let t,i;for(;;){if(e.lookahead=I&&(e.ins_h=ne(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=ee(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=ne(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=ne(e,e.ins_h,e.window[e.strstart+1]);else i=ee(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{let t,i,a;for(;;){if(e.lookahead=I&&(e.ins_h=ne(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_length4096)&&(e.match_length=I-1)),e.prev_length>=I&&e.match_length<=e.prev_length){a=e.strstart+e.lookahead-I,i=ee(e,e.strstart-1-e.prev_match,e.prev_length-I),e.lookahead-=e.prev_length-1,e.prev_length-=2;do++e.strstart<=a&&(e.ins_h=ne(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=ee(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=ee(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart{let t,i,a,r;const o=e.window;for(;;){if(e.lookahead<=Q){if(me(e),e.lookahead<=Q&&n===te)return B;if(e.lookahead===0)break}if(e.match_length=0,e.lookahead>=I&&e.strstart>0&&(a=e.strstart-1,i=o[a],i===o[++a]&&i===o[++a]&&i===o[++a])){r=e.strstart+Q;do;while(i===o[++a]&&i===o[++a]&&i===o[++a]&&i===o[++a]&&i===o[++a]&&i===o[++a]&&i===o[++a]&&i===o[++a]&&ae.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=I?(t=ee(e,1,e.match_length-I),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(t=ee(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?le: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===te)return B;break}if(e.match_length=0,t=ee(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?le:ke):e.sym_next&&(V(e,!1),e.strm.avail_out===0)?B:ve};function H(e,n,t,i,a){this.good_length=e,this.max_lazy=n,this.nice_length=t,this.max_chain=i,this.func=a}const Ne=[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,ce),new H(8,16,32,32,ce),new H(8,16,128,128,ce),new H(8,32,128,256,ce),new H(32,128,258,1024,ce),new H(32,258,258,4096,ce)],ha=e=>{e.window_size=2*e.w_size,q(e.head),e.max_lazy_match=Ne[e.level].max_lazy,e.good_match=Ne[e.level].good_length,e.nice_match=Ne[e.level].nice_length,e.max_chain_length=Ne[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),q(this.dyn_ltree),q(this.dyn_dtree),q(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),q(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*Rt+1),q(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!==se&&n.status!==Se?1:0},ci=e=>{if(Me(e))return fe(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:se,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,a,r)=>{if(!e)return G;let o=1;if(n===Hr&&(n=6),i<0?(o=0,i=-i):i>15&&(o=2,i-=16),a<1||a>Xr||t!==ut||i<8||i>15||n<0||n>9||r<0||r>Yr||i===8&&o!==1)return fe(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<pi(e,n,ut,qr,Jr,Kr),_a=(e,n)=>{if(Me(e)||n>fn||n<0)return e?fe(e,G):G;const t=e.state;if(!e.output||e.avail_in!==0&&!e.input||t.status===Se&&n!==L)return fe(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 fe(e,gt);if(t.status===Se&&e.avail_in!==0)return fe(e,gt);if(t.status===we&&t.wrap===0&&(t.status=se),t.status===we){let a=ut+(t.w_bits-8<<4)<<8,r=-1;if(t.strategy>=We||t.level<2?r=0:t.level<6?r=1:t.level===6?r=2:r=3,a|=r<<6,t.strstart!==0&&(a|=aa),a+=31-a%31,Ce(t,a),t.strstart!==0&&(Ce(t,e.adler>>>16),Ce(t,e.adler&65535)),e.adler=1,t.status=se,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=se,D(e),t.pending!==0)return t.last_flush=-1,R}if(t.status===Bt){if(t.gzhead.extra){let a=t.pending,r=(t.gzhead.extra.length&65535)-t.gzindex;for(;t.pending+r>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>a&&(e.adler=z(e.adler,t.pending_buf,t.pending-a,a)),t.gzindex+=f,D(e),t.pending!==0)return t.last_flush=-1,R;a=0,r-=f}let o=new Uint8Array(t.gzhead.extra);t.pending_buf.set(o.subarray(t.gzindex,t.gzindex+r),t.pending),t.pending+=r,t.gzhead.hcrc&&t.pending>a&&(e.adler=z(e.adler,t.pending_buf,t.pending-a,a)),t.gzindex=0}t.status=Ut}if(t.status===Ut){if(t.gzhead.name){let a=t.pending,r;do{if(t.pending===t.pending_buf_size){if(t.gzhead.hcrc&&t.pending>a&&(e.adler=z(e.adler,t.pending_buf,t.pending-a,a)),D(e),t.pending!==0)return t.last_flush=-1,R;a=0}t.gzindexa&&(e.adler=z(e.adler,t.pending_buf,t.pending-a,a)),t.gzindex=0}t.status=Dt}if(t.status===Dt){if(t.gzhead.comment){let a=t.pending,r;do{if(t.pending===t.pending_buf_size){if(t.gzhead.hcrc&&t.pending>a&&(e.adler=z(e.adler,t.pending_buf,t.pending-a,a)),D(e),t.pending!==0)return t.last_flush=-1,R;a=0}t.gzindexa&&(e.adler=z(e.adler,t.pending_buf,t.pending-a,a))}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=se,D(e),t.pending!==0)return t.last_flush=-1,R}if(e.avail_in!==0||t.lookahead!==0||n!==te&&t.status!==Se){let a=t.level===0?hi(t,n):t.strategy===We?ua(t,n):t.strategy===Gr?la(t,n):Ne[t.level].func(t,n);if((a===le||a===ke)&&(t.status=Se),a===B||a===le)return e.avail_out===0&&(t.last_flush=-1),R;if(a===ve&&(n===Pr?Fr(t):n!==fn&&(zt(t,0,0,!1),n===Zr&&(q(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===se?fe(e,Mr):R},ga=(e,n)=>{let t=n.length;if(Me(e))return G;const i=e.state,a=i.wrap;if(a===2||a===1&&i.status!==we||i.lookahead)return G;if(a===1&&(e.adler=Be(e.adler,n,t,0)),i.wrap=0,t>=i.w_size){a===0&&(q(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 r=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=ne(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=r,i.wrap=a,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 Na=(e,n)=>Object.prototype.hasOwnProperty.call(e,n);var xa=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)Na(t,i)&&(e[i]=t[i])}}return e},Ia=e=>{let n=0;for(let i=0,a=e.length;i=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,a,r,o=e.length,f=0;for(a=0;a>>6,n[r++]=128|t&63):t<65536?(n[r++]=224|t>>>12,n[r++]=128|t>>>6&63,n[r++]=128|t&63):(n[r++]=240|t>>>18,n[r++]=128|t>>>12&63,n[r++]=128|t>>>6&63,n[r++]=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{const t=n||e.length;if(typeof TextDecoder=="function"&&TextDecoder.prototype.decode)return new TextDecoder().decode(e.subarray(0,n));let i,a;const r=new Array(t*2);for(a=0,i=0;i4){r[a++]=65533,i+=f-1;continue}for(o&=f===2?31:f===3?15:7;f>1&&i1){r[a++]=65533;continue}o<65536?r[a++]=o:(o-=65536,r[a++]=55296|o>>10&1023,r[a++]=56320|o&1023)}return Aa(r,a)},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 a,r;if(this.ended)return!1;for(n===~~n?r=n:r=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),(r===Ua||r===Da)&&t.avail_out<=6){this.onData(t.output.subarray(0,t.next_out)),t.avail_out=0;continue}if(a=Ie.deflate(t,r),a===La)return t.next_out>0&&this.onData(t.output.subarray(0,t.next_out)),a=Ie.deflateEnd(this.strm),this.onEnd(a),this.ended=!0,a===rt;if(t.avail_out===0){this.onData(t.output);continue}if(r>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,a,r,o,f,u,s,l,p,c,h,_,g,k,m,E,C,d,$,N,b,y,w,v;const x=n.state;i=n.next_in,w=n.input,a=i+(n.avail_in-5),r=n.next_out,v=n.output,o=r-(t-n.avail_out),f=r+(n.avail_out-257),u=x.dmax,s=x.wsize,l=x.whave,p=x.wnext,c=x.window,h=x.hold,_=x.bits,g=x.lencode,k=x.distcode,m=(1<>>24,h>>>=d,_-=d,d=C>>>16&255,d===0)v[r++]=C&65535;else if(d&16){$=C&65535,d&=15,d&&(_>>=d,_-=d),_<15&&(h+=w[i++]<<_,_+=8,h+=w[i++]<<_,_+=8),C=k[h&E];n:for(;;){if(d=C>>>24,h>>>=d,_-=d,d=C>>>16&255,d&16){if(N=C&65535,d&=15,_u){n.msg="invalid distance too far back",x.mode=Xe;break e}if(h>>>=d,_-=d,d=r-o,N>d){if(d=N-d,d>l&&x.sane){n.msg="invalid distance too far back",x.mode=Xe;break e}if(b=0,y=c,p===0){if(b+=s-d,d<$){$-=d;do v[r++]=c[b++];while(--d);b=r-N,y=v}}else if(p2;)v[r++]=y[b++],v[r++]=y[b++],v[r++]=y[b++],$-=3;$&&(v[r++]=y[b++],$>1&&(v[r++]=y[b++]))}else{b=r-N;do v[r++]=v[b++],v[r++]=v[b++],v[r++]=v[b++],$-=3;while($>2);$&&(v[r++]=v[b++],$>1&&(v[r++]=v[b++]))}}else if(d&64){n.msg="invalid distance code",x.mode=Xe;break e}else{C=k[(C&65535)+(h&(1<>3,i-=$,_-=$<<3,h&=(1<<_)-1,n.next_in=i,n.next_out=r,n.avail_in=i{const u=f.bits;let s=0,l=0,p=0,c=0,h=0,_=0,g=0,k=0,m=0,E=0,C,d,$,N,b,y=null,w;const v=new Uint16Array(de+1),x=new Uint16Array(de+1);let re=null,Qt,je,Ge;for(s=0;s<=de;s++)v[s]=0;for(l=0;l=1&&v[c]===0;c--);if(h>c&&(h=c),c===0)return a[r++]=1<<24|64<<16|0,a[r++]=1<<24|64<<16|0,f.bits=1,0;for(p=1;p0&&(e===dn||c!==1))return-1;for(x[1]=0,s=1;shn||e===pn&&m>cn)return 1;for(;;){Qt=s-g,o[l]+1=w?(je=re[o[l]-w],Ge=y[o[l]-w]):(je=32+64,Ge=0),C=1<>g)+d]=Qt<<24|je<<16|Ge|0;while(d!==0);for(C=1<>=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&N)!==$){for(g===0&&(g=h),b+=p,_=s-g,k=1<<_;_+ghn||e===pn&&m>cn)return 1;$=E&N,a[$]=h<<24|_<<16|b-r|0}}return E!==0&&(a[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:ue,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,Nn=16195,xn=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 he=e=>{if(!e)return 1;const n=e.state;return!n||n.strm!==e||n.mode$i?1:0},Ei=e=>{if(he(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,ue},Ci=e=>{if(he(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(he(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))},Ni=(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!==ue&&(e.state=null),i},oo=e=>Ni(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},xi=(e,n,t,i)=>{let a;const r=e.state;return r.window===null&&(r.wsize=1<=r.wsize?(r.window.set(n.subarray(t-r.wsize,t),0),r.wnext=0,r.whave=r.wsize):(a=r.wsize-r.wnext,a>i&&(a=i),r.window.set(n.subarray(t-i,t-i+a),r.wnext),i-=a,i?(r.window.set(n.subarray(t-i,t),0),r.wnext=i,r.whave=r.wsize):(r.wnext+=a,r.wnext===r.wsize&&(r.wnext=0),r.whave{let t,i,a,r,o,f,u,s,l,p,c,h,_,g,k=0,m,E,C,d,$,N,b,y;const w=new Uint8Array(4);let v,x;const re=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(he(e)||!e.output||!e.input&&e.avail_in!==0)return F;t=e.state,t.mode===K&&(t.mode=yt),o=e.next_out,a=e.output,u=e.avail_out,r=e.next_in,i=e.input,f=e.avail_in,s=t.hold,l=t.bits,p=f,c=u,y=ue;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[r++]<>>8&255,t.check=z(t.check,w,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<>8&1),t.flags&512&&t.wrap&4&&(w[0]=s&255,w[1]=s>>>8&255,t.check=z(t.check,w,2,0)),s=0,l=0,t.mode=wn;case wn:for(;l<32;){if(f===0)break e;f--,s+=i[r++]<>>8&255,w[2]=s>>>16&255,w[3]=s>>>24&255,t.check=z(t.check,w,4,0)),s=0,l=0,t.mode=mn;case mn:for(;l<16;){if(f===0)break e;f--,s+=i[r++]<>8),t.flags&512&&t.wrap&4&&(w[0]=s&255,w[1]=s>>>8&255,t.check=z(t.check,w,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[r++]<>>8&255,t.check=z(t.check,w,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(r,r+h),b)),t.flags&512&&t.wrap&4&&(t.check=z(t.check,i,h,r)),f-=h,r+=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[r+h++],t.head&&b&&t.length<65536&&(t.head.name+=String.fromCharCode(b));while(b&&h>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[r++]<>>=l&7,l-=l&7,t.mode=kt;break}for(;l<3;){if(f===0)break e;f--,s+=i[r++]<>>=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=xn;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[r++]<>>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=Nn;case Nn:if(h=t.length,h){if(h>f&&(h=f),h>u&&(h=u),h===0)break e;a.set(i.subarray(r,r+h),o),f-=h,r+=h,u-=h,o+=h,t.length-=h;break}t.mode=K;break;case xn:for(;l<14;){if(f===0)break e;f--,s+=i[r++]<>>=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>>=3,l-=3}for(;t.have<19;)t.lens[re[t.have++]]=0;if(t.lencode=t.lendyn,t.lenbits=7,v={bits:t.lenbits},y=Te(Xa,t.lens,0,19,t.lencode,0,t.work,v),t.lenbits=v.bits,y){e.msg="invalid code lengths set",t.mode=A;break}t.have=0,t.mode=Tn;case Tn:for(;t.have>>24,E=k>>>16&255,C=k&65535,!(m<=l);){if(f===0)break e;f--,s+=i[r++]<>>=m,l-=m,t.lens[t.have++]=C;else{if(C===16){for(x=m+2;l>>=m,l-=m,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(x=m+3;l>>=m,l-=m,b=0,h=3+(s&7),s>>>=3,l-=3}else{for(x=m+7;l>>=m,l-=m,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},y=Te(wi,t.lens,0,t.nlen,t.lencode,0,t.work,v),t.lenbits=v.bits,y){e.msg="invalid literal/lengths set",t.mode=A;break}if(t.distbits=6,t.distcode=t.distdyn,v={bits:t.distbits},y=Te(mi,t.lens,t.nlen,t.ndist,t.distcode,0,t.work,v),t.distbits=v.bits,y){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=r,e.avail_in=f,t.hold=s,t.bits=l,Ha(e,c),o=e.next_out,a=e.output,u=e.avail_out,r=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<>>24,E=k>>>16&255,C=k&65535,!(m<=l);){if(f===0)break e;f--,s+=i[r++]<>d)],m=k>>>24,E=k>>>16&255,C=k&65535,!(d+m<=l);){if(f===0)break e;f--,s+=i[r++]<>>=d,l-=d,t.back+=d}if(s>>>=m,l-=m,t.back+=m,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(x=t.extra;l>>=t.extra,l-=t.extra,t.back+=t.extra}t.was=t.length,t.mode=On;case On:for(;k=t.distcode[s&(1<>>24,E=k>>>16&255,C=k&65535,!(m<=l);){if(f===0)break e;f--,s+=i[r++]<>d)],m=k>>>24,E=k>>>16&255,C=k&65535,!(d+m<=l);){if(f===0)break e;f--,s+=i[r++]<>>=d,l-=d,t.back+=d}if(s>>>=m,l-=m,t.back+=m,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(x=t.extra;l>>=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=a,_=o-t.offset,h=t.length;h>u&&(h=u),u-=h,t.length-=h;do a[o++]=g[_++];while(--h);t.length===0&&(t.mode=Qe);break;case Bn:if(u===0)break e;a[o++]=t.length,u--,t.mode=Qe;break;case kt:if(t.wrap){for(;l<32;){if(f===0)break e;f--,s|=i[r++]<{if(he(e))return F;let n=e.state;return n.window&&(n.window=null),e.state=null,ue},uo=(e,n)=>{if(he(e))return F;const t=e.state;return t.wrap&2?(t.head=n,n.done=!1,ue):F},ho=(e,n)=>{const t=n.length;let i,a,r;return he(e)||(i=e.state,i.wrap!==0&&i.mode!==at)?F:i.mode===at&&(a=1,a=Be(a,n,t,0),a!==i.check)?yi:(r=xi(e,n,t,t),r?(i.mode=ki,vi):(i.havedict=1,ue))};var co=Ci,po=Si,_o=Ei,bo=oo,go=Ni,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:No,Z_DATA_ERROR:Fn,Z_MEM_ERROR:xo}=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,a=this.options.dictionary;let r,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),r=X.inflate(t,o),r===St&&a&&(r=X.inflateSetDictionary(t,a),r===Ve?r=X.inflate(t,o):r===Fn&&(r=St));t.avail_in>0&&r===Ct&&t.state.wrap>0&&e[t.next_in]!==0;)X.inflateReset(t),r=X.inflate(t,o);switch(r){case No:case Fn:case St:case xo:return this.onEnd(r),this.ended=!0,!1}if(f=t.avail_out,t.next_out&&(t.avail_out===0||r===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(!(r===Ve&&f===0)){if(r===Ct)return r=X.inflateEnd(this.strm),this.onEnd(r),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((a,r)=>Number(a.offset)-Number(r.offset));const n=[];let t,i;for(const a of e)t&&i&&Number(a.offset)-i<=2e3?(t.length=BigInt(Number(t.length)+Number(a.length)-i+Number(a.offset)),t.blocks.push(a)):n.push(t={blocks:[a],length:a.length,offset:a.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 Nt(e,n,t,i){return e=t}function Ho(e){const n=e?"big":"little",t=new S().endianess(n).uint32("chromId").uint32("start").uint32("end").uint32("validCnt").floatle("minScore").floatle("maxScore").floatle("sumData").floatle("sumSqData").saveOffset("offset"),i=new S().endianess(n).uint8("isLeaf").skip(1).uint16("cnt").choice({tag:"isLeaf",choices:{1:new S().endianess(n).array("blocksToFetch",{length:"cnt",type:new S().endianess(n).uint32("startChrom").uint32("startBase").uint32("endChrom").uint32("endBase").uint64("blockOffset").uint64("blockSize").saveOffset("offset")}),0:new S().array("recurOffsets",{length:"cnt",type:new S().endianess(n).uint32("startChrom").uint32("startBase").uint32("endChrom").uint32("endBase").uint64("blockOffset").saveOffset("offset")})}}),a=new S().endianess(n).uint32("chromId").int32("start").int32("end").string("rest",{zeroTerminated:!0}).saveOffset("offset");return{bigWigParser:new S().endianess(n).skip(4).int32("blockStart").skip(4).uint32("itemStep").uint32("itemSpan").uint8("blockType").skip(1).uint16("itemCount").choice({tag:"blockType",choices:{[Mo]:new S().array("items",{length:"itemCount",type:new S().floatle("score")}),[Zo]:new S().array("items",{length:"itemCount",type:new S().endianess(n).int32("start").floatle("score")}),[Po]:new S().array("items",{length:"itemCount",type:new S().endianess(n).int32("start").int32("end").floatle("score")})}}),bigBedParser:a,summaryParser:t,leafParser:i}}class Ti{constructor(n,t,i,a,r,o){if(this.bbi=n,this.refsByName=t,this.cirTreeOffset=i,this.isBigEndian=a,this.isCompressed=r,this.blockType=o,this.featureCache=new Yn({cache:new Kn({maxSize:1e3}),fill:async(u,s)=>{const l=Number(u.length),p=Number(u.offset),{buffer:c}=await this.bbi.read(J.Buffer.alloc(l),0,l,p,{signal:s});return c}}),!(i>=0))throw new Error("invalid cirTreeOffset!");const f=Ho(a);this.leafParser=f.leafParser,this.bigBedParser=f.bigBedParser}async readWigData(n,t,i,a,r){try{const{refsByName:o,bbi:f,cirTreeOffset:u,isBigEndian:s}=this,l=o[n];l===void 0&&a.complete();const p={chrId:l,start:t,end:i};this.cirTreePromise||(this.cirTreePromise=f.read(J.Buffer.alloc(48),0,48,Number(u),r));const{buffer:c}=await this.cirTreePromise,h=s?c.readUInt32BE(4):c.readUInt32LE(4);let _=[],g=0;const k=(d,$,N)=>{try{const b=d.subarray($),y=this.leafParser.parse(b);if(y.blocksToFetch&&(_=_.concat(y.blocksToFetch.filter(w=>m(w)).map(w=>({offset:w.blockOffset,length:w.blockSize})))),y.recurOffsets){const w=y.recurOffsets.filter(v=>m(v)).map(v=>Number(v.blockOffset));w.length>0&&C(w,N+1)}}catch(b){a.error(b)}},m=d=>{const{startChrom:$,startBase:N,endChrom:b,endBase:y}=d;return($l||b===l&&y>=t)},E=async(d,$,N)=>{try{const b=$.max-$.min,y=$.min,w=await this.featureCache.get(`${b}_${y}`,{length:b,offset:y},r==null?void 0:r.signal);for(const v of d)$.contains(v)&&(k(w,v-y,N),g-=1,g===0&&this.readFeatures(a,_,{...r,request:p}).catch(x=>a.error(x)))}catch(b){a.error(b)}},C=(d,$)=>{try{g+=d.length;const N=4+Number(h)*32;let b=new pe([{min:d[0],max:d[0]+N}]);for(let y=1;yE(d,y,$))}catch(N){a.error(N)}};return C([Number(u)+48],1)}catch(o){a.error(o)}}parseSummaryBlock(n,t,i){const a=[];let r=t;const o=new DataView(n.buffer,n.byteOffset,n.length);for(;rNt(f.start,f.end,a.start,a.end)):r}parseBigWigBlock(n,t,i){const a=n.subarray(t),r=new DataView(a.buffer,a.byteOffset,a.length);let o=0;o+=4;const f=r.getInt32(o,!0);o+=8;const u=r.getUint32(o,!0);o+=4;const s=r.getUint32(o,!0);o+=4;const l=r.getUint8(o);o+=2;const p=r.getUint16(o,!0);o+=2;const c=new Array(p);switch(l){case 1:{for(let h=0;hNt(h.start,h.end,i.start,i.end)):c}async readFeatures(n,t,i={}){try{const{blockType:a,isCompressed:r}=this,{signal:o,request:f}=i,u=Fo(t);et(o),await Promise.all(u.map(async s=>{et(o);const{length:l,offset:p}=s,c=await this.featureCache.get(`${l}_${p}`,s,o);for(const h of s.blocks){et(o);let _=Number(h.offset)-Number(s.offset),g=c;switch(r&&(g=Vo(c.subarray(_)),_=0),et(o),a){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 ${a}`)}}})),n.complete()}catch(a){n.error(a)}}}var Ft=function(e,n){return Ft=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,i){t.__proto__=i}||function(t,i){for(var a in i)Object.prototype.hasOwnProperty.call(i,a)&&(t[a]=i[a])},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 a(r){return r instanceof t?r:new t(function(o){o(r)})}return new(t||(t=Promise))(function(r,o){function f(l){try{s(i.next(l))}catch(p){o(p)}}function u(l){try{s(i.throw(l))}catch(p){o(p)}}function s(l){l.done?r(l.value):a(l.value).then(f,u)}s((i=i.apply(e,n||[])).next())})}function Ai(e,n){var t={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},i,a,r,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,a&&(r=s[0]&2?a.return:s[0]?a.throw||((r=a.return)&&r.call(a),0):a.next)&&!(r=r.call(a,s[1])).done)return r;switch(a=0,r&&(s=[s[0]&2,r.value]),s[0]){case 0:case 1:r=s;break;case 4:return t.label++,{value:s[1],done:!1};case 5:t.label++,a=s[1],s=[0];continue;case 7:s=t.ops.pop(),t.trys.pop();continue;default:if(r=t.trys,!(r=r.length>0&&r[r.length-1])&&(s[0]===6||s[0]===2)){t=0;continue}if(s[0]===3&&(!r||s[1]>r[0]&&s[1]=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),a,r=[],o;try{for(;(n===void 0||n-- >0)&&!(a=i.next()).done;)r.push(a.value)}catch(f){o={error:f}}finally{try{a&&!a.done&&(t=i.return)&&t.call(i)}finally{if(o)throw o.error}}return r}function st(e,n,t){if(t||arguments.length===2)for(var i=0,a=n.length,r;i1||f(c,h)})})}function f(c,h){try{u(i[c](h))}catch(_){p(r[0][3],_)}}function u(c){c.value instanceof be?Promise.resolve(c.value.v).then(s,l):p(r[0][2],c)}function s(c){f("next",c)}function l(c){f("throw",c)}function p(c,h){c(h),r.shift(),r.length&&f(r[0][0],r[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(r){t[r]=e[r]&&function(o){return new Promise(function(f,u){o=e[r](o),a(f,u,o.done,o.value)})}}function a(r,o,f,u){Promise.resolve(u).then(function(s){r({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 xt=Oi(function(e){return function(t){e(this),this.message=t?t.length+` errors occurred during unsubscription: +`+t.map(function(i,a){return a+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,a,r;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){r=g instanceof xt?g.errors:[g]}var p=this._finalizers;if(p){this._finalizers=null;try{for(var c=Le(p),h=c.next();!h.done;h=c.next()){var _=h.value;try{Zn(_)}catch(g){r=r??[],g instanceof xt?r=st(st([],ot(r)),ot(g.errors)):r.push(g)}}}catch(g){i={error:g}}finally{try{h&&!h.done&&(a=c.return)&&a.call(c)}finally{if(i)throw i.error}}}if(r)throw new xt(r)}},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=2,!1,!0))}var Ns=function(e,n){return e.push(n),e};function xs(){return $e(function(e,n){er(Ns,[])(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 S().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 S().endianess(n).uint32("reductionLevel").uint32("reserved").uint64("dataOffset").uint64("indexOffset")}),i=new S().endianess(n).uint64("basesCovered").doublele("scoreMin").doublele("scoreMax").doublele("scoreSum").doublele("scoreSumSquares"),a=new S().endianess(n).uint32("magic").uint32("blockSize").uint32("keySize").uint32("valSize").uint64("itemCount"),r=new S().endianess(n).uint8("isLeafNode").skip(1).uint16("cnt").saveOffset("offset");return{chromTreeParser:a,totalSummaryParser:i,headerParser:t,isLeafNode:r}}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:a,url:r}=n;if(this.renameRefSeqs=i,t)this.bbi=t;else if(r)this.bbi=new ir(r);else if(a)this.bbi=new nr(a);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(J.Buffer.alloc(t),0,t,0,n),a=this._isBigEndian(i),r=Gn(a),o=r.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)),p=r.totalSummaryParser.parse(l);o.totalSummary={...p,basesCovered:Number(p.basesCovered)}}return{...o,isBigEndian:a}}_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,a=i?"big":"little",r=[],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(J.Buffer.alloc(s),0,s,Number(u),t),p=Gn(i),{keySize:c}=p.chromTreeParser.parse(l),h=new S().endianess(a).string("key",{stripNull:!0,length:c}).uint32("refId").uint32("refSize").saveOffset("offset"),_=new S().endianess(a).skip(c).uint64("childOffset").saveOffset("offset"),g=32,k=async m=>{let E=m;if(E>=l.length)throw new Error("reading beyond end of buffer");const C=p.isLeafNode.parse(l.subarray(E)),{isLeafNode:d,cnt:$}=C;if(E+=C.offset,d)for(let N=0;N<$;N+=1){const b=h.parse(l.subarray(E));E+=b.offset;const{key:y,refId:w,refSize:v}=b,x={name:y,id:w,length:v};o[this.renameRefSeqs(y)]=w,r[w]=x}else{const N=[];for(let b=0;b<$;b+=1){const y=_.parse(l.subarray(E)),{childOffset:w}=y;E+=y.offset,N.push(k(Number(w)-Number(u)))}await Promise.all(N)}};return await k(g),{refsByName:o,refsByNumber:r}}async getUnzoomedView(n){const{unzoomedIndexOffset:t,refsByName:i,uncompressBufSize:a,isBigEndian:r,fileType:o}=await this.getHeader(n);return new Ti(this.bbi,i,t,r,a>0,o)}async getFeatureStream(n,t,i,a){await this.getHeader(a);const r=this.renameRefSeqs(n);let o;const{basesPerSpan:f,scale:u}=a||{};return f?o=await this.getView(1/f,a):u?o=await this.getView(u,a):o=await this.getView(1,a),new P(s=>{o.readWigData(r,t,i,s,a).catch(l=>s.error(l))})}async getFeatures(n,t,i,a){const r=await this.getFeatureStream(n,t,i,a);return(await qi(r.pipe(xs()))).flat()}}class Ls extends tr{async getView(n,t){const{zoomLevels:i,refsByName:a,fileSize:r,isBigEndian:o,uncompressBufSize:f}=await this.getHeader(t),u=1/n;let s=i.length;r||(s-=1);for(let l=s;l>=0;l-=1){const p=i[l];if(p&&p.reductionLevel<=2*u){const c=Number(p.indexOffset);return new Ti(this.bbi,a,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:a}=await this.bbi.read(J.Buffer.alloc(64),0,64,Number(t)),r=i?"big":"little",o=new S().endianess(r).uint16("size").uint16("count").uint64("offset").parse(a),{count:f,offset:u}=o;if(f===0)return[];const s=20,l=s*f,{buffer:p}=await this.bbi.read(J.Buffer.alloc(l),0,l,Number(u)),c=new S().endianess(r).int16("type").int16("fieldcount").uint64("offset").skip(4).int16("field"),h=[];for(let _=0;_{const{offset:f,field:u}=o,{buffer:s}=await this.bbi.read(J.Buffer.alloc(32),0,32,Number(f),t),l=i?"big":"little",p=new S().endianess(l).int32("magic").int32("blockSize").int32("keySize").int32("valSize").uint64("itemCount"),{blockSize:c,keySize:h,valSize:_}=p.parse(s),g=new S().endianess(l).int8("nodeType").skip(1).int16("cnt").choice({tag:"nodeType",choices:{0:new S().array("leafkeys",{length:"cnt",type:new S().endianess(l).string("key",{length:h,stripNull:!0}).uint64("offset")}),1:new S().array("keys",{length:"cnt",type:new S().endianess(l).string("key",{length:h,stripNull:!0}).uint64("offset").uint32("length").uint32("reserved")})}}),k=async E=>{const C=Number(E),d=4+c*(h+_),{buffer:$}=await this.bbi.read(J.Buffer.alloc(d),0,d,C,t),N=g.parse($);if(N.leafkeys){let b;for(const{key:y,offset:w}of N.leafkeys){if(n.localeCompare(y)<0&&b)return k(b);b=w}return k(b)}for(const b of N.keys)if(b.key===n)return{...b,field:u}},m=32;return k(Number(f)+m)});return Ts(await Promise.all(r))}async searchExtraIndex(n,t={}){const i=await this.searchExtraIndexBlocks(n,t);if(i.length===0)return[];const a=await this.getUnzoomedView(t),r=i.map(f=>new P(u=>{a.readFeatures(u,[f],t).catch(s=>u.error(s))}).pipe(er((u,s)=>u.concat(s)),Ji(u=>{for(const s of u)s.field=f.field;return u})));return(await qi(Cs(...r))).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-785cda83.js b/segmentmodel/assets/index-785cda83.js new file mode 100644 index 0000000..0dda79d --- /dev/null +++ b/segmentmodel/assets/index-785cda83.js @@ -0,0 +1,522 @@ +var Hg=Object.defineProperty;var Wg=(t,e,n)=>e in t?Hg(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var ve=(t,e,n)=>(Wg(t,typeof e!="symbol"?e+"":e,n),n),rc=(t,e,n)=>{if(!e.has(t))throw TypeError("Cannot "+n)};var b=(t,e,n)=>(rc(t,e,"read from private field"),n?n.call(t):e.get(t)),F=(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)},k=(t,e,n,r)=>(rc(t,e,"write to private field"),r?r.call(t,n):e.set(t,n),n);var cf=(t,e,n,r)=>({set _(i){k(t,e,i,n)},get _(){return b(t,e,r)}}),D=(t,e,n)=>(rc(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 hi=globalThis,_o=hi.trustedTypes,uf=_o?_o.createPolicy("lit-html",{createHTML:t=>t}):void 0,gd="$lit$",Nt=`lit$${Math.random().toFixed(9).slice(2)}$`,yd="?"+Nt,qg=`<${yd}>`,Wn=document,wi=()=>Wn.createComment(""),Ai=t=>t===null||typeof t!="object"&&typeof t!="function",xd=Array.isArray,jg=t=>xd(t)||typeof(t==null?void 0:t[Symbol.iterator])=="function",ic=`[ +\f\r]`,ei=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,lf=/-->/g,ff=/>/g,yn=RegExp(`>|${ic}(?:([^\\s"'>=/]+)(${ic}*=${ic}*(?:[^ +\f\r"'\`<>=]|("|')|))|$)`,"g"),hf=/'/g,df=/"/g,bd=/^(?:script|style|textarea|title)$/i,Yg=t=>(e,...n)=>({_$litType$:t,strings:e,values:n}),z=Yg(1),Wt=Symbol.for("lit-noChange"),Q=Symbol.for("lit-nothing"),pf=new WeakMap,Sn=Wn.createTreeWalker(Wn,129);function wd(t,e){if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return uf!==void 0?uf.createHTML(e):e}const Xg=(t,e)=>{const n=t.length-1,r=[];let i,s=e===2?"":"",o=ei;for(let a=0;a"?(o=i??ei,l=-1):f[1]===void 0?l=-2:(l=o.lastIndex-f[2].length,u=f[1],o=f[3]===void 0?yn:f[3]==='"'?df:hf):o===df||o===hf?o=yn:o===lf||o===ff?o=ei:(o=yn,i=void 0);const p=o===yn&&t[a+1].startsWith("/>")?" ":"";s+=o===ei?c+qg:l>=0?(r.push(u),c.slice(0,l)+gd+c.slice(l)+Nt+p):c+Nt+(l===-2?a:p)}return[wd(t,s+(t[n]||"")+(e===2?"":"")),r]};class vi{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]=Xg(e,n);if(this.el=vi.createElement(u,r),Sn.currentNode=this.el.content,n===2){const l=this.el.content.firstChild;l.replaceWith(...l.childNodes)}for(;(i=Sn.nextNode())!==null&&c.length0){i.textContent=_o?_o.emptyScript:"";for(let p=0;p2||r[0]!==""||r[1]!==""?(this._$AH=Array(r.length-1).fill(new String),this.strings=r):this._$AH=Q}_$AI(e,n=this,r,i){const s=this.strings;let o=!1;if(s===void 0)e=kr(this,e,n,0),o=!Ai(e)||e!==this._$AH&&e!==Wt,o&&(this._$AH=e);else{const a=e;let c,u;for(e=s[0],c=0;c{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 Ts(e.insertBefore(wi(),s),s,void 0,n??{})}return i._$AI(t),i};/** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + */const Ad={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},vd=t=>(...e)=>({_$litDirective$:t,values:e});let Ed=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 mf=vd(class extends Ed{constructor(t){var e;if(super(t),t.type!==Ad.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.st===void 0){this.st=new Set,t.strings!==void 0&&(this.nt=new Set(t.strings.join(" ").split(/\s/).filter(s=>s!=="")));for(const s in e)e[s]&&!((r=this.nt)!=null&&r.has(s))&&this.st.add(s);return this.render(e)}const n=t.element.classList;for(const s of this.st)s in e||(n.remove(s),this.st.delete(s));for(const s in e){const o=!!e[s];o===this.st.has(s)||(i=this.nt)!=null&&i.has(s)||(o?(n.add(s),this.st.add(s)):(n.remove(s),this.st.delete(s)))}return Wt}});var gf={},io={},oc=34,xn=10,so=13;function Cd(t){return new Function("d","return {"+t.map(function(e,n){return JSON.stringify(e)+": d["+n+'] || ""'}).join(",")+"}")}function t1(t,e){var n=Cd(t);return function(r,i){return e(n(r),i,t)}}function yf(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 _e(t,e){var n=t+"",r=n.length;return r9999?"+"+_e(t,6):_e(t,4)}function r1(t){var e=t.getUTCHours(),n=t.getUTCMinutes(),r=t.getUTCSeconds(),i=t.getUTCMilliseconds();return isNaN(t)?"Invalid Date":n1(t.getUTCFullYear())+"-"+_e(t.getUTCMonth()+1,2)+"-"+_e(t.getUTCDate(),2)+(i?"T"+_e(e,2)+":"+_e(n,2)+":"+_e(r,2)+"."+_e(i,3)+"Z":r?"T"+_e(e,2)+":"+_e(n,2)+":"+_e(r,2)+"Z":n||e?"T"+_e(e,2)+":"+_e(n,2)+"Z":"")}function Sd(t,e){var n=new RegExp('["'+t+` +\r]`),r=t.charCodeAt(0);function i(h,p){var d,m,g=s(h,function(y,x){if(d)return d(y,x-1);m=y,d=p?t1(y,p):Cd(y)});return g.columns=m||[],g}function s(h,p){var d=[],m=h.length,g=0,y=0,x,w=m<=0,v=!1,C=!0,S=e?e.comment:void 0;h.charCodeAt(m-1)===xn&&--m,h.charCodeAt(m-1)===so&&--m;function E(){if(w)return io;if(v)return v=!1,C=!0,gf;if(C&&S){for(;;){let q=0;for(;q=m)return io}C=!1;var P,O=g,R;if(h.charCodeAt(O)===oc){for(;g++=m?w=!0:(R=h.charCodeAt(g++))===xn?v=!0:R===so&&(v=!0,h.charCodeAt(g)===xn&&++g),h.slice(O+1,P-1).replace(/""/g,'"')}for(;gfunction(e){return e[t]},l1=t=>{const e=t.length;return function(n){for(let r=0;ro?u():o=a+1:c==="["?(a>o&&u(),i=o=a+1):c==="]"&&(i||te("Access path missing open bracket: "+t),i>0&&u(),i=0,o=a+1)}return i&&te("Access path missing closing bracket: "+t),r&&te("Access path missing closing quote: "+t),a>o&&(a++,u()),e}function ya(t,e,n){const r=f1(t);return t=r.length===1?r[0]:t,rn((n&&n.get||c1)(r),[t],e||t)}ya("id");const xa=rn(t=>t,[],"identity");rn(()=>0,[],"zero");rn(()=>1,[],"one");rn(()=>!0,[],"true");rn(()=>!1,[],"false");var he=Array.isArray;function be(t){return t===Object(t)}function nt(t){return t[t.length-1]}function Ei(t){return t==null||t===""?null:+t}const Fd=t=>e=>t*Math.exp(e),Td=t=>e=>Math.log(t*e),h1=t=>e=>Math.sign(e)*Math.log1p(Math.abs(e/t)),d1=t=>e=>Math.sign(e)*Math.expm1(Math.abs(e))*t,Io=t=>e=>e<0?-Math.pow(-e,t):Math.pow(e,t);function Xu(t,e,n,r){const i=n(t[0]),s=n(nt(t)),o=(s-i)*e;return[r(i-o),r(s-o)]}function p1(t,e){return Xu(t,e,Ei,xa)}function m1(t,e){var n=Math.sign(t[0]);return Xu(t,e,Td(n),Fd(n))}function g1(t,e,n){return Xu(t,e,Io(n),Io(1/n))}function ba(t,e,n,r,i){const s=r(t[0]),o=r(nt(t)),a=e!=null?r(e):(s+o)/2;return[i(a+(s-a)*n),i(a+(o-a)*n)]}function Dd(t,e,n){return ba(t,e,n,Ei,xa)}function _d(t,e,n){const r=Math.sign(t[0]);return ba(t,e,n,Td(r),Fd(r))}function Nc(t,e,n,r){return ba(t,e,n,Io(r),Io(1/r))}function y1(t,e,n,r){return ba(t,e,n,h1(r),d1(r))}function $c(t){return t!=null?he(t)?t:[t]:[]}function x1(t,e,n){let r=t[0],i=t[1],s;return i=n-e?[e,n]:[r=Math.min(Math.max(r,e),n-s),r+s]}function je(t){return typeof t=="function"}const b1="descending";function Id(t,e,n){n=n||{},e=$c(e)||[];const r=[],i=[],s={},o=n.comparator||w1;return $c(t).forEach((a,c)=>{a!=null&&(r.push(e[c]===b1?-1:1),i.push(a=je(a)?a:ya(a,null,n)),(a1(a)||[]).forEach(u=>s[u]=1))}),i.length===0?null:rn(o(i,r),Object.keys(s))}const Rd=(t,e)=>(te||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),w1=(t,e)=>t.length===1?A1(t[0],e[0]):v1(t,e,t.length),A1=(t,e)=>function(n,r){return Rd(t(n),t(r))*e},v1=(t,e,n)=>(e.push(0),function(r,i){let s,o=0,a=-1;for(;o===0&&++aCe(t)||S1(t)?t:Date.parse(t);function I1(t,e){return e=e||_1,t==null||t===""?null:e(t)}function R1(t){return t==null||t===""?null:t+""}function Mo(t){const e={},n=t.length;for(let r=0;rnew M1(typeof t=="string"?t:t+"",void 0,kd),B1=(t,e)=>{if(Ju)t.adoptedStyleSheets=e.map(n=>n instanceof CSSStyleSheet?n:n.styleSheet);else for(const n of e){const r=document.createElement("style"),i=wo.litNonce;i!==void 0&&r.setAttribute("nonce",i),r.textContent=n.cssText,t.appendChild(r)}},bf=Ju?t=>t:t=>t instanceof CSSStyleSheet?(e=>{let n="";for(const r of e.cssRules)n+=r.cssText;return k1(n)})(t):t;/** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + */const{is:P1,defineProperty:O1,getOwnPropertyDescriptor:L1,getOwnPropertyNames:N1,getOwnPropertySymbols:$1,getPrototypeOf:U1}=Object,Gt=globalThis,wf=Gt.trustedTypes,z1=wf?wf.emptyScript:"",ac=Gt.reactiveElementPolyfillSupport,di=(t,e)=>t,Uc={toAttribute(t,e){switch(e){case Boolean:t=t?z1:null;break;case Object:case Array:t=t==null?t:JSON.stringify(t)}return t},fromAttribute(t,e){let n=t;switch(e){case Boolean:n=t!==null;break;case Number:n=t===null?null:Number(t);break;case Object:case Array:try{n=JSON.parse(t)}catch{n=null}}return n}},Bd=(t,e)=>!P1(t,e),Af={attribute:!0,type:String,converter:Uc,reflect:!1,hasChanged:Bd};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),Gt.litPropertyMetadata??(Gt.litPropertyMetadata=new WeakMap);class cr extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??(this.l=[])).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,n=Af){if(n.state&&(n.attribute=!1),this._$Ei(),this.elementProperties.set(e,n),!n.noAccessor){const r=Symbol(),i=this.getPropertyDescriptor(e,r,n);i!==void 0&&O1(this.prototype,e,i)}}static getPropertyDescriptor(e,n,r){const{get:i,set:s}=L1(this.prototype,e)??{get(){return this[n]},set(o){this[n]=o}};return{get(){return i==null?void 0:i.call(this)},set(o){const a=i==null?void 0:i.call(this);s.call(this,o),this.requestUpdate(e,a,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??Af}static _$Ei(){if(this.hasOwnProperty(di("elementProperties")))return;const e=U1(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(di("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(di("properties"))){const n=this.properties,r=[...N1(n),...$1(n)];for(const i of r)this.createProperty(i,n[i])}const e=this[Symbol.metadata];if(e!==null){const n=litPropertyMetadata.get(e);if(n!==void 0)for(const[r,i]of n)this.elementProperties.set(r,i)}this._$Eh=new Map;for(const[n,r]of this.elementProperties){const i=this._$Eu(n,r);i!==void 0&&this._$Eh.set(i,n)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){const n=[];if(Array.isArray(e)){const r=new Set(e.flat(1/0).reverse());for(const i of r)n.unshift(bf(i))}else e!==void 0&&n.push(bf(e));return n}static _$Eu(e,n){const r=n.attribute;return r===!1?void 0:typeof r=="string"?r:typeof e=="string"?e.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){var e;this._$ES=new Promise(n=>this.enableUpdating=n),this._$AL=new Map,this._$E_(),this.requestUpdate(),(e=this.constructor.l)==null||e.forEach(n=>n(this))}addController(e){var n;(this._$EO??(this._$EO=new Set)).add(e),this.renderRoot!==void 0&&this.isConnected&&((n=e.hostConnected)==null||n.call(e))}removeController(e){var n;(n=this._$EO)==null||n.delete(e)}_$E_(){const e=new Map,n=this.constructor.elementProperties;for(const r of n.keys())this.hasOwnProperty(r)&&(e.set(r,this[r]),delete this[r]);e.size>0&&(this._$Ep=e)}createRenderRoot(){const e=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return B1(e,this.constructor.elementStyles),e}connectedCallback(){var e;this.renderRoot??(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(e=this._$EO)==null||e.forEach(n=>{var r;return(r=n.hostConnected)==null?void 0:r.call(n)})}enableUpdating(e){}disconnectedCallback(){var e;(e=this._$EO)==null||e.forEach(n=>{var r;return(r=n.hostDisconnected)==null?void 0:r.call(n)})}attributeChangedCallback(e,n,r){this._$AK(e,r)}_$EC(e,n){var s;const r=this.constructor.elementProperties.get(e),i=this.constructor._$Eu(e,r);if(i!==void 0&&r.reflect===!0){const o=(((s=r.converter)==null?void 0:s.toAttribute)!==void 0?r.converter:Uc).toAttribute(n,r.type);this._$Em=e,o==null?this.removeAttribute(i):this.setAttribute(i,o),this._$Em=null}}_$AK(e,n){var s;const r=this.constructor,i=r._$Eh.get(e);if(i!==void 0&&this._$Em!==i){const o=r.getPropertyOptions(i),a=typeof o.converter=="function"?{fromAttribute:o.converter}:((s=o.converter)==null?void 0:s.fromAttribute)!==void 0?o.converter:Uc;this._$Em=i,this[i]=a.fromAttribute(n,o.type),this._$Em=null}}requestUpdate(e,n,r){if(e!==void 0){if(r??(r=this.constructor.getPropertyOptions(e)),!(r.hasChanged??Bd)(this[e],n))return;this.P(e,n,r)}this.isUpdatePending===!1&&(this._$ES=this._$ET())}P(e,n,r){this._$AL.has(e)||this._$AL.set(e,n),r.reflect===!0&&this._$Em!==e&&(this._$Ej??(this._$Ej=new Set)).add(e)}async _$ET(){this.isUpdatePending=!0;try{await this._$ES}catch(n){Promise.reject(n)}const e=this.scheduleUpdate();return e!=null&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var r;if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??(this.renderRoot=this.createRenderRoot()),this._$Ep){for(const[s,o]of this._$Ep)this[s]=o;this._$Ep=void 0}const i=this.constructor.elementProperties;if(i.size>0)for(const[s,o]of i)o.wrapped!==!0||this._$AL.has(s)||this[s]===void 0||this.P(s,this[s],o)}let e=!1;const n=this._$AL;try{e=this.shouldUpdate(n),e?(this.willUpdate(n),(r=this._$EO)==null||r.forEach(i=>{var s;return(s=i.hostUpdate)==null?void 0:s.call(i)}),this.update(n)):this._$EU()}catch(i){throw e=!1,this._$EU(),i}e&&this._$AE(n)}willUpdate(e){}_$AE(e){var n;(n=this._$EO)==null||n.forEach(r=>{var i;return(i=r.hostUpdated)==null?void 0:i.call(r)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$EU(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(e){return!0}update(e){this._$Ej&&(this._$Ej=this._$Ej.forEach(n=>this._$EC(n,this[n]))),this._$EU()}updated(e){}firstUpdated(e){}}cr.elementStyles=[],cr.shadowRootOptions={mode:"open"},cr[di("elementProperties")]=new Map,cr[di("finalized")]=new Map,ac==null||ac({ReactiveElement:cr}),(Gt.reactiveElementVersions??(Gt.reactiveElementVersions=[])).push("2.0.4");/** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + */class Ao extends cr{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var n;const e=super.createRenderRoot();return(n=this.renderOptions).renderBefore??(n.renderBefore=e.firstChild),e}update(e){const n=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=qn(n,this.renderRoot,this.renderOptions)}connectedCallback(){var e;super.connectedCallback(),(e=this._$Do)==null||e.setConnected(!0)}disconnectedCallback(){var e;super.disconnectedCallback(),(e=this._$Do)==null||e.setConnected(!1)}render(){return Wt}}var md;Ao._$litElement$=!0,Ao.finalized=!0,(md=globalThis.litElementHydrateSupport)==null||md.call(globalThis,{LitElement:Ao});const cc=globalThis.litElementPolyfillSupport;cc==null||cc({LitElement:Ao});(globalThis.litElementVersions??(globalThis.litElementVersions=[])).push("4.0.6");var vf={},uc={},lc=34,ti=10,fc=13;function Pd(t){return new Function("d","return {"+t.map(function(e,n){return JSON.stringify(e)+": d["+n+'] || ""'}).join(",")+"}")}function V1(t,e){var n=Pd(t);return function(r,i){return e(n(r),i,t)}}function Ef(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 Ie(t,e){var n=t+"",r=n.length;return r9999?"+"+Ie(t,6):Ie(t,4)}function H1(t){var e=t.getUTCHours(),n=t.getUTCMinutes(),r=t.getUTCSeconds(),i=t.getUTCMilliseconds();return isNaN(t)?"Invalid Date":G1(t.getUTCFullYear())+"-"+Ie(t.getUTCMonth()+1,2)+"-"+Ie(t.getUTCDate(),2)+(i?"T"+Ie(e,2)+":"+Ie(n,2)+":"+Ie(r,2)+"."+Ie(i,3)+"Z":r?"T"+Ie(e,2)+":"+Ie(n,2)+":"+Ie(r,2)+"Z":n||e?"T"+Ie(e,2)+":"+Ie(n,2)+"Z":"")}function W1(t){var e=new RegExp('["'+t+` +\r]`),n=t.charCodeAt(0);function r(l,h){var p,d,m=i(l,function(g,y){if(p)return p(g,y-1);d=g,p=h?V1(g,h):Pd(g)});return m.columns=d||[],m}function i(l,h){var p=[],d=l.length,m=0,g=0,y,x=d<=0,w=!1;l.charCodeAt(d-1)===ti&&--d,l.charCodeAt(d-1)===fc&&--d;function v(){if(x)return uc;if(w)return w=!1,vf;var S,E=m,M;if(l.charCodeAt(E)===lc){for(;m++=d?x=!0:(M=l.charCodeAt(m++))===ti?w=!0:M===fc&&(w=!0,l.charCodeAt(m)===ti&&++m),l.slice(E+1,S-1).replace(/""/g,'"')}for(;m1)r=Q1(t,e,n);else for(i=0,r=new Array(s=t.arcs.length);ie?1:t>=e?0:NaN}function ey(t,e){return t==null||e==null?NaN:et?1:e>=t?0:NaN}function Br(t){let e,n,r;t.length!==2?(e=pi,n=(a,c)=>pi(t(a),c),r=(a,c)=>t(a)-c):(e=t===pi||t===ey?t:ty,n=t,r=t);function i(a,c,u=0,f=a.length){if(u>>1;n(a[l],c)<0?u=l+1:f=l}while(u>>1;n(a[l],c)<=0?u=l+1:f=l}while(uu&&r(a[l-1],c)>-r(a[l],c)?l-1:l}return{left:i,center:o,right:s}}function ty(){return 0}function Ld(t){return t===null?NaN:+t}const Nd=Br(pi),zc=Nd.right;Nd.left;Br(Ld).center;const Wr=zc;function ny(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=s&&(n=r=s):(n>s&&(n=s),r=r.length)return n(s);const a=new Mt,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 ay=Math.sqrt(50),cy=Math.sqrt(10),uy=Math.sqrt(2);function ko(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>=ay?10:s>=cy?5:s>=uy?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/ue&&--c,u=-u):(u=Math.pow(10,i)*o,a=Math.round(t/u),c=Math.round(e/u),a*ue&&--c),c0))return[];if(t===e)return[t];const r=e=i))return[];const a=s-i+1,c=new Array(a);if(r)if(o<0)for(let u=0;u=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 Ci(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=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)}function Po(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 Pr(t){return t=Po(Math.abs(t)),t?t[1]:NaN}function fy(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 hy(t){return function(e){return e.replace(/[0-9]/g,function(n){return t[+n]})}}var dy=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function jt(t){if(!(e=dy.exec(t)))throw new Error("invalid format: "+t);var e;return new Zu({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]})}jt.prototype=Zu.prototype;function Zu(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+""}Zu.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 py(t){e:for(var e=t.length,n=1,r=-1,i;n0&&(r=0);break}return r>0?t.slice(0,r)+t.slice(i+1):t}var zd;function my(t,e){var n=Po(t,e);if(!n)return t+"";var r=n[0],i=n[1],s=i-(zd=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")+Po(t,Math.max(0,e+s-1))[0]}function Ff(t,e){var n=Po(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 Tf={"%":(t,e)=>(t*100).toFixed(e),b:t=>Math.round(t).toString(2),c:t=>t+"",d:ly,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)=>Ff(t*100,e),r:Ff,s:my,X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function Df(t){return t}var _f=Array.prototype.map,If=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function gy(t){var e=t.grouping===void 0||t.thousands===void 0?Df:fy(_f.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?Df:hy(_f.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=jt(l);var h=l.fill,p=l.align,d=l.sign,m=l.symbol,g=l.zero,y=l.width,x=l.comma,w=l.precision,v=l.trim,C=l.type;C==="n"?(x=!0,C="g"):Tf[C]||(w===void 0&&(w=12),v=!0,C="g"),(g||h==="0"&&p==="=")&&(g=!0,h="0",p="=");var S=m==="$"?n:m==="#"&&/[boxX]/.test(C)?"0"+C.toLowerCase():"",E=m==="$"?r:/[%p]/.test(C)?o:"",M=Tf[C],P=/[defgprs%]/.test(C);w=w===void 0?6:/[gprs]/.test(C)?Math.max(1,Math.min(21,w)):Math.max(0,Math.min(20,w));function O(R){var q=S,J=E,we,We,Ae;if(C==="c")J=M(R)+J,R="";else{R=+R;var Oe=R<0||1/R<0;if(R=isNaN(R)?c:M(Math.abs(R),w),v&&(R=py(R)),Oe&&+R==0&&d!=="+"&&(Oe=!1),q=(Oe?d==="("?d:a:d==="-"||d==="("?"":d)+q,J=(C==="s"?If[8+zd/3]:"")+J+(Oe&&d==="("?")":""),P){for(we=-1,We=R.length;++weAe||Ae>57){J=(Ae===46?i+R.slice(we+1):R.slice(we))+J,R=R.slice(0,we);break}}}x&&!g&&(R=e(R,1/0));var Te=q.length+R.length+J.length,de=Te>1)+q+R+J+de.slice(Te);break;default:R=de+q+R+J;break}return s(R)}return O.toString=function(){return l+""},O}function f(l,h){var p=u((l=jt(l),l.type="f",l)),d=Math.max(-8,Math.min(8,Math.floor(Pr(h)/3)))*3,m=Math.pow(10,-d),g=If[8+d/3];return function(y){return p(m*y)+g}}return{format:u,formatPrefix:f}}var ao,fe,Qu;yy({thousands:",",grouping:[3],currency:["$",""]});function yy(t){return ao=gy(t),fe=ao.format,Qu=ao.formatPrefix,ao}function Vd(t){return Math.max(0,-Pr(Math.abs(t)))}function Gd(t,e){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(Pr(e)/3)))*3-Pr(Math.abs(t)))}function Hd(t,e){return t=Math.abs(t),e=Math.abs(e)-t,Math.max(0,Pr(e)-Pr(t))+1}const hc=new Date,dc=new Date;function ne(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(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),!(s0))return c;let u;do c.push(u=new Date(+s)),e(s,a),t(s);while(une(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)=>(hc.setTime(+s),dc.setTime(+o),t(hc),t(dc),Math.floor(n(hc,dc))),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 Or=ne(()=>{},(t,e)=>{t.setTime(+t+e)},(t,e)=>e-t);Or.every=t=>(t=Math.floor(t),!isFinite(t)||!(t>0)?null:t>1?ne(e=>{e.setTime(Math.floor(e/t)*t)},(e,n)=>{e.setTime(+e+n*t)},(e,n)=>(n-e)/t):Or);Or.range;const Tt=1e3,qe=Tt*60,Dt=qe*60,kt=Dt*24,el=kt*7,Rf=kt*30,pc=kt*365,_t=ne(t=>{t.setTime(t-t.getMilliseconds())},(t,e)=>{t.setTime(+t+e*Tt)},(t,e)=>(e-t)/Tt,t=>t.getUTCSeconds());_t.range;const Aa=ne(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*Tt)},(t,e)=>{t.setTime(+t+e*qe)},(t,e)=>(e-t)/qe,t=>t.getMinutes());Aa.range;const va=ne(t=>{t.setUTCSeconds(0,0)},(t,e)=>{t.setTime(+t+e*qe)},(t,e)=>(e-t)/qe,t=>t.getUTCMinutes());va.range;const Ea=ne(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*Tt-t.getMinutes()*qe)},(t,e)=>{t.setTime(+t+e*Dt)},(t,e)=>(e-t)/Dt,t=>t.getHours());Ea.range;const Ca=ne(t=>{t.setUTCMinutes(0,0,0)},(t,e)=>{t.setTime(+t+e*Dt)},(t,e)=>(e-t)/Dt,t=>t.getUTCHours());Ca.range;const Ht=ne(t=>t.setHours(0,0,0,0),(t,e)=>t.setDate(t.getDate()+e),(t,e)=>(e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*qe)/kt,t=>t.getDate()-1);Ht.range;const Un=ne(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/kt,t=>t.getUTCDate()-1);Un.range;const Wd=ne(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/kt,t=>Math.floor(t/kt));Wd.range;function Zn(t){return ne(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())*qe)/el)}const _s=Zn(0),Oo=Zn(1),xy=Zn(2),by=Zn(3),Lr=Zn(4),wy=Zn(5),Ay=Zn(6);_s.range;Oo.range;xy.range;by.range;Lr.range;wy.range;Ay.range;function Qn(t){return ne(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)/el)}const Is=Qn(0),Lo=Qn(1),vy=Qn(2),Ey=Qn(3),Nr=Qn(4),Cy=Qn(5),Sy=Qn(6);Is.range;Lo.range;vy.range;Ey.range;Nr.range;Cy.range;Sy.range;const Si=ne(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());Si.range;const Fi=ne(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());Fi.range;const dt=ne(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());dt.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:ne(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)});dt.range;const pt=ne(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());pt.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:ne(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)});pt.range;function qd(t,e,n,r,i,s){const o=[[_t,1,Tt],[_t,5,5*Tt],[_t,15,15*Tt],[_t,30,30*Tt],[s,1,qe],[s,5,5*qe],[s,15,15*qe],[s,30,30*qe],[i,1,Dt],[i,3,3*Dt],[i,6,6*Dt],[i,12,12*Dt],[r,1,kt],[r,2,2*kt],[n,1,el],[e,1,Rf],[e,3,3*Rf],[t,1,pc]];function a(u,f,l){const h=fg).right(o,h);if(p===o.length)return t.every(qt(u/pc,f/pc,l));if(p===0)return Or.every(Math.max(qt(u,f,l),1));const[d,m]=o[h/o[p-1][2](t[e]=1+n,t),{});const Ry={[Ti]:dt,[Di]:Si.every(3),[_i]:Si,[Ii]:_s,[Ri]:Ht,[Sa]:Ht,[tl]:Ht,[Mi]:Ea,[ki]:Aa,[Bi]:_t,[Fa]:Or},My={[Ti]:pt,[Di]:Fi.every(3),[_i]:Fi,[Ii]:Is,[Ri]:Un,[Sa]:Un,[tl]:Un,[Mi]:Ca,[ki]:va,[Bi]:_t,[Fa]:Or};function ky(t){return Ry[t]}function By(t){return My[t]}function mc(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 gc(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 ni(t,e,n){return{y:t,m:e,d:n,H:0,M:0,S:0,L:0}}function jd(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=ri(i),f=ii(i),l=ri(s),h=ii(s),p=ri(o),d=ii(o),m=ri(a),g=ii(a),y=ri(c),x=ii(c),w={a:Oe,A:Te,b:de,B:Le,c:null,d:Lf,e:Lf,f:rx,g:dx,G:mx,H:ex,I:tx,j:nx,L:Yd,m:ix,M:sx,p:no,q:mn,Q:Uf,s:zf,S:ox,u:ax,U:cx,V:ux,w:lx,W:fx,x:null,X:null,y:hx,Y:px,Z:gx,"%":$f},v={a:Zr,A:ro,b:ce,B:st,c:null,d:Nf,e:Nf,f:wx,g:Ix,G:Mx,H:yx,I:xx,j:bx,L:Kd,m:Ax,M:vx,p:Ke,q:Qr,Q:Uf,s:zf,S:Ex,u:Cx,U:Sx,V:Fx,w:Tx,W:Dx,x:null,X:null,y:_x,Y:Rx,Z:kx,"%":$f},C={a:O,A:R,b:q,B:J,c:we,d:Pf,e:Pf,f:Ky,g:Bf,G:kf,H:Of,I:Of,j:qy,L:Xy,m:Wy,M:jy,p:P,q:Hy,Q:Zy,s:Qy,S:Yy,u:$y,U:Uy,V:zy,w:Ny,W:Vy,x:We,X:Ae,y:Bf,Y:kf,Z:Gy,"%":Jy};w.x=S(n,w),w.X=S(r,w),w.c=S(e,w),v.x=S(n,v),v.X=S(r,v),v.c=S(e,v);function S(_,L){return function(N){var T=[],De=-1,j=0,Ne=_.length,$e,gn,af;for(N instanceof Date||(N=new Date(+N));++De53)return null;"w"in T||(T.w=1),"Z"in T?(j=gc(ni(T.y,0,1)),Ne=j.getUTCDay(),j=Ne>4||Ne===0?Lo.ceil(j):Lo(j),j=Un.offset(j,(T.V-1)*7),T.y=j.getUTCFullYear(),T.m=j.getUTCMonth(),T.d=j.getUTCDate()+(T.w+6)%7):(j=mc(ni(T.y,0,1)),Ne=j.getDay(),j=Ne>4||Ne===0?Oo.ceil(j):Oo(j),j=Ht.offset(j,(T.V-1)*7),T.y=j.getFullYear(),T.m=j.getMonth(),T.d=j.getDate()+(T.w+6)%7)}else("W"in T||"U"in T)&&("w"in T||(T.w="u"in T?T.u%7:"W"in T?1:0),Ne="Z"in T?gc(ni(T.y,0,1)).getUTCDay():mc(ni(T.y,0,1)).getDay(),T.m=0,T.d="W"in T?(T.w+6)%7+T.W*7-(Ne+5)%7:T.w+T.U*7-(Ne+6)%7);return"Z"in T?(T.H+=T.Z/100|0,T.M+=T.Z%100,gc(T)):mc(T)}}function M(_,L,N,T){for(var De=0,j=L.length,Ne=N.length,$e,gn;De=Ne)return-1;if($e=L.charCodeAt(De++),$e===37){if($e=L.charAt(De++),gn=C[$e in Mf?L.charAt(De++):$e],!gn||(T=gn(_,N,T))<0)return-1}else if($e!=N.charCodeAt(T++))return-1}return T}function P(_,L,N){var T=u.exec(L.slice(N));return T?(_.p=f.get(T[0].toLowerCase()),N+T[0].length):-1}function O(_,L,N){var T=p.exec(L.slice(N));return T?(_.w=d.get(T[0].toLowerCase()),N+T[0].length):-1}function R(_,L,N){var T=l.exec(L.slice(N));return T?(_.w=h.get(T[0].toLowerCase()),N+T[0].length):-1}function q(_,L,N){var T=y.exec(L.slice(N));return T?(_.m=x.get(T[0].toLowerCase()),N+T[0].length):-1}function J(_,L,N){var T=m.exec(L.slice(N));return T?(_.m=g.get(T[0].toLowerCase()),N+T[0].length):-1}function we(_,L,N){return M(_,e,L,N)}function We(_,L,N){return M(_,n,L,N)}function Ae(_,L,N){return M(_,r,L,N)}function Oe(_){return o[_.getDay()]}function Te(_){return s[_.getDay()]}function de(_){return c[_.getMonth()]}function Le(_){return a[_.getMonth()]}function no(_){return i[+(_.getHours()>=12)]}function mn(_){return 1+~~(_.getMonth()/3)}function Zr(_){return o[_.getUTCDay()]}function ro(_){return s[_.getUTCDay()]}function ce(_){return c[_.getUTCMonth()]}function st(_){return a[_.getUTCMonth()]}function Ke(_){return i[+(_.getUTCHours()>=12)]}function Qr(_){return 1+~~(_.getUTCMonth()/3)}return{format:function(_){var L=S(_+="",w);return L.toString=function(){return _},L},parse:function(_){var L=E(_+="",!1);return L.toString=function(){return _},L},utcFormat:function(_){var L=S(_+="",v);return L.toString=function(){return _},L},utcParse:function(_){var L=E(_+="",!0);return L.toString=function(){return _},L}}}var Mf={"-":"",_:" ",0:"0"},ae=/^\s*\d+/,Py=/^%/,Oy=/[\\^$*+?|[\]().{}]/g;function U(t,e,n){var r=t<0?"-":"",i=(r?-t:t)+"",s=i.length;return r+(s[e.toLowerCase(),n]))}function Ny(t,e,n){var r=ae.exec(e.slice(n,n+1));return r?(t.w=+r[0],n+r[0].length):-1}function $y(t,e,n){var r=ae.exec(e.slice(n,n+1));return r?(t.u=+r[0],n+r[0].length):-1}function Uy(t,e,n){var r=ae.exec(e.slice(n,n+2));return r?(t.U=+r[0],n+r[0].length):-1}function zy(t,e,n){var r=ae.exec(e.slice(n,n+2));return r?(t.V=+r[0],n+r[0].length):-1}function Vy(t,e,n){var r=ae.exec(e.slice(n,n+2));return r?(t.W=+r[0],n+r[0].length):-1}function kf(t,e,n){var r=ae.exec(e.slice(n,n+4));return r?(t.y=+r[0],n+r[0].length):-1}function Bf(t,e,n){var r=ae.exec(e.slice(n,n+2));return r?(t.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function Gy(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 Hy(t,e,n){var r=ae.exec(e.slice(n,n+1));return r?(t.q=r[0]*3-3,n+r[0].length):-1}function Wy(t,e,n){var r=ae.exec(e.slice(n,n+2));return r?(t.m=r[0]-1,n+r[0].length):-1}function Pf(t,e,n){var r=ae.exec(e.slice(n,n+2));return r?(t.d=+r[0],n+r[0].length):-1}function qy(t,e,n){var r=ae.exec(e.slice(n,n+3));return r?(t.m=0,t.d=+r[0],n+r[0].length):-1}function Of(t,e,n){var r=ae.exec(e.slice(n,n+2));return r?(t.H=+r[0],n+r[0].length):-1}function jy(t,e,n){var r=ae.exec(e.slice(n,n+2));return r?(t.M=+r[0],n+r[0].length):-1}function Yy(t,e,n){var r=ae.exec(e.slice(n,n+2));return r?(t.S=+r[0],n+r[0].length):-1}function Xy(t,e,n){var r=ae.exec(e.slice(n,n+3));return r?(t.L=+r[0],n+r[0].length):-1}function Ky(t,e,n){var r=ae.exec(e.slice(n,n+6));return r?(t.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function Jy(t,e,n){var r=Py.exec(e.slice(n,n+1));return r?n+r[0].length:-1}function Zy(t,e,n){var r=ae.exec(e.slice(n));return r?(t.Q=+r[0],n+r[0].length):-1}function Qy(t,e,n){var r=ae.exec(e.slice(n));return r?(t.s=+r[0],n+r[0].length):-1}function Lf(t,e){return U(t.getDate(),e,2)}function ex(t,e){return U(t.getHours(),e,2)}function tx(t,e){return U(t.getHours()%12||12,e,2)}function nx(t,e){return U(1+Ht.count(dt(t),t),e,3)}function Yd(t,e){return U(t.getMilliseconds(),e,3)}function rx(t,e){return Yd(t,e)+"000"}function ix(t,e){return U(t.getMonth()+1,e,2)}function sx(t,e){return U(t.getMinutes(),e,2)}function ox(t,e){return U(t.getSeconds(),e,2)}function ax(t){var e=t.getDay();return e===0?7:e}function cx(t,e){return U(_s.count(dt(t)-1,t),e,2)}function Xd(t){var e=t.getDay();return e>=4||e===0?Lr(t):Lr.ceil(t)}function ux(t,e){return t=Xd(t),U(Lr.count(dt(t),t)+(dt(t).getDay()===4),e,2)}function lx(t){return t.getDay()}function fx(t,e){return U(Oo.count(dt(t)-1,t),e,2)}function hx(t,e){return U(t.getFullYear()%100,e,2)}function dx(t,e){return t=Xd(t),U(t.getFullYear()%100,e,2)}function px(t,e){return U(t.getFullYear()%1e4,e,4)}function mx(t,e){var n=t.getDay();return t=n>=4||n===0?Lr(t):Lr.ceil(t),U(t.getFullYear()%1e4,e,4)}function gx(t){var e=t.getTimezoneOffset();return(e>0?"-":(e*=-1,"+"))+U(e/60|0,"0",2)+U(e%60,"0",2)}function Nf(t,e){return U(t.getUTCDate(),e,2)}function yx(t,e){return U(t.getUTCHours(),e,2)}function xx(t,e){return U(t.getUTCHours()%12||12,e,2)}function bx(t,e){return U(1+Un.count(pt(t),t),e,3)}function Kd(t,e){return U(t.getUTCMilliseconds(),e,3)}function wx(t,e){return Kd(t,e)+"000"}function Ax(t,e){return U(t.getUTCMonth()+1,e,2)}function vx(t,e){return U(t.getUTCMinutes(),e,2)}function Ex(t,e){return U(t.getUTCSeconds(),e,2)}function Cx(t){var e=t.getUTCDay();return e===0?7:e}function Sx(t,e){return U(Is.count(pt(t)-1,t),e,2)}function Jd(t){var e=t.getUTCDay();return e>=4||e===0?Nr(t):Nr.ceil(t)}function Fx(t,e){return t=Jd(t),U(Nr.count(pt(t),t)+(pt(t).getUTCDay()===4),e,2)}function Tx(t){return t.getUTCDay()}function Dx(t,e){return U(Lo.count(pt(t)-1,t),e,2)}function _x(t,e){return U(t.getUTCFullYear()%100,e,2)}function Ix(t,e){return t=Jd(t),U(t.getUTCFullYear()%100,e,2)}function Rx(t,e){return U(t.getUTCFullYear()%1e4,e,4)}function Mx(t,e){var n=t.getUTCDay();return t=n>=4||n===0?Nr(t):Nr.ceil(t),U(t.getUTCFullYear()%1e4,e,4)}function kx(){return"+0000"}function $f(){return"%"}function Uf(t){return+t}function zf(t){return Math.floor(+t/1e3)}var nr,nl,Zd,rl,Qd;Bx({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 Bx(t){return nr=jd(t),nl=nr.format,Zd=nr.parse,rl=nr.utcFormat,Qd=nr.utcParse,nr}function ai(t){const e={};return n=>e[n]||(e[n]=t(n))}function Px(t,e){return n=>{const r=t(n),i=r.indexOf(e);if(i<0)return r;let s=Ox(r,i);const o=si;)if(r[s]!=="0"){++s;break}return r.slice(0,s)+o}}function Ox(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 Lx(t){const e=ai(t.format),n=t.formatPrefix;return{format:e,formatPrefix:n,formatFloat(r){const i=jt(r||",");if(i.precision==null){switch(i.precision=12,i.type){case"%":i.precision-=2;break;case"e":i.precision-=1;break}return Px(e(i),e(".1f")(1)[1])}else return e(i)},formatSpan(r,i,s,o){o=jt(o??",f");const a=qt(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=Gd(a,c))||(o.precision=u),n(o,c);case"":case"e":case"g":case"p":case"r":{isNaN(u=Hd(a,c))||(o.precision=u-(o.type==="e"));break}case"f":case"%":{isNaN(u=Vd(a))||(o.precision=u-(o.type==="%")*2);break}}return e(o)}}}Nx();function Nx(){return Lx({format:fe,formatPrefix:Qu})}function Vf(t,e,n){n=n||{},be(n)||te(`Invalid time multi-format specifier: ${n}`);const r=e(Bi),i=e(ki),s=e(Mi),o=e(Ri),a=e(Ii),c=e(_i),u=e(Di),f=e(Ti),l=t(n[Fa]||".%L"),h=t(n[Bi]||":%S"),p=t(n[ki]||"%I:%M"),d=t(n[Mi]||"%I %p"),m=t(n[Ri]||n[Sa]||"%a %d"),g=t(n[Ii]||"%b %d"),y=t(n[_i]||"%B"),x=t(n[Di]||"%B"),w=t(n[Ti]||"%Y");return v=>(r(v)H(r)?e(r):Vf(e,ky,r),utcFormat:r=>H(r)?n(r):Vf(n,By,r),timeParse:ai(t.parse),utcParse:ai(t.utcParse)}}let Hc;$x();function $x(){return Hc=e0({format:nl,parse:Zd,utcFormat:rl,utcParse:Qd})}function Ux(t){return e0(jd(t))}function zx(t){return arguments.length?Hc=Ux(t):Hc}const Vx=t=>t!=null&&t===t,Gx=t=>t==="true"||t==="false"||t===!0||t===!1,Hx=t=>!Number.isNaN(Date.parse(t)),t0=t=>!Number.isNaN(+t)&&!(t instanceof Date),Wx=t=>t0(t)&&Number.isInteger(+t),Gf={boolean:D1,integer:Ei,number:Ei,date:I1,string:R1,unknown:xa},co=[Gx,Wx,t0,Hx],qx=["boolean","integer","number","date"];function jx(t,e){if(!t||!t.length)return"unknown";const n=t.length,r=co.length,i=co.map((s,o)=>o+1);for(let s=0,o=0,a,c;ss===0?o:s,0)-1]}function Yx(t,e){return e.reduce((n,r)=>(n[r]=jx(t,r),n),{})}function Hf(t){const e=function(n,r){const i={delimiter:t};return il(n,r?E1(r,i):i)};return e.responseType="text",e}function il(t,e){return e.header&&(t=e.header.map(Ku).join(e.delimiter)+` +`+t),W1(e.delimiter).parse(t+"")}il.responseType="text";function Xx(t){return typeof Buffer=="function"&&je(Buffer.isBuffer)?Buffer.isBuffer(t):!1}function sl(t,e){const n=e&&e.property?ya(e.property):xa;return be(t)&&!Xx(t)?Kx(n(t),e):n(JSON.parse(t))}sl.responseType="json";function Kx(t,e){return!he(t)&&F1(t)&&(t=[...t]),e&&e.copy?JSON.parse(JSON.stringify(t)):t}const Jx={interior:(t,e)=>t!==e,exterior:(t,e)=>t===e};function n0(t,e){let n,r,i,s;return t=sl(t,e),e&&e.feature?(n=X1,i=e.feature):e&&e.mesh?(n=J1,i=e.mesh,s=Jx[e.filter]):te("Missing TopoJSON feature or mesh parameter."),r=(r=t.objects[i])?n(t,r,s):te("Invalid TopoJSON object: "+i),r&&r.features||[r]}n0.responseType="json";const yc={dsv:il,csv:Hf(","),tsv:Hf(" "),json:sl,topojson:n0};function ol(t,e){return arguments.length>1?(yc[t]=e,this):ur(yc,t)?yc[t]:null}function r0(t,e,n,r){e=e||{};const i=ol(e.type||"json");return i||te("Unknown data format type: "+e.type),t=i(t,e),e.parse&&Zx(t,e.parse,n,r),ur(t,"columns")&&delete t.columns,t}function Zx(t,e,n,r){if(!t.length)return;const i=zx();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=Yx(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(!Gf[d])throw Error("Illegal format pattern: "+p+":"+d);return Gf[d]});for(c=0,f=t.length,l=s.length;c2)throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.")}render(t){return Object.keys(t).reduce((e,n)=>{const r=t[n];return r==null?e:e+`${n=n.includes("-")?n:n.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${r};`},"")}update(t,[e]){const{style:n}=t.element;if(this.ft===void 0)return this.ft=new Set(Object.keys(e)),this.render(e);for(const r of this.ft)e[r]==null&&(this.ft.delete(r),r.includes("-")?n.removeProperty(r):n[r]=null);for(const r in e){const i=e[r];if(i!=null){this.ft.add(r);const s=typeof i=="string"&&i.endsWith(Qx);r.includes("-")||s?n.setProperty(r,s?i.slice(0,-11):i,s?i0:""):n[r]=i}}return Wt}}),tb=""+new URL("90-ring-with-bg-3f133867.svg",import.meta.url).href,nb=` +.genome-spy { + font-family: system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; + position: relative; + display: flex; + flex-direction: column; +} +.genome-spy .canvas-wrapper { + position: relative; + flex-grow: 1; + overflow: hidden; +} +.genome-spy canvas { + display: block; + transform: scale(1, 1); + opacity: 1; + transition: transform 0.6s, opacity 0.6s; +} +.genome-spy .loading-message { + position: absolute; + inset: 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 > .loading-message .message .ellipsis { + animation: blinker 1s linear infinite; +} +@keyframes blinker { + 50% { + opacity: 0; + } +} +.genome-spy .loading-indicators { + position: absolute; + inset: 0; + user-select: none; + pointer-events: none; +} +.genome-spy .loading-indicators div { + position: absolute; + display: flex; + align-items: center; + justify-content: center; +} +.genome-spy .loading-indicators div > div { + font-size: 11px; + transition: opacity 0.2s; + background: white; + padding: 2px 5px; + display: flex; + border-radius: 3px; + gap: 0.5em; + opacity: 0; +} +.genome-spy .loading-indicators div > div.loading { + opacity: 0.5; +} +.genome-spy .loading-indicators div > div.error { + opacity: 0.8; + color: firebrick; +} +.genome-spy .loading-indicators div > div > * { + display: block; +} +.genome-spy .loading-indicators div > div img { + width: 1.5em; + height: 1.5em; +} +.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; +} + +.gs-input-binding { + display: grid; + grid-template-columns: max-content max-content; + column-gap: 1em; + row-gap: 0.3em; + justify-items: start; +} +.gs-input-binding > select, +.gs-input-binding > input:not([type=checkbox]) { + width: 100%; +} +.gs-input-binding input[type=range] + span { + display: inline-block; + margin-left: 0.3em; + min-width: 2.2em; + font-variant-numeric: tabular-nums; +} +.gs-input-binding input[type=range], +.gs-input-binding input[type=radio] { + vertical-align: text-bottom; +} +.gs-input-binding .radio-group { + display: flex; + align-items: center; +} +.gs-input-binding .description { + max-width: 26em; + grid-column: 1/-1; + color: #777; + font-size: 90%; + margin-top: -0.5em; +} + +.gs-input-bindings { + flex-basis: content; + font-size: 14px; + padding: 10px; +} +`;function rb(t,e){var n=t.getBoundingClientRect();return[e.clientX-n.left-t.clientLeft,e.clientY-n.top-t.clientTop]}function No(t,e){return t.length==e.length&&t.every((n,r)=>t[r]===e[r])}function Be(t){return Array.isArray(t)?t:typeof t<"u"?[t]:[]}function Rs(t){return t[t.length-1]}class ib{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 Rs(this.enabledStack)??!0}pushEnabledState(e){this.enabledStack.push(e),e||(this.visible=!1)}popEnabledState(){this.enabledStack.pop()}handleMouseMove(e){this.mouseCoords=rb(this.container,e);const n=performance.now();!this.visible&&!this._isPenalty()&&n-this._previousMove>500&&(this._penaltyUntil=n+70),this._lastCoords&&sb(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&&(qn("",this.element),this.visible=!1),this._previousTooltipDatum=void 0;return}qn(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(z`${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 sb(t,e){let n=0;for(let r=0;r0)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 Bb(t,e){return t.numComponents||t.size||d0(e,Rb(t).length)}function pl(t,e){if($o(t))return t;if($o(t.data))return t.data;Array.isArray(t)&&(t={data:t});let n=t.type;return n||(h0(e)?n=Uint16Array:n=Float32Array),new n(t.data)}function Pb(t,e){const n={};return Object.keys(e).forEach(function(r){if(!h0(r)){const i=e[r],s=i.attrib||i.name||i.attribName||u0.attribPrefix+r;if(i.value){if(!Array.isArray(i.value)&&!$o(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=mb(l),c=i.normalize!==void 0?i.normalize:Ib(l),u=i.numComponents||i.size||d0(r,f),o=t.createBuffer(),t.bindBuffer(ut,o),t.bufferData(ut,h,i.drawType||c0)}else{const f=pl(i,r);o=f0(t,f,void 0,i.drawType),a=dl(f),c=i.normalize!==void 0?i.normalize:_b(f),u=Bb(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(ut,null),n}function Ob(t,e,n,r){n=pl(n),r!==void 0?(t.bindBuffer(ut,e.buffer),t.bufferSubData(ut,r,n)):l0(t,ut,e.buffer,n,e.drawType)}function Lb(t,e){return e===vb||e===Eb?1:e===Cb||e===Sb?2:e===Fb||e===Tb||e===Db?4:0}const xc=["position","positions","a_position"];function Nb(t,e){let n,r;for(r=0;r{const w=y*x.ndx,v=n.subarray(w,w+y);t.texImage2D(x.face,c,u,s,o,0,l,h,v)})}else i===Yt||i===Xt?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 mw(t,e,n){const r=n.target||Ot;t.bindTexture(r,e);const i=n.level||0,s=n.internalFormat||n.format||K,o=jr(s),a=n.format||o.format,c=n.type||o.type;if(Ur(t,n),r===Bt)for(let u=0;u<6;++u)t.texImage2D(Da+u,i,s,n.width,n.height,0,a,c,null);else r===Yt||r===Xt?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 Li(t,e,n){n=n||Ms,e=e||sn.textureOptions;const r=t.createTexture(),i=e.target||Ot;let s=e.width||1,o=e.height||1;const a=e.internalFormat||K;t.bindTexture(i,r),i===Bt&&(t.texParameteri(i,zo,Uo),t.texParameteri(i,Vo,Uo));let c=e.src;if(c)if(typeof c=="function"&&(c=c(t,e)),typeof c=="string")hw(t,r,e,n);else if($r(c)||Array.isArray(c)&&(typeof c[0]=="number"||Array.isArray(c[0])||$r(c[0]))){const u=S0(t,r,c,e);s=u.width,o=u.height}else Array.isArray(c)&&(typeof c[0]=="string"||C0(c[0]))?i===Bt?dw(t,r,e,n):pw(t,r,e,n):(E0(t,r,c,e),s=c.width,o=c.height);else mw(t,r,e);return Oi(e)&&Yc(t,r,e,s,o,a),v0(t,r,e),r}function gw(t,e,n,r,i,s){r=r||n.width,i=i||n.height,s=s||n.depth;const o=n.target||Ot;t.bindTexture(o,e);const a=n.level||0,c=n.internalFormat||n.format||K,u=jr(c),f=n.format||u.format;let l;const h=n.src;if(h&&($r(h)||Array.isArray(h)&&typeof h[0]=="number")?l=n.type||w0(t,h,u.type):l=n.type||u.type,o===Bt)for(let p=0;p<6;++p)t.texImage2D(Da+p,a,c,r,i,0,f,l,null);else o===Yt||o===Xt?t.texImage3D(o,a,c,r,i,s,0,f,l,null):t.texImage2D(o,a,c,r,i,0,f,l,null)}const yw=o0,Go=33984,xw=35048,Ia=34962,bw=34963,xl=35345,F0=35718,ww=35721,Aw=35971,vw=35382,Ew=35396,Cw=35398,Sw=35392,Fw=35395,Ra=5126,T0=35664,D0=35665,_0=35666,bl=5124,I0=35667,R0=35668,M0=35669,k0=35670,B0=35671,P0=35672,O0=35673,L0=35674,N0=35675,$0=35676,Tw=35678,Dw=35680,_w=35679,Iw=35682,Rw=35685,Mw=35686,kw=35687,Bw=35688,Pw=35689,Ow=35690,Lw=36289,Nw=36292,$w=36293,wl=5125,U0=36294,z0=36295,V0=36296,Uw=36298,zw=36299,Vw=36300,Gw=36303,Hw=36306,Ww=36307,qw=36308,jw=36311,Ma=3553,ka=34067,Al=32879,Ba=35866,B={};function G0(t,e){return B[e].bindPoint}function Yw(t,e){return function(n){t.uniform1f(e,n)}}function Xw(t,e){return function(n){t.uniform1fv(e,n)}}function Kw(t,e){return function(n){t.uniform2fv(e,n)}}function Jw(t,e){return function(n){t.uniform3fv(e,n)}}function Zw(t,e){return function(n){t.uniform4fv(e,n)}}function H0(t,e){return function(n){t.uniform1i(e,n)}}function W0(t,e){return function(n){t.uniform1iv(e,n)}}function q0(t,e){return function(n){t.uniform2iv(e,n)}}function j0(t,e){return function(n){t.uniform3iv(e,n)}}function Y0(t,e){return function(n){t.uniform4iv(e,n)}}function Qw(t,e){return function(n){t.uniform1ui(e,n)}}function eA(t,e){return function(n){t.uniform1uiv(e,n)}}function tA(t,e){return function(n){t.uniform2uiv(e,n)}}function nA(t,e){return function(n){t.uniform3uiv(e,n)}}function rA(t,e){return function(n){t.uniform4uiv(e,n)}}function iA(t,e){return function(n){t.uniformMatrix2fv(e,!1,n)}}function sA(t,e){return function(n){t.uniformMatrix3fv(e,!1,n)}}function oA(t,e){return function(n){t.uniformMatrix4fv(e,!1,n)}}function aA(t,e){return function(n){t.uniformMatrix2x3fv(e,!1,n)}}function cA(t,e){return function(n){t.uniformMatrix3x2fv(e,!1,n)}}function uA(t,e){return function(n){t.uniformMatrix2x4fv(e,!1,n)}}function lA(t,e){return function(n){t.uniformMatrix4x2fv(e,!1,n)}}function fA(t,e){return function(n){t.uniformMatrix3x4fv(e,!1,n)}}function hA(t,e){return function(n){t.uniformMatrix4x3fv(e,!1,n)}}function Se(t,e,n,r){const i=G0(t,e);return qr(t)?function(s){let o,a;Ta(t,s)?(o=s,a=null):(o=s.texture,a=s.sampler),t.uniform1i(r,n),t.activeTexture(Go+n),t.bindTexture(i,o),t.bindSampler(n,a)}:function(s){t.uniform1i(r,n),t.activeTexture(Go+n),t.bindTexture(i,s)}}function Fe(t,e,n,r,i){const s=G0(t,e),o=new Int32Array(i);for(let a=0;at>="0"&&t<="9";function K0(t,e,n,r){const i=t.split(dA).filter(a=>a!=="");let s=0,o="";for(;;){const a=i[s++];o+=a;const c=pA(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){Z0(d,m)}}(p),o+=l}}}function mA(t,e){let n=0;function r(a,c,u){const f=c.name.endsWith("[0]"),l=c.type,h=B[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,F0);for(let a=0;a((t+(e-1))/e|0)*e;function bA(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=Jc&&t1?t.renderbufferStorageMultisample(Fn,l,h,n,r):t.renderbufferStorage(Fn,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||Qc,d.mag=d.mag||d.minMag||Qc,d.wrapS=d.wrapS||d.wrap||Zc,d.wrapT=d.wrapT||d.wrap||Zc),f=Li(t,d)}if(a0(t,f))t.framebufferRenderbuffer(i,p,Fn,f);else if(Ta(t,f))c.layer!==void 0?t.framebufferTextureLayer(i,p,f,c.level||0,c.layer):t.framebufferTexture2D(i,p,c.target||FA,f,c.level||0);else throw new Error("unknown attachment type");a.attachments.push(f)}),t.drawBuffers&&t.drawBuffers(o),a}function VA(t,e,n,r,i){r=r||t.drawingBufferWidth,i=i||t.drawingBufferHeight,e.width=r,e.height=i,n=n||rp,n.forEach(function(s,o){const a=e.attachments[o],c=s.format,u=s.samples;if(u!==void 0||a0(t,a))t.bindRenderbuffer(Fn,a),u>1?t.renderbufferStorageMultisample(Fn,u,c,r,i):t.renderbufferStorage(Fn,c,r,i);else if(Ta(t,a))gw(t,a,s,r,i);else throw new Error("unknown attachment type")})}function GA(t,e,n){const r=t.createVertexArray();return t.bindVertexArray(r),e.length||(e=[e]),e.forEach(function(i){jn(t,i,n)}),t.bindVertexArray(null),{numElements:n.numElements,elementType:n.elementType,vertexArrayObject:r}}const HA=/^(.*?)_/;function WA(t,e){Wc(t,0);const n=t.getExtension(e);if(n){const r={},i=HA.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&&o0(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},Wc(r,0)}return n}const ih=["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 ip(t){for(let e=0;e0.0&&abs(size)b){float tmp=b;b=a;a=tmp;}}/***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.*/vec2 getVertexPos(){int index=gl_VertexID % 6;return vec2(index==0||index==1||index==3 ? 0.0 : 1.0,index==0||index==1||index==2 ? 0.0 : 1.0);}void main(void){vec2 frac=getVertexPos();vec2 normalizedMinSize=vec2(uMinWidth,uMinHeight)/uViewportSize;vec4 cornerRadii=vec4(uCornerRadiusTopRight,uCornerRadiusBottomRight,uCornerRadiusTopLeft,uCornerRadiusBottomLeft);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();}`,XA=`#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;}}`,KA=`layout(std140)uniform Mark{uniform float uMinWidth;uniform float uMinHeight;uniform float uMinOpacity;uniform float uCornerRadiusTopRight;uniform float uCornerRadiusBottomRight;uniform float uCornerRadiusTopLeft;uniform float uCornerRadiusBottomLeft; +#pragma markUniforms +};`;function mt(t,e){switch(arguments.length){case 0:break;case 1:this.range(t);break;default:this.range(e).domain(t);break}return this}function cn(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 eu=Symbol("implicit");function Sl(){var t=new Mt,e=[],n=[],r=eu;function i(s){let o=t.get(s);if(o===void 0){if(r!==eu)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 Mt;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 Sl(e,n).unknown(r)},mt.apply(i,arguments),i}function Yr(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function ks(t,e){var n=Object.create(t.prototype);for(var r in e)n[r]=e[r];return n}function un(){}var Yn=.7,zr=1/Yn,hr="\\s*([+-]?\\d+)\\s*",$i="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",lt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",JA=/^#([0-9a-f]{3,8})$/,ZA=new RegExp(`^rgb\\(${hr},${hr},${hr}\\)$`),QA=new RegExp(`^rgb\\(${lt},${lt},${lt}\\)$`),ev=new RegExp(`^rgba\\(${hr},${hr},${hr},${$i}\\)$`),tv=new RegExp(`^rgba\\(${lt},${lt},${lt},${$i}\\)$`),nv=new RegExp(`^hsl\\(${$i},${lt},${lt}\\)$`),rv=new RegExp(`^hsla\\(${$i},${lt},${lt},${$i}\\)$`),sh={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};Yr(un,Kt,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:oh,formatHex:oh,formatHex8:iv,formatHsl:sv,formatRgb:ah,toString:ah});function oh(){return this.rgb().formatHex()}function iv(){return this.rgb().formatHex8()}function sv(){return sp(this).formatHsl()}function ah(){return this.rgb().formatRgb()}function Kt(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=JA.exec(t))?(n=e[1].length,e=parseInt(e[1],16),n===6?ch(e):n===3?new ie(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):n===8?mo(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):n===4?mo(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=ZA.exec(t))?new ie(e[1],e[2],e[3],1):(e=QA.exec(t))?new ie(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=ev.exec(t))?mo(e[1],e[2],e[3],e[4]):(e=tv.exec(t))?mo(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=nv.exec(t))?fh(e[1],e[2]/100,e[3]/100,1):(e=rv.exec(t))?fh(e[1],e[2]/100,e[3]/100,e[4]):sh.hasOwnProperty(t)?ch(sh[t]):t==="transparent"?new ie(NaN,NaN,NaN,0):null}function ch(t){return new ie(t>>16&255,t>>8&255,t&255,1)}function mo(t,e,n,r){return r<=0&&(t=e=n=NaN),new ie(t,e,n,r)}function Fl(t){return t instanceof un||(t=Kt(t)),t?(t=t.rgb(),new ie(t.r,t.g,t.b,t.opacity)):new ie}function Ho(t,e,n,r){return arguments.length===1?Fl(t):new ie(t,e,n,r??1)}function ie(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}Yr(ie,Ho,ks(un,{brighter(t){return t=t==null?zr:Math.pow(zr,t),new ie(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?Yn:Math.pow(Yn,t),new ie(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new ie(zn(this.r),zn(this.g),zn(this.b),Wo(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:uh,formatHex:uh,formatHex8:ov,formatRgb:lh,toString:lh}));function uh(){return`#${Tn(this.r)}${Tn(this.g)}${Tn(this.b)}`}function ov(){return`#${Tn(this.r)}${Tn(this.g)}${Tn(this.b)}${Tn((isNaN(this.opacity)?1:this.opacity)*255)}`}function lh(){const t=Wo(this.opacity);return`${t===1?"rgb(":"rgba("}${zn(this.r)}, ${zn(this.g)}, ${zn(this.b)}${t===1?")":`, ${t})`}`}function Wo(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function zn(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function Tn(t){return t=zn(t),(t<16?"0":"")+t.toString(16)}function fh(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new tt(t,e,n,r)}function sp(t){if(t instanceof tt)return new tt(t.h,t.s,t.l,t.opacity);if(t instanceof un||(t=Kt(t)),!t)return new tt;if(t instanceof tt)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+(n0&&c<1?0:o,new tt(o,a,c,t.opacity)}function tu(t,e,n,r){return arguments.length===1?sp(t):new tt(t,e,n,r??1)}function tt(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}Yr(tt,tu,ks(un,{brighter(t){return t=t==null?zr:Math.pow(zr,t),new tt(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?Yn:Math.pow(Yn,t),new tt(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 ie(Ac(t>=240?t-240:t+120,i,r),Ac(t,i,r),Ac(t<120?t+240:t-120,i,r),this.opacity)},clamp(){return new tt(hh(this.h),go(this.s),go(this.l),Wo(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=Wo(this.opacity);return`${t===1?"hsl(":"hsla("}${hh(this.h)}, ${go(this.s)*100}%, ${go(this.l)*100}%${t===1?")":`, ${t})`}`}}));function hh(t){return t=(t||0)%360,t<0?t+360:t}function go(t){return Math.max(0,Math.min(1,t||0))}function Ac(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 op=Math.PI/180,ap=180/Math.PI,qo=18,cp=.96422,up=1,lp=.82521,fp=4/29,dr=6/29,hp=3*dr*dr,av=dr*dr*dr;function dp(t){if(t instanceof ft)return new ft(t.l,t.a,t.b,t.opacity);if(t instanceof It)return pp(t);t instanceof ie||(t=Fl(t));var e=Sc(t.r),n=Sc(t.g),r=Sc(t.b),i=vc((.2225045*e+.7168786*n+.0606169*r)/up),s,o;return e===n&&n===r?s=o=i:(s=vc((.4360747*e+.3850649*n+.1430804*r)/cp),o=vc((.0139322*e+.0971045*n+.7141733*r)/lp)),new ft(116*i-16,500*(s-i),200*(i-o),t.opacity)}function nu(t,e,n,r){return arguments.length===1?dp(t):new ft(t,e,n,r??1)}function ft(t,e,n,r){this.l=+t,this.a=+e,this.b=+n,this.opacity=+r}Yr(ft,nu,ks(un,{brighter(t){return new ft(this.l+qo*(t??1),this.a,this.b,this.opacity)},darker(t){return new ft(this.l-qo*(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=cp*Ec(e),t=up*Ec(t),n=lp*Ec(n),new ie(Cc(3.1338561*e-1.6168667*t-.4906146*n),Cc(-.9787684*e+1.9161415*t+.033454*n),Cc(.0719453*e-.2289914*t+1.4052427*n),this.opacity)}}));function vc(t){return t>av?Math.pow(t,1/3):t/hp+fp}function Ec(t){return t>dr?t*t*t:hp*(t-fp)}function Cc(t){return 255*(t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055)}function Sc(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function cv(t){if(t instanceof It)return new It(t.h,t.c,t.l,t.opacity);if(t instanceof ft||(t=dp(t)),t.a===0&&t.b===0)return new It(NaN,0=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()=>t;function bp(t,e){return function(n){return t+n*e}}function lv(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 za(t,e){var n=e-t;return n?bp(t,n>180||n<-180?n-360*Math.round(n/360):n):Ua(isNaN(t)?e:t)}function fv(t){return(t=+t)==1?se:function(e,n){return n-e?lv(e,n,t):Ua(isNaN(e)?n:e)}}function se(t,e){var n=e-t;return n?bp(t,n):Ua(isNaN(t)?e:t)}const su=function t(e){var n=fv(e);function r(i,s){var o=n((i=Ho(i)).r,(s=Ho(s)).r),a=n(i.g,s.g),c=n(i.b,s.b),u=se(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 wp(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;on&&(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:et(r,i)})),n=Fc.lastIndex;return n180?f+=360:f-u>180&&(u+=360),h.push({i:l.push(i(l)+"rotate(",null,r)-2,x:et(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:et(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:et(u,l)},{i:m-2,x:et(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;++de&&(n=t,t=e,e=n),function(r){return Math.max(t,Math.min(e,r))}}function Nv(t,e,n){var r=t[0],i=t[1],s=e[0],o=e[1];return i2?$v:Nv,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),et)))(h)))},l.domain=function(h){return arguments.length?(t=Array.from(h,cu),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=Bs,f()},l.clamp=function(h){return arguments.length?(o=h?!0:ke,f()):o!==ke},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 Rp(){return Va()(ke,ke)}function Mp(t,e,n,r){var i=qt(t,e,n),s;switch(r=jt(r??",f"),r.type){case"s":{var o=Math.max(Math.abs(t),Math.abs(e));return r.precision==null&&!isNaN(s=Gd(i,o))&&(r.precision=s),Qu(r,o)}case"":case"e":case"g":case"p":case"r":{r.precision==null&&!isNaN(s=Hd(i,Math.max(Math.abs(t),Math.abs(e))))&&(r.precision=s-(r.type==="e"));break}case"f":case"%":{r.precision==null&&!isNaN(s=Vd(i))&&(r.precision=s-(r.type==="%")*2);break}}return fe(r)}function er(t){var e=t.domain;return t.ticks=function(n){var r=e();return Bo(r[0],r[r.length-1],n??10)},t.tickFormat=function(n,r){var i=e();return Mp(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(a0;){if(u=Gc(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 kp(){var t=Rp();return t.copy=function(){return Ps(t,kp())},mt.apply(t,arguments),er(t)}function Bp(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,cu),n):t.slice()},n.unknown=function(r){return arguments.length?(e=r,n):e},n.copy=function(){return Bp(t).unknown(e)},t=arguments.length?Array.from(t,cu):[0,1],er(n)}function Pp(t,e){t=t.slice();var n=0,r=t.length-1,i=t[n],s=t[r],o;return sMath.pow(t,e)}function Hv(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 Ah(t){return(e,n)=>-t(-e,n)}function Rl(t){const e=t(bh,wh),n=e.domain;let r=10,i,s;function o(){return i=Hv(r),s=Gv(r),n()[0]<0?(i=Ah(i),s=Ah(s),t(Uv,zv)):t(bh,wh),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=f0){for(;h<=p;++h)for(d=1;df)break;y.push(m)}}else for(;h<=p;++h)for(d=r-1;d>=1;--d)if(m=h>0?d/s(-h):d*s(h),!(mf)break;y.push(m)}y.length*2{if(a==null&&(a=10),c==null&&(c=r===10?"s":","),typeof c!="function"&&(!(r%1)&&(c=jt(c)).precision==null&&(c.trim=!0),c=fe(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*rn(Pp(n(),{floor:a=>s(Math.floor(i(a))),ceil:a=>s(Math.ceil(i(a)))})),e}function Ml(){const t=Rl(Va()).domain([1,10]);return t.copy=()=>Ps(t,Ml()).base(t.base()),mt.apply(t,arguments),t}function vh(t){return function(e){return Math.sign(e)*Math.log1p(Math.abs(e/t))}}function Eh(t){return function(e){return Math.sign(e)*Math.expm1(Math.abs(e))*t}}function kl(t){var e=1,n=t(vh(e),Eh(e));return n.constant=function(r){return arguments.length?t(vh(e=+r),Eh(e)):e},er(n)}function Op(){var t=kl(Va());return t.copy=function(){return Ps(t,Op()).constant(t.constant())},mt.apply(t,arguments)}function Ch(t){return function(e){return e<0?-Math.pow(-e,t):Math.pow(e,t)}}function Wv(t){return t<0?-Math.sqrt(-t):Math.sqrt(t)}function qv(t){return t<0?-t*t:t*t}function Bl(t){var e=t(ke,ke),n=1;function r(){return n===1?t(ke,ke):n===.5?t(Wv,qv):t(Ch(n),Ch(1/n))}return e.exponent=function(i){return arguments.length?(n=+i,r()):n},er(e)}function Pl(){var t=Bl(Va());return t.copy=function(){return Ps(t,Pl()).exponent(t.exponent())},mt.apply(t,arguments),t}function jv(){return Pl.apply(null,arguments).exponent(.5)}function Lp(){var t=[],e=[],n=[],r;function i(){var o=0,a=Math.max(1,e.length);for(n=new Array(a-1);++o0?n[a-1]:t[0],a=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 Np().domain([t,e]).range(i).unknown(s)},mt.apply(er(o),arguments)}function $p(){var t=[.5],e=[0,1],n,r=1;function i(s){return s!=null&&s<=s?e[Wr(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 $p().domain(t).range(e).unknown(n)},mt.apply(i,arguments)}function Yv(t){return new Date(t)}function Xv(t){return t instanceof Date?+t:+new Date(+t)}function Ol(t,e,n,r,i,s,o,a,c,u){var f=Rp(),l=f.invert,h=f.domain,p=u(".%L"),d=u(":%S"),m=u("%I:%M"),g=u("%I %p"),y=u("%a %d"),x=u("%b %d"),w=u("%B"),v=u("%Y");function C(S){return(c(S)0?r:1:0}const lE="identity",Vr="linear",Jt="log",Os="pow",Ls="sqrt",Wa="symlog",Wp="time",qp="utc",ht="sequential",Xr="diverging",lu="quantile",jp="quantize",Yp="threshold",zl="ordinal",fu="point",Xp="band",Vl="bin-ordinal",re="continuous",Ns="discrete",$s="discretizing",Xe="interpolating",Kp="temporal";function fE(t){return function(e){let n=e[0],r=e[1],i;return r=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 Gl(){const t=Sl().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]m+i*y);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[1-h])))return y=Math.max(0,zc(p,m)-1),x=m===g?y:zc(p,g)-1,m-p[y]>s+1e-10&&++y,h&&(w=y,y=d-x,x=d-w),y>x?void 0:e().slice(y,x+1)},t.invert=function(l){const h=t.invertRange([l,l]);return h&&h[0]},t.copy=function(){return Gl().domain(e()).range(r).round(o).paddingInner(a).paddingOuter(c).align(u)},f()}function Jp(t){const e=t.copy;return t.padding=t.paddingOuter,delete t.paddingInner,t.copy=function(){return Jp(e())},t}function dE(){return Jp(Gl().paddingInner(1))}var pE=Array.prototype.map;function mE(t){return pE.call(t,Ei)}const gE=Array.prototype.slice;function Zp(){let t=[],e=[];function n(r){return r==null||r!==r?void 0:e[(Wr(t,r)-1)%e.length]}return n.domain=function(r){return arguments.length?(t=mE(r),n):t.slice()},n.range=function(r){return arguments.length?(e=gE.call(r),n):e.slice()},n.tickFormat=function(r,i){return Mp(t[0],nt(t),r??10,i)},n.copy=function(){return Zp().domain(n.domain()).range(n.range())},n}const jo=new Map,yE=Symbol("vega_scale");function xE(t){return t[yE]=!0,t}function bE(t,e,n){const r=function(){const s=e();return s.invertRange||(s.invertRange=s.invert?fE(s):s.invertExtent?hE(s):void 0),s.type=t,xE(s)};return r.metadata=Mo($c(n)),r}function V(t,e,n){return arguments.length>1?(jo.set(t,bE(t,e,n)),this):wE(t)?jo.get(t):void 0}V(lE,Bp);V(Vr,kp,re);V(Jt,Ml,[re,Jt]);V(Os,Pl,re);V(Ls,jv,re);V(Wa,Op,re);V(Wp,Kv,[re,Kp]);V(qp,Jv,[re,Kp]);V(ht,Ll,[re,Xe]);V(`${ht}-${Vr}`,Ll,[re,Xe]);V(`${ht}-${Jt}`,Up,[re,Xe,Jt]);V(`${ht}-${Os}`,Nl,[re,Xe]);V(`${ht}-${Ls}`,Zv,[re,Xe]);V(`${ht}-${Wa}`,zp,[re,Xe]);V(`${Xr}-${Vr}`,Vp,[re,Xe]);V(`${Xr}-${Jt}`,Gp,[re,Xe,Jt]);V(`${Xr}-${Os}`,$l,[re,Xe]);V(`${Xr}-${Ls}`,Qv,[re,Xe]);V(`${Xr}-${Wa}`,Hp,[re,Xe]);V(lu,Lp,[$s,lu]);V(jp,Np,$s);V(Yp,$p,$s);V(Vl,Zp,[Ns,$s]);V(zl,Sl,Ns);V(Xp,Gl,Ns);V(fu,dE,Ns);function wE(t){return jo.has(t)}function Us(t,e){const n=jo.get(t);return n&&n.metadata[e]}function ue(t){return Us(t,re)}function Zt(t){return Us(t,Ns)}function Cn(t){return Us(t,$s)}function Qp(t){return Us(t,Jt)}function qa(t){return Us(t,Xe)}function AE(t,e){const n=e[0],r=nt(e)-n;return function(i){return t(n+i*r)}}function ja(t,e,n){return Il(em(e||"rgb",n),t)}function vE(t,e){const n=new Array(e),r=e+1;for(let i=0;ie[0].toUpperCase()+e.slice(1)).join("")}const CE={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"},SE={accent:tE,category10:eE,category20:"1f77b4aec7e8ff7f0effbb782ca02c98df8ad62728ff98969467bdc5b0d58c564bc49c94e377c2f7b6d27f7f7fc7c7c7bcbd22dbdb8d17becf9edae5",category20b:"393b795254a36b6ecf9c9ede6379398ca252b5cf6bcedb9c8c6d31bd9e39e7ba52e7cb94843c39ad494ad6616be7969c7b4173a55194ce6dbdde9ed6",category20c:"3182bd6baed69ecae1c6dbefe6550dfd8d3cfdae6bfdd0a231a35474c476a1d99bc7e9c0756bb19e9ac8bcbddcdadaeb636363969696bdbdbdd9d9d9",dark2:nE,observable10:rE,paired:iE,pastel1:sE,pastel2:oE,set1:aE,set2:cE,set3:uE,tableau10:"4c78a8f58518e4575672b7b254a24beeca3bb279a2ff9da69d755dbab0ac",tableau20:"4c78a89ecae9f58518ffbf7954a24b88d27ab79a20f2cf5b43989483bcb6e45756ff9d9879706ebab0acd67195fcbfd2b279a2d6a5c99e765fd8b5a5"};function tm(t){if(he(t))return t;const e=t.length/6|0,n=new Array(e);for(let r=0;rja(tm(t)));function Hl(t,e){return t=t&&t.toLowerCase(),arguments.length>1?(Sh[t]=e,this):Sh[t]}function W(t,e=t){if(/^[A-Za-z0-9_]+$/.test(t)){const n=new Function("datum",`return datum[${JSON.stringify(t)}]`);return rn(n,[t],e)}else return ya(t)}const FE="RawCode",TE="Literal",DE="Property",_E="Identifier",IE="ArrayExpression",RE="BinaryExpression",ME="CallExpression",kE="ConditionalExpression",BE="LogicalExpression",PE="MemberExpression",OE="ObjectExpression",LE="UnaryExpression";function it(t){this.type=t}it.prototype.visit=function(t){let e,n,r;if(t(this))return 1;for(e=NE(this),n=0,r=e.length;n";yt[Xn]="Identifier";yt[hn]="Keyword";yt[Xa]="Null";yt[tr]="Numeric";yt[Re]="Punctuator";yt[Vs]="String";yt[$E]="RegularExpression";var UE="ArrayExpression",zE="BinaryExpression",VE="CallExpression",GE="ConditionalExpression",rm="Identifier",HE="Literal",WE="LogicalExpression",qE="MemberExpression",jE="ObjectExpression",YE="Property",XE="UnaryExpression",oe="Unexpected token %0",KE="Unexpected number",JE="Unexpected string",ZE="Unexpected identifier",QE="Unexpected reserved word",eC="Unexpected end of input",hu="Invalid regular expression",Tc="Invalid regular expression: missing /",im="Octal literals are not allowed in strict mode.",tC="Duplicate data property in object literal not allowed in strict mode",le="ILLEGAL",zi="Disabled.",nC=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]"),rC=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 Ka(t,e){if(!t)throw new Error("ASSERT: "+e)}function At(t){return t>=48&&t<=57}function Wl(t){return"0123456789abcdefABCDEF".indexOf(t)>=0}function mi(t){return"01234567".indexOf(t)>=0}function iC(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 Vi(t){return t===10||t===13||t===8232||t===8233}function Gs(t){return t===36||t===95||t>=65&&t<=90||t>=97&&t<=122||t===92||t>=128&&nC.test(String.fromCharCode(t))}function Yo(t){return t===36||t===95||t>=65&&t<=90||t>=97&&t<=122||t>=48&&t<=57||t===92||t>=128&&rC.test(String.fromCharCode(t))}const sC={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 sm(){for(;A1114111||t!=="}")&&$({},oe,le),e<=65535?String.fromCharCode(e):(n=(e-65536>>10)+55296,r=(e-65536&1023)+56320,String.fromCharCode(n,r))}function om(){var t,e;for(t=I.charCodeAt(A++),e=String.fromCharCode(t),t===92&&(I.charCodeAt(A)!==117&&$({},oe,le),++A,t=du("u"),(!t||t==="\\"||!Gs(t.charCodeAt(0)))&&$({},oe,le),e=t);A>>=")return A+=4,{type:Re,value:o,start:t,end:A};if(s=o.substr(0,3),s===">>>"||s==="<<="||s===">>=")return A+=3,{type:Re,value:s,start:t,end:A};if(i=s.substr(0,2),r===i[1]&&"+-<>&|".indexOf(r)>=0||i==="=>")return A+=2,{type:Re,value:i,start:t,end:A};if(i==="//"&&$({},oe,le),"<>=!+-*%&|^/".indexOf(r)>=0)return++A,{type:Re,value:r,start:t,end:A};$({},oe,le)}function uC(t){let e="";for(;A=0&&A=0&&(n=n.replace(/\\u\{([0-9a-fA-F]+)\}/g,(r,i)=>{if(parseInt(i,16)<=1114111)return"x";$({},hu)}).replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,"x"));try{new RegExp(n)}catch{$({},hu)}try{return new RegExp(t,e)}catch{return null}}function dC(){var t,e,n,r,i;for(t=I[A],Ka(t==="/","Regular expression literal must start with a slash"),e=I[A++],n=!1,r=!1;A=0&&$({},hu,n),{value:n,literal:e}}function mC(){var t,e,n,r;return G=null,sm(),t=A,e=dC(),n=pC(),r=hC(e.value,n.value),{literal:e.literal+n.literal,value:r,regex:{pattern:e.value,flags:n.value},start:t,end:A}}function gC(t){return t.type===Xn||t.type===hn||t.type===Ya||t.type===Xa}function am(){if(sm(),A>=ye)return{type:zs,start:A,end:A};const t=I.charCodeAt(A);return Gs(t)?cC():t===40||t===41||t===59?Dc():t===39||t===34?fC():t===46?At(I.charCodeAt(A+1))?Fh():Dc():At(t)?Fh():Dc()}function Me(){const t=G;return A=t.end,G=am(),A=t.end,t}function cm(){const t=A;G=am(),A=t}function yC(t){const e=new it(UE);return e.elements=t,e}function Th(t,e,n){const r=new it(t==="||"||t==="&&"?WE:zE);return r.operator=t,r.left=e,r.right=n,r}function xC(t,e){const n=new it(VE);return n.callee=t,n.arguments=e,n}function bC(t,e,n){const r=new it(GE);return r.test=t,r.consequent=e,r.alternate=n,r}function ql(t){const e=new it(rm);return e.name=t,e}function ci(t){const e=new it(HE);return e.value=t.value,e.raw=I.slice(t.start,t.end),t.regex&&(e.raw==="//"&&(e.raw="/(?:)/"),e.regex=t.regex),e}function Dh(t,e,n){const r=new it(qE);return r.computed=t==="[",r.object=e,r.property=n,r.computed||(n.member=!0),r}function wC(t){const e=new it(jE);return e.properties=t,e}function _h(t,e,n){const r=new it(YE);return r.key=e,r.value=n,r.kind=t,r}function AC(t,e){const n=new it(XE);return n.operator=t,n.argument=e,n.prefix=!0,n}function $(t,e){var n,r=Array.prototype.slice.call(arguments,2),i=e.replace(/%(\d)/g,(s,o)=>(Ka(o":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 kC(){var t,e,n,r,i,s,o,a,c,u;if(t=G,c=vo(),r=G,i=Mh(r),i===0)return c;for(r.prec=i,Me(),e=[t,G],o=vo(),s=[c,r,o];(i=Mh(G))>0;){for(;s.length>2&&i<=s[s.length-2].prec;)o=s.pop(),a=s.pop().value,c=s.pop(),e.pop(),n=Th(a,c,o),s.push(n);r=Me(),r.prec=i,s.push(r),e.push(G),n=vo(),s.push(n)}for(u=s.length-1,n=s[u],e.pop();u>1;)e.pop(),n=Th(s[u-1].value,s[u-2],n),u-=2;return n}function Kn(){var t,e,n;return t=kC(),Y("?")&&(Me(),e=Kn(),xe(":"),n=Kn(),t=bC(t,e,n)),t}function jl(){const t=Kn();if(Y(","))throw new Error(zi);return t}function BC(t){I=t,A=0,ye=I.length,G=null,cm();const e=jl();if(G.type!==zs)throw new Error("Unexpect token after expression.");return e}var PC={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 um(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&&te("Missing arguments to clamp function."),o.length>3&&te("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&&te("Missing arguments to if function."),o.length>3&&te("Too many arguments to if function.");const a=o.map(t);return"("+a[0]+"?"+a[1]+":"+a[2]+")"}}}function OC(t){const e=t&&t.length-1;return e&&(t[0]==='"'&&t[e]==='"'||t[0]==="'"&&t[e]==="'")?t.slice(1,-1):t}function LC(t){t=t||{};const e=t.allowed?Mo(t.allowed):{},n=t.forbidden?Mo(t.forbidden):{},r=t.constants||PC,i=(t.functions||um)(l),s=t.globalvar,o=t.fieldvar,a=je(s)?s:d=>`${s}["${d}"]`;let c={},u={},f=0;function l(d){if(H(d))return d;const m=h[d.type];return m==null&&te("Unsupported type: "+d.type),m(d)}const h={Literal:d=>d.raw,Identifier:d=>{const m=d.name;return f>0?m:ur(n,m)?te("Illegal identifier: "+m):ur(r,m)?r[m]:ur(e,m)?m:(c[m]=1,a(m))},MemberExpression:d=>{const m=!d.computed,g=l(d.object);m&&(f+=1);const y=l(d.property);return g===o&&(u[OC(y)]=1),m&&(f-=1),g+(m?"."+y:"["+y+"]")},CallExpression:d=>{d.callee.type!=="Identifier"&&te("Illegal callee type: "+d.callee.type);const m=d.callee.name,g=d.arguments,y=ur(i,m)&&i[m];return y||te("Unrecognized function: "+m),je(y)?y(g):y+"("+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 lm(t,e,n){return n=(n-t)/(e-t),n=Math.max(0,Math.min(1,n)),n*n*(3-2*n)}function Gr(t,e=0,n=1){return Math.max(e,Math.min(n,t))}function NC(t,e,n){return Gr((n-t)/(e-t),0,1)}const xt=1,dn=2,Yl=4;var In,ui;class Z{constructor(e){F(this,In);ve(this,"paramMediatorProvider",null);this.paramMediatorProvider=e,this.children=[],this.parent=void 0,this.completed=!1}get behavior(){return 0}reset(){this.completed=!1;for(const e of this.children)e.reset()}initialize(){}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),D(this,In,ui).call(this),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){var n;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,D(n=this.parent,In,ui).call(n),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,D(this,In,ui).call(this);else throw new Error("Trying to remove an unknown child node!")}excise(){var e;if(this.isRoot())throw new Error("Cannot excise root node!");if(this.isTerminal())this.parent.removeChild(this);else if(this.children.length==1){const n=this.children[0];n.setParent(this.parent),this.parent.children[this.parent.children.indexOf(this)]=n,D(e=this.parent,In,ui).call(e),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}`}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)}get paramMediator(){if(this.paramMediatorProvider)return this.paramMediatorProvider.paramMediator;if(!this.parent)throw new Error("Cannot find paramMediator!");return this.parent.paramMediator}repropagate(){if(this.parent)this.parent.repropagate();else throw new Error("Cannot repropagate data, no FlowNode with stored data found!")}_propagate(e){}}In=new WeakSet,ui=function(){this._propagate=Function("children",Ci(this.children.length).map(e=>`const child${e} = children[${e}];`).join(` +`)+`return function propagate(datum) {${Ci(this.children.length).map(e=>`child${e}.handle(datum);`).join(` +`)}}`)(this.children)};function fm(t){return t.type=="file"}function $C(t){return t.type=="facet"}const Qt="_uniqueId",kh=1e4,Bh=[null];class pu extends Z{get behavior(){return dn}constructor(e){super(),this.params=e,this.as=e.as??Qt,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%kh==0&&(this._id=this._getBlock()*kh),this._id}_getBlock(){return this._usedBlocksi(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}`)}}var $t,Rn,pr,mr,ji;class WC{constructor(e){F(this,$t,void 0);ve(this,"paramListeners");F(this,Rn,new Map);F(this,pr,new Map);F(this,mr,new Map);F(this,ji,void 0);k(this,ji,e??(()=>{})),k(this,$t,new Map),this.paramListeners=new Map}registerParam(e){const n=e.name;if("value"in e&&"expr"in e)throw new Error(`The parameter "${n}" must not have both value and expr properties!`);let r;if(e.push=="outer"){const i=this.findMediatorForParam(n);if(!i)throw new Error(`Parameter "${n}" not found in outer scope!`);const s=i.paramConfigs.get(n);if("expr"in s||"select"in s)throw new Error(`The outer parameter "${n}" must not have expr or select properties!`);r=i.getSetter(n),b(this,Rn).set(n,r)}else if("value"in e)r=this.allocateSetter(n,e.value);else if("expr"in e){const i=this.createExpression(e.expr),s=this.allocateSetter(n,i(null));i.addListener(()=>s(i(null))),r=o=>{}}else r=this.allocateSetter(n,null);return"select"in e&&(H(e.select)?e.select:e.select.type)=="point"&&r(hm(null)),b(this,mr).set(n,e),r}allocateSetter(e,n,r=!1){if(Qa(e),b(this,Rn).has(e))throw new Error("Setter already allocated for parameter: "+e);const i=s=>{const o=b(this,$t).get(e);if(s!==o){b(this,$t).set(e,s);const a=this.paramListeners.get(e);if(a&&!r)for(const c of a)c()}};return i(n),b(this,Rn).set(e,i),i}getSetter(e){const n=b(this,Rn).get(e);if(!n)throw new Error("Setter not found for parameter: "+e);return n}getValue(e){return b(this,$t).get(e)}findValue(e){const n=this.findMediatorForParam(e);return n==null?void 0:n.getValue(e)}get paramConfigs(){return b(this,mr)}findMediatorForParam(e){var n;return b(this,$t).has(e)?this:(n=b(this,ji).call(this))==null?void 0:n.findMediatorForParam(e)}createExpression(e){if(b(this,pr).has(e))return b(this,pr).get(e);const n={},r=HC(e,n),i=new Map;for(const o of r.globals){const a=this.findMediatorForParam(o);if(!a)throw new Error(`Unknown variable "${o}" in expression: ${e}`);i.set(o,a),Object.defineProperty(n,o,{enumerable:!0,get(){return a.getValue(o)}})}const s=new Set;return r.addListener=o=>{for(const[a,c]of i){const u=c.paramListeners.get(a)??new Set;c.paramListeners.set(a,u),u.add(o),s.add(o)}},r.invalidate=()=>{var o;for(const[a,c]of i)for(const u of s)(o=c.paramListeners.get(a))==null||o.delete(u)},r.identifier=()=>r.code,b(this,pr).set(e,r),r}evaluateAndGet(e){return this.createExpression(e)()}hasPointSelections(){for(const e of b(this,mr).values())if(jC(e)){const n=e.select;if(H(n)){if(n=="point")return!0}else if(n.type=="point")return!0}return!1}}$t=new WeakMap,Rn=new WeakMap,pr=new WeakMap,mr=new WeakMap,ji=new WeakMap;function Ee(t){return typeof t=="object"&&t!=null&&"expr"in t&&H(t.expr)}function Ve(t){if(Ee(t))throw new Error(`ExprRef ${JSON.stringify(t)} not allowed here. Expected a scalar value.`);return t}function qC(t){return("expr"in t||"bind"in t)&&!("select"in t)}function jC(t){return!("expr"in t||"bind"in t)&&"select"in t}function Za(t,e,n){const r={...e},i=[],s=o=>{i.push(o),i.length===1&&queueMicrotask(()=>{n(i.slice()),i.length=0})};for(const[o,a]of Object.entries(e))if(Ee(a)){const c=t.createExpression(a.expr);n&&c.addListener(()=>s(o)),Object.defineProperty(r,o,{enumerable:!0,get(){return c()}})}else r[o]=a;return r}function Qa(t){if(!/^[a-zA-Z_$][0-9a-zA-Z_$]*$/.test(t))throw new Error(`Invalid parameter name: ${t}. Must be a valid JavaScript identifier.`);return t}function YC(t){return Object.assign(()=>t,{addListener:()=>{},invalidate:()=>{},identifier:()=>"constant",fields:[],globals:[],code:JSON.stringify(t)})}function Ph(t,e,n){if(!t)return;function r(s){const o=s;return o.fields??(o.fields=[]),o.constant=o.fields.length===0,o.channelDef=e,o.channel=t,o.scaleChannel=((He(e)&&e.resolutionChannel)??(Hi(t)&&t))||void 0,"param"in e?(o.predicate=n.createExpression(dm(e)),o.predicate.param=e.param,o.predicate.empty=e.empty??!0):(o.predicate=YC(!0),o.predicate.empty=!1),o.asNumberAccessor=()=>o,o}function i(s){if(Ee(s)){const o=r(n.createExpression(s.expr));if(o.fields.length>0)throw new Error("Expression in DatumDef/ValueDef cannot access data fields: "+s.expr);return o}else{const o=s;return r(()=>o)}}if(pn(e))try{return r(W(e.field))}catch(s){throw new Error(`Invalid field definition: ${s.message}`)}else{if(Ws(e))return r(n.createExpression(e.expr));if(Hs(e))return i(e.datum);if(Ye(e))return i(e.value);throw new Error(`Invalid channel definition: ${JSON.stringify(e)}. Cannot create an accessor for channel ${t}!`)}}function XC(t,e,n){const r=[];if(QC(e)||eS(e)){const i=Array.isArray(e.condition)?e.condition:[e.condition];for(const s of i)r.push(Ph(t,s,n))}if(r.push(Ph(t,e,n)),r.filter(i=>!i.constant).length>1)throw new Error("Only one accessor can be non-constant. Channel: "+t);return r}function KC(t,e){const n={},r=i=>{var s;return(s=t.getScaleResolution(i))==null?void 0:s.scale};for(const[i,s]of Object.entries(e))s&&(n[i]=JC(XC(i,s,t.paramMediator),r));return n}function JC(t,e){if(t.length===1)return Oh(t[0],e);const n=t.map(s=>s.predicate),r=t.map(s=>Oh(s,e));return Object.assign(s=>{for(let o=0;os.accessors[0]),dataAccessor:r.map(s=>s.dataAccessor).find(s=>s),scale:r.map(s=>s.scale).find(s=>s),channelDef:t.at(-1).channelDef})}function Oh(t,e){const{channel:n,scaleChannel:r,channelDef:i}=t,s=t.scaleChannel?e(r):void 0;if(r&&!s)throw new Error(`Missing scale! "${n}": ${JSON.stringify(i)}`);return Object.assign(s?o=>s(t(o)):o=>t(o),{scale:s,constant:t.constant,accessors:[t],dataAccessor:t.constant?void 0:t,channelDef:i})}function Ye(t){return t&&"value"in t}function pn(t){return t&&"field"in t}function Hs(t){return t&&"datum"in t}function He(t){return pn(t)||Hs(t)||Ws(t)||gm(t)}function ZC(t,e){const n=t.mark.encoding[e];if(He(n))return n;throw new Error("Not a channel def with scale!")}function gm(t){return t&&"chrom"in t}function Ws(t){return t&&"expr"in t}function QC(t){return(pn(t)||Hs(t))&&"condition"in t}function eS(t){return Ye(t)&&"condition"in t}const Kr=["x","y"],tS=["x2","y2"],nS=[...Kr,...tS];function ym(t){return Kr.includes(t)}function Gi(t){return nS.includes(t)}const xm={x:"x2",y:"y2"},bm=Object.fromEntries(Object.entries(xm).map(t=>[t[1],t[0]]));function wm(t){return t in bm}function rS(t){const e=xm[t];if(e)return e;throw new Error(`${t} has no secondary channel!`)}function Jn(t){return bm[t]??t}function en(t){return["color","fill","stroke"].includes(Jn(t))}function ec(t){return["shape"].includes(t)}function Hi(t){return["x","y","x2","y2","color","fill","stroke","opacity","fillOpacity","strokeOpacity","strokeWidth","size","shape","angle","dx","dy"].includes(t)}function iS(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 Am(t){if(!ec(t))throw new Error("Not a discrete channel: "+t);const e=new Map(iS(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 Xl(){const t=e=>e;return t.invert=e=>e,t.copy=Xl,t.invertRange=()=>{},t.type="null",t}const qs="attr_",sS="uDomain_",oS="range_",aS="accessor_",vm="scale_",cS="getScaled_",mu="uRangeTexture_",gu="uParam_",Lh=3402823466e29;function uS(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 js(t,e){return`${aS}${t}_${e}`}function lS(t,e,n){let r;if(ec(t))r=Dn(Am(t)(n));else if(H(n))if(en(t))r=mS(n);else throw new Error(`String values are not supported on the "${t}" channel: ${n}`);else if(Ds(n))r=Dn(n?1:0);else if(n===null)if(en(t))r=Dn([0,0,0]);else throw new Error(`null value is not supported on the "${t}" chanel.`);else r=Dn(n);const i=js(t,e),s=` +${r.type} ${i}() { + // Constant value + return ${r}; +}`;return{channel:t,accessorGlsl:s,accessorFunctionName:i}}function fS(t,e){let n="float",r=c=>c;en(t)&&(n="vec3",r=c=>Fm(c));const i=`u${AS(t)}_${e}`,s=` // Dynamic value + uniform ${n} ${i};`,o=js(t,e);let a=` +${n} ${o}() { + // Dynamic value + return ${i}; +}`;return{channel:t,uniformName:i,uniformGlsl:s,accessorGlsl:a,accessorFunctionName:o,adjuster:r}}function Nh(t,e,n,r=[t]){const{attributeType:i}=Ys(e,t),s=qs+Kl(r),o=`in highp ${i} ${s};`,a=js(t,n),c=` +${i} ${a}() { + return ${s}; +}`;return{channel:t,attributeName:s,attributeGlsl:o,accessorGlsl:c,accessorFunctionName:a}}function hS(t,e,n){const{attributeType:r}=Ys(e,t),i=qs+Kl(t),s=` uniform highp ${r} ${i};`,o=js(t,n),a=` +${r} ${o}() { + return ${i}; +}`;return{channel:t,uniformName:i,uniformGlsl:s,accessorGlsl:a,accessorFunctionName:o}}function dS(t,e,n){e??(e=Xl());const r=Jn(t),i=sS+r,s=oS+r,{hp:o,attributeType:a}=Ys(e,t),c=e.domain?e.domain().length:void 0;let u;const f=[];f.push(""),f.push("/".repeat(70)),f.push(`// Channel: ${t}`),f.push("");const{transform:l}=uS(e.type),h=(E,...M)=>gS.apply(null,[E,"value",...M]);let p;switch(l){case"linear":p=h("scaleLinear","domain",s);break;case"log":p=h("scaleLog","domain",s,e.base());break;case"symlog":p=h("scaleSymlog","domain",s,e.constant());break;case"pow":case"sqrt":p=h("scalePow","domain",s,e.exponent());break;case"index":case"locus":p=h("scaleBandHp","domain",s,e.paddingInner(),e.paddingOuter(),e.align(),n.band??.5);break;case"point":case"band":p=h("scaleBand","domain",s,e.paddingInner(),e.paddingOuter(),e.align(),n.band??.5);break;case"ordinal":case"null":case"identity":p=h("scaleIdentity");break;case"threshold":break;default:throw new Error(`Unsupported scale type: ${e.type}! ${t}: ${JSON.stringify(n)}`)}const d=Im(e,t);let m;if(d&&t==r){const E=e.props.range??[];if(Ee(E)||E.some(Ee)){if(d.length<1||d.length>4)throw new Error(`A range with ExprRefs must have 1-4 elements, not ${d.length}! Range: ${JSON.stringify(d)}`);m=` uniform ${Cm(d.length)} ${s};`}else if(d.length&&d.every(Ce)){const M=$h(d);f.push(`const ${M.type} ${s} = ${M};`)}}const g=Sm(t);let y;if(en(t)){const E=mu+r;if(t==r&&f.push(`uniform sampler2D ${E};`),ue(e.type))y=`getInterpolatedColor(${E}, transformed)`;else if(Zt(e.type)||Cn(e.type))y=`getDiscreteColor(${E}, int(transformed))`;else throw new Error("Problem with color scale!")}else if(e.type==="ordinal"||Cn(e.type)){const E=mu+r;t==r&&f.push(`uniform sampler2D ${E};`),y=`getDiscreteColor(${E}, int(transformed)).r`}const x=[],w=ue(e.type)&&c>2,v=Cn(e.type)||w;if(x.push("int slot = 0;"),v){const E=i;x.push(w?`while (slot < ${E}.length() - 2 && value >= ${E}[slot + 1]) { slot++; }`:`while (slot < ${E}.length() && value >= ${E}[slot]) { slot++; }`)}const C=ue(e.type)||Cn(e.type)||["band","point"].includes(e.type);if(p){const E=i;C&&(o?x.push(`vec3 domain = ${E};`):x.push(`vec2 domain = vec2(${E}[slot], ${E}[slot + 1]);`)),x.push(`float transformed = ${p};`),w&&x.push(`transformed = (float(slot) + transformed) / (float(${E}.length() - 1));`)}else x.push("float transformed = float(slot);");"clamp"in e&&e.clamp()&&x.push(`transformed = clampToRange(transformed, ${$h(d)});`),x.push(`return ${y??"transformed"};`),f.push(` +${g} ${vm}${t}(${a} value) { +${x.map(E=>` ${E} +`).join("")} +}`);const S=f.join(` +`);if(C&&t==r){const E=ue(e.type)||Cn(e.type)?c:2;u=o?` highp vec3 ${i};`:` mediump float ${i}[${E}];`}return{glsl:S,domainUniformName:i,domainUniform:u,rangeUniformName:s,rangeUniform:m}}function pS(t,e){const n=Sm(t),r=[],i=[];for(let s=0;s4)throw new Error("Invalid number of components: "+e);const n=Cm(e),r=`${n}(${t.map(Em).join(", ")})`;return Object.assign(r,{type:n,numComponents:e})}function Cm(t){switch(t){case 1:return"float";case 2:return"vec2";case 3:return"vec3";case 4:return"vec4";default:throw new Error("Invalid number of components: "+t)}}function Sm(t){return en(t)?"vec3":t=="uniqueId"?"uint":"float"}function Fm(t){const e=Kt(t).rgb();return[e.r,e.g,e.b].map(n=>n/255)}function mS(t){return Dn(Fm(t))}function $h(t){return Dn([t[0],Rs(t)])}function gS(t,...e){const n=[];for(const r of e)Ce(r)?n.push(Em(r)):he(r)?n.push(Dn(r)):n.push(r);return`${t}(${n.join(", ")})`}function Ys(t,e){var o;const n=t&&Zt(t.type),r=t&&Tm(t.type),i=r&&yS(t.domain()),s=i?{attributeType:"uvec2",arrayConstructor:Uint32Array}:r?{attributeType:"uint",arrayConstructor:Uint32Array}:n?{attributeType:"uint",arrayConstructor:Uint16Array}:e=="uniqueId"?{attributeType:"uint",arrayConstructor:Uint32Array}:{attributeType:"float",arrayConstructor:Float32Array};return Object.assign(s,{numComponents:+(((o=s.attributeType.match(/^vec([234])$/))==null?void 0:o[1])??1),discrete:n,hp:r,largeHp:i})}function Tm(t){return t=="index"||t=="locus"}function yS(t){return t[1]>2**32}const xS=12,yu=2**xS;function Dm(t,e=[]){const n=t%yu,r=(t-n)/yu;return e[0]=r,e[1]=n,e}function bS(t){const e=t%yu;return[t-e,e]}function wS(t){return[...bS(t[0]),t[1]-t[0]]}function _m(t){const e=new Mt([],JSON.stringify);for(const[n,r]of Object.entries(t)){const i=r.channelDef;if(pn(i)){const o=[i.field,r.scale?(ue(r.scale.type)||Cn(r.scale.type))??!1:!1];e.set(o,[...e.get(o)??[],n])}}return e}function Kl(t){return Be(t).join("_")}function AS(t){return t[0].toUpperCase()+t.slice(1)}const Im=(t,e)=>qa(t.type)||ue(t.type)&&en(e)?[0,1]:t.range?t.range():void 0;function vS(t,e){if(t.length!=e.length)throw new Error("Unequal array lengths");const n=t.length;if(n==0)return"";if(n==1&&t[0]==null)return e[0];const r=[];for(let i=0;ir(i(s)):s=>r(i(s)))}createUpdater(e,n,r=Float32Array,i=void 0){if(!Ce(this.size))throw new Error("The number of vertices must be defined!");let s,o,a=0;const c=new r(this.size*n);if(this.arrays[e]={data:c,numComponents:n},n==1){let u=0;const f=l=>{u=+l};s=()=>{c[a++]=u},o=f}else{let u=i??[0];const f=i?l=>{}:l=>{u=l};switch(n){case 1:break;case 2:s=()=>{c[a++]=u[0],c[a++]=u[1]},o=f;break;case 3:s=()=>{c[a++]=u[0],c[a++]=u[1],c[a++]=u[2]},o=f;break;case 4:s=()=>{c[a++]=u[0],c[a++]=u[1],c[a++]=u[2],c[a++]=u[3]},o=f;break;default:throw new Error("Invalid numComponents: "+n)}}return this.pushers.push(s),o}pushAll(){throw new Error("Call configure() first!")}updateFromDatum(e){throw new Error("Call configure() first!")}pushFromDatum(e){this.updateFromDatum(e),this.pushAll()}}Yi=new WeakMap,na=new WeakSet,Rm=function(){if(this.size>Uh){const e=this.pushers.map((r,i)=>`const p${i} = that.pushers[${i}];`).join(` +`),n=this.pushers.map((r,i)=>` p${i}();`).join(` +`);this.pushAll=new Function("that",`${e} +return function unrolledPushAll() { +${n} + that.vertexCount++; +};`)(this)}else this.pushAll=()=>{for(let e=0;eUh){const e=this.dataUpdaters.map((r,i)=>`const u${i} = that.dataUpdaters[${i}];`).join(` +`),n=this.dataUpdaters.map((r,i)=>` u${i}(datum);`).join(` +`);this.updateFromDatum=new Function("that","datum",`${e} +return function unrolledUpdateFromDatum(datum) { +${n} +};`)(this)}else this.updateFromDatum=e=>{for(let n=0;n{const w=(y-u)/l,v=Math.floor(w);return Gr(x&&v==w?v-1:v,0,t-1)};function p(y,x,w){if(a)return;if(x>s)s=x;else{a=!0,console.debug("Items are not ordered properly. Disabling binned index.");return}const v=n(y);if(vx&&(i[C]=x),c[C]s)s=x;else{a=!0,console.debug("Items (vertices) are not ordered properly. Disabling binned index.");return}const v=n(y),C=r(y);if(vx&&(i[M]=x),c[M]{const v=h(y,!1),C=h(x,!0),S=i[v],E=Math.max(c[C],S);return w[0]=S,w[1]=E,w},g=()=>{if(a)return;for(let x=1;x0;x--)y&&i[x]==zh?(i[x]=c[x],y=!1):i[x-1]>i[x]&&(i[x-1]=i[x]);return m};return p.getIndex=g,d.getIndex=g,n==r?p:d}function FS(){let t=0,e,n=0;const r=new Map,i=s=>(s===e||(n=r.get(s),n===void 0&&(n=t++,r.set(s,n)),e=s),n);return i.addAll=s=>{for(const o of s)i(o)},i.invert=s=>{for(const o of r.entries())if(o[1]==s)return o[0]},i.domain=()=>[...r.keys()],i}class Xs{constructor({encoders:e,numVertices:n=void 0,attributes:r=[]}){this.encoders=e,this.variableEncoders=Object.fromEntries(Object.entries(e).filter(([s,o])=>r.includes(s)&&o&&!o.constant));const i=[..._m(e).entries()].filter(([s,o])=>s[1]&&o.length>1).map(([s,o])=>o);this.allocatedVertices=n,this.variableBuilder=new ES(n);for(const[s,o]of Object.entries(this.variableEncoders)){const a=o.dataAccessor;if(!a)continue;const c=i.find(w=>w.find(v=>v==s));if(c&&s!=c[0])continue;const u=a.asNumberAccessor(),f=o.scale,{largeHp:l,arrayConstructor:h,discrete:p,numComponents:d}=Ys(f,s),m=[0,0];let g;f&&p&&"domain"in f&&(g=FS(),g.addAll(f.domain()));const y=g?w=>g(a(w)):l?w=>Dm(u(w),m):u,x=c?Kl(c):s;this.variableBuilder.addConverter(x,{f:y,numComponents:d,arrayReference:l?m:void 0,targetArrayType:h})}this.lastOffset=0,this.rangeMap=new Mt([],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{this.addToXIndex=f=>{},this.xIndexer=void 0},s=(u=this.encoders.x)==null?void 0:u.channelDef;if(!("buildIndex"in s)||!s.buildIndex||!e.length||r-n<0){i();return}const o=f=>{var l;return f&&ue((l=f.scale)==null?void 0:l.type)&&f},a=o(this.variableEncoders.x),c=o(this.variableEncoders.x2);if(a&&!a.constant&&(!c||!c.constant)){const f=a.dataAccessor.asNumberAccessor(),l=c?c.dataAccessor.asNumberAccessor():f,h=[f(e[n]),l(e[r-1])];if(h[1]>h[0]){this.xIndexer=SS(50,h,f,l);let p=this.variableBuilder.vertexCount;this.addToXIndex=d=>{let m=this.variableBuilder.vertexCount;this.xIndexer(d,p,m),p=m}}else i()}else i()}addToXIndex(e){}toArrays(){return{arrays:this.variableBuilder.arrays,vertexCount:this.variableBuilder.vertexCount,allocatedVertices:this.allocatedVertices,rangeMap:this.rangeMap}}}class TS extends Xs{constructor({encoders:e,attributes:n,numItems:r}){super({encoders:e,attributes:n,numVertices:r*6}),this.variableBuilder.configure();const i=this.variableBuilder.pushAll;this.pushAllSixTimes=r>500?new Function("pushAll",`return function unrolledPushAllSixTimes() { + pushAll(); pushAll(); pushAll(); pushAll(); pushAll(); pushAll(); +};`)(i):function(){i(),i(),i(),i(),i(),i()}}addBatch(e,n,r=0,i=n.length){if(!(i<=r)){this.prepareXIndexer(n,r,i);for(let s=r;sc,this.updateVertexCoord=this.variableBuilder.createUpdater("vertexCoord",2),this.updateTextureCoord=this.variableBuilder.createUpdater("textureCoord",2),this.updateWidth=this.variableBuilder.createUpdater("width",1),this.variableBuilder.configure()}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=-lr;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,l=[0,0];this.updateVertexCoord(l);const h=[0,0];this.updateTextureCoord(h),this.prepareXIndexer(n,r,i);for(let p=r;p0.0){float sd=abs(d)-halfStrokeWidth;return mix(stroke,d<=0.0 ? fill : vec4(0.0),distanceToRatio(sd));}else{return fill*distanceToRatio(-d);}}`,MS="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 scaleIdentity(uint value){return float(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(uint 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+(float(value)-domainExtent[0])*step+bandwidth*band;}const int lowBits=12;const float lowDivisor=pow(2.0,float(lowBits));const uint lowMask=uint(lowDivisor-1.0);vec2 splitUint(uint value){uint valueLo=value&lowMask;uint valueHi=value-valueLo;return vec2(float(valueHi),float(valueLo));}/***High precision variant of scaleBand for index/locus scales*/float scaleBandHp(uint 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);vec2 splitValue=splitUint(value);float inf=1.0/uZero;float hi=max(splitValue[0]-domainStart[0],-inf);float lo=max(splitValue[1]-domainStart[1],-inf);return dot(vec4(start,hi,lo,bandwidth),vec4(1.0,step,step,band));}/***High precision variant of scaleBand for index/locus scales for large*domains where 32bit uints are not sufficient to represent the domain.*/float scaleBandHp(uvec2 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);vec2 splitValue=vec2(float(value[0])*lowDivisor,float(value[1]));float inf=1.0/uZero;float hi=max(splitValue[0]-domainStart[0],-inf);float lo=max(splitValue[1]-domainStart[1],-inf);return dot(vec4(start,hi,lo,bandwidth),vec4(1.0,step,step,band));}",kS=`/***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;}}`,BS=`/**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 +uint id=attr_uniqueId;vPickingColor=vec4(ivec4(id>>0,id>>8,id>>16,id>>24)&0xFF)/float(0xFF); +#else +vPickingColor=vec4(1.0); +#endif +return true;}return false;}`,PS="in highp vec4 vPickingColor;",Eo=Symbol("cacheMap");function tc(t,e,n){let r=Wi(t).get(e);return r===void 0&&(r=n(e),Wi(t).set(e,r)),r}function OS(t,e){Wi(t).delete(e)}function Co(t,e){const n=Wi(t);for(const r of n.keys())r.startsWith(e)&&n.delete(r);Wi(t).delete(e)}function km(t){t[Eo]=new Map}function Wi(t){return t[Eo]||km(t),t[Eo]}function LS(t,e,n,r){const i=H(t)?t:t.name,s=!H(t)&&t.extent||[0,1];if(n===void 0&&!H(t)&&(n=t.count),i){const o=Hl(i);if(je(o)){const a=Bm(o,{extent:s,count:n});return nc(e,{minMag:e.LINEAR,format:e.RGB,height:1,wrap:e.CLAMP_TO_EDGE},a,r)}else{if(he(o))return bu(o,e);throw new Error("Unknown scheme: "+i)}}}function NS(t,e="rgb",n,r){const i=ja(t,H(e)?e:e.type,H(e)?void 0:e.gamma),s=Bm(i);return nc(n,{minMag:n.LINEAR,format:n.RGB,height:1,wrap:n.CLAMP_TO_EDGE},s,r)}function $S(t,e,n,r){const i=Math.max(t.length,n||0),s=new Float32Array(i);for(let o=0;oa/(r-1)).map(a=>i+a/s).map(t);return n&&o.reverse(),Pm(o)}function Pm(t,e){const n=Math.max(t.length,e||0),r=new Uint8Array(n*3);for(let i=0;i({width:void 0,height:void 0})),this._shaderCache=new Map,this.rangeTextures=new WeakMap;const s=document.createElement("canvas");e.appendChild(s);const o=jA(s,{antialias:!0,depth:!1,premultipliedAlpha:!0,...i});if(!o)throw new Error("Unable to initialize WebGL. Your browser or machine may not support it.");if(!qr(o))throw new Error("Your web browser does not support WebGL 2.0. Chrome, Firefox, and Safari Tech Preview should work.");if(ip(o),o.blendFunc(o.ONE,o.ONE_MINUS_SRC_ALPHA),this.canvas=s,this.gl=o,this._pickingAttachmentOptions=[{format:o.RGBA,type:o.UNSIGNED_BYTE,minMag:o.LINEAR,wrap:o.CLAMP_TO_EDGE}],this._pickingBufferInfo=zA(o,this._pickingAttachmentOptions),o.bindFramebuffer(o.FRAMEBUFFER,null),this.adjustGl(),this._updateDpr(),this._clearColor=[0,0,0,0],r){const a=Kt(r).rgb();this._clearColor=[a.r/255,a.g/255,a.b/255,a.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;";he(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,VA(this.gl,this._pickingBufferInfo,this._pickingAttachmentOptions)}finalize(){this.canvas.remove()}getPhysicalCanvasSize(e){return e=e||this.getLogicalCanvasSize(),{width:e.width*this.dpr,height:e.height*this.dpr}}getLogicalCanvasSize(){if(this._logicalCanvasSize)return this._logicalCanvasSize;const e=this._sizeSource(),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}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 Zt(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(en(s)){const o=e.scale,a=o.props,c=o.range();let u;if(a.scheme)if(o.type=="threshold"&&c)u=bu(c,this.gl,o.domain().length,r);else{let f=H(a.scheme)?void 0:a.scheme.count;f=i(f,o),u=LS(a.scheme,this.gl,f,r)}else qa(o.type)||ue(o.type)&&c.length>1?u=NS(c,a.interpolate,this.gl,r):u=bu(c,this.gl,o.domain().length,r);this.rangeTextures.set(e,u)}else{const o=e.scale;if(o.type==="ordinal"||Cn(o.type)){const a=ec(s)?Am(s):u=>u,c=o.range();this.rangeTextures.set(e,$S(c.map(a),this.gl,o.domain().length,r))}}}}function zS(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 VS(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=zS(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 nc(t,e,n,r){return r?S0(t,r,n,e):r=Li(t,{...e,src:n}),r}function Gh(...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 GS(t){return H(t)||Ce(t)||Ds(t)}class Gn extends Error{constructor(e,n){super(e),this.name="ViewError",this.view=n}}const HS="SAMPLE_FACET_UNIFORM",Hh="SAMPLE_FACET_TEXTURE";var at;class Ks{constructor(e){F(this,at,[]);this.unitView=e,this.encoders=void 0,this.bufferInfo=void 0,this.bytesPerElement=new Map,this.programInfo=void 0,this.vertexArrayInfo=void 0,this.viewUniformInfo=void 0,this.markUniformInfo=void 0,this.markUniformsAltered=!0,this.rangeMap=new WS,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=Gh(typeof this.unitView.spec.mark=="object"?()=>this.unitView.spec.mark:()=>({}),()=>this.defaultProperties)}augmentDefaultProperties(e){Object.defineProperties(this.defaultProperties,Object.getOwnPropertyDescriptors(e))}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:Qt}),e}fixEncoding(e){return e}setupExprRefsNeedingGraphicsUpdate(e){const n=this.getSupportedChannels(),r={};for(const s of e){const o=this.properties[s];if(o&&Ee(o)){const a=this.unitView.paramMediator.createExpression(o.expr);a.addListener(()=>{this.updateGraphicsData(),this.unitView.context.animator.requestRender()}),n.includes(s)||Object.defineProperty(r,s,{get(){return a()}})}}const i=this.properties;this.properties=Gh(()=>r,()=>i)}get encoding(){return tc(this,"encoding",()=>{var o;const e=this.getDefaultEncoding(),n=this.unitView.getEncoding(),r=a=>{const c=this.properties[a];return GS(c)||Ee(c)?{value:c}:void 0},i=Object.fromEntries(this.getSupportedChannels().map(a=>[a,r(a)]).filter(a=>Ye(a[1]))),s=this.fixEncoding({...e,...i,...n});for(const a of Object.keys(s))this.getSupportedChannels().includes(a)||delete s[a];return s.x&&((o=s.x).buildIndex??(o.buildIndex=!0)),s})}getContext(){return this.unitView.context}getType(){return this.unitView.getMarkType()}initializeData(){}initializeEncoders(){this.encoders=KC(this.unitView,this.encoding)}async initializeGraphics(){}updateGraphicsData(){}getSampleFacetMode(){if(this.encoders.facetIndex)return Hh;if(this.unitView.getLayoutAncestors().find(e=>"samples"in e.spec))return HS}createAndLinkShaders(e,n,r=[]){const i=this.getAttributes(),s=this.encoders,o=this.getSampleFacetMode();o&&r.push(`#define ${o}`);const a="// view: "+this.unitView.getPathString();let c=[];const u=new Set,f=_m(s),l=[],h=Object.values(s).flatMap(C=>C.accessors).map(C=>C.predicate).filter(C=>C.param),p=new Map;for(const C of h){const S=C.param,E=this.unitView.paramMediator.getValue(S);if(!E)throw new Error(`Cannot infer selection type as the parameter "${S}" has no value. Please ensure that the parameter is properly defined!`);if(pm(E)){if(!p.has(S)){const M=gu+Qa(S);p.set(S,"single"),l.push(" // Selection parameter"),l.push(` uniform highp uint ${M};`),b(this,at).push(()=>{this.registerMarkUniformValue(M,{expr:S},P=>P.uniqueId??0)})}}else throw new Error(`Unsupported selection (${S}) in condition: ${JSON.stringify(E)}`)}const d=(C,S,E,M)=>{const P=S.channelDef;if(Ye(P))if(Ee(P.value)){const{uniformName:O,uniformGlsl:R,accessorGlsl:q,adjuster:J}=fS(C,E);c.push(q),l.push(R),b(this,at).push(()=>{this.registerMarkUniformValue(O,P.value,J)})}else c.push(lS(C,E,P.value).accessorGlsl);else if(Hs(P)){const{uniformName:O,uniformGlsl:R,accessorGlsl:q}=hS(C,M,E);l.push(R),c.push(q);const{largeHp:J,discrete:we}=Ys(M,C),We=we&&"domain"in M?Ae=>M.domain().indexOf(Ae):J?Dm:Ae=>+Ae;b(this,at).push(()=>{this.registerMarkUniformValue(O,P.datum,We)})}else if(pn(P)){const O=f.get([P.field,!0]),{attributeGlsl:R,accessorGlsl:q}=Nh(C,M,E,O!=null&&O.includes(C)?O:void 0);u.add(R),c.push(q)}else if(Ws(P)){const{attributeGlsl:O,accessorGlsl:R}=Nh(C,M,E);u.add(O),c.push(R)}else throw new Gn(`Unsupported channel definition: ${JSON.stringify(P)}`,this.unitView)};for(const[C,S]of Object.entries(s)){if(!i.includes(C))continue;const{channelDef:E,accessors:M,scale:P}=S;for(let O=0;O{const Oe=this.createMarkUniformSetter(Ae),Te=()=>Oe(Im(P,C));R.addEventListener("range",Te),Te()}),J&&b(this,at).push(()=>{const Oe=this.createMarkUniformSetter(we),Te=()=>{const de=Zt(P.type)?[0,P.domain().length]:P.domain();Oe(Tm(P.type)?wS(de):de)};R.addEventListener("domain",Te),Te()})}c.push(pS(C,M))}const m=[...p.entries()].filter(([,C])=>C=="single").map(([C])=>`${gu}${C} == ${qs}uniqueId`);c.push("bool isPointSelected() {",this.encoders.uniqueId&&m.length>0?` return ${m.join(" || ")};`:" return false;","}");const g=`precision highp float; +precision highp int;`,y=C=>C.replace("#pragma markUniforms",l.join(` +`));r=r.map(y),e=y(e),n=y(n);const x=[g,a,...r,Vh,MS,[...u].join(` +`),...c,kS,BS,e],w=[g,a,...r,Vh,PS,n],v=this.gl;this.programStatus=VS(v,this.glHelper.compileShader(v.VERTEX_SHADER,x),this.glHelper.compileShader(v.FRAGMENT_SHADER,w))}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=EA(this.gl,this.programStatus.program),delete this.programStatus,this.viewUniformInfo=th(this.gl,this.programInfo,"View"),this.markUniformInfo=th(this.gl,this.programInfo,"Mark"),this.gl.useProgram(this.programInfo.program),fr(this.programInfo,{uSampleFacet:[0,1,0,1],uTransitionOffset:0,uZero:0});for(const n of b(this,at))n();k(this,at,void 0)}createMarkUniformSetter(e){const n=this.markUniformInfo.setters[e];if(!n)throw new Error(`Uniform "${e}" not found int the Mark block!`);return r=>{n(r),this.markUniformsAltered=!0,this.unitView.context.animator.requestRender()}}registerMarkUniformValue(e,n,r=i=>i){const i=this.createMarkUniformSetter(e),s=o=>{if(o==null)throw new Error(`Trying to set null/undefined value for uniform: ${e}${Ee(n)?`Expr: ${n.expr}`:""}`);i(o)};if(Ee(n)){const o=this.unitView.paramMediator.createExpression(n.expr),a=()=>s(r(o(null)));o.addListener(a),a()}else s(r(n))}deleteGraphicsData(){const e=this.gl;if(this.vertexArrayInfo&&(this.gl.bindVertexArray(null),e.deleteVertexArray(this.vertexArrayInfo.vertexArrayObject),this.vertexArrayInfo=void 0),this.bufferInfo){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&&Ob(this.gl,this.bufferInfo.attribs[n],r.data,0);else{this.deleteGraphicsData(),this.bufferInfo=$b(this.gl,e.arrays,{numElements:e.vertexCount}),this.bufferInfo.allocatedVertices=e.allocatedVertices;for(const[n,r]of Object.entries(e.arrays))this.bytesPerElement.set(n,r.data.BYTES_PER_ELEMENT)}}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&&!this.unitView.paramMediator.hasPointSelections())return!1;for(const e of this.unitView.getLayoutAncestors())if(!e.isPickingSupported())return!1;return!0}bindOrSetMarkUniformBlock(){this.markUniformsAltered?(nh(this.gl,this.programInfo,this.markUniformInfo),this.markUniformsAltered=!1):J0(this.gl,this.programInfo,this.markUniformInfo)}prepareRender(e){const n=this.glHelper,r=this.gl,i=[];i.push(()=>{this.vertexArrayInfo||(this.vertexArrayInfo=GA(this.gl,this.programInfo,this.bufferInfo)),r.useProgram(this.programInfo.program)});for(const[o,a]of Object.entries(this.encoding))if(He(a)){const c=He(a)&&a.resolutionChannel||o;if(Hi(c)){const u=this.unitView.getScaleResolution(c),f=n.rangeTextures.get(u);f&&i.push(()=>fr(this.programInfo,{[mu+o]:f}))}}this.getSampleFacetMode()==Hh&&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.");fr(this.programInfo,{uSampleFacetTexture:o})});const s=(e.picking??!1)&&this.isPickingParticipant();return i.push(()=>Ni(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)return()=>{};const r=this;let i;const s=(l=this.unitView.getScaleResolution("x"))==null?void 0:l.scale,o=s&&ue(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(w=>w*r),g=m.map(w=>Math.floor(w)),y=m[0]-g[0],x=m[1]-g[1];i.viewport(...g),i.scissor(...g),i.enable(i.SCISSOR_TEST),f={uViewOffset:[(c+h+y/r)/l.width,-(u+p-x/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 Ni(this.viewUniformInfo,{...f,uViewportSize:[e.width,e.height],uDevicePixelRatio:r}),nh(this.gl,this.programInfo,this.viewUniformInfo),!0}findDatumAt(e,n){}}at=new WeakMap;class WS extends Mt{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 this.entries())e.has(n)||(r.offset=0,r.count=0,r.xIndex=void 0);for(const[n,r]of e.entries())Object.assign(this.get(n),r)}}function wu(t,e){const n=rS(e);let r=t[e]&&{...t[e]},i=t[n]&&{...t[n]};if(!(Ye(r)||Ye(i))){if(r){if(!He(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,contributesToScaleDomain:!1};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 Om(t,e){t.stroke||(e?t.stroke={value:null}:t.stroke={resolutionChannel:"color",...t.color}),Ye(t.stroke)&&t.stroke.value===null&&(t.strokeWidth={value:0}),t.strokeOpacity||(t.strokeOpacity={resolutionChannel:"opacity",...t.opacity})}function Lm(t,e){Ye(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 Xi,Au,Ki,vu;class qS extends Ks{constructor(n){super(n);F(this,Xi);F(this,Ki);this.augmentDefaultProperties({x2:void 0,y2:void 0,filled:!0,color:"#4c78a8",opacity:1,strokeWidth:3,cornerRadius:0,minWidth:.5,minHeight:.5,minOpacity:1})}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 tc(this,"opaque",()=>!D(this,Xi,Au).call(this)&&!D(this,Ki,vu).call(this)&&Ye(this.encoding.fillOpacity)&&this.encoding.fillOpacity.value==1&&this.properties.minOpacity==1)&&this.unitView.getEffectiveOpacity()==1}fixEncoding(n){return wu(n,"x"),wu(n,"y"),Om(n,this.properties.filled),Lm(n,this.properties.filled),delete n.color,delete n.opacity,n}onBeforeSampleAnimation(){}onAfterSampleAnimation(){}async initializeGraphics(){await super.initializeGraphics();const n=[];D(this,Xi,Au).call(this)&&n.push("ROUNDED_CORNERS"),D(this,Ki,vu).call(this)&&n.push("STROKED"),this.createAndLinkShaders(YA,XA,[KA,...n.map(r=>"#define "+r)])}finalizeGraphicsInitialization(){super.finalizeGraphicsInitialization(),this.gl.useProgram(this.programInfo.program);const n=this.properties;this.registerMarkUniformValue("uMinWidth",n.minWidth),this.registerMarkUniformValue("uMinHeight",n.minHeight),this.registerMarkUniformValue("uMinOpacity",n.minOpacity),this.registerMarkUniformValue("uCornerRadiusTopRight",n.cornerRadiusTopRight??n.cornerRadius??0),this.registerMarkUniformValue("uCornerRadiusBottomRight",n.cornerRadiusBottomRight??n.cornerRadius??0),this.registerMarkUniformValue("uCornerRadiusTopLeft",n.cornerRadiusTopLeft??n.cornerRadius??0),this.registerMarkUniformValue("uCornerRadiusBottomLeft",n.cornerRadiusBottomLeft??n.cornerRadius??0)}updateGraphicsData(){const n=this.unitView.getCollector();if(!n){console.debug("No collector");return}const r=n.getItemCount(),i=new TS({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(()=>jn(this.gl,this.programInfo,this.vertexArrayInfo)),r}render(n){const r=this.gl;return this.createRenderCallback((i,s)=>{La(r,this.vertexArrayInfo,r.TRIANGLE_STRIP,s,i)},n)}findDatumAt(n,r){n=Be(n);const i=this.unitView.getCollector().facetBatches.get(n);if(!i)return;const s=this.encoders,o=s.x.scale.type;if(Zt(o)){const a=s.x.dataAccessor;return i.find(c=>r==a(c))}else{const a=s.x.dataAccessor,c=s.x2.dataAccessor;return i.find(u=>r>=a(u)&&r=uSemanticThreshold ? 1.0 : 0.0;}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;float opacity=uViewOpacity;if(strokeWidth<=0.0||uInwardStroke){float minDiameter=1.0/uDevicePixelRatio;if(diameterTICK_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=max((diameter+padding),uPickingEnabled ? uMinPickingSize : 0.0)*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();}`,YS="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;}}",XS=`layout(std140)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 float uMinPickingSize;uniform mediump float uScaleFactor;uniform mediump float uZoomLevel;uniform highp float uSemanticThreshold;uniform mediump float uGradientStrength; +#pragma markUniforms +};`;class Nm extends Z{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 KS(t,e,n){const r=new Nm({type:"sample",size:t});for(const i of e)r.handle(n(i));return r.complete(),r.reservoir}const JS={};var gr,ia,$m;class ZS extends Ks{constructor(n){super(n);F(this,ia);F(this,gr,()=>0);this.augmentDefaultProperties({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,minPickingSize:2});const r=this.properties.semanticZoomFraction;if(r!=null)if(Ee(r)){const i=this.unitView.paramMediator.createExpression(r.expr);i.addListener(()=>this.getContext().animator.requestRender()),k(this,gr,i)}else k(this,gr,()=>r)}getAttributes(){return["uniqueId","facetIndex","x","y","size","semanticScore","shape","strokeWidth","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(),...JS}}fixEncoding(n){return Om(n,this.properties.filled),Lm(n,this.properties.filled),delete n.color,delete n.opacity,n}initializeData(){var r,i;super.initializeData();const n=(i=(r=this.encoders.semanticScore)==null?void 0:r.dataAccessor)==null?void 0:i.asNumberAccessor();n&&(this.sampledSemanticScores=Float32Array.from(KS(1e4,this.unitView.getCollector().getData(),n)),this.sampledSemanticScores.sort((s,o)=>s-o))}async initializeGraphics(){await super.initializeGraphics(),this.createAndLinkShaders(jS,YS,[XS])}finalizeGraphicsInitialization(){super.finalizeGraphicsInitialization(),this.gl.useProgram(this.programInfo.program);const n=this.properties;this.registerMarkUniformValue("uInwardStroke",n.inwardStroke,r=>!!r),this.registerMarkUniformValue("uGradientStrength",n.fillGradientStrength),this.registerMarkUniformValue("uMinPickingSize",n.minPickingSize)}updateGraphicsData(){const n=this.unitView.getCollector();if(!n){console.debug("No collector");return}const r=n.getItemCount(),i=new _S({encoders:this.encoders,attributes:this.getAttributes(),numItems:Math.max(r,this.properties.minBufferSize||0)});i.addBatches(n.facetBatches);const s=i.toArrays();this.rangeMap.migrateEntries(s.rangeMap),this.updateBufferInfo(s)}getSemanticThreshold(){if(this.sampledSemanticScores){const n=Math.max(0,1-b(this,gr).call(this)*this.unitView.getZoomLevel());if(n<=0)return-1/0;if(n>=1)return 1/0;{const r=this.sampledSemanticScores;return Ud(r,n)}}else return-1}prepareRender(n){const r=super.prepareRender(n);return r.push(()=>{Ni(this.markUniformInfo,{uScaleFactor:D(this,ia,$m).call(this),uSemanticThreshold:this.getSemanticThreshold()}),this.markUniformsAltered=!0}),r.push(()=>this.bindOrSetMarkUniformBlock()),r.push(()=>jn(this.gl,this.programInfo,this.vertexArrayInfo)),r}render(n){const r=this.gl;return this.createRenderCallback((i,s)=>{s&&La(r,this.vertexArrayInfo,r.POINTS,s,i)},n)}}gr=new WeakMap,ia=new WeakSet,$m=function(){const n=Math.pow(2,this.properties.geometricZoomBound||0);return Math.pow(Math.min(1,this.unitView.getZoomLevel()/n),1/3)};const QS="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(size0.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();}",e3="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;}}",t3=`layout(std140)uniform Mark{uniform mediump float uMinLength;uniform mediump float uDashTextureSize;uniform lowp int uStrokeCap;uniform mediump float uStrokeDashOffset; +#pragma markUniforms +};`;class n3 extends Ks{constructor(e){super(e),this.dashTextureSize=0,this.augmentDefaultProperties({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&&He(e.y)&&e.y.type=="quantitative")e.x2=e.x,e.y2={datum:0};else if(!e.y2&&He(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=r3(this.properties.strokeDash);this.dashTexture=Li(e,{mag:e.NEAREST,min:e.NEAREST,internalFormat:e.R8,format:e.RED,src:n,height:1}),this.dashTextureSize=n.length}this.createAndLinkShaders(QS,e3,[t3])}finalizeGraphicsInitialization(){super.finalizeGraphicsInitialization(),this.gl.useProgram(this.programInfo.program);const e=this.properties;this.registerMarkUniformValue("uMinLength",e.minLength),this.registerMarkUniformValue("uStrokeCap",e.strokeCap??"butt",n=>["butt","square","round"].indexOf(n)),Ni(this.markUniformInfo,{uDashTextureSize:+this.dashTextureSize}),this.markUniformsAltered=!0}updateGraphicsData(){const e=this.unitView.getCollector();if(!e){console.debug("No collector");return}const n=e.getItemCount(),r=new DS({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(()=>fr(this.programInfo,{uDashTexture:this.dashTexture})),n.push(()=>jn(this.gl,this.programInfo,this.vertexArrayInfo)),n}render(e){const n=this.gl;return this.createRenderCallback((r,i)=>La(n,this.vertexArrayInfo,n.TRIANGLE_STRIP,i,r),e)}}function r3(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 i3="out vec4 vColor;out float vSize;out float vNormalLengthInPixels;out float vGamma;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.x0.0){p1.y=max(p1.y,-p4.y);}if(p1.yuMaxChordLength){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;}vec2 strip=vec2(float(gl_VertexID/2)/float(uSegmentBreaks),float(gl_VertexID % 2)-0.5);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(size0.0&&uArcFadingDistance[1]>0.0&&(!uNoFadingOnPointSelection||!isPointSelected())){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);vGamma=getGammaForColor(color);vSize=paddedSize;setupPicking();}",s3="in vec4 vColor;in float vSize;in float vNormalLengthInPixels;in float vGamma;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);opacity=pow(opacity,vGamma);fragColor=vColor*opacity;if(uPickingEnabled){fragColor=vPickingColor;}}",o3=`layout(std140)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;uniform bool uNoFadingOnPointSelection;uniform int uSegmentBreaks; +#pragma markUniforms +};`,a3=["arc","dome","diagonal","line"],c3=["vertical","horizontal"];class u3 extends Ks{constructor(e){super(e),this.augmentDefaultProperties({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,noFadingOnPointSelection:!0,linkShape:"arc",orient:"vertical"}),this._baseInstanceExt=this.gl.getExtension("WEBGL_draw_instanced_base_vertex_base_instance")}getAttributes(){return["uniqueId","facetIndex","x","x2","y","y2","size","color","opacity"]}getSupportedChannels(){return[...super.getSupportedChannels(),"x2","y2","size"]}fixEncoding(e){return e.x2||(He(e.x)?e.x2={datum:0}:e.x2=e.x),e.y2||(He(e.y)?e.y2={datum:0}:e.y2=e.y),e}async initializeGraphics(){await super.initializeGraphics(),this.createAndLinkShaders(i3,s3,[o3])}finalizeGraphicsInitialization(){super.finalizeGraphicsInitialization(),this.gl.useProgram(this.programInfo.program);const e=this.properties;this.registerMarkUniformValue("uArcFadingDistance",e.arcFadingDistance,n=>n||[0,0]),this.registerMarkUniformValue("uArcHeightFactor",e.arcHeightFactor),this.registerMarkUniformValue("uMinArcHeight",e.minArcHeight),this.registerMarkUniformValue("uMinPickingSize",e.minPickingSize),this.registerMarkUniformValue("uShape",e.linkShape,n=>a3.indexOf(n)),this.registerMarkUniformValue("uOrient",e.orient,n=>c3.indexOf(n)),this.registerMarkUniformValue("uClampApex",e.clampApex,n=>!!n),this.registerMarkUniformValue("uMaxChordLength",e.maxChordLength),this.registerMarkUniformValue("uSegmentBreaks",e.segments,n=>n),this.registerMarkUniformValue("uNoFadingOnPointSelection",e.noFadingOnPointSelection,n=>!!n)}updateGraphicsData(){const e=this.unitView.getCollector();if(!e){console.debug("No collector");return}const n=e.getItemCount(),r=new IS({encoders:this.encoders,attributes:this.getAttributes(),numItems:n});r.addBatches(e.facetBatches);const i=r.toArrays();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()),this._baseInstanceExt?n.push(()=>jn(this.gl,this.programInfo,this.vertexArrayInfo)):n.push(()=>this.gl.bindVertexArray(null)),n}render(e){const n=this.gl,r=()=>(this.markUniformInfo.uniforms.uSegmentBreaks[0]+1)*2;return this._baseInstanceExt?this.createRenderCallback((i,s)=>{this._baseInstanceExt.drawArraysInstancedBaseInstanceWEBGL(n.TRIANGLE_STRIP,0,r(),s,i)},e):this.createRenderCallback((i,s)=>{for(const o of Object.entries(this.bufferInfo.attribs)){const[a,c]=o;c.buffer&&c.numComponents&&c.divisor&&(c.offset=i*this.arrays[a].numComponents*this.bytesPerElement.get(a))}jn(n,this.programInfo,this.bufferInfo),n.drawArraysInstanced(n.TRIANGLE_STRIP,0,r(),s)},e)}}const l3=`in mediump vec2 vertexCoord;in lowp vec2 textureCoord;in float width;out vec2 vTexCoord;out vec4 vColor;out float vSlope;out float vEdgeFadeOpacity;out float vGamma;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-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();}`,f3="uniform sampler2D uTexture;in vec2 vTexCoord;in float vEdgeFadeOpacity;in vec4 vColor;in float vSlope;in float vGamma;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*=clamp(vEdgeFadeOpacity,0.0,1.0);opa=pow(opa,vGamma);fragColor=vColor*opa;if(uPickingEnabled){fragColor=vPickingColor;}}",h3=`layout(std140)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; +#pragma markUniforms +};`,d3={left:-1,center:0,right:1},p3={top:-1,middle:0,bottom:1,alphabetic:1};class m3 extends Ks{constructor(e){super(e),this.augmentDefaultProperties({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(),this.setupExprRefsNeedingGraphicsUpdate(["text","fitToBand","logoLetters"])}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 Kr)this.properties.fitToBand&&wu(e,n);return e}async initializeGraphics(){await super.initializeGraphics(),this.createAndLinkShaders(l3,f3,[h3])}finalizeGraphicsInitialization(){super.finalizeGraphicsInitialization(),this.gl.useProgram(this.programInfo.program);const e=this.properties;this.registerMarkUniformValue("uSdfNumerator",{expr:"devicePixelRatio"},n=>{let r=.35;return this.properties.logoLetters&&(r/=2),this.font.metrics.common.base/(n/r)}),this.registerMarkUniformValue("uPaddingX",e.paddingX),this.registerMarkUniformValue("uPaddingY",e.paddingY),this.registerMarkUniformValue("uFlushX",e.flushX,n=>!!n),this.registerMarkUniformValue("uFlushY",e.flushY,n=>!!n),this.registerMarkUniformValue("uSqueeze",e.squeeze,n=>!!n),Ni(this.markUniformInfo,{uAlign:[d3[e.align],p3[e.baseline]],uD:[e.dx,-e.dy],uLogoLetter:!!e.logoLetters,uViewportEdgeFadeWidth:[e.viewportEdgeFadeWidthTop,e.viewportEdgeFadeWidthRight,e.viewportEdgeFadeWidthBottom,e.viewportEdgeFadeWidthLeft],uViewportEdgeFadeDistance:[e.viewportEdgeFadeDistanceTop,e.viewportEdgeFadeDistanceRight,e.viewportEdgeFadeDistanceBottom,e.viewportEdgeFadeDistanceLeft]})}updateGraphicsData(){const e=this.unitView.getCollector();if(!e){console.debug("No collector");return}const n=e.getData(),r=this.encoding,i=this.encoders.text;let s=0;const o="format"in r.text?fe(r.text.format):u=>u;for(const u of n){const f=o(i(u)),l=H(f)?f:f===null?"":""+f;s+=l&&l.length||0}const a=new RS({encoders:this.encoders,attributes:this.getAttributes(),properties:this.properties,fontMetrics:this.font.metrics,numCharacters:Math.max(s,this.properties.minBufferSize||1024)});a.addBatches(e.facetBatches);const c=a.toArrays();this.rangeMap.migrateEntries(c.rangeMap),this.updateBufferInfo(c)}prepareRender(e){const n=super.prepareRender(e);return n.push(()=>{fr(this.programInfo,{uTexture:this.font.texture})}),n.push(()=>this.bindOrSetMarkUniformBlock()),n.push(()=>jn(this.gl,this.programInfo,this.vertexArrayInfo)),n}render(e){const n=this.gl;return this.createRenderCallback((r,i)=>La(n,this.vertexArrayInfo,n.TRIANGLES,i,r),e)}}const Wh=1;function Jl(){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=ny(f),n=t[1]-t[0];const l=t[0]===0&&t[0]===0;if(nr/n,u.bandwidth=()=>u.step(),u.ticks=f=>{const l=u.align(),h=u.numberingOffset();return Bo(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=qt(t[0],t[1],Math.min(f,Math.ceil(n)))<1e5?fe(","):fe(".3s");return d=>p(d+a)},u.copy=()=>Jl().domain(t).range(e).paddingInner(i).paddingOuter(s).numberingOffset(a),u}function g3(){const t=Jl().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,qt(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{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=qt(s[0],s[1],Math.min(r,Math.ceil(o)))<1e6?fe(","):fe(".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 y3(t){return t.type=="locus"}function Xo(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||ar(o)&&ar(a)||ar(o)&&a===!0||o===!0&&be(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(ar(u))ar(c)&&(r[a]=Xo([u,c],a));else if(ar(c)){if(!(u===!0||u===void 0))throw new Error("Bug in merge! Target is: "+u);r[a]=Xo([{},c],a)}else r[a]=c}}};for(const o of t)s(o);return r}function ar(t){return be(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 Um(t,e,n){return Ce(e)&&n!=null&&(e=Math.min(e,~~(Ro(t.domain())/n)||1)),be(e)&&(e.step,e=e.interval),e}function zm(t,e,n){var r=t.range(),i=Math.floor(r[0]),s=Math.ceil(nt(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],nt(e)];e.length>n&&e.length>=3;)e=e.filter(function(a,c){return!(c%2)});e.length<3&&(e=o)}return e}function x3(t,e){return t.bins?zm(t,b3(t.bins,e)):t.ticks?t.ticks(e):t.domain()}function b3(t,e){var n=t.length,r=~~(n/(e||n));return r<2?t.slice():t.filter(function(i,s){return!(s%r)})}function w3(t,e,n){var r=t.tickFormat?t.tickFormat(e,n):n?fe(n):String;if(Qp(t.type)){var i=v3(n);r=t.bins?i:A3(r,i)}return r}function A3(t,e){return function(n){return t(n)?e(n):""}}function v3(t){var e=jt(t||",");if(e.precision==null){switch(e.precision=12,e.type){case"%":e.precision-=2;break;case"e":e.precision-=1;break}return E3(fe(e),fe(".1f")(1)[1])}else return fe(e)}function E3(t,e){return function(n){var r=t(n),i=r.indexOf(e),s,o;if(i<0)return r;for(s=C3(r,i),o=si;)if(r[s]!=="0"){++s;break}return r.slice(0,s)+o}}function C3(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 S3="locus",F3="index";var T3=5;function D3(t){const e=t.type;return!t.bins&&(e===Vr||e===Os||e===Ls)}function Vm(t){return ue(t)&&![ht,F3,S3].includes(t)}function Gm(t){return t||{warn:(e,...n)=>console.warn(e,...n)}}var _3=Mo(["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 Hm(t,e,n){n=Gm(n);for(const r in t)if(!_3[r]){if(r==="padding"&&Vm(e.type))continue;je(e[r])?e[r](t[r]):n.warn("Unsupported scale property: "+r)}L3(e,t,O3(e,t,k3(e,t,n)))}function I3(t,e){const n=R3(t),r=V(n);if(!r)throw new Error("Unknown scale type: "+n);const i=r();return!t.domain&&ue(i.type)&&(t.domain=[0,0]),Hm(t,i,e),i}function R3(t){var e=t.type,n="",r;return e===ht?ht+"-"+Vr:(M3(t)&&(r=t.rawDomain?t.rawDomain.length:t.domain?t.domain.length+ +(t.domainMid!=null):0,n=r===2?ht+"-":r===3?Xr+"-":""),(n+e||Vr).toLowerCase())}function M3(t){const e=t.type;return ue(e)&&e!==Wp&&e!==qp&&(t.scheme||t.range&&t.range.length&&t.range.every(H))}function k3(t,e,n){if(!t.domain)return 0;n=Gm(n);var r=B3(t,e.domainRaw,n);if(r>-1)return r;var i=e.domain,s=t.type,o=e.zero||e.zero===void 0&&D3(t),a,c;return i?(Vm(s)&&e.padding&&i[0]!==nt(i)&&(i=P3(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,(ci[a])&&n.warn("Scale domainMid exceeds domain min or max.",c),i.splice(a,0,c))),t.domain(Wm(s,i,n)),s===zl&&t.unknown(e.domainImplicit?eu:void 0),e.nice&&t.nice&&t.nice(e.nice!==!0&&Um(t,e.nice)||null),i.length):0}function B3(t,e,n){return e?(t.domain(Wm(t.type,e,n)),e.length):-1}function P3(t,e,n,r,i,s){n??(n=[0,1]);var o=Math.abs(nt(n)-n[0]),a=o/(o-2*r),c=t===Jt?_d(e,null,a):t===Ls?Nc(e,null,a,.5):t===Os?Nc(e,null,a,i||1):t===Wa?y1(e,null,a,s||1):Dd(e,null,a);return e=e.slice(),e[0]=c[0],e[e.length-1]=c[1],e}function Wm(t,e,n){if(Qp(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: "+Ku(e))}return e}function O3(t,e,n){let r=e.bins;if(r&&!he(r)){const i=(r.start==null||r.stop==null)&&t.domain(),s=r.start==null?i[0]:r.start,o=r.stop==null?nt(i):r.stop,a=r.step;a||te("Scale bins parameter missing step property."),r=Ci(s,o+a,a)}return r?t.bins=r:t.bins&&delete t.bins,t.type===Vl&&(r?!e.domain&&!e.domainRaw&&(t.domain(r),n=r.length):t.bins=t.domain()),n}function L3(t,e,n){var r=t.type,i=e.round||!1,s=e.range;if(e.rangeStep!=null)s=N3(r,e,n);else if(e.scheme&&(s=$3(r,e,n),je(s))){if(t.interpolator)return t.interpolator(s);te(`Scale type ${r} does not support interpolating color schemes.`)}if(s&&qa(r))return t.interpolator(ja(Eu(s,e.reverse),e.interpolate,e.interpolateGamma));s&&e.interpolate&&t.interpolate?t.interpolate(em(e.interpolate,e.interpolateGamma)):je(t.round)?t.round(i):je(t.rangeRound)&&t.interpolate(i?Bs:ln),s&&t.range(Eu(s,e.reverse))}function N3(t,e,n){t!==Xp&&t!==fu&&te("Only band and point scales support rangeStep.");var r=(e.paddingOuter!=null?e.paddingOuter:e.padding)||0,i=t===fu?1:(e.paddingInner!=null?e.paddingInner:e.padding)||0;return[0,e.rangeStep*Ul(n,i,r)]}function $3(t,e,n){var r=e.schemeExtent,i,s;return he(e.scheme)?s=ja(e.scheme,e.interpolate,e.interpolateGamma):(i=e.scheme.toLowerCase(),s=Hl(i),s||te(`Unrecognized scheme name: ${e.scheme}`)),n=t===Yp?n+1:t===Vl?n-1:t===lu||t===jp?+e.schemeCount||T3:n,qa(t)?qh(s,r,e.reverse):je(s)?vE(qh(s,r),n):t===zl?s:s.slice(0,n)}function qh(t,e,n){return je(t)&&(e||n)?AE(t,Eu(e||[0,1],n)):t}function Eu(t,e){return e?t.slice().reverse():t}const jh=fe(",d");function U3(t,e){return t.chrom+":"+jh(Math.floor(t.pos+1))+"-"+(t.chrom!=e.chrom?e.chrom+":":"")+jh(Math.ceil(e.pos))}const z3=`chr3R 32079331 +chr3L 28110227 +chr2R 25286936 +chrX 23542271 +chr2L 23513712 +chrY 3667352 +chr4 1348131 +chrM 19524`,V3=`chr1 247249719 +chr2 242951149 +chr3 199501827 +chr4 191273063 +chr5 180857866 +chr6 170899992 +chr7 158821424 +chr8 146274826 +chr9 140273252 +chr10 135374737 +chr11 134452384 +chr12 132349534 +chr13 114142980 +chr14 106368585 +chr15 100338915 +chr16 88827254 +chr17 78774742 +chr18 76117153 +chr19 63811651 +chr20 62435964 +chr21 46944323 +chr22 49691432 +chrX 154913754 +chrY 57772954 +chrM 16571`,G3=`chr1 249250621 +chr2 243199373 +chr3 198022430 +chr4 191154276 +chr5 180915260 +chr6 171115067 +chr7 159138663 +chr8 146364022 +chr9 141213431 +chr10 135534747 +chr11 135006516 +chr12 133851895 +chr13 115169878 +chr14 107349540 +chr15 102531392 +chr16 90354753 +chr17 81195210 +chr18 78077248 +chr19 59128983 +chr20 63025520 +chr21 48129895 +chr22 51304566 +chrX 155270560 +chrY 59373566 +chrM 16571`,H3=`chr1 248956422 +chr2 242193529 +chr3 198295559 +chr4 190214555 +chr5 181538259 +chr6 170805979 +chr7 159345973 +chr8 145138636 +chr9 138394717 +chr10 133797422 +chr11 135086622 +chr12 133275309 +chr13 114364328 +chr14 107043718 +chr15 101991189 +chr16 90338345 +chr17 83257441 +chr18 80373285 +chr19 58617616 +chr20 64444167 +chr21 46709983 +chr22 50818468 +chrX 156040895 +chrY 57227415 +chrM 16569`,W3=`chr1 197195432 +chr2 181748087 +chr3 159599783 +chr4 155630120 +chr5 152537259 +chr6 149517037 +chr7 152524553 +chr8 131738871 +chr9 124076172 +chr10 129993255 +chr11 121843856 +chr12 121257530 +chr13 120284312 +chr14 125194864 +chr15 103494974 +chr16 98319150 +chr17 95272651 +chr18 90772031 +chr19 61342430 +chrX 166650296 +chrY 15902555 +chrM 16299`,q3=`chr1 195471971 +chr2 182113224 +chr3 160039680 +chr4 156508116 +chr5 151834684 +chr6 149736546 +chr7 145441459 +chr8 129401213 +chr9 124595110 +chr10 130694993 +chr11 122082543 +chr12 120129022 +chr13 120421639 +chr14 124902244 +chr15 104043685 +chr16 98207768 +chr17 94987271 +chr18 90702639 +chr19 61431566 +chrX 171031299 +chrY 91744698 +chrM 16299`,Yh={dm6:z3,hg18:V3,hg19:G3,hg38:H3,mm9:W3,mm10:q3};function j3(t){if(!(t in Yh))throw new Error(`Unknown assembly: ${t}`);return Yh[t].split(` +`).map(e=>{const n=e.split(" ");return{name:n[0],size:parseInt(n[1])}})}const Y3=/^([A-Za-z]+:)?\/\//;function qi(t,e){if(e&&Y3.test(e))return e;const n=typeof t=="function"?t():t;if(!n)return e;if(!e)return n;if(/[#?]/.test(n))throw new Error(`Cannot append to a url with query or hash. Append: ${e}, base: ${n}`);return qm(n)+e}function qm(t){const e=t.replace(/[^/]*$/,"");return e===""?void 0:e.endsWith("://")?t+"/":e}class X3{constructor(e){if(this.config={name:"custom",...e},"baseUrl"in e)throw new Error("The `baseUrl` property in genome config has been removed in GenomeSpy v0.52.0. Use `url` instead. See https://genomespy.app/docs/genomic-data/genomic-coordinates/.");if(!Zl(e))throw new Error("Not a genome configuration: "+JSON.stringify(e));if(this.chromosomes=[],this.cumulativeChromPositions=new Map,this.chromosomesByName=new Map,this.startByIndex=[],this.totalSize=0,Ym(this.config))this.setChromSizes(this.config.contigs);else if(!Cu(this.config)){const n=j3(this.config.name);if(n)this.setChromSizes(n);else throw new Error(`Unknown genome: ${this.config.name}. Please provide contigs or a URL. See https://genomespy.app/docs/genomic-data/genomic-coordinates/.`)}}get name(){return this.config.name}async load(e){if(Cu(this.config))try{const n=qi(e,this.config.url),r=await fetch(n);if(!r.ok)throw new Error(`${r.status} ${r.statusText}`);this.setChromSizes(K3(await r.text()))}catch(n){throw new Error(`Could not load chrom sizes: ${this.config.url}. Reason: ${n.message}`)}}hasChrPrefix(){return this.chromosomes.some(e=>e.name.startsWith("chr"))}setChromSizes(e){let n=0;this.startByIndex=[0];for(let r=0;rthis.totalSize)return;e=Math.floor(e);const n=Wr(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 U3(...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;aa===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 K3(t){return s1(t).map(([e,n])=>({name:e,size:parseInt(n)}))}function jm(t){return be(t)&&"chrom"in t}function J3(t){return t.every(jm)}function Zl(t){return be(t)&&("name"in t||Cu(t)||Ym(t))}function Cu(t){return Zl(t)&&"url"in t}function Ym(t){return Zl(t)&&"contigs"in t}class Js extends Array{constructor(){super(),this.type=void 0}extend(e){return this}extendAll(e){if(e instanceof Js&&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 Rc extends Js{constructor(){super(),this.type="quantitative"}extend(e){return e==null||Number.isNaN(e)?this:(e=+e,this.length?ethis[1]&&(this[1]=e):(this.push(e),this.push(e)),this)}}class Xm extends Js{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 Km extends Xm{constructor(){super(),this.type="nominal"}}class Z3 extends Js{constructor(e){super();let n=0;for(let r=1;rthis.push(r))}extend(e){if(this.includes(e))return this;throw new Error("Piecewise domains are immutable and cannot be unioned!")}}const Xh={quantitative:Rc,index:Rc,locus:Rc,nominal:Km,ordinal:Xm};function Jm(t,e){if(t=="quantitative"&&Q3(e)){const n=new Z3(e);return n.type=t,n}else if(Xh[t]){const n=new Xh[t];return n.type=t,e&&n.extendAll(e),n}throw new Error("Unknown type: "+t)}function Q3(t){return t&&t.length>0&&t.length!=2&&t.every(e=>typeof e=="number")}function e4(t){return((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2}function t4(t,e,n){return t*Math.pow(e/t,n)}V("index",Jl,["continuous"]);V("locus",g3,["continuous"]);V("null",Xl,[]);const Kh="quantitative",Zm="ordinal",Qm="nominal",eg="locus",n4="index";var vt,yr,Ue,Ji,Zi,Su,Qi,Fu,Qe,wt,es,Tu,sa,tg,oa,ng,ts,Du,ns,_u,xr,So,rs,Iu,Et,vn,is,Ru,aa,rg;class r4{constructor(e){F(this,Zi);F(this,Qi);F(this,Qe);F(this,es);F(this,sa);F(this,oa);F(this,ts);F(this,ns);F(this,xr);F(this,rs);F(this,Et);F(this,is);F(this,aa);F(this,vt,void 0);F(this,yr,{domain:new Set,range:new Set});F(this,Ue,void 0);F(this,Ji,new Set);this.channel=e,this.members=[],this.type=null,this.name=void 0}addEventListener(e,n){b(this,yr)[e].add(n)}removeEventListener(e,n){b(this,yr)[e].delete(n)}addMember(e){var o;const{channel:n,channelDef:r}=e,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&&!wm(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(e)}getDataDomain(){return this.members.map(e=>{var n;return(n=e.dataDomainSource)==null?void 0:n.call(e,e.channel,this.type)}).filter(e=>!!e).reduce((e,n)=>e.extendAll(n))}reconfigure(){const e=b(this,Ue);if(!e||e.type=="null")return;const n=D(this,sa,tg).call(this),r=e.domain(),i=D(this,ts,Du).call(this,!0);if(Hm({...i,range:void 0},e),e.props=i,D(this,ns,_u).call(this),ue(e.type)&&k(this,vt,D(this,is,Ru).call(this)),!n){D(this,Qe,wt).call(this,"domain");return}const s=e.domain();No(s,r)||(this.isZoomable()?e.domain(r):D(this,Et,vn).call(this)?(e.domain(r),this.zoomTo(s,500)):D(this,Qe,wt).call(this,"domain"))}get scale(){if(b(this,Ue))return b(this,Ue);const e=D(this,ts,Du).call(this),n=I3({...e,range:void 0});n.props=e,"unknown"in n&&n.unknown(null),k(this,Ue,n),D(this,ns,_u).call(this),y3(n)&&n.genome(this.getGenome()),ue(n.type)&&k(this,vt,D(this,is,Ru).call(this));const r=n.range;if(r){const i=()=>D(this,Qe,wt).call(this,"range");n.range=function(s){if(arguments.length)r(s),i();else return r()},i()}return n}getDomain(){return this.scale.domain()}getComplexDomain(){var e;return((e=this.getGenome())==null?void 0:e.toChromosomalInterval(this.getDomain()))??this.getDomain()}isZoomed(){return D(this,Et,vn).call(this)&&No(D(this,xr,So).call(this),this.getDomain())}isZoomable(){return D(this,Et,vn).call(this)&&!!this.scale.props.zoom}zoom(e,n,r){if(!D(this,Et,vn).call(this))return!1;const i=this.scale,s=i.domain();let o=[...s],a=i.invert(n);switch(i.props.reverse&&(r=-r),"align"in i&&(a+=i.align()),i.type){case"linear":case"index":case"locus":o=p1(o,r||0),o=Dd(o,a,e);break;case"log":o=m1(o,r||0),o=_d(o,a,e);break;case"pow":case"sqrt":{const c=i;o=g1(o,r||0,c.exponent()),o=Nc(o,a,e,c.exponent());break}default:throw new Error("Zooming is not implemented for: "+i.type)}return b(this,vt)&&(o=x1(o,b(this,vt)[0],b(this,vt)[1])),[0,1].some(c=>o[c]!=s[c])?(i.domain(o),D(this,Qe,wt).call(this,"domain"),!0):!1}async zoomTo(e,n=!1){if(Ds(n)&&(n=n?700:0),!D(this,Et,vn).call(this))throw new Error("Not a zoomable scale!");const r=this.fromComplexInterval(e),i=b(this,Qi,Fu).animator,s=this.scale,o=s.domain();if(n>0&&o.length==2){const a=o[1]-o[0],c=r[1]-r[0],u=o[0]+a/2,f=r[0]+c/2,l=o[0]==r[0],h=o[1]==r[1];await i.transition({duration:n,easingFunction:e4,onUpdate:p=>{const d=t4(a,c,p),m=a==c?p:(a-d)/(a-c),g=m*f+(1-m)*u,y=[l?o[0]:g-d/2,h?o[1]:g+d/2];s.domain(y),D(this,Qe,wt).call(this,"domain")}}),s.domain(r),D(this,Qe,wt).call(this,"domain")}else s.domain(r),i==null||i.requestRender(),D(this,Qe,wt).call(this,"domain")}resetZoom(){if(!D(this,Et,vn).call(this))throw new Error("Not a zoomable scale!");const e=this.getDomain(),n=D(this,xr,So).call(this);return[0,1].some(r=>n[r]!=e[r])?(b(this,Ue).domain(n),D(this,Qe,wt).call(this,"domain"),!0):!1}getZoomLevel(){return this.isZoomable()?Ro(b(this,vt))/Ro(this.scale.domain()):1}getAxisLength(){if(this.channel!=="x"&&this.channel!=="y")throw new Error("Axis length is only defined for x and y channels!");const e=this.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}getGenome(){var n;if(this.type!=="locus")return;const e=(n=b(this,Qi,Fu).genomeStore)==null?void 0:n.getGenome();if(!e)throw new Error("No genome has been defined!");return e}invertToComplex(e){const n=this.scale;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 jm(e)?this.getGenome().toContinuous(e.chrom,e.pos):e}fromComplexInterval(e){return this.type==="locus"&&J3(e)?this.getGenome().toContinuousInterval(e):e}}vt=new WeakMap,yr=new WeakMap,Ue=new WeakMap,Ji=new WeakMap,Zi=new WeakSet,Su=function(){return this.members[0].view},Qi=new WeakSet,Fu=function(){return b(this,Zi,Su).context},Qe=new WeakSet,wt=function(e){for(const n of b(this,yr)[e].values())n({type:e,scaleResolution:this})},es=new WeakSet,Tu=function(){return!!D(this,rs,Iu).call(this)},sa=new WeakSet,tg=function(){const e=b(this,Ue);if(!e)return!1;const n=e.domain();return ue(e.type)?n.length>2||n.length==2&&(n[0]!==0||n[1]!==0):n.length>0},oa=new WeakSet,ng=function(){const e=this.members.map(n=>n.channelDef.scale).filter(n=>n!==void 0);return Xo(e,"scale",["domain"])},ts=new WeakSet,Du=function(e=!1){const n=D(this,oa,ng).call(this);if(n===null||n.type=="null")return{type:"null"};const r={...D(this,aa,rg).call(this,this.type),...n};r.type||(r.type=i4(this.channel,this.type));const i=D(this,xr,So).call(this,e);return i&&i.length>0?r.domain=i:Zt(r.type)&&(r.domain=new Km),!r.domain&&r.domainMid!==void 0&&(r.domain=[r.domainMin??0,r.domainMax??1]),this.channel=="y"&&Zt(r.type)&&r.reverse==null&&(r.reverse=!0),r.range&&r.scheme&&delete r.scheme,!("zoom"in r)&&["index","locus"].includes(r.type)&&(r.zoom=!0),s4(r,this.channel),r},ns=new WeakSet,_u=function(){const e=b(this,Ue).props,n=e.range;if(b(this,Ji).forEach(i=>i.invalidate()),!n||!he(n))return;const r=(i,s)=>s?i.slice().reverse():i;if(n.some(Ee)){let i;const s=()=>{b(this,Ue).range(r(i.map(o=>o()),e.reverse))};i=n.map(o=>{if(Ee(o)){const a=b(this,Zi,Su).paramMediator.createExpression(o.expr);return a.addListener(s),b(this,Ji).add(a),()=>a(null)}else return()=>o}),s()}else b(this,Ue).range(r(n,e.reverse))},xr=new WeakSet,So=function(e=!1){return D(this,rs,Iu).call(this)??(this.type==eg?this.getGenome().getExtent():e?this.getDataDomain():[])},rs=new WeakSet,Iu=function(){const e=this.members.map(n=>n.channelDef).filter(n=>{var r;return(r=n.scale)==null?void 0:r.domain}).map(n=>Jm(n.type,this.fromComplexInterval(n.scale.domain)));if(e.length>0)return e.reduce((n,r)=>n.extendAll(r))},Et=new WeakSet,vn=function(){const e=this.scale.type;return ue(e)},is=new WeakSet,Ru=function(){const e=this.scale.props,n=e.zoom;if(o4(n)&&he(n.extent))return this.fromComplexInterval(n.extent);if(n)return e.type=="locus"?this.getGenome().getExtent():b(this,Ue).domain()},aa=new WeakSet,rg=function(e){const n=this.channel,r={};return D(this,es,Tu).call(this)&&(r.zero=!1),Gi(n)?r.nice=!D(this,es,Tu).call(this):en(n)?r.scheme=e==Qm?"tableau10":e==Zm?"blues":"viridis":ec(n)?r.range=n=="shape"?["circle","square","triangle-up","cross","diamond"]:[]:n=="size"?r.range=[0,400]:n=="angle"&&(r.range=[0,360]),r};function i4(t,e){if(e==n4||e==eg){if(ym(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][[Qm,Zm,Kh].indexOf(e)]:e==Kh?"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 s4(t,e){Gi(e)&&t.type!=="ordinal"&&(t.range=[0,1]),e=="opacity"&&ue(t.type)&&(t.clamp=!0)}function o4(t){return be(t)}function Mu(t){const e=new Set;function n(r){for(const i of Object.values(r.resolutions.scale))e.add(i)}for(const r of Be(t)){r.visit(n);for(const i of r.getDataAncestors()){if(!i.options.contributesToScaleDomain)break;n(i)}}e.forEach(r=>r.reconfigure())}function Mc(...t){for(const e of t)if(e!==void 0)return e}class a4{constructor(e){this.channel=e,this.members=[]}get scaleResolution(){var e;return(e=Rs(this.members))==null?void 0:e.view.getScaleResolution(this.channel)}addMember(e){const{view:n}=e,r=n.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! Channel: ${this.channel}, existing views: [${this.members.map(i=>i.view.getPathString()).join(", ")}], new view: ${n.getPathString()}.`);this.members.push(e)}getAxisProps(){return tc(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:Xo(e.filter(n=>n!==void 0),"axis",["title"])})}getTitle(){const e=s=>{var a;const o=ZC(s.view,s.channel);if(!Ye(o))return{member:s,explicitTitle:Mc("axis"in o?(a=o.axis)==null?void 0:a.title:void 0,o.title),implicitTitle:Mc(pn(o)?o.field:void 0,Ws(o)?o.expr:void 0)}},n=this.members.map(e),r=n.filter(s=>{var o;if(wm(s.member.channel)&&!s.explicitTitle){const a=Jn(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=>Mc(s.explicitTitle,s.implicitTitle)).filter(H));return i.size?[...i].join(", "):null}}function Jh(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+=xo(d.px)+(kc(d)?0:n),a+=xo(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 y=0;y0);const g=xo(m.px)+(a?xo(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 c4(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 ss,ku;const of=class of{constructor(e,n){F(this,ss);this.width=e,this.height=n}addPadding(e){return D(this,ss,ku).call(this,e.width,e.height)}subtractPadding(e){return D(this,ss,ku).call(this,-e.width,-e.height)}isGrowing(){return!!(this.width.grow||this.height.grow)}};ss=new WeakSet,ku=function(e,n){return new of({px:(this.width.px??0)+e,grow:this.width.grow},{px:(this.height.px??0)+n,grow:this.height.grow})};let tn=of;const gi=Object.freeze({px:0,grow:0}),Zh=new tn(gi,gi);function kc(t){return!t.px&&!t.grow}function xo(t){return t||0}function u4(t){return t&&(Ce(t.px)||Ce(t.grow))}function ig(t){if(og(t))throw new Error("parseSizeDef does not accept step-based sizes.");if(u4(t))return t;if(Ce(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 me{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 me(this.top+e,this.right+e,this.bottom+e,this.left+e)}add(e){return new me(this.top+e.top,this.right+e.right,this.bottom+e.bottom,this.left+e.left)}subtract(e){return new me(this.top-e.top,this.right-e.right,this.bottom-e.bottom,this.left-e.left)}union(e){return new me(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 me(0,this.right,0,this.left)}getVertical(){return new me(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):Bu}static createFromRecord(e){return new me(e.top,e.right,e.bottom,e.left)}static zero(){return Bu}static createUniformPadding(e){return new me(e,e,e,e)}}const Bu=me.createUniformPadding(0);Object.freeze(Bu);function Zs(t,e){return!e||/^(data:|([A-Za-z]+:)?\/\/)/.test(t)||t.startsWith("/")?t:(e.endsWith("/")||(e+="/"),e+t)}function l4(t){if(!t)return t;if(/[?#]/.test(t))throw new Error(`Invalid base URL: ${t} - cannot contain query or hash.`);return t.endsWith("/")?t:t+"/"}const f4="VISIT_SKIP",yi="VISIT_STOP",Qh=t=>t;var br,os,as,cs,us,Mn,li,ls,Pu;class sg{constructor(e,n,r,i,s,o={}){F(this,Mn);F(this,ls);F(this,br,{});F(this,os,{});F(this,as,{});F(this,cs,void 0);F(this,us,void 0);ve(this,"opacityFunction",Qh);ve(this,"facetCoords",new Mt([],JSON.stringify));var a;if(!e)throw new Error("View spec must be defined!");if(this.context=n,this.layoutParent=r,this.dataParent=i,this.name=e.name||s,this.spec=e,this.resolutions={scale:{},axis:{}},km(this),this.options={blockEncodingInheritance:!1,contributesToScaleDomain:!0,...o},this.needsAxes={x:!1,y:!1},this.paramMediator=new WC(()=>{var c;return(c=this.dataParent)==null?void 0:c.paramMediator}),e.params)for(const c of e.params)this.paramMediator.registerParam(c);if(!((a=this.layoutParent)!=null&&a.options.layeredChildren)){const c=u=>this.paramMediator.findMediatorForParam(u)?void 0:this.paramMediator.allocateSetter(u,0);k(this,us,c("height")),k(this,cs,c("width"))}}get coords(){return this.facetCoords.values().next().value}getPadding(){return this._cache("size/padding",()=>me.createFromConfig(this.spec.padding))}getOverhang(){return me.zero()}isScrollable(){return this.spec.viewportWidth!=null||this.spec.viewportHeight!=null}getSize(){return this._cache("size/size",()=>this.isConfiguredVisible()?new tn(D(this,Mn,li).call(this,"width"),D(this,Mn,li).call(this,"height")):Zh)}getViewportSize(){if(!this.isScrollable())return this.getSize();if(!this.isConfiguredVisible())return Zh;const e=this.getSize();return new tn(D(this,Mn,li).call(this,"viewportWidth")??e.width,D(this,Mn,li).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 D(this,ls,Pu).call(this,"layoutParent")}getDataAncestors(){return D(this,ls,Pu).call(this,"dataParent")}handleBroadcast(e){for(const n of b(this,br)[e.type]||[])n(e)}_addBroadcastHandler(e,n){let r=b(this,br)[e];r||(r=[],b(this,br)[e]=r),r.push(n)}handleInteractionEvent(e,n,r){const i=r?b(this,os):b(this,as);for(const s of i[n.type]||[])s(e,n)}addInteractionEventListener(e,n,r){const i=r?b(this,os):b(this,as);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!==yi)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===Qh)&&(this.opacityFunction=d4(this))}onBeforeRender(){}render(e,n,r={}){var i,s;r.firstFacet&&this.facetCoords.clear(),this.facetCoords.set(r.facetId,r.clipRect?n.intersect(r.clipRect):n),(i=b(this,cs))==null||i.call(this,n.width),(s=b(this,us))==null||s.call(this,n.height)}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 pn(n)?[n.field]:(r=this.layoutParent)==null?void 0:r.getFacetFields(this)}getSampleFacetTexture(){}getScaleResolution(e){const n=Jn(e);return this.getDataAncestors().map(r=>r.resolutions.scale[n]).find(r=>r)}getAxisResolution(e){const n=Jn(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 qi(()=>{var e;return(e=this.dataParent)==null?void 0:e.getBaseUrl()},l4(this.spec.baseUrl))}isPickingSupported(){return!0}getTitleText(){const e=this.spec.title;if(e)return H(e)?e:Ee(e.text)?this.paramMediator.evaluateAndGet(e.text.expr):e.text}_cache(e,n){return tc(this,e,n)}_invalidateCacheByPrefix(e,n="self"){switch(n){case"self":Co(this,e);break;case"ancestors":for(const r of this.getLayoutAncestors())Co(r,e);break;case"progeny":this.visit(r=>Co(r,e));break}}invalidateSizeCache(){this._invalidateCacheByPrefix("size/","ancestors")}propagateInteractionEvent(e){}}br=new WeakMap,os=new WeakMap,as=new WeakMap,cs=new WeakMap,us=new WeakMap,Mn=new WeakSet,li=function(e){var i;let n=this.spec[e];const r=e=="viewportWidth"||e=="viewportHeight";if(og(n)){if(r)throw new Gn(`Cannot use step-based size with "${e}"!`,this);const s=n.step,o=(i=this.getScaleResolution(e=="width"?"x":"y"))==null?void 0:i.scale;if(o){let a=0;if(Zt(o.type))a=o.domain().length;else if(["locus","index"].includes(o.type)){const u=o.domain();a=Rs(u)-u[0]}else throw new Gn(`Cannot use step-based size with "${o.type}" scale!`,this);const c=o;return a=Ul(a,c.paddingInner(),c.paddingOuter()),{px:a*s,grow:0}}else throw new Gn("Cannot use 'step' size with missing scale!",this)}else return(n&&ig(n))??(r?void 0:{px:0,grow:1})},ls=new WeakSet,Pu=function(e){const n=[];let r=this;do n.push(r),r=r[e];while(r);return n};function h4(t){return"unitsPerPixel"in t}function d4(t){const e="opacity"in t.spec?t.spec.opacity:void 0;if(e!==void 0){if(Ce(e))return n=>n*e;if(h4(e)){const n=s=>{var a;const o=(a=t.getScaleResolution(s))==null?void 0:a.scale;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 Gn("Cannot find a resolved quantitative scale for dynamic opacity!",t);const i=Ml().domain(e.unitsPerPixel).range(e.values).clamp(!0);return s=>{const a=Ro(r.domain())/1e3;return i(a)*s}}else if(Ee(e)){const n=t.paramMediator.createExpression(e.expr);return n.addListener(()=>t.context.animator.requestRender()),r=>n(null)*r}}return n=>n}const og=t=>!!(t!=null&&t.step),p4={point:ZS,rect:qS,rule:n3,link:u3,text:m3};var fs,ca,ag;class Ge extends sg{constructor(n,r,i,s,o,a){super(n,r,i,s,o,a);F(this,ca);F(this,fs,void 0);this.spec=n;const c=p4[this.getMarkType()];if(c)this.mark=new c(this);else throw new Error(`No such mark: ${this.getMarkType()}`);this.resolve(),k(this,fs,this.paramMediator.allocateSetter("zoomLevel",1)),["x","y"].forEach(u=>{var f;return(f=this.getScaleResolution(u))==null?void 0:f.addEventListener("domain",()=>b(this,fs).call(this,Math.sqrt(this.getZoomLevel())))}),this.needsAxes={x:!0,y:!0},D(this,ca,ag).call(this)}render(n,r,i={}){super.render(n,r,i),this.isConfiguredVisible()&&(n.pushView(this,r),n.renderMark(this.mark,i),n.popView(this))}getMarkType(){return typeof this.spec.mark=="object"?this.spec.mark.type:this.spec.mark}resolve(n){n||(this.resolve("scale"),this.resolve("axis"));const r=this.mark.encoding;for(const[i,s]of Object.entries(r)){if(!He(s))continue;const o=Jn(s.resolutionChannel??i);if(!Hi(o)||n=="axis"&&!Gi(o))continue;let a=this;for(;(a.getConfiguredOrDefaultResolution(o,n)=="forced"||a.dataParent&&["shared","excluded","forced"].includes(a.dataParent.getConfiguredOrDefaultResolution(o,n)))&&a.getConfiguredOrDefaultResolution(o,n)!="excluded";)a=a.dataParent;if(n=="axis"&&Gi(i)&&ym(o))a.resolutions[n][o]||(a.resolutions[n][o]=new a4(o)),a.resolutions[n][o].addMember({view:this,channel:i,channelDef:s});else if(n=="scale"&&Hi(i)){if(!a.resolutions[n][o]){const u=new r4(o);a.resolutions[n][o]=u,u.addEventListener("range",f=>{var l;(l=this.context.glHelper)==null||l.createRangeTexture(f.scaleResolution,!0)})}const c=this.getLayoutAncestors().some(u=>!u.options.contributesToScaleDomain)||He(s)&&s.contributesToScaleDomain===!1?void 0:this.extractDataDomain.bind(this);a.resolutions[n][o].addMember({view:this,channel:i,channelDef:s,dataDomainSource:c})}}}getDataAccessor(n){var r;return(r=this.mark.encoders[n])==null?void 0:r.dataAccessor}getFacetAccessor(n){const r=this.getDataAccessor("sample");return r||super.getFacetAccessor(this)}getCollector(){return this.context.dataFlow.findCollectorByKey(this)}extractDataDomain(n,r){var s;let i=Jm(r);return(((s=this.mark.encoders[n])==null?void 0:s.accessors)??[]).filter(o=>o.scaleChannel).forEach(o=>{if(o.constant)i.extend(o({}));else{const a=this.getCollector();a!=null&&a.completed&&a.visitData(c=>i.extend(o(c)))}}),i}getZoomLevel(){const n=r=>{var i;return((i=this.getScaleResolution(r))==null?void 0:i.getZoomLevel())??1};return Kr.map(n).reduce((r,i)=>r*i,1)}propagateInteractionEvent(n){this.handleInteractionEvent(void 0,n,!0),n.target=this,!n.stopped&&this.handleInteractionEvent(void 0,n,!1)}getDefaultResolution(n,r){return n=="x"?"shared":"independent"}}fs=new WeakMap,ca=new WeakSet,ag=function(){for(const[n,r]of this.paramMediator.paramConfigs){if(!("select"in r))continue;const i=r.select;if((H(i)?i:i.type)==="point"){let a=-1;const c=this.paramMediator.getSetter(n),u=()=>{var h;const l=this.context.getCurrentHover();return((h=l==null?void 0:l.mark)==null?void 0:h.unitView)===this?l.datum:null},f=!H(i)&&"on"in i?i.on:"click";this.addInteractionEventListener(["mouseover","pointerover"].includes(f)?"mousemove":"click",(l,h)=>{const p=u(),d=p?p[Qt]:-1;if(d!=a){a=d;const m=hm(u());c(m)}})}}};function*Ql(t,e=[]){for(const[n,r]of t.entries())if(r instanceof Map)for(const i of Ql(r,[...e,n]))yield i;else yield[[...e,n],r]}const cg=2147483647,m4=ug([cg]);function ug(t){let e=0;for(let n=0,r=t.length;no),r=new Array(t.length);const i=new Array(16);for(let s=0;s{const f=t[n[u]];return s>=m4?f>cg?Math.floor(f/a)%16:0:f>>o&15};for(let u=0;u=0;u--)r[--i[c(u)]]=n[u];[n,r]=[r,n]}return n}var Ct,hs,kn,Bn,ds,Ou,ps,Lu,ms,Nu,ua,fg;class lg extends Z{constructor(n){super();F(this,ds);F(this,ps);F(this,ms);F(this,ua);F(this,Ct,[]);F(this,hs,W(Qt));F(this,kn,[]);F(this,Bn,void 0);this.params=n??{type:"collect"},this.observers=[],this.facetBatches=new Mt([],JSON.stringify),D(this,ds,Ou).call(this)}get behavior(){return Yl}reset(){super.reset(),D(this,ds,Ou).call(this)}handle(n){b(this,Ct).push(n)}beginBatch(n){$C(n)&&(k(this,Ct,[]),this.facetBatches.set(Be(n.facetId),b(this,Ct)))}complete(){var s,o;k(this,Ct,[]);const n=(s=this.params)==null?void 0:s.sort,r=n?Id(n.field,n.order):void 0,i=a=>{r&&a.sort(r)};if((o=this.params.groupby)!=null&&o.length){if(this.facetBatches.size>1)throw new Error("TODO: Support faceted data!");const a=this.facetBatches.get(void 0),c=this.params.groupby.map(f=>W(f)),u=c.length>1?wa(a,...c):y4(a,c[0]);this.facetBatches.clear();for(const[f,l]of Ql(u))this.facetBatches.set(f,l)}for(const a of this.facetBatches.values())i(a);D(this,ua,fg).call(this),D(this,ps,Lu).call(this),super.complete();for(const a of this.observers)a(this)}repropagate(){for(const n of this.children)n.reset();D(this,ps,Lu).call(this);for(const n of this.children)n.complete()}getData(){switch(D(this,ms,Nu).call(this),this.facetBatches.size){case 0:return[];case 1:return[...this.facetBatches.values()][0];default:{const n=this.facetBatches;return{[Symbol.iterator]:function*(){for(const i of n.values())yield*i}}}}}visitData(n){D(this,ms,Nu).call(this);for(const r of this.facetBatches.values())for(let i=0;ic.start).right,i=b(this,hs),s=Br(c=>i(o(c))).left,o=c=>{const u=r(b(this,Bn),c),f=b(this,Bn)[u-1];return!f||c>=f.stop?void 0:this.facetBatches.get(f.facetId)[c-f.start]},a=s(b(this,kn),n);if(a>=0){const c=o(b(this,kn)[a]);if(c&&i(c)===n)return c}}}Ct=new WeakMap,hs=new WeakMap,kn=new WeakMap,Bn=new WeakMap,ds=new WeakSet,Ou=function(){k(this,Ct,[]),this.facetBatches.clear(),this.facetBatches.set(void 0,b(this,Ct))},ps=new WeakSet,Lu=function(){if(this.children.length)for(const[n,r]of this.facetBatches.entries()){if(n){const i={type:"facet",facetId:n};for(const s of this.children)s.beginBatch(i)}for(let i=0,s=r.length;i0;){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=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 x4 extends Z{get behavior(){return xt}constructor(e){super(),this.params=e,this.startAccessor=W(e.start),this.endAccessor=W(e.end),this.chromAccessor=e.chrom?W(e.chrom):n=>{},this.weightAccessor=e.weight?W(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 Ko}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=NaN;const p=this.ends;p.clear();const d=y=>{this._propagate(y),c=null},m=(y,x,w)=>{if(y==x)return;let v=!1;c&&(c[e]===w?(c[n]=x,v=!0):c[e]!=0&&d(c)),v||(c=this.createSegment(y,x,w,f))},g=()=>{let y=0;for(;(y=p.peekValue())!==void 0;)m(h,y,l),h=y,l-=p.pop();h=NaN,c&&d(c)};this.handle=y=>{const x=i(y);let w=0;for(;(w=p.peekValue())!==void 0&&w{g(),super.complete()},this.beginBatch=y=>{g(),u=null,super.beginBatch(y)}}}function b4(t,e,n=0,r=t.length){const i=new Ko,s=r-n;let o;for(o=0;o=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 w4{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 A4 extends Z{get behavior(){return Yl}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=W(this.params.pos),this.posBisector=Br(this.posAccessor),this.scoreAccessor=W(this.params.score),this.widthAccessor=W(this.params.width),this.laneAccessor=this.params.lane?W(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 w4(200));this.schedule(),super.complete()}_filterAndPropagate(){super.reset();const e=this.resolution.scale,n=this.resolution.getAxisLength();if(!n)return;for(const o of this.reservationMaps.values())o.reset();const r=e.domain(),i=70,s=b4(this._scores,i,this.posBisector.left(this._data,r[0]),this.posBisector.right(this._data,r[1]));for(const o of s){const a=this._data[o],c=e(this.posAccessor(a))*n,u=this.widthAccessor(a)/2+this.padding;this.reservationMaps.get(this.laneAccessor(a)).reserve(c-u,c+u)&&this._propagate(a)}super.complete()}reset(){super.reset(),this._data=[],this.groups=new Map}handle(e){this._data.push(e)}}class v4 extends Z{constructor(e,n){super(n),this.params=e,this.predicate=void 0}initialize(){let e="";if(E4(this.params))e=this.params.expr;else if(C4(this.params))e=dm(this.params);else throw new Error("Invalid filter params: "+JSON.stringify(this.params));this.predicate=this.paramMediator.createExpression(e),this.predicate.addListener(()=>this.repropagate())}handle(e){this.predicate(e)&&this._propagate(e)}}function E4(t){return"expr"in t}function C4(t){return"param"in t}class S4 extends Z{get behavior(){return xt}constructor(e){super();const n=e.index;if(e.fields){const r=Be(e.fields).map(s=>W(s)),i=Be(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{for(let i=0;i{let a=r(o),c=a,u=!0;const f=n(o);for(const l of T4(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 _4 extends Z{get behavior(){return xt}constructor(e){super();const n=Be(e.field).map(s=>W(s)),r=Be(e.separator),i=Be(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]));I4(o,s);const a=o[0].length;for(let c=0;cr.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 R4 extends Z{get behavior(){return dn}constructor(e,n){super(n),this.params=e,this.as=e.as,this.fn=void 0}initialize(){this.fn=this.paramMediator.createExpression(this.params.expr),this.fn.addListener(()=>this.repropagate())}handle(e){e[this.as]=this.fn(e),this._propagate(e)}}class hg extends Z{get behavior(){return dn}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=W(e.chrom),o=Be(e.pos).map(d=>W(d)),a=Be(e.as);if(o.length!=a.length)throw new Error('The number of "pos" and "as" elements must be equal!');const c=Be(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 M4=["Lato-Regular.png"],k4=[{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}],B4={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]},P4={lineHeight:50.400000000000006,base:41.454,scaleW:512,scaleH:512,pages:1,packed:0,alphaChnl:0,redChnl:0,greenChnl:0,blueChnl:0},O4=[],dg={pages:M4,chars:k4,info:B4,common:P4,kernings:O4};class L4 extends Z{get behavior(){return dn}constructor(e){super();const n=xu(dg),r=W(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 N4=65536;class $4 extends Z{get behavior(){return dn}constructor(e){super(),this.params=e}reset(){super.reset(),this.initialize()}initialize(){const e=this.params,n=e.as||"lane",r=Ce(e.spacing)?e.spacing:1,i=W(e.start),s=W(e.end);if(!e.preference!=!e.preferredOrder)throw new Error('Must specify both "preference" and "preferredOrder"');if(e.preference){const o=new Float64Array(N4),a=W(e.preference),c=e.preferredOrder;let u=1/0;this.handle=f=>{const l=i(f);l=0&&o[h]=o.length)throw new Error("Out of lanes!")}o[p]=s(f)+r,f[n]=p,this._propagate(f)}}else{const o=new Ko,a=new Ko;let c=-1/0,u=0;this.handle=f=>{const l=i(f);for(;o.length&&(o.peekValue()<=l||lW(i)),r=e.as?e.as:n.map(o1);this.handle=i=>{const s={};for(let o=0;o{const o=i(s);if(H(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;cnew RegExp(h)),r=Be(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);for(const y of n)if(!p.some(x=>y.test(x)))throw new Error(`No columns matching the regex ${y.toString()} found in the data!`);const d=new Map;for(const[y,x]of n.entries())for(const w of p){const v=(g=x.exec(w))==null?void 0:g[1];if(v!==void 0){let C=d.get(v);C||(C=[],d.set(v,C)),C[y]=w}}o=[...d.entries()],a=p.filter(y=>!n.some(x=>x.test(y))&&!(i&&i.test(y)));const m=[...a.map(y=>JSON.stringify(y)+": datum["+JSON.stringify(y)+"]"),JSON.stringify(s)+": sampleId",...r.map((y,x)=>JSON.stringify(y)+`: datum[attrs[${x}]]`)];c=new Function("datum","sampleId","attrs",`return { +`+m.join(`, +`)+` +};`)},f=h=>{o||u(h);for(let p=0;p{u(h),f(h),this.handle=f};this.handle=l,this.beginBatch=h=>{fm(h)&&(this.handle=l),super.beginBatch(h)}}}class G4 extends Z{get behavior(){return dn}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?Id(e.sort.field,e.sort.order):void 0,i=e.field?W(e.field):()=>1,s=e.groupby.map(f=>W(f)),o=oy(this.buffer,f=>s.map(l=>l(f)).join()).map(f=>f[1]);let a=f=>!0;if(e.baseField){const f=W(e.baseField);a=l=>f(l)!==null}let c,u;switch(e.offset){case"normalize":c=(f,l)=>f/l,u=(f,l)=>oo(f,l);break;case"center":c=(f,l)=>f-l/2,u=(f,l)=>oo(f,l);break;case"information":{const f=Math.log2(e.cardinality??4);c=(l,h)=>l/h,u=(l,h)=>{const d=oo(l,x=>+!a(x)),m=oo(l,h),g=m-d;let y=0;for(let x=0;xf,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 H4 extends Z{get behavior(){return xt}constructor(e){super();const n=W(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;cW(s)),i=wa(this.buffer,...r);for(const[s,o]of Ql(i)){const a={count:o.length};for(let c=0;ctypeof t!="object"?K4:J4,K4=t=>({data:t}),J4=t=>t;function ed(t){return"url"in t}class Jr extends Z{constructor(n){super();ve(this,"view");this.view=n}get identifier(){}setLoadingStatus(n,r){this.view.context.setDataLoadingStatus(this.view,n,r)}get paramMediator(){return this.view.paramMediator}handle(n){throw new Error("Source does not handle incoming data!")}async load(){}repropagate(){this.load()}}function gg(t){return"values"in t}class Z4 extends Jr{constructor(e,n){var r;if(super(n),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=mg(e[0]));else if(typeof e=="object")n=[e];else if(typeof e=="string")n=r0(e,pg(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 Q4(t){return"url"in t}class eF extends Jr{constructor(e,n){super(n),this.params=Za(n.paramMediator,e,()=>this.load()),this.baseUrl=n==null?void 0:n.getBaseUrl()}get identifier(){return JSON.stringify({params:this.params,baseUrl:this.baseUrl})}async load(){const e=Ve(this.params.url),n=Array.isArray(e)?e:[e],r=pg(this.params),i=Y4(r.type);if(n.length===0||!n[0]){this.reset(),this.complete();return}const s=async a=>{try{const c=qi(this.baseUrl,a),u=await fetch(c);if(!u.ok)throw new Error(`${u.status} ${u.statusText}`);return typeof u[i]=="function"?u[i]():u.text()}catch(c){throw new Error(`Could not load data: ${a}. Reason: ${c.message}`)}},o=(a,c)=>{try{const u=r0(a,r);this.beginBatch({type:"file",url:c});for(const f of u)this._propagate(f)}catch(u){throw new Error(`Cannot parse: ${c}: ${u.message}`)}};this.setLoadingStatus("loading"),this.reset();try{await Promise.all(n.map(a=>s(a).then(o))),this.setLoadingStatus("complete")}catch(a){this.setLoadingStatus("error",a.message)}this.complete()}}function tF(t){return"sequence"in t}class nF extends Jr{constructor(e,n){if(super(n),this.sequence=Za(n.paramMediator,e.sequence,()=>this.loadSynchronously()),!("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=Ve(this.sequence.as)??"data",n=Ve(this.sequence.start)??0,r=Ve(this.sequence.step)??1,i=Ve(this.sequence.stop);this.reset(),this.beginBatch({type:"file"});for(let s=n;s{this.view.isVisible()&&this.onDomainChanged(this.scaleResolution.getDomain(),this.scaleResolution.getComplexDomain())};this.scaleResolution.addEventListener("domain",i),this.view.context.addBroadcastListener("layoutComputed",i)}get genome(){return this.scaleResolution.getGenome()}onDomainChanged(n,r){}requestRender(){this.view.context.animator.requestRender()}async load(){this.reset(),this.complete()}publishData(n){this.reset(),this.beginBatch({type:"file"});for(const r of n)for(const i of r)this._propagate(i);this.complete(),Mu(this.view)}}class rF extends ef{constructor(n,r){const i={axis:{},...n};super(r,i.channel);ve(this,"ticks",[]);this.params=n}async load(){this.ticks=null,this.onDomainChanged()}onDomainChanged(){const n=this.scaleResolution.scale,r=this.scaleResolution.getAxisLength(),i=this.params.axis,s=u=>25+60*lm(100,700,u),o=Ce(i.tickCount)?i.tickCount:Math.round(r/s(r)),a=Um(n,o,i.tickMinStep),c=i.values?zm(n,i.values,a):x3(n,a);if(this.ticks==null||!No(c,this.ticks)){this.ticks=c;const u=w3(n,o,i.format);this.publishData([c.map(f=>({value:f,label:u(f)}))])}}}class iF extends ef{constructor(e,n){super(n,e.channel)}async load(){this.publishData([this.genome.chromosomes])}}const sF="modulepreload",oF=function(t,e){return new URL(t,e).href},td={},Pe=function(e,n,r){if(!n||n.length===0)return e();const i=document.getElementsByTagName("link");return Promise.all(n.map(s=>{if(s=oF(s,r),s in td)return;td[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":sF,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 Jo(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,typeof e=="function"?e():e)})}}var wr,Ar,vr,gs;class Qs extends ef{constructor(){super(...arguments);F(this,wr,new AbortController);F(this,Ar,[0,0]);F(this,vr,[0,0]);F(this,gs,0);ve(this,"params")}setupDebouncing(n){const r=()=>Ve(n.debounce),i=n.debounceMode;if(i=="domain")this.onDomainChanged=Jo(this.onDomainChanged.bind(this),r,!1);else if(i=="window")this.loadInterval=Jo(this.loadInterval.bind(this),r,!1);else throw new Error("Invalid debounceMode: "+i)}onDomainChanged(n){var i;k(this,vr,n);const r=Ve((i=this.params)==null?void 0:i.windowSize)??-1;n[1]-n[0]>r||this.callIfWindowsChanged(n,r,async s=>{await this.initializedPromise,this.loadInterval(s)})}reloadLastDomain(){const n=b(this,vr);k(this,vr,[0,0]),k(this,Ar,[0,0]),this.onDomainChanged(n)}async loadInterval(n){}async discretizeAndLoad(n,r){b(this,wr).abort(),this.setLoadingStatus("loading"),k(this,wr,new AbortController);const i=b(this,wr).signal,s=this.genome.continuousToDiscreteChromosomeIntervals(n);try{const o=await Promise.all(s.map(async a=>r(a,i)));if(!i.aborted)return this.setLoadingStatus("complete"),o}catch(o){if(!i.aborted)throw this.setLoadingStatus("error",o.message),o}}callIfWindowsChanged(n,r,i){const s=[Math.max(Math.floor(n[0]/r)*r,0),Math.min(Math.ceil(n[1]/r)*r,this.genome.totalSize)],o=b(this,Ar);(r!==b(this,gs)||s[0]o[1])&&(k(this,Ar,s),k(this,gs,r),i(s))}}wr=new WeakMap,Ar=new WeakMap,vr=new WeakMap,gs=new WeakMap;class aF extends Qs{constructor(e,n){const r={channel:"x",windowSize:7e3,debounce:200,debounceMode:"window",...e};if(super(n,r.channel),this.params=r,!this.params.url)throw new Error("No URL provided for IndexedFastaSource");this.setupDebouncing(this.params),this.initializedPromise=new Promise(i=>{Promise.all([Pe(()=>import("./index-462333f7.js").then(s=>s.i),["./index-462333f7.js","./_commonjsHelpers-de833af9.js"],import.meta.url),Pe(()=>import("./index-f8b9b7f4.js"),["./index-f8b9b7f4.js","./__vite-browser-external-d053bc6e.js","./index-462333f7.js","./_commonjsHelpers-de833af9.js","./long-c1fdf4ae.js"],import.meta.url),Pe(()=>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(Zs(u,this.view.getBaseUrl()));this.fasta=new o({fasta:c(this.params.url),fai:c(this.params.indexUrl??this.params.url+".fai")}),i()})})}async loadInterval(e){const n=await this.discretizeAndLoad(e,async(r,i)=>this.fasta.getSequence(r.chrom,r.startPos,r.endPos,{signal:i}).then(s=>({chrom:r.chrom,start:r.startPos,sequence:s})));n&&this.publishData([n])}}var Er,Cr,ys,$u;class cF extends Qs{constructor(n,r){const i={pixelsPerBin:2,channel:"x",debounce:200,debounceMode:"window",...n},s=Za(r.paramMediator,i,o=>{o.includes("url")?D(this,ys,$u).call(this).then(()=>this.reloadLastDomain()):o.includes("pixelsPerBin")&&this.reloadLastDomain()});super(r,s.channel);F(this,ys);F(this,Er,[]);F(this,Cr,void 0);if(this.params=s,!this.params.url)throw new Error("No URL provided for BigWigSource");this.setupDebouncing(this.params),D(this,ys,$u).call(this)}async onDomainChanged(n){await this.initializedPromise;const r=this.scaleResolution.getAxisLength()||700,i=uF(n,r,b(this,Er)),s=Math.max(i*r,5e3);this.callIfWindowsChanged(n,s,o=>this.loadInterval(o,i))}async loadInterval(n,r){const i=.5/r/Ve(this.params.pixelsPerBin),s=await this.discretizeAndLoad(n,(o,a)=>b(this,Cr).getFeatures(o.chrom,o.startPos,o.endPos,{scale:i,signal:a}).then(c=>c.map(u=>({chrom:o.chrom,start:u.start,end:u.end,score:u.score}))));s&&this.publishData(s)}}Er=new WeakMap,Cr=new WeakMap,ys=new WeakSet,$u=function(){return this.initializedPromise=new Promise((n,r)=>{Promise.all([Pe(()=>import("./index-712d95de.js"),["./index-712d95de.js","./index-462333f7.js","./_commonjsHelpers-de833af9.js","./index-d89cadd6.js","./__vite-browser-external-d053bc6e.js","./remoteFile-1948951e.js"],import.meta.url),Pe(()=>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:i},{RemoteFile:s}])=>{k(this,Cr,new i({filehandle:new s(Zs(Ve(this.params.url),this.view.getBaseUrl()))})),this.setLoadingStatus("loading"),b(this,Cr).getHeader().then(o=>{k(this,Er,o.zoomLevels.map(a=>a.reductionLevel).reverse()),b(this,Er).push(1),this.setLoadingStatus("complete"),n()}).catch(o=>{this.load(),this.setLoadingStatus("error",`${Ve(this.params.url)}: ${o.message}`),r(o)})})}),this.initializedPromise};function uF(t,e,n){const r=(t[1]-t[0])/e;return n.find(i=>i{o.includes("url")?D(this,xs,Uu).call(this).then(()=>this.reloadLastDomain()):o.includes("windowSize")&&this.reloadLastDomain()});super(r,s.channel);F(this,xs);ve(this,"parser");ve(this,"bbi");ve(this,"parseLine");if(this.params=s,!this.params.url)throw new Error("No URL provided for BigBedSource");this.setupDebouncing(this.params),D(this,xs,Uu).call(this)}async loadInterval(n){const r=await this.discretizeAndLoad(n,async(i,s)=>this.bbi.getFeatures(i.chrom,i.startPos,i.endPos,{signal:s}).then(o=>o.map(a=>this.parseLine(i.chrom,a))));r&&this.publishData(r)}}xs=new WeakSet,Uu=function(){return this.initializedPromise=new Promise((n,r)=>{Promise.all([Pe(()=>import("./index-7a37a249.js"),["./index-7a37a249.js","./_commonjsHelpers-de833af9.js"],import.meta.url),Pe(()=>import("./index-712d95de.js"),["./index-712d95de.js","./index-462333f7.js","./_commonjsHelpers-de833af9.js","./index-d89cadd6.js","./__vite-browser-external-d053bc6e.js","./remoteFile-1948951e.js"],import.meta.url),Pe(()=>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(([i,{BigBed:s},{RemoteFile:o}])=>{const a=i.default;this.bbi=new s({filehandle:new o(Zs(Ve(this.params.url),this.view.getBaseUrl()))}),this.setLoadingStatus("loading"),this.bbi.getHeader().then(async c=>{this.parser=new a({autoSql:c.autoSql});try{const u=fF(this.parser);this.parseLine=(f,l)=>u(f,l.start,l.end,l.rest)}catch{this.parseLine=(f,l)=>this.parser.parseLine(`${f} ${l.start} ${l.end} ${l.rest}`)}this.setLoadingStatus("complete"),n()}).catch(c=>{this.load(),this.setLoadingStatus("error",`${Ve(this.params.url)}: ${c.message}`),r(c)})})}),this.initializedPromise};function fF(t){const e=t.autoSql.fields.filter(x=>x.type).slice(3);let n=0,r="",i=0,s={};const o=" ",a=o.charCodeAt(0),c="0".charCodeAt(0),u="-".charCodeAt(0);function f(){let x=r.indexOf(o,n);x<0&&(x=i);const w=r.substring(n,x);return n=x+1,w}function l(){let x=0,w=r.charCodeAt(n),v=1;w===u&&(v=-1,n++,w=r.charCodeAt(n));do{if(w===a){n++;break}x=x*10+w-c,w=r.charCodeAt(++n)}while(n`${JSON.stringify(x.name)}: ${x.isNumeric?"0":"emptyString"}`),p=new Function(` + const emptyString = ""; + return function makeTemplate(chrom, chromStart, chromEnd) { + return { + chrom, + chromStart, + chromEnd, + ${h.join(`, +`)} + } + };`)(),d=e.map(x=>{const w=x.type,v=JSON.stringify(x.name);if(["ubyte","int","uint"].includes(w))return`d[${v}] = parseInt();`;if(x.isNumeric)return`d[${v}] = Number(parseString());`;if(["char","string","lstring"].includes(w))return`d[${v}] = parseString();`;throw new Error("Unsupported type: "+w)}),m=hF(d,50).map((x,w)=>Function("parseInt","parseString",`return function parseFieldChunk${w}(d) { + ${x.join(` +`)} + }`)(l,f));function g(x){r=x,i=x.length,n=0}function y(x,w,v,C){g(C),s=p(x,w,v);for(const S of m)S(s);return s}return y}function hF(t,e){return Array.from({length:Math.ceil(t.length/e)},(n,r)=>t.slice(r*e,r*e+e))}var Pn;class dF extends Qs{constructor(n,r){const i={channel:"x",windowSize:2e4,debounce:200,debounceMode:"domain",...n};super(r,i.channel);F(this,Pn,void 0);ve(this,"chrPrefixFixer",n=>n);if(this.params=i,!this.params.url)throw new Error("No URL provided for BamSource");this.setupDebouncing(this.params),this.initializedPromise=new Promise(s=>{Promise.all([Pe(()=>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),Pe(()=>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(Zs(u,this.view.getBaseUrl()));k(this,Pn,new o({bamFilehandle:c(this.params.url),baiFilehandle:c(this.params.indexUrl??this.params.url+".bai")})),b(this,Pn).getHeader().then(u=>{var h,p;const f=this.genome.hasChrPrefix(),l=(p=(h=b(this,Pn).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 loadInterval(n){const r=await this.discretizeAndLoad(n,async(i,s)=>b(this,Pn).getRecordsForRange(this.chrPrefixFixer(i.chrom),i.startPos,i.endPos,{signal:s}).then(o=>o.map(a=>({chrom:i.chrom,start:a.get("start"),end:a.get("end"),name:a.get("name"),MD:a.get("MD"),cigar:a.get("cigar"),mapq:a.get("mq"),strand:a.get("strand")===1?"+":"-"}))));r&&this.publishData(r)}}Pn=new WeakMap;var bs;class pF extends Qs{constructor(n,r){const i={channel:"x",windowSize:3e6,debounce:200,debounceMode:"domain",...n};super(r,i.channel);F(this,bs,void 0);if(this.params=i,!this.params.url)throw new Error("No URL provided for TabixSource");this.setupDebouncing(this.params),this.initializedPromise=new Promise(s=>{Promise.all([Pe(()=>import("./index-462333f7.js").then(o=>o.i),["./index-462333f7.js","./_commonjsHelpers-de833af9.js"],import.meta.url),Pe(()=>import("./index-9e6f36fd.js"),["./index-9e6f36fd.js","./index-d89cadd6.js","./_commonjsHelpers-de833af9.js","./index-462333f7.js","./__vite-browser-external-d053bc6e.js","./long-c1fdf4ae.js"],import.meta.url),Pe(()=>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(Zs(f,this.view.getBaseUrl()));k(this,bs,new a({filehandle:u(this.params.url),tbiFilehandle:u(this.params.indexUrl??this.params.url+".tbi")})),s()})})}async loadInterval(n){const r=await this.discretizeAndLoad(n,async(i,s)=>{const o=[];return await b(this,bs).getLines(i.chrom,i.startPos,i.endPos,{lineCallback:a=>{o.push(a)},signal:s}),this._parseFeatures(o)});r&&this.publishData(r)}_parseFeatures(n){return[]}}bs=new WeakMap;var ws;class mF extends pF{constructor(n,r){super(n,r);F(this,ws,void 0);Pe(()=>import("./index-ba6a6d03.js"),["./index-ba6a6d03.js","./_commonjsHelpers-de833af9.js","./index-462333f7.js","./__vite-browser-external-d053bc6e.js"],import.meta.url).then(i=>{k(this,ws,i.default)})}_parseFeatures(n){var i;return(i=b(this,ws))==null?void 0:i.parseStringSync(n.join(` +`),{parseSequences:!1})}}ws=new WeakMap;function gF(t,e){if(gg(t))return new Z4(t,e);if(Q4(t))return new eF(t,e);if(tF(t))return new nF(t,e);if(yF(t))return SF(t.lazy,e);throw new Error("Cannot figure out the data source type: "+JSON.stringify(t))}function yF(t){return"lazy"in t}function xF(t){return(t==null?void 0:t.type)=="axisTicks"}function bF(t){return(t==null?void 0:t.type)=="axisGenome"}function wF(t){return(t==null?void 0:t.type)=="indexedFasta"}function AF(t){return(t==null?void 0:t.type)=="bigwig"}function vF(t){return(t==null?void 0:t.type)=="bigbed"}function EF(t){return(t==null?void 0:t.type)=="bam"}function CF(t){return(t==null?void 0:t.type)=="gff3"}function SF(t,e){if(xF(t))return new rF(t,e);if(bF(t))return new iF(t,e);if(wF(t))return new aF(t,e);if(AF(t))return new cF(t,e);if(vF(t))return new lF(t,e);if(EF(t))return new dF(t,e);if(CF(t))return new mF(t,e);throw new Error("Cannot figure out the data source type: "+JSON.stringify(t))}function FF(t){const e=yg(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}function yg(t){let e=[];do e=e.concat(Object.keys(t)),t=Object.getPrototypeOf(t);while(t&&t!==Object.prototype);return Array.from(new Set(e))}var Sr,As;class Zo extends Z{constructor(){super();F(this,Sr,void 0);F(this,As,n=>n);const n=r=>{const i=yg(r);(!b(this,Sr)||!No(i,b(this,Sr)))&&(k(this,Sr,i),k(this,As,FF(r)));const s=b(this,As);this.handle=o=>this._propagate(s(o)),this.handle(r)};this.handle=n,this.beginBatch=r=>{fm(r)&&(this.handle=n),super.beginBatch(r)}}get behavior(){return xt}}Sr=new WeakMap,As=new WeakMap;function TF(t){return"name"in t}var vs;class xg extends Jr{constructor(n,r,i){super(r);F(this,vs,void 0);this.provider=i,this.params=n}get identifier(){return this.params.name}updateDynamicData(n){k(this,vs,n),this.loadSynchronously()}loadSynchronously(){const n=b(this,vs)??this.provider(this.params.name)??[];let r=i=>i;if(Array.isArray(n))n.length>0&&(r=mg(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()}}vs=new WeakMap;class bg{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 xg&&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 DF(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 wg(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=wg(o,e,n);if(a==="stop")return a}return(s=e.postOrder)==null?void 0:s.call(e,t)}function _F(t,e){return wg(t,e,n=>n.children)}function IF(t,e){const n=[],r=[];let i;const s=e??new bg,o=[];function a(p,d=()=>{}){if(!i)throw d()||new Error("Cannot append data flow node, no parent exist!");return i.addChild(p),i=p,n.push(p),p}function c(p,d){return a(p,()=>new Error(`Cannot append a transform because no (inherited) data are available! ${d?JSON.stringify(d):""}`))}function u(p,d){for(const m of p){let g;try{g=j4(m,d)}catch(y){throw console.warn(y),new Error(`Cannot initialize "${m.type}" transform: ${y}`)}g.behavior&dn&&c(new Zo),c(g)}}function f(){return n.findLastIndex(p=>p instanceof pu)>n.findLastIndex(p=>p instanceof Jr)}const l=p=>{if(p.spec.data){const d=TF(p.spec.data)?new xg(p.spec.data,p,p.context.getNamedDataFromProvider):gF(p.spec.data,p);i=d,n.push(d),s.addDataSource(d,p)}if(p.spec.transform&&u(p.spec.transform,p),p instanceof Ge){if(!i)throw new Error(`A unit view (${p.getPathString()}) has no (inherited) data source`);const d=RF(p);if(d){o.push(d.rewrite);for(const g of d.transforms)c(g)}p.mark.isPickingParticipant()&&!f()&&(c(new Zo),c(new pu({type:"identifier"})));const m=new lg({type:"collect",groupby:p.getFacetFields(),sort:MF(p,d==null?void 0:d.rewrittenEncoding)});a(m),s.addCollector(m,p)}},h=DF(t.getDescendants(),p=>p.dataParent);for(const p of h)_F(p,{preOrder:d=>{r.push({view:d.ref,nodeStackDepth:n.length}),l(d.ref)},postOrder:()=>{const{nodeStackDepth:d}=r.pop();n.length=d,i=n.at(-1)}});return o.forEach(p=>p()),s}function RF(t){var s;const e=[],n={},r=[];for(const[o,a]of Object.entries(t.getEncoding())){const c=o;Gi(c)&&gm(a)&&r.push({channel:c,chromPosDef:a})}const i=wa(r,o=>Jn(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=x=>x.replace(/[^A-Za-z0-9_]/g,""),g=["_linearized_",m(d.chrom),"_",m(d.pos)].join(""),y={...((s=t.spec.encoding)==null?void 0:s[p])??t.getEncoding()[p]??{},field:g};delete y.chrom,delete y.pos,!y.type&&d.type&&(y.type=d.type),n[p]=y,f.push(d.pos),h.push(d.offset??0),l.push(g)}e.push(new Zo),e.push(new hg({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},OS(t.mark,"encoding")}}:void 0}function MF(t,e){var r;const n={...t.getEncoding(),...e}.x;if(He(n)&&(r=t.getScaleResolution("x"))!=null&&r.isZoomable()){if(pn(n))return"buildIndex"in n&&n.buildIndex?{field:n.field}:null;if(!Hs(n)){if(Ws(n))throw new Error("A zoomable x channel must be mapped to a field.")}}}function Ag(t,e=void 0){if(t.parent!==e)return!1;for(const n of t.children)if(!Ag(n,t))return!1;return!0}function zu(t,e=!1){if(t.behavior&Yl&&(e=!0),t instanceof Zo)if(e)e=!1;else{const n=t.children[0];t.excise(),n&&zu(n,e);return}t.behavior&xt&&(e=!1);for(let n=0,r=t.children.length;n1)}function kF(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 BF(t){if(zu(t),!Ag(t))throw new Error("Encountered a bug! There's a problem in the data flow structure.")}function PF(t){kF(t);for(const e of t.dataSources)BF(e)}function OF(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 LF(t){for(const e of Kr){const n=t.getScaleResolution(e);n&&!n.name&&n.isZoomable()&&(n.name=`${e}_at_root`)}}async function NF(t,e,n){const r=t.import;if(!("url"in r))throw new Error("Not an url import: "+JSON.stringify(r));const i=qi(e,r.url);let s;try{const o=await fetch(i);if(!o.ok)throw new Error(`${o.status} ${o.statusText}`);s=await o.json()}catch(o){throw new Error(`Could not load imported view spec: ${i}. Reason: ${o.message}`)}if(n.isViewSpec(s))return s.baseUrl=qi(qm(r.url),s.baseUrl),s;throw new Error(`The imported spec "${i}" is not a view spec: ${JSON.stringify(t)}`)}function $F(t){const e=t.getSize(),n=t.getPadding(),r=(i,s)=>i.grow>0?void 0:i.px+s;return{width:r(e.width,n.horizontalTotal),height:r(e.height,n.verticalTotal)}}function bt(t){return()=>t}const Ze=class Ze{static create(e,n,r,i){return new Ze(bt(e),bt(n),bt(r),bt(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"?bt(i):typeof i=="function"?i:this._passThrough(r)};return new Ze(n("x"),n("y"),n("width"),n("height"))}translate(e,n){return e===0&&n===0?this:new Ze(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 Ze(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 Ze(()=>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 Ze(()=>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 Ze(bt(this.x),bt(this.y),bt(this.width),bt(this.height))}containsPoint(e,n){return e>=this.x&&e=this.y&&n()=>{e&&o()},i=o=>()=>{e&&n&&o()},s=wa(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 UF extends vg{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 zF{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 ct{static fromMouseEvent(e){return new ct(e.clientX,e.clientY)}constructor(e,n){this.x=e,this.y=n}subtract(e){return new ct(this.x-e.x,this.y-e.y)}add(e){return new ct(this.x-e.x,this.y-e.y)}multiply(e){return new ct(this.x*e,this.y*e)}get length(){return Math.sqrt(this.x**2+this.y**2)}equals(e){return e?e===this||e.x===this.x&&e.y===this.y:!1}}const VF=t=>new Promise(e=>setTimeout(e,t));function GF(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=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 GF({requestAnimationFrame:n=>this.requestTransition(n),...e})}}function tf(t,e,n,r,i){let s=0,o=!0,a=structuredClone(i),c=a;function u(h,p,d,m){return p+(h-p)*Math.pow(2,-d/m)}function f(h){if(o)return;const p=h-s;s=h;for(const m of Object.keys(c))a[m]=u(a[m],c[m],p,n);e(a);let d=-1/0;for(const m of Object.keys(c))d=Math.max(d,Math.abs(c[m]-a[m]));df(m))}function l(h){c=h,o&&(o=!1,s=+document.timeline.currentTime,f(s))}return l.stop=()=>{o=!0},l}class WF{constructor(e){this.genomes=new Map,this.baseUrl=e}async initialize(e){const n=new X3(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 qF=""+new URL("Lato-Regular-e459d1f9.png",import.meta.url).href,jF={thin:100,light:300,regular:400,normal:400,medium:500,bold:700,black:900};class YF{constructor(e){this._webGLHelper=e,this.fontRepository="https://raw.githubusercontent.com/etiennepinchon/aframe-fonts/master/fonts/",this._fonts=new Mt([],JSON.stringify),this._metadataPromises=new Map,this._fontPromises=new Map,this._promises=[],this._defaultFontEntry={metrics:xu(dg),texture:e?this._createTextureNow(qF):void 0}}async waitUntilReady(){await Promise.all(this._promises)}getFont(e,n="normal",r="regular"){if(H(r)&&(r=jF[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=KF(r,n),s=this.fontRepository+rd(n.family)+"/"+i.replace(/\.\w+/,""),o=this._createTexture(s+".png"),a=this._loadFont(s+".json");e.texture=await o,e.metrics=await a}catch{console.warn(`Cannot load font: "${n.family}". Using the embedded default font.`),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=>xu(r)),this._fontPromises.set(e,n)),n}_loadMetadata(e){const n=rd(e);let r=this._metadataPromises.get(n);if(!r){const i=this.fontRepository+n+"/METADATA.pb";r=fetch(i).then(s=>{if(!s.ok)throw new Error("Could not load font metadata. Response status: "+s.status+", url: "+i);return s}).then(s=>s.text()).then(s=>XF(s)).catch(s=>{console.warn(s.message)}),this._metadataPromises.set(n,r)}return r}getDefaultFont(){return this._defaultFontEntry}_createTexture(e){const n=this._webGLHelper.gl;return new Promise((r,i)=>{Li(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=Li(n,{src:e,min:n.LINEAR},(a,c,u)=>{a?o(a):s(c)})});return this._promises.push(i),r}}function rd(t){return t.toLowerCase().replaceAll(/[^\w]/g,"")}function XF(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 KF(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={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 ZF{constructor(e,n){this.animator=e,this.disabled=!!n,this.maxDistance=500,this.callback=null,this.targetValue=0,this.lastValue=0,this.smoother=tf(e,r=>{var s;const i=r.x-this.lastValue;this.lastValue=r.x,(s=this.callback)==null||s.call(this,i)},40,.1,{x:0})}cancel(){this.lastValue!==this.targetValue&&(this.targetValue=Md([this.lastValue,this.targetValue],.3),this.smoother({x:this.targetValue}))}setMomentum(e,n){if(this.disabled){n(e);return}this.callback=n;const r=Gr(this.targetValue+e-this.lastValue,-this.maxDistance,this.maxDistance);this.targetValue=this.lastValue+r,this.smoother({x:this.targetValue})}}function QF(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 id=new Map;async function eT(t,e,n){const r=t.symbol;let i=id.get(r)??await rT(t.symbol);return i?(id.set(r,i),z`
${i.name} ${i.description}

${i.summary}

Source: NCBI RefSeq Gene

`):null}async function tT(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 nT=Jo(tT,500);function rT(t){return nT(t)}const iT=fe(".4~r"),sT=fe(".4~e");function Eg(t){return t==null?z`NA`:H(t)?t.substring(0,30):Number.isInteger(t)?""+t:Ce(t)?Math.abs(t)>Math.pow(10,8)||Math.abs(t)[Eg(e),n{var f;for(const[l,h]of Object.entries(e.encoders))if((f=h==null?void 0:h.dataAccessor)!=null&&f.fields.includes(c))switch(l){case"color":case"fill":case"stroke":return z``}return""},i=Object.entries(t).filter(([c,u])=>!c.startsWith("_"));if(i.length===0)return;const s=z`${i.map(([c,u])=>z``)}
${c}${Eg(u)} ${r(c,t)}
`,o=e.unitView.getTitleText(),a=o?z`
${o}
`:"";return z`${a}${s}`}class eo extends sg{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===yi)return n;if(n!==f4){e.beforeChildren&&e.beforeChildren(this);for(const r of this){const i=r.visit(e);if(i===yi)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 eo)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,yi}),n}getDefaultResolution(e,n){return"shared"}}var St;class to extends eo{constructor(n,r,i,s,o,a){super(n,r,i,s,o,{layersChildren:!0,...a});F(this,St,[]);this.spec=n,this.needsAxes={x:!0,y:!0}}async initializeChildren(){k(this,St,await Promise.all(this.spec.layer.map((n,r)=>this.context.createOrImportView(n,this,this,"grid"+r,i=>{if(!ju(i)&&!qu(i))throw new Gn("LayerView accepts only unit or layer specs as children!",this)}))))}get children(){return b(this,St).slice()}*[Symbol.iterator](){for(const n of b(this,St))yield n}render(n,r,i={}){if(super.render(n,r,i),!!this.isConfiguredVisible()){n.pushView(this,r);for(const s of b(this,St))s.render(n,r,i);n.popView(this)}}propagateInteractionEvent(n){this.handleInteractionEvent(void 0,n,!0);for(let r=b(this,St).length-1;r>=0;r--)if(b(this,St)[r].propagateInteractionEvent(n),n.stopped)return;this.handleInteractionEvent(void 0,n,!1)}}St=new WeakMap;class sd{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=this.maxCols)return;r=n*this.nCols+e}return r=this.n))return[e%this.nCols,Math.floor(e/this.nCols)]}}const aT="chromosome_ticks_and_labels",cT={x:"width",y:"height"};function Vu(t){return t=="x"?"y":"x"}const Qo={x:["bottom","top"],y:["left","right"]},nf=Object.fromEntries(Object.entries(Qo).map(([t,e])=>e.map(n=>[n,t])).flat(1));function nn(t){return nf[t]}class Cg extends to{constructor(e,n,r,i,s,o){const a=n=="locus",c={...a?lT:Sg,...uT(n,e),...e};super(a?fT(c,n):Fg(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 nf[this.axisProps.orient]=="x"?new tn(n,e):new tn(e,n)}getPerpendicularSize(){return rf(this.axisProps)}isPickingSupported(){return!1}}function rf(t){const e=nn(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 Sg={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 uT(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 Fg(t,e){const n={...t,extent:rf(t)},r=nn(n.orient),i=Vu(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"}},[cT[Vu(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 lT={...Sg,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 fT(t,e){const n={...t,extent:rf(t)},r=nn(n.orient),i=Vu(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=Fg({...t,...c},e);if(t.chromTicks||t.chromLabels){const f={name:aT,data:{lazy:{type:"axisGenome",channel:nn(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 hT extends to{constructor(e,n,r,i,s,o){const c={...n=="locus"?dT:Tg,...e};super(yT(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 Tg={values:null,grid:!1,gridCap:"butt",gridColor:"lightgray",gridDash:null,gridOpacity:1,gridWidth:1,tickCount:null,tickMinStep:null},dT={...Tg,chromGrid:!1,chromGridCap:"butt",chromGridColor:"gray",chromGridDash:[1,5],chromGridOpacity:1,chromGridWidth:1};function pT(t,e){const n=t,r=nn(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 mT(t,e){const n=t,r=nn(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 gT(t,e){const n=t,r=nn(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 yT(t,e){const n={...t},r=[];return n.chromGrid&&(n.chromGridFillOdd||n.chromGridFillEven)&&r.push(gT(n,e)),n.chromGrid&&n.chromGridOpacity>0&&r.push(mT(n,e)),n.grid&&n.gridOpacity>0&&r.push(pT(n,e)),{name:"grid_layers",configurableVisibility:!1,resolve:{scale:{[nn(t.orient)]:"forced",fill:"independent",opacity:"independent"}},layer:r}}const od={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"},xT={orient:"left",anchor:"middle",align:"right",baseline:"middle",angle:0,fontSize:12},bT={orient:"top",anchor:"start",align:"left",baseline:"top",offset:-10,dx:10,fontSize:12},wT={start:0,middle:.5,end:1},AT={start:"left",middle:"center",end:"right"};function vT(t){if(!t)return;const e=H(t)?{text:t}:t;if(!e.text||e.orient=="none")return;const n={"track-title":xT,overlay:bT}[e.style]??{},r={...od,...n,...e};let i={},s={x:0,y:0};const o=wT[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={...od,...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??AT[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}}}var On,Ut,zt;class ET{constructor(e){F(this,On,void 0);F(this,Ut,0);F(this,zt,0);k(this,On,new Array(e))}push(e){b(this,On)[b(this,Ut)]=e,k(this,Ut,(b(this,Ut)+1)%this.size),k(this,zt,Math.min(b(this,zt)+1,this.size))}get(){const e=b(this,On);return b(this,zt){const h=ct.fromMouseEvent(l);s.push({point:h,timestamp:performance.now()});const p=h.subtract(a);n({x:a.x,y:a.y,xDelta:p.x,yDelta:p.y,zDelta:0}),a=h},u=()=>{const h=performance.now(),p=s.get().filter(w=>h-w.timestamp<160);if(p.length<5||!i||FT(p))return;const d=p.at(-1),m=p[0],g=d.point.subtract(m.point).multiply(1/(d.timestamp-m.timestamp));let y=a.x,x=a.y;An=tf(i,w=>{n({x:w.x,y:w.y,xDelta:y-w.x,yDelta:x-w.y,zDelta:0}),y=w.x,x=w.y},150,.5,{x:y,y:x}),An({x:a.x-g.x*250,y:a.y-g.y*250})},f=()=>{document.removeEventListener("mousemove",c),document.removeEventListener("mouseup",f),u()};document.addEventListener("mouseup",f,!1),document.addEventListener("mousemove",c,!1)}}function FT(t){const e=t[Math.floor(t.length/2)],n=e.point.subtract(t[0].point).multiply(e.timestamp-t[0].timestamp),r=t.at(-1).point.subtract(e.point).multiply(t.at(-1).timestamp-e.timestamp),i=n.length,s=r.length,o=.4;return s/is.view==n);if(i>=0)b(this,ze)[i]=new ud(r,this,b(this,Dr));else throw new Error("Not my child view!")}get children(){return b(this,ze).map(n=>n.view)}get childCount(){return b(this,ze).length}async createAxes(){const n=[];for(const r of Kr){const i=this.resolutions.axis[r];if(i){const s=i.getAxisProps();if(s){const o={title:i.getTitle(),orient:Qo[r][0],...s},a=new Cg(o,i.scaleResolution.type,this.context,this,this);n.push(a.initializeChildren()),b(this,Ln)[r]=a}}}return Promise.all([...n,...b(this,ze).map(r=>r.createAxes())])}*[Symbol.iterator](){for(const n of b(this,ze))yield*n.getChildren();for(const n of Object.values(b(this,Ln)))yield n}getOverhang(){return D(this,fa,Ig).call(this).union(D(this,_r,Fo).call(this))}getSize(){return this._cache("size",()=>new tn(D(this,Cs,Hu).call(this,"column"),D(this,Cs,Hu).call(this,"row")).addPadding(D(this,_r,Fo).call(this)))}render(n,r,i={}){if(super.render(n,r,i),!this.isConfiguredVisible())return;this.layoutParent||(r=r.shrink(this.getPadding())),r=r.shrink(D(this,_r,Fo).call(this)),n.pushView(this,r);const s={devicePixelRatio:this.context.devicePixelRatio},o=Jh(D(this,Es,Gu).call(this,"column"),r.width,s),a=Jh(D(this,Es,Gu).call(this,"row"),r.height,s),c=new sd(b(this,Ft,En).length,b(this,Fr)??1/0),u=f=>Math.round(f*devicePixelRatio)/devicePixelRatio;for(const[f,l]of b(this,Ft,En).entries()){const{view:h,axes:p,gridLines:d,background:m,backgroundStroke:g,title:y}=l,[x,w]=c.getCellCoords(f),v=o[D(this,Ss,Wu).call(this,"column",x)],C=a[D(this,Ss,Wu).call(this,"row",w)],S=h.getViewportSize(),E=h.getSize(),M=h.getOverhang(),P=v.location-M.left,O=C.location-M.top,R=(ce,st)=>(ce[st].grow?(st=="width"?v:C).size:ce[st].px)+M[st],q=R(S,"width"),J=R(S,"height"),we=R(E,"width"),We=R(E,"height"),Ae=l.scrollbars.horizontal,Oe=l.scrollbars.vertical,Te=Ae?()=>u(Ae.viewportOffset):()=>0,de=Oe?()=>u(Oe.viewportOffset):()=>0,Le=new Rt(()=>r.x+P,()=>r.y+O,()=>q,()=>J),no=h.isScrollable(),mn=no?new Rt(()=>r.x+P-Te(),()=>r.y+O-de(),()=>we,()=>We):Le;l.coords=Le;const Zr=i.clipRect?Le.intersect(i.clipRect):Le;m==null||m.render(n,Zr,{...i,clipRect:void 0});for(const ce of Object.values(d))ce.render(n,Le,i);const ro=RT(h)||no;ro&&h.render(n,mn,{...i,clipRect:Zr}),g==null||g.render(n,Zr,{...i,clipRect:void 0});for(const[ce,st]of Object.entries(p)){const Ke=ce=="left"||ce=="right"?"vertical":"horizontal",Qr=l.scrollbars[Ke],_=Qr?Le.modify(Ke=="vertical"?{y:()=>mn.y,height:We}:{x:()=>mn.x,width:we}):Le,L=cd(_,ce,st);let N=i.clipRect;Qr&&(N=L.intersect(N).intersect(Qr?Le.modify(Ke=="vertical"?{x:-1e5,width:2e5}:{y:-1e5,height:2e5}):void 0)),st.render(n,L,{...i,clipRect:N})}for(const ce of Object.values(b(this,Ln))){const Ke=ce.axisProps.orient;(Ke=="left"&&x==0||Ke=="right"&&x==c.nCols-1||Ke=="top"&&w==0||Ke=="bottom"&&w==c.nRows-1)&&ce.render(n,cd(Le.shrink(l.view.getOverhang()),Ke,ce),i)}ro||h.render(n,mn,i);for(const ce of Object.values(l.scrollbars))ce.updateScrollbar(Le,mn),ce.render(n,r,i);y==null||y.render(n,Le,i)}n.popView(this)}propagateInteractionEvent(n){if(this.handleInteractionEvent(void 0,n,!0),n.stopped)return;const r=b(this,Ft,En).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 Ge||i instanceof to)&&ST(n,r.coords,s=>D(this,ha,Rg).call(this,r.coords,r.view,s),this.context.getCurrentHover(),this.context.animator)),!n.stopped&&this.handleInteractionEvent(void 0,n,!1)}getDefaultResolution(n,r){return"independent"}}Fr=new WeakMap,Tr=new WeakMap,ze=new WeakMap,Ln=new WeakMap,Dr=new WeakMap,Ft=new WeakSet,En=function(){return b(this,ze).filter(n=>n.view.isConfiguredVisible())},la=new WeakSet,_g=function(){return new sd(b(this,Ft,En).length,b(this,Fr)??1/0)},Nn=new WeakSet,fi=function(n){const r=n=="column"?"width":"height",i=(s,o)=>s.map(a=>{const u=b(this,Ft,En)[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}`,()=>b(this,la,_g)[n=="column"?"colIndices":"rowIndices"].map(s=>({axisBefore:i(s,0),axisAfter:i(s,1),view:c4(s.map(o=>b(this,Ft,En)[o].view.getViewportSize()[r]))})))},Es=new WeakSet,Gu=function(n){const r=D(this,Nn,fi).call(this,n),i=[];i.push(gi);for(const[s,o]of r.entries())s>0&&i.push({px:b(this,Tr),grow:0}),(s==0||this.wrappingFacet)&&i.push(gi),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(gi);return i},Cs=new WeakSet,Hu=function(n){let r=0,i=0;const s=n=="row"?this.spec.height:this.spec.width;if(s||s===0)return ig(s);const o=D(this,Nn,fi).call(this,n);for(const[a,c]of o.entries())a>0&&(i+=b(this,Tr)),(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}},Ss=new WeakSet,Wu=function(n,r){return n=="row"&&this.wrappingFacet?1+6*r+2:2+4*r+1},fa=new WeakSet,Ig=function(){const n=D(this,Nn,fi).call(this,"column"),r=D(this,Nn,fi).call(this,"row");return!n.length||!r.length?me.zero():new me(r.at(0).axisBefore,n.at(-1).axisAfter,r.at(-1).axisAfter,n.at(0).axisBefore)},_r=new WeakSet,Fo=function(){const n=r=>{const i=nf[r],s=b(this,Ln)[i];return(s==null?void 0:s.axisProps.orient)!==r?0:Math.max(s.getPerpendicularSize()+s.axisProps.offset,0)};return new me(n("top"),n("right"),n("bottom"),n("left"))},ha=new WeakSet,Rg=function(n,r,i){for(const[s,o]of Object.entries(IT(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 DT(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 _T(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",opacity: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 IT(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 RT(t){let e=!0;return t.visit(n=>{n instanceof Ge&&e&&(e=n.mark.properties.clip===!0)}),e}function cd(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 ud{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=Rt.ZERO,e.needsAxes.x||e.needsAxes.y){const i=e.spec,s="view"in i?i==null?void 0:i.view:void 0,o=DT(s);o&&(this.background=new Ge(o,n.context,n,e,"background"+r,{blockEncodingInheritance:!0}));const a=_T(s);a&&(this.backgroundStroke=new Ge(a,n.context,n,e,"backgroundStroke"+r,{blockEncodingInheritance:!0}));const c=vT(e.spec.title);if(c){const u=new Ge(c,n.context,n,e,"title"+r,{blockEncodingInheritance:!0});this.title=u}}e.spec.viewportWidth!=null&&(this.scrollbars.horizontal=new ld(this,"horizontal")),e.spec.viewportHeight!=null&&(this.scrollbars.vertical=new ld(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 Qo[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()),!Qo[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 Cg(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 hT(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 to){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 Ge&&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 me(e("top"),e("right"),e("bottom"),e("left")).add(this.view.getOverhang())}getOverhangAndPadding(){return this.getOverhang().add(this.view.getPadding())}}var Ir,Fs,Vt,$n;class ld extends Ge{constructor(n,r){const i={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},n.layoutParent.context,n.layoutParent,n.view,"scrollbar-"+r,{blockEncodingInheritance:!0});F(this,Ir,void 0);F(this,Fs,Rt.ZERO);F(this,Vt,0);F(this,$n,0);ve(this,"viewportOffset",0);this.config=i,k(this,Ir,r),this.interpolateViewportOffset=tf(this.context.animator,s=>{this.viewportOffset=s.x},50,.4,{x:this.viewportOffset}),this.addInteractionEventListener("mousedown",(s,o)=>{if(o.stopPropagation(),b(this,Vt)<=0)return;const a=p=>r=="vertical"?p.clientY:p.clientX,c=o.uiEvent;c.preventDefault();const u=this.scrollOffset,f=a(c),l=p=>{const d=Gr(a(p)-f+u,0,b(this,Vt));this.interpolateViewportOffset({x:d/b(this,Vt)*b(this,$n)})},h=()=>{document.removeEventListener("mousemove",l),document.removeEventListener("mouseup",h)};document.addEventListener("mouseup",h,!1),document.addEventListener("mousemove",l,!1)})}get scrollOffset(){return this.viewportOffset/b(this,$n)*b(this,Vt)}render(n,r,i){super.render(n,b(this,Fs),i)}updateScrollbar(n,r){const i=this.config.scrollbarPadding,s=this.config.scrollbarSize,o=b(this,Ir)=="horizontal"?"width":"height",a=Math.min(1,n[o]/r[o]),c=n[o]-2*i,u=a*c;k(this,Vt,c-u),k(this,$n,r[o]-n[o]),this.viewportOffset=Gr(this.viewportOffset,0,b(this,$n)),k(this,Fs,b(this,Ir)=="vertical"?new Rt(()=>n.x+n.width-s-i,()=>n.y+i+this.scrollOffset,()=>s,()=>u):new Rt(()=>n.x+i+this.scrollOffset,()=>n.y+n.height-s-i,()=>u,()=>s))}}Ir=new WeakMap,Fs=new WeakMap,Vt=new WeakMap,$n=new WeakMap;class Bc extends TT{constructor(e,n,r,i,s){super(e,n,r,i,s,Yu(e)?e.columns:To(e)?1:1/0),this.spec=e}async initializeChildren(){const e=this.spec,n=Yu(e)?e.concat:To(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":To(this.spec)&&e==="x"||Bg(this.spec)&&e==="y"?"shared":"independent"}}const Mg="viewRoot";var Rr;class MT{constructor(e={}){F(this,Rr,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(ju,n(to)),this.addViewType(qu,n(Ge)),this.addViewType(To,n(Bc)),this.addViewType(Bg,n(Bc)),this.addViewType(Yu,n(Bc)),this.addViewType(PT,()=>{throw new Error("SampleView is not supported by the @genome-spy/core package. Use @genome-spy/app instead!")})}addViewType(e,n){b(this,Rr).set(e,n)}createView(e,n,r,i,s){for(const[o,a]of b(this,Rr))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=[...b(this,Rr).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(BT(e)){let u;if("url"in e.import)if(this.options.allowImport)u=await NF(e,i.getBaseUrl(),n);else throw new Gn("Importing views is not allowed!",r);else if("template"in e.import)u=kg(e.import.template,i);else throw new Error("Invalid import: "+JSON.stringify(e));o==null||o(u),kT(u,e),a=u}else a=e;!i&&this.options.wrapRoot&&(qu(a)||ju(a))&&s===Mg&&(a={name:"implicitRoot",vconcat:[a]});const c=this.createView(a,n,r,i,s);return c instanceof eo&&await c.initializeChildren(),c}}Rr=new WeakMap;function kg(t,e){var r,i;const n=(i=(r=e.spec)==null?void 0:r.templates)==null?void 0:i[t];if(n)return structuredClone(n);if(e.dataParent)return kg(t,e.dataParent);throw new Error(`Cannot find template "${t}" in current view or its ancestors!`)}function kT(t,e){e.name!=null&&(t.name=e.name);const n=he(e.params)?e.params:be(e.params)?Object.entries(e.params).map(([r,i])=>({name:r,value:i})):[];if(n.length){t.params??(t.params=[]);for(const r of n){const i=t.params.findIndex(s=>s.name==r.name);i>=0&&(t.params[i]=r)}for(const r of n)t.params.some(i=>i.name==r.name)||t.params.push(r)}}function qu(t){return"mark"in t&&(H(t.mark)||be(t.mark))}function ju(t){return"layer"in t&&be(t.layer)}function BT(t){return"import"in t}function To(t){return"vconcat"in t&&he(t.vconcat)}function Bg(t){return"hconcat"in t&&he(t.hconcat)}function Yu(t){return"concat"in t&&he(t.concat)}function PT(t){return"samples"in t&&be(t.samples)&&"spec"in t&&be(t.spec)}function OT(t){const e=Math.floor(Math.random()*16777215).toString(16),n=[];for(const r of t.paramConfigs.values()){if(!qC(r))continue;const i=r.bind;if(!i||!("input"in i))continue;const s=r.name,o=t.getSetter(s),a=t.getValue(s),c=i.name??s,u=i.debounce?Jo(o,i.debounce,!1):o,f=`${e}-param-${s}`;if(i.input=="range")n.push(z`
${a}
`);else if(i.input=="checkbox")n.push(z` `);else if(i.input=="radio")n.push(z`${c}
${i.options.map((l,h)=>{var p;return z``})}
`);else if(i.input=="select")n.push(z` `);else if(i.input=="text"||i.input=="number"||i.input=="color")n.push(z`
`);else throw new Error("Unsupported input type: "+i.input);i.description&&n.push(z`
${i.description}
`)}return n}ol("fasta",JF);var Mr,Do,da,Pg,pa,Og,ma,Lg;class LT{constructor(e,n,r={}){F(this,Mr);F(this,da);F(this,pa);F(this,ma);this.container=e,this.options=r,r.inputBindingContainer??(r.inputBindingContainer="default"),this._destructionCallbacks=[],this.spec=n,this.viewFactory=new MT,this.namedDataProviders=[],this.animator=new HF(()=>this.renderAll()),this.genomeStore=void 0,this.viewVisibilityPredicate=i=>i.isVisibleInSpec(),this._renderingContext=void 0,this._pickingContext=void 0,this._dirtyPickingBuffer=!1,this._currentHover=void 0,this._wheelInertia=new ZF(this.animator),this._keyboardListeners=new Map,this._eventListeners=new Map,this._extraBroadcastListeners=new Map,this.tooltipHandlers={default:oT,refseqgene:eT,...r.tooltipHandlers??{}},this.viewRoot=void 0,this._loadingViews=new Map,this._inputBindingContainer=void 0,this._mouseDownCoords=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),Mu(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))}_updateLoadingIndicators(){const e=[],n=()=>[...this._loadingViews.values()].some(r=>r.status=="loading"||r.status=="error");for(const[r,i]of this._loadingViews){const s=r.coords;if(s){const o={left:`${s.x}px`,top:`${s.y}px`,width:`${s.width}px`,height:`${s.height}px`};e.push(z`
${i.status=="error"?z`Loading failed${i.detail?z`: ${i.detail}`:Q}`:z` Loading...`}
`)}}n()?this.loadingIndicatorsElement.style.display="block":setTimeout(()=>{n()||(this.loadingIndicatorsElement.style.display="none")},3e3),qn(e,this.loadingIndicatorsElement)}destroy(){var n;const e=b(this,Mr,Do);this.container.classList.remove("genome-spy"),e.classList.remove("loading");for(const[r,i]of this._keyboardListeners)for(const s of i)document.removeEventListener(r,s);for(this._destructionCallbacks.forEach(r=>r()),this._glHelper.finalize(),(n=this._inputBindingContainer)==null||n.remove();this.container.firstChild;)this.container.firstChild.remove()}async _prepareViewsAndData(){this.spec.genome&&(this.genomeStore=new WF(this.spec.baseUrl),await this.genomeStore.initialize(this.spec.genome));const e=this,n={dataFlow:new bg,glHelper:this._glHelper,animator:this.animator,genomeStore:this.genomeStore,fontManager:new YF(this._glHelper),get devicePixelRatio(){return e._glHelper.dpr},requestLayoutReflow:()=>{},updateTooltip:this.updateTooltip.bind(this),getNamedDataFromProvider:this.getNamedDataFromProvider.bind(this),getCurrentHover:()=>this._currentHover,setDataLoadingStatus:(c,u,f)=>{this._loadingViews.set(c,{status:u,detail:f}),this._updateLoadingIndicators()},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,Mg),b(this,Mr,Do).style.flexGrow=this.viewRoot.getSize().height.grow>0?"1":"0",D(this,da,Pg).call(this),OF(this.viewRoot),LF(this.viewRoot);const i=this.viewRoot.getDescendants();i.forEach(c=>c.configureViewOpacity()),this._glHelper.invalidateSize(),D(this,pa,Og).call(this);const s=i.filter(c=>c instanceof Ge),o=IF(this.viewRoot,n.dataFlow);PF(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(),n.animator.requestRender()},c);await n.fontManager.waitUntilReady(),o.initialize(),await Promise.all(o.dataSources.map(c=>c.load())),Mu(this.viewRoot),this.broadcast("dataLoaded"),await a;for(const c of s)c.mark.finalizeGraphicsInitialization();n.requestLayoutReflow=this.computeLayout.bind(this),this.viewRoot.visit(c=>Co(c,"size")),this._glHelper.invalidateSize()}async launch(){try{return D(this,ma,Lg).call(this),await this._prepareViewsAndData(),this.registerMouseEvents(),this.computeLayout(),this.animator.requestRender(),!0}catch(e){const n=`${e.view?`At "${e.view.getPathString()}": `:""}${e.toString()}`;return console.error(e.stack),NT(this.container,n),!1}finally{b(this,Mr,Do).classList.remove("loading"),window.setTimeout(()=>{this.loadingMessageElement.style.display="none"},2e3)}}registerMouseEvents(){const e=this._glHelper.canvas;let n=performance.now();const r=i=>{var a,c;const s=performance.now(),o=s-n<200;if(i instanceof MouseEvent){const u=e.getBoundingClientRect(),f=new ct(i.clientX-u.left-e.clientLeft,i.clientY-u.top-e.clientTop);i.type=="mousemove"&&!o&&(this.tooltip.handleMouseMove(i),this._tooltipUpdateRequested=!1,i.buttons==0&&!ad()&&(this.renderPickingFramebuffer(),this._handlePicking(f.x,f.y)));const l=h=>{this.viewRoot.propagateInteractionEvent(new zF(f,h)),this._tooltipUpdateRequested||this.tooltip.clear()};if(i.type!="wheel"&&this._wheelInertia.cancel(),(i.type=="mousedown"||i.type=="mouseup")&&!ad())this.renderPickingFramebuffer();else if(i.type=="wheel"){n=s,this._tooltipUpdateRequested=!1;const h=i;if(Math.abs(h.deltaX)>Math.abs(h.deltaY))this._currentHover=null,this._wheelInertia.cancel();else{const p=QF(h);this._wheelInertia.setMomentum(h.deltaY*(h.deltaMode?80:1),d=>{const m=new WheelEvent("wheel",{...p,deltaMode:0,deltaX:0,deltaY:d});l(m)}),h.preventDefault();return}}if(i.type=="click"){const h=this._currentHover?{type:i.type,viewPath:this._currentHover.mark.unitView.getLayoutAncestors().map(p=>p.name).reverse(),datum:this._currentHover.datum}:{type:i.type,viewPath:null,datum:null};(a=this._eventListeners.get("click"))==null||a.forEach(p=>p(h))}(i.type!="click"||((c=this._mouseDownCoords)==null?void 0:c.subtract(ct.fromMouseEvent(i)).length)<3)&&l(i)}};["mousedown","mouseup","wheel","click","mousemove","gesturechange","contextmenu"].forEach(i=>e.addEventListener(i,r)),e.addEventListener("mousedown",i=>{this._mouseDownCoords=ct.fromMouseEvent(i),document.addEventListener("mouseup",()=>this.tooltip.popEnabledState(),{once:!0}),this.tooltip.pushEnabledState(!1)}),e.addEventListener("dragstart",i=>i.stopPropagation())}_handlePicking(e,n){var s;const r=this._glHelper.readPickingPixel(e,n),i=r[0]|r[1]<<8|r[2]<<16|r[3]<<24;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 Ge){if(o.mark.isPickingParticipant()&&[...o.facetCoords.values()].some(a=>a.containsPoint(e,n))){const a=o.getCollector().findDatumByUniqueId(i);a&&(this._currentHover={mark:o.mark,datum:a,uniqueId:i})}if(this._currentHover)return yi}}),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 nd({picking:!1},this._glHelper),this._pickingContext=new nd({picking:!0},this._glHelper),e.render(new UF(this._renderingContext,this._pickingContext),Rt.create(0,0,n.width,n.height)),this._updateLoadingIndicators(),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 Ge&&n.getDataAccessor("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}}Mr=new WeakSet,Do=function(){return this.container.querySelector(".canvas-wrapper")},da=new WeakSet,Pg=function(){const e=[];this.viewRoot.visit(r=>{const i=r.paramMediator;e.push(...OT(i))});const n=this.options.inputBindingContainer;if(!(!n||n=="none"||!e.length)){if(this._inputBindingContainer=bo("div",{className:"gs-input-bindings"}),n=="default")this.container.appendChild(this._inputBindingContainer);else if(n instanceof HTMLElement)n.appendChild(this._inputBindingContainer);else throw new Error("Invalid inputBindingContainer");e.length&&qn(z`
${e}
`,this._inputBindingContainer)}},pa=new WeakSet,Og=function(){const e=this.viewRoot.paramMediator.allocateSetter("devicePixelRatio",window.devicePixelRatio),n=()=>{this._glHelper.invalidateSize(),e(window.devicePixelRatio),this.computeLayout(),this.renderAll()};if(this.viewRoot.getSize().isGrowing()){const s=new ResizeObserver(n);s.observe(this.container),this._destructionCallbacks.push(()=>s.disconnect())}let r=null;const i=()=>{r!=null&&(r(),n());const s=matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`);s.addEventListener("change",i),r=()=>{s.removeEventListener("change",i)}};i(),r&&this._destructionCallbacks.push(r)},ma=new WeakSet,Lg=function(){this.container.classList.add("genome-spy");const e=document.createElement("style");e.innerHTML=nb,this.container.appendChild(e);const n=bo("div",{class:"canvas-wrapper"});this.container.appendChild(n),n.classList.add("loading"),this._glHelper=new US(n,()=>this.viewRoot?$F(this.viewRoot):{width:void 0,height:void 0},this.spec.background,{powerPreference:this.options.powerPreference??"default"}),this.loadingMessageElement=bo("div",{class:"loading-message",innerHTML:'
Loading...
'}),n.appendChild(this.loadingMessageElement),this.loadingIndicatorsElement=bo("div",{class:"loading-indicators"}),n.appendChild(this.loadingIndicatorsElement),this.tooltip=new ib(this.container),this.loadingMessageElement.querySelector(".message").addEventListener("transitionend",()=>{this.loadingMessageElement.style.display="none"})};function NT(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)}function bo(t,e){const n=document.createElement(t);for(const[r,i]of Object.entries(e))["innerHTML","innerText","className"].includes(r)&&(n[r]=i),n.setAttribute(r,i);return n}async function $T(t,e,n={}){let r;if(H(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=be(e)?e:await zT(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 LT(r,s,n),UT(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 UT(t,e){e.namedDataProvider&&t.registerNamedDataProvider(e.namedDataProvider)}async function zT(t){let e;try{const n=await fetch(t);if(!n.ok)throw new Error(`${n.status} ${n.statusText}`);e=await n.json()}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*Ng(t){const r=t.length;let i=0,s=i;for(;i=r))return a}}function VT(t){return new Promise((e,n)=>{let r=new FileReader;r.onload=()=>e(r.result),r.onerror=n,r.readAsText(t)})}function fd(){return new Promise((t,e)=>window.requestAnimationFrame(()=>window.requestAnimationFrame(t)))}async function $g(t){return{name:t.name,size:t.size,textContent:await VT(t)}}async function GT(t){const n=await(await fetch(t)).text();return{name:t.match(/[^/]*$/)[0],size:n.length,textContent:n}}function HT(t){const e={},n=(r,i)=>{e[r]||(e[r]=[]),e[r].push(i)};for(const r of Ng(t)){const i=r.match(/^@([A-Z]{2})\t(.*)/);if(i){const s=i[1];if(s!=="CO"){const o=Object.fromEntries(i[2].split(" ").map(a=>a.match(/^([A-Za-z][A-Za-z0-9]):(.*)/)).filter(a=>a).map(a=>a.slice(1)));n(s,o)}}else break}return e}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 WT(t){const e=qT(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 qT(t,e="@"){for(const n of Ng(t))if(typeof e=="string"&&n[0]!==e)return n}const Pc=t=>t!==""?+t:null,jT={[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:Pc(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:Pc(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:Pc(t.MINOR_ALLELE_FRACTION_POSTERIOR_50),MINOR_ALLELE_FRACTION_POSTERIOR_90:+t.MINOR_ALLELE_FRACTION_POSTERIOR_90})},YT=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}}]}),XT=t=>({description:"Windowed GC content computed from the reference genome. Extracted with GATK AnnotateIntervals",height:50,view:{fill:_n.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}}}}),KT=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"]}}}}]}]}),_n={INTERVAL:"#f70",RULE:"black",POINT:"#49A0F2",BACKGROUD:"#f8f8f8"};function Oc(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:_n.INTERVAL},opacity:{value:.3}}}),r.push({mark:{type:"rule",size:3,minLength:3},encoding:{y:{field:t,type:"quantitative",title:null},color:{value:_n.RULE}}}),r}function hd(t){return Math.max(0,Math.log((t-1e3)/4)/Math.log(3))||0}function JT(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,name:"custom"},[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,YT),{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,XT),{name:"logRTrack",view:{fill:_n.BACKGROUD,stroke:"gray"},layer:[{data:{values:s},transform:[{type:"filter",expr:"!isNaN(datum.logR) && datum.logR > -3"}],mark:{type:"point",tooltip:null,geometricZoomBound:hd(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:_n.POINT},size:{value:150},opacity:{value:.25},strokeWidth:{value:0}}},{transform:[{type:"filter",expr:"datum.LOG2_COPY_RATIO_POSTERIOR_50 > -3"}],layer:Oc("LOG2_COPY_RATIO_POSTERIOR_50",{lower:"LOG2_COPY_RATIO_POSTERIOR_10",upper:"LOG2_COPY_RATIO_POSTERIOR_90"})}]},{name:"bafTrack",view:{fill:_n.BACKGROUD,stroke:"gray"},layer:[{data:{values:o},mark:{type:"point",tooltip:null,geometricZoomBound:hd(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:_n.POINT},size:{value:150},opacity:{value:.3},strokeWidth:{value:0}}},{layer:[{layer:Oc("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:Oc("MINOR_ALLELE_FRACTION_POSTERIOR_50",{lower:"MINOR_ALLELE_FRACTION_POSTERIOR_10",upper:"MINOR_ALLELE_FRACTION_POSTERIOR_90"})}]}]}]},...a(e,KT)]}}const ZT="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 Ug=["hg38","hg19"],Hr=new Map;let Hn=Ug[0],xi,ea=!1,ta=!1,bi=!1;Pt();function QT(){const t=r=>{const i=Hr.get(r);return z`${r.title}${i?z`${i.name}${i.data?`${i.data.length} records`:"Parsing..."}`:z`Missing. Example: ${r.example}`}`},e=()=>z`
${Ug.map(r=>z``)}
`;return z`${(()=>z`

1. Choose a genome assembly or a sequence dictionary

Choosing a genome assembly instead of a sequence dictionary activates cytoband, GC content, and RefSeq gene tracks.

${e()}

2. Select files

Please provide at least one of the following files to start visualizing. File types are detected from the TSV header row.

N.B. All data processing takes place in your web browser. Nothing is uploaded anywhere.

${Object.values(ge).filter(r=>r!==ge.DICT||!Hn).map(t)}
or drag and drop here.

No files to play with?

Try the example data sets:

${bi?z` Loading...`:""}

3. Explore the data

Zoom with the mouse wheel or touchpad, pan by dragging or with the touchpad. Hover an item to get details.
`)()}
`}function eD(){return z`
`}function Lc(t){t.stopPropagation(),t.preventDefault(),t.type==="dragleave"?ea=!1:ea=!0,Pt()}async function tD(t){t.stopPropagation(),t.preventDefault(),ea=!1;const n=[...t.dataTransfer.files];sf(await Promise.all(n.map($g)))}function zg(){const t=new Map([...Hr.entries()].filter(e=>e[0]!==ge.DICT));return t.size>0&&[...t.values()].every(e=>e.data)&&(Hn||Hr.has(ge.DICT))}function Pt(){qn(QT(),document.querySelector("main")),qn(eD(),document.querySelector("header .toolbar"))}async function Vg(){Gg();const t=JT(Hr,Hn);console.log(t),ta=!0,Pt(),xi=await $T(document.querySelector("#genome-spy-container"),t),Pt()}function Gg(){xi&&(xi.finalize(),xi=void 0),ta=!1,Pt()}function dd(t){Hn=t,Pt()}async function nD(t){const e=[...t.target.files];sf(await Promise.all(e.map($g)))}async function pd(t){const e="https://data.genomespy.app/sample-data/segment-model-spy/";bi=!0,Pt();const r=[".hets.tsv",".denoisedCR.tsv",".modelFinal.seg"].map(i=>e+t+i);try{sf(await Promise.all(r.map(GT)))}catch{alert("Failed to load example data. Please try again later.")}bi=!1}async function sf(t){const e=[];for(const n of t){const r=n.textContent,i=WT(r);i?(e.push({file:n,textContent:r,type:i}),Hr.set(i,{name:n.name,data:null})):alert(`Cannot recognise this file: ${n.name}.`),i===ge.DICT&&(Hn=void 0)}for(const n of e){Pt(),await fd();let r=[];n.type!==ge.DICT?r=Sd(" ",{comment:"@"}).parse(n.textContent,jT[n.type.name]):r=rD(n.textContent),Hr.set(n.type,{name:n.file.name,data:r})}await fd(),Pt(),new Set(e.filter(n=>n.type!==ge.DICT)).size===3&&zg()&&Vg()}function rD(t){return HT(t).SQ.map(n=>({name:n.SN,size:+n.LN}))} diff --git a/segmentmodel/assets/index-9e6f36fd.js b/segmentmodel/assets/index-9e6f36fd.js new file mode 100644 index 0000000..4076ff1 --- /dev/null +++ b/segmentmodel/assets/index-9e6f36fd.js @@ -0,0 +1,3 @@ +import{_ as Y,L as J}from"./index-d89cadd6.js";import{b as K}from"./index-462333f7.js";import{L as P}from"./__vite-browser-external-d053bc6e.js";import{u as F,L as G,a as Q}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(i,r){const s=i.minv.blockPosition-r.minv.blockPosition;return s!==0?s:i.minv.dataPosition-r.minv.dataPosition}),a.forEach(i=>{(!e||i.maxv.compareTo(e)>0)&&(n===null?(t.push(i),n=i):ee(n,i)?i.maxv.compareTo(n.maxv)>0&&(n.maxv=i.maxv):(t.push(i),n=i))}),t)}class M{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(;n0&&(t=e[n]);return t}}function T(a,e=0,t=!1){if(t)throw new Error("big-endian virtual file offsets not implemented");return new M(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 B{constructor(e,t,n,i=void 0){this.minv=e,this.maxv=t,this.bin=n,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 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={}){var n;return!!(!((n=(await this.parse(t)).indices[e])===null||n===void 0)&&n.binIndex)}}const te=21578324,q=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 z extends X{async lineCount(e,t={}){const n=await this.parse(t);if(!n)return-1;const i=n.refNameToId[e];if(!n.indices[i])return-1;const{stats:s}=n.indices[i];return s?s.lineCount:-1}async _parse(e={}){const t=await this.filehandle.readFile(e),n=await F(t);if(L(e.signal),n.readUInt32LE(0)!==te)throw new Error("Not a TBI file");const i=n.readInt32LE(4),r=n.readInt32LE(8),s=r&65536?"zero-based-half-open":"1-based-closed",f={0:"generic",1:"SAM",2:"VCF"}[r&15];if(!f)throw new Error(`invalid Tabix preset format flags ${r}`);const c={ref:n.readInt32LE(12),start:n.readInt32LE(16),end:n.readInt32LE(20)},m=n.readInt32LE(24),l=5,d=((1<<(l+1)*3)-1)/7,b=2**(14+l*3),w=m?String.fromCharCode(m):null,u=n.readInt32LE(28),I=n.readInt32LE(32),{refNameToId:x,refIdToName:p}=this._parseNameBytes(n.slice(36,36+I));let h=36+I,g;return{indices:new Array(i).fill(0).map(()=>{const N=n.readInt32LE(h);h+=4;const S={};let E;for(let v=0;vd+1)throw new Error("tabix index contains too many bins, please use a CSI index");if(_===d+1){const k=n.readInt32LE(h);h+=4,k===2&&(E=this.parsePseudoBin(n,h)),h+=16*k}else{const k=n.readInt32LE(h);h+=4;const $=new Array(k);for(let D=0;D>q>=o.linearIndex.length?o.linearIndex.length-1:t>>q]:new M(0,0))||console.warn("querying outside of possible tabix range");const c=ne(t,n),m=[];for(const[u,I]of c)for(let x=u;x<=I;x++)if(o.binIndex[x])for(const p of o.binIndex[x])m.push(new B(p.minv,p.maxv,x));const l=o.linearIndex.length;let d=null;const b=Math.min(t>>14,l-1),w=Math.min(n>>14,l-1);for(let u=b;u<=w;++u){const I=o.linearIndex[u];I&&(!d||I.compareTo(d)<0)&&(d=I)}return j(m,d)}}const ie=21582659,re=38359875;function oe(a,e){return a*2**e}function O(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 i=n.refNameToId[e];if(!n.indices[i])return-1;const{stats:s}=n.indices[i];return s?s.lineCount:-1}indexCov(){throw new Error("CSI indexes do not support indexcov")}parseAuxData(e,t){const n=e.readInt32LE(t),i=n&65536?"zero-based-half-open":"1-based-closed",r={0:"generic",1:"SAM",2:"VCF"}[n&15];if(!r)throw new Error(`invalid Tabix preset format flags ${n}`);const s={ref:e.readInt32LE(t+4),start:e.readInt32LE(t+8),end:e.readInt32LE(t+12)},o=e.readInt32LE(t+16),f=o?String.fromCharCode(o):null,c=e.readInt32LE(t+20),m=e.readInt32LE(t+24),{refIdToName:l,refNameToId:d}=this._parseNameBytes(e.slice(t+28,t+28+m));return{refIdToName:l,refNameToId:d,skipLines:c,metaChar:f,columnNumbers:s,format:r,coordinateType:i}}_parseNameBytes(e){let t=0,n=0;const i=[],r={};for(let s=0;s=30?this.parseAuxData(t,16):{refIdToName:[],refNameToId:{},metaChar:null,columnNumbers:{ref:0,start:1,end:2},coordinateType:"zero-based-half-open",format:"generic"},o=t.readInt32LE(16+r);let f,c=16+r+4;const m=new Array(o).fill(0).map(()=>{const l=t.readInt32LE(c);c+=4;const d={};let b;for(let w=0;wthis.maxBinNumber)b=this.parsePseudoBin(t,c+4),c+=4+8+4+16+16;else{const I=T(t,c+4);f=this._findFirstData(f,I);const x=t.readInt32LE(c+12);c+=16;const p=new Array(x);for(let h=0;h2**50&&(t=2**34),t-=1;let n=0,i=0,r=this.minShift+this.depth*3;const s=[];for(;n<=this.depth;r-=3,i+=oe(1,n*3),n+=1){const o=i+O(e,r),f=i+O(t,r);if(f-o+s.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`);s.push([o,f])}return s}}const R=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function se(a){return new Promise(e=>setTimeout(e,a))}class he{constructor({path:e,filehandle:t,tbiPath:n,tbiFilehandle:i,csiPath:r,csiFilehandle:s,yieldTime:o=500,chunkSizeLimit:f=5e7,renameRefSeqs:c=l=>l,chunkCacheSize:m=5*2**20}){if(t)this.filehandle=t;else if(e)this.filehandle=new P(e);else throw new TypeError("must provide either filehandle or path");if(i)this.index=new z({filehandle:i,renameRefSeqs:c});else if(s)this.index=new U({filehandle:s,renameRefSeqs:c});else if(n)this.index=new z({filehandle:new P(n),renameRefSeqs:c});else if(r)this.index=new U({filehandle:new P(r),renameRefSeqs:c});else if(e)this.index=new z({filehandle:new P(`${e}.tbi`),renameRefSeqs:c});else throw new TypeError("must provide one of tbiFilehandle, tbiPath, csiFilehandle, or csiPath");this.chunkSizeLimit=f,this.renameRefSeq=c,this.yieldTime=o,this.chunkCache=new Y({cache:new J({maxSize:Math.floor(m/65536)}),fill:(l,d)=>this.readChunk(l,{signal:d})})}async getLines(e,t,n,i){var r;let s,o={},f;if(i===void 0)throw new TypeError("line callback must be provided");if(typeof i=="function"?f=i:(o=i,f=i.lineCallback,s=i.signal),e===void 0)throw new TypeError("must provide a reference sequence name");if(!f)throw new TypeError("line callback must be provided");const c=await this.index.getMetadata(o);L(s);const m=t??0,l=n??c.maxRefLength;if(!(m<=l))throw new TypeError("invalid start and end coordinates. start must be less than or equal to end");if(m===l)return;const d=await this.index.blocksForRange(e,m,l,o);L(s);for(const w of d){const u=w.fetchedSize();if(u>this.chunkSizeLimit)throw new Error(`Too much data. Chunk size ${u.toLocaleString()} bytes exceeds chunkSizeLimit of ${this.chunkSizeLimit.toLocaleString()}.`)}let b=Date.now();for(const w of d){let u;const{buffer:I,cpositions:x,dpositions:p}=await this.chunkCache.get(w.toString(),w,s);L(s);let h=0,g=0;for(;h=p[g++];);g--}const{startCoordinate:E,overlaps:y}=this.checkLine(c,e,m,l,S);if(u!==void 0&&E!==void 0&&u>E)throw new Error(`Lines not sorted by start coordinate (${u} > ${E}), this file is not usable with Tabix.`);if(u=E,y)f(S.trim(),x[g]*256+(h-p[g])+w.minv.dataPosition+1);else if(E!==void 0&&E>=l)return;this.yieldTime&&b-Date.now()>this.yieldTime&&(b=Date.now(),L(s),await se(1)),h=C+1}}}async getMetadata(e={}){return this.index.getMetadata(e)}async getHeaderBuffer(e={}){const{firstDataLine:t,metaChar:n,maxBlockSize:i}=await this.getMetadata(e);L(e.signal);const r=((t==null?void 0:t.blockPosition)||0)+i,s=await this._readRegion(0,r,e),o=await F(s);if(n){let f=-1;const c=` +`.charCodeAt(0),m=n.charCodeAt(0);for(let l=0;l=i)return{startCoordinate:x,overlaps:!1};if((d===0||d===l)&&x+1<=n)return{startCoordinate:x,overlaps:!1}}else if(c==="VCF"&&w===4)I=r.slice(u,p);else if(w===d&&(c==="VCF"?this._getVcfEnd(x,I,r.slice(u,p)):parseInt(r.slice(u,p),10))<=n)return{overlaps:!1};if(u=p+1,w+=1,w>b)break}return{startCoordinate:x,overlaps:!0}}_getVcfEnd(e,t,n){let i=e+t.length;const r=n.includes("SVTYPE=TRA");if(n[0]!=="."&&!r){let s=";";for(let o=0;oe 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?"":"",o=Sr;for(let a=0;a"?(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?"":"")),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.length0){i.textContent=Cs?Cs.emptyScript:"";for(let p=0;p2||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{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 r9999?"+"+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=m)return is}F=!1;var Y,j=g,_;if(h.charCodeAt(j)===Ko){for(;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(;gfunction(e){return e[t]},Qp=t=>{const e=t.length;return function(n){for(let r=0;ro?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=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)=>(te||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&&++at}function Dc(t){for(let e,n,r=1,i=arguments.length;rbe(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;r9999?"+"+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?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(;m1)r=Mm(t,e,n);else for(i=0,r=new Array(s=t.arcs.length);ie?1:t>=e?0:NaN}function Bm(t,e){return t==null||e==null?NaN:et?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>>1;n(a[l],c)<0?u=l+1:f=l}while(u>>1;n(a[l],c)<=0?u=l+1:f=l}while(uu&&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=s&&(n=r=s):(n>s&&(n=s),r=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/ue&&--c,u=-u):(u=Math.pow(10,i)*o,a=Math.round(t/u),c=Math.round(e/u),a*ue&&--c),c0))return[];if(t===e)return[t];const r=e=i))return[];const a=s-i+1,c=new Array(a);if(r)if(o<0)for(let u=0;u=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=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;n0&&(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;++Velt||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>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(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),!(s0))return c;let u;do c.push(u=new Date(+s)),e(s,a),t(s);while(uZ(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=fg).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](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));++ve53)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[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=si;)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)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;ss===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 :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";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(;y1114111||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>>=")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=0&&y=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=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":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+(n0&&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=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()=>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;on&&(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 n180?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;++de&&(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 i2?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(a0;){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 sMath.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=f0){for(;h<=p;++h)for(d=1;df)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),!(mf)break;x.push(m)}x.length*2{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*rn(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);++o0?n[a-1]:t[0],a=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)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=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]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[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;ie[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;rRo(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{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;at>="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((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=tc&&t1?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;e0.0&&abs(size)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;i1e5?this._unrollPushAll():this.pushAll=()=>{for(let n=0;n{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]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]{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;x0;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{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;hm&&([d,m]=[m,d]),ma)continue;da&&(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;sc,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;p0.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;oa/(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{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=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(diameterTICK_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(size0.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.x0.0){p1.y=max(p1.y,-p4.y);}if(p1.yuMaxChordLength){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(size0.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-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;x0);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(nr/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{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=si;)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,(ci[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;rthis.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;aa===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?ethis[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;rthis.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;i0;){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=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{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=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{for(let i=0;i{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;cr.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=0&&o[h]=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||lU(i)),r=e.as?e.as:n.map(Kp);this.handle=i=>{const s={};for(let o=0;o{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;cnew 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{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;bf,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;cU(s)),i=uo(this.buffer,...r);for(const[s,o]of Iu(i)){const a={count:o.length};for(let c=0;ctypeof 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{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.requestIdthis.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{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.requestIdthis.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{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;n1)}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.y&&n()=>{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=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={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`
${i.name} ${i.description}

${i.summary}

Source: NCBI RefSeq Gene

`):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`NA`:V(t)?t.substring(0,30):Number.isInteger(t)?""+t:be(t)?Math.abs(t)>Math.pow(10,8)||Math.abs(t)[gp(e),n{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``}return""},i=Object.entries(t).filter(([c,u])=>!c.startsWith("_"));if(i.length===0)return;const s=te`${i.map(([c,u])=>te``)}
${c}${gp(u)} ${r(c,t)}
`,o=e.unitView.getTitleText(),a=o?te`
${o}
`:"";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=this.maxCols)return;r=n*this.nCols+e}return r=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){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='
Loading...
',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))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`${r.title}${i?te`${i.name}${i.data?`${i.data.length} records`:"Parsing..."}`:te`Missing. Example: ${r.example}`}`},e=()=>te`
${Tp.map(r=>te``)}
`;return te`${(()=>te`

1. Choose a genome assembly or a sequence dictionary

Choosing a genome assembly instead of a sequence dictionary activates cytoband, GC content, and RefSeq gene tracks.

${e()}

2. Select files

Please provide at least one of the following files to start visualizing. File types are detected from the TSV header row.

N.B. All data processing takes place in your web browser. Nothing is uploaded anywhere.

${Object.values(ge).filter(r=>r!==ge.DICT||!En).map(t)}
or drag and drop here.

No files to play with?

Try the example data sets:

${Gr?te` Loading...`:""}

3. Explore the data

Zoom with the mouse wheel or touchpad, pan by dragging or with the touchpad. Hover an item to get details.
`)()}
`}function Z3(){return te`
`}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/index.html b/segmentmodel/index.html index 955d581..2845b91 100644 --- a/segmentmodel/index.html +++ b/segmentmodel/index.html @@ -10,7 +10,7 @@ - +