@datagrok/bio 2.10.22 → 2.10.23
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/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 +2 -2
- package/src/package.ts +4 -4
- package/src/tests/WebLogo-positions-test.ts +13 -13
- package/src/tests/detectors-benchmark-tests.ts +2 -2
- package/src/tests/detectors-tests.ts +4 -1
- package/src/utils/cell-renderer.ts +7 -1
- package/src/utils/err-info.ts +28 -0
- package/src/viewers/vd-regions-viewer.ts +56 -31
- package/src/viewers/web-logo-viewer.ts +108 -102
package/dist/package.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/*! For license information please see package.js.LICENSE.txt */
|
|
2
|
-
var bio;(()=>{var t={2012:(t,e,s)=>{"use strict";s.d(e,{f:()=>n});var i=s(9976);class n extends i.B{static get Lesk(){return void 0===this.lesk&&(this.lesk=this.makePalette([[["G","A","S","T"],"orange"],[["C","V","I","L","P","F","Y","M","W"],"all_green"],[["N","Q","H"],"magenta"],[["D","E"],"red"],[["K","R"],"all_blue"]],!1,n)),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,n)),this.grokGroups}static get RasMol(){return void 0===this.rasMol&&(this.rasMol=new n({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 n.aaSynonyms?n.aaSynonyms[t]:t;return super.get(e)}}n.aaSynonyms={MeNle:"L",MeA:"A",MeG:"G",MeF:"F"};class o{static getPalette(t="grok"){switch(t){case"grok":return n.GrokGroups;case"lesk":return n.Lesk;default:throw new Error(`ChemPalette: scheme \`${t}\` does not exist`)}}static getInnerOuter(t){let e=0,s="",i="";for(const n of t)"("==n?e++:")"==n?e--:e?s+=n:i+=n;return isNaN(parseInt(s))?[i,s]:[i,""]}static getColorAAPivot(t="",e="grok"){const s=this.getPalette(e);let[i,n]=this.getInnerOuter(t);if(i=i.length>6?`${i.slice(0,3)}...`:i,n=n.length>6?`${n.slice(0,3)}...`:n,1==t.length||"("==t[1]){const e=t[0]?.toUpperCase();return e in s?[s.get(e),e,n,1]:[this.undefinedColor,i,n,1]}if("d"==t[0]&&t[1]in s&&(2==t.length||"("==t[2])){const e=t[1]?.toUpperCase();return e in s?[s.get(e),e,n,2]:[this.undefinedColor,i,n,2]}if(t.substring(0,3)in this.AAFullNames&&(3==t.length||"("==t[3])){const e=this.AAFullNames[t.substring(0,3)];return e in s?[s.get(e),e,n,3]:[this.undefinedColor,i,n,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 s?[s.get(e),e,n,4]:[this.undefinedColor,i,n,4]}return[this.undefinedColor,i,n,0]}}o.SemType="Aminoacids",o.SemTypeMultipleAlignment="AminoacidsMultipleAlignment",o.undefinedColor="rgb(100,100,100)",o.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"},o.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"},o.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(*)*"},o.AAFullNames={Ala:"A",Arg:"R",Asn:"N",Asp:"D",Cys:"C",Gln:"Q",Glu:"E",Gly:"G",His:"H",Ile:"I",Leu:"L",Lys:"K",Met:"M",Phe:"F",Pro:"P",Ser:"S",Thr:"T",Trp:"W",Tyr:"Y",Val:"V"}},7228:(t,e,s)=>{"use strict";s.d(e,{JN:()=>c,PF:()=>m,Qx:()=>u,Xk:()=>h,Z:()=>l,eD:()=>a});var i=s(976),n=s(4469),o=s(1047),r=(s(499),s(8457));function a(t){return t.every((t=>"object"==typeof t&&Object.values(o.pn).every((e=>e in t&&"string"==typeof t[e]))))}function l(t){function e(t){const e=new RegExp("\\[r\\]","g");let s=0;return t.replace(e,(t=>(++s,`[${s}*]`)))}const s=[];return t.forEach((t=>{const n={...o.zh};Object.entries(o.pn).forEach((([e,s])=>{const i=t[s];n[e]=i}));let r="smiles";const a=t[o.pn[r]],l=e(a).replace("[1*]","[H:1]").replace("[2*]","[OH:2]");n[r]=l,r="rgroups",n[r]=o.Ei,r="molfile";const h=e(a),c=i.chem.convert(h,i.chem.Notation.Smiles,i.chem.Notation.MolBlock);n[r]=c.replace("M ISO","M RGP"),s.push(n)})),console.log("resultLib:",s),s}function h(t){const e=[];for(let s=0;s<t.rowCount;s++){const i={};Object.keys(o.K4).forEach((e=>{if("symbol"===e){const n=t.get(o.K4[e],s);i[e]="."===n?t.get(o.At,s):n}else if("rgroups"===e){const n=t.get(o.K4[e],s).split("\n"),r=[];n.forEach((t=>{const e={},s=t.substring(t.lastIndexOf("]")+1),i=t.match(/\[R(\d+)\]/)[1];e.capGroupSmiles="H"===s?`[*:${i}][H]`:`O[*:${i}]`,e.alternateId="H"===s?`R${i}-H`:`R${i}-OH`,e.capGroupName="H"===s?"H":"OH",e.label=`R${i}`,r.push(e)})),i[e]=r}else o.K4[e]&&(i[e]=t.get(o.K4[e],s))})),e.push(i)}return e}async function c(){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()}async function u(t,e){t instanceof i.Column&&(t=(0,r.O)(t).columns.toList());const s=(await c()).getBioLib(),o=new Array(t.length),a=t[0].length,l=new Float32Array(a);for(let r=0;r<t.length;++r){const h=e[r],c=s.getMonomer("PEPTIDE",h)?.smiles??"",u=t[r],m=u.getRawData(),d=u.categories,g=d.indexOf("");if(o[r]={categories:d,data:m,emptyIndex:g},void 0===h)continue;const p=i.Column.fromStrings("smiles",d.map((t=>s.getMonomer("PEPTIDE",t)?.smiles??""))),f=(i.DataFrame.fromColumns([p]),(await n.chem.getSimilarities(p,c)).getRawData());for(let t=0;t<a;++t){const e=m[t];l[t]+=""!==h&&e!==g?f[e]:""===h&&e===g?1:0}}for(let s=0;s<l.length;++s){let n=l[s]/e.length;for(let r=0;r<t.length;++r){const t=o[r];if(r>=e.length&&t.data[s]!==t.emptyIndex||t.data[s]===t.emptyIndex&&r<e.length){n=i.FLOAT_NULL;break}}l[s]=n}return i.Column.fromFloat32Array("Similarity",l)}async function m(t){const e=(await c()).getBioLib(),s=[],o={},r=t.map((t=>e.getMonomer("PEPTIDE",t)?.smiles??"")),a=i.Column.fromStrings("smiles",r);for(let e=0;e<r.length;++e){o[t[e]]=e;const i=r[e],l=""===i?new Array(r.length).fill(0):(await n.chem.getSimilarities(a,i)).getRawData();l[e]=1,s[e]=Array.from(l)}return{scoringMatrix:s,alphabetIndexes:o}}},8601:(t,e,s)=>{"use strict";s.d(e,{i0:()=>m});var i=s(4469),n=s(976),o=s(6414),r=s.n(o),a=s(1821),l=s(499);const h={V2K_RGP_SHIFT:8,V2K_RGP_LINE:"M RGP",V2K_A_LINE:"A ",V3K_COUNTS_SHIFT:14,V3K_IDX_SHIFT:7,V3K_HEADER_FIRST_LINE:"\nDatagrok macromolecule handler\n\n",V3K_HEADER_SECOND_LINE:" 0 0 0 0 0 0 999 V3000\n",V3K_BEGIN_CTAB_BLOCK:"M V30 BEGIN CTAB\n",V3K_END_CTAB_BLOCK:"M V30 END CTAB\n",V3K_BEGIN_COUNTS_LINE:"M V30 COUNTS ",V3K_COUNTS_LINE_ENDING:" 0 0 0\n",V3K_BEGIN_ATOM_BLOCK:"M V30 BEGIN ATOM\n",V3K_END_ATOM_BLOCK:"M V30 END ATOM\n",V3K_BEGIN_BOND_BLOCK:"M V30 BEGIN BOND\n",V3K_END_BOND_BLOCK:"M V30 END BOND\n",V3K_BOND_CONFIG:" CFG:",V3K_BEGIN_DATA_LINE:"M V30 ",V3K_END:"M END",PRECISION_FACTOR:1e4,DEOXYRIBOSE:"d",RIBOSE:"r",PHOSPHATE:"p",OXYGEN:"O",HYDROGEN:"H"};var c=s(1047);function u(t){return Math.round(h.PRECISION_FACTOR*t)/h.PRECISION_FACTOR}async function m(t,e,o){if(0===n.Func.find({package:"Chem",name:"getRdKitModule"}).length)return{col:null,warnings:['Transformation to atomic level requires the package "Chem" installed.']};if(e.semType!==n.SEMTYPE.MACROMOLECULE)return{col:null,warnings:[`Only the ${n.SEMTYPE.MACROMOLECULE} columns can be converted to atomic level, the chosen column has semType '${e.semType}'`]};let u=e;const m=l.Cn.getOrCreate(e);m.isHelm()&&(u=m.convert(a.r2.SEPARATOR,"."),u.name=e.name);const g=l.Cn.getOrCreate(u).alphabet;let p;if("PT"===g||"UN"===g)p="PEPTIDE";else{if("RNA"!==g&&"DNA"!==g)return{col:null,warnings:[`Unexpected column's '${u.name}' alphabet '${g}'.`]};p="RNA"}const f=function(t){const e=t.length,s=new Array(e),i=l.Cn.getOrCreate(t).getSplitter();for(let n=0;n<e;++n){const e=t.get(n);s[n]=e?r()(i(e)).filter((t=>""!==t)).toArray():[]}return s}(u),y=await async function(t,e,s,n){const o=function(t,e,s){const i=new Map;for(const n of t.getMonomerSymbolsByType(e)){const o=t.getMonomer(e,n);if("RNA"===e&&("Branch"===o.monomerType||"DNA"===s&&o.symbol===h.DEOXYRIBOSE||"RNA"===s&&o.symbol===h.RIBOSE||o.symbol===h.PHOSPHATE)||"PEPTIDE"===e&&"Branch"!==o.monomerType){const t={};c.rx.forEach((e=>{t[e]=o[e]})),i.set(o.symbol,t)}}return i}(e,s,n),r=new Map,a=await i.functions.call("Chem:getRdKitModule"),l={value:null};if("RNA"===s){const t="RNA"===n?[h.RIBOSE,h.PHOSPHATE]:[h.DEOXYRIBOSE,h.PHOSPHATE];for(const e of t)d(r,e,o,a,s,l)}for(let e=0;e<t.length;++e){const i=t[e];for(const t of i)if(""!==t)try{d(r,t,o,a,s,l)}catch(e){const s=e instanceof Error?e.message:e.toString(),i=e instanceof Error?e.stack:void 0;throw console.error(`bio lib: getMonomersDictFromLib() sym='${t}', error:\n${s}\n${i}`),new Error(`Can't get monomer '${t}' from library: ${s}`)}}return r}(f,o,p,g),b=u.length,{molfileList:w,molfileWarningList:C}=await async function(t,e,i,n,o){const r=Math.max(navigator.hardwareConcurrency-2,1),a=new Array(r).fill(null).map((()=>new Worker(new URL(s.p+s.u(79),s.b)))),l=o/r;let h=[],c=[];const u=new Array(r);for(let s=0;s<r;s++){const h=Math.floor(s*l),c=s===r-1?o:Math.floor((s+1)*l);a[s].postMessage({monomerSequencesArray:t,monomersDict:e,alphabet:i,polymerType:n,start:h,end:c}),u[s]=new Promise((t=>{a[s].onmessage=({data:{molfileList:e,molfileWarningList:s}})=>{t({molfileList:e,molfileWarningList:s})}}))}return(await Promise.all(u)).forEach((t=>{h=h.concat(...t.molfileList),c=c.concat(...t.molfileWarningList)})),setTimeout((()=>{a.forEach((t=>{t.terminate()}))}),0),{molfileList:h,molfileWarningList:c}}(f,y,g,p,b);if(C.length>.05*b)throw new Error("Too many errors getting molfiles.");const v=`molfile(${u.name})`,S=t.columns.getUnusedName(v),T=n.Column.fromStrings(S,w);return T.semType=n.SEMTYPE.MOLECULE,T.setTag(n.TAGS.UNITS,n.UNITS.Molecule.MOLBLOCK),{col:T,warnings:C}}function d(t,e,s,i,n,o){if(!t.has(e)){const r=function(t,e,s,i,n){if(e.has(t)){const o=e.get(t),r=function(t){const e=[];for(const s of t){let t=s.capGroupSmiles;t||(t=s.capGroupSMILES),t=t.replace(/(\[|\]|\*|:|\d)/g,""),e.push(t)}return e}(o.rgroups),a=function(t){const e=new Map;let s=t.indexOf(h.V2K_A_LINE,0),i=s;for(;-1!==s;){i=t.indexOf("\n",s);const n=parseInt(t.substring(s,i).replace(/^A\s+/,""));s=t.indexOf("R",i),i=t.indexOf("\n",s);const o=parseInt(t.substring(s,i).replace(/^R/,""));e.set(n,o),s=t.indexOf(h.V2K_A_LINE,i)}for(s=t.indexOf(h.V2K_RGP_LINE,0),i=t.indexOf("\n",s);-1!==s;){s+=h.V2K_RGP_SHIFT,i=t.indexOf("\n",s);const n=t.substring(s,i).replaceAll(/\s+/g," ").split(" ").map((t=>parseInt(t))).slice(1);for(let t=0;t<n.length;t+=2){if(e.has(n[t])&&e.get(n[t])!==n[t+1])throw new Error(`r-group index ${n[t]} has already been added with a different value`);e.set(n[t],n[t+1])}s=t.indexOf(h.V2K_RGP_LINE,i)}return e}(o.molfile),l=function(t,e){const s=e.get_mol(t),i=s.get_v3Kmolblock();return s.delete(),i}(function(t){let e=t.indexOf(h.V2K_A_LINE,0);-1===e&&(e=t.indexOf(h.V2K_RGP_LINE));const s=t.indexOf(h.V3K_END,e);return t.substring(0,e)+t.substring(s)}(o.molfile),s),c=function(t){let e=(t=t.replaceAll("\r","")).indexOf(h.V3K_BEGIN_COUNTS_LINE)+h.V3K_COUNTS_SHIFT,s=t.indexOf(" ",e+1);const i=parseInt(t.substring(e,s));return e=s+1,s=t.indexOf(" ",e+1),{atomCount:i,bondCount:parseInt(t.substring(e,s))}}(l),m=function(t,e){const s=new Array(e),i=new Float32Array(e),n=new Float32Array(e),o=new Array(e);let r=t.indexOf(h.V3K_BEGIN_ATOM_BLOCK);r=t.indexOf("\n",r);let a=r;for(let l=0;l<e;l++){r=t.indexOf(h.V3K_BEGIN_DATA_LINE,r)+h.V3K_IDX_SHIFT,a=t.indexOf(" ",r),r=a+1,a=t.indexOf(" ",r),s[l]=t.substring(r,a);const e=new Array(2);for(let s=0;s<2;++s)r=a+1,a=t.indexOf(" ",r),e[s]=parseFloat(t.substring(r,a));i[l]=e[0],n[l]=e[1],r=a,a=t.indexOf("\n",r)+1,o[l]=t.slice(r,a),r=a}return{atomTypes:s,x:i,y:n,kwargs:o}}(l,c.atomCount),d=function(t,e){const s=new Uint32Array(e),i=new Array(e),n=new Map,o=new Map;let r=t.indexOf(h.V3K_BEGIN_BOND_BLOCK);r=t.indexOf("\n",r);let a=r;for(let l=0;l<e;++l){const e=new Array(3);r=t.indexOf(h.V3K_BEGIN_DATA_LINE,a)+h.V3K_IDX_SHIFT,a=t.indexOf(" ",r);for(let s=0;s<3;++s)r=a+1,a=Math.min(t.indexOf("\n",r),t.indexOf(" ",r)),e[s]=parseInt(t.slice(r,a));s[l]=e[0],i[l]=e.slice(1);const c=t.indexOf("\n",r);let u=t.slice(a,c),m=u.indexOf(h.V3K_BOND_CONFIG);if(-1!==m){m=u.indexOf("=",m)+1;let t=u.indexOf(" ",m);-1===t&&(t=u.length);const e=parseInt(u.slice(m,t));n.set(l,e);const s=h.V3K_BOND_CONFIG+e.toString();u=u.replace(s,"")}u||o.set(l,u)}return{bondTypes:s,atomPairs:i,bondConfiguration:n,kwargs:o}}(l,c.bondCount),y={atoms:m,bonds:d,meta:g(m,d,r,a)};return"PEPTIDE"===i?function(t){const e=t.meta.terminalNodes[0]-1,s=t.meta.rNodes[0]-1,i=t.atoms.x,n=t.atoms.y;T(t,-i[e],-n[e]);const o=C(i[s],n[s]);v(t.atoms,-o),i[t.meta.rNodes[1]-1]<0&&function(t){S(t,!1)}(t);const r=function(t){const e=function(t){const e=new Map;for(const s of t.bonds.atomPairs)for(let t=0;t<2;t++){const i=s[t],n=s[(t+1)%2];e.has(i)?e.get(i)?.push(n):e.set(i,new Array(1).fill(n))}return e}(t);let s=0,i=0;for(;0===s;){const n=e.get(t.meta.terminalNodes[1])[i];t.atoms.atomTypes[n-1]===h.OXYGEN&&n!==t.meta.rNodes[1]&&(s=n),i++}return s}(t);!function(t,e){t.atoms.y[t.meta.rNodes[1]-1]<0&&t.atoms.y[e-1]<0&&(function(t){S(t,!0)}(t),v(t.atoms,-function(t,e){return C(t,e)+Math.PI/2}(t.atoms.x[t.meta.terminalNodes[1]-1],t.atoms.y[t.meta.terminalNodes[1]-1])))}(t,r),function(t,e){const s=t.atoms.x;s[t.meta.rNodes[1]-1]>s[e-1]&&function(t,e,s){const i=e-1,n=s-1,o=t.atoms.x,r=t.atoms.y,a=o[i],l=r[i];o[i]=o[n],r[i]=r[n],o[n]=a,r[n]=l}(t,e,t.meta.rNodes[1])}(t,r)}(y):t===h.RIBOSE||t===h.DEOXYRIBOSE?function(t,e){const s=t.atoms.x,i=t.atoms.y;let n=t.meta.terminalNodes[0]-1;const o=t.meta.rNodes[1]-1;T(t,-s[n],-i[n]);const r=C(s[o],i[o]);v(t.atoms,3*Math.PI/2-r),e.value=function(t){const e=t.atoms.x,s=t.atoms.y,i=t.meta.rNodes[2]-1,n=t.meta.terminalNodes[2]-1,o=e[i]-e[n],r=s[i]-s[n];return Math.atan(r/o)+Math.PI/2}(t),n=t.meta.terminalNodes[0]-1,T(t,-s[n],-i[n])}(y,n):t===h.PHOSPHATE?function(t){const e=t.meta.terminalNodes[0]-1,s=t.meta.rNodes[0]-1,i=t.atoms.x,n=t.atoms.y;T(t,-i[e],-n[e]);const o=C(i[s],n[s]);v(t.atoms,Math.PI/2-o)}(y):function(t,e){const s=t.atoms.x,i=t.atoms.y,n=t.meta.terminalNodes[0]-1,o=t.meta.rNodes[0]-1;T(t,-s[n],-i[n]);const r=C(s[o],i[o]),a=e.value;if(!a)throw new Error("The value of sugarBranchToOYAngle is null");v(t.atoms,Math.PI-r+a);const l=function(t,e){return u(Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2))}({x:s[t.meta.rNodes[0]-1],y:i[t.meta.rNodes[0]-1]},{x:s[t.meta.terminalNodes[0]-1],y:i[t.meta.terminalNodes[0]-1]});if(1!=l)for(let t=0;t<s.length;++t)s[t]=u(s[t]/l),i[t]=u(i[t]/l)}(y,n),function(t,e,s){"PEPTIDE"===t?(f(e,t),b(e,e.meta.rNodes[1])):s===h.RIBOSE||s===h.DEOXYRIBOSE?(b(e,e.meta.rNodes[1]),e.meta.rNodes[1]=e.meta.terminalNodes[1],p(e.bonds,e.meta),f(e,t),b(e,e.meta.rNodes[1]),b(e,e.meta.rNodes[0]),b(e,e.meta.rNodes[2])):s===h.PHOSPHATE&&(e.meta.terminalNodes[0]=e.meta.rNodes[0],T(e,-e.atoms.x[e.meta.terminalNodes[0]-1],-e.atoms.y[e.meta.terminalNodes[0]-1]),f(e,t),b(e,e.meta.rNodes[1]))}(i,y,t),function(t){let e=0;for(;e<t.atoms.atomTypes.length;)t.atoms.atomTypes[e]===h.HYDROGEN&&(b(t,e+1),--e),++e}(y),y}return null}(e,s,i,n,o);if(!r)throw new Error(`Monomer with symbol '${e}' is absent the monomer library`);t.set(e,r)}}function g(t,e,s,i){const n={backboneShift:null,branchShift:null,terminalNodes:[],rNodes:[]};return function(t,e,s){for(const[i,n]of s)t.atomTypes[i-1]=e[n-1]}(t,s,i),function(t,e){e.rNodes=Array.from(t.keys());for(let s=0;s<e.rNodes.length;s++)for(const i of[1,2])if(t.get(e.rNodes[s])===i){const t=e.rNodes[i-1];e.rNodes[i-1]=e.rNodes[s],e.rNodes[s]=t}}(i,n),p(e,n),n}function p(t,e){const s=e.rNodes;e.terminalNodes=new Array(s.length).fill(0);const i=e.terminalNodes,n=t.atomPairs;let o=0,r=0;for(;o<n.length&&r<i.length;){for(let t=0;t<i.length;++t)for(let e=0;e<2;++e)n[o][e]===s[t]&&(i[t]=n[o][(e+1)%2],s.length,++r);++o}}function f(t,e){t.meta.rNodes.length>1&&(t.meta.backboneShift=y(t,t.meta.rNodes[1]-1,t.meta.terminalNodes[0]-1)),"RNA"===e&&t.meta.rNodes.length>2&&(t.meta.branchShift=y(t,t.meta.rNodes[2]-1,t.meta.terminalNodes[0]-1))}function y(t,e,s){return[u(t.atoms.x[e]-t.atoms.x[s]),u(t.atoms.y[e]-t.atoms.y[s])]}function b(t,e){if(void 0!==e){const s=e-1,i=t.atoms,n=t.bonds,o=t.meta;i.atomTypes.splice(s,1),i.x=w(Float32Array,i.x,s,1),i.y=w(Float32Array,i.y,s,1),i.kwargs.splice(s,1);for(let t=0;t<o.terminalNodes.length;++t)o.terminalNodes[t]>e?--o.terminalNodes[t]:o.terminalNodes[t]===e&&(o.terminalNodes[t]=-1);for(let t=0;t<o.rNodes.length;++t)o.rNodes[t]>e?--o.rNodes[t]:o.rNodes[t]===e&&(o.rNodes[t]=-1);let r=0;for(;r<n.atomPairs.length;){const t=n.atomPairs[r][0],s=n.atomPairs[r][1];t===e||s===e?(n.atomPairs.splice(r,1),n.bondTypes=w(Uint32Array,n.bondTypes,r,1),n.bondConfiguration.has(r)&&n.bondConfiguration.delete(r),n.kwargs.has(r)&&n.kwargs.delete(r),--r):(n.atomPairs[r][0]=t>e?t-1:t,n.atomPairs[r][1]=s>e?s-1:s),++r}let a=Array.from(n.bondConfiguration.keys());a.forEach((t=>{if(n.bondConfiguration.has(t)&&t>s){const e=n.bondConfiguration.get(t);n.bondConfiguration.delete(t),n.bondConfiguration.set(t-1,e)}})),a=Array.from(n.kwargs.keys()),a.forEach((t=>{if(n.kwargs.has(t)&&t>s){const e=n.kwargs.get(t);n.kwargs.delete(t),n.kwargs.set(t-1,e)}}))}}function w(t,e,s,i){const n=new t(e.length-i);let o=0,r=0;for(;o<e.length;)o===s&&(o+=i),n[r]=e[o],++r,++o;return n}function C(t,e){let s;if(0===t)s=e>0?0:Math.PI;else if(0===e)s=t>0?-Math.PI/2:Math.PI/2;else{const i=e/t,n=Math.atan(i);s=t<0?Math.PI/2+n:-Math.PI/2+n}return s}function v(t,e){if(0!==e){const s=t.x,i=t.y,n=Math.cos(e),o=Math.sin(e);for(let t=0;t<s.length;++t){const e=s[t];s[t]=u(e*n-i[t]*o),i[t]=u(e*o+i[t]*n)}}}function S(t,e){if(e){const e=t.atoms.y;for(let t=0;t<e.length;t++)e[t]=-e[t]}else{const e=t.atoms.x;for(let t=0;t<e.length;t++)e[t]=-e[t]}const s=t.bonds.bondConfiguration;for(const[t,e]of s){const i=1===e?3:1;s.set(t,i)}}function T(t,e,s){const i=t.atoms.x,n=t.atoms.y;for(let t=0;t<i.length;++t)i[t]=u(i[t]+e),void 0!==s&&(n[t]=u(n[t]+s))}},6137:(t,e,s)=>{"use strict";s.d(e,{J:()=>n});var i=s(9976);class n extends i.B{static get Chromatogram(){return void 0===this.chromatogram&&(this.chromatogram=new n({A:"green",C:"blue",G:"black",T:"red",U:"red",others:"gray"})),this.chromatogram}}class o{}o.SemType="Nucleotides",o.SemTypeMultipleAlignment="NucleotidesMultipleAlignment",o.Names={A:"Adenine",C:"Cytosine",G:"Guanine",T:"Thymine",U:"Uracil"}},9976:(t,e,s)=>{"use strict";s.d(e,{B:()=>i});class i{static makePalette(t,e=!1,s=i){const n={};return t.forEach((t=>{const s=t[0],i=t[1];s.forEach(((t,s)=>{n[t]=this.colourPalette[i][e?0:s]}))})),new s(n)}constructor(t){this._palette=t}get(t){return this._palette[t]}}i.undefinedColor="rgb(100,100,100)",i.colourPalette={orange:["rgb(255,187,120)","rgb(245,167,100)","rgb(235,137,70)","rgb(205, 111, 71)"],all_green:["rgb(44,160,44)","rgb(74,160,74)","rgb(23,103,57)","rgb(30,110,96)","rgb(60,131,95)","rgb(24,110,79)","rgb(152,223,138)","rgb(182, 223, 138)","rgb(152, 193, 138)"],all_blue:["rgb(31,119,180)","rgb(23,190,207)","rgb(122, 102, 189)","rgb(158,218,229)","rgb(141, 124, 217)","rgb(31, 120, 150)"],magenta:["rgb(162,106,192)","rgb(197,165,224)","rgb(208,113,218)"],red:["rgb(214,39,40)","rgb(255,152,150)"],st_blue:["rgb(23,190,207)","rgb(158,218,229)","rgb(31,119,180)"],dark_blue:["rgb(31,119,180)","rgb(31, 120, 150)"],light_blue:["rgb(23,190,207)","rgb(158,218,229)","rgb(108, 218, 229)","rgb(23,190,227)"],lilac_blue:["rgb(124,102,211)","rgb(149,134,217)","rgb(97, 81, 150)"],dark_green:["rgb(23,103,57)","rgb(30,110,96)","rgb(60,131,95)","rgb(24,110,79)"],green:["rgb(44,160,44)","rgb(74,160,74)"],light_green:["rgb(152,223,138)","rgb(182, 223, 138)","rgb(152, 193, 138)"],st_green:["rgb(44,160,44)","rgb(152,223,138)","rgb(39, 174, 96)","rgb(74,160,74)"],pink:["rgb(247,182,210)"],brown:["rgb(140,86,75)","rgb(102, 62, 54)"],gray:["rgb(127,127,127)","rgb(199,199,199)","rgb(196,156,148)","rgb(222, 222, 180)"],yellow:["rgb(188,189,34)"],white:["rgb(230,230,230)"]}},7331:(t,e,s)=>{"use strict";s.d(e,{UE:()=>h});var i=s(976),n=s(9976);class o{static hashCode(t){let e=0;if(0===t.length)return e;for(let s=0;s<t.length;s++)e=(e<<5)-e+t.charCodeAt(s),e|=0;return e}}class r{}class a extends r{get(t){return"#666666"}}class l extends r{static buildPalette(){return[].concat(...Object.values(n.B.colourPalette))}get(t){const e=o.hashCode(t)%l.palette.length;return function(t){if(null==t)return"rgb(100,100,100)";const e=i.Color.fromHtml(t),s=i.Color.g(e),n=i.Color.r(e),o=i.Color.b(e),r=Math.sqrt(Math.pow(0-n,2)+Math.pow(0-s,2)+Math.pow(0-o,2));return r>210?`rgb(${n/r*210},${s/r*210},${o/r*210})`:i.Color.toRgb(e)}(l.palette[e])}}l.palette=l.buildPalette();class h extends n.B{static get Gray(){return void 0===this.gray&&(this.gray=new a),this.gray}static get Color(){return void 0===this.color&&(this.color=new l),this.color}}},9611:(t,e,s)=>{"use strict";s.d(e,{A:()=>h});var i=s(4469),n=s(976),o=s(6414),r=s.n(o),a=s(8447);const l={DNA:"RNA",RNA:"RNA",PT:"PEPTIDE",UN:"PEPTIDE"};class h{get updated(){return this._updated}constructor(t,e,s){this.grid=t,this.col=e,this.propsProvider=s,this._monomerLengthList=null,this.separatorWidth=5,this._updated=!1,this._monomerLengthMap={},this._monomerStructureMap={},this.subs=[],this._splitter=(0,a.Mj)(this.col),this.props=this.propsProvider(),this._rowsProcessed=n.BitSet.create(this.col.length),this.grid&&(this.subs.push(e.dataFrame.onDataChanged.subscribe((()=>{this.props=this.propsProvider(),this._monomerLengthList=null,this._rowsProcessed=n.BitSet.create(this.col.length)}))),this.subs.push(i.events.onViewRemoved.subscribe((t=>{this.grid?.view?.id===t.id&&this.destroy()}))))}destroy(){for(const t of this.subs)t.unsubscribe()}getCellMonomerLengths(t){const e=this.props.unitsHandler.isMsa()?this.getCellMonomerLengthsForSeqMsa():this.getCellMonomerLengthsForSeq(t),s=new Array(e.length+1);s[0]=5;for(let t=1;t<s.length;t++)s[t]=s[t-1]+e[t-1];return[e,s]}getCellMonomerLengthsForSeq(t){null===this._monomerLengthList&&(this._monomerLengthList=new Array(this.col.length).fill(null),this._updated=!0);let e=this._monomerLengthList[t];if(null===e){const s=this.getSeqMonList(t);e=this._monomerLengthList[t]=new Array(s.length);for(const[t,i]of r().enumerate(s)){const s=this.props.monomerToShort(t,this.props.monomerLengthLimit),n=(this.props.unitsHandler.isSeparator()?this.separatorWidth:this.props.separatorWidth)+s.length*this.props.monomerCharWidth;e[i]=n}this._updated=!0}return e}getCellMonomerLengthsForSeqMsa(){var t;null===this._monomerLengthList&&(this._monomerLengthList=new Array(1).fill(null),this._updated=!0),(t=this._monomerLengthList)[0]??(t[0]=new Array(0));const e=this._monomerLengthList[0],s=Math.max(Math.floor((this.grid?.vertScroll.min??0)-10),0),i=Math.min(Math.ceil((this.grid?.vertScroll.max??0)+10),this.col.length);for(let t=s;t<i;t++){if(this._rowsProcessed.get(t))continue;const s=this.getSeqMonList(t);s.length>e.length&&e.push(...new Array(s.length-e.length).fill(0));for(const[t,i]of r().enumerate(s)){const s=this.props.monomerToShort(t,this.props.monomerLengthLimit),n=this.props.separatorWidth+s.length*this.props.monomerCharWidth;e[i]=Math.max(e[i]??0,n)}this._updated=!0}return e}getPosition(t,e){const[s,i]=this.getCellMonomerLengths(t),n=this.col.get(t),o=r()(this._splitter(n)).toArray();if(0===o.length)return null;let a=100,l=null,h=o.length,c=!1,u=0;if(i[0]<=e&&e<i.slice(-1)[0])for(;!c;)if(u=Math.floor((h+(l??0))/2),e>=i[u]&&e<=i[u+1]?(l=u,c=!0):e<i[u]?h=u-1:e>i[u+1]&&(l=u+1),l==h&&(c=!0),--a<=0)throw new Error(`Get position for pointer x = ${e} searching has not converged on ${JSON.stringify(i)}. `);return l}getSeqMonList(t){const e=this.col.get(t);return e?r()(this._splitter(e)).toArray():[]}getMonomer(t){const e=this.props.unitsHandler.alphabet??"UN",s=l[e];return this.props.monomerLib?.getMonomer(s,t)??null}setMonomerLengthLimit(t){this.props.monomerLengthLimit=t,this._updated=!0}setSeparatorWidth(t){this.props.separatorWidth=t,this._updated=!0}isMsa(){return this.props.unitsHandler.isMsa()}}},1047:(t,e,s)=>{"use strict";s.d(e,{$3:()=>h,At:()=>n,Ei:()=>r,K4:()=>a,pU:()=>c,pn:()=>o,rx:()=>i,zh:()=>l});const i=["symbol","molfile","rgroups","name"],n="MonomerName",o={symbol:"Short Name",name:"Medium Name",smiles:"SMILES"},r=[{capGroupSmiles:"[*:1][H]",alternateId:"R1-H",capGroupName:"H",label:"R1"},{capGroupSmiles:"O[*:2]",alternateId:"R2-OH",capGroupName:"OH",label:"R2"}],a={monomerType:null,smiles:null,name:"MonomerName",author:null,molfile:"molecule",naturalAnalog:"MonomerNaturalAnalogCode",rgroups:"MonomerCaps",createDate:null,id:null,polymerType:"MonomerType",symbol:"MonomerCode"},l={monomerType:"Backbone",smiles:"",name:"",author:"Datagrok",molfile:"",naturalAnalog:"",rgroups:[],createDate:null,id:0,polymerType:"PEPTIDE",symbol:""},h="p",c=new RegExp(`[rd]\\((\\w)\\)${h}?`,"g")},5226:(t,e,s)=>{"use strict";s.d(e,{i:()=>r});var i=s(976),n=s(499),o=s(1821);class r{get descriptionsArray(){return this._descriptionsArray}get sequencesArray(){return this._sequencesArray}parseMacromolecule(t,e){return this._fileContent.slice(t,e).split(/\s/).join("")}parseColumns(){const t=/^>(.*)$/gm;let e,s=0;for(;e=t.exec(this._fileContent);){const i=this._fileContent.substring(e.index+1,t.lastIndex);this._descriptionsArray.push(i),0!==s&&this._sequencesArray.push(this.parseMacromolecule(s,e.index)),s=t.lastIndex+1}this._sequencesArray.push(this.parseMacromolecule(s,-1))}importFasta(){const t=i.Column.fromStrings("description",this.descriptionsArray),e=i.Column.fromStrings("sequence",this.sequencesArray);return e.semType=i.SEMTYPE.MACROMOLECULE,e.setTag(i.TAGS.UNITS,o.r2.FASTA),n.Cn.getOrCreate(e),[i.DataFrame.fromColumns([t,e])]}constructor(t){this._descriptionsArray=[],this._sequencesArray=[],this._fileContent=t,this.parseColumns()}}},1821:(t,e,s)=>{"use strict";s.d(e,{BM:()=>r,CI:()=>o,XS:()=>l,r2:()=>i});var i,n=s(6286);!function(t){t.FASTA="fasta",t.SEPARATOR="separator",t.HELM="helm"}(i||(i={}));const o=", ",r=/(?:\[([A-Za-z0-9_\-,()]+)\])|([A-Za-z\-])/g,a=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"])}}},l=[new n.L("PT",a.fasta.peptide,.5),new n.L("DNA",a.fasta.dna,.55),new n.L("RNA",a.fasta.rna,.55)]},8447:(t,e,s)=>{"use strict";s.d(e,{CI:()=>i.CI,GU:()=>n.GU,Mj:()=>n.Mj,XS:()=>i.XS,dQ:()=>n.dQ,kB:()=>n.kB,py:()=>n.py,r2:()=>i.r2,up:()=>n.up});var i=s(1821),n=s(585)},6286:(t,e,s)=>{"use strict";s.d(e,{L:()=>i,d:()=>n});class i{constructor(t,e,s){this.name=t,this.alphabet=e,this.cutoff=s}}class n extends i{constructor(t,e,s){super(t.name,t.alphabet,t.cutoff),this.freq=e,this.similarity=s}}},585:(t,e,s)=>{"use strict";s.d(e,{Ar:()=>f,FJ:()=>p,GU:()=>T,Mj:()=>v,dQ:()=>A,gP:()=>w,kB:()=>g,py:()=>E,up:()=>x,vU:()=>C,w4:()=>M});var i=s(976),n=s(6414),o=s.n(n),r=s(6286),a=s(1821),l=s(499),h=s(3659),c=s(850),u=s(2012),m=s(6137),d=s(7331);function g(t){return o()(t.toString().matchAll(a.BM)).map((t=>t[2]??t[1])).toArray()}function p(t){return t||[]}function f(t,e=undefined){return s=>s?s.split(t,e):[]}const y=/(PEPTIDE1|DNA1|RNA1)\{([^}]+)}/g,b=/\[([^\[\]]+)]/g;function w(t){y.lastIndex=0;const e=y.exec(t.toString()),s=e?e[2]:null;return(s?s.split("."):[]).map((t=>{b.lastIndex=0;const e=b.exec(t);return e&&e.length>=2?e[1]:t}))}function C(t,e,s=undefined){if(t.toLowerCase().startsWith(a.r2.FASTA))return g;if(t.toLowerCase().startsWith(a.r2.SEPARATOR))return f(e,s);if(t.toLowerCase().startsWith(a.r2.HELM))return w;throw new Error(`Unexpected units ${t} .`)}function v(t){return l.Cn.getOrCreate(t).getSplitter()}const S=/([^\W_]+)/g;function T(t,e){if(t.length<=e)return t;const s=t.match(S),i=t.length>e||(s?.length??0)>1,n=s?.[0]??" ";return i?n.substring(0,e-1)+"…":n}function M(t,e,s="-"){const i=e.map((e=>{const i=function(t,e,s="-"){const i=new Set([...new Set(Object.keys(t)),...e]);i.delete(s);const n=[],o=[];for(const s of i)n.push(s in t?t[s]:0),o.push(e.has(s)?1:0);const r=new h.OW(n),a=new h.OW(o);return(0,c.MA)(r,a)/((0,c.$G)(r)*(0,c.$G)(a))}(t,e.alphabet,s);return new r.d(e,t,i)}));let n;const o=Math.max(...i.map((t=>t.similarity>t.cutoff?t.similarity:-1)));return n=o>0?i.find((t=>t.similarity===o)).name:"UN",n}function A(t,e=5){let s;if(t.semType==i.SEMTYPE.MACROMOLECULE)s=l.Cn.getOrCreate(t).alphabet;else{const i=function(t,e,s){return t.categories,function(t,e){const s={};let i=!0,n=null;for(const o of t)if(null==n?n=o.length:o.length!==n&&(i=!1),o.length>=e)for(const t of o)t in s||(s[t]=0),s[t]+=1;return{freq:s,sameLength:i}}(o()(t.getRawData()).map((e=>s(t.categories[e]))),e)}(t,e,g);s=M(i.freq,a.XS)}return E(s)}function E(t){switch(t){case"PT":return u.f.GrokGroups;case"DNA":case"RNA":return m.J.Chromatogram;default:return d.UE.Color}}function x(t){const e=t.columns.bySemTypeAll(i.SEMTYPE.MACROMOLECULE);let s=e.find((t=>{const e=t.getTag(i.TAGS.UNITS);return!!e&&-1!==e.indexOf("MSA")}))??null;return!s&&e.length>0&&(s=e[0]),s}},8457:(t,e,s)=>{"use strict";s.d(e,{O:()=>a});var i=s(976),n=s(6414),o=s.n(n),r=s(585);function a(t){const e=(0,r.Mj)(t),s=t=>{const e=l.columns.addNewString((t+1).toString());return n.push(e),e},n=[],a=t.length,l=i.DataFrame.create(a);for(let i=0;i<a;++i){const r=t.get(i);if(null==r)continue;const a=e(r);for(const[t,e]of o().enumerate(a))((n[e]??null)||s(e)).set(i,t||"-",!1)}return l}},499:(t,e,s)=>{"use strict";s.d(e,{Cn:()=>d});var i=s(976),n=s(6414),o=s.n(n),r=s(8447),a=s(585),l=s(489),h=s(7228),c=s(1047);const u=new class{constructor(){this.uhTemp=`units-handler.${i.SEMTYPE.MACROMOLECULE}`}},m={[r.r2.FASTA]:"-",[r.r2.SEPARATOR]:"",[r.r2.HELM]:"*"};class d{static setUnitsToFastaColumn(t){if(t.column.semType!==i.SEMTYPE.MACROMOLECULE||t.column.getTag(i.TAGS.UNITS)!==r.r2.FASTA)throw new Error(`The column of notation '${r.r2.FASTA}' must be '${i.SEMTYPE.MACROMOLECULE}'.`);t.column.setTag(i.TAGS.UNITS,r.r2.FASTA),d.setTags(t)}static setUnitsToSeparatorColumn(t,e){if(t.column.semType!==i.SEMTYPE.MACROMOLECULE||t.column.getTag(i.TAGS.UNITS)!==r.r2.SEPARATOR)throw new Error(`The column of notation '${r.r2.SEPARATOR}' must be '${i.SEMTYPE.MACROMOLECULE}'.`);if(!e)throw new Error(`The column of notation '${r.r2.SEPARATOR}' must have the separator tag.`);t.column.setTag(i.TAGS.UNITS,r.r2.SEPARATOR),t.column.setTag("separator",e),d.setTags(t)}static setUnitsToHelmColumn(t){if(t.column.semType!==i.SEMTYPE.MACROMOLECULE)throw new Error(`The column of notation '${r.r2.HELM}' must be '${i.SEMTYPE.MACROMOLECULE}'`);t.column.setTag(i.TAGS.UNITS,r.r2.HELM),d.setTags(t)}static setTags(t){const e=t.column.getTag(i.TAGS.UNITS),s=t.stats;if(Object.keys(s.freq).some((t=>t.length>1)),[r.r2.FASTA,r.r2.SEPARATOR].includes(e)){if(0===Object.keys(s.freq).length)throw new Error("Alphabet is empty");let e=t.column.getTag("aligned");null===e&&(e=s.sameLength?"SEQ.MSA":"SEQ",t.column.setTag("aligned",e));let i=t.column.getTag("alphabet");if(null===i&&(i=(0,a.w4)(s.freq,r.XS),t.column.setTag("alphabet",i)),"UN"===i){const e=Object.keys(s.freq).length,i=Object.keys(s.freq).some((t=>t.length>1));t.column.setTag(".alphabetSize",e.toString()),t.column.setTag(".alphabetIsMultichar",i?"true":"false")}}}get column(){return this._column}get units(){return this._units}get notation(){return this._notation}get defaultGapSymbol(){return this._defaultGapSymbol}get separator(){const t=this.column.getTag("separator")??void 0;if(this.notation===r.r2.SEPARATOR&&void 0===t)throw new Error(`Separator is mandatory for column '${this.column.name}' of notation '${this.notation}'.`);return t}get aligned(){const t=this.column.getTag("aligned");if(!t&&(this.isFasta()||this.isSeparator()))throw new Error("Tag aligned not set");return t}get alphabet(){const t=this.column.getTag("alphabet");if(!t&&(this.isFasta()||this.isSeparator()))throw new Error("Tag alphabet not set");return t}get helmCompatible(){return this.column.getTag(".isHelmCompatible")}getAlphabetSize(){if(this.notation==r.r2.HELM||"UN"==this.alphabet){const t=this.column.getTag(".alphabetSize");let e;if(t)e=parseInt(t);else{const t=this.stats;e=Object.keys(t.freq).length}return e}switch(this.alphabet){case"PT":return 20;case"DNA":case"RNA":return 4;case"NT":return console.warn("Unexpected alphabet 'NT'."),4;default:throw new Error(`Unexpected alphabet '${this.alphabet}'.`)}}getAlphabetIsMultichar(){return this.notation===r.r2.HELM||"UN"===this.alphabet&&"true"===this.column.getTag(".alphabetIsMultichar")}get splitted(){if(null===this._splitted){const t=this.getSplitter(),e=this._column.length;this._splitted=new Array(e);const s=this._column.getRawData(),i=this._column.categories;for(let n=0;n<e;n++){const e=i[s[n]];this._splitted[n]=t(e)}}return this._splitted}get stats(){if(null===this._stats){const t={};let e=!0,s=null;for(const i of this.splitted){null==s?s=i.length:i.length!==s&&(e=!1);for(const e of i)e in t||(t[e]=0),t[e]+=1}this._stats={freq:t,sameLength:e}}return this._stats}get maxLength(){return null===this._maxLength&&(this._maxLength=Math.max(...this.splitted.map((t=>t.length)))),this._maxLength}get posList(){if(null===this._posList){const t=this.column.getTag(".positionNames");this._posList=t?t.split(r.CI).map((t=>t.trim())):o().count(1).take(this.maxLength).map((t=>t.toString())).toArray()}return this._posList}isFasta(){return this.notation===r.r2.FASTA}isSeparator(){return this.notation===r.r2.SEPARATOR}isHelm(){return this.notation===r.r2.HELM}isRna(){return"RNA"===this.alphabet}isDna(){return"DNA"===this.alphabet}isPeptide(){return"PT"===this.alphabet}isMsa(){return!!this.aligned&&this.aligned.toUpperCase().includes("MSA")}isHelmCompatible(){return"true"===this.helmCompatible}isGap(t){return!t||this.units===r.r2.FASTA&&t===m[r.r2.FASTA]||this.units===r.r2.HELM&&t===m[r.r2.HELM]}getNotation(){if(this.units.toLowerCase().startsWith(r.r2.FASTA))return r.r2.FASTA;if(this.units.toLowerCase().startsWith(r.r2.SEPARATOR))return r.r2.SEPARATOR;if(this.units.toLowerCase().startsWith(r.r2.HELM))return r.r2.HELM;throw new Error(`Column '${this.column.name}' has unexpected notation '${this.units}'.`)}getHelmWrappers(){return[this.isDna()||this.isRna()||this.isHelmCompatible()?"RNA1{":"PEPTIDE1{",this.isDna()?"d(":this.isRna()?"r(":"",this.isDna()||this.isRna()?")p":"","}$$$$"]}getNewColumn(t,e){const s=this.column,n=s.length,o=t.toLowerCase()+"("+s.name+")",a=s.dataFrame.columns.getUnusedName(o),l=i.Column.fromList("string",a,new Array(n).fill(""));if(l.semType=i.SEMTYPE.MACROMOLECULE,l.setTag(i.TAGS.UNITS,t),t===r.r2.SEPARATOR){if(!e)throw new Error(`Notation '${r.r2.SEPARATOR}' requires separator value.`);l.setTag("separator",e)}l.setTag(i.TAGS.CELL_RENDERER,"Macromolecule");const h=s.getTag("aligned");h&&l.setTag("aligned",h);const c=s.getTag("alphabet");null!=c&&l.setTag("alphabet",c);let u=s.getTag(".alphabetSize");null!=c&&u&&l.setTag(".alphabetSize",u);const m=s.getTag(".alphabetIsMultichar");return null!=c&&void 0!==m&&l.setTag(".alphabetIsMultichar",m),t==r.r2.HELM&&(u=this.getAlphabetSize().toString(),l.setTag(".alphabetSize",u)),l}static getNewColumn(t){const e=d.getOrCreate(t),s=e.notation;return e.getNewColumn(s)}static unitsStringIsValid(t){return t=t.toLowerCase(),[r.r2.FASTA,r.r2.SEPARATOR,r.r2.HELM].some((e=>t.startsWith(e.toLowerCase())))}static getNewColumnFromParams(t,e,s){if(!d.unitsStringIsValid(s))throw new Error("Invalid format of 'units' parameter");const n=i.Column.fromList("string",e,new Array(t).fill(""));return n.semType=i.SEMTYPE.MACROMOLECULE,n.setTag(i.TAGS.UNITS,s),n}getSplitter(t){if(this.units.toLowerCase().startsWith(r.r2.FASTA))return null===this.column.getTag("alphabet")||this.getAlphabetIsMultichar()?a.kB:a.FJ;if(this.units.toLowerCase().startsWith(r.r2.SEPARATOR))return(0,a.Ar)(this.separator,t);if(this.units.toLowerCase().startsWith(r.r2.HELM))return a.gP;throw new Error(`Unexpected units ${this.units} .`)}getDistanceFunctionName(){if(!this.isFasta())throw new Error("Only FASTA notation is supported");return this.isMsa()?l.U.HAMMING:(this.alphabet,l.U.LEVENSHTEIN)}getDistanceFunction(){return l.o[this.getDistanceFunctionName()]()}async checkHelmCompatibility(){if(this.column.tags.has(".isHelmCompatible"))return"true"===this.column.getTag(".isHelmCompatible");const t=(await(0,h.JN)()).getBioLib().getMonomerSymbolsByType("PEPTIDE".toString()),e=new Set(t),s=(0,a.Ar)(this.separator);for(const t of this.column.categories){const i=s(t);for(const t of i)if(!e.has(t))return this.column.setTag(".isHelmCompatible","false"),!1}return this.column.setTag(".isHelmCompatible","true"),!0}get splitter(){return null===this._splitter&&(this._splitter=(0,a.Mj)(this.column)),this._splitter}toFasta(t){return t===r.r2.FASTA}toSeparator(t){return t===r.r2.SEPARATOR}toHelm(t){return t===r.r2.HELM}convertHelmToFastaSeparator(t,e,s,i){i||(i=this.toFasta(e)?m[r.r2.FASTA]:m[r.r2.SEPARATOR]),s||(s=this.toFasta(e)?"":this.separator);const n=t.startsWith("RNA"),o=this.splitter(t),a=[];for(let t=0;t<o.length;t++){let s=o[t];if(n&&(s=s.replace(c.pU,"")),s===m[r.r2.HELM])a.push(i);else if(this.toFasta(e)&&s.length>1){const t="["+s+"]";a.push(t)}else a.push(s)}return a.join(s)}convert(t,e){const s=this.getConverter(t,e),i=this.getNewColumn(t,e);return i.init((t=>s(this.column.get(t)))),i}getRegion(t,e,s){const i=this.getNewColumn(this.notation,this.separator);i.name=s,Math.max(...this.splitted.map((t=>t.length)));const n=t??0,o=e??this.maxLength-1,a=this.getJoiner(),l=o-n+1;i.init((t=>{const e=this.splitted[t],s=new Array(l);for(let t=0;t<l;++t){const i=n+t;s[t]=i<e.length?e[i]:m[this.notation]}return a(s)}));const h=t=>{const e=t.split(",").map((t=>t.trim())),s=new Array(l);for(let t=0;t<l;++t){const i=n+t;s[t]=i<e.length?e[i]:"?"}return s.join(r.CI)},c=this.column.getTag(".positionNames");c&&i.setTag(".positionNames",h(c));const u=this.column.getTag(".positionLabels");return u&&i.setTag(".positionLabels",h(u)),i}getJoiner(){const t=this;if(this.notation===r.r2.FASTA)return function(e){return g(t,e)};if(this.notation===r.r2.SEPARATOR)return function(e){return p(t,e,t.separator)};if(this.notation===r.r2.HELM){const e="DNA"===t.alphabet||"RNA"===t.alphabet;return function(s){return f(t,s,e)}}throw new Error}getConverter(t,e=undefined){if(t===r.r2.SEPARATOR&&!e)throw new Error(`Target separator is not specified for target units '${r.r2.SEPARATOR}'.`);const s=this;if(t===r.r2.FASTA)return function(t){return function(t,e){const s=t.isHelm()?y(t,e):t.getSplitter()(e);return g(t,s)}(s,t)};if(t===r.r2.HELM)return function(t){return function(t,e){const s=e.startsWith("DNA")||e.startsWith("RNA"),i=t.getSplitter()(e);return f(t,i,s)}(s,t)};if(t===r.r2.SEPARATOR)return function(t){return function(t,e,s){const i=t.isHelm()?y(t,e):t.getSplitter()(e);return p(t,i,s)}(s,t,e)};throw new Error}constructor(t){if(this._splitter=null,this._splitted=null,this._stats=null,this._maxLength=null,this._posList=null,t.type!=i.TYPE.STRING)throw new Error(`Unexpected column type '${t.type}', must be '${i.TYPE.STRING}'.`);this._column=t;const e=this._column.getTag(i.TAGS.UNITS);if(null==e)throw new Error("Units are not specified in column");if(this._units=e,this._notation=this.getNotation(),this._defaultGapSymbol=this.isFasta()?m[r.r2.FASTA]:this.isHelm()?m[r.r2.HELM]:m[r.r2.SEPARATOR],!this.column.tags.has("aligned")||!this.column.tags.has("alphabet")||!this.column.tags.has(".alphabetIsMultichar")&&!this.isHelm()&&"UN"===this.alphabet)if(this.isFasta())d.setUnitsToFastaColumn(this);else if(this.isSeparator()){const e=t.getTag("separator");d.setUnitsToSeparatorColumn(this,e)}else{if(!this.isHelm())throw new Error(`Unexpected units '${this.column.getTag(i.TAGS.UNITS)}'.`);d.setUnitsToHelmColumn(this)}if(!this.column.tags.has(".alphabetIsMultichar"))if(this.isHelm())this.column.setTag(".alphabetIsMultichar","true");else if(["UN"].includes(this.alphabet))throw new Error(`For column '${this.column.name}' of alphabet '${this.alphabet}' tag '.alphabetIsMultichar' is mandatory.`)}static getOrCreate(t){return u.uhTemp in t.temp||(t.temp[u.uhTemp]=new d(t)),t.temp[u.uhTemp]}}function g(t,e){const s=new Array(e.length);for(const[i,n]of o().enumerate(e)){let o=i;t.isHelm()&&(o=i.replace(c.pU,"$1")),t.isGap(o)?o=m[r.r2.FASTA]:o.length>1&&(o="["+e[n]+"]"),s[n]=o}return s.join("")}function p(t,e,s){const i=new Array(e.length);for(const[s,n]of o().enumerate(e)){let e=s;t.isGap(e)&&(e=m[r.r2.SEPARATOR]),i[n]=e}return i.map((t=>t??"")).join(s)}function f(t,e,s){const[i,n,a,l]=t.getHelmWrappers();return`${i}${o()(e).map((e=>{let i=e;return i=t.isGap(i)?m[r.r2.HELM]:s?i.replace(c.pU,"$1"):1==e.length?`${n}${e}${a}`:`${n}[${e}]${a}`,i})).toArray().join(".")}${l}`}function y(t,e){const s=t.getSplitter()(e),i=new Array(s.length),n=e.startsWith("DNA"),r=e.startsWith("RNA");for(const[t,e]of o().enumerate(s)){let s=t;(n||r)&&(s=s.replace(c.pU,"$1"),s=s===c.$3?null:s),i[e]=s}return i.filter((t=>null!==t))}},9298:(t,e,s)=>{"use strict";var i,n,o,r,a,l;s.d(e,{Ct:()=>l,DX:()=>i,ES:()=>n,dE:()=>a,iD:()=>r,vS:()=>h,vw:()=>o}),function(t){t.tooltipWebLogo=".tooltipWebLogo"}(i||(i={})),function(t){t.Entropy="Entropy",t.full="100%"}(n||(n={})),function(t){t.TOP="top",t.MIDDLE="middle",t.BOTTOM="bottom"}(o||(o={})),function(t){t.LEFT="left",t.CENTER="center",t.RIGHT="right"}(r||(r={})),function(t){t.AUTO="auto",t.ON="on",t.OFF="off"}(a||(a={})),function(t){t.Filtered="Filtered",t.Selected="Selected"}(l||(l={}));const h=new class{constructor(){this.sequenceColumnName=null,this.startPositionName=null,this.endPositionName=null,this.skipEmptySequences=!0,this.skipEmptyPositions=!1,this.shrinkEmptyTail=!0,this.backgroundColor=4294967295,this.positionHeight=n.Entropy,this.positionWidth=16,this.verticalAlignment=o.MIDDLE,this.horizontalAlignment=r.CENTER,this.fixWidth=!1,this.fitArea=!0,this.minHeight=50,this.maxHeight=100,this.showPositionLabels=!0,this.positionMarginState=a.AUTO,this.positionMargin=0,this.filterSource=l.Filtered}}},2669:(t,e,s)=>{"use strict";s.d(e,{m:()=>i});class i{constructor(t=!0,e=!0){const i=navigator.hardwareConcurrency;this._workerCount=t?Math.max(i-2,1):1,this._workers=new Array(this._workerCount).fill(null).map((()=>new Worker(new URL(s.p+s.u(868),s.b)))),this._terminateOnComplete=e}async calc(t,e,s=!0,i){return new Promise((async(n,o)=>{try{const o=t.length,r=new Array(this._workerCount),a=o*(o-1)/2;this._workerCount=Math.min(this._workerCount,a);const l=a/this._workerCount,h=new Float32Array(a);let c=0,u=1,m=0,d=Number.MIN_VALUE;for(let s=0;s<this._workerCount;s++){const n=Math.floor(s*l),g=s===this._workerCount-1?a:Math.floor((s+1)*l),p=c,f=u;s!==this._workerCount-1&&(c=o-2-Math.floor(Math.sqrt(-8*g+4*o*(o-1)-7)/2-.5),u=g-o*c+Math.floor((c+1)*(c+2)/2)),this._workers[s].postMessage({values:t,fnName:e,startRow:p,startCol:f,chunckSize:g-n,opts:i}),r[s]=new Promise(((t,e)=>{this._workers[s].onmessage=({data:{error:i,distanceMatrixData:o,min:r,max:a}})=>{this._terminateOnComplete&&this._workers[s].terminate(),i?e(i):(h.set(o,n),r<m&&(m=r),a>d&&(d=a),t())}}))}await Promise.all(r),s&&h.forEach(((t,e)=>{h[e]=(t-m)/(d-m)})),n(h)}catch(t){o(t)}}))}terminate(){this._workers.forEach((t=>t.terminate()))}}},3914:(t,e,s)=>{"use strict";s.d(e,{H:()=>n});var i=s(6814);class n{get data(){return this._data}get size(){return this._size}constructor(t,e){if(null==e){if(null==t)throw new Error("Arguments error: data or size is required.");if(this._data=t,this._size=(1+Math.sqrt(1+8*this._data.length))/2,this._size!=Math.floor(this._size))throw new Error(`Invalid data length ${this._data.length} leads to non integer size ${this._size}`)}else{this._size=e;const s=e*(e-1)/2;if(t){if(t.length!=s)throw new Error(`Invalid data length. Observations size ${e} requires data length ${s}.`);this._data=t}else this._data=new Float32Array(s)}}_linearizeIJ(t,e){if(!(t<e))throw new Error("i must be less than j");return this._size*t+e-Math.floor((t+2)*(t+1)/2)}get(t,e){return t==e?0:t<e?this._data[this._linearizeIJ(t,e)]:this._data[this._linearizeIJ(e,t)]}set(t,e,s){this._data[this._linearizeIJ(t,e)]=s}static calc(t,e){const s=t.length,o=new n(void 0,s);for(let n=0;n<s;n++)for(let r=n+1;r<s;r++)o.set(n,r,(0,i.k)(t[n])||(0,i.k)(t[r])?1:e(t[n],t[r]));return o}square(){for(let t=0;t<this._data.length;t++)this._data[t]=this._data[t]**2}add(t){if(this._size!==t._size)throw new Error(`Matrices must have the same size. This size: ${this._size}, other size: ${t._size}`);for(let e=0;e<this._data.length;e++)this._data[e]+=t._data[e]}sqrt(){for(let t=0;t<this._data.length;t++)this._data[t]=Math.sqrt(this._data[t])}normalize(){let t=0,e=this._data[0];for(let s=0;s<this._data.length;s++)this._data[s]<t&&(t=this._data[s]),this._data[s]>e&&(e=this._data[s]);const s=e-t;for(let i=0;i<this._data.length;i++)this._data[i]=0===s?this._data[i]-t:(this._data[i]-t)/(e-t)}}},6254:(t,e,s)=>{"use strict";function i(t,e){const s=n(e);function i(t,e){const i=Number(t),n=Number(e);return s(i,n)}const o={get:(t,s,n)=>"length"===s?e:new Proxy(t,function(t){return{get:(e,s,n)=>t===s?0:e[Number(t)>Number(s)?i(s,t):i(t,s)]}}(s))};return new Proxy(t,o)}function n(t){return(e,s)=>t*e+s-Math.floor((e+2)*(e+1)/2)}s.d(e,{_:()=>i,y:()=>n})},2590:(t,e,s)=>{"use strict";s.d(e,{_:()=>r});var i=s(5697),n=s(6361),o=s(6814);class r{constructor(){this._workerCount=Math.max(navigator.hardwareConcurrency-2,1),this._workers=new Array(this._workerCount).fill(null).map((()=>new Worker(new URL(s.p+s.u(381),s.b))))}async calc(t,e,s,i){const n=t.length*(t.length-1)/2,o=Math.floor(n/this._workerCount),r=new Array(this._workerCount);for(let a=0;a<this._workerCount;a++)r[a]=new Promise(((r,l)=>{const h=a*o,c=a===this._workerCount-1?n:(a+1)*o;this._workers[a].postMessage({values:t,startIdx:h,endIdx:c,threshold:s,fnName:e,opts:i}),this._workers[a].onmessage=({data:{error:t,i:e,j:s,distance:i}})=>{t?l(t):(this._workers[a].terminate(),r({i:e,j:s,distance:i,idx:a}))}}));const a=await Promise.all(r),l=a.reduce(((t,e)=>t+e.i.length),0),h=new Int32Array(l),c=new Int32Array(l),u=new Float32Array(l);let m=0;for(const t of a)h.set(t.i,m),c.set(t.j,m),u.set(t.distance,m),m+=t.i.length;return{i:h,j:c,distance:u}}static calcSync(t,e,s,r){const a=[],l=[],h=[];let c=0,u=0,m=0;const d=t.length*(t.length-1)/2;for(;c<d;){const d=(0,o.k)(t[u])||(0,o.k)(t[m])?1:s(t[u],t[m]);(Object.values(n.gk).some((t=>t===e))?(0,i.Om)(d):1-d)>=r&&(a.push(u),l.push(m),h.push(d)),c++,m++,m===t.length&&(u++,m=u+1)}return{i:new Int32Array(a),j:new Int32Array(l),distance:new Float32Array(h)}}}},6814:(t,e,s)=>{"use strict";s.d(e,{k:()=>i});const i=t=>null==t},5697:(t,e,s)=>{"use strict";s.d(e,{Dz:()=>C,FV:()=>u,KR:()=>c,MI:()=>S,NB:()=>f,Om:()=>T,Rt:()=>a,UX:()=>p,WI:()=>g,Zd:()=>d,_h:()=>m,aW:()=>b,bX:()=>A,bc:()=>l,fX:()=>v,kg:()=>r,s:()=>y,yU:()=>w});var i=s(9657),n=s(1040),o=s(489);n.gk.Tanimoto,n.gk.Dice,n.gk.Asymmetric,n.gk.BraunBlanquet,n.gk.Cosine,n.gk.Kulczynski,n.gk.McConnaughey,n.gk.RogotGoldberg,n.gk.Russel,n.gk.Sokal,n.gk.Hamming,n.gk.Euclidean,n.gk.Tanimoto,n.gk.Dice,n.gk.Asymmetric,n.gk.BraunBlanquet,n.gk.Cosine,n.gk.Kulczynski,n.gk.McConnaughey,n.gk.RogotGoldberg,n.gk.Russel,n.gk.Sokal,n.gk.Hamming,n.gk.Euclidean;const r=[n.gk.Tanimoto,n.gk.Dice,n.gk.Cosine],a=[n.gk.Tanimoto,n.gk.Asymmetric,n.gk.Cosine,n.gk.Sokal],l=[o.U.HAMMING,o.U.LEVENSHTEIN,o.U.MONOMER_CHEMICAL_DISTANCE];function h(t,e){const s=t.trueCount()+e.trueCount();if(0==s)return 1;const i=t.andWithCountBits(e,!0);return i/(s-i)}function c(t,e){return M(h(t,e))}function u(t,e){return M(h(new i.Z(t,32*t.length),new i.Z(e,32*e.length)))}function m(t,e){return M(function(t,e){const s=t.trueCount()+e.trueCount();return 0==s?0:2*t.andWithCountBits(e,!0)/s}(t,e))}function d(t,e){return M(function(t,e){const s=t.trueCount()*e.trueCount();return 0==s?0:t.andWithCountBits(e,!0)/Math.sqrt(s)}(t,e))}function g(t,e){return Math.sqrt(t.trueCount()+e.trueCount()-2*t.andWithCountBits(e,!0))}function p(t,e){return t.trueCount()+e.trueCount()-2*t.andWithCountBits(e,!0)}function f(t,e){return M(function(t,e){const s=t.trueCount()+e.trueCount(),i=t.andWithCountBits(e,!0);return i/(2*s-3*i)}(t,e))}function y(t,e){return M(function(t,e){const s=t.trueCount()+e.trueCount(),i=t.trueCount()*e.trueCount();return 0==i?0:t.andWithCountBits(e,!0)*s/(2*i)}(t,e))}function b(t,e){return M(function(t,e){const s=t.trueCount()+e.trueCount(),i=t.trueCount()*e.trueCount();return 0==i?0:(t.andWithCountBits(e,!0)*s-i)/i}(t,e))}function w(t,e){return M(function(t,e){const s=Math.min(t.trueCount(),e.trueCount());return 0==s?0:t.andWithCountBits(e,!0)/s}(t,e))}function C(t,e){return M(function(t,e){const s=Math.max(t.trueCount(),e.trueCount());return 0==s?0:t.andWithCountBits(e,!0)/s}(t,e))}function v(t,e){return M(function(t,e){return 0==t.length?0:t.andWithCountBits(e,!0)/t.length}(t,e))}function S(t,e){return M(function(t,e){const s=t.andWithCountBits(e,!0),i=t.countBits(!0)+e.countBits(!0),n=t.length,o=n-i+s;return s==n||o==n?1:s/i+o/(2*n-i)}(t,e))}function T(t){return 1/(1+t)}function M(t){return 0===t?3402823e32:1/t-1}function A(t,e){return Math.abs(t-e)}},779:(t,e,s)=>{"use strict";function i(t={}){const e=function(){if(!t||!t.scoringMatrix||!t.alphabetIndexes)return(t,e)=>t===e?0:1;if(t.scoringMatrix.length!==Object.keys(t.alphabetIndexes).length)throw new Error("Scoring matrix and alphabet indexes should have the same length");const e=t.alphabetIndexes,s=t.scoringMatrix,i=Math.min(...Object.keys(e).map((t=>t.charCodeAt(0))))+1,n=new Float32Array((s.length+i)*(s.length+i));return Object.entries(e).forEach((([t,i])=>{const o=s[i];Object.entries(e).forEach((([e,i])=>{n[t.charCodeAt(0)*s.length+e.charCodeAt(0)]=o[i]}))})),(t,e)=>n[t.charCodeAt(0)*s.length+e.charCodeAt(0)]}();return(t,s)=>{let i=0;const n=t.length,o=s.length;n!==o&&(i=Math.abs(n-o));let r=0;for(let i=0;i<Math.min(n,o);i++)t[i]!==s[i]&&(r+=e(t[i],s[i]));return r+=i,r/=Math.max(n,o),r}}s.d(e,{j:()=>i})},489:(t,e,s)=>{"use strict";s.d(e,{U:()=>i.U,o:()=>i.o});var i=s(5540)},458:(t,e,s)=>{"use strict";s.d(e,{r:()=>n});var i=s(1811);function n(){return(t,e)=>(0,i.T)(t,e)/Math.max(t.length,e.length)}},5540:(t,e,s)=>{"use strict";s.d(e,{U:()=>i,o:()=>a});var i,n=s(779),o=s(458),r=s(6683);!function(t){t.HAMMING="Hamming",t.LEVENSHTEIN="Levenshtein",t.NEEDLEMANN_WUNSCH="Needlemann-Wunsch",t.MONOMER_CHEMICAL_DISTANCE="Monomer chemical distance"}(i||(i={}));const a={[i.HAMMING]:n.j,[i.LEVENSHTEIN]:o.r,[i.NEEDLEMANN_WUNSCH]:r.n,[i.MONOMER_CHEMICAL_DISTANCE]:n.j}},6683:(t,e,s)=>{"use strict";s.d(e,{n:()=>n});const i={gapOpen:8,gapExtend:2,scoringMatrix:[[4,-1,-2,-2,0,-1,-1,0,-2,-1,-1,-1,-1,-2,-1,1,0,-3,-2,0,-2,-1,0,-4],[-1,5,0,-2,-3,1,0,-2,0,-3,-2,2,-1,-3,-2,-1,-1,-3,-2,-3,-1,0,-1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-3,-2,-3,-1,1,-4,-3,-2,11,2,-3,-4,-3,-2,-4],[-2,-2,-2,-3,-2,-1,-2,-3,2,-1,-1,-2,-1,3,-3,-2,-2,2,7,-1,-3,-2,-1,-4],[0,-3,-3,-3,-1,-2,-2,-3,-3,3,1,-2,1,-1,-2,-2,0,-3,-1,4,-3,-2,-1,-4],[-2,-1,3,4,-3,0,1,-1,0,-3,-4,0,-3,-3,-2,0,-1,-4,-3,-3,4,1,-1,-4],[-1,0,0,1,-3,3,4,-2,0,-3,-3,1,-1,-3,-1,0,-1,-3,-2,-2,1,4,-1,-4],[0,-1,-1,-1,-2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-2,0,0,-2,-1,-1,-1,-1,-1,-4],[-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,1]],alphabetIndexes:{A:0,R:1,N:2,D:3,C:4,Q:5,E:6,G:7,H:8,I:9,L:10,K:11,M:12,F:13,P:14,S:15,T:16,W:17,Y:18,V:19,B:20,Z:21,X:22,"*":23}};function n(t){return(e,s)=>{const{gapOpen:n,gapExtend:o,scoringMatrix:r,alphabetIndexes:a}={...i,...t},l=[new Array(e.length+1).fill(0),new Array(e.length+1).fill(0)],h=new Array(e.length+1).fill(!1),c=new Array(e.length+1).fill(!1);let u=0,m=1;for(let t=1;t<e.length+1;t++)l[0][t]=-n-(t-1)*o;for(let t=1;t<s.length+1;t++){l[m][0]=-n-(t-1)*o;for(let i=1;i<e.length+1;i++){const d=l[u][i-1]+r[a[e[i-1]]][a[s[t-1]]],g=l[u][i]-(h[i]?o:n),p=l[m][i-1]-(c[i-1]?o:n);l[m][i]=Math.max(d,p,g),l[m][i]===d?(h[i]=!1,c[i]=!1):l[m][i]===p?(h[i]=!1,c[i]=!0):(h[i]=!0,c[i]=!1)}u=m,m=(m+1)%2}const d=e.split("").map((t=>r[a[t]][a[t]])).reduce(((t,e)=>t+e),0),g=s.split("").map((t=>r[a[t]][a[t]])).reduce(((t,e)=>t+e),0),p=Math.max(d,g);return(p-l[u][e.length])/p}}},116:(t,e,s)=>{"use strict";var i;s.d(e,{AL:()=>i,aP:()=>o,bD:()=>n}),s(7659),s(3659),s(850),s(9006),s(7861),s(9657),s(1729),s(2669),s(3914),s(6254),s(2590),s(952),function(t){t.UMAP="UMAP",t.T_SNE="t-SNE"}(i||(i={}));class n{constructor(){this.learningRate={uiName:"Learinig rate",value:1,tooltip:"The initial learning rate for the embedding optimization"},this.nComponents={uiName:"Components",value:2,tooltip:"The number of components (dimensions) to project the data to"},this.nEpochs={uiName:"Epochs",value:0,tooltip:"The number of epochs to optimize embeddings via SGD. Computed automatically if set to 0"},this.nNeighbors={uiName:"Neighbors",value:15,tooltip:"The number of nearest neighbors to construct the fuzzy manifold"},this.spread={uiName:"Spread",value:1,tooltip:"The effective scale of embedded points, used with min distance to control the clumped/dispersed nature of the embedding"},this.minDist={uiName:"Min distance",value:.1,tooltip:"The effective minimum distance between embedded points, used with spread to control the clumped/dispersed nature of the embedding"}}}class o{constructor(){this.epsilon={uiName:"Epsilon",value:10,tooltip:"Epsilon is learning rate"},this.perplexity={uiName:"Perplexity",value:30,tooltip:"Roughly how many neighbors each point influences"},this.dim={uiName:"Dimensionality",value:2,tooltip:"Dimensionality of the embedding"}}}},9006:(t,e,s)=>{"use strict";s.d(e,{Ek:()=>l,a1:()=>a,nR:()=>h});var i=s(850),n=s(4588),o=s(6254),r=s(2669);class a{constructor(t){this.steps=t?.steps??0,this.cycles=t?.cycles??1e6,this.cutoff=t?.cutoff??0,this.lambda=t?.lambda??2,this.dlambda=t?.dlambda??.01,this.lambda2=this.lambda/2,this.dlambda2=this.dlambda/2,this.epsilon=t?.epsilon??1e-10,this.distanceFunction=t?.distance??i.dP,this.distance=new Float32Array,this.distanceFunctionName=t?.distanceFunctionName}async initDistance(t){this.dmIndexFunct=(0,o.y)(t.length);const e=new r.m(!0,!1);this.distance=await e.calc(t,this.distanceFunctionName),e.terminate()}calcDistance(t,e,s){return this.distance[this.dmIndexFunct(e,s)]}async embed(t){const e=t.length,s=(0,i.kO)(e,a.dimension,40);let o=this.lambda2;0===this.steps&&(this.steps=t.length-1),await this.initDistance(t);for(let r=0;r<this.cycles;++r){for(let r=0;r<this.steps;++r){const r=(0,n.I)(e);let a=(0,n.I)(e);for(;r==a;)a=(0,n.I)(e);const l=s[r],h=s[a],c=this.calcDistance(t,r,a),u=(0,i.dP)(l,h);if(0==this.cutoff||c<=this.cutoff||u<c){const t=o*(c-u)/(u+this.epsilon),e=(0,i.On)(l,h,-1);s[r]=(0,i.On)(l,e,t),s[a]=(0,i.On)(h,e,-t)}}if(o-=this.dlambda2,o<=0)break}return s}}a.dimension=2;class l extends a{async embed(t){const e=t.length,s=(0,i.kO)(e,l.dimension,40);let o=this.lambda;await this.initDistance(t);for(let r=0;r<this.cycles;++r){const r=(0,n.I)(e),a=s[r];for(let n=0;n<e;++n){if(r==n)continue;const e=s[n],l=this.calcDistance(t,r,n),h=(0,i.dP)(a,e);if(0==this.cutoff||l<=this.cutoff||h<l){const t=o*(l-h)/(h+this.epsilon),r=(0,i.On)(a,e,-1);s[n]=(0,i.On)(e,r,-t)}}if(o-=this.dlambda,o<=0)break}return s}}class h extends a{constructor(t){super(t),this.cycles=t?.cycles??1e3,this.steps=t?.steps??1e5,this.radiusPercent=t?.radiusPercent??1,this.maxDistance=t?.maxDistance??null,this.maxDistanceSteps=t?.maxDistanceSteps??null}async embed(t){const e=t.length,s=(0,i.kO)(e,h.dimension,40);if(await this.initDistance(t),null===this.maxDistanceSteps&&(this.maxDistanceSteps=e*Math.floor((e-1)/2)),null===this.maxDistance){this.maxDistance=-1e37;for(let s=0;s<this.maxDistanceSteps;s++){const s=(0,n.I)(e);let i=(0,n.I)(e);for(;s==i;)i=(0,n.I)(e);const o=this.calcDistance(t,s,i);o>this.maxDistance&&(this.maxDistance=o)}}let o=this.lambda;const r=0==this.radiusPercent?this.maxDistance:this.maxDistance*this.radiusPercent;for(let a=0;a<this.cycles;++a){for(let a=0;a<this.steps;++a){const a=(0,n.I)(e);let l=(0,n.I)(e);for(;a==l;)l=(0,n.I)(e);const h=s[a],c=s[l],u=this.calcDistance(t,a,l),m=(0,i.dP)(h,c);if(u<=r||m<u){const t=.5*o*(u-m)/(m+this.epsilon),e=(0,i.On)(h,c,-1);s[a]=(0,i.On)(h,e,t),s[l]=(0,i.On)(c,e,-t)}}if(o-=(this.lambda-this.dlambda)/(this.cycles-1),o<this.dlambda)break}return s}}},1040:(t,e,s)=>{"use strict";var i,n,o,r,a,l;s.d(e,{CF:()=>n,Qe:()=>a,W:()=>i,Yc:()=>l,gd:()=>r,gk:()=>o}),function(t){t.Levenshtein="Levenshtein",t.JaroWinkler="Jaro-Winkler",t.Manhattan="Manhattan"}(i||(i={})),function(t){t.Euclidean="Euclidean"}(n||(n={})),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"}(o||(o={})),function(t){t.TanimotoIntArray="TanimotoIntArray"}(r||(r={})),function(t){t.Vector="Vector",t.String="String",t.BitArray="BitArray",t.MacroMolecule="MacroMolecule",t.Number="Number",t.IntArray="IntArray"}(a||(a={})),function(t){t.NumericDistance="NumericDistance"}(l||(l={}))},6361:(t,e,s)=>{"use strict";s.d(e,{W:()=>i.W,gk:()=>i.gk});var i=s(1040);s(7861)},7861:(t,e,s)=>{"use strict";var i=s(1811),n=s(3979),o=s(5697),r=s(850),a=s(489),l=s(1040);const h={[l.CF.Euclidean]:r.dP},c={[l.W.Levenshtein]:i.T,[l.W.JaroWinkler]:n.H$,[l.W.Manhattan]:function(t,e){if(t.length!==e.length)return 1;{let s=0;for(let i=1;i<t.length;i++)s+=t[i]==e[i]?0:1;return s/t.length}}},u={[l.gk.Tanimoto]:o.KR,[l.gk.Dice]:o._h,[l.gk.Asymmetric]:o.yU,[l.gk.BraunBlanquet]:o.Dz,[l.gk.Cosine]:o.Zd,[l.gk.Kulczynski]:o.s,[l.gk.McConnaughey]:o.aW,[l.gk.RogotGoldberg]:o.MI,[l.gk.Russel]:o.fX,[l.gk.Sokal]:o.NB,[l.gk.Hamming]:o.UX,[l.gk.Euclidean]:o.WI},m={[l.gd.TanimotoIntArray]:o.FV},d={[l.Yc.NumericDistance]:o.bX},g={[l.Qe.Vector]:{[l.CF.Euclidean]:h[l.CF.Euclidean]},[l.Qe.String]:{[l.W.Levenshtein]:c[l.W.Levenshtein],[l.W.JaroWinkler]:c[l.W.JaroWinkler],[l.W.Manhattan]:c[l.W.Manhattan]},[l.Qe.BitArray]:{[l.gk.Tanimoto]:u[l.gk.Tanimoto],[l.gk.Dice]:u[l.gk.Dice],[l.gk.Asymmetric]:u[l.gk.Asymmetric],[l.gk.BraunBlanquet]:u[l.gk.BraunBlanquet],[l.gk.Cosine]:u[l.gk.Cosine],[l.gk.Kulczynski]:u[l.gk.Kulczynski],[l.gk.McConnaughey]:u[l.gk.McConnaughey],[l.gk.RogotGoldberg]:u[l.gk.RogotGoldberg],[l.gk.Russel]:u[l.gk.Russel],[l.gk.Sokal]:u[l.gk.Sokal]},[l.Qe.MacroMolecule]:{[a.U.HAMMING]:a.o[a.U.HAMMING],[a.U.LEVENSHTEIN]:a.o[a.U.LEVENSHTEIN],[a.U.NEEDLEMANN_WUNSCH]:a.o[a.U.NEEDLEMANN_WUNSCH],[a.U.MONOMER_CHEMICAL_DISTANCE]:a.o[a.U.MONOMER_CHEMICAL_DISTANCE]},[l.Qe.Number]:{[l.Yc.NumericDistance]:d[l.Yc.NumericDistance]},[l.Qe.IntArray]:{[l.gd.TanimotoIntArray]:m[l.gd.TanimotoIntArray]}};Object.keys(g).reduce(((t,e)=>{for(const s of Object.keys(g[e]))t[s]=e;return t}),{})},6490:(t,e,s)=>{"use strict";s.d(e,{M6:()=>o,SB:()=>l,Sr:()=>a,VA:()=>n,XV:()=>r,oi:()=>h,w5:()=>u});var i=s(9533);function n(t,e){const s=s=>i.cS(t).map((()=>i.VI(e,s))),n=[];return n.push(s(-1)),n.push(s(1/0)),n.push(s(0)),n}function o(t,e,s){const n=i.ll(t);for(let o=0;o<t;o++){let t=!0,r=0;for(;t;){r=i.AH(e,s);let a=!1;for(let t=0;t<o;t++)if(r===n[t]){a=!0;break}a||(t=!1)}n[o]=r}return n}function r(t,e,s,i,n){e=Math.floor(e);const o=t[0][e],r=t[1][e];if(t[2][e],s>=r[0])return 0;for(let t=0;t<o.length;t++)if(i===o[t])return 0;return a(t,e,s,i,n)}function a(t,e,s,i,n){const o=t[0][e],r=t[1][e],a=t[2][e];if(s>=r[0])return 0;r[0]=s,o[0]=i,a[0]=n;let l=0,h=0;for(;;){const e=2*l+1,i=e+1,n=t[0][0].length;if(e>=n)break;if(i>=n){if(!(r[e]>s))break;h=e}else if(r[e]>=r[i]){if(!(s<r[e]))break;h=e}else{if(!(s<r[i]))break;h=i}r[l]=r[h],o[l]=o[h],a[l]=a[h],l=h}return r[l]=s,o[l]=i,a[l]=n,1}function l(t,e,s,o,a){const l=n(e,o);for(let n=0;n<e;n++)for(let e=0;e<s;e++){if(t[0][n][e]<0)continue;const s=t[0][n][e],o=t[2][n][e],h=i.mH(a);r(l,n,h,s,o),r(l,s,h,n,o),t[2][n][e]=0}return l}function h(t){const e=t[0],s=t[1];for(let t=0;t<e.length;t++){const i=e[t],n=s[t];for(let t=0;t<i.length-1;t++){const e=i.length-t-1,s=n.length-t-1,o=i[0];i[0]=i[e],i[e]=o;const r=n[0];n[0]=n[s],n[s]=r,c(n,i,s,0)}}return{indices:e,weights:s}}function c(t,e,s,i){for(;2*i+1<s;){const n=2*i+1,o=n+1;let r=i;if(t[r]<t[n]&&(r=n),o<s&&t[r]<t[o]&&(r=o),r===i)break;{const s=t[i];t[i]=t[r],t[r]=s;const n=e[i];e[i]=e[r],e[r]=n,i=r}}}function u(t,e){const s=t[0][e],i=t[1][e],n=t[2][e];let o=1/0,r=-1;for(let t=0;t>s.length;t++)1===n[t]&&i[t]<o&&(o=i[t],r=t);return r>=0?(n[r]=0,Math.floor(s[r])):-1}},1729:(t,e,s)=>{"use strict";s.d(e,{u:()=>i.uB});var i=s(3585)},952:(t,e,s)=>{"use strict";function i(t,e,s,i,n){function o(t,e,s,i){if(s>t[t.length-1])return;let n=t.length-2;for(n=t.length-2;n>=0&&!(s>t[n]);n--);t.splice(t.length-1,1),t.splice(n+1,0,s),e.splice(e.length-1,1),e.splice(n+1,0,i)}console.time("knnGraph");const r=new Array(n).fill(null).map((()=>new Array(i).fill(1))),a=new Array(n).fill(null).map((()=>new Array(i).fill(1)));for(let i=0;i<t.length;i++)o(a[t[i]],r[t[i]],s[i],e[i]),o(a[e[i]],r[e[i]],s[i],t[i]);return console.timeEnd("knnGraph"),{knnIndexes:r,knnDistances:a}}s.d(e,{J:()=>i})},6802:(t,e,s)=>{"use strict";s.d(e,{$X:()=>l,A7:()=>n,Fv:()=>m,Hp:()=>p,IH:()=>a,NT:()=>r,RH:()=>u,cf:()=>c,gW:()=>h,p4:()=>o});var i=s(9533);class n{constructor(t,e,s,i){if(this.entries=new Map,this.nRows=0,this.nCols=0,t.length!==e.length||t.length!==s.length)throw new Error("rows, cols and values arrays must all have the same length");this.nRows=i[0],this.nCols=i[1];for(let i=0;i<s.length;i++){const n=t[i],o=e[i];this.checkDims(n,o);const r=this.makeKey(n,o);this.entries.set(r,{value:s[i],row:n,col:o})}}makeKey(t,e){return`${t}:${e}`}checkDims(t,e){if(!(t<this.nRows&&e<this.nCols))throw new Error("row and/or col specified outside of matrix dimensions")}set(t,e,s){this.checkDims(t,e);const i=this.makeKey(t,e);this.entries.has(i)?this.entries.get(i).value=s:this.entries.set(i,{value:s,row:t,col:e})}get(t,e,s=0){const i=this.makeKey(t,e);return this.entries.has(i)?this.entries.get(i).value:s}getAll(t=!0){const e=new Array(this.entries.size).fill(null);let s=0;return this.entries.forEach((t=>{e[s++]=t})),t&&e.sort(((t,e)=>t.row===e.row?t.col-e.col:t.row-e.row)),e}getDims(){return[this.nRows,this.nCols]}getRows(){return Array.from(this.entries,(([t,e])=>e.row))}getCols(){return Array.from(this.entries,(([t,e])=>e.col))}getValues(){return Array.from(this.entries,(([t,e])=>e.value))}forEach(t){this.entries.forEach((e=>t(e.value,e.row,e.col)))}map(t){const e=new Float32Array(this.entries.size);let s=0;this.entries.forEach((i=>{e[s++]=t(i.value,i.row,i.col)}));const i=[this.nRows,this.nCols];return new n(this.getRows(),this.getCols(),e,i)}toArray(){const t=i.cS(this.nRows).map((()=>i.ll(this.nCols)));return this.entries.forEach((e=>{t[e.row][e.col]=e.value})),t}}function o(t){const e=t.getRows(),s=t.getCols(),i=t.getValues(),o=s.length,r=new Int32Array(o),a=new Int32Array(o),l=new Float32Array(o);r.set(e),a.set(s),l.set(i);const h=[t.nCols,t.nRows];return new n(a,r,l,h)}function r(t,e){return g(t,e,((t,e)=>t*e))}function a(t,e){return g(t,e,((t,e)=>t+e))}function l(t,e){return g(t,e,((t,e)=>t-e))}function h(t,e){return g(t,e,((t,e)=>t>e?t:e))}function c(t,e){return t.map((t=>t*e))}function u(t){const e=new Set,s=t.getValues(),i=t.getRows(),o=t.getCols();for(let t=0;t<s.length;t++)0===s[t]&&e.add(t);const r=(t,s)=>!e.has(s),a=s.filter(r),l=i.filter(r),h=o.filter(r);return new n(l,h,a,t.getDims())}function m(t,e="l2"){const s=d[e],i=new Map;t.forEach(((t,e,s)=>{const n=i.get(e)||[];n.push(s),i.set(e,n)}));const o=new n([],[],[],t.getDims());for(let e of i.keys()){const n=i.get(e).sort(),r=s(n.map((s=>t.get(e,s))));for(let t=0;t<r.length;t++)o.set(e,n[t],r[t])}return o}const d={max:t=>{let e=-1/0;for(let s=0;s<t.length;s++)e=t[s]>e?t[s]:e;return t.map((t=>t/e))},l1:t=>{let e=0;for(let s=0;s<t.length;s++)e+=t[s];return t.map((t=>t/e))},l2:t=>{let e=0;for(let s=0;s<t.length;s++)e+=t[s]**2;return t.map((t=>Math.sqrt(t**2/e)))}};function g(t,e,s){const i=new Set,o=[],r=[],a=[],l=(i,n)=>{o.push(i),r.push(n);const l=s(t.get(i,n),e.get(i,n));a.push(l)},h=t.getValues(),c=t.getRows(),u=t.getCols();for(let t=0;t<h.length;t++){const e=c[t],s=u[t],n=`${e}:${s}`;i.add(n),l(e,s)}const m=e.getValues(),d=e.getRows(),g=e.getCols();for(let t=0;t<m.length;t++){const e=d[t],s=g[t],n=`${e}:${s}`;i.has(n)||l(e,s)}const p=[t.nRows,t.nCols];return new n(o,r,a,p)}function p(t){const e=[];t.forEach(((t,s,i)=>{e.push({value:t,row:s,col:i})})),e.sort(((t,e)=>t.row===e.row?t.col-e.col:t.row-e.row));const s=[],i=[],n=[];let o=-1;for(let t=0;t<e.length;t++){const{row:r,col:a,value:l}=e[t];r!==o&&(o=r,n.push(t)),s.push(a),i.push(l)}return{indices:s,values:i,indptr:n}}},1595:(t,e,s)=>{"use strict";s.d(e,{WX:()=>a,gK:()=>c,n_:()=>h,vF:()=>l});var i=s(6490),n=s(6802),o=s(4972),r=s(9533);function a(t,e){return function(s,n,o,a=10,l=50,h=.001,c=.5,u=!0){const m=s.length,d=i.VA(s.length,o);for(let n=0;n<s.length;n++){const r=i.M6(o,s.length,e);for(let e=0;e<r.length;e++){const o=t(s[n],s[r[e]]);i.XV(d,n,o,r[e],1),i.XV(d,r[e],o,n,1)}}if(u)for(let e=0;e<n.length;e++)for(let o=0;o<n[e].length&&!(n[e][o]<0);o++)for(let r=o+1;r<n[e].length&&!(n[e][r]<0);r++){const a=t(s[n[e][o]],s[n[e][r]]);i.XV(d,n[e][o],a,n[e][r],1),i.XV(d,n[e][r],a,n[e][o],1)}for(let n=0;n<a;n++){const n=i.SB(d,m,o,l,e);let a=0;for(let o=0;o<m;o++)for(let h=0;h<l;h++){let u=Math.floor(n[0][o][h]);if(!(u<0||r.mH(e)<c))for(let e=0;e<l;e++){const r=Math.floor(n[0][o][e]),l=n[2][o][h],c=n[2][o][e];if(r<0||!l&&!c)continue;const m=t(s[u],s[r]);a+=i.XV(d,u,m,r,1),a+=i.XV(d,r,m,u,1)}}if(a<=h*o*s.length)break}return i.oi(d)}}function l(t){return{initFromRandom:function(e,s,n,o,a){for(let l=0;l<n.length;l++){const h=r.M6(e,s.length,a);for(let e=0;e<h.length;e++){if(h[e]<0)continue;const r=t(s[h[e]],n[l]);i.XV(o,l,r,h[e],1)}}},initFromTree:function(e,s,n,r,a){for(let l=0;l<n.length;l++){const h=o.ii(n[l],e,a);for(let e=0;e<h.length;e++){if(h[e]<0)return;const o=t(s[h[e]],n[l]);i.XV(r,l,o,h[e],1)}}}}}function h(t){return function(e,s,o,r){const{indices:a,indptr:l}=n.Hp(s);for(let s=0;s<r.length;s++){const n=new Set(o[0][s]);for(;;){const h=i.w5(o,s);if(-1===h)break;const c=a.slice(l[h],l[h+1]);for(const a of c){if(a===h||-1===a||n.has(a))continue;const l=t(e[a],r[s]);i.Sr(o,s,l,a,1),n.add(a)}}}return o}}function c(t,e,s,n,o,r,a){const l=i.VA(s.length,n);if(o(n,e,s,l,a),t)for(let i of t)r(i,e,s,l,a);return l}},4972:(t,e,s)=>{"use strict";s.d(e,{HO:()=>c,Zv:()=>o,ii:()=>m});var i=s(9533);class n{constructor(t,e,s,i){this.hyperplanes=t,this.offsets=e,this.children=s,this.indices=i}}function o(t,e,s,o){const c=Math.max(10,e),u=i.w6(s).map(((e,s)=>function(t,e=30,s,n){return r(t,i.w6(t.length),e,s,n)}(t,c,s,o))),m=u.map((t=>function(t,e){const s=l(t),o=h(t),r=i.w6(s).map((()=>t.hyperplane?1:0)),c=i.ll(s),u=i.w6(s).map((()=>[-1,-1])),m=i.w6(o).map((()=>i.w6(e).map((()=>-1))));return a(t,r,c,u,m,0,0),new n(r,c,u,m)}(t,c)));return m}function r(t,e,s=30,n,o){if(e.length>s){const a=function(t,e,s){let n=i.AH(e.length,s),o=i.AH(e.length,s);o+=n===o?1:0,o%=e.length;const r=e[n],a=e[o];let l=0,h=0;h=t[r]-t[a],l-=h*(t[r]+t[a])/2;let c=0,u=0;const m=i.ll(e.length);for(let n=0;n<e.length;n++){let o=l;o+=h*t[e[n]],0===o?(m[n]=i.AH(2,s),0===m[n]?c+=1:u+=1):o>0?(m[n]=0,c+=1):(m[n]=1,u+=1)}const d=i.ll(c),g=i.ll(u);c=0,u=0;for(let t=0;t<m.length;t++)0===m[t]?(d[c]=e[t],c+=1):(g[u]=e[t],u+=1);return{indicesLeft:d,indicesRight:g,hyperplane:h,offset:l}}(t,e,o),{indicesLeft:l,indicesRight:h,hyperplane:c,offset:u}=a;return{leftChild:r(t,l,s,n+1,o),rightChild:r(t,h,s,n+1,o),isLeaf:!1,hyperplane:c,offset:u}}return{indices:e,isLeaf:!0}}function a(t,e,s,i,n,o,r){if(t.isLeaf)return i[o][0]=-r,n[r].splice(0,t.indices.length,...t.indices),{nodeNum:o,leafNum:r+=1};{e[o]=t.hyperplane,s[o]=t.offset,i[o][0]=o+1;const l=o;let h=a(t.leftChild,e,s,i,n,o+1,r);return o=h.nodeNum,r=h.leafNum,i[l][1]=o+1,h=a(t.rightChild,e,s,i,n,o+1,r),{nodeNum:h.nodeNum,leafNum:h.leafNum}}}function l(t){return t.isLeaf?1:1+l(t.leftChild)+l(t.rightChild)}function h(t){return t.isLeaf?1:h(t.leftChild)+h(t.rightChild)}function c(t){if(t.length>0){const e=[];for(let s of t)e.push(...s.indices);return e}return[[-1]]}function u(t,e,s,n){let o=e;return o+=t*s,0===o?i.AH(2,n):o>0?0:1}function m(t,e,s){let i=0;for(;e.children[i][0]>0;)i=0===u(e.hyperplanes[i],e.offsets[i],t,s)?e.children[i][0]:e.children[i][1];const n=-1*e.children[i][0];return e.indices[n]}},3585:(t,e,s)=>{"use strict";s.d(e,{uB:()=>u});var i=s(6490),n=s(6802),o=s(1595),r=s(4972),a=s(9533),l=s(3107);const h=1e-5,c=.001;class u{get neighbors(){return this.nNeighbors}constructor(t={}){this.learningRate=1,this.localConnectivity=1,this.minDist=.1,this.nComponents=2,this.nEpochs=0,this.nNeighbors=15,this.negativeSampleRate=5,this.random=Math.random,this.repulsionStrength=1,this.setOpMixRatio=1,this.spread=1,this.transformQueueSize=4,this.targetMetric="categorical",this.targetWeight=.5,this.targetNNeighbors=this.nNeighbors,this.distanceFn=m,this.isInitialized=!1,this.rpForest=[],this.embedding=[],this.optimizationState=new d;const e=e=>{void 0!==t[e]&&(this[e]=t[e])};e("distanceFn"),e("learningRate"),e("localConnectivity"),e("minDist"),e("nComponents"),e("nEpochs"),e("nNeighbors"),e("negativeSampleRate"),e("random"),e("repulsionStrength"),e("setOpMixRatio"),e("spread"),e("transformQueueSize")}fit(t){return this.initializeFit(t),this.optimizeLayout(),this.embedding}async fitAsync(t,e=(()=>!0)){return this.initializeFit(t),await this.optimizeLayoutAsync(e),this.embedding}setSupervisedProjection(t,e={}){this.Y=t,this.targetMetric=e.targetMetric||this.targetMetric,this.targetWeight=e.targetWeight||this.targetWeight,this.targetNNeighbors=e.targetNNeighbors||this.targetNNeighbors}setPrecomputedKNN(t,e){this.knnIndices=t,this.knnDistances=e}initializeFit(t){if(t.length<=this.nNeighbors)throw new Error(`Not enough data points (${t.length}) to create nNeighbors: ${this.nNeighbors}. Add more data points or adjust the configuration.`);if(this.X===t&&this.isInitialized)return this.getNEpochs();if(this.X=t,!this.knnIndices&&!this.knnDistances){const e=this.nearestNeighbors(t);this.knnIndices=e.knnIndices,this.knnDistances=e.knnDistances}this.graph=this.fuzzySimplicialSet(t,this.nNeighbors,this.setOpMixRatio),this.makeSearchFns(),this.searchGraph=this.makeSearchGraph(t),this.processGraphForSupervisedProjection();const{head:e,tail:s,epochsPerSample:i}=this.initializeSimplicialSetEmbedding();return this.optimizationState.head=e,this.optimizationState.tail=s,this.optimizationState.epochsPerSample=i,this.initializeOptimization(),this.prepareForOptimizationLoop(),this.isInitialized=!0,this.getNEpochs()}makeSearchFns(){const{initFromTree:t,initFromRandom:e}=o.vF(this.distanceFn);this.initFromTree=t,this.initFromRandom=e,this.search=o.n_(this.distanceFn)}makeSearchGraph(t){const e=this.knnIndices,s=this.knnDistances,i=[t.length,t.length],o=new n.A7([],[],[],i);for(let t=0;t<e.length;t++){const i=e[t],n=s[t];for(let e=0;e<i.length;e++){const s=i[e],r=n[e];r>0&&o.set(t,s,r)}}const r=n.p4(o);return n.gW(o,r)}transform(t){const e=this.X;if(void 0===e||0===e.length)throw new Error("No data has been fit.");let s=Math.floor(this.nNeighbors*this.transformQueueSize);s=Math.min(e.length,s);const r=o.gK(this.rpForest,e,t,s,this.initFromRandom,this.initFromTree,this.random),l=this.search(e,this.searchGraph,r,t);let{indices:h,weights:c}=i.oi(l);h=h.map((t=>t.slice(0,this.nNeighbors))),c=c.map((t=>t.slice(0,this.nNeighbors)));const u=Math.max(0,this.localConnectivity-1),{sigmas:m,rhos:d}=this.smoothKNNDistance(c,this.nNeighbors,u),{rows:g,cols:p,vals:f}=this.computeMembershipStrengths(h,c,m,d),y=[t.length,e.length];let b=new n.A7(g,p,f,y);const w=n.Fv(b,"l1"),C=n.Hp(w),v=t.length,S=function(t,e,s){const i=a.ll(t.length).map((t=>a.ll(s[0].length)));for(let n=0;n<t.length;n++)for(let o=0;o<t[0].length;o++)for(let r=0;r<s[0].length;r++){const a=t[n][o];i[n][r]+=e[n][o]*s[a][r]}return i}(a.HU(C.indices,v,this.nNeighbors),a.HU(C.values,v,this.nNeighbors),this.embedding),T=this.nEpochs?this.nEpochs/3:b.nRows<=1e4?100:30,M=b.getValues().reduce(((t,e)=>e>t?e:t),0);b=b.map((t=>t<M/T?0:t)),b=n.RH(b);const A=this.makeEpochsPerSample(b.getValues(),T),E=b.getRows(),x=b.getCols();return this.assignOptimizationStateParameters({headEmbedding:S,tailEmbedding:this.embedding,head:E,tail:x,currentEpoch:0,nEpochs:T,nVertices:b.getDims()[1],epochsPerSample:A}),this.prepareForOptimizationLoop(),this.optimizeLayout()}processGraphForSupervisedProjection(){const{Y:t,X:e}=this;if(t){if(t.length!==e.length)throw new Error("Length of X and y must be equal");if("categorical"===this.targetMetric){const e=this.targetWeight<1?1/(1-this.targetWeight)*2.5:1e12;this.graph=this.categoricalSimplicialSetIntersection(this.graph,t,e)}}}step(){const{currentEpoch:t}=this.optimizationState;return t<this.getNEpochs()&&this.optimizeLayoutStep(t),this.optimizationState.currentEpoch}getEmbedding(){return this.embedding}nearestNeighbors(t){const{distanceFn:e,nNeighbors:s}=this,i=o.WX(e,this.random),n=5+Math.floor(.5==(a=t.length**.5/20)?0:Math.round(a));var a;const l=Math.max(5,Math.floor(Math.round((t=>Math.log(t)/Math.log(2))(t.length))));this.rpForest=r.Zv(t,s,n,this.random);const h=r.HO(this.rpForest),{indices:c,weights:u}=i(t,h,s,l);return{knnIndices:c,knnDistances:u}}fuzzySimplicialSet(t,e,s=1){const{knnIndices:i=[],knnDistances:o=[],localConnectivity:r}=this,{sigmas:a,rhos:l}=this.smoothKNNDistance(o,e,r),{rows:h,cols:c,vals:u}=this.computeMembershipStrengths(i,o,a,l),m=[t.length,t.length],d=new n.A7(h,c,u,m),g=n.p4(d),p=n.NT(d,g),f=n.$X(n.IH(d,g),p),y=n.cf(f,s),b=n.cf(p,1-s);return n.IH(y,b)}categoricalSimplicialSetIntersection(t,e,s,i=1){let o=function(t,e,s=1,i=5){return t.map(((t,n,o)=>-1===e[n]||-1===e[o]?t*Math.exp(-s):e[n]!==e[o]?t*Math.exp(-i):t))}(t,e,i,s);return o=n.RH(o),function(t){t=n.Fv(t,"max");const e=n.p4(t),s=n.NT(e,t);return t=n.IH(t,n.$X(e,s)),n.RH(t)}(o)}smoothKNNDistance(t,e,s=1,i=64,n=1){const o=Math.log(e)/Math.log(2)*n,r=a.ll(t.length),l=a.ll(t.length);for(let e=0;e<t.length;e++){let n=0,u=1/0,m=1;const d=t[e],g=d.filter((t=>t>0));if(g.length>=s){let t=Math.floor(s),i=s-t;t>0?(r[e]=g[t-1],i>h&&(r[e]+=i*(g[t]-g[t-1]))):r[e]=i*g[0]}else g.length>0&&(r[e]=a.Fp(g));for(let s=0;s<i;s++){let s=0;for(let i=1;i<t[e].length;i++){const n=t[e][i]-r[e];s+=n>0?Math.exp(-n/m):1}if(Math.abs(s-o)<h)break;s>o?(u=m,m=(n+u)/2):(n=m,u===1/0?m*=2:m=(n+u)/2)}if(l[e]=m,r[e]>0){const t=a.J6(d);l[e]<c*t&&(l[e]=c*t)}else{const s=a.J6(t.map(a.J6));l[e]<c*s&&(l[e]=c*s)}}return{sigmas:l,rhos:r}}computeMembershipStrengths(t,e,s,i){const n=t.length,o=t[0].length,r=a.ll(n*o),l=a.ll(n*o),h=a.ll(n*o);for(let a=0;a<n;a++)for(let n=0;n<o;n++){let c=0;-1!==t[a][n]&&(c=t[a][n]===a?0:e[a][n]-i[a]<=0?1:Math.exp(-(e[a][n]-i[a])/s[a]),r[a*o+n]=a,l[a*o+n]=t[a][n],h[a*o+n]=c)}return{rows:r,cols:l,vals:h}}initializeSimplicialSetEmbedding(){const t=this.getNEpochs(),{nComponents:e}=this,s=this.graph.getValues();let i=0;for(let t=0;t<s.length;t++){const e=s[t];i<s[t]&&(i=e)}const n=this.graph.map((e=>e<i/t?0:e));this.embedding=a.ll(n.nRows).map((()=>a.ll(e).map((()=>20*a.mH(this.random)-10))));const o=[],r=[],l=[],h=n.getAll();for(let t=0;t<h.length;t++){const e=h[t];e.value&&(o.push(e.value),l.push(e.row),r.push(e.col))}return{head:r,tail:l,epochsPerSample:this.makeEpochsPerSample(o,t)}}makeEpochsPerSample(t,e){const s=a.VI(t.length,-1),i=a.Fp(t),n=t.map((t=>t/i*e));return n.forEach(((t,i)=>{t>0&&(s[i]=e/n[i])})),s}assignOptimizationStateParameters(t){Object.assign(this.optimizationState,t)}prepareForOptimizationLoop(){const{repulsionStrength:t,learningRate:e,negativeSampleRate:s}=this,{epochsPerSample:i,headEmbedding:n,tailEmbedding:o}=this.optimizationState,r=n[0].length,a=n.length===o.length,l=i.map((t=>t/s)),h=[...l],c=[...i];this.assignOptimizationStateParameters({epochOfNextSample:c,epochOfNextNegativeSample:h,epochsPerNegativeSample:l,moveOther:a,initialAlpha:e,alpha:e,gamma:t,dim:r})}initializeOptimization(){const t=this.embedding,e=this.embedding,{head:s,tail:i,epochsPerSample:n}=this.optimizationState,o=this.getNEpochs(),r=this.graph.nCols,{a:h,b:c}=function(t,e){const s=a.GE(0,3*t,300).map((t=>t<e?1:t)),i=a.ll(s.length).map(((i,n)=>s[n]>=e?Math.exp(-(s[n]-e)/t):i)),n={x:s,y:i},{parameterValues:o}=(0,l.Z)(n,(([t,e])=>s=>1/(1+t*s**(2*e))),{damping:1.5,initialValues:[.5,.5],gradientDifference:.1,maxIterations:100,errorTolerance:.01}),[r,h]=o;return{a:r,b:h}}(this.spread,this.minDist);this.assignOptimizationStateParameters({headEmbedding:t,tailEmbedding:e,head:s,tail:i,epochsPerSample:n,a:h,b:c,nEpochs:o,nVertices:r})}optimizeLayoutStep(t){const{optimizationState:e}=this,{head:s,tail:i,headEmbedding:n,tailEmbedding:o,epochsPerSample:r,epochOfNextSample:l,epochOfNextNegativeSample:h,epochsPerNegativeSample:c,moveOther:u,initialAlpha:m,alpha:d,gamma:f,a:y,b,dim:w,nEpochs:C,nVertices:v}=e;for(let e=0;e<r.length;e++){if(l[e]>t)continue;const m=s[e],C=i[e],S=n[m],T=o[C],M=p(S,T);let A=0;M>0&&(A=-2*y*b*Math.pow(M,b-1),A/=y*Math.pow(M,b)+1);for(let t=0;t<w;t++){const e=g(A*(S[t]-T[t]),4);S[t]+=e*d,u&&(T[t]+=-e*d)}l[e]+=r[e];const E=Math.floor((t-h[e])/c[e]);for(let t=0;t<E;t++){const t=a.AH(v,this.random),e=o[t],s=p(S,e);let i=0;if(s>0)i=2*f*b,i/=(.001+s)*(y*Math.pow(s,b)+1);else if(m===t)continue;for(let t=0;t<w;t++){let s=4;i>0&&(s=g(i*(S[t]-e[t]),4)),S[t]+=s*d}}h[e]+=E*c[e]}return e.alpha=m*(1-t/C),e.currentEpoch+=1,n}optimizeLayoutAsync(t=(()=>!0)){return new Promise(((e,s)=>{const i=async()=>{try{const{nEpochs:s,currentEpoch:n}=this.optimizationState;this.embedding=this.optimizeLayoutStep(n);const o=this.optimizationState.currentEpoch,r=!1===t(o),a=o===s;if(r||a)return e(a);setTimeout((()=>i()),0)}catch(t){s(t)}};setTimeout((()=>i()),0)}))}optimizeLayout(t=(()=>!0)){let e=!1,s=[];for(;!e;){const{nEpochs:i,currentEpoch:n}=this.optimizationState;s=this.optimizeLayoutStep(n);const o=this.optimizationState.currentEpoch,r=!1===t(o);e=o===i||r}return s}getNEpochs(){const t=this.graph;if(this.nEpochs>0)return this.nEpochs;if(!t)return 200;const e=t.nRows;return e<=2500?500:e<=5e3?400:e<=7500?300:200}}function m(t,e){return Math.abs(t-e)}class d{constructor(){this.currentEpoch=0,this.headEmbedding=[],this.tailEmbedding=[],this.head=[],this.tail=[],this.epochsPerSample=[],this.epochOfNextSample=[],this.epochOfNextNegativeSample=[],this.epochsPerNegativeSample=[],this.moveOther=!0,this.initialAlpha=1,this.alpha=1,this.gamma=1,this.a=1.5769434603113077,this.b=.8950608779109733,this.dim=2,this.nEpochs=500,this.nVertices=0}}function g(t,e){return t>e?e:t<-e?-e:t}function p(t,e){let s=0;for(let i=0;i<t.length;i++)s+=Math.pow(t[i]-e[i],2);return s}},9533:(t,e,s)=>{"use strict";function i(t,e){return Math.floor(e()*t)}function n(t){return t()}function o(t){const e=[];for(let s=0;s<t;s++)e.push(void 0);return e}function r(t){return o(t).map(((t,e)=>e))}function a(t,e){return o(t).map((()=>e))}function l(t){return a(t,0)}function h(t,e,s){return o(s).map(((i,n)=>t+n*((e-t)/(s-1))))}function c(t){return function(t){return t.reduce(((t,e)=>t+e))}(t)/t.length}function u(t){let e=0;for(let s=0;s<t.length;s++)e=t[s]>e?t[s]:e;return e}function m(t,e,s){const n=l(t);for(let o=0;o<t;o++){let t=!0;for(;t;){const r=i(e,s);let a=!1;for(let t=0;t<o;t++)if(r===n[t]){a=!0;break}a||(t=!1),n[o]=r}}return n}function d(t,e,s){const i=[];let n=0,o=0;if(t.length!==e*s)throw new Error("Array dimensions must match input length.");for(let r=0;r<e;r++){const e=[];for(let i=0;i<s;i++)e.push(t[o]),o+=1;i.push(e),n+=1}return i}s.d(e,{AH:()=>i,Fp:()=>u,GE:()=>h,HU:()=>d,J6:()=>c,M6:()=>m,VI:()=>a,cS:()=>o,ll:()=>l,mH:()=>n,w6:()=>r})},9657:(t,e,s)=>{"use strict";s.d(e,{Z:()=>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 s=t,n=i._createBuffer(s);if(e)for(let t=0;t<n.length;t++)n[t]=-1;this._data=n,this._length=s}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,s,i){if(t<e||t>s)throw new Error(`Argument ${i} (${t}) out of range (${e}, ${s})`)}copy(t,e,s){for(let i=0;i<s;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 s=new i(t._length);s._length=t._length,s._data=i._createBuffer(s._length),s._version=0;const n=t.lengthInInts;for(let i=0;i<n;i++)s._data[i]=t._data[i]&e._data[i];return s}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 s=0;s<e._length;s++)t[s]&&(e._data[Math.floor(s/32)]|=1<<(s%32&31));return e}static fromSeq(t,e){const s=new i(t);for(let i=0;i<t;++i)s.setBit(i,e(i));return s._version=0,s}static fromString(t){return i.fromSeq(t.length,(e=>"1"==t.charAt(e)))}static fromUint32Array(t,e){const s=new i(t);return s._data=e,s}static fromBytes(t){const e=t.length,s=new i(8*e);s._data=new Uint32Array(Math.floor((e+3)/4)),s._length=8*e;let n=0,o=0;for(;e-o>=4;)s._data[n++]=255&t[o]|(255&t[o+1])<<8|(255&t[o+2])<<16|(255&t[o+3])<<24,o+=4;return e-o==3&&(s._data[n]=(255&t[o+2])<<16),e-o==2&&(s._data[n]|=(255&t[o+1])<<8),e-o==1&&(s._data[n]|=255&t[o]),s._version=0,s}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 s=t?-1:0,i=this.lengthInInts;for(let t=0;t<i;t++)this._data[t]=s;this.incrementVersion(e)}setIndexes(t,e=!0,s=!0,i=!0){s&&this.setAll(!e,!1);for(const s of t)this.setFast(s,e);this.incrementVersion(i)}everyIndex(t,e=!0){for(const s of t)if(this.getBit(s)!=e)return!1;return!0}anyIndex(t,e=!0){for(const s of t)if(this.getBit(s)==e)return!0;return!1}setWhere(t,e=!0,s=!0,i=!0,n=!0){if(s&&n&&this.setAll(!e,!1),n)for(let s=0;s<this._length;s++)t(s)&&this.setFast(s,e);else for(let s=0;s<this._length;s++)this.setFast(s,t(s)?e:!e);this.incrementVersion(i)}getRange(t,e){this.assureInRange(t,0,this._length-1,"from"),this.assureInRange(e,0,this._length,"to");const s=[];for(let i=t;i<e;++i)s.push(this.getBit(i));return i.fromValues(s)}getRangeAsList(t,e){this.assureInRange(t,0,this._length-1,"from"),this.assureInRange(e,0,this._length,"to");const s=[];for(let i=t;i<e;++i)s.push(this.getBit(i));return s}setRange(t,e,s,i=!0){this.assureInRange(t,0,this._length-1,"from"),this.assureInRange(e,0,this._length-1,"to");const n=Math.min(t,e),o=Math.max(t,e);if(s)for(let t=n;t<=o;t++)this.setTrue(t);else for(let t=n;t<=o;t++)this.setFalse(t);return this.incrementVersion(i),this}setRandom(t,e,s=!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 s=0;s<t;){const t=Math.floor(Math.random()*this._length);this.getBit(t)!=e&&(this.setFast(t,e),s++)}this.incrementVersion(s)}and(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");for(let e=0,s=this.lengthInInts;e<s;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 s=this.lengthInInts;for(let e=0;e<s;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,s=this.lengthInInts;e<s;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,s=this.lengthInInts;e<s;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,s=this.lengthInInts;e<s;e++)this._data[e]^=t._data[e];return this.incrementVersion(e),this}insertAt(t,e,s=!1){if(this.assureInRange(t,0,this._length,"pos"),0==e)return;const i=this._length;this.setLength(this._length+e);for(let s=i-1;s>=t;s--)this.setBit(s+e,this.getBit(s));for(let i=t;i<t+e;i++)this.setBit(i,s)}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 s=t;s<this._length-e;s++)this.setBit(s,this.getBit(s+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 s=0;for(let i=-1;-1!=(i=t.findNext(i,!e));)this.setFast(s++,this.getBit(i));this._length=s,this._version++}return this}getBit(t){return 0!=(this._data[Math.floor(t/32)]&1<<(31&t))}setBit(t,e,s=!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 s=this._data[e];const n=31&this._length;for(0!=n&&(s&=~(4294967295<<n));0!=s;s>>>=8)this._selectedCount+=i._onBitCount[255&s];this._selectedCountVersion=this._version}return t?this._selectedCount:this._length-this._selectedCount}countWhere(t){let e=0;if(this.trueCount()==this._length)for(let s=0;s<this._length;s++)e+=t(s)?1:0;else for(let s=-1;-1!=(s=this.findNext(s,!0));)e+=t(s)?1:0;return e}andWithCountBits(t,e){if(0==this._length)return 0;let s=0;const n=this.lengthInInts;let o=0;for(;o<n-1;o++)for(let e=this._data[o]&t._data[o];0!=e;e>>>=8)s+=i._onBitCount[255&e];let r=this._data[o]&t._data[o];const a=31&this._length;for(0!=a&&(r&=~(4294967295<<a));0!=r;r>>>=8)s+=i._onBitCount[255&r];return e?s:this._length-s}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 s=31&(t=t<0?0:t+1);const n=this.lengthInInts;for(let o=Math.floor(t/32);o<n;o++){let n=e?this._data[o]:~this._data[o];if(0!=s)n&=4294967295<<s&4294967295,s=0;else if(!e&&-4294967296==n)continue;for(let e=0;0!=n;e+=8,n>>>=8){const s=i._firstOnBit[255&n];if(s>=0)return(t=s+32*o+e)>=this._length?-1:t}}return-1}findPrev(t,e=!0){if(0==t)return-1;this.assureInRange(t,-1,this._length,"index");let s=1+(t=t<0?this._length-1:t-1)&31;for(let n=Math.floor(t/32);n>=0;n--){let t=e?this._data[n]:~this._data[n];0!=s&&(t&=~(4294967295<<s),s=0);for(let e=24;0!=t;e-=8,t<<=8){const s=i._lastOnBit[t>>>24];if(s>=0)return s+32*n+e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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])},4588:(t,e,s)=>{"use strict";function i(t){return Math.random()*t}function n(t){return Math.floor(i(t))}s.d(e,{I:()=>n,t:()=>i})},8518:(t,e,s)=>{"use strict";s.d(e,{L:()=>n});var i=s(4588);function n(t,e,s){function n(t,e){let s=null,i=null;for(const n of t){const t=e(n);(null==i||t>i)&&(s=n,i=t)}return s}const o=[(0,i.I)(t-1)],r=new Set;for(let e=0;e<t;++e)o.includes(e)||r.add(e);for(;o.length<e;){const t=n(r.values(),(t=>Math.min.apply(Math,o.map((function(e,i){return s(t,e)})))));null!=t&&(o.push(t),r.delete(t))}return o}},1061:(t,e,s)=>{"use strict";s.d(e,{gw:()=>o}),s(4469),s(976);var i,n=function(t,e,s,i){return new(s||(s=Promise))((function(n,o){function r(t){try{l(i.next(t))}catch(t){o(t)}}function a(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?n(t.value):(e=t.value,e instanceof s?e:new s((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};function o(t){return n(this,void 0,void 0,(function*(){yield new Promise((e=>setTimeout(e,t)))}))}!function(t){t.notNull=function(t,e){if(null==t)throw new Error(`${null==e?"Value":e} not defined`)}}(i||(i={}))},3659:(t,e,s)=>{"use strict";s.d(e,{OW:()=>i});class i extends Float32Array{}},850:(t,e,s)=>{"use strict";s.d(e,{$G:()=>a,Fv:()=>u,MA:()=>l,On:()=>r,dP:()=>c,hu:()=>o,kO:()=>h});var i=s(3659),n=s(4588);function o(t=!1,e="Assertion error."){if(!t)throw new Error(e)}function r(t,e,s=1){const n=t.length;o(n==e.length,"Vector lengths do not match.");const r=new i.OW(n);for(let i=0;i<t.length;++i)r[i]=t[i]+s*e[i];return r}function a(t){let e=0;for(let s=0;s<t.length;s++)e+=t[s]*t[s];return Math.sqrt(e)}function l(t,e){if(t.length!=e.length)throw new Error("The dimensionality of the vectors must match");let s=0;for(let i=0;i<t.length;i++)s+=t[i]*e[i];return s}function h(t,e,s=1){const o=function(t,e,s=0){return new Array(t).fill(s).map((()=>new i.OW(e).fill(s)))}(t,e);for(let i=0;i<t;++i)for(let t=0;t<e;++t)o[i][t]=(0,n.t)(s);return o}function c(t,e){const s=function(t){let e=0;for(let s=0;s<t.length;++s)e+=t[s];return e}(function(t){const e=t.length,s=new i.OW(e);for(let e=0;e<t.length;++e)s[e]=t[e]*t[e];return s}(r(t,e,-1)));return Math.sqrt(s)}function u(t){let e=0,s=0;for(let s=0;s<t.length;++s)e+=t[s];e/=t.length;for(let i=0;i<t.length;++i)s+=(t[i]-e)*(t[i]-e);s=Math.sqrt(s/t.length);for(let i=0;i<t.length;++i)t[i]=(t[i]-e)/s;return t}},7659:(t,e,s)=>{"use strict";e.Z=void 0;var i=s(6215);Object.defineProperty(e,"Z",{enumerable:!0,get:function(){return i.TSNE}})},6215:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.TSNE=void 0,e.TSNE=class{constructor(t){this.returnV=!1,this.vValue=0,this.iter=0,t=t||{},this.perplexity=this.getopt(t,"perplexity",30),this.dim=this.getopt(t,"dim",2),this.epsilon=this.getopt(t,"epsilon",10)}assert(t,e){if(!t)throw e||"Assertion failed"}getopt(t,e,s){return t.hasOwnProperty(e)?t[e]:s}gaussRandom(){if(this.returnV)return this.returnV=!1,this.vValue;const t=2*Math.random()-1,e=2*Math.random()-1,s=t*t+e*e;if(0===s||s>1)return this.gaussRandom();const i=Math.sqrt(-2*Math.log(s)/s);return this.vValue=e*i,this.returnV=!0,t*i}randn(t,e){return t+this.gaussRandom()*e}zeros(t){if(void 0===t||isNaN(t))return[];if("undefined"==typeof ArrayBuffer){const e=new Array(t);for(let s=0;s<t;s++)e[s]=0;return e}return new Float64Array(t)}randn2d(t,e,s){const i=void 0!==s,n=[];for(let o=0;o<t;o++){const t=[];for(let n=0;n<e;n++)i?t.push(s):t.push(this.randn(0,1e-4));n.push(t)}return n}L2(t,e){const s=t.length;let i=0;for(let n=0;n<s;n++){const s=t[n],o=e[n];i+=(s-o)*(s-o)}return i}xtod(t){const e=t.length,s=this.zeros(e*e);for(let i=0;i<e;i++)for(let n=i+1;n<e;n++){const o=this.L2(t[i],t[n]);s[i*e+n]=o,s[n*e+i]=o}return s}d2p(t,e,s){const i=Math.sqrt(t.length),n=Math.floor(i);this.assert(n===i,"D should have square number of elements.");const o=Math.log(e),r=this.zeros(n*n),a=this.zeros(n);for(let e=0;e<n;e++){let i=-1/0,l=1/0,h=1,c=!1;const u=50;let m=0;for(;!c;){let r=0;for(let s=0;s<n;s++){let i=Math.exp(-t[e*n+s]*h);e===s&&(i=0),a[s]=i,r+=i}let d=0;for(let t=0;t<n;t++){let e;e=0===r?0:a[t]/r,a[t]=e,e>1e-7&&(d-=e*Math.log(e))}d>o?(i=h,l===1/0?h*=2:h=(h+l)/2):(l=h,i===-1/0?h/=2:h=(h+i)/2),m++,Math.abs(d-o)<s&&(c=!0),m>=u&&(c=!0)}for(let t=0;t<n;t++)r[e*n+t]=a[t]}const l=this.zeros(n*n),h=2*n;for(let t=0;t<n;t++)for(let e=0;e<n;e++)l[t*n+e]=Math.max((r[t*n+e]+r[e*n+t])/h,1e-100);return l}sign(t){return t>0?1:t<0?-1:0}initDataRaw(t){const e=t.length,s=t[0].length;this.assert(e>0," X is empty? You must have some data!"),this.assert(s>0," X[0] is empty? Where is the data?");const i=this.xtod(t);this.P=this.d2p(i,this.perplexity,1e-4),this.N=e,this.initSolution()}initDataDist(t){const e=t.length;this.assert(e>0," X is empty? You must have some data!");const s=this.zeros(e*e);for(let i=0;i<e;i++)for(let n=i+1;n<e;n++){const o=t[i][n];s[i*e+n]=o,s[n*e+i]=o}this.P=this.d2p(s,this.perplexity,1e-4),this.N=e,this.initSolution()}initSolution(){this.Y=this.randn2d(this.N,this.dim),this.gains=this.randn2d(this.N,this.dim,1),this.ystep=this.randn2d(this.N,this.dim,0),this.iter=0}getSolution(){return this.Y}step(){this.iter+=1;const t=this.N,e=this.costGrad(this.Y),s=e.cost,i=e.grad,n=this.zeros(this.dim);for(let e=0;e<t;e++)for(let t=0;t<this.dim;t++){const s=i[e][t],o=this.ystep[e][t],r=this.gains[e][t];let a=this.sign(s)===this.sign(o)?.8*r:r+.2;a<.01&&(a=.01),this.gains[e][t]=a;const l=(this.iter<250?.5:.8)*o-this.epsilon*a*i[e][t];this.ystep[e][t]=l,this.Y[e][t]+=l,n[t]+=this.Y[e][t]}for(let e=0;e<t;e++)for(let s=0;s<this.dim;s++)this.Y[e][s]-=n[s]/t;return s}debugGrad(){const t=this.N,e=this.costGrad(this.Y),s=(e.cost,e.grad),i=1e-5;for(let e=0;e<t;e++)for(let t=0;t<this.dim;t++){const n=this.Y[e][t];this.Y[e][t]=n+i;const o=this.costGrad(this.Y);this.Y[e][t]=n-i;const r=this.costGrad(this.Y),a=s[e][t],l=(o.cost-r.cost)/(2*i);console.log(e+","+t+": gradcheck analytic: "+a+" vs. numerical: "+l),this.Y[e][t]=n}}costGrad(t){const e=this.N,s=this.dim,i=this.P,n=this.iter<100?4:1,o=this.zeros(e*e);let r=0;for(let i=0;i<e;i++)for(let n=i+1;n<e;n++){let a=0;for(let e=0;e<s;e++){const s=t[i][e]-t[n][e];a+=s*s}const l=1/(1+a);o[i*e+n]=l,o[n*e+i]=l,r+=2*l}const a=e*e,l=this.zeros(a);for(let t=0;t<a;t++)l[t]=Math.max(o[t]/r,1e-100);let h=0;const c=[];for(let r=0;r<e;r++){const a=new Array(s);for(let t=0;t<s;t++)a[t]=0;for(let c=0;c<e;c++){h+=-i[r*e+c]*Math.log(l[r*e+c]);const u=4*(n*i[r*e+c]-l[r*e+c])*o[r*e+c];for(let e=0;e<s;e++)a[e]+=u*(t[r][e]-t[c][e])}c.push(a)}return{cost:h,grad:c}}}},5362:(t,e,s)=>{"use strict";s.d(e,{Z:()=>a});var i=s(7537),n=s.n(i),o=s(3645),r=s.n(o)()(n());r.push([t.id,".macromolecule-cell-comp-analysis-host{\n max-height: 250px;\n overflow-y: scroll;\n}\n\n.macromolecule-cell-comp-analysis-bar{\n height: inherit;\n display: block;\n margin-top: 1.5px;\n margin-bottom: 1.5px;\n margin-right: 3px;\n}\n\n.macromolecule-cell-comp-analysis-value{\n display: flex;\n}","",{version:3,sources:["webpack://./css/composition-analysis.css"],names:[],mappings:"AAAA;IACI,iBAAiB;IACjB,kBAAkB;AACtB;;AAEA;IACI,eAAe;IACf,cAAc;IACd,iBAAiB;IACjB,oBAAoB;IACpB,iBAAiB;AACrB;;AAEA;IACI,aAAa;AACjB",sourcesContent:[".macromolecule-cell-comp-analysis-host{\n max-height: 250px;\n overflow-y: scroll;\n}\n\n.macromolecule-cell-comp-analysis-bar{\n height: inherit;\n display: block;\n margin-top: 1.5px;\n margin-bottom: 1.5px;\n margin-right: 3px;\n}\n\n.macromolecule-cell-comp-analysis-value{\n display: flex;\n}"],sourceRoot:""}]);const a=r},9564:(t,e,s)=>{"use strict";s.d(e,{Z:()=>a});var i=s(7537),n=s.n(i),o=s(3645),r=s.n(o)()(n());r.push([t.id,".kalign-version {\n margin-bottom: 0;\n text-align: end;\n font-size: 12px;\n opacity: 0.8;\n}\nbutton.msa-params-button.ui-btn {\n justify-content: end;\n}","",{version:3,sources:["webpack://./css/msa.css"],names:[],mappings:"AAAA;IACI,gBAAgB;IAChB,eAAe;IACf,eAAe;IACf,YAAY;AAChB;AACA;IACI,oBAAoB;AACxB",sourcesContent:[".kalign-version {\n margin-bottom: 0;\n text-align: end;\n font-size: 12px;\n opacity: 0.8;\n}\nbutton.msa-params-button.ui-btn {\n justify-content: end;\n}"],sourceRoot:""}]);const a=r},9414:(t,e,s)=>{"use strict";s.d(e,{Z:()=>a});var i=s(7537),n=s.n(i),o=s(3645),r=s.n(o)()(n());r.push([t.id,".scatter_plot_link {\n position: absolute!important;\n right: 10px;\n}\n\n.cliffs_grid {\n top: 10px;\n}\n\n.show_only_cliffs {\n top: 30px;\n}\n\n.ml-dim-reduction-settings-input i.grok-icon.grok-font-icon-settings {\n font-size: 18px;\n position: absolute;\n height: 28px;\n}\n","",{version:3,sources:["webpack://./node_modules/@datagrok-libraries/ml/css/styles.css"],names:[],mappings:"AAAA;IACI,4BAA4B;IAC5B,WAAW;AACf;;AAEA;IACI,SAAS;AACb;;AAEA;IACI,SAAS;AACb;;AAEA;IACI,eAAe;IACf,kBAAkB;IAClB,YAAY;AAChB",sourcesContent:[".scatter_plot_link {\n position: absolute!important;\n right: 10px;\n}\n\n.cliffs_grid {\n top: 10px;\n}\n\n.show_only_cliffs {\n top: 30px;\n}\n\n.ml-dim-reduction-settings-input i.grok-icon.grok-font-icon-settings {\n font-size: 18px;\n position: absolute;\n height: 28px;\n}\n"],sourceRoot:""}]);const a=r},3645:t=>{"use strict";t.exports=function(t){var e=[];return e.toString=function(){return this.map((function(e){var s="",i=void 0!==e[5];return e[4]&&(s+="@supports (".concat(e[4],") {")),e[2]&&(s+="@media ".concat(e[2]," {")),i&&(s+="@layer".concat(e[5].length>0?" ".concat(e[5]):""," {")),s+=t(e),i&&(s+="}"),e[2]&&(s+="}"),e[4]&&(s+="}"),s})).join("")},e.i=function(t,s,i,n,o){"string"==typeof t&&(t=[[null,t,void 0]]);var r={};if(i)for(var a=0;a<this.length;a++){var l=this[a][0];null!=l&&(r[l]=!0)}for(var h=0;h<t.length;h++){var c=[].concat(t[h]);i&&r[c[0]]||(void 0!==o&&(void 0===c[5]||(c[1]="@layer".concat(c[5].length>0?" ".concat(c[5]):""," {").concat(c[1],"}")),c[5]=o),s&&(c[2]?(c[1]="@media ".concat(c[2]," {").concat(c[1],"}"),c[2]=s):c[2]=s),n&&(c[4]?(c[1]="@supports (".concat(c[4],") {").concat(c[1],"}"),c[4]=n):c[4]="".concat(n)),e.push(c))}},e}},7537:t=>{"use strict";t.exports=function(t){var e=t[1],s=t[3];if(!s)return e;if("function"==typeof btoa){var i=btoa(unescape(encodeURIComponent(JSON.stringify(s)))),n="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(i),o="/*# ".concat(n," */");return[e].concat([o]).join("\n")}return[e].join("\n")}},9133:function(t,e,s){var i;!function(e,n){var o={};!function(t){"use strict";t.__esModule=!0,t.digestLength=32,t.blockSize=64;var e=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function s(t,s,i,n,o){for(var r,a,l,h,c,u,m,d,g,p,f,y,b;o>=64;){for(r=s[0],a=s[1],l=s[2],h=s[3],c=s[4],u=s[5],m=s[6],d=s[7],p=0;p<16;p++)f=n+4*p,t[p]=(255&i[f])<<24|(255&i[f+1])<<16|(255&i[f+2])<<8|255&i[f+3];for(p=16;p<64;p++)y=((g=t[p-2])>>>17|g<<15)^(g>>>19|g<<13)^g>>>10,b=((g=t[p-15])>>>7|g<<25)^(g>>>18|g<<14)^g>>>3,t[p]=(y+t[p-7]|0)+(b+t[p-16]|0);for(p=0;p<64;p++)y=(((c>>>6|c<<26)^(c>>>11|c<<21)^(c>>>25|c<<7))+(c&u^~c&m)|0)+(d+(e[p]+t[p]|0)|0)|0,b=((r>>>2|r<<30)^(r>>>13|r<<19)^(r>>>22|r<<10))+(r&a^r&l^a&l)|0,d=m,m=u,u=c,c=h+y|0,h=l,l=a,a=r,r=y+b|0;s[0]+=r,s[1]+=a,s[2]+=l,s[3]+=h,s[4]+=c,s[5]+=u,s[6]+=m,s[7]+=d,n+=64,o-=64}return n}var i=function(){function e(){this.digestLength=t.digestLength,this.blockSize=t.blockSize,this.state=new Int32Array(8),this.temp=new Int32Array(64),this.buffer=new Uint8Array(128),this.bufferLength=0,this.bytesHashed=0,this.finished=!1,this.reset()}return e.prototype.reset=function(){return this.state[0]=1779033703,this.state[1]=3144134277,this.state[2]=1013904242,this.state[3]=2773480762,this.state[4]=1359893119,this.state[5]=2600822924,this.state[6]=528734635,this.state[7]=1541459225,this.bufferLength=0,this.bytesHashed=0,this.finished=!1,this},e.prototype.clean=function(){for(var t=0;t<this.buffer.length;t++)this.buffer[t]=0;for(t=0;t<this.temp.length;t++)this.temp[t]=0;this.reset()},e.prototype.update=function(t,e){if(void 0===e&&(e=t.length),this.finished)throw new Error("SHA256: can't update because hash was finished.");var i=0;if(this.bytesHashed+=e,this.bufferLength>0){for(;this.bufferLength<64&&e>0;)this.buffer[this.bufferLength++]=t[i++],e--;64===this.bufferLength&&(s(this.temp,this.state,this.buffer,0,64),this.bufferLength=0)}for(e>=64&&(i=s(this.temp,this.state,t,i,e),e%=64);e>0;)this.buffer[this.bufferLength++]=t[i++],e--;return this},e.prototype.finish=function(t){if(!this.finished){var e=this.bytesHashed,i=this.bufferLength,n=e/536870912|0,o=e<<3,r=e%64<56?64:128;this.buffer[i]=128;for(var a=i+1;a<r-8;a++)this.buffer[a]=0;this.buffer[r-8]=n>>>24&255,this.buffer[r-7]=n>>>16&255,this.buffer[r-6]=n>>>8&255,this.buffer[r-5]=n>>>0&255,this.buffer[r-4]=o>>>24&255,this.buffer[r-3]=o>>>16&255,this.buffer[r-2]=o>>>8&255,this.buffer[r-1]=o>>>0&255,s(this.temp,this.state,this.buffer,0,r),this.finished=!0}for(a=0;a<8;a++)t[4*a+0]=this.state[a]>>>24&255,t[4*a+1]=this.state[a]>>>16&255,t[4*a+2]=this.state[a]>>>8&255,t[4*a+3]=this.state[a]>>>0&255;return this},e.prototype.digest=function(){var t=new Uint8Array(this.digestLength);return this.finish(t),t},e.prototype._saveState=function(t){for(var e=0;e<this.state.length;e++)t[e]=this.state[e]},e.prototype._restoreState=function(t,e){for(var s=0;s<this.state.length;s++)this.state[s]=t[s];this.bytesHashed=e,this.finished=!1,this.bufferLength=0},e}();t.Hash=i;var n=function(){function t(t){this.inner=new i,this.outer=new i,this.blockSize=this.inner.blockSize,this.digestLength=this.inner.digestLength;var e=new Uint8Array(this.blockSize);if(t.length>this.blockSize)(new i).update(t).finish(e).clean();else for(var s=0;s<t.length;s++)e[s]=t[s];for(s=0;s<e.length;s++)e[s]^=54;for(this.inner.update(e),s=0;s<e.length;s++)e[s]^=106;for(this.outer.update(e),this.istate=new Uint32Array(8),this.ostate=new Uint32Array(8),this.inner._saveState(this.istate),this.outer._saveState(this.ostate),s=0;s<e.length;s++)e[s]=0}return t.prototype.reset=function(){return this.inner._restoreState(this.istate,this.inner.blockSize),this.outer._restoreState(this.ostate,this.outer.blockSize),this},t.prototype.clean=function(){for(var t=0;t<this.istate.length;t++)this.ostate[t]=this.istate[t]=0;this.inner.clean(),this.outer.clean()},t.prototype.update=function(t){return this.inner.update(t),this},t.prototype.finish=function(t){return this.outer.finished?this.outer.finish(t):(this.inner.finish(t),this.outer.update(t,this.digestLength).finish(t)),this},t.prototype.digest=function(){var t=new Uint8Array(this.digestLength);return this.finish(t),t},t}();function o(t){var e=(new i).update(t),s=e.digest();return e.clean(),s}function r(t,e){var s=new n(t).update(e),i=s.digest();return s.clean(),i}function a(t,e,s,i){var n=i[0];if(0===n)throw new Error("hkdf: cannot expand more");e.reset(),n>1&&e.update(t),s&&e.update(s),e.update(i),e.finish(t),i[0]++}t.HMAC=n,t.hash=o,t.default=o,t.hmac=r;var l=new Uint8Array(t.digestLength);t.hkdf=function(t,e,s,i){void 0===e&&(e=l),void 0===i&&(i=32);for(var o=new Uint8Array([1]),h=r(e,t),c=new n(h),u=new Uint8Array(c.digestLength),m=u.length,d=new Uint8Array(i),g=0;g<i;g++)m===u.length&&(a(u,c,s,o),m=0),d[g]=u[m++];return c.clean(),u.fill(0),o.fill(0),d},t.pbkdf2=function(t,e,s,i){for(var o=new n(t),r=o.digestLength,a=new Uint8Array(4),l=new Uint8Array(r),h=new Uint8Array(r),c=new Uint8Array(i),u=0;u*r<i;u++){var m=u+1;a[0]=m>>>24&255,a[1]=m>>>16&255,a[2]=m>>>8&255,a[3]=m>>>0&255,o.reset(),o.update(e),o.update(a),o.finish(h);for(var d=0;d<r;d++)l[d]=h[d];for(d=2;d<=s;d++){o.reset(),o.update(h).finish(h);for(var g=0;g<r;g++)l[g]^=h[g]}for(d=0;d<r&&u*r+d<i;d++)c[u*r+d]=l[d]}for(u=0;u<r;u++)l[u]=h[u]=0;for(u=0;u<4;u++)a[u]=0;return o.clean(),c}}(o);var r=o.default;for(var a in o)r[a]=o[a];"object"==typeof t.exports?t.exports=r:void 0===(i=function(){return r}.call(o,s,o,t))||(t.exports=i)}()},1811:(t,e,s)=>{"use strict";s.d(e,{T:()=>n});const i=new Uint32Array(65536),n=(t,e)=>{if(t.length<e.length){const s=e;e=t,t=s}return 0===e.length?t.length:t.length<=32?((t,e)=>{const s=t.length,n=e.length,o=1<<s-1;let r=-1,a=0,l=s,h=s;for(;h--;)i[t.charCodeAt(h)]|=1<<h;for(h=0;h<n;h++){let t=i[e.charCodeAt(h)];const s=t|a;t|=(t&r)+r^r,a|=~(t|r),r&=t,a&o&&l++,r&o&&l--,a=a<<1|1,r=r<<1|~(s|a),a&=s}for(h=s;h--;)i[t.charCodeAt(h)]=0;return l})(t,e):((t,e)=>{const s=e.length,n=t.length,o=[],r=[],a=Math.ceil(s/32),l=Math.ceil(n/32);for(let t=0;t<a;t++)r[t]=-1,o[t]=0;let h=0;for(;h<l-1;h++){let a=0,l=-1;const c=32*h,u=Math.min(32,n)+c;for(let e=c;e<u;e++)i[t.charCodeAt(e)]|=1<<e;for(let t=0;t<s;t++){const s=i[e.charCodeAt(t)],n=r[t/32|0]>>>t&1,h=o[t/32|0]>>>t&1,c=s|a,u=((s|h)&l)+l^l|s|h;let m=a|~(u|l),d=l&u;m>>>31^n&&(r[t/32|0]^=1<<t),d>>>31^h&&(o[t/32|0]^=1<<t),m=m<<1|n,d=d<<1|h,l=d|~(c|m),a=m&c}for(let e=c;e<u;e++)i[t.charCodeAt(e)]=0}let c=0,u=-1;const m=32*h,d=Math.min(32,n-m)+m;for(let e=m;e<d;e++)i[t.charCodeAt(e)]|=1<<e;let g=n;for(let t=0;t<s;t++){const s=i[e.charCodeAt(t)],a=r[t/32|0]>>>t&1,l=o[t/32|0]>>>t&1,h=s|c,m=((s|l)&u)+u^u|s|l;let d=c|~(m|u),p=u&m;g+=d>>>n-1&1,g-=p>>>n-1&1,d>>>31^a&&(r[t/32|0]^=1<<t),p>>>31^l&&(o[t/32|0]^=1<<t),d=d<<1|a,p=p<<1|l,u=p|~(h|d),c=d&h}for(let e=m;e<d;e++)i[t.charCodeAt(e)]=0;return g})(t,e)}},7531:(t,e,s)=>{"use strict";s.d(e,{Z:()=>n});const i=Object.prototype.toString;function n(t){return i.call(t).endsWith("Array]")}},3979:(t,e)=>{"use strict";e.H$=void 0,e.H$=function(t,e,s){var i=function(t,e,s){if(0===t.length||0===e.length)return 0;if(s&&!s.caseSensitive&&(t=t.toUpperCase(),e=e.toUpperCase()),t===e)return 1;for(var i=0,n=t.length,o=e.length,r=Math.floor(Math.max(n,o)/2)-1,a=new Array(n),l=new Array(o),h=0;h<n;h++)for(var c=Math.max(0,h-r);c<=Math.min(o,h+r+1);c++)if(!a[h]&&!l[c]&&t[h]===e[c]){++i,a[h]=l[c]=!0;break}if(0===i)return 0;var u=0,m=0;for(h=0;h<n;h++)if(a[h]){for(;!l[m];)m++;t.charAt(h)!==e.charAt(m++)&&u++}return(i/n+i/o+(i-(u/=2))/i)/3}(t,e,s),n=0;if(i>.7){for(var o=Math.min(t.length,e.length),r=0;t[r]===e[r]&&r<4&&r<o;)++n,r++;i+=.1*n*(1-i)}return i}},5111:(t,e,s)=>{"use strict";s.d(e,{Z:()=>n});var i=s(6044);function n(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!(0,i.N)(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");var s=e.fromIndex,n=void 0===s?0:s,o=e.toIndex,r=void 0===o?t.length:o;if(n<0||n>=t.length||!Number.isInteger(n))throw new Error("fromIndex must be a positive integer smaller than length");if(r<=n||r>t.length||!Number.isInteger(r))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var a=t[n],l=n+1;l<r;l++)t[l]>a&&(a=t[l]);return a}},6044:(t,e,s)=>{"use strict";s.d(e,{N:()=>n});const i=Object.prototype.toString;function n(t){return i.call(t).endsWith("Array]")}},1772:(t,e,s)=>{"use strict";s.d(e,{Z:()=>n});var i=s(994);function n(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!(0,i.N)(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");var s=e.fromIndex,n=void 0===s?0:s,o=e.toIndex,r=void 0===o?t.length:o;if(n<0||n>=t.length||!Number.isInteger(n))throw new Error("fromIndex must be a positive integer smaller than length");if(r<=n||r>t.length||!Number.isInteger(r))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var a=t[n],l=n+1;l<r;l++)t[l]<a&&(a=t[l]);return a}},994:(t,e,s)=>{"use strict";s.d(e,{N:()=>n});const i=Object.prototype.toString;function n(t){return i.call(t).endsWith("Array]")}},5408:(t,e,s)=>{"use strict";s.d(e,{Z:()=>r});var i=s(6241),n=s(5111),o=s(1772);function r(t){var e,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!(0,i.N)(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");if(void 0!==s.output){if(!(0,i.N)(s.output))throw new TypeError("output option must be an array if specified");e=s.output}else e=new Array(t.length);var r=(0,o.Z)(t),a=(0,n.Z)(t);if(r===a)throw new RangeError("minimum and maximum input values are equal. Cannot rescale a constant array");var l=s.min,h=void 0===l?s.autoMinMax?r:0:l,c=s.max,u=void 0===c?s.autoMinMax?a:1:c;if(h>=u)throw new RangeError("min option must be smaller than max option");for(var m=(u-h)/(a-r),d=0;d<t.length;d++)e[d]=(t[d]-r)*m+h;return e}},6241:(t,e,s)=>{"use strict";s.d(e,{N:()=>n});const i=Object.prototype.toString;function n(t){return i.call(t).endsWith("Array]")}},1353:(t,e,s)=>{"use strict";function i(t,e,s){let i=0;const n=s(e);for(let e=0;e<t.x.length;e++)i+=Math.abs(t.y[e]-n(t.x[e]));return i}s.d(e,{Z:()=>i})},3107:(t,e,s)=>{"use strict";s.d(e,{Z:()=>r});var i=s(7531),n=s(1353),o=s(8188);function r(t,e,s={}){let{maxIterations:r=100,gradientDifference:a=.1,damping:l=0,errorTolerance:h=.01,minValues:c,maxValues:u,initialValues:m}=s;if(l<=0)throw new Error("The damping option must be a positive number");if(!t.x||!t.y)throw new Error("The data parameter must have x and y elements");if(!(0,i.Z)(t.x)||t.x.length<2||!(0,i.Z)(t.y)||t.y.length<2)throw new Error("The data parameter elements must be an array with more than 2 points");if(t.x.length!==t.y.length)throw new Error("The data parameter elements must have the same size");let d=m||new Array(e.length).fill(1),g=d.length;if(u=u||new Array(g).fill(Number.MAX_SAFE_INTEGER),c=c||new Array(g).fill(Number.MIN_SAFE_INTEGER),u.length!==c.length)throw new Error("minValues and maxValues must be the same size");if(!(0,i.Z)(d))throw new Error("initialValues must be an array");let p,f=(0,n.Z)(t,d,e),y=f<=h;for(p=0;p<r&&!y;p++){d=(0,o.Z)(t,d,l,a,e);for(let t=0;t<g;t++)d[t]=Math.min(Math.max(c[t],d[t]),u[t]);if(f=(0,n.Z)(t,d,e),isNaN(f))break;y=f<=h}return{parameterValues:d,parameterError:f,iterations:p}}},8188:(t,e,s)=>{"use strict";s.d(e,{Z:()=>o});var i=s(1174),n=s(8345);function o(t,e,s,o,r){let a=s*o*o,l=i.Z.eye(e.length,e.length,a);const h=r(e);let c=new Float64Array(t.x.length);for(let e=0;e<t.x.length;e++)c[e]=h(t.x[e]);let u=function(t,e,s,n,o){const r=s.length,a=t.x.length;let l=new Array(r);for(let i=0;i<r;i++){l[i]=new Array(a);let r=s.slice();r[i]+=n;let h=o(r);for(let s=0;s<a;s++)l[i][s]=e[s]-h(t.x[s])}return new i.Z(l)}(t,c,e,o,r),m=function(t,e){const s=t.x.length;let n=new Array(s);for(let i=0;i<s;i++)n[i]=[t.y[i]-e[i]];return new i.Z(n)}(t,c),d=(0,n.S)(l.add(u.mmul(u.transpose())));return(e=(e=new i.Z([e])).sub(d.mmul(u).mmul(m).mul(o).transpose())).to1DArray()}},5776:(t,e,s)=>{"use strict";s.d(e,{N:()=>n});const i=Object.prototype.toString;function n(t){return i.call(t).endsWith("Array]")}},2313:(t,e,s)=>{"use strict";s.d(e,{Z:()=>o});var i=s(1174),n=s(8353);class o{constructor(t){let e,s,i,o,r,a,l,h,c,u=(t=n.Z.checkMatrix(t)).clone(),m=u.rows,d=u.columns,g=new Float64Array(m),p=1;for(e=0;e<m;e++)g[e]=e;for(h=new Float64Array(m),s=0;s<d;s++){for(e=0;e<m;e++)h[e]=u.get(e,s);for(e=0;e<m;e++){for(c=Math.min(e,s),r=0,i=0;i<c;i++)r+=u.get(e,i)*h[i];h[e]-=r,u.set(e,s,h[e])}for(o=s,e=s+1;e<m;e++)Math.abs(h[e])>Math.abs(h[o])&&(o=e);if(o!==s){for(i=0;i<d;i++)a=u.get(o,i),u.set(o,i,u.get(s,i)),u.set(s,i,a);l=g[o],g[o]=g[s],g[s]=l,p=-p}if(s<m&&0!==u.get(s,s))for(e=s+1;e<m;e++)u.set(e,s,u.get(e,s)/u.get(s,s))}this.LU=u,this.pivotVector=g,this.pivotSign=p}isSingular(){let t=this.LU,e=t.columns;for(let s=0;s<e;s++)if(0===t.get(s,s))return!0;return!1}solve(t){t=i.Z.checkMatrix(t);let e=this.LU;if(e.rows!==t.rows)throw new Error("Invalid matrix dimensions");if(this.isSingular())throw new Error("LU matrix is singular");let s,n,o,r=t.columns,a=t.subMatrixRow(this.pivotVector,0,r-1),l=e.columns;for(o=0;o<l;o++)for(s=o+1;s<l;s++)for(n=0;n<r;n++)a.set(s,n,a.get(s,n)-a.get(o,n)*e.get(s,o));for(o=l-1;o>=0;o--){for(n=0;n<r;n++)a.set(o,n,a.get(o,n)/e.get(o,o));for(s=0;s<o;s++)for(n=0;n<r;n++)a.set(s,n,a.get(s,n)-a.get(o,n)*e.get(s,o))}return a}get determinant(){let t=this.LU;if(!t.isSquare())throw new Error("Matrix must be square");let e=this.pivotSign,s=t.columns;for(let i=0;i<s;i++)e*=t.get(i,i);return e}get lowerTriangularMatrix(){let t=this.LU,e=t.rows,s=t.columns,n=new i.Z(e,s);for(let i=0;i<e;i++)for(let e=0;e<s;e++)i>e?n.set(i,e,t.get(i,e)):i===e?n.set(i,e,1):n.set(i,e,0);return n}get upperTriangularMatrix(){let t=this.LU,e=t.rows,s=t.columns,n=new i.Z(e,s);for(let i=0;i<e;i++)for(let e=0;e<s;e++)i<=e?n.set(i,e,t.get(i,e)):n.set(i,e,0);return n}get pivotPermutationVector(){return Array.from(this.pivotVector)}}},7072:(t,e,s)=>{"use strict";s.d(e,{Z:()=>r});var i=s(1174),n=s(8353),o=s(6310);class r{constructor(t){let e,s,i,r,a=(t=n.Z.checkMatrix(t)).clone(),l=t.rows,h=t.columns,c=new Float64Array(h);for(i=0;i<h;i++){let t=0;for(e=i;e<l;e++)t=(0,o.G)(t,a.get(e,i));if(0!==t){for(a.get(i,i)<0&&(t=-t),e=i;e<l;e++)a.set(e,i,a.get(e,i)/t);for(a.set(i,i,a.get(i,i)+1),s=i+1;s<h;s++){for(r=0,e=i;e<l;e++)r+=a.get(e,i)*a.get(e,s);for(r=-r/a.get(i,i),e=i;e<l;e++)a.set(e,s,a.get(e,s)+r*a.get(e,i))}}c[i]=-t}this.QR=a,this.Rdiag=c}solve(t){t=i.Z.checkMatrix(t);let e=this.QR,s=e.rows;if(t.rows!==s)throw new Error("Matrix row dimensions must agree");if(!this.isFullRank())throw new Error("Matrix is rank deficient");let n,o,r,a,l=t.columns,h=t.clone(),c=e.columns;for(r=0;r<c;r++)for(o=0;o<l;o++){for(a=0,n=r;n<s;n++)a+=e.get(n,r)*h.get(n,o);for(a=-a/e.get(r,r),n=r;n<s;n++)h.set(n,o,h.get(n,o)+a*e.get(n,r))}for(r=c-1;r>=0;r--){for(o=0;o<l;o++)h.set(r,o,h.get(r,o)/this.Rdiag[r]);for(n=0;n<r;n++)for(o=0;o<l;o++)h.set(n,o,h.get(n,o)-h.get(r,o)*e.get(n,r))}return h.subMatrix(0,c-1,0,l-1)}isFullRank(){let t=this.QR.columns;for(let e=0;e<t;e++)if(0===this.Rdiag[e])return!1;return!0}get upperTriangularMatrix(){let t,e,s=this.QR,n=s.columns,o=new i.Z(n,n);for(t=0;t<n;t++)for(e=0;e<n;e++)t<e?o.set(t,e,s.get(t,e)):t===e?o.set(t,e,this.Rdiag[t]):o.set(t,e,0);return o}get orthogonalMatrix(){let t,e,s,n,o=this.QR,r=o.rows,a=o.columns,l=new i.Z(r,a);for(s=a-1;s>=0;s--){for(t=0;t<r;t++)l.set(t,s,0);for(l.set(s,s,1),e=s;e<a;e++)if(0!==o.get(s,s)){for(n=0,t=s;t<r;t++)n+=o.get(t,s)*l.get(t,e);for(n=-n/o.get(s,s),t=s;t<r;t++)l.set(t,e,l.get(t,e)+n*o.get(t,s))}}return l}}},6943:(t,e,s)=>{"use strict";s.d(e,{Z:()=>r});var i=s(1174),n=s(8353),o=s(6310);class r{constructor(t,e={}){if((t=n.Z.checkMatrix(t)).isEmpty())throw new Error("Matrix must be non-empty");let s=t.rows,r=t.columns;const{computeLeftSingularVectors:a=!0,computeRightSingularVectors:l=!0,autoTranspose:h=!1}=e;let c,u=Boolean(a),m=Boolean(l),d=!1;if(s<r)if(h){c=t.transpose(),s=c.rows,r=c.columns,d=!0;let e=u;u=m,m=e}else c=t.clone(),console.warn("Computing SVD on a matrix with more columns than rows. Consider enabling autoTranspose");else c=t.clone();let g=Math.min(s,r),p=Math.min(s+1,r),f=new Float64Array(p),y=new i.Z(s,g),b=new i.Z(r,r),w=new Float64Array(r),C=new Float64Array(s),v=new Float64Array(p);for(let t=0;t<p;t++)v[t]=t;let S=Math.min(s-1,r),T=Math.max(0,Math.min(r-2,s)),M=Math.max(S,T);for(let t=0;t<M;t++){if(t<S){f[t]=0;for(let e=t;e<s;e++)f[t]=(0,o.G)(f[t],c.get(e,t));if(0!==f[t]){c.get(t,t)<0&&(f[t]=-f[t]);for(let e=t;e<s;e++)c.set(e,t,c.get(e,t)/f[t]);c.set(t,t,c.get(t,t)+1)}f[t]=-f[t]}for(let e=t+1;e<r;e++){if(t<S&&0!==f[t]){let i=0;for(let n=t;n<s;n++)i+=c.get(n,t)*c.get(n,e);i=-i/c.get(t,t);for(let n=t;n<s;n++)c.set(n,e,c.get(n,e)+i*c.get(n,t))}w[e]=c.get(t,e)}if(u&&t<S)for(let e=t;e<s;e++)y.set(e,t,c.get(e,t));if(t<T){w[t]=0;for(let e=t+1;e<r;e++)w[t]=(0,o.G)(w[t],w[e]);if(0!==w[t]){w[t+1]<0&&(w[t]=0-w[t]);for(let e=t+1;e<r;e++)w[e]/=w[t];w[t+1]+=1}if(w[t]=-w[t],t+1<s&&0!==w[t]){for(let e=t+1;e<s;e++)C[e]=0;for(let e=t+1;e<s;e++)for(let s=t+1;s<r;s++)C[e]+=w[s]*c.get(e,s);for(let e=t+1;e<r;e++){let i=-w[e]/w[t+1];for(let n=t+1;n<s;n++)c.set(n,e,c.get(n,e)+i*C[n])}}if(m)for(let e=t+1;e<r;e++)b.set(e,t,w[e])}}let A=Math.min(r,s+1);if(S<r&&(f[S]=c.get(S,S)),s<A&&(f[A-1]=0),T+1<A&&(w[T]=c.get(T,A-1)),w[A-1]=0,u){for(let t=S;t<g;t++){for(let e=0;e<s;e++)y.set(e,t,0);y.set(t,t,1)}for(let t=S-1;t>=0;t--)if(0!==f[t]){for(let e=t+1;e<g;e++){let i=0;for(let n=t;n<s;n++)i+=y.get(n,t)*y.get(n,e);i=-i/y.get(t,t);for(let n=t;n<s;n++)y.set(n,e,y.get(n,e)+i*y.get(n,t))}for(let e=t;e<s;e++)y.set(e,t,-y.get(e,t));y.set(t,t,1+y.get(t,t));for(let e=0;e<t-1;e++)y.set(e,t,0)}else{for(let e=0;e<s;e++)y.set(e,t,0);y.set(t,t,1)}}if(m)for(let t=r-1;t>=0;t--){if(t<T&&0!==w[t])for(let e=t+1;e<r;e++){let s=0;for(let i=t+1;i<r;i++)s+=b.get(i,t)*b.get(i,e);s=-s/b.get(t+1,t);for(let i=t+1;i<r;i++)b.set(i,e,b.get(i,e)+s*b.get(i,t))}for(let e=0;e<r;e++)b.set(e,t,0);b.set(t,t,1)}let E=A-1,x=0,I=Number.EPSILON;for(;A>0;){let t,e;for(t=A-2;t>=-1&&-1!==t;t--){const e=Number.MIN_VALUE+I*Math.abs(f[t]+Math.abs(f[t+1]));if(Math.abs(w[t])<=e||Number.isNaN(w[t])){w[t]=0;break}}if(t===A-2)e=4;else{let s;for(s=A-1;s>=t&&s!==t;s--){let e=(s!==A?Math.abs(w[s]):0)+(s!==t+1?Math.abs(w[s-1]):0);if(Math.abs(f[s])<=I*e){f[s]=0;break}}s===t?e=3:s===A-1?e=1:(e=2,t=s)}switch(t++,e){case 1:{let e=w[A-2];w[A-2]=0;for(let s=A-2;s>=t;s--){let i=(0,o.G)(f[s],e),n=f[s]/i,a=e/i;if(f[s]=i,s!==t&&(e=-a*w[s-1],w[s-1]=n*w[s-1]),m)for(let t=0;t<r;t++)i=n*b.get(t,s)+a*b.get(t,A-1),b.set(t,A-1,-a*b.get(t,s)+n*b.get(t,A-1)),b.set(t,s,i)}break}case 2:{let e=w[t-1];w[t-1]=0;for(let i=t;i<A;i++){let n=(0,o.G)(f[i],e),r=f[i]/n,a=e/n;if(f[i]=n,e=-a*w[i],w[i]=r*w[i],u)for(let e=0;e<s;e++)n=r*y.get(e,i)+a*y.get(e,t-1),y.set(e,t-1,-a*y.get(e,i)+r*y.get(e,t-1)),y.set(e,i,n)}break}case 3:{const e=Math.max(Math.abs(f[A-1]),Math.abs(f[A-2]),Math.abs(w[A-2]),Math.abs(f[t]),Math.abs(w[t])),i=f[A-1]/e,n=f[A-2]/e,a=w[A-2]/e,l=f[t]/e,h=w[t]/e,c=((n+i)*(n-i)+a*a)/2,d=i*a*(i*a);let g=0;0===c&&0===d||(g=c<0?0-Math.sqrt(c*c+d):Math.sqrt(c*c+d),g=d/(c+g));let p=(l+i)*(l-i)+g,C=l*h;for(let e=t;e<A-1;e++){let i=(0,o.G)(p,C);0===i&&(i=Number.MIN_VALUE);let n=p/i,a=C/i;if(e!==t&&(w[e-1]=i),p=n*f[e]+a*w[e],w[e]=n*w[e]-a*f[e],C=a*f[e+1],f[e+1]=n*f[e+1],m)for(let t=0;t<r;t++)i=n*b.get(t,e)+a*b.get(t,e+1),b.set(t,e+1,-a*b.get(t,e)+n*b.get(t,e+1)),b.set(t,e,i);if(i=(0,o.G)(p,C),0===i&&(i=Number.MIN_VALUE),n=p/i,a=C/i,f[e]=i,p=n*w[e]+a*f[e+1],f[e+1]=-a*w[e]+n*f[e+1],C=a*w[e+1],w[e+1]=n*w[e+1],u&&e<s-1)for(let t=0;t<s;t++)i=n*y.get(t,e)+a*y.get(t,e+1),y.set(t,e+1,-a*y.get(t,e)+n*y.get(t,e+1)),y.set(t,e,i)}w[A-2]=p,x+=1;break}case 4:if(f[t]<=0&&(f[t]=f[t]<0?-f[t]:0,m))for(let e=0;e<=E;e++)b.set(e,t,-b.get(e,t));for(;t<E&&!(f[t]>=f[t+1]);){let e=f[t];if(f[t]=f[t+1],f[t+1]=e,m&&t<r-1)for(let s=0;s<r;s++)e=b.get(s,t+1),b.set(s,t+1,b.get(s,t)),b.set(s,t,e);if(u&&t<s-1)for(let i=0;i<s;i++)e=y.get(i,t+1),y.set(i,t+1,y.get(i,t)),y.set(i,t,e);t++}x=0,A--}}if(d){let t=b;b=y,y=t}this.m=s,this.n=r,this.s=f,this.U=y,this.V=b}solve(t){let e=t,s=this.threshold,n=this.s.length,o=i.Z.zeros(n,n);for(let t=0;t<n;t++)Math.abs(this.s[t])<=s?o.set(t,t,0):o.set(t,t,1/this.s[t]);let r=this.U,a=this.rightSingularVectors,l=a.mmul(o),h=a.rows,c=r.rows,u=i.Z.zeros(h,c);for(let t=0;t<h;t++)for(let e=0;e<c;e++){let s=0;for(let i=0;i<n;i++)s+=l.get(t,i)*r.get(e,i);u.set(t,e,s)}return u.mmul(e)}solveForDiagonal(t){return this.solve(i.Z.diag(t))}inverse(){let t=this.V,e=this.threshold,s=t.rows,n=t.columns,o=new i.Z(s,this.s.length);for(let i=0;i<s;i++)for(let s=0;s<n;s++)Math.abs(this.s[s])>e&&o.set(i,s,t.get(i,s)/this.s[s]);let r=this.U,a=r.rows,l=r.columns,h=new i.Z(s,a);for(let t=0;t<s;t++)for(let e=0;e<a;e++){let s=0;for(let i=0;i<l;i++)s+=o.get(t,i)*r.get(e,i);h.set(t,e,s)}return h}get condition(){return this.s[0]/this.s[Math.min(this.m,this.n)-1]}get norm2(){return this.s[0]}get rank(){let t=Math.max(this.m,this.n)*this.s[0]*Number.EPSILON,e=0,s=this.s;for(let i=0,n=s.length;i<n;i++)s[i]>t&&e++;return e}get diagonal(){return Array.from(this.s)}get threshold(){return Number.EPSILON/2*Math.max(this.m,this.n)*this.s[0]}get leftSingularVectors(){return this.U}get rightSingularVectors(){return this.V}get diagonalMatrix(){return i.Z.diag(this.s)}}},6310:(t,e,s)=>{"use strict";function i(t,e){let s=0;return Math.abs(t)>Math.abs(e)?(s=e/t,Math.abs(t)*Math.sqrt(1+s*s)):0!==e?(s=t/e,Math.abs(e)*Math.sqrt(1+s*s)):0}s.d(e,{G:()=>i})},8345:(t,e,s)=>{"use strict";s.d(e,{S:()=>l});var i=s(2313),n=s(7072),o=s(6943),r=s(1174),a=s(8353);function l(t,e=!1){return t=a.Z.checkMatrix(t),e?new o.Z(t).inverse():function(t,e,s=!1){return t=a.Z.checkMatrix(t),e=a.Z.checkMatrix(e),s?new o.Z(t).solve(e):t.isSquare()?new i.Z(t).solve(e):new n.Z(t).solve(e)}(t,r.Z.eye(t.rows))}},3559:(t,e,s)=>{"use strict";s.d(e,{M:()=>r,V:()=>o});const i=" ".repeat(2),n=" ".repeat(4);function o(){return r(this)}function r(t,e={}){const{maxRows:s=15,maxColumns:o=10,maxNumSize:r=8,padMinus:l="auto"}=e;return`${t.constructor.name} {\n${i}[\n${n}${function(t,e,s,i,o){const{rows:r,columns:l}=t,h=Math.min(r,e),c=Math.min(l,s),u=[];if("auto"===o){o=!1;t:for(let e=0;e<h;e++)for(let s=0;s<c;s++)if(t.get(e,s)<0){o=!0;break t}}for(let e=0;e<h;e++){let s=[];for(let n=0;n<c;n++)s.push(a(t.get(e,n),i,o));u.push(`${s.join(" ")}`)}return c!==l&&(u[u.length-1]+=` ... ${l-s} more columns`),h!==r&&u.push(`... ${r-e} more rows`),u.join(`\n${n}`)}(t,s,o,r,l)}\n${i}]\n${i}rows: ${t.rows}\n${i}columns: ${t.columns}\n}`}function a(t,e,s){return(t>=0&&s?` ${l(t,e-1)}`:l(t,e)).padEnd(e)}function l(t,e){let s=t.toString();if(s.length<=e)return s;let i=t.toFixed(e);if(i.length>e&&(i=t.toFixed(Math.max(0,e-(i.length-e)))),i.length<=e&&!i.startsWith("0.000")&&!i.startsWith("-0.000"))return i;let n=t.toExponential(e);return n.length>e&&(n=t.toExponential(Math.max(0,e-(n.length-e)))),n.slice(0)}},5401:(t,e,s)=>{"use strict";function i(t,e){t.prototype.add=function(t){return"number"==typeof t?this.addS(t):this.addM(t)},t.prototype.addS=function(t){for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)+t);return this},t.prototype.addM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)+t.get(e,s));return this},t.add=function(t,s){return new e(t).add(s)},t.prototype.sub=function(t){return"number"==typeof t?this.subS(t):this.subM(t)},t.prototype.subS=function(t){for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)-t);return this},t.prototype.subM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)-t.get(e,s));return this},t.sub=function(t,s){return new e(t).sub(s)},t.prototype.subtract=t.prototype.sub,t.prototype.subtractS=t.prototype.subS,t.prototype.subtractM=t.prototype.subM,t.subtract=t.sub,t.prototype.mul=function(t){return"number"==typeof t?this.mulS(t):this.mulM(t)},t.prototype.mulS=function(t){for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)*t);return this},t.prototype.mulM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)*t.get(e,s));return this},t.mul=function(t,s){return new e(t).mul(s)},t.prototype.multiply=t.prototype.mul,t.prototype.multiplyS=t.prototype.mulS,t.prototype.multiplyM=t.prototype.mulM,t.multiply=t.mul,t.prototype.div=function(t){return"number"==typeof t?this.divS(t):this.divM(t)},t.prototype.divS=function(t){for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)/t);return this},t.prototype.divM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)/t.get(e,s));return this},t.div=function(t,s){return new e(t).div(s)},t.prototype.divide=t.prototype.div,t.prototype.divideS=t.prototype.divS,t.prototype.divideM=t.prototype.divM,t.divide=t.div,t.prototype.mod=function(t){return"number"==typeof t?this.modS(t):this.modM(t)},t.prototype.modS=function(t){for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)%t);return this},t.prototype.modM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)%t.get(e,s));return this},t.mod=function(t,s){return new e(t).mod(s)},t.prototype.modulus=t.prototype.mod,t.prototype.modulusS=t.prototype.modS,t.prototype.modulusM=t.prototype.modM,t.modulus=t.mod,t.prototype.and=function(t){return"number"==typeof t?this.andS(t):this.andM(t)},t.prototype.andS=function(t){for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)&t);return this},t.prototype.andM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)&t.get(e,s));return this},t.and=function(t,s){return new e(t).and(s)},t.prototype.or=function(t){return"number"==typeof t?this.orS(t):this.orM(t)},t.prototype.orS=function(t){for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)|t);return this},t.prototype.orM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)|t.get(e,s));return this},t.or=function(t,s){return new e(t).or(s)},t.prototype.xor=function(t){return"number"==typeof t?this.xorS(t):this.xorM(t)},t.prototype.xorS=function(t){for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)^t);return this},t.prototype.xorM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)^t.get(e,s));return this},t.xor=function(t,s){return new e(t).xor(s)},t.prototype.leftShift=function(t){return"number"==typeof t?this.leftShiftS(t):this.leftShiftM(t)},t.prototype.leftShiftS=function(t){for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)<<t);return this},t.prototype.leftShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)<<t.get(e,s));return this},t.leftShift=function(t,s){return new e(t).leftShift(s)},t.prototype.signPropagatingRightShift=function(t){return"number"==typeof t?this.signPropagatingRightShiftS(t):this.signPropagatingRightShiftM(t)},t.prototype.signPropagatingRightShiftS=function(t){for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)>>t);return this},t.prototype.signPropagatingRightShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)>>t.get(e,s));return this},t.signPropagatingRightShift=function(t,s){return new e(t).signPropagatingRightShift(s)},t.prototype.rightShift=function(t){return"number"==typeof t?this.rightShiftS(t):this.rightShiftM(t)},t.prototype.rightShiftS=function(t){for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)>>>t);return this},t.prototype.rightShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)>>>t.get(e,s));return this},t.rightShift=function(t,s){return new e(t).rightShift(s)},t.prototype.zeroFillRightShift=t.prototype.rightShift,t.prototype.zeroFillRightShiftS=t.prototype.rightShiftS,t.prototype.zeroFillRightShiftM=t.prototype.rightShiftM,t.zeroFillRightShift=t.rightShift,t.prototype.not=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,~this.get(t,e));return this},t.not=function(t){return new e(t).not()},t.prototype.abs=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.abs(this.get(t,e)));return this},t.abs=function(t){return new e(t).abs()},t.prototype.acos=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.acos(this.get(t,e)));return this},t.acos=function(t){return new e(t).acos()},t.prototype.acosh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.acosh(this.get(t,e)));return this},t.acosh=function(t){return new e(t).acosh()},t.prototype.asin=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.asin(this.get(t,e)));return this},t.asin=function(t){return new e(t).asin()},t.prototype.asinh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.asinh(this.get(t,e)));return this},t.asinh=function(t){return new e(t).asinh()},t.prototype.atan=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.atan(this.get(t,e)));return this},t.atan=function(t){return new e(t).atan()},t.prototype.atanh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.atanh(this.get(t,e)));return this},t.atanh=function(t){return new e(t).atanh()},t.prototype.cbrt=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.cbrt(this.get(t,e)));return this},t.cbrt=function(t){return new e(t).cbrt()},t.prototype.ceil=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.ceil(this.get(t,e)));return this},t.ceil=function(t){return new e(t).ceil()},t.prototype.clz32=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.clz32(this.get(t,e)));return this},t.clz32=function(t){return new e(t).clz32()},t.prototype.cos=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.cos(this.get(t,e)));return this},t.cos=function(t){return new e(t).cos()},t.prototype.cosh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.cosh(this.get(t,e)));return this},t.cosh=function(t){return new e(t).cosh()},t.prototype.exp=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.exp(this.get(t,e)));return this},t.exp=function(t){return new e(t).exp()},t.prototype.expm1=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.expm1(this.get(t,e)));return this},t.expm1=function(t){return new e(t).expm1()},t.prototype.floor=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.floor(this.get(t,e)));return this},t.floor=function(t){return new e(t).floor()},t.prototype.fround=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.fround(this.get(t,e)));return this},t.fround=function(t){return new e(t).fround()},t.prototype.log=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log(this.get(t,e)));return this},t.log=function(t){return new e(t).log()},t.prototype.log1p=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log1p(this.get(t,e)));return this},t.log1p=function(t){return new e(t).log1p()},t.prototype.log10=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log10(this.get(t,e)));return this},t.log10=function(t){return new e(t).log10()},t.prototype.log2=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log2(this.get(t,e)));return this},t.log2=function(t){return new e(t).log2()},t.prototype.round=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.round(this.get(t,e)));return this},t.round=function(t){return new e(t).round()},t.prototype.sign=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sign(this.get(t,e)));return this},t.sign=function(t){return new e(t).sign()},t.prototype.sin=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sin(this.get(t,e)));return this},t.sin=function(t){return new e(t).sin()},t.prototype.sinh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sinh(this.get(t,e)));return this},t.sinh=function(t){return new e(t).sinh()},t.prototype.sqrt=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sqrt(this.get(t,e)));return this},t.sqrt=function(t){return new e(t).sqrt()},t.prototype.tan=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.tan(this.get(t,e)));return this},t.tan=function(t){return new e(t).tan()},t.prototype.tanh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.tanh(this.get(t,e)));return this},t.tanh=function(t){return new e(t).tanh()},t.prototype.trunc=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.trunc(this.get(t,e)));return this},t.trunc=function(t){return new e(t).trunc()},t.pow=function(t,s){return new e(t).pow(s)},t.prototype.pow=function(t){return"number"==typeof t?this.powS(t):this.powM(t)},t.prototype.powS=function(t){for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,Math.pow(this.get(e,s),t));return this},t.prototype.powM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,Math.pow(this.get(e,s),t.get(e,s)));return this}}s.d(e,{z:()=>i})},1174:(t,e,s)=>{"use strict";s.d(e,{X:()=>h,Z:()=>u});var i=s(5776),n=s(5408),o=s(3559),r=s(5401),a=s(9515),l=s(3018);class h{static from1DArray(t,e,s){if(t*e!==s.length)throw new RangeError("data length does not match given dimensions");let i=new u(t,e);for(let n=0;n<t;n++)for(let t=0;t<e;t++)i.set(n,t,s[n*e+t]);return i}static rowVector(t){let e=new u(1,t.length);for(let s=0;s<t.length;s++)e.set(0,s,t[s]);return e}static columnVector(t){let e=new u(t.length,1);for(let s=0;s<t.length;s++)e.set(s,0,t[s]);return e}static zeros(t,e){return new u(t,e)}static ones(t,e){return new u(t,e).fill(1)}static rand(t,e,s={}){if("object"!=typeof s)throw new TypeError("options must be an object");const{random:i=Math.random}=s;let n=new u(t,e);for(let s=0;s<t;s++)for(let t=0;t<e;t++)n.set(s,t,i());return n}static randInt(t,e,s={}){if("object"!=typeof s)throw new TypeError("options must be an object");const{min:i=0,max:n=1e3,random:o=Math.random}=s;if(!Number.isInteger(i))throw new TypeError("min must be an integer");if(!Number.isInteger(n))throw new TypeError("max must be an integer");if(i>=n)throw new RangeError("min must be smaller than max");let r=n-i,a=new u(t,e);for(let s=0;s<t;s++)for(let t=0;t<e;t++){let e=i+Math.round(o()*r);a.set(s,t,e)}return a}static eye(t,e,s){void 0===e&&(e=t),void 0===s&&(s=1);let i=Math.min(t,e),n=this.zeros(t,e);for(let t=0;t<i;t++)n.set(t,t,s);return n}static diag(t,e,s){let i=t.length;void 0===e&&(e=i),void 0===s&&(s=e);let n=Math.min(i,e,s),o=this.zeros(e,s);for(let e=0;e<n;e++)o.set(e,e,t[e]);return o}static min(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let s=t.rows,i=t.columns,n=new u(s,i);for(let o=0;o<s;o++)for(let s=0;s<i;s++)n.set(o,s,Math.min(t.get(o,s),e.get(o,s)));return n}static max(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let s=t.rows,i=t.columns,n=new this(s,i);for(let o=0;o<s;o++)for(let s=0;s<i;s++)n.set(o,s,Math.max(t.get(o,s),e.get(o,s)));return n}static checkMatrix(t){return h.isMatrix(t)?t:new u(t)}static isMatrix(t){return null!=t&&"Matrix"===t.klass}get size(){return this.rows*this.columns}apply(t){if("function"!=typeof t)throw new TypeError("callback must be a function");for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)t.call(this,e,s);return this}to1DArray(){let t=[];for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)t.push(this.get(e,s));return t}to2DArray(){let t=[];for(let e=0;e<this.rows;e++){t.push([]);for(let s=0;s<this.columns;s++)t[e].push(this.get(e,s))}return t}toJSON(){return this.to2DArray()}isRowVector(){return 1===this.rows}isColumnVector(){return 1===this.columns}isVector(){return 1===this.rows||1===this.columns}isSquare(){return this.rows===this.columns}isEmpty(){return 0===this.rows||0===this.columns}isSymmetric(){if(this.isSquare()){for(let t=0;t<this.rows;t++)for(let e=0;e<=t;e++)if(this.get(t,e)!==this.get(e,t))return!1;return!0}return!1}isEchelonForm(){let t=0,e=0,s=-1,i=!0,n=!1;for(;t<this.rows&&i;){for(e=0,n=!1;e<this.columns&&!1===n;)0===this.get(t,e)?e++:1===this.get(t,e)&&e>s?(n=!0,s=e):(i=!1,n=!0);t++}return i}isReducedEchelonForm(){let t=0,e=0,s=-1,i=!0,n=!1;for(;t<this.rows&&i;){for(e=0,n=!1;e<this.columns&&!1===n;)0===this.get(t,e)?e++:1===this.get(t,e)&&e>s?(n=!0,s=e):(i=!1,n=!0);for(let s=e+1;s<this.rows;s++)0!==this.get(t,s)&&(i=!1);t++}return i}echelonForm(){let t=this.clone(),e=0,s=0;for(;e<t.rows&&s<t.columns;){let i=e;for(let n=e;n<t.rows;n++)t.get(n,s)>t.get(i,s)&&(i=n);if(0===t.get(i,s))s++;else{t.swapRows(e,i);let n=t.get(e,s);for(let i=s;i<t.columns;i++)t.set(e,i,t.get(e,i)/n);for(let i=e+1;i<t.rows;i++){let n=t.get(i,s)/t.get(e,s);t.set(i,s,0);for(let o=s+1;o<t.columns;o++)t.set(i,o,t.get(i,o)-t.get(e,o)*n)}e++,s++}}return t}reducedEchelonForm(){let t=this.echelonForm(),e=t.columns,s=t.rows,i=s-1;for(;i>=0;)if(0===t.maxRow(i))i--;else{let n=0,o=!1;for(;n<s&&!1===o;)1===t.get(i,n)?o=!0:n++;for(let s=0;s<i;s++){let o=t.get(s,n);for(let r=n;r<e;r++){let e=t.get(s,r)-o*t.get(i,r);t.set(s,r,e)}}i--}return t}set(){throw new Error("set method is unimplemented")}get(){throw new Error("get method is unimplemented")}repeat(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{rows:e=1,columns:s=1}=t;if(!Number.isInteger(e)||e<=0)throw new TypeError("rows must be a positive integer");if(!Number.isInteger(s)||s<=0)throw new TypeError("columns must be a positive integer");let i=new u(this.rows*e,this.columns*s);for(let t=0;t<e;t++)for(let e=0;e<s;e++)i.setSubMatrix(this,this.rows*t,this.columns*e);return i}fill(t){for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,t);return this}neg(){return this.mulS(-1)}getRow(t){(0,l.zb)(this,t);let e=[];for(let s=0;s<this.columns;s++)e.push(this.get(t,s));return e}getRowVector(t){return u.rowVector(this.getRow(t))}setRow(t,e){(0,l.zb)(this,t),e=(0,l.on)(this,e);for(let s=0;s<this.columns;s++)this.set(t,s,e[s]);return this}swapRows(t,e){(0,l.zb)(this,t),(0,l.zb)(this,e);for(let s=0;s<this.columns;s++){let i=this.get(t,s);this.set(t,s,this.get(e,s)),this.set(e,s,i)}return this}getColumn(t){(0,l.bp)(this,t);let e=[];for(let s=0;s<this.rows;s++)e.push(this.get(s,t));return e}getColumnVector(t){return u.columnVector(this.getColumn(t))}setColumn(t,e){(0,l.bp)(this,t),e=(0,l.Um)(this,e);for(let s=0;s<this.rows;s++)this.set(s,t,e[s]);return this}swapColumns(t,e){(0,l.bp)(this,t),(0,l.bp)(this,e);for(let s=0;s<this.rows;s++){let i=this.get(s,t);this.set(s,t,this.get(s,e)),this.set(s,e,i)}return this}addRowVector(t){t=(0,l.on)(this,t);for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)+t[s]);return this}subRowVector(t){t=(0,l.on)(this,t);for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)-t[s]);return this}mulRowVector(t){t=(0,l.on)(this,t);for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)*t[s]);return this}divRowVector(t){t=(0,l.on)(this,t);for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)/t[s]);return this}addColumnVector(t){t=(0,l.Um)(this,t);for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)+t[e]);return this}subColumnVector(t){t=(0,l.Um)(this,t);for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)-t[e]);return this}mulColumnVector(t){t=(0,l.Um)(this,t);for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)*t[e]);return this}divColumnVector(t){t=(0,l.Um)(this,t);for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)/t[e]);return this}mulRow(t,e){(0,l.zb)(this,t);for(let s=0;s<this.columns;s++)this.set(t,s,this.get(t,s)*e);return this}mulColumn(t,e){(0,l.bp)(this,t);for(let s=0;s<this.rows;s++)this.set(s,t,this.get(s,t)*e);return this}max(t){if(this.isEmpty())return NaN;switch(t){case"row":{const t=new Array(this.rows).fill(Number.NEGATIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.get(e,s)>t[e]&&(t[e]=this.get(e,s));return t}case"column":{const t=new Array(this.columns).fill(Number.NEGATIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.get(e,s)>t[s]&&(t[s]=this.get(e,s));return t}case void 0:{let t=this.get(0,0);for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.get(e,s)>t&&(t=this.get(e,s));return t}default:throw new Error(`invalid option: ${t}`)}}maxIndex(){(0,l.cT)(this);let t=this.get(0,0),e=[0,0];for(let s=0;s<this.rows;s++)for(let i=0;i<this.columns;i++)this.get(s,i)>t&&(t=this.get(s,i),e[0]=s,e[1]=i);return e}min(t){if(this.isEmpty())return NaN;switch(t){case"row":{const t=new Array(this.rows).fill(Number.POSITIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.get(e,s)<t[e]&&(t[e]=this.get(e,s));return t}case"column":{const t=new Array(this.columns).fill(Number.POSITIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.get(e,s)<t[s]&&(t[s]=this.get(e,s));return t}case void 0:{let t=this.get(0,0);for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.get(e,s)<t&&(t=this.get(e,s));return t}default:throw new Error(`invalid option: ${t}`)}}minIndex(){(0,l.cT)(this);let t=this.get(0,0),e=[0,0];for(let s=0;s<this.rows;s++)for(let i=0;i<this.columns;i++)this.get(s,i)<t&&(t=this.get(s,i),e[0]=s,e[1]=i);return e}maxRow(t){if((0,l.zb)(this,t),this.isEmpty())return NaN;let e=this.get(t,0);for(let s=1;s<this.columns;s++)this.get(t,s)>e&&(e=this.get(t,s));return e}maxRowIndex(t){(0,l.zb)(this,t),(0,l.cT)(this);let e=this.get(t,0),s=[t,0];for(let i=1;i<this.columns;i++)this.get(t,i)>e&&(e=this.get(t,i),s[1]=i);return s}minRow(t){if((0,l.zb)(this,t),this.isEmpty())return NaN;let e=this.get(t,0);for(let s=1;s<this.columns;s++)this.get(t,s)<e&&(e=this.get(t,s));return e}minRowIndex(t){(0,l.zb)(this,t),(0,l.cT)(this);let e=this.get(t,0),s=[t,0];for(let i=1;i<this.columns;i++)this.get(t,i)<e&&(e=this.get(t,i),s[1]=i);return s}maxColumn(t){if((0,l.bp)(this,t),this.isEmpty())return NaN;let e=this.get(0,t);for(let s=1;s<this.rows;s++)this.get(s,t)>e&&(e=this.get(s,t));return e}maxColumnIndex(t){(0,l.bp)(this,t),(0,l.cT)(this);let e=this.get(0,t),s=[0,t];for(let i=1;i<this.rows;i++)this.get(i,t)>e&&(e=this.get(i,t),s[0]=i);return s}minColumn(t){if((0,l.bp)(this,t),this.isEmpty())return NaN;let e=this.get(0,t);for(let s=1;s<this.rows;s++)this.get(s,t)<e&&(e=this.get(s,t));return e}minColumnIndex(t){(0,l.bp)(this,t),(0,l.cT)(this);let e=this.get(0,t),s=[0,t];for(let i=1;i<this.rows;i++)this.get(i,t)<e&&(e=this.get(i,t),s[0]=i);return s}diag(){let t=Math.min(this.rows,this.columns),e=[];for(let s=0;s<t;s++)e.push(this.get(s,s));return e}norm(t="frobenius"){let e=0;if("max"===t)return this.max();if("frobenius"===t){for(let t=0;t<this.rows;t++)for(let s=0;s<this.columns;s++)e+=this.get(t,s)*this.get(t,s);return Math.sqrt(e)}throw new RangeError(`unknown norm type: ${t}`)}cumulativeSum(){let t=0;for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)t+=this.get(e,s),this.set(e,s,t);return this}dot(t){h.isMatrix(t)&&(t=t.to1DArray());let e=this.to1DArray();if(e.length!==t.length)throw new RangeError("vectors do not have the same size");let s=0;for(let i=0;i<e.length;i++)s+=e[i]*t[i];return s}mmul(t){t=u.checkMatrix(t);let e=this.rows,s=this.columns,i=t.columns,n=new u(e,i),o=new Float64Array(s);for(let r=0;r<i;r++){for(let e=0;e<s;e++)o[e]=t.get(e,r);for(let t=0;t<e;t++){let e=0;for(let i=0;i<s;i++)e+=this.get(t,i)*o[i];n.set(t,r,e)}}return n}strassen2x2(t){t=u.checkMatrix(t);let e=new u(2,2);const s=this.get(0,0),i=t.get(0,0),n=this.get(0,1),o=t.get(0,1),r=this.get(1,0),a=t.get(1,0),l=this.get(1,1),h=t.get(1,1),c=(s+l)*(i+h),m=(r+l)*i,d=s*(o-h),g=l*(a-i),p=(s+n)*h,f=c+g-p+(n-l)*(a+h),y=d+p,b=m+g,w=c-m+d+(r-s)*(i+o);return e.set(0,0,f),e.set(0,1,y),e.set(1,0,b),e.set(1,1,w),e}strassen3x3(t){t=u.checkMatrix(t);let e=new u(3,3);const s=this.get(0,0),i=this.get(0,1),n=this.get(0,2),o=this.get(1,0),r=this.get(1,1),a=this.get(1,2),l=this.get(2,0),h=this.get(2,1),c=this.get(2,2),m=t.get(0,0),d=t.get(0,1),g=t.get(0,2),p=t.get(1,0),f=t.get(1,1),y=t.get(1,2),b=t.get(2,0),w=t.get(2,1),C=t.get(2,2),v=(s-o)*(-d+f),S=(-s+o+r)*(m-d+f),T=(o+r)*(-m+d),M=s*m,A=(-s+l+h)*(m-g+y),E=(-s+l)*(g-y),x=(l+h)*(-m+g),I=(-n+h+c)*(f+b-w),N=(n-c)*(f-w),L=n*b,_=(h+c)*(-b+w),R=(-n+r+a)*(y+b-C),O=(n-a)*(y-C),k=(r+a)*(-b+C),P=M+L+i*p,G=(s+i+n-o-r-h-c)*f+S+T+M+I+L+_,F=M+A+x+(s+i+n-r-a-l-h)*y+L+R+k,H=v+r*(-m+d+p-f-y-b+C)+S+M+L+R+O,V=v+S+T+M+a*w,W=L+R+O+k+o*g,B=M+A+E+h*(-m+g+p-f-y-b+w)+I+N+L,D=I+N+L+_+l*d,U=M+A+E+x+c*C;return e.set(0,0,P),e.set(0,1,G),e.set(0,2,F),e.set(1,0,H),e.set(1,1,V),e.set(1,2,W),e.set(2,0,B),e.set(2,1,D),e.set(2,2,U),e}mmulStrassen(t){t=u.checkMatrix(t);let e=this.clone(),s=e.rows,i=e.columns,n=t.rows,o=t.columns;function r(t,e,s){let i=t.rows,n=t.columns;if(i===e&&n===s)return t;{let i=h.zeros(e,s);return i=i.setSubMatrix(t,0,0),i}}i!==n&&console.warn(`Multiplying ${s} x ${i} and ${n} x ${o} matrix: dimensions do not match.`);let a=Math.max(s,n),l=Math.max(i,o);return e=r(e,a,l),function t(e,s,i,n){if(i<=512||n<=512)return e.mmul(s);i%2==1&&n%2==1?(e=r(e,i+1,n+1),s=r(s,i+1,n+1)):i%2==1?(e=r(e,i+1,n),s=r(s,i+1,n)):n%2==1&&(e=r(e,i,n+1),s=r(s,i,n+1));let o=parseInt(e.rows/2,10),a=parseInt(e.columns/2,10),l=e.subMatrix(0,o-1,0,a-1),c=s.subMatrix(0,o-1,0,a-1),u=e.subMatrix(0,o-1,a,e.columns-1),m=s.subMatrix(0,o-1,a,s.columns-1),d=e.subMatrix(o,e.rows-1,0,a-1),g=s.subMatrix(o,s.rows-1,0,a-1),p=e.subMatrix(o,e.rows-1,a,e.columns-1),f=s.subMatrix(o,s.rows-1,a,s.columns-1),y=t(h.add(l,p),h.add(c,f),o,a),b=t(h.add(d,p),c,o,a),w=t(l,h.sub(m,f),o,a),C=t(p,h.sub(g,c),o,a),v=t(h.add(l,u),f,o,a),S=t(h.sub(d,l),h.add(c,m),o,a),T=t(h.sub(u,p),h.add(g,f),o,a),M=h.add(y,C);M.sub(v),M.add(T);let A=h.add(w,v),E=h.add(b,C),x=h.sub(y,b);x.add(w),x.add(S);let I=h.zeros(2*M.rows,2*M.columns);return I=I.setSubMatrix(M,0,0),I=I.setSubMatrix(A,M.rows,0),I=I.setSubMatrix(E,0,M.columns),I=I.setSubMatrix(x,M.rows,M.columns),I.subMatrix(0,i-1,0,n-1)}(e,t=r(t,a,l),a,l)}scaleRows(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{min:e=0,max:s=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(s))throw new TypeError("max must be a number");if(e>=s)throw new RangeError("min must be smaller than max");let i=new u(this.rows,this.columns);for(let t=0;t<this.rows;t++){const o=this.getRow(t);o.length>0&&(0,n.Z)(o,{min:e,max:s,output:o}),i.setRow(t,o)}return i}scaleColumns(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{min:e=0,max:s=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(s))throw new TypeError("max must be a number");if(e>=s)throw new RangeError("min must be smaller than max");let i=new u(this.rows,this.columns);for(let t=0;t<this.columns;t++){const o=this.getColumn(t);o.length&&(0,n.Z)(o,{min:e,max:s,output:o}),i.setColumn(t,o)}return i}flipRows(){const t=Math.ceil(this.columns/2);for(let e=0;e<this.rows;e++)for(let s=0;s<t;s++){let t=this.get(e,s),i=this.get(e,this.columns-1-s);this.set(e,s,i),this.set(e,this.columns-1-s,t)}return this}flipColumns(){const t=Math.ceil(this.rows/2);for(let e=0;e<this.columns;e++)for(let s=0;s<t;s++){let t=this.get(s,e),i=this.get(this.rows-1-s,e);this.set(s,e,i),this.set(this.rows-1-s,e,t)}return this}kroneckerProduct(t){t=u.checkMatrix(t);let e=this.rows,s=this.columns,i=t.rows,n=t.columns,o=new u(e*i,s*n);for(let r=0;r<e;r++)for(let e=0;e<s;e++)for(let s=0;s<i;s++)for(let a=0;a<n;a++)o.set(i*r+s,n*e+a,this.get(r,e)*t.get(s,a));return o}kroneckerSum(t){if(t=u.checkMatrix(t),!this.isSquare()||!t.isSquare())throw new Error("Kronecker Sum needs two Square Matrices");let e=this.rows,s=t.rows,i=this.kroneckerProduct(u.eye(s,s)),n=u.eye(e,e).kroneckerProduct(t);return i.add(n)}transpose(){let t=new u(this.columns,this.rows);for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)t.set(s,e,this.get(e,s));return t}sortRows(t=c){for(let e=0;e<this.rows;e++)this.setRow(e,this.getRow(e).sort(t));return this}sortColumns(t=c){for(let e=0;e<this.columns;e++)this.setColumn(e,this.getColumn(e).sort(t));return this}subMatrix(t,e,s,i){(0,l.J5)(this,t,e,s,i);let n=new u(e-t+1,i-s+1);for(let o=t;o<=e;o++)for(let e=s;e<=i;e++)n.set(o-t,e-s,this.get(o,e));return n}subMatrixRow(t,e,s){if(void 0===e&&(e=0),void 0===s&&(s=this.columns-1),e>s||e<0||e>=this.columns||s<0||s>=this.columns)throw new RangeError("Argument out of range");let i=new u(t.length,s-e+1);for(let n=0;n<t.length;n++)for(let o=e;o<=s;o++){if(t[n]<0||t[n]>=this.rows)throw new RangeError(`Row index out of range: ${t[n]}`);i.set(n,o-e,this.get(t[n],o))}return i}subMatrixColumn(t,e,s){if(void 0===e&&(e=0),void 0===s&&(s=this.rows-1),e>s||e<0||e>=this.rows||s<0||s>=this.rows)throw new RangeError("Argument out of range");let i=new u(s-e+1,t.length);for(let n=0;n<t.length;n++)for(let o=e;o<=s;o++){if(t[n]<0||t[n]>=this.columns)throw new RangeError(`Column index out of range: ${t[n]}`);i.set(o-e,n,this.get(o,t[n]))}return i}setSubMatrix(t,e,s){if((t=u.checkMatrix(t)).isEmpty())return this;let i=e+t.rows-1,n=s+t.columns-1;(0,l.J5)(this,e,i,s,n);for(let i=0;i<t.rows;i++)for(let n=0;n<t.columns;n++)this.set(e+i,s+n,t.get(i,n));return this}selection(t,e){(0,l.ZR)(this,t),(0,l.g)(this,e);let s=new u(t.length,e.length);for(let i=0;i<t.length;i++){let n=t[i];for(let t=0;t<e.length;t++){let o=e[t];s.set(i,t,this.get(n,o))}}return s}trace(){let t=Math.min(this.rows,this.columns),e=0;for(let s=0;s<t;s++)e+=this.get(s,s);return e}clone(){let t=new u(this.rows,this.columns);for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)t.set(e,s,this.get(e,s));return t}sum(t){switch(t){case"row":return(0,a.bQ)(this);case"column":return(0,a.Dm)(this);case void 0:return(0,a.xo)(this);default:throw new Error(`invalid option: ${t}`)}}product(t){switch(t){case"row":return(0,a.Pw)(this);case"column":return(0,a.PI)(this);case void 0:return(0,a.tT)(this);default:throw new Error(`invalid option: ${t}`)}}mean(t){const e=this.sum(t);switch(t){case"row":for(let t=0;t<this.rows;t++)e[t]/=this.columns;return e;case"column":for(let t=0;t<this.columns;t++)e[t]/=this.rows;return e;case void 0:return e/this.size;default:throw new Error(`invalid option: ${t}`)}}variance(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");const{unbiased:s=!0,mean:n=this.mean(t)}=e;if("boolean"!=typeof s)throw new TypeError("unbiased must be a boolean");switch(t){case"row":if(!(0,i.N)(n))throw new TypeError("mean must be an array");return(0,a.we)(this,s,n);case"column":if(!(0,i.N)(n))throw new TypeError("mean must be an array");return(0,a._G)(this,s,n);case void 0:if("number"!=typeof n)throw new TypeError("mean must be a number");return(0,a.C)(this,s,n);default:throw new Error(`invalid option: ${t}`)}}standardDeviation(t,e){"object"==typeof t&&(e=t,t=void 0);const s=this.variance(t,e);if(void 0===t)return Math.sqrt(s);for(let t=0;t<s.length;t++)s[t]=Math.sqrt(s[t]);return s}center(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");const{center:s=this.mean(t)}=e;switch(t){case"row":if(!(0,i.N)(s))throw new TypeError("center must be an array");return(0,a.rU)(this,s),this;case"column":if(!(0,i.N)(s))throw new TypeError("center must be an array");return(0,a._f)(this,s),this;case void 0:if("number"!=typeof s)throw new TypeError("center must be a number");return(0,a.mm)(this,s),this;default:throw new Error(`invalid option: ${t}`)}}scale(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");let s=e.scale;switch(t){case"row":if(void 0===s)s=(0,a.kn)(this);else if(!(0,i.N)(s))throw new TypeError("scale must be an array");return(0,a.DU)(this,s),this;case"column":if(void 0===s)s=(0,a.Pr)(this);else if(!(0,i.N)(s))throw new TypeError("scale must be an array");return(0,a.Mj)(this,s),this;case void 0:if(void 0===s)s=(0,a.Y2)(this);else if("number"!=typeof s)throw new TypeError("scale must be a number");return(0,a.td)(this,s),this;default:throw new Error(`invalid option: ${t}`)}}toString(t){return(0,o.M)(this,t)}}function c(t,e){return t-e}h.prototype.klass="Matrix","undefined"!=typeof Symbol&&(h.prototype[Symbol.for("nodejs.util.inspect.custom")]=o.V),h.random=h.rand,h.randomInt=h.randInt,h.diagonal=h.diag,h.prototype.diagonal=h.prototype.diag,h.identity=h.eye,h.prototype.negate=h.prototype.neg,h.prototype.tensorProduct=h.prototype.kroneckerProduct;class u extends h{constructor(t,e){if(super(),u.isMatrix(t))return t.clone();if(Number.isInteger(t)&&t>=0){if(this.data=[],!(Number.isInteger(e)&&e>=0))throw new TypeError("nColumns must be a positive integer");for(let s=0;s<t;s++)this.data.push(new Float64Array(e))}else{if(!(0,i.N)(t))throw new TypeError("First argument must be a positive number or an array");{const s=t;if("number"!=typeof(e=(t=s.length)?s[0].length:0))throw new TypeError("Data must be a 2D array with at least one element");this.data=[];for(let i=0;i<t;i++){if(s[i].length!==e)throw new RangeError("Inconsistent array dimensions");if(!s[i].every((t=>"number"==typeof t)))throw new TypeError("Input data contains non-numeric values");this.data.push(Float64Array.from(s[i]))}}}this.rows=t,this.columns=e}set(t,e,s){return this.data[t][e]=s,this}get(t,e){return this.data[t][e]}removeRow(t){return(0,l.zb)(this,t),this.data.splice(t,1),this.rows-=1,this}addRow(t,e){return void 0===e&&(e=t,t=this.rows),(0,l.zb)(this,t,!0),e=Float64Array.from((0,l.on)(this,e)),this.data.splice(t,0,e),this.rows+=1,this}removeColumn(t){(0,l.bp)(this,t);for(let e=0;e<this.rows;e++){const s=new Float64Array(this.columns-1);for(let i=0;i<t;i++)s[i]=this.data[e][i];for(let i=t+1;i<this.columns;i++)s[i-1]=this.data[e][i];this.data[e]=s}return this.columns-=1,this}addColumn(t,e){void 0===e&&(e=t,t=this.columns),(0,l.bp)(this,t,!0),e=(0,l.Um)(this,e);for(let s=0;s<this.rows;s++){const i=new Float64Array(this.columns+1);let n=0;for(;n<t;n++)i[n]=this.data[s][n];for(i[n++]=e[s];n<this.columns+1;n++)i[n]=this.data[s][n-1];this.data[s]=i}return this.columns+=1,this}}(0,r.z)(h,u)},9515:(t,e,s)=>{"use strict";s.d(e,{C:()=>m,DU:()=>y,Dm:()=>o,Mj:()=>w,PI:()=>l,Pr:()=>b,Pw:()=>a,Y2:()=>C,_G:()=>u,_f:()=>g,bQ:()=>n,kn:()=>f,mm:()=>p,rU:()=>d,tT:()=>h,td:()=>v,we:()=>c,xo:()=>r});var i=s(3018);function n(t){let e=(0,i.B4)(t.rows);for(let s=0;s<t.rows;++s)for(let i=0;i<t.columns;++i)e[s]+=t.get(s,i);return e}function o(t){let e=(0,i.B4)(t.columns);for(let s=0;s<t.rows;++s)for(let i=0;i<t.columns;++i)e[i]+=t.get(s,i);return e}function r(t){let e=0;for(let s=0;s<t.rows;s++)for(let i=0;i<t.columns;i++)e+=t.get(s,i);return e}function a(t){let e=(0,i.B4)(t.rows,1);for(let s=0;s<t.rows;++s)for(let i=0;i<t.columns;++i)e[s]*=t.get(s,i);return e}function l(t){let e=(0,i.B4)(t.columns,1);for(let s=0;s<t.rows;++s)for(let i=0;i<t.columns;++i)e[i]*=t.get(s,i);return e}function h(t){let e=1;for(let s=0;s<t.rows;s++)for(let i=0;i<t.columns;i++)e*=t.get(s,i);return e}function c(t,e,s){const i=t.rows,n=t.columns,o=[];for(let r=0;r<i;r++){let i=0,a=0,l=0;for(let e=0;e<n;e++)l=t.get(r,e)-s[r],i+=l,a+=l*l;e?o.push((a-i*i/n)/(n-1)):o.push((a-i*i/n)/n)}return o}function u(t,e,s){const i=t.rows,n=t.columns,o=[];for(let r=0;r<n;r++){let n=0,a=0,l=0;for(let e=0;e<i;e++)l=t.get(e,r)-s[r],n+=l,a+=l*l;e?o.push((a-n*n/i)/(i-1)):o.push((a-n*n/i)/i)}return o}function m(t,e,s){const i=t.rows,n=t.columns,o=i*n;let r=0,a=0,l=0;for(let e=0;e<i;e++)for(let i=0;i<n;i++)l=t.get(e,i)-s,r+=l,a+=l*l;return e?(a-r*r/o)/(o-1):(a-r*r/o)/o}function d(t,e){for(let s=0;s<t.rows;s++)for(let i=0;i<t.columns;i++)t.set(s,i,t.get(s,i)-e[s])}function g(t,e){for(let s=0;s<t.rows;s++)for(let i=0;i<t.columns;i++)t.set(s,i,t.get(s,i)-e[i])}function p(t,e){for(let s=0;s<t.rows;s++)for(let i=0;i<t.columns;i++)t.set(s,i,t.get(s,i)-e)}function f(t){const e=[];for(let s=0;s<t.rows;s++){let i=0;for(let e=0;e<t.columns;e++)i+=Math.pow(t.get(s,e),2)/(t.columns-1);e.push(Math.sqrt(i))}return e}function y(t,e){for(let s=0;s<t.rows;s++)for(let i=0;i<t.columns;i++)t.set(s,i,t.get(s,i)/e[s])}function b(t){const e=[];for(let s=0;s<t.columns;s++){let i=0;for(let e=0;e<t.rows;e++)i+=Math.pow(t.get(e,s),2)/(t.rows-1);e.push(Math.sqrt(i))}return e}function w(t,e){for(let s=0;s<t.rows;s++)for(let i=0;i<t.columns;i++)t.set(s,i,t.get(s,i)/e[i])}function C(t){const e=t.size-1;let s=0;for(let i=0;i<t.columns;i++)for(let n=0;n<t.rows;n++)s+=Math.pow(t.get(n,i),2)/e;return Math.sqrt(s)}function v(t,e){for(let s=0;s<t.rows;s++)for(let i=0;i<t.columns;i++)t.set(s,i,t.get(s,i)/e)}},3018:(t,e,s)=>{"use strict";s.d(e,{B4:()=>u,J5:()=>c,Um:()=>a,ZR:()=>l,bp:()=>o,cT:()=>d,g:()=>h,on:()=>r,zb:()=>n});var i=s(5776);function n(t,e,s){let i=s?t.rows:t.rows-1;if(e<0||e>i)throw new RangeError("Row index out of range")}function o(t,e,s){let i=s?t.columns:t.columns-1;if(e<0||e>i)throw new RangeError("Column index out of range")}function r(t,e){if(e.to1DArray&&(e=e.to1DArray()),e.length!==t.columns)throw new RangeError("vector size must be the same as the number of columns");return e}function a(t,e){if(e.to1DArray&&(e=e.to1DArray()),e.length!==t.rows)throw new RangeError("vector size must be the same as the number of rows");return e}function l(t,e){if(!(0,i.N)(e))throw new TypeError("row indices must be an array");for(let s=0;s<e.length;s++)if(e[s]<0||e[s]>=t.rows)throw new RangeError("row indices are out of range")}function h(t,e){if(!(0,i.N)(e))throw new TypeError("column indices must be an array");for(let s=0;s<e.length;s++)if(e[s]<0||e[s]>=t.columns)throw new RangeError("column indices are out of range")}function c(t,e,s,i,n){if(5!==arguments.length)throw new RangeError("expected 4 arguments");if(m("startRow",e),m("endRow",s),m("startColumn",i),m("endColumn",n),e>s||i>n||e<0||e>=t.rows||s<0||s>=t.rows||i<0||i>=t.columns||n<0||n>=t.columns)throw new RangeError("Submatrix indices are out of range")}function u(t,e=0){let s=[];for(let i=0;i<t;i++)s.push(e);return s}function m(t,e){if("number"!=typeof e)throw new TypeError(`${t} must be a number`)}function d(t){if(t.isEmpty())throw new Error("Empty matrix has no elements to index")}},8353:(t,e,s)=>{"use strict";s.d(e,{Z:()=>n});var i=s(1174);class n extends i.X{constructor(t){super(),this.data=t,this.rows=t.length,this.columns=t[0].length}set(t,e,s){return this.data[t][e]=s,this}get(t,e){return this.data[t][e]}}},3379:t=>{"use strict";var e=[];function s(t){for(var s=-1,i=0;i<e.length;i++)if(e[i].identifier===t){s=i;break}return s}function i(t,i){for(var o={},r=[],a=0;a<t.length;a++){var l=t[a],h=i.base?l[0]+i.base:l[0],c=o[h]||0,u="".concat(h," ").concat(c);o[h]=c+1;var m=s(u),d={css:l[1],media:l[2],sourceMap:l[3],supports:l[4],layer:l[5]};if(-1!==m)e[m].references++,e[m].updater(d);else{var g=n(d,i);i.byIndex=a,e.splice(a,0,{identifier:u,updater:g,references:1})}r.push(u)}return r}function n(t,e){var s=e.domAPI(e);return s.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;s.update(t=e)}else s.remove()}}t.exports=function(t,n){var o=i(t=t||[],n=n||{});return function(t){t=t||[];for(var r=0;r<o.length;r++){var a=s(o[r]);e[a].references--}for(var l=i(t,n),h=0;h<o.length;h++){var c=s(o[h]);0===e[c].references&&(e[c].updater(),e.splice(c,1))}o=l}}},569:t=>{"use strict";var e={};t.exports=function(t,s){var i=function(t){if(void 0===e[t]){var s=document.querySelector(t);if(window.HTMLIFrameElement&&s instanceof window.HTMLIFrameElement)try{s=s.contentDocument.head}catch(t){s=null}e[t]=s}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(s)}},9216:t=>{"use strict";t.exports=function(t){var e=document.createElement("style");return t.setAttributes(e,t.attributes),t.insert(e,t.options),e}},3565:(t,e,s)=>{"use strict";t.exports=function(t){var e=s.nc;e&&t.setAttribute("nonce",e)}},7795:t=>{"use strict";t.exports=function(t){if("undefined"==typeof document)return{update:function(){},remove:function(){}};var e=t.insertStyleElement(t);return{update:function(s){!function(t,e,s){var i="";s.supports&&(i+="@supports (".concat(s.supports,") {")),s.media&&(i+="@media ".concat(s.media," {"));var n=void 0!==s.layer;n&&(i+="@layer".concat(s.layer.length>0?" ".concat(s.layer):""," {")),i+=s.css,n&&(i+="}"),s.media&&(i+="}"),s.supports&&(i+="}");var o=s.sourceMap;o&&"undefined"!=typeof btoa&&(i+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(o))))," */")),e.styleTagTransform(i,t,e.options)}(e,t,s)},remove:function(){!function(t){if(null===t.parentNode)return!1;t.parentNode.removeChild(t)}(e)}}}},4589:t=>{"use strict";t.exports=function(t,e){if(e.styleSheet)e.styleSheet.cssText=t;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(t))}}},7241:(t,e,s)=>{"use strict";s.d(e,{D:()=>c});var i=s(4469),n=s(976),o=s(6414),r=s.n(o),a=s(2904),l=s(499);const h=31;async function c(t,e=!1,s){const o=l.Cn.getOrCreate(t);let c;s??(s=new Map);const m=o.isHelm()?(0,a.getHelmMonomers)(t):Object.keys(o.stats.freq).filter((t=>""!==t));for(let t=0;t<m.length;t++)s.has(m[t])||s.set(m[t],`${s.size+1}`);if(o.isHelm())c=await i.functions.call("HELM:getMolFiles",{col:t}),c=function(t,e,s=!1){const i=new Array(t.length);for(let n=0;n<t.length;n++){let o=0,r=0,a="\n Datagrok macromolecule handler\n\n 0 0 0 0 0 0 999 V3000\nM V30 BEGIN CTAB\n";const l=t.get(n);o=l.indexOf("\n",o)+1,o=l.indexOf("\n",o)+1,o=l.indexOf("\n",o)+1;const c=parseInt(l.substring(o,o+3)),u=parseInt(l.substring(o+3,o+6));a+=`M V30 COUNTS ${c} ${u} 0 0 0\n`,a+="M V30 BEGIN ATOM\n";for(let t=0;t<c;t++){o=l.indexOf("\n",o)+1+h,r=l.indexOf(" ",o);const i=l.substring(o,r);a+=s?`M V30 ${t+1} R${e.get(i)} 0.000 0.000 0 0\n`:`M V30 ${t+1} At 0.000 0.000 0 0 MASS=${e.get(i)}\n`}a+="M V30 END ATOM\n",a+="M V30 BEGIN BOND\n";for(let t=0;t<u;t++){o=l.indexOf("\n",o)+1;const e=parseInt(l.substring(o,o+3).trim()),s=parseInt(l.substring(o+3,o+6).trim());a+=`M V30 ${t+1} ${parseInt(l.substring(o+6,o+9).trim())} ${e} ${s}\n`}a+="M V30 END BOND\n",a+="M V30 END CTAB\n",a+="M END",i[n]=a}return i}(c,s,e);else{c=new Array(t.length);for(let i=0;i<t.length;i++){const t=u(r()(o.splitted[i]).filter((t=>""!==t)).toArray(),s,e);c[i]=t}}return n.Column.fromStrings("monomericMols",c)}function u(t,e,s=!1){let i="\n Datagrok macromolecule handler\n\n 0 0 0 0 0 0 999 V3000\nM V30 BEGIN CTAB\n";i+=`M V30 COUNTS ${t.length} ${t.length?t.length-1:0} 0 0 0\n`,i+="M V30 BEGIN ATOM\n";for(let n=0;n<t.length;n++)i+=s?`M V30 ${n+1} R${e.get(t[n])} 0.000 0.000 0 0\n`:`M V30 ${n+1} At 0.000 0.000 0 0 MASS=${e.get(t[n])}\n`;i+="M V30 END ATOM\n",i+="M V30 BEGIN BOND\n";for(let e=0;e<t.length-1;e++)i+=`M V30 ${e+1} 1 ${e+1} ${e+2}\n`;return i+="M V30 END BOND\n",i+="M V30 END CTAB\n",i+="M END",i}},2904:(t,e,s)=>{"use strict";s.r(e),s.d(e,{BYPASS_LARGE_DATA_WARNING:()=>Ke,GetRegionEditor:()=>os,SeqActivityCliffsEditor:()=>ls,SeqPaletteCustom:()=>Qe,SequenceSpaceEditor:()=>as,SplitToMonomersEditor:()=>rs,SubsequenceSearchTopMenu:()=>Hs,_package:()=>$e,activityCliffs:()=>Cs,addCopyMenu:()=>zs,alignSequences:()=>Ms,bioSubstructureFilter:()=>Ds,compositionAnalysis:()=>As,compositionAnalysisWidget:()=>ms,convertDialog:()=>Is,demoBioActivityCliffs:()=>$s,demoBioAtomicLevel:()=>Ks,demoBioHelmMsaSequenceSpace:()=>js,demoBioSequenceSpace:()=>qs,demoBioSimilarityDiversity:()=>Xs,diversitySearchTopMenu:()=>Gs,diversitySearchViewer:()=>Ps,enumeratorColumnChoice:()=>Js,fastaSequenceCellRenderer:()=>cs,getBioLib:()=>ss,getEnumeratorWidget:()=>Qs,getHelmMonomers:()=>Rs,getMonomerLibHelper:()=>je,getRegion:()=>bs,getRegionApp:()=>Zs,getRegionHelmApp:()=>Ys,getRegionPanel:()=>is,getRegionTopMenu:()=>ws,hydrophobPalette:()=>Je,importBam:()=>xs,importFasta:()=>Es,initBio:()=>ts,libraryPanel:()=>ns,macroMolColumnPropertyPanel:()=>us,macromoleculeDifferenceCellRenderer:()=>gs,monomerCellRenderer:()=>Ns,multipleSequenceAlignmentDialog:()=>Ts,packageSettingsEditor:()=>hs,saveAsFasta:()=>Bs,sdfToJsonLib:()=>ti,searchSubsequenceEditor:()=>Fs,separatorSequenceCellRenderer:()=>ds,sequenceAlignment:()=>ps,sequenceIdentityScoring:()=>Vs,sequenceSimilarityScoring:()=>Ws,sequenceSpaceTopMenu:()=>vs,sequenceTooltip:()=>es,similaritySearchTopMenu:()=>ks,similaritySearchViewer:()=>Os,splitToMonomersTopMenu:()=>_s,testDetectMacromolecule:()=>Ls,toAtomicLevel:()=>Ss,vdRegionsViewer:()=>ys,webLogoLargeApp:()=>Us,webLogoViewer:()=>fs});var i=s(4469),n=s(3870),o=s(976),r=s(6414),a=s.n(r),l=s(585);const h="rgb(100,100,100)",c="#808080",u="rgb(0,0,0)",m=l.GU;var d,g;function p(t,e,s,i,n,o,r=h,a=0,l=!1,d=1,p="",f=!1,y=g.classic,b=[],w=0,C=null,v=[],S=null,T={}){n.textAlign="start";let M=o.substring(0),A=f?"":p;y===g.MSA&&(A="");let E=!0,x=!0,I="difference";null!=C&&null!=C.cell.column&&(E=C.cell.column.temp["color-code"]??!0,x=C.cell.column.temp["compare-with-current"]??!0,I=C.cell.column.temp["highlight-difference"]??"difference");const N=v[w];x&&v.length>0&&"difference"===I&&(d=M==N?.3:d),x&&v.length>0&&"equal"===I&&(d=M!=N?.3:d),null!=S&&(M=m(M,S));const L=M+A;T[L]??(T[L]=n.measureText(L));let _=T[L];T[M]??(T[M]=n.measureText(M));let R=T[M].width;T[A]??(T[A]=n.measureText(A));const O=T[A].width,k=i/2-(_.fontBoundingBoxAscent+_.fontBoundingBoxDescent)/2+1;function P(s,i){const o=E?r:u;n.fillStyle=o,n.globalAlpha=d,y===g.classic&&(n.fillText(M,t+s,e+k),n.fillStyle=c,n.fillText(A,t+i,e+k)),y===g.MSA&&n.fillText(M,t+s,e+k)}_=_.width,y===g.MSA&&(R=b[w],_=b[w]);const G=(b[w]??0)-(b[0]??0);if(l||_>s)return P(G,G+R),t+G+R+O;{const e=(s-_)/2;return P(e,e+R),t+G+e+R}}!function(t){t.maxMonomerLength=".mm.cellRenderer.maxMonomerLength"}(d||(d={})),function(t){t.MSA="MSA",t.classic="classic"}(g||(g={}));var f,y=s(9611),b=s(8447),w=s(7331),C=s(499);!function(t){t.long="long",t.short="short"}(f||(f={}));const v={true:"1",false:"0"};var S=s(3553);const T="rgb(100,100,100)",M=b.GU;function A(t,e,s,i,n){return t?Math.max(Math.min(t.canvas.width/n-s,i)):Math.max(e.canvas.width/n-s,0)}function E(t){const e=!a().enumerate(t).some((([e,s])=>e.length>1&&0!=s&&s!=t.length-1)),s=[],i=e?"":" ";for(const[e,n]of a().enumerate(t)){let o=e;n<t.length&&(o+=`${e?"":"-"}${i}`),s.push(o)}return[s,e]}class x extends o.GridCellRenderer{constructor(){super(...arguments),this.padding=5}get name(){return"sequence"}get cellType(){return"sequence"}get defaultHeight(){return 30}get defaultWidth(){return 230}onClick(t,e){t.cell.column.temp["current-word"]=t.cell.value,t.grid.invalidate()}onMouseMove(t,e){const s=t.cell.column.temp["bio-seqCol"];if(!s)return;const o=t.bounds,r=e.offsetX-t.gridColumn.left+(t.gridColumn.left-o.x),a=s.getPosition(t.tableRowIndex,r),l=s.getSeqMonList(t.tableRowIndex);if(null!==a&&a<l.length){const t=l[a],o=[n.div(t)];if(s._monomerStructureMap[t])o.push(s._monomerStructureMap[t]);else{const e=s.getMonomer(t);if(e){const n={autoCrop:!0,autoCropMargin:0,suppressChiralText:!0},r=i.chem.svgMol(e.smiles,void 0,void 0,n);o.push(r),s._monomerStructureMap[t]=r}}n.tooltip.show(n.divV(o),e.x+16,e.y+16)}else n.tooltip.hide()}render(t,e,s,i,n,r,l){let h=0,c=50;const u=r.grid,m=r.cell.column;if(!u||!m)return;const f=m.temp,w=f["monomer-width"];if("short"===(null!=w?w:"short")){const t=parseInt(m.getTag(d.maxMonomerLength));c=(isNaN(t)?$e.properties?.MaxMonomerLength:t)??4}let S=m.temp["bio-seqCol"];S||(S=new y.A(u,m,(()=>{const t=C.Cn.getOrCreate(m);return{unitsHandler:t,monomerCharWidth:7,separatorWidth:t.isMsa()?8:h,monomerToShort:M,monomerLengthLimit:c,monomerLib:ss()}}))),m.tags[".mm.cellRenderer.settingsChanged"]===v.true&&(h=f[".mm.cellRenderer.gapLength"]??h,S.setMonomerLengthLimit(c),S.setSeparatorWidth(S.isMsa()?8:h),m.setTag(".mm.cellRenderer.settingsChanged",v.false));const[E,x]=S.getCellMonomerLengths(r.tableRowIndex);E.length,S.updated&&(f["bio-seqCol"]=S),t.save();try{const l=window.devicePixelRatio,h=-1!==r.gridRow?r.grid:null,u=r.cell.value,d=m.getTag("alphabet"),y=50;i=A(h,t,e,i,l),t.beginPath(),t.rect(e+this.padding,s+this.padding,i-this.padding-1,n-2*this.padding),t.clip(),t.font="12px monospace",t.textBaseline="top";const w=m.getTag(o.TAGS.UNITS),v=m.getTag("aligned"),M=(0,b.py)(d),E=m.getTag("separator")??"",I=i/5,N=C.Cn.getOrCreate(m).getSplitter(I),L=f["reference-sequence"],_=f["current-word"],R=N(null!=L&&""!=L?L:_??""),O=N(u);let k=T,P=g.classic;v&&v.includes("MSA")&&w==b.r2.SEPARATOR&&(P=g.MSA);for(const[o,l]of a().enumerate(O)){k=M.get(o),t.fillStyle=T;const a=l===O.length-1;if(p(e+this.padding,s,i,n,t,o,k,0,!0,1,E,a,P,x,l,r,R,c,S._monomerLengthMap),y>i)break}}catch(t){const e=t instanceof Error?t.message:t?t.toString():"Error 'undefined'";$e.logger.error(`Bio: MacromoleculeSequenceCellRenderer.render() error: ${e}`)}finally{t.restore()}}}class I extends o.GridCellRenderer{get name(){return"MacromoleculeDifferenceCR"}get cellType(){return S.Of.MACROMOLECULE_DIFFERENCE}get defaultHeight(){return 30}get defaultWidth(){return 230}render(t,e,s,i,n,r,a){const h=window.devicePixelRatio,c=r.grid,u=r.cell,m=r.tableColumn,d=u.value??"",g=m.tags.separator,p=m.tags[o.TAGS.UNITS];i=A(c,t,e,i,h);const[f,y]=d.split("#"),b=(0,l.vU)(p,g);N(t,e,s,i,n,b(f),b(y),p)}}function N(t,e,s,i,n,o,r,l,h,c){if(o.length!==r.length){const t=function(t,e){let s=0,i=0;const n=t.length>e.length?t:e,o=t.length>e.length?e:t;for(let t=0;t<o.length;t++)n[t]===o[t]&&s++;const r=n.length-o.length;for(let t=n.length-1;t>r;t--)n[t]===o[t-r]&&i++;const a=new Array(Math.abs(t.length-e.length)).fill("");function l(t){return s>i?t.concat(a):a.concat(t)}return t.length>e.length?e=l(e):t=l(t),{subParts1:t,subParts2:e}}(a()(o).toArray(),a()(r).toArray());o=t.subParts1,r=t.subParts2}const u=t.measureText(E(o).join("")),m=t.measureText(E(r).join("")),d=Math.max(u.width,m.width);h&&(i=d+4*o.length,t.canvas.width=d+4*o.length);let g=Math.max(e,e+(i-(d+4*o.length))/2)+5;const f=Math.max(s,s+(n-28)/2);t.save(),t.beginPath(),t.rect(e,s,h?d+4*o.length:i,n),t.clip(),t.font="12px monospace",t.textBaseline="top";let y=w.UE.Color;"HELM"!=l&&(y=(0,b.py)(l.substring(l.length-2)));for(let e=0;e<o.length;e++){const s=o[e],a=r[e],l=y.get(s);if(s!=a){const o=y.get(a),r=p(g,f-7,i,n,t,s,l,0,!0),h=p(g,f+7,i,n,t,a,o,0,!0);g=Math.max(h,r),c&&(c[e]=L(s,a,l,o,f,7,n))}else g=p(g,f,i,n,t,s,l,0,!0,.5);g+=4}t.restore()}function L(t,e,s,i,n,o,r){const a=document.createElement("canvas"),l=a.getContext("2d");l.font="12px monospace";const h=l.measureText(E([t]).join("")).width,c=l.measureText(E([e]).join("")).width,u=Math.max(h,c);return a.height=r,a.width=u+4,l.font="12px monospace",l.textBaseline="top",p(0,n-o,u,r,l,t,s,0,!0),p(0,n+o,u,r,l,e,i,0,!0),a}var _,R=s(701),O=s(9298);!function(t){t.Unknown="unknown",t.FR="framework",t.CDR="cdr"}(_||(_={}));const k=new class{constructor(){this.regionTypes=[_.CDR],this.chains=["Heavy","Light"],this.skipEmptyPositions=!1,this.fitWidth=!1,this.positionWidth=16,this.positionHeight=O.ES.Entropy,this.filterSource=O.vS.filterSource}};var P=s(833);const G=_;var F,H;!function(t){t.STYLE="Style",t.BEHAVIOR="Behavior",t.LAYOUT="Layout",t.DATA="Data"}(F||(F={})),function(t){t.skipEmptyPositions="skipEmptyPositions",t.regionTypes="regionTypes",t.chains="chains",t.fitWidth="fitWidth",t.positionWidth="positionWidth",t.positionHeight="positionHeight",t.filterSource="filterSource"}(H||(H={}));const V=k;class W extends o.JsViewer{constructor(){super(),this.viewed=!1,this.regionsFg=null,this.regionsRoot=null,this.isOpened=!1,this.panelNode=null,this.regions=[],this.viewPromise=Promise.resolve(),this.detachPromise=Promise.resolve(),this.setDataInProgress=!1,this.host=null,this.mainLayout=null,this.logos=[],this.viewSubs=[],this.calcSizeRequested=!1,this.skipEmptyPositions=this.bool(H.skipEmptyPositions,V.skipEmptyPositions,{category:F.DATA}),this.regionTypes=this.stringList(H.regionTypes,V.regionTypes,{category:F.DATA,choices:Object.values(G).filter((t=>t!=G.Unknown))}),this.chains=this.stringList(H.chains,V.chains,{category:F.DATA,choices:["Heavy","Light"]}),this.fitWidth=this.bool(H.fitWidth,V.fitWidth,{category:F.LAYOUT}),this.positionWidth=this.float(H.positionWidth,V.positionWidth,{category:F.LAYOUT,editor:"slider",min:0,max:64,description:"Internal WebLogo viewers property width of position."}),this.positionHeight=this.string(H.positionHeight,V.positionHeight,{category:F.LAYOUT,choices:Object.keys(O.ES)}),this.filterSource=this.string(H.filterSource,V.filterSource,{category:F.BEHAVIOR,choices:Object.values(O.Ct)})}async init(){this.subs.push((0,R.fromEvent)(this.root,"mousemove").subscribe(this.rootOnMouseMove.bind(this)))}detach(){if(this.setDataInProgress)return;const t=super.detach.bind(this);this.detachPromise=this.detachPromise.then((async()=>{await this.viewPromise,this.viewed&&(await this.destroyView("detach"),this.viewed=!1),t()}))}onTableAttached(){super.onTableAttached(),this.setData(this.dataFrame,this.regions)}onPropertyChanged(t){if(super.onPropertyChanged(t),t){switch(t.name){case H.regionTypes:case H.chains:this.setData(this.dataFrame,this.regions)}switch(t.name){case H.skipEmptyPositions:for(let t=0;t<this.logos.length;++t)for(const e of this.chains)this.logos[t][e].setOptions({[P.bo.skipEmptyPositions]:this.skipEmptyPositions});this.calcSize();break;case H.fitWidth:case H.positionWidth:this.calcSize();break;case H.positionHeight:for(let t=0;t<this.logos.length;++t)for(const e of this.chains)this.logos[t][e].setOptions({[P.bo.positionHeight]:this.positionHeight});this.calcSize();break;case H.filterSource:this.filterSourceInput.value=this.filterSource;break;default:this.setData(this.dataFrame,this.regions)}}else console.warn("Bio: VdRegionsViewer.onPropertyChanged() property is null")}setData(t,e){this.setDataInProgress||(this.setDataInProgress=!0,$e.logger.debug("Bio: VdRegionsViewer.setData()"),this.viewPromise=this.viewPromise.then((async()=>{this.viewed&&(await this.destroyView("setData"),this.viewed=!1)})).then((async()=>{await this.detachPromise,this.regions=e,this.dataFrame.dart!==t.dart&&(this.dataFrame=t)})).then((async()=>{this.viewed||(await this.buildView("setData"),this.viewed=!0)})).catch((t=>{const e=t instanceof Error?t.message:t.toString(),s=t instanceof Error?t.stack:void 0;i.shell.error(e),$e.logger.error(e,void 0,s)})).finally((()=>{this.setDataInProgress=!1})))}async destroyView(t){$e.logger.debug(`Bio: VdRegionsViewer.destroyView( mainLayout = ${this.mainLayout?"value":"none"} ), purpose = '${t}'`),this.filterSourceInput&&n.empty(this.filterSourceInput.root),null!=this.mainLayout&&(this.mainLayout.remove(),this.host.remove(),this.host=null,this.mainLayout=null);for(const t of this.viewSubs)t.unsubscribe()}async buildView(t){$e.logger.debug(`Bio: VdRegionsViewer.buildView() begin, purpose = '${t}'`);const e=this.regions.filter((t=>this.regionTypes.includes(t.type))),s=Array.from(new Set(e.map((t=>t.order)))).sort(),i=[];for(let t=0;t<s.length;t++)for(const n of this.chains){const o=e.find((e=>e.order==s[t]&&e.chain==n));i.push((async()=>{const e=await this.dataFrame.plot.fromType("WebLogo",{sequenceColumnName:o.sequenceColumnName,startPositionName:o.positionStartName,endPositionName:o.positionEndName,fixWidth:!0,skipEmptyPositions:this.skipEmptyPositions,positionWidth:this.positionWidth,positionHeight:this.positionHeight,filterSource:this.filterSource});return e.onSizeChanged.subscribe((()=>{this.calcSize()})),[t,n,e]})())}const o=await Promise.all(i);this.logos=new Array(s.length);for(let t=0;t<s.length;++t)this.logos[t]={};for(const[t,e,s]of o)this.logos[t][e]=s,this.viewSubs.push(s.onFreqsCalculated.subscribe((()=>{this.calcSize()})));this.mainLayout=n.table(this.chains,(t=>[...s.length>0?[n.div(t,{style:{transform:"rotate(-90deg)",font:"12px Roboto, Roboto Local, sans-serif",textAlign:"center",width:"16px",marginTop:"24px",marginLeft:"6px"}})]:[],...[...Array(s.length).keys()].map((e=>{const s=this.logos[e][t];return s.root.style.height="100%",n.div([s.root],{style:{marginTop:"4px",marginBottom:"4px"}})}))]),["",...[...Array(s.length).keys()].map((t=>e.find((e=>e.order==s[t]&&e.chain==this.chains[0])).name||"Name"))]),this.mainLayout.className="mlb-vd-regions-viewer-table2",this.filterSourceInput=n.choiceInput("Data source",this.filterSource,Object.values(O.Ct),this.filterSourceInputOnValueChanged.bind(this)),this.filterSourceInput.root.style.position="absolute",this.filterSourceInput.root.style.right="9px",this.filterSourceInput.root.style.top="-4px",Math.ceil(255*Math.random()).toString(16),this.host=n.div([this.mainLayout,this.filterSourceInput.root],{}),this.root.appendChild(this.host),this.root.style.overflowX="auto",this.calcSize(),this.viewSubs.push(n.onSizeChanged(this.root).subscribe(this.rootOnSizeChanged.bind(this))),$e.logger.debug("Bio: VdRegionsViewer.buildView() end")}calcSize(){$e.logger.debug("Bio: VdRegionsViewer.calcSize(), start");const t=()=>{if(!this.host)return;const t=(this.root.clientHeight-54)/this.chains.length;let e=0;for(let s=0;s<this.logos.length;s++){for(const e of this.chains)this.logos[s][e].root.style.height=`${t}px`;e+=Math.max(...this.chains.map((t=>this.logos[s][t].Length)))}if(this.fitWidth){if(this.logos.length>0&&e>0){const t=22,s=13,i=9,n=(this.root.clientWidth-t-(this.logos.length-1)*i-s)/e;for(let t=0;t<this.logos.length;t++)for(const e of this.chains){const s=this.logos[t][e];s.setOptions({[P.bo.positionWidth]:n-s.positionMarginValue}),s.root.style.width=n*s.Length+"px"}}this.host.style.setProperty("overflow","hidden","important")}else{for(let t=0;t<this.logos.length;t++)for(const e of this.chains)this.logos[t][e].setOptions({[P.bo.positionWidth]:this.positionWidth});this.host.style.removeProperty("overflow")}0===this.positionWidth?this.host.style.setProperty("overflow-x","hidden","important"):this.host.style.removeProperty("overflow-x")};this.calcSizeRequested||(this.calcSizeRequested=!0,window.setTimeout((()=>{t(),this.calcSizeRequested=!1}),0))}rootOnSizeChanged(t){this.calcSize()}rootOnMouseMove(t){}filterSourceInputOnValueChanged(){const t=this.filterSourceInput.value;this.viewPromise=this.viewPromise.then((()=>{if(this.filterSource!==t){this.props.getProperty(H.filterSource).set(this,t);for(let t=0;t<this.logos.length;t++)for(let e=0;e<this.chains.length;e++){const s=this.chains[e];this.logos[t][s].setOptions({[P.bo.filterSource]:this.filterSource})}}}))}}var B=s(9017),D=s(850);const U="dimensionality-reducer-terminate-event";async function Z(t,e,n,o,r,a){const l=await async function(t,e,n,o,r){return new Promise((function(a,l){const h=new Worker(new URL(s.p+s.u(196),s.b));h.postMessage({columnData:t.data,method:e,measure:t.metric,options:n,parallelDistanceWorkers:o});const c=i.events.onCustomEvent(U).subscribe((()=>{try{h?.terminate()}finally{c.unsubscribe()}}));h.onmessage=({data:{error:t,distance:e,embedding:s,epochNum:i,epochsLength:n}})=>{i&&n?r&&r(i,n,s):(c.unsubscribe(),t?l(t):a({distance:e,embedding:s}),setTimeout((()=>h.terminate()),0))}}))}({data:t,metric:n},e,o,r,a);return l.embedding=l.embedding.map((t=>(0,D.Fv)(t))),l}var Y=s(7983),z=s(7228),X=s(489);async function q(t,e){const s=C.Cn.getOrCreate(t.seqCol),i=t.seqCol.toList(),n=s.getSplitter(),r=i.length;let a=36;const l=new Map;for(let e=0;e<r;e++){const s=i[e];if(null===i[e]||t.seqCol.isNone(e)){i[e]=null;continue}i[e]="";const o=n(s);for(let t=0;t<o.length;t++){const s=o[t];l.has(s)||(l.set(s,String.fromCharCode(a)),a++),i[e]+=l.get(s)}}if(t.similarityMetric===X.U.MONOMER_CHEMICAL_DISTANCE){const e=Array.from(l.keys()),s=await(0,z.PF)(e);s.scoringMatrix.forEach(((t,e)=>{t.forEach(((t,i)=>{s.scoringMatrix[e][i]=1-t}))}));const i={};Object.entries(s.alphabetIndexes).forEach((([t,e])=>{i[l.get(t)]=e})),t.options.distanceFnArgs={scoringMatrix:s.scoringMatrix,alphabetIndexes:i}}const h=await Z(i,t.methodName,t.similarityMetric,t.options,!0,e),c=t.embedAxesNames.map(((t,e)=>o.Column.fromFloat32Array(t,h.embedding[e])));return{distance:h.distance,coordinates:new o.ColumnList(c)}}function $(t){const e=["Embed_X","Embed_Y"],s=t.columns.names().filter((t=>t.includes(e[0]))).length+1;return e.map((t=>`${t}_${s}`))}var K=s(5697),j=s(3379),J=s.n(j),Q=s(7795),tt=s.n(Q),et=s(569),st=s.n(et),it=s(3565),nt=s.n(it),ot=s(9216),rt=s.n(ot),at=s(4589),lt=s.n(at),ht=s(9414),ct={};ct.styleTagTransform=lt(),ct.setAttributes=nt(),ct.insert=st().bind(null,"head"),ct.domAPI=tt(),ct.insertStyleElement=rt(),J()(ht.Z,ct),ht.Z&&ht.Z.locals&&ht.Z.locals;var ut=s(3914),mt=s(6254);let dt=0;const gt="cliffsDf",pt=new R.Subject,ft="act_diff",yt="sali",bt="sim",wt="line_index",Ct=["1_seq","2_seq"],vt="filterCliffs";function St(t,e,s){const i=e.getBoundingClientRect(),n=t.clientX-i.left,o=t.clientY-i.top;let r=null,a=0;for(const t of s){const e=Math.abs(Math.hypot(t.a[0]-n,t.a[1]-o)+Math.hypot(t.b[0]-n,t.b[1]-o)-Math.hypot(t.a[0]-t.b[0],t.a[1]-t.b[1]));(!a&&e<2||e<a)&&(a=e,r=t)}return r}var Tt=s(6361);async function Mt(t,e,s,n,r){e.version!==e.temp["last-invalidated-version"]&&await(0,Y.HV)(e,!1);const a=o.DataFrame.create(e.length);return a.columns.addNewString(n).init((t=>e.temp["monomeric-mols"].get(t))),await i.functions.call("Chem:getChemSimilaritiesMatrix",{dim:t,col:e.temp["monomeric-mols"],df:a,colName:n,simArr:r})}function At(t){const e=n.divH([]),s=n.divV([n.divText(t.seqCol.name),n.divText(t.activityCol.name)]);return s.style.fontWeight="bold",s.style.display="flex",s.style.justifyContent="space-between",e.append(s),t.line.mols.forEach(((s,i)=>{const o=n.divText(t.activityCol.get(s).toFixed(2));o.style.display="flex",o.style.justifyContent="left",o.style.paddingLeft="30px",e.append(n.divV([n.divText(t.seqCol.get(s)),o]))})),e}function Et(t){const e=n.div();e.append(n.divText(t.seqCol.name,{style:{fontWeight:"bold"}}));const s=new Array(2),i=new Array(2);t.line.mols.forEach(((e,n)=>{s[n]=t.seqCol.get(e),i[n]=t.activityCol.get(e)}));const o={},r=C.Cn.getOrCreate(t.seqCol),a=r.getSplitter(),l=It(a(s[0]),a(s[1]),r.units,o);return e.append(n.div(l,{style:{width:"300px",overflow:"scroll"}})),e.append(Nt(o)),e.append(xt("Activity delta",Math.abs(i[0]-i[1]))),e.append(xt("Cliff",t.sali)),e}function xt(t,e){return n.divH([n.divText(`${t}: `,{style:{fontWeight:"bold",paddingRight:"5px"}}),n.divText(e.toFixed(2))],{style:{paddingTop:"10px"}})}function It(t,e,s,i){const n=document.createElement("canvas"),o=n.getContext("2d");return n.height=30,N(o,0,0,0,30,t,e,s,!0,i),n}function Nt(t){const e=n.div();if(Object.keys(t).length>0){const s=n.divV([]);s.append(n.divH([n.divText("Pos",{style:{fontWeight:"bold",width:"30px",borderBottom:"1px solid"}}),n.divText("Difference",{style:{fontWeight:"bold",borderBottom:"1px solid"}})]));for(const e of Object.keys(t))t[e].style.borderBottom="1px solid lightgray",s.append(n.divH([n.divText((parseInt(e)+1).toString(),{style:{width:"30px",borderBottom:"1px solid lightgray"}}),t[e]]));e.append(s)}return e}function Lt(t,e){const s=o.Column.string("seq_diff",t.rowCount).init((s=>`${t.get(e[0],s)}#${t.get(e[1],s)}`));s.semType="MacromoleculeDifference",s.setTag(o.TAGS.UNITS,t.col(e[0]).getTag(o.TAGS.UNITS)),s.setTag("separator",t.col(e[0]).getTag("separator")),t.columns.add(s);const i=t.plot.grid();return i.col(e[0]).visible=!1,i.col(e[1]).visible=!1,i}var _t=s(4004),Rt=s(8601),Ot=s(5226);s(9133);class kt extends o.JsViewer{constructor(t){super(),this.name="",this.metricsProperties=["distanceMetric","fingerprint"],this.fingerprintChoices=["Morgan","Pattern"],this.initialized=!1,this.tags=[o.TAGS.UNITS,"aligned","separator","alphabet"],this.preComputeDistanceMatrix=!1,this.renderPromise=Promise.resolve(),this.fingerprint=this.string("fingerprint",this.fingerprintChoices[0],{choices:this.fingerprintChoices}),this.limit=this.int("limit",10),this.distanceMetric=this.string("distanceMetric",K.kg[0],{choices:K.kg}),this.moleculeColumnName=this.string("moleculeColumnName"),this.name=t}init(){this.initialized=!0}detach(){this.subs.forEach((t=>t.unsubscribe()))}async onTableAttached(){if(this.init(),this.dataFrame){this.preComputeDistanceMatrix=this.dataFrame.rowCount<=22e3,this.subs.push(o.debounce(this.dataFrame.onRowsRemoved,50).subscribe((t=>this.render(!0))));const t="diversity"!==this.name;this.subs.push(o.debounce(this.dataFrame.onCurrentRowChanged,50).subscribe((e=>this.render(t)))),this.subs.push(o.debounce(this.dataFrame.selection.onChanged,50).subscribe((t=>this.render(!1)))),this.subs.push(o.debounce(n.onSizeChanged(this.root),50).subscribe((t=>this.render(!1)))),this.moleculeColumn=this.dataFrame.columns.bySemType(o.SEMTYPE.MACROMOLECULE),this.moleculeColumnName=this.moleculeColumn?.name,this.getProperty("limit").fromOptions({min:1,max:this.dataFrame.rowCount})}this.render()}onPropertyChanged(t){if(super.onPropertyChanged(t),this.initialized){if("moleculeColumnName"===t.name){const e=this.dataFrame.col(t.get(this));e.semType===o.SEMTYPE.MACROMOLECULE&&(this.moleculeColumn=e)}this.render()}}render(t=!0){this.renderPromise=this.renderPromise.then((async()=>{this.computeRequested=this.computeRequested||t,await this.renderInt(t)}))}async renderInt(t){}beforeRender(){return!(!this.initialized||this.dataFrame&&this.moleculeColumnName&&this.dataFrame.col(this.moleculeColumnName).semType!==o.SEMTYPE.MACROMOLECULE&&(i.shell.error(`${this.moleculeColumnName} is not Macromolecule type`),1))}}var Pt=s(7241),Gt=s(4293),Ft=s(2669);async function Ht(t){const e=t.toList();if(t.semType!==o.SEMTYPE.MACROMOLECULE)throw new Error("Column has to be of macromolecule type");const s=C.Cn.getOrCreate(t).getDistanceFunctionName(),i=new Ft.m(!0,!1),n=await i.calc(e,s);return i.terminate(),n}function Vt(t){return(e,s)=>{const i=(e,s)=>t*e+s-Math.floor((e+2)*(e+1)/2);return e<=s?i(e,s):i(s,e)}}class Wt extends kt{constructor(){super("similarity"),this.sketchedMolecule="",this.curIdx=0,this.molCol=null,this.idxs=null,this.scores=null,this.gridSelect=!1,this.targetMoleculeIdx=0,this.computeCompleted=new R.Subject,this.distanceMatrixComputed=!1,this.cutoff=this.float("cutoff",.01,{min:0,max:1}),this.hotSearch=this.bool("hotSearch",!0),this.similarColumnLabel=this.string("similarColumnLabel",null)}init(){this.hotSearch=!0,this.initialized=!0}async renderInt(t){if(this.beforeRender()&&this.moleculeColumn&&(this.curIdx=-1==this.dataFrame.currentRowIdx?0:this.dataFrame.currentRowIdx,t&&!this.gridSelect)){this.targetMoleculeIdx=-1==this.dataFrame.currentRowIdx?0:this.dataFrame.currentRowIdx;const t=C.Cn.getOrCreate(this.moleculeColumn);await(t.isFasta()?this.computeByMM():this.computeByChem());const e=null!=this.similarColumnLabel?this.similarColumnLabel:`similar (${this.moleculeColumnName})`;this.molCol=o.Column.string(e,this.idxs.length).init((t=>this.moleculeColumn?.get(this.idxs?.get(t)))),this.molCol.semType=o.SEMTYPE.MACROMOLECULE,this.tags.forEach((t=>this.molCol.setTag(t,this.moleculeColumn.getTag(t))));const s=o.DataFrame.fromColumns([this.idxs,this.molCol,this.scores]);s.onCurrentRowChanged.subscribe((t=>{this.dataFrame.currentRowIdx=s.col("indexes").get(s.currentRowIdx),setTimeout((()=>{this.createPropertyPanel(s)}),1e3),this.gridSelect=!0}));const n=s.plot.grid();n.col("indexes").visible=!1;const r=this.idxs?.getRawData().findIndex((t=>t==this.targetMoleculeIdx));n.cell("score",r).cell.value=null,i.shell.v.grid.root.addEventListener("click",(t=>{this.gridSelect=!1})),(0,Gt.Y)(this.root,n.root),this.computeCompleted.next(!0)}}async computeByChem(){const t=await(0,Pt.D)(this.moleculeColumn),e=(o.DataFrame.fromColumns([t]),await i.functions.call("Chem:callChemSimilaritySearch",{df:this.dataFrame,col:t,molecule:t.get(this.targetMoleculeIdx),metricName:this.distanceMetric,limit:this.limit,minScore:this.cutoff,fingerprint:this.fingerprint}));this.idxs=e.getCol("indexes"),this.scores=e.getCol("score")}async computeByMM(){let t=new Float32Array;!this.distanceMatrixComputed&&this.preComputeDistanceMatrix?(this.mmDistanceMatrix=await Ht(this.moleculeColumn),this.distanceMatrixComputed=!0):this.preComputeDistanceMatrix||(t=await async function(t,e){const i=t.toList();if(t.semType!==o.SEMTYPE.MACROMOLECULE)throw new Error("Column has to be of macromolecule type");const n=C.Cn.getOrCreate(t).getDistanceFunctionName(),r=Math.min(Math.max(navigator.hardwareConcurrency-2,1),i.length),a=new Array(r).fill(null).map((t=>new Worker(new URL(s.p+s.u(190),s.b)))),l=new Float32Array(i.length);let h=0,c=Number.MIN_VALUE;const u=a.map(((t,s)=>{const o=Math.floor(s*i.length/r),u=s===a.length-1?Math.floor((s+1)*i.length/r):i.length;return new Promise(((s,r)=>{t.onmessage=({data:{error:t,distanceArrayData:e,min:i,max:n}})=>{t?r(t):(h=Math.min(h,i),c=Math.max(c,n),l.set(e,o),s())},t.postMessage({fnName:n,values:i,templateIdx:e,start:o,end:u})}))}));try{await Promise.all(u),l.forEach(((t,e)=>{l[e]=(t-h)/(c-h)})),a.forEach((t=>t.terminate()))}catch(t){throw a.forEach((t=>t.terminate())),t}return l}(this.moleculeColumn,this.targetMoleculeIdx));const e=this.moleculeColumn.length,i=Vt(e),n=Array(e).fill(0).map(((e,s)=>({idx:s,score:s===this.targetMoleculeIdx?1:this.preComputeDistanceMatrix?1-this.mmDistanceMatrix[i(this.targetMoleculeIdx,s)]:1-t[s]})));n.sort(((t,e)=>e.score-t.score));const r=Math.min(this.limit,e),a=n.slice(0,r);this.idxs=o.Column.int("indexes",r).init((t=>a[t].idx)),this.scores=o.Column.float("score",r).init((t=>a[t].score))}createPropertyPanel(t){const e=n.div(),s={},o=this.molCol?.name,r=t.col(o),a=C.Cn.getOrCreate(r),l=a.getSplitter(),h=l(this.moleculeColumn.get(this.targetMoleculeIdx)),c=l(t.get(o,t.currentRowIdx)),u=It(h,c,a.units,s);e.append(n.div(u,{style:{width:"300px",overflow:"scroll"}})),h.length!==c.length&&e.append(n.divV([n.divText("Different sequence length:",{style:{fontWeight:"bold"}}),n.divText(`target: ${h.length} monomers`),n.divText(`selected: ${c.length} monomers`)],{style:{paddingBottom:"10px"}})),e.append(Nt(s));const m=n.accordion(),d=n.element("i");d.className="grok-icon svg-icon svg-view-layout",m.addTitle(n.span([d,n.label("Similarity search")])),m.addPane("Differences",(()=>e),!0),i.shell.o=m.root}}var Bt=s(8518);class Dt extends kt{constructor(){super("diversity"),this.renderMolIds=null,this.columnNames=[],this.computeCompleted=new R.Subject,this.diverseColumnLabel=this.string("diverseColumnLabel",null)}async renderInt(t){if(this.beforeRender()&&this.dataFrame&&t&&this.moleculeColumn){const t=C.Cn.getOrCreate(this.moleculeColumn);await(t.isFasta()?this.computeByMM():this.computeByChem());const e=null!=this.diverseColumnLabel?this.diverseColumnLabel:`diverse (${this.moleculeColumnName})`,s=o.Column.string(e,this.renderMolIds.length).init((t=>this.moleculeColumn?.get(this.renderMolIds[t])));s.semType=o.SEMTYPE.MACROMOLECULE,this.tags.forEach((t=>s.setTag(t,this.moleculeColumn.getTag(t))));const i=o.DataFrame.fromColumns([s]);i.onCurrentRowChanged.subscribe((t=>{this.dataFrame.currentRowIdx=this.renderMolIds[i.currentRowIdx]})),(0,Gt.Y)(this.root,i.plot.grid().root),this.computeCompleted.next(!0)}}async computeByChem(){const t=await(0,Pt.D)(this.moleculeColumn);o.DataFrame.fromColumns([t]),this.renderMolIds=await i.functions.call("Chem:callChemDiversitySearch",{col:t,metricName:this.distanceMetric,limit:this.limit,fingerprint:this.fingerprint})}async computeByMM(){const t=await Ht(this.moleculeColumn),e=this.moleculeColumn.length,s=Vt(e);this.renderMolIds=(0,Bt.L)(e,Math.min(e,this.limit),((e,i)=>this.moleculeColumn.isNone(e)||this.moleculeColumn.isNone(i)?0:t[s(e,i)]))}}var Ut=s(9943),Zt=s(4413),Yt=s(1061),zt=s(5490),Xt=s(116),qt=s(1040);const $t={[o.SEMTYPE.MOLECULE]:"Molecules",[o.SEMTYPE.MACROMOLECULE]:"Sequences"};class Kt{get algorithmOptions(){const t=this.methodsParams[this.methodInput.value],e={};return Object.keys(t).forEach((s=>{null!=t[s].value&&(e[s]=t[s].value)})),e}constructor(t){this.methodSettingsDiv=n.inputs([]),this.methodsParams={[Xt.AL.UMAP]:new Xt.bD,[Xt.AL.T_SNE]:new Xt.aP},this.tableInput=n.tableInput("Table",i.shell.tv.dataFrame,void 0,(()=>{this.onTableInputChanged(t)})),this.molColInput=n.columnInput($t[t],this.tableInput.value,this.tableInput.value.columns.bySemType(t),null,{filter:e=>e.semType===t}),this.molColInputRoot=this.molColInput.root,this.molColInput.onChanged((()=>this.onColumnInputChanged(t))),this.methodInput=n.choiceInput("Method",Xt.AL.UMAP,[Xt.AL.UMAP,Xt.AL.T_SNE],(()=>{e&&this.createAlgorithmSettingsDiv(this.methodSettingsDiv,this.methodsParams[this.methodInput.value]),this.displaySimilarityThresholdInput(t)})),this.similarityThresholdInput=n.floatInput("Similarity threshold",.5),n.tooltip.bind(this.similarityThresholdInput.root,"Similarity threshold for sparse matrix creation."),this.methodSettingsIcon=n.icons.settings((()=>{e=!e,e?this.createAlgorithmSettingsDiv(this.methodSettingsDiv,this.methodsParams[this.methodInput.value]):n.empty(this.methodSettingsDiv)}),"Modify methods parameters"),this.methodInput.root.classList.add("ml-dim-reduction-settings-input"),this.methodInput.root.prepend(this.methodSettingsIcon),this.methodSettingsDiv=n.inputs([]);let e=!1;this.similarityMetricInput=t===o.SEMTYPE.MOLECULE?n.choiceInput("Similarity",qt.gk.Tanimoto,K.Rt):n.choiceInput("Similarity",X.U.HAMMING,K.bc),setTimeout((()=>{this.displaySimilarityThresholdInput(t),this.onColumnInputChanged(t)}))}createAlgorithmSettingsDiv(t,e){return n.empty(t),Object.keys(e).forEach((s=>{const i=e[s],o=n.floatInput(i.uiName,i.value,(()=>{i.value=o.value}));n.tooltip.bind(o.root,i.tooltip),t.append(o.root)})),t}onTableInputChanged(t){this.molColInput=n.columnInput($t[t],this.tableInput.value,this.tableInput.value.columns.bySemType(t)),this.molColInput.onChanged((()=>this.onColumnInputChanged(t))),n.empty(this.molColInputRoot),Array.from(this.molColInput.root.children).forEach((t=>this.molColInputRoot.append(t))),this.displaySimilarityThresholdInput(t),this.onColumnInputChanged(t)}onColumnInputChanged(t){const e=this.molColInput.value;if(!e||t!==o.SEMTYPE.MACROMOLECULE)return;const s=(e.getTag("aligned")??" ").toUpperCase().includes("MSA");this.similarityMetricInput.value=s?X.U.HAMMING:X.U.LEVENSHTEIN}displaySimilarityThresholdInput(t){t!==o.SEMTYPE.MOLECULE&&this.tableInput.value&&this.tableInput.value.rowCount>2e4&&this.methodInput.value===Xt.AL.UMAP?this.similarityThresholdInput.root.style.display="block":this.similarityThresholdInput.root.style.display="none"}}class jt extends Kt{get funcParams(){return{table:this.tableInput.value,molecules:this.molColInput.value,methodName:this.methodInput.value,similarityMetric:this.similarityMetricInput.value,sparseMatrixThreshold:this.similarityThresholdInput.value??.8,plotEmbeddings:this.plotEmbeddingsInput.value,options:this.algorithmOptions}}get paramsUI(){return this.funcParamsDiv}constructor(t){super(t),this.plotEmbeddingsInput=n.boolInput("Plot embeddings",!0),this.funcParamsDiv=n.inputs([this.tableInput,this.molColInput,this.methodInput,this.similarityThresholdInput,this.methodSettingsDiv,this.similarityMetricInput,this.plotEmbeddingsInput],{style:{minWidth:"320px"}})}}class Jt extends Kt{get funcParams(){return{table:this.tableInput.value,molecules:this.molColInput.value,activities:this.activitiesInput.value,similarity:this.similarityInput.value,methodName:this.methodInput.value,similarityMetric:this.similarityMetricInput.value,options:this.algorithmOptions}}get paramsUI(){return this.funcParamsDiv}constructor(t){super(t);const e=this.tableInput.value.columns.numerical;this.activitiesInput=n.columnInput("Activities",this.tableInput.value,o.Utils.firstOrNull(e),null,{filter:t=>Array.from(e).includes(t)}),this.activitiesInputRoot=this.activitiesInput.root,this.similarityInput=n.intInput("Similarity cutoff",80),n.tooltip.bind(this.similarityInput.root,"Pairs of similar (cutoff is used) molecules with high difference in activity are considered 'cliffs'"),this.funcParamsDiv=n.inputs([this.tableInput,this.molColInput,this.activitiesInput,this.similarityInput,this.methodInput,this.methodSettingsDiv,this.similarityMetricInput],{style:{minWidth:"320px"}})}onTableInputChanged(t){super.onTableInputChanged(t),n.empty(this.activitiesInputRoot);const e=this.tableInput.value.columns.numerical;this.activitiesInput=n.columnInput("Activities",this.tableInput.value,o.Utils.firstOrNull(e),null,{filter:t=>Array.from(e).includes(t)}),Array.from(this.activitiesInput.root.children).forEach((t=>this.activitiesInputRoot.append(t)))}}var Qt,te=s(8457);async function ee(t,e,s,i){const n=(0,te.O)(e),r=(0,l.vU)(e.getTag(o.TAGS.UNITS),e.getTag("separator"))(s),a=i===Qt.IDENTITY?function(t,e){const s=e.columns.length,i=new Array(s),n=new Array(s),r=new Array(s);for(let o=0;o<s;++o){const s=e.columns.byIndex(o);i[o]=s.getRawData(),n[o]=s.categories.indexOf(""),r[o]=s.categories.indexOf(t[o]??"")}const a=o.Column.float("Identity",e.rowCount),l=a.getRawData();for(let s=0;s<e.rowCount;++s){l[s]=0;for(let e=0;e<t.length;++e)i[e][s]===r[e]&&++l[s];l[s]/=t.length}return a}(r,n):i===Qt.SIMILARITY?await async function(t,e){const s=e.columns.toList();return await(0,z.Qx)(s,t)}(r,n):null;if(null===a)throw new Error(`In bio library: Unkown sequence scoring method: ${i}`);return a.name=t.columns.getUnusedName(a.name),t.columns.add(a),a}!function(t){t.IDENTITY="identity",t.SIMILARITY="similarity"}(Qt||(Qt={}));var se,ie=function(t,e,s,i){return new(s||(s=Promise))((function(n,o){function r(t){try{l(i.next(t))}catch(t){o(t)}}function a(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?n(t.value):(e=t.value,e instanceof s?e:new s((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};class ne{constructor(t,e,s=!1,i){var o;this.name="",this.description="",this._isAutomatic=!1,this._autoStartFirstStep=!1,this._currentStep=0,this._isStopped=!1,this._isCancelled=!1,this._isStepProcessed=!1,this._root=n.div([],{id:"demo-script",classes:"tutorials-root tutorials-track demo-app-script"}),this._steps=[],this._mainHeader=n.panel([],"tutorials-main-header"),this._header=n.h2(""),this._headerDiv=n.divH([],"tutorials-root-header"),this._stopStartBtn=n.button(n.iconFA("pause"),(()=>this._changeStopState()),"Play / pause"),this._restartBtn=n.button(n.iconFA("redo"),(()=>this._restartScript()),"Restart"),this._nextStepBtn=n.button(n.iconFA("play"),(()=>{this._isStepProcessed||this._nextStep()}),"Next step"),this._activity=n.panel([],"tutorials-root-description"),this._progressDiv=n.divV([],"tutorials-root-progress"),this._progress=n.element("progress"),this._progressSteps=n.divText(""),this._closeBtn=n.button(n.iconFA("chevron-left"),(()=>this._closeDock()),"Back to demo"),this.name=t,this.description=e,this._isAutomatic=s,this._autoStartFirstStep=null!==(o=null==i?void 0:i.autoStartFirstStep)&&void 0!==o&&o,this._progress.max=0,this._progress.value=1,ne.currentObject=this}get steps(){return this._steps}get stepNumber(){return this._steps.length}_addHeader(){this._createHeaderDiv(),this._createProgressDiv(),this._mainHeader.append(this._headerDiv,this._progressDiv)}_createHeaderDiv(){this._header.innerText=this.name,this._headerDiv.append(this._closeBtn),this._headerDiv.append(this._header),this._nextStepBtn.firstChild.className="grok-icon fas fa-play",this._headerDiv.append(this._isAutomatic?this._stopStartBtn:this._nextStepBtn)}_createProgressDiv(){this._progress.max=this.stepNumber,this._progressDiv.append(this._progress),this._progressSteps=n.divText(`Step: ${this._progress.value} of ${this.stepNumber}`),this._progressDiv.append(this._progressSteps)}_addDescription(){var t;this._activity.append(n.div(this.description,"tutorials-root-description"));for(let e=0;e<this.stepNumber;e++){let s=n.iconFA("clock");this._isAutomatic||0===e&&(s=n.iconFA("play",(()=>this._nextStep()),"Next step"),s.className="grok-icon fas fa-play");const i=n.div(this._steps[e].name,"grok-tutorial-entry-instruction"),o=n.div(null===(t=this._steps[e].options)||void 0===t?void 0:t.description,"grok-tutorial-step-description hidden"),r=n.divH([s,i],"grok-tutorial-entry");this._activity.append(r,o)}}_initRoot(){var t,e,s;i.shell.windows.showContextPanel=!0,i.shell.windows.showHelp=!1;const n=Array.from(i.shell.dockManager.rootNode.children)[0];this._node=i.shell.dockManager.dock(this._root,o.DOCK_TYPE.FILL,n,""),(null===(e=null===(t=n.parent.container.containerElement.firstElementChild)||void 0===t?void 0:t.lastElementChild)||void 0===e?void 0:e.classList.contains("tab-handle-list-container"))&&(null===(s=n.parent.container.containerElement.firstElementChild)||void 0===s||s.lastElementChild.remove()),this._node.container.containerElement.classList.add("tutorials-demo-script-container"),this._addHeader(),this._root.append(this._mainHeader),this._addDescription(),this._root.append(this._activity)}_nextStep(){var t,e;return ie(this,void 0,void 0,(function*(){this._isStepProcessed=!0,this._isAutomatic||(this._nextStepBtn.classList.add("disabled"),this._nextStepBtn.firstChild.classList.add("fa-disabled"));const s=this._activity.getElementsByClassName("grok-tutorial-entry")[this._currentStep],i=this._activity.getElementsByClassName("grok-icon")[this._currentStep],o=this._activity.getElementsByClassName("grok-tutorial-step-description")[this._currentStep];i.className="grok-icon far fa-spinner-third fa-spin",o.classList.remove("hidden"),o.classList.add("visible");const r=s,a=(null===(t=this._steps[this._currentStep].options)||void 0===t?void 0:t.delay)?null===(e=this._steps[this._currentStep].options)||void 0===e?void 0:e.delay:2e3;yield this._steps[this._currentStep].func(),this._scrollTo(this._root,r.offsetTop-this._mainHeader.offsetHeight),this._isAutomatic&&(yield this._countdown(s,i,a),yield(0,Yt.gw)(a));const l=n.iconFA("check");if(i.replaceWith(l),l.className="grok-icon far fa-check",this._progress.value++,this._progressSteps.innerText=`Step: ${this._progress.value} of ${this.stepNumber}`,this._currentStep++,this._isStepProcessed=!1,this._currentStep!==this.stepNumber){if(!this._isAutomatic){const t=this._activity.getElementsByClassName("grok-icon")[this._currentStep],e=n.iconFA("play",(()=>this._nextStep()),"Next step");e.className="grok-icon fas fa-play",t.replaceWith(e),this._nextStepBtn.classList.remove("disabled"),this._nextStepBtn.firstChild.classList.remove("fa-disabled")}}else this._isAutomatic?this._stopStartBtn.replaceWith(this._restartBtn):this._nextStepBtn.replaceWith(this._restartBtn)}))}_startScript(){return ie(this,void 0,void 0,(function*(){for(let t=this._currentStep;t<this.stepNumber&&!this._isStopped&&!this._isCancelled;t++)yield this._nextStep()}))}_scrollTo(t,e){t.focus(),t.scrollTop=e}_countdown(t,e,s){return ie(this,void 0,void 0,(function*(){const i=n.div([],"demo-script-countdown");e.classList.add("hidden");let o=s/1e3;const r=this._createSVGIndicator(o);i.append(r),t.prepend(i);const a=setInterval((()=>{o--,0===o&&(clearInterval(a),i.remove(),e.classList.remove("hidden"),e.classList.add("visible"))}),1e3)}))}_createSVGIndicator(t){const e=document.createElementNS("http://www.w3.org/2000/svg","svg"),s=document.createElementNS("http://www.w3.org/2000/svg","circle");return s.setAttributeNS(null,"cx","7"),s.setAttributeNS(null,"cy","7"),s.setAttributeNS(null,"r","6"),s.setAttributeNS(null,"style",`animation: countdown ${t}s linear infinite forwards`),e.append(s),e}_changeStopState(){const t=this._stopStartBtn.getElementsByClassName("grok-icon");t[0].className="grok-icon fas fa-play",this._isStopped=!this._isStopped,this._isStopped||(t[0].className="grok-icon fal fa-pause",this._isStepProcessed||this._startScript())}_restartScript(){i.shell.dockManager.close(this._node),i.shell.closeAll(),this._clearRoot(),this._setInitParams(),this.start()}_clearRoot(){this._root=n.div([],{id:"demo-script",classes:"tutorials-root tutorials-track demo-app-script"}),this._mainHeader=n.panel([],"tutorials-main-header"),this._header=n.h2(""),this._headerDiv=n.divH([],"tutorials-root-header"),this._activity=n.panel([],"tutorials-root-description"),this._progressDiv=n.divV([],"tutorials-root-progress"),this._progress=n.element("progress"),this._progressSteps=n.divText(""),this._progress.max=0,this._progress.value=1}_setInitParams(){this._currentStep=0,this._isStopped=!1,this._isCancelled=!1,this._stopStartBtn.getElementsByClassName("grok-icon")[0].className="grok-icon fal fa-pause",this._nextStepBtn.classList.remove("disabled")}_closeDock(){i.shell.dockManager.close(this._node),this.cancelScript()}cancelScript(){this._isCancelled=!0,ne.currentObject=null}step(t,e,s){return this._steps[this.steps.length]={name:t,func:e,options:s},this}start(){return ie(this,void 0,void 0,(function*(){this._initRoot(),i.shell.newView(this.name),this._isAutomatic?this._startScript():this._autoStartFirstStep&&(yield this._nextStep())}))}}function oe(t){const e=t instanceof Error?t.message:t.toString(),s=t instanceof Error?t.stack:void 0;i.shell.error(e),$e.logger.error(t.message,void 0,s)}ne.currentObject=null,function(t){t.X="Embed_X",t.Y="Embed_Y"}(se||(se={}));const re="data/sample_FASTA_PT_activity.csv";var ae=s(1811);async function le(){const t="Dendrogram",e=o.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()}async function he(){return await i.functions.call("Dendrogram:getDendrogramService",{})}const ce="data/sample_FASTA_PT_activity.csv",ue="sequence";var me=s(3336),de=s.n(me);const ge="data/sample_FASTA_PT_activity.csv";var pe=s(8341);const fe="samples/HELM.csv";var ye=s(2568),be=s(525);class we{constructor(t,e){this.urlParams=t,this.funcName=e}async init(t){this.df=t,await this.buildView()}async buildView(){const t=a()(this.urlParams.entries()).map((([t,e])=>`${t}=${encodeURIComponent(e)}`)).toArray().join("&");this.view=i.shell.addTableView(this.df),this.view.path=this.view.basePath=`func/${$e.name}.${this.funcName}?${t}`;const e={sequenceColumnName:"sequence"};for(const[t,s]of this.urlParams.entries())switch(t){case P.bo.fixWidth:case P.bo.fitArea:e[t]=["1","on","true"].includes(s.toLowerCase());break;default:e[t]=s}const s=await this.view.dataFrame.plot.fromType("WebLogo",e);this.view.dockManager.dock(s,o.DOCK_TYPE.DOWN,null,"WebLogo",.35)}}class Ce{get funcParams(){return{table:this.tableInput.value,sequence:this.seqColInput.value}}get paramsUI(){return this.funcParamsDiv}constructor(){this.tableInput=n.tableInput("Table",i.shell.tv.dataFrame,void 0,(()=>{this.onTableInputChanged()}));const t=this.tableInput.value.columns.bySemType(o.SEMTYPE.MACROMOLECULE),e={filter:t=>t.semType===o.SEMTYPE.MACROMOLECULE};this.seqColInput=n.columnInput("Sequence",this.tableInput.value,t,null,e),this.funcParamsDiv=n.inputs([this.tableInput,this.seqColInput],{style:{minWidth:"320px"}})}onTableInputChanged(){this.seqColInput=n.columnInput("Sequence",this.tableInput.value,this.tableInput.value.columns.bySemType(o.SEMTYPE.MACROMOLECULE))}}var ve=s(9416);class Se{constructor(t){this.monomerLib=t}getCappedRotatedMonomer(t,e){const s=this.monomerLib.getMonomer(t,e);return s?s.molfile:null}}const Te=new class{constructor(){this.tooltipHandlerTemp="tooltip-handler.Monomer"}},Me={autoCrop:!0,autoCropMargin:0,suppressChiralText:!0};class Ae{constructor(t){this.gridCol=t,this.gridCol.grid.onCellTooltip(this.onCellTooltip.bind(this))}onCellTooltip(t,e,s){if(t.grid.dart!=this.gridCol.grid.dart||t.gridColumn.dart!=this.gridCol.dart||!t.tableColumn||!t.isTableCell)return!1;const o=t.tableColumn.getTag("alphabet"),r=t.cell.value,a="DNA"===o||"RNA"===o?"RNA":"PEPTIDE",l=new Se(je().getBioLib()).getCappedRotatedMonomer(a,r),h=n.div(r),c=l?i.chem.svgMol(l,void 0,void 0,Me):null,u=t.grid.canvas.getBoundingClientRect(),m=t.bounds.right+u.left-4,d=t.bounds.bottom+u.top-4;return n.tooltip.show(n.divV([h,...c?[c]:[]]),m,d),!0}static getOrCreate(t){let e=t.temp[Te.tooltipHandlerTemp];return e||(e=t.temp[Te.tooltipHandlerTemp]=new Ae(t)),e}}class Ee extends o.GridCellRenderer{get name(){return S.Of.MONOMER}get cellType(){return S.Of.MONOMER}get defaultHeight(){return 15}get defaultWidth(){return 40}render(t,e,s,i,n,o,r){if(o.gridRow<0)return;Ae.getOrCreate(o.gridColumn),t.font="12px monospace",t.textBaseline="middle",t.textAlign="center";const a=(0,b.py)(o.cell.column.getTag("alphabet")),l=o.cell.value;if(!l)return;const h=a.get(l);t.fillStyle=h,t.fillText((0,b.GU)(l,6),e+i/2,s+n/2,i)}}class xe extends Map{get onPropertyChanged(){return this._onPropertyChanged}get MaxMonomerLength(){return super.get("MaxMonomerLength")}set MaxMonomerLength(t){super.set("MaxMonomerLength",t),this._onPropertyChanged.next("MaxMonomerLength")}get TooltipWebLogo(){return super.get("TooltipWebLogo")}set TooltipWebLogo(t){super.set("TooltipWebLogo",t),this._onPropertyChanged.next("TooltipWebLogo")}get DefaultSeparator(){return super.get("DefaultSeparator")}set DefaultSeparator(t){if(1!==t.length)throw new Error("The separator must be of length one.");super.set("DefaultSeparator",t),this._onPropertyChanged.next("DefaultSeparator")}constructor(t){super(Object.entries(t)),this._onPropertyChanged=new R.Subject}}class Ie extends o.Package{constructor(){super(...arguments),this._initialized=!1}get properties(){return this._properties}set properties(t){this._properties=t}get initialized(){return this._initialized}completeInit(){this._initialized=!0}handleErrorUI(t){const e=t instanceof Error?t.message:t.toString(),s=t instanceof Error?t.stack:void 0;i.shell.error(e),this.logger.error(e,void 0,s)}}class Ne extends o.Widget{constructor(t){super(n.div([],{}));const e=Object.assign({},...t.map((t=>({[t.name]:t}))));this.maxMonomerLengthProp=e.MaxMonomerLength,this.tooltipWebLogo=e.TooltipWebLogo,this.defaultSeparator=e.DefaultSeparator}async init(){const t=n.intInput("Max monomer length",$e.properties.MaxMonomerLength,(t=>{$e.properties.MaxMonomerLength=t})),e=n.boolInput("Tooltip WebLogo",$e.properties.TooltipWebLogo,(t=>{$e.properties.TooltipWebLogo=t})),s=n.choiceInput("Default Separator",$e.properties.DefaultSeparator,[".","/","-"],(t=>{$e.properties.DefaultSeparator=t}));this.root.appendChild(n.form([t,e,s]))}}var Le=s(5362),_e={};_e.styleTagTransform=lt(),_e.setAttributes=nt(),_e.insert=st().bind(null,"head"),_e.domAPI=tt(),_e.insertStyleElement=rt(),J()(Le.Z,_e),Le.Z&&Le.Z.locals&&Le.Z.locals;class Re extends o.Widget{constructor(t){super(n.divV([])),this.viewed=!1,this.seqCol=t}async init(){const t=C.Cn.getOrCreate(this.seqCol),e=$e.properties.TooltipWebLogo,s=this.seqCol.getTag(O.DX.tooltipWebLogo);!1===e||["false","off","disable","disabled"].includes(s)||(this.wlViewer=await this.seqCol.dataFrame.plot.fromType("WebLogo",{sequenceColumnName:this.seqCol.name,backgroundColor:0,positionHeight:"Entropy",positionWidth:t.getAlphabetIsMultichar()?24:16,fixWidth:!0,fitArea:!1}),this.wlViewer.root.style.height="50px",this.root.appendChild(this.wlViewer.root),this.root.style.width="100%")}}const Oe="PEPTIDE1{",ke="}$$$$",Pe="<All>";function Ge(t){t.setTag("quality",o.SEMTYPE.MACROMOLECULE),t.setTag("aligned","SEQ"),t.setTag("alphabet","PT")}class Fe{constructor(t,e){this.helmColumn=t,this.leftTerminal=e.leftTerminal,this.rightTerminal=e.rightTerminal}transform(){return this.helmColumn.toList().map((t=>this.hasTerminals(t)?this.getTransformedHelm(t):t))}}class He extends Fe{constructor(t,e){super(t,e)}hasTerminals(t){return!!t.includes(this.rightTerminal+ke)&&(this.leftTerminal===Pe||t.includes(Oe+this.leftTerminal))}getLinkedPositions(t){return[1,De(t)]}getTransformedHelm(t){const e=this.getLinkedPositions(t);return Ue(t,{monomerPosition:e[0],attachmentPoint:1},{monomerPosition:e[1],attachmentPoint:3})}}class Ve extends Fe{constructor(t,e){super(t,e)}hasTerminals(t){return this.leftTerminal===Pe||this.rightTerminal===Pe||t.includes(Oe+this.leftTerminal)&&t.includes(this.rightTerminal+ke)}getLinkedPositions(t){return[1,De(t)]}getTransformedHelm(t){const e=this.getLinkedPositions(t);return Ue(t,{monomerPosition:e[0],attachmentPoint:1},{monomerPosition:e[1],attachmentPoint:2})}}class We extends Fe{constructor(t,e){super(t,e)}hasTerminals(t){return this.leftTerminal===Pe||this.rightTerminal===Pe||this.getLinkedPositions(t).every((t=>t>0))}getLinkedPositions(t){const e=t.replace(Oe,"").replace(ke,"").split("."),s=e.findIndex((t=>t===this.leftTerminal)),i=e.findIndex(((t,e)=>t===this.rightTerminal&&e>s));return[s+1,i+1]}getTransformedHelm(t){const e=this.getLinkedPositions(t);return Ue(t,{monomerPosition:e[0],attachmentPoint:3},{monomerPosition:e[1],attachmentPoint:3})}}class Be{constructor(){}static getInstance(t,e){const s=e.cyclizationType;return"R3-R3"===s?new We(t,e):"N-Cys"===s?new He(t,e):new Ve(t,e)}}function De(t){return t.replace(Oe,"").replace(ke,"").split(".").length}function Ue(t,e,s){return t.replace(ke,`}$PEPTIDE1,PEPTIDE1,${e.monomerPosition}:R${e.attachmentPoint}-${s.monomerPosition}:R${s.attachmentPoint}${"$".repeat(6)}`)}async function Ze(t,e){const s=t.dataFrame,n=C.Cn.getOrCreate(t).convert(b.r2.HELM),r=Be.getInstance(n,e).transform(),a=s.columns.getUnusedName(`${e.transformationType}(`+t.name+")"),l=o.Column.fromList("string",a,r);Ge(l),l.setTag("units",b.r2.HELM),l.setTag("cell.renderer","helm"),s.columns.add(l),await i.data.detectSemanticTypes(s)}function Ye(t,e,s,i){const n=C.Cn.getOrCreate(t);let o=null,r=null;for(let t=0;t<n.posList.length;++t)n.posList[t]==e&&(o=t),n.posList[t]==s&&(r=t);if(null===o&&null!==e)throw new Error(`Start position ${e} not found.`);if(null===r&&null!==s)throw new Error(`End position ${s} not found.`);if(n.posList.length<r)throw new Error(`End position ${r} exceeds positions length`);const a=i||`${t.name}: (${e??""}-${s??""})`;return n.getRegion(o,r,a)}const ze={df:o.DataFrame.fromCsv("seq,value\nATCCGTCGT,0.5\nTGTTCGTCA,0.4\nATGGTCGTA,0.7\nATCCGTGCA,0.1"),colName:"seq",positionNames:["1","1A","1C","2","4","4A","4B","5","6"].join(b.CI),regions:[{name:"first region",start:"1",end:"2"},{name:"second region",start:"1C",end:"4"},{name:"overlapping second",start:"1C",end:"4A"},{name:"whole sequence",start:"1",end:"6"},{name:"bad start",start:"0",end:"6"},{name:"bad end",start:"1",end:"4C"},{name:"bad start & end",start:"0",end:"4C"}]};class Xe{constructor(t,e){this.urlParams=t,this.funcName=e}async init(t){this.data=t??ze;const e=this.data.df.getCol(this.data.colName);this.data.positionNames&&e.setTag(".positionNames",this.data.positionNames),this.data.regions&&e.setTag(".regions",JSON.stringify(this.data.regions)),await this.buildView()}async buildView(){await i.data.detectSemanticTypes(this.data.df),this.view=i.shell.addTableView(this.data.df),this.view.path=this.view.basePath=`func/${$e.name}.${this.funcName}`;const t=await this.view.dataFrame.plot.fromType("WebLogo",{sequenceColumnName:this.data.colName});this.view.dockManager.dock(t,o.DOCK_TYPE.DOWN,null,"WebLogo",.35)}}class qe{constructor(t){this.call=t,this.inputs=new class{},this.fixRegion=!1,this.defaultName=!0,this.defaultNameUpdating=!1;const e=t=>this.call.inputParams[t].property.description;this.inputs.table=n.tableInput("Table",this.call.inputParams.table.value??i.shell.tv.dataFrame,void 0,(()=>{}));const s=this.call.inputParams.sequence.value??this.inputs.table.value.columns.bySemType(o.SEMTYPE.MACROMOLECULE),r={filter:t=>t.semType===o.SEMTYPE.MACROMOLECULE};this.inputs.sequence=n.columnInput("Sequence",i.shell.tv.dataFrame,s,this.sequenceInputChanged.bind(this),r),this.inputs.start=n.choiceInput("Start",void 0,[],this.startInputChanged.bind(this)),this.inputs.end=n.choiceInput("End",void 0,[],this.endInputChanged.bind(this)),this.inputs.region=n.choiceInput("Region",null,[],this.regionInputChanged.bind(this)),this.inputs.name=n.stringInput("Column name",this.getDefaultName(),this.nameInputChanged.bind(this),{clearIcon:!0}),this.inputs.name.onInput(this.nameInputInput.bind(this));for(const t in this.call.inputParams)n.tooltip.bind(this.inputs[t].captionLabel,e(t));this.sequenceInputChanged()}sequenceInputChanged(){const t=this.inputs.sequence.value;t&&C.Cn.getOrCreate(t),this.updateRegionItems(),this.updateStartEndInputItems(),this.updateRegion(!0),this.updateNameInput()}regionInputChanged(){this.fixRegion=!0;try{const t=this.inputs.region.stringValue,e=t?JSON.parse(t):null;if(null!==e)this.inputs.start.value=e?.start,this.inputs.end.value=e?.end;else{const t=C.Cn.getOrCreate(this.inputs.sequence.value);this.inputs.start.value=t.posList[0],this.inputs.end.value=t.posList[t.posList.length-1]}}finally{this.fixRegion=!1}}startInputChanged(){this.updateRegion(!1),this.updateNameInput()}endInputChanged(){this.updateRegion(!1),this.updateNameInput()}nameInputChanged(){this.defaultNameUpdating||(this.defaultName=!1)}nameInputInput(){this.inputs.name.value||(this.defaultName=!0,this.inputs.name.input.focus())}updateStartEndInputItems(){const t=this.inputs.sequence.value,e=t?C.Cn.getOrCreate(t):null,s=this.inputs.start.input,i=this.inputs.end.input;for(let t=s.options.length-1;t>=0;--t)s.options.remove(t);for(let t=i.options.length-1;t>=0;--t)i.options.remove(t);for(const t of e?.posList??[]){const e=document.createElement("option"),n=document.createElement("option");e.text=n.text=t,e.value=n.value=t,s.options.add(e),i.options.add(n)}s.value=e?.posList[0]??"",i.value=e?.posList[e?.posList.length-1]??""}updateRegionItems(){const t=this.inputs.sequence.value,e=t?t.getTag(".regions"):null,s=e?JSON.parse(e):null,i=this.inputs.region.input;for(let t=i.options.length-1;t>=0;--t)i.options.remove(t);const n=document.createElement("option");if(n.text="",n.value=JSON.stringify(null),i.options.add(n),null!=s){this.inputs.region.root.style.removeProperty("display");for(const t of s){const e=document.createElement("option");e.text=`${t.name}: ${t.start}-${t.end}`,e.value=JSON.stringify(t),i.options.add(e)}}else this.inputs.region.root.style.display="none"}updateRegion(t){const e=this.inputs.start.stringValue??"",s=this.inputs.end.stringValue??"";if(!this.fixRegion){const t=this.inputs.region.input;t.selectedIndex=-1;for(let i=t.options.length-1;i>=0;--i){const n=t.options[i],o=JSON.parse(n.value);o&&e===o.start&&s===o.end&&(t.selectedIndex=i)}}}updateNameInput(){this.defaultNameUpdating=!0;try{this.defaultName&&(this.inputs.name.value=this.getDefaultName())}finally{this.defaultNameUpdating=!1}}getDefaultName(){const t=this.inputs.region.stringValue,e=t?JSON.parse(t):null,s=this.inputs.sequence.value,i=this.inputs.start.stringValue??"",n=this.inputs.end.stringValue??"";return null!=e?`${s.name}(${e.name}): ${e.start}-${e.end}`:`${s?.name}: (${i}-${n})`}getParams(){return{table:this.inputs.table.value,sequence:this.inputs.sequence.value,start:this.getStart(),end:this.getEnd(),name:this.getName()}}getStart(){return this.inputs.start.stringValue}getEnd(){return this.inputs.end.stringValue}getName(){const t=this.inputs.name.stringValue;return""==t?null:t}dialog(){const t=n.inputs(Object.values(this.inputs),{style:{minWidth:"320px"}});n.dialog({title:"Get Region"}).add(t).onOK((async()=>{(async()=>{const t=this.getParams();await this.call.func.prepare(t).call(!0)})().catch((t=>{$e.handleErrorUI(t)}))})).show()}widget(){const t=n.inputs(Object.entries(this.inputs).filter((([t,e])=>!["table","sequence"].includes(t))).map((([t,e])=>e))),e=n.button("Get Region",(()=>{(async()=>{const t=this.getParams();await this.call.func.prepare(t).call(!0)})().catch((t=>{$e.handleErrorUI(t)}))}));return o.Widget.fromRoot(n.divV([t,n.div(e)]))}}const $e=new Ie,Ke="bypassLargeDataWarning";function je(){return zt.NT.instance}let Je=null;class Qe{constructor(t){this._palette=t}get(t){return this._palette[t]}}async function ts(){$e.logger.debug("Bio: initBio(), started");const t=await i.functions.call("Chem:getRdKitModule");await Promise.all([(async()=>{await zt.NT.instance.loadLibraries()})(),(async()=>{const t=await $e.getProperties(),e=new xe(t);$e.properties=e})()]).finally((()=>{$e.completeInit()}));const e=zt.NT.instance.getBioLib(),s=[],n=[],o=e.getMonomerMolsByPolymerType("PEPTIDE");Object.keys(o).forEach((e=>{s.push(e);const i=o[e].replaceAll("#R","O "),r=t.get_mol(i),a=JSON.parse(r.get_descriptors()).CrippenClogP;n.push(a),r?.delete()}));const r=n.reduce(((t,e)=>t+e),0)/n.length||0,a={};for(let t=0;t<s.length;t++)a[s[t]]=n[t]<r?"#4682B4":"#DC143C";Je=new Qe(a),$e.logger.debug("Bio: initBio(), completed")}function es(t){const e=new Re(t);return e.init().then((()=>{})).catch((t=>{const e=t instanceof Error?t.message:t.toString();i.shell.error(e)})),e}function ss(){return zt.NT.instance.getBioLib()}function is(t){const e="getRegionTopMenu",s=o.Func.find({package:$e.name,name:e});if(1!==s.length)throw new Error(`Package '${$e.name}' func '${e}' not found`);const i=s[0].prepare({table:t.dataFrame,sequence:t});return new qe(i).widget()}async function ns(t){return(0,zt.cf)()}function os(t){try{new qe(t).dialog()}catch(t){const e=t instanceof Error?t.message:t.toString(),s=t instanceof Error?t.stack:void 0;i.shell.error(`Get region editor error: ${e}`),$e.logger.error(e,void 0,s)}}function rs(t){const e=new Ce;n.dialog({title:"Split to Monomers"}).add(e.paramsUI).onOK((async()=>t.func.prepare(e.funcParams).call(!0))).show()}function as(t){const e=new jt(o.SEMTYPE.MACROMOLECULE);n.dialog({title:"Sequence Space"}).add(e.paramsUI).onOK((async()=>t.func.prepare(e.funcParams).call())).show()}function ls(t){const e=new Jt(o.SEMTYPE.MACROMOLECULE);n.dialog({title:"Activity Cliffs"}).add(e.paramsUI).onOK((async()=>t.func.prepare(e.funcParams).call(!0))).show()}function hs(t){const e=new Ne(t);return e.init().then(),e}function cs(){return new x}function us(t){return function(t){const e=Array.from(t.dataFrame.columns).filter((t=>t.semType===o.SEMTYPE.MOLECULE)).map((t=>t.name));new Set(e).delete(t.name);const s=n.choiceInput("Monomer width",null!=t?.temp["monomer-width"]?t.temp["monomer-width"]:f.short,[f.short,f.long],(e=>{t.temp["monomer-width"]=e,t.setTag(".mm.cellRenderer.settingsChanged",v.true),t.dataFrame.fireValuesChanged()}));s.setTooltip("In short mode, only the 'Max monomer length' characters are displayed, followed by .. if there are more");const i=parseInt(t.getTag(d.maxMonomerLength)),r=n.intInput("Max monomer length",isNaN(i)?$e.properties.MaxMonomerLength:i,(e=>{t.setTag(d.maxMonomerLength,e.toString()),t.setTag(".mm.cellRenderer.settingsChanged",v.true),t.dataFrame.fireValuesChanged()}));r.setTooltip(`The max length of monomer name displayed without shortening in '${f.short}' monomer width mode.`);const a=n.intInput("Monomer margin",t.temp[".mm.cellRenderer.gapLength"]??0,(e=>{t.temp[".mm.cellRenderer.gapLength"]=e,t.setTag(".mm.cellRenderer.settingsChanged",v.true),t.dataFrame.fireValuesChanged()}));a.setTooltip("The size of margin between monomers (in pixels)");const l=n.boolInput("Color code",null==t?.temp["color-code"]||t.temp["color-code"],(e=>{t.temp["color-code"]=e,t.dataFrame.fireValuesChanged()}));l.setTooltip("Color code");const h=n.stringInput("Reference sequence",null!=t?.temp["reference-sequence"]?t?.temp["reference-sequence"]:"",(e=>{t.temp["reference-sequence"]=e,t.dataFrame.fireValuesChanged()}));h.setTooltip("Reference sequence is not empty, then the sequence will be render \nas a difference from the reference sequence");const c=n.boolInput("Compare with current",null==t?.temp["compare-with-current"]||t.temp["compare-with-current"],(e=>{t.temp["compare-with-current"]=e,t.dataFrame.fireValuesChanged()}));c.setTooltip('When on, all sequences get rendered in the "diff" mode');const u=n.inputs([s,r,a,h,l,c]);return new o.Widget(u)}(t)}function ms(t){return function(t){const e=n.div();e.classList.add("macromolecule-cell-comp-analysis-host");const s=t.cell.column.tags.alphabet;let i=w.UE.Color;switch(s){case"DNA":case"RNA":i=(0,b.py)("DNA");break;case"PT":i=(0,b.py)("PT")}const r=new Map;let l=0;const h=C.Cn.getOrCreate(t.cell.column).getSplitter()(t.value),c=h.length;a()(h).filter((t=>!!t&&""!==t)).forEach((t=>{const e=r.get(t)||0;r.set(t,e+1),l=Math.max(l,e+1)})),l/=c;const u={},m=Array.from(r.entries());m.sort(((t,e)=>e[1]-t[1])),m.forEach((([t,e])=>{const s=e/c,o=i.get(t),r=n.div("",{classes:"macromolecule-cell-comp-analysis-bar"});r.style.width=s/l*50+"px";const a=n.div((100*s).toFixed(2)+"%");r.style.backgroundColor=o,u[t]=n.div([r,a],{classes:"macromolecule-cell-comp-analysis-value"})}));const d=n.tableFromMap(u);return Array.from(d.rows).forEach((t=>{const e=t.getElementsByClassName("macromolecule-cell-comp-analysis-bar")[0].style.backgroundColor;t.cells[0].style.color=e})),e.appendChild(d),new o.Widget(e)}(t)}function ds(){return new x}function gs(){return new I}function ps(t,e,s,i,n){const o=new B.k(i,n,s,e);return"Local alignment"==t?o.smithWaterman():o.needlemanWunch()}function fs(){return new P.OZ}function ys(){return new W}function bs(t,e,s,i){return Ye(t,e??null,s??null,i??null)}async function ws(t,e,s,n,o){const r=Ye(e,s??null,n??null,o??null);e.dataFrame.columns.add(r),await i.data.detectSemanticTypes(e.dataFrame)}async function Cs(t,e,r,a,l,h){if(!(0,ye.n)(e,"Activity Cliffs"))return;const c=$(t),u={units:e.getTag(o.TAGS.UNITS),aligned:e.getTag("aligned"),separator:e.getTag("separator"),alphabet:e.getTag("alphabet")},m=C.Cn.getOrCreate(e);let d=Tt.gk.Tanimoto,g=e;if(m.isFasta()||m.isSeparator()&&m.alphabet&&"UN"!==m.alphabet)if(m.isFasta())d=m.getDistanceFunctionName();else{g=m.convert(b.r2.FASTA);const t=C.Cn.getOrCreate(g);d=t.getDistanceFunctionName(),u.units=b.r2.FASTA}const p=async()=>await async function(t,e,r,a,l,h,c,u,m,d,g,p,f,y,b,w,C,v){dt++;const S=c/100,T=r??e;let M=!1,A=!1;const E={};let x,I;const N={seqCol:T,methodName:m,similarityMetric:u,embedAxesNames:a,options:C},{distance:L,coordinates:_}=await p(N);for(const e of _)t.columns.add(e);let R=L;const O=Object.values(X.U).map((t=>t.toString())).includes(u);O&&!L&&(R=ut.H.calc(e.toList(),X.o[u]()).data);const k=function(t,e,s){const i=[],n=[],o=[],r=[],a=new Set;for(let l=0;l!=t.length;++l)for(let h=0;h!=t.length-l;++h){const c=t[l]?t[l].get(h):0;if(c>=e){o.push(l),r.push(l+h+1),a.add(l),a.add(l+h+1),i.push(c);const t=Math.abs(s.get(l)-s.get(l+h+1));n.push(1!=c?t/(1-c):1/0)}}return{simVals:i,saliVals:n,n1:o,n2:r,cliffsMolIds:a}}(await async function(t,e,s,i){const n=t.categories,r=t.getRawData(),a=o.Column.string("seq",t.length).init((t=>n[r[t]])),l=o.DataFrame.fromColumns([a]),h=t.length;let c=Array(h-1);return s&&e?function(t,e,s){const i=(0,mt.y)(t);for(let n=0;n<t-1;++n){const r=new Float32Array(t-n-1).fill(0);for(let s=n+1;s<t;++s){const t=i(n,s);r[s-n-1]=e[t]===o.FLOAT_NULL?0:(0,K.Om)(e[t])}s[n]=o.Column.fromFloat32Array("similarity",r)}}(h,e,c):c=await i(h,t,l,"seq",c),c}(T,R,O,f),S,h),P=function(t,e,s,i,n,r){const a=new Array(t).fill(0);for(let t=0;t!=s.length;++t)e[t]!=1/0&&(r.get(s[t])>r.get(i[t])?a[s[t]]+=e[t]:a[i[t]]+=e[t]);return o.Column.fromList("double",`sali_${n[0].substring(n[0].lastIndexOf("_"))}`,a)}(T.length,k.saliVals,k.n1,k.n2,a,h);t.columns.add(P);const G=function(t,e){const s="containsCliff",i=t.columns.names().filter((t=>t.includes(s))).length+1,n=`${s}_${i}`;return o.Column.bool(n,t.rowCount).init((t=>e.has(t)))}(t,k.cliffsMolIds);t.columns.add(G);const F=function(t){const e=t.filter((t=>t!==1/0)),s=Math.min(...e);return{max:Math.max(...e),min:s}}(k.saliVals),H=.8/(F.max-F.min),V=i.shell.getTableView(t.name);V.grid.columns.byName(G.name).visible=!1;const W=V.addViewer(o.VIEWER.SCATTER_PLOT,{xColumnName:a[0],yColumnName:a[1],size:P.name,color:h.name,showXSelector:!1,showYSelector:!1,showSizeSelector:!1,showColorSelector:!1,markerMinSize:5,markerMaxSize:25,title:l}),B=W.getInfo().canvas,D=function(t,e,s,i,n){const r=new Array(t.n1.length).fill(null);for(let e=0;e<t.n1.length;e++){const s=t.n1[e],i=t.n2[e];r[e]={id:e,mols:[s,i],selected:!1,a:[],b:[]}}const a=o.DataFrame.create(r.length);return Ct.forEach(((t,s)=>{a.columns.addNewString(t).init((t=>e.get(r[t].mols[s]))),function(t,e){Object.keys(e).forEach((s=>{t.tags[s]=e[s]}))}(a.col(t),n),a.col(t).semType=i})),a.columns.addNewFloat(ft).init((t=>Math.abs(s.get(r[t].mols[0])-s.get(r[t].mols[1])))),a.columns.addNewInt(wt).init((t=>t)),a.columns.addNewFloat(yt).init((e=>t.saliVals[e])),a.columns.addNewFloat(bt).init((e=>t.simVals[e])),a.name=`${gt}${dt}`,{lines:r,linesDf:a}}(k,e,h,d,g),U=w?w(D.linesDf,Ct).sort([yt],[!1]):D.linesDf.plot.grid().sort([yt],[!1]);t.temp[".cliffsDfGrid"]=U;const Z=n.button(`${D.linesDf.rowCount} cliffs`,(()=>{V.dockManager.dock(U,"down",null,"Activity cliffs",v??.2)}));Z.classList.add("scatter_plot_link","cliffs_grid"),W.root.append(Z);const Y=n.switchInput("Show only cliffs",!1,(()=>{Y.value?(W.dataFrame.setTag(vt,G.name),t.rows.match({[G.name]:!0}).filter(),pt.next(G.name)):(W.dataFrame.setTag(vt,""),t.filter.setAll(!0,!0),pt.next(""))}));Y.root.classList.add("scatter_plot_link","show_only_cliffs"),W.root.append(Y.root),pt.subscribe((t=>{Y.enabled=""===t||t===G.name}));const z=i.events.onViewerClosed.subscribe((t=>{t.args.viewer===W&&(V.dockManager.close(U.root),z.unsubscribe(),V.subs=V.subs.filter((t=>t!==z)))}));return V.subs.push(z),D.linesDf.onCurrentCellChanged.subscribe((()=>{M=!0;const s=D.linesDf.currentCol&&D.linesDf.currentCol.name===Ct[1]?1:0,o=-1!==D.linesDf.currentRowIdx?D.lines[D.linesDf.currentRowIdx]:null;W.dataFrame.currentRowIdx=o?o.mols[s]:-1,W.dataFrame.filter.set(0,!D.lines[0].selected),W.dataFrame.filter.set(0,D.lines[0].selected),o&&setTimeout((()=>{!function(t,e,s,o,r,a,l,h){const c=e.getPane("Cliff Details");n.empty(c.root);const u=h({cashedData:s,line:o,df:t,seqCol:r,activityCol:a,sali:l});c.root.append(u),setTimeout((()=>{i.shell.o=e.root}),500)}(t,x,E,o,e,h,D.linesDf.get(yt,o.id),b);const s=W.dataFrame.getSortedOrder(V.grid.sortByColumns,V.grid.sortTypes);V.grid.scrollToCell(e.name,s.indexOf(W.dataFrame.currentRowIdx))}),1e3)})),D.linesDf.onSelectionChanged.subscribe((e=>{if(!1===D.linesDf.selection.anyTrue)D.lines.forEach((t=>{t.selected=!1}));else if(-1!==D.linesDf.mouseOverRowIdx){const t=D.lines[D.linesDf.mouseOverRowIdx];t.selected=!t.selected}setTimeout((()=>{const e=o.BitSet.create(t.rowCount);D.lines.forEach((t=>{t.selected&&t.mols.forEach((s=>{e.set(s,t.selected,!0)}))})),t.selection.copyFrom(e),V.grid.invalidate()}),300)})),t.onSelectionChanged.subscribe((e=>{A?A=!1:!1===t.selection.anyTrue&&"number"==typeof e&&(D.lines.forEach((t=>{t.selected=!1})),U.dataFrame.selection.setAll(!1,!1),U.invalidate())})),B.addEventListener("mousemove",(function(i){clearTimeout(I),I=s.g.setTimeout((function(){const s=St(i,B,D.lines);s&&-1===t.mouseOverRowIdx&&n.tooltip.show(y({cashedData:E,line:s,df:t,seqCol:e,activityCol:h}),i.clientX,i.clientY)}),500)})),B.addEventListener("mousedown",(function(e){A=!0;const s=St(e,B,D.lines);if(s&&-1===t.mouseOverRowIdx){e.ctrlKey?(s.selected=!s.selected,D.linesDf.selection.set(s.id,s.selected)):D.linesDf.currentRowIdx!==s.id&&(D.linesDf.currentRowIdx=s.id,t.currentRowIdx=s.mols[0],t.filter.set(0,!D.lines[0].selected),t.filter.set(0,D.lines[0].selected));const i=D.linesDf.getSortedOrder(U.sortByColumns,U.sortTypes);U.scrollToCell(Ct[0],i.indexOf(s.id))}})),W.onEvent("d4-before-draw-scene").subscribe((e=>{const s=function(t,e,s,i,n,o,r){const a=i.lines,l=t.getInfo().canvas.getContext("2d"),h=t.dataFrame.columns.byName(e),c=t.dataFrame.columns.byName(s);for(let e=0;e<a.length;e++){const s=t.worldToScreen(h.get(a[e].mols[0]),c.get(a[e].mols[0])),u=t.worldToScreen(h.get(a[e].mols[1]),c.get(a[e].mols[1]));a[e].a=[s.x,s.y],a[e].b=[u.x,u.y];const m=new Path2D;m.moveTo(a[e].a[0],a[e].a[1]);const d=a[e].selected?"255,255,0":"0,128,0",g=n[e]===1/0?1:.2+(n[e]-r)*o;l.strokeStyle=`rgba(${d},${g})`,l.lineWidth=a[e].id===i.linesDf.currentRowIdx?3:1,m.lineTo(a[e].b[0],a[e].b[1]),l.stroke(m)}return a}(W,a[0],a[1],D,k.saliVals,H,F.min);if(M){const t=s[D.linesDf.currentRowIdx];setTimeout((()=>{const{zoomLeft:e,zoomRight:s,zoomTop:i,zoomBottom:n}=function(t,e,s,i,n,o){const r=Math.abs(s-n),a=Math.abs(i-o),l=t/r,h=e/a,c=Math.min(l,h),u=t/c*5,m=e/c*5,d=(s<n?s:n)+r/2-u/2,g=(i>o?i:o)-a/2+m/2;return{zoomLeft:d,zoomRight:d+u,zoomTop:g,zoomBottom:g-m}}(W.viewport.width,W.viewport.height,W.dataFrame.get(a[0],t.mols[0]),W.dataFrame.get(a[1],t.mols[0]),W.dataFrame.get(a[0],t.mols[1]),W.dataFrame.get(a[1],t.mols[1]));W.zoom(e,i,s,n)}),300),M=!1}Y.value?t.rows.match({[G.name]:!0}).filter():!0===Y.enabled&&t.filter.setAll(!0,!1)})),W.addProperty("similarityLimit","double",S),x=function(){const t=n.accordion(),e=n.element("i");return e.className="grok-icon svg-icon svg-view-layout",t.addTitle(n.span([e,n.label("Activity cliffs")])),t.addPane("Cliff Details",(()=>n.divText("Cliff has not been selected")),!0),i.shell.o=t.root,t}(),W}(t,g,null,c,"Activity cliffs",r,a,d,l,o.SEMTYPE.MACROMOLECULE,u,q,Mt,At,Et,Lt,h),f=l===Xt.AL.UMAP?5e3:2e3;if(t.rowCount>2e4)i.shell.warning("Too many rows, maximum for sequence activity cliffs is 20000");else{if(!(t.rowCount>f)||h?.[Ke])return await p();n.dialog().add(n.divText("Activity cliffs analysis might take several minutes.\n Do you want to continue?")).onOK((async()=>{const t=o.TaskBarProgressIndicator.create("Running sequence activity cliffs ..."),e=await p();return t.close(),e})).show()}}async function vs(t,e,s,r=X.U.LEVENSHTEIN,a,l,h){if(await(0,Yt.gw)(10),!(0,ye.n)(e,"Sequence space"))return;let c;const u=o.TaskBarProgressIndicator.create("Initializing sequence space ...");try{function m(e,s,n){let r=null,l=null;t.columns.names().includes(d[0])?(r=t.columns.byName(d[0]),l=t.columns.byName(d[1])):(r=t.columns.add(o.Column.float(d[0],t.rowCount)),l=t.columns.add(o.Column.float(d[1],t.rowCount)),a&&(c=i.shell.tableView(t.name).scatterPlot({x:d[0],y:d[1],title:"Sequence space"}))),r.init((t=>n[t][0])),l.init((t=>n[t][1]));const h=e/s*100;u.update(h,`Running sequence space ... ${h.toFixed(0)}%`)}const d=$(t),g=o.DataFrame.fromColumns([e]).clone(),p=function(t,e){const s=e.categories.map(((t,e)=>t?null:e)).filter((t=>null!==t)),i=[...e.getRawData()],n=[];let o=0;for(let e=0;e<t.rowCount;e++)s.includes(i[e])&&(t.rows.removeAt(e-o),n.push(e),o+=1);return n}(g,e),f={seqCol:g.col(e.name),methodName:s,similarityMetric:r,embedAxesNames:d,options:{...h,sparseMatrixThreshold:l??.8,usingSparseMatrix:t.rowCount>2e4}},y=s===Xt.AL.UMAP?1e5:15e3,b=s===Xt.AL.UMAP?5e3:2e3;if(t.rowCount>y)return void i.shell.warning(`Too many rows, maximum for sequence space is ${y}`);async function w(){let t=null;const e=i.events.onViewerClosed.subscribe((s=>{const n=s.args.viewer;n?.getOptions()?.look?.title&&c?.getOptions()?.look?.title&&n?.getOptions()?.look?.title===c?.getOptions()?.look?.title&&(i.events.fireCustomEvent(U,{}),e.unsubscribe(),t?.(),u.close())})),s=new Promise((async e=>{t=e,e(await q(f,h?.[Ke]?void 0:m))})),n=await s;return u.close(),e.unsubscribe(),n?C(n):n}if(!(t.rowCount>b)||h?.[Ke])return await w();function C(e){const s=e.coordinates;for(const e of s){const s=e.toList();p.forEach((t=>s.splice(t,0,null)));let i=t.columns.byName(e.name);i||(i=o.Column.float(e.name,s.length),t.columns.add(i)),i.init((t=>s[t]))}if(a)return c||(c=i.shell.tableView(t.name).scatterPlot({x:d[0],y:d[1],title:"Sequence space"})),c}n.dialog().add(n.divText("Sequence space analysis might take several minutes.\n Do you want to continue?")).onOK((async()=>{await w()})).onCancel((()=>{u.close()})).show()}catch(v){console.error(v),u.close()}}async function Ss(t,e){if(0===o.Func.find({package:"Chem",name:"getRdKitModule"}).length)return void i.shell.warning('Transformation to atomic level requires package "Chem" installed.');if(!(0,ye.n)(e,"To Atomic Level"))return;const s=(await je()).getBioLib(),r=await(0,Rt.i0)(t,e,s);null!==r.col&&(t.columns.add(r.col,!0),await i.data.detectSemanticTypes(t)),r.warnings&&r.warnings.length>0&&i.shell.warning(n.list(r.warnings))}function Ts(){(0,be.K)()}async function Ms(t=null,e=null){return(0,be.K)({col:t,clustersCol:e})}async function As(){const t=i.shell.tv,e=t.dataFrame.columns.toList().filter((t=>t.semType==o.SEMTYPE.MACROMOLECULE&&(C.Cn.getOrCreate(t),!0))),s=async e=>{if(!(0,ye.n)(e,"Composition"))return;const s=t.addViewer("WebLogo",{sequenceColumnName:e.name});i.shell.tv.dockManager.dock(s,o.DOCK_TYPE.DOWN,null,"Composition analysis",.25)};let r=null;if(0!=e.length){if(e.length>1){const t=e.map((t=>t.name)),i=e.find((t=>C.Cn.getOrCreate(t).isMsa())),o=n.choiceInput("Column",i?i.name:t[0],t);n.dialog({title:"Composition Analysis",helpUrl:"/help/domains/bio/macromolecules.md#composition-analysis"}).add(n.div([o])).onOK((async()=>{const t=e.find((t=>t.name==o.value))??null;t&&await s(t)})).show()}else r=e[0];r&&await s(r)}else i.shell.error("Current table does not contain sequences")}function Es(t){return new Ot.i(t).importFasta()}function xs(t){return console.log(t),[]}function Is(){const t=(0,Gt.B)()[0];(0,_t.O)(t)}function Ns(){return new Ee}async function Ls(t){const e=o.TaskBarProgressIndicator.create("Test detectMacromolecule..."),s=(await i.dapi.files.list(t,!0,"")).filter((t=>t.fileName.endsWith(".csv")));let n=0;const r=[];for(const a of s)try{const e=await i.dapi.files.readAsText(t+a.fullPath),s=o.DataFrame.fromCsv(e);for(const t of s.columns)await i.functions.call("Bio:detectMacromolecule",{col:t})===o.SEMTYPE.MACROMOLECULE&&r.push({file:a.path,result:"detected",column:t.name,message:`units: ${t.getTag(o.TAGS.UNITS)}`})}catch(t){r.push({file:a.path,result:"error",column:null,message:t instanceof Error?t.message:t.toString()})}finally{n+=1,e.update(100*n/s.length,`Test ${a.fileName}`)}i.shell.info("Test Demo:Files for detectMacromolecule finished."),e.close();const a=o.DataFrame.fromObjects(r);return a.name=`datasets_detectMacromolecule_${t}`,a}async function _s(t,e){await(0,ve.n)(t,e)}function Rs(t){const e=C.Cn.getOrCreate(t).stats;return Object.keys(e.freq)}function Os(){return new Wt}function ks(){const t=i.shell.v,e=t.addViewer("Sequence Similarity Search");t.dockManager.dock(e,"down")}function Ps(){return new Dt}function Gs(){const t=i.shell.v,e=t.addViewer("Sequence Diversity Search");t.dockManager.dock(e,"down")}function Fs(t){const e=(0,Gt.B)();1===e.length?t.func.prepare({macromolecules:e[0]}).call(!0):new Y.uH(e)}function Hs(t){i.shell.tv.getFiltersGroup({createDefaultFilters:!1}).updateOrAdd({type:"Bio:bioSubstructureFilter",column:t.name,columnName:t.name}),i.shell.tv.grid.scrollToCell(t,0)}async function Vs(t,e,s){return ee(t,e,s,Qt.IDENTITY)}async function Ws(t,e,s){return ee(t,e,s,Qt.SIMILARITY)}function Bs(){(0,Ut.C2)()}function Ds(){return new Zt.ST}async function Us(){const t=o.TaskBarProgressIndicator.create("WebLogo");try{const t=new URLSearchParams(window.location.search),e=new we(t,"webLogoLargeApp"),s=await $e.files.readCsv("data/sample_PT_100000x5.csv");await i.data.detectSemanticTypes(s),await e.init(s)}finally{t.close()}}async function Zs(){const t=o.TaskBarProgressIndicator.create("getRegion ...");try{const t=new URLSearchParams(window.location.search),e=new Xe(t,"getRegionApp");await e.init()}finally{t.close()}}async function Ys(){const t=o.TaskBarProgressIndicator.create("getRegion ...");try{const t=new URLSearchParams(window.location.search),e=await $e.files.readCsv("data/sample_HELM_empty_vals.csv"),s=new Xe(t,"getRegionHelmApp");await s.init({df:e,colName:"HELM"})}finally{t.close()}}function zs(t,e){!function(t,e){const s=C.Cn.getOrCreate(t.column),n=Object.values(b.r2).filter((t=>t!==s.units));e.group("Copy").items(n,(e=>{const s=C.Cn.getOrCreate(t.column),n=e===b.r2.SEPARATOR?$e.properties.DefaultSeparator:void 0,o=s.getConverter(e,n)(t.value);navigator.clipboard?(navigator.clipboard.writeText(o),i.shell.info(`Value of notation '${e}' copied to clipboard`)):i.shell.warning("The clipboard functionality requires a secure origin — either HTTPS or localhost")}))}(t,e)}async function Xs(){await async function(){let t,e;try{const s=new ne("Similarity, Diversity","Sequence similarity tracking and evaluation dataset diversity");await s.step("Load DNA sequences",(async()=>{i.shell.windows.showContextPanel=!1,i.shell.windows.showProperties=!1,e=await $e.files.readCsv(re),t=i.shell.addTableView(e),t.grid.columns.byName("cluster").visible=!1,t.grid.columns.byName("sequence_id").visible=!1,t.grid.columns.byName("sequence").width=300,t.grid.columns.byName("activity").visible=!1,t.grid.columns.byName("is_cliff").visible=!1}),{description:"Load dataset with macromolecules of 'fasta' notation, 'DNA' alphabet.",delay:2e3}).step("Find the most similar sequences to the current one",(async()=>{const s=await e.plot.fromType("Sequence Similarity Search",{moleculeColumnName:"sequence",similarColumnLabel:"Similar to current"});t.dockManager.dock(s,o.DOCK_TYPE.RIGHT,null,"Similarity search",.35)}),{description:"Add 'Sequence Similarity Search' viewer.",delay:2e3}).step("Explore most diverse sequences in a dataset",(async()=>{const s=await e.plot.fromType("Sequence Diversity Search",{moleculeColumnName:"sequence",diverseColumnLabel:"Top diverse sequences of all data"});t.dockManager.dock(s,o.DOCK_TYPE.DOWN,null,"Diversity search",.27)}),{description:"Add 'Sequence Deversity Search' viewer.",delay:2e3}).step("Choose another sequence for similarity search",(async()=>{e.currentRowIdx=3}),{description:"Handling current row changed of data frame showing update of similar sequences.",delay:2e3}).step("One more sequence for similarity search",(async()=>{e.currentRowIdx=7}),{description:"Just one more sequence to search similar ones.",delay:2e3}).start()}catch(t){oe(t)}}()}async function qs(){await async function(){let t,e,s,n,r;try{const a=new ne("Sequence Space","Exploring sequence space of Macromolecules, comparison with hierarchical clustering results");await a.step("Load DNA sequences",(async()=>{[n,t,e]=await Promise.all([$e.files.readCsv(ce),le(),he()]),s=i.shell.addTableView(n),s.grid.props.rowHeight=22,s.grid.columns.byName("cluster").visible=!1,s.grid.columns.byName("sequence").width=200,s.grid.columns.byName("is_cliff").visible=!1,i.shell.windows.showContextPanel=!1,i.shell.windows.showProperties=!1}),{description:"Load dataset with macromolecules of 'fasta' notation, 'DNA' alphabet.",delay:2e3}).step("Build sequence space",(async()=>{r=await async function(t,e,s,i){let n;{const t=Object.values(se);for(let s=0;s<t.length;s++){const i=t[s];if(!e.col(i)){const n=s==t.length-1;e.columns.add(o.Column.float(i,e.rowCount),n)}}if(e.rowCount>=1){const i=e.getCol(s).toList(),n=Date.now();$e.logger.debug("Bio: demoBio01aUI(), calc reduceDimensionality start...");const o=await Z(i,"UMAP",Tt.W.Levenshtein,{}),r=Date.now();$e.logger.debug(`Bio: demoBio01aUI(), calc reduceDimensionality ET: ${(r-n)/1e3} s`);for(let s=0;s<t.length;s++){const i=t[s],n=e.getCol(i),r=o.embedding[s];n.init((t=>r[t]))}const a=Date.now();$e.logger.debug(`MLB: MlbVrSpaceBrowser.buildView(), postprocess reduceDimensionality ET: ${(a-r)/1e3} s`)}n=await e.plot.fromType(o.VIEWER.SCATTER_PLOT,{xColumnName:se.X,yColumnName:se.Y,lassoTool:!0})}return t.dockManager.dock(n,o.DOCK_TYPE.RIGHT,null,"Sequence Space",.35),n}(s,n,ue)}),{description:"Reduce sequence space dimensionality to display on 2D representation.",delay:2e3}).step("Cluster sequences",(async()=>{const i=n.getCol(ue).toList(),o=ut.H.calc(i,((t,e)=>ae.T(t,e)/((t.length+e.length)/2))),r=await t.hierarchicalClusteringByDistance(o,"ward");e.injectTreeForGrid(s.grid,r,void 0,150,void 0)}),{description:"Perform hierarchical clustering to reveal relationships between sequences.",delay:2e3}).step("Select a sequence",(async()=>{n.selection.init((t=>[15].includes(t)))}),{description:"Handling selection of data frame row reflecting on linked viewers.",delay:2e3}).step("Select a bunch of sequences",(async()=>{const t=n.getCol("sequence_id");n.selection.init((e=>["c0_seq120","c0_seq105","c0_seq121","c0_seq93"].includes(t.get(e)))),n.currentRowIdx=27}),{description:"Selecting a group of rows from a data frame to show their similarity and proximity to each other on a viewer..",delay:2e3}).start()}catch(t){oe(t)}}()}async function $s(){await async function(){let t,e,s,n,r;const a=Xt.AL.UMAP;try{const l=new ne("Activity Cliffs","Activity Cliffs analysis on Macromolecules data");await l.step("Load DNA sequences",(async()=>{i.shell.windows.showContextPanel=!1,i.shell.windows.showProperties=!1,[s,t,e]=await Promise.all([$e.files.readCsv(ge),le(),he()]),n=i.shell.addTableView(s),n.grid.props.rowHeight=22,n.grid.columns.byName("cluster").visible=!1,n.grid.columns.byName("sequence").width=300,n.grid.columns.byName("is_cliff").visible=!1}),{description:"Load dataset with macromolecules of 'fasta' notation, 'DNA' alphabet.",delay:2e3}).step("Find activity cliffs",(async()=>{r=await Cs(s,s.getCol("Sequence"),s.getCol("Activity"),80,a),n.dockManager.dock(r,o.DOCK_TYPE.RIGHT,null,"Activity Cliffs",.35),de()(r.root).find("button.scatter_plot_link,cliffs_grid").get()[0].click()}),{description:"Reveal similar sequences with a cliff of activity.",delay:2e3}).step("Cluster sequences",(async()=>{const i=o.TaskBarProgressIndicator.create("Running sequence clustering..."),r=s.getCol("sequence").toList(),a=ut.H.calc(r,((t,e)=>ae.T(t,e)/((t.length+e.length)/2))),l=await t.hierarchicalClusteringByDistance(a,"ward");i.close(),e.injectTreeForGrid(n.grid,l,void 0,150,void 0),n.grid.columns.byName("Activity").scrollIntoView()}),{description:"Perform hierarchical clustering to reveal relationships between sequences.",delay:2e3}).step("Browse the cliff",(async()=>{const t=r.dataFrame.temp[".cliffsDfGrid"];t.dataFrame.rowCount>0&&(t.dataFrame.currentRowIdx=0)}),{description:"Zoom in to explore selected activity cliff details.",delay:2e3}).start()}catch(t){oe(t)}}()}async function Ks(){await async function(){const t="HELM";let e,s,r;try{await new ne("Atomic Level","Atomic level structure of Macromolecules").step("Loading Macromolecules notation 'Helm'",(async()=>{i.shell.windows.showContextPanel=!1,i.shell.windows.showProperties=!1,e=await $e.files.readCsv("samples/HELM.csv"),s=i.shell.addTableView(e);for(let e=0;e<s.grid.columns.length;e++){const i=s.grid.columns.byIndex(e);[t,"Activity"].includes(i.name)||(i.visible=!1)}}),{description:"Load dataset with macromolecules of 'fasta' notation, 'PT' alphabet (protein, aminoacids).",delay:2e3}).step("To atomic level",(async()=>{const s=e.getCol(t);await Ss(e,s)}),{description:"Get atomic level structures of Macromolecules.",delay:2e3}).step("Sketcher",(async()=>{const s=`molfile(${t})`;e.currentCell=e.cell(1,s);const i=e.currentCell.value,a=new o.chem.Sketcher(o.chem.SKETCHER_MODE.INPLACE);a.setMolFile(i),r=n.dialog().add(a).show(),await(0,Yt.gw)(3e3),r.close()}),{description:"Display atomic level structure within a sketcher.",delay:2e3}).start()}catch(t){oe(t)}}()}async function js(){await async function(){let t,e,s,n,r,a;const l="msa(HELM)",h=Xt.AL.UMAP;try{const c=new ne("Helm, MSA, Sequence Space","MSA and composition analysis on Helm data");await c.step("Load peptides with non-natural aminoacids in 'HELM' notation",(async()=>{t=i.shell.addTableView(e=await $e.files.readCsv(fe)),i.shell.windows.showContextPanel=!1,i.shell.windows.showProperties=!1}),{description:"Load dataset with macromolecules of 'Helm' notation.",delay:2e3}).step("Align peptides with non-natural aminoacids with PepSeA",(async()=>{s=e.getCol("HELM");const t=pe.J[0];n=await(0,pe.f)(s,l,t,1.53,0,void 0),e.columns.add(n),await i.data.detectSemanticTypes(e)}),{description:"Multiple sequence alignment (MSA) performed with PepSeA tool operating on non-natural aminoacids as well.",delay:2e3}).step("Build sequence space",(async()=>{a=await vs(e,n,h,X.U.LEVENSHTEIN,!0),t.dockManager.dock(a,o.DOCK_TYPE.RIGHT,null,"Sequence Space",.35)}),{description:"Reduce sequence space dimensionality to display on 2D representation.",delay:2e3}).step("Analyse sequence composition",(async()=>{r=await e.plot.fromType("WebLogo",{sequenceColumnName:l,positionWidth:40,maxHeight:50}),t.dockManager.dock(r,o.DOCK_TYPE.DOWN,null,"Composition analysis",.2)}),{description:"Composition analysis allows to reveal functional features of sequences like motifs, or variable loops.",delay:2e3}).start()}catch(t){oe(t)}}()}async function Js(t,e){var s;Ge(s=e),s.setTag("units",b.r2.SEPARATOR),s.setTag("separator","-"),await i.data.detectSemanticTypes(t)}function Qs(t){return function(t){function e(t){return t===c[0]?[Pe].concat(m.getMonomerSymbolsByType("PEPTIDE")):t===c[1]?[Pe].concat(m.getMonomerSymbolsByRGroup(3,"PEPTIDE")):["C"]}function s(){"N-Cys"===u.value?(d=e("N-O"),g=e("N-Cys")):(d=e(u.value),g=[...d]),p=n.choiceInput("R1:",d[0],d,(()=>{r.next()})),f=n.choiceInput("R2:",g[0],g,(()=>{r.next()})),r.next(),n.empty(y),[p,f].forEach((t=>{y.appendChild(t.root)}))}const i=new R.Subject,r=new R.Subject;i.subscribe((()=>{a.cyclizationType=u.value,s()})),r.subscribe((()=>{a.rightTerminal=f.value,a.leftTerminal=p.value}));const a={},l=["Cyclization"],h=n.choiceInput("Modification",l[0],l,(()=>a.transformationType=h.value)),c=["N-O","R3-R3","N-Cys"],u=n.choiceInput("Type",c[0],c,(()=>{i.next()})),m=zt.NT.instance.getBioLib();let d=[],g=[],p=n.choiceInput("R1:",d[0],d,(()=>{a.leftTerminal=p.value})),f=n.choiceInput("R2:",g[0],g,(()=>{a.rightTerminal=f.value}));const y=n.divV([p.root,f.root]);s(),a.cyclizationType=u.value,a.leftTerminal=p.value,a.rightTerminal=f.value,a.transformationType=h.value;const b=n.bigButton("Run",(async()=>Ze(t,a))),w=n.div([h,u,y,b]);return new o.Widget(w)}(t)}async function ti(t){const e=(0,z.Xk)(t),s=JSON.stringify(e);o.Utils.download(`${t.name}.json`,s)}},9017:(t,e,s)=>{"use strict";s.d(e,{k:()=>o});class i{constructor(){this.value=0,this.parentI=0,this.parentJ=0}}class n{constructor(t,e,s){this.seq1=t,this.seq2=e,this.score=s}}class o{fillNeedleman(){for(let t=0;t<=this.len1;t++)this.dpGrid[t][0].value=-t*this.gap,this.dpGrid[t][0].parentI=t-1,this.dpGrid[t][0].parentJ=0;for(let t=1;t<=this.len2;t++)this.dpGrid[0][t].value=-t*this.gap,this.dpGrid[0][t].parentI=0,this.dpGrid[0][t].parentJ=t-1}fillOne(t,e){this.dpGrid[t][e].value=Math.max(this.dpGrid[t-1][e-1].value+this.scores[t-1][e-1],Math.max(this.dpGrid[t-1][e].value-this.gap,this.dpGrid[t][e-1].value-this.gap)),this.dpGrid[t][e].value==this.dpGrid[t-1][e-1].value+this.scores[t-1][e-1]?(this.dpGrid[t][e].parentI=t-1,this.dpGrid[t][e].parentJ=e-1):this.dpGrid[t][e].value==this.dpGrid[t-1][e].value-this.gap?(this.dpGrid[t][e].parentI=t-1,this.dpGrid[t][e].parentJ=e):(this.dpGrid[t][e].parentI=t,this.dpGrid[t][e].parentJ=e-1)}gridFromName(t){switch(t){case"BLOSUM45":this.alignGrid=this.BLOSUM45,this.connections=this.CONBLO,this.step=1;break;case"BLOSUM50":this.alignGrid=this.BLOSUM50,this.connections=this.CONBLO,this.step=1;break;case"BLOSUM62":this.alignGrid=this.BLOSUM62,this.connections=this.CONBLO,this.step=1;break;case"BLOSUM80":this.alignGrid=this.BLOSUM80,this.connections=this.CONBLO,this.step=1;break;case"BLOSUM90":this.alignGrid=this.BLOSUM90,this.connections=this.CONBLO,this.step=1;break;case"PAM30":this.alignGrid=this.PAM30,this.connections=this.CONBLO,this.step=1;break;case"PAM70":this.alignGrid=this.PAM70,this.connections=this.CONBLO,this.step=1;break;case"PAM250":this.alignGrid=this.PAM250,this.connections=this.CONBLO,this.step=1;break;case"NUCLEOTIDES":this.alignGrid=this.NUCLEOTIDES,this.connections=this.CONNUCL,this.step=1;break;case"TRANS":this.alignGrid=this.TRANS,this.connections=this.CONNUCL,this.step=1;break;case"SCHNEIDER":this.alignGrid=this.SCHNEIDER,this.connections=this.CONSCHN,this.step=3}this.fillScores()}constructResult(t,e){let s="",i="",o="";const r=this.dpGrid[t][e].value;for(let t=0;t<this.step;t++)o+="|";for(;t>0||e>0;){this.dpGrid[t][e].parentI==t?(s=o+s,i=this.seq2.substr((e-1)*this.step,this.step)+i):this.dpGrid[t][e].parentJ==e?(i=o+i,s=this.seq1.substr((t-1)*this.step,this.step)+s):(s=t-1>=0?this.seq1.substr((t-1)*this.step,this.step)+s:o+s,i=e-1>=0?this.seq2.substr((e-1)*this.step,this.step)+i:o+i);const n=t;t=this.dpGrid[t][e].parentI,e=this.dpGrid[n][e].parentJ}return new n(s,i,r)}fillScores(){this.scores=[];for(let t=0;t<this.len1;t++){this.scores.push([]);for(let e=0;e<this.len2;e++)this.scores[t].push(this.alignGrid[this.connections[this.seq1.substr(t*this.step,this.step)]][this.connections[this.seq2.substr(e*this.step,this.step)]])}}typeRec(){if(/[ATGC]*/.test(this.seq1)&&/[ATGC]*/.test(this.seq2))return"NUCLEOTIDES";if(/[ARNDCQEGHILKMFPSTWYVBZX*]*/.test(this.seq1)&&/[ARNDCQEGHILKMFPSTWYVBZX*]*/.test(this.seq2))return"BLOSUM62";throw Error("Can't recognize sequence type")}needlemanWunch(){this.dpGrid=[];for(let t=0;t<this.len1+1;t++){const t=[];for(let e=0;e<this.len2+1;e++)t.push(new i);this.dpGrid.push(t)}this.fillNeedleman();for(let t=1;t<=this.len1;t++)for(let e=1;e<=this.len2;e++)this.fillOne(t,e);return this.constructResult(this.len1,this.len2)}smithWaterman(){this.dpGrid=[];for(let t=0;t<this.len1+1;t++){const t=[];for(let e=0;e<this.len2+1;e++)t.push(new i);this.dpGrid.push(t)}let t=0,e=0,s=0;for(let i=1;i<=this.len1;i++)for(let n=1;n<=this.len2;n++)this.fillOne(i,n),this.dpGrid[i][n].value<=0?(this.dpGrid[i][n].value=0,this.dpGrid[i][n].parentI=0,this.dpGrid[i][n].parentJ=0):0==this.dpGrid[this.dpGrid[i][n].parentI][this.dpGrid[i][n].parentJ].value&&(this.dpGrid[i][n].parentI=0,this.dpGrid[i][n].parentJ=0),this.dpGrid[i][n].value>t&&(t=this.dpGrid[i][n].value,e=i,s=n);return this.constructResult(e,s)}setSequences(t,e){this.seq1=t,this.seq2=e,this.len1=this.seq1.length/this.step,this.len2=this.seq2.length/this.step,this.fillScores()}setGap(t){this.gap=t}setMethod(t=""){"AUTO"==t&&(t=this.typeRec()),this.gridFromName(t)}constructor(t,e,s,i=""){this.seq1="",this.seq2="",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13.9,-.2,-8.2,-2.3,-6.8,-8.9,-11.1,-9.4,-10.9,-8.9,-11.7,-10,-9.9,-12.1,-15.2,-14.3,-14.4,11.1,2.9,9.2,3.5,-3,-7,-4.3,-6.2,-2.2,-6.6,-3.7,-5.7,-6,-10.4,-8.6,-9.5,-50,-15.5,-50,-13.9,-7.8,-10.5,-8.7,-9.6,-50,-16.5,-17.1,-14.8,-12.1,-18.9,-12.4,-17.4],[-8.5,.8,-9.1,-.7,-10.1,-7.5,-9.1,-8.2,-11.4,-3.1,-11.8,-4.4,-15.5,-14.3,-14.8,-15.4,-6.6,-4.7,-7.1,-5.8,-12.5,-10.3,-11,-12.2,-13.4,-10.6,-12.5,-11.8,-17.4,-15.1,-17.7,-15.7,2.9,12.5,3.1,10.3,-7.7,-5.2,-6.2,-7.3,-5.4,-1.7,-5.4,-3.7,-11.6,-9.1,-13,-10.8,-50,-10.3,-50,-11.2,-9.8,-8.3,-9.1,-9.7,-50,-12.7,-20.6,-13.1,-16,-16.6,-17,-18.4],[-5,-6.4,-3.4,-5.6,-7.5,-9.3,-7.1,-8.8,-8.8,-7.4,-6.9,-6.9,-11.4,-15.2,-9.7,-13.7,-1.8,-7.8,-.8,-7.2,-9.4,-10.6,-8.7,-11.2,-10,-10.1,-7.8,-10.5,-13.2,-14.6,-13,-14.5,9.2,3.1,10.8,3,-4.5,-6.7,-2.7,-6.7,-5,-6.8,-2.5,-6.7,-7.5,-10.4,-7.4,-10.2,-50,-15.5,-50,-14.2,-8.9,-10.2,-8.5,-10,-50,-15.6,-15.3,-15.5,-13,-18.8,-12.6,-18.3],[-8.1,-1.1,-8.9,1.4,-8.6,-9.2,-9.4,-6.8,-11,-4.9,-11.5,-2.6,-13.7,-16.8,-14.5,-12.6,-6,-6.7,-7.2,-4.2,-11.6,-11.9,-11.2,-10.9,-13.1,-12.2,-12.5,-10.3,-16.8,-17.2,-17.8,-14.6,3.5,10.3,3,12.4,-6.9,-7.5,-6.8,-4.9,-5.4,-4.2,-5.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.8,-8,-9.4,-7.2,-9.3,-13.3,-12.8,-10.9,-12.6,-1.8,-2.9,-.8,-2.9,-8.6,-13,-7.4,-12.4,-.4,-2.3,1.3,-2,-8.1,-9.3,-5.4,-8.4,10,8.6,11.4,8.9,-50,-13.7,-50,-13.2,-6.1,-8.1,-5.5,-7.5,-50,-11.3,-12.7,-10.1,-1.6,-7.8,-.3,-7.2],[-11.4,-10,-12.7,-8.2,-3.1,-3.1,-2.8,-.9,-11.7,-7.3,-12.1,-5.8,3.6,3.6,-1.1,5.8,-9.4,-11.9,-10.7,-10,-8.5,-8.8,-8.2,-6.5,-13.9,-13,-12.9,-10.9,-3.1,-2.3,-3.2,-.2,-9.5,-10.8,-10.2,-8.2,-1.1,-1.3,-.8,1.2,-8.6,-7.8,-7.8,-5,9,9.5,8.9,12,-50,-13,-50,-10.3,-6.2,-7,-7.1,-5.4,-50,-9.3,-14,-8.2,-2.4,-6.3,-2.4,-3.9],[-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,33.3,-50,30.6,-50,-50,-50,-50,-50,29.2,-50,-50,-50,-50,-50,-50,-50],[-14.8,-6.2,-14.9,-7.6,-14.6,-11.6,-13,-12.2,-14,-9,-14.1,-10.1,-13.6,-11.2,-12.4,-12.5,-8.1,2.2,-8.7,.4,-15.3,-11.3,-13.2,-13.3,-11.9,-7.2,-11.8,-7.9,-10.7,-7.4,-10.8,-8.9,-15.5,-10.3,-15.5,-12.5,-14.5,-12.1,-11.9,-12.8,-18.3,-12.7,-16.4,-14.7,-14.2,-10.4,-13.7,-13,-50,15.1,-50,13.3,-9.9,-5.8,-8.9,-7.6,-50,-1.5,-7.8,-3,-8.1,3.6,-9.4,2],[-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,30.6,-50,35.2,-50,-50,-50,-50,-50,28.5,-50,-50,-50,-50,-50,-50,-50],[-13.8,-7.5,-14.4,-5.1,-12.6,-11.6,-11.5,-10.1,-13.2,-9.7,-12.7,-7.4,-11.9,-11.9,-11.5,-10.2,-7.2,.9,-8.6,2.6,-14.1,-12.8,-13.3,-11,-9.7,-8.4,-11.2,-5.3,-9.3,-8.7,-9.9,-7.1,-13.9,-11.2,-14.2,-8.9,-12.9,-12.6,-12.6,-10.9,-15.4,-13.8,-14.8,-11.4,-12.8,-11.6,-13.2,-10.3,-50,13.3,-50,15.2,-8.6,-7,-8.4,-4.8,-50,-3,-7.1,-.1,-7.3,2.3,-8.7,3.9],[-7.3,-6.3,-8.9,-5.5,2.9,.2,1.5,1.2,-8.5,-2.3,-10,-1.7,-5.6,-10.5,-5.5,-9.6,-4.3,-7.9,-6.1,-7.2,2.3,-.6,.5,-0,-8.9,-11,-9.4,-9.3,-4.6,-9.4,-7.3,-8.1,-7.8,-9.8,-8.9,-9.2,2.8,.1,1.2,.8,-5.9,-6.8,-5.9,-6.3,-4.1,-7.2,-6.1,-6.2,-50,-9.9,-50,-8.6,12.5,9.4,11,9.8,-50,-4.8,-8.7,-3.5,-0,-8.6,-2.1,-7],[-10.1,-4.3,-10.8,-5.8,.1,2.3,.7,.6,-10.4,-.2,-10.8,-2,-8.8,-9.2,-8,-9.7,-6.8,-5.9,-7.5,-7,-1.4,2.2,-.9,-.4,-10.8,-7.7,-9.8,-8.8,-8.9,-7.3,-9.6,-9.1,-10.5,-8.3,-10.2,-10,-0,2.5,.7,.5,-7.5,-5.1,-7.1,-6.7,-7.4,-5.7,-8.1,-7,-50,-5.8,-50,-7,9.4,12.7,10.1,10,-50,-1.5,-11.3,-3.3,-5.4,-4.2,-5.6,-6.8],[-8.4,-6.2,-8.9,-5.9,1.8,.4,2.7,1.2,-9.1,-1.2,-8.8,-1.5,-7.2,-10.5,-4.9,-9.6,-5.7,-7.4,-5.5,-7.4,.3,-.3,1.8,-.4,-9,-8.7,-7.3,-8.9,-5.9,-9.4,-6.4,-8.7,-8.7,-9.1,-8.5,-9.4,1.4,.7,3.5,.7,-6.6,-5.3,-4.7,-5.8,-5.7,-7.5,-5.5,-7.1,-50,-8.9,-50,-8.4,11,10.1,13.2,10.2,-50,-4.2,-6.1,-3.6,-3.5,-8.4,-1.2,-6.8],[-9.1,-5.4,-10.4,-4.2,1,.5,.6,2.4,-9.6,-1.5,-10.5,-.5,-8.9,-10.5,-7.2,-8.3,-6.3,-6.9,-7.7,-5.1,-.5,.1,-.6,2.3,-11.1,-10.2,-10.5,-7,-8.3,-9.4,-9.4,-6.6,-9.6,-9.7,-10,-7.9,.7,.6,.8,2.3,-7.1,-6.5,-7.2,-5,-6.5,-7.4,-7.5,-5.4,-50,-7.6,-50,-4.8,9.8,10,10.2,12.1,-50,-3.1,-11.4,-.7,-4.6,-6.6,-4.9,-3.9],[-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,29.2,-50,28.5,-50,-50,-50,-50,-50,33.3,-50,-50,-50,-50,-50,-50,-50],[-13,-7,-13.1,-8.3,-9.2,-6.5,-8.9,-7.6,-9.8,-.7,-9.2,-2.1,-12.4,-10.3,-12.4,-11.6,-9.5,-4.6,-10.4,-5.7,-13.6,-10.1,-11.4,-10.9,-6.5,-1.5,-6.2,-3.6,-12.8,-8,-12.3,-9.7,-16.5,-12.7,-15.6,-14.3,-8.7,-6,-7.1,-7.5,-9.5,-4.1,-8.4,-6.1,-11,-8.6,-11.3,-9.3,-50,-1.5,-50,-3,-4.8,-1.5,-4.2,-3.1,-50,16.4,-5.1,14.2,-10.1,-4.3,-10,-5.4],[-13.5,-16.3,-11.8,-15.5,-13.6,-15.3,-12.1,-16.1,-7.7,-13.3,-4.2,-12.6,-14.1,-16.2,-10.3,-15.4,-9.6,-11.6,-7.7,-9.8,-14.3,-17.5,-11.1,-17.2,-5.3,-7.1,-2.2,-7.1,-9.6,-11.9,-8.7,-11.4,-17.1,-20.6,-15.3,-19.9,-14.1,-14.8,-12.4,-16.5,-11.7,-12.8,-6.4,-13.4,-14.3,-15.7,-12.7,-14,-50,-7.8,-50,-7.1,-8.7,-11.3,-6.1,-11.4,-50,-5.1,18.6,-4.8,-8.6,-8.1,-4.5,-7.3],[-12.4,-8.2,-13,-5.9,-7.7,-7.8,-7.4,-5.8,-8.8,-2,-9.3,-.4,-11.6,-11.3,-11.6,-9.4,-8.9,-5.6,-10,-3.2,-11.5,-11.1,-10.5,-8.3,-6.3,-4.9,-6.7,-1.2,-10.6,-9.7,-11.3,-8,-14.8,-13.1,-15.5,-11.4,-7.5,-7.5,-7.1,-5.9,-8.4,-5.8,-8.1,-3.6,-9.9,-9.7,-10.1,-8.2,-50,-3,-50,-.1,-3.5,-3.3,-3.6,-.7,-50,14.2,-4.8,16.4,-8.9,-5.8,-8.9,-3.4],[-10.7,-13.2,-12.4,-11.6,-4.8,-8.4,-6.1,-7.2,-10.3,-11.8,-11,-11.6,2.8,-1.7,.7,-1.1,-6.2,-9.7,-7.3,-8.4,-5.3,-8.6,-6.1,-8.3,-10.5,-11.2,-9.8,-10.2,9.5,6.5,7.6,6.8,-12.1,-16,-13,-16.2,-5.2,-8.6,-7.1,-7.8,-12.5,-14.4,-12.1,-13,1.4,-3,-1.6,-2.4,-50,-8.1,-50,-7.3,-0,-5.4,-3.5,-4.6,-50,-10.1,-8.6,-8.9,13.2,-.9,9.7,-.3],[-18.1,-12.3,-19.4,-14.2,-12.2,-9.5,-11.5,-10.8,-17.9,-11.9,-18.2,-13.9,-6.4,-3.7,-6.8,-5.4,-12.8,-5.9,-13.6,-7.4,-13.7,-9.9,-12.9,-12.7,-16.2,-11.6,-15.2,-12.7,-3.2,.5,-3.3,-1.8,-18.9,-16.6,-18.8,-19.2,-12.5,-9.4,-10.6,-11.1,-17.3,-14.1,-16.2,-16,-7.9,-3.7,-7.8,-6.3,-50,3.6,-50,2.3,-8.6,-4.2,-8.4,-6.6,-50,-4.3,-8.1,-5.8,-.9,14.2,-1.8,11.6],[-11.8,-13.1,-11.5,-12,-6.2,-8.3,-5.4,-7.4,-11.8,-12.3,-11.1,-11.4,.5,-2.5,2.4,-1.6,-6.8,-9.9,-6.4,-8.9,-6.1,-8.6,-5,-7.8,-10.4,-11.6,-8.5,-9.9,8.2,6.4,8.7,6.9,-12.4,-17,-12.6,-15.8,-6.5,-8.5,-5,-7.8,-13.2,-13.6,-10.3,-13.7,-.7,-3.2,-.3,-2.4,-50,-9.4,-50,-8.7,-2.1,-5.6,-1.2,-4.9,-50,-10,-4.5,-8.9,9.7,-1.8,11.3,-.9],[-17.2,-13.3,-17.8,-11.6,-11,-11.1,-10.4,-9,-16,-12.7,-16.1,-11.1,-5.2,-5.4,-6,-3.3,-11.8,-7.3,-13.3,-5.9,-12.7,-11.9,-11.9,-9.3,-15.2,-15,-14.9,-11,-2.8,-1.8,-2.9,.4,-17.4,-18.4,-18.3,-15.9,-10.7,-11.2,-10.6,-9,-15.4,-14.8,-15.8,-13.3,-6.8,-5.9,-7.2,-3.9,-50,2,-50,3.9,-7,-6.8,-6.8,-3.9,-50,-5.4,-7.3,-3.4,-.3,11.6,-.9,14.1]],this.TRANS=[[5,0,0,4],[0,5,4,0],[0,4,5,0],[4,0,0,5]],this.CONBLO={A:0,R:1,N:2,D:3,C:4,Q:5,E:6,G:7,H:8,I:9,L:10,K:11,M:12,F:13,P:14,S:15,T:16,W:17,Y:18,V:19,B:20,Z:21,X:22,"*":23},this.CONNUCL={A:0,T:1,C:2,G:3},this.CONSCHN={AAA:0,AAC:1,AAG:2,AAT:3,ACA:4,ACC:5,ACG:6,ACT:7,AGA:8,AGC:9,AGG:10,AGT:11,ATA:12,ATC:13,ATG:14,ATT:15,CAA:16,CAC:17,CAG:18,CAT:19,CCA:20,CCC:21,CCG:22,CCT:23,CGA:24,CGC:25,CGG:26,CGT:27,CTA:28,CTC:29,CTG:30,CTT:31,GAA:32,GAC:33,GAG:34,GAT:35,GCA:36,GCC:37,GCG:38,GCT:39,GGA:40,GGC:41,GGG:42,GGT:43,GTA:44,GTC:45,GTG:46,GTT:47,TAA:48,TAC:49,TAG:50,TAT:51,TCA:52,TCC:53,TCG:54,TCT:55,TGA:56,TGC:57,TGG:58,TGT:59,TTA:60,TTC:61,TTG:62,TTT:63},this.setMethod(i),this.setSequences(t,e),this.setGap(s)}}},7983:(t,e,s)=>{"use strict";s.d(e,{HV:()=>g,QF:()=>d,pf:()=>m,uH:()=>u});var i=s(4469),n=s(3870),o=s(976),r=s(7241),a=s(4293),l=s(1061),h=s(8447);const c="substr_helm";class u{constructor(t){this.col=t[0],this.createUI()}editHelmLinkAction(){(0,a.Y)(this.inputsDiv,this.grid.root),n.tools.waitForElementInDom(this.grid.root).then((()=>{setTimeout((()=>{this.grid.cell(c,0).element.children[0].dispatchEvent(new KeyboardEvent("keydown",{key:"Enter"}))}),100)}))}updateInputs(){const t=this.units===h.r2.HELM?n.divV([this.columnsInput,this.editHelmLink]):this.units===h.r2.SEPARATOR?n.inputs([this.columnsInput,this.substructureInput,this.separatorInput]):n.inputs([this.columnsInput,this.substructureInput]);(0,a.Y)(this.inputsDiv,t)}updateNotationDiv(){this.units=this.col.getTag(o.TAGS.UNITS),this.separator=this.col.getTag("separator");const t=this.dialog.root.getElementsByClassName("notation-text")[0];t&&(t.textContent=`Notation: ${this.units}`)}createUI(){const t=i.shell.tv.dataFrame,e={filter:t=>t.semType===o.SEMTYPE.MACROMOLECULE};this.columnsInput=n.columnInput("Column",t,this.col,(t=>{this.col=t,this.updateNotationDiv(),this.updateInputs()}),e),this.substructureInput=n.stringInput("Substructure",""),this.editHelmLink=n.link("Edit helm",(()=>this.editHelmLinkAction()),void 0,{style:{position:"relative",left:"95px"}});const s=o.DataFrame.create(1);s.columns.addNewString(c).init((t=>"")),s.col(c).semType=this.col.semType,s.col(c).setTag(o.TAGS.UNITS,h.r2.HELM),this.grid=s.plot.grid(),this.separatorInput=n.stringInput("Separator",this.separator),this.inputsDiv=n.div(),this.units=this.col.getTag(o.TAGS.UNITS),this.separator=this.col.getTag("separator"),this.updateInputs(),this.dialog=n.dialog("Substructure Search").add(n.divV([n.divText(`Notation: ${this.units}`,"notation-text"),this.inputsDiv])).onOK((async()=>{let t,e=this.units===h.r2.HELM?s.get(c,0):this.substructureInput.value;this.units===h.r2.SEPARATOR&&this.separatorInput.value!==this.separator&&""!==this.separatorInput.value&&(e=e.replaceAll(this.separatorInput.value,this.separator)),t=this.units===h.r2.HELM?await d(e,this.col):m(e,this.col),this.col.dataFrame.filter.and(t)})).show()}}function m(t,e,s){const i=s?function(t,e){const s=`${e}`.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),i=t.charAt(0)===e,n=t.charAt(t.length-1)===e,o=t.replace(new RegExp(`^${s}|${s}$`,"g"),"");return i?n?`${s}${o}${s}`:`${s}${o}${s}|${s}${o}$`:n?`^${o}${s}|${s}${o}${s}`:`^${o}${s}|${s}${o}${s}|${s}${o}$`}(t,s):t,n=o.BitSet.create(e.length);for(let s=0;s<e.length;s++){const o=e.get(s);(o.match(i)||o===t)&&n.set(s,!0,!1)}return n}async function d(t,e){e.version!==e.temp["last-invalidated-version"]&&await g(e,!0);const s=o.Column.string("helm",1).init((e=>t));s.semType=o.SEMTYPE.MACROMOLECULE,s.setTag(o.TAGS.UNITS,h.r2.HELM);const n=await(0,r.D)(s,!0,e.temp["monomers-dict"]);return(await i.functions.call("Chem:searchSubstructure",{molStringsColumn:e.temp["monomeric-mols"],molString:n.get(0),molBlockFailover:""})).get(0)}async function g(t,e){const s=o.TaskBarProgressIndicator.create(`Invalidating molfiles for ${t.name}`);await(0,l.gw)(10);const i=new Map,n=await(0,r.D)(t,e,i);t.temp["monomeric-mols"]=n,t.temp["monomers-dict"]=i,t.temp["last-invalidated-version"]=t.version,s.close()}},2568:(t,e,s)=>{"use strict";s.d(e,{n:()=>r});var i=s(4469),n=s(976),o=s(499);function r(t,e,s=[],r=[],a=!0){const[l,h]=function(t,e,s=[],r=[]){let a=!0,l="";const h=o.Cn.getOrCreate(t);if(t.semType!==n.SEMTYPE.MACROMOLECULE)i.shell.warning(e+" analysis is allowed for Macromolecules semantic type"),a=!1;else{const t=h.notation;if(s.length>0&&!s.some((e=>t.toUpperCase()==e.toUpperCase())))l=`${e} + ' analysis is allowed for Macromolecules with notation ${0==s.length?"any notation":`notation${s.length>1?"s":""} ${s.map((t=>`"${t}"`)).join(", ")} `}.`,a=!1;else if(!h.isHelm()){const t=h.alphabet;r.length>0&&!r.some((e=>t.toUpperCase()==e.toUpperCase()))&&(l=`${e} + ' analysis is allowed for Macromolecules with alphabet ${0==r.length?"any alphabet":`alphabet${r.length>1?"s":""} ${r.map((t=>`"${t}"`)).join(", ")}.`}.`,a=!1)}}return[a,l]}(t,e,s,r);return a&&!l&&i.shell.warning(h),l}},3553:(t,e,s)=>{"use strict";s.d(e,{Of:()=>o,WY:()=>h,jB:()=>c,rs:()=>a});var i,n,o,r,a,l=s(8341);!function(t){t.SPLIT_COL="~split",t.ACTIVITY="~activity",t.ACTIVITY_SCALED="activity_scaled",t.ALIGNED_SEQUENCE="~aligned_sequence",t.AMINO_ACID_RESIDUE="AAR",t.POSITION="Pos",t.P_VALUE="pValue",t.MEAN_DIFFERENCE="Mean difference"}(i||(i={})),function(t){t.AAR="AAR",t.POSITION="Pos",t.SELECTION="selection"}(n||(n={})),function(t){t.MONOMER="Monomer",t.MACROMOLECULE_DIFFERENCE="MacromoleculeDifference",t.ACTIVITY="activity",t.ACTIVITY_SCALED="activityScaled"}(o||(o={})),function(t){t.CELL_CHANGING="isCellChanging"}(r||(r={})),function(t){t.SEPARATOR="."}(a||(a={}));const h="3.3.1",c={pepsea:{gapOpen:1.53,gapExtend:0,method:l.J[0]},kalign:{gapOpen:-1,gapExtend:-1,terminalGap:-1}}},4004:(t,e,s)=>{"use strict";s.d(e,{O:()=>m});var i=s(976),n=s(3870),o=s(4469),r=s(3336),a=s.n(r),l=s(8447),h=s(499);let c=null,u=[];function m(t){let e=t??o.shell.t.columns.bySemType("Macromolecule");if(!e)throw new Error("No column with Macromolecule semantic type found");let s=h.Cn.getOrCreate(e),r=s.notation;const m=n.divText("Current notation: "+r,{style:{"text-align":"center","font-weight":"bold","font-size":"14px",padding:"5px"}}),d=[l.r2.FASTA,l.r2.SEPARATOR,l.r2.HELM],g=n.columnInput("Column",o.shell.t,e,(t=>{t.semType===i.SEMTYPE.MACROMOLECULE?(e=t,s=h.Cn.getOrCreate(e),r=s.notation,r===l.r2.HELM&&(y.value="/"),m.textContent="Current notation: "+r,f=d.filter((t=>t!==r)),w=n.choiceInput("Convert to",f[0],f,b),b(),c?.clear(),c?.add(n.div([m,g.root,w.root,y.root]))):g.value=e})),p=["-",".","/"];let f=d.filter((t=>t!==r));const y=n.choiceInput("Separator",p[0],p),b=()=>{w.value!==l.r2.SEPARATOR?a()(y.root).hide():a()(y.root).show()};let w=n.choiceInput("Convert to",f[0],f,b);b(),w.onChanged((()=>{b()})),null==c&&(c=n.dialog("Convert Sequence Notation").add(n.div([m,g.root,w.root,y.root])).onOK((async()=>{const t=w.value,s=y.value??void 0;await async function(t,e,s){const i=h.Cn.getOrCreate(t).convert(e,s);t.dataFrame.columns.add(i);const n=await o.functions.call("Bio:detectMacromolecule",{col:i});return n&&(i.semType=n),await o.data.detectSemanticTypes(t.dataFrame),i}(e,t,s)})).show({x:350,y:100}),u.push(c.onClose.subscribe((t=>{u.forEach((t=>{t.unsubscribe()})),u=[],c=null}))))}},5490:(t,e,s)=>{"use strict";s.d(e,{NT:()=>M,cf:()=>S});var i,n=s(4469),o=s(3870),r=s(976),a=s(701);class l{constructor(t){this.init(t)}init(t){this.fileContent=t.replace(/\r/g,""),this._atomCount=void 0,this._atomTypes=void 0,this._bondCount=void 0,this._bondTypes=void 0,this.xyzAtomCoordinates=void 0,this._pairsOfBondedAtoms=void 0}get atomCount(){return void 0===this._atomCount&&this.setAtomAndBondCounts(),this._atomCount}get bondCount(){return void 0===this._bondCount&&this.setAtomAndBondCounts(),this._bondCount}get x(){var t;return null!==(t=this.xyzAtomCoordinates)&&void 0!==t||(this.xyzAtomCoordinates=this.parseAtomCoordinates()),this.xyzAtomCoordinates.x}get y(){var t;return null!==(t=this.xyzAtomCoordinates)&&void 0!==t||(this.xyzAtomCoordinates=this.parseAtomCoordinates()),this.xyzAtomCoordinates.y}get z(){var t;return null!==(t=this.xyzAtomCoordinates)&&void 0!==t||(this.xyzAtomCoordinates=this.parseAtomCoordinates()),this.xyzAtomCoordinates.z}get atomTypes(){var t;return null!==(t=this._atomTypes)&&void 0!==t||(this._atomTypes=this.parseAtomTypes()),this._atomTypes}get pairsOfBondedAtoms(){var t;return null!==(t=this._pairsOfBondedAtoms)&&void 0!==t||(this._pairsOfBondedAtoms=this.parseBondedAtomPairs()),this._pairsOfBondedAtoms}get bondTypes(){var t;return null!==(t=this._bondTypes)&&void 0!==t||(this._bondTypes=this.parseBondTypes()),this._bondTypes}setAtomAndBondCounts(){const{atomCount:t,bondCount:e}=this.parseAtomAndBondCounts();this._atomCount=t,this._bondCount=e}getNextColumnIdx(t){for(;!this.isWhitespace(t);)++t;for(;this.isWhitespace(t);)++t;return t}shiftIdxToSpecifiedColumn(t,e){let s=t;const i=this.isWhitespace(s)?e:e-1;for(let t=0;t<i;t++)s=this.getNextColumnIdx(s);return s}parseAtomTypes(){const t=this.atomCount,e=new Array(t);let s=this.getAtomBlockIdx();for(let i=0;i<t;i++)s=this.shiftIdxToAtomType(s),e[i]=this.parseAtomType(s),s=this.getNextLineIdx(s);return e}parseAtomCoordinates(){const t=new Float32Array(this.atomCount),e=new Float32Array(this.atomCount),s=new Float32Array(this.atomCount);let i=this.getAtomBlockIdx();for(let n=0;n<this.atomCount;n++){i=this.shiftIdxToXColumn(i);for(const o of[t,e,s])o[n]=this.parseFloatValue(i),i=this.getNextColumnIdx(i);i=this.getNextLineIdx(i)}return{x:t,y:e,z:s}}parseBondedAtomPairs(){const t=new Array(this.bondCount);let e=this.getBondBlockIdx();for(let s=0;s<this.bondCount;s++){e=this.shiftIdxToBondedAtomsPair(e);const i=new Uint16Array(2);i[0]=this.parseIntValue(e),e=this.getNextColumnIdx(e),i[1]=this.parseIntValue(e),t[s]=i,e=this.getNextLineIdx(e)}return t}parseBondTypes(){const t=this.bondCount,e=new Uint16Array(t);let s=this.getBondBlockIdx();for(let i=0;i<t;i++)s=this.shiftIdxToBondType(s),e[i]=this.parseIntValue(s),s=this.getNextLineIdx(s);return e}isWhitespace(t){const e=this.fileContent[t];return" "===e||"\t"===e}getNextLineIdx(t){return"\n"!==this.fileContent[t]?this.fileContent.indexOf("\n",t)+1:t+1}parseFloatValue(t){return this.parseNumericValue(parseFloat,t)}parseIntValue(t){return this.parseNumericValue(parseInt,t)}parseNumericValue(t,e){let s=e+1;for(;!this.isWhitespace(s);)++s;return t(this.fileContent.substring(e,s))}}class h extends l{constructor(t){super(t),this.init(t)}init(t){super.init(t)}parseAtomType(t){let e=t,s=e;return this.isQuote(e)?(s=this.getNextIdenticalChar(e),e++):s=this.fileContent.indexOf(" ",s),this.fileContent.substring(e,s)}isQuote(t){const e=this.fileContent[t].charCodeAt(0);return 39===e||34===e}getNextIdenticalChar(t){const e=this.fileContent[t];return e?this.fileContent.indexOf(e,t+1):-1}isQuery(){return this.isQueryOrFragment(((t,e)=>{return 39===t||34===t||76===t&&!((s=this.fileContent.charCodeAt(e+1))>64&&s<91||s>96&&s<123);var s}))}isFragment(){return this.isQueryOrFragment((t=>82===t||42===t))}isQueryOrFragment(t){const e=this.atomCount;let s=this.getAtomBlockIdx();for(let i=0;i<e;i++){if(s=this.shiftIdxToAtomType(s),t(this.fileContent.charCodeAt(s),s))return!0;s=this.getNextLineIdx(s)}return!1}}!function(t){t.HEADER="V2000",t[t.NUM_OF_HEADER_LINES=3]="NUM_OF_HEADER_LINES",t[t.NUM_OF_COUNTS_DIGITS=3]="NUM_OF_COUNTS_DIGITS",t[t.ATOM_TYPE_COL=4]="ATOM_TYPE_COL",t[t.FIRST_BONDED_ATOM_COL=1]="FIRST_BONDED_ATOM_COL",t[t.BOND_TYPE_COL=3]="BOND_TYPE_COL",t[t.RGP_SHIFT=8]="RGP_SHIFT",t.RGP_LINE="M RGP",t.A_LINE="A ",t.END="M END"}(i||(i={}));class c extends h{constructor(t){super(t)}static validate(t){return-1!==t.indexOf(i.HEADER)&&-1!==t.indexOf(i.END)}shiftIdxToAtomType(t){return this.shiftIdxToSpecifiedColumn(t,i.ATOM_TYPE_COL)}getCountsLineIdx(){let t=0;for(let e=0;e<i.NUM_OF_HEADER_LINES;++e)t=this.getNextLineIdx(t);return t}getAtomBlockIdx(){let t=this.getCountsLineIdx();return t=this.getNextLineIdx(t),t}shiftIdxToXColumn(t){return this.getNextColumnIdx(t)}shiftIdxToBondedAtomsPair(t){return this.shiftIdxToSpecifiedColumn(t,i.FIRST_BONDED_ATOM_COL)}shiftIdxToBondType(t){return this.shiftIdxToSpecifiedColumn(t,i.BOND_TYPE_COL)}getBondBlockIdx(){let t=this.getAtomBlockIdx();for(let e=0;e<this.atomCount;e++)t=this.getNextLineIdx(t);return t}parseAtomAndBondCounts(){let t=this.getCountsLineIdx(),e=t+i.NUM_OF_COUNTS_DIGITS;const s=parseInt(this.fileContent.substring(t,e));return t=e,e+=i.NUM_OF_COUNTS_DIGITS,{atomCount:s,bondCount:parseInt(this.fileContent.substring(t,e))}}}class u extends h{constructor(t){super(t),this.init(t)}shiftIdxToAtomType(t){return this.shiftIdxToSpecifiedColumn(t,4)}getCountsLineIdx(){return this.fileContent.indexOf("M V30 COUNTS ")}getAtomBlockIdx(){let t=this.fileContent.indexOf("M V30 BEGIN ATOM");return t=this.getNextLineIdx(t),t}shiftIdxToXColumn(t){let e=this.shiftIdxToAtomType(t);return this.isQuote(e)?(e=this.getNextIdenticalChar(e),e=this.getNextColumnIdx(e),e):this.shiftIdxToSpecifiedColumn(t,5)}shiftIdxToBondedAtomsPair(t){return this.shiftIdxToSpecifiedColumn(t,5)}shiftIdxToBondType(t){return this.shiftIdxToSpecifiedColumn(t,4)}getBondBlockIdx(){return this.getNextLineIdx(this.fileContent.indexOf("M V30 BEGIN BOND"))}static validate(t){return-1!==t.indexOf("V3000")&&-1!==t.indexOf("M END")}parseAtomAndBondCounts(){let t=this.fileContent.indexOf("M V30 COUNTS ")+14,e=this.fileContent.indexOf(" ",t+1);const s=parseInt(this.fileContent.substring(t,e));return t=e+1,e=this.fileContent.indexOf(" ",t+1),{atomCount:s,bondCount:parseInt(this.fileContent.substring(t,e))}}}class m{constructor(){}static getInstance(t){if(c.validate(t))return new c(t);if(u.validate(t))return new u(t);throw new Error("Malformed molfile")}}var d=s(7228),g=s(2904);const p="Libraries",f="System:AppData/Bio/libraries/";async function y(){return await Promise.all((await n.dapi.files.list(f,!0,"")).map((async t=>t.fullPath.substring(f.length))))}let b=Promise.resolve();async function w(){let t;return b=b.then((async()=>{const e=await n.dapi.userDataStorage.getValue(p,"Settings",!0);t=e?JSON.parse(e):{exclude:[]},t.exclude=t.exclude instanceof Array?t.exclude:[],console.debug(`Bio: getUserLibSettings()\n${JSON.stringify(t,void 0,2)}`)})),await b,t}async function C(t){b=b.then((async()=>{console.debug(`Bio: setUserLibSettings()\n${JSON.stringify(t,void 0,2)}`),await n.dapi.userDataStorage.postValue(p,"Settings",JSON.stringify(t),!0)})),await b}async function v(){const t=o.dialog({title:"Manage files"}).add(o.fileBrowser({path:"System:AppData/Bio/libraries"}).root).addButton("OK",(()=>t.close())).show()}async function S(){const t=o.button("Manage",v),e=o.inputs([]),s=await y(),i=await w();for(const t of s){const s=o.boolInput(t,!i.exclude.includes(t),(()=>{1==s.value?i.exclude=i.exclude.filter((e=>e!=t)):i.exclude.includes(t)||i.exclude.push(t),C(i).then((async()=>{await M.instance.loadLibraries(!0),n.shell.info("Monomer library user settings saved.")}))}));e.append(s.root)}return new r.Widget(o.divV([e,o.div(t)]))}class T{constructor(t,e){this._monomers={},this._onChanged=new a.Subject,this._monomers=t,this.error=e}getMonomer(t,e){return t in this._monomers&&e in this._monomers[t]?this._monomers[t][e]:null}getPolymerTypes(){return Object.keys(this._monomers)}getMonomerMolsByPolymerType(t){const e={};return Object.keys(this._monomers[t]??{}).forEach((s=>{e[s]=this._monomers[t][s].molfile})),e}getMonomerSymbolsByType(t){return Object.keys(this._monomers[t])}getMonomerSymbolsByRGroup(t,e,s){let i=this.getMonomerSymbolsByType(e).map((t=>this.getMonomer(e,t)));return i=i.filter((t=>null!==t)),0===i.length?[]:(i=i.filter((e=>{if(!e?.rgroups)return!1;let s=e?.rgroups.length>=t;return m.getInstance(e.molfile).atomTypes.map(((t,e)=>"R#"===t?e:-1)).filter((t=>-1!==t)),s&&(s=!0),s})),i.map((t=>t?.symbol)))}get onChanged(){return this._onChanged}_updateInt(t){const e=t.getPolymerTypes(),s=this.getPolymerTypes();e.forEach((e=>{s.includes(e)||(this._monomers[e]={}),t.getMonomerSymbolsByType(e).forEach((s=>{this._monomers[e][s]=t.getMonomer(e,s)}))}))}update(t){this._updateInt(t),this._onChanged.next()}updateLibs(t,e=!1){e&&(this._monomers={});for(const e of t)e.error||this._updateInt(e);this._onChanged.next()}clear(){this._monomers={},this._onChanged.next()}}class M{constructor(){this._monomerLib=new T({}),this.loadLibrariesPromise=Promise.resolve()}getBioLib(){return this._monomerLib}async loadLibraries(t=!1){return this.loadLibrariesPromise=this.loadLibrariesPromise.then((async()=>{try{const[e,s]=await Promise.all([y(),w()]),i=e.filter((t=>!s.exclude.includes(t))),n=await Promise.all(i.map((t=>this.readLibrary(f,t).catch((e=>{const s=`Loading monomers from '${t}' error: ${e instanceof Error?e.message:e.toString()}`;return new T({},s)})))));this._monomerLib.updateLibs(n,t)}catch(t){const e=`Loading monomer libraries error: ${t instanceof Error?t.message:t.toString()}`;n.shell.warning(e);const s=t instanceof Error?t.stack:void 0;g._package.logger.error(e,void 0,s)}}))}async readLibrary(t,e){let s,i,o=[];const a=new r.FileSource(t);if(e.endsWith(".sdf"))1===r.Func.find({package:"Chem",name:"importSdf"}).length?(s=await a.readAsBytes(e),i=await n.functions.call("Chem:importSdf",{bytes:s}),o=(0,d.Xk)(i[0])):n.shell.warning("Chem package is not installed");else if(e.endsWith(".json")){const t=await a.readAsText(e);o=JSON.parse(t)}else{if(!e.endsWith(".csv"))throw new Error("Monomer library of unknown file format, supported formats: SDF, JSON, CSV");{const t=(l=await a.readCsv(e),Array.from({length:l.rowCount},((t,e)=>l.columns.names().reduce(((t,s)=>(t[s]=l.get(s,e),t)),{}))));if(!(0,d.eD)(t))throw new Error("Invalid format of CSV monomer lib");o=(0,d.Z)(t)}}var l;const h={},c=[];return o.forEach((t=>{c.includes(t.polymerType)||(h[t.polymerType]={},c.push(t.polymerType)),h[t.polymerType][t.symbol]=t})),new T(h)}static get instance(){return M._instance||(M._instance=new M),M._instance}}M._instance=null},525:(t,e,s)=>{"use strict";s.d(e,{K:()=>I});var i=s(4469),n=s(976),o=s(3870),r=s(8447),a=s(499),l=s(6098),h=s(8341),c=s(2568),u=s(3553),m=s(2904),d=s(3379),g=s.n(d),p=s(7795),f=s.n(p),y=s(569),b=s.n(y),w=s(3565),C=s.n(w),v=s(9216),S=s.n(v),T=s(4589),M=s.n(T),A=s(9564),E={};E.styleTagTransform=M(),E.setAttributes=C(),E.insert=b().bind(null,"head"),E.domAPI=f(),E.insertStyleElement=S(),g()(A.Z,E),A.Z&&A.Z.locals&&A.Z.locals;class x extends Error{constructor(t,e){super(t,e)}}async function I(t={}){return new Promise((async(e,s)=>{var r,a,l;t.clustersCol??(t.clustersCol=null),t.pepsea??(t.pepsea={}),(r=t.pepsea).method??(r.method=u.jB.pepsea.method),(a=t.pepsea).gapOpen??(a.gapOpen=u.jB.pepsea.gapOpen),(l=t.pepsea).gapExtend??(l.gapExtend=u.jB.pepsea.gapExtend);const c=t.col?.dataFrame??i.shell.t,m=t.col??c.columns.bySemType(n.SEMTYPE.MACROMOLECULE);if(null==m){const t="MSAError: dataset doesn't conain any Macromolecule column";i.shell.warning(t),s(new x(t))}const d=o.choiceInput("Method",t.pepsea.method,h.J);d.setTooltip("Alignment method");const g=o.floatInput("Terminal gap",t?.kalign?.terminalGap??null);g.setTooltip("Penalty for opening a gap at the beginning or end of the sequence");const p=o.p(`Kalign version: ${u.WY}`,"kalign-version"),f=o.floatInput("Gap open",t.pepsea.gapOpen);f.setTooltip("Gap opening penalty at group-to-group alignment");const y=o.floatInput("Gap extend",t.pepsea.gapExtend);y.setTooltip("Gap extension penalty to skip the alignment");const b=o.inputs([f,y,g]),w=o.button("Alignment parameters",(()=>{b.hidden=!b.hidden}),"Adjust alignment parameters such as penalties for opening and extending gaps");w.classList.add("msa-params-button"),b.hidden=!0,w.prepend(o.icons.settings((()=>null)));const C=[d.root.style],v=[g.root.style,p.style];let S;const T=o.columnInput("Sequence",c,m,(async()=>{S=await L(T.value,c,C,v,d,M,f,y,g)}),{filter:t=>t.semType===n.SEMTYPE.MACROMOLECULE});T.setTooltip("Sequences column to use for alignment");const M=o.columnInput("Clusters",c,t.clustersCol);if(M.nullable=!0,T.fireChanged(),t.col)return S=await L(t.col,c,C,v,d,M,f,y,g),void await N(T,c,S,e,s);o.dialog("MSA").add(T).add(M).add(d).add(b).add(w).add(p).onOK((async()=>{await N(T,c,S,e,s)})).show()}))}async function N(t,e,s,o,r){let a=null;const l=n.TaskBarProgressIndicator.create("Analyze for MSA ...");try{if(t.fireChanged(),t.value.semType!==n.SEMTYPE.MACROMOLECULE)throw new Error("Chosen column has to be of Macromolecule semantic type");if(void 0===s)throw new Error("Invalid column format");if(a=await s(),null==a)return r("PepSeA container has not started");e.columns.add(a),await i.data.detectSemanticTypes(e),o(a)}catch(t){const e=t instanceof Error?t.message:t.toString();i.shell.error(e),r(t)}finally{l.close()}}async function L(t,e,s,o,d,g,p,f,y){try{if(t.semType!==n.SEMTYPE.MACROMOLECULE)return;const i=e.columns.getUnusedName(`msa(${t.name})`);if((0,c.n)(t,t.name,[r.r2.FASTA,r.r2.SEPARATOR],["DNA","RNA","PT"],!1)){_(s,o,"kalign"),p.value=null,f.value=null,y.value=null;const e=a.Cn.getOrCreate(t),n=e.isFasta()?t:e.convert(r.r2.FASTA);return async()=>await(0,l.U)(n,!1,i,g.value)}if((0,c.n)(t,t.name,[r.r2.HELM],[],!1))return _(s,o,"pepsea"),p.value??(p.value=u.jB.pepsea.gapOpen),f.value??(f.value=u.jB.pepsea.gapExtend),async()=>await(0,h.f)(t,i,d.value,p.value,f.value,g.value);if((0,c.n)(t,t.name,[r.r2.SEPARATOR],["UN"],!1)){const e=a.Cn.getOrCreate(t).convert(r.r2.HELM);return _(s,o,"pepsea"),p.value??(p.value=u.jB.pepsea.gapOpen),f.value??(f.value=u.jB.pepsea.gapExtend),async()=>await(0,h.f)(e,i,d.value,p.value,f.value,g.value)}return p.value=null,f.value=null,y.value=null,void _(s,o,"kalign")}catch(t){const e=t instanceof Error?t.message:t.toString();i.shell.error(e),m._package.logger.error(e)}}function _(t,e,s){if("kalign"===s){for(const e of t)e.display="none";for(const t of e)t.removeProperty("display")}else{for(const t of e)t.display="none";for(const e of t)e.removeProperty("display")}}},6098:(t,e,s)=>{"use strict";s.d(e,{U:()=>k});var i=s(976),n=s(5226);const o=Symbol("Comlink.proxy"),r=Symbol("Comlink.endpoint"),a=Symbol("Comlink.releaseProxy"),l=Symbol("Comlink.thrown"),h=t=>"object"==typeof t&&null!==t||"function"==typeof t,c=new Map([["proxy",{canHandle:t=>h(t)&&t[o],serialize(t){const{port1:e,port2:s}=new MessageChannel;return u(t,e),[s,[s]]},deserialize:t=>(t.start(),d(t))}],["throw",{canHandle:t=>h(t)&&l in t,serialize({value:t}){let e;return e=t instanceof Error?{isError:!0,value:{message:t.message,name:t.name,stack:t.stack}}:{isError:!1,value:t},[e,[]]},deserialize(t){throw t.isError?Object.assign(new Error(t.value.message),t.value):t.value}}]]);function u(t,e=self){e.addEventListener("message",(function s(i){if(!i||!i.data)return;const{id:n,type:r,path:a}=Object.assign({path:[]},i.data),h=(i.data.argumentList||[]).map(C);let c;try{const e=a.slice(0,-1).reduce(((t,e)=>t[e]),t),s=a.reduce(((t,e)=>t[e]),t);switch(r){case"GET":c=s;break;case"SET":e[a.slice(-1)[0]]=C(i.data.value),c=!0;break;case"APPLY":c=s.apply(e,h);break;case"CONSTRUCT":c=function(t){return Object.assign(t,{[o]:!0})}(new s(...h));break;case"ENDPOINT":{const{port1:e,port2:s}=new MessageChannel;u(t,s),c=function(t,e){return b.set(t,e),t}(e,[e])}break;case"RELEASE":c=void 0;break;default:return}}catch(t){c={value:t,[l]:0}}Promise.resolve(c).catch((t=>({value:t,[l]:0}))).then((t=>{const[i,o]=w(t);e.postMessage(Object.assign(Object.assign({},i),{id:n}),o),"RELEASE"===r&&(e.removeEventListener("message",s),m(e))}))})),e.start&&e.start()}function m(t){(function(t){return"MessagePort"===t.constructor.name})(t)&&t.close()}function d(t,e){return p(t,[],e)}function g(t){if(t)throw new Error("Proxy has been released and is not useable")}function p(t,e=[],s=function(){}){let i=!1;const n=new Proxy(s,{get(s,o){if(g(i),o===a)return()=>v(t,{type:"RELEASE",path:e.map((t=>t.toString()))}).then((()=>{m(t),i=!0}));if("then"===o){if(0===e.length)return{then:()=>n};const s=v(t,{type:"GET",path:e.map((t=>t.toString()))}).then(C);return s.then.bind(s)}return p(t,[...e,o])},set(s,n,o){g(i);const[r,a]=w(o);return v(t,{type:"SET",path:[...e,n].map((t=>t.toString())),value:r},a).then(C)},apply(s,n,o){g(i);const a=e[e.length-1];if(a===r)return v(t,{type:"ENDPOINT"}).then(C);if("bind"===a)return p(t,e.slice(0,-1));const[l,h]=y(o);return v(t,{type:"APPLY",path:e.map((t=>t.toString())),argumentList:l},h).then(C)},construct(s,n){g(i);const[o,r]=y(n);return v(t,{type:"CONSTRUCT",path:e.map((t=>t.toString())),argumentList:o},r).then(C)}});return n}function f(t){return Array.prototype.concat.apply([],t)}function y(t){const e=t.map(w);return[e.map((t=>t[0])),f(e.map((t=>t[1])))]}const b=new WeakMap;function w(t){for(const[e,s]of c)if(s.canHandle(t)){const[i,n]=s.serialize(t);return[{type:"HANDLER",name:e,value:i},n]}return[{type:"RAW",value:t},b.get(t)||[]]}function C(t){switch(t.type){case"HANDLER":return c.get(t.name).deserialize(t.value);case"RAW":return t.value}}function v(t,e,s){return new Promise((i=>{const n=new Array(4).fill(0).map((()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16))).join("-");t.addEventListener("message",(function e(s){!s.data||!s.data.id||s.data.id!==n||(t.removeEventListener("message",e),i(s.data))})),t.start&&t.start(),t.postMessage(Object.assign({id:n},e),s)}))}const S="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2NvbnN0ICQ9U3ltYm9sKCJDb21saW5rLnByb3h5IiksQT1TeW1ib2woIkNvbWxpbmsuZW5kcG9pbnQiKSxSPVN5bWJvbCgiQ29tbGluay5yZWxlYXNlUHJveHkiKSx5PVN5bWJvbCgiQ29tbGluay50aHJvd24iKSxfPWU9PnR5cGVvZiBlPT0ib2JqZWN0IiYmZSE9PW51bGx8fHR5cGVvZiBlPT0iZnVuY3Rpb24iLEw9e2NhbkhhbmRsZTplPT5fKGUpJiZlWyRdLHNlcmlhbGl6ZShlKXtjb25zdHtwb3J0MTpyLHBvcnQyOml9PW5ldyBNZXNzYWdlQ2hhbm5lbDtyZXR1cm4gdyhlLHIpLFtpLFtpXV19LGRlc2VyaWFsaXplKGUpe3JldHVybiBlLnN0YXJ0KCksQyhlKX19LE89e2NhbkhhbmRsZTplPT5fKGUpJiZ5IGluIGUsc2VyaWFsaXplKHt2YWx1ZTplfSl7bGV0IHI7cmV0dXJuIGUgaW5zdGFuY2VvZiBFcnJvcj9yPXtp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3QuY29uZmlnLmRpclNoYXJlZH0ke3N9YDshaS5hbmFseXplUGF0aChzKS5leGlzdHN8fGUuYW5hbHl6ZVBhdGgobykuZXhpc3RzfHwodC5fbG9nKGBNb3VudGluZyAke3N9IG9udG8gJHt0LmJhc2UudG9vbH0gZmlsZXN5c3RlbSBhdCAke299YCksZS5ta2RpcihvKSxlLm1vdW50KHQuYmFzZS5tb2R1bGUuUFJPWFlGUyx7cm9vdDpzLGZzOml9LG8pKX19LF9maWxlb3AoZSxyKXt0Ll9sb2coYFJ1bm5pbmcgJHtlfSAke3J9YCk7Y29uc3QgaT10LmZzLmFuYWx5emVQYXRoKHIpO2lmKCFpLmV4aXN0cylyZXR1cm4gdC5fbG9nKGBGaWxlICR7cn0gbm90IGZvdW5kLmApLCExO3N3aXRjaChlKXtjYXNlImNhdCI6cmV0dXJuIHQuZnMucmVhZEZpbGUocix7ZW5jb2Rpbmc6InV0ZjgifSk7Y2FzZSJscyI6cmV0dXJuIHQuZnMuaXNGaWxlKGkub2JqZWN0Lm1vZGUpP3QuZnMuc3RhdChyKTp0LmZzLnJlYWRkaXIocik7Y2FzZSJkb3dubG9hZCI6Y29uc3Qgcz1uZXcgQmxvYihbdGhpcy5jYXQocildKTtyZXR1cm4gVVJMLmNyZWF0ZU9iamVjdFVSTChzKX1yZXR1cm4hMX0sX2xvZyhlKXtpZighdC5jb25maWcuZGVidWcpcmV0dXJuO2xldCByPVsuLi5hcmd1bWVudHNdO3Iuc2hpZnQoKSxjb25zb2xlLmxvZyhgJWNbV2ViV29ya2VyXSVjICR7ZX1gLCJmb250LXdlaWdodDpib2xkIiwiIiwuLi5yKX19O3codCl9KSgpOwo=",T=typeof window<"u"&&window.Blob&&new Blob([atob(S)],{type:"text/javascript;charset=utf-8"});function M(){const t=T&&(window.URL||window.webkitURL).createObjectURL(T);try{return t?new Worker(t):new Worker("data:application/javascript;base64,"+S)}finally{t&&(window.URL||window.webkitURL).revokeObjectURL(t)}}const A={urlCDN:"https://biowasm.com/cdn/v3",urlCDNStg:"https://stg.biowasm.com/cdn/v3",dirShared:"/shared",dirMounted:"/mnt",dirData:"/data",printInterleaved:!0,callback:null,debug:!1,env:"prd"};class E{constructor(t,e={}){if(null==t)throw"Expecting array of tools as input to Aioli constructor.";return Array.isArray(t)||(t=[t]),e=Object.assign({},A,e),t=t.map(this._parseTool),"stg"===e.env&&(e.urlCDN=e.urlCDNStg),this.tools=t,this.config=e,null!=this.config.callback&&(this.callback=this.config.callback),delete this.config.callback,this.init()}async init(){const t=new M;this.callback&&(t.onmessage=t=>{"biowasm"===t.data.type&&this.callback(t.data.value)});const e=d(t);return e.tools=this.tools,e.config=this.config,await e.init(),e}_parseTool(t){if("string"!=typeof t)return t;const e=t.split("/");if(2!=e.length&&3!=e.length)throw"Expecting '<tool>/<version>' or '<tool>/<program>/<version>'";return{tool:e[0],program:3==e.length?e[1]:e[0],version:e[e.length-1]}}}var x=s(850);class I{static getAvailableScales(){return Object.entries(this.scales).map((([t,e])=>t))}static getScale(t){return(0,x.hu)(!(void 0===this.scales[t]),`Scale '${t}' was not found.`),this.scales[t]}}I.scales={WimleyWhite:{"-":0,A:.17,C:-.24,D:-.07,E:-.01,F:-1.13,G:.01,H:.17,I:-.31,K:.99,L:-.56,M:-.23,N:.42,P:.45,Q:.58,R:.81,S:.13,T:.14,V:.07,W:-1.85,Y:-.94},categorial:{"-":0,A:1,C:2,D:3,E:4,F:5,G:6,H:7,I:8,K:9,L:10,M:11,N:12,P:13,Q:14,R:15,S:16,T:17,V:18,W:19,Y:20}};class N{constructor(t="categorial"){this.aa2num=I.getScale(t),this.num2aa={},Object.entries(this.aa2num).forEach((([t,e])=>this.num2aa[e]=t))}static _truncateSequence(t){let e=0,s=t.length;const i=["NH2","COOH"];if(t.startsWith(i[0])){const s=i[0].length;(0,x.hu)("-"==t[s],`Wrong sequence format: ${i[0]} without following '-' in '${t}'.`),e=s}if(t.endsWith(i[1])){const e=i[1].length+1;(0,x.hu)("-"==t[s-e],`Wrong sequence format: ${i[1]} without '-' precending in '${t}'.`),s-=e}return t.substring(e,s)}static _dropDefises(t){return t.replace(/(-)([^-]+)/g,"$2")}static clean(t){return N._dropDefises(N._truncateSequence(t))}encode(t){const e=t.length,s=new Array(e).fill(0);for(let i=0;i<e;++i){const e=t[i];(0,x.hu)(e in this.aa2num,`Unknown char '${e}' found in sequence '${t}'`),s[i]=this.encodeLettter(e)}return s}encodeLettter(t){return this.aa2num[t]}decode(t){let e="";for(let s=0;s<t.length;++s){const i=t[s];(0,x.hu)(i in this.num2aa,`Unknown code '${i}' found in vector '${t}'`),e+=this.num2aa[i]}return e}}var L=s(3553);const _="input.fa",R="result.fasta";function O(t){return t.reduce(((t,e,s)=>t+`>sample${s+1}\n${e}\n`),"")}async function k(t,e=!1,s="",o=null,r,a,l){let h=t.toList();e&&(h=h.map((t=>N.clean(t).replace(/\-/g,""))));const c=t.length;o??(o=i.Column.string("Clusters",c).init("0")),o.type!=i.COLUMN_TYPE.STRING&&(o=o.convertTo(i.TYPE.STRING)),o.compact();const u=o.categories,m=o.getRawData(),d=new Array(u.length),g=new Array(u.length);for(let t=0;t<c;++t){const e=m[t];(d[e]??(d[e]=[])).push(h[t]),(g[e]??(g[e]=[])).push(t)}const p=await new E(["base/1.0.0",{tool:"kalign",version:L.WY,reinit:!0}]),f=i.Column.string(s,c);for(let t=0;t<u.length;++t){const e=O(d[t]);await p.fs.writeFile(_,e);const s=`${void 0!==r?` --gpo ${r}`:""}${void 0!==a?` --gpe ${a}`:""}${void 0!==l?` --tgpe ${l}`:""}`,i=await p.exec(`kalign ${_} -f fasta -o ${R}${s}`);console.warn(i);const o=await p.cat(R);if(!o)throw new Error("kalign output no result");const h=new n.i(o).sequencesArray,c=g[t];for(let t=0;t<h.length;++t)f.set(c[t],h[t])}const y=t.getTag(i.TAGS.UNITS),b=t.getTag("alphabet");return f.setTag(i.TAGS.UNITS,y),f.setTag("aligned","SEQ.MSA"),f.setTag("alphabet",b),f.semType=i.SEMTYPE.MACROMOLECULE,f}},8341:(t,e,s)=>{"use strict";s.d(e,{J:()=>a,f:()=>h});var i=s(4469),n=s(976),o=s(8447),r=s(3553);const a=["mafft --auto","mafft","linsi","ginsi","einsi","fftns","fftnsi","nwns","nwnsi"],l=["AlignedSeq","AlignedSubpeptide","HELM","ID","PolymerID"];async function h(t,e,s="ginsi",a=1.53,h=0,u=null){const m=await i.dapi.docker.dockerContainers.filter("bio").first();if("started"!==m.status&&"checking"!==m.status)return i.log.warning("PepSeA container has not started yet"),null;const d=t.length;u??(u=n.Column.int("Clusters",d).init(0)),u.type!=n.COLUMN_TYPE.STRING&&(u=u.convertTo(n.TYPE.STRING));const g=u.categories,p=new Array(g.length);for(let e=0;e<d;++e){const s=u.get(e);if(""===s)continue;const i=g.indexOf(s),n=t.get(e);n&&(p[i]??(p[i]=[])).push({ID:e.toString(),HELM:n})}const f=new Array(d);for(const t of p){const e=(await c(m.id,t,s,a,h)).Alignment;for(const t of e)f[parseInt(t.ID)]=Object.entries(t).filter((t=>!l.includes(t[0]))).map((t=>"-"!==t[1]?t[1]:"")).join(r.rs.SEPARATOR)}const y=n.Column.fromStrings(e,f);return y.setTag(n.TAGS.UNITS,o.r2.SEPARATOR),y.setTag("separator",r.rs.SEPARATOR),y.setTag("aligned","SEQ.MSA"),y.setTag("alphabet","UN"),y.setTag(".alphabetIsMultichar","true"),y.semType=n.SEMTYPE.MACROMOLECULE,y}async function c(t,e,s,n,o){const r={method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(e)},a=`/align?method=${s}&gap_open=${n}&gap_extend=${o}`,l=await i.dapi.docker.dockerContainers.request(t,a,r);return JSON.parse(l??"{}")}},9943:(t,e,s)=>{"use strict";s.d(e,{C2:()=>u});var i=s(976),n=s(3870),o=s(4469),r=s(6414),a=s.n(r),l=s(8447),h=s(499);const c=60;function u(){const t=o.shell.tv.grid,e=a().count(0).take(t.columns.length).map((e=>t.columns.byIndex(e))).filter((t=>!!t.column&&t.column.semType!==i.SEMTYPE.MACROMOLECULE)).toArray(),s=e.find((t=>-1!==t.name.toLowerCase().indexOf("id"))),r=s?[s.name]:[],u=n.multiChoiceInput("Seq id columns",r,e.map((t=>t.name))),d=a().count(0).take(t.columns.length).map((e=>t.columns.byIndex(e))).filter((t=>{const e=t.column;return!(!e||e.semType!==i.SEMTYPE.MACROMOLECULE)&&h.Cn.getOrCreate(e).isFasta()})).toArray(),g=d.length>0?d[0].name:[],p=n.choiceInput("Seq column",g,d.map((t=>t.name))),f=n.intInput("FASTA line width",c);n.dialog({title:"Save as FASTA"}).add(n.inputs([u,p,f])).onOK((()=>{const e=u.value?u.value.map((e=>t.columns.byName(e).column)):[],s=p.value?t.columns.byName(p.value).column:null,i=f.value??c;s||o.shell.warning("Seq column is mandatory to save as FASTA.");const n=function(t,e,s=c,i="\n"){const n=l.kB,o=[];for(let r=0;r<e.length;r++){const a=t.map((t=>t.get(r).toString())).join("|"),l=m(e.get(r),n,s);o.push(`>${a}${i}`);for(const t of l)o.push(`${t}${i}`)}return"".concat(...o)}(e,s,i),r=document.createElement("a");r.setAttribute("href",`data:text/plain;charset=utf-8,${encodeURIComponent(n)}`),r.setAttribute("download",`${t.dataFrame.name}.fasta`),r.click()})).show()}function m(t,e,s=c){const i=e(t);let n=0;const o=i.length,r=[];for(;n<o;){const t=a()(i).slice(n,n+s).toArray(),e=t.map((t=>t.length>1?`[${t}]`:t)).join("");r.push(e),n+=t.length}return r}},9416:(t,e,s)=>{"use strict";s.d(e,{n:()=>h});var i=s(4469),n=s(976),o=s(1061),r=s(2568),a=s(8457),l=s(3553);async function h(t,e){if(await(0,o.gw)(10),!(0,r.n)(e,"Sequence space"))return t;const s=(0,a.O)(e);s.name="splitToMonomers";const h=e.dataFrame;for(const t of s.columns)t.semType=l.Of.MONOMER,t.setTag("alphabet",e.getTag("alphabet"));const c=/(\d+)(?: \((\d+)\))?/,u=t=>{c.lastIndex=0;const e=t.match(c);return e?`${e[1]} (${parseInt(e[2]??0)+1})`:t};for(let t=0;t<s.columns.length;t++){const i=s.columns.byIndex(t);i.semType=l.Of.MONOMER,i.setTag("alphabet",e.getTag("alphabet"));const n=100;let o=0;for(;h.columns.byName(i.name)&&o<n;)i.name=u(i.name),o++;h.columns.add(i)}await i.data.detectSemanticTypes(h);for(let t=0;t<s.columns.length;t++){const e=s.columns.byIndex(t);e.setTag(n.TAGS.CELL_RENDERER,"Monomer"),e.setTag(".use-as-filter","false")}return h}},4293:(t,e,s)=>{"use strict";s.d(e,{B:()=>o,Y:()=>r});var i=s(4469),n=s(976);function o(){const t=i.shell.t.columns.bySemTypeAll(n.SEMTYPE.MACROMOLECULE);if(null!==t)return t;i.shell.error("Current table does not contain macromolecules")}function r(t,e){t.innerHTML="",t.append(e)}},833:(t,e,s)=>{"use strict";s.d(e,{bo:()=>g,OZ:()=>C});var i=s(4469),n=s(3870),o=s(976),r=s(6414),a=s.n(r),l=s(701),h=s(499),c=s(8447),u=s(9298);function m(t){var e;return"string"==typeof t||t instanceof String?t:("object"==typeof t||t instanceof Object)&&"$thrownJsError"in t?m(t.$thrownJsError):t instanceof Error?null!==(e=t.stack)&&void 0!==e?e:t.message:t.toString()}var d,g,p=s(2904);HTMLCanvasElement.prototype.getCursorPosition=function(t,e){const s=this.getBoundingClientRect();return new o.Point((t.clientX-s.left)*e,(t.clientY-s.top)*e)},o.Rect.prototype.contains=function(t,e){return this.left<=t&&t<=this.right&&this.top<=e&&e<=this.bottom};class f{constructor(t=0,e){this.count=t,this.bounds=e}}class y{get label(){return this._label?this._label:this.name}constructor(t,e,s,i){this.pos=t,this.name=e,this._freqs=s??{},i?.rowCount&&(this.rowCount=i.rowCount),i?.sumForHeightCalc&&(this.sumForHeightCalc=i.sumForHeightCalc),i?.label&&(this._label=i.label)}getMonomers(){return Object.keys(this._freqs)}hasMonomer(t){return t in this._freqs}getFreq(t){let e=this._freqs[t];return e||(e=this._freqs[t]=new f),e}getMonomerAt(t,e){const s=Object.entries(this._freqs).find((([s,i])=>i.bounds.contains(t,e)));return s?s[0]:void 0}calcHeights(t){this.rowCount=0;for(const[t,e]of Object.entries(this._freqs))this.rowCount+=e.count;if(this.sumForHeightCalc=0,t===u.ES.Entropy)for(const[t,e]of Object.entries(this._freqs)){const t=e.count/this.rowCount;this.sumForHeightCalc+=-t*Math.log2(t)}else if(t===u.ES.full)for(const[t,e]of Object.entries(this._freqs)){const t=e.count/this.rowCount;this.sumForHeightCalc+=t}}calcScreen(t,e,s,i,n,r,a,l,h,c){const m=n==u.ES.Entropy?i*(r-this.sumForHeightCalc)/r:i;let d=c*h+(i-m-1);const g=Object.entries(this._freqs).sort(((e,s)=>t(e[0])||t(s[0])?t(e[0])&&t(s[0])?0:t(e[0])?-1:1:s[1].count-e[1].count));for(const t of g){const i=t[1],n=m*i.count/this.rowCount;i.bounds=new o.Rect((e-s)*h*a,d,l*h,n),d+=n}}render(t,e,s,i,n,o){for(const[r,a]of Object.entries(this._freqs))if(!e(r)){const e=(0,c.GU)(r,5),l=a.bounds,h=l.left;t.resetTransform(),t.strokeStyle="lightgray",t.lineWidth=1,t.rect(h,l.top,l.width,l.height),t.fillStyle=o.get(r)??o.get("other"),t.textAlign="left",t.font=s;const u=t.measureText(e);t.setTransform(l.width/u.width,0,0,l.height/n,h,l.top),t.fillText(e,0,-i)}}}!function(t){t.STYLE="Style",t.BEHAVIOR="Behavior",t.LAYOUT="Layout",t.DATA="Data"}(d||(d={})),function(t){t.sequenceColumnName="sequenceColumnName",t.startPositionName="startPositionName",t.endPositionName="endPositionName",t.skipEmptySequences="skipEmptySequences",t.skipEmptyPositions="skipEmptyPositions",t.shrinkEmptyTail="shrinkEmptyTail",t.backgroundColor="backgroundColor",t.positionHeight="positionHeight",t.positionWidth="positionWidth",t.verticalAlignment="verticalAlignment",t.horizontalAlignment="horizontalAlignment",t.fixWidth="fixWidth",t.fitArea="fitArea",t.minHeight="minHeight",t.maxHeight="maxHeight",t.showPositionLabels="showPositionLabels",t.positionMarginState="positionMarginState",t.positionMargin="positionMargin",t.filterSource="filterSource"}(g||(g={}));const b=u.vS;var w;!function(t){t[t.None=0]="None",t[t.Render=1]="Render",t[t.Layout=1]="Layout",t[t.Freqs=2]="Freqs"}(w||(w={}));class C extends o.JsViewer{get positionWidthWithMargin(){return this._positionWidthWithMargin}get Length(){return this.skipEmptyPositions?this.positions.length:this.startPosition<=this.endPosition?this.endPosition-this.startPosition+1:0}get positionMarginValue(){return this.positionMarginState===u.dE.AUTO&&!0===this.unitsHandler.getAlphabetIsMultichar()||this.positionMarginState===u.dE.ON?this.positionMargin:0}constructor(){super(),this.viewed=!1,this.viewerId=-1,this.initialized=!1,this.cp=null,this.seqCol=null,this.positions=[],this.visibleSlider=!1,this.allowResize=!0,this.turnOfResizeForOneSetValue=!1,this.backgroundColor=4294967295,this.positionMargin=0,this.positionNames=[],this.positionLabels=void 0,this.startPosition=-1,this.endPosition=-1,this.error=null,this.viewPromise=Promise.resolve(),this.detachPromise=Promise.resolve(),this.setDataInProgress=!1,this.viewSubs=[],this._onSizeChanged=new l.Subject,this._onFreqsCalculated=new l.Subject,this._onLayoutCalculated=new l.Subject,this.renderLevelRequested=w.Freqs,this.viewerId=C.viewerCount,C.viewerCount+=1,this.textBaseline="top",this.unitsHandler=null,this.sequenceColumnName=this.string(g.sequenceColumnName,b.sequenceColumnName,{category:d.DATA}),this.startPositionName=this.string(g.startPositionName,b.startPositionName,{category:d.DATA}),this.endPositionName=this.string(g.endPositionName,b.endPositionName,{category:d.DATA}),this.skipEmptySequences=this.bool(g.skipEmptySequences,b.skipEmptySequences,{category:d.DATA}),this.skipEmptyPositions=this.bool(g.skipEmptyPositions,b.skipEmptyPositions,{category:d.DATA}),this.shrinkEmptyTail=this.bool(g.shrinkEmptyTail,b.shrinkEmptyTail,{category:d.DATA}),this.backgroundColor=this.int(g.backgroundColor,b.backgroundColor,{category:d.STYLE}),this.positionHeight=this.string(g.positionHeight,b.positionHeight,{category:d.STYLE,choices:Object.values(u.ES)}),this._positionWidth=this.positionWidth=this.float(g.positionWidth,b.positionWidth,{category:d.STYLE}),this.verticalAlignment=this.string(g.verticalAlignment,b.verticalAlignment,{category:d.LAYOUT,choices:Object.values(u.vw)}),this.horizontalAlignment=this.string(g.horizontalAlignment,b.horizontalAlignment,{category:d.LAYOUT,choices:Object.values(u.iD)}),this.fixWidth=this.bool(g.fixWidth,b.fixWidth,{category:d.LAYOUT,userEditable:!1}),this.fitArea=this.bool(g.fitArea,b.fitArea,{category:d.LAYOUT}),this.minHeight=this.float(g.minHeight,b.minHeight,{category:d.LAYOUT}),this.maxHeight=this.float(g.maxHeight,b.maxHeight,{category:d.LAYOUT}),this.showPositionLabels=this.bool(g.showPositionLabels,b.showPositionLabels,{category:d.LAYOUT}),this.positionMarginState=this.string(g.positionMarginState,b.positionMarginState,{category:d.LAYOUT,choices:Object.values(u.dE)});let t=0;"auto"===this.positionMarginState&&(t=4),this.positionMargin=this.int(g.positionMargin,t,{category:d.LAYOUT,min:0,max:16}),this.filterSource=this.string(g.filterSource,b.filterSource,{category:d.BEHAVIOR,choices:Object.values(u.Ct)}),this.slider=n.rangeSlider(0,100,0,20,!1,{style:"barbell"}),this.canvas=n.canvas(),this.canvas.classList.value="bio-wl-canvas",this.canvas.style.width="100%"}setData(){this.setDataInProgress||(this.setDataInProgress=!0,p._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.setData() `),this.viewPromise=this.viewPromise.then((async()=>{this.viewed&&(await this.destroyView(),this.viewed=!1)})).then((async()=>{await this.detachPromise,this.updateSeqCol()})).then((async()=>{this.viewed||(await this.buildView(),this.viewed=!0)})).finally((()=>{this.setDataInProgress=!1})))}async destroyView(){for(const t of this.viewSubs)t.unsubscribe();this.viewSubs=[];const t=this.dataFrame?"data":"null";p._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.destroyView( dataFrame = ${t} ) start`),this.host.remove(),this.msgHost=void 0,this.host=void 0,p._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.destroyView() end`)}async buildView(){const t=this.dataFrame?"data":"null";p._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.buildView( dataFrame = ${t} ) start`),window.devicePixelRatio,this.helpUrl="/help/visualize/viewers/web-logo.md",this.msgHost=n.div("No message",{classes:"bio-wl-msg"}),this.msgHost.style.display="none",this.canvas=n.canvas(),this.canvas.style.width="100%",this.slider.root.style.position="absolute",this.slider.root.style.zIndex="999",this.slider.root.style.display="none",this.slider.root.style.height="0.7em",this.visibleSlider=!1,this.host=n.div([this.msgHost,this.canvas],{classes:"bio-wl-host",style:{display:"flex",flexDirection:"row",flexWrap:"wrap"}}),this.root.append(this.host),this.root.append(this.slider.root),this.error&&(this.msgHost.innerText=this.error.message,n.tooltip.bind(this.msgHost,this.error.stack),this.msgHost.style.setProperty("display",null)),this.dataFrame&&(this.viewSubs.push(this.dataFrame.filter.onChanged.subscribe(this.dataFrameFilterOnChanged.bind(this))),this.viewSubs.push(this.dataFrame.selection.onChanged.subscribe(this.dataFrameSelectionOnChanged.bind(this)))),this.viewSubs.push(n.onSizeChanged(this.root).subscribe(this.rootOnSizeChanged.bind(this))),this.viewSubs.push(this.slider.onValuesChanged.subscribe(this.sliderOnValuesChanged.bind(this))),this.viewSubs.push((0,l.fromEvent)(this.canvas,"mousemove").subscribe(this.canvasOnMouseMove.bind(this))),this.viewSubs.push((0,l.fromEvent)(this.canvas,"mousedown").subscribe(this.canvasOnMouseDown.bind(this))),this.viewSubs.push((0,l.fromEvent)(this.canvas,"wheel").subscribe(this.canvasOnWheel.bind(this))),await this.render(w.Freqs,"buildView"),p._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.buildView() end`)}rootOnSizeChanged(){p._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.rootOnSizeChanged(), start `),this.render(w.Layout,"rootOnSizeChanged").then((()=>{}))}updateSeqCol(){if(this.dataFrame&&(this.seqCol=this.sequenceColumnName?this.dataFrame.col(this.sequenceColumnName):null,null==this.seqCol&&(this.seqCol=(0,c.up)(this.dataFrame),this.sequenceColumnName=this.seqCol?this.seqCol.name:null),this.seqCol)){try{this.unitsHandler=h.Cn.getOrCreate(this.seqCol),this.cp=(0,c.dQ)(this.seqCol),this.updatePositions(),this.error=null}catch(t){throw this.seqCol=null,this.error=t instanceof Error?t:new Error(t.toString()),t}this.seqCol||(this.unitsHandler=null,this.positionNames=[],this.positionLabels=[],this.startPosition=-1,this.endPosition=-1,this.cp=null)}}updatePositions(){if(!this.seqCol)return;const t=this.getFilter(),e=0===t.trueCount?this.unitsHandler.maxLength:a().enumerate(this.unitsHandler.splitted).map((([e,s])=>t.get(s)&&e?e.length:0)).reduce(((t,e)=>Math.max(t,e)),0),s=this.seqCol.getTag(".positionNames"),i=this.seqCol.getTag(".positionLabels");this.positionNames=s?s.split(c.CI).map((t=>t.trim())):[...Array(e).keys()].map((t=>`${t+1}`)),this.positionLabels=i?i.split(c.CI).map((t=>t.trim())):void 0,this.startPosition=this.startPositionName&&this.positionNames&&this.positionNames.includes(this.startPositionName)?this.positionNames.indexOf(this.startPositionName):0,this.endPosition=this.endPositionName&&this.positionNames&&this.positionNames.includes(this.endPositionName)?this.positionNames.indexOf(this.endPositionName):e-1,this.render(w.Freqs,"updatePositions").then((()=>{}))}getFilter(){let t;switch(this.filterSource){case u.Ct.Filtered:t=this.dataFrame.filter;break;case u.Ct.Selected:t=0===this.dataFrame.selection.trueCount?this.dataFrame.filter:this.dataFrame.selection}return t}setSliderVisibility(t){t?(this.slider.root.style.display="inherit",this.visibleSlider=!0):(this.slider.root.style.display="none",this.visibleSlider=!1)}calcLayout(t){this.host&&this.canvas&&this.slider&&(this.host.classList.remove("bio-wl-fixWidth","bio-wl-fitArea"),this.canvas.classList.remove("bio-wl-fixWidth","bio-wl-fitArea"),this._positionWidth=this.positionWidth,this._positionMargin=this.positionMargin,this._positionWidthWithMargin=this._positionWidth+this.positionMarginValue,this.fixWidth?this.calcLayoutFixWidth(t):this.fitArea?this.calcLayoutFitArea(t):this.calcLayoutNoFitArea(t),this.slider.root.style.width=`${this.host.clientWidth}px`)}calcLayoutFixWidth(t){if(!this.host||!this.canvas||!this.slider)return;this.host.classList.add("bio-wl-fixWidth"),this.canvas.classList.add("bio-wl-fitArea");const e=this._positionWidthWithMargin*this.Length,s=Math.min(Math.max(this.minHeight,this.root.clientHeight),this.maxHeight);this.host.style.justifyContent=u.iD.LEFT,this.host.style.removeProperty("margin-left"),this.host.style.removeProperty("margin-top"),this.host.style.width=this.canvas.style.width=`${e}px`,this.host.style.height=this.canvas.style.height=`${s}px`,this.host.style.left=this.canvas.style.left="0",this.host.style.top=this.canvas.style.top="0",this.host.style.setProperty("overflow","hidden","important"),this.slider.root.style.display="none",this.slider.setValues(0,Math.max(0,this.Length-1),0,Math.max(0,this.Length-1)),this.canvas.width=e*t,this.canvas.height=s*t}calcLayoutNoFitArea(t){if(!this.host||!this.canvas||!this.slider)return;const e=this._positionWidthWithMargin*this.Length,s=Math.min(Math.max(this.minHeight,this.root.clientHeight),this.maxHeight),i=Math.min(this.root.clientWidth,e);this.canvas.style.width=`${i}px`,this.canvas.style.height=`${s}px`,this.host.style.width=`${i}px`,this.host.style.height=`${this.root.clientHeight}px`,this.host.style.justifyContent=this.horizontalAlignment,this.host.style.alignContent=this.verticalAlignment===u.vw.TOP?"start":this.verticalAlignment===u.vw.MIDDLE?"center":this.verticalAlignment===u.vw.BOTTOM?"end":"inherit",this.root.clientHeight<this.minHeight&&(this.host.style.alignContent="start",this.host.style.width=`${i+6}px`),this.host.style.width=`${this.host}px`;const n=e>i;if(this.setSliderVisibility(n),n){this.slider.root.style.removeProperty("display"),this.host.style.justifyContent="left",this.host.style.height=this.root.clientHeight-this.slider.root.offsetHeight+"px",this.slider.root.style.top=`${this.host.offsetHeight}px`;let t=Math.min(Math.max(0,this.slider.min),this.Length-.001),e=Math.min(Math.max(0,this.slider.max),this.Length-.001);const s=this.root.clientWidth/this._positionWidthWithMargin;e=Math.min(Math.max(t,0)+s,this.Length-.001),t=Math.max(0,Math.min(e,this.Length-.001)-s),this.slider.setValues(0,Math.max(this.Length-.001),t,e)}else this.slider.setValues(0,Math.max(0,this.Length-.001),0,Math.max(0,this.Length-.001));this.canvas.width=i*t,this.canvas.height=s*t}calcLayoutFitArea(t){if(!this.host||!this.canvas||!this.slider)return;const e=this._positionWidth*this.Length,s=Math.min(Math.max(this.minHeight,this.root.clientHeight),this.maxHeight),i=e>0?(this.root.clientWidth-this.positionMarginValue*this.Length)/e:0,n=this.root.clientHeight/s,o=Math.max(1,Math.min(i,n));this._positionWidth=this.positionWidth*o,this._positionWidthWithMargin=this._positionWidth+this.positionMarginValue;const r=(this._positionWidth+this.positionMarginValue)*this.Length,a=o*s,l=Math.min(this.root.clientWidth,r);this.canvas.style.width=`${l}px`,this.canvas.style.height=`${a}px`,this.host.style.width=`${l}px`,this.host.style.height=`${this.root.clientHeight}px`,this.host.style.justifyContent=this.horizontalAlignment,this.host.style.alignContent=this.verticalAlignment===u.vw.TOP?"start":this.verticalAlignment===u.vw.MIDDLE?"center":this.verticalAlignment===u.vw.BOTTOM?"end":"inherit",this.root.clientHeight<this.minHeight&&(this.host.style.alignContent="start",this.host.style.width=`${l+6}px`),this.host.style.width=`${this.host}px`;const h=r>l;if(this.setSliderVisibility(h),h){this.slider.root.style.removeProperty("display"),this.host.style.justifyContent="left",this.host.style.height=this.root.clientHeight-this.slider.root.offsetHeight+"px",this.slider.root.style.top=`${this.host.offsetHeight}px`;let t=Math.min(Math.max(0,this.slider.min),this.Length-.001),e=Math.min(Math.max(0,this.slider.max),this.Length-.001);const s=this.root.clientWidth/this._positionWidthWithMargin;e=Math.min(Math.max(t,0)+s,this.Length-.001),t=Math.max(0,Math.min(e,this.Length-.001)-s),this.slider.setValues(0,Math.max(0,this.Length-.001),t,e)}else this.slider.setValues(0,Math.max(0,this.Length-.001),0,Math.max(0,this.Length-.001));this.canvas.width=l*t,this.canvas.height=a*t}onPropertyChanged(t){switch(super.onPropertyChanged(t),t.name){case g.sequenceColumnName:this.updateSeqCol();break;case g.sequenceColumnName:case g.startPositionName:case g.endPositionName:case g.filterSource:case g.shrinkEmptyTail:case g.skipEmptyPositions:case g.positionHeight:this.updatePositions();break;case g.minHeight:case g.maxHeight:case g.positionWidth:case g.showPositionLabels:case g.fixWidth:case g.fitArea:case g.horizontalAlignment:case g.verticalAlignment:case g.positionMargin:case g.positionMarginState:this.render(w.Layout,`onPropertyChanged(${t.name})`).then((()=>{}));break;case g.backgroundColor:this.render(w.Render,`onPropertyChanged(${t.name})`).then((()=>{}))}}onTableAttached(){p._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.onTableAttached(), `),super.onTableAttached(),this.setData()}async detach(){if(this.setDataInProgress)return;p._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.detach(), `);const t=super.detach.bind(this);this.detachPromise=this.detachPromise.then((async()=>{await this.viewPromise,this.viewed&&(await this.destroyView(),this.viewed=!1),t()}))}get onSizeChanged(){return this._onSizeChanged}get onFreqsCalculated(){return this._onFreqsCalculated}get onLayoutCalculated(){return this._onLayoutCalculated}getMonomer(t,e){const s=t.x,i=Math.floor(t.x/(this._positionWidthWithMargin*e)+Math.floor(this.slider.min)),n=this.positions[i];if(void 0===n)return[i,null,null];const o=n.getMonomerAt(s,t.y);return void 0===o?[i,null,null]:[i,o,n.getFreq(o)]}_nullSequence(t="X"){return this.skipEmptySequences?"":new Array(this.Length).fill(t).join("")}_removeEmptyPositions(){this.skipEmptyPositions&&(this.positions=a()(this.positions).filter((t=>{const e=this.unitsHandler.defaultGapSymbol;return!t.hasMonomer(e)||t.getFreq(e).count!==t.rowCount})).toArray())}render(t,e){p._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.render( recalcLevelVal=${t}, reason='${e}' )`);const s=()=>{if(p._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.render.calculateFreqsInt(), start `),!this.host||!this.seqCol||!this.dataFrame)return;const t=this.startPosition<=this.endPosition?this.endPosition-this.startPosition+1:0;this.unitsHandler=h.Cn.getOrCreate(this.seqCol);const e=this.startPosition<=this.endPosition?this.endPosition-this.startPosition+1:0;this.positions=new Array(e);for(let e=0;e<t;e++){const t=this.positionNames[this.startPosition+e],s=this.positionLabels?this.positionLabels[this.startPosition+e]:void 0;this.positions[e]=new y(this.startPosition+e,t,{},{label:s})}const s=this.getFilter(),i=this.dataFrame.rowCount,n=this.unitsHandler.splitted;for(let e=0;e<i;++e)if(s.get(e)){const s=n[e];for(let e=0;e<t;++e){const t=s[this.startPosition+e]||this.unitsHandler.defaultGapSymbol;this.positions[e].getFreq(t).count++}}for(let e=0;e<t;e++)this.positions[e].calcHeights(this.positionHeight);this._removeEmptyPositions(),this._onFreqsCalculated.next()},n=(t,e)=>{p._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.render.calculateLayoutInt(), start `);const s=this.canvas.height-e*t,n=this.getAlphabetSize();this.positionHeight==u.ES.Entropy&&null==n&&i.shell.error("WebLogo: alphabet is undefined.");const o=Math.log2(n);for(let i=Math.floor(this.slider.min);i<=Math.floor(this.slider.max);++i)i in this.positions?this.positions[i].calcScreen((t=>this.unitsHandler.isGap(t)),i,this.slider.min,s,this.positionHeight,o,this._positionWidthWithMargin,this._positionWidth,t,e):console.warn(`Bio: WebLogoViewer<${this.viewerId}>.render.calculateLayoutInt() this.positions.length = ${this.positions.length}, jPos = ${i}`);p._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.render.calculateLayoutInt(), end `),this._onLayoutCalculated.next()},r=t=>{if(p._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.render.renderInt( recalcLevel=${t} ), start `),this.msgHost&&(this.seqCol&&!this.cp?(this.msgHost.innerText=`Unknown palette (column semType: '${this.seqCol.semType}').`,this.msgHost.style.display=""):this.msgHost.style.display="none"),!this.seqCol||!this.dataFrame||!this.cp||null==this.host||null==this.slider)return;const e=window.devicePixelRatio,i=this.showPositionLabels?12:0;if(t>=w.Freqs&&s(),this.calcLayout(e),0===this.positions.length||-1===this.startPosition||-1===this.endPosition)return;t>=w.Layout&&n(window.devicePixelRatio,i);const r=this.canvas.getContext("2d");if(!r)return;this.Length,r.resetTransform(),r.fillStyle=function(t){const e=o.Color.a(t);return`#${(16777215&t).toString(16).padStart(6,"0")}`+e.toString(16).padStart(2,"0")}(this.backgroundColor),r.fillRect(0,0,this.canvas.width,this.canvas.height),r.textBaseline=this.textBaseline;const a=10*e;r.resetTransform(),r.fillStyle="black",r.textAlign="center",r.font=`${a.toFixed(1)}px Roboto, Roboto Local, sans-serif`;const l=Math.max(...this.positions.map((t=>r.measureText(t.name).width))),h=l<this._positionWidth*e-2?1:(this._positionWidth*e-2)/l;i>0&&function(t,e,s,i,n,o,r,a){for(let l=Math.floor(r);l<=Math.floor(a);l++){const a=o[l];t.resetTransform(),t.setTransform(s,0,0,1,(l-r)*i*e+n*e/2,0),t.fillText(a.label,0,1)}}(r,e,h,this._positionWidthWithMargin,this._positionWidth,this.positions,this.slider.min,this.slider.max);for(let t=Math.floor(this.slider.min);t<=Math.floor(this.slider.max);t++)this.positions[t].render(r,(t=>this.unitsHandler.isGap(t)),"16px Roboto, Roboto Local, sans-serif",.25,12.2,this.cp);p._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.render.renderInt( recalcLevel=${t} ), end`)};return this.renderLevelRequested=Math.max(this.renderLevelRequested,t),new Promise(((t,e)=>{window.setTimeout((()=>{try{if(this.renderLevelRequested>w.None)try{r(this.renderLevelRequested)}finally{this.renderLevelRequested=w.None}}catch(t){e(t)}}),0)}))}getAlphabetSize(){return this.unitsHandler?.getAlphabetSize()??0}sliderOnValuesChanged(t){try{const t={minRange:this.slider.minRange,min:this.slider.min,max:this.slider.max,maxRange:this.slider.maxRange};p._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.sliderOnValuesChanged( ${JSON.stringify(t)} ), start`),this.render(w.Layout,"sliderOnValuesChanged").then((()=>{}))}catch(t){const e=m(t);p._package.logger.error(`Bio: WebLogoViewer<${this.viewerId}>.sliderOnValuesChanged() error:\n`+e)}}dataFrameFilterOnChanged(t){p._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.dataFrameFilterChanged()`);try{this.updatePositions(),this.filterSource===u.Ct.Filtered&&this.render(w.Freqs,"dataFrameFilterOnChanged").then((()=>{}))}catch(t){const e=m(t);p._package.logger.error(`Bio: WebLogoViewer<${this.viewerId}>.dataFrameFilterOnChanged() error:\n`+e)}}dataFrameSelectionOnChanged(t){p._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.dataFrameSelectionOnChanged()`);try{this.filterSource===u.Ct.Selected&&this.render(w.Freqs,"dataFrameSelectionOnChanged").then((()=>{}))}catch(t){const e=m(t);p._package.logger.error(`Bio: WebLogoViewer<${this.viewerId}>.dataFrameSelectionOnChanged() error:\n`+e)}}canvasOnMouseMove(t){const e=window.devicePixelRatio;try{const s=t,i=this.canvas.getCursorPosition(s,e),[o,r]=this.getMonomer(i,e);if(this.dataFrame&&this.seqCol&&r){const t=this.positions[o],e=function(t,e,s,i,n){let o=0,r=-1;for(;-1!=(r=s.findNext(r,!0));){const t=e.splitted[r],s=n.pos;(s<t.length?t[s]:null)===i&&o++}return o}(this.dataFrame,this.unitsHandler,this.getFilter(),r,t),i=n.div([n.div(`${r}`),n.div(`${e} rows`)]);n.tooltip.show(i,s.x+16,s.y+16)}else n.tooltip.hide()}catch(t){const e=m(t);p._package.logger.error(`Bio: WebLogoViewer<${this.viewerId}>.canvasOnMouseMove() error:\n`+e)}}canvasOnMouseDown(t){try{const e=t,s=window.devicePixelRatio,[i,n]=this.getMonomer(this.canvas.getCursorPosition(e,s),s);if(this.dataFrame&&this.seqCol&&this.unitsHandler&&n){const t=this.positions[i],e=o.BitSet.create(this.dataFrame.selection.length,(e=>function(t,e,s,i,n,o){const r=e.splitted[i],a=o.pos<r.length?r[o.pos]:null;return a===n||""===a&&n===e.defaultGapSymbol}(this.dataFrame,this.unitsHandler,this.getFilter(),e,n,t)));this.dataFrame.selection.init((t=>e.get(t)))}}catch(t){const e=m(t);p._package.logger.error(`Bio: WebLogoViewer<${this.viewerId}>.canvasOnMouseDown() error:\n`+e)}}canvasOnWheel(t){const e=window.devicePixelRatio;try{if(!this.visibleSlider)return;const s=this.canvas.width/(this._positionWidthWithMargin*e),i=t.deltaY/100*Math.max(Math.floor(s/5),1);this.slider.scrollBy(this.slider.min+i)}catch(t){const e=m(t);p._package.logger.error(`Bio: WebLogoViewer<${this.viewerId}>.canvasOnWheel() error:\n`+e)}}}C.residuesSet="nucleotides",C.viewerCount=0},4413:(t,e,s)=>{"use strict";s.d(e,{ST:()=>g});var i=s(3870),n=s(976),o=s(4469),r=s(6414),a=s.n(r),l=s(7983),h=s(701),c=s(4293),u=s(8447),m=s(1061);const d=rxjs.operators;class g extends n.Filter{get calculating(){return"initial"==this.loader.style.display}set calculating(t){this.loader.style.display=t?"initial":"none"}get filterSummary(){return this.bioFilter.substructure}get isFiltering(){return super.isFiltering&&""!==this.bioFilter.substructure}get isReadyToApplyFilter(){return!this.calculating&&null!=this.bitset}get _debounceTime(){if(null==this.column)return 1e3;const t=this.column.length;return t<500?0:t>1e4?1e3:Math.floor((t-500)/9500*1e3)}constructor(){super(),this.bioFilter=null,this.bitset=null,this.loader=i.loader(),this.notation=void 0,this.root=i.divV([]),this.calculating=!1}attach(t){super.attach(t),this.column=t.columns.bySemType(n.SEMTYPE.MACROMOLECULE),this.columnName??(this.columnName=this.column?.name),this.notation??(this.notation=this.column?.getTag(n.TAGS.UNITS)),this.bioFilter=this.notation===u.r2.FASTA?new f:this.notation===u.r2.SEPARATOR?new y(this.column.getTag("separator")):new b,this.root.appendChild(this.bioFilter.filterPanel),this.root.appendChild(this.loader),this.onBioFilterChangedSubs?.unsubscribe();let e=this.bioFilter.onChanged;e=e.pipe((0,d.debounceTime)(this._debounceTime)),this.onBioFilterChangedSubs=e.subscribe((async t=>await this._onInputChanged())),this.subs.push(o.events.onResetFilterRequest.subscribe((t=>{this.bioFilter?.resetFilter()})))}detach(){super.detach()}applyFilter(){this.bitset&&!this.isDetached&&this.dataFrame?.filter.and(this.bitset)}saveState(){const t=super.saveState();return t.bioSubstructure=this.bioFilter?.substructure,t}applyState(t){super.applyState(t),t.bioSubstructure&&(this.bioFilter.substructure=t.bioSubstructure);const e=this;t.bioSubstructure&&setTimeout((function(){e._onInputChanged()}),1e3)}async _onInputChanged(){if(this.isFiltering){if(a()(this.dataFrame.rows.filters).has(`${this.columnName}: ${this.filterSummary}`))return;this.calculating=!0;try{this.bitset=await(this.bioFilter?.substructureSearch(this.column)),this.calculating=!1,this.dataFrame?.rows.requestFilter()}finally{this.calculating=!1}}else this.bitset=null,this.dataFrame?.rows.requestFilter()}}class p{constructor(){this.onChanged=new h.Subject}get filterPanel(){return new HTMLElement}get substructure(){return""}set substructure(t){}async substructureSearch(t){return null}}class f extends p{constructor(){super(),this.substructureInput=i.stringInput("","",(()=>{this.onChanged.next()}),{placeholder:"Substructure"})}get filterPanel(){return this.substructureInput.root}get substructure(){return this.substructureInput.value}set substructure(t){this.substructureInput.value=t}async substructureSearch(t){return(0,l.pf)(this.substructure,t)}resetFilter(){this.substructureInput.value=""}}class y extends f{constructor(t){super(),this.colSeparator="",this.separatorInput=i.stringInput("","",(()=>{this.onChanged.next()}),{placeholder:"Separator"}),this.colSeparator=t,this.separatorInput.value=t}get filterPanel(){return i.divV([this.substructureInput.root,this.separatorInput.root])}get substructure(){return this.separatorInput.value&&this.separatorInput.value!==this.colSeparator?this.substructureInput.value.replaceAll(this.separatorInput.value,this.colSeparator):this.substructureInput.value}set substructure(t){this.substructureInput.value=t}async substructureSearch(t){return(0,l.pf)(this.substructure,t,this.colSeparator)}}class b extends p{constructor(){super(),this._filterPanel=i.div("",{style:{cursor:"pointer"}}),this.helmSubstructure="",this.init()}async init(){this.helmEditor=await o.functions.call("HELM:helmWebEditor"),await i.tools.waitForElementInDom(this._filterPanel),this.updateFilterPanel(),this._filterPanel.addEventListener("click",(t=>{const{editorDiv:e,webEditor:s}=this.helmEditor.createWebEditor(this.helmSubstructure);i.dialog({showHeader:!1,showFooter:!0}).add(e).onOK((()=>{const t=s.canvas.getHelm(!0).replace(/<\/span>/g,"").replace(/<span style='background:#bbf;'>/g,"");this.helmSubstructure=t,this.updateFilterPanel(this.substructure),setTimeout((()=>{this.onChanged.next()}),10)})).show({modal:!0,fullScreen:!0})})),i.onSizeChanged(this._filterPanel).subscribe((t=>{const e=this.helmEditor.webEditor.canvas.getHelm(!0).replace(/<\/span>/g,"").replace(/<span style='background:#bbf;'>/g,"");this.updateFilterPanel(e)}))}get filterPanel(){return this._filterPanel}get substructure(){return this.helmSubstructure}set substructure(t){this.helmEditor.editor.setHelm(t)}updateFilterPanel(t){const e=this._filterPanel.parentElement.clientWidth<100?100:this._filterPanel.parentElement.clientWidth,s=e/2;if(t)(0,c.Y)(this._filterPanel,this.helmEditor.host),this.helmEditor.editor.setHelm(t),this.helmEditor.resizeEditor(e,s);else{const t=i.divText("Click to edit","helm-substructure-filter");(0,c.Y)(this._filterPanel,t)}}async substructureSearch(t){i.setUpdateIndicator(this._filterPanel,!0),await(0,m.gw)(10);const e=await(0,l.QF)(this.substructure,t);return i.setUpdateIndicator(this._filterPanel,!1),e}resetFilter(){console.debug("Bio: HelmFilter.resetFilter()"),this.helmSubstructure="",this.updateFilterPanel(this.substructure)}}},3336:t=>{"use strict";t.exports=$},976:t=>{"use strict";t.exports=DG},4469:t=>{"use strict";t.exports=grok},701:t=>{"use strict";t.exports=rxjs},3870:t=>{"use strict";t.exports=ui},6414:t=>{"use strict";t.exports=wu}},e={};function s(i){var n=e[i];if(void 0!==n)return n.exports;var o=e[i]={id:i,exports:{}};return t[i].call(o.exports,o,o.exports,s),o.exports}s.m=t,s.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return s.d(e,{a:e}),e},s.d=(t,e)=>{for(var i in e)s.o(e,i)&&!s.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},s.u=t=>t+".js",s.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),s.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),s.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},(()=>{var t;s.g.importScripts&&(t=s.g.location+"");var e=s.g.document;if(!t&&e&&(e.currentScript&&(t=e.currentScript.src),!t)){var i=e.getElementsByTagName("script");if(i.length)for(var n=i.length-1;n>-1&&!t;)t=i[n--].src}if(!t)throw new Error("Automatic publicPath is not supported in this browser");t=t.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),s.p=t})(),s.b=document.baseURI||self.location.href,s.nc=void 0;var i=s(2904);bio=i})();
|
|
2
|
+
var bio;(()=>{var t={2012:(t,e,s)=>{"use strict";s.d(e,{f:()=>n});var i=s(9976);class n extends i.B{static get Lesk(){return void 0===this.lesk&&(this.lesk=this.makePalette([[["G","A","S","T"],"orange"],[["C","V","I","L","P","F","Y","M","W"],"all_green"],[["N","Q","H"],"magenta"],[["D","E"],"red"],[["K","R"],"all_blue"]],!1,n)),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,n)),this.grokGroups}static get RasMol(){return void 0===this.rasMol&&(this.rasMol=new n({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 n.aaSynonyms?n.aaSynonyms[t]:t;return super.get(e)}}n.aaSynonyms={MeNle:"L",MeA:"A",MeG:"G",MeF:"F"};class o{static getPalette(t="grok"){switch(t){case"grok":return n.GrokGroups;case"lesk":return n.Lesk;default:throw new Error(`ChemPalette: scheme \`${t}\` does not exist`)}}static getInnerOuter(t){let e=0,s="",i="";for(const n of t)"("==n?e++:")"==n?e--:e?s+=n:i+=n;return isNaN(parseInt(s))?[i,s]:[i,""]}static getColorAAPivot(t="",e="grok"){const s=this.getPalette(e);let[i,n]=this.getInnerOuter(t);if(i=i.length>6?`${i.slice(0,3)}...`:i,n=n.length>6?`${n.slice(0,3)}...`:n,1==t.length||"("==t[1]){const e=t[0]?.toUpperCase();return e in s?[s.get(e),e,n,1]:[this.undefinedColor,i,n,1]}if("d"==t[0]&&t[1]in s&&(2==t.length||"("==t[2])){const e=t[1]?.toUpperCase();return e in s?[s.get(e),e,n,2]:[this.undefinedColor,i,n,2]}if(t.substring(0,3)in this.AAFullNames&&(3==t.length||"("==t[3])){const e=this.AAFullNames[t.substring(0,3)];return e in s?[s.get(e),e,n,3]:[this.undefinedColor,i,n,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 s?[s.get(e),e,n,4]:[this.undefinedColor,i,n,4]}return[this.undefinedColor,i,n,0]}}o.SemType="Aminoacids",o.SemTypeMultipleAlignment="AminoacidsMultipleAlignment",o.undefinedColor="rgb(100,100,100)",o.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"},o.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"},o.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(*)*"},o.AAFullNames={Ala:"A",Arg:"R",Asn:"N",Asp:"D",Cys:"C",Gln:"Q",Glu:"E",Gly:"G",His:"H",Ile:"I",Leu:"L",Lys:"K",Met:"M",Phe:"F",Pro:"P",Ser:"S",Thr:"T",Trp:"W",Tyr:"Y",Val:"V"}},7228:(t,e,s)=>{"use strict";s.d(e,{JN:()=>c,PF:()=>m,Qx:()=>u,Xk:()=>h,Z:()=>l,eD:()=>a});var i=s(976),n=s(4469),o=s(1047),r=(s(499),s(8457));function a(t){return t.every((t=>"object"==typeof t&&Object.values(o.pn).every((e=>e in t&&"string"==typeof t[e]))))}function l(t){function e(t){const e=new RegExp("\\[r\\]","g");let s=0;return t.replace(e,(t=>(++s,`[${s}*]`)))}const s=[];return t.forEach((t=>{const n={...o.zh};Object.entries(o.pn).forEach((([e,s])=>{const i=t[s];n[e]=i}));let r="smiles";const a=t[o.pn[r]],l=e(a).replace("[1*]","[H:1]").replace("[2*]","[OH:2]");n[r]=l,r="rgroups",n[r]=o.Ei,r="molfile";const h=e(a),c=i.chem.convert(h,i.chem.Notation.Smiles,i.chem.Notation.MolBlock);n[r]=c.replace("M ISO","M RGP"),s.push(n)})),console.log("resultLib:",s),s}function h(t){const e=[];for(let s=0;s<t.rowCount;s++){const i={};Object.keys(o.K4).forEach((e=>{if("symbol"===e){const n=t.get(o.K4[e],s);i[e]="."===n?t.get(o.At,s):n}else if("rgroups"===e){const n=t.get(o.K4[e],s).split("\n"),r=[];n.forEach((t=>{const e={},s=t.substring(t.lastIndexOf("]")+1),i=t.match(/\[R(\d+)\]/)[1];e.capGroupSmiles="H"===s?`[*:${i}][H]`:`O[*:${i}]`,e.alternateId="H"===s?`R${i}-H`:`R${i}-OH`,e.capGroupName="H"===s?"H":"OH",e.label=`R${i}`,r.push(e)})),i[e]=r}else o.K4[e]&&(i[e]=t.get(o.K4[e],s))})),e.push(i)}return e}async function c(){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()}async function u(t,e){t instanceof i.Column&&(t=(0,r.O)(t).columns.toList());const s=(await c()).getBioLib(),o=new Array(t.length),a=t[0].length,l=new Float32Array(a);for(let r=0;r<t.length;++r){const h=e[r],c=s.getMonomer("PEPTIDE",h)?.smiles??"",u=t[r],m=u.getRawData(),d=u.categories,g=d.indexOf("");if(o[r]={categories:d,data:m,emptyIndex:g},void 0===h)continue;const p=i.Column.fromStrings("smiles",d.map((t=>s.getMonomer("PEPTIDE",t)?.smiles??""))),f=(i.DataFrame.fromColumns([p]),(await n.chem.getSimilarities(p,c)).getRawData());for(let t=0;t<a;++t){const e=m[t];l[t]+=""!==h&&e!==g?f[e]:""===h&&e===g?1:0}}for(let s=0;s<l.length;++s){let n=l[s]/e.length;for(let r=0;r<t.length;++r){const t=o[r];if(r>=e.length&&t.data[s]!==t.emptyIndex||t.data[s]===t.emptyIndex&&r<e.length){n=i.FLOAT_NULL;break}}l[s]=n}return i.Column.fromFloat32Array("Similarity",l)}async function m(t){const e=(await c()).getBioLib(),s=[],o={},r=t.map((t=>e.getMonomer("PEPTIDE",t)?.smiles??"")),a=i.Column.fromStrings("smiles",r);for(let e=0;e<r.length;++e){o[t[e]]=e;const i=r[e],l=""===i?new Array(r.length).fill(0):(await n.chem.getSimilarities(a,i)).getRawData();l[e]=1,s[e]=Array.from(l)}return{scoringMatrix:s,alphabetIndexes:o}}},8601:(t,e,s)=>{"use strict";s.d(e,{i0:()=>m});var i=s(4469),n=s(976),o=s(6414),r=s.n(o),a=s(1821),l=s(499);const h={V2K_RGP_SHIFT:8,V2K_RGP_LINE:"M RGP",V2K_A_LINE:"A ",V3K_COUNTS_SHIFT:14,V3K_IDX_SHIFT:7,V3K_HEADER_FIRST_LINE:"\nDatagrok macromolecule handler\n\n",V3K_HEADER_SECOND_LINE:" 0 0 0 0 0 0 999 V3000\n",V3K_BEGIN_CTAB_BLOCK:"M V30 BEGIN CTAB\n",V3K_END_CTAB_BLOCK:"M V30 END CTAB\n",V3K_BEGIN_COUNTS_LINE:"M V30 COUNTS ",V3K_COUNTS_LINE_ENDING:" 0 0 0\n",V3K_BEGIN_ATOM_BLOCK:"M V30 BEGIN ATOM\n",V3K_END_ATOM_BLOCK:"M V30 END ATOM\n",V3K_BEGIN_BOND_BLOCK:"M V30 BEGIN BOND\n",V3K_END_BOND_BLOCK:"M V30 END BOND\n",V3K_BOND_CONFIG:" CFG:",V3K_BEGIN_DATA_LINE:"M V30 ",V3K_END:"M END",PRECISION_FACTOR:1e4,DEOXYRIBOSE:"d",RIBOSE:"r",PHOSPHATE:"p",OXYGEN:"O",HYDROGEN:"H"};var c=s(1047);function u(t){return Math.round(h.PRECISION_FACTOR*t)/h.PRECISION_FACTOR}async function m(t,e,o){if(0===n.Func.find({package:"Chem",name:"getRdKitModule"}).length)return{col:null,warnings:['Transformation to atomic level requires the package "Chem" installed.']};if(e.semType!==n.SEMTYPE.MACROMOLECULE)return{col:null,warnings:[`Only the ${n.SEMTYPE.MACROMOLECULE} columns can be converted to atomic level, the chosen column has semType '${e.semType}'`]};let u=e;const m=l.Cn.getOrCreate(e);m.isHelm()&&(u=m.convert(a.r2.SEPARATOR,"."),u.name=e.name);const g=l.Cn.getOrCreate(u).alphabet;let p;if("PT"===g||"UN"===g)p="PEPTIDE";else{if("RNA"!==g&&"DNA"!==g)return{col:null,warnings:[`Unexpected column's '${u.name}' alphabet '${g}'.`]};p="RNA"}const f=function(t){const e=t.length,s=new Array(e),i=l.Cn.getOrCreate(t).getSplitter();for(let n=0;n<e;++n){const e=t.get(n);s[n]=e?r()(i(e)).filter((t=>""!==t)).toArray():[]}return s}(u),y=await async function(t,e,s,n){const o=function(t,e,s){const i=new Map;for(const n of t.getMonomerSymbolsByType(e)){const o=t.getMonomer(e,n);if("RNA"===e&&("Branch"===o.monomerType||"DNA"===s&&o.symbol===h.DEOXYRIBOSE||"RNA"===s&&o.symbol===h.RIBOSE||o.symbol===h.PHOSPHATE)||"PEPTIDE"===e&&"Branch"!==o.monomerType){const t={};c.rx.forEach((e=>{t[e]=o[e]})),i.set(o.symbol,t)}}return i}(e,s,n),r=new Map,a=await i.functions.call("Chem:getRdKitModule"),l={value:null};if("RNA"===s){const t="RNA"===n?[h.RIBOSE,h.PHOSPHATE]:[h.DEOXYRIBOSE,h.PHOSPHATE];for(const e of t)d(r,e,o,a,s,l)}for(let e=0;e<t.length;++e){const i=t[e];for(const t of i)if(""!==t)try{d(r,t,o,a,s,l)}catch(e){const s=e instanceof Error?e.message:e.toString(),i=e instanceof Error?e.stack:void 0;throw console.error(`bio lib: getMonomersDictFromLib() sym='${t}', error:\n${s}\n${i}`),new Error(`Can't get monomer '${t}' from library: ${s}`)}}return r}(f,o,p,g),b=u.length,{molfileList:w,molfileWarningList:C}=await async function(t,e,i,n,o){const r=Math.max(navigator.hardwareConcurrency-2,1),a=new Array(r).fill(null).map((()=>new Worker(new URL(s.p+s.u(79),s.b)))),l=o/r;let h=[],c=[];const u=new Array(r);for(let s=0;s<r;s++){const h=Math.floor(s*l),c=s===r-1?o:Math.floor((s+1)*l);a[s].postMessage({monomerSequencesArray:t,monomersDict:e,alphabet:i,polymerType:n,start:h,end:c}),u[s]=new Promise((t=>{a[s].onmessage=({data:{molfileList:e,molfileWarningList:s}})=>{t({molfileList:e,molfileWarningList:s})}}))}return(await Promise.all(u)).forEach((t=>{h=h.concat(...t.molfileList),c=c.concat(...t.molfileWarningList)})),setTimeout((()=>{a.forEach((t=>{t.terminate()}))}),0),{molfileList:h,molfileWarningList:c}}(f,y,g,p,b);if(C.length>.05*b)throw new Error("Too many errors getting molfiles.");const v=`molfile(${u.name})`,S=t.columns.getUnusedName(v),T=n.Column.fromStrings(S,w);return T.semType=n.SEMTYPE.MOLECULE,T.setTag(n.TAGS.UNITS,n.UNITS.Molecule.MOLBLOCK),{col:T,warnings:C}}function d(t,e,s,i,n,o){if(!t.has(e)){const r=function(t,e,s,i,n){if(e.has(t)){const o=e.get(t),r=function(t){const e=[];for(const s of t){let t=s.capGroupSmiles;t||(t=s.capGroupSMILES),t=t.replace(/(\[|\]|\*|:|\d)/g,""),e.push(t)}return e}(o.rgroups),a=function(t){const e=new Map;let s=t.indexOf(h.V2K_A_LINE,0),i=s;for(;-1!==s;){i=t.indexOf("\n",s);const n=parseInt(t.substring(s,i).replace(/^A\s+/,""));s=t.indexOf("R",i),i=t.indexOf("\n",s);const o=parseInt(t.substring(s,i).replace(/^R/,""));e.set(n,o),s=t.indexOf(h.V2K_A_LINE,i)}for(s=t.indexOf(h.V2K_RGP_LINE,0),i=t.indexOf("\n",s);-1!==s;){s+=h.V2K_RGP_SHIFT,i=t.indexOf("\n",s);const n=t.substring(s,i).replaceAll(/\s+/g," ").split(" ").map((t=>parseInt(t))).slice(1);for(let t=0;t<n.length;t+=2){if(e.has(n[t])&&e.get(n[t])!==n[t+1])throw new Error(`r-group index ${n[t]} has already been added with a different value`);e.set(n[t],n[t+1])}s=t.indexOf(h.V2K_RGP_LINE,i)}return e}(o.molfile),l=function(t,e){const s=e.get_mol(t),i=s.get_v3Kmolblock();return s.delete(),i}(function(t){let e=t.indexOf(h.V2K_A_LINE,0);-1===e&&(e=t.indexOf(h.V2K_RGP_LINE));const s=t.indexOf(h.V3K_END,e);return t.substring(0,e)+t.substring(s)}(o.molfile),s),c=function(t){let e=(t=t.replaceAll("\r","")).indexOf(h.V3K_BEGIN_COUNTS_LINE)+h.V3K_COUNTS_SHIFT,s=t.indexOf(" ",e+1);const i=parseInt(t.substring(e,s));return e=s+1,s=t.indexOf(" ",e+1),{atomCount:i,bondCount:parseInt(t.substring(e,s))}}(l),m=function(t,e){const s=new Array(e),i=new Float32Array(e),n=new Float32Array(e),o=new Array(e);let r=t.indexOf(h.V3K_BEGIN_ATOM_BLOCK);r=t.indexOf("\n",r);let a=r;for(let l=0;l<e;l++){r=t.indexOf(h.V3K_BEGIN_DATA_LINE,r)+h.V3K_IDX_SHIFT,a=t.indexOf(" ",r),r=a+1,a=t.indexOf(" ",r),s[l]=t.substring(r,a);const e=new Array(2);for(let s=0;s<2;++s)r=a+1,a=t.indexOf(" ",r),e[s]=parseFloat(t.substring(r,a));i[l]=e[0],n[l]=e[1],r=a,a=t.indexOf("\n",r)+1,o[l]=t.slice(r,a),r=a}return{atomTypes:s,x:i,y:n,kwargs:o}}(l,c.atomCount),d=function(t,e){const s=new Uint32Array(e),i=new Array(e),n=new Map,o=new Map;let r=t.indexOf(h.V3K_BEGIN_BOND_BLOCK);r=t.indexOf("\n",r);let a=r;for(let l=0;l<e;++l){const e=new Array(3);r=t.indexOf(h.V3K_BEGIN_DATA_LINE,a)+h.V3K_IDX_SHIFT,a=t.indexOf(" ",r);for(let s=0;s<3;++s)r=a+1,a=Math.min(t.indexOf("\n",r),t.indexOf(" ",r)),e[s]=parseInt(t.slice(r,a));s[l]=e[0],i[l]=e.slice(1);const c=t.indexOf("\n",r);let u=t.slice(a,c),m=u.indexOf(h.V3K_BOND_CONFIG);if(-1!==m){m=u.indexOf("=",m)+1;let t=u.indexOf(" ",m);-1===t&&(t=u.length);const e=parseInt(u.slice(m,t));n.set(l,e);const s=h.V3K_BOND_CONFIG+e.toString();u=u.replace(s,"")}u||o.set(l,u)}return{bondTypes:s,atomPairs:i,bondConfiguration:n,kwargs:o}}(l,c.bondCount),y={atoms:m,bonds:d,meta:g(m,d,r,a)};return"PEPTIDE"===i?function(t){const e=t.meta.terminalNodes[0]-1,s=t.meta.rNodes[0]-1,i=t.atoms.x,n=t.atoms.y;T(t,-i[e],-n[e]);const o=C(i[s],n[s]);v(t.atoms,-o),i[t.meta.rNodes[1]-1]<0&&function(t){S(t,!1)}(t);const r=function(t){const e=function(t){const e=new Map;for(const s of t.bonds.atomPairs)for(let t=0;t<2;t++){const i=s[t],n=s[(t+1)%2];e.has(i)?e.get(i)?.push(n):e.set(i,new Array(1).fill(n))}return e}(t);let s=0,i=0;for(;0===s;){const n=e.get(t.meta.terminalNodes[1])[i];t.atoms.atomTypes[n-1]===h.OXYGEN&&n!==t.meta.rNodes[1]&&(s=n),i++}return s}(t);!function(t,e){t.atoms.y[t.meta.rNodes[1]-1]<0&&t.atoms.y[e-1]<0&&(function(t){S(t,!0)}(t),v(t.atoms,-function(t,e){return C(t,e)+Math.PI/2}(t.atoms.x[t.meta.terminalNodes[1]-1],t.atoms.y[t.meta.terminalNodes[1]-1])))}(t,r),function(t,e){const s=t.atoms.x;s[t.meta.rNodes[1]-1]>s[e-1]&&function(t,e,s){const i=e-1,n=s-1,o=t.atoms.x,r=t.atoms.y,a=o[i],l=r[i];o[i]=o[n],r[i]=r[n],o[n]=a,r[n]=l}(t,e,t.meta.rNodes[1])}(t,r)}(y):t===h.RIBOSE||t===h.DEOXYRIBOSE?function(t,e){const s=t.atoms.x,i=t.atoms.y;let n=t.meta.terminalNodes[0]-1;const o=t.meta.rNodes[1]-1;T(t,-s[n],-i[n]);const r=C(s[o],i[o]);v(t.atoms,3*Math.PI/2-r),e.value=function(t){const e=t.atoms.x,s=t.atoms.y,i=t.meta.rNodes[2]-1,n=t.meta.terminalNodes[2]-1,o=e[i]-e[n],r=s[i]-s[n];return Math.atan(r/o)+Math.PI/2}(t),n=t.meta.terminalNodes[0]-1,T(t,-s[n],-i[n])}(y,n):t===h.PHOSPHATE?function(t){const e=t.meta.terminalNodes[0]-1,s=t.meta.rNodes[0]-1,i=t.atoms.x,n=t.atoms.y;T(t,-i[e],-n[e]);const o=C(i[s],n[s]);v(t.atoms,Math.PI/2-o)}(y):function(t,e){const s=t.atoms.x,i=t.atoms.y,n=t.meta.terminalNodes[0]-1,o=t.meta.rNodes[0]-1;T(t,-s[n],-i[n]);const r=C(s[o],i[o]),a=e.value;if(!a)throw new Error("The value of sugarBranchToOYAngle is null");v(t.atoms,Math.PI-r+a);const l=function(t,e){return u(Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2))}({x:s[t.meta.rNodes[0]-1],y:i[t.meta.rNodes[0]-1]},{x:s[t.meta.terminalNodes[0]-1],y:i[t.meta.terminalNodes[0]-1]});if(1!=l)for(let t=0;t<s.length;++t)s[t]=u(s[t]/l),i[t]=u(i[t]/l)}(y,n),function(t,e,s){"PEPTIDE"===t?(f(e,t),b(e,e.meta.rNodes[1])):s===h.RIBOSE||s===h.DEOXYRIBOSE?(b(e,e.meta.rNodes[1]),e.meta.rNodes[1]=e.meta.terminalNodes[1],p(e.bonds,e.meta),f(e,t),b(e,e.meta.rNodes[1]),b(e,e.meta.rNodes[0]),b(e,e.meta.rNodes[2])):s===h.PHOSPHATE&&(e.meta.terminalNodes[0]=e.meta.rNodes[0],T(e,-e.atoms.x[e.meta.terminalNodes[0]-1],-e.atoms.y[e.meta.terminalNodes[0]-1]),f(e,t),b(e,e.meta.rNodes[1]))}(i,y,t),function(t){let e=0;for(;e<t.atoms.atomTypes.length;)t.atoms.atomTypes[e]===h.HYDROGEN&&(b(t,e+1),--e),++e}(y),y}return null}(e,s,i,n,o);if(!r)throw new Error(`Monomer with symbol '${e}' is absent the monomer library`);t.set(e,r)}}function g(t,e,s,i){const n={backboneShift:null,branchShift:null,terminalNodes:[],rNodes:[]};return function(t,e,s){for(const[i,n]of s)t.atomTypes[i-1]=e[n-1]}(t,s,i),function(t,e){e.rNodes=Array.from(t.keys());for(let s=0;s<e.rNodes.length;s++)for(const i of[1,2])if(t.get(e.rNodes[s])===i){const t=e.rNodes[i-1];e.rNodes[i-1]=e.rNodes[s],e.rNodes[s]=t}}(i,n),p(e,n),n}function p(t,e){const s=e.rNodes;e.terminalNodes=new Array(s.length).fill(0);const i=e.terminalNodes,n=t.atomPairs;let o=0,r=0;for(;o<n.length&&r<i.length;){for(let t=0;t<i.length;++t)for(let e=0;e<2;++e)n[o][e]===s[t]&&(i[t]=n[o][(e+1)%2],s.length,++r);++o}}function f(t,e){t.meta.rNodes.length>1&&(t.meta.backboneShift=y(t,t.meta.rNodes[1]-1,t.meta.terminalNodes[0]-1)),"RNA"===e&&t.meta.rNodes.length>2&&(t.meta.branchShift=y(t,t.meta.rNodes[2]-1,t.meta.terminalNodes[0]-1))}function y(t,e,s){return[u(t.atoms.x[e]-t.atoms.x[s]),u(t.atoms.y[e]-t.atoms.y[s])]}function b(t,e){if(void 0!==e){const s=e-1,i=t.atoms,n=t.bonds,o=t.meta;i.atomTypes.splice(s,1),i.x=w(Float32Array,i.x,s,1),i.y=w(Float32Array,i.y,s,1),i.kwargs.splice(s,1);for(let t=0;t<o.terminalNodes.length;++t)o.terminalNodes[t]>e?--o.terminalNodes[t]:o.terminalNodes[t]===e&&(o.terminalNodes[t]=-1);for(let t=0;t<o.rNodes.length;++t)o.rNodes[t]>e?--o.rNodes[t]:o.rNodes[t]===e&&(o.rNodes[t]=-1);let r=0;for(;r<n.atomPairs.length;){const t=n.atomPairs[r][0],s=n.atomPairs[r][1];t===e||s===e?(n.atomPairs.splice(r,1),n.bondTypes=w(Uint32Array,n.bondTypes,r,1),n.bondConfiguration.has(r)&&n.bondConfiguration.delete(r),n.kwargs.has(r)&&n.kwargs.delete(r),--r):(n.atomPairs[r][0]=t>e?t-1:t,n.atomPairs[r][1]=s>e?s-1:s),++r}let a=Array.from(n.bondConfiguration.keys());a.forEach((t=>{if(n.bondConfiguration.has(t)&&t>s){const e=n.bondConfiguration.get(t);n.bondConfiguration.delete(t),n.bondConfiguration.set(t-1,e)}})),a=Array.from(n.kwargs.keys()),a.forEach((t=>{if(n.kwargs.has(t)&&t>s){const e=n.kwargs.get(t);n.kwargs.delete(t),n.kwargs.set(t-1,e)}}))}}function w(t,e,s,i){const n=new t(e.length-i);let o=0,r=0;for(;o<e.length;)o===s&&(o+=i),n[r]=e[o],++r,++o;return n}function C(t,e){let s;if(0===t)s=e>0?0:Math.PI;else if(0===e)s=t>0?-Math.PI/2:Math.PI/2;else{const i=e/t,n=Math.atan(i);s=t<0?Math.PI/2+n:-Math.PI/2+n}return s}function v(t,e){if(0!==e){const s=t.x,i=t.y,n=Math.cos(e),o=Math.sin(e);for(let t=0;t<s.length;++t){const e=s[t];s[t]=u(e*n-i[t]*o),i[t]=u(e*o+i[t]*n)}}}function S(t,e){if(e){const e=t.atoms.y;for(let t=0;t<e.length;t++)e[t]=-e[t]}else{const e=t.atoms.x;for(let t=0;t<e.length;t++)e[t]=-e[t]}const s=t.bonds.bondConfiguration;for(const[t,e]of s){const i=1===e?3:1;s.set(t,i)}}function T(t,e,s){const i=t.atoms.x,n=t.atoms.y;for(let t=0;t<i.length;++t)i[t]=u(i[t]+e),void 0!==s&&(n[t]=u(n[t]+s))}},6137:(t,e,s)=>{"use strict";s.d(e,{J:()=>n});var i=s(9976);class n extends i.B{static get Chromatogram(){return void 0===this.chromatogram&&(this.chromatogram=new n({A:"green",C:"blue",G:"black",T:"red",U:"red",others:"gray"})),this.chromatogram}}class o{}o.SemType="Nucleotides",o.SemTypeMultipleAlignment="NucleotidesMultipleAlignment",o.Names={A:"Adenine",C:"Cytosine",G:"Guanine",T:"Thymine",U:"Uracil"}},9976:(t,e,s)=>{"use strict";s.d(e,{B:()=>i});class i{static makePalette(t,e=!1,s=i){const n={};return t.forEach((t=>{const s=t[0],i=t[1];s.forEach(((t,s)=>{n[t]=this.colourPalette[i][e?0:s]}))})),new s(n)}constructor(t){this._palette=t}get(t){return this._palette[t]}}i.undefinedColor="rgb(100,100,100)",i.colourPalette={orange:["rgb(255,187,120)","rgb(245,167,100)","rgb(235,137,70)","rgb(205, 111, 71)"],all_green:["rgb(44,160,44)","rgb(74,160,74)","rgb(23,103,57)","rgb(30,110,96)","rgb(60,131,95)","rgb(24,110,79)","rgb(152,223,138)","rgb(182, 223, 138)","rgb(152, 193, 138)"],all_blue:["rgb(31,119,180)","rgb(23,190,207)","rgb(122, 102, 189)","rgb(158,218,229)","rgb(141, 124, 217)","rgb(31, 120, 150)"],magenta:["rgb(162,106,192)","rgb(197,165,224)","rgb(208,113,218)"],red:["rgb(214,39,40)","rgb(255,152,150)"],st_blue:["rgb(23,190,207)","rgb(158,218,229)","rgb(31,119,180)"],dark_blue:["rgb(31,119,180)","rgb(31, 120, 150)"],light_blue:["rgb(23,190,207)","rgb(158,218,229)","rgb(108, 218, 229)","rgb(23,190,227)"],lilac_blue:["rgb(124,102,211)","rgb(149,134,217)","rgb(97, 81, 150)"],dark_green:["rgb(23,103,57)","rgb(30,110,96)","rgb(60,131,95)","rgb(24,110,79)"],green:["rgb(44,160,44)","rgb(74,160,74)"],light_green:["rgb(152,223,138)","rgb(182, 223, 138)","rgb(152, 193, 138)"],st_green:["rgb(44,160,44)","rgb(152,223,138)","rgb(39, 174, 96)","rgb(74,160,74)"],pink:["rgb(247,182,210)"],brown:["rgb(140,86,75)","rgb(102, 62, 54)"],gray:["rgb(127,127,127)","rgb(199,199,199)","rgb(196,156,148)","rgb(222, 222, 180)"],yellow:["rgb(188,189,34)"],white:["rgb(230,230,230)"]}},7331:(t,e,s)=>{"use strict";s.d(e,{UE:()=>h});var i=s(976),n=s(9976);class o{static hashCode(t){let e=0;if(0===t.length)return e;for(let s=0;s<t.length;s++)e=(e<<5)-e+t.charCodeAt(s),e|=0;return e}}class r{}class a extends r{get(t){return"#666666"}}class l extends r{static buildPalette(){return[].concat(...Object.values(n.B.colourPalette))}get(t){const e=o.hashCode(t)%l.palette.length;return function(t){if(null==t)return"rgb(100,100,100)";const e=i.Color.fromHtml(t),s=i.Color.g(e),n=i.Color.r(e),o=i.Color.b(e),r=Math.sqrt(Math.pow(0-n,2)+Math.pow(0-s,2)+Math.pow(0-o,2));return r>210?`rgb(${n/r*210},${s/r*210},${o/r*210})`:i.Color.toRgb(e)}(l.palette[e])}}l.palette=l.buildPalette();class h extends n.B{static get Gray(){return void 0===this.gray&&(this.gray=new a),this.gray}static get Color(){return void 0===this.color&&(this.color=new l),this.color}}},9611:(t,e,s)=>{"use strict";s.d(e,{A:()=>h});var i=s(4469),n=s(976),o=s(6414),r=s.n(o),a=s(8447);const l={DNA:"RNA",RNA:"RNA",PT:"PEPTIDE",UN:"PEPTIDE"};class h{get updated(){return this._updated}constructor(t,e,s){this.grid=t,this.col=e,this.propsProvider=s,this._monomerLengthList=null,this.separatorWidth=5,this._updated=!1,this._monomerLengthMap={},this._monomerStructureMap={},this.subs=[],this._splitter=(0,a.Mj)(this.col),this.props=this.propsProvider(),this._rowsProcessed=n.BitSet.create(this.col.length),this.grid&&(this.subs.push(e.dataFrame.onDataChanged.subscribe((()=>{this.props=this.propsProvider(),this._monomerLengthList=null,this._rowsProcessed=n.BitSet.create(this.col.length)}))),this.subs.push(i.events.onViewRemoved.subscribe((t=>{this.grid?.view?.id===t.id&&this.destroy()}))))}destroy(){for(const t of this.subs)t.unsubscribe()}getCellMonomerLengths(t){const e=this.props.unitsHandler.isMsa()?this.getCellMonomerLengthsForSeqMsa():this.getCellMonomerLengthsForSeq(t),s=new Array(e.length+1);s[0]=5;for(let t=1;t<s.length;t++)s[t]=s[t-1]+e[t-1];return[e,s]}getCellMonomerLengthsForSeq(t){null===this._monomerLengthList&&(this._monomerLengthList=new Array(this.col.length).fill(null),this._updated=!0);let e=this._monomerLengthList[t];if(null===e){const s=this.getSeqMonList(t);e=this._monomerLengthList[t]=new Array(s.length);for(const[t,i]of r().enumerate(s)){const s=this.props.monomerToShort(t,this.props.monomerLengthLimit),n=(this.props.unitsHandler.isSeparator()?this.separatorWidth:this.props.separatorWidth)+s.length*this.props.monomerCharWidth;e[i]=n}this._updated=!0}return e}getCellMonomerLengthsForSeqMsa(){var t;null===this._monomerLengthList&&(this._monomerLengthList=new Array(1).fill(null),this._updated=!0),(t=this._monomerLengthList)[0]??(t[0]=new Array(0));const e=this._monomerLengthList[0],s=Math.max(Math.floor((this.grid?.vertScroll.min??0)-10),0),i=Math.min(Math.ceil((this.grid?.vertScroll.max??0)+10),this.col.length);for(let t=s;t<i;t++){if(this._rowsProcessed.get(t))continue;const s=this.getSeqMonList(t);s.length>e.length&&e.push(...new Array(s.length-e.length).fill(0));for(const[t,i]of r().enumerate(s)){const s=this.props.monomerToShort(t,this.props.monomerLengthLimit),n=this.props.separatorWidth+s.length*this.props.monomerCharWidth;e[i]=Math.max(e[i]??0,n)}this._updated=!0}return e}getPosition(t,e){const[s,i]=this.getCellMonomerLengths(t),n=this.col.get(t),o=r()(this._splitter(n)).toArray();if(0===o.length)return null;let a=100,l=null,h=o.length,c=!1,u=0;if(i[0]<=e&&e<i.slice(-1)[0])for(;!c;)if(u=Math.floor((h+(l??0))/2),e>=i[u]&&e<=i[u+1]?(l=u,c=!0):e<i[u]?h=u-1:e>i[u+1]&&(l=u+1),l==h&&(c=!0),--a<=0)throw new Error(`Get position for pointer x = ${e} searching has not converged on ${JSON.stringify(i)}. `);return l}getSeqMonList(t){const e=this.col.get(t);return e?r()(this._splitter(e)).toArray():[]}getMonomer(t){const e=this.props.unitsHandler.alphabet??"UN",s=l[e];return this.props.monomerLib?.getMonomer(s,t)??null}setMonomerLengthLimit(t){this.props.monomerLengthLimit=t,this._updated=!0}setSeparatorWidth(t){this.props.separatorWidth=t,this._updated=!0}isMsa(){return this.props.unitsHandler.isMsa()}}},1047:(t,e,s)=>{"use strict";s.d(e,{$3:()=>h,At:()=>n,Ei:()=>r,K4:()=>a,pU:()=>c,pn:()=>o,rx:()=>i,zh:()=>l});const i=["symbol","molfile","rgroups","name"],n="MonomerName",o={symbol:"Short Name",name:"Medium Name",smiles:"SMILES"},r=[{capGroupSmiles:"[*:1][H]",alternateId:"R1-H",capGroupName:"H",label:"R1"},{capGroupSmiles:"O[*:2]",alternateId:"R2-OH",capGroupName:"OH",label:"R2"}],a={monomerType:null,smiles:null,name:"MonomerName",author:null,molfile:"molecule",naturalAnalog:"MonomerNaturalAnalogCode",rgroups:"MonomerCaps",createDate:null,id:null,polymerType:"MonomerType",symbol:"MonomerCode"},l={monomerType:"Backbone",smiles:"",name:"",author:"Datagrok",molfile:"",naturalAnalog:"",rgroups:[],createDate:null,id:0,polymerType:"PEPTIDE",symbol:""},h="p",c=new RegExp(`[rd]\\((\\w)\\)${h}?`,"g")},5226:(t,e,s)=>{"use strict";s.d(e,{i:()=>r});var i=s(976),n=s(499),o=s(1821);class r{get descriptionsArray(){return this._descriptionsArray}get sequencesArray(){return this._sequencesArray}parseMacromolecule(t,e){return this._fileContent.slice(t,e).split(/\s/).join("")}parseColumns(){const t=/^>(.*)$/gm;let e,s=0;for(;e=t.exec(this._fileContent);){const i=this._fileContent.substring(e.index+1,t.lastIndex);this._descriptionsArray.push(i),0!==s&&this._sequencesArray.push(this.parseMacromolecule(s,e.index)),s=t.lastIndex+1}this._sequencesArray.push(this.parseMacromolecule(s,-1))}importFasta(){const t=i.Column.fromStrings("description",this.descriptionsArray),e=i.Column.fromStrings("sequence",this.sequencesArray);return e.semType=i.SEMTYPE.MACROMOLECULE,e.setTag(i.TAGS.UNITS,o.r2.FASTA),n.Cn.getOrCreate(e),[i.DataFrame.fromColumns([t,e])]}constructor(t){this._descriptionsArray=[],this._sequencesArray=[],this._fileContent=t,this.parseColumns()}}},1821:(t,e,s)=>{"use strict";s.d(e,{BM:()=>r,CI:()=>o,XS:()=>l,r2:()=>i});var i,n=s(6286);!function(t){t.FASTA="fasta",t.SEPARATOR="separator",t.HELM="helm"}(i||(i={}));const o=", ",r=/(?:\[([A-Za-z0-9_\-,()]+)\])|([A-Za-z\-])/g,a=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"])}}},l=[new n.L("PT",a.fasta.peptide,.5),new n.L("DNA",a.fasta.dna,.55),new n.L("RNA",a.fasta.rna,.55)]},8447:(t,e,s)=>{"use strict";s.d(e,{CI:()=>i.CI,GU:()=>n.GU,Mj:()=>n.Mj,XS:()=>i.XS,dQ:()=>n.dQ,kB:()=>n.kB,py:()=>n.py,r2:()=>i.r2,up:()=>n.up});var i=s(1821),n=s(585)},6286:(t,e,s)=>{"use strict";s.d(e,{L:()=>i,d:()=>n});class i{constructor(t,e,s){this.name=t,this.alphabet=e,this.cutoff=s}}class n extends i{constructor(t,e,s){super(t.name,t.alphabet,t.cutoff),this.freq=e,this.similarity=s}}},585:(t,e,s)=>{"use strict";s.d(e,{Ar:()=>f,FJ:()=>p,GU:()=>T,Mj:()=>v,dQ:()=>A,gP:()=>w,kB:()=>g,py:()=>E,up:()=>x,vU:()=>C,w4:()=>M});var i=s(976),n=s(6414),o=s.n(n),r=s(6286),a=s(1821),l=s(499),h=s(3659),c=s(850),u=s(2012),m=s(6137),d=s(7331);function g(t){return o()(t.toString().matchAll(a.BM)).map((t=>t[2]??t[1])).toArray()}function p(t){return t||[]}function f(t,e=undefined){return s=>s?s.split(t,e):[]}const y=/(PEPTIDE1|DNA1|RNA1)\{([^}]+)}/g,b=/\[([^\[\]]+)]/g;function w(t){y.lastIndex=0;const e=y.exec(t.toString()),s=e?e[2]:null;return(s?s.split("."):[]).map((t=>{b.lastIndex=0;const e=b.exec(t);return e&&e.length>=2?e[1]:t}))}function C(t,e,s=undefined){if(t.toLowerCase().startsWith(a.r2.FASTA))return g;if(t.toLowerCase().startsWith(a.r2.SEPARATOR))return f(e,s);if(t.toLowerCase().startsWith(a.r2.HELM))return w;throw new Error(`Unexpected units ${t} .`)}function v(t){return l.Cn.getOrCreate(t).getSplitter()}const S=/([^\W_]+)/g;function T(t,e){if(t.length<=e)return t;const s=t.match(S),i=t.length>e||(s?.length??0)>1,n=s?.[0]??" ";return i?n.substring(0,e-1)+"…":n}function M(t,e,s="-"){const i=e.map((e=>{const i=function(t,e,s="-"){const i=new Set([...new Set(Object.keys(t)),...e]);i.delete(s);const n=[],o=[];for(const s of i)n.push(s in t?t[s]:0),o.push(e.has(s)?1:0);const r=new h.OW(n),a=new h.OW(o);return(0,c.MA)(r,a)/((0,c.$G)(r)*(0,c.$G)(a))}(t,e.alphabet,s);return new r.d(e,t,i)}));let n;const o=Math.max(...i.map((t=>t.similarity>t.cutoff?t.similarity:-1)));return n=o>0?i.find((t=>t.similarity===o)).name:"UN",n}function A(t,e=5){let s;if(t.semType==i.SEMTYPE.MACROMOLECULE)s=l.Cn.getOrCreate(t).alphabet;else{const i=function(t,e,s){return t.categories,function(t,e){const s={};let i=!0,n=null;for(const o of t)if(null==n?n=o.length:o.length!==n&&(i=!1),o.length>=e)for(const t of o)t in s||(s[t]=0),s[t]+=1;return{freq:s,sameLength:i}}(o()(t.getRawData()).map((e=>s(t.categories[e]))),e)}(t,e,g);s=M(i.freq,a.XS)}return E(s)}function E(t){switch(t){case"PT":return u.f.GrokGroups;case"DNA":case"RNA":return m.J.Chromatogram;default:return d.UE.Color}}function x(t){const e=t.columns.bySemTypeAll(i.SEMTYPE.MACROMOLECULE);let s=e.find((t=>{const e=t.getTag(i.TAGS.UNITS);return!!e&&-1!==e.indexOf("MSA")}))??null;return!s&&e.length>0&&(s=e[0]),s}},8457:(t,e,s)=>{"use strict";s.d(e,{O:()=>a});var i=s(976),n=s(6414),o=s.n(n),r=s(585);function a(t){const e=(0,r.Mj)(t),s=t=>{const e=l.columns.addNewString((t+1).toString());return n.push(e),e},n=[],a=t.length,l=i.DataFrame.create(a);for(let i=0;i<a;++i){const r=t.get(i);if(null==r)continue;const a=e(r);for(const[t,e]of o().enumerate(a))((n[e]??null)||s(e)).set(i,t||"-",!1)}return l}},499:(t,e,s)=>{"use strict";s.d(e,{Cn:()=>d});var i=s(976),n=s(6414),o=s.n(n),r=s(8447),a=s(585),l=s(489),h=s(7228),c=s(1047);const u=new class{constructor(){this.uhTemp=`units-handler.${i.SEMTYPE.MACROMOLECULE}`}},m={[r.r2.FASTA]:"-",[r.r2.SEPARATOR]:"",[r.r2.HELM]:"*"};class d{static setUnitsToFastaColumn(t){if(t.column.semType!==i.SEMTYPE.MACROMOLECULE||t.column.getTag(i.TAGS.UNITS)!==r.r2.FASTA)throw new Error(`The column of notation '${r.r2.FASTA}' must be '${i.SEMTYPE.MACROMOLECULE}'.`);t.column.setTag(i.TAGS.UNITS,r.r2.FASTA),d.setTags(t)}static setUnitsToSeparatorColumn(t,e){if(t.column.semType!==i.SEMTYPE.MACROMOLECULE||t.column.getTag(i.TAGS.UNITS)!==r.r2.SEPARATOR)throw new Error(`The column of notation '${r.r2.SEPARATOR}' must be '${i.SEMTYPE.MACROMOLECULE}'.`);if(!e)throw new Error(`The column of notation '${r.r2.SEPARATOR}' must have the separator tag.`);t.column.setTag(i.TAGS.UNITS,r.r2.SEPARATOR),t.column.setTag("separator",e),d.setTags(t)}static setUnitsToHelmColumn(t){if(t.column.semType!==i.SEMTYPE.MACROMOLECULE)throw new Error(`The column of notation '${r.r2.HELM}' must be '${i.SEMTYPE.MACROMOLECULE}'`);t.column.setTag(i.TAGS.UNITS,r.r2.HELM),d.setTags(t)}static setTags(t){const e=t.column.getTag(i.TAGS.UNITS),s=t.stats;if(Object.keys(s.freq).some((t=>t.length>1)),[r.r2.FASTA,r.r2.SEPARATOR].includes(e)){if(0===Object.keys(s.freq).length)throw new Error("Alphabet is empty");let e=t.column.getTag("aligned");null===e&&(e=s.sameLength?"SEQ.MSA":"SEQ",t.column.setTag("aligned",e));let i=t.column.getTag("alphabet");if(null===i&&(i=(0,a.w4)(s.freq,r.XS),t.column.setTag("alphabet",i)),"UN"===i){const e=Object.keys(s.freq).length,i=Object.keys(s.freq).some((t=>t.length>1));t.column.setTag(".alphabetSize",e.toString()),t.column.setTag(".alphabetIsMultichar",i?"true":"false")}}}get column(){return this._column}get units(){return this._units}get notation(){return this._notation}get defaultGapSymbol(){return this._defaultGapSymbol}get separator(){const t=this.column.getTag("separator")??void 0;if(this.notation===r.r2.SEPARATOR&&void 0===t)throw new Error(`Separator is mandatory for column '${this.column.name}' of notation '${this.notation}'.`);return t}get aligned(){const t=this.column.getTag("aligned");if(!t&&(this.isFasta()||this.isSeparator()))throw new Error("Tag aligned not set");return t}get alphabet(){const t=this.column.getTag("alphabet");if(!t&&(this.isFasta()||this.isSeparator()))throw new Error("Tag alphabet not set");return t}get helmCompatible(){return this.column.getTag(".isHelmCompatible")}getAlphabetSize(){if(this.notation==r.r2.HELM||"UN"==this.alphabet){const t=this.column.getTag(".alphabetSize");let e;if(t)e=parseInt(t);else{const t=this.stats;e=Object.keys(t.freq).length}return e}switch(this.alphabet){case"PT":return 20;case"DNA":case"RNA":return 4;case"NT":return console.warn("Unexpected alphabet 'NT'."),4;default:throw new Error(`Unexpected alphabet '${this.alphabet}'.`)}}getAlphabetIsMultichar(){return this.notation===r.r2.HELM||"UN"===this.alphabet&&"true"===this.column.getTag(".alphabetIsMultichar")}get splitted(){if(null===this._splitted){const t=this.getSplitter(),e=this._column.length;this._splitted=new Array(e);const s=this._column.getRawData(),i=this._column.categories;for(let n=0;n<e;n++){const e=i[s[n]];this._splitted[n]=t(e)}}return this._splitted}get stats(){if(null===this._stats){const t={};let e=!0,s=null;for(const i of this.splitted){null==s?s=i.length:i.length!==s&&(e=!1);for(const e of i)e in t||(t[e]=0),t[e]+=1}this._stats={freq:t,sameLength:e}}return this._stats}get maxLength(){return null===this._maxLength&&(this._maxLength=Math.max(...this.splitted.map((t=>t.length)))),this._maxLength}get posList(){if(null===this._posList){const t=this.column.getTag(".positionNames");this._posList=t?t.split(r.CI).map((t=>t.trim())):o().count(1).take(this.maxLength).map((t=>t.toString())).toArray()}return this._posList}isFasta(){return this.notation===r.r2.FASTA}isSeparator(){return this.notation===r.r2.SEPARATOR}isHelm(){return this.notation===r.r2.HELM}isRna(){return"RNA"===this.alphabet}isDna(){return"DNA"===this.alphabet}isPeptide(){return"PT"===this.alphabet}isMsa(){return!!this.aligned&&this.aligned.toUpperCase().includes("MSA")}isHelmCompatible(){return"true"===this.helmCompatible}isGap(t){return!t||this.units===r.r2.FASTA&&t===m[r.r2.FASTA]||this.units===r.r2.HELM&&t===m[r.r2.HELM]}getNotation(){if(this.units.toLowerCase().startsWith(r.r2.FASTA))return r.r2.FASTA;if(this.units.toLowerCase().startsWith(r.r2.SEPARATOR))return r.r2.SEPARATOR;if(this.units.toLowerCase().startsWith(r.r2.HELM))return r.r2.HELM;throw new Error(`Column '${this.column.name}' has unexpected notation '${this.units}'.`)}getHelmWrappers(){return[this.isDna()||this.isRna()||this.isHelmCompatible()?"RNA1{":"PEPTIDE1{",this.isDna()?"d(":this.isRna()?"r(":"",this.isDna()||this.isRna()?")p":"","}$$$$"]}getNewColumn(t,e){const s=this.column,n=s.length,o=t.toLowerCase()+"("+s.name+")",a=s.dataFrame.columns.getUnusedName(o),l=i.Column.fromList("string",a,new Array(n).fill(""));if(l.semType=i.SEMTYPE.MACROMOLECULE,l.setTag(i.TAGS.UNITS,t),t===r.r2.SEPARATOR){if(!e)throw new Error(`Notation '${r.r2.SEPARATOR}' requires separator value.`);l.setTag("separator",e)}l.setTag(i.TAGS.CELL_RENDERER,"Macromolecule");const h=s.getTag("aligned");h&&l.setTag("aligned",h);const c=s.getTag("alphabet");null!=c&&l.setTag("alphabet",c);let u=s.getTag(".alphabetSize");null!=c&&u&&l.setTag(".alphabetSize",u);const m=s.getTag(".alphabetIsMultichar");return null!=c&&void 0!==m&&l.setTag(".alphabetIsMultichar",m),t==r.r2.HELM&&(u=this.getAlphabetSize().toString(),l.setTag(".alphabetSize",u)),l}static getNewColumn(t){const e=d.getOrCreate(t),s=e.notation;return e.getNewColumn(s)}static unitsStringIsValid(t){return t=t.toLowerCase(),[r.r2.FASTA,r.r2.SEPARATOR,r.r2.HELM].some((e=>t.startsWith(e.toLowerCase())))}static getNewColumnFromParams(t,e,s){if(!d.unitsStringIsValid(s))throw new Error("Invalid format of 'units' parameter");const n=i.Column.fromList("string",e,new Array(t).fill(""));return n.semType=i.SEMTYPE.MACROMOLECULE,n.setTag(i.TAGS.UNITS,s),n}getSplitter(t){if(this.units.toLowerCase().startsWith(r.r2.FASTA))return null===this.column.getTag("alphabet")||this.getAlphabetIsMultichar()?a.kB:a.FJ;if(this.units.toLowerCase().startsWith(r.r2.SEPARATOR))return(0,a.Ar)(this.separator,t);if(this.units.toLowerCase().startsWith(r.r2.HELM))return a.gP;throw new Error(`Unexpected units ${this.units} .`)}getDistanceFunctionName(){if(!this.isFasta())throw new Error("Only FASTA notation is supported");return this.isMsa()?l.U.HAMMING:(this.alphabet,l.U.LEVENSHTEIN)}getDistanceFunction(){return l.o[this.getDistanceFunctionName()]()}async checkHelmCompatibility(){if(this.column.tags.has(".isHelmCompatible"))return"true"===this.column.getTag(".isHelmCompatible");const t=(await(0,h.JN)()).getBioLib().getMonomerSymbolsByType("PEPTIDE".toString()),e=new Set(t),s=(0,a.Ar)(this.separator);for(const t of this.column.categories){const i=s(t);for(const t of i)if(!e.has(t))return this.column.setTag(".isHelmCompatible","false"),!1}return this.column.setTag(".isHelmCompatible","true"),!0}get splitter(){return null===this._splitter&&(this._splitter=(0,a.Mj)(this.column)),this._splitter}toFasta(t){return t===r.r2.FASTA}toSeparator(t){return t===r.r2.SEPARATOR}toHelm(t){return t===r.r2.HELM}convertHelmToFastaSeparator(t,e,s,i){i||(i=this.toFasta(e)?m[r.r2.FASTA]:m[r.r2.SEPARATOR]),s||(s=this.toFasta(e)?"":this.separator);const n=t.startsWith("RNA"),o=this.splitter(t),a=[];for(let t=0;t<o.length;t++){let s=o[t];if(n&&(s=s.replace(c.pU,"")),s===m[r.r2.HELM])a.push(i);else if(this.toFasta(e)&&s.length>1){const t="["+s+"]";a.push(t)}else a.push(s)}return a.join(s)}convert(t,e){const s=this.getConverter(t,e),i=this.getNewColumn(t,e);return i.init((t=>s(this.column.get(t)))),i}getRegion(t,e,s){const i=this.getNewColumn(this.notation,this.separator);i.name=s,Math.max(...this.splitted.map((t=>t.length)));const n=t??0,o=e??this.maxLength-1,a=this.getJoiner(),l=o-n+1;i.init((t=>{const e=this.splitted[t],s=new Array(l);for(let t=0;t<l;++t){const i=n+t;s[t]=i<e.length?e[i]:m[this.notation]}return a(s)}));const h=t=>{const e=t.split(",").map((t=>t.trim())),s=new Array(l);for(let t=0;t<l;++t){const i=n+t;s[t]=i<e.length?e[i]:"?"}return s.join(r.CI)},c=this.column.getTag(".positionNames");c&&i.setTag(".positionNames",h(c));const u=this.column.getTag(".positionLabels");return u&&i.setTag(".positionLabels",h(u)),i}getJoiner(){const t=this;if(this.notation===r.r2.FASTA)return function(e){return g(t,e)};if(this.notation===r.r2.SEPARATOR)return function(e){return p(t,e,t.separator)};if(this.notation===r.r2.HELM){const e="DNA"===t.alphabet||"RNA"===t.alphabet;return function(s){return f(t,s,e)}}throw new Error}getConverter(t,e=undefined){if(t===r.r2.SEPARATOR&&!e)throw new Error(`Target separator is not specified for target units '${r.r2.SEPARATOR}'.`);const s=this;if(t===r.r2.FASTA)return function(t){return function(t,e){const s=t.isHelm()?y(t,e):t.getSplitter()(e);return g(t,s)}(s,t)};if(t===r.r2.HELM)return function(t){return function(t,e){const s=e.startsWith("DNA")||e.startsWith("RNA"),i=t.getSplitter()(e);return f(t,i,s)}(s,t)};if(t===r.r2.SEPARATOR)return function(t){return function(t,e,s){const i=t.isHelm()?y(t,e):t.getSplitter()(e);return p(t,i,s)}(s,t,e)};throw new Error}constructor(t){if(this._splitter=null,this._splitted=null,this._stats=null,this._maxLength=null,this._posList=null,t.type!=i.TYPE.STRING)throw new Error(`Unexpected column type '${t.type}', must be '${i.TYPE.STRING}'.`);this._column=t;const e=this._column.getTag(i.TAGS.UNITS);if(null==e)throw new Error("Units are not specified in column");if(this._units=e,this._notation=this.getNotation(),this._defaultGapSymbol=this.isFasta()?m[r.r2.FASTA]:this.isHelm()?m[r.r2.HELM]:m[r.r2.SEPARATOR],!this.column.tags.has("aligned")||!this.column.tags.has("alphabet")||!this.column.tags.has(".alphabetIsMultichar")&&!this.isHelm()&&"UN"===this.alphabet)if(this.isFasta())d.setUnitsToFastaColumn(this);else if(this.isSeparator()){const e=t.getTag("separator");d.setUnitsToSeparatorColumn(this,e)}else{if(!this.isHelm())throw new Error(`Unexpected units '${this.column.getTag(i.TAGS.UNITS)}'.`);d.setUnitsToHelmColumn(this)}if(!this.column.tags.has(".alphabetIsMultichar"))if(this.isHelm())this.column.setTag(".alphabetIsMultichar","true");else if(["UN"].includes(this.alphabet))throw new Error(`For column '${this.column.name}' of alphabet '${this.alphabet}' tag '.alphabetIsMultichar' is mandatory.`)}static getOrCreate(t){return u.uhTemp in t.temp||(t.temp[u.uhTemp]=new d(t)),t.temp[u.uhTemp]}}function g(t,e){const s=new Array(e.length);for(const[i,n]of o().enumerate(e)){let o=i;t.isHelm()&&(o=i.replace(c.pU,"$1")),t.isGap(o)?o=m[r.r2.FASTA]:o.length>1&&(o="["+e[n]+"]"),s[n]=o}return s.join("")}function p(t,e,s){const i=new Array(e.length);for(const[s,n]of o().enumerate(e)){let e=s;t.isGap(e)&&(e=m[r.r2.SEPARATOR]),i[n]=e}return i.map((t=>t??"")).join(s)}function f(t,e,s){const[i,n,a,l]=t.getHelmWrappers();return`${i}${o()(e).map((e=>{let i=e;return i=t.isGap(i)?m[r.r2.HELM]:s?i.replace(c.pU,"$1"):1==e.length?`${n}${e}${a}`:`${n}[${e}]${a}`,i})).toArray().join(".")}${l}`}function y(t,e){const s=t.getSplitter()(e),i=new Array(s.length),n=e.startsWith("DNA"),r=e.startsWith("RNA");for(const[t,e]of o().enumerate(s)){let s=t;(n||r)&&(s=s.replace(c.pU,"$1"),s=s===c.$3?null:s),i[e]=s}return i.filter((t=>null!==t))}},9298:(t,e,s)=>{"use strict";var i,n,o,r,a,l;s.d(e,{Ct:()=>l,DX:()=>i,ES:()=>n,dE:()=>a,iD:()=>r,vS:()=>h,vw:()=>o}),function(t){t.tooltipWebLogo=".tooltipWebLogo"}(i||(i={})),function(t){t.Entropy="Entropy",t.full="100%"}(n||(n={})),function(t){t.TOP="top",t.MIDDLE="middle",t.BOTTOM="bottom"}(o||(o={})),function(t){t.LEFT="left",t.CENTER="center",t.RIGHT="right"}(r||(r={})),function(t){t.AUTO="auto",t.ON="on",t.OFF="off"}(a||(a={})),function(t){t.Filtered="Filtered",t.Selected="Selected"}(l||(l={}));const h=new class{constructor(){this.sequenceColumnName=null,this.startPositionName=null,this.endPositionName=null,this.skipEmptySequences=!0,this.skipEmptyPositions=!1,this.shrinkEmptyTail=!0,this.backgroundColor=4294967295,this.positionHeight=n.Entropy,this.positionWidth=16,this.verticalAlignment=o.MIDDLE,this.horizontalAlignment=r.CENTER,this.fixWidth=!1,this.fitArea=!0,this.minHeight=50,this.maxHeight=100,this.showPositionLabels=!0,this.positionMarginState=a.AUTO,this.positionMargin=0,this.filterSource=l.Filtered}}},2669:(t,e,s)=>{"use strict";s.d(e,{m:()=>i});class i{constructor(t=!0,e=!0){const i=navigator.hardwareConcurrency;this._workerCount=t?Math.max(i-2,1):1,this._workers=new Array(this._workerCount).fill(null).map((()=>new Worker(new URL(s.p+s.u(868),s.b)))),this._terminateOnComplete=e}async calc(t,e,s=!0,i){return new Promise((async(n,o)=>{try{const o=t.length,r=new Array(this._workerCount),a=o*(o-1)/2;this._workerCount=Math.min(this._workerCount,a);const l=a/this._workerCount,h=new Float32Array(a);let c=0,u=1,m=0,d=Number.MIN_VALUE;for(let s=0;s<this._workerCount;s++){const n=Math.floor(s*l),g=s===this._workerCount-1?a:Math.floor((s+1)*l),p=c,f=u;s!==this._workerCount-1&&(c=o-2-Math.floor(Math.sqrt(-8*g+4*o*(o-1)-7)/2-.5),u=g-o*c+Math.floor((c+1)*(c+2)/2)),this._workers[s].postMessage({values:t,fnName:e,startRow:p,startCol:f,chunckSize:g-n,opts:i}),r[s]=new Promise(((t,e)=>{this._workers[s].onmessage=({data:{error:i,distanceMatrixData:o,min:r,max:a}})=>{this._terminateOnComplete&&this._workers[s].terminate(),i?e(i):(h.set(o,n),r<m&&(m=r),a>d&&(d=a),t())}}))}await Promise.all(r),s&&h.forEach(((t,e)=>{h[e]=(t-m)/(d-m)})),n(h)}catch(t){o(t)}}))}terminate(){this._workers.forEach((t=>t.terminate()))}}},3914:(t,e,s)=>{"use strict";s.d(e,{H:()=>n});var i=s(6814);class n{get data(){return this._data}get size(){return this._size}constructor(t,e){if(null==e){if(null==t)throw new Error("Arguments error: data or size is required.");if(this._data=t,this._size=(1+Math.sqrt(1+8*this._data.length))/2,this._size!=Math.floor(this._size))throw new Error(`Invalid data length ${this._data.length} leads to non integer size ${this._size}`)}else{this._size=e;const s=e*(e-1)/2;if(t){if(t.length!=s)throw new Error(`Invalid data length. Observations size ${e} requires data length ${s}.`);this._data=t}else this._data=new Float32Array(s)}}_linearizeIJ(t,e){if(!(t<e))throw new Error("i must be less than j");return this._size*t+e-Math.floor((t+2)*(t+1)/2)}get(t,e){return t==e?0:t<e?this._data[this._linearizeIJ(t,e)]:this._data[this._linearizeIJ(e,t)]}set(t,e,s){this._data[this._linearizeIJ(t,e)]=s}static calc(t,e){const s=t.length,o=new n(void 0,s);for(let n=0;n<s;n++)for(let r=n+1;r<s;r++)o.set(n,r,(0,i.k)(t[n])||(0,i.k)(t[r])?1:e(t[n],t[r]));return o}square(){for(let t=0;t<this._data.length;t++)this._data[t]=this._data[t]**2}add(t){if(this._size!==t._size)throw new Error(`Matrices must have the same size. This size: ${this._size}, other size: ${t._size}`);for(let e=0;e<this._data.length;e++)this._data[e]+=t._data[e]}sqrt(){for(let t=0;t<this._data.length;t++)this._data[t]=Math.sqrt(this._data[t])}normalize(){let t=0,e=this._data[0];for(let s=0;s<this._data.length;s++)this._data[s]<t&&(t=this._data[s]),this._data[s]>e&&(e=this._data[s]);const s=e-t;for(let i=0;i<this._data.length;i++)this._data[i]=0===s?this._data[i]-t:(this._data[i]-t)/(e-t)}}},6254:(t,e,s)=>{"use strict";function i(t,e){const s=n(e);function i(t,e){const i=Number(t),n=Number(e);return s(i,n)}const o={get:(t,s,n)=>"length"===s?e:new Proxy(t,function(t){return{get:(e,s,n)=>t===s?0:e[Number(t)>Number(s)?i(s,t):i(t,s)]}}(s))};return new Proxy(t,o)}function n(t){return(e,s)=>t*e+s-Math.floor((e+2)*(e+1)/2)}s.d(e,{_:()=>i,y:()=>n})},2590:(t,e,s)=>{"use strict";s.d(e,{_:()=>r});var i=s(5697),n=s(6361),o=s(6814);class r{constructor(){this._workerCount=Math.max(navigator.hardwareConcurrency-2,1),this._workers=new Array(this._workerCount).fill(null).map((()=>new Worker(new URL(s.p+s.u(381),s.b))))}async calc(t,e,s,i){const n=t.length*(t.length-1)/2,o=Math.floor(n/this._workerCount),r=new Array(this._workerCount);for(let a=0;a<this._workerCount;a++)r[a]=new Promise(((r,l)=>{const h=a*o,c=a===this._workerCount-1?n:(a+1)*o;this._workers[a].postMessage({values:t,startIdx:h,endIdx:c,threshold:s,fnName:e,opts:i}),this._workers[a].onmessage=({data:{error:t,i:e,j:s,distance:i}})=>{t?l(t):(this._workers[a].terminate(),r({i:e,j:s,distance:i,idx:a}))}}));const a=await Promise.all(r),l=a.reduce(((t,e)=>t+e.i.length),0),h=new Int32Array(l),c=new Int32Array(l),u=new Float32Array(l);let m=0;for(const t of a)h.set(t.i,m),c.set(t.j,m),u.set(t.distance,m),m+=t.i.length;return{i:h,j:c,distance:u}}static calcSync(t,e,s,r){const a=[],l=[],h=[];let c=0,u=0,m=0;const d=t.length*(t.length-1)/2;for(;c<d;){const d=(0,o.k)(t[u])||(0,o.k)(t[m])?1:s(t[u],t[m]);(Object.values(n.gk).some((t=>t===e))?(0,i.Om)(d):1-d)>=r&&(a.push(u),l.push(m),h.push(d)),c++,m++,m===t.length&&(u++,m=u+1)}return{i:new Int32Array(a),j:new Int32Array(l),distance:new Float32Array(h)}}}},6814:(t,e,s)=>{"use strict";s.d(e,{k:()=>i});const i=t=>null==t},5697:(t,e,s)=>{"use strict";s.d(e,{Dz:()=>C,FV:()=>u,KR:()=>c,MI:()=>S,NB:()=>f,Om:()=>T,Rt:()=>a,UX:()=>p,WI:()=>g,Zd:()=>d,_h:()=>m,aW:()=>b,bX:()=>A,bc:()=>l,fX:()=>v,kg:()=>r,s:()=>y,yU:()=>w});var i=s(9657),n=s(1040),o=s(489);n.gk.Tanimoto,n.gk.Dice,n.gk.Asymmetric,n.gk.BraunBlanquet,n.gk.Cosine,n.gk.Kulczynski,n.gk.McConnaughey,n.gk.RogotGoldberg,n.gk.Russel,n.gk.Sokal,n.gk.Hamming,n.gk.Euclidean,n.gk.Tanimoto,n.gk.Dice,n.gk.Asymmetric,n.gk.BraunBlanquet,n.gk.Cosine,n.gk.Kulczynski,n.gk.McConnaughey,n.gk.RogotGoldberg,n.gk.Russel,n.gk.Sokal,n.gk.Hamming,n.gk.Euclidean;const r=[n.gk.Tanimoto,n.gk.Dice,n.gk.Cosine],a=[n.gk.Tanimoto,n.gk.Asymmetric,n.gk.Cosine,n.gk.Sokal],l=[o.U.HAMMING,o.U.LEVENSHTEIN,o.U.MONOMER_CHEMICAL_DISTANCE];function h(t,e){const s=t.trueCount()+e.trueCount();if(0==s)return 1;const i=t.andWithCountBits(e,!0);return i/(s-i)}function c(t,e){return M(h(t,e))}function u(t,e){return M(h(new i.Z(t,32*t.length),new i.Z(e,32*e.length)))}function m(t,e){return M(function(t,e){const s=t.trueCount()+e.trueCount();return 0==s?0:2*t.andWithCountBits(e,!0)/s}(t,e))}function d(t,e){return M(function(t,e){const s=t.trueCount()*e.trueCount();return 0==s?0:t.andWithCountBits(e,!0)/Math.sqrt(s)}(t,e))}function g(t,e){return Math.sqrt(t.trueCount()+e.trueCount()-2*t.andWithCountBits(e,!0))}function p(t,e){return t.trueCount()+e.trueCount()-2*t.andWithCountBits(e,!0)}function f(t,e){return M(function(t,e){const s=t.trueCount()+e.trueCount(),i=t.andWithCountBits(e,!0);return i/(2*s-3*i)}(t,e))}function y(t,e){return M(function(t,e){const s=t.trueCount()+e.trueCount(),i=t.trueCount()*e.trueCount();return 0==i?0:t.andWithCountBits(e,!0)*s/(2*i)}(t,e))}function b(t,e){return M(function(t,e){const s=t.trueCount()+e.trueCount(),i=t.trueCount()*e.trueCount();return 0==i?0:(t.andWithCountBits(e,!0)*s-i)/i}(t,e))}function w(t,e){return M(function(t,e){const s=Math.min(t.trueCount(),e.trueCount());return 0==s?0:t.andWithCountBits(e,!0)/s}(t,e))}function C(t,e){return M(function(t,e){const s=Math.max(t.trueCount(),e.trueCount());return 0==s?0:t.andWithCountBits(e,!0)/s}(t,e))}function v(t,e){return M(function(t,e){return 0==t.length?0:t.andWithCountBits(e,!0)/t.length}(t,e))}function S(t,e){return M(function(t,e){const s=t.andWithCountBits(e,!0),i=t.countBits(!0)+e.countBits(!0),n=t.length,o=n-i+s;return s==n||o==n?1:s/i+o/(2*n-i)}(t,e))}function T(t){return 1/(1+t)}function M(t){return 0===t?3402823e32:1/t-1}function A(t,e){return Math.abs(t-e)}},779:(t,e,s)=>{"use strict";function i(t={}){const e=function(){if(!t||!t.scoringMatrix||!t.alphabetIndexes)return(t,e)=>t===e?0:1;if(t.scoringMatrix.length!==Object.keys(t.alphabetIndexes).length)throw new Error("Scoring matrix and alphabet indexes should have the same length");const e=t.alphabetIndexes,s=t.scoringMatrix,i=Math.min(...Object.keys(e).map((t=>t.charCodeAt(0))))+1,n=new Float32Array((s.length+i)*(s.length+i));return Object.entries(e).forEach((([t,i])=>{const o=s[i];Object.entries(e).forEach((([e,i])=>{n[t.charCodeAt(0)*s.length+e.charCodeAt(0)]=o[i]}))})),(t,e)=>n[t.charCodeAt(0)*s.length+e.charCodeAt(0)]}();return(t,s)=>{let i=0;const n=t.length,o=s.length;n!==o&&(i=Math.abs(n-o));let r=0;for(let i=0;i<Math.min(n,o);i++)t[i]!==s[i]&&(r+=e(t[i],s[i]));return r+=i,r/=Math.max(n,o),r}}s.d(e,{j:()=>i})},489:(t,e,s)=>{"use strict";s.d(e,{U:()=>i.U,o:()=>i.o});var i=s(5540)},458:(t,e,s)=>{"use strict";s.d(e,{r:()=>n});var i=s(1811);function n(){return(t,e)=>(0,i.T)(t,e)/Math.max(t.length,e.length)}},5540:(t,e,s)=>{"use strict";s.d(e,{U:()=>i,o:()=>a});var i,n=s(779),o=s(458),r=s(6683);!function(t){t.HAMMING="Hamming",t.LEVENSHTEIN="Levenshtein",t.NEEDLEMANN_WUNSCH="Needlemann-Wunsch",t.MONOMER_CHEMICAL_DISTANCE="Monomer chemical distance"}(i||(i={}));const a={[i.HAMMING]:n.j,[i.LEVENSHTEIN]:o.r,[i.NEEDLEMANN_WUNSCH]:r.n,[i.MONOMER_CHEMICAL_DISTANCE]:n.j}},6683:(t,e,s)=>{"use strict";s.d(e,{n:()=>n});const i={gapOpen:8,gapExtend:2,scoringMatrix:[[4,-1,-2,-2,0,-1,-1,0,-2,-1,-1,-1,-1,-2,-1,1,0,-3,-2,0,-2,-1,0,-4],[-1,5,0,-2,-3,1,0,-2,0,-3,-2,2,-1,-3,-2,-1,-1,-3,-2,-3,-1,0,-1,-4],[-2,0,6,1,-3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,-3,-2,11,2,-3,-4,-3,-2,-4],[-2,-2,-2,-3,-2,-1,-2,-3,2,-1,-1,-2,-1,3,-3,-2,-2,2,7,-1,-3,-2,-1,-4],[0,-3,-3,-3,-1,-2,-2,-3,-3,3,1,-2,1,-1,-2,-2,0,-3,-1,4,-3,-2,-1,-4],[-2,-1,3,4,-3,0,1,-1,0,-3,-4,0,-3,-3,-2,0,-1,-4,-3,-3,4,1,-1,-4],[-1,0,0,1,-3,3,4,-2,0,-3,-3,1,-1,-3,-1,0,-1,-3,-2,-2,1,4,-1,-4],[0,-1,-1,-1,-2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-2,0,0,-2,-1,-1,-1,-1,-1,-4],[-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,1]],alphabetIndexes:{A:0,R:1,N:2,D:3,C:4,Q:5,E:6,G:7,H:8,I:9,L:10,K:11,M:12,F:13,P:14,S:15,T:16,W:17,Y:18,V:19,B:20,Z:21,X:22,"*":23}};function n(t){return(e,s)=>{const{gapOpen:n,gapExtend:o,scoringMatrix:r,alphabetIndexes:a}={...i,...t},l=[new Array(e.length+1).fill(0),new Array(e.length+1).fill(0)],h=new Array(e.length+1).fill(!1),c=new Array(e.length+1).fill(!1);let u=0,m=1;for(let t=1;t<e.length+1;t++)l[0][t]=-n-(t-1)*o;for(let t=1;t<s.length+1;t++){l[m][0]=-n-(t-1)*o;for(let i=1;i<e.length+1;i++){const d=l[u][i-1]+r[a[e[i-1]]][a[s[t-1]]],g=l[u][i]-(h[i]?o:n),p=l[m][i-1]-(c[i-1]?o:n);l[m][i]=Math.max(d,p,g),l[m][i]===d?(h[i]=!1,c[i]=!1):l[m][i]===p?(h[i]=!1,c[i]=!0):(h[i]=!0,c[i]=!1)}u=m,m=(m+1)%2}const d=e.split("").map((t=>r[a[t]][a[t]])).reduce(((t,e)=>t+e),0),g=s.split("").map((t=>r[a[t]][a[t]])).reduce(((t,e)=>t+e),0),p=Math.max(d,g);return(p-l[u][e.length])/p}}},116:(t,e,s)=>{"use strict";var i;s.d(e,{AL:()=>i,aP:()=>o,bD:()=>n}),s(7659),s(3659),s(850),s(9006),s(7861),s(9657),s(1729),s(2669),s(3914),s(6254),s(2590),s(952),function(t){t.UMAP="UMAP",t.T_SNE="t-SNE"}(i||(i={}));class n{constructor(){this.learningRate={uiName:"Learinig rate",value:1,tooltip:"The initial learning rate for the embedding optimization"},this.nComponents={uiName:"Components",value:2,tooltip:"The number of components (dimensions) to project the data to"},this.nEpochs={uiName:"Epochs",value:0,tooltip:"The number of epochs to optimize embeddings via SGD. Computed automatically if set to 0"},this.nNeighbors={uiName:"Neighbors",value:15,tooltip:"The number of nearest neighbors to construct the fuzzy manifold"},this.spread={uiName:"Spread",value:1,tooltip:"The effective scale of embedded points, used with min distance to control the clumped/dispersed nature of the embedding"},this.minDist={uiName:"Min distance",value:.1,tooltip:"The effective minimum distance between embedded points, used with spread to control the clumped/dispersed nature of the embedding"}}}class o{constructor(){this.epsilon={uiName:"Epsilon",value:10,tooltip:"Epsilon is learning rate"},this.perplexity={uiName:"Perplexity",value:30,tooltip:"Roughly how many neighbors each point influences"},this.dim={uiName:"Dimensionality",value:2,tooltip:"Dimensionality of the embedding"}}}},9006:(t,e,s)=>{"use strict";s.d(e,{Ek:()=>l,a1:()=>a,nR:()=>h});var i=s(850),n=s(4588),o=s(6254),r=s(2669);class a{constructor(t){this.steps=t?.steps??0,this.cycles=t?.cycles??1e6,this.cutoff=t?.cutoff??0,this.lambda=t?.lambda??2,this.dlambda=t?.dlambda??.01,this.lambda2=this.lambda/2,this.dlambda2=this.dlambda/2,this.epsilon=t?.epsilon??1e-10,this.distanceFunction=t?.distance??i.dP,this.distance=new Float32Array,this.distanceFunctionName=t?.distanceFunctionName}async initDistance(t){this.dmIndexFunct=(0,o.y)(t.length);const e=new r.m(!0,!1);this.distance=await e.calc(t,this.distanceFunctionName),e.terminate()}calcDistance(t,e,s){return this.distance[this.dmIndexFunct(e,s)]}async embed(t){const e=t.length,s=(0,i.kO)(e,a.dimension,40);let o=this.lambda2;0===this.steps&&(this.steps=t.length-1),await this.initDistance(t);for(let r=0;r<this.cycles;++r){for(let r=0;r<this.steps;++r){const r=(0,n.I)(e);let a=(0,n.I)(e);for(;r==a;)a=(0,n.I)(e);const l=s[r],h=s[a],c=this.calcDistance(t,r,a),u=(0,i.dP)(l,h);if(0==this.cutoff||c<=this.cutoff||u<c){const t=o*(c-u)/(u+this.epsilon),e=(0,i.On)(l,h,-1);s[r]=(0,i.On)(l,e,t),s[a]=(0,i.On)(h,e,-t)}}if(o-=this.dlambda2,o<=0)break}return s}}a.dimension=2;class l extends a{async embed(t){const e=t.length,s=(0,i.kO)(e,l.dimension,40);let o=this.lambda;await this.initDistance(t);for(let r=0;r<this.cycles;++r){const r=(0,n.I)(e),a=s[r];for(let n=0;n<e;++n){if(r==n)continue;const e=s[n],l=this.calcDistance(t,r,n),h=(0,i.dP)(a,e);if(0==this.cutoff||l<=this.cutoff||h<l){const t=o*(l-h)/(h+this.epsilon),r=(0,i.On)(a,e,-1);s[n]=(0,i.On)(e,r,-t)}}if(o-=this.dlambda,o<=0)break}return s}}class h extends a{constructor(t){super(t),this.cycles=t?.cycles??1e3,this.steps=t?.steps??1e5,this.radiusPercent=t?.radiusPercent??1,this.maxDistance=t?.maxDistance??null,this.maxDistanceSteps=t?.maxDistanceSteps??null}async embed(t){const e=t.length,s=(0,i.kO)(e,h.dimension,40);if(await this.initDistance(t),null===this.maxDistanceSteps&&(this.maxDistanceSteps=e*Math.floor((e-1)/2)),null===this.maxDistance){this.maxDistance=-1e37;for(let s=0;s<this.maxDistanceSteps;s++){const s=(0,n.I)(e);let i=(0,n.I)(e);for(;s==i;)i=(0,n.I)(e);const o=this.calcDistance(t,s,i);o>this.maxDistance&&(this.maxDistance=o)}}let o=this.lambda;const r=0==this.radiusPercent?this.maxDistance:this.maxDistance*this.radiusPercent;for(let a=0;a<this.cycles;++a){for(let a=0;a<this.steps;++a){const a=(0,n.I)(e);let l=(0,n.I)(e);for(;a==l;)l=(0,n.I)(e);const h=s[a],c=s[l],u=this.calcDistance(t,a,l),m=(0,i.dP)(h,c);if(u<=r||m<u){const t=.5*o*(u-m)/(m+this.epsilon),e=(0,i.On)(h,c,-1);s[a]=(0,i.On)(h,e,t),s[l]=(0,i.On)(c,e,-t)}}if(o-=(this.lambda-this.dlambda)/(this.cycles-1),o<this.dlambda)break}return s}}},1040:(t,e,s)=>{"use strict";var i,n,o,r,a,l;s.d(e,{CF:()=>n,Qe:()=>a,W:()=>i,Yc:()=>l,gd:()=>r,gk:()=>o}),function(t){t.Levenshtein="Levenshtein",t.JaroWinkler="Jaro-Winkler",t.Manhattan="Manhattan"}(i||(i={})),function(t){t.Euclidean="Euclidean"}(n||(n={})),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"}(o||(o={})),function(t){t.TanimotoIntArray="TanimotoIntArray"}(r||(r={})),function(t){t.Vector="Vector",t.String="String",t.BitArray="BitArray",t.MacroMolecule="MacroMolecule",t.Number="Number",t.IntArray="IntArray"}(a||(a={})),function(t){t.NumericDistance="NumericDistance"}(l||(l={}))},6361:(t,e,s)=>{"use strict";s.d(e,{W:()=>i.W,gk:()=>i.gk});var i=s(1040);s(7861)},7861:(t,e,s)=>{"use strict";var i=s(1811),n=s(3979),o=s(5697),r=s(850),a=s(489),l=s(1040);const h={[l.CF.Euclidean]:r.dP},c={[l.W.Levenshtein]:i.T,[l.W.JaroWinkler]:n.H$,[l.W.Manhattan]:function(t,e){if(t.length!==e.length)return 1;{let s=0;for(let i=1;i<t.length;i++)s+=t[i]==e[i]?0:1;return s/t.length}}},u={[l.gk.Tanimoto]:o.KR,[l.gk.Dice]:o._h,[l.gk.Asymmetric]:o.yU,[l.gk.BraunBlanquet]:o.Dz,[l.gk.Cosine]:o.Zd,[l.gk.Kulczynski]:o.s,[l.gk.McConnaughey]:o.aW,[l.gk.RogotGoldberg]:o.MI,[l.gk.Russel]:o.fX,[l.gk.Sokal]:o.NB,[l.gk.Hamming]:o.UX,[l.gk.Euclidean]:o.WI},m={[l.gd.TanimotoIntArray]:o.FV},d={[l.Yc.NumericDistance]:o.bX},g={[l.Qe.Vector]:{[l.CF.Euclidean]:h[l.CF.Euclidean]},[l.Qe.String]:{[l.W.Levenshtein]:c[l.W.Levenshtein],[l.W.JaroWinkler]:c[l.W.JaroWinkler],[l.W.Manhattan]:c[l.W.Manhattan]},[l.Qe.BitArray]:{[l.gk.Tanimoto]:u[l.gk.Tanimoto],[l.gk.Dice]:u[l.gk.Dice],[l.gk.Asymmetric]:u[l.gk.Asymmetric],[l.gk.BraunBlanquet]:u[l.gk.BraunBlanquet],[l.gk.Cosine]:u[l.gk.Cosine],[l.gk.Kulczynski]:u[l.gk.Kulczynski],[l.gk.McConnaughey]:u[l.gk.McConnaughey],[l.gk.RogotGoldberg]:u[l.gk.RogotGoldberg],[l.gk.Russel]:u[l.gk.Russel],[l.gk.Sokal]:u[l.gk.Sokal]},[l.Qe.MacroMolecule]:{[a.U.HAMMING]:a.o[a.U.HAMMING],[a.U.LEVENSHTEIN]:a.o[a.U.LEVENSHTEIN],[a.U.NEEDLEMANN_WUNSCH]:a.o[a.U.NEEDLEMANN_WUNSCH],[a.U.MONOMER_CHEMICAL_DISTANCE]:a.o[a.U.MONOMER_CHEMICAL_DISTANCE]},[l.Qe.Number]:{[l.Yc.NumericDistance]:d[l.Yc.NumericDistance]},[l.Qe.IntArray]:{[l.gd.TanimotoIntArray]:m[l.gd.TanimotoIntArray]}};Object.keys(g).reduce(((t,e)=>{for(const s of Object.keys(g[e]))t[s]=e;return t}),{})},6490:(t,e,s)=>{"use strict";s.d(e,{M6:()=>o,SB:()=>l,Sr:()=>a,VA:()=>n,XV:()=>r,oi:()=>h,w5:()=>u});var i=s(9533);function n(t,e){const s=s=>i.cS(t).map((()=>i.VI(e,s))),n=[];return n.push(s(-1)),n.push(s(1/0)),n.push(s(0)),n}function o(t,e,s){const n=i.ll(t);for(let o=0;o<t;o++){let t=!0,r=0;for(;t;){r=i.AH(e,s);let a=!1;for(let t=0;t<o;t++)if(r===n[t]){a=!0;break}a||(t=!1)}n[o]=r}return n}function r(t,e,s,i,n){e=Math.floor(e);const o=t[0][e],r=t[1][e];if(t[2][e],s>=r[0])return 0;for(let t=0;t<o.length;t++)if(i===o[t])return 0;return a(t,e,s,i,n)}function a(t,e,s,i,n){const o=t[0][e],r=t[1][e],a=t[2][e];if(s>=r[0])return 0;r[0]=s,o[0]=i,a[0]=n;let l=0,h=0;for(;;){const e=2*l+1,i=e+1,n=t[0][0].length;if(e>=n)break;if(i>=n){if(!(r[e]>s))break;h=e}else if(r[e]>=r[i]){if(!(s<r[e]))break;h=e}else{if(!(s<r[i]))break;h=i}r[l]=r[h],o[l]=o[h],a[l]=a[h],l=h}return r[l]=s,o[l]=i,a[l]=n,1}function l(t,e,s,o,a){const l=n(e,o);for(let n=0;n<e;n++)for(let e=0;e<s;e++){if(t[0][n][e]<0)continue;const s=t[0][n][e],o=t[2][n][e],h=i.mH(a);r(l,n,h,s,o),r(l,s,h,n,o),t[2][n][e]=0}return l}function h(t){const e=t[0],s=t[1];for(let t=0;t<e.length;t++){const i=e[t],n=s[t];for(let t=0;t<i.length-1;t++){const e=i.length-t-1,s=n.length-t-1,o=i[0];i[0]=i[e],i[e]=o;const r=n[0];n[0]=n[s],n[s]=r,c(n,i,s,0)}}return{indices:e,weights:s}}function c(t,e,s,i){for(;2*i+1<s;){const n=2*i+1,o=n+1;let r=i;if(t[r]<t[n]&&(r=n),o<s&&t[r]<t[o]&&(r=o),r===i)break;{const s=t[i];t[i]=t[r],t[r]=s;const n=e[i];e[i]=e[r],e[r]=n,i=r}}}function u(t,e){const s=t[0][e],i=t[1][e],n=t[2][e];let o=1/0,r=-1;for(let t=0;t>s.length;t++)1===n[t]&&i[t]<o&&(o=i[t],r=t);return r>=0?(n[r]=0,Math.floor(s[r])):-1}},1729:(t,e,s)=>{"use strict";s.d(e,{u:()=>i.uB});var i=s(3585)},952:(t,e,s)=>{"use strict";function i(t,e,s,i,n){function o(t,e,s,i){if(s>t[t.length-1])return;let n=t.length-2;for(n=t.length-2;n>=0&&!(s>t[n]);n--);t.splice(t.length-1,1),t.splice(n+1,0,s),e.splice(e.length-1,1),e.splice(n+1,0,i)}console.time("knnGraph");const r=new Array(n).fill(null).map((()=>new Array(i).fill(1))),a=new Array(n).fill(null).map((()=>new Array(i).fill(1)));for(let i=0;i<t.length;i++)o(a[t[i]],r[t[i]],s[i],e[i]),o(a[e[i]],r[e[i]],s[i],t[i]);return console.timeEnd("knnGraph"),{knnIndexes:r,knnDistances:a}}s.d(e,{J:()=>i})},6802:(t,e,s)=>{"use strict";s.d(e,{$X:()=>l,A7:()=>n,Fv:()=>m,Hp:()=>p,IH:()=>a,NT:()=>r,RH:()=>u,cf:()=>c,gW:()=>h,p4:()=>o});var i=s(9533);class n{constructor(t,e,s,i){if(this.entries=new Map,this.nRows=0,this.nCols=0,t.length!==e.length||t.length!==s.length)throw new Error("rows, cols and values arrays must all have the same length");this.nRows=i[0],this.nCols=i[1];for(let i=0;i<s.length;i++){const n=t[i],o=e[i];this.checkDims(n,o);const r=this.makeKey(n,o);this.entries.set(r,{value:s[i],row:n,col:o})}}makeKey(t,e){return`${t}:${e}`}checkDims(t,e){if(!(t<this.nRows&&e<this.nCols))throw new Error("row and/or col specified outside of matrix dimensions")}set(t,e,s){this.checkDims(t,e);const i=this.makeKey(t,e);this.entries.has(i)?this.entries.get(i).value=s:this.entries.set(i,{value:s,row:t,col:e})}get(t,e,s=0){const i=this.makeKey(t,e);return this.entries.has(i)?this.entries.get(i).value:s}getAll(t=!0){const e=new Array(this.entries.size).fill(null);let s=0;return this.entries.forEach((t=>{e[s++]=t})),t&&e.sort(((t,e)=>t.row===e.row?t.col-e.col:t.row-e.row)),e}getDims(){return[this.nRows,this.nCols]}getRows(){return Array.from(this.entries,(([t,e])=>e.row))}getCols(){return Array.from(this.entries,(([t,e])=>e.col))}getValues(){return Array.from(this.entries,(([t,e])=>e.value))}forEach(t){this.entries.forEach((e=>t(e.value,e.row,e.col)))}map(t){const e=new Float32Array(this.entries.size);let s=0;this.entries.forEach((i=>{e[s++]=t(i.value,i.row,i.col)}));const i=[this.nRows,this.nCols];return new n(this.getRows(),this.getCols(),e,i)}toArray(){const t=i.cS(this.nRows).map((()=>i.ll(this.nCols)));return this.entries.forEach((e=>{t[e.row][e.col]=e.value})),t}}function o(t){const e=t.getRows(),s=t.getCols(),i=t.getValues(),o=s.length,r=new Int32Array(o),a=new Int32Array(o),l=new Float32Array(o);r.set(e),a.set(s),l.set(i);const h=[t.nCols,t.nRows];return new n(a,r,l,h)}function r(t,e){return g(t,e,((t,e)=>t*e))}function a(t,e){return g(t,e,((t,e)=>t+e))}function l(t,e){return g(t,e,((t,e)=>t-e))}function h(t,e){return g(t,e,((t,e)=>t>e?t:e))}function c(t,e){return t.map((t=>t*e))}function u(t){const e=new Set,s=t.getValues(),i=t.getRows(),o=t.getCols();for(let t=0;t<s.length;t++)0===s[t]&&e.add(t);const r=(t,s)=>!e.has(s),a=s.filter(r),l=i.filter(r),h=o.filter(r);return new n(l,h,a,t.getDims())}function m(t,e="l2"){const s=d[e],i=new Map;t.forEach(((t,e,s)=>{const n=i.get(e)||[];n.push(s),i.set(e,n)}));const o=new n([],[],[],t.getDims());for(let e of i.keys()){const n=i.get(e).sort(),r=s(n.map((s=>t.get(e,s))));for(let t=0;t<r.length;t++)o.set(e,n[t],r[t])}return o}const d={max:t=>{let e=-1/0;for(let s=0;s<t.length;s++)e=t[s]>e?t[s]:e;return t.map((t=>t/e))},l1:t=>{let e=0;for(let s=0;s<t.length;s++)e+=t[s];return t.map((t=>t/e))},l2:t=>{let e=0;for(let s=0;s<t.length;s++)e+=t[s]**2;return t.map((t=>Math.sqrt(t**2/e)))}};function g(t,e,s){const i=new Set,o=[],r=[],a=[],l=(i,n)=>{o.push(i),r.push(n);const l=s(t.get(i,n),e.get(i,n));a.push(l)},h=t.getValues(),c=t.getRows(),u=t.getCols();for(let t=0;t<h.length;t++){const e=c[t],s=u[t],n=`${e}:${s}`;i.add(n),l(e,s)}const m=e.getValues(),d=e.getRows(),g=e.getCols();for(let t=0;t<m.length;t++){const e=d[t],s=g[t],n=`${e}:${s}`;i.has(n)||l(e,s)}const p=[t.nRows,t.nCols];return new n(o,r,a,p)}function p(t){const e=[];t.forEach(((t,s,i)=>{e.push({value:t,row:s,col:i})})),e.sort(((t,e)=>t.row===e.row?t.col-e.col:t.row-e.row));const s=[],i=[],n=[];let o=-1;for(let t=0;t<e.length;t++){const{row:r,col:a,value:l}=e[t];r!==o&&(o=r,n.push(t)),s.push(a),i.push(l)}return{indices:s,values:i,indptr:n}}},1595:(t,e,s)=>{"use strict";s.d(e,{WX:()=>a,gK:()=>c,n_:()=>h,vF:()=>l});var i=s(6490),n=s(6802),o=s(4972),r=s(9533);function a(t,e){return function(s,n,o,a=10,l=50,h=.001,c=.5,u=!0){const m=s.length,d=i.VA(s.length,o);for(let n=0;n<s.length;n++){const r=i.M6(o,s.length,e);for(let e=0;e<r.length;e++){const o=t(s[n],s[r[e]]);i.XV(d,n,o,r[e],1),i.XV(d,r[e],o,n,1)}}if(u)for(let e=0;e<n.length;e++)for(let o=0;o<n[e].length&&!(n[e][o]<0);o++)for(let r=o+1;r<n[e].length&&!(n[e][r]<0);r++){const a=t(s[n[e][o]],s[n[e][r]]);i.XV(d,n[e][o],a,n[e][r],1),i.XV(d,n[e][r],a,n[e][o],1)}for(let n=0;n<a;n++){const n=i.SB(d,m,o,l,e);let a=0;for(let o=0;o<m;o++)for(let h=0;h<l;h++){let u=Math.floor(n[0][o][h]);if(!(u<0||r.mH(e)<c))for(let e=0;e<l;e++){const r=Math.floor(n[0][o][e]),l=n[2][o][h],c=n[2][o][e];if(r<0||!l&&!c)continue;const m=t(s[u],s[r]);a+=i.XV(d,u,m,r,1),a+=i.XV(d,r,m,u,1)}}if(a<=h*o*s.length)break}return i.oi(d)}}function l(t){return{initFromRandom:function(e,s,n,o,a){for(let l=0;l<n.length;l++){const h=r.M6(e,s.length,a);for(let e=0;e<h.length;e++){if(h[e]<0)continue;const r=t(s[h[e]],n[l]);i.XV(o,l,r,h[e],1)}}},initFromTree:function(e,s,n,r,a){for(let l=0;l<n.length;l++){const h=o.ii(n[l],e,a);for(let e=0;e<h.length;e++){if(h[e]<0)return;const o=t(s[h[e]],n[l]);i.XV(r,l,o,h[e],1)}}}}}function h(t){return function(e,s,o,r){const{indices:a,indptr:l}=n.Hp(s);for(let s=0;s<r.length;s++){const n=new Set(o[0][s]);for(;;){const h=i.w5(o,s);if(-1===h)break;const c=a.slice(l[h],l[h+1]);for(const a of c){if(a===h||-1===a||n.has(a))continue;const l=t(e[a],r[s]);i.Sr(o,s,l,a,1),n.add(a)}}}return o}}function c(t,e,s,n,o,r,a){const l=i.VA(s.length,n);if(o(n,e,s,l,a),t)for(let i of t)r(i,e,s,l,a);return l}},4972:(t,e,s)=>{"use strict";s.d(e,{HO:()=>c,Zv:()=>o,ii:()=>m});var i=s(9533);class n{constructor(t,e,s,i){this.hyperplanes=t,this.offsets=e,this.children=s,this.indices=i}}function o(t,e,s,o){const c=Math.max(10,e),u=i.w6(s).map(((e,s)=>function(t,e=30,s,n){return r(t,i.w6(t.length),e,s,n)}(t,c,s,o))),m=u.map((t=>function(t,e){const s=l(t),o=h(t),r=i.w6(s).map((()=>t.hyperplane?1:0)),c=i.ll(s),u=i.w6(s).map((()=>[-1,-1])),m=i.w6(o).map((()=>i.w6(e).map((()=>-1))));return a(t,r,c,u,m,0,0),new n(r,c,u,m)}(t,c)));return m}function r(t,e,s=30,n,o){if(e.length>s){const a=function(t,e,s){let n=i.AH(e.length,s),o=i.AH(e.length,s);o+=n===o?1:0,o%=e.length;const r=e[n],a=e[o];let l=0,h=0;h=t[r]-t[a],l-=h*(t[r]+t[a])/2;let c=0,u=0;const m=i.ll(e.length);for(let n=0;n<e.length;n++){let o=l;o+=h*t[e[n]],0===o?(m[n]=i.AH(2,s),0===m[n]?c+=1:u+=1):o>0?(m[n]=0,c+=1):(m[n]=1,u+=1)}const d=i.ll(c),g=i.ll(u);c=0,u=0;for(let t=0;t<m.length;t++)0===m[t]?(d[c]=e[t],c+=1):(g[u]=e[t],u+=1);return{indicesLeft:d,indicesRight:g,hyperplane:h,offset:l}}(t,e,o),{indicesLeft:l,indicesRight:h,hyperplane:c,offset:u}=a;return{leftChild:r(t,l,s,n+1,o),rightChild:r(t,h,s,n+1,o),isLeaf:!1,hyperplane:c,offset:u}}return{indices:e,isLeaf:!0}}function a(t,e,s,i,n,o,r){if(t.isLeaf)return i[o][0]=-r,n[r].splice(0,t.indices.length,...t.indices),{nodeNum:o,leafNum:r+=1};{e[o]=t.hyperplane,s[o]=t.offset,i[o][0]=o+1;const l=o;let h=a(t.leftChild,e,s,i,n,o+1,r);return o=h.nodeNum,r=h.leafNum,i[l][1]=o+1,h=a(t.rightChild,e,s,i,n,o+1,r),{nodeNum:h.nodeNum,leafNum:h.leafNum}}}function l(t){return t.isLeaf?1:1+l(t.leftChild)+l(t.rightChild)}function h(t){return t.isLeaf?1:h(t.leftChild)+h(t.rightChild)}function c(t){if(t.length>0){const e=[];for(let s of t)e.push(...s.indices);return e}return[[-1]]}function u(t,e,s,n){let o=e;return o+=t*s,0===o?i.AH(2,n):o>0?0:1}function m(t,e,s){let i=0;for(;e.children[i][0]>0;)i=0===u(e.hyperplanes[i],e.offsets[i],t,s)?e.children[i][0]:e.children[i][1];const n=-1*e.children[i][0];return e.indices[n]}},3585:(t,e,s)=>{"use strict";s.d(e,{uB:()=>u});var i=s(6490),n=s(6802),o=s(1595),r=s(4972),a=s(9533),l=s(3107);const h=1e-5,c=.001;class u{get neighbors(){return this.nNeighbors}constructor(t={}){this.learningRate=1,this.localConnectivity=1,this.minDist=.1,this.nComponents=2,this.nEpochs=0,this.nNeighbors=15,this.negativeSampleRate=5,this.random=Math.random,this.repulsionStrength=1,this.setOpMixRatio=1,this.spread=1,this.transformQueueSize=4,this.targetMetric="categorical",this.targetWeight=.5,this.targetNNeighbors=this.nNeighbors,this.distanceFn=m,this.isInitialized=!1,this.rpForest=[],this.embedding=[],this.optimizationState=new d;const e=e=>{void 0!==t[e]&&(this[e]=t[e])};e("distanceFn"),e("learningRate"),e("localConnectivity"),e("minDist"),e("nComponents"),e("nEpochs"),e("nNeighbors"),e("negativeSampleRate"),e("random"),e("repulsionStrength"),e("setOpMixRatio"),e("spread"),e("transformQueueSize")}fit(t){return this.initializeFit(t),this.optimizeLayout(),this.embedding}async fitAsync(t,e=(()=>!0)){return this.initializeFit(t),await this.optimizeLayoutAsync(e),this.embedding}setSupervisedProjection(t,e={}){this.Y=t,this.targetMetric=e.targetMetric||this.targetMetric,this.targetWeight=e.targetWeight||this.targetWeight,this.targetNNeighbors=e.targetNNeighbors||this.targetNNeighbors}setPrecomputedKNN(t,e){this.knnIndices=t,this.knnDistances=e}initializeFit(t){if(t.length<=this.nNeighbors)throw new Error(`Not enough data points (${t.length}) to create nNeighbors: ${this.nNeighbors}. Add more data points or adjust the configuration.`);if(this.X===t&&this.isInitialized)return this.getNEpochs();if(this.X=t,!this.knnIndices&&!this.knnDistances){const e=this.nearestNeighbors(t);this.knnIndices=e.knnIndices,this.knnDistances=e.knnDistances}this.graph=this.fuzzySimplicialSet(t,this.nNeighbors,this.setOpMixRatio),this.makeSearchFns(),this.searchGraph=this.makeSearchGraph(t),this.processGraphForSupervisedProjection();const{head:e,tail:s,epochsPerSample:i}=this.initializeSimplicialSetEmbedding();return this.optimizationState.head=e,this.optimizationState.tail=s,this.optimizationState.epochsPerSample=i,this.initializeOptimization(),this.prepareForOptimizationLoop(),this.isInitialized=!0,this.getNEpochs()}makeSearchFns(){const{initFromTree:t,initFromRandom:e}=o.vF(this.distanceFn);this.initFromTree=t,this.initFromRandom=e,this.search=o.n_(this.distanceFn)}makeSearchGraph(t){const e=this.knnIndices,s=this.knnDistances,i=[t.length,t.length],o=new n.A7([],[],[],i);for(let t=0;t<e.length;t++){const i=e[t],n=s[t];for(let e=0;e<i.length;e++){const s=i[e],r=n[e];r>0&&o.set(t,s,r)}}const r=n.p4(o);return n.gW(o,r)}transform(t){const e=this.X;if(void 0===e||0===e.length)throw new Error("No data has been fit.");let s=Math.floor(this.nNeighbors*this.transformQueueSize);s=Math.min(e.length,s);const r=o.gK(this.rpForest,e,t,s,this.initFromRandom,this.initFromTree,this.random),l=this.search(e,this.searchGraph,r,t);let{indices:h,weights:c}=i.oi(l);h=h.map((t=>t.slice(0,this.nNeighbors))),c=c.map((t=>t.slice(0,this.nNeighbors)));const u=Math.max(0,this.localConnectivity-1),{sigmas:m,rhos:d}=this.smoothKNNDistance(c,this.nNeighbors,u),{rows:g,cols:p,vals:f}=this.computeMembershipStrengths(h,c,m,d),y=[t.length,e.length];let b=new n.A7(g,p,f,y);const w=n.Fv(b,"l1"),C=n.Hp(w),v=t.length,S=function(t,e,s){const i=a.ll(t.length).map((t=>a.ll(s[0].length)));for(let n=0;n<t.length;n++)for(let o=0;o<t[0].length;o++)for(let r=0;r<s[0].length;r++){const a=t[n][o];i[n][r]+=e[n][o]*s[a][r]}return i}(a.HU(C.indices,v,this.nNeighbors),a.HU(C.values,v,this.nNeighbors),this.embedding),T=this.nEpochs?this.nEpochs/3:b.nRows<=1e4?100:30,M=b.getValues().reduce(((t,e)=>e>t?e:t),0);b=b.map((t=>t<M/T?0:t)),b=n.RH(b);const A=this.makeEpochsPerSample(b.getValues(),T),E=b.getRows(),x=b.getCols();return this.assignOptimizationStateParameters({headEmbedding:S,tailEmbedding:this.embedding,head:E,tail:x,currentEpoch:0,nEpochs:T,nVertices:b.getDims()[1],epochsPerSample:A}),this.prepareForOptimizationLoop(),this.optimizeLayout()}processGraphForSupervisedProjection(){const{Y:t,X:e}=this;if(t){if(t.length!==e.length)throw new Error("Length of X and y must be equal");if("categorical"===this.targetMetric){const e=this.targetWeight<1?1/(1-this.targetWeight)*2.5:1e12;this.graph=this.categoricalSimplicialSetIntersection(this.graph,t,e)}}}step(){const{currentEpoch:t}=this.optimizationState;return t<this.getNEpochs()&&this.optimizeLayoutStep(t),this.optimizationState.currentEpoch}getEmbedding(){return this.embedding}nearestNeighbors(t){const{distanceFn:e,nNeighbors:s}=this,i=o.WX(e,this.random),n=5+Math.floor(.5==(a=t.length**.5/20)?0:Math.round(a));var a;const l=Math.max(5,Math.floor(Math.round((t=>Math.log(t)/Math.log(2))(t.length))));this.rpForest=r.Zv(t,s,n,this.random);const h=r.HO(this.rpForest),{indices:c,weights:u}=i(t,h,s,l);return{knnIndices:c,knnDistances:u}}fuzzySimplicialSet(t,e,s=1){const{knnIndices:i=[],knnDistances:o=[],localConnectivity:r}=this,{sigmas:a,rhos:l}=this.smoothKNNDistance(o,e,r),{rows:h,cols:c,vals:u}=this.computeMembershipStrengths(i,o,a,l),m=[t.length,t.length],d=new n.A7(h,c,u,m),g=n.p4(d),p=n.NT(d,g),f=n.$X(n.IH(d,g),p),y=n.cf(f,s),b=n.cf(p,1-s);return n.IH(y,b)}categoricalSimplicialSetIntersection(t,e,s,i=1){let o=function(t,e,s=1,i=5){return t.map(((t,n,o)=>-1===e[n]||-1===e[o]?t*Math.exp(-s):e[n]!==e[o]?t*Math.exp(-i):t))}(t,e,i,s);return o=n.RH(o),function(t){t=n.Fv(t,"max");const e=n.p4(t),s=n.NT(e,t);return t=n.IH(t,n.$X(e,s)),n.RH(t)}(o)}smoothKNNDistance(t,e,s=1,i=64,n=1){const o=Math.log(e)/Math.log(2)*n,r=a.ll(t.length),l=a.ll(t.length);for(let e=0;e<t.length;e++){let n=0,u=1/0,m=1;const d=t[e],g=d.filter((t=>t>0));if(g.length>=s){let t=Math.floor(s),i=s-t;t>0?(r[e]=g[t-1],i>h&&(r[e]+=i*(g[t]-g[t-1]))):r[e]=i*g[0]}else g.length>0&&(r[e]=a.Fp(g));for(let s=0;s<i;s++){let s=0;for(let i=1;i<t[e].length;i++){const n=t[e][i]-r[e];s+=n>0?Math.exp(-n/m):1}if(Math.abs(s-o)<h)break;s>o?(u=m,m=(n+u)/2):(n=m,u===1/0?m*=2:m=(n+u)/2)}if(l[e]=m,r[e]>0){const t=a.J6(d);l[e]<c*t&&(l[e]=c*t)}else{const s=a.J6(t.map(a.J6));l[e]<c*s&&(l[e]=c*s)}}return{sigmas:l,rhos:r}}computeMembershipStrengths(t,e,s,i){const n=t.length,o=t[0].length,r=a.ll(n*o),l=a.ll(n*o),h=a.ll(n*o);for(let a=0;a<n;a++)for(let n=0;n<o;n++){let c=0;-1!==t[a][n]&&(c=t[a][n]===a?0:e[a][n]-i[a]<=0?1:Math.exp(-(e[a][n]-i[a])/s[a]),r[a*o+n]=a,l[a*o+n]=t[a][n],h[a*o+n]=c)}return{rows:r,cols:l,vals:h}}initializeSimplicialSetEmbedding(){const t=this.getNEpochs(),{nComponents:e}=this,s=this.graph.getValues();let i=0;for(let t=0;t<s.length;t++){const e=s[t];i<s[t]&&(i=e)}const n=this.graph.map((e=>e<i/t?0:e));this.embedding=a.ll(n.nRows).map((()=>a.ll(e).map((()=>20*a.mH(this.random)-10))));const o=[],r=[],l=[],h=n.getAll();for(let t=0;t<h.length;t++){const e=h[t];e.value&&(o.push(e.value),l.push(e.row),r.push(e.col))}return{head:r,tail:l,epochsPerSample:this.makeEpochsPerSample(o,t)}}makeEpochsPerSample(t,e){const s=a.VI(t.length,-1),i=a.Fp(t),n=t.map((t=>t/i*e));return n.forEach(((t,i)=>{t>0&&(s[i]=e/n[i])})),s}assignOptimizationStateParameters(t){Object.assign(this.optimizationState,t)}prepareForOptimizationLoop(){const{repulsionStrength:t,learningRate:e,negativeSampleRate:s}=this,{epochsPerSample:i,headEmbedding:n,tailEmbedding:o}=this.optimizationState,r=n[0].length,a=n.length===o.length,l=i.map((t=>t/s)),h=[...l],c=[...i];this.assignOptimizationStateParameters({epochOfNextSample:c,epochOfNextNegativeSample:h,epochsPerNegativeSample:l,moveOther:a,initialAlpha:e,alpha:e,gamma:t,dim:r})}initializeOptimization(){const t=this.embedding,e=this.embedding,{head:s,tail:i,epochsPerSample:n}=this.optimizationState,o=this.getNEpochs(),r=this.graph.nCols,{a:h,b:c}=function(t,e){const s=a.GE(0,3*t,300).map((t=>t<e?1:t)),i=a.ll(s.length).map(((i,n)=>s[n]>=e?Math.exp(-(s[n]-e)/t):i)),n={x:s,y:i},{parameterValues:o}=(0,l.Z)(n,(([t,e])=>s=>1/(1+t*s**(2*e))),{damping:1.5,initialValues:[.5,.5],gradientDifference:.1,maxIterations:100,errorTolerance:.01}),[r,h]=o;return{a:r,b:h}}(this.spread,this.minDist);this.assignOptimizationStateParameters({headEmbedding:t,tailEmbedding:e,head:s,tail:i,epochsPerSample:n,a:h,b:c,nEpochs:o,nVertices:r})}optimizeLayoutStep(t){const{optimizationState:e}=this,{head:s,tail:i,headEmbedding:n,tailEmbedding:o,epochsPerSample:r,epochOfNextSample:l,epochOfNextNegativeSample:h,epochsPerNegativeSample:c,moveOther:u,initialAlpha:m,alpha:d,gamma:f,a:y,b,dim:w,nEpochs:C,nVertices:v}=e;for(let e=0;e<r.length;e++){if(l[e]>t)continue;const m=s[e],C=i[e],S=n[m],T=o[C],M=p(S,T);let A=0;M>0&&(A=-2*y*b*Math.pow(M,b-1),A/=y*Math.pow(M,b)+1);for(let t=0;t<w;t++){const e=g(A*(S[t]-T[t]),4);S[t]+=e*d,u&&(T[t]+=-e*d)}l[e]+=r[e];const E=Math.floor((t-h[e])/c[e]);for(let t=0;t<E;t++){const t=a.AH(v,this.random),e=o[t],s=p(S,e);let i=0;if(s>0)i=2*f*b,i/=(.001+s)*(y*Math.pow(s,b)+1);else if(m===t)continue;for(let t=0;t<w;t++){let s=4;i>0&&(s=g(i*(S[t]-e[t]),4)),S[t]+=s*d}}h[e]+=E*c[e]}return e.alpha=m*(1-t/C),e.currentEpoch+=1,n}optimizeLayoutAsync(t=(()=>!0)){return new Promise(((e,s)=>{const i=async()=>{try{const{nEpochs:s,currentEpoch:n}=this.optimizationState;this.embedding=this.optimizeLayoutStep(n);const o=this.optimizationState.currentEpoch,r=!1===t(o),a=o===s;if(r||a)return e(a);setTimeout((()=>i()),0)}catch(t){s(t)}};setTimeout((()=>i()),0)}))}optimizeLayout(t=(()=>!0)){let e=!1,s=[];for(;!e;){const{nEpochs:i,currentEpoch:n}=this.optimizationState;s=this.optimizeLayoutStep(n);const o=this.optimizationState.currentEpoch,r=!1===t(o);e=o===i||r}return s}getNEpochs(){const t=this.graph;if(this.nEpochs>0)return this.nEpochs;if(!t)return 200;const e=t.nRows;return e<=2500?500:e<=5e3?400:e<=7500?300:200}}function m(t,e){return Math.abs(t-e)}class d{constructor(){this.currentEpoch=0,this.headEmbedding=[],this.tailEmbedding=[],this.head=[],this.tail=[],this.epochsPerSample=[],this.epochOfNextSample=[],this.epochOfNextNegativeSample=[],this.epochsPerNegativeSample=[],this.moveOther=!0,this.initialAlpha=1,this.alpha=1,this.gamma=1,this.a=1.5769434603113077,this.b=.8950608779109733,this.dim=2,this.nEpochs=500,this.nVertices=0}}function g(t,e){return t>e?e:t<-e?-e:t}function p(t,e){let s=0;for(let i=0;i<t.length;i++)s+=Math.pow(t[i]-e[i],2);return s}},9533:(t,e,s)=>{"use strict";function i(t,e){return Math.floor(e()*t)}function n(t){return t()}function o(t){const e=[];for(let s=0;s<t;s++)e.push(void 0);return e}function r(t){return o(t).map(((t,e)=>e))}function a(t,e){return o(t).map((()=>e))}function l(t){return a(t,0)}function h(t,e,s){return o(s).map(((i,n)=>t+n*((e-t)/(s-1))))}function c(t){return function(t){return t.reduce(((t,e)=>t+e))}(t)/t.length}function u(t){let e=0;for(let s=0;s<t.length;s++)e=t[s]>e?t[s]:e;return e}function m(t,e,s){const n=l(t);for(let o=0;o<t;o++){let t=!0;for(;t;){const r=i(e,s);let a=!1;for(let t=0;t<o;t++)if(r===n[t]){a=!0;break}a||(t=!1),n[o]=r}}return n}function d(t,e,s){const i=[];let n=0,o=0;if(t.length!==e*s)throw new Error("Array dimensions must match input length.");for(let r=0;r<e;r++){const e=[];for(let i=0;i<s;i++)e.push(t[o]),o+=1;i.push(e),n+=1}return i}s.d(e,{AH:()=>i,Fp:()=>u,GE:()=>h,HU:()=>d,J6:()=>c,M6:()=>m,VI:()=>a,cS:()=>o,ll:()=>l,mH:()=>n,w6:()=>r})},9657:(t,e,s)=>{"use strict";s.d(e,{Z:()=>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 s=t,n=i._createBuffer(s);if(e)for(let t=0;t<n.length;t++)n[t]=-1;this._data=n,this._length=s}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,s,i){if(t<e||t>s)throw new Error(`Argument ${i} (${t}) out of range (${e}, ${s})`)}copy(t,e,s){for(let i=0;i<s;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 s=new i(t._length);s._length=t._length,s._data=i._createBuffer(s._length),s._version=0;const n=t.lengthInInts;for(let i=0;i<n;i++)s._data[i]=t._data[i]&e._data[i];return s}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 s=0;s<e._length;s++)t[s]&&(e._data[Math.floor(s/32)]|=1<<(s%32&31));return e}static fromSeq(t,e){const s=new i(t);for(let i=0;i<t;++i)s.setBit(i,e(i));return s._version=0,s}static fromString(t){return i.fromSeq(t.length,(e=>"1"==t.charAt(e)))}static fromUint32Array(t,e){const s=new i(t);return s._data=e,s}static fromBytes(t){const e=t.length,s=new i(8*e);s._data=new Uint32Array(Math.floor((e+3)/4)),s._length=8*e;let n=0,o=0;for(;e-o>=4;)s._data[n++]=255&t[o]|(255&t[o+1])<<8|(255&t[o+2])<<16|(255&t[o+3])<<24,o+=4;return e-o==3&&(s._data[n]=(255&t[o+2])<<16),e-o==2&&(s._data[n]|=(255&t[o+1])<<8),e-o==1&&(s._data[n]|=255&t[o]),s._version=0,s}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 s=t?-1:0,i=this.lengthInInts;for(let t=0;t<i;t++)this._data[t]=s;this.incrementVersion(e)}setIndexes(t,e=!0,s=!0,i=!0){s&&this.setAll(!e,!1);for(const s of t)this.setFast(s,e);this.incrementVersion(i)}everyIndex(t,e=!0){for(const s of t)if(this.getBit(s)!=e)return!1;return!0}anyIndex(t,e=!0){for(const s of t)if(this.getBit(s)==e)return!0;return!1}setWhere(t,e=!0,s=!0,i=!0,n=!0){if(s&&n&&this.setAll(!e,!1),n)for(let s=0;s<this._length;s++)t(s)&&this.setFast(s,e);else for(let s=0;s<this._length;s++)this.setFast(s,t(s)?e:!e);this.incrementVersion(i)}getRange(t,e){this.assureInRange(t,0,this._length-1,"from"),this.assureInRange(e,0,this._length,"to");const s=[];for(let i=t;i<e;++i)s.push(this.getBit(i));return i.fromValues(s)}getRangeAsList(t,e){this.assureInRange(t,0,this._length-1,"from"),this.assureInRange(e,0,this._length,"to");const s=[];for(let i=t;i<e;++i)s.push(this.getBit(i));return s}setRange(t,e,s,i=!0){this.assureInRange(t,0,this._length-1,"from"),this.assureInRange(e,0,this._length-1,"to");const n=Math.min(t,e),o=Math.max(t,e);if(s)for(let t=n;t<=o;t++)this.setTrue(t);else for(let t=n;t<=o;t++)this.setFalse(t);return this.incrementVersion(i),this}setRandom(t,e,s=!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 s=0;s<t;){const t=Math.floor(Math.random()*this._length);this.getBit(t)!=e&&(this.setFast(t,e),s++)}this.incrementVersion(s)}and(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");for(let e=0,s=this.lengthInInts;e<s;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 s=this.lengthInInts;for(let e=0;e<s;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,s=this.lengthInInts;e<s;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,s=this.lengthInInts;e<s;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,s=this.lengthInInts;e<s;e++)this._data[e]^=t._data[e];return this.incrementVersion(e),this}insertAt(t,e,s=!1){if(this.assureInRange(t,0,this._length,"pos"),0==e)return;const i=this._length;this.setLength(this._length+e);for(let s=i-1;s>=t;s--)this.setBit(s+e,this.getBit(s));for(let i=t;i<t+e;i++)this.setBit(i,s)}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 s=t;s<this._length-e;s++)this.setBit(s,this.getBit(s+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 s=0;for(let i=-1;-1!=(i=t.findNext(i,!e));)this.setFast(s++,this.getBit(i));this._length=s,this._version++}return this}getBit(t){return 0!=(this._data[Math.floor(t/32)]&1<<(31&t))}setBit(t,e,s=!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 s=this._data[e];const n=31&this._length;for(0!=n&&(s&=~(4294967295<<n));0!=s;s>>>=8)this._selectedCount+=i._onBitCount[255&s];this._selectedCountVersion=this._version}return t?this._selectedCount:this._length-this._selectedCount}countWhere(t){let e=0;if(this.trueCount()==this._length)for(let s=0;s<this._length;s++)e+=t(s)?1:0;else for(let s=-1;-1!=(s=this.findNext(s,!0));)e+=t(s)?1:0;return e}andWithCountBits(t,e){if(0==this._length)return 0;let s=0;const n=this.lengthInInts;let o=0;for(;o<n-1;o++)for(let e=this._data[o]&t._data[o];0!=e;e>>>=8)s+=i._onBitCount[255&e];let r=this._data[o]&t._data[o];const a=31&this._length;for(0!=a&&(r&=~(4294967295<<a));0!=r;r>>>=8)s+=i._onBitCount[255&r];return e?s:this._length-s}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 s=31&(t=t<0?0:t+1);const n=this.lengthInInts;for(let o=Math.floor(t/32);o<n;o++){let n=e?this._data[o]:~this._data[o];if(0!=s)n&=4294967295<<s&4294967295,s=0;else if(!e&&-4294967296==n)continue;for(let e=0;0!=n;e+=8,n>>>=8){const s=i._firstOnBit[255&n];if(s>=0)return(t=s+32*o+e)>=this._length?-1:t}}return-1}findPrev(t,e=!0){if(0==t)return-1;this.assureInRange(t,-1,this._length,"index");let s=1+(t=t<0?this._length-1:t-1)&31;for(let n=Math.floor(t/32);n>=0;n--){let t=e?this._data[n]:~this._data[n];0!=s&&(t&=~(4294967295<<s),s=0);for(let e=24;0!=t;e-=8,t<<=8){const s=i._lastOnBit[t>>>24];if(s>=0)return s+32*n+e}}return-1}}i._onBitCount=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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])},4588:(t,e,s)=>{"use strict";function i(t){return Math.random()*t}function n(t){return Math.floor(i(t))}s.d(e,{I:()=>n,t:()=>i})},8518:(t,e,s)=>{"use strict";s.d(e,{L:()=>n});var i=s(4588);function n(t,e,s){function n(t,e){let s=null,i=null;for(const n of t){const t=e(n);(null==i||t>i)&&(s=n,i=t)}return s}const o=[(0,i.I)(t-1)],r=new Set;for(let e=0;e<t;++e)o.includes(e)||r.add(e);for(;o.length<e;){const t=n(r.values(),(t=>Math.min.apply(Math,o.map((function(e,i){return s(t,e)})))));null!=t&&(o.push(t),r.delete(t))}return o}},1061:(t,e,s)=>{"use strict";s.d(e,{gw:()=>o}),s(4469),s(976);var i,n=function(t,e,s,i){return new(s||(s=Promise))((function(n,o){function r(t){try{l(i.next(t))}catch(t){o(t)}}function a(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?n(t.value):(e=t.value,e instanceof s?e:new s((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};function o(t){return n(this,void 0,void 0,(function*(){yield new Promise((e=>setTimeout(e,t)))}))}!function(t){t.notNull=function(t,e){if(null==t)throw new Error(`${null==e?"Value":e} not defined`)}}(i||(i={}))},3659:(t,e,s)=>{"use strict";s.d(e,{OW:()=>i});class i extends Float32Array{}},850:(t,e,s)=>{"use strict";s.d(e,{$G:()=>a,Fv:()=>u,MA:()=>l,On:()=>r,dP:()=>c,hu:()=>o,kO:()=>h});var i=s(3659),n=s(4588);function o(t=!1,e="Assertion error."){if(!t)throw new Error(e)}function r(t,e,s=1){const n=t.length;o(n==e.length,"Vector lengths do not match.");const r=new i.OW(n);for(let i=0;i<t.length;++i)r[i]=t[i]+s*e[i];return r}function a(t){let e=0;for(let s=0;s<t.length;s++)e+=t[s]*t[s];return Math.sqrt(e)}function l(t,e){if(t.length!=e.length)throw new Error("The dimensionality of the vectors must match");let s=0;for(let i=0;i<t.length;i++)s+=t[i]*e[i];return s}function h(t,e,s=1){const o=function(t,e,s=0){return new Array(t).fill(s).map((()=>new i.OW(e).fill(s)))}(t,e);for(let i=0;i<t;++i)for(let t=0;t<e;++t)o[i][t]=(0,n.t)(s);return o}function c(t,e){const s=function(t){let e=0;for(let s=0;s<t.length;++s)e+=t[s];return e}(function(t){const e=t.length,s=new i.OW(e);for(let e=0;e<t.length;++e)s[e]=t[e]*t[e];return s}(r(t,e,-1)));return Math.sqrt(s)}function u(t){let e=0,s=0;for(let s=0;s<t.length;++s)e+=t[s];e/=t.length;for(let i=0;i<t.length;++i)s+=(t[i]-e)*(t[i]-e);s=Math.sqrt(s/t.length);for(let i=0;i<t.length;++i)t[i]=(t[i]-e)/s;return t}},7659:(t,e,s)=>{"use strict";e.Z=void 0;var i=s(6215);Object.defineProperty(e,"Z",{enumerable:!0,get:function(){return i.TSNE}})},6215:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.TSNE=void 0,e.TSNE=class{constructor(t){this.returnV=!1,this.vValue=0,this.iter=0,t=t||{},this.perplexity=this.getopt(t,"perplexity",30),this.dim=this.getopt(t,"dim",2),this.epsilon=this.getopt(t,"epsilon",10)}assert(t,e){if(!t)throw e||"Assertion failed"}getopt(t,e,s){return t.hasOwnProperty(e)?t[e]:s}gaussRandom(){if(this.returnV)return this.returnV=!1,this.vValue;const t=2*Math.random()-1,e=2*Math.random()-1,s=t*t+e*e;if(0===s||s>1)return this.gaussRandom();const i=Math.sqrt(-2*Math.log(s)/s);return this.vValue=e*i,this.returnV=!0,t*i}randn(t,e){return t+this.gaussRandom()*e}zeros(t){if(void 0===t||isNaN(t))return[];if("undefined"==typeof ArrayBuffer){const e=new Array(t);for(let s=0;s<t;s++)e[s]=0;return e}return new Float64Array(t)}randn2d(t,e,s){const i=void 0!==s,n=[];for(let o=0;o<t;o++){const t=[];for(let n=0;n<e;n++)i?t.push(s):t.push(this.randn(0,1e-4));n.push(t)}return n}L2(t,e){const s=t.length;let i=0;for(let n=0;n<s;n++){const s=t[n],o=e[n];i+=(s-o)*(s-o)}return i}xtod(t){const e=t.length,s=this.zeros(e*e);for(let i=0;i<e;i++)for(let n=i+1;n<e;n++){const o=this.L2(t[i],t[n]);s[i*e+n]=o,s[n*e+i]=o}return s}d2p(t,e,s){const i=Math.sqrt(t.length),n=Math.floor(i);this.assert(n===i,"D should have square number of elements.");const o=Math.log(e),r=this.zeros(n*n),a=this.zeros(n);for(let e=0;e<n;e++){let i=-1/0,l=1/0,h=1,c=!1;const u=50;let m=0;for(;!c;){let r=0;for(let s=0;s<n;s++){let i=Math.exp(-t[e*n+s]*h);e===s&&(i=0),a[s]=i,r+=i}let d=0;for(let t=0;t<n;t++){let e;e=0===r?0:a[t]/r,a[t]=e,e>1e-7&&(d-=e*Math.log(e))}d>o?(i=h,l===1/0?h*=2:h=(h+l)/2):(l=h,i===-1/0?h/=2:h=(h+i)/2),m++,Math.abs(d-o)<s&&(c=!0),m>=u&&(c=!0)}for(let t=0;t<n;t++)r[e*n+t]=a[t]}const l=this.zeros(n*n),h=2*n;for(let t=0;t<n;t++)for(let e=0;e<n;e++)l[t*n+e]=Math.max((r[t*n+e]+r[e*n+t])/h,1e-100);return l}sign(t){return t>0?1:t<0?-1:0}initDataRaw(t){const e=t.length,s=t[0].length;this.assert(e>0," X is empty? You must have some data!"),this.assert(s>0," X[0] is empty? Where is the data?");const i=this.xtod(t);this.P=this.d2p(i,this.perplexity,1e-4),this.N=e,this.initSolution()}initDataDist(t){const e=t.length;this.assert(e>0," X is empty? You must have some data!");const s=this.zeros(e*e);for(let i=0;i<e;i++)for(let n=i+1;n<e;n++){const o=t[i][n];s[i*e+n]=o,s[n*e+i]=o}this.P=this.d2p(s,this.perplexity,1e-4),this.N=e,this.initSolution()}initSolution(){this.Y=this.randn2d(this.N,this.dim),this.gains=this.randn2d(this.N,this.dim,1),this.ystep=this.randn2d(this.N,this.dim,0),this.iter=0}getSolution(){return this.Y}step(){this.iter+=1;const t=this.N,e=this.costGrad(this.Y),s=e.cost,i=e.grad,n=this.zeros(this.dim);for(let e=0;e<t;e++)for(let t=0;t<this.dim;t++){const s=i[e][t],o=this.ystep[e][t],r=this.gains[e][t];let a=this.sign(s)===this.sign(o)?.8*r:r+.2;a<.01&&(a=.01),this.gains[e][t]=a;const l=(this.iter<250?.5:.8)*o-this.epsilon*a*i[e][t];this.ystep[e][t]=l,this.Y[e][t]+=l,n[t]+=this.Y[e][t]}for(let e=0;e<t;e++)for(let s=0;s<this.dim;s++)this.Y[e][s]-=n[s]/t;return s}debugGrad(){const t=this.N,e=this.costGrad(this.Y),s=(e.cost,e.grad),i=1e-5;for(let e=0;e<t;e++)for(let t=0;t<this.dim;t++){const n=this.Y[e][t];this.Y[e][t]=n+i;const o=this.costGrad(this.Y);this.Y[e][t]=n-i;const r=this.costGrad(this.Y),a=s[e][t],l=(o.cost-r.cost)/(2*i);console.log(e+","+t+": gradcheck analytic: "+a+" vs. numerical: "+l),this.Y[e][t]=n}}costGrad(t){const e=this.N,s=this.dim,i=this.P,n=this.iter<100?4:1,o=this.zeros(e*e);let r=0;for(let i=0;i<e;i++)for(let n=i+1;n<e;n++){let a=0;for(let e=0;e<s;e++){const s=t[i][e]-t[n][e];a+=s*s}const l=1/(1+a);o[i*e+n]=l,o[n*e+i]=l,r+=2*l}const a=e*e,l=this.zeros(a);for(let t=0;t<a;t++)l[t]=Math.max(o[t]/r,1e-100);let h=0;const c=[];for(let r=0;r<e;r++){const a=new Array(s);for(let t=0;t<s;t++)a[t]=0;for(let c=0;c<e;c++){h+=-i[r*e+c]*Math.log(l[r*e+c]);const u=4*(n*i[r*e+c]-l[r*e+c])*o[r*e+c];for(let e=0;e<s;e++)a[e]+=u*(t[r][e]-t[c][e])}c.push(a)}return{cost:h,grad:c}}}},5362:(t,e,s)=>{"use strict";s.d(e,{Z:()=>a});var i=s(7537),n=s.n(i),o=s(3645),r=s.n(o)()(n());r.push([t.id,".macromolecule-cell-comp-analysis-host{\n max-height: 250px;\n overflow-y: scroll;\n}\n\n.macromolecule-cell-comp-analysis-bar{\n height: inherit;\n display: block;\n margin-top: 1.5px;\n margin-bottom: 1.5px;\n margin-right: 3px;\n}\n\n.macromolecule-cell-comp-analysis-value{\n display: flex;\n}","",{version:3,sources:["webpack://./css/composition-analysis.css"],names:[],mappings:"AAAA;IACI,iBAAiB;IACjB,kBAAkB;AACtB;;AAEA;IACI,eAAe;IACf,cAAc;IACd,iBAAiB;IACjB,oBAAoB;IACpB,iBAAiB;AACrB;;AAEA;IACI,aAAa;AACjB",sourcesContent:[".macromolecule-cell-comp-analysis-host{\n max-height: 250px;\n overflow-y: scroll;\n}\n\n.macromolecule-cell-comp-analysis-bar{\n height: inherit;\n display: block;\n margin-top: 1.5px;\n margin-bottom: 1.5px;\n margin-right: 3px;\n}\n\n.macromolecule-cell-comp-analysis-value{\n display: flex;\n}"],sourceRoot:""}]);const a=r},9564:(t,e,s)=>{"use strict";s.d(e,{Z:()=>a});var i=s(7537),n=s.n(i),o=s(3645),r=s.n(o)()(n());r.push([t.id,".kalign-version {\n margin-bottom: 0;\n text-align: end;\n font-size: 12px;\n opacity: 0.8;\n}\nbutton.msa-params-button.ui-btn {\n justify-content: end;\n}","",{version:3,sources:["webpack://./css/msa.css"],names:[],mappings:"AAAA;IACI,gBAAgB;IAChB,eAAe;IACf,eAAe;IACf,YAAY;AAChB;AACA;IACI,oBAAoB;AACxB",sourcesContent:[".kalign-version {\n margin-bottom: 0;\n text-align: end;\n font-size: 12px;\n opacity: 0.8;\n}\nbutton.msa-params-button.ui-btn {\n justify-content: end;\n}"],sourceRoot:""}]);const a=r},9414:(t,e,s)=>{"use strict";s.d(e,{Z:()=>a});var i=s(7537),n=s.n(i),o=s(3645),r=s.n(o)()(n());r.push([t.id,".scatter_plot_link {\n position: absolute!important;\n right: 10px;\n}\n\n.cliffs_grid {\n top: 10px;\n}\n\n.show_only_cliffs {\n top: 30px;\n}\n\n.ml-dim-reduction-settings-input i.grok-icon.grok-font-icon-settings {\n font-size: 18px;\n position: absolute;\n height: 28px;\n}\n","",{version:3,sources:["webpack://./node_modules/@datagrok-libraries/ml/css/styles.css"],names:[],mappings:"AAAA;IACI,4BAA4B;IAC5B,WAAW;AACf;;AAEA;IACI,SAAS;AACb;;AAEA;IACI,SAAS;AACb;;AAEA;IACI,eAAe;IACf,kBAAkB;IAClB,YAAY;AAChB",sourcesContent:[".scatter_plot_link {\n position: absolute!important;\n right: 10px;\n}\n\n.cliffs_grid {\n top: 10px;\n}\n\n.show_only_cliffs {\n top: 30px;\n}\n\n.ml-dim-reduction-settings-input i.grok-icon.grok-font-icon-settings {\n font-size: 18px;\n position: absolute;\n height: 28px;\n}\n"],sourceRoot:""}]);const a=r},3645:t=>{"use strict";t.exports=function(t){var e=[];return e.toString=function(){return this.map((function(e){var s="",i=void 0!==e[5];return e[4]&&(s+="@supports (".concat(e[4],") {")),e[2]&&(s+="@media ".concat(e[2]," {")),i&&(s+="@layer".concat(e[5].length>0?" ".concat(e[5]):""," {")),s+=t(e),i&&(s+="}"),e[2]&&(s+="}"),e[4]&&(s+="}"),s})).join("")},e.i=function(t,s,i,n,o){"string"==typeof t&&(t=[[null,t,void 0]]);var r={};if(i)for(var a=0;a<this.length;a++){var l=this[a][0];null!=l&&(r[l]=!0)}for(var h=0;h<t.length;h++){var c=[].concat(t[h]);i&&r[c[0]]||(void 0!==o&&(void 0===c[5]||(c[1]="@layer".concat(c[5].length>0?" ".concat(c[5]):""," {").concat(c[1],"}")),c[5]=o),s&&(c[2]?(c[1]="@media ".concat(c[2]," {").concat(c[1],"}"),c[2]=s):c[2]=s),n&&(c[4]?(c[1]="@supports (".concat(c[4],") {").concat(c[1],"}"),c[4]=n):c[4]="".concat(n)),e.push(c))}},e}},7537:t=>{"use strict";t.exports=function(t){var e=t[1],s=t[3];if(!s)return e;if("function"==typeof btoa){var i=btoa(unescape(encodeURIComponent(JSON.stringify(s)))),n="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(i),o="/*# ".concat(n," */");return[e].concat([o]).join("\n")}return[e].join("\n")}},9133:function(t,e,s){var i;!function(e,n){var o={};!function(t){"use strict";t.__esModule=!0,t.digestLength=32,t.blockSize=64;var e=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function s(t,s,i,n,o){for(var r,a,l,h,c,u,m,d,g,p,f,y,b;o>=64;){for(r=s[0],a=s[1],l=s[2],h=s[3],c=s[4],u=s[5],m=s[6],d=s[7],p=0;p<16;p++)f=n+4*p,t[p]=(255&i[f])<<24|(255&i[f+1])<<16|(255&i[f+2])<<8|255&i[f+3];for(p=16;p<64;p++)y=((g=t[p-2])>>>17|g<<15)^(g>>>19|g<<13)^g>>>10,b=((g=t[p-15])>>>7|g<<25)^(g>>>18|g<<14)^g>>>3,t[p]=(y+t[p-7]|0)+(b+t[p-16]|0);for(p=0;p<64;p++)y=(((c>>>6|c<<26)^(c>>>11|c<<21)^(c>>>25|c<<7))+(c&u^~c&m)|0)+(d+(e[p]+t[p]|0)|0)|0,b=((r>>>2|r<<30)^(r>>>13|r<<19)^(r>>>22|r<<10))+(r&a^r&l^a&l)|0,d=m,m=u,u=c,c=h+y|0,h=l,l=a,a=r,r=y+b|0;s[0]+=r,s[1]+=a,s[2]+=l,s[3]+=h,s[4]+=c,s[5]+=u,s[6]+=m,s[7]+=d,n+=64,o-=64}return n}var i=function(){function e(){this.digestLength=t.digestLength,this.blockSize=t.blockSize,this.state=new Int32Array(8),this.temp=new Int32Array(64),this.buffer=new Uint8Array(128),this.bufferLength=0,this.bytesHashed=0,this.finished=!1,this.reset()}return e.prototype.reset=function(){return this.state[0]=1779033703,this.state[1]=3144134277,this.state[2]=1013904242,this.state[3]=2773480762,this.state[4]=1359893119,this.state[5]=2600822924,this.state[6]=528734635,this.state[7]=1541459225,this.bufferLength=0,this.bytesHashed=0,this.finished=!1,this},e.prototype.clean=function(){for(var t=0;t<this.buffer.length;t++)this.buffer[t]=0;for(t=0;t<this.temp.length;t++)this.temp[t]=0;this.reset()},e.prototype.update=function(t,e){if(void 0===e&&(e=t.length),this.finished)throw new Error("SHA256: can't update because hash was finished.");var i=0;if(this.bytesHashed+=e,this.bufferLength>0){for(;this.bufferLength<64&&e>0;)this.buffer[this.bufferLength++]=t[i++],e--;64===this.bufferLength&&(s(this.temp,this.state,this.buffer,0,64),this.bufferLength=0)}for(e>=64&&(i=s(this.temp,this.state,t,i,e),e%=64);e>0;)this.buffer[this.bufferLength++]=t[i++],e--;return this},e.prototype.finish=function(t){if(!this.finished){var e=this.bytesHashed,i=this.bufferLength,n=e/536870912|0,o=e<<3,r=e%64<56?64:128;this.buffer[i]=128;for(var a=i+1;a<r-8;a++)this.buffer[a]=0;this.buffer[r-8]=n>>>24&255,this.buffer[r-7]=n>>>16&255,this.buffer[r-6]=n>>>8&255,this.buffer[r-5]=n>>>0&255,this.buffer[r-4]=o>>>24&255,this.buffer[r-3]=o>>>16&255,this.buffer[r-2]=o>>>8&255,this.buffer[r-1]=o>>>0&255,s(this.temp,this.state,this.buffer,0,r),this.finished=!0}for(a=0;a<8;a++)t[4*a+0]=this.state[a]>>>24&255,t[4*a+1]=this.state[a]>>>16&255,t[4*a+2]=this.state[a]>>>8&255,t[4*a+3]=this.state[a]>>>0&255;return this},e.prototype.digest=function(){var t=new Uint8Array(this.digestLength);return this.finish(t),t},e.prototype._saveState=function(t){for(var e=0;e<this.state.length;e++)t[e]=this.state[e]},e.prototype._restoreState=function(t,e){for(var s=0;s<this.state.length;s++)this.state[s]=t[s];this.bytesHashed=e,this.finished=!1,this.bufferLength=0},e}();t.Hash=i;var n=function(){function t(t){this.inner=new i,this.outer=new i,this.blockSize=this.inner.blockSize,this.digestLength=this.inner.digestLength;var e=new Uint8Array(this.blockSize);if(t.length>this.blockSize)(new i).update(t).finish(e).clean();else for(var s=0;s<t.length;s++)e[s]=t[s];for(s=0;s<e.length;s++)e[s]^=54;for(this.inner.update(e),s=0;s<e.length;s++)e[s]^=106;for(this.outer.update(e),this.istate=new Uint32Array(8),this.ostate=new Uint32Array(8),this.inner._saveState(this.istate),this.outer._saveState(this.ostate),s=0;s<e.length;s++)e[s]=0}return t.prototype.reset=function(){return this.inner._restoreState(this.istate,this.inner.blockSize),this.outer._restoreState(this.ostate,this.outer.blockSize),this},t.prototype.clean=function(){for(var t=0;t<this.istate.length;t++)this.ostate[t]=this.istate[t]=0;this.inner.clean(),this.outer.clean()},t.prototype.update=function(t){return this.inner.update(t),this},t.prototype.finish=function(t){return this.outer.finished?this.outer.finish(t):(this.inner.finish(t),this.outer.update(t,this.digestLength).finish(t)),this},t.prototype.digest=function(){var t=new Uint8Array(this.digestLength);return this.finish(t),t},t}();function o(t){var e=(new i).update(t),s=e.digest();return e.clean(),s}function r(t,e){var s=new n(t).update(e),i=s.digest();return s.clean(),i}function a(t,e,s,i){var n=i[0];if(0===n)throw new Error("hkdf: cannot expand more");e.reset(),n>1&&e.update(t),s&&e.update(s),e.update(i),e.finish(t),i[0]++}t.HMAC=n,t.hash=o,t.default=o,t.hmac=r;var l=new Uint8Array(t.digestLength);t.hkdf=function(t,e,s,i){void 0===e&&(e=l),void 0===i&&(i=32);for(var o=new Uint8Array([1]),h=r(e,t),c=new n(h),u=new Uint8Array(c.digestLength),m=u.length,d=new Uint8Array(i),g=0;g<i;g++)m===u.length&&(a(u,c,s,o),m=0),d[g]=u[m++];return c.clean(),u.fill(0),o.fill(0),d},t.pbkdf2=function(t,e,s,i){for(var o=new n(t),r=o.digestLength,a=new Uint8Array(4),l=new Uint8Array(r),h=new Uint8Array(r),c=new Uint8Array(i),u=0;u*r<i;u++){var m=u+1;a[0]=m>>>24&255,a[1]=m>>>16&255,a[2]=m>>>8&255,a[3]=m>>>0&255,o.reset(),o.update(e),o.update(a),o.finish(h);for(var d=0;d<r;d++)l[d]=h[d];for(d=2;d<=s;d++){o.reset(),o.update(h).finish(h);for(var g=0;g<r;g++)l[g]^=h[g]}for(d=0;d<r&&u*r+d<i;d++)c[u*r+d]=l[d]}for(u=0;u<r;u++)l[u]=h[u]=0;for(u=0;u<4;u++)a[u]=0;return o.clean(),c}}(o);var r=o.default;for(var a in o)r[a]=o[a];"object"==typeof t.exports?t.exports=r:void 0===(i=function(){return r}.call(o,s,o,t))||(t.exports=i)}()},1811:(t,e,s)=>{"use strict";s.d(e,{T:()=>n});const i=new Uint32Array(65536),n=(t,e)=>{if(t.length<e.length){const s=e;e=t,t=s}return 0===e.length?t.length:t.length<=32?((t,e)=>{const s=t.length,n=e.length,o=1<<s-1;let r=-1,a=0,l=s,h=s;for(;h--;)i[t.charCodeAt(h)]|=1<<h;for(h=0;h<n;h++){let t=i[e.charCodeAt(h)];const s=t|a;t|=(t&r)+r^r,a|=~(t|r),r&=t,a&o&&l++,r&o&&l--,a=a<<1|1,r=r<<1|~(s|a),a&=s}for(h=s;h--;)i[t.charCodeAt(h)]=0;return l})(t,e):((t,e)=>{const s=e.length,n=t.length,o=[],r=[],a=Math.ceil(s/32),l=Math.ceil(n/32);for(let t=0;t<a;t++)r[t]=-1,o[t]=0;let h=0;for(;h<l-1;h++){let a=0,l=-1;const c=32*h,u=Math.min(32,n)+c;for(let e=c;e<u;e++)i[t.charCodeAt(e)]|=1<<e;for(let t=0;t<s;t++){const s=i[e.charCodeAt(t)],n=r[t/32|0]>>>t&1,h=o[t/32|0]>>>t&1,c=s|a,u=((s|h)&l)+l^l|s|h;let m=a|~(u|l),d=l&u;m>>>31^n&&(r[t/32|0]^=1<<t),d>>>31^h&&(o[t/32|0]^=1<<t),m=m<<1|n,d=d<<1|h,l=d|~(c|m),a=m&c}for(let e=c;e<u;e++)i[t.charCodeAt(e)]=0}let c=0,u=-1;const m=32*h,d=Math.min(32,n-m)+m;for(let e=m;e<d;e++)i[t.charCodeAt(e)]|=1<<e;let g=n;for(let t=0;t<s;t++){const s=i[e.charCodeAt(t)],a=r[t/32|0]>>>t&1,l=o[t/32|0]>>>t&1,h=s|c,m=((s|l)&u)+u^u|s|l;let d=c|~(m|u),p=u&m;g+=d>>>n-1&1,g-=p>>>n-1&1,d>>>31^a&&(r[t/32|0]^=1<<t),p>>>31^l&&(o[t/32|0]^=1<<t),d=d<<1|a,p=p<<1|l,u=p|~(h|d),c=d&h}for(let e=m;e<d;e++)i[t.charCodeAt(e)]=0;return g})(t,e)}},7531:(t,e,s)=>{"use strict";s.d(e,{Z:()=>n});const i=Object.prototype.toString;function n(t){return i.call(t).endsWith("Array]")}},3979:(t,e)=>{"use strict";e.H$=void 0,e.H$=function(t,e,s){var i=function(t,e,s){if(0===t.length||0===e.length)return 0;if(s&&!s.caseSensitive&&(t=t.toUpperCase(),e=e.toUpperCase()),t===e)return 1;for(var i=0,n=t.length,o=e.length,r=Math.floor(Math.max(n,o)/2)-1,a=new Array(n),l=new Array(o),h=0;h<n;h++)for(var c=Math.max(0,h-r);c<=Math.min(o,h+r+1);c++)if(!a[h]&&!l[c]&&t[h]===e[c]){++i,a[h]=l[c]=!0;break}if(0===i)return 0;var u=0,m=0;for(h=0;h<n;h++)if(a[h]){for(;!l[m];)m++;t.charAt(h)!==e.charAt(m++)&&u++}return(i/n+i/o+(i-(u/=2))/i)/3}(t,e,s),n=0;if(i>.7){for(var o=Math.min(t.length,e.length),r=0;t[r]===e[r]&&r<4&&r<o;)++n,r++;i+=.1*n*(1-i)}return i}},5111:(t,e,s)=>{"use strict";s.d(e,{Z:()=>n});var i=s(6044);function n(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!(0,i.N)(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");var s=e.fromIndex,n=void 0===s?0:s,o=e.toIndex,r=void 0===o?t.length:o;if(n<0||n>=t.length||!Number.isInteger(n))throw new Error("fromIndex must be a positive integer smaller than length");if(r<=n||r>t.length||!Number.isInteger(r))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var a=t[n],l=n+1;l<r;l++)t[l]>a&&(a=t[l]);return a}},6044:(t,e,s)=>{"use strict";s.d(e,{N:()=>n});const i=Object.prototype.toString;function n(t){return i.call(t).endsWith("Array]")}},1772:(t,e,s)=>{"use strict";s.d(e,{Z:()=>n});var i=s(994);function n(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!(0,i.N)(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");var s=e.fromIndex,n=void 0===s?0:s,o=e.toIndex,r=void 0===o?t.length:o;if(n<0||n>=t.length||!Number.isInteger(n))throw new Error("fromIndex must be a positive integer smaller than length");if(r<=n||r>t.length||!Number.isInteger(r))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var a=t[n],l=n+1;l<r;l++)t[l]<a&&(a=t[l]);return a}},994:(t,e,s)=>{"use strict";s.d(e,{N:()=>n});const i=Object.prototype.toString;function n(t){return i.call(t).endsWith("Array]")}},5408:(t,e,s)=>{"use strict";s.d(e,{Z:()=>r});var i=s(6241),n=s(5111),o=s(1772);function r(t){var e,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!(0,i.N)(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");if(void 0!==s.output){if(!(0,i.N)(s.output))throw new TypeError("output option must be an array if specified");e=s.output}else e=new Array(t.length);var r=(0,o.Z)(t),a=(0,n.Z)(t);if(r===a)throw new RangeError("minimum and maximum input values are equal. Cannot rescale a constant array");var l=s.min,h=void 0===l?s.autoMinMax?r:0:l,c=s.max,u=void 0===c?s.autoMinMax?a:1:c;if(h>=u)throw new RangeError("min option must be smaller than max option");for(var m=(u-h)/(a-r),d=0;d<t.length;d++)e[d]=(t[d]-r)*m+h;return e}},6241:(t,e,s)=>{"use strict";s.d(e,{N:()=>n});const i=Object.prototype.toString;function n(t){return i.call(t).endsWith("Array]")}},1353:(t,e,s)=>{"use strict";function i(t,e,s){let i=0;const n=s(e);for(let e=0;e<t.x.length;e++)i+=Math.abs(t.y[e]-n(t.x[e]));return i}s.d(e,{Z:()=>i})},3107:(t,e,s)=>{"use strict";s.d(e,{Z:()=>r});var i=s(7531),n=s(1353),o=s(8188);function r(t,e,s={}){let{maxIterations:r=100,gradientDifference:a=.1,damping:l=0,errorTolerance:h=.01,minValues:c,maxValues:u,initialValues:m}=s;if(l<=0)throw new Error("The damping option must be a positive number");if(!t.x||!t.y)throw new Error("The data parameter must have x and y elements");if(!(0,i.Z)(t.x)||t.x.length<2||!(0,i.Z)(t.y)||t.y.length<2)throw new Error("The data parameter elements must be an array with more than 2 points");if(t.x.length!==t.y.length)throw new Error("The data parameter elements must have the same size");let d=m||new Array(e.length).fill(1),g=d.length;if(u=u||new Array(g).fill(Number.MAX_SAFE_INTEGER),c=c||new Array(g).fill(Number.MIN_SAFE_INTEGER),u.length!==c.length)throw new Error("minValues and maxValues must be the same size");if(!(0,i.Z)(d))throw new Error("initialValues must be an array");let p,f=(0,n.Z)(t,d,e),y=f<=h;for(p=0;p<r&&!y;p++){d=(0,o.Z)(t,d,l,a,e);for(let t=0;t<g;t++)d[t]=Math.min(Math.max(c[t],d[t]),u[t]);if(f=(0,n.Z)(t,d,e),isNaN(f))break;y=f<=h}return{parameterValues:d,parameterError:f,iterations:p}}},8188:(t,e,s)=>{"use strict";s.d(e,{Z:()=>o});var i=s(1174),n=s(8345);function o(t,e,s,o,r){let a=s*o*o,l=i.Z.eye(e.length,e.length,a);const h=r(e);let c=new Float64Array(t.x.length);for(let e=0;e<t.x.length;e++)c[e]=h(t.x[e]);let u=function(t,e,s,n,o){const r=s.length,a=t.x.length;let l=new Array(r);for(let i=0;i<r;i++){l[i]=new Array(a);let r=s.slice();r[i]+=n;let h=o(r);for(let s=0;s<a;s++)l[i][s]=e[s]-h(t.x[s])}return new i.Z(l)}(t,c,e,o,r),m=function(t,e){const s=t.x.length;let n=new Array(s);for(let i=0;i<s;i++)n[i]=[t.y[i]-e[i]];return new i.Z(n)}(t,c),d=(0,n.S)(l.add(u.mmul(u.transpose())));return(e=(e=new i.Z([e])).sub(d.mmul(u).mmul(m).mul(o).transpose())).to1DArray()}},5776:(t,e,s)=>{"use strict";s.d(e,{N:()=>n});const i=Object.prototype.toString;function n(t){return i.call(t).endsWith("Array]")}},2313:(t,e,s)=>{"use strict";s.d(e,{Z:()=>o});var i=s(1174),n=s(8353);class o{constructor(t){let e,s,i,o,r,a,l,h,c,u=(t=n.Z.checkMatrix(t)).clone(),m=u.rows,d=u.columns,g=new Float64Array(m),p=1;for(e=0;e<m;e++)g[e]=e;for(h=new Float64Array(m),s=0;s<d;s++){for(e=0;e<m;e++)h[e]=u.get(e,s);for(e=0;e<m;e++){for(c=Math.min(e,s),r=0,i=0;i<c;i++)r+=u.get(e,i)*h[i];h[e]-=r,u.set(e,s,h[e])}for(o=s,e=s+1;e<m;e++)Math.abs(h[e])>Math.abs(h[o])&&(o=e);if(o!==s){for(i=0;i<d;i++)a=u.get(o,i),u.set(o,i,u.get(s,i)),u.set(s,i,a);l=g[o],g[o]=g[s],g[s]=l,p=-p}if(s<m&&0!==u.get(s,s))for(e=s+1;e<m;e++)u.set(e,s,u.get(e,s)/u.get(s,s))}this.LU=u,this.pivotVector=g,this.pivotSign=p}isSingular(){let t=this.LU,e=t.columns;for(let s=0;s<e;s++)if(0===t.get(s,s))return!0;return!1}solve(t){t=i.Z.checkMatrix(t);let e=this.LU;if(e.rows!==t.rows)throw new Error("Invalid matrix dimensions");if(this.isSingular())throw new Error("LU matrix is singular");let s,n,o,r=t.columns,a=t.subMatrixRow(this.pivotVector,0,r-1),l=e.columns;for(o=0;o<l;o++)for(s=o+1;s<l;s++)for(n=0;n<r;n++)a.set(s,n,a.get(s,n)-a.get(o,n)*e.get(s,o));for(o=l-1;o>=0;o--){for(n=0;n<r;n++)a.set(o,n,a.get(o,n)/e.get(o,o));for(s=0;s<o;s++)for(n=0;n<r;n++)a.set(s,n,a.get(s,n)-a.get(o,n)*e.get(s,o))}return a}get determinant(){let t=this.LU;if(!t.isSquare())throw new Error("Matrix must be square");let e=this.pivotSign,s=t.columns;for(let i=0;i<s;i++)e*=t.get(i,i);return e}get lowerTriangularMatrix(){let t=this.LU,e=t.rows,s=t.columns,n=new i.Z(e,s);for(let i=0;i<e;i++)for(let e=0;e<s;e++)i>e?n.set(i,e,t.get(i,e)):i===e?n.set(i,e,1):n.set(i,e,0);return n}get upperTriangularMatrix(){let t=this.LU,e=t.rows,s=t.columns,n=new i.Z(e,s);for(let i=0;i<e;i++)for(let e=0;e<s;e++)i<=e?n.set(i,e,t.get(i,e)):n.set(i,e,0);return n}get pivotPermutationVector(){return Array.from(this.pivotVector)}}},7072:(t,e,s)=>{"use strict";s.d(e,{Z:()=>r});var i=s(1174),n=s(8353),o=s(6310);class r{constructor(t){let e,s,i,r,a=(t=n.Z.checkMatrix(t)).clone(),l=t.rows,h=t.columns,c=new Float64Array(h);for(i=0;i<h;i++){let t=0;for(e=i;e<l;e++)t=(0,o.G)(t,a.get(e,i));if(0!==t){for(a.get(i,i)<0&&(t=-t),e=i;e<l;e++)a.set(e,i,a.get(e,i)/t);for(a.set(i,i,a.get(i,i)+1),s=i+1;s<h;s++){for(r=0,e=i;e<l;e++)r+=a.get(e,i)*a.get(e,s);for(r=-r/a.get(i,i),e=i;e<l;e++)a.set(e,s,a.get(e,s)+r*a.get(e,i))}}c[i]=-t}this.QR=a,this.Rdiag=c}solve(t){t=i.Z.checkMatrix(t);let e=this.QR,s=e.rows;if(t.rows!==s)throw new Error("Matrix row dimensions must agree");if(!this.isFullRank())throw new Error("Matrix is rank deficient");let n,o,r,a,l=t.columns,h=t.clone(),c=e.columns;for(r=0;r<c;r++)for(o=0;o<l;o++){for(a=0,n=r;n<s;n++)a+=e.get(n,r)*h.get(n,o);for(a=-a/e.get(r,r),n=r;n<s;n++)h.set(n,o,h.get(n,o)+a*e.get(n,r))}for(r=c-1;r>=0;r--){for(o=0;o<l;o++)h.set(r,o,h.get(r,o)/this.Rdiag[r]);for(n=0;n<r;n++)for(o=0;o<l;o++)h.set(n,o,h.get(n,o)-h.get(r,o)*e.get(n,r))}return h.subMatrix(0,c-1,0,l-1)}isFullRank(){let t=this.QR.columns;for(let e=0;e<t;e++)if(0===this.Rdiag[e])return!1;return!0}get upperTriangularMatrix(){let t,e,s=this.QR,n=s.columns,o=new i.Z(n,n);for(t=0;t<n;t++)for(e=0;e<n;e++)t<e?o.set(t,e,s.get(t,e)):t===e?o.set(t,e,this.Rdiag[t]):o.set(t,e,0);return o}get orthogonalMatrix(){let t,e,s,n,o=this.QR,r=o.rows,a=o.columns,l=new i.Z(r,a);for(s=a-1;s>=0;s--){for(t=0;t<r;t++)l.set(t,s,0);for(l.set(s,s,1),e=s;e<a;e++)if(0!==o.get(s,s)){for(n=0,t=s;t<r;t++)n+=o.get(t,s)*l.get(t,e);for(n=-n/o.get(s,s),t=s;t<r;t++)l.set(t,e,l.get(t,e)+n*o.get(t,s))}}return l}}},6943:(t,e,s)=>{"use strict";s.d(e,{Z:()=>r});var i=s(1174),n=s(8353),o=s(6310);class r{constructor(t,e={}){if((t=n.Z.checkMatrix(t)).isEmpty())throw new Error("Matrix must be non-empty");let s=t.rows,r=t.columns;const{computeLeftSingularVectors:a=!0,computeRightSingularVectors:l=!0,autoTranspose:h=!1}=e;let c,u=Boolean(a),m=Boolean(l),d=!1;if(s<r)if(h){c=t.transpose(),s=c.rows,r=c.columns,d=!0;let e=u;u=m,m=e}else c=t.clone(),console.warn("Computing SVD on a matrix with more columns than rows. Consider enabling autoTranspose");else c=t.clone();let g=Math.min(s,r),p=Math.min(s+1,r),f=new Float64Array(p),y=new i.Z(s,g),b=new i.Z(r,r),w=new Float64Array(r),C=new Float64Array(s),v=new Float64Array(p);for(let t=0;t<p;t++)v[t]=t;let S=Math.min(s-1,r),T=Math.max(0,Math.min(r-2,s)),M=Math.max(S,T);for(let t=0;t<M;t++){if(t<S){f[t]=0;for(let e=t;e<s;e++)f[t]=(0,o.G)(f[t],c.get(e,t));if(0!==f[t]){c.get(t,t)<0&&(f[t]=-f[t]);for(let e=t;e<s;e++)c.set(e,t,c.get(e,t)/f[t]);c.set(t,t,c.get(t,t)+1)}f[t]=-f[t]}for(let e=t+1;e<r;e++){if(t<S&&0!==f[t]){let i=0;for(let n=t;n<s;n++)i+=c.get(n,t)*c.get(n,e);i=-i/c.get(t,t);for(let n=t;n<s;n++)c.set(n,e,c.get(n,e)+i*c.get(n,t))}w[e]=c.get(t,e)}if(u&&t<S)for(let e=t;e<s;e++)y.set(e,t,c.get(e,t));if(t<T){w[t]=0;for(let e=t+1;e<r;e++)w[t]=(0,o.G)(w[t],w[e]);if(0!==w[t]){w[t+1]<0&&(w[t]=0-w[t]);for(let e=t+1;e<r;e++)w[e]/=w[t];w[t+1]+=1}if(w[t]=-w[t],t+1<s&&0!==w[t]){for(let e=t+1;e<s;e++)C[e]=0;for(let e=t+1;e<s;e++)for(let s=t+1;s<r;s++)C[e]+=w[s]*c.get(e,s);for(let e=t+1;e<r;e++){let i=-w[e]/w[t+1];for(let n=t+1;n<s;n++)c.set(n,e,c.get(n,e)+i*C[n])}}if(m)for(let e=t+1;e<r;e++)b.set(e,t,w[e])}}let A=Math.min(r,s+1);if(S<r&&(f[S]=c.get(S,S)),s<A&&(f[A-1]=0),T+1<A&&(w[T]=c.get(T,A-1)),w[A-1]=0,u){for(let t=S;t<g;t++){for(let e=0;e<s;e++)y.set(e,t,0);y.set(t,t,1)}for(let t=S-1;t>=0;t--)if(0!==f[t]){for(let e=t+1;e<g;e++){let i=0;for(let n=t;n<s;n++)i+=y.get(n,t)*y.get(n,e);i=-i/y.get(t,t);for(let n=t;n<s;n++)y.set(n,e,y.get(n,e)+i*y.get(n,t))}for(let e=t;e<s;e++)y.set(e,t,-y.get(e,t));y.set(t,t,1+y.get(t,t));for(let e=0;e<t-1;e++)y.set(e,t,0)}else{for(let e=0;e<s;e++)y.set(e,t,0);y.set(t,t,1)}}if(m)for(let t=r-1;t>=0;t--){if(t<T&&0!==w[t])for(let e=t+1;e<r;e++){let s=0;for(let i=t+1;i<r;i++)s+=b.get(i,t)*b.get(i,e);s=-s/b.get(t+1,t);for(let i=t+1;i<r;i++)b.set(i,e,b.get(i,e)+s*b.get(i,t))}for(let e=0;e<r;e++)b.set(e,t,0);b.set(t,t,1)}let E=A-1,x=0,I=Number.EPSILON;for(;A>0;){let t,e;for(t=A-2;t>=-1&&-1!==t;t--){const e=Number.MIN_VALUE+I*Math.abs(f[t]+Math.abs(f[t+1]));if(Math.abs(w[t])<=e||Number.isNaN(w[t])){w[t]=0;break}}if(t===A-2)e=4;else{let s;for(s=A-1;s>=t&&s!==t;s--){let e=(s!==A?Math.abs(w[s]):0)+(s!==t+1?Math.abs(w[s-1]):0);if(Math.abs(f[s])<=I*e){f[s]=0;break}}s===t?e=3:s===A-1?e=1:(e=2,t=s)}switch(t++,e){case 1:{let e=w[A-2];w[A-2]=0;for(let s=A-2;s>=t;s--){let i=(0,o.G)(f[s],e),n=f[s]/i,a=e/i;if(f[s]=i,s!==t&&(e=-a*w[s-1],w[s-1]=n*w[s-1]),m)for(let t=0;t<r;t++)i=n*b.get(t,s)+a*b.get(t,A-1),b.set(t,A-1,-a*b.get(t,s)+n*b.get(t,A-1)),b.set(t,s,i)}break}case 2:{let e=w[t-1];w[t-1]=0;for(let i=t;i<A;i++){let n=(0,o.G)(f[i],e),r=f[i]/n,a=e/n;if(f[i]=n,e=-a*w[i],w[i]=r*w[i],u)for(let e=0;e<s;e++)n=r*y.get(e,i)+a*y.get(e,t-1),y.set(e,t-1,-a*y.get(e,i)+r*y.get(e,t-1)),y.set(e,i,n)}break}case 3:{const e=Math.max(Math.abs(f[A-1]),Math.abs(f[A-2]),Math.abs(w[A-2]),Math.abs(f[t]),Math.abs(w[t])),i=f[A-1]/e,n=f[A-2]/e,a=w[A-2]/e,l=f[t]/e,h=w[t]/e,c=((n+i)*(n-i)+a*a)/2,d=i*a*(i*a);let g=0;0===c&&0===d||(g=c<0?0-Math.sqrt(c*c+d):Math.sqrt(c*c+d),g=d/(c+g));let p=(l+i)*(l-i)+g,C=l*h;for(let e=t;e<A-1;e++){let i=(0,o.G)(p,C);0===i&&(i=Number.MIN_VALUE);let n=p/i,a=C/i;if(e!==t&&(w[e-1]=i),p=n*f[e]+a*w[e],w[e]=n*w[e]-a*f[e],C=a*f[e+1],f[e+1]=n*f[e+1],m)for(let t=0;t<r;t++)i=n*b.get(t,e)+a*b.get(t,e+1),b.set(t,e+1,-a*b.get(t,e)+n*b.get(t,e+1)),b.set(t,e,i);if(i=(0,o.G)(p,C),0===i&&(i=Number.MIN_VALUE),n=p/i,a=C/i,f[e]=i,p=n*w[e]+a*f[e+1],f[e+1]=-a*w[e]+n*f[e+1],C=a*w[e+1],w[e+1]=n*w[e+1],u&&e<s-1)for(let t=0;t<s;t++)i=n*y.get(t,e)+a*y.get(t,e+1),y.set(t,e+1,-a*y.get(t,e)+n*y.get(t,e+1)),y.set(t,e,i)}w[A-2]=p,x+=1;break}case 4:if(f[t]<=0&&(f[t]=f[t]<0?-f[t]:0,m))for(let e=0;e<=E;e++)b.set(e,t,-b.get(e,t));for(;t<E&&!(f[t]>=f[t+1]);){let e=f[t];if(f[t]=f[t+1],f[t+1]=e,m&&t<r-1)for(let s=0;s<r;s++)e=b.get(s,t+1),b.set(s,t+1,b.get(s,t)),b.set(s,t,e);if(u&&t<s-1)for(let i=0;i<s;i++)e=y.get(i,t+1),y.set(i,t+1,y.get(i,t)),y.set(i,t,e);t++}x=0,A--}}if(d){let t=b;b=y,y=t}this.m=s,this.n=r,this.s=f,this.U=y,this.V=b}solve(t){let e=t,s=this.threshold,n=this.s.length,o=i.Z.zeros(n,n);for(let t=0;t<n;t++)Math.abs(this.s[t])<=s?o.set(t,t,0):o.set(t,t,1/this.s[t]);let r=this.U,a=this.rightSingularVectors,l=a.mmul(o),h=a.rows,c=r.rows,u=i.Z.zeros(h,c);for(let t=0;t<h;t++)for(let e=0;e<c;e++){let s=0;for(let i=0;i<n;i++)s+=l.get(t,i)*r.get(e,i);u.set(t,e,s)}return u.mmul(e)}solveForDiagonal(t){return this.solve(i.Z.diag(t))}inverse(){let t=this.V,e=this.threshold,s=t.rows,n=t.columns,o=new i.Z(s,this.s.length);for(let i=0;i<s;i++)for(let s=0;s<n;s++)Math.abs(this.s[s])>e&&o.set(i,s,t.get(i,s)/this.s[s]);let r=this.U,a=r.rows,l=r.columns,h=new i.Z(s,a);for(let t=0;t<s;t++)for(let e=0;e<a;e++){let s=0;for(let i=0;i<l;i++)s+=o.get(t,i)*r.get(e,i);h.set(t,e,s)}return h}get condition(){return this.s[0]/this.s[Math.min(this.m,this.n)-1]}get norm2(){return this.s[0]}get rank(){let t=Math.max(this.m,this.n)*this.s[0]*Number.EPSILON,e=0,s=this.s;for(let i=0,n=s.length;i<n;i++)s[i]>t&&e++;return e}get diagonal(){return Array.from(this.s)}get threshold(){return Number.EPSILON/2*Math.max(this.m,this.n)*this.s[0]}get leftSingularVectors(){return this.U}get rightSingularVectors(){return this.V}get diagonalMatrix(){return i.Z.diag(this.s)}}},6310:(t,e,s)=>{"use strict";function i(t,e){let s=0;return Math.abs(t)>Math.abs(e)?(s=e/t,Math.abs(t)*Math.sqrt(1+s*s)):0!==e?(s=t/e,Math.abs(e)*Math.sqrt(1+s*s)):0}s.d(e,{G:()=>i})},8345:(t,e,s)=>{"use strict";s.d(e,{S:()=>l});var i=s(2313),n=s(7072),o=s(6943),r=s(1174),a=s(8353);function l(t,e=!1){return t=a.Z.checkMatrix(t),e?new o.Z(t).inverse():function(t,e,s=!1){return t=a.Z.checkMatrix(t),e=a.Z.checkMatrix(e),s?new o.Z(t).solve(e):t.isSquare()?new i.Z(t).solve(e):new n.Z(t).solve(e)}(t,r.Z.eye(t.rows))}},3559:(t,e,s)=>{"use strict";s.d(e,{M:()=>r,V:()=>o});const i=" ".repeat(2),n=" ".repeat(4);function o(){return r(this)}function r(t,e={}){const{maxRows:s=15,maxColumns:o=10,maxNumSize:r=8,padMinus:l="auto"}=e;return`${t.constructor.name} {\n${i}[\n${n}${function(t,e,s,i,o){const{rows:r,columns:l}=t,h=Math.min(r,e),c=Math.min(l,s),u=[];if("auto"===o){o=!1;t:for(let e=0;e<h;e++)for(let s=0;s<c;s++)if(t.get(e,s)<0){o=!0;break t}}for(let e=0;e<h;e++){let s=[];for(let n=0;n<c;n++)s.push(a(t.get(e,n),i,o));u.push(`${s.join(" ")}`)}return c!==l&&(u[u.length-1]+=` ... ${l-s} more columns`),h!==r&&u.push(`... ${r-e} more rows`),u.join(`\n${n}`)}(t,s,o,r,l)}\n${i}]\n${i}rows: ${t.rows}\n${i}columns: ${t.columns}\n}`}function a(t,e,s){return(t>=0&&s?` ${l(t,e-1)}`:l(t,e)).padEnd(e)}function l(t,e){let s=t.toString();if(s.length<=e)return s;let i=t.toFixed(e);if(i.length>e&&(i=t.toFixed(Math.max(0,e-(i.length-e)))),i.length<=e&&!i.startsWith("0.000")&&!i.startsWith("-0.000"))return i;let n=t.toExponential(e);return n.length>e&&(n=t.toExponential(Math.max(0,e-(n.length-e)))),n.slice(0)}},5401:(t,e,s)=>{"use strict";function i(t,e){t.prototype.add=function(t){return"number"==typeof t?this.addS(t):this.addM(t)},t.prototype.addS=function(t){for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)+t);return this},t.prototype.addM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)+t.get(e,s));return this},t.add=function(t,s){return new e(t).add(s)},t.prototype.sub=function(t){return"number"==typeof t?this.subS(t):this.subM(t)},t.prototype.subS=function(t){for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)-t);return this},t.prototype.subM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)-t.get(e,s));return this},t.sub=function(t,s){return new e(t).sub(s)},t.prototype.subtract=t.prototype.sub,t.prototype.subtractS=t.prototype.subS,t.prototype.subtractM=t.prototype.subM,t.subtract=t.sub,t.prototype.mul=function(t){return"number"==typeof t?this.mulS(t):this.mulM(t)},t.prototype.mulS=function(t){for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)*t);return this},t.prototype.mulM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)*t.get(e,s));return this},t.mul=function(t,s){return new e(t).mul(s)},t.prototype.multiply=t.prototype.mul,t.prototype.multiplyS=t.prototype.mulS,t.prototype.multiplyM=t.prototype.mulM,t.multiply=t.mul,t.prototype.div=function(t){return"number"==typeof t?this.divS(t):this.divM(t)},t.prototype.divS=function(t){for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)/t);return this},t.prototype.divM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)/t.get(e,s));return this},t.div=function(t,s){return new e(t).div(s)},t.prototype.divide=t.prototype.div,t.prototype.divideS=t.prototype.divS,t.prototype.divideM=t.prototype.divM,t.divide=t.div,t.prototype.mod=function(t){return"number"==typeof t?this.modS(t):this.modM(t)},t.prototype.modS=function(t){for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)%t);return this},t.prototype.modM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)%t.get(e,s));return this},t.mod=function(t,s){return new e(t).mod(s)},t.prototype.modulus=t.prototype.mod,t.prototype.modulusS=t.prototype.modS,t.prototype.modulusM=t.prototype.modM,t.modulus=t.mod,t.prototype.and=function(t){return"number"==typeof t?this.andS(t):this.andM(t)},t.prototype.andS=function(t){for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)&t);return this},t.prototype.andM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)&t.get(e,s));return this},t.and=function(t,s){return new e(t).and(s)},t.prototype.or=function(t){return"number"==typeof t?this.orS(t):this.orM(t)},t.prototype.orS=function(t){for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)|t);return this},t.prototype.orM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)|t.get(e,s));return this},t.or=function(t,s){return new e(t).or(s)},t.prototype.xor=function(t){return"number"==typeof t?this.xorS(t):this.xorM(t)},t.prototype.xorS=function(t){for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)^t);return this},t.prototype.xorM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)^t.get(e,s));return this},t.xor=function(t,s){return new e(t).xor(s)},t.prototype.leftShift=function(t){return"number"==typeof t?this.leftShiftS(t):this.leftShiftM(t)},t.prototype.leftShiftS=function(t){for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)<<t);return this},t.prototype.leftShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)<<t.get(e,s));return this},t.leftShift=function(t,s){return new e(t).leftShift(s)},t.prototype.signPropagatingRightShift=function(t){return"number"==typeof t?this.signPropagatingRightShiftS(t):this.signPropagatingRightShiftM(t)},t.prototype.signPropagatingRightShiftS=function(t){for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)>>t);return this},t.prototype.signPropagatingRightShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)>>t.get(e,s));return this},t.signPropagatingRightShift=function(t,s){return new e(t).signPropagatingRightShift(s)},t.prototype.rightShift=function(t){return"number"==typeof t?this.rightShiftS(t):this.rightShiftM(t)},t.prototype.rightShiftS=function(t){for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)>>>t);return this},t.prototype.rightShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)>>>t.get(e,s));return this},t.rightShift=function(t,s){return new e(t).rightShift(s)},t.prototype.zeroFillRightShift=t.prototype.rightShift,t.prototype.zeroFillRightShiftS=t.prototype.rightShiftS,t.prototype.zeroFillRightShiftM=t.prototype.rightShiftM,t.zeroFillRightShift=t.rightShift,t.prototype.not=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,~this.get(t,e));return this},t.not=function(t){return new e(t).not()},t.prototype.abs=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.abs(this.get(t,e)));return this},t.abs=function(t){return new e(t).abs()},t.prototype.acos=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.acos(this.get(t,e)));return this},t.acos=function(t){return new e(t).acos()},t.prototype.acosh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.acosh(this.get(t,e)));return this},t.acosh=function(t){return new e(t).acosh()},t.prototype.asin=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.asin(this.get(t,e)));return this},t.asin=function(t){return new e(t).asin()},t.prototype.asinh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.asinh(this.get(t,e)));return this},t.asinh=function(t){return new e(t).asinh()},t.prototype.atan=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.atan(this.get(t,e)));return this},t.atan=function(t){return new e(t).atan()},t.prototype.atanh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.atanh(this.get(t,e)));return this},t.atanh=function(t){return new e(t).atanh()},t.prototype.cbrt=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.cbrt(this.get(t,e)));return this},t.cbrt=function(t){return new e(t).cbrt()},t.prototype.ceil=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.ceil(this.get(t,e)));return this},t.ceil=function(t){return new e(t).ceil()},t.prototype.clz32=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.clz32(this.get(t,e)));return this},t.clz32=function(t){return new e(t).clz32()},t.prototype.cos=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.cos(this.get(t,e)));return this},t.cos=function(t){return new e(t).cos()},t.prototype.cosh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.cosh(this.get(t,e)));return this},t.cosh=function(t){return new e(t).cosh()},t.prototype.exp=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.exp(this.get(t,e)));return this},t.exp=function(t){return new e(t).exp()},t.prototype.expm1=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.expm1(this.get(t,e)));return this},t.expm1=function(t){return new e(t).expm1()},t.prototype.floor=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.floor(this.get(t,e)));return this},t.floor=function(t){return new e(t).floor()},t.prototype.fround=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.fround(this.get(t,e)));return this},t.fround=function(t){return new e(t).fround()},t.prototype.log=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log(this.get(t,e)));return this},t.log=function(t){return new e(t).log()},t.prototype.log1p=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log1p(this.get(t,e)));return this},t.log1p=function(t){return new e(t).log1p()},t.prototype.log10=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log10(this.get(t,e)));return this},t.log10=function(t){return new e(t).log10()},t.prototype.log2=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log2(this.get(t,e)));return this},t.log2=function(t){return new e(t).log2()},t.prototype.round=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.round(this.get(t,e)));return this},t.round=function(t){return new e(t).round()},t.prototype.sign=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sign(this.get(t,e)));return this},t.sign=function(t){return new e(t).sign()},t.prototype.sin=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sin(this.get(t,e)));return this},t.sin=function(t){return new e(t).sin()},t.prototype.sinh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sinh(this.get(t,e)));return this},t.sinh=function(t){return new e(t).sinh()},t.prototype.sqrt=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sqrt(this.get(t,e)));return this},t.sqrt=function(t){return new e(t).sqrt()},t.prototype.tan=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.tan(this.get(t,e)));return this},t.tan=function(t){return new e(t).tan()},t.prototype.tanh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.tanh(this.get(t,e)));return this},t.tanh=function(t){return new e(t).tanh()},t.prototype.trunc=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.trunc(this.get(t,e)));return this},t.trunc=function(t){return new e(t).trunc()},t.pow=function(t,s){return new e(t).pow(s)},t.prototype.pow=function(t){return"number"==typeof t?this.powS(t):this.powM(t)},t.prototype.powS=function(t){for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,Math.pow(this.get(e,s),t));return this},t.prototype.powM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,Math.pow(this.get(e,s),t.get(e,s)));return this}}s.d(e,{z:()=>i})},1174:(t,e,s)=>{"use strict";s.d(e,{X:()=>h,Z:()=>u});var i=s(5776),n=s(5408),o=s(3559),r=s(5401),a=s(9515),l=s(3018);class h{static from1DArray(t,e,s){if(t*e!==s.length)throw new RangeError("data length does not match given dimensions");let i=new u(t,e);for(let n=0;n<t;n++)for(let t=0;t<e;t++)i.set(n,t,s[n*e+t]);return i}static rowVector(t){let e=new u(1,t.length);for(let s=0;s<t.length;s++)e.set(0,s,t[s]);return e}static columnVector(t){let e=new u(t.length,1);for(let s=0;s<t.length;s++)e.set(s,0,t[s]);return e}static zeros(t,e){return new u(t,e)}static ones(t,e){return new u(t,e).fill(1)}static rand(t,e,s={}){if("object"!=typeof s)throw new TypeError("options must be an object");const{random:i=Math.random}=s;let n=new u(t,e);for(let s=0;s<t;s++)for(let t=0;t<e;t++)n.set(s,t,i());return n}static randInt(t,e,s={}){if("object"!=typeof s)throw new TypeError("options must be an object");const{min:i=0,max:n=1e3,random:o=Math.random}=s;if(!Number.isInteger(i))throw new TypeError("min must be an integer");if(!Number.isInteger(n))throw new TypeError("max must be an integer");if(i>=n)throw new RangeError("min must be smaller than max");let r=n-i,a=new u(t,e);for(let s=0;s<t;s++)for(let t=0;t<e;t++){let e=i+Math.round(o()*r);a.set(s,t,e)}return a}static eye(t,e,s){void 0===e&&(e=t),void 0===s&&(s=1);let i=Math.min(t,e),n=this.zeros(t,e);for(let t=0;t<i;t++)n.set(t,t,s);return n}static diag(t,e,s){let i=t.length;void 0===e&&(e=i),void 0===s&&(s=e);let n=Math.min(i,e,s),o=this.zeros(e,s);for(let e=0;e<n;e++)o.set(e,e,t[e]);return o}static min(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let s=t.rows,i=t.columns,n=new u(s,i);for(let o=0;o<s;o++)for(let s=0;s<i;s++)n.set(o,s,Math.min(t.get(o,s),e.get(o,s)));return n}static max(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let s=t.rows,i=t.columns,n=new this(s,i);for(let o=0;o<s;o++)for(let s=0;s<i;s++)n.set(o,s,Math.max(t.get(o,s),e.get(o,s)));return n}static checkMatrix(t){return h.isMatrix(t)?t:new u(t)}static isMatrix(t){return null!=t&&"Matrix"===t.klass}get size(){return this.rows*this.columns}apply(t){if("function"!=typeof t)throw new TypeError("callback must be a function");for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)t.call(this,e,s);return this}to1DArray(){let t=[];for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)t.push(this.get(e,s));return t}to2DArray(){let t=[];for(let e=0;e<this.rows;e++){t.push([]);for(let s=0;s<this.columns;s++)t[e].push(this.get(e,s))}return t}toJSON(){return this.to2DArray()}isRowVector(){return 1===this.rows}isColumnVector(){return 1===this.columns}isVector(){return 1===this.rows||1===this.columns}isSquare(){return this.rows===this.columns}isEmpty(){return 0===this.rows||0===this.columns}isSymmetric(){if(this.isSquare()){for(let t=0;t<this.rows;t++)for(let e=0;e<=t;e++)if(this.get(t,e)!==this.get(e,t))return!1;return!0}return!1}isEchelonForm(){let t=0,e=0,s=-1,i=!0,n=!1;for(;t<this.rows&&i;){for(e=0,n=!1;e<this.columns&&!1===n;)0===this.get(t,e)?e++:1===this.get(t,e)&&e>s?(n=!0,s=e):(i=!1,n=!0);t++}return i}isReducedEchelonForm(){let t=0,e=0,s=-1,i=!0,n=!1;for(;t<this.rows&&i;){for(e=0,n=!1;e<this.columns&&!1===n;)0===this.get(t,e)?e++:1===this.get(t,e)&&e>s?(n=!0,s=e):(i=!1,n=!0);for(let s=e+1;s<this.rows;s++)0!==this.get(t,s)&&(i=!1);t++}return i}echelonForm(){let t=this.clone(),e=0,s=0;for(;e<t.rows&&s<t.columns;){let i=e;for(let n=e;n<t.rows;n++)t.get(n,s)>t.get(i,s)&&(i=n);if(0===t.get(i,s))s++;else{t.swapRows(e,i);let n=t.get(e,s);for(let i=s;i<t.columns;i++)t.set(e,i,t.get(e,i)/n);for(let i=e+1;i<t.rows;i++){let n=t.get(i,s)/t.get(e,s);t.set(i,s,0);for(let o=s+1;o<t.columns;o++)t.set(i,o,t.get(i,o)-t.get(e,o)*n)}e++,s++}}return t}reducedEchelonForm(){let t=this.echelonForm(),e=t.columns,s=t.rows,i=s-1;for(;i>=0;)if(0===t.maxRow(i))i--;else{let n=0,o=!1;for(;n<s&&!1===o;)1===t.get(i,n)?o=!0:n++;for(let s=0;s<i;s++){let o=t.get(s,n);for(let r=n;r<e;r++){let e=t.get(s,r)-o*t.get(i,r);t.set(s,r,e)}}i--}return t}set(){throw new Error("set method is unimplemented")}get(){throw new Error("get method is unimplemented")}repeat(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{rows:e=1,columns:s=1}=t;if(!Number.isInteger(e)||e<=0)throw new TypeError("rows must be a positive integer");if(!Number.isInteger(s)||s<=0)throw new TypeError("columns must be a positive integer");let i=new u(this.rows*e,this.columns*s);for(let t=0;t<e;t++)for(let e=0;e<s;e++)i.setSubMatrix(this,this.rows*t,this.columns*e);return i}fill(t){for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,t);return this}neg(){return this.mulS(-1)}getRow(t){(0,l.zb)(this,t);let e=[];for(let s=0;s<this.columns;s++)e.push(this.get(t,s));return e}getRowVector(t){return u.rowVector(this.getRow(t))}setRow(t,e){(0,l.zb)(this,t),e=(0,l.on)(this,e);for(let s=0;s<this.columns;s++)this.set(t,s,e[s]);return this}swapRows(t,e){(0,l.zb)(this,t),(0,l.zb)(this,e);for(let s=0;s<this.columns;s++){let i=this.get(t,s);this.set(t,s,this.get(e,s)),this.set(e,s,i)}return this}getColumn(t){(0,l.bp)(this,t);let e=[];for(let s=0;s<this.rows;s++)e.push(this.get(s,t));return e}getColumnVector(t){return u.columnVector(this.getColumn(t))}setColumn(t,e){(0,l.bp)(this,t),e=(0,l.Um)(this,e);for(let s=0;s<this.rows;s++)this.set(s,t,e[s]);return this}swapColumns(t,e){(0,l.bp)(this,t),(0,l.bp)(this,e);for(let s=0;s<this.rows;s++){let i=this.get(s,t);this.set(s,t,this.get(s,e)),this.set(s,e,i)}return this}addRowVector(t){t=(0,l.on)(this,t);for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)+t[s]);return this}subRowVector(t){t=(0,l.on)(this,t);for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)-t[s]);return this}mulRowVector(t){t=(0,l.on)(this,t);for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)*t[s]);return this}divRowVector(t){t=(0,l.on)(this,t);for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)/t[s]);return this}addColumnVector(t){t=(0,l.Um)(this,t);for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)+t[e]);return this}subColumnVector(t){t=(0,l.Um)(this,t);for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)-t[e]);return this}mulColumnVector(t){t=(0,l.Um)(this,t);for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)*t[e]);return this}divColumnVector(t){t=(0,l.Um)(this,t);for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,this.get(e,s)/t[e]);return this}mulRow(t,e){(0,l.zb)(this,t);for(let s=0;s<this.columns;s++)this.set(t,s,this.get(t,s)*e);return this}mulColumn(t,e){(0,l.bp)(this,t);for(let s=0;s<this.rows;s++)this.set(s,t,this.get(s,t)*e);return this}max(t){if(this.isEmpty())return NaN;switch(t){case"row":{const t=new Array(this.rows).fill(Number.NEGATIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.get(e,s)>t[e]&&(t[e]=this.get(e,s));return t}case"column":{const t=new Array(this.columns).fill(Number.NEGATIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.get(e,s)>t[s]&&(t[s]=this.get(e,s));return t}case void 0:{let t=this.get(0,0);for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.get(e,s)>t&&(t=this.get(e,s));return t}default:throw new Error(`invalid option: ${t}`)}}maxIndex(){(0,l.cT)(this);let t=this.get(0,0),e=[0,0];for(let s=0;s<this.rows;s++)for(let i=0;i<this.columns;i++)this.get(s,i)>t&&(t=this.get(s,i),e[0]=s,e[1]=i);return e}min(t){if(this.isEmpty())return NaN;switch(t){case"row":{const t=new Array(this.rows).fill(Number.POSITIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.get(e,s)<t[e]&&(t[e]=this.get(e,s));return t}case"column":{const t=new Array(this.columns).fill(Number.POSITIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.get(e,s)<t[s]&&(t[s]=this.get(e,s));return t}case void 0:{let t=this.get(0,0);for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.get(e,s)<t&&(t=this.get(e,s));return t}default:throw new Error(`invalid option: ${t}`)}}minIndex(){(0,l.cT)(this);let t=this.get(0,0),e=[0,0];for(let s=0;s<this.rows;s++)for(let i=0;i<this.columns;i++)this.get(s,i)<t&&(t=this.get(s,i),e[0]=s,e[1]=i);return e}maxRow(t){if((0,l.zb)(this,t),this.isEmpty())return NaN;let e=this.get(t,0);for(let s=1;s<this.columns;s++)this.get(t,s)>e&&(e=this.get(t,s));return e}maxRowIndex(t){(0,l.zb)(this,t),(0,l.cT)(this);let e=this.get(t,0),s=[t,0];for(let i=1;i<this.columns;i++)this.get(t,i)>e&&(e=this.get(t,i),s[1]=i);return s}minRow(t){if((0,l.zb)(this,t),this.isEmpty())return NaN;let e=this.get(t,0);for(let s=1;s<this.columns;s++)this.get(t,s)<e&&(e=this.get(t,s));return e}minRowIndex(t){(0,l.zb)(this,t),(0,l.cT)(this);let e=this.get(t,0),s=[t,0];for(let i=1;i<this.columns;i++)this.get(t,i)<e&&(e=this.get(t,i),s[1]=i);return s}maxColumn(t){if((0,l.bp)(this,t),this.isEmpty())return NaN;let e=this.get(0,t);for(let s=1;s<this.rows;s++)this.get(s,t)>e&&(e=this.get(s,t));return e}maxColumnIndex(t){(0,l.bp)(this,t),(0,l.cT)(this);let e=this.get(0,t),s=[0,t];for(let i=1;i<this.rows;i++)this.get(i,t)>e&&(e=this.get(i,t),s[0]=i);return s}minColumn(t){if((0,l.bp)(this,t),this.isEmpty())return NaN;let e=this.get(0,t);for(let s=1;s<this.rows;s++)this.get(s,t)<e&&(e=this.get(s,t));return e}minColumnIndex(t){(0,l.bp)(this,t),(0,l.cT)(this);let e=this.get(0,t),s=[0,t];for(let i=1;i<this.rows;i++)this.get(i,t)<e&&(e=this.get(i,t),s[0]=i);return s}diag(){let t=Math.min(this.rows,this.columns),e=[];for(let s=0;s<t;s++)e.push(this.get(s,s));return e}norm(t="frobenius"){let e=0;if("max"===t)return this.max();if("frobenius"===t){for(let t=0;t<this.rows;t++)for(let s=0;s<this.columns;s++)e+=this.get(t,s)*this.get(t,s);return Math.sqrt(e)}throw new RangeError(`unknown norm type: ${t}`)}cumulativeSum(){let t=0;for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)t+=this.get(e,s),this.set(e,s,t);return this}dot(t){h.isMatrix(t)&&(t=t.to1DArray());let e=this.to1DArray();if(e.length!==t.length)throw new RangeError("vectors do not have the same size");let s=0;for(let i=0;i<e.length;i++)s+=e[i]*t[i];return s}mmul(t){t=u.checkMatrix(t);let e=this.rows,s=this.columns,i=t.columns,n=new u(e,i),o=new Float64Array(s);for(let r=0;r<i;r++){for(let e=0;e<s;e++)o[e]=t.get(e,r);for(let t=0;t<e;t++){let e=0;for(let i=0;i<s;i++)e+=this.get(t,i)*o[i];n.set(t,r,e)}}return n}strassen2x2(t){t=u.checkMatrix(t);let e=new u(2,2);const s=this.get(0,0),i=t.get(0,0),n=this.get(0,1),o=t.get(0,1),r=this.get(1,0),a=t.get(1,0),l=this.get(1,1),h=t.get(1,1),c=(s+l)*(i+h),m=(r+l)*i,d=s*(o-h),g=l*(a-i),p=(s+n)*h,f=c+g-p+(n-l)*(a+h),y=d+p,b=m+g,w=c-m+d+(r-s)*(i+o);return e.set(0,0,f),e.set(0,1,y),e.set(1,0,b),e.set(1,1,w),e}strassen3x3(t){t=u.checkMatrix(t);let e=new u(3,3);const s=this.get(0,0),i=this.get(0,1),n=this.get(0,2),o=this.get(1,0),r=this.get(1,1),a=this.get(1,2),l=this.get(2,0),h=this.get(2,1),c=this.get(2,2),m=t.get(0,0),d=t.get(0,1),g=t.get(0,2),p=t.get(1,0),f=t.get(1,1),y=t.get(1,2),b=t.get(2,0),w=t.get(2,1),C=t.get(2,2),v=(s-o)*(-d+f),S=(-s+o+r)*(m-d+f),T=(o+r)*(-m+d),M=s*m,A=(-s+l+h)*(m-g+y),E=(-s+l)*(g-y),x=(l+h)*(-m+g),I=(-n+h+c)*(f+b-w),N=(n-c)*(f-w),L=n*b,_=(h+c)*(-b+w),R=(-n+r+a)*(y+b-C),O=(n-a)*(y-C),k=(r+a)*(-b+C),P=M+L+i*p,G=(s+i+n-o-r-h-c)*f+S+T+M+I+L+_,F=M+A+x+(s+i+n-r-a-l-h)*y+L+R+k,H=v+r*(-m+d+p-f-y-b+C)+S+M+L+R+O,V=v+S+T+M+a*w,W=L+R+O+k+o*g,D=M+A+E+h*(-m+g+p-f-y-b+w)+I+N+L,B=I+N+L+_+l*d,U=M+A+E+x+c*C;return e.set(0,0,P),e.set(0,1,G),e.set(0,2,F),e.set(1,0,H),e.set(1,1,V),e.set(1,2,W),e.set(2,0,D),e.set(2,1,B),e.set(2,2,U),e}mmulStrassen(t){t=u.checkMatrix(t);let e=this.clone(),s=e.rows,i=e.columns,n=t.rows,o=t.columns;function r(t,e,s){let i=t.rows,n=t.columns;if(i===e&&n===s)return t;{let i=h.zeros(e,s);return i=i.setSubMatrix(t,0,0),i}}i!==n&&console.warn(`Multiplying ${s} x ${i} and ${n} x ${o} matrix: dimensions do not match.`);let a=Math.max(s,n),l=Math.max(i,o);return e=r(e,a,l),function t(e,s,i,n){if(i<=512||n<=512)return e.mmul(s);i%2==1&&n%2==1?(e=r(e,i+1,n+1),s=r(s,i+1,n+1)):i%2==1?(e=r(e,i+1,n),s=r(s,i+1,n)):n%2==1&&(e=r(e,i,n+1),s=r(s,i,n+1));let o=parseInt(e.rows/2,10),a=parseInt(e.columns/2,10),l=e.subMatrix(0,o-1,0,a-1),c=s.subMatrix(0,o-1,0,a-1),u=e.subMatrix(0,o-1,a,e.columns-1),m=s.subMatrix(0,o-1,a,s.columns-1),d=e.subMatrix(o,e.rows-1,0,a-1),g=s.subMatrix(o,s.rows-1,0,a-1),p=e.subMatrix(o,e.rows-1,a,e.columns-1),f=s.subMatrix(o,s.rows-1,a,s.columns-1),y=t(h.add(l,p),h.add(c,f),o,a),b=t(h.add(d,p),c,o,a),w=t(l,h.sub(m,f),o,a),C=t(p,h.sub(g,c),o,a),v=t(h.add(l,u),f,o,a),S=t(h.sub(d,l),h.add(c,m),o,a),T=t(h.sub(u,p),h.add(g,f),o,a),M=h.add(y,C);M.sub(v),M.add(T);let A=h.add(w,v),E=h.add(b,C),x=h.sub(y,b);x.add(w),x.add(S);let I=h.zeros(2*M.rows,2*M.columns);return I=I.setSubMatrix(M,0,0),I=I.setSubMatrix(A,M.rows,0),I=I.setSubMatrix(E,0,M.columns),I=I.setSubMatrix(x,M.rows,M.columns),I.subMatrix(0,i-1,0,n-1)}(e,t=r(t,a,l),a,l)}scaleRows(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{min:e=0,max:s=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(s))throw new TypeError("max must be a number");if(e>=s)throw new RangeError("min must be smaller than max");let i=new u(this.rows,this.columns);for(let t=0;t<this.rows;t++){const o=this.getRow(t);o.length>0&&(0,n.Z)(o,{min:e,max:s,output:o}),i.setRow(t,o)}return i}scaleColumns(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{min:e=0,max:s=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(s))throw new TypeError("max must be a number");if(e>=s)throw new RangeError("min must be smaller than max");let i=new u(this.rows,this.columns);for(let t=0;t<this.columns;t++){const o=this.getColumn(t);o.length&&(0,n.Z)(o,{min:e,max:s,output:o}),i.setColumn(t,o)}return i}flipRows(){const t=Math.ceil(this.columns/2);for(let e=0;e<this.rows;e++)for(let s=0;s<t;s++){let t=this.get(e,s),i=this.get(e,this.columns-1-s);this.set(e,s,i),this.set(e,this.columns-1-s,t)}return this}flipColumns(){const t=Math.ceil(this.rows/2);for(let e=0;e<this.columns;e++)for(let s=0;s<t;s++){let t=this.get(s,e),i=this.get(this.rows-1-s,e);this.set(s,e,i),this.set(this.rows-1-s,e,t)}return this}kroneckerProduct(t){t=u.checkMatrix(t);let e=this.rows,s=this.columns,i=t.rows,n=t.columns,o=new u(e*i,s*n);for(let r=0;r<e;r++)for(let e=0;e<s;e++)for(let s=0;s<i;s++)for(let a=0;a<n;a++)o.set(i*r+s,n*e+a,this.get(r,e)*t.get(s,a));return o}kroneckerSum(t){if(t=u.checkMatrix(t),!this.isSquare()||!t.isSquare())throw new Error("Kronecker Sum needs two Square Matrices");let e=this.rows,s=t.rows,i=this.kroneckerProduct(u.eye(s,s)),n=u.eye(e,e).kroneckerProduct(t);return i.add(n)}transpose(){let t=new u(this.columns,this.rows);for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)t.set(s,e,this.get(e,s));return t}sortRows(t=c){for(let e=0;e<this.rows;e++)this.setRow(e,this.getRow(e).sort(t));return this}sortColumns(t=c){for(let e=0;e<this.columns;e++)this.setColumn(e,this.getColumn(e).sort(t));return this}subMatrix(t,e,s,i){(0,l.J5)(this,t,e,s,i);let n=new u(e-t+1,i-s+1);for(let o=t;o<=e;o++)for(let e=s;e<=i;e++)n.set(o-t,e-s,this.get(o,e));return n}subMatrixRow(t,e,s){if(void 0===e&&(e=0),void 0===s&&(s=this.columns-1),e>s||e<0||e>=this.columns||s<0||s>=this.columns)throw new RangeError("Argument out of range");let i=new u(t.length,s-e+1);for(let n=0;n<t.length;n++)for(let o=e;o<=s;o++){if(t[n]<0||t[n]>=this.rows)throw new RangeError(`Row index out of range: ${t[n]}`);i.set(n,o-e,this.get(t[n],o))}return i}subMatrixColumn(t,e,s){if(void 0===e&&(e=0),void 0===s&&(s=this.rows-1),e>s||e<0||e>=this.rows||s<0||s>=this.rows)throw new RangeError("Argument out of range");let i=new u(s-e+1,t.length);for(let n=0;n<t.length;n++)for(let o=e;o<=s;o++){if(t[n]<0||t[n]>=this.columns)throw new RangeError(`Column index out of range: ${t[n]}`);i.set(o-e,n,this.get(o,t[n]))}return i}setSubMatrix(t,e,s){if((t=u.checkMatrix(t)).isEmpty())return this;let i=e+t.rows-1,n=s+t.columns-1;(0,l.J5)(this,e,i,s,n);for(let i=0;i<t.rows;i++)for(let n=0;n<t.columns;n++)this.set(e+i,s+n,t.get(i,n));return this}selection(t,e){(0,l.ZR)(this,t),(0,l.g)(this,e);let s=new u(t.length,e.length);for(let i=0;i<t.length;i++){let n=t[i];for(let t=0;t<e.length;t++){let o=e[t];s.set(i,t,this.get(n,o))}}return s}trace(){let t=Math.min(this.rows,this.columns),e=0;for(let s=0;s<t;s++)e+=this.get(s,s);return e}clone(){let t=new u(this.rows,this.columns);for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)t.set(e,s,this.get(e,s));return t}sum(t){switch(t){case"row":return(0,a.bQ)(this);case"column":return(0,a.Dm)(this);case void 0:return(0,a.xo)(this);default:throw new Error(`invalid option: ${t}`)}}product(t){switch(t){case"row":return(0,a.Pw)(this);case"column":return(0,a.PI)(this);case void 0:return(0,a.tT)(this);default:throw new Error(`invalid option: ${t}`)}}mean(t){const e=this.sum(t);switch(t){case"row":for(let t=0;t<this.rows;t++)e[t]/=this.columns;return e;case"column":for(let t=0;t<this.columns;t++)e[t]/=this.rows;return e;case void 0:return e/this.size;default:throw new Error(`invalid option: ${t}`)}}variance(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");const{unbiased:s=!0,mean:n=this.mean(t)}=e;if("boolean"!=typeof s)throw new TypeError("unbiased must be a boolean");switch(t){case"row":if(!(0,i.N)(n))throw new TypeError("mean must be an array");return(0,a.we)(this,s,n);case"column":if(!(0,i.N)(n))throw new TypeError("mean must be an array");return(0,a._G)(this,s,n);case void 0:if("number"!=typeof n)throw new TypeError("mean must be a number");return(0,a.C)(this,s,n);default:throw new Error(`invalid option: ${t}`)}}standardDeviation(t,e){"object"==typeof t&&(e=t,t=void 0);const s=this.variance(t,e);if(void 0===t)return Math.sqrt(s);for(let t=0;t<s.length;t++)s[t]=Math.sqrt(s[t]);return s}center(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");const{center:s=this.mean(t)}=e;switch(t){case"row":if(!(0,i.N)(s))throw new TypeError("center must be an array");return(0,a.rU)(this,s),this;case"column":if(!(0,i.N)(s))throw new TypeError("center must be an array");return(0,a._f)(this,s),this;case void 0:if("number"!=typeof s)throw new TypeError("center must be a number");return(0,a.mm)(this,s),this;default:throw new Error(`invalid option: ${t}`)}}scale(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");let s=e.scale;switch(t){case"row":if(void 0===s)s=(0,a.kn)(this);else if(!(0,i.N)(s))throw new TypeError("scale must be an array");return(0,a.DU)(this,s),this;case"column":if(void 0===s)s=(0,a.Pr)(this);else if(!(0,i.N)(s))throw new TypeError("scale must be an array");return(0,a.Mj)(this,s),this;case void 0:if(void 0===s)s=(0,a.Y2)(this);else if("number"!=typeof s)throw new TypeError("scale must be a number");return(0,a.td)(this,s),this;default:throw new Error(`invalid option: ${t}`)}}toString(t){return(0,o.M)(this,t)}}function c(t,e){return t-e}h.prototype.klass="Matrix","undefined"!=typeof Symbol&&(h.prototype[Symbol.for("nodejs.util.inspect.custom")]=o.V),h.random=h.rand,h.randomInt=h.randInt,h.diagonal=h.diag,h.prototype.diagonal=h.prototype.diag,h.identity=h.eye,h.prototype.negate=h.prototype.neg,h.prototype.tensorProduct=h.prototype.kroneckerProduct;class u extends h{constructor(t,e){if(super(),u.isMatrix(t))return t.clone();if(Number.isInteger(t)&&t>=0){if(this.data=[],!(Number.isInteger(e)&&e>=0))throw new TypeError("nColumns must be a positive integer");for(let s=0;s<t;s++)this.data.push(new Float64Array(e))}else{if(!(0,i.N)(t))throw new TypeError("First argument must be a positive number or an array");{const s=t;if("number"!=typeof(e=(t=s.length)?s[0].length:0))throw new TypeError("Data must be a 2D array with at least one element");this.data=[];for(let i=0;i<t;i++){if(s[i].length!==e)throw new RangeError("Inconsistent array dimensions");if(!s[i].every((t=>"number"==typeof t)))throw new TypeError("Input data contains non-numeric values");this.data.push(Float64Array.from(s[i]))}}}this.rows=t,this.columns=e}set(t,e,s){return this.data[t][e]=s,this}get(t,e){return this.data[t][e]}removeRow(t){return(0,l.zb)(this,t),this.data.splice(t,1),this.rows-=1,this}addRow(t,e){return void 0===e&&(e=t,t=this.rows),(0,l.zb)(this,t,!0),e=Float64Array.from((0,l.on)(this,e)),this.data.splice(t,0,e),this.rows+=1,this}removeColumn(t){(0,l.bp)(this,t);for(let e=0;e<this.rows;e++){const s=new Float64Array(this.columns-1);for(let i=0;i<t;i++)s[i]=this.data[e][i];for(let i=t+1;i<this.columns;i++)s[i-1]=this.data[e][i];this.data[e]=s}return this.columns-=1,this}addColumn(t,e){void 0===e&&(e=t,t=this.columns),(0,l.bp)(this,t,!0),e=(0,l.Um)(this,e);for(let s=0;s<this.rows;s++){const i=new Float64Array(this.columns+1);let n=0;for(;n<t;n++)i[n]=this.data[s][n];for(i[n++]=e[s];n<this.columns+1;n++)i[n]=this.data[s][n-1];this.data[s]=i}return this.columns+=1,this}}(0,r.z)(h,u)},9515:(t,e,s)=>{"use strict";s.d(e,{C:()=>m,DU:()=>y,Dm:()=>o,Mj:()=>w,PI:()=>l,Pr:()=>b,Pw:()=>a,Y2:()=>C,_G:()=>u,_f:()=>g,bQ:()=>n,kn:()=>f,mm:()=>p,rU:()=>d,tT:()=>h,td:()=>v,we:()=>c,xo:()=>r});var i=s(3018);function n(t){let e=(0,i.B4)(t.rows);for(let s=0;s<t.rows;++s)for(let i=0;i<t.columns;++i)e[s]+=t.get(s,i);return e}function o(t){let e=(0,i.B4)(t.columns);for(let s=0;s<t.rows;++s)for(let i=0;i<t.columns;++i)e[i]+=t.get(s,i);return e}function r(t){let e=0;for(let s=0;s<t.rows;s++)for(let i=0;i<t.columns;i++)e+=t.get(s,i);return e}function a(t){let e=(0,i.B4)(t.rows,1);for(let s=0;s<t.rows;++s)for(let i=0;i<t.columns;++i)e[s]*=t.get(s,i);return e}function l(t){let e=(0,i.B4)(t.columns,1);for(let s=0;s<t.rows;++s)for(let i=0;i<t.columns;++i)e[i]*=t.get(s,i);return e}function h(t){let e=1;for(let s=0;s<t.rows;s++)for(let i=0;i<t.columns;i++)e*=t.get(s,i);return e}function c(t,e,s){const i=t.rows,n=t.columns,o=[];for(let r=0;r<i;r++){let i=0,a=0,l=0;for(let e=0;e<n;e++)l=t.get(r,e)-s[r],i+=l,a+=l*l;e?o.push((a-i*i/n)/(n-1)):o.push((a-i*i/n)/n)}return o}function u(t,e,s){const i=t.rows,n=t.columns,o=[];for(let r=0;r<n;r++){let n=0,a=0,l=0;for(let e=0;e<i;e++)l=t.get(e,r)-s[r],n+=l,a+=l*l;e?o.push((a-n*n/i)/(i-1)):o.push((a-n*n/i)/i)}return o}function m(t,e,s){const i=t.rows,n=t.columns,o=i*n;let r=0,a=0,l=0;for(let e=0;e<i;e++)for(let i=0;i<n;i++)l=t.get(e,i)-s,r+=l,a+=l*l;return e?(a-r*r/o)/(o-1):(a-r*r/o)/o}function d(t,e){for(let s=0;s<t.rows;s++)for(let i=0;i<t.columns;i++)t.set(s,i,t.get(s,i)-e[s])}function g(t,e){for(let s=0;s<t.rows;s++)for(let i=0;i<t.columns;i++)t.set(s,i,t.get(s,i)-e[i])}function p(t,e){for(let s=0;s<t.rows;s++)for(let i=0;i<t.columns;i++)t.set(s,i,t.get(s,i)-e)}function f(t){const e=[];for(let s=0;s<t.rows;s++){let i=0;for(let e=0;e<t.columns;e++)i+=Math.pow(t.get(s,e),2)/(t.columns-1);e.push(Math.sqrt(i))}return e}function y(t,e){for(let s=0;s<t.rows;s++)for(let i=0;i<t.columns;i++)t.set(s,i,t.get(s,i)/e[s])}function b(t){const e=[];for(let s=0;s<t.columns;s++){let i=0;for(let e=0;e<t.rows;e++)i+=Math.pow(t.get(e,s),2)/(t.rows-1);e.push(Math.sqrt(i))}return e}function w(t,e){for(let s=0;s<t.rows;s++)for(let i=0;i<t.columns;i++)t.set(s,i,t.get(s,i)/e[i])}function C(t){const e=t.size-1;let s=0;for(let i=0;i<t.columns;i++)for(let n=0;n<t.rows;n++)s+=Math.pow(t.get(n,i),2)/e;return Math.sqrt(s)}function v(t,e){for(let s=0;s<t.rows;s++)for(let i=0;i<t.columns;i++)t.set(s,i,t.get(s,i)/e)}},3018:(t,e,s)=>{"use strict";s.d(e,{B4:()=>u,J5:()=>c,Um:()=>a,ZR:()=>l,bp:()=>o,cT:()=>d,g:()=>h,on:()=>r,zb:()=>n});var i=s(5776);function n(t,e,s){let i=s?t.rows:t.rows-1;if(e<0||e>i)throw new RangeError("Row index out of range")}function o(t,e,s){let i=s?t.columns:t.columns-1;if(e<0||e>i)throw new RangeError("Column index out of range")}function r(t,e){if(e.to1DArray&&(e=e.to1DArray()),e.length!==t.columns)throw new RangeError("vector size must be the same as the number of columns");return e}function a(t,e){if(e.to1DArray&&(e=e.to1DArray()),e.length!==t.rows)throw new RangeError("vector size must be the same as the number of rows");return e}function l(t,e){if(!(0,i.N)(e))throw new TypeError("row indices must be an array");for(let s=0;s<e.length;s++)if(e[s]<0||e[s]>=t.rows)throw new RangeError("row indices are out of range")}function h(t,e){if(!(0,i.N)(e))throw new TypeError("column indices must be an array");for(let s=0;s<e.length;s++)if(e[s]<0||e[s]>=t.columns)throw new RangeError("column indices are out of range")}function c(t,e,s,i,n){if(5!==arguments.length)throw new RangeError("expected 4 arguments");if(m("startRow",e),m("endRow",s),m("startColumn",i),m("endColumn",n),e>s||i>n||e<0||e>=t.rows||s<0||s>=t.rows||i<0||i>=t.columns||n<0||n>=t.columns)throw new RangeError("Submatrix indices are out of range")}function u(t,e=0){let s=[];for(let i=0;i<t;i++)s.push(e);return s}function m(t,e){if("number"!=typeof e)throw new TypeError(`${t} must be a number`)}function d(t){if(t.isEmpty())throw new Error("Empty matrix has no elements to index")}},8353:(t,e,s)=>{"use strict";s.d(e,{Z:()=>n});var i=s(1174);class n extends i.X{constructor(t){super(),this.data=t,this.rows=t.length,this.columns=t[0].length}set(t,e,s){return this.data[t][e]=s,this}get(t,e){return this.data[t][e]}}},3379:t=>{"use strict";var e=[];function s(t){for(var s=-1,i=0;i<e.length;i++)if(e[i].identifier===t){s=i;break}return s}function i(t,i){for(var o={},r=[],a=0;a<t.length;a++){var l=t[a],h=i.base?l[0]+i.base:l[0],c=o[h]||0,u="".concat(h," ").concat(c);o[h]=c+1;var m=s(u),d={css:l[1],media:l[2],sourceMap:l[3],supports:l[4],layer:l[5]};if(-1!==m)e[m].references++,e[m].updater(d);else{var g=n(d,i);i.byIndex=a,e.splice(a,0,{identifier:u,updater:g,references:1})}r.push(u)}return r}function n(t,e){var s=e.domAPI(e);return s.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;s.update(t=e)}else s.remove()}}t.exports=function(t,n){var o=i(t=t||[],n=n||{});return function(t){t=t||[];for(var r=0;r<o.length;r++){var a=s(o[r]);e[a].references--}for(var l=i(t,n),h=0;h<o.length;h++){var c=s(o[h]);0===e[c].references&&(e[c].updater(),e.splice(c,1))}o=l}}},569:t=>{"use strict";var e={};t.exports=function(t,s){var i=function(t){if(void 0===e[t]){var s=document.querySelector(t);if(window.HTMLIFrameElement&&s instanceof window.HTMLIFrameElement)try{s=s.contentDocument.head}catch(t){s=null}e[t]=s}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(s)}},9216:t=>{"use strict";t.exports=function(t){var e=document.createElement("style");return t.setAttributes(e,t.attributes),t.insert(e,t.options),e}},3565:(t,e,s)=>{"use strict";t.exports=function(t){var e=s.nc;e&&t.setAttribute("nonce",e)}},7795:t=>{"use strict";t.exports=function(t){if("undefined"==typeof document)return{update:function(){},remove:function(){}};var e=t.insertStyleElement(t);return{update:function(s){!function(t,e,s){var i="";s.supports&&(i+="@supports (".concat(s.supports,") {")),s.media&&(i+="@media ".concat(s.media," {"));var n=void 0!==s.layer;n&&(i+="@layer".concat(s.layer.length>0?" ".concat(s.layer):""," {")),i+=s.css,n&&(i+="}"),s.media&&(i+="}"),s.supports&&(i+="}");var o=s.sourceMap;o&&"undefined"!=typeof btoa&&(i+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(o))))," */")),e.styleTagTransform(i,t,e.options)}(e,t,s)},remove:function(){!function(t){if(null===t.parentNode)return!1;t.parentNode.removeChild(t)}(e)}}}},4589:t=>{"use strict";t.exports=function(t,e){if(e.styleSheet)e.styleSheet.cssText=t;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(t))}}},7241:(t,e,s)=>{"use strict";s.d(e,{D:()=>c});var i=s(4469),n=s(976),o=s(6414),r=s.n(o),a=s(2904),l=s(499);const h=31;async function c(t,e=!1,s){const o=l.Cn.getOrCreate(t);let c;s??(s=new Map);const m=o.isHelm()?(0,a.getHelmMonomers)(t):Object.keys(o.stats.freq).filter((t=>""!==t));for(let t=0;t<m.length;t++)s.has(m[t])||s.set(m[t],`${s.size+1}`);if(o.isHelm())c=await i.functions.call("HELM:getMolFiles",{col:t}),c=function(t,e,s=!1){const i=new Array(t.length);for(let n=0;n<t.length;n++){let o=0,r=0,a="\n Datagrok macromolecule handler\n\n 0 0 0 0 0 0 999 V3000\nM V30 BEGIN CTAB\n";const l=t.get(n);o=l.indexOf("\n",o)+1,o=l.indexOf("\n",o)+1,o=l.indexOf("\n",o)+1;const c=parseInt(l.substring(o,o+3)),u=parseInt(l.substring(o+3,o+6));a+=`M V30 COUNTS ${c} ${u} 0 0 0\n`,a+="M V30 BEGIN ATOM\n";for(let t=0;t<c;t++){o=l.indexOf("\n",o)+1+h,r=l.indexOf(" ",o);const i=l.substring(o,r);a+=s?`M V30 ${t+1} R${e.get(i)} 0.000 0.000 0 0\n`:`M V30 ${t+1} At 0.000 0.000 0 0 MASS=${e.get(i)}\n`}a+="M V30 END ATOM\n",a+="M V30 BEGIN BOND\n";for(let t=0;t<u;t++){o=l.indexOf("\n",o)+1;const e=parseInt(l.substring(o,o+3).trim()),s=parseInt(l.substring(o+3,o+6).trim());a+=`M V30 ${t+1} ${parseInt(l.substring(o+6,o+9).trim())} ${e} ${s}\n`}a+="M V30 END BOND\n",a+="M V30 END CTAB\n",a+="M END",i[n]=a}return i}(c,s,e);else{c=new Array(t.length);for(let i=0;i<t.length;i++){const t=u(r()(o.splitted[i]).filter((t=>""!==t)).toArray(),s,e);c[i]=t}}return n.Column.fromStrings("monomericMols",c)}function u(t,e,s=!1){let i="\n Datagrok macromolecule handler\n\n 0 0 0 0 0 0 999 V3000\nM V30 BEGIN CTAB\n";i+=`M V30 COUNTS ${t.length} ${t.length?t.length-1:0} 0 0 0\n`,i+="M V30 BEGIN ATOM\n";for(let n=0;n<t.length;n++)i+=s?`M V30 ${n+1} R${e.get(t[n])} 0.000 0.000 0 0\n`:`M V30 ${n+1} At 0.000 0.000 0 0 MASS=${e.get(t[n])}\n`;i+="M V30 END ATOM\n",i+="M V30 BEGIN BOND\n";for(let e=0;e<t.length-1;e++)i+=`M V30 ${e+1} 1 ${e+1} ${e+2}\n`;return i+="M V30 END BOND\n",i+="M V30 END CTAB\n",i+="M END",i}},2904:(t,e,s)=>{"use strict";s.r(e),s.d(e,{BYPASS_LARGE_DATA_WARNING:()=>je,GetRegionEditor:()=>rs,SeqActivityCliffsEditor:()=>hs,SeqPaletteCustom:()=>ts,SequenceSpaceEditor:()=>ls,SplitToMonomersEditor:()=>as,SubsequenceSearchTopMenu:()=>Vs,_package:()=>Ke,activityCliffs:()=>vs,addCopyMenu:()=>qs,alignSequences:()=>As,bioSubstructureFilter:()=>Us,compositionAnalysis:()=>Es,compositionAnalysisWidget:()=>ds,convertDialog:()=>Ns,demoBioActivityCliffs:()=>Ks,demoBioAtomicLevel:()=>js,demoBioHelmMsaSequenceSpace:()=>Js,demoBioSequenceSpace:()=>Xs,demoBioSimilarityDiversity:()=>$s,diversitySearchTopMenu:()=>Fs,diversitySearchViewer:()=>Gs,enumeratorColumnChoice:()=>Qs,fastaSequenceCellRenderer:()=>us,getBioLib:()=>is,getEnumeratorWidget:()=>ti,getHelmMonomers:()=>Os,getMonomerLibHelper:()=>Je,getRegion:()=>ws,getRegionApp:()=>Ys,getRegionHelmApp:()=>zs,getRegionPanel:()=>ns,getRegionTopMenu:()=>Cs,hydrophobPalette:()=>Qe,importBam:()=>Is,importFasta:()=>xs,initBio:()=>es,libraryPanel:()=>os,macroMolColumnPropertyPanel:()=>ms,macromoleculeDifferenceCellRenderer:()=>ps,monomerCellRenderer:()=>Ls,multipleSequenceAlignmentDialog:()=>Ms,packageSettingsEditor:()=>cs,saveAsFasta:()=>Bs,sdfToJsonLib:()=>ei,searchSubsequenceEditor:()=>Hs,separatorSequenceCellRenderer:()=>gs,sequenceAlignment:()=>fs,sequenceIdentityScoring:()=>Ws,sequenceSimilarityScoring:()=>Ds,sequenceSpaceTopMenu:()=>Ss,sequenceTooltip:()=>ss,similaritySearchTopMenu:()=>Ps,similaritySearchViewer:()=>ks,splitToMonomersTopMenu:()=>Rs,testDetectMacromolecule:()=>_s,toAtomicLevel:()=>Ts,vdRegionsViewer:()=>bs,webLogoLargeApp:()=>Zs,webLogoViewer:()=>ys});var i=s(4469),n=s(3870),o=s(976),r=s(6414),a=s.n(r),l=s(585);const h="rgb(100,100,100)",c="#808080",u="rgb(0,0,0)",m=l.GU;var d,g;function p(t,e,s,i,n,o,r=h,a=0,l=!1,d=1,p="",f=!1,y=g.classic,b=[],w=0,C=null,v=[],S=null,T={}){n.textAlign="start";let M=o.substring(0),A=f?"":p;y===g.MSA&&(A="");let E=!0,x=!0,I="difference";null!=C&&null!=C.cell.column&&(E=C.cell.column.temp["color-code"]??!0,x=C.cell.column.temp["compare-with-current"]??!0,I=C.cell.column.temp["highlight-difference"]??"difference");const N=v[w];x&&v.length>0&&"difference"===I&&(d=M==N?.3:d),x&&v.length>0&&"equal"===I&&(d=M!=N?.3:d),null!=S&&(M=m(M,S));const L=M+A;T[L]??(T[L]=n.measureText(L));let _=T[L];T[M]??(T[M]=n.measureText(M));let R=T[M].width;T[A]??(T[A]=n.measureText(A));const O=T[A].width,k=i/2-(_.fontBoundingBoxAscent+_.fontBoundingBoxDescent)/2+1;function P(s,i){const o=E?r:u;n.fillStyle=o,n.globalAlpha=d,y===g.classic&&(n.fillText(M,t+s,e+k),n.fillStyle=c,n.fillText(A,t+i,e+k)),y===g.MSA&&n.fillText(M,t+s,e+k)}_=_.width,y===g.MSA&&(R=b[w],_=b[w]);const G=(b[w]??0)-(b[0]??0);if(l||_>s)return P(G,G+R),t+G+R+O;{const e=(s-_)/2;return P(e,e+R),t+G+e+R}}!function(t){t.maxMonomerLength=".mm.cellRenderer.maxMonomerLength"}(d||(d={})),function(t){t.MSA="MSA",t.classic="classic"}(g||(g={}));var f,y=s(9611),b=s(8447),w=s(7331),C=s(499);!function(t){t.long="long",t.short="short"}(f||(f={}));const v={true:"1",false:"0"};var S=s(3553),T=s(7958);const M="rgb(100,100,100)",A=b.GU;function E(t,e,s,i,n){return t?Math.max(Math.min(t.canvas.width/n-s,i)):Math.max(e.canvas.width/n-s,0)}function x(t){const e=!a().enumerate(t).some((([e,s])=>e.length>1&&0!=s&&s!=t.length-1)),s=[],i=e?"":" ";for(const[e,n]of a().enumerate(t)){let o=e;n<t.length&&(o+=`${e?"":"-"}${i}`),s.push(o)}return[s,e]}class I extends o.GridCellRenderer{constructor(){super(...arguments),this.padding=5}get name(){return"sequence"}get cellType(){return"sequence"}get defaultHeight(){return 30}get defaultWidth(){return 230}onClick(t,e){t.cell.column.temp["current-word"]=t.cell.value,t.grid.invalidate()}onMouseMove(t,e){const s=t.cell.column.temp["bio-seqCol"];if(!s)return;const o=t.bounds,r=e.offsetX-t.gridColumn.left+(t.gridColumn.left-o.x),a=s.getPosition(t.tableRowIndex,r),l=s.getSeqMonList(t.tableRowIndex);if(null!==a&&a<l.length){const t=l[a],o=[n.div(t)];if(s._monomerStructureMap[t])o.push(s._monomerStructureMap[t]);else{const e=s.getMonomer(t);if(e){const n={autoCrop:!0,autoCropMargin:0,suppressChiralText:!0},r=i.chem.svgMol(e.smiles,void 0,void 0,n);o.push(r),s._monomerStructureMap[t]=r}}n.tooltip.show(n.divV(o),e.x+16,e.y+16)}else n.tooltip.hide()}render(t,e,s,i,n,r,l){let h,c=0,u=50;try{h=r.grid}catch(t){h=void 0;const[e,s]=(0,T.yf)(t);Ke.logger.error(e,void 0,s)}const m=r.cell.column;if(!h||!m)return;const f=m.temp,w=f["monomer-width"];if("short"===(null!=w?w:"short")){const t=parseInt(m.getTag(d.maxMonomerLength));u=(isNaN(t)?Ke.properties?.MaxMonomerLength:t)??4}let S=m.temp["bio-seqCol"];S||(S=new y.A(h,m,(()=>{const t=C.Cn.getOrCreate(m);return{unitsHandler:t,monomerCharWidth:7,separatorWidth:t.isMsa()?8:c,monomerToShort:A,monomerLengthLimit:u,monomerLib:is()}}))),m.tags[".mm.cellRenderer.settingsChanged"]===v.true&&(c=f[".mm.cellRenderer.gapLength"]??c,S.setMonomerLengthLimit(u),S.setSeparatorWidth(S.isMsa()?8:c),m.setTag(".mm.cellRenderer.settingsChanged",v.false));const[x,I]=S.getCellMonomerLengths(r.tableRowIndex);x.length,S.updated&&(f["bio-seqCol"]=S),t.save();try{const l=window.devicePixelRatio,h=-1!==r.gridRow?r.grid:null,c=r.cell.value,d=m.getTag("alphabet"),y=50;i=E(h,t,e,i,l),t.beginPath(),t.rect(e+this.padding,s+this.padding,i-this.padding-1,n-2*this.padding),t.clip(),t.font="12px monospace",t.textBaseline="top";const w=m.getTag(o.TAGS.UNITS),v=m.getTag("aligned"),T=(0,b.py)(d),A=m.getTag("separator")??"",x=i/5,N=C.Cn.getOrCreate(m).getSplitter(x),L=f["reference-sequence"],_=f["current-word"],R=N(null!=L&&""!=L?L:_??""),O=N(c);let k=M,P=g.classic;v&&v.includes("MSA")&&w==b.r2.SEPARATOR&&(P=g.MSA);for(const[o,l]of a().enumerate(O)){k=T.get(o),t.fillStyle=M;const a=l===O.length-1;if(p(e+this.padding,s,i,n,t,o,k,0,!0,1,A,a,P,I,l,r,R,u,S._monomerLengthMap),y>i)break}}catch(t){const e=t instanceof Error?t.message:t?t.toString():"Error 'undefined'";Ke.logger.error(`Bio: MacromoleculeSequenceCellRenderer.render() error: ${e}`)}finally{t.restore()}}}class N extends o.GridCellRenderer{get name(){return"MacromoleculeDifferenceCR"}get cellType(){return S.Of.MACROMOLECULE_DIFFERENCE}get defaultHeight(){return 30}get defaultWidth(){return 230}render(t,e,s,i,n,r,a){const h=window.devicePixelRatio,c=r.grid,u=r.cell,m=r.tableColumn,d=u.value??"",g=m.tags.separator,p=m.tags[o.TAGS.UNITS];i=E(c,t,e,i,h);const[f,y]=d.split("#"),b=(0,l.vU)(p,g);L(t,e,s,i,n,b(f),b(y),p)}}function L(t,e,s,i,n,o,r,l,h,c){if(o.length!==r.length){const t=function(t,e){let s=0,i=0;const n=t.length>e.length?t:e,o=t.length>e.length?e:t;for(let t=0;t<o.length;t++)n[t]===o[t]&&s++;const r=n.length-o.length;for(let t=n.length-1;t>r;t--)n[t]===o[t-r]&&i++;const a=new Array(Math.abs(t.length-e.length)).fill("");function l(t){return s>i?t.concat(a):a.concat(t)}return t.length>e.length?e=l(e):t=l(t),{subParts1:t,subParts2:e}}(a()(o).toArray(),a()(r).toArray());o=t.subParts1,r=t.subParts2}const u=t.measureText(x(o).join("")),m=t.measureText(x(r).join("")),d=Math.max(u.width,m.width);h&&(i=d+4*o.length,t.canvas.width=d+4*o.length);let g=Math.max(e,e+(i-(d+4*o.length))/2)+5;const f=Math.max(s,s+(n-28)/2);t.save(),t.beginPath(),t.rect(e,s,h?d+4*o.length:i,n),t.clip(),t.font="12px monospace",t.textBaseline="top";let y=w.UE.Color;"HELM"!=l&&(y=(0,b.py)(l.substring(l.length-2)));for(let e=0;e<o.length;e++){const s=o[e],a=r[e],l=y.get(s);if(s!=a){const o=y.get(a),r=p(g,f-7,i,n,t,s,l,0,!0),h=p(g,f+7,i,n,t,a,o,0,!0);g=Math.max(h,r),c&&(c[e]=_(s,a,l,o,f,7,n))}else g=p(g,f,i,n,t,s,l,0,!0,.5);g+=4}t.restore()}function _(t,e,s,i,n,o,r){const a=document.createElement("canvas"),l=a.getContext("2d");l.font="12px monospace";const h=l.measureText(x([t]).join("")).width,c=l.measureText(x([e]).join("")).width,u=Math.max(h,c);return a.height=r,a.width=u+4,l.font="12px monospace",l.textBaseline="top",p(0,n-o,u,r,l,t,s,0,!0),p(0,n+o,u,r,l,e,i,0,!0),a}var R,O=s(701),k=s(9298);!function(t){t.Unknown="unknown",t.FR="framework",t.CDR="cdr"}(R||(R={}));const P=new class{constructor(){this.regionTypes=[R.CDR],this.chains=["Heavy","Light"],this.skipEmptyPositions=!1,this.fitWidth=!1,this.positionWidth=16,this.positionHeight=k.ES.Entropy,this.filterSource=k.vS.filterSource}};var G=s(833);const F=R;var H,V;!function(t){t.STYLE="Style",t.BEHAVIOR="Behavior",t.LAYOUT="Layout",t.DATA="Data"}(H||(H={})),function(t){t.skipEmptyPositions="skipEmptyPositions",t.regionTypes="regionTypes",t.chains="chains",t.fitWidth="fitWidth",t.positionWidth="positionWidth",t.positionHeight="positionHeight",t.filterSource="filterSource"}(V||(V={}));const W=P;class D extends o.JsViewer{constructor(){super(),this.viewed=!1,this.regionsFg=null,this.regionsRoot=null,this.isOpened=!1,this.panelNode=null,this.regions=[],this.viewPromise=Promise.resolve(),this.detachPromise=Promise.resolve(),this.setDataInProgress=!1,this.host=null,this.mainLayout=null,this.logos=[],this.viewSubs=[],this.calcSizeRequested=!1,this.skipEmptyPositions=this.bool(V.skipEmptyPositions,W.skipEmptyPositions,{category:H.DATA}),this.regionTypes=this.stringList(V.regionTypes,W.regionTypes,{category:H.DATA,choices:Object.values(F).filter((t=>t!=F.Unknown))}),this.chains=this.stringList(V.chains,W.chains,{category:H.DATA,choices:["Heavy","Light"]}),this.fitWidth=this.bool(V.fitWidth,W.fitWidth,{category:H.LAYOUT}),this.positionWidth=this.float(V.positionWidth,W.positionWidth,{category:H.LAYOUT,editor:"slider",min:0,max:64,description:"Internal WebLogo viewers property width of position."}),this.positionHeight=this.string(V.positionHeight,W.positionHeight,{category:H.LAYOUT,choices:Object.keys(k.ES)}),this.filterSource=this.string(V.filterSource,W.filterSource,{category:H.BEHAVIOR,choices:Object.values(k.Ct)})}async init(){this.subs.push((0,O.fromEvent)(this.root,"mousemove").subscribe(this.rootOnMouseMove.bind(this)))}detach(){const t=super.detach.bind(this);this.detachPromise=this.detachPromise.then((async()=>{await this.viewPromise,this.setDataInProgress||(this.viewed&&(await this.destroyView("detach"),this.viewed=!1),t())}))}onTableAttached(){super.onTableAttached(),this.setData(this.regions)}onPropertyChanged(t){if(super.onPropertyChanged(t),t){switch(t.name){case V.regionTypes:case V.chains:this.setData(this.regions)}switch(t.name){case V.skipEmptyPositions:for(let t=0;t<this.logos.length;++t)for(const e of this.chains)this.logos[t][e].setOptions({[G.bo.skipEmptyPositions]:this.skipEmptyPositions});this.calcSize();break;case V.fitWidth:case V.positionWidth:this.calcSize();break;case V.positionHeight:for(let t=0;t<this.logos.length;++t)for(const e of this.chains)this.logos[t][e].setOptions({[G.bo.positionHeight]:this.positionHeight});this.calcSize();break;case V.filterSource:this.filterSourceInput.value=this.filterSource;break;default:this.setData(this.regions)}}else console.warn("Bio: VdRegionsViewer.onPropertyChanged() property is null")}setData(t){Ke.logger.debug(`Bio: VdRegionsViewer.setData(), in, regions.length = ${t.length}`),this.viewPromise=this.viewPromise.then((async()=>{if(!this.setDataInProgress){this.setDataInProgress=!0;try{this.viewed&&(await this.destroyView("setData"),this.viewed=!1),await this.detachPromise,this.regions=t,this.viewed||(await this.buildView("setData"),this.viewed=!0)}catch(t){const e=t instanceof Error?t.message:t.toString(),s=t instanceof Error?t.stack:void 0;i.shell.error(e),Ke.logger.error(e,void 0,s)}finally{this.setDataInProgress=!1}}}))}async destroyView(t){Ke.logger.debug(`Bio: VdRegionsViewer.destroyView( mainLayout = ${this.mainLayout?"value":"none"} ), purpose = '${t}', this.regions.length = ${this.regions.length}`),this.filterSourceInput&&n.empty(this.filterSourceInput.root),null!=this.mainLayout&&(this.mainLayout.remove(),this.host.remove(),this.host=null,this.mainLayout=null);for(const t of this.viewSubs)t.unsubscribe()}async buildView(t){Ke.logger.debug(`Bio: VdRegionsViewer.buildView() begin, purpose = '${t}', this.regions.length = ${this.regions.length}`);const e=this.regions.filter((t=>this.regionTypes.includes(t.type))),s=Array.from(new Set(e.map((t=>t.order)))).sort(),i=[];for(let t=0;t<s.length;t++)for(const n of this.chains){const o=e.find((e=>e.order==s[t]&&e.chain==n));i.push((async()=>{const e=await this.dataFrame.plot.fromType("WebLogo",{sequenceColumnName:o.sequenceColumnName,startPositionName:o.positionStartName,endPositionName:o.positionEndName,fixWidth:!0,skipEmptyPositions:this.skipEmptyPositions,positionWidth:this.positionWidth,positionHeight:this.positionHeight,filterSource:this.filterSource});return e.onSizeChanged.subscribe((()=>{this.calcSize()})),[t,n,e]})())}const o=await Promise.all(i);this.logos=new Array(s.length);for(let t=0;t<s.length;++t)this.logos[t]={};for(const[t,e,s]of o)this.logos[t][e]=s,this.viewSubs.push(s.onFreqsCalculated.subscribe((()=>{this.calcSize()})));this.mainLayout=n.table(this.chains,(t=>[...s.length>0?[n.div(t,{style:{transform:"rotate(-90deg)",font:"12px Roboto, Roboto Local, sans-serif",textAlign:"center",width:"16px",marginTop:"24px",marginLeft:"6px"}})]:[],...[...Array(s.length).keys()].map((e=>{const s=this.logos[e][t];return s.root.style.height="100%",n.div([s.root],{style:{marginTop:"4px",marginBottom:"4px"}})}))]),["",...[...Array(s.length).keys()].map((t=>e.find((e=>e.order==s[t]&&e.chain==this.chains[0])).name||"Name"))]),this.mainLayout.className="mlb-vd-regions-viewer-table2",this.filterSourceInput=n.choiceInput("Data source",this.filterSource,Object.values(k.Ct),this.filterSourceInputOnValueChanged.bind(this)),this.filterSourceInput.root.style.position="absolute",this.filterSourceInput.root.style.right="9px",this.filterSourceInput.root.style.top="-4px",Math.ceil(255*Math.random()).toString(16),this.host=n.div([this.mainLayout,this.filterSourceInput.root],{}),this.root.appendChild(this.host),this.root.style.overflowX="auto",this.calcSize(),this.viewSubs.push(n.onSizeChanged(this.root).subscribe(this.rootOnSizeChanged.bind(this))),Ke.logger.debug("Bio: VdRegionsViewer.buildView() end")}calcSize(){Ke.logger.debug("Bio: VdRegionsViewer.calcSize(), start");const t=()=>{if(!this.host)return;const t=(this.root.clientHeight-54)/this.chains.length;let e=0;for(let s=0;s<this.logos.length;s++){for(const e of this.chains)this.logos[s][e].root.style.height=`${t}px`;e+=Math.max(...this.chains.map((t=>this.logos[s][t].Length)))}if(this.fitWidth){if(this.logos.length>0&&e>0){const t=22,s=13,i=9,n=(this.root.clientWidth-t-(this.logos.length-1)*i-s)/e;for(let t=0;t<this.logos.length;t++)for(const e of this.chains){const s=this.logos[t][e];s.setOptions({[G.bo.positionWidth]:n-s.positionMarginValue}),s.root.style.width=n*s.Length+"px"}}this.host.style.setProperty("overflow","hidden","important")}else{for(let t=0;t<this.logos.length;t++)for(const e of this.chains)this.logos[t][e].setOptions({[G.bo.positionWidth]:this.positionWidth});this.host.style.removeProperty("overflow")}0===this.positionWidth?this.host.style.setProperty("overflow-x","hidden","important"):this.host.style.removeProperty("overflow-x")};this.calcSizeRequested||(this.calcSizeRequested=!0,window.setTimeout((()=>{t(),this.calcSizeRequested=!1}),0))}rootOnSizeChanged(t){this.calcSize()}rootOnMouseMove(t){}filterSourceInputOnValueChanged(){const t=this.filterSourceInput.value;this.viewPromise=this.viewPromise.then((()=>{if(this.filterSource!==t){this.props.getProperty(V.filterSource).set(this,t);for(let t=0;t<this.logos.length;t++)for(let e=0;e<this.chains.length;e++){const s=this.chains[e];this.logos[t][s].setOptions({[G.bo.filterSource]:this.filterSource})}}}))}}var B=s(9017),U=s(850);const Z="dimensionality-reducer-terminate-event";async function Y(t,e,n,o,r,a){const l=await async function(t,e,n,o,r){return new Promise((function(a,l){const h=new Worker(new URL(s.p+s.u(196),s.b));h.postMessage({columnData:t.data,method:e,measure:t.metric,options:n,parallelDistanceWorkers:o});const c=i.events.onCustomEvent(Z).subscribe((()=>{try{h?.terminate()}finally{c.unsubscribe()}}));h.onmessage=({data:{error:t,distance:e,embedding:s,epochNum:i,epochsLength:n}})=>{i&&n?r&&r(i,n,s):(c.unsubscribe(),t?l(t):a({distance:e,embedding:s}),setTimeout((()=>h.terminate()),0))}}))}({data:t,metric:n},e,o,r,a);return l.embedding=l.embedding.map((t=>(0,U.Fv)(t))),l}var z=s(7983),q=s(7228),$=s(489);async function X(t,e){const s=C.Cn.getOrCreate(t.seqCol),i=t.seqCol.toList(),n=s.getSplitter(),r=i.length;let a=36;const l=new Map;for(let e=0;e<r;e++){const s=i[e];if(null===i[e]||t.seqCol.isNone(e)){i[e]=null;continue}i[e]="";const o=n(s);for(let t=0;t<o.length;t++){const s=o[t];l.has(s)||(l.set(s,String.fromCharCode(a)),a++),i[e]+=l.get(s)}}if(t.similarityMetric===$.U.MONOMER_CHEMICAL_DISTANCE){const e=Array.from(l.keys()),s=await(0,q.PF)(e);s.scoringMatrix.forEach(((t,e)=>{t.forEach(((t,i)=>{s.scoringMatrix[e][i]=1-t}))}));const i={};Object.entries(s.alphabetIndexes).forEach((([t,e])=>{i[l.get(t)]=e})),t.options.distanceFnArgs={scoringMatrix:s.scoringMatrix,alphabetIndexes:i}}const h=await Y(i,t.methodName,t.similarityMetric,t.options,!0,e),c=t.embedAxesNames.map(((t,e)=>o.Column.fromFloat32Array(t,h.embedding[e])));return{distance:h.distance,coordinates:new o.ColumnList(c)}}function K(t){const e=["Embed_X","Embed_Y"],s=t.columns.names().filter((t=>t.includes(e[0]))).length+1;return e.map((t=>`${t}_${s}`))}var j=s(5697),J=s(3379),Q=s.n(J),tt=s(7795),et=s.n(tt),st=s(569),it=s.n(st),nt=s(3565),ot=s.n(nt),rt=s(9216),at=s.n(rt),lt=s(4589),ht=s.n(lt),ct=s(9414),ut={};ut.styleTagTransform=ht(),ut.setAttributes=ot(),ut.insert=it().bind(null,"head"),ut.domAPI=et(),ut.insertStyleElement=at(),Q()(ct.Z,ut),ct.Z&&ct.Z.locals&&ct.Z.locals;var mt=s(3914),dt=s(6254);let gt=0;const pt="cliffsDf",ft=new O.Subject,yt="act_diff",bt="sali",wt="sim",Ct="line_index",vt=["1_seq","2_seq"],St="filterCliffs";function Tt(t,e,s){const i=e.getBoundingClientRect(),n=t.clientX-i.left,o=t.clientY-i.top;let r=null,a=0;for(const t of s){const e=Math.abs(Math.hypot(t.a[0]-n,t.a[1]-o)+Math.hypot(t.b[0]-n,t.b[1]-o)-Math.hypot(t.a[0]-t.b[0],t.a[1]-t.b[1]));(!a&&e<2||e<a)&&(a=e,r=t)}return r}var Mt=s(6361);async function At(t,e,s,n,r){e.version!==e.temp["last-invalidated-version"]&&await(0,z.HV)(e,!1);const a=o.DataFrame.create(e.length);return a.columns.addNewString(n).init((t=>e.temp["monomeric-mols"].get(t))),await i.functions.call("Chem:getChemSimilaritiesMatrix",{dim:t,col:e.temp["monomeric-mols"],df:a,colName:n,simArr:r})}function Et(t){const e=n.divH([]),s=n.divV([n.divText(t.seqCol.name),n.divText(t.activityCol.name)]);return s.style.fontWeight="bold",s.style.display="flex",s.style.justifyContent="space-between",e.append(s),t.line.mols.forEach(((s,i)=>{const o=n.divText(t.activityCol.get(s).toFixed(2));o.style.display="flex",o.style.justifyContent="left",o.style.paddingLeft="30px",e.append(n.divV([n.divText(t.seqCol.get(s)),o]))})),e}function xt(t){const e=n.div();e.append(n.divText(t.seqCol.name,{style:{fontWeight:"bold"}}));const s=new Array(2),i=new Array(2);t.line.mols.forEach(((e,n)=>{s[n]=t.seqCol.get(e),i[n]=t.activityCol.get(e)}));const o={},r=C.Cn.getOrCreate(t.seqCol),a=r.getSplitter(),l=Nt(a(s[0]),a(s[1]),r.units,o);return e.append(n.div(l,{style:{width:"300px",overflow:"scroll"}})),e.append(Lt(o)),e.append(It("Activity delta",Math.abs(i[0]-i[1]))),e.append(It("Cliff",t.sali)),e}function It(t,e){return n.divH([n.divText(`${t}: `,{style:{fontWeight:"bold",paddingRight:"5px"}}),n.divText(e.toFixed(2))],{style:{paddingTop:"10px"}})}function Nt(t,e,s,i){const n=document.createElement("canvas"),o=n.getContext("2d");return n.height=30,L(o,0,0,0,30,t,e,s,!0,i),n}function Lt(t){const e=n.div();if(Object.keys(t).length>0){const s=n.divV([]);s.append(n.divH([n.divText("Pos",{style:{fontWeight:"bold",width:"30px",borderBottom:"1px solid"}}),n.divText("Difference",{style:{fontWeight:"bold",borderBottom:"1px solid"}})]));for(const e of Object.keys(t))t[e].style.borderBottom="1px solid lightgray",s.append(n.divH([n.divText((parseInt(e)+1).toString(),{style:{width:"30px",borderBottom:"1px solid lightgray"}}),t[e]]));e.append(s)}return e}function _t(t,e){const s=o.Column.string("seq_diff",t.rowCount).init((s=>`${t.get(e[0],s)}#${t.get(e[1],s)}`));s.semType="MacromoleculeDifference",s.setTag(o.TAGS.UNITS,t.col(e[0]).getTag(o.TAGS.UNITS)),s.setTag("separator",t.col(e[0]).getTag("separator")),t.columns.add(s);const i=t.plot.grid();return i.col(e[0]).visible=!1,i.col(e[1]).visible=!1,i}var Rt=s(4004),Ot=s(8601),kt=s(5226);s(9133);class Pt extends o.JsViewer{constructor(t){super(),this.name="",this.metricsProperties=["distanceMetric","fingerprint"],this.fingerprintChoices=["Morgan","Pattern"],this.initialized=!1,this.tags=[o.TAGS.UNITS,"aligned","separator","alphabet"],this.preComputeDistanceMatrix=!1,this.renderPromise=Promise.resolve(),this.fingerprint=this.string("fingerprint",this.fingerprintChoices[0],{choices:this.fingerprintChoices}),this.limit=this.int("limit",10),this.distanceMetric=this.string("distanceMetric",j.kg[0],{choices:j.kg}),this.moleculeColumnName=this.string("moleculeColumnName"),this.name=t}init(){this.initialized=!0}detach(){this.subs.forEach((t=>t.unsubscribe()))}async onTableAttached(){if(this.init(),this.dataFrame){this.preComputeDistanceMatrix=this.dataFrame.rowCount<=22e3,this.subs.push(o.debounce(this.dataFrame.onRowsRemoved,50).subscribe((t=>this.render(!0))));const t="diversity"!==this.name;this.subs.push(o.debounce(this.dataFrame.onCurrentRowChanged,50).subscribe((e=>this.render(t)))),this.subs.push(o.debounce(this.dataFrame.selection.onChanged,50).subscribe((t=>this.render(!1)))),this.subs.push(o.debounce(n.onSizeChanged(this.root),50).subscribe((t=>this.render(!1)))),this.moleculeColumn=this.dataFrame.columns.bySemType(o.SEMTYPE.MACROMOLECULE),this.moleculeColumnName=this.moleculeColumn?.name,this.getProperty("limit").fromOptions({min:1,max:this.dataFrame.rowCount})}this.render()}onPropertyChanged(t){if(super.onPropertyChanged(t),this.initialized){if("moleculeColumnName"===t.name){const e=this.dataFrame.col(t.get(this));e.semType===o.SEMTYPE.MACROMOLECULE&&(this.moleculeColumn=e)}this.render()}}render(t=!0){this.renderPromise=this.renderPromise.then((async()=>{this.computeRequested=this.computeRequested||t,await this.renderInt(t)}))}async renderInt(t){}beforeRender(){return!(!this.initialized||this.dataFrame&&this.moleculeColumnName&&this.dataFrame.col(this.moleculeColumnName).semType!==o.SEMTYPE.MACROMOLECULE&&(i.shell.error(`${this.moleculeColumnName} is not Macromolecule type`),1))}}var Gt=s(7241),Ft=s(4293),Ht=s(2669);async function Vt(t){const e=t.toList();if(t.semType!==o.SEMTYPE.MACROMOLECULE)throw new Error("Column has to be of macromolecule type");const s=C.Cn.getOrCreate(t).getDistanceFunctionName(),i=new Ht.m(!0,!1),n=await i.calc(e,s);return i.terminate(),n}function Wt(t){return(e,s)=>{const i=(e,s)=>t*e+s-Math.floor((e+2)*(e+1)/2);return e<=s?i(e,s):i(s,e)}}class Dt extends Pt{constructor(){super("similarity"),this.sketchedMolecule="",this.curIdx=0,this.molCol=null,this.idxs=null,this.scores=null,this.gridSelect=!1,this.targetMoleculeIdx=0,this.computeCompleted=new O.Subject,this.distanceMatrixComputed=!1,this.cutoff=this.float("cutoff",.01,{min:0,max:1}),this.hotSearch=this.bool("hotSearch",!0),this.similarColumnLabel=this.string("similarColumnLabel",null)}init(){this.hotSearch=!0,this.initialized=!0}async renderInt(t){if(this.beforeRender()&&this.moleculeColumn&&(this.curIdx=-1==this.dataFrame.currentRowIdx?0:this.dataFrame.currentRowIdx,t&&!this.gridSelect)){this.targetMoleculeIdx=-1==this.dataFrame.currentRowIdx?0:this.dataFrame.currentRowIdx;const t=C.Cn.getOrCreate(this.moleculeColumn);await(t.isFasta()?this.computeByMM():this.computeByChem());const e=null!=this.similarColumnLabel?this.similarColumnLabel:`similar (${this.moleculeColumnName})`;this.molCol=o.Column.string(e,this.idxs.length).init((t=>this.moleculeColumn?.get(this.idxs?.get(t)))),this.molCol.semType=o.SEMTYPE.MACROMOLECULE,this.tags.forEach((t=>this.molCol.setTag(t,this.moleculeColumn.getTag(t))));const s=o.DataFrame.fromColumns([this.idxs,this.molCol,this.scores]);s.onCurrentRowChanged.subscribe((t=>{this.dataFrame.currentRowIdx=s.col("indexes").get(s.currentRowIdx),setTimeout((()=>{this.createPropertyPanel(s)}),1e3),this.gridSelect=!0}));const n=s.plot.grid();n.col("indexes").visible=!1;const r=this.idxs?.getRawData().findIndex((t=>t==this.targetMoleculeIdx));n.cell("score",r).cell.value=null,i.shell.v.grid.root.addEventListener("click",(t=>{this.gridSelect=!1})),(0,Ft.Y)(this.root,n.root),this.computeCompleted.next(!0)}}async computeByChem(){const t=await(0,Gt.D)(this.moleculeColumn),e=(o.DataFrame.fromColumns([t]),await i.functions.call("Chem:callChemSimilaritySearch",{df:this.dataFrame,col:t,molecule:t.get(this.targetMoleculeIdx),metricName:this.distanceMetric,limit:this.limit,minScore:this.cutoff,fingerprint:this.fingerprint}));this.idxs=e.getCol("indexes"),this.scores=e.getCol("score")}async computeByMM(){let t=new Float32Array;!this.distanceMatrixComputed&&this.preComputeDistanceMatrix?(this.mmDistanceMatrix=await Vt(this.moleculeColumn),this.distanceMatrixComputed=!0):this.preComputeDistanceMatrix||(t=await async function(t,e){const i=t.toList();if(t.semType!==o.SEMTYPE.MACROMOLECULE)throw new Error("Column has to be of macromolecule type");const n=C.Cn.getOrCreate(t).getDistanceFunctionName(),r=Math.min(Math.max(navigator.hardwareConcurrency-2,1),i.length),a=new Array(r).fill(null).map((t=>new Worker(new URL(s.p+s.u(190),s.b)))),l=new Float32Array(i.length);let h=0,c=Number.MIN_VALUE;const u=a.map(((t,s)=>{const o=Math.floor(s*i.length/r),u=s===a.length-1?Math.floor((s+1)*i.length/r):i.length;return new Promise(((s,r)=>{t.onmessage=({data:{error:t,distanceArrayData:e,min:i,max:n}})=>{t?r(t):(h=Math.min(h,i),c=Math.max(c,n),l.set(e,o),s())},t.postMessage({fnName:n,values:i,templateIdx:e,start:o,end:u})}))}));try{await Promise.all(u),l.forEach(((t,e)=>{l[e]=(t-h)/(c-h)})),a.forEach((t=>t.terminate()))}catch(t){throw a.forEach((t=>t.terminate())),t}return l}(this.moleculeColumn,this.targetMoleculeIdx));const e=this.moleculeColumn.length,i=Wt(e),n=Array(e).fill(0).map(((e,s)=>({idx:s,score:s===this.targetMoleculeIdx?1:this.preComputeDistanceMatrix?1-this.mmDistanceMatrix[i(this.targetMoleculeIdx,s)]:1-t[s]})));n.sort(((t,e)=>e.score-t.score));const r=Math.min(this.limit,e),a=n.slice(0,r);this.idxs=o.Column.int("indexes",r).init((t=>a[t].idx)),this.scores=o.Column.float("score",r).init((t=>a[t].score))}createPropertyPanel(t){const e=n.div(),s={},o=this.molCol?.name,r=t.col(o),a=C.Cn.getOrCreate(r),l=a.getSplitter(),h=l(this.moleculeColumn.get(this.targetMoleculeIdx)),c=l(t.get(o,t.currentRowIdx)),u=Nt(h,c,a.units,s);e.append(n.div(u,{style:{width:"300px",overflow:"scroll"}})),h.length!==c.length&&e.append(n.divV([n.divText("Different sequence length:",{style:{fontWeight:"bold"}}),n.divText(`target: ${h.length} monomers`),n.divText(`selected: ${c.length} monomers`)],{style:{paddingBottom:"10px"}})),e.append(Lt(s));const m=n.accordion(),d=n.element("i");d.className="grok-icon svg-icon svg-view-layout",m.addTitle(n.span([d,n.label("Similarity search")])),m.addPane("Differences",(()=>e),!0),i.shell.o=m.root}}var Bt=s(8518);class Ut extends Pt{constructor(){super("diversity"),this.renderMolIds=null,this.columnNames=[],this.computeCompleted=new O.Subject,this.diverseColumnLabel=this.string("diverseColumnLabel",null)}async renderInt(t){if(this.beforeRender()&&this.dataFrame&&t&&this.moleculeColumn){const t=C.Cn.getOrCreate(this.moleculeColumn);await(t.isFasta()?this.computeByMM():this.computeByChem());const e=null!=this.diverseColumnLabel?this.diverseColumnLabel:`diverse (${this.moleculeColumnName})`,s=o.Column.string(e,this.renderMolIds.length).init((t=>this.moleculeColumn?.get(this.renderMolIds[t])));s.semType=o.SEMTYPE.MACROMOLECULE,this.tags.forEach((t=>s.setTag(t,this.moleculeColumn.getTag(t))));const i=o.DataFrame.fromColumns([s]);i.onCurrentRowChanged.subscribe((t=>{this.dataFrame.currentRowIdx=this.renderMolIds[i.currentRowIdx]})),(0,Ft.Y)(this.root,i.plot.grid().root),this.computeCompleted.next(!0)}}async computeByChem(){const t=await(0,Gt.D)(this.moleculeColumn);o.DataFrame.fromColumns([t]),this.renderMolIds=await i.functions.call("Chem:callChemDiversitySearch",{col:t,metricName:this.distanceMetric,limit:this.limit,fingerprint:this.fingerprint})}async computeByMM(){const t=await Vt(this.moleculeColumn),e=this.moleculeColumn.length,s=Wt(e);this.renderMolIds=(0,Bt.L)(e,Math.min(e,this.limit),((e,i)=>this.moleculeColumn.isNone(e)||this.moleculeColumn.isNone(i)?0:t[s(e,i)]))}}var Zt=s(9943),Yt=s(4413),zt=s(1061),qt=s(5490),$t=s(116),Xt=s(1040);const Kt={[o.SEMTYPE.MOLECULE]:"Molecules",[o.SEMTYPE.MACROMOLECULE]:"Sequences"};class jt{get algorithmOptions(){const t=this.methodsParams[this.methodInput.value],e={};return Object.keys(t).forEach((s=>{null!=t[s].value&&(e[s]=t[s].value)})),e}constructor(t){this.methodSettingsDiv=n.inputs([]),this.methodsParams={[$t.AL.UMAP]:new $t.bD,[$t.AL.T_SNE]:new $t.aP},this.tableInput=n.tableInput("Table",i.shell.tv.dataFrame,void 0,(()=>{this.onTableInputChanged(t)})),this.molColInput=n.columnInput(Kt[t],this.tableInput.value,this.tableInput.value.columns.bySemType(t),null,{filter:e=>e.semType===t}),this.molColInputRoot=this.molColInput.root,this.molColInput.onChanged((()=>this.onColumnInputChanged(t))),this.methodInput=n.choiceInput("Method",$t.AL.UMAP,[$t.AL.UMAP,$t.AL.T_SNE],(()=>{e&&this.createAlgorithmSettingsDiv(this.methodSettingsDiv,this.methodsParams[this.methodInput.value]),this.displaySimilarityThresholdInput(t)})),this.similarityThresholdInput=n.floatInput("Similarity threshold",.5),n.tooltip.bind(this.similarityThresholdInput.root,"Similarity threshold for sparse matrix creation."),this.methodSettingsIcon=n.icons.settings((()=>{e=!e,e?this.createAlgorithmSettingsDiv(this.methodSettingsDiv,this.methodsParams[this.methodInput.value]):n.empty(this.methodSettingsDiv)}),"Modify methods parameters"),this.methodInput.root.classList.add("ml-dim-reduction-settings-input"),this.methodInput.root.prepend(this.methodSettingsIcon),this.methodSettingsDiv=n.inputs([]);let e=!1;this.similarityMetricInput=t===o.SEMTYPE.MOLECULE?n.choiceInput("Similarity",Xt.gk.Tanimoto,j.Rt):n.choiceInput("Similarity",$.U.HAMMING,j.bc),setTimeout((()=>{this.displaySimilarityThresholdInput(t),this.onColumnInputChanged(t)}))}createAlgorithmSettingsDiv(t,e){return n.empty(t),Object.keys(e).forEach((s=>{const i=e[s],o=n.floatInput(i.uiName,i.value,(()=>{i.value=o.value}));n.tooltip.bind(o.root,i.tooltip),t.append(o.root)})),t}onTableInputChanged(t){this.molColInput=n.columnInput(Kt[t],this.tableInput.value,this.tableInput.value.columns.bySemType(t)),this.molColInput.onChanged((()=>this.onColumnInputChanged(t))),n.empty(this.molColInputRoot),Array.from(this.molColInput.root.children).forEach((t=>this.molColInputRoot.append(t))),this.displaySimilarityThresholdInput(t),this.onColumnInputChanged(t)}onColumnInputChanged(t){const e=this.molColInput.value;if(!e||t!==o.SEMTYPE.MACROMOLECULE)return;const s=(e.getTag("aligned")??" ").toUpperCase().includes("MSA");this.similarityMetricInput.value=s?$.U.HAMMING:$.U.LEVENSHTEIN}displaySimilarityThresholdInput(t){t!==o.SEMTYPE.MOLECULE&&this.tableInput.value&&this.tableInput.value.rowCount>2e4&&this.methodInput.value===$t.AL.UMAP?this.similarityThresholdInput.root.style.display="block":this.similarityThresholdInput.root.style.display="none"}}class Jt extends jt{get funcParams(){return{table:this.tableInput.value,molecules:this.molColInput.value,methodName:this.methodInput.value,similarityMetric:this.similarityMetricInput.value,sparseMatrixThreshold:this.similarityThresholdInput.value??.8,plotEmbeddings:this.plotEmbeddingsInput.value,options:this.algorithmOptions}}get paramsUI(){return this.funcParamsDiv}constructor(t){super(t),this.plotEmbeddingsInput=n.boolInput("Plot embeddings",!0),this.funcParamsDiv=n.inputs([this.tableInput,this.molColInput,this.methodInput,this.similarityThresholdInput,this.methodSettingsDiv,this.similarityMetricInput,this.plotEmbeddingsInput],{style:{minWidth:"320px"}})}}class Qt extends jt{get funcParams(){return{table:this.tableInput.value,molecules:this.molColInput.value,activities:this.activitiesInput.value,similarity:this.similarityInput.value,methodName:this.methodInput.value,similarityMetric:this.similarityMetricInput.value,options:this.algorithmOptions}}get paramsUI(){return this.funcParamsDiv}constructor(t){super(t);const e=this.tableInput.value.columns.numerical;this.activitiesInput=n.columnInput("Activities",this.tableInput.value,o.Utils.firstOrNull(e),null,{filter:t=>Array.from(e).includes(t)}),this.activitiesInputRoot=this.activitiesInput.root,this.similarityInput=n.intInput("Similarity cutoff",80),n.tooltip.bind(this.similarityInput.root,"Pairs of similar (cutoff is used) molecules with high difference in activity are considered 'cliffs'"),this.funcParamsDiv=n.inputs([this.tableInput,this.molColInput,this.activitiesInput,this.similarityInput,this.methodInput,this.methodSettingsDiv,this.similarityMetricInput],{style:{minWidth:"320px"}})}onTableInputChanged(t){super.onTableInputChanged(t),n.empty(this.activitiesInputRoot);const e=this.tableInput.value.columns.numerical;this.activitiesInput=n.columnInput("Activities",this.tableInput.value,o.Utils.firstOrNull(e),null,{filter:t=>Array.from(e).includes(t)}),Array.from(this.activitiesInput.root.children).forEach((t=>this.activitiesInputRoot.append(t)))}}var te,ee=s(8457);async function se(t,e,s,i){const n=(0,ee.O)(e),r=(0,l.vU)(e.getTag(o.TAGS.UNITS),e.getTag("separator"))(s),a=i===te.IDENTITY?function(t,e){const s=e.columns.length,i=new Array(s),n=new Array(s),r=new Array(s);for(let o=0;o<s;++o){const s=e.columns.byIndex(o);i[o]=s.getRawData(),n[o]=s.categories.indexOf(""),r[o]=s.categories.indexOf(t[o]??"")}const a=o.Column.float("Identity",e.rowCount),l=a.getRawData();for(let s=0;s<e.rowCount;++s){l[s]=0;for(let e=0;e<t.length;++e)i[e][s]===r[e]&&++l[s];l[s]/=t.length}return a}(r,n):i===te.SIMILARITY?await async function(t,e){const s=e.columns.toList();return await(0,q.Qx)(s,t)}(r,n):null;if(null===a)throw new Error(`In bio library: Unkown sequence scoring method: ${i}`);return a.name=t.columns.getUnusedName(a.name),t.columns.add(a),a}!function(t){t.IDENTITY="identity",t.SIMILARITY="similarity"}(te||(te={}));var ie,ne=function(t,e,s,i){return new(s||(s=Promise))((function(n,o){function r(t){try{l(i.next(t))}catch(t){o(t)}}function a(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?n(t.value):(e=t.value,e instanceof s?e:new s((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};class oe{constructor(t,e,s=!1,i){var o;this.name="",this.description="",this._isAutomatic=!1,this._autoStartFirstStep=!1,this._currentStep=0,this._isStopped=!1,this._isCancelled=!1,this._isStepProcessed=!1,this._root=n.div([],{id:"demo-script",classes:"tutorials-root tutorials-track demo-app-script"}),this._steps=[],this._mainHeader=n.panel([],"tutorials-main-header"),this._header=n.h2(""),this._headerDiv=n.divH([],"tutorials-root-header"),this._stopStartBtn=n.button(n.iconFA("pause"),(()=>this._changeStopState()),"Play / pause"),this._restartBtn=n.button(n.iconFA("redo"),(()=>this._restartScript()),"Restart"),this._nextStepBtn=n.button(n.iconFA("play"),(()=>{this._isStepProcessed||this._nextStep()}),"Next step"),this._activity=n.panel([],"tutorials-root-description"),this._progressDiv=n.divV([],"tutorials-root-progress"),this._progress=n.element("progress"),this._progressSteps=n.divText(""),this._closeBtn=n.button(n.iconFA("chevron-left"),(()=>this._closeDock()),"Back to demo"),this.name=t,this.description=e,this._isAutomatic=s,this._autoStartFirstStep=null!==(o=null==i?void 0:i.autoStartFirstStep)&&void 0!==o&&o,this._progress.max=0,this._progress.value=1,oe.currentObject=this}get steps(){return this._steps}get stepNumber(){return this._steps.length}_addHeader(){this._createHeaderDiv(),this._createProgressDiv(),this._mainHeader.append(this._headerDiv,this._progressDiv)}_createHeaderDiv(){this._header.innerText=this.name,this._headerDiv.append(this._closeBtn),this._headerDiv.append(this._header),this._nextStepBtn.firstChild.className="grok-icon fas fa-play",this._headerDiv.append(this._isAutomatic?this._stopStartBtn:this._nextStepBtn)}_createProgressDiv(){this._progress.max=this.stepNumber,this._progressDiv.append(this._progress),this._progressSteps=n.divText(`Step: ${this._progress.value} of ${this.stepNumber}`),this._progressDiv.append(this._progressSteps)}_addDescription(){var t;this._activity.append(n.div(this.description,"tutorials-root-description"));for(let e=0;e<this.stepNumber;e++){let s=n.iconFA("clock");this._isAutomatic||0===e&&(s=n.iconFA("play",(()=>this._nextStep()),"Next step"),s.className="grok-icon fas fa-play");const i=n.div(this._steps[e].name,"grok-tutorial-entry-instruction"),o=n.div(null===(t=this._steps[e].options)||void 0===t?void 0:t.description,"grok-tutorial-step-description hidden"),r=n.divH([s,i],"grok-tutorial-entry");this._activity.append(r,o)}}_initRoot(){var t,e,s;i.shell.windows.showContextPanel=!0,i.shell.windows.showHelp=!1;const n=Array.from(i.shell.dockManager.rootNode.children)[0];this._node=i.shell.dockManager.dock(this._root,o.DOCK_TYPE.FILL,n,""),(null===(e=null===(t=n.parent.container.containerElement.firstElementChild)||void 0===t?void 0:t.lastElementChild)||void 0===e?void 0:e.classList.contains("tab-handle-list-container"))&&(null===(s=n.parent.container.containerElement.firstElementChild)||void 0===s||s.lastElementChild.remove()),this._node.container.containerElement.classList.add("tutorials-demo-script-container"),this._addHeader(),this._root.append(this._mainHeader),this._addDescription(),this._root.append(this._activity)}_nextStep(){var t,e;return ne(this,void 0,void 0,(function*(){this._isStepProcessed=!0,this._isAutomatic||(this._nextStepBtn.classList.add("disabled"),this._nextStepBtn.firstChild.classList.add("fa-disabled"));const s=this._activity.getElementsByClassName("grok-tutorial-entry")[this._currentStep],i=this._activity.getElementsByClassName("grok-icon")[this._currentStep],o=this._activity.getElementsByClassName("grok-tutorial-step-description")[this._currentStep];i.className="grok-icon far fa-spinner-third fa-spin",o.classList.remove("hidden"),o.classList.add("visible");const r=s,a=(null===(t=this._steps[this._currentStep].options)||void 0===t?void 0:t.delay)?null===(e=this._steps[this._currentStep].options)||void 0===e?void 0:e.delay:2e3;yield this._steps[this._currentStep].func(),this._scrollTo(this._root,r.offsetTop-this._mainHeader.offsetHeight),this._isAutomatic&&(yield this._countdown(s,i,a),yield(0,zt.gw)(a));const l=n.iconFA("check");if(i.replaceWith(l),l.className="grok-icon far fa-check",this._progress.value++,this._progressSteps.innerText=`Step: ${this._progress.value} of ${this.stepNumber}`,this._currentStep++,this._isStepProcessed=!1,this._currentStep!==this.stepNumber){if(!this._isAutomatic){const t=this._activity.getElementsByClassName("grok-icon")[this._currentStep],e=n.iconFA("play",(()=>this._nextStep()),"Next step");e.className="grok-icon fas fa-play",t.replaceWith(e),this._nextStepBtn.classList.remove("disabled"),this._nextStepBtn.firstChild.classList.remove("fa-disabled")}}else this._isAutomatic?this._stopStartBtn.replaceWith(this._restartBtn):this._nextStepBtn.replaceWith(this._restartBtn)}))}_startScript(){return ne(this,void 0,void 0,(function*(){for(let t=this._currentStep;t<this.stepNumber&&!this._isStopped&&!this._isCancelled;t++)yield this._nextStep()}))}_scrollTo(t,e){t.focus(),t.scrollTop=e}_countdown(t,e,s){return ne(this,void 0,void 0,(function*(){const i=n.div([],"demo-script-countdown");e.classList.add("hidden");let o=s/1e3;const r=this._createSVGIndicator(o);i.append(r),t.prepend(i);const a=setInterval((()=>{o--,0===o&&(clearInterval(a),i.remove(),e.classList.remove("hidden"),e.classList.add("visible"))}),1e3)}))}_createSVGIndicator(t){const e=document.createElementNS("http://www.w3.org/2000/svg","svg"),s=document.createElementNS("http://www.w3.org/2000/svg","circle");return s.setAttributeNS(null,"cx","7"),s.setAttributeNS(null,"cy","7"),s.setAttributeNS(null,"r","6"),s.setAttributeNS(null,"style",`animation: countdown ${t}s linear infinite forwards`),e.append(s),e}_changeStopState(){const t=this._stopStartBtn.getElementsByClassName("grok-icon");t[0].className="grok-icon fas fa-play",this._isStopped=!this._isStopped,this._isStopped||(t[0].className="grok-icon fal fa-pause",this._isStepProcessed||this._startScript())}_restartScript(){i.shell.dockManager.close(this._node),i.shell.closeAll(),this._clearRoot(),this._setInitParams(),this.start()}_clearRoot(){this._root=n.div([],{id:"demo-script",classes:"tutorials-root tutorials-track demo-app-script"}),this._mainHeader=n.panel([],"tutorials-main-header"),this._header=n.h2(""),this._headerDiv=n.divH([],"tutorials-root-header"),this._activity=n.panel([],"tutorials-root-description"),this._progressDiv=n.divV([],"tutorials-root-progress"),this._progress=n.element("progress"),this._progressSteps=n.divText(""),this._progress.max=0,this._progress.value=1}_setInitParams(){this._currentStep=0,this._isStopped=!1,this._isCancelled=!1,this._stopStartBtn.getElementsByClassName("grok-icon")[0].className="grok-icon fal fa-pause",this._nextStepBtn.classList.remove("disabled")}_closeDock(){i.shell.dockManager.close(this._node),this.cancelScript()}cancelScript(){this._isCancelled=!0,oe.currentObject=null}step(t,e,s){return this._steps[this.steps.length]={name:t,func:e,options:s},this}start(){return ne(this,void 0,void 0,(function*(){this._initRoot(),i.shell.newView(this.name),this._isAutomatic?this._startScript():this._autoStartFirstStep&&(yield this._nextStep())}))}}function re(t){const e=t instanceof Error?t.message:t.toString(),s=t instanceof Error?t.stack:void 0;i.shell.error(e),Ke.logger.error(t.message,void 0,s)}oe.currentObject=null,function(t){t.X="Embed_X",t.Y="Embed_Y"}(ie||(ie={}));const ae="data/sample_FASTA_PT_activity.csv";var le=s(1811);async function he(){const t="Dendrogram",e=o.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()}async function ce(){return await i.functions.call("Dendrogram:getDendrogramService",{})}const ue="data/sample_FASTA_PT_activity.csv",me="sequence";var de=s(3336),ge=s.n(de);const pe="data/sample_FASTA_PT_activity.csv";var fe=s(8341);const ye="samples/HELM.csv";var be=s(2568),we=s(525);class Ce{constructor(t,e){this.urlParams=t,this.funcName=e}async init(t){this.df=t,await this.buildView()}async buildView(){const t=a()(this.urlParams.entries()).map((([t,e])=>`${t}=${encodeURIComponent(e)}`)).toArray().join("&");this.view=i.shell.addTableView(this.df),this.view.path=this.view.basePath=`func/${Ke.name}.${this.funcName}?${t}`;const e={sequenceColumnName:"sequence"};for(const[t,s]of this.urlParams.entries())switch(t){case G.bo.fixWidth:case G.bo.fitArea:e[t]=["1","on","true"].includes(s.toLowerCase());break;default:e[t]=s}const s=await this.view.dataFrame.plot.fromType("WebLogo",e);this.view.dockManager.dock(s,o.DOCK_TYPE.DOWN,null,"WebLogo",.35)}}class ve{get funcParams(){return{table:this.tableInput.value,sequence:this.seqColInput.value}}get paramsUI(){return this.funcParamsDiv}constructor(){this.tableInput=n.tableInput("Table",i.shell.tv.dataFrame,void 0,(()=>{this.onTableInputChanged()}));const t=this.tableInput.value.columns.bySemType(o.SEMTYPE.MACROMOLECULE),e={filter:t=>t.semType===o.SEMTYPE.MACROMOLECULE};this.seqColInput=n.columnInput("Sequence",this.tableInput.value,t,null,e),this.funcParamsDiv=n.inputs([this.tableInput,this.seqColInput],{style:{minWidth:"320px"}})}onTableInputChanged(){this.seqColInput=n.columnInput("Sequence",this.tableInput.value,this.tableInput.value.columns.bySemType(o.SEMTYPE.MACROMOLECULE))}}var Se=s(9416);class Te{constructor(t){this.monomerLib=t}getCappedRotatedMonomer(t,e){const s=this.monomerLib.getMonomer(t,e);return s?s.molfile:null}}const Me=new class{constructor(){this.tooltipHandlerTemp="tooltip-handler.Monomer"}},Ae={autoCrop:!0,autoCropMargin:0,suppressChiralText:!0};class Ee{constructor(t){this.gridCol=t,this.gridCol.grid.onCellTooltip(this.onCellTooltip.bind(this))}onCellTooltip(t,e,s){if(t.grid.dart!=this.gridCol.grid.dart||t.gridColumn.dart!=this.gridCol.dart||!t.tableColumn||!t.isTableCell)return!1;const o=t.tableColumn.getTag("alphabet"),r=t.cell.value,a="DNA"===o||"RNA"===o?"RNA":"PEPTIDE",l=new Te(Je().getBioLib()).getCappedRotatedMonomer(a,r),h=n.div(r),c=l?i.chem.svgMol(l,void 0,void 0,Ae):null,u=t.grid.canvas.getBoundingClientRect(),m=t.bounds.right+u.left-4,d=t.bounds.bottom+u.top-4;return n.tooltip.show(n.divV([h,...c?[c]:[]]),m,d),!0}static getOrCreate(t){let e=t.temp[Me.tooltipHandlerTemp];return e||(e=t.temp[Me.tooltipHandlerTemp]=new Ee(t)),e}}class xe extends o.GridCellRenderer{get name(){return S.Of.MONOMER}get cellType(){return S.Of.MONOMER}get defaultHeight(){return 15}get defaultWidth(){return 40}render(t,e,s,i,n,o,r){if(o.gridRow<0)return;Ee.getOrCreate(o.gridColumn),t.font="12px monospace",t.textBaseline="middle",t.textAlign="center";const a=(0,b.py)(o.cell.column.getTag("alphabet")),l=o.cell.value;if(!l)return;const h=a.get(l);t.fillStyle=h,t.fillText((0,b.GU)(l,6),e+i/2,s+n/2,i)}}class Ie extends Map{get onPropertyChanged(){return this._onPropertyChanged}get MaxMonomerLength(){return super.get("MaxMonomerLength")}set MaxMonomerLength(t){super.set("MaxMonomerLength",t),this._onPropertyChanged.next("MaxMonomerLength")}get TooltipWebLogo(){return super.get("TooltipWebLogo")}set TooltipWebLogo(t){super.set("TooltipWebLogo",t),this._onPropertyChanged.next("TooltipWebLogo")}get DefaultSeparator(){return super.get("DefaultSeparator")}set DefaultSeparator(t){if(1!==t.length)throw new Error("The separator must be of length one.");super.set("DefaultSeparator",t),this._onPropertyChanged.next("DefaultSeparator")}constructor(t){super(Object.entries(t)),this._onPropertyChanged=new O.Subject}}class Ne extends o.Package{constructor(){super(...arguments),this._initialized=!1}get properties(){return this._properties}set properties(t){this._properties=t}get initialized(){return this._initialized}completeInit(){this._initialized=!0}handleErrorUI(t){const e=t instanceof Error?t.message:t.toString(),s=t instanceof Error?t.stack:void 0;i.shell.error(e),this.logger.error(e,void 0,s)}}class Le extends o.Widget{constructor(t){super(n.div([],{}));const e=Object.assign({},...t.map((t=>({[t.name]:t}))));this.maxMonomerLengthProp=e.MaxMonomerLength,this.tooltipWebLogo=e.TooltipWebLogo,this.defaultSeparator=e.DefaultSeparator}async init(){const t=n.intInput("Max monomer length",Ke.properties.MaxMonomerLength,(t=>{Ke.properties.MaxMonomerLength=t})),e=n.boolInput("Tooltip WebLogo",Ke.properties.TooltipWebLogo,(t=>{Ke.properties.TooltipWebLogo=t})),s=n.choiceInput("Default Separator",Ke.properties.DefaultSeparator,[".","/","-"],(t=>{Ke.properties.DefaultSeparator=t}));this.root.appendChild(n.form([t,e,s]))}}var _e=s(5362),Re={};Re.styleTagTransform=ht(),Re.setAttributes=ot(),Re.insert=it().bind(null,"head"),Re.domAPI=et(),Re.insertStyleElement=at(),Q()(_e.Z,Re),_e.Z&&_e.Z.locals&&_e.Z.locals;class Oe extends o.Widget{constructor(t){super(n.divV([])),this.viewed=!1,this.seqCol=t}async init(){const t=C.Cn.getOrCreate(this.seqCol),e=Ke.properties.TooltipWebLogo,s=this.seqCol.getTag(k.DX.tooltipWebLogo);!1===e||["false","off","disable","disabled"].includes(s)||(this.wlViewer=await this.seqCol.dataFrame.plot.fromType("WebLogo",{sequenceColumnName:this.seqCol.name,backgroundColor:0,positionHeight:"Entropy",positionWidth:t.getAlphabetIsMultichar()?24:16,fixWidth:!0,fitArea:!1}),this.wlViewer.root.style.height="50px",this.root.appendChild(this.wlViewer.root),this.root.style.width="100%")}}const ke="PEPTIDE1{",Pe="}$$$$",Ge="<All>";function Fe(t){t.setTag("quality",o.SEMTYPE.MACROMOLECULE),t.setTag("aligned","SEQ"),t.setTag("alphabet","PT")}class He{constructor(t,e){this.helmColumn=t,this.leftTerminal=e.leftTerminal,this.rightTerminal=e.rightTerminal}transform(){return this.helmColumn.toList().map((t=>this.hasTerminals(t)?this.getTransformedHelm(t):t))}}class Ve extends He{constructor(t,e){super(t,e)}hasTerminals(t){return!!t.includes(this.rightTerminal+Pe)&&(this.leftTerminal===Ge||t.includes(ke+this.leftTerminal))}getLinkedPositions(t){return[1,Ue(t)]}getTransformedHelm(t){const e=this.getLinkedPositions(t);return Ze(t,{monomerPosition:e[0],attachmentPoint:1},{monomerPosition:e[1],attachmentPoint:3})}}class We extends He{constructor(t,e){super(t,e)}hasTerminals(t){return this.leftTerminal===Ge||this.rightTerminal===Ge||t.includes(ke+this.leftTerminal)&&t.includes(this.rightTerminal+Pe)}getLinkedPositions(t){return[1,Ue(t)]}getTransformedHelm(t){const e=this.getLinkedPositions(t);return Ze(t,{monomerPosition:e[0],attachmentPoint:1},{monomerPosition:e[1],attachmentPoint:2})}}class De extends He{constructor(t,e){super(t,e)}hasTerminals(t){return this.leftTerminal===Ge||this.rightTerminal===Ge||this.getLinkedPositions(t).every((t=>t>0))}getLinkedPositions(t){const e=t.replace(ke,"").replace(Pe,"").split("."),s=e.findIndex((t=>t===this.leftTerminal)),i=e.findIndex(((t,e)=>t===this.rightTerminal&&e>s));return[s+1,i+1]}getTransformedHelm(t){const e=this.getLinkedPositions(t);return Ze(t,{monomerPosition:e[0],attachmentPoint:3},{monomerPosition:e[1],attachmentPoint:3})}}class Be{constructor(){}static getInstance(t,e){const s=e.cyclizationType;return"R3-R3"===s?new De(t,e):"N-Cys"===s?new Ve(t,e):new We(t,e)}}function Ue(t){return t.replace(ke,"").replace(Pe,"").split(".").length}function Ze(t,e,s){return t.replace(Pe,`}$PEPTIDE1,PEPTIDE1,${e.monomerPosition}:R${e.attachmentPoint}-${s.monomerPosition}:R${s.attachmentPoint}${"$".repeat(6)}`)}async function Ye(t,e){const s=t.dataFrame,n=C.Cn.getOrCreate(t).convert(b.r2.HELM),r=Be.getInstance(n,e).transform(),a=s.columns.getUnusedName(`${e.transformationType}(`+t.name+")"),l=o.Column.fromList("string",a,r);Fe(l),l.setTag("units",b.r2.HELM),l.setTag("cell.renderer","helm"),s.columns.add(l),await i.data.detectSemanticTypes(s)}function ze(t,e,s,i){const n=C.Cn.getOrCreate(t);let o=null,r=null;for(let t=0;t<n.posList.length;++t)n.posList[t]==e&&(o=t),n.posList[t]==s&&(r=t);if(null===o&&null!==e)throw new Error(`Start position ${e} not found.`);if(null===r&&null!==s)throw new Error(`End position ${s} not found.`);if(n.posList.length<r)throw new Error(`End position ${r} exceeds positions length`);const a=i||`${t.name}: (${e??""}-${s??""})`;return n.getRegion(o,r,a)}const qe={df:o.DataFrame.fromCsv("seq,value\nATCCGTCGT,0.5\nTGTTCGTCA,0.4\nATGGTCGTA,0.7\nATCCGTGCA,0.1"),colName:"seq",positionNames:["1","1A","1C","2","4","4A","4B","5","6"].join(b.CI),regions:[{name:"first region",start:"1",end:"2"},{name:"second region",start:"1C",end:"4"},{name:"overlapping second",start:"1C",end:"4A"},{name:"whole sequence",start:"1",end:"6"},{name:"bad start",start:"0",end:"6"},{name:"bad end",start:"1",end:"4C"},{name:"bad start & end",start:"0",end:"4C"}]};class $e{constructor(t,e){this.urlParams=t,this.funcName=e}async init(t){this.data=t??qe;const e=this.data.df.getCol(this.data.colName);this.data.positionNames&&e.setTag(".positionNames",this.data.positionNames),this.data.regions&&e.setTag(".regions",JSON.stringify(this.data.regions)),await this.buildView()}async buildView(){await i.data.detectSemanticTypes(this.data.df),this.view=i.shell.addTableView(this.data.df),this.view.path=this.view.basePath=`func/${Ke.name}.${this.funcName}`;const t=await this.view.dataFrame.plot.fromType("WebLogo",{sequenceColumnName:this.data.colName});this.view.dockManager.dock(t,o.DOCK_TYPE.DOWN,null,"WebLogo",.35)}}class Xe{constructor(t){this.call=t,this.inputs=new class{},this.fixRegion=!1,this.defaultName=!0,this.defaultNameUpdating=!1;const e=t=>this.call.inputParams[t].property.description;this.inputs.table=n.tableInput("Table",this.call.inputParams.table.value??i.shell.tv.dataFrame,void 0,(()=>{}));const s=this.call.inputParams.sequence.value??this.inputs.table.value.columns.bySemType(o.SEMTYPE.MACROMOLECULE),r={filter:t=>t.semType===o.SEMTYPE.MACROMOLECULE};this.inputs.sequence=n.columnInput("Sequence",i.shell.tv.dataFrame,s,this.sequenceInputChanged.bind(this),r),this.inputs.start=n.choiceInput("Start",void 0,[],this.startInputChanged.bind(this)),this.inputs.end=n.choiceInput("End",void 0,[],this.endInputChanged.bind(this)),this.inputs.region=n.choiceInput("Region",null,[],this.regionInputChanged.bind(this)),this.inputs.name=n.stringInput("Column name",this.getDefaultName(),this.nameInputChanged.bind(this),{clearIcon:!0}),this.inputs.name.onInput(this.nameInputInput.bind(this));for(const t in this.call.inputParams)n.tooltip.bind(this.inputs[t].captionLabel,e(t));this.sequenceInputChanged()}sequenceInputChanged(){const t=this.inputs.sequence.value;t&&C.Cn.getOrCreate(t),this.updateRegionItems(),this.updateStartEndInputItems(),this.updateRegion(!0),this.updateNameInput()}regionInputChanged(){this.fixRegion=!0;try{const t=this.inputs.region.stringValue,e=t?JSON.parse(t):null;if(null!==e)this.inputs.start.value=e?.start,this.inputs.end.value=e?.end;else{const t=C.Cn.getOrCreate(this.inputs.sequence.value);this.inputs.start.value=t.posList[0],this.inputs.end.value=t.posList[t.posList.length-1]}}finally{this.fixRegion=!1}}startInputChanged(){this.updateRegion(!1),this.updateNameInput()}endInputChanged(){this.updateRegion(!1),this.updateNameInput()}nameInputChanged(){this.defaultNameUpdating||(this.defaultName=!1)}nameInputInput(){this.inputs.name.value||(this.defaultName=!0,this.inputs.name.input.focus())}updateStartEndInputItems(){const t=this.inputs.sequence.value,e=t?C.Cn.getOrCreate(t):null,s=this.inputs.start.input,i=this.inputs.end.input;for(let t=s.options.length-1;t>=0;--t)s.options.remove(t);for(let t=i.options.length-1;t>=0;--t)i.options.remove(t);for(const t of e?.posList??[]){const e=document.createElement("option"),n=document.createElement("option");e.text=n.text=t,e.value=n.value=t,s.options.add(e),i.options.add(n)}s.value=e?.posList[0]??"",i.value=e?.posList[e?.posList.length-1]??""}updateRegionItems(){const t=this.inputs.sequence.value,e=t?t.getTag(".regions"):null,s=e?JSON.parse(e):null,i=this.inputs.region.input;for(let t=i.options.length-1;t>=0;--t)i.options.remove(t);const n=document.createElement("option");if(n.text="",n.value=JSON.stringify(null),i.options.add(n),null!=s){this.inputs.region.root.style.removeProperty("display");for(const t of s){const e=document.createElement("option");e.text=`${t.name}: ${t.start}-${t.end}`,e.value=JSON.stringify(t),i.options.add(e)}}else this.inputs.region.root.style.display="none"}updateRegion(t){const e=this.inputs.start.stringValue??"",s=this.inputs.end.stringValue??"";if(!this.fixRegion){const t=this.inputs.region.input;t.selectedIndex=-1;for(let i=t.options.length-1;i>=0;--i){const n=t.options[i],o=JSON.parse(n.value);o&&e===o.start&&s===o.end&&(t.selectedIndex=i)}}}updateNameInput(){this.defaultNameUpdating=!0;try{this.defaultName&&(this.inputs.name.value=this.getDefaultName())}finally{this.defaultNameUpdating=!1}}getDefaultName(){const t=this.inputs.region.stringValue,e=t?JSON.parse(t):null,s=this.inputs.sequence.value,i=this.inputs.start.stringValue??"",n=this.inputs.end.stringValue??"";return null!=e?`${s.name}(${e.name}): ${e.start}-${e.end}`:`${s?.name}: (${i}-${n})`}getParams(){return{table:this.inputs.table.value,sequence:this.inputs.sequence.value,start:this.getStart(),end:this.getEnd(),name:this.getName()}}getStart(){return this.inputs.start.stringValue}getEnd(){return this.inputs.end.stringValue}getName(){const t=this.inputs.name.stringValue;return""==t?null:t}dialog(){const t=n.inputs(Object.values(this.inputs),{style:{minWidth:"320px"}});n.dialog({title:"Get Region"}).add(t).onOK((async()=>{(async()=>{const t=this.getParams();await this.call.func.prepare(t).call(!0)})().catch((t=>{Ke.handleErrorUI(t)}))})).show()}widget(){const t=n.inputs(Object.entries(this.inputs).filter((([t,e])=>!["table","sequence"].includes(t))).map((([t,e])=>e))),e=n.button("Get Region",(()=>{(async()=>{const t=this.getParams();await this.call.func.prepare(t).call(!0)})().catch((t=>{Ke.handleErrorUI(t)}))}));return o.Widget.fromRoot(n.divV([t,n.div(e)]))}}const Ke=new Ne,je="bypassLargeDataWarning";function Je(){return qt.NT.instance}let Qe=null;class ts{constructor(t){this._palette=t}get(t){return this._palette[t]}}async function es(){Ke.logger.debug("Bio: initBio(), started");const t=await i.functions.call("Chem:getRdKitModule");await Promise.all([(async()=>{await qt.NT.instance.loadLibraries()})(),(async()=>{const t=await Ke.getProperties(),e=new Ie(t);Ke.properties=e})()]).finally((()=>{Ke.completeInit()}));const e=qt.NT.instance.getBioLib(),s=[],n=[],o=e.getMonomerMolsByPolymerType("PEPTIDE");Object.keys(o).forEach((e=>{s.push(e);const i=o[e].replaceAll("#R","O "),r=t.get_mol(i),a=JSON.parse(r.get_descriptors()).CrippenClogP;n.push(a),r?.delete()}));const r=n.reduce(((t,e)=>t+e),0)/n.length||0,a={};for(let t=0;t<s.length;t++)a[s[t]]=n[t]<r?"#4682B4":"#DC143C";Qe=new ts(a),Ke.logger.debug("Bio: initBio(), completed")}function ss(t){const e=new Oe(t);return e.init().then((()=>{})).catch((t=>{const e=t instanceof Error?t.message:t.toString();i.shell.error(e)})),e}function is(){return qt.NT.instance.getBioLib()}function ns(t){const e="getRegionTopMenu",s=o.Func.find({package:Ke.name,name:e});if(1!==s.length)throw new Error(`Package '${Ke.name}' func '${e}' not found`);const i=s[0].prepare({table:t.dataFrame,sequence:t});return new Xe(i).widget()}async function os(t){return(0,qt.cf)()}function rs(t){try{new Xe(t).dialog()}catch(t){const e=t instanceof Error?t.message:t.toString(),s=t instanceof Error?t.stack:void 0;i.shell.error(`Get region editor error: ${e}`),Ke.logger.error(e,void 0,s)}}function as(t){const e=new ve;n.dialog({title:"Split to Monomers"}).add(e.paramsUI).onOK((async()=>t.func.prepare(e.funcParams).call(!0))).show()}function ls(t){const e=new Jt(o.SEMTYPE.MACROMOLECULE);n.dialog({title:"Sequence Space"}).add(e.paramsUI).onOK((async()=>t.func.prepare(e.funcParams).call())).show()}function hs(t){const e=new Qt(o.SEMTYPE.MACROMOLECULE);n.dialog({title:"Activity Cliffs"}).add(e.paramsUI).onOK((async()=>t.func.prepare(e.funcParams).call(!0))).show()}function cs(t){const e=new Le(t);return e.init().then(),e}function us(){return new I}function ms(t){return function(t){const e=Array.from(t.dataFrame.columns).filter((t=>t.semType===o.SEMTYPE.MOLECULE)).map((t=>t.name));new Set(e).delete(t.name);const s=n.choiceInput("Monomer width",null!=t?.temp["monomer-width"]?t.temp["monomer-width"]:f.short,[f.short,f.long],(e=>{t.temp["monomer-width"]=e,t.setTag(".mm.cellRenderer.settingsChanged",v.true),t.dataFrame.fireValuesChanged()}));s.setTooltip("In short mode, only the 'Max monomer length' characters are displayed, followed by .. if there are more");const i=parseInt(t.getTag(d.maxMonomerLength)),r=n.intInput("Max monomer length",isNaN(i)?Ke.properties.MaxMonomerLength:i,(e=>{t.setTag(d.maxMonomerLength,e.toString()),t.setTag(".mm.cellRenderer.settingsChanged",v.true),t.dataFrame.fireValuesChanged()}));r.setTooltip(`The max length of monomer name displayed without shortening in '${f.short}' monomer width mode.`);const a=n.intInput("Monomer margin",t.temp[".mm.cellRenderer.gapLength"]??0,(e=>{t.temp[".mm.cellRenderer.gapLength"]=e,t.setTag(".mm.cellRenderer.settingsChanged",v.true),t.dataFrame.fireValuesChanged()}));a.setTooltip("The size of margin between monomers (in pixels)");const l=n.boolInput("Color code",null==t?.temp["color-code"]||t.temp["color-code"],(e=>{t.temp["color-code"]=e,t.dataFrame.fireValuesChanged()}));l.setTooltip("Color code");const h=n.stringInput("Reference sequence",null!=t?.temp["reference-sequence"]?t?.temp["reference-sequence"]:"",(e=>{t.temp["reference-sequence"]=e,t.dataFrame.fireValuesChanged()}));h.setTooltip("Reference sequence is not empty, then the sequence will be render \nas a difference from the reference sequence");const c=n.boolInput("Compare with current",null==t?.temp["compare-with-current"]||t.temp["compare-with-current"],(e=>{t.temp["compare-with-current"]=e,t.dataFrame.fireValuesChanged()}));c.setTooltip('When on, all sequences get rendered in the "diff" mode');const u=n.inputs([s,r,a,h,l,c]);return new o.Widget(u)}(t)}function ds(t){return function(t){const e=n.div();e.classList.add("macromolecule-cell-comp-analysis-host");const s=t.cell.column.tags.alphabet;let i=w.UE.Color;switch(s){case"DNA":case"RNA":i=(0,b.py)("DNA");break;case"PT":i=(0,b.py)("PT")}const r=new Map;let l=0;const h=C.Cn.getOrCreate(t.cell.column).getSplitter()(t.value),c=h.length;a()(h).filter((t=>!!t&&""!==t)).forEach((t=>{const e=r.get(t)||0;r.set(t,e+1),l=Math.max(l,e+1)})),l/=c;const u={},m=Array.from(r.entries());m.sort(((t,e)=>e[1]-t[1])),m.forEach((([t,e])=>{const s=e/c,o=i.get(t),r=n.div("",{classes:"macromolecule-cell-comp-analysis-bar"});r.style.width=s/l*50+"px";const a=n.div((100*s).toFixed(2)+"%");r.style.backgroundColor=o,u[t]=n.div([r,a],{classes:"macromolecule-cell-comp-analysis-value"})}));const d=n.tableFromMap(u);return Array.from(d.rows).forEach((t=>{const e=t.getElementsByClassName("macromolecule-cell-comp-analysis-bar")[0].style.backgroundColor;t.cells[0].style.color=e})),e.appendChild(d),new o.Widget(e)}(t)}function gs(){return new I}function ps(){return new N}function fs(t,e,s,i,n){const o=new B.k(i,n,s,e);return"Local alignment"==t?o.smithWaterman():o.needlemanWunch()}function ys(){return new G.OZ}function bs(){return new D}function ws(t,e,s,i){return ze(t,e??null,s??null,i??null)}async function Cs(t,e,s,n,o){const r=ze(e,s??null,n??null,o??null);e.dataFrame.columns.add(r),await i.data.detectSemanticTypes(e.dataFrame)}async function vs(t,e,r,a,l,h){if(!(0,be.n)(e,"Activity Cliffs"))return;const c=K(t),u={units:e.getTag(o.TAGS.UNITS),aligned:e.getTag("aligned"),separator:e.getTag("separator"),alphabet:e.getTag("alphabet")},m=C.Cn.getOrCreate(e);let d=Mt.gk.Tanimoto,g=e;if(m.isFasta()||m.isSeparator()&&m.alphabet&&"UN"!==m.alphabet)if(m.isFasta())d=m.getDistanceFunctionName();else{g=m.convert(b.r2.FASTA);const t=C.Cn.getOrCreate(g);d=t.getDistanceFunctionName(),u.units=b.r2.FASTA}const p=async()=>await async function(t,e,r,a,l,h,c,u,m,d,g,p,f,y,b,w,C,v){gt++;const S=c/100,T=r??e;let M=!1,A=!1;const E={};let x,I;const N={seqCol:T,methodName:m,similarityMetric:u,embedAxesNames:a,options:C},{distance:L,coordinates:_}=await p(N);for(const e of _)t.columns.add(e);let R=L;const O=Object.values($.U).map((t=>t.toString())).includes(u);O&&!L&&(R=mt.H.calc(e.toList(),$.o[u]()).data);const k=function(t,e,s){const i=[],n=[],o=[],r=[],a=new Set;for(let l=0;l!=t.length;++l)for(let h=0;h!=t.length-l;++h){const c=t[l]?t[l].get(h):0;if(c>=e){o.push(l),r.push(l+h+1),a.add(l),a.add(l+h+1),i.push(c);const t=Math.abs(s.get(l)-s.get(l+h+1));n.push(1!=c?t/(1-c):1/0)}}return{simVals:i,saliVals:n,n1:o,n2:r,cliffsMolIds:a}}(await async function(t,e,s,i){const n=t.categories,r=t.getRawData(),a=o.Column.string("seq",t.length).init((t=>n[r[t]])),l=o.DataFrame.fromColumns([a]),h=t.length;let c=Array(h-1);return s&&e?function(t,e,s){const i=(0,dt.y)(t);for(let n=0;n<t-1;++n){const r=new Float32Array(t-n-1).fill(0);for(let s=n+1;s<t;++s){const t=i(n,s);r[s-n-1]=e[t]===o.FLOAT_NULL?0:(0,j.Om)(e[t])}s[n]=o.Column.fromFloat32Array("similarity",r)}}(h,e,c):c=await i(h,t,l,"seq",c),c}(T,R,O,f),S,h),P=function(t,e,s,i,n,r){const a=new Array(t).fill(0);for(let t=0;t!=s.length;++t)e[t]!=1/0&&(r.get(s[t])>r.get(i[t])?a[s[t]]+=e[t]:a[i[t]]+=e[t]);return o.Column.fromList("double",`sali_${n[0].substring(n[0].lastIndexOf("_"))}`,a)}(T.length,k.saliVals,k.n1,k.n2,a,h);t.columns.add(P);const G=function(t,e){const s="containsCliff",i=t.columns.names().filter((t=>t.includes(s))).length+1,n=`${s}_${i}`;return o.Column.bool(n,t.rowCount).init((t=>e.has(t)))}(t,k.cliffsMolIds);t.columns.add(G);const F=function(t){const e=t.filter((t=>t!==1/0)),s=Math.min(...e);return{max:Math.max(...e),min:s}}(k.saliVals),H=.8/(F.max-F.min),V=i.shell.getTableView(t.name);V.grid.columns.byName(G.name).visible=!1;const W=V.addViewer(o.VIEWER.SCATTER_PLOT,{xColumnName:a[0],yColumnName:a[1],size:P.name,color:h.name,showXSelector:!1,showYSelector:!1,showSizeSelector:!1,showColorSelector:!1,markerMinSize:5,markerMaxSize:25,title:l}),D=W.getInfo().canvas,B=function(t,e,s,i,n){const r=new Array(t.n1.length).fill(null);for(let e=0;e<t.n1.length;e++){const s=t.n1[e],i=t.n2[e];r[e]={id:e,mols:[s,i],selected:!1,a:[],b:[]}}const a=o.DataFrame.create(r.length);return vt.forEach(((t,s)=>{a.columns.addNewString(t).init((t=>e.get(r[t].mols[s]))),function(t,e){Object.keys(e).forEach((s=>{t.tags[s]=e[s]}))}(a.col(t),n),a.col(t).semType=i})),a.columns.addNewFloat(yt).init((t=>Math.abs(s.get(r[t].mols[0])-s.get(r[t].mols[1])))),a.columns.addNewInt(Ct).init((t=>t)),a.columns.addNewFloat(bt).init((e=>t.saliVals[e])),a.columns.addNewFloat(wt).init((e=>t.simVals[e])),a.name=`${pt}${gt}`,{lines:r,linesDf:a}}(k,e,h,d,g),U=w?w(B.linesDf,vt).sort([bt],[!1]):B.linesDf.plot.grid().sort([bt],[!1]);t.temp[".cliffsDfGrid"]=U;const Z=n.button(`${B.linesDf.rowCount} cliffs`,(()=>{V.dockManager.dock(U,"down",null,"Activity cliffs",v??.2)}));Z.classList.add("scatter_plot_link","cliffs_grid"),W.root.append(Z);const Y=n.switchInput("Show only cliffs",!1,(()=>{Y.value?(W.dataFrame.setTag(St,G.name),t.rows.match({[G.name]:!0}).filter(),ft.next(G.name)):(W.dataFrame.setTag(St,""),t.filter.setAll(!0,!0),ft.next(""))}));Y.root.classList.add("scatter_plot_link","show_only_cliffs"),W.root.append(Y.root),ft.subscribe((t=>{Y.enabled=""===t||t===G.name}));const z=i.events.onViewerClosed.subscribe((t=>{t.args.viewer===W&&(V.dockManager.close(U.root),z.unsubscribe(),V.subs=V.subs.filter((t=>t!==z)))}));return V.subs.push(z),B.linesDf.onCurrentCellChanged.subscribe((()=>{M=!0;const s=B.linesDf.currentCol&&B.linesDf.currentCol.name===vt[1]?1:0,o=-1!==B.linesDf.currentRowIdx?B.lines[B.linesDf.currentRowIdx]:null;W.dataFrame.currentRowIdx=o?o.mols[s]:-1,W.dataFrame.filter.set(0,!B.lines[0].selected),W.dataFrame.filter.set(0,B.lines[0].selected),o&&setTimeout((()=>{!function(t,e,s,o,r,a,l,h){const c=e.getPane("Cliff Details");n.empty(c.root);const u=h({cashedData:s,line:o,df:t,seqCol:r,activityCol:a,sali:l});c.root.append(u),setTimeout((()=>{i.shell.o=e.root}),500)}(t,x,E,o,e,h,B.linesDf.get(bt,o.id),b);const s=W.dataFrame.getSortedOrder(V.grid.sortByColumns,V.grid.sortTypes);V.grid.scrollToCell(e.name,s.indexOf(W.dataFrame.currentRowIdx))}),1e3)})),B.linesDf.onSelectionChanged.subscribe((e=>{if(!1===B.linesDf.selection.anyTrue)B.lines.forEach((t=>{t.selected=!1}));else if(-1!==B.linesDf.mouseOverRowIdx){const t=B.lines[B.linesDf.mouseOverRowIdx];t.selected=!t.selected}setTimeout((()=>{const e=o.BitSet.create(t.rowCount);B.lines.forEach((t=>{t.selected&&t.mols.forEach((s=>{e.set(s,t.selected,!0)}))})),t.selection.copyFrom(e),V.grid.invalidate()}),300)})),t.onSelectionChanged.subscribe((e=>{A?A=!1:!1===t.selection.anyTrue&&"number"==typeof e&&(B.lines.forEach((t=>{t.selected=!1})),U.dataFrame.selection.setAll(!1,!1),U.invalidate())})),D.addEventListener("mousemove",(function(i){clearTimeout(I),I=s.g.setTimeout((function(){const s=Tt(i,D,B.lines);s&&-1===t.mouseOverRowIdx&&n.tooltip.show(y({cashedData:E,line:s,df:t,seqCol:e,activityCol:h}),i.clientX,i.clientY)}),500)})),D.addEventListener("mousedown",(function(e){A=!0;const s=Tt(e,D,B.lines);if(s&&-1===t.mouseOverRowIdx){e.ctrlKey?(s.selected=!s.selected,B.linesDf.selection.set(s.id,s.selected)):B.linesDf.currentRowIdx!==s.id&&(B.linesDf.currentRowIdx=s.id,t.currentRowIdx=s.mols[0],t.filter.set(0,!B.lines[0].selected),t.filter.set(0,B.lines[0].selected));const i=B.linesDf.getSortedOrder(U.sortByColumns,U.sortTypes);U.scrollToCell(vt[0],i.indexOf(s.id))}})),W.onEvent("d4-before-draw-scene").subscribe((e=>{const s=function(t,e,s,i,n,o,r){const a=i.lines,l=t.getInfo().canvas.getContext("2d"),h=t.dataFrame.columns.byName(e),c=t.dataFrame.columns.byName(s);for(let e=0;e<a.length;e++){const s=t.worldToScreen(h.get(a[e].mols[0]),c.get(a[e].mols[0])),u=t.worldToScreen(h.get(a[e].mols[1]),c.get(a[e].mols[1]));a[e].a=[s.x,s.y],a[e].b=[u.x,u.y];const m=new Path2D;m.moveTo(a[e].a[0],a[e].a[1]);const d=a[e].selected?"255,255,0":"0,128,0",g=n[e]===1/0?1:.2+(n[e]-r)*o;l.strokeStyle=`rgba(${d},${g})`,l.lineWidth=a[e].id===i.linesDf.currentRowIdx?3:1,m.lineTo(a[e].b[0],a[e].b[1]),l.stroke(m)}return a}(W,a[0],a[1],B,k.saliVals,H,F.min);if(M){const t=s[B.linesDf.currentRowIdx];setTimeout((()=>{const{zoomLeft:e,zoomRight:s,zoomTop:i,zoomBottom:n}=function(t,e,s,i,n,o){const r=Math.abs(s-n),a=Math.abs(i-o),l=t/r,h=e/a,c=Math.min(l,h),u=t/c*5,m=e/c*5,d=(s<n?s:n)+r/2-u/2,g=(i>o?i:o)-a/2+m/2;return{zoomLeft:d,zoomRight:d+u,zoomTop:g,zoomBottom:g-m}}(W.viewport.width,W.viewport.height,W.dataFrame.get(a[0],t.mols[0]),W.dataFrame.get(a[1],t.mols[0]),W.dataFrame.get(a[0],t.mols[1]),W.dataFrame.get(a[1],t.mols[1]));W.zoom(e,i,s,n)}),300),M=!1}Y.value?t.rows.match({[G.name]:!0}).filter():!0===Y.enabled&&t.filter.setAll(!0,!1)})),W.addProperty("similarityLimit","double",S),x=function(){const t=n.accordion(),e=n.element("i");return e.className="grok-icon svg-icon svg-view-layout",t.addTitle(n.span([e,n.label("Activity cliffs")])),t.addPane("Cliff Details",(()=>n.divText("Cliff has not been selected")),!0),i.shell.o=t.root,t}(),W}(t,g,null,c,"Activity cliffs",r,a,d,l,o.SEMTYPE.MACROMOLECULE,u,X,At,Et,xt,_t,h),f=l===$t.AL.UMAP?5e3:2e3;if(t.rowCount>2e4)i.shell.warning("Too many rows, maximum for sequence activity cliffs is 20000");else{if(!(t.rowCount>f)||h?.[je])return await p();n.dialog().add(n.divText("Activity cliffs analysis might take several minutes.\n Do you want to continue?")).onOK((async()=>{const t=o.TaskBarProgressIndicator.create("Running sequence activity cliffs ..."),e=await p();return t.close(),e})).show()}}async function Ss(t,e,s,r=$.U.LEVENSHTEIN,a,l,h){if(await(0,zt.gw)(10),!(0,be.n)(e,"Sequence space"))return;let c;const u=o.TaskBarProgressIndicator.create("Initializing sequence space ...");try{function m(e,s,n){let r=null,l=null;t.columns.names().includes(d[0])?(r=t.columns.byName(d[0]),l=t.columns.byName(d[1])):(r=t.columns.add(o.Column.float(d[0],t.rowCount)),l=t.columns.add(o.Column.float(d[1],t.rowCount)),a&&(c=i.shell.tableView(t.name).scatterPlot({x:d[0],y:d[1],title:"Sequence space"}))),r.init((t=>n[t]?n[t][0]:void 0)),l.init((t=>n[t]?n[t][1]:void 0));const h=e/s*100;u.update(h,`Running sequence space ... ${h.toFixed(0)}%`)}const d=K(t),g=o.DataFrame.fromColumns([e]).clone(),p=function(t,e){const s=e.categories.map(((t,e)=>t?null:e)).filter((t=>null!==t)),i=[...e.getRawData()],n=[];let o=0;for(let e=0;e<t.rowCount;e++)s.includes(i[e])&&(t.rows.removeAt(e-o),n.push(e),o+=1);return n}(g,e),f={seqCol:g.col(e.name),methodName:s,similarityMetric:r,embedAxesNames:d,options:{...h,sparseMatrixThreshold:l??.8,usingSparseMatrix:t.rowCount>2e4}},y=s===$t.AL.UMAP?1e5:15e3,b=s===$t.AL.UMAP?5e3:2e3;if(t.rowCount>y)return void i.shell.warning(`Too many rows, maximum for sequence space is ${y}`);async function w(){let t=null;const e=i.events.onViewerClosed.subscribe((s=>{const n=s.args.viewer;n?.getOptions()?.look?.title&&c?.getOptions()?.look?.title&&n?.getOptions()?.look?.title===c?.getOptions()?.look?.title&&(i.events.fireCustomEvent(Z,{}),e.unsubscribe(),t?.(),u.close())})),s=new Promise((async e=>{t=e,e(await X(f,h?.[je]?void 0:m))})),n=await s;return u.close(),e.unsubscribe(),n?C(n):n}if(!(t.rowCount>b)||h?.[je])return await w();function C(e){const s=e.coordinates;for(const e of s){const s=e.toList();p.forEach((t=>s.splice(t,0,null)));let i=t.columns.byName(e.name);i||(i=o.Column.float(e.name,s.length),t.columns.add(i)),i.init((t=>s[t]))}if(a)return c||(c=i.shell.tableView(t.name).scatterPlot({x:d[0],y:d[1],title:"Sequence space"})),c}n.dialog().add(n.divText("Sequence space analysis might take several minutes.\n Do you want to continue?")).onOK((async()=>{await w()})).onCancel((()=>{u.close()})).show()}catch(v){console.error(v),u.close()}}async function Ts(t,e){if(0===o.Func.find({package:"Chem",name:"getRdKitModule"}).length)return void i.shell.warning('Transformation to atomic level requires package "Chem" installed.');if(!(0,be.n)(e,"To Atomic Level"))return;const s=(await Je()).getBioLib(),r=await(0,Ot.i0)(t,e,s);null!==r.col&&(t.columns.add(r.col,!0),await i.data.detectSemanticTypes(t)),r.warnings&&r.warnings.length>0&&i.shell.warning(n.list(r.warnings))}function Ms(){(0,we.K)()}async function As(t=null,e=null){return(0,we.K)({col:t,clustersCol:e})}async function Es(){const t=i.shell.tv,e=t.dataFrame.columns.toList().filter((t=>t.semType==o.SEMTYPE.MACROMOLECULE&&(C.Cn.getOrCreate(t),!0))),s=async e=>{if(!(0,be.n)(e,"Composition"))return;const s=t.addViewer("WebLogo",{sequenceColumnName:e.name});i.shell.tv.dockManager.dock(s,o.DOCK_TYPE.DOWN,null,"Composition analysis",.25)};let r=null;if(0!=e.length){if(e.length>1){const t=e.map((t=>t.name)),i=e.find((t=>C.Cn.getOrCreate(t).isMsa())),o=n.choiceInput("Column",i?i.name:t[0],t);n.dialog({title:"Composition Analysis",helpUrl:"/help/domains/bio/macromolecules.md#composition-analysis"}).add(n.div([o])).onOK((async()=>{const t=e.find((t=>t.name==o.value))??null;t&&await s(t)})).show()}else r=e[0];r&&await s(r)}else i.shell.error("Current table does not contain sequences")}function xs(t){return new kt.i(t).importFasta()}function Is(t){return console.log(t),[]}function Ns(){const t=(0,Ft.B)()[0];(0,Rt.O)(t)}function Ls(){return new xe}async function _s(t){const e=o.TaskBarProgressIndicator.create("Test detectMacromolecule..."),s=(await i.dapi.files.list(t,!0,"")).filter((t=>t.fileName.endsWith(".csv")));let n=0;const r=[];for(const a of s)try{const e=await i.dapi.files.readAsText(t+a.fullPath),s=o.DataFrame.fromCsv(e);for(const t of s.columns)await i.functions.call("Bio:detectMacromolecule",{col:t})===o.SEMTYPE.MACROMOLECULE&&r.push({file:a.path,result:"detected",column:t.name,message:`units: ${t.getTag(o.TAGS.UNITS)}`})}catch(t){r.push({file:a.path,result:"error",column:null,message:t instanceof Error?t.message:t.toString()})}finally{n+=1,e.update(100*n/s.length,`Test ${a.fileName}`)}i.shell.info("Test Demo:Files for detectMacromolecule finished."),e.close();const a=o.DataFrame.fromObjects(r);return a.name=`datasets_detectMacromolecule_${t}`,a}async function Rs(t,e){await(0,Se.n)(t,e)}function Os(t){const e=C.Cn.getOrCreate(t).stats;return Object.keys(e.freq)}function ks(){return new Dt}function Ps(){const t=i.shell.v,e=t.addViewer("Sequence Similarity Search");t.dockManager.dock(e,"down")}function Gs(){return new Ut}function Fs(){const t=i.shell.v,e=t.addViewer("Sequence Diversity Search");t.dockManager.dock(e,"down")}function Hs(t){const e=(0,Ft.B)();1===e.length?t.func.prepare({macromolecules:e[0]}).call(!0):new z.uH(e)}function Vs(t){i.shell.tv.getFiltersGroup({createDefaultFilters:!1}).updateOrAdd({type:"Bio:bioSubstructureFilter",column:t.name,columnName:t.name}),i.shell.tv.grid.scrollToCell(t,0)}async function Ws(t,e,s){return se(t,e,s,te.IDENTITY)}async function Ds(t,e,s){return se(t,e,s,te.SIMILARITY)}function Bs(){(0,Zt.C2)()}function Us(){return new Yt.ST}async function Zs(){const t=o.TaskBarProgressIndicator.create("WebLogo");try{const t=new URLSearchParams(window.location.search),e=new Ce(t,"webLogoLargeApp"),s=await Ke.files.readCsv("data/sample_PT_100000x5.csv");await i.data.detectSemanticTypes(s),await e.init(s)}finally{t.close()}}async function Ys(){const t=o.TaskBarProgressIndicator.create("getRegion ...");try{const t=new URLSearchParams(window.location.search),e=new $e(t,"getRegionApp");await e.init()}finally{t.close()}}async function zs(){const t=o.TaskBarProgressIndicator.create("getRegion ...");try{const t=new URLSearchParams(window.location.search),e=await Ke.files.readCsv("data/sample_HELM_empty_vals.csv"),s=new $e(t,"getRegionHelmApp");await s.init({df:e,colName:"HELM"})}finally{t.close()}}function qs(t,e){!function(t,e){const s=C.Cn.getOrCreate(t.column),n=Object.values(b.r2).filter((t=>t!==s.units));e.group("Copy").items(n,(e=>{const s=C.Cn.getOrCreate(t.column),n=e===b.r2.SEPARATOR?Ke.properties.DefaultSeparator:void 0,o=s.getConverter(e,n)(t.value);navigator.clipboard?(navigator.clipboard.writeText(o),i.shell.info(`Value of notation '${e}' copied to clipboard`)):i.shell.warning("The clipboard functionality requires a secure origin — either HTTPS or localhost")}))}(t,e)}async function $s(){await async function(){let t,e;try{const s=new oe("Similarity, Diversity","Sequence similarity tracking and evaluation dataset diversity");await s.step("Load DNA sequences",(async()=>{i.shell.windows.showContextPanel=!1,i.shell.windows.showProperties=!1,e=await Ke.files.readCsv(ae),t=i.shell.addTableView(e),t.grid.columns.byName("cluster").visible=!1,t.grid.columns.byName("sequence_id").visible=!1,t.grid.columns.byName("sequence").width=300,t.grid.columns.byName("activity").visible=!1,t.grid.columns.byName("is_cliff").visible=!1}),{description:"Load dataset with macromolecules of 'fasta' notation, 'DNA' alphabet.",delay:2e3}).step("Find the most similar sequences to the current one",(async()=>{const s=await e.plot.fromType("Sequence Similarity Search",{moleculeColumnName:"sequence",similarColumnLabel:"Similar to current"});t.dockManager.dock(s,o.DOCK_TYPE.RIGHT,null,"Similarity search",.35)}),{description:"Add 'Sequence Similarity Search' viewer.",delay:2e3}).step("Explore most diverse sequences in a dataset",(async()=>{const s=await e.plot.fromType("Sequence Diversity Search",{moleculeColumnName:"sequence",diverseColumnLabel:"Top diverse sequences of all data"});t.dockManager.dock(s,o.DOCK_TYPE.DOWN,null,"Diversity search",.27)}),{description:"Add 'Sequence Deversity Search' viewer.",delay:2e3}).step("Choose another sequence for similarity search",(async()=>{e.currentRowIdx=3}),{description:"Handling current row changed of data frame showing update of similar sequences.",delay:2e3}).step("One more sequence for similarity search",(async()=>{e.currentRowIdx=7}),{description:"Just one more sequence to search similar ones.",delay:2e3}).start()}catch(t){re(t)}}()}async function Xs(){await async function(){let t,e,s,n,r;try{const a=new oe("Sequence Space","Exploring sequence space of Macromolecules, comparison with hierarchical clustering results");await a.step("Load DNA sequences",(async()=>{[n,t,e]=await Promise.all([Ke.files.readCsv(ue),he(),ce()]),s=i.shell.addTableView(n),s.grid.props.rowHeight=22,s.grid.columns.byName("cluster").visible=!1,s.grid.columns.byName("sequence").width=200,s.grid.columns.byName("is_cliff").visible=!1,i.shell.windows.showContextPanel=!1,i.shell.windows.showProperties=!1}),{description:"Load dataset with macromolecules of 'fasta' notation, 'DNA' alphabet.",delay:2e3}).step("Build sequence space",(async()=>{r=await async function(t,e,s,i){let n;{const t=Object.values(ie);for(let s=0;s<t.length;s++){const i=t[s];if(!e.col(i)){const n=s==t.length-1;e.columns.add(o.Column.float(i,e.rowCount),n)}}if(e.rowCount>=1){const i=e.getCol(s).toList(),n=Date.now();Ke.logger.debug("Bio: demoBio01aUI(), calc reduceDimensionality start...");const o=await Y(i,"UMAP",Mt.W.Levenshtein,{}),r=Date.now();Ke.logger.debug(`Bio: demoBio01aUI(), calc reduceDimensionality ET: ${(r-n)/1e3} s`);for(let s=0;s<t.length;s++){const i=t[s],n=e.getCol(i),r=o.embedding[s];n.init((t=>r[t]))}const a=Date.now();Ke.logger.debug(`MLB: MlbVrSpaceBrowser.buildView(), postprocess reduceDimensionality ET: ${(a-r)/1e3} s`)}n=await e.plot.fromType(o.VIEWER.SCATTER_PLOT,{xColumnName:ie.X,yColumnName:ie.Y,lassoTool:!0})}return t.dockManager.dock(n,o.DOCK_TYPE.RIGHT,null,"Sequence Space",.35),n}(s,n,me)}),{description:"Reduce sequence space dimensionality to display on 2D representation.",delay:2e3}).step("Cluster sequences",(async()=>{const i=n.getCol(me).toList(),o=mt.H.calc(i,((t,e)=>le.T(t,e)/((t.length+e.length)/2))),r=await t.hierarchicalClusteringByDistance(o,"ward");e.injectTreeForGrid(s.grid,r,void 0,150,void 0)}),{description:"Perform hierarchical clustering to reveal relationships between sequences.",delay:2e3}).step("Select a sequence",(async()=>{n.selection.init((t=>[15].includes(t)))}),{description:"Handling selection of data frame row reflecting on linked viewers.",delay:2e3}).step("Select a bunch of sequences",(async()=>{const t=n.getCol("sequence_id");n.selection.init((e=>["c0_seq120","c0_seq105","c0_seq121","c0_seq93"].includes(t.get(e)))),n.currentRowIdx=27}),{description:"Selecting a group of rows from a data frame to show their similarity and proximity to each other on a viewer..",delay:2e3}).start()}catch(t){re(t)}}()}async function Ks(){await async function(){let t,e,s,n,r;const a=$t.AL.UMAP;try{const l=new oe("Activity Cliffs","Activity Cliffs analysis on Macromolecules data");await l.step("Load DNA sequences",(async()=>{i.shell.windows.showContextPanel=!1,i.shell.windows.showProperties=!1,[s,t,e]=await Promise.all([Ke.files.readCsv(pe),he(),ce()]),n=i.shell.addTableView(s),n.grid.props.rowHeight=22,n.grid.columns.byName("cluster").visible=!1,n.grid.columns.byName("sequence").width=300,n.grid.columns.byName("is_cliff").visible=!1}),{description:"Load dataset with macromolecules of 'fasta' notation, 'DNA' alphabet.",delay:2e3}).step("Find activity cliffs",(async()=>{r=await vs(s,s.getCol("Sequence"),s.getCol("Activity"),80,a),n.dockManager.dock(r,o.DOCK_TYPE.RIGHT,null,"Activity Cliffs",.35),ge()(r.root).find("button.scatter_plot_link,cliffs_grid").get()[0].click()}),{description:"Reveal similar sequences with a cliff of activity.",delay:2e3}).step("Cluster sequences",(async()=>{const i=o.TaskBarProgressIndicator.create("Running sequence clustering..."),r=s.getCol("sequence").toList(),a=mt.H.calc(r,((t,e)=>le.T(t,e)/((t.length+e.length)/2))),l=await t.hierarchicalClusteringByDistance(a,"ward");i.close(),e.injectTreeForGrid(n.grid,l,void 0,150,void 0),n.grid.columns.byName("Activity").scrollIntoView()}),{description:"Perform hierarchical clustering to reveal relationships between sequences.",delay:2e3}).step("Browse the cliff",(async()=>{const t=r.dataFrame.temp[".cliffsDfGrid"];t.dataFrame.rowCount>0&&(t.dataFrame.currentRowIdx=0)}),{description:"Zoom in to explore selected activity cliff details.",delay:2e3}).start()}catch(t){re(t)}}()}async function js(){await async function(){const t="HELM";let e,s,r;try{await new oe("Atomic Level","Atomic level structure of Macromolecules").step("Loading Macromolecules notation 'Helm'",(async()=>{i.shell.windows.showContextPanel=!1,i.shell.windows.showProperties=!1,e=await Ke.files.readCsv("samples/HELM.csv"),s=i.shell.addTableView(e);for(let e=0;e<s.grid.columns.length;e++){const i=s.grid.columns.byIndex(e);[t,"Activity"].includes(i.name)||(i.visible=!1)}}),{description:"Load dataset with macromolecules of 'fasta' notation, 'PT' alphabet (protein, aminoacids).",delay:2e3}).step("To atomic level",(async()=>{const s=e.getCol(t);await Ts(e,s)}),{description:"Get atomic level structures of Macromolecules.",delay:2e3}).step("Sketcher",(async()=>{const s=`molfile(${t})`;e.currentCell=e.cell(1,s);const i=e.currentCell.value,a=new o.chem.Sketcher(o.chem.SKETCHER_MODE.INPLACE);a.setMolFile(i),r=n.dialog().add(a).show(),await(0,zt.gw)(3e3),r.close()}),{description:"Display atomic level structure within a sketcher.",delay:2e3}).start()}catch(t){re(t)}}()}async function Js(){await async function(){let t,e,s,n,r,a;const l="msa(HELM)",h=$t.AL.UMAP;try{const c=new oe("Helm, MSA, Sequence Space","MSA and composition analysis on Helm data");await c.step("Load peptides with non-natural aminoacids in 'HELM' notation",(async()=>{t=i.shell.addTableView(e=await Ke.files.readCsv(ye)),i.shell.windows.showContextPanel=!1,i.shell.windows.showProperties=!1}),{description:"Load dataset with macromolecules of 'Helm' notation.",delay:2e3}).step("Align peptides with non-natural aminoacids with PepSeA",(async()=>{s=e.getCol("HELM");const t=fe.J[0];n=await(0,fe.f)(s,l,t,1.53,0,void 0),e.columns.add(n),await i.data.detectSemanticTypes(e)}),{description:"Multiple sequence alignment (MSA) performed with PepSeA tool operating on non-natural aminoacids as well.",delay:2e3}).step("Build sequence space",(async()=>{a=await Ss(e,n,h,$.U.LEVENSHTEIN,!0),t.dockManager.dock(a,o.DOCK_TYPE.RIGHT,null,"Sequence Space",.35)}),{description:"Reduce sequence space dimensionality to display on 2D representation.",delay:2e3}).step("Analyse sequence composition",(async()=>{r=await e.plot.fromType("WebLogo",{sequenceColumnName:l,positionWidth:40,maxHeight:50}),t.dockManager.dock(r,o.DOCK_TYPE.DOWN,null,"Composition analysis",.2)}),{description:"Composition analysis allows to reveal functional features of sequences like motifs, or variable loops.",delay:2e3}).start()}catch(t){re(t)}}()}async function Qs(t,e){var s;Fe(s=e),s.setTag("units",b.r2.SEPARATOR),s.setTag("separator","-"),await i.data.detectSemanticTypes(t)}function ti(t){return function(t){function e(t){return t===c[0]?[Ge].concat(m.getMonomerSymbolsByType("PEPTIDE")):t===c[1]?[Ge].concat(m.getMonomerSymbolsByRGroup(3,"PEPTIDE")):["C"]}function s(){"N-Cys"===u.value?(d=e("N-O"),g=e("N-Cys")):(d=e(u.value),g=[...d]),p=n.choiceInput("R1:",d[0],d,(()=>{r.next()})),f=n.choiceInput("R2:",g[0],g,(()=>{r.next()})),r.next(),n.empty(y),[p,f].forEach((t=>{y.appendChild(t.root)}))}const i=new O.Subject,r=new O.Subject;i.subscribe((()=>{a.cyclizationType=u.value,s()})),r.subscribe((()=>{a.rightTerminal=f.value,a.leftTerminal=p.value}));const a={},l=["Cyclization"],h=n.choiceInput("Modification",l[0],l,(()=>a.transformationType=h.value)),c=["N-O","R3-R3","N-Cys"],u=n.choiceInput("Type",c[0],c,(()=>{i.next()})),m=qt.NT.instance.getBioLib();let d=[],g=[],p=n.choiceInput("R1:",d[0],d,(()=>{a.leftTerminal=p.value})),f=n.choiceInput("R2:",g[0],g,(()=>{a.rightTerminal=f.value}));const y=n.divV([p.root,f.root]);s(),a.cyclizationType=u.value,a.leftTerminal=p.value,a.rightTerminal=f.value,a.transformationType=h.value;const b=n.bigButton("Run",(async()=>Ye(t,a))),w=n.div([h,u,y,b]);return new o.Widget(w)}(t)}async function ei(t){const e=(0,q.Xk)(t),s=JSON.stringify(e);o.Utils.download(`${t.name}.json`,s)}},9017:(t,e,s)=>{"use strict";s.d(e,{k:()=>o});class i{constructor(){this.value=0,this.parentI=0,this.parentJ=0}}class n{constructor(t,e,s){this.seq1=t,this.seq2=e,this.score=s}}class o{fillNeedleman(){for(let t=0;t<=this.len1;t++)this.dpGrid[t][0].value=-t*this.gap,this.dpGrid[t][0].parentI=t-1,this.dpGrid[t][0].parentJ=0;for(let t=1;t<=this.len2;t++)this.dpGrid[0][t].value=-t*this.gap,this.dpGrid[0][t].parentI=0,this.dpGrid[0][t].parentJ=t-1}fillOne(t,e){this.dpGrid[t][e].value=Math.max(this.dpGrid[t-1][e-1].value+this.scores[t-1][e-1],Math.max(this.dpGrid[t-1][e].value-this.gap,this.dpGrid[t][e-1].value-this.gap)),this.dpGrid[t][e].value==this.dpGrid[t-1][e-1].value+this.scores[t-1][e-1]?(this.dpGrid[t][e].parentI=t-1,this.dpGrid[t][e].parentJ=e-1):this.dpGrid[t][e].value==this.dpGrid[t-1][e].value-this.gap?(this.dpGrid[t][e].parentI=t-1,this.dpGrid[t][e].parentJ=e):(this.dpGrid[t][e].parentI=t,this.dpGrid[t][e].parentJ=e-1)}gridFromName(t){switch(t){case"BLOSUM45":this.alignGrid=this.BLOSUM45,this.connections=this.CONBLO,this.step=1;break;case"BLOSUM50":this.alignGrid=this.BLOSUM50,this.connections=this.CONBLO,this.step=1;break;case"BLOSUM62":this.alignGrid=this.BLOSUM62,this.connections=this.CONBLO,this.step=1;break;case"BLOSUM80":this.alignGrid=this.BLOSUM80,this.connections=this.CONBLO,this.step=1;break;case"BLOSUM90":this.alignGrid=this.BLOSUM90,this.connections=this.CONBLO,this.step=1;break;case"PAM30":this.alignGrid=this.PAM30,this.connections=this.CONBLO,this.step=1;break;case"PAM70":this.alignGrid=this.PAM70,this.connections=this.CONBLO,this.step=1;break;case"PAM250":this.alignGrid=this.PAM250,this.connections=this.CONBLO,this.step=1;break;case"NUCLEOTIDES":this.alignGrid=this.NUCLEOTIDES,this.connections=this.CONNUCL,this.step=1;break;case"TRANS":this.alignGrid=this.TRANS,this.connections=this.CONNUCL,this.step=1;break;case"SCHNEIDER":this.alignGrid=this.SCHNEIDER,this.connections=this.CONSCHN,this.step=3}this.fillScores()}constructResult(t,e){let s="",i="",o="";const r=this.dpGrid[t][e].value;for(let t=0;t<this.step;t++)o+="|";for(;t>0||e>0;){this.dpGrid[t][e].parentI==t?(s=o+s,i=this.seq2.substr((e-1)*this.step,this.step)+i):this.dpGrid[t][e].parentJ==e?(i=o+i,s=this.seq1.substr((t-1)*this.step,this.step)+s):(s=t-1>=0?this.seq1.substr((t-1)*this.step,this.step)+s:o+s,i=e-1>=0?this.seq2.substr((e-1)*this.step,this.step)+i:o+i);const n=t;t=this.dpGrid[t][e].parentI,e=this.dpGrid[n][e].parentJ}return new n(s,i,r)}fillScores(){this.scores=[];for(let t=0;t<this.len1;t++){this.scores.push([]);for(let e=0;e<this.len2;e++)this.scores[t].push(this.alignGrid[this.connections[this.seq1.substr(t*this.step,this.step)]][this.connections[this.seq2.substr(e*this.step,this.step)]])}}typeRec(){if(/[ATGC]*/.test(this.seq1)&&/[ATGC]*/.test(this.seq2))return"NUCLEOTIDES";if(/[ARNDCQEGHILKMFPSTWYVBZX*]*/.test(this.seq1)&&/[ARNDCQEGHILKMFPSTWYVBZX*]*/.test(this.seq2))return"BLOSUM62";throw Error("Can't recognize sequence type")}needlemanWunch(){this.dpGrid=[];for(let t=0;t<this.len1+1;t++){const t=[];for(let e=0;e<this.len2+1;e++)t.push(new i);this.dpGrid.push(t)}this.fillNeedleman();for(let t=1;t<=this.len1;t++)for(let e=1;e<=this.len2;e++)this.fillOne(t,e);return this.constructResult(this.len1,this.len2)}smithWaterman(){this.dpGrid=[];for(let t=0;t<this.len1+1;t++){const t=[];for(let e=0;e<this.len2+1;e++)t.push(new i);this.dpGrid.push(t)}let t=0,e=0,s=0;for(let i=1;i<=this.len1;i++)for(let n=1;n<=this.len2;n++)this.fillOne(i,n),this.dpGrid[i][n].value<=0?(this.dpGrid[i][n].value=0,this.dpGrid[i][n].parentI=0,this.dpGrid[i][n].parentJ=0):0==this.dpGrid[this.dpGrid[i][n].parentI][this.dpGrid[i][n].parentJ].value&&(this.dpGrid[i][n].parentI=0,this.dpGrid[i][n].parentJ=0),this.dpGrid[i][n].value>t&&(t=this.dpGrid[i][n].value,e=i,s=n);return this.constructResult(e,s)}setSequences(t,e){this.seq1=t,this.seq2=e,this.len1=this.seq1.length/this.step,this.len2=this.seq2.length/this.step,this.fillScores()}setGap(t){this.gap=t}setMethod(t=""){"AUTO"==t&&(t=this.typeRec()),this.gridFromName(t)}constructor(t,e,s,i=""){this.seq1="",this.seq2="",this.gap=1,this.len1=0,this.len2=0,this.step=1,this.alignGrid=[],this.scores=[],this.dpGrid=[],this.connections={},this.BLOSUM45=[[5,-2,-1,-2,-1,-1,-1,0,-2,-1,-1,-1,-1,-2,-1,1,0,-2,-2,0,-1,-1,0,-5],[-2,7,0,-1,-3,1,0,-2,0,-3,-2,3,-1,-2,-2,-1,-1,-2,-1,-2,-1,0,-1,-5],[-1,0,6,2,-2,0,0,0,1,-2,-3,0,-2,-2,-2,1,0,-4,-2,-3,4,0,-1,-5],[-2,-1,2,7,-3,0,2,-1,0,-4,-3,0,-3,-4,-1,0,-1,-4,-2,-3,5,1,-1,-5],[-1,-3,-2,-3,12,-3,-3,-3,-3,-3,-2,-3,-2,-2,-4,-1,-1,-5,-3,-1,-2,-3,-2,-5],[-1,1,0,0,-3,6,2,-2,1,-2,-2,1,0,-4,-1,0,-1,-2,-1,-3,0,4,-1,-5],[-1,0,0,2,-3,2,6,-2,0,-3,-2,1,-2,-3,0,0,-1,-3,-2,-3,1,4,-1,-5],[0,-2,0,-1,-3,-2,-2,7,-2,-4,-3,-2,-2,-3,-2,0,-2,-2,-3,-3,-1,-2,-1,-5],[-2,0,1,0,-3,1,0,-2,10,-3,-2,-1,0,-2,-2,-1,-2,-3,2,-3,0,0,-1,-5],[-1,-3,-2,-4,-3,-2,-3,-4,-3,5,2,-3,2,0,-2,-2,-1,-2,0,3,-3,-3,-1,-5],[-1,-2,-3,-3,-2,-2,-2,-3,-2,2,5,-3,2,1,-3,-3,-1,-2,0,1,-3,-2,-1,-5],[-1,3,0,0,-3,1,1,-2,-1,-3,-3,5,-1,-3,-1,-1,-1,-2,-1,-2,0,1,-1,-5],[-1,-1,-2,-3,-2,0,-2,-2,0,2,2,-1,6,0,-2,-2,-1,-2,0,1,-2,-1,-1,-5],[-2,-2,-2,-4,-2,-4,-3,-3,-2,0,1,-3,0,8,-3,-2,-1,1,3,0,-3,-3,-1,-5],[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-6.3,-7.4,-8.2,-6.6,-9.7,-14.9,-11.1,-13.9,-.2,-8.2,-2.3,-6.8,-8.9,-11.1,-9.4,-10.9,-8.9,-11.7,-10,-9.9,-12.1,-15.2,-14.3,-14.4,11.1,2.9,9.2,3.5,-3,-7,-4.3,-6.2,-2.2,-6.6,-3.7,-5.7,-6,-10.4,-8.6,-9.5,-50,-15.5,-50,-13.9,-7.8,-10.5,-8.7,-9.6,-50,-16.5,-17.1,-14.8,-12.1,-18.9,-12.4,-17.4],[-8.5,.8,-9.1,-.7,-10.1,-7.5,-9.1,-8.2,-11.4,-3.1,-11.8,-4.4,-15.5,-14.3,-14.8,-15.4,-6.6,-4.7,-7.1,-5.8,-12.5,-10.3,-11,-12.2,-13.4,-10.6,-12.5,-11.8,-17.4,-15.1,-17.7,-15.7,2.9,12.5,3.1,10.3,-7.7,-5.2,-6.2,-7.3,-5.4,-1.7,-5.4,-3.7,-11.6,-9.1,-13,-10.8,-50,-10.3,-50,-11.2,-9.8,-8.3,-9.1,-9.7,-50,-12.7,-20.6,-13.1,-16,-16.6,-17,-18.4],[-5,-6.4,-3.4,-5.6,-7.5,-9.3,-7.1,-8.8,-8.8,-7.4,-6.9,-6.9,-11.4,-15.2,-9.7,-13.7,-1.8,-7.8,-.8,-7.2,-9.4,-10.6,-8.7,-11.2,-10,-10.1,-7.8,-10.5,-13.2,-14.6,-13,-14.5,9.2,3.1,10.8,3,-4.5,-6.7,-2.7,-6.7,-5,-6.8,-2.5,-6.7,-7.5,-10.4,-7.4,-10.2,-50,-15.5,-50,-14.2,-8.9,-10.2,-8.5,-10,-50,-15.6,-15.3,-15.5,-13,-18.8,-12.6,-18.3],[-8.1,-1.1,-8.9,1.4,-8.6,-9.2,-9.4,-6.8,-11,-4.9,-11.5,-2.6,-13.7,-16.8,-14.5,-12.6,-6,-6.7,-7.2,-4.2,-11.6,-11.9,-11.2,-10.9,-13.1,-12.2,-12.5,-10.3,-16.8,-17.2,-17.8,-14.6,3.5,10.3,3,12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.2,3.7,2.5,1.6,2.5,-9.6,-12.3,-9.5,-11.8,-8,-9.4,-7.2,-9.3,-13.3,-12.8,-10.9,-12.6,-1.8,-2.9,-.8,-2.9,-8.6,-13,-7.4,-12.4,-.4,-2.3,1.3,-2,-8.1,-9.3,-5.4,-8.4,10,8.6,11.4,8.9,-50,-13.7,-50,-13.2,-6.1,-8.1,-5.5,-7.5,-50,-11.3,-12.7,-10.1,-1.6,-7.8,-.3,-7.2],[-11.4,-10,-12.7,-8.2,-3.1,-3.1,-2.8,-.9,-11.7,-7.3,-12.1,-5.8,3.6,3.6,-1.1,5.8,-9.4,-11.9,-10.7,-10,-8.5,-8.8,-8.2,-6.5,-13.9,-13,-12.9,-10.9,-3.1,-2.3,-3.2,-.2,-9.5,-10.8,-10.2,-8.2,-1.1,-1.3,-.8,1.2,-8.6,-7.8,-7.8,-5,9,9.5,8.9,12,-50,-13,-50,-10.3,-6.2,-7,-7.1,-5.4,-50,-9.3,-14,-8.2,-2.4,-6.3,-2.4,-3.9],[-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,33.3,-50,30.6,-50,-50,-50,-50,-50,29.2,-50,-50,-50,-50,-50,-50,-50],[-14.8,-6.2,-14.9,-7.6,-14.6,-11.6,-13,-12.2,-14,-9,-14.1,-10.1,-13.6,-11.2,-12.4,-12.5,-8.1,2.2,-8.7,.4,-15.3,-11.3,-13.2,-13.3,-11.9,-7.2,-11.8,-7.9,-10.7,-7.4,-10.8,-8.9,-15.5,-10.3,-15.5,-12.5,-14.5,-12.1,-11.9,-12.8,-18.3,-12.7,-16.4,-14.7,-14.2,-10.4,-13.7,-13,-50,15.1,-50,13.3,-9.9,-5.8,-8.9,-7.6,-50,-1.5,-7.8,-3,-8.1,3.6,-9.4,2],[-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,30.6,-50,35.2,-50,-50,-50,-50,-50,28.5,-50,-50,-50,-50,-50,-50,-50],[-13.8,-7.5,-14.4,-5.1,-12.6,-11.6,-11.5,-10.1,-13.2,-9.7,-12.7,-7.4,-11.9,-11.9,-11.5,-10.2,-7.2,.9,-8.6,2.6,-14.1,-12.8,-13.3,-11,-9.7,-8.4,-11.2,-5.3,-9.3,-8.7,-9.9,-7.1,-13.9,-11.2,-14.2,-8.9,-12.9,-12.6,-12.6,-10.9,-15.4,-13.8,-14.8,-11.4,-12.8,-11.6,-13.2,-10.3,-50,13.3,-50,15.2,-8.6,-7,-8.4,-4.8,-50,-3,-7.1,-.1,-7.3,2.3,-8.7,3.9],[-7.3,-6.3,-8.9,-5.5,2.9,.2,1.5,1.2,-8.5,-2.3,-10,-1.7,-5.6,-10.5,-5.5,-9.6,-4.3,-7.9,-6.1,-7.2,2.3,-.6,.5,-0,-8.9,-11,-9.4,-9.3,-4.6,-9.4,-7.3,-8.1,-7.8,-9.8,-8.9,-9.2,2.8,.1,1.2,.8,-5.9,-6.8,-5.9,-6.3,-4.1,-7.2,-6.1,-6.2,-50,-9.9,-50,-8.6,12.5,9.4,11,9.8,-50,-4.8,-8.7,-3.5,-0,-8.6,-2.1,-7],[-10.1,-4.3,-10.8,-5.8,.1,2.3,.7,.6,-10.4,-.2,-10.8,-2,-8.8,-9.2,-8,-9.7,-6.8,-5.9,-7.5,-7,-1.4,2.2,-.9,-.4,-10.8,-7.7,-9.8,-8.8,-8.9,-7.3,-9.6,-9.1,-10.5,-8.3,-10.2,-10,-0,2.5,.7,.5,-7.5,-5.1,-7.1,-6.7,-7.4,-5.7,-8.1,-7,-50,-5.8,-50,-7,9.4,12.7,10.1,10,-50,-1.5,-11.3,-3.3,-5.4,-4.2,-5.6,-6.8],[-8.4,-6.2,-8.9,-5.9,1.8,.4,2.7,1.2,-9.1,-1.2,-8.8,-1.5,-7.2,-10.5,-4.9,-9.6,-5.7,-7.4,-5.5,-7.4,.3,-.3,1.8,-.4,-9,-8.7,-7.3,-8.9,-5.9,-9.4,-6.4,-8.7,-8.7,-9.1,-8.5,-9.4,1.4,.7,3.5,.7,-6.6,-5.3,-4.7,-5.8,-5.7,-7.5,-5.5,-7.1,-50,-8.9,-50,-8.4,11,10.1,13.2,10.2,-50,-4.2,-6.1,-3.6,-3.5,-8.4,-1.2,-6.8],[-9.1,-5.4,-10.4,-4.2,1,.5,.6,2.4,-9.6,-1.5,-10.5,-.5,-8.9,-10.5,-7.2,-8.3,-6.3,-6.9,-7.7,-5.1,-.5,.1,-.6,2.3,-11.1,-10.2,-10.5,-7,-8.3,-9.4,-9.4,-6.6,-9.6,-9.7,-10,-7.9,.7,.6,.8,2.3,-7.1,-6.5,-7.2,-5,-6.5,-7.4,-7.5,-5.4,-50,-7.6,-50,-4.8,9.8,10,10.2,12.1,-50,-3.1,-11.4,-.7,-4.6,-6.6,-4.9,-3.9],[-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,-50,29.2,-50,28.5,-50,-50,-50,-50,-50,33.3,-50,-50,-50,-50,-50,-50,-50],[-13,-7,-13.1,-8.3,-9.2,-6.5,-8.9,-7.6,-9.8,-.7,-9.2,-2.1,-12.4,-10.3,-12.4,-11.6,-9.5,-4.6,-10.4,-5.7,-13.6,-10.1,-11.4,-10.9,-6.5,-1.5,-6.2,-3.6,-12.8,-8,-12.3,-9.7,-16.5,-12.7,-15.6,-14.3,-8.7,-6,-7.1,-7.5,-9.5,-4.1,-8.4,-6.1,-11,-8.6,-11.3,-9.3,-50,-1.5,-50,-3,-4.8,-1.5,-4.2,-3.1,-50,16.4,-5.1,14.2,-10.1,-4.3,-10,-5.4],[-13.5,-16.3,-11.8,-15.5,-13.6,-15.3,-12.1,-16.1,-7.7,-13.3,-4.2,-12.6,-14.1,-16.2,-10.3,-15.4,-9.6,-11.6,-7.7,-9.8,-14.3,-17.5,-11.1,-17.2,-5.3,-7.1,-2.2,-7.1,-9.6,-11.9,-8.7,-11.4,-17.1,-20.6,-15.3,-19.9,-14.1,-14.8,-12.4,-16.5,-11.7,-12.8,-6.4,-13.4,-14.3,-15.7,-12.7,-14,-50,-7.8,-50,-7.1,-8.7,-11.3,-6.1,-11.4,-50,-5.1,18.6,-4.8,-8.6,-8.1,-4.5,-7.3],[-12.4,-8.2,-13,-5.9,-7.7,-7.8,-7.4,-5.8,-8.8,-2,-9.3,-.4,-11.6,-11.3,-11.6,-9.4,-8.9,-5.6,-10,-3.2,-11.5,-11.1,-10.5,-8.3,-6.3,-4.9,-6.7,-1.2,-10.6,-9.7,-11.3,-8,-14.8,-13.1,-15.5,-11.4,-7.5,-7.5,-7.1,-5.9,-8.4,-5.8,-8.1,-3.6,-9.9,-9.7,-10.1,-8.2,-50,-3,-50,-.1,-3.5,-3.3,-3.6,-.7,-50,14.2,-4.8,16.4,-8.9,-5.8,-8.9,-3.4],[-10.7,-13.2,-12.4,-11.6,-4.8,-8.4,-6.1,-7.2,-10.3,-11.8,-11,-11.6,2.8,-1.7,.7,-1.1,-6.2,-9.7,-7.3,-8.4,-5.3,-8.6,-6.1,-8.3,-10.5,-11.2,-9.8,-10.2,9.5,6.5,7.6,6.8,-12.1,-16,-13,-16.2,-5.2,-8.6,-7.1,-7.8,-12.5,-14.4,-12.1,-13,1.4,-3,-1.6,-2.4,-50,-8.1,-50,-7.3,-0,-5.4,-3.5,-4.6,-50,-10.1,-8.6,-8.9,13.2,-.9,9.7,-.3],[-18.1,-12.3,-19.4,-14.2,-12.2,-9.5,-11.5,-10.8,-17.9,-11.9,-18.2,-13.9,-6.4,-3.7,-6.8,-5.4,-12.8,-5.9,-13.6,-7.4,-13.7,-9.9,-12.9,-12.7,-16.2,-11.6,-15.2,-12.7,-3.2,.5,-3.3,-1.8,-18.9,-16.6,-18.8,-19.2,-12.5,-9.4,-10.6,-11.1,-17.3,-14.1,-16.2,-16,-7.9,-3.7,-7.8,-6.3,-50,3.6,-50,2.3,-8.6,-4.2,-8.4,-6.6,-50,-4.3,-8.1,-5.8,-.9,14.2,-1.8,11.6],[-11.8,-13.1,-11.5,-12,-6.2,-8.3,-5.4,-7.4,-11.8,-12.3,-11.1,-11.4,.5,-2.5,2.4,-1.6,-6.8,-9.9,-6.4,-8.9,-6.1,-8.6,-5,-7.8,-10.4,-11.6,-8.5,-9.9,8.2,6.4,8.7,6.9,-12.4,-17,-12.6,-15.8,-6.5,-8.5,-5,-7.8,-13.2,-13.6,-10.3,-13.7,-.7,-3.2,-.3,-2.4,-50,-9.4,-50,-8.7,-2.1,-5.6,-1.2,-4.9,-50,-10,-4.5,-8.9,9.7,-1.8,11.3,-.9],[-17.2,-13.3,-17.8,-11.6,-11,-11.1,-10.4,-9,-16,-12.7,-16.1,-11.1,-5.2,-5.4,-6,-3.3,-11.8,-7.3,-13.3,-5.9,-12.7,-11.9,-11.9,-9.3,-15.2,-15,-14.9,-11,-2.8,-1.8,-2.9,.4,-17.4,-18.4,-18.3,-15.9,-10.7,-11.2,-10.6,-9,-15.4,-14.8,-15.8,-13.3,-6.8,-5.9,-7.2,-3.9,-50,2,-50,3.9,-7,-6.8,-6.8,-3.9,-50,-5.4,-7.3,-3.4,-.3,11.6,-.9,14.1]],this.TRANS=[[5,0,0,4],[0,5,4,0],[0,4,5,0],[4,0,0,5]],this.CONBLO={A:0,R:1,N:2,D:3,C:4,Q:5,E:6,G:7,H:8,I:9,L:10,K:11,M:12,F:13,P:14,S:15,T:16,W:17,Y:18,V:19,B:20,Z:21,X:22,"*":23},this.CONNUCL={A:0,T:1,C:2,G:3},this.CONSCHN={AAA:0,AAC:1,AAG:2,AAT:3,ACA:4,ACC:5,ACG:6,ACT:7,AGA:8,AGC:9,AGG:10,AGT:11,ATA:12,ATC:13,ATG:14,ATT:15,CAA:16,CAC:17,CAG:18,CAT:19,CCA:20,CCC:21,CCG:22,CCT:23,CGA:24,CGC:25,CGG:26,CGT:27,CTA:28,CTC:29,CTG:30,CTT:31,GAA:32,GAC:33,GAG:34,GAT:35,GCA:36,GCC:37,GCG:38,GCT:39,GGA:40,GGC:41,GGG:42,GGT:43,GTA:44,GTC:45,GTG:46,GTT:47,TAA:48,TAC:49,TAG:50,TAT:51,TCA:52,TCC:53,TCG:54,TCT:55,TGA:56,TGC:57,TGG:58,TGT:59,TTA:60,TTC:61,TTG:62,TTT:63},this.setMethod(i),this.setSequences(t,e),this.setGap(s)}}},7983:(t,e,s)=>{"use strict";s.d(e,{HV:()=>g,QF:()=>d,pf:()=>m,uH:()=>u});var i=s(4469),n=s(3870),o=s(976),r=s(7241),a=s(4293),l=s(1061),h=s(8447);const c="substr_helm";class u{constructor(t){this.col=t[0],this.createUI()}editHelmLinkAction(){(0,a.Y)(this.inputsDiv,this.grid.root),n.tools.waitForElementInDom(this.grid.root).then((()=>{setTimeout((()=>{this.grid.cell(c,0).element.children[0].dispatchEvent(new KeyboardEvent("keydown",{key:"Enter"}))}),100)}))}updateInputs(){const t=this.units===h.r2.HELM?n.divV([this.columnsInput,this.editHelmLink]):this.units===h.r2.SEPARATOR?n.inputs([this.columnsInput,this.substructureInput,this.separatorInput]):n.inputs([this.columnsInput,this.substructureInput]);(0,a.Y)(this.inputsDiv,t)}updateNotationDiv(){this.units=this.col.getTag(o.TAGS.UNITS),this.separator=this.col.getTag("separator");const t=this.dialog.root.getElementsByClassName("notation-text")[0];t&&(t.textContent=`Notation: ${this.units}`)}createUI(){const t=i.shell.tv.dataFrame,e={filter:t=>t.semType===o.SEMTYPE.MACROMOLECULE};this.columnsInput=n.columnInput("Column",t,this.col,(t=>{this.col=t,this.updateNotationDiv(),this.updateInputs()}),e),this.substructureInput=n.stringInput("Substructure",""),this.editHelmLink=n.link("Edit helm",(()=>this.editHelmLinkAction()),void 0,{style:{position:"relative",left:"95px"}});const s=o.DataFrame.create(1);s.columns.addNewString(c).init((t=>"")),s.col(c).semType=this.col.semType,s.col(c).setTag(o.TAGS.UNITS,h.r2.HELM),this.grid=s.plot.grid(),this.separatorInput=n.stringInput("Separator",this.separator),this.inputsDiv=n.div(),this.units=this.col.getTag(o.TAGS.UNITS),this.separator=this.col.getTag("separator"),this.updateInputs(),this.dialog=n.dialog("Substructure Search").add(n.divV([n.divText(`Notation: ${this.units}`,"notation-text"),this.inputsDiv])).onOK((async()=>{let t,e=this.units===h.r2.HELM?s.get(c,0):this.substructureInput.value;this.units===h.r2.SEPARATOR&&this.separatorInput.value!==this.separator&&""!==this.separatorInput.value&&(e=e.replaceAll(this.separatorInput.value,this.separator)),t=this.units===h.r2.HELM?await d(e,this.col):m(e,this.col),this.col.dataFrame.filter.and(t)})).show()}}function m(t,e,s){const i=s?function(t,e){const s=`${e}`.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),i=t.charAt(0)===e,n=t.charAt(t.length-1)===e,o=t.replace(new RegExp(`^${s}|${s}$`,"g"),"");return i?n?`${s}${o}${s}`:`${s}${o}${s}|${s}${o}$`:n?`^${o}${s}|${s}${o}${s}`:`^${o}${s}|${s}${o}${s}|${s}${o}$`}(t,s):t,n=o.BitSet.create(e.length);for(let s=0;s<e.length;s++){const o=e.get(s);(o.match(i)||o===t)&&n.set(s,!0,!1)}return n}async function d(t,e){e.version!==e.temp["last-invalidated-version"]&&await g(e,!0);const s=o.Column.string("helm",1).init((e=>t));s.semType=o.SEMTYPE.MACROMOLECULE,s.setTag(o.TAGS.UNITS,h.r2.HELM);const n=await(0,r.D)(s,!0,e.temp["monomers-dict"]);return(await i.functions.call("Chem:searchSubstructure",{molStringsColumn:e.temp["monomeric-mols"],molString:n.get(0),molBlockFailover:""})).get(0)}async function g(t,e){const s=o.TaskBarProgressIndicator.create(`Invalidating molfiles for ${t.name}`);await(0,l.gw)(10);const i=new Map,n=await(0,r.D)(t,e,i);t.temp["monomeric-mols"]=n,t.temp["monomers-dict"]=i,t.temp["last-invalidated-version"]=t.version,s.close()}},2568:(t,e,s)=>{"use strict";s.d(e,{n:()=>r});var i=s(4469),n=s(976),o=s(499);function r(t,e,s=[],r=[],a=!0){const[l,h]=function(t,e,s=[],r=[]){let a=!0,l="";const h=o.Cn.getOrCreate(t);if(t.semType!==n.SEMTYPE.MACROMOLECULE)i.shell.warning(e+" analysis is allowed for Macromolecules semantic type"),a=!1;else{const t=h.notation;if(s.length>0&&!s.some((e=>t.toUpperCase()==e.toUpperCase())))l=`${e} + ' analysis is allowed for Macromolecules with notation ${0==s.length?"any notation":`notation${s.length>1?"s":""} ${s.map((t=>`"${t}"`)).join(", ")} `}.`,a=!1;else if(!h.isHelm()){const t=h.alphabet;r.length>0&&!r.some((e=>t.toUpperCase()==e.toUpperCase()))&&(l=`${e} + ' analysis is allowed for Macromolecules with alphabet ${0==r.length?"any alphabet":`alphabet${r.length>1?"s":""} ${r.map((t=>`"${t}"`)).join(", ")}.`}.`,a=!1)}}return[a,l]}(t,e,s,r);return a&&!l&&i.shell.warning(h),l}},3553:(t,e,s)=>{"use strict";s.d(e,{Of:()=>o,WY:()=>h,jB:()=>c,rs:()=>a});var i,n,o,r,a,l=s(8341);!function(t){t.SPLIT_COL="~split",t.ACTIVITY="~activity",t.ACTIVITY_SCALED="activity_scaled",t.ALIGNED_SEQUENCE="~aligned_sequence",t.AMINO_ACID_RESIDUE="AAR",t.POSITION="Pos",t.P_VALUE="pValue",t.MEAN_DIFFERENCE="Mean difference"}(i||(i={})),function(t){t.AAR="AAR",t.POSITION="Pos",t.SELECTION="selection"}(n||(n={})),function(t){t.MONOMER="Monomer",t.MACROMOLECULE_DIFFERENCE="MacromoleculeDifference",t.ACTIVITY="activity",t.ACTIVITY_SCALED="activityScaled"}(o||(o={})),function(t){t.CELL_CHANGING="isCellChanging"}(r||(r={})),function(t){t.SEPARATOR="."}(a||(a={}));const h="3.3.1",c={pepsea:{gapOpen:1.53,gapExtend:0,method:l.J[0]},kalign:{gapOpen:-1,gapExtend:-1,terminalGap:-1}}},4004:(t,e,s)=>{"use strict";s.d(e,{O:()=>m});var i=s(976),n=s(3870),o=s(4469),r=s(3336),a=s.n(r),l=s(8447),h=s(499);let c=null,u=[];function m(t){let e=t??o.shell.t.columns.bySemType("Macromolecule");if(!e)throw new Error("No column with Macromolecule semantic type found");let s=h.Cn.getOrCreate(e),r=s.notation;const m=n.divText("Current notation: "+r,{style:{"text-align":"center","font-weight":"bold","font-size":"14px",padding:"5px"}}),d=[l.r2.FASTA,l.r2.SEPARATOR,l.r2.HELM],g=n.columnInput("Column",o.shell.t,e,(t=>{t.semType===i.SEMTYPE.MACROMOLECULE?(e=t,s=h.Cn.getOrCreate(e),r=s.notation,r===l.r2.HELM&&(y.value="/"),m.textContent="Current notation: "+r,f=d.filter((t=>t!==r)),w=n.choiceInput("Convert to",f[0],f,b),b(),c?.clear(),c?.add(n.div([m,g.root,w.root,y.root]))):g.value=e})),p=["-",".","/"];let f=d.filter((t=>t!==r));const y=n.choiceInput("Separator",p[0],p),b=()=>{w.value!==l.r2.SEPARATOR?a()(y.root).hide():a()(y.root).show()};let w=n.choiceInput("Convert to",f[0],f,b);b(),w.onChanged((()=>{b()})),null==c&&(c=n.dialog("Convert Sequence Notation").add(n.div([m,g.root,w.root,y.root])).onOK((async()=>{const t=w.value,s=y.value??void 0;await async function(t,e,s){const i=h.Cn.getOrCreate(t).convert(e,s);t.dataFrame.columns.add(i);const n=await o.functions.call("Bio:detectMacromolecule",{col:i});return n&&(i.semType=n),await o.data.detectSemanticTypes(t.dataFrame),i}(e,t,s)})).show({x:350,y:100}),u.push(c.onClose.subscribe((t=>{u.forEach((t=>{t.unsubscribe()})),u=[],c=null}))))}},7958:(t,e,s)=>{"use strict";function i(t){return"string"==typeof t||t instanceof String?t:"StateError"===t.constructor.name?t.message:"StateError"===t.constructor.name&&"$thrownJsError"in t?i(t.$thrownJsError):t instanceof Error?t.message:t.toString()}function n(t){return t instanceof Error?t.stack:"StateError"===t.constructor.name&&"$thrownJsError"in t?n(t.$thrownJsError):void 0}function o(t){return[i(t),n(t)]}s.d(e,{yf:()=>o})},5490:(t,e,s)=>{"use strict";s.d(e,{NT:()=>M,cf:()=>S});var i,n=s(4469),o=s(3870),r=s(976),a=s(701);class l{constructor(t){this.init(t)}init(t){this.fileContent=t.replace(/\r/g,""),this._atomCount=void 0,this._atomTypes=void 0,this._bondCount=void 0,this._bondTypes=void 0,this.xyzAtomCoordinates=void 0,this._pairsOfBondedAtoms=void 0}get atomCount(){return void 0===this._atomCount&&this.setAtomAndBondCounts(),this._atomCount}get bondCount(){return void 0===this._bondCount&&this.setAtomAndBondCounts(),this._bondCount}get x(){var t;return null!==(t=this.xyzAtomCoordinates)&&void 0!==t||(this.xyzAtomCoordinates=this.parseAtomCoordinates()),this.xyzAtomCoordinates.x}get y(){var t;return null!==(t=this.xyzAtomCoordinates)&&void 0!==t||(this.xyzAtomCoordinates=this.parseAtomCoordinates()),this.xyzAtomCoordinates.y}get z(){var t;return null!==(t=this.xyzAtomCoordinates)&&void 0!==t||(this.xyzAtomCoordinates=this.parseAtomCoordinates()),this.xyzAtomCoordinates.z}get atomTypes(){var t;return null!==(t=this._atomTypes)&&void 0!==t||(this._atomTypes=this.parseAtomTypes()),this._atomTypes}get pairsOfBondedAtoms(){var t;return null!==(t=this._pairsOfBondedAtoms)&&void 0!==t||(this._pairsOfBondedAtoms=this.parseBondedAtomPairs()),this._pairsOfBondedAtoms}get bondTypes(){var t;return null!==(t=this._bondTypes)&&void 0!==t||(this._bondTypes=this.parseBondTypes()),this._bondTypes}setAtomAndBondCounts(){const{atomCount:t,bondCount:e}=this.parseAtomAndBondCounts();this._atomCount=t,this._bondCount=e}getNextColumnIdx(t){for(;!this.isWhitespace(t);)++t;for(;this.isWhitespace(t);)++t;return t}shiftIdxToSpecifiedColumn(t,e){let s=t;const i=this.isWhitespace(s)?e:e-1;for(let t=0;t<i;t++)s=this.getNextColumnIdx(s);return s}parseAtomTypes(){const t=this.atomCount,e=new Array(t);let s=this.getAtomBlockIdx();for(let i=0;i<t;i++)s=this.shiftIdxToAtomType(s),e[i]=this.parseAtomType(s),s=this.getNextLineIdx(s);return e}parseAtomCoordinates(){const t=new Float32Array(this.atomCount),e=new Float32Array(this.atomCount),s=new Float32Array(this.atomCount);let i=this.getAtomBlockIdx();for(let n=0;n<this.atomCount;n++){i=this.shiftIdxToXColumn(i);for(const o of[t,e,s])o[n]=this.parseFloatValue(i),i=this.getNextColumnIdx(i);i=this.getNextLineIdx(i)}return{x:t,y:e,z:s}}parseBondedAtomPairs(){const t=new Array(this.bondCount);let e=this.getBondBlockIdx();for(let s=0;s<this.bondCount;s++){e=this.shiftIdxToBondedAtomsPair(e);const i=new Uint16Array(2);i[0]=this.parseIntValue(e),e=this.getNextColumnIdx(e),i[1]=this.parseIntValue(e),t[s]=i,e=this.getNextLineIdx(e)}return t}parseBondTypes(){const t=this.bondCount,e=new Uint16Array(t);let s=this.getBondBlockIdx();for(let i=0;i<t;i++)s=this.shiftIdxToBondType(s),e[i]=this.parseIntValue(s),s=this.getNextLineIdx(s);return e}isWhitespace(t){const e=this.fileContent[t];return" "===e||"\t"===e}getNextLineIdx(t){return"\n"!==this.fileContent[t]?this.fileContent.indexOf("\n",t)+1:t+1}parseFloatValue(t){return this.parseNumericValue(parseFloat,t)}parseIntValue(t){return this.parseNumericValue(parseInt,t)}parseNumericValue(t,e){let s=e+1;for(;!this.isWhitespace(s);)++s;return t(this.fileContent.substring(e,s))}}class h extends l{constructor(t){super(t),this.init(t)}init(t){super.init(t)}parseAtomType(t){let e=t,s=e;return this.isQuote(e)?(s=this.getNextIdenticalChar(e),e++):s=this.fileContent.indexOf(" ",s),this.fileContent.substring(e,s)}isQuote(t){const e=this.fileContent[t].charCodeAt(0);return 39===e||34===e}getNextIdenticalChar(t){const e=this.fileContent[t];return e?this.fileContent.indexOf(e,t+1):-1}isQuery(){return this.isQueryOrFragment(((t,e)=>{return 39===t||34===t||76===t&&!((s=this.fileContent.charCodeAt(e+1))>64&&s<91||s>96&&s<123);var s}))}isFragment(){return this.isQueryOrFragment((t=>82===t||42===t))}isQueryOrFragment(t){const e=this.atomCount;let s=this.getAtomBlockIdx();for(let i=0;i<e;i++){if(s=this.shiftIdxToAtomType(s),t(this.fileContent.charCodeAt(s),s))return!0;s=this.getNextLineIdx(s)}return!1}}!function(t){t.HEADER="V2000",t[t.NUM_OF_HEADER_LINES=3]="NUM_OF_HEADER_LINES",t[t.NUM_OF_COUNTS_DIGITS=3]="NUM_OF_COUNTS_DIGITS",t[t.ATOM_TYPE_COL=4]="ATOM_TYPE_COL",t[t.FIRST_BONDED_ATOM_COL=1]="FIRST_BONDED_ATOM_COL",t[t.BOND_TYPE_COL=3]="BOND_TYPE_COL",t[t.RGP_SHIFT=8]="RGP_SHIFT",t.RGP_LINE="M RGP",t.A_LINE="A ",t.END="M END"}(i||(i={}));class c extends h{constructor(t){super(t)}static validate(t){return-1!==t.indexOf(i.HEADER)&&-1!==t.indexOf(i.END)}shiftIdxToAtomType(t){return this.shiftIdxToSpecifiedColumn(t,i.ATOM_TYPE_COL)}getCountsLineIdx(){let t=0;for(let e=0;e<i.NUM_OF_HEADER_LINES;++e)t=this.getNextLineIdx(t);return t}getAtomBlockIdx(){let t=this.getCountsLineIdx();return t=this.getNextLineIdx(t),t}shiftIdxToXColumn(t){return this.getNextColumnIdx(t)}shiftIdxToBondedAtomsPair(t){return this.shiftIdxToSpecifiedColumn(t,i.FIRST_BONDED_ATOM_COL)}shiftIdxToBondType(t){return this.shiftIdxToSpecifiedColumn(t,i.BOND_TYPE_COL)}getBondBlockIdx(){let t=this.getAtomBlockIdx();for(let e=0;e<this.atomCount;e++)t=this.getNextLineIdx(t);return t}parseAtomAndBondCounts(){let t=this.getCountsLineIdx(),e=t+i.NUM_OF_COUNTS_DIGITS;const s=parseInt(this.fileContent.substring(t,e));return t=e,e+=i.NUM_OF_COUNTS_DIGITS,{atomCount:s,bondCount:parseInt(this.fileContent.substring(t,e))}}}class u extends h{constructor(t){super(t),this.init(t)}shiftIdxToAtomType(t){return this.shiftIdxToSpecifiedColumn(t,4)}getCountsLineIdx(){return this.fileContent.indexOf("M V30 COUNTS ")}getAtomBlockIdx(){let t=this.fileContent.indexOf("M V30 BEGIN ATOM");return t=this.getNextLineIdx(t),t}shiftIdxToXColumn(t){let e=this.shiftIdxToAtomType(t);return this.isQuote(e)?(e=this.getNextIdenticalChar(e),e=this.getNextColumnIdx(e),e):this.shiftIdxToSpecifiedColumn(t,5)}shiftIdxToBondedAtomsPair(t){return this.shiftIdxToSpecifiedColumn(t,5)}shiftIdxToBondType(t){return this.shiftIdxToSpecifiedColumn(t,4)}getBondBlockIdx(){return this.getNextLineIdx(this.fileContent.indexOf("M V30 BEGIN BOND"))}static validate(t){return-1!==t.indexOf("V3000")&&-1!==t.indexOf("M END")}parseAtomAndBondCounts(){let t=this.fileContent.indexOf("M V30 COUNTS ")+14,e=this.fileContent.indexOf(" ",t+1);const s=parseInt(this.fileContent.substring(t,e));return t=e+1,e=this.fileContent.indexOf(" ",t+1),{atomCount:s,bondCount:parseInt(this.fileContent.substring(t,e))}}}class m{constructor(){}static getInstance(t){if(c.validate(t))return new c(t);if(u.validate(t))return new u(t);throw new Error("Malformed molfile")}}var d=s(7228),g=s(2904);const p="Libraries",f="System:AppData/Bio/libraries/";async function y(){return await Promise.all((await n.dapi.files.list(f,!0,"")).map((async t=>t.fullPath.substring(f.length))))}let b=Promise.resolve();async function w(){let t;return b=b.then((async()=>{const e=await n.dapi.userDataStorage.getValue(p,"Settings",!0);t=e?JSON.parse(e):{exclude:[]},t.exclude=t.exclude instanceof Array?t.exclude:[],console.debug(`Bio: getUserLibSettings()\n${JSON.stringify(t,void 0,2)}`)})),await b,t}async function C(t){b=b.then((async()=>{console.debug(`Bio: setUserLibSettings()\n${JSON.stringify(t,void 0,2)}`),await n.dapi.userDataStorage.postValue(p,"Settings",JSON.stringify(t),!0)})),await b}async function v(){const t=o.dialog({title:"Manage files"}).add(o.fileBrowser({path:"System:AppData/Bio/libraries"}).root).addButton("OK",(()=>t.close())).show()}async function S(){const t=o.button("Manage",v),e=o.inputs([]),s=await y(),i=await w();for(const t of s){const s=o.boolInput(t,!i.exclude.includes(t),(()=>{1==s.value?i.exclude=i.exclude.filter((e=>e!=t)):i.exclude.includes(t)||i.exclude.push(t),C(i).then((async()=>{await M.instance.loadLibraries(!0),n.shell.info("Monomer library user settings saved.")}))}));e.append(s.root)}return new r.Widget(o.divV([e,o.div(t)]))}class T{constructor(t,e){this._monomers={},this._onChanged=new a.Subject,this._monomers=t,this.error=e}getMonomer(t,e){return t in this._monomers&&e in this._monomers[t]?this._monomers[t][e]:null}getPolymerTypes(){return Object.keys(this._monomers)}getMonomerMolsByPolymerType(t){const e={};return Object.keys(this._monomers[t]??{}).forEach((s=>{e[s]=this._monomers[t][s].molfile})),e}getMonomerSymbolsByType(t){return Object.keys(this._monomers[t])}getMonomerSymbolsByRGroup(t,e,s){let i=this.getMonomerSymbolsByType(e).map((t=>this.getMonomer(e,t)));return i=i.filter((t=>null!==t)),0===i.length?[]:(i=i.filter((e=>{if(!e?.rgroups)return!1;let s=e?.rgroups.length>=t;return m.getInstance(e.molfile).atomTypes.map(((t,e)=>"R#"===t?e:-1)).filter((t=>-1!==t)),s&&(s=!0),s})),i.map((t=>t?.symbol)))}get onChanged(){return this._onChanged}_updateInt(t){const e=t.getPolymerTypes(),s=this.getPolymerTypes();e.forEach((e=>{s.includes(e)||(this._monomers[e]={}),t.getMonomerSymbolsByType(e).forEach((s=>{this._monomers[e][s]=t.getMonomer(e,s)}))}))}update(t){this._updateInt(t),this._onChanged.next()}updateLibs(t,e=!1){e&&(this._monomers={});for(const e of t)e.error||this._updateInt(e);this._onChanged.next()}clear(){this._monomers={},this._onChanged.next()}}class M{constructor(){this._monomerLib=new T({}),this.loadLibrariesPromise=Promise.resolve()}getBioLib(){return this._monomerLib}async loadLibraries(t=!1){return this.loadLibrariesPromise=this.loadLibrariesPromise.then((async()=>{try{const[e,s]=await Promise.all([y(),w()]),i=e.filter((t=>!s.exclude.includes(t))),n=await Promise.all(i.map((t=>this.readLibrary(f,t).catch((e=>{const s=`Loading monomers from '${t}' error: ${e instanceof Error?e.message:e.toString()}`;return new T({},s)})))));this._monomerLib.updateLibs(n,t)}catch(t){const e=`Loading monomer libraries error: ${t instanceof Error?t.message:t.toString()}`;n.shell.warning(e);const s=t instanceof Error?t.stack:void 0;g._package.logger.error(e,void 0,s)}}))}async readLibrary(t,e){let s,i,o=[];const a=new r.FileSource(t);if(e.endsWith(".sdf"))1===r.Func.find({package:"Chem",name:"importSdf"}).length?(s=await a.readAsBytes(e),i=await n.functions.call("Chem:importSdf",{bytes:s}),o=(0,d.Xk)(i[0])):n.shell.warning("Chem package is not installed");else if(e.endsWith(".json")){const t=await a.readAsText(e);o=JSON.parse(t)}else{if(!e.endsWith(".csv"))throw new Error("Monomer library of unknown file format, supported formats: SDF, JSON, CSV");{const t=(l=await a.readCsv(e),Array.from({length:l.rowCount},((t,e)=>l.columns.names().reduce(((t,s)=>(t[s]=l.get(s,e),t)),{}))));if(!(0,d.eD)(t))throw new Error("Invalid format of CSV monomer lib");o=(0,d.Z)(t)}}var l;const h={},c=[];return o.forEach((t=>{c.includes(t.polymerType)||(h[t.polymerType]={},c.push(t.polymerType)),h[t.polymerType][t.symbol]=t})),new T(h)}static get instance(){return M._instance||(M._instance=new M),M._instance}}M._instance=null},525:(t,e,s)=>{"use strict";s.d(e,{K:()=>I});var i=s(4469),n=s(976),o=s(3870),r=s(8447),a=s(499),l=s(6098),h=s(8341),c=s(2568),u=s(3553),m=s(2904),d=s(3379),g=s.n(d),p=s(7795),f=s.n(p),y=s(569),b=s.n(y),w=s(3565),C=s.n(w),v=s(9216),S=s.n(v),T=s(4589),M=s.n(T),A=s(9564),E={};E.styleTagTransform=M(),E.setAttributes=C(),E.insert=b().bind(null,"head"),E.domAPI=f(),E.insertStyleElement=S(),g()(A.Z,E),A.Z&&A.Z.locals&&A.Z.locals;class x extends Error{constructor(t,e){super(t,e)}}async function I(t={}){return new Promise((async(e,s)=>{var r,a,l;t.clustersCol??(t.clustersCol=null),t.pepsea??(t.pepsea={}),(r=t.pepsea).method??(r.method=u.jB.pepsea.method),(a=t.pepsea).gapOpen??(a.gapOpen=u.jB.pepsea.gapOpen),(l=t.pepsea).gapExtend??(l.gapExtend=u.jB.pepsea.gapExtend);const c=t.col?.dataFrame??i.shell.t,m=t.col??c.columns.bySemType(n.SEMTYPE.MACROMOLECULE);if(null==m){const t="MSAError: dataset doesn't conain any Macromolecule column";i.shell.warning(t),s(new x(t))}const d=o.choiceInput("Method",t.pepsea.method,h.J);d.setTooltip("Alignment method");const g=o.floatInput("Terminal gap",t?.kalign?.terminalGap??null);g.setTooltip("Penalty for opening a gap at the beginning or end of the sequence");const p=o.p(`Kalign version: ${u.WY}`,"kalign-version"),f=o.floatInput("Gap open",t.pepsea.gapOpen);f.setTooltip("Gap opening penalty at group-to-group alignment");const y=o.floatInput("Gap extend",t.pepsea.gapExtend);y.setTooltip("Gap extension penalty to skip the alignment");const b=o.inputs([f,y,g]),w=o.button("Alignment parameters",(()=>{b.hidden=!b.hidden}),"Adjust alignment parameters such as penalties for opening and extending gaps");w.classList.add("msa-params-button"),b.hidden=!0,w.prepend(o.icons.settings((()=>null)));const C=[d.root.style],v=[g.root.style,p.style];let S;const T=o.columnInput("Sequence",c,m,(async()=>{S=await L(T.value,c,C,v,d,M,f,y,g)}),{filter:t=>t.semType===n.SEMTYPE.MACROMOLECULE});T.setTooltip("Sequences column to use for alignment");const M=o.columnInput("Clusters",c,t.clustersCol);if(M.nullable=!0,T.fireChanged(),t.col)return S=await L(t.col,c,C,v,d,M,f,y,g),void await N(T,c,S,e,s);o.dialog("MSA").add(T).add(M).add(d).add(b).add(w).add(p).onOK((async()=>{await N(T,c,S,e,s)})).show()}))}async function N(t,e,s,o,r){let a=null;const l=n.TaskBarProgressIndicator.create("Analyze for MSA ...");try{if(t.fireChanged(),t.value.semType!==n.SEMTYPE.MACROMOLECULE)throw new Error("Chosen column has to be of Macromolecule semantic type");if(void 0===s)throw new Error("Invalid column format");if(a=await s(),null==a)return r("PepSeA container has not started");e.columns.add(a),await i.data.detectSemanticTypes(e),o(a)}catch(t){const e=t instanceof Error?t.message:t.toString();i.shell.error(e),r(t)}finally{l.close()}}async function L(t,e,s,o,d,g,p,f,y){try{if(t.semType!==n.SEMTYPE.MACROMOLECULE)return;const i=e.columns.getUnusedName(`msa(${t.name})`);if((0,c.n)(t,t.name,[r.r2.FASTA,r.r2.SEPARATOR],["DNA","RNA","PT"],!1)){_(s,o,"kalign"),p.value=null,f.value=null,y.value=null;const e=a.Cn.getOrCreate(t),n=e.isFasta()?t:e.convert(r.r2.FASTA);return async()=>await(0,l.U)(n,!1,i,g.value)}if((0,c.n)(t,t.name,[r.r2.HELM],[],!1))return _(s,o,"pepsea"),p.value??(p.value=u.jB.pepsea.gapOpen),f.value??(f.value=u.jB.pepsea.gapExtend),async()=>await(0,h.f)(t,i,d.value,p.value,f.value,g.value);if((0,c.n)(t,t.name,[r.r2.SEPARATOR],["UN"],!1)){const e=a.Cn.getOrCreate(t).convert(r.r2.HELM);return _(s,o,"pepsea"),p.value??(p.value=u.jB.pepsea.gapOpen),f.value??(f.value=u.jB.pepsea.gapExtend),async()=>await(0,h.f)(e,i,d.value,p.value,f.value,g.value)}return p.value=null,f.value=null,y.value=null,void _(s,o,"kalign")}catch(t){const e=t instanceof Error?t.message:t.toString();i.shell.error(e),m._package.logger.error(e)}}function _(t,e,s){if("kalign"===s){for(const e of t)e.display="none";for(const t of e)t.removeProperty("display")}else{for(const t of e)t.display="none";for(const e of t)e.removeProperty("display")}}},6098:(t,e,s)=>{"use strict";s.d(e,{U:()=>k});var i=s(976),n=s(5226);const o=Symbol("Comlink.proxy"),r=Symbol("Comlink.endpoint"),a=Symbol("Comlink.releaseProxy"),l=Symbol("Comlink.thrown"),h=t=>"object"==typeof t&&null!==t||"function"==typeof t,c=new Map([["proxy",{canHandle:t=>h(t)&&t[o],serialize(t){const{port1:e,port2:s}=new MessageChannel;return u(t,e),[s,[s]]},deserialize:t=>(t.start(),d(t))}],["throw",{canHandle:t=>h(t)&&l in t,serialize({value:t}){let e;return e=t instanceof Error?{isError:!0,value:{message:t.message,name:t.name,stack:t.stack}}:{isError:!1,value:t},[e,[]]},deserialize(t){throw t.isError?Object.assign(new Error(t.value.message),t.value):t.value}}]]);function u(t,e=self){e.addEventListener("message",(function s(i){if(!i||!i.data)return;const{id:n,type:r,path:a}=Object.assign({path:[]},i.data),h=(i.data.argumentList||[]).map(C);let c;try{const e=a.slice(0,-1).reduce(((t,e)=>t[e]),t),s=a.reduce(((t,e)=>t[e]),t);switch(r){case"GET":c=s;break;case"SET":e[a.slice(-1)[0]]=C(i.data.value),c=!0;break;case"APPLY":c=s.apply(e,h);break;case"CONSTRUCT":c=function(t){return Object.assign(t,{[o]:!0})}(new s(...h));break;case"ENDPOINT":{const{port1:e,port2:s}=new MessageChannel;u(t,s),c=function(t,e){return b.set(t,e),t}(e,[e])}break;case"RELEASE":c=void 0;break;default:return}}catch(t){c={value:t,[l]:0}}Promise.resolve(c).catch((t=>({value:t,[l]:0}))).then((t=>{const[i,o]=w(t);e.postMessage(Object.assign(Object.assign({},i),{id:n}),o),"RELEASE"===r&&(e.removeEventListener("message",s),m(e))}))})),e.start&&e.start()}function m(t){(function(t){return"MessagePort"===t.constructor.name})(t)&&t.close()}function d(t,e){return p(t,[],e)}function g(t){if(t)throw new Error("Proxy has been released and is not useable")}function p(t,e=[],s=function(){}){let i=!1;const n=new Proxy(s,{get(s,o){if(g(i),o===a)return()=>v(t,{type:"RELEASE",path:e.map((t=>t.toString()))}).then((()=>{m(t),i=!0}));if("then"===o){if(0===e.length)return{then:()=>n};const s=v(t,{type:"GET",path:e.map((t=>t.toString()))}).then(C);return s.then.bind(s)}return p(t,[...e,o])},set(s,n,o){g(i);const[r,a]=w(o);return v(t,{type:"SET",path:[...e,n].map((t=>t.toString())),value:r},a).then(C)},apply(s,n,o){g(i);const a=e[e.length-1];if(a===r)return v(t,{type:"ENDPOINT"}).then(C);if("bind"===a)return p(t,e.slice(0,-1));const[l,h]=y(o);return v(t,{type:"APPLY",path:e.map((t=>t.toString())),argumentList:l},h).then(C)},construct(s,n){g(i);const[o,r]=y(n);return v(t,{type:"CONSTRUCT",path:e.map((t=>t.toString())),argumentList:o},r).then(C)}});return n}function f(t){return Array.prototype.concat.apply([],t)}function y(t){const e=t.map(w);return[e.map((t=>t[0])),f(e.map((t=>t[1])))]}const b=new WeakMap;function w(t){for(const[e,s]of c)if(s.canHandle(t)){const[i,n]=s.serialize(t);return[{type:"HANDLER",name:e,value:i},n]}return[{type:"RAW",value:t},b.get(t)||[]]}function C(t){switch(t.type){case"HANDLER":return c.get(t.name).deserialize(t.value);case"RAW":return t.value}}function v(t,e,s){return new Promise((i=>{const n=new Array(4).fill(0).map((()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16))).join("-");t.addEventListener("message",(function e(s){!s.data||!s.data.id||s.data.id!==n||(t.removeEventListener("message",e),i(s.data))})),t.start&&t.start(),t.postMessage(Object.assign({id:n},e),s)}))}const S="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2NvbnN0ICQ9U3ltYm9sKCJDb21saW5rLnByb3h5IiksQT1TeW1ib2woIkNvbWxpbmsuZW5kcG9pbnQiKSxSPVN5bWJvbCgiQ29tbGluay5yZWxlYXNlUHJveHkiKSx5PVN5bWJvbCgiQ29tbGluay50aHJvd24iKSxfPWU9PnR5cGVvZiBlPT0ib2JqZWN0IiYmZSE9PW51bGx8fHR5cGVvZiBlPT0iZnVuY3Rpb24iLEw9e2NhbkhhbmRsZTplPT5fKGUpJiZlWyRdLHNlcmlhbGl6ZSh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xvZyhgJWNbV2ViV29ya2VyXSVjICR7ZX1gLCJmb250LXdlaWdodDpib2xkIiwiIiwuLi5yKX19O3codCl9KSgpOwo=",T=typeof window<"u"&&window.Blob&&new Blob([atob(S)],{type:"text/javascript;charset=utf-8"});function M(){const t=T&&(window.URL||window.webkitURL).createObjectURL(T);try{return t?new Worker(t):new Worker("data:application/javascript;base64,"+S)}finally{t&&(window.URL||window.webkitURL).revokeObjectURL(t)}}const A={urlCDN:"https://biowasm.com/cdn/v3",urlCDNStg:"https://stg.biowasm.com/cdn/v3",dirShared:"/shared",dirMounted:"/mnt",dirData:"/data",printInterleaved:!0,callback:null,debug:!1,env:"prd"};class E{constructor(t,e={}){if(null==t)throw"Expecting array of tools as input to Aioli constructor.";return Array.isArray(t)||(t=[t]),e=Object.assign({},A,e),t=t.map(this._parseTool),"stg"===e.env&&(e.urlCDN=e.urlCDNStg),this.tools=t,this.config=e,null!=this.config.callback&&(this.callback=this.config.callback),delete this.config.callback,this.init()}async init(){const t=new M;this.callback&&(t.onmessage=t=>{"biowasm"===t.data.type&&this.callback(t.data.value)});const e=d(t);return e.tools=this.tools,e.config=this.config,await e.init(),e}_parseTool(t){if("string"!=typeof t)return t;const e=t.split("/");if(2!=e.length&&3!=e.length)throw"Expecting '<tool>/<version>' or '<tool>/<program>/<version>'";return{tool:e[0],program:3==e.length?e[1]:e[0],version:e[e.length-1]}}}var x=s(850);class I{static getAvailableScales(){return Object.entries(this.scales).map((([t,e])=>t))}static getScale(t){return(0,x.hu)(!(void 0===this.scales[t]),`Scale '${t}' was not found.`),this.scales[t]}}I.scales={WimleyWhite:{"-":0,A:.17,C:-.24,D:-.07,E:-.01,F:-1.13,G:.01,H:.17,I:-.31,K:.99,L:-.56,M:-.23,N:.42,P:.45,Q:.58,R:.81,S:.13,T:.14,V:.07,W:-1.85,Y:-.94},categorial:{"-":0,A:1,C:2,D:3,E:4,F:5,G:6,H:7,I:8,K:9,L:10,M:11,N:12,P:13,Q:14,R:15,S:16,T:17,V:18,W:19,Y:20}};class N{constructor(t="categorial"){this.aa2num=I.getScale(t),this.num2aa={},Object.entries(this.aa2num).forEach((([t,e])=>this.num2aa[e]=t))}static _truncateSequence(t){let e=0,s=t.length;const i=["NH2","COOH"];if(t.startsWith(i[0])){const s=i[0].length;(0,x.hu)("-"==t[s],`Wrong sequence format: ${i[0]} without following '-' in '${t}'.`),e=s}if(t.endsWith(i[1])){const e=i[1].length+1;(0,x.hu)("-"==t[s-e],`Wrong sequence format: ${i[1]} without '-' precending in '${t}'.`),s-=e}return t.substring(e,s)}static _dropDefises(t){return t.replace(/(-)([^-]+)/g,"$2")}static clean(t){return N._dropDefises(N._truncateSequence(t))}encode(t){const e=t.length,s=new Array(e).fill(0);for(let i=0;i<e;++i){const e=t[i];(0,x.hu)(e in this.aa2num,`Unknown char '${e}' found in sequence '${t}'`),s[i]=this.encodeLettter(e)}return s}encodeLettter(t){return this.aa2num[t]}decode(t){let e="";for(let s=0;s<t.length;++s){const i=t[s];(0,x.hu)(i in this.num2aa,`Unknown code '${i}' found in vector '${t}'`),e+=this.num2aa[i]}return e}}var L=s(3553);const _="input.fa",R="result.fasta";function O(t){return t.reduce(((t,e,s)=>t+`>sample${s+1}\n${e}\n`),"")}async function k(t,e=!1,s="",o=null,r,a,l){let h=t.toList();e&&(h=h.map((t=>N.clean(t).replace(/\-/g,""))));const c=t.length;o??(o=i.Column.string("Clusters",c).init("0")),o.type!=i.COLUMN_TYPE.STRING&&(o=o.convertTo(i.TYPE.STRING)),o.compact();const u=o.categories,m=o.getRawData(),d=new Array(u.length),g=new Array(u.length);for(let t=0;t<c;++t){const e=m[t];(d[e]??(d[e]=[])).push(h[t]),(g[e]??(g[e]=[])).push(t)}const p=await new E(["base/1.0.0",{tool:"kalign",version:L.WY,reinit:!0}]),f=i.Column.string(s,c);for(let t=0;t<u.length;++t){const e=O(d[t]);await p.fs.writeFile(_,e);const s=`${void 0!==r?` --gpo ${r}`:""}${void 0!==a?` --gpe ${a}`:""}${void 0!==l?` --tgpe ${l}`:""}`,i=await p.exec(`kalign ${_} -f fasta -o ${R}${s}`);console.warn(i);const o=await p.cat(R);if(!o)throw new Error("kalign output no result");const h=new n.i(o).sequencesArray,c=g[t];for(let t=0;t<h.length;++t)f.set(c[t],h[t])}const y=t.getTag(i.TAGS.UNITS),b=t.getTag("alphabet");return f.setTag(i.TAGS.UNITS,y),f.setTag("aligned","SEQ.MSA"),f.setTag("alphabet",b),f.semType=i.SEMTYPE.MACROMOLECULE,f}},8341:(t,e,s)=>{"use strict";s.d(e,{J:()=>a,f:()=>h});var i=s(4469),n=s(976),o=s(8447),r=s(3553);const a=["mafft --auto","mafft","linsi","ginsi","einsi","fftns","fftnsi","nwns","nwnsi"],l=["AlignedSeq","AlignedSubpeptide","HELM","ID","PolymerID"];async function h(t,e,s="ginsi",a=1.53,h=0,u=null){const m=await i.dapi.docker.dockerContainers.filter("bio").first();if("started"!==m.status&&"checking"!==m.status)return i.log.warning("PepSeA container has not started yet"),null;const d=t.length;u??(u=n.Column.int("Clusters",d).init(0)),u.type!=n.COLUMN_TYPE.STRING&&(u=u.convertTo(n.TYPE.STRING));const g=u.categories,p=new Array(g.length);for(let e=0;e<d;++e){const s=u.get(e);if(""===s)continue;const i=g.indexOf(s),n=t.get(e);n&&(p[i]??(p[i]=[])).push({ID:e.toString(),HELM:n})}const f=new Array(d);for(const t of p){const e=(await c(m.id,t,s,a,h)).Alignment;for(const t of e)f[parseInt(t.ID)]=Object.entries(t).filter((t=>!l.includes(t[0]))).map((t=>"-"!==t[1]?t[1]:"")).join(r.rs.SEPARATOR)}const y=n.Column.fromStrings(e,f);return y.setTag(n.TAGS.UNITS,o.r2.SEPARATOR),y.setTag("separator",r.rs.SEPARATOR),y.setTag("aligned","SEQ.MSA"),y.setTag("alphabet","UN"),y.setTag(".alphabetIsMultichar","true"),y.semType=n.SEMTYPE.MACROMOLECULE,y}async function c(t,e,s,n,o){const r={method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(e)},a=`/align?method=${s}&gap_open=${n}&gap_extend=${o}`,l=await i.dapi.docker.dockerContainers.request(t,a,r);return JSON.parse(l??"{}")}},9943:(t,e,s)=>{"use strict";s.d(e,{C2:()=>u});var i=s(976),n=s(3870),o=s(4469),r=s(6414),a=s.n(r),l=s(8447),h=s(499);const c=60;function u(){const t=o.shell.tv.grid,e=a().count(0).take(t.columns.length).map((e=>t.columns.byIndex(e))).filter((t=>!!t.column&&t.column.semType!==i.SEMTYPE.MACROMOLECULE)).toArray(),s=e.find((t=>-1!==t.name.toLowerCase().indexOf("id"))),r=s?[s.name]:[],u=n.multiChoiceInput("Seq id columns",r,e.map((t=>t.name))),d=a().count(0).take(t.columns.length).map((e=>t.columns.byIndex(e))).filter((t=>{const e=t.column;return!(!e||e.semType!==i.SEMTYPE.MACROMOLECULE)&&h.Cn.getOrCreate(e).isFasta()})).toArray(),g=d.length>0?d[0].name:[],p=n.choiceInput("Seq column",g,d.map((t=>t.name))),f=n.intInput("FASTA line width",c);n.dialog({title:"Save as FASTA"}).add(n.inputs([u,p,f])).onOK((()=>{const e=u.value?u.value.map((e=>t.columns.byName(e).column)):[],s=p.value?t.columns.byName(p.value).column:null,i=f.value??c;s||o.shell.warning("Seq column is mandatory to save as FASTA.");const n=function(t,e,s=c,i="\n"){const n=l.kB,o=[];for(let r=0;r<e.length;r++){const a=t.map((t=>t.get(r).toString())).join("|"),l=m(e.get(r),n,s);o.push(`>${a}${i}`);for(const t of l)o.push(`${t}${i}`)}return"".concat(...o)}(e,s,i),r=document.createElement("a");r.setAttribute("href",`data:text/plain;charset=utf-8,${encodeURIComponent(n)}`),r.setAttribute("download",`${t.dataFrame.name}.fasta`),r.click()})).show()}function m(t,e,s=c){const i=e(t);let n=0;const o=i.length,r=[];for(;n<o;){const t=a()(i).slice(n,n+s).toArray(),e=t.map((t=>t.length>1?`[${t}]`:t)).join("");r.push(e),n+=t.length}return r}},9416:(t,e,s)=>{"use strict";s.d(e,{n:()=>h});var i=s(4469),n=s(976),o=s(1061),r=s(2568),a=s(8457),l=s(3553);async function h(t,e){if(await(0,o.gw)(10),!(0,r.n)(e,"Sequence space"))return t;const s=(0,a.O)(e);s.name="splitToMonomers";const h=e.dataFrame;for(const t of s.columns)t.semType=l.Of.MONOMER,t.setTag("alphabet",e.getTag("alphabet"));const c=/(\d+)(?: \((\d+)\))?/,u=t=>{c.lastIndex=0;const e=t.match(c);return e?`${e[1]} (${parseInt(e[2]??0)+1})`:t};for(let t=0;t<s.columns.length;t++){const i=s.columns.byIndex(t);i.semType=l.Of.MONOMER,i.setTag("alphabet",e.getTag("alphabet"));const n=100;let o=0;for(;h.columns.byName(i.name)&&o<n;)i.name=u(i.name),o++;h.columns.add(i)}await i.data.detectSemanticTypes(h);for(let t=0;t<s.columns.length;t++){const e=s.columns.byIndex(t);e.setTag(n.TAGS.CELL_RENDERER,"Monomer"),e.setTag(".use-as-filter","false")}return h}},4293:(t,e,s)=>{"use strict";s.d(e,{B:()=>o,Y:()=>r});var i=s(4469),n=s(976);function o(){const t=i.shell.t.columns.bySemTypeAll(n.SEMTYPE.MACROMOLECULE);if(null!==t)return t;i.shell.error("Current table does not contain macromolecules")}function r(t,e){t.innerHTML="",t.append(e)}},833:(t,e,s)=>{"use strict";s.d(e,{bo:()=>g,OZ:()=>v});var i=s(4469),n=s(3870),o=s(976),r=s(6414),a=s.n(r),l=s(701),h=s(499),c=s(8447),u=s(9298);function m(t){var e;return"string"==typeof t||t instanceof String?t:("object"==typeof t||t instanceof Object)&&"$thrownJsError"in t?m(t.$thrownJsError):t instanceof Error?null!==(e=t.stack)&&void 0!==e?e:t.message:t.toString()}var d,g,p=s(7958),f=s(2904);HTMLCanvasElement.prototype.getCursorPosition=function(t,e){const s=this.getBoundingClientRect();return new o.Point((t.clientX-s.left)*e,(t.clientY-s.top)*e)},o.Rect.prototype.contains=function(t,e){return this.left<=t&&t<=this.right&&this.top<=e&&e<=this.bottom};class y{constructor(t=0,e){this.count=t,this.bounds=e}}class b{get label(){return this._label?this._label:this.name}constructor(t,e,s,i){this.pos=t,this.name=e,this._freqs=s??{},i?.rowCount&&(this.rowCount=i.rowCount),i?.sumForHeightCalc&&(this.sumForHeightCalc=i.sumForHeightCalc),i?.label&&(this._label=i.label)}getMonomers(){return Object.keys(this._freqs)}hasMonomer(t){return t in this._freqs}getFreq(t){let e=this._freqs[t];return e||(e=this._freqs[t]=new y),e}getMonomerAt(t,e){const s=Object.entries(this._freqs).find((([s,i])=>i.bounds.contains(t,e)));return s?s[0]:void 0}calcHeights(t){this.rowCount=0;for(const[t,e]of Object.entries(this._freqs))this.rowCount+=e.count;if(this.sumForHeightCalc=0,t===u.ES.Entropy)for(const[t,e]of Object.entries(this._freqs)){const t=e.count/this.rowCount;this.sumForHeightCalc+=-t*Math.log2(t)}else if(t===u.ES.full)for(const[t,e]of Object.entries(this._freqs)){const t=e.count/this.rowCount;this.sumForHeightCalc+=t}}calcScreen(t,e,s,i,n,r,a,l,h,c){const m=n==u.ES.Entropy?i*(r-this.sumForHeightCalc)/r:i;let d=c*h+(i-m-1);const g=Object.entries(this._freqs).sort(((e,s)=>t(e[0])||t(s[0])?t(e[0])&&t(s[0])?0:t(e[0])?-1:1:s[1].count-e[1].count));for(const t of g){const i=t[1],n=m*i.count/this.rowCount;i.bounds=new o.Rect((e-s)*h*a,d,l*h,n),d+=n}}render(t,e,s,i,n,o){for(const[r,a]of Object.entries(this._freqs))if(!e(r)){const e=(0,c.GU)(r,5),l=a.bounds,h=l.left;t.resetTransform(),t.strokeStyle="lightgray",t.lineWidth=1,t.rect(h,l.top,l.width,l.height),t.fillStyle=o.get(r)??o.get("other"),t.textAlign="left",t.font=s;const u=t.measureText(e);t.setTransform(l.width/u.width,0,0,l.height/n,h,l.top),t.fillText(e,0,-i)}}}!function(t){t.STYLE="Style",t.BEHAVIOR="Behavior",t.LAYOUT="Layout",t.DATA="Data"}(d||(d={})),function(t){t.sequenceColumnName="sequenceColumnName",t.startPositionName="startPositionName",t.endPositionName="endPositionName",t.skipEmptySequences="skipEmptySequences",t.skipEmptyPositions="skipEmptyPositions",t.shrinkEmptyTail="shrinkEmptyTail",t.backgroundColor="backgroundColor",t.positionHeight="positionHeight",t.positionWidth="positionWidth",t.verticalAlignment="verticalAlignment",t.horizontalAlignment="horizontalAlignment",t.fixWidth="fixWidth",t.fitArea="fitArea",t.minHeight="minHeight",t.maxHeight="maxHeight",t.showPositionLabels="showPositionLabels",t.positionMarginState="positionMarginState",t.positionMargin="positionMargin",t.filterSource="filterSource"}(g||(g={}));const w=u.vS;var C;!function(t){t[t.None=0]="None",t[t.Render=1]="Render",t[t.Layout=1]="Layout",t[t.Freqs=2]="Freqs"}(C||(C={}));class v extends o.JsViewer{get positionWidthWithMargin(){return this._positionWidthWithMargin}get Length(){return this.skipEmptyPositions?this.positions.length:this.startPosition<=this.endPosition?this.endPosition-this.startPosition+1:0}get positionMarginValue(){return this.positionMarginState===u.dE.AUTO&&!0===this.unitsHandler.getAlphabetIsMultichar()||this.positionMarginState===u.dE.ON?this.positionMargin:0}constructor(){super(),this.viewed=!1,this.viewerId=-1,this.initialized=!1,this.cp=null,this.seqCol=null,this.positions=[],this.visibleSlider=!1,this.allowResize=!0,this.turnOfResizeForOneSetValue=!1,this.backgroundColor=4294967295,this.positionMargin=0,this.positionNames=[],this.positionLabels=void 0,this.startPosition=-1,this.endPosition=-1,this.error=null,this.viewPromise=Promise.resolve(),this.detachPromise=Promise.resolve(),this.setDataInProgress=!1,this.viewSubs=[],this._onSizeChanged=new l.Subject,this._onFreqsCalculated=new l.Subject,this._onLayoutCalculated=new l.Subject,this.requestedRenderLevel=C.Freqs,this.renderRequest=new l.Subject,this.viewerId=v.viewerCount,v.viewerCount+=1,this.textBaseline="top",this.unitsHandler=null,this.sequenceColumnName=this.string(g.sequenceColumnName,w.sequenceColumnName,{category:d.DATA}),this.startPositionName=this.string(g.startPositionName,w.startPositionName,{category:d.DATA}),this.endPositionName=this.string(g.endPositionName,w.endPositionName,{category:d.DATA}),this.skipEmptySequences=this.bool(g.skipEmptySequences,w.skipEmptySequences,{category:d.DATA}),this.skipEmptyPositions=this.bool(g.skipEmptyPositions,w.skipEmptyPositions,{category:d.DATA}),this.shrinkEmptyTail=this.bool(g.shrinkEmptyTail,w.shrinkEmptyTail,{category:d.DATA}),this.backgroundColor=this.int(g.backgroundColor,w.backgroundColor,{category:d.STYLE}),this.positionHeight=this.string(g.positionHeight,w.positionHeight,{category:d.STYLE,choices:Object.values(u.ES)}),this._positionWidth=this.positionWidth=this.float(g.positionWidth,w.positionWidth,{category:d.STYLE}),this.verticalAlignment=this.string(g.verticalAlignment,w.verticalAlignment,{category:d.LAYOUT,choices:Object.values(u.vw)}),this.horizontalAlignment=this.string(g.horizontalAlignment,w.horizontalAlignment,{category:d.LAYOUT,choices:Object.values(u.iD)}),this.fixWidth=this.bool(g.fixWidth,w.fixWidth,{category:d.LAYOUT,userEditable:!1}),this.fitArea=this.bool(g.fitArea,w.fitArea,{category:d.LAYOUT}),this.minHeight=this.float(g.minHeight,w.minHeight,{category:d.LAYOUT}),this.maxHeight=this.float(g.maxHeight,w.maxHeight,{category:d.LAYOUT}),this.showPositionLabels=this.bool(g.showPositionLabels,w.showPositionLabels,{category:d.LAYOUT}),this.positionMarginState=this.string(g.positionMarginState,w.positionMarginState,{category:d.LAYOUT,choices:Object.values(u.dE)});let t=0;"auto"===this.positionMarginState&&(t=4),this.positionMargin=this.int(g.positionMargin,t,{category:d.LAYOUT,min:0,max:16}),this.filterSource=this.string(g.filterSource,w.filterSource,{category:d.BEHAVIOR,choices:Object.values(u.Ct)}),this.slider=n.rangeSlider(0,100,0,20,!1,{style:"barbell"}),this.canvas=n.canvas(),this.canvas.classList.value="bio-wl-canvas",this.canvas.style.width="100%"}setData(){f._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.setData(), in`),this.viewPromise=this.viewPromise.then((async()=>{if(!this.setDataInProgress){this.setDataInProgress=!0;try{this.viewed&&(this.renderRequestSub.unsubscribe(),await this.destroyView(),this.viewed=!1),await this.detachPromise,this.updateSeqCol(),this.viewed||(await this.buildView(),this.viewed=!0)}catch(t){const[e,s]=(0,p.yf)(t);i.shell.error(e),f._package.logger.error(e,void 0,s)}finally{this.setDataInProgress=!1}}}))}async destroyView(){for(const t of this.viewSubs)t.unsubscribe();this.viewSubs=[];const t=this.dataFrame?"data":"null";f._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.destroyView( dataFrame = ${t} ) start`),this.host.remove(),this.msgHost=void 0,this.host=void 0,f._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.destroyView() end`)}async buildView(){const t=this.dataFrame?"data":"null";f._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.buildView( dataFrame = ${t} ) start`),window.devicePixelRatio,this.viewSubs.push(o.debounce(this.renderRequest).subscribe(this.renderRequestOnDebounce.bind(this))),this.helpUrl="/help/visualize/viewers/web-logo.md",this.msgHost=n.div("No message",{classes:"bio-wl-msg"}),this.msgHost.style.display="none",this.canvas=n.canvas(),this.canvas.style.width="100%",this.slider.root.style.position="absolute",this.slider.root.style.zIndex="999",this.slider.root.style.display="none",this.slider.root.style.height="0.7em",this.visibleSlider=!1,this.host=n.div([this.msgHost,this.canvas],{classes:"bio-wl-host",style:{display:"flex",flexDirection:"row",flexWrap:"wrap"}}),this.root.append(this.host),this.root.append(this.slider.root),this.error&&(this.msgHost.innerText=this.error.message,n.tooltip.bind(this.msgHost,this.error.stack),this.msgHost.style.setProperty("display",null)),this.dataFrame&&(this.viewSubs.push(this.dataFrame.filter.onChanged.subscribe(this.dataFrameFilterOnChanged.bind(this))),this.viewSubs.push(this.dataFrame.selection.onChanged.subscribe(this.dataFrameSelectionOnChanged.bind(this)))),this.viewSubs.push(n.onSizeChanged(this.root).subscribe(this.rootOnSizeChanged.bind(this))),this.viewSubs.push(this.slider.onValuesChanged.subscribe(this.sliderOnValuesChanged.bind(this))),this.viewSubs.push((0,l.fromEvent)(this.canvas,"mousemove").subscribe(this.canvasOnMouseMove.bind(this))),this.viewSubs.push((0,l.fromEvent)(this.canvas,"mousedown").subscribe(this.canvasOnMouseDown.bind(this))),this.viewSubs.push((0,l.fromEvent)(this.canvas,"wheel").subscribe(this.canvasOnWheel.bind(this))),await this.render(C.Freqs,"buildView"),f._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.buildView() end`)}rootOnSizeChanged(){f._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.rootOnSizeChanged(), start `),this.render(C.Layout,"rootOnSizeChanged")}updateSeqCol(){if(this.dataFrame&&(this.seqCol=this.sequenceColumnName?this.dataFrame.col(this.sequenceColumnName):null,null==this.seqCol&&(this.seqCol=(0,c.up)(this.dataFrame),this.sequenceColumnName=this.seqCol?this.seqCol.name:null),this.seqCol)){try{this.unitsHandler=h.Cn.getOrCreate(this.seqCol),this.cp=(0,c.dQ)(this.seqCol),this.updatePositions(),this.error=null}catch(t){throw this.seqCol=null,this.error=t instanceof Error?t:new Error(t.toString()),t}this.seqCol||(this.unitsHandler=null,this.positionNames=[],this.positionLabels=[],this.startPosition=-1,this.endPosition=-1,this.cp=null)}}updatePositions(){if(!this.seqCol)return;const t=this.getFilter(),e=0===t.trueCount?this.unitsHandler.maxLength:a().enumerate(this.unitsHandler.splitted).map((([e,s])=>t.get(s)&&e?e.length:0)).reduce(((t,e)=>Math.max(t,e)),0),s=this.seqCol.getTag(".positionNames"),i=this.seqCol.getTag(".positionLabels");this.positionNames=s?s.split(c.CI).map((t=>t.trim())):[...Array(e).keys()].map((t=>`${t+1}`)),this.positionLabels=i?i.split(c.CI).map((t=>t.trim())):void 0,this.startPosition=this.startPositionName&&this.positionNames&&this.positionNames.includes(this.startPositionName)?this.positionNames.indexOf(this.startPositionName):0,this.endPosition=this.endPositionName&&this.positionNames&&this.positionNames.includes(this.endPositionName)?this.positionNames.indexOf(this.endPositionName):e-1,this.render(C.Freqs,"updatePositions")}getFilter(){let t;switch(this.filterSource){case u.Ct.Filtered:t=this.dataFrame.filter;break;case u.Ct.Selected:t=0===this.dataFrame.selection.trueCount?this.dataFrame.filter:this.dataFrame.selection}return t}setSliderVisibility(t){t?(this.slider.root.style.display="inherit",this.visibleSlider=!0):(this.slider.root.style.display="none",this.visibleSlider=!1)}calcLayout(t){this.host&&this.canvas&&this.slider&&(this.host.classList.remove("bio-wl-fixWidth","bio-wl-fitArea"),this.canvas.classList.remove("bio-wl-fixWidth","bio-wl-fitArea"),this._positionWidth=this.positionWidth,this._positionMargin=this.positionMargin,this._positionWidthWithMargin=this._positionWidth+this.positionMarginValue,this.fixWidth?this.calcLayoutFixWidth(t):this.fitArea?this.calcLayoutFitArea(t):this.calcLayoutNoFitArea(t),this.slider.root.style.width=`${this.host.clientWidth}px`)}calcLayoutFixWidth(t){if(!this.host||!this.canvas||!this.slider)return;this.host.classList.add("bio-wl-fixWidth"),this.canvas.classList.add("bio-wl-fitArea");const e=this._positionWidthWithMargin*this.Length,s=Math.min(Math.max(this.minHeight,this.root.clientHeight),this.maxHeight);this.host.style.justifyContent=u.iD.LEFT,this.host.style.removeProperty("margin-left"),this.host.style.removeProperty("margin-top"),this.host.style.width=this.canvas.style.width=`${e}px`,this.host.style.height=this.canvas.style.height=`${s}px`,this.host.style.left=this.canvas.style.left="0",this.host.style.top=this.canvas.style.top="0",this.host.style.setProperty("overflow","hidden","important"),this.slider.root.style.display="none",this.slider.setValues(0,Math.max(0,this.Length-1),0,Math.max(0,this.Length-1)),this.canvas.width=e*t,this.canvas.height=s*t}calcLayoutNoFitArea(t){if(!this.host||!this.canvas||!this.slider)return;const e=this._positionWidthWithMargin*this.Length,s=Math.min(Math.max(this.minHeight,this.root.clientHeight),this.maxHeight),i=Math.min(this.root.clientWidth,e);this.canvas.style.width=`${i}px`,this.canvas.style.height=`${s}px`,this.host.style.width=`${i}px`,this.host.style.height=`${this.root.clientHeight}px`,this.host.style.justifyContent=this.horizontalAlignment,this.host.style.alignContent=this.verticalAlignment===u.vw.TOP?"start":this.verticalAlignment===u.vw.MIDDLE?"center":this.verticalAlignment===u.vw.BOTTOM?"end":"inherit",this.root.clientHeight<this.minHeight&&(this.host.style.alignContent="start",this.host.style.width=`${i+6}px`),this.host.style.width=`${this.host}px`;const n=e>i;if(this.setSliderVisibility(n),n){this.slider.root.style.removeProperty("display"),this.host.style.justifyContent="left",this.host.style.height=this.root.clientHeight-this.slider.root.offsetHeight+"px",this.slider.root.style.top=`${this.host.offsetHeight}px`;let t=Math.min(Math.max(0,this.slider.min),this.Length-.001),e=Math.min(Math.max(0,this.slider.max),this.Length-.001);const s=this.root.clientWidth/this._positionWidthWithMargin;e=Math.min(Math.max(t,0)+s,this.Length-.001),t=Math.max(0,Math.min(e,this.Length-.001)-s),this.slider.setValues(0,Math.max(this.Length-.001),t,e)}else this.slider.setValues(0,Math.max(0,this.Length-.001),0,Math.max(0,this.Length-.001));this.canvas.width=i*t,this.canvas.height=s*t}calcLayoutFitArea(t){if(!this.host||!this.canvas||!this.slider)return;const e=this._positionWidth*this.Length,s=Math.min(Math.max(this.minHeight,this.root.clientHeight),this.maxHeight),i=e>0?(this.root.clientWidth-this.positionMarginValue*this.Length)/e:0,n=this.root.clientHeight/s,o=Math.max(1,Math.min(i,n));this._positionWidth=this.positionWidth*o,this._positionWidthWithMargin=this._positionWidth+this.positionMarginValue;const r=(this._positionWidth+this.positionMarginValue)*this.Length,a=o*s,l=Math.min(this.root.clientWidth,r);this.canvas.style.width=`${l}px`,this.canvas.style.height=`${a}px`,this.host.style.width=`${l}px`,this.host.style.height=`${this.root.clientHeight}px`,this.host.style.justifyContent=this.horizontalAlignment,this.host.style.alignContent=this.verticalAlignment===u.vw.TOP?"start":this.verticalAlignment===u.vw.MIDDLE?"center":this.verticalAlignment===u.vw.BOTTOM?"end":"inherit",this.root.clientHeight<this.minHeight&&(this.host.style.alignContent="start",this.host.style.width=`${l+6}px`),this.host.style.width=`${this.host}px`;const h=r>l;if(this.setSliderVisibility(h),h){this.slider.root.style.removeProperty("display"),this.host.style.justifyContent="left",this.host.style.height=this.root.clientHeight-this.slider.root.offsetHeight+"px",this.slider.root.style.top=`${this.host.offsetHeight}px`;let t=Math.min(Math.max(0,this.slider.min),this.Length-.001),e=Math.min(Math.max(0,this.slider.max),this.Length-.001);const s=this.root.clientWidth/this._positionWidthWithMargin;e=Math.min(Math.max(t,0)+s,this.Length-.001),t=Math.max(0,Math.min(e,this.Length-.001)-s),this.slider.setValues(0,Math.max(0,this.Length-.001),t,e)}else this.slider.setValues(0,Math.max(0,this.Length-.001),0,Math.max(0,this.Length-.001));this.canvas.width=l*t,this.canvas.height=a*t}onPropertyChanged(t){switch(super.onPropertyChanged(t),t.name){case g.sequenceColumnName:this.updateSeqCol();break;case g.sequenceColumnName:case g.startPositionName:case g.endPositionName:case g.filterSource:case g.shrinkEmptyTail:case g.skipEmptyPositions:case g.positionHeight:this.updatePositions();break;case g.minHeight:case g.maxHeight:case g.positionWidth:case g.showPositionLabels:case g.fixWidth:case g.fitArea:case g.horizontalAlignment:case g.verticalAlignment:case g.positionMargin:case g.positionMarginState:this.render(C.Layout,`onPropertyChanged(${t.name})`);break;case g.backgroundColor:this.render(C.Render,`onPropertyChanged(${t.name})`)}}onTableAttached(){f._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.onTableAttached(), `),super.onTableAttached(),this.setData()}async detach(){f._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.detach(), `);const t=super.detach.bind(this);this.detachPromise=this.detachPromise.then((async()=>{await this.viewPromise,this.setDataInProgress||(this.viewed&&(await this.destroyView(),this.viewed=!1),t())}))}get onSizeChanged(){return this._onSizeChanged}get onFreqsCalculated(){return this._onFreqsCalculated}get onLayoutCalculated(){return this._onLayoutCalculated}getMonomer(t,e){const s=t.x,i=Math.floor(t.x/(this._positionWidthWithMargin*e)+Math.floor(this.slider.min)),n=this.positions[i];if(void 0===n)return[i,null,null];const o=n.getMonomerAt(s,t.y);return void 0===o?[i,null,null]:[i,o,n.getFreq(o)]}_nullSequence(t="X"){return this.skipEmptySequences?"":new Array(this.Length).fill(t).join("")}_removeEmptyPositions(){this.skipEmptyPositions&&(this.positions=a()(this.positions).filter((t=>{const e=this.unitsHandler.defaultGapSymbol;return!t.hasMonomer(e)||t.getFreq(e).count!==t.rowCount})).toArray())}render(t,e){f._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.render( recalcLevelVal=${t}, reason='${e}' )`),this.requestedRenderLevel=Math.max(this.requestedRenderLevel,t),this.renderRequest.next(this.requestedRenderLevel)}async renderInt(t){if(f._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.render.renderInt( renderLevel=${t} ), start `),this.msgHost&&(this.seqCol&&!this.cp?(this.msgHost.innerText=`Unknown palette (column semType: '${this.seqCol.semType}').`,this.msgHost.style.display=""):this.msgHost.style.display="none"),!this.seqCol||!this.dataFrame||!this.cp||null==this.host||null==this.slider)return;const e=window.devicePixelRatio,s=this.showPositionLabels?12:0;if(t>=C.Freqs&&(()=>{if(f._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.render.calculateFreqsInt(), start `),!this.host||!this.seqCol||!this.dataFrame)return;const t=this.startPosition<=this.endPosition?this.endPosition-this.startPosition+1:0;this.unitsHandler=h.Cn.getOrCreate(this.seqCol);const e=this.startPosition<=this.endPosition?this.endPosition-this.startPosition+1:0;this.positions=new Array(e);for(let e=0;e<t;e++){const t=this.positionNames[this.startPosition+e],s=this.positionLabels?this.positionLabels[this.startPosition+e]:void 0;this.positions[e]=new b(this.startPosition+e,t,{},{label:s})}const s=this.getFilter(),i=this.dataFrame.rowCount,n=this.unitsHandler.splitted;for(let e=0;e<i;++e)if(s.get(e)){const s=n[e];for(let e=0;e<t;++e){const t=s[this.startPosition+e]||this.unitsHandler.defaultGapSymbol;this.positions[e].getFreq(t).count++}}for(let e=0;e<t;e++)this.positions[e].calcHeights(this.positionHeight);this._removeEmptyPositions(),this._onFreqsCalculated.next()})(),this.calcLayout(e),0===this.positions.length||-1===this.startPosition||-1===this.endPosition)return;t>=C.Layout&&((t,e)=>{f._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.render.calculateLayoutInt(), start `);const s=this.canvas.height-e*t,n=this.getAlphabetSize();this.positionHeight==u.ES.Entropy&&null==n&&i.shell.error("WebLogo: alphabet is undefined.");const o=Math.log2(n);for(let i=Math.floor(this.slider.min);i<=Math.floor(this.slider.max);++i)i in this.positions?this.positions[i].calcScreen((t=>this.unitsHandler.isGap(t)),i,this.slider.min,s,this.positionHeight,o,this._positionWidthWithMargin,this._positionWidth,t,e):console.warn(`Bio: WebLogoViewer<${this.viewerId}>.render.calculateLayoutInt() this.positions.length = ${this.positions.length}, jPos = ${i}`);f._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.render.calculateLayoutInt(), end `),this._onLayoutCalculated.next()})(window.devicePixelRatio,s);const n=this.canvas.getContext("2d");if(!n)return;this.Length,n.resetTransform(),n.fillStyle=function(t){const e=o.Color.a(t);return`#${(16777215&t).toString(16).padStart(6,"0")}`+e.toString(16).padStart(2,"0")}(this.backgroundColor),n.fillRect(0,0,this.canvas.width,this.canvas.height),n.textBaseline=this.textBaseline;const r=10*e;n.resetTransform(),n.fillStyle="black",n.textAlign="center",n.font=`${r.toFixed(1)}px Roboto, Roboto Local, sans-serif`;const a=Math.max(...this.positions.map((t=>n.measureText(t.name).width))),l=a<this._positionWidth*e-2?1:(this._positionWidth*e-2)/a;s>0&&function(t,e,s,i,n,o,r,a){for(let l=Math.floor(r);l<=Math.floor(a);l++){const a=o[l];t.resetTransform(),t.setTransform(s,0,0,1,(l-r)*i*e+n*e/2,0),t.fillText(a.label,0,1)}}(n,e,l,this._positionWidthWithMargin,this._positionWidth,this.positions,this.slider.min,this.slider.max);for(let t=Math.floor(this.slider.min);t<=Math.floor(this.slider.max);t++)this.positions[t].render(n,(t=>this.unitsHandler.isGap(t)),"16px Roboto, Roboto Local, sans-serif",.25,12.2,this.cp);f._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.render.renderInt( recalcLevel=${t} ), end`)}renderRequestOnDebounce(t){this.requestedRenderLevel=C.None,this.renderInt(t).catch((t=>{const[e,s]=(0,p.yf)(t);f._package.logger.error(e,void 0,s)}))}getAlphabetSize(){return this.unitsHandler?.getAlphabetSize()??0}sliderOnValuesChanged(t){try{const t={minRange:this.slider.minRange,min:this.slider.min,max:this.slider.max,maxRange:this.slider.maxRange};f._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.sliderOnValuesChanged( ${JSON.stringify(t)} ), start`),this.render(C.Layout,"sliderOnValuesChanged")}catch(t){const e=m(t);f._package.logger.error(`Bio: WebLogoViewer<${this.viewerId}>.sliderOnValuesChanged() error:\n`+e)}}dataFrameFilterOnChanged(t){f._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.dataFrameFilterChanged()`);try{this.updatePositions(),this.filterSource===u.Ct.Filtered&&this.render(C.Freqs,"dataFrameFilterOnChanged")}catch(t){const e=m(t);f._package.logger.error(`Bio: WebLogoViewer<${this.viewerId}>.dataFrameFilterOnChanged() error:\n`+e)}}dataFrameSelectionOnChanged(t){f._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.dataFrameSelectionOnChanged()`);try{this.filterSource===u.Ct.Selected&&this.render(C.Freqs,"dataFrameSelectionOnChanged")}catch(t){const e=m(t);f._package.logger.error(`Bio: WebLogoViewer<${this.viewerId}>.dataFrameSelectionOnChanged() error:\n`+e)}}canvasOnMouseMove(t){const e=window.devicePixelRatio;try{const s=t,i=this.canvas.getCursorPosition(s,e),[o,r]=this.getMonomer(i,e);if(this.dataFrame&&this.seqCol&&r){const t=this.positions[o],e=function(t,e,s,i,n){let o=0,r=-1;for(;-1!=(r=s.findNext(r,!0));){const t=e.splitted[r],s=n.pos;(s<t.length?t[s]:null)===i&&o++}return o}(this.dataFrame,this.unitsHandler,this.getFilter(),r,t),i=n.div([n.div(`${r}`),n.div(`${e} rows`)]);n.tooltip.show(i,s.x+16,s.y+16)}else n.tooltip.hide()}catch(t){const e=m(t);f._package.logger.error(`Bio: WebLogoViewer<${this.viewerId}>.canvasOnMouseMove() error:\n`+e)}}canvasOnMouseDown(t){try{const e=t,s=window.devicePixelRatio,[i,n]=this.getMonomer(this.canvas.getCursorPosition(e,s),s);if(this.dataFrame&&this.seqCol&&this.unitsHandler&&n){const t=this.positions[i],e=o.BitSet.create(this.dataFrame.selection.length,(e=>function(t,e,s,i,n,o){const r=e.splitted[i],a=o.pos<r.length?r[o.pos]:null;return a===n||""===a&&n===e.defaultGapSymbol}(this.dataFrame,this.unitsHandler,this.getFilter(),e,n,t)));this.dataFrame.selection.init((t=>e.get(t)))}}catch(t){const e=m(t);f._package.logger.error(`Bio: WebLogoViewer<${this.viewerId}>.canvasOnMouseDown() error:\n`+e)}}canvasOnWheel(t){const e=window.devicePixelRatio;try{if(!this.visibleSlider)return;const s=this.canvas.width/(this._positionWidthWithMargin*e),i=t.deltaY/100*Math.max(Math.floor(s/5),1);this.slider.scrollBy(this.slider.min+i)}catch(t){const e=m(t);f._package.logger.error(`Bio: WebLogoViewer<${this.viewerId}>.canvasOnWheel() error:\n`+e)}}}v.residuesSet="nucleotides",v.viewerCount=0},4413:(t,e,s)=>{"use strict";s.d(e,{ST:()=>g});var i=s(3870),n=s(976),o=s(4469),r=s(6414),a=s.n(r),l=s(7983),h=s(701),c=s(4293),u=s(8447),m=s(1061);const d=rxjs.operators;class g extends n.Filter{get calculating(){return"initial"==this.loader.style.display}set calculating(t){this.loader.style.display=t?"initial":"none"}get filterSummary(){return this.bioFilter.substructure}get isFiltering(){return super.isFiltering&&""!==this.bioFilter.substructure}get isReadyToApplyFilter(){return!this.calculating&&null!=this.bitset}get _debounceTime(){if(null==this.column)return 1e3;const t=this.column.length;return t<500?0:t>1e4?1e3:Math.floor((t-500)/9500*1e3)}constructor(){super(),this.bioFilter=null,this.bitset=null,this.loader=i.loader(),this.notation=void 0,this.root=i.divV([]),this.calculating=!1}attach(t){super.attach(t),this.column=t.columns.bySemType(n.SEMTYPE.MACROMOLECULE),this.columnName??(this.columnName=this.column?.name),this.notation??(this.notation=this.column?.getTag(n.TAGS.UNITS)),this.bioFilter=this.notation===u.r2.FASTA?new f:this.notation===u.r2.SEPARATOR?new y(this.column.getTag("separator")):new b,this.root.appendChild(this.bioFilter.filterPanel),this.root.appendChild(this.loader),this.onBioFilterChangedSubs?.unsubscribe();let e=this.bioFilter.onChanged;e=e.pipe((0,d.debounceTime)(this._debounceTime)),this.onBioFilterChangedSubs=e.subscribe((async t=>await this._onInputChanged())),this.subs.push(o.events.onResetFilterRequest.subscribe((t=>{this.bioFilter?.resetFilter()})))}detach(){super.detach()}applyFilter(){this.bitset&&!this.isDetached&&this.dataFrame?.filter.and(this.bitset)}saveState(){const t=super.saveState();return t.bioSubstructure=this.bioFilter?.substructure,t}applyState(t){super.applyState(t),t.bioSubstructure&&(this.bioFilter.substructure=t.bioSubstructure);const e=this;t.bioSubstructure&&setTimeout((function(){e._onInputChanged()}),1e3)}async _onInputChanged(){if(this.isFiltering){if(a()(this.dataFrame.rows.filters).has(`${this.columnName}: ${this.filterSummary}`))return;this.calculating=!0;try{this.bitset=await(this.bioFilter?.substructureSearch(this.column)),this.calculating=!1,this.dataFrame?.rows.requestFilter()}finally{this.calculating=!1}}else this.bitset=null,this.dataFrame?.rows.requestFilter()}}class p{constructor(){this.onChanged=new h.Subject}get filterPanel(){return new HTMLElement}get substructure(){return""}set substructure(t){}async substructureSearch(t){return null}}class f extends p{constructor(){super(),this.substructureInput=i.stringInput("","",(()=>{this.onChanged.next()}),{placeholder:"Substructure"})}get filterPanel(){return this.substructureInput.root}get substructure(){return this.substructureInput.value}set substructure(t){this.substructureInput.value=t}async substructureSearch(t){return(0,l.pf)(this.substructure,t)}resetFilter(){this.substructureInput.value=""}}class y extends f{constructor(t){super(),this.colSeparator="",this.separatorInput=i.stringInput("","",(()=>{this.onChanged.next()}),{placeholder:"Separator"}),this.colSeparator=t,this.separatorInput.value=t}get filterPanel(){return i.divV([this.substructureInput.root,this.separatorInput.root])}get substructure(){return this.separatorInput.value&&this.separatorInput.value!==this.colSeparator?this.substructureInput.value.replaceAll(this.separatorInput.value,this.colSeparator):this.substructureInput.value}set substructure(t){this.substructureInput.value=t}async substructureSearch(t){return(0,l.pf)(this.substructure,t,this.colSeparator)}}class b extends p{constructor(){super(),this._filterPanel=i.div("",{style:{cursor:"pointer"}}),this.helmSubstructure="",this.init()}async init(){this.helmEditor=await o.functions.call("HELM:helmWebEditor"),await i.tools.waitForElementInDom(this._filterPanel),this.updateFilterPanel(),this._filterPanel.addEventListener("click",(t=>{const{editorDiv:e,webEditor:s}=this.helmEditor.createWebEditor(this.helmSubstructure);i.dialog({showHeader:!1,showFooter:!0}).add(e).onOK((()=>{const t=s.canvas.getHelm(!0).replace(/<\/span>/g,"").replace(/<span style='background:#bbf;'>/g,"");this.helmSubstructure=t,this.updateFilterPanel(this.substructure),setTimeout((()=>{this.onChanged.next()}),10)})).show({modal:!0,fullScreen:!0})})),i.onSizeChanged(this._filterPanel).subscribe((t=>{const e=this.helmEditor.webEditor.canvas.getHelm(!0).replace(/<\/span>/g,"").replace(/<span style='background:#bbf;'>/g,"");this.updateFilterPanel(e)}))}get filterPanel(){return this._filterPanel}get substructure(){return this.helmSubstructure}set substructure(t){this.helmEditor.editor.setHelm(t)}updateFilterPanel(t){const e=this._filterPanel.parentElement.clientWidth<100?100:this._filterPanel.parentElement.clientWidth,s=e/2;if(t)(0,c.Y)(this._filterPanel,this.helmEditor.host),this.helmEditor.editor.setHelm(t),this.helmEditor.resizeEditor(e,s);else{const t=i.divText("Click to edit","helm-substructure-filter");(0,c.Y)(this._filterPanel,t)}}async substructureSearch(t){i.setUpdateIndicator(this._filterPanel,!0),await(0,m.gw)(10);const e=await(0,l.QF)(this.substructure,t);return i.setUpdateIndicator(this._filterPanel,!1),e}resetFilter(){console.debug("Bio: HelmFilter.resetFilter()"),this.helmSubstructure="",this.updateFilterPanel(this.substructure)}}},3336:t=>{"use strict";t.exports=$},976:t=>{"use strict";t.exports=DG},4469:t=>{"use strict";t.exports=grok},701:t=>{"use strict";t.exports=rxjs},3870:t=>{"use strict";t.exports=ui},6414:t=>{"use strict";t.exports=wu}},e={};function s(i){var n=e[i];if(void 0!==n)return n.exports;var o=e[i]={id:i,exports:{}};return t[i].call(o.exports,o,o.exports,s),o.exports}s.m=t,s.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return s.d(e,{a:e}),e},s.d=(t,e)=>{for(var i in e)s.o(e,i)&&!s.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},s.u=t=>t+".js",s.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),s.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),s.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},(()=>{var t;s.g.importScripts&&(t=s.g.location+"");var e=s.g.document;if(!t&&e&&(e.currentScript&&(t=e.currentScript.src),!t)){var i=e.getElementsByTagName("script");if(i.length)for(var n=i.length-1;n>-1&&!t;)t=i[n--].src}if(!t)throw new Error("Automatic publicPath is not supported in this browser");t=t.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),s.p=t})(),s.b=document.baseURI||self.location.href,s.nc=void 0;var i=s(2904);bio=i})();
|
|
3
3
|
//# sourceMappingURL=package.js.map
|