@datagrok/peptides 1.27.5 → 1.27.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +12 -1
- package/dist/705.js +1 -1
- package/dist/705.js.map +1 -1
- package/dist/package-test.js +1 -1
- package/dist/package-test.js.map +1 -1
- package/dist/package.js +1 -1
- package/dist/package.js.map +1 -1
- package/package.json +6 -6
- package/src/package.g.ts +4 -4
- package/src/package.ts +5 -5
- package/src/viewers/sar-viewer.ts +151 -0
- package/src/widgets/peptides.ts +11 -10
- package/test-console-output-1.log +75 -143
- package/test-record-1.mp4 +0 -0
package/dist/package.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var peptides;(()=>{var t={3981:(t,e,n)=>{"use strict";var i;n.d(e,{o:()=>i}),function(t){t.BASE="HELM_BASE",t.SUGAR="HELM_SUGAR",t.LINKER="HELM_LINKER",t.AA="HELM_AA",t.CHEM="HELM_CHEM",t.BLOB="HELM_BLOB",t.NUCLEOTIDE="HELM_NUCLETIDE"}(i||(i={}))},4971:(t,e,n)=>{"use strict";n.d(e,{pj:()=>o});var i=n(6082);async function o(){const t=i.Func.find({package:"Bio",name:"getMonomerLibHelper"});if(0===t.length)throw new Error('Package "Bio" must be installed for MonomerLibHelper.');return(await t[0].prepare().call()).getOutputParamValue()}},439:(t,e,n)=>{"use strict";n.d(e,{B5:()=>a,Hi:()=>i,YI:()=>o,_S:()=>c,b9:()=>h,gp:()=>r,ot:()=>d,q7:()=>u});var i,o,r,s=n(2738);!function(t){t.FASTA="fasta",t.SEPARATOR="separator",t.HELM="helm",t.CUSTOM="custom",t.BILN="biln"}(i||(i={})),function(t){t.DNA="DNA",t.RNA="RNA",t.PT="PT",t.UN="UN"}(o||(o={})),function(t){t.aligned="aligned",t.alphabet="alphabet",t.alphabetSize=".alphabetSize",t.alphabetIsMultichar=".alphabetIsMultichar",t.separator="separator",t.isHelmCompatible=".isHelmCompatible",t.positionNames=".positionNames",t.positionLabels=".positionLabels",t.regions=".regions",t.positionShift=".positionShift",t.selectedPosition=".selectedPosition",t.polymerTypeColumnName=".polymerTypeColumnName"}(r||(r={}));const a=/(?:\[([A-Za-z0-9_\-,()]+)\])|([A-Za-z\-])/g,l=new class{constructor(){this.fasta={peptide:new Set(["G","L","Y","S","E","Q","D","N","F","A","K","R","H","C","V","P","W","I","M","T"]),dna:new Set(["A","C","G","T"]),rna:new Set(["A","C","G","U"])}}},u=[new s.a(o.PT,l.fasta.peptide,.5),new s.a(o.DNA,l.fasta.dna,.55),new s.a(o.RNA,l.fasta.rna,.55)],c="",h={[i.FASTA]:"-",[i.SEPARATOR]:"",[i.HELM]:"*",[i.BILN]:""},d=" , "},2003:(t,e,n)=>{"use strict";n.d(e,{Hi:()=>i.Hi,SM:()=>o.SM,YI:()=>i.YI,gp:()=>i.gp,ot:()=>i.ot,zS:()=>o.zS});var i=n(439),o=n(7194)},4025:(t,e,n)=>{"use strict";n.d(e,{j:()=>o});var i=n(6082);n(439),n(7194);const o=new class{constructor(){this.seqHandler="seq-handler",this.notationProvider="seq-handler.notation-provider"}};i.SemanticValue},2738:(t,e,n)=>{"use strict";n.d(e,{X:()=>o,a:()=>i});class i{constructor(t,e,n){this.name=t,this.alphabet=e,this.cutoff=n}}class o extends i{constructor(t,e,n){super(t.name,t.alphabet,t.cutoff),this.freq=e,this.similarity=n}}},7194:(t,e,n)=>{"use strict";n.d(e,{Mu:()=>A,zS:()=>N,SM:()=>M,qp:()=>E});var i=n(6082),o=n(144),r=n.n(o);class s extends Float32Array{}function a(t){let e=0;for(let n=0;n<t.length;n++)e+=t[n]*t[n];return Math.sqrt(e)}var l=n(2738),u=n(439);class c{static makePalette(t,e=!1,n=c){const i={};return t.forEach((t=>{const n=t[0],o=t[1];n.forEach(((t,n)=>{i[t]=this.colourPalette[o][e?0:n]}))})),new n(i)}constructor(t){this._palette=t}get(t,e){return this._palette[t]}}c.undefinedColor="rgb(100,100,100)",c.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)"]};class h extends c{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,h)),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,h)),this.grokGroups}static get RasMol(){return void 0===this.rasMol&&(this.rasMol=new h({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 h.aaSynonyms?h.aaSynonyms[t]:t;return super.get(e)}}h.aaSynonyms={MeNle:"L",MeA:"A",MeG:"G",MeF:"F"};class d{static getPalette(t="grok"){switch(t){case"grok":return h.GrokGroups;case"lesk":return h.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"){const n=this.getPalette(e);let[i,o]=this.getInnerOuter(t);if(i=i.length>6?`${i.slice(0,3)}...`:i,o=o.length>6?`${o.slice(0,3)}...`:o,1==t.length||"("==t[1]){const e=t[0]?.toUpperCase();return e in n?[n.get(e),e,o,1]:[this.undefinedColor,i,o,1]}if("d"==t[0]&&t[1]in n&&(2==t.length||"("==t[2])){const e=t[1]?.toUpperCase();return e in n?[n.get(e),e,o,2]:[this.undefinedColor,i,o,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 n?[n.get(e),e,o,3]:[this.undefinedColor,i,o,3]}if(t[0]?.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 n?[n.get(e),e,o,4]:[this.undefinedColor,i,o,4]}return[this.undefinedColor,i,o,0]}}d.SemType="Aminoacids",d.SemTypeMultipleAlignment="AminoacidsMultipleAlignment",d.undefinedColor="rgb(100,100,100)",d.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"},d.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"},d.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(*)*"},d.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"};class f extends c{static get Chromatogram(){return void 0===this.chromatogram&&(this.chromatogram=new f({A:"green",C:"blue",G:"black",T:"red",U:"red",others:"gray"})),this.chromatogram}}class m{}m.SemType="Nucleotides",m.SemTypeMultipleAlignment="NucleotidesMultipleAlignment",m.Names={A:"Adenine",C:"Cytosine",G:"Guanine",T:"Thymine",U:"Uracil"};var p=n(4971);function g(t,e=!0){if(null==t)return"rgb(100,100,100)";const n=i.Color.fromHtml(t);if(e){const t=i.Color.g(n),e=i.Color.r(n),o=i.Color.b(n),r=Math.sqrt(Math.pow(0-e,2)+Math.pow(0-t,2)+Math.pow(0-o,2));if(r>210)return`rgb(${e/r*210},${t/r*210},${o/r*210})`}return i.Color.toRgb(n)}class v{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 C{}class y extends C{get(t,e){return"#666666"}}class w extends C{static get palette(){return w._pallete||(w._pallete=w.buildPalette()),w._pallete}static buildPalette(){return(0,p.pj)().then((t=>{t.awaitLoaded(1/0).then((()=>{const e=t.getMonomerLib();e.onChanged.subscribe((()=>{w.customMonomerColors={},w.polymerTypes=e.getPolymerTypes();for(const t of this.polymerTypes){const n=e.getMonomerSymbolsByType(t);for(const i of n){const n=e.getMonomer(t,i);n?.meta?.colors?.default?.background&&(this.customMonomerColors[i]||(this.customMonomerColors[i]={}),this.customMonomerColors[i][t]=g(n.meta.colors.default.background))}}}))}))})),[].concat(...Object.values(c.colourPalette))}get(t,e){const n=w.palette.length,i=w.customMonomerColors[t],o=e??"PEPTIDE";if(i&&i[o])return i[o];const r=v.hashCode(t)%n;return g(w.palette[r])}}w._pallete=null,w.customMonomerColors={},w.polymerTypes=[];class b extends c{static get Gray(){return void 0===this.gray&&(this.gray=new y),this.gray}static get Color(){return void 0===this.color&&(this.color=new w),this.color}}n(3981);class A{get length(){return this.mList.length}get graphInfo(){}isGap(t){return this.getOriginal(t)===this.gapOriginalMonomer}getCanonical(t){if(this.length<=t)throw new Error("Index out of bounds");const e=this.mList[t];return e!==this.gapOriginalMonomer?e:u._S}getOriginal(t){if(this.length<=t)throw new Error("Index out of bounds");return this.mList[t]}getCanonicalRegion(t,e){const n=Math.min(Math.max(0,t),this.length),i=Math.max(Math.min(this.length,e),0)-n,o=this.gapOriginalMonomer;return new Array(i).fill(null).map(((t,e)=>{const i=this.mList[e+n];return i===o?u._S:i}))}getOriginalRegion(t,e){const n=Math.min(Math.max(0,t),this.length),i=Math.max(Math.min(this.length,e),0);return new Array(i-n).fill(null).map(((t,e)=>this.mList[e+n]))}get gapOriginal(){return this.gapOriginalMonomer}constructor(t,e){this.mList=t,this.gapOriginalMonomer=e}}class S extends A{constructor(t,e,n,i){super(t.flat(),i),this.mListSeparated=t,this.connections=e,this._graphInfo=void 0,this.polymerTypes=t.map(((t,e)=>new Array(t.length).fill(n[e]))).flat()}get graphInfo(){return this._graphInfo??(this._graphInfo=this.parseConnections()),this._graphInfo}parseConnections(){const t={connections:[],disjointSeqStarts:[],polymerTypes:this.polymerTypes};if((this.connections?.length??0)>0){let e=0;for(let n=0;n<this.mListSeparated.length;++n)t.disjointSeqStarts.push(e),e+=this.mListSeparated[n].length;const n=(this.connections??"").split("|").filter((t=>(t?.length??0)>0)),i=/^(PEPTIDE|RNA|BLOB|CHEM)\d{1,2}$/,o=/^\d{1,2}:R\d{1}-\d{1,2}:R\d{1}$/;for(const e of n){const n=e.split(",");if(3!==n.length||!o.test(n[2])||!i.test(n[0])||!i.test(n[1]))continue;const r=parseInt(n[0].replace(/^(PEPTIDE|RNA|BLOB|CHEM)/,""))-1,s=parseInt(n[1].replace(/^(PEPTIDE|RNA|BLOB|CHEM)/,""))-1,a=n[0].replace(/\d{1,2}$/,""),l=n[1].replace(/\d{1,2}$/,"");if(r<0||r>=this.mListSeparated.length||s<0||s>=this.mListSeparated.length)continue;const u=n[2].split("-");if(2!==u.length)continue;const c=u[0].split(":"),h=u[1].split(":");if(2!==c.length||2!==h.length)continue;const d=parseInt(c[0])-1,f=parseInt(h[0])-1;d<0||d>=this.mListSeparated[r].length||f<0||f>=this.mListSeparated[s].length||t.connections.push({seq1Type:a,seq2Type:l,seqIndex1:r,seqIndex2:s,monomerIndex1:d,monomerIndex2:f,rGroup1:parseInt(c[1].substring(1)),rGroup2:parseInt(h[1].substring(1))})}}return t}}const T=t=>{const e=r()(t.toString().matchAll(u.B5)).map((t=>t[2]??t[1])).toArray();return new A(e,u.b9[u.Hi.FASTA])},E=t=>{const e=t.indexOf("}$"),n=t.substring(0,e+1),i=t.indexOf("$",e+2),o=t.substring(e+2,i),r=n.split("}|");for(let t=0;t<r.length-1;t++)r[t]=r[t]+"}";const s=r.map((t=>(t.match(/(?<=\{).+(?=})/)?.[0]?.split(".")??[]).map((t=>{return(e=t).startsWith("[")&&e.endsWith("]")?e.slice(1,-1):e;var e})))),a=r.map((t=>t.replace(/\d{1,2}\{.+\}/,"")));return new S(s,o??"",a,u.b9[u.Hi.HELM])},_=/([^\W_]+)/g;function N(t,e){if(t.length<=e)return t;const n=t.match(_),i=t.length>e||(n?.length??0)>1,o=n?.[0]??" ";return i?o.substring(0,e-1)+"…":o}function x(t,e,n="-"){const i=e.map((e=>{const i=function(t,e,n="-"){const i=new Set([...new Set(Object.keys(t)),...e]);i.delete(n);const o=[],r=[];for(const n of i)o.push(n in t?t[n]:0),r.push(e.has(n)?1:0);const l=new s(o),u=new s(r);return function(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}(l,u)/(a(l)*a(u))}(t,e.alphabet,n);return new l.X(e,t,i)}));let o;const r=Math.max(...i.map((t=>t.similarity>t.cutoff?t.similarity:-1)));return o=r>0?i.find((t=>t.similarity===r)).name:u.YI.UN,o}function M(t,e,n=5){let o;if(t.semType==i.SEMTYPE.MACROMOLECULE)o=e.getSeqHandler(t).alphabet;else{const e=function(t,e,n){const i=t.categories;return function(t,e){const n={};let i=!0,o=null;for(const r of t)if(null==o?o=r.length:r.length!==o&&(i=!1),r.length>=e)for(let t=0;t<r.length;++t){const e=r.getCanonical(t);e in n||(n[e]=0),n[e]+=1}return{freq:n,sameLength:i}}(r().enumerate(t.getRawData()).map((([t,e])=>n(i[t]))),e)}(t,n,T);o=x(e.freq,u.q7)}return function(t){switch(t){case u.YI.PT:return h.GrokGroups;case u.YI.DNA:case u.YI.RNA:return f.Chromatogram;default:return b.Color}}(o)}},3077:(t,e,n)=>{"use strict";n.d(e,{R:()=>o});var i=n(6082);function o(t,e){const n=t=>{const e=s.columns.addNewString((t+1).toString());return o.push(e),e},o=[],r=t.length,s=i.DataFrame.create(r),a=e.getSeqHandler(t);for(let t=0;t<r;++t){const e=a.getSplitted(t);for(let i=0;i<e.length;++i){const r=e.getCanonical(i);((o[i]??null)||n(i)).set(t,r,!1)}}return s}},4326:(t,e,n)=>{"use strict";n.d(e,{P4:()=>s,fH:()=>o});var i,o,r,s,a,l,u=n(6082);!function(t){t.tooltipWebLogo=".tooltipWebLogo"}(i||(i={})),function(t){t.Entropy="Entropy",t.full="100%"}(o||(o={})),function(t){t.TOP="top",t.MIDDLE="middle",t.BOTTOM="bottom"}(r||(r={})),function(t){t.LEFT="left",t.CENTER="center",t.RIGHT="right"}(s||(s={})),function(t){t.AUTO="auto",t.ON="on",t.OFF="off"}(a||(a={})),function(t){t.Filtered="Filtered",t.Selected="Selected"}(l||(l={})),new class{constructor(){this.sequenceColumnName=null,this.valueAggrType=u.AGG.TOTAL_COUNT,this.valueColumnName="Activity",this.startPositionName=null,this.endPositionName=null,this.skipEmptySequences=!0,this.skipEmptyPositions=!1,this.shrinkEmptyTail=!0,this.backgroundColor=4294967295,this.positionHeight=o.Entropy,this.positionWidth=20,this.verticalAlignment=r.MIDDLE,this.horizontalAlignment=s.CENTER,this.fixWidth=!1,this.fitArea=!0,this.minHeight=25,this.maxHeight=300,this.maxMonomerLetters=5,this.showPositionLabels=!0,this.positionMarginState=a.AUTO,this.positionMargin=0,this.filterSource=l.Filtered}}},5540:(t,e,n)=>{"use strict";t=n.hmd(t);var i,o=(i="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0,function(t={}){var e,n,o=void 0!==t?t:{};o.ready=new Promise((function(t,i){e=t,n=i}));var r,s=Object.assign({},o),a="object"==typeof window,l="function"==typeof importScripts,u=("object"==typeof process&&"object"==typeof process.versions&&process.versions.node,"");(a||l)&&(l?u=self.location.href:"undefined"!=typeof document&&document.currentScript&&(u=document.currentScript.src),i&&(u=i),u=0!==u.indexOf("blob:")?u.substr(0,u.replace(/[?#].*/,"").lastIndexOf("/")+1):"",l&&(r=t=>{var e=new XMLHttpRequest;return e.open("GET",t,!1),e.responseType="arraybuffer",e.send(null),new Uint8Array(e.response)})),o.print||console.log.bind(console);var c,h,d=o.printErr||console.warn.bind(console);Object.assign(o,s),s=null,o.arguments&&o.arguments,o.thisProgram&&o.thisProgram,o.quit&&o.quit,o.wasmBinary&&(c=o.wasmBinary),o.noExitRuntime,"object"!=typeof WebAssembly&&T("no native wasm support detected");var f,m,p,g=!1;function v(){var t=h.buffer;o.HEAP8=f=new Int8Array(t),o.HEAP16=new Int16Array(t),o.HEAP32=new Int32Array(t),o.HEAPU8=m=new Uint8Array(t),o.HEAPU16=new Uint16Array(t),o.HEAPU32=p=new Uint32Array(t),o.HEAPF32=new Float32Array(t),o.HEAPF64=new Float64Array(t)}var C=[],y=[],w=[],b=0,A=null,S=null;function T(t){o.onAbort&&o.onAbort(t),d(t="Aborted("+t+")"),g=!0,t+=". Build with -sASSERTIONS for more info.";var e=new WebAssembly.RuntimeError(t);throw n(e),e}var E,_;function N(t){return t.startsWith("data:application/octet-stream;base64,")}function x(t){try{if(t==E&&c)return new Uint8Array(c);if(r)return r(t);throw"both async and sync fetching of the wasm failed"}catch(t){T(t)}}function M(t,e,n){return function(t){return c||!a&&!l||"function"!=typeof fetch?Promise.resolve().then((function(){return x(t)})):fetch(t,{credentials:"same-origin"}).then((function(e){if(!e.ok)throw"failed to load wasm binary file at '"+t+"'";return e.arrayBuffer()})).catch((function(){return x(t)}))}(t).then((function(t){return WebAssembly.instantiate(t,e)})).then((function(t){return t})).then(n,(function(t){d("failed to asynchronously prepare wasm: "+t),T(t)}))}function I(t){for(;t.length>0;)t.shift()(o)}function O(t){this.excPtr=t,this.ptr=t-24,this.set_type=function(t){p[this.ptr+4>>2]=t},this.get_type=function(){return p[this.ptr+4>>2]},this.set_destructor=function(t){p[this.ptr+8>>2]=t},this.get_destructor=function(){return p[this.ptr+8>>2]},this.set_caught=function(t){t=t?1:0,f[this.ptr+12|0]=t},this.get_caught=function(){return 0!=f[this.ptr+12|0]},this.set_rethrown=function(t){t=t?1:0,f[this.ptr+13|0]=t},this.get_rethrown=function(){return 0!=f[this.ptr+13|0]},this.init=function(t,e){this.set_adjusted_ptr(0),this.set_type(t),this.set_destructor(e)},this.set_adjusted_ptr=function(t){p[this.ptr+16>>2]=t},this.get_adjusted_ptr=function(){return p[this.ptr+16>>2]},this.get_exception_ptr=function(){if(q(this.get_type()))return p[this.excPtr>>2];var t=this.get_adjusted_ptr();return 0!==t?t:this.excPtr}}function L(t){var e=h.buffer;try{return h.grow(t-e.byteLength+65535>>>16),v(),1}catch(t){}}function P(t){return o["_"+t]}N(E="wasmDbscan.wasm")||(_=E,E=o.locateFile?o.locateFile(_,u):u+_);var R="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function k(t,e,n,i,o){var r={string:t=>{var e=0;return null!=t&&0!==t&&(e=function(t){var e=function(t){for(var e=0,n=0;n<t.length;++n){var i=t.charCodeAt(n);i<=127?e++:i<=2047?e+=2:i>=55296&&i<=57343?(e+=4,++n):e+=3}return e}(t)+1,n=U(e);return function(t,e,n){!function(t,e,n,i){if(!(i>0))return 0;for(var o=n+i-1,r=0;r<t.length;++r){var s=t.charCodeAt(r);if(s>=55296&&s<=57343&&(s=65536+((1023&s)<<10)|1023&t.charCodeAt(++r)),s<=127){if(n>=o)break;e[n++]=s}else if(s<=2047){if(n+1>=o)break;e[n++]=192|s>>6,e[n++]=128|63&s}else if(s<=65535){if(n+2>=o)break;e[n++]=224|s>>12,e[n++]=128|s>>6&63,e[n++]=128|63&s}else{if(n+3>=o)break;e[n++]=240|s>>18,e[n++]=128|s>>12&63,e[n++]=128|s>>6&63,e[n++]=128|63&s}}e[n]=0}(t,m,e,n)}(t,n,e),n}(t)),e},array:t=>{var e,n,i=U(t.length);return e=t,n=i,f.set(e,n),i}},s=P(t),a=[],l=0;if(i)for(var u=0;u<i.length;u++){var c=r[n[u]];c?(0===l&&(l=D()),a[u]=c(i[u])):a[u]=i[u]}var h=s.apply(null,a);return function(t){return 0!==l&&G(l),function(t){return"string"===e?(n=t)?function(t,e,n){for(var i=e+n,o=e;t[o]&&!(o>=i);)++o;if(o-e>16&&t.buffer&&R)return R.decode(t.subarray(e,o));for(var r="";e<o;){var s=t[e++];if(128&s){var a=63&t[e++];if(192!=(224&s)){var l=63&t[e++];if((s=224==(240&s)?(15&s)<<12|a<<6|l:(7&s)<<18|a<<12|l<<6|63&t[e++])<65536)r+=String.fromCharCode(s);else{var u=s-65536;r+=String.fromCharCode(55296|u>>10,56320|1023&u)}}else r+=String.fromCharCode((31&s)<<6|a)}else r+=String.fromCharCode(s)}return r}(m,n,i):"":"boolean"===e?Boolean(t):t;var n,i}(t)}(h)}var V,F={__cxa_throw:function(t,e,n){throw new O(t).init(e,n),t},abort:function(){T("")},emscripten_memcpy_big:function(t,e,n){m.copyWithin(t,e,e+n)},emscripten_resize_heap:function(t){var e,n=m.length,i=2147483648;if((t>>>=0)>i)return!1;for(var o=1;o<=4;o*=2){var r=n*(1+.2/o);if(r=Math.min(r,t+100663296),L(Math.min(i,(e=Math.max(t,r))+(65536-e%65536)%65536)))return!0}return!1}},D=(function(){var t,e,i,r,s={env:F,wasi_snapshot_preview1:F};function a(t,e){var n,i=t.exports;return o.asm=i,h=o.asm.memory,v(),o.asm.__indirect_function_table,n=o.asm.__wasm_call_ctors,y.unshift(n),function(t){if(b--,o.monitorRunDependencies&&o.monitorRunDependencies(b),0==b&&(null!==A&&(clearInterval(A),A=null),S)){var e=S;S=null,e()}}(),i}if(b++,o.monitorRunDependencies&&o.monitorRunDependencies(b),o.instantiateWasm)try{return o.instantiateWasm(s,a)}catch(t){d("Module.instantiateWasm callback failed with error: "+t),n(t)}(t=c,e=E,i=s,r=function(t){a(t.instance)},t||"function"!=typeof WebAssembly.instantiateStreaming||N(e)||"function"!=typeof fetch?M(e,i,r):fetch(e,{credentials:"same-origin"}).then((function(t){return WebAssembly.instantiateStreaming(t,i).then(r,(function(t){return d("wasm streaming compile failed: "+t),d("falling back to ArrayBuffer instantiation"),M(e,i,r)}))}))).catch(n)}(),o._dbscan=function(){return(o._dbscan=o.asm.dbscan).apply(null,arguments)},o._malloc=function(){return(o._malloc=o.asm.malloc).apply(null,arguments)},o._free=function(){return(o._free=o.asm.free).apply(null,arguments)},function(){return(D=o.asm.stackSave).apply(null,arguments)}),G=function(){return(G=o.asm.stackRestore).apply(null,arguments)},U=function(){return(U=o.asm.stackAlloc).apply(null,arguments)},q=function(){return(q=o.asm.__cxa_is_pointer_type).apply(null,arguments)};function B(){function t(){V||(V=!0,o.calledRun=!0,g||(I(y),e(o),o.onRuntimeInitialized&&o.onRuntimeInitialized(),function(){if(o.postRun)for("function"==typeof o.postRun&&(o.postRun=[o.postRun]);o.postRun.length;)t=o.postRun.shift(),w.unshift(t);var t;I(w)}()))}b>0||(function(){if(o.preRun)for("function"==typeof o.preRun&&(o.preRun=[o.preRun]);o.preRun.length;)t=o.preRun.shift(),C.unshift(t);var t;I(C)}(),b>0||(o.setStatus?(o.setStatus("Running..."),setTimeout((function(){setTimeout((function(){o.setStatus("")}),1),t()}),1)):t()))}if(o.ccall=k,o.cwrap=function(t,e,n,i){var o=!n||n.every((t=>"number"===t||"boolean"===t));return"string"!==e&&o&&!i?P(t):function(){return k(t,e,n,arguments)}},S=function t(){V||B(),V||(S=t)},o.preInit)for("function"==typeof o.preInit&&(o.preInit=[o.preInit]);o.preInit.length>0;)o.preInit.pop()();return B(),t.ready});"object"==typeof exports?t.exports=o:"function"==typeof define&&n.amdO?define([],(function(){return o})):"object"==typeof exports&&(exports.exportCppDbscanLib=o)},4329:(t,e,n)=>{"use strict";n.d(e,{_:()=>r});var i=function(t,e,n,i){return new(n||(n=Promise))((function(o,r){function s(t){try{l(i.next(t))}catch(t){r(t)}}function a(t){try{l(i.throw(t))}catch(t){r(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(s,a)}l((i=i.apply(t,e||[])).next())}))};let o=null;function r(){return i(this,void 0,void 0,(function*(){if(!navigator.gpu)return console.error("WebGPU is not supported in this browser"),null;if(!o&&(o=yield navigator.gpu.requestAdapter(),null==o))return null;let t=null;return"info"in o&&(t=o.info),t?s(t.description,s(t.vendor,"No GPU description available")):"No GPU description available"}))}function s(t,e){return t&&""!=t?t:e}},1199:(t,e,n)=>{"use strict";n.d(e,{Z:()=>i});new Uint32Array(65536);var i;!function(t){t.HAMMING="Hamming",t.LEVENSHTEIN="Levenshtein",t.NEEDLEMANN_WUNSCH="Needlemann-Wunsch",t.MONOMER_CHEMICAL_DISTANCE="Monomer chemical distance"}(i||(i={})),i.HAMMING,i.LEVENSHTEIN,i.NEEDLEMANN_WUNSCH,i.MONOMER_CHEMICAL_DISTANCE},8774:(t,e,n)=>{"use strict";n.d(e,{A:()=>i});class i{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,o=i._createBuffer(n);if(e)for(let t=0;t<o.length;t++)o[t]=-1;this._data=o,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 i(t._length);n._length=t._length,n._data=i._createBuffer(n._length),n._version=0;const o=t.lengthInInts;for(let i=0;i<o;i++)n._data[i]=t._data[i]&e._data[i];return n}static _createBuffer(t){return new Uint32Array(Math.floor((t+31)/32))}static fromValues(t){const e=new i(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 i(t);for(let i=0;i<t;++i)n.setBit(i,e(i));return n._version=0,n}static fromString(t){return i.fromSeq(t.length,(e=>"1"==t.charAt(e)))}static fromUint32Array(t,e){const n=new i(t);return n._data=e,n}static fromBytes(t){const e=t.length,n=new i(8*e);n._data=new Uint32Array(Math.floor((e+3)/4)),n._length=8*e;let o=0,r=0;for(;e-r>=4;)n._data[o++]=255&t[r]|(255&t[r+1])<<8|(255&t[r+2])<<16|(255&t[r+3])<<24,r+=4;return e-r==3&&(n._data[o]=(255&t[r+2])<<16),e-r==2&&(n._data[o]|=(255&t[r+1])<<8),e-r==1&&(n._data[o]|=255&t[r]),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 i(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 i.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),r=Math.max(t,e);if(n)for(let t=o;t<=r;t++)this.setTrue(t);else for(let t=o;t<=r;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!!(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+=i._onBitCount[255&t];let n=this._data[e];const o=31&this._length;for(0!=o&&(n&=~(4294967295<<o));0!=n;n>>>=8)this._selectedCount+=i._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 o=this.lengthInInts;let r=0;for(;r<o-1;r++)for(let e=this._data[r]&t._data[r];0!=e;e>>>=8)n+=i._onBitCount[255&e];let s=this._data[r]&t._data[r];const a=31&this._length;for(0!=a&&(s&=~(4294967295<<a));0!=s;s>>>=8)n+=i._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 o=this.lengthInInts;for(let r=Math.floor(t/32);r<o;r++){let o=e?this._data[r]:~this._data[r];if(0!=n)o&=4294967295<<n&4294967295,n=0;else if(!e&&-4294967296==o)continue;for(let e=0;0!=o;e+=8,o>>>=8){const n=i._firstOnBit[255&o];if(n>=0)return(t=n+32*r+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 o=Math.floor(t/32);o>=0;o--){let t=e?this._data[o]:~this._data[o];0!=n&&(t&=~(4294967295<<n),n=0);for(let e=24;0!=t;e-=8,t<<=8){const n=i._lastOnBit[t>>>24];if(n>=0)return n+32*o+e}}return-1}}i._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]),i._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]),i._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])},7233:t=>{!function(){"use strict";var e=document,n=window,i=e.documentElement,o=e.createElement.bind(e),r=o("div"),s=o("table"),a=o("tbody"),l=o("tr"),u=Array.isArray,c=Array.prototype,h=c.concat,d=c.filter,f=c.indexOf,m=c.map,p=c.push,g=c.slice,v=c.some,C=c.splice,y=/^#(?:[\w-]|\\.|[^\x00-\xa0])*$/,w=/^\.(?:[\w-]|\\.|[^\x00-\xa0])*$/,b=/<.+>/,A=/^\w+$/;function S(t,e){var n,i=!!(n=e)&&11===n.nodeType;return t&&(i||M(e)||I(e))?!i&&w.test(t)?e.getElementsByClassName(t.slice(1).replace(/\\/g,"")):!i&&A.test(t)?e.getElementsByTagName(t):e.querySelectorAll(t):[]}var T=function(){function t(t,i){if(t){if(N(t))return t;var o=t;if(L(t)){var r=i||e;if(!(o=y.test(t)&&M(r)?r.getElementById(t.slice(1).replace(/\\/g,"")):b.test(t)?X(t):N(r)?r.find(t):L(r)?_(r).find(t):S(t,r)))return}else if(O(t))return this.ready(t);(o.nodeType||o===n)&&(o=[o]),this.length=o.length;for(var s=0,a=this.length;s<a;s++)this[s]=o[s]}}return t.prototype.init=function(e,n){return new t(e,n)},t}(),E=T.prototype,_=E.init;function N(t){return t instanceof T}function x(t){return!!t&&t===t.window}function M(t){return!!t&&9===t.nodeType}function I(t){return!!t&&1===t.nodeType}function O(t){return"function"==typeof t}function L(t){return"string"==typeof t}function P(t){return void 0===t}function R(t){return null===t}function k(t){return!isNaN(parseFloat(t))&&isFinite(t)}function V(t){if("object"!=typeof t||null===t)return!1;var e=Object.getPrototypeOf(t);return null===e||e===Object.prototype}function F(t,e,n){if(n){for(var i=t.length;i--;)if(!1===e.call(t[i],i,t[i]))return t}else if(V(t))for(var o=Object.keys(t),r=(i=0,o.length);i<r;i++){var s=o[i];if(!1===e.call(t[s],s,t[s]))return t}else for(i=0,r=t.length;i<r;i++)if(!1===e.call(t[i],i,t[i]))return t;return t}function D(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n="boolean"==typeof t[0]&&t.shift(),i=t.shift(),o=t.length;if(!i)return{};if(!o)return D(n,_,i);for(var r=0;r<o;r++){var s=t[r];for(var a in s)n&&(u(s[a])||V(s[a]))?(i[a]&&i[a].constructor===s[a].constructor||(i[a]=new s[a].constructor),D(n,i[a],s[a])):i[a]=s[a]}return i}_.fn=_.prototype=E,E.length=0,E.splice=C,"function"==typeof Symbol&&(E[Symbol.iterator]=c[Symbol.iterator]),_.isWindow=x,_.isFunction=O,_.isArray=u,_.isNumeric=k,_.isPlainObject=V,_.each=F,E.each=function(t){return F(this,t)},E.empty=function(){return this.each((function(t,e){for(;e.firstChild;)e.removeChild(e.firstChild)}))},_.extend=D,E.extend=function(t){return D(E,t)};var G=/\S+/g;function U(t){return L(t)&&t.match(G)||[]}function q(t,e,i){if(I(t)){var o=n.getComputedStyle(t,null);return i?o.getPropertyValue(e)||void 0:o[e]||t.style[e]}}function B(t,e){return parseInt(q(t,e),10)||0}function H(t,e){return B(t,"border".concat(e?"Left":"Top","Width"))+B(t,"padding".concat(e?"Left":"Top"))+B(t,"padding".concat(e?"Right":"Bottom"))+B(t,"border".concat(e?"Right":"Bottom","Width"))}E.toggleClass=function(t,e){var n=U(t),i=!P(e);return this.each((function(t,o){I(o)&&F(n,(function(t,n){i?e?o.classList.add(n):o.classList.remove(n):o.classList.toggle(n)}))}))},E.addClass=function(t){return this.toggleClass(t,!0)},E.removeAttr=function(t){var e=U(t);return this.each((function(t,n){I(n)&&F(e,(function(t,e){n.removeAttribute(e)}))}))},E.attr=function(t,e){if(t){if(L(t)){if(arguments.length<2){if(!this[0]||!I(this[0]))return;var n=this[0].getAttribute(t);return R(n)?void 0:n}return P(e)?this:R(e)?this.removeAttr(t):this.each((function(n,i){I(i)&&i.setAttribute(t,e)}))}for(var i in t)this.attr(i,t[i]);return this}},E.removeClass=function(t){return arguments.length?this.toggleClass(t,!1):this.attr("class","")},E.hasClass=function(t){return!!t&&v.call(this,(function(e){return I(e)&&e.classList.contains(t)}))},E.get=function(t){return P(t)?g.call(this):this[(t=Number(t))<0?t+this.length:t]},E.eq=function(t){return _(this.get(t))},E.first=function(){return this.eq(0)},E.last=function(){return this.eq(-1)},E.text=function(t){return P(t)?this.get().map((function(t){return I(t)||(e=t)&&3===e.nodeType?t.textContent:"";var e})).join(""):this.each((function(e,n){I(n)&&(n.textContent=t)}))};var Y={};function j(t){return"none"===q(t,"display")}function W(t,e){var n=t&&(t.matches||t.webkitMatchesSelector||t.msMatchesSelector);return!!n&&!!e&&n.call(t,e)}function $(t){return L(t)?function(e,n){return W(n,t)}:O(t)?t:N(t)?function(e,n){return t.is(n)}:t?function(e,n){return n===t}:function(){return!1}}function z(t,e){return e?t.filter(e):t}E.filter=function(t){var e=$(t);return _(d.call(this,(function(t,n){return e.call(t,n,t)})))},E.detach=function(t){return z(this,t).each((function(t,e){e.parentNode&&e.parentNode.removeChild(e)})),this};var K=/^\s*<(\w+)[^>]*>/,Z=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,Q={"*":r,tr:a,td:l,th:l,thead:s,tbody:s,tfoot:s};function X(t){if(!L(t))return[];if(Z.test(t))return[o(RegExp.$1)];var e=K.test(t)&&RegExp.$1,n=Q[e]||Q["*"];return n.innerHTML=t,_(n.childNodes).detach().get()}function J(t,e,n,i){for(var o=[],r=O(e),s=i&&$(i),a=0,l=t.length;a<l;a++)if(r){var u=e(t[a]);u.length&&p.apply(o,u)}else for(var c=t[a][e];!(null==c||i&&s(-1,c));)o.push(c),c=n?c[e]:null;return o}function tt(t){return t.multiple&&t.options?J(d.call(t.options,(function(t){return t.selected&&!t.disabled&&!t.parentNode.disabled})),"value"):t.value||""}function et(t){return t.length>1?d.call(t,(function(t,e,n){return f.call(n,t)===e})):t}_.parseHTML=X,E.has=function(t){var e=L(t)?function(e,n){return S(t,n).length}:function(e,n){return n.contains(t)};return this.filter(e)},E.not=function(t){var e=$(t);return this.filter((function(n,i){return(!L(t)||I(i))&&!e.call(i,n,i)}))},E.val=function(t){return arguments.length?this.each((function(e,n){var i=n.multiple&&n.options;if(i||Lt.test(n.type)){var o=u(t)?m.call(t,String):R(t)?[]:[String(t)];i?F(n.options,(function(t,e){e.selected=o.indexOf(e.value)>=0}),!0):n.checked=o.indexOf(n.value)>=0}else n.value=P(t)||R(t)?"":t})):this[0]&&tt(this[0])},E.is=function(t){var e=$(t);return v.call(this,(function(t,n){return e.call(t,n,t)}))},_.guid=1,_.unique=et,E.add=function(t,e){return _(et(this.get().concat(_(t,e).get())))},E.children=function(t){return z(_(et(J(this,(function(t){return t.children})))),t)},E.parent=function(t){return z(_(et(J(this,"parentNode"))),t)},E.index=function(t){var e=t?_(t)[0]:this[0],n=t?this:_(e).parent().children();return f.call(n,e)},E.closest=function(t){var e=this.filter(t);if(e.length)return e;var n=this.parent();return n.length?n.closest(t):e},E.siblings=function(t){return z(_(et(J(this,(function(t){return _(t).parent().children().not(t)})))),t)},E.find=function(t){return _(et(J(this,(function(e){return S(t,e)}))))};var nt=/^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,it=/^$|^module$|\/(java|ecma)script/i,ot=["type","src","nonce","noModule"];function rt(t,e,n,r,s,a,l,u){return F(t,(function(t,a){F(_(a),(function(t,a){F(_(e),(function(e,l){var u=n?l:a,c=n?t:e;!function(t,e,n,r,s){r?t.insertBefore(e,n?t.firstChild:null):"HTML"===t.nodeName?t.parentNode.replaceChild(e,t):t.parentNode.insertBefore(e,n?t:t.nextSibling),s&&function(t,e){var n=_(t);n.filter("script").add(n.find("script")).each((function(t,n){if(it.test(n.type)&&i.contains(n)){var r=o("script");r.text=n.textContent.replace(nt,""),F(ot,(function(t,e){n[e]&&(r[e]=n[e])})),e.head.insertBefore(r,null),e.head.removeChild(r)}}))}(e,t.ownerDocument)}(n?a:l,c?u.cloneNode(!0):u,r,s,!c)}),u)}),l)}),a),e}E.after=function(){return rt(arguments,this,!1,!1,!1,!0,!0)},E.append=function(){return rt(arguments,this,!1,!1,!0)},E.html=function(t){if(!arguments.length)return this[0]&&this[0].innerHTML;if(P(t))return this;var e=/<script[\s>]/.test(t);return this.each((function(n,i){I(i)&&(e?_(i).empty().append(t):i.innerHTML=t)}))},E.appendTo=function(t){return rt(arguments,this,!0,!1,!0)},E.wrapInner=function(t){return this.each((function(e,n){var i=_(n),o=i.contents();o.length?o.wrapAll(t):i.append(t)}))},E.before=function(){return rt(arguments,this,!1,!0)},E.wrapAll=function(t){for(var e=_(t),n=e[0];n.children.length;)n=n.firstElementChild;return this.first().before(e),this.appendTo(n)},E.wrap=function(t){return this.each((function(e,n){var i=_(t)[0];_(n).wrapAll(e?i.cloneNode(!0):i)}))},E.insertAfter=function(t){return rt(arguments,this,!0,!1,!1,!1,!1,!0)},E.insertBefore=function(t){return rt(arguments,this,!0,!0)},E.prepend=function(){return rt(arguments,this,!1,!0,!0,!0,!0)},E.prependTo=function(t){return rt(arguments,this,!0,!0,!0,!1,!1,!0)},E.contents=function(){return _(et(J(this,(function(t){return"IFRAME"===t.tagName?[t.contentDocument]:"TEMPLATE"===t.tagName?t.content.childNodes:t.childNodes}))))},E.next=function(t,e,n){return z(_(et(J(this,"nextElementSibling",e,n))),t)},E.nextAll=function(t){return this.next(t,!0)},E.nextUntil=function(t,e){return this.next(e,!0,t)},E.parents=function(t,e){return z(_(et(J(this,"parentElement",!0,e))),t)},E.parentsUntil=function(t,e){return this.parents(e,t)},E.prev=function(t,e,n){return z(_(et(J(this,"previousElementSibling",e,n))),t)},E.prevAll=function(t){return this.prev(t,!0)},E.prevUntil=function(t,e){return this.prev(e,!0,t)},E.map=function(t){return _(h.apply([],m.call(this,(function(e,n){return t.call(e,n,e)}))))},E.clone=function(){return this.map((function(t,e){return e.cloneNode(!0)}))},E.offsetParent=function(){return this.map((function(t,e){for(var n=e.offsetParent;n&&"static"===q(n,"position");)n=n.offsetParent;return n||i}))},E.slice=function(t,e){return _(g.call(this,t,e))};var st=/-([a-z])/g;function at(t){return t.replace(st,(function(t,e){return e.toUpperCase()}))}E.ready=function(t){var n=function(){return setTimeout(t,0,_)};return"loading"!==e.readyState?n():e.addEventListener("DOMContentLoaded",n),this},E.unwrap=function(){return this.parent().each((function(t,e){if("BODY"!==e.tagName){var n=_(e);n.replaceWith(n.children())}})),this},E.offset=function(){var t=this[0];if(t){var e=t.getBoundingClientRect();return{top:e.top+n.pageYOffset,left:e.left+n.pageXOffset}}},E.position=function(){var t=this[0];if(t){var e="fixed"===q(t,"position"),n=e?t.getBoundingClientRect():this.offset();if(!e){for(var i=t.ownerDocument,o=t.offsetParent||i.documentElement;(o===i.body||o===i.documentElement)&&"static"===q(o,"position");)o=o.parentNode;if(o!==t&&I(o)){var r=_(o).offset();n.top-=r.top+B(o,"borderTopWidth"),n.left-=r.left+B(o,"borderLeftWidth")}}return{top:n.top-B(t,"marginTop"),left:n.left-B(t,"marginLeft")}}};var lt={class:"className",contenteditable:"contentEditable",for:"htmlFor",readonly:"readOnly",maxlength:"maxLength",tabindex:"tabIndex",colspan:"colSpan",rowspan:"rowSpan",usemap:"useMap"};E.prop=function(t,e){if(t){if(L(t))return t=lt[t]||t,arguments.length<2?this[0]&&this[0][t]:this.each((function(n,i){i[t]=e}));for(var n in t)this.prop(n,t[n]);return this}},E.removeProp=function(t){return this.each((function(e,n){delete n[lt[t]||t]}))};var ut=/^--/;function ct(t){return ut.test(t)}var ht={},dt=r.style,ft=["webkit","moz","ms"],mt={animationIterationCount:!0,columnCount:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,gridArea:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnStart:!0,gridRow:!0,gridRowEnd:!0,gridRowStart:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0};function pt(t,e,n){return void 0===n&&(n=ct(t)),n||mt[t]||!k(e)?e:"".concat(e,"px")}function gt(t,e){try{return t(e)}catch(t){return e}}E.css=function(t,e){if(L(t)){var n=ct(t);return t=function(t,e){if(void 0===e&&(e=ct(t)),e)return t;if(!ht[t]){var n=at(t),i="".concat(n[0].toUpperCase()).concat(n.slice(1));F("".concat(n," ").concat(ft.join("".concat(i," "))).concat(i).split(" "),(function(e,n){if(n in dt)return ht[t]=n,!1}))}return ht[t]}(t,n),arguments.length<2?this[0]&&q(this[0],t,n):t?(e=pt(t,e,n),this.each((function(i,o){I(o)&&(n?o.style.setProperty(t,e):o.style[t]=e)}))):this}for(var i in t)this.css(i,t[i]);return this};var vt=/^\s+|\s+$/;function Ct(t,e){var n=t.dataset[e]||t.dataset[at(e)];return vt.test(n)?n:gt(JSON.parse,n)}function yt(t,e){var n=t.documentElement;return Math.max(t.body["scroll".concat(e)],n["scroll".concat(e)],t.body["offset".concat(e)],n["offset".concat(e)],n["client".concat(e)])}E.data=function(t,e){if(!t){if(!this[0])return;var n={};for(var i in this[0].dataset)n[i]=Ct(this[0],i);return n}if(L(t))return arguments.length<2?this[0]&&Ct(this[0],t):P(e)?this:this.each((function(n,i){!function(t,e,n){n=gt(JSON.stringify,n),t.dataset[at(e)]=n}(i,t,e)}));for(var i in t)this.data(i,t[i]);return this},F([!0,!1],(function(t,e){F(["Width","Height"],(function(t,n){var i="".concat(e?"outer":"inner").concat(n);E[i]=function(i){if(this[0])return x(this[0])?e?this[0]["inner".concat(n)]:this[0].document.documentElement["client".concat(n)]:M(this[0])?yt(this[0],n):this[0]["".concat(e?"offset":"client").concat(n)]+(i&&e?B(this[0],"margin".concat(t?"Top":"Left"))+B(this[0],"margin".concat(t?"Bottom":"Right")):0)}}))})),F(["Width","Height"],(function(t,e){var n=e.toLowerCase();E[n]=function(i){if(!this[0])return P(i)?void 0:this;if(!arguments.length)return x(this[0])?this[0].document.documentElement["client".concat(e)]:M(this[0])?yt(this[0],e):this[0].getBoundingClientRect()[n]-H(this[0],!t);var o=parseInt(i,10);return this.each((function(e,i){if(I(i)){var r=q(i,"boxSizing");i.style[n]=pt(n,o+("border-box"===r?H(i,!t):0))}}))}}));var wt="___cd";E.toggle=function(t){return this.each((function(n,i){if(I(i)){var r=j(i);(P(t)?r:t)?(i.style.display=i[wt]||"",j(i)&&(i.style.display=function(t){if(Y[t])return Y[t];var n=o(t);e.body.insertBefore(n,null);var i=q(n,"display");return e.body.removeChild(n),Y[t]="none"!==i?i:"block"}(i.tagName))):r||(i[wt]=q(i,"display"),i.style.display="none")}}))},E.hide=function(){return this.toggle(!1)},E.show=function(){return this.toggle(!0)};var bt="___ce",At={focus:"focusin",blur:"focusout"},St={mouseenter:"mouseover",mouseleave:"mouseout"},Tt=/^(mouse|pointer|contextmenu|drag|drop|click|dblclick)/i;function Et(t){return St[t]||At[t]||t}function _t(t){var e=t.split(".");return[e[0],e.slice(1).sort()]}function Nt(t){return t[bt]=t[bt]||{}}function xt(t,e){return!e||!v.call(e,(function(e){return t.indexOf(e)<0}))}function Mt(t,e,n,i,o){var r=Nt(t);if(e)r[e]&&(r[e]=r[e].filter((function(r){var s=r[0],a=r[1],l=r[2];if(o&&l.guid!==o.guid||!xt(s,n)||i&&i!==a)return!0;t.removeEventListener(e,l)})));else for(e in r)Mt(t,e,n,i,o)}E.trigger=function(t,n){if(L(t)){var i=_t(t),o=i[0],r=i[1],s=Et(o);if(!s)return this;var a=Tt.test(s)?"MouseEvents":"HTMLEvents";(t=e.createEvent(a)).initEvent(s,!0,!0),t.namespace=r.join("."),t.___ot=o}t.___td=n;var l=t.___ot in At;return this.each((function(e,n){l&&O(n[t.___ot])&&(n["___i".concat(t.type)]=!0,n[t.___ot](),n["___i".concat(t.type)]=!1),n.dispatchEvent(t)}))},E.off=function(t,e,n){var i=this;if(P(t))this.each((function(t,e){(I(e)||M(e)||x(e))&&Mt(e)}));else if(L(t))O(e)&&(n=e,e=""),F(U(t),(function(t,o){var r=_t(o),s=r[0],a=r[1],l=Et(s);i.each((function(t,i){(I(i)||M(i)||x(i))&&Mt(i,l,a,e,n)}))}));else for(var o in t)this.off(o,t[o]);return this},E.remove=function(t){return z(this,t).detach().off(),this},E.replaceWith=function(t){return this.before(t).remove()},E.replaceAll=function(t){return _(t).replaceWith(this),this},E.on=function(t,e,n,i,o){var r=this;if(!L(t)){for(var s in t)this.on(s,e,n,t[s],o);return this}return L(e)||(P(e)||R(e)?e="":P(n)?(n=e,e=""):(i=n,n=e,e="")),O(i)||(i=n,n=void 0),i?(F(U(t),(function(t,s){var a=_t(s),l=a[0],u=a[1],c=Et(l),h=l in St,d=l in At;c&&r.each((function(t,r){if(I(r)||M(r)||x(r)){var s=function(t){if(t.target["___i".concat(t.type)])return t.stopImmediatePropagation();if((!t.namespace||xt(u,t.namespace.split(".")))&&(e||!(d&&(t.target!==r||t.___ot===c)||h&&t.relatedTarget&&r.contains(t.relatedTarget)))){var a=r;if(e){for(var l=t.target;!W(l,e);){if(l===r)return;if(!(l=l.parentNode))return}a=l}Object.defineProperty(t,"currentTarget",{configurable:!0,get:function(){return a}}),Object.defineProperty(t,"delegateTarget",{configurable:!0,get:function(){return r}}),Object.defineProperty(t,"data",{configurable:!0,get:function(){return n}});var f=i.call(a,t,t.___td);o&&Mt(r,c,u,e,s),!1===f&&(t.preventDefault(),t.stopPropagation())}};s.guid=i.guid=i.guid||_.guid++,function(t,e,n,i,o){var r=Nt(t);r[e]=r[e]||[],r[e].push([n,i,o]),t.addEventListener(e,o)}(r,c,u,e,s)}}))})),this):this},E.one=function(t,e,n,i){return this.on(t,e,n,i,!0)};var It=/\r?\n/g,Ot=/file|reset|submit|button|image/i,Lt=/radio|checkbox/i;E.serialize=function(){var t="";return this.each((function(e,n){F(n.elements||[n],(function(e,n){if(!(n.disabled||!n.name||"FIELDSET"===n.tagName||Ot.test(n.type)||Lt.test(n.type)&&!n.checked)){var i=tt(n);P(i)||F(u(i)?i:[i],(function(e,i){t+=function(t,e){return"&".concat(encodeURIComponent(t),"=").concat(encodeURIComponent(e.replace(It,"\r\n")))}(n.name,i)}))}}))})),t.slice(1)},t.exports=_}()},6677:(t,e,n)=>{"use strict";n.d(e,{A:()=>a});var i=n(1354),o=n.n(i),r=n(6314),s=n.n(r)()(o());s.push([t.id,".ui-app-header {\n\n}\n\n.ui-app-header-icon {\n width: 150px;\n height: 150px;\n margin-right: 20px;\n}\n\n.u2-panel {\n gap: 10px;\n}\n\n.u2-app-header-bottom-line {\n border-bottom: solid 1px lightgrey;\n}\n\n.u2-app-header-with-name {\n gap: 60px;\n}\n\n.u2-app-header-with-name .ui-app-header-icon{\n width: 90px;\n height: 90px;\n}\n\n.u2-app-header-app-name-and-slogan-div {\n gap: 10px;\n margin-top: 10px;\n}\n\n.u2-app-header-app-name-div {\n font-size: 20px;\n font-weight: bold;\n}\n\n.u2-app-header-description {\n margin-top: 10px;\n margin-bottom: 10px;\n}","",{version:3,sources:["webpack://./node_modules/@datagrok-libraries/utils/src/u2.css"],names:[],mappings:"AAAA;;AAEA;;AAEA;IACI,YAAY;IACZ,aAAa;IACb,kBAAkB;AACtB;;AAEA;IACI,SAAS;AACb;;AAEA;IACI,kCAAkC;AACtC;;AAEA;IACI,SAAS;AACb;;AAEA;IACI,WAAW;IACX,YAAY;AAChB;;AAEA;IACI,SAAS;IACT,gBAAgB;AACpB;;AAEA;IACI,eAAe;IACf,iBAAiB;AACrB;;AAEA;IACI,gBAAgB;IAChB,mBAAmB;AACvB",sourcesContent:[".ui-app-header {\n\n}\n\n.ui-app-header-icon {\n width: 150px;\n height: 150px;\n margin-right: 20px;\n}\n\n.u2-panel {\n gap: 10px;\n}\n\n.u2-app-header-bottom-line {\n border-bottom: solid 1px lightgrey;\n}\n\n.u2-app-header-with-name {\n gap: 60px;\n}\n\n.u2-app-header-with-name .ui-app-header-icon{\n width: 90px;\n height: 90px;\n}\n\n.u2-app-header-app-name-and-slogan-div {\n gap: 10px;\n margin-top: 10px;\n}\n\n.u2-app-header-app-name-div {\n font-size: 20px;\n font-weight: bold;\n}\n\n.u2-app-header-description {\n margin-top: 10px;\n margin-bottom: 10px;\n}"],sourceRoot:""}]);const a=s},365:(t,e,n)=>{"use strict";n.d(e,{A:()=>a});var i=n(1354),o=n.n(i),r=n(6314),s=n.n(r)()(o());s.push([t.id,".pep-textarea-box {\n position: relative;\n}\n\n.pep-textarea-box:hover .pep-snippet-editor-icon {\n visibility: visible;\n}\n\n.pep-snippet-editor-icon {\n position: absolute;\n top: 5px;\n visibility: hidden;\n margin: 5px;\n z-index: 1;\n}\n\n.pep-reset-icon {\n right: 10px;\n}\n\n.pep-snippet-editor-icon i {\n font-size: 13px;\n}\n\n.pep-snippet-editor-icon:hover {\n background-color: var(--steel-1);\n border-radius: 2px;\n}\n\n.pep-snippet-inline-icon i {\n font-size: 13px;\n}\n\n.pep-textinput {\n height: 50px;\n overflow: hidden;\n}\n\n#pep-hist-host #center {\n height: 131px;\n}\n\n#pep-hist-host > #root {\n height: unset;\n width: 100%;\n}\n\n#pep-viewer-title {\n height: 23px;\n font-size: 1.2rem;\n font-family: 'Roboto', 'Roboto Local', sans-serif;\n color: #4D5261;\n text-align: center;\n width: 100%;\n align-self: end;\n}\n\n.pep-help-icon {\n position: absolute;\n left: 5px;\n top: 1px;\n}\n\n.panel-base:has(.peptides-viewer-show-title:only-child) > .panel-titlebar > .panel-titlebar-text {\n visibility: visible;\n display: block;\n text-align: center;\n margin-left: 36px;\n padding: 0;\n width: 100%;\n font-size: 14px !important;\n color: #4d5261 !important;\n}","",{version:3,sources:["webpack://./src/styles.css"],names:[],mappings:"AAAA;EACE,kBAAkB;AACpB;;AAEA;EACE,mBAAmB;AACrB;;AAEA;EACE,kBAAkB;EAClB,QAAQ;EACR,kBAAkB;EAClB,WAAW;EACX,UAAU;AACZ;;AAEA;EACE,WAAW;AACb;;AAEA;EACE,eAAe;AACjB;;AAEA;EACE,gCAAgC;EAChC,kBAAkB;AACpB;;AAEA;EACE,eAAe;AACjB;;AAEA;EACE,YAAY;EACZ,gBAAgB;AAClB;;AAEA;EACE,aAAa;AACf;;AAEA;EACE,aAAa;EACb,WAAW;AACb;;AAEA;EACE,YAAY;EACZ,iBAAiB;EACjB,iDAAiD;EACjD,cAAc;EACd,kBAAkB;EAClB,WAAW;EACX,eAAe;AACjB;;AAEA;EACE,kBAAkB;EAClB,SAAS;EACT,QAAQ;AACV;;AAEA;IACI,mBAAmB;IACnB,cAAc;IACd,kBAAkB;IAClB,iBAAiB;IACjB,UAAU;IACV,WAAW;IACX,0BAA0B;IAC1B,yBAAyB;AAC7B",sourcesContent:[".pep-textarea-box {\n position: relative;\n}\n\n.pep-textarea-box:hover .pep-snippet-editor-icon {\n visibility: visible;\n}\n\n.pep-snippet-editor-icon {\n position: absolute;\n top: 5px;\n visibility: hidden;\n margin: 5px;\n z-index: 1;\n}\n\n.pep-reset-icon {\n right: 10px;\n}\n\n.pep-snippet-editor-icon i {\n font-size: 13px;\n}\n\n.pep-snippet-editor-icon:hover {\n background-color: var(--steel-1);\n border-radius: 2px;\n}\n\n.pep-snippet-inline-icon i {\n font-size: 13px;\n}\n\n.pep-textinput {\n height: 50px;\n overflow: hidden;\n}\n\n#pep-hist-host #center {\n height: 131px;\n}\n\n#pep-hist-host > #root {\n height: unset;\n width: 100%;\n}\n\n#pep-viewer-title {\n height: 23px;\n font-size: 1.2rem;\n font-family: 'Roboto', 'Roboto Local', sans-serif;\n color: #4D5261;\n text-align: center;\n width: 100%;\n align-self: end;\n}\n\n.pep-help-icon {\n position: absolute;\n left: 5px;\n top: 1px;\n}\n\n.panel-base:has(.peptides-viewer-show-title:only-child) > .panel-titlebar > .panel-titlebar-text {\n visibility: visible;\n display: block;\n text-align: center;\n margin-left: 36px;\n padding: 0;\n width: 100%;\n font-size: 14px !important;\n color: #4d5261 !important;\n}"],sourceRoot:""}]);const a=s},6314: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,r){"string"==typeof t&&(t=[[null,t,void 0]]);var s={};if(i)for(var a=0;a<this.length;a++){var l=this[a][0];null!=l&&(s[l]=!0)}for(var u=0;u<t.length;u++){var c=[].concat(t[u]);i&&s[c[0]]||(void 0!==r&&(void 0===c[5]||(c[1]="@layer".concat(c[5].length>0?" ".concat(c[5]):""," {").concat(c[1],"}")),c[5]=r),n&&(c[2]?(c[1]="@media ".concat(c[2]," {").concat(c[1],"}"),c[2]=n):c[2]=n),o&&(c[4]?(c[1]="@supports (".concat(c[4],") {").concat(c[1],"}"),c[4]=o):c[4]="".concat(o)),e.push(c))}},e}},1354: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),r="/*# ".concat(o," */");return[e].concat([r]).join("\n")}return[e].join("\n")}},6572:function(t){var e;t.exports=(e=function(t,e){var n=Array.prototype.concat,i=Array.prototype.slice,o=Object.prototype.toString;function r(e,n){var i=e>n?e:n;return t.pow(10,17-~~(t.log(i>0?i:-i)*t.LOG10E))}var s=Array.isArray||function(t){return"[object Array]"===o.call(t)};function a(t){return"[object Function]"===o.call(t)}function l(t){return"number"==typeof t&&t-t==0}function u(){return new u._init(arguments)}function c(){return 0}function h(){return 1}function d(t,e){return t===e?1:0}u.fn=u.prototype,u._init=function(t){if(s(t[0]))if(s(t[0][0])){a(t[1])&&(t[0]=u.map(t[0],t[1]));for(var e=0;e<t[0].length;e++)this[e]=t[0][e];this.length=t[0].length}else this[0]=a(t[1])?u.map(t[0],t[1]):t[0],this.length=1;else if(l(t[0]))this[0]=u.seq.apply(null,t),this.length=1;else{if(t[0]instanceof u)return u(t[0].toArray());this[0]=[],this.length=1}return this},u._init.prototype=u.prototype,u._init.constructor=u,u.utils={calcRdx:r,isArray:s,isFunction:a,isNumber:l,toVector:function(t){return n.apply([],t)}},u._random_fn=t.random,u.setRandom=function(t){if("function"!=typeof t)throw new TypeError("fn is not a function");u._random_fn=t},u.extend=function(t){var e,n;if(1===arguments.length){for(n in t)u[n]=t[n];return this}for(e=1;e<arguments.length;e++)for(n in arguments[e])t[n]=arguments[e][n];return t},u.rows=function(t){return t.length||1},u.cols=function(t){return t[0].length||1},u.dimensions=function(t){return{rows:u.rows(t),cols:u.cols(t)}},u.row=function(t,e){return s(e)?e.map((function(e){return u.row(t,e)})):t[e]},u.rowa=function(t,e){return u.row(t,e)},u.col=function(t,e){if(s(e)){var n=u.arange(t.length).map((function(){return new Array(e.length)}));return e.forEach((function(e,i){u.arange(t.length).forEach((function(o){n[o][i]=t[o][e]}))})),n}for(var i=new Array(t.length),o=0;o<t.length;o++)i[o]=[t[o][e]];return i},u.cola=function(t,e){return u.col(t,e).map((function(t){return t[0]}))},u.diag=function(t){for(var e=u.rows(t),n=new Array(e),i=0;i<e;i++)n[i]=[t[i][i]];return n},u.antidiag=function(t){for(var e=u.rows(t)-1,n=new Array(e),i=0;e>=0;e--,i++)n[i]=[t[i][e]];return n},u.transpose=function(t){var e,n,i,o,r,a=[];for(s(t[0])||(t=[t]),n=t.length,i=t[0].length,r=0;r<i;r++){for(e=new Array(n),o=0;o<n;o++)e[o]=t[o][r];a.push(e)}return 1===a.length?a[0]:a},u.map=function(t,e,n){var i,o,r,a,l;for(s(t[0])||(t=[t]),o=t.length,r=t[0].length,a=n?t:new Array(o),i=0;i<o;i++)for(a[i]||(a[i]=new Array(r)),l=0;l<r;l++)a[i][l]=e(t[i][l],i,l);return 1===a.length?a[0]:a},u.cumreduce=function(t,e,n){var i,o,r,a,l;for(s(t[0])||(t=[t]),o=t.length,r=t[0].length,a=n?t:new Array(o),i=0;i<o;i++)for(a[i]||(a[i]=new Array(r)),r>0&&(a[i][0]=t[i][0]),l=1;l<r;l++)a[i][l]=e(a[i][l-1],t[i][l]);return 1===a.length?a[0]:a},u.alter=function(t,e){return u.map(t,e,!0)},u.create=function(t,e,n){var i,o,r=new Array(t);for(a(e)&&(n=e,e=t),i=0;i<t;i++)for(r[i]=new Array(e),o=0;o<e;o++)r[i][o]=n(i,o);return r},u.zeros=function(t,e){return l(e)||(e=t),u.create(t,e,c)},u.ones=function(t,e){return l(e)||(e=t),u.create(t,e,h)},u.rand=function(t,e){return l(e)||(e=t),u.create(t,e,u._random_fn)},u.identity=function(t,e){return l(e)||(e=t),u.create(t,e,d)},u.symmetric=function(t){var e,n,i=t.length;if(t.length!==t[0].length)return!1;for(e=0;e<i;e++)for(n=0;n<i;n++)if(t[n][e]!==t[e][n])return!1;return!0},u.clear=function(t){return u.alter(t,c)},u.seq=function(t,e,n,i){a(i)||(i=!1);var o,s=[],l=r(t,e),u=(e*l-t*l)/((n-1)*l),c=t;for(o=0;c<=e&&o<n;c=(t*l+u*l*++o)/l)s.push(i?i(c,o):c);return s},u.arange=function(t,n,i){var o,r=[];if(i=i||1,n===e&&(n=t,t=0),t===n||0===i)return[];if(t<n&&i<0)return[];if(t>n&&i>0)return[];if(i>0)for(o=t;o<n;o+=i)r.push(o);else for(o=t;o>n;o+=i)r.push(o);return r},u.slice=function(){function t(t,n,i,o){var r,s=[],a=t.length;if(n===e&&i===e&&o===e)return u.copy(t);if(o=o||1,(n=(n=n||0)>=0?n:a+n)===(i=(i=i||t.length)>=0?i:a+i)||0===o)return[];if(n<i&&o<0)return[];if(n>i&&o>0)return[];if(o>0)for(r=n;r<i;r+=o)s.push(t[r]);else for(r=n;r>i;r+=o)s.push(t[r]);return s}return function(e,n){var i,o;return l((n=n||{}).row)?l(n.col)?e[n.row][n.col]:t(u.rowa(e,n.row),(i=n.col||{}).start,i.end,i.step):l(n.col)?t(u.cola(e,n.col),(o=n.row||{}).start,o.end,o.step):(o=n.row||{},i=n.col||{},t(e,o.start,o.end,o.step).map((function(e){return t(e,i.start,i.end,i.step)})))}}(),u.sliceAssign=function(n,i,o){var r,s;if(l(i.row)){if(l(i.col))return n[i.row][i.col]=o;i.col=i.col||{},i.col.start=i.col.start||0,i.col.end=i.col.end||n[0].length,i.col.step=i.col.step||1,r=u.arange(i.col.start,t.min(n.length,i.col.end),i.col.step);var a=i.row;return r.forEach((function(t,e){n[a][t]=o[e]})),n}if(l(i.col)){i.row=i.row||{},i.row.start=i.row.start||0,i.row.end=i.row.end||n.length,i.row.step=i.row.step||1,s=u.arange(i.row.start,t.min(n[0].length,i.row.end),i.row.step);var c=i.col;return s.forEach((function(t,e){n[t][c]=o[e]})),n}return o[0].length===e&&(o=[o]),i.row.start=i.row.start||0,i.row.end=i.row.end||n.length,i.row.step=i.row.step||1,i.col.start=i.col.start||0,i.col.end=i.col.end||n[0].length,i.col.step=i.col.step||1,s=u.arange(i.row.start,t.min(n.length,i.row.end),i.row.step),r=u.arange(i.col.start,t.min(n[0].length,i.col.end),i.col.step),s.forEach((function(t,e){r.forEach((function(i,r){n[t][i]=o[e][r]}))})),n},u.diagonal=function(t){var e=u.zeros(t.length,t.length);return t.forEach((function(t,n){e[n][n]=t})),e},u.copy=function(t){return t.map((function(t){return l(t)?t:t.map((function(t){return t}))}))};var f=u.prototype;return f.length=0,f.push=Array.prototype.push,f.sort=Array.prototype.sort,f.splice=Array.prototype.splice,f.slice=Array.prototype.slice,f.toArray=function(){return this.length>1?i.call(this):i.call(this)[0]},f.map=function(t,e){return u(u.map(this,t,e))},f.cumreduce=function(t,e){return u(u.cumreduce(this,t,e))},f.alter=function(t){return u.alter(this,t),this},function(t){for(var e=0;e<t.length;e++)!function(t){f[t]=function(e){var n,i=this;return e?(setTimeout((function(){e.call(i,f[t].call(i))})),this):(n=u[t](this),s(n)?u(n):n)}}(t[e])}("transpose clear symmetric rows cols dimensions diag antidiag".split(" ")),function(t){for(var e=0;e<t.length;e++)!function(t){f[t]=function(e,n){var i=this;return n?(setTimeout((function(){n.call(i,f[t].call(i,e))})),this):u(u[t](this,e))}}(t[e])}("row col".split(" ")),function(t){for(var e=0;e<t.length;e++)!function(t){f[t]=function(){return u(u[t].apply(null,arguments))}}(t[e])}("create zeros ones rand identity".split(" ")),u}(Math),function(t,e){var n=t.utils.isFunction;function i(t,e){return t-e}function o(t,n,i){return e.max(n,e.min(t,i))}t.sum=function(t){for(var e=0,n=t.length;--n>=0;)e+=t[n];return e},t.sumsqrd=function(t){for(var e=0,n=t.length;--n>=0;)e+=t[n]*t[n];return e},t.sumsqerr=function(e){for(var n,i=t.mean(e),o=0,r=e.length;--r>=0;)o+=(n=e[r]-i)*n;return o},t.sumrow=function(t){for(var e=0,n=t.length;--n>=0;)e+=t[n];return e},t.product=function(t){for(var e=1,n=t.length;--n>=0;)e*=t[n];return e},t.min=function(t){for(var e=t[0],n=0;++n<t.length;)t[n]<e&&(e=t[n]);return e},t.max=function(t){for(var e=t[0],n=0;++n<t.length;)t[n]>e&&(e=t[n]);return e},t.unique=function(t){for(var e={},n=[],i=0;i<t.length;i++)e[t[i]]||(e[t[i]]=!0,n.push(t[i]));return n},t.mean=function(e){return t.sum(e)/e.length},t.meansqerr=function(e){return t.sumsqerr(e)/e.length},t.geomean=function(n){var i=n.map(e.log),o=t.mean(i);return e.exp(o)},t.median=function(t){var e=t.length,n=t.slice().sort(i);return 1&e?n[e/2|0]:(n[e/2-1]+n[e/2])/2},t.cumsum=function(e){return t.cumreduce(e,(function(t,e){return t+e}))},t.cumprod=function(e){return t.cumreduce(e,(function(t,e){return t*e}))},t.diff=function(t){var e,n=[],i=t.length;for(e=1;e<i;e++)n.push(t[e]-t[e-1]);return n},t.rank=function(t){var e,n=[],o={};for(e=0;e<t.length;e++)o[l=t[e]]?o[l]++:(o[l]=1,n.push(l));var r=n.sort(i),s={},a=1;for(e=0;e<r.length;e++){var l,u=o[l=r[e]],c=(a+(a+u-1))/2;s[l]=c,a+=u}return t.map((function(t){return s[t]}))},t.mode=function(t){var e,n=t.length,o=t.slice().sort(i),r=1,s=0,a=0,l=[];for(e=0;e<n;e++)o[e]===o[e+1]?r++:(r>s?(l=[o[e]],s=r,a=0):r===s&&(l.push(o[e]),a++),r=1);return 0===a?l[0]:l},t.range=function(e){return t.max(e)-t.min(e)},t.variance=function(e,n){return t.sumsqerr(e)/(e.length-(n?1:0))},t.pooledvariance=function(e){return e.reduce((function(e,n){return e+t.sumsqerr(n)}),0)/(e.reduce((function(t,e){return t+e.length}),0)-e.length)},t.deviation=function(e){for(var n=t.mean(e),i=e.length,o=new Array(i),r=0;r<i;r++)o[r]=e[r]-n;return o},t.stdev=function(n,i){return e.sqrt(t.variance(n,i))},t.pooledstdev=function(n){return e.sqrt(t.pooledvariance(n))},t.meandev=function(n){for(var i=t.mean(n),o=[],r=n.length-1;r>=0;r--)o.push(e.abs(n[r]-i));return t.mean(o)},t.meddev=function(n){for(var i=t.median(n),o=[],r=n.length-1;r>=0;r--)o.push(e.abs(n[r]-i));return t.median(o)},t.coeffvar=function(e){return t.stdev(e)/t.mean(e)},t.quartiles=function(t){var n=t.length,o=t.slice().sort(i);return[o[e.round(n/4)-1],o[e.round(n/2)-1],o[e.round(3*n/4)-1]]},t.quantiles=function(t,n,r,s){var a,l,u,c,h,d=t.slice().sort(i),f=[n.length],m=t.length;for(void 0===r&&(r=3/8),void 0===s&&(s=3/8),a=0;a<n.length;a++)u=m*(l=n[a])+(r+l*(1-r-s)),c=e.floor(o(u,1,m-1)),h=o(u-c,0,1),f[a]=(1-h)*d[c-1]+h*d[c];return f},t.percentile=function(t,e,n){var o=t.slice().sort(i),r=e*(o.length+(n?1:-1))+(n?0:1),s=parseInt(r),a=r-s;return s+1<o.length?o[s-1]+a*(o[s]-o[s-1]):o[s-1]},t.percentileOfScore=function(t,e,n){var i,o,r=0,s=t.length,a=!1;for("strict"===n&&(a=!0),o=0;o<s;o++)i=t[o],(a&&i<e||!a&&i<=e)&&r++;return r/s},t.histogram=function(n,i){i=i||4;var o,r=t.min(n),s=(t.max(n)-r)/i,a=n.length,l=[];for(o=0;o<i;o++)l[o]=0;for(o=0;o<a;o++)l[e.min(e.floor((n[o]-r)/s),i-1)]+=1;return l},t.covariance=function(e,n){var i,o=t.mean(e),r=t.mean(n),s=e.length,a=new Array(s);for(i=0;i<s;i++)a[i]=(e[i]-o)*(n[i]-r);return t.sum(a)/(s-1)},t.corrcoeff=function(e,n){return t.covariance(e,n)/t.stdev(e,1)/t.stdev(n,1)},t.spearmancoeff=function(e,n){return e=t.rank(e),n=t.rank(n),t.corrcoeff(e,n)},t.stanMoment=function(n,i){for(var o=t.mean(n),r=t.stdev(n),s=n.length,a=0,l=0;l<s;l++)a+=e.pow((n[l]-o)/r,i);return a/n.length},t.skewness=function(e){return t.stanMoment(e,3)},t.kurtosis=function(e){return t.stanMoment(e,4)-3};var r=t.prototype;!function(e){for(var i=0;i<e.length;i++)!function(e){r[e]=function(i,o){var s=[],a=0,l=this;if(n(i)&&(o=i,i=!1),o)return setTimeout((function(){o.call(l,r[e].call(l,i))})),this;if(this.length>1){for(l=!0===i?this:this.transpose();a<l.length;a++)s[a]=t[e](l[a]);return s}return t[e](this[0],i)}}(e[i])}("cumsum cumprod".split(" ")),function(e){for(var i=0;i<e.length;i++)!function(e){r[e]=function(i,o){var s=[],a=0,l=this;if(n(i)&&(o=i,i=!1),o)return setTimeout((function(){o.call(l,r[e].call(l,i))})),this;if(this.length>1){for("sumrow"!==e&&(l=!0===i?this:this.transpose());a<l.length;a++)s[a]=t[e](l[a]);return!0===i?t[e](t.utils.toVector(s)):s}return t[e](this[0],i)}}(e[i])}("sum sumsqrd sumsqerr sumrow product min max unique mean meansqerr geomean median diff rank mode range variance deviation stdev meandev meddev coeffvar quartiles histogram skewness kurtosis".split(" ")),function(e){for(var i=0;i<e.length;i++)!function(e){r[e]=function(){var i,o=[],s=0,a=this,l=Array.prototype.slice.call(arguments);if(n(l[l.length-1])){i=l[l.length-1];var u=l.slice(0,l.length-1);return setTimeout((function(){i.call(a,r[e].apply(a,u))})),this}i=void 0;var c=function(n){return t[e].apply(a,[n].concat(l))};if(this.length>1){for(a=a.transpose();s<a.length;s++)o[s]=c(a[s]);return o}return c(this[0])}}(e[i])}("quantiles percentileOfScore".split(" "))}(e,Math),function(t,e){t.gammaln=function(t){var n,i,o,r=0,s=[76.18009172947146,-86.50532032941678,24.01409824083091,-1.231739572450155,.001208650973866179,-5395239384953e-18],a=1.000000000190015;for(o=(i=n=t)+5.5,o-=(n+.5)*e.log(o);r<6;r++)a+=s[r]/++i;return e.log(2.5066282746310007*a/n)-o},t.loggam=function(t){var n,i,o,r,s,a,l,u=[.08333333333333333,-.002777777777777778,.0007936507936507937,-.0005952380952380952,.0008417508417508418,-.001917526917526918,.00641025641025641,-.02955065359477124,.1796443723688307,-1.3924322169059];if(n=t,l=0,1==t||2==t)return 0;for(t<=7&&(n=t+(l=e.floor(7-t))),i=1/(n*n),o=2*e.PI,s=u[9],a=8;a>=0;a--)s*=i,s+=u[a];if(r=s/n+.5*e.log(o)+(n-.5)*e.log(n)-n,t<=7)for(a=1;a<=l;a++)r-=e.log(n-1),n-=1;return r},t.gammafn=function(t){var n,i,o,r,s=[-1.716185138865495,24.76565080557592,-379.80425647094563,629.3311553128184,866.9662027904133,-31451.272968848367,-36144.413418691176,66456.14382024054],a=[-30.8402300119739,315.35062697960416,-1015.1563674902192,-3107.771671572311,22538.11842098015,4755.846277527881,-134659.9598649693,-115132.2596755535],l=!1,u=0,c=0,h=0,d=t;if(t>171.6243769536076)return 1/0;if(d<=0){if(!(r=d%1+36e-17))return 1/0;l=(1&d?-1:1)*e.PI/e.sin(e.PI*r),d=1-d}for(o=d,i=d<1?d++:(d-=u=(0|d)-1)-1,n=0;n<8;++n)h=(h+s[n])*i,c=c*i+a[n];if(r=h/c+1,o<d)r/=o;else if(o>d)for(n=0;n<u;++n)r*=d,d++;return l&&(r=l/r),r},t.gammap=function(e,n){return t.lowRegGamma(e,n)*t.gammafn(e)},t.lowRegGamma=function(n,i){var o,r=t.gammaln(n),s=n,a=1/n,l=a,u=i+1-n,c=1/1e-30,h=1/u,d=h,f=1,m=-~(8.5*e.log(n>=1?n:1/n)+.4*n+17);if(i<0||n<=0)return NaN;if(i<n+1){for(;f<=m;f++)a+=l*=i/++s;return a*e.exp(-i+n*e.log(i)-r)}for(;f<=m;f++)d*=(h=1/(h=(o=-f*(f-n))*h+(u+=2)))*(c=u+o/c);return 1-d*e.exp(-i+n*e.log(i)-r)},t.factorialln=function(e){return e<0?NaN:t.gammaln(e+1)},t.factorial=function(e){return e<0?NaN:t.gammafn(e+1)},t.combination=function(n,i){return n>170||i>170?e.exp(t.combinationln(n,i)):t.factorial(n)/t.factorial(i)/t.factorial(n-i)},t.combinationln=function(e,n){return t.factorialln(e)-t.factorialln(n)-t.factorialln(e-n)},t.permutation=function(e,n){return t.factorial(e)/t.factorial(e-n)},t.betafn=function(n,i){if(!(n<=0||i<=0))return n+i>170?e.exp(t.betaln(n,i)):t.gammafn(n)*t.gammafn(i)/t.gammafn(n+i)},t.betaln=function(e,n){return t.gammaln(e)+t.gammaln(n)-t.gammaln(e+n)},t.betacf=function(t,n,i){var o,r,s,a,l=1e-30,u=1,c=n+i,h=n+1,d=n-1,f=1,m=1-c*t/h;for(e.abs(m)<l&&(m=l),a=m=1/m;u<=100&&(m=1+(r=u*(i-u)*t/((d+(o=2*u))*(n+o)))*m,e.abs(m)<l&&(m=l),f=1+r/f,e.abs(f)<l&&(f=l),a*=(m=1/m)*f,m=1+(r=-(n+u)*(c+u)*t/((n+o)*(h+o)))*m,e.abs(m)<l&&(m=l),f=1+r/f,e.abs(f)<l&&(f=l),a*=s=(m=1/m)*f,!(e.abs(s-1)<3e-7));u++);return a},t.gammapinv=function(n,i){var o,r,s,a,l,u,c=0,h=i-1,d=t.gammaln(i);if(n>=1)return e.max(100,i+100*e.sqrt(i));if(n<=0)return 0;for(i>1?(l=e.log(h),u=e.exp(h*(l-1)-d),a=n<.5?n:1-n,o=(2.30753+.27061*(r=e.sqrt(-2*e.log(a))))/(1+r*(.99229+.04481*r))-r,n<.5&&(o=-o),o=e.max(.001,i*e.pow(1-1/(9*i)-o/(3*e.sqrt(i)),3))):o=n<(r=1-i*(.253+.12*i))?e.pow(n/r,1/i):1-e.log(1-(n-r)/(1-r));c<12;c++){if(o<=0)return 0;if((o-=r=(s=(t.lowRegGamma(i,o)-n)/(r=i>1?u*e.exp(-(o-h)+h*(e.log(o)-l)):e.exp(-o+h*e.log(o)-d)))/(1-.5*e.min(1,s*((i-1)/o-1))))<=0&&(o=.5*(o+r)),e.abs(r)<1e-8*o)break}return o},t.erf=function(t){var n,i,o,r,s=[-1.3026537197817094,.6419697923564902,.019476473204185836,-.00956151478680863,-.000946595344482036,.000366839497852761,42523324806907e-18,-20278578112534e-18,-1624290004647e-18,130365583558e-17,1.5626441722e-8,-8.5238095915e-8,6.529054439e-9,5.059343495e-9,-9.91364156e-10,-2.27365122e-10,96467911e-18,2394038e-18,-6886027e-18,894487e-18,313092e-18,-112708e-18,381e-18,7106e-18,-1523e-18,-94e-18,121e-18,-28e-18],a=s.length-1,l=!1,u=0,c=0;for(t<0&&(t=-t,l=!0),i=4*(n=2/(2+t))-2;a>0;a--)o=u,u=i*u-c+s[a],c=o;return r=n*e.exp(-t*t+.5*(s[0]+i*u)-c),l?r-1:1-r},t.erfc=function(e){return 1-t.erf(e)},t.erfcinv=function(n){var i,o,r,s,a=0;if(n>=2)return-100;if(n<=0)return 100;for(s=n<1?n:2-n,i=-.70711*((2.30753+.27061*(r=e.sqrt(-2*e.log(s/2))))/(1+r*(.99229+.04481*r))-r);a<2;a++)i+=(o=t.erfc(i)-s)/(1.1283791670955126*e.exp(-i*i)-i*o);return n<1?i:-i},t.ibetainv=function(n,i,o){var r,s,a,l,u,c,h,d,f,m,p=i-1,g=o-1,v=0;if(n<=0)return 0;if(n>=1)return 1;for(i>=1&&o>=1?(a=n<.5?n:1-n,c=(2.30753+.27061*(l=e.sqrt(-2*e.log(a))))/(1+l*(.99229+.04481*l))-l,n<.5&&(c=-c),h=(c*c-3)/6,d=2/(1/(2*i-1)+1/(2*o-1)),f=c*e.sqrt(h+d)/d-(1/(2*o-1)-1/(2*i-1))*(h+5/6-2/(3*d)),c=i/(i+o*e.exp(2*f))):(r=e.log(i/(i+o)),s=e.log(o/(i+o)),c=n<(l=e.exp(i*r)/i)/(f=l+(u=e.exp(o*s)/o))?e.pow(i*f*n,1/i):1-e.pow(o*f*(1-n),1/o)),m=-t.gammaln(i)-t.gammaln(o)+t.gammaln(i+o);v<10;v++){if(0===c||1===c)return c;if((c-=l=(u=(t.ibeta(c,i,o)-n)/(l=e.exp(p*e.log(c)+g*e.log(1-c)+m)))/(1-.5*e.min(1,u*(p/c-g/(1-c)))))<=0&&(c=.5*(c+l)),c>=1&&(c=.5*(c+l+1)),e.abs(l)<1e-8*c&&v>0)break}return c},t.ibeta=function(n,i,o){var r=0===n||1===n?0:e.exp(t.gammaln(i+o)-t.gammaln(i)-t.gammaln(o)+i*e.log(n)+o*e.log(1-n));return!(n<0||n>1)&&(n<(i+1)/(i+o+2)?r*t.betacf(n,i,o)/i:1-r*t.betacf(1-n,o,i)/o)},t.randn=function(n,i){var o,r,s,a,l;if(i||(i=n),n)return t.create(n,i,(function(){return t.randn()}));do{o=t._random_fn(),r=1.7156*(t._random_fn()-.5),l=(s=o-.449871)*s+(a=e.abs(r)+.386595)*(.196*a-.25472*s)}while(l>.27597&&(l>.27846||r*r>-4*e.log(o)*o*o));return r/o},t.randg=function(n,i,o){var r,s,a,l,u,c,h=n;if(o||(o=i),n||(n=1),i)return(c=t.zeros(i,o)).alter((function(){return t.randg(n)})),c;n<1&&(n+=1),r=n-1/3,s=1/e.sqrt(9*r);do{do{l=1+s*(u=t.randn())}while(l<=0);l*=l*l,a=t._random_fn()}while(a>1-.331*e.pow(u,4)&&e.log(a)>.5*u*u+r*(1-l+e.log(l)));if(n==h)return r*l;do{a=t._random_fn()}while(0===a);return e.pow(a,1/h)*r*l},function(e){for(var n=0;n<e.length;n++)!function(e){t.fn[e]=function(){return t(t.map(this,(function(n){return t[e](n)})))}}(e[n])}("gammaln gammafn factorial factorialln".split(" ")),function(e){for(var n=0;n<e.length;n++)!function(e){t.fn[e]=function(){return t(t[e].apply(null,arguments))}}(e[n])}("randn".split(" "))}(e,Math),function(t,e){function n(t,n,i,o){for(var r,s=0,a=1,l=1,u=1,c=0,h=0;e.abs((l-h)/l)>o;)h=l,a=u+(r=-(n+c)*(n+i+c)*t/(n+2*c)/(n+2*c+1))*a,l=(s=l+r*s)+(r=(c+=1)*(i-c)*t/(n+2*c-1)/(n+2*c))*l,s/=u=a+r*u,a/=u,l/=u,u=1;return l/n}function i(n,i,o){var r=[.9815606342467192,.9041172563704749,.7699026741943047,.5873179542866175,.3678314989981802,.1252334085114689],s=[.04717533638651183,.10693932599531843,.16007832854334622,.20316742672306592,.2334925365383548,.24914704581340277],a=.5*n;if(a>=8)return 1;var l,u=2*t.normal.cdf(a,0,1,1,0)-1;u=u>=e.exp(-50/o)?e.pow(u,o):0;for(var c=a,h=(8-a)/(l=n>3?2:3),d=c+h,f=0,m=o-1,p=1;p<=l;p++){for(var g=0,v=.5*(d+c),C=.5*(d-c),y=1;y<=12;y++){var w,b=v+C*(6<y?r[(w=12-y+1)-1]:-r[(w=y)-1]),A=b*b;if(A>60)break;var S=2*t.normal.cdf(b,0,1,1,0)*.5-2*t.normal.cdf(b,n,1,1,0)*.5;S>=e.exp(-30/m)&&(g+=S=s[w-1]*e.exp(-.5*A)*e.pow(S,m))}f+=g*=2*C*o/e.sqrt(2*e.PI),c=d,d+=h}return(u+=f)<=e.exp(-30/i)?0:(u=e.pow(u,i))>=1?1:u}!function(e){for(var n=0;n<e.length;n++)!function(e){t[e]=function t(e,n,i){return this instanceof t?(this._a=e,this._b=n,this._c=i,this):new t(e,n,i)},t.fn[e]=function(n,i,o){var r=t[e](n,i,o);return r.data=this,r},t[e].prototype.sample=function(n){var i=this._a,o=this._b,r=this._c;return n?t.alter(n,(function(){return t[e].sample(i,o,r)})):t[e].sample(i,o,r)},function(n){for(var i=0;i<n.length;i++)!function(n){t[e].prototype[n]=function(i){var o=this._a,r=this._b,s=this._c;return i||0===i||(i=this.data),"number"!=typeof i?t.fn.map.call(i,(function(i){return t[e][n](i,o,r,s)})):t[e][n](i,o,r,s)}}(n[i])}("pdf cdf inv".split(" ")),function(n){for(var i=0;i<n.length;i++)!function(n){t[e].prototype[n]=function(){return t[e][n](this._a,this._b,this._c)}}(n[i])}("mean median mode variance".split(" "))}(e[n])}("beta centralF cauchy chisquare exponential gamma invgamma kumaraswamy laplace lognormal noncentralt normal pareto studentt weibull uniform binomial negbin hypgeom poisson triangular tukey arcsine".split(" ")),t.extend(t.beta,{pdf:function(n,i,o){return n>1||n<0?0:1==i&&1==o?1:i<512&&o<512?e.pow(n,i-1)*e.pow(1-n,o-1)/t.betafn(i,o):e.exp((i-1)*e.log(n)+(o-1)*e.log(1-n)-t.betaln(i,o))},cdf:function(e,n,i){return e>1||e<0?1*(e>1):t.ibeta(e,n,i)},inv:function(e,n,i){return t.ibetainv(e,n,i)},mean:function(t,e){return t/(t+e)},median:function(e,n){return t.ibetainv(.5,e,n)},mode:function(t,e){return(t-1)/(t+e-2)},sample:function(e,n){var i=t.randg(e);return i/(i+t.randg(n))},variance:function(t,n){return t*n/(e.pow(t+n,2)*(t+n+1))}}),t.extend(t.centralF,{pdf:function(n,i,o){var r;return n<0?0:i<=2?0===n&&i<2?1/0:0===n&&2===i?1:1/t.betafn(i/2,o/2)*e.pow(i/o,i/2)*e.pow(n,i/2-1)*e.pow(1+i/o*n,-(i+o)/2):(r=i*n/(o+n*i),i*(o/(o+n*i))/2*t.binomial.pdf((i-2)/2,(i+o-2)/2,r))},cdf:function(e,n,i){return e<0?0:t.ibeta(n*e/(n*e+i),n/2,i/2)},inv:function(e,n,i){return i/(n*(1/t.ibetainv(e,n/2,i/2)-1))},mean:function(t,e){return e>2?e/(e-2):void 0},mode:function(t,e){return t>2?e*(t-2)/(t*(e+2)):void 0},sample:function(e,n){return 2*t.randg(e/2)/e/(2*t.randg(n/2)/n)},variance:function(t,e){if(!(e<=4))return 2*e*e*(t+e-2)/(t*(e-2)*(e-2)*(e-4))}}),t.extend(t.cauchy,{pdf:function(t,n,i){return i<0?0:i/(e.pow(t-n,2)+e.pow(i,2))/e.PI},cdf:function(t,n,i){return e.atan((t-n)/i)/e.PI+.5},inv:function(t,n,i){return n+i*e.tan(e.PI*(t-.5))},median:function(t){return t},mode:function(t){return t},sample:function(n,i){return t.randn()*e.sqrt(1/(2*t.randg(.5)))*i+n}}),t.extend(t.chisquare,{pdf:function(n,i){return n<0?0:0===n&&2===i?.5:e.exp((i/2-1)*e.log(n)-n/2-i/2*e.log(2)-t.gammaln(i/2))},cdf:function(e,n){return e<0?0:t.lowRegGamma(n/2,e/2)},inv:function(e,n){return 2*t.gammapinv(e,.5*n)},mean:function(t){return t},median:function(t){return t*e.pow(1-2/(9*t),3)},mode:function(t){return t-2>0?t-2:0},sample:function(e){return 2*t.randg(e/2)},variance:function(t){return 2*t}}),t.extend(t.exponential,{pdf:function(t,n){return t<0?0:n*e.exp(-n*t)},cdf:function(t,n){return t<0?0:1-e.exp(-n*t)},inv:function(t,n){return-e.log(1-t)/n},mean:function(t){return 1/t},median:function(t){return 1/t*e.log(2)},mode:function(){return 0},sample:function(n){return-1/n*e.log(t._random_fn())},variance:function(t){return e.pow(t,-2)}}),t.extend(t.gamma,{pdf:function(n,i,o){return n<0?0:0===n&&1===i?1/o:e.exp((i-1)*e.log(n)-n/o-t.gammaln(i)-i*e.log(o))},cdf:function(e,n,i){return e<0?0:t.lowRegGamma(n,e/i)},inv:function(e,n,i){return t.gammapinv(e,n)*i},mean:function(t,e){return t*e},mode:function(t,e){if(t>1)return(t-1)*e},sample:function(e,n){return t.randg(e)*n},variance:function(t,e){return t*e*e}}),t.extend(t.invgamma,{pdf:function(n,i,o){return n<=0?0:e.exp(-(i+1)*e.log(n)-o/n-t.gammaln(i)+i*e.log(o))},cdf:function(e,n,i){return e<=0?0:1-t.lowRegGamma(n,i/e)},inv:function(e,n,i){return i/t.gammapinv(1-e,n)},mean:function(t,e){return t>1?e/(t-1):void 0},mode:function(t,e){return e/(t+1)},sample:function(e,n){return n/t.randg(e)},variance:function(t,e){if(!(t<=2))return e*e/((t-1)*(t-1)*(t-2))}}),t.extend(t.kumaraswamy,{pdf:function(t,n,i){return 0===t&&1===n?i:1===t&&1===i?n:e.exp(e.log(n)+e.log(i)+(n-1)*e.log(t)+(i-1)*e.log(1-e.pow(t,n)))},cdf:function(t,n,i){return t<0?0:t>1?1:1-e.pow(1-e.pow(t,n),i)},inv:function(t,n,i){return e.pow(1-e.pow(1-t,1/i),1/n)},mean:function(e,n){return n*t.gammafn(1+1/e)*t.gammafn(n)/t.gammafn(1+1/e+n)},median:function(t,n){return e.pow(1-e.pow(2,-1/n),1/t)},mode:function(t,n){if(t>=1&&n>=1&&1!==t&&1!==n)return e.pow((t-1)/(t*n-1),1/t)},variance:function(){throw new Error("variance not yet implemented")}}),t.extend(t.lognormal,{pdf:function(t,n,i){return t<=0?0:e.exp(-e.log(t)-.5*e.log(2*e.PI)-e.log(i)-e.pow(e.log(t)-n,2)/(2*i*i))},cdf:function(n,i,o){return n<0?0:.5+.5*t.erf((e.log(n)-i)/e.sqrt(2*o*o))},inv:function(n,i,o){return e.exp(-1.4142135623730951*o*t.erfcinv(2*n)+i)},mean:function(t,n){return e.exp(t+n*n/2)},median:function(t){return e.exp(t)},mode:function(t,n){return e.exp(t-n*n)},sample:function(n,i){return e.exp(t.randn()*i+n)},variance:function(t,n){return(e.exp(n*n)-1)*e.exp(2*t+n*n)}}),t.extend(t.noncentralt,{pdf:function(n,i,o){return e.abs(o)<1e-14?t.studentt.pdf(n,i):e.abs(n)<1e-14?e.exp(t.gammaln((i+1)/2)-o*o/2-.5*e.log(e.PI*i)-t.gammaln(i/2)):i/n*(t.noncentralt.cdf(n*e.sqrt(1+2/i),i+2,o)-t.noncentralt.cdf(n,i,o))},cdf:function(n,i,o){var r=1e-14;if(e.abs(o)<r)return t.studentt.cdf(n,i);var s=!1;n<0&&(s=!0,o=-o);for(var a=t.normal.cdf(-o,0,1),l=r+1,u=l,c=n*n/(n*n+i),h=0,d=e.exp(-o*o/2),f=e.exp(-o*o/2-.5*e.log(2)-t.gammaln(1.5))*o;h<200||u>r||l>r;)u=l,h>0&&(d*=o*o/(2*h),f*=o*o/(2*(h+.5))),a+=.5*(l=d*t.beta.cdf(c,h+.5,i/2)+f*t.beta.cdf(c,h+1,i/2)),h++;return s?1-a:a}}),t.extend(t.normal,{pdf:function(t,n,i){return e.exp(-.5*e.log(2*e.PI)-e.log(i)-e.pow(t-n,2)/(2*i*i))},cdf:function(n,i,o){return.5*(1+t.erf((n-i)/e.sqrt(2*o*o)))},inv:function(e,n,i){return-1.4142135623730951*i*t.erfcinv(2*e)+n},mean:function(t){return t},median:function(t){return t},mode:function(t){return t},sample:function(e,n){return t.randn()*n+e},variance:function(t,e){return e*e}}),t.extend(t.pareto,{pdf:function(t,n,i){return t<n?0:i*e.pow(n,i)/e.pow(t,i+1)},cdf:function(t,n,i){return t<n?0:1-e.pow(n/t,i)},inv:function(t,n,i){return n/e.pow(1-t,1/i)},mean:function(t,n){if(!(n<=1))return n*e.pow(t,n)/(n-1)},median:function(t,n){return t*(n*e.SQRT2)},mode:function(t){return t},variance:function(t,n){if(!(n<=2))return t*t*n/(e.pow(n-1,2)*(n-2))}}),t.extend(t.studentt,{pdf:function(n,i){return i=i>1e100?1e100:i,1/(e.sqrt(i)*t.betafn(.5,i/2))*e.pow(1+n*n/i,-(i+1)/2)},cdf:function(n,i){var o=i/2;return t.ibeta((n+e.sqrt(n*n+i))/(2*e.sqrt(n*n+i)),o,o)},inv:function(n,i){var o=t.ibetainv(2*e.min(n,1-n),.5*i,.5);return o=e.sqrt(i*(1-o)/o),n>.5?o:-o},mean:function(t){return t>1?0:void 0},median:function(){return 0},mode:function(){return 0},sample:function(n){return t.randn()*e.sqrt(n/(2*t.randg(n/2)))},variance:function(t){return t>2?t/(t-2):t>1?1/0:void 0}}),t.extend(t.weibull,{pdf:function(t,n,i){return t<0||n<0||i<0?0:i/n*e.pow(t/n,i-1)*e.exp(-e.pow(t/n,i))},cdf:function(t,n,i){return t<0?0:1-e.exp(-e.pow(t/n,i))},inv:function(t,n,i){return n*e.pow(-e.log(1-t),1/i)},mean:function(e,n){return e*t.gammafn(1+1/n)},median:function(t,n){return t*e.pow(e.log(2),1/n)},mode:function(t,n){return n<=1?0:t*e.pow((n-1)/n,1/n)},sample:function(n,i){return n*e.pow(-e.log(t._random_fn()),1/i)},variance:function(n,i){return n*n*t.gammafn(1+2/i)-e.pow(t.weibull.mean(n,i),2)}}),t.extend(t.uniform,{pdf:function(t,e,n){return t<e||t>n?0:1/(n-e)},cdf:function(t,e,n){return t<e?0:t<n?(t-e)/(n-e):1},inv:function(t,e,n){return e+t*(n-e)},mean:function(t,e){return.5*(t+e)},median:function(e,n){return t.mean(e,n)},mode:function(){throw new Error("mode is not yet implemented")},sample:function(e,n){return e/2+n/2+(n/2-e/2)*(2*t._random_fn()-1)},variance:function(t,n){return e.pow(n-t,2)/12}}),t.extend(t.binomial,{pdf:function(n,i,o){return 0===o||1===o?i*o===n?1:0:t.combination(i,n)*e.pow(o,n)*e.pow(1-o,i-n)},cdf:function(i,o,r){var s,a=1e-10;if(i<0)return 0;if(i>=o)return 1;if(r<0||r>1||o<=0)return NaN;var l=r,u=(i=e.floor(i))+1,c=o-i,h=u+c,d=e.exp(t.gammaln(h)-t.gammaln(c)-t.gammaln(u)+u*e.log(l)+c*e.log(1-l));return s=l<(u+1)/(h+2)?d*n(l,u,c,a):1-d*n(1-l,c,u,a),e.round(1/a*(1-s))/(1/a)}}),t.extend(t.negbin,{pdf:function(n,i,o){return n===n>>>0&&(n<0?0:t.combination(n+i-1,i-1)*e.pow(1-o,n)*e.pow(o,i))},cdf:function(e,n,i){var o=0,r=0;if(e<0)return 0;for(;r<=e;r++)o+=t.negbin.pdf(r,n,i);return o}}),t.extend(t.hypgeom,{pdf:function(n,i,o,r){if(n!=n|0)return!1;if(n<0||n<o-(i-r))return 0;if(n>r||n>o)return 0;if(2*o>i)return 2*r>i?t.hypgeom.pdf(i-o-r+n,i,i-o,i-r):t.hypgeom.pdf(r-n,i,i-o,r);if(2*r>i)return t.hypgeom.pdf(o-n,i,o,i-r);if(o<r)return t.hypgeom.pdf(n,i,r,o);for(var s=1,a=0,l=0;l<n;l++){for(;s>1&&a<r;)s*=1-o/(i-a),a++;s*=(r-l)*(o-l)/((l+1)*(i-o-r+l+1))}for(;a<r;a++)s*=1-o/(i-a);return e.min(1,e.max(0,s))},cdf:function(n,i,o,r){if(n<0||n<o-(i-r))return 0;if(n>=r||n>=o)return 1;if(2*o>i)return 2*r>i?t.hypgeom.cdf(i-o-r+n,i,i-o,i-r):1-t.hypgeom.cdf(r-n-1,i,i-o,r);if(2*r>i)return 1-t.hypgeom.cdf(o-n-1,i,o,i-r);if(o<r)return t.hypgeom.cdf(n,i,r,o);for(var s=1,a=1,l=0,u=0;u<n;u++){for(;s>1&&l<r;){var c=1-o/(i-l);a*=c,s*=c,l++}s+=a*=(r-u)*(o-u)/((u+1)*(i-o-r+u+1))}for(;l<r;l++)s*=1-o/(i-l);return e.min(1,e.max(0,s))}}),t.extend(t.poisson,{pdf:function(n,i){return i<0||n%1!=0||n<0?0:e.pow(i,n)*e.exp(-i)/t.factorial(n)},cdf:function(e,n){var i=[],o=0;if(e<0)return 0;for(;o<=e;o++)i.push(t.poisson.pdf(o,n));return t.sum(i)},mean:function(t){return t},variance:function(t){return t},sampleSmall:function(n){var i=1,o=0,r=e.exp(-n);do{o++,i*=t._random_fn()}while(i>r);return o-1},sampleLarge:function(n){var i,o,r,s,a,l,u,c,h,d,f=n;for(s=e.sqrt(f),a=e.log(f),l=.02483*(u=.931+2.53*s)-.059,c=1.1239+1.1328/(u-3.4),h=.9277-3.6224/(u-2);;){if(o=e.random()-.5,r=e.random(),d=.5-e.abs(o),i=e.floor((2*l/d+u)*o+f+.43),d>=.07&&r<=h)return i;if(!(i<0||d<.013&&r>d)&&e.log(r)+e.log(c)-e.log(l/(d*d)+u)<=i*a-f-t.loggam(i+1))return i}},sample:function(t){return t<10?this.sampleSmall(t):this.sampleLarge(t)}}),t.extend(t.triangular,{pdf:function(t,e,n,i){return n<=e||i<e||i>n?NaN:t<e||t>n?0:t<i?2*(t-e)/((n-e)*(i-e)):t===i?2/(n-e):2*(n-t)/((n-e)*(n-i))},cdf:function(t,n,i,o){return i<=n||o<n||o>i?NaN:t<=n?0:t>=i?1:t<=o?e.pow(t-n,2)/((i-n)*(o-n)):1-e.pow(i-t,2)/((i-n)*(i-o))},inv:function(t,n,i,o){return i<=n||o<n||o>i?NaN:t<=(o-n)/(i-n)?n+(i-n)*e.sqrt(t*((o-n)/(i-n))):n+(i-n)*(1-e.sqrt((1-t)*(1-(o-n)/(i-n))))},mean:function(t,e,n){return(t+e+n)/3},median:function(t,n,i){return i<=(t+n)/2?n-e.sqrt((n-t)*(n-i))/e.sqrt(2):i>(t+n)/2?t+e.sqrt((n-t)*(i-t))/e.sqrt(2):void 0},mode:function(t,e,n){return n},sample:function(n,i,o){var r=t._random_fn();return r<(o-n)/(i-n)?n+e.sqrt(r*(i-n)*(o-n)):i-e.sqrt((1-r)*(i-n)*(i-o))},variance:function(t,e,n){return(t*t+e*e+n*n-t*e-t*n-e*n)/18}}),t.extend(t.arcsine,{pdf:function(t,n,i){return i<=n?NaN:t<=n||t>=i?0:2/e.PI*e.pow(e.pow(i-n,2)-e.pow(2*t-n-i,2),-.5)},cdf:function(t,n,i){return t<n?0:t<i?2/e.PI*e.asin(e.sqrt((t-n)/(i-n))):1},inv:function(t,n,i){return n+(.5-.5*e.cos(e.PI*t))*(i-n)},mean:function(t,e){return e<=t?NaN:(t+e)/2},median:function(t,e){return e<=t?NaN:(t+e)/2},mode:function(){throw new Error("mode is not yet implemented")},sample:function(n,i){return(n+i)/2+(i-n)/2*e.sin(2*e.PI*t.uniform.sample(0,1))},variance:function(t,n){return n<=t?NaN:e.pow(n-t,2)/8}}),t.extend(t.laplace,{pdf:function(t,n,i){return i<=0?0:e.exp(-e.abs(t-n)/i)/(2*i)},cdf:function(t,n,i){return i<=0?0:t<n?.5*e.exp((t-n)/i):1-.5*e.exp(-(t-n)/i)},mean:function(t){return t},median:function(t){return t},mode:function(t){return t},variance:function(t,e){return 2*e*e},sample:function(n,i){var o,r=t._random_fn()-.5;return n-i*((o=r)/e.abs(o))*e.log(1-2*e.abs(r))}}),t.extend(t.tukey,{cdf:function(n,o,r){var s=o,a=[.9894009349916499,.9445750230732326,.8656312023878318,.755404408355003,.6178762444026438,.45801677765722737,.2816035507792589,.09501250983763744],l=[.027152459411754096,.062253523938647894,.09515851168249279,.12462897125553388,.14959598881657674,.16915651939500254,.18260341504492358,.1894506104550685];if(n<=0)return 0;if(r<2||s<2)return NaN;if(!Number.isFinite(n))return 1;if(r>25e3)return i(n,1,s);var u,c=.5*r,h=c*e.log(r)-r*e.log(2)-t.gammaln(c),d=c-1,f=.25*r;u=r<=100?1:r<=800?.5:r<=5e3?.25:.125,h+=e.log(u);for(var m=0,p=1;p<=50;p++){for(var g=0,v=(2*p-1)*u,C=1;C<=16;C++){var y,w;8<C?(y=C-8-1,w=h+d*e.log(v+a[y]*u)-(a[y]*u+v)*f):(y=C-1,w=h+d*e.log(v-a[y]*u)+(a[y]*u-v)*f),w>=-30&&(g+=i(8<C?n*e.sqrt(.5*(a[y]*u+v)):n*e.sqrt(.5*(-a[y]*u+v)),1,s)*l[y]*e.exp(w))}if(p*u>=1&&g<=1e-14)break;m+=g}if(g>1e-14)throw new Error("tukey.cdf failed to converge");return m>1&&(m=1),m},inv:function(n,i,o){if(o<2||i<2)return NaN;if(n<0||n>1)return NaN;if(0===n)return 0;if(1===n)return 1/0;var r,s=function(t,n,i){var o=.5-.5*t,r=e.sqrt(e.log(1/(o*o))),s=r+((((-453642210148e-16*r-.204231210125)*r-.342242088547)*r-1)*r+.322232421088)/((((.0038560700634*r+.10353775285)*r+.531103462366)*r+.588581570495)*r+.099348462606);i<120&&(s+=(s*s*s+s)/i/4);var a=.8832-.2368*s;return i<120&&(a+=-1.214/i+1.208*s/i),s*(a*e.log(n-1)+1.4142)}(n,i,o),a=t.tukey.cdf(s,i,o)-n;r=a>0?e.max(0,s-1):s+1;for(var l,u=t.tukey.cdf(r,i,o)-n,c=1;c<50;c++)if(l=r-u*(r-s)/(u-a),a=u,s=r,l<0&&(l=0,u=-n),u=t.tukey.cdf(l,i,o)-n,r=l,e.abs(r-s)<1e-4)return l;throw new Error("tukey.inv failed to converge")}})}(e,Math),function(t,e){var n,i,o=Array.prototype.push,r=t.utils.isArray;function s(e){return r(e)||e instanceof t}t.extend({add:function(e,n){return s(n)?(s(n[0])||(n=[n]),t.map(e,(function(t,e,i){return t+n[e][i]}))):t.map(e,(function(t){return t+n}))},subtract:function(e,n){return s(n)?(s(n[0])||(n=[n]),t.map(e,(function(t,e,i){return t-n[e][i]||0}))):t.map(e,(function(t){return t-n}))},divide:function(e,n){return s(n)?(s(n[0])||(n=[n]),t.multiply(e,t.inv(n))):t.map(e,(function(t){return t/n}))},multiply:function(e,n){var i,o,r,a,l,u,c,h;if(void 0===e.length&&void 0===n.length)return e*n;if(l=e.length,u=e[0].length,c=t.zeros(l,r=s(n)?n[0].length:u),h=0,s(n)){for(;h<r;h++)for(i=0;i<l;i++){for(a=0,o=0;o<u;o++)a+=e[i][o]*n[o][h];c[i][h]=a}return 1===l&&1===h?c[0][0]:c}return t.map(e,(function(t){return t*n}))},outer:function(e,n){return t.multiply(e.map((function(t){return[t]})),[n])},dot:function(e,n){s(e[0])||(e=[e]),s(n[0])||(n=[n]);for(var i,o,r=1===e[0].length&&1!==e.length?t.transpose(e):e,a=1===n[0].length&&1!==n.length?t.transpose(n):n,l=[],u=0,c=r.length,h=r[0].length;u<c;u++){for(l[u]=[],i=0,o=0;o<h;o++)i+=r[u][o]*a[u][o];l[u]=i}return 1===l.length?l[0]:l},pow:function(n,i){return t.map(n,(function(t){return e.pow(t,i)}))},exp:function(n){return t.map(n,(function(t){return e.exp(t)}))},log:function(n){return t.map(n,(function(t){return e.log(t)}))},abs:function(n){return t.map(n,(function(t){return e.abs(t)}))},norm:function(t,n){var i=0,o=0;for(isNaN(n)&&(n=2),s(t[0])&&(t=t[0]);o<t.length;o++)i+=e.pow(e.abs(t[o]),n);return e.pow(i,1/n)},angle:function(n,i){return e.acos(t.dot(n,i)/(t.norm(n)*t.norm(i)))},aug:function(t,e){var n,i=[];for(n=0;n<t.length;n++)i.push(t[n].slice());for(n=0;n<i.length;n++)o.apply(i[n],e[n]);return i},inv:function(e){for(var n,i=e.length,o=e[0].length,r=t.identity(i,o),s=t.gauss_jordan(e,r),a=[],l=0;l<i;l++)for(a[l]=[],n=o;n<s[0].length;n++)a[l][n-o]=s[l][n];return a},det:function t(e){if(2===e.length)return e[0][0]*e[1][1]-e[0][1]*e[1][0];for(var n=0,i=0;i<e.length;i++){for(var o=[],r=1;r<e.length;r++){o[r-1]=[];for(var s=0;s<e.length;s++)s<i?o[r-1][s]=e[r][s]:s>i&&(o[r-1][s-1]=e[r][s])}var a=i%2?-1:1;n+=t(o)*e[0][i]*a}return n},gauss_elimination:function(n,i){var o,r,s,a,l=0,u=0,c=n.length,h=n[0].length,d=1,f=0,m=[];for(o=(n=t.aug(n,i))[0].length,l=0;l<c;l++){for(r=n[l][l],u=l,a=l+1;a<h;a++)r<e.abs(n[a][l])&&(r=n[a][l],u=a);if(u!=l)for(a=0;a<o;a++)s=n[l][a],n[l][a]=n[u][a],n[u][a]=s;for(u=l+1;u<c;u++)for(d=n[u][l]/n[l][l],a=l;a<o;a++)n[u][a]=n[u][a]-d*n[l][a]}for(l=c-1;l>=0;l--){for(f=0,u=l+1;u<=c-1;u++)f+=m[u]*n[l][u];m[l]=(n[l][o-1]-f)/n[l][l]}return m},gauss_jordan:function(n,i){var o,r,s,a=t.aug(n,i),l=a.length,u=a[0].length,c=0;for(r=0;r<l;r++){var h=r;for(s=r+1;s<l;s++)e.abs(a[s][r])>e.abs(a[h][r])&&(h=s);var d=a[r];for(a[r]=a[h],a[h]=d,s=r+1;s<l;s++)for(c=a[s][r]/a[r][r],o=r;o<u;o++)a[s][o]-=a[r][o]*c}for(r=l-1;r>=0;r--){for(c=a[r][r],s=0;s<r;s++)for(o=u-1;o>r-1;o--)a[s][o]-=a[r][o]*a[s][r]/c;for(a[r][r]/=c,o=l;o<u;o++)a[r][o]/=c}return a},triaUpSolve:function(e,n){var i,o=e[0].length,r=t.zeros(1,o)[0],s=!1;return null!=n[0].length&&(n=n.map((function(t){return t[0]})),s=!0),t.arange(o-1,-1,-1).forEach((function(s){i=t.arange(s+1,o).map((function(t){return r[t]*e[s][t]})),r[s]=(n[s]-t.sum(i))/e[s][s]})),s?r.map((function(t){return[t]})):r},triaLowSolve:function(e,n){var i,o=e[0].length,r=t.zeros(1,o)[0],s=!1;return null!=n[0].length&&(n=n.map((function(t){return t[0]})),s=!0),t.arange(o).forEach((function(o){i=t.arange(o).map((function(t){return e[o][t]*r[t]})),r[o]=(n[o]-t.sum(i))/e[o][o]})),s?r.map((function(t){return[t]})):r},lu:function(e){var n,i=e.length,o=t.identity(i),r=t.zeros(e.length,e[0].length);return t.arange(i).forEach((function(t){r[0][t]=e[0][t]})),t.arange(1,i).forEach((function(s){t.arange(s).forEach((function(i){n=t.arange(i).map((function(t){return o[s][t]*r[t][i]})),o[s][i]=(e[s][i]-t.sum(n))/r[i][i]})),t.arange(s,i).forEach((function(i){n=t.arange(s).map((function(t){return o[s][t]*r[t][i]})),r[s][i]=e[n.length][i]-t.sum(n)}))})),[o,r]},cholesky:function(n){var i,o=n.length,r=t.zeros(n.length,n[0].length);return t.arange(o).forEach((function(s){i=t.arange(s).map((function(t){return e.pow(r[s][t],2)})),r[s][s]=e.sqrt(n[s][s]-t.sum(i)),t.arange(s+1,o).forEach((function(e){i=t.arange(s).map((function(t){return r[s][t]*r[e][t]})),r[e][s]=(n[s][e]-t.sum(i))/r[s][s]}))})),r},gauss_jacobi:function(n,i,o,r){for(var s,a,l,u,c=0,h=0,d=n.length,f=[],m=[],p=[];c<d;c++)for(f[c]=[],m[c]=[],p[c]=[],h=0;h<d;h++)c>h?(f[c][h]=n[c][h],m[c][h]=p[c][h]=0):c<h?(m[c][h]=n[c][h],f[c][h]=p[c][h]=0):(p[c][h]=n[c][h],f[c][h]=m[c][h]=0);for(l=t.multiply(t.multiply(t.inv(p),t.add(f,m)),-1),a=t.multiply(t.inv(p),i),s=o,u=t.add(t.multiply(l,o),a),c=2;e.abs(t.norm(t.subtract(u,s)))>r;)s=u,u=t.add(t.multiply(l,s),a),c++;return u},gauss_seidel:function(n,i,o,r){for(var s,a,l,u,c,h=0,d=n.length,f=[],m=[],p=[];h<d;h++)for(f[h]=[],m[h]=[],p[h]=[],s=0;s<d;s++)h>s?(f[h][s]=n[h][s],m[h][s]=p[h][s]=0):h<s?(m[h][s]=n[h][s],f[h][s]=p[h][s]=0):(p[h][s]=n[h][s],f[h][s]=m[h][s]=0);for(u=t.multiply(t.multiply(t.inv(t.add(p,f)),m),-1),l=t.multiply(t.inv(t.add(p,f)),i),a=o,c=t.add(t.multiply(u,o),l),h=2;e.abs(t.norm(t.subtract(c,a)))>r;)a=c,c=t.add(t.multiply(u,a),l),h+=1;return c},SOR:function(n,i,o,r,s){for(var a,l,u,c,h,d=0,f=n.length,m=[],p=[],g=[];d<f;d++)for(m[d]=[],p[d]=[],g[d]=[],a=0;a<f;a++)d>a?(m[d][a]=n[d][a],p[d][a]=g[d][a]=0):d<a?(p[d][a]=n[d][a],m[d][a]=g[d][a]=0):(g[d][a]=n[d][a],m[d][a]=p[d][a]=0);for(c=t.multiply(t.inv(t.add(g,t.multiply(m,s))),t.subtract(t.multiply(g,1-s),t.multiply(p,s))),u=t.multiply(t.multiply(t.inv(t.add(g,t.multiply(m,s))),i),s),l=o,h=t.add(t.multiply(c,o),u),d=2;e.abs(t.norm(t.subtract(h,l)))>r;)l=h,h=t.add(t.multiply(c,l),u),d++;return h},householder:function(n){for(var i,o,r,s,a=n.length,l=n[0].length,u=0,c=[],h=[];u<a-1;u++){for(i=0,s=u+1;s<l;s++)i+=n[s][u]*n[s][u];for(i=(n[u+1][u]>0?-1:1)*e.sqrt(i),o=e.sqrt((i*i-n[u+1][u]*i)/2),(c=t.zeros(a,1))[u+1][0]=(n[u+1][u]-i)/(2*o),r=u+2;r<a;r++)c[r][0]=n[r][u]/(2*o);h=t.subtract(t.identity(a,l),t.multiply(t.multiply(c,t.transpose(c)),2)),n=t.multiply(h,t.multiply(n,h))}return n},QR:(n=t.sum,i=t.arange,function(o){var r,s,a,l=o.length,u=o[0].length,c=t.zeros(u,u);for(o=t.copy(o),s=0;s<u;s++){for(c[s][s]=e.sqrt(n(i(l).map((function(t){return o[t][s]*o[t][s]})))),r=0;r<l;r++)o[r][s]=o[r][s]/c[s][s];for(a=s+1;a<u;a++)for(c[s][a]=n(i(l).map((function(t){return o[t][s]*o[t][a]}))),r=0;r<l;r++)o[r][a]=o[r][a]-o[r][s]*c[s][a]}return[o,c]}),lstsq:function(e,n){var i=!1;void 0===n[0].length&&(n=n.map((function(t){return[t]})),i=!0);var o=t.QR(e),r=o[0],s=o[1],a=e[0].length,l=t.slice(r,{col:{end:a}}),u=function(e){var n=(e=t.copy(e)).length,i=t.identity(n);return t.arange(n-1,-1,-1).forEach((function(n){t.sliceAssign(i,{row:n},t.divide(t.slice(i,{row:n}),e[n][n])),t.sliceAssign(e,{row:n},t.divide(t.slice(e,{row:n}),e[n][n])),t.arange(n).forEach((function(o){var r=t.multiply(e[o][n],-1),s=t.slice(e,{row:o}),a=t.multiply(t.slice(e,{row:n}),r);t.sliceAssign(e,{row:o},t.add(s,a));var l=t.slice(i,{row:o}),u=t.multiply(t.slice(i,{row:n}),r);t.sliceAssign(i,{row:o},t.add(l,u))}))})),i}(t.slice(s,{row:{end:a}})),c=t.transpose(l);void 0===c[0].length&&(c=[c]);var h=t.multiply(t.multiply(u,c),n);return void 0===h.length&&(h=[[h]]),i?h.map((function(t){return t[0]})):h},jacobi:function(n){for(var i,o,r,s,a,l,u,c=1,h=n.length,d=t.identity(h,h),f=[];1===c;){for(a=n[0][1],r=0,s=1,i=0;i<h;i++)for(o=0;o<h;o++)i!=o&&a<e.abs(n[i][o])&&(a=e.abs(n[i][o]),r=i,s=o);for(l=n[r][r]===n[s][s]?n[r][s]>0?e.PI/4:-e.PI/4:e.atan(2*n[r][s]/(n[r][r]-n[s][s]))/2,(u=t.identity(h,h))[r][r]=e.cos(l),u[r][s]=-e.sin(l),u[s][r]=e.sin(l),u[s][s]=e.cos(l),d=t.multiply(d,u),n=t.multiply(t.multiply(t.inv(u),n),u),c=0,i=1;i<h;i++)for(o=1;o<h;o++)i!=o&&e.abs(n[i][o])>.001&&(c=1)}for(i=0;i<h;i++)f.push(n[i][i]);return[d,f]},rungekutta:function(t,e,n,i,o,r){var s,a,l;if(2===r)for(;i<=n;)o+=((s=e*t(i,o))+(a=e*t(i+e,o+s)))/2,i+=e;if(4===r)for(;i<=n;)o+=((s=e*t(i,o))+2*(a=e*t(i+e/2,o+s/2))+2*(l=e*t(i+e/2,o+a/2))+e*t(i+e,o+l))/6,i+=e;return o},romberg:function(t,n,i,o){for(var r,s,a,l,u,c=0,h=(i-n)/2,d=[],f=[],m=[];c<o/2;){for(u=t(n),a=n,l=0;a<=i;a+=h,l++)d[l]=a;for(r=d.length,a=1;a<r-1;a++)u+=(a%2!=0?4:2)*t(d[a]);u=h/3*(u+t(i)),m[c]=u,h/=2,c++}for(s=m.length,r=1;1!==s;){for(a=0;a<s-1;a++)f[a]=(e.pow(4,r)*m[a+1]-m[a])/(e.pow(4,r)-1);s=f.length,m=f,f=[],r++}return m},richardson:function(t,n,i,o){function r(t,e){for(var n,i=0,o=t.length;i<o;i++)t[i]===e&&(n=i);return n}for(var s,a,l,u,c,h=e.abs(i-t[r(t,i)+1]),d=0,f=[],m=[];o>=h;)s=r(t,i+o),a=r(t,i),f[d]=(n[s]-2*n[a]+n[2*a-s])/(o*o),o/=2,d++;for(u=f.length,l=1;1!=u;){for(c=0;c<u-1;c++)m[c]=(e.pow(4,l)*f[c+1]-f[c])/(e.pow(4,l)-1);u=m.length,f=m,m=[],l++}return f},simpson:function(t,e,n,i){for(var o,r=(n-e)/i,s=t(e),a=[],l=e,u=0,c=1;l<=n;l+=r,u++)a[u]=l;for(o=a.length;c<o-1;c++)s+=(c%2!=0?4:2)*t(a[c]);return r/3*(s+t(n))},hermite:function(t,e,n,i){for(var o,r=t.length,s=0,a=0,l=[],u=[],c=[],h=[];a<r;a++){for(l[a]=1,o=0;o<r;o++)a!=o&&(l[a]*=(i-t[o])/(t[a]-t[o]));for(u[a]=0,o=0;o<r;o++)a!=o&&(u[a]+=1/(t[a]-t[o]));c[a]=(1-2*(i-t[a])*u[a])*(l[a]*l[a]),h[a]=(i-t[a])*(l[a]*l[a]),s+=c[a]*e[a]+h[a]*n[a]}return s},lagrange:function(t,e,n){for(var i,o,r=0,s=0,a=t.length;s<a;s++){for(o=e[s],i=0;i<a;i++)s!=i&&(o*=(n-t[i])/(t[s]-t[i]));r+=o}return r},cubic_spline:function(e,n,i){for(var o,r,s=e.length,a=0,l=[],u=[],c=[],h=[],d=[],f=[];a<s-1;a++)h[a]=e[a+1]-e[a];for(c[0]=0,a=1;a<s-1;a++)c[a]=3/h[a]*(n[a+1]-n[a])-3/h[a-1]*(n[a]-n[a-1]);for(a=1;a<s-1;a++)l[a]=[],u[a]=[],l[a][a-1]=h[a-1],l[a][a]=2*(h[a-1]+h[a]),l[a][a+1]=h[a],u[a][0]=c[a];for(r=t.multiply(t.inv(l),u),o=0;o<s-1;o++)d[o]=(n[o+1]-n[o])/h[o]-h[o]*(r[o+1][0]+2*r[o][0])/3,f[o]=(r[o+1][0]-r[o][0])/(3*h[o]);for(o=0;o<s&&!(e[o]>i);o++);return n[o-=1]+(i-e[o])*d[o]+t.sq(i-e[o])*r[o]+(i-e[o])*t.sq(i-e[o])*f[o]},gauss_quadrature:function(){throw new Error("gauss_quadrature not yet implemented")},PCA:function(e){var n,i,o,r,s,a=e.length,l=e[0].length,u=0,c=[],h=[],d=[],f=[],m=[],p=[],g=[];for(u=0;u<a;u++)c[u]=t.sum(e[u])/l;for(u=0;u<l;u++)for(m[u]=[],n=0;n<a;n++)m[u][n]=e[n][u]-c[n];for(m=t.transpose(m),u=0;u<a;u++)for(p[u]=[],n=0;n<a;n++)p[u][n]=t.dot([m[u]],[m[n]])/(l-1);for(s=(o=t.jacobi(p))[0],h=o[1],g=t.transpose(s),u=0;u<h.length;u++)for(n=u;n<h.length;n++)h[u]<h[n]&&(i=h[u],h[u]=h[n],h[n]=i,d=g[u],g[u]=g[n],g[n]=d);for(r=t.transpose(m),u=0;u<a;u++)for(f[u]=[],n=0;n<r.length;n++)f[u][n]=t.dot([g[u]],[r[n]]);return[e,h,g,f]}}),function(e){for(var n=0;n<e.length;n++)!function(e){t.fn[e]=function(n,i){var o=this;return i?(setTimeout((function(){i.call(o,t.fn[e].call(o,n))}),15),this):"number"==typeof t[e](this,n)?t[e](this,n):t(t[e](this,n))}}(e[n])}("add divide multiply subtract dot pow exp log abs norm angle".split(" "))}(e,Math),function(t,e){var n=[].slice,i=t.utils.isNumber,o=t.utils.isArray;function r(t,n,i,o){if(t>1||i>1||t<=0||i<=0)throw new Error("Proportions should be greater than 0 and less than 1");var r=(t*n+i*o)/(n+o);return(t-i)/e.sqrt(r*(1-r)*(1/n+1/o))}t.extend({zscore:function(){var e=n.call(arguments);return i(e[1])?(e[0]-e[1])/e[2]:(e[0]-t.mean(e[1]))/t.stdev(e[1],e[2])},ztest:function(){var i,r=n.call(arguments);return o(r[1])?(i=t.zscore(r[0],r[1],r[3]),1===r[2]?t.normal.cdf(-e.abs(i),0,1):2*t.normal.cdf(-e.abs(i),0,1)):r.length>2?(i=t.zscore(r[0],r[1],r[2]),1===r[3]?t.normal.cdf(-e.abs(i),0,1):2*t.normal.cdf(-e.abs(i),0,1)):(i=r[0],1===r[1]?t.normal.cdf(-e.abs(i),0,1):2*t.normal.cdf(-e.abs(i),0,1))}}),t.extend(t.fn,{zscore:function(t,e){return(t-this.mean())/this.stdev(e)},ztest:function(n,i,o){var r=e.abs(this.zscore(n,o));return 1===i?t.normal.cdf(-r,0,1):2*t.normal.cdf(-r,0,1)}}),t.extend({tscore:function(){var i=n.call(arguments);return 4===i.length?(i[0]-i[1])/(i[2]/e.sqrt(i[3])):(i[0]-t.mean(i[1]))/(t.stdev(i[1],!0)/e.sqrt(i[1].length))},ttest:function(){var o,r=n.call(arguments);return 5===r.length?(o=e.abs(t.tscore(r[0],r[1],r[2],r[3])),1===r[4]?t.studentt.cdf(-o,r[3]-1):2*t.studentt.cdf(-o,r[3]-1)):i(r[1])?(o=e.abs(r[0]),1==r[2]?t.studentt.cdf(-o,r[1]-1):2*t.studentt.cdf(-o,r[1]-1)):(o=e.abs(t.tscore(r[0],r[1])),1==r[2]?t.studentt.cdf(-o,r[1].length-1):2*t.studentt.cdf(-o,r[1].length-1))}}),t.extend(t.fn,{tscore:function(t){return(t-this.mean())/(this.stdev(!0)/e.sqrt(this.cols()))},ttest:function(n,i){return 1===i?1-t.studentt.cdf(e.abs(this.tscore(n)),this.cols()-1):2*t.studentt.cdf(-e.abs(this.tscore(n)),this.cols()-1)}}),t.extend({anovafscore:function(){var i,o,r,s,a,l,u,c,h=n.call(arguments);if(1===h.length){for(a=new Array(h[0].length),u=0;u<h[0].length;u++)a[u]=h[0][u];h=a}for(o=new Array,u=0;u<h.length;u++)o=o.concat(h[u]);for(r=t.mean(o),i=0,u=0;u<h.length;u++)i+=h[u].length*e.pow(t.mean(h[u])-r,2);for(i/=h.length-1,l=0,u=0;u<h.length;u++)for(s=t.mean(h[u]),c=0;c<h[u].length;c++)l+=e.pow(h[u][c]-s,2);return i/(l/(o.length-h.length))},anovaftest:function(){var e,o,r,s,a=n.call(arguments);if(i(a[0]))return 1-t.centralF.cdf(a[0],a[1],a[2]);var l=t.anovafscore(a);for(e=a.length-1,r=0,s=0;s<a.length;s++)r+=a[s].length;return o=r-e-1,1-t.centralF.cdf(l,e,o)},ftest:function(e,n,i){return 1-t.centralF.cdf(e,n,i)}}),t.extend(t.fn,{anovafscore:function(){return t.anovafscore(this.toArray())},anovaftes:function(){var e,n=0;for(e=0;e<this.length;e++)n+=this[e].length;return t.ftest(this.anovafscore(),this.length-1,n-this.length)}}),t.extend({qscore:function(){var o,r,s,a,l,u=n.call(arguments);return i(u[0])?(o=u[0],r=u[1],s=u[2],a=u[3],l=u[4]):(o=t.mean(u[0]),r=t.mean(u[1]),s=u[0].length,a=u[1].length,l=u[2]),e.abs(o-r)/(l*e.sqrt((1/s+1/a)/2))},qtest:function(){var e,i=n.call(arguments);3===i.length?(e=i[0],i=i.slice(1)):7===i.length?(e=t.qscore(i[0],i[1],i[2],i[3],i[4]),i=i.slice(5)):(e=t.qscore(i[0],i[1],i[2]),i=i.slice(3));var o=i[0],r=i[1];return 1-t.tukey.cdf(e,r,o-r)},tukeyhsd:function(e){for(var n=t.pooledstdev(e),i=e.map((function(e){return t.mean(e)})),o=e.reduce((function(t,e){return t+e.length}),0),r=[],s=0;s<e.length;++s)for(var a=s+1;a<e.length;++a){var l=t.qtest(i[s],i[a],e[s].length,e[a].length,n,o,e.length);r.push([[s,a],l])}return r}}),t.extend({normalci:function(){var i,o=n.call(arguments),r=new Array(2);return i=4===o.length?e.abs(t.normal.inv(o[1]/2,0,1)*o[2]/e.sqrt(o[3])):e.abs(t.normal.inv(o[1]/2,0,1)*t.stdev(o[2])/e.sqrt(o[2].length)),r[0]=o[0]-i,r[1]=o[0]+i,r},tci:function(){var i,o=n.call(arguments),r=new Array(2);return i=4===o.length?e.abs(t.studentt.inv(o[1]/2,o[3]-1)*o[2]/e.sqrt(o[3])):e.abs(t.studentt.inv(o[1]/2,o[2].length-1)*t.stdev(o[2],!0)/e.sqrt(o[2].length)),r[0]=o[0]-i,r[1]=o[0]+i,r},significant:function(t,e){return t<e}}),t.extend(t.fn,{normalci:function(e,n){return t.normalci(e,n,this.toArray())},tci:function(e,n){return t.tci(e,n,this.toArray())}}),t.extend(t.fn,{oneSidedDifferenceOfProportions:function(e,n,i,o){var s=r(e,n,i,o);return t.ztest(s,1)},twoSidedDifferenceOfProportions:function(e,n,i,o){var s=r(e,n,i,o);return t.ztest(s,2)}})}(e,Math),e.models=function(){function t(t,n){var i=t.length,o=n[0].length-1,r=i-o-1,s=e.lstsq(n,t),a=e.multiply(n,s.map((function(t){return[t]}))).map((function(t){return t[0]})),l=e.subtract(t,a),u=e.mean(t),c=e.sum(a.map((function(t){return Math.pow(t-u,2)}))),h=e.sum(t.map((function(t,e){return Math.pow(t-a[e],2)}))),d=c+h;return{exog:n,endog:t,nobs:i,df_model:o,df_resid:r,coef:s,predict:a,resid:l,ybar:u,SST:d,SSE:c,SSR:h,R2:c/d}}function n(n){var i,o,r=(i=n.exog,o=i[0].length,e.arange(o).map((function(n){var r=e.arange(o).filter((function(t){return t!==n}));return t(e.col(i,n).map((function(t){return t[0]})),e.col(i,r))}))),s=Math.sqrt(n.SSR/n.df_resid),a=r.map((function(t){var e=t.SST,n=t.R2;return s/Math.sqrt(e*(1-n))})),l=n.coef.map((function(t,e){return(t-0)/a[e]})),u=l.map((function(t){var i=e.studentt.cdf(t,n.df_resid);return 2*(i>.5?1-i:i)})),c=e.studentt.inv(.975,n.df_resid),h=n.coef.map((function(t,e){var n=c*a[e];return[t-n,t+n]}));return{se:a,t:l,p:u,sigmaHat:s,interval95:h}}return{ols:function(i,o){var r=t(i,o),s=n(r),a=function(t){var n,i,o,r=t.R2/t.df_model/((1-t.R2)/t.df_resid);return{F_statistic:r,pvalue:1-(n=r,i=t.df_model,o=t.df_resid,e.beta.cdf(n/(o/i+n),i/2,o/2))}}(r),l=1-(1-r.R2)*((r.nobs-1)/r.df_resid);return r.t=s,r.f=a,r.adjust_R2=l,r}}}(),e.extend({buildxmatrix:function(){for(var t=new Array(arguments.length),n=0;n<arguments.length;n++)t[n]=[1].concat(arguments[n]);return e(t)},builddxmatrix:function(){for(var t=new Array(arguments[0].length),n=0;n<arguments[0].length;n++)t[n]=[1].concat(arguments[0][n]);return e(t)},buildjxmatrix:function(t){for(var n=new Array(t.length),i=0;i<t.length;i++)n[i]=t[i];return e.builddxmatrix(n)},buildymatrix:function(t){return e(t).transpose()},buildjymatrix:function(t){return t.transpose()},matrixmult:function(t,n){var i,o,r,s,a;if(t.cols()==n.rows()){if(n.rows()>1){for(s=[],i=0;i<t.rows();i++)for(s[i]=[],o=0;o<n.cols();o++){for(a=0,r=0;r<t.cols();r++)a+=t.toArray()[i][r]*n.toArray()[r][o];s[i][o]=a}return e(s)}for(s=[],i=0;i<t.rows();i++)for(s[i]=[],o=0;o<n.cols();o++){for(a=0,r=0;r<t.cols();r++)a+=t.toArray()[i][r]*n.toArray()[o];s[i][o]=a}return e(s)}},regress:function(t,n){var i=e.xtranspxinv(t),o=t.transpose(),r=e.matrixmult(e(i),o);return e.matrixmult(r,n)},regresst:function(t,n,i){var o=e.regress(t,n),r={anova:{}},s=e.jMatYBar(t,o);r.yBar=s;var a=n.mean();r.anova.residuals=e.residuals(n,s),r.anova.ssr=e.ssr(s,a),r.anova.msr=r.anova.ssr/(t[0].length-1),r.anova.sse=e.sse(n,s),r.anova.mse=r.anova.sse/(n.length-(t[0].length-1)-1),r.anova.sst=e.sst(n,a),r.anova.mst=r.anova.sst/(n.length-1),r.anova.r2=1-r.anova.sse/r.anova.sst,r.anova.r2<0&&(r.anova.r2=0),r.anova.fratio=r.anova.msr/r.anova.mse,r.anova.pvalue=e.anovaftest(r.anova.fratio,t[0].length-1,n.length-(t[0].length-1)-1),r.anova.rmse=Math.sqrt(r.anova.mse),r.anova.r2adj=1-r.anova.mse/r.anova.mst,r.anova.r2adj<0&&(r.anova.r2adj=0),r.stats=new Array(t[0].length);for(var l,u,c,h=e.xtranspxinv(t),d=0;d<o.length;d++)l=Math.sqrt(r.anova.mse*Math.abs(h[d][d])),u=Math.abs(o[d]/l),c=e.ttest(u,n.length-t[0].length-1,i),r.stats[d]=[o[d],l,u,c];return r.regress=o,r},xtranspx:function(t){return e.matrixmult(t.transpose(),t)},xtranspxinv:function(t){var n=e.matrixmult(t.transpose(),t);return e.inv(n)},jMatYBar:function(t,n){var i=e.matrixmult(t,n);return new e(i)},residuals:function(t,n){return e.matrixsubtract(t,n)},ssr:function(t,e){for(var n=0,i=0;i<t.length;i++)n+=Math.pow(t[i]-e,2);return n},sse:function(t,e){for(var n=0,i=0;i<t.length;i++)n+=Math.pow(t[i]-e[i],2);return n},sst:function(t,e){for(var n=0,i=0;i<t.length;i++)n+=Math.pow(t[i]-e,2);return n},matrixsubtract:function(t,n){for(var i=new Array(t.length),o=0;o<t.length;o++){i[o]=new Array(t[o].length);for(var r=0;r<t[o].length;r++)i[o][r]=t[o][r]-n[o][r]}return e(i)}}),e.jStat=e,e)},4788:(t,e,n)=>{"use strict";var i=n(5072),o=n.n(i),r=n(7825),s=n.n(r),a=n(7659),l=n.n(a),u=n(5056),c=n.n(u),h=n(540),d=n.n(h),f=n(1113),m=n.n(f),p=n(365),g={};g.styleTagTransform=m(),g.setAttributes=c(),g.insert=l().bind(null,"head"),g.domAPI=s(),g.insertStyleElement=d(),o()(p.A,g),p.A&&p.A.locals&&p.A.locals},5072: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 r={},s=[],a=0;a<t.length;a++){var l=t[a],u=i.base?l[0]+i.base:l[0],c=r[u]||0,h="".concat(u," ").concat(c);r[u]=c+1;var d=n(h),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:h,updater:m,references:1})}s.push(h)}return s}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 r=i(t=t||[],o=o||{});return function(t){t=t||[];for(var s=0;s<r.length;s++){var a=n(r[s]);e[a].references--}for(var l=i(t,o),u=0;u<r.length;u++){var c=n(r[u]);0===e[c].references&&(e[c].updater(),e.splice(c,1))}r=l}}},7659: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)}},540:t=>{"use strict";t.exports=function(t){var e=document.createElement("style");return t.setAttributes(e,t.attributes),t.insert(e,t.options),e}},5056:(t,e,n)=>{"use strict";t.exports=function(t){var e=n.nc;e&&t.setAttribute("nonce",e)}},7825: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 r=n.sourceMap;r&&"undefined"!=typeof btoa&&(i+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(r))))," */")),e.styleTagTransform(i,t,e.options)}(e,t,n)},remove:function(){!function(t){if(null===t.parentNode)return!1;t.parentNode.removeChild(t)}(e)}}}},1113: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))}}},9499:(t,e,n)=>{"use strict";n.d(e,{i:()=>Z,q:()=>$});var i,o,r,s,a,l,u,c=n(7389),h=n(4328),d=n(6082),f=n(2003),m=n(8774);!function(t){t.Levenshtein="Levenshtein",t.JaroWinkler="Jaro-Winkler",t.Manhattan="Manhattan String",t.Onehot="One-Hot"}(i||(i={})),function(t){t.Euclidean="Euclidean",t.Manhattan="Manhattan",t.Cosine="Vector Cosine"}(o||(o={})),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 BitArray"}(r||(r={})),function(t){t.TanimotoIntArray="TanimotoIntArray"}(s||(s={})),function(t){t.Vector="Vector",t.String="String",t.BitArray="BitArray",t.MacroMolecule="MacroMolecule",t.Number="Number",t.IntArray="IntArray",t.NumberArray="NumberArray"}(a||(a={})),function(t){t.Difference="Difference"}(l||(l={})),function(t){t.CommonItems="Common Items"}(u||(u={}));var p=n(1199);r.Tanimoto,r.Dice,r.Asymmetric,r.BraunBlanquet,r.Cosine,r.Kulczynski,r.McConnaughey,r.RogotGoldberg,r.Russel,r.Sokal,r.Hamming,r.Euclidean,r.Tanimoto,r.Dice,r.Asymmetric,r.BraunBlanquet,r.Cosine,r.Kulczynski,r.McConnaughey,r.RogotGoldberg,r.Russel,r.Sokal,r.Hamming,r.Euclidean,r.Tanimoto,r.Dice,r.Cosine,r.Tanimoto,r.Asymmetric,r.Cosine,r.Sokal,p.Z.HAMMING,p.Z.LEVENSHTEIN,p.Z.MONOMER_CHEMICAL_DISTANCE,p.Z.NEEDLEMANN_WUNSCH,new RegExp("[rd]\\((\\w)\\)p?","g");var g,v=n(3077),C=n(439),y=n(4971);async function w(t,e,n,i,o){const r=(0,v.R)(e,o),s=o.getSeqHandler(e).getNewColumnFromList("ref",[n]),a=o.getSeqHandler(s).getSplitted(0),l=i===g.IDENTITY?function(t,e){const n=e.columns.length,i=new Array(n),o=new Array(n),r=new Array(n);for(let s=0;s<n;++s){const n=e.columns.byIndex(s);i[s]=n.getRawData(),o[s]=n.categories.indexOf("");const a=s<t.length?t.getOriginal(s):C._S;r[s]=n.categories.indexOf(a)}const s=d.Column.float("Identity",e.rowCount),a=s.getRawData();for(let n=0;n<e.rowCount;++n){a[n]=0;for(let e=0;e<t.length;++e)(i[e]?i[e][n]:0)===r[e]&&++a[n];a[n]/=t.length}return s}(a,r):i===g.SIMILARITY?await async function(t,e,n){const i=e.columns.toList(),o=await async function(t,e,n){t instanceof d.Column&&(t=(0,v.R)(t,n).columns.toList());const i=(await(0,y.pj)()).getMonomerLib(),o=new Array(t.length),r=t[0].length,s=new Float32Array(r);for(let n=0;n<t.length;++n){const a=n<e.length?e.getCanonical(n):C._S,l=i.getMonomer("PEPTIDE",a)?.smiles??"",u=t[n],c=u.getRawData(),f=u.categories,m=f.indexOf("");if(o[n]={categories:f,data:c,emptyIndex:m},void 0===a)continue;const p=d.Column.fromStrings("smiles",f.map((t=>i.getMonomer("PEPTIDE",t)?.smiles??""))),g=(d.DataFrame.fromColumns([p]),await h.chem.getSimilarities(p,l)),v=g?g.getRawData():null;for(let t=0;t<r;++t){const e=c[t];a!==C._S&&e!==m?s[t]+=v[e]:a===C._S&&e===m&&(s[t]+=1)}}for(let n=0;n<s.length;++n){let i=s[n]/e.length;for(let r=0;r<t.length;++r){const t=o[r];if(r>=e.length&&t.data[n]!==t.emptyIndex||t.data[n]===t.emptyIndex&&r<e.length){i=d.FLOAT_NULL;break}}s[n]=i}return d.Column.fromFloat32Array("Similarity",s)}(i,t,n);return o}(a,r,o):null;if(null===l)throw new Error(`In bio library: Unknown sequence scoring method: ${i}`);return l.name=t.columns.getUnusedName(l.name),t.columns.add(l),l}!function(t){t.IDENTITY="identity",t.SIMILARITY="similarity"}(g||(g={}));var b,A=n(144),S=n.n(A),T=n(7233),E=n.n(T),_=n(4139),N=n(115),x=n(8608),M=n(3541),I=n(3163),O=n(7923),L=n(7654),P=n(5480),R=n(5429),k=n(3262),V=n(1458),F=n(4025);!function(t){t.UMAP="UMAP",t.T_SNE="t-SNE"}(b||(b={}));n(5540);var D,G,U,q,B,H,Y,j,W=n(4329);(G=D||(D={})).EUCLIDEAN="EUCLIDEAN",G.MANHATTAN="MANHATTAN",D.EUCLIDEAN,D.MANHATTAN,(q=U||(U={})).HAMMING="Hamming",q.EUCLIDEAN="Euclidean",q.VECTOR_COSINE="Vector Cosine",q.MANHATTAN="Manhattan",q.TANIMOTO="Tanimoto",q.LEVENSTEIN="Levenshtein",q.NEEDLEMAN_WUNSCH="Needlemann-Wunsch",q.MONOMER_CHEMICAL_DISTANCE="Monomer chemical distance",q.SOKAL="Sokal",q.COSINE="Cosine",q.ASYMMETRIC="Asymmetric",q.Difference="Difference",q.OneHot="One-Hot",U.HAMMING,U.EUCLIDEAN,U.MANHATTAN,U.VECTOR_COSINE,U.TANIMOTO,U.LEVENSTEIN,U.NEEDLEMAN_WUNSCH,U.MONOMER_CHEMICAL_DISTANCE,U.SOKAL,U.COSINE,U.ASYMMETRIC,U.Difference,U.OneHot,U.HAMMING,U.EUCLIDEAN,U.MANHATTAN,U.TANIMOTO,U.SOKAL,U.COSINE,U.ASYMMETRIC,U.LEVENSTEIN,U.NEEDLEMAN_WUNSCH,U.MONOMER_CHEMICAL_DISTANCE,U.Difference,U.OneHot,U.VECTOR_COSINE,new Set([U.HAMMING,U.LEVENSTEIN,U.NEEDLEMAN_WUNSCH,U.MONOMER_CHEMICAL_DISTANCE,U.OneHot]),new Set([U.HAMMING,U.EUCLIDEAN,U.MANHATTAN,U.MONOMER_CHEMICAL_DISTANCE,U.LEVENSTEIN,U.NEEDLEMAN_WUNSCH,U.TANIMOTO,U.COSINE,U.VECTOR_COSINE,U.SOKAL,U.ASYMMETRIC,U.OneHot,U.Difference]),new Set([U.EUCLIDEAN,U.MANHATTAN,U.OneHot,U.Difference,U.VECTOR_COSINE]),new Set([U.EUCLIDEAN,U.MANHATTAN,U.Difference,U.VECTOR_COSINE]),new Set([U.EUCLIDEAN,U.MANHATTAN,U.Difference]),new Set([U.TANIMOTO,U.COSINE,U.SOKAL,U.ASYMMETRIC]),function(t){t.ADD="ADD",t.SUB="SUB",t.MULT="MULT"}(B||(B={})),function(t){t.SQUARE="SQUARE",t.INVERSE="INVERSE",t.TRANSPOSE="TRANSPOSE",t.NORM="NORM",t.COLUMN_NORM="COLUMN_NORM"}(H||(H={})),function(t){t.SCALARMULT="SCALARMULT",t.SCALARADD="SCALARADD",t.SCALARPOW="SCALARPOW"}(Y||(Y={})),Object.prototype.toString,function(t){t.EUCLIDEAN="EUCLIDEAN",t.MANHATTAN="MANHATTAN"}(j||(j={}));var $,z=n(726),K=function(t,e,n,i){return new(n||(n=Promise))((function(o,r){function s(t){try{l(i.next(t))}catch(t){r(t)}}function a(t){try{l(i.throw(t))}catch(t){r(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(s,a)}l((i=i.apply(t,e||[])).next())}))};!function(t){t.SEQUENCE_VARIABILITY_MAP="Sequence Variability Map",t.MOST_POTENT_RESIDUES="Most Potent Residues",t.LOGO_SUMMARY_TABLE="Logo Summary Table",t.DENDROGRAM="Dendrogram",t.CLUSTER_MAX_ACTIVITY="Active peptide selection",t.MCL="MCL",t.SEQUENCE_MUTATION_CLIFFS="Sequence Mutation Cliffs"}($||($={}));class Z{constructor(t){this.isBitsetChangedInitialized=!1,this.isUserChangedSelection=!0,this._dm=null,this.isInitialized=!1,this.isRibbonSet=!1,this.webLogoSelectedMonomers={},this.webLogoBounds={},this.cachedWebLogoTooltip={bar:"",tooltip:null},this._layoutEventInitialized=!1,this.subs=[],this.isHighlighting=!1,this.controlFire=!1,this.accordionSource=null,this._sequenceSpaceViewer=null,this._mclViewer=null,this._monomerPositionStats=null,this._settings=null,this._sequenceSpaceCols=[],this._mclCols=[],this._webLogoSelection=null,this.df=t}get monomerPositionStats(){var t;if(null!==this._monomerPositionStats)return this._monomerPositionStats;const e=this.getScaledActivityColumn();return null===this.positionColumns||null===e?null:(null!==(t=this._monomerPositionStats)&&void 0!==t||(this._monomerPositionStats=(0,V.Ej)(e,this.df.filter,this.positionColumns)),this._monomerPositionStats)}get analysisView(){var t,e,n;return void 0===this._analysisView&&(this._analysisView=this.id?S()(h.shell.tableViews).find((({dataFrame:t})=>(null==t?void 0:t.getTag(d.TAGS.ID))===this.id)):void 0,!this._analysisView&&(null===(t=h.shell.v)||void 0===t?void 0:t.preview)instanceof d.TableView&&(null===(n=null===(e=h.shell.v)||void 0===e?void 0:e.preview)||void 0===n?void 0:n.dataFrame)===this.df&&(this._analysisView=h.shell.v.preview),this._analysisView||(this._analysisView=h.shell.addTableView(this.df))),"1"===this.df.getTag(_.gp.MULTIPLE_VIEWS)||this._layoutEventInitialized||(0,x.Lv)()||(h.shell.v=this._analysisView),this._analysisView.grid.invalidate(),this._analysisView}get settings(){var t,e;const n=this.df.getTag(_.gp.SETTINGS);return n?(null!==(t=this._settings)&&void 0!==t||(this._settings=JSON.parse(n)),!(null===(e=this._settings)||void 0===e?void 0:e.mclSettings)||this._settings.mclSettings.webGPUDescriptionPromise instanceof Promise||(this._settings.mclSettings.webGPUDescriptionPromise=(0,W._)()),this._settings):null}set settings(t){var e,n,i;const o=Object.entries(t),r=Object.assign({},null!==(n=null===(e=this.settings)||void 0===e?void 0:e.sequenceSpaceParams)&&void 0!==n?n:{}),s=new Set;for(const[t,e]of o)switch(this.settings[t]=e,t){case"activityColumnName":case"activityScaling":s.add("activity"),s.add("stats");break;case"showDendrogram":s.add("dendrogram");break;case"showClusterMaxActivity":s.add("clusterMaxActivity");break;case"showSequenceSpace":s.add("showSequenceSpace");break;case"showLogoSummaryTable":s.add("logoSummaryTable");break;case"showMonomerPosition":s.add("monomerPosition");break;case"showMostPotentResidues":s.add("mostPotentResidues");break;case"columns":s.add("columns");break;case"sequenceSpaceParams":s.add("sequenceSpaceParams");break;case"mclSettings":s.add("mclSettings")}if(this.df.setTag("settings",JSON.stringify(this._settings)),this.isInitialized){if(s.has("sequenceSpaceParams")){const t=this.settings.sequenceSpaceParams;Object.entries(t).some((([t,e])=>r[t]!==e&&"epsilon"!==t&&"minPts"!==t&&"clusterEmbeddings"!==t))||(s.delete("sequenceSpaceParams"),this.settings.sequenceSpaceParams.clusterEmbeddings&&s.add("clusterParams"))}s.has("sequenceSpaceParams")&&s.delete("clusterParams");for(const t of s)switch(t){case"activity":this.createScaledCol();break;case"stats":this.webLogoSelection=(0,x.ZR)(this.positionColumns),this.webLogoBounds={},this.cachedWebLogoTooltip={bar:"",tooltip:null},this._monomerPositionStats=null;break;case"dendrogram":this.settings.showDendrogram?this.addDendrogram():this.closeViewer($.DENDROGRAM);break;case"clusterMaxActivity":this.settings.showClusterMaxActivity?this.addClusterMaxActivityViewer():this.closeViewer($.CLUSTER_MAX_ACTIVITY);break;case"logoSummaryTable":this.settings.showLogoSummaryTable?this.addLogoSummaryTable():this.closeViewer($.LOGO_SUMMARY_TABLE);break;case"monomerPosition":this.settings.showMonomerPosition?this.addMonomerPosition():this.closeViewer($.SEQUENCE_VARIABILITY_MAP);break;case"mostPotentResidues":this.settings.showMostPotentResidues?this.addMostPotentResidues():this.closeViewer($.MOST_POTENT_RESIDUES);break;case"columns":const t=this.findViewer($.LOGO_SUMMARY_TABLE);t._viewerGrid=null,t._logoSummaryTable=null,t.render();const e=this.findViewer($.MOST_POTENT_RESIDUES);e._viewerGrid=null,e.render();break;case"sequenceSpaceParams":case"showSequenceSpace":this.settings.showSequenceSpace&&this.addSequenceSpace({clusterEmbeddings:null===(i=this.settings.sequenceSpaceParams)||void 0===i?void 0:i.clusterEmbeddings});break;case"clusterParams":this.clusterEmbeddings();break;case"mclSettings":this.addMCLClusters()}}}get webLogoSelection(){var t,e;return null!==(t=this._webLogoSelection)&&void 0!==t||(this._webLogoSelection=(0,x.ZR)(null!==(e=this.positionColumns)&&void 0!==e?e:[])),this._webLogoSelection}set webLogoSelection(t){this._webLogoSelection=t,this.fireBitsetChanged(null),this.analysisView.grid.invalidate()}get positionColumns(){const t=S()(this.df.columns.byTags({[_.gp.POSITION_COL]:"true"})).toArray();return 0===t.length?null:t}get id(){return this.df.getTag(d.TAGS.ID)}get alphabet(){return this.df.getCol(this.settings.sequenceColumnName).getTag(f.gp.alphabet)}static getInstance(t){if(t.columns.contains(_.$2.ACTIVITY_SCALED)&&!t.columns.contains(_.$2.ACTIVITY)&&(t.getCol(_.$2.ACTIVITY_SCALED).name=_.$2.ACTIVITY),!t.temp[Z.modelName]){const e=t.temp[Z.modelName]=new Z(t),n=e.settings;n&&e.init(n);let i=!0;e.subs.push(d.debounce(t.onSelectionChanged,10).subscribe((n=>{var o,r,s;if(i||t.selection.anyTrue||!e._analysisView||!document.contains(e._analysisView.root)||e._analysisView.dataFrame!==t)return void(i=!(null===(o=null==t?void 0:t.selection)||void 0===o?void 0:o.anyTrue));e.positionColumns&&(e.webLogoSelection=(0,x.ZR)(e.positionColumns));const a=e.findViewer($.SEQUENCE_VARIABILITY_MAP);if(null!=a){const t=null!==(r=e.positionColumns)&&void 0!==r?r:a.positionColumns;t&&(a.invariantMapSelection=(0,x.ZR)(t),a.mutationCliffsSelection=(0,x.ZR)(t))}const l=e.findViewer($.MOST_POTENT_RESIDUES);if(null!=l){const t=null!==(s=e.positionColumns)&&void 0!==s?s:l.positionColumns;t&&(l.mutationCliffsSelection=(0,x.ZR)(t),l.invariantMapSelection=(0,x.ZR)(t))}const u=e.findViewer($.LOGO_SUMMARY_TABLE);null!=u&&(u.initClusterSelection({notify:!0}),u.render()),i=!0})))}return t.temp[Z.modelName]}modifyWebLogoSelection(t,e={shiftPressed:!1,ctrlPressed:!1},n=!0){n?this.webLogoSelection=(0,x.vW)(this.webLogoSelection,t,e):this._webLogoSelection=(0,x.vW)(this.webLogoSelection,t,e)}getVisibleSelection(){return this.df.selection.clone().and(this.df.filter)}createAccordion(){var t,e,n,i,o,r,s,a,l;const u=null===(t=this.df)||void 0===t?void 0:t.temp[Z.modelName];if(!u)return null;const h=c.accordion("Peptides analysis panel");h.root.style.width="100%";const m=u.getVisibleSelection(),p=u.df.filter.anyFalse?` among ${u.df.filter.trueCount} filtered`:"",g=t=>{const e=[];for(const[n,i]of Object.entries(t))for(const t of i)e.push(`${n}:${t}`);return e.join(", ")},v=u.findViewer($.LOGO_SUMMARY_TABLE),C=[],y=(null===v?[]:(null!==(n=null===(e=v.clusterSelection)||void 0===e?void 0:e[P.W.ORIGINAL])&&void 0!==n?n:[]).concat(null!==(o=null===(i=v.clusterSelection)||void 0===i?void 0:i[P.W.CUSTOM])&&void 0!==o?o:[])).join(", "),w=t=>{const e=c.divText(t);return e.innerHTML=t,e};0!==y.length&&C.push(w(`<b>Logo Summary Table</b> clusters: ${y}`));const b=u.findViewer($.SEQUENCE_VARIABILITY_MAP),A=g(null!==(r=null==b?void 0:b.invariantMapSelection)&&void 0!==r?r:{}),S=g(null!==(s=null==b?void 0:b.mutationCliffsSelection)&&void 0!==s?s:{});0!==A.length&&C.push(w(`<b>Invariant map</b>: ${A}`)),0!==S.length&&C.push(w(`<b>Mutation cliffs</b>: ${S}`));const T=u.findViewer($.MOST_POTENT_RESIDUES),E=g(null!==(a=null==T?void 0:T.invariantMapSelection)&&void 0!==a?a:{});0!==E.length&&C.push(w(`<b>Most potent residues</b>: ${E}`));const _=g(u.webLogoSelection);0!==_.length&&C.push(w(`<b>WebLogo</b>: ${_}`)),0!==C.length&&C.unshift(c.h1("Selection Sources"));const N=c.div(c.divV(C));h.addTitle(c.divV([c.h1(`${m.trueCount} selected rows${p}`),N],"css-gap-small"));let R=u.settings;const k=[b,T,v].filter((t=>null!==t&&(t.type!==this.accordionSource||(R=t,!1))));if(null===R)throw new Error("PeptidesError: Model is the source of accordion but is not initialized");R!==u.settings&&k.push(u.settings),k.filter((t=>null!==t&&(0,x.$s)(R,t)&&(t!==u.settings||u.isInitialized))).push(R);const D=R;R===u.settings||D instanceof P.s||null==D.mutationCliffs||h.addPane("Mutation Cliffs pairs",(()=>(0,O.F)(u.df,{mutationCliffs:D.mutationCliffs,mutationCliffsSelection:D.mutationCliffsSelection,gridColumns:u.analysisView.grid.columns,sequenceColumnName:D.sequenceColumnName,positionColumns:D.positionColumns,activityCol:D.getScaledActivityColumn(),mutationCliffStats:D.cliffStats}).root),!0);const G=R===u.settings,U=G?this.webLogoSelection:R instanceof M.J?R.invariantMapSelection:{},q=R instanceof P.s?R.clusterSelection:null!==(l=null==v?void 0:v.clusterSelection)&&void 0!==l?l:{};h.addPane("Distribution",(()=>{var t;try{return(0,L.HV)(u.df,{columns:G?null!==(t=u.settings.columns)&&void 0!==t?t:{}:R.getAggregationColumns(),activityCol:G?u.getScaledActivityColumn():R.getScaledActivityColumn(),monomerPositionSelection:U,clusterSelection:q,clusterColName:null==v?void 0:v.clustersColumnName})}catch(t){const e=c.divText("Error in Distribution");return c.tooltip.bind(e,String(t)),e}}),!0);const B=(t,e)=>{if(null==t||null==e)return!1;for(const[n,i]of Object.entries(t))if(i!==e[n])return!1;return!0};return h.addPane("Selection",(()=>{var t;try{return function(t,e){var n,i,o;if(0===e.tableSelection.trueCount)return c.divText("No compounds selected");const r=d.DataFrame.create(t.rowCount);r.name="Selected compounds",r.filter.copyFrom(e.tableSelection);let s=null;for(let t=1;t<e.gridColumns.length;t++){const o=e.gridColumns.byIndex(t);if(!o.visible)continue;const a=o.column;if(a.type===d.COLUMN_TYPE.BOOL)continue;null===s&&o.grid&&(null===(n=o.grid.sortByColumns)||void 0===n?void 0:n.length)>0&&(null===(i=o.grid.sortTypes)||void 0===i?void 0:i.length)===o.grid.sortByColumns.length&&(s={cols:o.grid.sortByColumns,types:o.grid.sortTypes});let l=null,u=null;try{l=a.getRawData(),u=a.categories}catch(t){}const c=l&&u?a.isNumerical?t=>l[t]:t=>u[l[t]]:t=>a.get(t),h=t=>a.isNone(t)?null:c(t),f=a.name===e.activityColumn.name?r.columns.addNewFloat(o.name).init((t=>h(t))):r.columns.addNewVirtual(o.name,(t=>h(t)),a.type);for(const[t,e]of a.tags)f.setTag(t,e)}const a=r.plot.grid();a.props.showRowHeader=!1,a.root.style.maxWidth="100%",d.debounce(c.onSizeChanged(a.root),50).subscribe((t=>{var e;const n=a.root.parentElement;(null===(e=null==n?void 0:n.parentElement)||void 0===e?void 0:e.classList.contains("panel-content"))&&(a.root.style.height="calc(100% - 20px)",a.root.style.width="calc(100% - 20px)",a.root.style.position="absolute",a.root.style.right="10px",a.root.style.top="10px")})),(0,x.zz)(a);const l=c.box(a.root);l.style.marginLeft="0px",setTimeout((()=>{null!==s&&a.sort(s.cols,s.types);for(let t=1;t<e.gridColumns.length;t++){const n=e.gridColumns.byIndex(t);n.visible&&a.col(n.name)&&(a.col(n.name).width=n.width)}}),500);const u=(0,V.Ej)(e.activityColumn,r.filter,e.positionColumns,{isFiltered:!0}),h={isSelectionTable:!0,cachedWebLogoTooltip:()=>({bar:"",tooltip:null}),webLogoBounds:()=>({}),colorPalette:()=>e.colorPalette},f={x:0,y:0,monomerPosition:{},mpStats:u};return e.isAnalysis&&(0,I.FZ)(a,u,e.positionColumns,e.activityColumn,h,f),(null!==(o=t.columns.bySemTypeAll(d.SEMTYPE.MACROMOLECULE))&&void 0!==o?o:[]).forEach((t=>{r.col(t.name)&&(r.col(t.name).temp[F.j.notationProvider]=t.temp[F.j.notationProvider])})),l}(u.df,{positionColumns:G?u.positionColumns:R.positionColumns,columns:G?null!==(t=u.settings.columns)&&void 0!==t?t:{}:R.getAggregationColumns(),activityColumn:G?u.getScaledActivityColumn():R.getScaledActivityColumn(),gridColumns:u.analysisView.grid.columns,colorPalette:(0,f.SM)(u.df.getCol(G?u.settings.sequenceColumnName:R.sequenceColumnName),z.Z.getSeqHelper()),tableSelection:u.getCombinedSelection(),isAnalysis:null!==u.settings&&(G||B(u.settings.columns,R.getAggregationColumns()))})}catch(t){const e=c.divText("Error in Selection");return c.tooltip.bind(e,String(t)),e}}),!0),h}getScaledActivityColumn(t=!1){const e=this.df.col(_.$2.ACTIVITY);return t&&null!==e?d.DataFrame.fromColumns([e]).clone(this.df.filter).getCol(e.name):e}updateGrid(){this.joinDataFrames(),this.createScaledCol(),this.webLogoBounds={};const t={selectionCallback:(t,e)=>this.modifyWebLogoSelection(t,e),unhighlightCallback:()=>this.unhighlight(),colorPalette:()=>(0,f.SM)(this.df.getCol(this.settings.sequenceColumnName),z.Z.getSeqHelper()),webLogoBounds:()=>this.webLogoBounds,cachedWebLogoTooltip:()=>this.cachedWebLogoTooltip,highlightCallback:(t,e,n)=>{(0,x.dl)(t,e,n),this.isHighlighting=!0},isSelectionTable:!1,headerSelectedMonomers:()=>this.webLogoSelectedMonomers};if(null===this.monomerPositionStats||null===this.positionColumns)throw new Error("PeptidesError: Could not updage grid: monomerPositionStats or positionColumns are null");I.FZ(this.analysisView.grid,this.monomerPositionStats,this.positionColumns,this.getScaledActivityColumn(),t),this._layoutEventInitialized||(h.events.onViewLayoutApplied.subscribe((t=>{t.view.id===this.analysisView.id&&this.updateGrid()})),this._layoutEventInitialized=!0),this.setTooltips(),this.setBitsetCallback(),this.setGridProperties()}joinDataFrames(){const t=this.df.name,e=this.df.columns,n=(0,v.R)(this.df.getCol(this.settings.sequenceColumnName),z.Z.getSeqHelper()),i=n.columns.names();if(i.every((t=>e.contains(t))))i.forEach((t=>{this.df.col(t).setTag(_.gp.ANALYSIS_COL,"true"),this.df.col(t).setTag(_.gp.POSITION_COL,"true"),I.rI(this.df.col(t),this.alphabet)}));else for(const t of i){let i=this.df.col(t);const o=n.getCol(t);null!==i&&e.remove(t);const r=o.categories,s=o.getRawData();i=e.addNew(o.name,o.type).init((t=>r[s[t]])),i.setTag(_.gp.ANALYSIS_COL,"true"),i.setTag(_.gp.POSITION_COL,"true"),I.rI(i,this.alphabet)}this.df.name=t}createScaledCol(){const t=this.analysisView.grid,e=(0,x.Y1)(this.df.getCol(this.settings.activityColumnName),this.settings.activityScaling);this.df.columns.replace(_.$2.ACTIVITY,e),t.columns.setOrder([e.name])}unhighlight(){this.isHighlighting&&(this.df.rows.highlight(null),this.isHighlighting=!1)}setTooltips(){this.analysisView.grid.onCellTooltip(((t,e,n)=>{var i,o;return!(!t.isColHeader||(null===(i=t.tableColumn)||void 0===i?void 0:i.semType)!==_.uF.MONOMER)||!(!t.isTableCell||(null===(o=t.tableColumn)||void 0===o?void 0:o.semType)!==_.uF.MONOMER)}))}getCombinedSelection(){var t,e,n,i,o,r,s,a;const l=new m.A(this.df.rowCount,!1),u=(t,e)=>{for(const[n,i]of Object.entries(t))for(const t of i){const i=null==e?void 0:e[n];if(void 0===i)continue;const o=i[t];void 0!==o&&l.or(o.mask)}};u(this.webLogoSelection,this.monomerPositionStats);const c=this.findViewer($.SEQUENCE_VARIABILITY_MAP);u(null!==(t=null==c?void 0:c.invariantMapSelection)&&void 0!==t?t:{},null!==(e=null==c?void 0:c.monomerPositionStats)&&void 0!==e?e:null),((t,e)=>{var n,i;for(const[o,r]of Object.entries(t))for(const t of r){const r=null!==(i=null===(n=null==e?void 0:e.get(t))||void 0===n?void 0:n.get(o))&&void 0!==i?i:null;if(null!==r)for(const[t,e]of r.entries()){l.setTrue(t);for(const t of e)l.setTrue(t)}}})(null!==(n=null==c?void 0:c.mutationCliffsSelection)&&void 0!==n?n:{},null!==(i=null==c?void 0:c.mutationCliffs)&&void 0!==i?i:null);const h=this.findViewer($.MOST_POTENT_RESIDUES);u(null!==(o=null==h?void 0:h.invariantMapSelection)&&void 0!==o?o:{},null!==(r=null==h?void 0:h.monomerPositionStats)&&void 0!==r?r:null);const f=this.findViewer($.LOGO_SUMMARY_TABLE);for(const t of Object.keys(null!==(s=null==f?void 0:f.clusterSelection)&&void 0!==s?s:{}))for(const e of null!==(a=f.clusterSelection[t])&&void 0!==a?a:[]){const n=f.clusterStats[t][e];l.or(n.mask)}const p=d.BitSet.fromBytes(l.buffer.buffer,l.length);return this.df.filter.anyFalse?p.and(this.df.filter):p}setBitsetCallback(){if(this.isBitsetChangedInitialized)return;const t=this.df.selection,e=this.df.filter;let n=null;const i=()=>{try{null!=n&&(clearTimeout(n),n=null);const t=this.createAccordion();if(null===t)return;h.shell.o=t.root,n=setTimeout((()=>{h.shell.o!=t.root&&(h.shell.o=t.root)}),1500)}catch(t){console.error(t)}};t.onChanged.subscribe((()=>{if(this.controlFire)this.controlFire=!1;else try{this.isUserChangedSelection||t.copyFrom(this.getCombinedSelection(),!1)}catch(t){k._package.logger.debug("Peptides: Error on selection changed"),k._package.logger.debug(t)}finally{i()}})),e.onChanged.subscribe((()=>{var t,e;try{if(this.controlFire)return void(this.controlFire=!1);const n=this.findViewer($.LOGO_SUMMARY_TABLE);null!==n&&void 0!==n.model&&(n._logoSummaryTable=null!==(t=n.createLogoSummaryTable())&&void 0!==t?t:n._logoSummaryTable,n._viewerGrid=null!==(e=n.createLogoSummaryTableGrid())&&void 0!==e?e:n._viewerGrid,n.render())}catch(t){k._package.logger.debug("Peptides: Error on filter changed"),k._package.logger.debug(t)}finally{i()}})),this.isBitsetChangedInitialized=!0}fireBitsetChanged(t,e=!1){this.accordionSource=t,this.isBitsetChangedInitialized||this.setBitsetCallback(),this.isUserChangedSelection=!1,this.df.selection.fireChanged(),e&&this.df.filter.fireChanged(),this.controlFire=!0,this.df.selection.fireChanged(),e&&this.df.filter.fireChanged(),this.isUserChangedSelection=!0,this.webLogoSelectedMonomers=(0,x.qx)(this.df)}setGridProperties(t){var e,n,i,o;const r=this.analysisView.grid,s=r.props;s.allowColSelection=null!==(e=null==t?void 0:t.allowColSelection)&&void 0!==e&&e,s.allowEdit=null!==(n=null==t?void 0:t.allowEdit)&&void 0!==n&&n,s.showReadOnlyNotifications=null!==(i=null==t?void 0:t.showReadOnlyNotifications)&&void 0!==i&&i,s.showCurrentRowIndicator=null!==(o=null==t?void 0:t.showCurrentRowIndicator)&&void 0!==o&&o;const a=this.positionColumns;if(null===a)throw new Error("PeptidesError: Could not set grid properties: positionColumns are null");let l=10;const u=r.canvas.getContext("2d");if(null===u)throw new Error("PeptidesError: Could not set grid properties: canvas context is null");for(const t of a){const e=(0,f.zS)(t.categories.reduce(((t,e)=>t.length>e.length?t:e)),6),n=Math.ceil(u.measureText(e).width);l=Math.max(l,n)}const c=a.map((t=>t.name));for(let t=1;t<this.analysisView.grid.columns.length;++t){const e=this.analysisView.grid.columns.byIndex(t);if(null===e)throw new Error(`PeptidesError: Could not get analysis view: grid column with index '${t}' is null`);if(null===e.column)throw new Error(`PeptidesError: Could not get analysis view: grid column with index '${t}' has null column`);e.visible=c.includes(e.column.name)||e.column.name===_.$2.ACTIVITY}setTimeout((()=>{for(const t of a){const e=r.col(t.name);if(null===e)throw new Error(`PeptidesError: Could not set column width: grid column '${t.name}' is null`);e.width=l+15}}),100)}closeViewer(t){const e=this.findViewer(t);null==e||e.detach(),null==e||e.close()}findViewerNode(t){for(const e of this.analysisView.dockManager.rootNode.children)if(e.container.containerElement.innerHTML.includes(t))return e;return null}addDendrogram(){return K(this,void 0,void 0,(function*(){const t=d.TaskBarProgressIndicator.create("Calculating distance matrix...");try{const t=d.Func.find({package:"Dendrogram",name:"hierarchicalClustering"})[0];if(!t||4!==t.inputs.length)throw new Error("Correct dendrogram function is not found");yield t.apply({df:this.df,colNameList:[this.settings.sequenceColumnName],distance:"euclidean",linkage:"complete"})}catch(t){k._package.logger.error(t)}finally{t.close()}}))}init(t){if(!this.isInitialized){if(this.settings=t,this.isInitialized=!0,!this.isRibbonSet&&"1"!==this.df.getTag(_.gp.MULTIPLE_VIEWS)){const t=c.iconFA("wrench",(()=>(0,R.OH)(this)),"Peptides analysis settings");this.analysisView.setRibbonPanels([[t]],!1),this.isRibbonSet=!0,this.updateGrid()}this.subs.push(h.events.onAccordionConstructed.subscribe((t=>{if(!(h.shell.o instanceof d.SemanticValue||h.shell.o instanceof d.Column&&this.df.columns.toList().includes(h.shell.o)))return;const e=t.getPane("Actions"),n=E()(e.root).find(".d4-flex-col"),i=c.label("Calculate identity");i.classList.add("d4-link-action"),c.tooltip.bind(i,"Adds a column with fractions of matching monomers against sequence in the current row"),i.onclick=()=>{const t=this.df.getCol(this.settings.sequenceColumnName);w(this.df,t,t.get(this.df.currentRowIdx),g.IDENTITY,z.Z.getSeqHelper()).then((e=>e.setTag(_.gp.IDENTITY_TEMPLATE,t.get(this.df.currentRowIdx)))).catch((t=>k._package.logger.debug(t)))},n.append(c.span([i],"d4-markdown-row"));const o=c.label("Calculate similarity");o.classList.add("d4-link-action"),c.tooltip.bind(o,"Adds a column with sequence similarity scores against sequence in the current row"),o.onclick=()=>{const t=this.df.getCol(this.settings.sequenceColumnName);w(this.df,t,t.get(this.df.currentRowIdx),g.SIMILARITY,z.Z.getSeqHelper()).then((e=>e.setTag(_.gp.SIMILARITY_TEMPLATE,t.get(this.df.currentRowIdx)))).catch((t=>k._package.logger.debug(t)))},n.append(c.span([o],"d4-markdown-row"))}))),this.subs.push(h.events.onViewRemoved.subscribe((t=>{t.id===this.analysisView.id&&this.subs.forEach((t=>t.unsubscribe())),h.log.debug(`Peptides: view ${t.name} removed`)}))),this.subs.push(h.events.onTableRemoved.subscribe((t=>{t.id===this.df.id&&this.subs.forEach((t=>t.unsubscribe())),h.log.debug(`Peptides: table ${t.name} removed`)}))),this.subs.push(h.events.onProjectClosed.subscribe((t=>{t.id===h.shell.project.id&&this.subs.forEach((t=>t.unsubscribe())),h.log.debug(`Peptides: project ${t.name} closed`)}))),this.fireBitsetChanged(null,!0),this.analysisView.grid.invalidate()}}findViewer(t){return S()(this.analysisView.viewers).find((e=>e.type===t))||null}addLogoSummaryTable(t){return K(this,void 0,void 0,(function*(){null!=t||(t={sequenceColumnName:this.settings.sequenceColumnName,clustersColumnName:S()(this.df.columns.categorical).next().value,activityColumnName:this.settings.activityColumnName,activityScaling:this.settings.activityScaling});const e=yield this.df.plot.fromType($.LOGO_SUMMARY_TABLE,t);(0,x.Lv)()&&this.analysisView.addViewer(e),this.analysisView.dockManager.dock(e,d.DOCK_TYPE.RIGHT,null,$.LOGO_SUMMARY_TABLE),e.viewerGrid.invalidate()}))}addClusterMaxActivityViewer(t){return K(this,void 0,void 0,(function*(){var e,n,i,o,r,s,a,l,u;const c=null!==(o=null!==(n=null===(e=this._mclCols)||void 0===e?void 0:e.find((t=>t.toLowerCase().startsWith("cluster (mcl)"))))&&void 0!==n?n:null===(i=this.findViewer($.LOGO_SUMMARY_TABLE))||void 0===i?void 0:i.clustersColumnName)&&void 0!==o?o:null===(r=this._sequenceSpaceCols)||void 0===r?void 0:r.find((t=>t.toLowerCase().startsWith("cluster")));null!=t||(t={activityColumnName:this.settings.activityColumnName,clusterColumnName:null!=c?c:null===(s=S()(this.df.columns.categorical).next().value)||void 0===s?void 0:s.name,activityTarget:_.wf.HIGH,connectivityColumnName:null!==(l=null!==(a=this._mclCols.find((t=>t.toLowerCase().startsWith("connectivity"))))&&void 0!==a?a:this.df.columns.names().find((t=>{var e;return t.toLowerCase().includes("connectivity")&&(null===(e=this.df.col(t))||void 0===e?void 0:e.isNumerical)})))&&void 0!==l?l:"",clusterSizeThreshold:20,activityThreshold:1e3});const h=yield this.df.plot.fromType($.CLUSTER_MAX_ACTIVITY,t),f=null!==(u=this.findViewerNode($.LOGO_SUMMARY_TABLE))&&void 0!==u?u:null;this.analysisView.dockManager.dock(h,f?d.DOCK_TYPE.DOWN:d.DOCK_TYPE.RIGHT,f,$.CLUSTER_MAX_ACTIVITY)}))}addMonomerPosition(t){return K(this,void 0,void 0,(function*(){null!=t||(t={maxMutations:1,activityScaling:this.settings.activityScaling,activityColumnName:this.settings.activityColumnName,sequenceColumnName:this.settings.sequenceColumnName,minActivityDelta:0,activityTarget:_.wf.HIGH});const e=yield this.df.plot.fromType($.SEQUENCE_VARIABILITY_MAP,t);(0,x.Lv)()&&this.analysisView.addViewer(e);const n=this.findViewer($.MOST_POTENT_RESIDUES),i=this.analysisView.dockManager,[o,r,s]=null===n?[d.DOCK_TYPE.DOWN,null,void 0]:[d.DOCK_TYPE.LEFT,this.findViewerNode($.MOST_POTENT_RESIDUES),.7];i.dock(e,o,r,$.SEQUENCE_VARIABILITY_MAP,s)}))}addMostPotentResidues(t){return K(this,void 0,void 0,(function*(){null!=t||(t={activityScaling:this.settings.activityScaling,activityColumnName:this.settings.activityColumnName,sequenceColumnName:this.settings.sequenceColumnName,minActivityDelta:0,maxMutations:1,activityTarget:_.wf.HIGH});const e=yield this.df.plot.fromType($.MOST_POTENT_RESIDUES,t);(0,x.Lv)()&&this.analysisView.addViewer(e);const n=this.findViewer($.SEQUENCE_VARIABILITY_MAP),i=this.analysisView.dockManager,[o,r,s]=null===n?[d.DOCK_TYPE.DOWN,null,void 0]:[d.DOCK_TYPE.RIGHT,this.findViewerNode($.SEQUENCE_VARIABILITY_MAP),.3];i.dock(e,o,r,$.MOST_POTENT_RESIDUES,s)}))}createNewView(){const t=this.getVisibleSelection(),e=this.df.clone(t);for(const[t,n]of e.tags)e.setTag(t,t===_.gp.SETTINGS?n:"");e.name="Peptides Multiple Views",e.setTag(_.gp.MULTIPLE_VIEWS,"1");const n=h.shell.addTableView(e),i=this.findViewer($.LOGO_SUMMARY_TABLE);return null!=i&&n.addViewer($.LOGO_SUMMARY_TABLE,{[`sequence${_.To}`]:i.sequenceColumnName,[`activity${_.To}`]:i.activityColumnName,activityScaling:i.activityScaling,webLogoMode:i.webLogoMode,membersRatioThreshold:i.membersRatioThreshold,[`clusters${_.To}`]:i.clustersColumnName}),e.getTag(d.TAGS.ID)}clusterEmbeddings(){return K(this,void 0,void 0,(function*(){var t,e;if(!this._sequenceSpaceCols||0===this._sequenceSpaceCols.length)return void h.shell.warning("Embeddings columns are not initialized");const i=this._sequenceSpaceCols.filter((t=>t.toLowerCase().startsWith("embed_")));if(2!==i.length)return void h.shell.warning(`Found ${i.length} embeddings columns, expected 2`);const o=this._sequenceSpaceCols.filter((t=>t.toLowerCase().startsWith("cluster")));o.length>0&&this.df.columns.remove(o[0]);const r=this.df.getCol(i[0]).getRawData(),s=this.df.getCol(i[1]).getRawData(),a=null!==(t=this.settings.sequenceSpaceParams.epsilon)&&void 0!==t?t:.01,l=null!==(e=this.settings.sequenceSpaceParams.minPts)&&void 0!==e?e:4,u=yield function(t,e,i,o){return r=this,s=void 0,l=function*(){return new Promise((function(r,s){const a=new Worker(new URL(n.p+n.u(682),n.b));a.postMessage({embedX:t,embedY:e,minPts:o,epsilon:i}),a.onmessage=({data:{error:t,clusters:e}})=>{a.terminate(),t?s(t):r(e)}}))},new((a=void 0)||(a=Promise))((function(t,e){function n(t){try{o(l.next(t))}catch(t){e(t)}}function i(t){try{o(l.throw(t))}catch(t){e(t)}}function o(e){var o;e.done?t(e.value):(o=e.value,o instanceof a?o:new a((function(t){t(o)}))).then(n,i)}o((l=l.apply(r,s||[])).next())}));var r,s,a,l}(r,s,a,l),c=this.df.columns.getUnusedName("Cluster (DBSCAN)"),d=this.df.columns.addNewString(c);d.init((t=>u[t].toString())),null!==this._sequenceSpaceViewer&&(this._sequenceSpaceViewer.props.colorColumnName=d.name),this._sequenceSpaceCols=[i[0],i[1],d.name];const f=this.analysisView.grid.col(d.name);f&&(f.visible=!1)}))}addMCLClusters(){return K(this,void 0,void 0,(function*(){var t,e,n,i,o;if(null!==this._mclViewer)try{null===(t=this._mclViewer)||void 0===t||t.detach(),null===(e=this._mclViewer)||void 0===e||e.close()}catch(t){}0!==this._mclCols.length&&this._mclCols.forEach((t=>this.df.columns.remove(t))),this._mclCols=[];const r=this.df.getCol(this.settings.sequenceColumnName);null!==(n=(o=this.settings).mclSettings)&&void 0!==n||(o.mclSettings=new N.av);const s=this.settings.mclSettings;let a=0;const l=this.df.onColumnsAdded.subscribe((t=>{for(const e of t.columns)if((e.name.toLowerCase().startsWith("embed")||e.name.toLowerCase().startsWith("cluster")||e.name.toLowerCase().startsWith("connectivity"))&&e.name.toLowerCase().includes("mcl")){const t=this.analysisView.grid.col(e.name);if(null==t||this._mclCols.includes(e.name))continue;t.visible=!1,this._mclCols.push(e.name),a++}5===a&&l.unsubscribe()})),u=h.events.onViewerAdded.subscribe((t=>{try{const e=t.args.viewer;if(e.type===d.VIEWER.SCATTER_PLOT){if(this._sequenceSpaceViewer&&this.analysisView.dockManager.findNode(this._sequenceSpaceViewer.root)){const t=this.analysisView.dockManager.findNode(this._sequenceSpaceViewer.root);setTimeout((()=>{this.analysisView.dockManager.dock(e,d.DOCK_TYPE.FILL,t)}))}u.unsubscribe()}}catch(t){console.error(t)}})),c=JSON.stringify({cols:[r].map((t=>t.name)),metrics:[s.distanceF],weights:[1],aggregationMethod:j.MANHATTAN,preprocessingFuncs:["macromoleculePreprocessingFunction"],preprocessingFuncArgs:[{gapOpen:s.gapOpen,gapExtend:s.gapExtend,fingerprintType:s.fingerprintType}],threshold:s.threshold,maxIterations:s.maxIterations,useWebGPU:s.useWebGPU,inflate:s.inflation,minClusterSize:s.minClusterSize}),f=null!==(i=this.analysisView)&&void 0!==i?i:h.shell.getTableView(this.df.name);if(f){const t=d.Func.find({package:"EDA",name:"markovClusteringViewer"})[0];if(!t)throw new Error("Markov clustering function is not found");if(yield t.apply(),f.addViewer($.MCL,{mclProps:c}),yield d.delay(500),this._mclViewer=this.findViewer($.MCL),yield this._mclViewer.initPromise,this._mclViewer=this.findViewer($.MCL),!this._mclViewer||!this._mclViewer.isDetached)return null==u||u.unsubscribe(),void(null==l||l.unsubscribe());const e=this.findViewer($.LOGO_SUMMARY_TABLE);e&&(e._clusterStats=null,e._clusterSelection=null,e._viewerGrid=null,e._logoSummaryTable=null,e.render())}}))}addSequenceSpace(){return K(this,arguments,void 0,(function*(t={}){var e,n,i,o;if(null!==this._sequenceSpaceViewer)try{null===(e=this._sequenceSpaceViewer)||void 0===e||e.detach(),null===(n=this._sequenceSpaceViewer)||void 0===n||n.close()}catch(t){}0!==this._sequenceSpaceCols.length&&this._sequenceSpaceCols.forEach((t=>this.df.columns.remove(t))),this._sequenceSpaceCols=[];let r=this.df.getCol(this.settings.sequenceColumnName);const s=z.Z.getSeqHelper().getSeqHandler(r);if(s.isHelm())try{h.shell.warning("Column is in HELM notation. Sequences space will linearize sequences from position 0 prior to analysis");const t=s.convert(f.Hi.SEPARATOR,"/"),e=this.df.columns.getUnusedName(`Separator(${r.name})`);t.name=e,this.df.columns.add(t,!0),this.analysisView.grid.col(e).visible=!1,r=t}catch(t){return h.shell.error("Error on converting HELM notation to linear notation"),void h.shell.error(t)}const a=!t.clusterCol&&!!t.clusterEmbeddings,l=null!==(o=null===(i=this.settings)||void 0===i?void 0:i.sequenceSpaceParams)&&void 0!==o?o:new N.GI(a);l.clusterEmbeddings=a;const u={table:this.df,molecules:r,methodName:b.UMAP,similarityMetric:l.distanceF,plotEmbeddings:!0,options:{bypassLargeDataWarning:!0,dbScanEpsilon:l.epsilon,dbScanMinPts:l.minPts,randomSeed:"1",preprocessingFuncArgs:{gapOpen:l.gapOpen,gapExtend:l.gapExtend,fingerprintType:l.fingerprintType}},clusterEmbeddings:l.clusterEmbeddings};let c=0;const m=l.clusterEmbeddings?3:2,p=this.df.onColumnsAdded.subscribe((t=>{for(const e of t.columns)if(e.name.toLowerCase().startsWith("embed_")||l.clusterEmbeddings&&e.name.toLowerCase().startsWith("cluster")){const t=this.analysisView.grid.col(e.name);if(null==t||this._sequenceSpaceCols.includes(e.name))continue;t.visible=!1,this._sequenceSpaceCols.push(e.name),c++}c===m&&p.unsubscribe()})),g=h.events.onViewerAdded.subscribe((t=>{try{const e=t.args.viewer;if(e.type===d.VIEWER.SCATTER_PLOT){if(this._mclViewer&&this.analysisView.dockManager.findNode(this._mclViewer.root)){const t=this.analysisView.dockManager.findNode(this._mclViewer.root);setTimeout((()=>{this.analysisView.dockManager.dock(e,d.DOCK_TYPE.FILL,t)}))}g.unsubscribe()}}catch(t){console.error(t)}})),v=yield h.functions.call("Bio:sequenceSpaceTopMenu",u);g.unsubscribe(),v instanceof d.ScatterPlotViewer&&(l.clusterEmbeddings||t.clusterCol||(v.props.colorColumnName=this.getScaledActivityColumn().name),v.props.showXSelector=!1,v.props.showYSelector=!1,t.clusterCol&&(v.props.colorColumnName=t.clusterCol.name),this._sequenceSpaceViewer=v,v.onContextMenu.subscribe((t=>{try{t.item("Modify Sequence space parameters",(()=>{(0,R.OH)(this)}))}catch(t){}})))}))}}Z.modelName="peptidesModel"},3262:(t,e,n)=>{"use strict";n.r(e),n.d(e,{PackageFunctions:()=>mt,Peptides:()=>j,_package:()=>ct,clusterMaxActivity:()=>tt,getMonomerWorksInstance:()=>ht,getTreeHelperInstance:()=>dt,initPeptides:()=>Y,logoSummaryTable:()=>X,lstPiechartCellRenderer:()=>it,macromoleculeSarFastaDemo:()=>nt,manualAlignment:()=>et,monomerPosition:()=>K,mostPotentResidues:()=>Z,mutationCliffs:()=>Q,peptidesDialog:()=>W,peptidesPanel:()=>z,sequencePositionStatistics:()=>J,testInitFunctionPeptides:()=>$});var i=n(4328),o=n(7389),r=n(6082),s=n(5082),a=n(7233),l=n.n(a),u=(n(4788),n(9499)),c=n(726),h=n(3541),d=n(5480);n(3981);class f{constructor(t){this.monomerLib=t}getCappedRotatedMonomer(t,e){const n=this.monomerLib.getMonomer(t,e);return n?n.molfile:null}}var m=n(4139),p=n(8608),g=n(2003),v=n(115),C=n(5072),y=n.n(C),w=n(7825),b=n.n(w),A=n(7659),S=n.n(A),T=n(5056),E=n.n(T),_=n(540),N=n.n(_),x=n(1113),M=n.n(x),I=n(6677),O={};O.styleTagTransform=M(),O.setAttributes=E(),O.insert=S().bind(null,"head"),O.domAPI=b(),O.insertStyleElement=N(),y()(I.A,O),I.A&&I.A.locals&&I.A.locals;var L;!function(t){let e,n;!function(t){t.vert=function(t){return o.divV(t.map((t=>o.render(t))),{classes:"u2-panel"})},t.horz=function(t){return o.divH(t.map((t=>o.render(t))),{classes:"u2-panel"})}}(e=t.panels||(t.panels={})),t.appHeader=function(t){const n=o.iconImage("",t.iconPath);l()(n).addClass("ui-app-header-icon").css("margin-right","20px");const i=e.horz([]);if(t.appTitle){i.classList.add("u2-app-header-with-name");const e=o.divV([o.divText(t.appTitle,"u2-app-header-app-name-div")],"u2-app-header-app-name-and-slogan-div");t.appSubTitle&&e.append(o.divText(t.appSubTitle));const r=o.div(n);i.append(o.divH([r,e]))}else i.append(n);const r=e.vert([o.markdown(t.description),t.learnMoreUrl?o.link("Learn more",t.learnMoreUrl,void 0,{style:{marginLeft:"15px"}}):null]);return r.classList.add("u2-app-header-description"),i.append(r),t.bottomLine&&i.classList.add("u2-app-header-bottom-line"),i},function(t){t.runAsync=function(t,e){return n=this,r=void 0,a=function*(){o.setUpdateIndicator(t,!0);try{return yield e()}catch(t){i.log.error(t)}finally{o.setUpdateIndicator(t,!1)}},new((s=void 0)||(s=Promise))((function(t,e){function i(t){try{l(a.next(t))}catch(t){e(t)}}function o(t){try{l(a.throw(t))}catch(t){e(t)}}function l(e){var n;e.done?t(e.value):(n=e.value,n instanceof s?n:new s((function(t){t(n)}))).then(i,o)}l((a=a.apply(n,r||[])).next())}));var n,r,s,a}}(n=t.tools||(t.tools={}))}(L||(L={}));var P=n(144),R=n.n(P);const k=rxjs.operators;class V extends r.JsViewer{get scViewer(){return this._scViewer||(this._scViewer=this.createSCViewer()),this._scViewer}constructor(){super(),this._titleHost=o.divText(u.q.CLUSTER_MAX_ACTIVITY,{id:"pep-viewer-title",style:{marginRight:"auto"}}),this._selsectIcon=o.div(),this.activityTarget=m.wf.HIGH,this.viewerError="",this.renderTimeout=null,this.renderDebounceTime=500,this.scFilterQuery=`\${${V.maxActivityInClusterColName}} == 1`,this.selectionSubscription=null,this.linesDrawSubscription=null,this.clusterColumnName=this.column("cluster",{nullable:!1}),this.activityColumnName=this.column("activity",{nullable:!1}),this.colorColumnName=this.column("color",{nullable:!0,defaultValue:null}),this.activityTarget=this.string("activityTarget",m.wf.HIGH,{choices:[m.wf.HIGH,m.wf.LOW]}),this.clusterSizeThreshold=this.int("clusterSizeThreshold",20),this.activityThreshold=this.float("activityThreshold",1e3,{step:.1}),this.connectivityColumnName=this.column("connectivity",{nullable:!0})}get model(){return u.i.getInstance(this.dataFrame)}createSCViewer(){var t;const e={showXAxis:!0,showYAxis:!0,showXSelector:!1,showYSelector:!1,showColorSelector:!1,xAxisType:r.AxisType.logarithmic,yAxisType:r.AxisType.logarithmic,invertYAxis:this.activityTarget===m.wf.LOW,xColumnName:V.clusterSizeColName,markerType:"circle",markerDefaultSize:10,showSizeSelector:!1};if(null==this.clusterColumnName||null==this.activityColumnName||!this.dataFrame.columns.contains(this.clusterColumnName)||!this.dataFrame.columns.contains(this.activityColumnName))return this.viewerError="Please set valid cluster and activity columns",null;const n=this.dataFrame.columns.byName(this.activityColumnName),i=this.dataFrame.columns.byName(this.clusterColumnName),s=null!=this.connectivityColumnName?this.dataFrame.columns.byName(this.connectivityColumnName):null;if(![r.COLUMN_TYPE.FLOAT,r.COLUMN_TYPE.INT,r.COLUMN_TYPE.BIG_INT,r.COLUMN_TYPE.QNUM].includes(n.type))return this.viewerError="Activity column should be numeric",null;const a=this.dataFrame.columns.getOrCreate(V.clusterSizeColName,r.TYPE.INT),l={};for(let e=0;e<this.dataFrame.rowCount;e++){const n=i.get(e);null!=n&&"-1"!=n&&(l[n]=(null!==(t=l[n])&&void 0!==t?t:0)+1)}a.init((t=>{var e;return i.isNone(t)?null:null!==(e=l[i.get(t)])&&void 0!==e?e:null})),n.stats.min<=0&&(e.yAxisType=r.AxisType.linear);const u={},c={};for(let t=0;t<this.dataFrame.rowCount;t++){const e=i.get(t);if(null==e||i.isNone(t)||n.isNone(t))continue;const o=n.get(t),r=u[e];if((null==r||null==r||o>n.get(r)&&this.activityTarget===m.wf.HIGH||o<n.get(r)&&this.activityTarget===m.wf.LOW)&&(u[e]=t),s){const n=s.get(t),i=c[e];(null==i||null==i||n>s.get(i))&&(c[e]=t)}}const h=this.dataFrame.columns.getOrCreate(V.maxActivityInClusterColName,r.COLUMN_TYPE.INT);h.init((t=>i.isNone(t)?0:t===u[i.get(t)]?1:0)),this.dataFrame.columns.getOrCreate(V.maxConnectivityInClusterColName,r.COLUMN_TYPE.INT).init((t=>i.isNone(t)?0:t===c[i.get(t)]?1:0)),this.dataFrame.columns.getOrCreate(V.synSelectionColName,r.TYPE.STRING).init((t=>{if(i.isNone(t))return null;let e=null;return t===u[i.get(t)]&&(e=V.maxActivityLabel),s&&t===c[i.get(t)]&&(e=e?`${e}, ${V.maxConnectivityLabel}`:V.maxConnectivityLabel),e})),e.xColumnName=V.clusterSizeColName,e.yColumnName=this.activityColumnName,e.filter=this.scFilterQuery,this.viewerError="";const d=r.Viewer.scatterPlot(this.dataFrame,e);this.selectionSubscription&&this.selectionSubscription.unsubscribe(),this.selectionSubscription=d.onDataEvent.pipe((0,k.filter)((t=>"d4-select"==t.type))).subscribe((t=>{var e,n;const o=null!==(n=null===(e=t.bitset)||void 0===e?void 0:e.getSelectedIndexes())&&void 0!==n?n:[],s=this.dataFrame.selection,a=r.BitSet.create(this.dataFrame.rowCount,(t=>1==h.get(t)));a.and(s);for(let t=0;t<o.length;t++){const e=o[t],n=i.get(e);i.isNone(e)||(a.set(e,!0),null!=c[n]&&a.set(c[n],!0))}a.fireChanged();const l=a.getSelectedIndexes();for(const t of l){const e=i.get(t);null!=e&&null!=c[e]&&a.set(c[e],!0)}setTimeout((()=>{this.dataFrame.selection.copyFrom(a,!0),setTimeout((()=>{this.model&&this.model.createAccordion()}),200)}),200)}));const f=()=>{const t=r.BitSet.create(this.dataFrame.rowCount);Object.entries(u).forEach((([e,i])=>{var o;if(null==e||null==i)return;const r=parseInt(e),s=n.get(i),a=null!==(o=l[r])&&void 0!==o?o:l[e];s<this.activityThreshold&&a<this.clusterSizeThreshold||(t.set(i,!0,!1),null!=c[r]&&t.set(c[r],!0,!1))})),t.fireChanged(),this.dataFrame.selection.copyFrom(t,!0)};return this._selsectIcon=o.iconSvg("select-all",(()=>{f()}),"Select 3 Active quadrants"),this._selsectIcon.style.cursor="pointer",this._selsectIcon.style.marginRight="5px",f(),this.linesDrawSubscription&&this.linesDrawSubscription.unsubscribe(),this.linesDrawSubscription=d.onBeforeDrawScene.subscribe((()=>{const t=d.getInfo().canvas.getContext("2d"),e=d.viewport,n=d.worldToScreen(e.x,this.activityThreshold),i=d.worldToScreen(this.clusterSizeThreshold,e.y),o=d.worldToScreen(e.x+e.width,this.activityThreshold),r=d.worldToScreen(this.clusterSizeThreshold,e.y+e.height);t.beginPath(),t.strokeStyle="rgb(0,0,0)",t.lineWidth=1,t.moveTo(n.x,n.y),t.lineTo(o.x,o.y),t.moveTo(i.x,i.y),t.lineTo(r.x,r.y),t.stroke(),t.closePath()})),d}onTableAttached(){var t,e,n,i,o,r,s,a,l,u,c,h;super.onTableAttached();const d=null!==(e=null===(t=this.dataFrame)||void 0===t?void 0:t.col(m.$2.ACTIVITY))&&void 0!==e?e:null===(i=R()(null===(n=this.dataFrame)||void 0===n?void 0:n.columns.numerical).next())||void 0===i?void 0:i.value;null!=d&&(null===(o=this.getProperty(`activity${m.To}`))||void 0===o||o.set(this,d.name));const f=null===(s=R()(null===(r=this.dataFrame)||void 0===r?void 0:r.columns.categorical).next())||void 0===s?void 0:s.value;null!=f&&(null===(a=this.getProperty(`cluster${m.To}`))||void 0===a||a.set(this,f.name));const p=null===(u=R()(null===(l=this.dataFrame)||void 0===l?void 0:l.columns.numerical).next())||void 0===u?void 0:u.value;null!=p&&(null===(c=this.getProperty(`connectivity${m.To}`))||void 0===c||c.set(this,p.name)),this.render(),null===(h=this.dataFrame)||void 0===h||h.onDataChanged.subscribe((()=>{this.render()}))}render(){this.renderTimeout&&clearTimeout(this.renderTimeout),this.renderTimeout=setTimeout((()=>{var t,e;if(!this.dataFrame)return;l()(this.root).empty();const n=this.scViewer;if(null==n)return void this.root.appendChild(o.divText(null!==(t=this.viewerError)&&void 0!==t?t:"Error creating scatter plot"));const i=o.div("Cluster Size",{style:{alignSelf:"center",color:"var(--grey-6)",marginBottom:"5px"}}),r=o.div(this.activityTarget===m.wf.HIGH?"Maximum Activity":"Minimum Activity",{style:{color:"var(--grey-6)",alignSelf:"center",textOrientation:"mixed",writingMode:"tb",transform:"rotate(180deg)",marginLeft:"5px"}});n.props.colorColumnName=null!==(e=this.colorColumnName)&&void 0!==e?e:null,this.root.appendChild(o.divH([r,o.divV([o.divH([this._titleHost,this._selsectIcon],{style:{alignSelf:"center",lineHeight:"normal",width:"100%"}}),n.root,i],{style:{flexGrow:"1"}})])),n.root.style.width="100%",setTimeout((()=>{n.props.filter=this.scFilterQuery,n.invalidateCanvas()}),100)}),this.renderDebounceTime)}onPropertyChanged(t){super.onPropertyChanged(t),(null==t?void 0:t.name)!==`color${m.To}`&&(this._scViewer=null),this.render()}}V.clusterSizeColName="~cluster.size",V.maxActivityInClusterColName="~max.activity.for.cluster",V.maxConnectivityInClusterColName="~max.connectivity.for.cluster",V.synSelectionColName="Syn Selection",V.maxActivityLabel="Max Activity",V.maxConnectivityLabel="Max Connectivity";var F=n(3163);class D extends r.JsViewer{constructor(){super(),this.showPositionInfo=!0,this.positions=this.string("positions","1",{description:"Comma-separated sequence positions (1-based) to analyze"}),this.sequenceColumnName=this.column("sequence",{semType:r.SEMTYPE.MACROMOLECULE,nullable:!1}),this.valueColumnName=this.column("value",{columnTypeFilter:"numerical",nullable:!1}),this.showPositionInfo=this.bool("showPositionInfo",!0,{nullable:!1,defaultValue:!0,description:"Show position selector in the viewer header"}),this.subs.push(i.events.onContextMenu.subscribe((t=>{var e;t.causedBy&&t.causedBy.target&&(null===(e=this._boxPlotViewer)||void 0===e?void 0:e.root.contains(t.causedBy.target))&&(t.causedBy.preventDefault(),t.causedBy.stopPropagation(),t.causedBy.stopImmediatePropagation())})))}getPositionFromColumn(){var t;const e=this.dataFrame.col(this.sequenceColumnName);if(null==e)return 1;const n=null!==(t=e.getTag(g.gp.selectedPosition))&&void 0!==t?t:"1",i=parseInt(n);return Number.isNaN(i)?1:Math.max(1,i)}parsePositions(){if(!this.positions)return[1];const t=this.positions.split(",").map((t=>parseInt(t.trim()))).filter((t=>!Number.isNaN(t)&&t>=1));return[...new Set(t)].sort(((t,e)=>t-e))}_setPositions(t){const e=[...new Set(t)].sort(((t,e)=>t-e));this.getProperty("positions").set(this,e.join(", "))}onTableAttached(){if(super.onTableAttached(),null==this.dataFrame.columns.bySemType(r.SEMTYPE.MACROMOLECULE))throw i.shell.error("No sequence column found"),new Error("No sequence column found");const t=this.dataFrame.columns.getUnusedName("~sequence_position_monomers");this._positionColumn=this.dataFrame.columns.addNewString(t),this._positionColumn.semType="Monomer",this._positionColumn.setTag("cell.renderer","Monomer"),this.getProperty("sequenceColumnName").set(this,this.dataFrame.columns.bySemType(r.SEMTYPE.MACROMOLECULE).name),this.getProperty("valueColumnName").set(this,R()(this.dataFrame.columns.numerical).next().value.name),this.getProperty("positions").set(this,String(this.getPositionFromColumn())),this.subs.push(r.debounce(this.dataFrame.onMetadataChanged,200).subscribe((t=>{const e=this.getPositionFromColumn();this.parsePositions().includes(e)||this._setPositions([e])})))}render(){var t;const e=this.parsePositions();if(!(null!=this.dataFrame&&this.sequenceColumnName&&e.length&&this._positionColumn&&this.valueColumnName))return;l()(this.root).empty(),null===(t=this._boxPlotViewer)||void 0===t||t.detach();const n=c.Z.getSeqHelper(),i=this.dataFrame.col(this.sequenceColumnName),o=n.getSeqHandler(i),s=o.maxLength,a=e.map((t=>o.getMonomersAtPosition(t-1,!0)));if(this._positionColumn.init((t=>a.map((e=>e[t])).join(g.ot))),this._boxPlotViewer=this.dataFrame.plot.box({categoryColumnNames:[this._positionColumn.name],plotStyle:"violin",valueColumnName:this.valueColumnName,colorColumnName:this._positionColumn.name,showColorSelector:!1,showSizeSelector:!1,showCategorySelector:!1,legendVisibility:r.VisibilityMode.Never,markerColorColumnName:this._positionColumn.name,title:"Sequence Position Statistics",autoLayout:!1,labelOrientation:"Vert"}),this.showPositionInfo){const t=this._renderPositionSelector(e,s);this.root.appendChild(t)}this._boxPlotViewer.props.statistics=["min","max","avg","med","count"],this._boxPlotViewer.root.style.width="100%",this._boxPlotViewer.root.style.height="100%",this.root.appendChild(this._boxPlotViewer.root),this._boxPlotViewer.sub(this._boxPlotViewer.onPropertyValueChanged.subscribe((t=>{var e,n,i,o;if((null===(n=null===(e=this._boxPlotViewer)||void 0===e?void 0:e.props)||void 0===n?void 0:n.valueColumnName)&&(null===(o=null===(i=this._boxPlotViewer)||void 0===i?void 0:i.props)||void 0===o?void 0:o.valueColumnName)!==this.valueColumnName){const t=this._boxPlotViewer.props.valueColumnName;setTimeout((()=>this.getProperty("valueColumnName").set(this,t)),10)}})))}_renderPositionSelector(t,e){const n=o.divH([],{style:{alignItems:"center",justifyContent:"center",gap:"4px",flexWrap:"wrap",padding:"4px 8px",width:"100%"}}),i=o.label(`${this.sequenceColumnName}:`);i.style.fontWeight="bold",i.style.marginRight="4px",n.appendChild(i);for(const i of t)n.appendChild(this._createChip(i,t,e));return n.appendChild(this._createAddButton(n,t,e)),n}_createChip(t,e,n){const i=1===e.length,r=document.createElement("span");r.textContent=String(t),r.style.marginRight="3px";const s=i?o.iconFA("pencil",(()=>this._showInlineEdit(a,t,n)),"Edit position"):o.iconFA("times",(()=>this._setPositions(e.filter((e=>e!==t)))),"Remove position");s.style.cursor="pointer",s.style.fontSize="10px",s.style.opacity="0.6";const a=o.divH([r,s],{style:{display:"inline-flex",alignItems:"center",background:"#f0f0f0",borderRadius:"12px",padding:"2px 8px",fontSize:"12px",cursor:"default",border:"1px solid #d0d0d0"}});return a}_showInlineEdit(t,e,n){var i;const o=document.createElement("input");o.type="number",o.min="1",o.max=String(n),o.value=String(e),o.style.cssText="width:45px;height:22px;font-size:12px;text-align:center;border-radius:12px;border:1px solid #aaa;outline:none;padding:0 4px;";let r=!1;const s=()=>{if(r)return;r=!0;const i=parseInt(o.value),s=this.parsePositions();!Number.isNaN(i)&&i>=1&&i<=n&&i!==e?this._setPositions(s.map((t=>t===e?i:t))):o.replaceWith(t)};o.addEventListener("keydown",(e=>{var n;"Enter"===e.key&&s(),"Escape"===e.key&&(r=!0,null===(n=t.parentElement)||void 0===n||n.replaceChild(t,o))})),o.addEventListener("blur",s),null===(i=t.parentElement)||void 0===i||i.replaceChild(o,t),o.focus(),o.select()}_createAddButton(t,e,n){const i=o.iconFA("plus-circle",(()=>{if(t.querySelector(".position-add-input"))return;const o=document.createElement("input");o.type="number",o.min="1",o.max=String(n),o.className="position-add-input",o.style.cssText="width:45px;height:22px;font-size:12px;text-align:center;border-radius:12px;border:1px solid #aaa;outline:none;padding:0 4px;";let r=!1;const s=()=>{if(r)return;r=!0;const t=parseInt(o.value);!Number.isNaN(t)&&t>=1&&t<=n&&!e.includes(t)?this._setPositions([...e,t]):o.remove()};o.addEventListener("keydown",(t=>{"Enter"===t.key&&s(),"Escape"===t.key&&(r=!0,o.remove())})),o.addEventListener("blur",s),t.insertBefore(o,i),o.focus()}),"Add position");return i.style.cursor="pointer",i.style.fontSize="14px",i.style.color="#2083d5",i}onPropertyChanged(t){null!=this.dataFrame&&this.sequenceColumnName&&this.render()}}var G=n(7471),U=function(t,e,n,i){return new(n||(n=Promise))((function(o,r){function s(t){try{l(i.next(t))}catch(t){r(t)}}function a(t){try{l(i.throw(t))}catch(t){r(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(s,a)}l((i=i.apply(t,e||[])).next())}))};class q extends r.JsViewer{constructor(){super(),this.position=1,this.currentRowMutationsOnly=!1,this.yAxisType="Linear",this._mutationCliffsData=null,this._dfSubs=[],this._positionColumns=null,this._innerDf=null,this._lineChart=null,this._debounceTimer=null,this.sequenceColumnName=this.column("sequence",{semType:r.SEMTYPE.MACROMOLECULE,nullable:!1}),this.seriesColumnName=this.column("series",{columnTypeFilter:"categorical",nullable:!1}),this.activityColumnName=this.column("activity",{columnTypeFilter:"numerical",nullable:!1}),this.position=this.int("position",1,{nullable:!1,showSlider:!1,min:1,max:100,showPlusMinus:!0,description:"Position in the sequence to analyze (1 Based).",category:"Data"}),this.yAxisType=this.string("yAxisType","Linear",{choices:["Linear","Logarithmic"],description:"Y-Axis scale type.",nullable:!1,category:"Data"}),this.currentRowMutationsOnly=this.bool("currentRowMutationsOnly",!1,{nullable:!1,defaultValue:!1,description:"When enabled, the viewer will show mutations related to the peptide in current row in the dataframe and selected position.",category:"Data"}),this.root.classList.add("peptides-viewer-show-title")}onTableAttached(){var t,e;super.onTableAttached();const n=this.dataFrame.columns.bySemType(r.SEMTYPE.MACROMOLECULE);n&&this.getProperty("sequenceColumnName").set(this,n.name),this.getProperty("activityColumnName").set(this,R()(this.dataFrame.columns.numerical).next().value.name);const o=null===(e=null===(t=R()(this.dataFrame.columns.categorical))||void 0===t?void 0:t.filter((t=>{var e;return t.name!==this.sequenceColumnName&&(null===(e=t.name)||void 0===e?void 0:e.toLowerCase().includes("series"))})).next())||void 0===e?void 0:e.value;o&&this.getProperty("seriesColumnName").set(this,o.name),this.subs.push(r.debounce(this.dataFrame.onFilterChanged,200).subscribe((()=>{this.clearCache(),this.debouncedRender()}))),this.debouncedRender(),this.subs.push(i.events.onContextMenu.subscribe((t=>{var e;t.causedBy&&t.causedBy.target&&(null===(e=this._lineChart)||void 0===e?void 0:e.root.contains(t.causedBy.target))&&(t.causedBy.preventDefault(),t.causedBy.stopPropagation(),t.causedBy.stopImmediatePropagation())})))}get mutationCliffsData(){if(this._mutationCliffsData)return this._mutationCliffsData;if(!this.activityColumnName||!this.sequenceColumnName||!this.position)throw new Error("Activity column or Sequence column is not set, or position is invalid");return this._mutationCliffsData=new Promise(((t,e)=>U(this,void 0,void 0,(function*(){try{const e=this.dataFrame.col(this.activityColumnName).getRawData(),n=this.positionColumns,i=n[this.position-1].toList(),o=n.map(p.eY),r=yield(new G.a).calc(e,o,{maxMutations:1,minActivityDelta:0,filter:this.dataFrame.filter.anyFalse?new Uint32Array(this.dataFrame.filter.getBuffer().buffer):void 0,singlePosition:{position:this.position-1}});t({cliffs:r,monomers:i})}catch(t){e(t)}})))),this._mutationCliffsData}calculateDf(){return U(this,void 0,void 0,(function*(){if(!(this.dataFrame&&this.activityColumnName&&this.sequenceColumnName&&this.position))throw new Error("Activity column or Sequence column is not set, or position is invalid");const t=yield this.mutationCliffsData,e=new Set;t.cliffs.forEach((t=>{t.forEach((t=>{Array.from(t.entries()).forEach((([t,n])=>{const i=Number(t);this.currentRowMutationsOnly&&this.dataFrame.currentRowIdx!==i||(e.add(i),n.forEach((t=>e.add(Number(t)))))}))}))}));const n=Array.from(e.values()).sort(((t,e)=>t-e)),i=new Map;n.forEach(((t,e)=>{i.set(t,e)}));const o=n.map((e=>t.monomers[e])),s=this.dataFrame.col(this.activityColumnName).getRawData(),a=n.map((t=>s[t])),l=[r.Column.fromList("string",`Position ${this.position}`,o),r.Column.fromList("double",this.activityColumnName,a)];if(this.seriesColumnName){const t=this.dataFrame.col(this.seriesColumnName).getRawData(),e=this.dataFrame.col(this.seriesColumnName).categories,i=n.map((n=>e[t[n]])),o=r.Column.fromList("string",this.seriesColumnName,i);l.push(o)}const u=r.DataFrame.fromColumns(l);Array.from(this.dataFrame.columns.numerical).filter((t=>t.name!==this.activityColumnName&&t.name!==this.seriesColumnName)).forEach((t=>{u.columns.addNew(t.name,t.type)})),this._dfSubs.push(u.onMouseOverRowChanged.subscribe((t=>{if(u.mouseOverRowIdx>=0){const t=n[u.mouseOverRowIdx];this.dataFrame.mouseOverRowIdx=t}}))),this._dfSubs.push(this.dataFrame.onMouseOverRowChanged.subscribe((t=>{if(this.dataFrame.mouseOverRowIdx>=0){const t=i.get(this.dataFrame.mouseOverRowIdx);u.mouseOverRowIdx=null!=t?t:-1}})));let c=!1;this._dfSubs.push(u.onCurrentRowChanged.subscribe((t=>{if(u.currentRowIdx>=0){c=!0;const t=n[u.currentRowIdx];this.dataFrame.currentRowIdx=t}}))),this.currentRowMutationsOnly&&this._dfSubs.push(this.dataFrame.onCurrentRowChanged.subscribe((t=>{c?c=!1:(this.clearCache(!1),this.debouncedRender())})));let h=!1,d=!1;return this._dfSubs.push(r.debounce(u.onSelectionChanged,100).subscribe((t=>{const e=u.selection;if(h)h=!1;else if(d=!0,this.dataFrame.selection.setAll(!1,!1),e.anyTrue){for(let t=-1;-1!==(t=e.findNext(t,!0));){const e=n[t];this.dataFrame.selection.set(e,!0,!1)}this.dataFrame.selection.fireChanged()}else this.dataFrame.selection.fireChanged()}))),this._dfSubs.push(r.debounce(this.dataFrame.onSelectionChanged,100).subscribe((t=>{const e=this.dataFrame.selection;if(d)d=!1;else if(h=!0,u.selection.setAll(!1,!1),e.anyTrue){for(let t=-1;-1!==(t=e.findNext(t,!0));){const e=i.get(t);null!=e&&u.selection.set(e,!0,!1)}u.selection.fireChanged()}else u.selection.fireChanged()}))),u}))}get positionColumns(){if(this._positionColumns)return this._positionColumns;if(!this.dataFrame)return[];const t=u.i.getInstance(this.dataFrame),e=null==t?void 0:t.positionColumns;if(e&&e.length>0)return this._positionColumns=e,this._positionColumns;const n=this.dataFrame.col(this.sequenceColumnName),i=c.Z.getSeqHelper().getSeqHandler(n),o=i.maxLength,s=[];for(let t=0;t<o;t++){const e=i.getMonomersAtPosition(t,!0),n=r.Column.fromList("string",`Position ${t+1}`,e);s.push(n)}return this._positionColumns=s,this._positionColumns}get innerDf(){return this._innerDf?Promise.resolve(this._innerDf):(this._innerDf=this.calculateDf(),this._innerDf)}render(){return U(this,void 0,void 0,(function*(){if(l()(this.root).empty(),!(this.dataFrame&&this.activityColumnName&&this.sequenceColumnName&&this.position))return o.setUpdateIndicator(this.root,!1),void this.root.appendChild(B("Please set Activity column, Sequence column and Position properties."));if(this._lineChart){try{this._lineChart.detach()}catch(t){console.error("Error detaching previous line chart:",t)}this._lineChart=null}o.setUpdateIndicator(this.root,!0),this.root.style.display="flex",this.root.style.flexDirection="column";const t=yield this.innerDf;o.setUpdateIndicator(this.root,!1),0===t.rowCount?this.currentRowMutationsOnly?this.dataFrame.currentRowIdx>=0?this.root.appendChild(B("No mutations cliffs found for the current peptide at the selected position.")):this.root.appendChild(B("Please select a row in the main table to see mutation cliffs for the corresponding peptide at the selected position.")):this.root.appendChild(B("No mutation cliffs found for the selected position.")):(this._lineChart=t.plot.line({xColumnName:`Position ${this.position}`,yColumnNames:[this.activityColumnName],splitColumnNames:this.seriesColumnName?[this.seriesColumnName]:[],legendVisibility:this.seriesColumnName?"Always":"Never",legendPosition:"Right",showXSelector:!1,showYSelector:!0,showSplitSelector:!1,packCategories:!1,xAxisLabelOrientation:"Auto",axisFont:'normal normal 14px "Roboto"',controlsFont:'normal normal 14px "Roboto"'}),this._lineChart.sub(this._lineChart.onPropertyValueChanged.subscribe((t=>{var e,n,i,o,r,s,a,l;if((null===(n=null===(e=this._lineChart)||void 0===e?void 0:e.props)||void 0===n?void 0:n.yColumnNames)&&(null===(r=null===(o=null===(i=this._lineChart)||void 0===i?void 0:i.props)||void 0===o?void 0:o.yColumnNames)||void 0===r?void 0:r[0])!==this.activityColumnName){const t=null===(l=null===(a=null===(s=this._lineChart)||void 0===s?void 0:s.props)||void 0===a?void 0:a.yColumnNames)||void 0===l?void 0:l[0];setTimeout((()=>this.getProperty("activityColumnName").set(this,t)),1)}}))),this.root.appendChild(this._lineChart.root));const e=this.positionColumns.length+1,n=new Array(e-1).fill(0).map(((t,e)=>e+1)).map((t=>t.toString())),i=o.input.choice("Position",{value:this.position.toString(),items:n,nullable:!1,onValueChanged:t=>{if(!t)return;const e=parseInt(t);this.getProperty("position").set(this,e)}});if(i.input.style.width="40px",this.root.appendChild(o.divH([i.root],{style:{justifyContent:"center",marginTop:"4px",width:"100%",font:'normal normal 14px "Roboto"'}})),t.rowCount>0){const t=o.input.column("Series",{table:this.dataFrame,filter:t=>t.isCategorical&&t.name!==this.sequenceColumnName,tooltipText:"Select column for series splitting.",onValueChanged:t=>{const e=t?t.name:void 0;this.getProperty("seriesColumnName").set(this,e)},value:this.seriesColumnName?this.dataFrame.col(this.seriesColumnName):void 0});this.root.prepend(o.divH([t.root],{style:{justifyContent:"flex-end",paddingBottom:"4px",padding:"8px",width:"100%",font:'normal normal 14px "Roboto"'}}))}}))}debouncedRender(){o.setUpdateIndicator(this.root,!0),this._debounceTimer&&clearTimeout(this._debounceTimer),this._debounceTimer=setTimeout((()=>this.render()),300)}clearCache(t=!0){t&&(this._mutationCliffsData=null),this._innerDf=null,this._dfSubs.forEach((t=>t.unsubscribe())),this._dfSubs=[]}detach(){super.detach(),this._dfSubs.forEach((t=>t.unsubscribe())),this._dfSubs=[],clearTimeout(this._debounceTimer)}onPropertyChanged(t){if(super.onPropertyChanged(t),"activityColumnName"===(null==t?void 0:t.name)||"sequenceColumnName"===(null==t?void 0:t.name)||"position"===(null==t?void 0:t.name)||"seriesColumnName"===(null==t?void 0:t.name)){const e="seriesColumnName"===(null==t?void 0:t.name)||"activityColumnName"===(null==t?void 0:t.name);this.clearCache(!e),"sequenceColumnName"===(null==t?void 0:t.name)&&(this._positionColumns=null),this.debouncedRender()}else"yAxisType"===(null==t?void 0:t.name)?this._lineChart&&(this._lineChart.props.yAxisType=this.yAxisType.toLowerCase()):"currentRowMutationsOnly"===(null==t?void 0:t.name)&&(this.clearCache(!1),this.debouncedRender())}}function B(t){const e=o.divText(t);return e.style.fontSize="14px",e.style.marginTop="10px",e.style.textAlign="center",e}var H=function(t,e,n,i){return new(n||(n=Promise))((function(o,r){function s(t){try{l(i.next(t))}catch(t){r(t)}}function a(t){try{l(i.throw(t))}catch(t){r(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(s,a)}l((i=i.apply(t,e||[])).next())}))};function Y(){return H(this,void 0,void 0,(function*(){yield mt.initPeptides()}))}function j(){return mt.Peptides()}function W(){return mt.peptidesDialog()}function $(t){return H(this,void 0,void 0,(function*(){yield mt.testInitFunctionPeptides(t)}))}function z(t){return mt.peptidesPanel(t)}function K(){return mt.monomerPosition()}function Z(){return mt.mostPotentResidues()}function Q(){return mt.mutationCliffs()}function X(){return mt.logoSummaryTable()}function J(){return mt.sequencePositionStatistics()}function tt(){return mt.clusterMaxActivity()}function et(t){return mt.manualAlignment(t)}function nt(){return H(this,void 0,void 0,(function*(){yield mt.macromoleculeSarFastaDemo()}))}function it(){return mt.lstPiechartCellRenderer()}var ot=function(t,e,n,i){var o,r=arguments.length,s=r<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,i);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(r<3?o(s):r>3?o(e,n,s):o(e,n))||s);return r>3&&s&&Object.defineProperty(e,n,s),s},rt=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},st=function(t,e){return function(n,i){e(n,i,t)}},at=function(t,e,n,i){return new(n||(n=Promise))((function(o,r){function s(t){try{l(i.next(t))}catch(t){r(t)}}function a(t){try{l(i.throw(t))}catch(t){r(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(s,a)}l((i=i.apply(t,e||[])).next())}))};let lt,ut=null;const ct=new r.Package;function ht(){return ut}function dt(){return lt}function ft(t){return at(this,void 0,void 0,(function*(){const e=r.TaskBarProgressIndicator.create("Loading Peptides"),n=ct.webRoot+"files/"+t,o=yield i.data.loadTable(n);o.name="Peptides",i.shell.addTableView(o).name="PeptidesView",i.shell.windows.showProperties=!0,e.close()}))}i.decorators||(i.decorators={}),["func","init","param","panel","editor","demo","app","appTreeBrowser","fileHandler","fileExporter","model","viewer","filter","cellRenderer","autostart","dashboard","folderViewer","semTypeDetector","packageSettingsEditor","functionAnalysis","converter","fileViewer","model","treeBrowser","polyfill"].forEach((t=>{i.decorators[t]||(i.decorators[t]=function(t){return function(t,e,n){}})}));class mt{static initPeptides(){return at(this,void 0,void 0,(function*(){try{null!=ut||(ut=new f(yield i.functions.call("Bio:getBioLib"))),null!=lt||(lt=yield async function(){const t="Dendrogram",e=r.Func.find({package:t,name:"getTreeHelper"});if(0===e.length)throw new Error(`Package "${t}" must be installed for TreeHelper.`);return(await e[0].prepare().call()).getOutputParamValue()}()),yield c.Z.loadComponents()}catch(t){i.log.error(t)}}))}static Peptides(){const t=L.appHeader({iconPath:ct.getIconUrl(),learnMoreUrl:"https://github.com/datagrok-ai/public/blob/master/help/domains/bio/peptides.md",description:"- Automatically recognizes peptides in your data\n- Invariant map and mutation cliffs\n- Logo plots to explore sequence composition\n- Hierarchical clustering\n- Sequence space to analyze clustering and activity cliffs\n- Finds statistically significant changes in activity for monomer/positions\n"}),e=i.shell.windows;e.showToolbox=!1,e.showHelp=!1,e.showProperties=!1;const n=r.View.create();return n.name="Peptides",o.appendAll(n.root,[t,o.divH([o.button("Simple demo",(()=>ft("aligned.csv")),""),o.button("Complex demo",(()=>ft("aligned_2.csv")),""),o.button("HELM demo",(()=>ft("aligned_3.csv")),"")])]),n}static peptidesDialog(){var t;if(!i.shell.t||!(null===(t=i.shell.t.columns.bySemType("Macromolecule"))||void 0===t?void 0:t.length))return i.shell.warning("SAR Analysis requires an active table with Macromolecule column"),null;if(!r.Utils.firstOrNull(i.shell.t.columns.numerical))return i.shell.warning("SAR Analysis requires an active table with at least one numerical column for activity"),null;const e=(0,s.v)(i.shell.t),n=o.dialog("Analyze Peptides").add(e.host).onOK((()=>at(this,void 0,void 0,(function*(){e.callback()||n.show()}))));return n.show()}static testInitFunctionPeptides(t){return at(this,void 0,void 0,(function*(){i.shell.info("Test init function for Peptides package"),i.shell.info("Viewer name: "+t.dataFrame.name),yield new Promise((t=>setTimeout(t,1e3)))}))}static peptidesPanel(t){if(!t.dataFrame||!r.Utils.firstOrNull(t.dataFrame.columns.numerical))return new r.Widget(o.divText("SAR Analysis requires an active table with at least one numerical column for activity"));const e=(0,s.v)(t.dataFrame,t);return new r.Widget(e.host)}static monomerPosition(){return new h.J}static mostPotentResidues(){return new h.UJ}static mutationCliffs(){return new q}static logoSummaryTable(){return new d.s}static sequencePositionStatistics(){return new D}static clusterMaxActivity(){return new V}static manualAlignment(t){const e=i.shell.t,n=null==e?void 0:e.temp[u.i.modelName];return n?function(t,e){const n=o.input.textArea("",{value:t.get(e.currentRowIdx)});l()(n.root).addClass("pep-textinput");const s=o.button("Apply",(()=>{return o=this,r=void 0,a=function*(){const o=c.Z.getSeqHelper().getSeqHandler(t),r=n.value,s=o.splitter(r),a=e.currentRowIdx;t.set(a,r);for(let t=0;t<s.length;t++){const n=s.getCanonical(t);null!==e.col(t.toString())&&e.set(t.toString(),a,n)}const l=i.shell.o;i.shell.o=null,u.i.getInstance(e).updateGrid(),setTimeout((()=>{i.shell.o=l}),100)},new((s=void 0)||(s=Promise))((function(t,e){function n(t){try{l(a.next(t))}catch(t){e(t)}}function i(t){try{l(a.throw(t))}catch(t){e(t)}}function l(e){var o;e.done?t(e.value):(o=e.value,o instanceof s?o:new s((function(t){t(o)}))).then(n,i)}l((a=a.apply(o,r||[])).next())}));var o,r,s,a}),"Apply changes"),a=o.button(o.iconFA("redo"),(()=>n.value=t.get(e.currentRowIdx)),"Reset");return l()(a).addClass("pep-snippet-editor-icon pep-reset-icon"),new r.Widget(o.divV([a,n.root,s],"pep-textarea-box"))}(e.getCol(n.settings.sequenceColumnName),e):new r.Widget(o.divText("Manual alignment works with peptides analysis"))}static macromoleculeSarFastaDemo(){return at(this,void 0,void 0,(function*(){return yield function(){return t=this,e=void 0,o=function*(){i.shell.windows.showContextPanel=!0;const t=r.DataFrame.fromCsv(yield ct.files.readAsText("aligned.csv"));t.name="Simple peptides",t.id||(t.id=`Simple-peptides-analysis-table-id-${Math.random()}-${Date.now()}`);const e=i.shell.addTableView(t);yield r.delay(50);const n=e.grid;yield new Promise((t=>{var e;let i=null;const o=null===(e=null==n?void 0:n.onAfterDrawContent)||void 0===e?void 0:e.subscribe((()=>{i&&clearTimeout(i),o.unsubscribe(),t(void 0)}));i=setTimeout((()=>{o.unsubscribe(),t(void 0)}),3e3)}));const o=t.getCol("IC50"),a=t.getCol("AlignedSequence");a.semType=r.SEMTYPE.MACROMOLECULE,a.setTag(m.gp.ALPHABET,g.YI.PT),a.meta.units=g.Hi.FASTA,a.setTag(g.gp.aligned,"SEQ.MSA");const l=(0,p.Y1)(o,m.rg.MINUS_LG),u=new v.av;u.threshold=94,yield(0,s.n)(o,a,null,t,l,m.rg.MINUS_LG,{addMCL:!0,useEmbeddingsClusters:!0,mclSettings:u})},new((n=void 0)||(n=Promise))((function(i,r){function s(t){try{l(o.next(t))}catch(t){r(t)}}function a(t){try{l(o.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}l((o=o.apply(t,e||[])).next())}));var t,e,n,o}()}))}static lstPiechartCellRenderer(){return new F.DX}}ot([i.decorators.init({tags:["init"]}),rt("design:type",Function),rt("design:paramtypes",[]),rt("design:returntype",Promise)],mt,"initPeptides",null),ot([i.decorators.func(),rt("design:type",Function),rt("design:paramtypes",[]),rt("design:returntype",r.View)],mt,"Peptides",null),ot([i.decorators.func({"top-menu":"Bio | Analyze | SAR...",name:"Bio Peptides",outputs:[]}),rt("design:type",Function),rt("design:paramtypes",[]),rt("design:returntype",Object)],mt,"peptidesDialog",null),ot([i.decorators.func(),st(0,i.decorators.param({type:"viewer"})),rt("design:type",Function),rt("design:paramtypes",[r.Viewer]),rt("design:returntype",Promise)],mt,"testInitFunctionPeptides",null),ot([i.decorators.panel({name:"Peptides",meta:{role:"widgets"},tags:["widgets","panel"]}),st(0,i.decorators.param({options:{semType:"Macromolecule"}})),rt("design:type",Function),rt("design:paramtypes",[r.Column]),rt("design:returntype",r.Widget)],mt,"peptidesPanel",null),ot([i.decorators.func({meta:{icon:"files/icons/peptide-sar-viewer.svg",role:"viewer"},name:"Sequence Variability Map",tags:["viewer"],description:"Peptides Sequence Variability Map Viewer",outputs:[{type:"viewer",name:"result"}]}),rt("design:type",Function),rt("design:paramtypes",[]),rt("design:returntype",r.Viewer)],mt,"monomerPosition",null),ot([i.decorators.func({meta:{icon:"files/icons/peptide-sar-vertical-viewer.svg",role:"viewer"},name:"Most Potent Residues",tags:["viewer"],description:"Peptides Most Potent Residues Viewer",outputs:[{type:"viewer",name:"result"}]}),rt("design:type",Function),rt("design:paramtypes",[]),rt("design:returntype",r.Viewer)],mt,"mostPotentResidues",null),ot([i.decorators.func({meta:{icon:"files/icons/sequence-statistics-viewer.svg",role:"viewer"},name:"Sequence Mutation Cliffs",description:"Mutation Cliffs Line Chart",tags:["viewer"],outputs:[{type:"viewer",name:"result"}]}),rt("design:type",Function),rt("design:paramtypes",[]),rt("design:returntype",r.Viewer)],mt,"mutationCliffs",null),ot([i.decorators.func({meta:{icon:"files/icons/logo-summary-viewer.svg",role:"viewer"},name:"Logo Summary Table",tags:["viewer"],outputs:[{type:"viewer",name:"result"}]}),rt("design:type",Function),rt("design:paramtypes",[]),rt("design:returntype",r.Viewer)],mt,"logoSummaryTable",null),ot([i.decorators.func({meta:{icon:"files/icons/sequence-statistics-viewer.svg",role:"viewer"},name:"Sequence Position Statistics",outputs:[{type:"viewer",name:"result"}],tags:["viewer"]}),rt("design:type",Function),rt("design:paramtypes",[]),rt("design:returntype",r.Viewer)],mt,"sequencePositionStatistics",null),ot([i.decorators.func({name:"Active peptide selection",outputs:[{type:"viewer",name:"result"}],meta:{role:"viewer"},tags:["viewer"]}),rt("design:type",Function),rt("design:paramtypes",[]),rt("design:returntype",r.Viewer)],mt,"clusterMaxActivity",null),ot([i.decorators.panel({name:"Manual Alignment",meta:{role:"widgets"},tags:["widgets","panel"]}),st(0,i.decorators.param({options:{semType:"Monomer"}})),rt("design:type",Function),rt("design:paramtypes",[String]),rt("design:returntype",r.Widget)],mt,"manualAlignment",null),ot([i.decorators.func({meta:{demoPath:"Bioinformatics | Peptide SAR",isDemoDashboard:"true"},name:"Peptide SAR",description:"Peptide SAR Analysis demo on peptide sequences in FASTA format"}),rt("design:type",Function),rt("design:paramtypes",[]),rt("design:returntype",Promise)],mt,"macromoleculeSarFastaDemo",null),ot([i.decorators.func({meta:{cellType:"lst-pie-chart",gridChart:"true",role:"cellRenderer"},tags:["cellRenderer"],name:"LST Pie Chart",outputs:[{type:"grid_cell_renderer",name:"result"}]}),rt("design:type",Function),rt("design:paramtypes",[]),rt("design:returntype",r.GridCellRenderer)],mt,"lstPiechartCellRenderer",null)},726:(t,e,n)=>{"use strict";n.d(e,{Z:()=>s});var i=n(4971),o=n(6082),r=function(t,e,n,i){return new(n||(n=Promise))((function(o,r){function s(t){try{l(i.next(t))}catch(t){r(t)}}function a(t){try{l(i.throw(t))}catch(t){r(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(s,a)}l((i=i.apply(t,e||[])).next())}))};class s{static getMonomerLib(){if(!this._monomerLibHelper)throw new Error("MonomerLib is not initialized");return this._monomerLibHelper.getMonomerLib()}static getSeqHelper(){if(!this._secHelper)throw new Error("SeqHelper is not initialized");return this._secHelper}static loadSeqHelper(){return r(this,void 0,void 0,(function*(){var t;null!==(t=this._secHelper)&&void 0!==t||(this._secHelper=yield async function(){const t=o.Func.find({package:"Bio",name:"getSeqHelper"});if(0===t.length)throw new Error("Package 'Bio' must be installed for SeqHelper.");return(await t[0].prepare().call()).getOutputParamValue()}())}))}static loadComponents(){return r(this,void 0,void 0,(function*(){yield this.loadSeqHelper(),yield this.loadMonomerLib()}))}static loadMonomerLib(){return r(this,void 0,void 0,(function*(){var t;null!==(t=this._monomerLibHelper)&&void 0!==t||(this._monomerLibHelper=yield(0,i.pj)()),yield this._monomerLibHelper.awaitLoaded()}))}}},1458:(t,e,n)=>{"use strict";n.d(e,{Ej:()=>h,Lw:()=>c,eW:()=>f,uz:()=>u});var i=n(4139),o=n(7471),r=n(5480),s=n(8774),a=n(5070),l=function(t,e,n,i){return new(n||(n=Promise))((function(o,r){function s(t){try{l(i.next(t))}catch(t){r(t)}}function a(t){try{l(i.throw(t))}catch(t){r(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(s,a)}l((i=i.apply(t,e||[])).next())}))};function u(t,e){return l(this,arguments,void 0,(function*(t,e,n={}){var r,s;if(0===e.length)throw new Error(`PepAlgorithmError: Couldn't find any column of semType '${i.uF.MONOMER}'`);null!==(r=n.minActivityDelta)&&void 0!==r||(n.minActivityDelta=0),null!==(s=n.maxMutations)&&void 0!==s||(n.maxMutations=1);const a=new o.a,l=yield a.calc(t,e,n);return a.terminate(),l}))}function c(t,e){const n=new Map;let i=999999,o=-999999,r=2,l=2;for(const u of t.keys()){const c=new Map;n.set(u,c);const h=t.get(u);for(const t of h.keys()){const n=h.get(t);if(0===n.size)continue;const u=new s.A(e.length,!1),d=new s.A(e.length,!1);for(const t of n.keys())u.setFast(t,!0),n.get(t).forEach((t=>u.setFast(t,!0))),d.setFast(t,!0);const f=(0,a.GT)(e,d,u);f.mask=u,i=Math.min(i,f.meanDifference),o=Math.max(o,f.meanDifference),r=Math.min(r,f.count),l=Math.max(l,f.count),c.set(t,f)}}return{stats:n,minDiff:i,maxDiff:o,minCount:r,maxCount:l}}function h(t,e,n,i={}){var o,r;null!==(o=i.isFiltered)&&void 0!==o||(i.isFiltered=!1);const l={general:{}},u=t.getRawData(),c=t.length;null!==(r=i.columns)&&void 0!==r||(i.columns=n.map((t=>t.name)));const h=i.isFiltered?(0,a.pY)(e):void 0;for(const t of n){if(!i.columns.includes(t.name))continue;const n=t.getRawData(),o=t.categories,r={general:{}};for(let t=0;t<o.length;++t){const l=o[t];if(""===l)continue;const f=new Array(c).fill(!1);for(let o=0;o<c;++o)n[o]!==t||i.isFiltered&&!e.get(o)||(f[o]=!0);const m=s.A.fromValues(f);if(m.allFalse)continue;const p=(0,a.GT)(u,m,h,i.aggValue);r[l]=p,d(r.general,p)}l[t.name]=r,d(l.general,null,r.general)}return l}function d(t,e=null,n=null){var i,o,r,s,a,l,u,c,h,d,f,m,p,g,v,C,y;if(null===e&&null===n)throw new Error("MonomerPositionStatsError: either stats or summaryStats must be present");const w=null!==(i=null==e?void 0:e.count)&&void 0!==i?i:n.maxCount;null!==(o=t.maxCount)&&void 0!==o||(t.maxCount=w),t.maxCount<w&&(t.maxCount=w);const b=null!==(r=null==e?void 0:e.count)&&void 0!==r?r:n.minCount;null!==(s=t.minCount)&&void 0!==s||(t.minCount=b),t.minCount>b&&(t.minCount=b);const A=null!==(a=null==e?void 0:e.meanDifference)&&void 0!==a?a:n.maxMeanDifference;null!==(l=t.maxMeanDifference)&&void 0!==l||(t.maxMeanDifference=A),t.maxMeanDifference<A&&(t.maxMeanDifference=A);const S=null!==(u=null==e?void 0:e.meanDifference)&&void 0!==u?u:n.minMeanDifference;if(null!==(c=t.minMeanDifference)&&void 0!==c||(t.minMeanDifference=S),t.minMeanDifference>S&&(t.minMeanDifference=S),!isNaN(null!==(h=null==e?void 0:e.pValue)&&void 0!==h?h:NaN)){const i=null!==(d=null==e?void 0:e.pValue)&&void 0!==d?d:n.maxPValue;null!==(f=t.maxPValue)&&void 0!==f||(t.maxPValue=i),t.maxPValue<i&&(t.maxPValue=i);const o=null!==(m=null==e?void 0:e.pValue)&&void 0!==m?m:n.minPValue;null!==(p=t.minPValue)&&void 0!==p||(t.minPValue=o),t.minPValue>o&&(t.minPValue=o)}const T=null!==(g=null==e?void 0:e.ratio)&&void 0!==g?g:n.maxRatio;null!==(v=t.maxRatio)&&void 0!==v||(t.maxRatio=T),t.maxRatio<T&&(t.maxRatio=T);const E=null!==(C=null==e?void 0:e.ratio)&&void 0!==C?C:n.minRatio;null!==(y=t.minRatio)&&void 0!==y||(t.minRatio=E),t.minRatio>E&&(t.minRatio=E)}function f(t,e,n,i){const o=t.rowCount,l=t.getCol(e),u=l.getRawData(),c=l.categories,h=Array.from({length:c.length},(()=>new s.A(o,!1)));for(let t=0;t<o;++t)h[u[t]].setTrue(t);const d=n.map((t=>s.A.fromUint32Array(o,t.getRawData()))),f=n.map((t=>t.name)),m=i.getRawData(),p={},g={},v=t.filter.anyFalse?(0,a.pY)(t.filter):void 0;for(const t of Object.values(r.W)){const e=t===r.W.ORIGINAL?h:d,n=t===r.W.ORIGINAL?c:f,o=t===r.W.ORIGINAL?p:g;for(let t=0;t<e.length;++t){const r=e[t];o[n[t]]=r.allTrue||r.allFalse?{count:r.length,meanDifference:0,ratio:1,pValue:null,mask:r,mean:i.stats.avg}:(0,a.GT)(m,r,v)}}const C={};return C[r.W.ORIGINAL]=p,C[r.W.CUSTOM]=g,C}},3163:(t,e,n)=>{"use strict";n.d(e,{DX:()=>S,X5:()=>v,rW:()=>w,k8:()=>b,Yd:()=>y,rI:()=>C,FZ:()=>A});var i=n(7389),o=n(6082),r=n(4139),s=n(2003),a=n(1458);const l=rxjs;var u=n(912),c=n(5480),h=n(3541);n(7194);var d,f,m;!function(t){t.maxMonomerLength=".mm.cellRenderer.maxMonomerLength"}(d||(d={})),function(t){t.applyToBackground=".m.cellRenderer.applyToBackground"}(f||(f={})),function(t){t.MSA="MSA",t.classic="classic"}(m||(m={})),new class{constructor(){this.color="rgb(100,100,100)",this.pivot=0,this.left=!1,this.transparencyRate=0,this.separator="",this.last=!1,this.drawStyle=m.classic,this.maxWord=[],this.wordIdx=0,this.gridCell=null,this.referenceSequence=null,this.maxLengthOfMonomer=null,this.monomerTextSizeMap={},this.logger=void 0,this.selectedPosition=void 0,this.isMultiLineContext=!1,this.lineNumber=0}};var p=n(726),g=n(3981);function v(t,e){t.strokeStyle=o.Color.toHtml(o.Color.selectedRows),t.lineWidth=3,t.strokeRect(e.x+1,e.y+1,e.width-1,e.height-1)}function C(t,e,n){t.semType=r.uF.MONOMER,t.setTag(o.TAGS.CELL_RENDERER,r.uF.MONOMER),t.setTag(r.gp.ALPHABET,e),n&&t.setTag(f.applyToBackground,"true")}function y(t,e,n,i,r){var s,a,l,u,c,d,f,m,p,g;const C=r.width/2,y=Math.ceil(r.x+1+C),w=Math.ceil(r.y+1+r.height/2),b=Math.min(.9*C/2,.9*r.height/2);if(i instanceof h.UJ){const r=i.monomerPositionStats[n],s=r[e].pValue,a=r[e].meanDifference,l=1-r.general.maxPValue,u=1-r.general.minPValue,c=Math.min(l,u),h=l-c,d=u-c,f=Math.max(h,d),m=null===s?0:1-s-c,p=a>=0?m:-m,g=o.Color.toHtml(null===s?o.Color.lightLightGray:o.Color.scaleColor(p,-f,f,255)),v=Math.max(Math.abs(i.monomerPositionStats.general.minMeanDifference),i.monomerPositionStats.general.maxMeanDifference),A=Math.abs(a)/v,S=Math.floor(b*A);t.beginPath(),t.fillStyle=g,t.arc(y-C/2,w,S<3||null===s?3:S,0,2*Math.PI,!0),t.closePath(),t.fill()}else if(i instanceof h.J&&i.mutationCliffs&&i.cliffStats){const r=i.cliffStats.maxCount,u=i.cliffStats.minDiff,c=i.cliffStats.maxDiff,h=null===(l=null===(a=null===(s=i.cliffStats)||void 0===s?void 0:s.stats)||void 0===a?void 0:a.get(e))||void 0===l?void 0:l.get(n);if(h){const e=h.count,n=h.meanDifference,i=Math.floor(Math.abs(e/Math.max(r,2))*b),s=Math.max(Math.abs(u),Math.abs(c)),a=o.Color.toHtml(null===n?o.Color.lightLightGray:o.Color.scaleColor(n,-s,s,255));t.beginPath(),t.fillStyle=a,t.arc(y-C/2,w,i<3||0==e?3:i,0,2*Math.PI,!0),t.closePath(),t.fill()}}if(t.textBaseline="middle",t.textAlign="end",t.fillStyle="#606060",t.font="13px Roboto, Roboto Local, sans-serif",t.shadowBlur=5,t.shadowColor=o.Color.toHtml(o.Color.white),i instanceof h.J){let o=0;const r=null!==(f=null===(d=null===(c=null===(u=i.mutationCliffs)||void 0===u?void 0:u.get(e))||void 0===c?void 0:c.get(n))||void 0===d?void 0:d.entries())&&void 0!==f?f:null;if(null!==r)for(const[t,e]of r)o+=null!==(m=e.length)&&void 0!==m?m:0;0!==o&&t.fillText(o.toString(),y+C-5,w,C-5)}else if(i instanceof h.UJ){const o=i.monomerPositionStats,r=null===(g=null===(p=null==o?void 0:o[n])||void 0===p?void 0:p[e])||void 0===g?void 0:g.count;r&&t.fillText(r.toString(),y+C-5,w,C-5)}if(i instanceof h.J){const o=i.mutationCliffsSelection[n];o&&o.includes(e)&&v(t,r)}else if(i instanceof h.UJ){const o=i.invariantMapSelection[n];o&&o.includes(e)&&v(t,r)}}function w(t,e,n,i,r,s,a){a=o.Color.fromHtml(o.Color.toHtml(function(t,e){return(16777215&t|255<<24)>>>0}(a)));let l=r.toFixed(2);l.endsWith(".00")&&(l=r.toFixed(0)),l.endsWith("0")&&l.includes(".")&&(l=r.toFixed(1));const u=Math.min(13,Math.floor(s.width/40/l.length*6*13));t.fillStyle=o.Color.toHtml(a),t.fillRect(s.x,s.y,s.width,s.height),t.font=`${u}px Roboto, Roboto Local, sans-serif`,t.textAlign="center",t.textBaseline="middle",t.fillStyle=o.Color.toHtml(o.Color.getContrastColor(a)),t.fillText(l,s.x+s.width/2,s.y+s.height/2,s.width);const c=i[n];c&&c.includes(e)&&v(t,s)}function b(t,e,n,i){t.font="13px Roboto, Roboto Local, sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillStyle="#000",t.fillText(e.toString(),i.x+i.width/2,i.y+i.height/2,i.width),(n[c.W.CUSTOM].includes(e)||n[c.W.ORIGINAL].includes(e))&&v(t,i)}function A(t,e,n,c,h,d={x:0,y:0,mpStats:{},monomerPosition:{}}){var f;if(null!==(f=h.isSelectionTable)&&void 0!==f||(h.isSelectionTable=!1),0==Object.keys(d.mpStats).length&&(d.mpStats=e),h.isSelectionTable&&(!h.webLogoBounds||!h.cachedWebLogoTooltip))throw new Error("Peptides: Cannot set WebLogo renderer for selection table without `headerSelectedMonomers`, `webLogoBounds` and `cachedWebLogoTooltip` options.");const m=t.dataFrame;t.setOptions({colHeaderHeight:130});t.onCellRender.subscribe((t=>(t=>{var i,l,u,d;if(!(null===(i=t.cell)||void 0===i?void 0:i.isColHeader))return;const f=t.g,v=t.bounds,C=t.cell.tableColumn;f.save();try{if(f.beginPath(),f.clearRect(v.x,v.y,v.width,v.height),f.rect(v.x,v.y,v.width,v.height),f.clip(),(null==C?void 0:C.semType)===r.uF.MONOMER){let i;if(m.filter.anyFalse){null!==(l=(d=m).jsOnlyTemp)&&void 0!==l||(d.jsOnlyTemp={});const t=null!==(u=m.jsOnlyTemp[r.gp.M_P_STATS_CACHE])&&void 0!==u?u:{},e=null==t?void 0:t[C.name];if(t&&e&&e.filterLength===m.filter.length&&e.filterVersion===m.filter.version)i=e.stats[C.name];else{const e=(0,a.Ej)(c,m.filter,n,{isFiltered:!0,columns:[C.name]});i=e[C.name],t[C.name]={filterVersion:m.filter.version,stats:e,filterLength:m.selection.length}}m.jsOnlyTemp[r.gp.M_P_STATS_CACHE]=t}else i=h.isSelectionTable?(0,a.Ej)(c,m.filter,n,{isFiltered:!0,columns:[C.name]})[C.name]:e[C.name];if(!i)return;const y=Object.keys(i).sort(((t,e)=>""===t||"-"===t?1:""===e||"-"===e?-1:0)).filter((t=>"general"!==t));h.webLogoBounds()[C.name]=function(t,e,n,i,r,a,l,u={},c={}){var h,d,f,m,v,C,y,w,b;const A=window.devicePixelRatio;null!==(h=c.symbolStyle)&&void 0!==h||(c.symbolStyle="16px Roboto, Roboto Local, sans-serif"),null!==(d=c.upperLetterHeight)&&void 0!==d||(c.upperLetterHeight=12.2),null!==(f=c.upperLetterAscent)&&void 0!==f||(c.upperLetterAscent=.25),null!==(m=c.marginVertical)&&void 0!==m||(c.marginVertical=1),null!==(v=c.marginHorizontal)&&void 0!==v||(c.marginHorizontal=1),null!==(C=c.selectionWidth)&&void 0!==C||(c.selectionWidth=2),null!==(y=c.textHeight)&&void 0!==y||(c.textHeight=13),null!==(w=c.headerStyle)&&void 0!==w||(c.headerStyle=`bold ${c.textHeight*A}px Roboto, Roboto Local, sans-serif`);const S=(r.length-1)*c.upperLetterAscent;let T=(e.y+c.marginVertical)*A;const E=(e.height-2*c.marginVertical-S-1.25*c.textHeight)*A,_=(e.x+c.marginHorizontal)*A,N=Math.max(c.selectionWidth*A,.05*e.width*A),x=2*c.marginHorizontal+c.selectionWidth,M=(e.width-(x+c.marginHorizontal))*A,I=(e.x+x)*A,O=p.Z.getMonomerLib(),L={};for(const e of r){const i=E*(n[e].count/a),r=E*((null!==(b=u[e])&&void 0!==b?b:0)/a);if(L[e]=new o.Rect(I/A,T/A,M/A,i/A),t.resetTransform(),"-"!==e&&""!==e){const n=(0,s.zS)(e,5),a=t.measureText(n);r>0&&(t.lineWidth=N,t.line(_,T,_,T+r,o.Color.rowSelection));const l=O.getMonomerTextColor(g.o.AA,e);t.fillStyle=l,t.textAlign="left",t.textBaseline="top",t.font=c.symbolStyle;const u=M/a.width,h=i/c.upperLetterHeight;t.setTransform(u,0,0,h,I,T),t.fillText(n,0,0,a.width)}T+=i+c.upperLetterAscent*A}return t.resetTransform(),t.fillStyle=o.Color.toHtml(o.Color.black),t.textAlign="center",t.textBaseline="top",t.font=c.headerStyle,t.fillText(i,(e.x+e.width/2)*A,(e.y+e.height-c.textHeight)*A),L}(f,v,i,C.name,y,m.filter.trueCount,h.colorPalette(),h.headerSelectedMonomers?h.headerSelectedMonomers()[C.name]:{}),t.preventDefault()}}catch(t){console.warn(`PeptidesHeaderLogoError: couldn't render WebLogo for column \`${C.name}\`. See original error below.`),console.warn(t)}finally{f.restore()}})(t)));const v=n=>{var o;const s=t.hitTest(n.offsetX,n.offsetY);if((null==s?void 0:s.isColHeader)&&(null===(o=s.tableColumn)||void 0===o?void 0:o.semType)===r.uF.MONOMER){const t=function(t,e,n){const i=n[t.tableColumn.name];if(!i)return null;for(const[n,o]of Object.entries(i)){const i=e.offsetX>=o.x&&e.offsetX<=o.x+o.width,r=e.offsetY>=o.y&&e.offsetY<=o.y+o.height;if(i&&r)return{monomerOrCluster:n,positionOrClusterType:t.tableColumn.name}}return null}(s,n,h.webLogoBounds());if(null===t)return void(h.isSelectionTable||null==h.unhighlightCallback||h.unhighlightCallback());d.monomerPosition=t;const o=m.filter.anyFalse?m.clone(m.filter):m,r=o.getCol(c.name);!function(t,e,n,o,r,s){if("click"!==t.type||r.isSelectionTable||null==r.selectionCallback){const a=`${e.positionOrClusterType} = ${e.monomerOrCluster}`;r.cachedWebLogoTooltip().bar===a?i.tooltip.show(r.cachedWebLogoTooltip().tooltip,t.clientX,t.clientY):(r.cachedWebLogoTooltip().bar=a,s.x=t.clientX,s.y=t.clientY,s.monomerPosition=e,r.cachedWebLogoTooltip().tooltip=(0,u.Y)(n,o,[],s))}else r.selectionCallback(e,{shiftPressed:t.shiftKey,ctrlPressed:t.ctrlKey})}(n,t,o,r,h,d),h.isSelectionTable||null==h.highlightCallback||h.highlightCallback(t,m,e)}else null!=h.unhighlightCallback&&h.unhighlightCallback()};l.fromEvent(t.overlay,"mousemove").subscribe((t=>v(t))),l.fromEvent(t.overlay,"click").subscribe((t=>v(t))),l.fromEvent(t.overlay,"mouseleave").subscribe((()=>{null!=h.unhighlightCallback&&h.unhighlightCallback()}))}class S extends o.GridCellRenderer{constructor(){super(...arguments),this.colorCacheKey="lst-pie-chart-color-cache",this.HoverTempKey="lst-pie-chart-hovered-sector",this.hoverSeparator=",,,,,"}get name(){return"LST Pie Chart"}get cellType(){return"lst-pie-chart"}get defaultWidth(){return 80}get defaultHeight(){return 80}categoryNumberCache(t){return t.temp[this.colorCacheKey]||(t.temp[this.colorCacheKey]={}),t.temp[this.colorCacheKey]}getPrevHoveredSector(t){return t.temp[this.HoverTempKey]}onMouseMove(t,e){const n=this.getPrevHoveredSector(t.cell.column),o=()=>{t.cell.column.temp[this.HoverTempKey]=null,i.tooltip.hide(),null!==n&&t.grid.invalidate()},r=t.cell.value;if(!r)return void o();const s=e.offsetX-t.bounds.midX,a=e.offsetY-t.bounds.midY,l=Math.sqrt(s*s+a*a),u=Math.atan2(a,s),c=u<0?u+2*Math.PI:u;if(l>Math.min(t.bounds.width,t.bounds.height)/2-2)return void o();let h;try{h=JSON.parse(r)}catch(e){return void o()}const d=new Float64Array(Object.keys(h).length+1),f=Object.values(h).reduce(((t,e)=>t+e),0);d[Object.keys(h).length]=2*Math.PI;let m=0,p=0;for(const t of Object.values(h))d[p++]=m,m+=2*Math.PI*t/f;let g=-1;for(let t=0;t<d.length-1;t++)if(c>=d[t]&&c<d[t+1]){g=t;break}if(-1===g)return void o();const v=Object.keys(h)[g],C=h[v],y=(C/f*100).toFixed(2);i.tooltip.show(i.h1(`${v}: ${C} (${y}%)`),e.x+16,e.y+16);const w=t.cell.rowIndex.toString()+this.hoverSeparator+v;t.cell.column.temp[this.HoverTempKey]=w,n!==w&&t.grid.invalidate()}render(t,e,n,i,r,s,a){const l=s.cell.dataFrame,u=new o.Rect(e,n,i,r).fitSquare().inflate(-2,-2);if(i<5||r<5||!l)return;const c=s.cell.value;if(t.clearRect(e,n,i,r),!c)return;let h;try{h=JSON.parse(c)}catch(t){return}const d=Object.values(h).reduce(((t,e)=>t+e),0);let f=0;const m=Object.fromEntries(Object.keys(h).map((t=>[t,255]))),p=s.cell.column.temp[this.HoverTempKey];if(p&&2===p.split(this.hoverSeparator).length){const[t,e]=p.split(this.hoverSeparator);if(t===s.cell.rowIndex.toString()){for(const[t,e]of Object.entries(h))m[t]=100;m[e]=255}}const g=Math.min(i,r)/2.2;for(const[e,n]of Object.entries(h)){const i=2*Math.PI*n/d;t.beginPath(),t.moveTo(u.midX,u.midY),t.arc(u.midX,u.midY,g,f,f+i),f+=i;const r=this.categoryNumberCache(s.cell.column);r[e]||(r[e]=Object.keys(r).length,s.cell.column.temp[this.colorCacheKey]=r),t.fillStyle=o.Color.toHtml(o.Color.setAlpha(o.Color.getCategoricalColor(r[e]),m[e])),t.fill(),t.strokeStyle=o.Color.toRgb(o.Color.lightGray),t.stroke();const a=e;t.fillStyle=o.Color.toRgb(o.Color.white),t.font="9px Arial";const l=t.measureText(a).width,c=f-i/2;for(let e=.8;e>=.4;e-=.05){const n=g*e,o=u.midX+Math.cos(c)*n,r=u.midY+Math.sin(c)*n;if([[o-l/2-2,r],[o+l/2+2,r]].every((t=>{const e=Math.sqrt(Math.pow(t[0]-u.midX,2)+Math.pow(t[1]-u.midY,2)),n=Math.atan2(t[1]-u.midY,t[0]-u.midX),o=n<0?n+2*Math.PI:n;return e<g-2&&o>f-i&&o<f}))){t.fillText(a,o,r);break}}}}}},4139:(t,e,n)=>{"use strict";n.d(e,{$2:()=>i,To:()=>l,V5:()=>d,gp:()=>r,i6:()=>o,rg:()=>u,uF:()=>s,wf:()=>c,zW:()=>f});var i,o,r,s,a=n(6082);!function(t){t.SPLIT_COL="~split",t.ACTIVITY="Activity",t.ACTIVITY_SCALED="Scaled activity",t.MONOMER="AAR",t.POSITION="Pos",t.P_VALUE="pValue",t.MEAN_DIFFERENCE="Mean difference",t.COUNT="Count",t.RATIO="Ratio",t.MEAN="Mean",t.TOTAL_COUNT="∑"}(i||(i={})),function(t){t.MEMBERS="Members",t.WEB_LOGO="WebLogo",t.DISTRIBUTION="Distribution",t.MEAN_DIFFERENCE="Mean difference",t.P_VALUE="P-Value",t.RATIO="Ratio",t.CLUSTER="Cluster"}(o||(o={})),function(t){t.MONOMER="monomer",t.POSITION="pos",t.SEPARATOR="separator",t.ALPHABET="alphabet",t.FILTER="filter",t.SAR_MODE="sarMode",t.VISIBLE="visible",t.SETTINGS="settings",t.CUSTOM_CLUSTER="customCluster",t.MONOMER_POSITION_MODE="monomerPositionMode",t.MULTIPLE_VIEWS="isMultipleViews",t.IDENTITY_TEMPLATE="Identity template",t.SIMILARITY_TEMPLATE="Similarity template",t.ANALYSIS_COL="isAnalysisCol",t.POSITION_COL="isPositionCol",t.M_P_STATS_CACHE=".MPStatsCache",t.INVARIANT_MAP_COLOR_CACHE=".InvariantMapColorCache",t.INVARIANT_MAP_COLOR_MAX_CACHE=".InvariantMapColorMaxCache",t.INVARIANT_MAP_COLOR_MIN_CACHE=".InvariantMapColorMinCache"}(r||(r={})),function(t){t.MONOMER="Monomer",t.MACROMOLECULE_DIFFERENCE="MacromoleculeDifference"}(s||(s={}));const l="ColumnName";var u,c,h;!function(t){t.NONE="none",t.LG="lg",t.MINUS_LG="-lg"}(u||(u={})),function(t){t.HIGH="High",t.LOW="Low"}(c||(c={})),function(t){t.LST="lst-",t.MP="mp-",t.MPR="mpr-",t.WL="wl-"}(h||(h={}));const d=Object.values(a.AGG).filter((t=>![a.AGG.FIRST,a.AGG.KEY,a.AGG.PIVOT,a.AGG.SELECTED_ROWS_COUNT].includes(t))),f={[a.AGG.TOTAL_COUNT]:"totalCount",[a.AGG.VALUE_COUNT]:"valueCount",[a.AGG.UNIQUE_COUNT]:"uniqueCount",[a.AGG.MISSING_VALUE_COUNT]:"missingValueCount",[a.AGG.MIN]:"min",[a.AGG.MAX]:"max",[a.AGG.SUM]:"sum",[a.AGG.MED]:"med",[a.AGG.AVG]:"avg",[a.AGG.STDEV]:"stdev",[a.AGG.VARIANCE]:"variance",[a.AGG.SKEW]:"skew",[a.AGG.KURT]:"kurt",[a.AGG.Q1]:"q1",[a.AGG.Q2]:"q2",[a.AGG.Q3]:"q3"}},8608:(t,e,n)=>{"use strict";n.d(e,{$s:()=>_,AN:()=>i,AY:()=>d,B2:()=>x,BE:()=>w,BX:()=>O,CD:()=>A,F2:()=>g,FZ:()=>v,Lv:()=>I,Y1:()=>f,Z7:()=>C,ZR:()=>E,dl:()=>T,eY:()=>p,qx:()=>m,sg:()=>M,vW:()=>S,vY:()=>b,zm:()=>N,zz:()=>y});var i,o=n(7389),r=n(6082),s=n(4328),a=n(4139),l=n(8774),u=n(144),c=n.n(u),h=function(t,e,n,i){return new(n||(n=Promise))((function(o,r){function s(t){try{l(i.next(t))}catch(t){r(t)}}function a(t){try{l(i.throw(t))}catch(t){r(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(s,a)}l((i=i.apply(t,e||[])).next())}))};function d(t){var e;return null!==(e=t.getTag(a.gp.SEPARATOR))&&void 0!==e?e:""}function f(t,e=a.rg.NONE){let n=t=>t;switch(e){case a.rg.NONE:break;case a.rg.LG:n=t=>Math.log10(t);break;case a.rg.MINUS_LG:n=t=>-Math.log10(t);break;default:throw new Error(`ScalingError: method \`${e}\` is not available.`)}const i=t.getRawData(),o=r.Column.float(a.$2.ACTIVITY,t.length).init((t=>{const e=i[t];return e===r.FLOAT_NULL||e===r.INT_NULL?e:n(e)}));return o.setTag(a.gp.ANALYSIS_COL,"true"),o.setTag(r.TAGS.FORMULA,e),o}function m(t){var e,n,i,o;const r=t.columns.bySemTypeAll(a.uF.MONOMER),s={},l=t.filter.clone().and(t.selection).getSelectedIndexes();for(const t of l)for(const a of r){const r=a.get(t);r&&(null!==(e=s[i=a.name])&&void 0!==e||(s[i]={}),null!==(n=(o=s[a.name])[r])&&void 0!==n||(o[r]=0),s[a.name][r]+=1)}return s}function p(t){return{name:t.name,cat:t.categories,rawData:t.getRawData()}}function g(t,e,n={}){var i;const s=[],l=t.dataFrame.getCol(a.$2.SPLIT_COL).categories;for(let t=0;t<l.length;++t){if(!l[t])continue;const e=r.Color.toHtml(r.Color.categoricalPalette[t%r.Color.categoricalPalette.length]),a=o.label(null!==(i=n[l[t]])&&void 0!==i?i:l[t],{style:{color:e}});s.push(a)}const u=o.divV([o.divV(s),t.root,o.tableFromMap(e)]);return t.root.style.maxHeight="75px",u}function v(t,e,n){const o=n.filter,s=e.clone().and(o),l=t.length,u=t.getRawData(),c=o.trueCount,h=new Float32Array(c+s.trueCount),d=new Array(h.length);for(let t=0,e=0,n=0;t<l;++t){if(!o.get(t))continue;const r=s.get(t);h[e]=u[t],d[e]=r?i.SELECTION:i.ALL,e++,r&&(h[c+n]=u[t],d[c+n]=i.ALL,++n)}const f=r.Column.fromStrings(a.$2.SPLIT_COL,d),m=[i.ALL,i.SELECTION];return f.setCategoryOrder(m),f.meta.colors.setCategorical(),r.DataFrame.fromColumns([r.Column.fromFloat32Array(a.$2.ACTIVITY,h),f])}function C(t,e,n){t.dataFrame||r.DataFrame.fromColumns([t]);const i=t.dataFrame.filter,o=t.getRawData(),s=Array.from(new Set(e.keys())).map((t=>Number(t))).filter((t=>i.get(t))),l=new Set;for(const t of e.values())for(const e of t)l.add(e);const u=Array.from(l).filter((t=>i.get(t))),c=s.length+u.length,h=new Array(c),d=new Float32Array(c);for(let t=0;t<s.length;++t){const e=s[t];d[t]=o[e],h[t]=n}for(let t=0;t<u.length;++t){const e=u[t];d[s.length+t]=o[e],h[s.length+t]="Mutated"}const f=r.Column.fromStrings(a.$2.SPLIT_COL,h),m=[n,"Mutated"];return f.setCategoryOrder(m),f.meta.colors.setCategorical(),r.DataFrame.fromColumns([r.Column.fromFloat32Array(a.$2.ACTIVITY,d),f])}function y(t){const e=o.iconFA("expand-alt",(()=>{const e=t.dataFrame.plot.grid();b(e,!1),e.root.style.height="100%";const n=o.dialog(t.dataFrame.name);n.add(e.root),n.showModal(!0),e.invalidate()}));t.root.appendChild(e),e.style.position="absolute",e.style.right="0px",e.style.top="0px",e.style.visibility="hidden",t.root.addEventListener("mouseenter",(t=>{e.style.visibility="visible"})),t.root.addEventListener("mouseleave",(t=>{e.style.visibility="hidden"}))}function w(t,e,n,i){const r=o.iconFA("expand-alt",(()=>{const e=i(),n=o.dialog(t);n.add(e),n.show({resizable:!0,modal:!0,width:window.innerWidth-60,x:30,y:30,height:window.innerHeight-60})}),"Expand to full screen");r.style.marginLeft="auto",r.style.marginRight="15px",n.addEventListener("mouseenter",(()=>{r.style.visibility="visible"})),n.addEventListener("mouseleave",(()=>{r.style.visibility="hidden"})),e.appendChild(r)}function b(t,e=!0){t.props.allowEdit=!1,t.props.showReadOnlyNotifications=!1,t.props.allowRowSelection=!1,t.props.allowBlockSelection=!1,t.props.allowColSelection=!1,t.props.showRowHeader=!1,t.props.showCurrentRowIndicator=!1,t.root.style.width="100%",t.root.style.maxWidth="100%",e&&t.autoSize(1e3,175,0,0,!0)}function A(t){for(const e of Object.values(t))if(0!==e.length)return!1;return!0}function S(t,e,n){const i=t[e.positionOrClusterType],o=i.indexOf(e.monomerOrCluster);if(n.shiftPressed&&n.ctrlPressed)-1!==o&&i.splice(o,1);else if(n.ctrlPressed)-1===o?i.push(e.monomerOrCluster):i.splice(o,1);else if(n.shiftPressed)-1===o&&i.push(e.monomerOrCluster);else{const n=Object.keys(t);t={};for(const i of n)t[i]=[],i===e.positionOrClusterType&&t[i].push(e.monomerOrCluster)}return t}function T(t,e,n){if(!e)return;const i=new l.A(e.rowCount);if(t.positionOrClusterType===a.$2.MONOMER){const e=Object.values(n);for(const n of e){const e=n[t.monomerOrCluster];void 0!==e&&i.or(e.mask)}}else{const e=n[t.positionOrClusterType];if(void 0!==e){const n=e[t.monomerOrCluster];void 0!==n&&i.or(n.mask)}}e.rows.highlight((t=>i.getBit(t)))}function E(t){const e={};for(const n of t)e[n.name]=[];return e}function _(t,e){return t.sequenceColumnName===e.sequenceColumnName&&t.activityColumnName===e.activityColumnName&&t.activityScaling===e.activityScaling}function N(t,e,n,i){const o=Object.entries(n),r=i?Object.entries(i).filter((t=>!e.includes(t[0])||n[t[0]]!==t[1])):[];return o.concat(r).filter((e=>t.columns.contains(e[0])&&t.col(e[0]).matches("numerical")))}function x(t,e=2){return t.columns.bySemTypeAll(r.SEMTYPE.MACROMOLECULE).length>0&&c()(t.columns.numerical).toArray().length>0&&t.rowCount>=e}function M(t,e=500){let n;return(...i)=>h(this,void 0,void 0,(function*(){return new Promise((o=>{clearTimeout(n),n=setTimeout((()=>o(t(...i))),e)}))}))}function I(){return"isInDemo"in s.shell&&!!s.shell.isInDemo}function O(t){return{set:function(e,n){return t[e]=n,this}}}!function(t){t.SELECTION="Selection",t.ALL="All",t.PEPTIDES_SELECTION="Peptides selection"}(i||(i={}))},7471:(t,e,n)=>{"use strict";n.d(e,{a:()=>i});class i{constructor(){const t=navigator.hardwareConcurrency;this._workerCount=Math.max(t-2,1),this._workers=new Array(this._workerCount).fill(null).map((()=>new Worker(new URL(n.p+n.u(216),n.b))))}calc(t,e){return n=this,i=arguments,r=function*(t,e,n={}){const i=new Map;try{const o=t.length,r=new Array(this._workerCount),s=o*(o-1)/2;this._workerCount=Math.min(this._workerCount,s);const a=s/this._workerCount;e.forEach((t=>{var e;t.cat=null===(e=t.cat)||void 0===e?void 0:e.slice()}));for(let i=0;i<this._workerCount;i++)r[i]=new Promise(((o,r)=>{const l=Math.floor(i*a),u=i===this._workerCount-1?s:Math.floor((i+1)*a);this._workers[i].postMessage({startIdx:l,endIdx:u,activityArray:t,monomerInfoArray:e,settings:n}),this._workers[i].onmessage=({data:{pos:t,seq1Idxs:e,seq2Idxs:n,error:s}})=>{var a;s?(null===(a=this._workers[i])||void 0===a||a.terminate(),r(s)):(this._workers[i].terminate(),o({pos:t,seq1Idxs:e,seq2Idxs:n}))}}));const l=yield Promise.all(r),u=new Map;e.forEach(((t,e)=>{u.set(t.name,e)})),l.filter(Boolean).forEach((t=>{for(let n=0;n<t.pos.length;n++){const o=u.get(t.pos[n]),r=e[o].rawData[t.seq1Idxs[n]],s=e[o].cat[r],a=e[o].rawData[t.seq2Idxs[n]],l=e[o].cat[a];i.has(s)||i.set(s,new Map),i.has(l)||i.set(l,new Map);const c=i.get(s),h=i.get(l);c.has(t.pos[n])||c.set(t.pos[n],new Map),h.has(t.pos[n])||h.set(t.pos[n],new Map);const d=c.get(t.pos[n]),f=h.get(t.pos[n]);d.has(t.seq1Idxs[n])||d.set(t.seq1Idxs[n],[]),f.has(t.seq2Idxs[n])||f.set(t.seq2Idxs[n],[]);const m=d.get(t.seq1Idxs[n]),p=f.get(t.seq2Idxs[n]);m.push(t.seq2Idxs[n]),p.push(t.seq1Idxs[n])}}))}catch(t){this.terminate(),console.error(t)}return i},new((o=void 0)||(o=Promise))((function(t,e){function s(t){try{l(r.next(t))}catch(t){e(t)}}function a(t){try{l(r.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(s,a)}l((r=r.apply(n,i||[])).next())}));var n,i,o,r}terminate(){var t;null===(t=this._workers)||void 0===t||t.forEach((t=>{try{null==t||t.terminate()}catch(t){console.error(t)}}))}}},5070:(t,e,n)=>{"use strict";n.d(e,{pY:()=>l,hX:()=>a,I_:()=>h,m2:()=>d,lh:()=>c,GT:()=>u,J1:()=>f});var i=n(6082),o=n(6572),r=n(8774),s=n(4139);const a=(t,e)=>`${t}(${e})`;function l(t){return r.A.fromUint32Array(t.length,new Uint32Array(t.getBuffer().buffer))}function u(t,e,n,r){var s;if(t.length!==e.length&&16!==t.length||n&&t.length!==n.length&&16!==t.length)throw new Error("PeptidesError: Data and bit array have different lengths");n&&n.allTrue&&(n=void 0);const a=n?e.clone().and(n):e,l=new Float32Array(a.trueCount()),u=new Float32Array(n?n.trueCount()-a.trueCount():a.falseCount());let c;if(r)try{c=null===(s=i.DataFrame.fromColumns([r.col]).clone(function(t){return i.BitSet.fromBytes(t.buffer.buffer,t.length)}(a)).col(r.col.name))||void 0===s?void 0:s.aggregate(r.type)}catch(t){console.error(t)}let h=0,d=0;for(let i=0;i<e.length;++i)n&&!n.getBit(i)||(e.getBit(i)?l[h++]=t[i]:u[d++]=t[i]);const f=l.length+u.length,m=l.reduce(((t,e)=>t+e),0)/Math.max(l.length,1);if(l.length<2||u.length<2){const t=u.reduce(((t,e)=>t+e),0)/Math.max(u.length,1);return{count:l.length,pValue:null,mean:m,meanDifference:m-t,ratio:l.length/f,mask:a,aggValue:c}}const p=function(t,e,n=!1,i=!1){if(t.length<=1||e.length<=1)throw new Error(`StatisticsError: Wrong sample size; expected at least 2, got ${Math.min(t.length,e.length)})`);const r=o.mean(t),s=o.mean(e),a=o.variance(t),l=o.variance(e),u=t.length,c=e.length;let h,d,f;if(n){const t=a/u,e=l/c,n=(r-s)/Math.sqrt(t+e);d=o.normal.pdf(n,0,1),h=1-d,f=2*(d<h?d:h)}else if(i){const t=u+c-2,e=(a*(u-1)+l*(c-1))/t,n=Math.sqrt(u*c/(u+c))*(r-s)/e;h=1-o.studentt.cdf(n,t),d=o.studentt.cdf(n,t),f=2*(d<h?d:h)}else{const t=a/u,e=l/c,n=(r-s)/Math.sqrt(t+e),i=Math.pow(t+e,2)/(Math.pow(t,2)/(u-1)+Math.pow(e,2)/(c-1));d=o.studentt.cdf(n,i),h=1-d,f=2*(d<h?d:h)}return{"p-value":f,"Mean difference":r-s,"p-value more":h,"p-value less":d}}(l,u),g=p["Mean difference"];return{count:l.length,pValue:p[g>=0?"p-value more":"p-value less"],mean:m,meanDifference:g,ratio:l.length/f,mask:a,aggValue:c}}function c(t,e,n){const o=s.zW[e],r=i.Stats.fromColumn(t,n);if(!(o in r))throw new Error(`Aggregation type ${o} is not supported`);return r[o]}function h(t,e,n={}){var i,o;null!==(i=n.filterDf)&&void 0!==i||(n.filterDf=!1),null!==(o=n.fractionDigits)&&void 0!==o||(n.fractionDigits=3);const r=!n.filterDf||!t.filter.anyFalse||n.mask&&n.mask.length!==t.filter.trueCount?t:t.clone(t.filter),s={};for(const[t,i]of e){const e=a(i,t),o=c(r.getCol(t),i,n.mask);s[e]=o.toFixed(n.fractionDigits)}return s}function d(t,e,n,i){var o;null!==(o=i.fractionDigits)&&void 0!==o||(i.fractionDigits=3);const r={};for(const[o,s]of n){const n=a(s,o),l=t.get(n,e);r[n]=l.toFixed(i.fractionDigits)}return r}function f(t,e,n){var o;const r=t.col(e.substring(5,e.length-1));if(!r||!r.matches("categorical"))return"{}";null!=n||(n=i.BitSet.create(t.rowCount,(()=>!0)));const s=r.getRawData(),a=new Map;for(let t=-1;-1!==(t=n.findNext(t,!0));)a.set(s[t],(null!==(o=a.get(s[t]))&&void 0!==o?o:0)+1);const l={};for(const[t,e]of a)l[r.categories[t]]=e;return JSON.stringify(l)}},912:(t,e,n)=>{"use strict";n.d(e,{D:()=>u,Y:()=>c});var i=n(7389),o=n(6082),r=n(4139),s=n(7654),a=n(8608),l=n(5070);function u(t,e,n,i){var o,s,a;return null!==(o=i.fromViewer)&&void 0!==o||(i.fromViewer=!1),null!==(s=i.isMutationCliffs)&&void 0!==s||(i.isMutationCliffs=!1),null!==(a=i.isMostPotentResidues)&&void 0!==a||(i.isMostPotentResidues=!1),i.monomerPosition.positionOrClusterType!==r.$2.MONOMER&&c(t,e,n,i),!0}function c(t,e,n,r){var u,c,h,d,f,m,p,g,v;if(null!==(u=r.fromViewer)&&void 0!==u||(r.fromViewer=!1),null!==(c=r.isMutationCliffs)&&void 0!==c||(r.isMutationCliffs=!1),null!==(h=r.isMostPotentResidues)&&void 0!==h||(r.isMostPotentResidues=!1),null!==(d=r.additionalStats)&&void 0!==d||(r.additionalStats={}),r.cliffStats&&r.isMutationCliffs&&r.cliffIndexes){const u=null===(g=null===(p=r.cliffStats)||void 0===p?void 0:p.get(r.monomerPosition.monomerOrCluster))||void 0===g?void 0:g.get(r.monomerPosition.positionOrClusterType);if(!u)return null;const c=o.BitSet.fromBytes(u.mask.buffer.buffer,e.length);c.and(t.filter);const h=(0,s.M1)((0,a.Z7)(e,r.cliffIndexes,r.monomerPosition.monomerOrCluster),!0),d="MP in cliffs count",f=(0,s.QD)(u,{countName:d});r.fromViewer&&(f["Mean difference"]=`${f["Mean difference"]} (Color)`,f[d]&&(f[d]=`${f[d]} (Size)`),r.additionalStats["Unique count"]=c.trueCount.toString());const m=null!==(v=r.aggrColValues)&&void 0!==v?v:(0,l.I_)(t,n,{mask:c}),C=Object.assign(Object.assign(Object.assign({},r.additionalStats),f),m),y=(0,a.F2)(h,C);return i.tooltip.show(y,r.x,r.y),y}{const u=r.mpStats[r.monomerPosition.positionOrClusterType][r.monomerPosition.monomerOrCluster];if(!(null==u?void 0:u.count))return null;const c=o.BitSet.fromBytes(u.mask.buffer.buffer,e.length);c.and(t.filter);const h=(0,s.M1)((0,a.FZ)(e,c,t),!0),d=(0,s.QD)(u);r.fromViewer&&(d["Mean difference"]=`${d["Mean difference"]}${r.isMostPotentResidues?" (size)":""}`,d["p-value"]&&(d["p-value"]=`${d["p-value"]}${r.isMostPotentResidues?" (color)":""}`));const p=null!==(f=r.aggrColValues)&&void 0!==f?f:(0,l.I_)(t,n,{mask:c}),g=Object.assign(Object.assign(Object.assign({},r.additionalStats),d),p);for(const[t,e]of Object.entries(null!==(m=r.postfixes)&&void 0!==m?m:{}))g[t]&&(g[t]=`${g[t]}${e}`);const v=(0,a.F2)(h,g);return i.tooltip.show(v,r.x,r.y),r.fromViewer||setTimeout((()=>h.props.legendVisibility="Never"),100),v}}},115:(t,e,n)=>{"use strict";n.d(e,{GI:()=>a,Ku:()=>r,av:()=>s});var i=n(1199),o=n(4329);const r="WebGPU is not supported on this device";class s{constructor(){this.maxIterations=16,this.inflation=1.4,this.threshold=70,this.distanceF=i.Z.NEEDLEMANN_WUNSCH,this.gapOpen=1.5,this.gapExtend=.2,this.fingerprintType="Morgan",this.useWebGPU=!1,this.minClusterSize=5,this.webGPUDescription=r,this.webGPUDescriptionPromise=(0,o._)().then((t=>{t&&(this.webGPUDescription=t)}))}}class a{constructor(t){this.distanceF=i.Z.NEEDLEMANN_WUNSCH,this.gapOpen=1.5,this.gapExtend=.2,this.clusterEmbeddings=!0,this.epsilon=.01,this.minPts=4,this.fingerprintType="Morgan",this.clusterEmbeddings=!!t}}},5480:(t,e,n)=>{"use strict";n.d(e,{W:()=>S,s:()=>E});var i=n(7389),o=n(4328),r=n(6082),s=n(7233),a=n.n(s),l=n(9499),u=n(4139),c=n(3163),h=n(4326),d=n(5070),f=n(144),m=n.n(f),p=n(7654),g=n(8608),v=n(8774),C=n(3262),y=n(1458),w=n(3077),b=n(726);const A=(t,e)=>`${t}(${e})`;var S,T;!function(t){t.ORIGINAL="original",t.CUSTOM="custom"}(S||(S={})),function(t){t.GENERAL="General",t.STYLE="WebLogo",t.AGGREGATION="Aggregation"}(T||(T={}));class E extends r.JsViewer{constructor(){super(),this.bitsets=[],this.keyPress=!1,this.currentRowIndex=null,this._scaledActivityColumn=null,this._webLogoCacheGeneration=0,this._viewerGrid=null,this._clusterStats=null,this._clusterSelection=null,this._logoSummaryTable=null,this._positionColumns=null,this.root.classList.add("peptides-viewer-show-title"),this.sequenceColumnName=this.column("sequence",{category:T.GENERAL,nullable:!1}),this.clustersColumnName=this.column("clusters",{category:T.GENERAL,nullable:!1,columnTypeFilter:r.TYPE.CATEGORICAL}),this.activityColumnName=this.column("activity",{category:T.GENERAL,nullable:!1,columnTypeFilter:r.TYPE.NUMERICAL}),this.activityScaling=this.string("activityScaling",u.rg.NONE,{category:T.GENERAL,choices:Object.values(u.rg)}),this.webLogoMode=this.string("webLogoMode",h.fH.Entropy,{choices:[h.fH.full,h.fH.Entropy],category:T.STYLE}),this.membersRatioThreshold=this.float("membersRatioThreshold",.1,{min:0,max:1,category:T.STYLE});const t=[r.AGG.KEY,r.AGG.PIVOT,r.AGG.MISSING_VALUE_COUNT,r.AGG.SKEW,r.AGG.KURT,r.AGG.SELECTED_ROWS_COUNT],e=Object.values(r.AGG).filter((e=>!t.includes(e)));this.webLogoAggregationType=this.string("webLogoAggregationType",r.AGG.TOTAL_COUNT,{category:T.STYLE,choices:e,description:"Aggregation method for WebLogo position heights"}),this.webLogoAggregationColumnName=this.column("webLogoAggregationColumnName",{defaultValue:null,category:T.STYLE,nullable:!0,columnTypeFilter:r.TYPE.NUMERICAL,description:`Column with values to aggregate for WebLogo position heights.\n Used if aggregation type is not '${r.AGG.TOTAL_COUNT}'.`}),this.columns=this.columnList("columns",[],{category:T.AGGREGATION}),this.aggregation=this.string("aggregation",r.AGG.AVG,{category:T.AGGREGATION,choices:u.V5})}get model(){return l.i.getInstance(this.dataFrame)}get viewerGrid(){var t;return null!==(t=this._viewerGrid)&&void 0!==t||(this._viewerGrid=this.createLogoSummaryTableGrid()),this._viewerGrid}get clusterStats(){var t;return null!==(t=this._clusterStats)&&void 0!==t||(this._clusterStats=(0,y.eW)(this.dataFrame,this.clustersColumnName,this.customClusters.toArray(),this.getScaledActivityColumn())),this._clusterStats}get clusterSelection(){var t;return null!==(t=this._clusterSelection)&&void 0!==t||(this._clusterSelection=this.initClusterSelection({notify:!1})),this._clusterSelection}set clusterSelection(t){this._clusterSelection=t,this.model.fireBitsetChanged(l.q.LOGO_SUMMARY_TABLE),this.model.analysisView.grid.invalidate()}get logoSummaryTable(){var t;return null!==(t=this._logoSummaryTable)&&void 0!==t||(this._logoSummaryTable=this.createLogoSummaryTable()),this._logoSummaryTable}set logoSummaryTable(t){this._logoSummaryTable=t}get positionColumns(){var t,e,n,i;if(null!=this._positionColumns)return this._positionColumns;const o=t=>{const e=this.model.findViewer(t);return this.sequenceColumnName===(null==e?void 0:e.sequenceColumnName)?e._positionColumns:null};return null!=this.model.positionColumns&&this.sequenceColumnName===(null===(t=this.model.settings)||void 0===t?void 0:t.sequenceColumnName)&&(this._positionColumns=this.model.positionColumns),null!==(e=this._positionColumns)&&void 0!==e||(this._positionColumns=null!==(i=null!==(n=o(l.q.SEQUENCE_VARIABILITY_MAP))&&void 0!==n?n:o(l.q.MOST_POTENT_RESIDUES))&&void 0!==i?i:(0,w.R)(this.dataFrame.getCol(this.sequenceColumnName),b.Z.getSeqHelper()).columns.toList()),this._positionColumns}get isClusterSelectionEmpty(){return 0===this.clusterSelection[S.ORIGINAL].length+this.clusterSelection[S.CUSTOM].length}get customClusters(){const t={};return t[u.gp.CUSTOM_CLUSTER]="1",m()(this.dataFrame.columns.byTags(t))}getScaledActivityColumn(t=!1){var e,n,i;return(null===(e=this.model.settings)||void 0===e?void 0:e.activityColumnName)===this.activityColumnName&&(null===(n=this.model.settings)||void 0===n?void 0:n.activityScaling)===this.activityScaling&&(this._scaledActivityColumn=this.model.getScaledActivityColumn(t)),null!==(i=this._scaledActivityColumn)&&void 0!==i||(this._scaledActivityColumn=(0,g.Y1)(this.dataFrame.getCol(this.activityColumnName),this.activityScaling)),t?r.DataFrame.fromColumns([this._scaledActivityColumn]).clone(this.dataFrame.rowCount===this._scaledActivityColumn.length?this.dataFrame.filter:null).getCol(this._scaledActivityColumn.name):this._scaledActivityColumn}getAggregationColumns(){return Object.fromEntries(this.columns.map((t=>[t,this.aggregation])).filter((([t,e])=>this.model.df.columns.contains(t)&&this.model.df.col(t).matches("numerical"))))}onTableAttached(){var t,e,n,i,s,a,l,c,h,d,f,p,v;if(super.onTableAttached(),(0,g.B2)(this.dataFrame)){const o=null===(t=m()(this.dataFrame.columns.numerical).filter((t=>{var e;return null===(e=t.name)||void 0===e?void 0:e.includes("activ")})).take(1).toArray()[0])||void 0===t?void 0:t.name,g=null!=o?o:null===(n=null===(e=m()(this.dataFrame.columns.numerical).take(1).toArray())||void 0===e?void 0:e[0])||void 0===n?void 0:n.name,C=this.dataFrame.columns.bySemType(r.SEMTYPE.MACROMOLECULE);C&&(null===(i=this.getProperty(`sequence${u.To}`))||void 0===i||i.set(this,C.name)),g&&(null===(s=this.getProperty(`activity${u.To}`))||void 0===s||s.set(this,g),null===(a=this.getProperty("webLogoAggregationColumnName"))||void 0===a||a.set(this,g));const y=null===(h=null===(c=null===(l=m()(this.dataFrame.columns).filter((t=>{var e;return t.isCategorical&&(null===(e=t.name)||void 0===e?void 0:e.toLowerCase().includes("cluster"))&&t.name!=(null==C?void 0:C.name)&&t.type!==r.COLUMN_TYPE.BOOL})))||void 0===l?void 0:l.take(1))||void 0===c?void 0:c.toArray())||void 0===h?void 0:h[0],w=null!=y?y:null===(p=null===(f=null===(d=m()(this.dataFrame.columns.categorical).filter((t=>t.name!=(null==C?void 0:C.name)&&t.categories.length<=50&&t.type!==r.COLUMN_TYPE.BOOL)))||void 0===d?void 0:d.take(1))||void 0===f?void 0:f.toArray())||void 0===p?void 0:p[0];w&&(null===(v=this.getProperty(`clusters${u.To}`))||void 0===v||v.set(this,w.name))}else{const t="PeptidesError: dataframe is missing Macromolecule or numeric columns";o.log.error(t),o.shell.warning(t)}this.render()}detach(){this.subs.forEach((t=>t.unsubscribe()))}render(){if(a()(this.root).empty(),null==this.clustersColumnName||null==this.sequenceColumnName||null==this.activityColumnName)return void this.root.appendChild(i.divText("Please, select a sequence, cluster and activity columns in the viewer properties"));if(!this.logoSummaryTable.filter.anyTrue){const t=i.divText("No clusters to satisfy the threshold. Please, lower the threshold in viewer proeperties to include clusters");return void this.root.appendChild(i.divV([t]))}const t=i.iconFA("expand-alt",(()=>{const t=i.dialog("Logo Summary Table");t.add(this.viewerGrid.root),t.onCancel((()=>this.render())),t.showModal(!0),this.viewerGrid.invalidate()}),"Show Logo Summary Table in full screen");a()(t).addClass("pep-help-icon"),this.viewerGrid.root.style.width="auto",this.viewerGrid.root.style.height="auto",this.viewerGrid.root.style.overflow="hidden",this.root.appendChild(i.divV([i.divH([t],{style:{alignSelf:"center",lineHeight:"normal"}}),this.viewerGrid.root])),this.viewerGrid.invalidate()}onPropertyChanged(t){super.onPropertyChanged(t);let e=!1;switch(t.name){case"membersRatioThreshold":this.logoSummaryTable.filter.anyTrue||(e=!0),this.updateFilter();break;case`sequence${u.To}`:this._viewerGrid=null,this._logoSummaryTable=null,e=!0;break;case`clusters${u.To}`:this._clusterStats=null,this._clusterSelection=null,this._viewerGrid=null,this._logoSummaryTable=null,e=!0;break;case`activity${u.To}`:this.webLogoAggregationColumnName=this.activityColumnName;case"activityScaling":case`webLogoAggregationColumnName${u.To}`:case"webLogoAggregationType":this._webLogoCacheGeneration++,this._scaledActivityColumn=null,this._viewerGrid=null,this._clusterStats=null,this._logoSummaryTable=null,e=!0;break;case"columns":case"aggregation":this._viewerGrid=null,this._logoSummaryTable=null,e=!0;break;case"webLogoMode":this.viewerGrid.invalidate()}e&&this.render()}initClusterSelection(t={}){var e;null!==(e=t.notify)&&void 0!==e||(t.notify=!0);const n={};return n[S.ORIGINAL]=[],n[S.CUSTOM]=[],t.notify?this.clusterSelection=n:this._clusterSelection=n,this.clusterSelection}getTotalViewerAggColumns(){var t,e;const n=this.getAggregationColumns();return(0,g.zm)(this.model.df,this.columns,n,null===(e=null===(t=this.model)||void 0===t?void 0:t.settings)||void 0===e?void 0:e.columns)}getStringAggregatedColumns(){return this.columns.filter((t=>this.model.df.columns.contains(t)&&this.model.df.col(t).matches("categorical"))).map((t=>`dist(${t})`))}getNeededDfClone(){var t,e;const n=[this.clustersColumnName,this.sequenceColumnName,this.activityColumnName,...(null!==(t=this.getTotalViewerAggColumns())&&void 0!==t?t:[]).map((([t,e])=>t)),...(null!==(e=this.getStringAggregatedColumns())&&void 0!==e?e:[]).map((t=>t.substring(5,t.length-1)))];this.webLogoAggregationColumnName&&n.push(this.webLogoAggregationColumnName);const i=Array.from(new Set(n)).filter((t=>this.dataFrame.columns.contains(t)));return this.dataFrame.clone(this.dataFrame.filter,i)}createLogoSummaryTable(){var t,e,n;const i=this.clustersColumnName,o=this.dataFrame.filter.anyFalse,s=o?this.getNeededDfClone():this.dataFrame,a=s.columns,l=s.rowCount,c=this.getScaledActivityColumn(o).getRawData(),h=s.getCol(i),f=h.getRawData(),p=h.categories,g={};g[u.gp.CUSTOM_CLUSTER]="1";const C=m()(a.byTags(g)).filter((t=>t.max>0)).toArray(),y=r.DataFrame.create(C.length),w=y.columns,b=w.addNewString(u.i6.CLUSTER),T=w.addNewInt(u.i6.MEMBERS).getRawData(),E=w.addNewString(u.i6.WEB_LOGO),_=w.addNewString(u.i6.DISTRIBUTION),N=w.addNewFloat(u.i6.MEAN_DIFFERENCE).getRawData(),x=w.addNewFloat(u.i6.P_VALUE).getRawData(),M=w.addNewFloat(u.i6.RATIO).getRawData();let I=s.groupBy([i]);const O=this.getTotalViewerAggColumns(),L=this.getStringAggregatedColumns(),P=L.map((t=>w.addNewString(t))),R=O.map((([t,e])=>A(e,t))),k=new Array(R.length+L.length),V=O.map((([t,e])=>[s.getCol(t),e]));for(let t=0;t<O.length;++t){const[e,n]=O[t];I=I.add(n,e,R[t]);const i=w.addNewFloat(R[t]);k[t]=i.getRawData()}const F=new Array(C.length);for(let e=0;e<C.length;++e){const n=C[e];b.set(e,n.name);const i=v.A.fromUint32Array(l,n.getRawData());if(i.allFalse)continue;const a=r.BitSet.fromBytes(i.buffer.buffer,l),u=o?(0,d.GT)(c,i):this.clusterStats[S.CUSTOM][n.name];T[e]=u.count,F[e]=a,N[e]=u.meanDifference,x[e]=null!==(t=u.pValue)&&void 0!==t?t:r.FLOAT_NULL,M[e]=u.ratio;for(let t=0;t<R.length;++t){const[n,i]=V[t];k[t][e]=(0,d.lh)(n,i,a)}for(let t=R.length;t<k.length;++t){const n=L[t-R.length];P[t-R.length].set(e,(0,d.J1)(s,n,a))}}E.setTag(r.TAGS.CELL_RENDERER,"html"),_.setTag(r.TAGS.CELL_RENDERER,"html");const D=I.aggregate(),G=D.rowCount,U=D.columns;let q=D.getCol(i);q.name=u.i6.CLUSTER,q.type!==r.COLUMN_TYPE.STRING&&(D.columns.replace(q,q.convertTo(r.COLUMN_TYPE.STRING)),q=D.getCol(q.name));const B=q.categories,H=U.addNewInt(u.i6.MEMBERS).getRawData(),Y=U.addNewString(u.i6.WEB_LOGO),j=U.addNewString(u.i6.DISTRIBUTION),W=U.addNewFloat(u.i6.MEAN_DIFFERENCE).getRawData(),$=U.addNewFloat(u.i6.P_VALUE).getRawData(),z=U.addNewFloat(u.i6.RATIO).getRawData(),K=L.map((t=>U.addNewString(t))),Z=new Array(G),Q=Array.from({length:G},(()=>new v.A(l,!1)));for(let t=0;t<l;++t){const n=p[f[t]];null===(e=Q[B.indexOf(n)])||void 0===e||e.setTrue(t)}for(let t=0;t<G;++t){const e=Q[t];if(e.allFalse)continue;const i=r.BitSet.fromBytes(e.buffer.buffer,l),a=o?(0,d.GT)(c,e):this.clusterStats[S.ORIGINAL][B[t]];for(let e=0;e<L.length;++e){const n=L[e];K[e].set(t,(0,d.J1)(s,n,i))}H[t]=a.count,Z[t]=i,W[t]=a.meanDifference,$[t]=null!==(n=a.pValue)&&void 0!==n?n:r.FLOAT_NULL,z[t]=a.ratio}Y.setTag(r.TAGS.CELL_RENDERER,"html"),j.setTag(r.TAGS.CELL_RENDERER,"html");const X=D.append(y);return this.bitsets=Z.concat(F),L.forEach((t=>X.col(t).semType="lst-pie-chart")),X}createLogoSummaryTableGrid(){const t=this.dataFrame.filter.anyFalse,e=t?this.getNeededDfClone():this.dataFrame,n=this.getTotalViewerAggColumns().map((([t,e])=>A(e,t))),i=this.logoSummaryTable.plot.grid();i.sort([u.i6.MEMBERS],[!1]),this.updateFilter(),i.col(u.i6.CLUSTER).visible=!0,i.columns.setOrder([u.i6.CLUSTER,u.i6.MEMBERS,u.i6.WEB_LOGO,...this.getStringAggregatedColumns(),u.i6.DISTRIBUTION,u.i6.MEAN_DIFFERENCE,u.i6.P_VALUE,u.i6.RATIO,...n]),i.columns.rowHeader.visible=!1,i.props.rowHeight=55;const o=new r.LruCache,s=new Map;let d=null;const f=new r.LruCache,m=this.positionColumns.length,p=i.columns.byName(u.i6.WEB_LOGO);p.cellType="html",p.width=350;const v=this.getScaledActivityColumn(t),C=e.getCol(this.sequenceColumnName);i.onCellRender.subscribe((t=>{var e,n,l;const p=t.cell,y=p.tableRowIndex;if(!p.isTableCell||null==y||-1===y)return;const w=t.g,b=t.bounds;w.save(),w.beginPath(),w.rect(b.x,b.y,b.width,b.height),w.clip();try{const A=Math.max(p.bounds.height-2,0),S=this.bitsets[y];if((null===(e=p.tableColumn)||void 0===e?void 0:e.name)===u.i6.CLUSTER)c.k8(w,p.cell.value,this.clusterSelection,b),t.preventDefault();else if((null===(n=p.tableColumn)||void 0===n?void 0:n.name)===u.i6.WEB_LOGO){const e=`${y}_${this.webLogoAggregationColumnName||"count"}_${this.webLogoAggregationType}_${this._webLogoCacheGeneration}`,n=o.get(e);if(!0===s.get(e))return void t.preventDefault();const l=Math.floor((p.bounds.width-2-4*(m-1))/m);if(void 0!==n){const e=n.getProperties();for(const t of e)"positionHeight"===t.name&&t.get(n)!==this.webLogoMode?t.set(n,this.webLogoMode):"positionWidth"===t.name&&t.get(n)!==l?t.set(n,l):"minHeight"===t.name&&t.get(n)!==A&&t.set(n,A);a()(n.root).css("height",`${A}px`).children().first().css("overflow-y","hidden !important"),n.root.style.height=`${A}px`,p.element=n.root,t.preventDefault()}else{const n=[C];if(this.webLogoAggregationType!==r.AGG.TOTAL_COUNT&&this.webLogoAggregationColumnName){const t=this.dataFrame.columns.byName(this.webLogoAggregationColumnName);t&&n.push(t)}const a=r.DataFrame.fromColumns(n);a.filter.copyFrom(S),s.set(e,!0),a.plot.fromType("WebLogo",{valueColumnName:this.webLogoAggregationColumnName,valueAggrType:this.webLogoAggregationType,positionHeight:this.webLogoMode,horizontalAlignment:h.P4.LEFT,maxHeight:1e3,minHeight:A,positionWidth:l,showPositionLabels:!1}).then((t=>{o.set(e,t),s.delete(e),d&&clearTimeout(d),d=setTimeout((()=>i.invalidate()),200)})),t.preventDefault()}}else if((null===(l=p.tableColumn)||void 0===l?void 0:l.name)===u.i6.DISTRIBUTION){let e=f.get(y);void 0===e&&(v.dataFrame||r.DataFrame.fromColumns([v]),e=(0,g.FZ)(v,S,v.dataFrame).plot.histogram({filteringEnabled:!1,valueColumnName:v.name,splitColumnName:u.$2.SPLIT_COL,legendVisibility:"Never",showXAxis:!1,showColumnSelector:!1,showRangeSlider:!1,showBinSelector:!1,backColor:r.Color.toHtml(r.Color.white),xAxisHeight:1,showSplitSelector:!1}),e.root.style.width="auto",f.set(y,e)),e.root.style.height=`${A}px`,p.element=e.root,t.preventDefault()}}finally{w.restore()}})),i.root.addEventListener("mouseleave",(t=>this.model.unhighlight())),r.debounce(i.onCurrentCellChanged,500).subscribe((t=>{var e;if(!t.isTableCell||-1===t.gridRow)return this.initClusterSelection({notify:!1}),this.model.fireBitsetChanged(l.q.LOGO_SUMMARY_TABLE),void i.invalidate();try{if(!this.keyPress||(null===(e=t.tableColumn)||void 0===e?void 0:e.name)!==u.i6.CLUSTER)return;null!==this.currentRowIndex&&-1!==this.currentRowIndex&&this.modifyClusterSelection(this.getCluster(i.cell(u.i6.CLUSTER,this.currentRowIndex)),{shiftPressed:!0,ctrlPressed:!0},!1),this.modifyClusterSelection(this.getCluster(t),{shiftPressed:!0,ctrlPressed:!1}),i.invalidate()}finally{this.keyPress=!1,this.currentRowIndex=t.gridRow}})),i.root.addEventListener("keydown",(t=>{if(this.keyPress=t.key.startsWith("Arrow"),!this.keyPress){if("Escape"===t.key||"KeyA"===t.code&&t.shiftKey&&t.ctrlKey)this.initClusterSelection({notify:!1});else if("KeyA"===t.code&&t.ctrlKey)for(let t=0;t<this.logoSummaryTable.rowCount;++t)this.modifyClusterSelection(this.getCluster(i.cell(u.i6.CLUSTER,t)),{shiftPressed:!0,ctrlPressed:!1},!1);this.model.fireBitsetChanged(l.q.LOGO_SUMMARY_TABLE),i.invalidate()}})),i.root.addEventListener("click",(t=>{var e;const n=i.hitTest(t.offsetX,t.offsetY);if(!n||!n.isTableCell||(null===(e=n.tableColumn)||void 0===e?void 0:e.name)!==u.i6.CLUSTER)return;const o=this.getCluster(n);this.modifyClusterSelection(o,{shiftPressed:t.shiftKey,ctrlPressed:t.ctrlKey}),i.invalidate()})),i.onCellTooltip(((t,e,n)=>{var i;if(!t.isTableCell)return this.model.unhighlight(),!0;const o=this.getCluster(t);return this.highlightCluster(o),(null===(i=t.tableColumn)||void 0===i?void 0:i.name)===u.i6.CLUSTER&&this.showTooltip(o,e,n),!0}));const y=i.props;return y.allowEdit=!1,y.allowRowSelection=!1,y.allowBlockSelection=!1,y.allowColSelection=!1,y.showCurrentRowIndicator=!1,y.showReadOnlyNotifications=!1,i}highlightCluster(t){const e=this.clusterStats[t.positionOrClusterType][t.monomerOrCluster].mask;this.dataFrame.rows.highlight((t=>e.getBit(t))),this.model.isHighlighting=!0}getCluster(t){const e=this.logoSummaryTable.get(u.i6.CLUSTER,t.tableRowIndex);return{positionOrClusterType:this.dataFrame.getCol(this.clustersColumnName).categories.includes(e)?S.ORIGINAL:S.CUSTOM,monomerOrCluster:e}}updateFilter(){const t=this.logoSummaryTable.getCol(u.i6.MEMBERS),e=this.logoSummaryTable.getCol(u.i6.CLUSTER),n=e.getRawData(),i=e.categories,o=i.indexOf("-1"),r=t.getRawData();let s=0;r.forEach(((t,e)=>{"-1"!==i[n[e]]&&(s=Math.max(s,r[e]))}));const a=Math.ceil(s*this.membersRatioThreshold);this.logoSummaryTable.filter.init((t=>r[t]>a&&(-1===o||"-1"!==i[n[t]])))}clusterFromSelection(){const t=this.model.getVisibleSelection(),e=this.logoSummaryTable.columns,n=e.length,i=new Array(e.length),o=this.getScaledActivityColumn(),r=(0,d.pY)(t),s=(0,d.GT)(o.getRawData(),r,(0,d.pY)(this.dataFrame.filter));this.bitsets.push(t.clone());const a=this.dataFrame.columns.getUnusedName("New Cluster"),l={},c={},h=this.getTotalViewerAggColumns(),f=this.getStringAggregatedColumns();for(const[e,n]of h){const i=A(n,e),o=this.dataFrame.getCol(e);l[i]=(0,d.lh)(o,n,t)}for(const e of f)c[e]=(0,d.J1)(this.dataFrame,e,t);for(let o=0;o<n;++o){const n=e.byIndex(o);i[o]=n.name===u.i6.CLUSTER?a:n.name===u.i6.MEMBERS?t.trueCount:n.name===u.i6.WEB_LOGO||n.name===u.i6.DISTRIBUTION?null:n.name===u.i6.MEAN_DIFFERENCE?s.meanDifference:n.name===u.i6.P_VALUE?s.pValue:n.name===u.i6.RATIO?s.ratio:n.name in l?l[n.name]:n.name in c?c[n.name]:void 0,void 0===i[o]&&C._package.logger.warning(`PeptidesLSTWarn: value for column ${n.name} is undefined`)}this.logoSummaryTable.rows.addNew(i),this.clusterStats[S.CUSTOM][a]=s,this.addNewCluster(a)}removeCluster(){const t=this.clusterSelection[S.CUSTOM];if(0===t.length)return void o.shell.warning("No custom clusters selected to be removed");const e=this.logoSummaryTable.rows,n=this.logoSummaryTable.getCol(u.i6.CLUSTER),i=n.categories,r=this.dataFrame.columns;for(const n of t){t.splice(t.indexOf(n),1),r.remove(n),delete this.clusterStats[S.CUSTOM][n];const o=i.indexOf(n);e.removeAt(o),this.bitsets.splice(o,1)}n.compact(),this.clusterSelection[S.CUSTOM]=t,this.render()}addNewCluster(t){const e=r.Column.fromBitSet(t,this.model.getVisibleSelection());e.setTag(u.gp.CUSTOM_CLUSTER,"1"),e.setTag(u.gp.ANALYSIS_COL,"true"),this.dataFrame.columns.add(e),this.model.analysisView.grid.col(e.name).visible=!1}modifyClusterSelection(t,e={shiftPressed:!1,ctrlPressed:!1},n=!0){n?this.clusterSelection=(0,g.vW)(this.clusterSelection,t,e):this._clusterSelection=(0,g.vW)(this.clusterSelection,t,e)}showTooltip(t,e,n){const o=this.dataFrame.filter,s=o.anyFalse?this.getNeededDfClone():this.dataFrame,a=s.rowCount,l=new v.A(a,!1),u=this.getScaledActivityColumn(o.anyFalse),c=u.getRawData();if(t.positionOrClusterType===S.ORIGINAL){const e=s.getCol(this.clustersColumnName),n=e.getRawData(),i=e.categories.indexOf(t.monomerOrCluster);for(let t=0;t<a;++t)n[t]===i&&l.setTrue(t);l.incrementVersion()}else{const e=s.getCol(t.monomerOrCluster);l.buffer=e.getRawData()}const h=o.anyFalse?(0,d.GT)(c,l):this.clusterStats[t.positionOrClusterType][t.monomerOrCluster];if(!h.count)return null;const f=r.BitSet.fromBytes(l.buffer.buffer,a);u.dataFrame||r.DataFrame.fromColumns([u]);const m=(0,g.FZ)(u,f,u.dataFrame),C=(0,p.M1)(m,!0),y=(0,p.QD)(h),w=(0,d.I_)(this.dataFrame,this.getTotalViewerAggColumns(),{filterDf:!0,mask:f}),b=Object.assign(Object.assign({},y),w),A=(0,g.F2)(C,b);return i.tooltip.show(A,e,n),A}createWebLogoDf(t,e){const n=r.DataFrame.fromColumns([t]);return n.filter.copyFrom(e),n}}},3541:(t,e,n)=>{"use strict";n.d(e,{J:()=>x,UJ:()=>M});var i,o,r,s,a=n(4328),l=n(7389),u=n(6082),c=n(7233),h=n.n(c),d=n(4139),f=n(3163),m=n(9499),p=n(144),g=n.n(p),v=n(5070),C=n(912),y=n(1458),w=n(8608),b=n(3077),A=n(439),S=n(2003),T=n(4971),E=n(726),_=function(t,e,n,i){return new(n||(n=Promise))((function(o,r){function s(t){try{l(i.next(t))}catch(t){r(t)}}function a(t){try{l(i.throw(t))}catch(t){r(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(s,a)}l((i=i.apply(t,e||[])).next())}))};!function(t){t.MUTATION_CLIFFS="Mutation Cliffs",t.INVARIANT_MAP="Invariant Map"}(i||(i={})),function(t){t.SEQUENCE="sequence",t.ACTIVITY="activity",t.ACTIVITY_SCALING="activityScaling",t.TARGET="target",t.TARGET_CATEGORY="targetCategory",t.MIN_ACTIVITY_DELTA="minActivityDelta",t.MAX_MUTATIONS="maxMutations",t.COLUMNS="columns",t.AGGREGATION="aggregation",t.ACTIVITY_TARGET="activityTarget",t.VALUE_INVARIANT_MAP="value",t.AGGREGATION_INVARIANT_MAP_VALUE="valueAggregation",t.DATA_SOURCE="dataSource"}(o||(o={})),function(t){t.COLOR="color",t.COLOR_AGGREGATION="colorAggregation",t.CUSTOM_COLOR_RANGE="customColorRange",t.MIN_COLOR_VALUE="minColorValue",t.MAX_COLOR_VALUE="maxColorValue",t.LOWER_BOUND_COLOR="lowerBoundColor",t.MIDDLE_COLOR="middleColor",t.UPPER_BOUND_COLOR="upperBoundColor",t.LOG_SCALE_COLOR="logScaleColor",t.SHOW_FILTER_CONTROLS="showFilterControls",t.SHOW_TOTAL_COUNT_COLUMN="showTotalCountColumn"}(r||(r={})),function(t){t.GENERAL="General",t.INVARIANT_MAP="Invariant Map",t.MUTATION_CLIFFS="Mutation Cliffs",t.AGGREGATION="Aggregation"}(s||(s={}));class N extends u.JsViewer{constructor(){super(),this.keyPressed=!1,this._scaledActivityColumn=null,this.doRender=!0,this.dataSource="Filtered",this._viewerGrid=null,this._positionColumns=null,this._monomerPositionStats=null,this._mutationCliffs=null,this._mutationCliffStats=null,this._invariantMapSelection=null,this._mutationCliffsSelection=null,this._monomerMetaColumns=new Set,this.sequenceColumnName=this.column(o.SEQUENCE,{category:s.GENERAL,semType:u.SEMTYPE.MACROMOLECULE,nullable:!1}),this.dataSource=this.string(o.DATA_SOURCE,"Filtered",{category:s.GENERAL,choices:["All","Filtered"],nullable:!1,description:"Data source for calculations and rendering. Can be set to whole data set or filtered data only."}),this.activityColumnName=this.column(o.ACTIVITY,{category:s.GENERAL,nullable:!1,columnTypeFilter:"numerical"}),this.activityScaling=this.string(o.ACTIVITY_SCALING,d.rg.NONE,{category:s.GENERAL,choices:Object.values(d.rg),nullable:!1}),this.activityTarget=this.string(o.ACTIVITY_TARGET,d.wf.HIGH,{category:s.GENERAL,choices:Object.values(d.wf),nullable:!1}),this.targetColumnName=this.column(o.TARGET,{category:s.GENERAL,nullable:!0,columnTypeFilter:"categorical",userEditable:!1}),this.minActivityDelta=this.float(o.MIN_ACTIVITY_DELTA,0,{category:s.MUTATION_CLIFFS,min:0,max:100}),this.maxMutations=this.int(o.MAX_MUTATIONS,1,{category:s.MUTATION_CLIFFS,min:1,max:20}),this.columns=this.columnList(o.COLUMNS,[],{category:s.AGGREGATION}),this.aggregation=this.string(o.AGGREGATION,u.AGG.AVG,{category:s.AGGREGATION,choices:d.V5}),this.valueColumnName=this.column(o.VALUE_INVARIANT_MAP,{category:s.INVARIANT_MAP,userEditable:!0,nullable:!1,columnTypeFilter:"numerical"}),this.valueAggregation=this.string(o.AGGREGATION_INVARIANT_MAP_VALUE,u.AGG.TOTAL_COUNT,{category:s.INVARIANT_MAP,choices:d.V5,userEditable:!0,nullable:!1}),this.mutationCliffsDebouncer=(0,w.sg)(((t,e,n)=>_(this,void 0,void 0,(function*(){return yield(0,y.uz)(t,e,n)})))),this.root.classList.add("peptides-viewer-show-title")}get viewerGrid(){var t;return null!==(t=this._viewerGrid)&&void 0!==t||(this._viewerGrid=this.createViewerGrid()),this._viewerGrid}render(){}get alphabet(){var t;return null!==(t=this.dataFrame.getCol(this.sequenceColumnName).getTag(A.gp.alphabet))&&void 0!==t?t:S.YI.UN}get model(){return m.i.getInstance(this.dataFrame)}get positionColumns(){var t,e,n;if(null!=this._positionColumns)return this._positionColumns;const i=t=>{const e=this.model.findViewer(t);return this.sequenceColumnName===(null==e?void 0:e.sequenceColumnName)?e._positionColumns:null};return null!=this.model.positionColumns&&this.sequenceColumnName===(null===(t=this.model.settings)||void 0===t?void 0:t.sequenceColumnName)?this._positionColumns=this.model.positionColumns:this instanceof x?this._positionColumns=i(m.q.MOST_POTENT_RESIDUES):this instanceof M&&(this._positionColumns=i(m.q.SEQUENCE_VARIABILITY_MAP)),null!==(e=this._positionColumns)&&void 0!==e||(this._positionColumns=null!==(n=i(m.q.LOGO_SUMMARY_TABLE))&&void 0!==n?n:(0,b.R)(this.dataFrame.getCol(this.sequenceColumnName),E.Z.getSeqHelper()).columns.toList()),this._positionColumns}get monomerPositionStats(){var t;if(null!=this._monomerPositionStats)return this._monomerPositionStats;const e=t=>this.sequenceColumnName===(null==t?void 0:t.sequenceColumnName)&&this.activityColumnName===(null==t?void 0:t.activityColumnName)&&this.activityScaling===(null==t?void 0:t.activityScaling)&&t instanceof N&&t.dataSource===this.dataSource&&(t instanceof N&&this.valueColumnName==(null==t?void 0:t.valueColumnName)&&this.valueAggregation==(null==t?void 0:t.valueAggregation)||!(t instanceof N)&&(!this.valueColumnName||!this.valueAggregation||this.valueAggregation==u.AGG.VALUE_COUNT||this.valueAggregation==u.AGG.TOTAL_COUNT)),n=t=>{const n=this.model.findViewer(t);return e(n)?n._monomerPositionStats:null};null!==this.model.monomerPositionStats&&e(this.model.settings)?this._monomerPositionStats=this.model.monomerPositionStats:this instanceof x?this._monomerPositionStats=n(m.q.MOST_POTENT_RESIDUES):this instanceof M&&(this._monomerPositionStats=n(m.q.SEQUENCE_VARIABILITY_MAP));const i=this.dataFrame.col(this.valueColumnName),o=this.valueAggregation;return null!==(t=this._monomerPositionStats)&&void 0!==t||(this._monomerPositionStats=(0,y.Ej)(this.getScaledActivityColumn(),this.dataFrame.filter,this.positionColumns,{isFiltered:"Filtered"===this.dataSource&&this.dataFrame.filter.anyFalse,aggValue:o&&i?{col:i,type:o}:void 0})),this._monomerPositionStats}get mutationCliffs(){if(null!=this._mutationCliffs)return this._mutationCliffs;const t=t=>{const e=this.model.findViewer(t);return i=e,(n=this).sequenceColumnName===(null==i?void 0:i.sequenceColumnName)&&n.activityColumnName===(null==i?void 0:i.activityColumnName)&&n.activityScaling===(null==i?void 0:i.activityScaling)&&n.minActivityDelta===(null==i?void 0:i.minActivityDelta)&&n.maxMutations===(null==i?void 0:i.maxMutations)&&(null==n?void 0:n.dataSource)===(null==i?void 0:i.dataSource)?e._mutationCliffs:null;var n,i};return this instanceof x?this._mutationCliffs=t(m.q.MOST_POTENT_RESIDUES):this instanceof M&&(this._mutationCliffs=t(m.q.SEQUENCE_VARIABILITY_MAP)),this._mutationCliffs}set mutationCliffs(t){this._mutationCliffs=t,this.viewerGrid.invalidate()}get cliffStats(){if(!this._mutationCliffStats&&this.mutationCliffs&&this.activityColumnName&&this.sequenceColumnName&&this.dataFrame.col(this.activityColumnName)){const t=this.dataFrame.col(this.activityColumnName).getRawData();this._mutationCliffStats=(0,y.Lw)(this.mutationCliffs,t)}return this._mutationCliffStats}set cliffStats(t){this._mutationCliffStats=t,this.viewerGrid.invalidate()}get mutationCliffsSelection(){var t;return null!==(t=this._mutationCliffsSelection)&&void 0!==t||(this._mutationCliffsSelection=(0,w.ZR)(this.positionColumns)),this._mutationCliffsSelection}set mutationCliffsSelection(t){var e,n;this._mutationCliffsSelection=t,this.model.fireBitsetChanged(this instanceof x?m.q.SEQUENCE_VARIABILITY_MAP:m.q.MOST_POTENT_RESIDUES);const i=this.model.findViewer(m.q.SEQUENCE_VARIABILITY_MAP);null===(e=null==i?void 0:i.viewerGrid)||void 0===e||e.invalidate();const o=this.model.findViewer(m.q.MOST_POTENT_RESIDUES);null===(n=null==o?void 0:o.viewerGrid)||void 0===n||n.invalidate(),this.model.analysisView.grid.invalidate()}getScaledActivityColumn(t=!1){var e,n,i;return(null===(e=this.model.settings)||void 0===e?void 0:e.activityColumnName)===this.activityColumnName&&(null===(n=this.model.settings)||void 0===n?void 0:n.activityScaling)===this.activityScaling&&(this._scaledActivityColumn=this.model.getScaledActivityColumn(t)),null!==(i=this._scaledActivityColumn)&&void 0!==i||(this._scaledActivityColumn=(0,w.Y1)(this.dataFrame.getCol(this.activityColumnName),this.activityScaling)),t?u.DataFrame.fromColumns([this._scaledActivityColumn]).clone(this.dataFrame.filter).getCol(this._scaledActivityColumn.name):this._scaledActivityColumn}modifyMutationCliffsSelection(t,e={shiftPressed:!1,ctrlPressed:!1},n=!0){n?this.mutationCliffsSelection=(0,w.vW)(this.mutationCliffsSelection,t,e):this._mutationCliffsSelection=(0,w.vW)(this.mutationCliffsSelection,t,e)}modifyInvariantMapSelection(t,e={shiftPressed:!1,ctrlPressed:!1},n=!0){n?this.invariantMapSelection=(0,w.vW)(this.invariantMapSelection,t,e):this._invariantMapSelection=(0,w.vW)(this.invariantMapSelection,t,e)}get invariantMapSelection(){var t;return null!==(t=this._invariantMapSelection)&&void 0!==t||(this._invariantMapSelection=(0,w.ZR)(this.positionColumns)),this._invariantMapSelection}set invariantMapSelection(t){this._invariantMapSelection=t,this.model.fireBitsetChanged(m.q.SEQUENCE_VARIABILITY_MAP),this.model.analysisView.grid.invalidate()}onPropertyChanged(t){switch(super.onPropertyChanged(t),this.doRender=!0,t.name){case`${o.SEQUENCE}${d.To}`:this._positionColumns=null,this._monomerPositionStats=null,this._mutationCliffs=null,this._mutationCliffStats=null,this._mutationCliffsSelection=null,this._viewerGrid=null;break;case`${o.ACTIVITY}${d.To}`:case o.ACTIVITY_SCALING:this._monomerPositionStats=null,this._mutationCliffs=null,this._mutationCliffStats=null,this._mutationCliffsSelection=null,this._viewerGrid=null,this._scaledActivityColumn=null;break;case`${o.VALUE_INVARIANT_MAP}${d.To}`:case o.AGGREGATION_INVARIANT_MAP_VALUE:this._monomerPositionStats=null,this._viewerGrid=null,this._invariantMapSelection=null;break;case o.MIN_ACTIVITY_DELTA:case o.MAX_MUTATIONS:this._mutationCliffs=null,this._mutationCliffStats=null,this._mutationCliffsSelection=null,this.doRender=!1;break;case o.COLUMNS:case o.AGGREGATION:this instanceof M&&(this._viewerGrid=null);break;case o.ACTIVITY_TARGET:(this instanceof M||this instanceof x)&&(this._viewerGrid=null);break;case o.DATA_SOURCE:this.onFilterChanged(!1,!1),this.doRender=!0}null===this._mutationCliffs&&this.sequenceColumnName&&this.activityColumnName&&this.dataFrame&&this.calculateMutationCliffs().then((t=>{this.mutationCliffs=t.cliffs,this.cliffStats=t.cliffStats}))}getAggregationColumns(){return Object.fromEntries(this.columns.map((t=>[t,this.aggregation])).filter((([t,e])=>this.model.df.columns.contains(t)&&this.model.df.col(t).matches("numerical"))))}getTotalViewerAggColumns(){var t,e;const n=this.getAggregationColumns();return(0,w.zm)(this.model.df,this.columns,n,null===(e=null===(t=this.model)||void 0===t?void 0:t.settings)||void 0===e?void 0:e.columns)}createViewerGrid(){throw new Error("Not implemented")}detach(){this.subs.forEach((t=>t.unsubscribe()))}onTableAttached(){var t,e,n,i;if(super.onTableAttached(),(0,w.B2)(this.dataFrame)){null===(t=this.getProperty(`${o.SEQUENCE}${d.To}`))||void 0===t||t.set(this,this.dataFrame.columns.bySemType(u.SEMTYPE.MACROMOLECULE).name);const r=null===(e=g()(this.dataFrame.columns.numerical).find((t=>t.name.toLowerCase().includes("activity"))))||void 0===e?void 0:e.name;null===(n=this.getProperty(`${o.ACTIVITY}${d.To}`))||void 0===n||n.set(this,null!=r?r:g()(this.dataFrame.columns.numerical).next().value.name),null===(i=this.getProperty(`${o.VALUE_INVARIANT_MAP}${d.To}`))||void 0===i||i.set(this,null!=r?r:g()(this.dataFrame.columns.numerical).next().value.name),null===this.mutationCliffs&&this.sequenceColumnName&&this.activityColumnName&&this.calculateMutationCliffs().then((t=>{this.mutationCliffs=t.cliffs,this.cliffStats=t.cliffStats})),this.subs.push(a.events.onContextMenu.subscribe((t=>{if(!(t&&t.causedBy&&t.args&&t.args.menu&&t.causedBy.target&&t.causedBy.target instanceof HTMLElement&&this.root.contains(t.causedBy.target)))return;const e=t.args.menu;(0,T.pj)().then((t=>{const n=t.getMonomerLib(),i=n.getMonomerSymbolsByType("PEPTIDE").map((t=>n.getMonomer("PEPTIDE",t))).filter(Boolean).map((t=>{var e;return null!==(e=t.meta)&&void 0!==e?e:{}})),o=new Set;i.forEach((t=>Object.keys(t).forEach((t=>o.add(t))))),o.delete("colors"),e.group("Monomer Meta").items(Array.from(o),(t=>{this._monomerMetaColumns.has(t)?this._monomerMetaColumns.delete(t):this._monomerMetaColumns.add(t),this._viewerGrid=null,this.render()}),{isChecked:t=>this._monomerMetaColumns.has(t)})}))}))),this.subs.push(u.debounce(this.dataFrame.onFilterChanged,300).subscribe((()=>{"Filtered"===this.dataSource&&this.onFilterChanged(!0,!1)})))}else{const t="PeptidesError: dataframe is missing Macromolecule or numeric columns";a.log.error(t),a.shell.warning(t)}}onFilterChanged(t,e=!1){if(this._monomerPositionStats=null,this._invariantMapSelection=null,this._mutationCliffStats=null,this._mutationCliffsSelection=null,this._mutationCliffs=null,e)return;this._viewerGrid=null;const n=this.model.findViewer(m.q.MOST_POTENT_RESIDUES);!n||this instanceof M||"Filtered"!==n.dataSource||n.onFilterChanged(!1,!0),t&&this.render(),this.sequenceColumnName&&this.activityColumnName&&this.calculateMutationCliffs().then((t=>{this.mutationCliffs=t.cliffs,this.cliffStats=t.cliffStats}))}calculateMutationCliffs(){return _(this,void 0,void 0,(function*(){var t;const e=this.dataFrame.getCol(this.activityColumnName),n=this.positionColumns.map(w.eY),i="Filtered"===this.dataSource&&this.dataFrame.filter.anyFalse?this.dataFrame.filter:null,o={maxMutations:this.maxMutations,minActivityDelta:this.minActivityDelta,filter:null!==(t=null==i?void 0:i.getBuffer())&&void 0!==t?t:void 0},r=e.getRawData(),s=yield this.mutationCliffsDebouncer(r,n,o);return{cliffs:s,cliffStats:(0,y.Lw)(s,r)}}))}}class x extends N{constructor(){super(),this.currentGridCell=null,this.customColorRange=!1,this.minColorValue=0,this.maxColorValue=0,this.logScaleColor=!1,this.showFilterControls=!0,this.showTotalCountColumn=!1,this._showSearchInput=!1,this.colorColumnName=this.column(r.COLOR,{category:s.INVARIANT_MAP,nullable:!1,columnTypeFilter:"numerical"}),this.colorAggregation=this.string(r.COLOR_AGGREGATION,u.AGG.AVG,{category:s.INVARIANT_MAP,choices:d.V5}),this.lowerBoundColor=this.int(r.LOWER_BOUND_COLOR,4278190335,{category:s.INVARIANT_MAP,editor:"color"}),this.middleColor=this.int(r.MIDDLE_COLOR,4294967295,{category:s.INVARIANT_MAP,editor:"color"}),this.upperBoundColor=this.int(r.UPPER_BOUND_COLOR,4294901760,{category:s.INVARIANT_MAP,editor:"color"}),this.showTotalCountColumn=this.bool(r.SHOW_TOTAL_COUNT_COLUMN,!1,{category:s.GENERAL,description:"Show total monomer count column"}),this.logScaleColor=this.bool(r.LOG_SCALE_COLOR,!1,{category:s.INVARIANT_MAP}),this.customColorRange=this.bool(r.CUSTOM_COLOR_RANGE,!1,{category:s.INVARIANT_MAP}),this.minColorValue=this.float(r.MIN_COLOR_VALUE,0,{category:s.INVARIANT_MAP}),this.maxColorValue=this.float(r.MAX_COLOR_VALUE,0,{category:s.INVARIANT_MAP}),this.showFilterControls=this.bool(r.SHOW_FILTER_CONTROLS,!0,{category:s.GENERAL,description:"Show monomer search and target controls",userEditable:!1}),this.monomerSearchInput=l.input.string("Search",{value:"",nullable:!0,placeholder:"Search monomer",tooltipText:"Search for monomer by symbol. For multiple monomers use comma as a separator.",onValueChanged:()=>{var t,e,n;const i=()=>{var t,e,n;return null===(n=null===(e=null===(t=this._viewerGrid)||void 0===t?void 0:t.dataFrame)||void 0===e?void 0:e.filter)||void 0===n?void 0:n.setAll(!0)},o=null!==(n=null===(e=null===(t=this.monomerSearchInput.value)||void 0===t?void 0:t.trim())||void 0===e?void 0:e.toLowerCase())&&void 0!==n?n:"";if(!o||null==this._viewerGrid||null==this._viewerGrid.dataFrame)return void i();const r=this._viewerGrid.dataFrame.col(d.$2.MONOMER);if(null==r)return void i();const s=o.split(",").map((t=>t.trim())).filter((t=>!!t)),a=r.toList();this._viewerGrid.dataFrame.filter.init((t=>s.some((e=>a[t].toLowerCase().includes(e)))))}})}get name(){return m.q.SEQUENCE_VARIABILITY_MAP}get mode(){var t;return null!==(t=this.dataFrame.getTag(d.gp.MONOMER_POSITION_MODE))&&void 0!==t?t:i.MUTATION_CLIFFS}set mode(t){this.dataFrame.setTag(d.gp.MONOMER_POSITION_MODE,t),this.viewerGrid.invalidate()}onTableAttached(){var t;if(super.onTableAttached(),(0,w.B2)(this.dataFrame))null===(t=this.getProperty(`${r.COLOR}${d.To}`))||void 0===t||t.set(this,this.activityColumnName);else{const t="PeptidesError: dataframe is missing Macromolecule or numeric columns";a.log.error(t),a.shell.warning(t)}this.render()}onPropertyChanged(t){var e;switch(super.onPropertyChanged(t),t.name){case o.SEQUENCE:this._invariantMapSelection=null;break;case r.SHOW_TOTAL_COUNT_COLUMN:this._viewerGrid&&this._viewerGrid.columns.byName(d.$2.TOTAL_COUNT)&&(this._viewerGrid.columns.byName(d.$2.TOTAL_COUNT).visible=this.showTotalCountColumn,this.doRender=!1)}null===(e=this.positionColumns)||void 0===e||e.forEach((t=>{t.temp[d.gp.INVARIANT_MAP_COLOR_CACHE]=null})),this.doRender?this.render():this.viewerGrid.invalidate()}createMonomerPositionDf(){const t=new Set,e=this.positionColumns;for(const e of Object.keys(this.monomerPositionStats)){if("general"===e)continue;const n=this.monomerPositionStats[e];for(const e of Object.keys(n))"general"!==e&&t.add(e)}const n=Array.from(t),i=u.Column.fromStrings(d.$2.MONOMER,n),o=u.DataFrame.fromColumns([i]),r=(0,T.pj)().then((t=>{const e=t.getMonomerLib();return e?n.map((t=>{var n,i;return null!==(i=null===(n=e.getMonomer("PEPTIDE",t))||void 0===n?void 0:n.meta)&&void 0!==i?i:{}})):n.map((t=>({})))})),s=o.columns.addNewInt(d.$2.TOTAL_COUNT),a={},l=this.monomerPositionStats;for(const t of Object.keys(l)){if("general"===t)continue;const e=l[t];for(const t of Object.keys(e))"general"!==t&&(a[t]||(a[t]=0),a[t]+=e[t].count)}s.init((t=>{var e;return null!==(e=a[i.get(t)])&&void 0!==e?e:0})),this._monomerMetaColumns.forEach((t=>{const e=o.columns.addNewString(t);r.then((n=>{e.init((e=>{var i,o;return null!==(o=null===(i=n[e][t])||void 0===i?void 0:i.toString())&&void 0!==o?o:""}))}))})),o.name="SAR";for(const t of e)o.columns.addNewBool(t.name);return o}cacheInvariantMapColors(){if(this.colorColumnName&&this.dataFrame.col(this.colorColumnName)){const t=this.dataFrame.getCol(this.colorColumnName).getRawData();let e=9999999,n=-9999999;const i="Filtered"===this.dataSource&&this.dataFrame.filter.anyFalse?this.dataFrame.filter:null,o=null==i?t=>!0:t=>i.get(t);for(const i of this.positionColumns){i.temp[d.gp.INVARIANT_MAP_COLOR_CACHE]={};const r=i.temp[d.gp.INVARIANT_MAP_COLOR_CACHE],s=i.name,a=i.getRawData(),l=i.categories;if(!this.monomerPositionStats[s])continue;const c=this.monomerPositionStats[s];for(const s of Object.keys(c)){if("general"===s)continue;const c=[];for(let t=0;t<i.length;++t)l[a[t]]===s&&o(t)&&c.push(t);const h=u.Column.float("color",c.length).init((e=>t[c[e]])).aggregate(this.colorAggregation);r[s]=h,e=Math.min(e,h),n=Math.max(n,h)}i.temp[d.gp.INVARIANT_MAP_COLOR_CACHE]=r}const r=this.customColorRange&&null!=this.minColorValue&&null!=this.maxColorValue;let s=r?this.minColorValue:e,a=r?this.maxColorValue:n;const l=this.logScaleColor&&s>1e-30&&a>1e-30&&e>1e-30&&n>1e-30;l&&(s=Math.log(s),a=Math.log(a));for(const t of this.positionColumns){const i=t.temp[d.gp.INVARIANT_MAP_COLOR_CACHE];if(i){for(const t of Object.keys(i))this.activityTarget===d.wf.LOW&&(i[t]=a-i[t]+s),i[t]=u.Color.scaleColor(l?Math.log(i[t]):i[t],s,a,void 0,[this.lowerBoundColor,this.middleColor,this.upperBoundColor]);t.temp[d.gp.INVARIANT_MAP_COLOR_CACHE]=i,t.temp[d.gp.INVARIANT_MAP_COLOR_MIN_CACHE]=e,t.temp[d.gp.INVARIANT_MAP_COLOR_MAX_CACHE]=n}}}}createViewerGrid(){const t=this.createMonomerPositionDf(),e=t.plot.grid();e.sort([d.$2.MONOMER]);const n=this.positionColumns.map((t=>t.name));e.columns.setOrder([d.$2.TOTAL_COUNT,d.$2.MONOMER,...this._monomerMetaColumns,...n]);const o=e.columns.byName(d.$2.TOTAL_COUNT);this.showTotalCountColumn&&null!=o?o.visible=!0:null!=o&&(o.visible=!1);const r=t.getCol(d.$2.MONOMER);f.rI(r,this.alphabet,!0),this.cacheInvariantMapColors(),e.onCellRender.subscribe((t=>I(t,this,this.mode===i.INVARIANT_MAP,this.dataFrame.getCol(this.colorColumnName),this.colorAggregation))),e.onCellTooltip(((t,e,n)=>{var o,r,s,a,l,c,h;if(!t.isTableCell||!(null===(o=null==t?void 0:t.cell.column)||void 0===o?void 0:o.name)||this._monomerMetaColumns.has(t.cell.column.name)||t.cell.column.name===d.$2.TOTAL_COUNT)return this.model.unhighlight(),!0;const f=this.getMonomerPosition(t);(0,w.dl)(f,this.dataFrame,this.monomerPositionStats),this.model.isHighlighting=!0;const m=this.getTotalViewerAggColumns(),p={},g={};if(this.mode===i.INVARIANT_MAP)this.colorColumnName&&this.colorAggregation&&this.colorColumnName!==this.valueColumnName?(m.unshift([this.colorColumnName,this.colorAggregation]),p[`${this.colorAggregation}(${this.colorColumnName})`]=" (color)"):this.colorColumnName&&this.colorAggregation&&this.colorColumnName===this.valueColumnName&&(p["Mean activity"]=" (color)"),this.valueColumnName&&this.valueAggregation&&this.valueAggregation!==u.AGG.VALUE_COUNT&&this.valueAggregation!==u.AGG.TOTAL_COUNT&&m.unshift([this.valueColumnName,this.valueAggregation]);else{const t=null===(s=null===(r=this.mutationCliffs)||void 0===r?void 0:r.get(f.monomerOrCluster))||void 0===s?void 0:s.get(f.positionOrClusterType);if(t){let e=0;for(const n of t.values())e+=n.length;g["Pairs count"]=e.toString()}}return(0,C.D)(this.model.df,this.getScaledActivityColumn(),m,{fromViewer:!0,isMutationCliffs:this.mode===i.MUTATION_CLIFFS,monomerPosition:f,x:e,y:n,mpStats:this.monomerPositionStats,cliffStats:null!==(l=null===(a=this.cliffStats)||void 0===a?void 0:a.stats)&&void 0!==l?l:void 0,postfixes:p,additionalStats:g,cliffIndexes:null===(h=null===(c=this.mutationCliffs)||void 0===c?void 0:c.get(f.monomerOrCluster))||void 0===h?void 0:h.get(f.positionOrClusterType)})})),e.root.addEventListener("mouseleave",(t=>this.model.unhighlight())),u.debounce(e.onCurrentCellChanged,500).subscribe((t=>{var n,o,r,s,a,l,c,h,f,p,g,v,C;try{if(!t||!t.dart||!(null===(o=null===(n=null==t?void 0:t.cell)||void 0===n?void 0:n.column)||void 0===o?void 0:o.name)||this._monomerMetaColumns.has(t.cell.column.name)||t.cell.column.name==d.$2.TOTAL_COUNT||!t.isTableCell)return;if(-1===t.gridRow&&(this.mode===i.INVARIANT_MAP?this._invariantMapSelection=(0,w.ZR)(this.positionColumns):this._mutationCliffsSelection=(0,w.ZR)(this.positionColumns),this.model.fireBitsetChanged(m.q.SEQUENCE_VARIABILITY_MAP),e.invalidate()),!this.keyPressed||t.cell.column.name===d.$2.MONOMER)return;if(null!==this.currentGridCell){const t=this.getMonomerPosition(this.currentGridCell);this.mode===i.INVARIANT_MAP?this.modifyInvariantMapSelection(t,{shiftPressed:!0,ctrlPressed:!0},!1):(null===(a=null===(s=null===(r=this.mutationCliffs)||void 0===r?void 0:r.get(t.monomerOrCluster))||void 0===s?void 0:s.get(t.positionOrClusterType))||void 0===a?void 0:a.size)&&this.modifyMutationCliffsSelection(t,{shiftPressed:!0,ctrlPressed:!0},!1)}const u=this.getMonomerPosition(t);this.mode===i.INVARIANT_MAP?this.modifyInvariantMapSelection(u,{shiftPressed:!0,ctrlPressed:!1},!0):(null===(h=null===(c=null===(l=this.mutationCliffs)||void 0===l?void 0:l.get(u.monomerOrCluster))||void 0===c?void 0:c.get(u.positionOrClusterType))||void 0===h?void 0:h.size)&&this.modifyMutationCliffsSelection(u,{shiftPressed:!0,ctrlPressed:!1},!0),e.invalidate(),setTimeout((()=>null==e?void 0:e.invalidate()),300)}catch(t){console.error(t)}finally{this.keyPressed=!1,(null===(f=t.tableColumn)||void 0===f?void 0:f.name)&&t.grid&&t.isTableCell&&(null===(p=null==t?void 0:t.cell)||void 0===p?void 0:p.column.name)!=d.$2.MONOMER&&!this._monomerMetaColumns.has(null===(v=null===(g=t.cell)||void 0===g?void 0:g.column)||void 0===v?void 0:v.name)&&(null===(C=t.cell)||void 0===C?void 0:C.column.name)!==d.$2.TOTAL_COUNT?this.currentGridCell=u.GridCell.fromColumnRow(t.grid,t.tableColumn.name,t.gridRow):this.currentGridCell=null}})),e.root.addEventListener("keydown",(t=>{if(this.keyPressed=t.key.startsWith("Arrow"),!this.keyPressed){if("Escape"===t.key||"KeyA"===t.code&&t.ctrlKey&&t.shiftKey)this.mode===i.INVARIANT_MAP?this._invariantMapSelection=(0,w.ZR)(this.positionColumns):this._mutationCliffsSelection=(0,w.ZR)(this.positionColumns);else{if("KeyA"!==t.code||!t.ctrlKey)return;{const t=Object.keys(this.monomerPositionStats).filter((t=>"general"!==t));for(const e of t){const t=Object.keys(this.monomerPositionStats[e]).filter((t=>"general"!==t));for(const n of t){const t={monomerOrCluster:n,positionOrClusterType:e};this.mode===i.INVARIANT_MAP?this.modifyInvariantMapSelection(t,{shiftPressed:!0,ctrlPressed:!1},!1):this.modifyMutationCliffsSelection(t,{shiftPressed:!0,ctrlPressed:!1},!1)}}}}this.model.fireBitsetChanged(m.q.SEQUENCE_VARIABILITY_MAP),e.invalidate()}})),e.root.addEventListener("click",(n=>{var o,r,s,a,l,u;const c=e.hitTest(n.offsetX,n.offsetY);if(!(null==c?void 0:c.isTableCell)||(null===(o=null==c?void 0:c.tableColumn)||void 0===o?void 0:o.name)===d.$2.MONOMER||(null===(r=null==c?void 0:c.tableColumn)||void 0===r?void 0:r.name)&&this._monomerMetaColumns.has(c.tableColumn.name)||(null===(s=null==c?void 0:c.tableColumn)||void 0===s?void 0:s.name)===d.$2.TOTAL_COUNT)return;const h=this.getMonomerPosition(c);this.mode===i.INVARIANT_MAP?(this.modifyInvariantMapSelection(h,{shiftPressed:n.shiftKey,ctrlPressed:n.ctrlKey}),(0,w.CD)(this.invariantMapSelection)&&(t.currentRowIdx=-1)):(null===(u=null===(l=null===(a=this.mutationCliffs)||void 0===a?void 0:a.get(h.monomerOrCluster))||void 0===l?void 0:l.get(h.positionOrClusterType))||void 0===u?void 0:u.size)&&this.modifyMutationCliffsSelection(h,{shiftPressed:n.shiftKey,ctrlPressed:n.ctrlKey}),e.invalidate()})),O(e),e.props.showRowHeader=!0;const s=e.onAfterDrawContent.subscribe((()=>{const t=e.col(d.$2.MONOMER);if(40!==t.width){t.width=40;for(const t of n)e.col(t).width=40}else s.unsubscribe()}));return e}getMonomerPosition(t){return{monomerOrCluster:t.cell.dataFrame.get(d.$2.MONOMER,t.tableRowIndex),positionOrClusterType:t.tableColumn.name}}render(){var t;if(h()(this.root).empty(),!this.activityColumnName||!this.sequenceColumnName)return void this.root.appendChild(l.divText("Please, select a sequence and activity columns in the viewer properties"));const e=this.getProperty(r.COLOR);e&&(e.choices=g()(a.shell.t.columns.numerical).toArray().map((t=>t.name)),e.get(this)===d.$2.ACTIVITY_SCALED&&e.set(this,d.$2.ACTIVITY)),h()(this.root).empty();let n=l.divText(m.q.MOST_POTENT_RESIDUES,{id:"pep-viewer-title"});if(this.name===m.q.SEQUENCE_VARIABILITY_MAP){const t=l.input.bool(i.MUTATION_CLIFFS,{value:this.mode===i.MUTATION_CLIFFS});t.root.addEventListener("click",(()=>{e.value=!1,t.value=!0,this.mode=i.MUTATION_CLIFFS})),t.setTooltip("Statistically significant changes in activity");const e=l.input.bool(i.INVARIANT_MAP,{value:this.mode===i.INVARIANT_MAP});e.root.addEventListener("click",(()=>{t.value=!1,e.value=!0,this.mode=i.INVARIANT_MAP})),e.setTooltip("Number of sequences having monomer-position");const o=t=>{h()(t.root).find(".ui-input-editor").css("margin","0px").attr("type","radio"),h()(t.root).find(".ui-input-description").css("padding","0px").css("padding-right","16px"),h()(t.captionLabel).addClass("ui-label-right")};o(t),o(e),n=l.divH([t.root,e.root],{id:"pep-viewer-title"}),h()(n).css("width","auto").css("align-self","center")}const o=this.viewerGrid.root;o.style.width="auto";const s=l.icons.search((()=>{this._showSearchInput=!this._showSearchInput,this.monomerSearchInput.input.style.display=this._showSearchInput?"block":"none"}),"Toggle monomer search input visibility");this.monomerSearchInput.input.style.display=this._showSearchInput?"block":"none",h()(s).addClass("pep-help-icon"),(0,w.BX)(s.style).set("top","3px").set("fontSize","14px");const u=l.divH([this.monomerSearchInput.input],{style:{alignSelf:"center",justifyContent:"center",width:"100%",flexWrap:"wrap"}}),c=l.divH([s,n,u],{style:{alignSelf:"center",lineHeight:"normal",flexDirection:"column",width:"100%"}});this.root.appendChild(l.divV([c,o])),null===(t=this.viewerGrid)||void 0===t||t.invalidate(),this.monomerSearchInput.fireChanged()}}class M extends N{constructor(){super(),this.currentGridRowIdx=null}get name(){return m.q.MOST_POTENT_RESIDUES}onTableAttached(){super.onTableAttached(),this.render()}onPropertyChanged(t){super.onPropertyChanged(t),this.doRender&&this.render()}onFilterChanged(t,e=!1){if(this._monomerPositionStats=null,this._invariantMapSelection=null,this._mutationCliffStats=null,this._mutationCliffsSelection=null,this._mutationCliffs=null,e)return;this._viewerGrid=null;const n=this.model.findViewer(m.q.SEQUENCE_VARIABILITY_MAP);"Filtered"===(null==n?void 0:n.dataSource)&&n.onFilterChanged(!1,!0),t&&this.render()}createMostPotentResiduesDf(){var t;const e=Object.entries(this.monomerPositionStats),n=new Array(e.length-1),i=new Array(n.length),o=new Array(n.length),r=new Array(n.length),s=new Array(n.length),a=new Array(n.length),l=new Array(n.length),c=this.getTotalViewerAggColumns(),h=c.map((([t,e])=>(0,v.hX)(e,t))),f=new Array(h.length);h.forEach(((t,e)=>f[e]=new Array(n.length)));let m=0;for(const[p,g]of e){const e=g.general;if(!e)continue;if(1===Object.entries(g).length)continue;const C=[];for(const[n,i]of Object.entries(g))"general"!==n&&(i.count>1&&(null==i.pValue||(null!==(t=i.pValue)&&void 0!==t?t:1)<=.05)&&C.push([n,i]),i.pValue===e.minPValue&&C.push([n,i]));let y=null;0===C.length&&(y=Object.entries(g).find((([t,e])=>"general"!=t)));for(const[t,e]of C)(null===y||this.activityTarget===d.wf.HIGH&&y[1].meanDifference<e.meanDifference||this.activityTarget===d.wf.LOW&&y[1].meanDifference>e.meanDifference)&&(y=[t,e]);if(null===y)continue;n[m]=parseInt(p),i[m]=y[0],o[m]=y[1].meanDifference,r[m]=y[1].pValue,s[m]=y[1].count,a[m]=y[1].ratio,l[m]=y[1].mean;const w=this.monomerPositionStats[p][y[0]],b=u.BitSet.fromBytes(w.mask.buffer.buffer,this.model.df.col(this.activityColumnName).length);for(let t=0;t<h.length;t++){const[e,n]=c[t];f[t][m]=(0,v.lh)(this.model.df.getCol(e),n,b)}++m}n.length=m,i.length=m,o.length=m,r.length=m,s.length=m,a.length=m,l.length=m;const p=u.DataFrame.create(m),g=p.columns;return g.add(u.Column.fromList(u.TYPE.INT,d.$2.POSITION,n)),g.add(u.Column.fromList(u.TYPE.STRING,d.$2.MONOMER,i)),g.add(u.Column.fromList(u.TYPE.FLOAT,d.$2.MEAN_DIFFERENCE,o)),g.add(u.Column.fromList(u.TYPE.FLOAT,d.$2.MEAN,l)),g.add(u.Column.fromList(u.TYPE.FLOAT,d.$2.P_VALUE,r)),g.add(u.Column.fromList(u.TYPE.INT,d.$2.COUNT,s)),g.add(u.Column.fromList(u.TYPE.FLOAT,d.$2.RATIO,a)),h.forEach(((t,e)=>g.add(u.Column.fromList(u.TYPE.FLOAT,t,f[e])))),p}createViewerGrid(){const t=this.createMostPotentResiduesDf(),e=t.plot.grid();e.sort([d.$2.POSITION]);const n=e.col(d.$2.P_VALUE);n.format="#.000",n.name="P-value";const i=t.getCol(d.$2.MONOMER);f.rI(i,this.alphabet,!0),e.onCellRender.subscribe((t=>I(t,this,!1))),e.onCellTooltip(((t,e,n)=>{var i,o;if(!t.isTableCell)return this.model.unhighlight(),!0;const r=this.getMonomerPosition(t);if((0,w.dl)(r,this.dataFrame,this.monomerPositionStats),this.model.isHighlighting=!0,(null===(i=t.tableColumn)||void 0===i?void 0:i.name)===d.$2.MONOMER)r.positionOrClusterType=d.$2.MONOMER;else if((null===(o=t.tableColumn)||void 0===o?void 0:o.name)!==d.$2.MEAN_DIFFERENCE)return!1;const s=this.getTotalViewerAggColumns(),a=null==t.tableRowIndex?void 0:(0,v.m2)(t.grid.dataFrame,t.tableRowIndex,s,{});return(0,C.D)(this.model.df,this.getScaledActivityColumn(),s,{fromViewer:!0,isMostPotentResidues:!0,monomerPosition:r,x:e,y:n,mpStats:this.monomerPositionStats,aggrColValues:a})})),u.debounce(e.onCurrentCellChanged,500).subscribe((n=>{var i,o,r;try{if(-1===n.gridRow)return this._mutationCliffsSelection=(0,w.ZR)(this.positionColumns),this._invariantMapSelection=(0,w.ZR)(this.positionColumns),this.model.fireBitsetChanged(m.q.MOST_POTENT_RESIDUES),void e.invalidate();if(this.keyPressed&&t.currentCol.name!==d.$2.MEAN_DIFFERENCE||!this.keyPressed)return;const s=this.getMonomerPosition(n);if(null!==this.currentGridRowIdx){const t=this.getMonomerPosition(e.cell("Diff",this.currentGridRowIdx));this.modifyInvariantMapSelection(t,{shiftPressed:!0,ctrlPressed:!0},!1)}(null===(r=null===(o=null===(i=this.mutationCliffs)||void 0===i?void 0:i.get(s.monomerOrCluster))||void 0===o?void 0:o.get(s.positionOrClusterType))||void 0===r?void 0:r.size)&&this.modifyInvariantMapSelection(s,{shiftPressed:!0,ctrlPressed:!1}),e.invalidate()}finally{this.keyPressed=!1,this.currentGridRowIdx=n.gridRow}})),e.root.addEventListener("keydown",(n=>{if(this.keyPressed=n.key.startsWith("Arrow"),!this.keyPressed){if("Escape"===n.key||"KeyA"===n.code&&n.ctrlKey&&n.shiftKey)this._mutationCliffsSelection=(0,w.ZR)(this.positionColumns);else{if("KeyA"!==n.code||!n.ctrlKey)return;for(let n=0;n<t.rowCount;++n){const t=this.getMonomerPosition(e.cell("Diff",n));this.modifyInvariantMapSelection(t,{shiftPressed:!0,ctrlPressed:!1},!1)}}this.model.fireBitsetChanged(m.q.MOST_POTENT_RESIDUES),e.invalidate()}})),e.root.addEventListener("mouseleave",(t=>this.model.unhighlight())),e.root.addEventListener("click",(t=>{var n,i,o;const r=e.hitTest(t.offsetX,t.offsetY);if(!(null==r?void 0:r.isTableCell)||r.tableColumn.name!==d.$2.MEAN_DIFFERENCE)return;const s=this.getMonomerPosition(r);(null===(o=null===(i=null===(n=this.monomerPositionStats)||void 0===n?void 0:n[s.positionOrClusterType])||void 0===i?void 0:i[s.monomerOrCluster])||void 0===o?void 0:o.count)&&(this.modifyInvariantMapSelection(s,{shiftPressed:t.shiftKey,ctrlPressed:t.ctrlKey}),e.invalidate())})),O(e);const o=e.col(d.$2.MEAN_DIFFERENCE);o.name="Diff";const r=e.onAfterDrawContent.subscribe((()=>{const t=e.col(d.$2.MONOMER);if(40===t.width)return o.width=40,void r.unsubscribe();t.width=40,o.width=40}));return e}getMonomerPosition(t){return{monomerOrCluster:t.cell.dataFrame.get(d.$2.MONOMER,t.tableRowIndex),positionOrClusterType:`${t.cell.dataFrame.get(d.$2.POSITION,t.tableRowIndex)}`}}render(){var t;if(h()(this.root).empty(),!this.activityColumnName||!this.sequenceColumnName)return void this.root.appendChild(l.divText("Please, select a sequence and activity columns in the viewer properties"));const e=this.viewerGrid.root;e.style.width="auto",this.root.appendChild(l.divV([e])),null===(t=this.viewerGrid)||void 0===t||t.invalidate()}}function I(t,e,n,i,o){var r,s,a,l,c;const h=[...e.positionColumns.map((t=>t.name)),d.$2.MEAN_DIFFERENCE],m=t.g,p=t.bounds;m.save(),m.beginPath(),m.rect(p.x,p.y,p.width,p.height),m.clip();const g=t.cell,v=null===(r=g.tableColumn)||void 0===r?void 0:r.name,C=g.tableRowIndex;if(!g.isTableCell||-1===h.indexOf(v))return void m.restore();const y=g.grid.table,w=y.get(d.$2.MONOMER,C),b=v!==d.$2.MEAN_DIFFERENCE?v:y.get(d.$2.POSITION,C).toFixed(),A=e.monomerPositionStats[b];if(!A[w])return t.preventDefault(),void m.restore();if(n){const t=null!==(s=A[w].aggValue)&&void 0!==s?s:A[w].count,n=e.positionColumns.find((t=>t.name===b)),i=null!==(a=n.temp[d.gp.INVARIANT_MAP_COLOR_CACHE])&&void 0!==a?a:{};let o=u.Color.white;null!=i[w]?o=i[w]:e instanceof x&&(e.cacheInvariantMapColors(),o=null!==(c=(null!==(l=n.temp[d.gp.INVARIANT_MAP_COLOR_CACHE])&&void 0!==l?l:{})[w])&&void 0!==c?c:u.Color.white),f.rW(m,w,b,e.invariantMapSelection,t,p,o)}else f.Yd(m,w,b,e,p);t.preventDefault(),m.restore()}function O(t){const e=t.props;e.allowEdit=!1,e.allowRowSelection=!1,e.allowBlockSelection=!1,e.allowColSelection=!1,e.showRowHeader=!1,e.showCurrentRowIndicator=!1,e.showReadOnlyNotifications=!1,e.rowHeight=20}},7654:(t,e,n)=>{"use strict";n.d(e,{HV:()=>p,M1:()=>g,QD:()=>v});var i,o=n(7389),r=n(6082),s=n(7233),a=n.n(s),l=n(4139),u=n(5070),c=n(8608),h=n(5480),d=n(8774);!function(t){t.SEPARATE_MONOMERS="separateMonomers",t.SEPARATE_POSITIONS="separatePositions",t.SEPARATE_CLUSTERS="separateClusters"}(i||(i={}));const f="general",m=t=>t===f?"General":t.substring(8);function p(t,e){if(!t.selection.anyTrue)return o.divText("No distribution");const n=()=>{const n=[y(f,t,e)];for(const o of Object.values(i))"true"!==t.getTag(o)||o===i.SEPARATE_CLUSTERS&&!e.clusterColName||n.push(y(o,t,e));return 1===n.length?n[0]:o.div(n)},r=o.div(n()),s=Object.values(i),l=new Array(s.length);for(let u=0;u<s.length;u++){const c=s[u].substring(8);l[u]=o.input.bool(c,{value:"true"===t.getTag(s[u]),onValueChanged:e=>{t.setTag(s[u],`${e}`),a()(r).empty(),r.append(n())}}),a()(l[u].captionLabel).addClass("ui-label-right").css("text-align","left"),a()(l[u].root).find(".ui-input-editor").css("margin","0px"),a()(l[u].root).find(".ui-input-description").css("margin","0px"),l[u].setTooltip(`Show distribution for each ${c}`),c===i.SEPARATE_CLUSTERS?l[u].enabled=!(!e.clusterColName||!e.clusterSelection[h.W.ORIGINAL]):c!==i.SEPARATE_MONOMERS&&c!==i.SEPARATE_POSITIONS||(l[u].enabled=0!==Object.entries(e.monomerPositionSelection).length)}const u=o.form(l,{style:{flexDirection:"row"}});return o.divV([u,r])}function g(t,e=!1){const n=t.plot.histogram({filteringEnabled:!1,valueColumnName:l.$2.ACTIVITY,splitColumnName:l.$2.SPLIT_COL,legendVisibility:"Never",showXAxis:!0,showColumnSelector:!1,showRangeSlider:!1,showBinSelector:!1,backColor:e?"#fdffe5":"#fffff"});return n.root.style.width="auto",n}function v(t,e={}){var n,i;null!==(n=e.fractionDigits)&&void 0!==n||(e.fractionDigits=3);const o={[null!==(i=null==e?void 0:e.countName)&&void 0!==i?i:"Count"]:`${t.count} (${(100*t.ratio).toFixed(e.fractionDigits)}%)`,"Mean difference":t.meanDifference.toFixed(e.fractionDigits),"Mean activity":t.mean.toFixed(e.fractionDigits)};return null!=t.pValue&&(o["p-value"]=t.pValue<.01?"<0.01":t.pValue.toFixed(e.fractionDigits)),o}function C(t,e,n,i={}){const o=g((0,c.FZ)(n.activityCol,t.selection,t)),s=(0,u.I_)(t,Object.entries(n.columns),{filterDf:!0,mask:r.BitSet.fromBytes(e.mask.buffer.buffer,e.mask.length)}),l=v(e),h=Object.assign(Object.assign({},l),s),d=(0,c.F2)(o,h,i);return a()(d).addClass("d4-flex-col"),d}function y(t,e,n){let r=o.divText("No distribution");const s=e.selection.clone().and(e.filter),a=d.A.fromUint32Array(s.length,new Uint32Array(s.getBuffer().buffer));switch(t){case f:r=C(e,e.selection.anyTrue&&e.selection.anyFalse?(0,u.GT)(n.activityCol.getRawData(),a,(0,u.pY)(e.filter)):{count:n.activityCol.length,pValue:null,meanDifference:0,ratio:1,mask:a,mean:n.activityCol.stats.avg},n);break;case i.SEPARATE_CLUSTERS:r=function(t,e,n){const i=t.rowCount,r=[],s=e.activityCol.getRawData(),a=t.getCol(e.clusterColName),l=a.categories,f=a.getRawData(),m=(0,u.pY)(t.filter),p=n[h.W.ORIGINAL].map((t=>l.indexOf(t))),g=new Array(p.length).fill(new d.A(i));for(let t=0;t<i;t++){const e=f[t],n=p.indexOf(e);-1!==n&&g[n].setTrue(t)}for(let n=0;n<p.length;n++){const i=p[n],o=(0,u.GT)(s,g[n],m);r.push(C(t,o,e,{[c.AN.SELECTION]:l[i]}))}const v=n[h.W.CUSTOM];for(const n of v){const o=t.getCol(n),a=d.A.fromUint32Array(i,o.getRawData()),l=(0,u.GT)(s,a,m);r.push(C(t,l,e,{[c.AN.SELECTION]:n}))}return o.div(r,"d4-flex-wrap")}(e,n,n.clusterSelection);break;case i.SEPARATE_MONOMERS:r=function(t,e,n){var i,r,s;const a=Object.keys(n),l=t.rowCount,h=[],f=[],m=[],p=[],g=e.activityCol.getRawData(),v=(0,u.pY)(t.filter);for(const o of a){const a=n[o],y=new d.A(l);for(let e=0;e<a.length;e++){const n=a[e];null!==(i=f[e])&&void 0!==i||(f[e]=t.getCol(n)),null!==(r=m[e])&&void 0!==r||(m[e]=f[e].categories),null!==(s=p[e])&&void 0!==s||(p[e]=f[e].getRawData());const u=m[e].indexOf(o);for(let t=0;t<l;t++)p[e][t]===u&&y.setTrue(t)}const w=(0,u.GT)(g,y,v);h.push(C(t,w,e,{[c.AN.SELECTION]:o}))}return o.div(h,"d4-flex-wrap")}(e,n,function(t){const e={},n=Object.keys(t);for(const i of n)for(const n of t[i])e.hasOwnProperty(n)?e[n].includes(i)||e[n].push(i):e[n]=[i];return e}(n.monomerPositionSelection));break;case i.SEPARATE_POSITIONS:r=function(t,e,n){var i,r,s;const a=Object.keys(n),l=t.rowCount,h=[],f=e.activityCol.getRawData(),m=[],p=[],g=[],v=(0,u.pY)(t.filter);for(let o=0;o<a.length;o++){const y=a[o],w=n[y];if(0===w.length)continue;null!==(i=m[o])&&void 0!==i||(m[o]=t.getCol(y)),null!==(r=p[o])&&void 0!==r||(p[o]=m[o].categories),null!==(s=g[o])&&void 0!==s||(g[o]=m[o].getRawData());const b=new d.A(t.rowCount);for(let t=0;t<w.length;t++){const e=w[t],n=p[o].indexOf(e);for(let t=0;t<l;t++)g[o][t]===n&&b.setTrue(t)}const A=(0,u.GT)(f,b,v);h.push(C(t,A,e,{[c.AN.SELECTION]:y}))}return o.div(h,"d4-flex-wrap")}(e,n,n.monomerPositionSelection)}return o.divV([o.h1(m(t)),r])}},7923:(t,e,n)=>{"use strict";n.d(e,{F:()=>c});var i=n(7389),o=n(6082),r=n(4139),s=n(8608),a=n(3163),l=n(4025),u=n(7654);function c(t,e,n=!0){var r,a,l,c,d;const f=h(t,e);if(!f)return new o.Widget(i.label("No mutations table generated"));const{pairsGrid:m,uniqueSequencesGrid:p,aminoToInput:g}=f,v=[m,p],C=i.divV([g.root,...v.map((t=>t.root))],{style:{width:"100%"}});if(1===Object.values(e.mutationCliffsSelection).filter((t=>t.length>0)).length){const t=Object.keys(e.mutationCliffsSelection).find((t=>e.mutationCliffsSelection[t].length>0)),n=e.mutationCliffsSelection[t];if(1===n.length){const i=n[0],o=null===(a=null===(r=e.mutationCliffs)||void 0===r?void 0:r.get(i))||void 0===a?void 0:a.get(t);if(o&&o.size>0){const n=(0,s.Z7)(e.activityCol,o,i),r=(0,u.M1)(n,!1),a=null===(d=null===(c=null===(l=e.mutationCliffStats)||void 0===l?void 0:l.stats)||void 0===c?void 0:c.get(i))||void 0===d?void 0:d.get(t),h={};let f=0;for(const t of o.values())f+=t.length;h["Pairs count"]=f.toString(),a&&(h["Unique Count"]=a.mask.trueCount().toString(),Object.assign(h,(0,u.QD)(a,{countName:"MP in cliffs count"})));const m=(0,s.F2)(r,h);r.root.style.maxHeight="100px",m.style.marginTop="10px",C.appendChild(m)}}}return n&&(0,s.BE)("Mutation Cliffs pairs",g.root,C,(()=>{const n=h(t,e),o=i.splitH([i.divV([n.aminoToInput.root,n.pairsGrid.root],{style:{marginRight:"10px"}}),i.divV([n.uniqueSequencesGrid.root],{style:{marginLeft:"10px"}})],{style:{width:"100%",height:"100%"}},!0);return setTimeout((()=>{var t,i;if(document.contains(o)){const r=o.offsetWidth,s=null===(t=n.pairsGrid.canvas)||void 0===t?void 0:t.parentElement;n.pairsGrid.props.showRowHeader=!0,n.uniqueSequencesGrid.props.showRowHeader=!0;const a=null===(i=n.uniqueSequencesGrid.canvas)||void 0===i?void 0:i.parentElement;if(s&&a&&(s.style.height="100%",a.style.height="calc(100% - 20px)",a.style.marginTop="20px",r>400)){const t=Math.max(.33*r,200),i=n.pairsGrid.columns.byName("Mutation");i&&(i.width=t);const o=n.uniqueSequencesGrid.columns.byName(e.sequenceColumnName);o&&(o.width=t)}}}),500),o})),new o.Widget(C)}function h(t,e){var n,u;const c=t.filter.getSelectedIndexes(),h=Object.keys(e.mutationCliffsSelection);if(!h.length||null===e.mutationCliffs)return null;const d=[],f=[],m=[],p=[],g=[],v=[],C=t.getCol(e.sequenceColumnName),y=C.categories,w=C.getRawData(),b=e.activityCol.getRawData(),A=new Map,S=o.BitSet.create(t.rowCount),T={},E=Object.fromEntries(e.positionColumns.map((t=>[t.name,t])));for(const t of h){const i=E[t],o=i.categories,r=i.getRawData();for(const i of e.mutationCliffsSelection[t]){const s=null===(n=e.mutationCliffs.get(i))||void 0===n?void 0:n.get(t);if(void 0!==s)for(const[t,n]of s.entries()){if(!c.includes(t))continue;T[t]||(T[t]=Object.keys(T).length+1);const i=T[t],s=null!==(u=A.get(t))&&void 0!==u?u:[],a=y[w[t]],l=b[t],h=e.activityCol.isNone(t)?null:l;for(const l of n){if(s.includes(l)||!c.includes(l))continue;A.has(l)||A.set(l,[]);const n=y[w[l]],u=e.activityCol.isNone(l)?null:b[l],C=null==h||null==u?null:h-u;A.get(l).push(t),d.push(`${a}#${n}`),p.push(`${i}`),f.push(C),m.push(o[r[l]]),g.push(t),v.push(l),S.set(t,!0),S.set(l,!0)}}}}if(0===d.length)return null;const _=o.Column.fromStrings("Mutation",d),N=o.Column.fromList("double","Delta",f),x=o.Column.fromStrings("Group",p),M=o.Column.fromStrings("~to",m),I=o.Column.fromList(o.COLUMN_TYPE.INT,"~toIdx",v),O=o.Column.fromList(o.COLUMN_TYPE.INT,"~fromIdx",g),L=o.DataFrame.fromColumns([_,N,x,M,I,O]);L.name="Mutation Cliff pairs";const P=i.input.string("Mutated to:",{value:"",onValueChanged:t=>{const e=t;""!==e?L.filter.init((t=>M.get(t)===e)):L.filter.setAll(!0)}});P.setTooltip("Filter the rows by the monomer that the mutation was substituted to");const R=L.plot.grid();(0,s.vY)(R,!0),_.semType=r.uF.MACROMOLECULE_DIFFERENCE,_.tags[r.gp.SEPARATOR]=(0,s.AY)(C),_.tags[o.TAGS.UNITS]=C.tags[o.TAGS.UNITS],_.tags[o.TAGS.CELL_RENDERER]="MacromoleculeDifference",_.temp[l.j.notationProvider]=C.temp[l.j.notationProvider];let k=!1,V=null;const F=[];R.onCurrentCellChanged.subscribe((t=>{try{if(!t||!t.dart)return F.length=0,void j();const e=t.tableRowIndex;if(!k)return;if(null===e)return F.length=0,void j();null!==V&&F.splice(F.indexOf(V),1),F.includes(e)||(F.push(e),R.invalidate()),j()}finally{k=!1,V=t&&t.dart?t.tableRowIndex:null}})),R.root.addEventListener("keydown",(t=>{k=t.key.startsWith("Arrow")})),R.root.addEventListener("click",(t=>{const e=R.hitTest(t.offsetX,t.offsetY);if(!e||null===e.tableRowIndex)return;const n=e.tableRowIndex;if(t.shiftKey){const t=F.indexOf(n);-1===t?F.push(n):F.splice(t,1)}else F.length=0,F.push(n);j(),R.invalidate(),Y.invalidate()})),R.onCellPrepare((t=>{var e,n,i,r;if((null==t?void 0:t.isTableCell)&&"delta"==(null===(n=null===(e=null==t?void 0:t.gridColumn)||void 0===e?void 0:e.name)||void 0===n?void 0:n.toLowerCase())&&(null==(null===(i=null==t?void 0:t.cell)||void 0===i?void 0:i.value)||(null===(r=null==t?void 0:t.cell)||void 0===r?void 0:r.value)==o.FLOAT_NULL))try{t.customText="N/A"}catch(t){}})),R.onCellRender.subscribe((t=>{var e;(null===(e=t.cell.tableColumn)||void 0===e?void 0:e.name)===_.name&&F.includes(t.cell.tableRowIndex)&&(0,a.X5)(t.g,t.bounds)}));const D=e.gridColumns.length,G=[];for(let t=1;t<D;t++){const n=e.gridColumns.byIndex(t);((null==n?void 0:n.name)===e.sequenceColumnName||!0===(null==n?void 0:n.visible)&&!Object.hasOwn(E,n.name))&&G.push(n.name)}const U=t.clone(S,G);U.name="Unique sequences that form Mutation Cliffs pairs";const q=U.columns.addNewInt("~seqIdx"),B=q.getRawData();U.col(e.sequenceColumnName)&&(U.col(e.sequenceColumnName).temp[l.j.notationProvider]=C.temp[l.j.notationProvider]);const H=S.getSelectedIndexes();q.init((t=>H[t]));const Y=U.plot.grid();function j(){const t=[];for(const e of F)t.push(O.get(e)),t.push(I.get(e));U.filter.init((e=>0===F.length||t.includes(B[e])),!0),R.invalidate(),Y.invalidate()}return(0,s.vY)(Y,!0),Y.props.rowHeight=20,R.root.style.width="100% !important",Y.root.style.width="100% !important",setTimeout((()=>{R.autoSize(window.innerWidth,250,void 0,void 0,!1),Y.autoSize(window.innerWidth,250,void 0,void 0,!1),R.root.style.removeProperty("width"),R.root.style.setProperty("width","100%"),Y.root.style.removeProperty("width"),Y.root.style.setProperty("width","100%"),R.root.style.minHeight="70px",Y.root.style.minHeight="100px",R.root.style.height="unset",Y.root.style.height="unset"}),200),{pairsGrid:R,uniqueSequencesGrid:Y,aminoToInput:P}}},5082:(t,e,n)=>{"use strict";n.d(e,{n:()=>g,v:()=>p});var i=n(4328),o=n(7389),r=n(6082),s=n(4139),a=n(115),l=n(9499),u=n(7233),c=n.n(u),h=n(8608),d=n(1199),f=n(5429),m=(n(4788),function(t,e,n,i){return new(n||(n=Promise))((function(o,r){function s(t){try{l(i.next(t))}catch(t){r(t)}}function a(t){try{l(i.throw(t))}catch(t){r(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(s,a)}l((i=i.apply(t,e||[])).next())}))});function p(t,e){const n=new a.av,l=o.div();let u=null;if(void 0===e){const e=r.Utils.firstOrNull(t.columns.toList().filter((t=>t.semType===r.SEMTYPE.MACROMOLECULE)));if(null===e)throw new Error("Peptides Error: table doesn't contain sequence columns");0!==e.stats.missingValueCount&&i.shell.info("Sequences column contains missing values. They will be ignored during analysis"),u=o.input.column("Sequence",{table:t,value:e,onValueChanged:e=>{c()(l).empty().append(o.wait((()=>m(this,void 0,void 0,(function*(){const n=yield t.plot.fromType("WebLogo",{sequenceColumnName:e.name});return n.root.style.setProperty("height","130px"),n.root}))))),0!==e.stats.missingValueCount&&i.shell.info("Sequences column contains missing values. They will be ignored during analysis")},filter:t=>t.semType===r.SEMTYPE.MACROMOLECULE,nullable:!1}),u.setTooltip("Macromolecule column in FASTA, HELM or separated format")}let p,v=r.Func.find({package:"Bio",name:"webLogoViewer"});if(0===v.length)return{host:o.label("Bio package is missing or out of date. Please install the latest version."),callback:()=>m(this,void 0,void 0,(function*(){return!1}))};if(v=r.Func.find({package:"Bio",name:"getBioLib"}),0===v.length)return{host:o.label("Bio package is missing or out of date. Please install the latest version."),callback:()=>m(this,void 0,void 0,(function*(){return!1}))};const C=t.col("activity")||t.col("IC50")||r.Utils.firstOrNull(t.columns.numerical),y=o.div([],{id:"pep-hist-host"}),w=o.input.choice("Scaling",{value:s.rg.NONE,items:Object.values(s.rg),onValueChanged:t=>m(this,void 0,void 0,(function*(){var e;p=(0,h.Y1)(A.value,t);const n=r.DataFrame.fromColumns([p]).plot.histogram({filteringEnabled:!1,valueColumnName:s.$2.ACTIVITY,legendVisibility:"Never",showXAxis:!0,showColumnSelector:!1,showRangeSlider:!1,showBinSelector:!1});null===(e=y.lastChild)||void 0===e||e.remove(),y.appendChild(n.root)}))});w.setTooltip("Activity column transformation method");const b=()=>{var t;w.enabled=null!==(t=A.value)&&void 0!==t&&t&&A.value.stats.min>0,w.value=s.rg.NONE,0!==A.value.stats.missingValueCount&&i.shell.info("Activity column contains missing values. They will be ignored during analysis")},A=o.input.column("Activity",{table:t,value:C,nullable:!1,onValueChanged:b,filter:t=>t.type===r.TYPE.INT||t.type===r.TYPE.FLOAT||t.type===r.TYPE.QNUM});A.setTooltip("Numerical activity column");const S=o.input.column("Clusters",{table:t,onValueChanged:t=>{t&&(T.value=!1,T.fireChanged())}});S.setTooltip("Optional. Clusters column is used to create Logo Summary Table"),S.nullable=!0;const T=o.input.bool("Generate clusters",{value:!0,onValueChanged:t=>{t&&(S.value=null,S.fireChanged())}});T.setTooltip("Generate clusters column based on MCL embeddings for Logo Summary Table"),A.fireChanged(),w.fireChanged(),T.fireChanged();const E=[A,w,S,T];null!==u&&E.splice(0,0,u);const _=o.input.float(f.t_.THRESHOLD,{value:n.threshold,nullable:!1,onValueChanged:t=>n.threshold=null!=t?t:n.threshold});_.setTooltip("Threshold for similarity between two sequences to create edges");const N=o.input.float(f.t_.INFLATION,{value:n.inflation,nullable:!1,onValueChanged:t=>n.inflation=null!=t?t:n.inflation});N.setTooltip("Inflation value for MCL algorithm");const x=o.input.int(f.t_.MAX_ITERATIONS,{value:n.maxIterations,nullable:!1,onValueChanged:t=>n.maxIterations=null!=t?t:n.maxIterations});x.setTooltip("Maximum iterations for MCL algorithm");const M=o.input.bool(f.t_.USE_WEBGPU,{value:n.useWebGPU,onValueChanged:t=>n.useWebGPU=t});M.enabled=!1,n.webGPUDescriptionPromise.then((()=>{n.webGPUDescription!==a.Ku?(M.setTooltip(`Use WebGPU for MCL algorithm (${n.webGPUDescription})`),M.enabled=!0):(M.setTooltip(a.Ku),M.enabled=!1,M.value=!1)}));const I=o.input.int(f.t_.MIN_CLUSTER_SIZE,{value:n.minClusterSize,nullable:!1,onValueChanged:t=>n.minClusterSize=null!=t?t:n.minClusterSize});I.setTooltip("Minimum cluster size for MCL algorithm");const O=o.input.choice(f.t_.DISTANCE_FUNCTION,{value:n.distanceF,items:[d.Z.NEEDLEMANN_WUNSCH,d.Z.MONOMER_CHEMICAL_DISTANCE,d.Z.HAMMING,d.Z.LEVENSHTEIN],nullable:!1,onValueChanged:t=>n.distanceF=t}),L=o.input.float(f.t_.GAP_OPEN,{value:n.gapOpen,onValueChanged:t=>n.gapOpen=null!=t?t:n.gapOpen}),P=o.input.float(f.t_.GAP_EXTEND,{value:n.gapExtend,onValueChanged:t=>n.gapExtend=null!=t?t:n.gapExtend}),R=[_,N,x,I,O,o.input.choice(f.t_.FINGERPRINT_TYPE,{value:n.fingerprintType,items:["Morgan","RDKit","Pattern","AtomPair","MACCS","TopologicalTorsion"],nullable:!1,onValueChanged:t=>n.fingerprintType=t}),L,P,M],k=o.form(R);k.style.display="none";const V=o.icons.settings((()=>{k.style.display="none"===k.style.display?"flex":"none",k.classList.remove("ui-form-condensed")}),"Adjust clustering parameters");V.style.fontSize="16px",T.root.appendChild(V);const F=t.filter.onChanged.subscribe((()=>b())),D=()=>m(this,void 0,void 0,(function*(){var i,o;const r=null!=e?e:u.value;return F.unsubscribe(),!!r&&null!==(yield g(A.value,r,S.value,t,p,null!==(i=w.value)&&void 0!==i?i:s.rg.NONE,{addSequenceSpace:!1,addMCL:T.value,useEmbeddingsClusters:null!==(o=T.value)&&void 0!==o&&o,mclSettings:n}))}));let G="auto";const U=[o.divV(E)];if(c()(U[0]).find("label").css("width","unset"),void 0!==e){const t=o.button("Launch SAR",D,"");t.style.alignSelf="center",U.push(t),G="215px"}return c()(l).empty().append(o.wait((()=>m(this,void 0,void 0,(function*(){var n;const i=yield t.plot.fromType("WebLogo",{sequenceColumnName:null!==(n=null==e?void 0:e.name)&&void 0!==n?n:u.value.name});return i.root.style.setProperty("height","130px"),i.root}))))),{host:o.divV([l,o.splitH([o.splitV(U),y],{style:{height:G,minWidth:"500px",maxWidth:"600px"}}),k]),callback:D}}function g(t,e,n,o,u,c){return m(this,arguments,void 0,(function*(t,e,n,o,u,c,h={}){var d,f,m,p,g;let v=null;if(t.type!==r.COLUMN_TYPE.FLOAT&&t.type!==r.COLUMN_TYPE.INT&&t.type!==r.COLUMN_TYPE.QNUM)return i.shell.error("The activity column must be of numeric type!"),v;const C=r.TaskBarProgressIndicator.create("Loading SAR...");o.tags.delete&&o.tags.delete(".script");const y=o.columns,w=o.col(u.name);w&&(w.name=y.getUnusedName(w.name));const b=u.getRawData();o.columns.addNew(u.name,u.type).init((t=>b[t])),y.setOrder([u.name,e.name,...y.names().filter((t=>t!==e.name&&t!==u.name))]);const A={sequenceColumnName:e.name,activityColumnName:t.name,activityScaling:c,columns:{},showDendrogram:!1,showSequenceSpace:!1,sequenceSpaceParams:new a.GI(!!h.useEmbeddingsClusters&&!n),mclSettings:null!==(d=h.mclSettings)&&void 0!==d?d:new a.av};if(n){const t=o.getCol(n.name);t.type!==r.COLUMN_TYPE.STRING&&y.replace(t,t.convertTo(r.COLUMN_TYPE.STRING))}if(o.setTag(s.gp.SETTINGS,JSON.stringify(A)),v=l.i.getInstance(o),v.init(A),n){const i={clustersColumnName:n.name,sequenceColumnName:e.name,activityScaling:c,activityColumnName:t.name};yield v.addLogoSummaryTable(i)}if(yield v.addMonomerPosition(),yield v.addMostPotentResidues(),null!==(f=h.addSequenceSpace)&&void 0!==f&&f){if(yield v.addSequenceSpace({clusterCol:n,clusterEmbeddings:h.useEmbeddingsClusters}),!n&&null!==(m=h.useEmbeddingsClusters)&&void 0!==m&&m){const n=v._sequenceSpaceCols.find((t=>{var e;return v.df.col(t)&&(null===(e=v.df.col(t))||void 0===e?void 0:e.type)===r.COLUMN_TYPE.STRING}));if(n){const i={clustersColumnName:n,sequenceColumnName:e.name,activityScaling:c,activityColumnName:t.name};yield v.addLogoSummaryTable(i),setTimeout((()=>{var t,e;v&&(null===(t=null==v?void 0:v.findViewer(l.q.LOGO_SUMMARY_TABLE))||void 0===t?void 0:t.render)&&(null===(e=null==v?void 0:v.findViewer(l.q.LOGO_SUMMARY_TABLE))||void 0===e||e.render())}),100)}}}else if(null!==(p=h.addMCL)&&void 0!==p&&p&&(yield v.addMCLClusters(),!n&&null!==(g=h.useEmbeddingsClusters)&&void 0!==g&&g)){const n=v._mclCols.find((t=>(null==v?void 0:v.df.col(t))&&t.toLowerCase().startsWith("cluster")&&!t.toLowerCase().includes("size")));if(n){const i={clustersColumnName:n,sequenceColumnName:e.name,activityScaling:c,activityColumnName:t.name};yield v.addLogoSummaryTable(i),setTimeout((()=>{var t,e;v&&(null===(t=null==v?void 0:v.findViewer(l.q.LOGO_SUMMARY_TABLE))||void 0===t?void 0:t.render)&&(null===(e=null==v?void 0:v.findViewer(l.q.LOGO_SUMMARY_TABLE))||void 0===e||e.render())}),100)}}const S=v.df.plot.grid({rowSource:r.RowSet.Selected,selectedRowsColor:r.Color.fromHtml("#ffffff"),title:"Selection"}),T=null==v?void 0:v.findViewerNode(l.q.LOGO_SUMMARY_TABLE);return T&&v.analysisView.dockManager.dock(S,r.DOCK_TYPE.DOWN,T,"Selection",.4),C.close(),v}))}},5429:(t,e,n)=>{"use strict";n.d(e,{OH:()=>b,t_:()=>l});var i,o,r,s,a,l,u=n(7389),c=n(4328),h=n(6082),d=n(115),f=n(4139),m=n(9499),p=n(7233),g=n.n(p),v=n(144),C=n.n(v),y=n(3262),w=n(1199);function b(t){var e,n,r,p,v,b,A,S,T,E;null==t.settings&&c.log.error("PeptidesError: Settings are not initialized");const _=u.accordion(),N=t.settings,x=null!==(e=null==N?void 0:N.activityScaling)&&void 0!==e?e:f.rg.NONE,M=null!==(n=null==N?void 0:N.columns)&&void 0!==n?n:{},I={},O={},L=null!==(r=null==N?void 0:N.sequenceSpaceParams)&&void 0!==r?r:new d.GI,P=null!==(p=null==N?void 0:N.mclSettings)&&void 0!==p?p:new d.av,R=u.input.column(o.ACTIVITY,{table:t.df,value:t.df.getCol(t.settings.activityColumnName),onValueChanged:t=>{I.activityColumnName=t.name},filter:t=>(t.type===h.TYPE.FLOAT||t.type===h.TYPE.INT)&&t.name!==f.$2.ACTIVITY&&0===t.stats.missingValueCount});R.setTooltip("Numeric activity column");const k=u.input.choice(o.ACTIVITY_SCALING,{value:x,items:Object.values(f.rg),onValueChanged:t=>I.activityScaling=t});k.setTooltip("Activity column transformation method"),_.addPane(i.GENERAL,(()=>u.inputs([R,k])),!0),O[i.GENERAL]=[R,k];const V=C()(t.analysisView.viewers).some((t=>t.type===m.q.DENDROGRAM)),F=u.input.bool(m.q.DENDROGRAM,{value:null!=V&&V,onValueChanged:t=>I.showDendrogram=t}),D=u.input.bool(m.q.CLUSTER_MAX_ACTIVITY,{value:!!(null==N?void 0:N.showClusterMaxActivity),onValueChanged:t=>{I.showClusterMaxActivity=null!=t?t:void 0}}),G=u.input.bool("Sequence space",{value:!!(null==N?void 0:N.showSequenceSpace),onValueChanged:t=>{I.showSequenceSpace=null!=t?t:void 0,t?(ft.root.style.display="flex",(null==N?void 0:N.showSequenceSpace)||(I.sequenceSpaceParams=L)):(ft.root.style.display="none",delete I.sequenceSpaceParams),I.showSequenceSpace===(null==N?void 0:N.showSequenceSpace)&&delete I.showSequenceSpace}});D.setTooltip("Show cluster max activity viewer"),F.setTooltip("Show dendrogram viewer"),F.enabled=null!==(0,y.getTreeHelperInstance)(),_.addPane(i.VIEWERS,(()=>u.inputs([F,G,D])),!0),O[i.VIEWERS]=[F,G,D];const U=[],q=[];for(const e of t.df.columns.numerical){const t=e.name;if(t===N.activityColumnName||t===f.$2.ACTIVITY)continue;const n=u.input.bool(s.IS_INCLUDED,{value:void 0!==M[t],onValueChanged:e=>{var n;null!==(n=I.columns)&&void 0!==n||(I.columns={}),e?I.columns[t]=i.value:(delete I.columns[t],Object.keys(I.columns).length===Object.keys(M).length&&delete I.columns)}});n.setTooltip("Include aggregated column value in tooltips, Logo Summary Table and Distribution panel");const i=u.input.choice(s.AGGREGATION,{value:null!==(v=M[t])&&void 0!==v?v:h.AGG.AVG,items:Object.values(h.STATS),onValueChanged:i=>{var o;null!==(o=I.columns)&&void 0!==o||(I.columns={}),n.value?I.columns[t]=i:(delete I.columns[e.name],Object.keys(I.columns).length===Object.keys(M).length&&delete I.columns)}});i.setTooltip("Aggregation method"),g()(i.root).find("label").css("width","auto");const o=u.inputsRow(e.name,[n,i]);q.push(n,i),g()(o).find("div.ui-div").css("display","inline-flex"),U.push(o)}0!==U.length&&(_.addPane(i.COLUMNS,(()=>u.divV(U)),!1),O[i.COLUMNS]=q);const B={};function H(t,e){if(X(),null==e||""===e)return;B[t]=e;let n=!0;for(const[t,e]of Object.entries(B))if(e!==L[t]){n=!1;break}n?delete I.sequenceSpaceParams:I.sequenceSpaceParams=Object.assign(Object.assign({},L),B)}function Y(t,e){t.forEach((t=>{t.root.style.display=e?"flex":"none"}))}const j=u.input.choice(a.DISTANCE_FUNCTION,{value:L.distanceF,items:[w.Z.NEEDLEMANN_WUNSCH,w.Z.HAMMING,w.Z.LEVENSHTEIN,w.Z.MONOMER_CHEMICAL_DISTANCE],onValueChanged:t=>H("distanceF",t)});j.setTooltip("Distance function for sequences");const W=u.input.float(a.GAP_OPEN,{value:L.gapOpen,onValueChanged:t=>H("gapOpen",t)}),$=u.input.float(a.GAP_EXTEND,{value:L.gapExtend,onValueChanged:t=>H("gapExtend",t)}),z=u.input.bool(a.CLUSTER_EMBEDDINGS,{value:null!==(b=L.clusterEmbeddings)&&void 0!==b&&b,onValueChanged:t=>H("clusterEmbeddings",t)});z.setTooltip("Cluster embeddings using DBSCAN algorithm");const K=u.input.float(a.EPSILON,{value:L.epsilon,onValueChanged:t=>H("epsilon",t)});K.setTooltip("Epsilon parameter for DBSCAN. Minimum distance between two points to be considered as a cluster");const Z=u.input.int(a.MIN_PTS,{value:L.minPts,onValueChanged:t=>H("minPts",t)});Z.setTooltip("Minimum number of points in a cluster");const Q=u.input.choice(a.FINGERPRINT_TYPE,{value:L.fingerprintType,items:["Morgan","RDKit","Pattern","AtomPair","MACCS","TopologicalTorsion"],onValueChanged:t=>H("fingerprintType",t)});function X(){Y([W,$],j.value===w.Z.NEEDLEMANN_WUNSCH),Y([K,Z],!0===z.value),Y([Q],j.value===w.Z.MONOMER_CHEMICAL_DISTANCE||j.value===w.Z.NEEDLEMANN_WUNSCH)}X();const J={};function tt(t,e){if(et(),null==e||""===e)return;J[t]=e;let n=!0;for(const[t,e]of Object.entries(J))if(e!==P[t]){n=!1;break}n?delete I.mclSettings:I.mclSettings=Object.assign(Object.assign({},P),J)}function et(){Y([it,ot],nt.value===w.Z.NEEDLEMANN_WUNSCH),Y([rt],nt.value===w.Z.MONOMER_CHEMICAL_DISTANCE||nt.value===w.Z.NEEDLEMANN_WUNSCH)}const nt=u.input.choice(l.DISTANCE_FUNCTION,{value:P.distanceF,items:[w.Z.NEEDLEMANN_WUNSCH,w.Z.MONOMER_CHEMICAL_DISTANCE,w.Z.HAMMING,w.Z.LEVENSHTEIN],onValueChanged:t=>tt("distanceF",t)}),it=u.input.float(l.GAP_OPEN,{value:P.gapOpen,onValueChanged:t=>tt("gapOpen",t)}),ot=u.input.float(l.GAP_EXTEND,{value:P.gapExtend,onValueChanged:t=>tt("gapExtend",t)}),rt=u.input.choice(l.FINGERPRINT_TYPE,{value:P.fingerprintType,items:["Morgan","RDKit","Pattern","AtomPair","MACCS","TopologicalTorsion"],onValueChanged:t=>tt("fingerprintType",t)}),st=u.input.int(l.THRESHOLD,{value:null!==(A=P.threshold)&&void 0!==A?A:80,onValueChanged:t=>tt("threshold",t)}),at=u.input.int(l.MAX_ITERATIONS,{value:null!==(S=P.maxIterations)&&void 0!==S?S:5,onValueChanged:t=>tt("maxIterations",t)}),lt=u.input.float(l.INFLATION,{value:null!==(T=P.inflation)&&void 0!==T?T:1.4,onValueChanged:t=>{tt("inflation",t)}}),ut=u.input.bool(l.USE_WEBGPU,{value:P.useWebGPU,onValueChanged:t=>tt("useWebGPU",t)});ut.enabled=!1,P.webGPUDescriptionPromise.then((()=>{P.webGPUDescription!==d.Ku?(ut.setTooltip(`Use WebGPU for MCL algorithm (${P.webGPUDescription})`),ut.enabled=!0):(ut.setTooltip(d.Ku),ut.enabled=!1,ut.value=!1)}));const ct=u.input.int(l.MIN_CLUSTER_SIZE,{value:null!==(E=P.minClusterSize)&&void 0!==E?E:5,onValueChanged:t=>tt("minClusterSize",t)});et();const ht=[st,nt,rt,it,ot,lt,at,ct,ut];_.addPane(i.MCL,(()=>u.inputs(ht)),!0),O[i.MCL]=ht;const dt=[j,Q,W,$,z,K,Z],ft=_.addPane(i.SEQUENCE_SPACE,(()=>u.inputs(dt)),!0);O[i.SEQUENCE_SPACE]=dt,G.fireChanged();const mt=u.dialog("Peptides settings").add(_);return mt.root.style.width="400px",mt.onOK((()=>{t.settings=I})),mt.show(),{dialog:mt,accordion:_,inputs:O}}!function(t){t.GENERAL="General",t.VIEWERS="Viewers",t.COLUMNS="Columns",t.SEQUENCE_SPACE="Sequence space",t.MCL="MCL"}(i||(i={})),function(t){t.ACTIVITY="Activity",t.ACTIVITY_SCALING="Activity scaling"}(o||(o={})),function(t){t.DENDROGRAM="Dendrogram"}(r||(r={})),function(t){t.IS_INCLUDED="",t.AGGREGATION="Aggregation"}(s||(s={})),function(t){t.DISTANCE_FUNCTION="Distance Function",t.GAP_OPEN="Gap Open Penalty",t.GAP_EXTEND="Gap Extend Penalty",t.CLUSTER_EMBEDDINGS="Cluster Embeddings",t.EPSILON="Epsilon",t.MIN_PTS="Minimum Points",t.FINGERPRINT_TYPE="Fingerprint Type"}(a||(a={})),function(t){t.DISTANCE_FUNCTION="Distance Function",t.GAP_OPEN="Gap Open Penalty",t.GAP_EXTEND="Gap Extend Penalty",t.FINGERPRINT_TYPE="Fingerprint Type",t.THRESHOLD="Similarity Threshold",t.INFLATION="Inflation Factor",t.MAX_ITERATIONS="Max Iterations",t.USE_WEBGPU="Use WebGPU",t.MIN_CLUSTER_SIZE="Min Cluster Size"}(l||(l={})),i.GENERAL,i.VIEWERS,i.COLUMNS,i.SEQUENCE_SPACE,i.MCL},144:function(t){var e;e=function(){return function(t){var e={};function n(i){if(e[i])return e[i].exports;var o=e[i]={exports:{},id:i,loaded:!1};return t[i].call(o.exports,o,o.exports,n),o.loaded=!0,o.exports}return n.m=t,n.c=e,n.p="",n(0)}([function(t,e,n){"use strict";var i=n(1).default,o=n(39).default,r=n(52).default,s=n(40).default,a=n(54).default,l=n(80).default,u=n(84).default,c=n(65).default,h=t.exports=function(t){if(!m(t))throw new Error("wu: `"+t+"` is not iterable!");return new d(t)};function d(t){var e=p(t);this.next=e.next.bind(e)}h.prototype=d.prototype,h.prototype[r]=function(){return this};var f={},m=function(t){return t&&"function"==typeof t[r]},p=function(t){if(m(t))return s(t);throw new TypeError("Not iterable: "+t)},g=function(t,e){e.prototype=d.prototype,h[t]=e},v=function(t,e){var n=arguments.length<=2||void 0===arguments[2]?e.length:arguments[2];return e.prototype=d.prototype,d.prototype[t]=e,n+=1,void(h[t]=h.curryable((function(){for(var e,n=arguments.length,i=Array(n),o=0;o<n;o++)i[o]=arguments[o];var r=i.pop();return(e=h(r))[t].apply(e,i)}),n))},C=function(t){return function(){for(var e=arguments.length,n=Array(e),i=0;i<e;i++)n[i]=arguments[i];return h(t.call.apply(t,[this].concat(n)))}},y=function(t,e){return g(t,C(e))},w=function(t,e,n){return v(t,C(e),n)};g("curryable",(function(t){var e=arguments.length<=1||void 0===arguments[1]?t.length:arguments[1];return function n(){for(var o=arguments.length,r=Array(o),s=0;s<o;s++)r[s]=arguments[s];return r.length>=e?t.apply(this,r):function(t,e){return function(){for(var n=arguments.length,o=Array(n),r=0;r<n;r++)o[r]=arguments[r];return t.call.apply(t,[this].concat(i(e),o))}}(n,r)}})),y("entries",a.mark((function t(e){var n,i,o,r,u,c;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=!0,i=!1,o=void 0,t.prev=3,r=s(l(e));case 5:if(n=(u=r.next()).done){t.next=12;break}return c=u.value,t.next=9,[c,e[c]];case 9:n=!0,t.next=5;break;case 12:t.next=18;break;case 14:t.prev=14,t.t0=t.catch(3),i=!0,o=t.t0;case 18:t.prev=18,t.prev=19,!n&&r.return&&r.return();case 21:if(t.prev=21,!i){t.next=24;break}throw o;case 24:return t.finish(21);case 25:return t.finish(18);case 26:case"end":return t.stop()}}),t,this,[[3,14,18,26],[19,,21,25]])}))),y("keys",a.mark((function t(e){return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.delegateYield(l(e),"t0",1);case 1:case"end":return t.stop()}}),t,this)}))),y("values",a.mark((function t(e){var n,i,o,r,u,c;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=!0,i=!1,o=void 0,t.prev=3,r=s(l(e));case 5:if(n=(u=r.next()).done){t.next=12;break}return c=u.value,t.next=9,e[c];case 9:n=!0,t.next=5;break;case 12:t.next=18;break;case 14:t.prev=14,t.t0=t.catch(3),i=!0,o=t.t0;case 18:t.prev=18,t.prev=19,!n&&r.return&&r.return();case 21:if(t.prev=21,!i){t.next=24;break}throw o;case 24:return t.finish(21);case 25:return t.finish(18);case 26:case"end":return t.stop()}}),t,this,[[3,14,18,26],[19,,21,25]])}))),w("cycle",a.mark((function t(){var e,n,i,o,r,l,u;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e=[],n=!0,i=!1,o=void 0,t.prev=4,r=s(this);case 6:if(n=(l=r.next()).done){t.next=14;break}return u=l.value,t.next=10,u;case 10:e.push(u);case 11:n=!0,t.next=6;break;case 14:t.next=20;break;case 16:t.prev=16,t.t0=t.catch(4),i=!0,o=t.t0;case 20:t.prev=20,t.prev=21,!n&&r.return&&r.return();case 23:if(t.prev=23,!i){t.next=26;break}throw o;case 26:return t.finish(23);case 27:return t.finish(20);case 28:if(!e){t.next=32;break}return t.delegateYield(e,"t1",30);case 30:t.next=28;break;case 32:case"end":return t.stop()}}),t,this,[[4,16,20,28],[21,,23,27]])}))),y("count",a.mark((function t(){var e,n=arguments.length<=0||void 0===arguments[0]?0:arguments[0],i=arguments.length<=1||void 0===arguments[1]?1:arguments[1];return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e=n;case 1:return t.next=4,e;case 4:e+=i,t.next=1;break;case 7:case"end":return t.stop()}}),t,this)}))),y("repeat",a.mark((function t(e){var n,i=arguments.length<=1||void 0===arguments[1]?1/0:arguments[1];return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(i!==1/0){t.next=8;break}case 1:return t.next=4,e;case 4:t.next=1;break;case 6:t.next=15;break;case 8:n=0;case 9:if(!(n<i)){t.next=15;break}return t.next=12,e;case 12:n++,t.next=9;break;case 15:case"end":return t.stop()}}),t,this)}))),y("chain",a.mark((function t(){var e,n,i,o,r,l,u,c,h,d=arguments;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:for(e=!0,n=!1,i=void 0,t.prev=3,o=d.length,r=Array(o),l=0;l<o;l++)r[l]=d[l];u=s(r);case 6:if(e=(c=u.next()).done){t.next=12;break}return h=c.value,t.delegateYield(h,"t0",9);case 9:e=!0,t.next=6;break;case 12:t.next=18;break;case 14:t.prev=14,t.t1=t.catch(3),n=!0,i=t.t1;case 18:t.prev=18,t.prev=19,!e&&u.return&&u.return();case 21:if(t.prev=21,!n){t.next=24;break}throw i;case 24:return t.finish(21);case 25:return t.finish(18);case 26:case"end":return t.stop()}}),t,this,[[3,14,18,26],[19,,21,25]])}))),w("chunk",a.mark((function t(){var e,n,i,o,r,l,u,c,h=arguments.length<=0||void 0===arguments[0]?2:arguments[0];return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e=[],n=0,i=!0,o=!1,r=void 0,t.prev=5,l=s(this);case 7:if(i=(u=l.next()).done){t.next=18;break}if(c=u.value,e[n++]=c,n!==h){t.next=15;break}return t.next=13,e;case 13:e=[],n=0;case 15:i=!0,t.next=7;break;case 18:t.next=24;break;case 20:t.prev=20,t.t0=t.catch(5),o=!0,r=t.t0;case 24:t.prev=24,t.prev=25,!i&&l.return&&l.return();case 27:if(t.prev=27,!o){t.next=30;break}throw r;case 30:return t.finish(27);case 31:return t.finish(24);case 32:if(!n){t.next=35;break}return t.next=35,e;case 35:case"end":return t.stop()}}),t,this,[[5,20,24,32],[25,,27,31]])})),1),w("concatMap",a.mark((function t(e){var n,i,o,r,l,u;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=!0,i=!1,o=void 0,t.prev=3,r=s(this);case 5:if(n=(l=r.next()).done){t.next=11;break}return u=l.value,t.delegateYield(e(u),"t0",8);case 8:n=!0,t.next=5;break;case 11:t.next=17;break;case 13:t.prev=13,t.t1=t.catch(3),i=!0,o=t.t1;case 17:t.prev=17,t.prev=18,!n&&r.return&&r.return();case 20:if(t.prev=20,!i){t.next=23;break}throw o;case 23:return t.finish(20);case 24:return t.finish(17);case 25:case"end":return t.stop()}}),t,this,[[3,13,17,25],[18,,20,24]])}))),w("drop",a.mark((function t(e){var n,i,o,r,l,u,c;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=0,i=!0,o=!1,r=void 0,t.prev=4,l=s(this);case 6:if(i=(u=l.next()).done){t.next=16;break}if(c=u.value,!(n++<e)){t.next=10;break}return t.abrupt("continue",13);case 10:return t.next=12,c;case 12:return t.abrupt("break",16);case 13:i=!0,t.next=6;break;case 16:t.next=22;break;case 18:t.prev=18,t.t0=t.catch(4),o=!0,r=t.t0;case 22:t.prev=22,t.prev=23,!i&&l.return&&l.return();case 25:if(t.prev=25,!o){t.next=28;break}throw r;case 28:return t.finish(25);case 29:return t.finish(22);case 30:return t.delegateYield(this,"t1",31);case 31:case"end":return t.stop()}}),t,this,[[4,18,22,30],[23,,25,29]])}))),w("dropWhile",a.mark((function t(){var e,n,i,o,r,l,u=arguments.length<=0||void 0===arguments[0]?Boolean:arguments[0];return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e=!0,n=!1,i=void 0,t.prev=3,o=s(this);case 5:if(e=(r=o.next()).done){t.next=15;break}if(l=r.value,!u(l)){t.next=9;break}return t.abrupt("continue",12);case 9:return t.next=11,l;case 11:return t.abrupt("break",15);case 12:e=!0,t.next=5;break;case 15:t.next=21;break;case 17:t.prev=17,t.t0=t.catch(3),n=!0,i=t.t0;case 21:t.prev=21,t.prev=22,!e&&o.return&&o.return();case 24:if(t.prev=24,!n){t.next=27;break}throw i;case 27:return t.finish(24);case 28:return t.finish(21);case 29:return t.delegateYield(this,"t1",30);case 30:case"end":return t.stop()}}),t,this,[[3,17,21,29],[22,,24,28]])})),1),w("enumerate",a.mark((function t(){return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.delegateYield(b([this,h.count()]),"t0",1);case 1:case"end":return t.stop()}}),t,this)}))),w("filter",a.mark((function t(){var e,n,i,o,r,l,u=arguments.length<=0||void 0===arguments[0]?Boolean:arguments[0];return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e=!0,n=!1,i=void 0,t.prev=3,o=s(this);case 5:if(e=(r=o.next()).done){t.next=13;break}if(l=r.value,!u(l)){t.next=10;break}return t.next=10,l;case 10:e=!0,t.next=5;break;case 13:t.next=19;break;case 15:t.prev=15,t.t0=t.catch(3),n=!0,i=t.t0;case 19:t.prev=19,t.prev=20,!e&&o.return&&o.return();case 22:if(t.prev=22,!n){t.next=25;break}throw i;case 25:return t.finish(22);case 26:return t.finish(19);case 27:case"end":return t.stop()}}),t,this,[[3,15,19,27],[20,,22,26]])})),1),w("flatten",a.mark((function t(){var e,n,i,o,r,l,u=!(arguments.length<=0||void 0===arguments[0])&&arguments[0];return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e=!0,n=!1,i=void 0,t.prev=3,o=s(this);case 5:if(e=(r=o.next()).done){t.next=16;break}if("string"==typeof(l=r.value)||!m(l)){t.next=11;break}return t.delegateYield(u?l:h(l).flatten(),"t0",9);case 9:t.next=13;break;case 11:return t.next=13,l;case 13:e=!0,t.next=5;break;case 16:t.next=22;break;case 18:t.prev=18,t.t1=t.catch(3),n=!0,i=t.t1;case 22:t.prev=22,t.prev=23,!e&&o.return&&o.return();case 25:if(t.prev=25,!n){t.next=28;break}throw i;case 28:return t.finish(25);case 29:return t.finish(22);case 30:case"end":return t.stop()}}),t,this,[[3,18,22,30],[23,,25,29]])})),1),w("invoke",a.mark((function t(e){var n,i,o,r,l,u,c,h,d,f=arguments;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:for(n=!0,i=!1,o=void 0,t.prev=3,r=f.length,l=Array(r>1?r-1:0),u=1;u<r;u++)l[u-1]=f[u];c=s(this);case 6:if(n=(h=c.next()).done){t.next=13;break}return d=h.value,t.next=10,d[e].apply(d,l);case 10:n=!0,t.next=6;break;case 13:t.next=19;break;case 15:t.prev=15,t.t0=t.catch(3),i=!0,o=t.t0;case 19:t.prev=19,t.prev=20,!n&&c.return&&c.return();case 22:if(t.prev=22,!i){t.next=25;break}throw o;case 25:return t.finish(22);case 26:return t.finish(19);case 27:case"end":return t.stop()}}),t,this,[[3,15,19,27],[20,,22,26]])}))),w("map",a.mark((function t(e){var n,i,o,r,l,u;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=!0,i=!1,o=void 0,t.prev=3,r=s(this);case 5:if(n=(l=r.next()).done){t.next=12;break}return u=l.value,t.next=9,e(u);case 9:n=!0,t.next=5;break;case 12:t.next=18;break;case 14:t.prev=14,t.t0=t.catch(3),i=!0,o=t.t0;case 18:t.prev=18,t.prev=19,!n&&r.return&&r.return();case 21:if(t.prev=21,!i){t.next=24;break}throw o;case 24:return t.finish(21);case 25:return t.finish(18);case 26:case"end":return t.stop()}}),t,this,[[3,14,18,26],[19,,21,25]])}))),w("pluck",a.mark((function t(e){var n,i,o,r,l,u;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=!0,i=!1,o=void 0,t.prev=3,r=s(this);case 5:if(n=(l=r.next()).done){t.next=12;break}return u=l.value,t.next=9,u[e];case 9:n=!0,t.next=5;break;case 12:t.next=18;break;case 14:t.prev=14,t.t0=t.catch(3),i=!0,o=t.t0;case 18:t.prev=18,t.prev=19,!n&&r.return&&r.return();case 21:if(t.prev=21,!i){t.next=24;break}throw o;case 24:return t.finish(21);case 25:return t.finish(18);case 26:case"end":return t.stop()}}),t,this,[[3,14,18,26],[19,,21,25]])}))),w("reductions",a.mark((function t(e){var n,i,o,r,l,u,c,h,d,f,m,p,g=arguments.length<=1||void 0===arguments[1]?void 0:arguments[1];return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(void 0!==(n=g)){t.next=28;break}i=!0,o=!1,r=void 0,t.prev=5,l=s(this);case 7:if(i=(u=l.next()).done){t.next=14;break}return c=u.value,n=c,t.abrupt("break",14);case 11:i=!0,t.next=7;break;case 14:t.next=20;break;case 16:t.prev=16,t.t0=t.catch(5),o=!0,r=t.t0;case 20:t.prev=20,t.prev=21,!i&&l.return&&l.return();case 23:if(t.prev=23,!o){t.next=26;break}throw r;case 26:return t.finish(23);case 27:return t.finish(20);case 28:return t.next=30,n;case 30:h=!0,d=!1,f=void 0,t.prev=33,m=s(this);case 35:if(h=(p=m.next()).done){t.next=42;break}return c=p.value,t.next=39,n=e(n,c);case 39:h=!0,t.next=35;break;case 42:t.next=48;break;case 44:t.prev=44,t.t1=t.catch(33),d=!0,f=t.t1;case 48:t.prev=48,t.prev=49,!h&&m.return&&m.return();case 51:if(t.prev=51,!d){t.next=54;break}throw f;case 54:return t.finish(51);case 55:return t.finish(48);case 56:return t.abrupt("return",n);case 57:case"end":return t.stop()}}),t,this,[[5,16,20,28],[21,,23,27],[33,44,48,56],[49,,51,55]])})),2),w("reject",a.mark((function t(){var e,n,i,o,r,l,u=arguments.length<=0||void 0===arguments[0]?Boolean:arguments[0];return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e=!0,n=!1,i=void 0,t.prev=3,o=s(this);case 5:if(e=(r=o.next()).done){t.next=13;break}if(l=r.value,u(l)){t.next=10;break}return t.next=10,l;case 10:e=!0,t.next=5;break;case 13:t.next=19;break;case 15:t.prev=15,t.t0=t.catch(3),n=!0,i=t.t0;case 19:t.prev=19,t.prev=20,!e&&o.return&&o.return();case 22:if(t.prev=22,!n){t.next=25;break}throw i;case 25:return t.finish(22);case 26:return t.finish(19);case 27:case"end":return t.stop()}}),t,this,[[3,15,19,27],[20,,22,26]])})),1),w("slice",a.mark((function t(){var e,n,i,r,l,u,c,h,d=arguments.length<=0||void 0===arguments[0]?0:arguments[0],f=arguments.length<=1||void 0===arguments[1]?1/0:arguments[1];return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(f<d)){t.next=2;break}throw new RangeError("parameter `stop` (= "+f+") must be >= `start` (= "+d+")");case 2:e=!0,n=!1,i=void 0,t.prev=5,r=s(this.enumerate());case 7:if(e=(l=r.next()).done){t.next=20;break}if(u=o(l.value,2),c=u[0],!((h=u[1])<d)){t.next=13;break}return t.abrupt("continue",17);case 13:if(!(h>=f)){t.next=15;break}return t.abrupt("break",20);case 15:return t.next=17,c;case 17:e=!0,t.next=7;break;case 20:t.next=26;break;case 22:t.prev=22,t.t0=t.catch(5),n=!0,i=t.t0;case 26:t.prev=26,t.prev=27,!e&&r.return&&r.return();case 29:if(t.prev=29,!n){t.next=32;break}throw i;case 32:return t.finish(29);case 33:return t.finish(26);case 34:case"end":return t.stop()}}),t,this,[[5,22,26,34],[27,,29,33]])})),2),w("spreadMap",a.mark((function t(e){var n,o,r,l,u,c;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=!0,o=!1,r=void 0,t.prev=3,l=s(this);case 5:if(n=(u=l.next()).done){t.next=12;break}return c=u.value,t.next=9,e.apply(void 0,i(c));case 9:n=!0,t.next=5;break;case 12:t.next=18;break;case 14:t.prev=14,t.t0=t.catch(3),o=!0,r=t.t0;case 18:t.prev=18,t.prev=19,!n&&l.return&&l.return();case 21:if(t.prev=21,!o){t.next=24;break}throw r;case 24:return t.finish(21);case 25:return t.finish(18);case 26:case"end":return t.stop()}}),t,this,[[3,14,18,26],[19,,21,25]])}))),w("take",a.mark((function t(e){var n,i,o,r,l,u,c;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e<1)){t.next=2;break}return t.abrupt("return");case 2:n=0,i=!0,o=!1,r=void 0,t.prev=6,l=s(this);case 8:if(i=(u=l.next()).done){t.next=17;break}return c=u.value,t.next=12,c;case 12:if(!(++n>=e)){t.next=14;break}return t.abrupt("break",17);case 14:i=!0,t.next=8;break;case 17:t.next=23;break;case 19:t.prev=19,t.t0=t.catch(6),o=!0,r=t.t0;case 23:t.prev=23,t.prev=24,!i&&l.return&&l.return();case 26:if(t.prev=26,!o){t.next=29;break}throw r;case 29:return t.finish(26);case 30:return t.finish(23);case 31:case"end":return t.stop()}}),t,this,[[6,19,23,31],[24,,26,30]])}))),w("takeWhile",a.mark((function t(){var e,n,i,o,r,l,u=arguments.length<=0||void 0===arguments[0]?Boolean:arguments[0];return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e=!0,n=!1,i=void 0,t.prev=3,o=s(this);case 5:if(e=(r=o.next()).done){t.next=14;break}if(l=r.value,u(l)){t.next=9;break}return t.abrupt("break",14);case 9:return t.next=11,l;case 11:e=!0,t.next=5;break;case 14:t.next=20;break;case 16:t.prev=16,t.t0=t.catch(3),n=!0,i=t.t0;case 20:t.prev=20,t.prev=21,!e&&o.return&&o.return();case 23:if(t.prev=23,!n){t.next=26;break}throw i;case 26:return t.finish(23);case 27:return t.finish(20);case 28:case"end":return t.stop()}}),t,this,[[3,16,20,28],[21,,23,27]])})),1),w("tap",a.mark((function t(){var e,n,i,o,r,l,u=arguments.length<=0||void 0===arguments[0]?console.log.bind(console):arguments[0];return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e=!0,n=!1,i=void 0,t.prev=3,o=s(this);case 5:if(e=(r=o.next()).done){t.next=13;break}return l=r.value,u(l),t.next=10,l;case 10:e=!0,t.next=5;break;case 13:t.next=19;break;case 15:t.prev=15,t.t0=t.catch(3),n=!0,i=t.t0;case 19:t.prev=19,t.prev=20,!e&&o.return&&o.return();case 22:if(t.prev=22,!n){t.next=25;break}throw i;case 25:return t.finish(22);case 26:return t.finish(19);case 27:case"end":return t.stop()}}),t,this,[[3,15,19,27],[20,,22,26]])})),1),w("unique",a.mark((function t(){var e,n,i,o,r,l,c;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e=new u,n=!0,i=!1,o=void 0,t.prev=4,r=s(this);case 6:if(n=(l=r.next()).done){t.next=15;break}if(c=l.value,e.has(c)){t.next=12;break}return t.next=11,c;case 11:e.add(c);case 12:n=!0,t.next=6;break;case 15:t.next=21;break;case 17:t.prev=17,t.t0=t.catch(4),i=!0,o=t.t0;case 21:t.prev=21,t.prev=22,!n&&r.return&&r.return();case 24:if(t.prev=24,!i){t.next=27;break}throw o;case 27:return t.finish(24);case 28:return t.finish(21);case 29:e.clear();case 30:case"end":return t.stop()}}),t,this,[[4,17,21,29],[22,,24,28]])})));var b=C(a.mark((function t(e){var n,i,o,r,l,u,c,h,d,f,m,g,v,C=!(arguments.length<=1||void 0===arguments[1])&&arguments[1];return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.length){t.next=2;break}return t.abrupt("return");case 2:n=e.map(p),i=e.length,o=0,r=!1;case 6:if(r){t.next=44;break}l=[],u=!0,c=!1,h=void 0,t.prev=11,d=s(n);case 13:if(u=(f=d.next()).done){t.next=26;break}if(m=f.value,g=m.next(),v=g.value,!g.done){t.next=22;break}if(C){t.next=21;break}return t.abrupt("return");case 21:++o==i&&(r=!0);case 22:void 0===v?l.length++:l.push(v);case 23:u=!0,t.next=13;break;case 26:t.next=32;break;case 28:t.prev=28,t.t0=t.catch(11),c=!0,h=t.t0;case 32:t.prev=32,t.prev=33,!u&&d.return&&d.return();case 35:if(t.prev=35,!c){t.next=38;break}throw h;case 38:return t.finish(35);case 39:return t.finish(32);case 40:return t.next=42,l;case 42:t.next=6;break;case 44:case"end":return t.stop()}}),t,this,[[11,28,32,40],[33,,35,39]])})));y("zip",a.mark((function t(){for(var e=arguments.length,n=Array(e),i=0;i<e;i++)n[i]=arguments[i];return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.delegateYield(b(n),"t0",1);case 1:case"end":return t.stop()}}),t,this)}))),y("zipLongest",a.mark((function t(){for(var e=arguments.length,n=Array(e),i=0;i<e;i++)n[i]=arguments[i];return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.delegateYield(b(n,!0),"t0",1);case 1:case"end":return t.stop()}}),t,this)}))),y("zipWith",a.mark((function t(e){for(var n=arguments.length,i=Array(n>1?n-1:0),o=1;o<n;o++)i[o-1]=arguments[o];return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.delegateYield(b(i).spreadMap(e),"t0",1);case 1:case"end":return t.stop()}}),t,this)}))),h.MAX_BLOCK=15,h.TIMEOUT=1,v("asyncEach",(function(t){var e=arguments.length<=1||void 0===arguments[1]?h.MAX_BLOCK:arguments[1],n=arguments.length<=2||void 0===arguments[2]?h.TIMEOUT:arguments[2],i=p(this);return new c((function(o,r){!function a(){var l=Date.now(),u=!0,c=!1,h=void 0;try{for(var d,f=s(i);!(u=(d=f.next()).done);u=!0){var m=d.value;try{t(m)}catch(t){return void r(t)}if(Date.now()-l>e)return void setTimeout(a,n)}}catch(t){c=!0,h=t}finally{try{!u&&f.return&&f.return()}finally{if(c)throw h}}o()}()}))}),3),v("every",(function(){var t=arguments.length<=0||void 0===arguments[0]?Boolean:arguments[0],e=!0,n=!1,i=void 0;try{for(var o,r=s(this);!(e=(o=r.next()).done);e=!0)if(!t(o.value))return!1}catch(t){n=!0,i=t}finally{try{!e&&r.return&&r.return()}finally{if(n)throw i}}return!0}),1),v("find",(function(t){var e=!0,n=!1,i=void 0;try{for(var o,r=s(this);!(e=(o=r.next()).done);e=!0){var a=o.value;if(t(a))return a}}catch(t){n=!0,i=t}finally{try{!e&&r.return&&r.return()}finally{if(n)throw i}}})),v("forEach",(function(t){var e=!0,n=!1,i=void 0;try{for(var o,r=s(this);!(e=(o=r.next()).done);e=!0)t(o.value)}catch(t){n=!0,i=t}finally{try{!e&&r.return&&r.return()}finally{if(n)throw i}}})),v("has",(function(t){return this.some((function(e){return e===t}))})),v("reduce",(function(t){var e=arguments.length<=1||void 0===arguments[1]?void 0:arguments[1];if(void 0===e){var n=!0,i=!1,o=void 0;try{for(var r,a=s(this);!(n=(r=a.next()).done);n=!0){e=r.value;break}}catch(t){i=!0,o=t}finally{try{!n&&a.return&&a.return()}finally{if(i)throw o}}}var l=!0,u=!1,c=void 0;try{for(var h,d=s(this);!(l=(h=d.next()).done);l=!0)e=t(e,h.value)}catch(t){u=!0,c=t}finally{try{!l&&d.return&&d.return()}finally{if(u)throw c}}return e}),2),v("some",(function(){var t=arguments.length<=0||void 0===arguments[0]?Boolean:arguments[0],e=!0,n=!1,i=void 0;try{for(var o,r=s(this);!(e=(o=r.next()).done);e=!0)if(t(o.value))return!0}catch(t){n=!0,i=t}finally{try{!e&&r.return&&r.return()}finally{if(n)throw i}}return!1}),1),v("toArray",(function(){return[].concat(i(this))}));var A=C(a.mark((function t(e,n){var i,o,r,s,l;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:i=n.items,o=0;case 2:if(o!==i.length){t.next=14;break}if(r=e.next(),s=r.done,l=r.value,!s){t.next=10;break}return n.returned===f&&(n.returned=l),t.abrupt("break",25);case 10:return t.next=12,i[o++]=l;case 12:t.next=23;break;case 14:if(o!==n.tail){t.next=21;break}return l=i[o],500===o?(i=n.items=i.slice(o),o=0,n.tail=0):(i[o]=void 0,n.tail=++o),t.next=19,l;case 19:t.next=23;break;case 21:return t.next=23,i[o++];case 23:t.next=2;break;case 25:return n.tail===o&&(i.length=0),t.abrupt("return",n.returned);case 27:case"end":return t.stop()}}),t,this)})));A.prototype=d.prototype,v("tee",(function(){for(var t=arguments.length<=0||void 0===arguments[0]?2:arguments[0],e=new Array(t),n={tail:0,items:[],returned:f};t--;)e[t]=A(this,n);return e}),1),v("unzip",(function(){var t=arguments.length<=0||void 0===arguments[0]?2:arguments[0];return this.tee(t).map((function(t,e){return t.pluck(e)}))}),1),h.tang={clan:36}},function(t,e,n){"use strict";var i=n(2).default;e.default=function(t){if(Array.isArray(t)){for(var e=0,n=Array(t.length);e<t.length;e++)n[e]=t[e];return n}return i(t)},e.__esModule=!0},function(t,e,n){t.exports={default:n(3),__esModule:!0}},function(t,e,n){n(4),n(26),t.exports=n(12).Array.from},function(t,e,n){"use strict";var i=n(5)(!0);n(8)(String,"String",(function(t){this._t=String(t),this._i=0}),(function(){var t,e=this._t,n=this._i;return n>=e.length?{value:void 0,done:!0}:(t=i(e,n),this._i+=t.length,{value:t,done:!1})}))},function(t,e,n){var i=n(6),o=n(7);t.exports=function(t){return function(e,n){var r,s,a=String(o(e)),l=i(n),u=a.length;return l<0||l>=u?t?"":void 0:(r=a.charCodeAt(l))<55296||r>56319||l+1===u||(s=a.charCodeAt(l+1))<56320||s>57343?t?a.charAt(l):r:t?a.slice(l,l+2):s-56320+(r-55296<<10)+65536}}},function(t,e){var n=Math.ceil,i=Math.floor;t.exports=function(t){return isNaN(t=+t)?0:(t>0?i:n)(t)}},function(t,e){t.exports=function(t){if(null==t)throw TypeError("Can't call method on "+t);return t}},function(t,e,n){"use strict";var i=n(9),o=n(10),r=n(13),s=n(14),a=n(19),l=n(20)("iterator"),u=n(23),c=!([].keys&&"next"in[].keys()),h="@@iterator",d="keys",f="values",m=function(){return this};t.exports=function(t,e,p,g,v,C,y){n(24)(p,e,g);var w,b,A=function(t){switch(t){case d:case f:return function(){return new p(this,t)}}return function(){return new p(this,t)}},S=e+" Iterator",T=t.prototype,E=T[l]||T[h]||v&&T[v],_=E||A(v);if(E){var N=n(15).getProto(_.call(new t));n(25)(N,S,!0),!i&&a(T,h)&&s(N,l,m)}if(i&&!y||s(T,l,_),u[e]=_,u[S]=m,v)if(w={keys:C?_:A(d),values:v==f?_:A(f),entries:v!=f?_:A("entries")},y)for(b in w)b in T||r(T,b,w[b]);else o(o.P+o.F*c,e,w)}},function(t,e){t.exports=!0},function(t,e,n){var i=n(11),o=n(12),r="prototype",s=function(t,e){return function(){return t.apply(e,arguments)}},a=function(t,e,n){var l,u,c,h,d=t&a.G,f=t&a.P,m=d?i:t&a.S?i[e]:(i[e]||{})[r],p=d?o:o[e]||(o[e]={});for(l in d&&(n=e),n)(u=!(t&a.F)&&m&&l in m)&&l in p||(c=u?m[l]:n[l],d&&"function"!=typeof m[l]?h=n[l]:t&a.B&&u?h=s(c,i):t&a.W&&m[l]==c?function(t){(h=function(e){return this instanceof t?new t(e):t(e)})[r]=t[r]}(c):h=f&&"function"==typeof c?s(Function.call,c):c,p[l]=h,f&&((p[r]||(p[r]={}))[l]=c))};a.F=1,a.G=2,a.S=4,a.P=8,a.B=16,a.W=32,t.exports=a},function(t,e){var n="undefined",i=t.exports=typeof window!=n&&window.Math==Math?window:typeof self!=n&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=i)},function(t,e){var n=t.exports={version:"1.2.0"};"number"==typeof __e&&(__e=n)},function(t,e,n){t.exports=n(14)},function(t,e,n){var i=n(15),o=n(16);t.exports=n(17)?function(t,e,n){return i.setDesc(t,e,o(1,n))}:function(t,e,n){return t[e]=n,t}},function(t,e){var n=Object;t.exports={create:n.create,getProto:n.getPrototypeOf,isEnum:{}.propertyIsEnumerable,getDesc:n.getOwnPropertyDescriptor,setDesc:n.defineProperty,setDescs:n.defineProperties,getKeys:n.keys,getNames:n.getOwnPropertyNames,getSymbols:n.getOwnPropertySymbols,each:[].forEach}},function(t,e){t.exports=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}}},function(t,e,n){t.exports=!n(18)((function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a}))},function(t,e){t.exports=function(t){try{return!!t()}catch(t){return!0}}},function(t,e){var n={}.hasOwnProperty;t.exports=function(t,e){return n.call(t,e)}},function(t,e,n){var i=n(21)("wks"),o=n(11).Symbol;t.exports=function(t){return i[t]||(i[t]=o&&o[t]||(o||n(22))("Symbol."+t))}},function(t,e,n){var i=n(11),o="__core-js_shared__",r=i[o]||(i[o]={});t.exports=function(t){return r[t]||(r[t]={})}},function(t,e){var n=0,i=Math.random();t.exports=function(t){return"Symbol(".concat(void 0===t?"":t,")_",(++n+i).toString(36))}},function(t,e){t.exports={}},function(t,e,n){"use strict";var i=n(15),o={};n(14)(o,n(20)("iterator"),(function(){return this})),t.exports=function(t,e,r){t.prototype=i.create(o,{next:n(16)(1,r)}),n(25)(t,e+" Iterator")}},function(t,e,n){var i=n(19),o=n(14),r=n(20)("toStringTag");t.exports=function(t,e,n){t&&!i(t=n?t:t.prototype,r)&&o(t,r,e)}},function(t,e,n){"use strict";var i=n(27),o=n(10),r=n(29),s=n(30),a=n(33),l=n(34),u=n(35);o(o.S+o.F*!n(38)((function(t){Array.from(t)})),"Array",{from:function(t){var e,n,o,c,h=r(t),d="function"==typeof this?this:Array,f=arguments[1],m=void 0!==f,p=0,g=u(h);if(m&&(f=i(f,arguments[2],2)),null==g||d==Array&&a(g))for(n=new d(e=l(h.length));e>p;p++)n[p]=m?f(h[p],p):h[p];else for(c=g.call(h),n=new d;!(o=c.next()).done;p++)n[p]=m?s(c,f,[o.value,p],!0):o.value;return n.length=p,n}})},function(t,e,n){var i=n(28);t.exports=function(t,e,n){if(i(t),void 0===e)return t;switch(n){case 1:return function(n){return t.call(e,n)};case 2:return function(n,i){return t.call(e,n,i)};case 3:return function(n,i,o){return t.call(e,n,i,o)}}return function(){return t.apply(e,arguments)}}},function(t,e){t.exports=function(t){if("function"!=typeof t)throw TypeError(t+" is not a function!");return t}},function(t,e,n){var i=n(7);t.exports=function(t){return Object(i(t))}},function(t,e,n){var i=n(31);t.exports=function(t,e,n,o){try{return o?e(i(n)[0],n[1]):e(n)}catch(e){var r=t.return;throw void 0!==r&&i(r.call(t)),e}}},function(t,e,n){var i=n(32);t.exports=function(t){if(!i(t))throw TypeError(t+" is not an object!");return t}},function(t,e){t.exports=function(t){return"object"==typeof t?null!==t:"function"==typeof t}},function(t,e,n){var i=n(23),o=n(20)("iterator");t.exports=function(t){return(i.Array||Array.prototype[o])===t}},function(t,e,n){var i=n(6),o=Math.min;t.exports=function(t){return t>0?o(i(t),9007199254740991):0}},function(t,e,n){var i=n(36),o=n(20)("iterator"),r=n(23);t.exports=n(12).getIteratorMethod=function(t){if(null!=t)return t[o]||t["@@iterator"]||r[i(t)]}},function(t,e,n){var i=n(37),o=n(20)("toStringTag"),r="Arguments"==i(function(){return arguments}());t.exports=function(t){var e,n,s;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(n=(e=Object(t))[o])?n:r?i(e):"Object"==(s=i(e))&&"function"==typeof e.callee?"Arguments":s}},function(t,e){var n={}.toString;t.exports=function(t){return n.call(t).slice(8,-1)}},function(t,e,n){var i=n(20)("iterator"),o=!1;try{var r=[7][i]();r.return=function(){o=!0},Array.from(r,(function(){throw 2}))}catch(t){}t.exports=function(t){if(!o)return!1;var e=!1;try{var n=[7],r=n[i]();r.next=function(){e=!0},n[i]=function(){return r},t(n)}catch(t){}return e}},function(t,e,n){"use strict";var i=n(40).default,o=n(49).default;e.default=function(t,e){if(Array.isArray(t))return t;if(o(Object(t)))return function(t,e){var n=[],o=!0,r=!1,s=void 0;try{for(var a,l=i(t);!(o=(a=l.next()).done)&&(n.push(a.value),!e||n.length!==e);o=!0);}catch(t){r=!0,s=t}finally{try{!o&&l.return&&l.return()}finally{if(r)throw s}}return n}(t,e);throw new TypeError("Invalid attempt to destructure non-iterable instance")},e.__esModule=!0},function(t,e,n){t.exports={default:n(41),__esModule:!0}},function(t,e,n){n(42),n(4),t.exports=n(48)},function(t,e,n){n(43);var i=n(23);i.NodeList=i.HTMLCollection=i.Array},function(t,e,n){"use strict";var i=n(44),o=n(45),r=n(23),s=n(46);n(8)(Array,"Array",(function(t,e){this._t=s(t),this._i=0,this._k=e}),(function(){var t=this._t,e=this._k,n=this._i++;return!t||n>=t.length?(this._t=void 0,o(1)):o(0,"keys"==e?n:"values"==e?t[n]:[n,t[n]])}),"values"),r.Arguments=r.Array,i("keys"),i("values"),i("entries")},function(t,e){t.exports=function(){}},function(t,e){t.exports=function(t,e){return{value:e,done:!!t}}},function(t,e,n){var i=n(47),o=n(7);t.exports=function(t){return i(o(t))}},function(t,e,n){var i=n(37);t.exports=0 in Object("z")?Object:function(t){return"String"==i(t)?t.split(""):Object(t)}},function(t,e,n){var i=n(31),o=n(35);t.exports=n(12).getIterator=function(t){var e=o(t);if("function"!=typeof e)throw TypeError(t+" is not iterable!");return i(e.call(t))}},function(t,e,n){t.exports={default:n(50),__esModule:!0}},function(t,e,n){n(42),n(4),t.exports=n(51)},function(t,e,n){var i=n(36),o=n(20)("iterator"),r=n(23);t.exports=n(12).isIterable=function(t){var e=Object(t);return o in e||"@@iterator"in e||r.hasOwnProperty(i(e))}},function(t,e,n){t.exports={default:n(53),__esModule:!0}},function(t,e,n){n(4),n(42),t.exports=n(20)("iterator")},function(t,e,n){(function(e){var i="object"==typeof e?e:"object"==typeof window?window:"object"==typeof self?self:this,o=i.regeneratorRuntime&&Object.getOwnPropertyNames(i).indexOf("regeneratorRuntime")>=0,r=o&&i.regeneratorRuntime;if(i.regeneratorRuntime=void 0,t.exports=n(55),o)i.regeneratorRuntime=r;else try{delete i.regeneratorRuntime}catch(t){i.regeneratorRuntime=void 0}t.exports={default:t.exports,__esModule:!0}}).call(e,function(){return this}())},function(t,e,n){(function(e,i){"use strict";var o=n(57).default,r=n(52).default,s=n(63).default,a=n(65).default;!function(e){var n,l=Object.prototype.hasOwnProperty,u="function"==typeof o&&r||"@@iterator",c="object"==typeof t,h=e.regeneratorRuntime;if(h)c&&(t.exports=h);else{(h=e.regeneratorRuntime=c?t.exports:{}).wrap=C;var d="suspendedStart",f="suspendedYield",m="executing",p="completed",g={},v=A.prototype=w.prototype;b.prototype=v.constructor=A,A.constructor=b,b.displayName="GeneratorFunction",h.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===b||"GeneratorFunction"===(e.displayName||e.name))},h.mark=function(t){return t.__proto__=A,t.prototype=s(v),t},h.awrap=function(t){return new T(t)},S(E.prototype),h.async=function(t,e,n,i){var o=new E(C(t,e,n,i));return h.isGeneratorFunction(e)?o:o.next().then((function(t){return t.done?t.value:o.next()}))},S(v),v[u]=function(){return this},v.toString=function(){return"[object Generator]"},h.keys=function(t){var e=[];for(var n in t)e.push(n);return e.reverse(),function n(){for(;e.length;){var i=e.pop();if(i in t)return n.value=i,n.done=!1,n}return n.done=!0,n}},h.values=M,x.prototype={constructor:x,reset:function(t){if(this.prev=0,this.next=0,this.sent=n,this.done=!1,this.delegate=null,this.tryEntries.forEach(N),!t)for(var e in this)"t"===e.charAt(0)&&l.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=n)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(n,i){return r.type="throw",r.arg=t,e.next=n,!!i}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],r=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var s=l.call(o,"catchLoc"),a=l.call(o,"finallyLoc");if(s&&a){if(this.prev<o.catchLoc)return n(o.catchLoc,!0);if(this.prev<o.finallyLoc)return n(o.finallyLoc)}else if(s){if(this.prev<o.catchLoc)return n(o.catchLoc,!0)}else{if(!a)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return n(o.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&l.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var r=o?o.completion:{};return r.type=t,r.arg=e,o?this.next=o.finallyLoc:this.complete(r),g},complete:function(t,e){if("throw"===t.type)throw t.arg;"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=t.arg,this.next="end"):"normal"===t.type&&e&&(this.next=e)},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),N(n),g}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var i=n.completion;if("throw"===i.type){var o=i.arg;N(n)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:M(t),resultName:e,nextLoc:n},g}}}function C(t,e,i,o){var r=s((e||w).prototype);return r._invoke=function(t,e,i){var o=d;return function(r,s){if(o===m)throw new Error("Generator is already running");if(o===p){if("throw"===r)throw s;return I()}for(;;){var a=i.delegate;if(a){if("return"===r||"throw"===r&&a.iterator[r]===n){i.delegate=null;var l=a.iterator.return;if(l&&"throw"===(u=y(l,a.iterator,s)).type){r="throw",s=u.arg;continue}if("return"===r)continue}var u;if("throw"===(u=y(a.iterator[r],a.iterator,s)).type){i.delegate=null,r="throw",s=u.arg;continue}if(r="next",s=n,!(c=u.arg).done)return o=f,c;i[a.resultName]=c.value,i.next=a.nextLoc,i.delegate=null}if("next"===r)i.sent=o===f?s:n;else if("throw"===r){if(o===d)throw o=p,s;i.dispatchException(s)&&(r="next",s=n)}else"return"===r&&i.abrupt("return",s);if(o=m,"normal"===(u=y(t,e,i)).type){o=i.done?p:f;var c={value:u.arg,done:i.done};if(u.arg!==g)return c;i.delegate&&"next"===r&&(s=n)}else"throw"===u.type&&(o=p,r="throw",s=u.arg)}}}(t,i||null,new x(o||[])),r}function y(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}function w(){}function b(){}function A(){}function S(t){["next","throw","return"].forEach((function(e){t[e]=function(t){return this._invoke(e,t)}}))}function T(t){this.arg=t}function E(t){function e(e,n){var i=t[e](n),s=i.value;return s instanceof T?a.resolve(s.arg).then(o,r):a.resolve(s).then((function(t){return i.value=t,i}))}"object"==typeof i&&i.domain&&(e=i.domain.bind(e));var n,o=e.bind(t,"next"),r=e.bind(t,"throw");e.bind(t,"return"),this._invoke=function(t,i){var o=n?n.then((function(){return e(t,i)})):new a((function(n){n(e(t,i))}));return n=o.catch((function(t){})),o}}function _(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function N(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function x(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(_,this),this.reset(!0)}function M(t){if(t){var e=t[u];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,o=function e(){for(;++i<t.length;)if(l.call(t,i))return e.value=t[i],e.done=!1,e;return e.value=n,e.done=!0,e};return o.next=o}}return{next:I}}function I(){return{value:n,done:!0}}}("object"==typeof e?e:"object"==typeof window?window:"object"==typeof self?self:void 0)}).call(e,function(){return this}(),n(56))},function(t,e){var n,i=t.exports={},o=[],r=!1,s=-1;function a(){r=!1,n.length?o=n.concat(o):s=-1,o.length&&l()}function l(){if(!r){var t=setTimeout(a);r=!0;for(var e=o.length;e;){for(n=o,o=[];++s<e;)n&&n[s].run();s=-1,e=o.length}n=null,r=!1,clearTimeout(t)}}function u(t,e){this.fun=t,this.array=e}function c(){}i.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)e[n-1]=arguments[n];o.push(new u(t,e)),1!==o.length||r||setTimeout(l,0)},u.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=c,i.addListener=c,i.once=c,i.off=c,i.removeListener=c,i.removeAllListeners=c,i.emit=c,i.binding=function(t){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(t){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}},function(t,e,n){t.exports={default:n(58),__esModule:!0}},function(t,e,n){n(59),t.exports=n(12).Symbol},function(t,e,n){"use strict";var i=n(15),o=n(11),r=n(19),s=n(17),a=n(10),l=n(13),u=n(18),c=n(21),h=n(25),d=n(22),f=n(20),m=n(60),p=n(61),g=n(62),v=n(32),C=n(31),y=n(46),w=n(16),b=i.getDesc,A=i.setDesc,S=i.create,T=p.get,E=o.Symbol,_=!1,N=f("_hidden"),x=i.isEnum,M=c("symbol-registry"),I=c("symbols"),O="function"==typeof E,L=Object.prototype,P=s&&u((function(){return 7!=S(A({},"a",{get:function(){return A(this,"a",{value:7}).a}})).a}))?function(t,e,n){var i=b(L,e);i&&delete L[e],A(t,e,n),i&&t!==L&&A(L,e,i)}:A,R=function(t){var e=I[t]=S(E.prototype);return e._k=t,s&&_&&P(L,t,{configurable:!0,set:function(e){r(this,N)&&r(this[N],t)&&(this[N][t]=!1),P(this,t,w(1,e))}}),e},k=function(t,e,n){return n&&r(I,e)?(n.enumerable?(r(t,N)&&t[N][e]&&(t[N][e]=!1),n=S(n,{enumerable:w(0,!1)})):(r(t,N)||A(t,N,w(1,{})),t[N][e]=!0),P(t,e,n)):A(t,e,n)},V=function(t,e){C(t);for(var n,i=g(e=y(e)),o=0,r=i.length;r>o;)k(t,n=i[o++],e[n]);return t},F=function(t,e){return void 0===e?S(t):V(S(t),e)},D=function(t){var e=x.call(this,t);return!(e||!r(this,t)||!r(I,t)||r(this,N)&&this[N][t])||e},G=function(t,e){var n=b(t=y(t),e);return!n||!r(I,e)||r(t,N)&&t[N][e]||(n.enumerable=!0),n},U=function(t){for(var e,n=T(y(t)),i=[],o=0;n.length>o;)r(I,e=n[o++])||e==N||i.push(e);return i},q=function(t){for(var e,n=T(y(t)),i=[],o=0;n.length>o;)r(I,e=n[o++])&&i.push(I[e]);return i};O||(E=function(){if(this instanceof E)throw TypeError("Symbol is not a constructor");return R(d(arguments[0]))},l(E.prototype,"toString",(function(){return this._k})),i.create=F,i.isEnum=D,i.getDesc=G,i.setDesc=k,i.setDescs=V,i.getNames=p.get=U,i.getSymbols=q,s&&!n(9)&&l(L,"propertyIsEnumerable",D,!0)),O&&!u((function(){return"[null]"!=JSON.stringify([E()])}))||l(E.prototype,"toJSON",(function(){if(O&&v(this))return this}));var B={for:function(t){return r(M,t+="")?M[t]:M[t]=E(t)},keyFor:function(t){return m(M,t)},useSetter:function(){_=!0},useSimple:function(){_=!1}};i.each.call("hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables".split(","),(function(t){var e=f(t);B[t]=O?e:R(e)})),_=!0,a(a.G+a.W,{Symbol:E}),a(a.S,"Symbol",B),a(a.S+a.F*!O,"Object",{create:F,defineProperty:k,defineProperties:V,getOwnPropertyDescriptor:G,getOwnPropertyNames:U,getOwnPropertySymbols:q}),h(E,"Symbol"),h(Math,"Math",!0),h(o.JSON,"JSON",!0)},function(t,e,n){var i=n(15),o=n(46);t.exports=function(t,e){for(var n,r=o(t),s=i.getKeys(r),a=s.length,l=0;a>l;)if(r[n=s[l++]]===e)return n}},function(t,e,n){var i={}.toString,o=n(46),r=n(15).getNames,s="object"==typeof window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[];t.exports.get=function(t){return s&&"[object Window]"==i.call(t)?function(t){try{return r(t)}catch(t){return s.slice()}}(t):r(o(t))}},function(t,e,n){var i=n(15);t.exports=function(t){var e=i.getKeys(t),n=i.getSymbols;if(n)for(var o,r=n(t),s=i.isEnum,a=0;r.length>a;)s.call(t,o=r[a++])&&e.push(o);return e}},function(t,e,n){t.exports={default:n(64),__esModule:!0}},function(t,e,n){var i=n(15);t.exports=function(t,e){return i.create(t,e)}},function(t,e,n){t.exports={default:n(66),__esModule:!0}},function(t,e,n){n(67),n(4),n(42),n(68),t.exports=n(12).Promise},function(t,e){},function(t,e,n){"use strict";var i,o=n(15),r=n(9),s=n(11),a=n(27),l=n(36),u=n(10),c=n(32),h=n(31),d=n(28),f=n(69),m=n(70),p=n(71).set,g=n(72),v=n(73),C=n(20)("species"),y=n(22)("record"),w=n(74),b="Promise",A=s.process,S="process"==l(A),T=s[b],E=function(t){var e=new T((function(){}));return t&&(e.constructor=Object),T.resolve(e)===e},_=function(){var t=!1;function e(t){var n=new T(t);return p(n,e.prototype),n}try{if(t=T&&T.resolve&&E(),p(e,T),e.prototype=o.create(T.prototype,{constructor:{value:e}}),e.resolve(5).then((function(){}))instanceof e||(t=!1),t&&n(17)){var i=!1;T.resolve(o.setDesc({},"then",{get:function(){i=!0}})),t=i}}catch(e){t=!1}return t}(),N=function(t){var e=h(t)[C];return null!=e?e:t},x=function(t){var e;return!(!c(t)||"function"!=typeof(e=t.then))&&e},M=function(t,e){if(!t.n){t.n=!0;var n=t.c;w((function(){for(var i=t.v,o=1==t.s,r=0,a=function(e){var n,r,s=o?e.ok:e.fail;try{s?(o||(t.h=!0),(n=!0===s?i:s(i))===e.P?e.rej(TypeError("Promise-chain cycle")):(r=x(n))?r.call(n,e.res,e.rej):e.res(n)):e.rej(i)}catch(t){e.rej(t)}};n.length>r;)a(n[r++]);n.length=0,t.n=!1,e&&setTimeout((function(){var e,n,o=t.p;I(o)&&(S?A.emit("unhandledRejection",i,o):(e=s.onunhandledrejection)?e({promise:o,reason:i}):(n=s.console)&&n.error&&n.error("Unhandled promise rejection",i)),t.a=void 0}),1)}))}},I=function(t){var e,n=t[y],i=n.a||n.c,o=0;if(n.h)return!1;for(;i.length>o;)if((e=i[o++]).fail||!I(e.P))return!1;return!0},O=function(t){var e=this;e.d||(e.d=!0,(e=e.r||e).v=t,e.s=2,e.a=e.c.slice(),M(e,!0))},L=function(t){var e,n=this;if(!n.d){n.d=!0,n=n.r||n;try{(e=x(t))?w((function(){var i={r:n,d:!1};try{e.call(t,a(L,i,1),a(O,i,1))}catch(t){O.call(i,t)}})):(n.v=t,n.s=1,M(n,!1))}catch(t){O.call({r:n,d:!1},t)}}};_||(T=function(t){d(t);var e={p:f(this,T,b),c:[],a:void 0,s:0,d:!1,v:void 0,h:!1,n:!1};this[y]=e;try{t(a(L,e,1),a(O,e,1))}catch(t){O.call(e,t)}},n(79)(T.prototype,{then:function(t,e){var n=h(h(this).constructor)[C],i={ok:"function"!=typeof t||t,fail:"function"==typeof e&&e},o=i.P=new(null!=n?n:T)((function(t,e){i.res=t,i.rej=e}));d(i.res),d(i.rej);var r=this[y];return r.c.push(i),r.a&&r.a.push(i),r.s&&M(r,!1),o},catch:function(t){return this.then(void 0,t)}})),u(u.G+u.W+u.F*!_,{Promise:T}),n(25)(T,b),v(T),v(i=n(12)[b]),u(u.S+u.F*!_,b,{reject:function(t){return new this((function(e,n){n(t)}))}}),u(u.S+u.F*(!_||E(!0)),b,{resolve:function(t){return c(n=t)&&(_?"Promise"==l(n):y in n)&&(e=t.constructor,r&&e===T&&this===i||g(e,this))?t:new this((function(e){e(t)}));var e,n}}),u(u.S+u.F*!(_&&n(38)((function(t){T.all(t).catch((function(){}))}))),b,{all:function(t){var e=N(this),n=[];return new e((function(i,r){m(t,!1,n.push,n);var s=n.length,a=Array(s);s?o.each.call(n,(function(t,n){e.resolve(t).then((function(t){a[n]=t,--s||i(a)}),r)})):i(a)}))},race:function(t){var e=N(this);return new e((function(n,i){m(t,!1,(function(t){e.resolve(t).then(n,i)}))}))}})},function(t,e){t.exports=function(t,e,n){if(!(t instanceof e))throw TypeError(n+": use the 'new' operator!");return t}},function(t,e,n){var i=n(27),o=n(30),r=n(33),s=n(31),a=n(34),l=n(35);t.exports=function(t,e,n,u){var c,h,d,f=l(t),m=i(n,u,e?2:1),p=0;if("function"!=typeof f)throw TypeError(t+" is not iterable!");if(r(f))for(c=a(t.length);c>p;p++)e?m(s(h=t[p])[0],h[1]):m(t[p]);else for(d=f.call(t);!(h=d.next()).done;)o(d,m,h.value,e)}},function(t,e,n){var i=n(15).getDesc,o=n(32),r=n(31),s=function(t,e){if(r(t),!o(e)&&null!==e)throw TypeError(e+": can't set as prototype!")};t.exports={set:Object.setPrototypeOf||("__proto__"in{}?function(t,e,o){try{(o=n(27)(Function.call,i(Object.prototype,"__proto__").set,2))(t,[]),e=!(t instanceof Array)}catch(t){e=!0}return function(t,n){return s(t,n),e?t.__proto__=n:o(t,n),t}}({},!1):void 0),check:s}},function(t,e){t.exports=Object.is||function(t,e){return t===e?0!==t||1/t==1/e:t!=t&&e!=e}},function(t,e,n){"use strict";var i=n(15),o=n(20)("species");t.exports=function(t){n(17)&&!(o in t)&&i.setDesc(t,o,{configurable:!0,get:function(){return this}})}},function(t,e,n){var i,o,r,s=n(11),a=n(75).set,l=s.MutationObserver||s.WebKitMutationObserver,u=s.process,c="process"==n(37)(u),h=function(){var t,e;for(c&&(t=u.domain)&&(u.domain=null,t.exit());i;)(e=i.domain)&&e.enter(),i.fn.call(),e&&e.exit(),i=i.next;o=void 0,t&&t.enter()};if(c)r=function(){u.nextTick(h)};else if(l){var d=1,f=document.createTextNode("");new l(h).observe(f,{characterData:!0}),r=function(){f.data=d=-d}}else r=function(){a.call(s,h)};t.exports=function(t){var e={fn:t,next:void 0,domain:c&&u.domain};o&&(o.next=e),i||(i=e,r()),o=e}},function(t,e,n){"use strict";var i,o,r,s=n(27),a=n(76),l=n(77),u=n(78),c=n(11),h=c.process,d=c.setImmediate,f=c.clearImmediate,m=c.MessageChannel,p=0,g={},v="onreadystatechange",C=function(){var t=+this;if(g.hasOwnProperty(t)){var e=g[t];delete g[t],e()}},y=function(t){C.call(t.data)};d&&f||(d=function(t){for(var e=[],n=1;arguments.length>n;)e.push(arguments[n++]);return g[++p]=function(){a("function"==typeof t?t:Function(t),e)},i(p),p},f=function(t){delete g[t]},"process"==n(37)(h)?i=function(t){h.nextTick(s(C,t,1))}:m?(r=(o=new m).port2,o.port1.onmessage=y,i=s(r.postMessage,r,1)):c.addEventListener&&"function"==typeof postMessage&&!c.importScript?(i=function(t){c.postMessage(t+"","*")},c.addEventListener("message",y,!1)):i=v in u("script")?function(t){l.appendChild(u("script"))[v]=function(){l.removeChild(this),C.call(t)}}:function(t){setTimeout(s(C,t,1),0)}),t.exports={set:d,clear:f}},function(t,e){t.exports=function(t,e,n){var i=void 0===n;switch(e.length){case 0:return i?t():t.call(n);case 1:return i?t(e[0]):t.call(n,e[0]);case 2:return i?t(e[0],e[1]):t.call(n,e[0],e[1]);case 3:return i?t(e[0],e[1],e[2]):t.call(n,e[0],e[1],e[2]);case 4:return i?t(e[0],e[1],e[2],e[3]):t.call(n,e[0],e[1],e[2],e[3])}return t.apply(n,e)}},function(t,e,n){t.exports=n(11).document&&document.documentElement},function(t,e,n){var i=n(32),o=n(11).document,r=i(o)&&i(o.createElement);t.exports=function(t){return r?o.createElement(t):{}}},function(t,e,n){var i=n(13);t.exports=function(t,e){for(var n in e)i(t,n,e[n]);return t}},function(t,e,n){t.exports={default:n(81),__esModule:!0}},function(t,e,n){n(82),t.exports=n(12).Object.keys},function(t,e,n){var i=n(29);n(83)("keys",(function(t){return function(e){return t(i(e))}}))},function(t,e,n){t.exports=function(t,e){var i=n(10),o=(n(12).Object||{})[t]||Object[t],r={};r[t]=e(o),i(i.S+i.F*n(18)((function(){o(1)})),"Object",r)}},function(t,e,n){t.exports={default:n(85),__esModule:!0}},function(t,e,n){n(67),n(4),n(42),n(86),n(89),t.exports=n(12).Set},function(t,e,n){"use strict";var i=n(87);n(88)("Set",(function(t){return function(){return t(this,arguments[0])}}),{add:function(t){return i.def(this,t=0===t?0:t,t)}},i)},function(t,e,n){"use strict";var i=n(15),o=n(14),r=n(27),s=n(73),a=n(69),l=n(7),u=n(70),c=n(45),h=n(22)("id"),d=n(19),f=n(32),m=Object.isExtensible||f,p=n(17),g=p?"_s":"size",v=0,C=function(t,e){if(!f(t))return"symbol"==typeof t?t:("string"==typeof t?"S":"P")+t;if(!d(t,h)){if(!m(t))return"F";if(!e)return"E";o(t,h,++v)}return"O"+t[h]},y=function(t,e){var n,i=C(e);if("F"!==i)return t._i[i];for(n=t._f;n;n=n.n)if(n.k==e)return n};t.exports={getConstructor:function(t,e,o,s){var c=t((function(t,n){a(t,c,e),t._i=i.create(null),t._f=void 0,t._l=void 0,t[g]=0,null!=n&&u(n,o,t[s],t)}));return n(79)(c.prototype,{clear:function(){for(var t=this,e=t._i,n=t._f;n;n=n.n)n.r=!0,n.p&&(n.p=n.p.n=void 0),delete e[n.i];t._f=t._l=void 0,t[g]=0},delete:function(t){var e=this,n=y(e,t);if(n){var i=n.n,o=n.p;delete e._i[n.i],n.r=!0,o&&(o.n=i),i&&(i.p=o),e._f==n&&(e._f=i),e._l==n&&(e._l=o),e[g]--}return!!n},forEach:function(t){for(var e,n=r(t,arguments[1],3);e=e?e.n:this._f;)for(n(e.v,e.k,this);e&&e.r;)e=e.p},has:function(t){return!!y(this,t)}}),p&&i.setDesc(c.prototype,"size",{get:function(){return l(this[g])}}),c},def:function(t,e,n){var i,o,r=y(t,e);return r?r.v=n:(t._l=r={i:o=C(e,!0),k:e,v:n,p:i=t._l,n:void 0,r:!1},t._f||(t._f=r),i&&(i.n=r),t[g]++,"F"!==o&&(t._i[o]=r)),t},getEntry:y,setStrong:function(t,e,i){n(8)(t,e,(function(t,e){this._t=t,this._k=e,this._l=void 0}),(function(){for(var t=this,e=t._k,n=t._l;n&&n.r;)n=n.p;return t._t&&(t._l=n=n?n.n:t._t._f)?c(0,"keys"==e?n.k:"values"==e?n.v:[n.k,n.v]):(t._t=void 0,c(1))}),i?"entries":"values",!i,!0),s(t),s(n(12)[e])}}},function(t,e,n){"use strict";var i=n(15),o=n(10),r=n(14),s=n(70),a=n(69);t.exports=function(t,e,l,u,c,h){var d=n(11)[t],f=d,m=c?"set":"add",p=f&&f.prototype,g={};return n(17)&&"function"==typeof f&&(h||p.forEach&&!n(18)((function(){(new f).entries().next()})))?(f=e((function(e,n){a(e,f,t),e._c=new d,null!=n&&s(n,c,e[m],e)})),i.each.call("add,clear,delete,forEach,get,has,set,keys,values,entries".split(","),(function(t){var e="add"==t||"set"==t;!(t in p)||h&&"clear"==t||r(f.prototype,t,(function(n,i){var o=this._c[t](0===n?0:n,i);return e?this:o}))})),"size"in p&&i.setDesc(f.prototype,"size",{get:function(){return this._c.size}})):(f=u.getConstructor(e,t,c,m),n(79)(f.prototype,l)),n(25)(f,t),g[t]=f,o(o.G+o.W+o.F,g),h||u.setStrong(f,t,c),f}},function(t,e,n){var i=n(10);i(i.P,"Set",{toJSON:n(90)("Set")})},function(t,e,n){var i=n(70),o=n(36);t.exports=function(t){return function(){if(o(this)!=t)throw TypeError(t+"#toJSON isn't generic");var e=[];return i(this,!1,e.push,e),e}}}])},t.exports=e()},6082:t=>{"use strict";t.exports=DG},4328:t=>{"use strict";t.exports=grok},7389:t=>{"use strict";t.exports=ui}},e={};function n(i){var o=e[i];if(void 0!==o)return o.exports;var r=e[i]={id:i,loaded:!1,exports:{}};return t[i].call(r.exports,r,r.exports,n),r.loaded=!0,r.exports}n.m=t,n.amdO={},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.u=t=>t+".js",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.hmd=t=>((t=Object.create(t)).children||(t.children=[]),Object.defineProperty(t,"exports",{enumerable:!0,set:()=>{throw new Error("ES Modules may not assign module.exports or exports.*, Use ESM export syntax, instead: "+t.id)}}),t),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})},(()=>{var t;n.g.importScripts&&(t=n.g.location+"");var e=n.g.document;if(!t&&e&&(e.currentScript&&"SCRIPT"===e.currentScript.tagName.toUpperCase()&&(t=e.currentScript.src),!t)){var i=e.getElementsByTagName("script");if(i.length)for(var o=i.length-1;o>-1&&(!t||!/^http(s?):/.test(t));)t=i[o--].src}if(!t)throw new Error("Automatic publicPath is not supported in this browser");t=t.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),n.p=t})(),n.b=document.baseURI||self.location.href,n.nc=void 0;var i=n(3262);peptides=i})();
|
|
1
|
+
var peptides;(()=>{var t={3981:(t,e,n)=>{"use strict";var i;n.d(e,{o:()=>i}),function(t){t.BASE="HELM_BASE",t.SUGAR="HELM_SUGAR",t.LINKER="HELM_LINKER",t.AA="HELM_AA",t.CHEM="HELM_CHEM",t.BLOB="HELM_BLOB",t.NUCLEOTIDE="HELM_NUCLETIDE"}(i||(i={}))},4971:(t,e,n)=>{"use strict";n.d(e,{pj:()=>o});var i=n(6082);async function o(){const t=i.Func.find({package:"Bio",name:"getMonomerLibHelper"});if(0===t.length)throw new Error('Package "Bio" must be installed for MonomerLibHelper.');return(await t[0].prepare().call()).getOutputParamValue()}},439:(t,e,n)=>{"use strict";n.d(e,{B5:()=>a,Hi:()=>i,YI:()=>o,_S:()=>c,b9:()=>h,gp:()=>r,ot:()=>d,q7:()=>u});var i,o,r,s=n(2738);!function(t){t.FASTA="fasta",t.SEPARATOR="separator",t.HELM="helm",t.CUSTOM="custom",t.BILN="biln"}(i||(i={})),function(t){t.DNA="DNA",t.RNA="RNA",t.PT="PT",t.UN="UN"}(o||(o={})),function(t){t.aligned="aligned",t.alphabet="alphabet",t.alphabetSize=".alphabetSize",t.alphabetIsMultichar=".alphabetIsMultichar",t.separator="separator",t.isHelmCompatible=".isHelmCompatible",t.positionNames=".positionNames",t.positionLabels=".positionLabels",t.regions=".regions",t.positionShift=".positionShift",t.selectedPosition=".selectedPosition",t.polymerTypeColumnName=".polymerTypeColumnName",t.annotations=".annotations",t.numberingScheme=".numberingScheme",t.annotationColumnName=".annotationColumnName"}(r||(r={}));const a=/(?:\[([A-Za-z0-9_\-,()]+)\])|([A-Za-z\-])/g,l=new class{constructor(){this.fasta={peptide:new Set(["G","L","Y","S","E","Q","D","N","F","A","K","R","H","C","V","P","W","I","M","T"]),dna:new Set(["A","C","G","T"]),rna:new Set(["A","C","G","U"])}}},u=[new s.aD(o.PT,l.fasta.peptide,.5),new s.aD(o.DNA,l.fasta.dna,.55),new s.aD(o.RNA,l.fasta.rna,.55)],c="",h={[i.FASTA]:"-",[i.SEPARATOR]:"",[i.HELM]:"*",[i.BILN]:""},d=" , "},2003:(t,e,n)=>{"use strict";n.d(e,{Hi:()=>i.Hi,SM:()=>o.SM,YI:()=>i.YI,gp:()=>i.gp,ot:()=>i.ot,zS:()=>o.zS});var i=n(439),o=n(7194)},4025:(t,e,n)=>{"use strict";n.d(e,{j:()=>o});var i=n(6082);n(439),n(7194);const o=new class{constructor(){this.seqHandler="seq-handler",this.notationProvider="seq-handler.notation-provider"}};i.SemanticValue},2738:(t,e,n)=>{"use strict";n.d(e,{XN:()=>o,aD:()=>i}),n(439);class i{constructor(t,e,n){this.name=t,this.alphabet=e,this.cutoff=n}}class o extends i{constructor(t,e,n){super(t.name,t.alphabet,t.cutoff),this.freq=e,this.similarity=n}}},7194:(t,e,n)=>{"use strict";n.d(e,{Mu:()=>b,zS:()=>N,SM:()=>M,qp:()=>E});var i=n(6082),o=n(144),r=n.n(o);class s extends Float32Array{}function a(t){let e=0;for(let n=0;n<t.length;n++)e+=t[n]*t[n];return Math.sqrt(e)}var l=n(2738),u=n(439);class c{static makePalette(t,e=!1,n=c){const i={};return t.forEach((t=>{const n=t[0],o=t[1];n.forEach(((t,n)=>{i[t]=this.colourPalette[o][e?0:n]}))})),new n(i)}constructor(t){this._palette=t}get(t,e){return this._palette[t]}}c.undefinedColor="rgb(100,100,100)",c.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)"]};class h extends c{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,h)),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,h)),this.grokGroups}static get RasMol(){return void 0===this.rasMol&&(this.rasMol=new h({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 h.aaSynonyms?h.aaSynonyms[t]:t;return super.get(e)}}h.aaSynonyms={MeNle:"L",MeA:"A",MeG:"G",MeF:"F"};class d{static getPalette(t="grok"){switch(t){case"grok":return h.GrokGroups;case"lesk":return h.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"){const n=this.getPalette(e);let[i,o]=this.getInnerOuter(t);if(i=i.length>6?`${i.slice(0,3)}...`:i,o=o.length>6?`${o.slice(0,3)}...`:o,1==t.length||"("==t[1]){const e=t[0]?.toUpperCase();return e in n?[n.get(e),e,o,1]:[this.undefinedColor,i,o,1]}if("d"==t[0]&&t[1]in n&&(2==t.length||"("==t[2])){const e=t[1]?.toUpperCase();return e in n?[n.get(e),e,o,2]:[this.undefinedColor,i,o,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 n?[n.get(e),e,o,3]:[this.undefinedColor,i,o,3]}if(t[0]?.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 n?[n.get(e),e,o,4]:[this.undefinedColor,i,o,4]}return[this.undefinedColor,i,o,0]}}d.SemType="Aminoacids",d.SemTypeMultipleAlignment="AminoacidsMultipleAlignment",d.undefinedColor="rgb(100,100,100)",d.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"},d.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"},d.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(*)*"},d.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"};class f extends c{static get Chromatogram(){return void 0===this.chromatogram&&(this.chromatogram=new f({A:"green",C:"blue",G:"black",T:"red",U:"red",others:"gray"})),this.chromatogram}}class m{}m.SemType="Nucleotides",m.SemTypeMultipleAlignment="NucleotidesMultipleAlignment",m.Names={A:"Adenine",C:"Cytosine",G:"Guanine",T:"Thymine",U:"Uracil"};var p=n(4971);function g(t,e=!0){if(null==t)return"rgb(100,100,100)";const n=i.Color.fromHtml(t);if(e){const t=i.Color.g(n),e=i.Color.r(n),o=i.Color.b(n),r=Math.sqrt(Math.pow(0-e,2)+Math.pow(0-t,2)+Math.pow(0-o,2));if(r>210)return`rgb(${e/r*210},${t/r*210},${o/r*210})`}return i.Color.toRgb(n)}class v{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 C{}class y extends C{get(t,e){return"#666666"}}class w extends C{static get palette(){return w._pallete||(w._pallete=w.buildPalette()),w._pallete}static buildPalette(){return(0,p.pj)().then((t=>{t.awaitLoaded(1/0).then((()=>{const e=t.getMonomerLib();e.onChanged.subscribe((()=>{w.customMonomerColors={},w.polymerTypes=e.getPolymerTypes();for(const t of this.polymerTypes){const n=e.getMonomerSymbolsByType(t);for(const i of n){const n=e.getMonomer(t,i);n?.meta?.colors?.default?.background&&(this.customMonomerColors[i]||(this.customMonomerColors[i]={}),this.customMonomerColors[i][t]=g(n.meta.colors.default.background))}}}))}))})),[].concat(...Object.values(c.colourPalette))}get(t,e){const n=w.palette.length,i=w.customMonomerColors[t],o=e??"PEPTIDE";if(i&&i[o])return i[o];const r=v.hashCode(t)%n;return g(w.palette[r])}}w._pallete=null,w.customMonomerColors={},w.polymerTypes=[];class A extends c{static get Gray(){return void 0===this.gray&&(this.gray=new y),this.gray}static get Color(){return void 0===this.color&&(this.color=new w),this.color}}n(3981);class b{get length(){return this.mList.length}get graphInfo(){}isGap(t){return this.getOriginal(t)===this.gapOriginalMonomer}getCanonical(t){if(this.length<=t)throw new Error("Index out of bounds");const e=this.mList[t];return e!==this.gapOriginalMonomer?e:u._S}getOriginal(t){if(this.length<=t)throw new Error("Index out of bounds");return this.mList[t]}getCanonicalRegion(t,e){const n=Math.min(Math.max(0,t),this.length),i=Math.max(Math.min(this.length,e),0)-n,o=this.gapOriginalMonomer;return new Array(i).fill(null).map(((t,e)=>{const i=this.mList[e+n];return i===o?u._S:i}))}getOriginalRegion(t,e){const n=Math.min(Math.max(0,t),this.length),i=Math.max(Math.min(this.length,e),0);return new Array(i-n).fill(null).map(((t,e)=>this.mList[e+n]))}get gapOriginal(){return this.gapOriginalMonomer}constructor(t,e){this.mList=t,this.gapOriginalMonomer=e}}class S extends b{constructor(t,e,n,i){super(t.flat(),i),this.mListSeparated=t,this.connections=e,this._graphInfo=void 0,this.polymerTypes=t.map(((t,e)=>new Array(t.length).fill(n[e]))).flat()}get graphInfo(){return this._graphInfo??(this._graphInfo=this.parseConnections()),this._graphInfo}parseConnections(){const t={connections:[],disjointSeqStarts:[],polymerTypes:this.polymerTypes};if((this.connections?.length??0)>0){let e=0;for(let n=0;n<this.mListSeparated.length;++n)t.disjointSeqStarts.push(e),e+=this.mListSeparated[n].length;const n=(this.connections??"").split("|").filter((t=>(t?.length??0)>0)),i=/^(PEPTIDE|RNA|BLOB|CHEM)\d{1,2}$/,o=/^\d{1,2}:R\d{1}-\d{1,2}:R\d{1}$/;for(const e of n){const n=e.split(",");if(3!==n.length||!o.test(n[2])||!i.test(n[0])||!i.test(n[1]))continue;const r=parseInt(n[0].replace(/^(PEPTIDE|RNA|BLOB|CHEM)/,""))-1,s=parseInt(n[1].replace(/^(PEPTIDE|RNA|BLOB|CHEM)/,""))-1,a=n[0].replace(/\d{1,2}$/,""),l=n[1].replace(/\d{1,2}$/,"");if(r<0||r>=this.mListSeparated.length||s<0||s>=this.mListSeparated.length)continue;const u=n[2].split("-");if(2!==u.length)continue;const c=u[0].split(":"),h=u[1].split(":");if(2!==c.length||2!==h.length)continue;const d=parseInt(c[0])-1,f=parseInt(h[0])-1;d<0||d>=this.mListSeparated[r].length||f<0||f>=this.mListSeparated[s].length||t.connections.push({seq1Type:a,seq2Type:l,seqIndex1:r,seqIndex2:s,monomerIndex1:d,monomerIndex2:f,rGroup1:parseInt(c[1].substring(1)),rGroup2:parseInt(h[1].substring(1))})}}return t}}const T=t=>{const e=r()(t.toString().matchAll(u.B5)).map((t=>t[2]??t[1])).toArray();return new b(e,u.b9[u.Hi.FASTA])},E=t=>{const e=t.indexOf("}$"),n=t.substring(0,e+1),i=t.indexOf("$",e+2),o=t.substring(e+2,i),r=n.split("}|");for(let t=0;t<r.length-1;t++)r[t]=r[t]+"}";const s=r.map((t=>(t.match(/(?<=\{).+(?=})/)?.[0]?.split(".")??[]).map((t=>{return(e=t).startsWith("[")&&e.endsWith("]")?e.slice(1,-1):e;var e})))),a=r.map((t=>t.replace(/\d{1,2}\{.+\}/,"")));return new S(s,o??"",a,u.b9[u.Hi.HELM])},_=/([^\W_]+)/g;function N(t,e){if(t.length<=e)return t;const n=t.match(_),i=t.length>e||(n?.length??0)>1,o=n?.[0]??" ";return i?o.substring(0,e-1)+"…":o}function x(t,e,n="-"){const i=e.map((e=>{const i=function(t,e,n="-"){const i=new Set([...new Set(Object.keys(t)),...e]);i.delete(n);const o=[],r=[];for(const n of i)o.push(n in t?t[n]:0),r.push(e.has(n)?1:0);const l=new s(o),u=new s(r);return function(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}(l,u)/(a(l)*a(u))}(t,e.alphabet,n);return new l.XN(e,t,i)}));let o;const r=Math.max(...i.map((t=>t.similarity>t.cutoff?t.similarity:-1)));return o=r>0?i.find((t=>t.similarity===r)).name:u.YI.UN,o}function M(t,e,n=5){let o;if(t.semType==i.SEMTYPE.MACROMOLECULE)o=e.getSeqHandler(t).alphabet;else{const e=function(t,e,n){const i=t.categories;return function(t,e){const n={};let i=!0,o=null;for(const r of t)if(null==o?o=r.length:r.length!==o&&(i=!1),r.length>=e)for(let t=0;t<r.length;++t){const e=r.getCanonical(t);e in n||(n[e]=0),n[e]+=1}return{freq:n,sameLength:i}}(r().enumerate(t.getRawData()).map((([t,e])=>n(i[t]))),e)}(t,n,T);o=x(e.freq,u.q7)}return function(t){switch(t){case u.YI.PT:return h.GrokGroups;case u.YI.DNA:case u.YI.RNA:return f.Chromatogram;default:return A.Color}}(o)}},3077:(t,e,n)=>{"use strict";n.d(e,{R:()=>o});var i=n(6082);function o(t,e){const n=t=>{const e=s.columns.addNewString((t+1).toString());return o.push(e),e},o=[],r=t.length,s=i.DataFrame.create(r),a=e.getSeqHandler(t);for(let t=0;t<r;++t){const e=a.getSplitted(t);for(let i=0;i<e.length;++i){const r=e.getCanonical(i);((o[i]??null)||n(i)).set(t,r,!1)}}return s}},4326:(t,e,n)=>{"use strict";n.d(e,{P4:()=>s,fH:()=>o});var i,o,r,s,a,l,u=n(6082);!function(t){t.tooltipWebLogo=".tooltipWebLogo"}(i||(i={})),function(t){t.Entropy="Entropy",t.full="100%"}(o||(o={})),function(t){t.TOP="top",t.MIDDLE="middle",t.BOTTOM="bottom"}(r||(r={})),function(t){t.LEFT="left",t.CENTER="center",t.RIGHT="right"}(s||(s={})),function(t){t.AUTO="auto",t.ON="on",t.OFF="off"}(a||(a={})),function(t){t.Filtered="Filtered",t.Selected="Selected"}(l||(l={})),new class{constructor(){this.sequenceColumnName=null,this.valueAggrType=u.AGG.TOTAL_COUNT,this.valueColumnName="Activity",this.startPositionName=null,this.endPositionName=null,this.skipEmptySequences=!0,this.skipEmptyPositions=!1,this.shrinkEmptyTail=!0,this.backgroundColor=4294967295,this.positionHeight=o.Entropy,this.positionWidth=20,this.verticalAlignment=r.MIDDLE,this.horizontalAlignment=s.CENTER,this.fixWidth=!1,this.fitArea=!0,this.minHeight=25,this.maxHeight=300,this.maxMonomerLetters=5,this.showPositionLabels=!0,this.positionMarginState=a.AUTO,this.positionMargin=0,this.filterSource=l.Filtered}}},5540:(t,e,n)=>{"use strict";t=n.hmd(t);var i,o=(i="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0,function(t={}){var e,n,o=void 0!==t?t:{};o.ready=new Promise((function(t,i){e=t,n=i}));var r,s=Object.assign({},o),a="object"==typeof window,l="function"==typeof importScripts,u=("object"==typeof process&&"object"==typeof process.versions&&process.versions.node,"");(a||l)&&(l?u=self.location.href:"undefined"!=typeof document&&document.currentScript&&(u=document.currentScript.src),i&&(u=i),u=0!==u.indexOf("blob:")?u.substr(0,u.replace(/[?#].*/,"").lastIndexOf("/")+1):"",l&&(r=t=>{var e=new XMLHttpRequest;return e.open("GET",t,!1),e.responseType="arraybuffer",e.send(null),new Uint8Array(e.response)})),o.print||console.log.bind(console);var c,h,d=o.printErr||console.warn.bind(console);Object.assign(o,s),s=null,o.arguments&&o.arguments,o.thisProgram&&o.thisProgram,o.quit&&o.quit,o.wasmBinary&&(c=o.wasmBinary),o.noExitRuntime,"object"!=typeof WebAssembly&&T("no native wasm support detected");var f,m,p,g=!1;function v(){var t=h.buffer;o.HEAP8=f=new Int8Array(t),o.HEAP16=new Int16Array(t),o.HEAP32=new Int32Array(t),o.HEAPU8=m=new Uint8Array(t),o.HEAPU16=new Uint16Array(t),o.HEAPU32=p=new Uint32Array(t),o.HEAPF32=new Float32Array(t),o.HEAPF64=new Float64Array(t)}var C=[],y=[],w=[],A=0,b=null,S=null;function T(t){o.onAbort&&o.onAbort(t),d(t="Aborted("+t+")"),g=!0,t+=". Build with -sASSERTIONS for more info.";var e=new WebAssembly.RuntimeError(t);throw n(e),e}var E,_;function N(t){return t.startsWith("data:application/octet-stream;base64,")}function x(t){try{if(t==E&&c)return new Uint8Array(c);if(r)return r(t);throw"both async and sync fetching of the wasm failed"}catch(t){T(t)}}function M(t,e,n){return function(t){return c||!a&&!l||"function"!=typeof fetch?Promise.resolve().then((function(){return x(t)})):fetch(t,{credentials:"same-origin"}).then((function(e){if(!e.ok)throw"failed to load wasm binary file at '"+t+"'";return e.arrayBuffer()})).catch((function(){return x(t)}))}(t).then((function(t){return WebAssembly.instantiate(t,e)})).then((function(t){return t})).then(n,(function(t){d("failed to asynchronously prepare wasm: "+t),T(t)}))}function I(t){for(;t.length>0;)t.shift()(o)}function O(t){this.excPtr=t,this.ptr=t-24,this.set_type=function(t){p[this.ptr+4>>2]=t},this.get_type=function(){return p[this.ptr+4>>2]},this.set_destructor=function(t){p[this.ptr+8>>2]=t},this.get_destructor=function(){return p[this.ptr+8>>2]},this.set_caught=function(t){t=t?1:0,f[this.ptr+12|0]=t},this.get_caught=function(){return 0!=f[this.ptr+12|0]},this.set_rethrown=function(t){t=t?1:0,f[this.ptr+13|0]=t},this.get_rethrown=function(){return 0!=f[this.ptr+13|0]},this.init=function(t,e){this.set_adjusted_ptr(0),this.set_type(t),this.set_destructor(e)},this.set_adjusted_ptr=function(t){p[this.ptr+16>>2]=t},this.get_adjusted_ptr=function(){return p[this.ptr+16>>2]},this.get_exception_ptr=function(){if(q(this.get_type()))return p[this.excPtr>>2];var t=this.get_adjusted_ptr();return 0!==t?t:this.excPtr}}function L(t){var e=h.buffer;try{return h.grow(t-e.byteLength+65535>>>16),v(),1}catch(t){}}function P(t){return o["_"+t]}N(E="wasmDbscan.wasm")||(_=E,E=o.locateFile?o.locateFile(_,u):u+_);var R="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function k(t,e,n,i,o){var r={string:t=>{var e=0;return null!=t&&0!==t&&(e=function(t){var e=function(t){for(var e=0,n=0;n<t.length;++n){var i=t.charCodeAt(n);i<=127?e++:i<=2047?e+=2:i>=55296&&i<=57343?(e+=4,++n):e+=3}return e}(t)+1,n=U(e);return function(t,e,n){!function(t,e,n,i){if(!(i>0))return 0;for(var o=n+i-1,r=0;r<t.length;++r){var s=t.charCodeAt(r);if(s>=55296&&s<=57343&&(s=65536+((1023&s)<<10)|1023&t.charCodeAt(++r)),s<=127){if(n>=o)break;e[n++]=s}else if(s<=2047){if(n+1>=o)break;e[n++]=192|s>>6,e[n++]=128|63&s}else if(s<=65535){if(n+2>=o)break;e[n++]=224|s>>12,e[n++]=128|s>>6&63,e[n++]=128|63&s}else{if(n+3>=o)break;e[n++]=240|s>>18,e[n++]=128|s>>12&63,e[n++]=128|s>>6&63,e[n++]=128|63&s}}e[n]=0}(t,m,e,n)}(t,n,e),n}(t)),e},array:t=>{var e,n,i=U(t.length);return e=t,n=i,f.set(e,n),i}},s=P(t),a=[],l=0;if(i)for(var u=0;u<i.length;u++){var c=r[n[u]];c?(0===l&&(l=D()),a[u]=c(i[u])):a[u]=i[u]}var h=s.apply(null,a);return function(t){return 0!==l&&G(l),function(t){return"string"===e?(n=t)?function(t,e,n){for(var i=e+n,o=e;t[o]&&!(o>=i);)++o;if(o-e>16&&t.buffer&&R)return R.decode(t.subarray(e,o));for(var r="";e<o;){var s=t[e++];if(128&s){var a=63&t[e++];if(192!=(224&s)){var l=63&t[e++];if((s=224==(240&s)?(15&s)<<12|a<<6|l:(7&s)<<18|a<<12|l<<6|63&t[e++])<65536)r+=String.fromCharCode(s);else{var u=s-65536;r+=String.fromCharCode(55296|u>>10,56320|1023&u)}}else r+=String.fromCharCode((31&s)<<6|a)}else r+=String.fromCharCode(s)}return r}(m,n,i):"":"boolean"===e?Boolean(t):t;var n,i}(t)}(h)}var V,F={__cxa_throw:function(t,e,n){throw new O(t).init(e,n),t},abort:function(){T("")},emscripten_memcpy_big:function(t,e,n){m.copyWithin(t,e,e+n)},emscripten_resize_heap:function(t){var e,n=m.length,i=2147483648;if((t>>>=0)>i)return!1;for(var o=1;o<=4;o*=2){var r=n*(1+.2/o);if(r=Math.min(r,t+100663296),L(Math.min(i,(e=Math.max(t,r))+(65536-e%65536)%65536)))return!0}return!1}},D=(function(){var t,e,i,r,s={env:F,wasi_snapshot_preview1:F};function a(t,e){var n,i=t.exports;return o.asm=i,h=o.asm.memory,v(),o.asm.__indirect_function_table,n=o.asm.__wasm_call_ctors,y.unshift(n),function(t){if(A--,o.monitorRunDependencies&&o.monitorRunDependencies(A),0==A&&(null!==b&&(clearInterval(b),b=null),S)){var e=S;S=null,e()}}(),i}if(A++,o.monitorRunDependencies&&o.monitorRunDependencies(A),o.instantiateWasm)try{return o.instantiateWasm(s,a)}catch(t){d("Module.instantiateWasm callback failed with error: "+t),n(t)}(t=c,e=E,i=s,r=function(t){a(t.instance)},t||"function"!=typeof WebAssembly.instantiateStreaming||N(e)||"function"!=typeof fetch?M(e,i,r):fetch(e,{credentials:"same-origin"}).then((function(t){return WebAssembly.instantiateStreaming(t,i).then(r,(function(t){return d("wasm streaming compile failed: "+t),d("falling back to ArrayBuffer instantiation"),M(e,i,r)}))}))).catch(n)}(),o._dbscan=function(){return(o._dbscan=o.asm.dbscan).apply(null,arguments)},o._malloc=function(){return(o._malloc=o.asm.malloc).apply(null,arguments)},o._free=function(){return(o._free=o.asm.free).apply(null,arguments)},function(){return(D=o.asm.stackSave).apply(null,arguments)}),G=function(){return(G=o.asm.stackRestore).apply(null,arguments)},U=function(){return(U=o.asm.stackAlloc).apply(null,arguments)},q=function(){return(q=o.asm.__cxa_is_pointer_type).apply(null,arguments)};function B(){function t(){V||(V=!0,o.calledRun=!0,g||(I(y),e(o),o.onRuntimeInitialized&&o.onRuntimeInitialized(),function(){if(o.postRun)for("function"==typeof o.postRun&&(o.postRun=[o.postRun]);o.postRun.length;)t=o.postRun.shift(),w.unshift(t);var t;I(w)}()))}A>0||(function(){if(o.preRun)for("function"==typeof o.preRun&&(o.preRun=[o.preRun]);o.preRun.length;)t=o.preRun.shift(),C.unshift(t);var t;I(C)}(),A>0||(o.setStatus?(o.setStatus("Running..."),setTimeout((function(){setTimeout((function(){o.setStatus("")}),1),t()}),1)):t()))}if(o.ccall=k,o.cwrap=function(t,e,n,i){var o=!n||n.every((t=>"number"===t||"boolean"===t));return"string"!==e&&o&&!i?P(t):function(){return k(t,e,n,arguments)}},S=function t(){V||B(),V||(S=t)},o.preInit)for("function"==typeof o.preInit&&(o.preInit=[o.preInit]);o.preInit.length>0;)o.preInit.pop()();return B(),t.ready});"object"==typeof exports?t.exports=o:"function"==typeof define&&n.amdO?define([],(function(){return o})):"object"==typeof exports&&(exports.exportCppDbscanLib=o)},4329:(t,e,n)=>{"use strict";n.d(e,{_:()=>r});var i=function(t,e,n,i){return new(n||(n=Promise))((function(o,r){function s(t){try{l(i.next(t))}catch(t){r(t)}}function a(t){try{l(i.throw(t))}catch(t){r(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(s,a)}l((i=i.apply(t,e||[])).next())}))};let o=null;function r(){return i(this,void 0,void 0,(function*(){if(!navigator.gpu)return console.error("WebGPU is not supported in this browser"),null;if(!o&&(o=yield navigator.gpu.requestAdapter(),null==o))return null;let t=null;return"info"in o&&(t=o.info),t?s(t.description,s(t.vendor,"No GPU description available")):"No GPU description available"}))}function s(t,e){return t&&""!=t?t:e}},1199:(t,e,n)=>{"use strict";n.d(e,{Z:()=>i});new Uint32Array(65536);var i;!function(t){t.HAMMING="Hamming",t.LEVENSHTEIN="Levenshtein",t.NEEDLEMANN_WUNSCH="Needlemann-Wunsch",t.MONOMER_CHEMICAL_DISTANCE="Monomer chemical distance"}(i||(i={})),i.HAMMING,i.LEVENSHTEIN,i.NEEDLEMANN_WUNSCH,i.MONOMER_CHEMICAL_DISTANCE},8774:(t,e,n)=>{"use strict";n.d(e,{A:()=>i});class i{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,o=i._createBuffer(n);if(e)for(let t=0;t<o.length;t++)o[t]=-1;this._data=o,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 i(t._length);n._length=t._length,n._data=i._createBuffer(n._length),n._version=0;const o=t.lengthInInts;for(let i=0;i<o;i++)n._data[i]=t._data[i]&e._data[i];return n}static _createBuffer(t){return new Uint32Array(Math.floor((t+31)/32))}static fromValues(t){const e=new i(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 i(t);for(let i=0;i<t;++i)n.setBit(i,e(i));return n._version=0,n}static fromString(t){return i.fromSeq(t.length,(e=>"1"==t.charAt(e)))}static fromUint32Array(t,e){const n=new i(t);return n._data=e,n}static fromBytes(t){const e=t.length,n=new i(8*e);n._data=new Uint32Array(Math.floor((e+3)/4)),n._length=8*e;let o=0,r=0;for(;e-r>=4;)n._data[o++]=255&t[r]|(255&t[r+1])<<8|(255&t[r+2])<<16|(255&t[r+3])<<24,r+=4;return e-r==3&&(n._data[o]=(255&t[r+2])<<16),e-r==2&&(n._data[o]|=(255&t[r+1])<<8),e-r==1&&(n._data[o]|=255&t[r]),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 i(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 i.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),r=Math.max(t,e);if(n)for(let t=o;t<=r;t++)this.setTrue(t);else for(let t=o;t<=r;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!!(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+=i._onBitCount[255&t];let n=this._data[e];const o=31&this._length;for(0!=o&&(n&=~(4294967295<<o));0!=n;n>>>=8)this._selectedCount+=i._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 o=this.lengthInInts;let r=0;for(;r<o-1;r++)for(let e=this._data[r]&t._data[r];0!=e;e>>>=8)n+=i._onBitCount[255&e];let s=this._data[r]&t._data[r];const a=31&this._length;for(0!=a&&(s&=~(4294967295<<a));0!=s;s>>>=8)n+=i._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 o=this.lengthInInts;for(let r=Math.floor(t/32);r<o;r++){let o=e?this._data[r]:~this._data[r];if(0!=n)o&=4294967295<<n&4294967295,n=0;else if(!e&&-4294967296==o)continue;for(let e=0;0!=o;e+=8,o>>>=8){const n=i._firstOnBit[255&o];if(n>=0)return(t=n+32*r+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 o=Math.floor(t/32);o>=0;o--){let t=e?this._data[o]:~this._data[o];0!=n&&(t&=~(4294967295<<n),n=0);for(let e=24;0!=t;e-=8,t<<=8){const n=i._lastOnBit[t>>>24];if(n>=0)return n+32*o+e}}return-1}}i._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]),i._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]),i._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])},7233:t=>{!function(){"use strict";var e=document,n=window,i=e.documentElement,o=e.createElement.bind(e),r=o("div"),s=o("table"),a=o("tbody"),l=o("tr"),u=Array.isArray,c=Array.prototype,h=c.concat,d=c.filter,f=c.indexOf,m=c.map,p=c.push,g=c.slice,v=c.some,C=c.splice,y=/^#(?:[\w-]|\\.|[^\x00-\xa0])*$/,w=/^\.(?:[\w-]|\\.|[^\x00-\xa0])*$/,A=/<.+>/,b=/^\w+$/;function S(t,e){var n,i=!!(n=e)&&11===n.nodeType;return t&&(i||M(e)||I(e))?!i&&w.test(t)?e.getElementsByClassName(t.slice(1).replace(/\\/g,"")):!i&&b.test(t)?e.getElementsByTagName(t):e.querySelectorAll(t):[]}var T=function(){function t(t,i){if(t){if(N(t))return t;var o=t;if(L(t)){var r=i||e;if(!(o=y.test(t)&&M(r)?r.getElementById(t.slice(1).replace(/\\/g,"")):A.test(t)?X(t):N(r)?r.find(t):L(r)?_(r).find(t):S(t,r)))return}else if(O(t))return this.ready(t);(o.nodeType||o===n)&&(o=[o]),this.length=o.length;for(var s=0,a=this.length;s<a;s++)this[s]=o[s]}}return t.prototype.init=function(e,n){return new t(e,n)},t}(),E=T.prototype,_=E.init;function N(t){return t instanceof T}function x(t){return!!t&&t===t.window}function M(t){return!!t&&9===t.nodeType}function I(t){return!!t&&1===t.nodeType}function O(t){return"function"==typeof t}function L(t){return"string"==typeof t}function P(t){return void 0===t}function R(t){return null===t}function k(t){return!isNaN(parseFloat(t))&&isFinite(t)}function V(t){if("object"!=typeof t||null===t)return!1;var e=Object.getPrototypeOf(t);return null===e||e===Object.prototype}function F(t,e,n){if(n){for(var i=t.length;i--;)if(!1===e.call(t[i],i,t[i]))return t}else if(V(t))for(var o=Object.keys(t),r=(i=0,o.length);i<r;i++){var s=o[i];if(!1===e.call(t[s],s,t[s]))return t}else for(i=0,r=t.length;i<r;i++)if(!1===e.call(t[i],i,t[i]))return t;return t}function D(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n="boolean"==typeof t[0]&&t.shift(),i=t.shift(),o=t.length;if(!i)return{};if(!o)return D(n,_,i);for(var r=0;r<o;r++){var s=t[r];for(var a in s)n&&(u(s[a])||V(s[a]))?(i[a]&&i[a].constructor===s[a].constructor||(i[a]=new s[a].constructor),D(n,i[a],s[a])):i[a]=s[a]}return i}_.fn=_.prototype=E,E.length=0,E.splice=C,"function"==typeof Symbol&&(E[Symbol.iterator]=c[Symbol.iterator]),_.isWindow=x,_.isFunction=O,_.isArray=u,_.isNumeric=k,_.isPlainObject=V,_.each=F,E.each=function(t){return F(this,t)},E.empty=function(){return this.each((function(t,e){for(;e.firstChild;)e.removeChild(e.firstChild)}))},_.extend=D,E.extend=function(t){return D(E,t)};var G=/\S+/g;function U(t){return L(t)&&t.match(G)||[]}function q(t,e,i){if(I(t)){var o=n.getComputedStyle(t,null);return i?o.getPropertyValue(e)||void 0:o[e]||t.style[e]}}function B(t,e){return parseInt(q(t,e),10)||0}function H(t,e){return B(t,"border".concat(e?"Left":"Top","Width"))+B(t,"padding".concat(e?"Left":"Top"))+B(t,"padding".concat(e?"Right":"Bottom"))+B(t,"border".concat(e?"Right":"Bottom","Width"))}E.toggleClass=function(t,e){var n=U(t),i=!P(e);return this.each((function(t,o){I(o)&&F(n,(function(t,n){i?e?o.classList.add(n):o.classList.remove(n):o.classList.toggle(n)}))}))},E.addClass=function(t){return this.toggleClass(t,!0)},E.removeAttr=function(t){var e=U(t);return this.each((function(t,n){I(n)&&F(e,(function(t,e){n.removeAttribute(e)}))}))},E.attr=function(t,e){if(t){if(L(t)){if(arguments.length<2){if(!this[0]||!I(this[0]))return;var n=this[0].getAttribute(t);return R(n)?void 0:n}return P(e)?this:R(e)?this.removeAttr(t):this.each((function(n,i){I(i)&&i.setAttribute(t,e)}))}for(var i in t)this.attr(i,t[i]);return this}},E.removeClass=function(t){return arguments.length?this.toggleClass(t,!1):this.attr("class","")},E.hasClass=function(t){return!!t&&v.call(this,(function(e){return I(e)&&e.classList.contains(t)}))},E.get=function(t){return P(t)?g.call(this):this[(t=Number(t))<0?t+this.length:t]},E.eq=function(t){return _(this.get(t))},E.first=function(){return this.eq(0)},E.last=function(){return this.eq(-1)},E.text=function(t){return P(t)?this.get().map((function(t){return I(t)||(e=t)&&3===e.nodeType?t.textContent:"";var e})).join(""):this.each((function(e,n){I(n)&&(n.textContent=t)}))};var Y={};function j(t){return"none"===q(t,"display")}function W(t,e){var n=t&&(t.matches||t.webkitMatchesSelector||t.msMatchesSelector);return!!n&&!!e&&n.call(t,e)}function $(t){return L(t)?function(e,n){return W(n,t)}:O(t)?t:N(t)?function(e,n){return t.is(n)}:t?function(e,n){return n===t}:function(){return!1}}function z(t,e){return e?t.filter(e):t}E.filter=function(t){var e=$(t);return _(d.call(this,(function(t,n){return e.call(t,n,t)})))},E.detach=function(t){return z(this,t).each((function(t,e){e.parentNode&&e.parentNode.removeChild(e)})),this};var K=/^\s*<(\w+)[^>]*>/,Z=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,Q={"*":r,tr:a,td:l,th:l,thead:s,tbody:s,tfoot:s};function X(t){if(!L(t))return[];if(Z.test(t))return[o(RegExp.$1)];var e=K.test(t)&&RegExp.$1,n=Q[e]||Q["*"];return n.innerHTML=t,_(n.childNodes).detach().get()}function J(t,e,n,i){for(var o=[],r=O(e),s=i&&$(i),a=0,l=t.length;a<l;a++)if(r){var u=e(t[a]);u.length&&p.apply(o,u)}else for(var c=t[a][e];!(null==c||i&&s(-1,c));)o.push(c),c=n?c[e]:null;return o}function tt(t){return t.multiple&&t.options?J(d.call(t.options,(function(t){return t.selected&&!t.disabled&&!t.parentNode.disabled})),"value"):t.value||""}function et(t){return t.length>1?d.call(t,(function(t,e,n){return f.call(n,t)===e})):t}_.parseHTML=X,E.has=function(t){var e=L(t)?function(e,n){return S(t,n).length}:function(e,n){return n.contains(t)};return this.filter(e)},E.not=function(t){var e=$(t);return this.filter((function(n,i){return(!L(t)||I(i))&&!e.call(i,n,i)}))},E.val=function(t){return arguments.length?this.each((function(e,n){var i=n.multiple&&n.options;if(i||Lt.test(n.type)){var o=u(t)?m.call(t,String):R(t)?[]:[String(t)];i?F(n.options,(function(t,e){e.selected=o.indexOf(e.value)>=0}),!0):n.checked=o.indexOf(n.value)>=0}else n.value=P(t)||R(t)?"":t})):this[0]&&tt(this[0])},E.is=function(t){var e=$(t);return v.call(this,(function(t,n){return e.call(t,n,t)}))},_.guid=1,_.unique=et,E.add=function(t,e){return _(et(this.get().concat(_(t,e).get())))},E.children=function(t){return z(_(et(J(this,(function(t){return t.children})))),t)},E.parent=function(t){return z(_(et(J(this,"parentNode"))),t)},E.index=function(t){var e=t?_(t)[0]:this[0],n=t?this:_(e).parent().children();return f.call(n,e)},E.closest=function(t){var e=this.filter(t);if(e.length)return e;var n=this.parent();return n.length?n.closest(t):e},E.siblings=function(t){return z(_(et(J(this,(function(t){return _(t).parent().children().not(t)})))),t)},E.find=function(t){return _(et(J(this,(function(e){return S(t,e)}))))};var nt=/^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,it=/^$|^module$|\/(java|ecma)script/i,ot=["type","src","nonce","noModule"];function rt(t,e,n,r,s,a,l,u){return F(t,(function(t,a){F(_(a),(function(t,a){F(_(e),(function(e,l){var u=n?l:a,c=n?t:e;!function(t,e,n,r,s){r?t.insertBefore(e,n?t.firstChild:null):"HTML"===t.nodeName?t.parentNode.replaceChild(e,t):t.parentNode.insertBefore(e,n?t:t.nextSibling),s&&function(t,e){var n=_(t);n.filter("script").add(n.find("script")).each((function(t,n){if(it.test(n.type)&&i.contains(n)){var r=o("script");r.text=n.textContent.replace(nt,""),F(ot,(function(t,e){n[e]&&(r[e]=n[e])})),e.head.insertBefore(r,null),e.head.removeChild(r)}}))}(e,t.ownerDocument)}(n?a:l,c?u.cloneNode(!0):u,r,s,!c)}),u)}),l)}),a),e}E.after=function(){return rt(arguments,this,!1,!1,!1,!0,!0)},E.append=function(){return rt(arguments,this,!1,!1,!0)},E.html=function(t){if(!arguments.length)return this[0]&&this[0].innerHTML;if(P(t))return this;var e=/<script[\s>]/.test(t);return this.each((function(n,i){I(i)&&(e?_(i).empty().append(t):i.innerHTML=t)}))},E.appendTo=function(t){return rt(arguments,this,!0,!1,!0)},E.wrapInner=function(t){return this.each((function(e,n){var i=_(n),o=i.contents();o.length?o.wrapAll(t):i.append(t)}))},E.before=function(){return rt(arguments,this,!1,!0)},E.wrapAll=function(t){for(var e=_(t),n=e[0];n.children.length;)n=n.firstElementChild;return this.first().before(e),this.appendTo(n)},E.wrap=function(t){return this.each((function(e,n){var i=_(t)[0];_(n).wrapAll(e?i.cloneNode(!0):i)}))},E.insertAfter=function(t){return rt(arguments,this,!0,!1,!1,!1,!1,!0)},E.insertBefore=function(t){return rt(arguments,this,!0,!0)},E.prepend=function(){return rt(arguments,this,!1,!0,!0,!0,!0)},E.prependTo=function(t){return rt(arguments,this,!0,!0,!0,!1,!1,!0)},E.contents=function(){return _(et(J(this,(function(t){return"IFRAME"===t.tagName?[t.contentDocument]:"TEMPLATE"===t.tagName?t.content.childNodes:t.childNodes}))))},E.next=function(t,e,n){return z(_(et(J(this,"nextElementSibling",e,n))),t)},E.nextAll=function(t){return this.next(t,!0)},E.nextUntil=function(t,e){return this.next(e,!0,t)},E.parents=function(t,e){return z(_(et(J(this,"parentElement",!0,e))),t)},E.parentsUntil=function(t,e){return this.parents(e,t)},E.prev=function(t,e,n){return z(_(et(J(this,"previousElementSibling",e,n))),t)},E.prevAll=function(t){return this.prev(t,!0)},E.prevUntil=function(t,e){return this.prev(e,!0,t)},E.map=function(t){return _(h.apply([],m.call(this,(function(e,n){return t.call(e,n,e)}))))},E.clone=function(){return this.map((function(t,e){return e.cloneNode(!0)}))},E.offsetParent=function(){return this.map((function(t,e){for(var n=e.offsetParent;n&&"static"===q(n,"position");)n=n.offsetParent;return n||i}))},E.slice=function(t,e){return _(g.call(this,t,e))};var st=/-([a-z])/g;function at(t){return t.replace(st,(function(t,e){return e.toUpperCase()}))}E.ready=function(t){var n=function(){return setTimeout(t,0,_)};return"loading"!==e.readyState?n():e.addEventListener("DOMContentLoaded",n),this},E.unwrap=function(){return this.parent().each((function(t,e){if("BODY"!==e.tagName){var n=_(e);n.replaceWith(n.children())}})),this},E.offset=function(){var t=this[0];if(t){var e=t.getBoundingClientRect();return{top:e.top+n.pageYOffset,left:e.left+n.pageXOffset}}},E.position=function(){var t=this[0];if(t){var e="fixed"===q(t,"position"),n=e?t.getBoundingClientRect():this.offset();if(!e){for(var i=t.ownerDocument,o=t.offsetParent||i.documentElement;(o===i.body||o===i.documentElement)&&"static"===q(o,"position");)o=o.parentNode;if(o!==t&&I(o)){var r=_(o).offset();n.top-=r.top+B(o,"borderTopWidth"),n.left-=r.left+B(o,"borderLeftWidth")}}return{top:n.top-B(t,"marginTop"),left:n.left-B(t,"marginLeft")}}};var lt={class:"className",contenteditable:"contentEditable",for:"htmlFor",readonly:"readOnly",maxlength:"maxLength",tabindex:"tabIndex",colspan:"colSpan",rowspan:"rowSpan",usemap:"useMap"};E.prop=function(t,e){if(t){if(L(t))return t=lt[t]||t,arguments.length<2?this[0]&&this[0][t]:this.each((function(n,i){i[t]=e}));for(var n in t)this.prop(n,t[n]);return this}},E.removeProp=function(t){return this.each((function(e,n){delete n[lt[t]||t]}))};var ut=/^--/;function ct(t){return ut.test(t)}var ht={},dt=r.style,ft=["webkit","moz","ms"],mt={animationIterationCount:!0,columnCount:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,gridArea:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnStart:!0,gridRow:!0,gridRowEnd:!0,gridRowStart:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0};function pt(t,e,n){return void 0===n&&(n=ct(t)),n||mt[t]||!k(e)?e:"".concat(e,"px")}function gt(t,e){try{return t(e)}catch(t){return e}}E.css=function(t,e){if(L(t)){var n=ct(t);return t=function(t,e){if(void 0===e&&(e=ct(t)),e)return t;if(!ht[t]){var n=at(t),i="".concat(n[0].toUpperCase()).concat(n.slice(1));F("".concat(n," ").concat(ft.join("".concat(i," "))).concat(i).split(" "),(function(e,n){if(n in dt)return ht[t]=n,!1}))}return ht[t]}(t,n),arguments.length<2?this[0]&&q(this[0],t,n):t?(e=pt(t,e,n),this.each((function(i,o){I(o)&&(n?o.style.setProperty(t,e):o.style[t]=e)}))):this}for(var i in t)this.css(i,t[i]);return this};var vt=/^\s+|\s+$/;function Ct(t,e){var n=t.dataset[e]||t.dataset[at(e)];return vt.test(n)?n:gt(JSON.parse,n)}function yt(t,e){var n=t.documentElement;return Math.max(t.body["scroll".concat(e)],n["scroll".concat(e)],t.body["offset".concat(e)],n["offset".concat(e)],n["client".concat(e)])}E.data=function(t,e){if(!t){if(!this[0])return;var n={};for(var i in this[0].dataset)n[i]=Ct(this[0],i);return n}if(L(t))return arguments.length<2?this[0]&&Ct(this[0],t):P(e)?this:this.each((function(n,i){!function(t,e,n){n=gt(JSON.stringify,n),t.dataset[at(e)]=n}(i,t,e)}));for(var i in t)this.data(i,t[i]);return this},F([!0,!1],(function(t,e){F(["Width","Height"],(function(t,n){var i="".concat(e?"outer":"inner").concat(n);E[i]=function(i){if(this[0])return x(this[0])?e?this[0]["inner".concat(n)]:this[0].document.documentElement["client".concat(n)]:M(this[0])?yt(this[0],n):this[0]["".concat(e?"offset":"client").concat(n)]+(i&&e?B(this[0],"margin".concat(t?"Top":"Left"))+B(this[0],"margin".concat(t?"Bottom":"Right")):0)}}))})),F(["Width","Height"],(function(t,e){var n=e.toLowerCase();E[n]=function(i){if(!this[0])return P(i)?void 0:this;if(!arguments.length)return x(this[0])?this[0].document.documentElement["client".concat(e)]:M(this[0])?yt(this[0],e):this[0].getBoundingClientRect()[n]-H(this[0],!t);var o=parseInt(i,10);return this.each((function(e,i){if(I(i)){var r=q(i,"boxSizing");i.style[n]=pt(n,o+("border-box"===r?H(i,!t):0))}}))}}));var wt="___cd";E.toggle=function(t){return this.each((function(n,i){if(I(i)){var r=j(i);(P(t)?r:t)?(i.style.display=i[wt]||"",j(i)&&(i.style.display=function(t){if(Y[t])return Y[t];var n=o(t);e.body.insertBefore(n,null);var i=q(n,"display");return e.body.removeChild(n),Y[t]="none"!==i?i:"block"}(i.tagName))):r||(i[wt]=q(i,"display"),i.style.display="none")}}))},E.hide=function(){return this.toggle(!1)},E.show=function(){return this.toggle(!0)};var At="___ce",bt={focus:"focusin",blur:"focusout"},St={mouseenter:"mouseover",mouseleave:"mouseout"},Tt=/^(mouse|pointer|contextmenu|drag|drop|click|dblclick)/i;function Et(t){return St[t]||bt[t]||t}function _t(t){var e=t.split(".");return[e[0],e.slice(1).sort()]}function Nt(t){return t[At]=t[At]||{}}function xt(t,e){return!e||!v.call(e,(function(e){return t.indexOf(e)<0}))}function Mt(t,e,n,i,o){var r=Nt(t);if(e)r[e]&&(r[e]=r[e].filter((function(r){var s=r[0],a=r[1],l=r[2];if(o&&l.guid!==o.guid||!xt(s,n)||i&&i!==a)return!0;t.removeEventListener(e,l)})));else for(e in r)Mt(t,e,n,i,o)}E.trigger=function(t,n){if(L(t)){var i=_t(t),o=i[0],r=i[1],s=Et(o);if(!s)return this;var a=Tt.test(s)?"MouseEvents":"HTMLEvents";(t=e.createEvent(a)).initEvent(s,!0,!0),t.namespace=r.join("."),t.___ot=o}t.___td=n;var l=t.___ot in bt;return this.each((function(e,n){l&&O(n[t.___ot])&&(n["___i".concat(t.type)]=!0,n[t.___ot](),n["___i".concat(t.type)]=!1),n.dispatchEvent(t)}))},E.off=function(t,e,n){var i=this;if(P(t))this.each((function(t,e){(I(e)||M(e)||x(e))&&Mt(e)}));else if(L(t))O(e)&&(n=e,e=""),F(U(t),(function(t,o){var r=_t(o),s=r[0],a=r[1],l=Et(s);i.each((function(t,i){(I(i)||M(i)||x(i))&&Mt(i,l,a,e,n)}))}));else for(var o in t)this.off(o,t[o]);return this},E.remove=function(t){return z(this,t).detach().off(),this},E.replaceWith=function(t){return this.before(t).remove()},E.replaceAll=function(t){return _(t).replaceWith(this),this},E.on=function(t,e,n,i,o){var r=this;if(!L(t)){for(var s in t)this.on(s,e,n,t[s],o);return this}return L(e)||(P(e)||R(e)?e="":P(n)?(n=e,e=""):(i=n,n=e,e="")),O(i)||(i=n,n=void 0),i?(F(U(t),(function(t,s){var a=_t(s),l=a[0],u=a[1],c=Et(l),h=l in St,d=l in bt;c&&r.each((function(t,r){if(I(r)||M(r)||x(r)){var s=function(t){if(t.target["___i".concat(t.type)])return t.stopImmediatePropagation();if((!t.namespace||xt(u,t.namespace.split(".")))&&(e||!(d&&(t.target!==r||t.___ot===c)||h&&t.relatedTarget&&r.contains(t.relatedTarget)))){var a=r;if(e){for(var l=t.target;!W(l,e);){if(l===r)return;if(!(l=l.parentNode))return}a=l}Object.defineProperty(t,"currentTarget",{configurable:!0,get:function(){return a}}),Object.defineProperty(t,"delegateTarget",{configurable:!0,get:function(){return r}}),Object.defineProperty(t,"data",{configurable:!0,get:function(){return n}});var f=i.call(a,t,t.___td);o&&Mt(r,c,u,e,s),!1===f&&(t.preventDefault(),t.stopPropagation())}};s.guid=i.guid=i.guid||_.guid++,function(t,e,n,i,o){var r=Nt(t);r[e]=r[e]||[],r[e].push([n,i,o]),t.addEventListener(e,o)}(r,c,u,e,s)}}))})),this):this},E.one=function(t,e,n,i){return this.on(t,e,n,i,!0)};var It=/\r?\n/g,Ot=/file|reset|submit|button|image/i,Lt=/radio|checkbox/i;E.serialize=function(){var t="";return this.each((function(e,n){F(n.elements||[n],(function(e,n){if(!(n.disabled||!n.name||"FIELDSET"===n.tagName||Ot.test(n.type)||Lt.test(n.type)&&!n.checked)){var i=tt(n);P(i)||F(u(i)?i:[i],(function(e,i){t+=function(t,e){return"&".concat(encodeURIComponent(t),"=").concat(encodeURIComponent(e.replace(It,"\r\n")))}(n.name,i)}))}}))})),t.slice(1)},t.exports=_}()},6677:(t,e,n)=>{"use strict";n.d(e,{A:()=>a});var i=n(1354),o=n.n(i),r=n(6314),s=n.n(r)()(o());s.push([t.id,".ui-app-header {\n\n}\n\n.ui-app-header-icon {\n width: 150px;\n height: 150px;\n margin-right: 20px;\n}\n\n.u2-panel {\n gap: 10px;\n}\n\n.u2-app-header-bottom-line {\n border-bottom: solid 1px lightgrey;\n}\n\n.u2-app-header-with-name {\n gap: 60px;\n}\n\n.u2-app-header-with-name .ui-app-header-icon{\n width: 90px;\n height: 90px;\n}\n\n.u2-app-header-app-name-and-slogan-div {\n gap: 10px;\n margin-top: 10px;\n}\n\n.u2-app-header-app-name-div {\n font-size: 20px;\n font-weight: bold;\n}\n\n.u2-app-header-description {\n margin-top: 10px;\n margin-bottom: 10px;\n}","",{version:3,sources:["webpack://./node_modules/@datagrok-libraries/utils/src/u2.css"],names:[],mappings:"AAAA;;AAEA;;AAEA;IACI,YAAY;IACZ,aAAa;IACb,kBAAkB;AACtB;;AAEA;IACI,SAAS;AACb;;AAEA;IACI,kCAAkC;AACtC;;AAEA;IACI,SAAS;AACb;;AAEA;IACI,WAAW;IACX,YAAY;AAChB;;AAEA;IACI,SAAS;IACT,gBAAgB;AACpB;;AAEA;IACI,eAAe;IACf,iBAAiB;AACrB;;AAEA;IACI,gBAAgB;IAChB,mBAAmB;AACvB",sourcesContent:[".ui-app-header {\n\n}\n\n.ui-app-header-icon {\n width: 150px;\n height: 150px;\n margin-right: 20px;\n}\n\n.u2-panel {\n gap: 10px;\n}\n\n.u2-app-header-bottom-line {\n border-bottom: solid 1px lightgrey;\n}\n\n.u2-app-header-with-name {\n gap: 60px;\n}\n\n.u2-app-header-with-name .ui-app-header-icon{\n width: 90px;\n height: 90px;\n}\n\n.u2-app-header-app-name-and-slogan-div {\n gap: 10px;\n margin-top: 10px;\n}\n\n.u2-app-header-app-name-div {\n font-size: 20px;\n font-weight: bold;\n}\n\n.u2-app-header-description {\n margin-top: 10px;\n margin-bottom: 10px;\n}"],sourceRoot:""}]);const a=s},365:(t,e,n)=>{"use strict";n.d(e,{A:()=>a});var i=n(1354),o=n.n(i),r=n(6314),s=n.n(r)()(o());s.push([t.id,".pep-textarea-box {\n position: relative;\n}\n\n.pep-textarea-box:hover .pep-snippet-editor-icon {\n visibility: visible;\n}\n\n.pep-snippet-editor-icon {\n position: absolute;\n top: 5px;\n visibility: hidden;\n margin: 5px;\n z-index: 1;\n}\n\n.pep-reset-icon {\n right: 10px;\n}\n\n.pep-snippet-editor-icon i {\n font-size: 13px;\n}\n\n.pep-snippet-editor-icon:hover {\n background-color: var(--steel-1);\n border-radius: 2px;\n}\n\n.pep-snippet-inline-icon i {\n font-size: 13px;\n}\n\n.pep-textinput {\n height: 50px;\n overflow: hidden;\n}\n\n#pep-hist-host #center {\n height: 131px;\n}\n\n#pep-hist-host > #root {\n height: unset;\n width: 100%;\n}\n\n#pep-viewer-title {\n height: 23px;\n font-size: 1.2rem;\n font-family: 'Roboto', 'Roboto Local', sans-serif;\n color: #4D5261;\n text-align: center;\n width: 100%;\n align-self: end;\n}\n\n.pep-help-icon {\n position: absolute;\n left: 5px;\n top: 1px;\n}\n\n.panel-base:has(.peptides-viewer-show-title:only-child) > .panel-titlebar > .panel-titlebar-text {\n visibility: visible;\n display: block;\n text-align: center;\n margin-left: 36px;\n padding: 0;\n width: 100%;\n font-size: 14px !important;\n color: #4d5261 !important;\n}","",{version:3,sources:["webpack://./src/styles.css"],names:[],mappings:"AAAA;EACE,kBAAkB;AACpB;;AAEA;EACE,mBAAmB;AACrB;;AAEA;EACE,kBAAkB;EAClB,QAAQ;EACR,kBAAkB;EAClB,WAAW;EACX,UAAU;AACZ;;AAEA;EACE,WAAW;AACb;;AAEA;EACE,eAAe;AACjB;;AAEA;EACE,gCAAgC;EAChC,kBAAkB;AACpB;;AAEA;EACE,eAAe;AACjB;;AAEA;EACE,YAAY;EACZ,gBAAgB;AAClB;;AAEA;EACE,aAAa;AACf;;AAEA;EACE,aAAa;EACb,WAAW;AACb;;AAEA;EACE,YAAY;EACZ,iBAAiB;EACjB,iDAAiD;EACjD,cAAc;EACd,kBAAkB;EAClB,WAAW;EACX,eAAe;AACjB;;AAEA;EACE,kBAAkB;EAClB,SAAS;EACT,QAAQ;AACV;;AAEA;IACI,mBAAmB;IACnB,cAAc;IACd,kBAAkB;IAClB,iBAAiB;IACjB,UAAU;IACV,WAAW;IACX,0BAA0B;IAC1B,yBAAyB;AAC7B",sourcesContent:[".pep-textarea-box {\n position: relative;\n}\n\n.pep-textarea-box:hover .pep-snippet-editor-icon {\n visibility: visible;\n}\n\n.pep-snippet-editor-icon {\n position: absolute;\n top: 5px;\n visibility: hidden;\n margin: 5px;\n z-index: 1;\n}\n\n.pep-reset-icon {\n right: 10px;\n}\n\n.pep-snippet-editor-icon i {\n font-size: 13px;\n}\n\n.pep-snippet-editor-icon:hover {\n background-color: var(--steel-1);\n border-radius: 2px;\n}\n\n.pep-snippet-inline-icon i {\n font-size: 13px;\n}\n\n.pep-textinput {\n height: 50px;\n overflow: hidden;\n}\n\n#pep-hist-host #center {\n height: 131px;\n}\n\n#pep-hist-host > #root {\n height: unset;\n width: 100%;\n}\n\n#pep-viewer-title {\n height: 23px;\n font-size: 1.2rem;\n font-family: 'Roboto', 'Roboto Local', sans-serif;\n color: #4D5261;\n text-align: center;\n width: 100%;\n align-self: end;\n}\n\n.pep-help-icon {\n position: absolute;\n left: 5px;\n top: 1px;\n}\n\n.panel-base:has(.peptides-viewer-show-title:only-child) > .panel-titlebar > .panel-titlebar-text {\n visibility: visible;\n display: block;\n text-align: center;\n margin-left: 36px;\n padding: 0;\n width: 100%;\n font-size: 14px !important;\n color: #4d5261 !important;\n}"],sourceRoot:""}]);const a=s},6314: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,r){"string"==typeof t&&(t=[[null,t,void 0]]);var s={};if(i)for(var a=0;a<this.length;a++){var l=this[a][0];null!=l&&(s[l]=!0)}for(var u=0;u<t.length;u++){var c=[].concat(t[u]);i&&s[c[0]]||(void 0!==r&&(void 0===c[5]||(c[1]="@layer".concat(c[5].length>0?" ".concat(c[5]):""," {").concat(c[1],"}")),c[5]=r),n&&(c[2]?(c[1]="@media ".concat(c[2]," {").concat(c[1],"}"),c[2]=n):c[2]=n),o&&(c[4]?(c[1]="@supports (".concat(c[4],") {").concat(c[1],"}"),c[4]=o):c[4]="".concat(o)),e.push(c))}},e}},1354: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),r="/*# ".concat(o," */");return[e].concat([r]).join("\n")}return[e].join("\n")}},6572:function(t){var e;t.exports=(e=function(t,e){var n=Array.prototype.concat,i=Array.prototype.slice,o=Object.prototype.toString;function r(e,n){var i=e>n?e:n;return t.pow(10,17-~~(t.log(i>0?i:-i)*t.LOG10E))}var s=Array.isArray||function(t){return"[object Array]"===o.call(t)};function a(t){return"[object Function]"===o.call(t)}function l(t){return"number"==typeof t&&t-t==0}function u(){return new u._init(arguments)}function c(){return 0}function h(){return 1}function d(t,e){return t===e?1:0}u.fn=u.prototype,u._init=function(t){if(s(t[0]))if(s(t[0][0])){a(t[1])&&(t[0]=u.map(t[0],t[1]));for(var e=0;e<t[0].length;e++)this[e]=t[0][e];this.length=t[0].length}else this[0]=a(t[1])?u.map(t[0],t[1]):t[0],this.length=1;else if(l(t[0]))this[0]=u.seq.apply(null,t),this.length=1;else{if(t[0]instanceof u)return u(t[0].toArray());this[0]=[],this.length=1}return this},u._init.prototype=u.prototype,u._init.constructor=u,u.utils={calcRdx:r,isArray:s,isFunction:a,isNumber:l,toVector:function(t){return n.apply([],t)}},u._random_fn=t.random,u.setRandom=function(t){if("function"!=typeof t)throw new TypeError("fn is not a function");u._random_fn=t},u.extend=function(t){var e,n;if(1===arguments.length){for(n in t)u[n]=t[n];return this}for(e=1;e<arguments.length;e++)for(n in arguments[e])t[n]=arguments[e][n];return t},u.rows=function(t){return t.length||1},u.cols=function(t){return t[0].length||1},u.dimensions=function(t){return{rows:u.rows(t),cols:u.cols(t)}},u.row=function(t,e){return s(e)?e.map((function(e){return u.row(t,e)})):t[e]},u.rowa=function(t,e){return u.row(t,e)},u.col=function(t,e){if(s(e)){var n=u.arange(t.length).map((function(){return new Array(e.length)}));return e.forEach((function(e,i){u.arange(t.length).forEach((function(o){n[o][i]=t[o][e]}))})),n}for(var i=new Array(t.length),o=0;o<t.length;o++)i[o]=[t[o][e]];return i},u.cola=function(t,e){return u.col(t,e).map((function(t){return t[0]}))},u.diag=function(t){for(var e=u.rows(t),n=new Array(e),i=0;i<e;i++)n[i]=[t[i][i]];return n},u.antidiag=function(t){for(var e=u.rows(t)-1,n=new Array(e),i=0;e>=0;e--,i++)n[i]=[t[i][e]];return n},u.transpose=function(t){var e,n,i,o,r,a=[];for(s(t[0])||(t=[t]),n=t.length,i=t[0].length,r=0;r<i;r++){for(e=new Array(n),o=0;o<n;o++)e[o]=t[o][r];a.push(e)}return 1===a.length?a[0]:a},u.map=function(t,e,n){var i,o,r,a,l;for(s(t[0])||(t=[t]),o=t.length,r=t[0].length,a=n?t:new Array(o),i=0;i<o;i++)for(a[i]||(a[i]=new Array(r)),l=0;l<r;l++)a[i][l]=e(t[i][l],i,l);return 1===a.length?a[0]:a},u.cumreduce=function(t,e,n){var i,o,r,a,l;for(s(t[0])||(t=[t]),o=t.length,r=t[0].length,a=n?t:new Array(o),i=0;i<o;i++)for(a[i]||(a[i]=new Array(r)),r>0&&(a[i][0]=t[i][0]),l=1;l<r;l++)a[i][l]=e(a[i][l-1],t[i][l]);return 1===a.length?a[0]:a},u.alter=function(t,e){return u.map(t,e,!0)},u.create=function(t,e,n){var i,o,r=new Array(t);for(a(e)&&(n=e,e=t),i=0;i<t;i++)for(r[i]=new Array(e),o=0;o<e;o++)r[i][o]=n(i,o);return r},u.zeros=function(t,e){return l(e)||(e=t),u.create(t,e,c)},u.ones=function(t,e){return l(e)||(e=t),u.create(t,e,h)},u.rand=function(t,e){return l(e)||(e=t),u.create(t,e,u._random_fn)},u.identity=function(t,e){return l(e)||(e=t),u.create(t,e,d)},u.symmetric=function(t){var e,n,i=t.length;if(t.length!==t[0].length)return!1;for(e=0;e<i;e++)for(n=0;n<i;n++)if(t[n][e]!==t[e][n])return!1;return!0},u.clear=function(t){return u.alter(t,c)},u.seq=function(t,e,n,i){a(i)||(i=!1);var o,s=[],l=r(t,e),u=(e*l-t*l)/((n-1)*l),c=t;for(o=0;c<=e&&o<n;c=(t*l+u*l*++o)/l)s.push(i?i(c,o):c);return s},u.arange=function(t,n,i){var o,r=[];if(i=i||1,n===e&&(n=t,t=0),t===n||0===i)return[];if(t<n&&i<0)return[];if(t>n&&i>0)return[];if(i>0)for(o=t;o<n;o+=i)r.push(o);else for(o=t;o>n;o+=i)r.push(o);return r},u.slice=function(){function t(t,n,i,o){var r,s=[],a=t.length;if(n===e&&i===e&&o===e)return u.copy(t);if(o=o||1,(n=(n=n||0)>=0?n:a+n)===(i=(i=i||t.length)>=0?i:a+i)||0===o)return[];if(n<i&&o<0)return[];if(n>i&&o>0)return[];if(o>0)for(r=n;r<i;r+=o)s.push(t[r]);else for(r=n;r>i;r+=o)s.push(t[r]);return s}return function(e,n){var i,o;return l((n=n||{}).row)?l(n.col)?e[n.row][n.col]:t(u.rowa(e,n.row),(i=n.col||{}).start,i.end,i.step):l(n.col)?t(u.cola(e,n.col),(o=n.row||{}).start,o.end,o.step):(o=n.row||{},i=n.col||{},t(e,o.start,o.end,o.step).map((function(e){return t(e,i.start,i.end,i.step)})))}}(),u.sliceAssign=function(n,i,o){var r,s;if(l(i.row)){if(l(i.col))return n[i.row][i.col]=o;i.col=i.col||{},i.col.start=i.col.start||0,i.col.end=i.col.end||n[0].length,i.col.step=i.col.step||1,r=u.arange(i.col.start,t.min(n.length,i.col.end),i.col.step);var a=i.row;return r.forEach((function(t,e){n[a][t]=o[e]})),n}if(l(i.col)){i.row=i.row||{},i.row.start=i.row.start||0,i.row.end=i.row.end||n.length,i.row.step=i.row.step||1,s=u.arange(i.row.start,t.min(n[0].length,i.row.end),i.row.step);var c=i.col;return s.forEach((function(t,e){n[t][c]=o[e]})),n}return o[0].length===e&&(o=[o]),i.row.start=i.row.start||0,i.row.end=i.row.end||n.length,i.row.step=i.row.step||1,i.col.start=i.col.start||0,i.col.end=i.col.end||n[0].length,i.col.step=i.col.step||1,s=u.arange(i.row.start,t.min(n.length,i.row.end),i.row.step),r=u.arange(i.col.start,t.min(n[0].length,i.col.end),i.col.step),s.forEach((function(t,e){r.forEach((function(i,r){n[t][i]=o[e][r]}))})),n},u.diagonal=function(t){var e=u.zeros(t.length,t.length);return t.forEach((function(t,n){e[n][n]=t})),e},u.copy=function(t){return t.map((function(t){return l(t)?t:t.map((function(t){return t}))}))};var f=u.prototype;return f.length=0,f.push=Array.prototype.push,f.sort=Array.prototype.sort,f.splice=Array.prototype.splice,f.slice=Array.prototype.slice,f.toArray=function(){return this.length>1?i.call(this):i.call(this)[0]},f.map=function(t,e){return u(u.map(this,t,e))},f.cumreduce=function(t,e){return u(u.cumreduce(this,t,e))},f.alter=function(t){return u.alter(this,t),this},function(t){for(var e=0;e<t.length;e++)!function(t){f[t]=function(e){var n,i=this;return e?(setTimeout((function(){e.call(i,f[t].call(i))})),this):(n=u[t](this),s(n)?u(n):n)}}(t[e])}("transpose clear symmetric rows cols dimensions diag antidiag".split(" ")),function(t){for(var e=0;e<t.length;e++)!function(t){f[t]=function(e,n){var i=this;return n?(setTimeout((function(){n.call(i,f[t].call(i,e))})),this):u(u[t](this,e))}}(t[e])}("row col".split(" ")),function(t){for(var e=0;e<t.length;e++)!function(t){f[t]=function(){return u(u[t].apply(null,arguments))}}(t[e])}("create zeros ones rand identity".split(" ")),u}(Math),function(t,e){var n=t.utils.isFunction;function i(t,e){return t-e}function o(t,n,i){return e.max(n,e.min(t,i))}t.sum=function(t){for(var e=0,n=t.length;--n>=0;)e+=t[n];return e},t.sumsqrd=function(t){for(var e=0,n=t.length;--n>=0;)e+=t[n]*t[n];return e},t.sumsqerr=function(e){for(var n,i=t.mean(e),o=0,r=e.length;--r>=0;)o+=(n=e[r]-i)*n;return o},t.sumrow=function(t){for(var e=0,n=t.length;--n>=0;)e+=t[n];return e},t.product=function(t){for(var e=1,n=t.length;--n>=0;)e*=t[n];return e},t.min=function(t){for(var e=t[0],n=0;++n<t.length;)t[n]<e&&(e=t[n]);return e},t.max=function(t){for(var e=t[0],n=0;++n<t.length;)t[n]>e&&(e=t[n]);return e},t.unique=function(t){for(var e={},n=[],i=0;i<t.length;i++)e[t[i]]||(e[t[i]]=!0,n.push(t[i]));return n},t.mean=function(e){return t.sum(e)/e.length},t.meansqerr=function(e){return t.sumsqerr(e)/e.length},t.geomean=function(n){var i=n.map(e.log),o=t.mean(i);return e.exp(o)},t.median=function(t){var e=t.length,n=t.slice().sort(i);return 1&e?n[e/2|0]:(n[e/2-1]+n[e/2])/2},t.cumsum=function(e){return t.cumreduce(e,(function(t,e){return t+e}))},t.cumprod=function(e){return t.cumreduce(e,(function(t,e){return t*e}))},t.diff=function(t){var e,n=[],i=t.length;for(e=1;e<i;e++)n.push(t[e]-t[e-1]);return n},t.rank=function(t){var e,n=[],o={};for(e=0;e<t.length;e++)o[l=t[e]]?o[l]++:(o[l]=1,n.push(l));var r=n.sort(i),s={},a=1;for(e=0;e<r.length;e++){var l,u=o[l=r[e]],c=(a+(a+u-1))/2;s[l]=c,a+=u}return t.map((function(t){return s[t]}))},t.mode=function(t){var e,n=t.length,o=t.slice().sort(i),r=1,s=0,a=0,l=[];for(e=0;e<n;e++)o[e]===o[e+1]?r++:(r>s?(l=[o[e]],s=r,a=0):r===s&&(l.push(o[e]),a++),r=1);return 0===a?l[0]:l},t.range=function(e){return t.max(e)-t.min(e)},t.variance=function(e,n){return t.sumsqerr(e)/(e.length-(n?1:0))},t.pooledvariance=function(e){return e.reduce((function(e,n){return e+t.sumsqerr(n)}),0)/(e.reduce((function(t,e){return t+e.length}),0)-e.length)},t.deviation=function(e){for(var n=t.mean(e),i=e.length,o=new Array(i),r=0;r<i;r++)o[r]=e[r]-n;return o},t.stdev=function(n,i){return e.sqrt(t.variance(n,i))},t.pooledstdev=function(n){return e.sqrt(t.pooledvariance(n))},t.meandev=function(n){for(var i=t.mean(n),o=[],r=n.length-1;r>=0;r--)o.push(e.abs(n[r]-i));return t.mean(o)},t.meddev=function(n){for(var i=t.median(n),o=[],r=n.length-1;r>=0;r--)o.push(e.abs(n[r]-i));return t.median(o)},t.coeffvar=function(e){return t.stdev(e)/t.mean(e)},t.quartiles=function(t){var n=t.length,o=t.slice().sort(i);return[o[e.round(n/4)-1],o[e.round(n/2)-1],o[e.round(3*n/4)-1]]},t.quantiles=function(t,n,r,s){var a,l,u,c,h,d=t.slice().sort(i),f=[n.length],m=t.length;for(void 0===r&&(r=3/8),void 0===s&&(s=3/8),a=0;a<n.length;a++)u=m*(l=n[a])+(r+l*(1-r-s)),c=e.floor(o(u,1,m-1)),h=o(u-c,0,1),f[a]=(1-h)*d[c-1]+h*d[c];return f},t.percentile=function(t,e,n){var o=t.slice().sort(i),r=e*(o.length+(n?1:-1))+(n?0:1),s=parseInt(r),a=r-s;return s+1<o.length?o[s-1]+a*(o[s]-o[s-1]):o[s-1]},t.percentileOfScore=function(t,e,n){var i,o,r=0,s=t.length,a=!1;for("strict"===n&&(a=!0),o=0;o<s;o++)i=t[o],(a&&i<e||!a&&i<=e)&&r++;return r/s},t.histogram=function(n,i){i=i||4;var o,r=t.min(n),s=(t.max(n)-r)/i,a=n.length,l=[];for(o=0;o<i;o++)l[o]=0;for(o=0;o<a;o++)l[e.min(e.floor((n[o]-r)/s),i-1)]+=1;return l},t.covariance=function(e,n){var i,o=t.mean(e),r=t.mean(n),s=e.length,a=new Array(s);for(i=0;i<s;i++)a[i]=(e[i]-o)*(n[i]-r);return t.sum(a)/(s-1)},t.corrcoeff=function(e,n){return t.covariance(e,n)/t.stdev(e,1)/t.stdev(n,1)},t.spearmancoeff=function(e,n){return e=t.rank(e),n=t.rank(n),t.corrcoeff(e,n)},t.stanMoment=function(n,i){for(var o=t.mean(n),r=t.stdev(n),s=n.length,a=0,l=0;l<s;l++)a+=e.pow((n[l]-o)/r,i);return a/n.length},t.skewness=function(e){return t.stanMoment(e,3)},t.kurtosis=function(e){return t.stanMoment(e,4)-3};var r=t.prototype;!function(e){for(var i=0;i<e.length;i++)!function(e){r[e]=function(i,o){var s=[],a=0,l=this;if(n(i)&&(o=i,i=!1),o)return setTimeout((function(){o.call(l,r[e].call(l,i))})),this;if(this.length>1){for(l=!0===i?this:this.transpose();a<l.length;a++)s[a]=t[e](l[a]);return s}return t[e](this[0],i)}}(e[i])}("cumsum cumprod".split(" ")),function(e){for(var i=0;i<e.length;i++)!function(e){r[e]=function(i,o){var s=[],a=0,l=this;if(n(i)&&(o=i,i=!1),o)return setTimeout((function(){o.call(l,r[e].call(l,i))})),this;if(this.length>1){for("sumrow"!==e&&(l=!0===i?this:this.transpose());a<l.length;a++)s[a]=t[e](l[a]);return!0===i?t[e](t.utils.toVector(s)):s}return t[e](this[0],i)}}(e[i])}("sum sumsqrd sumsqerr sumrow product min max unique mean meansqerr geomean median diff rank mode range variance deviation stdev meandev meddev coeffvar quartiles histogram skewness kurtosis".split(" ")),function(e){for(var i=0;i<e.length;i++)!function(e){r[e]=function(){var i,o=[],s=0,a=this,l=Array.prototype.slice.call(arguments);if(n(l[l.length-1])){i=l[l.length-1];var u=l.slice(0,l.length-1);return setTimeout((function(){i.call(a,r[e].apply(a,u))})),this}i=void 0;var c=function(n){return t[e].apply(a,[n].concat(l))};if(this.length>1){for(a=a.transpose();s<a.length;s++)o[s]=c(a[s]);return o}return c(this[0])}}(e[i])}("quantiles percentileOfScore".split(" "))}(e,Math),function(t,e){t.gammaln=function(t){var n,i,o,r=0,s=[76.18009172947146,-86.50532032941678,24.01409824083091,-1.231739572450155,.001208650973866179,-5395239384953e-18],a=1.000000000190015;for(o=(i=n=t)+5.5,o-=(n+.5)*e.log(o);r<6;r++)a+=s[r]/++i;return e.log(2.5066282746310007*a/n)-o},t.loggam=function(t){var n,i,o,r,s,a,l,u=[.08333333333333333,-.002777777777777778,.0007936507936507937,-.0005952380952380952,.0008417508417508418,-.001917526917526918,.00641025641025641,-.02955065359477124,.1796443723688307,-1.3924322169059];if(n=t,l=0,1==t||2==t)return 0;for(t<=7&&(n=t+(l=e.floor(7-t))),i=1/(n*n),o=2*e.PI,s=u[9],a=8;a>=0;a--)s*=i,s+=u[a];if(r=s/n+.5*e.log(o)+(n-.5)*e.log(n)-n,t<=7)for(a=1;a<=l;a++)r-=e.log(n-1),n-=1;return r},t.gammafn=function(t){var n,i,o,r,s=[-1.716185138865495,24.76565080557592,-379.80425647094563,629.3311553128184,866.9662027904133,-31451.272968848367,-36144.413418691176,66456.14382024054],a=[-30.8402300119739,315.35062697960416,-1015.1563674902192,-3107.771671572311,22538.11842098015,4755.846277527881,-134659.9598649693,-115132.2596755535],l=!1,u=0,c=0,h=0,d=t;if(t>171.6243769536076)return 1/0;if(d<=0){if(!(r=d%1+36e-17))return 1/0;l=(1&d?-1:1)*e.PI/e.sin(e.PI*r),d=1-d}for(o=d,i=d<1?d++:(d-=u=(0|d)-1)-1,n=0;n<8;++n)h=(h+s[n])*i,c=c*i+a[n];if(r=h/c+1,o<d)r/=o;else if(o>d)for(n=0;n<u;++n)r*=d,d++;return l&&(r=l/r),r},t.gammap=function(e,n){return t.lowRegGamma(e,n)*t.gammafn(e)},t.lowRegGamma=function(n,i){var o,r=t.gammaln(n),s=n,a=1/n,l=a,u=i+1-n,c=1/1e-30,h=1/u,d=h,f=1,m=-~(8.5*e.log(n>=1?n:1/n)+.4*n+17);if(i<0||n<=0)return NaN;if(i<n+1){for(;f<=m;f++)a+=l*=i/++s;return a*e.exp(-i+n*e.log(i)-r)}for(;f<=m;f++)d*=(h=1/(h=(o=-f*(f-n))*h+(u+=2)))*(c=u+o/c);return 1-d*e.exp(-i+n*e.log(i)-r)},t.factorialln=function(e){return e<0?NaN:t.gammaln(e+1)},t.factorial=function(e){return e<0?NaN:t.gammafn(e+1)},t.combination=function(n,i){return n>170||i>170?e.exp(t.combinationln(n,i)):t.factorial(n)/t.factorial(i)/t.factorial(n-i)},t.combinationln=function(e,n){return t.factorialln(e)-t.factorialln(n)-t.factorialln(e-n)},t.permutation=function(e,n){return t.factorial(e)/t.factorial(e-n)},t.betafn=function(n,i){if(!(n<=0||i<=0))return n+i>170?e.exp(t.betaln(n,i)):t.gammafn(n)*t.gammafn(i)/t.gammafn(n+i)},t.betaln=function(e,n){return t.gammaln(e)+t.gammaln(n)-t.gammaln(e+n)},t.betacf=function(t,n,i){var o,r,s,a,l=1e-30,u=1,c=n+i,h=n+1,d=n-1,f=1,m=1-c*t/h;for(e.abs(m)<l&&(m=l),a=m=1/m;u<=100&&(m=1+(r=u*(i-u)*t/((d+(o=2*u))*(n+o)))*m,e.abs(m)<l&&(m=l),f=1+r/f,e.abs(f)<l&&(f=l),a*=(m=1/m)*f,m=1+(r=-(n+u)*(c+u)*t/((n+o)*(h+o)))*m,e.abs(m)<l&&(m=l),f=1+r/f,e.abs(f)<l&&(f=l),a*=s=(m=1/m)*f,!(e.abs(s-1)<3e-7));u++);return a},t.gammapinv=function(n,i){var o,r,s,a,l,u,c=0,h=i-1,d=t.gammaln(i);if(n>=1)return e.max(100,i+100*e.sqrt(i));if(n<=0)return 0;for(i>1?(l=e.log(h),u=e.exp(h*(l-1)-d),a=n<.5?n:1-n,o=(2.30753+.27061*(r=e.sqrt(-2*e.log(a))))/(1+r*(.99229+.04481*r))-r,n<.5&&(o=-o),o=e.max(.001,i*e.pow(1-1/(9*i)-o/(3*e.sqrt(i)),3))):o=n<(r=1-i*(.253+.12*i))?e.pow(n/r,1/i):1-e.log(1-(n-r)/(1-r));c<12;c++){if(o<=0)return 0;if((o-=r=(s=(t.lowRegGamma(i,o)-n)/(r=i>1?u*e.exp(-(o-h)+h*(e.log(o)-l)):e.exp(-o+h*e.log(o)-d)))/(1-.5*e.min(1,s*((i-1)/o-1))))<=0&&(o=.5*(o+r)),e.abs(r)<1e-8*o)break}return o},t.erf=function(t){var n,i,o,r,s=[-1.3026537197817094,.6419697923564902,.019476473204185836,-.00956151478680863,-.000946595344482036,.000366839497852761,42523324806907e-18,-20278578112534e-18,-1624290004647e-18,130365583558e-17,1.5626441722e-8,-8.5238095915e-8,6.529054439e-9,5.059343495e-9,-9.91364156e-10,-2.27365122e-10,96467911e-18,2394038e-18,-6886027e-18,894487e-18,313092e-18,-112708e-18,381e-18,7106e-18,-1523e-18,-94e-18,121e-18,-28e-18],a=s.length-1,l=!1,u=0,c=0;for(t<0&&(t=-t,l=!0),i=4*(n=2/(2+t))-2;a>0;a--)o=u,u=i*u-c+s[a],c=o;return r=n*e.exp(-t*t+.5*(s[0]+i*u)-c),l?r-1:1-r},t.erfc=function(e){return 1-t.erf(e)},t.erfcinv=function(n){var i,o,r,s,a=0;if(n>=2)return-100;if(n<=0)return 100;for(s=n<1?n:2-n,i=-.70711*((2.30753+.27061*(r=e.sqrt(-2*e.log(s/2))))/(1+r*(.99229+.04481*r))-r);a<2;a++)i+=(o=t.erfc(i)-s)/(1.1283791670955126*e.exp(-i*i)-i*o);return n<1?i:-i},t.ibetainv=function(n,i,o){var r,s,a,l,u,c,h,d,f,m,p=i-1,g=o-1,v=0;if(n<=0)return 0;if(n>=1)return 1;for(i>=1&&o>=1?(a=n<.5?n:1-n,c=(2.30753+.27061*(l=e.sqrt(-2*e.log(a))))/(1+l*(.99229+.04481*l))-l,n<.5&&(c=-c),h=(c*c-3)/6,d=2/(1/(2*i-1)+1/(2*o-1)),f=c*e.sqrt(h+d)/d-(1/(2*o-1)-1/(2*i-1))*(h+5/6-2/(3*d)),c=i/(i+o*e.exp(2*f))):(r=e.log(i/(i+o)),s=e.log(o/(i+o)),c=n<(l=e.exp(i*r)/i)/(f=l+(u=e.exp(o*s)/o))?e.pow(i*f*n,1/i):1-e.pow(o*f*(1-n),1/o)),m=-t.gammaln(i)-t.gammaln(o)+t.gammaln(i+o);v<10;v++){if(0===c||1===c)return c;if((c-=l=(u=(t.ibeta(c,i,o)-n)/(l=e.exp(p*e.log(c)+g*e.log(1-c)+m)))/(1-.5*e.min(1,u*(p/c-g/(1-c)))))<=0&&(c=.5*(c+l)),c>=1&&(c=.5*(c+l+1)),e.abs(l)<1e-8*c&&v>0)break}return c},t.ibeta=function(n,i,o){var r=0===n||1===n?0:e.exp(t.gammaln(i+o)-t.gammaln(i)-t.gammaln(o)+i*e.log(n)+o*e.log(1-n));return!(n<0||n>1)&&(n<(i+1)/(i+o+2)?r*t.betacf(n,i,o)/i:1-r*t.betacf(1-n,o,i)/o)},t.randn=function(n,i){var o,r,s,a,l;if(i||(i=n),n)return t.create(n,i,(function(){return t.randn()}));do{o=t._random_fn(),r=1.7156*(t._random_fn()-.5),l=(s=o-.449871)*s+(a=e.abs(r)+.386595)*(.196*a-.25472*s)}while(l>.27597&&(l>.27846||r*r>-4*e.log(o)*o*o));return r/o},t.randg=function(n,i,o){var r,s,a,l,u,c,h=n;if(o||(o=i),n||(n=1),i)return(c=t.zeros(i,o)).alter((function(){return t.randg(n)})),c;n<1&&(n+=1),r=n-1/3,s=1/e.sqrt(9*r);do{do{l=1+s*(u=t.randn())}while(l<=0);l*=l*l,a=t._random_fn()}while(a>1-.331*e.pow(u,4)&&e.log(a)>.5*u*u+r*(1-l+e.log(l)));if(n==h)return r*l;do{a=t._random_fn()}while(0===a);return e.pow(a,1/h)*r*l},function(e){for(var n=0;n<e.length;n++)!function(e){t.fn[e]=function(){return t(t.map(this,(function(n){return t[e](n)})))}}(e[n])}("gammaln gammafn factorial factorialln".split(" ")),function(e){for(var n=0;n<e.length;n++)!function(e){t.fn[e]=function(){return t(t[e].apply(null,arguments))}}(e[n])}("randn".split(" "))}(e,Math),function(t,e){function n(t,n,i,o){for(var r,s=0,a=1,l=1,u=1,c=0,h=0;e.abs((l-h)/l)>o;)h=l,a=u+(r=-(n+c)*(n+i+c)*t/(n+2*c)/(n+2*c+1))*a,l=(s=l+r*s)+(r=(c+=1)*(i-c)*t/(n+2*c-1)/(n+2*c))*l,s/=u=a+r*u,a/=u,l/=u,u=1;return l/n}function i(n,i,o){var r=[.9815606342467192,.9041172563704749,.7699026741943047,.5873179542866175,.3678314989981802,.1252334085114689],s=[.04717533638651183,.10693932599531843,.16007832854334622,.20316742672306592,.2334925365383548,.24914704581340277],a=.5*n;if(a>=8)return 1;var l,u=2*t.normal.cdf(a,0,1,1,0)-1;u=u>=e.exp(-50/o)?e.pow(u,o):0;for(var c=a,h=(8-a)/(l=n>3?2:3),d=c+h,f=0,m=o-1,p=1;p<=l;p++){for(var g=0,v=.5*(d+c),C=.5*(d-c),y=1;y<=12;y++){var w,A=v+C*(6<y?r[(w=12-y+1)-1]:-r[(w=y)-1]),b=A*A;if(b>60)break;var S=2*t.normal.cdf(A,0,1,1,0)*.5-2*t.normal.cdf(A,n,1,1,0)*.5;S>=e.exp(-30/m)&&(g+=S=s[w-1]*e.exp(-.5*b)*e.pow(S,m))}f+=g*=2*C*o/e.sqrt(2*e.PI),c=d,d+=h}return(u+=f)<=e.exp(-30/i)?0:(u=e.pow(u,i))>=1?1:u}!function(e){for(var n=0;n<e.length;n++)!function(e){t[e]=function t(e,n,i){return this instanceof t?(this._a=e,this._b=n,this._c=i,this):new t(e,n,i)},t.fn[e]=function(n,i,o){var r=t[e](n,i,o);return r.data=this,r},t[e].prototype.sample=function(n){var i=this._a,o=this._b,r=this._c;return n?t.alter(n,(function(){return t[e].sample(i,o,r)})):t[e].sample(i,o,r)},function(n){for(var i=0;i<n.length;i++)!function(n){t[e].prototype[n]=function(i){var o=this._a,r=this._b,s=this._c;return i||0===i||(i=this.data),"number"!=typeof i?t.fn.map.call(i,(function(i){return t[e][n](i,o,r,s)})):t[e][n](i,o,r,s)}}(n[i])}("pdf cdf inv".split(" ")),function(n){for(var i=0;i<n.length;i++)!function(n){t[e].prototype[n]=function(){return t[e][n](this._a,this._b,this._c)}}(n[i])}("mean median mode variance".split(" "))}(e[n])}("beta centralF cauchy chisquare exponential gamma invgamma kumaraswamy laplace lognormal noncentralt normal pareto studentt weibull uniform binomial negbin hypgeom poisson triangular tukey arcsine".split(" ")),t.extend(t.beta,{pdf:function(n,i,o){return n>1||n<0?0:1==i&&1==o?1:i<512&&o<512?e.pow(n,i-1)*e.pow(1-n,o-1)/t.betafn(i,o):e.exp((i-1)*e.log(n)+(o-1)*e.log(1-n)-t.betaln(i,o))},cdf:function(e,n,i){return e>1||e<0?1*(e>1):t.ibeta(e,n,i)},inv:function(e,n,i){return t.ibetainv(e,n,i)},mean:function(t,e){return t/(t+e)},median:function(e,n){return t.ibetainv(.5,e,n)},mode:function(t,e){return(t-1)/(t+e-2)},sample:function(e,n){var i=t.randg(e);return i/(i+t.randg(n))},variance:function(t,n){return t*n/(e.pow(t+n,2)*(t+n+1))}}),t.extend(t.centralF,{pdf:function(n,i,o){var r;return n<0?0:i<=2?0===n&&i<2?1/0:0===n&&2===i?1:1/t.betafn(i/2,o/2)*e.pow(i/o,i/2)*e.pow(n,i/2-1)*e.pow(1+i/o*n,-(i+o)/2):(r=i*n/(o+n*i),i*(o/(o+n*i))/2*t.binomial.pdf((i-2)/2,(i+o-2)/2,r))},cdf:function(e,n,i){return e<0?0:t.ibeta(n*e/(n*e+i),n/2,i/2)},inv:function(e,n,i){return i/(n*(1/t.ibetainv(e,n/2,i/2)-1))},mean:function(t,e){return e>2?e/(e-2):void 0},mode:function(t,e){return t>2?e*(t-2)/(t*(e+2)):void 0},sample:function(e,n){return 2*t.randg(e/2)/e/(2*t.randg(n/2)/n)},variance:function(t,e){if(!(e<=4))return 2*e*e*(t+e-2)/(t*(e-2)*(e-2)*(e-4))}}),t.extend(t.cauchy,{pdf:function(t,n,i){return i<0?0:i/(e.pow(t-n,2)+e.pow(i,2))/e.PI},cdf:function(t,n,i){return e.atan((t-n)/i)/e.PI+.5},inv:function(t,n,i){return n+i*e.tan(e.PI*(t-.5))},median:function(t){return t},mode:function(t){return t},sample:function(n,i){return t.randn()*e.sqrt(1/(2*t.randg(.5)))*i+n}}),t.extend(t.chisquare,{pdf:function(n,i){return n<0?0:0===n&&2===i?.5:e.exp((i/2-1)*e.log(n)-n/2-i/2*e.log(2)-t.gammaln(i/2))},cdf:function(e,n){return e<0?0:t.lowRegGamma(n/2,e/2)},inv:function(e,n){return 2*t.gammapinv(e,.5*n)},mean:function(t){return t},median:function(t){return t*e.pow(1-2/(9*t),3)},mode:function(t){return t-2>0?t-2:0},sample:function(e){return 2*t.randg(e/2)},variance:function(t){return 2*t}}),t.extend(t.exponential,{pdf:function(t,n){return t<0?0:n*e.exp(-n*t)},cdf:function(t,n){return t<0?0:1-e.exp(-n*t)},inv:function(t,n){return-e.log(1-t)/n},mean:function(t){return 1/t},median:function(t){return 1/t*e.log(2)},mode:function(){return 0},sample:function(n){return-1/n*e.log(t._random_fn())},variance:function(t){return e.pow(t,-2)}}),t.extend(t.gamma,{pdf:function(n,i,o){return n<0?0:0===n&&1===i?1/o:e.exp((i-1)*e.log(n)-n/o-t.gammaln(i)-i*e.log(o))},cdf:function(e,n,i){return e<0?0:t.lowRegGamma(n,e/i)},inv:function(e,n,i){return t.gammapinv(e,n)*i},mean:function(t,e){return t*e},mode:function(t,e){if(t>1)return(t-1)*e},sample:function(e,n){return t.randg(e)*n},variance:function(t,e){return t*e*e}}),t.extend(t.invgamma,{pdf:function(n,i,o){return n<=0?0:e.exp(-(i+1)*e.log(n)-o/n-t.gammaln(i)+i*e.log(o))},cdf:function(e,n,i){return e<=0?0:1-t.lowRegGamma(n,i/e)},inv:function(e,n,i){return i/t.gammapinv(1-e,n)},mean:function(t,e){return t>1?e/(t-1):void 0},mode:function(t,e){return e/(t+1)},sample:function(e,n){return n/t.randg(e)},variance:function(t,e){if(!(t<=2))return e*e/((t-1)*(t-1)*(t-2))}}),t.extend(t.kumaraswamy,{pdf:function(t,n,i){return 0===t&&1===n?i:1===t&&1===i?n:e.exp(e.log(n)+e.log(i)+(n-1)*e.log(t)+(i-1)*e.log(1-e.pow(t,n)))},cdf:function(t,n,i){return t<0?0:t>1?1:1-e.pow(1-e.pow(t,n),i)},inv:function(t,n,i){return e.pow(1-e.pow(1-t,1/i),1/n)},mean:function(e,n){return n*t.gammafn(1+1/e)*t.gammafn(n)/t.gammafn(1+1/e+n)},median:function(t,n){return e.pow(1-e.pow(2,-1/n),1/t)},mode:function(t,n){if(t>=1&&n>=1&&1!==t&&1!==n)return e.pow((t-1)/(t*n-1),1/t)},variance:function(){throw new Error("variance not yet implemented")}}),t.extend(t.lognormal,{pdf:function(t,n,i){return t<=0?0:e.exp(-e.log(t)-.5*e.log(2*e.PI)-e.log(i)-e.pow(e.log(t)-n,2)/(2*i*i))},cdf:function(n,i,o){return n<0?0:.5+.5*t.erf((e.log(n)-i)/e.sqrt(2*o*o))},inv:function(n,i,o){return e.exp(-1.4142135623730951*o*t.erfcinv(2*n)+i)},mean:function(t,n){return e.exp(t+n*n/2)},median:function(t){return e.exp(t)},mode:function(t,n){return e.exp(t-n*n)},sample:function(n,i){return e.exp(t.randn()*i+n)},variance:function(t,n){return(e.exp(n*n)-1)*e.exp(2*t+n*n)}}),t.extend(t.noncentralt,{pdf:function(n,i,o){return e.abs(o)<1e-14?t.studentt.pdf(n,i):e.abs(n)<1e-14?e.exp(t.gammaln((i+1)/2)-o*o/2-.5*e.log(e.PI*i)-t.gammaln(i/2)):i/n*(t.noncentralt.cdf(n*e.sqrt(1+2/i),i+2,o)-t.noncentralt.cdf(n,i,o))},cdf:function(n,i,o){var r=1e-14;if(e.abs(o)<r)return t.studentt.cdf(n,i);var s=!1;n<0&&(s=!0,o=-o);for(var a=t.normal.cdf(-o,0,1),l=r+1,u=l,c=n*n/(n*n+i),h=0,d=e.exp(-o*o/2),f=e.exp(-o*o/2-.5*e.log(2)-t.gammaln(1.5))*o;h<200||u>r||l>r;)u=l,h>0&&(d*=o*o/(2*h),f*=o*o/(2*(h+.5))),a+=.5*(l=d*t.beta.cdf(c,h+.5,i/2)+f*t.beta.cdf(c,h+1,i/2)),h++;return s?1-a:a}}),t.extend(t.normal,{pdf:function(t,n,i){return e.exp(-.5*e.log(2*e.PI)-e.log(i)-e.pow(t-n,2)/(2*i*i))},cdf:function(n,i,o){return.5*(1+t.erf((n-i)/e.sqrt(2*o*o)))},inv:function(e,n,i){return-1.4142135623730951*i*t.erfcinv(2*e)+n},mean:function(t){return t},median:function(t){return t},mode:function(t){return t},sample:function(e,n){return t.randn()*n+e},variance:function(t,e){return e*e}}),t.extend(t.pareto,{pdf:function(t,n,i){return t<n?0:i*e.pow(n,i)/e.pow(t,i+1)},cdf:function(t,n,i){return t<n?0:1-e.pow(n/t,i)},inv:function(t,n,i){return n/e.pow(1-t,1/i)},mean:function(t,n){if(!(n<=1))return n*e.pow(t,n)/(n-1)},median:function(t,n){return t*(n*e.SQRT2)},mode:function(t){return t},variance:function(t,n){if(!(n<=2))return t*t*n/(e.pow(n-1,2)*(n-2))}}),t.extend(t.studentt,{pdf:function(n,i){return i=i>1e100?1e100:i,1/(e.sqrt(i)*t.betafn(.5,i/2))*e.pow(1+n*n/i,-(i+1)/2)},cdf:function(n,i){var o=i/2;return t.ibeta((n+e.sqrt(n*n+i))/(2*e.sqrt(n*n+i)),o,o)},inv:function(n,i){var o=t.ibetainv(2*e.min(n,1-n),.5*i,.5);return o=e.sqrt(i*(1-o)/o),n>.5?o:-o},mean:function(t){return t>1?0:void 0},median:function(){return 0},mode:function(){return 0},sample:function(n){return t.randn()*e.sqrt(n/(2*t.randg(n/2)))},variance:function(t){return t>2?t/(t-2):t>1?1/0:void 0}}),t.extend(t.weibull,{pdf:function(t,n,i){return t<0||n<0||i<0?0:i/n*e.pow(t/n,i-1)*e.exp(-e.pow(t/n,i))},cdf:function(t,n,i){return t<0?0:1-e.exp(-e.pow(t/n,i))},inv:function(t,n,i){return n*e.pow(-e.log(1-t),1/i)},mean:function(e,n){return e*t.gammafn(1+1/n)},median:function(t,n){return t*e.pow(e.log(2),1/n)},mode:function(t,n){return n<=1?0:t*e.pow((n-1)/n,1/n)},sample:function(n,i){return n*e.pow(-e.log(t._random_fn()),1/i)},variance:function(n,i){return n*n*t.gammafn(1+2/i)-e.pow(t.weibull.mean(n,i),2)}}),t.extend(t.uniform,{pdf:function(t,e,n){return t<e||t>n?0:1/(n-e)},cdf:function(t,e,n){return t<e?0:t<n?(t-e)/(n-e):1},inv:function(t,e,n){return e+t*(n-e)},mean:function(t,e){return.5*(t+e)},median:function(e,n){return t.mean(e,n)},mode:function(){throw new Error("mode is not yet implemented")},sample:function(e,n){return e/2+n/2+(n/2-e/2)*(2*t._random_fn()-1)},variance:function(t,n){return e.pow(n-t,2)/12}}),t.extend(t.binomial,{pdf:function(n,i,o){return 0===o||1===o?i*o===n?1:0:t.combination(i,n)*e.pow(o,n)*e.pow(1-o,i-n)},cdf:function(i,o,r){var s,a=1e-10;if(i<0)return 0;if(i>=o)return 1;if(r<0||r>1||o<=0)return NaN;var l=r,u=(i=e.floor(i))+1,c=o-i,h=u+c,d=e.exp(t.gammaln(h)-t.gammaln(c)-t.gammaln(u)+u*e.log(l)+c*e.log(1-l));return s=l<(u+1)/(h+2)?d*n(l,u,c,a):1-d*n(1-l,c,u,a),e.round(1/a*(1-s))/(1/a)}}),t.extend(t.negbin,{pdf:function(n,i,o){return n===n>>>0&&(n<0?0:t.combination(n+i-1,i-1)*e.pow(1-o,n)*e.pow(o,i))},cdf:function(e,n,i){var o=0,r=0;if(e<0)return 0;for(;r<=e;r++)o+=t.negbin.pdf(r,n,i);return o}}),t.extend(t.hypgeom,{pdf:function(n,i,o,r){if(n!=n|0)return!1;if(n<0||n<o-(i-r))return 0;if(n>r||n>o)return 0;if(2*o>i)return 2*r>i?t.hypgeom.pdf(i-o-r+n,i,i-o,i-r):t.hypgeom.pdf(r-n,i,i-o,r);if(2*r>i)return t.hypgeom.pdf(o-n,i,o,i-r);if(o<r)return t.hypgeom.pdf(n,i,r,o);for(var s=1,a=0,l=0;l<n;l++){for(;s>1&&a<r;)s*=1-o/(i-a),a++;s*=(r-l)*(o-l)/((l+1)*(i-o-r+l+1))}for(;a<r;a++)s*=1-o/(i-a);return e.min(1,e.max(0,s))},cdf:function(n,i,o,r){if(n<0||n<o-(i-r))return 0;if(n>=r||n>=o)return 1;if(2*o>i)return 2*r>i?t.hypgeom.cdf(i-o-r+n,i,i-o,i-r):1-t.hypgeom.cdf(r-n-1,i,i-o,r);if(2*r>i)return 1-t.hypgeom.cdf(o-n-1,i,o,i-r);if(o<r)return t.hypgeom.cdf(n,i,r,o);for(var s=1,a=1,l=0,u=0;u<n;u++){for(;s>1&&l<r;){var c=1-o/(i-l);a*=c,s*=c,l++}s+=a*=(r-u)*(o-u)/((u+1)*(i-o-r+u+1))}for(;l<r;l++)s*=1-o/(i-l);return e.min(1,e.max(0,s))}}),t.extend(t.poisson,{pdf:function(n,i){return i<0||n%1!=0||n<0?0:e.pow(i,n)*e.exp(-i)/t.factorial(n)},cdf:function(e,n){var i=[],o=0;if(e<0)return 0;for(;o<=e;o++)i.push(t.poisson.pdf(o,n));return t.sum(i)},mean:function(t){return t},variance:function(t){return t},sampleSmall:function(n){var i=1,o=0,r=e.exp(-n);do{o++,i*=t._random_fn()}while(i>r);return o-1},sampleLarge:function(n){var i,o,r,s,a,l,u,c,h,d,f=n;for(s=e.sqrt(f),a=e.log(f),l=.02483*(u=.931+2.53*s)-.059,c=1.1239+1.1328/(u-3.4),h=.9277-3.6224/(u-2);;){if(o=e.random()-.5,r=e.random(),d=.5-e.abs(o),i=e.floor((2*l/d+u)*o+f+.43),d>=.07&&r<=h)return i;if(!(i<0||d<.013&&r>d)&&e.log(r)+e.log(c)-e.log(l/(d*d)+u)<=i*a-f-t.loggam(i+1))return i}},sample:function(t){return t<10?this.sampleSmall(t):this.sampleLarge(t)}}),t.extend(t.triangular,{pdf:function(t,e,n,i){return n<=e||i<e||i>n?NaN:t<e||t>n?0:t<i?2*(t-e)/((n-e)*(i-e)):t===i?2/(n-e):2*(n-t)/((n-e)*(n-i))},cdf:function(t,n,i,o){return i<=n||o<n||o>i?NaN:t<=n?0:t>=i?1:t<=o?e.pow(t-n,2)/((i-n)*(o-n)):1-e.pow(i-t,2)/((i-n)*(i-o))},inv:function(t,n,i,o){return i<=n||o<n||o>i?NaN:t<=(o-n)/(i-n)?n+(i-n)*e.sqrt(t*((o-n)/(i-n))):n+(i-n)*(1-e.sqrt((1-t)*(1-(o-n)/(i-n))))},mean:function(t,e,n){return(t+e+n)/3},median:function(t,n,i){return i<=(t+n)/2?n-e.sqrt((n-t)*(n-i))/e.sqrt(2):i>(t+n)/2?t+e.sqrt((n-t)*(i-t))/e.sqrt(2):void 0},mode:function(t,e,n){return n},sample:function(n,i,o){var r=t._random_fn();return r<(o-n)/(i-n)?n+e.sqrt(r*(i-n)*(o-n)):i-e.sqrt((1-r)*(i-n)*(i-o))},variance:function(t,e,n){return(t*t+e*e+n*n-t*e-t*n-e*n)/18}}),t.extend(t.arcsine,{pdf:function(t,n,i){return i<=n?NaN:t<=n||t>=i?0:2/e.PI*e.pow(e.pow(i-n,2)-e.pow(2*t-n-i,2),-.5)},cdf:function(t,n,i){return t<n?0:t<i?2/e.PI*e.asin(e.sqrt((t-n)/(i-n))):1},inv:function(t,n,i){return n+(.5-.5*e.cos(e.PI*t))*(i-n)},mean:function(t,e){return e<=t?NaN:(t+e)/2},median:function(t,e){return e<=t?NaN:(t+e)/2},mode:function(){throw new Error("mode is not yet implemented")},sample:function(n,i){return(n+i)/2+(i-n)/2*e.sin(2*e.PI*t.uniform.sample(0,1))},variance:function(t,n){return n<=t?NaN:e.pow(n-t,2)/8}}),t.extend(t.laplace,{pdf:function(t,n,i){return i<=0?0:e.exp(-e.abs(t-n)/i)/(2*i)},cdf:function(t,n,i){return i<=0?0:t<n?.5*e.exp((t-n)/i):1-.5*e.exp(-(t-n)/i)},mean:function(t){return t},median:function(t){return t},mode:function(t){return t},variance:function(t,e){return 2*e*e},sample:function(n,i){var o,r=t._random_fn()-.5;return n-i*((o=r)/e.abs(o))*e.log(1-2*e.abs(r))}}),t.extend(t.tukey,{cdf:function(n,o,r){var s=o,a=[.9894009349916499,.9445750230732326,.8656312023878318,.755404408355003,.6178762444026438,.45801677765722737,.2816035507792589,.09501250983763744],l=[.027152459411754096,.062253523938647894,.09515851168249279,.12462897125553388,.14959598881657674,.16915651939500254,.18260341504492358,.1894506104550685];if(n<=0)return 0;if(r<2||s<2)return NaN;if(!Number.isFinite(n))return 1;if(r>25e3)return i(n,1,s);var u,c=.5*r,h=c*e.log(r)-r*e.log(2)-t.gammaln(c),d=c-1,f=.25*r;u=r<=100?1:r<=800?.5:r<=5e3?.25:.125,h+=e.log(u);for(var m=0,p=1;p<=50;p++){for(var g=0,v=(2*p-1)*u,C=1;C<=16;C++){var y,w;8<C?(y=C-8-1,w=h+d*e.log(v+a[y]*u)-(a[y]*u+v)*f):(y=C-1,w=h+d*e.log(v-a[y]*u)+(a[y]*u-v)*f),w>=-30&&(g+=i(8<C?n*e.sqrt(.5*(a[y]*u+v)):n*e.sqrt(.5*(-a[y]*u+v)),1,s)*l[y]*e.exp(w))}if(p*u>=1&&g<=1e-14)break;m+=g}if(g>1e-14)throw new Error("tukey.cdf failed to converge");return m>1&&(m=1),m},inv:function(n,i,o){if(o<2||i<2)return NaN;if(n<0||n>1)return NaN;if(0===n)return 0;if(1===n)return 1/0;var r,s=function(t,n,i){var o=.5-.5*t,r=e.sqrt(e.log(1/(o*o))),s=r+((((-453642210148e-16*r-.204231210125)*r-.342242088547)*r-1)*r+.322232421088)/((((.0038560700634*r+.10353775285)*r+.531103462366)*r+.588581570495)*r+.099348462606);i<120&&(s+=(s*s*s+s)/i/4);var a=.8832-.2368*s;return i<120&&(a+=-1.214/i+1.208*s/i),s*(a*e.log(n-1)+1.4142)}(n,i,o),a=t.tukey.cdf(s,i,o)-n;r=a>0?e.max(0,s-1):s+1;for(var l,u=t.tukey.cdf(r,i,o)-n,c=1;c<50;c++)if(l=r-u*(r-s)/(u-a),a=u,s=r,l<0&&(l=0,u=-n),u=t.tukey.cdf(l,i,o)-n,r=l,e.abs(r-s)<1e-4)return l;throw new Error("tukey.inv failed to converge")}})}(e,Math),function(t,e){var n,i,o=Array.prototype.push,r=t.utils.isArray;function s(e){return r(e)||e instanceof t}t.extend({add:function(e,n){return s(n)?(s(n[0])||(n=[n]),t.map(e,(function(t,e,i){return t+n[e][i]}))):t.map(e,(function(t){return t+n}))},subtract:function(e,n){return s(n)?(s(n[0])||(n=[n]),t.map(e,(function(t,e,i){return t-n[e][i]||0}))):t.map(e,(function(t){return t-n}))},divide:function(e,n){return s(n)?(s(n[0])||(n=[n]),t.multiply(e,t.inv(n))):t.map(e,(function(t){return t/n}))},multiply:function(e,n){var i,o,r,a,l,u,c,h;if(void 0===e.length&&void 0===n.length)return e*n;if(l=e.length,u=e[0].length,c=t.zeros(l,r=s(n)?n[0].length:u),h=0,s(n)){for(;h<r;h++)for(i=0;i<l;i++){for(a=0,o=0;o<u;o++)a+=e[i][o]*n[o][h];c[i][h]=a}return 1===l&&1===h?c[0][0]:c}return t.map(e,(function(t){return t*n}))},outer:function(e,n){return t.multiply(e.map((function(t){return[t]})),[n])},dot:function(e,n){s(e[0])||(e=[e]),s(n[0])||(n=[n]);for(var i,o,r=1===e[0].length&&1!==e.length?t.transpose(e):e,a=1===n[0].length&&1!==n.length?t.transpose(n):n,l=[],u=0,c=r.length,h=r[0].length;u<c;u++){for(l[u]=[],i=0,o=0;o<h;o++)i+=r[u][o]*a[u][o];l[u]=i}return 1===l.length?l[0]:l},pow:function(n,i){return t.map(n,(function(t){return e.pow(t,i)}))},exp:function(n){return t.map(n,(function(t){return e.exp(t)}))},log:function(n){return t.map(n,(function(t){return e.log(t)}))},abs:function(n){return t.map(n,(function(t){return e.abs(t)}))},norm:function(t,n){var i=0,o=0;for(isNaN(n)&&(n=2),s(t[0])&&(t=t[0]);o<t.length;o++)i+=e.pow(e.abs(t[o]),n);return e.pow(i,1/n)},angle:function(n,i){return e.acos(t.dot(n,i)/(t.norm(n)*t.norm(i)))},aug:function(t,e){var n,i=[];for(n=0;n<t.length;n++)i.push(t[n].slice());for(n=0;n<i.length;n++)o.apply(i[n],e[n]);return i},inv:function(e){for(var n,i=e.length,o=e[0].length,r=t.identity(i,o),s=t.gauss_jordan(e,r),a=[],l=0;l<i;l++)for(a[l]=[],n=o;n<s[0].length;n++)a[l][n-o]=s[l][n];return a},det:function t(e){if(2===e.length)return e[0][0]*e[1][1]-e[0][1]*e[1][0];for(var n=0,i=0;i<e.length;i++){for(var o=[],r=1;r<e.length;r++){o[r-1]=[];for(var s=0;s<e.length;s++)s<i?o[r-1][s]=e[r][s]:s>i&&(o[r-1][s-1]=e[r][s])}var a=i%2?-1:1;n+=t(o)*e[0][i]*a}return n},gauss_elimination:function(n,i){var o,r,s,a,l=0,u=0,c=n.length,h=n[0].length,d=1,f=0,m=[];for(o=(n=t.aug(n,i))[0].length,l=0;l<c;l++){for(r=n[l][l],u=l,a=l+1;a<h;a++)r<e.abs(n[a][l])&&(r=n[a][l],u=a);if(u!=l)for(a=0;a<o;a++)s=n[l][a],n[l][a]=n[u][a],n[u][a]=s;for(u=l+1;u<c;u++)for(d=n[u][l]/n[l][l],a=l;a<o;a++)n[u][a]=n[u][a]-d*n[l][a]}for(l=c-1;l>=0;l--){for(f=0,u=l+1;u<=c-1;u++)f+=m[u]*n[l][u];m[l]=(n[l][o-1]-f)/n[l][l]}return m},gauss_jordan:function(n,i){var o,r,s,a=t.aug(n,i),l=a.length,u=a[0].length,c=0;for(r=0;r<l;r++){var h=r;for(s=r+1;s<l;s++)e.abs(a[s][r])>e.abs(a[h][r])&&(h=s);var d=a[r];for(a[r]=a[h],a[h]=d,s=r+1;s<l;s++)for(c=a[s][r]/a[r][r],o=r;o<u;o++)a[s][o]-=a[r][o]*c}for(r=l-1;r>=0;r--){for(c=a[r][r],s=0;s<r;s++)for(o=u-1;o>r-1;o--)a[s][o]-=a[r][o]*a[s][r]/c;for(a[r][r]/=c,o=l;o<u;o++)a[r][o]/=c}return a},triaUpSolve:function(e,n){var i,o=e[0].length,r=t.zeros(1,o)[0],s=!1;return null!=n[0].length&&(n=n.map((function(t){return t[0]})),s=!0),t.arange(o-1,-1,-1).forEach((function(s){i=t.arange(s+1,o).map((function(t){return r[t]*e[s][t]})),r[s]=(n[s]-t.sum(i))/e[s][s]})),s?r.map((function(t){return[t]})):r},triaLowSolve:function(e,n){var i,o=e[0].length,r=t.zeros(1,o)[0],s=!1;return null!=n[0].length&&(n=n.map((function(t){return t[0]})),s=!0),t.arange(o).forEach((function(o){i=t.arange(o).map((function(t){return e[o][t]*r[t]})),r[o]=(n[o]-t.sum(i))/e[o][o]})),s?r.map((function(t){return[t]})):r},lu:function(e){var n,i=e.length,o=t.identity(i),r=t.zeros(e.length,e[0].length);return t.arange(i).forEach((function(t){r[0][t]=e[0][t]})),t.arange(1,i).forEach((function(s){t.arange(s).forEach((function(i){n=t.arange(i).map((function(t){return o[s][t]*r[t][i]})),o[s][i]=(e[s][i]-t.sum(n))/r[i][i]})),t.arange(s,i).forEach((function(i){n=t.arange(s).map((function(t){return o[s][t]*r[t][i]})),r[s][i]=e[n.length][i]-t.sum(n)}))})),[o,r]},cholesky:function(n){var i,o=n.length,r=t.zeros(n.length,n[0].length);return t.arange(o).forEach((function(s){i=t.arange(s).map((function(t){return e.pow(r[s][t],2)})),r[s][s]=e.sqrt(n[s][s]-t.sum(i)),t.arange(s+1,o).forEach((function(e){i=t.arange(s).map((function(t){return r[s][t]*r[e][t]})),r[e][s]=(n[s][e]-t.sum(i))/r[s][s]}))})),r},gauss_jacobi:function(n,i,o,r){for(var s,a,l,u,c=0,h=0,d=n.length,f=[],m=[],p=[];c<d;c++)for(f[c]=[],m[c]=[],p[c]=[],h=0;h<d;h++)c>h?(f[c][h]=n[c][h],m[c][h]=p[c][h]=0):c<h?(m[c][h]=n[c][h],f[c][h]=p[c][h]=0):(p[c][h]=n[c][h],f[c][h]=m[c][h]=0);for(l=t.multiply(t.multiply(t.inv(p),t.add(f,m)),-1),a=t.multiply(t.inv(p),i),s=o,u=t.add(t.multiply(l,o),a),c=2;e.abs(t.norm(t.subtract(u,s)))>r;)s=u,u=t.add(t.multiply(l,s),a),c++;return u},gauss_seidel:function(n,i,o,r){for(var s,a,l,u,c,h=0,d=n.length,f=[],m=[],p=[];h<d;h++)for(f[h]=[],m[h]=[],p[h]=[],s=0;s<d;s++)h>s?(f[h][s]=n[h][s],m[h][s]=p[h][s]=0):h<s?(m[h][s]=n[h][s],f[h][s]=p[h][s]=0):(p[h][s]=n[h][s],f[h][s]=m[h][s]=0);for(u=t.multiply(t.multiply(t.inv(t.add(p,f)),m),-1),l=t.multiply(t.inv(t.add(p,f)),i),a=o,c=t.add(t.multiply(u,o),l),h=2;e.abs(t.norm(t.subtract(c,a)))>r;)a=c,c=t.add(t.multiply(u,a),l),h+=1;return c},SOR:function(n,i,o,r,s){for(var a,l,u,c,h,d=0,f=n.length,m=[],p=[],g=[];d<f;d++)for(m[d]=[],p[d]=[],g[d]=[],a=0;a<f;a++)d>a?(m[d][a]=n[d][a],p[d][a]=g[d][a]=0):d<a?(p[d][a]=n[d][a],m[d][a]=g[d][a]=0):(g[d][a]=n[d][a],m[d][a]=p[d][a]=0);for(c=t.multiply(t.inv(t.add(g,t.multiply(m,s))),t.subtract(t.multiply(g,1-s),t.multiply(p,s))),u=t.multiply(t.multiply(t.inv(t.add(g,t.multiply(m,s))),i),s),l=o,h=t.add(t.multiply(c,o),u),d=2;e.abs(t.norm(t.subtract(h,l)))>r;)l=h,h=t.add(t.multiply(c,l),u),d++;return h},householder:function(n){for(var i,o,r,s,a=n.length,l=n[0].length,u=0,c=[],h=[];u<a-1;u++){for(i=0,s=u+1;s<l;s++)i+=n[s][u]*n[s][u];for(i=(n[u+1][u]>0?-1:1)*e.sqrt(i),o=e.sqrt((i*i-n[u+1][u]*i)/2),(c=t.zeros(a,1))[u+1][0]=(n[u+1][u]-i)/(2*o),r=u+2;r<a;r++)c[r][0]=n[r][u]/(2*o);h=t.subtract(t.identity(a,l),t.multiply(t.multiply(c,t.transpose(c)),2)),n=t.multiply(h,t.multiply(n,h))}return n},QR:(n=t.sum,i=t.arange,function(o){var r,s,a,l=o.length,u=o[0].length,c=t.zeros(u,u);for(o=t.copy(o),s=0;s<u;s++){for(c[s][s]=e.sqrt(n(i(l).map((function(t){return o[t][s]*o[t][s]})))),r=0;r<l;r++)o[r][s]=o[r][s]/c[s][s];for(a=s+1;a<u;a++)for(c[s][a]=n(i(l).map((function(t){return o[t][s]*o[t][a]}))),r=0;r<l;r++)o[r][a]=o[r][a]-o[r][s]*c[s][a]}return[o,c]}),lstsq:function(e,n){var i=!1;void 0===n[0].length&&(n=n.map((function(t){return[t]})),i=!0);var o=t.QR(e),r=o[0],s=o[1],a=e[0].length,l=t.slice(r,{col:{end:a}}),u=function(e){var n=(e=t.copy(e)).length,i=t.identity(n);return t.arange(n-1,-1,-1).forEach((function(n){t.sliceAssign(i,{row:n},t.divide(t.slice(i,{row:n}),e[n][n])),t.sliceAssign(e,{row:n},t.divide(t.slice(e,{row:n}),e[n][n])),t.arange(n).forEach((function(o){var r=t.multiply(e[o][n],-1),s=t.slice(e,{row:o}),a=t.multiply(t.slice(e,{row:n}),r);t.sliceAssign(e,{row:o},t.add(s,a));var l=t.slice(i,{row:o}),u=t.multiply(t.slice(i,{row:n}),r);t.sliceAssign(i,{row:o},t.add(l,u))}))})),i}(t.slice(s,{row:{end:a}})),c=t.transpose(l);void 0===c[0].length&&(c=[c]);var h=t.multiply(t.multiply(u,c),n);return void 0===h.length&&(h=[[h]]),i?h.map((function(t){return t[0]})):h},jacobi:function(n){for(var i,o,r,s,a,l,u,c=1,h=n.length,d=t.identity(h,h),f=[];1===c;){for(a=n[0][1],r=0,s=1,i=0;i<h;i++)for(o=0;o<h;o++)i!=o&&a<e.abs(n[i][o])&&(a=e.abs(n[i][o]),r=i,s=o);for(l=n[r][r]===n[s][s]?n[r][s]>0?e.PI/4:-e.PI/4:e.atan(2*n[r][s]/(n[r][r]-n[s][s]))/2,(u=t.identity(h,h))[r][r]=e.cos(l),u[r][s]=-e.sin(l),u[s][r]=e.sin(l),u[s][s]=e.cos(l),d=t.multiply(d,u),n=t.multiply(t.multiply(t.inv(u),n),u),c=0,i=1;i<h;i++)for(o=1;o<h;o++)i!=o&&e.abs(n[i][o])>.001&&(c=1)}for(i=0;i<h;i++)f.push(n[i][i]);return[d,f]},rungekutta:function(t,e,n,i,o,r){var s,a,l;if(2===r)for(;i<=n;)o+=((s=e*t(i,o))+(a=e*t(i+e,o+s)))/2,i+=e;if(4===r)for(;i<=n;)o+=((s=e*t(i,o))+2*(a=e*t(i+e/2,o+s/2))+2*(l=e*t(i+e/2,o+a/2))+e*t(i+e,o+l))/6,i+=e;return o},romberg:function(t,n,i,o){for(var r,s,a,l,u,c=0,h=(i-n)/2,d=[],f=[],m=[];c<o/2;){for(u=t(n),a=n,l=0;a<=i;a+=h,l++)d[l]=a;for(r=d.length,a=1;a<r-1;a++)u+=(a%2!=0?4:2)*t(d[a]);u=h/3*(u+t(i)),m[c]=u,h/=2,c++}for(s=m.length,r=1;1!==s;){for(a=0;a<s-1;a++)f[a]=(e.pow(4,r)*m[a+1]-m[a])/(e.pow(4,r)-1);s=f.length,m=f,f=[],r++}return m},richardson:function(t,n,i,o){function r(t,e){for(var n,i=0,o=t.length;i<o;i++)t[i]===e&&(n=i);return n}for(var s,a,l,u,c,h=e.abs(i-t[r(t,i)+1]),d=0,f=[],m=[];o>=h;)s=r(t,i+o),a=r(t,i),f[d]=(n[s]-2*n[a]+n[2*a-s])/(o*o),o/=2,d++;for(u=f.length,l=1;1!=u;){for(c=0;c<u-1;c++)m[c]=(e.pow(4,l)*f[c+1]-f[c])/(e.pow(4,l)-1);u=m.length,f=m,m=[],l++}return f},simpson:function(t,e,n,i){for(var o,r=(n-e)/i,s=t(e),a=[],l=e,u=0,c=1;l<=n;l+=r,u++)a[u]=l;for(o=a.length;c<o-1;c++)s+=(c%2!=0?4:2)*t(a[c]);return r/3*(s+t(n))},hermite:function(t,e,n,i){for(var o,r=t.length,s=0,a=0,l=[],u=[],c=[],h=[];a<r;a++){for(l[a]=1,o=0;o<r;o++)a!=o&&(l[a]*=(i-t[o])/(t[a]-t[o]));for(u[a]=0,o=0;o<r;o++)a!=o&&(u[a]+=1/(t[a]-t[o]));c[a]=(1-2*(i-t[a])*u[a])*(l[a]*l[a]),h[a]=(i-t[a])*(l[a]*l[a]),s+=c[a]*e[a]+h[a]*n[a]}return s},lagrange:function(t,e,n){for(var i,o,r=0,s=0,a=t.length;s<a;s++){for(o=e[s],i=0;i<a;i++)s!=i&&(o*=(n-t[i])/(t[s]-t[i]));r+=o}return r},cubic_spline:function(e,n,i){for(var o,r,s=e.length,a=0,l=[],u=[],c=[],h=[],d=[],f=[];a<s-1;a++)h[a]=e[a+1]-e[a];for(c[0]=0,a=1;a<s-1;a++)c[a]=3/h[a]*(n[a+1]-n[a])-3/h[a-1]*(n[a]-n[a-1]);for(a=1;a<s-1;a++)l[a]=[],u[a]=[],l[a][a-1]=h[a-1],l[a][a]=2*(h[a-1]+h[a]),l[a][a+1]=h[a],u[a][0]=c[a];for(r=t.multiply(t.inv(l),u),o=0;o<s-1;o++)d[o]=(n[o+1]-n[o])/h[o]-h[o]*(r[o+1][0]+2*r[o][0])/3,f[o]=(r[o+1][0]-r[o][0])/(3*h[o]);for(o=0;o<s&&!(e[o]>i);o++);return n[o-=1]+(i-e[o])*d[o]+t.sq(i-e[o])*r[o]+(i-e[o])*t.sq(i-e[o])*f[o]},gauss_quadrature:function(){throw new Error("gauss_quadrature not yet implemented")},PCA:function(e){var n,i,o,r,s,a=e.length,l=e[0].length,u=0,c=[],h=[],d=[],f=[],m=[],p=[],g=[];for(u=0;u<a;u++)c[u]=t.sum(e[u])/l;for(u=0;u<l;u++)for(m[u]=[],n=0;n<a;n++)m[u][n]=e[n][u]-c[n];for(m=t.transpose(m),u=0;u<a;u++)for(p[u]=[],n=0;n<a;n++)p[u][n]=t.dot([m[u]],[m[n]])/(l-1);for(s=(o=t.jacobi(p))[0],h=o[1],g=t.transpose(s),u=0;u<h.length;u++)for(n=u;n<h.length;n++)h[u]<h[n]&&(i=h[u],h[u]=h[n],h[n]=i,d=g[u],g[u]=g[n],g[n]=d);for(r=t.transpose(m),u=0;u<a;u++)for(f[u]=[],n=0;n<r.length;n++)f[u][n]=t.dot([g[u]],[r[n]]);return[e,h,g,f]}}),function(e){for(var n=0;n<e.length;n++)!function(e){t.fn[e]=function(n,i){var o=this;return i?(setTimeout((function(){i.call(o,t.fn[e].call(o,n))}),15),this):"number"==typeof t[e](this,n)?t[e](this,n):t(t[e](this,n))}}(e[n])}("add divide multiply subtract dot pow exp log abs norm angle".split(" "))}(e,Math),function(t,e){var n=[].slice,i=t.utils.isNumber,o=t.utils.isArray;function r(t,n,i,o){if(t>1||i>1||t<=0||i<=0)throw new Error("Proportions should be greater than 0 and less than 1");var r=(t*n+i*o)/(n+o);return(t-i)/e.sqrt(r*(1-r)*(1/n+1/o))}t.extend({zscore:function(){var e=n.call(arguments);return i(e[1])?(e[0]-e[1])/e[2]:(e[0]-t.mean(e[1]))/t.stdev(e[1],e[2])},ztest:function(){var i,r=n.call(arguments);return o(r[1])?(i=t.zscore(r[0],r[1],r[3]),1===r[2]?t.normal.cdf(-e.abs(i),0,1):2*t.normal.cdf(-e.abs(i),0,1)):r.length>2?(i=t.zscore(r[0],r[1],r[2]),1===r[3]?t.normal.cdf(-e.abs(i),0,1):2*t.normal.cdf(-e.abs(i),0,1)):(i=r[0],1===r[1]?t.normal.cdf(-e.abs(i),0,1):2*t.normal.cdf(-e.abs(i),0,1))}}),t.extend(t.fn,{zscore:function(t,e){return(t-this.mean())/this.stdev(e)},ztest:function(n,i,o){var r=e.abs(this.zscore(n,o));return 1===i?t.normal.cdf(-r,0,1):2*t.normal.cdf(-r,0,1)}}),t.extend({tscore:function(){var i=n.call(arguments);return 4===i.length?(i[0]-i[1])/(i[2]/e.sqrt(i[3])):(i[0]-t.mean(i[1]))/(t.stdev(i[1],!0)/e.sqrt(i[1].length))},ttest:function(){var o,r=n.call(arguments);return 5===r.length?(o=e.abs(t.tscore(r[0],r[1],r[2],r[3])),1===r[4]?t.studentt.cdf(-o,r[3]-1):2*t.studentt.cdf(-o,r[3]-1)):i(r[1])?(o=e.abs(r[0]),1==r[2]?t.studentt.cdf(-o,r[1]-1):2*t.studentt.cdf(-o,r[1]-1)):(o=e.abs(t.tscore(r[0],r[1])),1==r[2]?t.studentt.cdf(-o,r[1].length-1):2*t.studentt.cdf(-o,r[1].length-1))}}),t.extend(t.fn,{tscore:function(t){return(t-this.mean())/(this.stdev(!0)/e.sqrt(this.cols()))},ttest:function(n,i){return 1===i?1-t.studentt.cdf(e.abs(this.tscore(n)),this.cols()-1):2*t.studentt.cdf(-e.abs(this.tscore(n)),this.cols()-1)}}),t.extend({anovafscore:function(){var i,o,r,s,a,l,u,c,h=n.call(arguments);if(1===h.length){for(a=new Array(h[0].length),u=0;u<h[0].length;u++)a[u]=h[0][u];h=a}for(o=new Array,u=0;u<h.length;u++)o=o.concat(h[u]);for(r=t.mean(o),i=0,u=0;u<h.length;u++)i+=h[u].length*e.pow(t.mean(h[u])-r,2);for(i/=h.length-1,l=0,u=0;u<h.length;u++)for(s=t.mean(h[u]),c=0;c<h[u].length;c++)l+=e.pow(h[u][c]-s,2);return i/(l/(o.length-h.length))},anovaftest:function(){var e,o,r,s,a=n.call(arguments);if(i(a[0]))return 1-t.centralF.cdf(a[0],a[1],a[2]);var l=t.anovafscore(a);for(e=a.length-1,r=0,s=0;s<a.length;s++)r+=a[s].length;return o=r-e-1,1-t.centralF.cdf(l,e,o)},ftest:function(e,n,i){return 1-t.centralF.cdf(e,n,i)}}),t.extend(t.fn,{anovafscore:function(){return t.anovafscore(this.toArray())},anovaftes:function(){var e,n=0;for(e=0;e<this.length;e++)n+=this[e].length;return t.ftest(this.anovafscore(),this.length-1,n-this.length)}}),t.extend({qscore:function(){var o,r,s,a,l,u=n.call(arguments);return i(u[0])?(o=u[0],r=u[1],s=u[2],a=u[3],l=u[4]):(o=t.mean(u[0]),r=t.mean(u[1]),s=u[0].length,a=u[1].length,l=u[2]),e.abs(o-r)/(l*e.sqrt((1/s+1/a)/2))},qtest:function(){var e,i=n.call(arguments);3===i.length?(e=i[0],i=i.slice(1)):7===i.length?(e=t.qscore(i[0],i[1],i[2],i[3],i[4]),i=i.slice(5)):(e=t.qscore(i[0],i[1],i[2]),i=i.slice(3));var o=i[0],r=i[1];return 1-t.tukey.cdf(e,r,o-r)},tukeyhsd:function(e){for(var n=t.pooledstdev(e),i=e.map((function(e){return t.mean(e)})),o=e.reduce((function(t,e){return t+e.length}),0),r=[],s=0;s<e.length;++s)for(var a=s+1;a<e.length;++a){var l=t.qtest(i[s],i[a],e[s].length,e[a].length,n,o,e.length);r.push([[s,a],l])}return r}}),t.extend({normalci:function(){var i,o=n.call(arguments),r=new Array(2);return i=4===o.length?e.abs(t.normal.inv(o[1]/2,0,1)*o[2]/e.sqrt(o[3])):e.abs(t.normal.inv(o[1]/2,0,1)*t.stdev(o[2])/e.sqrt(o[2].length)),r[0]=o[0]-i,r[1]=o[0]+i,r},tci:function(){var i,o=n.call(arguments),r=new Array(2);return i=4===o.length?e.abs(t.studentt.inv(o[1]/2,o[3]-1)*o[2]/e.sqrt(o[3])):e.abs(t.studentt.inv(o[1]/2,o[2].length-1)*t.stdev(o[2],!0)/e.sqrt(o[2].length)),r[0]=o[0]-i,r[1]=o[0]+i,r},significant:function(t,e){return t<e}}),t.extend(t.fn,{normalci:function(e,n){return t.normalci(e,n,this.toArray())},tci:function(e,n){return t.tci(e,n,this.toArray())}}),t.extend(t.fn,{oneSidedDifferenceOfProportions:function(e,n,i,o){var s=r(e,n,i,o);return t.ztest(s,1)},twoSidedDifferenceOfProportions:function(e,n,i,o){var s=r(e,n,i,o);return t.ztest(s,2)}})}(e,Math),e.models=function(){function t(t,n){var i=t.length,o=n[0].length-1,r=i-o-1,s=e.lstsq(n,t),a=e.multiply(n,s.map((function(t){return[t]}))).map((function(t){return t[0]})),l=e.subtract(t,a),u=e.mean(t),c=e.sum(a.map((function(t){return Math.pow(t-u,2)}))),h=e.sum(t.map((function(t,e){return Math.pow(t-a[e],2)}))),d=c+h;return{exog:n,endog:t,nobs:i,df_model:o,df_resid:r,coef:s,predict:a,resid:l,ybar:u,SST:d,SSE:c,SSR:h,R2:c/d}}function n(n){var i,o,r=(i=n.exog,o=i[0].length,e.arange(o).map((function(n){var r=e.arange(o).filter((function(t){return t!==n}));return t(e.col(i,n).map((function(t){return t[0]})),e.col(i,r))}))),s=Math.sqrt(n.SSR/n.df_resid),a=r.map((function(t){var e=t.SST,n=t.R2;return s/Math.sqrt(e*(1-n))})),l=n.coef.map((function(t,e){return(t-0)/a[e]})),u=l.map((function(t){var i=e.studentt.cdf(t,n.df_resid);return 2*(i>.5?1-i:i)})),c=e.studentt.inv(.975,n.df_resid),h=n.coef.map((function(t,e){var n=c*a[e];return[t-n,t+n]}));return{se:a,t:l,p:u,sigmaHat:s,interval95:h}}return{ols:function(i,o){var r=t(i,o),s=n(r),a=function(t){var n,i,o,r=t.R2/t.df_model/((1-t.R2)/t.df_resid);return{F_statistic:r,pvalue:1-(n=r,i=t.df_model,o=t.df_resid,e.beta.cdf(n/(o/i+n),i/2,o/2))}}(r),l=1-(1-r.R2)*((r.nobs-1)/r.df_resid);return r.t=s,r.f=a,r.adjust_R2=l,r}}}(),e.extend({buildxmatrix:function(){for(var t=new Array(arguments.length),n=0;n<arguments.length;n++)t[n]=[1].concat(arguments[n]);return e(t)},builddxmatrix:function(){for(var t=new Array(arguments[0].length),n=0;n<arguments[0].length;n++)t[n]=[1].concat(arguments[0][n]);return e(t)},buildjxmatrix:function(t){for(var n=new Array(t.length),i=0;i<t.length;i++)n[i]=t[i];return e.builddxmatrix(n)},buildymatrix:function(t){return e(t).transpose()},buildjymatrix:function(t){return t.transpose()},matrixmult:function(t,n){var i,o,r,s,a;if(t.cols()==n.rows()){if(n.rows()>1){for(s=[],i=0;i<t.rows();i++)for(s[i]=[],o=0;o<n.cols();o++){for(a=0,r=0;r<t.cols();r++)a+=t.toArray()[i][r]*n.toArray()[r][o];s[i][o]=a}return e(s)}for(s=[],i=0;i<t.rows();i++)for(s[i]=[],o=0;o<n.cols();o++){for(a=0,r=0;r<t.cols();r++)a+=t.toArray()[i][r]*n.toArray()[o];s[i][o]=a}return e(s)}},regress:function(t,n){var i=e.xtranspxinv(t),o=t.transpose(),r=e.matrixmult(e(i),o);return e.matrixmult(r,n)},regresst:function(t,n,i){var o=e.regress(t,n),r={anova:{}},s=e.jMatYBar(t,o);r.yBar=s;var a=n.mean();r.anova.residuals=e.residuals(n,s),r.anova.ssr=e.ssr(s,a),r.anova.msr=r.anova.ssr/(t[0].length-1),r.anova.sse=e.sse(n,s),r.anova.mse=r.anova.sse/(n.length-(t[0].length-1)-1),r.anova.sst=e.sst(n,a),r.anova.mst=r.anova.sst/(n.length-1),r.anova.r2=1-r.anova.sse/r.anova.sst,r.anova.r2<0&&(r.anova.r2=0),r.anova.fratio=r.anova.msr/r.anova.mse,r.anova.pvalue=e.anovaftest(r.anova.fratio,t[0].length-1,n.length-(t[0].length-1)-1),r.anova.rmse=Math.sqrt(r.anova.mse),r.anova.r2adj=1-r.anova.mse/r.anova.mst,r.anova.r2adj<0&&(r.anova.r2adj=0),r.stats=new Array(t[0].length);for(var l,u,c,h=e.xtranspxinv(t),d=0;d<o.length;d++)l=Math.sqrt(r.anova.mse*Math.abs(h[d][d])),u=Math.abs(o[d]/l),c=e.ttest(u,n.length-t[0].length-1,i),r.stats[d]=[o[d],l,u,c];return r.regress=o,r},xtranspx:function(t){return e.matrixmult(t.transpose(),t)},xtranspxinv:function(t){var n=e.matrixmult(t.transpose(),t);return e.inv(n)},jMatYBar:function(t,n){var i=e.matrixmult(t,n);return new e(i)},residuals:function(t,n){return e.matrixsubtract(t,n)},ssr:function(t,e){for(var n=0,i=0;i<t.length;i++)n+=Math.pow(t[i]-e,2);return n},sse:function(t,e){for(var n=0,i=0;i<t.length;i++)n+=Math.pow(t[i]-e[i],2);return n},sst:function(t,e){for(var n=0,i=0;i<t.length;i++)n+=Math.pow(t[i]-e,2);return n},matrixsubtract:function(t,n){for(var i=new Array(t.length),o=0;o<t.length;o++){i[o]=new Array(t[o].length);for(var r=0;r<t[o].length;r++)i[o][r]=t[o][r]-n[o][r]}return e(i)}}),e.jStat=e,e)},4788:(t,e,n)=>{"use strict";var i=n(5072),o=n.n(i),r=n(7825),s=n.n(r),a=n(7659),l=n.n(a),u=n(5056),c=n.n(u),h=n(540),d=n.n(h),f=n(1113),m=n.n(f),p=n(365),g={};g.styleTagTransform=m(),g.setAttributes=c(),g.insert=l().bind(null,"head"),g.domAPI=s(),g.insertStyleElement=d(),o()(p.A,g),p.A&&p.A.locals&&p.A.locals},5072: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 r={},s=[],a=0;a<t.length;a++){var l=t[a],u=i.base?l[0]+i.base:l[0],c=r[u]||0,h="".concat(u," ").concat(c);r[u]=c+1;var d=n(h),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:h,updater:m,references:1})}s.push(h)}return s}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 r=i(t=t||[],o=o||{});return function(t){t=t||[];for(var s=0;s<r.length;s++){var a=n(r[s]);e[a].references--}for(var l=i(t,o),u=0;u<r.length;u++){var c=n(r[u]);0===e[c].references&&(e[c].updater(),e.splice(c,1))}r=l}}},7659: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)}},540:t=>{"use strict";t.exports=function(t){var e=document.createElement("style");return t.setAttributes(e,t.attributes),t.insert(e,t.options),e}},5056:(t,e,n)=>{"use strict";t.exports=function(t){var e=n.nc;e&&t.setAttribute("nonce",e)}},7825: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 r=n.sourceMap;r&&"undefined"!=typeof btoa&&(i+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(r))))," */")),e.styleTagTransform(i,t,e.options)}(e,t,n)},remove:function(){!function(t){if(null===t.parentNode)return!1;t.parentNode.removeChild(t)}(e)}}}},1113: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))}}},9499:(t,e,n)=>{"use strict";n.d(e,{i:()=>Z,q:()=>$});var i,o,r,s,a,l,u,c=n(7389),h=n(4328),d=n(6082),f=n(2003),m=n(8774);!function(t){t.Levenshtein="Levenshtein",t.JaroWinkler="Jaro-Winkler",t.Manhattan="Manhattan String",t.Onehot="One-Hot"}(i||(i={})),function(t){t.Euclidean="Euclidean",t.Manhattan="Manhattan",t.Cosine="Vector Cosine"}(o||(o={})),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 BitArray"}(r||(r={})),function(t){t.TanimotoIntArray="TanimotoIntArray"}(s||(s={})),function(t){t.Vector="Vector",t.String="String",t.BitArray="BitArray",t.MacroMolecule="MacroMolecule",t.Number="Number",t.IntArray="IntArray",t.NumberArray="NumberArray"}(a||(a={})),function(t){t.Difference="Difference"}(l||(l={})),function(t){t.CommonItems="Common Items"}(u||(u={}));var p=n(1199);r.Tanimoto,r.Dice,r.Asymmetric,r.BraunBlanquet,r.Cosine,r.Kulczynski,r.McConnaughey,r.RogotGoldberg,r.Russel,r.Sokal,r.Hamming,r.Euclidean,r.Tanimoto,r.Dice,r.Asymmetric,r.BraunBlanquet,r.Cosine,r.Kulczynski,r.McConnaughey,r.RogotGoldberg,r.Russel,r.Sokal,r.Hamming,r.Euclidean,r.Tanimoto,r.Dice,r.Cosine,r.Tanimoto,r.Asymmetric,r.Cosine,r.Sokal,p.Z.HAMMING,p.Z.LEVENSHTEIN,p.Z.MONOMER_CHEMICAL_DISTANCE,p.Z.NEEDLEMANN_WUNSCH,new RegExp("[rd]\\((\\w)\\)p?","g");var g,v=n(3077),C=n(439),y=n(4971);async function w(t,e,n,i,o){const r=(0,v.R)(e,o),s=o.getSeqHandler(e).getNewColumnFromList("ref",[n]),a=o.getSeqHandler(s).getSplitted(0),l=i===g.IDENTITY?function(t,e){const n=e.columns.length,i=new Array(n),o=new Array(n),r=new Array(n);for(let s=0;s<n;++s){const n=e.columns.byIndex(s);i[s]=n.getRawData(),o[s]=n.categories.indexOf("");const a=s<t.length?t.getOriginal(s):C._S;r[s]=n.categories.indexOf(a)}const s=d.Column.float("Identity",e.rowCount),a=s.getRawData();for(let n=0;n<e.rowCount;++n){a[n]=0;for(let e=0;e<t.length;++e)(i[e]?i[e][n]:0)===r[e]&&++a[n];a[n]/=t.length}return s}(a,r):i===g.SIMILARITY?await async function(t,e,n){const i=e.columns.toList(),o=await async function(t,e,n){t instanceof d.Column&&(t=(0,v.R)(t,n).columns.toList());const i=(await(0,y.pj)()).getMonomerLib(),o=new Array(t.length),r=t[0].length,s=new Float32Array(r);for(let n=0;n<t.length;++n){const a=n<e.length?e.getCanonical(n):C._S,l=i.getMonomer("PEPTIDE",a)?.smiles??"",u=t[n],c=u.getRawData(),f=u.categories,m=f.indexOf("");if(o[n]={categories:f,data:c,emptyIndex:m},void 0===a)continue;const p=d.Column.fromStrings("smiles",f.map((t=>i.getMonomer("PEPTIDE",t)?.smiles??""))),g=(d.DataFrame.fromColumns([p]),await h.chem.getSimilarities(p,l)),v=g?g.getRawData():null;for(let t=0;t<r;++t){const e=c[t];a!==C._S&&e!==m?s[t]+=v[e]:a===C._S&&e===m&&(s[t]+=1)}}for(let n=0;n<s.length;++n){let i=s[n]/e.length;for(let r=0;r<t.length;++r){const t=o[r];if(r>=e.length&&t.data[n]!==t.emptyIndex||t.data[n]===t.emptyIndex&&r<e.length){i=d.FLOAT_NULL;break}}s[n]=i}return d.Column.fromFloat32Array("Similarity",s)}(i,t,n);return o}(a,r,o):null;if(null===l)throw new Error(`In bio library: Unknown sequence scoring method: ${i}`);return l.name=t.columns.getUnusedName(l.name),t.columns.add(l),l}!function(t){t.IDENTITY="identity",t.SIMILARITY="similarity"}(g||(g={}));var A,b=n(144),S=n.n(b),T=n(7233),E=n.n(T),_=n(4139),N=n(115),x=n(8608),M=n(3541),I=n(3163),O=n(7923),L=n(7654),P=n(5480),R=n(5429),k=n(3262),V=n(1458),F=n(4025);!function(t){t.UMAP="UMAP",t.T_SNE="t-SNE"}(A||(A={}));n(5540);var D,G,U,q,B,H,Y,j,W=n(4329);(G=D||(D={})).EUCLIDEAN="EUCLIDEAN",G.MANHATTAN="MANHATTAN",D.EUCLIDEAN,D.MANHATTAN,(q=U||(U={})).HAMMING="Hamming",q.EUCLIDEAN="Euclidean",q.VECTOR_COSINE="Vector Cosine",q.MANHATTAN="Manhattan",q.TANIMOTO="Tanimoto",q.LEVENSTEIN="Levenshtein",q.NEEDLEMAN_WUNSCH="Needlemann-Wunsch",q.MONOMER_CHEMICAL_DISTANCE="Monomer chemical distance",q.SOKAL="Sokal",q.COSINE="Cosine",q.ASYMMETRIC="Asymmetric",q.Difference="Difference",q.OneHot="One-Hot",U.HAMMING,U.EUCLIDEAN,U.MANHATTAN,U.VECTOR_COSINE,U.TANIMOTO,U.LEVENSTEIN,U.NEEDLEMAN_WUNSCH,U.MONOMER_CHEMICAL_DISTANCE,U.SOKAL,U.COSINE,U.ASYMMETRIC,U.Difference,U.OneHot,U.HAMMING,U.EUCLIDEAN,U.MANHATTAN,U.TANIMOTO,U.SOKAL,U.COSINE,U.ASYMMETRIC,U.LEVENSTEIN,U.NEEDLEMAN_WUNSCH,U.MONOMER_CHEMICAL_DISTANCE,U.Difference,U.OneHot,U.VECTOR_COSINE,new Set([U.HAMMING,U.LEVENSTEIN,U.NEEDLEMAN_WUNSCH,U.MONOMER_CHEMICAL_DISTANCE,U.OneHot]),new Set([U.HAMMING,U.EUCLIDEAN,U.MANHATTAN,U.MONOMER_CHEMICAL_DISTANCE,U.LEVENSTEIN,U.NEEDLEMAN_WUNSCH,U.TANIMOTO,U.COSINE,U.VECTOR_COSINE,U.SOKAL,U.ASYMMETRIC,U.OneHot,U.Difference]),new Set([U.EUCLIDEAN,U.MANHATTAN,U.OneHot,U.Difference,U.VECTOR_COSINE]),new Set([U.EUCLIDEAN,U.MANHATTAN,U.Difference,U.VECTOR_COSINE]),new Set([U.EUCLIDEAN,U.MANHATTAN,U.Difference]),new Set([U.TANIMOTO,U.COSINE,U.SOKAL,U.ASYMMETRIC]),function(t){t.ADD="ADD",t.SUB="SUB",t.MULT="MULT"}(B||(B={})),function(t){t.SQUARE="SQUARE",t.INVERSE="INVERSE",t.TRANSPOSE="TRANSPOSE",t.NORM="NORM",t.COLUMN_NORM="COLUMN_NORM"}(H||(H={})),function(t){t.SCALARMULT="SCALARMULT",t.SCALARADD="SCALARADD",t.SCALARPOW="SCALARPOW"}(Y||(Y={})),Object.prototype.toString,function(t){t.EUCLIDEAN="EUCLIDEAN",t.MANHATTAN="MANHATTAN"}(j||(j={}));var $,z=n(726),K=function(t,e,n,i){return new(n||(n=Promise))((function(o,r){function s(t){try{l(i.next(t))}catch(t){r(t)}}function a(t){try{l(i.throw(t))}catch(t){r(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(s,a)}l((i=i.apply(t,e||[])).next())}))};!function(t){t.SEQUENCE_VARIABILITY_MAP="Sequence Variability Map",t.MOST_POTENT_RESIDUES="Most Potent Residues",t.LOGO_SUMMARY_TABLE="Logo Summary Table",t.DENDROGRAM="Dendrogram",t.CLUSTER_MAX_ACTIVITY="Active peptide selection",t.MCL="MCL",t.SEQUENCE_MUTATION_CLIFFS="Sequence Mutation Cliffs"}($||($={}));class Z{constructor(t){this.isBitsetChangedInitialized=!1,this.isUserChangedSelection=!0,this._dm=null,this.isInitialized=!1,this.isRibbonSet=!1,this.webLogoSelectedMonomers={},this.webLogoBounds={},this.cachedWebLogoTooltip={bar:"",tooltip:null},this._layoutEventInitialized=!1,this.subs=[],this.isHighlighting=!1,this.controlFire=!1,this.accordionSource=null,this._sequenceSpaceViewer=null,this._mclViewer=null,this._monomerPositionStats=null,this._settings=null,this._sequenceSpaceCols=[],this._mclCols=[],this._webLogoSelection=null,this.df=t}get monomerPositionStats(){var t;if(null!==this._monomerPositionStats)return this._monomerPositionStats;const e=this.getScaledActivityColumn();return null===this.positionColumns||null===e?null:(null!==(t=this._monomerPositionStats)&&void 0!==t||(this._monomerPositionStats=(0,V.Ej)(e,this.df.filter,this.positionColumns)),this._monomerPositionStats)}get analysisView(){var t,e,n;return void 0===this._analysisView&&(this._analysisView=this.id?S()(h.shell.tableViews).find((({dataFrame:t})=>(null==t?void 0:t.getTag(d.TAGS.ID))===this.id)):void 0,!this._analysisView&&(null===(t=h.shell.v)||void 0===t?void 0:t.preview)instanceof d.TableView&&(null===(n=null===(e=h.shell.v)||void 0===e?void 0:e.preview)||void 0===n?void 0:n.dataFrame)===this.df&&(this._analysisView=h.shell.v.preview),this._analysisView||(this._analysisView=h.shell.addTableView(this.df))),"1"===this.df.getTag(_.gp.MULTIPLE_VIEWS)||this._layoutEventInitialized||(0,x.Lv)()||(h.shell.v=this._analysisView),this._analysisView.grid.invalidate(),this._analysisView}get settings(){var t,e;const n=this.df.getTag(_.gp.SETTINGS);return n?(null!==(t=this._settings)&&void 0!==t||(this._settings=JSON.parse(n)),!(null===(e=this._settings)||void 0===e?void 0:e.mclSettings)||this._settings.mclSettings.webGPUDescriptionPromise instanceof Promise||(this._settings.mclSettings.webGPUDescriptionPromise=(0,W._)()),this._settings):null}set settings(t){var e,n,i;const o=Object.entries(t),r=Object.assign({},null!==(n=null===(e=this.settings)||void 0===e?void 0:e.sequenceSpaceParams)&&void 0!==n?n:{}),s=new Set;for(const[t,e]of o)switch(this.settings[t]=e,t){case"activityColumnName":case"activityScaling":s.add("activity"),s.add("stats");break;case"showDendrogram":s.add("dendrogram");break;case"showClusterMaxActivity":s.add("clusterMaxActivity");break;case"showSequenceSpace":s.add("showSequenceSpace");break;case"showLogoSummaryTable":s.add("logoSummaryTable");break;case"showMonomerPosition":s.add("monomerPosition");break;case"showMostPotentResidues":s.add("mostPotentResidues");break;case"columns":s.add("columns");break;case"sequenceSpaceParams":s.add("sequenceSpaceParams");break;case"mclSettings":s.add("mclSettings")}if(this.df.setTag("settings",JSON.stringify(this._settings)),this.isInitialized){if(s.has("sequenceSpaceParams")){const t=this.settings.sequenceSpaceParams;Object.entries(t).some((([t,e])=>r[t]!==e&&"epsilon"!==t&&"minPts"!==t&&"clusterEmbeddings"!==t))||(s.delete("sequenceSpaceParams"),this.settings.sequenceSpaceParams.clusterEmbeddings&&s.add("clusterParams"))}s.has("sequenceSpaceParams")&&s.delete("clusterParams");for(const t of s)switch(t){case"activity":this.createScaledCol();break;case"stats":this.webLogoSelection=(0,x.ZR)(this.positionColumns),this.webLogoBounds={},this.cachedWebLogoTooltip={bar:"",tooltip:null},this._monomerPositionStats=null;break;case"dendrogram":this.settings.showDendrogram?this.addDendrogram():this.closeViewer($.DENDROGRAM);break;case"clusterMaxActivity":this.settings.showClusterMaxActivity?this.addClusterMaxActivityViewer():this.closeViewer($.CLUSTER_MAX_ACTIVITY);break;case"logoSummaryTable":this.settings.showLogoSummaryTable?this.addLogoSummaryTable():this.closeViewer($.LOGO_SUMMARY_TABLE);break;case"monomerPosition":this.settings.showMonomerPosition?this.addMonomerPosition():this.closeViewer($.SEQUENCE_VARIABILITY_MAP);break;case"mostPotentResidues":this.settings.showMostPotentResidues?this.addMostPotentResidues():this.closeViewer($.MOST_POTENT_RESIDUES);break;case"columns":const t=this.findViewer($.LOGO_SUMMARY_TABLE);t._viewerGrid=null,t._logoSummaryTable=null,t.render();const e=this.findViewer($.MOST_POTENT_RESIDUES);e._viewerGrid=null,e.render();break;case"sequenceSpaceParams":case"showSequenceSpace":this.settings.showSequenceSpace&&this.addSequenceSpace({clusterEmbeddings:null===(i=this.settings.sequenceSpaceParams)||void 0===i?void 0:i.clusterEmbeddings});break;case"clusterParams":this.clusterEmbeddings();break;case"mclSettings":this.addMCLClusters()}}}get webLogoSelection(){var t,e;return null!==(t=this._webLogoSelection)&&void 0!==t||(this._webLogoSelection=(0,x.ZR)(null!==(e=this.positionColumns)&&void 0!==e?e:[])),this._webLogoSelection}set webLogoSelection(t){this._webLogoSelection=t,this.fireBitsetChanged(null),this.analysisView.grid.invalidate()}get positionColumns(){const t=S()(this.df.columns.byTags({[_.gp.POSITION_COL]:"true"})).toArray();return 0===t.length?null:t}get id(){return this.df.getTag(d.TAGS.ID)}get alphabet(){return this.df.getCol(this.settings.sequenceColumnName).getTag(f.gp.alphabet)}static getInstance(t){if(t.columns.contains(_.$2.ACTIVITY_SCALED)&&!t.columns.contains(_.$2.ACTIVITY)&&(t.getCol(_.$2.ACTIVITY_SCALED).name=_.$2.ACTIVITY),!t.temp[Z.modelName]){const e=t.temp[Z.modelName]=new Z(t),n=e.settings;n&&e.init(n);let i=!0;e.subs.push(d.debounce(t.onSelectionChanged,10).subscribe((n=>{var o,r,s;if(i||t.selection.anyTrue||!e._analysisView||!document.contains(e._analysisView.root)||e._analysisView.dataFrame!==t)return void(i=!(null===(o=null==t?void 0:t.selection)||void 0===o?void 0:o.anyTrue));e.positionColumns&&(e.webLogoSelection=(0,x.ZR)(e.positionColumns));const a=e.findViewer($.SEQUENCE_VARIABILITY_MAP);if(null!=a){const t=null!==(r=e.positionColumns)&&void 0!==r?r:a.positionColumns;t&&(a.invariantMapSelection=(0,x.ZR)(t),a.mutationCliffsSelection=(0,x.ZR)(t))}const l=e.findViewer($.MOST_POTENT_RESIDUES);if(null!=l){const t=null!==(s=e.positionColumns)&&void 0!==s?s:l.positionColumns;t&&(l.mutationCliffsSelection=(0,x.ZR)(t),l.invariantMapSelection=(0,x.ZR)(t))}const u=e.findViewer($.LOGO_SUMMARY_TABLE);null!=u&&(u.initClusterSelection({notify:!0}),u.render()),i=!0})))}return t.temp[Z.modelName]}modifyWebLogoSelection(t,e={shiftPressed:!1,ctrlPressed:!1},n=!0){n?this.webLogoSelection=(0,x.vW)(this.webLogoSelection,t,e):this._webLogoSelection=(0,x.vW)(this.webLogoSelection,t,e)}getVisibleSelection(){return this.df.selection.clone().and(this.df.filter)}createAccordion(){var t,e,n,i,o,r,s,a,l;const u=null===(t=this.df)||void 0===t?void 0:t.temp[Z.modelName];if(!u)return null;const h=c.accordion("Peptides analysis panel");h.root.style.width="100%";const m=u.getVisibleSelection(),p=u.df.filter.anyFalse?` among ${u.df.filter.trueCount} filtered`:"",g=t=>{const e=[];for(const[n,i]of Object.entries(t))for(const t of i)e.push(`${n}:${t}`);return e.join(", ")},v=u.findViewer($.LOGO_SUMMARY_TABLE),C=[],y=(null===v?[]:(null!==(n=null===(e=v.clusterSelection)||void 0===e?void 0:e[P.W.ORIGINAL])&&void 0!==n?n:[]).concat(null!==(o=null===(i=v.clusterSelection)||void 0===i?void 0:i[P.W.CUSTOM])&&void 0!==o?o:[])).join(", "),w=t=>{const e=c.divText(t);return e.innerHTML=t,e};0!==y.length&&C.push(w(`<b>Logo Summary Table</b> clusters: ${y}`));const A=u.findViewer($.SEQUENCE_VARIABILITY_MAP),b=g(null!==(r=null==A?void 0:A.invariantMapSelection)&&void 0!==r?r:{}),S=g(null!==(s=null==A?void 0:A.mutationCliffsSelection)&&void 0!==s?s:{});0!==b.length&&C.push(w(`<b>Invariant map</b>: ${b}`)),0!==S.length&&C.push(w(`<b>Mutation cliffs</b>: ${S}`));const T=u.findViewer($.MOST_POTENT_RESIDUES),E=g(null!==(a=null==T?void 0:T.invariantMapSelection)&&void 0!==a?a:{});0!==E.length&&C.push(w(`<b>Most potent residues</b>: ${E}`));const _=g(u.webLogoSelection);0!==_.length&&C.push(w(`<b>WebLogo</b>: ${_}`)),0!==C.length&&C.unshift(c.h1("Selection Sources"));const N=c.div(c.divV(C));h.addTitle(c.divV([c.h1(`${m.trueCount} selected rows${p}`),N],"css-gap-small"));let R=u.settings;const k=[A,T,v].filter((t=>null!==t&&(t.type!==this.accordionSource||(R=t,!1))));if(null===R)throw new Error("PeptidesError: Model is the source of accordion but is not initialized");R!==u.settings&&k.push(u.settings),k.filter((t=>null!==t&&(0,x.$s)(R,t)&&(t!==u.settings||u.isInitialized))).push(R);const D=R;R===u.settings||D instanceof P.s||null==D.mutationCliffs||h.addPane("Mutation Cliffs pairs",(()=>(0,O.F)(u.df,{mutationCliffs:D.mutationCliffs,mutationCliffsSelection:D.mutationCliffsSelection,gridColumns:u.analysisView.grid.columns,sequenceColumnName:D.sequenceColumnName,positionColumns:D.positionColumns,activityCol:D.getScaledActivityColumn(),mutationCliffStats:D.cliffStats}).root),!0);const G=R===u.settings,U=G?this.webLogoSelection:R instanceof M.J?R.invariantMapSelection:{},q=R instanceof P.s?R.clusterSelection:null!==(l=null==v?void 0:v.clusterSelection)&&void 0!==l?l:{};h.addPane("Distribution",(()=>{var t;try{return(0,L.HV)(u.df,{columns:G?null!==(t=u.settings.columns)&&void 0!==t?t:{}:R.getAggregationColumns(),activityCol:G?u.getScaledActivityColumn():R.getScaledActivityColumn(),monomerPositionSelection:U,clusterSelection:q,clusterColName:null==v?void 0:v.clustersColumnName})}catch(t){const e=c.divText("Error in Distribution");return c.tooltip.bind(e,String(t)),e}}),!0);const B=(t,e)=>{if(null==t||null==e)return!1;for(const[n,i]of Object.entries(t))if(i!==e[n])return!1;return!0};return h.addPane("Selection",(()=>{var t;try{return function(t,e){var n,i,o;if(0===e.tableSelection.trueCount)return c.divText("No compounds selected");const r=d.DataFrame.create(t.rowCount);r.name="Selected compounds",r.filter.copyFrom(e.tableSelection);let s=null;for(let t=1;t<e.gridColumns.length;t++){const o=e.gridColumns.byIndex(t);if(!o.visible)continue;const a=o.column;if(a.type===d.COLUMN_TYPE.BOOL)continue;null===s&&o.grid&&(null===(n=o.grid.sortByColumns)||void 0===n?void 0:n.length)>0&&(null===(i=o.grid.sortTypes)||void 0===i?void 0:i.length)===o.grid.sortByColumns.length&&(s={cols:o.grid.sortByColumns,types:o.grid.sortTypes});let l=null,u=null;try{l=a.getRawData(),u=a.categories}catch(t){}const c=l&&u?a.isNumerical?t=>l[t]:t=>u[l[t]]:t=>a.get(t),h=t=>a.isNone(t)?null:c(t),f=a.name===e.activityColumn.name?r.columns.addNewFloat(o.name).init((t=>h(t))):r.columns.addNewVirtual(o.name,(t=>h(t)),a.type);for(const[t,e]of a.tags)f.setTag(t,e)}const a=r.plot.grid();a.props.showRowHeader=!1,a.root.style.maxWidth="100%",d.debounce(c.onSizeChanged(a.root),50).subscribe((t=>{var e;const n=a.root.parentElement;(null===(e=null==n?void 0:n.parentElement)||void 0===e?void 0:e.classList.contains("panel-content"))&&(a.root.style.height="calc(100% - 20px)",a.root.style.width="calc(100% - 20px)",a.root.style.position="absolute",a.root.style.right="10px",a.root.style.top="10px")})),(0,x.zz)(a);const l=c.box(a.root);l.style.marginLeft="0px",setTimeout((()=>{null!==s&&a.sort(s.cols,s.types);for(let t=1;t<e.gridColumns.length;t++){const n=e.gridColumns.byIndex(t);n.visible&&a.col(n.name)&&(a.col(n.name).width=n.width)}}),500);const u=(0,V.Ej)(e.activityColumn,r.filter,e.positionColumns,{isFiltered:!0}),h={isSelectionTable:!0,cachedWebLogoTooltip:()=>({bar:"",tooltip:null}),webLogoBounds:()=>({}),colorPalette:()=>e.colorPalette},f={x:0,y:0,monomerPosition:{},mpStats:u};return e.isAnalysis&&(0,I.FZ)(a,u,e.positionColumns,e.activityColumn,h,f),(null!==(o=t.columns.bySemTypeAll(d.SEMTYPE.MACROMOLECULE))&&void 0!==o?o:[]).forEach((t=>{r.col(t.name)&&(r.col(t.name).temp[F.j.notationProvider]=t.temp[F.j.notationProvider])})),l}(u.df,{positionColumns:G?u.positionColumns:R.positionColumns,columns:G?null!==(t=u.settings.columns)&&void 0!==t?t:{}:R.getAggregationColumns(),activityColumn:G?u.getScaledActivityColumn():R.getScaledActivityColumn(),gridColumns:u.analysisView.grid.columns,colorPalette:(0,f.SM)(u.df.getCol(G?u.settings.sequenceColumnName:R.sequenceColumnName),z.Z.getSeqHelper()),tableSelection:u.getCombinedSelection(),isAnalysis:null!==u.settings&&(G||B(u.settings.columns,R.getAggregationColumns()))})}catch(t){const e=c.divText("Error in Selection");return c.tooltip.bind(e,String(t)),e}}),!0),h}getScaledActivityColumn(t=!1){const e=this.df.col(_.$2.ACTIVITY);return t&&null!==e?d.DataFrame.fromColumns([e]).clone(this.df.filter).getCol(e.name):e}updateGrid(){this.joinDataFrames(),this.createScaledCol(),this.webLogoBounds={};const t={selectionCallback:(t,e)=>this.modifyWebLogoSelection(t,e),unhighlightCallback:()=>this.unhighlight(),colorPalette:()=>(0,f.SM)(this.df.getCol(this.settings.sequenceColumnName),z.Z.getSeqHelper()),webLogoBounds:()=>this.webLogoBounds,cachedWebLogoTooltip:()=>this.cachedWebLogoTooltip,highlightCallback:(t,e,n)=>{(0,x.dl)(t,e,n),this.isHighlighting=!0},isSelectionTable:!1,headerSelectedMonomers:()=>this.webLogoSelectedMonomers};if(null===this.monomerPositionStats||null===this.positionColumns)throw new Error("PeptidesError: Could not updage grid: monomerPositionStats or positionColumns are null");I.FZ(this.analysisView.grid,this.monomerPositionStats,this.positionColumns,this.getScaledActivityColumn(),t),this._layoutEventInitialized||(h.events.onViewLayoutApplied.subscribe((t=>{t.view.id===this.analysisView.id&&this.updateGrid()})),this._layoutEventInitialized=!0),this.setTooltips(),this.setBitsetCallback(),this.setGridProperties()}joinDataFrames(){const t=this.df.name,e=this.df.columns,n=(0,v.R)(this.df.getCol(this.settings.sequenceColumnName),z.Z.getSeqHelper()),i=n.columns.names();if(i.every((t=>e.contains(t))))i.forEach((t=>{this.df.col(t).setTag(_.gp.ANALYSIS_COL,"true"),this.df.col(t).setTag(_.gp.POSITION_COL,"true"),I.rI(this.df.col(t),this.alphabet)}));else for(const t of i){let i=this.df.col(t);const o=n.getCol(t);null!==i&&e.remove(t);const r=o.categories,s=o.getRawData();i=e.addNew(o.name,o.type).init((t=>r[s[t]])),i.setTag(_.gp.ANALYSIS_COL,"true"),i.setTag(_.gp.POSITION_COL,"true"),I.rI(i,this.alphabet)}this.df.name=t}createScaledCol(){const t=this.analysisView.grid,e=(0,x.Y1)(this.df.getCol(this.settings.activityColumnName),this.settings.activityScaling);this.df.columns.replace(_.$2.ACTIVITY,e),t.columns.setOrder([e.name])}unhighlight(){this.isHighlighting&&(this.df.rows.highlight(null),this.isHighlighting=!1)}setTooltips(){this.analysisView.grid.onCellTooltip(((t,e,n)=>{var i,o;return!(!t.isColHeader||(null===(i=t.tableColumn)||void 0===i?void 0:i.semType)!==_.uF.MONOMER)||!(!t.isTableCell||(null===(o=t.tableColumn)||void 0===o?void 0:o.semType)!==_.uF.MONOMER)}))}getCombinedSelection(){var t,e,n,i,o,r,s,a;const l=new m.A(this.df.rowCount,!1),u=(t,e)=>{for(const[n,i]of Object.entries(t))for(const t of i){const i=null==e?void 0:e[n];if(void 0===i)continue;const o=i[t];void 0!==o&&l.or(o.mask)}};u(this.webLogoSelection,this.monomerPositionStats);const c=this.findViewer($.SEQUENCE_VARIABILITY_MAP);u(null!==(t=null==c?void 0:c.invariantMapSelection)&&void 0!==t?t:{},null!==(e=null==c?void 0:c.monomerPositionStats)&&void 0!==e?e:null),((t,e)=>{var n,i;for(const[o,r]of Object.entries(t))for(const t of r){const r=null!==(i=null===(n=null==e?void 0:e.get(t))||void 0===n?void 0:n.get(o))&&void 0!==i?i:null;if(null!==r)for(const[t,e]of r.entries()){l.setTrue(t);for(const t of e)l.setTrue(t)}}})(null!==(n=null==c?void 0:c.mutationCliffsSelection)&&void 0!==n?n:{},null!==(i=null==c?void 0:c.mutationCliffs)&&void 0!==i?i:null);const h=this.findViewer($.MOST_POTENT_RESIDUES);u(null!==(o=null==h?void 0:h.invariantMapSelection)&&void 0!==o?o:{},null!==(r=null==h?void 0:h.monomerPositionStats)&&void 0!==r?r:null);const f=this.findViewer($.LOGO_SUMMARY_TABLE);for(const t of Object.keys(null!==(s=null==f?void 0:f.clusterSelection)&&void 0!==s?s:{}))for(const e of null!==(a=f.clusterSelection[t])&&void 0!==a?a:[]){const n=f.clusterStats[t][e];l.or(n.mask)}const p=d.BitSet.fromBytes(l.buffer.buffer,l.length);return this.df.filter.anyFalse?p.and(this.df.filter):p}setBitsetCallback(){if(this.isBitsetChangedInitialized)return;const t=this.df.selection,e=this.df.filter;let n=null;const i=()=>{try{null!=n&&(clearTimeout(n),n=null);const t=this.createAccordion();if(null===t)return;h.shell.o=t.root,n=setTimeout((()=>{h.shell.o!=t.root&&(h.shell.o=t.root)}),1500)}catch(t){console.error(t)}};t.onChanged.subscribe((()=>{if(this.controlFire)this.controlFire=!1;else try{this.isUserChangedSelection||t.copyFrom(this.getCombinedSelection(),!1)}catch(t){k._package.logger.debug("Peptides: Error on selection changed"),k._package.logger.debug(t)}finally{i()}})),e.onChanged.subscribe((()=>{var t,e;try{if(this.controlFire)return void(this.controlFire=!1);const n=this.findViewer($.LOGO_SUMMARY_TABLE);null!==n&&void 0!==n.model&&(n._logoSummaryTable=null!==(t=n.createLogoSummaryTable())&&void 0!==t?t:n._logoSummaryTable,n._viewerGrid=null!==(e=n.createLogoSummaryTableGrid())&&void 0!==e?e:n._viewerGrid,n.render())}catch(t){k._package.logger.debug("Peptides: Error on filter changed"),k._package.logger.debug(t)}finally{i()}})),this.isBitsetChangedInitialized=!0}fireBitsetChanged(t,e=!1){this.accordionSource=t,this.isBitsetChangedInitialized||this.setBitsetCallback(),this.isUserChangedSelection=!1,this.df.selection.fireChanged(),e&&this.df.filter.fireChanged(),this.controlFire=!0,this.df.selection.fireChanged(),e&&this.df.filter.fireChanged(),this.isUserChangedSelection=!0,this.webLogoSelectedMonomers=(0,x.qx)(this.df)}setGridProperties(t){var e,n,i,o;const r=this.analysisView.grid,s=r.props;s.allowColSelection=null!==(e=null==t?void 0:t.allowColSelection)&&void 0!==e&&e,s.allowEdit=null!==(n=null==t?void 0:t.allowEdit)&&void 0!==n&&n,s.showReadOnlyNotifications=null!==(i=null==t?void 0:t.showReadOnlyNotifications)&&void 0!==i&&i,s.showCurrentRowIndicator=null!==(o=null==t?void 0:t.showCurrentRowIndicator)&&void 0!==o&&o;const a=this.positionColumns;if(null===a)throw new Error("PeptidesError: Could not set grid properties: positionColumns are null");let l=10;const u=r.canvas.getContext("2d");if(null===u)throw new Error("PeptidesError: Could not set grid properties: canvas context is null");for(const t of a){const e=(0,f.zS)(t.categories.reduce(((t,e)=>t.length>e.length?t:e)),6),n=Math.ceil(u.measureText(e).width);l=Math.max(l,n)}const c=a.map((t=>t.name));for(let t=1;t<this.analysisView.grid.columns.length;++t){const e=this.analysisView.grid.columns.byIndex(t);if(null===e)throw new Error(`PeptidesError: Could not get analysis view: grid column with index '${t}' is null`);if(null===e.column)throw new Error(`PeptidesError: Could not get analysis view: grid column with index '${t}' has null column`);e.visible=c.includes(e.column.name)||e.column.name===_.$2.ACTIVITY}setTimeout((()=>{for(const t of a){const e=r.col(t.name);if(null===e)throw new Error(`PeptidesError: Could not set column width: grid column '${t.name}' is null`);e.width=l+15}}),100)}closeViewer(t){const e=this.findViewer(t);null==e||e.detach(),null==e||e.close()}findViewerNode(t){for(const e of this.analysisView.dockManager.rootNode.children)if(e.container.containerElement.innerHTML.includes(t))return e;return null}addDendrogram(){return K(this,void 0,void 0,(function*(){const t=d.TaskBarProgressIndicator.create("Calculating distance matrix...");try{const t=d.Func.find({package:"Dendrogram",name:"hierarchicalClustering"})[0];if(!t||4!==t.inputs.length)throw new Error("Correct dendrogram function is not found");yield t.apply({df:this.df,colNameList:[this.settings.sequenceColumnName],distance:"euclidean",linkage:"complete"})}catch(t){k._package.logger.error(t)}finally{t.close()}}))}init(t){if(!this.isInitialized){if(this.settings=t,this.isInitialized=!0,!this.isRibbonSet&&"1"!==this.df.getTag(_.gp.MULTIPLE_VIEWS)){const t=c.iconFA("wrench",(()=>(0,R.OH)(this)),"Peptides analysis settings");this.analysisView.setRibbonPanels([[t]],!1),this.isRibbonSet=!0,this.updateGrid()}this.subs.push(h.events.onAccordionConstructed.subscribe((t=>{if(!(h.shell.o instanceof d.SemanticValue||h.shell.o instanceof d.Column&&this.df.columns.toList().includes(h.shell.o)))return;const e=t.getPane("Actions"),n=E()(e.root).find(".d4-flex-col"),i=c.label("Calculate identity");i.classList.add("d4-link-action"),c.tooltip.bind(i,"Adds a column with fractions of matching monomers against sequence in the current row"),i.onclick=()=>{const t=this.df.getCol(this.settings.sequenceColumnName);w(this.df,t,t.get(this.df.currentRowIdx),g.IDENTITY,z.Z.getSeqHelper()).then((e=>e.setTag(_.gp.IDENTITY_TEMPLATE,t.get(this.df.currentRowIdx)))).catch((t=>k._package.logger.debug(t)))},n.append(c.span([i],"d4-markdown-row"));const o=c.label("Calculate similarity");o.classList.add("d4-link-action"),c.tooltip.bind(o,"Adds a column with sequence similarity scores against sequence in the current row"),o.onclick=()=>{const t=this.df.getCol(this.settings.sequenceColumnName);w(this.df,t,t.get(this.df.currentRowIdx),g.SIMILARITY,z.Z.getSeqHelper()).then((e=>e.setTag(_.gp.SIMILARITY_TEMPLATE,t.get(this.df.currentRowIdx)))).catch((t=>k._package.logger.debug(t)))},n.append(c.span([o],"d4-markdown-row"))}))),this.subs.push(h.events.onViewRemoved.subscribe((t=>{t.id===this.analysisView.id&&this.subs.forEach((t=>t.unsubscribe())),h.log.debug(`Peptides: view ${t.name} removed`)}))),this.subs.push(h.events.onTableRemoved.subscribe((t=>{t.id===this.df.id&&this.subs.forEach((t=>t.unsubscribe())),h.log.debug(`Peptides: table ${t.name} removed`)}))),this.subs.push(h.events.onProjectClosed.subscribe((t=>{t.id===h.shell.project.id&&this.subs.forEach((t=>t.unsubscribe())),h.log.debug(`Peptides: project ${t.name} closed`)}))),this.fireBitsetChanged(null,!0),this.analysisView.grid.invalidate()}}findViewer(t){return S()(this.analysisView.viewers).find((e=>e.type===t))||null}addLogoSummaryTable(t){return K(this,void 0,void 0,(function*(){null!=t||(t={sequenceColumnName:this.settings.sequenceColumnName,clustersColumnName:S()(this.df.columns.categorical).next().value,activityColumnName:this.settings.activityColumnName,activityScaling:this.settings.activityScaling});const e=yield this.df.plot.fromType($.LOGO_SUMMARY_TABLE,t);(0,x.Lv)()&&this.analysisView.addViewer(e),this.analysisView.dockManager.dock(e,d.DOCK_TYPE.RIGHT,null,$.LOGO_SUMMARY_TABLE),e.viewerGrid.invalidate()}))}addClusterMaxActivityViewer(t){return K(this,void 0,void 0,(function*(){var e,n,i,o,r,s,a,l,u;const c=null!==(o=null!==(n=null===(e=this._mclCols)||void 0===e?void 0:e.find((t=>t.toLowerCase().startsWith("cluster (mcl)"))))&&void 0!==n?n:null===(i=this.findViewer($.LOGO_SUMMARY_TABLE))||void 0===i?void 0:i.clustersColumnName)&&void 0!==o?o:null===(r=this._sequenceSpaceCols)||void 0===r?void 0:r.find((t=>t.toLowerCase().startsWith("cluster")));null!=t||(t={activityColumnName:this.settings.activityColumnName,clusterColumnName:null!=c?c:null===(s=S()(this.df.columns.categorical).next().value)||void 0===s?void 0:s.name,activityTarget:_.wf.HIGH,connectivityColumnName:null!==(l=null!==(a=this._mclCols.find((t=>t.toLowerCase().startsWith("connectivity"))))&&void 0!==a?a:this.df.columns.names().find((t=>{var e;return t.toLowerCase().includes("connectivity")&&(null===(e=this.df.col(t))||void 0===e?void 0:e.isNumerical)})))&&void 0!==l?l:"",clusterSizeThreshold:20,activityThreshold:1e3});const h=yield this.df.plot.fromType($.CLUSTER_MAX_ACTIVITY,t),f=null!==(u=this.findViewerNode($.LOGO_SUMMARY_TABLE))&&void 0!==u?u:null;this.analysisView.dockManager.dock(h,f?d.DOCK_TYPE.DOWN:d.DOCK_TYPE.RIGHT,f,$.CLUSTER_MAX_ACTIVITY)}))}addMonomerPosition(t){return K(this,void 0,void 0,(function*(){null!=t||(t={maxMutations:1,activityScaling:this.settings.activityScaling,activityColumnName:this.settings.activityColumnName,sequenceColumnName:this.settings.sequenceColumnName,minActivityDelta:0,activityTarget:_.wf.HIGH});const e=yield this.df.plot.fromType($.SEQUENCE_VARIABILITY_MAP,t);(0,x.Lv)()&&this.analysisView.addViewer(e);const n=this.findViewer($.MOST_POTENT_RESIDUES),i=this.analysisView.dockManager,[o,r,s]=null===n?[d.DOCK_TYPE.DOWN,null,void 0]:[d.DOCK_TYPE.LEFT,this.findViewerNode($.MOST_POTENT_RESIDUES),.7];i.dock(e,o,r,$.SEQUENCE_VARIABILITY_MAP,s)}))}addMostPotentResidues(t){return K(this,void 0,void 0,(function*(){null!=t||(t={activityScaling:this.settings.activityScaling,activityColumnName:this.settings.activityColumnName,sequenceColumnName:this.settings.sequenceColumnName,minActivityDelta:0,maxMutations:1,activityTarget:_.wf.HIGH});const e=yield this.df.plot.fromType($.MOST_POTENT_RESIDUES,t);(0,x.Lv)()&&this.analysisView.addViewer(e);const n=this.findViewer($.SEQUENCE_VARIABILITY_MAP),i=this.analysisView.dockManager,[o,r,s]=null===n?[d.DOCK_TYPE.DOWN,null,void 0]:[d.DOCK_TYPE.RIGHT,this.findViewerNode($.SEQUENCE_VARIABILITY_MAP),.3];i.dock(e,o,r,$.MOST_POTENT_RESIDUES,s)}))}createNewView(){const t=this.getVisibleSelection(),e=this.df.clone(t);for(const[t,n]of e.tags)e.setTag(t,t===_.gp.SETTINGS?n:"");e.name="Peptides Multiple Views",e.setTag(_.gp.MULTIPLE_VIEWS,"1");const n=h.shell.addTableView(e),i=this.findViewer($.LOGO_SUMMARY_TABLE);return null!=i&&n.addViewer($.LOGO_SUMMARY_TABLE,{[`sequence${_.To}`]:i.sequenceColumnName,[`activity${_.To}`]:i.activityColumnName,activityScaling:i.activityScaling,webLogoMode:i.webLogoMode,membersRatioThreshold:i.membersRatioThreshold,[`clusters${_.To}`]:i.clustersColumnName}),e.getTag(d.TAGS.ID)}clusterEmbeddings(){return K(this,void 0,void 0,(function*(){var t,e;if(!this._sequenceSpaceCols||0===this._sequenceSpaceCols.length)return void h.shell.warning("Embeddings columns are not initialized");const i=this._sequenceSpaceCols.filter((t=>t.toLowerCase().startsWith("embed_")));if(2!==i.length)return void h.shell.warning(`Found ${i.length} embeddings columns, expected 2`);const o=this._sequenceSpaceCols.filter((t=>t.toLowerCase().startsWith("cluster")));o.length>0&&this.df.columns.remove(o[0]);const r=this.df.getCol(i[0]).getRawData(),s=this.df.getCol(i[1]).getRawData(),a=null!==(t=this.settings.sequenceSpaceParams.epsilon)&&void 0!==t?t:.01,l=null!==(e=this.settings.sequenceSpaceParams.minPts)&&void 0!==e?e:4,u=yield function(t,e,i,o){return r=this,s=void 0,l=function*(){return new Promise((function(r,s){const a=new Worker(new URL(n.p+n.u(682),n.b));a.postMessage({embedX:t,embedY:e,minPts:o,epsilon:i}),a.onmessage=({data:{error:t,clusters:e}})=>{a.terminate(),t?s(t):r(e)}}))},new((a=void 0)||(a=Promise))((function(t,e){function n(t){try{o(l.next(t))}catch(t){e(t)}}function i(t){try{o(l.throw(t))}catch(t){e(t)}}function o(e){var o;e.done?t(e.value):(o=e.value,o instanceof a?o:new a((function(t){t(o)}))).then(n,i)}o((l=l.apply(r,s||[])).next())}));var r,s,a,l}(r,s,a,l),c=this.df.columns.getUnusedName("Cluster (DBSCAN)"),d=this.df.columns.addNewString(c);d.init((t=>u[t].toString())),null!==this._sequenceSpaceViewer&&(this._sequenceSpaceViewer.props.colorColumnName=d.name),this._sequenceSpaceCols=[i[0],i[1],d.name];const f=this.analysisView.grid.col(d.name);f&&(f.visible=!1)}))}addMCLClusters(){return K(this,void 0,void 0,(function*(){var t,e,n,i,o;if(null!==this._mclViewer)try{null===(t=this._mclViewer)||void 0===t||t.detach(),null===(e=this._mclViewer)||void 0===e||e.close()}catch(t){}0!==this._mclCols.length&&this._mclCols.forEach((t=>this.df.columns.remove(t))),this._mclCols=[];const r=this.df.getCol(this.settings.sequenceColumnName);null!==(n=(o=this.settings).mclSettings)&&void 0!==n||(o.mclSettings=new N.av);const s=this.settings.mclSettings;let a=0;const l=this.df.onColumnsAdded.subscribe((t=>{for(const e of t.columns)if((e.name.toLowerCase().startsWith("embed")||e.name.toLowerCase().startsWith("cluster")||e.name.toLowerCase().startsWith("connectivity"))&&e.name.toLowerCase().includes("mcl")){const t=this.analysisView.grid.col(e.name);if(null==t||this._mclCols.includes(e.name))continue;t.visible=!1,this._mclCols.push(e.name),a++}5===a&&l.unsubscribe()})),u=h.events.onViewerAdded.subscribe((t=>{try{const e=t.args.viewer;if(e.type===d.VIEWER.SCATTER_PLOT){if(this._sequenceSpaceViewer&&this.analysisView.dockManager.findNode(this._sequenceSpaceViewer.root)){const t=this.analysisView.dockManager.findNode(this._sequenceSpaceViewer.root);setTimeout((()=>{this.analysisView.dockManager.dock(e,d.DOCK_TYPE.FILL,t)}))}u.unsubscribe()}}catch(t){console.error(t)}})),c=JSON.stringify({cols:[r].map((t=>t.name)),metrics:[s.distanceF],weights:[1],aggregationMethod:j.MANHATTAN,preprocessingFuncs:["macromoleculePreprocessingFunction"],preprocessingFuncArgs:[{gapOpen:s.gapOpen,gapExtend:s.gapExtend,fingerprintType:s.fingerprintType}],threshold:s.threshold,maxIterations:s.maxIterations,useWebGPU:s.useWebGPU,inflate:s.inflation,minClusterSize:s.minClusterSize}),f=null!==(i=this.analysisView)&&void 0!==i?i:h.shell.getTableView(this.df.name);if(f){const t=d.Func.find({package:"EDA",name:"markovClusteringViewer"})[0];if(!t)throw new Error("Markov clustering function is not found");if(yield t.apply(),f.addViewer($.MCL,{mclProps:c}),yield d.delay(500),this._mclViewer=this.findViewer($.MCL),yield this._mclViewer.initPromise,this._mclViewer=this.findViewer($.MCL),!this._mclViewer||!this._mclViewer.isDetached)return null==u||u.unsubscribe(),void(null==l||l.unsubscribe());const e=this.findViewer($.LOGO_SUMMARY_TABLE);e&&(e._clusterStats=null,e._clusterSelection=null,e._viewerGrid=null,e._logoSummaryTable=null,e.render())}}))}addSequenceSpace(){return K(this,arguments,void 0,(function*(t={}){var e,n,i,o;if(null!==this._sequenceSpaceViewer)try{null===(e=this._sequenceSpaceViewer)||void 0===e||e.detach(),null===(n=this._sequenceSpaceViewer)||void 0===n||n.close()}catch(t){}0!==this._sequenceSpaceCols.length&&this._sequenceSpaceCols.forEach((t=>this.df.columns.remove(t))),this._sequenceSpaceCols=[];let r=this.df.getCol(this.settings.sequenceColumnName);const s=z.Z.getSeqHelper().getSeqHandler(r);if(s.isHelm())try{h.shell.warning("Column is in HELM notation. Sequences space will linearize sequences from position 0 prior to analysis");const t=s.convert(f.Hi.SEPARATOR,"/"),e=this.df.columns.getUnusedName(`Separator(${r.name})`);t.name=e,this.df.columns.add(t,!0),this.analysisView.grid.col(e).visible=!1,r=t}catch(t){return h.shell.error("Error on converting HELM notation to linear notation"),void h.shell.error(t)}const a=!t.clusterCol&&!!t.clusterEmbeddings,l=null!==(o=null===(i=this.settings)||void 0===i?void 0:i.sequenceSpaceParams)&&void 0!==o?o:new N.GI(a);l.clusterEmbeddings=a;const u={table:this.df,molecules:r,methodName:A.UMAP,similarityMetric:l.distanceF,plotEmbeddings:!0,options:{bypassLargeDataWarning:!0,dbScanEpsilon:l.epsilon,dbScanMinPts:l.minPts,randomSeed:"1",preprocessingFuncArgs:{gapOpen:l.gapOpen,gapExtend:l.gapExtend,fingerprintType:l.fingerprintType}},clusterEmbeddings:l.clusterEmbeddings};let c=0;const m=l.clusterEmbeddings?3:2,p=this.df.onColumnsAdded.subscribe((t=>{for(const e of t.columns)if(e.name.toLowerCase().startsWith("embed_")||l.clusterEmbeddings&&e.name.toLowerCase().startsWith("cluster")){const t=this.analysisView.grid.col(e.name);if(null==t||this._sequenceSpaceCols.includes(e.name))continue;t.visible=!1,this._sequenceSpaceCols.push(e.name),c++}c===m&&p.unsubscribe()})),g=h.events.onViewerAdded.subscribe((t=>{try{const e=t.args.viewer;if(e.type===d.VIEWER.SCATTER_PLOT){if(this._mclViewer&&this.analysisView.dockManager.findNode(this._mclViewer.root)){const t=this.analysisView.dockManager.findNode(this._mclViewer.root);setTimeout((()=>{this.analysisView.dockManager.dock(e,d.DOCK_TYPE.FILL,t)}))}g.unsubscribe()}}catch(t){console.error(t)}})),v=yield h.functions.call("Bio:sequenceSpaceTopMenu",u);g.unsubscribe(),v instanceof d.ScatterPlotViewer&&(l.clusterEmbeddings||t.clusterCol||(v.props.colorColumnName=this.getScaledActivityColumn().name),v.props.showXSelector=!1,v.props.showYSelector=!1,t.clusterCol&&(v.props.colorColumnName=t.clusterCol.name),this._sequenceSpaceViewer=v,v.onContextMenu.subscribe((t=>{try{t.item("Modify Sequence space parameters",(()=>{(0,R.OH)(this)}))}catch(t){}})))}))}}Z.modelName="peptidesModel"},3262:(t,e,n)=>{"use strict";n.r(e),n.d(e,{PackageFunctions:()=>mt,Peptides:()=>j,_package:()=>ct,clusterMaxActivity:()=>tt,getMonomerWorksInstance:()=>ht,getTreeHelperInstance:()=>dt,initPeptides:()=>Y,logoSummaryTable:()=>X,lstPiechartCellRenderer:()=>it,macromoleculeSarFastaDemo:()=>nt,manualAlignment:()=>et,monomerPosition:()=>K,mostPotentResidues:()=>Z,mutationCliffs:()=>Q,peptidesDialog:()=>W,peptidesPanel:()=>z,sequencePositionStatistics:()=>J,testInitFunctionPeptides:()=>$});var i=n(4328),o=n(7389),r=n(6082),s=n(440),a=n(7233),l=n.n(a),u=(n(4788),n(9499)),c=n(726),h=n(3541),d=n(5480);n(3981);class f{constructor(t){this.monomerLib=t}getCappedRotatedMonomer(t,e){const n=this.monomerLib.getMonomer(t,e);return n?n.molfile:null}}var m=n(4139),p=n(8608),g=n(2003),v=n(115),C=n(5072),y=n.n(C),w=n(7825),A=n.n(w),b=n(7659),S=n.n(b),T=n(5056),E=n.n(T),_=n(540),N=n.n(_),x=n(1113),M=n.n(x),I=n(6677),O={};O.styleTagTransform=M(),O.setAttributes=E(),O.insert=S().bind(null,"head"),O.domAPI=A(),O.insertStyleElement=N(),y()(I.A,O),I.A&&I.A.locals&&I.A.locals;var L;!function(t){let e,n;!function(t){t.vert=function(t){return o.divV(t.map((t=>o.render(t))),{classes:"u2-panel"})},t.horz=function(t){return o.divH(t.map((t=>o.render(t))),{classes:"u2-panel"})}}(e=t.panels||(t.panels={})),t.appHeader=function(t){const n=o.iconImage("",t.iconPath);l()(n).addClass("ui-app-header-icon").css("margin-right","20px"),t.iconSize&&(n.style.width=`${t.iconSize}px`,n.style.height=`${t.iconSize}px`);const i=e.horz([]);if(t.appTitle){i.classList.add("u2-app-header-with-name");const e=o.divV([o.divText(t.appTitle,"u2-app-header-app-name-div")],"u2-app-header-app-name-and-slogan-div");t.appSubTitle&&e.append(o.divText(t.appSubTitle));const r=o.div(n);i.append(o.divH([r,e]))}else i.append(n);const r=e.vert([o.markdown(t.description),t.learnMoreUrl?o.link("Learn more",t.learnMoreUrl,void 0,{style:{marginLeft:"15px"}}):null]);return r.classList.add("u2-app-header-description"),i.append(r),t.bottomLine&&i.classList.add("u2-app-header-bottom-line"),i},function(t){t.runAsync=function(t,e){return n=this,r=void 0,a=function*(){o.setUpdateIndicator(t,!0);try{return yield e()}catch(t){i.log.error(t)}finally{o.setUpdateIndicator(t,!1)}},new((s=void 0)||(s=Promise))((function(t,e){function i(t){try{l(a.next(t))}catch(t){e(t)}}function o(t){try{l(a.throw(t))}catch(t){e(t)}}function l(e){var n;e.done?t(e.value):(n=e.value,n instanceof s?n:new s((function(t){t(n)}))).then(i,o)}l((a=a.apply(n,r||[])).next())}));var n,r,s,a}}(n=t.tools||(t.tools={}))}(L||(L={}));var P=n(144),R=n.n(P);const k=rxjs.operators;class V extends r.JsViewer{get scViewer(){return this._scViewer||(this._scViewer=this.createSCViewer()),this._scViewer}constructor(){super(),this._titleHost=o.divText(u.q.CLUSTER_MAX_ACTIVITY,{id:"pep-viewer-title",style:{marginRight:"auto"}}),this._selsectIcon=o.div(),this.activityTarget=m.wf.HIGH,this.viewerError="",this.renderTimeout=null,this.renderDebounceTime=500,this.scFilterQuery=`\${${V.maxActivityInClusterColName}} == 1`,this.selectionSubscription=null,this.linesDrawSubscription=null,this.clusterColumnName=this.column("cluster",{nullable:!1}),this.activityColumnName=this.column("activity",{nullable:!1}),this.colorColumnName=this.column("color",{nullable:!0,defaultValue:null}),this.activityTarget=this.string("activityTarget",m.wf.HIGH,{choices:[m.wf.HIGH,m.wf.LOW]}),this.clusterSizeThreshold=this.int("clusterSizeThreshold",20),this.activityThreshold=this.float("activityThreshold",1e3,{step:.1}),this.connectivityColumnName=this.column("connectivity",{nullable:!0})}get model(){return u.i.getInstance(this.dataFrame)}createSCViewer(){var t;const e={showXAxis:!0,showYAxis:!0,showXSelector:!1,showYSelector:!1,showColorSelector:!1,xAxisType:r.AxisType.logarithmic,yAxisType:r.AxisType.logarithmic,invertYAxis:this.activityTarget===m.wf.LOW,xColumnName:V.clusterSizeColName,markerType:"circle",markerDefaultSize:10,showSizeSelector:!1};if(null==this.clusterColumnName||null==this.activityColumnName||!this.dataFrame.columns.contains(this.clusterColumnName)||!this.dataFrame.columns.contains(this.activityColumnName))return this.viewerError="Please set valid cluster and activity columns",null;const n=this.dataFrame.columns.byName(this.activityColumnName),i=this.dataFrame.columns.byName(this.clusterColumnName),s=null!=this.connectivityColumnName?this.dataFrame.columns.byName(this.connectivityColumnName):null;if(![r.COLUMN_TYPE.FLOAT,r.COLUMN_TYPE.INT,r.COLUMN_TYPE.BIG_INT,r.COLUMN_TYPE.QNUM].includes(n.type))return this.viewerError="Activity column should be numeric",null;const a=this.dataFrame.columns.getOrCreate(V.clusterSizeColName,r.TYPE.INT),l={};for(let e=0;e<this.dataFrame.rowCount;e++){const n=i.get(e);null!=n&&"-1"!=n&&(l[n]=(null!==(t=l[n])&&void 0!==t?t:0)+1)}a.init((t=>{var e;return i.isNone(t)?null:null!==(e=l[i.get(t)])&&void 0!==e?e:null})),n.stats.min<=0&&(e.yAxisType=r.AxisType.linear);const u={},c={};for(let t=0;t<this.dataFrame.rowCount;t++){const e=i.get(t);if(null==e||i.isNone(t)||n.isNone(t))continue;const o=n.get(t),r=u[e];if((null==r||null==r||o>n.get(r)&&this.activityTarget===m.wf.HIGH||o<n.get(r)&&this.activityTarget===m.wf.LOW)&&(u[e]=t),s){const n=s.get(t),i=c[e];(null==i||null==i||n>s.get(i))&&(c[e]=t)}}const h=this.dataFrame.columns.getOrCreate(V.maxActivityInClusterColName,r.COLUMN_TYPE.INT);h.init((t=>i.isNone(t)?0:t===u[i.get(t)]?1:0)),this.dataFrame.columns.getOrCreate(V.maxConnectivityInClusterColName,r.COLUMN_TYPE.INT).init((t=>i.isNone(t)?0:t===c[i.get(t)]?1:0)),this.dataFrame.columns.getOrCreate(V.synSelectionColName,r.TYPE.STRING).init((t=>{if(i.isNone(t))return null;let e=null;return t===u[i.get(t)]&&(e=V.maxActivityLabel),s&&t===c[i.get(t)]&&(e=e?`${e}, ${V.maxConnectivityLabel}`:V.maxConnectivityLabel),e})),e.xColumnName=V.clusterSizeColName,e.yColumnName=this.activityColumnName,e.filter=this.scFilterQuery,this.viewerError="";const d=r.Viewer.scatterPlot(this.dataFrame,e);this.selectionSubscription&&this.selectionSubscription.unsubscribe(),this.selectionSubscription=d.onDataEvent.pipe((0,k.filter)((t=>"d4-select"==t.type))).subscribe((t=>{var e,n;const o=null!==(n=null===(e=t.bitset)||void 0===e?void 0:e.getSelectedIndexes())&&void 0!==n?n:[],s=this.dataFrame.selection,a=r.BitSet.create(this.dataFrame.rowCount,(t=>1==h.get(t)));a.and(s);for(let t=0;t<o.length;t++){const e=o[t],n=i.get(e);i.isNone(e)||(a.set(e,!0),null!=c[n]&&a.set(c[n],!0))}a.fireChanged();const l=a.getSelectedIndexes();for(const t of l){const e=i.get(t);null!=e&&null!=c[e]&&a.set(c[e],!0)}setTimeout((()=>{this.dataFrame.selection.copyFrom(a,!0),setTimeout((()=>{this.model&&this.model.createAccordion()}),200)}),200)}));const f=()=>{const t=r.BitSet.create(this.dataFrame.rowCount);Object.entries(u).forEach((([e,i])=>{var o;if(null==e||null==i)return;const r=parseInt(e),s=n.get(i),a=null!==(o=l[r])&&void 0!==o?o:l[e];s<this.activityThreshold&&a<this.clusterSizeThreshold||(t.set(i,!0,!1),null!=c[r]&&t.set(c[r],!0,!1))})),t.fireChanged(),this.dataFrame.selection.copyFrom(t,!0)};return this._selsectIcon=o.iconSvg("select-all",(()=>{f()}),"Select 3 Active quadrants"),this._selsectIcon.style.cursor="pointer",this._selsectIcon.style.marginRight="5px",f(),this.linesDrawSubscription&&this.linesDrawSubscription.unsubscribe(),this.linesDrawSubscription=d.onBeforeDrawScene.subscribe((()=>{const t=d.getInfo().canvas.getContext("2d"),e=d.viewport,n=d.worldToScreen(e.x,this.activityThreshold),i=d.worldToScreen(this.clusterSizeThreshold,e.y),o=d.worldToScreen(e.x+e.width,this.activityThreshold),r=d.worldToScreen(this.clusterSizeThreshold,e.y+e.height);t.beginPath(),t.strokeStyle="rgb(0,0,0)",t.lineWidth=1,t.moveTo(n.x,n.y),t.lineTo(o.x,o.y),t.moveTo(i.x,i.y),t.lineTo(r.x,r.y),t.stroke(),t.closePath()})),d}onTableAttached(){var t,e,n,i,o,r,s,a,l,u,c,h;super.onTableAttached();const d=null!==(e=null===(t=this.dataFrame)||void 0===t?void 0:t.col(m.$2.ACTIVITY))&&void 0!==e?e:null===(i=R()(null===(n=this.dataFrame)||void 0===n?void 0:n.columns.numerical).next())||void 0===i?void 0:i.value;null!=d&&(null===(o=this.getProperty(`activity${m.To}`))||void 0===o||o.set(this,d.name));const f=null===(s=R()(null===(r=this.dataFrame)||void 0===r?void 0:r.columns.categorical).next())||void 0===s?void 0:s.value;null!=f&&(null===(a=this.getProperty(`cluster${m.To}`))||void 0===a||a.set(this,f.name));const p=null===(u=R()(null===(l=this.dataFrame)||void 0===l?void 0:l.columns.numerical).next())||void 0===u?void 0:u.value;null!=p&&(null===(c=this.getProperty(`connectivity${m.To}`))||void 0===c||c.set(this,p.name)),this.render(),null===(h=this.dataFrame)||void 0===h||h.onDataChanged.subscribe((()=>{this.render()}))}render(){this.renderTimeout&&clearTimeout(this.renderTimeout),this.renderTimeout=setTimeout((()=>{var t,e;if(!this.dataFrame)return;l()(this.root).empty();const n=this.scViewer;if(null==n)return void this.root.appendChild(o.divText(null!==(t=this.viewerError)&&void 0!==t?t:"Error creating scatter plot"));const i=o.div("Cluster Size",{style:{alignSelf:"center",color:"var(--grey-6)",marginBottom:"5px"}}),r=o.div(this.activityTarget===m.wf.HIGH?"Maximum Activity":"Minimum Activity",{style:{color:"var(--grey-6)",alignSelf:"center",textOrientation:"mixed",writingMode:"tb",transform:"rotate(180deg)",marginLeft:"5px"}});n.props.colorColumnName=null!==(e=this.colorColumnName)&&void 0!==e?e:null,this.root.appendChild(o.divH([r,o.divV([o.divH([this._titleHost,this._selsectIcon],{style:{alignSelf:"center",lineHeight:"normal",width:"100%"}}),n.root,i],{style:{flexGrow:"1"}})])),n.root.style.width="100%",setTimeout((()=>{n.props.filter=this.scFilterQuery,n.invalidateCanvas()}),100)}),this.renderDebounceTime)}onPropertyChanged(t){super.onPropertyChanged(t),(null==t?void 0:t.name)!==`color${m.To}`&&(this._scViewer=null),this.render()}}V.clusterSizeColName="~cluster.size",V.maxActivityInClusterColName="~max.activity.for.cluster",V.maxConnectivityInClusterColName="~max.connectivity.for.cluster",V.synSelectionColName="Syn Selection",V.maxActivityLabel="Max Activity",V.maxConnectivityLabel="Max Connectivity";var F=n(3163);class D extends r.JsViewer{constructor(){super(),this.showPositionInfo=!0,this.positions=this.string("positions","1",{description:"Comma-separated sequence positions (1-based) to analyze"}),this.sequenceColumnName=this.column("sequence",{semType:r.SEMTYPE.MACROMOLECULE,nullable:!1}),this.valueColumnName=this.column("value",{columnTypeFilter:"numerical",nullable:!1}),this.showPositionInfo=this.bool("showPositionInfo",!0,{nullable:!1,defaultValue:!0,description:"Show position selector in the viewer header"}),this.subs.push(i.events.onContextMenu.subscribe((t=>{var e;t.causedBy&&t.causedBy.target&&(null===(e=this._boxPlotViewer)||void 0===e?void 0:e.root.contains(t.causedBy.target))&&(t.causedBy.preventDefault(),t.causedBy.stopPropagation(),t.causedBy.stopImmediatePropagation())})))}getPositionFromColumn(){var t;const e=this.dataFrame.col(this.sequenceColumnName);if(null==e)return 1;const n=null!==(t=e.getTag(g.gp.selectedPosition))&&void 0!==t?t:"1",i=parseInt(n);return Number.isNaN(i)?1:Math.max(1,i)}parsePositions(){if(!this.positions)return[1];const t=this.positions.split(",").map((t=>parseInt(t.trim()))).filter((t=>!Number.isNaN(t)&&t>=1));return[...new Set(t)].sort(((t,e)=>t-e))}_setPositions(t){const e=[...new Set(t)].sort(((t,e)=>t-e));this.getProperty("positions").set(this,e.join(", "))}onTableAttached(){if(super.onTableAttached(),null==this.dataFrame.columns.bySemType(r.SEMTYPE.MACROMOLECULE))throw i.shell.error("No sequence column found"),new Error("No sequence column found");const t=this.dataFrame.columns.getUnusedName("~sequence_position_monomers");this._positionColumn=this.dataFrame.columns.addNewString(t),this._positionColumn.semType="Monomer",this._positionColumn.setTag("cell.renderer","Monomer"),this.getProperty("sequenceColumnName").set(this,this.dataFrame.columns.bySemType(r.SEMTYPE.MACROMOLECULE).name),this.getProperty("valueColumnName").set(this,R()(this.dataFrame.columns.numerical).next().value.name),this.getProperty("positions").set(this,String(this.getPositionFromColumn())),this.subs.push(r.debounce(this.dataFrame.onMetadataChanged,200).subscribe((t=>{const e=this.getPositionFromColumn();this.parsePositions().includes(e)||this._setPositions([e])})))}render(){var t;const e=this.parsePositions();if(!(null!=this.dataFrame&&this.sequenceColumnName&&e.length&&this._positionColumn&&this.valueColumnName))return;l()(this.root).empty(),null===(t=this._boxPlotViewer)||void 0===t||t.detach();const n=c.Z.getSeqHelper(),i=this.dataFrame.col(this.sequenceColumnName),o=n.getSeqHandler(i),s=o.maxLength,a=e.map((t=>o.getMonomersAtPosition(t-1,!0)));if(this._positionColumn.init((t=>a.map((e=>e[t])).join(g.ot))),this._boxPlotViewer=this.dataFrame.plot.box({categoryColumnNames:[this._positionColumn.name],plotStyle:"violin",valueColumnName:this.valueColumnName,colorColumnName:this._positionColumn.name,showColorSelector:!1,showSizeSelector:!1,showCategorySelector:!1,legendVisibility:r.VisibilityMode.Never,markerColorColumnName:this._positionColumn.name,title:"Sequence Position Statistics",autoLayout:!1,labelOrientation:"Vert"}),this.showPositionInfo){const t=this._renderPositionSelector(e,s);this.root.appendChild(t)}this._boxPlotViewer.props.statistics=["min","max","avg","med","count"],this._boxPlotViewer.root.style.width="100%",this._boxPlotViewer.root.style.height="100%",this.root.appendChild(this._boxPlotViewer.root),this._boxPlotViewer.sub(this._boxPlotViewer.onPropertyValueChanged.subscribe((t=>{var e,n,i,o;if((null===(n=null===(e=this._boxPlotViewer)||void 0===e?void 0:e.props)||void 0===n?void 0:n.valueColumnName)&&(null===(o=null===(i=this._boxPlotViewer)||void 0===i?void 0:i.props)||void 0===o?void 0:o.valueColumnName)!==this.valueColumnName){const t=this._boxPlotViewer.props.valueColumnName;setTimeout((()=>this.getProperty("valueColumnName").set(this,t)),10)}})))}_renderPositionSelector(t,e){const n=o.divH([],{style:{alignItems:"center",justifyContent:"center",gap:"4px",flexWrap:"wrap",padding:"4px 8px",width:"100%"}}),i=o.label(`${this.sequenceColumnName}:`);i.style.fontWeight="bold",i.style.marginRight="4px",n.appendChild(i);for(const i of t)n.appendChild(this._createChip(i,t,e));return n.appendChild(this._createAddButton(n,t,e)),n}_createChip(t,e,n){const i=1===e.length,r=document.createElement("span");r.textContent=String(t),r.style.marginRight="3px";const s=i?o.iconFA("pencil",(()=>this._showInlineEdit(a,t,n)),"Edit position"):o.iconFA("times",(()=>this._setPositions(e.filter((e=>e!==t)))),"Remove position");s.style.cursor="pointer",s.style.fontSize="10px",s.style.opacity="0.6";const a=o.divH([r,s],{style:{display:"inline-flex",alignItems:"center",background:"#f0f0f0",borderRadius:"12px",padding:"2px 8px",fontSize:"12px",cursor:"default",border:"1px solid #d0d0d0"}});return a}_showInlineEdit(t,e,n){var i;const o=document.createElement("input");o.type="number",o.min="1",o.max=String(n),o.value=String(e),o.style.cssText="width:45px;height:22px;font-size:12px;text-align:center;border-radius:12px;border:1px solid #aaa;outline:none;padding:0 4px;";let r=!1;const s=()=>{if(r)return;r=!0;const i=parseInt(o.value),s=this.parsePositions();!Number.isNaN(i)&&i>=1&&i<=n&&i!==e?this._setPositions(s.map((t=>t===e?i:t))):o.replaceWith(t)};o.addEventListener("keydown",(e=>{var n;"Enter"===e.key&&s(),"Escape"===e.key&&(r=!0,null===(n=t.parentElement)||void 0===n||n.replaceChild(t,o))})),o.addEventListener("blur",s),null===(i=t.parentElement)||void 0===i||i.replaceChild(o,t),o.focus(),o.select()}_createAddButton(t,e,n){const i=o.iconFA("plus-circle",(()=>{if(t.querySelector(".position-add-input"))return;const o=document.createElement("input");o.type="number",o.min="1",o.max=String(n),o.className="position-add-input",o.style.cssText="width:45px;height:22px;font-size:12px;text-align:center;border-radius:12px;border:1px solid #aaa;outline:none;padding:0 4px;";let r=!1;const s=()=>{if(r)return;r=!0;const t=parseInt(o.value);!Number.isNaN(t)&&t>=1&&t<=n&&!e.includes(t)?this._setPositions([...e,t]):o.remove()};o.addEventListener("keydown",(t=>{"Enter"===t.key&&s(),"Escape"===t.key&&(r=!0,o.remove())})),o.addEventListener("blur",s),t.insertBefore(o,i),o.focus()}),"Add position");return i.style.cursor="pointer",i.style.fontSize="14px",i.style.color="#2083d5",i}onPropertyChanged(t){null!=this.dataFrame&&this.sequenceColumnName&&this.render()}}var G=n(7471),U=function(t,e,n,i){return new(n||(n=Promise))((function(o,r){function s(t){try{l(i.next(t))}catch(t){r(t)}}function a(t){try{l(i.throw(t))}catch(t){r(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(s,a)}l((i=i.apply(t,e||[])).next())}))};class q extends r.JsViewer{constructor(){super(),this.position=1,this.currentRowMutationsOnly=!1,this.yAxisType="Linear",this._mutationCliffsData=null,this._dfSubs=[],this._positionColumns=null,this._innerDf=null,this._lineChart=null,this._debounceTimer=null,this.sequenceColumnName=this.column("sequence",{semType:r.SEMTYPE.MACROMOLECULE,nullable:!1}),this.seriesColumnName=this.column("series",{columnTypeFilter:"categorical",nullable:!1}),this.activityColumnName=this.column("activity",{columnTypeFilter:"numerical",nullable:!1}),this.position=this.int("position",1,{nullable:!1,showSlider:!1,min:1,max:100,showPlusMinus:!0,description:"Position in the sequence to analyze (1 Based).",category:"Data"}),this.yAxisType=this.string("yAxisType","Linear",{choices:["Linear","Logarithmic"],description:"Y-Axis scale type.",nullable:!1,category:"Data"}),this.currentRowMutationsOnly=this.bool("currentRowMutationsOnly",!1,{nullable:!1,defaultValue:!1,description:"When enabled, the viewer will show mutations related to the peptide in current row in the dataframe and selected position.",category:"Data"}),this.root.classList.add("peptides-viewer-show-title")}onTableAttached(){var t,e;super.onTableAttached();const n=this.dataFrame.columns.bySemType(r.SEMTYPE.MACROMOLECULE);n&&this.getProperty("sequenceColumnName").set(this,n.name),this.getProperty("activityColumnName").set(this,R()(this.dataFrame.columns.numerical).next().value.name);const o=null===(e=null===(t=R()(this.dataFrame.columns.categorical))||void 0===t?void 0:t.filter((t=>{var e;return t.name!==this.sequenceColumnName&&(null===(e=t.name)||void 0===e?void 0:e.toLowerCase().includes("series"))})).next())||void 0===e?void 0:e.value;o&&this.getProperty("seriesColumnName").set(this,o.name),this.subs.push(r.debounce(this.dataFrame.onFilterChanged,200).subscribe((()=>{this.clearCache(),this.debouncedRender()}))),this.debouncedRender(),this.subs.push(i.events.onContextMenu.subscribe((t=>{var e;t.causedBy&&t.causedBy.target&&(null===(e=this._lineChart)||void 0===e?void 0:e.root.contains(t.causedBy.target))&&(t.causedBy.preventDefault(),t.causedBy.stopPropagation(),t.causedBy.stopImmediatePropagation())})))}get mutationCliffsData(){if(this._mutationCliffsData)return this._mutationCliffsData;if(!this.activityColumnName||!this.sequenceColumnName||!this.position)throw new Error("Activity column or Sequence column is not set, or position is invalid");return this._mutationCliffsData=new Promise(((t,e)=>U(this,void 0,void 0,(function*(){try{const e=this.dataFrame.col(this.activityColumnName).getRawData(),n=this.positionColumns,i=n[this.position-1].toList(),o=n.map(p.eY),r=yield(new G.a).calc(e,o,{maxMutations:1,minActivityDelta:0,filter:this.dataFrame.filter.anyFalse?new Uint32Array(this.dataFrame.filter.getBuffer().buffer):void 0,singlePosition:{position:this.position-1}});t({cliffs:r,monomers:i})}catch(t){e(t)}})))),this._mutationCliffsData}calculateDf(){return U(this,void 0,void 0,(function*(){if(!(this.dataFrame&&this.activityColumnName&&this.sequenceColumnName&&this.position))throw new Error("Activity column or Sequence column is not set, or position is invalid");const t=yield this.mutationCliffsData,e=new Set;t.cliffs.forEach((t=>{t.forEach((t=>{Array.from(t.entries()).forEach((([t,n])=>{const i=Number(t);this.currentRowMutationsOnly&&this.dataFrame.currentRowIdx!==i||(e.add(i),n.forEach((t=>e.add(Number(t)))))}))}))}));const n=Array.from(e.values()).sort(((t,e)=>t-e)),i=new Map;n.forEach(((t,e)=>{i.set(t,e)}));const o=n.map((e=>t.monomers[e])),s=this.dataFrame.col(this.activityColumnName).getRawData(),a=n.map((t=>s[t])),l=[r.Column.fromList("string",`Position ${this.position}`,o),r.Column.fromList("double",this.activityColumnName,a)];if(this.seriesColumnName){const t=this.dataFrame.col(this.seriesColumnName).getRawData(),e=this.dataFrame.col(this.seriesColumnName).categories,i=n.map((n=>e[t[n]])),o=r.Column.fromList("string",this.seriesColumnName,i);l.push(o)}const u=r.DataFrame.fromColumns(l);Array.from(this.dataFrame.columns.numerical).filter((t=>t.name!==this.activityColumnName&&t.name!==this.seriesColumnName)).forEach((t=>{u.columns.addNew(t.name,t.type)})),this._dfSubs.push(u.onMouseOverRowChanged.subscribe((t=>{if(u.mouseOverRowIdx>=0){const t=n[u.mouseOverRowIdx];this.dataFrame.mouseOverRowIdx=t}}))),this._dfSubs.push(this.dataFrame.onMouseOverRowChanged.subscribe((t=>{if(this.dataFrame.mouseOverRowIdx>=0){const t=i.get(this.dataFrame.mouseOverRowIdx);u.mouseOverRowIdx=null!=t?t:-1}})));let c=!1;this._dfSubs.push(u.onCurrentRowChanged.subscribe((t=>{if(u.currentRowIdx>=0){c=!0;const t=n[u.currentRowIdx];this.dataFrame.currentRowIdx=t}}))),this.currentRowMutationsOnly&&this._dfSubs.push(this.dataFrame.onCurrentRowChanged.subscribe((t=>{c?c=!1:(this.clearCache(!1),this.debouncedRender())})));let h=!1,d=!1;return this._dfSubs.push(r.debounce(u.onSelectionChanged,100).subscribe((t=>{const e=u.selection;if(h)h=!1;else if(d=!0,this.dataFrame.selection.setAll(!1,!1),e.anyTrue){for(let t=-1;-1!==(t=e.findNext(t,!0));){const e=n[t];this.dataFrame.selection.set(e,!0,!1)}this.dataFrame.selection.fireChanged()}else this.dataFrame.selection.fireChanged()}))),this._dfSubs.push(r.debounce(this.dataFrame.onSelectionChanged,100).subscribe((t=>{const e=this.dataFrame.selection;if(d)d=!1;else if(h=!0,u.selection.setAll(!1,!1),e.anyTrue){for(let t=-1;-1!==(t=e.findNext(t,!0));){const e=i.get(t);null!=e&&u.selection.set(e,!0,!1)}u.selection.fireChanged()}else u.selection.fireChanged()}))),u}))}get positionColumns(){if(this._positionColumns)return this._positionColumns;if(!this.dataFrame)return[];const t=u.i.getInstance(this.dataFrame),e=null==t?void 0:t.positionColumns;if(e&&e.length>0)return this._positionColumns=e,this._positionColumns;const n=this.dataFrame.col(this.sequenceColumnName),i=c.Z.getSeqHelper().getSeqHandler(n),o=i.maxLength,s=[];for(let t=0;t<o;t++){const e=i.getMonomersAtPosition(t,!0),n=r.Column.fromList("string",`Position ${t+1}`,e);s.push(n)}return this._positionColumns=s,this._positionColumns}get innerDf(){return this._innerDf?Promise.resolve(this._innerDf):(this._innerDf=this.calculateDf(),this._innerDf)}render(){return U(this,void 0,void 0,(function*(){if(l()(this.root).empty(),!(this.dataFrame&&this.activityColumnName&&this.sequenceColumnName&&this.position))return o.setUpdateIndicator(this.root,!1),void this.root.appendChild(B("Please set Activity column, Sequence column and Position properties."));if(this._lineChart){try{this._lineChart.detach()}catch(t){console.error("Error detaching previous line chart:",t)}this._lineChart=null}o.setUpdateIndicator(this.root,!0),this.root.style.display="flex",this.root.style.flexDirection="column";const t=yield this.innerDf;o.setUpdateIndicator(this.root,!1),0===t.rowCount?this.currentRowMutationsOnly?this.dataFrame.currentRowIdx>=0?this.root.appendChild(B("No mutations cliffs found for the current peptide at the selected position.")):this.root.appendChild(B("Please select a row in the main table to see mutation cliffs for the corresponding peptide at the selected position.")):this.root.appendChild(B("No mutation cliffs found for the selected position.")):(this._lineChart=t.plot.line({xColumnName:`Position ${this.position}`,yColumnNames:[this.activityColumnName],splitColumnNames:this.seriesColumnName?[this.seriesColumnName]:[],legendVisibility:this.seriesColumnName?"Always":"Never",legendPosition:"Right",showXSelector:!1,showYSelector:!0,showSplitSelector:!1,packCategories:!1,xAxisLabelOrientation:"Auto",axisFont:'normal normal 14px "Roboto"',controlsFont:'normal normal 14px "Roboto"'}),this._lineChart.sub(this._lineChart.onPropertyValueChanged.subscribe((t=>{var e,n,i,o,r,s,a,l;if((null===(n=null===(e=this._lineChart)||void 0===e?void 0:e.props)||void 0===n?void 0:n.yColumnNames)&&(null===(r=null===(o=null===(i=this._lineChart)||void 0===i?void 0:i.props)||void 0===o?void 0:o.yColumnNames)||void 0===r?void 0:r[0])!==this.activityColumnName){const t=null===(l=null===(a=null===(s=this._lineChart)||void 0===s?void 0:s.props)||void 0===a?void 0:a.yColumnNames)||void 0===l?void 0:l[0];setTimeout((()=>this.getProperty("activityColumnName").set(this,t)),1)}}))),this.root.appendChild(this._lineChart.root));const e=this.positionColumns.length+1,n=new Array(e-1).fill(0).map(((t,e)=>e+1)).map((t=>t.toString())),i=o.input.choice("Position",{value:this.position.toString(),items:n,nullable:!1,onValueChanged:t=>{if(!t)return;const e=parseInt(t);this.getProperty("position").set(this,e)}});if(i.input.style.width="40px",this.root.appendChild(o.divH([i.root],{style:{justifyContent:"center",marginTop:"4px",width:"100%",font:'normal normal 14px "Roboto"'}})),t.rowCount>0){const t=o.input.column("Series",{table:this.dataFrame,filter:t=>t.isCategorical&&t.name!==this.sequenceColumnName,tooltipText:"Select column for series splitting.",onValueChanged:t=>{const e=t?t.name:void 0;this.getProperty("seriesColumnName").set(this,e)},value:this.seriesColumnName?this.dataFrame.col(this.seriesColumnName):void 0});this.root.prepend(o.divH([t.root],{style:{justifyContent:"flex-end",paddingBottom:"4px",padding:"8px",width:"100%",font:'normal normal 14px "Roboto"'}}))}}))}debouncedRender(){o.setUpdateIndicator(this.root,!0),this._debounceTimer&&clearTimeout(this._debounceTimer),this._debounceTimer=setTimeout((()=>this.render()),300)}clearCache(t=!0){t&&(this._mutationCliffsData=null),this._innerDf=null,this._dfSubs.forEach((t=>t.unsubscribe())),this._dfSubs=[]}detach(){super.detach(),this._dfSubs.forEach((t=>t.unsubscribe())),this._dfSubs=[],clearTimeout(this._debounceTimer)}onPropertyChanged(t){if(super.onPropertyChanged(t),"activityColumnName"===(null==t?void 0:t.name)||"sequenceColumnName"===(null==t?void 0:t.name)||"position"===(null==t?void 0:t.name)||"seriesColumnName"===(null==t?void 0:t.name)){const e="seriesColumnName"===(null==t?void 0:t.name)||"activityColumnName"===(null==t?void 0:t.name);this.clearCache(!e),"sequenceColumnName"===(null==t?void 0:t.name)&&(this._positionColumns=null),this.debouncedRender()}else"yAxisType"===(null==t?void 0:t.name)?this._lineChart&&(this._lineChart.props.yAxisType=this.yAxisType.toLowerCase()):"currentRowMutationsOnly"===(null==t?void 0:t.name)&&(this.clearCache(!1),this.debouncedRender())}}function B(t){const e=o.divText(t);return e.style.fontSize="14px",e.style.marginTop="10px",e.style.textAlign="center",e}var H=function(t,e,n,i){return new(n||(n=Promise))((function(o,r){function s(t){try{l(i.next(t))}catch(t){r(t)}}function a(t){try{l(i.throw(t))}catch(t){r(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(s,a)}l((i=i.apply(t,e||[])).next())}))};function Y(){return H(this,void 0,void 0,(function*(){yield mt.initPeptides()}))}function j(){return mt.Peptides()}function W(){return H(this,void 0,void 0,(function*(){return yield mt.peptidesDialog()}))}function $(t){return H(this,void 0,void 0,(function*(){yield mt.testInitFunctionPeptides(t)}))}function z(t){return H(this,void 0,void 0,(function*(){return yield mt.peptidesPanel(t)}))}function K(){return mt.monomerPosition()}function Z(){return mt.mostPotentResidues()}function Q(){return mt.mutationCliffs()}function X(){return mt.logoSummaryTable()}function J(){return mt.sequencePositionStatistics()}function tt(){return mt.clusterMaxActivity()}function et(t){return mt.manualAlignment(t)}function nt(){return H(this,void 0,void 0,(function*(){yield mt.macromoleculeSarFastaDemo()}))}function it(){return mt.lstPiechartCellRenderer()}var ot=function(t,e,n,i){var o,r=arguments.length,s=r<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,i);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(r<3?o(s):r>3?o(e,n,s):o(e,n))||s);return r>3&&s&&Object.defineProperty(e,n,s),s},rt=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},st=function(t,e){return function(n,i){e(n,i,t)}},at=function(t,e,n,i){return new(n||(n=Promise))((function(o,r){function s(t){try{l(i.next(t))}catch(t){r(t)}}function a(t){try{l(i.throw(t))}catch(t){r(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(s,a)}l((i=i.apply(t,e||[])).next())}))};let lt,ut=null;const ct=new r.Package;function ht(){return ut}function dt(){return lt}function ft(t){return at(this,void 0,void 0,(function*(){const e=r.TaskBarProgressIndicator.create("Loading Peptides"),n=ct.webRoot+"files/"+t,o=yield i.data.loadTable(n);o.name="Peptides",i.shell.addTableView(o).name="PeptidesView",i.shell.windows.showProperties=!0,e.close()}))}i.decorators||(i.decorators={}),["func","init","param","panel","editor","demo","app","appTreeBrowser","fileHandler","fileExporter","model","viewer","filter","cellRenderer","autostart","dashboard","folderViewer","semTypeDetector","packageSettingsEditor","functionAnalysis","converter","fileViewer","model","treeBrowser","polyfill"].forEach((t=>{i.decorators[t]||(i.decorators[t]=function(t){return function(t,e,n){}})}));class mt{static initPeptides(){return at(this,void 0,void 0,(function*(){try{null!=ut||(ut=new f(yield i.functions.call("Bio:getBioLib"))),null!=lt||(lt=yield async function(){const t="Dendrogram",e=r.Func.find({package:t,name:"getTreeHelper"});if(0===e.length)throw new Error(`Package "${t}" must be installed for TreeHelper.`);return(await e[0].prepare().call()).getOutputParamValue()}()),yield c.Z.loadComponents()}catch(t){i.log.error(t)}}))}static Peptides(){const t=L.appHeader({iconPath:ct.getIconUrl(),learnMoreUrl:"https://github.com/datagrok-ai/public/blob/master/help/domains/bio/peptides.md",description:"- Automatically recognizes peptides in your data\n- Invariant map and mutation cliffs\n- Logo plots to explore sequence composition\n- Hierarchical clustering\n- Sequence space to analyze clustering and activity cliffs\n- Finds statistically significant changes in activity for monomer/positions\n"}),e=i.shell.windows;e.showToolbox=!1,e.showHelp=!1,e.showProperties=!1;const n=r.View.create();return n.name="Peptides",o.appendAll(n.root,[t,o.divH([o.button("Simple demo",(()=>ft("aligned.csv")),""),o.button("Complex demo",(()=>ft("aligned_2.csv")),""),o.button("HELM demo",(()=>ft("aligned_3.csv")),"")])]),n}static peptidesDialog(){return at(this,void 0,void 0,(function*(){var t;if(!i.shell.t||!(null===(t=i.shell.t.columns.bySemType("Macromolecule"))||void 0===t?void 0:t.length))return i.shell.warning("SAR Analysis requires an active table with Macromolecule column"),null;if(!r.Utils.firstOrNull(i.shell.t.columns.numerical))return i.shell.warning("SAR Analysis requires an active table with at least one numerical column for activity"),null;const e=yield(0,s.v)(i.shell.t),n=o.dialog("Analyze Peptides").add(e.host).onOK((()=>at(this,void 0,void 0,(function*(){e.callback()||n.show()}))));return n.show()}))}static testInitFunctionPeptides(t){return at(this,void 0,void 0,(function*(){i.shell.info("Test init function for Peptides package"),i.shell.info("Viewer name: "+t.dataFrame.name),yield new Promise((t=>setTimeout(t,1e3)))}))}static peptidesPanel(t){return at(this,void 0,void 0,(function*(){if(!t.dataFrame||!r.Utils.firstOrNull(t.dataFrame.columns.numerical))return new r.Widget(o.divText("SAR Analysis requires an active table with at least one numerical column for activity"));const e=yield(0,s.v)(t.dataFrame,t);return new r.Widget(e.host)}))}static monomerPosition(){return new h.J}static mostPotentResidues(){return new h.UJ}static mutationCliffs(){return new q}static logoSummaryTable(){return new d.s}static sequencePositionStatistics(){return new D}static clusterMaxActivity(){return new V}static manualAlignment(t){const e=i.shell.t,n=null==e?void 0:e.temp[u.i.modelName];return n?function(t,e){const n=o.input.textArea("",{value:t.get(e.currentRowIdx)});l()(n.root).addClass("pep-textinput");const s=o.button("Apply",(()=>{return o=this,r=void 0,a=function*(){const o=c.Z.getSeqHelper().getSeqHandler(t),r=n.value,s=o.splitter(r),a=e.currentRowIdx;t.set(a,r);for(let t=0;t<s.length;t++){const n=s.getCanonical(t);null!==e.col(t.toString())&&e.set(t.toString(),a,n)}const l=i.shell.o;i.shell.o=null,u.i.getInstance(e).updateGrid(),setTimeout((()=>{i.shell.o=l}),100)},new((s=void 0)||(s=Promise))((function(t,e){function n(t){try{l(a.next(t))}catch(t){e(t)}}function i(t){try{l(a.throw(t))}catch(t){e(t)}}function l(e){var o;e.done?t(e.value):(o=e.value,o instanceof s?o:new s((function(t){t(o)}))).then(n,i)}l((a=a.apply(o,r||[])).next())}));var o,r,s,a}),"Apply changes"),a=o.button(o.iconFA("redo"),(()=>n.value=t.get(e.currentRowIdx)),"Reset");return l()(a).addClass("pep-snippet-editor-icon pep-reset-icon"),new r.Widget(o.divV([a,n.root,s],"pep-textarea-box"))}(e.getCol(n.settings.sequenceColumnName),e):new r.Widget(o.divText("Manual alignment works with peptides analysis"))}static macromoleculeSarFastaDemo(){return at(this,void 0,void 0,(function*(){return yield function(){return t=this,e=void 0,o=function*(){i.shell.windows.showContextPanel=!0;const t=r.DataFrame.fromCsv(yield ct.files.readAsText("aligned.csv"));t.name="Simple peptides",t.id||(t.id=`Simple-peptides-analysis-table-id-${Math.random()}-${Date.now()}`);const e=i.shell.addTableView(t);yield r.delay(50);const n=e.grid;yield new Promise((t=>{var e;let i=null;const o=null===(e=null==n?void 0:n.onAfterDrawContent)||void 0===e?void 0:e.subscribe((()=>{i&&clearTimeout(i),o.unsubscribe(),t(void 0)}));i=setTimeout((()=>{o.unsubscribe(),t(void 0)}),3e3)}));const o=t.getCol("IC50"),a=t.getCol("AlignedSequence");a.semType=r.SEMTYPE.MACROMOLECULE,a.setTag(m.gp.ALPHABET,g.YI.PT),a.meta.units=g.Hi.FASTA,a.setTag(g.gp.aligned,"SEQ.MSA");const l=(0,p.Y1)(o,m.rg.MINUS_LG),u=new v.av;u.threshold=94,yield(0,s.n)(o,a,null,t,l,m.rg.MINUS_LG,{addMCL:!0,useEmbeddingsClusters:!0,mclSettings:u})},new((n=void 0)||(n=Promise))((function(i,r){function s(t){try{l(o.next(t))}catch(t){r(t)}}function a(t){try{l(o.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}l((o=o.apply(t,e||[])).next())}));var t,e,n,o}()}))}static lstPiechartCellRenderer(){return new F.DX}}ot([i.decorators.init({tags:["init"]}),rt("design:type",Function),rt("design:paramtypes",[]),rt("design:returntype",Promise)],mt,"initPeptides",null),ot([i.decorators.func(),rt("design:type",Function),rt("design:paramtypes",[]),rt("design:returntype",r.View)],mt,"Peptides",null),ot([i.decorators.func({"top-menu":"Bio | Analyze | SAR...",name:"Bio Peptides",outputs:[]}),rt("design:type",Function),rt("design:paramtypes",[]),rt("design:returntype",Promise)],mt,"peptidesDialog",null),ot([i.decorators.func(),st(0,i.decorators.param({type:"viewer"})),rt("design:type",Function),rt("design:paramtypes",[r.Viewer]),rt("design:returntype",Promise)],mt,"testInitFunctionPeptides",null),ot([i.decorators.panel({name:"Peptides",meta:{role:"widgets"},tags:["widgets","panel"]}),st(0,i.decorators.param({options:{semType:"Macromolecule"}})),rt("design:type",Function),rt("design:paramtypes",[r.Column]),rt("design:returntype",Promise)],mt,"peptidesPanel",null),ot([i.decorators.func({meta:{icon:"files/icons/peptide-sar-viewer.svg",role:"viewer"},name:"Sequence Variability Map",tags:["viewer"],description:"Peptides Sequence Variability Map Viewer",outputs:[{type:"viewer",name:"result"}]}),rt("design:type",Function),rt("design:paramtypes",[]),rt("design:returntype",r.Viewer)],mt,"monomerPosition",null),ot([i.decorators.func({meta:{icon:"files/icons/peptide-sar-vertical-viewer.svg",role:"viewer"},name:"Most Potent Residues",tags:["viewer"],description:"Peptides Most Potent Residues Viewer",outputs:[{type:"viewer",name:"result"}]}),rt("design:type",Function),rt("design:paramtypes",[]),rt("design:returntype",r.Viewer)],mt,"mostPotentResidues",null),ot([i.decorators.func({meta:{icon:"files/icons/sequence-statistics-viewer.svg",role:"viewer"},name:"Sequence Mutation Cliffs",description:"Mutation Cliffs Line Chart",tags:["viewer"],outputs:[{type:"viewer",name:"result"}]}),rt("design:type",Function),rt("design:paramtypes",[]),rt("design:returntype",r.Viewer)],mt,"mutationCliffs",null),ot([i.decorators.func({meta:{icon:"files/icons/logo-summary-viewer.svg",role:"viewer"},name:"Logo Summary Table",tags:["viewer"],outputs:[{type:"viewer",name:"result"}]}),rt("design:type",Function),rt("design:paramtypes",[]),rt("design:returntype",r.Viewer)],mt,"logoSummaryTable",null),ot([i.decorators.func({meta:{icon:"files/icons/sequence-statistics-viewer.svg",role:"viewer"},name:"Sequence Position Statistics",outputs:[{type:"viewer",name:"result"}],tags:["viewer"]}),rt("design:type",Function),rt("design:paramtypes",[]),rt("design:returntype",r.Viewer)],mt,"sequencePositionStatistics",null),ot([i.decorators.func({name:"Active peptide selection",outputs:[{type:"viewer",name:"result"}],meta:{role:"viewer"},tags:["viewer"]}),rt("design:type",Function),rt("design:paramtypes",[]),rt("design:returntype",r.Viewer)],mt,"clusterMaxActivity",null),ot([i.decorators.panel({name:"Manual Alignment",meta:{role:"widgets"},tags:["widgets","panel"]}),st(0,i.decorators.param({options:{semType:"Monomer"}})),rt("design:type",Function),rt("design:paramtypes",[String]),rt("design:returntype",r.Widget)],mt,"manualAlignment",null),ot([i.decorators.func({meta:{demoPath:"Bioinformatics | Peptide SAR",isDemoDashboard:"true"},name:"Peptide SAR",description:"Peptide SAR Analysis demo on peptide sequences in FASTA format"}),rt("design:type",Function),rt("design:paramtypes",[]),rt("design:returntype",Promise)],mt,"macromoleculeSarFastaDemo",null),ot([i.decorators.func({meta:{cellType:"lst-pie-chart",gridChart:"true",role:"cellRenderer"},tags:["cellRenderer"],name:"LST Pie Chart",outputs:[{type:"grid_cell_renderer",name:"result"}]}),rt("design:type",Function),rt("design:paramtypes",[]),rt("design:returntype",r.GridCellRenderer)],mt,"lstPiechartCellRenderer",null)},726:(t,e,n)=>{"use strict";n.d(e,{Z:()=>s});var i=n(4971),o=n(6082),r=function(t,e,n,i){return new(n||(n=Promise))((function(o,r){function s(t){try{l(i.next(t))}catch(t){r(t)}}function a(t){try{l(i.throw(t))}catch(t){r(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(s,a)}l((i=i.apply(t,e||[])).next())}))};class s{static getMonomerLib(){if(!this._monomerLibHelper)throw new Error("MonomerLib is not initialized");return this._monomerLibHelper.getMonomerLib()}static getSeqHelper(){if(!this._secHelper)throw new Error("SeqHelper is not initialized");return this._secHelper}static loadSeqHelper(){return r(this,void 0,void 0,(function*(){var t;null!==(t=this._secHelper)&&void 0!==t||(this._secHelper=yield async function(){const t=o.Func.find({package:"Bio",name:"getSeqHelper"});if(0===t.length)throw new Error("Package 'Bio' must be installed for SeqHelper.");return(await t[0].prepare().call()).getOutputParamValue()}())}))}static loadComponents(){return r(this,void 0,void 0,(function*(){yield this.loadSeqHelper(),yield this.loadMonomerLib()}))}static loadMonomerLib(){return r(this,void 0,void 0,(function*(){var t;null!==(t=this._monomerLibHelper)&&void 0!==t||(this._monomerLibHelper=yield(0,i.pj)()),yield this._monomerLibHelper.awaitLoaded()}))}}},1458:(t,e,n)=>{"use strict";n.d(e,{Ej:()=>h,Lw:()=>c,eW:()=>f,uz:()=>u});var i=n(4139),o=n(7471),r=n(5480),s=n(8774),a=n(5070),l=function(t,e,n,i){return new(n||(n=Promise))((function(o,r){function s(t){try{l(i.next(t))}catch(t){r(t)}}function a(t){try{l(i.throw(t))}catch(t){r(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(s,a)}l((i=i.apply(t,e||[])).next())}))};function u(t,e){return l(this,arguments,void 0,(function*(t,e,n={}){var r,s;if(0===e.length)throw new Error(`PepAlgorithmError: Couldn't find any column of semType '${i.uF.MONOMER}'`);null!==(r=n.minActivityDelta)&&void 0!==r||(n.minActivityDelta=0),null!==(s=n.maxMutations)&&void 0!==s||(n.maxMutations=1);const a=new o.a,l=yield a.calc(t,e,n);return a.terminate(),l}))}function c(t,e){const n=new Map;let i=999999,o=-999999,r=2,l=2;for(const u of t.keys()){const c=new Map;n.set(u,c);const h=t.get(u);for(const t of h.keys()){const n=h.get(t);if(0===n.size)continue;const u=new s.A(e.length,!1),d=new s.A(e.length,!1);for(const t of n.keys())u.setFast(t,!0),n.get(t).forEach((t=>u.setFast(t,!0))),d.setFast(t,!0);const f=(0,a.GT)(e,d,u);f.mask=u,i=Math.min(i,f.meanDifference),o=Math.max(o,f.meanDifference),r=Math.min(r,f.count),l=Math.max(l,f.count),c.set(t,f)}}return{stats:n,minDiff:i,maxDiff:o,minCount:r,maxCount:l}}function h(t,e,n,i={}){var o,r;null!==(o=i.isFiltered)&&void 0!==o||(i.isFiltered=!1);const l={general:{}},u=t.getRawData(),c=t.length;null!==(r=i.columns)&&void 0!==r||(i.columns=n.map((t=>t.name)));const h=i.isFiltered?(0,a.pY)(e):void 0;for(const t of n){if(!i.columns.includes(t.name))continue;const n=t.getRawData(),o=t.categories,r={general:{}};for(let t=0;t<o.length;++t){const l=o[t];if(""===l)continue;const f=new Array(c).fill(!1);for(let o=0;o<c;++o)n[o]!==t||i.isFiltered&&!e.get(o)||(f[o]=!0);const m=s.A.fromValues(f);if(m.allFalse)continue;const p=(0,a.GT)(u,m,h,i.aggValue);r[l]=p,d(r.general,p)}l[t.name]=r,d(l.general,null,r.general)}return l}function d(t,e=null,n=null){var i,o,r,s,a,l,u,c,h,d,f,m,p,g,v,C,y;if(null===e&&null===n)throw new Error("MonomerPositionStatsError: either stats or summaryStats must be present");const w=null!==(i=null==e?void 0:e.count)&&void 0!==i?i:n.maxCount;null!==(o=t.maxCount)&&void 0!==o||(t.maxCount=w),t.maxCount<w&&(t.maxCount=w);const A=null!==(r=null==e?void 0:e.count)&&void 0!==r?r:n.minCount;null!==(s=t.minCount)&&void 0!==s||(t.minCount=A),t.minCount>A&&(t.minCount=A);const b=null!==(a=null==e?void 0:e.meanDifference)&&void 0!==a?a:n.maxMeanDifference;null!==(l=t.maxMeanDifference)&&void 0!==l||(t.maxMeanDifference=b),t.maxMeanDifference<b&&(t.maxMeanDifference=b);const S=null!==(u=null==e?void 0:e.meanDifference)&&void 0!==u?u:n.minMeanDifference;if(null!==(c=t.minMeanDifference)&&void 0!==c||(t.minMeanDifference=S),t.minMeanDifference>S&&(t.minMeanDifference=S),!isNaN(null!==(h=null==e?void 0:e.pValue)&&void 0!==h?h:NaN)){const i=null!==(d=null==e?void 0:e.pValue)&&void 0!==d?d:n.maxPValue;null!==(f=t.maxPValue)&&void 0!==f||(t.maxPValue=i),t.maxPValue<i&&(t.maxPValue=i);const o=null!==(m=null==e?void 0:e.pValue)&&void 0!==m?m:n.minPValue;null!==(p=t.minPValue)&&void 0!==p||(t.minPValue=o),t.minPValue>o&&(t.minPValue=o)}const T=null!==(g=null==e?void 0:e.ratio)&&void 0!==g?g:n.maxRatio;null!==(v=t.maxRatio)&&void 0!==v||(t.maxRatio=T),t.maxRatio<T&&(t.maxRatio=T);const E=null!==(C=null==e?void 0:e.ratio)&&void 0!==C?C:n.minRatio;null!==(y=t.minRatio)&&void 0!==y||(t.minRatio=E),t.minRatio>E&&(t.minRatio=E)}function f(t,e,n,i){const o=t.rowCount,l=t.getCol(e),u=l.getRawData(),c=l.categories,h=Array.from({length:c.length},(()=>new s.A(o,!1)));for(let t=0;t<o;++t)h[u[t]].setTrue(t);const d=n.map((t=>s.A.fromUint32Array(o,t.getRawData()))),f=n.map((t=>t.name)),m=i.getRawData(),p={},g={},v=t.filter.anyFalse?(0,a.pY)(t.filter):void 0;for(const t of Object.values(r.W)){const e=t===r.W.ORIGINAL?h:d,n=t===r.W.ORIGINAL?c:f,o=t===r.W.ORIGINAL?p:g;for(let t=0;t<e.length;++t){const r=e[t];o[n[t]]=r.allTrue||r.allFalse?{count:r.length,meanDifference:0,ratio:1,pValue:null,mask:r,mean:i.stats.avg}:(0,a.GT)(m,r,v)}}const C={};return C[r.W.ORIGINAL]=p,C[r.W.CUSTOM]=g,C}},3163:(t,e,n)=>{"use strict";n.d(e,{DX:()=>S,X5:()=>v,rW:()=>w,k8:()=>A,Yd:()=>y,rI:()=>C,FZ:()=>b});var i=n(7389),o=n(6082),r=n(4139),s=n(2003),a=n(1458);const l=rxjs;var u=n(912),c=n(5480),h=n(3541);n(7194);var d,f,m;!function(t){t.maxMonomerLength=".mm.cellRenderer.maxMonomerLength"}(d||(d={})),function(t){t.applyToBackground=".m.cellRenderer.applyToBackground"}(f||(f={})),function(t){t.MSA="MSA",t.classic="classic"}(m||(m={})),new class{constructor(){this.color="rgb(100,100,100)",this.pivot=0,this.left=!1,this.transparencyRate=0,this.separator="",this.last=!1,this.drawStyle=m.classic,this.maxWord=[],this.wordIdx=0,this.gridCell=null,this.referenceSequence=null,this.maxLengthOfMonomer=null,this.monomerTextSizeMap={},this.logger=void 0,this.selectedPosition=void 0,this.isMultiLineContext=!1,this.lineNumber=0}};var p=n(726),g=n(3981);function v(t,e){t.strokeStyle=o.Color.toHtml(o.Color.selectedRows),t.lineWidth=3,t.strokeRect(e.x+1,e.y+1,e.width-1,e.height-1)}function C(t,e,n){t.semType=r.uF.MONOMER,t.setTag(o.TAGS.CELL_RENDERER,r.uF.MONOMER),t.setTag(r.gp.ALPHABET,e),n&&t.setTag(f.applyToBackground,"true")}function y(t,e,n,i,r){var s,a,l,u,c,d,f,m,p,g;const C=r.width/2,y=Math.ceil(r.x+1+C),w=Math.ceil(r.y+1+r.height/2),A=Math.min(.9*C/2,.9*r.height/2);if(i instanceof h.UJ){const r=i.monomerPositionStats[n],s=r[e].pValue,a=r[e].meanDifference,l=1-r.general.maxPValue,u=1-r.general.minPValue,c=Math.min(l,u),h=l-c,d=u-c,f=Math.max(h,d),m=null===s?0:1-s-c,p=a>=0?m:-m,g=o.Color.toHtml(null===s?o.Color.lightLightGray:o.Color.scaleColor(p,-f,f,255)),v=Math.max(Math.abs(i.monomerPositionStats.general.minMeanDifference),i.monomerPositionStats.general.maxMeanDifference),b=Math.abs(a)/v,S=Math.floor(A*b);t.beginPath(),t.fillStyle=g,t.arc(y-C/2,w,S<3||null===s?3:S,0,2*Math.PI,!0),t.closePath(),t.fill()}else if(i instanceof h.J&&i.mutationCliffs&&i.cliffStats){const r=i.cliffStats.maxCount,u=i.cliffStats.minDiff,c=i.cliffStats.maxDiff,h=null===(l=null===(a=null===(s=i.cliffStats)||void 0===s?void 0:s.stats)||void 0===a?void 0:a.get(e))||void 0===l?void 0:l.get(n);if(h){const e=h.count,n=h.meanDifference,i=Math.floor(Math.abs(e/Math.max(r,2))*A),s=Math.max(Math.abs(u),Math.abs(c)),a=o.Color.toHtml(null===n?o.Color.lightLightGray:o.Color.scaleColor(n,-s,s,255));t.beginPath(),t.fillStyle=a,t.arc(y-C/2,w,i<3||0==e?3:i,0,2*Math.PI,!0),t.closePath(),t.fill()}}if(t.textBaseline="middle",t.textAlign="end",t.fillStyle="#606060",t.font="13px Roboto, Roboto Local, sans-serif",t.shadowBlur=5,t.shadowColor=o.Color.toHtml(o.Color.white),i instanceof h.J){let o=0;const r=null!==(f=null===(d=null===(c=null===(u=i.mutationCliffs)||void 0===u?void 0:u.get(e))||void 0===c?void 0:c.get(n))||void 0===d?void 0:d.entries())&&void 0!==f?f:null;if(null!==r)for(const[t,e]of r)o+=null!==(m=e.length)&&void 0!==m?m:0;0!==o&&t.fillText(o.toString(),y+C-5,w,C-5)}else if(i instanceof h.UJ){const o=i.monomerPositionStats,r=null===(g=null===(p=null==o?void 0:o[n])||void 0===p?void 0:p[e])||void 0===g?void 0:g.count;r&&t.fillText(r.toString(),y+C-5,w,C-5)}if(i instanceof h.J){const o=i.mutationCliffsSelection[n];o&&o.includes(e)&&v(t,r)}else if(i instanceof h.UJ){const o=i.invariantMapSelection[n];o&&o.includes(e)&&v(t,r)}}function w(t,e,n,i,r,s,a){a=o.Color.fromHtml(o.Color.toHtml(function(t,e){return(16777215&t|255<<24)>>>0}(a)));let l=r.toFixed(2);l.endsWith(".00")&&(l=r.toFixed(0)),l.endsWith("0")&&l.includes(".")&&(l=r.toFixed(1));const u=Math.min(13,Math.floor(s.width/40/l.length*6*13));t.fillStyle=o.Color.toHtml(a),t.fillRect(s.x,s.y,s.width,s.height),t.font=`${u}px Roboto, Roboto Local, sans-serif`,t.textAlign="center",t.textBaseline="middle",t.fillStyle=o.Color.toHtml(o.Color.getContrastColor(a)),t.fillText(l,s.x+s.width/2,s.y+s.height/2,s.width);const c=i[n];c&&c.includes(e)&&v(t,s)}function A(t,e,n,i){t.font="13px Roboto, Roboto Local, sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillStyle="#000",t.fillText(e.toString(),i.x+i.width/2,i.y+i.height/2,i.width),(n[c.W.CUSTOM].includes(e)||n[c.W.ORIGINAL].includes(e))&&v(t,i)}function b(t,e,n,c,h,d={x:0,y:0,mpStats:{},monomerPosition:{}}){var f;if(null!==(f=h.isSelectionTable)&&void 0!==f||(h.isSelectionTable=!1),0==Object.keys(d.mpStats).length&&(d.mpStats=e),h.isSelectionTable&&(!h.webLogoBounds||!h.cachedWebLogoTooltip))throw new Error("Peptides: Cannot set WebLogo renderer for selection table without `headerSelectedMonomers`, `webLogoBounds` and `cachedWebLogoTooltip` options.");const m=t.dataFrame;t.setOptions({colHeaderHeight:130});t.onCellRender.subscribe((t=>(t=>{var i,l,u,d;if(!(null===(i=t.cell)||void 0===i?void 0:i.isColHeader))return;const f=t.g,v=t.bounds,C=t.cell.tableColumn;f.save();try{if(f.beginPath(),f.clearRect(v.x,v.y,v.width,v.height),f.rect(v.x,v.y,v.width,v.height),f.clip(),(null==C?void 0:C.semType)===r.uF.MONOMER){let i;if(m.filter.anyFalse){null!==(l=(d=m).jsOnlyTemp)&&void 0!==l||(d.jsOnlyTemp={});const t=null!==(u=m.jsOnlyTemp[r.gp.M_P_STATS_CACHE])&&void 0!==u?u:{},e=null==t?void 0:t[C.name];if(t&&e&&e.filterLength===m.filter.length&&e.filterVersion===m.filter.version)i=e.stats[C.name];else{const e=(0,a.Ej)(c,m.filter,n,{isFiltered:!0,columns:[C.name]});i=e[C.name],t[C.name]={filterVersion:m.filter.version,stats:e,filterLength:m.selection.length}}m.jsOnlyTemp[r.gp.M_P_STATS_CACHE]=t}else i=h.isSelectionTable?(0,a.Ej)(c,m.filter,n,{isFiltered:!0,columns:[C.name]})[C.name]:e[C.name];if(!i)return;const y=Object.keys(i).sort(((t,e)=>""===t||"-"===t?1:""===e||"-"===e?-1:0)).filter((t=>"general"!==t));h.webLogoBounds()[C.name]=function(t,e,n,i,r,a,l,u={},c={}){var h,d,f,m,v,C,y,w,A;const b=window.devicePixelRatio;null!==(h=c.symbolStyle)&&void 0!==h||(c.symbolStyle="16px Roboto, Roboto Local, sans-serif"),null!==(d=c.upperLetterHeight)&&void 0!==d||(c.upperLetterHeight=12.2),null!==(f=c.upperLetterAscent)&&void 0!==f||(c.upperLetterAscent=.25),null!==(m=c.marginVertical)&&void 0!==m||(c.marginVertical=1),null!==(v=c.marginHorizontal)&&void 0!==v||(c.marginHorizontal=1),null!==(C=c.selectionWidth)&&void 0!==C||(c.selectionWidth=2),null!==(y=c.textHeight)&&void 0!==y||(c.textHeight=13),null!==(w=c.headerStyle)&&void 0!==w||(c.headerStyle=`bold ${c.textHeight*b}px Roboto, Roboto Local, sans-serif`);const S=(r.length-1)*c.upperLetterAscent;let T=(e.y+c.marginVertical)*b;const E=(e.height-2*c.marginVertical-S-1.25*c.textHeight)*b,_=(e.x+c.marginHorizontal)*b,N=Math.max(c.selectionWidth*b,.05*e.width*b),x=2*c.marginHorizontal+c.selectionWidth,M=(e.width-(x+c.marginHorizontal))*b,I=(e.x+x)*b,O=p.Z.getMonomerLib(),L={};for(const e of r){const i=E*(n[e].count/a),r=E*((null!==(A=u[e])&&void 0!==A?A:0)/a);if(L[e]=new o.Rect(I/b,T/b,M/b,i/b),t.resetTransform(),"-"!==e&&""!==e){const n=(0,s.zS)(e,5),a=t.measureText(n);r>0&&(t.lineWidth=N,t.line(_,T,_,T+r,o.Color.rowSelection));const l=O.getMonomerTextColor(g.o.AA,e);t.fillStyle=l,t.textAlign="left",t.textBaseline="top",t.font=c.symbolStyle;const u=M/a.width,h=i/c.upperLetterHeight;t.setTransform(u,0,0,h,I,T),t.fillText(n,0,0,a.width)}T+=i+c.upperLetterAscent*b}return t.resetTransform(),t.fillStyle=o.Color.toHtml(o.Color.black),t.textAlign="center",t.textBaseline="top",t.font=c.headerStyle,t.fillText(i,(e.x+e.width/2)*b,(e.y+e.height-c.textHeight)*b),L}(f,v,i,C.name,y,m.filter.trueCount,h.colorPalette(),h.headerSelectedMonomers?h.headerSelectedMonomers()[C.name]:{}),t.preventDefault()}}catch(t){console.warn(`PeptidesHeaderLogoError: couldn't render WebLogo for column \`${C.name}\`. See original error below.`),console.warn(t)}finally{f.restore()}})(t)));const v=n=>{var o;const s=t.hitTest(n.offsetX,n.offsetY);if((null==s?void 0:s.isColHeader)&&(null===(o=s.tableColumn)||void 0===o?void 0:o.semType)===r.uF.MONOMER){const t=function(t,e,n){const i=n[t.tableColumn.name];if(!i)return null;for(const[n,o]of Object.entries(i)){const i=e.offsetX>=o.x&&e.offsetX<=o.x+o.width,r=e.offsetY>=o.y&&e.offsetY<=o.y+o.height;if(i&&r)return{monomerOrCluster:n,positionOrClusterType:t.tableColumn.name}}return null}(s,n,h.webLogoBounds());if(null===t)return void(h.isSelectionTable||null==h.unhighlightCallback||h.unhighlightCallback());d.monomerPosition=t;const o=m.filter.anyFalse?m.clone(m.filter):m,r=o.getCol(c.name);!function(t,e,n,o,r,s){if("click"!==t.type||r.isSelectionTable||null==r.selectionCallback){const a=`${e.positionOrClusterType} = ${e.monomerOrCluster}`;r.cachedWebLogoTooltip().bar===a?i.tooltip.show(r.cachedWebLogoTooltip().tooltip,t.clientX,t.clientY):(r.cachedWebLogoTooltip().bar=a,s.x=t.clientX,s.y=t.clientY,s.monomerPosition=e,r.cachedWebLogoTooltip().tooltip=(0,u.Y)(n,o,[],s))}else r.selectionCallback(e,{shiftPressed:t.shiftKey,ctrlPressed:t.ctrlKey})}(n,t,o,r,h,d),h.isSelectionTable||null==h.highlightCallback||h.highlightCallback(t,m,e)}else null!=h.unhighlightCallback&&h.unhighlightCallback()};l.fromEvent(t.overlay,"mousemove").subscribe((t=>v(t))),l.fromEvent(t.overlay,"click").subscribe((t=>v(t))),l.fromEvent(t.overlay,"mouseleave").subscribe((()=>{null!=h.unhighlightCallback&&h.unhighlightCallback()}))}class S extends o.GridCellRenderer{constructor(){super(...arguments),this.colorCacheKey="lst-pie-chart-color-cache",this.HoverTempKey="lst-pie-chart-hovered-sector",this.hoverSeparator=",,,,,"}get name(){return"LST Pie Chart"}get cellType(){return"lst-pie-chart"}get defaultWidth(){return 80}get defaultHeight(){return 80}categoryNumberCache(t){return t.temp[this.colorCacheKey]||(t.temp[this.colorCacheKey]={}),t.temp[this.colorCacheKey]}getPrevHoveredSector(t){return t.temp[this.HoverTempKey]}onMouseMove(t,e){const n=this.getPrevHoveredSector(t.cell.column),o=()=>{t.cell.column.temp[this.HoverTempKey]=null,i.tooltip.hide(),null!==n&&t.grid.invalidate()},r=t.cell.value;if(!r)return void o();const s=e.offsetX-t.bounds.midX,a=e.offsetY-t.bounds.midY,l=Math.sqrt(s*s+a*a),u=Math.atan2(a,s),c=u<0?u+2*Math.PI:u;if(l>Math.min(t.bounds.width,t.bounds.height)/2-2)return void o();let h;try{h=JSON.parse(r)}catch(e){return void o()}const d=new Float64Array(Object.keys(h).length+1),f=Object.values(h).reduce(((t,e)=>t+e),0);d[Object.keys(h).length]=2*Math.PI;let m=0,p=0;for(const t of Object.values(h))d[p++]=m,m+=2*Math.PI*t/f;let g=-1;for(let t=0;t<d.length-1;t++)if(c>=d[t]&&c<d[t+1]){g=t;break}if(-1===g)return void o();const v=Object.keys(h)[g],C=h[v],y=(C/f*100).toFixed(2);i.tooltip.show(i.h1(`${v}: ${C} (${y}%)`),e.x+16,e.y+16);const w=t.cell.rowIndex.toString()+this.hoverSeparator+v;t.cell.column.temp[this.HoverTempKey]=w,n!==w&&t.grid.invalidate()}render(t,e,n,i,r,s,a){const l=s.cell.dataFrame,u=new o.Rect(e,n,i,r).fitSquare().inflate(-2,-2);if(i<5||r<5||!l)return;const c=s.cell.value;if(t.clearRect(e,n,i,r),!c)return;let h;try{h=JSON.parse(c)}catch(t){return}const d=Object.values(h).reduce(((t,e)=>t+e),0);let f=0;const m=Object.fromEntries(Object.keys(h).map((t=>[t,255]))),p=s.cell.column.temp[this.HoverTempKey];if(p&&2===p.split(this.hoverSeparator).length){const[t,e]=p.split(this.hoverSeparator);if(t===s.cell.rowIndex.toString()){for(const[t,e]of Object.entries(h))m[t]=100;m[e]=255}}const g=Math.min(i,r)/2.2;for(const[e,n]of Object.entries(h)){const i=2*Math.PI*n/d;t.beginPath(),t.moveTo(u.midX,u.midY),t.arc(u.midX,u.midY,g,f,f+i),f+=i;const r=this.categoryNumberCache(s.cell.column);r[e]||(r[e]=Object.keys(r).length,s.cell.column.temp[this.colorCacheKey]=r),t.fillStyle=o.Color.toHtml(o.Color.setAlpha(o.Color.getCategoricalColor(r[e]),m[e])),t.fill(),t.strokeStyle=o.Color.toRgb(o.Color.lightGray),t.stroke();const a=e;t.fillStyle=o.Color.toRgb(o.Color.white),t.font="9px Arial";const l=t.measureText(a).width,c=f-i/2;for(let e=.8;e>=.4;e-=.05){const n=g*e,o=u.midX+Math.cos(c)*n,r=u.midY+Math.sin(c)*n;if([[o-l/2-2,r],[o+l/2+2,r]].every((t=>{const e=Math.sqrt(Math.pow(t[0]-u.midX,2)+Math.pow(t[1]-u.midY,2)),n=Math.atan2(t[1]-u.midY,t[0]-u.midX),o=n<0?n+2*Math.PI:n;return e<g-2&&o>f-i&&o<f}))){t.fillText(a,o,r);break}}}}}},4139:(t,e,n)=>{"use strict";n.d(e,{$2:()=>i,To:()=>l,V5:()=>d,gp:()=>r,i6:()=>o,rg:()=>u,uF:()=>s,wf:()=>c,zW:()=>f});var i,o,r,s,a=n(6082);!function(t){t.SPLIT_COL="~split",t.ACTIVITY="Activity",t.ACTIVITY_SCALED="Scaled activity",t.MONOMER="AAR",t.POSITION="Pos",t.P_VALUE="pValue",t.MEAN_DIFFERENCE="Mean difference",t.COUNT="Count",t.RATIO="Ratio",t.MEAN="Mean",t.TOTAL_COUNT="∑"}(i||(i={})),function(t){t.MEMBERS="Members",t.WEB_LOGO="WebLogo",t.DISTRIBUTION="Distribution",t.MEAN_DIFFERENCE="Mean difference",t.P_VALUE="P-Value",t.RATIO="Ratio",t.CLUSTER="Cluster"}(o||(o={})),function(t){t.MONOMER="monomer",t.POSITION="pos",t.SEPARATOR="separator",t.ALPHABET="alphabet",t.FILTER="filter",t.SAR_MODE="sarMode",t.VISIBLE="visible",t.SETTINGS="settings",t.CUSTOM_CLUSTER="customCluster",t.MONOMER_POSITION_MODE="monomerPositionMode",t.MULTIPLE_VIEWS="isMultipleViews",t.IDENTITY_TEMPLATE="Identity template",t.SIMILARITY_TEMPLATE="Similarity template",t.ANALYSIS_COL="isAnalysisCol",t.POSITION_COL="isPositionCol",t.M_P_STATS_CACHE=".MPStatsCache",t.INVARIANT_MAP_COLOR_CACHE=".InvariantMapColorCache",t.INVARIANT_MAP_COLOR_MAX_CACHE=".InvariantMapColorMaxCache",t.INVARIANT_MAP_COLOR_MIN_CACHE=".InvariantMapColorMinCache"}(r||(r={})),function(t){t.MONOMER="Monomer",t.MACROMOLECULE_DIFFERENCE="MacromoleculeDifference"}(s||(s={}));const l="ColumnName";var u,c,h;!function(t){t.NONE="none",t.LG="lg",t.MINUS_LG="-lg"}(u||(u={})),function(t){t.HIGH="High",t.LOW="Low"}(c||(c={})),function(t){t.LST="lst-",t.MP="mp-",t.MPR="mpr-",t.WL="wl-"}(h||(h={}));const d=Object.values(a.AGG).filter((t=>![a.AGG.FIRST,a.AGG.KEY,a.AGG.PIVOT,a.AGG.SELECTED_ROWS_COUNT].includes(t))),f={[a.AGG.TOTAL_COUNT]:"totalCount",[a.AGG.VALUE_COUNT]:"valueCount",[a.AGG.UNIQUE_COUNT]:"uniqueCount",[a.AGG.MISSING_VALUE_COUNT]:"missingValueCount",[a.AGG.MIN]:"min",[a.AGG.MAX]:"max",[a.AGG.SUM]:"sum",[a.AGG.MED]:"med",[a.AGG.AVG]:"avg",[a.AGG.STDEV]:"stdev",[a.AGG.VARIANCE]:"variance",[a.AGG.SKEW]:"skew",[a.AGG.KURT]:"kurt",[a.AGG.Q1]:"q1",[a.AGG.Q2]:"q2",[a.AGG.Q3]:"q3"}},8608:(t,e,n)=>{"use strict";n.d(e,{$s:()=>_,AN:()=>i,AY:()=>d,B2:()=>x,BE:()=>w,BX:()=>O,CD:()=>b,F2:()=>g,FZ:()=>v,Lv:()=>I,Y1:()=>f,Z7:()=>C,ZR:()=>E,dl:()=>T,eY:()=>p,qx:()=>m,sg:()=>M,vW:()=>S,vY:()=>A,zm:()=>N,zz:()=>y});var i,o=n(7389),r=n(6082),s=n(4328),a=n(4139),l=n(8774),u=n(144),c=n.n(u),h=function(t,e,n,i){return new(n||(n=Promise))((function(o,r){function s(t){try{l(i.next(t))}catch(t){r(t)}}function a(t){try{l(i.throw(t))}catch(t){r(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(s,a)}l((i=i.apply(t,e||[])).next())}))};function d(t){var e;return null!==(e=t.getTag(a.gp.SEPARATOR))&&void 0!==e?e:""}function f(t,e=a.rg.NONE){let n=t=>t;switch(e){case a.rg.NONE:break;case a.rg.LG:n=t=>Math.log10(t);break;case a.rg.MINUS_LG:n=t=>-Math.log10(t);break;default:throw new Error(`ScalingError: method \`${e}\` is not available.`)}const i=t.getRawData(),o=r.Column.float(a.$2.ACTIVITY,t.length).init((t=>{const e=i[t];return e===r.FLOAT_NULL||e===r.INT_NULL?e:n(e)}));return o.setTag(a.gp.ANALYSIS_COL,"true"),o.setTag(r.TAGS.FORMULA,e),o}function m(t){var e,n,i,o;const r=t.columns.bySemTypeAll(a.uF.MONOMER),s={},l=t.filter.clone().and(t.selection).getSelectedIndexes();for(const t of l)for(const a of r){const r=a.get(t);r&&(null!==(e=s[i=a.name])&&void 0!==e||(s[i]={}),null!==(n=(o=s[a.name])[r])&&void 0!==n||(o[r]=0),s[a.name][r]+=1)}return s}function p(t){return{name:t.name,cat:t.categories,rawData:t.getRawData()}}function g(t,e,n={}){var i;const s=[],l=t.dataFrame.getCol(a.$2.SPLIT_COL).categories;for(let t=0;t<l.length;++t){if(!l[t])continue;const e=r.Color.toHtml(r.Color.categoricalPalette[t%r.Color.categoricalPalette.length]),a=o.label(null!==(i=n[l[t]])&&void 0!==i?i:l[t],{style:{color:e}});s.push(a)}const u=o.divV([o.divV(s),t.root,o.tableFromMap(e)]);return t.root.style.maxHeight="75px",u}function v(t,e,n){const o=n.filter,s=e.clone().and(o),l=t.length,u=t.getRawData(),c=o.trueCount,h=new Float32Array(c+s.trueCount),d=new Array(h.length);for(let t=0,e=0,n=0;t<l;++t){if(!o.get(t))continue;const r=s.get(t);h[e]=u[t],d[e]=r?i.SELECTION:i.ALL,e++,r&&(h[c+n]=u[t],d[c+n]=i.ALL,++n)}const f=r.Column.fromStrings(a.$2.SPLIT_COL,d),m=[i.ALL,i.SELECTION];return f.setCategoryOrder(m),f.meta.colors.setCategorical(),r.DataFrame.fromColumns([r.Column.fromFloat32Array(a.$2.ACTIVITY,h),f])}function C(t,e,n){t.dataFrame||r.DataFrame.fromColumns([t]);const i=t.dataFrame.filter,o=t.getRawData(),s=Array.from(new Set(e.keys())).map((t=>Number(t))).filter((t=>i.get(t))),l=new Set;for(const t of e.values())for(const e of t)l.add(e);const u=Array.from(l).filter((t=>i.get(t))),c=s.length+u.length,h=new Array(c),d=new Float32Array(c);for(let t=0;t<s.length;++t){const e=s[t];d[t]=o[e],h[t]=n}for(let t=0;t<u.length;++t){const e=u[t];d[s.length+t]=o[e],h[s.length+t]="Mutated"}const f=r.Column.fromStrings(a.$2.SPLIT_COL,h),m=[n,"Mutated"];return f.setCategoryOrder(m),f.meta.colors.setCategorical(),r.DataFrame.fromColumns([r.Column.fromFloat32Array(a.$2.ACTIVITY,d),f])}function y(t){const e=o.iconFA("expand-alt",(()=>{const e=t.dataFrame.plot.grid();A(e,!1),e.root.style.height="100%";const n=o.dialog(t.dataFrame.name);n.add(e.root),n.showModal(!0),e.invalidate()}));t.root.appendChild(e),e.style.position="absolute",e.style.right="0px",e.style.top="0px",e.style.visibility="hidden",t.root.addEventListener("mouseenter",(t=>{e.style.visibility="visible"})),t.root.addEventListener("mouseleave",(t=>{e.style.visibility="hidden"}))}function w(t,e,n,i){const r=o.iconFA("expand-alt",(()=>{const e=i(),n=o.dialog(t);n.add(e),n.show({resizable:!0,modal:!0,width:window.innerWidth-60,x:30,y:30,height:window.innerHeight-60})}),"Expand to full screen");r.style.marginLeft="auto",r.style.marginRight="15px",n.addEventListener("mouseenter",(()=>{r.style.visibility="visible"})),n.addEventListener("mouseleave",(()=>{r.style.visibility="hidden"})),e.appendChild(r)}function A(t,e=!0){t.props.allowEdit=!1,t.props.showReadOnlyNotifications=!1,t.props.allowRowSelection=!1,t.props.allowBlockSelection=!1,t.props.allowColSelection=!1,t.props.showRowHeader=!1,t.props.showCurrentRowIndicator=!1,t.root.style.width="100%",t.root.style.maxWidth="100%",e&&t.autoSize(1e3,175,0,0,!0)}function b(t){for(const e of Object.values(t))if(0!==e.length)return!1;return!0}function S(t,e,n){const i=t[e.positionOrClusterType],o=i.indexOf(e.monomerOrCluster);if(n.shiftPressed&&n.ctrlPressed)-1!==o&&i.splice(o,1);else if(n.ctrlPressed)-1===o?i.push(e.monomerOrCluster):i.splice(o,1);else if(n.shiftPressed)-1===o&&i.push(e.monomerOrCluster);else{const n=Object.keys(t);t={};for(const i of n)t[i]=[],i===e.positionOrClusterType&&t[i].push(e.monomerOrCluster)}return t}function T(t,e,n){if(!e)return;const i=new l.A(e.rowCount);if(t.positionOrClusterType===a.$2.MONOMER){const e=Object.values(n);for(const n of e){const e=n[t.monomerOrCluster];void 0!==e&&i.or(e.mask)}}else{const e=n[t.positionOrClusterType];if(void 0!==e){const n=e[t.monomerOrCluster];void 0!==n&&i.or(n.mask)}}e.rows.highlight((t=>i.getBit(t)))}function E(t){const e={};for(const n of t)e[n.name]=[];return e}function _(t,e){return t.sequenceColumnName===e.sequenceColumnName&&t.activityColumnName===e.activityColumnName&&t.activityScaling===e.activityScaling}function N(t,e,n,i){const o=Object.entries(n),r=i?Object.entries(i).filter((t=>!e.includes(t[0])||n[t[0]]!==t[1])):[];return o.concat(r).filter((e=>t.columns.contains(e[0])&&t.col(e[0]).matches("numerical")))}function x(t,e=2){return t.columns.bySemTypeAll(r.SEMTYPE.MACROMOLECULE).length>0&&c()(t.columns.numerical).toArray().length>0&&t.rowCount>=e}function M(t,e=500){let n;return(...i)=>h(this,void 0,void 0,(function*(){return new Promise((o=>{clearTimeout(n),n=setTimeout((()=>o(t(...i))),e)}))}))}function I(){return"isInDemo"in s.shell&&!!s.shell.isInDemo}function O(t){return{set:function(e,n){return t[e]=n,this}}}!function(t){t.SELECTION="Selection",t.ALL="All",t.PEPTIDES_SELECTION="Peptides selection"}(i||(i={}))},7471:(t,e,n)=>{"use strict";n.d(e,{a:()=>i});class i{constructor(){const t=navigator.hardwareConcurrency;this._workerCount=Math.max(t-2,1),this._workers=new Array(this._workerCount).fill(null).map((()=>new Worker(new URL(n.p+n.u(216),n.b))))}calc(t,e){return n=this,i=arguments,r=function*(t,e,n={}){const i=new Map;try{const o=t.length,r=new Array(this._workerCount),s=o*(o-1)/2;this._workerCount=Math.min(this._workerCount,s);const a=s/this._workerCount;e.forEach((t=>{var e;t.cat=null===(e=t.cat)||void 0===e?void 0:e.slice()}));for(let i=0;i<this._workerCount;i++)r[i]=new Promise(((o,r)=>{const l=Math.floor(i*a),u=i===this._workerCount-1?s:Math.floor((i+1)*a);this._workers[i].postMessage({startIdx:l,endIdx:u,activityArray:t,monomerInfoArray:e,settings:n}),this._workers[i].onmessage=({data:{pos:t,seq1Idxs:e,seq2Idxs:n,error:s}})=>{var a;s?(null===(a=this._workers[i])||void 0===a||a.terminate(),r(s)):(this._workers[i].terminate(),o({pos:t,seq1Idxs:e,seq2Idxs:n}))}}));const l=yield Promise.all(r),u=new Map;e.forEach(((t,e)=>{u.set(t.name,e)})),l.filter(Boolean).forEach((t=>{for(let n=0;n<t.pos.length;n++){const o=u.get(t.pos[n]),r=e[o].rawData[t.seq1Idxs[n]],s=e[o].cat[r],a=e[o].rawData[t.seq2Idxs[n]],l=e[o].cat[a];i.has(s)||i.set(s,new Map),i.has(l)||i.set(l,new Map);const c=i.get(s),h=i.get(l);c.has(t.pos[n])||c.set(t.pos[n],new Map),h.has(t.pos[n])||h.set(t.pos[n],new Map);const d=c.get(t.pos[n]),f=h.get(t.pos[n]);d.has(t.seq1Idxs[n])||d.set(t.seq1Idxs[n],[]),f.has(t.seq2Idxs[n])||f.set(t.seq2Idxs[n],[]);const m=d.get(t.seq1Idxs[n]),p=f.get(t.seq2Idxs[n]);m.push(t.seq2Idxs[n]),p.push(t.seq1Idxs[n])}}))}catch(t){this.terminate(),console.error(t)}return i},new((o=void 0)||(o=Promise))((function(t,e){function s(t){try{l(r.next(t))}catch(t){e(t)}}function a(t){try{l(r.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(s,a)}l((r=r.apply(n,i||[])).next())}));var n,i,o,r}terminate(){var t;null===(t=this._workers)||void 0===t||t.forEach((t=>{try{null==t||t.terminate()}catch(t){console.error(t)}}))}}},5070:(t,e,n)=>{"use strict";n.d(e,{pY:()=>l,hX:()=>a,I_:()=>h,m2:()=>d,lh:()=>c,GT:()=>u,J1:()=>f});var i=n(6082),o=n(6572),r=n(8774),s=n(4139);const a=(t,e)=>`${t}(${e})`;function l(t){return r.A.fromUint32Array(t.length,new Uint32Array(t.getBuffer().buffer))}function u(t,e,n,r){var s;if(t.length!==e.length&&16!==t.length||n&&t.length!==n.length&&16!==t.length)throw new Error("PeptidesError: Data and bit array have different lengths");n&&n.allTrue&&(n=void 0);const a=n?e.clone().and(n):e,l=new Float32Array(a.trueCount()),u=new Float32Array(n?n.trueCount()-a.trueCount():a.falseCount());let c;if(r)try{c=null===(s=i.DataFrame.fromColumns([r.col]).clone(function(t){return i.BitSet.fromBytes(t.buffer.buffer,t.length)}(a)).col(r.col.name))||void 0===s?void 0:s.aggregate(r.type)}catch(t){console.error(t)}let h=0,d=0;for(let i=0;i<e.length;++i)n&&!n.getBit(i)||(e.getBit(i)?l[h++]=t[i]:u[d++]=t[i]);const f=l.length+u.length,m=l.reduce(((t,e)=>t+e),0)/Math.max(l.length,1);if(l.length<2||u.length<2){const t=u.reduce(((t,e)=>t+e),0)/Math.max(u.length,1);return{count:l.length,pValue:null,mean:m,meanDifference:m-t,ratio:l.length/f,mask:a,aggValue:c}}const p=function(t,e,n=!1,i=!1){if(t.length<=1||e.length<=1)throw new Error(`StatisticsError: Wrong sample size; expected at least 2, got ${Math.min(t.length,e.length)})`);const r=o.mean(t),s=o.mean(e),a=o.variance(t),l=o.variance(e),u=t.length,c=e.length;let h,d,f;if(n){const t=a/u,e=l/c,n=(r-s)/Math.sqrt(t+e);d=o.normal.pdf(n,0,1),h=1-d,f=2*(d<h?d:h)}else if(i){const t=u+c-2,e=(a*(u-1)+l*(c-1))/t,n=Math.sqrt(u*c/(u+c))*(r-s)/e;h=1-o.studentt.cdf(n,t),d=o.studentt.cdf(n,t),f=2*(d<h?d:h)}else{const t=a/u,e=l/c,n=(r-s)/Math.sqrt(t+e),i=Math.pow(t+e,2)/(Math.pow(t,2)/(u-1)+Math.pow(e,2)/(c-1));d=o.studentt.cdf(n,i),h=1-d,f=2*(d<h?d:h)}return{"p-value":f,"Mean difference":r-s,"p-value more":h,"p-value less":d}}(l,u),g=p["Mean difference"];return{count:l.length,pValue:p[g>=0?"p-value more":"p-value less"],mean:m,meanDifference:g,ratio:l.length/f,mask:a,aggValue:c}}function c(t,e,n){const o=s.zW[e],r=i.Stats.fromColumn(t,n);if(!(o in r))throw new Error(`Aggregation type ${o} is not supported`);return r[o]}function h(t,e,n={}){var i,o;null!==(i=n.filterDf)&&void 0!==i||(n.filterDf=!1),null!==(o=n.fractionDigits)&&void 0!==o||(n.fractionDigits=3);const r=!n.filterDf||!t.filter.anyFalse||n.mask&&n.mask.length!==t.filter.trueCount?t:t.clone(t.filter),s={};for(const[t,i]of e){const e=a(i,t),o=c(r.getCol(t),i,n.mask);s[e]=o.toFixed(n.fractionDigits)}return s}function d(t,e,n,i){var o;null!==(o=i.fractionDigits)&&void 0!==o||(i.fractionDigits=3);const r={};for(const[o,s]of n){const n=a(s,o),l=t.get(n,e);r[n]=l.toFixed(i.fractionDigits)}return r}function f(t,e,n){var o;const r=t.col(e.substring(5,e.length-1));if(!r||!r.matches("categorical"))return"{}";null!=n||(n=i.BitSet.create(t.rowCount,(()=>!0)));const s=r.getRawData(),a=new Map;for(let t=-1;-1!==(t=n.findNext(t,!0));)a.set(s[t],(null!==(o=a.get(s[t]))&&void 0!==o?o:0)+1);const l={};for(const[t,e]of a)l[r.categories[t]]=e;return JSON.stringify(l)}},912:(t,e,n)=>{"use strict";n.d(e,{D:()=>u,Y:()=>c});var i=n(7389),o=n(6082),r=n(4139),s=n(7654),a=n(8608),l=n(5070);function u(t,e,n,i){var o,s,a;return null!==(o=i.fromViewer)&&void 0!==o||(i.fromViewer=!1),null!==(s=i.isMutationCliffs)&&void 0!==s||(i.isMutationCliffs=!1),null!==(a=i.isMostPotentResidues)&&void 0!==a||(i.isMostPotentResidues=!1),i.monomerPosition.positionOrClusterType!==r.$2.MONOMER&&c(t,e,n,i),!0}function c(t,e,n,r){var u,c,h,d,f,m,p,g,v;if(null!==(u=r.fromViewer)&&void 0!==u||(r.fromViewer=!1),null!==(c=r.isMutationCliffs)&&void 0!==c||(r.isMutationCliffs=!1),null!==(h=r.isMostPotentResidues)&&void 0!==h||(r.isMostPotentResidues=!1),null!==(d=r.additionalStats)&&void 0!==d||(r.additionalStats={}),r.cliffStats&&r.isMutationCliffs&&r.cliffIndexes){const u=null===(g=null===(p=r.cliffStats)||void 0===p?void 0:p.get(r.monomerPosition.monomerOrCluster))||void 0===g?void 0:g.get(r.monomerPosition.positionOrClusterType);if(!u)return null;const c=o.BitSet.fromBytes(u.mask.buffer.buffer,e.length);c.and(t.filter);const h=(0,s.M1)((0,a.Z7)(e,r.cliffIndexes,r.monomerPosition.monomerOrCluster),!0),d="MP in cliffs count",f=(0,s.QD)(u,{countName:d});r.fromViewer&&(f["Mean difference"]=`${f["Mean difference"]} (Color)`,f[d]&&(f[d]=`${f[d]} (Size)`),r.additionalStats["Unique count"]=c.trueCount.toString());const m=null!==(v=r.aggrColValues)&&void 0!==v?v:(0,l.I_)(t,n,{mask:c}),C=Object.assign(Object.assign(Object.assign({},r.additionalStats),f),m),y=(0,a.F2)(h,C);return i.tooltip.show(y,r.x,r.y),y}{const u=r.mpStats[r.monomerPosition.positionOrClusterType][r.monomerPosition.monomerOrCluster];if(!(null==u?void 0:u.count))return null;const c=o.BitSet.fromBytes(u.mask.buffer.buffer,e.length);c.and(t.filter);const h=(0,s.M1)((0,a.FZ)(e,c,t),!0),d=(0,s.QD)(u);r.fromViewer&&(d["Mean difference"]=`${d["Mean difference"]}${r.isMostPotentResidues?" (size)":""}`,d["p-value"]&&(d["p-value"]=`${d["p-value"]}${r.isMostPotentResidues?" (color)":""}`));const p=null!==(f=r.aggrColValues)&&void 0!==f?f:(0,l.I_)(t,n,{mask:c}),g=Object.assign(Object.assign(Object.assign({},r.additionalStats),d),p);for(const[t,e]of Object.entries(null!==(m=r.postfixes)&&void 0!==m?m:{}))g[t]&&(g[t]=`${g[t]}${e}`);const v=(0,a.F2)(h,g);return i.tooltip.show(v,r.x,r.y),r.fromViewer||setTimeout((()=>h.props.legendVisibility="Never"),100),v}}},115:(t,e,n)=>{"use strict";n.d(e,{GI:()=>a,Ku:()=>r,av:()=>s});var i=n(1199),o=n(4329);const r="WebGPU is not supported on this device";class s{constructor(){this.maxIterations=16,this.inflation=1.4,this.threshold=70,this.distanceF=i.Z.NEEDLEMANN_WUNSCH,this.gapOpen=1.5,this.gapExtend=.2,this.fingerprintType="Morgan",this.useWebGPU=!1,this.minClusterSize=5,this.webGPUDescription=r,this.webGPUDescriptionPromise=(0,o._)().then((t=>{t&&(this.webGPUDescription=t)}))}}class a{constructor(t){this.distanceF=i.Z.NEEDLEMANN_WUNSCH,this.gapOpen=1.5,this.gapExtend=.2,this.clusterEmbeddings=!0,this.epsilon=.01,this.minPts=4,this.fingerprintType="Morgan",this.clusterEmbeddings=!!t}}},5480:(t,e,n)=>{"use strict";n.d(e,{W:()=>S,s:()=>E});var i=n(7389),o=n(4328),r=n(6082),s=n(7233),a=n.n(s),l=n(9499),u=n(4139),c=n(3163),h=n(4326),d=n(5070),f=n(144),m=n.n(f),p=n(7654),g=n(8608),v=n(8774),C=n(3262),y=n(1458),w=n(3077),A=n(726);const b=(t,e)=>`${t}(${e})`;var S,T;!function(t){t.ORIGINAL="original",t.CUSTOM="custom"}(S||(S={})),function(t){t.GENERAL="General",t.STYLE="WebLogo",t.AGGREGATION="Aggregation"}(T||(T={}));class E extends r.JsViewer{constructor(){super(),this.bitsets=[],this.keyPress=!1,this.currentRowIndex=null,this._scaledActivityColumn=null,this._webLogoCacheGeneration=0,this._viewerGrid=null,this._clusterStats=null,this._clusterSelection=null,this._logoSummaryTable=null,this._positionColumns=null,this.root.classList.add("peptides-viewer-show-title"),this.sequenceColumnName=this.column("sequence",{category:T.GENERAL,nullable:!1}),this.clustersColumnName=this.column("clusters",{category:T.GENERAL,nullable:!1,columnTypeFilter:r.TYPE.CATEGORICAL}),this.activityColumnName=this.column("activity",{category:T.GENERAL,nullable:!1,columnTypeFilter:r.TYPE.NUMERICAL}),this.activityScaling=this.string("activityScaling",u.rg.NONE,{category:T.GENERAL,choices:Object.values(u.rg)}),this.webLogoMode=this.string("webLogoMode",h.fH.Entropy,{choices:[h.fH.full,h.fH.Entropy],category:T.STYLE}),this.membersRatioThreshold=this.float("membersRatioThreshold",.1,{min:0,max:1,category:T.STYLE});const t=[r.AGG.KEY,r.AGG.PIVOT,r.AGG.MISSING_VALUE_COUNT,r.AGG.SKEW,r.AGG.KURT,r.AGG.SELECTED_ROWS_COUNT],e=Object.values(r.AGG).filter((e=>!t.includes(e)));this.webLogoAggregationType=this.string("webLogoAggregationType",r.AGG.TOTAL_COUNT,{category:T.STYLE,choices:e,description:"Aggregation method for WebLogo position heights"}),this.webLogoAggregationColumnName=this.column("webLogoAggregationColumnName",{defaultValue:null,category:T.STYLE,nullable:!0,columnTypeFilter:r.TYPE.NUMERICAL,description:`Column with values to aggregate for WebLogo position heights.\n Used if aggregation type is not '${r.AGG.TOTAL_COUNT}'.`}),this.columns=this.columnList("columns",[],{category:T.AGGREGATION}),this.aggregation=this.string("aggregation",r.AGG.AVG,{category:T.AGGREGATION,choices:u.V5})}get model(){return l.i.getInstance(this.dataFrame)}get viewerGrid(){var t;return null!==(t=this._viewerGrid)&&void 0!==t||(this._viewerGrid=this.createLogoSummaryTableGrid()),this._viewerGrid}get clusterStats(){var t;return null!==(t=this._clusterStats)&&void 0!==t||(this._clusterStats=(0,y.eW)(this.dataFrame,this.clustersColumnName,this.customClusters.toArray(),this.getScaledActivityColumn())),this._clusterStats}get clusterSelection(){var t;return null!==(t=this._clusterSelection)&&void 0!==t||(this._clusterSelection=this.initClusterSelection({notify:!1})),this._clusterSelection}set clusterSelection(t){this._clusterSelection=t,this.model.fireBitsetChanged(l.q.LOGO_SUMMARY_TABLE),this.model.analysisView.grid.invalidate()}get logoSummaryTable(){var t;return null!==(t=this._logoSummaryTable)&&void 0!==t||(this._logoSummaryTable=this.createLogoSummaryTable()),this._logoSummaryTable}set logoSummaryTable(t){this._logoSummaryTable=t}get positionColumns(){var t,e,n,i;if(null!=this._positionColumns)return this._positionColumns;const o=t=>{const e=this.model.findViewer(t);return this.sequenceColumnName===(null==e?void 0:e.sequenceColumnName)?e._positionColumns:null};return null!=this.model.positionColumns&&this.sequenceColumnName===(null===(t=this.model.settings)||void 0===t?void 0:t.sequenceColumnName)&&(this._positionColumns=this.model.positionColumns),null!==(e=this._positionColumns)&&void 0!==e||(this._positionColumns=null!==(i=null!==(n=o(l.q.SEQUENCE_VARIABILITY_MAP))&&void 0!==n?n:o(l.q.MOST_POTENT_RESIDUES))&&void 0!==i?i:(0,w.R)(this.dataFrame.getCol(this.sequenceColumnName),A.Z.getSeqHelper()).columns.toList()),this._positionColumns}get isClusterSelectionEmpty(){return 0===this.clusterSelection[S.ORIGINAL].length+this.clusterSelection[S.CUSTOM].length}get customClusters(){const t={};return t[u.gp.CUSTOM_CLUSTER]="1",m()(this.dataFrame.columns.byTags(t))}getScaledActivityColumn(t=!1){var e,n,i;return(null===(e=this.model.settings)||void 0===e?void 0:e.activityColumnName)===this.activityColumnName&&(null===(n=this.model.settings)||void 0===n?void 0:n.activityScaling)===this.activityScaling&&(this._scaledActivityColumn=this.model.getScaledActivityColumn(t)),null!==(i=this._scaledActivityColumn)&&void 0!==i||(this._scaledActivityColumn=(0,g.Y1)(this.dataFrame.getCol(this.activityColumnName),this.activityScaling)),t?r.DataFrame.fromColumns([this._scaledActivityColumn]).clone(this.dataFrame.rowCount===this._scaledActivityColumn.length?this.dataFrame.filter:null).getCol(this._scaledActivityColumn.name):this._scaledActivityColumn}getAggregationColumns(){return Object.fromEntries(this.columns.map((t=>[t,this.aggregation])).filter((([t,e])=>this.model.df.columns.contains(t)&&this.model.df.col(t).matches("numerical"))))}onTableAttached(){var t,e,n,i,s,a,l,c,h,d,f,p,v;if(super.onTableAttached(),(0,g.B2)(this.dataFrame)){const o=null===(t=m()(this.dataFrame.columns.numerical).filter((t=>{var e;return null===(e=t.name)||void 0===e?void 0:e.includes("activ")})).take(1).toArray()[0])||void 0===t?void 0:t.name,g=null!=o?o:null===(n=null===(e=m()(this.dataFrame.columns.numerical).take(1).toArray())||void 0===e?void 0:e[0])||void 0===n?void 0:n.name,C=this.dataFrame.columns.bySemType(r.SEMTYPE.MACROMOLECULE);C&&(null===(i=this.getProperty(`sequence${u.To}`))||void 0===i||i.set(this,C.name)),g&&(null===(s=this.getProperty(`activity${u.To}`))||void 0===s||s.set(this,g),null===(a=this.getProperty("webLogoAggregationColumnName"))||void 0===a||a.set(this,g));const y=null===(h=null===(c=null===(l=m()(this.dataFrame.columns).filter((t=>{var e;return t.isCategorical&&(null===(e=t.name)||void 0===e?void 0:e.toLowerCase().includes("cluster"))&&t.name!=(null==C?void 0:C.name)&&t.type!==r.COLUMN_TYPE.BOOL})))||void 0===l?void 0:l.take(1))||void 0===c?void 0:c.toArray())||void 0===h?void 0:h[0],w=null!=y?y:null===(p=null===(f=null===(d=m()(this.dataFrame.columns.categorical).filter((t=>t.name!=(null==C?void 0:C.name)&&t.categories.length<=50&&t.type!==r.COLUMN_TYPE.BOOL)))||void 0===d?void 0:d.take(1))||void 0===f?void 0:f.toArray())||void 0===p?void 0:p[0];w&&(null===(v=this.getProperty(`clusters${u.To}`))||void 0===v||v.set(this,w.name))}else{const t="PeptidesError: dataframe is missing Macromolecule or numeric columns";o.log.error(t),o.shell.warning(t)}this.render()}detach(){this.subs.forEach((t=>t.unsubscribe()))}render(){if(a()(this.root).empty(),null==this.clustersColumnName||null==this.sequenceColumnName||null==this.activityColumnName)return void this.root.appendChild(i.divText("Please, select a sequence, cluster and activity columns in the viewer properties"));if(!this.logoSummaryTable.filter.anyTrue){const t=i.divText("No clusters to satisfy the threshold. Please, lower the threshold in viewer proeperties to include clusters");return void this.root.appendChild(i.divV([t]))}const t=i.iconFA("expand-alt",(()=>{const t=i.dialog("Logo Summary Table");t.add(this.viewerGrid.root),t.onCancel((()=>this.render())),t.showModal(!0),this.viewerGrid.invalidate()}),"Show Logo Summary Table in full screen");a()(t).addClass("pep-help-icon"),this.viewerGrid.root.style.width="auto",this.viewerGrid.root.style.height="auto",this.viewerGrid.root.style.overflow="hidden",this.root.appendChild(i.divV([i.divH([t],{style:{alignSelf:"center",lineHeight:"normal"}}),this.viewerGrid.root])),this.viewerGrid.invalidate()}onPropertyChanged(t){super.onPropertyChanged(t);let e=!1;switch(t.name){case"membersRatioThreshold":this.logoSummaryTable.filter.anyTrue||(e=!0),this.updateFilter();break;case`sequence${u.To}`:this._viewerGrid=null,this._logoSummaryTable=null,e=!0;break;case`clusters${u.To}`:this._clusterStats=null,this._clusterSelection=null,this._viewerGrid=null,this._logoSummaryTable=null,e=!0;break;case`activity${u.To}`:this.webLogoAggregationColumnName=this.activityColumnName;case"activityScaling":case`webLogoAggregationColumnName${u.To}`:case"webLogoAggregationType":this._webLogoCacheGeneration++,this._scaledActivityColumn=null,this._viewerGrid=null,this._clusterStats=null,this._logoSummaryTable=null,e=!0;break;case"columns":case"aggregation":this._viewerGrid=null,this._logoSummaryTable=null,e=!0;break;case"webLogoMode":this.viewerGrid.invalidate()}e&&this.render()}initClusterSelection(t={}){var e;null!==(e=t.notify)&&void 0!==e||(t.notify=!0);const n={};return n[S.ORIGINAL]=[],n[S.CUSTOM]=[],t.notify?this.clusterSelection=n:this._clusterSelection=n,this.clusterSelection}getTotalViewerAggColumns(){var t,e;const n=this.getAggregationColumns();return(0,g.zm)(this.model.df,this.columns,n,null===(e=null===(t=this.model)||void 0===t?void 0:t.settings)||void 0===e?void 0:e.columns)}getStringAggregatedColumns(){return this.columns.filter((t=>this.model.df.columns.contains(t)&&this.model.df.col(t).matches("categorical"))).map((t=>`dist(${t})`))}getNeededDfClone(){var t,e;const n=[this.clustersColumnName,this.sequenceColumnName,this.activityColumnName,...(null!==(t=this.getTotalViewerAggColumns())&&void 0!==t?t:[]).map((([t,e])=>t)),...(null!==(e=this.getStringAggregatedColumns())&&void 0!==e?e:[]).map((t=>t.substring(5,t.length-1)))];this.webLogoAggregationColumnName&&n.push(this.webLogoAggregationColumnName);const i=Array.from(new Set(n)).filter((t=>this.dataFrame.columns.contains(t)));return this.dataFrame.clone(this.dataFrame.filter,i)}createLogoSummaryTable(){var t,e,n;const i=this.clustersColumnName,o=this.dataFrame.filter.anyFalse,s=o?this.getNeededDfClone():this.dataFrame,a=s.columns,l=s.rowCount,c=this.getScaledActivityColumn(o).getRawData(),h=s.getCol(i),f=h.getRawData(),p=h.categories,g={};g[u.gp.CUSTOM_CLUSTER]="1";const C=m()(a.byTags(g)).filter((t=>t.max>0)).toArray(),y=r.DataFrame.create(C.length),w=y.columns,A=w.addNewString(u.i6.CLUSTER),T=w.addNewInt(u.i6.MEMBERS).getRawData(),E=w.addNewString(u.i6.WEB_LOGO),_=w.addNewString(u.i6.DISTRIBUTION),N=w.addNewFloat(u.i6.MEAN_DIFFERENCE).getRawData(),x=w.addNewFloat(u.i6.P_VALUE).getRawData(),M=w.addNewFloat(u.i6.RATIO).getRawData();let I=s.groupBy([i]);const O=this.getTotalViewerAggColumns(),L=this.getStringAggregatedColumns(),P=L.map((t=>w.addNewString(t))),R=O.map((([t,e])=>b(e,t))),k=new Array(R.length+L.length),V=O.map((([t,e])=>[s.getCol(t),e]));for(let t=0;t<O.length;++t){const[e,n]=O[t];I=I.add(n,e,R[t]);const i=w.addNewFloat(R[t]);k[t]=i.getRawData()}const F=new Array(C.length);for(let e=0;e<C.length;++e){const n=C[e];A.set(e,n.name);const i=v.A.fromUint32Array(l,n.getRawData());if(i.allFalse)continue;const a=r.BitSet.fromBytes(i.buffer.buffer,l),u=o?(0,d.GT)(c,i):this.clusterStats[S.CUSTOM][n.name];T[e]=u.count,F[e]=a,N[e]=u.meanDifference,x[e]=null!==(t=u.pValue)&&void 0!==t?t:r.FLOAT_NULL,M[e]=u.ratio;for(let t=0;t<R.length;++t){const[n,i]=V[t];k[t][e]=(0,d.lh)(n,i,a)}for(let t=R.length;t<k.length;++t){const n=L[t-R.length];P[t-R.length].set(e,(0,d.J1)(s,n,a))}}E.setTag(r.TAGS.CELL_RENDERER,"html"),_.setTag(r.TAGS.CELL_RENDERER,"html");const D=I.aggregate(),G=D.rowCount,U=D.columns;let q=D.getCol(i);q.name=u.i6.CLUSTER,q.type!==r.COLUMN_TYPE.STRING&&(D.columns.replace(q,q.convertTo(r.COLUMN_TYPE.STRING)),q=D.getCol(q.name));const B=q.categories,H=U.addNewInt(u.i6.MEMBERS).getRawData(),Y=U.addNewString(u.i6.WEB_LOGO),j=U.addNewString(u.i6.DISTRIBUTION),W=U.addNewFloat(u.i6.MEAN_DIFFERENCE).getRawData(),$=U.addNewFloat(u.i6.P_VALUE).getRawData(),z=U.addNewFloat(u.i6.RATIO).getRawData(),K=L.map((t=>U.addNewString(t))),Z=new Array(G),Q=Array.from({length:G},(()=>new v.A(l,!1)));for(let t=0;t<l;++t){const n=p[f[t]];null===(e=Q[B.indexOf(n)])||void 0===e||e.setTrue(t)}for(let t=0;t<G;++t){const e=Q[t];if(e.allFalse)continue;const i=r.BitSet.fromBytes(e.buffer.buffer,l),a=o?(0,d.GT)(c,e):this.clusterStats[S.ORIGINAL][B[t]];for(let e=0;e<L.length;++e){const n=L[e];K[e].set(t,(0,d.J1)(s,n,i))}H[t]=a.count,Z[t]=i,W[t]=a.meanDifference,$[t]=null!==(n=a.pValue)&&void 0!==n?n:r.FLOAT_NULL,z[t]=a.ratio}Y.setTag(r.TAGS.CELL_RENDERER,"html"),j.setTag(r.TAGS.CELL_RENDERER,"html");const X=D.append(y);return this.bitsets=Z.concat(F),L.forEach((t=>X.col(t).semType="lst-pie-chart")),X}createLogoSummaryTableGrid(){const t=this.dataFrame.filter.anyFalse,e=t?this.getNeededDfClone():this.dataFrame,n=this.getTotalViewerAggColumns().map((([t,e])=>b(e,t))),i=this.logoSummaryTable.plot.grid();i.sort([u.i6.MEMBERS],[!1]),this.updateFilter(),i.col(u.i6.CLUSTER).visible=!0,i.columns.setOrder([u.i6.CLUSTER,u.i6.MEMBERS,u.i6.WEB_LOGO,...this.getStringAggregatedColumns(),u.i6.DISTRIBUTION,u.i6.MEAN_DIFFERENCE,u.i6.P_VALUE,u.i6.RATIO,...n]),i.columns.rowHeader.visible=!1,i.props.rowHeight=55;const o=new r.LruCache,s=new Map;let d=null;const f=new r.LruCache,m=this.positionColumns.length,p=i.columns.byName(u.i6.WEB_LOGO);p.cellType="html",p.width=350;const v=this.getScaledActivityColumn(t),C=e.getCol(this.sequenceColumnName);i.onCellRender.subscribe((t=>{var e,n,l;const p=t.cell,y=p.tableRowIndex;if(!p.isTableCell||null==y||-1===y)return;const w=t.g,A=t.bounds;w.save(),w.beginPath(),w.rect(A.x,A.y,A.width,A.height),w.clip();try{const b=Math.max(p.bounds.height-2,0),S=this.bitsets[y];if((null===(e=p.tableColumn)||void 0===e?void 0:e.name)===u.i6.CLUSTER)c.k8(w,p.cell.value,this.clusterSelection,A),t.preventDefault();else if((null===(n=p.tableColumn)||void 0===n?void 0:n.name)===u.i6.WEB_LOGO){const e=`${y}_${this.webLogoAggregationColumnName||"count"}_${this.webLogoAggregationType}_${this._webLogoCacheGeneration}`,n=o.get(e);if(!0===s.get(e))return void t.preventDefault();const l=Math.floor((p.bounds.width-2-4*(m-1))/m);if(void 0!==n){const e=n.getProperties();for(const t of e)"positionHeight"===t.name&&t.get(n)!==this.webLogoMode?t.set(n,this.webLogoMode):"positionWidth"===t.name&&t.get(n)!==l?t.set(n,l):"minHeight"===t.name&&t.get(n)!==b&&t.set(n,b);a()(n.root).css("height",`${b}px`).children().first().css("overflow-y","hidden !important"),n.root.style.height=`${b}px`,p.element=n.root,t.preventDefault()}else{const n=[C];if(this.webLogoAggregationType!==r.AGG.TOTAL_COUNT&&this.webLogoAggregationColumnName){const t=this.dataFrame.columns.byName(this.webLogoAggregationColumnName);t&&n.push(t)}const a=r.DataFrame.fromColumns(n);a.filter.copyFrom(S),s.set(e,!0),a.plot.fromType("WebLogo",{valueColumnName:this.webLogoAggregationColumnName,valueAggrType:this.webLogoAggregationType,positionHeight:this.webLogoMode,horizontalAlignment:h.P4.LEFT,maxHeight:1e3,minHeight:b,positionWidth:l,showPositionLabels:!1}).then((t=>{o.set(e,t),s.delete(e),d&&clearTimeout(d),d=setTimeout((()=>i.invalidate()),200)})),t.preventDefault()}}else if((null===(l=p.tableColumn)||void 0===l?void 0:l.name)===u.i6.DISTRIBUTION){let e=f.get(y);void 0===e&&(v.dataFrame||r.DataFrame.fromColumns([v]),e=(0,g.FZ)(v,S,v.dataFrame).plot.histogram({filteringEnabled:!1,valueColumnName:v.name,splitColumnName:u.$2.SPLIT_COL,legendVisibility:"Never",showXAxis:!1,showColumnSelector:!1,showRangeSlider:!1,showBinSelector:!1,backColor:r.Color.toHtml(r.Color.white),xAxisHeight:1,showSplitSelector:!1}),e.root.style.width="auto",f.set(y,e)),e.root.style.height=`${b}px`,p.element=e.root,t.preventDefault()}}finally{w.restore()}})),i.root.addEventListener("mouseleave",(t=>this.model.unhighlight())),r.debounce(i.onCurrentCellChanged,500).subscribe((t=>{var e;if(!t.isTableCell||-1===t.gridRow)return this.initClusterSelection({notify:!1}),this.model.fireBitsetChanged(l.q.LOGO_SUMMARY_TABLE),void i.invalidate();try{if(!this.keyPress||(null===(e=t.tableColumn)||void 0===e?void 0:e.name)!==u.i6.CLUSTER)return;null!==this.currentRowIndex&&-1!==this.currentRowIndex&&this.modifyClusterSelection(this.getCluster(i.cell(u.i6.CLUSTER,this.currentRowIndex)),{shiftPressed:!0,ctrlPressed:!0},!1),this.modifyClusterSelection(this.getCluster(t),{shiftPressed:!0,ctrlPressed:!1}),i.invalidate()}finally{this.keyPress=!1,this.currentRowIndex=t.gridRow}})),i.root.addEventListener("keydown",(t=>{if(this.keyPress=t.key.startsWith("Arrow"),!this.keyPress){if("Escape"===t.key||"KeyA"===t.code&&t.shiftKey&&t.ctrlKey)this.initClusterSelection({notify:!1});else if("KeyA"===t.code&&t.ctrlKey)for(let t=0;t<this.logoSummaryTable.rowCount;++t)this.modifyClusterSelection(this.getCluster(i.cell(u.i6.CLUSTER,t)),{shiftPressed:!0,ctrlPressed:!1},!1);this.model.fireBitsetChanged(l.q.LOGO_SUMMARY_TABLE),i.invalidate()}})),i.root.addEventListener("click",(t=>{var e;const n=i.hitTest(t.offsetX,t.offsetY);if(!n||!n.isTableCell||(null===(e=n.tableColumn)||void 0===e?void 0:e.name)!==u.i6.CLUSTER)return;const o=this.getCluster(n);this.modifyClusterSelection(o,{shiftPressed:t.shiftKey,ctrlPressed:t.ctrlKey}),i.invalidate()})),i.onCellTooltip(((t,e,n)=>{var i;if(!t.isTableCell)return this.model.unhighlight(),!0;const o=this.getCluster(t);return this.highlightCluster(o),(null===(i=t.tableColumn)||void 0===i?void 0:i.name)===u.i6.CLUSTER&&this.showTooltip(o,e,n),!0}));const y=i.props;return y.allowEdit=!1,y.allowRowSelection=!1,y.allowBlockSelection=!1,y.allowColSelection=!1,y.showCurrentRowIndicator=!1,y.showReadOnlyNotifications=!1,i}highlightCluster(t){const e=this.clusterStats[t.positionOrClusterType][t.monomerOrCluster].mask;this.dataFrame.rows.highlight((t=>e.getBit(t))),this.model.isHighlighting=!0}getCluster(t){const e=this.logoSummaryTable.get(u.i6.CLUSTER,t.tableRowIndex);return{positionOrClusterType:this.dataFrame.getCol(this.clustersColumnName).categories.includes(e)?S.ORIGINAL:S.CUSTOM,monomerOrCluster:e}}updateFilter(){const t=this.logoSummaryTable.getCol(u.i6.MEMBERS),e=this.logoSummaryTable.getCol(u.i6.CLUSTER),n=e.getRawData(),i=e.categories,o=i.indexOf("-1"),r=t.getRawData();let s=0;r.forEach(((t,e)=>{"-1"!==i[n[e]]&&(s=Math.max(s,r[e]))}));const a=Math.ceil(s*this.membersRatioThreshold);this.logoSummaryTable.filter.init((t=>r[t]>a&&(-1===o||"-1"!==i[n[t]])))}clusterFromSelection(){const t=this.model.getVisibleSelection(),e=this.logoSummaryTable.columns,n=e.length,i=new Array(e.length),o=this.getScaledActivityColumn(),r=(0,d.pY)(t),s=(0,d.GT)(o.getRawData(),r,(0,d.pY)(this.dataFrame.filter));this.bitsets.push(t.clone());const a=this.dataFrame.columns.getUnusedName("New Cluster"),l={},c={},h=this.getTotalViewerAggColumns(),f=this.getStringAggregatedColumns();for(const[e,n]of h){const i=b(n,e),o=this.dataFrame.getCol(e);l[i]=(0,d.lh)(o,n,t)}for(const e of f)c[e]=(0,d.J1)(this.dataFrame,e,t);for(let o=0;o<n;++o){const n=e.byIndex(o);i[o]=n.name===u.i6.CLUSTER?a:n.name===u.i6.MEMBERS?t.trueCount:n.name===u.i6.WEB_LOGO||n.name===u.i6.DISTRIBUTION?null:n.name===u.i6.MEAN_DIFFERENCE?s.meanDifference:n.name===u.i6.P_VALUE?s.pValue:n.name===u.i6.RATIO?s.ratio:n.name in l?l[n.name]:n.name in c?c[n.name]:void 0,void 0===i[o]&&C._package.logger.warning(`PeptidesLSTWarn: value for column ${n.name} is undefined`)}this.logoSummaryTable.rows.addNew(i),this.clusterStats[S.CUSTOM][a]=s,this.addNewCluster(a)}removeCluster(){const t=this.clusterSelection[S.CUSTOM];if(0===t.length)return void o.shell.warning("No custom clusters selected to be removed");const e=this.logoSummaryTable.rows,n=this.logoSummaryTable.getCol(u.i6.CLUSTER),i=n.categories,r=this.dataFrame.columns;for(const n of t){t.splice(t.indexOf(n),1),r.remove(n),delete this.clusterStats[S.CUSTOM][n];const o=i.indexOf(n);e.removeAt(o),this.bitsets.splice(o,1)}n.compact(),this.clusterSelection[S.CUSTOM]=t,this.render()}addNewCluster(t){const e=r.Column.fromBitSet(t,this.model.getVisibleSelection());e.setTag(u.gp.CUSTOM_CLUSTER,"1"),e.setTag(u.gp.ANALYSIS_COL,"true"),this.dataFrame.columns.add(e),this.model.analysisView.grid.col(e.name).visible=!1}modifyClusterSelection(t,e={shiftPressed:!1,ctrlPressed:!1},n=!0){n?this.clusterSelection=(0,g.vW)(this.clusterSelection,t,e):this._clusterSelection=(0,g.vW)(this.clusterSelection,t,e)}showTooltip(t,e,n){const o=this.dataFrame.filter,s=o.anyFalse?this.getNeededDfClone():this.dataFrame,a=s.rowCount,l=new v.A(a,!1),u=this.getScaledActivityColumn(o.anyFalse),c=u.getRawData();if(t.positionOrClusterType===S.ORIGINAL){const e=s.getCol(this.clustersColumnName),n=e.getRawData(),i=e.categories.indexOf(t.monomerOrCluster);for(let t=0;t<a;++t)n[t]===i&&l.setTrue(t);l.incrementVersion()}else{const e=s.getCol(t.monomerOrCluster);l.buffer=e.getRawData()}const h=o.anyFalse?(0,d.GT)(c,l):this.clusterStats[t.positionOrClusterType][t.monomerOrCluster];if(!h.count)return null;const f=r.BitSet.fromBytes(l.buffer.buffer,a);u.dataFrame||r.DataFrame.fromColumns([u]);const m=(0,g.FZ)(u,f,u.dataFrame),C=(0,p.M1)(m,!0),y=(0,p.QD)(h),w=(0,d.I_)(this.dataFrame,this.getTotalViewerAggColumns(),{filterDf:!0,mask:f}),A=Object.assign(Object.assign({},y),w),b=(0,g.F2)(C,A);return i.tooltip.show(b,e,n),b}createWebLogoDf(t,e){const n=r.DataFrame.fromColumns([t]);return n.filter.copyFrom(e),n}}},3541:(t,e,n)=>{"use strict";n.d(e,{J:()=>M,UJ:()=>I});var i,o,r,s,a=n(4328),l=n(7389),u=n(6082),c=n(7233),h=n.n(c),d=n(4139),f=n(3163),m=n(9499),p=n(144),g=n.n(p),v=n(5070),C=n(912),y=n(1458),w=n(8608),A=n(3077),b=n(439),S=n(2003),T=n(4971),E=n(726),_=n(4025),N=function(t,e,n,i){return new(n||(n=Promise))((function(o,r){function s(t){try{l(i.next(t))}catch(t){r(t)}}function a(t){try{l(i.throw(t))}catch(t){r(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(s,a)}l((i=i.apply(t,e||[])).next())}))};!function(t){t.MUTATION_CLIFFS="Mutation Cliffs",t.INVARIANT_MAP="Invariant Map"}(i||(i={})),function(t){t.SEQUENCE="sequence",t.ACTIVITY="activity",t.ACTIVITY_SCALING="activityScaling",t.TARGET="target",t.TARGET_CATEGORY="targetCategory",t.MIN_ACTIVITY_DELTA="minActivityDelta",t.MAX_MUTATIONS="maxMutations",t.COLUMNS="columns",t.AGGREGATION="aggregation",t.ACTIVITY_TARGET="activityTarget",t.VALUE_INVARIANT_MAP="value",t.AGGREGATION_INVARIANT_MAP_VALUE="valueAggregation",t.DATA_SOURCE="dataSource"}(o||(o={})),function(t){t.COLOR="color",t.COLOR_AGGREGATION="colorAggregation",t.CUSTOM_COLOR_RANGE="customColorRange",t.MIN_COLOR_VALUE="minColorValue",t.MAX_COLOR_VALUE="maxColorValue",t.LOWER_BOUND_COLOR="lowerBoundColor",t.MIDDLE_COLOR="middleColor",t.UPPER_BOUND_COLOR="upperBoundColor",t.LOG_SCALE_COLOR="logScaleColor",t.SHOW_FILTER_CONTROLS="showFilterControls",t.SHOW_TOTAL_COUNT_COLUMN="showTotalCountColumn"}(r||(r={})),function(t){t.GENERAL="General",t.INVARIANT_MAP="Invariant Map",t.MUTATION_CLIFFS="Mutation Cliffs",t.AGGREGATION="Aggregation"}(s||(s={}));class x extends u.JsViewer{constructor(){super(),this.keyPressed=!1,this._scaledActivityColumn=null,this.doRender=!0,this.dataSource="Filtered",this._viewerGrid=null,this._positionColumns=null,this._monomerPositionStats=null,this._mutationCliffs=null,this._mutationCliffStats=null,this._invariantMapSelection=null,this._mutationCliffsSelection=null,this._monomerMetaColumns=new Set,this.sequenceColumnName=this.column(o.SEQUENCE,{category:s.GENERAL,semType:u.SEMTYPE.MACROMOLECULE,nullable:!1}),this.dataSource=this.string(o.DATA_SOURCE,"Filtered",{category:s.GENERAL,choices:["All","Filtered"],nullable:!1,description:"Data source for calculations and rendering. Can be set to whole data set or filtered data only."}),this.activityColumnName=this.column(o.ACTIVITY,{category:s.GENERAL,nullable:!1,columnTypeFilter:"numerical"}),this.activityScaling=this.string(o.ACTIVITY_SCALING,d.rg.NONE,{category:s.GENERAL,choices:Object.values(d.rg),nullable:!1}),this.activityTarget=this.string(o.ACTIVITY_TARGET,d.wf.HIGH,{category:s.GENERAL,choices:Object.values(d.wf),nullable:!1}),this.targetColumnName=this.column(o.TARGET,{category:s.GENERAL,nullable:!0,columnTypeFilter:"categorical",userEditable:!1}),this.minActivityDelta=this.float(o.MIN_ACTIVITY_DELTA,0,{category:s.MUTATION_CLIFFS,min:0,max:100}),this.maxMutations=this.int(o.MAX_MUTATIONS,1,{category:s.MUTATION_CLIFFS,min:1,max:20}),this.columns=this.columnList(o.COLUMNS,[],{category:s.AGGREGATION}),this.aggregation=this.string(o.AGGREGATION,u.AGG.AVG,{category:s.AGGREGATION,choices:d.V5}),this.valueColumnName=this.column(o.VALUE_INVARIANT_MAP,{category:s.INVARIANT_MAP,userEditable:!0,nullable:!1,columnTypeFilter:"numerical"}),this.valueAggregation=this.string(o.AGGREGATION_INVARIANT_MAP_VALUE,u.AGG.TOTAL_COUNT,{category:s.INVARIANT_MAP,choices:d.V5,userEditable:!0,nullable:!1}),this.mutationCliffsDebouncer=(0,w.sg)(((t,e,n)=>N(this,void 0,void 0,(function*(){return yield(0,y.uz)(t,e,n)})))),this.root.classList.add("peptides-viewer-show-title")}get viewerGrid(){var t;return null!==(t=this._viewerGrid)&&void 0!==t||(this._viewerGrid=this.createViewerGrid()),this._viewerGrid}render(){}get alphabet(){var t;return null!==(t=this.dataFrame.getCol(this.sequenceColumnName).getTag(b.gp.alphabet))&&void 0!==t?t:S.YI.UN}get model(){return m.i.getInstance(this.dataFrame)}get positionColumns(){var t,e,n;if(null!=this._positionColumns)return this._positionColumns;const i=t=>{const e=this.model.findViewer(t);return this.sequenceColumnName===(null==e?void 0:e.sequenceColumnName)?e._positionColumns:null};return null!=this.model.positionColumns&&this.sequenceColumnName===(null===(t=this.model.settings)||void 0===t?void 0:t.sequenceColumnName)?this._positionColumns=this.model.positionColumns:this instanceof M?this._positionColumns=i(m.q.MOST_POTENT_RESIDUES):this instanceof I&&(this._positionColumns=i(m.q.SEQUENCE_VARIABILITY_MAP)),null!==(e=this._positionColumns)&&void 0!==e||(this._positionColumns=null!==(n=i(m.q.LOGO_SUMMARY_TABLE))&&void 0!==n?n:(0,A.R)(this.dataFrame.getCol(this.sequenceColumnName),E.Z.getSeqHelper()).columns.toList()),this._positionColumns}get monomerPositionStats(){var t;if(null!=this._monomerPositionStats)return this._monomerPositionStats;const e=t=>this.sequenceColumnName===(null==t?void 0:t.sequenceColumnName)&&this.activityColumnName===(null==t?void 0:t.activityColumnName)&&this.activityScaling===(null==t?void 0:t.activityScaling)&&t instanceof x&&t.dataSource===this.dataSource&&(t instanceof x&&this.valueColumnName==(null==t?void 0:t.valueColumnName)&&this.valueAggregation==(null==t?void 0:t.valueAggregation)||!(t instanceof x)&&(!this.valueColumnName||!this.valueAggregation||this.valueAggregation==u.AGG.VALUE_COUNT||this.valueAggregation==u.AGG.TOTAL_COUNT)),n=t=>{const n=this.model.findViewer(t);return e(n)?n._monomerPositionStats:null};null!==this.model.monomerPositionStats&&e(this.model.settings)?this._monomerPositionStats=this.model.monomerPositionStats:this instanceof M?this._monomerPositionStats=n(m.q.MOST_POTENT_RESIDUES):this instanceof I&&(this._monomerPositionStats=n(m.q.SEQUENCE_VARIABILITY_MAP));const i=this.dataFrame.col(this.valueColumnName),o=this.valueAggregation;return null!==(t=this._monomerPositionStats)&&void 0!==t||(this._monomerPositionStats=(0,y.Ej)(this.getScaledActivityColumn(),this.dataFrame.filter,this.positionColumns,{isFiltered:"Filtered"===this.dataSource&&this.dataFrame.filter.anyFalse,aggValue:o&&i?{col:i,type:o}:void 0})),this._monomerPositionStats}get mutationCliffs(){if(null!=this._mutationCliffs)return this._mutationCliffs;const t=t=>{const e=this.model.findViewer(t);return i=e,(n=this).sequenceColumnName===(null==i?void 0:i.sequenceColumnName)&&n.activityColumnName===(null==i?void 0:i.activityColumnName)&&n.activityScaling===(null==i?void 0:i.activityScaling)&&n.minActivityDelta===(null==i?void 0:i.minActivityDelta)&&n.maxMutations===(null==i?void 0:i.maxMutations)&&(null==n?void 0:n.dataSource)===(null==i?void 0:i.dataSource)?e._mutationCliffs:null;var n,i};return this instanceof M?this._mutationCliffs=t(m.q.MOST_POTENT_RESIDUES):this instanceof I&&(this._mutationCliffs=t(m.q.SEQUENCE_VARIABILITY_MAP)),this._mutationCliffs}set mutationCliffs(t){this._mutationCliffs=t,this.viewerGrid.invalidate()}get cliffStats(){if(!this._mutationCliffStats&&this.mutationCliffs&&this.activityColumnName&&this.sequenceColumnName&&this.dataFrame.col(this.activityColumnName)){const t=this.dataFrame.col(this.activityColumnName).getRawData();this._mutationCliffStats=(0,y.Lw)(this.mutationCliffs,t)}return this._mutationCliffStats}set cliffStats(t){this._mutationCliffStats=t,this.viewerGrid.invalidate()}get mutationCliffsSelection(){var t;return null!==(t=this._mutationCliffsSelection)&&void 0!==t||(this._mutationCliffsSelection=(0,w.ZR)(this.positionColumns)),this._mutationCliffsSelection}set mutationCliffsSelection(t){var e,n;this._mutationCliffsSelection=t,this.model.fireBitsetChanged(this instanceof M?m.q.SEQUENCE_VARIABILITY_MAP:m.q.MOST_POTENT_RESIDUES);const i=this.model.findViewer(m.q.SEQUENCE_VARIABILITY_MAP);null===(e=null==i?void 0:i.viewerGrid)||void 0===e||e.invalidate();const o=this.model.findViewer(m.q.MOST_POTENT_RESIDUES);null===(n=null==o?void 0:o.viewerGrid)||void 0===n||n.invalidate(),this.model.analysisView.grid.invalidate()}getScaledActivityColumn(t=!1){var e,n,i;return(null===(e=this.model.settings)||void 0===e?void 0:e.activityColumnName)===this.activityColumnName&&(null===(n=this.model.settings)||void 0===n?void 0:n.activityScaling)===this.activityScaling&&(this._scaledActivityColumn=this.model.getScaledActivityColumn(t)),null!==(i=this._scaledActivityColumn)&&void 0!==i||(this._scaledActivityColumn=(0,w.Y1)(this.dataFrame.getCol(this.activityColumnName),this.activityScaling)),t?u.DataFrame.fromColumns([this._scaledActivityColumn]).clone(this.dataFrame.filter).getCol(this._scaledActivityColumn.name):this._scaledActivityColumn}modifyMutationCliffsSelection(t,e={shiftPressed:!1,ctrlPressed:!1},n=!0){n?this.mutationCliffsSelection=(0,w.vW)(this.mutationCliffsSelection,t,e):this._mutationCliffsSelection=(0,w.vW)(this.mutationCliffsSelection,t,e)}modifyInvariantMapSelection(t,e={shiftPressed:!1,ctrlPressed:!1},n=!0){n?this.invariantMapSelection=(0,w.vW)(this.invariantMapSelection,t,e):this._invariantMapSelection=(0,w.vW)(this.invariantMapSelection,t,e)}get invariantMapSelection(){var t;return null!==(t=this._invariantMapSelection)&&void 0!==t||(this._invariantMapSelection=(0,w.ZR)(this.positionColumns)),this._invariantMapSelection}set invariantMapSelection(t){this._invariantMapSelection=t,this.model.fireBitsetChanged(m.q.SEQUENCE_VARIABILITY_MAP),this.model.analysisView.grid.invalidate()}onPropertyChanged(t){switch(super.onPropertyChanged(t),this.doRender=!0,t.name){case`${o.SEQUENCE}${d.To}`:this._positionColumns=null,this._monomerPositionStats=null,this._mutationCliffs=null,this._mutationCliffStats=null,this._mutationCliffsSelection=null,this._viewerGrid=null;break;case`${o.ACTIVITY}${d.To}`:case o.ACTIVITY_SCALING:this._monomerPositionStats=null,this._mutationCliffs=null,this._mutationCliffStats=null,this._mutationCliffsSelection=null,this._viewerGrid=null,this._scaledActivityColumn=null;break;case`${o.VALUE_INVARIANT_MAP}${d.To}`:case o.AGGREGATION_INVARIANT_MAP_VALUE:this._monomerPositionStats=null,this._viewerGrid=null,this._invariantMapSelection=null;break;case o.MIN_ACTIVITY_DELTA:case o.MAX_MUTATIONS:this._mutationCliffs=null,this._mutationCliffStats=null,this._mutationCliffsSelection=null,this.doRender=!1;break;case o.COLUMNS:case o.AGGREGATION:this instanceof I&&(this._viewerGrid=null);break;case o.ACTIVITY_TARGET:(this instanceof I||this instanceof M)&&(this._viewerGrid=null);break;case o.DATA_SOURCE:this.onFilterChanged(!1,!1),this.doRender=!0}null===this._mutationCliffs&&this.sequenceColumnName&&this.activityColumnName&&this.dataFrame&&this.calculateMutationCliffs().then((t=>{this.mutationCliffs=t.cliffs,this.cliffStats=t.cliffStats}))}getAggregationColumns(){return Object.fromEntries(this.columns.map((t=>[t,this.aggregation])).filter((([t,e])=>this.model.df.columns.contains(t)&&this.model.df.col(t).matches("numerical"))))}getTotalViewerAggColumns(){var t,e;const n=this.getAggregationColumns();return(0,w.zm)(this.model.df,this.columns,n,null===(e=null===(t=this.model)||void 0===t?void 0:t.settings)||void 0===e?void 0:e.columns)}createViewerGrid(){throw new Error("Not implemented")}exportMutationCliffs(){if(!this.mutationCliffs)return void a.shell.warning("Mutation cliffs have not been calculated yet.");const t=this.dataFrame.columns.toList().filter((t=>t.name!==this.activityColumnName&&t.name!==this.sequenceColumnName&&!this.positionColumns.some((e=>e.name===t.name)))).map((t=>t.name)),e=l.input.columns("Extra columns",{table:this.dataFrame,value:[],available:t,nullable:!0});l.dialog("Export Mutation Cliffs").add(e.root).onOK((()=>{var t;return this._doExportMutationCliffs(null!==(t=e.value)&&void 0!==t?t:[])})).show()}_doExportMutationCliffs(t){var e;const n=this.mutationCliffs,i=this.dataFrame.getCol(this.sequenceColumnName),o=i.categories,r=i.getRawData(),s=this.dataFrame.getCol(this.activityColumnName),l=s.getRawData(),c=[],h=[],f=[],m=[],p=[],g=[],v=t.map((()=>[])),C=t.map((()=>[])),y=new Set;for(const[e,i]of n.entries())for(const[e,n]of i.entries())for(const[e,i]of n.entries())for(const n of i){const i=e<n?`${e}-${n}`:`${n}-${e}`;if(y.has(i))continue;y.add(i);const a=o[r[e]],u=o[r[n]];c.push(a),h.push(u),f.push(`${a}#${u}`);const d=s.isNone(e)?null:l[e],w=s.isNone(n)?null:l[n];m.push(d),p.push(w),g.push(null==d||null==w?null:d-w);for(let i=0;i<t.length;i++){const o=t[i];v[i].push(o.isNone(e)?null:o.get(e)),C[i].push(o.isNone(n)?null:o.get(n))}}if(0===c.length)return void a.shell.warning("No mutation cliffs found to export.");const A=u.Column.fromStrings("Seq 1",c),b=u.Column.fromStrings("Seq 2",h),S=u.Column.fromStrings("Mutation",f);for(const t of[A,b]){for(const e of i.tags.keys())".notationProvider"!==e&&t.setTag(e,i.getTag(e));t.semType=i.semType}S.semType=d.uF.MACROMOLECULE_DIFFERENCE,S.setTag(d.gp.SEPARATOR,(0,w.AY)(i)),S.setTag(u.TAGS.UNITS,null!==(e=i.getTag(u.TAGS.UNITS))&&void 0!==e?e:""),S.setTag(u.TAGS.CELL_RENDERER,"MacromoleculeDifference"),S.temp[_.j.notationProvider]=i.temp[_.j.notationProvider];const T=[A,b,S,u.Column.fromList(u.COLUMN_TYPE.FLOAT,`Seq 1 ${this.activityColumnName}`,m),u.Column.fromList(u.COLUMN_TYPE.FLOAT,`Seq 2 ${this.activityColumnName}`,p),u.Column.fromList(u.COLUMN_TYPE.FLOAT,"Delta",g)];for(let e=0;e<t.length;e++){const n=t[e].name,i=t[e].type;T.push(u.Column.fromList(i,`Seq 1 ${n}`,v[e])),T.push(u.Column.fromList(i,`Seq 2 ${n}`,C[e]))}const E=u.DataFrame.fromColumns(T);E.name="Mutation Cliffs",a.shell.addTableView(E)}exportInvariantMap(){const t=this.monomerPositionStats,e=new Set,n=[];for(const i of Object.keys(t)){if("general"===i)continue;n.push(i);const o=t[i];for(const t of Object.keys(o))"general"!==t&&e.add(t)}const i=Array.from(e).sort(),o=[u.Column.fromStrings(d.$2.MONOMER,i)];for(const e of n){const n=t[e],r=i.map((t=>{var e,i;return null!==(i=null===(e=n[t])||void 0===e?void 0:e.count)&&void 0!==i?i:0}));o.push(u.Column.fromList(u.COLUMN_TYPE.INT,e,r))}const r=u.DataFrame.fromColumns(o);r.name="Invariant Map",a.shell.addTableView(r)}detach(){this.subs.forEach((t=>t.unsubscribe()))}onTableAttached(){var t,e,n,i;if(super.onTableAttached(),(0,w.B2)(this.dataFrame)){null===(t=this.getProperty(`${o.SEQUENCE}${d.To}`))||void 0===t||t.set(this,this.dataFrame.columns.bySemType(u.SEMTYPE.MACROMOLECULE).name);const r=null===(e=g()(this.dataFrame.columns.numerical).find((t=>t.name.toLowerCase().includes("activity"))))||void 0===e?void 0:e.name;null===(n=this.getProperty(`${o.ACTIVITY}${d.To}`))||void 0===n||n.set(this,null!=r?r:g()(this.dataFrame.columns.numerical).next().value.name),null===(i=this.getProperty(`${o.VALUE_INVARIANT_MAP}${d.To}`))||void 0===i||i.set(this,null!=r?r:g()(this.dataFrame.columns.numerical).next().value.name),null===this.mutationCliffs&&this.sequenceColumnName&&this.activityColumnName&&this.calculateMutationCliffs().then((t=>{this.mutationCliffs=t.cliffs,this.cliffStats=t.cliffStats})),this.subs.push(a.events.onContextMenu.subscribe((t=>{if(!(t&&t.causedBy&&t.args&&t.args.menu&&t.causedBy.target&&t.causedBy.target instanceof HTMLElement&&this.root.contains(t.causedBy.target)))return;const e=t.args.menu,n=e.group("Export");n.item("Export Mutation Cliffs...",(()=>this.exportMutationCliffs())),n.item("Export Invariant Map",(()=>this.exportInvariantMap())),(0,T.pj)().then((t=>{const n=t.getMonomerLib(),i=n.getMonomerSymbolsByType("PEPTIDE").map((t=>n.getMonomer("PEPTIDE",t))).filter(Boolean).map((t=>{var e;return null!==(e=t.meta)&&void 0!==e?e:{}})),o=new Set;i.forEach((t=>Object.keys(t).forEach((t=>o.add(t))))),o.delete("colors"),e.group("Monomer Meta").items(Array.from(o),(t=>{this._monomerMetaColumns.has(t)?this._monomerMetaColumns.delete(t):this._monomerMetaColumns.add(t),this._viewerGrid=null,this.render()}),{isChecked:t=>this._monomerMetaColumns.has(t)})}))}))),this.subs.push(u.debounce(this.dataFrame.onFilterChanged,300).subscribe((()=>{"Filtered"===this.dataSource&&this.onFilterChanged(!0,!1)})))}else{const t="PeptidesError: dataframe is missing Macromolecule or numeric columns";a.log.error(t),a.shell.warning(t)}}onFilterChanged(t,e=!1){if(this._monomerPositionStats=null,this._invariantMapSelection=null,this._mutationCliffStats=null,this._mutationCliffsSelection=null,this._mutationCliffs=null,e)return;this._viewerGrid=null;const n=this.model.findViewer(m.q.MOST_POTENT_RESIDUES);!n||this instanceof I||"Filtered"!==n.dataSource||n.onFilterChanged(!1,!0),t&&this.render(),this.sequenceColumnName&&this.activityColumnName&&this.calculateMutationCliffs().then((t=>{this.mutationCliffs=t.cliffs,this.cliffStats=t.cliffStats}))}calculateMutationCliffs(){return N(this,void 0,void 0,(function*(){var t;const e=this.dataFrame.getCol(this.activityColumnName),n=this.positionColumns.map(w.eY),i="Filtered"===this.dataSource&&this.dataFrame.filter.anyFalse?this.dataFrame.filter:null,o={maxMutations:this.maxMutations,minActivityDelta:this.minActivityDelta,filter:null!==(t=null==i?void 0:i.getBuffer())&&void 0!==t?t:void 0},r=e.getRawData(),s=yield this.mutationCliffsDebouncer(r,n,o);return{cliffs:s,cliffStats:(0,y.Lw)(s,r)}}))}}class M extends x{constructor(){super(),this.currentGridCell=null,this.customColorRange=!1,this.minColorValue=0,this.maxColorValue=0,this.logScaleColor=!1,this.showFilterControls=!0,this.showTotalCountColumn=!1,this._showSearchInput=!1,this.colorColumnName=this.column(r.COLOR,{category:s.INVARIANT_MAP,nullable:!1,columnTypeFilter:"numerical"}),this.colorAggregation=this.string(r.COLOR_AGGREGATION,u.AGG.AVG,{category:s.INVARIANT_MAP,choices:d.V5}),this.lowerBoundColor=this.int(r.LOWER_BOUND_COLOR,4278190335,{category:s.INVARIANT_MAP,editor:"color"}),this.middleColor=this.int(r.MIDDLE_COLOR,4294967295,{category:s.INVARIANT_MAP,editor:"color"}),this.upperBoundColor=this.int(r.UPPER_BOUND_COLOR,4294901760,{category:s.INVARIANT_MAP,editor:"color"}),this.showTotalCountColumn=this.bool(r.SHOW_TOTAL_COUNT_COLUMN,!1,{category:s.GENERAL,description:"Show total monomer count column"}),this.logScaleColor=this.bool(r.LOG_SCALE_COLOR,!1,{category:s.INVARIANT_MAP}),this.customColorRange=this.bool(r.CUSTOM_COLOR_RANGE,!1,{category:s.INVARIANT_MAP}),this.minColorValue=this.float(r.MIN_COLOR_VALUE,0,{category:s.INVARIANT_MAP}),this.maxColorValue=this.float(r.MAX_COLOR_VALUE,0,{category:s.INVARIANT_MAP}),this.showFilterControls=this.bool(r.SHOW_FILTER_CONTROLS,!0,{category:s.GENERAL,description:"Show monomer search and target controls",userEditable:!1}),this.monomerSearchInput=l.input.string("Search",{value:"",nullable:!0,placeholder:"Search monomer",tooltipText:"Search for monomer by symbol. For multiple monomers use comma as a separator.",onValueChanged:()=>{var t,e,n;const i=()=>{var t,e,n;return null===(n=null===(e=null===(t=this._viewerGrid)||void 0===t?void 0:t.dataFrame)||void 0===e?void 0:e.filter)||void 0===n?void 0:n.setAll(!0)},o=null!==(n=null===(e=null===(t=this.monomerSearchInput.value)||void 0===t?void 0:t.trim())||void 0===e?void 0:e.toLowerCase())&&void 0!==n?n:"";if(!o||null==this._viewerGrid||null==this._viewerGrid.dataFrame)return void i();const r=this._viewerGrid.dataFrame.col(d.$2.MONOMER);if(null==r)return void i();const s=o.split(",").map((t=>t.trim())).filter((t=>!!t)),a=r.toList();this._viewerGrid.dataFrame.filter.init((t=>s.some((e=>a[t].toLowerCase().includes(e)))))}})}get name(){return m.q.SEQUENCE_VARIABILITY_MAP}get mode(){var t;return null!==(t=this.dataFrame.getTag(d.gp.MONOMER_POSITION_MODE))&&void 0!==t?t:i.MUTATION_CLIFFS}set mode(t){this.dataFrame.setTag(d.gp.MONOMER_POSITION_MODE,t),this.viewerGrid.invalidate()}onTableAttached(){var t;if(super.onTableAttached(),(0,w.B2)(this.dataFrame))null===(t=this.getProperty(`${r.COLOR}${d.To}`))||void 0===t||t.set(this,this.activityColumnName);else{const t="PeptidesError: dataframe is missing Macromolecule or numeric columns";a.log.error(t),a.shell.warning(t)}this.render()}onPropertyChanged(t){var e;switch(super.onPropertyChanged(t),t.name){case o.SEQUENCE:this._invariantMapSelection=null;break;case r.SHOW_TOTAL_COUNT_COLUMN:this._viewerGrid&&this._viewerGrid.columns.byName(d.$2.TOTAL_COUNT)&&(this._viewerGrid.columns.byName(d.$2.TOTAL_COUNT).visible=this.showTotalCountColumn,this.doRender=!1)}null===(e=this.positionColumns)||void 0===e||e.forEach((t=>{t.temp[d.gp.INVARIANT_MAP_COLOR_CACHE]=null})),this.doRender?this.render():this.viewerGrid.invalidate()}createMonomerPositionDf(){const t=new Set,e=this.positionColumns;for(const e of Object.keys(this.monomerPositionStats)){if("general"===e)continue;const n=this.monomerPositionStats[e];for(const e of Object.keys(n))"general"!==e&&t.add(e)}const n=Array.from(t),i=u.Column.fromStrings(d.$2.MONOMER,n),o=u.DataFrame.fromColumns([i]),r=(0,T.pj)().then((t=>{const e=t.getMonomerLib();return e?n.map((t=>{var n,i;return null!==(i=null===(n=e.getMonomer("PEPTIDE",t))||void 0===n?void 0:n.meta)&&void 0!==i?i:{}})):n.map((t=>({})))})),s=o.columns.addNewInt(d.$2.TOTAL_COUNT),a={},l=this.monomerPositionStats;for(const t of Object.keys(l)){if("general"===t)continue;const e=l[t];for(const t of Object.keys(e))"general"!==t&&(a[t]||(a[t]=0),a[t]+=e[t].count)}s.init((t=>{var e;return null!==(e=a[i.get(t)])&&void 0!==e?e:0})),this._monomerMetaColumns.forEach((t=>{const e=o.columns.addNewString(t);r.then((n=>{e.init((e=>{var i,o;return null!==(o=null===(i=n[e][t])||void 0===i?void 0:i.toString())&&void 0!==o?o:""}))}))})),o.name="SAR";for(const t of e)o.columns.addNewBool(t.name);return o}cacheInvariantMapColors(){if(this.colorColumnName&&this.dataFrame.col(this.colorColumnName)){const t=this.dataFrame.getCol(this.colorColumnName).getRawData();let e=9999999,n=-9999999;const i="Filtered"===this.dataSource&&this.dataFrame.filter.anyFalse?this.dataFrame.filter:null,o=null==i?t=>!0:t=>i.get(t);for(const i of this.positionColumns){i.temp[d.gp.INVARIANT_MAP_COLOR_CACHE]={};const r=i.temp[d.gp.INVARIANT_MAP_COLOR_CACHE],s=i.name,a=i.getRawData(),l=i.categories;if(!this.monomerPositionStats[s])continue;const c=this.monomerPositionStats[s];for(const s of Object.keys(c)){if("general"===s)continue;const c=[];for(let t=0;t<i.length;++t)l[a[t]]===s&&o(t)&&c.push(t);const h=u.Column.float("color",c.length).init((e=>t[c[e]])).aggregate(this.colorAggregation);r[s]=h,e=Math.min(e,h),n=Math.max(n,h)}i.temp[d.gp.INVARIANT_MAP_COLOR_CACHE]=r}const r=this.customColorRange&&null!=this.minColorValue&&null!=this.maxColorValue;let s=r?this.minColorValue:e,a=r?this.maxColorValue:n;const l=this.logScaleColor&&s>1e-30&&a>1e-30&&e>1e-30&&n>1e-30;l&&(s=Math.log(s),a=Math.log(a));for(const t of this.positionColumns){const i=t.temp[d.gp.INVARIANT_MAP_COLOR_CACHE];if(i){for(const t of Object.keys(i))this.activityTarget===d.wf.LOW&&(i[t]=a-i[t]+s),i[t]=u.Color.scaleColor(l?Math.log(i[t]):i[t],s,a,void 0,[this.lowerBoundColor,this.middleColor,this.upperBoundColor]);t.temp[d.gp.INVARIANT_MAP_COLOR_CACHE]=i,t.temp[d.gp.INVARIANT_MAP_COLOR_MIN_CACHE]=e,t.temp[d.gp.INVARIANT_MAP_COLOR_MAX_CACHE]=n}}}}createViewerGrid(){const t=this.createMonomerPositionDf(),e=t.plot.grid();e.sort([d.$2.MONOMER]);const n=this.positionColumns.map((t=>t.name));e.columns.setOrder([d.$2.TOTAL_COUNT,d.$2.MONOMER,...this._monomerMetaColumns,...n]);const o=e.columns.byName(d.$2.TOTAL_COUNT);this.showTotalCountColumn&&null!=o?o.visible=!0:null!=o&&(o.visible=!1);const r=t.getCol(d.$2.MONOMER);f.rI(r,this.alphabet,!0),this.cacheInvariantMapColors(),e.onCellRender.subscribe((t=>O(t,this,this.mode===i.INVARIANT_MAP,this.dataFrame.getCol(this.colorColumnName),this.colorAggregation))),e.onCellTooltip(((t,e,n)=>{var o,r,s,a,l,c,h;if(!t.isTableCell||!(null===(o=null==t?void 0:t.cell.column)||void 0===o?void 0:o.name)||this._monomerMetaColumns.has(t.cell.column.name)||t.cell.column.name===d.$2.TOTAL_COUNT)return this.model.unhighlight(),!0;const f=this.getMonomerPosition(t);(0,w.dl)(f,this.dataFrame,this.monomerPositionStats),this.model.isHighlighting=!0;const m=this.getTotalViewerAggColumns(),p={},g={};if(this.mode===i.INVARIANT_MAP)this.colorColumnName&&this.colorAggregation&&this.colorColumnName!==this.valueColumnName?(m.unshift([this.colorColumnName,this.colorAggregation]),p[`${this.colorAggregation}(${this.colorColumnName})`]=" (color)"):this.colorColumnName&&this.colorAggregation&&this.colorColumnName===this.valueColumnName&&(p["Mean activity"]=" (color)"),this.valueColumnName&&this.valueAggregation&&this.valueAggregation!==u.AGG.VALUE_COUNT&&this.valueAggregation!==u.AGG.TOTAL_COUNT&&m.unshift([this.valueColumnName,this.valueAggregation]);else{const t=null===(s=null===(r=this.mutationCliffs)||void 0===r?void 0:r.get(f.monomerOrCluster))||void 0===s?void 0:s.get(f.positionOrClusterType);if(t){let e=0;for(const n of t.values())e+=n.length;g["Pairs count"]=e.toString()}}return(0,C.D)(this.model.df,this.getScaledActivityColumn(),m,{fromViewer:!0,isMutationCliffs:this.mode===i.MUTATION_CLIFFS,monomerPosition:f,x:e,y:n,mpStats:this.monomerPositionStats,cliffStats:null!==(l=null===(a=this.cliffStats)||void 0===a?void 0:a.stats)&&void 0!==l?l:void 0,postfixes:p,additionalStats:g,cliffIndexes:null===(h=null===(c=this.mutationCliffs)||void 0===c?void 0:c.get(f.monomerOrCluster))||void 0===h?void 0:h.get(f.positionOrClusterType)})})),e.root.addEventListener("mouseleave",(t=>this.model.unhighlight())),u.debounce(e.onCurrentCellChanged,500).subscribe((t=>{var n,o,r,s,a,l,c,h,f,p,g,v,C;try{if(!t||!t.dart||!(null===(o=null===(n=null==t?void 0:t.cell)||void 0===n?void 0:n.column)||void 0===o?void 0:o.name)||this._monomerMetaColumns.has(t.cell.column.name)||t.cell.column.name==d.$2.TOTAL_COUNT||!t.isTableCell)return;if(-1===t.gridRow&&(this.mode===i.INVARIANT_MAP?this._invariantMapSelection=(0,w.ZR)(this.positionColumns):this._mutationCliffsSelection=(0,w.ZR)(this.positionColumns),this.model.fireBitsetChanged(m.q.SEQUENCE_VARIABILITY_MAP),e.invalidate()),!this.keyPressed||t.cell.column.name===d.$2.MONOMER)return;if(null!==this.currentGridCell){const t=this.getMonomerPosition(this.currentGridCell);this.mode===i.INVARIANT_MAP?this.modifyInvariantMapSelection(t,{shiftPressed:!0,ctrlPressed:!0},!1):(null===(a=null===(s=null===(r=this.mutationCliffs)||void 0===r?void 0:r.get(t.monomerOrCluster))||void 0===s?void 0:s.get(t.positionOrClusterType))||void 0===a?void 0:a.size)&&this.modifyMutationCliffsSelection(t,{shiftPressed:!0,ctrlPressed:!0},!1)}const u=this.getMonomerPosition(t);this.mode===i.INVARIANT_MAP?this.modifyInvariantMapSelection(u,{shiftPressed:!0,ctrlPressed:!1},!0):(null===(h=null===(c=null===(l=this.mutationCliffs)||void 0===l?void 0:l.get(u.monomerOrCluster))||void 0===c?void 0:c.get(u.positionOrClusterType))||void 0===h?void 0:h.size)&&this.modifyMutationCliffsSelection(u,{shiftPressed:!0,ctrlPressed:!1},!0),e.invalidate(),setTimeout((()=>null==e?void 0:e.invalidate()),300)}catch(t){console.error(t)}finally{this.keyPressed=!1,(null===(f=t.tableColumn)||void 0===f?void 0:f.name)&&t.grid&&t.isTableCell&&(null===(p=null==t?void 0:t.cell)||void 0===p?void 0:p.column.name)!=d.$2.MONOMER&&!this._monomerMetaColumns.has(null===(v=null===(g=t.cell)||void 0===g?void 0:g.column)||void 0===v?void 0:v.name)&&(null===(C=t.cell)||void 0===C?void 0:C.column.name)!==d.$2.TOTAL_COUNT?this.currentGridCell=u.GridCell.fromColumnRow(t.grid,t.tableColumn.name,t.gridRow):this.currentGridCell=null}})),e.root.addEventListener("keydown",(t=>{if(this.keyPressed=t.key.startsWith("Arrow"),!this.keyPressed){if("Escape"===t.key||"KeyA"===t.code&&t.ctrlKey&&t.shiftKey)this.mode===i.INVARIANT_MAP?this._invariantMapSelection=(0,w.ZR)(this.positionColumns):this._mutationCliffsSelection=(0,w.ZR)(this.positionColumns);else{if("KeyA"!==t.code||!t.ctrlKey)return;{const t=Object.keys(this.monomerPositionStats).filter((t=>"general"!==t));for(const e of t){const t=Object.keys(this.monomerPositionStats[e]).filter((t=>"general"!==t));for(const n of t){const t={monomerOrCluster:n,positionOrClusterType:e};this.mode===i.INVARIANT_MAP?this.modifyInvariantMapSelection(t,{shiftPressed:!0,ctrlPressed:!1},!1):this.modifyMutationCliffsSelection(t,{shiftPressed:!0,ctrlPressed:!1},!1)}}}}this.model.fireBitsetChanged(m.q.SEQUENCE_VARIABILITY_MAP),e.invalidate()}})),e.root.addEventListener("click",(n=>{var o,r,s,a,l,u;const c=e.hitTest(n.offsetX,n.offsetY);if(!(null==c?void 0:c.isTableCell)||(null===(o=null==c?void 0:c.tableColumn)||void 0===o?void 0:o.name)===d.$2.MONOMER||(null===(r=null==c?void 0:c.tableColumn)||void 0===r?void 0:r.name)&&this._monomerMetaColumns.has(c.tableColumn.name)||(null===(s=null==c?void 0:c.tableColumn)||void 0===s?void 0:s.name)===d.$2.TOTAL_COUNT)return;const h=this.getMonomerPosition(c);this.mode===i.INVARIANT_MAP?(this.modifyInvariantMapSelection(h,{shiftPressed:n.shiftKey,ctrlPressed:n.ctrlKey}),(0,w.CD)(this.invariantMapSelection)&&(t.currentRowIdx=-1)):(null===(u=null===(l=null===(a=this.mutationCliffs)||void 0===a?void 0:a.get(h.monomerOrCluster))||void 0===l?void 0:l.get(h.positionOrClusterType))||void 0===u?void 0:u.size)&&this.modifyMutationCliffsSelection(h,{shiftPressed:n.shiftKey,ctrlPressed:n.ctrlKey}),e.invalidate()})),L(e),e.props.showRowHeader=!0;const s=e.onAfterDrawContent.subscribe((()=>{const t=e.col(d.$2.MONOMER);if(40!==t.width){t.width=40;for(const t of n)e.col(t).width=40}else s.unsubscribe()}));return e}getMonomerPosition(t){return{monomerOrCluster:t.cell.dataFrame.get(d.$2.MONOMER,t.tableRowIndex),positionOrClusterType:t.tableColumn.name}}render(){var t;if(h()(this.root).empty(),!this.activityColumnName||!this.sequenceColumnName)return void this.root.appendChild(l.divText("Please, select a sequence and activity columns in the viewer properties"));const e=this.getProperty(r.COLOR);e&&(e.choices=g()(a.shell.t.columns.numerical).toArray().map((t=>t.name)),e.get(this)===d.$2.ACTIVITY_SCALED&&e.set(this,d.$2.ACTIVITY)),h()(this.root).empty();let n=l.divText(m.q.MOST_POTENT_RESIDUES,{id:"pep-viewer-title"});if(this.name===m.q.SEQUENCE_VARIABILITY_MAP){const t=l.input.bool(i.MUTATION_CLIFFS,{value:this.mode===i.MUTATION_CLIFFS});t.root.addEventListener("click",(()=>{e.value=!1,t.value=!0,this.mode=i.MUTATION_CLIFFS})),t.setTooltip("Statistically significant changes in activity");const e=l.input.bool(i.INVARIANT_MAP,{value:this.mode===i.INVARIANT_MAP});e.root.addEventListener("click",(()=>{t.value=!1,e.value=!0,this.mode=i.INVARIANT_MAP})),e.setTooltip("Number of sequences having monomer-position");const o=t=>{h()(t.root).find(".ui-input-editor").css("margin","0px").attr("type","radio"),h()(t.root).find(".ui-input-description").css("padding","0px").css("padding-right","16px"),h()(t.captionLabel).addClass("ui-label-right")};o(t),o(e),n=l.divH([t.root,e.root],{id:"pep-viewer-title"}),h()(n).css("width","auto").css("align-self","center")}const o=this.viewerGrid.root;o.style.width="auto";const s=l.icons.search((()=>{this._showSearchInput=!this._showSearchInput,this.monomerSearchInput.input.style.display=this._showSearchInput?"block":"none"}),"Toggle monomer search input visibility");this.monomerSearchInput.input.style.display=this._showSearchInput?"block":"none",h()(s).addClass("pep-help-icon"),(0,w.BX)(s.style).set("top","3px").set("fontSize","14px");const u=l.divH([this.monomerSearchInput.input],{style:{alignSelf:"center",justifyContent:"center",width:"100%",flexWrap:"wrap"}}),c=l.divH([s,n,u],{style:{alignSelf:"center",lineHeight:"normal",flexDirection:"column",width:"100%"}});this.root.appendChild(l.divV([c,o])),null===(t=this.viewerGrid)||void 0===t||t.invalidate(),this.monomerSearchInput.fireChanged()}}class I extends x{constructor(){super(),this.currentGridRowIdx=null}get name(){return m.q.MOST_POTENT_RESIDUES}onTableAttached(){super.onTableAttached(),this.render()}onPropertyChanged(t){super.onPropertyChanged(t),this.doRender&&this.render()}onFilterChanged(t,e=!1){if(this._monomerPositionStats=null,this._invariantMapSelection=null,this._mutationCliffStats=null,this._mutationCliffsSelection=null,this._mutationCliffs=null,e)return;this._viewerGrid=null;const n=this.model.findViewer(m.q.SEQUENCE_VARIABILITY_MAP);"Filtered"===(null==n?void 0:n.dataSource)&&n.onFilterChanged(!1,!0),t&&this.render()}createMostPotentResiduesDf(){var t;const e=Object.entries(this.monomerPositionStats),n=new Array(e.length-1),i=new Array(n.length),o=new Array(n.length),r=new Array(n.length),s=new Array(n.length),a=new Array(n.length),l=new Array(n.length),c=this.getTotalViewerAggColumns(),h=c.map((([t,e])=>(0,v.hX)(e,t))),f=new Array(h.length);h.forEach(((t,e)=>f[e]=new Array(n.length)));let m=0;for(const[p,g]of e){const e=g.general;if(!e)continue;if(1===Object.entries(g).length)continue;const C=[];for(const[n,i]of Object.entries(g))"general"!==n&&(i.count>1&&(null==i.pValue||(null!==(t=i.pValue)&&void 0!==t?t:1)<=.05)&&C.push([n,i]),i.pValue===e.minPValue&&C.push([n,i]));let y=null;0===C.length&&(y=Object.entries(g).find((([t,e])=>"general"!=t)));for(const[t,e]of C)(null===y||this.activityTarget===d.wf.HIGH&&y[1].meanDifference<e.meanDifference||this.activityTarget===d.wf.LOW&&y[1].meanDifference>e.meanDifference)&&(y=[t,e]);if(null===y)continue;n[m]=parseInt(p),i[m]=y[0],o[m]=y[1].meanDifference,r[m]=y[1].pValue,s[m]=y[1].count,a[m]=y[1].ratio,l[m]=y[1].mean;const w=this.monomerPositionStats[p][y[0]],A=u.BitSet.fromBytes(w.mask.buffer.buffer,this.model.df.col(this.activityColumnName).length);for(let t=0;t<h.length;t++){const[e,n]=c[t];f[t][m]=(0,v.lh)(this.model.df.getCol(e),n,A)}++m}n.length=m,i.length=m,o.length=m,r.length=m,s.length=m,a.length=m,l.length=m;const p=u.DataFrame.create(m),g=p.columns;return g.add(u.Column.fromList(u.TYPE.INT,d.$2.POSITION,n)),g.add(u.Column.fromList(u.TYPE.STRING,d.$2.MONOMER,i)),g.add(u.Column.fromList(u.TYPE.FLOAT,d.$2.MEAN_DIFFERENCE,o)),g.add(u.Column.fromList(u.TYPE.FLOAT,d.$2.MEAN,l)),g.add(u.Column.fromList(u.TYPE.FLOAT,d.$2.P_VALUE,r)),g.add(u.Column.fromList(u.TYPE.INT,d.$2.COUNT,s)),g.add(u.Column.fromList(u.TYPE.FLOAT,d.$2.RATIO,a)),h.forEach(((t,e)=>g.add(u.Column.fromList(u.TYPE.FLOAT,t,f[e])))),p}createViewerGrid(){const t=this.createMostPotentResiduesDf(),e=t.plot.grid();e.sort([d.$2.POSITION]);const n=e.col(d.$2.P_VALUE);n.format="#.000",n.name="P-value";const i=t.getCol(d.$2.MONOMER);f.rI(i,this.alphabet,!0),e.onCellRender.subscribe((t=>O(t,this,!1))),e.onCellTooltip(((t,e,n)=>{var i,o;if(!t.isTableCell)return this.model.unhighlight(),!0;const r=this.getMonomerPosition(t);if((0,w.dl)(r,this.dataFrame,this.monomerPositionStats),this.model.isHighlighting=!0,(null===(i=t.tableColumn)||void 0===i?void 0:i.name)===d.$2.MONOMER)r.positionOrClusterType=d.$2.MONOMER;else if((null===(o=t.tableColumn)||void 0===o?void 0:o.name)!==d.$2.MEAN_DIFFERENCE)return!1;const s=this.getTotalViewerAggColumns(),a=null==t.tableRowIndex?void 0:(0,v.m2)(t.grid.dataFrame,t.tableRowIndex,s,{});return(0,C.D)(this.model.df,this.getScaledActivityColumn(),s,{fromViewer:!0,isMostPotentResidues:!0,monomerPosition:r,x:e,y:n,mpStats:this.monomerPositionStats,aggrColValues:a})})),u.debounce(e.onCurrentCellChanged,500).subscribe((n=>{var i,o,r;try{if(-1===n.gridRow)return this._mutationCliffsSelection=(0,w.ZR)(this.positionColumns),this._invariantMapSelection=(0,w.ZR)(this.positionColumns),this.model.fireBitsetChanged(m.q.MOST_POTENT_RESIDUES),void e.invalidate();if(this.keyPressed&&t.currentCol.name!==d.$2.MEAN_DIFFERENCE||!this.keyPressed)return;const s=this.getMonomerPosition(n);if(null!==this.currentGridRowIdx){const t=this.getMonomerPosition(e.cell("Diff",this.currentGridRowIdx));this.modifyInvariantMapSelection(t,{shiftPressed:!0,ctrlPressed:!0},!1)}(null===(r=null===(o=null===(i=this.mutationCliffs)||void 0===i?void 0:i.get(s.monomerOrCluster))||void 0===o?void 0:o.get(s.positionOrClusterType))||void 0===r?void 0:r.size)&&this.modifyInvariantMapSelection(s,{shiftPressed:!0,ctrlPressed:!1}),e.invalidate()}finally{this.keyPressed=!1,this.currentGridRowIdx=n.gridRow}})),e.root.addEventListener("keydown",(n=>{if(this.keyPressed=n.key.startsWith("Arrow"),!this.keyPressed){if("Escape"===n.key||"KeyA"===n.code&&n.ctrlKey&&n.shiftKey)this._mutationCliffsSelection=(0,w.ZR)(this.positionColumns);else{if("KeyA"!==n.code||!n.ctrlKey)return;for(let n=0;n<t.rowCount;++n){const t=this.getMonomerPosition(e.cell("Diff",n));this.modifyInvariantMapSelection(t,{shiftPressed:!0,ctrlPressed:!1},!1)}}this.model.fireBitsetChanged(m.q.MOST_POTENT_RESIDUES),e.invalidate()}})),e.root.addEventListener("mouseleave",(t=>this.model.unhighlight())),e.root.addEventListener("click",(t=>{var n,i,o;const r=e.hitTest(t.offsetX,t.offsetY);if(!(null==r?void 0:r.isTableCell)||r.tableColumn.name!==d.$2.MEAN_DIFFERENCE)return;const s=this.getMonomerPosition(r);(null===(o=null===(i=null===(n=this.monomerPositionStats)||void 0===n?void 0:n[s.positionOrClusterType])||void 0===i?void 0:i[s.monomerOrCluster])||void 0===o?void 0:o.count)&&(this.modifyInvariantMapSelection(s,{shiftPressed:t.shiftKey,ctrlPressed:t.ctrlKey}),e.invalidate())})),L(e);const o=e.col(d.$2.MEAN_DIFFERENCE);o.name="Diff";const r=e.onAfterDrawContent.subscribe((()=>{const t=e.col(d.$2.MONOMER);if(40===t.width)return o.width=40,void r.unsubscribe();t.width=40,o.width=40}));return e}getMonomerPosition(t){return{monomerOrCluster:t.cell.dataFrame.get(d.$2.MONOMER,t.tableRowIndex),positionOrClusterType:`${t.cell.dataFrame.get(d.$2.POSITION,t.tableRowIndex)}`}}render(){var t;if(h()(this.root).empty(),!this.activityColumnName||!this.sequenceColumnName)return void this.root.appendChild(l.divText("Please, select a sequence and activity columns in the viewer properties"));const e=this.viewerGrid.root;e.style.width="auto",this.root.appendChild(l.divV([e])),null===(t=this.viewerGrid)||void 0===t||t.invalidate()}}function O(t,e,n,i,o){var r,s,a,l,c;const h=[...e.positionColumns.map((t=>t.name)),d.$2.MEAN_DIFFERENCE],m=t.g,p=t.bounds;m.save(),m.beginPath(),m.rect(p.x,p.y,p.width,p.height),m.clip();const g=t.cell,v=null===(r=g.tableColumn)||void 0===r?void 0:r.name,C=g.tableRowIndex;if(!g.isTableCell||-1===h.indexOf(v))return void m.restore();const y=g.grid.table,w=y.get(d.$2.MONOMER,C),A=v!==d.$2.MEAN_DIFFERENCE?v:y.get(d.$2.POSITION,C).toFixed(),b=e.monomerPositionStats[A];if(!b[w])return t.preventDefault(),void m.restore();if(n){const t=null!==(s=b[w].aggValue)&&void 0!==s?s:b[w].count,n=e.positionColumns.find((t=>t.name===A)),i=null!==(a=n.temp[d.gp.INVARIANT_MAP_COLOR_CACHE])&&void 0!==a?a:{};let o=u.Color.white;null!=i[w]?o=i[w]:e instanceof M&&(e.cacheInvariantMapColors(),o=null!==(c=(null!==(l=n.temp[d.gp.INVARIANT_MAP_COLOR_CACHE])&&void 0!==l?l:{})[w])&&void 0!==c?c:u.Color.white),f.rW(m,w,A,e.invariantMapSelection,t,p,o)}else f.Yd(m,w,A,e,p);t.preventDefault(),m.restore()}function L(t){const e=t.props;e.allowEdit=!1,e.allowRowSelection=!1,e.allowBlockSelection=!1,e.allowColSelection=!1,e.showRowHeader=!1,e.showCurrentRowIndicator=!1,e.showReadOnlyNotifications=!1,e.rowHeight=20}},7654:(t,e,n)=>{"use strict";n.d(e,{HV:()=>p,M1:()=>g,QD:()=>v});var i,o=n(7389),r=n(6082),s=n(7233),a=n.n(s),l=n(4139),u=n(5070),c=n(8608),h=n(5480),d=n(8774);!function(t){t.SEPARATE_MONOMERS="separateMonomers",t.SEPARATE_POSITIONS="separatePositions",t.SEPARATE_CLUSTERS="separateClusters"}(i||(i={}));const f="general",m=t=>t===f?"General":t.substring(8);function p(t,e){if(!t.selection.anyTrue)return o.divText("No distribution");const n=()=>{const n=[y(f,t,e)];for(const o of Object.values(i))"true"!==t.getTag(o)||o===i.SEPARATE_CLUSTERS&&!e.clusterColName||n.push(y(o,t,e));return 1===n.length?n[0]:o.div(n)},r=o.div(n()),s=Object.values(i),l=new Array(s.length);for(let u=0;u<s.length;u++){const c=s[u].substring(8);l[u]=o.input.bool(c,{value:"true"===t.getTag(s[u]),onValueChanged:e=>{t.setTag(s[u],`${e}`),a()(r).empty(),r.append(n())}}),a()(l[u].captionLabel).addClass("ui-label-right").css("text-align","left"),a()(l[u].root).find(".ui-input-editor").css("margin","0px"),a()(l[u].root).find(".ui-input-description").css("margin","0px"),l[u].setTooltip(`Show distribution for each ${c}`),c===i.SEPARATE_CLUSTERS?l[u].enabled=!(!e.clusterColName||!e.clusterSelection[h.W.ORIGINAL]):c!==i.SEPARATE_MONOMERS&&c!==i.SEPARATE_POSITIONS||(l[u].enabled=0!==Object.entries(e.monomerPositionSelection).length)}const u=o.form(l,{style:{flexDirection:"row"}});return o.divV([u,r])}function g(t,e=!1){const n=t.plot.histogram({filteringEnabled:!1,valueColumnName:l.$2.ACTIVITY,splitColumnName:l.$2.SPLIT_COL,legendVisibility:"Never",showXAxis:!0,showColumnSelector:!1,showRangeSlider:!1,showBinSelector:!1,backColor:e?"#fdffe5":"#fffff"});return n.root.style.width="auto",n}function v(t,e={}){var n,i;null!==(n=e.fractionDigits)&&void 0!==n||(e.fractionDigits=3);const o={[null!==(i=null==e?void 0:e.countName)&&void 0!==i?i:"Count"]:`${t.count} (${(100*t.ratio).toFixed(e.fractionDigits)}%)`,"Mean difference":t.meanDifference.toFixed(e.fractionDigits),"Mean activity":t.mean.toFixed(e.fractionDigits)};return null!=t.pValue&&(o["p-value"]=t.pValue<.01?"<0.01":t.pValue.toFixed(e.fractionDigits)),o}function C(t,e,n,i={}){const o=g((0,c.FZ)(n.activityCol,t.selection,t)),s=(0,u.I_)(t,Object.entries(n.columns),{filterDf:!0,mask:r.BitSet.fromBytes(e.mask.buffer.buffer,e.mask.length)}),l=v(e),h=Object.assign(Object.assign({},l),s),d=(0,c.F2)(o,h,i);return a()(d).addClass("d4-flex-col"),d}function y(t,e,n){let r=o.divText("No distribution");const s=e.selection.clone().and(e.filter),a=d.A.fromUint32Array(s.length,new Uint32Array(s.getBuffer().buffer));switch(t){case f:r=C(e,e.selection.anyTrue&&e.selection.anyFalse?(0,u.GT)(n.activityCol.getRawData(),a,(0,u.pY)(e.filter)):{count:n.activityCol.length,pValue:null,meanDifference:0,ratio:1,mask:a,mean:n.activityCol.stats.avg},n);break;case i.SEPARATE_CLUSTERS:r=function(t,e,n){const i=t.rowCount,r=[],s=e.activityCol.getRawData(),a=t.getCol(e.clusterColName),l=a.categories,f=a.getRawData(),m=(0,u.pY)(t.filter),p=n[h.W.ORIGINAL].map((t=>l.indexOf(t))),g=new Array(p.length).fill(new d.A(i));for(let t=0;t<i;t++){const e=f[t],n=p.indexOf(e);-1!==n&&g[n].setTrue(t)}for(let n=0;n<p.length;n++){const i=p[n],o=(0,u.GT)(s,g[n],m);r.push(C(t,o,e,{[c.AN.SELECTION]:l[i]}))}const v=n[h.W.CUSTOM];for(const n of v){const o=t.getCol(n),a=d.A.fromUint32Array(i,o.getRawData()),l=(0,u.GT)(s,a,m);r.push(C(t,l,e,{[c.AN.SELECTION]:n}))}return o.div(r,"d4-flex-wrap")}(e,n,n.clusterSelection);break;case i.SEPARATE_MONOMERS:r=function(t,e,n){var i,r,s;const a=Object.keys(n),l=t.rowCount,h=[],f=[],m=[],p=[],g=e.activityCol.getRawData(),v=(0,u.pY)(t.filter);for(const o of a){const a=n[o],y=new d.A(l);for(let e=0;e<a.length;e++){const n=a[e];null!==(i=f[e])&&void 0!==i||(f[e]=t.getCol(n)),null!==(r=m[e])&&void 0!==r||(m[e]=f[e].categories),null!==(s=p[e])&&void 0!==s||(p[e]=f[e].getRawData());const u=m[e].indexOf(o);for(let t=0;t<l;t++)p[e][t]===u&&y.setTrue(t)}const w=(0,u.GT)(g,y,v);h.push(C(t,w,e,{[c.AN.SELECTION]:o}))}return o.div(h,"d4-flex-wrap")}(e,n,function(t){const e={},n=Object.keys(t);for(const i of n)for(const n of t[i])e.hasOwnProperty(n)?e[n].includes(i)||e[n].push(i):e[n]=[i];return e}(n.monomerPositionSelection));break;case i.SEPARATE_POSITIONS:r=function(t,e,n){var i,r,s;const a=Object.keys(n),l=t.rowCount,h=[],f=e.activityCol.getRawData(),m=[],p=[],g=[],v=(0,u.pY)(t.filter);for(let o=0;o<a.length;o++){const y=a[o],w=n[y];if(0===w.length)continue;null!==(i=m[o])&&void 0!==i||(m[o]=t.getCol(y)),null!==(r=p[o])&&void 0!==r||(p[o]=m[o].categories),null!==(s=g[o])&&void 0!==s||(g[o]=m[o].getRawData());const A=new d.A(t.rowCount);for(let t=0;t<w.length;t++){const e=w[t],n=p[o].indexOf(e);for(let t=0;t<l;t++)g[o][t]===n&&A.setTrue(t)}const b=(0,u.GT)(f,A,v);h.push(C(t,b,e,{[c.AN.SELECTION]:y}))}return o.div(h,"d4-flex-wrap")}(e,n,n.monomerPositionSelection)}return o.divV([o.h1(m(t)),r])}},7923:(t,e,n)=>{"use strict";n.d(e,{F:()=>c});var i=n(7389),o=n(6082),r=n(4139),s=n(8608),a=n(3163),l=n(4025),u=n(7654);function c(t,e,n=!0){var r,a,l,c,d;const f=h(t,e);if(!f)return new o.Widget(i.label("No mutations table generated"));const{pairsGrid:m,uniqueSequencesGrid:p,aminoToInput:g}=f,v=[m,p],C=i.divV([g.root,...v.map((t=>t.root))],{style:{width:"100%"}});if(1===Object.values(e.mutationCliffsSelection).filter((t=>t.length>0)).length){const t=Object.keys(e.mutationCliffsSelection).find((t=>e.mutationCliffsSelection[t].length>0)),n=e.mutationCliffsSelection[t];if(1===n.length){const i=n[0],o=null===(a=null===(r=e.mutationCliffs)||void 0===r?void 0:r.get(i))||void 0===a?void 0:a.get(t);if(o&&o.size>0){const n=(0,s.Z7)(e.activityCol,o,i),r=(0,u.M1)(n,!1),a=null===(d=null===(c=null===(l=e.mutationCliffStats)||void 0===l?void 0:l.stats)||void 0===c?void 0:c.get(i))||void 0===d?void 0:d.get(t),h={};let f=0;for(const t of o.values())f+=t.length;h["Pairs count"]=f.toString(),a&&(h["Unique Count"]=a.mask.trueCount().toString(),Object.assign(h,(0,u.QD)(a,{countName:"MP in cliffs count"})));const m=(0,s.F2)(r,h);r.root.style.maxHeight="100px",m.style.marginTop="10px",C.appendChild(m)}}}return n&&(0,s.BE)("Mutation Cliffs pairs",g.root,C,(()=>{const n=h(t,e),o=i.splitH([i.divV([n.aminoToInput.root,n.pairsGrid.root],{style:{marginRight:"10px"}}),i.divV([n.uniqueSequencesGrid.root],{style:{marginLeft:"10px"}})],{style:{width:"100%",height:"100%"}},!0);return setTimeout((()=>{var t,i;if(document.contains(o)){const r=o.offsetWidth,s=null===(t=n.pairsGrid.canvas)||void 0===t?void 0:t.parentElement;n.pairsGrid.props.showRowHeader=!0,n.uniqueSequencesGrid.props.showRowHeader=!0;const a=null===(i=n.uniqueSequencesGrid.canvas)||void 0===i?void 0:i.parentElement;if(s&&a&&(s.style.height="100%",a.style.height="calc(100% - 20px)",a.style.marginTop="20px",r>400)){const t=Math.max(.33*r,200),i=n.pairsGrid.columns.byName("Mutation");i&&(i.width=t);const o=n.uniqueSequencesGrid.columns.byName(e.sequenceColumnName);o&&(o.width=t)}}}),500),o})),new o.Widget(C)}function h(t,e){var n,u;const c=t.filter.getSelectedIndexes(),h=Object.keys(e.mutationCliffsSelection);if(!h.length||null===e.mutationCliffs)return null;const d=[],f=[],m=[],p=[],g=[],v=[],C=t.getCol(e.sequenceColumnName),y=C.categories,w=C.getRawData(),A=e.activityCol.getRawData(),b=new Map,S=o.BitSet.create(t.rowCount),T={},E=Object.fromEntries(e.positionColumns.map((t=>[t.name,t])));for(const t of h){const i=E[t],o=i.categories,r=i.getRawData();for(const i of e.mutationCliffsSelection[t]){const s=null===(n=e.mutationCliffs.get(i))||void 0===n?void 0:n.get(t);if(void 0!==s)for(const[t,n]of s.entries()){if(!c.includes(t))continue;T[t]||(T[t]=Object.keys(T).length+1);const i=T[t],s=null!==(u=b.get(t))&&void 0!==u?u:[],a=y[w[t]],l=A[t],h=e.activityCol.isNone(t)?null:l;for(const l of n){if(s.includes(l)||!c.includes(l))continue;b.has(l)||b.set(l,[]);const n=y[w[l]],u=e.activityCol.isNone(l)?null:A[l],C=null==h||null==u?null:h-u;b.get(l).push(t),d.push(`${a}#${n}`),p.push(`${i}`),f.push(C),m.push(o[r[l]]),g.push(t),v.push(l),S.set(t,!0),S.set(l,!0)}}}}if(0===d.length)return null;const _=o.Column.fromStrings("Mutation",d),N=o.Column.fromList("double","Delta",f),x=o.Column.fromStrings("Group",p),M=o.Column.fromStrings("~to",m),I=o.Column.fromList(o.COLUMN_TYPE.INT,"~toIdx",v),O=o.Column.fromList(o.COLUMN_TYPE.INT,"~fromIdx",g),L=o.DataFrame.fromColumns([_,N,x,M,I,O]);L.name="Mutation Cliff pairs";const P=i.input.string("Mutated to:",{value:"",onValueChanged:t=>{const e=t;""!==e?L.filter.init((t=>M.get(t)===e)):L.filter.setAll(!0)}});P.setTooltip("Filter the rows by the monomer that the mutation was substituted to");const R=L.plot.grid();(0,s.vY)(R,!0),_.semType=r.uF.MACROMOLECULE_DIFFERENCE,_.tags[r.gp.SEPARATOR]=(0,s.AY)(C),_.tags[o.TAGS.UNITS]=C.tags[o.TAGS.UNITS],_.tags[o.TAGS.CELL_RENDERER]="MacromoleculeDifference",_.temp[l.j.notationProvider]=C.temp[l.j.notationProvider];let k=!1,V=null;const F=[];R.onCurrentCellChanged.subscribe((t=>{try{if(!t||!t.dart)return F.length=0,void j();const e=t.tableRowIndex;if(!k)return;if(null===e)return F.length=0,void j();null!==V&&F.splice(F.indexOf(V),1),F.includes(e)||(F.push(e),R.invalidate()),j()}finally{k=!1,V=t&&t.dart?t.tableRowIndex:null}})),R.root.addEventListener("keydown",(t=>{k=t.key.startsWith("Arrow")})),R.root.addEventListener("click",(t=>{const e=R.hitTest(t.offsetX,t.offsetY);if(!e||null===e.tableRowIndex)return;const n=e.tableRowIndex;if(t.shiftKey){const t=F.indexOf(n);-1===t?F.push(n):F.splice(t,1)}else F.length=0,F.push(n);j(),R.invalidate(),Y.invalidate()})),R.onCellPrepare((t=>{var e,n,i,r;if((null==t?void 0:t.isTableCell)&&"delta"==(null===(n=null===(e=null==t?void 0:t.gridColumn)||void 0===e?void 0:e.name)||void 0===n?void 0:n.toLowerCase())&&(null==(null===(i=null==t?void 0:t.cell)||void 0===i?void 0:i.value)||(null===(r=null==t?void 0:t.cell)||void 0===r?void 0:r.value)==o.FLOAT_NULL))try{t.customText="N/A"}catch(t){}})),R.onCellRender.subscribe((t=>{var e;(null===(e=t.cell.tableColumn)||void 0===e?void 0:e.name)===_.name&&F.includes(t.cell.tableRowIndex)&&(0,a.X5)(t.g,t.bounds)}));const D=e.gridColumns.length,G=[];for(let t=1;t<D;t++){const n=e.gridColumns.byIndex(t);((null==n?void 0:n.name)===e.sequenceColumnName||!0===(null==n?void 0:n.visible)&&!Object.hasOwn(E,n.name))&&G.push(n.name)}const U=t.clone(S,G);U.name="Unique sequences that form Mutation Cliffs pairs";const q=U.columns.addNewInt("~seqIdx"),B=q.getRawData();U.col(e.sequenceColumnName)&&(U.col(e.sequenceColumnName).temp[l.j.notationProvider]=C.temp[l.j.notationProvider]);const H=S.getSelectedIndexes();q.init((t=>H[t]));const Y=U.plot.grid();function j(){const t=[];for(const e of F)t.push(O.get(e)),t.push(I.get(e));U.filter.init((e=>0===F.length||t.includes(B[e])),!0),R.invalidate(),Y.invalidate()}return(0,s.vY)(Y,!0),Y.props.rowHeight=20,R.root.style.width="100% !important",Y.root.style.width="100% !important",setTimeout((()=>{R.autoSize(window.innerWidth,250,void 0,void 0,!1),Y.autoSize(window.innerWidth,250,void 0,void 0,!1),R.root.style.removeProperty("width"),R.root.style.setProperty("width","100%"),Y.root.style.removeProperty("width"),Y.root.style.setProperty("width","100%"),R.root.style.minHeight="70px",Y.root.style.minHeight="100px",R.root.style.height="unset",Y.root.style.height="unset"}),200),{pairsGrid:R,uniqueSequencesGrid:Y,aminoToInput:P}}},440:(t,e,n)=>{"use strict";n.d(e,{v:()=>g,n:()=>v});var i=n(4328),o=n(7389),r=n(6082),s=n(4139),a=n(115),l=n(9499),u=n(7233),c=n.n(u),h=n(8608),d=n(1199),f=n(5429);class m{constructor(t){this._inputBase=t}get root(){return this._inputBase.root}get value(){return this._inputBase.value}set value(t){this._inputBase.value=t}get inputBase(){return this._inputBase}}n(4788);var p=function(t,e,n,i){return new(n||(n=Promise))((function(o,r){function s(t){try{l(i.next(t))}catch(t){r(t)}}function a(t){try{l(i.throw(t))}catch(t){r(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(s,a)}l((i=i.apply(t,e||[])).next())}))};function g(t,e){return p(this,void 0,void 0,(function*(){const n=new a.av,l=o.div();let u=null;if(void 0===e){const e=r.Utils.firstOrNull(t.columns.toList().filter((t=>t.semType===r.SEMTYPE.MACROMOLECULE)));if(null===e)throw new Error("Peptides Error: table doesn't contain sequence columns");0!==e.stats.missingValueCount&&i.shell.info("Sequences column contains missing values. They will be ignored during analysis"),u=yield async function(t,e){const n=r.Func.find({package:"Bio",name:"sequenceColumnInput"})[0];return n?await n.apply({name:t,options:e}):new m(o.input.column(t,e))}("Sequence",{table:t,value:e,onValueChanged:e=>{c()(l).empty().append(o.wait((()=>p(this,void 0,void 0,(function*(){const n=yield t.plot.fromType("WebLogo",{sequenceColumnName:e.name});return n.root.style.setProperty("height","130px"),n.root}))))),0!==e.stats.missingValueCount&&i.shell.info("Sequences column contains missing values. They will be ignored during analysis")},filter:t=>t.semType===r.SEMTYPE.MACROMOLECULE,nullable:!1}),u.inputBase.setTooltip("Macromolecule column in FASTA, HELM or separated format")}let g,C=r.Func.find({package:"Bio",name:"webLogoViewer"});if(0===C.length)return{host:o.label("Bio package is missing or out of date. Please install the latest version."),callback:()=>p(this,void 0,void 0,(function*(){return!1}))};if(C=r.Func.find({package:"Bio",name:"getBioLib"}),0===C.length)return{host:o.label("Bio package is missing or out of date. Please install the latest version."),callback:()=>p(this,void 0,void 0,(function*(){return!1}))};const y=t.col("activity")||t.col("IC50")||r.Utils.firstOrNull(t.columns.numerical),w=o.div([],{id:"pep-hist-host"}),A=o.input.choice("Scaling",{value:s.rg.NONE,items:Object.values(s.rg),onValueChanged:t=>p(this,void 0,void 0,(function*(){var e;g=(0,h.Y1)(S.value,t);const n=r.DataFrame.fromColumns([g]).plot.histogram({filteringEnabled:!1,valueColumnName:s.$2.ACTIVITY,legendVisibility:"Never",showXAxis:!0,showColumnSelector:!1,showRangeSlider:!1,showBinSelector:!1});null===(e=w.lastChild)||void 0===e||e.remove(),w.appendChild(n.root)}))});A.setTooltip("Activity column transformation method");const b=()=>{var t;A.enabled=null!==(t=S.value)&&void 0!==t&&t&&S.value.stats.min>0,A.value=s.rg.NONE,0!==S.value.stats.missingValueCount&&i.shell.info("Activity column contains missing values. They will be ignored during analysis")},S=o.input.column("Activity",{table:t,value:y,nullable:!1,onValueChanged:b,filter:t=>t.type===r.TYPE.INT||t.type===r.TYPE.FLOAT||t.type===r.TYPE.QNUM});S.setTooltip("Numerical activity column");const T=o.input.column("Clusters",{table:t,onValueChanged:t=>{t&&(E.value=!1,E.fireChanged())}});T.setTooltip("Optional. Clusters column is used to create Logo Summary Table"),T.nullable=!0;const E=o.input.bool("Generate clusters",{value:!0,onValueChanged:t=>{t&&(T.value=null,T.fireChanged())}});E.setTooltip("Generate clusters column based on MCL embeddings for Logo Summary Table"),S.fireChanged(),A.fireChanged(),E.fireChanged();const _=[S,A,T,E];null!==u&&_.splice(0,0,u.inputBase);const N=o.input.float(f.t_.THRESHOLD,{value:n.threshold,nullable:!1,onValueChanged:t=>n.threshold=null!=t?t:n.threshold});N.setTooltip("Threshold for similarity between two sequences to create edges");const x=o.input.float(f.t_.INFLATION,{value:n.inflation,nullable:!1,onValueChanged:t=>n.inflation=null!=t?t:n.inflation});x.setTooltip("Inflation value for MCL algorithm");const M=o.input.int(f.t_.MAX_ITERATIONS,{value:n.maxIterations,nullable:!1,onValueChanged:t=>n.maxIterations=null!=t?t:n.maxIterations});M.setTooltip("Maximum iterations for MCL algorithm");const I=o.input.bool(f.t_.USE_WEBGPU,{value:n.useWebGPU,onValueChanged:t=>n.useWebGPU=t});I.enabled=!1,n.webGPUDescriptionPromise.then((()=>{n.webGPUDescription!==a.Ku?(I.setTooltip(`Use WebGPU for MCL algorithm (${n.webGPUDescription})`),I.enabled=!0):(I.setTooltip(a.Ku),I.enabled=!1,I.value=!1)}));const O=o.input.int(f.t_.MIN_CLUSTER_SIZE,{value:n.minClusterSize,nullable:!1,onValueChanged:t=>n.minClusterSize=null!=t?t:n.minClusterSize});O.setTooltip("Minimum cluster size for MCL algorithm");const L=o.input.choice(f.t_.DISTANCE_FUNCTION,{value:n.distanceF,items:[d.Z.NEEDLEMANN_WUNSCH,d.Z.MONOMER_CHEMICAL_DISTANCE,d.Z.HAMMING,d.Z.LEVENSHTEIN],nullable:!1,onValueChanged:t=>n.distanceF=t}),P=o.input.float(f.t_.GAP_OPEN,{value:n.gapOpen,onValueChanged:t=>n.gapOpen=null!=t?t:n.gapOpen}),R=o.input.float(f.t_.GAP_EXTEND,{value:n.gapExtend,onValueChanged:t=>n.gapExtend=null!=t?t:n.gapExtend}),k=[N,x,M,O,L,o.input.choice(f.t_.FINGERPRINT_TYPE,{value:n.fingerprintType,items:["Morgan","RDKit","Pattern","AtomPair","MACCS","TopologicalTorsion"],nullable:!1,onValueChanged:t=>n.fingerprintType=t}),P,R,I],V=o.form(k);V.style.display="none";const F=o.icons.settings((()=>{V.style.display="none"===V.style.display?"flex":"none",V.classList.remove("ui-form-condensed")}),"Adjust clustering parameters");F.style.fontSize="16px",E.root.appendChild(F);const D=t.filter.onChanged.subscribe((()=>b())),G=()=>p(this,void 0,void 0,(function*(){var i,o;const r=null!=e?e:u.value;return D.unsubscribe(),!!r&&null!==(yield v(S.value,r,T.value,t,g,null!==(i=A.value)&&void 0!==i?i:s.rg.NONE,{addSequenceSpace:!1,addMCL:E.value,useEmbeddingsClusters:null!==(o=E.value)&&void 0!==o&&o,mclSettings:n}))}));let U="auto";const q=[o.divV(_)];if(c()(q[0]).find("label").css("width","unset"),void 0!==e){const t=o.button("Launch SAR",G,"");t.style.alignSelf="center",q.push(t),U="215px"}return c()(l).empty().append(o.wait((()=>p(this,void 0,void 0,(function*(){var n;const i=yield t.plot.fromType("WebLogo",{sequenceColumnName:null!==(n=null==e?void 0:e.name)&&void 0!==n?n:u.value.name});return i.root.style.setProperty("height","130px"),i.root}))))),{host:o.divV([l,o.splitH([o.splitV(q,{style:{flex:"0 1 auto"}}),w],{style:{height:U,minWidth:"600px",maxWidth:"750px"}}),V]),callback:G}}))}function v(t,e,n,o,u,c){return p(this,arguments,void 0,(function*(t,e,n,o,u,c,h={}){var d,f,m,p,g;let v=null;if(t.type!==r.COLUMN_TYPE.FLOAT&&t.type!==r.COLUMN_TYPE.INT&&t.type!==r.COLUMN_TYPE.QNUM)return i.shell.error("The activity column must be of numeric type!"),v;const C=r.TaskBarProgressIndicator.create("Loading SAR...");o.tags.delete&&o.tags.delete(".script");const y=o.columns,w=o.col(u.name);w&&(w.name=y.getUnusedName(w.name));const A=u.getRawData();o.columns.addNew(u.name,u.type).init((t=>A[t])),y.setOrder([u.name,e.name,...y.names().filter((t=>t!==e.name&&t!==u.name))]);const b={sequenceColumnName:e.name,activityColumnName:t.name,activityScaling:c,columns:{},showDendrogram:!1,showSequenceSpace:!1,sequenceSpaceParams:new a.GI(!!h.useEmbeddingsClusters&&!n),mclSettings:null!==(d=h.mclSettings)&&void 0!==d?d:new a.av};if(n){const t=o.getCol(n.name);t.type!==r.COLUMN_TYPE.STRING&&y.replace(t,t.convertTo(r.COLUMN_TYPE.STRING))}if(o.setTag(s.gp.SETTINGS,JSON.stringify(b)),v=l.i.getInstance(o),v.init(b),n){const i={clustersColumnName:n.name,sequenceColumnName:e.name,activityScaling:c,activityColumnName:t.name};yield v.addLogoSummaryTable(i)}if(yield v.addMonomerPosition(),yield v.addMostPotentResidues(),null!==(f=h.addSequenceSpace)&&void 0!==f&&f){if(yield v.addSequenceSpace({clusterCol:n,clusterEmbeddings:h.useEmbeddingsClusters}),!n&&null!==(m=h.useEmbeddingsClusters)&&void 0!==m&&m){const n=v._sequenceSpaceCols.find((t=>{var e;return v.df.col(t)&&(null===(e=v.df.col(t))||void 0===e?void 0:e.type)===r.COLUMN_TYPE.STRING}));if(n){const i={clustersColumnName:n,sequenceColumnName:e.name,activityScaling:c,activityColumnName:t.name};yield v.addLogoSummaryTable(i),setTimeout((()=>{var t,e;v&&(null===(t=null==v?void 0:v.findViewer(l.q.LOGO_SUMMARY_TABLE))||void 0===t?void 0:t.render)&&(null===(e=null==v?void 0:v.findViewer(l.q.LOGO_SUMMARY_TABLE))||void 0===e||e.render())}),100)}}}else if(null!==(p=h.addMCL)&&void 0!==p&&p&&(yield v.addMCLClusters(),!n&&null!==(g=h.useEmbeddingsClusters)&&void 0!==g&&g)){const n=v._mclCols.find((t=>(null==v?void 0:v.df.col(t))&&t.toLowerCase().startsWith("cluster")&&!t.toLowerCase().includes("size")));if(n){const i={clustersColumnName:n,sequenceColumnName:e.name,activityScaling:c,activityColumnName:t.name};yield v.addLogoSummaryTable(i),setTimeout((()=>{var t,e;v&&(null===(t=null==v?void 0:v.findViewer(l.q.LOGO_SUMMARY_TABLE))||void 0===t?void 0:t.render)&&(null===(e=null==v?void 0:v.findViewer(l.q.LOGO_SUMMARY_TABLE))||void 0===e||e.render())}),100)}}const S=v.df.plot.grid({rowSource:r.RowSet.Selected,selectedRowsColor:r.Color.fromHtml("#ffffff"),title:"Selection"}),T=null==v?void 0:v.findViewerNode(l.q.LOGO_SUMMARY_TABLE);return T&&v.analysisView.dockManager.dock(S,r.DOCK_TYPE.DOWN,T,"Selection",.4),C.close(),v}))}},5429:(t,e,n)=>{"use strict";n.d(e,{OH:()=>A,t_:()=>l});var i,o,r,s,a,l,u=n(7389),c=n(4328),h=n(6082),d=n(115),f=n(4139),m=n(9499),p=n(7233),g=n.n(p),v=n(144),C=n.n(v),y=n(3262),w=n(1199);function A(t){var e,n,r,p,v,A,b,S,T,E;null==t.settings&&c.log.error("PeptidesError: Settings are not initialized");const _=u.accordion(),N=t.settings,x=null!==(e=null==N?void 0:N.activityScaling)&&void 0!==e?e:f.rg.NONE,M=null!==(n=null==N?void 0:N.columns)&&void 0!==n?n:{},I={},O={},L=null!==(r=null==N?void 0:N.sequenceSpaceParams)&&void 0!==r?r:new d.GI,P=null!==(p=null==N?void 0:N.mclSettings)&&void 0!==p?p:new d.av,R=u.input.column(o.ACTIVITY,{table:t.df,value:t.df.getCol(t.settings.activityColumnName),onValueChanged:t=>{I.activityColumnName=t.name},filter:t=>(t.type===h.TYPE.FLOAT||t.type===h.TYPE.INT)&&t.name!==f.$2.ACTIVITY&&0===t.stats.missingValueCount});R.setTooltip("Numeric activity column");const k=u.input.choice(o.ACTIVITY_SCALING,{value:x,items:Object.values(f.rg),onValueChanged:t=>I.activityScaling=t});k.setTooltip("Activity column transformation method"),_.addPane(i.GENERAL,(()=>u.inputs([R,k])),!0),O[i.GENERAL]=[R,k];const V=C()(t.analysisView.viewers).some((t=>t.type===m.q.DENDROGRAM)),F=u.input.bool(m.q.DENDROGRAM,{value:null!=V&&V,onValueChanged:t=>I.showDendrogram=t}),D=u.input.bool(m.q.CLUSTER_MAX_ACTIVITY,{value:!!(null==N?void 0:N.showClusterMaxActivity),onValueChanged:t=>{I.showClusterMaxActivity=null!=t?t:void 0}}),G=u.input.bool("Sequence space",{value:!!(null==N?void 0:N.showSequenceSpace),onValueChanged:t=>{I.showSequenceSpace=null!=t?t:void 0,t?(ft.root.style.display="flex",(null==N?void 0:N.showSequenceSpace)||(I.sequenceSpaceParams=L)):(ft.root.style.display="none",delete I.sequenceSpaceParams),I.showSequenceSpace===(null==N?void 0:N.showSequenceSpace)&&delete I.showSequenceSpace}});D.setTooltip("Show cluster max activity viewer"),F.setTooltip("Show dendrogram viewer"),F.enabled=null!==(0,y.getTreeHelperInstance)(),_.addPane(i.VIEWERS,(()=>u.inputs([F,G,D])),!0),O[i.VIEWERS]=[F,G,D];const U=[],q=[];for(const e of t.df.columns.numerical){const t=e.name;if(t===N.activityColumnName||t===f.$2.ACTIVITY)continue;const n=u.input.bool(s.IS_INCLUDED,{value:void 0!==M[t],onValueChanged:e=>{var n;null!==(n=I.columns)&&void 0!==n||(I.columns={}),e?I.columns[t]=i.value:(delete I.columns[t],Object.keys(I.columns).length===Object.keys(M).length&&delete I.columns)}});n.setTooltip("Include aggregated column value in tooltips, Logo Summary Table and Distribution panel");const i=u.input.choice(s.AGGREGATION,{value:null!==(v=M[t])&&void 0!==v?v:h.AGG.AVG,items:Object.values(h.STATS),onValueChanged:i=>{var o;null!==(o=I.columns)&&void 0!==o||(I.columns={}),n.value?I.columns[t]=i:(delete I.columns[e.name],Object.keys(I.columns).length===Object.keys(M).length&&delete I.columns)}});i.setTooltip("Aggregation method"),g()(i.root).find("label").css("width","auto");const o=u.inputsRow(e.name,[n,i]);q.push(n,i),g()(o).find("div.ui-div").css("display","inline-flex"),U.push(o)}0!==U.length&&(_.addPane(i.COLUMNS,(()=>u.divV(U)),!1),O[i.COLUMNS]=q);const B={};function H(t,e){if(X(),null==e||""===e)return;B[t]=e;let n=!0;for(const[t,e]of Object.entries(B))if(e!==L[t]){n=!1;break}n?delete I.sequenceSpaceParams:I.sequenceSpaceParams=Object.assign(Object.assign({},L),B)}function Y(t,e){t.forEach((t=>{t.root.style.display=e?"flex":"none"}))}const j=u.input.choice(a.DISTANCE_FUNCTION,{value:L.distanceF,items:[w.Z.NEEDLEMANN_WUNSCH,w.Z.HAMMING,w.Z.LEVENSHTEIN,w.Z.MONOMER_CHEMICAL_DISTANCE],onValueChanged:t=>H("distanceF",t)});j.setTooltip("Distance function for sequences");const W=u.input.float(a.GAP_OPEN,{value:L.gapOpen,onValueChanged:t=>H("gapOpen",t)}),$=u.input.float(a.GAP_EXTEND,{value:L.gapExtend,onValueChanged:t=>H("gapExtend",t)}),z=u.input.bool(a.CLUSTER_EMBEDDINGS,{value:null!==(A=L.clusterEmbeddings)&&void 0!==A&&A,onValueChanged:t=>H("clusterEmbeddings",t)});z.setTooltip("Cluster embeddings using DBSCAN algorithm");const K=u.input.float(a.EPSILON,{value:L.epsilon,onValueChanged:t=>H("epsilon",t)});K.setTooltip("Epsilon parameter for DBSCAN. Minimum distance between two points to be considered as a cluster");const Z=u.input.int(a.MIN_PTS,{value:L.minPts,onValueChanged:t=>H("minPts",t)});Z.setTooltip("Minimum number of points in a cluster");const Q=u.input.choice(a.FINGERPRINT_TYPE,{value:L.fingerprintType,items:["Morgan","RDKit","Pattern","AtomPair","MACCS","TopologicalTorsion"],onValueChanged:t=>H("fingerprintType",t)});function X(){Y([W,$],j.value===w.Z.NEEDLEMANN_WUNSCH),Y([K,Z],!0===z.value),Y([Q],j.value===w.Z.MONOMER_CHEMICAL_DISTANCE||j.value===w.Z.NEEDLEMANN_WUNSCH)}X();const J={};function tt(t,e){if(et(),null==e||""===e)return;J[t]=e;let n=!0;for(const[t,e]of Object.entries(J))if(e!==P[t]){n=!1;break}n?delete I.mclSettings:I.mclSettings=Object.assign(Object.assign({},P),J)}function et(){Y([it,ot],nt.value===w.Z.NEEDLEMANN_WUNSCH),Y([rt],nt.value===w.Z.MONOMER_CHEMICAL_DISTANCE||nt.value===w.Z.NEEDLEMANN_WUNSCH)}const nt=u.input.choice(l.DISTANCE_FUNCTION,{value:P.distanceF,items:[w.Z.NEEDLEMANN_WUNSCH,w.Z.MONOMER_CHEMICAL_DISTANCE,w.Z.HAMMING,w.Z.LEVENSHTEIN],onValueChanged:t=>tt("distanceF",t)}),it=u.input.float(l.GAP_OPEN,{value:P.gapOpen,onValueChanged:t=>tt("gapOpen",t)}),ot=u.input.float(l.GAP_EXTEND,{value:P.gapExtend,onValueChanged:t=>tt("gapExtend",t)}),rt=u.input.choice(l.FINGERPRINT_TYPE,{value:P.fingerprintType,items:["Morgan","RDKit","Pattern","AtomPair","MACCS","TopologicalTorsion"],onValueChanged:t=>tt("fingerprintType",t)}),st=u.input.int(l.THRESHOLD,{value:null!==(b=P.threshold)&&void 0!==b?b:80,onValueChanged:t=>tt("threshold",t)}),at=u.input.int(l.MAX_ITERATIONS,{value:null!==(S=P.maxIterations)&&void 0!==S?S:5,onValueChanged:t=>tt("maxIterations",t)}),lt=u.input.float(l.INFLATION,{value:null!==(T=P.inflation)&&void 0!==T?T:1.4,onValueChanged:t=>{tt("inflation",t)}}),ut=u.input.bool(l.USE_WEBGPU,{value:P.useWebGPU,onValueChanged:t=>tt("useWebGPU",t)});ut.enabled=!1,P.webGPUDescriptionPromise.then((()=>{P.webGPUDescription!==d.Ku?(ut.setTooltip(`Use WebGPU for MCL algorithm (${P.webGPUDescription})`),ut.enabled=!0):(ut.setTooltip(d.Ku),ut.enabled=!1,ut.value=!1)}));const ct=u.input.int(l.MIN_CLUSTER_SIZE,{value:null!==(E=P.minClusterSize)&&void 0!==E?E:5,onValueChanged:t=>tt("minClusterSize",t)});et();const ht=[st,nt,rt,it,ot,lt,at,ct,ut];_.addPane(i.MCL,(()=>u.inputs(ht)),!0),O[i.MCL]=ht;const dt=[j,Q,W,$,z,K,Z],ft=_.addPane(i.SEQUENCE_SPACE,(()=>u.inputs(dt)),!0);O[i.SEQUENCE_SPACE]=dt,G.fireChanged();const mt=u.dialog("Peptides settings").add(_);return mt.root.style.width="400px",mt.onOK((()=>{t.settings=I})),mt.show(),{dialog:mt,accordion:_,inputs:O}}!function(t){t.GENERAL="General",t.VIEWERS="Viewers",t.COLUMNS="Columns",t.SEQUENCE_SPACE="Sequence space",t.MCL="MCL"}(i||(i={})),function(t){t.ACTIVITY="Activity",t.ACTIVITY_SCALING="Activity scaling"}(o||(o={})),function(t){t.DENDROGRAM="Dendrogram"}(r||(r={})),function(t){t.IS_INCLUDED="",t.AGGREGATION="Aggregation"}(s||(s={})),function(t){t.DISTANCE_FUNCTION="Distance Function",t.GAP_OPEN="Gap Open Penalty",t.GAP_EXTEND="Gap Extend Penalty",t.CLUSTER_EMBEDDINGS="Cluster Embeddings",t.EPSILON="Epsilon",t.MIN_PTS="Minimum Points",t.FINGERPRINT_TYPE="Fingerprint Type"}(a||(a={})),function(t){t.DISTANCE_FUNCTION="Distance Function",t.GAP_OPEN="Gap Open Penalty",t.GAP_EXTEND="Gap Extend Penalty",t.FINGERPRINT_TYPE="Fingerprint Type",t.THRESHOLD="Similarity Threshold",t.INFLATION="Inflation Factor",t.MAX_ITERATIONS="Max Iterations",t.USE_WEBGPU="Use WebGPU",t.MIN_CLUSTER_SIZE="Min Cluster Size"}(l||(l={})),i.GENERAL,i.VIEWERS,i.COLUMNS,i.SEQUENCE_SPACE,i.MCL},144:function(t){var e;e=function(){return function(t){var e={};function n(i){if(e[i])return e[i].exports;var o=e[i]={exports:{},id:i,loaded:!1};return t[i].call(o.exports,o,o.exports,n),o.loaded=!0,o.exports}return n.m=t,n.c=e,n.p="",n(0)}([function(t,e,n){"use strict";var i=n(1).default,o=n(39).default,r=n(52).default,s=n(40).default,a=n(54).default,l=n(80).default,u=n(84).default,c=n(65).default,h=t.exports=function(t){if(!m(t))throw new Error("wu: `"+t+"` is not iterable!");return new d(t)};function d(t){var e=p(t);this.next=e.next.bind(e)}h.prototype=d.prototype,h.prototype[r]=function(){return this};var f={},m=function(t){return t&&"function"==typeof t[r]},p=function(t){if(m(t))return s(t);throw new TypeError("Not iterable: "+t)},g=function(t,e){e.prototype=d.prototype,h[t]=e},v=function(t,e){var n=arguments.length<=2||void 0===arguments[2]?e.length:arguments[2];return e.prototype=d.prototype,d.prototype[t]=e,n+=1,void(h[t]=h.curryable((function(){for(var e,n=arguments.length,i=Array(n),o=0;o<n;o++)i[o]=arguments[o];var r=i.pop();return(e=h(r))[t].apply(e,i)}),n))},C=function(t){return function(){for(var e=arguments.length,n=Array(e),i=0;i<e;i++)n[i]=arguments[i];return h(t.call.apply(t,[this].concat(n)))}},y=function(t,e){return g(t,C(e))},w=function(t,e,n){return v(t,C(e),n)};g("curryable",(function(t){var e=arguments.length<=1||void 0===arguments[1]?t.length:arguments[1];return function n(){for(var o=arguments.length,r=Array(o),s=0;s<o;s++)r[s]=arguments[s];return r.length>=e?t.apply(this,r):function(t,e){return function(){for(var n=arguments.length,o=Array(n),r=0;r<n;r++)o[r]=arguments[r];return t.call.apply(t,[this].concat(i(e),o))}}(n,r)}})),y("entries",a.mark((function t(e){var n,i,o,r,u,c;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=!0,i=!1,o=void 0,t.prev=3,r=s(l(e));case 5:if(n=(u=r.next()).done){t.next=12;break}return c=u.value,t.next=9,[c,e[c]];case 9:n=!0,t.next=5;break;case 12:t.next=18;break;case 14:t.prev=14,t.t0=t.catch(3),i=!0,o=t.t0;case 18:t.prev=18,t.prev=19,!n&&r.return&&r.return();case 21:if(t.prev=21,!i){t.next=24;break}throw o;case 24:return t.finish(21);case 25:return t.finish(18);case 26:case"end":return t.stop()}}),t,this,[[3,14,18,26],[19,,21,25]])}))),y("keys",a.mark((function t(e){return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.delegateYield(l(e),"t0",1);case 1:case"end":return t.stop()}}),t,this)}))),y("values",a.mark((function t(e){var n,i,o,r,u,c;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=!0,i=!1,o=void 0,t.prev=3,r=s(l(e));case 5:if(n=(u=r.next()).done){t.next=12;break}return c=u.value,t.next=9,e[c];case 9:n=!0,t.next=5;break;case 12:t.next=18;break;case 14:t.prev=14,t.t0=t.catch(3),i=!0,o=t.t0;case 18:t.prev=18,t.prev=19,!n&&r.return&&r.return();case 21:if(t.prev=21,!i){t.next=24;break}throw o;case 24:return t.finish(21);case 25:return t.finish(18);case 26:case"end":return t.stop()}}),t,this,[[3,14,18,26],[19,,21,25]])}))),w("cycle",a.mark((function t(){var e,n,i,o,r,l,u;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e=[],n=!0,i=!1,o=void 0,t.prev=4,r=s(this);case 6:if(n=(l=r.next()).done){t.next=14;break}return u=l.value,t.next=10,u;case 10:e.push(u);case 11:n=!0,t.next=6;break;case 14:t.next=20;break;case 16:t.prev=16,t.t0=t.catch(4),i=!0,o=t.t0;case 20:t.prev=20,t.prev=21,!n&&r.return&&r.return();case 23:if(t.prev=23,!i){t.next=26;break}throw o;case 26:return t.finish(23);case 27:return t.finish(20);case 28:if(!e){t.next=32;break}return t.delegateYield(e,"t1",30);case 30:t.next=28;break;case 32:case"end":return t.stop()}}),t,this,[[4,16,20,28],[21,,23,27]])}))),y("count",a.mark((function t(){var e,n=arguments.length<=0||void 0===arguments[0]?0:arguments[0],i=arguments.length<=1||void 0===arguments[1]?1:arguments[1];return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e=n;case 1:return t.next=4,e;case 4:e+=i,t.next=1;break;case 7:case"end":return t.stop()}}),t,this)}))),y("repeat",a.mark((function t(e){var n,i=arguments.length<=1||void 0===arguments[1]?1/0:arguments[1];return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(i!==1/0){t.next=8;break}case 1:return t.next=4,e;case 4:t.next=1;break;case 6:t.next=15;break;case 8:n=0;case 9:if(!(n<i)){t.next=15;break}return t.next=12,e;case 12:n++,t.next=9;break;case 15:case"end":return t.stop()}}),t,this)}))),y("chain",a.mark((function t(){var e,n,i,o,r,l,u,c,h,d=arguments;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:for(e=!0,n=!1,i=void 0,t.prev=3,o=d.length,r=Array(o),l=0;l<o;l++)r[l]=d[l];u=s(r);case 6:if(e=(c=u.next()).done){t.next=12;break}return h=c.value,t.delegateYield(h,"t0",9);case 9:e=!0,t.next=6;break;case 12:t.next=18;break;case 14:t.prev=14,t.t1=t.catch(3),n=!0,i=t.t1;case 18:t.prev=18,t.prev=19,!e&&u.return&&u.return();case 21:if(t.prev=21,!n){t.next=24;break}throw i;case 24:return t.finish(21);case 25:return t.finish(18);case 26:case"end":return t.stop()}}),t,this,[[3,14,18,26],[19,,21,25]])}))),w("chunk",a.mark((function t(){var e,n,i,o,r,l,u,c,h=arguments.length<=0||void 0===arguments[0]?2:arguments[0];return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e=[],n=0,i=!0,o=!1,r=void 0,t.prev=5,l=s(this);case 7:if(i=(u=l.next()).done){t.next=18;break}if(c=u.value,e[n++]=c,n!==h){t.next=15;break}return t.next=13,e;case 13:e=[],n=0;case 15:i=!0,t.next=7;break;case 18:t.next=24;break;case 20:t.prev=20,t.t0=t.catch(5),o=!0,r=t.t0;case 24:t.prev=24,t.prev=25,!i&&l.return&&l.return();case 27:if(t.prev=27,!o){t.next=30;break}throw r;case 30:return t.finish(27);case 31:return t.finish(24);case 32:if(!n){t.next=35;break}return t.next=35,e;case 35:case"end":return t.stop()}}),t,this,[[5,20,24,32],[25,,27,31]])})),1),w("concatMap",a.mark((function t(e){var n,i,o,r,l,u;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=!0,i=!1,o=void 0,t.prev=3,r=s(this);case 5:if(n=(l=r.next()).done){t.next=11;break}return u=l.value,t.delegateYield(e(u),"t0",8);case 8:n=!0,t.next=5;break;case 11:t.next=17;break;case 13:t.prev=13,t.t1=t.catch(3),i=!0,o=t.t1;case 17:t.prev=17,t.prev=18,!n&&r.return&&r.return();case 20:if(t.prev=20,!i){t.next=23;break}throw o;case 23:return t.finish(20);case 24:return t.finish(17);case 25:case"end":return t.stop()}}),t,this,[[3,13,17,25],[18,,20,24]])}))),w("drop",a.mark((function t(e){var n,i,o,r,l,u,c;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=0,i=!0,o=!1,r=void 0,t.prev=4,l=s(this);case 6:if(i=(u=l.next()).done){t.next=16;break}if(c=u.value,!(n++<e)){t.next=10;break}return t.abrupt("continue",13);case 10:return t.next=12,c;case 12:return t.abrupt("break",16);case 13:i=!0,t.next=6;break;case 16:t.next=22;break;case 18:t.prev=18,t.t0=t.catch(4),o=!0,r=t.t0;case 22:t.prev=22,t.prev=23,!i&&l.return&&l.return();case 25:if(t.prev=25,!o){t.next=28;break}throw r;case 28:return t.finish(25);case 29:return t.finish(22);case 30:return t.delegateYield(this,"t1",31);case 31:case"end":return t.stop()}}),t,this,[[4,18,22,30],[23,,25,29]])}))),w("dropWhile",a.mark((function t(){var e,n,i,o,r,l,u=arguments.length<=0||void 0===arguments[0]?Boolean:arguments[0];return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e=!0,n=!1,i=void 0,t.prev=3,o=s(this);case 5:if(e=(r=o.next()).done){t.next=15;break}if(l=r.value,!u(l)){t.next=9;break}return t.abrupt("continue",12);case 9:return t.next=11,l;case 11:return t.abrupt("break",15);case 12:e=!0,t.next=5;break;case 15:t.next=21;break;case 17:t.prev=17,t.t0=t.catch(3),n=!0,i=t.t0;case 21:t.prev=21,t.prev=22,!e&&o.return&&o.return();case 24:if(t.prev=24,!n){t.next=27;break}throw i;case 27:return t.finish(24);case 28:return t.finish(21);case 29:return t.delegateYield(this,"t1",30);case 30:case"end":return t.stop()}}),t,this,[[3,17,21,29],[22,,24,28]])})),1),w("enumerate",a.mark((function t(){return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.delegateYield(A([this,h.count()]),"t0",1);case 1:case"end":return t.stop()}}),t,this)}))),w("filter",a.mark((function t(){var e,n,i,o,r,l,u=arguments.length<=0||void 0===arguments[0]?Boolean:arguments[0];return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e=!0,n=!1,i=void 0,t.prev=3,o=s(this);case 5:if(e=(r=o.next()).done){t.next=13;break}if(l=r.value,!u(l)){t.next=10;break}return t.next=10,l;case 10:e=!0,t.next=5;break;case 13:t.next=19;break;case 15:t.prev=15,t.t0=t.catch(3),n=!0,i=t.t0;case 19:t.prev=19,t.prev=20,!e&&o.return&&o.return();case 22:if(t.prev=22,!n){t.next=25;break}throw i;case 25:return t.finish(22);case 26:return t.finish(19);case 27:case"end":return t.stop()}}),t,this,[[3,15,19,27],[20,,22,26]])})),1),w("flatten",a.mark((function t(){var e,n,i,o,r,l,u=!(arguments.length<=0||void 0===arguments[0])&&arguments[0];return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e=!0,n=!1,i=void 0,t.prev=3,o=s(this);case 5:if(e=(r=o.next()).done){t.next=16;break}if("string"==typeof(l=r.value)||!m(l)){t.next=11;break}return t.delegateYield(u?l:h(l).flatten(),"t0",9);case 9:t.next=13;break;case 11:return t.next=13,l;case 13:e=!0,t.next=5;break;case 16:t.next=22;break;case 18:t.prev=18,t.t1=t.catch(3),n=!0,i=t.t1;case 22:t.prev=22,t.prev=23,!e&&o.return&&o.return();case 25:if(t.prev=25,!n){t.next=28;break}throw i;case 28:return t.finish(25);case 29:return t.finish(22);case 30:case"end":return t.stop()}}),t,this,[[3,18,22,30],[23,,25,29]])})),1),w("invoke",a.mark((function t(e){var n,i,o,r,l,u,c,h,d,f=arguments;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:for(n=!0,i=!1,o=void 0,t.prev=3,r=f.length,l=Array(r>1?r-1:0),u=1;u<r;u++)l[u-1]=f[u];c=s(this);case 6:if(n=(h=c.next()).done){t.next=13;break}return d=h.value,t.next=10,d[e].apply(d,l);case 10:n=!0,t.next=6;break;case 13:t.next=19;break;case 15:t.prev=15,t.t0=t.catch(3),i=!0,o=t.t0;case 19:t.prev=19,t.prev=20,!n&&c.return&&c.return();case 22:if(t.prev=22,!i){t.next=25;break}throw o;case 25:return t.finish(22);case 26:return t.finish(19);case 27:case"end":return t.stop()}}),t,this,[[3,15,19,27],[20,,22,26]])}))),w("map",a.mark((function t(e){var n,i,o,r,l,u;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=!0,i=!1,o=void 0,t.prev=3,r=s(this);case 5:if(n=(l=r.next()).done){t.next=12;break}return u=l.value,t.next=9,e(u);case 9:n=!0,t.next=5;break;case 12:t.next=18;break;case 14:t.prev=14,t.t0=t.catch(3),i=!0,o=t.t0;case 18:t.prev=18,t.prev=19,!n&&r.return&&r.return();case 21:if(t.prev=21,!i){t.next=24;break}throw o;case 24:return t.finish(21);case 25:return t.finish(18);case 26:case"end":return t.stop()}}),t,this,[[3,14,18,26],[19,,21,25]])}))),w("pluck",a.mark((function t(e){var n,i,o,r,l,u;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=!0,i=!1,o=void 0,t.prev=3,r=s(this);case 5:if(n=(l=r.next()).done){t.next=12;break}return u=l.value,t.next=9,u[e];case 9:n=!0,t.next=5;break;case 12:t.next=18;break;case 14:t.prev=14,t.t0=t.catch(3),i=!0,o=t.t0;case 18:t.prev=18,t.prev=19,!n&&r.return&&r.return();case 21:if(t.prev=21,!i){t.next=24;break}throw o;case 24:return t.finish(21);case 25:return t.finish(18);case 26:case"end":return t.stop()}}),t,this,[[3,14,18,26],[19,,21,25]])}))),w("reductions",a.mark((function t(e){var n,i,o,r,l,u,c,h,d,f,m,p,g=arguments.length<=1||void 0===arguments[1]?void 0:arguments[1];return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(void 0!==(n=g)){t.next=28;break}i=!0,o=!1,r=void 0,t.prev=5,l=s(this);case 7:if(i=(u=l.next()).done){t.next=14;break}return c=u.value,n=c,t.abrupt("break",14);case 11:i=!0,t.next=7;break;case 14:t.next=20;break;case 16:t.prev=16,t.t0=t.catch(5),o=!0,r=t.t0;case 20:t.prev=20,t.prev=21,!i&&l.return&&l.return();case 23:if(t.prev=23,!o){t.next=26;break}throw r;case 26:return t.finish(23);case 27:return t.finish(20);case 28:return t.next=30,n;case 30:h=!0,d=!1,f=void 0,t.prev=33,m=s(this);case 35:if(h=(p=m.next()).done){t.next=42;break}return c=p.value,t.next=39,n=e(n,c);case 39:h=!0,t.next=35;break;case 42:t.next=48;break;case 44:t.prev=44,t.t1=t.catch(33),d=!0,f=t.t1;case 48:t.prev=48,t.prev=49,!h&&m.return&&m.return();case 51:if(t.prev=51,!d){t.next=54;break}throw f;case 54:return t.finish(51);case 55:return t.finish(48);case 56:return t.abrupt("return",n);case 57:case"end":return t.stop()}}),t,this,[[5,16,20,28],[21,,23,27],[33,44,48,56],[49,,51,55]])})),2),w("reject",a.mark((function t(){var e,n,i,o,r,l,u=arguments.length<=0||void 0===arguments[0]?Boolean:arguments[0];return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e=!0,n=!1,i=void 0,t.prev=3,o=s(this);case 5:if(e=(r=o.next()).done){t.next=13;break}if(l=r.value,u(l)){t.next=10;break}return t.next=10,l;case 10:e=!0,t.next=5;break;case 13:t.next=19;break;case 15:t.prev=15,t.t0=t.catch(3),n=!0,i=t.t0;case 19:t.prev=19,t.prev=20,!e&&o.return&&o.return();case 22:if(t.prev=22,!n){t.next=25;break}throw i;case 25:return t.finish(22);case 26:return t.finish(19);case 27:case"end":return t.stop()}}),t,this,[[3,15,19,27],[20,,22,26]])})),1),w("slice",a.mark((function t(){var e,n,i,r,l,u,c,h,d=arguments.length<=0||void 0===arguments[0]?0:arguments[0],f=arguments.length<=1||void 0===arguments[1]?1/0:arguments[1];return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(f<d)){t.next=2;break}throw new RangeError("parameter `stop` (= "+f+") must be >= `start` (= "+d+")");case 2:e=!0,n=!1,i=void 0,t.prev=5,r=s(this.enumerate());case 7:if(e=(l=r.next()).done){t.next=20;break}if(u=o(l.value,2),c=u[0],!((h=u[1])<d)){t.next=13;break}return t.abrupt("continue",17);case 13:if(!(h>=f)){t.next=15;break}return t.abrupt("break",20);case 15:return t.next=17,c;case 17:e=!0,t.next=7;break;case 20:t.next=26;break;case 22:t.prev=22,t.t0=t.catch(5),n=!0,i=t.t0;case 26:t.prev=26,t.prev=27,!e&&r.return&&r.return();case 29:if(t.prev=29,!n){t.next=32;break}throw i;case 32:return t.finish(29);case 33:return t.finish(26);case 34:case"end":return t.stop()}}),t,this,[[5,22,26,34],[27,,29,33]])})),2),w("spreadMap",a.mark((function t(e){var n,o,r,l,u,c;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=!0,o=!1,r=void 0,t.prev=3,l=s(this);case 5:if(n=(u=l.next()).done){t.next=12;break}return c=u.value,t.next=9,e.apply(void 0,i(c));case 9:n=!0,t.next=5;break;case 12:t.next=18;break;case 14:t.prev=14,t.t0=t.catch(3),o=!0,r=t.t0;case 18:t.prev=18,t.prev=19,!n&&l.return&&l.return();case 21:if(t.prev=21,!o){t.next=24;break}throw r;case 24:return t.finish(21);case 25:return t.finish(18);case 26:case"end":return t.stop()}}),t,this,[[3,14,18,26],[19,,21,25]])}))),w("take",a.mark((function t(e){var n,i,o,r,l,u,c;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e<1)){t.next=2;break}return t.abrupt("return");case 2:n=0,i=!0,o=!1,r=void 0,t.prev=6,l=s(this);case 8:if(i=(u=l.next()).done){t.next=17;break}return c=u.value,t.next=12,c;case 12:if(!(++n>=e)){t.next=14;break}return t.abrupt("break",17);case 14:i=!0,t.next=8;break;case 17:t.next=23;break;case 19:t.prev=19,t.t0=t.catch(6),o=!0,r=t.t0;case 23:t.prev=23,t.prev=24,!i&&l.return&&l.return();case 26:if(t.prev=26,!o){t.next=29;break}throw r;case 29:return t.finish(26);case 30:return t.finish(23);case 31:case"end":return t.stop()}}),t,this,[[6,19,23,31],[24,,26,30]])}))),w("takeWhile",a.mark((function t(){var e,n,i,o,r,l,u=arguments.length<=0||void 0===arguments[0]?Boolean:arguments[0];return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e=!0,n=!1,i=void 0,t.prev=3,o=s(this);case 5:if(e=(r=o.next()).done){t.next=14;break}if(l=r.value,u(l)){t.next=9;break}return t.abrupt("break",14);case 9:return t.next=11,l;case 11:e=!0,t.next=5;break;case 14:t.next=20;break;case 16:t.prev=16,t.t0=t.catch(3),n=!0,i=t.t0;case 20:t.prev=20,t.prev=21,!e&&o.return&&o.return();case 23:if(t.prev=23,!n){t.next=26;break}throw i;case 26:return t.finish(23);case 27:return t.finish(20);case 28:case"end":return t.stop()}}),t,this,[[3,16,20,28],[21,,23,27]])})),1),w("tap",a.mark((function t(){var e,n,i,o,r,l,u=arguments.length<=0||void 0===arguments[0]?console.log.bind(console):arguments[0];return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e=!0,n=!1,i=void 0,t.prev=3,o=s(this);case 5:if(e=(r=o.next()).done){t.next=13;break}return l=r.value,u(l),t.next=10,l;case 10:e=!0,t.next=5;break;case 13:t.next=19;break;case 15:t.prev=15,t.t0=t.catch(3),n=!0,i=t.t0;case 19:t.prev=19,t.prev=20,!e&&o.return&&o.return();case 22:if(t.prev=22,!n){t.next=25;break}throw i;case 25:return t.finish(22);case 26:return t.finish(19);case 27:case"end":return t.stop()}}),t,this,[[3,15,19,27],[20,,22,26]])})),1),w("unique",a.mark((function t(){var e,n,i,o,r,l,c;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e=new u,n=!0,i=!1,o=void 0,t.prev=4,r=s(this);case 6:if(n=(l=r.next()).done){t.next=15;break}if(c=l.value,e.has(c)){t.next=12;break}return t.next=11,c;case 11:e.add(c);case 12:n=!0,t.next=6;break;case 15:t.next=21;break;case 17:t.prev=17,t.t0=t.catch(4),i=!0,o=t.t0;case 21:t.prev=21,t.prev=22,!n&&r.return&&r.return();case 24:if(t.prev=24,!i){t.next=27;break}throw o;case 27:return t.finish(24);case 28:return t.finish(21);case 29:e.clear();case 30:case"end":return t.stop()}}),t,this,[[4,17,21,29],[22,,24,28]])})));var A=C(a.mark((function t(e){var n,i,o,r,l,u,c,h,d,f,m,g,v,C=!(arguments.length<=1||void 0===arguments[1])&&arguments[1];return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.length){t.next=2;break}return t.abrupt("return");case 2:n=e.map(p),i=e.length,o=0,r=!1;case 6:if(r){t.next=44;break}l=[],u=!0,c=!1,h=void 0,t.prev=11,d=s(n);case 13:if(u=(f=d.next()).done){t.next=26;break}if(m=f.value,g=m.next(),v=g.value,!g.done){t.next=22;break}if(C){t.next=21;break}return t.abrupt("return");case 21:++o==i&&(r=!0);case 22:void 0===v?l.length++:l.push(v);case 23:u=!0,t.next=13;break;case 26:t.next=32;break;case 28:t.prev=28,t.t0=t.catch(11),c=!0,h=t.t0;case 32:t.prev=32,t.prev=33,!u&&d.return&&d.return();case 35:if(t.prev=35,!c){t.next=38;break}throw h;case 38:return t.finish(35);case 39:return t.finish(32);case 40:return t.next=42,l;case 42:t.next=6;break;case 44:case"end":return t.stop()}}),t,this,[[11,28,32,40],[33,,35,39]])})));y("zip",a.mark((function t(){for(var e=arguments.length,n=Array(e),i=0;i<e;i++)n[i]=arguments[i];return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.delegateYield(A(n),"t0",1);case 1:case"end":return t.stop()}}),t,this)}))),y("zipLongest",a.mark((function t(){for(var e=arguments.length,n=Array(e),i=0;i<e;i++)n[i]=arguments[i];return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.delegateYield(A(n,!0),"t0",1);case 1:case"end":return t.stop()}}),t,this)}))),y("zipWith",a.mark((function t(e){for(var n=arguments.length,i=Array(n>1?n-1:0),o=1;o<n;o++)i[o-1]=arguments[o];return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.delegateYield(A(i).spreadMap(e),"t0",1);case 1:case"end":return t.stop()}}),t,this)}))),h.MAX_BLOCK=15,h.TIMEOUT=1,v("asyncEach",(function(t){var e=arguments.length<=1||void 0===arguments[1]?h.MAX_BLOCK:arguments[1],n=arguments.length<=2||void 0===arguments[2]?h.TIMEOUT:arguments[2],i=p(this);return new c((function(o,r){!function a(){var l=Date.now(),u=!0,c=!1,h=void 0;try{for(var d,f=s(i);!(u=(d=f.next()).done);u=!0){var m=d.value;try{t(m)}catch(t){return void r(t)}if(Date.now()-l>e)return void setTimeout(a,n)}}catch(t){c=!0,h=t}finally{try{!u&&f.return&&f.return()}finally{if(c)throw h}}o()}()}))}),3),v("every",(function(){var t=arguments.length<=0||void 0===arguments[0]?Boolean:arguments[0],e=!0,n=!1,i=void 0;try{for(var o,r=s(this);!(e=(o=r.next()).done);e=!0)if(!t(o.value))return!1}catch(t){n=!0,i=t}finally{try{!e&&r.return&&r.return()}finally{if(n)throw i}}return!0}),1),v("find",(function(t){var e=!0,n=!1,i=void 0;try{for(var o,r=s(this);!(e=(o=r.next()).done);e=!0){var a=o.value;if(t(a))return a}}catch(t){n=!0,i=t}finally{try{!e&&r.return&&r.return()}finally{if(n)throw i}}})),v("forEach",(function(t){var e=!0,n=!1,i=void 0;try{for(var o,r=s(this);!(e=(o=r.next()).done);e=!0)t(o.value)}catch(t){n=!0,i=t}finally{try{!e&&r.return&&r.return()}finally{if(n)throw i}}})),v("has",(function(t){return this.some((function(e){return e===t}))})),v("reduce",(function(t){var e=arguments.length<=1||void 0===arguments[1]?void 0:arguments[1];if(void 0===e){var n=!0,i=!1,o=void 0;try{for(var r,a=s(this);!(n=(r=a.next()).done);n=!0){e=r.value;break}}catch(t){i=!0,o=t}finally{try{!n&&a.return&&a.return()}finally{if(i)throw o}}}var l=!0,u=!1,c=void 0;try{for(var h,d=s(this);!(l=(h=d.next()).done);l=!0)e=t(e,h.value)}catch(t){u=!0,c=t}finally{try{!l&&d.return&&d.return()}finally{if(u)throw c}}return e}),2),v("some",(function(){var t=arguments.length<=0||void 0===arguments[0]?Boolean:arguments[0],e=!0,n=!1,i=void 0;try{for(var o,r=s(this);!(e=(o=r.next()).done);e=!0)if(t(o.value))return!0}catch(t){n=!0,i=t}finally{try{!e&&r.return&&r.return()}finally{if(n)throw i}}return!1}),1),v("toArray",(function(){return[].concat(i(this))}));var b=C(a.mark((function t(e,n){var i,o,r,s,l;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:i=n.items,o=0;case 2:if(o!==i.length){t.next=14;break}if(r=e.next(),s=r.done,l=r.value,!s){t.next=10;break}return n.returned===f&&(n.returned=l),t.abrupt("break",25);case 10:return t.next=12,i[o++]=l;case 12:t.next=23;break;case 14:if(o!==n.tail){t.next=21;break}return l=i[o],500===o?(i=n.items=i.slice(o),o=0,n.tail=0):(i[o]=void 0,n.tail=++o),t.next=19,l;case 19:t.next=23;break;case 21:return t.next=23,i[o++];case 23:t.next=2;break;case 25:return n.tail===o&&(i.length=0),t.abrupt("return",n.returned);case 27:case"end":return t.stop()}}),t,this)})));b.prototype=d.prototype,v("tee",(function(){for(var t=arguments.length<=0||void 0===arguments[0]?2:arguments[0],e=new Array(t),n={tail:0,items:[],returned:f};t--;)e[t]=b(this,n);return e}),1),v("unzip",(function(){var t=arguments.length<=0||void 0===arguments[0]?2:arguments[0];return this.tee(t).map((function(t,e){return t.pluck(e)}))}),1),h.tang={clan:36}},function(t,e,n){"use strict";var i=n(2).default;e.default=function(t){if(Array.isArray(t)){for(var e=0,n=Array(t.length);e<t.length;e++)n[e]=t[e];return n}return i(t)},e.__esModule=!0},function(t,e,n){t.exports={default:n(3),__esModule:!0}},function(t,e,n){n(4),n(26),t.exports=n(12).Array.from},function(t,e,n){"use strict";var i=n(5)(!0);n(8)(String,"String",(function(t){this._t=String(t),this._i=0}),(function(){var t,e=this._t,n=this._i;return n>=e.length?{value:void 0,done:!0}:(t=i(e,n),this._i+=t.length,{value:t,done:!1})}))},function(t,e,n){var i=n(6),o=n(7);t.exports=function(t){return function(e,n){var r,s,a=String(o(e)),l=i(n),u=a.length;return l<0||l>=u?t?"":void 0:(r=a.charCodeAt(l))<55296||r>56319||l+1===u||(s=a.charCodeAt(l+1))<56320||s>57343?t?a.charAt(l):r:t?a.slice(l,l+2):s-56320+(r-55296<<10)+65536}}},function(t,e){var n=Math.ceil,i=Math.floor;t.exports=function(t){return isNaN(t=+t)?0:(t>0?i:n)(t)}},function(t,e){t.exports=function(t){if(null==t)throw TypeError("Can't call method on "+t);return t}},function(t,e,n){"use strict";var i=n(9),o=n(10),r=n(13),s=n(14),a=n(19),l=n(20)("iterator"),u=n(23),c=!([].keys&&"next"in[].keys()),h="@@iterator",d="keys",f="values",m=function(){return this};t.exports=function(t,e,p,g,v,C,y){n(24)(p,e,g);var w,A,b=function(t){switch(t){case d:case f:return function(){return new p(this,t)}}return function(){return new p(this,t)}},S=e+" Iterator",T=t.prototype,E=T[l]||T[h]||v&&T[v],_=E||b(v);if(E){var N=n(15).getProto(_.call(new t));n(25)(N,S,!0),!i&&a(T,h)&&s(N,l,m)}if(i&&!y||s(T,l,_),u[e]=_,u[S]=m,v)if(w={keys:C?_:b(d),values:v==f?_:b(f),entries:v!=f?_:b("entries")},y)for(A in w)A in T||r(T,A,w[A]);else o(o.P+o.F*c,e,w)}},function(t,e){t.exports=!0},function(t,e,n){var i=n(11),o=n(12),r="prototype",s=function(t,e){return function(){return t.apply(e,arguments)}},a=function(t,e,n){var l,u,c,h,d=t&a.G,f=t&a.P,m=d?i:t&a.S?i[e]:(i[e]||{})[r],p=d?o:o[e]||(o[e]={});for(l in d&&(n=e),n)(u=!(t&a.F)&&m&&l in m)&&l in p||(c=u?m[l]:n[l],d&&"function"!=typeof m[l]?h=n[l]:t&a.B&&u?h=s(c,i):t&a.W&&m[l]==c?function(t){(h=function(e){return this instanceof t?new t(e):t(e)})[r]=t[r]}(c):h=f&&"function"==typeof c?s(Function.call,c):c,p[l]=h,f&&((p[r]||(p[r]={}))[l]=c))};a.F=1,a.G=2,a.S=4,a.P=8,a.B=16,a.W=32,t.exports=a},function(t,e){var n="undefined",i=t.exports=typeof window!=n&&window.Math==Math?window:typeof self!=n&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=i)},function(t,e){var n=t.exports={version:"1.2.0"};"number"==typeof __e&&(__e=n)},function(t,e,n){t.exports=n(14)},function(t,e,n){var i=n(15),o=n(16);t.exports=n(17)?function(t,e,n){return i.setDesc(t,e,o(1,n))}:function(t,e,n){return t[e]=n,t}},function(t,e){var n=Object;t.exports={create:n.create,getProto:n.getPrototypeOf,isEnum:{}.propertyIsEnumerable,getDesc:n.getOwnPropertyDescriptor,setDesc:n.defineProperty,setDescs:n.defineProperties,getKeys:n.keys,getNames:n.getOwnPropertyNames,getSymbols:n.getOwnPropertySymbols,each:[].forEach}},function(t,e){t.exports=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}}},function(t,e,n){t.exports=!n(18)((function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a}))},function(t,e){t.exports=function(t){try{return!!t()}catch(t){return!0}}},function(t,e){var n={}.hasOwnProperty;t.exports=function(t,e){return n.call(t,e)}},function(t,e,n){var i=n(21)("wks"),o=n(11).Symbol;t.exports=function(t){return i[t]||(i[t]=o&&o[t]||(o||n(22))("Symbol."+t))}},function(t,e,n){var i=n(11),o="__core-js_shared__",r=i[o]||(i[o]={});t.exports=function(t){return r[t]||(r[t]={})}},function(t,e){var n=0,i=Math.random();t.exports=function(t){return"Symbol(".concat(void 0===t?"":t,")_",(++n+i).toString(36))}},function(t,e){t.exports={}},function(t,e,n){"use strict";var i=n(15),o={};n(14)(o,n(20)("iterator"),(function(){return this})),t.exports=function(t,e,r){t.prototype=i.create(o,{next:n(16)(1,r)}),n(25)(t,e+" Iterator")}},function(t,e,n){var i=n(19),o=n(14),r=n(20)("toStringTag");t.exports=function(t,e,n){t&&!i(t=n?t:t.prototype,r)&&o(t,r,e)}},function(t,e,n){"use strict";var i=n(27),o=n(10),r=n(29),s=n(30),a=n(33),l=n(34),u=n(35);o(o.S+o.F*!n(38)((function(t){Array.from(t)})),"Array",{from:function(t){var e,n,o,c,h=r(t),d="function"==typeof this?this:Array,f=arguments[1],m=void 0!==f,p=0,g=u(h);if(m&&(f=i(f,arguments[2],2)),null==g||d==Array&&a(g))for(n=new d(e=l(h.length));e>p;p++)n[p]=m?f(h[p],p):h[p];else for(c=g.call(h),n=new d;!(o=c.next()).done;p++)n[p]=m?s(c,f,[o.value,p],!0):o.value;return n.length=p,n}})},function(t,e,n){var i=n(28);t.exports=function(t,e,n){if(i(t),void 0===e)return t;switch(n){case 1:return function(n){return t.call(e,n)};case 2:return function(n,i){return t.call(e,n,i)};case 3:return function(n,i,o){return t.call(e,n,i,o)}}return function(){return t.apply(e,arguments)}}},function(t,e){t.exports=function(t){if("function"!=typeof t)throw TypeError(t+" is not a function!");return t}},function(t,e,n){var i=n(7);t.exports=function(t){return Object(i(t))}},function(t,e,n){var i=n(31);t.exports=function(t,e,n,o){try{return o?e(i(n)[0],n[1]):e(n)}catch(e){var r=t.return;throw void 0!==r&&i(r.call(t)),e}}},function(t,e,n){var i=n(32);t.exports=function(t){if(!i(t))throw TypeError(t+" is not an object!");return t}},function(t,e){t.exports=function(t){return"object"==typeof t?null!==t:"function"==typeof t}},function(t,e,n){var i=n(23),o=n(20)("iterator");t.exports=function(t){return(i.Array||Array.prototype[o])===t}},function(t,e,n){var i=n(6),o=Math.min;t.exports=function(t){return t>0?o(i(t),9007199254740991):0}},function(t,e,n){var i=n(36),o=n(20)("iterator"),r=n(23);t.exports=n(12).getIteratorMethod=function(t){if(null!=t)return t[o]||t["@@iterator"]||r[i(t)]}},function(t,e,n){var i=n(37),o=n(20)("toStringTag"),r="Arguments"==i(function(){return arguments}());t.exports=function(t){var e,n,s;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(n=(e=Object(t))[o])?n:r?i(e):"Object"==(s=i(e))&&"function"==typeof e.callee?"Arguments":s}},function(t,e){var n={}.toString;t.exports=function(t){return n.call(t).slice(8,-1)}},function(t,e,n){var i=n(20)("iterator"),o=!1;try{var r=[7][i]();r.return=function(){o=!0},Array.from(r,(function(){throw 2}))}catch(t){}t.exports=function(t){if(!o)return!1;var e=!1;try{var n=[7],r=n[i]();r.next=function(){e=!0},n[i]=function(){return r},t(n)}catch(t){}return e}},function(t,e,n){"use strict";var i=n(40).default,o=n(49).default;e.default=function(t,e){if(Array.isArray(t))return t;if(o(Object(t)))return function(t,e){var n=[],o=!0,r=!1,s=void 0;try{for(var a,l=i(t);!(o=(a=l.next()).done)&&(n.push(a.value),!e||n.length!==e);o=!0);}catch(t){r=!0,s=t}finally{try{!o&&l.return&&l.return()}finally{if(r)throw s}}return n}(t,e);throw new TypeError("Invalid attempt to destructure non-iterable instance")},e.__esModule=!0},function(t,e,n){t.exports={default:n(41),__esModule:!0}},function(t,e,n){n(42),n(4),t.exports=n(48)},function(t,e,n){n(43);var i=n(23);i.NodeList=i.HTMLCollection=i.Array},function(t,e,n){"use strict";var i=n(44),o=n(45),r=n(23),s=n(46);n(8)(Array,"Array",(function(t,e){this._t=s(t),this._i=0,this._k=e}),(function(){var t=this._t,e=this._k,n=this._i++;return!t||n>=t.length?(this._t=void 0,o(1)):o(0,"keys"==e?n:"values"==e?t[n]:[n,t[n]])}),"values"),r.Arguments=r.Array,i("keys"),i("values"),i("entries")},function(t,e){t.exports=function(){}},function(t,e){t.exports=function(t,e){return{value:e,done:!!t}}},function(t,e,n){var i=n(47),o=n(7);t.exports=function(t){return i(o(t))}},function(t,e,n){var i=n(37);t.exports=0 in Object("z")?Object:function(t){return"String"==i(t)?t.split(""):Object(t)}},function(t,e,n){var i=n(31),o=n(35);t.exports=n(12).getIterator=function(t){var e=o(t);if("function"!=typeof e)throw TypeError(t+" is not iterable!");return i(e.call(t))}},function(t,e,n){t.exports={default:n(50),__esModule:!0}},function(t,e,n){n(42),n(4),t.exports=n(51)},function(t,e,n){var i=n(36),o=n(20)("iterator"),r=n(23);t.exports=n(12).isIterable=function(t){var e=Object(t);return o in e||"@@iterator"in e||r.hasOwnProperty(i(e))}},function(t,e,n){t.exports={default:n(53),__esModule:!0}},function(t,e,n){n(4),n(42),t.exports=n(20)("iterator")},function(t,e,n){(function(e){var i="object"==typeof e?e:"object"==typeof window?window:"object"==typeof self?self:this,o=i.regeneratorRuntime&&Object.getOwnPropertyNames(i).indexOf("regeneratorRuntime")>=0,r=o&&i.regeneratorRuntime;if(i.regeneratorRuntime=void 0,t.exports=n(55),o)i.regeneratorRuntime=r;else try{delete i.regeneratorRuntime}catch(t){i.regeneratorRuntime=void 0}t.exports={default:t.exports,__esModule:!0}}).call(e,function(){return this}())},function(t,e,n){(function(e,i){"use strict";var o=n(57).default,r=n(52).default,s=n(63).default,a=n(65).default;!function(e){var n,l=Object.prototype.hasOwnProperty,u="function"==typeof o&&r||"@@iterator",c="object"==typeof t,h=e.regeneratorRuntime;if(h)c&&(t.exports=h);else{(h=e.regeneratorRuntime=c?t.exports:{}).wrap=C;var d="suspendedStart",f="suspendedYield",m="executing",p="completed",g={},v=b.prototype=w.prototype;A.prototype=v.constructor=b,b.constructor=A,A.displayName="GeneratorFunction",h.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===A||"GeneratorFunction"===(e.displayName||e.name))},h.mark=function(t){return t.__proto__=b,t.prototype=s(v),t},h.awrap=function(t){return new T(t)},S(E.prototype),h.async=function(t,e,n,i){var o=new E(C(t,e,n,i));return h.isGeneratorFunction(e)?o:o.next().then((function(t){return t.done?t.value:o.next()}))},S(v),v[u]=function(){return this},v.toString=function(){return"[object Generator]"},h.keys=function(t){var e=[];for(var n in t)e.push(n);return e.reverse(),function n(){for(;e.length;){var i=e.pop();if(i in t)return n.value=i,n.done=!1,n}return n.done=!0,n}},h.values=M,x.prototype={constructor:x,reset:function(t){if(this.prev=0,this.next=0,this.sent=n,this.done=!1,this.delegate=null,this.tryEntries.forEach(N),!t)for(var e in this)"t"===e.charAt(0)&&l.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=n)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(n,i){return r.type="throw",r.arg=t,e.next=n,!!i}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],r=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var s=l.call(o,"catchLoc"),a=l.call(o,"finallyLoc");if(s&&a){if(this.prev<o.catchLoc)return n(o.catchLoc,!0);if(this.prev<o.finallyLoc)return n(o.finallyLoc)}else if(s){if(this.prev<o.catchLoc)return n(o.catchLoc,!0)}else{if(!a)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return n(o.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&l.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var r=o?o.completion:{};return r.type=t,r.arg=e,o?this.next=o.finallyLoc:this.complete(r),g},complete:function(t,e){if("throw"===t.type)throw t.arg;"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=t.arg,this.next="end"):"normal"===t.type&&e&&(this.next=e)},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),N(n),g}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var i=n.completion;if("throw"===i.type){var o=i.arg;N(n)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:M(t),resultName:e,nextLoc:n},g}}}function C(t,e,i,o){var r=s((e||w).prototype);return r._invoke=function(t,e,i){var o=d;return function(r,s){if(o===m)throw new Error("Generator is already running");if(o===p){if("throw"===r)throw s;return I()}for(;;){var a=i.delegate;if(a){if("return"===r||"throw"===r&&a.iterator[r]===n){i.delegate=null;var l=a.iterator.return;if(l&&"throw"===(u=y(l,a.iterator,s)).type){r="throw",s=u.arg;continue}if("return"===r)continue}var u;if("throw"===(u=y(a.iterator[r],a.iterator,s)).type){i.delegate=null,r="throw",s=u.arg;continue}if(r="next",s=n,!(c=u.arg).done)return o=f,c;i[a.resultName]=c.value,i.next=a.nextLoc,i.delegate=null}if("next"===r)i.sent=o===f?s:n;else if("throw"===r){if(o===d)throw o=p,s;i.dispatchException(s)&&(r="next",s=n)}else"return"===r&&i.abrupt("return",s);if(o=m,"normal"===(u=y(t,e,i)).type){o=i.done?p:f;var c={value:u.arg,done:i.done};if(u.arg!==g)return c;i.delegate&&"next"===r&&(s=n)}else"throw"===u.type&&(o=p,r="throw",s=u.arg)}}}(t,i||null,new x(o||[])),r}function y(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}function w(){}function A(){}function b(){}function S(t){["next","throw","return"].forEach((function(e){t[e]=function(t){return this._invoke(e,t)}}))}function T(t){this.arg=t}function E(t){function e(e,n){var i=t[e](n),s=i.value;return s instanceof T?a.resolve(s.arg).then(o,r):a.resolve(s).then((function(t){return i.value=t,i}))}"object"==typeof i&&i.domain&&(e=i.domain.bind(e));var n,o=e.bind(t,"next"),r=e.bind(t,"throw");e.bind(t,"return"),this._invoke=function(t,i){var o=n?n.then((function(){return e(t,i)})):new a((function(n){n(e(t,i))}));return n=o.catch((function(t){})),o}}function _(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function N(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function x(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(_,this),this.reset(!0)}function M(t){if(t){var e=t[u];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,o=function e(){for(;++i<t.length;)if(l.call(t,i))return e.value=t[i],e.done=!1,e;return e.value=n,e.done=!0,e};return o.next=o}}return{next:I}}function I(){return{value:n,done:!0}}}("object"==typeof e?e:"object"==typeof window?window:"object"==typeof self?self:void 0)}).call(e,function(){return this}(),n(56))},function(t,e){var n,i=t.exports={},o=[],r=!1,s=-1;function a(){r=!1,n.length?o=n.concat(o):s=-1,o.length&&l()}function l(){if(!r){var t=setTimeout(a);r=!0;for(var e=o.length;e;){for(n=o,o=[];++s<e;)n&&n[s].run();s=-1,e=o.length}n=null,r=!1,clearTimeout(t)}}function u(t,e){this.fun=t,this.array=e}function c(){}i.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)e[n-1]=arguments[n];o.push(new u(t,e)),1!==o.length||r||setTimeout(l,0)},u.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=c,i.addListener=c,i.once=c,i.off=c,i.removeListener=c,i.removeAllListeners=c,i.emit=c,i.binding=function(t){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(t){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}},function(t,e,n){t.exports={default:n(58),__esModule:!0}},function(t,e,n){n(59),t.exports=n(12).Symbol},function(t,e,n){"use strict";var i=n(15),o=n(11),r=n(19),s=n(17),a=n(10),l=n(13),u=n(18),c=n(21),h=n(25),d=n(22),f=n(20),m=n(60),p=n(61),g=n(62),v=n(32),C=n(31),y=n(46),w=n(16),A=i.getDesc,b=i.setDesc,S=i.create,T=p.get,E=o.Symbol,_=!1,N=f("_hidden"),x=i.isEnum,M=c("symbol-registry"),I=c("symbols"),O="function"==typeof E,L=Object.prototype,P=s&&u((function(){return 7!=S(b({},"a",{get:function(){return b(this,"a",{value:7}).a}})).a}))?function(t,e,n){var i=A(L,e);i&&delete L[e],b(t,e,n),i&&t!==L&&b(L,e,i)}:b,R=function(t){var e=I[t]=S(E.prototype);return e._k=t,s&&_&&P(L,t,{configurable:!0,set:function(e){r(this,N)&&r(this[N],t)&&(this[N][t]=!1),P(this,t,w(1,e))}}),e},k=function(t,e,n){return n&&r(I,e)?(n.enumerable?(r(t,N)&&t[N][e]&&(t[N][e]=!1),n=S(n,{enumerable:w(0,!1)})):(r(t,N)||b(t,N,w(1,{})),t[N][e]=!0),P(t,e,n)):b(t,e,n)},V=function(t,e){C(t);for(var n,i=g(e=y(e)),o=0,r=i.length;r>o;)k(t,n=i[o++],e[n]);return t},F=function(t,e){return void 0===e?S(t):V(S(t),e)},D=function(t){var e=x.call(this,t);return!(e||!r(this,t)||!r(I,t)||r(this,N)&&this[N][t])||e},G=function(t,e){var n=A(t=y(t),e);return!n||!r(I,e)||r(t,N)&&t[N][e]||(n.enumerable=!0),n},U=function(t){for(var e,n=T(y(t)),i=[],o=0;n.length>o;)r(I,e=n[o++])||e==N||i.push(e);return i},q=function(t){for(var e,n=T(y(t)),i=[],o=0;n.length>o;)r(I,e=n[o++])&&i.push(I[e]);return i};O||(E=function(){if(this instanceof E)throw TypeError("Symbol is not a constructor");return R(d(arguments[0]))},l(E.prototype,"toString",(function(){return this._k})),i.create=F,i.isEnum=D,i.getDesc=G,i.setDesc=k,i.setDescs=V,i.getNames=p.get=U,i.getSymbols=q,s&&!n(9)&&l(L,"propertyIsEnumerable",D,!0)),O&&!u((function(){return"[null]"!=JSON.stringify([E()])}))||l(E.prototype,"toJSON",(function(){if(O&&v(this))return this}));var B={for:function(t){return r(M,t+="")?M[t]:M[t]=E(t)},keyFor:function(t){return m(M,t)},useSetter:function(){_=!0},useSimple:function(){_=!1}};i.each.call("hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables".split(","),(function(t){var e=f(t);B[t]=O?e:R(e)})),_=!0,a(a.G+a.W,{Symbol:E}),a(a.S,"Symbol",B),a(a.S+a.F*!O,"Object",{create:F,defineProperty:k,defineProperties:V,getOwnPropertyDescriptor:G,getOwnPropertyNames:U,getOwnPropertySymbols:q}),h(E,"Symbol"),h(Math,"Math",!0),h(o.JSON,"JSON",!0)},function(t,e,n){var i=n(15),o=n(46);t.exports=function(t,e){for(var n,r=o(t),s=i.getKeys(r),a=s.length,l=0;a>l;)if(r[n=s[l++]]===e)return n}},function(t,e,n){var i={}.toString,o=n(46),r=n(15).getNames,s="object"==typeof window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[];t.exports.get=function(t){return s&&"[object Window]"==i.call(t)?function(t){try{return r(t)}catch(t){return s.slice()}}(t):r(o(t))}},function(t,e,n){var i=n(15);t.exports=function(t){var e=i.getKeys(t),n=i.getSymbols;if(n)for(var o,r=n(t),s=i.isEnum,a=0;r.length>a;)s.call(t,o=r[a++])&&e.push(o);return e}},function(t,e,n){t.exports={default:n(64),__esModule:!0}},function(t,e,n){var i=n(15);t.exports=function(t,e){return i.create(t,e)}},function(t,e,n){t.exports={default:n(66),__esModule:!0}},function(t,e,n){n(67),n(4),n(42),n(68),t.exports=n(12).Promise},function(t,e){},function(t,e,n){"use strict";var i,o=n(15),r=n(9),s=n(11),a=n(27),l=n(36),u=n(10),c=n(32),h=n(31),d=n(28),f=n(69),m=n(70),p=n(71).set,g=n(72),v=n(73),C=n(20)("species"),y=n(22)("record"),w=n(74),A="Promise",b=s.process,S="process"==l(b),T=s[A],E=function(t){var e=new T((function(){}));return t&&(e.constructor=Object),T.resolve(e)===e},_=function(){var t=!1;function e(t){var n=new T(t);return p(n,e.prototype),n}try{if(t=T&&T.resolve&&E(),p(e,T),e.prototype=o.create(T.prototype,{constructor:{value:e}}),e.resolve(5).then((function(){}))instanceof e||(t=!1),t&&n(17)){var i=!1;T.resolve(o.setDesc({},"then",{get:function(){i=!0}})),t=i}}catch(e){t=!1}return t}(),N=function(t){var e=h(t)[C];return null!=e?e:t},x=function(t){var e;return!(!c(t)||"function"!=typeof(e=t.then))&&e},M=function(t,e){if(!t.n){t.n=!0;var n=t.c;w((function(){for(var i=t.v,o=1==t.s,r=0,a=function(e){var n,r,s=o?e.ok:e.fail;try{s?(o||(t.h=!0),(n=!0===s?i:s(i))===e.P?e.rej(TypeError("Promise-chain cycle")):(r=x(n))?r.call(n,e.res,e.rej):e.res(n)):e.rej(i)}catch(t){e.rej(t)}};n.length>r;)a(n[r++]);n.length=0,t.n=!1,e&&setTimeout((function(){var e,n,o=t.p;I(o)&&(S?b.emit("unhandledRejection",i,o):(e=s.onunhandledrejection)?e({promise:o,reason:i}):(n=s.console)&&n.error&&n.error("Unhandled promise rejection",i)),t.a=void 0}),1)}))}},I=function(t){var e,n=t[y],i=n.a||n.c,o=0;if(n.h)return!1;for(;i.length>o;)if((e=i[o++]).fail||!I(e.P))return!1;return!0},O=function(t){var e=this;e.d||(e.d=!0,(e=e.r||e).v=t,e.s=2,e.a=e.c.slice(),M(e,!0))},L=function(t){var e,n=this;if(!n.d){n.d=!0,n=n.r||n;try{(e=x(t))?w((function(){var i={r:n,d:!1};try{e.call(t,a(L,i,1),a(O,i,1))}catch(t){O.call(i,t)}})):(n.v=t,n.s=1,M(n,!1))}catch(t){O.call({r:n,d:!1},t)}}};_||(T=function(t){d(t);var e={p:f(this,T,A),c:[],a:void 0,s:0,d:!1,v:void 0,h:!1,n:!1};this[y]=e;try{t(a(L,e,1),a(O,e,1))}catch(t){O.call(e,t)}},n(79)(T.prototype,{then:function(t,e){var n=h(h(this).constructor)[C],i={ok:"function"!=typeof t||t,fail:"function"==typeof e&&e},o=i.P=new(null!=n?n:T)((function(t,e){i.res=t,i.rej=e}));d(i.res),d(i.rej);var r=this[y];return r.c.push(i),r.a&&r.a.push(i),r.s&&M(r,!1),o},catch:function(t){return this.then(void 0,t)}})),u(u.G+u.W+u.F*!_,{Promise:T}),n(25)(T,A),v(T),v(i=n(12)[A]),u(u.S+u.F*!_,A,{reject:function(t){return new this((function(e,n){n(t)}))}}),u(u.S+u.F*(!_||E(!0)),A,{resolve:function(t){return c(n=t)&&(_?"Promise"==l(n):y in n)&&(e=t.constructor,r&&e===T&&this===i||g(e,this))?t:new this((function(e){e(t)}));var e,n}}),u(u.S+u.F*!(_&&n(38)((function(t){T.all(t).catch((function(){}))}))),A,{all:function(t){var e=N(this),n=[];return new e((function(i,r){m(t,!1,n.push,n);var s=n.length,a=Array(s);s?o.each.call(n,(function(t,n){e.resolve(t).then((function(t){a[n]=t,--s||i(a)}),r)})):i(a)}))},race:function(t){var e=N(this);return new e((function(n,i){m(t,!1,(function(t){e.resolve(t).then(n,i)}))}))}})},function(t,e){t.exports=function(t,e,n){if(!(t instanceof e))throw TypeError(n+": use the 'new' operator!");return t}},function(t,e,n){var i=n(27),o=n(30),r=n(33),s=n(31),a=n(34),l=n(35);t.exports=function(t,e,n,u){var c,h,d,f=l(t),m=i(n,u,e?2:1),p=0;if("function"!=typeof f)throw TypeError(t+" is not iterable!");if(r(f))for(c=a(t.length);c>p;p++)e?m(s(h=t[p])[0],h[1]):m(t[p]);else for(d=f.call(t);!(h=d.next()).done;)o(d,m,h.value,e)}},function(t,e,n){var i=n(15).getDesc,o=n(32),r=n(31),s=function(t,e){if(r(t),!o(e)&&null!==e)throw TypeError(e+": can't set as prototype!")};t.exports={set:Object.setPrototypeOf||("__proto__"in{}?function(t,e,o){try{(o=n(27)(Function.call,i(Object.prototype,"__proto__").set,2))(t,[]),e=!(t instanceof Array)}catch(t){e=!0}return function(t,n){return s(t,n),e?t.__proto__=n:o(t,n),t}}({},!1):void 0),check:s}},function(t,e){t.exports=Object.is||function(t,e){return t===e?0!==t||1/t==1/e:t!=t&&e!=e}},function(t,e,n){"use strict";var i=n(15),o=n(20)("species");t.exports=function(t){n(17)&&!(o in t)&&i.setDesc(t,o,{configurable:!0,get:function(){return this}})}},function(t,e,n){var i,o,r,s=n(11),a=n(75).set,l=s.MutationObserver||s.WebKitMutationObserver,u=s.process,c="process"==n(37)(u),h=function(){var t,e;for(c&&(t=u.domain)&&(u.domain=null,t.exit());i;)(e=i.domain)&&e.enter(),i.fn.call(),e&&e.exit(),i=i.next;o=void 0,t&&t.enter()};if(c)r=function(){u.nextTick(h)};else if(l){var d=1,f=document.createTextNode("");new l(h).observe(f,{characterData:!0}),r=function(){f.data=d=-d}}else r=function(){a.call(s,h)};t.exports=function(t){var e={fn:t,next:void 0,domain:c&&u.domain};o&&(o.next=e),i||(i=e,r()),o=e}},function(t,e,n){"use strict";var i,o,r,s=n(27),a=n(76),l=n(77),u=n(78),c=n(11),h=c.process,d=c.setImmediate,f=c.clearImmediate,m=c.MessageChannel,p=0,g={},v="onreadystatechange",C=function(){var t=+this;if(g.hasOwnProperty(t)){var e=g[t];delete g[t],e()}},y=function(t){C.call(t.data)};d&&f||(d=function(t){for(var e=[],n=1;arguments.length>n;)e.push(arguments[n++]);return g[++p]=function(){a("function"==typeof t?t:Function(t),e)},i(p),p},f=function(t){delete g[t]},"process"==n(37)(h)?i=function(t){h.nextTick(s(C,t,1))}:m?(r=(o=new m).port2,o.port1.onmessage=y,i=s(r.postMessage,r,1)):c.addEventListener&&"function"==typeof postMessage&&!c.importScript?(i=function(t){c.postMessage(t+"","*")},c.addEventListener("message",y,!1)):i=v in u("script")?function(t){l.appendChild(u("script"))[v]=function(){l.removeChild(this),C.call(t)}}:function(t){setTimeout(s(C,t,1),0)}),t.exports={set:d,clear:f}},function(t,e){t.exports=function(t,e,n){var i=void 0===n;switch(e.length){case 0:return i?t():t.call(n);case 1:return i?t(e[0]):t.call(n,e[0]);case 2:return i?t(e[0],e[1]):t.call(n,e[0],e[1]);case 3:return i?t(e[0],e[1],e[2]):t.call(n,e[0],e[1],e[2]);case 4:return i?t(e[0],e[1],e[2],e[3]):t.call(n,e[0],e[1],e[2],e[3])}return t.apply(n,e)}},function(t,e,n){t.exports=n(11).document&&document.documentElement},function(t,e,n){var i=n(32),o=n(11).document,r=i(o)&&i(o.createElement);t.exports=function(t){return r?o.createElement(t):{}}},function(t,e,n){var i=n(13);t.exports=function(t,e){for(var n in e)i(t,n,e[n]);return t}},function(t,e,n){t.exports={default:n(81),__esModule:!0}},function(t,e,n){n(82),t.exports=n(12).Object.keys},function(t,e,n){var i=n(29);n(83)("keys",(function(t){return function(e){return t(i(e))}}))},function(t,e,n){t.exports=function(t,e){var i=n(10),o=(n(12).Object||{})[t]||Object[t],r={};r[t]=e(o),i(i.S+i.F*n(18)((function(){o(1)})),"Object",r)}},function(t,e,n){t.exports={default:n(85),__esModule:!0}},function(t,e,n){n(67),n(4),n(42),n(86),n(89),t.exports=n(12).Set},function(t,e,n){"use strict";var i=n(87);n(88)("Set",(function(t){return function(){return t(this,arguments[0])}}),{add:function(t){return i.def(this,t=0===t?0:t,t)}},i)},function(t,e,n){"use strict";var i=n(15),o=n(14),r=n(27),s=n(73),a=n(69),l=n(7),u=n(70),c=n(45),h=n(22)("id"),d=n(19),f=n(32),m=Object.isExtensible||f,p=n(17),g=p?"_s":"size",v=0,C=function(t,e){if(!f(t))return"symbol"==typeof t?t:("string"==typeof t?"S":"P")+t;if(!d(t,h)){if(!m(t))return"F";if(!e)return"E";o(t,h,++v)}return"O"+t[h]},y=function(t,e){var n,i=C(e);if("F"!==i)return t._i[i];for(n=t._f;n;n=n.n)if(n.k==e)return n};t.exports={getConstructor:function(t,e,o,s){var c=t((function(t,n){a(t,c,e),t._i=i.create(null),t._f=void 0,t._l=void 0,t[g]=0,null!=n&&u(n,o,t[s],t)}));return n(79)(c.prototype,{clear:function(){for(var t=this,e=t._i,n=t._f;n;n=n.n)n.r=!0,n.p&&(n.p=n.p.n=void 0),delete e[n.i];t._f=t._l=void 0,t[g]=0},delete:function(t){var e=this,n=y(e,t);if(n){var i=n.n,o=n.p;delete e._i[n.i],n.r=!0,o&&(o.n=i),i&&(i.p=o),e._f==n&&(e._f=i),e._l==n&&(e._l=o),e[g]--}return!!n},forEach:function(t){for(var e,n=r(t,arguments[1],3);e=e?e.n:this._f;)for(n(e.v,e.k,this);e&&e.r;)e=e.p},has:function(t){return!!y(this,t)}}),p&&i.setDesc(c.prototype,"size",{get:function(){return l(this[g])}}),c},def:function(t,e,n){var i,o,r=y(t,e);return r?r.v=n:(t._l=r={i:o=C(e,!0),k:e,v:n,p:i=t._l,n:void 0,r:!1},t._f||(t._f=r),i&&(i.n=r),t[g]++,"F"!==o&&(t._i[o]=r)),t},getEntry:y,setStrong:function(t,e,i){n(8)(t,e,(function(t,e){this._t=t,this._k=e,this._l=void 0}),(function(){for(var t=this,e=t._k,n=t._l;n&&n.r;)n=n.p;return t._t&&(t._l=n=n?n.n:t._t._f)?c(0,"keys"==e?n.k:"values"==e?n.v:[n.k,n.v]):(t._t=void 0,c(1))}),i?"entries":"values",!i,!0),s(t),s(n(12)[e])}}},function(t,e,n){"use strict";var i=n(15),o=n(10),r=n(14),s=n(70),a=n(69);t.exports=function(t,e,l,u,c,h){var d=n(11)[t],f=d,m=c?"set":"add",p=f&&f.prototype,g={};return n(17)&&"function"==typeof f&&(h||p.forEach&&!n(18)((function(){(new f).entries().next()})))?(f=e((function(e,n){a(e,f,t),e._c=new d,null!=n&&s(n,c,e[m],e)})),i.each.call("add,clear,delete,forEach,get,has,set,keys,values,entries".split(","),(function(t){var e="add"==t||"set"==t;!(t in p)||h&&"clear"==t||r(f.prototype,t,(function(n,i){var o=this._c[t](0===n?0:n,i);return e?this:o}))})),"size"in p&&i.setDesc(f.prototype,"size",{get:function(){return this._c.size}})):(f=u.getConstructor(e,t,c,m),n(79)(f.prototype,l)),n(25)(f,t),g[t]=f,o(o.G+o.W+o.F,g),h||u.setStrong(f,t,c),f}},function(t,e,n){var i=n(10);i(i.P,"Set",{toJSON:n(90)("Set")})},function(t,e,n){var i=n(70),o=n(36);t.exports=function(t){return function(){if(o(this)!=t)throw TypeError(t+"#toJSON isn't generic");var e=[];return i(this,!1,e.push,e),e}}}])},t.exports=e()},6082:t=>{"use strict";t.exports=DG},4328:t=>{"use strict";t.exports=grok},7389:t=>{"use strict";t.exports=ui}},e={};function n(i){var o=e[i];if(void 0!==o)return o.exports;var r=e[i]={id:i,loaded:!1,exports:{}};return t[i].call(r.exports,r,r.exports,n),r.loaded=!0,r.exports}n.m=t,n.amdO={},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.u=t=>t+".js",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.hmd=t=>((t=Object.create(t)).children||(t.children=[]),Object.defineProperty(t,"exports",{enumerable:!0,set:()=>{throw new Error("ES Modules may not assign module.exports or exports.*, Use ESM export syntax, instead: "+t.id)}}),t),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})},(()=>{var t;n.g.importScripts&&(t=n.g.location+"");var e=n.g.document;if(!t&&e&&(e.currentScript&&"SCRIPT"===e.currentScript.tagName.toUpperCase()&&(t=e.currentScript.src),!t)){var i=e.getElementsByTagName("script");if(i.length)for(var o=i.length-1;o>-1&&(!t||!/^http(s?):/.test(t));)t=i[o--].src}if(!t)throw new Error("Automatic publicPath is not supported in this browser");t=t.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),n.p=t})(),n.b=document.baseURI||self.location.href,n.nc=void 0;var i=n(3262);peptides=i})();
|
|
2
2
|
//# sourceMappingURL=package.js.map
|