@datagrok/bio 2.4.8 → 2.4.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- var bio_test;(()=>{var t={2012:(t,e,n)=>{"use strict";n.d(e,{f:()=>o});var i=n(9976);class o extends i.B{static get Lesk(){return void 0===this.lesk&&(this.lesk=this.makePalette([[["G","A","S","T"],"orange"],[["C","V","I","L","P","F","Y","M","W"],"all_green"],[["N","Q","H"],"magenta"],[["D","E"],"red"],[["K","R"],"all_blue"]],!1,o)),this.lesk}static get GrokGroups(){return void 0===this.grokGroups&&(this.grokGroups=this.makePalette([[["C","U"],"yellow"],[["G","P"],"red"],[["A","V","I","L","M","F","Y","W"],"all_green"],[["R","H","K"],"light_blue"],[["D","E"],"dark_blue"],[["S","T","N","Q"],"orange"]],!1,o)),this.grokGroups}static get RasMol(){return void 0===this.rasMol&&(this.rasMol=new o({D:"#E60A0A",E:"#E60A0A",C:"#E6E600",M:"#E6E600",K:"#145AFF",R:"#145AFF",S:"#FA9600",T:"#FA9600",F:"#3232AA",Y:"#3232AA",N:"#00DCDC",Q:"#00DCDC",G:"#EBEBEB",L:"#0F820F",V:"#0F820F",I:"#0F820F",A:"#C8C8C8",W:"#B45AB4",H:"#8282D2",P:"#DC9682",others:"#BEA06E"})),this.rasMol}get(t){const e=t in o.aaSynonyms?o.aaSynonyms[t]:t;return super.get(e)}}o.aaSynonyms={MeNle:"L",MeA:"A",MeG:"G",MeF:"F"};class s{static getPalette(t="grok"){switch(t){case"grok":return o.GrokGroups;case"lesk":return o.Lesk;default:throw new Error(`ChemPalette: scheme \`${t}\` does not exist`)}}static getInnerOuter(t){let e=0,n="",i="";for(const o of t)"("==o?e++:")"==o?e--:e?n+=o:i+=o;return isNaN(parseInt(n))?[i,n]:[i,""]}static getColorAAPivot(t="",e="grok"){var n,i,o;const s=this.getPalette(e);let[r,a]=this.getInnerOuter(t);if(r=r.length>6?`${r.slice(0,3)}...`:r,a=a.length>6?`${a.slice(0,3)}...`:a,1==t.length||"("==t[1]){const e=null===(n=t[0])||void 0===n?void 0:n.toUpperCase();return e in s?[s.get(e),e,a,1]:[this.undefinedColor,r,a,1]}if("d"==t[0]&&t[1]in s&&(2==t.length||"("==t[2])){const e=null===(i=t[1])||void 0===i?void 0:i.toUpperCase();return e in s?[s.get(e),e,a,2]:[this.undefinedColor,r,a,2]}if(t.substring(0,3)in this.AAFullNames&&(3==t.length||"("==t[3])){const e=this.AAFullNames[t.substring(0,3)];return e in s?[s.get(e),e,a,3]:[this.undefinedColor,r,a,3]}if((null===(o=t[0])||void 0===o?void 0:o.toLowerCase())==t[0]&&t.substring(1,3)in this.AAFullNames&&(4==t.length||"("==t[4])){const e=this.AAFullNames[t.substring(1,3)];return e in s?[s.get(e),e,a,4]:[this.undefinedColor,r,a,4]}return[this.undefinedColor,r,a,0]}}s.SemType="Aminoacids",s.SemTypeMultipleAlignment="AminoacidsMultipleAlignment",s.undefinedColor="rgb(100,100,100)",s.Names={G:"Glycine",L:"Leucine",Y:"Tyrosine",S:"Serine",E:"Glutamic acid",Q:"Glutamine",D:"Aspartic acid",N:"Asparagine",F:"Phenylalanine",A:"Alanine",K:"Lysine",R:"Arginine",H:"Histidine",C:"Cysteine",V:"Valine",P:"Proline",W:"Tryptophan",I:"Isoleucine",M:"Methionine",T:"Threonine"},s.AASmiles={G:"NCC(=O)O",L:"N[C@H](CC(C)C)C(=O)O",Y:"NC(CC1=CC=C(O)C=C1)C(=O)O",S:"NC(CO)C(=O)O",E:"N[C@@H](CCC(O)=O)C(=O)O",Q:"N[C@@H](CCC(N)=O)C(=O)O",D:"N[C@@H](CC(O)=O)C(=O)O",N:"N[C@@H](CC(N)=O)C(=O)O",F:"NC(CC1=CC=CC=C1)C(=O)O",A:"N[C@H](C)C(=O)O",K:"NC(CCCCN)C(=O)O",R:"N[C@H](CCCNC(=N)C)C(=O)O",H:"NC(CC1=CN=C[N]1)C(=O)O",C:"N[C@@H](CS)C(=O)O",V:"NC(C(C)C)C(=O)O",P:"N(CCC1)C1C(=O)O",W:"N[C@@H](Cc1c2ccccc2n([H])c1)C(=O)O",I:"N[C@H]([C@H](C)CC)C(=O)O",M:"NC(CCSC)C(=O)O",T:"NC(C(O)C)C(=O)O"},s.AASmilesTruncated={G:"*C*",L:"CC(C)C[C@H](*)*",Y:"C1=CC(=CC=C1CC(*)*)O",S:"OCC(*)C*",E:"*[C@@H](CCC(O)=O)*",Q:"*N[C@@H](CCC(N)=O)*",D:"*[C@@H](CC(O)=O)*",N:"*[C@@H](CC(N)=O)*",F:"C1=CC=C(C=C1)CC(*)*",A:"C[C@H](*)*",K:"C(CCN)CC(*)*",R:"*[C@H](CCCNC(=N)C)*",H:"C1=C(NC=N1)CC(*)*",C:"C([C@@H](*)*)S",V:"CC(C)C(*)*",P:"C1CCN(*)C1*",W:"*[C@@H](Cc1c2ccccc2n([H])c1)*",I:"CC[C@H](C)[C@H](*)*",M:"CSCCC(*)*",T:"CC(O)C(*)*"},s.AAFullNames={Ala:"A",Arg:"R",Asn:"N",Asp:"D",Cys:"C",Gln:"Q",Glu:"E",Gly:"G",His:"H",Ile:"I",Leu:"L",Lys:"K",Met:"M",Phe:"F",Pro:"P",Ser:"S",Thr:"T",Trp:"W",Tyr:"Y",Val:"V"}},7228:(t,e,n)=>{"use strict";n.d(e,{DC:()=>r,JN:()=>l,Xk:()=>a});var i=n(976),o=(n(4469),n(1047)),s=(n(6714),function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))});const r=["symbol","name","molfile","rgroups","polymerType","monomerType"];function a(t){const e=[];for(let n=0;n<t.rowCount;n++){const i={};Object.keys(o.K4).forEach((e=>{if("symbol"===e){const s=t.get(o.K4[e],n);i[e]="."===s?t.get(o.At,n):s}else if("rgroups"===e){const s=t.get(o.K4[e],n).split("\n"),r=[];s.forEach((t=>{const e={},n=t.substring(t.lastIndexOf("]")+1),i=t.match(/\[R(\d+)\]/)[1];e.capGroupSmiles="H"===n?`[*:${i}][H]`:`O[*:${i}]`,e.alternateId="H"===n?`R${i}-H`:`R${i}-OH`,e.capGroupName="H"===n?"H":"OH",e.label=`R${i}`,r.push(e)})),i[e]=r}else o.K4[e]&&(i[e]=t.get(o.K4[e],n))})),e.push(i)}return e}function l(){return s(this,void 0,void 0,(function*(){const t=i.Func.find({package:"Bio",name:"getMonomerLibHelper"});if(0===t.length)throw new Error('Package "Bio" must be installer for MonomerLibraryHelper.');return(yield t[0].prepare().call()).getOutputParamValue()}))}},6137:(t,e,n)=>{"use strict";n.d(e,{J:()=>o,V:()=>s});var i=n(9976);class o extends i.B{static get Chromatogram(){return void 0===this.chromatogram&&(this.chromatogram=new o({A:"green",C:"blue",G:"black",T:"red",U:"red",others:"gray"})),this.chromatogram}}class s{}s.SemType="Nucleotides",s.SemTypeMultipleAlignment="NucleotidesMultipleAlignment",s.Names={A:"Adenine",C:"Cytosine",G:"Guanine",T:"Thymine",U:"Uracil"}},9976:(t,e,n)=>{"use strict";n.d(e,{B:()=>i});class i{static makePalette(t,e=!1,n=i){const o={};return t.forEach((t=>{const n=t[0],i=t[1];n.forEach(((t,n)=>{o[t]=this.colourPalette[i][e?0:n]}))})),new n(o)}constructor(t){this._palette=t}get(t){return this._palette[t]}}i.undefinedColor="rgb(100,100,100)",i.colourPalette={orange:["rgb(255,187,120)","rgb(245,167,100)","rgb(235,137,70)","rgb(205, 111, 71)"],all_green:["rgb(44,160,44)","rgb(74,160,74)","rgb(23,103,57)","rgb(30,110,96)","rgb(60,131,95)","rgb(24,110,79)","rgb(152,223,138)","rgb(182, 223, 138)","rgb(152, 193, 138)"],all_blue:["rgb(31,119,180)","rgb(23,190,207)","rgb(122, 102, 189)","rgb(158,218,229)","rgb(141, 124, 217)","rgb(31, 120, 150)"],magenta:["rgb(162,106,192)","rgb(197,165,224)","rgb(208,113,218)"],red:["rgb(214,39,40)","rgb(255,152,150)"],st_blue:["rgb(23,190,207)","rgb(158,218,229)","rgb(31,119,180)"],dark_blue:["rgb(31,119,180)","rgb(31, 120, 150)"],light_blue:["rgb(23,190,207)","rgb(158,218,229)","rgb(108, 218, 229)","rgb(23,190,227)"],lilac_blue:["rgb(124,102,211)","rgb(149,134,217)","rgb(97, 81, 150)"],dark_green:["rgb(23,103,57)","rgb(30,110,96)","rgb(60,131,95)","rgb(24,110,79)"],green:["rgb(44,160,44)","rgb(74,160,74)"],light_green:["rgb(152,223,138)","rgb(182, 223, 138)","rgb(152, 193, 138)"],st_green:["rgb(44,160,44)","rgb(152,223,138)","rgb(39, 174, 96)","rgb(74,160,74)"],pink:["rgb(247,182,210)"],brown:["rgb(140,86,75)","rgb(102, 62, 54)"],gray:["rgb(127,127,127)","rgb(199,199,199)","rgb(196,156,148)","rgb(222, 222, 180)"],yellow:["rgb(188,189,34)"],white:["rgb(230,230,230)"]}},7331:(t,e,n)=>{"use strict";n.d(e,{UE:()=>h,kQ:()=>r});var i=n(976),o=n(9976);class s{static hashCode(t){let e=0;if(0===t.length)return e;for(let n=0;n<t.length;n++)e=(e<<5)-e+t.charCodeAt(n),e|=0;return e}}class r{}class a extends r{get(t){return"#666666"}}class l extends r{static buildPalette(){return[].concat(...Object.values(o.B.colourPalette))}get(t){const e=s.hashCode(t)%l.palette.length;return function(t){if(null==t)return"rgb(100,100,100)";const e=i.Color.fromHtml(t),n=i.Color.g(e),o=i.Color.r(e),s=i.Color.b(e),r=Math.sqrt(Math.pow(0-o,2)+Math.pow(0-n,2)+Math.pow(0-s,2));return r>210?`rgb(${o/r*210},${n/r*210},${s/r*210})`:i.Color.toRgb(e)}(l.palette[e])}}l.palette=l.buildPalette();class h extends o.B{static get Gray(){return void 0===this.gray&&(this.gray=new a),this.gray}static get Color(){return void 0===this.color&&(this.color=new l),this.color}}},1047:(t,e,n)=>{"use strict";n.d(e,{At:()=>i,K4:()=>o});const i="MonomerName",o={monomerType:null,smiles:null,name:"MonomerName",author:null,molfile:"molecule",naturalAnalog:"MonomerNaturalAnalogCode",rgroups:"MonomerCaps",createDate:null,id:null,polymerType:"MonomerType",symbol:"MonomerCode"}},5226:(t,e,n)=>{"use strict";n.d(e,{i:()=>s});var i=n(976),o=n(499);class s{get descriptionsArray(){return this._descriptionsArray}get sequencesArray(){return this._sequencesArray}parseMacromolecule(t,e){return this._fileContent.slice(t,e).split(/\s/).join("")}parseColumns(){const t=/^>(.*)$/gm;let e,n=0;for(;e=t.exec(this._fileContent);){const i=this._fileContent.substring(e.index+1,t.lastIndex);this._descriptionsArray.push(i),0!==n&&this._sequencesArray.push(this.parseMacromolecule(n,e.index)),n=t.lastIndex+1}this._sequencesArray.push(this.parseMacromolecule(n,-1))}importFasta(){const t=i.Column.fromStrings("description",this.descriptionsArray),e=i.Column.fromStrings("sequence",this.sequencesArray);return e.semType=i.SEMTYPE.MACROMOLECULE,o.C.setUnitsToFastaColumn(e),[i.DataFrame.fromColumns([t,e])]}constructor(t){this._descriptionsArray=[],this._sequencesArray=[],this._fileContent=t,this.parseColumns()}}},6714:(t,e,n)=>{"use strict";n.d(e,{GU:()=>C,KX:()=>T,Mj:()=>w,dQ:()=>E,fy:()=>d,gM:()=>S,gP:()=>v,kB:()=>m,py:()=>A,up:()=>R,vU:()=>y,w4:()=>M});var i=n(976),o=n(6414),s=n.n(o),r=n(3659),a=n(850),l=n(2012),h=n(6137),u=n(7331),c=n(499);function d(t,e,n){const i={};let o=!0,s=null;for(const r of t.categories){const t=n(r);if(null==s?s=t.length:t.length!==s&&(o=!1),t.length>=e)for(const e of t)e in i||(i[e]=0),i[e]+=1}return{freq:i,sameLength:o}}const f=/\[(\w+)\]|(\w)|(-)/g;function m(t){return s()(t.toString().matchAll(f)).map((t=>{let e;const n=t[0];return e=n.length>1?t[1]:n,e})).toArray()}const p=/(PEPTIDE1|DNA1|RNA1)\{([^}]+)}/g,g=/\[([^\[\]]+)]/g;function v(t){p.lastIndex=0;const e=p.exec(t.toString()),n=e?e[2]:null;return(n?n.split("."):[]).map((t=>{g.lastIndex=0;const e=g.exec(t);return e&&e.length>=2?e[1]:t}))}function y(t,e,n=undefined){if(t.toLowerCase().startsWith("fasta"))return m;if(t.toLowerCase().startsWith("separator"))return function(t,e=undefined){return n=>n.split(t,e)}(e,n);if(t.toLowerCase().startsWith("helm"))return v;throw new Error(`Unexpected units ${t} .`)}function w(t){if(t.semType!==i.SEMTYPE.MACROMOLECULE)throw new Error(`Get splitter for semType "${i.SEMTYPE.MACROMOLECULE}" only.`);return y(t.getTag(i.TAGS.UNITS),t.getTag("separator"))}const b=/(\w+)/g;function C(t,e){var n,i;const o=t.match(b),s=t.length>e||(null!==(n=null==o?void 0:o.length)&&void 0!==n?n:0)>1,r=null!==(i=null==o?void 0:o[0])&&void 0!==i?i:" ";return s?r.substring(0,e)+"…":r}function S(t){switch(t){case"DNA":return c.C.DnaFastaAlphabet;case"RNA":return c.C.RnaFastaAlphabet;case"PT":return c.C.PeptideFastaAlphabet;default:throw new Error(`Unsupported alphabet '${t}'.`)}}function T(t,e,n="-"){const i=new Set([...new Set(Object.keys(t)),...e]);i.delete(n);const o=[],s=[];for(const n of i)o.push(n in t?t[n]:0),s.push(e.has(n)?1:0);const l=new r.OW(o),h=new r.OW(s);return(0,a.MA)(l,h)/((0,a.$G)(l)*(0,a.$G)(h))}function M(t){const e=[["PT",c.C.PeptideFastaAlphabet],["DNA",c.C.DnaFastaAlphabet],["RNA",c.C.RnaFastaAlphabet]],n=e.map((e=>T(t.freq,e[1]))),i=Math.max(...n);return i>.65?e[n.indexOf(i)][0]:"UN"}function E(t,e=5){let n;return n=t.semType==i.SEMTYPE.MACROMOLECULE?new c.C(t).alphabet:M(d(t,e,m)),A(n)}function A(t){switch(t){case"PT":return l.f.GrokGroups;case"NT":case"DNA":case"RNA":return h.J.Chromatogram;default:return u.UE.Color}}function R(t){var e;const n=t.columns.bySemTypeAll(i.SEMTYPE.MACROMOLECULE);let o=null!==(e=n.find((t=>{const e=t.getTag(i.TAGS.UNITS);return!!e&&-1!==e.indexOf("MSA")})))&&void 0!==e?e:null;return!o&&n.length>0&&(o=n[0]),o}},7767:(t,e,n)=>{"use strict";n.d(e,{L:()=>r});var i=n(976),o=n(499),s=n(6714);class r extends o.C{get splitter(){return null===this._splitter&&(this._splitter=(0,s.Mj)(this.column)),this._splitter}toFasta(t){return"fasta"===t}toSeparator(t){return"separator"===t}toHelm(t){return"helm"===t}convertFastaToSeparator(t,e=null){null===e&&(e=this.defaultGapSymbol);const n=this.getNewColumn("separator");return n.init((n=>{const i=this.column.get(n),s=this.splitter(i);for(let t=0;t<s.length;t++)s[t]===e&&(s[t]=o.C._defaultGapSymbolsDict.SEPARATOR);return s.join(t)})),n.setTag(i.TAGS.UNITS,"separator"),n.setTag("separator",t),n}getHelmWrappers(){const t=this.isDna()?"DNA1{":this.isRna()?"RNA1{":this.isPeptide()?"PEPTIDE1{":"Unknown";if("Unknown"===t)throw new Error("Neither peptide, nor nucleotide");return[t,this.isDna()?"D(":this.isRna()?"R(":"",this.isDna()||this.isRna()?")P":"","}$$$"]}convertToHelmHelper(t,e,n,i,s,r){return`${n}${this.splitter(t).map((t=>t===e?o.C._defaultGapSymbolsDict.HELM:`${i}${t}${s}`)).join(".")}${r}`}convertStringToHelm(t,e=null){null===e&&(e=this.defaultGapSymbol);const[n,i,o,s]=this.getHelmWrappers();return this.convertToHelmHelper(t,e,n,i,o,s)}convertToHelm(t=null){null===t&&(t=this.defaultGapSymbol);const[e,n,o,s]=this.getHelmWrappers(),r=this.getNewColumn("helm");return r.init((i=>{const r=this.column.get(i);return this.convertToHelmHelper(r,t,e,n,o,s)})),r.setTag(i.TAGS.UNITS,"helm"),r}convertSeparatorToFasta(t=null){null===t&&(t=o.C._defaultGapSymbolsDict.FASTA);const e=this.getNewColumn("fasta");return e.init((e=>{const n=this.column.get(e),i=this.splitter(n),o=[];for(let e=0;e<i.length;e++){const n=i[e];if(0===n.length)o.push(t);else if(n.length>1){const t="["+n+"]";o.push(t)}else o.push(n)}return o.join("")})),e.setTag(i.TAGS.UNITS,"fasta"),e}convertHelmToFastaSeparator(t,e,n,i){i||(i=this.toFasta(e)?o.C._defaultGapSymbolsDict.FASTA:o.C._defaultGapSymbolsDict.SEPARATOR),n||(n=this.toFasta(e)?"":this.separator);const s=/(R\(|D\(|\)|P)/g,r=t.startsWith("DNA")||t.startsWith("RNA"),a=this.splitter(t),l=[];for(let t=0;t<a.length;t++){let n=a[t];if(r&&(n=n.replace(s,"")),n===o.C._defaultGapSymbolsDict.HELM)l.push(i);else if(this.toFasta(e)&&n.length>1){const t="["+n+"]";l.push(t)}else l.push(n)}return l.join(n)}convertHelm(t,e,n){const i=this.getNewColumn(t);i.init((i=>{const o=this.column.get(i);return this.convertHelmToFastaSeparator(o,t,e,n)}));const o=(0,s.Mj)(i),r=(0,s.fy)(i,5,o).sameLength?"SEQ.MSA":"SEQ";return i.setTag("aligned",r),i}convertHelmToSeparator(){return this.getNewColumn("separator")}convert(t,e=null){if(this.notation===t)throw new Error("tgt notation is invalid");if(this.toSeparator(t)&&null===e)throw new Error("tgt separator is not specified");if(this.isFasta()&&this.toSeparator(t)&&null!==e)return this.convertFastaToSeparator(e);if((this.isFasta()||this.isSeparator())&&this.toHelm(t))return this.convertToHelm();if(this.isSeparator()&&this.toFasta(t))return this.convertSeparatorToFasta();if(this.isHelm()&&this.toFasta(t))return this.convertHelm(t);if(this.isHelm()&&this.toSeparator(t))return this.convertHelm(t,e);throw new Error(`Not supported conversion from source notation '${this.notation}' to target notation '${t}'.`)}constructor(t){super(t),this._splitter=null}}},499:(t,e,n)=>{"use strict";n.d(e,{C:()=>s});var i=n(976),o=n(6714);class s{static setUnitsToFastaColumn(t){if(t.semType!==i.SEMTYPE.MACROMOLECULE)throw new Error("Fasta column must be MACROMOLECULE");const e=(0,o.fy)(t,5,o.kB),n=e.sameLength?"SEQ.MSA":"SEQ",s=(0,o.w4)(e);t.setTag(i.TAGS.UNITS,"fasta"),t.setTag("aligned",n),t.setTag("alphabet",s)}get units(){return this._units}get column(){return this._column}get notation(){return this._notation}get defaultGapSymbol(){return this._defaultGapSymbol}get separator(){var t;const e=null!==(t=this.column.getTag("separator"))&&void 0!==t?t:void 0;if("separator"===this.notation&&void 0===e)throw new Error(`Separator is mandatory for column '${this.column.name}' of notation '${this.notation}'.`);return e}get aligned(){const t=this.column.getTag("aligned");if(!t&&(this.isFasta()||this.isSeparator()))throw new Error("Tag aligned not set");return t}get alphabet(){const t=this.column.getTag("alphabet");if(!t&&(this.isFasta()||this.isSeparator()))throw new Error("Tag alphabet not set");return t}getAlphabetSize(){if("helm"==this.notation||"UN"==this.alphabet){const t=this.column.getTag(".alphabetSize");let e;if(t)e=parseInt(t);else{const t=(0,o.Mj)(this.column),n=(0,o.fy)(this.column,1,t);e=Object.keys(n.freq).length}return e}switch(this.alphabet){case"PT":return 20;case"DNA":case"RNA":return 4;case"NT":return console.warn("Unexpected alphabet 'NT'."),4;default:throw new Error(`Unexpected alphabet '${this.alphabet}'.`)}}getAlphabetIsMultichar(){return("helm"==this.notation||"UN"==this.alphabet)&&"true"==this.column.getTag(".alphabetIsMultichar")}isFasta(){return"fasta"===this.notation}isSeparator(){return"separator"===this.notation}isHelm(){return"helm"===this.notation}isRna(){return"RNA"===this.alphabet}isDna(){return"DNA"===this.alphabet}isPeptide(){return"PT"===this.alphabet}isMsa(){return!!this.aligned&&this.aligned.toUpperCase().includes("MSA")}getNotation(){if(this.units.toLowerCase().startsWith("fasta"))return"fasta";if(this.units.toLowerCase().startsWith("separator"))return"separator";if(this.units.toLowerCase().startsWith("helm"))return"helm";throw new Error(`Column '${this.column.name}' has unexpected notation '${this.units}'.`)}getNewColumn(t){const e=this.column,n=e.length,o=t.toLowerCase()+"("+e.name+")",s=e.dataFrame.columns.getUnusedName(o),r=i.Column.fromList("string",s,new Array(n).fill(""));r.semType=i.SEMTYPE.MACROMOLECULE,r.setTag(i.TAGS.UNITS,t),r.setTag(i.TAGS.CELL_RENDERER,"Macromolecule");const a=e.getTag("aligned");a&&r.setTag("aligned",a);const l=e.getTag("alphabet");l&&r.setTag("alphabet",l);let h=e.getTag(".alphabetSize");h&&r.setTag(".alphabetSize",h);const u=e.getTag(".alphabetIsMultichar");return void 0!==u&&r.setTag(".alphabetIsMultichar",u),"helm"==t&&(h=this.getAlphabetSize().toString(),r.setTag(".alphabetSize",h)),r}static getNewColumn(t){const e=new s(t),n=e.notation;return e.getNewColumn(n)}static unitsStringIsValid(t){return t=t.toLowerCase(),["fasta","separator","helm"].some((e=>t.startsWith(e.toLowerCase())))}static getNewColumnFromParams(t,e,n){if(!s.unitsStringIsValid(n))throw new Error("Invalid format of 'units' parameter");const o=i.Column.fromList("string",e,new Array(t).fill(""));return o.semType=i.SEMTYPE.MACROMOLECULE,o.setTag(i.TAGS.UNITS,n),o}constructor(t){this._column=t;const e=this._column.tags[i.TAGS.UNITS];if(null===e)throw new Error("Units are not specified in column");if(this._units=e,this._notation=this.getNotation(),this._defaultGapSymbol=this.isFasta()?s._defaultGapSymbolsDict.FASTA:this.isHelm()?s._defaultGapSymbolsDict.HELM:s._defaultGapSymbolsDict.SEPARATOR,!this.column.tags.has("aligned")&&(this.isFasta()||this.isSeparator()))throw new Error(`For column '${this.column.name}' of notation '${this.notation}' tag 'aligned' is mandatory.`);if(!this.column.tags.has(".alphabetIsMultichar")){if(this.isHelm())throw new Error(`For column '${this.column.name}' of notation '${this.notation}' tag '.alphabetIsMultichar' is mandatory.`);if(["UN"].includes(this.alphabet))throw new Error(`For column '${this.column.name}' of alphabet '${this.alphabet}' tag '.alphabetIsMultichar' is mandatory.`)}}}s._defaultGapSymbolsDict={HELM:"*",SEPARATOR:"",FASTA:"-"},s.PeptideFastaAlphabet=new Set(["G","L","Y","S","E","Q","D","N","F","A","K","R","H","C","V","P","W","I","M","T"]),s.DnaFastaAlphabet=new Set(["A","C","G","T"]),s.RnaFastaAlphabet=new Set(["A","C","G","U"])},9298:(t,e,n)=>{"use strict";var i;n.d(e,{CI:()=>o,DX:()=>s,ES:()=>i}),function(t){t.Entropy="Entropy",t.full="100%"}(i||(i={}));const o=", ";var s;!function(t){t.positionNames=".positionNames"}(s||(s={}))},4588:(t,e,n)=>{"use strict";function i(t){return Math.random()*t}function o(t){return Math.floor(i(t))}n.d(e,{I:()=>o,t:()=>i})},1061:(t,e,n)=>{"use strict";n.d(e,{AB:()=>A,Bu:()=>f,QK:()=>r,W3:()=>y,Wh:()=>g,X5:()=>b,bb:()=>w,ci:()=>S,f6:()=>v,gw:()=>M,l_:()=>m});var i=n(4469),o=n(976),s=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};const r={},a="Auto Tests",l={};let h;var u;!function(t){t.notNull=function(t,e){if(null==t)throw new Error(`${null==e?"Value":e} not defined`)}}(u||(u={}));class c{constructor(t,e){this.catchUnhandled=!0,this.report=!1,void 0!==t&&(this.catchUnhandled=t),void 0!==e&&(this.report=e)}}class d{constructor(t,e,n,i){var o;this.category=t,this.name=e,null!=i||(i={}),null!==(o=i.timeout)&&void 0!==o||(i.timeout=3e4),this.options=i,this.test=()=>s(this,void 0,void 0,(function*(){return new Promise(((t,e)=>s(this,void 0,void 0,(function*(){let i="";try{i=yield n()}catch(t){e(t)}t(i)}))))}))}}function f(t,e,n){null==r[h]&&(r[h]={}),null==r[h].tests&&(r[h].tests=[]),r[h].tests.push(new d(h,t,e,n))}function m(t,e=!0,n){if(n=n?`${n}, `:"",t!==e)throw new Error(`${n}Expected "${e}", got "${t}"`)}function p(t,e,n=.001,i){if(t===Number.POSITIVE_INFINITY&&e===Number.POSITIVE_INFINITY||t===Number.NEGATIVE_INFINITY&&e===Number.NEGATIVE_INFINITY||t===Number.NaN&&e===Number.NaN||isNaN(t)&&isNaN(e))return;const o=Math.abs(t-e)<n;if(m(o,!0,`${null!=i?i:""} (tolerance = ${n})`),!o)throw new Error(`Expected ${e}, got ${t} (tolerance = ${n})`)}function g(t,e){for(const[n,i]of Object.entries(e)){if(!t.hasOwnProperty(n))throw new Error(`Expected property "${n}" not found`);const e=t[n];if(e instanceof Array&&i instanceof Array)v(e,i);else if(e instanceof Object&&i instanceof Object)g(e,i);else if(Number.isFinite(e)&&Number.isFinite(i))p(e,i);else if(e!=i)throw new Error(`Expected (${i}) for key '${n}', got (${e})`)}}function v(t,e){const n=t.length,i=e.length;if(n!=i)throw new Error(`Arrays are of different length: actual array length is ${n} and expected array length is ${i}`);for(let i=0;i<n;i++)if(t[i]instanceof Array&&e[i]instanceof Array)v(t[i],e[i]);else if(t[i]instanceof Object&&e[i]instanceof Object)g(t[i],e[i]);else if(t[i]!=e[i])throw new Error(`Expected ${e[i]} at position ${i}, got ${t[i]}`)}function y(t,e){h=t,e()}function w(t){null==r[h]&&(r[h]={}),r[h].before=t}function b(t){null==r[h]&&(r[h]={}),r[h].after=t}function C(t,e){return t.replace(new RegExp(e.name,"gi"),e.nqName)}function S(t){var e,n,h,u,f;return s(this,void 0,void 0,(function*(){const m=null===(n=null===(e=i.functions.getCurrentCall())||void 0===e?void 0:e.func)||void 0===n?void 0:n.package;yield function(t,e){return s(this,void 0,void 0,(function*(){if(l[t])return;const e=r;if(void 0!==e[a])return void(l[t]=!0);const n=[],o=yield i.dapi.functions.filter(`package.id = "${t}"`).list();for(const t of o){const e=t.options.test;if(e&&Array.isArray(e)&&e.length)for(let o=0;o<e.length;o++)n.push(new d(a,1===e.length?t.name:`${t.name} ${o+1}`,(()=>s(this,void 0,void 0,(function*(){if(!0!==(yield i.functions.eval(C(e[o],t))))throw`Failed: ${e[o]}`})))))}l[t]=!0,n.length&&(e[a]={tests:n})}))}(m.id);const p=[];console.log("Running tests"),null!=t||(t={}),null!==(h=(f=t).testContext)&&void 0!==h||(f.testContext=new c),i.shell.lastError="";for(const[e,n]of Object.entries(r)){if(null!=(null==t?void 0:t.category)&&!e.toLowerCase().startsWith(null==t?void 0:t.category.toLowerCase()))continue;console.log(`Started ${e} category`);try{n.before&&(yield n.before())}catch(t){n.beforeStatus=t.toString()}const i=null!==(u=n.tests)&&void 0!==u?u:[],o=[];for(let e=0;e<i.length;e++)o.push(yield T(i[e],null==t?void 0:t.test));const s=(yield Promise.all(o)).filter((t=>"skipped"!=t.result));try{n.after&&(yield n.after())}catch(t){n.afterStatus=t.toString()}n.afterStatus&&s.push({category:e,name:"init",result:n.afterStatus,success:!1,ms:0,skipped:!1}),n.beforeStatus&&s.push({category:e,name:"init",result:n.beforeStatus,success:!1,ms:0,skipped:!1}),p.push(...s)}if(t.testContext.catchUnhandled&&(yield M(1e3),i.shell.lastError.length>0&&p.push({category:"Unhandled exceptions",name:"exceptions",result:i.shell.lastError,success:!1,ms:0,skipped:!1})),t.testContext.report){const t=new o.Logger,e=p.filter((t=>t.success)).length,n=p.filter((t=>t.skipped)).length,i=p.filter((t=>!t.success)),s="Package @package tested: @successful successful, @skipped skipped, @failed failed tests",r={successful:e,skipped:n,failed:i.length,package:m};for(const t of i)Object.assign(r,{[`${t.category} | ${t.name}`]:t.result});t.log(s,r,"package-tested")}return p}))}function T(t,e){var n,i,o;return s(this,void 0,void 0,(function*(){let s;const r=null!=e&&!t.name.toLowerCase().startsWith(e.toLowerCase()),a=(null===(n=t.options)||void 0===n?void 0:n.skipReason)||r,l=r?"skipped":null===(i=t.options)||void 0===i?void 0:i.skipReason;a||console.log(`Started ${t.category} ${t.name}`);const h=new Date;try{s=a?{success:!0,result:l,ms:0,skipped:!0}:{success:!0,result:null!==(o=yield t.test())&&void 0!==o?o:"OK",ms:0,skipped:!1}}catch(t){s={success:!1,result:t.toString(),ms:0,skipped:!1}}const u=new Date;return s.ms=u-h,a||console.log(`Finished ${t.category} ${t.name} for ${s.ms} ms`),s.category=t.category,s.name=t.name,s}))}function M(t){return s(this,void 0,void 0,(function*(){yield new Promise((e=>setTimeout(e,t)))}))}function E(t,e="Timeout exceeded",n=500){return s(this,void 0,void 0,(function*(){return new Promise(((i,o)=>{setTimeout((()=>{clearInterval(s),o(new Error(e))}),n);const s=setInterval((()=>{t()&&(clearInterval(s),i())}),50)}))}))}function A(t,e,n=!1){return s(this,void 0,void 0,(function*(){n&&(yield i.data.detectSemanticTypes(e));const o=i.shell.addTableView(e),s=`[name=viewer-${t.replace(/\s+/g,"-")} i]`,r=`${s} canvas,${s} svg,${s} img,\n ${s} input,${s} h1,${s} a`,a=[];try{let n=o.addViewer(t);yield E((()=>null!==document.querySelector(r)),"cannot load viewer",3e3),a.push(Array.from(o.viewers).length),Array.from(e.row(0).cells).forEach((t=>t.value=null)),e.rows.select((t=>t.idx>1&&t.idx<7));for(let t=7;t<12;t++)e.filter.set(t,!1);e.currentRowIdx=1;const i=n.getOptions(!0).look,s={};Object.keys(i).filter((t=>"boolean"==typeof i[t])).forEach((t=>s[t]=!i[t])),n.setOptions(s),yield M(250);const l=o.saveLayout(),h=n.getOptions().look;o.resetLayout(),a.push(Array.from(o.viewers).length),o.loadLayout(l),yield E((()=>null!==document.querySelector(r)),"cannot load viewer from layout",3e3),yield M(250),a.push(Array.from(o.viewers).length),n=Array.from(o.viewers).find((t=>"Grid"!==t.type)),v(a,[2,1,2]),m(JSON.stringify(n.getOptions().look),JSON.stringify(h))}finally{o.close(),i.shell.closeTable(e)}}))}},7604:(t,e,n)=>{"use strict";function i(t){var e;return"string"==typeof t||t instanceof String?t:("object"==typeof t||t instanceof Object)&&"$thrownJsError"in t?i(t.$thrownJsError):t instanceof Error?null!==(e=t.stack)&&void 0!==e?e:t.message:t.toString()}n.d(e,{O:()=>i})},3659:(t,e,n)=>{"use strict";n.d(e,{OW:()=>i});class i extends Float32Array{}},850:(t,e,n)=>{"use strict";n.d(e,{$G:()=>l,H3:()=>d,MA:()=>h,On:()=>a,dP:()=>c,hu:()=>s,kO:()=>u});var i=n(3659),o=n(4588);function s(t=!1,e="Assertion error."){if(!t)throw new Error(e)}function r(t,e,n=0){return new Array(t).fill(n).map((()=>new i.OW(e).fill(n)))}function a(t,e,n=1){const o=t.length;s(o==e.length,"Vector lengths do not match.");const r=new i.OW(o);for(let i=0;i<t.length;++i)r[i]=t[i]+n*e[i];return r}function l(t){let e=0;for(let n=0;n<t.length;n++)e+=t[n]*t[n];return Math.sqrt(e)}function h(t,e){if(t.length!=e.length)throw new Error("The dimensionality of the vectors must match");let n=0;for(let i=0;i<t.length;i++)n+=t[i]*e[i];return n}function u(t,e,n=1){const i=r(t,e);for(let s=0;s<t;++s)for(let t=0;t<e;++t)i[s][t]=(0,o.t)(n);return i}function c(t,e){const n=function(t){let e=0;for(let n=0;n<t.length;++n)e+=t[n];return e}(function(t){const e=t.length,n=new i.OW(e);for(let e=0;e<t.length;++e)n[e]=t[e]*t[e];return n}(a(t,e,-1)));return Math.sqrt(n)}function d(t,e){const n=t.length,i=r(n,n,0);for(let o=0;o<n;++o)for(let s=o+1;s<n;++s){const n=null==t[o]||null==t[s]?0:e(t[o],t[s]);i[o][s]=i[s][o]=n}return i}},7659:(t,e,n)=>{"use strict";e.Z=void 0;var i=n(6215);Object.defineProperty(e,"Z",{enumerable:!0,get:function(){return i.TSNE}})},6215:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.TSNE=void 0,e.TSNE=class{constructor(t){this.returnV=!1,this.vValue=0,this.iter=0,t=t||{},this.perplexity=this.getopt(t,"perplexity",30),this.dim=this.getopt(t,"dim",2),this.epsilon=this.getopt(t,"epsilon",10)}assert(t,e){if(!t)throw e||"Assertion failed"}getopt(t,e,n){return t.hasOwnProperty(e)?t[e]:n}gaussRandom(){if(this.returnV)return this.returnV=!1,this.vValue;const t=2*Math.random()-1,e=2*Math.random()-1,n=t*t+e*e;if(0===n||n>1)return this.gaussRandom();const i=Math.sqrt(-2*Math.log(n)/n);return this.vValue=e*i,this.returnV=!0,t*i}randn(t,e){return t+this.gaussRandom()*e}zeros(t){if(void 0===t||isNaN(t))return[];if("undefined"==typeof ArrayBuffer){const e=new Array(t);for(let n=0;n<t;n++)e[n]=0;return e}return new Float64Array(t)}randn2d(t,e,n){const i=void 0!==n,o=[];for(let s=0;s<t;s++){const t=[];for(let o=0;o<e;o++)i?t.push(n):t.push(this.randn(0,1e-4));o.push(t)}return o}L2(t,e){const n=t.length;let i=0;for(let o=0;o<n;o++){const n=t[o],s=e[o];i+=(n-s)*(n-s)}return i}xtod(t){const e=t.length,n=this.zeros(e*e);for(let i=0;i<e;i++)for(let o=i+1;o<e;o++){const s=this.L2(t[i],t[o]);n[i*e+o]=s,n[o*e+i]=s}return n}d2p(t,e,n){const i=Math.sqrt(t.length),o=Math.floor(i);this.assert(o===i,"D should have square number of elements.");const s=Math.log(e),r=this.zeros(o*o),a=this.zeros(o);for(let e=0;e<o;e++){let i=-1/0,l=1/0,h=1,u=!1;const c=50;let d=0;for(;!u;){let r=0;for(let n=0;n<o;n++){let i=Math.exp(-t[e*o+n]*h);e===n&&(i=0),a[n]=i,r+=i}let f=0;for(let t=0;t<o;t++){let e;e=0===r?0:a[t]/r,a[t]=e,e>1e-7&&(f-=e*Math.log(e))}f>s?(i=h,l===1/0?h*=2:h=(h+l)/2):(l=h,i===-1/0?h/=2:h=(h+i)/2),d++,Math.abs(f-s)<n&&(u=!0),d>=c&&(u=!0)}for(let t=0;t<o;t++)r[e*o+t]=a[t]}const l=this.zeros(o*o),h=2*o;for(let t=0;t<o;t++)for(let e=0;e<o;e++)l[t*o+e]=Math.max((r[t*o+e]+r[e*o+t])/h,1e-100);return l}sign(t){return t>0?1:t<0?-1:0}initDataRaw(t){const e=t.length,n=t[0].length;this.assert(e>0," X is empty? You must have some data!"),this.assert(n>0," X[0] is empty? Where is the data?");const i=this.xtod(t);this.P=this.d2p(i,this.perplexity,1e-4),this.N=e,this.initSolution()}initDataDist(t){const e=t.length;this.assert(e>0," X is empty? You must have some data!");const n=this.zeros(e*e);for(let i=0;i<e;i++)for(let o=i+1;o<e;o++){const s=t[i][o];n[i*e+o]=s,n[o*e+i]=s}this.P=this.d2p(n,this.perplexity,1e-4),this.N=e,this.initSolution()}initSolution(){this.Y=this.randn2d(this.N,this.dim),this.gains=this.randn2d(this.N,this.dim,1),this.ystep=this.randn2d(this.N,this.dim,0),this.iter=0}getSolution(){return this.Y}step(){this.iter+=1;const t=this.N,e=this.costGrad(this.Y),n=e.cost,i=e.grad,o=this.zeros(this.dim);for(let e=0;e<t;e++)for(let t=0;t<this.dim;t++){const n=i[e][t],s=this.ystep[e][t],r=this.gains[e][t];let a=this.sign(n)===this.sign(s)?.8*r:r+.2;a<.01&&(a=.01),this.gains[e][t]=a;const l=(this.iter<250?.5:.8)*s-this.epsilon*a*i[e][t];this.ystep[e][t]=l,this.Y[e][t]+=l,o[t]+=this.Y[e][t]}for(let e=0;e<t;e++)for(let n=0;n<this.dim;n++)this.Y[e][n]-=o[n]/t;return n}debugGrad(){const t=this.N,e=this.costGrad(this.Y),n=(e.cost,e.grad),i=1e-5;for(let e=0;e<t;e++)for(let t=0;t<this.dim;t++){const o=this.Y[e][t];this.Y[e][t]=o+i;const s=this.costGrad(this.Y);this.Y[e][t]=o-i;const r=this.costGrad(this.Y),a=n[e][t],l=(s.cost-r.cost)/(2*i);console.log(e+","+t+": gradcheck analytic: "+a+" vs. numerical: "+l),this.Y[e][t]=o}}costGrad(t){const e=this.N,n=this.dim,i=this.P,o=this.iter<100?4:1,s=this.zeros(e*e);let r=0;for(let i=0;i<e;i++)for(let o=i+1;o<e;o++){let a=0;for(let e=0;e<n;e++){const n=t[i][e]-t[o][e];a+=n*n}const l=1/(1+a);s[i*e+o]=l,s[o*e+i]=l,r+=2*l}const a=e*e,l=this.zeros(a);for(let t=0;t<a;t++)l[t]=Math.max(s[t]/r,1e-100);let h=0;const u=[];for(let r=0;r<e;r++){const a=new Array(n);for(let t=0;t<n;t++)a[t]=0;for(let u=0;u<e;u++){h+=-i[r*e+u]*Math.log(l[r*e+u]);const c=4*(o*i[r*e+u]-l[r*e+u])*s[r*e+u];for(let e=0;e<n;e++)a[e]+=c*(t[r][e]-t[u][e])}u.push(a)}return{cost:h,grad:u}}}},9414:(t,e,n)=>{"use strict";n.d(e,{Z:()=>a});var i=n(7537),o=n.n(i),s=n(3645),r=n.n(s)()(o());r.push([t.id,".scatter_plot_link {\n position: absolute!important;\n right: 10px;\n}\n\n.cliffs_grid {\n top: 10px;\n}\n\n.show_only_cliffs {\n top: 30px;\n}\n","",{version:3,sources:["webpack://./node_modules/@datagrok-libraries/ml/css/styles.css"],names:[],mappings:"AAAA;IACI,4BAA4B;IAC5B,WAAW;AACf;;AAEA;IACI,SAAS;AACb;;AAEA;IACI,SAAS;AACb",sourcesContent:[".scatter_plot_link {\n position: absolute!important;\n right: 10px;\n}\n\n.cliffs_grid {\n top: 10px;\n}\n\n.show_only_cliffs {\n top: 30px;\n}\n"],sourceRoot:""}]);const a=r},3645:t=>{"use strict";t.exports=function(t){var e=[];return e.toString=function(){return this.map((function(e){var n="",i=void 0!==e[5];return e[4]&&(n+="@supports (".concat(e[4],") {")),e[2]&&(n+="@media ".concat(e[2]," {")),i&&(n+="@layer".concat(e[5].length>0?" ".concat(e[5]):""," {")),n+=t(e),i&&(n+="}"),e[2]&&(n+="}"),e[4]&&(n+="}"),n})).join("")},e.i=function(t,n,i,o,s){"string"==typeof t&&(t=[[null,t,void 0]]);var r={};if(i)for(var a=0;a<this.length;a++){var l=this[a][0];null!=l&&(r[l]=!0)}for(var h=0;h<t.length;h++){var u=[].concat(t[h]);i&&r[u[0]]||(void 0!==s&&(void 0===u[5]||(u[1]="@layer".concat(u[5].length>0?" ".concat(u[5]):""," {").concat(u[1],"}")),u[5]=s),n&&(u[2]?(u[1]="@media ".concat(u[2]," {").concat(u[1],"}"),u[2]=n):u[2]=n),o&&(u[4]?(u[1]="@supports (".concat(u[4],") {").concat(u[1],"}"),u[4]=o):u[4]="".concat(o)),e.push(u))}},e}},7537:t=>{"use strict";t.exports=function(t){var e=t[1],n=t[3];if(!n)return e;if("function"==typeof btoa){var i=btoa(unescape(encodeURIComponent(JSON.stringify(n)))),o="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(i),s="/*# ".concat(o," */");return[e].concat([s]).join("\n")}return[e].join("\n")}},9133:function(t,e,n){var i;!function(e,o){var s={};!function(t){"use strict";t.__esModule=!0,t.digestLength=32,t.blockSize=64;var e=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function n(t,n,i,o,s){for(var r,a,l,h,u,c,d,f,m,p,g,v,y;s>=64;){for(r=n[0],a=n[1],l=n[2],h=n[3],u=n[4],c=n[5],d=n[6],f=n[7],p=0;p<16;p++)g=o+4*p,t[p]=(255&i[g])<<24|(255&i[g+1])<<16|(255&i[g+2])<<8|255&i[g+3];for(p=16;p<64;p++)v=((m=t[p-2])>>>17|m<<15)^(m>>>19|m<<13)^m>>>10,y=((m=t[p-15])>>>7|m<<25)^(m>>>18|m<<14)^m>>>3,t[p]=(v+t[p-7]|0)+(y+t[p-16]|0);for(p=0;p<64;p++)v=(((u>>>6|u<<26)^(u>>>11|u<<21)^(u>>>25|u<<7))+(u&c^~u&d)|0)+(f+(e[p]+t[p]|0)|0)|0,y=((r>>>2|r<<30)^(r>>>13|r<<19)^(r>>>22|r<<10))+(r&a^r&l^a&l)|0,f=d,d=c,c=u,u=h+v|0,h=l,l=a,a=r,r=v+y|0;n[0]+=r,n[1]+=a,n[2]+=l,n[3]+=h,n[4]+=u,n[5]+=c,n[6]+=d,n[7]+=f,o+=64,s-=64}return o}var i=function(){function e(){this.digestLength=t.digestLength,this.blockSize=t.blockSize,this.state=new Int32Array(8),this.temp=new Int32Array(64),this.buffer=new Uint8Array(128),this.bufferLength=0,this.bytesHashed=0,this.finished=!1,this.reset()}return e.prototype.reset=function(){return this.state[0]=1779033703,this.state[1]=3144134277,this.state[2]=1013904242,this.state[3]=2773480762,this.state[4]=1359893119,this.state[5]=2600822924,this.state[6]=528734635,this.state[7]=1541459225,this.bufferLength=0,this.bytesHashed=0,this.finished=!1,this},e.prototype.clean=function(){for(var t=0;t<this.buffer.length;t++)this.buffer[t]=0;for(t=0;t<this.temp.length;t++)this.temp[t]=0;this.reset()},e.prototype.update=function(t,e){if(void 0===e&&(e=t.length),this.finished)throw new Error("SHA256: can't update because hash was finished.");var i=0;if(this.bytesHashed+=e,this.bufferLength>0){for(;this.bufferLength<64&&e>0;)this.buffer[this.bufferLength++]=t[i++],e--;64===this.bufferLength&&(n(this.temp,this.state,this.buffer,0,64),this.bufferLength=0)}for(e>=64&&(i=n(this.temp,this.state,t,i,e),e%=64);e>0;)this.buffer[this.bufferLength++]=t[i++],e--;return this},e.prototype.finish=function(t){if(!this.finished){var e=this.bytesHashed,i=this.bufferLength,o=e/536870912|0,s=e<<3,r=e%64<56?64:128;this.buffer[i]=128;for(var a=i+1;a<r-8;a++)this.buffer[a]=0;this.buffer[r-8]=o>>>24&255,this.buffer[r-7]=o>>>16&255,this.buffer[r-6]=o>>>8&255,this.buffer[r-5]=o>>>0&255,this.buffer[r-4]=s>>>24&255,this.buffer[r-3]=s>>>16&255,this.buffer[r-2]=s>>>8&255,this.buffer[r-1]=s>>>0&255,n(this.temp,this.state,this.buffer,0,r),this.finished=!0}for(a=0;a<8;a++)t[4*a+0]=this.state[a]>>>24&255,t[4*a+1]=this.state[a]>>>16&255,t[4*a+2]=this.state[a]>>>8&255,t[4*a+3]=this.state[a]>>>0&255;return this},e.prototype.digest=function(){var t=new Uint8Array(this.digestLength);return this.finish(t),t},e.prototype._saveState=function(t){for(var e=0;e<this.state.length;e++)t[e]=this.state[e]},e.prototype._restoreState=function(t,e){for(var n=0;n<this.state.length;n++)this.state[n]=t[n];this.bytesHashed=e,this.finished=!1,this.bufferLength=0},e}();t.Hash=i;var o=function(){function t(t){this.inner=new i,this.outer=new i,this.blockSize=this.inner.blockSize,this.digestLength=this.inner.digestLength;var e=new Uint8Array(this.blockSize);if(t.length>this.blockSize)(new i).update(t).finish(e).clean();else for(var n=0;n<t.length;n++)e[n]=t[n];for(n=0;n<e.length;n++)e[n]^=54;for(this.inner.update(e),n=0;n<e.length;n++)e[n]^=106;for(this.outer.update(e),this.istate=new Uint32Array(8),this.ostate=new Uint32Array(8),this.inner._saveState(this.istate),this.outer._saveState(this.ostate),n=0;n<e.length;n++)e[n]=0}return t.prototype.reset=function(){return this.inner._restoreState(this.istate,this.inner.blockSize),this.outer._restoreState(this.ostate,this.outer.blockSize),this},t.prototype.clean=function(){for(var t=0;t<this.istate.length;t++)this.ostate[t]=this.istate[t]=0;this.inner.clean(),this.outer.clean()},t.prototype.update=function(t){return this.inner.update(t),this},t.prototype.finish=function(t){return this.outer.finished?this.outer.finish(t):(this.inner.finish(t),this.outer.update(t,this.digestLength).finish(t)),this},t.prototype.digest=function(){var t=new Uint8Array(this.digestLength);return this.finish(t),t},t}();function s(t){var e=(new i).update(t),n=e.digest();return e.clean(),n}function r(t,e){var n=new o(t).update(e),i=n.digest();return n.clean(),i}function a(t,e,n,i){var o=i[0];if(0===o)throw new Error("hkdf: cannot expand more");e.reset(),o>1&&e.update(t),n&&e.update(n),e.update(i),e.finish(t),i[0]++}t.HMAC=o,t.hash=s,t.default=s,t.hmac=r;var l=new Uint8Array(t.digestLength);t.hkdf=function(t,e,n,i){void 0===e&&(e=l),void 0===i&&(i=32);for(var s=new Uint8Array([1]),h=r(e,t),u=new o(h),c=new Uint8Array(u.digestLength),d=c.length,f=new Uint8Array(i),m=0;m<i;m++)d===c.length&&(a(c,u,n,s),d=0),f[m]=c[d++];return u.clean(),c.fill(0),s.fill(0),f},t.pbkdf2=function(t,e,n,i){for(var s=new o(t),r=s.digestLength,a=new Uint8Array(4),l=new Uint8Array(r),h=new Uint8Array(r),u=new Uint8Array(i),c=0;c*r<i;c++){var d=c+1;a[0]=d>>>24&255,a[1]=d>>>16&255,a[2]=d>>>8&255,a[3]=d>>>0&255,s.reset(),s.update(e),s.update(a),s.finish(h);for(var f=0;f<r;f++)l[f]=h[f];for(f=2;f<=n;f++){s.reset(),s.update(h).finish(h);for(var m=0;m<r;m++)l[m]^=h[m]}for(f=0;f<r&&c*r+f<i;f++)u[c*r+f]=l[f]}for(c=0;c<r;c++)l[c]=h[c]=0;for(c=0;c<4;c++)a[c]=0;return s.clean(),u}}(s);var r=s.default;for(var a in s)r[a]=s[a];"object"==typeof t.exports?t.exports=r:void 0===(i=function(){return r}.call(s,n,s,t))||(t.exports=i)}()},3979:(t,e)=>{"use strict";e.H$=void 0,e.H$=function(t,e,n){var i=function(t,e,n){if(0===t.length||0===e.length)return 0;if(n&&!n.caseSensitive&&(t=t.toUpperCase(),e=e.toUpperCase()),t===e)return 1;for(var i=0,o=t.length,s=e.length,r=Math.floor(Math.max(o,s)/2)-1,a=new Array(o),l=new Array(s),h=0;h<o;h++)for(var u=Math.max(0,h-r);u<=Math.min(s,h+r+1);u++)if(!a[h]&&!l[u]&&t[h]===e[u]){++i,a[h]=l[u]=!0;break}if(0===i)return 0;var c=0,d=0;for(h=0;h<o;h++)if(a[h]){for(;!l[d];)d++;t.charAt(h)!==e.charAt(d++)&&c++}return(i/o+i/s+(i-(c/=2))/i)/3}(t,e,n),o=0;if(i>.7){for(var s=Math.min(t.length,e.length),r=0;t[r]===e[r]&&r<4&&r<s;)++o,r++;i+=.1*o*(1-i)}return i}},9251:(t,e,n)=>{"use strict";n.r(e),n.d(e,{default:()=>W});const i=Object.prototype.toString;function o(t){return i.call(t).endsWith("Array]")}function s(t,e,n){let i=0;const o=n(e);for(let e=0;e<t.x.length;e++)i+=Math.abs(t.y[e]-o(t.x[e]));return i}const r=Object.prototype.toString;function a(t){return r.call(t).endsWith("Array]")}const l=Object.prototype.toString;function h(t){return l.call(t).endsWith("Array]")}const u=Object.prototype.toString;const c=Object.prototype.toString;function d(t){var e,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!h(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");if(void 0!==n.output){if(!h(n.output))throw new TypeError("output option must be an array if specified");e=n.output}else e=new Array(t.length);var i=function(t){var e,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(e=t,!c.call(e).endsWith("Array]"))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");var i=n.fromIndex,o=void 0===i?0:i,s=n.toIndex,r=void 0===s?t.length:s;if(o<0||o>=t.length||!Number.isInteger(o))throw new Error("fromIndex must be a positive integer smaller than length");if(r<=o||r>t.length||!Number.isInteger(r))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var a=t[o],l=o+1;l<r;l++)t[l]<a&&(a=t[l]);return a}(t),o=function(t){var e,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(e=t,!u.call(e).endsWith("Array]"))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");var i=n.fromIndex,o=void 0===i?0:i,s=n.toIndex,r=void 0===s?t.length:s;if(o<0||o>=t.length||!Number.isInteger(o))throw new Error("fromIndex must be a positive integer smaller than length");if(r<=o||r>t.length||!Number.isInteger(r))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var a=t[o],l=o+1;l<r;l++)t[l]>a&&(a=t[l]);return a}(t);if(i===o)throw new RangeError("minimum and maximum input values are equal. Cannot rescale a constant array");var s=n.min,r=void 0===s?n.autoMinMax?i:0:s,a=n.max,l=void 0===a?n.autoMinMax?o:1:a;if(r>=l)throw new RangeError("min option must be smaller than max option");for(var d=(l-r)/(o-i),f=0;f<t.length;f++)e[f]=(t[f]-i)*d+r;return e}const f=" ".repeat(2),m=" ".repeat(4);function p(t,e={}){const{maxRows:n=15,maxColumns:i=10,maxNumSize:o=8,padMinus:s="auto"}=e;return`${t.constructor.name} {\n${f}[\n${m}${function(t,e,n,i,o){const{rows:s,columns:r}=t,a=Math.min(s,e),l=Math.min(r,n),h=[];if("auto"===o){o=!1;t:for(let e=0;e<a;e++)for(let n=0;n<l;n++)if(t.get(e,n)<0){o=!0;break t}}for(let e=0;e<a;e++){let n=[];for(let s=0;s<l;s++)n.push(g(t.get(e,s),i,o));h.push(`${n.join(" ")}`)}return l!==r&&(h[h.length-1]+=` ... ${r-n} more columns`),a!==s&&h.push(`... ${s-e} more rows`),h.join(`\n${m}`)}(t,n,i,o,s)}\n${f}]\n${f}rows: ${t.rows}\n${f}columns: ${t.columns}\n}`}function g(t,e,n){return(t>=0&&n?` ${v(t,e-1)}`:v(t,e)).padEnd(e)}function v(t,e){let n=t.toString();if(n.length<=e)return n;let i=t.toFixed(e);if(i.length>e&&(i=t.toFixed(Math.max(0,e-(i.length-e)))),i.length<=e&&!i.startsWith("0.000")&&!i.startsWith("-0.000"))return i;let o=t.toExponential(e);return o.length>e&&(o=t.toExponential(Math.max(0,e-(o.length-e)))),o.slice(0)}function y(t,e,n){let i=n?t.rows:t.rows-1;if(e<0||e>i)throw new RangeError("Row index out of range")}function w(t,e,n){let i=n?t.columns:t.columns-1;if(e<0||e>i)throw new RangeError("Column index out of range")}function b(t,e){if(e.to1DArray&&(e=e.to1DArray()),e.length!==t.columns)throw new RangeError("vector size must be the same as the number of columns");return e}function C(t,e){if(e.to1DArray&&(e=e.to1DArray()),e.length!==t.rows)throw new RangeError("vector size must be the same as the number of rows");return e}function S(t,e,n,i,o){if(5!==arguments.length)throw new RangeError("expected 4 arguments");if(M("startRow",e),M("endRow",n),M("startColumn",i),M("endColumn",o),e>n||i>o||e<0||e>=t.rows||n<0||n>=t.rows||i<0||i>=t.columns||o<0||o>=t.columns)throw new RangeError("Submatrix indices are out of range")}function T(t,e=0){let n=[];for(let i=0;i<t;i++)n.push(e);return n}function M(t,e){if("number"!=typeof e)throw new TypeError(`${t} must be a number`)}function E(t){if(t.isEmpty())throw new Error("Empty matrix has no elements to index")}class A{static from1DArray(t,e,n){if(t*e!==n.length)throw new RangeError("data length does not match given dimensions");let i=new P(t,e);for(let o=0;o<t;o++)for(let t=0;t<e;t++)i.set(o,t,n[o*e+t]);return i}static rowVector(t){let e=new P(1,t.length);for(let n=0;n<t.length;n++)e.set(0,n,t[n]);return e}static columnVector(t){let e=new P(t.length,1);for(let n=0;n<t.length;n++)e.set(n,0,t[n]);return e}static zeros(t,e){return new P(t,e)}static ones(t,e){return new P(t,e).fill(1)}static rand(t,e,n={}){if("object"!=typeof n)throw new TypeError("options must be an object");const{random:i=Math.random}=n;let o=new P(t,e);for(let n=0;n<t;n++)for(let t=0;t<e;t++)o.set(n,t,i());return o}static randInt(t,e,n={}){if("object"!=typeof n)throw new TypeError("options must be an object");const{min:i=0,max:o=1e3,random:s=Math.random}=n;if(!Number.isInteger(i))throw new TypeError("min must be an integer");if(!Number.isInteger(o))throw new TypeError("max must be an integer");if(i>=o)throw new RangeError("min must be smaller than max");let r=o-i,a=new P(t,e);for(let n=0;n<t;n++)for(let t=0;t<e;t++){let e=i+Math.round(s()*r);a.set(n,t,e)}return a}static eye(t,e,n){void 0===e&&(e=t),void 0===n&&(n=1);let i=Math.min(t,e),o=this.zeros(t,e);for(let t=0;t<i;t++)o.set(t,t,n);return o}static diag(t,e,n){let i=t.length;void 0===e&&(e=i),void 0===n&&(n=e);let o=Math.min(i,e,n),s=this.zeros(e,n);for(let e=0;e<o;e++)s.set(e,e,t[e]);return s}static min(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let n=t.rows,i=t.columns,o=new P(n,i);for(let s=0;s<n;s++)for(let n=0;n<i;n++)o.set(s,n,Math.min(t.get(s,n),e.get(s,n)));return o}static max(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let n=t.rows,i=t.columns,o=new this(n,i);for(let s=0;s<n;s++)for(let n=0;n<i;n++)o.set(s,n,Math.max(t.get(s,n),e.get(s,n)));return o}static checkMatrix(t){return A.isMatrix(t)?t:new P(t)}static isMatrix(t){return null!=t&&"Matrix"===t.klass}get size(){return this.rows*this.columns}apply(t){if("function"!=typeof t)throw new TypeError("callback must be a function");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)t.call(this,e,n);return this}to1DArray(){let t=[];for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)t.push(this.get(e,n));return t}to2DArray(){let t=[];for(let e=0;e<this.rows;e++){t.push([]);for(let n=0;n<this.columns;n++)t[e].push(this.get(e,n))}return t}toJSON(){return this.to2DArray()}isRowVector(){return 1===this.rows}isColumnVector(){return 1===this.columns}isVector(){return 1===this.rows||1===this.columns}isSquare(){return this.rows===this.columns}isEmpty(){return 0===this.rows||0===this.columns}isSymmetric(){if(this.isSquare()){for(let t=0;t<this.rows;t++)for(let e=0;e<=t;e++)if(this.get(t,e)!==this.get(e,t))return!1;return!0}return!1}isEchelonForm(){let t=0,e=0,n=-1,i=!0,o=!1;for(;t<this.rows&&i;){for(e=0,o=!1;e<this.columns&&!1===o;)0===this.get(t,e)?e++:1===this.get(t,e)&&e>n?(o=!0,n=e):(i=!1,o=!0);t++}return i}isReducedEchelonForm(){let t=0,e=0,n=-1,i=!0,o=!1;for(;t<this.rows&&i;){for(e=0,o=!1;e<this.columns&&!1===o;)0===this.get(t,e)?e++:1===this.get(t,e)&&e>n?(o=!0,n=e):(i=!1,o=!0);for(let n=e+1;n<this.rows;n++)0!==this.get(t,n)&&(i=!1);t++}return i}echelonForm(){let t=this.clone(),e=0,n=0;for(;e<t.rows&&n<t.columns;){let i=e;for(let o=e;o<t.rows;o++)t.get(o,n)>t.get(i,n)&&(i=o);if(0===t.get(i,n))n++;else{t.swapRows(e,i);let o=t.get(e,n);for(let i=n;i<t.columns;i++)t.set(e,i,t.get(e,i)/o);for(let i=e+1;i<t.rows;i++){let o=t.get(i,n)/t.get(e,n);t.set(i,n,0);for(let s=n+1;s<t.columns;s++)t.set(i,s,t.get(i,s)-t.get(e,s)*o)}e++,n++}}return t}reducedEchelonForm(){let t=this.echelonForm(),e=t.columns,n=t.rows,i=n-1;for(;i>=0;)if(0===t.maxRow(i))i--;else{let o=0,s=!1;for(;o<n&&!1===s;)1===t.get(i,o)?s=!0:o++;for(let n=0;n<i;n++){let s=t.get(n,o);for(let r=o;r<e;r++){let e=t.get(n,r)-s*t.get(i,r);t.set(n,r,e)}}i--}return t}set(){throw new Error("set method is unimplemented")}get(){throw new Error("get method is unimplemented")}repeat(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{rows:e=1,columns:n=1}=t;if(!Number.isInteger(e)||e<=0)throw new TypeError("rows must be a positive integer");if(!Number.isInteger(n)||n<=0)throw new TypeError("columns must be a positive integer");let i=new P(this.rows*e,this.columns*n);for(let t=0;t<e;t++)for(let e=0;e<n;e++)i.setSubMatrix(this,this.rows*t,this.columns*e);return i}fill(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,t);return this}neg(){return this.mulS(-1)}getRow(t){y(this,t);let e=[];for(let n=0;n<this.columns;n++)e.push(this.get(t,n));return e}getRowVector(t){return P.rowVector(this.getRow(t))}setRow(t,e){y(this,t),e=b(this,e);for(let n=0;n<this.columns;n++)this.set(t,n,e[n]);return this}swapRows(t,e){y(this,t),y(this,e);for(let n=0;n<this.columns;n++){let i=this.get(t,n);this.set(t,n,this.get(e,n)),this.set(e,n,i)}return this}getColumn(t){w(this,t);let e=[];for(let n=0;n<this.rows;n++)e.push(this.get(n,t));return e}getColumnVector(t){return P.columnVector(this.getColumn(t))}setColumn(t,e){w(this,t),e=C(this,e);for(let n=0;n<this.rows;n++)this.set(n,t,e[n]);return this}swapColumns(t,e){w(this,t),w(this,e);for(let n=0;n<this.rows;n++){let i=this.get(n,t);this.set(n,t,this.get(n,e)),this.set(n,e,i)}return this}addRowVector(t){t=b(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)+t[n]);return this}subRowVector(t){t=b(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)-t[n]);return this}mulRowVector(t){t=b(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)*t[n]);return this}divRowVector(t){t=b(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)/t[n]);return this}addColumnVector(t){t=C(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)+t[e]);return this}subColumnVector(t){t=C(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)-t[e]);return this}mulColumnVector(t){t=C(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)*t[e]);return this}divColumnVector(t){t=C(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)/t[e]);return this}mulRow(t,e){y(this,t);for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)*e);return this}mulColumn(t,e){w(this,t);for(let n=0;n<this.rows;n++)this.set(n,t,this.get(n,t)*e);return this}max(t){if(this.isEmpty())return NaN;switch(t){case"row":{const t=new Array(this.rows).fill(Number.NEGATIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.get(e,n)>t[e]&&(t[e]=this.get(e,n));return t}case"column":{const t=new Array(this.columns).fill(Number.NEGATIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.get(e,n)>t[n]&&(t[n]=this.get(e,n));return t}case void 0:{let t=this.get(0,0);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.get(e,n)>t&&(t=this.get(e,n));return t}default:throw new Error(`invalid option: ${t}`)}}maxIndex(){E(this);let t=this.get(0,0),e=[0,0];for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.get(n,i)>t&&(t=this.get(n,i),e[0]=n,e[1]=i);return e}min(t){if(this.isEmpty())return NaN;switch(t){case"row":{const t=new Array(this.rows).fill(Number.POSITIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.get(e,n)<t[e]&&(t[e]=this.get(e,n));return t}case"column":{const t=new Array(this.columns).fill(Number.POSITIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.get(e,n)<t[n]&&(t[n]=this.get(e,n));return t}case void 0:{let t=this.get(0,0);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.get(e,n)<t&&(t=this.get(e,n));return t}default:throw new Error(`invalid option: ${t}`)}}minIndex(){E(this);let t=this.get(0,0),e=[0,0];for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.get(n,i)<t&&(t=this.get(n,i),e[0]=n,e[1]=i);return e}maxRow(t){if(y(this,t),this.isEmpty())return NaN;let e=this.get(t,0);for(let n=1;n<this.columns;n++)this.get(t,n)>e&&(e=this.get(t,n));return e}maxRowIndex(t){y(this,t),E(this);let e=this.get(t,0),n=[t,0];for(let i=1;i<this.columns;i++)this.get(t,i)>e&&(e=this.get(t,i),n[1]=i);return n}minRow(t){if(y(this,t),this.isEmpty())return NaN;let e=this.get(t,0);for(let n=1;n<this.columns;n++)this.get(t,n)<e&&(e=this.get(t,n));return e}minRowIndex(t){y(this,t),E(this);let e=this.get(t,0),n=[t,0];for(let i=1;i<this.columns;i++)this.get(t,i)<e&&(e=this.get(t,i),n[1]=i);return n}maxColumn(t){if(w(this,t),this.isEmpty())return NaN;let e=this.get(0,t);for(let n=1;n<this.rows;n++)this.get(n,t)>e&&(e=this.get(n,t));return e}maxColumnIndex(t){w(this,t),E(this);let e=this.get(0,t),n=[0,t];for(let i=1;i<this.rows;i++)this.get(i,t)>e&&(e=this.get(i,t),n[0]=i);return n}minColumn(t){if(w(this,t),this.isEmpty())return NaN;let e=this.get(0,t);for(let n=1;n<this.rows;n++)this.get(n,t)<e&&(e=this.get(n,t));return e}minColumnIndex(t){w(this,t),E(this);let e=this.get(0,t),n=[0,t];for(let i=1;i<this.rows;i++)this.get(i,t)<e&&(e=this.get(i,t),n[0]=i);return n}diag(){let t=Math.min(this.rows,this.columns),e=[];for(let n=0;n<t;n++)e.push(this.get(n,n));return e}norm(t="frobenius"){let e=0;if("max"===t)return this.max();if("frobenius"===t){for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)e+=this.get(t,n)*this.get(t,n);return Math.sqrt(e)}throw new RangeError(`unknown norm type: ${t}`)}cumulativeSum(){let t=0;for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)t+=this.get(e,n),this.set(e,n,t);return this}dot(t){A.isMatrix(t)&&(t=t.to1DArray());let e=this.to1DArray();if(e.length!==t.length)throw new RangeError("vectors do not have the same size");let n=0;for(let i=0;i<e.length;i++)n+=e[i]*t[i];return n}mmul(t){t=P.checkMatrix(t);let e=this.rows,n=this.columns,i=t.columns,o=new P(e,i),s=new Float64Array(n);for(let r=0;r<i;r++){for(let e=0;e<n;e++)s[e]=t.get(e,r);for(let t=0;t<e;t++){let e=0;for(let i=0;i<n;i++)e+=this.get(t,i)*s[i];o.set(t,r,e)}}return o}strassen2x2(t){t=P.checkMatrix(t);let e=new P(2,2);const n=this.get(0,0),i=t.get(0,0),o=this.get(0,1),s=t.get(0,1),r=this.get(1,0),a=t.get(1,0),l=this.get(1,1),h=t.get(1,1),u=(n+l)*(i+h),c=(r+l)*i,d=n*(s-h),f=l*(a-i),m=(n+o)*h,p=u+f-m+(o-l)*(a+h),g=d+m,v=c+f,y=u-c+d+(r-n)*(i+s);return e.set(0,0,p),e.set(0,1,g),e.set(1,0,v),e.set(1,1,y),e}strassen3x3(t){t=P.checkMatrix(t);let e=new P(3,3);const n=this.get(0,0),i=this.get(0,1),o=this.get(0,2),s=this.get(1,0),r=this.get(1,1),a=this.get(1,2),l=this.get(2,0),h=this.get(2,1),u=this.get(2,2),c=t.get(0,0),d=t.get(0,1),f=t.get(0,2),m=t.get(1,0),p=t.get(1,1),g=t.get(1,2),v=t.get(2,0),y=t.get(2,1),w=t.get(2,2),b=(n-s)*(-d+p),C=(-n+s+r)*(c-d+p),S=(s+r)*(-c+d),T=n*c,M=(-n+l+h)*(c-f+g),E=(-n+l)*(f-g),A=(l+h)*(-c+f),R=(-o+h+u)*(p+v-y),N=(o-u)*(p-y),x=o*v,L=(h+u)*(-v+y),G=(-o+r+a)*(g+v-w),_=(o-a)*(g-w),I=(r+a)*(-v+w),W=T+x+i*m,F=(n+i+o-s-r-h-u)*p+C+S+T+R+x+L,k=T+M+A+(n+i+o-r-a-l-h)*g+x+G+I,D=b+r*(-c+d+m-p-g-v+w)+C+T+x+G+_,V=b+C+S+T+a*y,H=x+G+_+I+s*f,O=T+M+E+h*(-c+f+m-p-g-v+y)+R+N+x,Y=R+N+x+L+l*d,U=T+M+E+A+u*w;return e.set(0,0,W),e.set(0,1,F),e.set(0,2,k),e.set(1,0,D),e.set(1,1,V),e.set(1,2,H),e.set(2,0,O),e.set(2,1,Y),e.set(2,2,U),e}mmulStrassen(t){t=P.checkMatrix(t);let e=this.clone(),n=e.rows,i=e.columns,o=t.rows,s=t.columns;function r(t,e,n){let i=t.rows,o=t.columns;if(i===e&&o===n)return t;{let i=A.zeros(e,n);return i=i.setSubMatrix(t,0,0),i}}i!==o&&console.warn(`Multiplying ${n} x ${i} and ${o} x ${s} matrix: dimensions do not match.`);let a=Math.max(n,o),l=Math.max(i,s);return e=r(e,a,l),function t(e,n,i,o){if(i<=512||o<=512)return e.mmul(n);i%2==1&&o%2==1?(e=r(e,i+1,o+1),n=r(n,i+1,o+1)):i%2==1?(e=r(e,i+1,o),n=r(n,i+1,o)):o%2==1&&(e=r(e,i,o+1),n=r(n,i,o+1));let s=parseInt(e.rows/2,10),a=parseInt(e.columns/2,10),l=e.subMatrix(0,s-1,0,a-1),h=n.subMatrix(0,s-1,0,a-1),u=e.subMatrix(0,s-1,a,e.columns-1),c=n.subMatrix(0,s-1,a,n.columns-1),d=e.subMatrix(s,e.rows-1,0,a-1),f=n.subMatrix(s,n.rows-1,0,a-1),m=e.subMatrix(s,e.rows-1,a,e.columns-1),p=n.subMatrix(s,n.rows-1,a,n.columns-1),g=t(A.add(l,m),A.add(h,p),s,a),v=t(A.add(d,m),h,s,a),y=t(l,A.sub(c,p),s,a),w=t(m,A.sub(f,h),s,a),b=t(A.add(l,u),p,s,a),C=t(A.sub(d,l),A.add(h,c),s,a),S=t(A.sub(u,m),A.add(f,p),s,a),T=A.add(g,w);T.sub(b),T.add(S);let M=A.add(y,b),E=A.add(v,w),R=A.sub(g,v);R.add(y),R.add(C);let P=A.zeros(2*T.rows,2*T.columns);return P=P.setSubMatrix(T,0,0),P=P.setSubMatrix(M,T.rows,0),P=P.setSubMatrix(E,0,T.columns),P=P.setSubMatrix(R,T.rows,T.columns),P.subMatrix(0,i-1,0,o-1)}(e,t=r(t,a,l),a,l)}scaleRows(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{min:e=0,max:n=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(n))throw new TypeError("max must be a number");if(e>=n)throw new RangeError("min must be smaller than max");let i=new P(this.rows,this.columns);for(let t=0;t<this.rows;t++){const o=this.getRow(t);o.length>0&&d(o,{min:e,max:n,output:o}),i.setRow(t,o)}return i}scaleColumns(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{min:e=0,max:n=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(n))throw new TypeError("max must be a number");if(e>=n)throw new RangeError("min must be smaller than max");let i=new P(this.rows,this.columns);for(let t=0;t<this.columns;t++){const o=this.getColumn(t);o.length&&d(o,{min:e,max:n,output:o}),i.setColumn(t,o)}return i}flipRows(){const t=Math.ceil(this.columns/2);for(let e=0;e<this.rows;e++)for(let n=0;n<t;n++){let t=this.get(e,n),i=this.get(e,this.columns-1-n);this.set(e,n,i),this.set(e,this.columns-1-n,t)}return this}flipColumns(){const t=Math.ceil(this.rows/2);for(let e=0;e<this.columns;e++)for(let n=0;n<t;n++){let t=this.get(n,e),i=this.get(this.rows-1-n,e);this.set(n,e,i),this.set(this.rows-1-n,e,t)}return this}kroneckerProduct(t){t=P.checkMatrix(t);let e=this.rows,n=this.columns,i=t.rows,o=t.columns,s=new P(e*i,n*o);for(let r=0;r<e;r++)for(let e=0;e<n;e++)for(let n=0;n<i;n++)for(let a=0;a<o;a++)s.set(i*r+n,o*e+a,this.get(r,e)*t.get(n,a));return s}kroneckerSum(t){if(t=P.checkMatrix(t),!this.isSquare()||!t.isSquare())throw new Error("Kronecker Sum needs two Square Matrices");let e=this.rows,n=t.rows,i=this.kroneckerProduct(P.eye(n,n)),o=P.eye(e,e).kroneckerProduct(t);return i.add(o)}transpose(){let t=new P(this.columns,this.rows);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)t.set(n,e,this.get(e,n));return t}sortRows(t=R){for(let e=0;e<this.rows;e++)this.setRow(e,this.getRow(e).sort(t));return this}sortColumns(t=R){for(let e=0;e<this.columns;e++)this.setColumn(e,this.getColumn(e).sort(t));return this}subMatrix(t,e,n,i){S(this,t,e,n,i);let o=new P(e-t+1,i-n+1);for(let s=t;s<=e;s++)for(let e=n;e<=i;e++)o.set(s-t,e-n,this.get(s,e));return o}subMatrixRow(t,e,n){if(void 0===e&&(e=0),void 0===n&&(n=this.columns-1),e>n||e<0||e>=this.columns||n<0||n>=this.columns)throw new RangeError("Argument out of range");let i=new P(t.length,n-e+1);for(let o=0;o<t.length;o++)for(let s=e;s<=n;s++){if(t[o]<0||t[o]>=this.rows)throw new RangeError(`Row index out of range: ${t[o]}`);i.set(o,s-e,this.get(t[o],s))}return i}subMatrixColumn(t,e,n){if(void 0===e&&(e=0),void 0===n&&(n=this.rows-1),e>n||e<0||e>=this.rows||n<0||n>=this.rows)throw new RangeError("Argument out of range");let i=new P(n-e+1,t.length);for(let o=0;o<t.length;o++)for(let s=e;s<=n;s++){if(t[o]<0||t[o]>=this.columns)throw new RangeError(`Column index out of range: ${t[o]}`);i.set(s-e,o,this.get(s,t[o]))}return i}setSubMatrix(t,e,n){if((t=P.checkMatrix(t)).isEmpty())return this;S(this,e,e+t.rows-1,n,n+t.columns-1);for(let i=0;i<t.rows;i++)for(let o=0;o<t.columns;o++)this.set(e+i,n+o,t.get(i,o));return this}selection(t,e){!function(t,e){if(!a(e))throw new TypeError("row indices must be an array");for(let n=0;n<e.length;n++)if(e[n]<0||e[n]>=t.rows)throw new RangeError("row indices are out of range")}(this,t),function(t,e){if(!a(e))throw new TypeError("column indices must be an array");for(let n=0;n<e.length;n++)if(e[n]<0||e[n]>=t.columns)throw new RangeError("column indices are out of range")}(this,e);let n=new P(t.length,e.length);for(let i=0;i<t.length;i++){let o=t[i];for(let t=0;t<e.length;t++){let s=e[t];n.set(i,t,this.get(o,s))}}return n}trace(){let t=Math.min(this.rows,this.columns),e=0;for(let n=0;n<t;n++)e+=this.get(n,n);return e}clone(){let t=new P(this.rows,this.columns);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)t.set(e,n,this.get(e,n));return t}sum(t){switch(t){case"row":return function(t){let e=T(t.rows);for(let n=0;n<t.rows;++n)for(let i=0;i<t.columns;++i)e[n]+=t.get(n,i);return e}(this);case"column":return function(t){let e=T(t.columns);for(let n=0;n<t.rows;++n)for(let i=0;i<t.columns;++i)e[i]+=t.get(n,i);return e}(this);case void 0:return function(t){let e=0;for(let n=0;n<t.rows;n++)for(let i=0;i<t.columns;i++)e+=t.get(n,i);return e}(this);default:throw new Error(`invalid option: ${t}`)}}product(t){switch(t){case"row":return function(t){let e=T(t.rows,1);for(let n=0;n<t.rows;++n)for(let i=0;i<t.columns;++i)e[n]*=t.get(n,i);return e}(this);case"column":return function(t){let e=T(t.columns,1);for(let n=0;n<t.rows;++n)for(let i=0;i<t.columns;++i)e[i]*=t.get(n,i);return e}(this);case void 0:return function(t){let e=1;for(let n=0;n<t.rows;n++)for(let i=0;i<t.columns;i++)e*=t.get(n,i);return e}(this);default:throw new Error(`invalid option: ${t}`)}}mean(t){const e=this.sum(t);switch(t){case"row":for(let t=0;t<this.rows;t++)e[t]/=this.columns;return e;case"column":for(let t=0;t<this.columns;t++)e[t]/=this.rows;return e;case void 0:return e/this.size;default:throw new Error(`invalid option: ${t}`)}}variance(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");const{unbiased:n=!0,mean:i=this.mean(t)}=e;if("boolean"!=typeof n)throw new TypeError("unbiased must be a boolean");switch(t){case"row":if(!a(i))throw new TypeError("mean must be an array");return function(t,e,n){const i=t.rows,o=t.columns,s=[];for(let r=0;r<i;r++){let i=0,a=0,l=0;for(let e=0;e<o;e++)l=t.get(r,e)-n[r],i+=l,a+=l*l;e?s.push((a-i*i/o)/(o-1)):s.push((a-i*i/o)/o)}return s}(this,n,i);case"column":if(!a(i))throw new TypeError("mean must be an array");return function(t,e,n){const i=t.rows,o=t.columns,s=[];for(let r=0;r<o;r++){let o=0,a=0,l=0;for(let e=0;e<i;e++)l=t.get(e,r)-n[r],o+=l,a+=l*l;e?s.push((a-o*o/i)/(i-1)):s.push((a-o*o/i)/i)}return s}(this,n,i);case void 0:if("number"!=typeof i)throw new TypeError("mean must be a number");return function(t,e,n){const i=t.rows,o=t.columns,s=i*o;let r=0,a=0,l=0;for(let e=0;e<i;e++)for(let i=0;i<o;i++)l=t.get(e,i)-n,r+=l,a+=l*l;return e?(a-r*r/s)/(s-1):(a-r*r/s)/s}(this,n,i);default:throw new Error(`invalid option: ${t}`)}}standardDeviation(t,e){"object"==typeof t&&(e=t,t=void 0);const n=this.variance(t,e);if(void 0===t)return Math.sqrt(n);for(let t=0;t<n.length;t++)n[t]=Math.sqrt(n[t]);return n}center(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");const{center:n=this.mean(t)}=e;switch(t){case"row":if(!a(n))throw new TypeError("center must be an array");return function(t,e){for(let n=0;n<t.rows;n++)for(let i=0;i<t.columns;i++)t.set(n,i,t.get(n,i)-e[n])}(this,n),this;case"column":if(!a(n))throw new TypeError("center must be an array");return function(t,e){for(let n=0;n<t.rows;n++)for(let i=0;i<t.columns;i++)t.set(n,i,t.get(n,i)-e[i])}(this,n),this;case void 0:if("number"!=typeof n)throw new TypeError("center must be a number");return function(t,e){for(let n=0;n<t.rows;n++)for(let i=0;i<t.columns;i++)t.set(n,i,t.get(n,i)-e)}(this,n),this;default:throw new Error(`invalid option: ${t}`)}}scale(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");let n=e.scale;switch(t){case"row":if(void 0===n)n=function(t){const e=[];for(let n=0;n<t.rows;n++){let i=0;for(let e=0;e<t.columns;e++)i+=Math.pow(t.get(n,e),2)/(t.columns-1);e.push(Math.sqrt(i))}return e}(this);else if(!a(n))throw new TypeError("scale must be an array");return function(t,e){for(let n=0;n<t.rows;n++)for(let i=0;i<t.columns;i++)t.set(n,i,t.get(n,i)/e[n])}(this,n),this;case"column":if(void 0===n)n=function(t){const e=[];for(let n=0;n<t.columns;n++){let i=0;for(let e=0;e<t.rows;e++)i+=Math.pow(t.get(e,n),2)/(t.rows-1);e.push(Math.sqrt(i))}return e}(this);else if(!a(n))throw new TypeError("scale must be an array");return function(t,e){for(let n=0;n<t.rows;n++)for(let i=0;i<t.columns;i++)t.set(n,i,t.get(n,i)/e[i])}(this,n),this;case void 0:if(void 0===n)n=function(t){const e=t.size-1;let n=0;for(let i=0;i<t.columns;i++)for(let o=0;o<t.rows;o++)n+=Math.pow(t.get(o,i),2)/e;return Math.sqrt(n)}(this);else if("number"!=typeof n)throw new TypeError("scale must be a number");return function(t,e){for(let n=0;n<t.rows;n++)for(let i=0;i<t.columns;i++)t.set(n,i,t.get(n,i)/e)}(this,n),this;default:throw new Error(`invalid option: ${t}`)}}toString(t){return p(this,t)}}function R(t,e){return t-e}A.prototype.klass="Matrix","undefined"!=typeof Symbol&&(A.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return p(this)}),A.random=A.rand,A.randomInt=A.randInt,A.diagonal=A.diag,A.prototype.diagonal=A.prototype.diag,A.identity=A.eye,A.prototype.negate=A.prototype.neg,A.prototype.tensorProduct=A.prototype.kroneckerProduct;class P extends A{constructor(t,e){if(super(),P.isMatrix(t))return t.clone();if(Number.isInteger(t)&&t>=0){if(this.data=[],!(Number.isInteger(e)&&e>=0))throw new TypeError("nColumns must be a positive integer");for(let n=0;n<t;n++)this.data.push(new Float64Array(e))}else{if(!a(t))throw new TypeError("First argument must be a positive number or an array");{const n=t;if("number"!=typeof(e=(t=n.length)?n[0].length:0))throw new TypeError("Data must be a 2D array with at least one element");this.data=[];for(let i=0;i<t;i++){if(n[i].length!==e)throw new RangeError("Inconsistent array dimensions");if(!n[i].every((t=>"number"==typeof t)))throw new TypeError("Input data contains non-numeric values");this.data.push(Float64Array.from(n[i]))}}}this.rows=t,this.columns=e}set(t,e,n){return this.data[t][e]=n,this}get(t,e){return this.data[t][e]}removeRow(t){return y(this,t),this.data.splice(t,1),this.rows-=1,this}addRow(t,e){return void 0===e&&(e=t,t=this.rows),y(this,t,!0),e=Float64Array.from(b(this,e)),this.data.splice(t,0,e),this.rows+=1,this}removeColumn(t){w(this,t);for(let e=0;e<this.rows;e++){const n=new Float64Array(this.columns-1);for(let i=0;i<t;i++)n[i]=this.data[e][i];for(let i=t+1;i<this.columns;i++)n[i-1]=this.data[e][i];this.data[e]=n}return this.columns-=1,this}addColumn(t,e){void 0===e&&(e=t,t=this.columns),w(this,t,!0),e=C(this,e);for(let n=0;n<this.rows;n++){const i=new Float64Array(this.columns+1);let o=0;for(;o<t;o++)i[o]=this.data[n][o];for(i[o++]=e[n];o<this.columns+1;o++)i[o]=this.data[n][o-1];this.data[n]=i}return this.columns+=1,this}}!function(t,e){t.prototype.add=function(t){return"number"==typeof t?this.addS(t):this.addM(t)},t.prototype.addS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)+t);return this},t.prototype.addM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)+t.get(e,n));return this},t.add=function(t,n){return new e(t).add(n)},t.prototype.sub=function(t){return"number"==typeof t?this.subS(t):this.subM(t)},t.prototype.subS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)-t);return this},t.prototype.subM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)-t.get(e,n));return this},t.sub=function(t,n){return new e(t).sub(n)},t.prototype.subtract=t.prototype.sub,t.prototype.subtractS=t.prototype.subS,t.prototype.subtractM=t.prototype.subM,t.subtract=t.sub,t.prototype.mul=function(t){return"number"==typeof t?this.mulS(t):this.mulM(t)},t.prototype.mulS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)*t);return this},t.prototype.mulM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)*t.get(e,n));return this},t.mul=function(t,n){return new e(t).mul(n)},t.prototype.multiply=t.prototype.mul,t.prototype.multiplyS=t.prototype.mulS,t.prototype.multiplyM=t.prototype.mulM,t.multiply=t.mul,t.prototype.div=function(t){return"number"==typeof t?this.divS(t):this.divM(t)},t.prototype.divS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)/t);return this},t.prototype.divM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)/t.get(e,n));return this},t.div=function(t,n){return new e(t).div(n)},t.prototype.divide=t.prototype.div,t.prototype.divideS=t.prototype.divS,t.prototype.divideM=t.prototype.divM,t.divide=t.div,t.prototype.mod=function(t){return"number"==typeof t?this.modS(t):this.modM(t)},t.prototype.modS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)%t);return this},t.prototype.modM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)%t.get(e,n));return this},t.mod=function(t,n){return new e(t).mod(n)},t.prototype.modulus=t.prototype.mod,t.prototype.modulusS=t.prototype.modS,t.prototype.modulusM=t.prototype.modM,t.modulus=t.mod,t.prototype.and=function(t){return"number"==typeof t?this.andS(t):this.andM(t)},t.prototype.andS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)&t);return this},t.prototype.andM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)&t.get(e,n));return this},t.and=function(t,n){return new e(t).and(n)},t.prototype.or=function(t){return"number"==typeof t?this.orS(t):this.orM(t)},t.prototype.orS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)|t);return this},t.prototype.orM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)|t.get(e,n));return this},t.or=function(t,n){return new e(t).or(n)},t.prototype.xor=function(t){return"number"==typeof t?this.xorS(t):this.xorM(t)},t.prototype.xorS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)^t);return this},t.prototype.xorM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)^t.get(e,n));return this},t.xor=function(t,n){return new e(t).xor(n)},t.prototype.leftShift=function(t){return"number"==typeof t?this.leftShiftS(t):this.leftShiftM(t)},t.prototype.leftShiftS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)<<t);return this},t.prototype.leftShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)<<t.get(e,n));return this},t.leftShift=function(t,n){return new e(t).leftShift(n)},t.prototype.signPropagatingRightShift=function(t){return"number"==typeof t?this.signPropagatingRightShiftS(t):this.signPropagatingRightShiftM(t)},t.prototype.signPropagatingRightShiftS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)>>t);return this},t.prototype.signPropagatingRightShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)>>t.get(e,n));return this},t.signPropagatingRightShift=function(t,n){return new e(t).signPropagatingRightShift(n)},t.prototype.rightShift=function(t){return"number"==typeof t?this.rightShiftS(t):this.rightShiftM(t)},t.prototype.rightShiftS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)>>>t);return this},t.prototype.rightShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)>>>t.get(e,n));return this},t.rightShift=function(t,n){return new e(t).rightShift(n)},t.prototype.zeroFillRightShift=t.prototype.rightShift,t.prototype.zeroFillRightShiftS=t.prototype.rightShiftS,t.prototype.zeroFillRightShiftM=t.prototype.rightShiftM,t.zeroFillRightShift=t.rightShift,t.prototype.not=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,~this.get(t,e));return this},t.not=function(t){return new e(t).not()},t.prototype.abs=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.abs(this.get(t,e)));return this},t.abs=function(t){return new e(t).abs()},t.prototype.acos=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.acos(this.get(t,e)));return this},t.acos=function(t){return new e(t).acos()},t.prototype.acosh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.acosh(this.get(t,e)));return this},t.acosh=function(t){return new e(t).acosh()},t.prototype.asin=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.asin(this.get(t,e)));return this},t.asin=function(t){return new e(t).asin()},t.prototype.asinh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.asinh(this.get(t,e)));return this},t.asinh=function(t){return new e(t).asinh()},t.prototype.atan=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.atan(this.get(t,e)));return this},t.atan=function(t){return new e(t).atan()},t.prototype.atanh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.atanh(this.get(t,e)));return this},t.atanh=function(t){return new e(t).atanh()},t.prototype.cbrt=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.cbrt(this.get(t,e)));return this},t.cbrt=function(t){return new e(t).cbrt()},t.prototype.ceil=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.ceil(this.get(t,e)));return this},t.ceil=function(t){return new e(t).ceil()},t.prototype.clz32=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.clz32(this.get(t,e)));return this},t.clz32=function(t){return new e(t).clz32()},t.prototype.cos=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.cos(this.get(t,e)));return this},t.cos=function(t){return new e(t).cos()},t.prototype.cosh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.cosh(this.get(t,e)));return this},t.cosh=function(t){return new e(t).cosh()},t.prototype.exp=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.exp(this.get(t,e)));return this},t.exp=function(t){return new e(t).exp()},t.prototype.expm1=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.expm1(this.get(t,e)));return this},t.expm1=function(t){return new e(t).expm1()},t.prototype.floor=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.floor(this.get(t,e)));return this},t.floor=function(t){return new e(t).floor()},t.prototype.fround=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.fround(this.get(t,e)));return this},t.fround=function(t){return new e(t).fround()},t.prototype.log=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log(this.get(t,e)));return this},t.log=function(t){return new e(t).log()},t.prototype.log1p=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log1p(this.get(t,e)));return this},t.log1p=function(t){return new e(t).log1p()},t.prototype.log10=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log10(this.get(t,e)));return this},t.log10=function(t){return new e(t).log10()},t.prototype.log2=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log2(this.get(t,e)));return this},t.log2=function(t){return new e(t).log2()},t.prototype.round=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.round(this.get(t,e)));return this},t.round=function(t){return new e(t).round()},t.prototype.sign=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sign(this.get(t,e)));return this},t.sign=function(t){return new e(t).sign()},t.prototype.sin=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sin(this.get(t,e)));return this},t.sin=function(t){return new e(t).sin()},t.prototype.sinh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sinh(this.get(t,e)));return this},t.sinh=function(t){return new e(t).sinh()},t.prototype.sqrt=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sqrt(this.get(t,e)));return this},t.sqrt=function(t){return new e(t).sqrt()},t.prototype.tan=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.tan(this.get(t,e)));return this},t.tan=function(t){return new e(t).tan()},t.prototype.tanh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.tanh(this.get(t,e)));return this},t.tanh=function(t){return new e(t).tanh()},t.prototype.trunc=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.trunc(this.get(t,e)));return this},t.trunc=function(t){return new e(t).trunc()},t.pow=function(t,n){return new e(t).pow(n)},t.prototype.pow=function(t){return"number"==typeof t?this.powS(t):this.powM(t)},t.prototype.powS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,Math.pow(this.get(e,n),t));return this},t.prototype.powM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,Math.pow(this.get(e,n),t.get(e,n)));return this}}(A,P);class N extends A{constructor(t){super(),this.data=t,this.rows=t.length,this.columns=t[0].length}set(t,e,n){return this.data[t][e]=n,this}get(t,e){return this.data[t][e]}}class x{constructor(t){let e,n,i,o,s,r,a,l,h,u=(t=N.checkMatrix(t)).clone(),c=u.rows,d=u.columns,f=new Float64Array(c),m=1;for(e=0;e<c;e++)f[e]=e;for(l=new Float64Array(c),n=0;n<d;n++){for(e=0;e<c;e++)l[e]=u.get(e,n);for(e=0;e<c;e++){for(h=Math.min(e,n),s=0,i=0;i<h;i++)s+=u.get(e,i)*l[i];l[e]-=s,u.set(e,n,l[e])}for(o=n,e=n+1;e<c;e++)Math.abs(l[e])>Math.abs(l[o])&&(o=e);if(o!==n){for(i=0;i<d;i++)r=u.get(o,i),u.set(o,i,u.get(n,i)),u.set(n,i,r);a=f[o],f[o]=f[n],f[n]=a,m=-m}if(n<c&&0!==u.get(n,n))for(e=n+1;e<c;e++)u.set(e,n,u.get(e,n)/u.get(n,n))}this.LU=u,this.pivotVector=f,this.pivotSign=m}isSingular(){let t=this.LU,e=t.columns;for(let n=0;n<e;n++)if(0===t.get(n,n))return!0;return!1}solve(t){t=P.checkMatrix(t);let e=this.LU;if(e.rows!==t.rows)throw new Error("Invalid matrix dimensions");if(this.isSingular())throw new Error("LU matrix is singular");let n,i,o,s=t.columns,r=t.subMatrixRow(this.pivotVector,0,s-1),a=e.columns;for(o=0;o<a;o++)for(n=o+1;n<a;n++)for(i=0;i<s;i++)r.set(n,i,r.get(n,i)-r.get(o,i)*e.get(n,o));for(o=a-1;o>=0;o--){for(i=0;i<s;i++)r.set(o,i,r.get(o,i)/e.get(o,o));for(n=0;n<o;n++)for(i=0;i<s;i++)r.set(n,i,r.get(n,i)-r.get(o,i)*e.get(n,o))}return r}get determinant(){let t=this.LU;if(!t.isSquare())throw new Error("Matrix must be square");let e=this.pivotSign,n=t.columns;for(let i=0;i<n;i++)e*=t.get(i,i);return e}get lowerTriangularMatrix(){let t=this.LU,e=t.rows,n=t.columns,i=new P(e,n);for(let o=0;o<e;o++)for(let e=0;e<n;e++)o>e?i.set(o,e,t.get(o,e)):o===e?i.set(o,e,1):i.set(o,e,0);return i}get upperTriangularMatrix(){let t=this.LU,e=t.rows,n=t.columns,i=new P(e,n);for(let o=0;o<e;o++)for(let e=0;e<n;e++)o<=e?i.set(o,e,t.get(o,e)):i.set(o,e,0);return i}get pivotPermutationVector(){return Array.from(this.pivotVector)}}function L(t,e){let n=0;return Math.abs(t)>Math.abs(e)?(n=e/t,Math.abs(t)*Math.sqrt(1+n*n)):0!==e?(n=t/e,Math.abs(e)*Math.sqrt(1+n*n)):0}class G{constructor(t){let e,n,i,o,s=(t=N.checkMatrix(t)).clone(),r=t.rows,a=t.columns,l=new Float64Array(a);for(i=0;i<a;i++){let t=0;for(e=i;e<r;e++)t=L(t,s.get(e,i));if(0!==t){for(s.get(i,i)<0&&(t=-t),e=i;e<r;e++)s.set(e,i,s.get(e,i)/t);for(s.set(i,i,s.get(i,i)+1),n=i+1;n<a;n++){for(o=0,e=i;e<r;e++)o+=s.get(e,i)*s.get(e,n);for(o=-o/s.get(i,i),e=i;e<r;e++)s.set(e,n,s.get(e,n)+o*s.get(e,i))}}l[i]=-t}this.QR=s,this.Rdiag=l}solve(t){t=P.checkMatrix(t);let e=this.QR,n=e.rows;if(t.rows!==n)throw new Error("Matrix row dimensions must agree");if(!this.isFullRank())throw new Error("Matrix is rank deficient");let i,o,s,r,a=t.columns,l=t.clone(),h=e.columns;for(s=0;s<h;s++)for(o=0;o<a;o++){for(r=0,i=s;i<n;i++)r+=e.get(i,s)*l.get(i,o);for(r=-r/e.get(s,s),i=s;i<n;i++)l.set(i,o,l.get(i,o)+r*e.get(i,s))}for(s=h-1;s>=0;s--){for(o=0;o<a;o++)l.set(s,o,l.get(s,o)/this.Rdiag[s]);for(i=0;i<s;i++)for(o=0;o<a;o++)l.set(i,o,l.get(i,o)-l.get(s,o)*e.get(i,s))}return l.subMatrix(0,h-1,0,a-1)}isFullRank(){let t=this.QR.columns;for(let e=0;e<t;e++)if(0===this.Rdiag[e])return!1;return!0}get upperTriangularMatrix(){let t,e,n=this.QR,i=n.columns,o=new P(i,i);for(t=0;t<i;t++)for(e=0;e<i;e++)t<e?o.set(t,e,n.get(t,e)):t===e?o.set(t,e,this.Rdiag[t]):o.set(t,e,0);return o}get orthogonalMatrix(){let t,e,n,i,o=this.QR,s=o.rows,r=o.columns,a=new P(s,r);for(n=r-1;n>=0;n--){for(t=0;t<s;t++)a.set(t,n,0);for(a.set(n,n,1),e=n;e<r;e++)if(0!==o.get(n,n)){for(i=0,t=n;t<s;t++)i+=o.get(t,n)*a.get(t,e);for(i=-i/o.get(n,n),t=n;t<s;t++)a.set(t,e,a.get(t,e)+i*o.get(t,n))}}return a}}class _{constructor(t,e={}){if((t=N.checkMatrix(t)).isEmpty())throw new Error("Matrix must be non-empty");let n=t.rows,i=t.columns;const{computeLeftSingularVectors:o=!0,computeRightSingularVectors:s=!0,autoTranspose:r=!1}=e;let a,l=Boolean(o),h=Boolean(s),u=!1;if(n<i)if(r){a=t.transpose(),n=a.rows,i=a.columns,u=!0;let e=l;l=h,h=e}else a=t.clone(),console.warn("Computing SVD on a matrix with more columns than rows. Consider enabling autoTranspose");else a=t.clone();let c=Math.min(n,i),d=Math.min(n+1,i),f=new Float64Array(d),m=new P(n,c),p=new P(i,i),g=new Float64Array(i),v=new Float64Array(n),y=new Float64Array(d);for(let t=0;t<d;t++)y[t]=t;let w=Math.min(n-1,i),b=Math.max(0,Math.min(i-2,n)),C=Math.max(w,b);for(let t=0;t<C;t++){if(t<w){f[t]=0;for(let e=t;e<n;e++)f[t]=L(f[t],a.get(e,t));if(0!==f[t]){a.get(t,t)<0&&(f[t]=-f[t]);for(let e=t;e<n;e++)a.set(e,t,a.get(e,t)/f[t]);a.set(t,t,a.get(t,t)+1)}f[t]=-f[t]}for(let e=t+1;e<i;e++){if(t<w&&0!==f[t]){let i=0;for(let o=t;o<n;o++)i+=a.get(o,t)*a.get(o,e);i=-i/a.get(t,t);for(let o=t;o<n;o++)a.set(o,e,a.get(o,e)+i*a.get(o,t))}g[e]=a.get(t,e)}if(l&&t<w)for(let e=t;e<n;e++)m.set(e,t,a.get(e,t));if(t<b){g[t]=0;for(let e=t+1;e<i;e++)g[t]=L(g[t],g[e]);if(0!==g[t]){g[t+1]<0&&(g[t]=0-g[t]);for(let e=t+1;e<i;e++)g[e]/=g[t];g[t+1]+=1}if(g[t]=-g[t],t+1<n&&0!==g[t]){for(let e=t+1;e<n;e++)v[e]=0;for(let e=t+1;e<n;e++)for(let n=t+1;n<i;n++)v[e]+=g[n]*a.get(e,n);for(let e=t+1;e<i;e++){let i=-g[e]/g[t+1];for(let o=t+1;o<n;o++)a.set(o,e,a.get(o,e)+i*v[o])}}if(h)for(let e=t+1;e<i;e++)p.set(e,t,g[e])}}let S=Math.min(i,n+1);if(w<i&&(f[w]=a.get(w,w)),n<S&&(f[S-1]=0),b+1<S&&(g[b]=a.get(b,S-1)),g[S-1]=0,l){for(let t=w;t<c;t++){for(let e=0;e<n;e++)m.set(e,t,0);m.set(t,t,1)}for(let t=w-1;t>=0;t--)if(0!==f[t]){for(let e=t+1;e<c;e++){let i=0;for(let o=t;o<n;o++)i+=m.get(o,t)*m.get(o,e);i=-i/m.get(t,t);for(let o=t;o<n;o++)m.set(o,e,m.get(o,e)+i*m.get(o,t))}for(let e=t;e<n;e++)m.set(e,t,-m.get(e,t));m.set(t,t,1+m.get(t,t));for(let e=0;e<t-1;e++)m.set(e,t,0)}else{for(let e=0;e<n;e++)m.set(e,t,0);m.set(t,t,1)}}if(h)for(let t=i-1;t>=0;t--){if(t<b&&0!==g[t])for(let e=t+1;e<i;e++){let n=0;for(let o=t+1;o<i;o++)n+=p.get(o,t)*p.get(o,e);n=-n/p.get(t+1,t);for(let o=t+1;o<i;o++)p.set(o,e,p.get(o,e)+n*p.get(o,t))}for(let e=0;e<i;e++)p.set(e,t,0);p.set(t,t,1)}let T=S-1,M=0,E=Number.EPSILON;for(;S>0;){let t,e;for(t=S-2;t>=-1&&-1!==t;t--){const e=Number.MIN_VALUE+E*Math.abs(f[t]+Math.abs(f[t+1]));if(Math.abs(g[t])<=e||Number.isNaN(g[t])){g[t]=0;break}}if(t===S-2)e=4;else{let n;for(n=S-1;n>=t&&n!==t;n--){let e=(n!==S?Math.abs(g[n]):0)+(n!==t+1?Math.abs(g[n-1]):0);if(Math.abs(f[n])<=E*e){f[n]=0;break}}n===t?e=3:n===S-1?e=1:(e=2,t=n)}switch(t++,e){case 1:{let e=g[S-2];g[S-2]=0;for(let n=S-2;n>=t;n--){let o=L(f[n],e),s=f[n]/o,r=e/o;if(f[n]=o,n!==t&&(e=-r*g[n-1],g[n-1]=s*g[n-1]),h)for(let t=0;t<i;t++)o=s*p.get(t,n)+r*p.get(t,S-1),p.set(t,S-1,-r*p.get(t,n)+s*p.get(t,S-1)),p.set(t,n,o)}break}case 2:{let e=g[t-1];g[t-1]=0;for(let i=t;i<S;i++){let o=L(f[i],e),s=f[i]/o,r=e/o;if(f[i]=o,e=-r*g[i],g[i]=s*g[i],l)for(let e=0;e<n;e++)o=s*m.get(e,i)+r*m.get(e,t-1),m.set(e,t-1,-r*m.get(e,i)+s*m.get(e,t-1)),m.set(e,i,o)}break}case 3:{const e=Math.max(Math.abs(f[S-1]),Math.abs(f[S-2]),Math.abs(g[S-2]),Math.abs(f[t]),Math.abs(g[t])),o=f[S-1]/e,s=f[S-2]/e,r=g[S-2]/e,a=f[t]/e,u=g[t]/e,c=((s+o)*(s-o)+r*r)/2,d=o*r*(o*r);let v=0;0===c&&0===d||(v=c<0?0-Math.sqrt(c*c+d):Math.sqrt(c*c+d),v=d/(c+v));let y=(a+o)*(a-o)+v,w=a*u;for(let e=t;e<S-1;e++){let o=L(y,w);0===o&&(o=Number.MIN_VALUE);let s=y/o,r=w/o;if(e!==t&&(g[e-1]=o),y=s*f[e]+r*g[e],g[e]=s*g[e]-r*f[e],w=r*f[e+1],f[e+1]=s*f[e+1],h)for(let t=0;t<i;t++)o=s*p.get(t,e)+r*p.get(t,e+1),p.set(t,e+1,-r*p.get(t,e)+s*p.get(t,e+1)),p.set(t,e,o);if(o=L(y,w),0===o&&(o=Number.MIN_VALUE),s=y/o,r=w/o,f[e]=o,y=s*g[e]+r*f[e+1],f[e+1]=-r*g[e]+s*f[e+1],w=r*g[e+1],g[e+1]=s*g[e+1],l&&e<n-1)for(let t=0;t<n;t++)o=s*m.get(t,e)+r*m.get(t,e+1),m.set(t,e+1,-r*m.get(t,e)+s*m.get(t,e+1)),m.set(t,e,o)}g[S-2]=y,M+=1;break}case 4:if(f[t]<=0&&(f[t]=f[t]<0?-f[t]:0,h))for(let e=0;e<=T;e++)p.set(e,t,-p.get(e,t));for(;t<T&&!(f[t]>=f[t+1]);){let e=f[t];if(f[t]=f[t+1],f[t+1]=e,h&&t<i-1)for(let n=0;n<i;n++)e=p.get(n,t+1),p.set(n,t+1,p.get(n,t)),p.set(n,t,e);if(l&&t<n-1)for(let i=0;i<n;i++)e=m.get(i,t+1),m.set(i,t+1,m.get(i,t)),m.set(i,t,e);t++}M=0,S--}}if(u){let t=p;p=m,m=t}this.m=n,this.n=i,this.s=f,this.U=m,this.V=p}solve(t){let e=t,n=this.threshold,i=this.s.length,o=P.zeros(i,i);for(let t=0;t<i;t++)Math.abs(this.s[t])<=n?o.set(t,t,0):o.set(t,t,1/this.s[t]);let s=this.U,r=this.rightSingularVectors,a=r.mmul(o),l=r.rows,h=s.rows,u=P.zeros(l,h);for(let t=0;t<l;t++)for(let e=0;e<h;e++){let n=0;for(let o=0;o<i;o++)n+=a.get(t,o)*s.get(e,o);u.set(t,e,n)}return u.mmul(e)}solveForDiagonal(t){return this.solve(P.diag(t))}inverse(){let t=this.V,e=this.threshold,n=t.rows,i=t.columns,o=new P(n,this.s.length);for(let s=0;s<n;s++)for(let n=0;n<i;n++)Math.abs(this.s[n])>e&&o.set(s,n,t.get(s,n)/this.s[n]);let s=this.U,r=s.rows,a=s.columns,l=new P(n,r);for(let t=0;t<n;t++)for(let e=0;e<r;e++){let n=0;for(let i=0;i<a;i++)n+=o.get(t,i)*s.get(e,i);l.set(t,e,n)}return l}get condition(){return this.s[0]/this.s[Math.min(this.m,this.n)-1]}get norm2(){return this.s[0]}get rank(){let t=Math.max(this.m,this.n)*this.s[0]*Number.EPSILON,e=0,n=this.s;for(let i=0,o=n.length;i<o;i++)n[i]>t&&e++;return e}get diagonal(){return Array.from(this.s)}get threshold(){return Number.EPSILON/2*Math.max(this.m,this.n)*this.s[0]}get leftSingularVectors(){return this.U}get rightSingularVectors(){return this.V}get diagonalMatrix(){return P.diag(this.s)}}function I(t,e,n,i,o){let s=n*i*i,r=P.eye(e.length,e.length,s);const a=o(e);let l=new Float64Array(t.x.length);for(let e=0;e<t.x.length;e++)l[e]=a(t.x[e]);let h=function(t,e,n,i,o){const s=n.length,r=t.x.length;let a=new Array(s);for(let l=0;l<s;l++){a[l]=new Array(r);let s=n.slice();s[l]+=i;let h=o(s);for(let n=0;n<r;n++)a[l][n]=e[n]-h(t.x[n])}return new P(a)}(t,l,e,i,o),u=function(t,e){const n=t.x.length;let i=new Array(n);for(let o=0;o<n;o++)i[o]=[t.y[o]-e[o]];return new P(i)}(t,l),c=function(t,e=!1){return t=N.checkMatrix(t),e?new _(t).inverse():function(t,e,n=!1){return t=N.checkMatrix(t),e=N.checkMatrix(e),n?new _(t).solve(e):t.isSquare()?new x(t).solve(e):new G(t).solve(e)}(t,P.eye(t.rows))}(r.add(h.mmul(h.transpose())));return(e=(e=new P([e])).sub(c.mmul(h).mmul(u).mul(i).transpose())).to1DArray()}function W(t,e,n={}){let{maxIterations:i=100,gradientDifference:r=.1,damping:a=0,errorTolerance:l=.01,minValues:h,maxValues:u,initialValues:c}=n;if(a<=0)throw new Error("The damping option must be a positive number");if(!t.x||!t.y)throw new Error("The data parameter must have x and y elements");if(!o(t.x)||t.x.length<2||!o(t.y)||t.y.length<2)throw new Error("The data parameter elements must be an array with more than 2 points");if(t.x.length!==t.y.length)throw new Error("The data parameter elements must have the same size");let d=c||new Array(e.length).fill(1),f=d.length;if(u=u||new Array(f).fill(Number.MAX_SAFE_INTEGER),h=h||new Array(f).fill(Number.MIN_SAFE_INTEGER),u.length!==h.length)throw new Error("minValues and maxValues must be the same size");if(!o(d))throw new Error("initialValues must be an array");let m,p=s(t,d,e),g=p<=l;for(m=0;m<i&&!g;m++){d=I(t,d,a,r,e);for(let t=0;t<f;t++)d[t]=Math.min(Math.max(h[t],d[t]),u[t]);if(p=s(t,d,e),isNaN(p))break;g=p<=l}return{parameterValues:d,parameterError:p,iterations:m}}},3379:t=>{"use strict";var e=[];function n(t){for(var n=-1,i=0;i<e.length;i++)if(e[i].identifier===t){n=i;break}return n}function i(t,i){for(var s={},r=[],a=0;a<t.length;a++){var l=t[a],h=i.base?l[0]+i.base:l[0],u=s[h]||0,c="".concat(h," ").concat(u);s[h]=u+1;var d=n(c),f={css:l[1],media:l[2],sourceMap:l[3],supports:l[4],layer:l[5]};if(-1!==d)e[d].references++,e[d].updater(f);else{var m=o(f,i);i.byIndex=a,e.splice(a,0,{identifier:c,updater:m,references:1})}r.push(c)}return r}function o(t,e){var n=e.domAPI(e);return n.update(t),function(e){if(e){if(e.css===t.css&&e.media===t.media&&e.sourceMap===t.sourceMap&&e.supports===t.supports&&e.layer===t.layer)return;n.update(t=e)}else n.remove()}}t.exports=function(t,o){var s=i(t=t||[],o=o||{});return function(t){t=t||[];for(var r=0;r<s.length;r++){var a=n(s[r]);e[a].references--}for(var l=i(t,o),h=0;h<s.length;h++){var u=n(s[h]);0===e[u].references&&(e[u].updater(),e.splice(u,1))}s=l}}},569:t=>{"use strict";var e={};t.exports=function(t,n){var i=function(t){if(void 0===e[t]){var n=document.querySelector(t);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(t){n=null}e[t]=n}return e[t]}(t);if(!i)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");i.appendChild(n)}},9216:t=>{"use strict";t.exports=function(t){var e=document.createElement("style");return t.setAttributes(e,t.attributes),t.insert(e,t.options),e}},3565:(t,e,n)=>{"use strict";t.exports=function(t){var e=n.nc;e&&t.setAttribute("nonce",e)}},7795:t=>{"use strict";t.exports=function(t){if("undefined"==typeof document)return{update:function(){},remove:function(){}};var e=t.insertStyleElement(t);return{update:function(n){!function(t,e,n){var i="";n.supports&&(i+="@supports (".concat(n.supports,") {")),n.media&&(i+="@media ".concat(n.media," {"));var o=void 0!==n.layer;o&&(i+="@layer".concat(n.layer.length>0?" ".concat(n.layer):""," {")),i+=n.css,o&&(i+="}"),n.media&&(i+="}"),n.supports&&(i+="}");var s=n.sourceMap;s&&"undefined"!=typeof btoa&&(i+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(s))))," */")),e.styleTagTransform(i,t,e.options)}(e,t,n)},remove:function(){!function(t){if(null===t.parentNode)return!1;t.parentNode.removeChild(t)}(e)}}}},4589:t=>{"use strict";t.exports=function(t,e){if(e.styleSheet)e.styleSheet.cssText=t;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(t))}}},7241:(t,e,n)=>{"use strict";n.d(e,{D:()=>h});var i=n(4469),o=n(976),s=n(7399),r=n(6714),a=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};const l=31;function h(t,e=!1,n){return a(this,void 0,void 0,(function*(){const a=t.tags.separator,h=t.tags[o.TAGS.UNITS],c=(0,r.vU)(h,a);let d;null!=n||(n=new Map);const f="helm"===h?(0,s.getHelmMonomers)(t):Object.keys((0,r.fy)(t,0,c).freq).filter((t=>""!==t));for(let t=0;t<f.length;t++)n.has(f[t])||n.set(f[t],`${n.size+1}`);if("helm"===h)d=yield i.functions.call("HELM:getMolFiles",{col:t}),d=function(t,e,n=!1){const i=new Array(t.length);for(let o=0;o<t.length;o++){let s=0,r=0,a="\n Datagrok macromolecule handler\n\n 0 0 0 0 0 0 999 V3000\nM V30 BEGIN CTAB\n";const h=t.get(o);s=h.indexOf("\n",s)+1,s=h.indexOf("\n",s)+1,s=h.indexOf("\n",s)+1;const u=parseInt(h.substring(s,s+3)),c=parseInt(h.substring(s+3,s+6));a+=`M V30 COUNTS ${u} ${c} 0 0 0\n`,a+="M V30 BEGIN ATOM\n";for(let t=0;t<u;t++){s=h.indexOf("\n",s)+1+l,r=h.indexOf(" ",s);const i=h.substring(s,r);a+=n?`M V30 ${t+1} R${e.get(i)} 0.000 0.000 0 0\n`:`M V30 ${t+1} At 0.000 0.000 0 0 MASS=${e.get(i)}\n`}a+="M V30 END ATOM\n",a+="M V30 BEGIN BOND\n";for(let t=0;t<c;t++){s=h.indexOf("\n",s)+1;const e=parseInt(h.substring(s,s+3).trim()),n=parseInt(h.substring(s+3,s+6).trim());a+=`M V30 ${t+1} ${parseInt(h.substring(s+6,s+9).trim())} ${e} ${n}\n`}a+="M V30 END BOND\n",a+="M V30 END CTAB\n",a+="M END",i[o]=a}return i}(d,n,e);else{d=new Array(t.length);for(let i=0;i<t.length;i++){const o=u(c(t.get(i)).filter((t=>""!==t)),n,e);d[i]=o}}return o.Column.fromStrings("monomericMols",d)}))}function u(t,e,n=!1){let i="\n Datagrok macromolecule handler\n\n 0 0 0 0 0 0 999 V3000\nM V30 BEGIN CTAB\n";i+=`M V30 COUNTS ${t.length} ${t.length?t.length-1:0} 0 0 0\n`,i+="M V30 BEGIN ATOM\n";for(let o=0;o<t.length;o++)i+=n?`M V30 ${o+1} R${e.get(t[o])} 0.000 0.000 0 0\n`:`M V30 ${o+1} At 0.000 0.000 0 0 MASS=${e.get(t[o])}\n`;i+="M V30 END ATOM\n",i+="M V30 BEGIN BOND\n";for(let e=0;e<t.length-1;e++)i+=`M V30 ${e+1} 1 ${e+1} ${e+2}\n`;return i+="M V30 END BOND\n",i+="M V30 END CTAB\n",i+="M END",i}},7399:(t,e,n)=>{"use strict";n.d(e,{activityCliffs:()=>_t,checkInputColumn:()=>Gt,getHelmMonomers:()=>Dt,importFasta:()=>Ft,multipleSequenceAlignmentAny:()=>Wt,sequenceSpaceTopMenu:()=>It,splitToMonomers:()=>kt});var i=n(4469),o=n(3870),s=n(976),r=n(6714);const a=r.GU;var l;!function(t){t.MSA="MSA",t.classic="classic"}(l||(l={}));const h=(t,e,n,i,o,s,r="rgb(100,100,100)",h=0,u=!1,c=1,d="",f=!1,m=l.classic,p={},g=0,v=null,y=[],w=null)=>{var b,C,S;o.textAlign="start";let T=s.substring(0),M=f?"":d;m===l.MSA&&(M="");let E=!0,A=!0,R="difference";null!=v&&null!=v.cell.column&&(E=null===(b=v.cell.column.temp["color-code"])||void 0===b||b,A=null===(C=v.cell.column.temp["compare-with-current"])||void 0===C||C,R=null!==(S=v.cell.column.temp["highlight-difference"])&&void 0!==S?S:"difference");const P=y[g];A&&y.length>0&&"difference"===R&&(c=T==P?.3:c),A&&y.length>0&&"equal"===R&&(c=T!=P?.3:c),null!=w&&(T=a(T,w));let N=o.measureText(T+M),x=o.measureText(T).width,L=o.measureText(T).width;const G=i/2-(N.fontBoundingBoxAscent+N.fontBoundingBoxDescent)/2+1;function _(n,i){const s=E?r:"rgb(0,0,0)";o.fillStyle=s,o.globalAlpha=c,m===l.classic&&(o.fillText(T,t+n,e+G),o.fillStyle="#808080",o.fillText(M,t+i,e+G)),m===l.MSA&&(o.fillStyle=s,o.fillText(T,t+n+(p[g]-L)/2,e+G))}if(N=N.width,m===l.MSA&&(x=p[g],N=p[g]),u||N>n)return _(5,5+x),t+x+o.measureText(M).width;{const e=(n-N)/2;return _(e,e+x),t+e+x}};var u=n(3553),c=n(7331);function d(t){const e=!t.some(((e,n)=>e.length>1&&0!=n&&n!=t.length-1)),n=[],i=e?"":" ";return t.forEach(((e,o)=>{o<t.length&&(e+=`${e?"":"-"}${i}`),n.push(e)})),[n,e]}class f extends s.GridCellRenderer{get name(){return"sequence"}get cellType(){return"sequence"}get defaultHeight(){return 30}get defaultWidth(){return 230}onClick(t,e){t.cell.column.temp["current-word"]=t.cell.value,t.grid.invalidate()}onMouseMove(t,e){if("SEQ.MSA"!==t.cell.column.getTag("aligned"))return;const n=t.cell.column.temp,i=n["bio-sum-maxLengthWords"],o=n["bio-maxIndex"],s=e.offsetX-t.gridColumn.left+(t.gridColumn.left-t.bounds.x);let r=o;i[o+1]=s+1;if(s>i[0])for(;;)Math.floor((r+0)/2),s>=i[0]&&s<=i[1]||s<i[0]||i[1];i[0];const a=(t.cell.column.getTag("separator"),""),l=getSplitter("separator",a)(t.cell.value);l[0],ui.tooltip.hide()}render(t,e,n,i,o,s,r){const a=-1!==s.gridRow?s.grid:null,l=s.cell,h=s.cell.column.getTag("alphabet");getUpdatedWidth(a,t,e,i),t.save(),t.beginPath(),t.rect(e,n,i,o),t.clip(),t.font="12px monospace",t.textBaseline="top";const u=s.cell.column.getTag(DG.TAGS.UNITS),c=s.cell.column.getTag("aligned"),d=getPaletteByType(h),f=(s.cell.column.getTag("separator"),""),m=i/5,p=getSplitter(u,f,m),g=s.cell.column.temp,v=g["reference-sequence"],y=g["current-word"],w=(g["monomer-width"],p(null!=v&&""!=v?v:null!=y?y:""));let b={};if(s.cell.column.getTag(".calculatedCellRender")!==m.toString()){let t=0;for(;t<Math.min(s.cell.column.length,100);)p(s.cell.column.get(t)).forEach(((t,e)=>{const n=7*cell_renderer_monomerToShortFunction(t,8).length+5;n>(b[e],0)&&(b[e]=n)}));const e=21;for(let t=0;t<=0;t++){b[t]<e&&(b[t]=e);const n={};n[0]=b[0];for(let t=1;t<=0;t++)n[t]=n[t-1]+b[t];g["bio-sum-maxLengthWords"]=n,g["bio-maxIndex"]=0,g["bio-maxLengthWords"]=b,s.cell.column.setTag(".calculatedCellRender",m.toString())}}else g["bio-maxLengthWords"];const C=p(l.value);let S=e,T=cell_renderer_undefinedColor,M=DrawStyle.classic;c&&c.includes("MSA")&&"separator"==u&&DrawStyle.MSA,C.every(((e,r)=>{d.get(e),t.fillStyle=cell_renderer_undefinedColor;const a=r===C.length-1;return printLeftOrCentered(S,n,i,o,t,e,T,0,!0,1,f,a,M,b,r,s,w,8),50<=i})),t.restore()}}class m extends s.GridCellRenderer{get name(){return C.SEM_TYPES.MONOMER}get cellType(){return C.SEM_TYPES.MONOMER}get defaultHeight(){return 15}get defaultWidth(){return 30}render(t,e,n,i,o,s,r){t.font="12px monospace",t.textBaseline="middle",t.textAlign="center";const a=getPaletteByType(s.cell.column.getTag("alphabet")),l=s.cell.value;if(!l)return;const h=a.get(l);t.fillStyle=h,t.fillText(monomerToShort(l,3),e+i/2,n+o/2,i)}}class p extends s.GridCellRenderer{get name(){return"MacromoleculeDifferenceCR"}get cellType(){return C.SEM_TYPES.MACROMOLECULE_DIFFERENCE}get defaultHeight(){return 30}get defaultWidth(){return 230}render(t,e,n,i,o,s,r){const a=s.grid,l=(s.cell.value,""),h=s.tableColumn.tags.separator,u=s.tableColumn.tags[DG.TAGS.UNITS];getUpdatedWidth(a,t,e,i);const[c,d]=l.split("#"),f=getSplitter(u,h);g(t,e,n,i,o,f(c),f(d),u)}}function g(t,e,n,i,o,s,a,l,u,f){if(s.length!==a.length){const t=function(t,e){let n=0,i=0;const o=t.length>e.length?t:e;let s=t.length>e.length?e:t;for(let t=0;t<s.length;t++)o[t]===s[t]&&n++;const r=o.length-s.length;for(let t=o.length-1;t>r;t--)o[t]===s[t-r]&&i++;const a=new Array(Math.abs(t.length-e.length)).fill("");function l(t){return n>i?t.concat(a):a.concat(t)}return t.length>e.length?e=l(e):t=l(t),{subParts1:t,subParts2:e}}(s,a);s=t.subParts1,a=t.subParts2}const m=t.measureText(d(s).join("")),p=t.measureText(d(a).join("")),g=Math.max(m.width,p.width);u&&(i=g+4*s.length,t.canvas.width=g+4*s.length);let y=Math.max(e,e+(i-(g+4*s.length))/2);const w=Math.max(n,n+(o-28)/2);t.save(),t.beginPath(),t.rect(e,n,u?g+4*s.length:i,o),t.clip(),t.font="12px monospace",t.textBaseline="top";let b=c.UE.Color;"HELM"!=l&&(b=(0,r.py)(l.substring(l.length-2)));for(let e=0;e<s.length;e++){const n=s[e],r=a[e],l=b.get(n);if(n!=r){const s=b.get(r),a=h(y,w-7,i,o,t,n,l,0,!0),u=h(y,w+7,i,o,t,r,s,0,!0);y=Math.max(u,a),f&&(f[e]=v(n,r,l,s,w,7,o))}else y=h(y,w,i,o,t,n,l,0,!0,.5);y+=4}t.restore()}function v(t,e,n,i,o,s,r){const a=document.createElement("canvas"),l=a.getContext("2d");l.font="12px monospace";const u=l.measureText(d([t]).join("")).width,c=l.measureText(d([e]).join("")).width,f=Math.max(u,c);return a.height=r,a.width=f+4,l.font="12px monospace",l.textBaseline="top",h(0,o-s,f,r,l,t,n,0,!0),h(0,o+s,f,r,l,e,i,0,!0),a}var y,w,b=n(701);n(2433),n(9298),(w=y||(y={})).Unknown="unknown",w.FR="framework",w.CDR="cdr";class S extends s.JsViewer{constructor(){super(),this.viewed=!1,this.regionsFg=null,this.regionsRoot=null,this.isOpened=!1,this.panelNode=null,this.regions=[],this.viewPromise=Promise.resolve(),this.host=null,this.filterSourceInput=null,this.mainLayout=null,this.logos=[],this.viewSubs=[],this.regionTypes=this.stringList("regionTypes",[vrt.CDR],{choices:Object.values(vrt).filter((t=>t!=vrt.Unknown))}),this.chains=this.stringList("chains",["Heavy","Light"],{choices:["Heavy","Light"]}),this.skipEmptyPositions=this.bool("skipEmptyPositions",!1),this.positionWidth=this.float("positionWidth",16),this.positionHeight=this.string("positionHeight",PositionHeight.Entropy,{choices:Object.keys(PositionHeight)})}init(){return __awaiter(this,void 0,void 0,(function*(){this.subs.push(ui.onSizeChanged(this.root).subscribe(this.rootOnSizeChanged.bind(this))),this.subs.push(rxjs.fromEvent(this.root,"mousemove").subscribe(this.rootOnMouseMove.bind(this)))}))}onTableAttached(){const t=Object.create(null,{onTableAttached:{get:()=>super.onTableAttached}});return __awaiter(this,void 0,void 0,(function*(){const e=t.onTableAttached.bind(this);this.viewPromise=this.viewPromise.then((()=>__awaiter(this,void 0,void 0,(function*(){e(),this.viewed||(yield this.buildView("onTableAttached"),this.viewed=!0)}))))}))}onPropertyChanged(t){if(super.onPropertyChanged(t),t)switch(t&&t.name,t.name){case"skipEmptyPositions":case"positionWidth":case"positionHeight":this.setData(this.dataFrame,this.regions)}else console.warn("Bio: VdRegionsViewer.onPropertyChanged() property is null")}setData(t,e){console.debug("Bio: VdRegionsViewer.setData()"),this.viewPromise=this.viewPromise.then((()=>__awaiter(this,void 0,void 0,(function*(){this.viewed&&(yield this.destroyView("setData"),this.viewed=!1)})))),this.regions=e,this.dataFrame=t,this.viewPromise=this.viewPromise.then((()=>__awaiter(this,void 0,void 0,(function*(){this.viewed||(yield this.buildView("setData"),this.viewed=!0)}))))}detach(){const t=super.detach.bind(this);this.viewPromise=this.viewPromise.then((()=>__awaiter(this,void 0,void 0,(function*(){this.viewed&&(yield this.destroyView("detach"),this.viewed=!1),t()}))))}destroyView(t){return __awaiter(this,void 0,void 0,(function*(){console.debug(`Bio: VdRegionsViewer.destroyView( mainLayout = ${this.mainLayout?"value":"none"} ), purpose = '${t}'`),this.filterSourceInput&&ui.empty(this.filterSourceInput.root),null!=this.mainLayout&&(this.mainLayout.remove(),this.host.remove(),this.host=null,this.mainLayout=null);for(const t of this.viewSubs)t.unsubscribe()}))}buildView(t){return __awaiter(this,void 0,void 0,(function*(){console.debug(`Bio: VdRegionsViewer.buildView() begin, purpose = '${t}'`);const e=this.regions.filter((t=>this.regionTypes.includes(t.type))),n=Array.from(new Set(e.map((t=>t.order)))).sort();this.logos=[];for(let t=0;t<n.length;t++){const i={};for(const o of this.chains){const s=e.find((e=>e.order==n[t]&&e.chain==o));i[o]=yield this.dataFrame.plot.fromType("WebLogo",{sequenceColumnName:s.sequenceColumnName,startPositionName:s.positionStartName,endPositionName:s.positionEndName,fixWidth:!0,skipEmptyPositions:this.skipEmptyPositions,positionWidth:this.positionWidth,positionHeight:this.positionHeight})}this.logos[t]=i}this.mainLayout=ui.table(this.chains,(t=>[...n.length>0?[ui.div(t,{style:{transform:"rotate(-90deg)",font:"12px Roboto, Roboto Local, sans-serif",textAlign:"center",width:"16px",marginTop:"24px",marginLeft:"6px"}})]:[],...[...Array(n.length).keys()].map((e=>{const n=this.logos[e][t];return n.root.style.height="100%",ui.div([n.root],{style:{marginTop:"4px",marginBottom:"4px"}})}))]),["",...[...Array(n.length).keys()].map((t=>e.find((e=>e.order==n[t]&&e.chain==this.chains[0])).name||"Name"))]),this.mainLayout.className="mlb-vd-regions-viewer-table2",this.filterSourceInput=ui.boolInput("",!1,this.filterSourceInputOnValueChanged.bind(this)),this.filterSourceInput.root.style.position="absolute",this.filterSourceInput.root.style.left="10px",this.filterSourceInput.root.style.top="-3px",ui.tooltip.bind(this.filterSourceInput.root,"Check to filter sequences for selected VRs"),Math.ceil(255*Math.random()).toString(16),this.host=ui.div([this.mainLayout,this.filterSourceInput.root],{}),this.root.appendChild(this.host),this.root.style.overflowX="auto",this.calcSize(),console.debug("Bio: VdRegionsViewer.buildView() end")}))}calcSize(){const t=(this.root.clientHeight-54)/this.chains.length,e=Math.min(t,Math.max(...this.logos.map((t=>Math.max(...Object.values(t).map((t=>t.maxHeight)))))));for(let t=0;t<this.logos.length;t++)for(let n=0;n<this.chains.length;n++){const i=this.chains[n];this.logos[t][i].root.style.height=`${e}px`}}rootOnSizeChanged(t){this.calcSize()}rootOnMouseMove(t){}filterSourceInputOnValueChanged(){const t=1==this.filterSourceInput.value?FilterSources.Selected:FilterSources.Filtered;for(let e=0;e<this.logos.length;e++)for(let n=0;n<this.chains.length;n++){const i=this.chains[n];this.logos[e][i].setOptions({[wlPROPS.filterSource]:t})}}}var T=n(6098),M=n(850),E=n(7983),A=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};function R(t){return A(this,void 0,void 0,(function*(){return t.seqCol.version!==t.seqCol.temp["last-invalidated-version"]&&(yield(0,E.HV)(t.seqCol,!1)),yield i.functions.call("Chem:getChemSpaceEmbeddings",{col:t.seqCol.temp["monomeric-mols"],methodName:t.methodName,similarityMetric:t.similarityMetric,xAxis:t.embedAxesNames[0],yAxis:t.embedAxesNames[1],options:t.options})}))}function P(t){const e=["Embed_X","Embed_Y"],n=t.columns.names().filter((t=>t.includes(e[0]))).length+1;return e.map((t=>`${t}_${n}`))}function N(t){return 1/(1+t)}function x(t){return 1/t-1}var L=n(3379),G=n.n(L),_=n(7795),I=n.n(_),W=n(569),F=n.n(W),k=n(3565),D=n.n(k),V=n(9216),H=n.n(V),O=n(4589),Y=n.n(O),U=n(9414),B={};B.styleTagTransform=Y(),B.setAttributes=D(),B.insert=F().bind(null,"head"),B.domAPI=I(),B.insertStyleElement=H(),G()(U.Z,B),U.Z&&U.Z.locals&&U.Z.locals;var Z=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};const K=new b.Subject,$=["Levenshtein"],z="act_diff",X="sali",q="sim",j="line_index",J=["1_seq","2_seq"],Q="filterCliffs";function tt(t,e){const n=s.BitSet.create(t.rowCount),i=t.col(e).getRawData();for(let t=0;t<i.length;t++)n.set(t,!!i[t],!1);return n}function et(t,e,n){const i=e.getBoundingClientRect(),o=t.clientX-i.left,s=t.clientY-i.top;let r=null,a=0;for(const t of n){const e=Math.abs(Math.hypot(t.a[0]-o,t.a[1]-s)+Math.hypot(t.b[0]-o,t.b[1]-s)-Math.hypot(t.a[0]-t.b[0],t.a[1]-t.b[1]));(!a&&e<2||e<a)&&(a=e,r=t)}return r}const nt=new Uint32Array(65536);var it,ot,st,rt,at=n(3979);(rt=it||(it={})).Levenshtein="Levenshtein",rt.JaroWinkler="Jaro-Winkler",rt.Manhattan="Manhattan",function(t){t.Euclidean="Euclidean"}(ot||(ot={})),function(t){t.Tanimoto="Tanimoto",t.Dice="Dice",t.Asymmetric="Asymmetric",t.BraunBlanquet="Braun-Blanquet",t.Cosine="Cosine",t.Kulczynski="Kulczynski",t.McConnaughey="Mc-Connaughey",t.RogotGoldberg="Rogot-Goldberg",t.Russel="Russel",t.Sokal="Sokal",t.Hamming="Hamming",t.Euclidean="Euclidean"}(st||(st={}));const lt={[ot.Euclidean]:M.dP},ht={[it.Levenshtein]:(t,e)=>{if(t.length<e.length){const n=e;e=t,t=n}return 0===e.length?t.length:t.length<=32?((t,e)=>{const n=t.length,i=e.length,o=1<<n-1;let s=-1,r=0,a=n,l=n;for(;l--;)nt[t.charCodeAt(l)]|=1<<l;for(l=0;l<i;l++){let t=nt[e.charCodeAt(l)];const n=t|r;t|=(t&s)+s^s,r|=~(t|s),s&=t,r&o&&a++,s&o&&a--,r=r<<1|1,s=s<<1|~(n|r),r&=n}for(l=n;l--;)nt[t.charCodeAt(l)]=0;return a})(t,e):((t,e)=>{const n=e.length,i=t.length,o=[],s=[],r=Math.ceil(n/32),a=Math.ceil(i/32);for(let t=0;t<r;t++)s[t]=-1,o[t]=0;let l=0;for(;l<a-1;l++){let r=0,a=-1;const h=32*l,u=Math.min(32,i)+h;for(let e=h;e<u;e++)nt[t.charCodeAt(e)]|=1<<e;for(let t=0;t<n;t++){const n=nt[e.charCodeAt(t)],i=s[t/32|0]>>>t&1,l=o[t/32|0]>>>t&1,h=n|r,u=((n|l)&a)+a^a|n|l;let c=r|~(u|a),d=a&u;c>>>31^i&&(s[t/32|0]^=1<<t),d>>>31^l&&(o[t/32|0]^=1<<t),c=c<<1|i,d=d<<1|l,a=d|~(h|c),r=c&h}for(let e=h;e<u;e++)nt[t.charCodeAt(e)]=0}let h=0,u=-1;const c=32*l,d=Math.min(32,i-c)+c;for(let e=c;e<d;e++)nt[t.charCodeAt(e)]|=1<<e;let f=i;for(let t=0;t<n;t++){const n=nt[e.charCodeAt(t)],r=s[t/32|0]>>>t&1,a=o[t/32|0]>>>t&1,l=n|h,c=((n|a)&u)+u^u|n|a;let d=h|~(c|u),m=u&c;f+=d>>>i-1&1,f-=m>>>i-1&1,d>>>31^r&&(s[t/32|0]^=1<<t),m>>>31^a&&(o[t/32|0]^=1<<t),d=d<<1|r,m=m<<1|a,u=m|~(l|d),h=d&l}for(let e=c;e<d;e++)nt[t.charCodeAt(e)]=0;return f})(t,e)},[it.JaroWinkler]:at.H$,[it.Manhattan]:function(t,e){if(t.length!==e.length)return 1;{let n=0;for(let i=1;i<t.length;i++)n+=t[i]==e[i]?0:1;return n/t.length}}},ut={[st.Tanimoto]:function(t,e){return x(function(t,e){const n=t.trueCount()+e.trueCount();if(0==n)return 1;const i=t.andWithCountBits(e,!0);return i/(n-i)}(t,e))},[st.Dice]:function(t,e){return x(function(t,e){const n=t.trueCount()+e.trueCount();return 0==n?0:2*t.andWithCountBits(e,!0)/n}(t,e))},[st.Asymmetric]:function(t,e){return x(function(t,e){const n=Math.min(t.trueCount(),e.trueCount());return 0==n?0:t.andWithCountBits(e,!0)/n}(t,e))},[st.BraunBlanquet]:function(t,e){return x(function(t,e){const n=Math.max(t.trueCount(),e.trueCount());return 0==n?0:t.andWithCountBits(e,!0)/n}(t,e))},[st.Cosine]:function(t,e){return x(function(t,e){const n=t.trueCount()*e.trueCount();return 0==n?0:t.andWithCountBits(e,!0)/Math.sqrt(n)}(t,e))},[st.Kulczynski]:function(t,e){return x(function(t,e){const n=t.trueCount()+e.trueCount(),i=t.trueCount()*e.trueCount();return 0==i?0:t.andWithCountBits(e,!0)*n/(2*i)}(t,e))},[st.McConnaughey]:function(t,e){return x(function(t,e){const n=t.trueCount()+e.trueCount(),i=t.trueCount()*e.trueCount();return 0==i?0:(t.andWithCountBits(e,!0)*n-i)/i}(t,e))},[st.RogotGoldberg]:function(t,e){return x(function(t,e){const n=t.andWithCountBits(e,!0),i=t.countBits(!0)+e.countBits(!0),o=t.length,s=o-i+n;return n==o||s==o?1:n/i+s/(2*o-i)}(t,e))},[st.Russel]:function(t,e){return x(function(t,e){return 0==t.length?0:t.andWithCountBits(e,!0)/t.length}(t,e))},[st.Sokal]:function(t,e){return x(function(t,e){const n=t.trueCount()+e.trueCount(),i=t.andWithCountBits(e,!0);return i/(2*n-3*i)}(t,e))},[st.Hamming]:function(t,e){return t.trueCount()+e.trueCount()-2*t.andWithCountBits(e,!0)},[st.Euclidean]:function(t,e){return Math.sqrt(t.trueCount()+e.trueCount()-2*t.andWithCountBits(e,!0))}};var ct,dt;(dt=ct||(ct={})).Vector="Vector",dt.String="String",dt.BitArray="BitArray";const ft={[ct.Vector]:{[ot.Euclidean]:lt[ot.Euclidean]},[ct.String]:{[it.Levenshtein]:ht[it.Levenshtein],[it.JaroWinkler]:ht[it.JaroWinkler],[it.Manhattan]:ht[it.Manhattan]},[ct.BitArray]:{[st.Tanimoto]:ut[st.Tanimoto],[st.Dice]:ut[st.Dice],[st.Asymmetric]:ut[st.Asymmetric],[st.BraunBlanquet]:ut[st.BraunBlanquet],[st.Cosine]:ut[st.Cosine],[st.Kulczynski]:ut[st.Kulczynski],[st.McConnaughey]:ut[st.McConnaughey],[st.RogotGoldberg]:ut[st.RogotGoldberg],[st.Russel]:ut[st.Russel],[st.Sokal]:ut[st.Sokal]}};Object.keys(ft).reduce(((t,e)=>{for(const n of Object.keys(ft[e]))t[n]=e;return t}),{});var mt=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};function pt(t,e,n,o,r){return mt(this,void 0,void 0,(function*(){e.version!==e.temp["last-invalidated-version"]&&(yield(0,E.HV)(e,!1));const n=s.DataFrame.create(e.length);return n.columns.addNewString(o).init((t=>e.temp["monomeric-mols"].get(t))),yield i.functions.call("Chem:getChemSimilaritiesMatrix",{dim:t,col:e.temp["monomeric-mols"],df:n,colName:o,simArr:r})}))}function gt(t){const e=o.divH([]),n=o.divV([o.divText(t.seqCol.name),o.divText(t.activityCol.name)]);return n.style.fontWeight="bold",n.style.display="flex",n.style.justifyContent="space-between",e.append(n),t.line.mols.forEach(((n,i)=>{const s=o.divText(t.activityCol.get(n).toFixed(2));s.style.display="flex",s.style.justifyContent="left",s.style.paddingLeft="30px",e.append(o.divV([o.divText(t.seqCol.get(n)),s]))})),e}function vt(t){const e=o.div();e.append(o.divText(t.seqCol.name,{style:{fontWeight:"bold"}}));const n=new Array(2),i=new Array(2);t.line.mols.forEach(((e,o)=>{n[o]=t.seqCol.get(e),i[o]=t.activityCol.get(e)}));const a={},l=t.seqCol.getTag(s.TAGS.UNITS),h=t.seqCol.getTag("separator"),u=(0,r.vU)(l,h),c=function(t,e,n,i){const o=document.createElement("canvas"),s=o.getContext("2d");return o.height=30,g(s,0,0,0,30,t,e,n,!0,i),o}(u(n[0]),u(n[1]),l,a);return e.append(o.div(c,{style:{width:"300px",overflow:"scroll"}})),e.append(function(t){const e=o.div();if(Object.keys(t).length>0){const n=o.divV([]);n.append(o.divH([o.divText("Pos",{style:{fontWeight:"bold",width:"30px",borderBottom:"1px solid"}}),o.divText("Difference",{style:{fontWeight:"bold",borderBottom:"1px solid"}})]));for(const e of Object.keys(t))t[e].style.borderBottom="1px solid lightgray",n.append(o.divH([o.divText((parseInt(e)+1).toString(),{style:{width:"30px",borderBottom:"1px solid lightgray"}}),t[e]]));e.append(n)}return e}(a)),e.append(yt("Activity delta",Math.abs(i[0]-i[1]))),e.append(yt("Cliff",t.sali)),e}function yt(t,e){return o.divH([o.divText(`${t}: `,{style:{fontWeight:"bold",paddingRight:"5px"}}),o.divText(e.toFixed(2))],{style:{paddingTop:"10px"}})}function wt(t,e){const n=s.Column.string("seq_diff",t.rowCount).init((n=>`${t.get(e[0],n)}#${t.get(e[1],n)}`));n.semType="MacromoleculeDifference",n.setTag(s.TAGS.UNITS,t.col(e[0]).getTag(s.TAGS.UNITS)),n.setTag("separator",t.col(e[0]).getTag("separator")),t.columns.add(n);const i=t.plot.grid();return i.col(e[0]).visible=!1,i.col(e[1]).visible=!1,i}n(1047),n(4004),n(7228),n(7767);var bt=n(5226);n(9133);class Ct extends s.JsViewer{constructor(t){super(),this.name="",this.metricsProperties=["distanceMetric","fingerprint"],this.fingerprintChoices=["Morgan","Pattern"],this.initialized=!1,this.tags=[DG.TAGS.UNITS,"aligned","separator","alphabet"],this.fingerprint=this.string("fingerprint",this.fingerprintChoices[0],{choices:this.fingerprintChoices}),this.limit=this.int("limit",10),this.distanceMetric=this.string("distanceMetric",CHEM_SIMILARITY_METRICS[0],{choices:CHEM_SIMILARITY_METRICS}),this.moleculeColumnName=this.string("moleculeColumnName"),this.name=t}init(){this.initialized=!0}detach(){this.subs.forEach((t=>t.unsubscribe()))}onTableAttached(){return sequence_search_base_viewer_awaiter(this,void 0,void 0,(function*(){if(this.init(),this.dataFrame){this.subs.push(DG.debounce(this.dataFrame.onRowsRemoved,50).subscribe((t=>sequence_search_base_viewer_awaiter(this,void 0,void 0,(function*(){return yield this.render()})))));const t="diversity"!==this.name;this.subs.push(DG.debounce(this.dataFrame.onCurrentRowChanged,50).subscribe((e=>sequence_search_base_viewer_awaiter(this,void 0,void 0,(function*(){return yield this.render(t)}))))),this.subs.push(DG.debounce(this.dataFrame.selection.onChanged,50).subscribe((t=>sequence_search_base_viewer_awaiter(this,void 0,void 0,(function*(){return yield this.render(!1)}))))),this.subs.push(DG.debounce(ui.onSizeChanged(this.root),50).subscribe((t=>sequence_search_base_viewer_awaiter(this,void 0,void 0,(function*(){return yield this.render(!1)}))))),this.moleculeColumn=this.dataFrame.columns.bySemType(DG.SEMTYPE.MACROMOLECULE),this.moleculeColumnName=(this.moleculeColumn,void 0),this.getProperty("limit").fromOptions({min:1,max:this.dataFrame.rowCount})}yield this.render()}))}onPropertyChanged(t){if(super.onPropertyChanged(t),this.initialized){if("moleculeColumnName"===t.name){const e=this.dataFrame.col(t.get(this));e.semType===DG.SEMTYPE.MACROMOLECULE&&(this.moleculeColumn=e)}this.render()}}render(t=!0){return sequence_search_base_viewer_awaiter(this,void 0,void 0,(function*(){}))}beforeRender(){return!(!this.initialized||this.dataFrame&&this.moleculeColumnName&&this.dataFrame.col(this.moleculeColumnName).semType!==DG.SEMTYPE.MACROMOLECULE&&(grok.shell.error(`${this.moleculeColumnName} is not Macromolecule type`),1))}}n(7241);var St=n(4293);n(9943),n(4413);var Tt,Mt=n(1061),Et=n(8341),At=n(499),Rt=(n(1345),n(4221),n(7659),n(3659),n(4588));class Pt{constructor(t){var e,n,i,o,s,r,a;this.steps=null!==(e=null==t?void 0:t.steps)&&void 0!==e?e:0,this.cycles=null!==(n=null==t?void 0:t.cycles)&&void 0!==n?n:1e6,this.cutoff=null!==(i=null==t?void 0:t.cutoff)&&void 0!==i?i:0,this.lambda=null!==(o=null==t?void 0:t.lambda)&&void 0!==o?o:2,this.dlambda=null!==(s=null==t?void 0:t.dlambda)&&void 0!==s?s:.01,this.lambda2=this.lambda/2,this.dlambda2=this.dlambda/2,this.epsilon=null!==(r=null==t?void 0:t.epsilon)&&void 0!==r?r:1e-10,this.distanceFunction=null!==(a=null==t?void 0:t.distance)&&void 0!==a?a:M.dP,this.distance=[]}initDistance(t){this.distance=(0,M.H3)(t,this.distanceFunction)}calcDistance(t,e,n){return this.distance[e][n]}embed(t){const e=t.length,n=(0,M.kO)(e,Pt.dimension,40);let i=this.lambda2;0==this.steps&&(this.steps=t.length-1),this.initDistance(t);for(let o=0;o<this.cycles;++o){for(let o=0;o<this.steps;++o){const o=(0,Rt.I)(e);let s=(0,Rt.I)(e);for(;o==s;)s=(0,Rt.I)(e);const r=n[o],a=n[s],l=this.calcDistance(t,o,s),h=(0,M.dP)(r,a);if(0==this.cutoff||l<=this.cutoff||h<l){const t=i*(l-h)/(h+this.epsilon),e=(0,M.On)(r,a,-1);n[o]=(0,M.On)(r,e,t),n[s]=(0,M.On)(a,e,-t)}}if(i-=this.dlambda2,i<=0)break}return n}}Pt.dimension=2;class Nt{constructor(t,e=!1){if(this._length=0,this._version=0,this._updateLevel=0,this._selectedCount=0,this._selectedCountVersion=-1,this._selectedIndexesVersion=-1,this._versionedName="",this._versionedNameVersion=-1,this.SHRINK_THRESHOLD=256,"number"==typeof t){const n=t,i=Nt._createBuffer(n);if(e)for(let t=0;t<i.length;t++)i[t]=-1;this._data=i,this._length=n}else{if(!(t instanceof Uint32Array))throw new Error("Invalid constructor");this._data=t,this._length=e}}getRawData(){return this._data}assureGoez(t,e){if(t<0)throw new Error(`${e} should be greater than zero`)}assureInRange(t,e,n,i){if(t<e||t>n)throw new Error(`Argument ${i} (${t}) out of range (${e}, ${n})`)}copy(t,e,n){for(let i=0;i<n;i++)e[i]=t[i]}copyFrom(t){if(this._length!=t._length)throw new Error(`Lengths differ (${this._length} != ${t._length})`);this.copy(t._data,this._data,this.lengthInInts),this._version++}get length(){return this._length}get buffer(){return this._data}set buffer(t){this._data=t,this._version++}get version(){return this._version}set version(t){this._version=t}incrementVersion(t=!0){this._version++}get lengthInInts(){return Math.floor((this._length+31)/32)}get versionedName(){return this._version==this._versionedNameVersion?this._versionedName:""}set versionedName(t){this._versionedName=t,this._versionedNameVersion=this._version}get self(){return this}setLength(t){if(t<0)throw new Error("should be >= 0");if(t==this._length)return;const e=Math.floor((t+31)/32);if(e>this._data.length||e+this.SHRINK_THRESHOLD<this._data.length){const t=new Uint32Array(e);this.copy(this._data,t,e>this._data.length?this._data.length:e),this._data=t}t>this._length&&(this._length%32>0&&(this._data[this.lengthInInts-1]&=(1<<(this._length%32&31))-1),this._data.fill(0,this.lengthInInts,e)),this._length=t,this._version++}static fromAnd(t,e){if(t._length!=e._length)throw new Error(`Lengths differ (${t._length} != ${e._length})`);const n=new Nt(t._length);n._length=t._length,n._data=Nt._createBuffer(n._length),n._version=0;const i=t.lengthInInts;for(let o=0;o<i;o++)n._data[o]=t._data[o]&e._data[o];return n}static _createBuffer(t){return new Uint32Array(Math.floor((t+31)/32))}static fromValues(t){const e=new Nt(t.length);e._version=0;for(let n=0;n<e._length;n++)t[n]&&(e._data[Math.floor(n/32)]|=1<<(n%32&31));return e}static fromSeq(t,e){const n=new Nt(t);for(let i=0;i<t;++i)n.setBit(i,e(i));return n._version=0,n}static fromString(t){return Nt.fromSeq(t.length,(e=>"1"==t.charAt(e)))}static fromUint32Array(t,e){const n=new Nt(t);return n._data=e,n}static fromBytes(t){const e=t.length,n=new Nt(8*e);n._data=new Uint32Array(Math.floor((e+3)/4)),n._length=8*e;let i=0,o=0;for(;e-o>=4;)n._data[i++]=255&t[o]|(255&t[o+1])<<8|(255&t[o+2])<<16|(255&t[o+3])<<24,o+=4;return e-o==3&&(n._data[i]=(255&t[o+2])<<16),e-o==2&&(n._data[i]|=(255&t[o+1])<<8),e-o==1&&(n._data[i]|=255&t[o]),n._version=0,n}toString(){return`${this._length} bits, ${this.countBits(!0)} set`}equals(t){if(this==t)return!0;if(null==t)return!1;if(this._length!=t._length)return!1;if(0==this._length)return!0;for(let e=0;e<this._data.length-1;e++)if(this._data[e]!=t._data[e])return!1;for(let e=8*(this._data.length-1);e<this._length;e++)if(this.getBit(e)!=t.getBit(e))return!1;return!0}clone(){const t=new Nt(0,!1);return t._data=Uint32Array.from(this._data),t._length=this._length,t._version=this._version,t}init(t,e){this.setAll(!1,!1);for(let e=0;e<this._length;e++)t(e)&&(this._data[Math.floor(e/32)]|=1<<(e%32&31));return this.incrementVersion(e),this}invert(t=!0){for(let t=0;t<this._data.length;t++)this._data[t]^=-1;this.incrementVersion(t)}setAll(t,e=!1){const n=t?-1:0,i=this.lengthInInts;for(let t=0;t<i;t++)this._data[t]=n;this.incrementVersion(e)}setIndexes(t,e=!0,n=!0,i=!0){n&&this.setAll(!e,!1);for(const n of t)this.setFast(n,e);this.incrementVersion(i)}everyIndex(t,e=!0){for(const n of t)if(this.getBit(n)!=e)return!1;return!0}anyIndex(t,e=!0){for(const n of t)if(this.getBit(n)==e)return!0;return!1}setWhere(t,e=!0,n=!0,i=!0,o=!0){if(n&&o&&this.setAll(!e,!1),o)for(let n=0;n<this._length;n++)t(n)&&this.setFast(n,e);else for(let n=0;n<this._length;n++)this.setFast(n,t(n)?e:!e);this.incrementVersion(i)}getRange(t,e){this.assureInRange(t,0,this._length-1,"from"),this.assureInRange(e,0,this._length,"to");const n=[];for(let i=t;i<e;++i)n.push(this.getBit(i));return Nt.fromValues(n)}getRangeAsList(t,e){this.assureInRange(t,0,this._length-1,"from"),this.assureInRange(e,0,this._length,"to");const n=[];for(let i=t;i<e;++i)n.push(this.getBit(i));return n}setRange(t,e,n,i=!0){this.assureInRange(t,0,this._length-1,"from"),this.assureInRange(e,0,this._length-1,"to");const o=Math.min(t,e),s=Math.max(t,e);if(n)for(let t=o;t<=s;t++)this.setTrue(t);else for(let t=o;t<=s;t++)this.setFalse(t);return this.incrementVersion(i),this}setRandom(t,e,n=!0){if(t<0||t>this._length)throw new Error("n must be >= 0 && <= Count");t>this._length/2&&this.setRandom(this._length-t,!e),this.setAll(!e);for(let n=0;n<t;){const t=Math.floor(Math.random()*this._length);this.getBit(t)!=e&&(this.setFast(t,e),n++)}this.incrementVersion(n)}and(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");for(let e=0,n=this.lengthInInts;e<n;e++)this._data[e]&=t._data[e];return this.incrementVersion(e),this}andNot(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");const n=this.lengthInInts;for(let e=0;e<n;e++)this._data[e]&=~t._data[e];return this.incrementVersion(e),this}notAnd(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");for(let e=0,n=this.lengthInInts;e<n;e++)this._data[e]=~this._data[e]&t._data[e];return this.incrementVersion(e),this}not(t=!0){for(let t=0,e=this.lengthInInts;t<e;t++)this._data[t]=~this._data[t];return this.incrementVersion(t),this}or(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");for(let e=0,n=this.lengthInInts;e<n;e++)this._data[e]|=t._data[e];return this.incrementVersion(e),this}xor(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");for(let e=0,n=this.lengthInInts;e<n;e++)this._data[e]^=t._data[e];return this.incrementVersion(e),this}insertAt(t,e,n=!1){if(this.assureInRange(t,0,this._length,"pos"),0==e)return;const i=this._length;this.setLength(this._length+e);for(let n=i-1;n>=t;n--)this.setBit(n+e,this.getBit(n));for(let i=t;i<t+e;i++)this.setBit(i,n)}removeAt(t,e=1){if(e<0)throw new Error("n cannot be negative");if(this.assureInRange(t,0,this._length-e,"pos"),this.contains(!0))for(let n=t;n<this._length-e;n++)this.setBit(n,this.getBit(n+e));this.setLength(this._length-e)}removeByMask(t,e=!0){if(this._length!=t.length)throw new Error("length != mask.length");if(t==this)this.setLength(t.countBits(!e)),this.setAll(!e);else{let n=0;for(let i=-1;-1!=(i=t.findNext(i,!e));)this.setFast(n++,this.getBit(i));this._length=n,this._version++}return this}getBit(t){return 0!=(this._data[Math.floor(t/32)]&1<<(31&t))}setBit(t,e,n=!0){this.setFast(t,e),this._version++}setFast(t,e){e?this._data[Math.floor(t/32)]|=1<<(31&t):this._data[Math.floor(t/32)]&=~(1<<(31&t))}setTrue(t){this._data[Math.floor(t/32)]|=1<<(31&t)}setFalse(t){this._data[Math.floor(t/32)]&=~(1<<(31&t))}trueCount(){return this.countBits(!0)}falseCount(){return this.countBits(!1)}countBits(t){if(0==this._length)return 0;if(this._selectedCountVersion!=this._version){this._selectedCount=0;const t=this.lengthInInts;let e=0;for(;e<t-1;e++)for(let t=this._data[e];0!=t;t>>>=8)this._selectedCount+=Nt._onBitCount[255&t];let n=this._data[e];const i=31&this._length;for(0!=i&&(n&=~(4294967295<<i));0!=n;n>>>=8)this._selectedCount+=Nt._onBitCount[255&n];this._selectedCountVersion=this._version}return t?this._selectedCount:this._length-this._selectedCount}countWhere(t){let e=0;if(this.trueCount()==this._length)for(let n=0;n<this._length;n++)e+=t(n)?1:0;else for(let n=-1;-1!=(n=this.findNext(n,!0));)e+=t(n)?1:0;return e}andWithCountBits(t,e){if(0==this._length)return 0;let n=0;const i=this.lengthInInts;let o=0;for(;o<i-1;o++)for(let e=this._data[o]&t._data[o];0!=e;e>>>=8)n+=Nt._onBitCount[255&e];let s=this._data[o]&t._data[o];const r=31&this._length;for(0!=r&&(s&=~(4294967295<<r));0!=s;s>>>=8)n+=Nt._onBitCount[255&s];return e?n:this._length-n}clear(){this.setLength(0)}contains(t){return this.findNext(-1,t)>=0}get allTrue(){return this.countBits(!0)==this._length}get allFalse(){return this.countBits(!1)==this._length}get anyTrue(){return this.countBits(!0)>0}get anyFalse(){return this.countBits(!1)>0}findNext(t,e=!0){if(this.assureInRange(t,-1,this._length,"index"),t>=this._length-1)return-1;let n=31&(t=t<0?0:t+1);const i=this.lengthInInts;for(let o=Math.floor(t/32);o<i;o++){let i=e?this._data[o]:~this._data[o];if(0!=n)i&=4294967295<<n&4294967295,n=0;else if(!e&&-4294967296==i)continue;for(let e=0;0!=i;e+=8,i>>>=8){const n=Nt._firstOnBit[255&i];if(n>=0)return(t=n+32*o+e)>=this._length?-1:t}}return-1}findPrev(t,e=!0){if(0==t)return-1;this.assureInRange(t,-1,this._length,"index");let n=1+(t=t<0?this._length-1:t-1)&31;for(let i=Math.floor(t/32);i>=0;i--){let t=e?this._data[i]:~this._data[i];0!=n&&(t&=~(4294967295<<n),n=0);for(let e=24;0!=t;e-=8,t<<=8){const n=Nt._lastOnBit[t>>>24];if(n>=0)return n+32*i+e}}return-1}}Nt._onBitCount=Int8Array.from([0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,4,5,5,6,5,6,6,7,5,6,6,7,6,7,7,8]),Nt._firstOnBit=Int8Array.from([-1,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,7,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0]),Nt._lastOnBit=Int8Array.from([-1,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7]),s.SEMTYPE.MOLECULE,s.SEMTYPE.MACROMOLECULE,function(t){t.X="Embed_X",t.Y="Embed_Y"}(Tt||(Tt={})),n(3336);var xt=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};function Lt(t,e,n=[],o=[],s=!0){const[r,a]=Gt(t,e,n,o);return s&&!r&&i.shell.warning(a),r}function Gt(t,e,n=[],o=[]){let r=!0,a="";const l=new At.C(t);if(t.semType!==s.SEMTYPE.MACROMOLECULE)i.shell.warning(e+" analysis is allowed for Macromolecules semantic type"),r=!1;else{const t=l.notation;if(n.length>0&&!n.some((e=>t.toUpperCase()==e.toUpperCase())))a=`${e} + ' analysis is allowed for Macromolecules with notation ${0==n.length?"any notation":`notation${n.length>1?"s":""} ${n.map((t=>`"${t}"`)).join(", ")} `}.`,r=!1;else if(!l.isHelm()){const t=l.alphabet;o.length>0&&!o.some((e=>t.toUpperCase()==e.toUpperCase()))&&(a=`${e} + ' analysis is allowed for Macromolecules with alphabet ${0==o.length?"any alphabet":`alphabet${o.length>1?"s":""} ${o.map((t=>`"${t}"`)).join(", ")}.`}.`,r=!1)}}return[r,a]}function _t(t,e,r,a,l,h){return xt(this,void 0,void 0,(function*(){if(!Lt(e,"Activity Cliffs"))return;const u=P(t),c={units:e.getTag(s.TAGS.UNITS),aligned:e.getTag("aligned"),separator:e.getTag("separator"),alphabet:e.getTag("alphabet")};return yield function(t,e,r,a,l,h,u,c,d,f,m,p,g,v,y,w,b){return Z(this,void 0,void 0,(function*(){const C=u/100,S=null!=r?r:e;let T=!1,M=!1;const E={};let A,R;const P={seqCol:S,methodName:d,similarityMetric:c,embedAxesNames:a,options:b},{distance:x,coordinates:L}=yield p(P);for(const e of L)t.columns.add(e);const G=yield function(t,e,n,i){return Z(this,void 0,void 0,(function*(){const o=t.categories,r=t.getRawData(),a=s.Column.string("seq",t.length).init((t=>o[r[t]])),l=s.DataFrame.fromColumns([a]),h=t.length;let u=Array(h-1);return n?u=yield i(h,t,l,"seq",u):function(t,e,n){for(let i=0;i<t-1;++i){const o=new Float32Array(t-i-1).fill(0);for(let n=i+1;n<t;++n)o[n-i-1]=e[i][n]===s.FLOAT_NULL?0:N(e[i][n]);n[i]=s.Column.fromFloat32Array("similarity",o)}}(h,e,u),u}))}(S,x,!x||$.includes(c),g),_=function(t,e,n){const i=[],o=[],s=[],r=[],a=new Set;for(let l=0;l!=t.length;++l)for(let h=0;h!=t.length-l;++h){const u=t[l]?t[l].get(h):0;if(u>=e){s.push(l),r.push(l+h+1),a.add(l),a.add(l+h+1),i.push(u);const t=Math.abs(n.get(l)-n.get(l+h+1));1!=u?o.push(t/(1-u)):o.push(1/0)}}return{simVals:i,saliVals:o,n1:s,n2:r,cliffsMolIds:a}}(G,C,h),I=function(t,e,n,i,o,r){const a=new Array(t).fill(0);for(let t=0;t!=n.length;++t)e[t]!=1/0&&(r.get(n[t])>r.get(i[t])?a[n[t]]+=e[t]:a[i[t]]+=e[t]);return s.Column.fromList("double",`sali_${o[0].substring(o[0].lastIndexOf("_"))}`,a)}(S.length,_.saliVals,_.n1,_.n2,a,h);t.columns.add(I);const W=function(t,e){const n="containsCliff",i=t.columns.names().filter((t=>t.includes(n))).length+1,o=`${n}_${i}`;return s.Column.bool(o,t.rowCount).init((t=>e.has(t)))}(t,_.cliffsMolIds);t.columns.add(W);const F=function(t){const e=t.filter((t=>t!==1/0)),n=Math.min(...e);return{max:Math.max(...e),min:n}}(_.saliVals),k=.8/(F.max-F.min),D=i.shell.getTableView(t.name);D.grid.columns.byName(W.name).visible=!1;const V=D.addViewer(s.VIEWER.SCATTER_PLOT,{xColumnName:a[0],yColumnName:a[1],size:I.name,color:h.name,showXSelector:!1,showYSelector:!1,showSizeSelector:!1,showColorSelector:!1,markerMinSize:5,markerMaxSize:25,title:l}),H=V.getInfo().canvas,O=function(t,e,n,i,o){const r=new Array(t.n1.length).fill(null);for(let e=0;e<t.n1.length;e++){const n=t.n1[e],i=t.n2[e];r[e]={id:e,mols:[n,i],selected:!1,a:[],b:[]}}const a=s.DataFrame.create(r.length);return J.forEach(((t,n)=>{a.columns.addNewString(t).init((t=>e.get(r[t].mols[n]))),function(t,e){Object.keys(e).forEach((n=>{t.tags[n]=e[n]}))}(a.col(t),o),a.col(t).semType=i})),a.columns.addNewFloat(z).init((t=>Math.abs(n.get(r[t].mols[0])-n.get(r[t].mols[1])))),a.columns.addNewInt(j).init((t=>t)),a.columns.addNewFloat(X).init((e=>t.saliVals[e])),a.columns.addNewFloat(q).init((e=>t.simVals[e])),{lines:r,linesDf:a}}(_,e,h,f,m),Y=w?w(O.linesDf,J).sort([X],[!1]):O.linesDf.plot.grid().sort([X],[!1]);t.temp[".cliffsDfGrid"]=Y;const U=o.button(`${O.linesDf.rowCount} cliffs`,(()=>{D.dockManager.dock(Y.root,"down",null,"Activity cliffs",.2)}));U.classList.add("scatter_plot_link","cliffs_grid"),V.root.append(U);const B=o.switchInput("Show only cliffs",!1,(()=>{B.value?(V.dataFrame.setTag(Q,W.name),t.filter.copyFrom(tt(t,W.name)),K.next(W.name)):(V.dataFrame.setTag(Q,""),t.filter.setAll(!0,!0),K.next(""))}));B.root.classList.add("scatter_plot_link","show_only_cliffs"),V.root.append(B.root),K.subscribe((t=>{""!==t?t!==W.name&&(B.enabled=!1):B.enabled=!0}));const nt=i.events.onViewerClosed.subscribe((t=>{t.args.viewer===V&&(D.dockManager.close(Y.root),nt.unsubscribe(),D.subs=D.subs.filter((t=>t!==nt)))}));return D.subs.push(nt),O.linesDf.onCurrentCellChanged.subscribe((()=>{T=!0;const n=O.linesDf.currentCol&&O.linesDf.currentCol.name===J[1]?1:0,s=-1!==O.linesDf.currentRowIdx?O.lines[O.linesDf.currentRowIdx]:null;V.dataFrame.currentRowIdx=s?s.mols[n]:-1,V.dataFrame.filter.set(0,!O.lines[0].selected),V.dataFrame.filter.set(0,O.lines[0].selected),s&&setTimeout((()=>{!function(t,e,n,s,r,a,l,h){const u=e.getPane("Cliff Details");o.empty(u.root);const c=h({cashedData:n,line:s,df:t,seqCol:r,activityCol:a,sali:l});u.root.append(c),setTimeout((()=>{i.shell.o=e.root}),500)}(t,A,E,s,e,h,O.linesDf.get(X,s.id),y);const n=V.dataFrame.getSortedOrder(D.grid.sortByColumns,D.grid.sortTypes);D.grid.scrollToCell(e.name,n.indexOf(V.dataFrame.currentRowIdx))}),1e3)})),O.linesDf.onSelectionChanged.subscribe((e=>{if(!1===O.linesDf.selection.anyTrue)O.lines.forEach((t=>{t.selected=!1}));else if(-1!==O.linesDf.mouseOverRowIdx){const t=O.lines[O.linesDf.mouseOverRowIdx];t.selected=!t.selected}setTimeout((()=>{const e=s.BitSet.create(t.rowCount);O.lines.forEach((t=>{t.selected&&t.mols.forEach((n=>{e.set(n,t.selected,!0)}))})),t.selection.copyFrom(e),D.grid.invalidate()}),300)})),t.onSelectionChanged.subscribe((e=>{M?M=!1:!1===t.selection.anyTrue&&"number"==typeof e&&(O.lines.forEach((t=>{t.selected=!1})),Y.dataFrame.selection.setAll(!1,!1),Y.invalidate())})),H.addEventListener("mousemove",(function(i){clearTimeout(R),R=n.g.setTimeout((function(){const n=et(i,H,O.lines);n&&-1===t.mouseOverRowIdx&&o.tooltip.show(v({cashedData:E,line:n,df:t,seqCol:e,activityCol:h}),i.clientX,i.clientY)}),500)})),H.addEventListener("mousedown",(function(e){M=!0;const n=et(e,H,O.lines);if(n&&-1===t.mouseOverRowIdx){e.ctrlKey?(n.selected=!n.selected,O.linesDf.selection.set(n.id,n.selected)):O.linesDf.currentRowIdx!==n.id&&(O.linesDf.currentRowIdx=n.id,t.currentRowIdx=n.mols[0],t.filter.set(0,!O.lines[0].selected),t.filter.set(0,O.lines[0].selected));const i=O.linesDf.getSortedOrder(Y.sortByColumns,Y.sortTypes);Y.scrollToCell(J[0],i.indexOf(n.id))}})),V.onEvent("d4-before-draw-scene").subscribe((e=>{const n=function(t,e,n,i,o,s,r){const a=i.lines,l=t.getInfo().canvas.getContext("2d"),h=t.dataFrame.columns.byName(e),u=t.dataFrame.columns.byName(n);for(let e=0;e<a.length;e++){const n=t.worldToScreen(h.get(a[e].mols[0]),u.get(a[e].mols[0])),c=t.worldToScreen(h.get(a[e].mols[1]),u.get(a[e].mols[1]));a[e].a=[n.x,n.y],a[e].b=[c.x,c.y];const d=new Path2D;d.moveTo(a[e].a[0],a[e].a[1]);const f=a[e].selected?"255,255,0":"0,128,0",m=o[e]===1/0?1:.2+(o[e]-r)*s;l.strokeStyle=`rgba(${f},${m})`,l.lineWidth=a[e].id===i.linesDf.currentRowIdx?3:1,d.lineTo(a[e].b[0],a[e].b[1]),l.stroke(d)}return a}(V,a[0],a[1],O,_.saliVals,k,F.min);if(T){const t=n[O.linesDf.currentRowIdx];setTimeout((()=>{const{zoomLeft:e,zoomRight:n,zoomTop:i,zoomBottom:o}=function(t,e,n,i,o,s){const r=Math.abs(n-o),a=Math.abs(i-s),l=t/r,h=e/a,u=Math.min(l,h),c=t/u*5,d=e/u*5,f=(n<o?n:o)+r/2-c/2,m=(i>s?i:s)-a/2+d/2;return{zoomLeft:f,zoomRight:f+c,zoomTop:m,zoomBottom:m-d}}(V.viewport.width,V.viewport.height,V.dataFrame.get(a[0],t.mols[0]),V.dataFrame.get(a[1],t.mols[0]),V.dataFrame.get(a[0],t.mols[1]),V.dataFrame.get(a[1],t.mols[1]));V.zoom(e,i,n,o)}),300),T=!1}B.value?t.filter.copyFrom(tt(t,W.name)):!0===B.enabled&&t.filter.setAll(!0,!1)})),V.addProperty("similarityLimit","double",C),A=function(){const t=o.accordion(),e=o.element("i");return e.className="grok-icon svg-icon svg-view-layout",t.addTitle(o.span([e,o.label("Activity cliffs")])),t.addPane("Cliff Details",(()=>o.divText("Cliff has not been selected")),!0),i.shell.o=t.root,t}(),V}))}(t,e,null,u,"Activity cliffs",r,a,"Tanimoto",l,s.SEMTYPE.MACROMOLECULE,c,R,pt,gt,vt,wt,h)}))}function It(t,e,n,o="Tanimoto",r,a){return xt(this,void 0,void 0,(function*(){if(yield(0,Mt.gw)(10),!Lt(e,"Sequence space"))return;const l=P(t),h=s.DataFrame.fromColumns([e]).clone(),u=function(t,e){const n=e.categories.map(((t,e)=>t?null:e)).filter((t=>null!==t)),i=[...e.getRawData()],o=[];let s=0;for(let e=0;e<t.rowCount;e++)n.includes(i[e])&&(t.rows.removeAt(e-s),o.push(e),s+=1);return o}(h,e),c={seqCol:h.col(e.name),methodName:n,similarityMetric:o,embedAxesNames:l,options:a},d=(yield R(c)).coordinates;for(const e of d){const n=e.toList();u.forEach((t=>n.splice(t,0,null))),t.columns.add(s.Column.float(e.name,t.rowCount).init((t=>n[t])))}return r?i.shell.tableView(t.name).scatterPlot({x:l[0],y:l[1],title:"Sequence space"}):void 0}))}function Wt(t=null){var e;const n=null!==(e=null==t?void 0:t.dataFrame)&&void 0!==e?e:i.shell.t,r=null!=t?t:n.columns.bySemType(s.SEMTYPE.MACROMOLECULE);if(null==r)return void i.shell.warning("MSAError: dataset doesn't conain any Macromolecule column");let a=()=>xt(this,void 0,void 0,(function*(){return null}));const l=o.choiceInput("Method",Et.J[0],Et.J);l.setTooltip("Alignment method");const h=o.floatInput("Gap open",1.53);h.setTooltip("Gap opening penalty at group-to-group alignment");const u=o.floatInput("Gap extend",0);u.setTooltip("Gap extension penalty to skip the alignment");const c=[l.root.style,h.root.style,u.root.style],d=o.columnInput("Sequence",n,r,(()=>{const t=d.value,e=n.columns.getUnusedName(`msa(${t.name})`);if(Lt(t,t.name,["fasta"],["DNA","RNA","PT"],!1)){for(const t of c)t.display="none";a=()=>(0,T.U)(t,!1,e,f.value)}else if(Lt(t,t.name,["helm"],[],!1)){for(const t of c)t.display="initial";a=()=>(0,Et.f)(t,e,l.value,h.value,u.value,f.value)}else{for(const t of c)t.display="none";a=()=>xt(this,void 0,void 0,(function*(){return null}))}}));d.setTooltip("Sequences column to use for alignment"),d.fireChanged();const f=o.columnInput("Clusters",n,null);f.nullable=!0;let m=null;o.dialog("MSA").add(d).add(f).add(l).add(h).add(u).onOK((()=>xt(this,void 0,void 0,(function*(){if(d.fireChanged(),m=yield a(),null==m)return i.shell.warning("Wrong column format");n.columns.add(m),yield i.data.detectSemanticTypes(n)})))).show()}function Ft(t){return new bt.i(t).importFasta()}function kt(){const t=(0,St.m)(),e=function(t){const e=(0,r.Mj)(t),n=t=>{const e=a.columns.addNewString((t+1).toString());return i.push(e),e},i=[],o=t.length,a=s.DataFrame.create(o);for(let s=0;s<o;++s){const o=t.get(s);null!=o&&e(o).forEach(((t,e)=>{var o;((null!==(o=i[e])&&void 0!==o?o:null)||n(e)).set(s,t||"-",!1)}))}return a}(t),n=t.dataFrame;for(const i of e.columns){const e=n.columns.add(i);e.semType=u.Of.MONOMER,e.setTag(s.TAGS.CELL_RENDERER,u.Of.MONOMER),e.setTag("alphabet",t.getTag("alphabet"))}i.shell.tv.grid.invalidate()}function Dt(t){const e=(0,r.fy)(t,1,r.gP);return Object.keys(e.freq)}new s.Package},7983:(t,e,n)=>{"use strict";n.d(e,{HV:()=>u,QF:()=>h,pf:()=>l});var i=n(4469),o=(n(3870),n(976)),s=n(7241),r=(n(4293),n(1061)),a=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};function l(t,e,n){const i=n?function(t,e){const n=`${e}`.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),i=t.charAt(0)===e,o=t.charAt(t.length-1)===e,s=t.replace(new RegExp(`^${n}|${n}$`,"g"),"");return i?o?`${n}${s}${n}`:`${n}${s}${n}|${n}${s}$`:o?`^${s}${n}|${n}${s}${n}`:`^${s}${n}|${n}${s}${n}|${n}${s}$`}(t,n):t,s=o.BitSet.create(e.length);for(let n=0;n<e.length;n++){const o=e.get(n);(o.match(i)||o===t)&&s.set(n,!0,!1)}return s}function h(t,e){return a(this,void 0,void 0,(function*(){e.version!==e.temp["last-invalidated-version"]&&(yield u(e,!0));const n=o.Column.string("helm",1).init((e=>t));n.setTag(o.TAGS.UNITS,"helm");const r=yield(0,s.D)(n,!0,e.temp["monomers-dict"]);return(yield i.functions.call("Chem:searchSubstructure",{molStringsColumn:e.temp["monomeric-mols"],molString:r.get(0),molBlockFailover:""})).get(0)}))}function u(t,e){return a(this,void 0,void 0,(function*(){const n=o.TaskBarProgressIndicator.create(`Invalidating molfiles for ${t.name}`);yield(0,r.gw)(10);const i=new Map,a=yield(0,s.D)(t,e,i);t.temp["monomeric-mols"]=a,t.temp["monomers-dict"]=i,t.temp["last-invalidated-version"]=t.version,n.close()}))}},3553:(t,e,n)=>{"use strict";var i,o,s;n.d(e,{Of:()=>s,mU:()=>r,rs:()=>l}),function(t){t.SPLIT_COL="~split",t.ACTIVITY="~activity",t.ACTIVITY_SCALED="activity_scaled",t.ALIGNED_SEQUENCE="~aligned_sequence",t.AMINO_ACID_RESIDUE="AAR",t.POSITION="Pos",t.P_VALUE="pValue",t.MEAN_DIFFERENCE="Mean difference"}(i||(i={})),function(t){t.AAR="AAR",t.POSITION="Pos",t.SELECTION="selection"}(o||(o={})),function(t){t.MONOMER="Monomer",t.MACROMOLECULE_DIFFERENCE="MacromoleculeDifference",t.ACTIVITY="activity",t.ACTIVITY_SCALED="activityScaled"}(s||(s={}));const r="MSA";var a,l;!function(t){t.CELL_CHANGING="isCellChanging"}(a||(a={})),function(t){t.SEPARATOR="."}(l||(l={}))},4004:(t,e,n)=>{"use strict";n.d(e,{o:()=>r}),n(3870);var i=n(4469),o=(n(3336),n(7767)),s=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};function r(t,e,n){return s(this,void 0,void 0,(function*(){const s=new o.L(t).convert(e,n);t.dataFrame.columns.add(s);const r=yield i.functions.call("Bio:detectMacromolecule",{col:s});return r&&(s.semType=r),yield i.data.detectSemanticTypes(t.dataFrame),s}))}},1345:(t,e,n)=>{"use strict";n.d(e,{RV:()=>l,rb:()=>h});var i=n(976),o=n(4469),s=n(701),r=n(7228),a=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};const l="Libraries",h={"HELMCoreLibrary.json":"HELMCoreLibrary.json"};class u{constructor(t){this._monomers={},this._onChanged=new s.Subject,this._monomers=t}getMonomer(t,e){return t in this._monomers&&e in this._monomers[t]?this._monomers[t][e]:null}getTypes(){return Object.keys(this._monomers)}getMonomerMolsByType(t){const e={};return Object.keys(this._monomers[t]).forEach((n=>{e[n]=this._monomers[t][n].molfile})),e}getMonomerNamesByType(t){return Object.keys(this._monomers[t])}get onChanged(){return this._onChanged}_updateInt(t){const e=t.getTypes(),n=this.getTypes();e.forEach((e=>{n.includes(e)||(this._monomers[e]={}),t.getMonomerNamesByType(e).forEach((n=>{this._monomers[e][n]=t.getMonomer(e,n)}))}))}update(t){this._updateInt(t),this._onChanged.next()}updateLibs(t,e=!1){e&&(this._monomers={});for(const e of t)this._updateInt(e);this._onChanged.next()}clear(){this._monomers={},this._onChanged.next()}}class c{constructor(){this._monomerLib=new u({}),this.loadLibrariesPromise=Promise.resolve()}getBioLib(){return this._monomerLib}loadLibraries(t=!1){return a(this,void 0,void 0,(function*(){return this.loadLibrariesPromise=this.loadLibrariesPromise.then((()=>a(this,void 0,void 0,(function*(){const e=Object.keys(yield o.dapi.userDataStorage.get(l,!0)),n=yield Promise.all(e.map((t=>this.readLibrary("System:AppData/Bio/libraries/",t))));this._monomerLib.updateLibs(n,t)}))))}))}readLibrary(t,e){return a(this,void 0,void 0,(function*(){let n,s,a=[];const l=new i.FileSource(t);if(e.endsWith(".sdf"))1===i.Func.find({package:"Chem",name:"importSdf"}).length?(n=yield l.readAsBytes(e),s=yield o.functions.call("Chem:importSdf",{bytes:n}),a=(0,r.Xk)(s[0])):o.shell.warning("Chem package is not installed");else{const t=yield l.readAsText(e);a=JSON.parse(t)}const h={},c=[];return a.forEach((t=>{const e={symbol:t.symbol,name:t.name,naturalAnalog:t.naturalAnalog,molfile:t.molfile,rgroups:t.rgroups,polymerType:t.polymerType,monomerType:t.monomerType,data:{}};Object.keys(t).forEach((n=>{r.DC.includes(n)||(e.data[n]=t[n])})),c.includes(t.polymerType)||(h[t.polymerType]={},c.push(t.polymerType)),h[t.polymerType][t.symbol]=e})),new u(h)}))}static get instance(){return c._instance||(c._instance=new c),c._instance}}c._instance=null},6098:(t,e,n)=>{"use strict";n.d(e,{U:()=>I});var i=n(976),o=n(5226);const s=Symbol("Comlink.proxy"),r=Symbol("Comlink.endpoint"),a=Symbol("Comlink.releaseProxy"),l=Symbol("Comlink.thrown"),h=t=>"object"==typeof t&&null!==t||"function"==typeof t,u=new Map([["proxy",{canHandle:t=>h(t)&&t[s],serialize(t){const{port1:e,port2:n}=new MessageChannel;return c(t,e),[n,[n]]},deserialize:t=>(t.start(),f(t))}],["throw",{canHandle:t=>h(t)&&l in t,serialize({value:t}){let e;return e=t instanceof Error?{isError:!0,value:{message:t.message,name:t.name,stack:t.stack}}:{isError:!1,value:t},[e,[]]},deserialize(t){throw t.isError?Object.assign(new Error(t.value.message),t.value):t.value}}]]);function c(t,e=self){e.addEventListener("message",(function n(i){if(!i||!i.data)return;const{id:o,type:r,path:a}=Object.assign({path:[]},i.data),h=(i.data.argumentList||[]).map(b);let u;try{const e=a.slice(0,-1).reduce(((t,e)=>t[e]),t),n=a.reduce(((t,e)=>t[e]),t);switch(r){case"GET":u=n;break;case"SET":e[a.slice(-1)[0]]=b(i.data.value),u=!0;break;case"APPLY":u=n.apply(e,h);break;case"CONSTRUCT":u=function(t){return Object.assign(t,{[s]:!0})}(new n(...h));break;case"ENDPOINT":{const{port1:e,port2:n}=new MessageChannel;c(t,n),u=function(t,e){return y.set(t,e),t}(e,[e])}break;case"RELEASE":u=void 0;break;default:return}}catch(t){u={value:t,[l]:0}}Promise.resolve(u).catch((t=>({value:t,[l]:0}))).then((t=>{const[i,s]=w(t);e.postMessage(Object.assign(Object.assign({},i),{id:o}),s),"RELEASE"===r&&(e.removeEventListener("message",n),d(e))}))})),e.start&&e.start()}function d(t){(function(t){return"MessagePort"===t.constructor.name})(t)&&t.close()}function f(t,e){return p(t,[],e)}function m(t){if(t)throw new Error("Proxy has been released and is not useable")}function p(t,e=[],n=function(){}){let i=!1;const o=new Proxy(n,{get(n,s){if(m(i),s===a)return()=>C(t,{type:"RELEASE",path:e.map((t=>t.toString()))}).then((()=>{d(t),i=!0}));if("then"===s){if(0===e.length)return{then:()=>o};const n=C(t,{type:"GET",path:e.map((t=>t.toString()))}).then(b);return n.then.bind(n)}return p(t,[...e,s])},set(n,o,s){m(i);const[r,a]=w(s);return C(t,{type:"SET",path:[...e,o].map((t=>t.toString())),value:r},a).then(b)},apply(n,o,s){m(i);const a=e[e.length-1];if(a===r)return C(t,{type:"ENDPOINT"}).then(b);if("bind"===a)return p(t,e.slice(0,-1));const[l,h]=v(s);return C(t,{type:"APPLY",path:e.map((t=>t.toString())),argumentList:l},h).then(b)},construct(n,o){m(i);const[s,r]=v(o);return C(t,{type:"CONSTRUCT",path:e.map((t=>t.toString())),argumentList:s},r).then(b)}});return o}function g(t){return Array.prototype.concat.apply([],t)}function v(t){const e=t.map(w);return[e.map((t=>t[0])),g(e.map((t=>t[1])))]}const y=new WeakMap;function w(t){for(const[e,n]of u)if(n.canHandle(t)){const[i,o]=n.serialize(t);return[{type:"HANDLER",name:e,value:i},o]}return[{type:"RAW",value:t},y.get(t)||[]]}function b(t){switch(t.type){case"HANDLER":return u.get(t.name).deserialize(t.value);case"RAW":return t.value}}function C(t,e,n){return new Promise((i=>{const o=new Array(4).fill(0).map((()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16))).join("-");t.addEventListener("message",(function e(n){!n.data||!n.data.id||n.data.id!==o||(t.removeEventListener("message",e),i(n.data))})),t.start&&t.start(),t.postMessage(Object.assign({id:o},e),n)}))}const S="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2NvbnN0ICQ9U3ltYm9sKCJDb21saW5rLnByb3h5IiksQT1TeW1ib2woIkNvbWxpbmsuZW5kcG9pbnQiKSxSPVN5bWJvbCgiQ29tbGluay5yZWxlYXNlUHJveHkiKSx5PVN5bWJvbCgiQ29tbGluay50aHJvd24iKSxfPWU9PnR5cGVvZiBlPT0ib2JqZWN0IiYmZSE9PW51bGx8fHR5cGVvZiBlPT0iZnVuY3Rpb24iLEw9e2NhbkhhbmRsZTplPT5fKGUpJiZlWyRdLHNlcmlhbGl6ZShlKXtjb25zdHtwb3J0MTpyLHBvcnQyOml9PW5ldyBNZXNzYWdlQ2hhbm5lbDtyZXR1cm4gdyhlLHIpLFtpLFtpXV19LGRlc2VyaWFsaXplKGUpe3JldHVybiBlLnN0YXJ0KCksQyhlKX19LE89e2NhbkhhbmRsZTplPT5fKGUpJiZ5IGluIGUsc2VyaWFsaXplKHt2YWx1ZTplfSl7bGV0IHI7cmV0dXJuIGUgaW5zdGFuY2VvZiBFcnJvcj9yPXtpc0Vycm9yOiEwLHZhbHVlOnttZXNzYWdlOmUubWVzc2FnZSxuYW1lOmUubmFtZSxzdGFjazplLnN0YWNrfX06cj17aXNFcnJvcjohMSx2YWx1ZTplfSxbcixbXV19LGRlc2VyaWFsaXplKGUpe3Rocm93IGUuaXNFcnJvcj9PYmplY3QuYXNzaWduKG5ldyBFcnJvcihlLnZhbHVlLm1lc3NhZ2UpLGUudmFsdWUpOmUudmFsdWV9fSxFPW5ldyBNYXAoW1sicHJveHkiLExdLFsidGhyb3ciLE9dXSk7ZnVuY3Rpb24gdyhlLHI9c2VsZil7ci5hZGRFdmVudExpc3RlbmVyKCJtZXNzYWdlIixmdW5jdGlvbiBpKHMpe2lmKCFzfHwhcy5kYXRhKXJldHVybjtjb25zdHtpZDpvLHR5cGU6YSxwYXRoOm59PU9iamVjdC5hc3NpZ24oe3BhdGg6W119LHMuZGF0YSksdT0ocy5kYXRhLmFyZ3VtZW50TGlzdHx8W10pLm1hcChtKTtsZXQgbDt0cnl7Y29uc3QgYz1uLnNsaWNlKDAsLTEpLnJlZHVjZSgoZCxoKT0+ZFtoXSxlKSxmPW4ucmVkdWNlKChkLGgpPT5kW2hdLGUpO3N3aXRjaChhKXtjYXNlIkdFVCI6bD1mO2JyZWFrO2Nhc2UiU0VUIjpjW24uc2xpY2UoLTEpWzBdXT1tKHMuZGF0YS52YWx1ZSksbD0hMDticmVhaztjYXNlIkFQUExZIjpsPWYuYXBwbHkoYyx1KTticmVhaztjYXNlIkNPTlNUUlVDVCI6e2NvbnN0IGQ9bmV3IGYoLi4udSk7bD16KGQpfWJyZWFrO2Nhc2UiRU5EUE9JTlQiOntjb25zdHtwb3J0MTpkLHBvcnQyOmh9PW5ldyBNZXNzYWdlQ2hhbm5lbDt3KGUsaCksbD1OKGQsW2RdKX1icmVhaztjYXNlIlJFTEVBU0UiOmw9dm9pZCAwO2JyZWFrO2RlZmF1bHQ6cmV0dXJufX1jYXRjaChjKXtsPXt2YWx1ZTpjLFt5XTowfX1Qcm9taXNlLnJlc29sdmUobCkuY2F0Y2goYz0+KHt2YWx1ZTpjLFt5XTowfSkpLnRoZW4oYz0+e2NvbnN0W2YsZF09UyhjKTtyLnBvc3RNZXNzYWdlKE9iamVjdC5hc3NpZ24oT2JqZWN0LmFzc2lnbih7fSxmKSx7aWQ6b30pLGQpLGE9PT0iUkVMRUFTRSImJihyLnJlbW92ZUV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLGkpLEYocikpfSl9KSxyLnN0YXJ0JiZyLnN0YXJ0KCl9ZnVuY3Rpb24gVChlKXtyZXR1cm4gZS5jb25zdHJ1Y3Rvci5uYW1lPT09Ik1lc3NhZ2VQb3J0In1mdW5jdGlvbiBGKGUpe1QoZSkmJmUuY2xvc2UoKX1mdW5jdGlvbiBDKGUscil7cmV0dXJuIGIoZSxbXSxyKX1mdW5jdGlvbiBwKGUpe2lmKGUpdGhyb3cgbmV3IEVycm9yKCJQcm94eSBoYXMgYmVlbiByZWxlYXNlZCBhbmQgaXMgbm90IHVzZWFibGUiKX1mdW5jdGlvbiBiKGUscj1bXSxpPWZ1bmN0aW9uKCl7fSl7bGV0IHM9ITE7Y29uc3Qgbz1uZXcgUHJveHkoaSx7Z2V0KGEsbil7aWYocChzKSxuPT09UilyZXR1cm4oKT0+ZyhlLHt0eXBlOiJSRUxFQVNFIixwYXRoOnIubWFwKHU9PnUudG9TdHJpbmcoKSl9KS50aGVuKCgpPT57RihlKSxzPSEwfSk7aWYobj09PSJ0aGVuIil7aWYoci5sZW5ndGg9PT0wKXJldHVybnt0aGVuOigpPT5vfTtjb25zdCB1PWcoZSx7dHlwZToiR0VUIixwYXRoOnIubWFwKGw9PmwudG9TdHJpbmcoKSl9KS50aGVuKG0pO3JldHVybiB1LnRoZW4uYmluZCh1KX1yZXR1cm4gYihlLFsuLi5yLG5dKX0sc2V0KGEsbix1KXtwKHMpO2NvbnN0W2wsY109Uyh1KTtyZXR1cm4gZyhlLHt0eXBlOiJTRVQiLHBhdGg6Wy4uLnIsbl0ubWFwKGY9PmYudG9TdHJpbmcoKSksdmFsdWU6bH0sYykudGhlbihtKX0sYXBwbHkoYSxuLHUpe3Aocyk7Y29uc3QgbD1yW3IubGVuZ3RoLTFdO2lmKGw9PT1BKXJldHVybiBnKGUse3R5cGU6IkVORFBPSU5UIn0pLnRoZW4obSk7aWYobD09PSJiaW5kIilyZXR1cm4gYihlLHIuc2xpY2UoMCwtMSkpO2NvbnN0W2MsZl09TSh1KTtyZXR1cm4gZyhlLHt0eXBlOiJBUFBMWSIscGF0aDpyLm1hcChkPT5kLnRvU3RyaW5nKCkpLGFyZ3VtZW50TGlzdDpjfSxmKS50aGVuKG0pfSxjb25zdHJ1Y3QoYSxuKXtwKHMpO2NvbnN0W3UsbF09TShuKTtyZXR1cm4gZyhlLHt0eXBlOiJDT05TVFJVQ1QiLHBhdGg6ci5tYXAoYz0+Yy50b1N0cmluZygpKSxhcmd1bWVudExpc3Q6dX0sbCkudGhlbihtKX19KTtyZXR1cm4gb31mdW5jdGlvbiBEKGUpe3JldHVybiBBcnJheS5wcm90b3R5cGUuY29uY2F0LmFwcGx5KFtdLGUpfWZ1bmN0aW9uIE0oZSl7Y29uc3Qgcj1lLm1hcChTKTtyZXR1cm5bci5tYXAoaT0+aVswXSksRChyLm1hcChpPT5pWzFdKSldfWNvbnN0IFA9bmV3IFdlYWtNYXA7ZnVuY3Rpb24gTihlLHIpe3JldHVybiBQLnNldChlLHIpLGV9ZnVuY3Rpb24geihlKXtyZXR1cm4gT2JqZWN0LmFzc2lnbihlLHtbJF06ITB9KX1mdW5jdGlvbiBTKGUpe2Zvcihjb25zdFtyLGldb2YgRSlpZihpLmNhbkhhbmRsZShlKSl7Y29uc3RbcyxvXT1pLnNlcmlhbGl6ZShlKTtyZXR1cm5be3R5cGU6IkhBTkRMRVIiLG5hbWU6cix2YWx1ZTpzfSxvXX1yZXR1cm5be3R5cGU6IlJBVyIsdmFsdWU6ZX0sUC5nZXQoZSl8fFtdXX1mdW5jdGlvbiBtKGUpe3N3aXRjaChlLnR5cGUpe2Nhc2UiSEFORExFUiI6cmV0dXJuIEUuZ2V0KGUubmFtZSkuZGVzZXJpYWxpemUoZS52YWx1ZSk7Y2FzZSJSQVciOnJldHVybiBlLnZhbHVlfX1mdW5jdGlvbiBnKGUscixpKXtyZXR1cm4gbmV3IFByb21pc2Uocz0+e2NvbnN0IG89VSgpO2UuYWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsZnVuY3Rpb24gYShuKXshbi5kYXRhfHwhbi5kYXRhLmlkfHxuLmRhdGEuaWQhPT1vfHwoZS5yZW1vdmVFdmVudExpc3RlbmVyKCJtZXNzYWdlIixhKSxzKG4uZGF0YSkpfSksZS5zdGFydCYmZS5zdGFydCgpLGUucG9zdE1lc3NhZ2UoT2JqZWN0LmFzc2lnbih7aWQ6b30sciksaSl9KX1mdW5jdGlvbiBVKCl7cmV0dXJuIG5ldyBBcnJheSg0KS5maWxsKDApLm1hcCgoKT0+TWF0aC5mbG9vcihNYXRoLnJhbmRvbSgpKk51bWJlci5NQVhfU0FGRV9JTlRFR0VSKS50b1N0cmluZygxNikpLmpvaW4oIi0iKX1jb25zdCBXPWFzeW5jKCk9PldlYkFzc2VtYmx5LnZhbGlkYXRlKG5ldyBVaW50OEFycmF5KFswLDk3LDExNSwxMDksMSwwLDAsMCwxLDUsMSw5NiwwLDEsMTIzLDMsMiwxLDAsMTAsMTAsMSw4LDAsNjUsMCwyNTMsMTUsMjUzLDk4LDExXSkpLHg9ImVhZ2VyIixrPSJsYXp5IixqPXtzc3c6WyJzaW1kIl0sbWluaW1hcDI6WyJzaW1kIl19LHQ9e3Rvb2xzOltdLGNvbmZpZzp7fSxmaWxlczpbXSxiYXNlOnt9LGZzOnt9LGFzeW5jIGluaXQoKXtpZih0LnRvb2xzLmxlbmd0aD09PTApdGhyb3ciRXhwZWN0aW5nIGF0IGxlYXN0IDEgdG9vbC4iO2lmKG5ldyBTZXQodC50b29scy5tYXAocj0+YCR7ci50b29sfS8ke3IucHJvZ3JhbXx8ci50b29sfWApKS5zaXplIT09dC50b29scy5sZW5ndGgpdGhyb3ciRm91bmQgZHVwbGljYXRlIHRvb2xzOyBjYW4gb25seSBoYXZlIGVhY2ggdG9vbC9wcm9ncmFtIGNvbWJpbmF0aW9uIGF0IG1vc3Qgb25jZS4iO2lmKHQuYmFzZT10LnRvb2xzLmZpbmQocj0+ci5yZWluaXQhPT0hMCksIXQuYmFzZSl0aHJvdyJDb3VsZCBub3QgZmluZCBhIHRvb2wgd2l0aCBgcmVpbml0OiBmYWxzZWAgdG8gdXNlIGFzIHRoZSBiYXNlIG1vZHVsZS4gVG8gZml4IHRoaXMgaXNzdWUsIGluY2x1ZGUgdGhlIHRvb2wgYGJhc2UvMS4wLjBgIHdoZW4gaW5pdGlhbGl6aW5nIEFpb2xpLiI7cmV0dXJuIHQuYmFzZS5pc0Jhc2VNb2R1bGU9ITAsYXdhaXQgdGhpcy5fc2V0dXAodC5iYXNlKSxhd2FpdCB0aGlzLl9pbml0TW9kdWxlcygpLHQuX2xvZygiUmVhZHkiKSwhMH0sYXN5bmMgX2luaXRNb2R1bGVzKCl7YXdhaXQgUHJvbWlzZS5hbGwodC50b29scy5tYXAodGhpcy5fc2V0dXApKSxhd2FpdCB0aGlzLl9zZXR1cEZTKCl9LG1vdW50KGU9W10pe2NvbnN0IHI9YCR7dC5jb25maWcuZGlyU2hhcmVkfSR7dC5jb25maWcuZGlyRGF0YX1gLGk9YCR7dC5jb25maWcuZGlyU2hhcmVkfSR7dC5jb25maWcuZGlyTW91bnRlZH1gO2xldCBzPVtdLG89W10sYT1bXTshQXJyYXkuaXNBcnJheShlKSYmIShlIGluc3RhbmNlb2YgRmlsZUxpc3QpJiYoZT1bZV0pLHQuX2xvZyhgTW91bnRpbmcgJHtlLmxlbmd0aH0gZmlsZXNgKTtmb3IobGV0IG4gb2YgZSl7aWYobiBpbnN0YW5jZW9mIEZpbGV8fChuPT1udWxsP3ZvaWQgMDpuLmRhdGEpaW5zdGFuY2VvZiBCbG9iJiZuLm5hbWV8fHR5cGVvZihuPT1udWxsP3ZvaWQgMDpuLmRhdGEpPT0ic3RyaW5nIiYmbi5uYW1lKXR5cGVvZihuPT1udWxsP3ZvaWQgMDpuLmRhdGEpPT0ic3RyaW5nIiYmKG4uZGF0YT1uZXcgQmxvYihbbi5kYXRhXSx7dHlwZToidGV4dC9wbGFpbiJ9KSkscy5wdXNoKG4pO2Vsc2UgaWYobi5uYW1lJiZuLnVybClvLnB1c2gobik7ZWxzZSBpZih0eXBlb2Ygbj09InN0cmluZyImJm4uc3RhcnRzV2l0aCgiaHR0cCIpKW49e3VybDpuLG5hbWU6bi5zcGxpdCgiLy8iKS5wb3AoKS5yZXBsYWNlKC9cLy9nLCItIil9LG8ucHVzaChuKTtlbHNlIHRocm93J0Nhbm5vdCBtb3VudCBmaWxlKHMpIHNwZWNpZmllZC4gTXVzdCBiZSBhIEZpbGUsIEJsb2IsIGEgVVJMIHN0cmluZywgb3IgeyBuYW1lOiAiZmlsZS50eHQiLCBkYXRhOiAic3RyaW5nIiB9Lic7YS5wdXNoKG4ubmFtZSl9dHJ5e3QuZnMudW5tb3VudChpKX1jYXRjaHt9Zm9yKGxldCBuIG9mIG8pdC5mcy5jcmVhdGVMYXp5RmlsZShyLG4ubmFtZSxuLnVybCwhMCwhMCk7cmV0dXJuIHQuZmlsZXM9dC5maWxlcy5jb25jYXQocyksdC5iYXNlLm1vZHVsZS5GUy5tb3VudCh0LmJhc2UubW9kdWxlLldPUktFUkZTLHtmaWxlczp0LmZpbGVzLmZpbHRlcihuPT5uIGluc3RhbmNlb2YgRmlsZSksYmxvYnM6dC5maWxlcy5maWx0ZXIobj0+KG49PW51bGw/dm9pZCAwOm4uZGF0YSlpbnN0YW5jZW9mIEJsb2IpfSxpKSxzLm1hcChuPT57Y29uc3QgdT1gJHtpfS8ke24ubmFtZX1gLGw9YCR7cn0vJHtuLm5hbWV9YDt0cnl7dC5mcy51bmxpbmsobCl9Y2F0Y2h7fXQuX2xvZyhgQ3JlYXRpbmcgc3ltbGluazogJHtsfSAtLT4gJHt1fWApLHQuZnMuc3ltbGluayh1LGwpfSksYS5tYXAobj0+YCR7cn0vJHtufWApfSxhc3luYyBleGVjKGUscj1udWxsKXtpZih0Ll9sb2coYEV4ZWN1dGluZyAlYyR7ZX0lYyBhcmdzPSR7cn1gLCJjb2xvcjpkYXJrYmx1ZTsgZm9udC13ZWlnaHQ6Ym9sZCIsIiIpLCFlKXRocm93IkV4cGVjdGluZyBhIGNvbW1hbmQiO2xldCBpPWU7cj09bnVsbCYmKHI9ZS5zcGxpdCgiICIpLGk9ci5zaGlmdCgpKTtjb25zdCBzPXQudG9vbHMuZmluZChhPT57dmFyIHU7bGV0IG49aTtyZXR1cm4oKHU9YT09bnVsbD92b2lkIDA6YS5mZWF0dXJlcyk9PW51bGw/dm9pZCAwOnUuc2ltZCk9PT0hMCYmKG49YCR7bn0tc2ltZGApLGEucHJvZ3JhbT09bn0pO2lmKHM9PW51bGwpdGhyb3dgUHJvZ3JhbSAke2l9IG5vdCBmb3VuZC5gO3Muc3Rkb3V0PSIiLHMuc3RkZXJyPSIiLHMubG9hZGluZz09ayYmKHMubG9hZGluZz14LGF3YWl0IHRoaXMuX2luaXRNb2R1bGVzKCkpO3RyeXtzLm1vZHVsZS5jYWxsTWFpbihyKX1jYXRjaChhKXtjb25zb2xlLmVycm9yKGEpfXRyeXtzLm1vZHVsZS5GUy5jbG9zZShzLm1vZHVsZS5GUy5zdHJlYW1zWzFdKSxzLm1vZHVsZS5GUy5jbG9zZShzLm1vZHVsZS5GUy5zdHJlYW1zWzJdKX1jYXRjaHt9cy5tb2R1bGUuRlMuc3RyZWFtc1sxXT1zLm1vZHVsZS5GUy5vcGVuKCIvZGV2L3N0ZG91dCIsInciKSxzLm1vZHVsZS5GUy5zdHJlYW1zWzJdPXMubW9kdWxlLkZTLm9wZW4oIi9kZXYvc3RkZXJyIiwidyIpO2xldCBvPXtzdGRvdXQ6cy5zdGRvdXQsc3RkZXJyOnMuc3RkZXJyfTtpZih0LmNvbmZpZy5wcmludEludGVybGVhdmVkJiYobz1zLnN0ZG91dCkscy5yZWluaXQ9PT0hMCl7Y29uc3QgYT10LmJhc2UubW9kdWxlLkZTLmN3ZCgpO09iamVjdC5hc3NpZ24ocyxzLmNvbmZpZykscy5yZWFkeT0hMSxhd2FpdCB0aGlzLmluaXQoKSxzLmlzQmFzZU1vZHVsZSYmdGhpcy5tb3VudCgpLHRoaXMuY2QoYSl9cmV0dXJuIG99LGNhdChlKXtyZXR1cm4gdC5fZmlsZW9wKCJjYXQiLGUpfSxscyhlKXtyZXR1cm4gdC5fZmlsZW9wKCJscyIsZSl9LGRvd25sb2FkKGUpe3JldHVybiB0Ll9maWxlb3AoImRvd25sb2FkIixlKX0scHdkKCl7cmV0dXJuIHQuZnMuY3dkKCl9LGNkKGUpe2ZvcihsZXQgciBvZiB0LnRvb2xzKSFyLm1vZHVsZXx8ci5tb2R1bGUuRlMuY2hkaXIoZSl9LG1rZGlyKGUpe3JldHVybiB0LmZzLm1rZGlyKGUpLCEwfSxyZWFkKHtwYXRoOmUsbGVuZ3RoOnIsZmxhZzppPSJyIixvZmZzZXQ6cz0wLHBvc2l0aW9uOm89MH0pe2NvbnN0IGE9dC5mcy5vcGVuKGUsaSksbj1uZXcgVWludDhBcnJheShyKTtyZXR1cm4gdC5mcy5yZWFkKGEsbixzLHIsbyksdC5mcy5jbG9zZShhKSxufSx3cml0ZSh7cGF0aDplLGJ1ZmZlcjpyLGZsYWc6aT0idysiLG9mZnNldDpzPTAscG9zaXRpb246bz0wfSl7Y29uc3QgYT10LmZzLm9wZW4oZSxpKTt0LmZzLndyaXRlKGEscixzLHIubGVuZ3RoLG8pLHQuZnMuY2xvc2UoYSl9LF9zdGRpblR4dDoiIixfc3RkaW5QdHI6MCxnZXQgc3RkaW4oKXtyZXR1cm4gdC5fc3RkaW5UeHR9LHNldCBzdGRpbihlPSIiKXt0Ll9sb2coYFNldHRpbmcgc3RkaW4gdG8gJWMke2V9JWNgLCJjb2xvcjpkYXJrYmx1ZSIsIiIpLHQuX3N0ZGluVHh0PWUsdC5fc3RkaW5QdHI9MH0sYXN5bmMgX3NldHVwKGUpe2lmKGUucmVhZHkpcmV0dXJuO2lmKHQuX2xvZyhgU2V0dGluZyB1cCAke2UudG9vbH0gKGJhc2UgPSAke2UuaXNCYXNlTW9kdWxlPT09ITB9KS4uLmApLGUuY29uZmlnPU9iamVjdC5hc3NpZ24oe30sZSksZS51cmxQcmVmaXh8fChlLnVybFByZWZpeD1gJHt0LmNvbmZpZy51cmxDRE59LyR7ZS50b29sfS8ke2UudmVyc2lvbn1gKSxlLnByb2dyYW18fChlLnByb2dyYW09ZS50b29sKSxlLmZlYXR1cmVzfHwoZS5mZWF0dXJlcz17fSwoaltlLnByb2dyYW1dfHxbXSkuaW5jbHVkZXMoInNpbWQiKSYmKGF3YWl0IFcoKT8oZS5wcm9ncmFtKz0iLXNpbWQiLGUuZmVhdHVyZXMuc2ltZD0hMCk6dC5fbG9nKGBXZWJBc3NlbWJseSBTSU1EIGlzIG5vdCBzdXBwb3J0ZWQgaW4gdGhpcyBicm93c2VyOyB3aWxsIGxvYWQgbm9uLVNJTUQgdmVyc2lvbiBvZiAke2UucHJvZ3JhbX0uYCkpKSxlLmlzQmFzZU1vZHVsZSYmKGUubG9hZGluZz14KSxlLmxvYWRpbmc9PT1rKXt0Ll9sb2coYFdpbGwgbGF6eS1sb2FkICR7ZS50b29sfTsgc2tpcHBpbmcgaW5pdGlhbGl6YXRpb24uYCk7cmV0dXJufXNlbGYuaW1wb3J0U2NyaXB0cyhgJHtlLnVybFByZWZpeH0vJHtlLnByb2dyYW19LmpzYCksZS5tb2R1bGU9YXdhaXQgTW9kdWxlKHt0aGlzUHJvZ3JhbTplLnByb2dyYW0sbG9jYXRlRmlsZTooaSxzKT0+YCR7ZS51cmxQcmVmaXh9LyR7aX1gLHN0ZGluOigpPT50Ll9zdGRpblB0cjx0LnN0ZGluLmxlbmd0aD90LnN0ZGluLmNoYXJDb2RlQXQodC5fc3RkaW5QdHIrKyk6KHQuc3RkaW49IiIsbnVsbCkscHJpbnQ6aT0+ZS5zdGRvdXQrPWAke2l9CmAscHJpbnRFcnI6dC5jb25maWcucHJpbnRJbnRlcmxlYXZlZD9pPT5lLnN0ZG91dCs9YCR7aX0KYDppPT5lLnN0ZGVycis9YCR7aX0KYH0pO2NvbnN0IHI9ZS5tb2R1bGUuRlM7ZS5pc0Jhc2VNb2R1bGU/KHQuX2xvZyhgU2V0dGluZyB1cCAke2UudG9vbH0gd2l0aCBiYXNlIG1vZHVsZSBmaWxlc3lzdGVtLi4uYCksci5ta2Rpcih0LmNvbmZpZy5kaXJTaGFyZWQsNTExKSxyLm1rZGlyKGAke3QuY29uZmlnLmRpclNoYXJlZH0vJHt0LmNvbmZpZy5kaXJEYXRhfWAsNTExKSxyLm1rZGlyKGAke3QuY29uZmlnLmRpclNoYXJlZH0vJHt0LmNvbmZpZy5kaXJNb3VudGVkfWAsNTExKSxyLmNoZGlyKGAke3QuY29uZmlnLmRpclNoYXJlZH0vJHt0LmNvbmZpZy5kaXJEYXRhfWApLHQuZnM9cik6KHQuX2xvZyhgU2V0dGluZyB1cCAke2UudG9vbH0gd2l0aCBmaWxlc3lzdGVtLi4uYCksci5ta2Rpcih0LmNvbmZpZy5kaXJTaGFyZWQpLHIubW91bnQoZS5tb2R1bGUuUFJPWFlGUyx7cm9vdDp0LmNvbmZpZy5kaXJTaGFyZWQsZnM6dC5mc30sdC5jb25maWcuZGlyU2hhcmVkKSxyLmNoZGlyKHQuZnMuY3dkKCkpKSxlLnN0ZG91dD0iIixlLnN0ZGVycj0iIixlLnJlYWR5PSEwfSxhc3luYyBfc2V0dXBGUygpe2NvbnN0IGU9dC5mcztmb3IobGV0IHIgb2YgdC50b29scyl7aWYoIXIucmVhZHkpY29udGludWU7Y29uc3QgaT1yLm1vZHVsZS5GUyxzPWAvJHtyLnRvb2x9YCxvPWAke3QuY29uZmlnLmRpclNoYXJlZH0ke3N9YDshaS5hbmFseXplUGF0aChzKS5leGlzdHN8fGUuYW5hbHl6ZVBhdGgobykuZXhpc3RzfHwodC5fbG9nKGBNb3VudGluZyAke3N9IG9udG8gJHt0LmJhc2UudG9vbH0gZmlsZXN5c3RlbSBhdCAke299YCksZS5ta2RpcihvKSxlLm1vdW50KHQuYmFzZS5tb2R1bGUuUFJPWFlGUyx7cm9vdDpzLGZzOml9LG8pKX19LF9maWxlb3AoZSxyKXt0Ll9sb2coYFJ1bm5pbmcgJHtlfSAke3J9YCk7Y29uc3QgaT10LmZzLmFuYWx5emVQYXRoKHIpO2lmKCFpLmV4aXN0cylyZXR1cm4gdC5fbG9nKGBGaWxlICR7cn0gbm90IGZvdW5kLmApLCExO3N3aXRjaChlKXtjYXNlImNhdCI6cmV0dXJuIHQuZnMucmVhZEZpbGUocix7ZW5jb2Rpbmc6InV0ZjgifSk7Y2FzZSJscyI6cmV0dXJuIHQuZnMuaXNGaWxlKGkub2JqZWN0Lm1vZGUpP3QuZnMuc3RhdChyKTp0LmZzLnJlYWRkaXIocik7Y2FzZSJkb3dubG9hZCI6Y29uc3Qgcz1uZXcgQmxvYihbdGhpcy5jYXQocildKTtyZXR1cm4gVVJMLmNyZWF0ZU9iamVjdFVSTChzKX1yZXR1cm4hMX0sX2xvZyhlKXtpZighdC5jb25maWcuZGVidWcpcmV0dXJuO2xldCByPVsuLi5hcmd1bWVudHNdO3Iuc2hpZnQoKSxjb25zb2xlLmxvZyhgJWNbV2ViV29ya2VyXSVjICR7ZX1gLCJmb250LXdlaWdodDpib2xkIiwiIiwuLi5yKX19O3codCl9KSgpOwo=",T=typeof window<"u"&&window.Blob&&new Blob([atob(S)],{type:"text/javascript;charset=utf-8"});function M(){const t=T&&(window.URL||window.webkitURL).createObjectURL(T);try{return t?new Worker(t):new Worker("data:application/javascript;base64,"+S)}finally{t&&(window.URL||window.webkitURL).revokeObjectURL(t)}}const E={urlCDN:"https://biowasm.com/cdn/v3",urlCDNStg:"https://stg.biowasm.com/cdn/v3",dirShared:"/shared",dirMounted:"/mnt",dirData:"/data",printInterleaved:!0,callback:null,debug:!1,env:"prd"};class A{constructor(t,e={}){if(null==t)throw"Expecting array of tools as input to Aioli constructor.";return Array.isArray(t)||(t=[t]),e=Object.assign({},E,e),t=t.map(this._parseTool),"stg"===e.env&&(e.urlCDN=e.urlCDNStg),this.tools=t,this.config=e,null!=this.config.callback&&(this.callback=this.config.callback),delete this.config.callback,this.init()}async init(){const t=new M;this.callback&&(t.onmessage=t=>{"biowasm"===t.data.type&&this.callback(t.data.value)});const e=f(t);return e.tools=this.tools,e.config=this.config,await e.init(),e}_parseTool(t){if("string"!=typeof t)return t;const e=t.split("/");if(2!=e.length&&3!=e.length)throw"Expecting '<tool>/<version>' or '<tool>/<program>/<version>'";return{tool:e[0],program:3==e.length?e[1]:e[0],version:e[e.length-1]}}}var R=n(850);class P{static getAvailableScales(){return Object.entries(this.scales).map((([t,e])=>t))}static getScale(t){return(0,R.hu)(!(void 0===this.scales[t]),`Scale '${t}' was not found.`),this.scales[t]}}P.scales={WimleyWhite:{"-":0,A:.17,C:-.24,D:-.07,E:-.01,F:-1.13,G:.01,H:.17,I:-.31,K:.99,L:-.56,M:-.23,N:.42,P:.45,Q:.58,R:.81,S:.13,T:.14,V:.07,W:-1.85,Y:-.94},categorial:{"-":0,A:1,C:2,D:3,E:4,F:5,G:6,H:7,I:8,K:9,L:10,M:11,N:12,P:13,Q:14,R:15,S:16,T:17,V:18,W:19,Y:20}};class N{constructor(t="categorial"){this.aa2num=P.getScale(t),this.num2aa={},Object.entries(this.aa2num).forEach((([t,e])=>this.num2aa[e]=t))}static _truncateSequence(t){let e=0,n=t.length;const i=["NH2","COOH"];if(t.startsWith(i[0])){const n=i[0].length;(0,R.hu)("-"==t[n],`Wrong sequence format: ${i[0]} without following '-' in '${t}'.`),e=n}if(t.endsWith(i[1])){const e=i[1].length+1;(0,R.hu)("-"==t[n-e],`Wrong sequence format: ${i[1]} without '-' precending in '${t}'.`),n-=e}return t.substring(e,n)}static _dropDefises(t){return t.replace(/(-)([^-]+)/g,"$2")}static clean(t){return N._dropDefises(N._truncateSequence(t))}encode(t){const e=t.length,n=new Array(e).fill(0);for(let i=0;i<e;++i){const e=t[i];(0,R.hu)(e in this.aa2num,`Unknown char '${e}' found in sequence '${t}'`),n[i]=this.encodeLettter(e)}return n}encodeLettter(t){return this.aa2num[t]}decode(t){let e="";for(let n=0;n<t.length;++n){const i=t[n];(0,R.hu)(i in this.num2aa,`Unknown code '${i}' found in vector '${t}'`),e+=this.num2aa[i]}return e}}var x=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};const L="input.fa",G="result.fasta";function _(t){return t.reduce(((t,e,n)=>t+`>sample${n+1}\n${e}\n`),"")}function I(t,e=!1,n="",s=null){var r,a;return x(this,void 0,void 0,(function*(){let l=t.toList();e&&(l=l.map((t=>N.clean(t).replace(/\-/g,""))));const h=t.length;null!=s||(s=i.Column.string("Clusters",h).init("0")),s.type!=i.COLUMN_TYPE.STRING&&(s=s.convertTo(i.TYPE.STRING)),s.compact();const u=s.categories,c=s.getRawData(),d=new Array(u.length),f=new Array(u.length);for(let t=0;t<h;++t){const e=c[t];(null!==(r=d[e])&&void 0!==r?r:d[e]=[]).push(l[t]),(null!==(a=f[e])&&void 0!==a?a:f[e]=[]).push(t)}const m=yield new A(["base/1.0.0",{tool:"kalign",version:"3.3.1",reinit:!0}]),p=i.Column.string(n,h);for(let t=0;t<u.length;++t){const e=_(d[t]);console.log(["fasta.length =",e.length]),yield m.fs.writeFile(L,e);const n=yield m.exec(`kalign ${L} -f fasta -o ${G}`);console.warn(n);const i=yield m.cat(G);if(!i)throw new Error("kalign output no result");const s=new o.i(i).sequencesArray,r=f[t];for(let t=0;t<s.length;++t)p.set(r[t],s[t])}const g=t.getTag(i.TAGS.UNITS),v=t.getTag("aligned")+".MSA",y=t.getTag("alphabet");return p.setTag(i.TAGS.UNITS,g),p.setTag("aligned",v),p.setTag("alphabet",y),p.semType=i.SEMTYPE.MACROMOLECULE,p}))}},8341:(t,e,n)=>{"use strict";n.d(e,{J:()=>a,f:()=>h});var i=n(4469),o=n(976),s=n(3553),r=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};const a=["mafft --auto","mafft","linsi","ginsi","einsi","fftns","fftnsi","nwns","nwnsi"],l=["AlignedSeq","AlignedSubpeptide","HELM","ID","PolymerID"];function h(t,e,n="ginsi",a=1.53,h=0,c=null){var d;return r(this,void 0,void 0,(function*(){const r=t.length;null!=c||(c=o.Column.int("Clusters",r).init(0)),c.type!=o.COLUMN_TYPE.STRING&&(c=c.convertTo(o.TYPE.STRING));const f=c.categories,m=new Array(f.length);for(let e=0;e<r;++e){const n=c.get(e);if(""===n)continue;const i=f.indexOf(n),o=t.get(e);o&&(null!==(d=m[i])&&void 0!==d?d:m[i]=[]).push({ID:e.toString(),HELM:o})}const p=yield(void 0!==i.dapi.docker?i.dapi.docker.dockerContainers:i.dapi.dockerfiles).filter("bio").first(),g=new Array(r);for(const t of m){const e=(yield u(p.id,t,n,a,h)).Alignment;for(const t of e)g[parseInt(t.ID)]=Object.entries(t).filter((t=>!l.includes(t[0]))).map((t=>"-"!==t[1]?t[1]:"")).join(s.rs.SEPARATOR)}const v=o.Column.fromStrings(e,g);return v.setTag(o.TAGS.UNITS,"separator"),v.setTag("separator",s.rs.SEPARATOR),v.setTag("aligned","SEQ.MSA"),v.setTag("alphabet","UN"),v.setTag(".alphabetIsMultichar","true"),v.semType=o.SEMTYPE.MACROMOLECULE,v}))}function u(t,e,n,o,s){return r(this,void 0,void 0,(function*(){const r={method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(e)},a=`/align?method=${n}&gap_open=${o}&gap_extend=${s}`,l=yield(void 0!==i.dapi.docker?i.dapi.docker.dockerContainers:i.dapi.dockerfiles).request(t,a,r);return JSON.parse(null!=l?l:"{}")}))}},9943:(t,e,n)=>{"use strict";n.d(e,{i$:()=>s,sK:()=>r}),n(976),n(3870),n(4469),n(6414);var i=n(6714);n(499);const o=60;function s(t,e,n=o,s="\n"){const a=i.kB,l=[];for(let i=0;i<e.length;i++){const o=t.map((t=>t.get(i).toString())).join("|"),h=r(e.get(i),a,n);l.push(`>${o}${s}`);for(const t of h)l.push(`${t}${s}`)}return"".concat(...l)}function r(t,e,n=o){const i=e(t);let s=0;const r=i.length,a=[];for(;s<r;){const t=i.slice(s,s+n),e=t.map((t=>t.length>1?`[${t}]`:t)).join("");a.push(e),s+=t.length}return a}},4293:(t,e,n)=>{"use strict";n.d(e,{Y:()=>r,m:()=>s});var i=n(4469),o=n(976);function s(){const t=i.shell.t.columns.bySemType(o.SEMTYPE.MACROMOLECULE);if(null!==t)return t;i.shell.error("Current table does not contain macromolecules")}function r(t,e){t.innerHTML="",t.append(e)}},2433:(t,e,n)=>{"use strict";n.d(e,{CK:()=>b,eZ:()=>S,yW:()=>w});var i,o,s,r,a,l,h=n(4469),u=n(3870),c=n(976),d=n(6414),f=n.n(d),m=n(701),p=n(499),g=n(6714),v=n(9298),y=n(7604);HTMLCanvasElement.prototype.getCursorPosition=function(t,e){const n=this.getBoundingClientRect();return new c.Point((t.clientX-n.left)*e,(t.clientY-n.top)*e)},c.Rect.prototype.contains=function(t,e){return this.left<=t&&t<=this.right&&this.top<=e&&e<=this.bottom};class w{constructor(t=0,e=new c.Rect(0,0,0,0)){this.count=t,this.bounds=e}}class b{constructor(t,e,n={},i=0,o=0){this.pos=t,this.name=e,this.freq=n,this.rowCount=i,this.sumForHeightCalc=o}}!function(t){t.TOP="top",t.MIDDLE="middle",t.BOTTOM="bottom"}(i||(i={})),function(t){t.LEFT="left",t.CENTER="center",t.RIGHT="right"}(o||(o={})),function(t){t.AUTO="auto",t.ON="on",t.OFF="off"}(s||(s={})),function(t){t.Filtered="Filtered",t.Selected="Selected"}(r||(r={})),function(t){t.STYLE="Style",t.BEHAVIOR="Behavior",t.LAYOUT="Layout",t.DATA="Data"}(a||(a={})),function(t){t.sequenceColumnName="sequenceColumnName",t.startPositionName="startPositionName",t.endPositionName="endPositionName",t.skipEmptySequences="skipEmptySequences",t.skipEmptyPositions="skipEmptyPositions",t.shrinkEmptyTail="shrinkEmptyTail",t.backgroundColor="backgroundColor",t.positionHeight="positionHeight",t.positionWidth="positionWidth",t.verticalAlignment="verticalAlignment",t.horizontalAlignment="horizontalAlignment",t.fixWidth="fixWidth",t.fitArea="fitArea",t.minHeight="minHeight",t.maxHeight="maxHeight",t.positionMarginState="positionMarginState",t.positionMargin="positionMargin",t.filterSource="filterSource"}(l||(l={}));class C extends c.JsViewer{get filter(){let t;switch(this.filterSource){case r.Filtered:t=this.dataFrame.filter;break;case r.Selected:t=this.dataFrame.selection}return t}get Length(){return this.skipEmptyPositions?this.positions.length:this.startPosition<=this.endPosition?this.endPosition-this.startPosition+1:0}get positionWidthWithMargin(){return this._positionWidth+this.positionMarginValue}get positionMarginValue(){var t;return"auto"===this.positionMarginState&&!0===(null===(t=this.unitsHandler)||void 0===t?void 0:t.getAlphabetIsMultichar())||"enable"===this.positionMarginState?this.positionMargin:0}get countOfRenderPositions(){if(null==this.host)return 0;const t=window.devicePixelRatio;return t>1?this.canvasWidthWithRatio/this.positionWidthWithMargin:this.canvas.width/(this.positionWidthWithMargin*t)}get canvasWidthWithRatio(){return this.canvas.width*window.devicePixelRatio}get firstVisibleIndex(){return this.visibleSlider?Math.floor(this.slider.min):0}constructor(){super(),this.viewerId=-1,this.initialized=!1,this.cp=null,this.axisHeight=12,this.seqCol=null,this.splitter=null,this.positions=[],this.rowsMasked=0,this.rowsNull=0,this.visibleSlider=!1,this.allowResize=!0,this.turnOfResizeForOneSetValue=!1,this.backgroundColor=4294967295,this.positionMargin=0,this.positionNames=[],this.startPosition=-1,this.endPosition=-1,this.viewSubs=[],this.viewerId=C.viewerCount,C.viewerCount+=1,this.textBaseline="top",this.unitsHandler=null,this.sequenceColumnName=this.string(l.sequenceColumnName,null,{category:a.DATA}),this.startPositionName=this.string(l.startPositionName,null,{category:a.DATA}),this.endPositionName=this.string(l.endPositionName,null,{category:a.DATA}),this.skipEmptySequences=this.bool(l.skipEmptySequences,!0,{category:a.DATA}),this.skipEmptyPositions=this.bool(l.skipEmptyPositions,!1,{category:a.DATA}),this.shrinkEmptyTail=this.bool(l.shrinkEmptyTail,!0,{category:a.DATA}),this.backgroundColor=this.int(l.backgroundColor,4294967295,{category:a.STYLE}),this.positionHeight=this.string(l.positionHeight,v.ES.full,{category:a.STYLE,choices:Object.values(v.ES)}),this._positionWidth=this.positionWidth=this.float(l.positionWidth,16,{category:a.STYLE}),this.verticalAlignment=this.string(l.verticalAlignment,i.MIDDLE,{category:a.LAYOUT,choices:Object.values(i)}),this.horizontalAlignment=this.string(l.horizontalAlignment,o.CENTER,{category:a.LAYOUT,choices:Object.values(o)}),this.fixWidth=this.bool(l.fixWidth,!1,{category:a.LAYOUT}),this.fitArea=this.bool(l.fitArea,!0,{category:a.LAYOUT}),this.minHeight=this.float(l.minHeight,50,{category:a.LAYOUT}),this.maxHeight=this.float(l.maxHeight,100,{category:a.LAYOUT}),this.positionMarginState=this.string(l.positionMarginState,s.AUTO,{category:a.LAYOUT,choices:Object.values(s)});let t=0;"auto"===this.positionMarginState&&(t=4),this.positionMargin=this.int(l.positionMargin,t,{category:a.LAYOUT,min:0,max:16}),this.filterSource=this.string(l.filterSource,r.Filtered,{category:a.BEHAVIOR,choices:Object.values(r)}),this.slider=u.rangeSlider(0,100,0,20,!1,{style:"barbell"}),this.canvas=u.canvas(),this.canvas.style.width="100%"}init(){this.initialized?console.error("Bio: WebLogoViewer.init() second initialization!"):(this.initialized=!0,this.helpUrl="/help/visualize/viewers/web-logo.md",this.msgHost=u.div("No message"),this.msgHost.style.display="none",this.canvas=u.canvas(),this.canvas.style.width="100%",this.slider.root.style.position="absolute",this.slider.root.style.zIndex="999",this.slider.root.style.display="none",this.slider.root.style.height="0.7em",this.visibleSlider=!1,this.subs.push(this.slider.onValuesChanged.subscribe(this.sliderOnValuesChanged.bind(this))),this.host=u.div([this.msgHost,this.canvas]),this.host.style.justifyContent="center",this.host.style.alignItems="center",this.host.style.position="relative",this.host.style.setProperty("overflow","hidden","important"),this.subs.push(m.fromEvent(this.canvas,"mousemove").subscribe(this.canvasOnMouseMove.bind(this))),this.subs.push(m.fromEvent(this.canvas,"mousedown").subscribe(this.canvasOnMouseDown.bind(this))),this.subs.push(m.fromEvent(this.canvas,"wheel").subscribe(this.canvasOnWheel.bind(this))),this.subs.push(u.onSizeChanged(this.root).subscribe(this.rootOnSizeChanged.bind(this))),this.root.append(this.host),this.root.append(this.slider.root),this._calculate(window.devicePixelRatio),this.updateSlider(),this.render(!0))}rootOnSizeChanged(){this._calculate(window.devicePixelRatio),this.updateSlider(),this.render(!0)}updateSeqCol(){if(this.dataFrame)if(this.seqCol=this.sequenceColumnName?this.dataFrame.col(this.sequenceColumnName):null,null==this.seqCol&&(this.seqCol=(0,g.up)(this.dataFrame),this.sequenceColumnName=this.seqCol?this.seqCol.name:null),this.seqCol){const t=this.seqCol.getTag(c.TAGS.UNITS),e=this.seqCol.getTag("separator");this.splitter=(0,g.vU)(t,e),this.unitsHandler=new p.C(this.seqCol),this.updatePositions(),this.cp=(0,g.dQ)(this.seqCol)}else this.splitter=null,this.positionNames=[],this.startPosition=-1,this.endPosition=-1,this.cp=null;this.render()}updatePositions(){if(!this.seqCol)return;let t;if(this.shrinkEmptyTail){const e=this.dataFrame.filter.getSelectedIndexes();t=Array.from(new Set(Array.from(Array(e.length).keys()).map((t=>this.seqCol.get(e[t])))))}else t=this.seqCol.categories;const e=t.length>0?Math.max(...t.map((t=>null!==t?this.splitter(t).length:0))):0,n=this.seqCol.getTag(v.DX.positionNames);this.positionNames=n?n.split(v.CI).map((t=>t.trim())):[...Array(e).keys()].map((t=>`${t+1}`)),this.startPosition=this.startPositionName&&this.positionNames&&this.positionNames.includes(this.startPositionName)?this.positionNames.indexOf(this.startPositionName):0,this.endPosition=this.endPositionName&&this.positionNames&&this.positionNames.includes(this.endPositionName)?this.positionNames.indexOf(this.endPositionName):e-1}get widthArea(){return this.Length*this.positionWidth/window.devicePixelRatio}get heightArea(){return Math.min(this.maxHeight,Math.max(this.minHeight,this.root.clientHeight))}get xScale(){return this.widthArea>0?(this.root.clientWidth-this.Length*this.positionMarginValue)/this.widthArea:0}get yScale(){return this.root.clientHeight/this.heightArea}checkIsHideSlider(){let t=!0;const e=Math.min(this.xScale,this.yScale);return(e==this.xScale||e<=1)&&this.fitArea&&(t=!1),this.fixWidth||Math.ceil(this.canvas.width/this.positionWidthWithMargin)>=this.Length||t}setSliderVisibility(t){t?(this.slider.root.style.display="inherit",this.visibleSlider=!0):(this.slider.root.style.display="none",this.visibleSlider=!1)}updateSlider(){if(this.checkIsHideSlider()?this.setSliderVisibility(!1):this.setSliderVisibility(!0),null!=this.slider&&null!=this.canvas){const t=Math.max(0,Math.floor(this.slider.min+this.canvas.width/this.positionWidthWithMargin)-this.Length);let e=Math.floor(this.slider.min-t),n=Math.floor(this.slider.min-t)+Math.floor(this.canvas.width/this.positionWidthWithMargin);this.checkIsHideSlider()&&(e=0,n=Math.max(e,this.Length-1)),this.turnOfResizeForOneSetValue=!0,this.slider.setValues(0,this.Length,e,n)}}onPropertyChanged(t){switch(super.onPropertyChanged(t),t.name){case l.sequenceColumnName:case l.startPositionName:case l.endPositionName:case l.filterSource:this.updateSeqCol();break;case l.positionWidth:this._positionWidth=this.positionWidth,this.updateSlider();break;case l.fixWidth:case l.fitArea:case l.positionMargin:this.updateSlider();break;case l.shrinkEmptyTail:case l.skipEmptyPositions:this.updatePositions()}this.render(!0)}onTableAttached(){super.onTableAttached();const t=this.dataFrame?"data":"null";console.debug(`Bio: WebLogoViewer<${this.viewerId}>.onTableAttached( dataFrame = ${t} ) start`),this.updateSeqCol(),void 0!==this.dataFrame&&(this.viewSubs.push(this.dataFrame.filter.onChanged.subscribe(this.dataFrameFilterOnChanged.bind(this))),this.viewSubs.push(this.dataFrame.selection.onChanged.subscribe(this.dataFrameSelectionOnChanged.bind(this)))),this.init(),console.debug(`Bio: WebLogoViewer<${this.viewerId}>.onTableAttached() end`)}detach(){const t=Object.create(null,{detach:{get:()=>super.detach}});return e=this,n=void 0,o=function*(){const e=this.dataFrame?"data":"null";console.debug(`Bio: WebLogoViewer<${this.viewerId}>.onTableAttached( dataFrame = ${e} ) start`),t.detach.call(this),this.viewSubs.forEach((t=>t.unsubscribe())),this.host.remove(),this.msgHost=void 0,this.host=void 0,this.initialized=!1,console.debug(`Bio: WebLogoViewer<${this.viewerId}>.onTableAttached() end`)},new((i=void 0)||(i=Promise))((function(t,s){function r(t){try{l(o.next(t))}catch(t){s(t)}}function a(t){try{l(o.throw(t))}catch(t){s(t)}}function l(e){var n;e.done?t(e.value):(n=e.value,n instanceof i?n:new i((function(t){t(n)}))).then(r,a)}l((o=o.apply(e,n||[])).next())}));var e,n,i,o}getMonomer(t){const e=t.x+this.firstVisibleIndex*this.positionWidthWithMargin,n=Math.floor(t.x/this.positionWidthWithMargin+this.firstVisibleIndex),i=this.positions[n];if(null==i)return[n,null,null];const o=Object.keys(i.freq).find((n=>i.freq[n].bounds.contains(e,t.y)));return void 0===o?[n,null,null]:[n,o,i.freq[o]]}_nullSequence(t="X"){return this.skipEmptySequences?"":new Array(this.Length).fill(t).join("")}removeWhere(t,e){const n=t.length;let i=0;for(let o=0;o<n;o++)e(t[o])||(t[i]=t[o],i++);return t.length=i,t}_removeEmptyPositions(){this.skipEmptyPositions&&this.removeWhere(this.positions,(t=>{var e;return(null===(e=null==t?void 0:t.freq["-"])||void 0===e?void 0:e.count)===t.rowCount}))}_calculate(t){if(!this.host||!this.seqCol||!this.dataFrame)return;this.unitsHandler=new p.C(this.seqCol),this.calcSize();const e=this.startPosition<=this.endPosition?this.endPosition-this.startPosition+1:0;this.positions=new Array(e);for(let t=0;t<this.Length;t++){const e=this.positionNames[this.startPosition+t];this.positions[t]=new b(this.startPosition+t,e)}const n=this.filter.getSelectedIndexes();this.rowsMasked=n.length,this.rowsNull=0;for(const t of n){let e=this.seqCol.get(t);e||(e=this._nullSequence(),++this.rowsNull);const n=this.splitter(e);for(let t=0;t<this.Length;t++){const e=this.positions[t].freq,i=n[this.startPosition+t]||"-";i in e||(e[i]=new w),e[i].count++}}for(let t=0;t<this.Length;t++){this.positions[t].rowCount=0;for(const e in this.positions[t].freq)this.positions[t].rowCount+=this.positions[t].freq[e].count;if(this.positionHeight==v.ES.Entropy){this.positions[t].sumForHeightCalc=0;for(const e in this.positions[t].freq){const n=this.positions[t].freq[e].count/this.positions[t].rowCount;this.positions[t].sumForHeightCalc+=-n*Math.log2(n)}}}this._removeEmptyPositions();const i=this.canvas.height-this.axisHeight*t;for(let e=0;e<this.Length;e++){const n=this.positions[e].freq,o=this.positions[e].rowCount,s=this.getAlphabetSize();this.positionHeight==v.ES.Entropy&&null==s&&h.shell.error("WebLogo: alphabet is undefined.");const r=Math.log2(s),a=this.positionHeight==v.ES.Entropy?i*(r-this.positions[e].sumForHeightCalc)/r:i;let l=this.axisHeight*t+(i-a-1);const u=Object.entries(n).sort(((t,e)=>"-"!==t[0]&&"-"!==e[0]?e[1].count-t[1].count:"-"===t[0]&&"-"===e[0]?0:"-"===t[0]?-1:1));for(const t of u){const n=t[1],i=a*n.count/o;n.bounds=new c.Rect(e*this.positionWidthWithMargin,l,this._positionWidth,i),l+=i}}}render(t=!0){var e;if(this.msgHost&&(this.seqCol&&!this.cp?(this.msgHost.innerText=`Unknown palette (column semType: '${this.seqCol.semType}').`,this.msgHost.style.display=""):this.msgHost.style.display="none"),!this.seqCol||!this.dataFrame||!this.cp||-1===this.startPosition||-1===this.endPosition||null==this.host||null==this.slider)return;const n=this.canvas.getContext("2d");if(!n)return;this.slider.root.style.width=`${this.host.clientWidth}px`;const i=window.devicePixelRatio;t&&this._calculate(i),n.resetTransform(),n.fillStyle=c.Color.toHtml(this.backgroundColor),n.fillRect(0,0,this.canvas.width,this.canvas.height),n.textBaseline=this.textBaseline;const o=this.countOfRenderPositions+1,s=this.visibleSlider?Math.floor(this.slider.min):0,r=Math.min(this.Length,s+o),a=10*i;n.resetTransform(),n.fillStyle="black",n.textAlign="center",n.font=`${a.toFixed(1)}px Roboto, Roboto Local, sans-serif`;const l=Math.max(...this.positions.map((t=>n.measureText(t.name).width))),h=l<this._positionWidth-2?1:(this._positionWidth-2)/l;for(let t=this.firstVisibleIndex;t<r;t++){const e=this.positions[t];n.resetTransform(),n.setTransform(h,0,0,1,t*this.positionWidthWithMargin+this._positionWidth/2-this.positionWidthWithMargin*s,0),n.fillText(e.name,0,0)}for(let t=this.firstVisibleIndex;t<r;t++)for(const[i,o]of Object.entries(this.positions[t].freq))if("-"!==i){const t=(0,g.GU)(i,5),s=o.bounds,r=s.left-this.positionWidthWithMargin*this.firstVisibleIndex;n.resetTransform(),n.strokeStyle="lightgray",n.lineWidth=1,n.rect(r,s.top,s.width,s.height),n.fillStyle=null!==(e=this.cp.get(i))&&void 0!==e?e:this.cp.get("other"),n.textAlign="left",n.font="16px Roboto, Roboto Local, sans-serif";const a=n.measureText(t);n.setTransform(s.width/a.width,0,0,s.height/12.2,r,s.top),n.fillText(t,0,-.25)}}calcSize(){if(!this.host)return;const t=window.devicePixelRatio;let e=this.widthArea,n=this.heightArea;if(this.fitArea&&!this.visibleSlider){const t=Math.max(1,Math.min(this.xScale,this.yScale));e*=t,n*=t,this._positionWidth=this.positionWidth*t}e=this.Length*this.positionWidthWithMargin/t,this.canvas.width=this.root.clientWidth*t,this.canvas.style.width=`${this.root.clientWidth}px`,this.host.style.setProperty("height",`${n}px`);const i=this.host.clientHeight;if(this.canvas.height=i*t,this.fixWidth)this.root.style.width=this.host.style.width=`${e}px`,this.root.style.height=`${n}px`,this.root.style.overflow="hidden",this.host.style.setProperty("overflow-y","hidden","important");else{this.root.style.width=this.host.style.width="100%",this.host.style.overflowX="auto!important",this.host.style.setProperty("text-align",this.horizontalAlignment);const t=this.visibleSlider?10:0;let o=0;switch(this.verticalAlignment){case"top":o=0;break;case"middle":o=Math.max(0,(this.root.clientHeight-n)/2);break;case"bottom":o=Math.max(0,this.root.clientHeight-n-t)}let s=0;switch(this.horizontalAlignment){case"left":s=0;break;case"center":s=Math.max(0,(this.root.clientWidth-e)/2);break;case"right":s=Math.max(0,this.root.clientWidth-e)}this.host.style.setProperty("margin-top",`${o}px`,"important"),this.host.style.setProperty("margin-left",`${s}px`,"important"),null!=this.slider&&this.slider.root.style.setProperty("margin-top",`${o+i}px`,"important"),this.root.clientHeight<=n?(this.host.style.setProperty("height",`${this.root.clientHeight}px`),this.host.style.setProperty("overflow-y",null)):this.host.style.setProperty("overflow-y","hidden","important")}}getAlphabetSize(){var t,e;return null!==(e=null===(t=this.unitsHandler)||void 0===t?void 0:t.getAlphabetSize())&&void 0!==e?e:0}sliderOnValuesChanged(t){if(null!=this.host)try{if(this.allowResize&&!this.turnOfResizeForOneSetValue&&this.visibleSlider){const t=Math.ceil(this.slider.max-this.slider.min),e=this.canvas.width/t-this.positionMarginValue;this.positionWidth=e,this._positionWidth=e}this.turnOfResizeForOneSetValue=!1,this.render(!0)}catch(t){const e=(0,y.O)(t);console.error("Bio: WebLogoViewer.sliderOnValuesChanged() error:\n"+e)}}dataFrameFilterOnChanged(t){console.debug("Bio: WebLogoViewer.dataFrameFilterChanged()");try{this.updatePositions(),this.render()}catch(t){const e=(0,y.O)(t);console.error("Bio: WebLogoViewer.dataFrameFilterOnChanged() error:\n"+e)}}dataFrameSelectionOnChanged(t){console.debug("Bio: WebLogoViewer.dataFrameSelectionOnChanged()");try{this.render()}catch(t){const e=(0,y.O)(t);console.error("Bio: WebLogoViewer.dataFrameSelectionOnChanged() error:\n"+e)}}canvasOnMouseMove(t){try{const e=t,n=window.devicePixelRatio,i=this.canvas.getCursorPosition(e,n),[o,s]=this.getMonomer(i);if(this.dataFrame&&this.seqCol&&this.splitter&&s){const t=this.positions[o],n=S(this.dataFrame,this.seqCol,this.filter,this.splitter,s,t),i=u.div([u.div(`${s}`),u.div(`${n} rows`)]);u.tooltip.show(i,e.x+16,e.y+16)}else u.tooltip.hide()}catch(t){const e=(0,y.O)(t);console.error("Bio: WebLogoViewer.canvasOnMouseMove() error:\n"+e)}}canvasOnMouseDown(t){try{const e=t,n=window.devicePixelRatio,[i,o]=this.getMonomer(this.canvas.getCursorPosition(e,n));if(this.dataFrame&&this.seqCol&&this.splitter&&o){const t=this.positions[i],e=c.BitSet.create(this.dataFrame.selection.length,(e=>function(t,e,n,i,o,s,r){if(!n.getSelectedIndexes().includes(i))return!1;const a=e.get(i),l=a?o(a)[r.pos]:null;return l===s||""===l&&"-"===s}(this.dataFrame,this.seqCol,this.filter,e,this.splitter,o,t)));this.dataFrame.selection.init((t=>e.get(t)))}}catch(t){const e=(0,y.O)(t);console.error("Bio: WebLogoViewer.canvasOnMouseDown() error:\n"+e)}}canvasOnWheel(t){try{if(!this.visibleSlider)return;const e=t.deltaY/100*Math.max(Math.floor(this.countOfRenderPositions/2),1);this.slider.scrollBy(this.slider.min+e)}catch(t){const e=(0,y.O)(t);console.error("Bio: WebLogoViewer.canvasOnWheel() error:\n"+e)}}}function S(t,e,n,i,o,s){return f().count(0).take(t.rowCount).filter((t=>n.get(t))).map((t=>{const n=e.get(t),o=n?i(n):[],r=s.pos;return r<o.length?o[r]:null})).toArray().filter((t=>t==o)).reduce(((t,e)=>t+1),0)}C.residuesSet="nucleotides",C.viewerCount=-1},4413:(t,e,n)=>{"use strict";n.d(e,{ST:()=>m});var i=n(3870),o=n(976),s=n(4469),r=n(6414),a=n.n(r),l=n(7983),h=n(701),u=n(4293),c=n(1061);const d=rxjs.operators;var f=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};class m extends o.Filter{get calculating(){return"initial"==this.loader.style.display}set calculating(t){this.loader.style.display=t?"initial":"none"}get filterSummary(){return this.bioFilter.substructure}get isFiltering(){return super.isFiltering&&""!==this.bioFilter.substructure}get isReadyToApplyFilter(){return!this.calculating&&null!=this.bitset}get _debounceTime(){if(null==this.column)return 1e3;const t=this.column.length;return t<500?0:t>1e4?1e3:Math.floor((t-500)/9500*1e3)}constructor(){super(),this.bioFilter=null,this.bitset=null,this.loader=i.loader(),this.notation=void 0,this.root=i.divV([]),this.calculating=!1}attach(t){var e,n,i,s,r;super.attach(t),this.column=t.columns.bySemType(o.SEMTYPE.MACROMOLECULE),null!==(e=this.columnName)&&void 0!==e||(this.columnName=null===(n=this.column)||void 0===n?void 0:n.name),null!==(i=this.notation)&&void 0!==i||(this.notation=null===(s=this.column)||void 0===s?void 0:s.getTag(o.TAGS.UNITS)),this.bioFilter="fasta"===this.notation?new g:"separator"===this.notation?new v(this.column.getTag("separator")):new y,this.root.appendChild(this.bioFilter.filterPanel),this.root.appendChild(this.loader),null===(r=this.onBioFilterChangedSubs)||void 0===r||r.unsubscribe();let a=this.bioFilter.onChanged;a=a.pipe((0,d.debounceTime)(this._debounceTime)),this.onBioFilterChangedSubs=a.subscribe((t=>f(this,void 0,void 0,(function*(){return yield this._onInputChanged()}))))}detach(){super.detach()}applyFilter(){var t;this.bitset&&!this.isDetached&&(null===(t=this.dataFrame)||void 0===t||t.filter.and(this.bitset))}saveState(){var t;const e=super.saveState();return e.bioSubstructure=null===(t=this.bioFilter)||void 0===t?void 0:t.substructure,e}applyState(t){super.applyState(t),t.bioSubstructure&&(this.bioFilter.substructure=t.bioSubstructure);const e=this;t.bioSubstructure&&setTimeout((function(){e._onInputChanged()}),1e3)}_onInputChanged(){var t,e,n;return f(this,void 0,void 0,(function*(){if(this.isFiltering){if(a()(this.dataFrame.rows.filters).has(`${this.columnName}: ${this.filterSummary}`))return;this.calculating=!0;try{this.bitset=yield null===(e=this.bioFilter)||void 0===e?void 0:e.substrucrureSearch(this.column),this.calculating=!1,null===(n=this.dataFrame)||void 0===n||n.rows.requestFilter()}finally{this.calculating=!1}}else this.bitset=null,null===(t=this.dataFrame)||void 0===t||t.rows.requestFilter()}))}}class p{constructor(){this.onChanged=new h.Subject}get filterPanel(){return new HTMLElement}get substructure(){return""}set substructure(t){}substrucrureSearch(t){return f(this,void 0,void 0,(function*(){return null}))}}class g extends p{constructor(){super(),this.substructureInput=i.stringInput("","",(()=>{this.onChanged.next()}),{placeholder:"Substructure"})}get filterPanel(){return this.substructureInput.root}get substructure(){return this.substructureInput.value}set substructure(t){this.substructureInput.value=t}substrucrureSearch(t){return f(this,void 0,void 0,(function*(){return yield(0,l.pf)(this.substructure,t)}))}}class v extends g{constructor(t){super(),this.colSeparator="",this.separatorInput=i.stringInput("","",(()=>{this.onChanged.next()}),{placeholder:"Separator"}),this.colSeparator=t,this.separatorInput.value=t}get filterPanel(){return i.divV([this.substructureInput.root,this.separatorInput.root])}get substructure(){return this.separatorInput.value&&this.separatorInput.value!==this.colSeparator?this.substructureInput.value.replaceAll(this.separatorInput.value,this.colSeparator):this.substructureInput.value}set substructure(t){this.substructureInput.value=t}substrucrureSearch(t){return f(this,void 0,void 0,(function*(){return yield(0,l.pf)(this.substructure,t,this.colSeparator)}))}}class y extends p{constructor(){super(),this._filterPanel=i.div("",{style:{cursor:"pointer"}}),this.helmSubstructure="",this.init()}init(){return f(this,void 0,void 0,(function*(){this.helmEditor=yield s.functions.call("HELM:helmWebEditor"),yield i.tools.waitForElementInDom(this._filterPanel),this.updateFilterPanel(),this._filterPanel.addEventListener("click",(t=>{const{editorDiv:e,webEditor:n}=this.helmEditor.createWebEditor(this.helmSubstructure);i.dialog({showHeader:!1,showFooter:!0}).add(e).onOK((()=>{const t=n.canvas.getHelm(!0).replace(/<\/span>/g,"").replace(/<span style='background:#bbf;'>/g,"");this.helmSubstructure=t,this.updateFilterPanel(this.substructure),setTimeout((()=>{this.onChanged.next()}),10)})).show({modal:!0,fullScreen:!0})})),i.onSizeChanged(this._filterPanel).subscribe((t=>{const e=this.helmEditor.webEditor.canvas.getHelm(!0).replace(/<\/span>/g,"").replace(/<span style='background:#bbf;'>/g,"");this.updateFilterPanel(e)}))}))}get filterPanel(){return this._filterPanel}get substructure(){return this.helmSubstructure}set substructure(t){this.helmEditor.editor.setHelm(t)}updateFilterPanel(t){const e=this._filterPanel.parentElement.clientWidth<100?100:this._filterPanel.parentElement.clientWidth,n=e/2;if(t)(0,u.Y)(this._filterPanel,this.helmEditor.host),this.helmEditor.editor.setHelm(t),this.helmEditor.resizeEditor(e,n);else{const t=i.divText("Click to edit","helm-substructure-filter");(0,u.Y)(this._filterPanel,t)}}substrucrureSearch(t){return f(this,void 0,void 0,(function*(){i.setUpdateIndicator(this._filterPanel,!0),yield(0,c.gw)(10);const e=yield(0,l.QF)(this.substructure,t);return i.setUpdateIndicator(this._filterPanel,!1),e}))}}},9378:function(t,e,n){"use strict";var i=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e.default=t,e};Object.defineProperty(e,"__esModule",{value:!0});var o=i(n(4517));function s(t,e){var n=function(n){return o.empty(t).map((function(){return o.filled(e,n)}))},i=[];return i.push(n(-1)),i.push(n(1/0)),i.push(n(0)),i}function r(t,e,n,i,o){e=Math.floor(e);var s=t[0][e],r=t[1][e];if(t[2][e],n>=r[0])return 0;for(var l=0;l<s.length;l++)if(i===s[l])return 0;return a(t,e,n,i,o)}function a(t,e,n,i,o){var s=t[0][e],r=t[1][e],a=t[2][e];if(n>=r[0])return 0;r[0]=n,s[0]=i,a[0]=o;for(var l=0,h=0;;){var u=2*l+1,c=u+1,d=t[0][0].length;if(u>=d)break;if(c>=d){if(!(r[u]>n))break;h=u}else if(r[u]>=r[c]){if(!(n<r[u]))break;h=u}else{if(!(n<r[c]))break;h=c}r[l]=r[h],s[l]=s[h],a[l]=a[h],l=h}return r[l]=n,s[l]=i,a[l]=o,1}function l(t,e,n,i){for(;2*i+1<n;){var o=2*i+1,s=o+1,r=i;if(t[r]<t[o]&&(r=o),s<n&&t[r]<t[s]&&(r=s),r===i)break;var a=t[i];t[i]=t[r],t[r]=a;var l=e[i];e[i]=e[r],e[r]=l,i=r}}e.makeHeap=s,e.rejectionSample=function(t,e,n){for(var i=o.zeros(t),s=0;s<t;s++){for(var r=!0,a=0;r;){a=o.tauRandInt(e,n);for(var l=!1,h=0;h<s;h++)if(a===i[h]){l=!0;break}l||(r=!1)}i[s]=a}return i},e.heapPush=r,e.uncheckedHeapPush=a,e.buildCandidates=function(t,e,n,i,a){for(var l=s(e,i),h=0;h<e;h++)for(var u=0;u<n;u++)if(!(t[0][h][u]<0)){var c=t[0][h][u],d=t[2][h][u],f=o.tauRand(a);r(l,h,f,c,d),r(l,c,f,h,d),t[2][h][u]=0}return l},e.deheapSort=function(t){for(var e=t[0],n=t[1],i=0;i<e.length;i++)for(var o=e[i],s=n[i],r=0;r<o.length-1;r++){var a=o.length-r-1,h=s.length-r-1,u=o[0];o[0]=o[a],o[a]=u;var c=s[0];s[0]=s[h],s[h]=c,l(s,o,h,0)}return{indices:e,weights:n}},e.smallestFlagged=function(t,e){for(var n=t[0][e],i=t[1][e],o=t[2][e],s=1/0,r=-1,a=0;a>n.length;a++)1===o[a]&&i[a]<s&&(s=i[a],r=a);return r>=0?(o[r]=0,Math.floor(n[r])):-1}},4221:(t,e,n)=>{"use strict";var i=n(4364);e.u=i.UMAP},5686:function(t,e,n){"use strict";var i,o=this&&this.__read||function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var i,o,s=n.call(t),r=[];try{for(;(void 0===e||e-- >0)&&!(i=s.next()).done;)r.push(i.value)}catch(t){o={error:t}}finally{try{i&&!i.done&&(n=s.return)&&n.call(s)}finally{if(o)throw o.error}}return r},s=this&&this.__values||function(t){var e="function"==typeof Symbol&&t[Symbol.iterator],n=0;return e?e.call(t):{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}}},r=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e.default=t,e};Object.defineProperty(e,"__esModule",{value:!0});var a=r(n(4517)),l=function(){function t(t,e,n,i){if(this.entries=new Map,this.nRows=0,this.nCols=0,t.length!==e.length||t.length!==n.length)throw new Error("rows, cols and values arrays must all have the same length");this.nRows=i[0],this.nCols=i[1];for(var o=0;o<n.length;o++){var s=t[o],r=e[o];this.checkDims(s,r);var a=this.makeKey(s,r);this.entries.set(a,{value:n[o],row:s,col:r})}}return t.prototype.makeKey=function(t,e){return t+":"+e},t.prototype.checkDims=function(t,e){if(!(t<this.nRows&&e<this.nCols))throw new Error("row and/or col specified outside of matrix dimensions")},t.prototype.set=function(t,e,n){this.checkDims(t,e);var i=this.makeKey(t,e);this.entries.has(i)?this.entries.get(i).value=n:this.entries.set(i,{value:n,row:t,col:e})},t.prototype.get=function(t,e,n){void 0===n&&(n=0),this.checkDims(t,e);var i=this.makeKey(t,e);return this.entries.has(i)?this.entries.get(i).value:n},t.prototype.getAll=function(t){void 0===t&&(t=!0);var e=[];return this.entries.forEach((function(t){e.push(t)})),t&&e.sort((function(t,e){return t.row===e.row?t.col-e.col:t.row-e.row})),e},t.prototype.getDims=function(){return[this.nRows,this.nCols]},t.prototype.getRows=function(){return Array.from(this.entries,(function(t){var e=o(t,2);return e[0],e[1].row}))},t.prototype.getCols=function(){return Array.from(this.entries,(function(t){var e=o(t,2);return e[0],e[1].col}))},t.prototype.getValues=function(){return Array.from(this.entries,(function(t){var e=o(t,2);return e[0],e[1].value}))},t.prototype.forEach=function(t){this.entries.forEach((function(e){return t(e.value,e.row,e.col)}))},t.prototype.map=function(e){var n=[];this.entries.forEach((function(t){n.push(e(t.value,t.row,t.col))}));var i=[this.nRows,this.nCols];return new t(this.getRows(),this.getCols(),n,i)},t.prototype.toArray=function(){var t=this,e=a.empty(this.nRows).map((function(){return a.zeros(t.nCols)}));return this.entries.forEach((function(t){e[t.row][t.col]=t.value})),e},t}();e.SparseMatrix=l,e.transpose=function(t){var e=[],n=[],i=[];t.forEach((function(t,o,s){e.push(o),n.push(s),i.push(t)}));var o=[t.nCols,t.nRows];return new l(n,e,i,o)},e.identity=function(t){for(var e=o(t,1)[0],n=new l([],[],[],t),i=0;i<e;i++)n.set(i,i,1);return n},e.pairwiseMultiply=function(t,e){return u(t,e,(function(t,e){return t*e}))},e.add=function(t,e){return u(t,e,(function(t,e){return t+e}))},e.subtract=function(t,e){return u(t,e,(function(t,e){return t-e}))},e.maximum=function(t,e){return u(t,e,(function(t,e){return t>e?t:e}))},e.multiplyScalar=function(t,e){return t.map((function(t){return t*e}))},e.eliminateZeros=function(t){for(var e=new Set,n=t.getValues(),i=t.getRows(),o=t.getCols(),s=0;s<n.length;s++)0===n[s]&&e.add(s);var r=function(t,n){return!e.has(n)},a=n.filter(r),h=i.filter(r),u=o.filter(r);return new l(h,u,a,t.getDims())},e.normalize=function(t,e){var n,i;void 0===e&&(e="l2");var o=h[e],r=new Map;t.forEach((function(t,e,n){var i=r.get(e)||[];i.push(n),r.set(e,i)}));var a=new l([],[],[],t.getDims()),u=function(e){for(var n=r.get(e).sort(),i=n.map((function(n){return t.get(e,n)})),s=o(i),l=0;l<s.length;l++)a.set(e,n[l],s[l])};try{for(var c=s(r.keys()),d=c.next();!d.done;d=c.next())u(d.value)}catch(t){n={error:t}}finally{try{d&&!d.done&&(i=c.return)&&i.call(c)}finally{if(n)throw n.error}}return a};var h=((i={}).max=function(t){for(var e=-1/0,n=0;n<t.length;n++)e=t[n]>e?t[n]:e;return t.map((function(t){return t/e}))},i.l1=function(t){for(var e=0,n=0;n<t.length;n++)e+=t[n];return t.map((function(t){return t/e}))},i.l2=function(t){for(var e=0,n=0;n<t.length;n++)e+=Math.pow(t[n],2);return t.map((function(t){return Math.sqrt(Math.pow(t,2)/e)}))},i);function u(t,e,n){for(var i=new Set,o=[],s=[],r=[],a=function(i,a){o.push(i),s.push(a);var l=n(t.get(i,a),e.get(i,a));r.push(l)},h=t.getValues(),u=t.getRows(),c=t.getCols(),d=0;d<h.length;d++){var f=(v=u[d])+":"+(y=c[d]);i.add(f),a(v,y)}var m=e.getValues(),p=e.getRows(),g=e.getCols();for(d=0;d<m.length;d++){var v,y;f=(v=p[d])+":"+(y=g[d]),i.has(f)||a(v,y)}var w=[t.nRows,t.nCols];return new l(o,s,r,w)}e.getCSR=function(t){var e=[];t.forEach((function(t,n,i){e.push({value:t,row:n,col:i})})),e.sort((function(t,e){return t.row===e.row?t.col-e.col:t.row-e.row}));for(var n=[],i=[],o=[],s=-1,r=0;r<e.length;r++){var a=e[r],l=a.row,h=a.col,u=a.value;l!==s&&(s=l,o.push(r)),n.push(h),i.push(u)}return{indices:n,values:i,indptr:o}}},760:function(t,e,n){"use strict";var i=this&&this.__values||function(t){var e="function"==typeof Symbol&&t[Symbol.iterator],n=0;return e?e.call(t):{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}}},o=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e.default=t,e};Object.defineProperty(e,"__esModule",{value:!0});var s=o(n(9378)),r=o(n(5686)),a=o(n(2320)),l=o(n(4517));e.makeNNDescent=function(t,e){return function(n,i,o,r,a,h,u,c){void 0===r&&(r=10),void 0===a&&(a=50),void 0===h&&(h=.001),void 0===u&&(u=.5),void 0===c&&(c=!0);for(var d=n.length,f=s.makeHeap(n.length,o),m=0;m<n.length;m++)for(var p=s.rejectionSample(o,n.length,e),g=0;g<p.length;g++){var v=t(n[m],n[p[g]]);s.heapPush(f,m,v,p[g],1),s.heapPush(f,p[g],v,m,1)}if(c)for(var y=0;y<i.length;y++)for(m=0;m<i[y].length&&!(i[y][m]<0);m++)for(g=m+1;g<i[y].length&&!(i[y][g]<0);g++)v=t(n[i[y][m]],n[i[y][g]]),s.heapPush(f,i[y][m],v,i[y][g],1),s.heapPush(f,i[y][g],v,i[y][m],1);for(y=0;y<r;y++){var w=s.buildCandidates(f,d,o,a,e),b=0;for(m=0;m<d;m++)for(g=0;g<a;g++){var C=Math.floor(w[0][m][g]);if(!(C<0||l.tauRand(e)<u))for(var S=0;S<a;S++){var T=Math.floor(w[0][m][S]),M=w[2][m][g],E=w[2][m][S];T<0||!M&&!E||(v=t(n[C],n[T]),b+=s.heapPush(f,C,v,T,1),b+=s.heapPush(f,T,v,C,1))}}if(b<=h*o*n.length)break}return s.deheapSort(f)}},e.makeInitializations=function(t){return{initFromRandom:function(e,n,i,o,r){for(var a=0;a<i.length;a++)for(var h=l.rejectionSample(e,n.length,r),u=0;u<h.length;u++)if(!(h[u]<0)){var c=t(n[h[u]],i[a]);s.heapPush(o,a,c,h[u],1)}},initFromTree:function(e,n,i,o,r){for(var l=0;l<i.length;l++)for(var h=a.searchFlatTree(i[l],e,r),u=0;u<h.length;u++){if(h[u]<0)return;var c=t(n[h[u]],i[l]);s.heapPush(o,l,c,h[u],1)}}}},e.makeInitializedNNSearch=function(t){return function(e,n,o,a){for(var l,h,u=r.getCSR(n),c=u.indices,d=u.indptr,f=0;f<a.length;f++)for(var m=new Set(o[0][f]);;){var p=s.smallestFlagged(o,f);if(-1===p)break;var g=c.slice(d[p],d[p+1]);try{for(var v=i(g),y=v.next();!y.done;y=v.next()){var w=y.value;if(w!==p&&-1!==w&&!m.has(w)){var b=t(e[w],a[f]);s.uncheckedHeapPush(o,f,b,w,1),m.add(w)}}}catch(t){l={error:t}}finally{try{y&&!y.done&&(h=v.return)&&h.call(v)}finally{if(l)throw l.error}}}return o}},e.initializeSearch=function(t,e,n,o,r,a,l){var h,u,c=s.makeHeap(n.length,o);if(r(o,e,n,c,l),t)try{for(var d=i(t),f=d.next();!f.done;f=d.next())a(f.value,e,n,c,l)}catch(t){h={error:t}}finally{try{f&&!f.done&&(u=d.return)&&u.call(d)}finally{if(h)throw h.error}}return c}},2320:function(t,e,n){"use strict";var i=this&&this.__read||function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var i,o,s=n.call(t),r=[];try{for(;(void 0===e||e-- >0)&&!(i=s.next()).done;)r.push(i.value)}catch(t){o={error:t}}finally{try{i&&!i.done&&(n=s.return)&&n.call(s)}finally{if(o)throw o.error}}return r},o=this&&this.__spread||function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(i(arguments[e]));return t},s=this&&this.__values||function(t){var e="function"==typeof Symbol&&t[Symbol.iterator],n=0;return e?e.call(t):{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}}},r=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e.default=t,e};Object.defineProperty(e,"__esModule",{value:!0});var a=r(n(4517)),l=function(t,e,n,i){this.hyperplanes=t,this.offsets=e,this.children=n,this.indices=i};function h(t,e,n,i,o){if(void 0===n&&(n=30),e.length>n){var s=function(t,e,n){var i=t[0].length,o=a.tauRandInt(e.length,n),s=a.tauRandInt(e.length,n);s=(s+=o===s?1:0)%e.length;for(var r=e[o],l=e[s],h=0,u=a.zeros(i),c=0;c<u.length;c++)u[c]=t[r][c]-t[l][c],h-=u[c]*(t[r][c]+t[l][c])/2;var d=0,f=0,m=a.zeros(e.length);for(c=0;c<e.length;c++){for(var p=h,g=0;g<i;g++)p+=u[g]*t[e[c]][g];0===p?(m[c]=a.tauRandInt(2,n),0===m[c]?d+=1:f+=1):p>0?(m[c]=0,d+=1):(m[c]=1,f+=1)}var v=a.zeros(d),y=a.zeros(f);for(d=0,f=0,c=0;c<m.length;c++)0===m[c]?(v[d]=e[c],d+=1):(y[f]=e[c],f+=1);return{indicesLeft:v,indicesRight:y,hyperplane:u,offset:h}}(t,e,o),r=s.indicesLeft,l=s.indicesRight,u=s.hyperplane,c=s.offset;return{leftChild:h(t,r,n,i+1,o),rightChild:h(t,l,n,i+1,o),isLeaf:!1,hyperplane:u,offset:c}}return{indices:e,isLeaf:!0}}function u(t,e,n,i,s,r,a){var l;if(t.isLeaf)return i[r][0]=-a,(l=s[a]).splice.apply(l,o([0,t.indices.length],t.indices)),{nodeNum:r,leafNum:a+=1};e[r]=t.hyperplane,n[r]=t.offset,i[r][0]=r+1;var h=r,c=u(t.leftChild,e,n,i,s,r+1,a);return r=c.nodeNum,a=c.leafNum,i[h][1]=r+1,{nodeNum:(c=u(t.rightChild,e,n,i,s,r+1,a)).nodeNum,leafNum:c.leafNum}}function c(t){return t.isLeaf?1:1+c(t.leftChild)+c(t.rightChild)}function d(t){return t.isLeaf?1:d(t.leftChild)+d(t.rightChild)}function f(t,e,n,i){for(var o=e,s=0;s<n.length;s++)o+=t[s]*n[s];return 0===o?a.tauRandInt(2,i):o>0?0:1}e.FlatTree=l,e.makeForest=function(t,e,n,i){var o=Math.max(10,e);return a.range(n).map((function(e,n){return function(t,e,n,i){return void 0===e&&(e=30),h(t,a.range(t.length),e,n,i)}(t,o,n,i)})).map((function(t){return function(t,e){var n=c(t),i=d(t),o=a.range(n).map((function(){return a.zeros(t.hyperplane?t.hyperplane.length:0)})),s=a.zeros(n),r=a.range(n).map((function(){return[-1,-1]})),h=a.range(i).map((function(){return a.range(e).map((function(){return-1}))}));return u(t,o,s,r,h,0,0),new l(o,s,r,h)}(t,o)}))},e.makeLeafArray=function(t){var e,n;if(t.length>0){var i=[];try{for(var r=s(t),a=r.next();!a.done;a=r.next()){var l=a.value;i.push.apply(i,o(l.indices))}}catch(t){e={error:t}}finally{try{a&&!a.done&&(n=r.return)&&n.call(r)}finally{if(e)throw e.error}}return i}return[[-1]]},e.searchFlatTree=function(t,e,n){for(var i=0;e.children[i][0]>0;)i=0===f(e.hyperplanes[i],e.offsets[i],t,n)?e.children[i][0]:e.children[i][1];var o=-1*e.children[i][0];return e.indices[o]}},4364:function(t,e,n){"use strict";var i=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){t.done?o(t.value):new n((function(e){e(t.value)})).then(r,a)}l((i=i.apply(t,e||[])).next())}))},o=this&&this.__generator||function(t,e){var n,i,o,s,r={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;r;)try{if(n=1,i&&(o=2&s[0]?i.return:s[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,s[1])).done)return o;switch(i=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return r.label++,{value:s[1],done:!1};case 5:r.label++,i=s[1],s=[0];continue;case 7:s=r.ops.pop(),r.trys.pop();continue;default:if(!((o=(o=r.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){r=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){r.label=s[1];break}if(6===s[0]&&r.label<o[1]){r.label=o[1],o=s;break}if(o&&r.label<o[2]){r.label=o[2],r.ops.push(s);break}o[2]&&r.ops.pop(),r.trys.pop();continue}s=e.call(t,r)}catch(t){s=[6,t],i=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,a])}}},s=this&&this.__read||function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var i,o,s=n.call(t),r=[];try{for(;(void 0===e||e-- >0)&&!(i=s.next()).done;)r.push(i.value)}catch(t){o={error:t}}finally{try{i&&!i.done&&(n=s.return)&&n.call(s)}finally{if(o)throw o.error}}return r},r=this&&this.__spread||function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(s(arguments[e]));return t},a=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e.default=t,e},l=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});var h=a(n(9378)),u=a(n(5686)),c=a(n(760)),d=a(n(2320)),f=a(n(4517)),m=l(n(9251)),p=1e-5,g=.001,v=function(){function t(t){void 0===t&&(t={});var e=this;this.learningRate=1,this.localConnectivity=1,this.minDist=.1,this.nComponents=2,this.nEpochs=0,this.nNeighbors=15,this.negativeSampleRate=5,this.random=Math.random,this.repulsionStrength=1,this.setOpMixRatio=1,this.spread=1,this.transformQueueSize=4,this.targetMetric="categorical",this.targetWeight=.5,this.targetNNeighbors=this.nNeighbors,this.distanceFn=y,this.isInitialized=!1,this.rpForest=[],this.embedding=[],this.optimizationState=new w;var n=function(n){void 0!==t[n]&&(e[n]=t[n])};n("distanceFn"),n("learningRate"),n("localConnectivity"),n("minDist"),n("nComponents"),n("nEpochs"),n("nNeighbors"),n("negativeSampleRate"),n("random"),n("repulsionStrength"),n("setOpMixRatio"),n("spread"),n("transformQueueSize")}return t.prototype.fit=function(t){return this.initializeFit(t),this.optimizeLayout(),this.embedding},t.prototype.fitAsync=function(t,e){return void 0===e&&(e=function(){return!0}),i(this,void 0,void 0,(function(){return o(this,(function(n){switch(n.label){case 0:return this.initializeFit(t),[4,this.optimizeLayoutAsync(e)];case 1:return n.sent(),[2,this.embedding]}}))}))},t.prototype.setSupervisedProjection=function(t,e){void 0===e&&(e={}),this.Y=t,this.targetMetric=e.targetMetric||this.targetMetric,this.targetWeight=e.targetWeight||this.targetWeight,this.targetNNeighbors=e.targetNNeighbors||this.targetNNeighbors},t.prototype.setPrecomputedKNN=function(t,e){this.knnIndices=t,this.knnDistances=e},t.prototype.initializeFit=function(t){if(t.length<=this.nNeighbors)throw new Error("Not enough data points ("+t.length+") to create nNeighbors: "+this.nNeighbors+". Add more data points or adjust the configuration.");if(this.X===t&&this.isInitialized)return this.getNEpochs();if(this.X=t,!this.knnIndices&&!this.knnDistances){var e=this.nearestNeighbors(t);this.knnIndices=e.knnIndices,this.knnDistances=e.knnDistances}this.graph=this.fuzzySimplicialSet(t,this.nNeighbors,this.setOpMixRatio),this.makeSearchFns(),this.searchGraph=this.makeSearchGraph(t),this.processGraphForSupervisedProjection();var n=this.initializeSimplicialSetEmbedding(),i=n.head,o=n.tail,s=n.epochsPerSample;return this.optimizationState.head=i,this.optimizationState.tail=o,this.optimizationState.epochsPerSample=s,this.initializeOptimization(),this.prepareForOptimizationLoop(),this.isInitialized=!0,this.getNEpochs()},t.prototype.makeSearchFns=function(){var t=c.makeInitializations(this.distanceFn),e=t.initFromTree,n=t.initFromRandom;this.initFromTree=e,this.initFromRandom=n,this.search=c.makeInitializedNNSearch(this.distanceFn)},t.prototype.makeSearchGraph=function(t){for(var e=this.knnIndices,n=this.knnDistances,i=[t.length,t.length],o=new u.SparseMatrix([],[],[],i),s=0;s<e.length;s++)for(var r=e[s],a=n[s],l=0;l<r.length;l++){var h=r[l],c=a[l];c>0&&o.set(s,h,c)}var d=u.transpose(o);return u.maximum(o,d)},t.prototype.transform=function(t){var e=this,n=this.X;if(void 0===n||0===n.length)throw new Error("No data has been fit.");var i=Math.floor(this.nNeighbors*this.transformQueueSize);i=Math.min(n.length,i);var o=c.initializeSearch(this.rpForest,n,t,i,this.initFromRandom,this.initFromTree,this.random),s=this.search(n,this.searchGraph,o,t),r=h.deheapSort(s),a=r.indices,l=r.weights;a=a.map((function(t){return t.slice(0,e.nNeighbors)})),l=l.map((function(t){return t.slice(0,e.nNeighbors)}));var d=Math.max(0,this.localConnectivity-1),m=this.smoothKNNDistance(l,this.nNeighbors,d),p=m.sigmas,g=m.rhos,v=this.computeMembershipStrengths(a,l,p,g),y=v.rows,w=v.cols,b=v.vals,C=[t.length,n.length],S=new u.SparseMatrix(y,w,b,C),T=u.normalize(S,"l1"),M=u.getCSR(T),A=t.length,R=E(f.reshape2d(M.indices,A,this.nNeighbors),f.reshape2d(M.values,A,this.nNeighbors),this.embedding),P=this.nEpochs?this.nEpochs/3:S.nRows<=1e4?100:30,N=S.getValues().reduce((function(t,e){return e>t?e:t}),0);S=S.map((function(t){return t<N/P?0:t})),S=u.eliminateZeros(S);var x=this.makeEpochsPerSample(S.getValues(),P),L=S.getRows(),G=S.getCols();return this.assignOptimizationStateParameters({headEmbedding:R,tailEmbedding:this.embedding,head:L,tail:G,currentEpoch:0,nEpochs:P,nVertices:S.getDims()[1],epochsPerSample:x}),this.prepareForOptimizationLoop(),this.optimizeLayout()},t.prototype.processGraphForSupervisedProjection=function(){var t=this.Y,e=this.X;if(t){if(t.length!==e.length)throw new Error("Length of X and y must be equal");if("categorical"===this.targetMetric){var n=this.targetWeight<1?1/(1-this.targetWeight)*2.5:1e12;this.graph=this.categoricalSimplicialSetIntersection(this.graph,t,n)}}},t.prototype.step=function(){var t=this.optimizationState.currentEpoch;return t<this.getNEpochs()&&this.optimizeLayoutStep(t),this.optimizationState.currentEpoch},t.prototype.getEmbedding=function(){return this.embedding},t.prototype.nearestNeighbors=function(t){var e,n=this.distanceFn,i=this.nNeighbors,o=c.makeNNDescent(n,this.random),s=5+Math.floor(.5==(e=Math.pow(t.length,.5)/20)?0:Math.round(e)),r=Math.max(5,Math.floor(Math.round(function(t){return Math.log(t)/Math.log(2)}(t.length))));this.rpForest=d.makeForest(t,i,s,this.random);var a=o(t,d.makeLeafArray(this.rpForest),i,r);return{knnIndices:a.indices,knnDistances:a.weights}},t.prototype.fuzzySimplicialSet=function(t,e,n){void 0===n&&(n=1);var i=this,o=i.knnIndices,s=void 0===o?[]:o,r=i.knnDistances,a=void 0===r?[]:r,l=i.localConnectivity,h=this.smoothKNNDistance(a,e,l),c=h.sigmas,d=h.rhos,f=this.computeMembershipStrengths(s,a,c,d),m=f.rows,p=f.cols,g=f.vals,v=[t.length,t.length],y=new u.SparseMatrix(m,p,g,v),w=u.transpose(y),b=u.pairwiseMultiply(y,w),C=u.subtract(u.add(y,w),b),S=u.multiplyScalar(C,n),T=u.multiplyScalar(b,1-n);return u.add(S,T)},t.prototype.categoricalSimplicialSetIntersection=function(t,e,n,i){void 0===i&&(i=1);var o=T(t,e,i,n);return M(o=u.eliminateZeros(o))},t.prototype.smoothKNNDistance=function(t,e,n,i,o){void 0===n&&(n=1),void 0===i&&(i=64),void 0===o&&(o=1);for(var s=Math.log(e)/Math.log(2)*o,r=f.zeros(t.length),a=f.zeros(t.length),l=0;l<t.length;l++){var h=0,u=1/0,c=1,d=t[l],m=d.filter((function(t){return t>0}));if(m.length>=n){var v=Math.floor(n),y=n-v;v>0?(r[l]=m[v-1],y>p&&(r[l]+=y*(m[v]-m[v-1]))):r[l]=y*m[0]}else m.length>0&&(r[l]=f.max(m));for(var w=0;w<i;w++){for(var b=0,C=1;C<t[l].length;C++){var S=t[l][C]-r[l];b+=S>0?Math.exp(-S/c):1}if(Math.abs(b-s)<p)break;b>s?c=(h+(u=c))/2:(h=c,u===1/0?c*=2:c=(h+u)/2)}if(a[l]=c,r[l]>0){var T=f.mean(d);a[l]<g*T&&(a[l]=g*T)}else{var M=f.mean(t.map(f.mean));a[l]<g*M&&(a[l]=g*M)}}return{sigmas:a,rhos:r}},t.prototype.computeMembershipStrengths=function(t,e,n,i){for(var o=t.length,s=t[0].length,r=f.zeros(o*s),a=f.zeros(o*s),l=f.zeros(o*s),h=0;h<o;h++)for(var u=0;u<s;u++){var c=0;-1!==t[h][u]&&(c=t[h][u]===h?0:e[h][u]-i[h]<=0?1:Math.exp(-(e[h][u]-i[h])/n[h]),r[h*s+u]=h,a[h*s+u]=t[h][u],l[h*s+u]=c)}return{rows:r,cols:a,vals:l}},t.prototype.initializeSimplicialSetEmbedding=function(){for(var t=this,e=this.getNEpochs(),n=this.nComponents,i=this.graph.getValues(),o=0,s=0;s<i.length;s++){var r=i[s];o<i[s]&&(o=r)}var a=this.graph.map((function(t){return t<o/e?0:t}));this.embedding=f.zeros(a.nRows).map((function(){return f.zeros(n).map((function(){return 20*f.tauRand(t.random)-10}))}));var l=[],h=[],u=[],c=a.getAll();for(s=0;s<c.length;s++){var d=c[s];d.value&&(l.push(d.value),u.push(d.row),h.push(d.col))}return{head:h,tail:u,epochsPerSample:this.makeEpochsPerSample(l,e)}},t.prototype.makeEpochsPerSample=function(t,e){var n=f.filled(t.length,-1),i=f.max(t),o=t.map((function(t){return t/i*e}));return o.forEach((function(t,i){t>0&&(n[i]=e/o[i])})),n},t.prototype.assignOptimizationStateParameters=function(t){Object.assign(this.optimizationState,t)},t.prototype.prepareForOptimizationLoop=function(){var t=this,e=t.repulsionStrength,n=t.learningRate,i=t.negativeSampleRate,o=this.optimizationState,s=o.epochsPerSample,a=o.headEmbedding,l=o.tailEmbedding,h=a[0].length,u=a.length===l.length,c=s.map((function(t){return t/i})),d=r(c),f=r(s);this.assignOptimizationStateParameters({epochOfNextSample:f,epochOfNextNegativeSample:d,epochsPerNegativeSample:c,moveOther:u,initialAlpha:n,alpha:n,gamma:e,dim:h})},t.prototype.initializeOptimization=function(){var t=this.embedding,e=this.embedding,n=this.optimizationState,i=n.head,o=n.tail,s=n.epochsPerSample,r=this.getNEpochs(),a=this.graph.nCols,l=S(this.spread,this.minDist),h=l.a,u=l.b;this.assignOptimizationStateParameters({headEmbedding:t,tailEmbedding:e,head:i,tail:o,epochsPerSample:s,a:h,b:u,nEpochs:r,nVertices:a})},t.prototype.optimizeLayoutStep=function(t){for(var e=this.optimizationState,n=e.head,i=e.tail,o=e.headEmbedding,s=e.tailEmbedding,r=e.epochsPerSample,a=e.epochOfNextSample,l=e.epochOfNextNegativeSample,h=e.epochsPerNegativeSample,u=e.moveOther,c=e.initialAlpha,d=e.alpha,m=e.gamma,p=e.a,g=e.b,v=e.dim,y=e.nEpochs,w=e.nVertices,S=0;S<r.length;S++)if(!(a[S]>t)){var T=n[S],M=i[S],E=o[T],A=s[M],R=C(E,A),P=0;R>0&&(P=-2*p*g*Math.pow(R,g-1),P/=p*Math.pow(R,g)+1);for(var N=0;N<v;N++){var x=b(P*(E[N]-A[N]),4);E[N]+=x*d,u&&(A[N]+=-x*d)}a[S]+=r[S];for(var L=Math.floor((t-l[S])/h[S]),G=0;G<L;G++){var _=f.tauRandInt(w,this.random),I=s[_],W=C(E,I),F=0;if(W>0)F=2*m*g,F/=(.001+W)*(p*Math.pow(W,g)+1);else if(T===_)continue;for(N=0;N<v;N++)x=4,F>0&&(x=b(F*(E[N]-I[N]),4)),E[N]+=x*d}l[S]+=L*h[S]}return e.alpha=c*(1-t/y),e.currentEpoch+=1,o},t.prototype.optimizeLayoutAsync=function(t){var e=this;return void 0===t&&(t=function(){return!0}),new Promise((function(n,s){var r=function(){return i(e,void 0,void 0,(function(){var e,i,a,l,h,u;return o(this,(function(o){try{if(e=this.optimizationState,i=e.nEpochs,a=e.currentEpoch,this.embedding=this.optimizeLayoutStep(a),l=this.optimizationState.currentEpoch,h=!1===t(l),u=l===i,h||u)return[2,n(u)];setTimeout((function(){return r()}),0)}catch(t){s(t)}return[2]}))}))};setTimeout((function(){return r()}),0)}))},t.prototype.optimizeLayout=function(t){void 0===t&&(t=function(){return!0});for(var e=!1,n=[];!e;){var i=this.optimizationState,o=i.nEpochs,s=i.currentEpoch;n=this.optimizeLayoutStep(s);var r=this.optimizationState.currentEpoch,a=!1===t(r);e=r===o||a}return n},t.prototype.getNEpochs=function(){var t=this.graph;if(this.nEpochs>0)return this.nEpochs;var e=t.nRows;return e<=2500?500:e<=5e3?400:e<=7500?300:200},t}();function y(t,e){for(var n=0,i=0;i<t.length;i++)n+=Math.pow(t[i]-e[i],2);return Math.sqrt(n)}e.UMAP=v,e.euclidean=y,e.cosine=function(t,e){for(var n=0,i=0,o=0,s=0;s<t.length;s++)n+=t[s]*e[s],i+=Math.pow(t[s],2),o+=Math.pow(e[s],2);return 0===i&&0===o?0:0===i||0===o?1:1-n/Math.sqrt(i*o)};var w=function(){this.currentEpoch=0,this.headEmbedding=[],this.tailEmbedding=[],this.head=[],this.tail=[],this.epochsPerSample=[],this.epochOfNextSample=[],this.epochOfNextNegativeSample=[],this.epochsPerNegativeSample=[],this.moveOther=!0,this.initialAlpha=1,this.alpha=1,this.gamma=1,this.a=1.5769434603113077,this.b=.8950608779109733,this.dim=2,this.nEpochs=500,this.nVertices=0};function b(t,e){return t>e?e:t<-e?-e:t}function C(t,e){for(var n=0,i=0;i<t.length;i++)n+=Math.pow(t[i]-e[i],2);return n}function S(t,e){var n=f.linear(0,3*t,300).map((function(t){return t<e?1:t})),i=f.zeros(n.length).map((function(i,o){return n[o]>=e?Math.exp(-(n[o]-e)/t):i})),o={x:n,y:i},r=m.default(o,(function(t){var e=s(t,2),n=e[0],i=e[1];return function(t){return 1/(1+n*Math.pow(t,2*i))}}),{damping:1.5,initialValues:[.5,.5],gradientDifference:.1,maxIterations:100,errorTolerance:.01}).parameterValues,a=s(r,2);return{a:a[0],b:a[1]}}function T(t,e,n,i){return void 0===n&&(n=1),void 0===i&&(i=5),t.map((function(t,o,s){return-1===e[o]||-1===e[s]?t*Math.exp(-n):e[o]!==e[s]?t*Math.exp(-i):t}))}function M(t){t=u.normalize(t,"max");var e=u.transpose(t),n=u.pairwiseMultiply(e,t);return t=u.add(t,u.subtract(e,n)),u.eliminateZeros(t)}function E(t,e,n){for(var i=f.zeros(t.length).map((function(t){return f.zeros(n[0].length)})),o=0;o<t.length;o++)for(var s=0;s<t[0].length;s++)for(var r=0;r<n[0].length;r++){var a=t[o][s];i[o][r]+=e[o][s]*n[a][r]}return i}e.findABParams=S,e.fastIntersection=T,e.resetLocalConnectivity=M,e.initTransform=E},4517:function(t,e){"use strict";var n=this&&this.__values||function(t){var e="function"==typeof Symbol&&t[Symbol.iterator],n=0;return e?e.call(t):{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}}};function i(t,e){return Math.floor(e()*t)}function o(t){for(var e=[],n=0;n<t;n++)e.push(void 0);return e}function s(t,e){return o(t).map((function(){return e}))}function r(t){return s(t,0)}function a(t){return t.reduce((function(t,e){return t+e}))}Object.defineProperty(e,"__esModule",{value:!0}),e.tauRandInt=i,e.tauRand=function(t){return t()},e.norm=function(t){var e,i,o=0;try{for(var s=n(t),r=s.next();!r.done;r=s.next()){var a=r.value;o+=Math.pow(a,2)}}catch(t){e={error:t}}finally{try{r&&!r.done&&(i=s.return)&&i.call(s)}finally{if(e)throw e.error}}return Math.sqrt(o)},e.empty=o,e.range=function(t){return o(t).map((function(t,e){return e}))},e.filled=s,e.zeros=r,e.ones=function(t){return s(t,1)},e.linear=function(t,e,n){return o(n).map((function(i,o){return t+o*((e-t)/(n-1))}))},e.sum=a,e.mean=function(t){return a(t)/t.length},e.max=function(t){for(var e=0,n=0;n<t.length;n++)e=t[n]>e?t[n]:e;return e},e.max2d=function(t){for(var e=0,n=0;n<t.length;n++)for(var i=0;i<t[n].length;i++)e=t[n][i]>e?t[n][i]:e;return e},e.rejectionSample=function(t,e,n){for(var o=r(t),s=0;s<t;s++)for(var a=!0;a;){for(var l=i(e,n),h=!1,u=0;u<s;u++)if(l===o[u]){h=!0;break}h||(a=!1),o[s]=l}return o},e.reshape2d=function(t,e,n){var i=[],o=0;if(t.length!==e*n)throw new Error("Array dimensions must match input length.");for(var s=0;s<e;s++){for(var r=[],a=0;a<n;a++)r.push(t[o]),o+=1;i.push(r)}return i}},3336:t=>{"use strict";t.exports=$},976:t=>{"use strict";t.exports=DG},4469:t=>{"use strict";t.exports=grok},701:t=>{"use strict";t.exports=rxjs},3870:t=>{"use strict";t.exports=ui},6414:t=>{"use strict";t.exports=wu}},e={};function n(i){var o=e[i];if(void 0!==o)return o.exports;var s=e[i]={id:i,exports:{}};return t[i].call(s.exports,s,s.exports,n),s.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var i in e)n.o(e,i)&&!n.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.nc=void 0;var i={};(()=>{"use strict";n.r(i),n.d(i,{_package:()=>ut,test:()=>ct,tests:()=>e.QK});var t=n(976),e=n(1061);(0,e.W3)("_first",(()=>{(0,e.Bu)("_first",(()=>{return t=void 0,e=void 0,i=function*(){},new((n=void 0)||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}));var t,e,n,i}))}));var o=n(2012),s=n(9976),r=n(6137),a=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))},l=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};(0,e.W3)("Palettes",(()=>{(0,e.Bu)("testPaletteN",(()=>l(void 0,void 0,void 0,(function*(){yield function(){return a(this,void 0,void 0,(function*(){const t=r.J.Chromatogram;(0,e.l_)(t instanceof s.B,!0),(0,e.l_)(t instanceof r.J,!0)}))}()})))),(0,e.Bu)("testPaletteAA",(()=>l(void 0,void 0,void 0,(function*(){yield function(){return a(this,void 0,void 0,(function*(){const t=o.f.Lesk,n=o.f.RasMol,i=o.f.GrokGroups;(0,e.l_)(t instanceof s.B,!0),(0,e.l_)(n instanceof s.B,!0),(0,e.l_)(i instanceof s.B,!0),(0,e.l_)(t instanceof o.f,!0),(0,e.l_)(n instanceof o.f,!0),(0,e.l_)(i instanceof o.f,!0)}))}()})))),(0,e.Bu)("testPalettePtMe",(()=>l(void 0,void 0,void 0,(function*(){const t=o.f.GrokGroups.get("MeNle"),n=o.f.GrokGroups.get("MeA"),i=o.f.GrokGroups.get("MeG"),s=o.f.GrokGroups.get("MeF"),r=o.f.GrokGroups.get("L"),a=o.f.GrokGroups.get("A"),l=o.f.GrokGroups.get("G"),h=o.f.GrokGroups.get("F");(0,e.l_)(t,r),(0,e.l_)(n,a),(0,e.l_)(i,l),(0,e.l_)(s,h)}))))}));var h=n(4469),u=n(7399),c=n(499),d=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};function f(e,n){return d(this,void 0,void 0,(function*(){const i=(yield e()).getCol(n),o=yield h.functions.call("Bio:detectMacromolecule",{col:i});if(o&&(i.semType=o),i.semType===t.SEMTYPE.MACROMOLECULE){const e=`Negative test detected semType='${i.semType}', units='${i.getTag(t.TAGS.UNITS)}'.`;throw new Error(e)}}))}function m(n,i,o,s,r,a,l,u=null){return d(this,void 0,void 0,(function*(){const d=(yield n()).col(i),f=yield h.functions.call("Bio:detectMacromolecule",{col:d});f&&(d.semType=f),(0,e.l_)(d.semType,t.SEMTYPE.MACROMOLECULE),(0,e.l_)(d.getTag(t.TAGS.UNITS),o),(0,e.l_)(d.getTag("aligned"),s),(0,e.l_)(d.getTag("alphabet"),r),u&&(0,e.l_)(d.getTag("separator"),u);const m=new c.C(d);(0,e.l_)(m.getAlphabetSize(),a),(0,e.l_)(m.getAlphabetIsMultichar(),l),m.isHelm()||((0,e.l_)(m.aligned,s),(0,e.l_)(m.alphabet,r))}))}(0,e.W3)("detectors",(()=>{var n,i,o,s,r,a,l,u,c,v,y,w,b,C,S,T,M,E;const A=new(E=class{constructor(){this[n]="id,col1\n1,\n2,\n3,\n4,\n5,",this[i]="col1\n1\n2\n3",this[o]="col1\n4\n5\n6\n7",this[s]="col1\n8\n9\n10\n11\n12",this[r]="col1\nCCCCN1C(=O)CN=C(c2cc(F)ccc12)C3CCCCC3\nC1CCCCC1\nCCCCCC\n",this[a]="seq\nACGTC\nCAGTGT\nTTCAAC\n",this[l]="seq\nACGUC\nCAGUGU\nUUCAAC\n",this[u]="seq\nFWPHEY\nYNRQWYV\nMKPSEYV\n",this[c]="seq\n[meI][hHis][Aca]NT[dE][Thr_PO3H2][Aca]D\n[meI][hHis][Aca][Cys_SEt]T[dK][Thr_PO3H2][Aca][Tyr_PO3H2]\n[Lys_Boc][hHis][Aca][Cys_SEt]T[dK][Thr_PO3H2][Aca][Tyr_PO3H2]\n",this[v]="seq\nA*C*G*T*C\nC*A*G*T*G*T\nT*T*C*A*A*C\n",this[y]="seq\nA*C*G*U*C\nC*A*G*U*G*U\nU*U*C*A*A*C\n",this[w]="seq\nF-W-P-H-E-Y\nY-N-R-Q-W-Y-V\nM-K-P-S-E-Y-V\n",this[b]="seq\nabc-dfgg-abc1-cfr3-rty-wert\nrut12-her2-rty-wert-abc-abc1-dfgg\nrut12-rty-her2-abc-cfr3-wert-rut12\n",this[C]="seq\nabc/dfgg/abc1/cfr3/rty/wert\nrut12/her2/rty/wert//abc/abc1/dfgg\nrut12/rty/her2/abc/cfr3//wert/rut12\n",this[S]="seq\nA-C--G-T--C-T\nC-A-C--T--G-T\nA-C-C-G-T-A-C-T\n",this[T]="seq\nAC-GT-CT\nCAC-T-GT\nACCGTACT\n",this[M]="seq\nFWR-WYV-KHP\nYNR-WYV-KHP\nMWRSWY-CKHP\n"}},n="negEmpty",i="neg1",o="neg2",s="neg3",r="negSmiles",a="csvFastaDna1",l="fastaRna1",u="fastaPt1",c="fastaUn",v="sepDna",y="sepRna",w="sepPt",b="sepUn1",C="sepUn2",S="sepMsaDna1",T="fastaMsaDna1",M="fastaMsaPt1",E),R={fastaFasta:"System:AppData/Bio/data/sample_FASTA.fasta",fastaPtCsv:"System:AppData/Bio/data/sample_FASTA_PT.csv",msaComplex:"System:AppData/Bio/samples/sample_MSA.csv",fastaCsv:"System:AppData/Bio/samples/sample_FASTA.csv",helmCsv:"System:AppData/Bio/samples/sample_HELM.csv",peptidesComplex:"System:AppData/Bio/tests/peptides_complex_msa.csv",peptidesSimple:"System:AppData/Bio/tests/peptides_simple_msa.csv",testDemogCsv:"System:AppData/Bio/tests/testDemog.csv",testHelmCsv:"System:AppData/Bio/tests/testHelm.csv",testIdCsv:"System:AppData/Bio/tests/testId.csv",testSmilesCsv:"System:AppData/Bio/tests/testSmiles.csv",testSmiles2Csv:"System:AppData/Bio/tests/testSmiles2.csv",testSmilesShort:"System:AppData/Bio/tests/testSmilesShort.csv",testActivityCliffsCsv:"System:AppData/Bio/tests/testActivityCliffs.csv",testCerealCsv:"System:AppData/Bio/tests/testCereal.csv",testUnichemSources:"System:AppData/Bio/tests/testUnichemSources.csv",testDmvOffices:"System:AppData/Bio/tests/testDmvOffices.csv",testAlertCollection:"System:AppData/Bio/tests/testAlertCollection.csv",testSpgi100:"System:AppData/Bio/tests/testSpgi100.csv",testSpgi:"System:AppData/Bio/tests/SPGI-derived.csv",testUrl:"System:AppData/Bio/tests/testUrl.csv"},P={};function N(t,e=x){return()=>d(this,void 0,void 0,(function*(){return t in P||(P[t]=(()=>d(this,void 0,void 0,(function*(){return yield e(R[t])})))()),P[t]}))}function x(e){return d(this,void 0,void 0,(function*(){const n=yield h.dapi.files.readAsText(e);return t.DataFrame.fromCsv(n)}))}const L=e=>()=>d(void 0,void 0,void 0,(function*(){const n=A[e],i=t.DataFrame.fromCsv(n);return yield h.data.detectSemanticTypes(i),i}));(0,e.Bu)("NegativeEmpty",(()=>d(void 0,void 0,void 0,(function*(){yield f(L("negEmpty"),"col1")})))),(0,e.Bu)("Negative1",(()=>d(void 0,void 0,void 0,(function*(){yield f(L("neg1"),"col1")})))),(0,e.Bu)("Negative2",(()=>d(void 0,void 0,void 0,(function*(){yield f(L("neg2"),"col1")})))),(0,e.Bu)("Negative3",(()=>d(void 0,void 0,void 0,(function*(){yield f(L("neg3"),"col1")})))),(0,e.Bu)("NegativeSmiles",(()=>d(void 0,void 0,void 0,(function*(){yield f(L("negSmiles"),"col1")})))),(0,e.Bu)("FastaDna1",(()=>d(void 0,void 0,void 0,(function*(){yield m(L("csvFastaDna1"),"seq","fasta","SEQ","DNA",4,!1)})))),(0,e.Bu)("FastaRna1",(()=>d(void 0,void 0,void 0,(function*(){yield m(L("fastaRna1"),"seq","fasta","SEQ","RNA",4,!1)})))),(0,e.Bu)("FastaPt1",(()=>d(void 0,void 0,void 0,(function*(){yield m(L("fastaPt1"),"seq","fasta","SEQ","PT",20,!1)})))),(0,e.Bu)("FastaUn",(()=>d(void 0,void 0,void 0,(function*(){yield m(L("fastaUn"),"seq","fasta","SEQ.MSA","UN",12,!0)})))),(0,e.Bu)("FastaMsaDna1",(()=>d(void 0,void 0,void 0,(function*(){yield m(L("fastaMsaDna1"),"seq","fasta","SEQ.MSA","DNA",4,!1)})))),(0,e.Bu)("FastaMsaPt1",(()=>d(void 0,void 0,void 0,(function*(){yield m(L("fastaMsaPt1"),"seq","fasta","SEQ.MSA","PT",20,!1)})))),(0,e.Bu)("SepDna",(()=>d(void 0,void 0,void 0,(function*(){yield m(L("sepDna"),"seq","separator","SEQ","DNA",4,!1,"*")})))),(0,e.Bu)("SepRna",(()=>d(void 0,void 0,void 0,(function*(){yield m(L("sepRna"),"seq","separator","SEQ","RNA",4,!1,"*")})))),(0,e.Bu)("SepPt",(()=>d(void 0,void 0,void 0,(function*(){yield m(L("sepPt"),"seq","separator","SEQ","PT",20,!1,"-")})))),(0,e.Bu)("SepUn1",(()=>d(void 0,void 0,void 0,(function*(){yield m(L("sepUn1"),"seq","separator","SEQ","UN",8,!0,"-")})))),(0,e.Bu)("SepUn2",(()=>d(void 0,void 0,void 0,(function*(){yield m(L("sepUn2"),"seq","separator","SEQ","UN",9,!0,"/")})))),(0,e.Bu)("SepMsaN1",(()=>d(void 0,void 0,void 0,(function*(){yield m(L("sepMsaDna1"),"seq","separator","SEQ.MSA","DNA",4,!1,"-")})))),(0,e.Bu)("samplesFastaCsv",(()=>d(void 0,void 0,void 0,(function*(){yield g(N("fastaCsv"),{Sequence:new p("fasta","SEQ","PT",20,!1)})})))),(0,e.Bu)("samplesFastaFasta",(()=>d(void 0,void 0,void 0,(function*(){yield g(N("fastaFasta"),{sequence:new p("fasta","SEQ","PT",20,!1)})})))),(0,e.Bu)("samplesPeptidesComplex",(()=>d(void 0,void 0,void 0,(function*(){yield g(N("peptidesComplex"),{})})))),(0,e.Bu)("samplesMsaComplex",(()=>d(void 0,void 0,void 0,(function*(){yield g(N("msaComplex"),{MSA:new p("separator","SEQ.MSA","UN",161,!0,"/")})})))),(0,e.Bu)("samplesIdCsv",(()=>d(void 0,void 0,void 0,(function*(){yield g(N("testIdCsv"),{})})))),(0,e.Bu)("samplesSarSmallCsv",(()=>d(void 0,void 0,void 0,(function*(){yield g(N("testSmilesCsv"),{})})))),(0,e.Bu)("samplesHelmCsv",(()=>d(void 0,void 0,void 0,(function*(){yield g(N("helmCsv"),{HELM:new p("helm",null,null,160,!0)})})))),(0,e.Bu)("samplesTestHelmCsv",(()=>d(void 0,void 0,void 0,(function*(){yield g(N("testHelmCsv"),{"HELM string":new p("helm",null,null,9,!0)})})))),(0,e.Bu)("samplesTestDemogCsv",(()=>d(void 0,void 0,void 0,(function*(){yield g(N("testDemogCsv"),{})})))),(0,e.Bu)("samplesTestSmiles2Csv",(()=>d(void 0,void 0,void 0,(function*(){yield g(N("testSmiles2Csv"),{})})))),(0,e.Bu)("samplesTestSmilesShort",(()=>d(void 0,void 0,void 0,(function*(){yield g(N("testSmilesShort"),{})})))),(0,e.Bu)("samplesTestActivityCliffsNegativeSmiles",(()=>d(void 0,void 0,void 0,(function*(){yield g(N("testActivityCliffsCsv"),{})})))),(0,e.Bu)("samplesFastaPtCsv",(()=>d(void 0,void 0,void 0,(function*(){yield g(N("fastaPtCsv"),{sequence:new p("fasta","SEQ","PT",20,!1)})})))),(0,e.Bu)("samplesTestCerealCsv",(()=>d(void 0,void 0,void 0,(function*(){yield g(N("testCerealCsv"),{})})))),(0,e.Bu)("samplesTestUnichemSources",(()=>d(void 0,void 0,void 0,(function*(){yield g(N("testUnichemSources"),{})})))),(0,e.Bu)("samplesTestDmvOffices",(()=>d(void 0,void 0,void 0,(function*(){yield g(N("testDmvOffices"),{})})))),(0,e.Bu)("samplesTestAlertCollection",(()=>d(void 0,void 0,void 0,(function*(){yield g(N("testAlertCollection"),{})})))),(0,e.Bu)("samplesTestSpgi",(()=>d(void 0,void 0,void 0,(function*(){yield g(N("testSpgi"),{})})))),(0,e.Bu)("samplesTestSpgi100",(()=>d(void 0,void 0,void 0,(function*(){yield g(N("testSpgi100"),{})})))),(0,e.Bu)("samplesTestUrl",(()=>d(void 0,void 0,void 0,(function*(){yield g(N("testUrl"),{})}))))}));class p{constructor(t,e,n,i,o,s){this.units=t,this.aligned=e,this.alphabet=n,this.alphabetSize=i,this.alphabetIsMultichar=o,this.separator=s}}function g(t,e){return d(this,void 0,void 0,(function*(){const n=yield t(),i=[];for(const o of n.columns.names())if(o in e){const n=e[o];try{yield m(t,o,n.units,n.aligned,n.alphabet,n.alphabetSize,n.alphabetIsMultichar,n.separator)}catch(t){const e=t.toString();i.push(`Positive col '${o}' failed: ${e}`)}}else try{yield f(t,o)}catch(t){const e=t.toString();i.push(`Negative col '${o}' failed: ${e}`)}if(i.length>0)throw new Error(i.join("\n"))}))}var v=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};(0,e.W3)("detectors:weak-and-likely",(()=>{const n={fastaDnaWeak1:"id,colName\n1,TTTTT\n2,TTTTT\n3,TTTTT\n4,TTTTT\n",fastaDnaWeak1LikelyName:"id,seq\n1,TTTTT\n2,TTTTT\n3,TTTTT\n4,TTTTT\n",fastaRnaWeak1:"id,colName\n1,UUUUU\n2,UUUUU\n3,UUUUU\n4,UUUUU\n",fastaRnaWeak1LikelyName:"id,seq\n1,UUUUU\n2,UUUUU\n3,UUUUU\n4,UUUUU\n",fastaPtWeak1:"id,colName\n1,SLSLSPGK\n2,SLSLSPGK\n3,SLSLSPGK\n4,SLSLSPGK\n",fastaPtWeak1LikelyName:"id,seq\n1,SLSLSPGK\n2,SLSLSPGK\n3,SLSLSPGK\n4,SLSLSPGK\n",fastaUn1:"id,colName\n1,word\n2,other\n3,some\n4,another\n",fastaUn1LikelyName:"id,seq\n1,word\n2,other\n3,some\n4,another\n",fastaUn2LikelyName:'protein\nBoombastic\nMegafantastic\n"just-a-random-thought,oy!"\n',fastaUnMsa1LikelyName:"id,seq\n1,word\n2,male\n3,bare\n4,core\n"},i=e=>()=>v(void 0,void 0,void 0,(function*(){const i=n[e],o=t.DataFrame.fromCsv(i);return yield h.data.detectSemanticTypes(o),o}));(0,e.Bu)("fastaDnaWeak1",(()=>v(void 0,void 0,void 0,(function*(){yield f(i("fastaDnaWeak1"),"colName")})))),(0,e.Bu)("fastaDnaWeak1LikelyName",(()=>v(void 0,void 0,void 0,(function*(){yield m(i("fastaDnaWeak1LikelyName"),"seq","fasta","SEQ.MSA","DNA",4,!1)})))),(0,e.Bu)("fastaRnaWeak1",(()=>v(void 0,void 0,void 0,(function*(){yield f(i("fastaRnaWeak1"),"colName")})))),(0,e.Bu)("fastaRnaWeak1LikelyName",(()=>v(void 0,void 0,void 0,(function*(){yield m(i("fastaRnaWeak1LikelyName"),"seq","fasta","SEQ.MSA","RNA",4,!1)})))),(0,e.Bu)("fastaPtWeak1",(()=>v(void 0,void 0,void 0,(function*(){yield f(i("fastaPtWeak1"),"colName")})))),(0,e.Bu)("fastaPtWeak1LikelyName",(()=>v(void 0,void 0,void 0,(function*(){yield m(i("fastaPtWeak1LikelyName"),"seq","fasta","SEQ.MSA","PT",20,!1)})))),(0,e.Bu)("fastaUn1",(()=>v(void 0,void 0,void 0,(function*(){yield f(i("fastaUn1"),"colName")})))),(0,e.Bu)("fastaUn1LikelyName",(()=>v(void 0,void 0,void 0,(function*(){yield f(i("fastaUn1LikelyName"),"seq")})))),(0,e.Bu)("fastaUn2LikelyName",(()=>v(void 0,void 0,void 0,(function*(){yield f(i("fastaUn2LikelyName"),"protein")})))),(0,e.Bu)("fastaUnMsa1LikelyName",(()=>v(void 0,void 0,void 0,(function*(){yield f(i("fastaUnMsa1LikelyName"),"seq")}))))}));var y=n(6714),w=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};(0,e.W3)("detectorsBenchmark",(()=>{let n;function i(i,o,s,r,a,l){return w(this,void 0,void 0,(function*(){return yield function(i,h,u,d){return w(this,void 0,void 0,(function*(){const i=(()=>{const e=function(e,n,i,o,s){let r;switch(e){case"fasta":r=t=>{let e="";for(let n=0;n<t.length;n++){const i=t[n];e+=1==i.length?i:`[${i}]`}return e};break;case"separator":r=(t,e)=>t.join(e);break;default:throw new Error(`Not supported notation '${e}'.`)}const a=(t,e)=>{const n=new Array(e);for(let i=0;i<e;i++)n[i]=t[Math.floor(Math.random()*t.length)];return r(n,s)},l=Array(o);for(let t=0;t<o;t++)l[t]=a(n,i);return t.Column.fromStrings("seq",l)}(o,[...(0,y.gM)(s)],r,a,l);return n.prepare({col:e})})(),h=Date.now(),d=yield u(i),f=Date.now();(function(t,n){const i=new c.C(t);(0,e.l_)(t.semType,n.semType),(0,e.l_)(i.notation,n.notation),(0,e.l_)(i.alphabet,n.alphabet),(0,e.l_)(i.separator,n.separator)})(d,{semType:t.SEMTYPE.MACROMOLECULE,notation:o,alphabet:s,separator:l});const m=f-h;if(m>10){const t=`ET ${m} ms is more than max allowed 10 ms.`;throw console.error(t),new Error(t)}return console.log(`ET ${m} ms is OK.`),m}))}(0,0,(t=>w(this,void 0,void 0,(function*(){return function(t){t.callSync();const e=t.getOutputParamValue(),n=t.inputs.col;return e&&(n.semType=e),n}(t)}))))}))}(0,e.bb)((()=>w(void 0,void 0,void 0,(function*(){const e=t.Func.find({package:"Bio",name:"detectMacromolecule"});n=e[0];const i=t.Column.fromStrings("seq",["ACGT","ACGT","ACGT"]);yield n.prepare({col:i}).call()})))),(0,e.Bu)("fastaDnaShorts50Few50",(()=>w(void 0,void 0,void 0,(function*(){yield i(0,"fasta","DNA",50,50)}))),{skipReason:"#1192"}),(0,e.Bu)("fastaDnaShorts50Many1E6",(()=>w(void 0,void 0,void 0,(function*(){yield i(0,"fasta","DNA",50,1e6)}))),{skipReason:"#1192"}),(0,e.Bu)("fastaDnaLong1e6Few50",(()=>w(void 0,void 0,void 0,(function*(){yield i(0,"fasta","DNA",1e6,50)}))),{skipReason:"#1192"}),(0,e.Bu)("separatorDnaShorts50Few50",(()=>w(void 0,void 0,void 0,(function*(){yield i(0,"separator","DNA",50,50,"/")}))),{skipReason:"#1192"}),(0,e.Bu)("separatorDnaShorts50Many1E6",(()=>w(void 0,void 0,void 0,(function*(){yield i(0,"separator","DNA",50,1e6,"/")}))),{}),(0,e.Bu)("separatorDnaLong1e6Few50",(()=>w(void 0,void 0,void 0,(function*(){yield i(0,"separator","DNA",1e6,50,"/")}))),{skipReason:"#1192"})}));var b=n(6098),C=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};function S(n,i){return C(this,void 0,void 0,(function*(){const o=t.DataFrame.fromCsv(n),s=t.DataFrame.fromCsv(i),r=o.getCol("seq"),a=yield h.functions.call("Bio:detectMacromolecule",{col:r});a&&(r.semType=a);const l=s.getCol("seq"),u=yield(0,b.U)(r,!0);(0,e.f6)(u.toList(),l.toList())}))}new t.Package,(0,e.W3)("MSA",(()=>C(void 0,void 0,void 0,(function*(){(0,e.Bu)("isCorrect",(()=>C(void 0,void 0,void 0,(function*(){yield S("seq\nFWRWYVKHP\nYNRWYVKHP\nMWRSWYCKHP","seq\nFWR-WYVKHP\nYNR-WYVKHP\nMWRSWYCKHP")})))),(0,e.Bu)("isCorrectLong",(()=>C(void 0,void 0,void 0,(function*(){yield S("seq\nFWRWYVKHPFWRWYVKHPFWRWYVKHPFWRWYVKHPFWRWYVKHPFWRWYVKHPFWRWYVKHPFWRWYVKHP\nYNRWYVKHPYNRWYVKHPYNRWYVKHPYNRWYVKHPYNRWYVKHPYNRWYVKHPYNRWYVKHPYNRWYVKHP\nMWRSWYCKHPMWRSWYCKHPMWRSWYCKHPMWRSWYCKHPMWRSWYCKHPMWRSWYCKHPMWRSWYCKHPMWRSWYCKHP","seq\nFWR-WYVKHPFWR-WYVKHPFWR-WYVKHPFWR-WYVKHPFWR-WYVKHPFWR-WYVKHPFWR-WYVKHPFWR-WYVKHP\nYNR-WYVKHPYNR-WYVKHPYNR-WYVKHPYNR-WYVKHPYNR-WYVKHPYNR-WYVKHPYNR-WYVKHPYNR-WYVKHP\nMWRSWYCKHPMWRSWYCKHPMWRSWYCKHPMWRSWYCKHPMWRSWYCKHPMWRSWYCKHPMWRSWYCKHPMWRSWYCKHP")}))))}))));var T=n(3553),M=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};function E(t,n){return M(this,void 0,void 0,(function*(){const i=(0,y.gP)(t);console.debug(`Bio: tests: splitters: src=${JSON.stringify(t)}, res=${JSON.stringify(i)} .`),(0,e.f6)(i,n)}))}(0,e.W3)("splitters",(()=>{let n,i;(0,e.bb)((()=>M(void 0,void 0,void 0,(function*(){n=[],i=[]})))),(0,e.X5)((()=>M(void 0,void 0,void 0,(function*(){i.forEach((t=>{h.shell.closeTable(t)})),n.forEach((t=>t.close()))}))));const o=["M[MeI]YKETLL[MeF]PKTDFPMRGGL[MeA]",["M","MeI","Y","K","E","T","L","L","MeF","P","K","T","D","F","P","M","R","G","G","L","MeA"]],s=["PEPTIDE1{meI.hHis.Aca.N.T.dE.Thr_PO3H2.Aca.D-Tyr_Et.Tyr_ab-dehydroMe.dV.E.N.D-Orn.D-aThr.Phe_4Me}$$$",["meI","hHis","Aca","N","T","dE","Thr_PO3H2","Aca","D-Tyr_Et","Tyr_ab-dehydroMe","dV","E","N","D-Orn","D-aThr","Phe_4Me"]],r=["PEPTIDE1{meI.hHis.Aca.N.T.dK.Thr_PO3H2.Aca.D-Tyr_Et.D-Dap.dV.E.N.pnG.Phe_4Me}$$$",["meI","hHis","Aca","N","T","dK","Thr_PO3H2","Aca","D-Tyr_Et","D-Dap","dV","E","N","pnG","Phe_4Me"]],a=["PEPTIDE1{[meI].[hHis].[Aca].N.T.[dK].[Thr_PO3H2].[Aca].[D-Tyr_Et].[D-Dap].[dV].E.N.[pnG].[Phe_4Me]}$$$",["meI","hHis","Aca","N","T","dK","Thr_PO3H2","Aca","D-Tyr_Et","D-Dap","dV","E","N","pnG","Phe_4Me"]],l=["RNA1{R(U)P.R(T)P.R(G)P.R(C)P.R(A)}$$$$",["R(U)P","R(T)P","R(G)P","R(C)P","R(A)"]],c=["RNA1{P.R(U)P.R(T)}$$$$",["P","R(U)P","R(T)"]],d=["RNA1{P.R(U).P.R(T)}$$$$",["P","R(U)","P","R(T)"]];(0,e.Bu)("fastaMulti",(()=>M(void 0,void 0,void 0,(function*(){yield function(t,n){return M(this,void 0,void 0,(function*(){const i=(0,y.kB)(t);console.debug(`Bio: tests: splitters: src=${JSON.stringify(t)}, res=${JSON.stringify(i)} .`),(0,e.f6)(i,n)}))}(o[0],o[1])})))),(0,e.Bu)("helm1",(()=>M(void 0,void 0,void 0,(function*(){yield E(s[0],s[1])})))),(0,e.Bu)("helm2",(()=>M(void 0,void 0,void 0,(function*(){yield E(r[0],r[1])})))),(0,e.Bu)("helm3-multichar",(()=>M(void 0,void 0,void 0,(function*(){yield E(a[0],a[1])})))),(0,e.Bu)("testHelm1",(()=>M(void 0,void 0,void 0,(function*(){yield E(l[0],l[1])})))),(0,e.Bu)("testHelm2",(()=>M(void 0,void 0,void 0,(function*(){yield E(c[0],c[1])})))),(0,e.Bu)("testHelm3",(()=>M(void 0,void 0,void 0,(function*(){yield E(d[0],d[1])})))),(0,e.Bu)("splitToMonomers",(()=>M(void 0,void 0,void 0,(function*(){const t=yield h.dapi.files.readCsv("System:AppData/Bio/samples/sample_MSA.csv"),o=t.getCol("MSA"),s=yield h.functions.call("Bio:detectMacromolecule",{col:o});s&&(o.semType=s),o.setTag("aligned",T.mU);const r=h.shell.addTableView(t);yield h.data.detectSemanticTypes(t),i.push(t),n.push(r),(0,u.splitToMonomers)(),(0,e.l_)(t.columns.names().includes("17"),!0)}))),{skipReason:"GROK-12766"}),(0,e.Bu)("getHelmMonomers",(()=>M(void 0,void 0,void 0,(function*(){const e=t.DataFrame.fromCsv("HELM,Activity\nPEPTIDE1{hHis.N.T}$$$,5.30751\nPEPTIDE1{hHis.Aca.Cys_SEt}$$$,5.72388\n"),n=["hHis","Aca","Cys_SEt","N","T"],i=e.getCol("HELM"),o=(0,u.getHelmMonomers)(i),s=n.filter((t=>!o.includes(t))),r=o.filter((t=>!n.includes(t)));if(s.length>0||r.length){const t=[];throw s.length>0&&t.push(`Missed monomers ${JSON.stringify(s)}.`),r.length>0&&t.push(`Unexpected monomers ${JSON.stringify(r)}.`),new Error(t.join(" "))}}))))}));var A=n(7228),R=n(1345),P=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};(0,e.W3)("monomerLibraries",(()=>{let t,n=null;(0,e.bb)((()=>P(void 0,void 0,void 0,(function*(){t=yield(0,A.JN)(),n=yield h.dapi.userDataStorage.get(R.RV,!0)})))),(0,e.X5)((()=>P(void 0,void 0,void 0,(function*(){yield h.dapi.userDataStorage.put(R.RV,n,!0)})))),(0,e.Bu)("default",(()=>P(void 0,void 0,void 0,(function*(){yield h.dapi.userDataStorage.put(R.RV,{},!0),yield t.loadLibraries(!0);const n=t.getBioLib();(0,e.l_)(n.getTypes().length,0)}))))}));var N=n(4004);function x(){const e=[];return e.push(t.Column.fromList("string","MSA",new Array(Math.pow(10,6)).fill("meI/hHis/Aca/N/T/dE/Thr_PO3H2/Aca/D-Tyr_Et/Tyr_ab-dehydroMe/dV/E/N/D-Orn/D-aThr//Phe_4Me"))),e.push(t.Column.fromList("string","Activity",new Array(Math.pow(10,6)).fill("5.30751"))),e}function L(){const e=[],n="meI/hHis/Aca/N/T/dE/Thr_PO3H2/Aca/D-Tyr_Et/Tyr_ab-dehydroMe/dV/E/N/D-Orn/D-aThr".repeat(Math.pow(10,5));return e.push(t.Column.fromList("string","MSA",new Array(Math.pow(10,2)).fill(n))),e.push(t.Column.fromList("string","Activity",new Array(Math.pow(10,2)).fill("7.30751"))),e}function G(e,n){const i=e(),o=t.DataFrame.fromColumns(i),s=Date.now();var r;(r=o.columns.byName("MSA")).semType=t.SEMTYPE.MACROMOLECULE,r.setTag(t.TAGS.UNITS,"separator"),r.setTag("aligned","SEQ.MSA"),r.setTag("alphabet","UN"),r.setTag("separator","/"),h.shell.addTableView(o);const a=Date.now()-s;console.log(`Performance test: ${n}: ${a}ms`)}var _=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};(0,e.W3)("renderers",(()=>{let n,i;(0,e.bb)((()=>_(void 0,void 0,void 0,(function*(){n=[],i=[]})))),(0,e.X5)((()=>_(void 0,void 0,void 0,(function*(){})))),(0,e.Bu)("long sequence performance ",(()=>_(void 0,void 0,void 0,(function*(){G(L,"Long sequences")})))),(0,e.Bu)("many sequence performance",(()=>_(void 0,void 0,void 0,(function*(){G(x,"Many sequences")})))),(0,e.Bu)("rendererMacromoleculeFasta",(()=>_(void 0,void 0,void 0,(function*(){yield function(){return _(this,void 0,void 0,(function*(){const o=yield h.dapi.files.readAsText("System:AppData/Bio/samples/sample_FASTA.csv"),s=t.DataFrame.fromCsv(o),r=s.getCol("Sequence"),a=yield h.functions.call("Bio:detectMacromolecule",{col:r});a&&(r.semType=a);const l=h.shell.addTableView(s);yield h.data.detectSemanticTypes(s),i.push(s),n.push(l);const u=r.getTag(t.TAGS.CELL_RENDERER);(0,e.l_)(u,"sequence")}))}()})))),(0,e.Bu)("rendererMacromoleculeSeparator",(()=>_(void 0,void 0,void 0,(function*(){yield function(){return _(this,void 0,void 0,(function*(){const o=yield h.dapi.files.readAsText("System:AppData/Bio/data/sample_SEPARATOR_PT.csv"),s=t.DataFrame.fromCsv(o),r=s.getCol("sequence"),a=yield h.functions.call("Bio:detectMacromolecule",{col:r});a&&(r.semType=a);const l=h.shell.addTableView(s);yield h.data.detectSemanticTypes(s),i.push(s),n.push(l);const u=r.getTag(t.TAGS.CELL_RENDERER);(0,e.l_)(u,"sequence")}))}()})))),(0,e.Bu)("rendererMacromoleculeDifference",(()=>_(void 0,void 0,void 0,(function*(){yield function(){return _(this,void 0,void 0,(function*(){const o=t.Column.fromStrings("SequencesDiff",["meI/hHis/Aca/N/T/dK/Thr_PO3H2/Aca#D-Tyr_Et/Tyr_ab-dehydroMe/meN/E/N/dV"]);o.tags[t.TAGS.UNITS]="separator",o.tags.separator="/",o.semType=T.Of.MACROMOLECULE_DIFFERENCE;const s=t.DataFrame.fromColumns([o]),r=h.shell.addTableView(s);yield h.data.detectSemanticTypes(s),i.push(s),n.push(r);const a=o.getTag(t.TAGS.CELL_RENDERER);(0,e.l_)(a,T.Of.MACROMOLECULE_DIFFERENCE)}))}()})))),(0,e.Bu)("afterMsa",(()=>_(void 0,void 0,void 0,(function*(){yield function(){return _(this,void 0,void 0,(function*(){const o=yield h.dapi.files.readAsText("System:AppData/Bio/data/sample_FASTA.fasta"),s=(0,u.importFasta)(o)[0],r=s.getCol("sequence"),a=yield h.functions.call("Bio:detectMacromolecule",{col:r});a&&(r.semType=a);const l=h.shell.addTableView(s);yield h.data.detectSemanticTypes(s),console.log("Bio: tests/renderers/afterMsa, table view"),console.log(`Bio: tests/renderers/afterMsa, src before test semType="${r.semType}", units="${r.getTag(t.TAGS.UNITS)}", cell.renderer="${r.getTag(t.TAGS.CELL_RENDERER)}"`),(0,e.l_)(r.semType,t.SEMTYPE.MACROMOLECULE),(0,e.l_)(r.getTag(t.TAGS.UNITS),"fasta"),(0,e.l_)(r.getTag("aligned"),"SEQ"),(0,e.l_)(r.getTag("alphabet"),"PT"),(0,e.l_)(r.getTag(t.TAGS.CELL_RENDERER),"sequence"),(0,u.multipleSequenceAlignmentAny)(r),l.grid.invalidate(),i.push(s),n.push(l)}))}()})))),(0,e.Bu)("afterConvert",(()=>_(void 0,void 0,void 0,(function*(){yield function(){return _(this,void 0,void 0,(function*(){const o=yield h.dapi.files.readAsText("System:AppData/Bio/data/sample_FASTA_PT.csv"),s=t.DataFrame.fromCsv(o),r=s.col("sequence"),a=yield h.functions.call("Bio:detectMacromolecule",{col:r});a&&(r.semType=a);const l=h.shell.addTableView(s);yield h.data.detectSemanticTypes(s),n.push(l),i.push(s);const u=yield(0,N.o)(r,"separator","/"),d=u.getTag(t.TAGS.CELL_RENDERER);(0,e.l_)(d,"sequence"),new c.C(u)}))}()}))),{skipReason:"GROK-12765"}),(0,e.Bu)("selectRendererBySemType",(()=>_(void 0,void 0,void 0,(function*(){yield function(){return _(this,void 0,void 0,(function*(){const o=t.Column.fromStrings("SequencesDiff",["meI/hHis/Aca/N/T/dK/Thr_PO3H2/Aca#D-Tyr_Et/Tyr_ab-dehydroMe/meN/E/N/dV"]);o.tags[t.TAGS.UNITS]="separator",o.tags.separator="/",o.semType=T.Of.MACROMOLECULE_DIFFERENCE;const s=t.DataFrame.fromColumns([o]),r=h.shell.addTableView(s);i.push(s),n.push(r),yield(0,e.gw)(100);const a=o.getTag(t.TAGS.CELL_RENDERER);if("MacromoleculeDifference"!==a)throw new Error(`Units 'separator', separator '/' and semType 'MacromoleculeDifference' have been manually set on column but after df was added as table, view renderer has set to '${a}' instead of correct 'MacromoleculeDifference'.`)}))}()})))),(0,e.Bu)("setRendererManually",(()=>_(void 0,void 0,void 0,(function*(){yield function(){return _(this,void 0,void 0,(function*(){const o=t.Column.fromStrings("SequencesDiff",["meI/hHis/Aca/N/T/dK/Thr_PO3H2/Aca#D-Tyr_Et/Tyr_ab-dehydroMe/meN/E/N/dV"]);o.tags[t.TAGS.UNITS]="separator",o.tags.separator="/",o.semType=t.SEMTYPE.MACROMOLECULE;const s="MacromoleculeDifference";o.setTag(t.TAGS.CELL_RENDERER,s);const r=t.DataFrame.fromColumns([o]);yield h.data.detectSemanticTypes(r);const a=h.shell.addTableView(r);i.push(r),n.push(a),yield(0,e.gw)(100);const l=o.getTag(t.TAGS.CELL_RENDERER);if(l!==s)throw new Error(`Tag 'cell.renderer' has been manually set to '${s}' for column but after df was added as table, tag 'cell.renderer' has reset to '${l}' instead of manual '${s}'.`)}))}()}))),{skipReason:"GROK-11212"})}));var I=n(7767),W=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};(0,e.W3)("converters",(()=>{let n;!function(t){t.fastaPt="fastaPt",t.separatorPt="separatorPt",t.helmPt="helmPt",t.fastaDna="fastaDna",t.separatorDna="separatorDna",t.helmDna="helmDna",t.fastaRna="fastaRna",t.separatorRna="separatorRna",t.helmRna="helmRna",t.fastaGaps="fastaGaps",t.separatorGaps="separatorGaps",t.helmGaps="helmGaps",t.fastaUn="fastaUn",t.separatorUn="separatorUn",t.helmUn="helmUn",t.helmLoneDeoxyribose="helmLoneDeoxyribose",t.helmLoneRibose="helmLoneRibose",t.helmLonePhosphorus="helmLonePhosphorus",t.fastaLoneDeoxyribose="fastaLoneDeoxyribose",t.fastaLoneRibose="fastaLoneRibose",t.fastaLonePhosphorus="fastaLonePhosphorus"}(n||(n={}));const i={fastaPt:"seq\nFWPHEY\nYNRQWYV\nMKPSEYV\n",separatorPt:"seq\nF-W-P-H-E-Y\nY-N-R-Q-W-Y-V\nM-K-P-S-E-Y-V\n",helmPt:"seq\nPEPTIDE1{F.W.P.H.E.Y}$$$\nPEPTIDE1{Y.N.R.Q.W.Y.V}$$$\nPEPTIDE1{M.K.P.S.E.Y.V}$$$\n",fastaDna:"seq\nACGTC\nCAGTGT\nTTCAAC\n",separatorDna:"seq\nA/C/G/T/C\nC/A/G/T/G/T\nT/T/C/A/A/C\n",helmDna:"seq\nDNA1{D(A)P.D(C)P.D(G)P.D(T)P.D(C)P}$$$\nDNA1{D(C)P.D(A)P.D(G)P.D(T)P.D(G)P.D(T)P}$$$\nDNA1{D(T)P.D(T)P.D(C)P.D(A)P.D(A)P.D(C)P}$$$\n",fastaRna:"seq\nACGUC\nCAGUGU\nUUCAAC\n",separatorRna:"seq\nA*C*G*U*C\nC*A*G*U*G*U\nU*U*C*A*A*C\n",helmRna:"seq\nRNA1{R(A)P.R(C)P.R(G)P.R(U)P.R(C)P}$$$\nRNA1{R(C)P.R(A)P.R(G)P.R(U)P.R(G)P.R(U)P}$$$\nRNA1{R(U)P.R(U)P.R(C)P.R(A)P.R(A)P.R(C)P}$$$\n",fastaGaps:"seq\nFW-PH-EYY\nFYNRQWYV-\nFKP-Q-SEYV\n",separatorGaps:"seq\nF/W//P/H//E/Y/Y\nF/Y/N/R/Q/W/Y/V/\nF/K/P//Q//S/E/Y/V\n",helmGaps:"seq\nPEPTIDE1{F.W.*.P.H.*.E.Y.Y}$$$\nPEPTIDE1{F.Y.N.R.Q.W.Y.V.*}$$$\nPEPTIDE1{F.K.P.*.Q.*.S.E.Y.V}$$$\n",fastaUn:"seq\n[meI][hHis][Aca]NT[dE][Thr_PO3H2][Aca]D\n[meI][hHis][Aca][Cys_SEt]T[dK][Thr_PO3H2][Aca][Tyr_PO3H2]\n[Lys_Boc][hHis][Aca][Cys_SEt]T[dK][Thr_PO3H2][Aca][Tyr_PO3H2]\n",separatorUn:"seq\nmeI-hHis-Aca-N-T-dE-Thr_PO3H2-Aca-D\nmeI-hHis-Aca-Cys_SEt-T-dK-Thr_PO3H2-Aca-Tyr_PO3H2\nLys_Boc-hHis-Aca-Cys_SEt-T-dK-Thr_PO3H2-Aca-Tyr_PO3H2\n",helmUn:"seq\nPEPTIDE1{meI.hHis.Aca.N.T.dE.Thr_PO3H2.Aca.D}$$$\nPEPTIDE1{meI.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.Aca.Tyr_PO3H2}$$$\nPEPTIDE1{Lys_Boc.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.Aca.Tyr_PO3H2}$$$\n",helmLoneDeoxyribose:"seq\nDNA1{D(A).D(C).D(G).D(T).D(C)}$$$\nDNA1{D(C).D(A).D(G).D(T).D(G).D(T)P}$$$\nDNA1{D(T).D(T).D(C).D(A).D(A).D(C)P}$$$\n",helmLoneRibose:"seq\nRNA1{R(A).R(C).R(G).R(U).R(C)}$$$\nRNA1{R(C).R(A).R(G).R(U).R(G).R(U)P}$$$\nRNA1{R(U).R(U).R(C).R(A).R(A).R(C)P}$$$\n",helmLonePhosphorus:"seq\nRNA1{P.P.R(A)P.R(C)P.R(G)P.R(U)P.R(C)P}$$$\nRNA1{P.P.R(C)P.R(A)P.P.R(G)P.R(U)P.R(G)P.R(U)P}$$$\nRNA1{P.R(U)P.R(U)P.R(C)P.R(A)P.R(A)P.R(C)P.P.P}$$$\n"};function o(e){return W(this,void 0,void 0,(function*(){const n=i[e],o=t.DataFrame.fromCsv(n);return yield h.data.detectSemanticTypes(o),o}))}function s(t,n=null){if("separator"===t&&!n)throw new Error(`Argument 'separator' is missed for notation '${t.toString()}'.`);return function(i){const o=new I.L(i).convert(t,n);return(0,e.l_)(o.getTag("units"),t),o}}function r(t,n,i){return W(this,void 0,void 0,(function*(){const s=(yield o(t)).getCol("seq"),r=n(s),a=(yield o(i)).getCol("seq");(0,e.f6)(r.toList(),a.toList()),new c.C(r)}))}(0,e.Bu)("testFastaPtToSeparator",(()=>W(void 0,void 0,void 0,(function*(){yield r(n.fastaPt,s("separator","-"),n.separatorPt)})))),(0,e.Bu)("testFastaDnaToSeparator",(()=>W(void 0,void 0,void 0,(function*(){yield r(n.fastaDna,s("separator","/"),n.separatorDna)})))),(0,e.Bu)("testFastaRnaToSeparator",(()=>W(void 0,void 0,void 0,(function*(){yield r(n.fastaRna,s("separator","*"),n.separatorRna)})))),(0,e.Bu)("testFastaGapsToSeparator",(()=>W(void 0,void 0,void 0,(function*(){yield r(n.fastaGaps,s("separator","/"),n.separatorGaps)})))),(0,e.Bu)("testFastaUnToSeparator",(()=>W(void 0,void 0,void 0,(function*(){yield r(n.fastaUn,s("separator","-"),n.separatorUn)})))),(0,e.Bu)("testFastaPtToHelm",(()=>W(void 0,void 0,void 0,(function*(){yield r(n.fastaPt,s("helm"),n.helmPt)})))),(0,e.Bu)("testFastaDnaToHelm",(()=>W(void 0,void 0,void 0,(function*(){yield r(n.fastaDna,s("helm"),n.helmDna)})))),(0,e.Bu)("testFastaRnaToHelm",(()=>W(void 0,void 0,void 0,(function*(){yield r(n.fastaRna,s("helm"),n.helmRna)})))),(0,e.Bu)("testFastaGapsToHelm",(()=>W(void 0,void 0,void 0,(function*(){yield r(n.fastaGaps,s("helm"),n.helmGaps)})))),(0,e.Bu)("testSeparatorPtToFasta",(()=>W(void 0,void 0,void 0,(function*(){yield r(n.separatorPt,s("fasta"),n.fastaPt)})))),(0,e.Bu)("testSeparatorDnaToFasta",(()=>W(void 0,void 0,void 0,(function*(){yield r(n.separatorDna,s("fasta"),n.fastaDna)})))),(0,e.Bu)("testSeparatorRnaToFasta",(()=>W(void 0,void 0,void 0,(function*(){yield r(n.separatorRna,s("fasta"),n.fastaRna)})))),(0,e.Bu)("testSeparatorGapsToFasta",(()=>W(void 0,void 0,void 0,(function*(){yield r(n.separatorGaps,s("fasta"),n.fastaGaps)})))),(0,e.Bu)("testSeparatorUnToFasta",(()=>W(void 0,void 0,void 0,(function*(){yield r(n.separatorUn,s("fasta"),n.fastaUn)})))),(0,e.Bu)("testSeparatorPtToHelm",(()=>W(void 0,void 0,void 0,(function*(){yield r(n.separatorPt,s("helm"),n.helmPt)})))),(0,e.Bu)("testSeparatorDnaToHelm",(()=>W(void 0,void 0,void 0,(function*(){yield r(n.separatorDna,s("helm"),n.helmDna)})))),(0,e.Bu)("testSeparatorRnaToHelm",(()=>W(void 0,void 0,void 0,(function*(){yield r(n.separatorRna,s("helm"),n.helmRna)})))),(0,e.Bu)("testSeparatorGapsToHelm",(()=>W(void 0,void 0,void 0,(function*(){yield r(n.separatorGaps,s("helm"),n.helmGaps)})))),(0,e.Bu)("testHelmDnaToFasta",(()=>W(void 0,void 0,void 0,(function*(){yield r(n.helmDna,s("fasta"),n.fastaDna)})))),(0,e.Bu)("testHelmRnaToFasta",(()=>W(void 0,void 0,void 0,(function*(){yield r(n.helmRna,s("fasta"),n.fastaRna)})))),(0,e.Bu)("testHelmPtToFasta",(()=>W(void 0,void 0,void 0,(function*(){yield r(n.helmPt,s("fasta"),n.fastaPt)})))),(0,e.Bu)("testHelmUnToFasta",(()=>W(void 0,void 0,void 0,(function*(){yield r(n.helmUn,s("fasta"),n.fastaUn)})))),(0,e.Bu)("testHelmDnaToSeparator",(()=>W(void 0,void 0,void 0,(function*(){yield r(n.helmDna,s("separator","/"),n.separatorDna)})))),(0,e.Bu)("testHelmRnaToSeparator",(()=>W(void 0,void 0,void 0,(function*(){yield r(n.helmRna,s("separator","*"),n.separatorRna)})))),(0,e.Bu)("testHelmPtToSeparator",(()=>W(void 0,void 0,void 0,(function*(){yield r(n.helmPt,s("separator","-"),n.separatorPt)})))),(0,e.Bu)("testHelmUnToSeparator",(()=>W(void 0,void 0,void 0,(function*(){yield r(n.helmUn,s("separator","-"),n.separatorUn)})))),(0,e.Bu)("testHelmLoneRibose",(()=>W(void 0,void 0,void 0,(function*(){yield r(n.helmLoneRibose,s("fasta"),n.fastaRna)})))),(0,e.Bu)("testHelmLoneDeoxyribose",(()=>W(void 0,void 0,void 0,(function*(){yield r(n.helmLoneDeoxyribose,s("separator","/"),n.separatorDna)})))),(0,e.Bu)("testHelmLonePhosphorus",(()=>W(void 0,void 0,void 0,(function*(){yield r(n.helmLonePhosphorus,s("fasta"),n.fastaRna)}))))}));var F=n(5226),k=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};(0,e.W3)("fastaFileHandler",(()=>{const n=["description:1","description:2","description:3","description:4"],i=t.Column.fromStrings("description",n),o=["MDYKETLLMPKTDFPMRGGLPNKEPQIQEKW","MIEVFLFGIVLGLIPITLAGLFVTAYLQYRRGDQLDL","MMELVLKTIIGPIVVGVVLRIVDKWLNKDK","MDRTDEVSNHTHDKPTLTWFEEIFEEYHSPFHN"],s=t.Column.fromStrings("sequence",o);function r(t){const i=new F.i(t),s=i.descriptionsArray,r=i.sequencesArray;(0,e.f6)([s,r],[n,o])}s.semType=t.SEMTYPE.MACROMOLECULE,c.C.setUnitsToFastaColumn(s),t.DataFrame.fromColumns([i,s]),(0,e.Bu)("testNormalFormatting",(()=>k(void 0,void 0,void 0,(function*(){r(">description:1\nMDYKETLLMPKTDFPMRGGLPNKEPQIQEKW\n\n>description:2\nMIEVFLFGIVLGLIPITLAGLFVTAYLQYRRGDQLDL\n\n>description:3\nMMELVLKTIIGPIVVGVVLRIVDKWLNKDK\n\n>description:4\nMDRTDEVSNHTHDKPTLTWFEEIFEEYHSPFHN\n")})))),(0,e.Bu)("testExtraSpaces",(()=>k(void 0,void 0,void 0,(function*(){r(">description:1\n MDYKETLLMPKTDFPMRGGLPNKEPQIQEKW\n\n>description:2\nMI EVF LFGIVLGLI PITLAGLFVTAY LQYRRGDQLDL\n\n>description:3\nM MELVLKTI IGPI VVGVVLR IVDKWLNKDK\n\n>description:4\nMDR TDEVSNHTHDKP TLTWFEEIFEEYHSPFHN\n ")})))),(0,e.Bu)("testExtraNewlines",(()=>k(void 0,void 0,void 0,(function*(){r(">description:1\n\nMDYKETLLMPKTDFPMRGGLPNKEPQIQEKW\n\n>description:2\nMIEVF\nLFGIVLGLI\nPITLAGLFVTA\nYLQYRRGDQLDL\n\n>description:3\nM\nME\n\nLVLKTIIG\n\nPIVVGVVLRI\nVDKWLNKDK\n\n\n>description:4\n\nMDRT\n\nDEVSNHTHDKP\n\nTLTWFEEIFEE\n\n\n\nYHSPFHN\n")}))))}));var D=n(9943),V=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};(0,e.W3)("fastaExport",(()=>{let n;!function(t){t.single="single",t.multi="multi"}(n||(n={}));const i={[n.single]:{src:"MDYKETLLMPKTDFPMRGGLP",tgt:["MDYKETLLMP","KTDFPMRGGL","P"]},[n.multi]:{src:"M[MeI]YKETLL[MeF]PKTDFPMRGGL[MeA]",tgt:["M[MeI]YKETLL[MeF]P","KTDFPMRGGL","[MeA]"]}};let o;!function(t){t.test1="test1",t.test2="test2"}(o||(o={}));const s={[o.test1]:{srcCsv:"id,seq\n1,MDYKETLLMP\n2,KTDFPMRGGL\n3,P",idCols:["id"],seqCol:"seq",lineWidth:10,tgtFasta:">1\nMDYKETLLMP\n>2\nKTDFPMRGGL\n>3\nP\n"},[o.test2]:{srcCsv:"id,id2,seq\n1,seqA,M[MeI]YKETLL[MeF]P\n2,seqB,KTDFPMRGGL\n3,seqC,[MeA]\n",idCols:["id2","id"],seqCol:"seq",lineWidth:5,tgtFasta:">seqA|1\nM[MeI]YKE\nTLL[MeF]P\n>seqB|2\nKTDFP\nMRGGL\n>seqC|3\n[MeA]\n"}};function r(t,n=10){const o=y.kB,s=i[t].src,r=(0,D.sK)(s,o,n),a=i[t].tgt;(0,e.f6)(r,a)}function a(n){return V(this,void 0,void 0,(function*(){const i=t.DataFrame.fromCsv(n.srcCsv),o=i.getCol(n.seqCol),s=n.idCols.map((t=>i.getCol(t))),r=(0,D.i$)(s,o,n.lineWidth);(0,e.l_)(r,n.tgtFasta)}))}(0,e.Bu)("wrapSequenceSingle",(()=>V(void 0,void 0,void 0,(function*(){r(n.single,10)})))),(0,e.Bu)("wrapSequenceMulti",(()=>V(void 0,void 0,void 0,(function*(){r(n.multi,10)})))),(0,e.Bu)("saveAsFastaTest1",(()=>V(void 0,void 0,void 0,(function*(){a(s[o.test1])})))),(0,e.Bu)("saveAsFastaTest2",(()=>V(void 0,void 0,void 0,(function*(){a(s[o.test2])}))))}));var H=n(7331),O=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};(0,e.W3)("bio",(()=>{const n="seq\nACGTCT\nCAGTGT\nTTCAAC\n";(0,e.Bu)("testGetStatsHelm1",(()=>O(void 0,void 0,void 0,(function*(){const n=t.DataFrame.fromCsv("seq\nPEPTIDE1{meI}$$$$\n").getCol("seq"),i=(0,y.fy)(n,1,y.gP);(0,e.Wh)(i.freq,{meI:1}),(0,e.l_)(i.sameLength,!0)})))),(0,e.Bu)("testGetStatsN1",(()=>O(void 0,void 0,void 0,(function*(){yield function(n){return O(this,void 0,void 0,(function*(){const i=t.DataFrame.fromCsv(n).col("seq"),o=(0,y.fy)(i,5,y.kB);(0,e.Wh)(o.freq,{A:4,C:5,G:3,T:6}),(0,e.l_)(o.sameLength,!0)}))}(n)})))),(0,e.Bu)("testGetAlphabetSimilarity",(()=>O(void 0,void 0,void 0,(function*(){yield function(){return O(this,void 0,void 0,(function*(){const t=new Set(Object.keys(r.V.Names)),n=(0,y.KX)({A:2041,C:3015,G:3015,T:2048,"-":1e3},t);(0,e.l_)(n>.6,!0)}))}()})))),(0,e.Bu)("testPickupPaletteN1",(()=>O(void 0,void 0,void 0,(function*(){yield function(n){return O(this,void 0,void 0,(function*(){const i=t.DataFrame.fromCsv(n).col("seq"),o=(0,y.dQ)(i);(0,e.l_)(o instanceof r.J,!0)}))}(n)})))),(0,e.Bu)("testPickupPaletteN1e",(()=>O(void 0,void 0,void 0,(function*(){yield function(n){return O(this,void 0,void 0,(function*(){const n=t.DataFrame.fromCsv("seq\nACGTAT\nCAGTTG\nTTCG2C\n").col("seq"),i=(0,y.dQ)(n);(0,e.l_)(i instanceof r.J,!0)}))}()})))),(0,e.Bu)("testPickupPaletteAA1",(()=>O(void 0,void 0,void 0,(function*(){yield function(n){return O(this,void 0,void 0,(function*(){const n=t.DataFrame.fromCsv("seq\nFWPHEYV\nYNRQWYV\nMKPSEYV\n").col("seq"),i=(0,y.dQ)(n);(0,e.l_)(i instanceof o.f,!0)}))}()})))),(0,e.Bu)("testPickupPaletteX",(()=>O(void 0,void 0,void 0,(function*(){yield function(n){return O(this,void 0,void 0,(function*(){const n=t.DataFrame.fromCsv("seq\nXZJ{}2\n5Z4733\n3Z6></\n675687\n").col("seq"),i=(0,y.dQ)(n);(0,e.l_)(i instanceof H.kQ,!0)}))}()}))))})),(0,e.W3)("WebLogo.monomerToShort",(()=>{(0,e.Bu)("longMonomerSingle",(()=>O(void 0,void 0,void 0,(function*(){yield(0,e.l_)((0,y.GU)("S",5),"S")})))),(0,e.Bu)("longMonomerShort",(()=>O(void 0,void 0,void 0,(function*(){yield(0,e.l_)((0,y.GU)("Short",5),"Short")})))),(0,e.Bu)("longMonomerLong56",(()=>O(void 0,void 0,void 0,(function*(){yield(0,e.l_)((0,y.GU)("Long56",5),"Long5…")})))),(0,e.Bu)("longMonomerComplexFirstPartShort",(()=>O(void 0,void 0,void 0,(function*(){yield(0,e.l_)((0,y.GU)("Long-long",5),"Long…")})))),(0,e.Bu)("longMonomerComplexFirstPartLong56",(()=>O(void 0,void 0,void 0,(function*(){yield(0,e.l_)((0,y.GU)("Long56-long",5),"Long5…")}))))}));var Y=n(2433),U=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};function B(t,n){(0,e.l_)(t.name,n.name),(0,e.f6)(Object.keys(t.freq),Object.keys(n.freq));for(const i in t.freq)(0,e.l_)(t.freq[i].count,n.freq[i].count)}(0,e.W3)("WebLogo-positions",(()=>{let n,i;const o="seq\nATC-G-TTGC--\nATC-G-TTGC--\n-TC-G-TTGC--\n-TC-GCTTGC--\n-TC-GCTTGC--";(0,e.bb)((()=>U(void 0,void 0,void 0,(function*(){n=[],i=[]})))),(0,e.X5)((()=>U(void 0,void 0,void 0,(function*(){})))),(0,e.Bu)("allPositions",(()=>U(void 0,void 0,void 0,(function*(){const s=t.DataFrame.fromCsv(o),r=h.shell.addTableView(s),a=s.getCol("seq");a.semType=t.SEMTYPE.MACROMOLECULE,a.setTag(t.TAGS.UNITS,"fasta"),a.setTag("alphabet","DNA"),a.setTag("aligned","SEQ.MSA");const l=yield s.plot.fromType("WebLogo");r.dockManager.dock(l.root,t.DOCK_TYPE.DOWN),n.push(r),i.push(s);const u=l.positions,c=[new Y.CK(0,"1",{A:new Y.yW(2),"-":new Y.yW(3)}),new Y.CK(1,"2",{T:new Y.yW(5)}),new Y.CK(2,"3",{C:new Y.yW(5)}),new Y.CK(3,"4",{"-":new Y.yW(5)}),new Y.CK(4,"5",{G:new Y.yW(5)}),new Y.CK(5,"6",{"-":new Y.yW(3),C:new Y.yW(2)}),new Y.CK(6,"7",{T:new Y.yW(5)}),new Y.CK(7,"8",{T:new Y.yW(5)}),new Y.CK(8,"9",{G:new Y.yW(5)}),new Y.CK(9,"10",{C:new Y.yW(5)}),new Y.CK(10,"11",{"-":new Y.yW(5)}),new Y.CK(11,"12",{"-":new Y.yW(5)})];(0,e.l_)(u.length,c.length);for(let t=0;t<u.length;t++){(0,e.l_)(u[t].name,c[t].name);for(const n in u[t].freq)(0,e.l_)(u[t].freq[n].count,c[t].freq[n].count)}})))),(0,e.Bu)("positions with shrinkEmptyTail option true (filtered)",(()=>U(void 0,void 0,void 0,(function*(){const o=t.DataFrame.fromCsv("seq \n-TC-G-TTGC--\n-TC-GCTTGC--\n-T--C-GT-\n-T--C-GT-\n-T--C-GT-\n-T--CCGT-"),s=h.shell.addTableView(o),r=o.getCol("seq");r.semType=t.SEMTYPE.MACROMOLECULE,r.setTag(t.TAGS.UNITS,"fasta"),r.setTag("alphabet","DNA"),r.setTag("aligned","SEQ"),o.filter.init((t=>t>2)),o.filter.fireChanged();const a=yield o.plot.fromType("WebLogo",{shrinkEmptyTail:!0});s.dockManager.dock(a.root,t.DOCK_TYPE.DOWN),n.push(s),i.push(o);const l=a.positions,u=[new Y.CK(0,"1",{"-":new Y.yW(3)}),new Y.CK(1,"2",{T:new Y.yW(3)}),new Y.CK(2,"3",{"-":new Y.yW(3)}),new Y.CK(3,"4",{"-":new Y.yW(3)}),new Y.CK(4,"5",{C:new Y.yW(3)}),new Y.CK(5,"6",{"-":new Y.yW(2),C:new Y.yW(1)}),new Y.CK(6,"7",{G:new Y.yW(3)}),new Y.CK(7,"8",{T:new Y.yW(3)}),new Y.CK(8,"9",{"-":new Y.yW(3)})];(0,e.l_)(l.length,u.length);for(let t=0;t<l.length;t++){(0,e.l_)(l[t].name,u[t].name);for(const n in l[t].freq)(0,e.l_)(l[t].freq[n].count,u[t].freq[n].count)}})))),(0,e.Bu)("positions with skipEmptyPositions option",(()=>U(void 0,void 0,void 0,(function*(){const s=t.DataFrame.fromCsv(o),r=h.shell.addTableView(s),a=s.getCol("seq");a.semType=t.SEMTYPE.MACROMOLECULE,a.setTag(t.TAGS.UNITS,"fasta"),a.setTag("alphabet","DNA"),a.setTag("aligned","SEQ.MSA");const l=yield s.plot.fromType("WebLogo",{skipEmptyPositions:!0});r.dockManager.dock(l.root,t.DOCK_TYPE.DOWN),n.push(r),i.push(s);const u=l.positions,c=[new Y.CK(0,"1",{A:new Y.yW(2),"-":new Y.yW(3)}),new Y.CK(1,"2",{T:new Y.yW(5)}),new Y.CK(2,"3",{C:new Y.yW(5)}),new Y.CK(4,"5",{G:new Y.yW(5)}),new Y.CK(5,"6",{"-":new Y.yW(3),C:new Y.yW(2)}),new Y.CK(6,"7",{T:new Y.yW(5)}),new Y.CK(7,"8",{T:new Y.yW(5)}),new Y.CK(8,"9",{G:new Y.yW(5)}),new Y.CK(9,"10",{C:new Y.yW(5)})];(0,e.l_)(u.length,c.length);for(let t=0;t<u.length;t++)B(u[t],c[t])})))),(0,e.Bu)("count sequences for monomer at position",(()=>U(void 0,void 0,void 0,(function*(){const s=function(e,n,i,o){const s=t.DataFrame.fromCsv(e),r=s.getCol("seq");return r.semType=t.SEMTYPE.MACROMOLECULE,r.setTag(t.TAGS.UNITS,"fasta"),r.setTag("alphabet","DNA"),r.setTag("aligned","SEQ.MSA"),s}(o),r=s.getCol("seq"),a=h.shell.addTableView(s),l=yield s.plot.fromType("WebLogo",{startPositionName:"3",endPositionName:"7",skipEmptyPositions:!0});a.dockManager.dock(l.root,t.DOCK_TYPE.DOWN),n.push(a),i.push(s);const u=l.positions,c=[new Y.CK(2,"3",{C:new Y.yW(5)}),new Y.CK(4,"5",{G:new Y.yW(5)}),new Y.CK(5,"6",{"-":new Y.yW(3),C:new Y.yW(2)}),new Y.CK(6,"7",{T:new Y.yW(5)})];(0,e.l_)(u.length,c.length);for(let t=0;t<u.length;t++)B(u[t],c[t]);const d=l.splitter,f=u[1],m=(0,Y.eZ)(s,r,s.filter,d,"G",f);(0,e.l_)(m,5)}))))}));var Z=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};(0,e.W3)("checkInputColumn",(()=>{const n="seq\nseq1,\nseq2,\nseq3,\nseq4";(0,e.Bu)("testMsaPos",(()=>Z(void 0,void 0,void 0,(function*(){t.Func.find({package:"Bio",name:"multipleSequenceAlignmentAny"})[0].inputs.find((t=>"sequence"==t.name));const i=t.DataFrame.fromCsv(n).getCol("seq");i.semType=t.SEMTYPE.MACROMOLECULE,i.setTag(t.TAGS.UNITS,"fasta"),i.setTag("alphabet","DNA"),i.setTag("aligned","SEQ");const[o,s]=(0,u.checkInputColumn)(i,"Test",["fasta"],["DNA","RNA","PT"]);(0,e.l_)(o,!0)})))),(0,e.Bu)("testMsaNegHelm",(()=>Z(void 0,void 0,void 0,(function*(){const i=t.DataFrame.fromCsv(n).getCol("seq");i.semType=t.SEMTYPE.MACROMOLECULE,i.setTag(t.TAGS.UNITS,"helm"),i.setTag(".alphabetIsMultichar","true");const[o,s]=(0,u.checkInputColumn)(i,"Test",["fasta"],["DNA","RNA","PT"]);(0,e.l_)(o,!1)})))),(0,e.Bu)("testMsaNegUN",(()=>Z(void 0,void 0,void 0,(function*(){const i=t.DataFrame.fromCsv(n).getCol("seq");i.semType=t.SEMTYPE.MACROMOLECULE,i.setTag(t.TAGS.UNITS,"fasta"),i.setTag("alphabet","UN"),i.setTag(".alphabetSize","11"),i.setTag(".alphabetIsMultichar","true"),i.setTag("aligned","SEQ");const[o,s]=(0,u.checkInputColumn)(i,"Test",["fasta"],["DNA","RNA","PT"]);(0,e.l_)(o,!1)})))),(0,e.Bu)("testGetActionFunctionMeta",(()=>Z(void 0,void 0,void 0,(function*(){t.Func.find({package:"Bio",name:"multipleSequenceAlignmentAny"})[0].inputs.find((t=>"sequence"==t.name))}))))}));var K=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};function $(e){return K(this,void 0,void 0,(function*(){const n=yield function(t){return K(this,void 0,void 0,(function*(){return yield ut.files.readAsText(t)}))}(e),i=t.DataFrame.fromCsv(n);return i.name=e.replace(".csv",""),i}))}function z(t){return K(this,void 0,void 0,(function*(){const e=yield $(t);return e.name=t.replace(".csv",""),h.shell.addTableView(e)}))}var X=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};let q,j;function J(t,e){for(const n of t.view.viewers)if(n.type===e)return n}function Q(t){return X(this,void 0,void 0,(function*(){const e=new Promise(((e,n)=>{t.computeCompleted.subscribe((t=>X(this,void 0,void 0,(function*(){try{e(!0)}catch(t){n(t)}}))))}));yield e}))}(0,e.W3)("similarity/diversity",(()=>X(void 0,void 0,void 0,(function*(){(0,e.bb)((()=>X(void 0,void 0,void 0,(function*(){q=[],j=[]})))),(0,e.X5)((()=>X(void 0,void 0,void 0,(function*(){for(const t of q)t.close();for(const t of j)h.shell.closeTable(t)})))),(0,e.Bu)("similaritySearchViewer",(()=>X(void 0,void 0,void 0,(function*(){yield function(){return X(this,void 0,void 0,(function*(){const n=yield z("tests/sample_MSA_data.csv"),i=n.addViewer("Sequence Similarity Search");yield(0,e.gw)(100);const o=J(i,"Sequence Similarity Search");q.push(o),q.push(n),o.molCol||(yield Q(o)),(0,e.l_)(o.fingerprint,"Morgan"),(0,e.l_)(o.distanceMetric,"Tanimoto"),(0,e.l_)(o.scores.get(0),t.FLOAT_NULL),(0,e.l_)(o.idxs.get(0),0),(0,e.l_)(o.molCol.get(0),"D-Tyr_Et/Tyr_ab-dehydroMe/dV/E/N/D-Orn/D-aThr//Phe_4Me"),(0,e.l_)(o.scores.get(1),.4722222089767456),(0,e.l_)(o.idxs.get(1),11),(0,e.l_)(o.molCol.get(1),"meI/hHis//Aca/meM/Tyr_ab-dehydroMe/dV/E/N/D-Orn/D-aThr//Phe_4Me");const s=Q(o);n.dataFrame.currentRowIdx=1,yield s,(0,e.l_)(o.targetMoleculeIdx,1),(0,e.l_)(o.molCol.get(0),"meI/hHis/Aca/Cys_SEt/T/dK/Thr_PO3H2/Aca/Tyr_PO3H2/D-Chg/dV/Phe_ab-dehydro/N/D-Orn/D-aThr//Phe_4Me")}))}()})))),(0,e.Bu)("diversitySearchViewer",(()=>X(void 0,void 0,void 0,(function*(){yield function(){return X(this,void 0,void 0,(function*(){const t=yield z("tests/sample_MSA_data.csv"),n=t.addViewer("Sequence Diversity Search");yield(0,e.gw)(10);const i=J(n,"Sequence Diversity Search");q.push(i),q.push(t),i.renderMolIds||(yield Q(i)),(0,e.l_)(i.fingerprint,"Morgan"),(0,e.l_)(i.distanceMetric,"Tanimoto"),(0,e.l_)(i.initialized,!0),(0,e.l_)(i.renderMolIds.length>0,!0)}))}()}))))}))));var tt=n(4413),et=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};(0,e.W3)("substructureFilters",(()=>et(void 0,void 0,void 0,(function*(){let t,n;(0,e.bb)((()=>et(void 0,void 0,void 0,(function*(){t=yield(0,A.JN)(),n=yield h.dapi.userDataStorage.get(R.RV,!0),yield h.dapi.userDataStorage.post(R.RV,R.rb,!0),yield t.loadLibraries(!0)})))),(0,e.X5)((()=>et(void 0,void 0,void 0,(function*(){yield h.dapi.userDataStorage.put(R.RV,n,!0),yield t.loadLibraries(!0)})))),(0,e.Bu)("fasta",(()=>et(void 0,void 0,void 0,(function*(){const t=yield $("tests/filter_FASTA.csv"),n=new tt.ST;yield h.data.detectSemanticTypes(t),n.attach(t),n.bioFilter.substructure="MD",yield(0,e.gw)(100),(0,e.l_)(n.dataFrame.filter.trueCount,3),(0,e.l_)(n.dataFrame.filter.get(0),!0),(0,e.l_)(n.dataFrame.filter.get(3),!0),(0,e.l_)(n.dataFrame.filter.get(8),!0),(0,e.l_)(n.dataFrame.filter.get(1),!1)})))),(0,e.Bu)("separator",(()=>et(void 0,void 0,void 0,(function*(){const t=yield $("tests/filter_MSA.csv"),n=new tt.ST;yield h.data.detectSemanticTypes(t),n.attach(t),n.bioFilter.substructure="meI",yield(0,e.gw)(100),(0,e.l_)(n.dataFrame.filter.trueCount,7),(0,e.l_)(n.dataFrame.filter.get(2),!1),n.bioFilter.substructure="/meI",yield(0,e.gw)(100),(0,e.l_)(n.dataFrame.filter.trueCount,0),n.bioFilter.substructure="meI-hHis",n.bioFilter.separatorInput.value="-",yield(0,e.gw)(100),(0,e.l_)(n.dataFrame.filter.trueCount,7),(0,e.l_)(n.dataFrame.filter.get(2),!1)})))),(0,e.Bu)("helm",(()=>et(void 0,void 0,void 0,(function*(){const t=yield $("tests/filter_HELM.csv"),n=h.shell.addTableView(t),i=new tt.ST;yield h.data.detectSemanticTypes(t),i.attach(t);const o=new Promise(((e,n)=>{t.onFilterChanged.subscribe((t=>et(void 0,void 0,void 0,(function*(){try{e(!0)}catch(t){n(t)}}))))}));i.bioFilter.helmSubstructure="PEPTIDE1{C}$$$$V2.0",i.bioFilter.onChanged.next(),yield o,(0,e.l_)(i.dataFrame.filter.trueCount,2),(0,e.l_)(i.dataFrame.filter.get(0),!0),(0,e.l_)(i.dataFrame.filter.get(3),!0),i.bioFilter.helmSubstructure="PEPTIDE1{A.C}$$$$V2.0",i.bioFilter.onChanged.next(),yield(0,e.gw)(100),(0,e.l_)(i.dataFrame.filter.trueCount,1),(0,e.l_)(i.dataFrame.filter.get(3),!0),n.close()}))),{skipReason:"GROK-12779"})}))));var nt=n(8341);(0,e.W3)("PepSeA",(()=>{(0,e.Bu)("Basic alignment",(()=>{return n=void 0,i=void 0,s=function*(){const n=t.DataFrame.fromCsv('HELM,MSA\n "PEPTIDE1{F.L.R.G.W.[MeF].Y.S.N.N.C}$$$$","F.L.R.G.W.MeF.Y..S.N.N.C"\n "PEPTIDE1{F.L.R.G.Y.[MeF].Y.W.N.C}$$$$","F.L.R.G.Y.MeF.Y.W...N.C"\n "PEPTIDE1{F.G.Y.[MeF].Y.W.S.D.N.C}$$$$","F...G.Y.MeF.Y.W.S.D.N.C"\n "PEPTIDE1{F.L.R.G.Y.[MeF].Y.W.S.N.D.C}$$$$","F.L.R.G.Y.MeF.Y.W.S.N.D.C"\n "PEPTIDE1{F.V.R.G.Y.[MeF].Y.W.S.N.C}$$$$","F.V.R.G.Y.MeF.Y.W.S..N.C"'),i=yield(0,nt.f)(n.getCol("HELM"),"msa(HELM)"),o=n.getCol("MSA");for(let t=0;t<i.length;++t)(0,e.l_)(i.get(t)==o.get(t),!0)},new((o=void 0)||(o=Promise))((function(t,e){function r(t){try{l(s.next(t))}catch(t){e(t)}}function a(t){try{l(s.throw(t))}catch(t){e(t)}}function l(e){var n;e.done?t(e.value):(n=e.value,n instanceof o?n:new o((function(t){t(n)}))).then(r,a)}l((s=s.apply(n,i||[])).next())}));var n,i,o,s}),{skipReason:"GROK-12764"})}));(0,e.W3)("viewers",(()=>{const n=t.Func.find({package:"Bio",tags:["viewer"]}).map((t=>t.friendlyName));for(const t of n)(0,e.Bu)(t,(()=>{return n=void 0,i=void 0,s=function*(){yield(0,e.AB)(t,yield $("data/sample_FASTA_DNA.csv"),!0)},new((o=void 0)||(o=Promise))((function(t,e){function r(t){try{l(s.next(t))}catch(t){e(t)}}function a(t){try{l(s.throw(t))}catch(t){e(t)}}function l(e){var n;e.done?t(e.value):(n=e.value,n instanceof o?n:new o((function(t){t(n)}))).then(r,a)}l((s=s.apply(n,i||[])).next())}));var n,i,o,s}))}));var it=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};function ot(t,n,i,o){return it(this,void 0,void 0,(function*(){yield h.data.detectSemanticTypes(t);const s=yield(0,u.activityCliffs)(t,t.getCol(o),t.getCol("Activity"),50,i);(0,e.l_)(null!=s,!0);const r=Array.from(s.root.children).find((t=>{const e=t.className.split(" ");return["ui-btn","ui-btn-ok"].every((t=>e.includes(t)))}));(0,e.l_)(r.innerText.toLowerCase(),`${n} cliffs`)}))}var st=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};(0,e.W3)("activityCliffs",(()=>st(void 0,void 0,void 0,(function*(){let t,n,i,o,s=[],r=[];(0,e.bb)((()=>st(void 0,void 0,void 0,(function*(){s=[],r=[]})))),(0,e.X5)((()=>st(void 0,void 0,void 0,(function*(){})))),(0,e.Bu)("activityCliffsOpens",(()=>st(void 0,void 0,void 0,(function*(){n=yield $("tests/sample_MSA_data.csv"),r.push(n),t=h.shell.addTableView(n),s.push(t),yield ot(n,57,"UMAP","MSA")}))),{skipReason:"GROK-12774"}),(0,e.Bu)("activityCliffsWithEmptyRows",(()=>st(void 0,void 0,void 0,(function*(){o=yield $("tests/sample_MSA_data_empty_vals.csv"),r.push(o),i=h.shell.addTableView(o),s.push(i),yield ot(o,57,"UMAP","MSA")}))),{skipReason:"GROK-12774"})}))));var rt=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};function at(t,n,i){return rt(this,void 0,void 0,(function*(){const o=t.getCol(i),s=yield h.functions.call("Bio:detectMacromolecule",{col:o});s&&(o.semType=s);const r=yield(0,u.sequenceSpaceTopMenu)(t,t.col(i),n,"Levenshtein",!0);(0,e.l_)(null!=r,!0)}))}var lt=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};(0,e.W3)("sequenceSpace",(()=>lt(void 0,void 0,void 0,(function*(){let t,n,i,o;(0,e.Bu)("sequenceSpaceOpens",(()=>lt(void 0,void 0,void 0,(function*(){t=yield $("tests/sample_MSA_data.csv"),n=h.shell.addTableView(t),yield at(t,"UMAP","MSA"),h.shell.closeTable(t),n.close()}))),{skipReason:"GROK-12775"}),(0,e.Bu)("sequenceSpaceWithEmptyRows",(()=>lt(void 0,void 0,void 0,(function*(){i=yield $("tests/sample_MSA_data_empty_vals.csv"),o=h.shell.addTableView(i),yield at(i,"UMAP","MSA"),h.shell.closeTable(i),o.close()}))),{skipReason:"GROK-12775"})}))));var ht=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};const ut=new t.Package;function ct(n,i,o){return ht(this,void 0,void 0,(function*(){const s=yield(0,e.ci)({category:n,test:i,testContext:o});return t.DataFrame.fromObjects(s)}))}})(),bio_test=i})();
1
+ var bio_test;(()=>{var t={2012:(t,e,n)=>{"use strict";n.d(e,{f:()=>o});var i=n(9976);class o extends i.B{static get Lesk(){return void 0===this.lesk&&(this.lesk=this.makePalette([[["G","A","S","T"],"orange"],[["C","V","I","L","P","F","Y","M","W"],"all_green"],[["N","Q","H"],"magenta"],[["D","E"],"red"],[["K","R"],"all_blue"]],!1,o)),this.lesk}static get GrokGroups(){return void 0===this.grokGroups&&(this.grokGroups=this.makePalette([[["C","U"],"yellow"],[["G","P"],"red"],[["A","V","I","L","M","F","Y","W"],"all_green"],[["R","H","K"],"light_blue"],[["D","E"],"dark_blue"],[["S","T","N","Q"],"orange"]],!1,o)),this.grokGroups}static get RasMol(){return void 0===this.rasMol&&(this.rasMol=new o({D:"#E60A0A",E:"#E60A0A",C:"#E6E600",M:"#E6E600",K:"#145AFF",R:"#145AFF",S:"#FA9600",T:"#FA9600",F:"#3232AA",Y:"#3232AA",N:"#00DCDC",Q:"#00DCDC",G:"#EBEBEB",L:"#0F820F",V:"#0F820F",I:"#0F820F",A:"#C8C8C8",W:"#B45AB4",H:"#8282D2",P:"#DC9682",others:"#BEA06E"})),this.rasMol}get(t){const e=t in o.aaSynonyms?o.aaSynonyms[t]:t;return super.get(e)}}o.aaSynonyms={MeNle:"L",MeA:"A",MeG:"G",MeF:"F"};class s{static getPalette(t="grok"){switch(t){case"grok":return o.GrokGroups;case"lesk":return o.Lesk;default:throw new Error(`ChemPalette: scheme \`${t}\` does not exist`)}}static getInnerOuter(t){let e=0,n="",i="";for(const o of t)"("==o?e++:")"==o?e--:e?n+=o:i+=o;return isNaN(parseInt(n))?[i,n]:[i,""]}static getColorAAPivot(t="",e="grok"){var n,i,o;const s=this.getPalette(e);let[r,a]=this.getInnerOuter(t);if(r=r.length>6?`${r.slice(0,3)}...`:r,a=a.length>6?`${a.slice(0,3)}...`:a,1==t.length||"("==t[1]){const e=null===(n=t[0])||void 0===n?void 0:n.toUpperCase();return e in s?[s.get(e),e,a,1]:[this.undefinedColor,r,a,1]}if("d"==t[0]&&t[1]in s&&(2==t.length||"("==t[2])){const e=null===(i=t[1])||void 0===i?void 0:i.toUpperCase();return e in s?[s.get(e),e,a,2]:[this.undefinedColor,r,a,2]}if(t.substring(0,3)in this.AAFullNames&&(3==t.length||"("==t[3])){const e=this.AAFullNames[t.substring(0,3)];return e in s?[s.get(e),e,a,3]:[this.undefinedColor,r,a,3]}if((null===(o=t[0])||void 0===o?void 0:o.toLowerCase())==t[0]&&t.substring(1,3)in this.AAFullNames&&(4==t.length||"("==t[4])){const e=this.AAFullNames[t.substring(1,3)];return e in s?[s.get(e),e,a,4]:[this.undefinedColor,r,a,4]}return[this.undefinedColor,r,a,0]}}s.SemType="Aminoacids",s.SemTypeMultipleAlignment="AminoacidsMultipleAlignment",s.undefinedColor="rgb(100,100,100)",s.Names={G:"Glycine",L:"Leucine",Y:"Tyrosine",S:"Serine",E:"Glutamic acid",Q:"Glutamine",D:"Aspartic acid",N:"Asparagine",F:"Phenylalanine",A:"Alanine",K:"Lysine",R:"Arginine",H:"Histidine",C:"Cysteine",V:"Valine",P:"Proline",W:"Tryptophan",I:"Isoleucine",M:"Methionine",T:"Threonine"},s.AASmiles={G:"NCC(=O)O",L:"N[C@H](CC(C)C)C(=O)O",Y:"NC(CC1=CC=C(O)C=C1)C(=O)O",S:"NC(CO)C(=O)O",E:"N[C@@H](CCC(O)=O)C(=O)O",Q:"N[C@@H](CCC(N)=O)C(=O)O",D:"N[C@@H](CC(O)=O)C(=O)O",N:"N[C@@H](CC(N)=O)C(=O)O",F:"NC(CC1=CC=CC=C1)C(=O)O",A:"N[C@H](C)C(=O)O",K:"NC(CCCCN)C(=O)O",R:"N[C@H](CCCNC(=N)C)C(=O)O",H:"NC(CC1=CN=C[N]1)C(=O)O",C:"N[C@@H](CS)C(=O)O",V:"NC(C(C)C)C(=O)O",P:"N(CCC1)C1C(=O)O",W:"N[C@@H](Cc1c2ccccc2n([H])c1)C(=O)O",I:"N[C@H]([C@H](C)CC)C(=O)O",M:"NC(CCSC)C(=O)O",T:"NC(C(O)C)C(=O)O"},s.AASmilesTruncated={G:"*C*",L:"CC(C)C[C@H](*)*",Y:"C1=CC(=CC=C1CC(*)*)O",S:"OCC(*)C*",E:"*[C@@H](CCC(O)=O)*",Q:"*N[C@@H](CCC(N)=O)*",D:"*[C@@H](CC(O)=O)*",N:"*[C@@H](CC(N)=O)*",F:"C1=CC=C(C=C1)CC(*)*",A:"C[C@H](*)*",K:"C(CCN)CC(*)*",R:"*[C@H](CCCNC(=N)C)*",H:"C1=C(NC=N1)CC(*)*",C:"C([C@@H](*)*)S",V:"CC(C)C(*)*",P:"C1CCN(*)C1*",W:"*[C@@H](Cc1c2ccccc2n([H])c1)*",I:"CC[C@H](C)[C@H](*)*",M:"CSCCC(*)*",T:"CC(O)C(*)*"},s.AAFullNames={Ala:"A",Arg:"R",Asn:"N",Asp:"D",Cys:"C",Gln:"Q",Glu:"E",Gly:"G",His:"H",Ile:"I",Leu:"L",Lys:"K",Met:"M",Phe:"F",Pro:"P",Ser:"S",Thr:"T",Trp:"W",Tyr:"Y",Val:"V"}},7228:(t,e,n)=>{"use strict";n.d(e,{DC:()=>r,JN:()=>l,Xk:()=>a});var i=n(976),o=(n(4469),n(1047)),s=(n(6714),function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))});const r=["symbol","name","molfile","rgroups","polymerType","monomerType"];function a(t){const e=[];for(let n=0;n<t.rowCount;n++){const i={};Object.keys(o.K4).forEach((e=>{if("symbol"===e){const s=t.get(o.K4[e],n);i[e]="."===s?t.get(o.At,n):s}else if("rgroups"===e){const s=t.get(o.K4[e],n).split("\n"),r=[];s.forEach((t=>{const e={},n=t.substring(t.lastIndexOf("]")+1),i=t.match(/\[R(\d+)\]/)[1];e.capGroupSmiles="H"===n?`[*:${i}][H]`:`O[*:${i}]`,e.alternateId="H"===n?`R${i}-H`:`R${i}-OH`,e.capGroupName="H"===n?"H":"OH",e.label=`R${i}`,r.push(e)})),i[e]=r}else o.K4[e]&&(i[e]=t.get(o.K4[e],n))})),e.push(i)}return e}function l(){return s(this,void 0,void 0,(function*(){const t=i.Func.find({package:"Bio",name:"getMonomerLibHelper"});if(0===t.length)throw new Error('Package "Bio" must be installer for MonomerLibraryHelper.');return(yield t[0].prepare().call()).getOutputParamValue()}))}},6137:(t,e,n)=>{"use strict";n.d(e,{J:()=>o,V:()=>s});var i=n(9976);class o extends i.B{static get Chromatogram(){return void 0===this.chromatogram&&(this.chromatogram=new o({A:"green",C:"blue",G:"black",T:"red",U:"red",others:"gray"})),this.chromatogram}}class s{}s.SemType="Nucleotides",s.SemTypeMultipleAlignment="NucleotidesMultipleAlignment",s.Names={A:"Adenine",C:"Cytosine",G:"Guanine",T:"Thymine",U:"Uracil"}},9976:(t,e,n)=>{"use strict";n.d(e,{B:()=>i});class i{static makePalette(t,e=!1,n=i){const o={};return t.forEach((t=>{const n=t[0],i=t[1];n.forEach(((t,n)=>{o[t]=this.colourPalette[i][e?0:n]}))})),new n(o)}constructor(t){this._palette=t}get(t){return this._palette[t]}}i.undefinedColor="rgb(100,100,100)",i.colourPalette={orange:["rgb(255,187,120)","rgb(245,167,100)","rgb(235,137,70)","rgb(205, 111, 71)"],all_green:["rgb(44,160,44)","rgb(74,160,74)","rgb(23,103,57)","rgb(30,110,96)","rgb(60,131,95)","rgb(24,110,79)","rgb(152,223,138)","rgb(182, 223, 138)","rgb(152, 193, 138)"],all_blue:["rgb(31,119,180)","rgb(23,190,207)","rgb(122, 102, 189)","rgb(158,218,229)","rgb(141, 124, 217)","rgb(31, 120, 150)"],magenta:["rgb(162,106,192)","rgb(197,165,224)","rgb(208,113,218)"],red:["rgb(214,39,40)","rgb(255,152,150)"],st_blue:["rgb(23,190,207)","rgb(158,218,229)","rgb(31,119,180)"],dark_blue:["rgb(31,119,180)","rgb(31, 120, 150)"],light_blue:["rgb(23,190,207)","rgb(158,218,229)","rgb(108, 218, 229)","rgb(23,190,227)"],lilac_blue:["rgb(124,102,211)","rgb(149,134,217)","rgb(97, 81, 150)"],dark_green:["rgb(23,103,57)","rgb(30,110,96)","rgb(60,131,95)","rgb(24,110,79)"],green:["rgb(44,160,44)","rgb(74,160,74)"],light_green:["rgb(152,223,138)","rgb(182, 223, 138)","rgb(152, 193, 138)"],st_green:["rgb(44,160,44)","rgb(152,223,138)","rgb(39, 174, 96)","rgb(74,160,74)"],pink:["rgb(247,182,210)"],brown:["rgb(140,86,75)","rgb(102, 62, 54)"],gray:["rgb(127,127,127)","rgb(199,199,199)","rgb(196,156,148)","rgb(222, 222, 180)"],yellow:["rgb(188,189,34)"],white:["rgb(230,230,230)"]}},7331:(t,e,n)=>{"use strict";n.d(e,{UE:()=>h,kQ:()=>r});var i=n(976),o=n(9976);class s{static hashCode(t){let e=0;if(0===t.length)return e;for(let n=0;n<t.length;n++)e=(e<<5)-e+t.charCodeAt(n),e|=0;return e}}class r{}class a extends r{get(t){return"#666666"}}class l extends r{static buildPalette(){return[].concat(...Object.values(o.B.colourPalette))}get(t){const e=s.hashCode(t)%l.palette.length;return function(t){if(null==t)return"rgb(100,100,100)";const e=i.Color.fromHtml(t),n=i.Color.g(e),o=i.Color.r(e),s=i.Color.b(e),r=Math.sqrt(Math.pow(0-o,2)+Math.pow(0-n,2)+Math.pow(0-s,2));return r>210?`rgb(${o/r*210},${n/r*210},${s/r*210})`:i.Color.toRgb(e)}(l.palette[e])}}l.palette=l.buildPalette();class h extends o.B{static get Gray(){return void 0===this.gray&&(this.gray=new a),this.gray}static get Color(){return void 0===this.color&&(this.color=new l),this.color}}},1047:(t,e,n)=>{"use strict";n.d(e,{At:()=>i,K4:()=>o});const i="MonomerName",o={monomerType:null,smiles:null,name:"MonomerName",author:null,molfile:"molecule",naturalAnalog:"MonomerNaturalAnalogCode",rgroups:"MonomerCaps",createDate:null,id:null,polymerType:"MonomerType",symbol:"MonomerCode"}},5226:(t,e,n)=>{"use strict";n.d(e,{i:()=>s});var i=n(976),o=n(499);class s{get descriptionsArray(){return this._descriptionsArray}get sequencesArray(){return this._sequencesArray}parseMacromolecule(t,e){return this._fileContent.slice(t,e).split(/\s/).join("")}parseColumns(){const t=/^>(.*)$/gm;let e,n=0;for(;e=t.exec(this._fileContent);){const i=this._fileContent.substring(e.index+1,t.lastIndex);this._descriptionsArray.push(i),0!==n&&this._sequencesArray.push(this.parseMacromolecule(n,e.index)),n=t.lastIndex+1}this._sequencesArray.push(this.parseMacromolecule(n,-1))}importFasta(){const t=i.Column.fromStrings("description",this.descriptionsArray),e=i.Column.fromStrings("sequence",this.sequencesArray);return e.semType=i.SEMTYPE.MACROMOLECULE,o.C.setUnitsToFastaColumn(e),[i.DataFrame.fromColumns([t,e])]}constructor(t){this._descriptionsArray=[],this._sequencesArray=[],this._fileContent=t,this.parseColumns()}}},6714:(t,e,n)=>{"use strict";n.d(e,{GU:()=>C,KX:()=>T,Mj:()=>w,dQ:()=>E,fy:()=>d,gM:()=>S,gP:()=>v,kB:()=>m,py:()=>A,up:()=>R,vU:()=>y,w4:()=>M});var i=n(976),o=n(6414),s=n.n(o),r=n(3659),a=n(850),l=n(2012),h=n(6137),u=n(7331),c=n(499);function d(t,e,n){const i={};let o=!0,s=null;for(const r of t.categories){const t=n(r);if(null==s?s=t.length:t.length!==s&&(o=!1),t.length>=e)for(const e of t)e in i||(i[e]=0),i[e]+=1}return{freq:i,sameLength:o}}const f=/\[(\w+)\]|(\w)|(-)/g;function m(t){return s()(t.toString().matchAll(f)).map((t=>{let e;const n=t[0];return e=n.length>1?t[1]:n,e})).toArray()}const p=/(PEPTIDE1|DNA1|RNA1)\{([^}]+)}/g,g=/\[([^\[\]]+)]/g;function v(t){p.lastIndex=0;const e=p.exec(t.toString()),n=e?e[2]:null;return(n?n.split("."):[]).map((t=>{g.lastIndex=0;const e=g.exec(t);return e&&e.length>=2?e[1]:t}))}function y(t,e,n=undefined){if(t.toLowerCase().startsWith("fasta"))return m;if(t.toLowerCase().startsWith("separator"))return function(t,e=undefined){return n=>n.split(t,e)}(e,n);if(t.toLowerCase().startsWith("helm"))return v;throw new Error(`Unexpected units ${t} .`)}function w(t){if(t.semType!==i.SEMTYPE.MACROMOLECULE)throw new Error(`Get splitter for semType "${i.SEMTYPE.MACROMOLECULE}" only.`);return y(t.getTag(i.TAGS.UNITS),t.getTag("separator"))}const b=/(\w+)/g;function C(t,e){var n,i;const o=t.match(b),s=t.length>e||(null!==(n=null==o?void 0:o.length)&&void 0!==n?n:0)>1,r=null!==(i=null==o?void 0:o[0])&&void 0!==i?i:" ";return s?r.substring(0,e)+"…":r}function S(t){switch(t){case"DNA":return c.C.DnaFastaAlphabet;case"RNA":return c.C.RnaFastaAlphabet;case"PT":return c.C.PeptideFastaAlphabet;default:throw new Error(`Unsupported alphabet '${t}'.`)}}function T(t,e,n="-"){const i=new Set([...new Set(Object.keys(t)),...e]);i.delete(n);const o=[],s=[];for(const n of i)o.push(n in t?t[n]:0),s.push(e.has(n)?1:0);const l=new r.OW(o),h=new r.OW(s);return(0,a.MA)(l,h)/((0,a.$G)(l)*(0,a.$G)(h))}function M(t){const e=[["PT",c.C.PeptideFastaAlphabet],["DNA",c.C.DnaFastaAlphabet],["RNA",c.C.RnaFastaAlphabet]],n=e.map((e=>T(t.freq,e[1]))),i=Math.max(...n);return i>.65?e[n.indexOf(i)][0]:"UN"}function E(t,e=5){let n;return n=t.semType==i.SEMTYPE.MACROMOLECULE?new c.C(t).alphabet:M(d(t,e,m)),A(n)}function A(t){switch(t){case"PT":return l.f.GrokGroups;case"NT":case"DNA":case"RNA":return h.J.Chromatogram;default:return u.UE.Color}}function R(t){var e;const n=t.columns.bySemTypeAll(i.SEMTYPE.MACROMOLECULE);let o=null!==(e=n.find((t=>{const e=t.getTag(i.TAGS.UNITS);return!!e&&-1!==e.indexOf("MSA")})))&&void 0!==e?e:null;return!o&&n.length>0&&(o=n[0]),o}},7767:(t,e,n)=>{"use strict";n.d(e,{L:()=>r});var i=n(976),o=n(499),s=n(6714);class r extends o.C{get splitter(){return null===this._splitter&&(this._splitter=(0,s.Mj)(this.column)),this._splitter}toFasta(t){return"fasta"===t}toSeparator(t){return"separator"===t}toHelm(t){return"helm"===t}convertFastaToSeparator(t,e=null){null===e&&(e=this.defaultGapSymbol);const n=this.getNewColumn("separator");return n.init((n=>{const i=this.column.get(n),s=this.splitter(i);for(let t=0;t<s.length;t++)s[t]===e&&(s[t]=o.C._defaultGapSymbolsDict.SEPARATOR);return s.join(t)})),n.setTag(i.TAGS.UNITS,"separator"),n.setTag("separator",t),n}getHelmWrappers(){const t=this.isDna()?"DNA1{":this.isRna()?"RNA1{":this.isPeptide()?"PEPTIDE1{":"Unknown";if("Unknown"===t)throw new Error("Neither peptide, nor nucleotide");return[t,this.isDna()?"D(":this.isRna()?"R(":"",this.isDna()||this.isRna()?")P":"","}$$$"]}convertToHelmHelper(t,e,n,i,s,r){return`${n}${this.splitter(t).map((t=>t===e?o.C._defaultGapSymbolsDict.HELM:`${i}${t}${s}`)).join(".")}${r}`}convertStringToHelm(t,e=null){null===e&&(e=this.defaultGapSymbol);const[n,i,o,s]=this.getHelmWrappers();return this.convertToHelmHelper(t,e,n,i,o,s)}convertToHelm(t=null){null===t&&(t=this.defaultGapSymbol);const[e,n,o,s]=this.getHelmWrappers(),r=this.getNewColumn("helm");return r.init((i=>{const r=this.column.get(i);return this.convertToHelmHelper(r,t,e,n,o,s)})),r.setTag(i.TAGS.UNITS,"helm"),r}convertSeparatorToFasta(t=null){null===t&&(t=o.C._defaultGapSymbolsDict.FASTA);const e=this.getNewColumn("fasta");return e.init((e=>{const n=this.column.get(e),i=this.splitter(n),o=[];for(let e=0;e<i.length;e++){const n=i[e];if(0===n.length)o.push(t);else if(n.length>1){const t="["+n+"]";o.push(t)}else o.push(n)}return o.join("")})),e.setTag(i.TAGS.UNITS,"fasta"),e}convertHelmToFastaSeparator(t,e,n,i){i||(i=this.toFasta(e)?o.C._defaultGapSymbolsDict.FASTA:o.C._defaultGapSymbolsDict.SEPARATOR),n||(n=this.toFasta(e)?"":this.separator);const s=/(R\(|D\(|\)|P)/g,r=t.startsWith("DNA")||t.startsWith("RNA"),a=this.splitter(t),l=[];for(let t=0;t<a.length;t++){let n=a[t];if(r&&(n=n.replace(s,"")),n===o.C._defaultGapSymbolsDict.HELM)l.push(i);else if(this.toFasta(e)&&n.length>1){const t="["+n+"]";l.push(t)}else l.push(n)}return l.join(n)}convertHelm(t,e,n){const i=this.getNewColumn(t);i.init((i=>{const o=this.column.get(i);return this.convertHelmToFastaSeparator(o,t,e,n)}));const o=(0,s.Mj)(i),r=(0,s.fy)(i,5,o).sameLength?"SEQ.MSA":"SEQ";return i.setTag("aligned",r),i}convertHelmToSeparator(){return this.getNewColumn("separator")}convert(t,e=null){if(this.notation===t)throw new Error("tgt notation is invalid");if(this.toSeparator(t)&&null===e)throw new Error("tgt separator is not specified");if(this.isFasta()&&this.toSeparator(t)&&null!==e)return this.convertFastaToSeparator(e);if((this.isFasta()||this.isSeparator())&&this.toHelm(t))return this.convertToHelm();if(this.isSeparator()&&this.toFasta(t))return this.convertSeparatorToFasta();if(this.isHelm()&&this.toFasta(t))return this.convertHelm(t);if(this.isHelm()&&this.toSeparator(t))return this.convertHelm(t,e);throw new Error(`Not supported conversion from source notation '${this.notation}' to target notation '${t}'.`)}constructor(t){super(t),this._splitter=null}}},499:(t,e,n)=>{"use strict";n.d(e,{C:()=>s});var i=n(976),o=n(6714);class s{static setUnitsToFastaColumn(t){if(t.semType!==i.SEMTYPE.MACROMOLECULE)throw new Error("Fasta column must be MACROMOLECULE");const e=(0,o.fy)(t,5,o.kB),n=e.sameLength?"SEQ.MSA":"SEQ",s=(0,o.w4)(e);t.setTag(i.TAGS.UNITS,"fasta"),t.setTag("aligned",n),t.setTag("alphabet",s)}get units(){return this._units}get column(){return this._column}get notation(){return this._notation}get defaultGapSymbol(){return this._defaultGapSymbol}get separator(){var t;const e=null!==(t=this.column.getTag("separator"))&&void 0!==t?t:void 0;if("separator"===this.notation&&void 0===e)throw new Error(`Separator is mandatory for column '${this.column.name}' of notation '${this.notation}'.`);return e}get aligned(){const t=this.column.getTag("aligned");if(!t&&(this.isFasta()||this.isSeparator()))throw new Error("Tag aligned not set");return t}get alphabet(){const t=this.column.getTag("alphabet");if(!t&&(this.isFasta()||this.isSeparator()))throw new Error("Tag alphabet not set");return t}getAlphabetSize(){if("helm"==this.notation||"UN"==this.alphabet){const t=this.column.getTag(".alphabetSize");let e;if(t)e=parseInt(t);else{const t=(0,o.Mj)(this.column),n=(0,o.fy)(this.column,1,t);e=Object.keys(n.freq).length}return e}switch(this.alphabet){case"PT":return 20;case"DNA":case"RNA":return 4;case"NT":return console.warn("Unexpected alphabet 'NT'."),4;default:throw new Error(`Unexpected alphabet '${this.alphabet}'.`)}}getAlphabetIsMultichar(){return("helm"==this.notation||"UN"==this.alphabet)&&"true"==this.column.getTag(".alphabetIsMultichar")}isFasta(){return"fasta"===this.notation}isSeparator(){return"separator"===this.notation}isHelm(){return"helm"===this.notation}isRna(){return"RNA"===this.alphabet}isDna(){return"DNA"===this.alphabet}isPeptide(){return"PT"===this.alphabet}isMsa(){return!!this.aligned&&this.aligned.toUpperCase().includes("MSA")}getNotation(){if(this.units.toLowerCase().startsWith("fasta"))return"fasta";if(this.units.toLowerCase().startsWith("separator"))return"separator";if(this.units.toLowerCase().startsWith("helm"))return"helm";throw new Error(`Column '${this.column.name}' has unexpected notation '${this.units}'.`)}getNewColumn(t){const e=this.column,n=e.length,o=t.toLowerCase()+"("+e.name+")",s=e.dataFrame.columns.getUnusedName(o),r=i.Column.fromList("string",s,new Array(n).fill(""));r.semType=i.SEMTYPE.MACROMOLECULE,r.setTag(i.TAGS.UNITS,t),r.setTag(i.TAGS.CELL_RENDERER,"Macromolecule");const a=e.getTag("aligned");a&&r.setTag("aligned",a);const l=e.getTag("alphabet");l&&r.setTag("alphabet",l);let h=e.getTag(".alphabetSize");h&&r.setTag(".alphabetSize",h);const u=e.getTag(".alphabetIsMultichar");return void 0!==u&&r.setTag(".alphabetIsMultichar",u),"helm"==t&&(h=this.getAlphabetSize().toString(),r.setTag(".alphabetSize",h)),r}static getNewColumn(t){const e=new s(t),n=e.notation;return e.getNewColumn(n)}static unitsStringIsValid(t){return t=t.toLowerCase(),["fasta","separator","helm"].some((e=>t.startsWith(e.toLowerCase())))}static getNewColumnFromParams(t,e,n){if(!s.unitsStringIsValid(n))throw new Error("Invalid format of 'units' parameter");const o=i.Column.fromList("string",e,new Array(t).fill(""));return o.semType=i.SEMTYPE.MACROMOLECULE,o.setTag(i.TAGS.UNITS,n),o}constructor(t){this._column=t;const e=this._column.tags[i.TAGS.UNITS];if(null===e)throw new Error("Units are not specified in column");if(this._units=e,this._notation=this.getNotation(),this._defaultGapSymbol=this.isFasta()?s._defaultGapSymbolsDict.FASTA:this.isHelm()?s._defaultGapSymbolsDict.HELM:s._defaultGapSymbolsDict.SEPARATOR,!this.column.tags.has("aligned")&&(this.isFasta()||this.isSeparator()))throw new Error(`For column '${this.column.name}' of notation '${this.notation}' tag 'aligned' is mandatory.`);if(!this.column.tags.has(".alphabetIsMultichar")){if(this.isHelm())throw new Error(`For column '${this.column.name}' of notation '${this.notation}' tag '.alphabetIsMultichar' is mandatory.`);if(["UN"].includes(this.alphabet))throw new Error(`For column '${this.column.name}' of alphabet '${this.alphabet}' tag '.alphabetIsMultichar' is mandatory.`)}}}s._defaultGapSymbolsDict={HELM:"*",SEPARATOR:"",FASTA:"-"},s.PeptideFastaAlphabet=new Set(["G","L","Y","S","E","Q","D","N","F","A","K","R","H","C","V","P","W","I","M","T"]),s.DnaFastaAlphabet=new Set(["A","C","G","T"]),s.RnaFastaAlphabet=new Set(["A","C","G","U"])},9298:(t,e,n)=>{"use strict";var i,o,s,r,a;n.d(e,{CI:()=>h,Ct:()=>a,DX:()=>u,ES:()=>i,dE:()=>r,iD:()=>s,vS:()=>l,vw:()=>o}),function(t){t.Entropy="Entropy",t.full="100%"}(i||(i={})),function(t){t.TOP="top",t.MIDDLE="middle",t.BOTTOM="bottom"}(o||(o={})),function(t){t.LEFT="left",t.CENTER="center",t.RIGHT="right"}(s||(s={})),function(t){t.AUTO="auto",t.ON="on",t.OFF="off"}(r||(r={})),function(t){t.Filtered="Filtered",t.Selected="Selected"}(a||(a={}));const l=new class{constructor(){this.sequenceColumnName=null,this.startPositionName=null,this.endPositionName=null,this.skipEmptySequences=!0,this.skipEmptyPositions=!1,this.shrinkEmptyTail=!0,this.backgroundColor=4294967295,this.positionHeight=i.full,this.positionWidth=16,this.verticalAlignment=o.MIDDLE,this.horizontalAlignment=s.CENTER,this.fixWidth=!1,this.fitArea=!0,this.minHeight=50,this.maxHeight=100,this.positionMarginState=r.AUTO,this.positionMargin=0,this.filterSource=a.Filtered}},h=", ";var u;!function(t){t.positionNames=".positionNames"}(u||(u={}))},4588:(t,e,n)=>{"use strict";function i(t){return Math.random()*t}function o(t){return Math.floor(i(t))}n.d(e,{I:()=>o,t:()=>i})},1061:(t,e,n)=>{"use strict";n.d(e,{AB:()=>A,Bu:()=>f,QK:()=>r,W3:()=>y,Wh:()=>g,X5:()=>b,bb:()=>w,ci:()=>S,f6:()=>v,gw:()=>M,l_:()=>m});var i=n(4469),o=n(976),s=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};const r={},a="Auto Tests",l={};let h;var u;!function(t){t.notNull=function(t,e){if(null==t)throw new Error(`${null==e?"Value":e} not defined`)}}(u||(u={}));class c{constructor(t,e){this.catchUnhandled=!0,this.report=!1,void 0!==t&&(this.catchUnhandled=t),void 0!==e&&(this.report=e)}}class d{constructor(t,e,n,i){var o;this.category=t,this.name=e,null!=i||(i={}),null!==(o=i.timeout)&&void 0!==o||(i.timeout=3e4),this.options=i,this.test=()=>s(this,void 0,void 0,(function*(){return new Promise(((t,e)=>s(this,void 0,void 0,(function*(){let i="";try{i=yield n()}catch(t){e(t)}t(i)}))))}))}}function f(t,e,n){null==r[h]&&(r[h]={}),null==r[h].tests&&(r[h].tests=[]),r[h].tests.push(new d(h,t,e,n))}function m(t,e=!0,n){if(n=n?`${n}, `:"",t!==e)throw new Error(`${n}Expected "${e}", got "${t}"`)}function p(t,e,n=.001,i){if(t===Number.POSITIVE_INFINITY&&e===Number.POSITIVE_INFINITY||t===Number.NEGATIVE_INFINITY&&e===Number.NEGATIVE_INFINITY||t===Number.NaN&&e===Number.NaN||isNaN(t)&&isNaN(e))return;const o=Math.abs(t-e)<n;if(m(o,!0,`${null!=i?i:""} (tolerance = ${n})`),!o)throw new Error(`Expected ${e}, got ${t} (tolerance = ${n})`)}function g(t,e){for(const[n,i]of Object.entries(e)){if(!t.hasOwnProperty(n))throw new Error(`Expected property "${n}" not found`);const e=t[n];if(e instanceof Array&&i instanceof Array)v(e,i);else if(e instanceof Object&&i instanceof Object)g(e,i);else if(Number.isFinite(e)&&Number.isFinite(i))p(e,i);else if(e!=i)throw new Error(`Expected (${i}) for key '${n}', got (${e})`)}}function v(t,e){const n=t.length,i=e.length;if(n!=i)throw new Error(`Arrays are of different length: actual array length is ${n} and expected array length is ${i}`);for(let i=0;i<n;i++)if(t[i]instanceof Array&&e[i]instanceof Array)v(t[i],e[i]);else if(t[i]instanceof Object&&e[i]instanceof Object)g(t[i],e[i]);else if(t[i]!=e[i])throw new Error(`Expected ${e[i]} at position ${i}, got ${t[i]}`)}function y(t,e){h=t,e()}function w(t){null==r[h]&&(r[h]={}),r[h].before=t}function b(t){null==r[h]&&(r[h]={}),r[h].after=t}function C(t,e){return t.replace(new RegExp(e.name,"gi"),e.nqName)}function S(t){var e,n,h,u,f;return s(this,void 0,void 0,(function*(){const m=null===(n=null===(e=i.functions.getCurrentCall())||void 0===e?void 0:e.func)||void 0===n?void 0:n.package;yield function(t,e){return s(this,void 0,void 0,(function*(){if(l[t])return;const e=r;if(void 0!==e[a])return void(l[t]=!0);const n=[],o=yield i.dapi.functions.filter(`package.id = "${t}"`).list();for(const t of o){const e=t.options.test;if(e&&Array.isArray(e)&&e.length)for(let o=0;o<e.length;o++)n.push(new d(a,1===e.length?t.name:`${t.name} ${o+1}`,(()=>s(this,void 0,void 0,(function*(){if(!0!==(yield i.functions.eval(C(e[o],t))))throw`Failed: ${e[o]}`})))))}l[t]=!0,n.length&&(e[a]={tests:n})}))}(m.id);const p=[];console.log("Running tests"),null!=t||(t={}),null!==(h=(f=t).testContext)&&void 0!==h||(f.testContext=new c),i.shell.lastError="";for(const[e,n]of Object.entries(r)){if(null!=(null==t?void 0:t.category)&&!e.toLowerCase().startsWith(null==t?void 0:t.category.toLowerCase()))continue;console.log(`Started ${e} category`);try{n.before&&(yield n.before())}catch(t){n.beforeStatus=t.toString()}const i=null!==(u=n.tests)&&void 0!==u?u:[],o=[];for(let e=0;e<i.length;e++)o.push(yield T(i[e],null==t?void 0:t.test));const s=(yield Promise.all(o)).filter((t=>"skipped"!=t.result));try{n.after&&(yield n.after())}catch(t){n.afterStatus=t.toString()}n.afterStatus&&s.push({category:e,name:"init",result:n.afterStatus,success:!1,ms:0,skipped:!1}),n.beforeStatus&&s.push({category:e,name:"init",result:n.beforeStatus,success:!1,ms:0,skipped:!1}),p.push(...s)}if(t.testContext.catchUnhandled&&(yield M(1e3),i.shell.lastError.length>0&&p.push({category:"Unhandled exceptions",name:"exceptions",result:i.shell.lastError,success:!1,ms:0,skipped:!1})),t.testContext.report){const t=new o.Logger,e=p.filter((t=>t.success)).length,n=p.filter((t=>t.skipped)).length,i=p.filter((t=>!t.success)),s="Package @package tested: @successful successful, @skipped skipped, @failed failed tests",r={successful:e,skipped:n,failed:i.length,package:m};for(const t of i)Object.assign(r,{[`${t.category} | ${t.name}`]:t.result});t.log(s,r,"package-tested")}return p}))}function T(t,e){var n,i,o;return s(this,void 0,void 0,(function*(){let s;const r=null!=e&&!t.name.toLowerCase().startsWith(e.toLowerCase()),a=(null===(n=t.options)||void 0===n?void 0:n.skipReason)||r,l=r?"skipped":null===(i=t.options)||void 0===i?void 0:i.skipReason;a||console.log(`Started ${t.category} ${t.name}`);const h=new Date;try{s=a?{success:!0,result:l,ms:0,skipped:!0}:{success:!0,result:null!==(o=yield t.test())&&void 0!==o?o:"OK",ms:0,skipped:!1}}catch(t){s={success:!1,result:t.toString(),ms:0,skipped:!1}}const u=new Date;return s.ms=u-h,a||console.log(`Finished ${t.category} ${t.name} for ${s.ms} ms`),s.category=t.category,s.name=t.name,s}))}function M(t){return s(this,void 0,void 0,(function*(){yield new Promise((e=>setTimeout(e,t)))}))}function E(t,e="Timeout exceeded",n=500){return s(this,void 0,void 0,(function*(){return new Promise(((i,o)=>{setTimeout((()=>{clearInterval(s),o(new Error(e))}),n);const s=setInterval((()=>{t()&&(clearInterval(s),i())}),50)}))}))}function A(t,e,n=!1){return s(this,void 0,void 0,(function*(){n&&(yield i.data.detectSemanticTypes(e));const o=i.shell.addTableView(e),s=`[name=viewer-${t.replace(/\s+/g,"-")} i]`,r=`${s} canvas,${s} svg,${s} img,\n ${s} input,${s} h1,${s} a`,a=[];try{let n=o.addViewer(t);yield E((()=>null!==document.querySelector(r)),"cannot load viewer",3e3),a.push(Array.from(o.viewers).length),Array.from(e.row(0).cells).forEach((t=>t.value=null)),e.rows.select((t=>t.idx>1&&t.idx<7));for(let t=7;t<12;t++)e.filter.set(t,!1);e.currentRowIdx=1;const i=n.getOptions(!0).look,s={};Object.keys(i).filter((t=>"boolean"==typeof i[t])).forEach((t=>s[t]=!i[t])),n.setOptions(s),yield M(250);const l=o.saveLayout(),h=n.getOptions().look;o.resetLayout(),a.push(Array.from(o.viewers).length),o.loadLayout(l),yield E((()=>null!==document.querySelector(r)),"cannot load viewer from layout",3e3),yield M(250),a.push(Array.from(o.viewers).length),n=Array.from(o.viewers).find((t=>"Grid"!==t.type)),v(a,[2,1,2]),m(JSON.stringify(n.getOptions().look),JSON.stringify(h))}finally{o.close(),i.shell.closeTable(e)}}))}},7604:(t,e,n)=>{"use strict";function i(t){var e;return"string"==typeof t||t instanceof String?t:("object"==typeof t||t instanceof Object)&&"$thrownJsError"in t?i(t.$thrownJsError):t instanceof Error?null!==(e=t.stack)&&void 0!==e?e:t.message:t.toString()}n.d(e,{O:()=>i})},3659:(t,e,n)=>{"use strict";n.d(e,{OW:()=>i});class i extends Float32Array{}},850:(t,e,n)=>{"use strict";n.d(e,{$G:()=>l,H3:()=>d,MA:()=>h,On:()=>a,dP:()=>c,hu:()=>s,kO:()=>u});var i=n(3659),o=n(4588);function s(t=!1,e="Assertion error."){if(!t)throw new Error(e)}function r(t,e,n=0){return new Array(t).fill(n).map((()=>new i.OW(e).fill(n)))}function a(t,e,n=1){const o=t.length;s(o==e.length,"Vector lengths do not match.");const r=new i.OW(o);for(let i=0;i<t.length;++i)r[i]=t[i]+n*e[i];return r}function l(t){let e=0;for(let n=0;n<t.length;n++)e+=t[n]*t[n];return Math.sqrt(e)}function h(t,e){if(t.length!=e.length)throw new Error("The dimensionality of the vectors must match");let n=0;for(let i=0;i<t.length;i++)n+=t[i]*e[i];return n}function u(t,e,n=1){const i=r(t,e);for(let s=0;s<t;++s)for(let t=0;t<e;++t)i[s][t]=(0,o.t)(n);return i}function c(t,e){const n=function(t){let e=0;for(let n=0;n<t.length;++n)e+=t[n];return e}(function(t){const e=t.length,n=new i.OW(e);for(let e=0;e<t.length;++e)n[e]=t[e]*t[e];return n}(a(t,e,-1)));return Math.sqrt(n)}function d(t,e){const n=t.length,i=r(n,n,0);for(let o=0;o<n;++o)for(let s=o+1;s<n;++s){const n=null==t[o]||null==t[s]?0:e(t[o],t[s]);i[o][s]=i[s][o]=n}return i}},7659:(t,e,n)=>{"use strict";e.Z=void 0;var i=n(6215);Object.defineProperty(e,"Z",{enumerable:!0,get:function(){return i.TSNE}})},6215:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.TSNE=void 0,e.TSNE=class{constructor(t){this.returnV=!1,this.vValue=0,this.iter=0,t=t||{},this.perplexity=this.getopt(t,"perplexity",30),this.dim=this.getopt(t,"dim",2),this.epsilon=this.getopt(t,"epsilon",10)}assert(t,e){if(!t)throw e||"Assertion failed"}getopt(t,e,n){return t.hasOwnProperty(e)?t[e]:n}gaussRandom(){if(this.returnV)return this.returnV=!1,this.vValue;const t=2*Math.random()-1,e=2*Math.random()-1,n=t*t+e*e;if(0===n||n>1)return this.gaussRandom();const i=Math.sqrt(-2*Math.log(n)/n);return this.vValue=e*i,this.returnV=!0,t*i}randn(t,e){return t+this.gaussRandom()*e}zeros(t){if(void 0===t||isNaN(t))return[];if("undefined"==typeof ArrayBuffer){const e=new Array(t);for(let n=0;n<t;n++)e[n]=0;return e}return new Float64Array(t)}randn2d(t,e,n){const i=void 0!==n,o=[];for(let s=0;s<t;s++){const t=[];for(let o=0;o<e;o++)i?t.push(n):t.push(this.randn(0,1e-4));o.push(t)}return o}L2(t,e){const n=t.length;let i=0;for(let o=0;o<n;o++){const n=t[o],s=e[o];i+=(n-s)*(n-s)}return i}xtod(t){const e=t.length,n=this.zeros(e*e);for(let i=0;i<e;i++)for(let o=i+1;o<e;o++){const s=this.L2(t[i],t[o]);n[i*e+o]=s,n[o*e+i]=s}return n}d2p(t,e,n){const i=Math.sqrt(t.length),o=Math.floor(i);this.assert(o===i,"D should have square number of elements.");const s=Math.log(e),r=this.zeros(o*o),a=this.zeros(o);for(let e=0;e<o;e++){let i=-1/0,l=1/0,h=1,u=!1;const c=50;let d=0;for(;!u;){let r=0;for(let n=0;n<o;n++){let i=Math.exp(-t[e*o+n]*h);e===n&&(i=0),a[n]=i,r+=i}let f=0;for(let t=0;t<o;t++){let e;e=0===r?0:a[t]/r,a[t]=e,e>1e-7&&(f-=e*Math.log(e))}f>s?(i=h,l===1/0?h*=2:h=(h+l)/2):(l=h,i===-1/0?h/=2:h=(h+i)/2),d++,Math.abs(f-s)<n&&(u=!0),d>=c&&(u=!0)}for(let t=0;t<o;t++)r[e*o+t]=a[t]}const l=this.zeros(o*o),h=2*o;for(let t=0;t<o;t++)for(let e=0;e<o;e++)l[t*o+e]=Math.max((r[t*o+e]+r[e*o+t])/h,1e-100);return l}sign(t){return t>0?1:t<0?-1:0}initDataRaw(t){const e=t.length,n=t[0].length;this.assert(e>0," X is empty? You must have some data!"),this.assert(n>0," X[0] is empty? Where is the data?");const i=this.xtod(t);this.P=this.d2p(i,this.perplexity,1e-4),this.N=e,this.initSolution()}initDataDist(t){const e=t.length;this.assert(e>0," X is empty? You must have some data!");const n=this.zeros(e*e);for(let i=0;i<e;i++)for(let o=i+1;o<e;o++){const s=t[i][o];n[i*e+o]=s,n[o*e+i]=s}this.P=this.d2p(n,this.perplexity,1e-4),this.N=e,this.initSolution()}initSolution(){this.Y=this.randn2d(this.N,this.dim),this.gains=this.randn2d(this.N,this.dim,1),this.ystep=this.randn2d(this.N,this.dim,0),this.iter=0}getSolution(){return this.Y}step(){this.iter+=1;const t=this.N,e=this.costGrad(this.Y),n=e.cost,i=e.grad,o=this.zeros(this.dim);for(let e=0;e<t;e++)for(let t=0;t<this.dim;t++){const n=i[e][t],s=this.ystep[e][t],r=this.gains[e][t];let a=this.sign(n)===this.sign(s)?.8*r:r+.2;a<.01&&(a=.01),this.gains[e][t]=a;const l=(this.iter<250?.5:.8)*s-this.epsilon*a*i[e][t];this.ystep[e][t]=l,this.Y[e][t]+=l,o[t]+=this.Y[e][t]}for(let e=0;e<t;e++)for(let n=0;n<this.dim;n++)this.Y[e][n]-=o[n]/t;return n}debugGrad(){const t=this.N,e=this.costGrad(this.Y),n=(e.cost,e.grad),i=1e-5;for(let e=0;e<t;e++)for(let t=0;t<this.dim;t++){const o=this.Y[e][t];this.Y[e][t]=o+i;const s=this.costGrad(this.Y);this.Y[e][t]=o-i;const r=this.costGrad(this.Y),a=n[e][t],l=(s.cost-r.cost)/(2*i);console.log(e+","+t+": gradcheck analytic: "+a+" vs. numerical: "+l),this.Y[e][t]=o}}costGrad(t){const e=this.N,n=this.dim,i=this.P,o=this.iter<100?4:1,s=this.zeros(e*e);let r=0;for(let i=0;i<e;i++)for(let o=i+1;o<e;o++){let a=0;for(let e=0;e<n;e++){const n=t[i][e]-t[o][e];a+=n*n}const l=1/(1+a);s[i*e+o]=l,s[o*e+i]=l,r+=2*l}const a=e*e,l=this.zeros(a);for(let t=0;t<a;t++)l[t]=Math.max(s[t]/r,1e-100);let h=0;const u=[];for(let r=0;r<e;r++){const a=new Array(n);for(let t=0;t<n;t++)a[t]=0;for(let u=0;u<e;u++){h+=-i[r*e+u]*Math.log(l[r*e+u]);const c=4*(o*i[r*e+u]-l[r*e+u])*s[r*e+u];for(let e=0;e<n;e++)a[e]+=c*(t[r][e]-t[u][e])}u.push(a)}return{cost:h,grad:u}}}},9414:(t,e,n)=>{"use strict";n.d(e,{Z:()=>a});var i=n(7537),o=n.n(i),s=n(3645),r=n.n(s)()(o());r.push([t.id,".scatter_plot_link {\n position: absolute!important;\n right: 10px;\n}\n\n.cliffs_grid {\n top: 10px;\n}\n\n.show_only_cliffs {\n top: 30px;\n}\n","",{version:3,sources:["webpack://./node_modules/@datagrok-libraries/ml/css/styles.css"],names:[],mappings:"AAAA;IACI,4BAA4B;IAC5B,WAAW;AACf;;AAEA;IACI,SAAS;AACb;;AAEA;IACI,SAAS;AACb",sourcesContent:[".scatter_plot_link {\n position: absolute!important;\n right: 10px;\n}\n\n.cliffs_grid {\n top: 10px;\n}\n\n.show_only_cliffs {\n top: 30px;\n}\n"],sourceRoot:""}]);const a=r},3645:t=>{"use strict";t.exports=function(t){var e=[];return e.toString=function(){return this.map((function(e){var n="",i=void 0!==e[5];return e[4]&&(n+="@supports (".concat(e[4],") {")),e[2]&&(n+="@media ".concat(e[2]," {")),i&&(n+="@layer".concat(e[5].length>0?" ".concat(e[5]):""," {")),n+=t(e),i&&(n+="}"),e[2]&&(n+="}"),e[4]&&(n+="}"),n})).join("")},e.i=function(t,n,i,o,s){"string"==typeof t&&(t=[[null,t,void 0]]);var r={};if(i)for(var a=0;a<this.length;a++){var l=this[a][0];null!=l&&(r[l]=!0)}for(var h=0;h<t.length;h++){var u=[].concat(t[h]);i&&r[u[0]]||(void 0!==s&&(void 0===u[5]||(u[1]="@layer".concat(u[5].length>0?" ".concat(u[5]):""," {").concat(u[1],"}")),u[5]=s),n&&(u[2]?(u[1]="@media ".concat(u[2]," {").concat(u[1],"}"),u[2]=n):u[2]=n),o&&(u[4]?(u[1]="@supports (".concat(u[4],") {").concat(u[1],"}"),u[4]=o):u[4]="".concat(o)),e.push(u))}},e}},7537:t=>{"use strict";t.exports=function(t){var e=t[1],n=t[3];if(!n)return e;if("function"==typeof btoa){var i=btoa(unescape(encodeURIComponent(JSON.stringify(n)))),o="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(i),s="/*# ".concat(o," */");return[e].concat([s]).join("\n")}return[e].join("\n")}},9133:function(t,e,n){var i;!function(e,o){var s={};!function(t){"use strict";t.__esModule=!0,t.digestLength=32,t.blockSize=64;var e=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function n(t,n,i,o,s){for(var r,a,l,h,u,c,d,f,m,p,g,v,y;s>=64;){for(r=n[0],a=n[1],l=n[2],h=n[3],u=n[4],c=n[5],d=n[6],f=n[7],p=0;p<16;p++)g=o+4*p,t[p]=(255&i[g])<<24|(255&i[g+1])<<16|(255&i[g+2])<<8|255&i[g+3];for(p=16;p<64;p++)v=((m=t[p-2])>>>17|m<<15)^(m>>>19|m<<13)^m>>>10,y=((m=t[p-15])>>>7|m<<25)^(m>>>18|m<<14)^m>>>3,t[p]=(v+t[p-7]|0)+(y+t[p-16]|0);for(p=0;p<64;p++)v=(((u>>>6|u<<26)^(u>>>11|u<<21)^(u>>>25|u<<7))+(u&c^~u&d)|0)+(f+(e[p]+t[p]|0)|0)|0,y=((r>>>2|r<<30)^(r>>>13|r<<19)^(r>>>22|r<<10))+(r&a^r&l^a&l)|0,f=d,d=c,c=u,u=h+v|0,h=l,l=a,a=r,r=v+y|0;n[0]+=r,n[1]+=a,n[2]+=l,n[3]+=h,n[4]+=u,n[5]+=c,n[6]+=d,n[7]+=f,o+=64,s-=64}return o}var i=function(){function e(){this.digestLength=t.digestLength,this.blockSize=t.blockSize,this.state=new Int32Array(8),this.temp=new Int32Array(64),this.buffer=new Uint8Array(128),this.bufferLength=0,this.bytesHashed=0,this.finished=!1,this.reset()}return e.prototype.reset=function(){return this.state[0]=1779033703,this.state[1]=3144134277,this.state[2]=1013904242,this.state[3]=2773480762,this.state[4]=1359893119,this.state[5]=2600822924,this.state[6]=528734635,this.state[7]=1541459225,this.bufferLength=0,this.bytesHashed=0,this.finished=!1,this},e.prototype.clean=function(){for(var t=0;t<this.buffer.length;t++)this.buffer[t]=0;for(t=0;t<this.temp.length;t++)this.temp[t]=0;this.reset()},e.prototype.update=function(t,e){if(void 0===e&&(e=t.length),this.finished)throw new Error("SHA256: can't update because hash was finished.");var i=0;if(this.bytesHashed+=e,this.bufferLength>0){for(;this.bufferLength<64&&e>0;)this.buffer[this.bufferLength++]=t[i++],e--;64===this.bufferLength&&(n(this.temp,this.state,this.buffer,0,64),this.bufferLength=0)}for(e>=64&&(i=n(this.temp,this.state,t,i,e),e%=64);e>0;)this.buffer[this.bufferLength++]=t[i++],e--;return this},e.prototype.finish=function(t){if(!this.finished){var e=this.bytesHashed,i=this.bufferLength,o=e/536870912|0,s=e<<3,r=e%64<56?64:128;this.buffer[i]=128;for(var a=i+1;a<r-8;a++)this.buffer[a]=0;this.buffer[r-8]=o>>>24&255,this.buffer[r-7]=o>>>16&255,this.buffer[r-6]=o>>>8&255,this.buffer[r-5]=o>>>0&255,this.buffer[r-4]=s>>>24&255,this.buffer[r-3]=s>>>16&255,this.buffer[r-2]=s>>>8&255,this.buffer[r-1]=s>>>0&255,n(this.temp,this.state,this.buffer,0,r),this.finished=!0}for(a=0;a<8;a++)t[4*a+0]=this.state[a]>>>24&255,t[4*a+1]=this.state[a]>>>16&255,t[4*a+2]=this.state[a]>>>8&255,t[4*a+3]=this.state[a]>>>0&255;return this},e.prototype.digest=function(){var t=new Uint8Array(this.digestLength);return this.finish(t),t},e.prototype._saveState=function(t){for(var e=0;e<this.state.length;e++)t[e]=this.state[e]},e.prototype._restoreState=function(t,e){for(var n=0;n<this.state.length;n++)this.state[n]=t[n];this.bytesHashed=e,this.finished=!1,this.bufferLength=0},e}();t.Hash=i;var o=function(){function t(t){this.inner=new i,this.outer=new i,this.blockSize=this.inner.blockSize,this.digestLength=this.inner.digestLength;var e=new Uint8Array(this.blockSize);if(t.length>this.blockSize)(new i).update(t).finish(e).clean();else for(var n=0;n<t.length;n++)e[n]=t[n];for(n=0;n<e.length;n++)e[n]^=54;for(this.inner.update(e),n=0;n<e.length;n++)e[n]^=106;for(this.outer.update(e),this.istate=new Uint32Array(8),this.ostate=new Uint32Array(8),this.inner._saveState(this.istate),this.outer._saveState(this.ostate),n=0;n<e.length;n++)e[n]=0}return t.prototype.reset=function(){return this.inner._restoreState(this.istate,this.inner.blockSize),this.outer._restoreState(this.ostate,this.outer.blockSize),this},t.prototype.clean=function(){for(var t=0;t<this.istate.length;t++)this.ostate[t]=this.istate[t]=0;this.inner.clean(),this.outer.clean()},t.prototype.update=function(t){return this.inner.update(t),this},t.prototype.finish=function(t){return this.outer.finished?this.outer.finish(t):(this.inner.finish(t),this.outer.update(t,this.digestLength).finish(t)),this},t.prototype.digest=function(){var t=new Uint8Array(this.digestLength);return this.finish(t),t},t}();function s(t){var e=(new i).update(t),n=e.digest();return e.clean(),n}function r(t,e){var n=new o(t).update(e),i=n.digest();return n.clean(),i}function a(t,e,n,i){var o=i[0];if(0===o)throw new Error("hkdf: cannot expand more");e.reset(),o>1&&e.update(t),n&&e.update(n),e.update(i),e.finish(t),i[0]++}t.HMAC=o,t.hash=s,t.default=s,t.hmac=r;var l=new Uint8Array(t.digestLength);t.hkdf=function(t,e,n,i){void 0===e&&(e=l),void 0===i&&(i=32);for(var s=new Uint8Array([1]),h=r(e,t),u=new o(h),c=new Uint8Array(u.digestLength),d=c.length,f=new Uint8Array(i),m=0;m<i;m++)d===c.length&&(a(c,u,n,s),d=0),f[m]=c[d++];return u.clean(),c.fill(0),s.fill(0),f},t.pbkdf2=function(t,e,n,i){for(var s=new o(t),r=s.digestLength,a=new Uint8Array(4),l=new Uint8Array(r),h=new Uint8Array(r),u=new Uint8Array(i),c=0;c*r<i;c++){var d=c+1;a[0]=d>>>24&255,a[1]=d>>>16&255,a[2]=d>>>8&255,a[3]=d>>>0&255,s.reset(),s.update(e),s.update(a),s.finish(h);for(var f=0;f<r;f++)l[f]=h[f];for(f=2;f<=n;f++){s.reset(),s.update(h).finish(h);for(var m=0;m<r;m++)l[m]^=h[m]}for(f=0;f<r&&c*r+f<i;f++)u[c*r+f]=l[f]}for(c=0;c<r;c++)l[c]=h[c]=0;for(c=0;c<4;c++)a[c]=0;return s.clean(),u}}(s);var r=s.default;for(var a in s)r[a]=s[a];"object"==typeof t.exports?t.exports=r:void 0===(i=function(){return r}.call(s,n,s,t))||(t.exports=i)}()},3979:(t,e)=>{"use strict";e.H$=void 0,e.H$=function(t,e,n){var i=function(t,e,n){if(0===t.length||0===e.length)return 0;if(n&&!n.caseSensitive&&(t=t.toUpperCase(),e=e.toUpperCase()),t===e)return 1;for(var i=0,o=t.length,s=e.length,r=Math.floor(Math.max(o,s)/2)-1,a=new Array(o),l=new Array(s),h=0;h<o;h++)for(var u=Math.max(0,h-r);u<=Math.min(s,h+r+1);u++)if(!a[h]&&!l[u]&&t[h]===e[u]){++i,a[h]=l[u]=!0;break}if(0===i)return 0;var c=0,d=0;for(h=0;h<o;h++)if(a[h]){for(;!l[d];)d++;t.charAt(h)!==e.charAt(d++)&&c++}return(i/o+i/s+(i-(c/=2))/i)/3}(t,e,n),o=0;if(i>.7){for(var s=Math.min(t.length,e.length),r=0;t[r]===e[r]&&r<4&&r<s;)++o,r++;i+=.1*o*(1-i)}return i}},9251:(t,e,n)=>{"use strict";n.r(e),n.d(e,{default:()=>W});const i=Object.prototype.toString;function o(t){return i.call(t).endsWith("Array]")}function s(t,e,n){let i=0;const o=n(e);for(let e=0;e<t.x.length;e++)i+=Math.abs(t.y[e]-o(t.x[e]));return i}const r=Object.prototype.toString;function a(t){return r.call(t).endsWith("Array]")}const l=Object.prototype.toString;function h(t){return l.call(t).endsWith("Array]")}const u=Object.prototype.toString;const c=Object.prototype.toString;function d(t){var e,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!h(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");if(void 0!==n.output){if(!h(n.output))throw new TypeError("output option must be an array if specified");e=n.output}else e=new Array(t.length);var i=function(t){var e,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(e=t,!c.call(e).endsWith("Array]"))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");var i=n.fromIndex,o=void 0===i?0:i,s=n.toIndex,r=void 0===s?t.length:s;if(o<0||o>=t.length||!Number.isInteger(o))throw new Error("fromIndex must be a positive integer smaller than length");if(r<=o||r>t.length||!Number.isInteger(r))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var a=t[o],l=o+1;l<r;l++)t[l]<a&&(a=t[l]);return a}(t),o=function(t){var e,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(e=t,!u.call(e).endsWith("Array]"))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");var i=n.fromIndex,o=void 0===i?0:i,s=n.toIndex,r=void 0===s?t.length:s;if(o<0||o>=t.length||!Number.isInteger(o))throw new Error("fromIndex must be a positive integer smaller than length");if(r<=o||r>t.length||!Number.isInteger(r))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var a=t[o],l=o+1;l<r;l++)t[l]>a&&(a=t[l]);return a}(t);if(i===o)throw new RangeError("minimum and maximum input values are equal. Cannot rescale a constant array");var s=n.min,r=void 0===s?n.autoMinMax?i:0:s,a=n.max,l=void 0===a?n.autoMinMax?o:1:a;if(r>=l)throw new RangeError("min option must be smaller than max option");for(var d=(l-r)/(o-i),f=0;f<t.length;f++)e[f]=(t[f]-i)*d+r;return e}const f=" ".repeat(2),m=" ".repeat(4);function p(t,e={}){const{maxRows:n=15,maxColumns:i=10,maxNumSize:o=8,padMinus:s="auto"}=e;return`${t.constructor.name} {\n${f}[\n${m}${function(t,e,n,i,o){const{rows:s,columns:r}=t,a=Math.min(s,e),l=Math.min(r,n),h=[];if("auto"===o){o=!1;t:for(let e=0;e<a;e++)for(let n=0;n<l;n++)if(t.get(e,n)<0){o=!0;break t}}for(let e=0;e<a;e++){let n=[];for(let s=0;s<l;s++)n.push(g(t.get(e,s),i,o));h.push(`${n.join(" ")}`)}return l!==r&&(h[h.length-1]+=` ... ${r-n} more columns`),a!==s&&h.push(`... ${s-e} more rows`),h.join(`\n${m}`)}(t,n,i,o,s)}\n${f}]\n${f}rows: ${t.rows}\n${f}columns: ${t.columns}\n}`}function g(t,e,n){return(t>=0&&n?` ${v(t,e-1)}`:v(t,e)).padEnd(e)}function v(t,e){let n=t.toString();if(n.length<=e)return n;let i=t.toFixed(e);if(i.length>e&&(i=t.toFixed(Math.max(0,e-(i.length-e)))),i.length<=e&&!i.startsWith("0.000")&&!i.startsWith("-0.000"))return i;let o=t.toExponential(e);return o.length>e&&(o=t.toExponential(Math.max(0,e-(o.length-e)))),o.slice(0)}function y(t,e,n){let i=n?t.rows:t.rows-1;if(e<0||e>i)throw new RangeError("Row index out of range")}function w(t,e,n){let i=n?t.columns:t.columns-1;if(e<0||e>i)throw new RangeError("Column index out of range")}function b(t,e){if(e.to1DArray&&(e=e.to1DArray()),e.length!==t.columns)throw new RangeError("vector size must be the same as the number of columns");return e}function C(t,e){if(e.to1DArray&&(e=e.to1DArray()),e.length!==t.rows)throw new RangeError("vector size must be the same as the number of rows");return e}function S(t,e,n,i,o){if(5!==arguments.length)throw new RangeError("expected 4 arguments");if(M("startRow",e),M("endRow",n),M("startColumn",i),M("endColumn",o),e>n||i>o||e<0||e>=t.rows||n<0||n>=t.rows||i<0||i>=t.columns||o<0||o>=t.columns)throw new RangeError("Submatrix indices are out of range")}function T(t,e=0){let n=[];for(let i=0;i<t;i++)n.push(e);return n}function M(t,e){if("number"!=typeof e)throw new TypeError(`${t} must be a number`)}function E(t){if(t.isEmpty())throw new Error("Empty matrix has no elements to index")}class A{static from1DArray(t,e,n){if(t*e!==n.length)throw new RangeError("data length does not match given dimensions");let i=new P(t,e);for(let o=0;o<t;o++)for(let t=0;t<e;t++)i.set(o,t,n[o*e+t]);return i}static rowVector(t){let e=new P(1,t.length);for(let n=0;n<t.length;n++)e.set(0,n,t[n]);return e}static columnVector(t){let e=new P(t.length,1);for(let n=0;n<t.length;n++)e.set(n,0,t[n]);return e}static zeros(t,e){return new P(t,e)}static ones(t,e){return new P(t,e).fill(1)}static rand(t,e,n={}){if("object"!=typeof n)throw new TypeError("options must be an object");const{random:i=Math.random}=n;let o=new P(t,e);for(let n=0;n<t;n++)for(let t=0;t<e;t++)o.set(n,t,i());return o}static randInt(t,e,n={}){if("object"!=typeof n)throw new TypeError("options must be an object");const{min:i=0,max:o=1e3,random:s=Math.random}=n;if(!Number.isInteger(i))throw new TypeError("min must be an integer");if(!Number.isInteger(o))throw new TypeError("max must be an integer");if(i>=o)throw new RangeError("min must be smaller than max");let r=o-i,a=new P(t,e);for(let n=0;n<t;n++)for(let t=0;t<e;t++){let e=i+Math.round(s()*r);a.set(n,t,e)}return a}static eye(t,e,n){void 0===e&&(e=t),void 0===n&&(n=1);let i=Math.min(t,e),o=this.zeros(t,e);for(let t=0;t<i;t++)o.set(t,t,n);return o}static diag(t,e,n){let i=t.length;void 0===e&&(e=i),void 0===n&&(n=e);let o=Math.min(i,e,n),s=this.zeros(e,n);for(let e=0;e<o;e++)s.set(e,e,t[e]);return s}static min(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let n=t.rows,i=t.columns,o=new P(n,i);for(let s=0;s<n;s++)for(let n=0;n<i;n++)o.set(s,n,Math.min(t.get(s,n),e.get(s,n)));return o}static max(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let n=t.rows,i=t.columns,o=new this(n,i);for(let s=0;s<n;s++)for(let n=0;n<i;n++)o.set(s,n,Math.max(t.get(s,n),e.get(s,n)));return o}static checkMatrix(t){return A.isMatrix(t)?t:new P(t)}static isMatrix(t){return null!=t&&"Matrix"===t.klass}get size(){return this.rows*this.columns}apply(t){if("function"!=typeof t)throw new TypeError("callback must be a function");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)t.call(this,e,n);return this}to1DArray(){let t=[];for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)t.push(this.get(e,n));return t}to2DArray(){let t=[];for(let e=0;e<this.rows;e++){t.push([]);for(let n=0;n<this.columns;n++)t[e].push(this.get(e,n))}return t}toJSON(){return this.to2DArray()}isRowVector(){return 1===this.rows}isColumnVector(){return 1===this.columns}isVector(){return 1===this.rows||1===this.columns}isSquare(){return this.rows===this.columns}isEmpty(){return 0===this.rows||0===this.columns}isSymmetric(){if(this.isSquare()){for(let t=0;t<this.rows;t++)for(let e=0;e<=t;e++)if(this.get(t,e)!==this.get(e,t))return!1;return!0}return!1}isEchelonForm(){let t=0,e=0,n=-1,i=!0,o=!1;for(;t<this.rows&&i;){for(e=0,o=!1;e<this.columns&&!1===o;)0===this.get(t,e)?e++:1===this.get(t,e)&&e>n?(o=!0,n=e):(i=!1,o=!0);t++}return i}isReducedEchelonForm(){let t=0,e=0,n=-1,i=!0,o=!1;for(;t<this.rows&&i;){for(e=0,o=!1;e<this.columns&&!1===o;)0===this.get(t,e)?e++:1===this.get(t,e)&&e>n?(o=!0,n=e):(i=!1,o=!0);for(let n=e+1;n<this.rows;n++)0!==this.get(t,n)&&(i=!1);t++}return i}echelonForm(){let t=this.clone(),e=0,n=0;for(;e<t.rows&&n<t.columns;){let i=e;for(let o=e;o<t.rows;o++)t.get(o,n)>t.get(i,n)&&(i=o);if(0===t.get(i,n))n++;else{t.swapRows(e,i);let o=t.get(e,n);for(let i=n;i<t.columns;i++)t.set(e,i,t.get(e,i)/o);for(let i=e+1;i<t.rows;i++){let o=t.get(i,n)/t.get(e,n);t.set(i,n,0);for(let s=n+1;s<t.columns;s++)t.set(i,s,t.get(i,s)-t.get(e,s)*o)}e++,n++}}return t}reducedEchelonForm(){let t=this.echelonForm(),e=t.columns,n=t.rows,i=n-1;for(;i>=0;)if(0===t.maxRow(i))i--;else{let o=0,s=!1;for(;o<n&&!1===s;)1===t.get(i,o)?s=!0:o++;for(let n=0;n<i;n++){let s=t.get(n,o);for(let r=o;r<e;r++){let e=t.get(n,r)-s*t.get(i,r);t.set(n,r,e)}}i--}return t}set(){throw new Error("set method is unimplemented")}get(){throw new Error("get method is unimplemented")}repeat(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{rows:e=1,columns:n=1}=t;if(!Number.isInteger(e)||e<=0)throw new TypeError("rows must be a positive integer");if(!Number.isInteger(n)||n<=0)throw new TypeError("columns must be a positive integer");let i=new P(this.rows*e,this.columns*n);for(let t=0;t<e;t++)for(let e=0;e<n;e++)i.setSubMatrix(this,this.rows*t,this.columns*e);return i}fill(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,t);return this}neg(){return this.mulS(-1)}getRow(t){y(this,t);let e=[];for(let n=0;n<this.columns;n++)e.push(this.get(t,n));return e}getRowVector(t){return P.rowVector(this.getRow(t))}setRow(t,e){y(this,t),e=b(this,e);for(let n=0;n<this.columns;n++)this.set(t,n,e[n]);return this}swapRows(t,e){y(this,t),y(this,e);for(let n=0;n<this.columns;n++){let i=this.get(t,n);this.set(t,n,this.get(e,n)),this.set(e,n,i)}return this}getColumn(t){w(this,t);let e=[];for(let n=0;n<this.rows;n++)e.push(this.get(n,t));return e}getColumnVector(t){return P.columnVector(this.getColumn(t))}setColumn(t,e){w(this,t),e=C(this,e);for(let n=0;n<this.rows;n++)this.set(n,t,e[n]);return this}swapColumns(t,e){w(this,t),w(this,e);for(let n=0;n<this.rows;n++){let i=this.get(n,t);this.set(n,t,this.get(n,e)),this.set(n,e,i)}return this}addRowVector(t){t=b(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)+t[n]);return this}subRowVector(t){t=b(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)-t[n]);return this}mulRowVector(t){t=b(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)*t[n]);return this}divRowVector(t){t=b(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)/t[n]);return this}addColumnVector(t){t=C(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)+t[e]);return this}subColumnVector(t){t=C(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)-t[e]);return this}mulColumnVector(t){t=C(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)*t[e]);return this}divColumnVector(t){t=C(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)/t[e]);return this}mulRow(t,e){y(this,t);for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)*e);return this}mulColumn(t,e){w(this,t);for(let n=0;n<this.rows;n++)this.set(n,t,this.get(n,t)*e);return this}max(t){if(this.isEmpty())return NaN;switch(t){case"row":{const t=new Array(this.rows).fill(Number.NEGATIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.get(e,n)>t[e]&&(t[e]=this.get(e,n));return t}case"column":{const t=new Array(this.columns).fill(Number.NEGATIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.get(e,n)>t[n]&&(t[n]=this.get(e,n));return t}case void 0:{let t=this.get(0,0);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.get(e,n)>t&&(t=this.get(e,n));return t}default:throw new Error(`invalid option: ${t}`)}}maxIndex(){E(this);let t=this.get(0,0),e=[0,0];for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.get(n,i)>t&&(t=this.get(n,i),e[0]=n,e[1]=i);return e}min(t){if(this.isEmpty())return NaN;switch(t){case"row":{const t=new Array(this.rows).fill(Number.POSITIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.get(e,n)<t[e]&&(t[e]=this.get(e,n));return t}case"column":{const t=new Array(this.columns).fill(Number.POSITIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.get(e,n)<t[n]&&(t[n]=this.get(e,n));return t}case void 0:{let t=this.get(0,0);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.get(e,n)<t&&(t=this.get(e,n));return t}default:throw new Error(`invalid option: ${t}`)}}minIndex(){E(this);let t=this.get(0,0),e=[0,0];for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.get(n,i)<t&&(t=this.get(n,i),e[0]=n,e[1]=i);return e}maxRow(t){if(y(this,t),this.isEmpty())return NaN;let e=this.get(t,0);for(let n=1;n<this.columns;n++)this.get(t,n)>e&&(e=this.get(t,n));return e}maxRowIndex(t){y(this,t),E(this);let e=this.get(t,0),n=[t,0];for(let i=1;i<this.columns;i++)this.get(t,i)>e&&(e=this.get(t,i),n[1]=i);return n}minRow(t){if(y(this,t),this.isEmpty())return NaN;let e=this.get(t,0);for(let n=1;n<this.columns;n++)this.get(t,n)<e&&(e=this.get(t,n));return e}minRowIndex(t){y(this,t),E(this);let e=this.get(t,0),n=[t,0];for(let i=1;i<this.columns;i++)this.get(t,i)<e&&(e=this.get(t,i),n[1]=i);return n}maxColumn(t){if(w(this,t),this.isEmpty())return NaN;let e=this.get(0,t);for(let n=1;n<this.rows;n++)this.get(n,t)>e&&(e=this.get(n,t));return e}maxColumnIndex(t){w(this,t),E(this);let e=this.get(0,t),n=[0,t];for(let i=1;i<this.rows;i++)this.get(i,t)>e&&(e=this.get(i,t),n[0]=i);return n}minColumn(t){if(w(this,t),this.isEmpty())return NaN;let e=this.get(0,t);for(let n=1;n<this.rows;n++)this.get(n,t)<e&&(e=this.get(n,t));return e}minColumnIndex(t){w(this,t),E(this);let e=this.get(0,t),n=[0,t];for(let i=1;i<this.rows;i++)this.get(i,t)<e&&(e=this.get(i,t),n[0]=i);return n}diag(){let t=Math.min(this.rows,this.columns),e=[];for(let n=0;n<t;n++)e.push(this.get(n,n));return e}norm(t="frobenius"){let e=0;if("max"===t)return this.max();if("frobenius"===t){for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)e+=this.get(t,n)*this.get(t,n);return Math.sqrt(e)}throw new RangeError(`unknown norm type: ${t}`)}cumulativeSum(){let t=0;for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)t+=this.get(e,n),this.set(e,n,t);return this}dot(t){A.isMatrix(t)&&(t=t.to1DArray());let e=this.to1DArray();if(e.length!==t.length)throw new RangeError("vectors do not have the same size");let n=0;for(let i=0;i<e.length;i++)n+=e[i]*t[i];return n}mmul(t){t=P.checkMatrix(t);let e=this.rows,n=this.columns,i=t.columns,o=new P(e,i),s=new Float64Array(n);for(let r=0;r<i;r++){for(let e=0;e<n;e++)s[e]=t.get(e,r);for(let t=0;t<e;t++){let e=0;for(let i=0;i<n;i++)e+=this.get(t,i)*s[i];o.set(t,r,e)}}return o}strassen2x2(t){t=P.checkMatrix(t);let e=new P(2,2);const n=this.get(0,0),i=t.get(0,0),o=this.get(0,1),s=t.get(0,1),r=this.get(1,0),a=t.get(1,0),l=this.get(1,1),h=t.get(1,1),u=(n+l)*(i+h),c=(r+l)*i,d=n*(s-h),f=l*(a-i),m=(n+o)*h,p=u+f-m+(o-l)*(a+h),g=d+m,v=c+f,y=u-c+d+(r-n)*(i+s);return e.set(0,0,p),e.set(0,1,g),e.set(1,0,v),e.set(1,1,y),e}strassen3x3(t){t=P.checkMatrix(t);let e=new P(3,3);const n=this.get(0,0),i=this.get(0,1),o=this.get(0,2),s=this.get(1,0),r=this.get(1,1),a=this.get(1,2),l=this.get(2,0),h=this.get(2,1),u=this.get(2,2),c=t.get(0,0),d=t.get(0,1),f=t.get(0,2),m=t.get(1,0),p=t.get(1,1),g=t.get(1,2),v=t.get(2,0),y=t.get(2,1),w=t.get(2,2),b=(n-s)*(-d+p),C=(-n+s+r)*(c-d+p),S=(s+r)*(-c+d),T=n*c,M=(-n+l+h)*(c-f+g),E=(-n+l)*(f-g),A=(l+h)*(-c+f),R=(-o+h+u)*(p+v-y),N=(o-u)*(p-y),x=o*v,L=(h+u)*(-v+y),G=(-o+r+a)*(g+v-w),_=(o-a)*(g-w),I=(r+a)*(-v+w),W=T+x+i*m,F=(n+i+o-s-r-h-u)*p+C+S+T+R+x+L,k=T+M+A+(n+i+o-r-a-l-h)*g+x+G+I,D=b+r*(-c+d+m-p-g-v+w)+C+T+x+G+_,H=b+C+S+T+a*y,V=x+G+_+I+s*f,O=T+M+E+h*(-c+f+m-p-g-v+y)+R+N+x,Y=R+N+x+L+l*d,U=T+M+E+A+u*w;return e.set(0,0,W),e.set(0,1,F),e.set(0,2,k),e.set(1,0,D),e.set(1,1,H),e.set(1,2,V),e.set(2,0,O),e.set(2,1,Y),e.set(2,2,U),e}mmulStrassen(t){t=P.checkMatrix(t);let e=this.clone(),n=e.rows,i=e.columns,o=t.rows,s=t.columns;function r(t,e,n){let i=t.rows,o=t.columns;if(i===e&&o===n)return t;{let i=A.zeros(e,n);return i=i.setSubMatrix(t,0,0),i}}i!==o&&console.warn(`Multiplying ${n} x ${i} and ${o} x ${s} matrix: dimensions do not match.`);let a=Math.max(n,o),l=Math.max(i,s);return e=r(e,a,l),function t(e,n,i,o){if(i<=512||o<=512)return e.mmul(n);i%2==1&&o%2==1?(e=r(e,i+1,o+1),n=r(n,i+1,o+1)):i%2==1?(e=r(e,i+1,o),n=r(n,i+1,o)):o%2==1&&(e=r(e,i,o+1),n=r(n,i,o+1));let s=parseInt(e.rows/2,10),a=parseInt(e.columns/2,10),l=e.subMatrix(0,s-1,0,a-1),h=n.subMatrix(0,s-1,0,a-1),u=e.subMatrix(0,s-1,a,e.columns-1),c=n.subMatrix(0,s-1,a,n.columns-1),d=e.subMatrix(s,e.rows-1,0,a-1),f=n.subMatrix(s,n.rows-1,0,a-1),m=e.subMatrix(s,e.rows-1,a,e.columns-1),p=n.subMatrix(s,n.rows-1,a,n.columns-1),g=t(A.add(l,m),A.add(h,p),s,a),v=t(A.add(d,m),h,s,a),y=t(l,A.sub(c,p),s,a),w=t(m,A.sub(f,h),s,a),b=t(A.add(l,u),p,s,a),C=t(A.sub(d,l),A.add(h,c),s,a),S=t(A.sub(u,m),A.add(f,p),s,a),T=A.add(g,w);T.sub(b),T.add(S);let M=A.add(y,b),E=A.add(v,w),R=A.sub(g,v);R.add(y),R.add(C);let P=A.zeros(2*T.rows,2*T.columns);return P=P.setSubMatrix(T,0,0),P=P.setSubMatrix(M,T.rows,0),P=P.setSubMatrix(E,0,T.columns),P=P.setSubMatrix(R,T.rows,T.columns),P.subMatrix(0,i-1,0,o-1)}(e,t=r(t,a,l),a,l)}scaleRows(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{min:e=0,max:n=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(n))throw new TypeError("max must be a number");if(e>=n)throw new RangeError("min must be smaller than max");let i=new P(this.rows,this.columns);for(let t=0;t<this.rows;t++){const o=this.getRow(t);o.length>0&&d(o,{min:e,max:n,output:o}),i.setRow(t,o)}return i}scaleColumns(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{min:e=0,max:n=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(n))throw new TypeError("max must be a number");if(e>=n)throw new RangeError("min must be smaller than max");let i=new P(this.rows,this.columns);for(let t=0;t<this.columns;t++){const o=this.getColumn(t);o.length&&d(o,{min:e,max:n,output:o}),i.setColumn(t,o)}return i}flipRows(){const t=Math.ceil(this.columns/2);for(let e=0;e<this.rows;e++)for(let n=0;n<t;n++){let t=this.get(e,n),i=this.get(e,this.columns-1-n);this.set(e,n,i),this.set(e,this.columns-1-n,t)}return this}flipColumns(){const t=Math.ceil(this.rows/2);for(let e=0;e<this.columns;e++)for(let n=0;n<t;n++){let t=this.get(n,e),i=this.get(this.rows-1-n,e);this.set(n,e,i),this.set(this.rows-1-n,e,t)}return this}kroneckerProduct(t){t=P.checkMatrix(t);let e=this.rows,n=this.columns,i=t.rows,o=t.columns,s=new P(e*i,n*o);for(let r=0;r<e;r++)for(let e=0;e<n;e++)for(let n=0;n<i;n++)for(let a=0;a<o;a++)s.set(i*r+n,o*e+a,this.get(r,e)*t.get(n,a));return s}kroneckerSum(t){if(t=P.checkMatrix(t),!this.isSquare()||!t.isSquare())throw new Error("Kronecker Sum needs two Square Matrices");let e=this.rows,n=t.rows,i=this.kroneckerProduct(P.eye(n,n)),o=P.eye(e,e).kroneckerProduct(t);return i.add(o)}transpose(){let t=new P(this.columns,this.rows);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)t.set(n,e,this.get(e,n));return t}sortRows(t=R){for(let e=0;e<this.rows;e++)this.setRow(e,this.getRow(e).sort(t));return this}sortColumns(t=R){for(let e=0;e<this.columns;e++)this.setColumn(e,this.getColumn(e).sort(t));return this}subMatrix(t,e,n,i){S(this,t,e,n,i);let o=new P(e-t+1,i-n+1);for(let s=t;s<=e;s++)for(let e=n;e<=i;e++)o.set(s-t,e-n,this.get(s,e));return o}subMatrixRow(t,e,n){if(void 0===e&&(e=0),void 0===n&&(n=this.columns-1),e>n||e<0||e>=this.columns||n<0||n>=this.columns)throw new RangeError("Argument out of range");let i=new P(t.length,n-e+1);for(let o=0;o<t.length;o++)for(let s=e;s<=n;s++){if(t[o]<0||t[o]>=this.rows)throw new RangeError(`Row index out of range: ${t[o]}`);i.set(o,s-e,this.get(t[o],s))}return i}subMatrixColumn(t,e,n){if(void 0===e&&(e=0),void 0===n&&(n=this.rows-1),e>n||e<0||e>=this.rows||n<0||n>=this.rows)throw new RangeError("Argument out of range");let i=new P(n-e+1,t.length);for(let o=0;o<t.length;o++)for(let s=e;s<=n;s++){if(t[o]<0||t[o]>=this.columns)throw new RangeError(`Column index out of range: ${t[o]}`);i.set(s-e,o,this.get(s,t[o]))}return i}setSubMatrix(t,e,n){if((t=P.checkMatrix(t)).isEmpty())return this;S(this,e,e+t.rows-1,n,n+t.columns-1);for(let i=0;i<t.rows;i++)for(let o=0;o<t.columns;o++)this.set(e+i,n+o,t.get(i,o));return this}selection(t,e){!function(t,e){if(!a(e))throw new TypeError("row indices must be an array");for(let n=0;n<e.length;n++)if(e[n]<0||e[n]>=t.rows)throw new RangeError("row indices are out of range")}(this,t),function(t,e){if(!a(e))throw new TypeError("column indices must be an array");for(let n=0;n<e.length;n++)if(e[n]<0||e[n]>=t.columns)throw new RangeError("column indices are out of range")}(this,e);let n=new P(t.length,e.length);for(let i=0;i<t.length;i++){let o=t[i];for(let t=0;t<e.length;t++){let s=e[t];n.set(i,t,this.get(o,s))}}return n}trace(){let t=Math.min(this.rows,this.columns),e=0;for(let n=0;n<t;n++)e+=this.get(n,n);return e}clone(){let t=new P(this.rows,this.columns);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)t.set(e,n,this.get(e,n));return t}sum(t){switch(t){case"row":return function(t){let e=T(t.rows);for(let n=0;n<t.rows;++n)for(let i=0;i<t.columns;++i)e[n]+=t.get(n,i);return e}(this);case"column":return function(t){let e=T(t.columns);for(let n=0;n<t.rows;++n)for(let i=0;i<t.columns;++i)e[i]+=t.get(n,i);return e}(this);case void 0:return function(t){let e=0;for(let n=0;n<t.rows;n++)for(let i=0;i<t.columns;i++)e+=t.get(n,i);return e}(this);default:throw new Error(`invalid option: ${t}`)}}product(t){switch(t){case"row":return function(t){let e=T(t.rows,1);for(let n=0;n<t.rows;++n)for(let i=0;i<t.columns;++i)e[n]*=t.get(n,i);return e}(this);case"column":return function(t){let e=T(t.columns,1);for(let n=0;n<t.rows;++n)for(let i=0;i<t.columns;++i)e[i]*=t.get(n,i);return e}(this);case void 0:return function(t){let e=1;for(let n=0;n<t.rows;n++)for(let i=0;i<t.columns;i++)e*=t.get(n,i);return e}(this);default:throw new Error(`invalid option: ${t}`)}}mean(t){const e=this.sum(t);switch(t){case"row":for(let t=0;t<this.rows;t++)e[t]/=this.columns;return e;case"column":for(let t=0;t<this.columns;t++)e[t]/=this.rows;return e;case void 0:return e/this.size;default:throw new Error(`invalid option: ${t}`)}}variance(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");const{unbiased:n=!0,mean:i=this.mean(t)}=e;if("boolean"!=typeof n)throw new TypeError("unbiased must be a boolean");switch(t){case"row":if(!a(i))throw new TypeError("mean must be an array");return function(t,e,n){const i=t.rows,o=t.columns,s=[];for(let r=0;r<i;r++){let i=0,a=0,l=0;for(let e=0;e<o;e++)l=t.get(r,e)-n[r],i+=l,a+=l*l;e?s.push((a-i*i/o)/(o-1)):s.push((a-i*i/o)/o)}return s}(this,n,i);case"column":if(!a(i))throw new TypeError("mean must be an array");return function(t,e,n){const i=t.rows,o=t.columns,s=[];for(let r=0;r<o;r++){let o=0,a=0,l=0;for(let e=0;e<i;e++)l=t.get(e,r)-n[r],o+=l,a+=l*l;e?s.push((a-o*o/i)/(i-1)):s.push((a-o*o/i)/i)}return s}(this,n,i);case void 0:if("number"!=typeof i)throw new TypeError("mean must be a number");return function(t,e,n){const i=t.rows,o=t.columns,s=i*o;let r=0,a=0,l=0;for(let e=0;e<i;e++)for(let i=0;i<o;i++)l=t.get(e,i)-n,r+=l,a+=l*l;return e?(a-r*r/s)/(s-1):(a-r*r/s)/s}(this,n,i);default:throw new Error(`invalid option: ${t}`)}}standardDeviation(t,e){"object"==typeof t&&(e=t,t=void 0);const n=this.variance(t,e);if(void 0===t)return Math.sqrt(n);for(let t=0;t<n.length;t++)n[t]=Math.sqrt(n[t]);return n}center(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");const{center:n=this.mean(t)}=e;switch(t){case"row":if(!a(n))throw new TypeError("center must be an array");return function(t,e){for(let n=0;n<t.rows;n++)for(let i=0;i<t.columns;i++)t.set(n,i,t.get(n,i)-e[n])}(this,n),this;case"column":if(!a(n))throw new TypeError("center must be an array");return function(t,e){for(let n=0;n<t.rows;n++)for(let i=0;i<t.columns;i++)t.set(n,i,t.get(n,i)-e[i])}(this,n),this;case void 0:if("number"!=typeof n)throw new TypeError("center must be a number");return function(t,e){for(let n=0;n<t.rows;n++)for(let i=0;i<t.columns;i++)t.set(n,i,t.get(n,i)-e)}(this,n),this;default:throw new Error(`invalid option: ${t}`)}}scale(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");let n=e.scale;switch(t){case"row":if(void 0===n)n=function(t){const e=[];for(let n=0;n<t.rows;n++){let i=0;for(let e=0;e<t.columns;e++)i+=Math.pow(t.get(n,e),2)/(t.columns-1);e.push(Math.sqrt(i))}return e}(this);else if(!a(n))throw new TypeError("scale must be an array");return function(t,e){for(let n=0;n<t.rows;n++)for(let i=0;i<t.columns;i++)t.set(n,i,t.get(n,i)/e[n])}(this,n),this;case"column":if(void 0===n)n=function(t){const e=[];for(let n=0;n<t.columns;n++){let i=0;for(let e=0;e<t.rows;e++)i+=Math.pow(t.get(e,n),2)/(t.rows-1);e.push(Math.sqrt(i))}return e}(this);else if(!a(n))throw new TypeError("scale must be an array");return function(t,e){for(let n=0;n<t.rows;n++)for(let i=0;i<t.columns;i++)t.set(n,i,t.get(n,i)/e[i])}(this,n),this;case void 0:if(void 0===n)n=function(t){const e=t.size-1;let n=0;for(let i=0;i<t.columns;i++)for(let o=0;o<t.rows;o++)n+=Math.pow(t.get(o,i),2)/e;return Math.sqrt(n)}(this);else if("number"!=typeof n)throw new TypeError("scale must be a number");return function(t,e){for(let n=0;n<t.rows;n++)for(let i=0;i<t.columns;i++)t.set(n,i,t.get(n,i)/e)}(this,n),this;default:throw new Error(`invalid option: ${t}`)}}toString(t){return p(this,t)}}function R(t,e){return t-e}A.prototype.klass="Matrix","undefined"!=typeof Symbol&&(A.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return p(this)}),A.random=A.rand,A.randomInt=A.randInt,A.diagonal=A.diag,A.prototype.diagonal=A.prototype.diag,A.identity=A.eye,A.prototype.negate=A.prototype.neg,A.prototype.tensorProduct=A.prototype.kroneckerProduct;class P extends A{constructor(t,e){if(super(),P.isMatrix(t))return t.clone();if(Number.isInteger(t)&&t>=0){if(this.data=[],!(Number.isInteger(e)&&e>=0))throw new TypeError("nColumns must be a positive integer");for(let n=0;n<t;n++)this.data.push(new Float64Array(e))}else{if(!a(t))throw new TypeError("First argument must be a positive number or an array");{const n=t;if("number"!=typeof(e=(t=n.length)?n[0].length:0))throw new TypeError("Data must be a 2D array with at least one element");this.data=[];for(let i=0;i<t;i++){if(n[i].length!==e)throw new RangeError("Inconsistent array dimensions");if(!n[i].every((t=>"number"==typeof t)))throw new TypeError("Input data contains non-numeric values");this.data.push(Float64Array.from(n[i]))}}}this.rows=t,this.columns=e}set(t,e,n){return this.data[t][e]=n,this}get(t,e){return this.data[t][e]}removeRow(t){return y(this,t),this.data.splice(t,1),this.rows-=1,this}addRow(t,e){return void 0===e&&(e=t,t=this.rows),y(this,t,!0),e=Float64Array.from(b(this,e)),this.data.splice(t,0,e),this.rows+=1,this}removeColumn(t){w(this,t);for(let e=0;e<this.rows;e++){const n=new Float64Array(this.columns-1);for(let i=0;i<t;i++)n[i]=this.data[e][i];for(let i=t+1;i<this.columns;i++)n[i-1]=this.data[e][i];this.data[e]=n}return this.columns-=1,this}addColumn(t,e){void 0===e&&(e=t,t=this.columns),w(this,t,!0),e=C(this,e);for(let n=0;n<this.rows;n++){const i=new Float64Array(this.columns+1);let o=0;for(;o<t;o++)i[o]=this.data[n][o];for(i[o++]=e[n];o<this.columns+1;o++)i[o]=this.data[n][o-1];this.data[n]=i}return this.columns+=1,this}}!function(t,e){t.prototype.add=function(t){return"number"==typeof t?this.addS(t):this.addM(t)},t.prototype.addS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)+t);return this},t.prototype.addM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)+t.get(e,n));return this},t.add=function(t,n){return new e(t).add(n)},t.prototype.sub=function(t){return"number"==typeof t?this.subS(t):this.subM(t)},t.prototype.subS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)-t);return this},t.prototype.subM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)-t.get(e,n));return this},t.sub=function(t,n){return new e(t).sub(n)},t.prototype.subtract=t.prototype.sub,t.prototype.subtractS=t.prototype.subS,t.prototype.subtractM=t.prototype.subM,t.subtract=t.sub,t.prototype.mul=function(t){return"number"==typeof t?this.mulS(t):this.mulM(t)},t.prototype.mulS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)*t);return this},t.prototype.mulM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)*t.get(e,n));return this},t.mul=function(t,n){return new e(t).mul(n)},t.prototype.multiply=t.prototype.mul,t.prototype.multiplyS=t.prototype.mulS,t.prototype.multiplyM=t.prototype.mulM,t.multiply=t.mul,t.prototype.div=function(t){return"number"==typeof t?this.divS(t):this.divM(t)},t.prototype.divS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)/t);return this},t.prototype.divM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)/t.get(e,n));return this},t.div=function(t,n){return new e(t).div(n)},t.prototype.divide=t.prototype.div,t.prototype.divideS=t.prototype.divS,t.prototype.divideM=t.prototype.divM,t.divide=t.div,t.prototype.mod=function(t){return"number"==typeof t?this.modS(t):this.modM(t)},t.prototype.modS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)%t);return this},t.prototype.modM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)%t.get(e,n));return this},t.mod=function(t,n){return new e(t).mod(n)},t.prototype.modulus=t.prototype.mod,t.prototype.modulusS=t.prototype.modS,t.prototype.modulusM=t.prototype.modM,t.modulus=t.mod,t.prototype.and=function(t){return"number"==typeof t?this.andS(t):this.andM(t)},t.prototype.andS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)&t);return this},t.prototype.andM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)&t.get(e,n));return this},t.and=function(t,n){return new e(t).and(n)},t.prototype.or=function(t){return"number"==typeof t?this.orS(t):this.orM(t)},t.prototype.orS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)|t);return this},t.prototype.orM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)|t.get(e,n));return this},t.or=function(t,n){return new e(t).or(n)},t.prototype.xor=function(t){return"number"==typeof t?this.xorS(t):this.xorM(t)},t.prototype.xorS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)^t);return this},t.prototype.xorM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)^t.get(e,n));return this},t.xor=function(t,n){return new e(t).xor(n)},t.prototype.leftShift=function(t){return"number"==typeof t?this.leftShiftS(t):this.leftShiftM(t)},t.prototype.leftShiftS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)<<t);return this},t.prototype.leftShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)<<t.get(e,n));return this},t.leftShift=function(t,n){return new e(t).leftShift(n)},t.prototype.signPropagatingRightShift=function(t){return"number"==typeof t?this.signPropagatingRightShiftS(t):this.signPropagatingRightShiftM(t)},t.prototype.signPropagatingRightShiftS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)>>t);return this},t.prototype.signPropagatingRightShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)>>t.get(e,n));return this},t.signPropagatingRightShift=function(t,n){return new e(t).signPropagatingRightShift(n)},t.prototype.rightShift=function(t){return"number"==typeof t?this.rightShiftS(t):this.rightShiftM(t)},t.prototype.rightShiftS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)>>>t);return this},t.prototype.rightShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)>>>t.get(e,n));return this},t.rightShift=function(t,n){return new e(t).rightShift(n)},t.prototype.zeroFillRightShift=t.prototype.rightShift,t.prototype.zeroFillRightShiftS=t.prototype.rightShiftS,t.prototype.zeroFillRightShiftM=t.prototype.rightShiftM,t.zeroFillRightShift=t.rightShift,t.prototype.not=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,~this.get(t,e));return this},t.not=function(t){return new e(t).not()},t.prototype.abs=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.abs(this.get(t,e)));return this},t.abs=function(t){return new e(t).abs()},t.prototype.acos=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.acos(this.get(t,e)));return this},t.acos=function(t){return new e(t).acos()},t.prototype.acosh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.acosh(this.get(t,e)));return this},t.acosh=function(t){return new e(t).acosh()},t.prototype.asin=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.asin(this.get(t,e)));return this},t.asin=function(t){return new e(t).asin()},t.prototype.asinh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.asinh(this.get(t,e)));return this},t.asinh=function(t){return new e(t).asinh()},t.prototype.atan=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.atan(this.get(t,e)));return this},t.atan=function(t){return new e(t).atan()},t.prototype.atanh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.atanh(this.get(t,e)));return this},t.atanh=function(t){return new e(t).atanh()},t.prototype.cbrt=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.cbrt(this.get(t,e)));return this},t.cbrt=function(t){return new e(t).cbrt()},t.prototype.ceil=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.ceil(this.get(t,e)));return this},t.ceil=function(t){return new e(t).ceil()},t.prototype.clz32=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.clz32(this.get(t,e)));return this},t.clz32=function(t){return new e(t).clz32()},t.prototype.cos=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.cos(this.get(t,e)));return this},t.cos=function(t){return new e(t).cos()},t.prototype.cosh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.cosh(this.get(t,e)));return this},t.cosh=function(t){return new e(t).cosh()},t.prototype.exp=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.exp(this.get(t,e)));return this},t.exp=function(t){return new e(t).exp()},t.prototype.expm1=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.expm1(this.get(t,e)));return this},t.expm1=function(t){return new e(t).expm1()},t.prototype.floor=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.floor(this.get(t,e)));return this},t.floor=function(t){return new e(t).floor()},t.prototype.fround=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.fround(this.get(t,e)));return this},t.fround=function(t){return new e(t).fround()},t.prototype.log=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log(this.get(t,e)));return this},t.log=function(t){return new e(t).log()},t.prototype.log1p=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log1p(this.get(t,e)));return this},t.log1p=function(t){return new e(t).log1p()},t.prototype.log10=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log10(this.get(t,e)));return this},t.log10=function(t){return new e(t).log10()},t.prototype.log2=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log2(this.get(t,e)));return this},t.log2=function(t){return new e(t).log2()},t.prototype.round=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.round(this.get(t,e)));return this},t.round=function(t){return new e(t).round()},t.prototype.sign=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sign(this.get(t,e)));return this},t.sign=function(t){return new e(t).sign()},t.prototype.sin=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sin(this.get(t,e)));return this},t.sin=function(t){return new e(t).sin()},t.prototype.sinh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sinh(this.get(t,e)));return this},t.sinh=function(t){return new e(t).sinh()},t.prototype.sqrt=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sqrt(this.get(t,e)));return this},t.sqrt=function(t){return new e(t).sqrt()},t.prototype.tan=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.tan(this.get(t,e)));return this},t.tan=function(t){return new e(t).tan()},t.prototype.tanh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.tanh(this.get(t,e)));return this},t.tanh=function(t){return new e(t).tanh()},t.prototype.trunc=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.trunc(this.get(t,e)));return this},t.trunc=function(t){return new e(t).trunc()},t.pow=function(t,n){return new e(t).pow(n)},t.prototype.pow=function(t){return"number"==typeof t?this.powS(t):this.powM(t)},t.prototype.powS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,Math.pow(this.get(e,n),t));return this},t.prototype.powM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,Math.pow(this.get(e,n),t.get(e,n)));return this}}(A,P);class N extends A{constructor(t){super(),this.data=t,this.rows=t.length,this.columns=t[0].length}set(t,e,n){return this.data[t][e]=n,this}get(t,e){return this.data[t][e]}}class x{constructor(t){let e,n,i,o,s,r,a,l,h,u=(t=N.checkMatrix(t)).clone(),c=u.rows,d=u.columns,f=new Float64Array(c),m=1;for(e=0;e<c;e++)f[e]=e;for(l=new Float64Array(c),n=0;n<d;n++){for(e=0;e<c;e++)l[e]=u.get(e,n);for(e=0;e<c;e++){for(h=Math.min(e,n),s=0,i=0;i<h;i++)s+=u.get(e,i)*l[i];l[e]-=s,u.set(e,n,l[e])}for(o=n,e=n+1;e<c;e++)Math.abs(l[e])>Math.abs(l[o])&&(o=e);if(o!==n){for(i=0;i<d;i++)r=u.get(o,i),u.set(o,i,u.get(n,i)),u.set(n,i,r);a=f[o],f[o]=f[n],f[n]=a,m=-m}if(n<c&&0!==u.get(n,n))for(e=n+1;e<c;e++)u.set(e,n,u.get(e,n)/u.get(n,n))}this.LU=u,this.pivotVector=f,this.pivotSign=m}isSingular(){let t=this.LU,e=t.columns;for(let n=0;n<e;n++)if(0===t.get(n,n))return!0;return!1}solve(t){t=P.checkMatrix(t);let e=this.LU;if(e.rows!==t.rows)throw new Error("Invalid matrix dimensions");if(this.isSingular())throw new Error("LU matrix is singular");let n,i,o,s=t.columns,r=t.subMatrixRow(this.pivotVector,0,s-1),a=e.columns;for(o=0;o<a;o++)for(n=o+1;n<a;n++)for(i=0;i<s;i++)r.set(n,i,r.get(n,i)-r.get(o,i)*e.get(n,o));for(o=a-1;o>=0;o--){for(i=0;i<s;i++)r.set(o,i,r.get(o,i)/e.get(o,o));for(n=0;n<o;n++)for(i=0;i<s;i++)r.set(n,i,r.get(n,i)-r.get(o,i)*e.get(n,o))}return r}get determinant(){let t=this.LU;if(!t.isSquare())throw new Error("Matrix must be square");let e=this.pivotSign,n=t.columns;for(let i=0;i<n;i++)e*=t.get(i,i);return e}get lowerTriangularMatrix(){let t=this.LU,e=t.rows,n=t.columns,i=new P(e,n);for(let o=0;o<e;o++)for(let e=0;e<n;e++)o>e?i.set(o,e,t.get(o,e)):o===e?i.set(o,e,1):i.set(o,e,0);return i}get upperTriangularMatrix(){let t=this.LU,e=t.rows,n=t.columns,i=new P(e,n);for(let o=0;o<e;o++)for(let e=0;e<n;e++)o<=e?i.set(o,e,t.get(o,e)):i.set(o,e,0);return i}get pivotPermutationVector(){return Array.from(this.pivotVector)}}function L(t,e){let n=0;return Math.abs(t)>Math.abs(e)?(n=e/t,Math.abs(t)*Math.sqrt(1+n*n)):0!==e?(n=t/e,Math.abs(e)*Math.sqrt(1+n*n)):0}class G{constructor(t){let e,n,i,o,s=(t=N.checkMatrix(t)).clone(),r=t.rows,a=t.columns,l=new Float64Array(a);for(i=0;i<a;i++){let t=0;for(e=i;e<r;e++)t=L(t,s.get(e,i));if(0!==t){for(s.get(i,i)<0&&(t=-t),e=i;e<r;e++)s.set(e,i,s.get(e,i)/t);for(s.set(i,i,s.get(i,i)+1),n=i+1;n<a;n++){for(o=0,e=i;e<r;e++)o+=s.get(e,i)*s.get(e,n);for(o=-o/s.get(i,i),e=i;e<r;e++)s.set(e,n,s.get(e,n)+o*s.get(e,i))}}l[i]=-t}this.QR=s,this.Rdiag=l}solve(t){t=P.checkMatrix(t);let e=this.QR,n=e.rows;if(t.rows!==n)throw new Error("Matrix row dimensions must agree");if(!this.isFullRank())throw new Error("Matrix is rank deficient");let i,o,s,r,a=t.columns,l=t.clone(),h=e.columns;for(s=0;s<h;s++)for(o=0;o<a;o++){for(r=0,i=s;i<n;i++)r+=e.get(i,s)*l.get(i,o);for(r=-r/e.get(s,s),i=s;i<n;i++)l.set(i,o,l.get(i,o)+r*e.get(i,s))}for(s=h-1;s>=0;s--){for(o=0;o<a;o++)l.set(s,o,l.get(s,o)/this.Rdiag[s]);for(i=0;i<s;i++)for(o=0;o<a;o++)l.set(i,o,l.get(i,o)-l.get(s,o)*e.get(i,s))}return l.subMatrix(0,h-1,0,a-1)}isFullRank(){let t=this.QR.columns;for(let e=0;e<t;e++)if(0===this.Rdiag[e])return!1;return!0}get upperTriangularMatrix(){let t,e,n=this.QR,i=n.columns,o=new P(i,i);for(t=0;t<i;t++)for(e=0;e<i;e++)t<e?o.set(t,e,n.get(t,e)):t===e?o.set(t,e,this.Rdiag[t]):o.set(t,e,0);return o}get orthogonalMatrix(){let t,e,n,i,o=this.QR,s=o.rows,r=o.columns,a=new P(s,r);for(n=r-1;n>=0;n--){for(t=0;t<s;t++)a.set(t,n,0);for(a.set(n,n,1),e=n;e<r;e++)if(0!==o.get(n,n)){for(i=0,t=n;t<s;t++)i+=o.get(t,n)*a.get(t,e);for(i=-i/o.get(n,n),t=n;t<s;t++)a.set(t,e,a.get(t,e)+i*o.get(t,n))}}return a}}class _{constructor(t,e={}){if((t=N.checkMatrix(t)).isEmpty())throw new Error("Matrix must be non-empty");let n=t.rows,i=t.columns;const{computeLeftSingularVectors:o=!0,computeRightSingularVectors:s=!0,autoTranspose:r=!1}=e;let a,l=Boolean(o),h=Boolean(s),u=!1;if(n<i)if(r){a=t.transpose(),n=a.rows,i=a.columns,u=!0;let e=l;l=h,h=e}else a=t.clone(),console.warn("Computing SVD on a matrix with more columns than rows. Consider enabling autoTranspose");else a=t.clone();let c=Math.min(n,i),d=Math.min(n+1,i),f=new Float64Array(d),m=new P(n,c),p=new P(i,i),g=new Float64Array(i),v=new Float64Array(n),y=new Float64Array(d);for(let t=0;t<d;t++)y[t]=t;let w=Math.min(n-1,i),b=Math.max(0,Math.min(i-2,n)),C=Math.max(w,b);for(let t=0;t<C;t++){if(t<w){f[t]=0;for(let e=t;e<n;e++)f[t]=L(f[t],a.get(e,t));if(0!==f[t]){a.get(t,t)<0&&(f[t]=-f[t]);for(let e=t;e<n;e++)a.set(e,t,a.get(e,t)/f[t]);a.set(t,t,a.get(t,t)+1)}f[t]=-f[t]}for(let e=t+1;e<i;e++){if(t<w&&0!==f[t]){let i=0;for(let o=t;o<n;o++)i+=a.get(o,t)*a.get(o,e);i=-i/a.get(t,t);for(let o=t;o<n;o++)a.set(o,e,a.get(o,e)+i*a.get(o,t))}g[e]=a.get(t,e)}if(l&&t<w)for(let e=t;e<n;e++)m.set(e,t,a.get(e,t));if(t<b){g[t]=0;for(let e=t+1;e<i;e++)g[t]=L(g[t],g[e]);if(0!==g[t]){g[t+1]<0&&(g[t]=0-g[t]);for(let e=t+1;e<i;e++)g[e]/=g[t];g[t+1]+=1}if(g[t]=-g[t],t+1<n&&0!==g[t]){for(let e=t+1;e<n;e++)v[e]=0;for(let e=t+1;e<n;e++)for(let n=t+1;n<i;n++)v[e]+=g[n]*a.get(e,n);for(let e=t+1;e<i;e++){let i=-g[e]/g[t+1];for(let o=t+1;o<n;o++)a.set(o,e,a.get(o,e)+i*v[o])}}if(h)for(let e=t+1;e<i;e++)p.set(e,t,g[e])}}let S=Math.min(i,n+1);if(w<i&&(f[w]=a.get(w,w)),n<S&&(f[S-1]=0),b+1<S&&(g[b]=a.get(b,S-1)),g[S-1]=0,l){for(let t=w;t<c;t++){for(let e=0;e<n;e++)m.set(e,t,0);m.set(t,t,1)}for(let t=w-1;t>=0;t--)if(0!==f[t]){for(let e=t+1;e<c;e++){let i=0;for(let o=t;o<n;o++)i+=m.get(o,t)*m.get(o,e);i=-i/m.get(t,t);for(let o=t;o<n;o++)m.set(o,e,m.get(o,e)+i*m.get(o,t))}for(let e=t;e<n;e++)m.set(e,t,-m.get(e,t));m.set(t,t,1+m.get(t,t));for(let e=0;e<t-1;e++)m.set(e,t,0)}else{for(let e=0;e<n;e++)m.set(e,t,0);m.set(t,t,1)}}if(h)for(let t=i-1;t>=0;t--){if(t<b&&0!==g[t])for(let e=t+1;e<i;e++){let n=0;for(let o=t+1;o<i;o++)n+=p.get(o,t)*p.get(o,e);n=-n/p.get(t+1,t);for(let o=t+1;o<i;o++)p.set(o,e,p.get(o,e)+n*p.get(o,t))}for(let e=0;e<i;e++)p.set(e,t,0);p.set(t,t,1)}let T=S-1,M=0,E=Number.EPSILON;for(;S>0;){let t,e;for(t=S-2;t>=-1&&-1!==t;t--){const e=Number.MIN_VALUE+E*Math.abs(f[t]+Math.abs(f[t+1]));if(Math.abs(g[t])<=e||Number.isNaN(g[t])){g[t]=0;break}}if(t===S-2)e=4;else{let n;for(n=S-1;n>=t&&n!==t;n--){let e=(n!==S?Math.abs(g[n]):0)+(n!==t+1?Math.abs(g[n-1]):0);if(Math.abs(f[n])<=E*e){f[n]=0;break}}n===t?e=3:n===S-1?e=1:(e=2,t=n)}switch(t++,e){case 1:{let e=g[S-2];g[S-2]=0;for(let n=S-2;n>=t;n--){let o=L(f[n],e),s=f[n]/o,r=e/o;if(f[n]=o,n!==t&&(e=-r*g[n-1],g[n-1]=s*g[n-1]),h)for(let t=0;t<i;t++)o=s*p.get(t,n)+r*p.get(t,S-1),p.set(t,S-1,-r*p.get(t,n)+s*p.get(t,S-1)),p.set(t,n,o)}break}case 2:{let e=g[t-1];g[t-1]=0;for(let i=t;i<S;i++){let o=L(f[i],e),s=f[i]/o,r=e/o;if(f[i]=o,e=-r*g[i],g[i]=s*g[i],l)for(let e=0;e<n;e++)o=s*m.get(e,i)+r*m.get(e,t-1),m.set(e,t-1,-r*m.get(e,i)+s*m.get(e,t-1)),m.set(e,i,o)}break}case 3:{const e=Math.max(Math.abs(f[S-1]),Math.abs(f[S-2]),Math.abs(g[S-2]),Math.abs(f[t]),Math.abs(g[t])),o=f[S-1]/e,s=f[S-2]/e,r=g[S-2]/e,a=f[t]/e,u=g[t]/e,c=((s+o)*(s-o)+r*r)/2,d=o*r*(o*r);let v=0;0===c&&0===d||(v=c<0?0-Math.sqrt(c*c+d):Math.sqrt(c*c+d),v=d/(c+v));let y=(a+o)*(a-o)+v,w=a*u;for(let e=t;e<S-1;e++){let o=L(y,w);0===o&&(o=Number.MIN_VALUE);let s=y/o,r=w/o;if(e!==t&&(g[e-1]=o),y=s*f[e]+r*g[e],g[e]=s*g[e]-r*f[e],w=r*f[e+1],f[e+1]=s*f[e+1],h)for(let t=0;t<i;t++)o=s*p.get(t,e)+r*p.get(t,e+1),p.set(t,e+1,-r*p.get(t,e)+s*p.get(t,e+1)),p.set(t,e,o);if(o=L(y,w),0===o&&(o=Number.MIN_VALUE),s=y/o,r=w/o,f[e]=o,y=s*g[e]+r*f[e+1],f[e+1]=-r*g[e]+s*f[e+1],w=r*g[e+1],g[e+1]=s*g[e+1],l&&e<n-1)for(let t=0;t<n;t++)o=s*m.get(t,e)+r*m.get(t,e+1),m.set(t,e+1,-r*m.get(t,e)+s*m.get(t,e+1)),m.set(t,e,o)}g[S-2]=y,M+=1;break}case 4:if(f[t]<=0&&(f[t]=f[t]<0?-f[t]:0,h))for(let e=0;e<=T;e++)p.set(e,t,-p.get(e,t));for(;t<T&&!(f[t]>=f[t+1]);){let e=f[t];if(f[t]=f[t+1],f[t+1]=e,h&&t<i-1)for(let n=0;n<i;n++)e=p.get(n,t+1),p.set(n,t+1,p.get(n,t)),p.set(n,t,e);if(l&&t<n-1)for(let i=0;i<n;i++)e=m.get(i,t+1),m.set(i,t+1,m.get(i,t)),m.set(i,t,e);t++}M=0,S--}}if(u){let t=p;p=m,m=t}this.m=n,this.n=i,this.s=f,this.U=m,this.V=p}solve(t){let e=t,n=this.threshold,i=this.s.length,o=P.zeros(i,i);for(let t=0;t<i;t++)Math.abs(this.s[t])<=n?o.set(t,t,0):o.set(t,t,1/this.s[t]);let s=this.U,r=this.rightSingularVectors,a=r.mmul(o),l=r.rows,h=s.rows,u=P.zeros(l,h);for(let t=0;t<l;t++)for(let e=0;e<h;e++){let n=0;for(let o=0;o<i;o++)n+=a.get(t,o)*s.get(e,o);u.set(t,e,n)}return u.mmul(e)}solveForDiagonal(t){return this.solve(P.diag(t))}inverse(){let t=this.V,e=this.threshold,n=t.rows,i=t.columns,o=new P(n,this.s.length);for(let s=0;s<n;s++)for(let n=0;n<i;n++)Math.abs(this.s[n])>e&&o.set(s,n,t.get(s,n)/this.s[n]);let s=this.U,r=s.rows,a=s.columns,l=new P(n,r);for(let t=0;t<n;t++)for(let e=0;e<r;e++){let n=0;for(let i=0;i<a;i++)n+=o.get(t,i)*s.get(e,i);l.set(t,e,n)}return l}get condition(){return this.s[0]/this.s[Math.min(this.m,this.n)-1]}get norm2(){return this.s[0]}get rank(){let t=Math.max(this.m,this.n)*this.s[0]*Number.EPSILON,e=0,n=this.s;for(let i=0,o=n.length;i<o;i++)n[i]>t&&e++;return e}get diagonal(){return Array.from(this.s)}get threshold(){return Number.EPSILON/2*Math.max(this.m,this.n)*this.s[0]}get leftSingularVectors(){return this.U}get rightSingularVectors(){return this.V}get diagonalMatrix(){return P.diag(this.s)}}function I(t,e,n,i,o){let s=n*i*i,r=P.eye(e.length,e.length,s);const a=o(e);let l=new Float64Array(t.x.length);for(let e=0;e<t.x.length;e++)l[e]=a(t.x[e]);let h=function(t,e,n,i,o){const s=n.length,r=t.x.length;let a=new Array(s);for(let l=0;l<s;l++){a[l]=new Array(r);let s=n.slice();s[l]+=i;let h=o(s);for(let n=0;n<r;n++)a[l][n]=e[n]-h(t.x[n])}return new P(a)}(t,l,e,i,o),u=function(t,e){const n=t.x.length;let i=new Array(n);for(let o=0;o<n;o++)i[o]=[t.y[o]-e[o]];return new P(i)}(t,l),c=function(t,e=!1){return t=N.checkMatrix(t),e?new _(t).inverse():function(t,e,n=!1){return t=N.checkMatrix(t),e=N.checkMatrix(e),n?new _(t).solve(e):t.isSquare()?new x(t).solve(e):new G(t).solve(e)}(t,P.eye(t.rows))}(r.add(h.mmul(h.transpose())));return(e=(e=new P([e])).sub(c.mmul(h).mmul(u).mul(i).transpose())).to1DArray()}function W(t,e,n={}){let{maxIterations:i=100,gradientDifference:r=.1,damping:a=0,errorTolerance:l=.01,minValues:h,maxValues:u,initialValues:c}=n;if(a<=0)throw new Error("The damping option must be a positive number");if(!t.x||!t.y)throw new Error("The data parameter must have x and y elements");if(!o(t.x)||t.x.length<2||!o(t.y)||t.y.length<2)throw new Error("The data parameter elements must be an array with more than 2 points");if(t.x.length!==t.y.length)throw new Error("The data parameter elements must have the same size");let d=c||new Array(e.length).fill(1),f=d.length;if(u=u||new Array(f).fill(Number.MAX_SAFE_INTEGER),h=h||new Array(f).fill(Number.MIN_SAFE_INTEGER),u.length!==h.length)throw new Error("minValues and maxValues must be the same size");if(!o(d))throw new Error("initialValues must be an array");let m,p=s(t,d,e),g=p<=l;for(m=0;m<i&&!g;m++){d=I(t,d,a,r,e);for(let t=0;t<f;t++)d[t]=Math.min(Math.max(h[t],d[t]),u[t]);if(p=s(t,d,e),isNaN(p))break;g=p<=l}return{parameterValues:d,parameterError:p,iterations:m}}},3379:t=>{"use strict";var e=[];function n(t){for(var n=-1,i=0;i<e.length;i++)if(e[i].identifier===t){n=i;break}return n}function i(t,i){for(var s={},r=[],a=0;a<t.length;a++){var l=t[a],h=i.base?l[0]+i.base:l[0],u=s[h]||0,c="".concat(h," ").concat(u);s[h]=u+1;var d=n(c),f={css:l[1],media:l[2],sourceMap:l[3],supports:l[4],layer:l[5]};if(-1!==d)e[d].references++,e[d].updater(f);else{var m=o(f,i);i.byIndex=a,e.splice(a,0,{identifier:c,updater:m,references:1})}r.push(c)}return r}function o(t,e){var n=e.domAPI(e);return n.update(t),function(e){if(e){if(e.css===t.css&&e.media===t.media&&e.sourceMap===t.sourceMap&&e.supports===t.supports&&e.layer===t.layer)return;n.update(t=e)}else n.remove()}}t.exports=function(t,o){var s=i(t=t||[],o=o||{});return function(t){t=t||[];for(var r=0;r<s.length;r++){var a=n(s[r]);e[a].references--}for(var l=i(t,o),h=0;h<s.length;h++){var u=n(s[h]);0===e[u].references&&(e[u].updater(),e.splice(u,1))}s=l}}},569:t=>{"use strict";var e={};t.exports=function(t,n){var i=function(t){if(void 0===e[t]){var n=document.querySelector(t);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(t){n=null}e[t]=n}return e[t]}(t);if(!i)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");i.appendChild(n)}},9216:t=>{"use strict";t.exports=function(t){var e=document.createElement("style");return t.setAttributes(e,t.attributes),t.insert(e,t.options),e}},3565:(t,e,n)=>{"use strict";t.exports=function(t){var e=n.nc;e&&t.setAttribute("nonce",e)}},7795:t=>{"use strict";t.exports=function(t){if("undefined"==typeof document)return{update:function(){},remove:function(){}};var e=t.insertStyleElement(t);return{update:function(n){!function(t,e,n){var i="";n.supports&&(i+="@supports (".concat(n.supports,") {")),n.media&&(i+="@media ".concat(n.media," {"));var o=void 0!==n.layer;o&&(i+="@layer".concat(n.layer.length>0?" ".concat(n.layer):""," {")),i+=n.css,o&&(i+="}"),n.media&&(i+="}"),n.supports&&(i+="}");var s=n.sourceMap;s&&"undefined"!=typeof btoa&&(i+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(s))))," */")),e.styleTagTransform(i,t,e.options)}(e,t,n)},remove:function(){!function(t){if(null===t.parentNode)return!1;t.parentNode.removeChild(t)}(e)}}}},4589:t=>{"use strict";t.exports=function(t,e){if(e.styleSheet)e.styleSheet.cssText=t;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(t))}}},7241:(t,e,n)=>{"use strict";n.d(e,{D:()=>h});var i=n(4469),o=n(976),s=n(7399),r=n(6714),a=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};const l=31;function h(t,e=!1,n){return a(this,void 0,void 0,(function*(){const a=t.tags.separator,h=t.tags[o.TAGS.UNITS],c=(0,r.vU)(h,a);let d;null!=n||(n=new Map);const f="helm"===h?(0,s.getHelmMonomers)(t):Object.keys((0,r.fy)(t,0,c).freq).filter((t=>""!==t));for(let t=0;t<f.length;t++)n.has(f[t])||n.set(f[t],`${n.size+1}`);if("helm"===h)d=yield i.functions.call("HELM:getMolFiles",{col:t}),d=function(t,e,n=!1){const i=new Array(t.length);for(let o=0;o<t.length;o++){let s=0,r=0,a="\n Datagrok macromolecule handler\n\n 0 0 0 0 0 0 999 V3000\nM V30 BEGIN CTAB\n";const h=t.get(o);s=h.indexOf("\n",s)+1,s=h.indexOf("\n",s)+1,s=h.indexOf("\n",s)+1;const u=parseInt(h.substring(s,s+3)),c=parseInt(h.substring(s+3,s+6));a+=`M V30 COUNTS ${u} ${c} 0 0 0\n`,a+="M V30 BEGIN ATOM\n";for(let t=0;t<u;t++){s=h.indexOf("\n",s)+1+l,r=h.indexOf(" ",s);const i=h.substring(s,r);a+=n?`M V30 ${t+1} R${e.get(i)} 0.000 0.000 0 0\n`:`M V30 ${t+1} At 0.000 0.000 0 0 MASS=${e.get(i)}\n`}a+="M V30 END ATOM\n",a+="M V30 BEGIN BOND\n";for(let t=0;t<c;t++){s=h.indexOf("\n",s)+1;const e=parseInt(h.substring(s,s+3).trim()),n=parseInt(h.substring(s+3,s+6).trim());a+=`M V30 ${t+1} ${parseInt(h.substring(s+6,s+9).trim())} ${e} ${n}\n`}a+="M V30 END BOND\n",a+="M V30 END CTAB\n",a+="M END",i[o]=a}return i}(d,n,e);else{d=new Array(t.length);for(let i=0;i<t.length;i++){const o=u(c(t.get(i)).filter((t=>""!==t)),n,e);d[i]=o}}return o.Column.fromStrings("monomericMols",d)}))}function u(t,e,n=!1){let i="\n Datagrok macromolecule handler\n\n 0 0 0 0 0 0 999 V3000\nM V30 BEGIN CTAB\n";i+=`M V30 COUNTS ${t.length} ${t.length?t.length-1:0} 0 0 0\n`,i+="M V30 BEGIN ATOM\n";for(let o=0;o<t.length;o++)i+=n?`M V30 ${o+1} R${e.get(t[o])} 0.000 0.000 0 0\n`:`M V30 ${o+1} At 0.000 0.000 0 0 MASS=${e.get(t[o])}\n`;i+="M V30 END ATOM\n",i+="M V30 BEGIN BOND\n";for(let e=0;e<t.length-1;e++)i+=`M V30 ${e+1} 1 ${e+1} ${e+2}\n`;return i+="M V30 END BOND\n",i+="M V30 END CTAB\n",i+="M END",i}},7399:(t,e,n)=>{"use strict";n.d(e,{activityCliffs:()=>It,checkInputColumn:()=>_t,getHelmMonomers:()=>Ht,importFasta:()=>kt,multipleSequenceAlignmentAny:()=>Ft,sequenceSpaceTopMenu:()=>Wt,splitToMonomers:()=>Dt});var i=n(4469),o=n(3870),s=n(976),r=n(6714);const a=r.GU;var l;!function(t){t.MSA="MSA",t.classic="classic"}(l||(l={}));const h=(t,e,n,i,o,s,r="rgb(100,100,100)",h=0,u=!1,c=1,d="",f=!1,m=l.classic,p={},g=0,v=null,y=[],w=null)=>{var b,C,S;o.textAlign="start";let T=s.substring(0),M=f?"":d;m===l.MSA&&(M="");let E=!0,A=!0,R="difference";null!=v&&null!=v.cell.column&&(E=null===(b=v.cell.column.temp["color-code"])||void 0===b||b,A=null===(C=v.cell.column.temp["compare-with-current"])||void 0===C||C,R=null!==(S=v.cell.column.temp["highlight-difference"])&&void 0!==S?S:"difference");const P=y[g];A&&y.length>0&&"difference"===R&&(c=T==P?.3:c),A&&y.length>0&&"equal"===R&&(c=T!=P?.3:c),null!=w&&(T=a(T,w));let N=o.measureText(T+M),x=o.measureText(T).width,L=o.measureText(T).width;const G=i/2-(N.fontBoundingBoxAscent+N.fontBoundingBoxDescent)/2+1;function _(n,i){const s=E?r:"rgb(0,0,0)";o.fillStyle=s,o.globalAlpha=c,m===l.classic&&(o.fillText(T,t+n,e+G),o.fillStyle="#808080",o.fillText(M,t+i,e+G)),m===l.MSA&&(o.fillStyle=s,o.fillText(T,t+n+(p[g]-L)/2,e+G))}if(N=N.width,m===l.MSA&&(x=p[g],N=p[g]),u||N>n)return _(5,5+x),t+x+o.measureText(M).width;{const e=(n-N)/2;return _(e,e+x),t+e+x}};var u=n(3553),c=n(7331);function d(t){const e=!t.some(((e,n)=>e.length>1&&0!=n&&n!=t.length-1)),n=[],i=e?"":" ";return t.forEach(((e,o)=>{o<t.length&&(e+=`${e?"":"-"}${i}`),n.push(e)})),[n,e]}class f extends s.GridCellRenderer{get name(){return"sequence"}get cellType(){return"sequence"}get defaultHeight(){return 30}get defaultWidth(){return 230}onClick(t,e){t.cell.column.temp["current-word"]=t.cell.value,t.grid.invalidate()}onMouseMove(t,e){if("SEQ.MSA"!==t.cell.column.getTag("aligned"))return;const n=t.cell.column.temp,i=n["bio-sum-maxLengthWords"],o=n["bio-maxIndex"],s=e.offsetX-t.gridColumn.left+(t.gridColumn.left-t.bounds.x);let r=o;i[o+1]=s+1;if(s>i[0])for(;;)Math.floor((r+0)/2),s>=i[0]&&s<=i[1]||s<i[0]||i[1];i[0];const a=(t.cell.column.getTag("separator"),""),l=getSplitter("separator",a)(t.cell.value);l[0],ui.tooltip.hide()}render(t,e,n,i,o,s,r){const a=-1!==s.gridRow?s.grid:null,l=s.cell,h=s.cell.column.getTag("alphabet");getUpdatedWidth(a,t,e,i),t.save(),t.beginPath(),t.rect(e,n,i,o),t.clip(),t.font="12px monospace",t.textBaseline="top";const u=s.cell.column.getTag(DG.TAGS.UNITS),c=s.cell.column.getTag("aligned"),d=getPaletteByType(h),f=(s.cell.column.getTag("separator"),""),m=i/5,p=getSplitter(u,f,m),g=s.cell.column.temp,v=g["reference-sequence"],y=g["current-word"],w=(g["monomer-width"],p(null!=v&&""!=v?v:null!=y?y:""));let b={};if(s.cell.column.getTag(".calculatedCellRender")!==m.toString()){let t=0;for(;t<Math.min(s.cell.column.length,100);)p(s.cell.column.get(t)).forEach(((t,e)=>{const n=7*cell_renderer_monomerToShortFunction(t,8).length+5;n>(b[e],0)&&(b[e]=n)}));const e=21;for(let t=0;t<=0;t++){b[t]<e&&(b[t]=e);const n={};n[0]=b[0];for(let t=1;t<=0;t++)n[t]=n[t-1]+b[t];g["bio-sum-maxLengthWords"]=n,g["bio-maxIndex"]=0,g["bio-maxLengthWords"]=b,s.cell.column.setTag(".calculatedCellRender",m.toString())}}else g["bio-maxLengthWords"];const C=p(l.value);let S=e,T=cell_renderer_undefinedColor,M=DrawStyle.classic;c&&c.includes("MSA")&&"separator"==u&&DrawStyle.MSA,C.every(((e,r)=>{d.get(e),t.fillStyle=cell_renderer_undefinedColor;const a=r===C.length-1;return printLeftOrCentered(S,n,i,o,t,e,T,0,!0,1,f,a,M,b,r,s,w,8),50<=i})),t.restore()}}class m extends s.GridCellRenderer{get name(){return C.SEM_TYPES.MONOMER}get cellType(){return C.SEM_TYPES.MONOMER}get defaultHeight(){return 15}get defaultWidth(){return 30}render(t,e,n,i,o,s,r){t.font="12px monospace",t.textBaseline="middle",t.textAlign="center";const a=getPaletteByType(s.cell.column.getTag("alphabet")),l=s.cell.value;if(!l)return;const h=a.get(l);t.fillStyle=h,t.fillText(monomerToShort(l,3),e+i/2,n+o/2,i)}}class p extends s.GridCellRenderer{get name(){return"MacromoleculeDifferenceCR"}get cellType(){return C.SEM_TYPES.MACROMOLECULE_DIFFERENCE}get defaultHeight(){return 30}get defaultWidth(){return 230}render(t,e,n,i,o,s,r){const a=s.grid,l=(s.cell.value,""),h=s.tableColumn.tags.separator,u=s.tableColumn.tags[DG.TAGS.UNITS];getUpdatedWidth(a,t,e,i);const[c,d]=l.split("#"),f=getSplitter(u,h);g(t,e,n,i,o,f(c),f(d),u)}}function g(t,e,n,i,o,s,a,l,u,f){if(s.length!==a.length){const t=function(t,e){let n=0,i=0;const o=t.length>e.length?t:e;let s=t.length>e.length?e:t;for(let t=0;t<s.length;t++)o[t]===s[t]&&n++;const r=o.length-s.length;for(let t=o.length-1;t>r;t--)o[t]===s[t-r]&&i++;const a=new Array(Math.abs(t.length-e.length)).fill("");function l(t){return n>i?t.concat(a):a.concat(t)}return t.length>e.length?e=l(e):t=l(t),{subParts1:t,subParts2:e}}(s,a);s=t.subParts1,a=t.subParts2}const m=t.measureText(d(s).join("")),p=t.measureText(d(a).join("")),g=Math.max(m.width,p.width);u&&(i=g+4*s.length,t.canvas.width=g+4*s.length);let y=Math.max(e,e+(i-(g+4*s.length))/2);const w=Math.max(n,n+(o-28)/2);t.save(),t.beginPath(),t.rect(e,n,u?g+4*s.length:i,o),t.clip(),t.font="12px monospace",t.textBaseline="top";let b=c.UE.Color;"HELM"!=l&&(b=(0,r.py)(l.substring(l.length-2)));for(let e=0;e<s.length;e++){const n=s[e],r=a[e],l=b.get(n);if(n!=r){const s=b.get(r),a=h(y,w-7,i,o,t,n,l,0,!0),u=h(y,w+7,i,o,t,r,s,0,!0);y=Math.max(u,a),f&&(f[e]=v(n,r,l,s,w,7,o))}else y=h(y,w,i,o,t,n,l,0,!0,.5);y+=4}t.restore()}function v(t,e,n,i,o,s,r){const a=document.createElement("canvas"),l=a.getContext("2d");l.font="12px monospace";const u=l.measureText(d([t]).join("")).width,c=l.measureText(d([e]).join("")).width,f=Math.max(u,c);return a.height=r,a.width=f+4,l.font="12px monospace",l.textBaseline="top",h(0,o-s,f,r,l,t,n,0,!0),h(0,o+s,f,r,l,e,i,0,!0),a}var y,w,b=n(701),S=(n(2433),n(9298));(w=y||(y={})).Unknown="unknown",w.FR="framework",w.CDR="cdr",new class{constructor(){this.regionTypes=[y.CDR],this.chains=["Heavy","Light"],this.skipEmptyPositions=!1,this.positionWidth=16,this.positionHeight=S.ES.Entropy}};class T extends s.JsViewer{constructor(){super(),this.viewed=!1,this.regionsFg=null,this.regionsRoot=null,this.isOpened=!1,this.panelNode=null,this.regions=[],this.viewPromise=Promise.resolve(),this.host=null,this.filterSourceInput=null,this.mainLayout=null,this.logos=[],this.viewSubs=[],this.regionTypes=this.stringList("regionTypes",[vrt.CDR],{choices:Object.values(vrt).filter((t=>t!=vrt.Unknown))}),this.chains=this.stringList("chains",["Heavy","Light"],{choices:["Heavy","Light"]}),this.skipEmptyPositions=this.bool("skipEmptyPositions",!1),this.positionWidth=this.float("positionWidth",16),this.positionHeight=this.string("positionHeight",PositionHeight.Entropy,{choices:Object.keys(PositionHeight)})}init(){return __awaiter(this,void 0,void 0,(function*(){this.subs.push(ui.onSizeChanged(this.root).subscribe(this.rootOnSizeChanged.bind(this))),this.subs.push(rxjs.fromEvent(this.root,"mousemove").subscribe(this.rootOnMouseMove.bind(this)))}))}onTableAttached(){const t=Object.create(null,{onTableAttached:{get:()=>super.onTableAttached}});return __awaiter(this,void 0,void 0,(function*(){const e=t.onTableAttached.bind(this);this.viewPromise=this.viewPromise.then((()=>__awaiter(this,void 0,void 0,(function*(){e(),this.viewed||(yield this.buildView("onTableAttached"),this.viewed=!0)}))))}))}onPropertyChanged(t){if(super.onPropertyChanged(t),t)switch(t&&t.name,t.name){case"skipEmptyPositions":case"positionWidth":case"positionHeight":this.setData(this.dataFrame,this.regions)}else console.warn("Bio: VdRegionsViewer.onPropertyChanged() property is null")}setData(t,e){console.debug("Bio: VdRegionsViewer.setData()"),this.viewPromise=this.viewPromise.then((()=>__awaiter(this,void 0,void 0,(function*(){this.viewed&&(yield this.destroyView("setData"),this.viewed=!1)})))),this.regions=e,this.dataFrame=t,this.viewPromise=this.viewPromise.then((()=>__awaiter(this,void 0,void 0,(function*(){this.viewed||(yield this.buildView("setData"),this.viewed=!0)}))))}detach(){const t=super.detach.bind(this);this.viewPromise=this.viewPromise.then((()=>__awaiter(this,void 0,void 0,(function*(){this.viewed&&(yield this.destroyView("detach"),this.viewed=!1),t()}))))}destroyView(t){return __awaiter(this,void 0,void 0,(function*(){console.debug(`Bio: VdRegionsViewer.destroyView( mainLayout = ${this.mainLayout?"value":"none"} ), purpose = '${t}'`),this.filterSourceInput&&ui.empty(this.filterSourceInput.root),null!=this.mainLayout&&(this.mainLayout.remove(),this.host.remove(),this.host=null,this.mainLayout=null);for(const t of this.viewSubs)t.unsubscribe()}))}buildView(t){return __awaiter(this,void 0,void 0,(function*(){console.debug(`Bio: VdRegionsViewer.buildView() begin, purpose = '${t}'`);const e=this.regions.filter((t=>this.regionTypes.includes(t.type))),n=Array.from(new Set(e.map((t=>t.order)))).sort();this.logos=[];for(let t=0;t<n.length;t++){const i={};for(const o of this.chains){const s=e.find((e=>e.order==n[t]&&e.chain==o));i[o]=yield this.dataFrame.plot.fromType("WebLogo",{sequenceColumnName:s.sequenceColumnName,startPositionName:s.positionStartName,endPositionName:s.positionEndName,fixWidth:!0,skipEmptyPositions:this.skipEmptyPositions,positionWidth:this.positionWidth,positionHeight:this.positionHeight})}this.logos[t]=i}this.mainLayout=ui.table(this.chains,(t=>[...n.length>0?[ui.div(t,{style:{transform:"rotate(-90deg)",font:"12px Roboto, Roboto Local, sans-serif",textAlign:"center",width:"16px",marginTop:"24px",marginLeft:"6px"}})]:[],...[...Array(n.length).keys()].map((e=>{const n=this.logos[e][t];return n.root.style.height="100%",ui.div([n.root],{style:{marginTop:"4px",marginBottom:"4px"}})}))]),["",...[...Array(n.length).keys()].map((t=>e.find((e=>e.order==n[t]&&e.chain==this.chains[0])).name||"Name"))]),this.mainLayout.className="mlb-vd-regions-viewer-table2",this.filterSourceInput=ui.boolInput("",!1,this.filterSourceInputOnValueChanged.bind(this)),this.filterSourceInput.root.style.position="absolute",this.filterSourceInput.root.style.left="10px",this.filterSourceInput.root.style.top="-3px",ui.tooltip.bind(this.filterSourceInput.root,"Check to filter sequences for selected VRs"),Math.ceil(255*Math.random()).toString(16),this.host=ui.div([this.mainLayout,this.filterSourceInput.root],{}),this.root.appendChild(this.host),this.root.style.overflowX="auto",this.calcSize(),console.debug("Bio: VdRegionsViewer.buildView() end")}))}calcSize(){const t=(this.root.clientHeight-54)/this.chains.length,e=Math.min(t,Math.max(...this.logos.map((t=>Math.max(...Object.values(t).map((t=>t.maxHeight)))))));for(let t=0;t<this.logos.length;t++)for(let n=0;n<this.chains.length;n++){const i=this.chains[n];this.logos[t][i].root.style.height=`${e}px`}}rootOnSizeChanged(t){this.calcSize()}rootOnMouseMove(t){}filterSourceInputOnValueChanged(){const t=1==this.filterSourceInput.value?FilterSources.Selected:FilterSources.Filtered;for(let e=0;e<this.logos.length;e++)for(let n=0;n<this.chains.length;n++){const i=this.chains[n];this.logos[e][i].setOptions({[wlPROPS.filterSource]:t})}}}var M=n(6098),E=n(850),A=n(7983),R=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};function P(t){return R(this,void 0,void 0,(function*(){return t.seqCol.version!==t.seqCol.temp["last-invalidated-version"]&&(yield(0,A.HV)(t.seqCol,!1)),yield i.functions.call("Chem:getChemSpaceEmbeddings",{col:t.seqCol.temp["monomeric-mols"],methodName:t.methodName,similarityMetric:t.similarityMetric,xAxis:t.embedAxesNames[0],yAxis:t.embedAxesNames[1],options:t.options})}))}function N(t){const e=["Embed_X","Embed_Y"],n=t.columns.names().filter((t=>t.includes(e[0]))).length+1;return e.map((t=>`${t}_${n}`))}function x(t){return 1/(1+t)}function L(t){return 1/t-1}var G=n(3379),_=n.n(G),I=n(7795),W=n.n(I),F=n(569),k=n.n(F),D=n(3565),H=n.n(D),V=n(9216),O=n.n(V),Y=n(4589),U=n.n(Y),B=n(9414),Z={};Z.styleTagTransform=U(),Z.setAttributes=H(),Z.insert=k().bind(null,"head"),Z.domAPI=W(),Z.insertStyleElement=O(),_()(B.Z,Z),B.Z&&B.Z.locals&&B.Z.locals;var K=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};const $=new b.Subject,z=["Levenshtein"],X="act_diff",q="sali",j="sim",J="line_index",Q=["1_seq","2_seq"],tt="filterCliffs";function et(t,e){const n=s.BitSet.create(t.rowCount),i=t.col(e).getRawData();for(let t=0;t<i.length;t++)n.set(t,!!i[t],!1);return n}function nt(t,e,n){const i=e.getBoundingClientRect(),o=t.clientX-i.left,s=t.clientY-i.top;let r=null,a=0;for(const t of n){const e=Math.abs(Math.hypot(t.a[0]-o,t.a[1]-s)+Math.hypot(t.b[0]-o,t.b[1]-s)-Math.hypot(t.a[0]-t.b[0],t.a[1]-t.b[1]));(!a&&e<2||e<a)&&(a=e,r=t)}return r}const it=new Uint32Array(65536);var ot,st,rt,at,lt=n(3979);(at=ot||(ot={})).Levenshtein="Levenshtein",at.JaroWinkler="Jaro-Winkler",at.Manhattan="Manhattan",function(t){t.Euclidean="Euclidean"}(st||(st={})),function(t){t.Tanimoto="Tanimoto",t.Dice="Dice",t.Asymmetric="Asymmetric",t.BraunBlanquet="Braun-Blanquet",t.Cosine="Cosine",t.Kulczynski="Kulczynski",t.McConnaughey="Mc-Connaughey",t.RogotGoldberg="Rogot-Goldberg",t.Russel="Russel",t.Sokal="Sokal",t.Hamming="Hamming",t.Euclidean="Euclidean"}(rt||(rt={}));const ht={[st.Euclidean]:E.dP},ut={[ot.Levenshtein]:(t,e)=>{if(t.length<e.length){const n=e;e=t,t=n}return 0===e.length?t.length:t.length<=32?((t,e)=>{const n=t.length,i=e.length,o=1<<n-1;let s=-1,r=0,a=n,l=n;for(;l--;)it[t.charCodeAt(l)]|=1<<l;for(l=0;l<i;l++){let t=it[e.charCodeAt(l)];const n=t|r;t|=(t&s)+s^s,r|=~(t|s),s&=t,r&o&&a++,s&o&&a--,r=r<<1|1,s=s<<1|~(n|r),r&=n}for(l=n;l--;)it[t.charCodeAt(l)]=0;return a})(t,e):((t,e)=>{const n=e.length,i=t.length,o=[],s=[],r=Math.ceil(n/32),a=Math.ceil(i/32);for(let t=0;t<r;t++)s[t]=-1,o[t]=0;let l=0;for(;l<a-1;l++){let r=0,a=-1;const h=32*l,u=Math.min(32,i)+h;for(let e=h;e<u;e++)it[t.charCodeAt(e)]|=1<<e;for(let t=0;t<n;t++){const n=it[e.charCodeAt(t)],i=s[t/32|0]>>>t&1,l=o[t/32|0]>>>t&1,h=n|r,u=((n|l)&a)+a^a|n|l;let c=r|~(u|a),d=a&u;c>>>31^i&&(s[t/32|0]^=1<<t),d>>>31^l&&(o[t/32|0]^=1<<t),c=c<<1|i,d=d<<1|l,a=d|~(h|c),r=c&h}for(let e=h;e<u;e++)it[t.charCodeAt(e)]=0}let h=0,u=-1;const c=32*l,d=Math.min(32,i-c)+c;for(let e=c;e<d;e++)it[t.charCodeAt(e)]|=1<<e;let f=i;for(let t=0;t<n;t++){const n=it[e.charCodeAt(t)],r=s[t/32|0]>>>t&1,a=o[t/32|0]>>>t&1,l=n|h,c=((n|a)&u)+u^u|n|a;let d=h|~(c|u),m=u&c;f+=d>>>i-1&1,f-=m>>>i-1&1,d>>>31^r&&(s[t/32|0]^=1<<t),m>>>31^a&&(o[t/32|0]^=1<<t),d=d<<1|r,m=m<<1|a,u=m|~(l|d),h=d&l}for(let e=c;e<d;e++)it[t.charCodeAt(e)]=0;return f})(t,e)},[ot.JaroWinkler]:lt.H$,[ot.Manhattan]:function(t,e){if(t.length!==e.length)return 1;{let n=0;for(let i=1;i<t.length;i++)n+=t[i]==e[i]?0:1;return n/t.length}}},ct={[rt.Tanimoto]:function(t,e){return L(function(t,e){const n=t.trueCount()+e.trueCount();if(0==n)return 1;const i=t.andWithCountBits(e,!0);return i/(n-i)}(t,e))},[rt.Dice]:function(t,e){return L(function(t,e){const n=t.trueCount()+e.trueCount();return 0==n?0:2*t.andWithCountBits(e,!0)/n}(t,e))},[rt.Asymmetric]:function(t,e){return L(function(t,e){const n=Math.min(t.trueCount(),e.trueCount());return 0==n?0:t.andWithCountBits(e,!0)/n}(t,e))},[rt.BraunBlanquet]:function(t,e){return L(function(t,e){const n=Math.max(t.trueCount(),e.trueCount());return 0==n?0:t.andWithCountBits(e,!0)/n}(t,e))},[rt.Cosine]:function(t,e){return L(function(t,e){const n=t.trueCount()*e.trueCount();return 0==n?0:t.andWithCountBits(e,!0)/Math.sqrt(n)}(t,e))},[rt.Kulczynski]:function(t,e){return L(function(t,e){const n=t.trueCount()+e.trueCount(),i=t.trueCount()*e.trueCount();return 0==i?0:t.andWithCountBits(e,!0)*n/(2*i)}(t,e))},[rt.McConnaughey]:function(t,e){return L(function(t,e){const n=t.trueCount()+e.trueCount(),i=t.trueCount()*e.trueCount();return 0==i?0:(t.andWithCountBits(e,!0)*n-i)/i}(t,e))},[rt.RogotGoldberg]:function(t,e){return L(function(t,e){const n=t.andWithCountBits(e,!0),i=t.countBits(!0)+e.countBits(!0),o=t.length,s=o-i+n;return n==o||s==o?1:n/i+s/(2*o-i)}(t,e))},[rt.Russel]:function(t,e){return L(function(t,e){return 0==t.length?0:t.andWithCountBits(e,!0)/t.length}(t,e))},[rt.Sokal]:function(t,e){return L(function(t,e){const n=t.trueCount()+e.trueCount(),i=t.andWithCountBits(e,!0);return i/(2*n-3*i)}(t,e))},[rt.Hamming]:function(t,e){return t.trueCount()+e.trueCount()-2*t.andWithCountBits(e,!0)},[rt.Euclidean]:function(t,e){return Math.sqrt(t.trueCount()+e.trueCount()-2*t.andWithCountBits(e,!0))}};var dt,ft;(ft=dt||(dt={})).Vector="Vector",ft.String="String",ft.BitArray="BitArray";const mt={[dt.Vector]:{[st.Euclidean]:ht[st.Euclidean]},[dt.String]:{[ot.Levenshtein]:ut[ot.Levenshtein],[ot.JaroWinkler]:ut[ot.JaroWinkler],[ot.Manhattan]:ut[ot.Manhattan]},[dt.BitArray]:{[rt.Tanimoto]:ct[rt.Tanimoto],[rt.Dice]:ct[rt.Dice],[rt.Asymmetric]:ct[rt.Asymmetric],[rt.BraunBlanquet]:ct[rt.BraunBlanquet],[rt.Cosine]:ct[rt.Cosine],[rt.Kulczynski]:ct[rt.Kulczynski],[rt.McConnaughey]:ct[rt.McConnaughey],[rt.RogotGoldberg]:ct[rt.RogotGoldberg],[rt.Russel]:ct[rt.Russel],[rt.Sokal]:ct[rt.Sokal]}};Object.keys(mt).reduce(((t,e)=>{for(const n of Object.keys(mt[e]))t[n]=e;return t}),{});var pt=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};function gt(t,e,n,o,r){return pt(this,void 0,void 0,(function*(){e.version!==e.temp["last-invalidated-version"]&&(yield(0,A.HV)(e,!1));const n=s.DataFrame.create(e.length);return n.columns.addNewString(o).init((t=>e.temp["monomeric-mols"].get(t))),yield i.functions.call("Chem:getChemSimilaritiesMatrix",{dim:t,col:e.temp["monomeric-mols"],df:n,colName:o,simArr:r})}))}function vt(t){const e=o.divH([]),n=o.divV([o.divText(t.seqCol.name),o.divText(t.activityCol.name)]);return n.style.fontWeight="bold",n.style.display="flex",n.style.justifyContent="space-between",e.append(n),t.line.mols.forEach(((n,i)=>{const s=o.divText(t.activityCol.get(n).toFixed(2));s.style.display="flex",s.style.justifyContent="left",s.style.paddingLeft="30px",e.append(o.divV([o.divText(t.seqCol.get(n)),s]))})),e}function yt(t){const e=o.div();e.append(o.divText(t.seqCol.name,{style:{fontWeight:"bold"}}));const n=new Array(2),i=new Array(2);t.line.mols.forEach(((e,o)=>{n[o]=t.seqCol.get(e),i[o]=t.activityCol.get(e)}));const a={},l=t.seqCol.getTag(s.TAGS.UNITS),h=t.seqCol.getTag("separator"),u=(0,r.vU)(l,h),c=function(t,e,n,i){const o=document.createElement("canvas"),s=o.getContext("2d");return o.height=30,g(s,0,0,0,30,t,e,n,!0,i),o}(u(n[0]),u(n[1]),l,a);return e.append(o.div(c,{style:{width:"300px",overflow:"scroll"}})),e.append(function(t){const e=o.div();if(Object.keys(t).length>0){const n=o.divV([]);n.append(o.divH([o.divText("Pos",{style:{fontWeight:"bold",width:"30px",borderBottom:"1px solid"}}),o.divText("Difference",{style:{fontWeight:"bold",borderBottom:"1px solid"}})]));for(const e of Object.keys(t))t[e].style.borderBottom="1px solid lightgray",n.append(o.divH([o.divText((parseInt(e)+1).toString(),{style:{width:"30px",borderBottom:"1px solid lightgray"}}),t[e]]));e.append(n)}return e}(a)),e.append(wt("Activity delta",Math.abs(i[0]-i[1]))),e.append(wt("Cliff",t.sali)),e}function wt(t,e){return o.divH([o.divText(`${t}: `,{style:{fontWeight:"bold",paddingRight:"5px"}}),o.divText(e.toFixed(2))],{style:{paddingTop:"10px"}})}function bt(t,e){const n=s.Column.string("seq_diff",t.rowCount).init((n=>`${t.get(e[0],n)}#${t.get(e[1],n)}`));n.semType="MacromoleculeDifference",n.setTag(s.TAGS.UNITS,t.col(e[0]).getTag(s.TAGS.UNITS)),n.setTag("separator",t.col(e[0]).getTag("separator")),t.columns.add(n);const i=t.plot.grid();return i.col(e[0]).visible=!1,i.col(e[1]).visible=!1,i}n(1047),n(4004),n(7228),n(7767);var Ct=n(5226);n(9133);class St extends s.JsViewer{constructor(t){super(),this.name="",this.metricsProperties=["distanceMetric","fingerprint"],this.fingerprintChoices=["Morgan","Pattern"],this.initialized=!1,this.tags=[DG.TAGS.UNITS,"aligned","separator","alphabet"],this.fingerprint=this.string("fingerprint",this.fingerprintChoices[0],{choices:this.fingerprintChoices}),this.limit=this.int("limit",10),this.distanceMetric=this.string("distanceMetric",CHEM_SIMILARITY_METRICS[0],{choices:CHEM_SIMILARITY_METRICS}),this.moleculeColumnName=this.string("moleculeColumnName"),this.name=t}init(){this.initialized=!0}detach(){this.subs.forEach((t=>t.unsubscribe()))}onTableAttached(){return sequence_search_base_viewer_awaiter(this,void 0,void 0,(function*(){if(this.init(),this.dataFrame){this.subs.push(DG.debounce(this.dataFrame.onRowsRemoved,50).subscribe((t=>sequence_search_base_viewer_awaiter(this,void 0,void 0,(function*(){return yield this.render()})))));const t="diversity"!==this.name;this.subs.push(DG.debounce(this.dataFrame.onCurrentRowChanged,50).subscribe((e=>sequence_search_base_viewer_awaiter(this,void 0,void 0,(function*(){return yield this.render(t)}))))),this.subs.push(DG.debounce(this.dataFrame.selection.onChanged,50).subscribe((t=>sequence_search_base_viewer_awaiter(this,void 0,void 0,(function*(){return yield this.render(!1)}))))),this.subs.push(DG.debounce(ui.onSizeChanged(this.root),50).subscribe((t=>sequence_search_base_viewer_awaiter(this,void 0,void 0,(function*(){return yield this.render(!1)}))))),this.moleculeColumn=this.dataFrame.columns.bySemType(DG.SEMTYPE.MACROMOLECULE),this.moleculeColumnName=(this.moleculeColumn,void 0),this.getProperty("limit").fromOptions({min:1,max:this.dataFrame.rowCount})}yield this.render()}))}onPropertyChanged(t){if(super.onPropertyChanged(t),this.initialized){if("moleculeColumnName"===t.name){const e=this.dataFrame.col(t.get(this));e.semType===DG.SEMTYPE.MACROMOLECULE&&(this.moleculeColumn=e)}this.render()}}render(t=!0){return sequence_search_base_viewer_awaiter(this,void 0,void 0,(function*(){}))}beforeRender(){return!(!this.initialized||this.dataFrame&&this.moleculeColumnName&&this.dataFrame.col(this.moleculeColumnName).semType!==DG.SEMTYPE.MACROMOLECULE&&(grok.shell.error(`${this.moleculeColumnName} is not Macromolecule type`),1))}}n(7241);var Tt=n(4293);n(9943),n(4413);var Mt,Et=n(1061),At=n(8341),Rt=n(499),Pt=(n(1345),n(4221),n(7659),n(3659),n(4588));class Nt{constructor(t){var e,n,i,o,s,r,a;this.steps=null!==(e=null==t?void 0:t.steps)&&void 0!==e?e:0,this.cycles=null!==(n=null==t?void 0:t.cycles)&&void 0!==n?n:1e6,this.cutoff=null!==(i=null==t?void 0:t.cutoff)&&void 0!==i?i:0,this.lambda=null!==(o=null==t?void 0:t.lambda)&&void 0!==o?o:2,this.dlambda=null!==(s=null==t?void 0:t.dlambda)&&void 0!==s?s:.01,this.lambda2=this.lambda/2,this.dlambda2=this.dlambda/2,this.epsilon=null!==(r=null==t?void 0:t.epsilon)&&void 0!==r?r:1e-10,this.distanceFunction=null!==(a=null==t?void 0:t.distance)&&void 0!==a?a:E.dP,this.distance=[]}initDistance(t){this.distance=(0,E.H3)(t,this.distanceFunction)}calcDistance(t,e,n){return this.distance[e][n]}embed(t){const e=t.length,n=(0,E.kO)(e,Nt.dimension,40);let i=this.lambda2;0==this.steps&&(this.steps=t.length-1),this.initDistance(t);for(let o=0;o<this.cycles;++o){for(let o=0;o<this.steps;++o){const o=(0,Pt.I)(e);let s=(0,Pt.I)(e);for(;o==s;)s=(0,Pt.I)(e);const r=n[o],a=n[s],l=this.calcDistance(t,o,s),h=(0,E.dP)(r,a);if(0==this.cutoff||l<=this.cutoff||h<l){const t=i*(l-h)/(h+this.epsilon),e=(0,E.On)(r,a,-1);n[o]=(0,E.On)(r,e,t),n[s]=(0,E.On)(a,e,-t)}}if(i-=this.dlambda2,i<=0)break}return n}}Nt.dimension=2;class xt{constructor(t,e=!1){if(this._length=0,this._version=0,this._updateLevel=0,this._selectedCount=0,this._selectedCountVersion=-1,this._selectedIndexesVersion=-1,this._versionedName="",this._versionedNameVersion=-1,this.SHRINK_THRESHOLD=256,"number"==typeof t){const n=t,i=xt._createBuffer(n);if(e)for(let t=0;t<i.length;t++)i[t]=-1;this._data=i,this._length=n}else{if(!(t instanceof Uint32Array))throw new Error("Invalid constructor");this._data=t,this._length=e}}getRawData(){return this._data}assureGoez(t,e){if(t<0)throw new Error(`${e} should be greater than zero`)}assureInRange(t,e,n,i){if(t<e||t>n)throw new Error(`Argument ${i} (${t}) out of range (${e}, ${n})`)}copy(t,e,n){for(let i=0;i<n;i++)e[i]=t[i]}copyFrom(t){if(this._length!=t._length)throw new Error(`Lengths differ (${this._length} != ${t._length})`);this.copy(t._data,this._data,this.lengthInInts),this._version++}get length(){return this._length}get buffer(){return this._data}set buffer(t){this._data=t,this._version++}get version(){return this._version}set version(t){this._version=t}incrementVersion(t=!0){this._version++}get lengthInInts(){return Math.floor((this._length+31)/32)}get versionedName(){return this._version==this._versionedNameVersion?this._versionedName:""}set versionedName(t){this._versionedName=t,this._versionedNameVersion=this._version}get self(){return this}setLength(t){if(t<0)throw new Error("should be >= 0");if(t==this._length)return;const e=Math.floor((t+31)/32);if(e>this._data.length||e+this.SHRINK_THRESHOLD<this._data.length){const t=new Uint32Array(e);this.copy(this._data,t,e>this._data.length?this._data.length:e),this._data=t}t>this._length&&(this._length%32>0&&(this._data[this.lengthInInts-1]&=(1<<(this._length%32&31))-1),this._data.fill(0,this.lengthInInts,e)),this._length=t,this._version++}static fromAnd(t,e){if(t._length!=e._length)throw new Error(`Lengths differ (${t._length} != ${e._length})`);const n=new xt(t._length);n._length=t._length,n._data=xt._createBuffer(n._length),n._version=0;const i=t.lengthInInts;for(let o=0;o<i;o++)n._data[o]=t._data[o]&e._data[o];return n}static _createBuffer(t){return new Uint32Array(Math.floor((t+31)/32))}static fromValues(t){const e=new xt(t.length);e._version=0;for(let n=0;n<e._length;n++)t[n]&&(e._data[Math.floor(n/32)]|=1<<(n%32&31));return e}static fromSeq(t,e){const n=new xt(t);for(let i=0;i<t;++i)n.setBit(i,e(i));return n._version=0,n}static fromString(t){return xt.fromSeq(t.length,(e=>"1"==t.charAt(e)))}static fromUint32Array(t,e){const n=new xt(t);return n._data=e,n}static fromBytes(t){const e=t.length,n=new xt(8*e);n._data=new Uint32Array(Math.floor((e+3)/4)),n._length=8*e;let i=0,o=0;for(;e-o>=4;)n._data[i++]=255&t[o]|(255&t[o+1])<<8|(255&t[o+2])<<16|(255&t[o+3])<<24,o+=4;return e-o==3&&(n._data[i]=(255&t[o+2])<<16),e-o==2&&(n._data[i]|=(255&t[o+1])<<8),e-o==1&&(n._data[i]|=255&t[o]),n._version=0,n}toString(){return`${this._length} bits, ${this.countBits(!0)} set`}equals(t){if(this==t)return!0;if(null==t)return!1;if(this._length!=t._length)return!1;if(0==this._length)return!0;for(let e=0;e<this._data.length-1;e++)if(this._data[e]!=t._data[e])return!1;for(let e=8*(this._data.length-1);e<this._length;e++)if(this.getBit(e)!=t.getBit(e))return!1;return!0}clone(){const t=new xt(0,!1);return t._data=Uint32Array.from(this._data),t._length=this._length,t._version=this._version,t}init(t,e){this.setAll(!1,!1);for(let e=0;e<this._length;e++)t(e)&&(this._data[Math.floor(e/32)]|=1<<(e%32&31));return this.incrementVersion(e),this}invert(t=!0){for(let t=0;t<this._data.length;t++)this._data[t]^=-1;this.incrementVersion(t)}setAll(t,e=!1){const n=t?-1:0,i=this.lengthInInts;for(let t=0;t<i;t++)this._data[t]=n;this.incrementVersion(e)}setIndexes(t,e=!0,n=!0,i=!0){n&&this.setAll(!e,!1);for(const n of t)this.setFast(n,e);this.incrementVersion(i)}everyIndex(t,e=!0){for(const n of t)if(this.getBit(n)!=e)return!1;return!0}anyIndex(t,e=!0){for(const n of t)if(this.getBit(n)==e)return!0;return!1}setWhere(t,e=!0,n=!0,i=!0,o=!0){if(n&&o&&this.setAll(!e,!1),o)for(let n=0;n<this._length;n++)t(n)&&this.setFast(n,e);else for(let n=0;n<this._length;n++)this.setFast(n,t(n)?e:!e);this.incrementVersion(i)}getRange(t,e){this.assureInRange(t,0,this._length-1,"from"),this.assureInRange(e,0,this._length,"to");const n=[];for(let i=t;i<e;++i)n.push(this.getBit(i));return xt.fromValues(n)}getRangeAsList(t,e){this.assureInRange(t,0,this._length-1,"from"),this.assureInRange(e,0,this._length,"to");const n=[];for(let i=t;i<e;++i)n.push(this.getBit(i));return n}setRange(t,e,n,i=!0){this.assureInRange(t,0,this._length-1,"from"),this.assureInRange(e,0,this._length-1,"to");const o=Math.min(t,e),s=Math.max(t,e);if(n)for(let t=o;t<=s;t++)this.setTrue(t);else for(let t=o;t<=s;t++)this.setFalse(t);return this.incrementVersion(i),this}setRandom(t,e,n=!0){if(t<0||t>this._length)throw new Error("n must be >= 0 && <= Count");t>this._length/2&&this.setRandom(this._length-t,!e),this.setAll(!e);for(let n=0;n<t;){const t=Math.floor(Math.random()*this._length);this.getBit(t)!=e&&(this.setFast(t,e),n++)}this.incrementVersion(n)}and(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");for(let e=0,n=this.lengthInInts;e<n;e++)this._data[e]&=t._data[e];return this.incrementVersion(e),this}andNot(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");const n=this.lengthInInts;for(let e=0;e<n;e++)this._data[e]&=~t._data[e];return this.incrementVersion(e),this}notAnd(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");for(let e=0,n=this.lengthInInts;e<n;e++)this._data[e]=~this._data[e]&t._data[e];return this.incrementVersion(e),this}not(t=!0){for(let t=0,e=this.lengthInInts;t<e;t++)this._data[t]=~this._data[t];return this.incrementVersion(t),this}or(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");for(let e=0,n=this.lengthInInts;e<n;e++)this._data[e]|=t._data[e];return this.incrementVersion(e),this}xor(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");for(let e=0,n=this.lengthInInts;e<n;e++)this._data[e]^=t._data[e];return this.incrementVersion(e),this}insertAt(t,e,n=!1){if(this.assureInRange(t,0,this._length,"pos"),0==e)return;const i=this._length;this.setLength(this._length+e);for(let n=i-1;n>=t;n--)this.setBit(n+e,this.getBit(n));for(let i=t;i<t+e;i++)this.setBit(i,n)}removeAt(t,e=1){if(e<0)throw new Error("n cannot be negative");if(this.assureInRange(t,0,this._length-e,"pos"),this.contains(!0))for(let n=t;n<this._length-e;n++)this.setBit(n,this.getBit(n+e));this.setLength(this._length-e)}removeByMask(t,e=!0){if(this._length!=t.length)throw new Error("length != mask.length");if(t==this)this.setLength(t.countBits(!e)),this.setAll(!e);else{let n=0;for(let i=-1;-1!=(i=t.findNext(i,!e));)this.setFast(n++,this.getBit(i));this._length=n,this._version++}return this}getBit(t){return 0!=(this._data[Math.floor(t/32)]&1<<(31&t))}setBit(t,e,n=!0){this.setFast(t,e),this._version++}setFast(t,e){e?this._data[Math.floor(t/32)]|=1<<(31&t):this._data[Math.floor(t/32)]&=~(1<<(31&t))}setTrue(t){this._data[Math.floor(t/32)]|=1<<(31&t)}setFalse(t){this._data[Math.floor(t/32)]&=~(1<<(31&t))}trueCount(){return this.countBits(!0)}falseCount(){return this.countBits(!1)}countBits(t){if(0==this._length)return 0;if(this._selectedCountVersion!=this._version){this._selectedCount=0;const t=this.lengthInInts;let e=0;for(;e<t-1;e++)for(let t=this._data[e];0!=t;t>>>=8)this._selectedCount+=xt._onBitCount[255&t];let n=this._data[e];const i=31&this._length;for(0!=i&&(n&=~(4294967295<<i));0!=n;n>>>=8)this._selectedCount+=xt._onBitCount[255&n];this._selectedCountVersion=this._version}return t?this._selectedCount:this._length-this._selectedCount}countWhere(t){let e=0;if(this.trueCount()==this._length)for(let n=0;n<this._length;n++)e+=t(n)?1:0;else for(let n=-1;-1!=(n=this.findNext(n,!0));)e+=t(n)?1:0;return e}andWithCountBits(t,e){if(0==this._length)return 0;let n=0;const i=this.lengthInInts;let o=0;for(;o<i-1;o++)for(let e=this._data[o]&t._data[o];0!=e;e>>>=8)n+=xt._onBitCount[255&e];let s=this._data[o]&t._data[o];const r=31&this._length;for(0!=r&&(s&=~(4294967295<<r));0!=s;s>>>=8)n+=xt._onBitCount[255&s];return e?n:this._length-n}clear(){this.setLength(0)}contains(t){return this.findNext(-1,t)>=0}get allTrue(){return this.countBits(!0)==this._length}get allFalse(){return this.countBits(!1)==this._length}get anyTrue(){return this.countBits(!0)>0}get anyFalse(){return this.countBits(!1)>0}findNext(t,e=!0){if(this.assureInRange(t,-1,this._length,"index"),t>=this._length-1)return-1;let n=31&(t=t<0?0:t+1);const i=this.lengthInInts;for(let o=Math.floor(t/32);o<i;o++){let i=e?this._data[o]:~this._data[o];if(0!=n)i&=4294967295<<n&4294967295,n=0;else if(!e&&-4294967296==i)continue;for(let e=0;0!=i;e+=8,i>>>=8){const n=xt._firstOnBit[255&i];if(n>=0)return(t=n+32*o+e)>=this._length?-1:t}}return-1}findPrev(t,e=!0){if(0==t)return-1;this.assureInRange(t,-1,this._length,"index");let n=1+(t=t<0?this._length-1:t-1)&31;for(let i=Math.floor(t/32);i>=0;i--){let t=e?this._data[i]:~this._data[i];0!=n&&(t&=~(4294967295<<n),n=0);for(let e=24;0!=t;e-=8,t<<=8){const n=xt._lastOnBit[t>>>24];if(n>=0)return n+32*i+e}}return-1}}xt._onBitCount=Int8Array.from([0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,4,5,5,6,5,6,6,7,5,6,6,7,6,7,7,8]),xt._firstOnBit=Int8Array.from([-1,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,7,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0]),xt._lastOnBit=Int8Array.from([-1,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7]),s.SEMTYPE.MOLECULE,s.SEMTYPE.MACROMOLECULE,function(t){t.X="Embed_X",t.Y="Embed_Y"}(Mt||(Mt={})),n(3336);var Lt=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};function Gt(t,e,n=[],o=[],s=!0){const[r,a]=_t(t,e,n,o);return s&&!r&&i.shell.warning(a),r}function _t(t,e,n=[],o=[]){let r=!0,a="";const l=new Rt.C(t);if(t.semType!==s.SEMTYPE.MACROMOLECULE)i.shell.warning(e+" analysis is allowed for Macromolecules semantic type"),r=!1;else{const t=l.notation;if(n.length>0&&!n.some((e=>t.toUpperCase()==e.toUpperCase())))a=`${e} + ' analysis is allowed for Macromolecules with notation ${0==n.length?"any notation":`notation${n.length>1?"s":""} ${n.map((t=>`"${t}"`)).join(", ")} `}.`,r=!1;else if(!l.isHelm()){const t=l.alphabet;o.length>0&&!o.some((e=>t.toUpperCase()==e.toUpperCase()))&&(a=`${e} + ' analysis is allowed for Macromolecules with alphabet ${0==o.length?"any alphabet":`alphabet${o.length>1?"s":""} ${o.map((t=>`"${t}"`)).join(", ")}.`}.`,r=!1)}}return[r,a]}function It(t,e,r,a,l,h){return Lt(this,void 0,void 0,(function*(){if(!Gt(e,"Activity Cliffs"))return;const u=N(t),c={units:e.getTag(s.TAGS.UNITS),aligned:e.getTag("aligned"),separator:e.getTag("separator"),alphabet:e.getTag("alphabet")};return yield function(t,e,r,a,l,h,u,c,d,f,m,p,g,v,y,w,b){return K(this,void 0,void 0,(function*(){const C=u/100,S=null!=r?r:e;let T=!1,M=!1;const E={};let A,R;const P={seqCol:S,methodName:d,similarityMetric:c,embedAxesNames:a,options:b},{distance:N,coordinates:L}=yield p(P);for(const e of L)t.columns.add(e);const G=yield function(t,e,n,i){return K(this,void 0,void 0,(function*(){const o=t.categories,r=t.getRawData(),a=s.Column.string("seq",t.length).init((t=>o[r[t]])),l=s.DataFrame.fromColumns([a]),h=t.length;let u=Array(h-1);return n?u=yield i(h,t,l,"seq",u):function(t,e,n){for(let i=0;i<t-1;++i){const o=new Float32Array(t-i-1).fill(0);for(let n=i+1;n<t;++n)o[n-i-1]=e[i][n]===s.FLOAT_NULL?0:x(e[i][n]);n[i]=s.Column.fromFloat32Array("similarity",o)}}(h,e,u),u}))}(S,N,!N||z.includes(c),g),_=function(t,e,n){const i=[],o=[],s=[],r=[],a=new Set;for(let l=0;l!=t.length;++l)for(let h=0;h!=t.length-l;++h){const u=t[l]?t[l].get(h):0;if(u>=e){s.push(l),r.push(l+h+1),a.add(l),a.add(l+h+1),i.push(u);const t=Math.abs(n.get(l)-n.get(l+h+1));1!=u?o.push(t/(1-u)):o.push(1/0)}}return{simVals:i,saliVals:o,n1:s,n2:r,cliffsMolIds:a}}(G,C,h),I=function(t,e,n,i,o,r){const a=new Array(t).fill(0);for(let t=0;t!=n.length;++t)e[t]!=1/0&&(r.get(n[t])>r.get(i[t])?a[n[t]]+=e[t]:a[i[t]]+=e[t]);return s.Column.fromList("double",`sali_${o[0].substring(o[0].lastIndexOf("_"))}`,a)}(S.length,_.saliVals,_.n1,_.n2,a,h);t.columns.add(I);const W=function(t,e){const n="containsCliff",i=t.columns.names().filter((t=>t.includes(n))).length+1,o=`${n}_${i}`;return s.Column.bool(o,t.rowCount).init((t=>e.has(t)))}(t,_.cliffsMolIds);t.columns.add(W);const F=function(t){const e=t.filter((t=>t!==1/0)),n=Math.min(...e);return{max:Math.max(...e),min:n}}(_.saliVals),k=.8/(F.max-F.min),D=i.shell.getTableView(t.name);D.grid.columns.byName(W.name).visible=!1;const H=D.addViewer(s.VIEWER.SCATTER_PLOT,{xColumnName:a[0],yColumnName:a[1],size:I.name,color:h.name,showXSelector:!1,showYSelector:!1,showSizeSelector:!1,showColorSelector:!1,markerMinSize:5,markerMaxSize:25,title:l}),V=H.getInfo().canvas,O=function(t,e,n,i,o){const r=new Array(t.n1.length).fill(null);for(let e=0;e<t.n1.length;e++){const n=t.n1[e],i=t.n2[e];r[e]={id:e,mols:[n,i],selected:!1,a:[],b:[]}}const a=s.DataFrame.create(r.length);return Q.forEach(((t,n)=>{a.columns.addNewString(t).init((t=>e.get(r[t].mols[n]))),function(t,e){Object.keys(e).forEach((n=>{t.tags[n]=e[n]}))}(a.col(t),o),a.col(t).semType=i})),a.columns.addNewFloat(X).init((t=>Math.abs(n.get(r[t].mols[0])-n.get(r[t].mols[1])))),a.columns.addNewInt(J).init((t=>t)),a.columns.addNewFloat(q).init((e=>t.saliVals[e])),a.columns.addNewFloat(j).init((e=>t.simVals[e])),{lines:r,linesDf:a}}(_,e,h,f,m),Y=w?w(O.linesDf,Q).sort([q],[!1]):O.linesDf.plot.grid().sort([q],[!1]);t.temp[".cliffsDfGrid"]=Y;const U=o.button(`${O.linesDf.rowCount} cliffs`,(()=>{D.dockManager.dock(Y.root,"down",null,"Activity cliffs",.2)}));U.classList.add("scatter_plot_link","cliffs_grid"),H.root.append(U);const B=o.switchInput("Show only cliffs",!1,(()=>{B.value?(H.dataFrame.setTag(tt,W.name),t.filter.copyFrom(et(t,W.name)),$.next(W.name)):(H.dataFrame.setTag(tt,""),t.filter.setAll(!0,!0),$.next(""))}));B.root.classList.add("scatter_plot_link","show_only_cliffs"),H.root.append(B.root),$.subscribe((t=>{""!==t?t!==W.name&&(B.enabled=!1):B.enabled=!0}));const Z=i.events.onViewerClosed.subscribe((t=>{t.args.viewer===H&&(D.dockManager.close(Y.root),Z.unsubscribe(),D.subs=D.subs.filter((t=>t!==Z)))}));return D.subs.push(Z),O.linesDf.onCurrentCellChanged.subscribe((()=>{T=!0;const n=O.linesDf.currentCol&&O.linesDf.currentCol.name===Q[1]?1:0,s=-1!==O.linesDf.currentRowIdx?O.lines[O.linesDf.currentRowIdx]:null;H.dataFrame.currentRowIdx=s?s.mols[n]:-1,H.dataFrame.filter.set(0,!O.lines[0].selected),H.dataFrame.filter.set(0,O.lines[0].selected),s&&setTimeout((()=>{!function(t,e,n,s,r,a,l,h){const u=e.getPane("Cliff Details");o.empty(u.root);const c=h({cashedData:n,line:s,df:t,seqCol:r,activityCol:a,sali:l});u.root.append(c),setTimeout((()=>{i.shell.o=e.root}),500)}(t,A,E,s,e,h,O.linesDf.get(q,s.id),y);const n=H.dataFrame.getSortedOrder(D.grid.sortByColumns,D.grid.sortTypes);D.grid.scrollToCell(e.name,n.indexOf(H.dataFrame.currentRowIdx))}),1e3)})),O.linesDf.onSelectionChanged.subscribe((e=>{if(!1===O.linesDf.selection.anyTrue)O.lines.forEach((t=>{t.selected=!1}));else if(-1!==O.linesDf.mouseOverRowIdx){const t=O.lines[O.linesDf.mouseOverRowIdx];t.selected=!t.selected}setTimeout((()=>{const e=s.BitSet.create(t.rowCount);O.lines.forEach((t=>{t.selected&&t.mols.forEach((n=>{e.set(n,t.selected,!0)}))})),t.selection.copyFrom(e),D.grid.invalidate()}),300)})),t.onSelectionChanged.subscribe((e=>{M?M=!1:!1===t.selection.anyTrue&&"number"==typeof e&&(O.lines.forEach((t=>{t.selected=!1})),Y.dataFrame.selection.setAll(!1,!1),Y.invalidate())})),V.addEventListener("mousemove",(function(i){clearTimeout(R),R=n.g.setTimeout((function(){const n=nt(i,V,O.lines);n&&-1===t.mouseOverRowIdx&&o.tooltip.show(v({cashedData:E,line:n,df:t,seqCol:e,activityCol:h}),i.clientX,i.clientY)}),500)})),V.addEventListener("mousedown",(function(e){M=!0;const n=nt(e,V,O.lines);if(n&&-1===t.mouseOverRowIdx){e.ctrlKey?(n.selected=!n.selected,O.linesDf.selection.set(n.id,n.selected)):O.linesDf.currentRowIdx!==n.id&&(O.linesDf.currentRowIdx=n.id,t.currentRowIdx=n.mols[0],t.filter.set(0,!O.lines[0].selected),t.filter.set(0,O.lines[0].selected));const i=O.linesDf.getSortedOrder(Y.sortByColumns,Y.sortTypes);Y.scrollToCell(Q[0],i.indexOf(n.id))}})),H.onEvent("d4-before-draw-scene").subscribe((e=>{const n=function(t,e,n,i,o,s,r){const a=i.lines,l=t.getInfo().canvas.getContext("2d"),h=t.dataFrame.columns.byName(e),u=t.dataFrame.columns.byName(n);for(let e=0;e<a.length;e++){const n=t.worldToScreen(h.get(a[e].mols[0]),u.get(a[e].mols[0])),c=t.worldToScreen(h.get(a[e].mols[1]),u.get(a[e].mols[1]));a[e].a=[n.x,n.y],a[e].b=[c.x,c.y];const d=new Path2D;d.moveTo(a[e].a[0],a[e].a[1]);const f=a[e].selected?"255,255,0":"0,128,0",m=o[e]===1/0?1:.2+(o[e]-r)*s;l.strokeStyle=`rgba(${f},${m})`,l.lineWidth=a[e].id===i.linesDf.currentRowIdx?3:1,d.lineTo(a[e].b[0],a[e].b[1]),l.stroke(d)}return a}(H,a[0],a[1],O,_.saliVals,k,F.min);if(T){const t=n[O.linesDf.currentRowIdx];setTimeout((()=>{const{zoomLeft:e,zoomRight:n,zoomTop:i,zoomBottom:o}=function(t,e,n,i,o,s){const r=Math.abs(n-o),a=Math.abs(i-s),l=t/r,h=e/a,u=Math.min(l,h),c=t/u*5,d=e/u*5,f=(n<o?n:o)+r/2-c/2,m=(i>s?i:s)-a/2+d/2;return{zoomLeft:f,zoomRight:f+c,zoomTop:m,zoomBottom:m-d}}(H.viewport.width,H.viewport.height,H.dataFrame.get(a[0],t.mols[0]),H.dataFrame.get(a[1],t.mols[0]),H.dataFrame.get(a[0],t.mols[1]),H.dataFrame.get(a[1],t.mols[1]));H.zoom(e,i,n,o)}),300),T=!1}B.value?t.filter.copyFrom(et(t,W.name)):!0===B.enabled&&t.filter.setAll(!0,!1)})),H.addProperty("similarityLimit","double",C),A=function(){const t=o.accordion(),e=o.element("i");return e.className="grok-icon svg-icon svg-view-layout",t.addTitle(o.span([e,o.label("Activity cliffs")])),t.addPane("Cliff Details",(()=>o.divText("Cliff has not been selected")),!0),i.shell.o=t.root,t}(),H}))}(t,e,null,u,"Activity cliffs",r,a,"Tanimoto",l,s.SEMTYPE.MACROMOLECULE,c,P,gt,vt,yt,bt,h)}))}function Wt(t,e,n,o="Tanimoto",r,a){return Lt(this,void 0,void 0,(function*(){if(yield(0,Et.gw)(10),!Gt(e,"Sequence space"))return;const l=N(t),h=s.DataFrame.fromColumns([e]).clone(),u=function(t,e){const n=e.categories.map(((t,e)=>t?null:e)).filter((t=>null!==t)),i=[...e.getRawData()],o=[];let s=0;for(let e=0;e<t.rowCount;e++)n.includes(i[e])&&(t.rows.removeAt(e-s),o.push(e),s+=1);return o}(h,e),c={seqCol:h.col(e.name),methodName:n,similarityMetric:o,embedAxesNames:l,options:a},d=(yield P(c)).coordinates;for(const e of d){const n=e.toList();u.forEach((t=>n.splice(t,0,null))),t.columns.add(s.Column.float(e.name,t.rowCount).init((t=>n[t])))}return r?i.shell.tableView(t.name).scatterPlot({x:l[0],y:l[1],title:"Sequence space"}):void 0}))}function Ft(t=null){var e;const n=null!==(e=null==t?void 0:t.dataFrame)&&void 0!==e?e:i.shell.t,r=null!=t?t:n.columns.bySemType(s.SEMTYPE.MACROMOLECULE);if(null==r)return void i.shell.warning("MSAError: dataset doesn't conain any Macromolecule column");let a=()=>Lt(this,void 0,void 0,(function*(){return null}));const l=o.choiceInput("Method",At.J[0],At.J);l.setTooltip("Alignment method");const h=o.floatInput("Gap open",1.53);h.setTooltip("Gap opening penalty at group-to-group alignment");const u=o.floatInput("Gap extend",0);u.setTooltip("Gap extension penalty to skip the alignment");const c=[l.root.style,h.root.style,u.root.style],d=o.columnInput("Sequence",n,r,(()=>{const t=d.value,e=n.columns.getUnusedName(`msa(${t.name})`);if(Gt(t,t.name,["fasta"],["DNA","RNA","PT"],!1)){for(const t of c)t.display="none";a=()=>(0,M.U)(t,!1,e,f.value)}else if(Gt(t,t.name,["helm"],[],!1)){for(const t of c)t.display="initial";a=()=>(0,At.f)(t,e,l.value,h.value,u.value,f.value)}else{for(const t of c)t.display="none";a=()=>Lt(this,void 0,void 0,(function*(){return null}))}}));d.setTooltip("Sequences column to use for alignment"),d.fireChanged();const f=o.columnInput("Clusters",n,null);f.nullable=!0;let m=null;o.dialog("MSA").add(d).add(f).add(l).add(h).add(u).onOK((()=>Lt(this,void 0,void 0,(function*(){if(d.fireChanged(),m=yield a(),null==m)return i.shell.warning("Wrong column format");n.columns.add(m),yield i.data.detectSemanticTypes(n)})))).show()}function kt(t){return new Ct.i(t).importFasta()}function Dt(){const t=(0,Tt.m)(),e=function(t){const e=(0,r.Mj)(t),n=t=>{const e=a.columns.addNewString((t+1).toString());return i.push(e),e},i=[],o=t.length,a=s.DataFrame.create(o);for(let s=0;s<o;++s){const o=t.get(s);null!=o&&e(o).forEach(((t,e)=>{var o;((null!==(o=i[e])&&void 0!==o?o:null)||n(e)).set(s,t||"-",!1)}))}return a}(t),n=t.dataFrame;for(const i of e.columns){const e=n.columns.add(i);e.semType=u.Of.MONOMER,e.setTag(s.TAGS.CELL_RENDERER,u.Of.MONOMER),e.setTag("alphabet",t.getTag("alphabet"))}i.shell.tv.grid.invalidate()}function Ht(t){const e=(0,r.fy)(t,1,r.gP);return Object.keys(e.freq)}new s.Package},7983:(t,e,n)=>{"use strict";n.d(e,{HV:()=>u,QF:()=>h,pf:()=>l});var i=n(4469),o=(n(3870),n(976)),s=n(7241),r=(n(4293),n(1061)),a=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};function l(t,e,n){const i=n?function(t,e){const n=`${e}`.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),i=t.charAt(0)===e,o=t.charAt(t.length-1)===e,s=t.replace(new RegExp(`^${n}|${n}$`,"g"),"");return i?o?`${n}${s}${n}`:`${n}${s}${n}|${n}${s}$`:o?`^${s}${n}|${n}${s}${n}`:`^${s}${n}|${n}${s}${n}|${n}${s}$`}(t,n):t,s=o.BitSet.create(e.length);for(let n=0;n<e.length;n++){const o=e.get(n);(o.match(i)||o===t)&&s.set(n,!0,!1)}return s}function h(t,e){return a(this,void 0,void 0,(function*(){e.version!==e.temp["last-invalidated-version"]&&(yield u(e,!0));const n=o.Column.string("helm",1).init((e=>t));n.setTag(o.TAGS.UNITS,"helm");const r=yield(0,s.D)(n,!0,e.temp["monomers-dict"]);return(yield i.functions.call("Chem:searchSubstructure",{molStringsColumn:e.temp["monomeric-mols"],molString:r.get(0),molBlockFailover:""})).get(0)}))}function u(t,e){return a(this,void 0,void 0,(function*(){const n=o.TaskBarProgressIndicator.create(`Invalidating molfiles for ${t.name}`);yield(0,r.gw)(10);const i=new Map,a=yield(0,s.D)(t,e,i);t.temp["monomeric-mols"]=a,t.temp["monomers-dict"]=i,t.temp["last-invalidated-version"]=t.version,n.close()}))}},3553:(t,e,n)=>{"use strict";var i,o,s;n.d(e,{Of:()=>s,mU:()=>r,rs:()=>l}),function(t){t.SPLIT_COL="~split",t.ACTIVITY="~activity",t.ACTIVITY_SCALED="activity_scaled",t.ALIGNED_SEQUENCE="~aligned_sequence",t.AMINO_ACID_RESIDUE="AAR",t.POSITION="Pos",t.P_VALUE="pValue",t.MEAN_DIFFERENCE="Mean difference"}(i||(i={})),function(t){t.AAR="AAR",t.POSITION="Pos",t.SELECTION="selection"}(o||(o={})),function(t){t.MONOMER="Monomer",t.MACROMOLECULE_DIFFERENCE="MacromoleculeDifference",t.ACTIVITY="activity",t.ACTIVITY_SCALED="activityScaled"}(s||(s={}));const r="MSA";var a,l;!function(t){t.CELL_CHANGING="isCellChanging"}(a||(a={})),function(t){t.SEPARATOR="."}(l||(l={}))},4004:(t,e,n)=>{"use strict";n.d(e,{o:()=>r}),n(3870);var i=n(4469),o=(n(3336),n(7767)),s=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};function r(t,e,n){return s(this,void 0,void 0,(function*(){const s=new o.L(t).convert(e,n);t.dataFrame.columns.add(s);const r=yield i.functions.call("Bio:detectMacromolecule",{col:s});return r&&(s.semType=r),yield i.data.detectSemanticTypes(t.dataFrame),s}))}},1345:(t,e,n)=>{"use strict";n.d(e,{RV:()=>l,rb:()=>h});var i=n(976),o=n(4469),s=n(701),r=n(7228),a=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};const l="Libraries",h={"HELMCoreLibrary.json":"HELMCoreLibrary.json"};class u{constructor(t){this._monomers={},this._onChanged=new s.Subject,this._monomers=t}getMonomer(t,e){return t in this._monomers&&e in this._monomers[t]?this._monomers[t][e]:null}getTypes(){return Object.keys(this._monomers)}getMonomerMolsByType(t){const e={};return Object.keys(this._monomers[t]).forEach((n=>{e[n]=this._monomers[t][n].molfile})),e}getMonomerNamesByType(t){return Object.keys(this._monomers[t])}get onChanged(){return this._onChanged}_updateInt(t){const e=t.getTypes(),n=this.getTypes();e.forEach((e=>{n.includes(e)||(this._monomers[e]={}),t.getMonomerNamesByType(e).forEach((n=>{this._monomers[e][n]=t.getMonomer(e,n)}))}))}update(t){this._updateInt(t),this._onChanged.next()}updateLibs(t,e=!1){e&&(this._monomers={});for(const e of t)this._updateInt(e);this._onChanged.next()}clear(){this._monomers={},this._onChanged.next()}}class c{constructor(){this._monomerLib=new u({}),this.loadLibrariesPromise=Promise.resolve()}getBioLib(){return this._monomerLib}loadLibraries(t=!1){return a(this,void 0,void 0,(function*(){return this.loadLibrariesPromise=this.loadLibrariesPromise.then((()=>a(this,void 0,void 0,(function*(){const e=Object.keys(yield o.dapi.userDataStorage.get(l,!0)),n=yield Promise.all(e.map((t=>this.readLibrary("System:AppData/Bio/libraries/",t))));this._monomerLib.updateLibs(n,t)}))))}))}readLibrary(t,e){return a(this,void 0,void 0,(function*(){let n,s,a=[];const l=new i.FileSource(t);if(e.endsWith(".sdf"))1===i.Func.find({package:"Chem",name:"importSdf"}).length?(n=yield l.readAsBytes(e),s=yield o.functions.call("Chem:importSdf",{bytes:n}),a=(0,r.Xk)(s[0])):o.shell.warning("Chem package is not installed");else{const t=yield l.readAsText(e);a=JSON.parse(t)}const h={},c=[];return a.forEach((t=>{const e={symbol:t.symbol,name:t.name,naturalAnalog:t.naturalAnalog,molfile:t.molfile,rgroups:t.rgroups,polymerType:t.polymerType,monomerType:t.monomerType,data:{}};Object.keys(t).forEach((n=>{r.DC.includes(n)||(e.data[n]=t[n])})),c.includes(t.polymerType)||(h[t.polymerType]={},c.push(t.polymerType)),h[t.polymerType][t.symbol]=e})),new u(h)}))}static get instance(){return c._instance||(c._instance=new c),c._instance}}c._instance=null},6098:(t,e,n)=>{"use strict";n.d(e,{U:()=>I});var i=n(976),o=n(5226);const s=Symbol("Comlink.proxy"),r=Symbol("Comlink.endpoint"),a=Symbol("Comlink.releaseProxy"),l=Symbol("Comlink.thrown"),h=t=>"object"==typeof t&&null!==t||"function"==typeof t,u=new Map([["proxy",{canHandle:t=>h(t)&&t[s],serialize(t){const{port1:e,port2:n}=new MessageChannel;return c(t,e),[n,[n]]},deserialize:t=>(t.start(),f(t))}],["throw",{canHandle:t=>h(t)&&l in t,serialize({value:t}){let e;return e=t instanceof Error?{isError:!0,value:{message:t.message,name:t.name,stack:t.stack}}:{isError:!1,value:t},[e,[]]},deserialize(t){throw t.isError?Object.assign(new Error(t.value.message),t.value):t.value}}]]);function c(t,e=self){e.addEventListener("message",(function n(i){if(!i||!i.data)return;const{id:o,type:r,path:a}=Object.assign({path:[]},i.data),h=(i.data.argumentList||[]).map(b);let u;try{const e=a.slice(0,-1).reduce(((t,e)=>t[e]),t),n=a.reduce(((t,e)=>t[e]),t);switch(r){case"GET":u=n;break;case"SET":e[a.slice(-1)[0]]=b(i.data.value),u=!0;break;case"APPLY":u=n.apply(e,h);break;case"CONSTRUCT":u=function(t){return Object.assign(t,{[s]:!0})}(new n(...h));break;case"ENDPOINT":{const{port1:e,port2:n}=new MessageChannel;c(t,n),u=function(t,e){return y.set(t,e),t}(e,[e])}break;case"RELEASE":u=void 0;break;default:return}}catch(t){u={value:t,[l]:0}}Promise.resolve(u).catch((t=>({value:t,[l]:0}))).then((t=>{const[i,s]=w(t);e.postMessage(Object.assign(Object.assign({},i),{id:o}),s),"RELEASE"===r&&(e.removeEventListener("message",n),d(e))}))})),e.start&&e.start()}function d(t){(function(t){return"MessagePort"===t.constructor.name})(t)&&t.close()}function f(t,e){return p(t,[],e)}function m(t){if(t)throw new Error("Proxy has been released and is not useable")}function p(t,e=[],n=function(){}){let i=!1;const o=new Proxy(n,{get(n,s){if(m(i),s===a)return()=>C(t,{type:"RELEASE",path:e.map((t=>t.toString()))}).then((()=>{d(t),i=!0}));if("then"===s){if(0===e.length)return{then:()=>o};const n=C(t,{type:"GET",path:e.map((t=>t.toString()))}).then(b);return n.then.bind(n)}return p(t,[...e,s])},set(n,o,s){m(i);const[r,a]=w(s);return C(t,{type:"SET",path:[...e,o].map((t=>t.toString())),value:r},a).then(b)},apply(n,o,s){m(i);const a=e[e.length-1];if(a===r)return C(t,{type:"ENDPOINT"}).then(b);if("bind"===a)return p(t,e.slice(0,-1));const[l,h]=v(s);return C(t,{type:"APPLY",path:e.map((t=>t.toString())),argumentList:l},h).then(b)},construct(n,o){m(i);const[s,r]=v(o);return C(t,{type:"CONSTRUCT",path:e.map((t=>t.toString())),argumentList:s},r).then(b)}});return o}function g(t){return Array.prototype.concat.apply([],t)}function v(t){const e=t.map(w);return[e.map((t=>t[0])),g(e.map((t=>t[1])))]}const y=new WeakMap;function w(t){for(const[e,n]of u)if(n.canHandle(t)){const[i,o]=n.serialize(t);return[{type:"HANDLER",name:e,value:i},o]}return[{type:"RAW",value:t},y.get(t)||[]]}function b(t){switch(t.type){case"HANDLER":return u.get(t.name).deserialize(t.value);case"RAW":return t.value}}function C(t,e,n){return new Promise((i=>{const o=new Array(4).fill(0).map((()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16))).join("-");t.addEventListener("message",(function e(n){!n.data||!n.data.id||n.data.id!==o||(t.removeEventListener("message",e),i(n.data))})),t.start&&t.start(),t.postMessage(Object.assign({id:o},e),n)}))}const S="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2NvbnN0ICQ9U3ltYm9sKCJDb21saW5rLnByb3h5IiksQT1TeW1ib2woIkNvbWxpbmsuZW5kcG9pbnQiKSxSPVN5bWJvbCgiQ29tbGluay5yZWxlYXNlUHJveHkiKSx5PVN5bWJvbCgiQ29tbGluay50aHJvd24iKSxfPWU9PnR5cGVvZiBlPT0ib2JqZWN0IiYmZSE9PW51bGx8fHR5cGVvZiBlPT0iZnVuY3Rpb24iLEw9e2NhbkhhbmRsZTplPT5fKGUpJiZlWyRdLHNlcmlhbGl6ZShlKXtjb25zdHtwb3J0MTpyLHBvcnQyOml9PW5ldyBNZXNzYWdlQ2hhbm5lbDtyZXR1cm4gdyhlLHIpLFtpLFtpXV19LGRlc2VyaWFsaXplKGUpe3JldHVybiBlLnN0YXJ0KCksQyhlKX19LE89e2NhbkhhbmRsZTplPT5fKGUpJiZ5IGluIGUsc2VyaWFsaXplKHt2YWx1ZTplfSl7bGV0IHI7cmV0dXJuIGUgaW5zdGFuY2VvZiBFcnJvcj9yPXtpc0Vycm9yOiEwLHZhbHVlOnttZXNzYWdlOmUubWVzc2FnZSxuYW1lOmUubmFtZSxzdGFjazplLnN0YWNrfX06cj17aXNFcnJvcjohMSx2YWx1ZTplfSxbcixbXV19LGRlc2VyaWFsaXplKGUpe3Rocm93IGUuaXNFcnJvcj9PYmplY3QuYXNzaWduKG5ldyBFcnJvcihlLnZhbHVlLm1lc3NhZ2UpLGUudmFsdWUpOmUudmFsdWV9fSxFPW5ldyBNYXAoW1sicHJveHkiLExdLFsidGhyb3ciLE9dXSk7ZnVuY3Rpb24gdyhlLHI9c2VsZil7ci5hZGRFdmVudExpc3RlbmVyKCJtZXNzYWdlIixmdW5jdGlvbiBpKHMpe2lmKCFzfHwhcy5kYXRhKXJldHVybjtjb25zdHtpZDpvLHR5cGU6YSxwYXRoOm59PU9iamVjdC5hc3NpZ24oe3BhdGg6W119LHMuZGF0YSksdT0ocy5kYXRhLmFyZ3VtZW50TGlzdHx8W10pLm1hcChtKTtsZXQgbDt0cnl7Y29uc3QgYz1uLnNsaWNlKDAsLTEpLnJlZHVjZSgoZCxoKT0+ZFtoXSxlKSxmPW4ucmVkdWNlKChkLGgpPT5kW2hdLGUpO3N3aXRjaChhKXtjYXNlIkdFVCI6bD1mO2JyZWFrO2Nhc2UiU0VUIjpjW24uc2xpY2UoLTEpWzBdXT1tKHMuZGF0YS52YWx1ZSksbD0hMDticmVhaztjYXNlIkFQUExZIjpsPWYuYXBwbHkoYyx1KTticmVhaztjYXNlIkNPTlNUUlVDVCI6e2NvbnN0IGQ9bmV3IGYoLi4udSk7bD16KGQpfWJyZWFrO2Nhc2UiRU5EUE9JTlQiOntjb25zdHtwb3J0MTpkLHBvcnQyOmh9PW5ldyBNZXNzYWdlQ2hhbm5lbDt3KGUsaCksbD1OKGQsW2RdKX1icmVhaztjYXNlIlJFTEVBU0UiOmw9dm9pZCAwO2JyZWFrO2RlZmF1bHQ6cmV0dXJufX1jYXRjaChjKXtsPXt2YWx1ZTpjLFt5XTowfX1Qcm9taXNlLnJlc29sdmUobCkuY2F0Y2goYz0+KHt2YWx1ZTpjLFt5XTowfSkpLnRoZW4oYz0+e2NvbnN0W2YsZF09UyhjKTtyLnBvc3RNZXNzYWdlKE9iamVjdC5hc3NpZ24oT2JqZWN0LmFzc2lnbih7fSxmKSx7aWQ6b30pLGQpLGE9PT0iUkVMRUFTRSImJihyLnJlbW92ZUV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLGkpLEYocikpfSl9KSxyLnN0YXJ0JiZyLnN0YXJ0KCl9ZnVuY3Rpb24gVChlKXtyZXR1cm4gZS5jb25zdHJ1Y3Rvci5uYW1lPT09Ik1lc3NhZ2VQb3J0In1mdW5jdGlvbiBGKGUpe1QoZSkmJmUuY2xvc2UoKX1mdW5jdGlvbiBDKGUscil7cmV0dXJuIGIoZSxbXSxyKX1mdW5jdGlvbiBwKGUpe2lmKGUpdGhyb3cgbmV3IEVycm9yKCJQcm94eSBoYXMgYmVlbiByZWxlYXNlZCBhbmQgaXMgbm90IHVzZWFibGUiKX1mdW5jdGlvbiBiKGUscj1bXSxpPWZ1bmN0aW9uKCl7fSl7bGV0IHM9ITE7Y29uc3Qgbz1uZXcgUHJveHkoaSx7Z2V0KGEsbil7aWYocChzKSxuPT09UilyZXR1cm4oKT0+ZyhlLHt0eXBlOiJSRUxFQVNFIixwYXRoOnIubWFwKHU9PnUudG9TdHJpbmcoKSl9KS50aGVuKCgpPT57RihlKSxzPSEwfSk7aWYobj09PSJ0aGVuIil7aWYoci5sZW5ndGg9PT0wKXJldHVybnt0aGVuOigpPT5vfTtjb25zdCB1PWcoZSx7dHlwZToiR0VUIixwYXRoOnIubWFwKGw9PmwudG9TdHJpbmcoKSl9KS50aGVuKG0pO3JldHVybiB1LnRoZW4uYmluZCh1KX1yZXR1cm4gYihlLFsuLi5yLG5dKX0sc2V0KGEsbix1KXtwKHMpO2NvbnN0W2wsY109Uyh1KTtyZXR1cm4gZyhlLHt0eXBlOiJTRVQiLHBhdGg6Wy4uLnIsbl0ubWFwKGY9PmYudG9TdHJpbmcoKSksdmFsdWU6bH0sYykudGhlbihtKX0sYXBwbHkoYSxuLHUpe3Aocyk7Y29uc3QgbD1yW3IubGVuZ3RoLTFdO2lmKGw9PT1BKXJldHVybiBnKGUse3R5cGU6IkVORFBPSU5UIn0pLnRoZW4obSk7aWYobD09PSJiaW5kIilyZXR1cm4gYihlLHIuc2xpY2UoMCwtMSkpO2NvbnN0W2MsZl09TSh1KTtyZXR1cm4gZyhlLHt0eXBlOiJBUFBMWSIscGF0aDpyLm1hcChkPT5kLnRvU3RyaW5nKCkpLGFyZ3VtZW50TGlzdDpjfSxmKS50aGVuKG0pfSxjb25zdHJ1Y3QoYSxuKXtwKHMpO2NvbnN0W3UsbF09TShuKTtyZXR1cm4gZyhlLHt0eXBlOiJDT05TVFJVQ1QiLHBhdGg6ci5tYXAoYz0+Yy50b1N0cmluZygpKSxhcmd1bWVudExpc3Q6dX0sbCkudGhlbihtKX19KTtyZXR1cm4gb31mdW5jdGlvbiBEKGUpe3JldHVybiBBcnJheS5wcm90b3R5cGUuY29uY2F0LmFwcGx5KFtdLGUpfWZ1bmN0aW9uIE0oZSl7Y29uc3Qgcj1lLm1hcChTKTtyZXR1cm5bci5tYXAoaT0+aVswXSksRChyLm1hcChpPT5pWzFdKSldfWNvbnN0IFA9bmV3IFdlYWtNYXA7ZnVuY3Rpb24gTihlLHIpe3JldHVybiBQLnNldChlLHIpLGV9ZnVuY3Rpb24geihlKXtyZXR1cm4gT2JqZWN0LmFzc2lnbihlLHtbJF06ITB9KX1mdW5jdGlvbiBTKGUpe2Zvcihjb25zdFtyLGldb2YgRSlpZihpLmNhbkhhbmRsZShlKSl7Y29uc3RbcyxvXT1pLnNlcmlhbGl6ZShlKTtyZXR1cm5be3R5cGU6IkhBTkRMRVIiLG5hbWU6cix2YWx1ZTpzfSxvXX1yZXR1cm5be3R5cGU6IlJBVyIsdmFsdWU6ZX0sUC5nZXQoZSl8fFtdXX1mdW5jdGlvbiBtKGUpe3N3aXRjaChlLnR5cGUpe2Nhc2UiSEFORExFUiI6cmV0dXJuIEUuZ2V0KGUubmFtZSkuZGVzZXJpYWxpemUoZS52YWx1ZSk7Y2FzZSJSQVciOnJldHVybiBlLnZhbHVlfX1mdW5jdGlvbiBnKGUscixpKXtyZXR1cm4gbmV3IFByb21pc2Uocz0+e2NvbnN0IG89VSgpO2UuYWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsZnVuY3Rpb24gYShuKXshbi5kYXRhfHwhbi5kYXRhLmlkfHxuLmRhdGEuaWQhPT1vfHwoZS5yZW1vdmVFdmVudExpc3RlbmVyKCJtZXNzYWdlIixhKSxzKG4uZGF0YSkpfSksZS5zdGFydCYmZS5zdGFydCgpLGUucG9zdE1lc3NhZ2UoT2JqZWN0LmFzc2lnbih7aWQ6b30sciksaSl9KX1mdW5jdGlvbiBVKCl7cmV0dXJuIG5ldyBBcnJheSg0KS5maWxsKDApLm1hcCgoKT0+TWF0aC5mbG9vcihNYXRoLnJhbmRvbSgpKk51bWJlci5NQVhfU0FGRV9JTlRFR0VSKS50b1N0cmluZygxNikpLmpvaW4oIi0iKX1jb25zdCBXPWFzeW5jKCk9PldlYkFzc2VtYmx5LnZhbGlkYXRlKG5ldyBVaW50OEFycmF5KFswLDk3LDExNSwxMDksMSwwLDAsMCwxLDUsMSw5NiwwLDEsMTIzLDMsMiwxLDAsMTAsMTAsMSw4LDAsNjUsMCwyNTMsMTUsMjUzLDk4LDExXSkpLHg9ImVhZ2VyIixrPSJsYXp5IixqPXtzc3c6WyJzaW1kIl0sbWluaW1hcDI6WyJzaW1kIl19LHQ9e3Rvb2xzOltdLGNvbmZpZzp7fSxmaWxlczpbXSxiYXNlOnt9LGZzOnt9LGFzeW5jIGluaXQoKXtpZih0LnRvb2xzLmxlbmd0aD09PTApdGhyb3ciRXhwZWN0aW5nIGF0IGxlYXN0IDEgdG9vbC4iO2lmKG5ldyBTZXQodC50b29scy5tYXAocj0+YCR7ci50b29sfS8ke3IucHJvZ3JhbXx8ci50b29sfWApKS5zaXplIT09dC50b29scy5sZW5ndGgpdGhyb3ciRm91bmQgZHVwbGljYXRlIHRvb2xzOyBjYW4gb25seSBoYXZlIGVhY2ggdG9vbC9wcm9ncmFtIGNvbWJpbmF0aW9uIGF0IG1vc3Qgb25jZS4iO2lmKHQuYmFzZT10LnRvb2xzLmZpbmQocj0+ci5yZWluaXQhPT0hMCksIXQuYmFzZSl0aHJvdyJDb3VsZCBub3QgZmluZCBhIHRvb2wgd2l0aCBgcmVpbml0OiBmYWxzZWAgdG8gdXNlIGFzIHRoZSBiYXNlIG1vZHVsZS4gVG8gZml4IHRoaXMgaXNzdWUsIGluY2x1ZGUgdGhlIHRvb2wgYGJhc2UvMS4wLjBgIHdoZW4gaW5pdGlhbGl6aW5nIEFpb2xpLiI7cmV0dXJuIHQuYmFzZS5pc0Jhc2VNb2R1bGU9ITAsYXdhaXQgdGhpcy5fc2V0dXAodC5iYXNlKSxhd2FpdCB0aGlzLl9pbml0TW9kdWxlcygpLHQuX2xvZygiUmVhZHkiKSwhMH0sYXN5bmMgX2luaXRNb2R1bGVzKCl7YXdhaXQgUHJvbWlzZS5hbGwodC50b29scy5tYXAodGhpcy5fc2V0dXApKSxhd2FpdCB0aGlzLl9zZXR1cEZTKCl9LG1vdW50KGU9W10pe2NvbnN0IHI9YCR7dC5jb25maWcuZGlyU2hhcmVkfSR7dC5jb25maWcuZGlyRGF0YX1gLGk9YCR7dC5jb25maWcuZGlyU2hhcmVkfSR7dC5jb25maWcuZGlyTW91bnRlZH1gO2xldCBzPVtdLG89W10sYT1bXTshQXJyYXkuaXNBcnJheShlKSYmIShlIGluc3RhbmNlb2YgRmlsZUxpc3QpJiYoZT1bZV0pLHQuX2xvZyhgTW91bnRpbmcgJHtlLmxlbmd0aH0gZmlsZXNgKTtmb3IobGV0IG4gb2YgZSl7aWYobiBpbnN0YW5jZW9mIEZpbGV8fChuPT1udWxsP3ZvaWQgMDpuLmRhdGEpaW5zdGFuY2VvZiBCbG9iJiZuLm5hbWV8fHR5cGVvZihuPT1udWxsP3ZvaWQgMDpuLmRhdGEpPT0ic3RyaW5nIiYmbi5uYW1lKXR5cGVvZihuPT1udWxsP3ZvaWQgMDpuLmRhdGEpPT0ic3RyaW5nIiYmKG4uZGF0YT1uZXcgQmxvYihbbi5kYXRhXSx7dHlwZToidGV4dC9wbGFpbiJ9KSkscy5wdXNoKG4pO2Vsc2UgaWYobi5uYW1lJiZuLnVybClvLnB1c2gobik7ZWxzZSBpZih0eXBlb2Ygbj09InN0cmluZyImJm4uc3RhcnRzV2l0aCgiaHR0cCIpKW49e3VybDpuLG5hbWU6bi5zcGxpdCgiLy8iKS5wb3AoKS5yZXBsYWNlKC9cLy9nLCItIil9LG8ucHVzaChuKTtlbHNlIHRocm93J0Nhbm5vdCBtb3VudCBmaWxlKHMpIHNwZWNpZmllZC4gTXVzdCBiZSBhIEZpbGUsIEJsb2IsIGEgVVJMIHN0cmluZywgb3IgeyBuYW1lOiAiZmlsZS50eHQiLCBkYXRhOiAic3RyaW5nIiB9Lic7YS5wdXNoKG4ubmFtZSl9dHJ5e3QuZnMudW5tb3VudChpKX1jYXRjaHt9Zm9yKGxldCBuIG9mIG8pdC5mcy5jcmVhdGVMYXp5RmlsZShyLG4ubmFtZSxuLnVybCwhMCwhMCk7cmV0dXJuIHQuZmlsZXM9dC5maWxlcy5jb25jYXQocyksdC5iYXNlLm1vZHVsZS5GUy5tb3VudCh0LmJhc2UubW9kdWxlLldPUktFUkZTLHtmaWxlczp0LmZpbGVzLmZpbHRlcihuPT5uIGluc3RhbmNlb2YgRmlsZSksYmxvYnM6dC5maWxlcy5maWx0ZXIobj0+KG49PW51bGw/dm9pZCAwOm4uZGF0YSlpbnN0YW5jZW9mIEJsb2IpfSxpKSxzLm1hcChuPT57Y29uc3QgdT1gJHtpfS8ke24ubmFtZX1gLGw9YCR7cn0vJHtuLm5hbWV9YDt0cnl7dC5mcy51bmxpbmsobCl9Y2F0Y2h7fXQuX2xvZyhgQ3JlYXRpbmcgc3ltbGluazogJHtsfSAtLT4gJHt1fWApLHQuZnMuc3ltbGluayh1LGwpfSksYS5tYXAobj0+YCR7cn0vJHtufWApfSxhc3luYyBleGVjKGUscj1udWxsKXtpZih0Ll9sb2coYEV4ZWN1dGluZyAlYyR7ZX0lYyBhcmdzPSR7cn1gLCJjb2xvcjpkYXJrYmx1ZTsgZm9udC13ZWlnaHQ6Ym9sZCIsIiIpLCFlKXRocm93IkV4cGVjdGluZyBhIGNvbW1hbmQiO2xldCBpPWU7cj09bnVsbCYmKHI9ZS5zcGxpdCgiICIpLGk9ci5zaGlmdCgpKTtjb25zdCBzPXQudG9vbHMuZmluZChhPT57dmFyIHU7bGV0IG49aTtyZXR1cm4oKHU9YT09bnVsbD92b2lkIDA6YS5mZWF0dXJlcyk9PW51bGw/dm9pZCAwOnUuc2ltZCk9PT0hMCYmKG49YCR7bn0tc2ltZGApLGEucHJvZ3JhbT09bn0pO2lmKHM9PW51bGwpdGhyb3dgUHJvZ3JhbSAke2l9IG5vdCBmb3VuZC5gO3Muc3Rkb3V0PSIiLHMuc3RkZXJyPSIiLHMubG9hZGluZz09ayYmKHMubG9hZGluZz14LGF3YWl0IHRoaXMuX2luaXRNb2R1bGVzKCkpO3RyeXtzLm1vZHVsZS5jYWxsTWFpbihyKX1jYXRjaChhKXtjb25zb2xlLmVycm9yKGEpfXRyeXtzLm1vZHVsZS5GUy5jbG9zZShzLm1vZHVsZS5GUy5zdHJlYW1zWzFdKSxzLm1vZHVsZS5GUy5jbG9zZShzLm1vZHVsZS5GUy5zdHJlYW1zWzJdKX1jYXRjaHt9cy5tb2R1bGUuRlMuc3RyZWFtc1sxXT1zLm1vZHVsZS5GUy5vcGVuKCIvZGV2L3N0ZG91dCIsInciKSxzLm1vZHVsZS5GUy5zdHJlYW1zWzJdPXMubW9kdWxlLkZTLm9wZW4oIi9kZXYvc3RkZXJyIiwidyIpO2xldCBvPXtzdGRvdXQ6cy5zdGRvdXQsc3RkZXJyOnMuc3RkZXJyfTtpZih0LmNvbmZpZy5wcmludEludGVybGVhdmVkJiYobz1zLnN0ZG91dCkscy5yZWluaXQ9PT0hMCl7Y29uc3QgYT10LmJhc2UubW9kdWxlLkZTLmN3ZCgpO09iamVjdC5hc3NpZ24ocyxzLmNvbmZpZykscy5yZWFkeT0hMSxhd2FpdCB0aGlzLmluaXQoKSxzLmlzQmFzZU1vZHVsZSYmdGhpcy5tb3VudCgpLHRoaXMuY2QoYSl9cmV0dXJuIG99LGNhdChlKXtyZXR1cm4gdC5fZmlsZW9wKCJjYXQiLGUpfSxscyhlKXtyZXR1cm4gdC5fZmlsZW9wKCJscyIsZSl9LGRvd25sb2FkKGUpe3JldHVybiB0Ll9maWxlb3AoImRvd25sb2FkIixlKX0scHdkKCl7cmV0dXJuIHQuZnMuY3dkKCl9LGNkKGUpe2ZvcihsZXQgciBvZiB0LnRvb2xzKSFyLm1vZHVsZXx8ci5tb2R1bGUuRlMuY2hkaXIoZSl9LG1rZGlyKGUpe3JldHVybiB0LmZzLm1rZGlyKGUpLCEwfSxyZWFkKHtwYXRoOmUsbGVuZ3RoOnIsZmxhZzppPSJyIixvZmZzZXQ6cz0wLHBvc2l0aW9uOm89MH0pe2NvbnN0IGE9dC5mcy5vcGVuKGUsaSksbj1uZXcgVWludDhBcnJheShyKTtyZXR1cm4gdC5mcy5yZWFkKGEsbixzLHIsbyksdC5mcy5jbG9zZShhKSxufSx3cml0ZSh7cGF0aDplLGJ1ZmZlcjpyLGZsYWc6aT0idysiLG9mZnNldDpzPTAscG9zaXRpb246bz0wfSl7Y29uc3QgYT10LmZzLm9wZW4oZSxpKTt0LmZzLndyaXRlKGEscixzLHIubGVuZ3RoLG8pLHQuZnMuY2xvc2UoYSl9LF9zdGRpblR4dDoiIixfc3RkaW5QdHI6MCxnZXQgc3RkaW4oKXtyZXR1cm4gdC5fc3RkaW5UeHR9LHNldCBzdGRpbihlPSIiKXt0Ll9sb2coYFNldHRpbmcgc3RkaW4gdG8gJWMke2V9JWNgLCJjb2xvcjpkYXJrYmx1ZSIsIiIpLHQuX3N0ZGluVHh0PWUsdC5fc3RkaW5QdHI9MH0sYXN5bmMgX3NldHVwKGUpe2lmKGUucmVhZHkpcmV0dXJuO2lmKHQuX2xvZyhgU2V0dGluZyB1cCAke2UudG9vbH0gKGJhc2UgPSAke2UuaXNCYXNlTW9kdWxlPT09ITB9KS4uLmApLGUuY29uZmlnPU9iamVjdC5hc3NpZ24oe30sZSksZS51cmxQcmVmaXh8fChlLnVybFByZWZpeD1gJHt0LmNvbmZpZy51cmxDRE59LyR7ZS50b29sfS8ke2UudmVyc2lvbn1gKSxlLnByb2dyYW18fChlLnByb2dyYW09ZS50b29sKSxlLmZlYXR1cmVzfHwoZS5mZWF0dXJlcz17fSwoaltlLnByb2dyYW1dfHxbXSkuaW5jbHVkZXMoInNpbWQiKSYmKGF3YWl0IFcoKT8oZS5wcm9ncmFtKz0iLXNpbWQiLGUuZmVhdHVyZXMuc2ltZD0hMCk6dC5fbG9nKGBXZWJBc3NlbWJseSBTSU1EIGlzIG5vdCBzdXBwb3J0ZWQgaW4gdGhpcyBicm93c2VyOyB3aWxsIGxvYWQgbm9uLVNJTUQgdmVyc2lvbiBvZiAke2UucHJvZ3JhbX0uYCkpKSxlLmlzQmFzZU1vZHVsZSYmKGUubG9hZGluZz14KSxlLmxvYWRpbmc9PT1rKXt0Ll9sb2coYFdpbGwgbGF6eS1sb2FkICR7ZS50b29sfTsgc2tpcHBpbmcgaW5pdGlhbGl6YXRpb24uYCk7cmV0dXJufXNlbGYuaW1wb3J0U2NyaXB0cyhgJHtlLnVybFByZWZpeH0vJHtlLnByb2dyYW19LmpzYCksZS5tb2R1bGU9YXdhaXQgTW9kdWxlKHt0aGlzUHJvZ3JhbTplLnByb2dyYW0sbG9jYXRlRmlsZTooaSxzKT0+YCR7ZS51cmxQcmVmaXh9LyR7aX1gLHN0ZGluOigpPT50Ll9zdGRpblB0cjx0LnN0ZGluLmxlbmd0aD90LnN0ZGluLmNoYXJDb2RlQXQodC5fc3RkaW5QdHIrKyk6KHQuc3RkaW49IiIsbnVsbCkscHJpbnQ6aT0+ZS5zdGRvdXQrPWAke2l9CmAscHJpbnRFcnI6dC5jb25maWcucHJpbnRJbnRlcmxlYXZlZD9pPT5lLnN0ZG91dCs9YCR7aX0KYDppPT5lLnN0ZGVycis9YCR7aX0KYH0pO2NvbnN0IHI9ZS5tb2R1bGUuRlM7ZS5pc0Jhc2VNb2R1bGU/KHQuX2xvZyhgU2V0dGluZyB1cCAke2UudG9vbH0gd2l0aCBiYXNlIG1vZHVsZSBmaWxlc3lzdGVtLi4uYCksci5ta2Rpcih0LmNvbmZpZy5kaXJTaGFyZWQsNTExKSxyLm1rZGlyKGAke3QuY29uZmlnLmRpclNoYXJlZH0vJHt0LmNvbmZpZy5kaXJEYXRhfWAsNTExKSxyLm1rZGlyKGAke3QuY29uZmlnLmRpclNoYXJlZH0vJHt0LmNvbmZpZy5kaXJNb3VudGVkfWAsNTExKSxyLmNoZGlyKGAke3QuY29uZmlnLmRpclNoYXJlZH0vJHt0LmNvbmZpZy5kaXJEYXRhfWApLHQuZnM9cik6KHQuX2xvZyhgU2V0dGluZyB1cCAke2UudG9vbH0gd2l0aCBmaWxlc3lzdGVtLi4uYCksci5ta2Rpcih0LmNvbmZpZy5kaXJTaGFyZWQpLHIubW91bnQoZS5tb2R1bGUuUFJPWFlGUyx7cm9vdDp0LmNvbmZpZy5kaXJTaGFyZWQsZnM6dC5mc30sdC5jb25maWcuZGlyU2hhcmVkKSxyLmNoZGlyKHQuZnMuY3dkKCkpKSxlLnN0ZG91dD0iIixlLnN0ZGVycj0iIixlLnJlYWR5PSEwfSxhc3luYyBfc2V0dXBGUygpe2NvbnN0IGU9dC5mcztmb3IobGV0IHIgb2YgdC50b29scyl7aWYoIXIucmVhZHkpY29udGludWU7Y29uc3QgaT1yLm1vZHVsZS5GUyxzPWAvJHtyLnRvb2x9YCxvPWAke3QuY29uZmlnLmRpclNoYXJlZH0ke3N9YDshaS5hbmFseXplUGF0aChzKS5leGlzdHN8fGUuYW5hbHl6ZVBhdGgobykuZXhpc3RzfHwodC5fbG9nKGBNb3VudGluZyAke3N9IG9udG8gJHt0LmJhc2UudG9vbH0gZmlsZXN5c3RlbSBhdCAke299YCksZS5ta2RpcihvKSxlLm1vdW50KHQuYmFzZS5tb2R1bGUuUFJPWFlGUyx7cm9vdDpzLGZzOml9LG8pKX19LF9maWxlb3AoZSxyKXt0Ll9sb2coYFJ1bm5pbmcgJHtlfSAke3J9YCk7Y29uc3QgaT10LmZzLmFuYWx5emVQYXRoKHIpO2lmKCFpLmV4aXN0cylyZXR1cm4gdC5fbG9nKGBGaWxlICR7cn0gbm90IGZvdW5kLmApLCExO3N3aXRjaChlKXtjYXNlImNhdCI6cmV0dXJuIHQuZnMucmVhZEZpbGUocix7ZW5jb2Rpbmc6InV0ZjgifSk7Y2FzZSJscyI6cmV0dXJuIHQuZnMuaXNGaWxlKGkub2JqZWN0Lm1vZGUpP3QuZnMuc3RhdChyKTp0LmZzLnJlYWRkaXIocik7Y2FzZSJkb3dubG9hZCI6Y29uc3Qgcz1uZXcgQmxvYihbdGhpcy5jYXQocildKTtyZXR1cm4gVVJMLmNyZWF0ZU9iamVjdFVSTChzKX1yZXR1cm4hMX0sX2xvZyhlKXtpZighdC5jb25maWcuZGVidWcpcmV0dXJuO2xldCByPVsuLi5hcmd1bWVudHNdO3Iuc2hpZnQoKSxjb25zb2xlLmxvZyhgJWNbV2ViV29ya2VyXSVjICR7ZX1gLCJmb250LXdlaWdodDpib2xkIiwiIiwuLi5yKX19O3codCl9KSgpOwo=",T=typeof window<"u"&&window.Blob&&new Blob([atob(S)],{type:"text/javascript;charset=utf-8"});function M(){const t=T&&(window.URL||window.webkitURL).createObjectURL(T);try{return t?new Worker(t):new Worker("data:application/javascript;base64,"+S)}finally{t&&(window.URL||window.webkitURL).revokeObjectURL(t)}}const E={urlCDN:"https://biowasm.com/cdn/v3",urlCDNStg:"https://stg.biowasm.com/cdn/v3",dirShared:"/shared",dirMounted:"/mnt",dirData:"/data",printInterleaved:!0,callback:null,debug:!1,env:"prd"};class A{constructor(t,e={}){if(null==t)throw"Expecting array of tools as input to Aioli constructor.";return Array.isArray(t)||(t=[t]),e=Object.assign({},E,e),t=t.map(this._parseTool),"stg"===e.env&&(e.urlCDN=e.urlCDNStg),this.tools=t,this.config=e,null!=this.config.callback&&(this.callback=this.config.callback),delete this.config.callback,this.init()}async init(){const t=new M;this.callback&&(t.onmessage=t=>{"biowasm"===t.data.type&&this.callback(t.data.value)});const e=f(t);return e.tools=this.tools,e.config=this.config,await e.init(),e}_parseTool(t){if("string"!=typeof t)return t;const e=t.split("/");if(2!=e.length&&3!=e.length)throw"Expecting '<tool>/<version>' or '<tool>/<program>/<version>'";return{tool:e[0],program:3==e.length?e[1]:e[0],version:e[e.length-1]}}}var R=n(850);class P{static getAvailableScales(){return Object.entries(this.scales).map((([t,e])=>t))}static getScale(t){return(0,R.hu)(!(void 0===this.scales[t]),`Scale '${t}' was not found.`),this.scales[t]}}P.scales={WimleyWhite:{"-":0,A:.17,C:-.24,D:-.07,E:-.01,F:-1.13,G:.01,H:.17,I:-.31,K:.99,L:-.56,M:-.23,N:.42,P:.45,Q:.58,R:.81,S:.13,T:.14,V:.07,W:-1.85,Y:-.94},categorial:{"-":0,A:1,C:2,D:3,E:4,F:5,G:6,H:7,I:8,K:9,L:10,M:11,N:12,P:13,Q:14,R:15,S:16,T:17,V:18,W:19,Y:20}};class N{constructor(t="categorial"){this.aa2num=P.getScale(t),this.num2aa={},Object.entries(this.aa2num).forEach((([t,e])=>this.num2aa[e]=t))}static _truncateSequence(t){let e=0,n=t.length;const i=["NH2","COOH"];if(t.startsWith(i[0])){const n=i[0].length;(0,R.hu)("-"==t[n],`Wrong sequence format: ${i[0]} without following '-' in '${t}'.`),e=n}if(t.endsWith(i[1])){const e=i[1].length+1;(0,R.hu)("-"==t[n-e],`Wrong sequence format: ${i[1]} without '-' precending in '${t}'.`),n-=e}return t.substring(e,n)}static _dropDefises(t){return t.replace(/(-)([^-]+)/g,"$2")}static clean(t){return N._dropDefises(N._truncateSequence(t))}encode(t){const e=t.length,n=new Array(e).fill(0);for(let i=0;i<e;++i){const e=t[i];(0,R.hu)(e in this.aa2num,`Unknown char '${e}' found in sequence '${t}'`),n[i]=this.encodeLettter(e)}return n}encodeLettter(t){return this.aa2num[t]}decode(t){let e="";for(let n=0;n<t.length;++n){const i=t[n];(0,R.hu)(i in this.num2aa,`Unknown code '${i}' found in vector '${t}'`),e+=this.num2aa[i]}return e}}var x=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};const L="input.fa",G="result.fasta";function _(t){return t.reduce(((t,e,n)=>t+`>sample${n+1}\n${e}\n`),"")}function I(t,e=!1,n="",s=null){var r,a;return x(this,void 0,void 0,(function*(){let l=t.toList();e&&(l=l.map((t=>N.clean(t).replace(/\-/g,""))));const h=t.length;null!=s||(s=i.Column.string("Clusters",h).init("0")),s.type!=i.COLUMN_TYPE.STRING&&(s=s.convertTo(i.TYPE.STRING)),s.compact();const u=s.categories,c=s.getRawData(),d=new Array(u.length),f=new Array(u.length);for(let t=0;t<h;++t){const e=c[t];(null!==(r=d[e])&&void 0!==r?r:d[e]=[]).push(l[t]),(null!==(a=f[e])&&void 0!==a?a:f[e]=[]).push(t)}const m=yield new A(["base/1.0.0",{tool:"kalign",version:"3.3.1",reinit:!0}]),p=i.Column.string(n,h);for(let t=0;t<u.length;++t){const e=_(d[t]);console.log(["fasta.length =",e.length]),yield m.fs.writeFile(L,e);const n=yield m.exec(`kalign ${L} -f fasta -o ${G}`);console.warn(n);const i=yield m.cat(G);if(!i)throw new Error("kalign output no result");const s=new o.i(i).sequencesArray,r=f[t];for(let t=0;t<s.length;++t)p.set(r[t],s[t])}const g=t.getTag(i.TAGS.UNITS),v=t.getTag("aligned")+".MSA",y=t.getTag("alphabet");return p.setTag(i.TAGS.UNITS,g),p.setTag("aligned",v),p.setTag("alphabet",y),p.semType=i.SEMTYPE.MACROMOLECULE,p}))}},8341:(t,e,n)=>{"use strict";n.d(e,{J:()=>a,f:()=>h});var i=n(4469),o=n(976),s=n(3553),r=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};const a=["mafft --auto","mafft","linsi","ginsi","einsi","fftns","fftnsi","nwns","nwnsi"],l=["AlignedSeq","AlignedSubpeptide","HELM","ID","PolymerID"];function h(t,e,n="ginsi",a=1.53,h=0,c=null){var d;return r(this,void 0,void 0,(function*(){const r=t.length;null!=c||(c=o.Column.int("Clusters",r).init(0)),c.type!=o.COLUMN_TYPE.STRING&&(c=c.convertTo(o.TYPE.STRING));const f=c.categories,m=new Array(f.length);for(let e=0;e<r;++e){const n=c.get(e);if(""===n)continue;const i=f.indexOf(n),o=t.get(e);o&&(null!==(d=m[i])&&void 0!==d?d:m[i]=[]).push({ID:e.toString(),HELM:o})}const p=yield(void 0!==i.dapi.docker?i.dapi.docker.dockerContainers:i.dapi.dockerfiles).filter("bio").first(),g=new Array(r);for(const t of m){const e=(yield u(p.id,t,n,a,h)).Alignment;for(const t of e)g[parseInt(t.ID)]=Object.entries(t).filter((t=>!l.includes(t[0]))).map((t=>"-"!==t[1]?t[1]:"")).join(s.rs.SEPARATOR)}const v=o.Column.fromStrings(e,g);return v.setTag(o.TAGS.UNITS,"separator"),v.setTag("separator",s.rs.SEPARATOR),v.setTag("aligned","SEQ.MSA"),v.setTag("alphabet","UN"),v.setTag(".alphabetIsMultichar","true"),v.semType=o.SEMTYPE.MACROMOLECULE,v}))}function u(t,e,n,o,s){return r(this,void 0,void 0,(function*(){const r={method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(e)},a=`/align?method=${n}&gap_open=${o}&gap_extend=${s}`,l=yield(void 0!==i.dapi.docker?i.dapi.docker.dockerContainers:i.dapi.dockerfiles).request(t,a,r);return JSON.parse(null!=l?l:"{}")}))}},9943:(t,e,n)=>{"use strict";n.d(e,{i$:()=>s,sK:()=>r}),n(976),n(3870),n(4469),n(6414);var i=n(6714);n(499);const o=60;function s(t,e,n=o,s="\n"){const a=i.kB,l=[];for(let i=0;i<e.length;i++){const o=t.map((t=>t.get(i).toString())).join("|"),h=r(e.get(i),a,n);l.push(`>${o}${s}`);for(const t of h)l.push(`${t}${s}`)}return"".concat(...l)}function r(t,e,n=o){const i=e(t);let s=0;const r=i.length,a=[];for(;s<r;){const t=i.slice(s,s+n),e=t.map((t=>t.length>1?`[${t}]`:t)).join("");a.push(e),s+=t.length}return a}},4293:(t,e,n)=>{"use strict";n.d(e,{Y:()=>r,m:()=>s});var i=n(4469),o=n(976);function s(){const t=i.shell.t.columns.bySemType(o.SEMTYPE.MACROMOLECULE);if(null!==t)return t;i.shell.error("Current table does not contain macromolecules")}function r(t,e){t.innerHTML="",t.append(e)}},2433:(t,e,n)=>{"use strict";n.d(e,{CK:()=>g,eZ:()=>w,yW:()=>p});var i,o,s=n(4469),r=n(3870),a=n(976),l=n(6414),h=n.n(l),u=n(701),c=n(499),d=n(6714),f=n(9298),m=n(7604);HTMLCanvasElement.prototype.getCursorPosition=function(t,e){const n=this.getBoundingClientRect();return new a.Point((t.clientX-n.left)*e,(t.clientY-n.top)*e)},a.Rect.prototype.contains=function(t,e){return this.left<=t&&t<=this.right&&this.top<=e&&e<=this.bottom};class p{constructor(t=0,e=new a.Rect(0,0,0,0)){this.count=t,this.bounds=e}}class g{constructor(t,e,n={},i=0,o=0){this.pos=t,this.name=e,this.freq=n,this.rowCount=i,this.sumForHeightCalc=o}}!function(t){t.STYLE="Style",t.BEHAVIOR="Behavior",t.LAYOUT="Layout",t.DATA="Data"}(i||(i={})),function(t){t.sequenceColumnName="sequenceColumnName",t.startPositionName="startPositionName",t.endPositionName="endPositionName",t.skipEmptySequences="skipEmptySequences",t.skipEmptyPositions="skipEmptyPositions",t.shrinkEmptyTail="shrinkEmptyTail",t.backgroundColor="backgroundColor",t.positionHeight="positionHeight",t.positionWidth="positionWidth",t.verticalAlignment="verticalAlignment",t.horizontalAlignment="horizontalAlignment",t.fixWidth="fixWidth",t.fitArea="fitArea",t.minHeight="minHeight",t.maxHeight="maxHeight",t.positionMarginState="positionMarginState",t.positionMargin="positionMargin",t.filterSource="filterSource"}(o||(o={}));const v=f.vS;class y extends a.JsViewer{get filter(){let t;switch(this.filterSource){case f.Ct.Filtered:t=this.dataFrame.filter;break;case f.Ct.Selected:t=this.dataFrame.selection}return t}get Length(){return this.skipEmptyPositions?this.positions.length:this.startPosition<=this.endPosition?this.endPosition-this.startPosition+1:0}get positionWidthWithMargin(){return this._positionWidth+this.positionMarginValue}get positionMarginValue(){var t;return"auto"===this.positionMarginState&&!0===(null===(t=this.unitsHandler)||void 0===t?void 0:t.getAlphabetIsMultichar())||"enable"===this.positionMarginState?this.positionMargin:0}get countOfRenderPositions(){if(null==this.host)return 0;const t=window.devicePixelRatio;return t>1?this.canvasWidthWithRatio/this.positionWidthWithMargin:this.canvas.width/(this.positionWidthWithMargin*t)}get canvasWidthWithRatio(){return this.canvas.width*window.devicePixelRatio}get firstVisibleIndex(){return this.visibleSlider?Math.floor(this.slider.min):0}constructor(){super(),this.viewerId=-1,this.initialized=!1,this.cp=null,this.axisHeight=12,this.seqCol=null,this.splitter=null,this.positions=[],this.rowsMasked=0,this.rowsNull=0,this.visibleSlider=!1,this.allowResize=!0,this.turnOfResizeForOneSetValue=!1,this.backgroundColor=4294967295,this.positionMargin=0,this.positionNames=[],this.startPosition=-1,this.endPosition=-1,this.viewSubs=[],this.viewerId=y.viewerCount,y.viewerCount+=1,this.textBaseline="top",this.unitsHandler=null,this.sequenceColumnName=this.string(o.sequenceColumnName,v.sequenceColumnName,{category:i.DATA}),this.startPositionName=this.string(o.startPositionName,v.startPositionName,{category:i.DATA}),this.endPositionName=this.string(o.endPositionName,v.endPositionName,{category:i.DATA}),this.skipEmptySequences=this.bool(o.skipEmptySequences,v.skipEmptySequences,{category:i.DATA}),this.skipEmptyPositions=this.bool(o.skipEmptyPositions,v.skipEmptyPositions,{category:i.DATA}),this.shrinkEmptyTail=this.bool(o.shrinkEmptyTail,v.shrinkEmptyTail,{category:i.DATA}),this.backgroundColor=this.int(o.backgroundColor,v.backgroundColor,{category:i.STYLE}),this.positionHeight=this.string(o.positionHeight,v.positionHeight,{category:i.STYLE,choices:Object.values(f.ES)}),this._positionWidth=this.positionWidth=this.float(o.positionWidth,v.positionWidth,{category:i.STYLE}),this.verticalAlignment=this.string(o.verticalAlignment,v.verticalAlignment,{category:i.LAYOUT,choices:Object.values(f.vw)}),this.horizontalAlignment=this.string(o.horizontalAlignment,v.horizontalAlignment,{category:i.LAYOUT,choices:Object.values(f.iD)}),this.fixWidth=this.bool(o.fixWidth,v.fixWidth,{category:i.LAYOUT}),this.fitArea=this.bool(o.fitArea,v.fitArea,{category:i.LAYOUT}),this.minHeight=this.float(o.minHeight,v.minHeight,{category:i.LAYOUT}),this.maxHeight=this.float(o.maxHeight,v.maxHeight,{category:i.LAYOUT}),this.positionMarginState=this.string(o.positionMarginState,v.positionMarginState,{category:i.LAYOUT,choices:Object.values(f.dE)});let t=0;"auto"===this.positionMarginState&&(t=4),this.positionMargin=this.int(o.positionMargin,t,{category:i.LAYOUT,min:0,max:16}),this.filterSource=this.string(o.filterSource,v.filterSource,{category:i.BEHAVIOR,choices:Object.values(f.Ct)}),this.slider=r.rangeSlider(0,100,0,20,!1,{style:"barbell"}),this.canvas=r.canvas(),this.canvas.style.width="100%"}init(){this.initialized?console.error("Bio: WebLogoViewer.init() second initialization!"):(this.initialized=!0,this.helpUrl="/help/visualize/viewers/web-logo.md",this.msgHost=r.div("No message"),this.msgHost.style.display="none",this.canvas=r.canvas(),this.canvas.style.width="100%",this.slider.root.style.position="absolute",this.slider.root.style.zIndex="999",this.slider.root.style.display="none",this.slider.root.style.height="0.7em",this.visibleSlider=!1,this.subs.push(this.slider.onValuesChanged.subscribe(this.sliderOnValuesChanged.bind(this))),this.host=r.div([this.msgHost,this.canvas]),this.host.style.justifyContent="center",this.host.style.alignItems="center",this.host.style.position="relative",this.host.style.setProperty("overflow","hidden","important"),this.subs.push(u.fromEvent(this.canvas,"mousemove").subscribe(this.canvasOnMouseMove.bind(this))),this.subs.push(u.fromEvent(this.canvas,"mousedown").subscribe(this.canvasOnMouseDown.bind(this))),this.subs.push(u.fromEvent(this.canvas,"wheel").subscribe(this.canvasOnWheel.bind(this))),this.subs.push(r.onSizeChanged(this.root).subscribe(this.rootOnSizeChanged.bind(this))),this.root.append(this.host),this.root.append(this.slider.root),this._calculate(window.devicePixelRatio),this.updateSlider(),this.render(!0))}rootOnSizeChanged(){this._calculate(window.devicePixelRatio),this.updateSlider(),this.render(!0)}updateSeqCol(){if(this.dataFrame)if(this.seqCol=this.sequenceColumnName?this.dataFrame.col(this.sequenceColumnName):null,null==this.seqCol&&(this.seqCol=(0,d.up)(this.dataFrame),this.sequenceColumnName=this.seqCol?this.seqCol.name:null),this.seqCol){const t=this.seqCol.getTag(a.TAGS.UNITS),e=this.seqCol.getTag("separator");this.splitter=(0,d.vU)(t,e),this.unitsHandler=new c.C(this.seqCol),this.updatePositions(),this.cp=(0,d.dQ)(this.seqCol)}else this.splitter=null,this.positionNames=[],this.startPosition=-1,this.endPosition=-1,this.cp=null;this.render()}updatePositions(){if(!this.seqCol)return;let t;if(this.shrinkEmptyTail){const e=this.dataFrame.filter.getSelectedIndexes();t=Array.from(new Set(Array.from(Array(e.length).keys()).map((t=>this.seqCol.get(e[t])))))}else t=this.seqCol.categories;const e=t.length>0?Math.max(...t.map((t=>null!==t?this.splitter(t).length:0))):0,n=this.seqCol.getTag(f.DX.positionNames);this.positionNames=n?n.split(f.CI).map((t=>t.trim())):[...Array(e).keys()].map((t=>`${t+1}`)),this.startPosition=this.startPositionName&&this.positionNames&&this.positionNames.includes(this.startPositionName)?this.positionNames.indexOf(this.startPositionName):0,this.endPosition=this.endPositionName&&this.positionNames&&this.positionNames.includes(this.endPositionName)?this.positionNames.indexOf(this.endPositionName):e-1}get widthArea(){return this.Length*this.positionWidth/window.devicePixelRatio}get heightArea(){return Math.min(this.maxHeight,Math.max(this.minHeight,this.root.clientHeight))}get xScale(){return this.widthArea>0?(this.root.clientWidth-this.Length*this.positionMarginValue)/this.widthArea:0}get yScale(){return this.root.clientHeight/this.heightArea}checkIsHideSlider(){let t=!0;const e=Math.min(this.xScale,this.yScale);return(e==this.xScale||e<=1)&&this.fitArea&&(t=!1),this.fixWidth||Math.ceil(this.canvas.width/this.positionWidthWithMargin)>=this.Length||t}setSliderVisibility(t){t?(this.slider.root.style.display="inherit",this.visibleSlider=!0):(this.slider.root.style.display="none",this.visibleSlider=!1)}updateSlider(){if(this.checkIsHideSlider()?this.setSliderVisibility(!1):this.setSliderVisibility(!0),null!=this.slider&&null!=this.canvas){const t=Math.max(0,Math.floor(this.slider.min+this.canvas.width/this.positionWidthWithMargin)-this.Length);let e=Math.floor(this.slider.min-t),n=Math.floor(this.slider.min-t)+Math.floor(this.canvas.width/this.positionWidthWithMargin);this.checkIsHideSlider()&&(e=0,n=Math.max(e,this.Length-1)),this.turnOfResizeForOneSetValue=!0,this.slider.setValues(0,this.Length,e,n)}}onPropertyChanged(t){switch(super.onPropertyChanged(t),t.name){case o.sequenceColumnName:case o.startPositionName:case o.endPositionName:case o.filterSource:this.updateSeqCol();break;case o.positionWidth:this._positionWidth=this.positionWidth,this.updateSlider();break;case o.fixWidth:case o.fitArea:case o.positionMargin:this.updateSlider();break;case o.shrinkEmptyTail:case o.skipEmptyPositions:this.updatePositions()}this.render(!0)}onTableAttached(){super.onTableAttached();const t=this.dataFrame?"data":"null";console.debug(`Bio: WebLogoViewer<${this.viewerId}>.onTableAttached( dataFrame = ${t} ) start`),this.updateSeqCol(),void 0!==this.dataFrame&&(this.viewSubs.push(this.dataFrame.filter.onChanged.subscribe(this.dataFrameFilterOnChanged.bind(this))),this.viewSubs.push(this.dataFrame.selection.onChanged.subscribe(this.dataFrameSelectionOnChanged.bind(this)))),this.init(),console.debug(`Bio: WebLogoViewer<${this.viewerId}>.onTableAttached() end`)}detach(){const t=Object.create(null,{detach:{get:()=>super.detach}});return e=this,n=void 0,o=function*(){const e=this.dataFrame?"data":"null";console.debug(`Bio: WebLogoViewer<${this.viewerId}>.onTableAttached( dataFrame = ${e} ) start`),t.detach.call(this),this.viewSubs.forEach((t=>t.unsubscribe())),this.host.remove(),this.msgHost=void 0,this.host=void 0,this.initialized=!1,console.debug(`Bio: WebLogoViewer<${this.viewerId}>.onTableAttached() end`)},new((i=void 0)||(i=Promise))((function(t,s){function r(t){try{l(o.next(t))}catch(t){s(t)}}function a(t){try{l(o.throw(t))}catch(t){s(t)}}function l(e){var n;e.done?t(e.value):(n=e.value,n instanceof i?n:new i((function(t){t(n)}))).then(r,a)}l((o=o.apply(e,n||[])).next())}));var e,n,i,o}getMonomer(t){const e=t.x+this.firstVisibleIndex*this.positionWidthWithMargin,n=Math.floor(t.x/this.positionWidthWithMargin+this.firstVisibleIndex),i=this.positions[n];if(null==i)return[n,null,null];const o=Object.keys(i.freq).find((n=>i.freq[n].bounds.contains(e,t.y)));return void 0===o?[n,null,null]:[n,o,i.freq[o]]}_nullSequence(t="X"){return this.skipEmptySequences?"":new Array(this.Length).fill(t).join("")}removeWhere(t,e){const n=t.length;let i=0;for(let o=0;o<n;o++)e(t[o])||(t[i]=t[o],i++);return t.length=i,t}_removeEmptyPositions(){this.skipEmptyPositions&&this.removeWhere(this.positions,(t=>{var e;return(null===(e=null==t?void 0:t.freq["-"])||void 0===e?void 0:e.count)===t.rowCount}))}_calculate(t){if(!this.host||!this.seqCol||!this.dataFrame)return;this.unitsHandler=new c.C(this.seqCol),this.calcSize();const e=this.startPosition<=this.endPosition?this.endPosition-this.startPosition+1:0;this.positions=new Array(e);for(let t=0;t<this.Length;t++){const e=this.positionNames[this.startPosition+t];this.positions[t]=new g(this.startPosition+t,e)}const n=this.filter.getSelectedIndexes();this.rowsMasked=n.length,this.rowsNull=0;for(const t of n){let e=this.seqCol.get(t);e||(e=this._nullSequence(),++this.rowsNull);const n=this.splitter(e);for(let t=0;t<this.Length;t++){const e=this.positions[t].freq,i=n[this.startPosition+t]||"-";i in e||(e[i]=new p),e[i].count++}}for(let t=0;t<this.Length;t++){this.positions[t].rowCount=0;for(const e in this.positions[t].freq)this.positions[t].rowCount+=this.positions[t].freq[e].count;if(this.positionHeight==f.ES.Entropy){this.positions[t].sumForHeightCalc=0;for(const e in this.positions[t].freq){const n=this.positions[t].freq[e].count/this.positions[t].rowCount;this.positions[t].sumForHeightCalc+=-n*Math.log2(n)}}}this._removeEmptyPositions();const i=this.canvas.height-this.axisHeight*t;for(let e=0;e<this.Length;e++){const n=this.positions[e].freq,o=this.positions[e].rowCount,r=this.getAlphabetSize();this.positionHeight==f.ES.Entropy&&null==r&&s.shell.error("WebLogo: alphabet is undefined.");const l=Math.log2(r),h=this.positionHeight==f.ES.Entropy?i*(l-this.positions[e].sumForHeightCalc)/l:i;let u=this.axisHeight*t+(i-h-1);const c=Object.entries(n).sort(((t,e)=>"-"!==t[0]&&"-"!==e[0]?e[1].count-t[1].count:"-"===t[0]&&"-"===e[0]?0:"-"===t[0]?-1:1));for(const t of c){const n=t[1],i=h*n.count/o;n.bounds=new a.Rect(e*this.positionWidthWithMargin,u,this._positionWidth,i),u+=i}}}render(t=!0){var e;if(this.msgHost&&(this.seqCol&&!this.cp?(this.msgHost.innerText=`Unknown palette (column semType: '${this.seqCol.semType}').`,this.msgHost.style.display=""):this.msgHost.style.display="none"),!this.seqCol||!this.dataFrame||!this.cp||-1===this.startPosition||-1===this.endPosition||null==this.host||null==this.slider)return;const n=this.canvas.getContext("2d");if(!n)return;this.slider.root.style.width=`${this.host.clientWidth}px`;const i=window.devicePixelRatio;t&&this._calculate(i),n.resetTransform(),n.fillStyle=a.Color.toHtml(this.backgroundColor),n.fillRect(0,0,this.canvas.width,this.canvas.height),n.textBaseline=this.textBaseline;const o=this.countOfRenderPositions+1,s=this.visibleSlider?Math.floor(this.slider.min):0,r=Math.min(this.Length,s+o),l=10*i;n.resetTransform(),n.fillStyle="black",n.textAlign="center",n.font=`${l.toFixed(1)}px Roboto, Roboto Local, sans-serif`;const h=Math.max(...this.positions.map((t=>n.measureText(t.name).width))),u=h<this._positionWidth-2?1:(this._positionWidth-2)/h;for(let t=this.firstVisibleIndex;t<r;t++){const e=this.positions[t];n.resetTransform(),n.setTransform(u,0,0,1,t*this.positionWidthWithMargin+this._positionWidth/2-this.positionWidthWithMargin*s,0),n.fillText(e.name,0,0)}for(let t=this.firstVisibleIndex;t<r;t++)for(const[i,o]of Object.entries(this.positions[t].freq))if("-"!==i){const t=(0,d.GU)(i,5),s=o.bounds,r=s.left-this.positionWidthWithMargin*this.firstVisibleIndex;n.resetTransform(),n.strokeStyle="lightgray",n.lineWidth=1,n.rect(r,s.top,s.width,s.height),n.fillStyle=null!==(e=this.cp.get(i))&&void 0!==e?e:this.cp.get("other"),n.textAlign="left",n.font="16px Roboto, Roboto Local, sans-serif";const a=n.measureText(t);n.setTransform(s.width/a.width,0,0,s.height/12.2,r,s.top),n.fillText(t,0,-.25)}}calcSize(){if(!this.host)return;const t=window.devicePixelRatio;let e=this.widthArea,n=this.heightArea;if(this.fitArea&&!this.visibleSlider){const t=Math.max(1,Math.min(this.xScale,this.yScale));e*=t,n*=t,this._positionWidth=this.positionWidth*t}e=this.Length*this.positionWidthWithMargin/t,this.canvas.width=this.root.clientWidth*t,this.canvas.style.width=`${this.root.clientWidth}px`,this.host.style.setProperty("height",`${n}px`);const i=this.host.clientHeight;if(this.canvas.height=i*t,this.fixWidth)this.root.style.width=this.host.style.width=`${e}px`,this.root.style.height=`${n}px`,this.root.style.overflow="hidden",this.host.style.setProperty("overflow-y","hidden","important");else{this.root.style.width=this.host.style.width="100%",this.host.style.overflowX="auto!important",this.host.style.setProperty("text-align",this.horizontalAlignment);const t=this.visibleSlider?10:0;let o=0;switch(this.verticalAlignment){case"top":o=0;break;case"middle":o=Math.max(0,(this.root.clientHeight-n)/2);break;case"bottom":o=Math.max(0,this.root.clientHeight-n-t)}let s=0;switch(this.horizontalAlignment){case"left":s=0;break;case"center":s=Math.max(0,(this.root.clientWidth-e)/2);break;case"right":s=Math.max(0,this.root.clientWidth-e)}this.host.style.setProperty("margin-top",`${o}px`,"important"),this.host.style.setProperty("margin-left",`${s}px`,"important"),null!=this.slider&&this.slider.root.style.setProperty("margin-top",`${o+i}px`,"important"),this.root.clientHeight<=n?(this.host.style.setProperty("height",`${this.root.clientHeight}px`),this.host.style.setProperty("overflow-y",null)):this.host.style.setProperty("overflow-y","hidden","important")}}getAlphabetSize(){var t,e;return null!==(e=null===(t=this.unitsHandler)||void 0===t?void 0:t.getAlphabetSize())&&void 0!==e?e:0}sliderOnValuesChanged(t){if(null!=this.host)try{if(this.allowResize&&!this.turnOfResizeForOneSetValue&&this.visibleSlider){const t=Math.ceil(this.slider.max-this.slider.min),e=this.canvas.width/t-this.positionMarginValue;this.positionWidth=e,this._positionWidth=e}this.turnOfResizeForOneSetValue=!1,this.render(!0)}catch(t){const e=(0,m.O)(t);console.error("Bio: WebLogoViewer.sliderOnValuesChanged() error:\n"+e)}}dataFrameFilterOnChanged(t){console.debug("Bio: WebLogoViewer.dataFrameFilterChanged()");try{this.updatePositions(),this.render()}catch(t){const e=(0,m.O)(t);console.error("Bio: WebLogoViewer.dataFrameFilterOnChanged() error:\n"+e)}}dataFrameSelectionOnChanged(t){console.debug("Bio: WebLogoViewer.dataFrameSelectionOnChanged()");try{this.render()}catch(t){const e=(0,m.O)(t);console.error("Bio: WebLogoViewer.dataFrameSelectionOnChanged() error:\n"+e)}}canvasOnMouseMove(t){try{const e=t,n=window.devicePixelRatio,i=this.canvas.getCursorPosition(e,n),[o,s]=this.getMonomer(i);if(this.dataFrame&&this.seqCol&&this.splitter&&s){const t=this.positions[o],n=w(this.dataFrame,this.seqCol,this.filter,this.splitter,s,t),i=r.div([r.div(`${s}`),r.div(`${n} rows`)]);r.tooltip.show(i,e.x+16,e.y+16)}else r.tooltip.hide()}catch(t){const e=(0,m.O)(t);console.error("Bio: WebLogoViewer.canvasOnMouseMove() error:\n"+e)}}canvasOnMouseDown(t){try{const e=t,n=window.devicePixelRatio,[i,o]=this.getMonomer(this.canvas.getCursorPosition(e,n));if(this.dataFrame&&this.seqCol&&this.splitter&&o){const t=this.positions[i],e=a.BitSet.create(this.dataFrame.selection.length,(e=>function(t,e,n,i,o,s,r){if(!n.getSelectedIndexes().includes(i))return!1;const a=e.get(i),l=a?o(a)[r.pos]:null;return l===s||""===l&&"-"===s}(this.dataFrame,this.seqCol,this.filter,e,this.splitter,o,t)));this.dataFrame.selection.init((t=>e.get(t)))}}catch(t){const e=(0,m.O)(t);console.error("Bio: WebLogoViewer.canvasOnMouseDown() error:\n"+e)}}canvasOnWheel(t){try{if(!this.visibleSlider)return;const e=t.deltaY/100*Math.max(Math.floor(this.countOfRenderPositions/2),1);this.slider.scrollBy(this.slider.min+e)}catch(t){const e=(0,m.O)(t);console.error("Bio: WebLogoViewer.canvasOnWheel() error:\n"+e)}}}function w(t,e,n,i,o,s){return h().count(0).take(t.rowCount).filter((t=>n.get(t))).map((t=>{const n=e.get(t),o=n?i(n):[],r=s.pos;return r<o.length?o[r]:null})).toArray().filter((t=>t==o)).reduce(((t,e)=>t+1),0)}y.residuesSet="nucleotides",y.viewerCount=-1},4413:(t,e,n)=>{"use strict";n.d(e,{ST:()=>m});var i=n(3870),o=n(976),s=n(4469),r=n(6414),a=n.n(r),l=n(7983),h=n(701),u=n(4293),c=n(1061);const d=rxjs.operators;var f=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};class m extends o.Filter{get calculating(){return"initial"==this.loader.style.display}set calculating(t){this.loader.style.display=t?"initial":"none"}get filterSummary(){return this.bioFilter.substructure}get isFiltering(){return super.isFiltering&&""!==this.bioFilter.substructure}get isReadyToApplyFilter(){return!this.calculating&&null!=this.bitset}get _debounceTime(){if(null==this.column)return 1e3;const t=this.column.length;return t<500?0:t>1e4?1e3:Math.floor((t-500)/9500*1e3)}constructor(){super(),this.bioFilter=null,this.bitset=null,this.loader=i.loader(),this.notation=void 0,this.root=i.divV([]),this.calculating=!1}attach(t){var e,n,i,s,r;super.attach(t),this.column=t.columns.bySemType(o.SEMTYPE.MACROMOLECULE),null!==(e=this.columnName)&&void 0!==e||(this.columnName=null===(n=this.column)||void 0===n?void 0:n.name),null!==(i=this.notation)&&void 0!==i||(this.notation=null===(s=this.column)||void 0===s?void 0:s.getTag(o.TAGS.UNITS)),this.bioFilter="fasta"===this.notation?new g:"separator"===this.notation?new v(this.column.getTag("separator")):new y,this.root.appendChild(this.bioFilter.filterPanel),this.root.appendChild(this.loader),null===(r=this.onBioFilterChangedSubs)||void 0===r||r.unsubscribe();let a=this.bioFilter.onChanged;a=a.pipe((0,d.debounceTime)(this._debounceTime)),this.onBioFilterChangedSubs=a.subscribe((t=>f(this,void 0,void 0,(function*(){return yield this._onInputChanged()}))))}detach(){super.detach()}applyFilter(){var t;this.bitset&&!this.isDetached&&(null===(t=this.dataFrame)||void 0===t||t.filter.and(this.bitset))}saveState(){var t;const e=super.saveState();return e.bioSubstructure=null===(t=this.bioFilter)||void 0===t?void 0:t.substructure,e}applyState(t){super.applyState(t),t.bioSubstructure&&(this.bioFilter.substructure=t.bioSubstructure);const e=this;t.bioSubstructure&&setTimeout((function(){e._onInputChanged()}),1e3)}_onInputChanged(){var t,e,n;return f(this,void 0,void 0,(function*(){if(this.isFiltering){if(a()(this.dataFrame.rows.filters).has(`${this.columnName}: ${this.filterSummary}`))return;this.calculating=!0;try{this.bitset=yield null===(e=this.bioFilter)||void 0===e?void 0:e.substrucrureSearch(this.column),this.calculating=!1,null===(n=this.dataFrame)||void 0===n||n.rows.requestFilter()}finally{this.calculating=!1}}else this.bitset=null,null===(t=this.dataFrame)||void 0===t||t.rows.requestFilter()}))}}class p{constructor(){this.onChanged=new h.Subject}get filterPanel(){return new HTMLElement}get substructure(){return""}set substructure(t){}substrucrureSearch(t){return f(this,void 0,void 0,(function*(){return null}))}}class g extends p{constructor(){super(),this.substructureInput=i.stringInput("","",(()=>{this.onChanged.next()}),{placeholder:"Substructure"})}get filterPanel(){return this.substructureInput.root}get substructure(){return this.substructureInput.value}set substructure(t){this.substructureInput.value=t}substrucrureSearch(t){return f(this,void 0,void 0,(function*(){return yield(0,l.pf)(this.substructure,t)}))}}class v extends g{constructor(t){super(),this.colSeparator="",this.separatorInput=i.stringInput("","",(()=>{this.onChanged.next()}),{placeholder:"Separator"}),this.colSeparator=t,this.separatorInput.value=t}get filterPanel(){return i.divV([this.substructureInput.root,this.separatorInput.root])}get substructure(){return this.separatorInput.value&&this.separatorInput.value!==this.colSeparator?this.substructureInput.value.replaceAll(this.separatorInput.value,this.colSeparator):this.substructureInput.value}set substructure(t){this.substructureInput.value=t}substrucrureSearch(t){return f(this,void 0,void 0,(function*(){return yield(0,l.pf)(this.substructure,t,this.colSeparator)}))}}class y extends p{constructor(){super(),this._filterPanel=i.div("",{style:{cursor:"pointer"}}),this.helmSubstructure="",this.init()}init(){return f(this,void 0,void 0,(function*(){this.helmEditor=yield s.functions.call("HELM:helmWebEditor"),yield i.tools.waitForElementInDom(this._filterPanel),this.updateFilterPanel(),this._filterPanel.addEventListener("click",(t=>{const{editorDiv:e,webEditor:n}=this.helmEditor.createWebEditor(this.helmSubstructure);i.dialog({showHeader:!1,showFooter:!0}).add(e).onOK((()=>{const t=n.canvas.getHelm(!0).replace(/<\/span>/g,"").replace(/<span style='background:#bbf;'>/g,"");this.helmSubstructure=t,this.updateFilterPanel(this.substructure),setTimeout((()=>{this.onChanged.next()}),10)})).show({modal:!0,fullScreen:!0})})),i.onSizeChanged(this._filterPanel).subscribe((t=>{const e=this.helmEditor.webEditor.canvas.getHelm(!0).replace(/<\/span>/g,"").replace(/<span style='background:#bbf;'>/g,"");this.updateFilterPanel(e)}))}))}get filterPanel(){return this._filterPanel}get substructure(){return this.helmSubstructure}set substructure(t){this.helmEditor.editor.setHelm(t)}updateFilterPanel(t){const e=this._filterPanel.parentElement.clientWidth<100?100:this._filterPanel.parentElement.clientWidth,n=e/2;if(t)(0,u.Y)(this._filterPanel,this.helmEditor.host),this.helmEditor.editor.setHelm(t),this.helmEditor.resizeEditor(e,n);else{const t=i.divText("Click to edit","helm-substructure-filter");(0,u.Y)(this._filterPanel,t)}}substrucrureSearch(t){return f(this,void 0,void 0,(function*(){i.setUpdateIndicator(this._filterPanel,!0),yield(0,c.gw)(10);const e=yield(0,l.QF)(this.substructure,t);return i.setUpdateIndicator(this._filterPanel,!1),e}))}}},9378:function(t,e,n){"use strict";var i=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e.default=t,e};Object.defineProperty(e,"__esModule",{value:!0});var o=i(n(4517));function s(t,e){var n=function(n){return o.empty(t).map((function(){return o.filled(e,n)}))},i=[];return i.push(n(-1)),i.push(n(1/0)),i.push(n(0)),i}function r(t,e,n,i,o){e=Math.floor(e);var s=t[0][e],r=t[1][e];if(t[2][e],n>=r[0])return 0;for(var l=0;l<s.length;l++)if(i===s[l])return 0;return a(t,e,n,i,o)}function a(t,e,n,i,o){var s=t[0][e],r=t[1][e],a=t[2][e];if(n>=r[0])return 0;r[0]=n,s[0]=i,a[0]=o;for(var l=0,h=0;;){var u=2*l+1,c=u+1,d=t[0][0].length;if(u>=d)break;if(c>=d){if(!(r[u]>n))break;h=u}else if(r[u]>=r[c]){if(!(n<r[u]))break;h=u}else{if(!(n<r[c]))break;h=c}r[l]=r[h],s[l]=s[h],a[l]=a[h],l=h}return r[l]=n,s[l]=i,a[l]=o,1}function l(t,e,n,i){for(;2*i+1<n;){var o=2*i+1,s=o+1,r=i;if(t[r]<t[o]&&(r=o),s<n&&t[r]<t[s]&&(r=s),r===i)break;var a=t[i];t[i]=t[r],t[r]=a;var l=e[i];e[i]=e[r],e[r]=l,i=r}}e.makeHeap=s,e.rejectionSample=function(t,e,n){for(var i=o.zeros(t),s=0;s<t;s++){for(var r=!0,a=0;r;){a=o.tauRandInt(e,n);for(var l=!1,h=0;h<s;h++)if(a===i[h]){l=!0;break}l||(r=!1)}i[s]=a}return i},e.heapPush=r,e.uncheckedHeapPush=a,e.buildCandidates=function(t,e,n,i,a){for(var l=s(e,i),h=0;h<e;h++)for(var u=0;u<n;u++)if(!(t[0][h][u]<0)){var c=t[0][h][u],d=t[2][h][u],f=o.tauRand(a);r(l,h,f,c,d),r(l,c,f,h,d),t[2][h][u]=0}return l},e.deheapSort=function(t){for(var e=t[0],n=t[1],i=0;i<e.length;i++)for(var o=e[i],s=n[i],r=0;r<o.length-1;r++){var a=o.length-r-1,h=s.length-r-1,u=o[0];o[0]=o[a],o[a]=u;var c=s[0];s[0]=s[h],s[h]=c,l(s,o,h,0)}return{indices:e,weights:n}},e.smallestFlagged=function(t,e){for(var n=t[0][e],i=t[1][e],o=t[2][e],s=1/0,r=-1,a=0;a>n.length;a++)1===o[a]&&i[a]<s&&(s=i[a],r=a);return r>=0?(o[r]=0,Math.floor(n[r])):-1}},4221:(t,e,n)=>{"use strict";var i=n(4364);e.u=i.UMAP},5686:function(t,e,n){"use strict";var i,o=this&&this.__read||function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var i,o,s=n.call(t),r=[];try{for(;(void 0===e||e-- >0)&&!(i=s.next()).done;)r.push(i.value)}catch(t){o={error:t}}finally{try{i&&!i.done&&(n=s.return)&&n.call(s)}finally{if(o)throw o.error}}return r},s=this&&this.__values||function(t){var e="function"==typeof Symbol&&t[Symbol.iterator],n=0;return e?e.call(t):{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}}},r=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e.default=t,e};Object.defineProperty(e,"__esModule",{value:!0});var a=r(n(4517)),l=function(){function t(t,e,n,i){if(this.entries=new Map,this.nRows=0,this.nCols=0,t.length!==e.length||t.length!==n.length)throw new Error("rows, cols and values arrays must all have the same length");this.nRows=i[0],this.nCols=i[1];for(var o=0;o<n.length;o++){var s=t[o],r=e[o];this.checkDims(s,r);var a=this.makeKey(s,r);this.entries.set(a,{value:n[o],row:s,col:r})}}return t.prototype.makeKey=function(t,e){return t+":"+e},t.prototype.checkDims=function(t,e){if(!(t<this.nRows&&e<this.nCols))throw new Error("row and/or col specified outside of matrix dimensions")},t.prototype.set=function(t,e,n){this.checkDims(t,e);var i=this.makeKey(t,e);this.entries.has(i)?this.entries.get(i).value=n:this.entries.set(i,{value:n,row:t,col:e})},t.prototype.get=function(t,e,n){void 0===n&&(n=0),this.checkDims(t,e);var i=this.makeKey(t,e);return this.entries.has(i)?this.entries.get(i).value:n},t.prototype.getAll=function(t){void 0===t&&(t=!0);var e=[];return this.entries.forEach((function(t){e.push(t)})),t&&e.sort((function(t,e){return t.row===e.row?t.col-e.col:t.row-e.row})),e},t.prototype.getDims=function(){return[this.nRows,this.nCols]},t.prototype.getRows=function(){return Array.from(this.entries,(function(t){var e=o(t,2);return e[0],e[1].row}))},t.prototype.getCols=function(){return Array.from(this.entries,(function(t){var e=o(t,2);return e[0],e[1].col}))},t.prototype.getValues=function(){return Array.from(this.entries,(function(t){var e=o(t,2);return e[0],e[1].value}))},t.prototype.forEach=function(t){this.entries.forEach((function(e){return t(e.value,e.row,e.col)}))},t.prototype.map=function(e){var n=[];this.entries.forEach((function(t){n.push(e(t.value,t.row,t.col))}));var i=[this.nRows,this.nCols];return new t(this.getRows(),this.getCols(),n,i)},t.prototype.toArray=function(){var t=this,e=a.empty(this.nRows).map((function(){return a.zeros(t.nCols)}));return this.entries.forEach((function(t){e[t.row][t.col]=t.value})),e},t}();e.SparseMatrix=l,e.transpose=function(t){var e=[],n=[],i=[];t.forEach((function(t,o,s){e.push(o),n.push(s),i.push(t)}));var o=[t.nCols,t.nRows];return new l(n,e,i,o)},e.identity=function(t){for(var e=o(t,1)[0],n=new l([],[],[],t),i=0;i<e;i++)n.set(i,i,1);return n},e.pairwiseMultiply=function(t,e){return u(t,e,(function(t,e){return t*e}))},e.add=function(t,e){return u(t,e,(function(t,e){return t+e}))},e.subtract=function(t,e){return u(t,e,(function(t,e){return t-e}))},e.maximum=function(t,e){return u(t,e,(function(t,e){return t>e?t:e}))},e.multiplyScalar=function(t,e){return t.map((function(t){return t*e}))},e.eliminateZeros=function(t){for(var e=new Set,n=t.getValues(),i=t.getRows(),o=t.getCols(),s=0;s<n.length;s++)0===n[s]&&e.add(s);var r=function(t,n){return!e.has(n)},a=n.filter(r),h=i.filter(r),u=o.filter(r);return new l(h,u,a,t.getDims())},e.normalize=function(t,e){var n,i;void 0===e&&(e="l2");var o=h[e],r=new Map;t.forEach((function(t,e,n){var i=r.get(e)||[];i.push(n),r.set(e,i)}));var a=new l([],[],[],t.getDims()),u=function(e){for(var n=r.get(e).sort(),i=n.map((function(n){return t.get(e,n)})),s=o(i),l=0;l<s.length;l++)a.set(e,n[l],s[l])};try{for(var c=s(r.keys()),d=c.next();!d.done;d=c.next())u(d.value)}catch(t){n={error:t}}finally{try{d&&!d.done&&(i=c.return)&&i.call(c)}finally{if(n)throw n.error}}return a};var h=((i={}).max=function(t){for(var e=-1/0,n=0;n<t.length;n++)e=t[n]>e?t[n]:e;return t.map((function(t){return t/e}))},i.l1=function(t){for(var e=0,n=0;n<t.length;n++)e+=t[n];return t.map((function(t){return t/e}))},i.l2=function(t){for(var e=0,n=0;n<t.length;n++)e+=Math.pow(t[n],2);return t.map((function(t){return Math.sqrt(Math.pow(t,2)/e)}))},i);function u(t,e,n){for(var i=new Set,o=[],s=[],r=[],a=function(i,a){o.push(i),s.push(a);var l=n(t.get(i,a),e.get(i,a));r.push(l)},h=t.getValues(),u=t.getRows(),c=t.getCols(),d=0;d<h.length;d++){var f=(v=u[d])+":"+(y=c[d]);i.add(f),a(v,y)}var m=e.getValues(),p=e.getRows(),g=e.getCols();for(d=0;d<m.length;d++){var v,y;f=(v=p[d])+":"+(y=g[d]),i.has(f)||a(v,y)}var w=[t.nRows,t.nCols];return new l(o,s,r,w)}e.getCSR=function(t){var e=[];t.forEach((function(t,n,i){e.push({value:t,row:n,col:i})})),e.sort((function(t,e){return t.row===e.row?t.col-e.col:t.row-e.row}));for(var n=[],i=[],o=[],s=-1,r=0;r<e.length;r++){var a=e[r],l=a.row,h=a.col,u=a.value;l!==s&&(s=l,o.push(r)),n.push(h),i.push(u)}return{indices:n,values:i,indptr:o}}},760:function(t,e,n){"use strict";var i=this&&this.__values||function(t){var e="function"==typeof Symbol&&t[Symbol.iterator],n=0;return e?e.call(t):{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}}},o=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e.default=t,e};Object.defineProperty(e,"__esModule",{value:!0});var s=o(n(9378)),r=o(n(5686)),a=o(n(2320)),l=o(n(4517));e.makeNNDescent=function(t,e){return function(n,i,o,r,a,h,u,c){void 0===r&&(r=10),void 0===a&&(a=50),void 0===h&&(h=.001),void 0===u&&(u=.5),void 0===c&&(c=!0);for(var d=n.length,f=s.makeHeap(n.length,o),m=0;m<n.length;m++)for(var p=s.rejectionSample(o,n.length,e),g=0;g<p.length;g++){var v=t(n[m],n[p[g]]);s.heapPush(f,m,v,p[g],1),s.heapPush(f,p[g],v,m,1)}if(c)for(var y=0;y<i.length;y++)for(m=0;m<i[y].length&&!(i[y][m]<0);m++)for(g=m+1;g<i[y].length&&!(i[y][g]<0);g++)v=t(n[i[y][m]],n[i[y][g]]),s.heapPush(f,i[y][m],v,i[y][g],1),s.heapPush(f,i[y][g],v,i[y][m],1);for(y=0;y<r;y++){var w=s.buildCandidates(f,d,o,a,e),b=0;for(m=0;m<d;m++)for(g=0;g<a;g++){var C=Math.floor(w[0][m][g]);if(!(C<0||l.tauRand(e)<u))for(var S=0;S<a;S++){var T=Math.floor(w[0][m][S]),M=w[2][m][g],E=w[2][m][S];T<0||!M&&!E||(v=t(n[C],n[T]),b+=s.heapPush(f,C,v,T,1),b+=s.heapPush(f,T,v,C,1))}}if(b<=h*o*n.length)break}return s.deheapSort(f)}},e.makeInitializations=function(t){return{initFromRandom:function(e,n,i,o,r){for(var a=0;a<i.length;a++)for(var h=l.rejectionSample(e,n.length,r),u=0;u<h.length;u++)if(!(h[u]<0)){var c=t(n[h[u]],i[a]);s.heapPush(o,a,c,h[u],1)}},initFromTree:function(e,n,i,o,r){for(var l=0;l<i.length;l++)for(var h=a.searchFlatTree(i[l],e,r),u=0;u<h.length;u++){if(h[u]<0)return;var c=t(n[h[u]],i[l]);s.heapPush(o,l,c,h[u],1)}}}},e.makeInitializedNNSearch=function(t){return function(e,n,o,a){for(var l,h,u=r.getCSR(n),c=u.indices,d=u.indptr,f=0;f<a.length;f++)for(var m=new Set(o[0][f]);;){var p=s.smallestFlagged(o,f);if(-1===p)break;var g=c.slice(d[p],d[p+1]);try{for(var v=i(g),y=v.next();!y.done;y=v.next()){var w=y.value;if(w!==p&&-1!==w&&!m.has(w)){var b=t(e[w],a[f]);s.uncheckedHeapPush(o,f,b,w,1),m.add(w)}}}catch(t){l={error:t}}finally{try{y&&!y.done&&(h=v.return)&&h.call(v)}finally{if(l)throw l.error}}}return o}},e.initializeSearch=function(t,e,n,o,r,a,l){var h,u,c=s.makeHeap(n.length,o);if(r(o,e,n,c,l),t)try{for(var d=i(t),f=d.next();!f.done;f=d.next())a(f.value,e,n,c,l)}catch(t){h={error:t}}finally{try{f&&!f.done&&(u=d.return)&&u.call(d)}finally{if(h)throw h.error}}return c}},2320:function(t,e,n){"use strict";var i=this&&this.__read||function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var i,o,s=n.call(t),r=[];try{for(;(void 0===e||e-- >0)&&!(i=s.next()).done;)r.push(i.value)}catch(t){o={error:t}}finally{try{i&&!i.done&&(n=s.return)&&n.call(s)}finally{if(o)throw o.error}}return r},o=this&&this.__spread||function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(i(arguments[e]));return t},s=this&&this.__values||function(t){var e="function"==typeof Symbol&&t[Symbol.iterator],n=0;return e?e.call(t):{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}}},r=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e.default=t,e};Object.defineProperty(e,"__esModule",{value:!0});var a=r(n(4517)),l=function(t,e,n,i){this.hyperplanes=t,this.offsets=e,this.children=n,this.indices=i};function h(t,e,n,i,o){if(void 0===n&&(n=30),e.length>n){var s=function(t,e,n){var i=t[0].length,o=a.tauRandInt(e.length,n),s=a.tauRandInt(e.length,n);s=(s+=o===s?1:0)%e.length;for(var r=e[o],l=e[s],h=0,u=a.zeros(i),c=0;c<u.length;c++)u[c]=t[r][c]-t[l][c],h-=u[c]*(t[r][c]+t[l][c])/2;var d=0,f=0,m=a.zeros(e.length);for(c=0;c<e.length;c++){for(var p=h,g=0;g<i;g++)p+=u[g]*t[e[c]][g];0===p?(m[c]=a.tauRandInt(2,n),0===m[c]?d+=1:f+=1):p>0?(m[c]=0,d+=1):(m[c]=1,f+=1)}var v=a.zeros(d),y=a.zeros(f);for(d=0,f=0,c=0;c<m.length;c++)0===m[c]?(v[d]=e[c],d+=1):(y[f]=e[c],f+=1);return{indicesLeft:v,indicesRight:y,hyperplane:u,offset:h}}(t,e,o),r=s.indicesLeft,l=s.indicesRight,u=s.hyperplane,c=s.offset;return{leftChild:h(t,r,n,i+1,o),rightChild:h(t,l,n,i+1,o),isLeaf:!1,hyperplane:u,offset:c}}return{indices:e,isLeaf:!0}}function u(t,e,n,i,s,r,a){var l;if(t.isLeaf)return i[r][0]=-a,(l=s[a]).splice.apply(l,o([0,t.indices.length],t.indices)),{nodeNum:r,leafNum:a+=1};e[r]=t.hyperplane,n[r]=t.offset,i[r][0]=r+1;var h=r,c=u(t.leftChild,e,n,i,s,r+1,a);return r=c.nodeNum,a=c.leafNum,i[h][1]=r+1,{nodeNum:(c=u(t.rightChild,e,n,i,s,r+1,a)).nodeNum,leafNum:c.leafNum}}function c(t){return t.isLeaf?1:1+c(t.leftChild)+c(t.rightChild)}function d(t){return t.isLeaf?1:d(t.leftChild)+d(t.rightChild)}function f(t,e,n,i){for(var o=e,s=0;s<n.length;s++)o+=t[s]*n[s];return 0===o?a.tauRandInt(2,i):o>0?0:1}e.FlatTree=l,e.makeForest=function(t,e,n,i){var o=Math.max(10,e);return a.range(n).map((function(e,n){return function(t,e,n,i){return void 0===e&&(e=30),h(t,a.range(t.length),e,n,i)}(t,o,n,i)})).map((function(t){return function(t,e){var n=c(t),i=d(t),o=a.range(n).map((function(){return a.zeros(t.hyperplane?t.hyperplane.length:0)})),s=a.zeros(n),r=a.range(n).map((function(){return[-1,-1]})),h=a.range(i).map((function(){return a.range(e).map((function(){return-1}))}));return u(t,o,s,r,h,0,0),new l(o,s,r,h)}(t,o)}))},e.makeLeafArray=function(t){var e,n;if(t.length>0){var i=[];try{for(var r=s(t),a=r.next();!a.done;a=r.next()){var l=a.value;i.push.apply(i,o(l.indices))}}catch(t){e={error:t}}finally{try{a&&!a.done&&(n=r.return)&&n.call(r)}finally{if(e)throw e.error}}return i}return[[-1]]},e.searchFlatTree=function(t,e,n){for(var i=0;e.children[i][0]>0;)i=0===f(e.hyperplanes[i],e.offsets[i],t,n)?e.children[i][0]:e.children[i][1];var o=-1*e.children[i][0];return e.indices[o]}},4364:function(t,e,n){"use strict";var i=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){t.done?o(t.value):new n((function(e){e(t.value)})).then(r,a)}l((i=i.apply(t,e||[])).next())}))},o=this&&this.__generator||function(t,e){var n,i,o,s,r={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;r;)try{if(n=1,i&&(o=2&s[0]?i.return:s[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,s[1])).done)return o;switch(i=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return r.label++,{value:s[1],done:!1};case 5:r.label++,i=s[1],s=[0];continue;case 7:s=r.ops.pop(),r.trys.pop();continue;default:if(!((o=(o=r.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){r=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){r.label=s[1];break}if(6===s[0]&&r.label<o[1]){r.label=o[1],o=s;break}if(o&&r.label<o[2]){r.label=o[2],r.ops.push(s);break}o[2]&&r.ops.pop(),r.trys.pop();continue}s=e.call(t,r)}catch(t){s=[6,t],i=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,a])}}},s=this&&this.__read||function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var i,o,s=n.call(t),r=[];try{for(;(void 0===e||e-- >0)&&!(i=s.next()).done;)r.push(i.value)}catch(t){o={error:t}}finally{try{i&&!i.done&&(n=s.return)&&n.call(s)}finally{if(o)throw o.error}}return r},r=this&&this.__spread||function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(s(arguments[e]));return t},a=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e.default=t,e},l=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});var h=a(n(9378)),u=a(n(5686)),c=a(n(760)),d=a(n(2320)),f=a(n(4517)),m=l(n(9251)),p=1e-5,g=.001,v=function(){function t(t){void 0===t&&(t={});var e=this;this.learningRate=1,this.localConnectivity=1,this.minDist=.1,this.nComponents=2,this.nEpochs=0,this.nNeighbors=15,this.negativeSampleRate=5,this.random=Math.random,this.repulsionStrength=1,this.setOpMixRatio=1,this.spread=1,this.transformQueueSize=4,this.targetMetric="categorical",this.targetWeight=.5,this.targetNNeighbors=this.nNeighbors,this.distanceFn=y,this.isInitialized=!1,this.rpForest=[],this.embedding=[],this.optimizationState=new w;var n=function(n){void 0!==t[n]&&(e[n]=t[n])};n("distanceFn"),n("learningRate"),n("localConnectivity"),n("minDist"),n("nComponents"),n("nEpochs"),n("nNeighbors"),n("negativeSampleRate"),n("random"),n("repulsionStrength"),n("setOpMixRatio"),n("spread"),n("transformQueueSize")}return t.prototype.fit=function(t){return this.initializeFit(t),this.optimizeLayout(),this.embedding},t.prototype.fitAsync=function(t,e){return void 0===e&&(e=function(){return!0}),i(this,void 0,void 0,(function(){return o(this,(function(n){switch(n.label){case 0:return this.initializeFit(t),[4,this.optimizeLayoutAsync(e)];case 1:return n.sent(),[2,this.embedding]}}))}))},t.prototype.setSupervisedProjection=function(t,e){void 0===e&&(e={}),this.Y=t,this.targetMetric=e.targetMetric||this.targetMetric,this.targetWeight=e.targetWeight||this.targetWeight,this.targetNNeighbors=e.targetNNeighbors||this.targetNNeighbors},t.prototype.setPrecomputedKNN=function(t,e){this.knnIndices=t,this.knnDistances=e},t.prototype.initializeFit=function(t){if(t.length<=this.nNeighbors)throw new Error("Not enough data points ("+t.length+") to create nNeighbors: "+this.nNeighbors+". Add more data points or adjust the configuration.");if(this.X===t&&this.isInitialized)return this.getNEpochs();if(this.X=t,!this.knnIndices&&!this.knnDistances){var e=this.nearestNeighbors(t);this.knnIndices=e.knnIndices,this.knnDistances=e.knnDistances}this.graph=this.fuzzySimplicialSet(t,this.nNeighbors,this.setOpMixRatio),this.makeSearchFns(),this.searchGraph=this.makeSearchGraph(t),this.processGraphForSupervisedProjection();var n=this.initializeSimplicialSetEmbedding(),i=n.head,o=n.tail,s=n.epochsPerSample;return this.optimizationState.head=i,this.optimizationState.tail=o,this.optimizationState.epochsPerSample=s,this.initializeOptimization(),this.prepareForOptimizationLoop(),this.isInitialized=!0,this.getNEpochs()},t.prototype.makeSearchFns=function(){var t=c.makeInitializations(this.distanceFn),e=t.initFromTree,n=t.initFromRandom;this.initFromTree=e,this.initFromRandom=n,this.search=c.makeInitializedNNSearch(this.distanceFn)},t.prototype.makeSearchGraph=function(t){for(var e=this.knnIndices,n=this.knnDistances,i=[t.length,t.length],o=new u.SparseMatrix([],[],[],i),s=0;s<e.length;s++)for(var r=e[s],a=n[s],l=0;l<r.length;l++){var h=r[l],c=a[l];c>0&&o.set(s,h,c)}var d=u.transpose(o);return u.maximum(o,d)},t.prototype.transform=function(t){var e=this,n=this.X;if(void 0===n||0===n.length)throw new Error("No data has been fit.");var i=Math.floor(this.nNeighbors*this.transformQueueSize);i=Math.min(n.length,i);var o=c.initializeSearch(this.rpForest,n,t,i,this.initFromRandom,this.initFromTree,this.random),s=this.search(n,this.searchGraph,o,t),r=h.deheapSort(s),a=r.indices,l=r.weights;a=a.map((function(t){return t.slice(0,e.nNeighbors)})),l=l.map((function(t){return t.slice(0,e.nNeighbors)}));var d=Math.max(0,this.localConnectivity-1),m=this.smoothKNNDistance(l,this.nNeighbors,d),p=m.sigmas,g=m.rhos,v=this.computeMembershipStrengths(a,l,p,g),y=v.rows,w=v.cols,b=v.vals,C=[t.length,n.length],S=new u.SparseMatrix(y,w,b,C),T=u.normalize(S,"l1"),M=u.getCSR(T),A=t.length,R=E(f.reshape2d(M.indices,A,this.nNeighbors),f.reshape2d(M.values,A,this.nNeighbors),this.embedding),P=this.nEpochs?this.nEpochs/3:S.nRows<=1e4?100:30,N=S.getValues().reduce((function(t,e){return e>t?e:t}),0);S=S.map((function(t){return t<N/P?0:t})),S=u.eliminateZeros(S);var x=this.makeEpochsPerSample(S.getValues(),P),L=S.getRows(),G=S.getCols();return this.assignOptimizationStateParameters({headEmbedding:R,tailEmbedding:this.embedding,head:L,tail:G,currentEpoch:0,nEpochs:P,nVertices:S.getDims()[1],epochsPerSample:x}),this.prepareForOptimizationLoop(),this.optimizeLayout()},t.prototype.processGraphForSupervisedProjection=function(){var t=this.Y,e=this.X;if(t){if(t.length!==e.length)throw new Error("Length of X and y must be equal");if("categorical"===this.targetMetric){var n=this.targetWeight<1?1/(1-this.targetWeight)*2.5:1e12;this.graph=this.categoricalSimplicialSetIntersection(this.graph,t,n)}}},t.prototype.step=function(){var t=this.optimizationState.currentEpoch;return t<this.getNEpochs()&&this.optimizeLayoutStep(t),this.optimizationState.currentEpoch},t.prototype.getEmbedding=function(){return this.embedding},t.prototype.nearestNeighbors=function(t){var e,n=this.distanceFn,i=this.nNeighbors,o=c.makeNNDescent(n,this.random),s=5+Math.floor(.5==(e=Math.pow(t.length,.5)/20)?0:Math.round(e)),r=Math.max(5,Math.floor(Math.round(function(t){return Math.log(t)/Math.log(2)}(t.length))));this.rpForest=d.makeForest(t,i,s,this.random);var a=o(t,d.makeLeafArray(this.rpForest),i,r);return{knnIndices:a.indices,knnDistances:a.weights}},t.prototype.fuzzySimplicialSet=function(t,e,n){void 0===n&&(n=1);var i=this,o=i.knnIndices,s=void 0===o?[]:o,r=i.knnDistances,a=void 0===r?[]:r,l=i.localConnectivity,h=this.smoothKNNDistance(a,e,l),c=h.sigmas,d=h.rhos,f=this.computeMembershipStrengths(s,a,c,d),m=f.rows,p=f.cols,g=f.vals,v=[t.length,t.length],y=new u.SparseMatrix(m,p,g,v),w=u.transpose(y),b=u.pairwiseMultiply(y,w),C=u.subtract(u.add(y,w),b),S=u.multiplyScalar(C,n),T=u.multiplyScalar(b,1-n);return u.add(S,T)},t.prototype.categoricalSimplicialSetIntersection=function(t,e,n,i){void 0===i&&(i=1);var o=T(t,e,i,n);return M(o=u.eliminateZeros(o))},t.prototype.smoothKNNDistance=function(t,e,n,i,o){void 0===n&&(n=1),void 0===i&&(i=64),void 0===o&&(o=1);for(var s=Math.log(e)/Math.log(2)*o,r=f.zeros(t.length),a=f.zeros(t.length),l=0;l<t.length;l++){var h=0,u=1/0,c=1,d=t[l],m=d.filter((function(t){return t>0}));if(m.length>=n){var v=Math.floor(n),y=n-v;v>0?(r[l]=m[v-1],y>p&&(r[l]+=y*(m[v]-m[v-1]))):r[l]=y*m[0]}else m.length>0&&(r[l]=f.max(m));for(var w=0;w<i;w++){for(var b=0,C=1;C<t[l].length;C++){var S=t[l][C]-r[l];b+=S>0?Math.exp(-S/c):1}if(Math.abs(b-s)<p)break;b>s?c=(h+(u=c))/2:(h=c,u===1/0?c*=2:c=(h+u)/2)}if(a[l]=c,r[l]>0){var T=f.mean(d);a[l]<g*T&&(a[l]=g*T)}else{var M=f.mean(t.map(f.mean));a[l]<g*M&&(a[l]=g*M)}}return{sigmas:a,rhos:r}},t.prototype.computeMembershipStrengths=function(t,e,n,i){for(var o=t.length,s=t[0].length,r=f.zeros(o*s),a=f.zeros(o*s),l=f.zeros(o*s),h=0;h<o;h++)for(var u=0;u<s;u++){var c=0;-1!==t[h][u]&&(c=t[h][u]===h?0:e[h][u]-i[h]<=0?1:Math.exp(-(e[h][u]-i[h])/n[h]),r[h*s+u]=h,a[h*s+u]=t[h][u],l[h*s+u]=c)}return{rows:r,cols:a,vals:l}},t.prototype.initializeSimplicialSetEmbedding=function(){for(var t=this,e=this.getNEpochs(),n=this.nComponents,i=this.graph.getValues(),o=0,s=0;s<i.length;s++){var r=i[s];o<i[s]&&(o=r)}var a=this.graph.map((function(t){return t<o/e?0:t}));this.embedding=f.zeros(a.nRows).map((function(){return f.zeros(n).map((function(){return 20*f.tauRand(t.random)-10}))}));var l=[],h=[],u=[],c=a.getAll();for(s=0;s<c.length;s++){var d=c[s];d.value&&(l.push(d.value),u.push(d.row),h.push(d.col))}return{head:h,tail:u,epochsPerSample:this.makeEpochsPerSample(l,e)}},t.prototype.makeEpochsPerSample=function(t,e){var n=f.filled(t.length,-1),i=f.max(t),o=t.map((function(t){return t/i*e}));return o.forEach((function(t,i){t>0&&(n[i]=e/o[i])})),n},t.prototype.assignOptimizationStateParameters=function(t){Object.assign(this.optimizationState,t)},t.prototype.prepareForOptimizationLoop=function(){var t=this,e=t.repulsionStrength,n=t.learningRate,i=t.negativeSampleRate,o=this.optimizationState,s=o.epochsPerSample,a=o.headEmbedding,l=o.tailEmbedding,h=a[0].length,u=a.length===l.length,c=s.map((function(t){return t/i})),d=r(c),f=r(s);this.assignOptimizationStateParameters({epochOfNextSample:f,epochOfNextNegativeSample:d,epochsPerNegativeSample:c,moveOther:u,initialAlpha:n,alpha:n,gamma:e,dim:h})},t.prototype.initializeOptimization=function(){var t=this.embedding,e=this.embedding,n=this.optimizationState,i=n.head,o=n.tail,s=n.epochsPerSample,r=this.getNEpochs(),a=this.graph.nCols,l=S(this.spread,this.minDist),h=l.a,u=l.b;this.assignOptimizationStateParameters({headEmbedding:t,tailEmbedding:e,head:i,tail:o,epochsPerSample:s,a:h,b:u,nEpochs:r,nVertices:a})},t.prototype.optimizeLayoutStep=function(t){for(var e=this.optimizationState,n=e.head,i=e.tail,o=e.headEmbedding,s=e.tailEmbedding,r=e.epochsPerSample,a=e.epochOfNextSample,l=e.epochOfNextNegativeSample,h=e.epochsPerNegativeSample,u=e.moveOther,c=e.initialAlpha,d=e.alpha,m=e.gamma,p=e.a,g=e.b,v=e.dim,y=e.nEpochs,w=e.nVertices,S=0;S<r.length;S++)if(!(a[S]>t)){var T=n[S],M=i[S],E=o[T],A=s[M],R=C(E,A),P=0;R>0&&(P=-2*p*g*Math.pow(R,g-1),P/=p*Math.pow(R,g)+1);for(var N=0;N<v;N++){var x=b(P*(E[N]-A[N]),4);E[N]+=x*d,u&&(A[N]+=-x*d)}a[S]+=r[S];for(var L=Math.floor((t-l[S])/h[S]),G=0;G<L;G++){var _=f.tauRandInt(w,this.random),I=s[_],W=C(E,I),F=0;if(W>0)F=2*m*g,F/=(.001+W)*(p*Math.pow(W,g)+1);else if(T===_)continue;for(N=0;N<v;N++)x=4,F>0&&(x=b(F*(E[N]-I[N]),4)),E[N]+=x*d}l[S]+=L*h[S]}return e.alpha=c*(1-t/y),e.currentEpoch+=1,o},t.prototype.optimizeLayoutAsync=function(t){var e=this;return void 0===t&&(t=function(){return!0}),new Promise((function(n,s){var r=function(){return i(e,void 0,void 0,(function(){var e,i,a,l,h,u;return o(this,(function(o){try{if(e=this.optimizationState,i=e.nEpochs,a=e.currentEpoch,this.embedding=this.optimizeLayoutStep(a),l=this.optimizationState.currentEpoch,h=!1===t(l),u=l===i,h||u)return[2,n(u)];setTimeout((function(){return r()}),0)}catch(t){s(t)}return[2]}))}))};setTimeout((function(){return r()}),0)}))},t.prototype.optimizeLayout=function(t){void 0===t&&(t=function(){return!0});for(var e=!1,n=[];!e;){var i=this.optimizationState,o=i.nEpochs,s=i.currentEpoch;n=this.optimizeLayoutStep(s);var r=this.optimizationState.currentEpoch,a=!1===t(r);e=r===o||a}return n},t.prototype.getNEpochs=function(){var t=this.graph;if(this.nEpochs>0)return this.nEpochs;var e=t.nRows;return e<=2500?500:e<=5e3?400:e<=7500?300:200},t}();function y(t,e){for(var n=0,i=0;i<t.length;i++)n+=Math.pow(t[i]-e[i],2);return Math.sqrt(n)}e.UMAP=v,e.euclidean=y,e.cosine=function(t,e){for(var n=0,i=0,o=0,s=0;s<t.length;s++)n+=t[s]*e[s],i+=Math.pow(t[s],2),o+=Math.pow(e[s],2);return 0===i&&0===o?0:0===i||0===o?1:1-n/Math.sqrt(i*o)};var w=function(){this.currentEpoch=0,this.headEmbedding=[],this.tailEmbedding=[],this.head=[],this.tail=[],this.epochsPerSample=[],this.epochOfNextSample=[],this.epochOfNextNegativeSample=[],this.epochsPerNegativeSample=[],this.moveOther=!0,this.initialAlpha=1,this.alpha=1,this.gamma=1,this.a=1.5769434603113077,this.b=.8950608779109733,this.dim=2,this.nEpochs=500,this.nVertices=0};function b(t,e){return t>e?e:t<-e?-e:t}function C(t,e){for(var n=0,i=0;i<t.length;i++)n+=Math.pow(t[i]-e[i],2);return n}function S(t,e){var n=f.linear(0,3*t,300).map((function(t){return t<e?1:t})),i=f.zeros(n.length).map((function(i,o){return n[o]>=e?Math.exp(-(n[o]-e)/t):i})),o={x:n,y:i},r=m.default(o,(function(t){var e=s(t,2),n=e[0],i=e[1];return function(t){return 1/(1+n*Math.pow(t,2*i))}}),{damping:1.5,initialValues:[.5,.5],gradientDifference:.1,maxIterations:100,errorTolerance:.01}).parameterValues,a=s(r,2);return{a:a[0],b:a[1]}}function T(t,e,n,i){return void 0===n&&(n=1),void 0===i&&(i=5),t.map((function(t,o,s){return-1===e[o]||-1===e[s]?t*Math.exp(-n):e[o]!==e[s]?t*Math.exp(-i):t}))}function M(t){t=u.normalize(t,"max");var e=u.transpose(t),n=u.pairwiseMultiply(e,t);return t=u.add(t,u.subtract(e,n)),u.eliminateZeros(t)}function E(t,e,n){for(var i=f.zeros(t.length).map((function(t){return f.zeros(n[0].length)})),o=0;o<t.length;o++)for(var s=0;s<t[0].length;s++)for(var r=0;r<n[0].length;r++){var a=t[o][s];i[o][r]+=e[o][s]*n[a][r]}return i}e.findABParams=S,e.fastIntersection=T,e.resetLocalConnectivity=M,e.initTransform=E},4517:function(t,e){"use strict";var n=this&&this.__values||function(t){var e="function"==typeof Symbol&&t[Symbol.iterator],n=0;return e?e.call(t):{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}}};function i(t,e){return Math.floor(e()*t)}function o(t){for(var e=[],n=0;n<t;n++)e.push(void 0);return e}function s(t,e){return o(t).map((function(){return e}))}function r(t){return s(t,0)}function a(t){return t.reduce((function(t,e){return t+e}))}Object.defineProperty(e,"__esModule",{value:!0}),e.tauRandInt=i,e.tauRand=function(t){return t()},e.norm=function(t){var e,i,o=0;try{for(var s=n(t),r=s.next();!r.done;r=s.next()){var a=r.value;o+=Math.pow(a,2)}}catch(t){e={error:t}}finally{try{r&&!r.done&&(i=s.return)&&i.call(s)}finally{if(e)throw e.error}}return Math.sqrt(o)},e.empty=o,e.range=function(t){return o(t).map((function(t,e){return e}))},e.filled=s,e.zeros=r,e.ones=function(t){return s(t,1)},e.linear=function(t,e,n){return o(n).map((function(i,o){return t+o*((e-t)/(n-1))}))},e.sum=a,e.mean=function(t){return a(t)/t.length},e.max=function(t){for(var e=0,n=0;n<t.length;n++)e=t[n]>e?t[n]:e;return e},e.max2d=function(t){for(var e=0,n=0;n<t.length;n++)for(var i=0;i<t[n].length;i++)e=t[n][i]>e?t[n][i]:e;return e},e.rejectionSample=function(t,e,n){for(var o=r(t),s=0;s<t;s++)for(var a=!0;a;){for(var l=i(e,n),h=!1,u=0;u<s;u++)if(l===o[u]){h=!0;break}h||(a=!1),o[s]=l}return o},e.reshape2d=function(t,e,n){var i=[],o=0;if(t.length!==e*n)throw new Error("Array dimensions must match input length.");for(var s=0;s<e;s++){for(var r=[],a=0;a<n;a++)r.push(t[o]),o+=1;i.push(r)}return i}},3336:t=>{"use strict";t.exports=$},976:t=>{"use strict";t.exports=DG},4469:t=>{"use strict";t.exports=grok},701:t=>{"use strict";t.exports=rxjs},3870:t=>{"use strict";t.exports=ui},6414:t=>{"use strict";t.exports=wu}},e={};function n(i){var o=e[i];if(void 0!==o)return o.exports;var s=e[i]={id:i,exports:{}};return t[i].call(s.exports,s,s.exports,n),s.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var i in e)n.o(e,i)&&!n.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.nc=void 0;var i={};(()=>{"use strict";n.r(i),n.d(i,{_package:()=>ut,test:()=>ct,tests:()=>e.QK});var t=n(976),e=n(1061);(0,e.W3)("_first",(()=>{(0,e.Bu)("_first",(()=>{return t=void 0,e=void 0,i=function*(){},new((n=void 0)||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}));var t,e,n,i}))}));var o=n(2012),s=n(9976),r=n(6137),a=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))},l=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};(0,e.W3)("Palettes",(()=>{(0,e.Bu)("testPaletteN",(()=>l(void 0,void 0,void 0,(function*(){yield function(){return a(this,void 0,void 0,(function*(){const t=r.J.Chromatogram;(0,e.l_)(t instanceof s.B,!0),(0,e.l_)(t instanceof r.J,!0)}))}()})))),(0,e.Bu)("testPaletteAA",(()=>l(void 0,void 0,void 0,(function*(){yield function(){return a(this,void 0,void 0,(function*(){const t=o.f.Lesk,n=o.f.RasMol,i=o.f.GrokGroups;(0,e.l_)(t instanceof s.B,!0),(0,e.l_)(n instanceof s.B,!0),(0,e.l_)(i instanceof s.B,!0),(0,e.l_)(t instanceof o.f,!0),(0,e.l_)(n instanceof o.f,!0),(0,e.l_)(i instanceof o.f,!0)}))}()})))),(0,e.Bu)("testPalettePtMe",(()=>l(void 0,void 0,void 0,(function*(){const t=o.f.GrokGroups.get("MeNle"),n=o.f.GrokGroups.get("MeA"),i=o.f.GrokGroups.get("MeG"),s=o.f.GrokGroups.get("MeF"),r=o.f.GrokGroups.get("L"),a=o.f.GrokGroups.get("A"),l=o.f.GrokGroups.get("G"),h=o.f.GrokGroups.get("F");(0,e.l_)(t,r),(0,e.l_)(n,a),(0,e.l_)(i,l),(0,e.l_)(s,h)}))))}));var h=n(4469),u=n(7399),c=n(499),d=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};function f(e,n){return d(this,void 0,void 0,(function*(){const i=(yield e()).getCol(n),o=yield h.functions.call("Bio:detectMacromolecule",{col:i});if(o&&(i.semType=o),i.semType===t.SEMTYPE.MACROMOLECULE){const e=`Negative test detected semType='${i.semType}', units='${i.getTag(t.TAGS.UNITS)}'.`;throw new Error(e)}}))}function m(n,i,o,s,r,a,l,u=null){return d(this,void 0,void 0,(function*(){const d=(yield n()).col(i),f=yield h.functions.call("Bio:detectMacromolecule",{col:d});f&&(d.semType=f),(0,e.l_)(d.semType,t.SEMTYPE.MACROMOLECULE),(0,e.l_)(d.getTag(t.TAGS.UNITS),o),(0,e.l_)(d.getTag("aligned"),s),(0,e.l_)(d.getTag("alphabet"),r),u&&(0,e.l_)(d.getTag("separator"),u);const m=new c.C(d);(0,e.l_)(m.getAlphabetSize(),a),(0,e.l_)(m.getAlphabetIsMultichar(),l),m.isHelm()||((0,e.l_)(m.aligned,s),(0,e.l_)(m.alphabet,r))}))}(0,e.W3)("detectors",(()=>{var n,i,o,s,r,a,l,u,c,v,y,w,b,C,S,T,M,E;const A=new(E=class{constructor(){this[n]="id,col1\n1,\n2,\n3,\n4,\n5,",this[i]="col1\n1\n2\n3",this[o]="col1\n4\n5\n6\n7",this[s]="col1\n8\n9\n10\n11\n12",this[r]="col1\nCCCCN1C(=O)CN=C(c2cc(F)ccc12)C3CCCCC3\nC1CCCCC1\nCCCCCC\n",this[a]="seq\nACGTC\nCAGTGT\nTTCAAC\n",this[l]="seq\nACGUC\nCAGUGU\nUUCAAC\n",this[u]="seq\nFWPHEY\nYNRQWYV\nMKPSEYV\n",this[c]="seq\n[meI][hHis][Aca]NT[dE][Thr_PO3H2][Aca]D\n[meI][hHis][Aca][Cys_SEt]T[dK][Thr_PO3H2][Aca][Tyr_PO3H2]\n[Lys_Boc][hHis][Aca][Cys_SEt]T[dK][Thr_PO3H2][Aca][Tyr_PO3H2]\n",this[v]="seq\nA*C*G*T*C\nC*A*G*T*G*T\nT*T*C*A*A*C\n",this[y]="seq\nA*C*G*U*C\nC*A*G*U*G*U\nU*U*C*A*A*C\n",this[w]="seq\nF-W-P-H-E-Y\nY-N-R-Q-W-Y-V\nM-K-P-S-E-Y-V\n",this[b]="seq\nabc-dfgg-abc1-cfr3-rty-wert\nrut12-her2-rty-wert-abc-abc1-dfgg\nrut12-rty-her2-abc-cfr3-wert-rut12\n",this[C]="seq\nabc/dfgg/abc1/cfr3/rty/wert\nrut12/her2/rty/wert//abc/abc1/dfgg\nrut12/rty/her2/abc/cfr3//wert/rut12\n",this[S]="seq\nA-C--G-T--C-T\nC-A-C--T--G-T\nA-C-C-G-T-A-C-T\n",this[T]="seq\nAC-GT-CT\nCAC-T-GT\nACCGTACT\n",this[M]="seq\nFWR-WYV-KHP\nYNR-WYV-KHP\nMWRSWY-CKHP\n"}},n="negEmpty",i="neg1",o="neg2",s="neg3",r="negSmiles",a="csvFastaDna1",l="fastaRna1",u="fastaPt1",c="fastaUn",v="sepDna",y="sepRna",w="sepPt",b="sepUn1",C="sepUn2",S="sepMsaDna1",T="fastaMsaDna1",M="fastaMsaPt1",E),R={fastaFasta:"System:AppData/Bio/data/sample_FASTA.fasta",fastaPtCsv:"System:AppData/Bio/data/sample_FASTA_PT.csv",msaComplex:"System:AppData/Bio/samples/sample_MSA.csv",fastaCsv:"System:AppData/Bio/samples/sample_FASTA.csv",helmCsv:"System:AppData/Bio/samples/sample_HELM.csv",peptidesComplex:"System:AppData/Bio/tests/peptides_complex_msa.csv",peptidesSimple:"System:AppData/Bio/tests/peptides_simple_msa.csv",testDemogCsv:"System:AppData/Bio/tests/testDemog.csv",testHelmCsv:"System:AppData/Bio/tests/testHelm.csv",testIdCsv:"System:AppData/Bio/tests/testId.csv",testSmilesCsv:"System:AppData/Bio/tests/testSmiles.csv",testSmiles2Csv:"System:AppData/Bio/tests/testSmiles2.csv",testSmilesShort:"System:AppData/Bio/tests/testSmilesShort.csv",testActivityCliffsCsv:"System:AppData/Bio/tests/testActivityCliffs.csv",testCerealCsv:"System:AppData/Bio/tests/testCereal.csv",testUnichemSources:"System:AppData/Bio/tests/testUnichemSources.csv",testDmvOffices:"System:AppData/Bio/tests/testDmvOffices.csv",testAlertCollection:"System:AppData/Bio/tests/testAlertCollection.csv",testSpgi100:"System:AppData/Bio/tests/testSpgi100.csv",testSpgi:"System:AppData/Bio/tests/SPGI-derived.csv",testUrl:"System:AppData/Bio/tests/testUrl.csv"},P={};function N(t,e=x){return()=>d(this,void 0,void 0,(function*(){return t in P||(P[t]=(()=>d(this,void 0,void 0,(function*(){return yield e(R[t])})))()),P[t]}))}function x(e){return d(this,void 0,void 0,(function*(){const n=yield h.dapi.files.readAsText(e);return t.DataFrame.fromCsv(n)}))}const L=e=>()=>d(void 0,void 0,void 0,(function*(){const n=A[e],i=t.DataFrame.fromCsv(n);return yield h.data.detectSemanticTypes(i),i}));(0,e.Bu)("NegativeEmpty",(()=>d(void 0,void 0,void 0,(function*(){yield f(L("negEmpty"),"col1")})))),(0,e.Bu)("Negative1",(()=>d(void 0,void 0,void 0,(function*(){yield f(L("neg1"),"col1")})))),(0,e.Bu)("Negative2",(()=>d(void 0,void 0,void 0,(function*(){yield f(L("neg2"),"col1")})))),(0,e.Bu)("Negative3",(()=>d(void 0,void 0,void 0,(function*(){yield f(L("neg3"),"col1")})))),(0,e.Bu)("NegativeSmiles",(()=>d(void 0,void 0,void 0,(function*(){yield f(L("negSmiles"),"col1")})))),(0,e.Bu)("FastaDna1",(()=>d(void 0,void 0,void 0,(function*(){yield m(L("csvFastaDna1"),"seq","fasta","SEQ","DNA",4,!1)})))),(0,e.Bu)("FastaRna1",(()=>d(void 0,void 0,void 0,(function*(){yield m(L("fastaRna1"),"seq","fasta","SEQ","RNA",4,!1)})))),(0,e.Bu)("FastaPt1",(()=>d(void 0,void 0,void 0,(function*(){yield m(L("fastaPt1"),"seq","fasta","SEQ","PT",20,!1)})))),(0,e.Bu)("FastaUn",(()=>d(void 0,void 0,void 0,(function*(){yield m(L("fastaUn"),"seq","fasta","SEQ.MSA","UN",12,!0)})))),(0,e.Bu)("FastaMsaDna1",(()=>d(void 0,void 0,void 0,(function*(){yield m(L("fastaMsaDna1"),"seq","fasta","SEQ.MSA","DNA",4,!1)})))),(0,e.Bu)("FastaMsaPt1",(()=>d(void 0,void 0,void 0,(function*(){yield m(L("fastaMsaPt1"),"seq","fasta","SEQ.MSA","PT",20,!1)})))),(0,e.Bu)("SepDna",(()=>d(void 0,void 0,void 0,(function*(){yield m(L("sepDna"),"seq","separator","SEQ","DNA",4,!1,"*")})))),(0,e.Bu)("SepRna",(()=>d(void 0,void 0,void 0,(function*(){yield m(L("sepRna"),"seq","separator","SEQ","RNA",4,!1,"*")})))),(0,e.Bu)("SepPt",(()=>d(void 0,void 0,void 0,(function*(){yield m(L("sepPt"),"seq","separator","SEQ","PT",20,!1,"-")})))),(0,e.Bu)("SepUn1",(()=>d(void 0,void 0,void 0,(function*(){yield m(L("sepUn1"),"seq","separator","SEQ","UN",8,!0,"-")})))),(0,e.Bu)("SepUn2",(()=>d(void 0,void 0,void 0,(function*(){yield m(L("sepUn2"),"seq","separator","SEQ","UN",9,!0,"/")})))),(0,e.Bu)("SepMsaN1",(()=>d(void 0,void 0,void 0,(function*(){yield m(L("sepMsaDna1"),"seq","separator","SEQ.MSA","DNA",4,!1,"-")})))),(0,e.Bu)("samplesFastaCsv",(()=>d(void 0,void 0,void 0,(function*(){yield g(N("fastaCsv"),{Sequence:new p("fasta","SEQ","PT",20,!1)})})))),(0,e.Bu)("samplesFastaFasta",(()=>d(void 0,void 0,void 0,(function*(){yield g(N("fastaFasta"),{sequence:new p("fasta","SEQ","PT",20,!1)})})))),(0,e.Bu)("samplesPeptidesComplex",(()=>d(void 0,void 0,void 0,(function*(){yield g(N("peptidesComplex"),{})})))),(0,e.Bu)("samplesMsaComplex",(()=>d(void 0,void 0,void 0,(function*(){yield g(N("msaComplex"),{MSA:new p("separator","SEQ.MSA","UN",161,!0,"/")})})))),(0,e.Bu)("samplesIdCsv",(()=>d(void 0,void 0,void 0,(function*(){yield g(N("testIdCsv"),{})})))),(0,e.Bu)("samplesSarSmallCsv",(()=>d(void 0,void 0,void 0,(function*(){yield g(N("testSmilesCsv"),{})})))),(0,e.Bu)("samplesHelmCsv",(()=>d(void 0,void 0,void 0,(function*(){yield g(N("helmCsv"),{HELM:new p("helm",null,null,160,!0)})})))),(0,e.Bu)("samplesTestHelmCsv",(()=>d(void 0,void 0,void 0,(function*(){yield g(N("testHelmCsv"),{"HELM string":new p("helm",null,null,9,!0)})})))),(0,e.Bu)("samplesTestDemogCsv",(()=>d(void 0,void 0,void 0,(function*(){yield g(N("testDemogCsv"),{})})))),(0,e.Bu)("samplesTestSmiles2Csv",(()=>d(void 0,void 0,void 0,(function*(){yield g(N("testSmiles2Csv"),{})})))),(0,e.Bu)("samplesTestSmilesShort",(()=>d(void 0,void 0,void 0,(function*(){yield g(N("testSmilesShort"),{})})))),(0,e.Bu)("samplesTestActivityCliffsNegativeSmiles",(()=>d(void 0,void 0,void 0,(function*(){yield g(N("testActivityCliffsCsv"),{})})))),(0,e.Bu)("samplesFastaPtCsv",(()=>d(void 0,void 0,void 0,(function*(){yield g(N("fastaPtCsv"),{sequence:new p("fasta","SEQ","PT",20,!1)})})))),(0,e.Bu)("samplesTestCerealCsv",(()=>d(void 0,void 0,void 0,(function*(){yield g(N("testCerealCsv"),{})})))),(0,e.Bu)("samplesTestUnichemSources",(()=>d(void 0,void 0,void 0,(function*(){yield g(N("testUnichemSources"),{})})))),(0,e.Bu)("samplesTestDmvOffices",(()=>d(void 0,void 0,void 0,(function*(){yield g(N("testDmvOffices"),{})})))),(0,e.Bu)("samplesTestAlertCollection",(()=>d(void 0,void 0,void 0,(function*(){yield g(N("testAlertCollection"),{})})))),(0,e.Bu)("samplesTestSpgi",(()=>d(void 0,void 0,void 0,(function*(){yield g(N("testSpgi"),{})})))),(0,e.Bu)("samplesTestSpgi100",(()=>d(void 0,void 0,void 0,(function*(){yield g(N("testSpgi100"),{})})))),(0,e.Bu)("samplesTestUrl",(()=>d(void 0,void 0,void 0,(function*(){yield g(N("testUrl"),{})}))))}));class p{constructor(t,e,n,i,o,s){this.units=t,this.aligned=e,this.alphabet=n,this.alphabetSize=i,this.alphabetIsMultichar=o,this.separator=s}}function g(t,e){return d(this,void 0,void 0,(function*(){const n=yield t(),i=[];for(const o of n.columns.names())if(o in e){const n=e[o];try{yield m(t,o,n.units,n.aligned,n.alphabet,n.alphabetSize,n.alphabetIsMultichar,n.separator)}catch(t){const e=t.toString();i.push(`Positive col '${o}' failed: ${e}`)}}else try{yield f(t,o)}catch(t){const e=t.toString();i.push(`Negative col '${o}' failed: ${e}`)}if(i.length>0)throw new Error(i.join("\n"))}))}var v=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};(0,e.W3)("detectors:weak-and-likely",(()=>{const n={fastaDnaWeak1:"id,colName\n1,TTTTT\n2,TTTTT\n3,TTTTT\n4,TTTTT\n",fastaDnaWeak1LikelyName:"id,seq\n1,TTTTT\n2,TTTTT\n3,TTTTT\n4,TTTTT\n",fastaRnaWeak1:"id,colName\n1,UUUUU\n2,UUUUU\n3,UUUUU\n4,UUUUU\n",fastaRnaWeak1LikelyName:"id,seq\n1,UUUUU\n2,UUUUU\n3,UUUUU\n4,UUUUU\n",fastaPtWeak1:"id,colName\n1,SLSLSPGK\n2,SLSLSPGK\n3,SLSLSPGK\n4,SLSLSPGK\n",fastaPtWeak1LikelyName:"id,seq\n1,SLSLSPGK\n2,SLSLSPGK\n3,SLSLSPGK\n4,SLSLSPGK\n",fastaUn1:"id,colName\n1,word\n2,other\n3,some\n4,another\n",fastaUn1LikelyName:"id,seq\n1,word\n2,other\n3,some\n4,another\n",fastaUn2LikelyName:'protein\nBoombastic\nMegafantastic\n"just-a-random-thought,oy!"\n',fastaUnMsa1LikelyName:"id,seq\n1,word\n2,male\n3,bare\n4,core\n"},i=e=>()=>v(void 0,void 0,void 0,(function*(){const i=n[e],o=t.DataFrame.fromCsv(i);return yield h.data.detectSemanticTypes(o),o}));(0,e.Bu)("fastaDnaWeak1",(()=>v(void 0,void 0,void 0,(function*(){yield f(i("fastaDnaWeak1"),"colName")})))),(0,e.Bu)("fastaDnaWeak1LikelyName",(()=>v(void 0,void 0,void 0,(function*(){yield m(i("fastaDnaWeak1LikelyName"),"seq","fasta","SEQ.MSA","DNA",4,!1)})))),(0,e.Bu)("fastaRnaWeak1",(()=>v(void 0,void 0,void 0,(function*(){yield f(i("fastaRnaWeak1"),"colName")})))),(0,e.Bu)("fastaRnaWeak1LikelyName",(()=>v(void 0,void 0,void 0,(function*(){yield m(i("fastaRnaWeak1LikelyName"),"seq","fasta","SEQ.MSA","RNA",4,!1)})))),(0,e.Bu)("fastaPtWeak1",(()=>v(void 0,void 0,void 0,(function*(){yield f(i("fastaPtWeak1"),"colName")})))),(0,e.Bu)("fastaPtWeak1LikelyName",(()=>v(void 0,void 0,void 0,(function*(){yield m(i("fastaPtWeak1LikelyName"),"seq","fasta","SEQ.MSA","PT",20,!1)})))),(0,e.Bu)("fastaUn1",(()=>v(void 0,void 0,void 0,(function*(){yield f(i("fastaUn1"),"colName")})))),(0,e.Bu)("fastaUn1LikelyName",(()=>v(void 0,void 0,void 0,(function*(){yield f(i("fastaUn1LikelyName"),"seq")})))),(0,e.Bu)("fastaUn2LikelyName",(()=>v(void 0,void 0,void 0,(function*(){yield f(i("fastaUn2LikelyName"),"protein")})))),(0,e.Bu)("fastaUnMsa1LikelyName",(()=>v(void 0,void 0,void 0,(function*(){yield f(i("fastaUnMsa1LikelyName"),"seq")}))))}));var y=n(6714),w=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};(0,e.W3)("detectorsBenchmark",(()=>{let n;function i(i,o,s,r,a,l){return w(this,void 0,void 0,(function*(){return yield function(i,h,u,d){return w(this,void 0,void 0,(function*(){const i=(()=>{const e=function(e,n,i,o,s){let r;switch(e){case"fasta":r=t=>{let e="";for(let n=0;n<t.length;n++){const i=t[n];e+=1==i.length?i:`[${i}]`}return e};break;case"separator":r=(t,e)=>t.join(e);break;default:throw new Error(`Not supported notation '${e}'.`)}const a=(t,e)=>{const n=new Array(e);for(let i=0;i<e;i++)n[i]=t[Math.floor(Math.random()*t.length)];return r(n,s)},l=Array(o);for(let t=0;t<o;t++)l[t]=a(n,i);return t.Column.fromStrings("seq",l)}(o,[...(0,y.gM)(s)],r,a,l);return n.prepare({col:e})})(),h=Date.now(),d=yield u(i),f=Date.now();(function(t,n){const i=new c.C(t);(0,e.l_)(t.semType,n.semType),(0,e.l_)(i.notation,n.notation),(0,e.l_)(i.alphabet,n.alphabet),(0,e.l_)(i.separator,n.separator)})(d,{semType:t.SEMTYPE.MACROMOLECULE,notation:o,alphabet:s,separator:l});const m=f-h;if(m>10){const t=`ET ${m} ms is more than max allowed 10 ms.`;throw console.error(t),new Error(t)}return console.log(`ET ${m} ms is OK.`),m}))}(0,0,(t=>w(this,void 0,void 0,(function*(){return function(t){t.callSync();const e=t.getOutputParamValue(),n=t.inputs.col;return e&&(n.semType=e),n}(t)}))))}))}(0,e.bb)((()=>w(void 0,void 0,void 0,(function*(){const e=t.Func.find({package:"Bio",name:"detectMacromolecule"});n=e[0];const i=t.Column.fromStrings("seq",["ACGT","ACGT","ACGT"]);yield n.prepare({col:i}).call()})))),(0,e.Bu)("fastaDnaShorts50Few50",(()=>w(void 0,void 0,void 0,(function*(){yield i(0,"fasta","DNA",50,50)}))),{skipReason:"#1192"}),(0,e.Bu)("fastaDnaShorts50Many1E6",(()=>w(void 0,void 0,void 0,(function*(){yield i(0,"fasta","DNA",50,1e6)}))),{skipReason:"#1192"}),(0,e.Bu)("fastaDnaLong1e6Few50",(()=>w(void 0,void 0,void 0,(function*(){yield i(0,"fasta","DNA",1e6,50)}))),{skipReason:"#1192"}),(0,e.Bu)("separatorDnaShorts50Few50",(()=>w(void 0,void 0,void 0,(function*(){yield i(0,"separator","DNA",50,50,"/")}))),{skipReason:"#1192"}),(0,e.Bu)("separatorDnaShorts50Many1E6",(()=>w(void 0,void 0,void 0,(function*(){yield i(0,"separator","DNA",50,1e6,"/")}))),{}),(0,e.Bu)("separatorDnaLong1e6Few50",(()=>w(void 0,void 0,void 0,(function*(){yield i(0,"separator","DNA",1e6,50,"/")}))),{skipReason:"#1192"})}));var b=n(6098),C=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};function S(n,i){return C(this,void 0,void 0,(function*(){const o=t.DataFrame.fromCsv(n),s=t.DataFrame.fromCsv(i),r=o.getCol("seq"),a=yield h.functions.call("Bio:detectMacromolecule",{col:r});a&&(r.semType=a);const l=s.getCol("seq"),u=yield(0,b.U)(r,!0);(0,e.f6)(u.toList(),l.toList())}))}new t.Package,(0,e.W3)("MSA",(()=>C(void 0,void 0,void 0,(function*(){(0,e.Bu)("isCorrect",(()=>C(void 0,void 0,void 0,(function*(){yield S("seq\nFWRWYVKHP\nYNRWYVKHP\nMWRSWYCKHP","seq\nFWR-WYVKHP\nYNR-WYVKHP\nMWRSWYCKHP")})))),(0,e.Bu)("isCorrectLong",(()=>C(void 0,void 0,void 0,(function*(){yield S("seq\nFWRWYVKHPFWRWYVKHPFWRWYVKHPFWRWYVKHPFWRWYVKHPFWRWYVKHPFWRWYVKHPFWRWYVKHP\nYNRWYVKHPYNRWYVKHPYNRWYVKHPYNRWYVKHPYNRWYVKHPYNRWYVKHPYNRWYVKHPYNRWYVKHP\nMWRSWYCKHPMWRSWYCKHPMWRSWYCKHPMWRSWYCKHPMWRSWYCKHPMWRSWYCKHPMWRSWYCKHPMWRSWYCKHP","seq\nFWR-WYVKHPFWR-WYVKHPFWR-WYVKHPFWR-WYVKHPFWR-WYVKHPFWR-WYVKHPFWR-WYVKHPFWR-WYVKHP\nYNR-WYVKHPYNR-WYVKHPYNR-WYVKHPYNR-WYVKHPYNR-WYVKHPYNR-WYVKHPYNR-WYVKHPYNR-WYVKHP\nMWRSWYCKHPMWRSWYCKHPMWRSWYCKHPMWRSWYCKHPMWRSWYCKHPMWRSWYCKHPMWRSWYCKHPMWRSWYCKHP")}))))}))));var T=n(3553),M=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};function E(t,n){return M(this,void 0,void 0,(function*(){const i=(0,y.gP)(t);console.debug(`Bio: tests: splitters: src=${JSON.stringify(t)}, res=${JSON.stringify(i)} .`),(0,e.f6)(i,n)}))}(0,e.W3)("splitters",(()=>{let n,i;(0,e.bb)((()=>M(void 0,void 0,void 0,(function*(){n=[],i=[]})))),(0,e.X5)((()=>M(void 0,void 0,void 0,(function*(){i.forEach((t=>{h.shell.closeTable(t)})),n.forEach((t=>t.close()))}))));const o=["M[MeI]YKETLL[MeF]PKTDFPMRGGL[MeA]",["M","MeI","Y","K","E","T","L","L","MeF","P","K","T","D","F","P","M","R","G","G","L","MeA"]],s=["PEPTIDE1{meI.hHis.Aca.N.T.dE.Thr_PO3H2.Aca.D-Tyr_Et.Tyr_ab-dehydroMe.dV.E.N.D-Orn.D-aThr.Phe_4Me}$$$",["meI","hHis","Aca","N","T","dE","Thr_PO3H2","Aca","D-Tyr_Et","Tyr_ab-dehydroMe","dV","E","N","D-Orn","D-aThr","Phe_4Me"]],r=["PEPTIDE1{meI.hHis.Aca.N.T.dK.Thr_PO3H2.Aca.D-Tyr_Et.D-Dap.dV.E.N.pnG.Phe_4Me}$$$",["meI","hHis","Aca","N","T","dK","Thr_PO3H2","Aca","D-Tyr_Et","D-Dap","dV","E","N","pnG","Phe_4Me"]],a=["PEPTIDE1{[meI].[hHis].[Aca].N.T.[dK].[Thr_PO3H2].[Aca].[D-Tyr_Et].[D-Dap].[dV].E.N.[pnG].[Phe_4Me]}$$$",["meI","hHis","Aca","N","T","dK","Thr_PO3H2","Aca","D-Tyr_Et","D-Dap","dV","E","N","pnG","Phe_4Me"]],l=["RNA1{R(U)P.R(T)P.R(G)P.R(C)P.R(A)}$$$$",["R(U)P","R(T)P","R(G)P","R(C)P","R(A)"]],c=["RNA1{P.R(U)P.R(T)}$$$$",["P","R(U)P","R(T)"]],d=["RNA1{P.R(U).P.R(T)}$$$$",["P","R(U)","P","R(T)"]];(0,e.Bu)("fastaMulti",(()=>M(void 0,void 0,void 0,(function*(){yield function(t,n){return M(this,void 0,void 0,(function*(){const i=(0,y.kB)(t);console.debug(`Bio: tests: splitters: src=${JSON.stringify(t)}, res=${JSON.stringify(i)} .`),(0,e.f6)(i,n)}))}(o[0],o[1])})))),(0,e.Bu)("helm1",(()=>M(void 0,void 0,void 0,(function*(){yield E(s[0],s[1])})))),(0,e.Bu)("helm2",(()=>M(void 0,void 0,void 0,(function*(){yield E(r[0],r[1])})))),(0,e.Bu)("helm3-multichar",(()=>M(void 0,void 0,void 0,(function*(){yield E(a[0],a[1])})))),(0,e.Bu)("testHelm1",(()=>M(void 0,void 0,void 0,(function*(){yield E(l[0],l[1])})))),(0,e.Bu)("testHelm2",(()=>M(void 0,void 0,void 0,(function*(){yield E(c[0],c[1])})))),(0,e.Bu)("testHelm3",(()=>M(void 0,void 0,void 0,(function*(){yield E(d[0],d[1])})))),(0,e.Bu)("splitToMonomers",(()=>M(void 0,void 0,void 0,(function*(){const t=yield h.dapi.files.readCsv("System:AppData/Bio/samples/sample_MSA.csv"),o=t.getCol("MSA"),s=yield h.functions.call("Bio:detectMacromolecule",{col:o});s&&(o.semType=s),o.setTag("aligned",T.mU);const r=h.shell.addTableView(t);yield h.data.detectSemanticTypes(t),i.push(t),n.push(r),(0,u.splitToMonomers)(),(0,e.l_)(t.columns.names().includes("17"),!0)}))),{skipReason:"GROK-12766"}),(0,e.Bu)("getHelmMonomers",(()=>M(void 0,void 0,void 0,(function*(){const e=t.DataFrame.fromCsv("HELM,Activity\nPEPTIDE1{hHis.N.T}$$$,5.30751\nPEPTIDE1{hHis.Aca.Cys_SEt}$$$,5.72388\n"),n=["hHis","Aca","Cys_SEt","N","T"],i=e.getCol("HELM"),o=(0,u.getHelmMonomers)(i),s=n.filter((t=>!o.includes(t))),r=o.filter((t=>!n.includes(t)));if(s.length>0||r.length){const t=[];throw s.length>0&&t.push(`Missed monomers ${JSON.stringify(s)}.`),r.length>0&&t.push(`Unexpected monomers ${JSON.stringify(r)}.`),new Error(t.join(" "))}}))))}));var A=n(7228),R=n(1345),P=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};(0,e.W3)("monomerLibraries",(()=>{let t,n=null;(0,e.bb)((()=>P(void 0,void 0,void 0,(function*(){t=yield(0,A.JN)(),n=yield h.dapi.userDataStorage.get(R.RV,!0)})))),(0,e.X5)((()=>P(void 0,void 0,void 0,(function*(){yield h.dapi.userDataStorage.put(R.RV,n,!0)})))),(0,e.Bu)("default",(()=>P(void 0,void 0,void 0,(function*(){yield h.dapi.userDataStorage.put(R.RV,{},!0),yield t.loadLibraries(!0);const n=t.getBioLib();(0,e.l_)(n.getTypes().length,0)}))))}));var N=n(4004);function x(){const e=[];return e.push(t.Column.fromList("string","MSA",new Array(Math.pow(10,6)).fill("meI/hHis/Aca/N/T/dE/Thr_PO3H2/Aca/D-Tyr_Et/Tyr_ab-dehydroMe/dV/E/N/D-Orn/D-aThr//Phe_4Me"))),e.push(t.Column.fromList("string","Activity",new Array(Math.pow(10,6)).fill("5.30751"))),e}function L(){const e=[],n="meI/hHis/Aca/N/T/dE/Thr_PO3H2/Aca/D-Tyr_Et/Tyr_ab-dehydroMe/dV/E/N/D-Orn/D-aThr".repeat(Math.pow(10,5));return e.push(t.Column.fromList("string","MSA",new Array(Math.pow(10,2)).fill(n))),e.push(t.Column.fromList("string","Activity",new Array(Math.pow(10,2)).fill("7.30751"))),e}function G(e,n){const i=e(),o=t.DataFrame.fromColumns(i),s=Date.now();var r;(r=o.columns.byName("MSA")).semType=t.SEMTYPE.MACROMOLECULE,r.setTag(t.TAGS.UNITS,"separator"),r.setTag("aligned","SEQ.MSA"),r.setTag("alphabet","UN"),r.setTag("separator","/"),h.shell.addTableView(o);const a=Date.now()-s;console.log(`Performance test: ${n}: ${a}ms`)}var _=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};(0,e.W3)("renderers",(()=>{let n,i;(0,e.bb)((()=>_(void 0,void 0,void 0,(function*(){n=[],i=[]})))),(0,e.X5)((()=>_(void 0,void 0,void 0,(function*(){})))),(0,e.Bu)("long sequence performance ",(()=>_(void 0,void 0,void 0,(function*(){G(L,"Long sequences")})))),(0,e.Bu)("many sequence performance",(()=>_(void 0,void 0,void 0,(function*(){G(x,"Many sequences")})))),(0,e.Bu)("rendererMacromoleculeFasta",(()=>_(void 0,void 0,void 0,(function*(){yield function(){return _(this,void 0,void 0,(function*(){const o=yield h.dapi.files.readAsText("System:AppData/Bio/samples/sample_FASTA.csv"),s=t.DataFrame.fromCsv(o),r=s.getCol("Sequence"),a=yield h.functions.call("Bio:detectMacromolecule",{col:r});a&&(r.semType=a);const l=h.shell.addTableView(s);yield h.data.detectSemanticTypes(s),i.push(s),n.push(l);const u=r.getTag(t.TAGS.CELL_RENDERER);(0,e.l_)(u,"sequence")}))}()})))),(0,e.Bu)("rendererMacromoleculeSeparator",(()=>_(void 0,void 0,void 0,(function*(){yield function(){return _(this,void 0,void 0,(function*(){const o=yield h.dapi.files.readAsText("System:AppData/Bio/data/sample_SEPARATOR_PT.csv"),s=t.DataFrame.fromCsv(o),r=s.getCol("sequence"),a=yield h.functions.call("Bio:detectMacromolecule",{col:r});a&&(r.semType=a);const l=h.shell.addTableView(s);yield h.data.detectSemanticTypes(s),i.push(s),n.push(l);const u=r.getTag(t.TAGS.CELL_RENDERER);(0,e.l_)(u,"sequence")}))}()})))),(0,e.Bu)("rendererMacromoleculeDifference",(()=>_(void 0,void 0,void 0,(function*(){yield function(){return _(this,void 0,void 0,(function*(){const o=t.Column.fromStrings("SequencesDiff",["meI/hHis/Aca/N/T/dK/Thr_PO3H2/Aca#D-Tyr_Et/Tyr_ab-dehydroMe/meN/E/N/dV"]);o.tags[t.TAGS.UNITS]="separator",o.tags.separator="/",o.semType=T.Of.MACROMOLECULE_DIFFERENCE;const s=t.DataFrame.fromColumns([o]),r=h.shell.addTableView(s);yield h.data.detectSemanticTypes(s),i.push(s),n.push(r);const a=o.getTag(t.TAGS.CELL_RENDERER);(0,e.l_)(a,T.Of.MACROMOLECULE_DIFFERENCE)}))}()})))),(0,e.Bu)("afterMsa",(()=>_(void 0,void 0,void 0,(function*(){yield function(){return _(this,void 0,void 0,(function*(){const o=yield h.dapi.files.readAsText("System:AppData/Bio/data/sample_FASTA.fasta"),s=(0,u.importFasta)(o)[0],r=s.getCol("sequence"),a=yield h.functions.call("Bio:detectMacromolecule",{col:r});a&&(r.semType=a);const l=h.shell.addTableView(s);yield h.data.detectSemanticTypes(s),console.log("Bio: tests/renderers/afterMsa, table view"),console.log(`Bio: tests/renderers/afterMsa, src before test semType="${r.semType}", units="${r.getTag(t.TAGS.UNITS)}", cell.renderer="${r.getTag(t.TAGS.CELL_RENDERER)}"`),(0,e.l_)(r.semType,t.SEMTYPE.MACROMOLECULE),(0,e.l_)(r.getTag(t.TAGS.UNITS),"fasta"),(0,e.l_)(r.getTag("aligned"),"SEQ"),(0,e.l_)(r.getTag("alphabet"),"PT"),(0,e.l_)(r.getTag(t.TAGS.CELL_RENDERER),"sequence"),(0,u.multipleSequenceAlignmentAny)(r),l.grid.invalidate(),i.push(s),n.push(l)}))}()})))),(0,e.Bu)("afterConvert",(()=>_(void 0,void 0,void 0,(function*(){yield function(){return _(this,void 0,void 0,(function*(){const o=yield h.dapi.files.readAsText("System:AppData/Bio/data/sample_FASTA_PT.csv"),s=t.DataFrame.fromCsv(o),r=s.col("sequence"),a=yield h.functions.call("Bio:detectMacromolecule",{col:r});a&&(r.semType=a);const l=h.shell.addTableView(s);yield h.data.detectSemanticTypes(s),n.push(l),i.push(s);const u=yield(0,N.o)(r,"separator","/"),d=u.getTag(t.TAGS.CELL_RENDERER);(0,e.l_)(d,"sequence"),new c.C(u)}))}()}))),{skipReason:"GROK-12765"}),(0,e.Bu)("selectRendererBySemType",(()=>_(void 0,void 0,void 0,(function*(){yield function(){return _(this,void 0,void 0,(function*(){const o=t.Column.fromStrings("SequencesDiff",["meI/hHis/Aca/N/T/dK/Thr_PO3H2/Aca#D-Tyr_Et/Tyr_ab-dehydroMe/meN/E/N/dV"]);o.tags[t.TAGS.UNITS]="separator",o.tags.separator="/",o.semType=T.Of.MACROMOLECULE_DIFFERENCE;const s=t.DataFrame.fromColumns([o]),r=h.shell.addTableView(s);i.push(s),n.push(r),yield(0,e.gw)(100);const a=o.getTag(t.TAGS.CELL_RENDERER);if("MacromoleculeDifference"!==a)throw new Error(`Units 'separator', separator '/' and semType 'MacromoleculeDifference' have been manually set on column but after df was added as table, view renderer has set to '${a}' instead of correct 'MacromoleculeDifference'.`)}))}()})))),(0,e.Bu)("setRendererManually",(()=>_(void 0,void 0,void 0,(function*(){yield function(){return _(this,void 0,void 0,(function*(){const o=t.Column.fromStrings("SequencesDiff",["meI/hHis/Aca/N/T/dK/Thr_PO3H2/Aca#D-Tyr_Et/Tyr_ab-dehydroMe/meN/E/N/dV"]);o.tags[t.TAGS.UNITS]="separator",o.tags.separator="/",o.semType=t.SEMTYPE.MACROMOLECULE;const s="MacromoleculeDifference";o.setTag(t.TAGS.CELL_RENDERER,s);const r=t.DataFrame.fromColumns([o]);yield h.data.detectSemanticTypes(r);const a=h.shell.addTableView(r);i.push(r),n.push(a),yield(0,e.gw)(100);const l=o.getTag(t.TAGS.CELL_RENDERER);if(l!==s)throw new Error(`Tag 'cell.renderer' has been manually set to '${s}' for column but after df was added as table, tag 'cell.renderer' has reset to '${l}' instead of manual '${s}'.`)}))}()}))),{skipReason:"GROK-11212"})}));var I=n(7767),W=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};(0,e.W3)("converters",(()=>{let n;!function(t){t.fastaPt="fastaPt",t.separatorPt="separatorPt",t.helmPt="helmPt",t.fastaDna="fastaDna",t.separatorDna="separatorDna",t.helmDna="helmDna",t.fastaRna="fastaRna",t.separatorRna="separatorRna",t.helmRna="helmRna",t.fastaGaps="fastaGaps",t.separatorGaps="separatorGaps",t.helmGaps="helmGaps",t.fastaUn="fastaUn",t.separatorUn="separatorUn",t.helmUn="helmUn",t.helmLoneDeoxyribose="helmLoneDeoxyribose",t.helmLoneRibose="helmLoneRibose",t.helmLonePhosphorus="helmLonePhosphorus",t.fastaLoneDeoxyribose="fastaLoneDeoxyribose",t.fastaLoneRibose="fastaLoneRibose",t.fastaLonePhosphorus="fastaLonePhosphorus"}(n||(n={}));const i={fastaPt:"seq\nFWPHEY\nYNRQWYV\nMKPSEYV\n",separatorPt:"seq\nF-W-P-H-E-Y\nY-N-R-Q-W-Y-V\nM-K-P-S-E-Y-V\n",helmPt:"seq\nPEPTIDE1{F.W.P.H.E.Y}$$$\nPEPTIDE1{Y.N.R.Q.W.Y.V}$$$\nPEPTIDE1{M.K.P.S.E.Y.V}$$$\n",fastaDna:"seq\nACGTC\nCAGTGT\nTTCAAC\n",separatorDna:"seq\nA/C/G/T/C\nC/A/G/T/G/T\nT/T/C/A/A/C\n",helmDna:"seq\nDNA1{D(A)P.D(C)P.D(G)P.D(T)P.D(C)P}$$$\nDNA1{D(C)P.D(A)P.D(G)P.D(T)P.D(G)P.D(T)P}$$$\nDNA1{D(T)P.D(T)P.D(C)P.D(A)P.D(A)P.D(C)P}$$$\n",fastaRna:"seq\nACGUC\nCAGUGU\nUUCAAC\n",separatorRna:"seq\nA*C*G*U*C\nC*A*G*U*G*U\nU*U*C*A*A*C\n",helmRna:"seq\nRNA1{R(A)P.R(C)P.R(G)P.R(U)P.R(C)P}$$$\nRNA1{R(C)P.R(A)P.R(G)P.R(U)P.R(G)P.R(U)P}$$$\nRNA1{R(U)P.R(U)P.R(C)P.R(A)P.R(A)P.R(C)P}$$$\n",fastaGaps:"seq\nFW-PH-EYY\nFYNRQWYV-\nFKP-Q-SEYV\n",separatorGaps:"seq\nF/W//P/H//E/Y/Y\nF/Y/N/R/Q/W/Y/V/\nF/K/P//Q//S/E/Y/V\n",helmGaps:"seq\nPEPTIDE1{F.W.*.P.H.*.E.Y.Y}$$$\nPEPTIDE1{F.Y.N.R.Q.W.Y.V.*}$$$\nPEPTIDE1{F.K.P.*.Q.*.S.E.Y.V}$$$\n",fastaUn:"seq\n[meI][hHis][Aca]NT[dE][Thr_PO3H2][Aca]D\n[meI][hHis][Aca][Cys_SEt]T[dK][Thr_PO3H2][Aca][Tyr_PO3H2]\n[Lys_Boc][hHis][Aca][Cys_SEt]T[dK][Thr_PO3H2][Aca][Tyr_PO3H2]\n",separatorUn:"seq\nmeI-hHis-Aca-N-T-dE-Thr_PO3H2-Aca-D\nmeI-hHis-Aca-Cys_SEt-T-dK-Thr_PO3H2-Aca-Tyr_PO3H2\nLys_Boc-hHis-Aca-Cys_SEt-T-dK-Thr_PO3H2-Aca-Tyr_PO3H2\n",helmUn:"seq\nPEPTIDE1{meI.hHis.Aca.N.T.dE.Thr_PO3H2.Aca.D}$$$\nPEPTIDE1{meI.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.Aca.Tyr_PO3H2}$$$\nPEPTIDE1{Lys_Boc.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.Aca.Tyr_PO3H2}$$$\n",helmLoneDeoxyribose:"seq\nDNA1{D(A).D(C).D(G).D(T).D(C)}$$$\nDNA1{D(C).D(A).D(G).D(T).D(G).D(T)P}$$$\nDNA1{D(T).D(T).D(C).D(A).D(A).D(C)P}$$$\n",helmLoneRibose:"seq\nRNA1{R(A).R(C).R(G).R(U).R(C)}$$$\nRNA1{R(C).R(A).R(G).R(U).R(G).R(U)P}$$$\nRNA1{R(U).R(U).R(C).R(A).R(A).R(C)P}$$$\n",helmLonePhosphorus:"seq\nRNA1{P.P.R(A)P.R(C)P.R(G)P.R(U)P.R(C)P}$$$\nRNA1{P.P.R(C)P.R(A)P.P.R(G)P.R(U)P.R(G)P.R(U)P}$$$\nRNA1{P.R(U)P.R(U)P.R(C)P.R(A)P.R(A)P.R(C)P.P.P}$$$\n"};function o(e){return W(this,void 0,void 0,(function*(){const n=i[e],o=t.DataFrame.fromCsv(n);return yield h.data.detectSemanticTypes(o),o}))}function s(t,n=null){if("separator"===t&&!n)throw new Error(`Argument 'separator' is missed for notation '${t.toString()}'.`);return function(i){const o=new I.L(i).convert(t,n);return(0,e.l_)(o.getTag("units"),t),o}}function r(t,n,i){return W(this,void 0,void 0,(function*(){const s=(yield o(t)).getCol("seq"),r=n(s),a=(yield o(i)).getCol("seq");(0,e.f6)(r.toList(),a.toList()),new c.C(r)}))}(0,e.Bu)("testFastaPtToSeparator",(()=>W(void 0,void 0,void 0,(function*(){yield r(n.fastaPt,s("separator","-"),n.separatorPt)})))),(0,e.Bu)("testFastaDnaToSeparator",(()=>W(void 0,void 0,void 0,(function*(){yield r(n.fastaDna,s("separator","/"),n.separatorDna)})))),(0,e.Bu)("testFastaRnaToSeparator",(()=>W(void 0,void 0,void 0,(function*(){yield r(n.fastaRna,s("separator","*"),n.separatorRna)})))),(0,e.Bu)("testFastaGapsToSeparator",(()=>W(void 0,void 0,void 0,(function*(){yield r(n.fastaGaps,s("separator","/"),n.separatorGaps)})))),(0,e.Bu)("testFastaUnToSeparator",(()=>W(void 0,void 0,void 0,(function*(){yield r(n.fastaUn,s("separator","-"),n.separatorUn)})))),(0,e.Bu)("testFastaPtToHelm",(()=>W(void 0,void 0,void 0,(function*(){yield r(n.fastaPt,s("helm"),n.helmPt)})))),(0,e.Bu)("testFastaDnaToHelm",(()=>W(void 0,void 0,void 0,(function*(){yield r(n.fastaDna,s("helm"),n.helmDna)})))),(0,e.Bu)("testFastaRnaToHelm",(()=>W(void 0,void 0,void 0,(function*(){yield r(n.fastaRna,s("helm"),n.helmRna)})))),(0,e.Bu)("testFastaGapsToHelm",(()=>W(void 0,void 0,void 0,(function*(){yield r(n.fastaGaps,s("helm"),n.helmGaps)})))),(0,e.Bu)("testSeparatorPtToFasta",(()=>W(void 0,void 0,void 0,(function*(){yield r(n.separatorPt,s("fasta"),n.fastaPt)})))),(0,e.Bu)("testSeparatorDnaToFasta",(()=>W(void 0,void 0,void 0,(function*(){yield r(n.separatorDna,s("fasta"),n.fastaDna)})))),(0,e.Bu)("testSeparatorRnaToFasta",(()=>W(void 0,void 0,void 0,(function*(){yield r(n.separatorRna,s("fasta"),n.fastaRna)})))),(0,e.Bu)("testSeparatorGapsToFasta",(()=>W(void 0,void 0,void 0,(function*(){yield r(n.separatorGaps,s("fasta"),n.fastaGaps)})))),(0,e.Bu)("testSeparatorUnToFasta",(()=>W(void 0,void 0,void 0,(function*(){yield r(n.separatorUn,s("fasta"),n.fastaUn)})))),(0,e.Bu)("testSeparatorPtToHelm",(()=>W(void 0,void 0,void 0,(function*(){yield r(n.separatorPt,s("helm"),n.helmPt)})))),(0,e.Bu)("testSeparatorDnaToHelm",(()=>W(void 0,void 0,void 0,(function*(){yield r(n.separatorDna,s("helm"),n.helmDna)})))),(0,e.Bu)("testSeparatorRnaToHelm",(()=>W(void 0,void 0,void 0,(function*(){yield r(n.separatorRna,s("helm"),n.helmRna)})))),(0,e.Bu)("testSeparatorGapsToHelm",(()=>W(void 0,void 0,void 0,(function*(){yield r(n.separatorGaps,s("helm"),n.helmGaps)})))),(0,e.Bu)("testHelmDnaToFasta",(()=>W(void 0,void 0,void 0,(function*(){yield r(n.helmDna,s("fasta"),n.fastaDna)})))),(0,e.Bu)("testHelmRnaToFasta",(()=>W(void 0,void 0,void 0,(function*(){yield r(n.helmRna,s("fasta"),n.fastaRna)})))),(0,e.Bu)("testHelmPtToFasta",(()=>W(void 0,void 0,void 0,(function*(){yield r(n.helmPt,s("fasta"),n.fastaPt)})))),(0,e.Bu)("testHelmUnToFasta",(()=>W(void 0,void 0,void 0,(function*(){yield r(n.helmUn,s("fasta"),n.fastaUn)})))),(0,e.Bu)("testHelmDnaToSeparator",(()=>W(void 0,void 0,void 0,(function*(){yield r(n.helmDna,s("separator","/"),n.separatorDna)})))),(0,e.Bu)("testHelmRnaToSeparator",(()=>W(void 0,void 0,void 0,(function*(){yield r(n.helmRna,s("separator","*"),n.separatorRna)})))),(0,e.Bu)("testHelmPtToSeparator",(()=>W(void 0,void 0,void 0,(function*(){yield r(n.helmPt,s("separator","-"),n.separatorPt)})))),(0,e.Bu)("testHelmUnToSeparator",(()=>W(void 0,void 0,void 0,(function*(){yield r(n.helmUn,s("separator","-"),n.separatorUn)})))),(0,e.Bu)("testHelmLoneRibose",(()=>W(void 0,void 0,void 0,(function*(){yield r(n.helmLoneRibose,s("fasta"),n.fastaRna)})))),(0,e.Bu)("testHelmLoneDeoxyribose",(()=>W(void 0,void 0,void 0,(function*(){yield r(n.helmLoneDeoxyribose,s("separator","/"),n.separatorDna)})))),(0,e.Bu)("testHelmLonePhosphorus",(()=>W(void 0,void 0,void 0,(function*(){yield r(n.helmLonePhosphorus,s("fasta"),n.fastaRna)}))))}));var F=n(5226),k=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};(0,e.W3)("fastaFileHandler",(()=>{const n=["description:1","description:2","description:3","description:4"],i=t.Column.fromStrings("description",n),o=["MDYKETLLMPKTDFPMRGGLPNKEPQIQEKW","MIEVFLFGIVLGLIPITLAGLFVTAYLQYRRGDQLDL","MMELVLKTIIGPIVVGVVLRIVDKWLNKDK","MDRTDEVSNHTHDKPTLTWFEEIFEEYHSPFHN"],s=t.Column.fromStrings("sequence",o);function r(t){const i=new F.i(t),s=i.descriptionsArray,r=i.sequencesArray;(0,e.f6)([s,r],[n,o])}s.semType=t.SEMTYPE.MACROMOLECULE,c.C.setUnitsToFastaColumn(s),t.DataFrame.fromColumns([i,s]),(0,e.Bu)("testNormalFormatting",(()=>k(void 0,void 0,void 0,(function*(){r(">description:1\nMDYKETLLMPKTDFPMRGGLPNKEPQIQEKW\n\n>description:2\nMIEVFLFGIVLGLIPITLAGLFVTAYLQYRRGDQLDL\n\n>description:3\nMMELVLKTIIGPIVVGVVLRIVDKWLNKDK\n\n>description:4\nMDRTDEVSNHTHDKPTLTWFEEIFEEYHSPFHN\n")})))),(0,e.Bu)("testExtraSpaces",(()=>k(void 0,void 0,void 0,(function*(){r(">description:1\n MDYKETLLMPKTDFPMRGGLPNKEPQIQEKW\n\n>description:2\nMI EVF LFGIVLGLI PITLAGLFVTAY LQYRRGDQLDL\n\n>description:3\nM MELVLKTI IGPI VVGVVLR IVDKWLNKDK\n\n>description:4\nMDR TDEVSNHTHDKP TLTWFEEIFEEYHSPFHN\n ")})))),(0,e.Bu)("testExtraNewlines",(()=>k(void 0,void 0,void 0,(function*(){r(">description:1\n\nMDYKETLLMPKTDFPMRGGLPNKEPQIQEKW\n\n>description:2\nMIEVF\nLFGIVLGLI\nPITLAGLFVTA\nYLQYRRGDQLDL\n\n>description:3\nM\nME\n\nLVLKTIIG\n\nPIVVGVVLRI\nVDKWLNKDK\n\n\n>description:4\n\nMDRT\n\nDEVSNHTHDKP\n\nTLTWFEEIFEE\n\n\n\nYHSPFHN\n")}))))}));var D=n(9943),H=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};(0,e.W3)("fastaExport",(()=>{let n;!function(t){t.single="single",t.multi="multi"}(n||(n={}));const i={[n.single]:{src:"MDYKETLLMPKTDFPMRGGLP",tgt:["MDYKETLLMP","KTDFPMRGGL","P"]},[n.multi]:{src:"M[MeI]YKETLL[MeF]PKTDFPMRGGL[MeA]",tgt:["M[MeI]YKETLL[MeF]P","KTDFPMRGGL","[MeA]"]}};let o;!function(t){t.test1="test1",t.test2="test2"}(o||(o={}));const s={[o.test1]:{srcCsv:"id,seq\n1,MDYKETLLMP\n2,KTDFPMRGGL\n3,P",idCols:["id"],seqCol:"seq",lineWidth:10,tgtFasta:">1\nMDYKETLLMP\n>2\nKTDFPMRGGL\n>3\nP\n"},[o.test2]:{srcCsv:"id,id2,seq\n1,seqA,M[MeI]YKETLL[MeF]P\n2,seqB,KTDFPMRGGL\n3,seqC,[MeA]\n",idCols:["id2","id"],seqCol:"seq",lineWidth:5,tgtFasta:">seqA|1\nM[MeI]YKE\nTLL[MeF]P\n>seqB|2\nKTDFP\nMRGGL\n>seqC|3\n[MeA]\n"}};function r(t,n=10){const o=y.kB,s=i[t].src,r=(0,D.sK)(s,o,n),a=i[t].tgt;(0,e.f6)(r,a)}function a(n){return H(this,void 0,void 0,(function*(){const i=t.DataFrame.fromCsv(n.srcCsv),o=i.getCol(n.seqCol),s=n.idCols.map((t=>i.getCol(t))),r=(0,D.i$)(s,o,n.lineWidth);(0,e.l_)(r,n.tgtFasta)}))}(0,e.Bu)("wrapSequenceSingle",(()=>H(void 0,void 0,void 0,(function*(){r(n.single,10)})))),(0,e.Bu)("wrapSequenceMulti",(()=>H(void 0,void 0,void 0,(function*(){r(n.multi,10)})))),(0,e.Bu)("saveAsFastaTest1",(()=>H(void 0,void 0,void 0,(function*(){a(s[o.test1])})))),(0,e.Bu)("saveAsFastaTest2",(()=>H(void 0,void 0,void 0,(function*(){a(s[o.test2])}))))}));var V=n(7331),O=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};(0,e.W3)("bio",(()=>{const n="seq\nACGTCT\nCAGTGT\nTTCAAC\n";(0,e.Bu)("testGetStatsHelm1",(()=>O(void 0,void 0,void 0,(function*(){const n=t.DataFrame.fromCsv("seq\nPEPTIDE1{meI}$$$$\n").getCol("seq"),i=(0,y.fy)(n,1,y.gP);(0,e.Wh)(i.freq,{meI:1}),(0,e.l_)(i.sameLength,!0)})))),(0,e.Bu)("testGetStatsN1",(()=>O(void 0,void 0,void 0,(function*(){yield function(n){return O(this,void 0,void 0,(function*(){const i=t.DataFrame.fromCsv(n).col("seq"),o=(0,y.fy)(i,5,y.kB);(0,e.Wh)(o.freq,{A:4,C:5,G:3,T:6}),(0,e.l_)(o.sameLength,!0)}))}(n)})))),(0,e.Bu)("testGetAlphabetSimilarity",(()=>O(void 0,void 0,void 0,(function*(){yield function(){return O(this,void 0,void 0,(function*(){const t=new Set(Object.keys(r.V.Names)),n=(0,y.KX)({A:2041,C:3015,G:3015,T:2048,"-":1e3},t);(0,e.l_)(n>.6,!0)}))}()})))),(0,e.Bu)("testPickupPaletteN1",(()=>O(void 0,void 0,void 0,(function*(){yield function(n){return O(this,void 0,void 0,(function*(){const i=t.DataFrame.fromCsv(n).col("seq"),o=(0,y.dQ)(i);(0,e.l_)(o instanceof r.J,!0)}))}(n)})))),(0,e.Bu)("testPickupPaletteN1e",(()=>O(void 0,void 0,void 0,(function*(){yield function(n){return O(this,void 0,void 0,(function*(){const n=t.DataFrame.fromCsv("seq\nACGTAT\nCAGTTG\nTTCG2C\n").col("seq"),i=(0,y.dQ)(n);(0,e.l_)(i instanceof r.J,!0)}))}()})))),(0,e.Bu)("testPickupPaletteAA1",(()=>O(void 0,void 0,void 0,(function*(){yield function(n){return O(this,void 0,void 0,(function*(){const n=t.DataFrame.fromCsv("seq\nFWPHEYV\nYNRQWYV\nMKPSEYV\n").col("seq"),i=(0,y.dQ)(n);(0,e.l_)(i instanceof o.f,!0)}))}()})))),(0,e.Bu)("testPickupPaletteX",(()=>O(void 0,void 0,void 0,(function*(){yield function(n){return O(this,void 0,void 0,(function*(){const n=t.DataFrame.fromCsv("seq\nXZJ{}2\n5Z4733\n3Z6></\n675687\n").col("seq"),i=(0,y.dQ)(n);(0,e.l_)(i instanceof V.kQ,!0)}))}()}))))})),(0,e.W3)("WebLogo.monomerToShort",(()=>{(0,e.Bu)("longMonomerSingle",(()=>O(void 0,void 0,void 0,(function*(){yield(0,e.l_)((0,y.GU)("S",5),"S")})))),(0,e.Bu)("longMonomerShort",(()=>O(void 0,void 0,void 0,(function*(){yield(0,e.l_)((0,y.GU)("Short",5),"Short")})))),(0,e.Bu)("longMonomerLong56",(()=>O(void 0,void 0,void 0,(function*(){yield(0,e.l_)((0,y.GU)("Long56",5),"Long5…")})))),(0,e.Bu)("longMonomerComplexFirstPartShort",(()=>O(void 0,void 0,void 0,(function*(){yield(0,e.l_)((0,y.GU)("Long-long",5),"Long…")})))),(0,e.Bu)("longMonomerComplexFirstPartLong56",(()=>O(void 0,void 0,void 0,(function*(){yield(0,e.l_)((0,y.GU)("Long56-long",5),"Long5…")}))))}));var Y=n(2433),U=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};function B(t,n){(0,e.l_)(t.name,n.name),(0,e.f6)(Object.keys(t.freq),Object.keys(n.freq));for(const i in t.freq)(0,e.l_)(t.freq[i].count,n.freq[i].count)}(0,e.W3)("WebLogo-positions",(()=>{let n,i;const o="seq\nATC-G-TTGC--\nATC-G-TTGC--\n-TC-G-TTGC--\n-TC-GCTTGC--\n-TC-GCTTGC--";(0,e.bb)((()=>U(void 0,void 0,void 0,(function*(){n=[],i=[]})))),(0,e.X5)((()=>U(void 0,void 0,void 0,(function*(){})))),(0,e.Bu)("allPositions",(()=>U(void 0,void 0,void 0,(function*(){const s=t.DataFrame.fromCsv(o),r=h.shell.addTableView(s),a=s.getCol("seq");a.semType=t.SEMTYPE.MACROMOLECULE,a.setTag(t.TAGS.UNITS,"fasta"),a.setTag("alphabet","DNA"),a.setTag("aligned","SEQ.MSA");const l=yield s.plot.fromType("WebLogo");r.dockManager.dock(l.root,t.DOCK_TYPE.DOWN),n.push(r),i.push(s);const u=l.positions,c=[new Y.CK(0,"1",{A:new Y.yW(2),"-":new Y.yW(3)}),new Y.CK(1,"2",{T:new Y.yW(5)}),new Y.CK(2,"3",{C:new Y.yW(5)}),new Y.CK(3,"4",{"-":new Y.yW(5)}),new Y.CK(4,"5",{G:new Y.yW(5)}),new Y.CK(5,"6",{"-":new Y.yW(3),C:new Y.yW(2)}),new Y.CK(6,"7",{T:new Y.yW(5)}),new Y.CK(7,"8",{T:new Y.yW(5)}),new Y.CK(8,"9",{G:new Y.yW(5)}),new Y.CK(9,"10",{C:new Y.yW(5)}),new Y.CK(10,"11",{"-":new Y.yW(5)}),new Y.CK(11,"12",{"-":new Y.yW(5)})];(0,e.l_)(u.length,c.length);for(let t=0;t<u.length;t++){(0,e.l_)(u[t].name,c[t].name);for(const n in u[t].freq)(0,e.l_)(u[t].freq[n].count,c[t].freq[n].count)}})))),(0,e.Bu)("positions with shrinkEmptyTail option true (filtered)",(()=>U(void 0,void 0,void 0,(function*(){const o=t.DataFrame.fromCsv("seq\n-TC-G-TTGC--\n-TC-GCTTGC--\n-T--C-GT-\n-T--C-GT-\n-T--C-GT-\n-T--CCGT-"),s=h.shell.addTableView(o),r=o.getCol("seq");r.semType=t.SEMTYPE.MACROMOLECULE,r.setTag(t.TAGS.UNITS,"fasta"),r.setTag("alphabet","DNA"),r.setTag("aligned","SEQ"),o.filter.init((t=>t>2)),o.filter.fireChanged();const a=yield o.plot.fromType("WebLogo",{shrinkEmptyTail:!0});s.dockManager.dock(a.root,t.DOCK_TYPE.DOWN),n.push(s),i.push(o);const l=a.positions,u=[new Y.CK(0,"1",{"-":new Y.yW(3)}),new Y.CK(1,"2",{T:new Y.yW(3)}),new Y.CK(2,"3",{"-":new Y.yW(3)}),new Y.CK(3,"4",{"-":new Y.yW(3)}),new Y.CK(4,"5",{C:new Y.yW(3)}),new Y.CK(5,"6",{"-":new Y.yW(2),C:new Y.yW(1)}),new Y.CK(6,"7",{G:new Y.yW(3)}),new Y.CK(7,"8",{T:new Y.yW(3)}),new Y.CK(8,"9",{"-":new Y.yW(3)})];(0,e.l_)(l.length,u.length);for(let t=0;t<l.length;t++){(0,e.l_)(l[t].name,u[t].name);for(const n in l[t].freq)(0,e.l_)(l[t].freq[n].count,u[t].freq[n].count)}})))),(0,e.Bu)("positions with skipEmptyPositions option",(()=>U(void 0,void 0,void 0,(function*(){const s=t.DataFrame.fromCsv(o),r=h.shell.addTableView(s),a=s.getCol("seq");a.semType=t.SEMTYPE.MACROMOLECULE,a.setTag(t.TAGS.UNITS,"fasta"),a.setTag("alphabet","DNA"),a.setTag("aligned","SEQ.MSA");const l=yield s.plot.fromType("WebLogo",{skipEmptyPositions:!0});r.dockManager.dock(l.root,t.DOCK_TYPE.DOWN),n.push(r),i.push(s);const u=l.positions,c=[new Y.CK(0,"1",{A:new Y.yW(2),"-":new Y.yW(3)}),new Y.CK(1,"2",{T:new Y.yW(5)}),new Y.CK(2,"3",{C:new Y.yW(5)}),new Y.CK(4,"5",{G:new Y.yW(5)}),new Y.CK(5,"6",{"-":new Y.yW(3),C:new Y.yW(2)}),new Y.CK(6,"7",{T:new Y.yW(5)}),new Y.CK(7,"8",{T:new Y.yW(5)}),new Y.CK(8,"9",{G:new Y.yW(5)}),new Y.CK(9,"10",{C:new Y.yW(5)})];(0,e.l_)(u.length,c.length);for(let t=0;t<u.length;t++)B(u[t],c[t])})))),(0,e.Bu)("count sequences for monomer at position",(()=>U(void 0,void 0,void 0,(function*(){const s=function(e,n,i,o){const s=t.DataFrame.fromCsv(e),r=s.getCol("seq");return r.semType=t.SEMTYPE.MACROMOLECULE,r.setTag(t.TAGS.UNITS,"fasta"),r.setTag("alphabet","DNA"),r.setTag("aligned","SEQ.MSA"),s}(o),r=s.getCol("seq"),a=h.shell.addTableView(s),l=yield s.plot.fromType("WebLogo",{startPositionName:"3",endPositionName:"7",skipEmptyPositions:!0});a.dockManager.dock(l.root,t.DOCK_TYPE.DOWN),n.push(a),i.push(s);const u=l.positions,c=[new Y.CK(2,"3",{C:new Y.yW(5)}),new Y.CK(4,"5",{G:new Y.yW(5)}),new Y.CK(5,"6",{"-":new Y.yW(3),C:new Y.yW(2)}),new Y.CK(6,"7",{T:new Y.yW(5)})];(0,e.l_)(u.length,c.length);for(let t=0;t<u.length;t++)B(u[t],c[t]);const d=l.splitter,f=u[1],m=(0,Y.eZ)(s,r,s.filter,d,"G",f);(0,e.l_)(m,5)}))))}));var Z=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};(0,e.W3)("checkInputColumn",(()=>{const n="seq\nseq1,\nseq2,\nseq3,\nseq4";(0,e.Bu)("testMsaPos",(()=>Z(void 0,void 0,void 0,(function*(){t.Func.find({package:"Bio",name:"multipleSequenceAlignmentAny"})[0].inputs.find((t=>"sequence"==t.name));const i=t.DataFrame.fromCsv(n).getCol("seq");i.semType=t.SEMTYPE.MACROMOLECULE,i.setTag(t.TAGS.UNITS,"fasta"),i.setTag("alphabet","DNA"),i.setTag("aligned","SEQ");const[o,s]=(0,u.checkInputColumn)(i,"Test",["fasta"],["DNA","RNA","PT"]);(0,e.l_)(o,!0)})))),(0,e.Bu)("testMsaNegHelm",(()=>Z(void 0,void 0,void 0,(function*(){const i=t.DataFrame.fromCsv(n).getCol("seq");i.semType=t.SEMTYPE.MACROMOLECULE,i.setTag(t.TAGS.UNITS,"helm"),i.setTag(".alphabetIsMultichar","true");const[o,s]=(0,u.checkInputColumn)(i,"Test",["fasta"],["DNA","RNA","PT"]);(0,e.l_)(o,!1)})))),(0,e.Bu)("testMsaNegUN",(()=>Z(void 0,void 0,void 0,(function*(){const i=t.DataFrame.fromCsv(n).getCol("seq");i.semType=t.SEMTYPE.MACROMOLECULE,i.setTag(t.TAGS.UNITS,"fasta"),i.setTag("alphabet","UN"),i.setTag(".alphabetSize","11"),i.setTag(".alphabetIsMultichar","true"),i.setTag("aligned","SEQ");const[o,s]=(0,u.checkInputColumn)(i,"Test",["fasta"],["DNA","RNA","PT"]);(0,e.l_)(o,!1)})))),(0,e.Bu)("testGetActionFunctionMeta",(()=>Z(void 0,void 0,void 0,(function*(){t.Func.find({package:"Bio",name:"multipleSequenceAlignmentAny"})[0].inputs.find((t=>"sequence"==t.name))}))))}));var K=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};function $(e){return K(this,void 0,void 0,(function*(){const n=yield function(t){return K(this,void 0,void 0,(function*(){return yield ut.files.readAsText(t)}))}(e),i=t.DataFrame.fromCsv(n);return i.name=e.replace(".csv",""),i}))}function z(t){return K(this,void 0,void 0,(function*(){const e=yield $(t);return e.name=t.replace(".csv",""),h.shell.addTableView(e)}))}var X=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};let q,j;function J(t,e){for(const n of t.view.viewers)if(n.type===e)return n}function Q(t){return X(this,void 0,void 0,(function*(){const e=new Promise(((e,n)=>{t.computeCompleted.subscribe((t=>X(this,void 0,void 0,(function*(){try{e(!0)}catch(t){n(t)}}))))}));yield e}))}(0,e.W3)("similarity/diversity",(()=>X(void 0,void 0,void 0,(function*(){(0,e.bb)((()=>X(void 0,void 0,void 0,(function*(){q=[],j=[]})))),(0,e.X5)((()=>X(void 0,void 0,void 0,(function*(){for(const t of q)t.close();for(const t of j)h.shell.closeTable(t)})))),(0,e.Bu)("similaritySearchViewer",(()=>X(void 0,void 0,void 0,(function*(){yield function(){return X(this,void 0,void 0,(function*(){const n=yield z("tests/sample_MSA_data.csv"),i=n.addViewer("Sequence Similarity Search");yield(0,e.gw)(100);const o=J(i,"Sequence Similarity Search");q.push(o),q.push(n),o.molCol||(yield Q(o)),(0,e.l_)(o.fingerprint,"Morgan"),(0,e.l_)(o.distanceMetric,"Tanimoto"),(0,e.l_)(o.scores.get(0),t.FLOAT_NULL),(0,e.l_)(o.idxs.get(0),0),(0,e.l_)(o.molCol.get(0),"D-Tyr_Et/Tyr_ab-dehydroMe/dV/E/N/D-Orn/D-aThr//Phe_4Me"),(0,e.l_)(o.scores.get(1),.4722222089767456),(0,e.l_)(o.idxs.get(1),11),(0,e.l_)(o.molCol.get(1),"meI/hHis//Aca/meM/Tyr_ab-dehydroMe/dV/E/N/D-Orn/D-aThr//Phe_4Me");const s=Q(o);n.dataFrame.currentRowIdx=1,yield s,(0,e.l_)(o.targetMoleculeIdx,1),(0,e.l_)(o.molCol.get(0),"meI/hHis/Aca/Cys_SEt/T/dK/Thr_PO3H2/Aca/Tyr_PO3H2/D-Chg/dV/Phe_ab-dehydro/N/D-Orn/D-aThr//Phe_4Me")}))}()})))),(0,e.Bu)("diversitySearchViewer",(()=>X(void 0,void 0,void 0,(function*(){yield function(){return X(this,void 0,void 0,(function*(){const t=yield z("tests/sample_MSA_data.csv"),n=t.addViewer("Sequence Diversity Search");yield(0,e.gw)(10);const i=J(n,"Sequence Diversity Search");q.push(i),q.push(t),i.renderMolIds||(yield Q(i)),(0,e.l_)(i.fingerprint,"Morgan"),(0,e.l_)(i.distanceMetric,"Tanimoto"),(0,e.l_)(i.initialized,!0),(0,e.l_)(i.renderMolIds.length>0,!0)}))}()}))))}))));var tt=n(4413),et=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};(0,e.W3)("substructureFilters",(()=>et(void 0,void 0,void 0,(function*(){let t,n;(0,e.bb)((()=>et(void 0,void 0,void 0,(function*(){t=yield(0,A.JN)(),n=yield h.dapi.userDataStorage.get(R.RV,!0),yield h.dapi.userDataStorage.post(R.RV,R.rb,!0),yield t.loadLibraries(!0)})))),(0,e.X5)((()=>et(void 0,void 0,void 0,(function*(){yield h.dapi.userDataStorage.put(R.RV,n,!0),yield t.loadLibraries(!0)})))),(0,e.Bu)("fasta",(()=>et(void 0,void 0,void 0,(function*(){const t=yield $("tests/filter_FASTA.csv"),n=new tt.ST;yield h.data.detectSemanticTypes(t),n.attach(t),n.bioFilter.substructure="MD",yield(0,e.gw)(100),(0,e.l_)(n.dataFrame.filter.trueCount,3),(0,e.l_)(n.dataFrame.filter.get(0),!0),(0,e.l_)(n.dataFrame.filter.get(3),!0),(0,e.l_)(n.dataFrame.filter.get(8),!0),(0,e.l_)(n.dataFrame.filter.get(1),!1)})))),(0,e.Bu)("separator",(()=>et(void 0,void 0,void 0,(function*(){const t=yield $("tests/filter_MSA.csv"),n=new tt.ST;yield h.data.detectSemanticTypes(t),n.attach(t),n.bioFilter.substructure="meI",yield(0,e.gw)(100),(0,e.l_)(n.dataFrame.filter.trueCount,7),(0,e.l_)(n.dataFrame.filter.get(2),!1),n.bioFilter.substructure="/meI",yield(0,e.gw)(100),(0,e.l_)(n.dataFrame.filter.trueCount,0),n.bioFilter.substructure="meI-hHis",n.bioFilter.separatorInput.value="-",yield(0,e.gw)(100),(0,e.l_)(n.dataFrame.filter.trueCount,7),(0,e.l_)(n.dataFrame.filter.get(2),!1)})))),(0,e.Bu)("helm",(()=>et(void 0,void 0,void 0,(function*(){const t=yield $("tests/filter_HELM.csv"),n=h.shell.addTableView(t),i=new tt.ST;yield h.data.detectSemanticTypes(t),i.attach(t);const o=new Promise(((e,n)=>{t.onFilterChanged.subscribe((t=>et(void 0,void 0,void 0,(function*(){try{e(!0)}catch(t){n(t)}}))))}));i.bioFilter.helmSubstructure="PEPTIDE1{C}$$$$V2.0",i.bioFilter.onChanged.next(),yield o,(0,e.l_)(i.dataFrame.filter.trueCount,2),(0,e.l_)(i.dataFrame.filter.get(0),!0),(0,e.l_)(i.dataFrame.filter.get(3),!0),i.bioFilter.helmSubstructure="PEPTIDE1{A.C}$$$$V2.0",i.bioFilter.onChanged.next(),yield(0,e.gw)(100),(0,e.l_)(i.dataFrame.filter.trueCount,1),(0,e.l_)(i.dataFrame.filter.get(3),!0),n.close()}))),{skipReason:"GROK-12779"})}))));var nt=n(8341);(0,e.W3)("PepSeA",(()=>{(0,e.Bu)("Basic alignment",(()=>{return n=void 0,i=void 0,s=function*(){const n=t.DataFrame.fromCsv('HELM,MSA\n "PEPTIDE1{F.L.R.G.W.[MeF].Y.S.N.N.C}$$$$","F.L.R.G.W.MeF.Y..S.N.N.C"\n "PEPTIDE1{F.L.R.G.Y.[MeF].Y.W.N.C}$$$$","F.L.R.G.Y.MeF.Y.W...N.C"\n "PEPTIDE1{F.G.Y.[MeF].Y.W.S.D.N.C}$$$$","F...G.Y.MeF.Y.W.S.D.N.C"\n "PEPTIDE1{F.L.R.G.Y.[MeF].Y.W.S.N.D.C}$$$$","F.L.R.G.Y.MeF.Y.W.S.N.D.C"\n "PEPTIDE1{F.V.R.G.Y.[MeF].Y.W.S.N.C}$$$$","F.V.R.G.Y.MeF.Y.W.S..N.C"'),i=yield(0,nt.f)(n.getCol("HELM"),"msa(HELM)"),o=n.getCol("MSA");for(let t=0;t<i.length;++t)(0,e.l_)(i.get(t)==o.get(t),!0)},new((o=void 0)||(o=Promise))((function(t,e){function r(t){try{l(s.next(t))}catch(t){e(t)}}function a(t){try{l(s.throw(t))}catch(t){e(t)}}function l(e){var n;e.done?t(e.value):(n=e.value,n instanceof o?n:new o((function(t){t(n)}))).then(r,a)}l((s=s.apply(n,i||[])).next())}));var n,i,o,s}),{skipReason:"GROK-12764"})}));(0,e.W3)("viewers",(()=>{const n=t.Func.find({package:"Bio",tags:["viewer"]}).map((t=>t.friendlyName));for(const t of n)(0,e.Bu)(t,(()=>{return n=void 0,i=void 0,s=function*(){yield(0,e.AB)(t,yield $("data/sample_FASTA_DNA.csv"),!0)},new((o=void 0)||(o=Promise))((function(t,e){function r(t){try{l(s.next(t))}catch(t){e(t)}}function a(t){try{l(s.throw(t))}catch(t){e(t)}}function l(e){var n;e.done?t(e.value):(n=e.value,n instanceof o?n:new o((function(t){t(n)}))).then(r,a)}l((s=s.apply(n,i||[])).next())}));var n,i,o,s}))}));var it=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};function ot(t,n,i,o){return it(this,void 0,void 0,(function*(){yield h.data.detectSemanticTypes(t);const s=yield(0,u.activityCliffs)(t,t.getCol(o),t.getCol("Activity"),50,i);(0,e.l_)(null!=s,!0);const r=Array.from(s.root.children).find((t=>{const e=t.className.split(" ");return["ui-btn","ui-btn-ok"].every((t=>e.includes(t)))}));(0,e.l_)(r.innerText.toLowerCase(),`${n} cliffs`)}))}var st=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};(0,e.W3)("activityCliffs",(()=>st(void 0,void 0,void 0,(function*(){let t,n,i,o,s=[],r=[];(0,e.bb)((()=>st(void 0,void 0,void 0,(function*(){s=[],r=[]})))),(0,e.X5)((()=>st(void 0,void 0,void 0,(function*(){})))),(0,e.Bu)("activityCliffsOpens",(()=>st(void 0,void 0,void 0,(function*(){n=yield $("tests/sample_MSA_data.csv"),r.push(n),t=h.shell.addTableView(n),s.push(t),yield ot(n,57,"UMAP","MSA")}))),{skipReason:"GROK-12774"}),(0,e.Bu)("activityCliffsWithEmptyRows",(()=>st(void 0,void 0,void 0,(function*(){o=yield $("tests/sample_MSA_data_empty_vals.csv"),r.push(o),i=h.shell.addTableView(o),s.push(i),yield ot(o,57,"UMAP","MSA")}))),{skipReason:"GROK-12774"})}))));var rt=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};function at(t,n,i){return rt(this,void 0,void 0,(function*(){const o=t.getCol(i),s=yield h.functions.call("Bio:detectMacromolecule",{col:o});s&&(o.semType=s);const r=yield(0,u.sequenceSpaceTopMenu)(t,t.col(i),n,"Levenshtein",!0);(0,e.l_)(null!=r,!0)}))}var lt=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};(0,e.W3)("sequenceSpace",(()=>lt(void 0,void 0,void 0,(function*(){let t,n,i,o;(0,e.Bu)("sequenceSpaceOpens",(()=>lt(void 0,void 0,void 0,(function*(){t=yield $("tests/sample_MSA_data.csv"),n=h.shell.addTableView(t),yield at(t,"UMAP","MSA"),h.shell.closeTable(t),n.close()}))),{skipReason:"GROK-12775"}),(0,e.Bu)("sequenceSpaceWithEmptyRows",(()=>lt(void 0,void 0,void 0,(function*(){i=yield $("tests/sample_MSA_data_empty_vals.csv"),o=h.shell.addTableView(i),yield at(i,"UMAP","MSA"),h.shell.closeTable(i),o.close()}))),{skipReason:"GROK-12775"})}))));var ht=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};const ut=new t.Package;function ct(n,i,o){return ht(this,void 0,void 0,(function*(){const s=yield(0,e.ci)({category:n,test:i,testContext:o});return t.DataFrame.fromObjects(s)}))}})(),bio_test=i})();
2
2
  //# sourceMappingURL=package-test.js.map