@datagrok/bio 2.11.13 → 2.11.14

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.
Files changed (48) hide show
  1. package/dist/23.js +2 -0
  2. package/dist/23.js.map +1 -0
  3. package/dist/282.js +2 -0
  4. package/dist/282.js.map +1 -0
  5. package/dist/361.js +1 -1
  6. package/dist/361.js.map +1 -1
  7. package/dist/40.js +2 -0
  8. package/dist/40.js.map +1 -0
  9. package/dist/562.js +2 -0
  10. package/dist/562.js.map +1 -0
  11. package/dist/586.js +2 -0
  12. package/dist/586.js.map +1 -0
  13. package/dist/65.js +2 -0
  14. package/dist/65.js.map +1 -0
  15. package/dist/{931.js → 935.js} +3 -3
  16. package/dist/935.js.map +1 -0
  17. package/dist/package-test.js +1 -1
  18. package/dist/package-test.js.map +1 -1
  19. package/dist/package.js +1 -1
  20. package/dist/package.js.map +1 -1
  21. package/package.json +4 -4
  22. package/scripts/sequence_generator.py +24 -22
  23. package/src/demo/bio05-helm-msa-sequence-space.ts +53 -13
  24. package/src/demo/utils.ts +2 -1
  25. package/src/function-edtiors/split-to-monomers-editor.ts +2 -2
  26. package/src/package.ts +80 -177
  27. package/src/tests/pepsea-tests.ts +1 -1
  28. package/src/tests/sequence-space-utils.ts +6 -2
  29. package/src/tests/similarity-diversity-tests.ts +16 -4
  30. package/src/utils/cell-renderer.ts +1 -1
  31. package/src/utils/helm-to-molfile.ts +1 -1
  32. package/src/utils/monomer-lib.ts +1 -1
  33. package/src/utils/pepsea.ts +16 -1
  34. package/src/viewers/vd-regions-viewer.ts +42 -16
  35. package/src/viewers/web-logo-viewer.ts +40 -20
  36. package/dist/1.js +0 -2
  37. package/dist/1.js.map +0 -1
  38. package/dist/190.js +0 -2
  39. package/dist/190.js.map +0 -1
  40. package/dist/381.js +0 -2
  41. package/dist/381.js.map +0 -1
  42. package/dist/770.js +0 -2
  43. package/dist/770.js.map +0 -1
  44. package/dist/868.js +0 -2
  45. package/dist/868.js.map +0 -1
  46. package/dist/931.js.map +0 -1
  47. package/src/utils/err-info.ts +0 -28
  48. /package/dist/{931.js.LICENSE.txt → 935.js.LICENSE.txt} +0 -0
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:()=>i});var n=s(9976);class i extends n.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,i)),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,i)),this.grokGroups}static get RasMol(){return void 0===this.rasMol&&(this.rasMol=new i({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 i.aaSynonyms?i.aaSynonyms[t]:t;return super.get(e)}}i.aaSynonyms={MeNle:"L",MeA:"A",MeG:"G",MeF:"F"};class o{static getPalette(t="grok"){switch(t){case"grok":return i.GrokGroups;case"lesk":return i.Lesk;default:throw new Error(`ChemPalette: scheme \`${t}\` does not exist`)}}static getInnerOuter(t){let e=0,s="",n="";for(const i of t)"("==i?e++:")"==i?e--:e?s+=i:n+=i;return isNaN(parseInt(s))?[n,s]:[n,""]}static getColorAAPivot(t="",e="grok"){const s=this.getPalette(e);let[n,i]=this.getInnerOuter(t);if(n=n.length>6?`${n.slice(0,3)}...`:n,i=i.length>6?`${i.slice(0,3)}...`:i,1==t.length||"("==t[1]){const e=t[0]?.toUpperCase();return e in s?[s.get(e),e,i,1]:[this.undefinedColor,n,i,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,i,2]:[this.undefinedColor,n,i,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,i,3]:[this.undefinedColor,n,i,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,i,4]:[this.undefinedColor,n,i,4]}return[this.undefinedColor,n,i,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"}},6584:(t,e,s)=>{"use strict";s.d(e,{BX:()=>o,nW:()=>l,tW:()=>c,tb:()=>h});var n=s(4469);const i="Libraries",o="System:AppData/Bio/libraries/",r={explicit:["HELMCoreLibrary.json"],exclude:[]};let a=Promise.resolve();async function l(){let t;return a=a.then((async()=>{const e=await n.dapi.userDataStorage.getValue(i,"Settings",!0);t=e?JSON.parse(e):{exclude:[],explicit:[]},t.exclude=t.exclude instanceof Array?t.exclude:[],t.explicit=t.explicit instanceof Array?t.explicit:[],console.debug(`Bio: getUserLibSettings()\n${JSON.stringify(t,void 0,2)}`)})),await a,t}async function c(t){a=a.then((async()=>{console.debug(`Bio: setUserLibSettings()\n${JSON.stringify(t,void 0,2)}`),await n.dapi.userDataStorage.postValue(i,"Settings",JSON.stringify(t),!0)})),await a}async function h(){await c(r)}},7228:(t,e,s)=>{"use strict";s.d(e,{JN:()=>l,PF:()=>h,Qx:()=>c,Xk:()=>a});var n=s(976),i=s(4469),o=s(1047),r=(s(499),s(8457));function a(t){const e=[];for(let s=0;s<t.rowCount;s++){const n={};Object.keys(o.K4).forEach((e=>{if("symbol"===e){const i=t.get(o.K4[e],s);n[e]="."===i?t.get(o.At,s):i}else if("rgroups"===e){const i=t.get(o.K4[e],s).split("\n"),r=[];i.forEach((t=>{const e={},s=t.substring(t.lastIndexOf("]")+1),n=t.match(/\[R(\d+)\]/)[1];e.capGroupSmiles="H"===s?`[*:${n}][H]`:`O[*:${n}]`,e.alternateId="H"===s?`R${n}-H`:`R${n}-OH`,e.capGroupName="H"===s?"H":"OH",e.label=`R${n}`,r.push(e)})),n[e]=r}else o.K4[e]&&(n[e]=t.get(o.K4[e],s))})),e.push(n)}return e}async function l(){const t=n.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 c(t,e){t instanceof n.Column&&(t=(0,r.O)(t).columns.toList());const s=(await l()).getBioLib(),o=new Array(t.length),a=t[0].length,c=new Float32Array(a);for(let r=0;r<t.length;++r){const l=e[r],h=s.getMonomer("PEPTIDE",l)?.smiles??"",u=t[r],m=u.getRawData(),d=u.categories,p=d.indexOf("");if(o[r]={categories:d,data:m,emptyIndex:p},void 0===l)continue;const g=n.Column.fromStrings("smiles",d.map((t=>s.getMonomer("PEPTIDE",t)?.smiles??""))),f=(n.DataFrame.fromColumns([g]),(await i.chem.getSimilarities(g,h)).getRawData());for(let t=0;t<a;++t){const e=m[t];c[t]+=""!==l&&e!==p?f[e]:""===l&&e===p?1:0}}for(let s=0;s<c.length;++s){let i=c[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){i=n.FLOAT_NULL;break}}c[s]=i}return n.Column.fromFloat32Array("Similarity",c)}async function h(t){const e=(await l()).getBioLib(),s=[],o={},r=t.map((t=>e.getMonomer("PEPTIDE",t)?.smiles??"")),a=n.Column.fromStrings("smiles",r);for(let e=0;e<r.length;++e){o[t[e]]=e;const n=r[e],l=""===n?new Array(r.length).fill(0):(await i.chem.getSimilarities(a,n)).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 n=s(4469),i=s(976),o=s(6414),r=s.n(o),a=s(1821),l=s(499);const c={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 h=s(1047);function u(t){return Math.round(c.PRECISION_FACTOR*t)/c.PRECISION_FACTOR}async function m(t,e,o){if(0===i.Func.find({package:"Chem",name:"getRdKitModule"}).length)return{col:null,warnings:['Transformation to atomic level requires the package "Chem" installed.']};if(e.semType!==i.SEMTYPE.MACROMOLECULE)return{col:null,warnings:[`Only the ${i.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 p=l.Cn.getOrCreate(u).alphabet;let g;if("PT"===p||"UN"===p)g="PEPTIDE";else{if("RNA"!==p&&"DNA"!==p)return{col:null,warnings:[`Unexpected column's '${u.name}' alphabet '${p}'.`]};g="RNA"}const f=function(t){const e=t.length,s=new Array(e),n=l.Cn.getOrCreate(t).getSplitter();for(let i=0;i<e;++i){const e=t.get(i);s[i]=e?r()(n(e)).filter((t=>""!==t)).toArray():[]}return s}(u),y=await async function(t,e,s,i){const o=function(t,e,s){const n=new Map;for(const i of t.getMonomerSymbolsByType(e)){const o=t.getMonomer(e,i);if("RNA"===e&&("Branch"===o.monomerType||"DNA"===s&&o.symbol===c.DEOXYRIBOSE||"RNA"===s&&o.symbol===c.RIBOSE||o.symbol===c.PHOSPHATE)||"PEPTIDE"===e&&"Branch"!==o.monomerType){const t={};h.rx.forEach((e=>{t[e]=o[e]})),n.set(o.symbol,t)}}return n}(e,s,i),r=new Map,a=await n.functions.call("Chem:getRdKitModule"),l={value:null};if("RNA"===s){const t="RNA"===i?[c.RIBOSE,c.PHOSPHATE]:[c.DEOXYRIBOSE,c.PHOSPHATE];for(const e of t)d(r,e,o,a,s,l)}for(let e=0;e<t.length;++e){const n=t[e];for(const t of n)if(""!==t)try{d(r,t,o,a,s,l)}catch(e){const s=e instanceof Error?e.message:e.toString(),n=e instanceof Error?e.stack:void 0;throw console.error(`bio lib: getMonomersDictFromLib() sym='${t}', error:\n${s}\n${n}`),new Error(`Can't get monomer '${t}' from library: ${s}`)}}return r}(f,o,g,p),w=u.length,{molfileList:C,molfileWarningList:T}=await async function(t,e,n,i,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 c=[],h=[];const u=new Array(r);for(let s=0;s<r;s++){const c=Math.floor(s*l),h=s===r-1?o:Math.floor((s+1)*l);a[s].postMessage({monomerSequencesArray:t,monomersDict:e,alphabet:n,polymerType:i,start:c,end:h}),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=>{c=c.concat(...t.molfileList),h=h.concat(...t.molfileWarningList)})),setTimeout((()=>{a.forEach((t=>{t.terminate()}))}),0),{molfileList:c,molfileWarningList:h}}(f,y,p,g,w);if(T.length>.05*w)throw new Error("Too many errors getting molfiles.");const b=`molfile(${u.name})`,A=t.columns.getUnusedName(b),S=i.Column.fromStrings(A,C);return S.semType=i.SEMTYPE.MOLECULE,S.setTag(i.TAGS.UNITS,i.UNITS.Molecule.MOLBLOCK),{col:S,warnings:T}}function d(t,e,s,n,i,o){if(!t.has(e)){const r=function(t,e,s,n,i){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(c.V2K_A_LINE,0),n=s;for(;-1!==s;){n=t.indexOf("\n",s);const i=parseInt(t.substring(s,n).replace(/^A\s+/,""));s=t.indexOf("R",n),n=t.indexOf("\n",s);const o=parseInt(t.substring(s,n).replace(/^R/,""));e.set(i,o),s=t.indexOf(c.V2K_A_LINE,n)}for(s=t.indexOf(c.V2K_RGP_LINE,0),n=t.indexOf("\n",s);-1!==s;){s+=c.V2K_RGP_SHIFT,n=t.indexOf("\n",s);const i=t.substring(s,n).replaceAll(/\s+/g," ").split(" ").map((t=>parseInt(t))).slice(1);for(let t=0;t<i.length;t+=2){if(e.has(i[t])&&e.get(i[t])!==i[t+1])throw new Error(`r-group index ${i[t]} has already been added with a different value`);e.set(i[t],i[t+1])}s=t.indexOf(c.V2K_RGP_LINE,n)}return e}(o.molfile),l=function(t,e){const s=e.get_mol(t),n=s.get_v3Kmolblock();return s.delete(),n}(function(t){let e=t.indexOf(c.V2K_A_LINE,0);-1===e&&(e=t.indexOf(c.V2K_RGP_LINE));const s=t.indexOf(c.V3K_END,e);return t.substring(0,e)+t.substring(s)}(o.molfile),s),h=function(t){let e=(t=t.replaceAll("\r","")).indexOf(c.V3K_BEGIN_COUNTS_LINE)+c.V3K_COUNTS_SHIFT,s=t.indexOf(" ",e+1);const n=parseInt(t.substring(e,s));return e=s+1,s=t.indexOf(" ",e+1),{atomCount:n,bondCount:parseInt(t.substring(e,s))}}(l),m=function(t,e){const s=new Array(e),n=new Float32Array(e),i=new Float32Array(e),o=new Array(e);let r=t.indexOf(c.V3K_BEGIN_ATOM_BLOCK);r=t.indexOf("\n",r);let a=r;for(let l=0;l<e;l++){r=t.indexOf(c.V3K_BEGIN_DATA_LINE,r)+c.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));n[l]=e[0],i[l]=e[1],r=a,a=t.indexOf("\n",r)+1,o[l]=t.slice(r,a),r=a}return{atomTypes:s,x:n,y:i,kwargs:o}}(l,h.atomCount),d=function(t,e){const s=new Uint32Array(e),n=new Array(e),i=new Map,o=new Map;let r=t.indexOf(c.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(c.V3K_BEGIN_DATA_LINE,a)+c.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],n[l]=e.slice(1);const h=t.indexOf("\n",r);let u=t.slice(a,h),m=u.indexOf(c.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));i.set(l,e);const s=c.V3K_BOND_CONFIG+e.toString();u=u.replace(s,"")}u||o.set(l,u)}return{bondTypes:s,atomPairs:n,bondConfiguration:i,kwargs:o}}(l,h.bondCount),y={atoms:m,bonds:d,meta:p(m,d,r,a)};return"PEPTIDE"===n?function(t){const e=t.meta.terminalNodes[0]-1,s=t.meta.rNodes[0]-1,n=t.atoms.x,i=t.atoms.y;S(t,-n[e],-i[e]);const o=T(n[s],i[s]);b(t.atoms,-o),n[t.meta.rNodes[1]-1]<0&&function(t){A(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 n=s[t],i=s[(t+1)%2];e.has(n)?e.get(n)?.push(i):e.set(n,new Array(1).fill(i))}return e}(t);let s=0;const n=t.atoms.atomTypes.length;let i=0;for(;0===s;){const o=e.get(t.meta.terminalNodes[1])[i];if(t.atoms.atomTypes[o-1]===c.OXYGEN&&o!==t.meta.rNodes[1]&&(s=o),i++,i>n)throw new Error(`Search for double-bonded Oxygen in ${t} has exceeded the limit of ${n}`)}return s}(t);!function(t,e){t.atoms.y[t.meta.rNodes[1]-1]<0&&t.atoms.y[e-1]<0&&(function(t){A(t,!0)}(t),b(t.atoms,-function(t,e){return T(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 n=e-1,i=s-1,o=t.atoms.x,r=t.atoms.y,a=o[n],l=r[n];o[n]=o[i],r[n]=r[i],o[i]=a,r[i]=l}(t,e,t.meta.rNodes[1])}(t,r)}(y):t===c.RIBOSE||t===c.DEOXYRIBOSE?function(t,e){const s=t.atoms.x,n=t.atoms.y;let i=t.meta.terminalNodes[0]-1;const o=t.meta.rNodes[1]-1;S(t,-s[i],-n[i]);const r=T(s[o],n[o]);b(t.atoms,3*Math.PI/2-r),e.value=function(t){const e=t.atoms.x,s=t.atoms.y,n=t.meta.rNodes[2]-1,i=t.meta.terminalNodes[2]-1,o=e[n]-e[i],r=s[n]-s[i];return Math.atan(r/o)+Math.PI/2}(t),i=t.meta.terminalNodes[0]-1,S(t,-s[i],-n[i])}(y,i):t===c.PHOSPHATE?function(t){const e=t.meta.terminalNodes[0]-1,s=t.meta.rNodes[0]-1,n=t.atoms.x,i=t.atoms.y;S(t,-n[e],-i[e]);const o=T(n[s],i[s]);b(t.atoms,Math.PI/2-o)}(y):function(t,e){const s=t.atoms.x,n=t.atoms.y,i=t.meta.terminalNodes[0]-1,o=t.meta.rNodes[0]-1;S(t,-s[i],-n[i]);const r=T(s[o],n[o]),a=e.value;if(!a)throw new Error("The value of sugarBranchToOYAngle is null");b(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:n[t.meta.rNodes[0]-1]},{x:s[t.meta.terminalNodes[0]-1],y:n[t.meta.terminalNodes[0]-1]});if(1!=l)for(let t=0;t<s.length;++t)s[t]=u(s[t]/l),n[t]=u(n[t]/l)}(y,i),function(t,e,s){"PEPTIDE"===t?(f(e,t),w(e,e.meta.rNodes[1])):s===c.RIBOSE||s===c.DEOXYRIBOSE?(w(e,e.meta.rNodes[1]),e.meta.rNodes[1]=e.meta.terminalNodes[1],g(e.bonds,e.meta),f(e,t),w(e,e.meta.rNodes[1]),w(e,e.meta.rNodes[0]),w(e,e.meta.rNodes[2])):s===c.PHOSPHATE&&(e.meta.terminalNodes[0]=e.meta.rNodes[0],S(e,-e.atoms.x[e.meta.terminalNodes[0]-1],-e.atoms.y[e.meta.terminalNodes[0]-1]),f(e,t),w(e,e.meta.rNodes[1]))}(n,y,t),function(t){let e=0;for(;e<t.atoms.atomTypes.length;)t.atoms.atomTypes[e]===c.HYDROGEN&&(w(t,e+1),--e),++e}(y),y}return null}(e,s,n,i,o);if(!r)throw new Error(`Monomer with symbol '${e}' is absent the monomer library`);t.set(e,r)}}function p(t,e,s,n){const i={backboneShift:null,branchShift:null,terminalNodes:[],rNodes:[]};return function(t,e,s){for(const[n,i]of s)t.atomTypes[n-1]=e[i-1]}(t,s,n),function(t,e){e.rNodes=Array.from(t.keys());for(let s=0;s<e.rNodes.length;s++)for(const n of[1,2])if(t.get(e.rNodes[s])===n){const t=e.rNodes[n-1];e.rNodes[n-1]=e.rNodes[s],e.rNodes[s]=t}}(n,i),g(e,i),i}function g(t,e){const s=e.rNodes;e.terminalNodes=new Array(s.length).fill(0);const n=e.terminalNodes,i=t.atomPairs;let o=0,r=0;for(;o<i.length&&r<n.length;){for(let t=0;t<n.length;++t)for(let e=0;e<2;++e)i[o][e]===s[t]&&(n[t]=i[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 w(t,e){if(void 0!==e){const s=e-1,n=t.atoms,i=t.bonds,o=t.meta;n.atomTypes.splice(s,1),n.x=C(Float32Array,n.x,s,1),n.y=C(Float32Array,n.y,s,1),n.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<i.atomPairs.length;){const t=i.atomPairs[r][0],s=i.atomPairs[r][1];t===e||s===e?(i.atomPairs.splice(r,1),i.bondTypes=C(Uint32Array,i.bondTypes,r,1),i.bondConfiguration.has(r)&&i.bondConfiguration.delete(r),i.kwargs.has(r)&&i.kwargs.delete(r),--r):(i.atomPairs[r][0]=t>e?t-1:t,i.atomPairs[r][1]=s>e?s-1:s),++r}let a=Array.from(i.bondConfiguration.keys());a.forEach((t=>{if(i.bondConfiguration.has(t)&&t>s){const e=i.bondConfiguration.get(t);i.bondConfiguration.delete(t),i.bondConfiguration.set(t-1,e)}})),a=Array.from(i.kwargs.keys()),a.forEach((t=>{if(i.kwargs.has(t)&&t>s){const e=i.kwargs.get(t);i.kwargs.delete(t),i.kwargs.set(t-1,e)}}))}}function C(t,e,s,n){const i=new t(e.length-n);let o=0,r=0;for(;o<e.length;)o===s&&(o+=n),i[r]=e[o],++r,++o;return i}function T(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 n=e/t,i=Math.atan(n);s=t<0?Math.PI/2+i:-Math.PI/2+i}return s}function b(t,e){if(0!==e){const s=t.x,n=t.y,i=Math.cos(e),o=Math.sin(e);for(let t=0;t<s.length;++t){const e=s[t];s[t]=u(e*i-n[t]*o),n[t]=u(e*o+n[t]*i)}}}function A(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 n=1===e?3:1;s.set(t,n)}}function S(t,e,s){const n=t.atoms.x,i=t.atoms.y;for(let t=0;t<n.length;++t)n[t]=u(n[t]+e),void 0!==s&&(i[t]=u(i[t]+s))}},6137:(t,e,s)=>{"use strict";s.d(e,{J:()=>i,V:()=>o});var n=s(9976);class i extends n.B{static get Chromatogram(){return void 0===this.chromatogram&&(this.chromatogram=new i({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:()=>n});class n{static makePalette(t,e=!1,s=n){const i={};return t.forEach((t=>{const s=t[0],n=t[1];s.forEach(((t,s)=>{i[t]=this.colourPalette[n][e?0:s]}))})),new s(i)}constructor(t){this._palette=t}get(t){return this._palette[t]}}n.undefinedColor="rgb(100,100,100)",n.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:()=>c,kQ:()=>r});var n=s(976),i=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(i.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=n.Color.fromHtml(t),s=n.Color.g(e),i=n.Color.r(e),o=n.Color.b(e),r=Math.sqrt(Math.pow(0-i,2)+Math.pow(0-s,2)+Math.pow(0-o,2));return r>210?`rgb(${i/r*210},${s/r*210},${o/r*210})`:n.Color.toRgb(e)}(l.palette[e])}}l.palette=l.buildPalette();class c extends i.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:()=>c});var n=s(4469),i=s(976),o=s(6414),r=s.n(o),a=s(8447);const l={DNA:"RNA",RNA:"RNA",PT:"PEPTIDE",UN:"PEPTIDE"};class c{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=i.BitSet.create(this.col.length),this.grid&&(this.subs.push(e.dataFrame.onDataChanged.subscribe((()=>{this.props=this.propsProvider(),this._monomerLengthList=null,this._rowsProcessed=i.BitSet.create(this.col.length)}))),this.subs.push(n.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,n]of r().enumerate(s)){const s=this.props.monomerToShort(t,this.props.monomerLengthLimit),i=(this.props.unitsHandler.isSeparator()?this.separatorWidth:this.props.separatorWidth)+s.length*this.props.monomerCharWidth;e[n]=i}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),n=Math.min(Math.ceil((this.grid?.vertScroll.max??0)+10),this.col.length);for(let t=s;t<n;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,n]of r().enumerate(s)){const s=this.props.monomerToShort(t,this.props.monomerLengthLimit),i=this.props.separatorWidth+s.length*this.props.monomerCharWidth;e[n]=Math.max(e[n]??0,i)}this._updated=!0}return e}getPosition(t,e){const[s,n]=this.getCellMonomerLengths(t),i=this.col.get(t),o=r()(this._splitter(i)).toArray();if(0===o.length)return null;let a=100,l=null,c=o.length,h=!1,u=0;if(n[0]<=e&&e<n.slice(-1)[0])for(;!h;)if(u=Math.floor((c+(l??0))/2),e>=n[u]&&e<=n[u+1]?(l=u,h=!0):e<n[u]?c=u-1:e>n[u+1]&&(l=u+1),l==c&&(h=!0),--a<=0)throw new Error(`Get position for pointer x = ${e} searching has not converged on ${JSON.stringify(n)}. `);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:()=>c,At:()=>i,K4:()=>a,Wc:()=>o,Z2:()=>l,nJ:()=>r,pU:()=>h,rx:()=>n});const n=["symbol","molfile","rgroups","name"],i="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"},{capGroupSmiles:"[*:3][H]",alternateId:"R3-H",capGroupName:"H",label:"R3"}],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:""},c="p",h=new RegExp(`[rd]\\((\\w)\\)${c}?`,"g")},5226:(t,e,s)=>{"use strict";s.d(e,{i:()=>r});var n=s(976),i=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 n=this._fileContent.substring(e.index+1,t.lastIndex);this._descriptionsArray.push(n),0!==s&&this._sequencesArray.push(this.parseMacromolecule(s,e.index)),s=t.lastIndex+1}this._sequencesArray.push(this.parseMacromolecule(s,-1))}importFasta(){const t=n.Column.fromStrings("description",this.descriptionsArray),e=n.Column.fromStrings("sequence",this.sequencesArray);return e.semType=n.SEMTYPE.MACROMOLECULE,e.setTag(n.TAGS.UNITS,o.r2.FASTA),i.Cn.getOrCreate(e),[n.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:()=>n,se:()=>a});var n,i=s(6286);!function(t){t.FASTA="fasta",t.SEPARATOR="separator",t.HELM="helm"}(n||(n={}));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 i.L("PT",a.fasta.peptide,.5),new i.L("DNA",a.fasta.dna,.55),new i.L("RNA",a.fasta.rna,.55)]},8447:(t,e,s)=>{"use strict";s.d(e,{CI:()=>n.CI,GU:()=>i.GU,KX:()=>i.KX,Mj:()=>i.Mj,XS:()=>n.XS,dQ:()=>i.dQ,gM:()=>i.gM,gP:()=>i.gP,kB:()=>i.kB,py:()=>i.py,r2:()=>n.r2,up:()=>i.up});var n=s(1821),i=s(585)},6286:(t,e,s)=>{"use strict";s.d(e,{L:()=>n,d:()=>i});class n{constructor(t,e,s){this.name=t,this.alphabet=e,this.cutoff=s}}class i extends n{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:()=>y,FJ:()=>f,GU:()=>E,KX:()=>v,Mj:()=>A,dQ:()=>I,gM:()=>M,gP:()=>T,jY:()=>p,kB:()=>g,py:()=>L,up:()=>P,vU:()=>b,w4:()=>N});var n=s(976),i=s(6414),o=s.n(i),r=s(6286),a=s(1821),l=s(499),c=s(3659),h=s(850),u=s(2012),m=s(6137),d=s(7331);function p(t,e,s){return t.categories,function(t,e){const s={};let n=!0,i=null;for(const o of t)if(null==i?i=o.length:o.length!==i&&(n=!1),o.length>=e)for(const t of o)t in s||(s[t]=0),s[t]+=1;return{freq:s,sameLength:n}}(o()(t.getRawData()).map((e=>s(t.categories[e]))),e)}function g(t){return o()(t.toString().matchAll(a.BM)).map((t=>t[2]??t[1])).toArray()}function f(t){return t||[]}function y(t,e=undefined){return s=>s?s.replaceAll('"-"',"").replaceAll("'-'","").split(t,e):[]}const w=/(PEPTIDE1|DNA1|RNA1)\{([^}]+)}/g,C=/\[([^\[\]]+)]/g;function T(t){w.lastIndex=0;const e=w.exec(t.toString()),s=e?e[2]:null;return(s?s.split("."):[]).map((t=>{C.lastIndex=0;const e=C.exec(t);return e&&e.length>=2?e[1]:t}))}function b(t,e,s=undefined){if(t.toLowerCase().startsWith(a.r2.FASTA))return g;if(t.toLowerCase().startsWith(a.r2.SEPARATOR))return y(e,s);if(t.toLowerCase().startsWith(a.r2.HELM))return T;throw new Error(`Unexpected units ${t} .`)}function A(t){return l.Cn.getOrCreate(t).getSplitter()}const S=/([^\W_]+)/g;function E(t,e){if(t.length<=e)return t;const s=t.match(S),n=t.length>e||(s?.length??0)>1,i=s?.[0]??" ";return n?i.substring(0,e-1)+"…":i}function M(t){switch(t){case"DNA":return a.se.fasta.dna;case"RNA":return a.se.fasta.rna;case"PT":return a.se.fasta.peptide;default:throw new Error(`Unsupported alphabet '${t}'.`)}}function v(t,e,s="-"){const n=new Set([...new Set(Object.keys(t)),...e]);n.delete(s);const i=[],o=[];for(const s of n)i.push(s in t?t[s]:0),o.push(e.has(s)?1:0);const r=new c.OW(i),a=new c.OW(o);return(0,h.MA)(r,a)/((0,h.$G)(r)*(0,h.$G)(a))}function N(t,e,s="-"){const n=e.map((e=>{const n=v(t,e.alphabet,s);return new r.d(e,t,n)}));let i;const o=Math.max(...n.map((t=>t.similarity>t.cutoff?t.similarity:-1)));return i=o>0?n.find((t=>t.similarity===o)).name:"UN",i}function I(t,e=5){let s;return s=t.semType==n.SEMTYPE.MACROMOLECULE?l.Cn.getOrCreate(t).alphabet:N(p(t,e,g).freq,a.XS),L(s)}function L(t){switch(t){case"PT":return u.f.GrokGroups;case"DNA":case"RNA":return m.J.Chromatogram;default:return d.UE.Color}}function P(t){const e=t.columns.bySemTypeAll(n.SEMTYPE.MACROMOLECULE);let s=e.find((t=>{const e=t.getTag(n.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 n=s(976),i=s(6414),o=s.n(i),r=s(585);function a(t){const e=(0,r.Mj)(t),s=t=>{const e=l.columns.addNewString((t+1).toString());return i.push(e),e},i=[],a=t.length,l=n.DataFrame.create(a);for(let n=0;n<a;++n){const r=t.get(n);if(null==r)continue;const a=e(r);for(const[t,e]of o().enumerate(a))((i[e]??null)||s(e)).set(n,t||"-",!1)}return l}},499:(t,e,s)=>{"use strict";s.d(e,{Cn:()=>d,_9:()=>m});var n=s(976),i=s(6414),o=s.n(i),r=s(8447),a=s(585),l=s(489),c=s(7228),h=s(1047);const u=new class{constructor(){this.uh=`units-handler.${n.SEMTYPE.MACROMOLECULE}`}},m={[r.r2.FASTA]:"-",[r.r2.SEPARATOR]:"",[r.r2.HELM]:"*"};class d{static setUnitsToFastaColumn(t){if(t.column.semType!==n.SEMTYPE.MACROMOLECULE||t.column.getTag(n.TAGS.UNITS)!==r.r2.FASTA)throw new Error(`The column of notation '${r.r2.FASTA}' must be '${n.SEMTYPE.MACROMOLECULE}'.`);t.column.setTag(n.TAGS.UNITS,r.r2.FASTA),d.setTags(t)}static setUnitsToSeparatorColumn(t,e){if(t.column.semType!==n.SEMTYPE.MACROMOLECULE||t.column.getTag(n.TAGS.UNITS)!==r.r2.SEPARATOR)throw new Error(`The column of notation '${r.r2.SEPARATOR}' must be '${n.SEMTYPE.MACROMOLECULE}'.`);if(!e)throw new Error(`The column of notation '${r.r2.SEPARATOR}' must have the separator tag.`);t.column.setTag(n.TAGS.UNITS,r.r2.SEPARATOR),t.column.setTag("separator",e),d.setTags(t)}static setUnitsToHelmColumn(t){if(t.column.semType!==n.SEMTYPE.MACROMOLECULE)throw new Error(`The column of notation '${r.r2.HELM}' must be '${n.SEMTYPE.MACROMOLECULE}'`);t.column.setTag(n.TAGS.UNITS,r.r2.HELM),d.setTags(t)}static setTags(t){const e=t.column.getTag(n.TAGS.UNITS),s=t.stats;if(Object.keys(s.freq).some((t=>t.length>1)),[r.r2.FASTA,r.r2.SEPARATOR].includes(e)){if(!t.column.getTag("alphabet")&&0===Object.keys(s.freq).length)throw new Error("Alphabet is empty and not annotated.");let e=t.column.getTag("aligned");null===e&&(e=s.sameLength?"SEQ.MSA":"SEQ",t.column.setTag("aligned",e));let n=t.column.getTag("alphabet");if(null===n&&(n=(0,a.w4)(s.freq,r.XS),t.column.setTag("alphabet",n)),"UN"===n){const e=Object.keys(s.freq).length,n=Object.keys(s.freq).some((t=>t.length>1));t.column.setTag(".alphabetSize",e.toString()),t.column.setTag(".alphabetIsMultichar",n?"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(),n=this._column.categories;for(let i=0;i<e;i++){const e=n[s[i]];this._splitted[i]=t(e)}}return this._splitted}get stats(){if(null===this._stats){const t={};let e=!0,s=null;for(const n of this.splitted){null==s?s=n.length:n.length!==s&&(e=!1);for(const e of n)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=0===this.splitted.length?0: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,i=s.length,o=t.toLowerCase()+"("+s.name+")",a=s.dataFrame.columns.getUnusedName(o),l=n.Column.fromList("string",a,new Array(i).fill(""));if(l.semType=n.SEMTYPE.MACROMOLECULE,l.setTag(n.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(n.TAGS.CELL_RENDERER,"Macromolecule");const c=s.getTag("aligned");c&&l.setTag("aligned",c);const h=s.getTag("alphabet");null!=h&&l.setTag("alphabet",h);let u=s.getTag(".alphabetSize");null!=h&&u&&l.setTag(".alphabetSize",u);const m=s.getTag(".alphabetIsMultichar");return null!=h&&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 i=n.Column.fromList("string",e,new Array(t).fill(""));return i.semType=n.SEMTYPE.MACROMOLECULE,i.setTag(n.TAGS.UNITS,s),i}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,c.JN)()).getBioLib().getMonomerSymbolsByType("PEPTIDE".toString()),e=new Set(t),s=(0,a.Ar)(this.separator);for(const t of this.column.categories){const n=s(t);for(const t of n)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,n){n||(n=this.toFasta(e)?m[r.r2.FASTA]:m[r.r2.SEPARATOR]),s||(s=this.toFasta(e)?"":this.separator);const i=t.startsWith("RNA"),o=this.splitter(t),a=[];for(let t=0;t<o.length;t++){let s=o[t];if(i&&(s=s.replace(h.pU,"")),s===m[r.r2.HELM])a.push(n);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),n=this.getNewColumn(t,e);return n.init((t=>s(this.column.get(t)))),n}getRegion(t,e,s){const n=this.getNewColumn(this.notation,this.separator);n.name=s,Math.max(...this.splitted.map((t=>t.length)));const i=t??0,o=e??this.maxLength-1,a=this.getJoiner(),l=o-i+1;n.init((t=>{const e=this.splitted[t],s=new Array(l);for(let t=0;t<l;++t){const n=i+t;s[t]=n<e.length?e[n]:m[this.notation]}return a(s)}));const c=t=>{const e=t.split(",").map((t=>t.trim())),s=new Array(l);for(let t=0;t<l;++t){const n=i+t;s[t]=n<e.length?e[n]:"?"}return s.join(r.CI)},h=this.column.getTag(".positionNames");h&&n.setTag(".positionNames",c(h));const u=this.column.getTag(".positionLabels");return u&&n.setTag(".positionLabels",c(u)),n}getJoiner(){const t=this;if(this.notation===r.r2.FASTA)return function(e){return p(t,e)};if(this.notation===r.r2.SEPARATOR)return function(e){return g(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 p(t,s)}(s,t)};if(t===r.r2.HELM)return function(t){return function(t,e){const s=e.startsWith("DNA")||e.startsWith("RNA"),n=t.getSplitter()(e);return f(t,n,s)}(s,t)};if(t===r.r2.SEPARATOR)return function(t){return function(t,e,s){const n=t.isHelm()?y(t,e):t.getSplitter()(e);return g(t,n,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!==n.TYPE.STRING)throw new Error(`Unexpected column type '${t.type}', must be '${n.TYPE.STRING}'.`);this._column=t;const e=this._column.getTag(n.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(n.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){let e=t.temp[u.uh];return e||(e=t.temp[u.uh]=new d(t)),e}}function p(t,e){const s=new Array(e.length);for(const[n,i]of o().enumerate(e)){let o=n;t.isHelm()&&(o=n.replace(h.pU,"$1")),t.isGap(o)?o=m[r.r2.FASTA]:o.length>1&&(o="["+e[i]+"]"),s[i]=o}return s.join("")}function g(t,e,s){const n=new Array(e.length);for(const[s,i]of o().enumerate(e)){let e=s;t.isGap(e)&&(e=m[r.r2.SEPARATOR]),n[i]=e}return n.map((t=>t??"")).join(s)}function f(t,e,s){const[n,i,a,l]=t.getHelmWrappers();return`${n}${o()(e).map((e=>{let n=e;return n=t.isGap(n)?m[r.r2.HELM]:s?n.replace(h.pU,"$1"):1==e.length?`${i}${e}${a}`:`${i}[${e}]${a}`,n})).toArray().join(".")}${l}`}function y(t,e){const s=t.getSplitter()(e),n=new Array(s.length),i=e.startsWith("DNA"),r=e.startsWith("RNA");for(const[t,e]of o().enumerate(s)){let s=t;(i||r)&&(s=s.replace(h.pU,"$1"),s=s===h.$3?null:s),n[e]=s}return n.filter((t=>null!==t))}},9298:(t,e,s)=>{"use strict";s.d(e,{Ct:()=>l,DX:()=>n,ES:()=>i,dE:()=>a,iD:()=>r,vS:()=>h,vw:()=>o});var n,i,o,r,a,l,c=s(976);!function(t){t.tooltipWebLogo=".tooltipWebLogo"}(n||(n={})),function(t){t.Entropy="Entropy",t.full="100%"}(i||(i={})),function(t){t.TOP="top",t.MIDDLE="middle",t.BOTTOM="bottom"}(o||(o={})),function(t){t.LEFT="left",t.CENTER="center",t.RIGHT="right"}(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.valueAggrType=c.AGG.TOTAL_COUNT,this.valueColumnName="Activity",this.startPositionName=null,this.endPositionName=null,this.skipEmptySequences=!0,this.skipEmptyPositions=!1,this.shrinkEmptyTail=!0,this.backgroundColor=4294967295,this.positionHeight=i.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}}},922:(t,e,s)=>{"use strict";s.d(e,{_:()=>l});class n{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 n=this.isWhitespace(s)?e:e-1;for(let t=0;t<n;t++)s=this.getNextColumnIdx(s);return s}parseAtomTypes(){const t=this.atomCount,e=new Array(t);let s=this.getAtomBlockIdx();for(let n=0;n<t;n++)s=this.shiftIdxToAtomType(s),e[n]=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 n=this.getAtomBlockIdx();for(let i=0;i<this.atomCount;i++){n=this.shiftIdxToXColumn(n);for(const o of[t,e,s])o[i]=this.parseFloatValue(n),n=this.getNextColumnIdx(n);n=this.getNextLineIdx(n)}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 n=new Uint16Array(2);n[0]=this.parseIntValue(e),e=this.getNextColumnIdx(e),n[1]=this.parseIntValue(e),t[s]=n,e=this.getNextLineIdx(e)}return t}parseBondTypes(){const t=this.bondCount,e=new Uint16Array(t);let s=this.getBondBlockIdx();for(let n=0;n<t;n++)s=this.shiftIdxToBondType(s),e[n]=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 i extends n{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 n=0;n<e;n++){if(s=this.shiftIdxToAtomType(s),t(this.fileContent.charCodeAt(s),s))return!0;s=this.getNextLineIdx(s)}return!1}}var o;!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"}(o||(o={}));class r extends i{constructor(t){super(t)}static validate(t){return-1!==t.indexOf(o.HEADER)&&-1!==t.indexOf(o.END)}shiftIdxToAtomType(t){return this.shiftIdxToSpecifiedColumn(t,o.ATOM_TYPE_COL)}getCountsLineIdx(){let t=0;for(let e=0;e<o.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,o.FIRST_BONDED_ATOM_COL)}shiftIdxToBondType(t){return this.shiftIdxToSpecifiedColumn(t,o.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+o.NUM_OF_COUNTS_DIGITS;const s=parseInt(this.fileContent.substring(t,e));return t=e,e+=o.NUM_OF_COUNTS_DIGITS,{atomCount:s,bondCount:parseInt(this.fileContent.substring(t,e))}}}class a extends i{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 l{constructor(){}static getInstance(t){if(r.validate(t))return new r(t);if(a.validate(t))return new a(t);throw new Error("Malformed molfile")}}},2669:(t,e,s)=>{"use strict";s.d(e,{m:()=>n});class n{constructor(t=!0,e=!0){const n=navigator.hardwareConcurrency;this._workerCount=t?Math.max(n-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,n){return new Promise((async(i,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,c=new Float32Array(a);let h=0,u=1,m=0,d=Number.MIN_VALUE;for(let s=0;s<this._workerCount;s++){const i=Math.floor(s*l),p=s===this._workerCount-1?a:Math.floor((s+1)*l),g=h,f=u;s!==this._workerCount-1&&(h=o-2-Math.floor(Math.sqrt(-8*p+4*o*(o-1)-7)/2-.5),u=p-o*h+Math.floor((h+1)*(h+2)/2)),this._workers[s].postMessage({values:t,fnName:e,startRow:g,startCol:f,chunckSize:p-i,opts:n}),r[s]=new Promise(((t,e)=>{this._workers[s].onmessage=({data:{error:n,distanceMatrixData:o,min:r,max:a}})=>{this._terminateOnComplete&&this._workers[s].terminate(),n?e(n):(c.set(o,i),r<m&&(m=r),a>d&&(d=a),t())}}))}await Promise.all(r),s&&c.forEach(((t,e)=>{c[e]=(t-m)/(d-m)})),i(c)}catch(t){o(t)}}))}terminate(){this._workers.forEach((t=>t.terminate()))}}},3914:(t,e,s)=>{"use strict";s.d(e,{H:()=>i});var n=s(6814);class i{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 i(void 0,s);for(let i=0;i<s;i++)for(let r=i+1;r<s;r++)o.set(i,r,(0,n.k)(t[i])||(0,n.k)(t[r])?1:e(t[i],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 n=0;n<this._data.length;n++)this._data[n]=0===s?this._data[n]-t:(this._data[n]-t)/(e-t)}}},6254:(t,e,s)=>{"use strict";function n(t,e){const s=i(e);function n(t,e){const n=Number(t),i=Number(e);return s(n,i)}const o={get:(t,s,i)=>"length"===s?e:new Proxy(t,function(t){return{get:(e,s,i)=>t===s?0:e[Number(t)>Number(s)?n(s,t):n(t,s)]}}(s))};return new Proxy(t,o)}function i(t){return(e,s)=>t*e+s-Math.floor((e+2)*(e+1)/2)}s.d(e,{_:()=>n,y:()=>i})},2590:(t,e,s)=>{"use strict";s.d(e,{_:()=>r});var n=s(5697),i=s(6361),o=s(6814);class r{constructor(){this._workerCount=Math.max(navigator.hardwareConcurrency-2,1)}async calc(t,e,n,i={}){const o=t.length*(t.length-1)/2,r=Math.floor(o/this._workerCount),a=t.length>2e4?await this.getMinimalThreshold(t,e,i):0;n<a&&(console.log(`using threshold ${a}`),n=a),i.threshold=n;const l=new Array(this._workerCount),c=new Array(this._workerCount).fill(null).map((()=>new Worker(new URL(s.p+s.u(381),s.b))));for(let s=0;s<this._workerCount;s++)l[s]=new Promise(((a,l)=>{const h=s*r,u=s===this._workerCount-1?o:(s+1)*r;u<=h&&a({i:new Int32Array(0),j:new Int32Array(0),distance:new Float32Array(0),idx:s}),c[s].postMessage({values:t,startIdx:h,endIdx:u,threshold:n,fnName:e,opts:i}),c[s].onmessage=({data:{error:t,i:e,j:n,distance:i}})=>{t?(c[s].terminate(),l(t)):(c[s].terminate(),a({i:e,j:n,distance:i,idx:s}))}}));const h=await Promise.all(l),u=h.reduce(((t,e)=>t+e.i.length),0),m=new Int32Array(u),d=new Int32Array(u),p=new Float32Array(u);let g=0;for(const t of h)m.set(t.i,g),d.set(t.j,g),p.set(t.distance,g),g+=t.i.length;return{i:m,j:d,distance:p}}async getMinimalThreshold(t,e,n={}){const i=new Array(this._workerCount).fill(null).map((()=>new Worker(new URL(s.p+s.u(770),s.b)))),o=t.slice();for(let t=o.length-1;t>0;t--){const e=Math.floor(Math.random()*(t+1));[o[t],o[e]]=[o[e],o[t]]}try{const s=t.length*(t.length-1)/2,r=Math.floor(s/this._workerCount),a=Math.floor(Math.min(s/1e3,1e6)/this._workerCount),l=new Array(this._workerCount);for(let t=0;t<this._workerCount;t++)l[t]=new Promise(((l,c)=>{const h=t*r,u=t===this._workerCount-1?s:(t+1)*r;i[t].postMessage({values:o,startIdx:h,endIdx:u,sampleLength:a,fnName:e,opts:n}),i[t].onmessage=({data:{error:e,distance:s}})=>{i[t].terminate(),e?c(e):l({distance:s})}}));const c=await Promise.all(l),h=c.reduce(((t,e)=>t+e.distance.length),0),u=new Float32Array(h);let m=0;for(const t of c)u.set(t.distance,m),m+=t.distance.length;return u.sort(),1-u[Math.floor(7e7/s*u.length)]}catch(t){return i?.forEach((t=>t?.terminate())),console.error(t),.5}}static calcSync(t,e,s,r){const a=[],l=[],c=[];let h=0,u=0,m=0;const d=t.length*(t.length-1)/2;for(;h<d;){const d=(0,o.k)(t[u])||(0,o.k)(t[m])?1:s(t[u],t[m]);(Object.values(i.gk).some((t=>t===e))?(0,n.Om)(d):1-d)>=r&&(a.push(u),l.push(m),c.push(d)),h++,m++,m===t.length&&(u++,m=u+1)}return{i:new Int32Array(a),j:new Int32Array(l),distance:new Float32Array(c)}}}},6814:(t,e,s)=>{"use strict";s.d(e,{k:()=>n});const n=t=>null==t},5697:(t,e,s)=>{"use strict";s.d(e,{Dz:()=>T,FV:()=>u,KR:()=>h,MI:()=>A,NB:()=>f,Om:()=>S,Rt:()=>a,UX:()=>g,WI:()=>p,Zd:()=>d,_h:()=>m,aW:()=>w,bX:()=>M,bc:()=>l,eo:()=>E,fX:()=>b,kg:()=>r,s:()=>y,yU:()=>C});var n=s(9657),i=s(1040),o=s(489);i.gk.Tanimoto,i.gk.Dice,i.gk.Asymmetric,i.gk.BraunBlanquet,i.gk.Cosine,i.gk.Kulczynski,i.gk.McConnaughey,i.gk.RogotGoldberg,i.gk.Russel,i.gk.Sokal,i.gk.Hamming,i.gk.Euclidean,i.gk.Tanimoto,i.gk.Dice,i.gk.Asymmetric,i.gk.BraunBlanquet,i.gk.Cosine,i.gk.Kulczynski,i.gk.McConnaughey,i.gk.RogotGoldberg,i.gk.Russel,i.gk.Sokal,i.gk.Hamming,i.gk.Euclidean;const r=[i.gk.Tanimoto,i.gk.Dice,i.gk.Cosine],a=[i.gk.Tanimoto,i.gk.Asymmetric,i.gk.Cosine,i.gk.Sokal],l=[o.U.HAMMING,o.U.LEVENSHTEIN,o.U.MONOMER_CHEMICAL_DISTANCE,o.U.NEEDLEMANN_WUNSCH];function c(t,e){const s=t.trueCount()+e.trueCount();if(0==s)return 1;const n=t.andWithCountBits(e,!0);return n/(s-n)}function h(t,e){return E(c(t,e))}function u(t,e){return E(c(new n.Z(t,32*t.length),new n.Z(e,32*e.length)))}function m(t,e){return E(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 E(function(t,e){const s=t.trueCount()*e.trueCount();return 0==s?0:t.andWithCountBits(e,!0)/Math.sqrt(s)}(t,e))}function p(t,e){return Math.sqrt(t.trueCount()+e.trueCount()-2*t.andWithCountBits(e,!0))}function g(t,e){return t.trueCount()+e.trueCount()-2*t.andWithCountBits(e,!0)}function f(t,e){return E(function(t,e){const s=t.trueCount()+e.trueCount(),n=t.andWithCountBits(e,!0);return n/(2*s-3*n)}(t,e))}function y(t,e){return E(function(t,e){const s=t.trueCount()+e.trueCount(),n=t.trueCount()*e.trueCount();return 0==n?0:t.andWithCountBits(e,!0)*s/(2*n)}(t,e))}function w(t,e){return E(function(t,e){const s=t.trueCount()+e.trueCount(),n=t.trueCount()*e.trueCount();return 0==n?0:(t.andWithCountBits(e,!0)*s-n)/n}(t,e))}function C(t,e){return E(function(t,e){const s=Math.min(t.trueCount(),e.trueCount());return 0==s?0:t.andWithCountBits(e,!0)/s}(t,e))}function T(t,e){return E(function(t,e){const s=Math.max(t.trueCount(),e.trueCount());return 0==s?0:t.andWithCountBits(e,!0)/s}(t,e))}function b(t,e){return E(function(t,e){return 0==t.length?0:t.andWithCountBits(e,!0)/t.length}(t,e))}function A(t,e){return E(function(t,e){const s=t.andWithCountBits(e,!0),n=t.countBits(!0)+e.countBits(!0),i=t.length,o=i-n+s;return s==i||o==i?1:s/n+o/(2*i-n)}(t,e))}function S(t){return 1/(1+t)}function E(t){return 0===t?3402823e32:1/t-1}function M(t,e){return Math.abs(t-e)}},779:(t,e,s)=>{"use strict";function n(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,n=Math.min(...Object.keys(e).map((t=>t.charCodeAt(0))))+1,i=new Float32Array((s.length+n)*(s.length+n));return Object.entries(e).forEach((([t,n])=>{const o=s[n];Object.entries(e).forEach((([e,n])=>{i[t.charCodeAt(0)*s.length+e.charCodeAt(0)]=o[n]}))})),(t,e)=>i[t.charCodeAt(0)*s.length+e.charCodeAt(0)]}(),s=t?.threshold??0;return(t,n)=>{let i=0;const o=t.length,r=n.length,a=Math.max(o,r)*(1-s);o!==r&&(i=Math.abs(o-r));let l=0;for(let s=0;s<Math.min(o,r);s++)if(t[s]!==n[s]&&(l+=e(t[s],n[s]),l>a))return 1;return l+=i,l/=Math.max(o,r),l}}s.d(e,{j:()=>n})},489:(t,e,s)=>{"use strict";s.d(e,{U:()=>n.U,o:()=>n.o});var n=s(5540)},458:(t,e,s)=>{"use strict";s.d(e,{r:()=>i});var n=s(1811);function i(){return(t,e)=>(0,n.T)(t,e)/Math.max(t.length,e.length)}},5540:(t,e,s)=>{"use strict";s.d(e,{U:()=>n,o:()=>a});var n,i=s(779),o=s(458),r=s(6683);!function(t){t.HAMMING="Hamming",t.LEVENSHTE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],[-1,-1,-2,-3,-1,0,-2,-3,-2,1,2,-1,5,0,-2,-1,-1,-1,-1,1,-3,-1,-1,-4],[-2,-3,-3,-3,-2,-3,-3,-3,-1,0,0,-3,0,6,-4,-2,-2,1,3,-1,-3,-3,-1,-4],[-1,-2,-2,-1,-3,-1,-1,-2,-2,-3,-3,-1,-2,-4,7,-1,-1,-4,-3,-2,-2,-1,-2,-4],[1,-1,1,0,-1,0,0,0,-1,-2,-2,0,-1,-2,-1,4,1,-3,-2,-2,0,0,0,-4],[0,-1,0,-1,-1,-1,-1,-2,-2,-1,-1,-1,-1,-2,-1,1,5,-2,-2,0,-1,-1,0,-4],[-3,-3,-4,-4,-2,-2,-3,-2,-2,-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 i(t){const e=new Uint16Array(65536),{gapOpen:s,gapExtend:i,scoringMatrix:o,alphabetIndexes:r}={...n,...t};Object.entries(r).forEach((([t,s])=>e[t.charCodeAt(0)]=s));const a=[new Float32Array(1e4),new Float32Array(1e4)];return(t,n)=>{const r=new Array(t.length+1).fill(!1),l=new Array(t.length+1).fill(!1);let c=0,h=1;for(let e=1;e<t.length+1;e++)a[0][e]=-s-(e-1)*i,a[1][e]=0;for(let u=1;u<n.length+1;u++){a[h][0]=-s-(u-1)*i;for(let m=1;m<t.length+1;m++){const d=a[c][m-1]+o[e[t.charCodeAt(m-1)]][e[n.charCodeAt(u-1)]],p=a[c][m]-(r[m]?i:s),g=a[h][m-1]-(l[m-1]?i:s);a[h][m]=Math.max(d,g,p),a[h][m]===d?(r[m]=!1,l[m]=!1):a[h][m]===g?(r[m]=!1,l[m]=!0):(r[m]=!0,l[m]=!1)}c=h,h=(h+1)%2}const u=Math.max(t.length,n.length);return(u-a[c][t.length])/u}}},116:(t,e,s)=>{"use strict";var n;s.d(e,{AL:()=>n,aP:()=>o,bD:()=>i}),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"}(n||(n={}));class i{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:()=>c});var n=s(850),i=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??n.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,n.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,i.I)(e);let a=(0,i.I)(e);for(;r==a;)a=(0,i.I)(e);const l=s[r],c=s[a],h=this.calcDistance(t,r,a),u=(0,n.dP)(l,c);if(0==this.cutoff||h<=this.cutoff||u<h){const t=o*(h-u)/(u+this.epsilon),e=(0,n.On)(l,c,-1);s[r]=(0,n.On)(l,e,t),s[a]=(0,n.On)(c,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,n.kO)(e,l.dimension,40);let o=this.lambda;await this.initDistance(t);for(let r=0;r<this.cycles;++r){const r=(0,i.I)(e),a=s[r];for(let i=0;i<e;++i){if(r==i)continue;const e=s[i],l=this.calcDistance(t,r,i),c=(0,n.dP)(a,e);if(0==this.cutoff||l<=this.cutoff||c<l){const t=o*(l-c)/(c+this.epsilon),r=(0,n.On)(a,e,-1);s[i]=(0,n.On)(e,r,-t)}}if(o-=this.dlambda,o<=0)break}return s}}class c 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,n.kO)(e,c.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,i.I)(e);let n=(0,i.I)(e);for(;s==n;)n=(0,i.I)(e);const o=this.calcDistance(t,s,n);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,i.I)(e);let l=(0,i.I)(e);for(;a==l;)l=(0,i.I)(e);const c=s[a],h=s[l],u=this.calcDistance(t,a,l),m=(0,n.dP)(c,h);if(u<=r||m<u){const t=.5*o*(u-m)/(m+this.epsilon),e=(0,n.On)(c,h,-1);s[a]=(0,n.On)(c,e,t),s[l]=(0,n.On)(h,e,-t)}}if(o-=(this.lambda-this.dlambda)/(this.cycles-1),o<this.dlambda)break}return s}}},1040:(t,e,s)=>{"use strict";var n,i,o,r,a,l;s.d(e,{CF:()=>i,Qe:()=>a,W:()=>n,Yc:()=>l,gd:()=>r,gk:()=>o}),function(t){t.Levenshtein="Levenshtein",t.JaroWinkler="Jaro-Winkler",t.Manhattan="Manhattan"}(n||(n={})),function(t){t.Euclidean="Euclidean"}(i||(i={})),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:()=>n.W,gk:()=>n.gk});var n=s(1040);s(7861)},7861:(t,e,s)=>{"use strict";s.d(e,{sQ:()=>f});var n=s(1811),i=s(3979),o=s(5697),r=s(850),a=s(489),l=s(1040);const c={[l.CF.Euclidean]:r.dP},h={[l.W.Levenshtein]:n.T,[l.W.JaroWinkler]:i.H$,[l.W.Manhattan]:function(t,e){if(t.length!==e.length)return 1;{let s=0;for(let n=1;n<t.length;n++)s+=t[n]==e[n]?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},p={[l.Qe.Vector]:{[l.CF.Euclidean]:c[l.CF.Euclidean]},[l.Qe.String]:{[l.W.Levenshtein]:h[l.W.Levenshtein],[l.W.JaroWinkler]:h[l.W.JaroWinkler],[l.W.Manhattan]:h[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]}},g=Object.keys(p).reduce(((t,e)=>{for(const s of Object.keys(p[e]))t[s]=e;return t}),{});function f(t){return"BitArray"==g[t]}},6490:(t,e,s)=>{"use strict";s.d(e,{M6:()=>o,SB:()=>l,Sr:()=>a,VA:()=>i,XV:()=>r,oi:()=>c,w5:()=>u});var n=s(9533);function i(t,e){const s=s=>n.cS(t).map((()=>n.VI(e,s))),i=[];return i.push(s(-1)),i.push(s(1/0)),i.push(s(0)),i}function o(t,e,s){const i=n.ll(t);for(let o=0;o<t;o++){let t=!0,r=0;for(;t;){r=n.AH(e,s);let a=!1;for(let t=0;t<o;t++)if(r===i[t]){a=!0;break}a||(t=!1)}i[o]=r}return i}function r(t,e,s,n,i){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(n===o[t])return 0;return a(t,e,s,n,i)}function a(t,e,s,n,i){const o=t[0][e],r=t[1][e],a=t[2][e];if(s>=r[0])return 0;r[0]=s,o[0]=n,a[0]=i;let l=0,c=0;for(;;){const e=2*l+1,n=e+1,i=t[0][0].length;if(e>=i)break;if(n>=i){if(!(r[e]>s))break;c=e}else if(r[e]>=r[n]){if(!(s<r[e]))break;c=e}else{if(!(s<r[n]))break;c=n}r[l]=r[c],o[l]=o[c],a[l]=a[c],l=c}return r[l]=s,o[l]=n,a[l]=i,1}function l(t,e,s,o,a){const l=i(e,o);for(let i=0;i<e;i++)for(let e=0;e<s;e++){if(t[0][i][e]<0)continue;const s=t[0][i][e],o=t[2][i][e],c=n.mH(a);r(l,i,c,s,o),r(l,s,c,i,o),t[2][i][e]=0}return l}function c(t){const e=t[0],s=t[1];for(let t=0;t<e.length;t++){const n=e[t],i=s[t];for(let t=0;t<n.length-1;t++){const e=n.length-t-1,s=i.length-t-1,o=n[0];n[0]=n[e],n[e]=o;const r=i[0];i[0]=i[s],i[s]=r,h(i,n,s,0)}}return{indices:e,weights:s}}function h(t,e,s,n){for(;2*n+1<s;){const i=2*n+1,o=i+1;let r=n;if(t[r]<t[i]&&(r=i),o<s&&t[r]<t[o]&&(r=o),r===n)break;{const s=t[n];t[n]=t[r],t[r]=s;const i=e[n];e[n]=e[r],e[r]=i,n=r}}}function u(t,e){const s=t[0][e],n=t[1][e],i=t[2][e];let o=1/0,r=-1;for(let t=0;t>s.length;t++)1===i[t]&&n[t]<o&&(o=n[t],r=t);return r>=0?(i[r]=0,Math.floor(s[r])):-1}},1729:(t,e,s)=>{"use strict";s.d(e,{u:()=>n.uB});var n=s(3585)},952:(t,e,s)=>{"use strict";function n(t,e,s,n,i){function o(t,e,s,n){if(s>t[t.length-1])return;let i=t.length-2;for(i=t.length-2;i>=0&&!(s>t[i]);i--);t.splice(t.length-1,1),t.splice(i+1,0,s),e.splice(e.length-1,1),e.splice(i+1,0,n)}console.time("knnGraph");const r=new Array(i).fill(null).map((()=>new Array(n).fill(1))),a=new Array(i).fill(null).map((()=>new Array(n).fill(1)));for(let n=0;n<t.length;n++)o(a[t[n]],r[t[n]],s[n],e[n]),o(a[e[n]],r[e[n]],s[n],t[n]);return console.timeEnd("knnGraph"),{knnIndexes:r,knnDistances:a}}function i(t,e,s){function n(t,e,s,n){if(s>t[t.length-1])return;let i=t.length-2;for(i=t.length-2;i>=0&&!(s>t[i]);i--);t.splice(t.length-1,1),t.splice(i+1,0,s),e.splice(e.length-1,1),e.splice(i+1,0,n)}console.time("knnGraph");const i=new Array(s).fill(null).map((()=>new Array(e).fill(1))),o=new Array(s).fill(null).map((()=>new Array(e).fill(1)));let r=0,a=1;for(let e=0;e<t.length;e++)n(o[r],i[r],t[e],a),n(o[a],i[a],t[e],r),a++,a>=s&&(r++,a=r+1);return console.timeEnd("knnGraph"),{knnIndexes:i,knnDistances:o}}s.d(e,{J:()=>n,N:()=>i})},6802:(t,e,s)=>{"use strict";s.d(e,{$X:()=>l,A7:()=>i,Fv:()=>m,Hp:()=>g,IH:()=>a,NT:()=>r,RH:()=>u,cf:()=>h,gW:()=>c,p4:()=>o});var n=s(9533);class i{constructor(t,e,s,n){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=n[0],this.nCols=n[1];for(let n=0;n<s.length;n++){const i=t[n],o=e[n];this.checkDims(i,o);const r=this.makeKey(i,o);this.entries.set(r,{value:s[n],row:i,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 n=this.makeKey(t,e);this.entries.has(n)?this.entries.get(n).value=s:this.entries.set(n,{value:s,row:t,col:e})}get(t,e,s=0){const n=this.makeKey(t,e);return this.entries.has(n)?this.entries.get(n).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((n=>{e[s++]=t(n.value,n.row,n.col)}));const n=[this.nRows,this.nCols];return new i(this.getRows(),this.getCols(),e,n)}toArray(){const t=n.cS(this.nRows).map((()=>n.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(),n=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(n);const c=[t.nCols,t.nRows];return new i(a,r,l,c)}function r(t,e){return p(t,e,((t,e)=>t*e))}function a(t,e){return p(t,e,((t,e)=>t+e))}function l(t,e){return p(t,e,((t,e)=>t-e))}function c(t,e){return p(t,e,((t,e)=>t>e?t:e))}function h(t,e){return t.map((t=>t*e))}function u(t){const e=new Set,s=t.getValues(),n=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=n.filter(r),c=o.filter(r);return new i(l,c,a,t.getDims())}function m(t,e="l2"){const s=d[e],n=new Map;t.forEach(((t,e,s)=>{const i=n.get(e)||[];i.push(s),n.set(e,i)}));const o=new i([],[],[],t.getDims());for(let e of n.keys()){const i=n.get(e).sort(),r=s(i.map((s=>t.get(e,s))));for(let t=0;t<r.length;t++)o.set(e,i[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 p(t,e,s){const n=new Set,o=[],r=[],a=[],l=(n,i)=>{o.push(n),r.push(i);const l=s(t.get(n,i),e.get(n,i));a.push(l)},c=t.getValues(),h=t.getRows(),u=t.getCols();for(let t=0;t<c.length;t++){const e=h[t],s=u[t],i=`${e}:${s}`;n.add(i),l(e,s)}const m=e.getValues(),d=e.getRows(),p=e.getCols();for(let t=0;t<m.length;t++){const e=d[t],s=p[t],i=`${e}:${s}`;n.has(i)||l(e,s)}const g=[t.nRows,t.nCols];return new i(o,r,a,g)}function g(t){const e=[];t.forEach(((t,s,n)=>{e.push({value:t,row:s,col:n})})),e.sort(((t,e)=>t.row===e.row?t.col-e.col:t.row-e.row));const s=[],n=[],i=[];let o=-1;for(let t=0;t<e.length;t++){const{row:r,col:a,value:l}=e[t];r!==o&&(o=r,i.push(t)),s.push(a),n.push(l)}return{indices:s,values:n,indptr:i}}},1595:(t,e,s)=>{"use strict";s.d(e,{WX:()=>a,gK:()=>h,n_:()=>c,vF:()=>l});var n=s(6490),i=s(6802),o=s(4972),r=s(9533);function a(t,e){return function(s,i,o,a=10,l=50,c=.001,h=.5,u=!0){const m=s.length,d=n.VA(s.length,o);for(let i=0;i<s.length;i++){const r=n.M6(o,s.length,e);for(let e=0;e<r.length;e++){const o=t(s[i],s[r[e]]);n.XV(d,i,o,r[e],1),n.XV(d,r[e],o,i,1)}}if(u)for(let e=0;e<i.length;e++)for(let o=0;o<i[e].length&&!(i[e][o]<0);o++)for(let r=o+1;r<i[e].length&&!(i[e][r]<0);r++){const a=t(s[i[e][o]],s[i[e][r]]);n.XV(d,i[e][o],a,i[e][r],1),n.XV(d,i[e][r],a,i[e][o],1)}for(let i=0;i<a;i++){const i=n.SB(d,m,o,l,e);let a=0;for(let o=0;o<m;o++)for(let c=0;c<l;c++){let u=Math.floor(i[0][o][c]);if(!(u<0||r.mH(e)<h))for(let e=0;e<l;e++){const r=Math.floor(i[0][o][e]),l=i[2][o][c],h=i[2][o][e];if(r<0||!l&&!h)continue;const m=t(s[u],s[r]);a+=n.XV(d,u,m,r,1),a+=n.XV(d,r,m,u,1)}}if(a<=c*o*s.length)break}return n.oi(d)}}function l(t){return{initFromRandom:function(e,s,i,o,a){for(let l=0;l<i.length;l++){const c=r.M6(e,s.length,a);for(let e=0;e<c.length;e++){if(c[e]<0)continue;const r=t(s[c[e]],i[l]);n.XV(o,l,r,c[e],1)}}},initFromTree:function(e,s,i,r,a){for(let l=0;l<i.length;l++){const c=o.ii(i[l],e,a);for(let e=0;e<c.length;e++){if(c[e]<0)return;const o=t(s[c[e]],i[l]);n.XV(r,l,o,c[e],1)}}}}}function c(t){return function(e,s,o,r){const{indices:a,indptr:l}=i.Hp(s);for(let s=0;s<r.length;s++){const i=new Set(o[0][s]);for(;;){const c=n.w5(o,s);if(-1===c)break;const h=a.slice(l[c],l[c+1]);for(const a of h){if(a===c||-1===a||i.has(a))continue;const l=t(e[a],r[s]);n.Sr(o,s,l,a,1),i.add(a)}}}return o}}function h(t,e,s,i,o,r,a){const l=n.VA(s.length,i);if(o(i,e,s,l,a),t)for(let n of t)r(n,e,s,l,a);return l}},4972:(t,e,s)=>{"use strict";s.d(e,{HO:()=>h,Zv:()=>o,ii:()=>m});var n=s(9533);class i{constructor(t,e,s,n){this.hyperplanes=t,this.offsets=e,this.children=s,this.indices=n}}function o(t,e,s,o){const h=Math.max(10,e),u=n.w6(s).map(((e,s)=>function(t,e=30,s,i){return r(t,n.w6(t.length),e,s,i)}(t,h,s,o))),m=u.map((t=>function(t,e){const s=l(t),o=c(t),r=n.w6(s).map((()=>t.hyperplane?1:0)),h=n.ll(s),u=n.w6(s).map((()=>[-1,-1])),m=n.w6(o).map((()=>n.w6(e).map((()=>-1))));return a(t,r,h,u,m,0,0),new i(r,h,u,m)}(t,h)));return m}function r(t,e,s=30,i,o){if(e.length>s){const a=function(t,e,s){let i=n.AH(e.length,s),o=n.AH(e.length,s);o+=i===o?1:0,o%=e.length;const r=e[i],a=e[o];let l=0,c=0;c=t[r]-t[a],l-=c*(t[r]+t[a])/2;let h=0,u=0;const m=n.ll(e.length);for(let i=0;i<e.length;i++){let o=l;o+=c*t[e[i]],0===o?(m[i]=n.AH(2,s),0===m[i]?h+=1:u+=1):o>0?(m[i]=0,h+=1):(m[i]=1,u+=1)}const d=n.ll(h),p=n.ll(u);h=0,u=0;for(let t=0;t<m.length;t++)0===m[t]?(d[h]=e[t],h+=1):(p[u]=e[t],u+=1);return{indicesLeft:d,indicesRight:p,hyperplane:c,offset:l}}(t,e,o),{indicesLeft:l,indicesRight:c,hyperplane:h,offset:u}=a;return{leftChild:r(t,l,s,i+1,o),rightChild:r(t,c,s,i+1,o),isLeaf:!1,hyperplane:h,offset:u}}return{indices:e,isLeaf:!0}}function a(t,e,s,n,i,o,r){if(t.isLeaf)return n[o][0]=-r,i[r].splice(0,t.indices.length,...t.indices),{nodeNum:o,leafNum:r+=1};{e[o]=t.hyperplane,s[o]=t.offset,n[o][0]=o+1;const l=o;let c=a(t.leftChild,e,s,n,i,o+1,r);return o=c.nodeNum,r=c.leafNum,n[l][1]=o+1,c=a(t.rightChild,e,s,n,i,o+1,r),{nodeNum:c.nodeNum,leafNum:c.leafNum}}}function l(t){return t.isLeaf?1:1+l(t.leftChild)+l(t.rightChild)}function c(t){return t.isLeaf?1:c(t.leftChild)+c(t.rightChild)}function h(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,i){let o=e;return o+=t*s,0===o?n.AH(2,i):o>0?0:1}function m(t,e,s){let n=0;for(;e.children[n][0]>0;)n=0===u(e.hyperplanes[n],e.offsets[n],t,s)?e.children[n][0]:e.children[n][1];const i=-1*e.children[n][0];return e.indices[i]}},3585:(t,e,s)=>{"use strict";s.d(e,{uB:()=>u});var n=s(6490),i=s(6802),o=s(1595),r=s(4972),a=s(9533),l=s(3107);const c=1e-5,h=.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:n}=this.initializeSimplicialSetEmbedding();return this.optimizationState.head=e,this.optimizationState.tail=s,this.optimizationState.epochsPerSample=n,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,n=[t.length,t.length],o=new i.A7([],[],[],n);for(let t=0;t<e.length;t++){const n=e[t],i=s[t];for(let e=0;e<n.length;e++){const s=n[e],r=i[e];r>0&&o.set(t,s,r)}}const r=i.p4(o);return i.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:c,weights:h}=n.oi(l);c=c.map((t=>t.slice(0,this.nNeighbors))),h=h.map((t=>t.slice(0,this.nNeighbors)));const u=Math.max(0,this.localConnectivity-1),{sigmas:m,rhos:d}=this.smoothKNNDistance(h,this.nNeighbors,u),{rows:p,cols:g,vals:f}=this.computeMembershipStrengths(c,h,m,d),y=[t.length,e.length];let w=new i.A7(p,g,f,y);const C=i.Fv(w,"l1"),T=i.Hp(C),b=t.length,A=function(t,e,s){const n=a.ll(t.length).map((t=>a.ll(s[0].length)));for(let i=0;i<t.length;i++)for(let o=0;o<t[0].length;o++)for(let r=0;r<s[0].length;r++){const a=t[i][o];n[i][r]+=e[i][o]*s[a][r]}return n}(a.HU(T.indices,b,this.nNeighbors),a.HU(T.values,b,this.nNeighbors),this.embedding),S=this.nEpochs?this.nEpochs/3:w.nRows<=1e4?100:30,E=w.getValues().reduce(((t,e)=>e>t?e:t),0);w=w.map((t=>t<E/S?0:t)),w=i.RH(w);const M=this.makeEpochsPerSample(w.getValues(),S),v=w.getRows(),N=w.getCols();return this.assignOptimizationStateParameters({headEmbedding:A,tailEmbedding:this.embedding,head:v,tail:N,currentEpoch:0,nEpochs:S,nVertices:w.getDims()[1],epochsPerSample:M}),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,n=o.WX(e,this.random),i=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,i,this.random);const c=r.HO(this.rpForest),{indices:h,weights:u}=n(t,c,s,l);return{knnIndices:h,knnDistances:u}}fuzzySimplicialSet(t,e,s=1){const{knnIndices:n=[],knnDistances:o=[],localConnectivity:r}=this,{sigmas:a,rhos:l}=this.smoothKNNDistance(o,e,r),{rows:c,cols:h,vals:u}=this.computeMembershipStrengths(n,o,a,l),m=[t.length,t.length],d=new i.A7(c,h,u,m),p=i.p4(d),g=i.NT(d,p),f=i.$X(i.IH(d,p),g),y=i.cf(f,s),w=i.cf(g,1-s);return i.IH(y,w)}categoricalSimplicialSetIntersection(t,e,s,n=1){let o=function(t,e,s=1,n=5){return t.map(((t,i,o)=>-1===e[i]||-1===e[o]?t*Math.exp(-s):e[i]!==e[o]?t*Math.exp(-n):t))}(t,e,n,s);return o=i.RH(o),function(t){t=i.Fv(t,"max");const e=i.p4(t),s=i.NT(e,t);return t=i.IH(t,i.$X(e,s)),i.RH(t)}(o)}smoothKNNDistance(t,e,s=1,n=64,i=1){const o=Math.log(e)/Math.log(2)*i,r=a.ll(t.length),l=a.ll(t.length);for(let e=0;e<t.length;e++){let i=0,u=1/0,m=1;const d=t[e],p=d.filter((t=>t>0));if(p.length>=s){let t=Math.floor(s),n=s-t;t>0?(r[e]=p[t-1],n>c&&(r[e]+=n*(p[t]-p[t-1]))):r[e]=n*p[0]}else p.length>0&&(r[e]=a.Fp(p));for(let s=0;s<n;s++){let s=0;for(let n=1;n<t[e].length;n++){const i=t[e][n]-r[e];s+=i>0?Math.exp(-i/m):1}if(Math.abs(s-o)<c)break;s>o?(u=m,m=(i+u)/2):(i=m,u===1/0?m*=2:m=(i+u)/2)}if(l[e]=m,r[e]>0){const t=a.J6(d);l[e]<h*t&&(l[e]=h*t)}else{const s=a.J6(t.map(a.J6));l[e]<h*s&&(l[e]=h*s)}}return{sigmas:l,rhos:r}}computeMembershipStrengths(t,e,s,n){const i=t.length,o=t[0].length,r=a.ll(i*o),l=a.ll(i*o),c=a.ll(i*o);for(let a=0;a<i;a++)for(let i=0;i<o;i++){let h=0;-1!==t[a][i]&&(h=t[a][i]===a?0:e[a][i]-n[a]<=0?1:Math.exp(-(e[a][i]-n[a])/s[a]),r[a*o+i]=a,l[a*o+i]=t[a][i],c[a*o+i]=h)}return{rows:r,cols:l,vals:c}}initializeSimplicialSetEmbedding(){const t=this.getNEpochs(),{nComponents:e}=this,s=this.graph.getValues();let n=0;for(let t=0;t<s.length;t++){const e=s[t];n<s[t]&&(n=e)}const i=this.graph.map((e=>e<n/t?0:e));this.embedding=a.ll(i.nRows).map((()=>a.ll(e).map((()=>20*a.mH(this.random)-10))));const o=[],r=[],l=[],c=i.getAll();for(let t=0;t<c.length;t++){const e=c[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),n=a.Fp(t),i=t.map((t=>t/n*e));return i.forEach(((t,n)=>{t>0&&(s[n]=e/i[n])})),s}assignOptimizationStateParameters(t){Object.assign(this.optimizationState,t)}prepareForOptimizationLoop(){const{repulsionStrength:t,learningRate:e,negativeSampleRate:s}=this,{epochsPerSample:n,headEmbedding:i,tailEmbedding:o}=this.optimizationState,r=i[0].length,a=i.length===o.length,l=n.map((t=>t/s)),c=[...l],h=[...n];this.assignOptimizationStateParameters({epochOfNextSample:h,epochOfNextNegativeSample:c,epochsPerNegativeSample:l,moveOther:a,initialAlpha:e,alpha:e,gamma:t,dim:r})}initializeOptimization(){const t=this.embedding,e=this.embedding,{head:s,tail:n,epochsPerSample:i}=this.optimizationState,o=this.getNEpochs(),r=this.graph.nCols,{a:c,b:h}=function(t,e){const s=a.GE(0,3*t,300).map((t=>t<e?1:t)),n=a.ll(s.length).map(((n,i)=>s[i]>=e?Math.exp(-(s[i]-e)/t):n)),i={x:s,y:n},{parameterValues:o}=(0,l.Z)(i,(([t,e])=>s=>1/(1+t*s**(2*e))),{damping:1.5,initialValues:[.5,.5],gradientDifference:.1,maxIterations:100,errorTolerance:.01}),[r,c]=o;return{a:r,b:c}}(this.spread,this.minDist);this.assignOptimizationStateParameters({headEmbedding:t,tailEmbedding:e,head:s,tail:n,epochsPerSample:i,a:c,b:h,nEpochs:o,nVertices:r})}optimizeLayoutStep(t){const{optimizationState:e}=this,{head:s,tail:n,headEmbedding:i,tailEmbedding:o,epochsPerSample:r,epochOfNextSample:l,epochOfNextNegativeSample:c,epochsPerNegativeSample:h,moveOther:u,initialAlpha:m,alpha:d,gamma:f,a:y,b:w,dim:C,nEpochs:T,nVertices:b}=e;for(let e=0;e<r.length;e++){if(l[e]>t)continue;const m=s[e],T=n[e],A=i[m],S=o[T],E=g(A,S);let M=0;E>0&&(M=-2*y*w*Math.pow(E,w-1),M/=y*Math.pow(E,w)+1);for(let t=0;t<C;t++){const e=p(M*(A[t]-S[t]),4);A[t]+=e*d,u&&(S[t]+=-e*d)}l[e]+=r[e];const v=Math.floor((t-c[e])/h[e]);for(let t=0;t<v;t++){const t=a.AH(b,this.random),e=o[t],s=g(A,e);let n=0;if(s>0)n=2*f*w,n/=(.001+s)*(y*Math.pow(s,w)+1);else if(m===t)continue;for(let t=0;t<C;t++){let s=4;n>0&&(s=p(n*(A[t]-e[t]),4)),A[t]+=s*d}}c[e]+=v*h[e]}return e.alpha=m*(1-t/T),e.currentEpoch+=1,i}optimizeLayoutAsync(t=(()=>!0)){return new Promise(((e,s)=>{const n=async()=>{try{const{nEpochs:s,currentEpoch:i}=this.optimizationState;this.embedding=this.optimizeLayoutStep(i);const o=this.optimizationState.currentEpoch,r=!1===t(o),a=o===s;if(r||a)return e(a);setTimeout((()=>n()),0)}catch(t){s(t)}};setTimeout((()=>n()),0)}))}optimizeLayout(t=(()=>!0)){let e=!1,s=[];for(;!e;){const{nEpochs:n,currentEpoch:i}=this.optimizationState;s=this.optimizeLayoutStep(i);const o=this.optimizationState.currentEpoch,r=!1===t(o);e=o===n||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 p(t,e){return t>e?e:t<-e?-e:t}function g(t,e){let s=0;for(let n=0;n<t.length;n++)s+=Math.pow(t[n]-e[n],2);return s}},9533:(t,e,s)=>{"use strict";function n(t,e){return Math.floor(e()*t)}function i(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 c(t,e,s){return o(s).map(((n,i)=>t+i*((e-t)/(s-1))))}function h(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 i=l(t);for(let o=0;o<t;o++){let t=!0;for(;t;){const r=n(e,s);let a=!1;for(let t=0;t<o;t++)if(r===i[t]){a=!0;break}a||(t=!1),i[o]=r}}return i}function d(t,e,s){const n=[];let i=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 n=0;n<s;n++)e.push(t[o]),o+=1;n.push(e),i+=1}return n}s.d(e,{AH:()=>n,Fp:()=>u,GE:()=>c,HU:()=>d,J6:()=>h,M6:()=>m,VI:()=>a,cS:()=>o,ll:()=>l,mH:()=>i,w6:()=>r})},9657:(t,e,s)=>{"use strict";s.d(e,{Z:()=>n});class n{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,i=n._createBuffer(s);if(e)for(let t=0;t<i.length;t++)i[t]=-1;this._data=i,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,n){if(t<e||t>s)throw new Error(`Argument ${n} (${t}) out of range (${e}, ${s})`)}copy(t,e,s){for(let n=0;n<s;n++)e[n]=t[n]}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 n(t._length);s._length=t._length,s._data=n._createBuffer(s._length),s._version=0;const i=t.lengthInInts;for(let n=0;n<i;n++)s._data[n]=t._data[n]&e._data[n];return s}static _createBuffer(t){return new Uint32Array(Math.floor((t+31)/32))}static fromValues(t){const e=new n(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 n(t);for(let n=0;n<t;++n)s.setBit(n,e(n));return s._version=0,s}static fromString(t){return n.fromSeq(t.length,(e=>"1"==t.charAt(e)))}static fromUint32Array(t,e){const s=new n(t);return s._data=e,s}static fromBytes(t){const e=t.length,s=new n(8*e);s._data=new Uint32Array(Math.floor((e+3)/4)),s._length=8*e;let i=0,o=0;for(;e-o>=4;)s._data[i++]=255&t[o]|(255&t[o+1])<<8|(255&t[o+2])<<16|(255&t[o+3])<<24,o+=4;return e-o==3&&(s._data[i]=(255&t[o+2])<<16),e-o==2&&(s._data[i]|=(255&t[o+1])<<8),e-o==1&&(s._data[i]|=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 n(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,n=this.lengthInInts;for(let t=0;t<n;t++)this._data[t]=s;this.incrementVersion(e)}setIndexes(t,e=!0,s=!0,n=!0){s&&this.setAll(!e,!1);for(const s of t)this.setFast(s,e);this.incrementVersion(n)}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,n=!0,i=!0){if(s&&i&&this.setAll(!e,!1),i)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(n)}getRange(t,e){this.assureInRange(t,0,this._length-1,"from"),this.assureInRange(e,0,this._length,"to");const s=[];for(let n=t;n<e;++n)s.push(this.getBit(n));return n.fromValues(s)}getRangeAsList(t,e){this.assureInRange(t,0,this._length-1,"from"),this.assureInRange(e,0,this._length,"to");const s=[];for(let n=t;n<e;++n)s.push(this.getBit(n));return s}setRange(t,e,s,n=!0){this.assureInRange(t,0,this._length-1,"from"),this.assureInRange(e,0,this._length-1,"to");const i=Math.min(t,e),o=Math.max(t,e);if(s)for(let t=i;t<=o;t++)this.setTrue(t);else for(let t=i;t<=o;t++)this.setFalse(t);return this.incrementVersion(n),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 n=this._length;this.setLength(this._length+e);for(let s=n-1;s>=t;s--)this.setBit(s+e,this.getBit(s));for(let n=t;n<t+e;n++)this.setBit(n,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 n=-1;-1!=(n=t.findNext(n,!e));)this.setFast(s++,this.getBit(n));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+=n._onBitCount[255&t];let s=this._data[e];const i=31&this._length;for(0!=i&&(s&=~(4294967295<<i));0!=s;s>>>=8)this._selectedCount+=n._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 i=this.lengthInInts;let o=0;for(;o<i-1;o++)for(let e=this._data[o]&t._data[o];0!=e;e>>>=8)s+=n._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+=n._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 i=this.lengthInInts;for(let o=Math.floor(t/32);o<i;o++){let i=e?this._data[o]:~this._data[o];if(0!=s)i&=4294967295<<s&4294967295,s=0;else if(!e&&-4294967296==i)continue;for(let e=0;0!=i;e+=8,i>>>=8){const s=n._firstOnBit[255&i];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 i=Math.floor(t/32);i>=0;i--){let t=e?this._data[i]:~this._data[i];0!=s&&(t&=~(4294967295<<s),s=0);for(let e=24;0!=t;e-=8,t<<=8){const s=n._lastOnBit[t>>>24];if(s>=0)return s+32*i+e}}return-1}}n._onBitCount=Int8Array.from([0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4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,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,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 n(t){return Math.random()*t}function i(t){return Math.floor(n(t))}s.d(e,{I:()=>i,t:()=>n})},8518:(t,e,s)=>{"use strict";s.d(e,{L:()=>i});var n=s(4588);function i(t,e,s){function i(t,e){let s=null,n=null;for(const i of t){const t=e(i);(null==n||t>n)&&(s=i,n=t)}return s}const o=[(0,n.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=i(r.values(),(t=>Math.min.apply(Math,o.map((function(e,n){return s(t,e)})))));null!=t&&(o.push(t),r.delete(t))}return o}},1061:(t,e,s)=>{"use strict";s.d(e,{AB:()=>A,Bu:()=>u,W3:()=>f,Wh:()=>p,X5:()=>w,bb:()=>y,f6:()=>g,gw:()=>C,jh:()=>d,l_:()=>m,ow:()=>T,zg:()=>h});var n=s(4469),i=s(976),o=function(t,e,s,n){return new(s||(s=Promise))((function(i,o){function r(t){try{l(n.next(t))}catch(t){o(t)}}function a(t){try{l(n.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof s?e:new s((function(t){t(e)}))).then(r,a)}l((n=n.apply(t,e||[])).next())}))};const r={};let a;var l;!function(t){t.notNull=function(t,e){if(null==t)throw new Error(`${null==e?"Value":e} not defined`)}}(l||(l={}));class c{constructor(t,e,s,n){var i;this.category=t,this.name=e,null!=n||(n={}),null!==(i=n.timeout)&&void 0!==i||(n.timeout=3e4),this.options=n,this.test=()=>o(this,void 0,void 0,(function*(){return new Promise(((t,e)=>o(this,void 0,void 0,(function*(){let n="";try{n=yield s()}catch(t){e(t)}t(n)}))))}))}}function h(t,e,s,n=0){return o(this,void 0,void 0,(function*(){let i;return new Promise(((o,r)=>{i=t.subscribe((t=>{try{e(t)}catch(t){r(t)}i.unsubscribe(),o("OK")})),setTimeout((()=>{i.unsubscribe(),r("timeout")}),n),s()}))}))}function u(t,e,s){null==r[a]&&(r[a]={}),null==r[a].tests&&(r[a].tests=[]),r[a].tests.push(new c(a,t,e,s))}function m(t,e=!0,s){if(s=s?`${s}, `:"",t!==e)throw new Error(`${s}Expected "${e}", got "${t}"`)}function d(t,e,s=.001,n){if(t===Number.POSITIVE_INFINITY&&e===Number.POSITIVE_INFINITY||t===Number.NEGATIVE_INFINITY&&e===Number.NEGATIVE_INFINITY||t===Number.NaN&&e===Number.NaN||isNaN(t)&&isNaN(e))return;const i=Math.abs(t-e)<s;if(m(i,!0,`${null!=n?n:""} (tolerance = ${s})`),!i)throw new Error(`Expected ${e}, got ${t} (tolerance = ${s})`)}function p(t,e){for(const[s,n]of Object.entries(e)){if(!t.hasOwnProperty(s))throw new Error(`Expected property "${s}" not found`);const e=t[s];if(e instanceof Array&&n instanceof Array)g(e,n);else if(e instanceof Object&&n instanceof Object)p(e,n);else if(Number.isFinite(e)&&Number.isFinite(n))d(e,n);else if(e!=n)throw new Error(`Expected (${n}) for key '${s}', got (${e})`)}}function g(t,e){const s=t.length,n=e.length;if(s!=n)throw new Error(`Arrays are of different length: actual array length is ${s} and expected array length is ${n}`);for(let n=0;n<s;n++)if(t[n]instanceof Array&&e[n]instanceof Array)g(t[n],e[n]);else if(t[n]instanceof Object&&e[n]instanceof Object)p(t[n],e[n]);else if(t[n]!=e[n])throw new Error(`Expected ${e[n]} at position ${n}, got ${t[n]}`)}function f(t,e,s){var n;a=t,e(),r[a]&&(r[a].clear=null===(n=null==s?void 0:s.clear)||void 0===n||n,r[a].timeout=null==s?void 0:s.timeout)}function y(t){null==r[a]&&(r[a]={}),r[a].before=t}function w(t){null==r[a]&&(r[a]={}),r[a].after=t}function C(t){return o(this,void 0,void 0,(function*(){yield new Promise((e=>setTimeout(e,t)))}))}function T(t,e="Timeout exceeded",s=500,n=50){return o(this,void 0,void 0,(function*(){return new Promise(((i,o)=>{setTimeout((()=>{clearInterval(r),o(new Error(e))}),s);const r=setInterval((()=>{t()&&(clearInterval(r),i())}),n)}))}))}const b=i.DataFrame.fromColumns([i.Column.fromStrings("col",["val1","val2","val3"])]);function A(t,e,s){var r;return o(this,void 0,void 0,(function*(){(null==s?void 0:s.detectSemanticTypes)&&(yield n.data.detectSemanticTypes(e));let o=n.shell.addTableView(e);const a=`[name=viewer-${t.replace(/\s+/g,"-")} i]`,l=`${a} canvas,${a} svg,${a} img,\n ${a} input,${a} h1,${a} a,${a} .d4-viewer-error`,c=[];try{let h=o.addViewer(t);yield T((()=>null!==document.querySelector(l)),"cannot load viewer",3e3);const u=null===(r=document.querySelector(l))||void 0===r?void 0:r.tagName;if(c.push(Array.from(o.viewers).length),!(null==s?void 0:s.readOnly)){Array.from(e.row(0).cells).forEach((t=>t.value=null));const t=e.rowCount<20?Math.floor(e.rowCount/2):10;e.rows.select((e=>e.idx>=0&&e.idx<t)),yield C(50);for(let s=t;s<2*t;s++)e.filter.set(s,!1);yield C(50),e.currentRowIdx=1;const s=e.clone();e.columns.names().slice(0,Math.ceil(e.columns.length/2)).forEach((t=>e.columns.remove(t))),yield C(100),o.dataFrame=s}const d=h.getOptions(!0).look,p=h.getProperties(),f={};Object.keys(d).filter((t=>"boolean"==typeof d[t])).forEach((t=>f[t]=!d[t])),p.filter((t=>null!==t.choices)).forEach((t=>f[t.name]=t.choices.find((e=>e!==d[t.name])))),h.setOptions(f),yield C(300);const y=o.saveLayout(),w=h.getOptions().look;o.resetLayout(),c.push(Array.from(o.viewers).length),o.loadLayout(y);const A=`${a} ${u}`;if(yield T((()=>null!==document.querySelector(A)),"cannot load viewer from layout",3e3),c.push(Array.from(o.viewers).length),h=Array.from(o.viewers).find((t=>"Grid"!==t.type)),g(c,[2,1,2]),m(JSON.stringify(h.getOptions().look),JSON.stringify(w)),!1!==(null==s?void 0:s.arbitraryDfTest)){n.shell.closeAll(),yield C(100),o=n.shell.addTableView(b);try{h=o.addViewer(t)}catch(t){return n.shell.closeAll(),void i.Balloon.closeAll()}yield T((()=>null!==document.querySelector(l)),"cannot load viewer on arbitrary dataset",3e3)}}finally{n.shell.closeAll(),i.Balloon.closeAll()}}))}},3659:(t,e,s)=>{"use strict";s.d(e,{OW:()=>n});class n extends Float32Array{}},850:(t,e,s)=>{"use strict";s.d(e,{$G:()=>a,Fv:()=>u,MA:()=>l,On:()=>r,dP:()=>h,hu:()=>o,kO:()=>c});var n=s(3659),i=s(4588);function o(t=!1,e="Assertion error."){if(!t)throw new Error(e)}function r(t,e,s=1){const i=t.length;o(i==e.length,"Vector lengths do not match.");const r=new n.OW(i);for(let n=0;n<t.length;++n)r[n]=t[n]+s*e[n];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 n=0;n<t.length;n++)s+=t[n]*e[n];return s}function c(t,e,s=1){const o=function(t,e,s=0){return new Array(t).fill(s).map((()=>new n.OW(e).fill(s)))}(t,e);for(let n=0;n<t;++n)for(let t=0;t<e;++t)o[n][t]=(0,i.t)(s);return o}function h(t,e){let s=0;const n=t.length;if(n!==e.length)throw new Error("The dimensionality of the vectors must match");for(let i=0;i<n;++i)s+=Math.pow(t[i]-e[i],2);return Math.sqrt(s)}function u(t){const e=t.length;let s=0,n=0;for(let i=0;i<e;++i)s+=t[i],n+=Math.pow(t[i],2);const i=s/e,o=1/Math.sqrt(n/e-Math.pow(i,2));for(let s=0;s<e;++s)t[s]=(t[s]-i)*o;return t}},7659:(t,e,s)=>{"use strict";e.Z=void 0;var n=s(6215);Object.defineProperty(e,"Z",{enumerable:!0,get:function(){return n.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 n=Math.sqrt(-2*Math.log(s)/s);return this.vValue=e*n,this.returnV=!0,t*n}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 n=void 0!==s,i=[];for(let o=0;o<t;o++){const t=[];for(let i=0;i<e;i++)n?t.push(s):t.push(this.randn(0,1e-4));i.push(t)}return i}L2(t,e){const s=t.length;let n=0;for(let i=0;i<s;i++){const s=t[i],o=e[i];n+=(s-o)*(s-o)}return n}xtod(t){const e=t.length,s=this.zeros(e*e);for(let n=0;n<e;n++)for(let i=n+1;i<e;i++){const o=this.L2(t[n],t[i]);s[n*e+i]=o,s[i*e+n]=o}return s}d2p(t,e,s){const n=Math.sqrt(t.length),i=Math.floor(n);this.assert(i===n,"D should have square number of elements.");const o=Math.log(e),r=this.zeros(i*i),a=this.zeros(i);for(let e=0;e<i;e++){let n=-1/0,l=1/0,c=1,h=!1;const u=50;let m=0;for(;!h;){let r=0;for(let s=0;s<i;s++){let n=Math.exp(-t[e*i+s]*c);e===s&&(n=0),a[s]=n,r+=n}let d=0;for(let t=0;t<i;t++){let e;e=0===r?0:a[t]/r,a[t]=e,e>1e-7&&(d-=e*Math.log(e))}d>o?(n=c,l===1/0?c*=2:c=(c+l)/2):(l=c,n===-1/0?c/=2:c=(c+n)/2),m++,Math.abs(d-o)<s&&(h=!0),m>=u&&(h=!0)}for(let t=0;t<i;t++)r[e*i+t]=a[t]}const l=this.zeros(i*i),c=2*i;for(let t=0;t<i;t++)for(let e=0;e<i;e++)l[t*i+e]=Math.max((r[t*i+e]+r[e*i+t])/c,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 n=this.xtod(t);this.P=this.d2p(n,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 n=0;n<e;n++)for(let i=n+1;i<e;i++){const o=t[n][i];s[n*e+i]=o,s[i*e+n]=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,n=e.grad,i=this.zeros(this.dim);for(let e=0;e<t;e++)for(let t=0;t<this.dim;t++){const s=n[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*n[e][t];this.ystep[e][t]=l,this.Y[e][t]+=l,i[t]+=this.Y[e][t]}for(let e=0;e<t;e++)for(let s=0;s<this.dim;s++)this.Y[e][s]-=i[s]/t;return s}debugGrad(){const t=this.N,e=this.costGrad(this.Y),s=(e.cost,e.grad),n=1e-5;for(let e=0;e<t;e++)for(let t=0;t<this.dim;t++){const i=this.Y[e][t];this.Y[e][t]=i+n;const o=this.costGrad(this.Y);this.Y[e][t]=i-n;const r=this.costGrad(this.Y),a=s[e][t],l=(o.cost-r.cost)/(2*n);console.log(e+","+t+": gradcheck analytic: "+a+" vs. numerical: "+l),this.Y[e][t]=i}}costGrad(t){const e=this.N,s=this.dim,n=this.P,i=this.iter<100?4:1,o=this.zeros(e*e);let r=0;for(let n=0;n<e;n++)for(let i=n+1;i<e;i++){let a=0;for(let e=0;e<s;e++){const s=t[n][e]-t[i][e];a+=s*s}const l=1/(1+a);o[n*e+i]=l,o[i*e+n]=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 c=0;const h=[];for(let r=0;r<e;r++){const a=new Array(s);for(let t=0;t<s;t++)a[t]=0;for(let h=0;h<e;h++){c+=-n[r*e+h]*Math.log(l[r*e+h]);const u=4*(i*n[r*e+h]-l[r*e+h])*o[r*e+h];for(let e=0;e<s;e++)a[e]+=u*(t[r][e]-t[h][e])}h.push(a)}return{cost:c,grad:h}}}},5362:(t,e,s)=>{"use strict";s.d(e,{Z:()=>a});var n=s(7537),i=s.n(n),o=s(3645),r=s.n(o)()(i());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 n=s(7537),i=s.n(n),o=s(3645),r=s.n(o)()(i());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 n=s(7537),i=s.n(n),o=s(3645),r=s.n(o)()(i());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="",n=void 0!==e[5];return e[4]&&(s+="@supports (".concat(e[4],") {")),e[2]&&(s+="@media ".concat(e[2]," {")),n&&(s+="@layer".concat(e[5].length>0?" ".concat(e[5]):""," {")),s+=t(e),n&&(s+="}"),e[2]&&(s+="}"),e[4]&&(s+="}"),s})).join("")},e.i=function(t,s,n,i,o){"string"==typeof t&&(t=[[null,t,void 0]]);var r={};if(n)for(var a=0;a<this.length;a++){var l=this[a][0];null!=l&&(r[l]=!0)}for(var c=0;c<t.length;c++){var h=[].concat(t[c]);n&&r[h[0]]||(void 0!==o&&(void 0===h[5]||(h[1]="@layer".concat(h[5].length>0?" ".concat(h[5]):""," {").concat(h[1],"}")),h[5]=o),s&&(h[2]?(h[1]="@media ".concat(h[2]," {").concat(h[1],"}"),h[2]=s):h[2]=s),i&&(h[4]?(h[1]="@supports (".concat(h[4],") {").concat(h[1],"}"),h[4]=i):h[4]="".concat(i)),e.push(h))}},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 n=btoa(unescape(encodeURIComponent(JSON.stringify(s)))),i="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(n),o="/*# ".concat(i," */");return[e].concat([o]).join("\n")}return[e].join("\n")}},9133:function(t,e,s){var n;!function(e,i){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,n,i,o){for(var r,a,l,c,h,u,m,d,p,g,f,y,w;o>=64;){for(r=s[0],a=s[1],l=s[2],c=s[3],h=s[4],u=s[5],m=s[6],d=s[7],g=0;g<16;g++)f=i+4*g,t[g]=(255&n[f])<<24|(255&n[f+1])<<16|(255&n[f+2])<<8|255&n[f+3];for(g=16;g<64;g++)y=((p=t[g-2])>>>17|p<<15)^(p>>>19|p<<13)^p>>>10,w=((p=t[g-15])>>>7|p<<25)^(p>>>18|p<<14)^p>>>3,t[g]=(y+t[g-7]|0)+(w+t[g-16]|0);for(g=0;g<64;g++)y=(((h>>>6|h<<26)^(h>>>11|h<<21)^(h>>>25|h<<7))+(h&u^~h&m)|0)+(d+(e[g]+t[g]|0)|0)|0,w=((r>>>2|r<<30)^(r>>>13|r<<19)^(r>>>22|r<<10))+(r&a^r&l^a&l)|0,d=m,m=u,u=h,h=c+y|0,c=l,l=a,a=r,r=y+w|0;s[0]+=r,s[1]+=a,s[2]+=l,s[3]+=c,s[4]+=h,s[5]+=u,s[6]+=m,s[7]+=d,i+=64,o-=64}return i}var n=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 n=0;if(this.bytesHashed+=e,this.bufferLength>0){for(;this.bufferLength<64&&e>0;)this.buffer[this.bufferLength++]=t[n++],e--;64===this.bufferLength&&(s(this.temp,this.state,this.buffer,0,64),this.bufferLength=0)}for(e>=64&&(n=s(this.temp,this.state,t,n,e),e%=64);e>0;)this.buffer[this.bufferLength++]=t[n++],e--;return this},e.prototype.finish=function(t){if(!this.finished){var e=this.bytesHashed,n=this.bufferLength,i=e/536870912|0,o=e<<3,r=e%64<56?64:128;this.buffer[n]=128;for(var a=n+1;a<r-8;a++)this.buffer[a]=0;this.buffer[r-8]=i>>>24&255,this.buffer[r-7]=i>>>16&255,this.buffer[r-6]=i>>>8&255,this.buffer[r-5]=i>>>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=n;var i=function(){function t(t){this.inner=new n,this.outer=new n,this.blockSize=this.inner.blockSize,this.digestLength=this.inner.digestLength;var e=new Uint8Array(this.blockSize);if(t.length>this.blockSize)(new n).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 n).update(t),s=e.digest();return e.clean(),s}function r(t,e){var s=new i(t).update(e),n=s.digest();return s.clean(),n}function a(t,e,s,n){var i=n[0];if(0===i)throw new Error("hkdf: cannot expand more");e.reset(),i>1&&e.update(t),s&&e.update(s),e.update(n),e.finish(t),n[0]++}t.HMAC=i,t.hash=o,t.default=o,t.hmac=r;var l=new Uint8Array(t.digestLength);t.hkdf=function(t,e,s,n){void 0===e&&(e=l),void 0===n&&(n=32);for(var o=new Uint8Array([1]),c=r(e,t),h=new i(c),u=new Uint8Array(h.digestLength),m=u.length,d=new Uint8Array(n),p=0;p<n;p++)m===u.length&&(a(u,h,s,o),m=0),d[p]=u[m++];return h.clean(),u.fill(0),o.fill(0),d},t.pbkdf2=function(t,e,s,n){for(var o=new i(t),r=o.digestLength,a=new Uint8Array(4),l=new Uint8Array(r),c=new Uint8Array(r),h=new Uint8Array(n),u=0;u*r<n;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(c);for(var d=0;d<r;d++)l[d]=c[d];for(d=2;d<=s;d++){o.reset(),o.update(c).finish(c);for(var p=0;p<r;p++)l[p]^=c[p]}for(d=0;d<r&&u*r+d<n;d++)h[u*r+d]=l[d]}for(u=0;u<r;u++)l[u]=c[u]=0;for(u=0;u<4;u++)a[u]=0;return o.clean(),h}}(o);var r=o.default;for(var a in o)r[a]=o[a];"object"==typeof t.exports?t.exports=r:void 0===(n=function(){return r}.call(o,s,o,t))||(t.exports=n)}()},1811:(t,e,s)=>{"use strict";s.d(e,{T:()=>i});const n=new Uint32Array(65536),i=(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,i=e.length,o=1<<s-1;let r=-1,a=0,l=s,c=s;for(;c--;)n[t.charCodeAt(c)]|=1<<c;for(c=0;c<i;c++){let t=n[e.charCodeAt(c)];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(c=s;c--;)n[t.charCodeAt(c)]=0;return l})(t,e):((t,e)=>{const s=e.length,i=t.length,o=[],r=[],a=Math.ceil(s/32),l=Math.ceil(i/32);for(let t=0;t<a;t++)r[t]=-1,o[t]=0;let c=0;for(;c<l-1;c++){let a=0,l=-1;const h=32*c,u=Math.min(32,i)+h;for(let e=h;e<u;e++)n[t.charCodeAt(e)]|=1<<e;for(let t=0;t<s;t++){const s=n[e.charCodeAt(t)],i=r[t/32|0]>>>t&1,c=o[t/32|0]>>>t&1,h=s|a,u=((s|c)&l)+l^l|s|c;let m=a|~(u|l),d=l&u;m>>>31^i&&(r[t/32|0]^=1<<t),d>>>31^c&&(o[t/32|0]^=1<<t),m=m<<1|i,d=d<<1|c,l=d|~(h|m),a=m&h}for(let e=h;e<u;e++)n[t.charCodeAt(e)]=0}let h=0,u=-1;const m=32*c,d=Math.min(32,i-m)+m;for(let e=m;e<d;e++)n[t.charCodeAt(e)]|=1<<e;let p=i;for(let t=0;t<s;t++){const s=n[e.charCodeAt(t)],a=r[t/32|0]>>>t&1,l=o[t/32|0]>>>t&1,c=s|h,m=((s|l)&u)+u^u|s|l;let d=h|~(m|u),g=u&m;p+=d>>>i-1&1,p-=g>>>i-1&1,d>>>31^a&&(r[t/32|0]^=1<<t),g>>>31^l&&(o[t/32|0]^=1<<t),d=d<<1|a,g=g<<1|l,u=g|~(c|d),h=d&c}for(let e=m;e<d;e++)n[t.charCodeAt(e)]=0;return p})(t,e)}},7531:(t,e,s)=>{"use strict";s.d(e,{Z:()=>i});const n=Object.prototype.toString;function i(t){return n.call(t).endsWith("Array]")}},3979:(t,e)=>{"use strict";e.H$=void 0,e.H$=function(t,e,s){var n=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 n=0,i=t.length,o=e.length,r=Math.floor(Math.max(i,o)/2)-1,a=new Array(i),l=new Array(o),c=0;c<i;c++)for(var h=Math.max(0,c-r);h<=Math.min(o,c+r+1);h++)if(!a[c]&&!l[h]&&t[c]===e[h]){++n,a[c]=l[h]=!0;break}if(0===n)return 0;var u=0,m=0;for(c=0;c<i;c++)if(a[c]){for(;!l[m];)m++;t.charAt(c)!==e.charAt(m++)&&u++}return(n/i+n/o+(n-(u/=2))/n)/3}(t,e,s),i=0;if(n>.7){for(var o=Math.min(t.length,e.length),r=0;t[r]===e[r]&&r<4&&r<o;)++i,r++;n+=.1*i*(1-n)}return n}},5111:(t,e,s)=>{"use strict";s.d(e,{Z:()=>i});var n=s(6044);function i(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!(0,n.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,i=void 0===s?0:s,o=e.toIndex,r=void 0===o?t.length:o;if(i<0||i>=t.length||!Number.isInteger(i))throw new Error("fromIndex must be a positive integer smaller than length");if(r<=i||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[i],l=i+1;l<r;l++)t[l]>a&&(a=t[l]);return a}},6044:(t,e,s)=>{"use strict";s.d(e,{N:()=>i});const n=Object.prototype.toString;function i(t){return n.call(t).endsWith("Array]")}},1772:(t,e,s)=>{"use strict";s.d(e,{Z:()=>i});var n=s(994);function i(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!(0,n.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,i=void 0===s?0:s,o=e.toIndex,r=void 0===o?t.length:o;if(i<0||i>=t.length||!Number.isInteger(i))throw new Error("fromIndex must be a positive integer smaller than length");if(r<=i||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[i],l=i+1;l<r;l++)t[l]<a&&(a=t[l]);return a}},994:(t,e,s)=>{"use strict";s.d(e,{N:()=>i});const n=Object.prototype.toString;function i(t){return n.call(t).endsWith("Array]")}},5408:(t,e,s)=>{"use strict";s.d(e,{Z:()=>r});var n=s(6241),i=s(5111),o=s(1772);function r(t){var e,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!(0,n.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,n.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,i.Z)(t);if(r===a)throw new RangeError("minimum and maximum input values are equal. Cannot rescale a constant array");var l=s.min,c=void 0===l?s.autoMinMax?r:0:l,h=s.max,u=void 0===h?s.autoMinMax?a:1:h;if(c>=u)throw new RangeError("min option must be smaller than max option");for(var m=(u-c)/(a-r),d=0;d<t.length;d++)e[d]=(t[d]-r)*m+c;return e}},6241:(t,e,s)=>{"use strict";s.d(e,{N:()=>i});const n=Object.prototype.toString;function i(t){return n.call(t).endsWith("Array]")}},1353:(t,e,s)=>{"use strict";function n(t,e,s){let n=0;const i=s(e);for(let e=0;e<t.x.length;e++)n+=Math.abs(t.y[e]-i(t.x[e]));return n}s.d(e,{Z:()=>n})},3107:(t,e,s)=>{"use strict";s.d(e,{Z:()=>r});var n=s(7531),i=s(1353),o=s(8188);function r(t,e,s={}){let{maxIterations:r=100,gradientDifference:a=.1,damping:l=0,errorTolerance:c=.01,minValues:h,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,n.Z)(t.x)||t.x.length<2||!(0,n.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),p=d.length;if(u=u||new Array(p).fill(Number.MAX_SAFE_INTEGER),h=h||new Array(p).fill(Number.MIN_SAFE_INTEGER),u.length!==h.length)throw new Error("minValues and maxValues must be the same size");if(!(0,n.Z)(d))throw new Error("initialValues must be an array");let g,f=(0,i.Z)(t,d,e),y=f<=c;for(g=0;g<r&&!y;g++){d=(0,o.Z)(t,d,l,a,e);for(let t=0;t<p;t++)d[t]=Math.min(Math.max(h[t],d[t]),u[t]);if(f=(0,i.Z)(t,d,e),isNaN(f))break;y=f<=c}return{parameterValues:d,parameterError:f,iterations:g}}},8188:(t,e,s)=>{"use strict";s.d(e,{Z:()=>o});var n=s(1174),i=s(8345);function o(t,e,s,o,r){let a=s*o*o,l=n.Z.eye(e.length,e.length,a);const c=r(e);let h=new Float64Array(t.x.length);for(let e=0;e<t.x.length;e++)h[e]=c(t.x[e]);let u=function(t,e,s,i,o){const r=s.length,a=t.x.length;let l=new Array(r);for(let n=0;n<r;n++){l[n]=new Array(a);let r=s.slice();r[n]+=i;let c=o(r);for(let s=0;s<a;s++)l[n][s]=e[s]-c(t.x[s])}return new n.Z(l)}(t,h,e,o,r),m=function(t,e){const s=t.x.length;let i=new Array(s);for(let n=0;n<s;n++)i[n]=[t.y[n]-e[n]];return new n.Z(i)}(t,h),d=(0,i.S)(l.add(u.mmul(u.transpose())));return(e=(e=new n.Z([e])).sub(d.mmul(u).mmul(m).mul(o).transpose())).to1DArray()}},5776:(t,e,s)=>{"use strict";s.d(e,{N:()=>i});const n=Object.prototype.toString;function i(t){return n.call(t).endsWith("Array]")}},2313:(t,e,s)=>{"use strict";s.d(e,{Z:()=>o});var n=s(1174),i=s(8353);class o{constructor(t){let e,s,n,o,r,a,l,c,h,u=(t=i.Z.checkMatrix(t)).clone(),m=u.rows,d=u.columns,p=new Float64Array(m),g=1;for(e=0;e<m;e++)p[e]=e;for(c=new Float64Array(m),s=0;s<d;s++){for(e=0;e<m;e++)c[e]=u.get(e,s);for(e=0;e<m;e++){for(h=Math.min(e,s),r=0,n=0;n<h;n++)r+=u.get(e,n)*c[n];c[e]-=r,u.set(e,s,c[e])}for(o=s,e=s+1;e<m;e++)Math.abs(c[e])>Math.abs(c[o])&&(o=e);if(o!==s){for(n=0;n<d;n++)a=u.get(o,n),u.set(o,n,u.get(s,n)),u.set(s,n,a);l=p[o],p[o]=p[s],p[s]=l,g=-g}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=p,this.pivotSign=g}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=n.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,i,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(i=0;i<r;i++)a.set(s,i,a.get(s,i)-a.get(o,i)*e.get(s,o));for(o=l-1;o>=0;o--){for(i=0;i<r;i++)a.set(o,i,a.get(o,i)/e.get(o,o));for(s=0;s<o;s++)for(i=0;i<r;i++)a.set(s,i,a.get(s,i)-a.get(o,i)*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 n=0;n<s;n++)e*=t.get(n,n);return e}get lowerTriangularMatrix(){let t=this.LU,e=t.rows,s=t.columns,i=new n.Z(e,s);for(let n=0;n<e;n++)for(let e=0;e<s;e++)n>e?i.set(n,e,t.get(n,e)):n===e?i.set(n,e,1):i.set(n,e,0);return i}get upperTriangularMatrix(){let t=this.LU,e=t.rows,s=t.columns,i=new n.Z(e,s);for(let n=0;n<e;n++)for(let e=0;e<s;e++)n<=e?i.set(n,e,t.get(n,e)):i.set(n,e,0);return i}get pivotPermutationVector(){return Array.from(this.pivotVector)}}},7072:(t,e,s)=>{"use strict";s.d(e,{Z:()=>r});var n=s(1174),i=s(8353),o=s(6310);class r{constructor(t){let e,s,n,r,a=(t=i.Z.checkMatrix(t)).clone(),l=t.rows,c=t.columns,h=new Float64Array(c);for(n=0;n<c;n++){let t=0;for(e=n;e<l;e++)t=(0,o.G)(t,a.get(e,n));if(0!==t){for(a.get(n,n)<0&&(t=-t),e=n;e<l;e++)a.set(e,n,a.get(e,n)/t);for(a.set(n,n,a.get(n,n)+1),s=n+1;s<c;s++){for(r=0,e=n;e<l;e++)r+=a.get(e,n)*a.get(e,s);for(r=-r/a.get(n,n),e=n;e<l;e++)a.set(e,s,a.get(e,s)+r*a.get(e,n))}}h[n]=-t}this.QR=a,this.Rdiag=h}solve(t){t=n.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 i,o,r,a,l=t.columns,c=t.clone(),h=e.columns;for(r=0;r<h;r++)for(o=0;o<l;o++){for(a=0,i=r;i<s;i++)a+=e.get(i,r)*c.get(i,o);for(a=-a/e.get(r,r),i=r;i<s;i++)c.set(i,o,c.get(i,o)+a*e.get(i,r))}for(r=h-1;r>=0;r--){for(o=0;o<l;o++)c.set(r,o,c.get(r,o)/this.Rdiag[r]);for(i=0;i<r;i++)for(o=0;o<l;o++)c.set(i,o,c.get(i,o)-c.get(r,o)*e.get(i,r))}return c.subMatrix(0,h-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,i=s.columns,o=new n.Z(i,i);for(t=0;t<i;t++)for(e=0;e<i;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,i,o=this.QR,r=o.rows,a=o.columns,l=new n.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(i=0,t=s;t<r;t++)i+=o.get(t,s)*l.get(t,e);for(i=-i/o.get(s,s),t=s;t<r;t++)l.set(t,e,l.get(t,e)+i*o.get(t,s))}}return l}}},6943:(t,e,s)=>{"use strict";s.d(e,{Z:()=>r});var n=s(1174),i=s(8353),o=s(6310);class r{constructor(t,e={}){if((t=i.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:c=!1}=e;let h,u=Boolean(a),m=Boolean(l),d=!1;if(s<r)if(c){h=t.transpose(),s=h.rows,r=h.columns,d=!0;let e=u;u=m,m=e}else h=t.clone(),console.warn("Computing SVD on a matrix with more columns than rows. Consider enabling autoTranspose");else h=t.clone();let p=Math.min(s,r),g=Math.min(s+1,r),f=new Float64Array(g),y=new n.Z(s,p),w=new n.Z(r,r),C=new Float64Array(r),T=new Float64Array(s),b=new Float64Array(g);for(let t=0;t<g;t++)b[t]=t;let A=Math.min(s-1,r),S=Math.max(0,Math.min(r-2,s)),E=Math.max(A,S);for(let t=0;t<E;t++){if(t<A){f[t]=0;for(let e=t;e<s;e++)f[t]=(0,o.G)(f[t],h.get(e,t));if(0!==f[t]){h.get(t,t)<0&&(f[t]=-f[t]);for(let e=t;e<s;e++)h.set(e,t,h.get(e,t)/f[t]);h.set(t,t,h.get(t,t)+1)}f[t]=-f[t]}for(let e=t+1;e<r;e++){if(t<A&&0!==f[t]){let n=0;for(let i=t;i<s;i++)n+=h.get(i,t)*h.get(i,e);n=-n/h.get(t,t);for(let i=t;i<s;i++)h.set(i,e,h.get(i,e)+n*h.get(i,t))}C[e]=h.get(t,e)}if(u&&t<A)for(let e=t;e<s;e++)y.set(e,t,h.get(e,t));if(t<S){C[t]=0;for(let e=t+1;e<r;e++)C[t]=(0,o.G)(C[t],C[e]);if(0!==C[t]){C[t+1]<0&&(C[t]=0-C[t]);for(let e=t+1;e<r;e++)C[e]/=C[t];C[t+1]+=1}if(C[t]=-C[t],t+1<s&&0!==C[t]){for(let e=t+1;e<s;e++)T[e]=0;for(let e=t+1;e<s;e++)for(let s=t+1;s<r;s++)T[e]+=C[s]*h.get(e,s);for(let e=t+1;e<r;e++){let n=-C[e]/C[t+1];for(let i=t+1;i<s;i++)h.set(i,e,h.get(i,e)+n*T[i])}}if(m)for(let e=t+1;e<r;e++)w.set(e,t,C[e])}}let M=Math.min(r,s+1);if(A<r&&(f[A]=h.get(A,A)),s<M&&(f[M-1]=0),S+1<M&&(C[S]=h.get(S,M-1)),C[M-1]=0,u){for(let t=A;t<p;t++){for(let e=0;e<s;e++)y.set(e,t,0);y.set(t,t,1)}for(let t=A-1;t>=0;t--)if(0!==f[t]){for(let e=t+1;e<p;e++){let n=0;for(let i=t;i<s;i++)n+=y.get(i,t)*y.get(i,e);n=-n/y.get(t,t);for(let i=t;i<s;i++)y.set(i,e,y.get(i,e)+n*y.get(i,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<S&&0!==C[t])for(let e=t+1;e<r;e++){let s=0;for(let n=t+1;n<r;n++)s+=w.get(n,t)*w.get(n,e);s=-s/w.get(t+1,t);for(let n=t+1;n<r;n++)w.set(n,e,w.get(n,e)+s*w.get(n,t))}for(let e=0;e<r;e++)w.set(e,t,0);w.set(t,t,1)}let v=M-1,N=0,I=Number.EPSILON;for(;M>0;){let t,e;for(t=M-2;t>=-1&&-1!==t;t--){const e=Number.MIN_VALUE+I*Math.abs(f[t]+Math.abs(f[t+1]));if(Math.abs(C[t])<=e||Number.isNaN(C[t])){C[t]=0;break}}if(t===M-2)e=4;else{let s;for(s=M-1;s>=t&&s!==t;s--){let e=(s!==M?Math.abs(C[s]):0)+(s!==t+1?Math.abs(C[s-1]):0);if(Math.abs(f[s])<=I*e){f[s]=0;break}}s===t?e=3:s===M-1?e=1:(e=2,t=s)}switch(t++,e){case 1:{let e=C[M-2];C[M-2]=0;for(let s=M-2;s>=t;s--){let n=(0,o.G)(f[s],e),i=f[s]/n,a=e/n;if(f[s]=n,s!==t&&(e=-a*C[s-1],C[s-1]=i*C[s-1]),m)for(let t=0;t<r;t++)n=i*w.get(t,s)+a*w.get(t,M-1),w.set(t,M-1,-a*w.get(t,s)+i*w.get(t,M-1)),w.set(t,s,n)}break}case 2:{let e=C[t-1];C[t-1]=0;for(let n=t;n<M;n++){let i=(0,o.G)(f[n],e),r=f[n]/i,a=e/i;if(f[n]=i,e=-a*C[n],C[n]=r*C[n],u)for(let e=0;e<s;e++)i=r*y.get(e,n)+a*y.get(e,t-1),y.set(e,t-1,-a*y.get(e,n)+r*y.get(e,t-1)),y.set(e,n,i)}break}case 3:{const e=Math.max(Math.abs(f[M-1]),Math.abs(f[M-2]),Math.abs(C[M-2]),Math.abs(f[t]),Math.abs(C[t])),n=f[M-1]/e,i=f[M-2]/e,a=C[M-2]/e,l=f[t]/e,c=C[t]/e,h=((i+n)*(i-n)+a*a)/2,d=n*a*(n*a);let p=0;0===h&&0===d||(p=h<0?0-Math.sqrt(h*h+d):Math.sqrt(h*h+d),p=d/(h+p));let g=(l+n)*(l-n)+p,T=l*c;for(let e=t;e<M-1;e++){let n=(0,o.G)(g,T);0===n&&(n=Number.MIN_VALUE);let i=g/n,a=T/n;if(e!==t&&(C[e-1]=n),g=i*f[e]+a*C[e],C[e]=i*C[e]-a*f[e],T=a*f[e+1],f[e+1]=i*f[e+1],m)for(let t=0;t<r;t++)n=i*w.get(t,e)+a*w.get(t,e+1),w.set(t,e+1,-a*w.get(t,e)+i*w.get(t,e+1)),w.set(t,e,n);if(n=(0,o.G)(g,T),0===n&&(n=Number.MIN_VALUE),i=g/n,a=T/n,f[e]=n,g=i*C[e]+a*f[e+1],f[e+1]=-a*C[e]+i*f[e+1],T=a*C[e+1],C[e+1]=i*C[e+1],u&&e<s-1)for(let t=0;t<s;t++)n=i*y.get(t,e)+a*y.get(t,e+1),y.set(t,e+1,-a*y.get(t,e)+i*y.get(t,e+1)),y.set(t,e,n)}C[M-2]=g,N+=1;break}case 4:if(f[t]<=0&&(f[t]=f[t]<0?-f[t]:0,m))for(let e=0;e<=v;e++)w.set(e,t,-w.get(e,t));for(;t<v&&!(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=w.get(s,t+1),w.set(s,t+1,w.get(s,t)),w.set(s,t,e);if(u&&t<s-1)for(let n=0;n<s;n++)e=y.get(n,t+1),y.set(n,t+1,y.get(n,t)),y.set(n,t,e);t++}N=0,M--}}if(d){let t=w;w=y,y=t}this.m=s,this.n=r,this.s=f,this.U=y,this.V=w}solve(t){let e=t,s=this.threshold,i=this.s.length,o=n.Z.zeros(i,i);for(let t=0;t<i;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),c=a.rows,h=r.rows,u=n.Z.zeros(c,h);for(let t=0;t<c;t++)for(let e=0;e<h;e++){let s=0;for(let n=0;n<i;n++)s+=l.get(t,n)*r.get(e,n);u.set(t,e,s)}return u.mmul(e)}solveForDiagonal(t){return this.solve(n.Z.diag(t))}inverse(){let t=this.V,e=this.threshold,s=t.rows,i=t.columns,o=new n.Z(s,this.s.length);for(let n=0;n<s;n++)for(let s=0;s<i;s++)Math.abs(this.s[s])>e&&o.set(n,s,t.get(n,s)/this.s[s]);let r=this.U,a=r.rows,l=r.columns,c=new n.Z(s,a);for(let t=0;t<s;t++)for(let e=0;e<a;e++){let s=0;for(let n=0;n<l;n++)s+=o.get(t,n)*r.get(e,n);c.set(t,e,s)}return c}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 n=0,i=s.length;n<i;n++)s[n]>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 n.Z.diag(this.s)}}},6310:(t,e,s)=>{"use strict";function n(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:()=>n})},8345:(t,e,s)=>{"use strict";s.d(e,{S:()=>l});var n=s(2313),i=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 n.Z(t).solve(e):new i.Z(t).solve(e)}(t,r.Z.eye(t.rows))}},3559:(t,e,s)=>{"use strict";s.d(e,{M:()=>r,V:()=>o});const n=" ".repeat(2),i=" ".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${n}[\n${i}${function(t,e,s,n,o){const{rows:r,columns:l}=t,c=Math.min(r,e),h=Math.min(l,s),u=[];if("auto"===o){o=!1;t:for(let e=0;e<c;e++)for(let s=0;s<h;s++)if(t.get(e,s)<0){o=!0;break t}}for(let e=0;e<c;e++){let s=[];for(let i=0;i<h;i++)s.push(a(t.get(e,i),n,o));u.push(`${s.join(" ")}`)}return h!==l&&(u[u.length-1]+=` ... ${l-s} more columns`),c!==r&&u.push(`... ${r-e} more rows`),u.join(`\n${i}`)}(t,s,o,r,l)}\n${n}]\n${n}rows: ${t.rows}\n${n}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 n=t.toFixed(e);if(n.length>e&&(n=t.toFixed(Math.max(0,e-(n.length-e)))),n.length<=e&&!n.startsWith("0.000")&&!n.startsWith("-0.000"))return n;let i=t.toExponential(e);return i.length>e&&(i=t.toExponential(Math.max(0,e-(i.length-e)))),i.slice(0)}},5401:(t,e,s)=>{"use strict";function n(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:()=>n})},1174:(t,e,s)=>{"use strict";s.d(e,{X:()=>c,Z:()=>u});var n=s(5776),i=s(5408),o=s(3559),r=s(5401),a=s(9515),l=s(3018);class c{static from1DArray(t,e,s){if(t*e!==s.length)throw new RangeError("data length does not match given dimensions");let n=new u(t,e);for(let i=0;i<t;i++)for(let t=0;t<e;t++)n.set(i,t,s[i*e+t]);return n}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:n=Math.random}=s;let i=new u(t,e);for(let s=0;s<t;s++)for(let t=0;t<e;t++)i.set(s,t,n());return i}static randInt(t,e,s={}){if("object"!=typeof s)throw new TypeError("options must be an object");const{min:n=0,max:i=1e3,random:o=Math.random}=s;if(!Number.isInteger(n))throw new TypeError("min must be an integer");if(!Number.isInteger(i))throw new TypeError("max must be an integer");if(n>=i)throw new RangeError("min must be smaller than max");let r=i-n,a=new u(t,e);for(let s=0;s<t;s++)for(let t=0;t<e;t++){let e=n+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 n=Math.min(t,e),i=this.zeros(t,e);for(let t=0;t<n;t++)i.set(t,t,s);return i}static diag(t,e,s){let n=t.length;void 0===e&&(e=n),void 0===s&&(s=e);let i=Math.min(n,e,s),o=this.zeros(e,s);for(let e=0;e<i;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,n=t.columns,i=new u(s,n);for(let o=0;o<s;o++)for(let s=0;s<n;s++)i.set(o,s,Math.min(t.get(o,s),e.get(o,s)));return i}static max(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let s=t.rows,n=t.columns,i=new this(s,n);for(let o=0;o<s;o++)for(let s=0;s<n;s++)i.set(o,s,Math.max(t.get(o,s),e.get(o,s)));return i}static checkMatrix(t){return c.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,n=!0,i=!1;for(;t<this.rows&&n;){for(e=0,i=!1;e<this.columns&&!1===i;)0===this.get(t,e)?e++:1===this.get(t,e)&&e>s?(i=!0,s=e):(n=!1,i=!0);t++}return n}isReducedEchelonForm(){let t=0,e=0,s=-1,n=!0,i=!1;for(;t<this.rows&&n;){for(e=0,i=!1;e<this.columns&&!1===i;)0===this.get(t,e)?e++:1===this.get(t,e)&&e>s?(i=!0,s=e):(n=!1,i=!0);for(let s=e+1;s<this.rows;s++)0!==this.get(t,s)&&(n=!1);t++}return n}echelonForm(){let t=this.clone(),e=0,s=0;for(;e<t.rows&&s<t.columns;){let n=e;for(let i=e;i<t.rows;i++)t.get(i,s)>t.get(n,s)&&(n=i);if(0===t.get(n,s))s++;else{t.swapRows(e,n);let i=t.get(e,s);for(let n=s;n<t.columns;n++)t.set(e,n,t.get(e,n)/i);for(let n=e+1;n<t.rows;n++){let i=t.get(n,s)/t.get(e,s);t.set(n,s,0);for(let o=s+1;o<t.columns;o++)t.set(n,o,t.get(n,o)-t.get(e,o)*i)}e++,s++}}return t}reducedEchelonForm(){let t=this.echelonForm(),e=t.columns,s=t.rows,n=s-1;for(;n>=0;)if(0===t.maxRow(n))n--;else{let i=0,o=!1;for(;i<s&&!1===o;)1===t.get(n,i)?o=!0:i++;for(let s=0;s<n;s++){let o=t.get(s,i);for(let r=i;r<e;r++){let e=t.get(s,r)-o*t.get(n,r);t.set(s,r,e)}}n--}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 n=new u(this.rows*e,this.columns*s);for(let t=0;t<e;t++)for(let e=0;e<s;e++)n.setSubMatrix(this,this.rows*t,this.columns*e);return n}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 n=this.get(t,s);this.set(t,s,this.get(e,s)),this.set(e,s,n)}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 n=this.get(s,t);this.set(s,t,this.get(s,e)),this.set(s,e,n)}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 n=0;n<this.columns;n++)this.get(s,n)>t&&(t=this.get(s,n),e[0]=s,e[1]=n);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 n=0;n<this.columns;n++)this.get(s,n)<t&&(t=this.get(s,n),e[0]=s,e[1]=n);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 n=1;n<this.columns;n++)this.get(t,n)>e&&(e=this.get(t,n),s[1]=n);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 n=1;n<this.columns;n++)this.get(t,n)<e&&(e=this.get(t,n),s[1]=n);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 n=1;n<this.rows;n++)this.get(n,t)>e&&(e=this.get(n,t),s[0]=n);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 n=1;n<this.rows;n++)this.get(n,t)<e&&(e=this.get(n,t),s[0]=n);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){c.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 n=0;n<e.length;n++)s+=e[n]*t[n];return s}mmul(t){t=u.checkMatrix(t);let e=this.rows,s=this.columns,n=t.columns,i=new u(e,n),o=new Float64Array(s);for(let r=0;r<n;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 n=0;n<s;n++)e+=this.get(t,n)*o[n];i.set(t,r,e)}}return i}strassen2x2(t){t=u.checkMatrix(t);let e=new u(2,2);const s=this.get(0,0),n=t.get(0,0),i=this.get(0,1),o=t.get(0,1),r=this.get(1,0),a=t.get(1,0),l=this.get(1,1),c=t.get(1,1),h=(s+l)*(n+c),m=(r+l)*n,d=s*(o-c),p=l*(a-n),g=(s+i)*c,f=h+p-g+(i-l)*(a+c),y=d+g,w=m+p,C=h-m+d+(r-s)*(n+o);return e.set(0,0,f),e.set(0,1,y),e.set(1,0,w),e.set(1,1,C),e}strassen3x3(t){t=u.checkMatrix(t);let e=new u(3,3);const s=this.get(0,0),n=this.get(0,1),i=this.get(0,2),o=this.get(1,0),r=this.get(1,1),a=this.get(1,2),l=this.get(2,0),c=this.get(2,1),h=this.get(2,2),m=t.get(0,0),d=t.get(0,1),p=t.get(0,2),g=t.get(1,0),f=t.get(1,1),y=t.get(1,2),w=t.get(2,0),C=t.get(2,1),T=t.get(2,2),b=(s-o)*(-d+f),A=(-s+o+r)*(m-d+f),S=(o+r)*(-m+d),E=s*m,M=(-s+l+c)*(m-p+y),v=(-s+l)*(p-y),N=(l+c)*(-m+p),I=(-i+c+h)*(f+w-C),L=(i-h)*(f-C),P=i*w,_=(c+h)*(-w+C),R=(-i+r+a)*(y+w-T),x=(i-a)*(y-T),O=(r+a)*(-w+T),G=E+P+n*g,F=(s+n+i-o-r-c-h)*f+A+S+E+I+P+_,D=E+M+N+(s+n+i-r-a-l-c)*y+P+R+O,H=b+r*(-m+d+g-f-y-w+T)+A+E+P+R+x,W=b+A+S+E+a*C,B=P+R+x+O+o*p,k=E+M+v+c*(-m+p+g-f-y-w+C)+I+L+P,U=I+L+P+_+l*d,V=E+M+v+N+h*T;return e.set(0,0,G),e.set(0,1,F),e.set(0,2,D),e.set(1,0,H),e.set(1,1,W),e.set(1,2,B),e.set(2,0,k),e.set(2,1,U),e.set(2,2,V),e}mmulStrassen(t){t=u.checkMatrix(t);let e=this.clone(),s=e.rows,n=e.columns,i=t.rows,o=t.columns;function r(t,e,s){let n=t.rows,i=t.columns;if(n===e&&i===s)return t;{let n=c.zeros(e,s);return n=n.setSubMatrix(t,0,0),n}}n!==i&&console.warn(`Multiplying ${s} x ${n} and ${i} x ${o} matrix: dimensions do not match.`);let a=Math.max(s,i),l=Math.max(n,o);return e=r(e,a,l),function t(e,s,n,i){if(n<=512||i<=512)return e.mmul(s);n%2==1&&i%2==1?(e=r(e,n+1,i+1),s=r(s,n+1,i+1)):n%2==1?(e=r(e,n+1,i),s=r(s,n+1,i)):i%2==1&&(e=r(e,n,i+1),s=r(s,n,i+1));let o=parseInt(e.rows/2,10),a=parseInt(e.columns/2,10),l=e.subMatrix(0,o-1,0,a-1),h=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),p=s.subMatrix(o,s.rows-1,0,a-1),g=e.subMatrix(o,e.rows-1,a,e.columns-1),f=s.subMatrix(o,s.rows-1,a,s.columns-1),y=t(c.add(l,g),c.add(h,f),o,a),w=t(c.add(d,g),h,o,a),C=t(l,c.sub(m,f),o,a),T=t(g,c.sub(p,h),o,a),b=t(c.add(l,u),f,o,a),A=t(c.sub(d,l),c.add(h,m),o,a),S=t(c.sub(u,g),c.add(p,f),o,a),E=c.add(y,T);E.sub(b),E.add(S);let M=c.add(C,b),v=c.add(w,T),N=c.sub(y,w);N.add(C),N.add(A);let I=c.zeros(2*E.rows,2*E.columns);return I=I.setSubMatrix(E,0,0),I=I.setSubMatrix(M,E.rows,0),I=I.setSubMatrix(v,0,E.columns),I=I.setSubMatrix(N,E.rows,E.columns),I.subMatrix(0,n-1,0,i-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 n=new u(this.rows,this.columns);for(let t=0;t<this.rows;t++){const o=this.getRow(t);o.length>0&&(0,i.Z)(o,{min:e,max:s,output:o}),n.setRow(t,o)}return n}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 n=new u(this.rows,this.columns);for(let t=0;t<this.columns;t++){const o=this.getColumn(t);o.length&&(0,i.Z)(o,{min:e,max:s,output:o}),n.setColumn(t,o)}return n}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),n=this.get(e,this.columns-1-s);this.set(e,s,n),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),n=this.get(this.rows-1-s,e);this.set(s,e,n),this.set(this.rows-1-s,e,t)}return this}kroneckerProduct(t){t=u.checkMatrix(t);let e=this.rows,s=this.columns,n=t.rows,i=t.columns,o=new u(e*n,s*i);for(let r=0;r<e;r++)for(let e=0;e<s;e++)for(let s=0;s<n;s++)for(let a=0;a<i;a++)o.set(n*r+s,i*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,n=this.kroneckerProduct(u.eye(s,s)),i=u.eye(e,e).kroneckerProduct(t);return n.add(i)}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=h){for(let e=0;e<this.rows;e++)this.setRow(e,this.getRow(e).sort(t));return this}sortColumns(t=h){for(let e=0;e<this.columns;e++)this.setColumn(e,this.getColumn(e).sort(t));return this}subMatrix(t,e,s,n){(0,l.J5)(this,t,e,s,n);let i=new u(e-t+1,n-s+1);for(let o=t;o<=e;o++)for(let e=s;e<=n;e++)i.set(o-t,e-s,this.get(o,e));return i}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 n=new u(t.length,s-e+1);for(let i=0;i<t.length;i++)for(let o=e;o<=s;o++){if(t[i]<0||t[i]>=this.rows)throw new RangeError(`Row index out of range: ${t[i]}`);n.set(i,o-e,this.get(t[i],o))}return n}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 n=new u(s-e+1,t.length);for(let i=0;i<t.length;i++)for(let o=e;o<=s;o++){if(t[i]<0||t[i]>=this.columns)throw new RangeError(`Column index out of range: ${t[i]}`);n.set(o-e,i,this.get(o,t[i]))}return n}setSubMatrix(t,e,s){if((t=u.checkMatrix(t)).isEmpty())return this;let n=e+t.rows-1,i=s+t.columns-1;(0,l.J5)(this,e,n,s,i);for(let n=0;n<t.rows;n++)for(let i=0;i<t.columns;i++)this.set(e+n,s+i,t.get(n,i));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 n=0;n<t.length;n++){let i=t[n];for(let t=0;t<e.length;t++){let o=e[t];s.set(n,t,this.get(i,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:i=this.mean(t)}=e;if("boolean"!=typeof s)throw new TypeError("unbiased must be a boolean");switch(t){case"row":if(!(0,n.N)(i))throw new TypeError("mean must be an array");return(0,a.we)(this,s,i);case"column":if(!(0,n.N)(i))throw new TypeError("mean must be an array");return(0,a._G)(this,s,i);case void 0:if("number"!=typeof i)throw new TypeError("mean must be a number");return(0,a.C)(this,s,i);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,n.N)(s))throw new TypeError("center must be an array");return(0,a.rU)(this,s),this;case"column":if(!(0,n.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,n.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,n.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 h(t,e){return t-e}c.prototype.klass="Matrix","undefined"!=typeof Symbol&&(c.prototype[Symbol.for("nodejs.util.inspect.custom")]=o.V),c.random=c.rand,c.randomInt=c.randInt,c.diagonal=c.diag,c.prototype.diagonal=c.prototype.diag,c.identity=c.eye,c.prototype.negate=c.prototype.neg,c.prototype.tensorProduct=c.prototype.kroneckerProduct;class u extends c{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,n.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 n=0;n<t;n++){if(s[n].length!==e)throw new RangeError("Inconsistent array dimensions");if(!s[n].every((t=>"number"==typeof t)))throw new TypeError("Input data contains non-numeric values");this.data.push(Float64Array.from(s[n]))}}}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 n=0;n<t;n++)s[n]=this.data[e][n];for(let n=t+1;n<this.columns;n++)s[n-1]=this.data[e][n];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 n=new Float64Array(this.columns+1);let i=0;for(;i<t;i++)n[i]=this.data[s][i];for(n[i++]=e[s];i<this.columns+1;i++)n[i]=this.data[s][i-1];this.data[s]=n}return this.columns+=1,this}}(0,r.z)(c,u)},9515:(t,e,s)=>{"use strict";s.d(e,{C:()=>m,DU:()=>y,Dm:()=>o,Mj:()=>C,PI:()=>l,Pr:()=>w,Pw:()=>a,Y2:()=>T,_G:()=>u,_f:()=>p,bQ:()=>i,kn:()=>f,mm:()=>g,rU:()=>d,tT:()=>c,td:()=>b,we:()=>h,xo:()=>r});var n=s(3018);function i(t){let e=(0,n.B4)(t.rows);for(let s=0;s<t.rows;++s)for(let n=0;n<t.columns;++n)e[s]+=t.get(s,n);return e}function o(t){let e=(0,n.B4)(t.columns);for(let s=0;s<t.rows;++s)for(let n=0;n<t.columns;++n)e[n]+=t.get(s,n);return e}function r(t){let e=0;for(let s=0;s<t.rows;s++)for(let n=0;n<t.columns;n++)e+=t.get(s,n);return e}function a(t){let e=(0,n.B4)(t.rows,1);for(let s=0;s<t.rows;++s)for(let n=0;n<t.columns;++n)e[s]*=t.get(s,n);return e}function l(t){let e=(0,n.B4)(t.columns,1);for(let s=0;s<t.rows;++s)for(let n=0;n<t.columns;++n)e[n]*=t.get(s,n);return e}function c(t){let e=1;for(let s=0;s<t.rows;s++)for(let n=0;n<t.columns;n++)e*=t.get(s,n);return e}function h(t,e,s){const n=t.rows,i=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(r,e)-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 u(t,e,s){const n=t.rows,i=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(e,r)-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 m(t,e,s){const n=t.rows,i=t.columns,o=n*i;let r=0,a=0,l=0;for(let e=0;e<n;e++)for(let n=0;n<i;n++)l=t.get(e,n)-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 n=0;n<t.columns;n++)t.set(s,n,t.get(s,n)-e[s])}function p(t,e){for(let s=0;s<t.rows;s++)for(let n=0;n<t.columns;n++)t.set(s,n,t.get(s,n)-e[n])}function g(t,e){for(let s=0;s<t.rows;s++)for(let n=0;n<t.columns;n++)t.set(s,n,t.get(s,n)-e)}function f(t){const e=[];for(let s=0;s<t.rows;s++){let n=0;for(let e=0;e<t.columns;e++)n+=Math.pow(t.get(s,e),2)/(t.columns-1);e.push(Math.sqrt(n))}return e}function y(t,e){for(let s=0;s<t.rows;s++)for(let n=0;n<t.columns;n++)t.set(s,n,t.get(s,n)/e[s])}function w(t){const e=[];for(let s=0;s<t.columns;s++){let n=0;for(let e=0;e<t.rows;e++)n+=Math.pow(t.get(e,s),2)/(t.rows-1);e.push(Math.sqrt(n))}return e}function C(t,e){for(let s=0;s<t.rows;s++)for(let n=0;n<t.columns;n++)t.set(s,n,t.get(s,n)/e[n])}function T(t){const e=t.size-1;let s=0;for(let n=0;n<t.columns;n++)for(let i=0;i<t.rows;i++)s+=Math.pow(t.get(i,n),2)/e;return Math.sqrt(s)}function b(t,e){for(let s=0;s<t.rows;s++)for(let n=0;n<t.columns;n++)t.set(s,n,t.get(s,n)/e)}},3018:(t,e,s)=>{"use strict";s.d(e,{B4:()=>u,J5:()=>h,Um:()=>a,ZR:()=>l,bp:()=>o,cT:()=>d,g:()=>c,on:()=>r,zb:()=>i});var n=s(5776);function i(t,e,s){let n=s?t.rows:t.rows-1;if(e<0||e>n)throw new RangeError("Row index out of range")}function o(t,e,s){let n=s?t.columns:t.columns-1;if(e<0||e>n)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,n.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 c(t,e){if(!(0,n.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 h(t,e,s,n,i){if(5!==arguments.length)throw new RangeError("expected 4 arguments");if(m("startRow",e),m("endRow",s),m("startColumn",n),m("endColumn",i),e>s||n>i||e<0||e>=t.rows||s<0||s>=t.rows||n<0||n>=t.columns||i<0||i>=t.columns)throw new RangeError("Submatrix indices are out of range")}function u(t,e=0){let s=[];for(let n=0;n<t;n++)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:()=>i});var n=s(1174);class i extends n.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,n=0;n<e.length;n++)if(e[n].identifier===t){s=n;break}return s}function n(t,n){for(var o={},r=[],a=0;a<t.length;a++){var l=t[a],c=n.base?l[0]+n.base:l[0],h=o[c]||0,u="".concat(c," ").concat(h);o[c]=h+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 p=i(d,n);n.byIndex=a,e.splice(a,0,{identifier:u,updater:p,references:1})}r.push(u)}return r}function i(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,i){var o=n(t=t||[],i=i||{});return function(t){t=t||[];for(var r=0;r<o.length;r++){var a=s(o[r]);e[a].references--}for(var l=n(t,i),c=0;c<o.length;c++){var h=s(o[c]);0===e[h].references&&(e[h].updater(),e.splice(h,1))}o=l}}},569:t=>{"use strict";var e={};t.exports=function(t,s){var n=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(!n)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");n.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 n="";s.supports&&(n+="@supports (".concat(s.supports,") {")),s.media&&(n+="@media ".concat(s.media," {"));var i=void 0!==s.layer;i&&(n+="@layer".concat(s.layer.length>0?" ".concat(s.layer):""," {")),n+=s.css,i&&(n+="}"),s.media&&(n+="}"),s.supports&&(n+="}");var o=s.sourceMap;o&&"undefined"!=typeof btoa&&(n+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(o))))," */")),e.styleTagTransform(n,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:()=>h});var n=s(4469),i=s(976),o=s(6414),r=s.n(o),a=s(2991),l=s(499);const c=31;async function h(t,e=!1,s){const o=l.Cn.getOrCreate(t);let h;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())h=await n.functions.call("HELM:getMolFiles",{col:t}),h=function(t,e,s=!1){const n=new Array(t.length);for(let i=0;i<t.length;i++){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(i);o=l.indexOf("\n",o)+1,o=l.indexOf("\n",o)+1,o=l.indexOf("\n",o)+1;const h=parseInt(l.substring(o,o+3)),u=parseInt(l.substring(o+3,o+6));a+=`M V30 COUNTS ${h} ${u} 0 0 0\n`,a+="M V30 BEGIN ATOM\n";for(let t=0;t<h;t++){o=l.indexOf("\n",o)+1+c,r=l.indexOf(" ",o);const n=l.substring(o,r);a+=s?`M V30 ${t+1} R${e.get(n)} 0.000 0.000 0 0\n`:`M V30 ${t+1} At 0.000 0.000 0 0 MASS=${e.get(n)}\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",n[i]=a}return n}(h,s,e);else{h=new Array(t.length);for(let n=0;n<t.length;n++){const t=u(r()(o.splitted[n]).filter((t=>""!==t)).toArray(),s,e);h[n]=t}}return i.Column.fromStrings("monomericMols",h)}function u(t,e,s=!1){let n="\n Datagrok macromolecule handler\n\n 0 0 0 0 0 0 999 V3000\nM V30 BEGIN CTAB\n";n+=`M V30 COUNTS ${t.length} ${t.length?t.length-1:0} 0 0 0\n`,n+="M V30 BEGIN ATOM\n";for(let i=0;i<t.length;i++)n+=s?`M V30 ${i+1} R${e.get(t[i])} 0.000 0.000 0 0\n`:`M V30 ${i+1} At 0.000 0.000 0 0 MASS=${e.get(t[i])}\n`;n+="M V30 END ATOM\n",n+="M V30 BEGIN BOND\n";for(let e=0;e<t.length-1;e++)n+=`M V30 ${e+1} 1 ${e+1} ${e+2}\n`;return n+="M V30 END BOND\n",n+="M V30 END CTAB\n",n+="M END",n}},3377:(t,e,s)=>{"use strict";s.d(e,{_package:()=>pt});var n=s(976),i=s(1061);(0,i.W3)("_first",(()=>{(0,i.Bu)("_first",(async()=>{}))}));var o=s(2012),r=s(9976),a=s(6137);(0,i.W3)("Palettes",(()=>{(0,i.Bu)("testPaletteN",(async()=>{await async function(){const t=a.J.Chromatogram;(0,i.l_)(t instanceof r.B,!0),(0,i.l_)(t instanceof a.J,!0)}()})),(0,i.Bu)("testPaletteAA",(async()=>{await async function(){const t=o.f.Lesk,e=o.f.RasMol,s=o.f.GrokGroups;(0,i.l_)(t instanceof r.B,!0),(0,i.l_)(e instanceof r.B,!0),(0,i.l_)(s instanceof r.B,!0),(0,i.l_)(t instanceof o.f,!0),(0,i.l_)(e instanceof o.f,!0),(0,i.l_)(s instanceof o.f,!0)}()})),(0,i.Bu)("testPalettePtMe",(async()=>{const t=o.f.GrokGroups.get("MeNle"),e=o.f.GrokGroups.get("MeA"),s=o.f.GrokGroups.get("MeG"),n=o.f.GrokGroups.get("MeF"),r=o.f.GrokGroups.get("L"),a=o.f.GrokGroups.get("A"),l=o.f.GrokGroups.get("G"),c=o.f.GrokGroups.get("F");(0,i.l_)(t,r),(0,i.l_)(e,a),(0,i.l_)(s,l),(0,i.l_)(n,c)}))}));var l=s(4469),c=s(2991),h=s(8447),u=s(499);async function m(t){const e=n.Column.fromList(n.TYPE.STRING,"col1",t);if(await l.functions.call("Bio:detectMacromolecule",{col:e}),e.semType===n.SEMTYPE.MACROMOLECULE){const t=`Negative test detected semType='${e.semType}', units='${e.getTag(n.TAGS.UNITS)}'.`;throw new Error(t)}}async function d(t,e){const s=(await t()).getCol(e),i=await l.functions.call("Bio:detectMacromolecule",{col:s});if(i&&(s.semType=i),s.semType===n.SEMTYPE.MACROMOLECULE){const t=`Negative test detected semType='${s.semType}', units='${s.getTag(n.TAGS.UNITS)}'.`;throw new Error(t)}}async function p(t,e,s,o,r,a,c=null){const h=n.Column.fromList(n.TYPE.STRING,"seq",t),m=await l.functions.call("Bio:detectMacromolecule",{col:h});m&&(h.semType=m),(0,i.l_)(h.semType,n.SEMTYPE.MACROMOLECULE),(0,i.l_)(h.getTag(n.TAGS.UNITS),e),(0,i.l_)(h.getTag("aligned"),s),(0,i.l_)(h.getTag("alphabet"),o),c&&(0,i.l_)(h.getTag("separator"),c);const d=u.Cn.getOrCreate(h);(0,i.l_)(d.getAlphabetSize(),r),(0,i.l_)(d.getAlphabetIsMultichar(),a),d.isHelm()||((0,i.l_)(d.aligned,s),(0,i.l_)(d.alphabet,o))}async function g(t,e,s,o,r,a,c,h=null){const m=(await t()).col(e),d=await l.functions.call("Bio:detectMacromolecule",{col:m});d&&(m.semType=d),(0,i.l_)(m.semType,n.SEMTYPE.MACROMOLECULE),(0,i.l_)(m.getTag(n.TAGS.UNITS),s),(0,i.l_)(m.getTag("aligned"),o),(0,i.l_)(m.getTag("alphabet"),r),h&&(0,i.l_)(m.getTag("separator"),h);const p=u.Cn.getOrCreate(m);(0,i.l_)(p.getAlphabetSize(),a),(0,i.l_)(p.getAlphabetIsMultichar(),c),p.isHelm()||((0,i.l_)(p.aligned,o),(0,i.l_)(p.alphabet,r))}(0,i.W3)("detectors",(()=>{var t,e,s,o,r,a,c,u,w,C,T,b,A,S,E,M,v,N,I,L;const P=new(L=class{constructor(){this[t]="id,col1\n1,\n2,\n3,\n4,\n5,",this[e]="col1\n1\n2\n3",this[s]="col1\n4\n5\n6\n7",this[o]="col1\n8\n9\n10\n11\n12",this[r]="col1\nCCCCN1C(=O)CN=C(c2cc(F)ccc12)C3CCCCC3\nC1CCCCC1\nCCCCCC",this[a]="seq\nACGTCACGTC\nCAGTGTCAGTGT\nTTCAACTTCAAC",this[c]="seq\nACGUCACGUC\nCAGUGUCAGUGU\nUUCAACUUCAAC",this[u]="seq\nFWPHEY\nYNRQWYV\nMKPSEYV",this[w]="seq\n[meI][hHis][Aca]NT[dE][Thr_PO3H2][Aca]DN\n[meI][hHis][Aca][Cys_SEt]T[dK][Thr_PO3H2][Aca][Tyr_PO3H2][Aca]\n[Lys_Boc][hHis][Aca][Cys_SEt]T[dK][Thr_PO3H2][Aca][Tyr_PO3H2][Aca]",this[C]="seq\nA*C*G*T*C*A*C*G*T*C\nC*A*G*T*G*T*C*A*G*T*G*T\nT*T*C*A*A*C*T*T*C*A*A*C",this[T]="seq\nA*C*G*U*C*A*C*G*U*C\nC*A*G*U*G*U*C*A*G*U*G*U\nU*U*C*A*A*C*U*U*C*A*A*C",this[b]="seq\nF-W-P-H-E-Y-F-W-P-H-E-Y\nY-N-R-Q-W-Y-V-Y-N-R-Q-W-Y-V\nM-K-P-S-E-Y-V-M-K-P-S-E-Y-V",this[A]="seq\nabc-dfgg-abc1-cfr3-rty-wert-cfr3-rty-wert\nrut12-her2-rty-wert-abc-abc1-dfgg-abc-abc1-dfgg\nrut12-rty-her2-abc-cfr3-wert-rut12-cfr3-wert-rut12",this[S]="seq\nabc/dfgg/abc1/cfr3/rty/wert/abc/dfgg/abc1/cfr3/rty/wert\nrut12/her2/rty/wert//abc/abc1/dfgg/rut12/her2/rty/wert//abc/abc1/dfgg\nrut12/rty/her2/abc/cfr3//wert/rut12/rut12/rty/her2/abc/cfr3//wert/rut12",this[E]="seq\nA-C--G-T--C-T-A-C--G-T--C-T\nC-A-C--T--G-T-C-A-C--T--G-T\nA-C-C-G-T-A-C-T-A-C-C-G-T-A-C-T",this[M]="seq\nm1-M-m3-mon4-mon5-N-T-MON8-N9-m1-M-m3-mon4-mon5-N-T-MON8-N9\nm1-mon2-m3-mon4-mon5-Num--MON8-N9-m1-mon2-m3-mon4-mon5-Num--MON8-N9\n\nmon1-M-mon3-mon4-mon5---MON8-N9-mon1-M-mon3-mon4-mon5---MON8-N9",this[v]="seq\nAc(1)-F-K(AEEA-AEEA-R-Ac)-L-mF-V-Y-mNle-D-W-N-mF-C(1)-G-NH2\nAc(1)-F-K(AEEA-ARRA-W-Ac)-L-mF-V-Y-mNle-D-W-N-mF-C(1)-G-NH2\nAc(1)-F-K(AEEA-AEEA-Ac)-L-mF-V-Y-mNle-D-W-N-mF-C(1)-G-NH2",this[N]="seq\nAC-GT-CTAC-GT-CT\nCAC-T-GTCAC-T-GT\nACCGTACTACCGTACT",this[I]="seq\nFWR-WYV-KHPFWR-WYV-KHP\nYNR-WYV-KHPYNR-WYV-KHP\nMWRSWY-CKHPMWRSWY-CKHP"}},t="negEmpty",e="neg1",s="neg2",o="neg3",r="negSmiles",a="csvFastaDna1",c="fastaRna1",u="fastaPt1",w="fastaUn",C="sepDna",T="sepRna",b="sepPt",A="sepUn1",S="sepUn2",E="sepMsaDna1",M="sepMsaUnWEmpty",v="sepComplex",N="fastaMsaDna1",I="fastaMsaPt1",L),_={fastaFasta:"System:AppData/Bio/data/sample_FASTA.fasta",fastaPtCsv:"System:AppData/Bio/data/sample_FASTA_PT.csv",msaComplex:"System:AppData/Bio/samples/MSA.csv",fastaCsv:"System:AppData/Bio/samples/FASTA.csv",helmCsv:"System:AppData/Bio/samples/HELM.csv",peptidesComplex:"System:AppData/Bio/tests/peptides_complex_msa.csv",peptidesSimple:"System:AppData/Bio/tests/peptides_simple_msa.csv",testDemogCsv:"System:AppData/Bio/tests/testDemog.csv",testHelmCsv:"System:AppData/Bio/tests/testHelm.csv",testIdCsv:"System:AppData/Bio/tests/testId.csv",testSmilesCsv:"System:AppData/Bio/tests/testSmiles.csv",testSmiles2Csv:"System:AppData/Bio/tests/testSmiles2.csv",testSmilesShort:"System:AppData/Bio/tests/testSmilesShort.csv",testActivityCliffsCsv:"System:AppData/Bio/tests/testActivityCliffs.csv",testCerealCsv:"System:AppData/Bio/tests/testCereal.csv",testUnichemSources:"System:AppData/Bio/tests/testUnichemSources.csv",testDmvOffices:"System:AppData/Bio/tests/testDmvOffices.csv",testAlertCollection:"System:AppData/Bio/tests/testAlertCollection.csv",testSpgi100:"System:AppData/Bio/tests/testSpgi100.csv",testSpgi:"System:AppData/Bio/tests/SPGI-derived.csv",testUrl:"System:AppData/Bio/tests/testUrl.csv"},R={};function x(t,e=O){return async()=>(t in R||(R[t]=(async()=>await e(_[t]))().catch((e=>{throw delete R[t],e}))),R[t])}async function O(t){const e=await l.dapi.files.readAsText(t);return n.DataFrame.fromCsv(e)}const G=t=>async()=>{const e=P[t],s=n.DataFrame.fromCsv(e);return await l.data.detectSemanticTypes(s),s};(0,i.Bu)("NegativeEmpty",(async()=>{await d(G("negEmpty"),"col1")})),(0,i.Bu)("Negative1",(async()=>{await d(G("neg1"),"col1")})),(0,i.Bu)("Negative2",(async()=>{await d(G("neg2"),"col1")})),(0,i.Bu)("Negative3",(async()=>{await d(G("neg3"),"col1")})),(0,i.Bu)("NegativeSmiles",(async()=>{await d(G("negSmiles"),"col1")})),(0,i.Bu)("NegativeStartEnd",(async()=>{await m(["START","END"])})),(0,i.Bu)("NegativeStartEndIntermediate",(async()=>{await m(["START","END","INTERMEDIATE"])})),(0,i.Bu)("FastaDna1",(async()=>{await g(G("csvFastaDna1"),"seq",h.r2.FASTA,"SEQ","DNA",4,!1)})),(0,i.Bu)("FastaRna1",(async()=>{await g(G("fastaRna1"),"seq",h.r2.FASTA,"SEQ","RNA",4,!1)})),(0,i.Bu)("FastaPt1",(async()=>{await g(G("fastaPt1"),"seq",h.r2.FASTA,"SEQ","PT",20,!1)})),(0,i.Bu)("FastaPtGaps",(()=>p(["FW-PH-EYY","FYNRQWYV-","FKP-Q-SEYV"],h.r2.FASTA,"SEQ","PT",20,!1))),(0,i.Bu)("FastaPtGapsMsa",(()=>p(["FW-PH-EYY","FYNRQWYV-","FKP-Q-SEY"],h.r2.FASTA,"SEQ.MSA","PT",20,!1))),(0,i.Bu)("FastaUn",(async()=>{await g(G("fastaUn"),"seq",h.r2.FASTA,"SEQ.MSA","UN",12,!0)})),(0,i.Bu)("FastaMsaDna1",(async()=>{await g(G("fastaMsaDna1"),"seq",h.r2.FASTA,"SEQ.MSA","DNA",4,!1)})),(0,i.Bu)("FastaMsaPt1",(async()=>{await g(G("fastaMsaPt1"),"seq",h.r2.FASTA,"SEQ.MSA","PT",20,!1)})),(0,i.Bu)("SepDna",(async()=>{await g(G("sepDna"),"seq",h.r2.SEPARATOR,"SEQ","DNA",4,!1,"*")})),(0,i.Bu)("SepRna",(async()=>{await g(G("sepRna"),"seq",h.r2.SEPARATOR,"SEQ","RNA",4,!1,"*")})),(0,i.Bu)("SepPt",(async()=>{await g(G("sepPt"),"seq",h.r2.SEPARATOR,"SEQ","PT",20,!1,"-")})),(0,i.Bu)("SepUn1",(async()=>{await g(G("sepUn1"),"seq",h.r2.SEPARATOR,"SEQ","UN",8,!0,"-")})),(0,i.Bu)("SepUn2",(async()=>{await g(G("sepUn2"),"seq",h.r2.SEPARATOR,"SEQ","UN",9,!0,"/")})),(0,i.Bu)("SepMsaN1",(async()=>{await g(G("sepMsaDna1"),"seq",h.r2.SEPARATOR,"SEQ.MSA","DNA",4,!1,"-")})),(0,i.Bu)("SepMsaUnWEmpty",(async()=>{await g(G("sepMsaUnWEmpty"),"seq",h.r2.SEPARATOR,"SEQ.MSA","UN",14,!0)})),(0,i.Bu)("SepComplex",(async()=>{await g(G("sepComplex"),"seq",h.r2.SEPARATOR,"SEQ","UN",18,!0)})),(0,i.Bu)("samplesFastaCsv",(async()=>{await y(x("fastaCsv"),{Sequence:new f(h.r2.FASTA,"SEQ","PT",20,!1)})})),(0,i.Bu)("samplesFastaFasta",(async()=>{await y(x("fastaFasta"),{sequence:new f(h.r2.FASTA,"SEQ","PT",20,!1)})})),(0,i.Bu)("samplesPeptidesComplex",(async()=>{await y(x("peptidesComplex"),{})})),(0,i.Bu)("samplesMsaComplex",(async()=>{await y(x("msaComplex"),{MSA:new f(h.r2.SEPARATOR,"SEQ.MSA","UN",161,!0,"/")})})),(0,i.Bu)("samplesIdCsv",(async()=>{await y(x("testIdCsv"),{})})),(0,i.Bu)("samplesSarSmallCsv",(async()=>{await y(x("testSmilesCsv"),{})})),(0,i.Bu)("samplesHelmCsv",(async()=>{await y(x("helmCsv"),{HELM:new f(h.r2.HELM,null,null,160,!0)})})),(0,i.Bu)("samplesTestHelmCsv",(async()=>{await y(x("testHelmCsv"),{"HELM string":new f(h.r2.HELM,null,null,9,!0)})})),(0,i.Bu)("samplesTestDemogCsv",(async()=>{await y(x("testDemogCsv"),{})})),(0,i.Bu)("samplesTestSmiles2Csv",(async()=>{await y(x("testSmiles2Csv"),{})})),(0,i.Bu)("samplesTestSmilesShort",(async()=>{await y(x("testSmilesShort"),{})})),(0,i.Bu)("samplesTestActivityCliffsNegativeSmiles",(async()=>{await y(x("testActivityCliffsCsv"),{})})),(0,i.Bu)("samplesFastaPtCsv",(async()=>{await y(x("fastaPtCsv"),{sequence:new f(h.r2.FASTA,"SEQ","PT",20,!1)})})),(0,i.Bu)("samplesTestCerealCsv",(async()=>{await y(x("testCerealCsv"),{})})),(0,i.Bu)("samplesTestUnichemSources",(async()=>{await y(x("testUnichemSources"),{})})),(0,i.Bu)("samplesTestDmvOffices",(async()=>{await y(x("testDmvOffices"),{})})),(0,i.Bu)("samplesTestAlertCollection",(async()=>{await y(x("testAlertCollection"),{})})),(0,i.Bu)("samplesTestSpgi",(async()=>{await y(x("testSpgi"),{})})),(0,i.Bu)("samplesTestSpgi100",(async()=>{await y(x("testSpgi100"),{})})),(0,i.Bu)("samplesTestUrl",(async()=>{await y(x("testUrl"),{})}))}));class f{constructor(t,e,s,n,i,o){this.units=t,this.aligned=e,this.alphabet=s,this.alphabetSize=n,this.alphabetIsMultichar=i,this.separator=o}}async function y(t,e){const s=await t(),n=[];for(const i of s.columns.names())if(i in e){const s=e[i];try{await g(t,i,s.units,s.aligned,s.alphabet,s.alphabetSize,s.alphabetIsMultichar,s.separator)}catch(t){const e=t.toString();n.push(`Positive col '${i}' failed: ${e}`)}}else try{await d(t,i)}catch(t){const e=t.toString();n.push(`Negative col '${i}' failed: ${e}`)}if(n.length>0)throw new Error(n.join("\n"))}(0,i.W3)("detectors:weak-and-likely",(()=>{const t={fastaDnaWeak1:"id,colName\n1,TTTTTTTTTT\n2,TTTTTTTTTT\n3,TTTTTTTTTT\n4,TTTTTTTTTT",fastaDnaWeak1LikelyName:"id,seq\n1,TTTTTTT\n2,TTTTTTT\n3,TTTTTTT\n4,TTTTTTT",fastaRnaWeak1:"id,colName\n1,UUUUUUUUUU\n2,UUUUUUUUUU\n3,UUUUUUUUUU\n4,UUUUUUUUUU",fastaRnaWeak1LikelyName:"id,seq\n1,UUUUUUU\n2,UUUUUUU\n3,UUUUUUU\n4,UUUUUUU",fastaPtWeak1:"id,colName\n1,SLSLSPGKSLSLSPGK\n2,SLSLSPGKSLSLSPGK\n3,SLSLSPGKSLSLSPGK\n4,SLSLSPGKSLSLSPGK",fastaPtWeak1LikelyName:"id,seq\n1,SLSLSPGKSLSLSPGK\n2,SLSLSPGKSLSLSPGK\n3,SLSLSPGKSLSLSPGK\n4,SLSLSPGKSLSLSPGK",fastaUn1:"id,colName\n1,word\n2,other\n3,some\n4,another",fastaUn1LikelyName:"id,seq\n1,word\n2,other\n3,some\n4,another",fastaUn2LikelyName:'protein\nBoombastic\nMegafantastic\n"just-a-random-thought,oy!"',fastaUnMsa1LikelyName:"id,seq\n1,word\n2,male\n3,bare\n4,core"},e=e=>async()=>{const s=t[e],i=n.DataFrame.fromCsv(s);return await l.data.detectSemanticTypes(i),i};(0,i.Bu)("fastaDnaWeak1",(async()=>{await d(e("fastaDnaWeak1"),"colName")})),(0,i.Bu)("fastaDnaWeak1LikelyName",(async()=>{await g(e("fastaDnaWeak1LikelyName"),"seq",h.r2.FASTA,"SEQ.MSA","DNA",4,!1)})),(0,i.Bu)("fastaRnaWeak1",(async()=>{await d(e("fastaRnaWeak1"),"colName")})),(0,i.Bu)("fastaRnaWeak1LikelyName",(async()=>{await g(e("fastaRnaWeak1LikelyName"),"seq",h.r2.FASTA,"SEQ.MSA","RNA",4,!1)})),(0,i.Bu)("fastaPtWeak1",(async()=>{await d(e("fastaPtWeak1"),"colName")})),(0,i.Bu)("fastaPtWeak1LikelyName",(async()=>{await g(e("fastaPtWeak1LikelyName"),"seq",h.r2.FASTA,"SEQ.MSA","PT",20,!1)})),(0,i.Bu)("fastaUn1",(async()=>{await d(e("fastaUn1"),"colName")})),(0,i.Bu)("fastaUn1LikelyName",(async()=>{await d(e("fastaUn1LikelyName"),"seq")})),(0,i.Bu)("fastaUn2LikelyName",(async()=>{await d(e("fastaUn2LikelyName"),"protein")})),(0,i.Bu)("fastaUnMsa1LikelyName",(async()=>{await d(e("fastaUnMsa1LikelyName"),"seq")}))})),(0,i.W3)("detectorsBenchmark",(()=>{let t;async function e(e,o,r,a,l,c){return await async function(e,i,u,m){const d=(()=>{const e=function(t,e,s,i,o){let r;switch(t){case h.r2.FASTA:r=t=>{let e="";for(let s=0;s<t.length;s++){const n=t[s];e+=1==n.length?n:`[${n}]`}return e};break;case h.r2.SEPARATOR:r=(t,e)=>t.join(e);break;default:throw new Error(`Not supported notation '${t}'.`)}const a=(t,e)=>{const s=new Array(e);for(let n=0;n<e;n++)s[n]=t[Math.floor(Math.random()*t.length)];return r(s,o)},l=Array(i);for(let t=0;t<i;t++)l[t]=a(e,s);return n.Column.fromStrings("seq",l)}(o,[...(0,h.gM)(r)],a,l,c),i=t.prepare({col:e});return s(i),i})(),p=Date.now(),g=await(async t=>s(t))(d),f=Date.now();m(g);const y=f-p;if(y>e){const t=`ET ${y} ms is more than max allowed ${e} ms.`;throw console.error(t),new Error(t)}return console.log(`ET ${y} ms is OK.`),y}(e,0,0,(t=>{!function(t,e){const s=u.Cn.getOrCreate(t);(0,i.l_)(t.semType===e.semType,!0),(0,i.l_)(s.notation===e.notation,!0),(0,i.l_)(s.alphabet===e.alphabet,!0),(0,i.l_)(s.separator===e.separator,!0)}(t,{semType:n.SEMTYPE.MACROMOLECULE,notation:o,alphabet:r,separator:c})}))}function s(t){t.callSync();const e=t.getOutputParamValue(),s=t.inputs.col;return e&&(s.semType=e),s}(0,i.bb)((async()=>{const e=n.Func.find({package:"Bio",name:"detectMacromolecule"});t=e[0];const s=n.Column.fromStrings("seq",["ACGT","ACGT","ACGT"]);await t.prepare({col:s}).call()})),(0,i.Bu)("fastaDnaShorts50Few50",(async()=>{await e(10,h.r2.FASTA,"DNA",50,50)})),(0,i.Bu)("fastaDnaShorts50Many1E6",(async()=>{await e(20,h.r2.FASTA,"DNA",50,1e6)})),(0,i.Bu)("fastaDnaLong1e6Few50",(async()=>{await e(20,h.r2.FASTA,"DNA",1e6,50)})),(0,i.Bu)("separatorDnaShorts50Few50",(async()=>{await e(10,h.r2.SEPARATOR,"DNA",50,50,"/")})),(0,i.Bu)("separatorDnaShorts50Many1E6",(async()=>{await e(20,h.r2.SEPARATOR,"DNA",50,1e6,"/")})),(0,i.Bu)("separatorDnaLong1e6Few50",(async()=>{await e(20,h.r2.SEPARATOR,"DNA",1e6,50,"/")}))}));var w=s(6098),C=s(525);async function T(t){const e=await async function(t){return await pt.files.readAsText(t)}(t),s=n.DataFrame.fromCsv(e);return s.name=t.replace(".csv",""),s}async function b(t){const e=await T(t);return e.name=t.replace(".csv",""),l.shell.addTableView(e)}async function A(t=1e4){const e=await l.dapi.docker.dockerContainers.filter("bio").first();"started"!==e.status&&"checking"!==e.status&&await(0,i.gw)(t)}async function S(t,e){const s=n.DataFrame.fromCsv(t),o=n.DataFrame.fromCsv(e),r=s.getCol("seq"),a=await l.functions.call("Bio:detectMacromolecule",{col:r});a&&(r.semType=a);const c=o.getCol("seq"),h=await(0,w.U)(r,!0);(0,i.f6)(h.toList(),c.toList())}async function E(t,e,s,o,r,a){const c=n.DataFrame.fromCsv(t),h=n.DataFrame.fromCsv(e),u=c.getCol("seq"),m=h.getCol("seq"),d=c.getCol("seq"),p=await l.functions.call("Bio:detectMacromolecule",{col:d});p&&(d.semType=p),await l.data.detectSemanticTypes(c),(0,i.l_)(u.semType,n.SEMTYPE.MACROMOLECULE),(0,i.l_)(u.getTag(n.TAGS.UNITS),s),r&&(0,i.l_)(u.getTag("alphabet"),r);const g=await(0,C.K)({col:u,pepsea:{method:a}});(0,i.l_)(g.semType,n.SEMTYPE.MACROMOLECULE),(0,i.l_)(g.getTag(n.TAGS.UNITS),o),(0,i.l_)(g.getTag("aligned"),"SEQ.MSA"),r&&(0,i.l_)(g.getTag("alphabet"),r),(0,i.f6)(g.toList(),m.toList())}(0,i.W3)("MSA",(async()=>{(0,i.Bu)("isCorrect",(async()=>{await S("seq\nFWRWYVKHP\nYNRWYVKHP\nMWRSWYCKHP","seq\nFWR-WYVKHP\nYNR-WYVKHP\nMWRSWYCKHP")})),(0,i.Bu)("isCorrectLong",(async()=>{await S("seq\nFWRWYVKHPFWRWYVKHPFWRWYVKHPFWRWYVKHPFWRWYVKHPFWRWYVKHPFWRWYVKHPFWRWYVKHP\nYNRWYVKHPYNRWYVKHPYNRWYVKHPYNRWYVKHPYNRWYVKHPYNRWYVKHPYNRWYVKHPYNRWYVKHP\nMWRSWYCKHPMWRSWYCKHPMWRSWYCKHPMWRSWYCKHPMWRSWYCKHPMWRSWYCKHPMWRSWYCKHPMWRSWYCKHP","seq\nFWR-WYVKHPFWR-WYVKHPFWR-WYVKHPFWR-WYVKHPFWR-WYVKHPFWR-WYVKHPFWR-WYVKHPFWR-WYVKHP\nYNR-WYVKHPYNR-WYVKHPYNR-WYVKHPYNR-WYVKHPYNR-WYVKHPYNR-WYVKHPYNR-WYVKHPYNR-WYVKHP\nMWRSWYCKHPMWRSWYCKHPMWRSWYCKHPMWRSWYCKHPMWRSWYCKHPMWRSWYCKHPMWRSWYCKHPMWRSWYCKHP")})),(0,i.Bu)("isCorrectHelm",(async()=>{await A(),await E("seq\n PEPTIDE1{meI.hHis.Aca.N.T.dE.Thr_PO3H2}$$$$\n PEPTIDE1{meI.Aca.N.T.dE.Thr_PO3H2}$$$$\n PEPTIDE1{hHis.Aca.N.T.dE.Thr_PO3H2}$$$$","seq\n meI.hHis.Aca.N.T.dE.Thr_PO3H2\n .meI.Aca.N.T.dE.Thr_PO3H2\n .hHis.Aca.N.T.dE.Thr_PO3H2",h.r2.HELM,h.r2.SEPARATOR,void 0,"mafft")}),{skipReason:"GROK-13221"}),(0,i.Bu)("isCorrectHelmLong",(async()=>{await A(),await E("seq\n PEPTIDE1{meI.hHis.Aca.N.T.dE.Thr_PO3H2.Aca.D-Tyr_Et.dV.E.N.D-Orn.D-aThr.Phe_4Me.Thr_PO3H2}$$$$\n PEPTIDE1{meI.hHis.Aca.Cys_SEt.T.dK.Tyr_PO3H2.D-Chg.dV.Phe_ab-dehydro.N.D-Orn.D-aThr.Phe_4Me}$$$$\n PEPTIDE1{Lys_Boc.hHis.Aca.Cys_SEt.T.dK.Tyr_PO3H2.D-Chg.dV.Thr_PO3H2.N.D-Orn.D-aThr.Phe_4Me}$$$$","seq\n meI.hHis.Aca.N.T.dE.Thr_PO3H2.Aca.D-Tyr_Et.dV.E.N.D-Orn.D-aThr.Phe_4Me.Thr_PO3H2\n meI.hHis.Aca.Cys_SEt.T.dK..Tyr_PO3H2.D-Chg.dV.Phe_ab-dehydro.N.D-Orn.D-aThr.Phe_4Me.\n Lys_Boc.hHis.Aca.Cys_SEt.T.dK..Tyr_PO3H2.D-Chg.dV.Thr_PO3H2.N.D-Orn.D-aThr.Phe_4Me.",h.r2.HELM,h.r2.SEPARATOR,void 0,"mafft")}),{skipReason:"GROK-13221"}),(0,i.Bu)("isCorrectSeparator",(async()=>{await E("seq\n F-W-P-H-E-Y\n Y-N-R-Q-W-Y-V\n M-K-P-S-E-Y-V","seq\n FWPHEY-\n YNRQWYV\n MKPSEYV",h.r2.SEPARATOR,h.r2.FASTA,"PT")})),(0,i.Bu)("isCorrectSeparatorLong",(async()=>{await E("seq\n M-I-E-V-F-L-F-G-I-V-L-G-L-I-P-I-T-L-A-G-L-F-V-T-A-Y-L-Q-Y-R-R-G-D-Q-L-D-L\n M-M-E-L-V-L-K-T-I-I-G-P-I-V-V-G-V-V-L-R-I-V-D-K-W-L-N-K-D-K\n M-D-R-T-D-E-V-S-N-H-T-H-D-K-P-T-L-T-W-F-E-E-I-F-E-E-Y-H-S-P-F-H-N","seq\n MIEV-FLFGIVLGLIPITLAGLFVTAYLQYRRGDQLDL\n MMEL-VLKTII-GPIVVGVVLRIVDKWLNKDK------\n MDRTDEVSNHTHDKPTLTWFEEIFEEYHSPFHN-----",h.r2.SEPARATOR,h.r2.FASTA,"PT")}))}));var M=s(3553),v=s(9416);async function N(t,e){const s=(0,h.kB)(t);console.debug(`Bio: tests: splitters: src=${JSON.stringify(t)}, res=${JSON.stringify(s)} .`),(0,i.f6)(s,e)}async function I(t,e){const s=(0,h.gP)(t);console.debug(`Bio: tests: splitters: src=${JSON.stringify(t)}, res=${JSON.stringify(s)} .`),(0,i.f6)(s,e)}(0,i.W3)("splitters",(async()=>{(0,i.bb)((async()=>{})),(0,i.X5)((async()=>{}));const t=["M[MeI]YKETLL[MeF]PKTDFPMRGGL[MeA]",["M","MeI","Y","K","E","T","L","L","MeF","P","K","T","D","F","P","M","R","G","G","L","MeA"]],e=["[meI][Pip][dK][Thr_PO3H2][L-hArg(Et,Et)][D-Tyr_Et][Tyr_ab-dehydroMe][dV]EN[D-Orn][D-aThr][Phe_4Me]",["meI","Pip","dK","Thr_PO3H2","L-hArg(Et,Et)","D-Tyr_Et","Tyr_ab-dehydroMe","dV","E","N","D-Orn","D-aThr","Phe_4Me"]],s=["PEPTIDE1{meI.hHis.Aca.N.T.dE.Thr_PO3H2.Aca.D-Tyr_Et.Tyr_ab-dehydroMe.dV.E.N.D-Orn.D-aThr.Phe_4Me}$$$",["meI","hHis","Aca","N","T","dE","Thr_PO3H2","Aca","D-Tyr_Et","Tyr_ab-dehydroMe","dV","E","N","D-Orn","D-aThr","Phe_4Me"]],o=["PEPTIDE1{meI.hHis.Aca.N.T.dK.Thr_PO3H2.Aca.D-Tyr_Et.D-Dap.dV.E.N.pnG.Phe_4Me}$$$",["meI","hHis","Aca","N","T","dK","Thr_PO3H2","Aca","D-Tyr_Et","D-Dap","dV","E","N","pnG","Phe_4Me"]],r=["PEPTIDE1{[meI].[hHis].[Aca].N.T.[dK].[Thr_PO3H2].[Aca].[D-Tyr_Et].[D-Dap].[dV].E.N.[pnG].[Phe_4Me]}$$$",["meI","hHis","Aca","N","T","dK","Thr_PO3H2","Aca","D-Tyr_Et","D-Dap","dV","E","N","pnG","Phe_4Me"]],a=["RNA1{R(U)P.R(T)P.R(G)P.R(C)P.R(A)}$$$$",["R(U)P","R(T)P","R(G)P","R(C)P","R(A)"]],h=["RNA1{P.R(U)P.R(T)}$$$$",["P","R(U)P","R(T)"]],u=["RNA1{P.R(U).P.R(T)}$$$$",["P","R(U)","P","R(T)"]];(0,i.Bu)("fastaMulti",(async()=>{await N(t[0],t[1])})),(0,i.Bu)("fastaFromHelm",(async()=>{await N(e[0],e[1])})),(0,i.Bu)("helm1",(async()=>{await I(s[0],s[1])})),(0,i.Bu)("helm2",(async()=>{await I(o[0],o[1])})),(0,i.Bu)("helm3-multichar",(async()=>{await I(r[0],r[1])})),(0,i.Bu)("testHelm1",(async()=>{await I(a[0],a[1])})),(0,i.Bu)("testHelm2",(async()=>{await I(h[0],h[1])})),(0,i.Bu)("testHelm3",(async()=>{await I(u[0],u[1])})),(0,i.Bu)("splitToMonomers",(async()=>{const t=await l.dapi.files.readCsv("System:AppData/Bio/samples/MSA.csv"),e=t.getCol("MSA"),s=await l.functions.call("Bio:detectMacromolecule",{col:e});s&&(e.semType=s),e.setTag("aligned",M.mU);const n=await(0,v.n)(t,e);(0,i.l_)(n.columns.names().includes("17"),!0),await l.data.detectSemanticTypes(n);const o=l.shell.addTableView(n);await(0,i.ow)((()=>o.grid.dataFrame!=t),"View grid has wrong data frame",100)})),(0,i.Bu)("getHelmMonomers",(async()=>{const t=n.DataFrame.fromCsv("HELM,Activity\nPEPTIDE1{hHis.N.T}$$$,5.30751\nPEPTIDE1{hHis.Aca.Cys_SEt}$$$,5.72388\n");await l.data.detectSemanticTypes(t);const e=["hHis","Aca","Cys_SEt","N","T"],s=t.getCol("HELM"),i=(0,c.getHelmMonomers)(s),o=e.filter((t=>!i.includes(t))),r=i.filter((t=>!e.includes(t)));if(o.length>0||r.length){const t=[];throw o.length>0&&t.push(`Missed monomers ${JSON.stringify(o)}.`),r.length>0&&t.push(`Unexpected monomers ${JSON.stringify(r)}.`),new Error(t.join(" "))}}))}));var L=s(7228),P=s(6584),_=s(2918);(0,i.W3)("monomerLibraries",(()=>{let t,e=null;(0,i.bb)((async()=>{t=await(0,L.JN)(),e=(0,P.nW)()})),(0,i.X5)((async()=>{await(0,P.tW)(e)})),(0,i.Bu)("default",(async()=>{await(0,P.tW)({exclude:[],explicit:[]}),await t.loadLibraries(!0);const e=t.getBioLib();(0,i.l_)(e.getPolymerTypes().length>0,!0)})),(0,i.Bu)("forTests",(async()=>{await(0,P.tb)(),await t.loadLibraries(!0);const e=t.getBioLib();(0,i.l_)(e.getPolymerTypes().length,2),(0,i.l_)(e.getMonomerSymbolsByType("PEPTIDE").length,322),(0,i.l_)(e.getMonomerSymbolsByType("RNA").length,383)})),(0,i.Bu)("empty",(async()=>{const e=await(0,P.nW)(),s=await(0,_.P4)();e.exclude=s,e.explicit=[],await(0,P.tW)(e),await t.loadLibraries(!0);const n=t.getBioLib();(0,i.l_)(0===n.getPolymerTypes().length,!0),n.getMonomerMolsByPolymerType("PEPTIDE")}))}));var R=s(4004);function x(){const t=[];return t.push(n.Column.fromList("string","MSA",new Array(10**6).fill("meI/hHis/Aca/N/T/dE/Thr_PO3H2/Aca/D-Tyr_Et/Tyr_ab-dehydroMe/dV/E/N/D-Orn/D-aThr//Phe_4Me"))),t.push(n.Column.fromList("string","Activity",new Array(10**6).fill("5.30751"))),t}function O(){const t=[],e="meI/hHis/Aca/N/T/dE/Thr_PO3H2/Aca/D-Tyr_Et/Tyr_ab-dehydroMe/dV/E/N/D-Orn/D-aThr".repeat(10**5);return t.push(n.Column.fromList("string","MSA",new Array(100).fill(e))),t.push(n.Column.fromList("string","Activity",new Array(100).fill("7.30751"))),t}async function G(t,e){const s=t(),o=n.DataFrame.fromColumns(s);await l.data.detectSemanticTypes(o);const r=Date.now(),a=(o.columns.byName("MSA"),l.shell.addTableView(o));await(0,i.ow)((()=>a.grid.dataFrame!==o),"View grid has wrong data frame ",100);const c=Date.now()-r;console.log(`Performance test: ${e}: ${c}ms`)}(0,i.W3)("renderers",(()=>{(0,i.Bu)("long sequence performance ",(async()=>{await G(O,"Long sequences")})),(0,i.Bu)("many sequence performance",(async()=>{await G(x,"Many sequences")})),(0,i.Bu)("many sequence performance",(async()=>{await G(x,"Many sequences")})),(0,i.Bu)("rendererMacromoleculeFasta",(async()=>{await async function(){const t=await l.dapi.files.readAsText("System:AppData/Bio/samples/FASTA.csv"),e=n.DataFrame.fromCsv(t),s=e.getCol("Sequence"),o=await l.functions.call("Bio:detectMacromolecule",{col:s});o&&(s.semType=o);const r=l.shell.addTableView(e);await l.data.detectSemanticTypes(e),await(0,i.ow)((()=>r.grid.dataFrame!=e),"View grid has wrong data frame",100);const a=s.getTag(n.TAGS.CELL_RENDERER);(0,i.l_)(a,"sequence")}()})),(0,i.Bu)("rendererMacromoleculeSeparator",(async()=>{await async function(){const t=await l.dapi.files.readAsText("System:AppData/Bio/data/sample_SEPARATOR_PT.csv"),e=n.DataFrame.fromCsv(t),s=e.getCol("sequence"),o=await l.functions.call("Bio:detectMacromolecule",{col:s});o&&(s.semType=o);const r=l.shell.addTableView(e);await l.data.detectSemanticTypes(e),await(0,i.ow)((()=>r.grid.dataFrame!=e),"View grid has wrong data frame",100);const a=s.getTag(n.TAGS.CELL_RENDERER);(0,i.l_)(a,"sequence")}()})),(0,i.Bu)("rendererMacromoleculeDifference",(async()=>{await async function(){const t=n.Column.fromStrings("SequencesDiff",["meI/hHis/Aca/N/T/dK/Thr_PO3H2/Aca#D-Tyr_Et/Tyr_ab-dehydroMe/meN/E/N/dV"]);t.setTag(n.TAGS.UNITS,h.r2.SEPARATOR),t.setTag("separator","/"),t.setTag("aligned","SEQ"),t.setTag("alphabet","UN"),t.setTag(".alphabetIsMultichar","true"),t.semType=M.Of.MACROMOLECULE_DIFFERENCE;const e=n.DataFrame.fromColumns([t]),s=l.shell.addTableView(e);await l.data.detectSemanticTypes(e),await(0,i.ow)((()=>s.grid.dataFrame!=e),"View grid has wrong data frame",100);const o=t.getTag(n.TAGS.CELL_RENDERER);(0,i.l_)(o,M.Of.MACROMOLECULE_DIFFERENCE)}()})),(0,i.Bu)("afterMsa",(async()=>{await async function(){const t=await l.dapi.files.readAsText("System:AppData/Bio/data/sample_FASTA.fasta"),e=(0,c.importFasta)(t)[0],s=e.getCol("sequence"),o=await l.functions.call("Bio:detectMacromolecule",{col:s});o&&(s.semType=o);const r=l.shell.addTableView(e);await l.data.detectSemanticTypes(e),console.log("Bio: tests/renderers/afterMsa, table view"),await(0,i.ow)((()=>r.grid.dataFrame!=e),"View grid has wrong data frame",100),console.log(`Bio: tests/renderers/afterMsa, src before test semType="${s.semType}", units="${s.getTag(n.TAGS.UNITS)}", cell.renderer="${s.getTag(n.TAGS.CELL_RENDERER)}"`),(0,i.l_)(s.semType,n.SEMTYPE.MACROMOLECULE),(0,i.l_)(s.getTag(n.TAGS.UNITS),h.r2.FASTA),(0,i.l_)(s.getTag("aligned"),"SEQ"),(0,i.l_)(s.getTag("alphabet"),"PT"),(0,i.l_)(s.getTag(n.TAGS.CELL_RENDERER),"sequence");const a=await(0,C.K)({col:s});r.grid.invalidate(),await(0,i.ow)((()=>r.grid.dataFrame!=e),"View grid has wrong data frame",100),(0,i.l_)(a.semType,n.SEMTYPE.MACROMOLECULE),(0,i.l_)(a.getTag(n.TAGS.UNITS),h.r2.FASTA),(0,i.l_)(a.getTag("aligned"),"SEQ.MSA"),(0,i.l_)(a.getTag("alphabet"),"PT"),(0,i.l_)(a.getTag(n.TAGS.CELL_RENDERER),"sequence"),u.Cn.getOrCreate(a)}()})),(0,i.Bu)("afterConvert",(async()=>{await async function(){const t=await l.dapi.files.readAsText("System:AppData/Bio/data/sample_FASTA_PT.csv"),e=n.DataFrame.fromCsv(t),s=e.col("sequence"),o=await l.functions.call("Bio:detectMacromolecule",{col:s});o&&(s.semType=o);const r=l.shell.addTableView(e);await l.data.detectSemanticTypes(e);const a=await(0,R.o)(s,h.r2.SEPARATOR,"/");await(0,i.ow)((()=>r.grid.dataFrame!=e),"View grid has wrong data frame",100);const c=a.getTag(n.TAGS.CELL_RENDERER);(0,i.l_)(c,"sequence"),u.Cn.getOrCreate(a)}()})),(0,i.Bu)("selectRendererBySemType",(async()=>{await async function(){const t=n.Column.fromStrings("SequencesDiff",["meI/hHis/Aca/N/T/dK/Thr_PO3H2/Aca#D-Tyr_Et/Tyr_ab-dehydroMe/meN/E/N/dV"]);t.setTag(n.TAGS.UNITS,h.r2.SEPARATOR),t.setTag("separator","/"),t.setTag("aligned","SEQ"),t.setTag("alphabet","UN"),t.setTag(".alphabetIsMultichar","true"),t.semType=M.Of.MACROMOLECULE_DIFFERENCE;const e=n.DataFrame.fromColumns([t]);l.shell.addTableView(e),await(0,i.gw)(100);const s=t.getTag(n.TAGS.CELL_RENDERER);if("MacromoleculeDifference"!==s)throw new Error(`Units 'separator', separator '/' and semType 'MacromoleculeDifference' have been manually set on column but after df was added as table, view renderer has set to '${s}' instead of correct 'MacromoleculeDifference'.`)}()}))}));var F=s(6414),D=s.n(F),H=s(9611);(0,i.W3)("renderers: monomerPlacer",(()=>{const t={splitter:{csv:"id,seq\nid1,m1-M-m3-mon4-mon5-N-T-MON8-N9\nid2,m1-mon2-m3-mon4-mon5-Num-MON8-N9\nid3,mon1-M-mon3-mon4-mon5-MON8-N9\n",testList:[{src:{row:0,x:-1},tgt:{pos:null}},{src:{row:1,x:0},tgt:{pos:null}},{src:{row:1,x:5},tgt:{pos:0}},{src:{row:1,x:6},tgt:{pos:0}},{src:{row:1,x:26},tgt:{pos:1}},{src:{row:1,x:160},tgt:{pos:6}},{src:{row:1,x:185},tgt:{pos:7}},{src:{row:2,x:140},tgt:{pos:5}},{src:{row:2,x:145},tgt:{pos:5}}]},splitterMsa:{csv:"id,seq\nid1,m1-M-m3-mon4-mon5-N-T-MON8-N9\nid2,m1-mon2-m3-mon4-mon5-Num--MON8-N9\nid3,\nid4,mon1-M-mon3-mon4-mon5---MON8-N9\n",testList:[{src:{row:0,x:-1},tgt:{pos:null}},{src:{row:1,x:0},tgt:{pos:null}},{src:{row:1,x:1},tgt:{pos:null}},{src:{row:1,x:4},tgt:{pos:null}},{src:{row:1,x:5},tgt:{pos:0}},{src:{row:1,x:37},tgt:{pos:0}},{src:{row:1,x:38},tgt:{pos:1}},{src:{row:1,x:170},tgt:{pos:4}},{src:{row:1,x:200},tgt:{pos:5}},{src:{row:2,x:20},tgt:{pos:null}},{src:{row:3,x:170},tgt:{pos:4}},{src:{row:3,x:200},tgt:{pos:5}},{src:{row:3,x:282},tgt:{pos:null}}]},fastaMsa:{csv:"id,seq\nid1,QQYNIYPLT\nid2,QQWSSFPYT\nid3,\nid3,QHIRE--LT\n",testList:[{src:{row:1,x:-1},tgt:{pos:null}},{src:{row:1,x:0},tgt:{pos:null}},{src:{row:1,x:1},tgt:{pos:null}},{src:{row:1,x:19},tgt:{pos:0}},{src:{row:1,x:170},tgt:{pos:8}},{src:{row:1,x:171},tgt:{pos:8}},{src:{row:2,x:5},tgt:{pos:null}},{src:{row:3,x:170},tgt:{pos:8}},{src:{row:3,x:181},tgt:{pos:null}}]}};for(const[e,s]of Object.entries(t))(0,i.Bu)(`getPosition-${e}`,(async()=>{const t=n.DataFrame.fromCsv(s.csv);await l.data.detectSemanticTypes(t);const e=t.getCol("seq"),i=new H.A(null,e,(()=>({unitsHandler:u.Cn.getOrCreate(e),monomerCharWidth:7,separatorWidth:12,monomerToShort:h.GU,monomerLengthLimit:3}))),o=s.testList;for(let t=0;t<e.length;++t)i.getCellMonomerLengths(t);const r=[];for(const[t,e]of D().enumerate(o)){const e={pos:i.getPosition(t.src.row,t.src.x)};t.tgt.pos!=e.pos&&r.push(`Test src ${JSON.stringify(t.src)} expected tgt ${JSON.stringify(t.tgt)}, but get ${JSON.stringify({res:e})}`)}if(r.length>0)throw new Error("Test failed error(s):\n"+r.join(", n"))}))})),(0,i.W3)("converters",(()=>{let t;!function(t){t.fastaPt="fastaPt",t.separatorPt="separatorPt",t.helmPt="helmPt",t.fastaDna="fastaDna",t.separatorDna="separatorDna",t.helmDna="helmDna",t.fastaRna="fastaRna",t.separatorRna="separatorRna",t.helmRna="helmRna",t.fastaGaps="fastaGaps",t.separatorGaps="separatorGaps",t.helmGaps="helmGaps",t.fastaUn="fastaUn",t.separatorUn="separatorUn",t.helmUn="helmUn",t.helmLoneDeoxyribose="helmLoneDeoxyribose",t.helmLoneRibose="helmLoneRibose",t.helmLonePhosphorus="helmLonePhosphorus",t.fastaLoneDeoxyribose="fastaLoneDeoxyribose",t.fastaLoneRibose="fastaLoneRibose",t.fastaLonePhosphorus="fastaLonePhosphorus"}(t||(t={}));const e={[t.fastaPt]:"seq\nFWPHEYFWPHEY\nYNRQWYVYNRQWYV\nMKPSEYVMKPSEYV",[t.separatorPt]:"seq\nF-W-P-H-E-Y-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PEPTIDE1{meI.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.Aca.Tyr_PO3H2.meI.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.Aca.Tyr_PO3H2}$$$$\nPEPTIDE1{Lys_Boc.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.Aca.Tyr_PO3H2.Lys_Boc.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.Aca}$$$$",[t.helmLoneDeoxyribose]:"seq\nRNA1{d(A).d(C).d(G).d(T).d(C).d(A).d(C).d(G).d(T).d(C)}$$$$\nRNA1{d(C).d(A).d(G).d(T).d(G).d(T)p.d(C).d(A).d(G).d(T).d(G).d(T)p}$$$$\nRNA1{d(T).d(T).d(C).d(A).d(A).d(C)p.d(T).d(T).d(C).d(A).d(A).d(C)p}$$$$",[t.helmLoneRibose]:"seq\nRNA1{r(A).r(C).r(G).r(U).r(C).r(A).r(C).r(G).r(U).r(C)}$$$$\nRNA1{r(C).r(A).r(G).r(U).r(G).r(U)p.r(C).r(A).r(G).r(U).r(G).r(U)p}$$$$\nRNA1{r(U).r(U).r(C).r(A).r(A).r(C)p.r(U).r(U).r(C).r(A).r(A).r(C)p}$$$$",[t.helmLonePhosphorus]:"seq\nRNA1{p.p.r(A)p.r(C)p.r(G)p.r(U)p.r(C)p.r(A)p.r(C)p.r(G)p.r(U)p.r(C)p}$$$$\nRNA1{p.p.r(C)p.r(A)p.p.r(G)p.r(U)p.r(G)p.r(U)p.r(C)p.r(A)p.p.r(G)p.r(U)p.r(G)p.r(U)p}$$$$\nRNA1{p.r(U)p.r(U)p.r(C)p.r(A)p.r(A)p.r(C)p.r(U)p.r(U)p.r(C)p.r(A)p.r(A)p.r(C)p.p.p}$$$$"};async function s(t){const s=e[t],i=n.DataFrame.fromCsv(s);return await l.data.detectSemanticTypes(i),i}function o(t,e){if(t===h.r2.SEPARATOR&&!e)throw new Error(`Argument 'separator' is mandatory for target notation '${t.toString()}'.`);return function(s){const o=u.Cn.getOrCreate(s).convert(t,e);return(0,i.l_)(o.getTag(n.TAGS.UNITS),t),o}}async function r(t,e,n){const o=e((await s(t)).getCol("seq")),r=(await s(n)).getCol("seq");(0,i.f6)(o.toList(),r.toList()),u.Cn.getOrCreate(o)}(0,i.Bu)("testFastaPtToSeparator",(async()=>{await r(t.fastaPt,o(h.r2.SEPARATOR,"-"),t.separatorPt)})),(0,i.Bu)("testFastaDnaToSeparator",(async()=>{await r(t.fastaDna,o(h.r2.SEPARATOR,"/"),t.separatorDna)})),(0,i.Bu)("testFastaRnaToSeparator",(async()=>{await r(t.fastaRna,o(h.r2.SEPARATOR,"*"),t.separatorRna)})),(0,i.Bu)("testFastaGapsToSeparator",(async()=>{await r(t.fastaGaps,o(h.r2.SEPARATOR,"/"),t.separatorGaps)})),(0,i.Bu)("testFastaUnToSeparator",(async()=>{await r(t.fastaUn,o(h.r2.SEPARATOR,"-"),t.separatorUn)})),(0,i.Bu)("testFastaPtToHelm",(async()=>{await r(t.fastaPt,o(h.r2.HELM),t.helmPt)})),(0,i.Bu)("testFastaDnaToHelm",(async()=>{await r(t.fastaDna,o(h.r2.HELM),t.helmDna)})),(0,i.Bu)("testFastaRnaToHelm",(async()=>{await r(t.fastaRna,o(h.r2.HELM),t.helmRna)})),(0,i.Bu)("testFastaGapsToHelm",(async()=>{await r(t.fastaGaps,o(h.r2.HELM),t.helmGaps)})),(0,i.Bu)("testSeparatorPtToFasta",(async()=>{await r(t.separatorPt,o(h.r2.FASTA),t.fastaPt)})),(0,i.Bu)("testSeparatorDnaToFasta",(async()=>{await r(t.separatorDna,o(h.r2.FASTA),t.fastaDna)})),(0,i.Bu)("testSeparatorRnaToFasta",(async()=>{await r(t.separatorRna,o(h.r2.FASTA),t.fastaRna)})),(0,i.Bu)("testSeparatorGapsToFasta",(async()=>{await r(t.separatorGaps,o(h.r2.FASTA),t.fastaGaps)})),(0,i.Bu)("testSeparatorUnToFasta",(async()=>{await r(t.separatorUn,o(h.r2.FASTA),t.fastaUn)})),(0,i.Bu)("testSeparatorPtToHelm",(async()=>{await r(t.separatorPt,o(h.r2.HELM),t.helmPt)})),(0,i.Bu)("testSeparatorDnaToHelm",(async()=>{await r(t.separatorDna,o(h.r2.HELM),t.helmDna)})),(0,i.Bu)("testSeparatorRnaToHelm",(async()=>{await r(t.separatorRna,o(h.r2.HELM),t.helmRna)})),(0,i.Bu)("testSeparatorGapsToHelm",(async()=>{await r(t.separatorGaps,o(h.r2.HELM),t.helmGaps)})),(0,i.Bu)("testHelmDnaToFasta",(async()=>{await r(t.helmDna,o(h.r2.FASTA),t.fastaDna)})),(0,i.Bu)("testHelmRnaToFasta",(async()=>{await r(t.helmRna,o(h.r2.FASTA),t.fastaRna)})),(0,i.Bu)("testHelmPtToFasta",(async()=>{await r(t.helmPt,o(h.r2.FASTA),t.fastaPt)})),(0,i.Bu)("testHelmUnToFasta",(async()=>{await r(t.helmUn,o(h.r2.FASTA),t.fastaUn)})),(0,i.Bu)("testHelmDnaToSeparator",(async()=>{await r(t.helmDna,o(h.r2.SEPARATOR,"/"),t.separatorDna)})),(0,i.Bu)("testHelmRnaToSeparator",(async()=>{await r(t.helmRna,o(h.r2.SEPARATOR,"*"),t.separatorRna)})),(0,i.Bu)("testHelmPtToSeparator",(async()=>{await r(t.helmPt,o(h.r2.SEPARATOR,"-"),t.separatorPt)})),(0,i.Bu)("testHelmUnToSeparator",(async()=>{await r(t.helmUn,o(h.r2.SEPARATOR,"-"),t.separatorUn)})),(0,i.Bu)("testHelmLoneRibose",(async()=>{await r(t.helmLoneRibose,o(h.r2.FASTA),t.fastaRna)})),(0,i.Bu)("testHelmLoneDeoxyribose",(async()=>{await r(t.helmLoneDeoxyribose,o(h.r2.SEPARATOR,"/"),t.separatorDna)})),(0,i.Bu)("testHelmLonePhosphorus",(async()=>{await r(t.helmLonePhosphorus,o(h.r2.FASTA),t.fastaRna)}))}));var W=s(5226);(0,i.W3)("fastaFileHandler",(()=>{const t=["description:1","description:2","description:3","description:4"],e=(n.Column.fromStrings("description",t),["MDYKETLLMPKTDFPMRGGLPNKEPQIQEKW","MIEVFLFGIVLGLIPITLAGLFVTAYLQYRRGDQLDL","MMELVLKTIIGPIVVGVVLRIVDKWLNKDK","MDRTDEVSNHTHDKPTLTWFEEIFEEYHSPFHN"]);function s(s){const n=new W.i(s),o=n.descriptionsArray,r=n.sequencesArray;(0,i.f6)([o,r],[t,e])}(0,i.Bu)("testNormalFormatting",(async()=>{s(">description:1\nMDYKETLLMPKTDFPMRGGLPNKEPQIQEKW\n\n>description:2\nMIEVFLFGIVLGLIPITLAGLFVTAYLQYRRGDQLDL\n\n>description:3\nMMELVLKTIIGPIVVGVVLRIVDKWLNKDK\n\n>description:4\nMDRTDEVSNHTHDKPTLTWFEEIFEEYHSPFHN\n")})),(0,i.Bu)("testExtraSpaces",(async()=>{s(">description:1\n MDYKETLLMPKTDFPMRGGLPNKEPQIQEKW\n\n>description:2\nMI EVF LFGIVLGLI PITLAGLFVTAY LQYRRGDQLDL\n\n>description:3\nM MELVLKTI IGPI VVGVVLR IVDKWLNKDK\n\n>description:4\nMDR TDEVSNHTHDKP TLTWFEEIFEEYHSPFHN\n ")})),(0,i.Bu)("testExtraNewlines",(async()=>{s(">description:1\n\nMDYKETLLMPKTDFPMRGGLPNKEPQIQEKW\n\n>description:2\nMIEVF\nLFGIVLGLI\nPITLAGLFVTA\nYLQYRRGDQLDL\n\n>description:3\nM\nME\n\nLVLKTIIG\n\nPIVVGVVLRI\nVDKWLNKDK\n\n\n>description:4\n\nMDRT\n\nDEVSNHTHDKP\n\nTLTWFEEIFEE\n\n\n\nYHSPFHN\n")}))}));var B=s(9943);(0,i.W3)("fastaExport",(()=>{let t;!function(t){t.single="single",t.multi="multi"}(t||(t={}));const e={[t.single]:{src:"MDYKETLLMPKTDFPMRGGLP",tgt:["MDYKETLLMP","KTDFPMRGGL","P"]},[t.multi]:{src:"M[MeI]YKETLL[MeF]PKTDFPMRGGL[MeA]",tgt:["M[MeI]YKETLL[MeF]P","KTDFPMRGGL","[MeA]"]}};let s;!function(t){t.test1="test1",t.test2="test2"}(s||(s={}));const o={[s.test1]:{srcCsv:"id,seq\n1,MDYKETLLMP\n2,KTDFPMRGGL\n3,P",idCols:["id"],seqCol:"seq",lineWidth:10,tgtFasta:">1\nMDYKETLLMP\n>2\nKTDFPMRGGL\n>3\nP\n"},[s.test2]:{srcCsv:"id,id2,seq\n1,seqA,M[MeI]YKETLL[MeF]P\n2,seqB,KTDFPMRGGL\n3,seqC,[MeA]\n",idCols:["id2","id"],seqCol:"seq",lineWidth:5,tgtFasta:">seqA|1\nM[MeI]YKE\nTLL[MeF]P\n>seqB|2\nKTDFP\nMRGGL\n>seqC|3\n[MeA]\n"}};function r(t,s=10){const n=h.kB,o=e[t].src,r=(0,B.sK)(o,n,s),a=e[t].tgt;(0,i.f6)(r,a)}async function a(t){const e=n.DataFrame.fromCsv(t.srcCsv),s=e.getCol(t.seqCol),o=t.idCols.map((t=>e.getCol(t))),r=(0,B.i$)(o,s,t.lineWidth);(0,i.l_)(r,t.tgtFasta)}(0,i.Bu)("wrapSequenceSingle",(async()=>{r(t.single,10)})),(0,i.Bu)("wrapSequenceMulti",(async()=>{r(t.multi,10)})),(0,i.Bu)("saveAsFastaTest1",(async()=>{a(o[s.test1])})),(0,i.Bu)("saveAsFastaTest2",(async()=>{a(o[s.test2])}))}));var k=s(7331),U=s(585);(0,i.W3)("bio",(()=>{const t="seq\nACGTCT\nCAGTGT\nTTCAAC";(0,i.Bu)("testGetStatsHelm1",(async()=>{const t=n.DataFrame.fromCsv("seq\nPEPTIDE1{meI}$$$$").getCol("seq"),e=(0,U.jY)(t,1,h.gP);(0,i.Wh)(e.freq,{meI:1}),(0,i.l_)(e.sameLength,!0)})),(0,i.Bu)("testGetStatsN1",(async()=>{await async function(t){const e=n.DataFrame.fromCsv(t).col("seq"),s=(0,U.jY)(e,5,h.kB);(0,i.Wh)(s.freq,{A:4,C:5,G:3,T:6}),(0,i.l_)(s.sameLength,!0)}(t)})),(0,i.Bu)("testGetAlphabetSimilarity",(async()=>{await async function(){const t=new Set(Object.keys(a.V.Names)),e=(0,h.KX)({A:2041,C:3015,G:3015,T:2048,"-":1e3},t);(0,i.l_)(e>.6,!0)}()})),(0,i.Bu)("testPickupPaletteN1",(async()=>{await async function(t){const e=n.DataFrame.fromCsv(t).col("seq"),s=(0,h.dQ)(e);(0,i.l_)(s instanceof a.J,!0)}(t)})),(0,i.Bu)("testPickupPaletteN1e",(async()=>{await async function(t){const e=n.DataFrame.fromCsv("seq\nACGTAT\nCAGTTG\nTTCG2C").col("seq"),s=(0,h.dQ)(e);(0,i.l_)(s instanceof a.J,!0)}()})),(0,i.Bu)("testPickupPaletteAA1",(async()=>{await async function(t){const e=n.DataFrame.fromCsv("seq\nFWPHEYV\nYNRQWYV\nMKPSEYV").col("seq"),s=(0,h.dQ)(e);(0,i.l_)(s instanceof o.f,!0)}()})),(0,i.Bu)("testPickupPaletteX",(async()=>{await async function(t){const e=n.DataFrame.fromCsv("seq\nXZJ{}2\n5Z4733\n3Z6></\n675687").col("seq"),s=(0,h.dQ)(e);(0,i.l_)(s instanceof k.kQ,!0)}()}))})),(0,i.W3)("WebLogo.monomerToShort",(()=>{(0,i.Bu)("longMonomerSingle",(async()=>{(0,i.l_)((0,h.GU)("S",5),"S")})),(0,i.Bu)("longMonomerShort",(async()=>{(0,i.l_)((0,h.GU)("Short",5),"Short")})),(0,i.Bu)("longMonomerLong56",(async()=>{(0,i.l_)((0,h.GU)("Long56",6),"Long56")})),(0,i.Bu)("longMonomerComplexFirstPartShort",(async()=>{(0,i.l_)((0,h.GU)("Long-long",5),"Long…")})),(0,i.Bu)("longMonomerComplexFirstPartLong56",(async()=>{(0,i.l_)((0,h.GU)("Long56-long",6),"Long5…")})),(0,i.Bu)("monomerToShort",(async()=>{const t=[["AbC","AbC"],["AbCd","Ab…"],["ABc","ABc"],["ABcd","AB…"],["A_b","A_b"],["A_bc","A…"],["Ab_c","Ab…"],["A1_b","A1…"],["Abc_d","Ab…"],["Abcd_e","Ab…"],["A-b","A-b"],["A-bc","A…"],["Ab-c","Ab…"],["A1-b","A1…"],["Abc-d","Ab…"],["Abcd-e","Ab…"],["A","A"],["Ab","Ab"],["Abc","Abc"],["Ab…","Ab…"],["Abcd","Ab…"],["Abcde","Ab…"]],e=t.map((t=>t[0])),s=t.map((t=>t[1])),n=e.map((t=>(0,h.GU)(t,3)));(0,i.f6)(n,s)}))}));var V=s(8415);function $(t,e){(0,i.l_)(t.name,e.name),(0,i.f6)(t.getMonomers(),e.getMonomers());for(const s of t.getMonomers())(0,i.l_)(t.getFreq(s).rowCount,e.getFreq(s).rowCount)}(0,i.W3)("WebLogo-positions",(()=>{const t="seq\nATC-G-TTGC--\nATC-G-TTGC--\n-TC-G-TTGC--\n-TC-GCTTGC--\n-TC-GCTTGC--";(0,i.Bu)("allPositions",(async()=>{const e=n.DataFrame.fromCsv(t),s=l.shell.addTableView(e),o=e.getCol("seq");o.semType=n.SEMTYPE.MACROMOLECULE,o.setTag(n.TAGS.UNITS,h.r2.FASTA),o.setTag("alphabet","DNA"),o.setTag("aligned","SEQ.MSA");const r=await e.plot.fromType("WebLogo");await(0,i.zg)(r.onLayoutCalculated,(()=>{}),(()=>{s.dockManager.dock(r.root,n.DOCK_TYPE.DOWN)}),500);const a=r.positions,c=[new V.CK(0,"1",{A:new V.yW(2),"-":new V.yW(3)}),new V.CK(1,"2",{T:new V.yW(5)}),new V.CK(2,"3",{C:new V.yW(5)}),new V.CK(3,"4",{"-":new V.yW(5)}),new V.CK(4,"5",{G:new V.yW(5)}),new V.CK(5,"6",{"-":new V.yW(3),C:new V.yW(2)}),new V.CK(6,"7",{T:new V.yW(5)}),new V.CK(7,"8",{T:new V.yW(5)}),new V.CK(8,"9",{G:new V.yW(5)}),new V.CK(9,"10",{C:new V.yW(5)}),new V.CK(10,"11",{"-":new V.yW(5)}),new V.CK(11,"12",{"-":new V.yW(5)})];(0,i.l_)(a.length,c.length);for(let t=0;t<a.length;t++){(0,i.l_)(a[t].name,c[t].name);for(const e of a[t].getMonomers())(0,i.l_)(a[t].getFreq(e).rowCount,c[t].getFreq(e).rowCount)}})),(0,i.Bu)("positions with shrinkEmptyTail option true (filtered)",(async()=>{const t=n.DataFrame.fromCsv("seq\n-TC-G-TTGC--\n-TC-GCTTGC--\n-T--C-GT-\n-T--C-GT-\n-T--C-GT-\n-T--CCGT-"),e=l.shell.addTableView(t),s=t.getCol("seq");s.semType=n.SEMTYPE.MACROMOLECULE,s.setTag(n.TAGS.UNITS,h.r2.FASTA),s.setTag("alphabet","DNA"),s.setTag("aligned","SEQ"),t.filter.init((t=>t>2)),t.filter.fireChanged();const o=await t.plot.fromType("WebLogo",{shrinkEmptyTail:!0});await(0,i.zg)(o.onLayoutCalculated,(()=>{}),(()=>{e.dockManager.dock(o.root,n.DOCK_TYPE.DOWN)}),500);const r=o.positions,a=[new V.CK(0,"1",{"-":new V.yW(3)}),new V.CK(1,"2",{T:new V.yW(3)}),new V.CK(2,"3",{"-":new V.yW(3)}),new V.CK(3,"4",{"-":new V.yW(3)}),new V.CK(4,"5",{C:new V.yW(3)}),new V.CK(5,"6",{"-":new V.yW(2),C:new V.yW(1)}),new V.CK(6,"7",{G:new V.yW(3)}),new V.CK(7,"8",{T:new V.yW(3)}),new V.CK(8,"9",{"-":new V.yW(3)})];(0,i.l_)(r.length,a.length);for(let t=0;t<r.length;t++){(0,i.l_)(r[t].name,a[t].name);for(const e of r[t].getMonomers())(0,i.l_)(r[t].getFreq(e).rowCount,a[t].getFreq(e).rowCount)}})),(0,i.Bu)("positions with skipEmptyPositions option",(async()=>{const e=n.DataFrame.fromCsv(t),s=l.shell.addTableView(e),o=e.getCol("seq");o.semType=n.SEMTYPE.MACROMOLECULE,o.setTag(n.TAGS.UNITS,h.r2.FASTA),o.setTag("alphabet","DNA"),o.setTag("aligned","SEQ.MSA");const r=await e.plot.fromType("WebLogo",{skipEmptyPositions:!0});await(0,i.zg)(r.onLayoutCalculated,(()=>{}),(()=>{s.dockManager.dock(r.root,n.DOCK_TYPE.DOWN)}),500);const a=r.positions,c=[new V.CK(0,"1",{A:new V.yW(2),"-":new V.yW(3)}),new V.CK(1,"2",{T:new V.yW(5)}),new V.CK(2,"3",{C:new V.yW(5)}),new V.CK(4,"5",{G:new V.yW(5)}),new V.CK(5,"6",{"-":new V.yW(3),C:new V.yW(2)}),new V.CK(6,"7",{T:new V.yW(5)}),new V.CK(7,"8",{T:new V.yW(5)}),new V.CK(8,"9",{G:new V.yW(5)}),new V.CK(9,"10",{C:new V.yW(5)})];(0,i.l_)(a.length,c.length);for(let t=0;t<a.length;t++)$(a[t],c[t])})),(0,i.Bu)("count sequences for monomer at position",(async()=>{const e=function(t,e,s,i){const o=n.DataFrame.fromCsv(t),r=o.getCol("seq");return r.semType=n.SEMTYPE.MACROMOLECULE,r.setTag(n.TAGS.UNITS,e),r.setTag("alphabet","DNA"),r.setTag("aligned","SEQ.MSA"),o}(t,h.r2.FASTA),s=e.getCol("seq"),o=l.shell.addTableView(e),r=await e.plot.fromType("WebLogo",{startPositionName:"3",endPositionName:"7",skipEmptyPositions:!0});await(0,i.zg)(r.onLayoutCalculated,(()=>{}),(()=>{o.dockManager.dock(r.root,n.DOCK_TYPE.DOWN)}),500);const a=r.positions,c=[new V.CK(2,"3",{C:new V.yW(5)}),new V.CK(4,"5",{G:new V.yW(5)}),new V.CK(5,"6",{"-":new V.yW(3),C:new V.yW(2)}),new V.CK(6,"7",{T:new V.yW(5)})];(0,i.l_)(a.length,c.length);for(let t=0;t<a.length;t++)$(a[t],c[t]);const m=a[1],d=u.Cn.getOrCreate(s),p=(0,V.eZ)(e,d,e.filter,"G",m);(0,i.l_)(p,5)})),(0,i.Bu)("empty",(async()=>{const t=n.DataFrame.fromColumns([(()=>{const t=n.Column.fromStrings("seq",[]);return t.setTag(n.TAGS.SEMTYPE,n.SEMTYPE.MACROMOLECULE),t.setTag(n.TAGS.UNITS,h.r2.FASTA),t.setTag("alphabet","DNA"),t})()]),e=l.shell.addTableView(t),s=await t.plot.fromType("WebLogo");await(0,i.zg)(s.onLayoutCalculated,(()=>{}),(()=>{e.dockManager.dock(s.root,n.DOCK_TYPE.DOWN)}),500),s.positions}))}));var Y=s(2568);function q(t,e){let s=null;for(const n of t.viewers)n.type===e&&(s=n);return s}(0,i.W3)("checkInputColumn",(()=>{const t="seq\nseq1,\nseq2,\nseq3,\nseq4";(0,i.Bu)("testMsaPos",(async()=>{const e=n.DataFrame.fromCsv(t).getCol("seq");e.semType=n.SEMTYPE.MACROMOLECULE,e.setTag(n.TAGS.UNITS,h.r2.FASTA),e.setTag("alphabet","DNA"),e.setTag("aligned","SEQ");const[s,o]=(0,Y.l)(e,"Test",[h.r2.FASTA],["DNA","RNA","PT"]);(0,i.l_)(s,!0)})),(0,i.Bu)("testMsaNegHelm",(async()=>{const e=n.DataFrame.fromCsv(t).getCol("seq");e.semType=n.SEMTYPE.MACROMOLECULE,e.setTag(n.TAGS.UNITS,h.r2.HELM),e.setTag(".alphabetIsMultichar","true");const[s,o]=(0,Y.l)(e,"Test",[h.r2.FASTA],["DNA","RNA","PT"]);(0,i.l_)(s,!1)})),(0,i.Bu)("testMsaNegUN",(async()=>{const e=n.DataFrame.fromCsv(t).getCol("seq");e.semType=n.SEMTYPE.MACROMOLECULE,e.setTag(n.TAGS.UNITS,h.r2.FASTA),e.setTag("alphabet","UN"),e.setTag(".alphabetSize","11"),e.setTag(".alphabetIsMultichar","true"),e.setTag("aligned","SEQ");const[s,o]=(0,Y.l)(e,"Test",[h.r2.FASTA],["DNA","RNA","PT"]);(0,i.l_)(s,!1)})),(0,i.Bu)("testGetActionFunctionMeta",(async()=>{n.Func.find({package:"Bio",name:"multipleSequenceAlignmentDialog"})[0].inputs.find((t=>"sequence"==t.name))}))})),(0,i.W3)("similarity/diversity",(async()=>{(0,i.Bu)("similaritySearchViewer",(async()=>{await async function(){const t=await b("tests/sample_MSA_data.csv"),e=await t.dataFrame.plot.fromType("Sequence Similarity Search");let s=!1;if(e.computeCompleted.subscribe((t=>{t&&(s=!0)})),t.dockManager.dock(e,n.DOCK_TYPE.RIGHT,null,"Similarity"),await e.renderPromise,await(0,i.ow)((()=>void 0!==q(t,"Sequence Similarity Search")),"Sequence Similarity Search viewer has not been created",100),!e.initialized)throw new Error("The viewer is not initialized.");if(!e.moleculeColumn)throw new Error("The viewer has not molecule column (onTableAttached).");if(!e.beforeRender())throw new Error("The viewer is not able to render.");if(!e.computeRequested)throw new Error("The viewer has not compute requested even.");if(!s)throw new Error("The viewer has not compute completed.");const o=e;await(0,i.ow)((()=>0!==o.root.getElementsByClassName("d4-grid").length),"Sequence Similarity Search viewer grid has not been created",100);(0,i.l_)(o.fingerprint,"Morgan"),(0,i.l_)(o.distanceMetric,"Tanimoto"),(0,i.l_)(o.scores.get(0),n.FLOAT_NULL),(0,i.l_)(o.idxs.get(0),0),(0,i.l_)(o.molCol.get(0),"D-Tyr_Et/Tyr_ab-dehydroMe/dV/E/N/D-Orn/D-aThr//Phe_4Me"),(0,i.l_)(o.scores.get(1),.4722222089767456),(0,i.l_)(o.idxs.get(1),11),(0,i.l_)(o.molCol.get(1),"meI/hHis//Aca/meM/Tyr_ab-dehydroMe/dV/E/N/D-Orn/D-aThr//Phe_4Me"),t.dataFrame.currentRowIdx=1,await(0,i.ow)((()=>1===o.targetMoleculeIdx),"Target molecule has not been changed",5e3),await(0,i.ow)((()=>"meI/hHis/Aca/Cys_SEt/T/dK/Thr_PO3H2/Aca/Tyr_PO3H2/D-Chg/dV/Phe_ab-dehydro/N/D-Orn/D-aThr//Phe_4Me"===o.molCol.get(0)),"Incorrect first similar molecule",5e3)}()})),(0,i.Bu)("diversitySearchViewer",(async()=>{await async function(){const t=await b("tests/sample_MSA_data.csv"),e=await t.dataFrame.plot.fromType("Sequence Diversity Search");let s=!1;if(e.computeCompleted.subscribe((t=>{t&&(s=!0)})),t.dockManager.dock(e,n.DOCK_TYPE.DOWN,null,"Diversity"),await e.renderPromise,await(0,i.ow)((()=>void 0!==q(t,"Sequence Diversity Search")),"Sequence Diversity Search viewer has not been created",100),!e.initialized)throw new Error("The viewer is not initialized.");if(!e.moleculeColumn)throw new Error("The viewer has not molecule column (onTableAttached).");if(!e.beforeRender())throw new Error("The viewer is not able to render.");if(!e.computeRequested)throw new Error("The viewer has not compute requested even.");if(!s)throw new Error("The viewer has not compute completed.");const o=e;await(0,i.ow)((()=>0!==o.root.getElementsByClassName("d4-grid").length),"Sequence Diversity Search viewer grid has not been created",100),(0,i.l_)(o.fingerprint,"Morgan"),(0,i.l_)(o.distanceMetric,"Tanimoto"),(0,i.l_)(o.initialized,!0),(0,i.l_)(o.renderMolIds.length>0,!0)}()}))}));var K=s(4413);(0,i.W3)("substructureFilters",(async()=>{let t,e;(0,i.bb)((async()=>{t=await(0,L.JN)(),e=await(0,P.nW)(),await(0,P.tb)(),await t.loadLibraries(!0)})),(0,i.X5)((async()=>{await(0,P.tW)(e),await t.loadLibraries(!0)})),(0,i.Bu)("fasta",(async()=>{const t=await T("tests/filter_FASTA.csv"),e=new K.ST;await l.data.detectSemanticTypes(t),e.attach(t),e.bioFilter.substructure="MD",await(0,i.gw)(100),(0,i.l_)(e.dataFrame.filter.trueCount,3),(0,i.l_)(e.dataFrame.filter.get(0),!0),(0,i.l_)(e.dataFrame.filter.get(3),!0),(0,i.l_)(e.dataFrame.filter.get(8),!0),(0,i.l_)(e.dataFrame.filter.get(1),!1)})),(0,i.Bu)("separator",(async()=>{const t=await T("tests/filter_MSA.csv"),e=new K.ST;await l.data.detectSemanticTypes(t),e.attach(t),e.bioFilter.substructure="meI",await(0,i.gw)(100),(0,i.l_)(e.dataFrame.filter.trueCount,7),(0,i.l_)(e.dataFrame.filter.get(2),!1),e.bioFilter.substructure="/meI",await(0,i.gw)(100),(0,i.l_)(e.dataFrame.filter.trueCount,0),e.bioFilter.substructure="meI-hHis",e.bioFilter.separatorInput.value="-",await(0,i.gw)(100),(0,i.l_)(e.dataFrame.filter.trueCount,7),(0,i.l_)(e.dataFrame.filter.get(2),!1)})),(0,i.Bu)("helm",(async()=>{const t=await T("tests/filter_HELM.csv"),e=l.shell.addTableView(t),s=new K.ST;await l.data.detectSemanticTypes(t),pt.logger.debug("Bio/substructureFilters/helm, filter attaching."),s.attach(t),pt.logger.debug("Bio/substructureFilters/helm, filter attached."),pt.logger.debug("Bio/substructureFilters/helm, filter 1 changing."),s.bioFilter.helmSubstructure="PEPTIDE1{C}$$$$V2.0",pt.logger.debug("Bio/substructureFilters/helm, filter 1 change awaiting."),await(0,i.zg)(t.onRowsFiltered,(()=>{}),(()=>{s.bioFilter.onChanged.next()}),2e4),pt.logger.debug("Bio/substructureFilters/helm, filter 1 changed."),(0,i.l_)(s.dataFrame.filter.trueCount,2),(0,i.l_)(s.dataFrame.filter.get(0),!0),(0,i.l_)(s.dataFrame.filter.get(3),!0),pt.logger.debug("Bio/substructureFilters/helm, filter 2 changing."),s.bioFilter.helmSubstructure="PEPTIDE1{A.C}$$$$V2.0",pt.logger.debug("Bio/substructureFilters/helm, filter 2 change awaiting."),await(0,i.zg)(t.onRowsFiltered,(()=>{}),(()=>{s.bioFilter.onChanged.next()}),2e4),await async function(t,e=5e3){await(0,i.gw)(0),await(0,i.zg)(t.onAfterDrawContent,(()=>{}),(()=>{t.invalidate()}),e)}(e.grid),pt.logger.debug("Bio/substructureFilters/helm, filter 2 changed."),(0,i.l_)(s.dataFrame.filter.trueCount,1),(0,i.l_)(s.dataFrame.filter.get(3),!0)}),{timeout:3e4})}));var Z=s(8341);(0,i.W3)("PepSeA",(()=>{(0,i.Bu)("Basic alignment",(async()=>{await A();const t=n.DataFrame.fromCsv('HELM,MSA\n "PEPTIDE1{F.L.R.G.W.[MeF].Y.S.N.N.C}$$$$","F.L.R.G.W.MeF.Y..S.N.N.C"\n "PEPTIDE1{F.L.R.G.Y.[MeF].Y.W.N.C}$$$$","F.L.R.G.Y.MeF.Y.W...N.C"\n "PEPTIDE1{F.G.Y.[MeF].Y.W.S.D.N.C}$$$$","F...G.Y.MeF.Y.W.S.D.N.C"\n "PEPTIDE1{F.L.R.G.Y.[MeF].Y.W.S.N.D.C}$$$$","F.L.R.G.Y.MeF.Y.W.S.N.D.C"\n "PEPTIDE1{F.V.R.G.Y.[MeF].Y.W.S.N.C}$$$$","F.V.R.G.Y.MeF.Y.W.S..N.C"'),e=await(0,Z.f)(t.getCol("HELM"),"msa(HELM)");(0,i.l_)(null!==e,!0,"PepSeA conainter has not started");const s=t.getCol("MSA");for(let t=0;t<e.length;++t)(0,i.l_)(e.get(t)==s.get(t),!0)}),{skipReason:"GROK-13221"})})),(0,i.W3)("viewers",(()=>{const t=n.Func.find({package:"Bio",tags:["viewer"]}).map((t=>t.friendlyName));for(const e of t)(0,i.Bu)(e,(async()=>{const t=await T("data/sample_FASTA_DNA.csv");await(0,i.AB)(e,t,{detectSemanticTypes:!0})}),{skipReason:{"Sequence Similarity Search":"GROK-13162","Sequence Diversity Search":"GROK-13162",WebLogo:"GROK-13162",VdRegions:"GROK-13162"}[e]})}));const z="seq\nACGTCACGTC\nCAGTGTCAGTGT\nTTCAACTTCAAC",X="seq\nAC-GT-CTAC-GT-CT\nCAC-T-GTCAC-T-GT\nACCGTACTACCGTACT",j="seq\nabc-dfgg-abc1-cfr3-rty-wert-abc-dfgg-abc1-cfr3-rty-wert\nrut12-her2-rty-wert-abc-abc1-dfgg-rut12-her2-rty-wert-abc-abc1-dfgg\nrut12-rty-her2-abc-cfr3-wert-rut12-rut12-rty-her2-abc-cfr3-wert-rut12";var J;(0,i.W3)("UnitsHandler",(()=>{async function t(t){const e=n.DataFrame.fromCsv(t);await l.data.detectSemanticTypes(e);const s=u.Cn.getOrCreate(e.getCol("seq"));return[e,s]}(0,i.Bu)("Seq-Fasta",(async()=>{const[e,s]=await t(z);(0,i.l_)(s.notation,h.r2.FASTA),(0,i.l_)(s.isMsa(),!1)})),(0,i.Bu)("Seq-Fasta-MSA",(async()=>{const[e,s]=await t(X);(0,i.l_)(s.notation,h.r2.FASTA),(0,i.l_)(s.isMsa(),!0)})),(0,i.Bu)("Seq-Fasta-units",(async()=>{const[e,s]=await t(z);(0,i.l_)(s.notation,h.r2.FASTA),(0,i.l_)(s.isMsa(),!1)})),(0,i.Bu)("Seq-Fasta-MSA-units",(async()=>{const[e,s]=await t(X);(0,i.l_)(s.notation,h.r2.FASTA),(0,i.l_)(s.isMsa(),!0)})),(0,i.Bu)("Seq-Helm",(async()=>{const[e,s]=await t("seq\nPEPTIDE1{meI.hHis.Aca.N.T.dE.Thr_PO3H2.Aca.D-Tyr_Et.Tyr_ab-dehydroMe.dV.E.N.D-Orn.D-aThr.Phe_4Me}$$$$\nPEPTIDE1{meI.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.Aca.Tyr_PO3H2.D-Chg.dV.Phe_ab-dehydro.N.D-Orn.D-aThr.Phe_4Me}$$$$\nPEPTIDE1{Lys_Boc.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.Aca.Tyr_PO3H2.D-Chg.dV.Thr_PO3H2.N.D-Orn.D-aThr.Phe_4Me}$$$$\nPEPTIDE1{meI.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.Aca.Tyr_PO3H2.D-Chg.dV.Thr_PO3H2.N.D-Orn.D-aThr.Phe_4Me}$$$$");(0,i.l_)(s.notation,h.r2.HELM),(0,i.l_)(s.isHelm(),!0)})),(0,i.Bu)("Seq-UN",(async()=>{const[e,s]=await t(j);(0,i.l_)(s.notation,h.r2.SEPARATOR),(0,i.l_)(s.separator,"-"),(0,i.l_)(s.alphabet,"UN")})),(0,i.Bu)("Seq-UN-auto",(async()=>{const[e,s]=await t(j);(0,i.l_)(s.notation,h.r2.SEPARATOR),(0,i.l_)(s.separator,"-"),(0,i.l_)(s.alphabet,"UN")}))})),function(t){t.fasta="fasta",t.fastaMsa="fastaMsa",t.separator="separator",t.separatorMsa="separatorMsa",t.helm="helm"}(J||(J={})),(0,i.W3)("UnitsHandler",(()=>{u._9[h.r2.FASTA],u._9[h.r2.HELM];const t=u._9[h.r2.SEPARATOR],e={[J.fasta]:{src:{csv:"seq\nACGTCACGTC\nCAGTGTCAGTGT\nTTCAACTTCAAC"},tgt:{notation:h.r2.FASTA,splitted:["ACGTCACGTC","CAGTGTCAGTGT","TTCAACTTCAAC"]}},[J.fastaMsa]:{src:{csv:"seq\nAC-GT-CTAC-GT-CT\nCAC-T-GTCAC-T-GT\nACCGTACTACCGTACT"},tgt:{notation:h.r2.FASTA,splitted:["AC-GT-CTAC-GT-CT","CAC-T-GTCAC-T-GT","ACCGTACTACCGTACT"]}},[J.separator]:{src:{csv:"seq\nabc-dfgg-abc1-cfr3-rty-wert-abc-dfgg-abc1-cfr3-rty-wert\nrut12-her2-rty-wert-abc-abc1-dfgg-rut12-her2-rty-wert-abc\nrut12-rty-her2-abc-cfr3-wert-rut12-rut12-rty-her2-abc-cfr3"},tgt:{notation:h.r2.SEPARATOR,separator:"-",splitted:[["abc","dfgg","abc1","cfr3","rty","wert","abc","dfgg","abc1","cfr3","rty","wert"],["rut12","her2","rty","wert","abc","abc1","dfgg","rut12","her2","rty","wert","abc"],["rut12","rty","her2","abc","cfr3","wert","rut12","rut12","rty","her2","abc","cfr3"]]}},[J.separatorMsa]:{src:{csv:'seq\nrut0-dfgg-abc1-cfr3-rty-wert-abc-dfgg-abc1-cfr3-rty-wert\nrut1-her2-rty--abc1-dfgg-rut12-her2-rty--abc1-dfgg\nrut2-rty-her2---wert-rut12-rty-her2---wert\n"rut3-rty-her2-""-""-""-""-wert-rut12-rty-her2-""-""-""-""-wert"\n"""-""-rut4-her2-wert-rut12-rty-her2-wert"\n"rut5-rty-her2-wert-rut12-rty-her2-wert-""-"""'},tgt:{notation:h.r2.SEPARATOR,separator:"-",splitted:[["rut0","dfgg","abc1","cfr3","rty","wert","abc","dfgg","abc1","cfr3","rty","wert"],["rut1","her2","rty",t,"abc1","dfgg","rut12","her2","rty",t,"abc1","dfgg"],["rut2","rty","her2",t,t,"wert","rut12","rty","her2",t,t,"wert"],["rut3","rty","her2",t,t,"wert","rut12","rty","her2",t,t,"wert"],[t,"rut4","her2","wert","rut12","rty","her2","wert"],["rut5","rty","her2","wert","rut12","rty","her2","wert",t]]}},[J.helm]:{src:{csv:"seq\nPEPTIDE1{meI.hHis.Aca.N.T.dE.Thr_PO3H2.Aca.D-Tyr_Et.Thr_PO3H2.Aca.D-Tyr_Et}$$$$\nPEPTIDE1{meI.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.Aca.dK.Thr_PO3H2.Aca}$$$$\nPEPTIDE1{Lys_Boc.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.Aca.dK.Thr_PO3H2.Aca}$$$$\nPEPTIDE1{meI.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.T.dK.Thr_PO3H2}$$$$"},tgt:{notation:h.r2.HELM,splitted:[["meI","hHis","Aca","N","T","dE","Thr_PO3H2","Aca","D-Tyr_Et","Thr_PO3H2","Aca","D-Tyr_Et"],["meI","hHis","Aca","Cys_SEt","T","dK","Thr_PO3H2","Aca","dK","Thr_PO3H2","Aca"],["Lys_Boc","hHis","Aca","Cys_SEt","T","dK","Thr_PO3H2","Aca","dK","Thr_PO3H2","Aca"],["meI","hHis","Aca","Cys_SEt","T","dK","Thr_PO3H2","T","dK","Thr_PO3H2"]]}}};for(const[t,s]of Object.entries(e))(0,i.Bu)(`splitted-${t}`,(async()=>{const t=n.DataFrame.fromCsv(s.src.csv).getCol("seq"),e=await l.functions.call("Bio:detectMacromolecule",{col:t});e&&(t.semType=e),(0,i.l_)(t.semType,n.SEMTYPE.MACROMOLECULE);const o=u.Cn.getOrCreate(t);(0,i.l_)(o.notation,s.tgt.notation),(0,i.l_)(o.separator===s.tgt.separator,!0);const r=o.splitted;(0,i.f6)(r,s.tgt.splitted)}),t==J.separatorMsa?{skipReason:"#2468 CSV row starting with the quote character"}:void 0)})),(0,i.W3)("UnitsHandler: getRegion",(()=>{const t={fastaDna:{srcCsv:"seq\nATTCGT\nACTGCTC\nATTCCGTA",startIdx:2,endIdx:4,tgtCsv:"seq\nTCG\nTGC\nTCC",units:h.r2.FASTA,alphabet:"DNA",positionNames:{tag:"a, b, c, d, e, f, g, h",start:"c",end:"e"}},separatorPt:{srcCsv:"seq\nM-D-Y-K-E-T-L\nM-I-E-V-F-L-F-G-I\nM-M-",startIdx:5,endIdx:null,tgtCsv:"seq\nT-L--\nL-F-G-I\n---",units:h.r2.SEPARATOR,alphabet:"PT",positionNames:{tag:"1, 1A, 1B, 2, 3, 4, 4A, 4A, 4C",start:"4",end:null}},helm:{srcCsv:"seq\nPEPTIDE1{[meI].[hHis].[Aca].N.T.[dE].[Thr_PO3H2].[Aca].[D-Tyr_Et].[Tyr_ab-dehydroMe].[dV].E.N.[D-Orn]}$$$$\nPEPTIDE1{[meI].[hHis].[Aca].[Cys_SEt].T.[dK].[Thr_PO3H2].[Aca].[Tyr_PO3H2].[D-Chg].[dV].[Phe_ab-dehydro]}$$$$\nPEPTIDE1{[Lys_Boc].[hHis].[Aca].[Cys_SEt].T}$$$$",startIdx:3,endIdx:6,tgtCsv:"seq\nPEPTIDE1{N.T.[dE].[Thr_PO3H2]}$$$$\nPEPTIDE1{[Cys_SEt].T.[dK].[Thr_PO3H2]}$$$$\nPEPTIDE1{[Cys_SEt].T.*.*}$$$$",units:h.r2.HELM,alphabet:null,positionNames:{tag:null,start:"4",end:"7"}}};for(const[e,s]of Object.entries(t))(0,i.Bu)(`${e}-idx`,(async()=>{const t=n.DataFrame.fromCsv(s.srcCsv).getCol("seq"),e=await l.functions.call("Bio:detectMacromolecule",{col:t});e&&(t.semType=e);const o=u.Cn.getOrCreate(t).getRegion(s.startIdx,s.endIdx,"regSeq"),r=n.DataFrame.fromCsv(s.tgtCsv).getCol("seq");(0,i.l_)(t.getTag(n.TAGS.UNITS),s.units),(0,i.l_)(o.getTag(n.TAGS.UNITS),s.units),(0,i.l_)(t.getTag("alphabet"),s.alphabet),(0,i.l_)(o.getTag("alphabet"),s.alphabet),(0,i.f6)(o.toList(),r.toList())})),s.positionNames&&(0,i.Bu)(`${e}-positionNames`,(async()=>{const t=n.DataFrame.fromCsv(s.srcCsv).getCol("seq");s.positionNames.tag&&t.setTag(".positionNames",s.positionNames.tag);const e=await l.functions.call("Bio:detectMacromolecule",{col:t});e&&(t.semType=e);const o=await l.functions.call("Bio:getRegion",{sequence:t,start:s.positionNames.start,end:s.positionNames.end}),r=n.DataFrame.fromCsv(s.tgtCsv).getCol("seq");(0,i.l_)(t.getTag(n.TAGS.UNITS),s.units),(0,i.l_)(o.getTag(n.TAGS.UNITS),s.units),(0,i.l_)(t.getTag("alphabet"),s.alphabet),(0,i.l_)(o.getTag("alphabet"),s.alphabet),(0,i.f6)(o.toList(),r.toList())}))}));var Q=s(8601);const tt=new n.FileSource("System:AppData/Bio"),et={PT:"peptides-fasta",DNA:"dna-fasta",MSA:"msa-separator"},st={PT:"tests/to-atomic-level-peptides-fasta-input.csv",DNA:"tests/to-atomic-level-dna-fasta-input.csv",MSA:"tests/to-atomic-level-msa-separator-input.csv"},nt={PT:"tests/to-atomic-level-peptides-fasta-output.csv",DNA:"tests/to-atomic-level-dna-fasta-output.csv",MSA:"tests/to-atomic-level-msa-separator-output.csv"},it="molfile(sequence)";async function ot(t,e="seq",s){const n=t.getCol(e),i=s.getBioLib(),o=await(0,Q.i0)(t,n,i);return o.warnings.length>0&&pt.logger.warning(`_toAtomicLevel() warnings ${o.warnings.join("\n")}`),o.col}function rt(t){return t.replaceAll("\r\n","\n").replace(/\n$/,"").split("\n").map((t=>t.trimEnd())).join("\n")}(0,i.W3)("toAtomicLevel",(async()=>{const t={},e={};let s,o,r;async function a(t,e){const s=t.getCol("sequence");await(0,c.toAtomicLevel)(t,s,!1);const n=t.getCol(it),o=e.getCol(it),r=D()(n.values()).map((t=>rt(t))).toArray(),a=D()(o.values()).map((t=>rt(t))).toArray();(0,i.f6)(r,a)}(0,i.bb)((async()=>{s=await(0,L.JN)(),o=await(0,P.nW)(),await(0,P.tb)(),await s.loadLibraries(!0);for(const s in et)t[s]=n.DataFrame.fromCsv((await tt.readAsText(st[s])).replace(/\n$/,"")),await l.data.detectSemanticTypes(t[s]),e[s]=n.DataFrame.fromCsv((await tt.readAsText(nt[s])).replace(/\n$/,""))})),(0,i.X5)((async()=>{await(0,P.tW)(o),await s.loadLibraries(!0)}));for(const s in et)(0,i.Bu)(`${et[s]}`,(async()=>{await a(t[s],e[s])}));!function(t){t.fastaDna="fastaDna",t.fastaRna="fastaRna",t.fastaPt="fastaPt",t.separatorDna="separatorDna",t.separatorRna="separatorRna",t.separatorPt="separatorPt",t.separatorUn="separatorUn",t.helm="helm"}(r||(r={}));const m={[r.fastaDna]:"seq\nACGTCACGTC\nCAGTGTCAGTGT\nTTCAACTTCAAC",[r.fastaRna]:"seq\nACGUCACGUC\nCAGUGUCAGUGU\nUUCAACUUCAAC",[r.fastaPt]:"seq\nFWPHEYFWPHEY\nYNRQWYVYNRQWYV\nMKPSEYVMKPSEYV",[r.separatorDna]:"seq\nA/C/G/T/C/A/C/G/T/C\nC/A/G/T/G/T/C/A/G/T/G/T\nT/T/C/A/A/C/T/T/C/A/A/C",[r.separatorRna]:"seq\nA*C*G*U*C*A*C*G*U*C\nC*A*G*U*G*U*C*A*G*U*G*U\nU*U*C*A*A*C*U*U*C*A*A*C",[r.separatorPt]:"seq\nF-W-P-H-E-Y-F-W-P-H-E-Y\nY-N-R-Q-W-Y-V-Y-N-R-Q-W-Y-V\nM-K-P-S-E-Y-V-M-K-P-S-E-Y-V",[r.separatorUn]:"seq\nmeI-hHis-Aca-N-T-dE-Thr_PO3H2-Aca-D-meI-hHis-Aca-N-T-dE-Thr_PO3H2-Aca-D\nmeI-hHis-Aca-Cys_SEt-T-dK-Thr_PO3H2-Aca-Tyr_PO3H2-meI-hHis-Aca-Cys_SEt-T-dK-Thr_PO3H2-Aca-Tyr_PO3H2\nLys_Boc-hHis-Aca-Cys_SEt-T-dK-Thr_PO3H2-Aca-Tyr_PO3H2-Lys_Boc-hHis-Aca-Cys_SEt-T-dK-Thr_PO3H2-Aca-Tyr_PO3H2",[r.helm]:"seq\nPEPTIDE1{meI.D-gGlu.Aca.N.T.dE.Thr_PO3H2.Aca.D.Thr_PO3H2.Aca.D}$$$\nPEPTIDE1{meI.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.Aca.Tyr_PO3H2.Thr_PO3H2.Aca.Tyr_PO3H2}$$$\nPEPTIDE1{Lys_Boc.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.Aca.Tyr_PO3H2.Thr_PO3H2.Aca.Tyr_PO3H2}$$$"};async function d(t){const e=m[t],s=n.DataFrame.fromCsv(e.replace(/\n$/,""));return await l.data.detectSemanticTypes(s),s}(0,i.Bu)("fastaDna",(async()=>{await ot(await d(r.fastaDna),"seq",s)})),(0,i.Bu)("fastaRna",(async()=>{await ot(await d(r.fastaRna),"seq",s)})),(0,i.Bu)("fastaPt",(async()=>{await ot(await d(r.fastaPt),"seq",s)})),(0,i.Bu)("separatorDna",(async()=>{await ot(await d(r.separatorDna),"seq",s)})),(0,i.Bu)("separatorDna",(async()=>{await ot(await d(r.separatorRna),"seq",s)})),(0,i.Bu)("separatorPt",(async()=>{await ot(await d(r.separatorPt),"seq",s)})),(0,i.Bu)("separatorUn",(async()=>{await ot(await d(r.separatorUn),"seq",s)})),(0,i.Bu)("helm",(async()=>{await ot(await d(r.helm),"seq",s)})),(0,i.Bu)("ptFasta2",(async()=>{const t=await pt.files.readAsText("tests/to-atomic-level-pt-fasta-2.mol"),e=n.DataFrame.fromCsv("seq\nAR"),o=e.getCol("seq");o.semType=n.SEMTYPE.MACROMOLECULE,o.setTag(n.TAGS.UNITS,h.r2.FASTA),o.setTag("alphabet","PT"),u.Cn.getOrCreate(o);const r=await ot(e,"seq",s);(0,i.l_)(rt(r.get(0)),rt(t))}))}));var at=s(489);async function lt(t){const e=n.DataFrame.fromCsv(t),s=e.col("seq"),i=await l.functions.call("Bio:detectMacromolecule",{col:s});return i&&(s.semType=i),await l.data.detectSemanticTypes(e),u.Cn.getOrCreate(s)}function ct(t,e,s,n){const o=s(t,e);(0,i.l_)(Number(o.toFixed(3)),Number(n.toFixed(3)))}async function ht(t,e,s,n,o,r,a){await l.data.detectSemanticTypes(t);const h=await(0,c.activityCliffs)(t,t.getCol(s),t.getCol(n),o,e,a,{[`${c.BYPASS_LARGE_DATA_WARNING}`]:!0});(0,i.l_)(null!=h,!0);const u=Array.from(h.root.children).find((t=>{const e=t.className.split(" ");return["ui-btn","ui-btn-ok"].every((t=>e.includes(t)))}));(0,i.l_)(u.innerText.toLowerCase(),`${r} cliffs`)}(0,i.W3)("Distance",(async()=>{const t=[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]],e={F:0,W:1,R:2,Y:3},s="FWRWY",o="FWRWW",r="FWY",a="FWRWY",l="FWY",c="FWRRRRY";(0,i.Bu)("protein-distance-function",(async()=>{const t=(await lt("seq\nFWRWYVKHPFWRWYVKHP\nYNRWYVKHPYNRWYVKHP\nMWRSWYCKHPMWRSWYCKHP")).getDistanceFunctionName();(0,i.l_)(t,at.U.LEVENSHTEIN)})),(0,i.Bu)("DNA-distance-function",(async()=>{const t=(await lt("seq\nATAACGATAACG\nATCGAATCGA\nATCGAATCGA")).getDistanceFunctionName();(0,i.l_)(t,at.U.LEVENSHTEIN)})),(0,i.Bu)("MSA-distance-function",(async()=>{const t=(await lt("seq\nATAACATAAC\nATCGAATCGA\nATCGAATCGA")).getDistanceFunctionName();(0,i.l_)(t,at.U.HAMMING)})),(0,i.Bu)("levenstein-sub",(async()=>{const t=at.o[at.U.LEVENSHTEIN]();ct(s,o,t,.2)})),(0,i.Bu)("levenstein-del",(async()=>{const t=at.o[at.U.LEVENSHTEIN]();ct(r,a,t,.4)})),(0,i.Bu)("hamming",(async()=>{const t=at.o[at.U.HAMMING]();ct(r,a,t,.6)})),(0,i.Bu)("needleman-blosum62",(async()=>{const t=at.o[at.U.NEEDLEMANN_WUNSCH]({gapOpen:8,gapExtend:2});ct(s,o,t,-6)})),(0,i.Bu)("needleman-blosum62-del",(async()=>{const t=at.o[at.U.NEEDLEMANN_WUNSCH]({gapOpen:8,gapExtend:2});ct(r,a,t,-1.8)})),(0,i.Bu)("needleman-custom-sub",(async()=>{const n=at.o[at.U.NEEDLEMANN_WUNSCH]({scoringMatrix:t,alphabetIndexes:e,gapOpen:1,gapExtend:1});ct(s,o,n,.2)})),(0,i.Bu)("needleman-custom-del",(async()=>{const s=at.o[at.U.NEEDLEMANN_WUNSCH]({scoringMatrix:t,alphabetIndexes:e,gapOpen:1,gapExtend:1});ct(r,a,s,.8)})),(0,i.Bu)("needleman-custom-zero-extend",(async()=>{const s=at.o[at.U.NEEDLEMANN_WUNSCH]({scoringMatrix:t,alphabetIndexes:e,gapOpen:1,gapExtend:0});ct(l,c,s,.714)})),(0,i.Bu)("needleman-custom-half-extend",(async()=>{const s=at.o[at.U.NEEDLEMANN_WUNSCH]({scoringMatrix:t,alphabetIndexes:e,gapOpen:2,gapExtend:1});ct(l,c,s,1.286)})),(0,i.Bu)("needleman-custom-same-extend",(async()=>{const s=at.o[at.U.NEEDLEMANN_WUNSCH]({scoringMatrix:t,alphabetIndexes:e,gapOpen:1,gapExtend:1});n.Test.isInBenchmark?ct(Array(1e4).fill("FWRY").join(""),Array(1e4).fill("FYWRRY").join(""),s,.667):ct(l,c,s,1.143)}))}));var ut=s(116),mt=s(6361);async function dt(t,e,s){const n=t.getCol(s),o=await l.functions.call("Bio:detectMacromolecule",{col:n});o&&(n.semType=o);const r=await(0,c.sequenceSpaceTopMenu)(t,t.col(s),e,at.U.LEVENSHTEIN,!0,.6,{[`${c.BYPASS_LARGE_DATA_WARNING}`]:!0});(0,i.l_)(null!=r,!0)}(0,i.W3)("activityCliffs",(async()=>{let t,e,s=[],o=[];(0,i.bb)((async()=>{t=await(0,L.JN)(),e=await(0,P.nW)(),await(0,P.tb)(),await t.loadLibraries(!0),s=[],o=[]})),(0,i.X5)((async()=>{await(0,P.tW)(e),await t.loadLibraries(!0)})),(0,i.Bu)("activityCliffsOpens",(async()=>{const t=await T(n.Test.isInBenchmark?"test/peptides_motif-with-random_10000.csv":"tests/100_3_clustests.csv");o.push(t);const e=l.shell.addTableView(t);s.push(e);const i=n.Test.isInBenchmark?6:3;await ht(t,ut.AL.UMAP,"sequence","Activity",90,i,at.U.LEVENSHTEIN)})),(0,i.Bu)("activityCliffsWithEmptyRows",(async()=>{const t=await T("tests/100_3_clustests_empty_vals.csv");o.push(t);const e=l.shell.addTableView(t);s.push(e),await ht(t,ut.AL.UMAP,"sequence","Activity",90,3,at.U.LEVENSHTEIN)})),(0,i.Bu)("Helm",(async()=>{const t=await pt.files.readCsv("data/sample_HELM_50.csv");l.shell.addTableView(t),await ht(t,ut.AL.UMAP,"HELM","Activity",65,4,mt.gk.Tanimoto)}))})),(0,i.W3)("sequenceSpace",(async()=>{let t,e,s,o;(0,i.Bu)("sequenceSpaceOpens",(async()=>{t=await T(n.Test.isInBenchmark?"test/peptides_motif-with-random_10000.csv":"tests/100_3_clustests.csv"),e=l.shell.addTableView(t),await dt(t,ut.AL.UMAP,"sequence")})),(0,i.Bu)("sequenceSpaceWithEmptyRows",(async()=>{s=await T("tests/100_3_clustests_empty_vals.csv"),o=l.shell.addTableView(s),await dt(s,ut.AL.UMAP,"sequence")}))})),(0,i.W3)("Scoring",(()=>{const t="sequence",e="expected_similarity",s="expected_identity",o=n.DataFrame.fromCsv(`${t},${e},${s}\nPEPTIDE1{Aca.Orn.gGlu.Pqa.D-His_1Bn.dH.hHis.4Abz.D-Tic.D-Dap.Y.Iva.meS.F.P.F.D-1Nal}$$$$,1.0,1.0\nPEPTIDE1{Iva.Gly_allyl.gGlu.Pqa.D-Dip.dH.hHis.4Abz.D-aHyp.D-Dap.Y.Iva.I.Tyr_26diMe.P.Asu.meC}$$$$,0.68,0.53\nPEPTIDE1{[1Nal].[1Nal].[1Nal].[1Nal].[1Nal].[1Nal].[1Nal].[1Nal].[1Nal].[1Nal].[1Nal].[1Nal].[1Nal].[1Nal].[1Nal].[1Nal].[1Nal]}$$$$V2.0,0.34,0.0`),r=o.getCol(t);r.setTag(n.TAGS.UNITS,h.r2.HELM),r.semType=n.SEMTYPE.MACROMOLECULE;const a=r.get(0);let l,u;(0,i.bb)((async()=>{l=await(0,L.JN)(),u=await(0,P.nW)(),await(0,P.tb)(),await l.loadLibraries(!0)})),(0,i.X5)((async()=>{await(0,P.tW)(u),await l.loadLibraries(!0)})),(0,i.Bu)("Identity",(async()=>{const t=await(0,c.sequenceIdentityScoring)(o,r,a);for(let e=0;e<t.length;e++)(0,i.jh)(t.get(e),o.get(s,e),.01,`Wrong identity score for sequence at position ${e}`)})),(0,i.Bu)("Similarity",(async()=>{const t=await(0,c.sequenceSimilarityScoring)(o,r,a);for(let s=0;s<t.length;s++)(0,i.jh)(t.get(s),o.get(e,s),.01,`Wrong similarity score for sequence at position ${s}`)}))}));const pt=new n.Package},2991:(t,e,s)=>{"use strict";s.r(e),s.d(e,{BYPASS_LARGE_DATA_WARNING:()=>ms,GetRegionEditor:()=>bs,SeqActivityCliffsEditor:()=>Es,SeqPaletteCustom:()=>gs,SequenceSpaceEditor:()=>Ss,SplitToMonomersEditor:()=>As,SubsequenceSearchTopMenu:()=>en,_package:()=>us,activityCliffs:()=>Fs,addCopyMenu:()=>un,alignSequences:()=>Bs,bioSubstructureFilter:()=>rn,compositionAnalysis:()=>ks,compositionAnalysisWidget:()=>Is,convertDialog:()=>$s,demoBioActivityCliffs:()=>pn,demoBioAtomicLevel:()=>gn,demoBioHelmMsaSequenceSpace:()=>fn,demoBioSequenceSpace:()=>dn,demoBioSimilarityDiversity:()=>mn,detectMacromoleculeProbe:()=>Cn,diversitySearchTopMenu:()=>Qs,diversitySearchViewer:()=>Js,fastaSequenceCellRenderer:()=>vs,getBioLib:()=>ws,getHelmMonomers:()=>zs,getMonomerLibHelper:()=>ds,getRegion:()=>Os,getRegionApp:()=>cn,getRegionHelmApp:()=>hn,getRegionPanel:()=>Cs,getRegionTopMenu:()=>Gs,hydrophobPalette:()=>ps,importBam:()=>Vs,importFasta:()=>Us,initBio:()=>fs,libraryPanel:()=>Ts,macroMolColumnPropertyPanel:()=>Ns,macromoleculeDifferenceCellRenderer:()=>Ps,monomerCellRenderer:()=>qs,multipleSequenceAlignmentDialog:()=>Ws,packageSettingsEditor:()=>Ms,polyTool:()=>Ys,polyToolColumnChoice:()=>yn,saveAsFasta:()=>on,sdfToJsonLib:()=>wn,searchSubsequenceEditor:()=>tn,separatorSequenceCellRenderer:()=>Ls,sequenceAlignment:()=>_s,sequenceIdentityScoring:()=>sn,sequenceSimilarityScoring:()=>nn,sequenceSpaceTopMenu:()=>Ds,sequenceTooltip:()=>ys,similaritySearchTopMenu:()=>js,similaritySearchViewer:()=>Xs,splitToMonomersTopMenu:()=>Zs,testDetectMacromolecule:()=>Ks,toAtomicLevel:()=>Hs,vdRegionsViewer:()=>xs,webLogoAggApp:()=>ln,webLogoLargeApp:()=>an,webLogoViewer:()=>Rs});var n=s(4469),i=s(3870),o=s(976),r=s(1061);s(9133);var a=s(116),l=s(5697),c=s(1040),h=s(489);const u={[o.SEMTYPE.MOLECULE]:"Molecules",[o.SEMTYPE.MACROMOLECULE]:"Sequences"},m="show-scatterplot-progress";class d{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=i.inputs([]),this.similarityThresholdObj={"Similarity threshold":0},this.methodsParams={[a.AL.UMAP]:new a.bD,[a.AL.T_SNE]:new a.aP},this.tableInput=i.tableInput("Table",n.shell.tv.dataFrame,void 0,(()=>{this.onTableInputChanged(t)})),this.tableInput.value=n.shell.tv.dataFrame,this.molColInput=i.columnInput(u[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=i.choiceInput("Method",a.AL.UMAP,[a.AL.UMAP,a.AL.T_SNE],(()=>{e&&this.createAlgorithmSettingsDiv(this.methodSettingsDiv,this.methodsParams[this.methodInput.value]),this.displaySimilarityThresholdInput(t)})),this.regenerateThresholdInput(0,1),i.input.forProperty(o.Property.fromOptions({type:o.TYPE.FLOAT,name:"Similarity threshold",min:0,max:1})),this.initSimilarityMetricInput(t),this.methodSettingsIcon=i.icons.settings((()=>{e=!e,e?this.createAlgorithmSettingsDiv(this.methodSettingsDiv,this.methodsParams[this.methodInput.value]):i.empty(this.methodSettingsDiv)}),"Modify methods parameters"),this.methodInput.root.classList.add("ml-dim-reduction-settings-input"),this.methodInput.root.prepend(this.methodSettingsIcon),this.methodSettingsDiv=i.inputs([]);let e=!1;setTimeout((()=>{this.displaySimilarityThresholdInput(t),this.onColumnInputChanged(t)}))}regenerateThresholdInput(t,e){const s=o.Property.fromOptions({name:"Similarity threshold",type:o.TYPE.FLOAT,showSlider:!0,min:t,max:e,nullable:!1});this.similarityThresholdObj["Similarity threshold"]=t;const n=i.input.form(this.similarityThresholdObj,[s]),r=n.getElementsByClassName("ui-input-root")[0];let a=this.similarityThresholdInput??null;return a&&(i.empty(a),a.append(r)),this.similarityThresholdInput=n,i.tooltip.bind(this.similarityThresholdInput,"Similarity threshold for sparse matrix creation."),this.similarityThresholdInput}createAlgorithmSettingsDiv(t,e){return i.empty(t),Object.keys(e).forEach((s=>{const n=e[s],o=i.floatInput(n.uiName,n.value,(()=>{n.value=o.value}));i.tooltip.bind(o.root,n.tooltip),t.append(o.root)})),t}onTableInputChanged(t){this.molColInput=i.columnInput(u[t],this.tableInput.value,this.tableInput.value.columns.bySemType(t)),this.molColInput.onChanged((()=>this.onColumnInputChanged(t))),i.empty(this.molColInputRoot),Array.from(this.molColInput.root.children).forEach((t=>this.molColInputRoot.append(t))),this.displaySimilarityThresholdInput(t),this.onColumnInputChanged(t)}initSimilarityMetricInput(t){const e=this.molColInput.value;if(!e)return;this.similarityMetricInputRoot&&i.empty(this.similarityMetricInputRoot);const s=t===o.SEMTYPE.MOLECULE||"helm"===e.getTag("units")?i.choiceInput("Similarity",c.gk.Tanimoto,l.Rt):i.choiceInput("Similarity",h.U.HAMMING,l.bc);this.similarityMetricInputRoot||(this.similarityMetricInputRoot=s.root),this.similarityMetricInputRoot&&Array.from(s.root.children).forEach((t=>this.similarityMetricInputRoot.append(t))),this.similarityMetricInput=s,this.similarityMetricInput.value=t===o.SEMTYPE.MOLECULE||"helm"===e.getTag("units")?c.gk.Tanimoto:h.U.HAMMING}onColumnInputChanged(t){const e=this.molColInput.value;if(!e)return;if(this.initSimilarityMetricInput(t),t!==o.SEMTYPE.MACROMOLECULE||"helm"===e.getTag("units"))return;const s=(e.getTag("aligned")??" ").toUpperCase().includes("MSA");this.similarityMetricInput.value=s?h.U.HAMMING:h.U.LEVENSHTEIN}displaySimilarityThresholdInput(t){t!==o.SEMTYPE.MOLECULE&&this.tableInput.value&&this.tableInput.value.rowCount>2e4&&this.methodInput.value===a.AL.UMAP?this.similarityThresholdInput.style.display="block":this.similarityThresholdInput.style.display="none"}}class p extends d{get funcParams(){return{table:this.tableInput.value,molecules:this.molColInput.value,methodName:this.methodInput.value,similarityMetric:this.similarityMetricInput.value,sparseMatrixThreshold:this.similarityThresholdObj["Similarity threshold"]??0,plotEmbeddings:this.plotEmbeddingsInput.value,options:this.algorithmOptions}}get paramsUI(){return this.funcParamsDiv}constructor(t){super(t),this.plotEmbeddingsInput=i.boolInput("Plot embeddings",!0),this.funcParamsDiv=i.inputs([this.tableInput,this.molColInput,this.methodInput,this.methodSettingsDiv,this.similarityMetricInputRoot,this.similarityThresholdInput,this.plotEmbeddingsInput],{style:{minWidth:"320px"}})}}class g extends d{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=i.columnInput("Activities",this.tableInput.value,o.Utils.firstOrNull(e),null,{filter:t=>Array.from(e).includes(t)}),this.activitiesInputRoot=this.activitiesInput.root,this.similarityInput=i.intInput("Similarity cutoff",80),i.tooltip.bind(this.similarityInput.root,"Pairs of similar (cutoff is used) molecules with high difference in activity are considered 'cliffs'"),this.funcParamsDiv=i.inputs([this.tableInput,this.molColInput,this.activitiesInput,this.similarityInput,this.methodInput,this.methodSettingsDiv,this.similarityMetricInputRoot],{style:{minWidth:"320px"}})}onTableInputChanged(t){super.onTableInputChanged(t),i.empty(this.activitiesInputRoot);const e=this.tableInput.value.columns.numerical;this.activitiesInput=i.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 f=s(701),y=s(3379),w=s.n(y),C=s(7795),T=s.n(C),b=s(569),A=s.n(b),S=s(3565),E=s.n(S),M=s(9216),v=s.n(M),N=s(4589),I=s.n(N),L=s(9414),P={};P.styleTagTransform=I(),P.setAttributes=E(),P.insert=A().bind(null,"head"),P.domAPI=T(),P.insertStyleElement=v(),w()(L.Z,P),L.Z&&L.Z.locals&&L.Z.locals;var _=s(2590),R=s(9657);let x=0;const O="cliffsDf",G="cliffs_col_encode_fn",F=new f.Subject,D="act_diff",H="sali",W="sim",B="line_index",k=["1_seq","2_seq"],U="filterCliffs";async function V(t,e,s){const n=t.distance.map(((e,n)=>{const i=Math.abs(s.get(t.i[n])-s.get(t.j[n]));return 0!=e?i/e:1/0})),i=t.distance.map((t=>1-t)),o=t.i,r=t.j,a=new Set;return t.distance.forEach(((e,s)=>{a.add(t.i[s]),a.add(t.j[s])})),{simVals:i,saliVals:n,n1:o,n2:r,cliffsMolIds:a}}function $(t,e,s){const n=e.getBoundingClientRect(),i=t.clientX-n.left,o=t.clientY-n.top;let r=null,a=0;for(const t of s){const e=Math.abs(Math.hypot(t.a[0]-i,t.a[1]-o)+Math.hypot(t.b[0]-i,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 Y,q=s(499),K=s(5226),Z=s(7228),z=s(8457),X=s(585);async function j(t,e,s,n){const i=(0,z.O)(e),r=(0,X.vU)(e.getTag(o.TAGS.UNITS),e.getTag("separator"))(s),a=n===Y.IDENTITY?function(t,e){const s=e.columns.length,n=new Array(s),i=new Array(s),r=new Array(s);for(let o=0;o<s;++o){const s=e.columns.byIndex(o);n[o]=s.getRawData(),i[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)n[e][s]===r[e]&&++l[s];l[s]/=t.length}return a}(r,i):n===Y.SIMILARITY?await async function(t,e){const s=e.columns.toList();return await(0,Z.Qx)(s,t)}(r,i):null;if(null===a)throw new Error(`In bio library: Unkown sequence scoring method: ${n}`);return a.name=t.columns.getUnusedName(a.name),t.columns.add(a),a}!function(t){t.IDENTITY="identity",t.SIMILARITY="similarity"}(Y||(Y={}));var J=s(4293),Q=s(6414),tt=s.n(Q);const et="rgb(100,100,100)",st="#808080",nt="rgb(0,0,0)",it=X.GU;var ot,rt;function at(t,e,s,n,i,o,r=et,a=0,l=!1,c=1,h="",u=!1,m=rt.classic,d=[],p=0,g=null,f=[],y=null,w={}){i.textAlign="start";let C=o.substring(0),T=u?"":h;m===rt.MSA&&(T="");let b=!0,A=!0,S="difference";null!=g&&null!=g.cell.column&&(b=g.cell.column.temp["color-code"]??!0,A=g.cell.column.temp["compare-with-current"]??!0,S=g.cell.column.temp["highlight-difference"]??"difference");const E=f[p];A&&f.length>0&&"difference"===S&&(c=C==E?.3:c),A&&f.length>0&&"equal"===S&&(c=C!=E?.3:c),null!=y&&(C=it(C,y));const M=C+T;w[M]??(w[M]=i.measureText(M));let v=w[M];w[C]??(w[C]=i.measureText(C));let N=w[C].width;w[T]??(w[T]=i.measureText(T));const I=w[T].width,L=n/2-(v.fontBoundingBoxAscent+v.fontBoundingBoxDescent)/2+1;function P(s,n){const o=b?r:nt;i.fillStyle=o,i.globalAlpha=c,m===rt.classic&&(i.fillText(C,t+s,e+L),i.fillStyle=st,i.fillText(T,t+n,e+L)),m===rt.MSA&&i.fillText(C,t+s,e+L)}v=v.width,m===rt.MSA&&(N=d[p],v=d[p]);const _=(d[p]??0)-(d[0]??0);if(l||v>s)return P(_,_+N),t+_+N+I;{const e=(s-v)/2;return P(e,e+N),t+_+e+N}}!function(t){t.maxMonomerLength=".mm.cellRenderer.maxMonomerLength"}(ot||(ot={})),function(t){t.MSA="MSA",t.classic="classic"}(rt||(rt={}));var lt,ct=s(9611),ht=s(8447),ut=s(7331);!function(t){t.long="long",t.short="short"}(lt||(lt={}));const mt={true:"1",false:"0"};var dt=s(3553),pt=s(7958);const gt="rgb(100,100,100)",ft=ht.GU;function yt(t,e,s,n,i){return t?Math.max(Math.min(t.canvas.width/i-s,n)):Math.max(e.canvas.width/i-s,0)}function wt(t){const e=!tt().enumerate(t).some((([e,s])=>e.length>1&&0!=s&&s!=t.length-1)),s=[],n=e?"":" ";for(const[e,i]of tt().enumerate(t)){let o=e;i<t.length&&(o+=`${e?"":"-"}${n}`),s.push(o)}return[s,e]}class Ct 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=[i.div(t)];if(s._monomerStructureMap[t])o.push(s._monomerStructureMap[t]);else{const e=s.getMonomer(t);if(e){const i={autoCrop:!0,autoCropMargin:0,suppressChiralText:!0},r=n.chem.svgMol(e.smiles,void 0,void 0,i);o.push(r),s._monomerStructureMap[t]=r}}i.tooltip.show(i.divV(o),e.x+16,e.y+16)}else i.tooltip.hide()}render(t,e,s,n,i,r,a){let l,c=0,h=50;try{l=r.grid}catch(t){l=void 0;const[e,s]=(0,pt.yf)(t);us.logger.error(e,void 0,s)}const u=r.cell.column;if(!l||!u)return;const m=u.temp,d=m["monomer-width"];if("short"===(null!=d?d:"short")){const t=parseInt(u.getTag(ot.maxMonomerLength));h=(isNaN(t)?us.properties?.MaxMonomerLength:t)??4}let p=u.temp["bio-seqCol"];p||(p=new ct.A(l,u,(()=>{const t=q.Cn.getOrCreate(u);return{unitsHandler:t,monomerCharWidth:7,separatorWidth:t.isMsa()?8:c,monomerToShort:ft,monomerLengthLimit:h,monomerLib:ws()}}))),u.tags[".mm.cellRenderer.settingsChanged"]===mt.true&&(c=m[".mm.cellRenderer.gapLength"]??c,p.setMonomerLengthLimit(h),p.setSeparatorWidth(p.isMsa()?8:c),u.setTag(".mm.cellRenderer.settingsChanged",mt.false));const[g,f]=p.getCellMonomerLengths(r.tableRowIndex);g.length,p.updated&&(m["bio-seqCol"]=p),t.save();try{const a=window.devicePixelRatio,l=-1!==r.gridRow?r.grid:null,c=r.cell.value,d=u.getTag("alphabet"),g=50;n=yt(l,t,e,n,a),t.beginPath(),t.rect(e+this.padding,s+this.padding,n-this.padding-1,i-2*this.padding),t.clip(),t.font="12px monospace",t.textBaseline="top";const y=u.getTag(o.TAGS.UNITS),w=u.getTag("aligned"),C=(0,ht.py)(d),T=u.getTag("separator")??"",b=n/5,A=q.Cn.getOrCreate(u).getSplitter(b),S=m["reference-sequence"],E=m["current-word"],M=A(null!=S&&""!=S?S:E??""),v=A(c);let N=gt,I=rt.classic;w&&w.includes("MSA")&&y==ht.r2.SEPARATOR&&(I=rt.MSA);for(const[o,a]of tt().enumerate(v)){N=C.get(o),t.fillStyle=gt;const l=a===v.length-1;if(at(e+this.padding,s,n,i,t,o,N,0,!0,1,T,l,I,f,a,r,M,h,p._monomerLengthMap),g>n)break}}catch(t){const e=t instanceof Error?t.message:t?t.toString():"Error 'undefined'";us.logger.error(`Bio: MacromoleculeSequenceCellRenderer.render() error: ${e}`)}finally{t.restore()}}}class Tt extends o.GridCellRenderer{get name(){return"MacromoleculeDifferenceCR"}get cellType(){return dt.Of.MACROMOLECULE_DIFFERENCE}get defaultHeight(){return 30}get defaultWidth(){return 230}render(t,e,s,n,i,r,a){const l=window.devicePixelRatio,c=r.grid,h=r.cell,u=r.tableColumn,m=h.value??"",d=u.tags.separator,p=u.tags[o.TAGS.UNITS];n=yt(c,t,e,n,l);const[g,f]=m.split("#"),y=(0,X.vU)(p,d);bt(t,e,s,n,i,y(g),y(f),p)}}function bt(t,e,s,n,i,o,r,a,l,c){if(o.length!==r.length){const t=function(t,e){let s=0,n=0;const i=t.length>e.length?t:e,o=t.length>e.length?e:t;for(let t=0;t<o.length;t++)i[t]===o[t]&&s++;const r=i.length-o.length;for(let t=i.length-1;t>r;t--)i[t]===o[t-r]&&n++;const a=new Array(Math.abs(t.length-e.length)).fill("");function l(t){return s>n?t.concat(a):a.concat(t)}return t.length>e.length?e=l(e):t=l(t),{subParts1:t,subParts2:e}}(tt()(o).toArray(),tt()(r).toArray());o=t.subParts1,r=t.subParts2}const h=t.measureText(wt(o).join("")),u=t.measureText(wt(r).join("")),m=Math.max(h.width,u.width);l&&(n=m+4*o.length,t.canvas.width=m+4*o.length);let d=Math.max(e,e+(n-(m+4*o.length))/2)+5;const p=Math.max(s,s+(i-28)/2);t.save(),t.beginPath(),t.rect(e,s,l?m+4*o.length:n,i),t.clip(),t.font="12px monospace",t.textBaseline="top";let g=ut.UE.Color;"HELM"!=a&&(g=(0,ht.py)(a.substring(a.length-2)));for(let e=0;e<o.length;e++){const s=o[e],a=r[e],l=g.get(s);if(s!=a){const o=g.get(a),r=at(d,p-7,n,i,t,s,l,0,!0),h=at(d,p+7,n,i,t,a,o,0,!0);d=Math.max(h,r),c&&(c[e]=At(s,a,l,o,p,7,i))}else d=at(d,p,n,i,t,s,l,0,!0,.5);d+=4}t.restore()}function At(t,e,s,n,i,o,r){const a=document.createElement("canvas"),l=a.getContext("2d");l.font="12px monospace";const c=l.measureText(wt([t]).join("")).width,h=l.measureText(wt([e]).join("")).width,u=Math.max(c,h);return a.height=r,a.width=u+4,l.font="12px monospace",l.textBaseline="top",at(0,i-o,u,r,l,t,s,0,!0),at(0,i+o,u,r,l,e,n,0,!0),a}var St,Et=s(9298);!function(t){t.Unknown="unknown",t.FR="framework",t.CDR="cdr"}(St||(St={}));const Mt=new class{constructor(){this.regionTypes=[St.CDR],this.chains=["Heavy","Light"],this.skipEmptyPositions=!1,this.fitWidth=!1,this.positionWidth=16,this.positionHeight=Et.ES.Entropy,this.filterSource=Et.vS.filterSource}};var vt=s(8415);const Nt=St;var It,Lt;!function(t){t.STYLE="Style",t.BEHAVIOR="Behavior",t.LAYOUT="Layout",t.DATA="Data"}(It||(It={})),function(t){t.skipEmptyPositions="skipEmptyPositions",t.regionTypes="regionTypes",t.chains="chains",t.fitWidth="fitWidth",t.positionWidth="positionWidth",t.positionHeight="positionHeight",t.filterSource="filterSource"}(Lt||(Lt={}));const Pt=Mt;class _t 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.setDataInProgress=!1,this.host=null,this.mainLayout=null,this.logos=[],this.viewSubs=[],this.calcSizeRequested=!1,this.skipEmptyPositions=this.bool(Lt.skipEmptyPositions,Pt.skipEmptyPositions,{category:It.DATA}),this.regionTypes=this.stringList(Lt.regionTypes,Pt.regionTypes,{category:It.DATA,choices:Object.values(Nt).filter((t=>t!=Nt.Unknown))}),this.chains=this.stringList(Lt.chains,Pt.chains,{category:It.DATA,choices:["Heavy","Light"]}),this.fitWidth=this.bool(Lt.fitWidth,Pt.fitWidth,{category:It.LAYOUT}),this.positionWidth=this.float(Lt.positionWidth,Pt.positionWidth,{category:It.LAYOUT,editor:"slider",min:0,max:64,description:"Internal WebLogo viewers property width of position."}),this.positionHeight=this.string(Lt.positionHeight,Pt.positionHeight,{category:It.LAYOUT,choices:Object.keys(Et.ES)}),this.filterSource=this.string(Lt.filterSource,Pt.filterSource,{category:It.BEHAVIOR,choices:Object.values(Et.Ct)})}async init(){this.subs.push((0,f.fromEvent)(this.root,"mousemove").subscribe(this.rootOnMouseMove.bind(this)))}detach(){const t=super.detach.bind(this);this.viewPromise=this.viewPromise.then((async()=>{this.setDataInProgress||(this.viewed&&(await this.destroyView("detach"),this.viewed=!1),t())})).catch((t=>{const[e,s]=(0,pt.yf)(t);us.logger.error(e,void 0,s)}))}onTableAttached(){super.onTableAttached(),this.setData(this.regions)}onPropertyChanged(t){if(super.onPropertyChanged(t),t){switch(t.name){case Lt.regionTypes:case Lt.chains:this.setData(this.regions)}switch(t.name){case Lt.skipEmptyPositions:for(let t=0;t<this.logos.length;++t)for(const e of this.chains)this.logos[t][e].setOptions({[vt.bo.skipEmptyPositions]:this.skipEmptyPositions});this.calcSize();break;case Lt.fitWidth:case Lt.positionWidth:this.calcSize();break;case Lt.positionHeight:for(let t=0;t<this.logos.length;++t)for(const e of this.chains)this.logos[t][e].setOptions({[vt.bo.positionHeight]:this.positionHeight});this.calcSize();break;case Lt.filterSource:this.filterSourceInput.value=this.filterSource;break;default:this.setData(this.regions)}}else console.warn("Bio: VdRegionsViewer.onPropertyChanged() property is null")}setData(t){us.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),this.regions=t,this.viewed||(await this.buildView("setData"),this.viewed=!0)}catch(t){const[e,s]=(0,pt.yf)(t);n.shell.error(e),us.logger.error(e,void 0,s)}finally{this.setDataInProgress=!1}}}))}async destroyView(t){us.logger.debug(`Bio: VdRegionsViewer.destroyView( mainLayout = ${this.mainLayout?"value":"none"} ), purpose = '${t}', this.regions.length = ${this.regions.length}`),this.filterSourceInput&&i.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){us.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(),n=[];for(let t=0;t<s.length;t++)for(const i of this.chains){const o=e.find((e=>e.order==s[t]&&e.chain==i));n.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,i,e]})())}const o=await Promise.all(n);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=i.table(this.chains,(t=>[...s.length>0?[i.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%",i.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=i.choiceInput("Data source",this.filterSource,Object.values(Et.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=i.div([this.mainLayout,this.filterSourceInput.root],{}),this.root.appendChild(this.host),this.root.style.overflowX="auto",this.calcSize(),this.viewSubs.push(i.onSizeChanged(this.root).subscribe(this.rootOnSizeChanged.bind(this))),us.logger.debug("Bio: VdRegionsViewer.buildView() end")}calcSize(){us.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,n=9,i=(this.root.clientWidth-t-(this.logos.length-1)*n-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({[vt.bo.positionWidth]:i-s.positionMarginValue}),s.root.style.width=i*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({[vt.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(Lt.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({[vt.bo.filterSource]:this.filterSource})}}}))}}var Rt=s(9017),xt=s(850);const Ot="dimensionality-reducer-terminate-event";async function Gt(t,e,i,o,r,a){const l=await async function(t,e,i,o,r){return new Promise((function(a,l){const c=new Worker(new URL(s.p+s.u(931),s.b));c.postMessage({columnData:t.data,method:e,measure:t.metric,options:i,parallelDistanceWorkers:o});const h=n.events.onCustomEvent(Ot).subscribe((()=>{try{c?.terminate()}finally{h.unsubscribe()}}));c.onmessage=({data:{error:t,distance:e,embedding:s,epochNum:n,epochsLength:i}})=>{n&&i?r&&r(n,i,s):(h.unsubscribe(),t?l(t):a({distance:e,embedding:s}),setTimeout((()=>c.terminate()),0))}}))}({data:t,metric:i},e,o,r,a);return l.embedding=l.embedding.map((t=>(0,xt.Fv)(t))),l}var Ft=s(7983);async function Dt(t){return t.seqCol.version!==t.seqCol.temp["last-invalidated-version"]&&await(0,Ft.HV)(t.seqCol,!1),await n.functions.call("Chem:getChemSpaceEmbeddings",{col:t.seqCol.temp["monomeric-mols"],methodName:t.methodName,similarityMetric:t.similarityMetric,xAxis:t.embedAxesNames[0],yAxis:t.embedAxesNames[1],options:t.options})}async function Ht(t,e){const s=q.Cn.getOrCreate(t),n=t.toList(),i=s.getSplitter(),o=n.length;let r=36;const a=new Map;for(let e=0;e<o;e++){const s=n[e];if(null===n[e]||t.isNone(e)){n[e]=null;continue}n[e]="";const o=i(s);for(let t=0;t<o.length;t++){const s=o[t];a.has(s)||(a.set(s,String.fromCharCode(r)),r++),n[e]+=a.get(s)}}let l={};if(e===h.U.MONOMER_CHEMICAL_DISTANCE){const t=Array.from(a.keys()),e=await(0,Z.PF)(t);e.scoringMatrix.forEach(((t,s)=>{t.forEach(((t,n)=>{e.scoringMatrix[s][n]=1-t}))}));const s={};Object.entries(e.alphabetIndexes).forEach((([t,e])=>{s[a.get(t)]=e})),l={scoringMatrix:e.scoringMatrix,alphabetIndexes:s}}else if(e===h.U.NEEDLEMANN_WUNSCH){const t=Array.from(a.keys()),e=await(0,Z.PF)(t),s={};Object.entries(e.alphabetIndexes).forEach((([t,e])=>{s[a.get(t)]=e})),l={scoringMatrix:e.scoringMatrix,alphabetIndexes:s}}return{seqList:n,options:l}}async function Wt(t,e){if(q.Cn.getOrCreate(t.seqCol).isHelm())return await Dt(t);const{seqList:s,options:n}=await Ht(t.seqCol,t.similarityMetric);t.options=t.options??{},t.options.distanceFnArgs=n;const i=await Gt(s,t.methodName,t.similarityMetric,t.options,!0,e),r=t.embedAxesNames.map(((t,e)=>o.Column.fromFloat32Array(t,i.embedding[e])));return{distance:i.distance,coordinates:new o.ColumnList(r)}}function Bt(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 kt=s(6361);function Ut(t){const e=i.divH([]),s=i.divV([i.divText(t.seqCol.name),i.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,n)=>{const o=i.divText(t.activityCol.get(s).toFixed(2));o.style.display="flex",o.style.justifyContent="left",o.style.paddingLeft="30px",e.append(i.divV([i.divText(t.seqCol.get(s)),o]))})),e}function Vt(t){const e=i.div();e.append(i.divText(t.seqCol.name,{style:{fontWeight:"bold"}}));const s=new Array(2),n=new Array(2);t.line.mols.forEach(((e,i)=>{s[i]=t.seqCol.get(e),n[i]=t.activityCol.get(e)}));const o={},r=q.Cn.getOrCreate(t.seqCol),a=r.getSplitter(),l=Yt(a(s[0]),a(s[1]),r.units,o);return e.append(i.div(l,{style:{width:"300px",overflow:"scroll"}})),e.append(qt(o)),e.append($t("Activity delta",Math.abs(n[0]-n[1]))),e.append($t("Cliff",t.sali)),e}function $t(t,e){return i.divH([i.divText(`${t}: `,{style:{fontWeight:"bold",paddingRight:"5px"}}),i.divText(e.toFixed(2))],{style:{paddingTop:"10px"}})}function Yt(t,e,s,n){const i=document.createElement("canvas"),o=i.getContext("2d");return i.height=30,bt(o,0,0,0,30,t,e,s,!0,n),i}function qt(t){const e=i.div();if(Object.keys(t).length>0){const s=i.divV([]);s.append(i.divH([i.divText("Pos",{style:{fontWeight:"bold",width:"30px",borderBottom:"1px solid"}}),i.divText("Difference",{style:{fontWeight:"bold",borderBottom:"1px solid"}})]));for(const e of Object.keys(t))t[e].style.borderBottom="1px solid lightgray",s.append(i.divH([i.divText((parseInt(e)+1).toString(),{style:{width:"30px",borderBottom:"1px solid lightgray"}}),t[e]]));e.append(s)}return e}function Kt(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 n=t.plot.grid();return n.col(e[0]).visible=!1,n.col(e[1]).visible=!1,n}class Zt 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",l.kg[0],{choices:l.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(i.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&&(n.shell.error(`${this.moleculeColumnName} is not Macromolecule type`),1))}}var zt=s(7241),Xt=s(2669);async function jt(t){const e=t.toList();if(t.semType!==o.SEMTYPE.MACROMOLECULE)throw new Error("Column has to be of macromolecule type");const s=q.Cn.getOrCreate(t).getDistanceFunctionName(),n=new Xt.m(!0,!1),i=await n.calc(e,s);return n.terminate(),i}function Jt(t){return(e,s)=>{const n=(e,s)=>t*e+s-Math.floor((e+2)*(e+1)/2);return e<=s?n(e,s):n(s,e)}}class Qt extends Zt{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 f.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=q.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 i=s.plot.grid();i.col("indexes").visible=!1;const r=this.idxs?.getRawData().findIndex((t=>t==this.targetMoleculeIdx));i.cell("score",r).cell.value=null,n.shell.v.grid.root.addEventListener("click",(t=>{this.gridSelect=!1})),(0,J.Y)(this.root,i.root),this.computeCompleted.next(!0)}}async computeByChem(){const t=await(0,zt.D)(this.moleculeColumn),e=(o.DataFrame.fromColumns([t]),await n.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 jt(this.moleculeColumn),this.distanceMatrixComputed=!0):this.preComputeDistanceMatrix||(t=await async function(t,e){const n=t.toList();if(t.semType!==o.SEMTYPE.MACROMOLECULE)throw new Error("Column has to be of macromolecule type");const i=q.Cn.getOrCreate(t).getDistanceFunctionName(),r=Math.min(Math.max(navigator.hardwareConcurrency-2,1),n.length),a=new Array(r).fill(null).map((t=>new Worker(new URL(s.p+s.u(190),s.b)))),l=new Float32Array(n.length);let c=0,h=Number.MIN_VALUE;const u=a.map(((t,s)=>{const o=Math.floor(s*n.length/r),u=s===a.length-1?Math.floor((s+1)*n.length/r):n.length;return new Promise(((s,r)=>{t.onmessage=({data:{error:t,distanceArrayData:e,min:n,max:i}})=>{t?r(t):(c=Math.min(c,n),h=Math.max(h,i),l.set(e,o),s())},t.postMessage({fnName:i,values:n,templateIdx:e,start:o,end:u})}))}));try{await Promise.all(u),l.forEach(((t,e)=>{l[e]=(t-c)/(h-c)})),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,n=Jt(e),i=Array(e).fill(0).map(((e,s)=>({idx:s,score:s===this.targetMoleculeIdx?1:this.preComputeDistanceMatrix?1-this.mmDistanceMatrix[n(this.targetMoleculeIdx,s)]:1-t[s]})));i.sort(((t,e)=>e.score-t.score));const r=Math.min(this.limit,e),a=i.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=i.div(),s={},o=this.molCol?.name,r=t.col(o),a=q.Cn.getOrCreate(r),l=a.getSplitter(),c=l(this.moleculeColumn.get(this.targetMoleculeIdx)),h=l(t.get(o,t.currentRowIdx)),u=Yt(c,h,a.units,s);e.append(i.div(u,{style:{width:"300px",overflow:"scroll"}})),c.length!==h.length&&e.append(i.divV([i.divText("Different sequence length:",{style:{fontWeight:"bold"}}),i.divText(`target: ${c.length} monomers`),i.divText(`selected: ${h.length} monomers`)],{style:{paddingBottom:"10px"}})),e.append(qt(s));const m=i.accordion(),d=i.element("i");d.className="grok-icon svg-icon svg-view-layout",m.addTitle(i.span([d,i.label("Similarity search")])),m.addPane("Differences",(()=>e),!0),n.shell.o=m.root}}var te=s(8518);class ee extends Zt{constructor(){super("diversity"),this.renderMolIds=null,this.columnNames=[],this.computeCompleted=new f.Subject,this.diverseColumnLabel=this.string("diverseColumnLabel",null)}async renderInt(t){if(this.beforeRender()&&this.dataFrame&&t&&this.moleculeColumn){const t=q.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 n=o.DataFrame.fromColumns([s]);n.onCurrentRowChanged.subscribe((t=>{this.dataFrame.currentRowIdx=this.renderMolIds[n.currentRowIdx]})),(0,J.Y)(this.root,n.plot.grid().root),this.computeCompleted.next(!0)}}async computeByChem(){const t=await(0,zt.D)(this.moleculeColumn);o.DataFrame.fromColumns([t]),this.renderMolIds=await n.functions.call("Chem:callChemDiversitySearch",{col:t,metricName:this.distanceMetric,limit:this.limit,fingerprint:this.fingerprint})}async computeByMM(){const t=await jt(this.moleculeColumn),e=this.moleculeColumn.length,s=Jt(e);this.renderMolIds=(0,te.L)(e,Math.min(e,this.limit),((e,n)=>this.moleculeColumn.isNone(e)||this.moleculeColumn.isNone(n)?0:t[s(e,n)]))}}var se,ne=s(4004),ie=s(9943),oe=s(4413),re=s(2918),ae=function(t,e,s,n){return new(s||(s=Promise))((function(i,o){function r(t){try{l(n.next(t))}catch(t){o(t)}}function a(t){try{l(n.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof s?e:new s((function(t){t(e)}))).then(r,a)}l((n=n.apply(t,e||[])).next())}))};class le{constructor(t,e,s=!1,n){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=i.div([],{id:"demo-script",classes:"tutorials-root tutorials-track demo-app-script"}),this._steps=[],this._mainHeader=i.panel([],"tutorials-main-header"),this._header=i.h2(""),this._headerDiv=i.divH([],"tutorials-root-header"),this._stopStartBtn=i.button(i.iconFA("pause"),(()=>this._changeStopState()),"Play / pause"),this._restartBtn=i.button(i.iconFA("redo"),(()=>this._restartScript()),"Restart"),this._nextStepBtn=i.button(i.iconFA("play"),(()=>{this._isStepProcessed||this._nextStep()}),"Next step"),this._activity=i.panel([],"tutorials-root-description"),this._progressDiv=i.divV([],"tutorials-root-progress"),this._progress=i.element("progress"),this._progressSteps=i.divText(""),this._closeBtn=i.button(i.iconFA("chevron-left"),(()=>this._closeDock()),"Back to demo"),this.name=t,this.description=e,this._isAutomatic=s,this._autoStartFirstStep=null!==(o=null==n?void 0:n.autoStartFirstStep)&&void 0!==o&&o,this._progress.max=0,this._progress.value=1,le.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=i.divText(`Step: ${this._progress.value} of ${this.stepNumber}`),this._progressDiv.append(this._progressSteps)}_addDescription(){var t;this._activity.append(i.div(this.description,"tutorials-root-description"));for(let e=0;e<this.stepNumber;e++){let s=i.iconFA("clock");this._isAutomatic||0===e&&(s=i.iconFA("play",(()=>this._nextStep()),"Next step"),s.className="grok-icon fas fa-play");const n=i.div(this._steps[e].name,"grok-tutorial-entry-instruction"),o=i.div(null===(t=this._steps[e].options)||void 0===t?void 0:t.description,"grok-tutorial-step-description hidden"),r=i.divH([s,n],"grok-tutorial-entry");this._activity.append(r,o)}}_initRoot(){var t,e,s;n.shell.windows.showContextPanel=!0,n.shell.windows.showHelp=!1;const i=Array.from(n.shell.dockManager.rootNode.children)[0];this._node=n.shell.dockManager.dock(this._root,o.DOCK_TYPE.FILL,i,""),(null===(e=null===(t=i.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=i.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 ae(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],n=this._activity.getElementsByClassName("grok-icon")[this._currentStep],o=this._activity.getElementsByClassName("grok-tutorial-step-description")[this._currentStep];n.className="grok-icon far fa-spinner-third fa-spin",o.classList.remove("hidden"),o.classList.add("visible");const a=s,l=(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,a.offsetTop-this._mainHeader.offsetHeight),this._isAutomatic&&(yield this._countdown(s,n,l),yield(0,r.gw)(l));const c=i.iconFA("check");if(n.replaceWith(c),c.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=i.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 ae(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 ae(this,void 0,void 0,(function*(){const n=i.div([],"demo-script-countdown");e.classList.add("hidden");let o=s/1e3;const r=this._createSVGIndicator(o);n.append(r),t.prepend(n);const a=setInterval((()=>{o--,0===o&&(clearInterval(a),n.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(){n.shell.dockManager.close(this._node),n.shell.closeAll(),this._clearRoot(),this._setInitParams(),this.start()}_clearRoot(){this._root=i.div([],{id:"demo-script",classes:"tutorials-root tutorials-track demo-app-script"}),this._mainHeader=i.panel([],"tutorials-main-header"),this._header=i.h2(""),this._headerDiv=i.divH([],"tutorials-root-header"),this._activity=i.panel([],"tutorials-root-description"),this._progressDiv=i.divV([],"tutorials-root-progress"),this._progress=i.element("progress"),this._progressSteps=i.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(){n.shell.dockManager.close(this._node),this.cancelScript()}cancelScript(){this._isCancelled=!0,le.currentObject=null}step(t,e,s){return this._steps[this.steps.length]={name:t,func:e,options:s},this}start(){return ae(this,void 0,void 0,(function*(){this._initRoot(),n.shell.newView(this.name),this._isAutomatic?this._startScript():this._autoStartFirstStep&&(yield this._nextStep())}))}}function ce(t){const e=t instanceof Error?t.message:t.toString(),s=t instanceof Error?t.stack:void 0;n.shell.error(e),us.logger.error(t.message,void 0,s)}le.currentObject=null,function(t){t.X="Embed_X",t.Y="Embed_Y"}(se||(se={}));const he="data/sample_FASTA_PT_activity.csv";var ue=s(1811),me=s(3914);async function de(){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 pe(){return await n.functions.call("Dendrogram:getDendrogramService",{})}const ge="data/sample_FASTA_PT_activity.csv",fe="sequence";var ye=s(3336),we=s.n(ye);const Ce="data/sample_FASTA_PT_activity.csv";var Te=s(8341);const be="samples/HELM.csv";var Ae=s(2568),Se=s(525);class Ee{constructor(t,e,s={}){this.urlParams=t,this.funcName=e,this.options=s}async init(t){this.df=t,await this.buildView()}async buildView(){const t=tt()(this.urlParams.entries()).map((([t,e])=>`${t}=${encodeURIComponent(e)}`)).toArray().join("&");this.view=n.shell.addTableView(this.df),this.view.path=this.view.basePath=`func/${us.name}.${this.funcName}?${t}`;const e={...this.options,sequenceColumnName:"sequence"};for(const[t,s]of this.urlParams.entries())switch(t){case vt.bo.fixWidth:case vt.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 Me{get funcParams(){return{table:this.tableInput.value,sequence:this.seqColInput.value}}get paramsUI(){return this.funcParamsDiv}constructor(){this.tableInput=i.tableInput("Table",n.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=i.columnInput("Sequence",this.tableInput.value,t,null,e),this.funcParamsDiv=i.inputs([this.tableInput,this.seqColInput],{style:{minWidth:"320px"}})}onTableInputChanged(){this.seqColInput=i.columnInput("Sequence",this.tableInput.value,this.tableInput.value.columns.bySemType(o.SEMTYPE.MACROMOLECULE))}}var ve=s(9416);class Ne{constructor(t){this.monomerLib=t}getCappedRotatedMonomer(t,e){const s=this.monomerLib.getMonomer(t,e);return s?s.molfile:null}}const Ie=new class{constructor(){this.tooltipHandlerTemp="tooltip-handler.Monomer"}},Le={autoCrop:!0,autoCropMargin:0,suppressChiralText:!0};class Pe{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 Ne(ds().getBioLib()).getCappedRotatedMonomer(a,r),c=i.div(r),h=l?n.chem.svgMol(l,void 0,void 0,Le):null,u=t.grid.canvas.getBoundingClientRect(),m=t.bounds.right+u.left-4,d=t.bounds.bottom+u.top-4;return i.tooltip.show(i.divV([c,...h?[h]:[]]),m,d),!0}static getOrCreate(t){let e=t.temp[Ie.tooltipHandlerTemp];return e||(e=t.temp[Ie.tooltipHandlerTemp]=new Pe(t)),e}}class _e extends o.GridCellRenderer{get name(){return dt.Of.MONOMER}get cellType(){return dt.Of.MONOMER}get defaultHeight(){return 15}get defaultWidth(){return 40}render(t,e,s,n,i,o,r){if(o.gridRow<0)return;Pe.getOrCreate(o.gridColumn),t.font="12px monospace",t.textBaseline="middle",t.textAlign="center";const a=(0,ht.py)(o.cell.column.getTag("alphabet")),l=o.cell.value;if(!l)return;const c=a.get(l);t.fillStyle=c,t.fillText((0,ht.GU)(l,6),e+n/2,s+i/2,n)}}class Re 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 f.Subject}}class xe 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;n.shell.error(e),this.logger.error(e,void 0,s)}}class Oe extends o.Widget{constructor(t){super(i.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=i.intInput("Max monomer length",us.properties.MaxMonomerLength,(t=>{us.properties.MaxMonomerLength=t})),e=i.boolInput("Tooltip WebLogo",us.properties.TooltipWebLogo,(t=>{us.properties.TooltipWebLogo=t})),s=i.choiceInput("Default Separator",us.properties.DefaultSeparator,[".","/","-"],(t=>{us.properties.DefaultSeparator=t}));this.root.appendChild(i.form([t,e,s]))}}var Ge=s(8770);class Fe extends o.Widget{constructor(t){super(i.divV([])),this.viewed=!1,this.seqCol=t}async init(){const t=q.Cn.getOrCreate(this.seqCol),e=us.properties.TooltipWebLogo,s=this.seqCol.getTag(Et.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%")}}var De=s(9953);function He(t){t.setTag("quality",o.SEMTYPE.MACROMOLECULE),t.setTag("aligned","SEQ"),t.setTag("alphabet","PT")}var We=s(922);async function Be(t,e){const s=new ke(e,t),n=await s.convertToRdKitBeautifiedMolfileColumn();return n.semType=o.SEMTYPE.MOLECULE,n}class ke{constructor(t,e){this.helmColumn=t,this.df=e,this.helmColumn=t}async convertToSmiles(){const t=await this.getSmilesList(),e=this.df.columns.getUnusedName(`smiles(${this.helmColumn.name})`);return o.Column.fromStrings(e,t.map((t=>null===t?"":t)))}async getSmilesList(){return(await this.convertToMolfileV2KColumn()).toList().map((t=>o.chem.convert(t,o.chem.Notation.MolBlock,o.chem.Notation.Smiles)))}async convertToRdKitBeautifiedMolfileColumn(){const t=await this.getSmilesList(),e=await n.functions.call("Chem:getRdKitModule"),s=t.map((t=>{if(""===t)return null;const s=e.get_mol(t);return s?(s.normalize_depiction(1),s.straighten_depiction(!0),s):null})),i=this.df.columns.getUnusedName(`molfile(${this.helmColumn.name})`);return o.Column.fromStrings(i,s.map((t=>null===t?"":t.get_molblock())))}async convertToMolfileV2KColumn(){const t=(await this.getPolymerGraphColumn()).toList().map(((t,e)=>{const s=this.helmColumn.get(e);if(!s)return"";let n="";try{n=this.getPolymerMolfile(s,t)}catch(t){const[e,s]=(0,pt.yf)(t);us.logger.error(e,void 0,s)}finally{return n}})),e=this.df.columns.getUnusedName(`molfileV2K(${this.helmColumn.name})`);return o.Column.fromList("string",e,t)}async getPolymerGraphColumn(){return await n.functions.call("HELM:getMolfiles",{col:this.helmColumn})}getPolymerMolfile(t,e){const s=new Ue(e),n=new je(t);return s.monomerSymbols.forEach(((t,e)=>{const i=s.getMonomerShifts(e);n.addMonomer(t,e,i)})),n.compileToMolfile()}}class Ue{constructor(t){this.molfileHandler=We._.getInstance(t)}get monomerSymbols(){return this.molfileHandler.atomTypes}getMonomerShifts(t){return{x:this.molfileHandler.x[t],y:this.molfileHandler.y[t]}}}class Ve{constructor(t,e){this.capGroupElements=[];const s=re.NT.instance.getBioLib().getMonomer(e,t);if(!s)throw new Error(`Monomer ${t} is not found in the library`);this.molfileWrapper=new Ke(s.molfile,t),this.capGroupElements=s.rgroups.map((t=>(t.capGroupSmiles||t.capGroupSMILES).replace(/(\[|\]|\*|:|\d)/g,"")))}shiftCoordinates(t){this.molfileWrapper.shiftCoordinates(t)}getAtomLines(){return this.molfileWrapper.getAtomLines()}getBondLines(){return this.molfileWrapper.getBondLines()}removeBondedRGroups(t){this.molfileWrapper.removeRGroups(t)}capTrailingRGroups(){this.molfileWrapper.capRGroups(this.capGroupElements)}replaceRGroupWithAttachmentAtom(t,e){this.molfileWrapper.replaceRGroupWithAttachmentAtom(t,e)}getAttachmentAtomByRGroupId(t){return this.molfileWrapper.getAttachmentAtomByRGroupId(t)}deleteBondLineWithSpecifiedRGroup(t){this.molfileWrapper.deleteBondLineWithSpecifiedRGroup(t)}shiftBonds(t){this.molfileWrapper.shiftBonds(t)}}class $e{constructor(t,e,s){this.atoms=e,this.bonds=s,this.rGroupBondPositionMap=new Map,this.rGroupIdToAtomicIndexMap=this.getRGroupIdToAtomicIdxMap(t)}getAtomicIdx(t){const e=this.rGroupIdToAtomicIndexMap.get(t);return void 0===e?null:e}removeRGroupsFromAtomBlock(t){t.forEach((t=>{if(void 0===this.rGroupIdToAtomicIndexMap.get(t))throw new Error(`Cannot find atomic index for R group ${t}`)}));const e=Array.from(this.rGroupIdToAtomicIndexMap.entries()).filter((([e,s])=>t.includes(e))).map((([t,e])=>e));this.atoms.deleteAtoms(e)}removeRGroups(t){this.removeRGroupsFromAtomBlock(t),t.forEach((t=>{const e=this.replaceRGroupInBondsByDummy(t);this.rGroupBondPositionMap.set(t,e)}))}replaceRGroupInBondsByDummy(t){const e=this.rGroupIdToAtomicIndexMap.get(t);if(this.rGroupBondPositionMap.has(t))throw new Error(`R group ${t} is already handled`);const s=this.bonds.getPositionsInBonds(e+1);if(0===s.length)throw new Error(`Cannot find position for R group ${t}`);if(s.length>1)throw new Error(`More than one position for R group ${t}`);const n=s[0];return this.bonds.replacePositionsInBondsByDummy([n]),this.bonds.removeAtomIdFromBonds(e+1),this.removeRGroupFromAtomicIdxMap(t,e),n}removeRGroupFromAtomicIdxMap(t,e){this.rGroupIdToAtomicIndexMap.delete(t);for(const[t,s]of this.rGroupIdToAtomicIndexMap)s>e&&this.rGroupIdToAtomicIndexMap.set(t,s-1)}getRGroupIdToAtomicIdxMap(t){const e=new Map;t.filter((t=>t.startsWith("M RGP"))).forEach((t=>{const s=function(t){const e=t.split(/\s+/).filter((t=>t)).slice(3).map((t=>parseInt(t))),s=new Array(e.length/2);for(let t=0;t<e.length;t+=2)s[t/2]=[e[t+1],e[t]-1];return s}(t);for(const[t,n]of s){if(e.has(t))throw new Error(`R group ${t} is already in the map`);e.set(t,n)}}));const s=t.map(((t,e)=>{if(t.startsWith("A "))return e})).filter((t=>void 0!==t)),n=s.map((e=>t[e])),i=s.map((e=>t[e+1]));n.forEach(((t,s)=>{const n=parseInt(t.split(/\s+/)[1])-1,o=parseInt(i[s].substring(1));if(e.has(o))throw new Error(`R group ${o} is already in the map`);e.set(o,n)}));const o=this.atoms.getRGroupAtomicIndices().filter((t=>!Array.from(e.values()).includes(t)));if(0!==o.length)throw new Error(`Unaccounted R group indices: ${o}`);return e}deleteBondLineWithSpecifiedRGroup(t){const e=this.rGroupBondPositionMap.get(t);if(!e)throw new Error(`Cannot find position for R group ${t}`);const{bondLineIdx:s}=e;this.bonds.deleteBondLines([s]),this.rGroupBondPositionMap.delete(t),this.rGroupIdToAtomicIndexMap.delete(t),this.rGroupBondPositionMap.forEach((t=>{t.bondLineIdx>s&&(t.bondLineIdx-=1)}))}replaceRGroupWithAttachmentAtom(t,e){const s=this.rGroupBondPositionMap.get(t);if(!s)throw new Error(`Cannot find position for R group ${t}`);const{bondLineIdx:n,nodeIdx:i}=s;this.bonds.bondedAtoms[n][i]=e}getAttachmentAtomIdByRGroupId(t){const e=this.rGroupBondPositionMap.get(t);if(!e)throw new Error(`Cannot find position for R group ${t}`);const{bondLineIdx:s,nodeIdx:n}=e;return this.bonds.bondedAtoms[s][(n+1)%2]}capRGroups(t){this.rGroupIdToAtomicIndexMap.forEach(((e,s)=>{const n=t[s-1];"H"===n?(this.removeRGroups([s]),this.deleteBondLineWithSpecifiedRGroup(s)):this.atoms.replaceElementSymbol(e,n)}))}}class Ye{constructor(t){this.bondedPairs=[],this.rawBondLines=[],this.rawBondLines=t,this.bondedPairs=this.rawBondLines.map((t=>[parseInt(t.substring(0,3)),parseInt(t.substring(3,6))]))}getBondLines(){return this.bondedPairs.map(((t,e)=>{if(t.some((t=>-1===t)))throw new Error(`Bonded pair ${t} contains -1`);return`${t[0].toString().padStart(3," ")}${t[1].toString().padStart(3," ")}${this.rawBondLines[e].substring(6)}`}))}get bondedAtoms(){return this.bondedPairs}deleteBondLines(t){this.rawBondLines=this.rawBondLines.filter(((e,s)=>!t.includes(s))),this.bondedPairs=this.bondedPairs.filter(((e,s)=>!t.includes(s)))}getPositionsInBonds(t){const e=[];return this.bondedPairs.forEach(((s,n)=>{s.forEach(((s,i)=>{s===t&&e.push({bondLineIdx:n,nodeIdx:i})}))})),e}replacePositionsInBondsByDummy(t,e){void 0===e&&(e=-1),t.forEach((t=>{const{bondLineIdx:s,nodeIdx:n}=t;this.bondedPairs[s][n]=e}))}removeAtomIdFromBonds(t){this.bondedPairs=this.bondedPairs.map((e=>e.map((e=>e>t?e-1:e))))}shift(t){this.bondedPairs=this.bondedPairs.map((e=>e.map((e=>e+t))))}}class qe{constructor(t){this.coordinates=[],this.rawAtomLines=[],this.rawAtomLines=t,this.coordinates=this.rawAtomLines.map((t=>({x:parseFloat(t.substring(0,10)),y:parseFloat(t.substring(10,20))})))}get atomCoordinates(){return this.coordinates}get atomLines(){return this.rawAtomLines.map(((t,e)=>{const s=this.coordinates[e];return`${s.x.toFixed(4).padStart(10," ")}${s.y.toFixed(4).padStart(10," ")}${t.substring(20)}`}))}replaceElementSymbol(t,e){this.rawAtomLines[t]=this.rawAtomLines[t].replace("R#",e)}deleteAtoms(t){this.coordinates=this.coordinates.filter(((e,s)=>!t.includes(s))),this.rawAtomLines=this.rawAtomLines.filter(((e,s)=>!t.includes(s)))}shift(t){this.coordinates=this.coordinates.map((e=>{const s=e.x+t.x,n=e.y+t.y;if(isNaN(s)||isNaN(n))throw new Error(`Cannot shift coordinates by ${t.x}, ${t.y}`);return{x:s,y:n}}))}rotate(t){this.coordinates=this.coordinates.map((e=>{const s=e.x,n=e.y,i=s*Math.cos(t)-n*Math.sin(t),o=s*Math.sin(t)+n*Math.cos(t);if(isNaN(i)||isNaN(o))throw new Error(`Cannot rotate coordinates by ${t}`);return{x:i,y:o}}))}getRGroupAtomicIndices(){return this.rawAtomLines.map(((t,e)=>{if(t.includes("R#"))return e})).filter((t=>void 0!==t))}}class Ke{constructor(t,e){this.monomerSymbol=e;const s=t.split("\n"),n=parseInt(s[3].substring(0,3)),i=parseInt(s[3].substring(3,6)),o=s.slice(4,4+n);this.atoms=new qe(o);const r=s.slice(4+n,4+n+i);this.bonds=new Ye(r),this.rGroups=new $e(s,this.atoms,this.bonds),this.shiftMonomerToDefaultPosition()}deleteBondLineWithSpecifiedRGroup(t){this.rGroups.deleteBondLineWithSpecifiedRGroup(t)}shiftCoordinates(t){this.atoms.shift(t)}rotateCoordinates(t){this.atoms.rotate(t)}getBondLines(){return this.bonds.getBondLines()}getAtomLines(){return this.atoms.atomLines}removeRGroups(t){this.rGroups.removeRGroups(t)}replaceRGroupWithAttachmentAtom(t,e){this.rGroups.replaceRGroupWithAttachmentAtom(t,e)}getAttachmentAtomByRGroupId(t){return this.rGroups.getAttachmentAtomIdByRGroupId(t)}shiftR1GroupToOrigin(){const t=this.rGroups.getAtomicIdx(1);if(null===t)throw new Error(`Cannot find R1 group for monomer ${this.monomerSymbol}`);const{x:e,y:s}=this.atoms.atomCoordinates[t];this.atoms.shift({x:-e,y:-s})}alignR2AlongX(){const t=this.rGroups.getAtomicIdx(2);if(null===t)throw new Error(`Cannot find R2 group for monomer ${this.monomerSymbol}`);const e=this.atoms.atomCoordinates[t],s=e.y/e.x,n=Math.atan(s);if(isNaN(n))throw new Error(`Cannot calculate angle for R2 group for monomer ${this.monomerSymbol}`);this.rotateCoordinates(-n)}shiftMonomerToDefaultPosition(){this.shiftR1GroupToOrigin(),null!==this.rGroups.getAtomicIdx(2)&&this.alignR2AlongX()}shiftBonds(t){this.bonds.shift(t)}capRGroups(t){this.rGroups.capRGroups(t)}}class Ze{constructor(t){this.simplePolymer=t,this.polymerType=this.getPolymerType(),this.idx=this.getIdx();const{monomers:e,monomerTypes:s}=this.getMonomerSymbolsAndTypes();this.monomers=e,this.monomerTypes=s}get id(){return this.polymerType+this.idx.toString()}getPolymerType(){const t=new RegExp("(PEPTIDE|RNA)[0-9]+{"),e=this.simplePolymer.match(t);if(!e)throw new Error(`Unsupported polymer type in ${this.simplePolymer}`);return e[1]}getIdx(){const t=new RegExp(`${this.polymerType}([0-9]+){`),e=this.simplePolymer.match(t);if(!e)throw new Error(`Cannot parse simple polymer id from ${this.simplePolymer}`);return parseInt(e[1])}getMonomerSymbolsAndTypes(){const t=new RegExp(`${this.polymerType}${this.idx}{|}`,"g"),e=this.simplePolymer.replace(t,"").split("."),s=[],n=[];return e.forEach((t=>{const e=t.split(/\(|\)/).map((t=>t.replace(/[\[\]]/g,"")));s.push(...e);const i=e.map(((t,e)=>e%2==0?0:1));n.push(...i)})),{monomers:s,monomerTypes:n}}getBondData(){const t=[],e=this.monomerTypes.map(((t,e)=>{if(0===t)return e})).filter((t=>void 0!==t)),s=this.monomerTypes.map(((t,e)=>{if(1===t)return e})).filter((t=>void 0!==t));for(let s=0;s<e.length-1;s++){const n=e[s],i=e[s+1];t.push([{monomerIdx:n,rGroupId:2},{monomerIdx:i,rGroupId:1}])}for(let e=0;e<s.length;e++){const n=s[e],i=n-1;t.push([{monomerIdx:i,rGroupId:3},{monomerIdx:n,rGroupId:1}])}return t}}class ze{constructor(t){const e=t.split("|");e.forEach((t=>this.validateConnectionItem(t))),this.connectionItems=e}validateConnectionItem(t){const e="(PEPTIDE|RNA)",s=new RegExp(`${e}[0-9]+,${e}[0-9]+,[0-9]+:R[0-9]+-[0-9]+:R[0-9]+`,"g");if(!t.match(s))throw new Error(`Cannot parse connection item from ${t}`)}getConnectionData(){const t=[];return this.connectionItems.forEach((e=>{const s=[],n=e.split(",");n[2].split("-").forEach(((t,e)=>{const i=n[e],o=t.split(":"),r={monomerIdx:parseInt(o[0])-1,rGroupId:parseInt(o[1].slice(1))};s.push({polymerId:i,bond:r})})),t.push(s)})),t}}class Xe{constructor(t){this.helm=t;const e=this.helm.split("$"),s=e[0].split("|");this.simplePolymers=s.map((t=>new Ze(t))),""!==e[1]&&(this.connectionList=new ze(e[1])),this.bondData=this.getBondData()}toString(){return this.helm}getPolymerTypeByMonomerIdx(t){return this.getSimplePolymerByMonomerIdx(t).polymerType}getSimplePolymerByMonomerIdx(t){const e=this.getMonomerIdxShifts(),s=Object.values(e).sort(((t,e)=>t-e)).find((e=>t>=e));if(void 0===s)throw new Error(`Cannot find simple polymer for monomer ${t}`);const n=Object.keys(e).find((t=>e[t]===s));return this.simplePolymers.find((t=>t.id===n))}shiftBondMonomerIds(t,e){e.forEach((e=>{e.forEach((e=>{e.monomerIdx+=t}))}))}getMonomerIdxShifts(){const t={};let e=0;return this.simplePolymers.forEach((s=>{t[s.id]=e,e+=s.monomers.length})),t}getBondData(){const t=this.getMonomerIdxShifts(),e=[];return this.simplePolymers.forEach((s=>{const n=s.getBondData(),i=t[s.id];this.shiftBondMonomerIds(i,n),e.push(...n)})),this.connectionList&&this.connectionList.getConnectionData().forEach((s=>{const n=[];s.forEach((e=>{const s=t[e.polymerId],i=e.bond;i.monomerIdx+=s,n.push(i)})),e.push(n)})),e}}class je{constructor(t){this.monomerWrappers=[],this.helm=new Xe(t),this.bondedRGroupsMap=new Map,this.helm.bondData.forEach((t=>{t.forEach((t=>{const e=t.monomerIdx,s=t.rGroupId;this.bondedRGroupsMap.get(e)||this.bondedRGroupsMap.set(e,[]),this.bondedRGroupsMap.get(e).push(s)}))}))}addMonomer(t,e,s){const n=this.helm.getPolymerTypeByMonomerIdx(e),i=new Ve(t,n);i.shiftCoordinates(s),this.monomerWrappers.push(i)}removeRGroups(){this.monomerWrappers.forEach(((t,e)=>{this.bondedRGroupsMap.has(e)&&t.removeBondedRGroups(this.bondedRGroupsMap.get(e)),t.capTrailingRGroups()}))}getAtomNumberShifts(){const t=[];let e=0;return this.monomerWrappers.forEach((s=>{t.push(e),e+=s.getAtomLines().length})),t}restoreBondsBetweenMonomers(){this.helm.bondData.forEach((t=>{const e=t.map((t=>t.monomerIdx)),s=t.map((t=>t.rGroupId)),n=e.map((t=>this.monomerWrappers[t])),i=n[1].getAttachmentAtomByRGroupId(s[1]);n[0].replaceRGroupWithAttachmentAtom(s[0],i),n[1].deleteBondLineWithSpecifiedRGroup(s[1])}))}compileToMolfile(){const t=[],e=[];this.removeRGroups();const s=this.getAtomNumberShifts();this.monomerWrappers.forEach(((t,e)=>{t.shiftBonds(s[e])})),this.restoreBondsBetweenMonomers(),this.monomerWrappers.forEach((s=>{t.push(...s.getAtomLines()),e.push(...s.getBondLines())}));const n=t.length;if(n>999)throw new Error(`Atom count in polymer ${this.helm.toString()} is ${n} and exceeds 999`);const i=e.length;return["\nDatagrok\n",`${n.toString().padStart(3," ")}${i.toString().padStart(3," ")} 0 0 1 0 0 V2000`,t.join("\n"),e.join("\n"),"M END\n"].join("\n")}}class Je{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 Qe extends Je{constructor(t,e){super(t,e)}hasTerminals(t){return this.getLinkedPositions(t).every((t=>t>0))}getLinkedPositions(t){return[1,t.replace("PEPTIDE1{","").replace("}$$$$","").split(".").findIndex(((t,e)=>t===this.rightTerminal&&e>0))+1]}getTransformedHelm(t){const e=this.getLinkedPositions(t);return is(t,{monomerPosition:e[0],attachmentPoint:1},{monomerPosition:e[1],attachmentPoint:3})}}class ts extends Je{constructor(t,e){super(t,e)}hasTerminals(t){return this.leftTerminal===De.M||this.rightTerminal===De.M||t.includes("PEPTIDE1{"+this.leftTerminal)&&t.includes(this.rightTerminal+"}$$$$")}getLinkedPositions(t){return[1,ns(t)]}getTransformedHelm(t){const e=this.getLinkedPositions(t);return is(t,{monomerPosition:e[0],attachmentPoint:1},{monomerPosition:e[1],attachmentPoint:2})}}class es extends Je{constructor(t,e){super(t,e)}hasTerminals(t){return this.leftTerminal===De.M||this.rightTerminal===De.M||this.getLinkedPositions(t).every((t=>t>0))}getLinkedPositions(t){const e=t.replace("PEPTIDE1{","").replace("}$$$$","").split("."),s=e.findIndex((t=>t===this.leftTerminal)),n=e.findIndex(((t,e)=>t===this.rightTerminal&&e>s));return[s+1,n+1]}getTransformedHelm(t){const e=this.getLinkedPositions(t);return is(t,{monomerPosition:e[0],attachmentPoint:3},{monomerPosition:e[1],attachmentPoint:3})}}class ss{constructor(){}static getInstance(t,e){const s=e.cyclizationType;return"R3-R3"===s?new es(t,e):"N-Cys"===s?new Qe(t,e):new ts(t,e)}}function ns(t){return t.replace("PEPTIDE1{","").replace("}$$$$","").split(".").length}function is(t,e,s){return t.replace("}$$$$",`}$PEPTIDE1,PEPTIDE1,${e.monomerPosition}:R${e.attachmentPoint}-${s.monomerPosition}:R${s.attachmentPoint}${"$".repeat(6)}`)}async function os(t,e,s){const i=t.dataFrame,r=q.Cn.getOrCreate(t).convert(ht.r2.HELM),a=ss.getInstance(r,e).transform(),l=i.columns.getUnusedName(`${e.transformationType}(`+t.name+")"),c=o.Column.fromList("string",l,a);He(c),c.setTag("units",ht.r2.HELM);const h=await Be(i,c);h.name=i.columns.getUnusedName(`${e.transformationType}_molfile(`+t.name+")"),s&&(c.setTag("cell.renderer","helm"),i.columns.add(c)),i.columns.add(h,!0),await n.data.detectSemanticTypes(i)}function rs(t,e,s,n){const i=q.Cn.getOrCreate(t);let o=null,r=null;for(let t=0;t<i.posList.length;++t)i.posList[t]==e&&(o=t),i.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(i.posList.length<r)throw new Error(`End position ${r} exceeds positions length`);const a=n||`${t.name}: (${e??""}-${s??""})`;return i.getRegion(o,r,a)}const as={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(ht.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 ls{constructor(t,e){this.urlParams=t,this.funcName=e}async init(t){this.data=t??as;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 n.data.detectSemanticTypes(this.data.df),this.view=n.shell.addTableView(this.data.df),this.view.path=this.view.basePath=`func/${us.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 cs{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=i.tableInput("Table",this.call.inputParams.table.value??n.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=i.columnInput("Sequence",n.shell.tv.dataFrame,s,this.sequenceInputChanged.bind(this),r),this.inputs.start=i.choiceInput("Start",void 0,[],this.startInputChanged.bind(this)),this.inputs.end=i.choiceInput("End",void 0,[],this.endInputChanged.bind(this)),this.inputs.region=i.choiceInput("Region",null,[],this.regionInputChanged.bind(this)),this.inputs.name=i.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)i.tooltip.bind(this.inputs[t].captionLabel,e(t));this.sequenceInputChanged()}sequenceInputChanged(){const t=this.inputs.sequence.value;t&&q.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=q.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?q.Cn.getOrCreate(t):null,s=this.inputs.start.input,n=this.inputs.end.input;for(let t=s.options.length-1;t>=0;--t)s.options.remove(t);for(let t=n.options.length-1;t>=0;--t)n.options.remove(t);for(const t of e?.posList??[]){const e=document.createElement("option"),i=document.createElement("option");e.text=i.text=t,e.value=i.value=t,s.options.add(e),n.options.add(i)}s.value=e?.posList[0]??"",n.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,n=this.inputs.region.input;for(let t=n.options.length-1;t>=0;--t)n.options.remove(t);const i=document.createElement("option");if(i.text="",i.value=JSON.stringify(null),n.options.add(i),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),n.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 n=t.options.length-1;n>=0;--n){const i=t.options[n],o=JSON.parse(i.value);o&&e===o.start&&s===o.end&&(t.selectedIndex=n)}}}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,n=this.inputs.start.stringValue??"",i=this.inputs.end.stringValue??"";return null!=e?`${s.name}(${e.name}): ${e.start}-${e.end}`:`${s?.name}: (${n}-${i})`}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=i.inputs(Object.values(this.inputs),{style:{minWidth:"320px"}});i.dialog({title:"Get Region"}).add(t).onOK((async()=>{(async()=>{const t=this.getParams();await this.call.func.prepare(t).call(!0)})().catch((t=>{us.handleErrorUI(t)}))})).show()}widget(){const t=i.inputs(Object.entries(this.inputs).filter((([t,e])=>!["table","sequence"].includes(t))).map((([t,e])=>e))),e=i.button("Get Region",(()=>{(async()=>{const t=this.getParams();await this.call.func.prepare(t).call(!0)})().catch((t=>{us.handleErrorUI(t)}))}));return o.Widget.fromRoot(i.divV([t,i.div(e)]))}}var hs=s(8601);const us=new xe,ms="bypassLargeDataWarning";function ds(){return re.NT.instance}let ps=null;class gs{constructor(t){this._palette=t}get(t){return this._palette[t]}}async function fs(){us.logger.debug("Bio: initBio(), started");const t=await n.functions.call("Chem:getRdKitModule");await Promise.all([(async()=>{await re.NT.instance.loadLibraries()})(),(async()=>{const t=await us.getProperties(),e=new Re(t);us.properties=e})()]).finally((()=>{us.completeInit()}));const e=re.NT.instance.getBioLib(),s=[],i=[],o=e.getMonomerMolsByPolymerType("PEPTIDE");Object.keys(o).forEach((e=>{s.push(e);const n=o[e].replaceAll("#R","O "),r=t.get_mol(n),a=JSON.parse(r.get_descriptors()).CrippenClogP;i.push(a),r?.delete()}));const r=i.reduce(((t,e)=>t+e),0)/i.length||0,a={};for(let t=0;t<s.length;t++)a[s[t]]=i[t]<r?"#4682B4":"#DC143C";ps=new gs(a),us.logger.debug("Bio: initBio(), completed")}function ys(t){const e=new Fe(t);return e.init().then((()=>{})).catch((t=>{const e=t instanceof Error?t.message:t.toString();n.shell.error(e)})),e}function ws(){return re.NT.instance.getBioLib()}function Cs(t){const e="getRegionTopMenu",s=o.Func.find({package:us.name,name:e});if(1!==s.length)throw new Error(`Package '${us.name}' func '${e}' not found`);const n=s[0].prepare({table:t.dataFrame,sequence:t});return new cs(n).widget()}async function Ts(t){return(0,re.cf)()}function bs(t){try{new cs(t).dialog()}catch(t){const e=t instanceof Error?t.message:t.toString(),s=t instanceof Error?t.stack:void 0;n.shell.error(`Get region editor error: ${e}`),us.logger.error(e,void 0,s)}}function As(t){const e=new Me;i.dialog({title:"Split to Monomers"}).add(e.paramsUI).onOK((async()=>t.func.prepare(e.funcParams).call(!0))).show()}function Ss(t){const e=new p(o.SEMTYPE.MACROMOLECULE);i.dialog({title:"Sequence Space"}).add(e.paramsUI).onOK((async()=>t.func.prepare(e.funcParams).call())).show()}function Es(t){const e=new g(o.SEMTYPE.MACROMOLECULE);i.dialog({title:"Activity Cliffs"}).add(e.paramsUI).onOK((async()=>t.func.prepare(e.funcParams).call(!0))).show()}function Ms(t){const e=new Oe(t);return e.init().then(),e}function vs(){return new Ct}function Ns(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=i.choiceInput("Monomer width",null!=t?.temp["monomer-width"]?t.temp["monomer-width"]:lt.short,[lt.short,lt.long],(e=>{t.temp["monomer-width"]=e,t.setTag(".mm.cellRenderer.settingsChanged",mt.true),t.dataFrame.fireValuesChanged()}));s.setTooltip("In short mode, only the 'Max monomer length' characters are displayed, followed by .. if there are more");const n=parseInt(t.getTag(ot.maxMonomerLength)),r=i.intInput("Max monomer length",isNaN(n)?us.properties.MaxMonomerLength:n,(e=>{t.setTag(ot.maxMonomerLength,e.toString()),t.setTag(".mm.cellRenderer.settingsChanged",mt.true),t.dataFrame.fireValuesChanged()}));r.setTooltip(`The max length of monomer name displayed without shortening in '${lt.short}' monomer width mode.`);const a=i.intInput("Monomer margin",t.temp[".mm.cellRenderer.gapLength"]??0,(e=>{t.temp[".mm.cellRenderer.gapLength"]=e,t.setTag(".mm.cellRenderer.settingsChanged",mt.true),t.dataFrame.fireValuesChanged()}));a.setTooltip("The size of margin between monomers (in pixels)");const l=i.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 c=i.stringInput("Reference sequence",null!=t?.temp["reference-sequence"]?t?.temp["reference-sequence"]:"",(e=>{t.temp["reference-sequence"]=e,t.dataFrame.fireValuesChanged()}));c.setTooltip("Reference sequence is not empty, then the sequence will be render \nas a difference from the reference sequence");const h=i.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()}));h.setTooltip('When on, all sequences get rendered in the "diff" mode');const u=i.inputs([s,r,a,c,l,h]);return new o.Widget(u)}(t)}function Is(t){return(0,Ge.t)(t)}function Ls(){return new Ct}function Ps(){return new Tt}function _s(t,e,s,n,i){const o=new Rt.k(n,i,s,e);return"Local alignment"==t?o.smithWaterman():o.needlemanWunch()}function Rs(){return new vt.OZ}function xs(){return new _t}function Os(t,e,s,n){return rs(t,e??null,s??null,n??null)}async function Gs(t,e,s,i,o){const r=rs(e,s??null,i??null,o??null);e.dataFrame.columns.add(r),await n.data.detectSemanticTypes(e.dataFrame)}async function Fs(t,e,r,c,h,u,m){if(!(0,Ae.n)(e,"Activity Cliffs"))return;const d=Bt(t),p={units:e.getTag(o.TAGS.UNITS),aligned:e.getTag("aligned"),separator:e.getTag("separator"),alphabet:e.getTag("alphabet")};let g=Ht;const f=q.Cn.getOrCreate(e),y=u,w=e;let C=Wt;f.isHelm()&&(C=Dt,g=async(t,e)=>{await(0,Ft.HV)(t,!1);const s=t.temp["monomeric-mols"];return{seqList:(await n.functions.call("Chem:getMorganFingerprints",{molColumn:s})).toList().map((t=>R.Z.fromUint32Array(t.length,new Uint32Array(t.getBuffer().buffer)))),options:{}}});const T=async()=>await async function(t,e,r,a,c,h,u,m,d,p,g,f,y,w,C,T,b,A){x++;const S=u/100,E=r??e;let M=!1,v=!1;const N={};let I,L;const P={seqCol:E,methodName:d,similarityMetric:m,embedAxesNames:a,options:{...b??{},[G]:void 0}},{distance:Y,coordinates:q}=await f(P);for(const e of q)t.columns.add(e);let K;if(e.semType===o.SEMTYPE.MOLECULE){const t=(await n.functions.call("Chem:getMorganFingerprints",{molColumn:E})).toList().map((t=>new R.Z(new Uint32Array(t.getBuffer().buffer),t.length))),e=1-(0,l.eo)(S),s=await(new _._).calc(t,m,e);K=await V(s,0,h)}else{let t=e.toList(),s={};if(b?.[G]){const{seqList:n,options:i}=await b[G](e,m);t=n,s=i}const n=await(new _._).calc(t,m,S,s);K=await V(n,0,h)}const Z=function(t,e,s,n,i,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(n[t])?a[s[t]]+=e[t]:a[n[t]]+=e[t]);return o.Column.fromList("double",`sali_${i[0].substring(i[0].lastIndexOf("_"))}`,a)}(E.length,K.saliVals,K.n1,K.n2,a,h);t.columns.add(Z);const z=function(t,e){const s="containsCliff",n=t.columns.names().filter((t=>t.includes(s))).length+1,i=`${s}_${n}`;return o.Column.bool(i,t.rowCount).init((t=>e.has(t)))}(t,K.cliffsMolIds);t.columns.add(z);const X=function(t){const e=t.filter((t=>t!==1/0)),s=e.reduce(((t,e)=>Math.min(t,e)),Number.MAX_VALUE),n=e.reduce(((t,e)=>Math.max(t,e)),s);return{max:n,min:s}}(K.saliVals),j=.8/(X.max-X.min),J=n.shell.getTableView(t.name);J.grid.columns.byName(z.name).visible=!1;const Q=J.addViewer(o.VIEWER.SCATTER_PLOT,{xColumnName:a[0],yColumnName:a[1],size:Z.name,color:h.name,showXSelector:!1,showYSelector:!1,showSizeSelector:!1,showColorSelector:!1,markerMinSize:5,markerMaxSize:25,title:c}),tt=Q.getInfo().canvas,et=function(t,e,s,n,i){const r=new Array(t.n1.length).fill(null);for(let e=0;e<t.n1.length;e++){const s=t.n1[e],n=t.n2[e];r[e]={id:e,mols:[s,n],selected:!1,a:[],b:[]}}const a=o.DataFrame.create(r.length);return k.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),i),a.col(t).semType=n})),a.columns.addNewFloat(D).init((t=>Math.abs(s.get(r[t].mols[0])-s.get(r[t].mols[1])))),a.columns.addNewInt(B).init((t=>t)),a.columns.addNewFloat(H).init((e=>t.saliVals[e])),a.columns.addNewFloat(W).init((e=>t.simVals[e])),a.name=`${O}${x}`,{lines:r,linesDf:a}}(K,e,h,p,g),st=T?T(et.linesDf,k).sort([H],[!1]):et.linesDf.plot.grid().sort([H],[!1]);t.temp[".cliffsDfGrid"]=st;const nt=i.button(`${et.linesDf.rowCount} cliffs`,(()=>{J.dockManager.dock(st,"down",null,"Activity cliffs",A??.2)}));nt.classList.add("scatter_plot_link","cliffs_grid"),Q.root.append(nt);const it=i.switchInput("Show only cliffs",!1,(()=>{it.value?(Q.dataFrame.setTag(U,z.name),t.rows.match({[z.name]:!0}).filter(),F.next(z.name)):(Q.dataFrame.setTag(U,""),t.filter.setAll(!0,!0),F.next(""))}));it.root.classList.add("scatter_plot_link","show_only_cliffs"),Q.root.append(it.root),F.subscribe((t=>{it.enabled=""===t||t===z.name}));const ot=n.events.onViewerClosed.subscribe((t=>{t.args.viewer===Q&&(J.dockManager.close(st.root),ot.unsubscribe(),J.subs=J.subs.filter((t=>t!==ot)))}));return J.subs.push(ot),et.linesDf.onCurrentCellChanged.subscribe((()=>{M=!0;const s=et.linesDf.currentCol&&et.linesDf.currentCol.name===k[1]?1:0,o=-1!==et.linesDf.currentRowIdx?et.lines[et.linesDf.currentRowIdx]:null;Q.dataFrame.currentRowIdx=o?o.mols[s]:-1,Q.dataFrame.filter.set(0,!et.lines[0].selected),Q.dataFrame.filter.set(0,et.lines[0].selected),o&&setTimeout((()=>{!function(t,e,s,o,r,a,l,c){const h=e.getPane("Cliff Details");i.empty(h.root);const u=c({cashedData:s,line:o,df:t,seqCol:r,activityCol:a,sali:l});h.root.append(u),setTimeout((()=>{n.shell.o=e.root}),500)}(t,I,N,o,e,h,et.linesDf.get(H,o.id),C);const s=Q.dataFrame.getSortedOrder(J.grid.sortByColumns,J.grid.sortTypes);J.grid.scrollToCell(e.name,s.indexOf(Q.dataFrame.currentRowIdx))}),1e3)})),et.linesDf.onSelectionChanged.subscribe((e=>{if(!1===et.linesDf.selection.anyTrue)et.lines.forEach((t=>{t.selected=!1}));else if(-1!==et.linesDf.mouseOverRowIdx){const t=et.lines[et.linesDf.mouseOverRowIdx];t.selected=!t.selected}setTimeout((()=>{const e=o.BitSet.create(t.rowCount);et.lines.forEach((t=>{t.selected&&t.mols.forEach((s=>{e.set(s,t.selected,!0)}))})),t.selection.copyFrom(e),J.grid.invalidate()}),300)})),t.onSelectionChanged.subscribe((e=>{v?v=!1:!1===t.selection.anyTrue&&"number"==typeof e&&(et.lines.forEach((t=>{t.selected=!1})),st.dataFrame.selection.setAll(!1,!1),st.invalidate())})),tt.addEventListener("mousemove",(function(n){clearTimeout(L),L=s.g.setTimeout((function(){const s=$(n,tt,et.lines);s&&-1===t.mouseOverRowIdx&&i.tooltip.show(w({cashedData:N,line:s,df:t,seqCol:e,activityCol:h}),n.clientX,n.clientY)}),500)})),tt.addEventListener("mousedown",(function(e){v=!0;const s=$(e,tt,et.lines);if(s&&-1===t.mouseOverRowIdx){e.ctrlKey?(s.selected=!s.selected,et.linesDf.selection.set(s.id,s.selected)):et.linesDf.currentRowIdx!==s.id&&(et.linesDf.currentRowIdx=s.id,t.currentRowIdx=s.mols[0],t.filter.set(0,!et.lines[0].selected),t.filter.set(0,et.lines[0].selected));const n=et.linesDf.getSortedOrder(st.sortByColumns,st.sortTypes);st.scrollToCell(k[0],n.indexOf(s.id))}})),Q.onEvent("d4-before-draw-scene").subscribe((e=>{const s=function(t,e,s,n,i,o,r){const a=n.lines,l=t.getInfo().canvas.getContext("2d"),c=t.dataFrame.columns.byName(e),h=t.dataFrame.columns.byName(s);for(let e=0;e<a.length;e++){const s=t.worldToScreen(c.get(a[e].mols[0]),h.get(a[e].mols[0])),u=t.worldToScreen(c.get(a[e].mols[1]),h.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",p=i[e]===1/0?1:.2+(i[e]-r)*o;l.strokeStyle=`rgba(${d},${p})`,l.lineWidth=a[e].id===n.linesDf.currentRowIdx?3:1,m.lineTo(a[e].b[0],a[e].b[1]),l.stroke(m)}return a}(Q,a[0],a[1],et,K.saliVals,j,X.min);if(M){const t=s[et.linesDf.currentRowIdx];setTimeout((()=>{const{zoomLeft:e,zoomRight:s,zoomTop:n,zoomBottom:i}=function(t,e,s,n,i,o){const r=Math.abs(s-i),a=Math.abs(n-o),l=t/r,c=e/a,h=Math.min(l,c),u=t/h*5,m=e/h*5,d=(s<i?s:i)+r/2-u/2,p=(n>o?n:o)-a/2+m/2;return{zoomLeft:d,zoomRight:d+u,zoomTop:p,zoomBottom:p-m}}(Q.viewport.width,Q.viewport.height,Q.dataFrame.get(a[0],t.mols[0]),Q.dataFrame.get(a[1],t.mols[0]),Q.dataFrame.get(a[0],t.mols[1]),Q.dataFrame.get(a[1],t.mols[1]));Q.zoom(e,n,s,i)}),300),M=!1}it.value?t.rows.match({[z.name]:!0}).filter():!0===it.enabled&&t.filter.setAll(!0,!1)})),Q.addProperty("similarityLimit","double",S),I=function(){const t=i.accordion(),e=i.element("i");return e.className="grok-icon svg-icon svg-view-layout",t.addTitle(i.span([e,i.label("Activity cliffs")])),t.addPane("Cliff Details",(()=>i.divText("Cliff has not been selected")),!0),n.shell.o=t.root,t}(),Q}(t,w,null,d,"Activity cliffs",r,c,y,h,o.SEMTYPE.MACROMOLECULE,p,C,0,Ut,Vt,Kt,{...m??{},[G]:g}),b=h===a.AL.UMAP?2e5:2e4,A=h===a.AL.UMAP?5e3:2e3;if(t.rowCount>b)return void n.shell.warning(`Too many rows, maximum for sequence activity cliffs is ${b}`);const S=o.TaskBarProgressIndicator.create("Running sequence activity cliffs ...");return new Promise(((e,s)=>{t.rowCount>A&&!m?.[ms]?i.dialog().add(i.divText("Activity cliffs analysis might take several minutes.\n Do you want to continue?")).onOK((async()=>{T().then((t=>e(t))).catch((t=>s(t)))})).onCancel((()=>{e(void 0)})).show():T().then((t=>e(t))).catch((t=>s(t)))})).catch((t=>{const[e,s]=(0,pt.yf)(t);throw us.logger.error(e,void 0,s),t})).finally((()=>{S.close()}))}async function Ds(t,e,s,l=h.U.LEVENSHTEIN,c,u,d){if(await(0,r.gw)(10),!(0,Ae.n)(e,"Sequence space"))return;let p;const g=o.TaskBarProgressIndicator.create("Initializing sequence space ...");try{function f(e,s,r){let a=null,l=null;t.columns.names().includes(y[0])?(a=t.columns.byName(y[0]),l=t.columns.byName(y[1])):(a=t.columns.add(o.Column.float(y[0],t.rowCount)),l=t.columns.add(o.Column.float(y[1],t.rowCount)),c&&(p=n.shell.tableView(t.name).scatterPlot({x:y[0],y:y[1],title:"Sequence space"}))),d?.[m]&&(p?.root&&i.setUpdateIndicator(p.root,!1),a.init((t=>r[t]?r[t][0]:void 0)),l.init((t=>r[t]?r[t][1]:void 0)));const h=e/s*100;g.update(h,`Running sequence space ... ${h.toFixed(0)}%`)}const y=Bt(t),w=o.DataFrame.fromColumns([e]).clone(),C=function(t,e){const s=e.categories.map(((t,e)=>t?null:e)).filter((t=>null!==t)),n=[...e.getRawData()],i=[];let o=0;for(let e=0;e<t.rowCount;e++)s.includes(n[e])&&(t.rows.removeAt(e-o),i.push(e),o+=1);return i}(w,e),T={seqCol:w.col(e.name),methodName:s,similarityMetric:l,embedAxesNames:y,options:{...d,sparseMatrixThreshold:u??.5,usingSparseMatrix:t.rowCount>2e4}},b=s===a.AL.UMAP?5e5:15e3,A=s===a.AL.UMAP?5e3:2e3;if(t.rowCount>b)return void n.shell.warning(`Too many rows, maximum for sequence space is ${b}`);async function S(){t.columns.add(o.Column.float(y[0],t.rowCount)),t.columns.add(o.Column.float(y[1],t.rowCount)),c&&(p=n.shell.tableView(t.name).scatterPlot({x:y[0],y:y[1],title:"Sequence space"}),i.setUpdateIndicator(p.root,!0));let e=null;const s=n.events.onViewerClosed.subscribe((t=>{const i=t.args.viewer;i?.getOptions()?.look?.title&&p?.getOptions()?.look?.title&&i?.getOptions()?.look?.title===p?.getOptions()?.look?.title&&(n.events.fireCustomEvent(Ot,{}),s.unsubscribe(),e?.(),g.close())})),r=new Promise((async(t,s)=>{try{e=t,t(await Wt(T,d?.[ms]?void 0:f))}catch(t){s(t)}})),a=await r;return g.close(),s.unsubscribe(),a?E(a):a}if(!(t.rowCount>A)||d?.[ms])return await S();function E(e){const s=e.coordinates;for(const e of s){const s=e.toList();C.forEach((t=>s.splice(t,0,null)));let n=t.columns.byName(e.name);n||(n=o.Column.float(e.name,s.length),t.columns.add(n)),n.init((t=>s[t]))}if(c)return p||(p=n.shell.tableView(t.name).scatterPlot({x:y[0],y:y[1],title:"Sequence space"})),i.setUpdateIndicator(p.root,!1),p}i.dialog().add(i.divText("Sequence space analysis might take several minutes.\n Do you want to continue?")).onOK((async()=>{await S().catch((t=>{g.close();const[e,s]=(0,pt.yf)(t);us.logger.error(e,void 0,s),p&&p.close()}))})).onCancel((()=>{g.close()})).show()}catch(M){console.error(M),g.close();const[v,N]=(0,pt.yf)(M);us.logger.error(v,void 0,N),p&&p.close()}}async function Hs(t,e,s){const r=o.TaskBarProgressIndicator.create("Converting to atomic level ...");try{await async function(t,e,s){if(0===o.Func.find({package:"Chem",name:"getRdKitModule"}).length)return void n.shell.warning('Transformation to atomic level requires package "Chem" installed.');if(s){const s=q.Cn.getOrCreate(e);return s.isHelm()||(e=s.convert(ht.r2.HELM)),void async function(t,e){const s=await Be(t,e);t.columns.add(s,!0),await n.data.detectSemanticTypes(t)}(t,e)}if(!(0,Ae.n)(e,"To Atomic Level"))return;const r=ds().getBioLib(),a=await(0,hs.i0)(t,e,r);null!==a.col&&(t.columns.add(a.col,!0),await n.data.detectSemanticTypes(t)),a.warnings&&a.warnings.length>0&&n.shell.warning(i.list(a.warnings))}(t,e,s)}finally{r.close()}}function Ws(){(0,Se.K)()}async function Bs(t=null,e=null){return(0,Se.K)({col:t,clustersCol:e})}async function ks(){const t=n.shell.tv,e=t.dataFrame.columns.toList().filter((t=>t.semType==o.SEMTYPE.MACROMOLECULE&&(q.Cn.getOrCreate(t),!0))),s=async e=>{if(!(0,Ae.n)(e,"Composition"))return;const s=t.addViewer("WebLogo",{sequenceColumnName:e.name});n.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)),n=e.find((t=>q.Cn.getOrCreate(t).isMsa())),o=i.choiceInput("Column",n?n.name:t[0],t);i.dialog({title:"Composition Analysis",helpUrl:"https://datagrok.ai/help/datagrok/solutions/domains/bio/#sequence-composition"}).add(i.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 n.shell.error("Current table does not contain sequences")}function Us(t){return new K.i(t).importFasta()}function Vs(t){return console.log(t),[]}function $s(){const t=(0,J.B)()[0];(0,ne.O)(t)}function Ys(){let t;try{t=function(){function t(t){return t===h[0]?[De.M].concat(m.getMonomerSymbolsByType("PEPTIDE")):t===h[1]?[De.M].concat(m.getMonomerSymbolsByRGroup(3,"PEPTIDE")):["C"]}function e(){"N-Cys"===u.value?(d=t("N-O"),p=t("N-Cys")):(d=t(u.value),p=[...d]),g=i.choiceInput("R1:",d[0],d,(()=>{r.next()})),y=i.choiceInput("R2:",p[0],p,(()=>{r.next()})),r.next(),i.empty(w),[g,y].forEach((t=>{w.appendChild(t.root)}))}const s=new f.Subject,r=new f.Subject;s.subscribe((()=>{a.cyclizationType=u.value,e()})),r.subscribe((()=>{a.rightTerminal=y.value,a.leftTerminal=g.value}));const a={},l=["Cyclization"],c=i.choiceInput("Modification",l[0],l,(()=>a.transformationType=c.value)),h=["N-O","R3-R3","N-Cys"],u=i.choiceInput("Type",h[2],h,(()=>{s.next()})),m=re.NT.instance.getBioLib();let d=[],p=[],g=i.choiceInput("R1:",d[0],d,(()=>{a.leftTerminal=g.value})),y=i.choiceInput("R2:",p[0],p,(()=>{a.rightTerminal=y.value}));const w=i.divV([g.root,y.root]);e(),a.cyclizationType=u.value,a.leftTerminal=g.value,a.rightTerminal=y.value,a.transformationType=c.value;const C=n.shell.t.columns.bySemTypeAll(o.SEMTYPE.MACROMOLECULE);if(!C)throw new Error("No dataframe with maceomolecule columns open");const T=i.columnInput("Column",n.shell.t,C[0],null,{filter:t=>t.semType===o.SEMTYPE.MACROMOLECULE}),b=i.boolInput("Get HELM",!0);i.tooltip.bind(b.root,"Add HELM column");const A=i.div([T,c,u,w,b]);return i.dialog("Poly Tool").add(A).onOK((async()=>{const t=T.value;t?os(t,a,b.value):n.shell.warning("No marcomolecule column chosen!")}))}(),t.show()}catch(t){n.shell.warning("To run PolyTool, open a dataframe with macromolecules")}}function qs(){return new _e}async function Ks(t){const e=o.TaskBarProgressIndicator.create("Test detectMacromolecule..."),s=(await n.dapi.files.list(t,!0,"")).filter((t=>t.fileName.endsWith(".csv")));let i=0;const r=[];for(const a of s)try{const e=await n.dapi.files.readAsText(t+a.fullPath),s=o.DataFrame.fromCsv(e);for(const t of s.columns)await n.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{i+=1,e.update(100*i/s.length,`Test ${a.fileName}`)}n.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 Zs(t,e){await(0,ve.n)(t,e)}function zs(t){const e=q.Cn.getOrCreate(t).stats;return Object.keys(e.freq)}function Xs(){return new Qt}function js(){const t=n.shell.v,e=t.addViewer("Sequence Similarity Search");t.dockManager.dock(e,"down")}function Js(){return new ee}function Qs(){const t=n.shell.v,e=t.addViewer("Sequence Diversity Search");t.dockManager.dock(e,"down")}function tn(t){const e=(0,J.B)();1===e.length?t.func.prepare({macromolecules:e[0]}).call(!0):new Ft.uH(e)}function en(t){n.shell.tv.getFiltersGroup({createDefaultFilters:!1}).updateOrAdd({type:"Bio:bioSubstructureFilter",column:t.name,columnName:t.name}),n.shell.tv.grid.scrollToCell(t,0)}async function sn(t,e,s){return j(t,e,s,Y.IDENTITY)}async function nn(t,e,s){return j(t,e,s,Y.SIMILARITY)}function on(){(0,ie.C2)()}function rn(){return new oe.ST}async function an(){const t=o.TaskBarProgressIndicator.create("WebLogo");try{const t=new URLSearchParams(window.location.search),e=new Ee(t,"webLogoLargeApp"),s=await us.files.readCsv("data/sample_PT_100000x5.csv");await n.data.detectSemanticTypes(s),await e.init(s)}finally{t.close()}}async function ln(){const t=o.TaskBarProgressIndicator.create("WebLogo ...");try{const t=new URLSearchParams(window.location.search),e=new Ee(t,"webLogoAggApp"),s=await us.files.readCsv("data/sample_FASTA_PT_activity.csv");await n.data.detectSemanticTypes(s),await e.init(s)}finally{t.close()}}async function cn(){const t=o.TaskBarProgressIndicator.create("getRegion ...");try{const t=new URLSearchParams(window.location.search),e=new ls(t,"getRegionApp");await e.init()}finally{t.close()}}async function hn(){const t=o.TaskBarProgressIndicator.create("getRegion ...");try{const t=new URLSearchParams(window.location.search),e=await us.files.readCsv("data/sample_HELM_empty_vals.csv"),s=new ls(t,"getRegionHelmApp");await s.init({df:e,colName:"HELM"})}finally{t.close()}}function un(t,e){!function(t,e){const s=q.Cn.getOrCreate(t.column),i=Object.values(ht.r2).filter((t=>t!==s.units));e.group("Copy").items(i,(e=>{const s=q.Cn.getOrCreate(t.column),i=e===ht.r2.SEPARATOR?us.properties.DefaultSeparator:void 0,o=s.getConverter(e,i)(t.value);navigator.clipboard?(navigator.clipboard.writeText(o),n.shell.info(`Value of notation '${e}' copied to clipboard`)):n.shell.warning("The clipboard functionality requires a secure origin — either HTTPS or localhost")}))}(t,e)}async function mn(){await async function(){let t,e;try{const s=new le("Similarity, Diversity","Sequence similarity tracking and evaluation dataset diversity");await s.step("Load DNA sequences",(async()=>{n.shell.windows.showContextPanel=!1,n.shell.windows.showProperties=!1,e=await us.files.readCsv(he),t=n.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){ce(t)}}()}async function dn(){await async function(){let t,e,s,i,r;try{const a=new le("Sequence Space","Exploring sequence space of Macromolecules, comparison with hierarchical clustering results");await a.step("Load DNA sequences",(async()=>{[i,t,e]=await Promise.all([us.files.readCsv(ge),de(),pe()]),s=n.shell.addTableView(i),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,n.shell.windows.showContextPanel=!1,n.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,n){let i;{const t=Object.values(se);for(let s=0;s<t.length;s++){const n=t[s];if(!e.col(n)){const i=s==t.length-1;e.columns.add(o.Column.float(n,e.rowCount),i)}}if(e.rowCount>=1){const n=e.getCol(s).toList(),i=Date.now();us.logger.debug("Bio: demoBio01aUI(), calc reduceDimensionality start...");const o=await Gt(n,"UMAP",kt.W.Levenshtein,{}),r=Date.now();us.logger.debug(`Bio: demoBio01aUI(), calc reduceDimensionality ET: ${(r-i)/1e3} s`);for(let s=0;s<t.length;s++){const n=t[s],i=e.getCol(n),r=o.embedding[s];i.init((t=>r[t]))}const a=Date.now();us.logger.debug(`MLB: MlbVrSpaceBrowser.buildView(), postprocess reduceDimensionality ET: ${(a-r)/1e3} s`)}i=await e.plot.fromType(o.VIEWER.SCATTER_PLOT,{xColumnName:se.X,yColumnName:se.Y,lassoTool:!0})}return t.dockManager.dock(i,o.DOCK_TYPE.RIGHT,null,"Sequence Space",.35),i}(s,i,fe)}),{description:"Reduce sequence space dimensionality to display on 2D representation.",delay:2e3}).step("Cluster sequences",(async()=>{const n=i.getCol(fe).toList(),o=me.H.calc(n,((t,e)=>ue.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()=>{i.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=i.getCol("sequence_id");i.selection.init((e=>["c0_seq120","c0_seq105","c0_seq121","c0_seq93"].includes(t.get(e)))),i.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){ce(t)}}()}async function pn(){await async function(){let t,e,s,i,r;const l=a.AL.UMAP;try{const a=new le("Activity Cliffs","Activity Cliffs analysis on Macromolecules data");await a.step("Load DNA sequences",(async()=>{n.shell.windows.showContextPanel=!1,n.shell.windows.showProperties=!1,[s,t,e]=await Promise.all([us.files.readCsv(Ce),de(),pe()]),i=n.shell.addTableView(s),i.grid.props.rowHeight=22,i.grid.columns.byName("cluster").visible=!1,i.grid.columns.byName("sequence").width=300,i.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 Fs(s,s.getCol("Sequence"),s.getCol("Activity"),80,l,h.U.LEVENSHTEIN),i.dockManager.dock(r,o.DOCK_TYPE.RIGHT,null,"Activity Cliffs",.35),we()(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 n=o.TaskBarProgressIndicator.create("Running sequence clustering..."),r=s.getCol("sequence").toList(),a=me.H.calc(r,((t,e)=>ue.T(t,e)/((t.length+e.length)/2))),l=await t.hierarchicalClusteringByDistance(a,"ward");n.close(),e.injectTreeForGrid(i.grid,l,void 0,150,void 0),i.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){ce(t)}}()}async function gn(){await async function(){const t="HELM";let e,s,a;try{await new le("Atomic Level","Atomic level structure of Macromolecules").step("Loading Macromolecules notation 'Helm'",(async()=>{n.shell.windows.showContextPanel=!1,n.shell.windows.showProperties=!1,e=await us.files.readCsv("samples/HELM.csv"),s=n.shell.addTableView(e);for(let e=0;e<s.grid.columns.length;e++){const n=s.grid.columns.byIndex(e);[t,"Activity"].includes(n.name)||(n.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 Hs(e,s,!1)}),{description:"Get atomic level structures of Macromolecules.",delay:2e3}).step("Sketcher",(async()=>{const s=`molfile(${t})`;e.currentCell=e.cell(1,s);const n=e.currentCell.value,l=new o.chem.Sketcher(o.chem.SKETCHER_MODE.INPLACE);l.setMolFile(n),a=i.dialog().add(l).show(),await(0,r.gw)(3e3),a.close()}),{description:"Display atomic level structure within a sketcher.",delay:2e3}).start()}catch(t){ce(t)}}()}async function fn(){await async function(){let t,e,s,i,r,l;const c="msa(HELM)",u=a.AL.UMAP;try{const a=new le("Helm, MSA, Sequence Space","MSA and composition analysis on Helm data");await a.step("Load peptides with non-natural aminoacids in 'HELM' notation",(async()=>{t=n.shell.addTableView(e=await us.files.readCsv(be)),n.shell.windows.showContextPanel=!1,n.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=Te.J[0];i=await(0,Te.f)(s,c,t,1.53,0,void 0),e.columns.add(i),await n.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()=>{l=await Ds(e,i,u,h.U.LEVENSHTEIN,!0),t.dockManager.dock(l,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:c,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){ce(t)}}()}async function yn(t,e){var s;He(s=e),s.setTag("units",ht.r2.SEPARATOR),s.setTag("separator","-"),await n.data.detectSemanticTypes(t)}async function wn(t){const e=(0,Z.Xk)(t),s=JSON.stringify(e);o.Utils.download(`${t.name}.json`,s)}async function Cn(t,e,s){const i=await t.readAsString();await async function(t,e,s){const i=o.TaskBarProgressIndicator.create("detectMacromolecule probe ...");try{let a=0;const l=await n.functions.call("Bio:detectMacromoleculeEnableStore");let c=0;for(let h=0;h<s;++h){const u=o.DataFrame.fromCsv(t),m=e?u.getCol(e):u.columns.byIndex(0);await n.functions.call("Bio:detectMacromolecule",{col:m})!==o.SEMTYPE.MACROMOLECULE&&(++c,console.warn(`Reject reason: ${l.last.rejectReason}`));const d=h/s;d-a>=.1&&(a=d,i.update(100*d,`detectMacromolecule probe ${c}/${h}/${s} ...`),await(0,r.gw)(0))}c>0?n.shell.warning(`detectMacromolecule failed ${c} / ${s}`):n.shell.info(`detectMacromolecule success ${s}`)}finally{i.close()}}(i,e,s)}},9017:(t,e,s)=>{"use strict";s.d(e,{k:()=>o});class n{constructor(){this.value=0,this.parentI=0,this.parentJ=0}}class i{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="",n="",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,n=this.seq2.substr((e-1)*this.step,this.step)+n):this.dpGrid[t][e].parentJ==e?(n=o+n,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,n=e-1>=0?this.seq2.substr((e-1)*this.step,this.step)+n:o+n);const i=t;t=this.dpGrid[t][e].parentI,e=this.dpGrid[i][e].parentJ}return new i(s,n,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 n);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 n);this.dpGrid.push(t)}let t=0,e=0,s=0;for(let n=1;n<=this.len1;n++)for(let i=1;i<=this.len2;i++)this.fillOne(n,i),this.dpGrid[n][i].value<=0?(this.dpGrid[n][i].value=0,this.dpGrid[n][i].parentI=0,this.dpGrid[n][i].parentJ=0):0==this.dpGrid[this.dpGrid[n][i].parentI][this.dpGrid[n][i].parentJ].value&&(this.dpGrid[n][i].parentI=0,this.dpGrid[n][i].parentJ=0),this.dpGrid[n][i].value>t&&(t=this.dpGrid[n][i].value,e=n,s=i);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,n=""){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,-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,-1,-3.4,-2.9,-12.5,-6.3,-11.6,-8.1,3.3,6,-1.6,3.8,-10.5,-10.1,-11.1,-11.1,-9,-6.9,-8.2,-9.1,-14,-11.4,-12.3,-12.1,-3.1,.2,-3.2,-2.2,-10.4,-9.1,-10.4,-11.5,-2.1,1.2,-1.1,-1.4,-9.4,-5.6,-8.1,-8,8.6,12.4,8.6,9.5,-50,-10.4,-50,-11.6,-7.2,-5.7,-7.5,-7.4,-50,-8.6,-15.7,-9.7,-3,-3.7,-3.2,-5.9],[-11.1,-11.9,-10.6,-11.3,-2.6,-4.1,-1.7,-3.5,-11.4,-9.6,-9.6,-9.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,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,-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(n),this.setSequences(t,e),this.setGap(s)}}},7983:(t,e,s)=>{"use strict";s.d(e,{HV:()=>p,QF:()=>d,pf:()=>m,uH:()=>u});var n=s(4469),i=s(3870),o=s(976),r=s(7241),a=s(4293),l=s(1061),c=s(8447);const h="substr_helm";class u{constructor(t){this.col=t[0],this.createUI()}editHelmLinkAction(){(0,a.Y)(this.inputsDiv,this.grid.root),i.tools.waitForElementInDom(this.grid.root).then((()=>{setTimeout((()=>{this.grid.cell(h,0).element.children[0].dispatchEvent(new KeyboardEvent("keydown",{key:"Enter"}))}),100)}))}updateInputs(){const t=this.units===c.r2.HELM?i.divV([this.columnsInput,this.editHelmLink]):this.units===c.r2.SEPARATOR?i.inputs([this.columnsInput,this.substructureInput,this.separatorInput]):i.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=n.shell.tv.dataFrame,e={filter:t=>t.semType===o.SEMTYPE.MACROMOLECULE};this.columnsInput=i.columnInput("Column",t,this.col,(t=>{this.col=t,this.updateNotationDiv(),this.updateInputs()}),e),this.substructureInput=i.stringInput("Substructure",""),this.editHelmLink=i.link("Edit helm",(()=>this.editHelmLinkAction()),void 0,{style:{position:"relative",left:"95px"}});const s=o.DataFrame.create(1);s.columns.addNewString(h).init((t=>"")),s.col(h).semType=this.col.semType,s.col(h).setTag(o.TAGS.UNITS,c.r2.HELM),this.grid=s.plot.grid(),this.separatorInput=i.stringInput("Separator",this.separator),this.inputsDiv=i.div(),this.units=this.col.getTag(o.TAGS.UNITS),this.separator=this.col.getTag("separator"),this.updateInputs(),this.dialog=i.dialog("Substructure Search").add(i.divV([i.divText(`Notation: ${this.units}`,"notation-text"),this.inputsDiv])).onOK((async()=>{let t,e=this.units===c.r2.HELM?s.get(h,0):this.substructureInput.value;this.units===c.r2.SEPARATOR&&this.separatorInput.value!==this.separator&&""!==this.separatorInput.value&&(e=e.replaceAll(this.separatorInput.value,this.separator)),t=this.units===c.r2.HELM?await d(e,this.col):m(e,this.col),this.col.dataFrame.filter.and(t)})).show()}}function m(t,e,s){const n=s?function(t,e){const s=`${e}`.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),n=t.charAt(0)===e,i=t.charAt(t.length-1)===e,o=t.replace(new RegExp(`^${s}|${s}$`,"g"),"");return n?i?`${s}${o}${s}`:`${s}${o}${s}|${s}${o}$`:i?`^${o}${s}|${s}${o}${s}`:`^${o}${s}|${s}${o}${s}|${s}${o}$`}(t,s):t,i=o.BitSet.create(e.length);for(let s=0;s<e.length;s++){const o=e.get(s);(o.match(n)||o===t)&&i.set(s,!0,!1)}return i}async function d(t,e){e.version!==e.temp["last-invalidated-version"]&&await p(e,!0);const s=o.Column.string("helm",1).init((e=>t));s.semType=o.SEMTYPE.MACROMOLECULE,s.setTag(o.TAGS.UNITS,c.r2.HELM);const i=await(0,r.D)(s,!0,e.temp["monomers-dict"]);return(await n.functions.call("Chem:searchSubstructure",{molStringsColumn:e.temp["monomeric-mols"],molString:i.get(0),molBlockFailover:""})).get(0)}async function p(t,e){const s=o.TaskBarProgressIndicator.create(`Invalidating molfiles for ${t.name}`);try{await(0,l.gw)(10);const s=new Map,n=await(0,r.D)(t,e,s);t.temp["monomeric-mols"]=n,t.temp["monomers-dict"]=s,t.temp["last-invalidated-version"]=t.version}finally{s.close()}}},2568:(t,e,s)=>{"use strict";s.d(e,{l:()=>a,n:()=>r});var n=s(4469),i=s(976),o=s(499);function r(t,e,s=[],i=[],o=!0){const[r,l]=a(t,e,s,i);return o&&!r&&n.shell.warning(l),r}function a(t,e,s=[],r=[]){let a=!0,l="";const c=o.Cn.getOrCreate(t);if(t.semType!==i.SEMTYPE.MACROMOLECULE)n.shell.warning(e+" analysis is allowed for Macromolecules semantic type"),a=!1;else{const t=c.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(!c.isHelm()){const t=c.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]}},3553:(t,e,s)=>{"use strict";s.d(e,{Of:()=>o,WY:()=>h,jB:()=>u,mU:()=>a,rs:()=>c});var n,i,o,r=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"}(n||(n={})),function(t){t.AAR="AAR",t.POSITION="Pos",t.SELECTION="selection"}(i||(i={})),function(t){t.MONOMER="Monomer",t.MACROMOLECULE_DIFFERENCE="MacromoleculeDifference",t.ACTIVITY="activity",t.ACTIVITY_SCALED="activityScaled"}(o||(o={}));const a="MSA";var l,c;!function(t){t.CELL_CHANGING="isCellChanging"}(l||(l={})),function(t){t.SEPARATOR="."}(c||(c={}));const h="3.3.1",u={pepsea:{gapOpen:1.53,gapExtend:0,method:r.J[0]},kalign:{gapOpen:-1,gapExtend:-1,terminalGap:-1}}},4004:(t,e,s)=>{"use strict";s.d(e,{O:()=>m,o:()=>d});var n=s(976),i=s(3870),o=s(4469),r=s(3336),a=s.n(r),l=s(8447),c=s(499);let h=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=c.Cn.getOrCreate(e),r=s.notation;const m=i.divText("Current notation: "+r,{style:{"text-align":"center","font-weight":"bold","font-size":"14px",padding:"5px"}}),p=[l.r2.FASTA,l.r2.SEPARATOR,l.r2.HELM],g=i.columnInput("Column",o.shell.t,e,(t=>{t.semType===n.SEMTYPE.MACROMOLECULE?(e=t,s=c.Cn.getOrCreate(e),r=s.notation,r===l.r2.HELM&&(w.value="/"),m.textContent="Current notation: "+r,y=p.filter((t=>t!==r)),T=i.choiceInput("Convert to",y[0],y,C),C(),h?.clear(),h?.add(i.div([m,g.root,T.root,w.root]))):g.value=e})),f=["-",".","/"];let y=p.filter((t=>t!==r));const w=i.choiceInput("Separator",f[0],f),C=()=>{T.value!==l.r2.SEPARATOR?a()(w.root).hide():a()(w.root).show()};let T=i.choiceInput("Convert to",y[0],y,C);C(),T.onChanged((()=>{C()})),null==h&&(h=i.dialog("Convert Sequence Notation").add(i.div([m,g.root,T.root,w.root])).onOK((async()=>{const t=T.value,s=w.value??void 0;await d(e,t,s)})).show({x:350,y:100}),u.push(h.onClose.subscribe((t=>{u.forEach((t=>{t.unsubscribe()})),u=[],h=null}))))}async function d(t,e,s){const n=c.Cn.getOrCreate(t).convert(e,s);t.dataFrame.columns.add(n);const i=await o.functions.call("Bio:detectMacromolecule",{col:n});return i&&(n.semType=i),await o.data.detectSemanticTypes(t.dataFrame),n}},7958:(t,e,s)=>{"use strict";function n(t){return"string"==typeof t||t instanceof String?t:"StateError"===t.constructor.name?t.message:"StateError"===t.constructor.name&&"$thrownJsError"in t?n(t.$thrownJsError):t instanceof Error?t.message:t.toString()}function i(t){return t instanceof Error?t.stack:"StateError"===t.constructor.name&&"$thrownJsError"in t?i(t.$thrownJsError):void 0}function o(t){return[n(t),i(t)]}s.d(e,{yf:()=>o})},2918:(t,e,s)=>{"use strict";s.d(e,{NT:()=>T,P4:()=>f,cf:()=>w});var n=s(4469),i=s(3870),o=s(976),r=s(701),a=s(6584),l=s(922),c=s(1047);class h{constructor(t){this.rawLib=t}isValid(){return this.rawLib.every((t=>"object"==typeof t&&Object.values(c.Wc).every((e=>e in t&&"string"==typeof t[e]))))}getJsonMonomerLib(){const t=[];return this.rawLib.forEach((e=>{const s=this.prepareMonomer(e);t.push(s)})),t}prepareMonomer(t){const e={...c.Z2};Object.entries(c.Wc).forEach((([s,n])=>{const i=t[n];e[s]=i}));let s="smiles";const n=t[c.Wc[s]],i=new u(n),o=i.getCappedSmiles();return e[s]=o,s="rgroups",e[s]=m.getRGroups(i.getNumberOfRGroups()),s="molfile",e[s]=new d(i.getSmilesWithRGroups()).getMolfile(),e}}class u{constructor(t){const e=new RegExp("\\[r\\]","g");let s=0;this.smilesWithRGroups=t.replace(e,(t=>(++s,`[${s}*]`))),this.numberOfRGroups=s}getSmilesWithRGroups(){return this.smilesWithRGroups}getCappedSmiles(){return this.capRGroups()}getNumberOfRGroups(){return this.numberOfRGroups}capRGroups(){let t=this.smilesWithRGroups.replace("[1*]","[H:1]");return t=t.replace("[2*]","[OH:2]"),t.replace("[3*]","[H:3]")}}class m{constructor(){}static getRGroups(t){return c.nJ.slice(0,t)}}class d{constructor(t){this.smilesWithRGroups=t}getMolfile(){let t=o.chem.convert(this.smilesWithRGroups,o.chem.Notation.Smiles,o.chem.Notation.MolBlock);return t=this.restoreRGPLine(t),t=this.fixRGroupSymbols(t),t}restoreRGPLine(t){return t.replace("M ISO","M RGP")}fixRGroupSymbols(t){return t.replace(/\bR\b/g,"R#")}}var p=s(7228),g=s(2991);async function f(){return await Promise.all((await n.dapi.files.list(a.BX,!0,"")).map((async t=>t.fullPath.substring(a.BX.length))))}async function y(){const t=i.dialog({title:"Manage files"}).add(i.fileBrowser({path:"System:AppData/Bio/libraries"}).root).addButton("OK",(()=>t.close())).show()}async function w(){const t=i.button("Manage",y),e=i.inputs([]),s=await f(),r=await(0,a.nW)();for(const t of s){const s=i.boolInput(t,!r.exclude.includes(t),(()=>{1==s.value?r.exclude=r.exclude.filter((e=>e!=t)):r.exclude.includes(t)||r.exclude.push(t),(0,a.tW)(r).then((async()=>{await T.instance.loadLibraries(!0),n.shell.info("Monomer library user settings saved.")}))}));e.append(s.root)}return new o.Widget(i.divV([e,i.div(t)]))}class C{constructor(t,e){this._monomers={},this._onChanged=new r.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 n=this.getMonomerSymbolsByType(e).map((t=>this.getMonomer(e,t)));return n=n.filter((t=>null!==t)),0===n.length?[]:(n=n.filter((e=>{if(!e?.rgroups)return!1;let s=e?.rgroups.length>=t;return l._.getInstance(e.molfile).atomTypes.map(((t,e)=>"R#"===t?e:-1)).filter((t=>-1!==t)),s&&(s=!0),s})),n.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 T{constructor(){this._monomerLib=new C({}),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([f(),(0,a.nW)()]),n=e.filter((t=>!s.exclude.includes(t))).filter((t=>!(s.explicit.length>0)||s.explicit.includes(t))),i=await Promise.all(n.map((t=>this.readLibrary(a.BX,t).catch((e=>{const s=`Loading monomers from '${t}' error: ${e instanceof Error?e.message:e.toString()}`;return new C({},s)})))));this._monomerLib.updateLibs(i,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,r=[];const a=new o.FileSource(t);if(e.endsWith(".sdf"))1===o.Func.find({package:"Chem",name:"importSdf"}).length?(s=await a.readAsBytes(e),i=await n.functions.call("Chem:importSdf",{bytes:s}),r=(0,p.Xk)(i[0])):n.shell.warning("Chem package is not installed");else if(e.endsWith(".json")){const t=await a.readAsText(e);r=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)),{})))),s=new h(t);if(!s.isValid())throw new Error("Invalid format of CSV monomer lib");r=s.getJsonMonomerLib()}}var l;const c={},u=[];return r.forEach((t=>{u.includes(t.polymerType)||(c[t.polymerType]={},u.push(t.polymerType)),c[t.polymerType][t.symbol]=t})),new C(c)}async selectSpecifiedLibraries(t){const e=await this.getInvalidFileNames(t);if(e.length>0)throw new Error(`Cannot select libraries ${e}: no such library in the list`);const s=await(0,a.nW)();s.exclude=(await f()).filter((e=>!t.includes(e))),await(0,a.tW)(s)}async getInvalidFileNames(t){const e=await f();return t.filter((t=>!e.includes(t)))}static get instance(){return window.$monomerLibHelper||(window.$monomerLibHelper=new T),window.$monomerLibHelper}}},525:(t,e,s)=>{"use strict";s.d(e,{K:()=>I});var n=s(4469),i=s(976),o=s(3870),r=s(8447),a=s(499),l=s(6098),c=s(8341),h=s(2568),u=s(3553),m=s(2991),d=s(3379),p=s.n(d),g=s(7795),f=s.n(g),y=s(569),w=s.n(y),C=s(3565),T=s.n(C),b=s(9216),A=s.n(b),S=s(4589),E=s.n(S),M=s(9564),v={};v.styleTagTransform=E(),v.setAttributes=T(),v.insert=w().bind(null,"head"),v.domAPI=f(),v.insertStyleElement=A(),p()(M.Z,v),M.Z&&M.Z.locals&&M.Z.locals;class N 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 h=t.col?.dataFrame??n.shell.t,m=t.col??h.columns.bySemType(i.SEMTYPE.MACROMOLECULE);if(null==m){const t="MSAError: dataset doesn't conain any Macromolecule column";n.shell.warning(t),s(new N(t))}const d=o.choiceInput("Method",t.pepsea.method,c.J);d.setTooltip("Alignment method");const p=o.floatInput("Terminal gap",t?.kalign?.terminalGap??null);p.setTooltip("Penalty for opening a gap at the beginning or end of the sequence");const g=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 w=o.inputs([f,y,p]),C=o.button("Alignment parameters",(()=>{w.hidden=!w.hidden}),"Adjust alignment parameters such as penalties for opening and extending gaps");C.classList.add("msa-params-button"),w.hidden=!0,C.prepend(o.icons.settings((()=>null)));const T=[d.root.style],b=[p.root.style,g.style];let A;const S=o.columnInput("Sequence",h,m,(async()=>{A=await P(S.value,h,T,b,d,E,f,y,p)}),{filter:t=>t.semType===i.SEMTYPE.MACROMOLECULE});S.setTooltip("Sequences column to use for alignment");const E=o.columnInput("Clusters",h,t.clustersCol);if(E.nullable=!0,S.fireChanged(),t.col)return A=await P(t.col,h,T,b,d,E,f,y,p),void await L(S,h,A,e,s);o.dialog("MSA").add(S).add(E).add(d).add(w).add(C).add(g).onOK((async()=>{await L(S,h,A,e,s)})).show()}))}async function L(t,e,s,o,r){let a=null;const l=i.TaskBarProgressIndicator.create("Analyze for MSA ...");try{if(t.fireChanged(),t.value.semType!==i.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 n.data.detectSemanticTypes(e),o(a)}catch(t){const e=t instanceof Error?t.message:t.toString();n.shell.error(e),r(t)}finally{l.close()}}async function P(t,e,s,o,d,p,g,f,y){try{if(t.semType!==i.SEMTYPE.MACROMOLECULE)return;const n=e.columns.getUnusedName(`msa(${t.name})`);if((0,h.n)(t,t.name,[r.r2.FASTA,r.r2.SEPARATOR],["DNA","RNA","PT"],!1)){_(s,o,"kalign"),g.value=null,f.value=null,y.value=null;const e=a.Cn.getOrCreate(t),i=e.isFasta()?t:e.convert(r.r2.FASTA);return async()=>await(0,l.U)(i,!1,n,p.value)}if((0,h.n)(t,t.name,[r.r2.HELM],[],!1))return _(s,o,"pepsea"),g.value??(g.value=u.jB.pepsea.gapOpen),f.value??(f.value=u.jB.pepsea.gapExtend),async()=>await(0,c.f)(t,n,d.value,g.value,f.value,p.value);if((0,h.n)(t,t.name,[r.r2.SEPARATOR],["UN"],!1)){const e=a.Cn.getOrCreate(t).convert(r.r2.HELM);return _(s,o,"pepsea"),g.value??(g.value=u.jB.pepsea.gapOpen),f.value??(f.value=u.jB.pepsea.gapExtend),async()=>await(0,c.f)(e,n,d.value,g.value,f.value,p.value)}return g.value=null,f.value=null,y.value=null,void _(s,o,"kalign")}catch(t){const e=t instanceof Error?t.message:t.toString();n.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:()=>O});var n=s(976),i=s(5226);const o=Symbol("Comlink.proxy"),r=Symbol("Comlink.endpoint"),a=Symbol("Comlink.releaseProxy"),l=Symbol("Comlink.thrown"),c=t=>"object"==typeof t&&null!==t||"function"==typeof t,h=new Map([["proxy",{canHandle:t=>c(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=>c(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(n){if(!n||!n.data)return;const{id:i,type:r,path:a}=Object.assign({path:[]},n.data),c=(n.data.argumentList||[]).map(T);let h;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":h=s;break;case"SET":e[a.slice(-1)[0]]=T(n.data.value),h=!0;break;case"APPLY":h=s.apply(e,c);break;case"CONSTRUCT":h=function(t){return Object.assign(t,{[o]:!0})}(new s(...c));break;case"ENDPOINT":{const{port1:e,port2:s}=new MessageChannel;u(t,s),h=function(t,e){return w.set(t,e),t}(e,[e])}break;case"RELEASE":h=void 0;break;default:return}}catch(t){h={value:t,[l]:0}}Promise.resolve(h).catch((t=>({value:t,[l]:0}))).then((t=>{const[n,o]=C(t);e.postMessage(Object.assign(Object.assign({},n),{id:i}),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 g(t,[],e)}function p(t){if(t)throw new Error("Proxy has been released and is not useable")}function g(t,e=[],s=function(){}){let n=!1;const i=new Proxy(s,{get(s,o){if(p(n),o===a)return()=>b(t,{type:"RELEASE",path:e.map((t=>t.toString()))}).then((()=>{m(t),n=!0}));if("then"===o){if(0===e.length)return{then:()=>i};const s=b(t,{type:"GET",path:e.map((t=>t.toString()))}).then(T);return s.then.bind(s)}return g(t,[...e,o])},set(s,i,o){p(n);const[r,a]=C(o);return b(t,{type:"SET",path:[...e,i].map((t=>t.toString())),value:r},a).then(T)},apply(s,i,o){p(n);const a=e[e.length-1];if(a===r)return b(t,{type:"ENDPOINT"}).then(T);if("bind"===a)return g(t,e.slice(0,-1));const[l,c]=y(o);return b(t,{type:"APPLY",path:e.map((t=>t.toString())),argumentList:l},c).then(T)},construct(s,i){p(n);const[o,r]=y(i);return b(t,{type:"CONSTRUCT",path:e.map((t=>t.toString())),argumentList:o},r).then(T)}});return i}function f(t){return Array.prototype.concat.apply([],t)}function y(t){const e=t.map(C);return[e.map((t=>t[0])),f(e.map((t=>t[1])))]}const w=new WeakMap;function C(t){for(const[e,s]of h)if(s.canHandle(t)){const[n,i]=s.serialize(t);return[{type:"HANDLER",name:e,value:n},i]}return[{type:"RAW",value:t},w.get(t)||[]]}function T(t){switch(t.type){case"HANDLER":return h.get(t.name).deserialize(t.value);case"RAW":return t.value}}function b(t,e,s){return new Promise((n=>{const i=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!==i||(t.removeEventListener("message",e),n(s.data))})),t.start&&t.start(),t.postMessage(Object.assign({id:i},e),s)}))}const A="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2NvbnN0ICQ9U3ltYm9sKCJDb21saW5rLnByb3h5IiksQT1TeW1ib2woIkNvbWxpbmsuZW5kcG9pbnQiKSxSPVN5bWJvbCgiQ29tbGluay5yZWxlYXNlUHJveHkiKSx5PVN5bWJvbCgiQ29tbGluay50aHJvd24iKSxfPWU9PnR5cGVvZiBlPT0ib2JqZWN0IiYmZSE9PW51bGx8fHR5cGVvZiBlPT0iZnVuY3Rpb24iLEw9e2NhbkhhbmRsZTplPT5fKGUpJiZlWyRdLHNlcmlhbGl6ZShlKXtjb25zdHtwb3J0MTpyLHBvcnQyOml9PW5ldyBNZXNzYWdlQ2hhbm5lbDtyZXR1cm4gdyhlLHIpLFtpLFtpXV19LGRlc2VyaWFsaXplKGUpe3JldHVybiBlLnN0YXJ0KCksQyhlKX19LE89e2NhbkhhbmRsZTplPT5fKGUpJiZ5IGluIGUsc2VyaWFsaXplKHt2YWx1ZTplfSl7bGV0IHI7cmV0dXJuIGUgaW5zdGFuY2VvZiBFcnJvcj9yPXtpc0Vycm9yOiEwLHZhbHVlOnttZXNzYWdlOmUubWVzc2FnZSxuYW1lOmUubmFtZSxzdGFjazplLnN0YWNrfX06cj17aXNFcnJvcjohMSx2YWx1ZTplfSxbcixbXV19LGRlc2VyaWFsaXplKGUpe3Rocm93IGUuaXNFcnJvcj9PYmplY3QuYXNzaWduKG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ta2RpcihvKSxlLm1vdW50KHQuYmFzZS5tb2R1bGUuUFJPWFlGUyx7cm9vdDpzLGZzOml9LG8pKX19LF9maWxlb3AoZSxyKXt0Ll9sb2coYFJ1bm5pbmcgJHtlfSAke3J9YCk7Y29uc3QgaT10LmZzLmFuYWx5emVQYXRoKHIpO2lmKCFpLmV4aXN0cylyZXR1cm4gdC5fbG9nKGBGaWxlICR7cn0gbm90IGZvdW5kLmApLCExO3N3aXRjaChlKXtjYXNlImNhdCI6cmV0dXJuIHQuZnMucmVhZEZpbGUocix7ZW5jb2Rpbmc6InV0ZjgifSk7Y2FzZSJscyI6cmV0dXJuIHQuZnMuaXNGaWxlKGkub2JqZWN0Lm1vZGUpP3QuZnMuc3RhdChyKTp0LmZzLnJlYWRkaXIocik7Y2FzZSJkb3dubG9hZCI6Y29uc3Qgcz1uZXcgQmxvYihbdGhpcy5jYXQocildKTtyZXR1cm4gVVJMLmNyZWF0ZU9iamVjdFVSTChzKX1yZXR1cm4hMX0sX2xvZyhlKXtpZighdC5jb25maWcuZGVidWcpcmV0dXJuO2xldCByPVsuLi5hcmd1bWVudHNdO3Iuc2hpZnQoKSxjb25zb2xlLmxvZyhgJWNbV2ViV29ya2VyXSVjICR7ZX1gLCJmb250LXdlaWdodDpib2xkIiwiIiwuLi5yKX19O3codCl9KSgpOwo=",S=typeof window<"u"&&window.Blob&&new Blob([atob(A)],{type:"text/javascript;charset=utf-8"});function E(){const t=S&&(window.URL||window.webkitURL).createObjectURL(S);try{return t?new Worker(t):new Worker("data:application/javascript;base64,"+A)}finally{t&&(window.URL||window.webkitURL).revokeObjectURL(t)}}const M={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 v{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({},M,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 E;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 N=s(850);class I{static getAvailableScales(){return Object.entries(this.scales).map((([t,e])=>t))}static getScale(t){return(0,N.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 L{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 n=["NH2","COOH"];if(t.startsWith(n[0])){const s=n[0].length;(0,N.hu)("-"==t[s],`Wrong sequence format: ${n[0]} without following '-' in '${t}'.`),e=s}if(t.endsWith(n[1])){const e=n[1].length+1;(0,N.hu)("-"==t[s-e],`Wrong sequence format: ${n[1]} without '-' precending in '${t}'.`),s-=e}return t.substring(e,s)}static _dropDefises(t){return t.replace(/(-)([^-]+)/g,"$2")}static clean(t){return L._dropDefises(L._truncateSequence(t))}encode(t){const e=t.length,s=new Array(e).fill(0);for(let n=0;n<e;++n){const e=t[n];(0,N.hu)(e in this.aa2num,`Unknown char '${e}' found in sequence '${t}'`),s[n]=this.encodeLettter(e)}return s}encodeLettter(t){return this.aa2num[t]}decode(t){let e="";for(let s=0;s<t.length;++s){const n=t[s];(0,N.hu)(n in this.num2aa,`Unknown code '${n}' found in vector '${t}'`),e+=this.num2aa[n]}return e}}var P=s(3553);const _="input.fa",R="result.fasta";function x(t){return t.reduce(((t,e,s)=>t+`>sample${s+1}\n${e}\n`),"")}async function O(t,e=!1,s="",o=null,r,a,l){let c=t.toList();e&&(c=c.map((t=>L.clean(t).replace(/\-/g,""))));const h=t.length;o??(o=n.Column.string("Clusters",h).init("0")),o.type!=n.COLUMN_TYPE.STRING&&(o=o.convertTo(n.TYPE.STRING)),o.compact();const u=o.categories,m=o.getRawData(),d=new Array(u.length),p=new Array(u.length);for(let t=0;t<h;++t){const e=m[t];(d[e]??(d[e]=[])).push(c[t]),(p[e]??(p[e]=[])).push(t)}const g=await new v(["base/1.0.0",{tool:"kalign",version:P.WY,reinit:!0}]),f=n.Column.string(s,h);for(let t=0;t<u.length;++t){const e=x(d[t]);await g.fs.writeFile(_,e);const s=`${void 0!==r?` --gpo ${r}`:""}${void 0!==a?` --gpe ${a}`:""}${void 0!==l?` --tgpe ${l}`:""}`,n=await g.exec(`kalign ${_} -f fasta -o ${R}${s}`);console.warn(n);const o=await g.cat(R);if(!o)throw new Error("kalign output no result");const c=new i.i(o).sequencesArray,h=p[t];for(let t=0;t<c.length;++t)f.set(h[t],c[t])}const y=t.getTag(n.TAGS.UNITS),w=t.getTag("alphabet");return f.setTag(n.TAGS.UNITS,y),f.setTag("aligned","SEQ.MSA"),f.setTag("alphabet",w),f.semType=n.SEMTYPE.MACROMOLECULE,f}},8341:(t,e,s)=>{"use strict";s.d(e,{J:()=>a,f:()=>c});var n=s(4469),i=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 c(t,e,s="ginsi",a=1.53,c=0,u=null){const m=await n.dapi.docker.dockerContainers.filter("bio").first();if("started"!==m.status&&"checking"!==m.status)return n.log.warning("PepSeA container has not started yet"),null;const d=t.length;u??(u=i.Column.int("Clusters",d).init(0)),u.type!=i.COLUMN_TYPE.STRING&&(u=u.convertTo(i.TYPE.STRING));const p=u.categories,g=new Array(p.length);for(let e=0;e<d;++e){const s=u.get(e);if(""===s)continue;const n=p.indexOf(s),i=t.get(e);i&&(g[n]??(g[n]=[])).push({ID:e.toString(),HELM:i})}const f=new Array(d);for(const t of g){const e=(await h(m.id,t,s,a,c)).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=i.Column.fromStrings(e,f);return y.setTag(i.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=i.SEMTYPE.MACROMOLECULE,y}async function h(t,e,s,i,o){const r={method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(e)},a=`/align?method=${s}&gap_open=${i}&gap_extend=${o}`,l=await n.dapi.docker.dockerContainers.request(t,a,r);return JSON.parse(l??"{}")}},9953:(t,e,s)=>{"use strict";s.d(e,{M:()=>n});const n="<All>"},9943:(t,e,s)=>{"use strict";s.d(e,{C2:()=>u,i$:()=>m,sK:()=>d});var n=s(976),i=s(3870),o=s(4469),r=s(6414),a=s.n(r),l=s(8447),c=s(499);const h=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!==n.SEMTYPE.MACROMOLECULE)).toArray(),s=e.find((t=>-1!==t.name.toLowerCase().indexOf("id"))),r=s?[s.name]:[],l=i.multiChoiceInput("Seq id columns",r,e.map((t=>t.name))),u=a().count(0).take(t.columns.length).map((e=>t.columns.byIndex(e))).filter((t=>{const e=t.column;return!(!e||e.semType!==n.SEMTYPE.MACROMOLECULE)&&c.Cn.getOrCreate(e).isFasta()})).toArray(),d=u.length>0?u[0].name:[],p=i.choiceInput("Seq column",d,u.map((t=>t.name))),g=i.intInput("FASTA line width",h);i.dialog({title:"Save as FASTA"}).add(i.inputs([l,p,g])).onOK((()=>{const e=l.value?l.value.map((e=>t.columns.byName(e).column)):[],s=p.value?t.columns.byName(p.value).column:null,n=g.value??h;s||o.shell.warning("Seq column is mandatory to save as FASTA.");const i=m(e,s,n),r=document.createElement("a");r.setAttribute("href",`data:text/plain;charset=utf-8,${encodeURIComponent(i)}`),r.setAttribute("download",`${t.dataFrame.name}.fasta`),r.click()})).show()}function m(t,e,s=h,n="\n"){const i=l.kB,o=[];for(let r=0;r<e.length;r++){const a=t.map((t=>t.get(r).toString())).join("|"),l=d(e.get(r),i,s);o.push(`>${a}${n}`);for(const t of l)o.push(`${t}${n}`)}return"".concat(...o)}function d(t,e,s=h){const n=e(t);let i=0;const o=n.length,r=[];for(;i<o;){const t=a()(n).slice(i,i+s).toArray(),e=t.map((t=>t.length>1?`[${t}]`:t)).join("");r.push(e),i+=t.length}return r}},9416:(t,e,s)=>{"use strict";s.d(e,{n:()=>c});var n=s(4469),i=s(976),o=s(1061),r=s(2568),a=s(8457),l=s(3553);async function c(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 c=e.dataFrame;for(const t of s.columns)t.semType=l.Of.MONOMER,t.setTag("alphabet",e.getTag("alphabet"));const h=/(\d+)(?: \((\d+)\))?/,u=t=>{h.lastIndex=0;const e=t.match(h);return e?`${e[1]} (${parseInt(e[2]??0)+1})`:t};for(let t=0;t<s.columns.length;t++){const n=s.columns.byIndex(t);n.semType=l.Of.MONOMER,n.setTag("alphabet",e.getTag("alphabet"));const i=100;let o=0;for(;c.columns.byName(n.name)&&o<i;)n.name=u(n.name),o++;c.columns.add(n)}await n.data.detectSemanticTypes(c);for(let t=0;t<s.columns.length;t++){const e=s.columns.byIndex(t);e.setTag(i.TAGS.CELL_RENDERER,"Monomer"),e.setTag(".use-as-filter","false")}return c}},4293:(t,e,s)=>{"use strict";s.d(e,{B:()=>o,Y:()=>r});var n=s(4469),i=s(976);function o(){const t=n.shell.t.columns.bySemTypeAll(i.SEMTYPE.MACROMOLECULE);if(null!==t)return t;n.shell.error("Current table does not contain macromolecules")}function r(t,e){t.innerHTML="",t.append(e)}},8415:(t,e,s)=>{"use strict";s.d(e,{bo:()=>p,CK:()=>C,yW:()=>w,OZ:()=>A,eZ:()=>S});var n=s(4469),i=s(3870),o=s(976),r=s(6414),a=s.n(r),l=s(701),c=s(499),h=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,p,g=s(7958),f=s(8770),y=s(2991);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 w{constructor(t=0,e){this.valueList=null,this.valueIdx=0,this.value=this.rowCount=t,this.bounds=e}push(t){this.valueList||(this.valueList=new Array(this.rowCount),this.valueIdx=0),this.valueList[this.valueIdx]=t,++this.valueIdx}aggregate(t){this.value=t(this.valueList)??0,this.valueList=null}}class C{get label(){return this._label?this._label:this.name}constructor(t,e,s,n){this.sumRowCount=0,this.pos=t,this.name=e,this._freqs=s??{},n?.sumRowCount&&(this.sumRowCount=n.sumRowCount),n?.sumValueForHeight&&(this.sumPlotValue=n.sumValueForHeight),n?.label&&(this._label=n.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 w),e}aggregate(t){const e=function(t){return e=>{const s=function(t){let e;const s="agg";return e=t instanceof Float32Array?o.Column.fromFloat32Array(s,t):t instanceof Int32Array?o.Column.fromInt32Array(s,t):o.Column.fromList(o.COLUMN_TYPE.FLOAT,s,t),e}(e);return s.aggregate(t)}}(t);for(const[t,s]of Object.entries(this._freqs))s.aggregate(e)}getMinValue(){return Math.min(...Object.values(this._freqs).map((t=>t.value)))}calcPlotValue(t){for(const e of Object.values(this._freqs))e.plotValue=e.value-t}calcHeights(t){this.sumPlotValue=0;for(const t of Object.values(this._freqs))this.sumPlotValue+=t.plotValue;if(this.sumPlotValueForHeight=0,t===u.ES.Entropy){const t=Object.keys(this._freqs).length,e=.01*this.sumPlotValue,s=e/t;for(const t of Object.values(this._freqs)){const n=(t.plotValue+s)/(this.sumPlotValue+e);this.sumPlotValueForHeight+=-n*Math.log2(n)}}else if(t===u.ES.full)for(const[t,e]of Object.entries(this._freqs)){const t=e.plotValue/this.sumPlotValue;this.sumPlotValueForHeight+=t}}calcScreen(t,e,s,n,i,r,a,l,c,h){const m=i===u.ES.Entropy?n*(r-this.sumPlotValueForHeight)/r:n;let d=h*c+(n-m-1);const p=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].value-e[1].value));for(const[t,n]of p){const t=m*n.plotValue/this.sumPlotValue;n.bounds=new o.Rect((e-s)*c*a,d,l*c,t),d+=t}}render(t,e,s,n,i,o){for(const[r,a]of Object.entries(this._freqs))if(!e(r)){const e=(0,h.GU)(r,5),l=a.bounds,c=l.left;t.resetTransform(),t.strokeStyle="lightgray",t.lineWidth=1,t.rect(c,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/i,c,l.top),t.fillText(e,0,-n)}}getMonomerAt(t,e){const s=Object.entries(this._freqs).find((([s,n])=>n.bounds.contains(t,e)));return s?s[0]:void 0}buildCompositionTable(t){return(0,f._)(t,Object.assign({},...Object.entries(this._freqs).map((([t,e])=>({[t]:e.rowCount})))))}}!function(t){t.STYLE="Style",t.BEHAVIOR="Behavior",t.LAYOUT="Layout",t.DATA="Data"}(d||(d={})),function(t){t.sequenceColumnName="sequenceColumnName",t.valueAggrType="valueAggrType",t.valueColumnName="valueColumnName",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"}(p||(p={}));const T=u.vS;var b;!function(t){t[t.None=0]="None",t[t.Render=1]="Render",t[t.Layout=1]="Layout",t[t.Freqs=2]="Freqs"}(b||(b={}));class A 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.palette=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.setDataInProgress=!1,this.viewSubs=[],this._onSizeChanged=new l.Subject,this._onFreqsCalculated=new l.Subject,this._onLayoutCalculated=new l.Subject,this.requestedRenderLevel=b.Freqs,this.renderRequest=new l.Subject,this.viewerId=A.viewerCount,A.viewerCount+=1,this.textBaseline="top",this.unitsHandler=null,this.sequenceColumnName=this.string(p.sequenceColumnName,T.sequenceColumnName,{category:d.DATA});const t=[o.AGG.KEY,o.AGG.PIVOT,o.AGG.MISSING_VALUE_COUNT,o.AGG.SKEW,o.AGG.KURT,o.AGG.SELECTED_ROWS_COUNT],e=Object.values(o.AGG).filter((e=>!t.includes(e)));this.valueAggrType=this.string(p.valueAggrType,T.valueAggrType,{category:d.DATA,choices:e}),this.valueColumnName=this.string(p.valueColumnName,T.valueColumnName,{category:d.DATA}),this.startPositionName=this.string(p.startPositionName,T.startPositionName,{category:d.DATA}),this.endPositionName=this.string(p.endPositionName,T.endPositionName,{category:d.DATA}),this.skipEmptySequences=this.bool(p.skipEmptySequences,T.skipEmptySequences,{category:d.DATA}),this.skipEmptyPositions=this.bool(p.skipEmptyPositions,T.skipEmptyPositions,{category:d.DATA}),this.shrinkEmptyTail=this.bool(p.shrinkEmptyTail,T.shrinkEmptyTail,{category:d.DATA}),this.backgroundColor=this.int(p.backgroundColor,T.backgroundColor,{category:d.STYLE}),this.positionHeight=this.string(p.positionHeight,T.positionHeight,{category:d.STYLE,choices:Object.values(u.ES)}),this._positionWidth=this.positionWidth=this.float(p.positionWidth,T.positionWidth,{category:d.STYLE}),this.verticalAlignment=this.string(p.verticalAlignment,T.verticalAlignment,{category:d.LAYOUT,choices:Object.values(u.vw)}),this.horizontalAlignment=this.string(p.horizontalAlignment,T.horizontalAlignment,{category:d.LAYOUT,choices:Object.values(u.iD)}),this.fixWidth=this.bool(p.fixWidth,T.fixWidth,{category:d.LAYOUT,userEditable:!1}),this.fitArea=this.bool(p.fitArea,T.fitArea,{category:d.LAYOUT}),this.minHeight=this.float(p.minHeight,T.minHeight,{category:d.LAYOUT}),this.maxHeight=this.float(p.maxHeight,T.maxHeight,{category:d.LAYOUT}),this.showPositionLabels=this.bool(p.showPositionLabels,T.showPositionLabels,{category:d.LAYOUT}),this.positionMarginState=this.string(p.positionMarginState,T.positionMarginState,{category:d.LAYOUT,choices:Object.values(u.dE)});let s=0;"auto"===this.positionMarginState&&(s=4),this.positionMargin=this.int(p.positionMargin,s,{category:d.LAYOUT,min:0,max:16}),this.filterSource=this.string(p.filterSource,T.filterSource,{category:d.BEHAVIOR,choices:Object.values(u.Ct)}),this.slider=i.rangeSlider(0,100,0,20,!1,{style:"barbell"}),this.canvas=i.canvas(),this.canvas.classList.value="bio-wl-canvas",this.canvas.style.width="100%"}setData(){y._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),this.updateSeqCol(),this.updateEditors(),this.viewed||(await this.buildView(),this.viewed=!0)}catch(t){const[e,s]=(0,g.yf)(t);n.shell.error(e),y._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";y._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.destroyView( dataFrame = ${t} ) start`),this.host.remove(),this.msgHost=void 0,this.host=void 0,y._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.destroyView() end`)}async buildView(){const t=this.dataFrame?"data":"null";y._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=i.div("No message",{classes:"bio-wl-msg"}),this.msgHost.style.display="none",this.canvas=i.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=i.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,i.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(i.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(b.Freqs,"buildView"),y._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.buildView() end`)}rootOnSizeChanged(){y._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.rootOnSizeChanged(), start `),this.render(b.Layout,"rootOnSizeChanged")}updateEditors(){this.props.getProperty(p.valueColumnName).choices=a()(this.dataFrame.columns.numerical).map((t=>t.name)).toArray()}updateSeqCol(){if(this.dataFrame&&(this.seqCol=this.sequenceColumnName?this.dataFrame.col(this.sequenceColumnName):null,null==this.seqCol&&(this.seqCol=(0,h.up)(this.dataFrame),this.sequenceColumnName=this.seqCol?this.seqCol.name:null),this.seqCol)){try{this.unitsHandler=c.Cn.getOrCreate(this.seqCol),this.palette=(0,h.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.palette=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"),n=this.seqCol.getTag(".positionLabels");this.positionNames=s?s.split(h.CI).map((t=>t.trim())):[...Array(e).keys()].map((t=>`${t+1}`)),this.positionLabels=n?n.split(h.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(b.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),n=Math.min(this.root.clientWidth,e);this.canvas.style.width=`${n}px`,this.canvas.style.height=`${s}px`,this.host.style.width=`${n}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=`${n+6}px`),this.host.style.width=`${this.host}px`;const i=e>n;if(this.setSliderVisibility(i),i){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=n*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),n=e>0?(this.root.clientWidth-this.positionMarginValue*this.Length)/e:0,i=this.root.clientHeight/s,o=Math.max(1,Math.min(n,i));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 c=r>l;if(this.setSliderVisibility(c),c){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 p.sequenceColumnName:this.updateSeqCol();break;case p.sequenceColumnName:case p.startPositionName:case p.endPositionName:case p.filterSource:case p.shrinkEmptyTail:case p.skipEmptyPositions:case p.positionHeight:this.updatePositions();break;case p.valueColumnName:case p.valueAggrType:this.render(b.Freqs,`onPropertyChanged(${t.name})`);break;case p.minHeight:case p.maxHeight:case p.positionWidth:case p.showPositionLabels:case p.fixWidth:case p.fitArea:case p.horizontalAlignment:case p.verticalAlignment:case p.positionMargin:case p.positionMarginState:this.render(b.Layout,`onPropertyChanged(${t.name})`);break;case p.backgroundColor:this.render(b.Render,`onPropertyChanged(${t.name})`)}}onTableAttached(){y._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.onTableAttached(), `),super.onTableAttached(),this.setData()}async detach(){y._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.detach(), `);const t=super.detach.bind(this);this.viewPromise=this.viewPromise.then((async()=>{this.setDataInProgress||(this.viewed&&(await this.destroyView(),this.viewed=!1),t())})).catch((t=>{const[e,s]=(0,g.yf)(t);y._package.logger.error(e,void 0,s)}))}get onSizeChanged(){return this._onSizeChanged}get onFreqsCalculated(){return this._onFreqsCalculated}get onLayoutCalculated(){return this._onLayoutCalculated}getMonomer(t,e){const s=t.x,n=Math.floor(t.x/(this._positionWidthWithMargin*e)+Math.floor(this.slider.min)),i=this.positions[n];if(!i)return[null,null,null];const o=i.getMonomerAt(s,t.y);return void 0===o?[i,null,null]:[i,o,i.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).rowCount!==t.sumRowCount})).toArray())}render(t,e){y._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(y._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.render.renderInt( renderLevel=${t} ), start `),this.msgHost&&(this.seqCol&&!this.palette?(this.msgHost.innerText=`Unknown palette (column semType: '${this.seqCol.semType}').`,this.msgHost.style.display=""):this.msgHost.style.display="none"),!this.seqCol||!this.dataFrame||!this.palette||null==this.host||null==this.slider)return;const e=window.devicePixelRatio,s=this.showPositionLabels?12:0;if(t>=b.Freqs&&(()=>{if(y._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=c.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 C(this.startPosition+e,t,{},{label:s})}const s=this.getFilter(),n=this.dataFrame.rowCount,i=this.unitsHandler.splitted;for(let e=0;e<t;++e){for(let t=0;t<n;++t)if(s.get(t)){const s=i[t][this.startPosition+e]||this.unitsHandler.defaultGapSymbol,n=this.positions[e],o=n.getFreq(s);++n.sumRowCount,o.value=++o.rowCount}if(this.valueAggrType===o.AGG.TOTAL_COUNT)continue;let t=null;try{t=this.dataFrame.getCol(this.valueColumnName),t.matches("numerical")||(t=null)}catch{t=null}if(t){for(let o=0;o<n;++o)if(s.get(o)){const s=i[o][this.startPosition+e]||this.unitsHandler.defaultGapSymbol,n=t.get(o);this.positions[e].getFreq(s).push(n)}this.positions[e].aggregate(this.valueAggrType)}}const r=this.valueAggrType===o.AGG.TOTAL_COUNT?0:Math.min(0,Math.min(...this.positions.map((t=>t.getMinValue()))));for(let e=0;e<t;++e)this.positions[e].calcPlotValue(r),this.positions[e].calcHeights(this.positionHeight);this._removeEmptyPositions(),this._onFreqsCalculated.next()})(),this.calcLayout(e),-1===this.startPosition)return;const i=Math.max(Math.floor(this.slider.min),0),r=Math.min(this.positions.length-1,Math.floor(this.slider.max));t>=b.Layout&&((t,e,s,i)=>{y._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.render.calculateLayoutInt(), start `);const r=this.canvas.height-i*s;let l;if(this.valueAggrType===o.AGG.TOTAL_COUNT){const t=this.getAlphabetSize();this.positionHeight==u.ES.Entropy&&null==t&&n.shell.error("WebLogo: alphabet is undefined."),l=Math.log2(t)}else l=Math.max(...a().count(t).takeWhile((t=>t<=e)).map((t=>this.positions[t].sumPlotValueForHeight)));for(let n=t;n<=e;++n)n in this.positions?this.positions[n].calcScreen((t=>this.unitsHandler.isGap(t)),n,this.slider.min,r,this.positionHeight,l,this._positionWidthWithMargin,this._positionWidth,s,i):y._package.logger.warning(`Bio: WebLogoViewer<${this.viewerId}>.render.calculateLayoutInt() this.positions.length = ${this.positions.length}, jPos = ${n}`);y._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.render.calculateLayoutInt(), end `),this._onLayoutCalculated.next()})(i,r,window.devicePixelRatio,s);const l=this.canvas.getContext("2d");if(l){l.save();try{this.Length,l.resetTransform(),l.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),l.fillRect(0,0,this.canvas.width,this.canvas.height),l.textBaseline=this.textBaseline;const t=10*e;l.resetTransform(),l.fillStyle="black",l.textAlign="center",l.font=`${t.toFixed(1)}px Roboto, Roboto Local, sans-serif`,s>0&&this.positions.length>0&&function(t,e,s,n,i,o,r,a){t.save();try{t.textAlign="center";let l=null,c=null;for(let e=Math.floor(r);e<=Math.floor(a);e++){const s=o[e],n=t.measureText(s.name),i=n.actualBoundingBoxDescent-n.actualBoundingBoxAscent;l=null===l?n.width:Math.max(l,n.width),c=null===c?i:Math.max(c,i)}const h=l<n*e-2?1:(n*e-2)/l;for(let l=Math.floor(r);l<=Math.floor(a);l++){const a=o[l],u=(l-r)*s*e+n*e/2,m=(i*e-c)/2;t.setTransform(h,0,0,1,u,m),t.measureText(a.label),t.fillText(a.label,0,0)}}finally{t.restore()}}(l,e,this._positionWidthWithMargin,this._positionWidth,s,this.positions,this.slider.min,this.slider.max);const n="16px Roboto, Roboto Local, sans-serif",a=.25,c=12.2;for(let t=i;t<=r;t++)this.positions[t].render(l,(t=>this.unitsHandler.isGap(t)),n,a,c,this.palette)}finally{l.restore()}y._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.render.renderInt( recalcLevel=${t} ), end`)}}renderRequestOnDebounce(t){this.requestedRenderLevel=b.None,this.renderInt(t).catch((t=>{const[e,s]=(0,g.yf)(t);y._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};y._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.sliderOnValuesChanged( ${JSON.stringify(t)} ), start`),this.render(b.Layout,"sliderOnValuesChanged")}catch(t){const e=m(t);y._package.logger.error(`Bio: WebLogoViewer<${this.viewerId}>.sliderOnValuesChanged() error:\n`+e)}}dataFrameFilterOnChanged(t){y._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.dataFrameFilterChanged()`);try{this.updatePositions(),this.filterSource===u.Ct.Filtered&&this.render(b.Freqs,"dataFrameFilterOnChanged")}catch(t){const e=m(t);y._package.logger.error(`Bio: WebLogoViewer<${this.viewerId}>.dataFrameFilterOnChanged() error:\n`+e)}}dataFrameSelectionOnChanged(t){y._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.dataFrameSelectionOnChanged()`);try{this.filterSource===u.Ct.Selected&&this.render(b.Freqs,"dataFrameSelectionOnChanged")}catch(t){const e=m(t);y._package.logger.error(`Bio: WebLogoViewer<${this.viewerId}>.dataFrameSelectionOnChanged() error:\n`+e)}}canvasOnMouseMove(t){const e=window.devicePixelRatio;try{const s=t,n=this.canvas.getCursorPosition(s,e),[r,a]=this.getMonomer(n,e),l=this.showPositionLabels?12*e:0;if(null!==r&&null===a&&0<=n.y&&n.y<=l){const t=[i.divText(`Position ${r.label}`)];this.valueAggrType===o.AGG.TOTAL_COUNT&&t.push(r.buildCompositionTable(this.palette));const e=i.divV(t);i.tooltip.show(e,s.x+16,s.y+16)}else if(null!==r&&a&&this.dataFrame&&this.seqCol&&this.unitsHandler){const t=r.getFreq(a),e=[i.div(`${a}`),i.div(`${t.rowCount} rows`)];this.valueAggrType!==o.AGG.TOTAL_COUNT&&e.push(i.div(`${this.valueAggrType}: ${t.value.toFixed(3)}`));const n=i.divV(e);i.tooltip.show(n,s.x+16,s.y+16)}else i.tooltip.hide()}catch(t){const e=m(t);y._package.logger.error(`Bio: WebLogoViewer<${this.viewerId}>.canvasOnMouseMove() error:\n`+e)}}canvasOnMouseDown(t){try{const e=t,s=window.devicePixelRatio,[n,i]=this.getMonomer(this.canvas.getCursorPosition(e,s),s);if(null!==n&&null!==i&&this.dataFrame&&this.seqCol&&this.unitsHandler){const t=o.BitSet.create(this.dataFrame.selection.length,(t=>function(t,e,s,n,i,o){const r=e.splitted[n],a=o.pos<r.length?r[o.pos]:null;return a===i||""===a&&i===e.defaultGapSymbol}(this.dataFrame,this.unitsHandler,this.getFilter(),t,i,n)));this.dataFrame.selection.init((e=>t.get(e)))}}catch(t){const e=m(t);y._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),n=t.deltaY/100*Math.max(Math.floor(s/5),1);this.slider.scrollBy(this.slider.min+n)}catch(t){const e=m(t);y._package.logger.error(`Bio: WebLogoViewer<${this.viewerId}>.canvasOnWheel() error:\n`+e)}}}function S(t,e,s,n,i){let o=0,r=-1;for(;-1!=(r=s.findNext(r,!0));){const t=e.splitted[r],s=i.pos;(s<t.length?t[s]:null)===n&&o++}return o}A.residuesSet="nucleotides",A.viewerCount=0},4413:(t,e,s)=>{"use strict";s.d(e,{ST:()=>g});var n=s(3870),i=s(976),o=s(4469),r=s(6414),a=s.n(r),l=s(7983),c=s(701),h=s(4293),u=s(8447),m=s(1061);const d=rxjs.operators;var p=s(3377);class g extends i.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=n.loader(),this.notation=void 0,this.root=n.divV([]),this.calculating=!1}attach(t){super.attach(t),this.column=t.columns.bySemType(i.SEMTYPE.MACROMOLECULE),this.columnName??(this.columnName=this.column?.name),this.notation??(this.notation=this.column?.getTag(i.TAGS.UNITS)),this.bioFilter=this.notation===u.r2.FASTA?new y:this.notation===u.r2.SEPARATOR?new w(this.column.getTag("separator")):new C,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(p._package.logger.debug("Bio: BioSubstructureFilter._onInputChanged(), start"),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 f{constructor(){this.onChanged=new c.Subject}get filterPanel(){return new HTMLElement}get substructure(){return""}set substructure(t){}async substructureSearch(t){return null}}class y extends f{constructor(){super(),this.substructureInput=n.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 w extends y{constructor(t){super(),this.colSeparator="",this.separatorInput=n.stringInput("","",(()=>{this.onChanged.next()}),{placeholder:"Separator"}),this.colSeparator=t,this.separatorInput.value=t}get filterPanel(){return n.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 C extends f{constructor(){super(),this._filterPanel=n.div("",{style:{cursor:"pointer"}}),this.helmSubstructure="",this.init()}async init(){this.helmEditor=await o.functions.call("HELM:helmWebEditor"),await n.tools.waitForElementInDom(this._filterPanel),this.updateFilterPanel(),this._filterPanel.addEventListener("click",(t=>{const{editorDiv:e,webEditor:s}=this.helmEditor.createWebEditor(this.helmSubstructure);n.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})})),n.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,h.Y)(this._filterPanel,this.helmEditor.host),this.helmEditor.editor.setHelm(t),this.helmEditor.resizeEditor(e,s);else{const t=n.divText("Click to edit","helm-substructure-filter");(0,h.Y)(this._filterPanel,t)}}async substructureSearch(t){n.setUpdateIndicator(this._filterPanel,!0),await(0,m.gw)(10);const e=await(0,l.QF)(this.substructure,t);return n.setUpdateIndicator(this._filterPanel,!1),e}resetFilter(){console.debug("Bio: HelmFilter.resetFilter()"),this.helmSubstructure="",this.updateFilterPanel(this.substructure)}}},8770:(t,e,s)=>{"use strict";s.d(e,{_:()=>M,t:()=>E});var n=s(3870),i=s(976),o=s(6414),r=s.n(o),a=s(8447),l=s(7331),c=s(3379),h=s.n(c),u=s(7795),m=s.n(u),d=s(569),p=s.n(d),g=s(3565),f=s.n(g),y=s(9216),w=s.n(y),C=s(4589),T=s.n(C),b=s(5362),A={};A.styleTagTransform=T(),A.setAttributes=f(),A.insert=p().bind(null,"head"),A.domAPI=m(),A.insertStyleElement=w(),h()(b.Z,A),b.Z&&b.Z.locals&&b.Z.locals;var S=s(499);function E(t){const e=n.div();e.classList.add("macromolecule-cell-comp-analysis-host");const s=t.cell.column.tags.alphabet;let o=l.UE.Color;switch(s){case"DNA":case"RNA":o=(0,a.py)("DNA");break;case"PT":o=(0,a.py)("PT")}const c={},h=S.Cn.getOrCreate(t.cell.column).getSplitter()(t.value);r()(h).filter((t=>!!t&&""!==t)).forEach((t=>{const e=c[t]||0;c[t]=e+1}));const u=M(o,c);return Array.from(u.rows).forEach((t=>{const e=t.getElementsByClassName("macromolecule-cell-comp-analysis-bar")[0].style.backgroundColor;t.cells[0].style.color=e})),e.appendChild(u),new i.Widget(e)}function M(t,e){let s=0,i=null;for(const t of Object.values(e))s+=t,i=null===i?t:Math.max(i,t);const o=i/s,r=Object.assign({},...Array.from(Object.entries(e)).sort(((t,e)=>e[1]-t[1])).map((([e,i])=>{const r=i/s,a=t.get(e),l=n.div("",{classes:"macromolecule-cell-comp-analysis-bar"});l.style.width=50*r/o+"px",l.style.backgroundColor=a;const c=n.div(`${(100*r).toFixed(2)}%`);return{[e]:n.div([l,c],{classes:"macromolecule-cell-comp-analysis-value"})}}))),a=n.tableFromMap(r);return Array.from(a.rows).forEach((t=>{const e=t.getElementsByClassName("macromolecule-cell-comp-analysis-bar")[0].style.backgroundColor;t.cells[0].style.color=e})),a}},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(n){var i=e[n];if(void 0!==i)return i.exports;var o=e[n]={id:n,exports:{}};return t[n].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 n in e)s.o(e,n)&&!s.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},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 n=e.getElementsByTagName("script");if(n.length)for(var i=n.length-1;i>-1&&!t;)t=n[i--].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 n=s(2991);bio=n})();
2
+ var bio;(()=>{var t={2012:(t,e,s)=>{"use strict";s.d(e,{f:()=>i});var n=s(9976);class i extends n.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,i)),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,i)),this.grokGroups}static get RasMol(){return void 0===this.rasMol&&(this.rasMol=new i({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 i.aaSynonyms?i.aaSynonyms[t]:t;return super.get(e)}}i.aaSynonyms={MeNle:"L",MeA:"A",MeG:"G",MeF:"F"};class o{static getPalette(t="grok"){switch(t){case"grok":return i.GrokGroups;case"lesk":return i.Lesk;default:throw new Error(`ChemPalette: scheme \`${t}\` does not exist`)}}static getInnerOuter(t){let e=0,s="",n="";for(const i of t)"("==i?e++:")"==i?e--:e?s+=i:n+=i;return isNaN(parseInt(s))?[n,s]:[n,""]}static getColorAAPivot(t="",e="grok"){const s=this.getPalette(e);let[n,i]=this.getInnerOuter(t);if(n=n.length>6?`${n.slice(0,3)}...`:n,i=i.length>6?`${i.slice(0,3)}...`:i,1==t.length||"("==t[1]){const e=t[0]?.toUpperCase();return e in s?[s.get(e),e,i,1]:[this.undefinedColor,n,i,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,i,2]:[this.undefinedColor,n,i,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,i,3]:[this.undefinedColor,n,i,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,i,4]:[this.undefinedColor,n,i,4]}return[this.undefinedColor,n,i,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"}},6584:(t,e,s)=>{"use strict";s.d(e,{BX:()=>o,nW:()=>l,tW:()=>c,tb:()=>h});var n=s(4469);const i="Libraries",o="System:AppData/Bio/libraries/",r={explicit:["HELMCoreLibrary.json"],exclude:[]};let a=Promise.resolve();async function l(){let t;return a=a.then((async()=>{const e=await n.dapi.userDataStorage.getValue(i,"Settings",!0);t=e?JSON.parse(e):{exclude:[],explicit:[]},t.exclude=t.exclude instanceof Array?t.exclude:[],t.explicit=t.explicit instanceof Array?t.explicit:[],console.debug(`Bio: getUserLibSettings()\n${JSON.stringify(t,void 0,2)}`)})),await a,t}async function c(t){a=a.then((async()=>{console.debug(`Bio: setUserLibSettings()\n${JSON.stringify(t,void 0,2)}`),await n.dapi.userDataStorage.postValue(i,"Settings",JSON.stringify(t),!0)})),await a}async function h(){await c(r)}},7228:(t,e,s)=>{"use strict";s.d(e,{JN:()=>l,PF:()=>h,Qx:()=>c,Xk:()=>a});var n=s(976),i=s(4469),o=s(1047),r=(s(499),s(8457));function a(t){const e=[];for(let s=0;s<t.rowCount;s++){const n={};Object.keys(o.K4).forEach((e=>{if("symbol"===e){const i=t.get(o.K4[e],s);n[e]="."===i?t.get(o.At,s):i}else if("rgroups"===e){const i=t.get(o.K4[e],s).split("\n"),r=[];i.forEach((t=>{const e={},s=t.substring(t.lastIndexOf("]")+1),n=t.match(/\[R(\d+)\]/)[1];e.capGroupSmiles="H"===s?`[*:${n}][H]`:`O[*:${n}]`,e.alternateId="H"===s?`R${n}-H`:`R${n}-OH`,e.capGroupName="H"===s?"H":"OH",e.label=`R${n}`,r.push(e)})),n[e]=r}else o.K4[e]&&(n[e]=t.get(o.K4[e],s))})),e.push(n)}return e}async function l(){const t=n.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 c(t,e){t instanceof n.Column&&(t=(0,r.O)(t).columns.toList());const s=(await l()).getBioLib(),o=new Array(t.length),a=t[0].length,c=new Float32Array(a);for(let r=0;r<t.length;++r){const l=e[r],h=s.getMonomer("PEPTIDE",l)?.smiles??"",u=t[r],m=u.getRawData(),d=u.categories,p=d.indexOf("");if(o[r]={categories:d,data:m,emptyIndex:p},void 0===l)continue;const g=n.Column.fromStrings("smiles",d.map((t=>s.getMonomer("PEPTIDE",t)?.smiles??""))),f=(n.DataFrame.fromColumns([g]),(await i.chem.getSimilarities(g,h)).getRawData());for(let t=0;t<a;++t){const e=m[t];c[t]+=""!==l&&e!==p?f[e]:""===l&&e===p?1:0}}for(let s=0;s<c.length;++s){let i=c[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){i=n.FLOAT_NULL;break}}c[s]=i}return n.Column.fromFloat32Array("Similarity",c)}async function h(t){const e=(await l()).getBioLib(),s=[],o={},r=t.map((t=>e.getMonomer("PEPTIDE",t)?.smiles??"")),a=n.Column.fromStrings("smiles",r);for(let e=0;e<r.length;++e){o[t[e]]=e;const n=r[e],l=""===n?new Array(r.length).fill(0):(await i.chem.getSimilarities(a,n)).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 n=s(4469),i=s(976),o=s(6414),r=s.n(o),a=s(1821),l=s(499);const c={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 h=s(1047);function u(t){return Math.round(c.PRECISION_FACTOR*t)/c.PRECISION_FACTOR}async function m(t,e,o){if(0===i.Func.find({package:"Chem",name:"getRdKitModule"}).length)return{col:null,warnings:['Transformation to atomic level requires the package "Chem" installed.']};if(e.semType!==i.SEMTYPE.MACROMOLECULE)return{col:null,warnings:[`Only the ${i.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 p=l.Cn.getOrCreate(u).alphabet;let g;if("PT"===p||"UN"===p)g="PEPTIDE";else{if("RNA"!==p&&"DNA"!==p)return{col:null,warnings:[`Unexpected column's '${u.name}' alphabet '${p}'.`]};g="RNA"}const f=function(t){const e=t.length,s=new Array(e),n=l.Cn.getOrCreate(t).getSplitter();for(let i=0;i<e;++i){const e=t.get(i);s[i]=e?r()(n(e)).filter((t=>""!==t)).toArray():[]}return s}(u),y=await async function(t,e,s,i){const o=function(t,e,s){const n=new Map;for(const i of t.getMonomerSymbolsByType(e)){const o=t.getMonomer(e,i);if("RNA"===e&&("Branch"===o.monomerType||"DNA"===s&&o.symbol===c.DEOXYRIBOSE||"RNA"===s&&o.symbol===c.RIBOSE||o.symbol===c.PHOSPHATE)||"PEPTIDE"===e&&"Branch"!==o.monomerType){const t={};h.rx.forEach((e=>{t[e]=o[e]})),n.set(o.symbol,t)}}return n}(e,s,i),r=new Map,a=await n.functions.call("Chem:getRdKitModule"),l={value:null};if("RNA"===s){const t="RNA"===i?[c.RIBOSE,c.PHOSPHATE]:[c.DEOXYRIBOSE,c.PHOSPHATE];for(const e of t)d(r,e,o,a,s,l)}for(let e=0;e<t.length;++e){const n=t[e];for(const t of n)if(""!==t)try{d(r,t,o,a,s,l)}catch(e){const s=e instanceof Error?e.message:e.toString(),n=e instanceof Error?e.stack:void 0;throw console.error(`bio lib: getMonomersDictFromLib() sym='${t}', error:\n${s}\n${n}`),new Error(`Can't get monomer '${t}' from library: ${s}`)}}return r}(f,o,g,p),w=u.length,{molfileList:C,molfileWarningList:T}=await async function(t,e,n,i,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 c=[],h=[];const u=new Array(r);for(let s=0;s<r;s++){const c=Math.floor(s*l),h=s===r-1?o:Math.floor((s+1)*l);a[s].postMessage({monomerSequencesArray:t,monomersDict:e,alphabet:n,polymerType:i,start:c,end:h}),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=>{c=c.concat(...t.molfileList),h=h.concat(...t.molfileWarningList)})),setTimeout((()=>{a.forEach((t=>{t.terminate()}))}),0),{molfileList:c,molfileWarningList:h}}(f,y,p,g,w);if(T.length>.05*w)throw new Error("Too many errors getting molfiles.");const b=`molfile(${u.name})`,A=t.columns.getUnusedName(b),S=i.Column.fromStrings(A,C);return S.semType=i.SEMTYPE.MOLECULE,S.setTag(i.TAGS.UNITS,i.UNITS.Molecule.MOLBLOCK),{col:S,warnings:T}}function d(t,e,s,n,i,o){if(!t.has(e)){const r=function(t,e,s,n,i){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(c.V2K_A_LINE,0),n=s;for(;-1!==s;){n=t.indexOf("\n",s);const i=parseInt(t.substring(s,n).replace(/^A\s+/,""));s=t.indexOf("R",n),n=t.indexOf("\n",s);const o=parseInt(t.substring(s,n).replace(/^R/,""));e.set(i,o),s=t.indexOf(c.V2K_A_LINE,n)}for(s=t.indexOf(c.V2K_RGP_LINE,0),n=t.indexOf("\n",s);-1!==s;){s+=c.V2K_RGP_SHIFT,n=t.indexOf("\n",s);const i=t.substring(s,n).replaceAll(/\s+/g," ").split(" ").map((t=>parseInt(t))).slice(1);for(let t=0;t<i.length;t+=2){if(e.has(i[t])&&e.get(i[t])!==i[t+1])throw new Error(`r-group index ${i[t]} has already been added with a different value`);e.set(i[t],i[t+1])}s=t.indexOf(c.V2K_RGP_LINE,n)}return e}(o.molfile),l=function(t,e){const s=e.get_mol(t),n=s.get_v3Kmolblock();return s.delete(),n}(function(t){let e=t.indexOf(c.V2K_A_LINE,0);-1===e&&(e=t.indexOf(c.V2K_RGP_LINE));const s=t.indexOf(c.V3K_END,e);return t.substring(0,e)+t.substring(s)}(o.molfile),s),h=function(t){let e=(t=t.replaceAll("\r","")).indexOf(c.V3K_BEGIN_COUNTS_LINE)+c.V3K_COUNTS_SHIFT,s=t.indexOf(" ",e+1);const n=parseInt(t.substring(e,s));return e=s+1,s=t.indexOf(" ",e+1),{atomCount:n,bondCount:parseInt(t.substring(e,s))}}(l),m=function(t,e){const s=new Array(e),n=new Float32Array(e),i=new Float32Array(e),o=new Array(e);let r=t.indexOf(c.V3K_BEGIN_ATOM_BLOCK);r=t.indexOf("\n",r);let a=r;for(let l=0;l<e;l++){r=t.indexOf(c.V3K_BEGIN_DATA_LINE,r)+c.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));n[l]=e[0],i[l]=e[1],r=a,a=t.indexOf("\n",r)+1,o[l]=t.slice(r,a),r=a}return{atomTypes:s,x:n,y:i,kwargs:o}}(l,h.atomCount),d=function(t,e){const s=new Uint32Array(e),n=new Array(e),i=new Map,o=new Map;let r=t.indexOf(c.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(c.V3K_BEGIN_DATA_LINE,a)+c.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],n[l]=e.slice(1);const h=t.indexOf("\n",r);let u=t.slice(a,h),m=u.indexOf(c.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));i.set(l,e);const s=c.V3K_BOND_CONFIG+e.toString();u=u.replace(s,"")}u||o.set(l,u)}return{bondTypes:s,atomPairs:n,bondConfiguration:i,kwargs:o}}(l,h.bondCount),y={atoms:m,bonds:d,meta:p(m,d,r,a)};return"PEPTIDE"===n?function(t){const e=t.meta.terminalNodes[0]-1,s=t.meta.rNodes[0]-1,n=t.atoms.x,i=t.atoms.y;S(t,-n[e],-i[e]);const o=T(n[s],i[s]);b(t.atoms,-o),n[t.meta.rNodes[1]-1]<0&&function(t){A(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 n=s[t],i=s[(t+1)%2];e.has(n)?e.get(n)?.push(i):e.set(n,new Array(1).fill(i))}return e}(t);let s=0;const n=t.atoms.atomTypes.length;let i=0;for(;0===s;){const o=e.get(t.meta.terminalNodes[1])[i];if(t.atoms.atomTypes[o-1]===c.OXYGEN&&o!==t.meta.rNodes[1]&&(s=o),i++,i>n)throw new Error(`Search for double-bonded Oxygen in ${t} has exceeded the limit of ${n}`)}return s}(t);!function(t,e){t.atoms.y[t.meta.rNodes[1]-1]<0&&t.atoms.y[e-1]<0&&(function(t){A(t,!0)}(t),b(t.atoms,-function(t,e){return T(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 n=e-1,i=s-1,o=t.atoms.x,r=t.atoms.y,a=o[n],l=r[n];o[n]=o[i],r[n]=r[i],o[i]=a,r[i]=l}(t,e,t.meta.rNodes[1])}(t,r)}(y):t===c.RIBOSE||t===c.DEOXYRIBOSE?function(t,e){const s=t.atoms.x,n=t.atoms.y;let i=t.meta.terminalNodes[0]-1;const o=t.meta.rNodes[1]-1;S(t,-s[i],-n[i]);const r=T(s[o],n[o]);b(t.atoms,3*Math.PI/2-r),e.value=function(t){const e=t.atoms.x,s=t.atoms.y,n=t.meta.rNodes[2]-1,i=t.meta.terminalNodes[2]-1,o=e[n]-e[i],r=s[n]-s[i];return Math.atan(r/o)+Math.PI/2}(t),i=t.meta.terminalNodes[0]-1,S(t,-s[i],-n[i])}(y,i):t===c.PHOSPHATE?function(t){const e=t.meta.terminalNodes[0]-1,s=t.meta.rNodes[0]-1,n=t.atoms.x,i=t.atoms.y;S(t,-n[e],-i[e]);const o=T(n[s],i[s]);b(t.atoms,Math.PI/2-o)}(y):function(t,e){const s=t.atoms.x,n=t.atoms.y,i=t.meta.terminalNodes[0]-1,o=t.meta.rNodes[0]-1;S(t,-s[i],-n[i]);const r=T(s[o],n[o]),a=e.value;if(!a)throw new Error("The value of sugarBranchToOYAngle is null");b(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:n[t.meta.rNodes[0]-1]},{x:s[t.meta.terminalNodes[0]-1],y:n[t.meta.terminalNodes[0]-1]});if(1!=l)for(let t=0;t<s.length;++t)s[t]=u(s[t]/l),n[t]=u(n[t]/l)}(y,i),function(t,e,s){"PEPTIDE"===t?(f(e,t),w(e,e.meta.rNodes[1])):s===c.RIBOSE||s===c.DEOXYRIBOSE?(w(e,e.meta.rNodes[1]),e.meta.rNodes[1]=e.meta.terminalNodes[1],g(e.bonds,e.meta),f(e,t),w(e,e.meta.rNodes[1]),w(e,e.meta.rNodes[0]),w(e,e.meta.rNodes[2])):s===c.PHOSPHATE&&(e.meta.terminalNodes[0]=e.meta.rNodes[0],S(e,-e.atoms.x[e.meta.terminalNodes[0]-1],-e.atoms.y[e.meta.terminalNodes[0]-1]),f(e,t),w(e,e.meta.rNodes[1]))}(n,y,t),function(t){let e=0;for(;e<t.atoms.atomTypes.length;)t.atoms.atomTypes[e]===c.HYDROGEN&&(w(t,e+1),--e),++e}(y),y}return null}(e,s,n,i,o);if(!r)throw new Error(`Monomer with symbol '${e}' is absent the monomer library`);t.set(e,r)}}function p(t,e,s,n){const i={backboneShift:null,branchShift:null,terminalNodes:[],rNodes:[]};return function(t,e,s){for(const[n,i]of s)t.atomTypes[n-1]=e[i-1]}(t,s,n),function(t,e){e.rNodes=Array.from(t.keys());for(let s=0;s<e.rNodes.length;s++)for(const n of[1,2])if(t.get(e.rNodes[s])===n){const t=e.rNodes[n-1];e.rNodes[n-1]=e.rNodes[s],e.rNodes[s]=t}}(n,i),g(e,i),i}function g(t,e){const s=e.rNodes;e.terminalNodes=new Array(s.length).fill(0);const n=e.terminalNodes,i=t.atomPairs;let o=0,r=0;for(;o<i.length&&r<n.length;){for(let t=0;t<n.length;++t)for(let e=0;e<2;++e)i[o][e]===s[t]&&(n[t]=i[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 w(t,e){if(void 0!==e){const s=e-1,n=t.atoms,i=t.bonds,o=t.meta;n.atomTypes.splice(s,1),n.x=C(Float32Array,n.x,s,1),n.y=C(Float32Array,n.y,s,1),n.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<i.atomPairs.length;){const t=i.atomPairs[r][0],s=i.atomPairs[r][1];t===e||s===e?(i.atomPairs.splice(r,1),i.bondTypes=C(Uint32Array,i.bondTypes,r,1),i.bondConfiguration.has(r)&&i.bondConfiguration.delete(r),i.kwargs.has(r)&&i.kwargs.delete(r),--r):(i.atomPairs[r][0]=t>e?t-1:t,i.atomPairs[r][1]=s>e?s-1:s),++r}let a=Array.from(i.bondConfiguration.keys());a.forEach((t=>{if(i.bondConfiguration.has(t)&&t>s){const e=i.bondConfiguration.get(t);i.bondConfiguration.delete(t),i.bondConfiguration.set(t-1,e)}})),a=Array.from(i.kwargs.keys()),a.forEach((t=>{if(i.kwargs.has(t)&&t>s){const e=i.kwargs.get(t);i.kwargs.delete(t),i.kwargs.set(t-1,e)}}))}}function C(t,e,s,n){const i=new t(e.length-n);let o=0,r=0;for(;o<e.length;)o===s&&(o+=n),i[r]=e[o],++r,++o;return i}function T(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 n=e/t,i=Math.atan(n);s=t<0?Math.PI/2+i:-Math.PI/2+i}return s}function b(t,e){if(0!==e){const s=t.x,n=t.y,i=Math.cos(e),o=Math.sin(e);for(let t=0;t<s.length;++t){const e=s[t];s[t]=u(e*i-n[t]*o),n[t]=u(e*o+n[t]*i)}}}function A(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 n=1===e?3:1;s.set(t,n)}}function S(t,e,s){const n=t.atoms.x,i=t.atoms.y;for(let t=0;t<n.length;++t)n[t]=u(n[t]+e),void 0!==s&&(i[t]=u(i[t]+s))}},6137:(t,e,s)=>{"use strict";s.d(e,{J:()=>i,V:()=>o});var n=s(9976);class i extends n.B{static get Chromatogram(){return void 0===this.chromatogram&&(this.chromatogram=new i({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:()=>n});class n{static makePalette(t,e=!1,s=n){const i={};return t.forEach((t=>{const s=t[0],n=t[1];s.forEach(((t,s)=>{i[t]=this.colourPalette[n][e?0:s]}))})),new s(i)}constructor(t){this._palette=t}get(t){return this._palette[t]}}n.undefinedColor="rgb(100,100,100)",n.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:()=>c,kQ:()=>r});var n=s(976),i=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(i.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=n.Color.fromHtml(t),s=n.Color.g(e),i=n.Color.r(e),o=n.Color.b(e),r=Math.sqrt(Math.pow(0-i,2)+Math.pow(0-s,2)+Math.pow(0-o,2));return r>210?`rgb(${i/r*210},${s/r*210},${o/r*210})`:n.Color.toRgb(e)}(l.palette[e])}}l.palette=l.buildPalette();class c extends i.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:()=>c});var n=s(4469),i=s(976),o=s(6414),r=s.n(o),a=s(8447);const l={DNA:"RNA",RNA:"RNA",PT:"PEPTIDE",UN:"PEPTIDE"};class c{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=i.BitSet.create(this.col.length),this.grid&&(this.subs.push(e.dataFrame.onDataChanged.subscribe((()=>{this.props=this.propsProvider(),this._monomerLengthList=null,this._rowsProcessed=i.BitSet.create(this.col.length)}))),this.subs.push(n.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,n]of r().enumerate(s)){const s=this.props.monomerToShort(t,this.props.monomerLengthLimit),i=(this.props.unitsHandler.isSeparator()?this.separatorWidth:this.props.separatorWidth)+s.length*this.props.monomerCharWidth;e[n]=i}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),n=Math.min(Math.ceil((this.grid?.vertScroll.max??0)+10),this.col.length);for(let t=s;t<n;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,n]of r().enumerate(s)){const s=this.props.monomerToShort(t,this.props.monomerLengthLimit),i=this.props.separatorWidth+s.length*this.props.monomerCharWidth;e[n]=Math.max(e[n]??0,i)}this._updated=!0}return e}getPosition(t,e){const[s,n]=this.getCellMonomerLengths(t),i=this.col.get(t),o=r()(this._splitter(i)).toArray();if(0===o.length)return null;let a=100,l=null,c=o.length,h=!1,u=0;if(n[0]<=e&&e<n.slice(-1)[0])for(;!h;)if(u=Math.floor((c+(l??0))/2),e>=n[u]&&e<=n[u+1]?(l=u,h=!0):e<n[u]?c=u-1:e>n[u+1]&&(l=u+1),l==c&&(h=!0),--a<=0)throw new Error(`Get position for pointer x = ${e} searching has not converged on ${JSON.stringify(n)}. `);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:()=>c,At:()=>i,K4:()=>a,Wc:()=>o,Z2:()=>l,nJ:()=>r,pU:()=>h,rx:()=>n});const n=["symbol","molfile","rgroups","name"],i="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"},{capGroupSmiles:"[*:3][H]",alternateId:"R3-H",capGroupName:"H",label:"R3"}],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:""},c="p",h=new RegExp(`[rd]\\((\\w)\\)${c}?`,"g")},7945:(t,e,s)=>{"use strict";function n(t){return"string"==typeof t||t instanceof String?t:"StateError"===t.constructor.name?t.message:"StateError"===t.constructor.name&&"$thrownJsError"in t?n(t.$thrownJsError):t instanceof Error?t.message:t.toString()}function i(t){return t instanceof Error?t.stack:"StateError"===t.constructor.name&&"$thrownJsError"in t?i(t.$thrownJsError):void 0}function o(t){return[n(t),i(t)]}s.d(e,{yf:()=>o})},5226:(t,e,s)=>{"use strict";s.d(e,{i:()=>r});var n=s(976),i=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 n=this._fileContent.substring(e.index+1,t.lastIndex);this._descriptionsArray.push(n),0!==s&&this._sequencesArray.push(this.parseMacromolecule(s,e.index)),s=t.lastIndex+1}this._sequencesArray.push(this.parseMacromolecule(s,-1))}importFasta(){const t=n.Column.fromStrings("description",this.descriptionsArray),e=n.Column.fromStrings("sequence",this.sequencesArray);return e.semType=n.SEMTYPE.MACROMOLECULE,e.setTag(n.TAGS.UNITS,o.r2.FASTA),i.Cn.getOrCreate(e),[n.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:()=>n,se:()=>a});var n,i=s(6286);!function(t){t.FASTA="fasta",t.SEPARATOR="separator",t.HELM="helm"}(n||(n={}));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 i.L("PT",a.fasta.peptide,.5),new i.L("DNA",a.fasta.dna,.55),new i.L("RNA",a.fasta.rna,.55)]},8447:(t,e,s)=>{"use strict";s.d(e,{CI:()=>n.CI,GU:()=>i.GU,KX:()=>i.KX,Mj:()=>i.Mj,XS:()=>n.XS,dQ:()=>i.dQ,gM:()=>i.gM,gP:()=>i.gP,kB:()=>i.kB,py:()=>i.py,r2:()=>n.r2,up:()=>i.up});var n=s(1821),i=s(585)},6286:(t,e,s)=>{"use strict";s.d(e,{L:()=>n,d:()=>i});class n{constructor(t,e,s){this.name=t,this.alphabet=e,this.cutoff=s}}class i extends n{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:()=>y,FJ:()=>f,GU:()=>E,KX:()=>v,Mj:()=>A,dQ:()=>x,gM:()=>M,gP:()=>T,jY:()=>p,kB:()=>g,py:()=>I,up:()=>L,vU:()=>b,w4:()=>N});var n=s(976),i=s(6414),o=s.n(i),r=s(6286),a=s(1821),l=s(499),c=s(3659),h=s(850),u=s(2012),m=s(6137),d=s(7331);function p(t,e,s){return t.categories,function(t,e){const s={};let n=!0,i=null;for(const o of t)if(null==i?i=o.length:o.length!==i&&(n=!1),o.length>=e)for(const t of o)t in s||(s[t]=0),s[t]+=1;return{freq:s,sameLength:n}}(o()(t.getRawData()).map((e=>s(t.categories[e]))),e)}function g(t){return o()(t.toString().matchAll(a.BM)).map((t=>t[2]??t[1])).toArray()}function f(t){return t||[]}function y(t,e=undefined){return s=>s?s.replaceAll('"-"',"").replaceAll("'-'","").split(t,e):[]}const w=/(PEPTIDE1|DNA1|RNA1)\{([^}]+)}/g,C=/\[([^\[\]]+)]/g;function T(t){w.lastIndex=0;const e=w.exec(t.toString()),s=e?e[2]:null;return(s?s.split("."):[]).map((t=>{C.lastIndex=0;const e=C.exec(t);return e&&e.length>=2?e[1]:t}))}function b(t,e,s=undefined){if(t.toLowerCase().startsWith(a.r2.FASTA))return g;if(t.toLowerCase().startsWith(a.r2.SEPARATOR))return y(e,s);if(t.toLowerCase().startsWith(a.r2.HELM))return T;throw new Error(`Unexpected units ${t} .`)}function A(t){return l.Cn.getOrCreate(t).getSplitter()}const S=/([^\W_]+)/g;function E(t,e){if(t.length<=e)return t;const s=t.match(S),n=t.length>e||(s?.length??0)>1,i=s?.[0]??" ";return n?i.substring(0,e-1)+"…":i}function M(t){switch(t){case"DNA":return a.se.fasta.dna;case"RNA":return a.se.fasta.rna;case"PT":return a.se.fasta.peptide;default:throw new Error(`Unsupported alphabet '${t}'.`)}}function v(t,e,s="-"){const n=new Set([...new Set(Object.keys(t)),...e]);n.delete(s);const i=[],o=[];for(const s of n)i.push(s in t?t[s]:0),o.push(e.has(s)?1:0);const r=new c.OW(i),a=new c.OW(o);return(0,h.MA)(r,a)/((0,h.$G)(r)*(0,h.$G)(a))}function N(t,e,s="-"){const n=e.map((e=>{const n=v(t,e.alphabet,s);return new r.d(e,t,n)}));let i;const o=Math.max(...n.map((t=>t.similarity>t.cutoff?t.similarity:-1)));return i=o>0?n.find((t=>t.similarity===o)).name:"UN",i}function x(t,e=5){let s;return s=t.semType==n.SEMTYPE.MACROMOLECULE?l.Cn.getOrCreate(t).alphabet:N(p(t,e,g).freq,a.XS),I(s)}function I(t){switch(t){case"PT":return u.f.GrokGroups;case"DNA":case"RNA":return m.J.Chromatogram;default:return d.UE.Color}}function L(t){const e=t.columns.bySemTypeAll(n.SEMTYPE.MACROMOLECULE);let s=e.find((t=>{const e=t.getTag(n.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 n=s(976),i=s(6414),o=s.n(i),r=s(585);function a(t){const e=(0,r.Mj)(t),s=t=>{const e=l.columns.addNewString((t+1).toString());return i.push(e),e},i=[],a=t.length,l=n.DataFrame.create(a);for(let n=0;n<a;++n){const r=t.get(n);if(null==r)continue;const a=e(r);for(const[t,e]of o().enumerate(a))((i[e]??null)||s(e)).set(n,t||"-",!1)}return l}},172:(t,e,s)=>{"use strict";s.d(e,{c:()=>o});var n,i=s(7945);!function(t){t[t.error=0]="error",t[t.warning=1]="warning",t[t.info=2]="info",t[t.debug=3]="debug"}(n||(n={}));class o{constructor(t){this.logger=t,this.promise=Promise.resolve(),this.syncCounter=0}sync(t,e){const s=++this.syncCounter;this.logger.debug(`${t}, SYNC syncId = ${s}, IN `),this.promise=this.promise.then((async()=>{this.logger.debug(`${t}, SYNC syncId = ${s}, START `),await e(),this.logger.debug(`${t}, SYNC syncId = ${s}, END `)})).catch((e=>{const[n,o]=(0,i.yf)(e);this.logger.error(`${t}, SYNC syncId = ${s}, ERROR:\n${n}`,void 0,o)}))}}},499:(t,e,s)=>{"use strict";s.d(e,{Cn:()=>d,_9:()=>m});var n=s(976),i=s(6414),o=s.n(i),r=s(8447),a=s(585),l=s(489),c=s(7228),h=s(1047);const u=new class{constructor(){this.uh=`units-handler.${n.SEMTYPE.MACROMOLECULE}`}},m={[r.r2.FASTA]:"-",[r.r2.SEPARATOR]:"",[r.r2.HELM]:"*"};class d{static setUnitsToFastaColumn(t){if(t.column.semType!==n.SEMTYPE.MACROMOLECULE||t.column.getTag(n.TAGS.UNITS)!==r.r2.FASTA)throw new Error(`The column of notation '${r.r2.FASTA}' must be '${n.SEMTYPE.MACROMOLECULE}'.`);t.column.setTag(n.TAGS.UNITS,r.r2.FASTA),d.setTags(t)}static setUnitsToSeparatorColumn(t,e){if(t.column.semType!==n.SEMTYPE.MACROMOLECULE||t.column.getTag(n.TAGS.UNITS)!==r.r2.SEPARATOR)throw new Error(`The column of notation '${r.r2.SEPARATOR}' must be '${n.SEMTYPE.MACROMOLECULE}'.`);if(!e)throw new Error(`The column of notation '${r.r2.SEPARATOR}' must have the separator tag.`);t.column.setTag(n.TAGS.UNITS,r.r2.SEPARATOR),t.column.setTag("separator",e),d.setTags(t)}static setUnitsToHelmColumn(t){if(t.column.semType!==n.SEMTYPE.MACROMOLECULE)throw new Error(`The column of notation '${r.r2.HELM}' must be '${n.SEMTYPE.MACROMOLECULE}'`);t.column.setTag(n.TAGS.UNITS,r.r2.HELM),d.setTags(t)}static setTags(t){const e=t.column.getTag(n.TAGS.UNITS),s=t.stats;if(Object.keys(s.freq).some((t=>t.length>1)),[r.r2.FASTA,r.r2.SEPARATOR].includes(e)){if(!t.column.getTag("alphabet")&&0===Object.keys(s.freq).length)throw new Error("Alphabet is empty and not annotated.");let e=t.column.getTag("aligned");null===e&&(e=s.sameLength?"SEQ.MSA":"SEQ",t.column.setTag("aligned",e));let n=t.column.getTag("alphabet");if(null===n&&(n=(0,a.w4)(s.freq,r.XS),t.column.setTag("alphabet",n)),"UN"===n){const e=Object.keys(s.freq).length,n=Object.keys(s.freq).some((t=>t.length>1));t.column.setTag(".alphabetSize",e.toString()),t.column.setTag(".alphabetIsMultichar",n?"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(),n=this._column.categories;for(let i=0;i<e;i++){const e=n[s[i]];this._splitted[i]=t(e)}}return this._splitted}get stats(){if(null===this._stats){const t={};let e=!0,s=null;for(const n of this.splitted){null==s?s=n.length:n.length!==s&&(e=!1);for(const e of n)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=0===this.splitted.length?0: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,i=s.length,o=t.toLowerCase()+"("+s.name+")",a=s.dataFrame.columns.getUnusedName(o),l=n.Column.fromList("string",a,new Array(i).fill(""));if(l.semType=n.SEMTYPE.MACROMOLECULE,l.setTag(n.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(n.TAGS.CELL_RENDERER,"Macromolecule");const c=s.getTag("aligned");c&&l.setTag("aligned",c);const h=s.getTag("alphabet");null!=h&&l.setTag("alphabet",h);let u=s.getTag(".alphabetSize");null!=h&&u&&l.setTag(".alphabetSize",u);const m=s.getTag(".alphabetIsMultichar");return null!=h&&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 i=n.Column.fromList("string",e,new Array(t).fill(""));return i.semType=n.SEMTYPE.MACROMOLECULE,i.setTag(n.TAGS.UNITS,s),i}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,c.JN)()).getBioLib().getMonomerSymbolsByType("PEPTIDE".toString()),e=new Set(t),s=(0,a.Ar)(this.separator);for(const t of this.column.categories){const n=s(t);for(const t of n)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,n){n||(n=this.toFasta(e)?m[r.r2.FASTA]:m[r.r2.SEPARATOR]),s||(s=this.toFasta(e)?"":this.separator);const i=t.startsWith("RNA"),o=this.splitter(t),a=[];for(let t=0;t<o.length;t++){let s=o[t];if(i&&(s=s.replace(h.pU,"")),s===m[r.r2.HELM])a.push(n);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),n=this.getNewColumn(t,e);return n.init((t=>s(this.column.get(t)))),n}getRegion(t,e,s){const n=this.getNewColumn(this.notation,this.separator);n.name=s,Math.max(...this.splitted.map((t=>t.length)));const i=t??0,o=e??this.maxLength-1,a=this.getJoiner(),l=o-i+1;n.init((t=>{const e=this.splitted[t],s=new Array(l);for(let t=0;t<l;++t){const n=i+t;s[t]=n<e.length?e[n]:m[this.notation]}return a(s)}));const c=t=>{const e=t.split(",").map((t=>t.trim())),s=new Array(l);for(let t=0;t<l;++t){const n=i+t;s[t]=n<e.length?e[n]:"?"}return s.join(r.CI)},h=this.column.getTag(".positionNames");h&&n.setTag(".positionNames",c(h));const u=this.column.getTag(".positionLabels");return u&&n.setTag(".positionLabels",c(u)),n}getJoiner(){if(void 0===this._joiner){const t=this;if(this.notation===r.r2.FASTA)this._joiner=function(e){return p(t,e)};else if(this.notation===r.r2.SEPARATOR)this._joiner=function(e){return g(t,e,t.separator)};else{if(this.notation!==r.r2.HELM)throw new Error;{const e="DNA"===t.alphabet||"RNA"===t.alphabet;this._joiner=function(s){return f(t,s,e)}}}}return this._joiner}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 p(t,s)}(s,t)};if(t===r.r2.HELM)return function(t){return function(t,e){const s=e.startsWith("DNA")||e.startsWith("RNA"),n=t.getSplitter()(e);return f(t,n,s)}(s,t)};if(t===r.r2.SEPARATOR)return function(t){return function(t,e,s){const n=t.isHelm()?y(t,e):t.getSplitter()(e);return g(t,n,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,this._joiner=void 0,t.type!==n.TYPE.STRING)throw new Error(`Unexpected column type '${t.type}', must be '${n.TYPE.STRING}'.`);this._column=t;const e=this._column.getTag(n.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(n.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){let e=t.temp[u.uh];return e||(e=t.temp[u.uh]=new d(t)),e}}function p(t,e){const s=new Array(e.length);for(const[n,i]of o().enumerate(e)){let o=n;t.isHelm()&&(o=n.replace(h.pU,"$1")),t.isGap(o)?o=m[r.r2.FASTA]:o.length>1&&(o="["+e[i]+"]"),s[i]=o}return s.join("")}function g(t,e,s){const n=new Array(e.length);for(const[s,i]of o().enumerate(e)){let e=s;t.isGap(e)&&(e=m[r.r2.SEPARATOR]),n[i]=e}return n.map((t=>t??"")).join(s)}function f(t,e,s){const[n,i,a,l]=t.getHelmWrappers();return`${n}${o()(e).map((e=>{let n=e;return n=t.isGap(n)?m[r.r2.HELM]:s?n.replace(h.pU,"$1"):1==e.length?`${i}${e}${a}`:`${i}[${e}]${a}`,n})).toArray().join(".")}${l}`}function y(t,e){const s=t.getSplitter()(e),n=new Array(s.length),i=e.startsWith("DNA"),r=e.startsWith("RNA");for(const[t,e]of o().enumerate(s)){let s=t;(i||r)&&(s=s.replace(h.pU,"$1"),s=s===h.$3?null:s),n[e]=s}return n.filter((t=>null!==t))}},9298:(t,e,s)=>{"use strict";s.d(e,{Ct:()=>l,DX:()=>n,ES:()=>i,dE:()=>a,iD:()=>r,vS:()=>h,vw:()=>o});var n,i,o,r,a,l,c=s(976);!function(t){t.tooltipWebLogo=".tooltipWebLogo"}(n||(n={})),function(t){t.Entropy="Entropy",t.full="100%"}(i||(i={})),function(t){t.TOP="top",t.MIDDLE="middle",t.BOTTOM="bottom"}(o||(o={})),function(t){t.LEFT="left",t.CENTER="center",t.RIGHT="right"}(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.valueAggrType=c.AGG.TOTAL_COUNT,this.valueColumnName="Activity",this.startPositionName=null,this.endPositionName=null,this.skipEmptySequences=!0,this.skipEmptyPositions=!1,this.shrinkEmptyTail=!0,this.backgroundColor=4294967295,this.positionHeight=i.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}}},922:(t,e,s)=>{"use strict";s.d(e,{_:()=>l});class n{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 n=this.isWhitespace(s)?e:e-1;for(let t=0;t<n;t++)s=this.getNextColumnIdx(s);return s}parseAtomTypes(){const t=this.atomCount,e=new Array(t);let s=this.getAtomBlockIdx();for(let n=0;n<t;n++)s=this.shiftIdxToAtomType(s),e[n]=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 n=this.getAtomBlockIdx();for(let i=0;i<this.atomCount;i++){n=this.shiftIdxToXColumn(n);for(const o of[t,e,s])o[i]=this.parseFloatValue(n),n=this.getNextColumnIdx(n);n=this.getNextLineIdx(n)}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 n=new Uint16Array(2);n[0]=this.parseIntValue(e),e=this.getNextColumnIdx(e),n[1]=this.parseIntValue(e),t[s]=n,e=this.getNextLineIdx(e)}return t}parseBondTypes(){const t=this.bondCount,e=new Uint16Array(t);let s=this.getBondBlockIdx();for(let n=0;n<t;n++)s=this.shiftIdxToBondType(s),e[n]=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 i extends n{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 n=0;n<e;n++){if(s=this.shiftIdxToAtomType(s),t(this.fileContent.charCodeAt(s),s))return!0;s=this.getNextLineIdx(s)}return!1}}var o;!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"}(o||(o={}));class r extends i{constructor(t){super(t)}static validate(t){return-1!==t.indexOf(o.HEADER)&&-1!==t.indexOf(o.END)}shiftIdxToAtomType(t){return this.shiftIdxToSpecifiedColumn(t,o.ATOM_TYPE_COL)}getCountsLineIdx(){let t=0;for(let e=0;e<o.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,o.FIRST_BONDED_ATOM_COL)}shiftIdxToBondType(t){return this.shiftIdxToSpecifiedColumn(t,o.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+o.NUM_OF_COUNTS_DIGITS;const s=parseInt(this.fileContent.substring(t,e));return t=e,e+=o.NUM_OF_COUNTS_DIGITS,{atomCount:s,bondCount:parseInt(this.fileContent.substring(t,e))}}}class a extends i{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 l{constructor(){}static getInstance(t){if(r.validate(t))return new r(t);if(a.validate(t))return new a(t);throw new Error("Malformed molfile")}}},2669:(t,e,s)=>{"use strict";s.d(e,{m:()=>n});class n{constructor(t=!0,e=!0){const n=navigator.hardwareConcurrency;this._workerCount=t?Math.max(n-2,1):1,this._workers=new Array(this._workerCount).fill(null).map((()=>new Worker(new URL(s.p+s.u(65),s.b)))),this._terminateOnComplete=e}async calc(t,e,s=!0,n){return new Promise((async(i,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,c=new Float32Array(a);let h=0,u=1,m=0,d=Number.MIN_VALUE;for(let s=0;s<this._workerCount;s++){const i=Math.floor(s*l),p=s===this._workerCount-1?a:Math.floor((s+1)*l),g=h,f=u;s!==this._workerCount-1&&(h=o-2-Math.floor(Math.sqrt(-8*p+4*o*(o-1)-7)/2-.5),u=p-o*h+Math.floor((h+1)*(h+2)/2)),this._workers[s].postMessage({values:t,fnName:e,startRow:g,startCol:f,chunckSize:p-i,opts:n}),r[s]=new Promise(((t,e)=>{this._workers[s].onmessage=({data:{error:n,distanceMatrixData:o,min:r,max:a}})=>{this._terminateOnComplete&&this._workers[s].terminate(),n?e(n):(c.set(o,i),r<m&&(m=r),a>d&&(d=a),t())}}))}await Promise.all(r),s&&c.forEach(((t,e)=>{c[e]=(t-m)/(d-m)})),i(c)}catch(t){o(t)}}))}terminate(){this._workers.forEach((t=>t.terminate()))}}},3914:(t,e,s)=>{"use strict";s.d(e,{H:()=>i});var n=s(6814);class i{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 i(void 0,s);for(let i=0;i<s;i++)for(let r=i+1;r<s;r++)o.set(i,r,(0,n.k)(t[i])||(0,n.k)(t[r])?1:e(t[i],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 n=0;n<this._data.length;n++)this._data[n]=0===s?this._data[n]-t:(this._data[n]-t)/(e-t)}}},6254:(t,e,s)=>{"use strict";function n(t,e){const s=i(e);function n(t,e){const n=Number(t),i=Number(e);return s(n,i)}const o={get:(t,s,i)=>"length"===s?e:new Proxy(t,function(t){return{get:(e,s,i)=>t===s?0:e[Number(t)>Number(s)?n(s,t):n(t,s)]}}(s))};return new Proxy(t,o)}function i(t){return(e,s)=>t*e+s-Math.floor((e+2)*(e+1)/2)}s.d(e,{_:()=>n,y:()=>i})},2590:(t,e,s)=>{"use strict";s.d(e,{_:()=>r});var n=s(5697),i=s(6361),o=s(6814);class r{constructor(){this._workerCount=Math.max(navigator.hardwareConcurrency-2,1)}async calc(t,e,n,i={}){const o=t.length*(t.length-1)/2,r=Math.floor(o/this._workerCount),a=t.length>2e4?await this.getMinimalThreshold(t,e,i):0;n<a&&(console.log(`using threshold ${a}`),n=a),i.threshold=n;const l=new Array(this._workerCount),c=new Array(this._workerCount).fill(null).map((()=>new Worker(new URL(s.p+s.u(23),s.b))));for(let s=0;s<this._workerCount;s++)l[s]=new Promise(((a,l)=>{const h=s*r,u=s===this._workerCount-1?o:(s+1)*r;u<=h&&a({i:new Int32Array(0),j:new Int32Array(0),distance:new Float32Array(0),idx:s}),c[s].postMessage({values:t,startIdx:h,endIdx:u,threshold:n,fnName:e,opts:i}),c[s].onmessage=({data:{error:t,i:e,j:n,distance:i}})=>{t?(c[s].terminate(),l(t)):(c[s].terminate(),a({i:e,j:n,distance:i,idx:s}))}}));const h=await Promise.all(l),u=h.reduce(((t,e)=>t+e.i.length),0),m=new Int32Array(u),d=new Int32Array(u),p=new Float32Array(u);let g=0;for(const t of h)m.set(t.i,g),d.set(t.j,g),p.set(t.distance,g),g+=t.i.length;return{i:m,j:d,distance:p}}async getKNN(t,e,n=15,i={}){const r=t.length*(t.length-1)/2,a=Math.floor(r/this._workerCount),l=new Array(this._workerCount),c=new Array(this._workerCount).fill(null).map((()=>new Worker(new URL(s.p+s.u(282),s.b))));for(let s=0;s<this._workerCount;s++)l[s]=new Promise(((o,l)=>{const h=s*a,u=s===this._workerCount-1?r:(s+1)*a;u<=h&&o({knnDistances:new Array(0),knnIndexes:new Array(0)}),c[s].postMessage({values:t,startIdx:h,endIdx:u,fnName:e,opts:i,nNeighbours:n}),c[s].onmessage=({data:{error:t,knnDistances:e,knnIndexes:n}})=>{t?(c[s].terminate(),l(t)):(c[s].terminate(),o({knnDistances:e,knnIndexes:n}))}}));const h=await Promise.all(l),u={knnDistances:new Array(t.length).fill(null).map((()=>new Array(n).fill(99999))),knnIndexes:new Array(t.length).fill(null).map((()=>new Array(n).fill(-1)))};for(const e of h)for(let s=0;s<t.length;++s)for(let t=0;t<e.knnDistances[s]?.length;++t)(0,o.c)(u.knnDistances[s],u.knnIndexes[s],e.knnDistances[s][t],e.knnIndexes[s][t]);return u}async getSampleDistances(t,e,n={}){const i=new Array(this._workerCount).fill(null).map((()=>new Worker(new URL(s.p+s.u(40),s.b)))),o=t.slice();for(let t=o.length-1;t>0;t--){const e=Math.floor(Math.random()*(t+1));[o[t],o[e]]=[o[e],o[t]]}try{const s=t.length*(t.length-1)/2,r=Math.floor(s/this._workerCount),a=1e6,l=Math.max(Math.min(s/1e3,a),Math.min(s,a)),c=Math.floor(l/this._workerCount),h=new Array(this._workerCount);for(let t=0;t<this._workerCount;t++)h[t]=new Promise(((a,l)=>{const h=t*r,u=t===this._workerCount-1?s:(t+1)*r;i[t].postMessage({values:o,startIdx:h,endIdx:u,sampleLength:c,fnName:e,opts:n}),i[t].onmessage=({data:{error:e,distance:s}})=>{i[t].terminate(),e?l(e):a({distance:s})}}));const u=await Promise.all(h),m=u.reduce(((t,e)=>t+e.distance.length),0),d=new Float32Array(m);let p=0;for(const t of u)d.set(t.distance,p),p+=t.distance.length;return d.sort(),d}catch(t){return i?.forEach((t=>t?.terminate())),console.error(t),new Float32Array(1).fill(.5)}}async getMinimalThreshold(t,e,s={}){try{const n=t.length*(t.length-1)/2,i=await this.getSampleDistances(t,e,s);return 1-i[Math.floor(7e7/n*i.length)]}catch(t){return console.error(t),.5}}static calcSync(t,e,s,r){const a=[],l=[],c=[];let h=0,u=0,m=0;const d=t.length*(t.length-1)/2;for(;h<d;){const d=(0,o.k)(t[u])||(0,o.k)(t[m])?1:s(t[u],t[m]);(Object.values(i.gk).some((t=>t===e))?(0,n.Om)(d):1-d)>=r&&(a.push(u),l.push(m),c.push(d)),h++,m++,m===t.length&&(u++,m=u+1)}return{i:new Int32Array(a),j:new Int32Array(l),distance:new Float32Array(c)}}}},6814:(t,e,s)=>{"use strict";s.d(e,{c:()=>i,k:()=>n});const n=t=>null==t;function i(t,e,s,n){if(s>t[t.length-1])return;const i=t.findIndex((t=>s>t))+1;t.pop(),t.splice(i,0,s),e.pop(),e.splice(i,0,n)}},5697:(t,e,s)=>{"use strict";s.d(e,{Dz:()=>T,FV:()=>u,KR:()=>h,MI:()=>A,NB:()=>f,Om:()=>S,Rt:()=>a,UX:()=>g,WI:()=>p,Zd:()=>d,_h:()=>m,aW:()=>w,bX:()=>M,bc:()=>l,eo:()=>E,fX:()=>b,kg:()=>r,s:()=>y,yU:()=>C});var n=s(9657),i=s(1040),o=s(489);i.gk.Tanimoto,i.gk.Dice,i.gk.Asymmetric,i.gk.BraunBlanquet,i.gk.Cosine,i.gk.Kulczynski,i.gk.McConnaughey,i.gk.RogotGoldberg,i.gk.Russel,i.gk.Sokal,i.gk.Hamming,i.gk.Euclidean,i.gk.Tanimoto,i.gk.Dice,i.gk.Asymmetric,i.gk.BraunBlanquet,i.gk.Cosine,i.gk.Kulczynski,i.gk.McConnaughey,i.gk.RogotGoldberg,i.gk.Russel,i.gk.Sokal,i.gk.Hamming,i.gk.Euclidean;const r=[i.gk.Tanimoto,i.gk.Dice,i.gk.Cosine],a=[i.gk.Tanimoto,i.gk.Asymmetric,i.gk.Cosine,i.gk.Sokal],l=[o.U.HAMMING,o.U.LEVENSHTEIN,o.U.MONOMER_CHEMICAL_DISTANCE,o.U.NEEDLEMANN_WUNSCH];function c(t,e){const s=t.trueCount()+e.trueCount();if(0==s)return 1;const n=t.andWithCountBits(e,!0);return n/(s-n)}function h(t,e){return E(c(t,e))}function u(t,e){return E(c(new n.Z(t,32*t.length),new n.Z(e,32*e.length)))}function m(t,e){return E(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 E(function(t,e){const s=t.trueCount()*e.trueCount();return 0==s?0:t.andWithCountBits(e,!0)/Math.sqrt(s)}(t,e))}function p(t,e){return Math.sqrt(t.trueCount()+e.trueCount()-2*t.andWithCountBits(e,!0))}function g(t,e){return t.trueCount()+e.trueCount()-2*t.andWithCountBits(e,!0)}function f(t,e){return E(function(t,e){const s=t.trueCount()+e.trueCount(),n=t.andWithCountBits(e,!0);return n/(2*s-3*n)}(t,e))}function y(t,e){return E(function(t,e){const s=t.trueCount()+e.trueCount(),n=t.trueCount()*e.trueCount();return 0==n?0:t.andWithCountBits(e,!0)*s/(2*n)}(t,e))}function w(t,e){return E(function(t,e){const s=t.trueCount()+e.trueCount(),n=t.trueCount()*e.trueCount();return 0==n?0:(t.andWithCountBits(e,!0)*s-n)/n}(t,e))}function C(t,e){return E(function(t,e){const s=Math.min(t.trueCount(),e.trueCount());return 0==s?0:t.andWithCountBits(e,!0)/s}(t,e))}function T(t,e){return E(function(t,e){const s=Math.max(t.trueCount(),e.trueCount());return 0==s?0:t.andWithCountBits(e,!0)/s}(t,e))}function b(t,e){return E(function(t,e){return 0==t.length?0:t.andWithCountBits(e,!0)/t.length}(t,e))}function A(t,e){return E(function(t,e){const s=t.andWithCountBits(e,!0),n=t.countBits(!0)+e.countBits(!0),i=t.length,o=i-n+s;return s==i||o==i?1:s/n+o/(2*i-n)}(t,e))}function S(t){return 1/(1+t)}function E(t){return 0===t?3402823e32:1/t-1}function M(t,e){return Math.abs(t-e)}},3277:(t,e,s)=>{"use strict";s.d(e,{dB:()=>a,n3:()=>n,q6:()=>r,sS:()=>l,ts:()=>o,vO:()=>i});const n="dim-red-preprocessing-function",i="supportedSemTypes",o="supportedTypes",r="supportedUnits",a="supportedDistanceFunctions",l="bypassLargeDataWarning"},779:(t,e,s)=>{"use strict";function n(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,n=Math.min(...Object.keys(e).map((t=>t.charCodeAt(0))))+1,i=new Float32Array((s.length+n)*(s.length+n));return Object.entries(e).forEach((([t,n])=>{const o=s[n];Object.entries(e).forEach((([e,n])=>{i[t.charCodeAt(0)*s.length+e.charCodeAt(0)]=o[n]}))})),(t,e)=>i[t.charCodeAt(0)*s.length+e.charCodeAt(0)]}(),s=t?.threshold??0;return(t,n)=>{let i=0;const o=t.length,r=n.length,a=Math.max(o,r)*(1-s);o!==r&&(i=Math.abs(o-r));let l=0;for(let s=0;s<Math.min(o,r);s++)if(t[s]!==n[s]&&(l+=e(t[s],n[s]),l>a))return 1;return l+=i,l/=Math.max(o,r),l}}s.d(e,{j:()=>n})},489:(t,e,s)=>{"use strict";s.d(e,{U:()=>n.U,o:()=>n.o});var n=s(5540)},458:(t,e,s)=>{"use strict";s.d(e,{r:()=>i});var n=s(1811);function i(){return(t,e)=>(0,n.T)(t,e)/Math.max(t.length,e.length)}},5540:(t,e,s)=>{"use strict";s.d(e,{U:()=>n,o:()=>a});var n,i=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"}(n||(n={}));const a={[n.HAMMING]:i.j,[n.LEVENSHTEIN]:o.r,[n.NEEDLEMANN_WUNSCH]:r.n,[n.MONOMER_CHEMICAL_DISTANCE]:i.j}},6683:(t,e,s)=>{"use strict";s.d(e,{n:()=>i});const n={gapOpen:1,gapExtend:.6,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,0,0,0,1,-3,-3,0,-2,-3,-2,1,0,-4,-2,-3,3,0,-1,-4],[-2,-2,1,6,-3,0,2,-1,-1,-3,-4,-1,-3,-3,-1,0,-1,-4,-3,-3,4,1,-1,-4],[0,-3,-3,-3,9,-3,-4,-3,-3,-1,-1,-3,-1,-2,-3,-1,-1,-2,-2,-1,-3,-3,-2,-4],[-1,1,0,0,-3,5,2,-2,0,-3,-2,1,0,-3,-1,0,-1,-2,-1,-2,0,3,-1,-4],[-1,0,0,2,-4,2,5,-2,0,-3,-3,1,-2,-3,-1,0,-1,-3,-2,-2,1,4,-1,-4],[0,-2,0,-1,-3,-2,-2,6,-2,-4,-4,-2,-3,-3,-2,0,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-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 i(t){const e=new Uint16Array(65536),{gapOpen:s,gapExtend:i,scoringMatrix:o,alphabetIndexes:r}={...n,...t};Object.entries(r).forEach((([t,s])=>e[t.charCodeAt(0)]=s));const a=[new Float32Array(1e4),new Float32Array(1e4)];return(t,n)=>{const r=new Array(t.length+1).fill(!1),l=new Array(t.length+1).fill(!1);let c=0,h=1;for(let e=1;e<t.length+1;e++)a[0][e]=-s-(e-1)*i,a[1][e]=0;for(let u=1;u<n.length+1;u++){a[h][0]=-s-(u-1)*i;for(let m=1;m<t.length+1;m++){const d=a[c][m-1]+o[e[t.charCodeAt(m-1)]][e[n.charCodeAt(u-1)]],p=a[c][m]-(r[m]?i:s),g=a[h][m-1]-(l[m-1]?i:s);a[h][m]=Math.max(d,g,p),a[h][m]===d?(r[m]=!1,l[m]=!1):a[h][m]===g?(r[m]=!1,l[m]=!0):(r[m]=!0,l[m]=!1)}c=h,h=(h+1)%2}const u=Math.max(t.length,n.length);return(u-a[c][t.length])/u}}},116:(t,e,s)=>{"use strict";var n;s.d(e,{AL:()=>n,aP:()=>o,bD:()=>i}),s(7659),s(3659),s(850),s(9006),s(7861),s(9657),s(1729),s(2669),s(3914),s(6254),s(2590),function(t){t.UMAP="UMAP",t.T_SNE="t-SNE"}(n||(n={}));class i{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:()=>c});var n=s(850),i=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??n.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,n.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,i.I)(e);let a=(0,i.I)(e);for(;r==a;)a=(0,i.I)(e);const l=s[r],c=s[a],h=this.calcDistance(t,r,a),u=(0,n.dP)(l,c);if(0==this.cutoff||h<=this.cutoff||u<h){const t=o*(h-u)/(u+this.epsilon),e=(0,n.On)(l,c,-1);s[r]=(0,n.On)(l,e,t),s[a]=(0,n.On)(c,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,n.kO)(e,l.dimension,40);let o=this.lambda;await this.initDistance(t);for(let r=0;r<this.cycles;++r){const r=(0,i.I)(e),a=s[r];for(let i=0;i<e;++i){if(r==i)continue;const e=s[i],l=this.calcDistance(t,r,i),c=(0,n.dP)(a,e);if(0==this.cutoff||l<=this.cutoff||c<l){const t=o*(l-c)/(c+this.epsilon),r=(0,n.On)(a,e,-1);s[i]=(0,n.On)(e,r,-t)}}if(o-=this.dlambda,o<=0)break}return s}}class c 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,n.kO)(e,c.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,i.I)(e);let n=(0,i.I)(e);for(;s==n;)n=(0,i.I)(e);const o=this.calcDistance(t,s,n);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,i.I)(e);let l=(0,i.I)(e);for(;a==l;)l=(0,i.I)(e);const c=s[a],h=s[l],u=this.calcDistance(t,a,l),m=(0,n.dP)(c,h);if(u<=r||m<u){const t=.5*o*(u-m)/(m+this.epsilon),e=(0,n.On)(c,h,-1);s[a]=(0,n.On)(c,e,t),s[l]=(0,n.On)(h,e,-t)}}if(o-=(this.lambda-this.dlambda)/(this.cycles-1),o<this.dlambda)break}return s}}},1040:(t,e,s)=>{"use strict";var n,i,o,r,a,l;s.d(e,{CF:()=>i,Qe:()=>a,W:()=>n,Yc:()=>l,gd:()=>r,gk:()=>o}),function(t){t.Levenshtein="Levenshtein",t.JaroWinkler="Jaro-Winkler",t.Manhattan="Manhattan"}(n||(n={})),function(t){t.Euclidean="Euclidean"}(i||(i={})),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.Difference="Difference"}(l||(l={}))},6361:(t,e,s)=>{"use strict";s.d(e,{W:()=>n.W,gk:()=>n.gk});var n=s(1040);s(7861)},7861:(t,e,s)=>{"use strict";var n=s(1811),i=s(3979),o=s(5697),r=s(850),a=s(489),l=s(1040);const c={[l.CF.Euclidean]:r.dP},h={[l.W.Levenshtein]:n.T,[l.W.JaroWinkler]:i.H$,[l.W.Manhattan]:function(t,e){if(t.length!==e.length)return 1;{let s=0;for(let n=1;n<t.length;n++)s+=t[n]==e[n]?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.Difference]:o.bX},p={[l.Qe.Vector]:{[l.CF.Euclidean]:c[l.CF.Euclidean]},[l.Qe.String]:{[l.W.Levenshtein]:h[l.W.Levenshtein],[l.W.JaroWinkler]:h[l.W.JaroWinkler],[l.W.Manhattan]:h[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.Difference]:d[l.Yc.Difference]},[l.Qe.IntArray]:{[l.gd.TanimotoIntArray]:m[l.gd.TanimotoIntArray]}};Object.keys(p).reduce(((t,e)=>{for(const s of Object.keys(p[e]))t[s]=e;return t}),{})},6490:(t,e,s)=>{"use strict";s.d(e,{M6:()=>o,SB:()=>l,Sr:()=>a,VA:()=>i,XV:()=>r,oi:()=>c,w5:()=>u});var n=s(9533);function i(t,e){const s=s=>n.cS(t).map((()=>n.VI(e,s))),i=[];return i.push(s(-1)),i.push(s(1/0)),i.push(s(0)),i}function o(t,e,s){const i=n.ll(t);for(let o=0;o<t;o++){let t=!0,r=0;for(;t;){r=n.AH(e,s);let a=!1;for(let t=0;t<o;t++)if(r===i[t]){a=!0;break}a||(t=!1)}i[o]=r}return i}function r(t,e,s,n,i){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(n===o[t])return 0;return a(t,e,s,n,i)}function a(t,e,s,n,i){const o=t[0][e],r=t[1][e],a=t[2][e];if(s>=r[0])return 0;r[0]=s,o[0]=n,a[0]=i;let l=0,c=0;for(;;){const e=2*l+1,n=e+1,i=t[0][0].length;if(e>=i)break;if(n>=i){if(!(r[e]>s))break;c=e}else if(r[e]>=r[n]){if(!(s<r[e]))break;c=e}else{if(!(s<r[n]))break;c=n}r[l]=r[c],o[l]=o[c],a[l]=a[c],l=c}return r[l]=s,o[l]=n,a[l]=i,1}function l(t,e,s,o,a){const l=i(e,o);for(let i=0;i<e;i++)for(let e=0;e<s;e++){if(t[0][i][e]<0)continue;const s=t[0][i][e],o=t[2][i][e],c=n.mH(a);r(l,i,c,s,o),r(l,s,c,i,o),t[2][i][e]=0}return l}function c(t){const e=t[0],s=t[1];for(let t=0;t<e.length;t++){const n=e[t],i=s[t];for(let t=0;t<n.length-1;t++){const e=n.length-t-1,s=i.length-t-1,o=n[0];n[0]=n[e],n[e]=o;const r=i[0];i[0]=i[s],i[s]=r,h(i,n,s,0)}}return{indices:e,weights:s}}function h(t,e,s,n){for(;2*n+1<s;){const i=2*n+1,o=i+1;let r=n;if(t[r]<t[i]&&(r=i),o<s&&t[r]<t[o]&&(r=o),r===n)break;{const s=t[n];t[n]=t[r],t[r]=s;const i=e[n];e[n]=e[r],e[r]=i,n=r}}}function u(t,e){const s=t[0][e],n=t[1][e],i=t[2][e];let o=1/0,r=-1;for(let t=0;t>s.length;t++)1===i[t]&&n[t]<o&&(o=n[t],r=t);return r>=0?(i[r]=0,Math.floor(s[r])):-1}},1729:(t,e,s)=>{"use strict";s.d(e,{u:()=>n.uB});var n=s(3585)},6802:(t,e,s)=>{"use strict";s.d(e,{$X:()=>l,A7:()=>i,Fv:()=>m,Hp:()=>g,IH:()=>a,NT:()=>r,RH:()=>u,cf:()=>h,gW:()=>c,p4:()=>o});var n=s(9533);class i{constructor(t,e,s,n){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=n[0],this.nCols=n[1];for(let n=0;n<s.length;n++){const i=t[n],o=e[n];this.checkDims(i,o);const r=this.makeKey(i,o);this.entries.set(r,{value:s[n],row:i,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 n=this.makeKey(t,e);this.entries.has(n)?this.entries.get(n).value=s:this.entries.set(n,{value:s,row:t,col:e})}get(t,e,s=0){const n=this.makeKey(t,e);return this.entries.has(n)?this.entries.get(n).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((n=>{e[s++]=t(n.value,n.row,n.col)}));const n=[this.nRows,this.nCols];return new i(this.getRows(),this.getCols(),e,n)}toArray(){const t=n.cS(this.nRows).map((()=>n.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(),n=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(n);const c=[t.nCols,t.nRows];return new i(a,r,l,c)}function r(t,e){return p(t,e,((t,e)=>t*e))}function a(t,e){return p(t,e,((t,e)=>t+e))}function l(t,e){return p(t,e,((t,e)=>t-e))}function c(t,e){return p(t,e,((t,e)=>t>e?t:e))}function h(t,e){return t.map((t=>t*e))}function u(t){const e=new Set,s=t.getValues(),n=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=n.filter(r),c=o.filter(r);return new i(l,c,a,t.getDims())}function m(t,e="l2"){const s=d[e],n=new Map;t.forEach(((t,e,s)=>{const i=n.get(e)||[];i.push(s),n.set(e,i)}));const o=new i([],[],[],t.getDims());for(let e of n.keys()){const i=n.get(e).sort(),r=s(i.map((s=>t.get(e,s))));for(let t=0;t<r.length;t++)o.set(e,i[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 p(t,e,s){const n=new Set,o=[],r=[],a=[],l=(n,i)=>{o.push(n),r.push(i);const l=s(t.get(n,i),e.get(n,i));a.push(l)},c=t.getValues(),h=t.getRows(),u=t.getCols();for(let t=0;t<c.length;t++){const e=h[t],s=u[t],i=`${e}:${s}`;n.add(i),l(e,s)}const m=e.getValues(),d=e.getRows(),p=e.getCols();for(let t=0;t<m.length;t++){const e=d[t],s=p[t],i=`${e}:${s}`;n.has(i)||l(e,s)}const g=[t.nRows,t.nCols];return new i(o,r,a,g)}function g(t){const e=[];t.forEach(((t,s,n)=>{e.push({value:t,row:s,col:n})})),e.sort(((t,e)=>t.row===e.row?t.col-e.col:t.row-e.row));const s=[],n=[],i=[];let o=-1;for(let t=0;t<e.length;t++){const{row:r,col:a,value:l}=e[t];r!==o&&(o=r,i.push(t)),s.push(a),n.push(l)}return{indices:s,values:n,indptr:i}}},1595:(t,e,s)=>{"use strict";s.d(e,{WX:()=>a,gK:()=>h,n_:()=>c,vF:()=>l});var n=s(6490),i=s(6802),o=s(4972),r=s(9533);function a(t,e){return function(s,i,o,a=10,l=50,c=.001,h=.5,u=!0){const m=s.length,d=n.VA(s.length,o);for(let i=0;i<s.length;i++){const r=n.M6(o,s.length,e);for(let e=0;e<r.length;e++){const o=t(s[i],s[r[e]]);n.XV(d,i,o,r[e],1),n.XV(d,r[e],o,i,1)}}if(u)for(let e=0;e<i.length;e++)for(let o=0;o<i[e].length&&!(i[e][o]<0);o++)for(let r=o+1;r<i[e].length&&!(i[e][r]<0);r++){const a=t(s[i[e][o]],s[i[e][r]]);n.XV(d,i[e][o],a,i[e][r],1),n.XV(d,i[e][r],a,i[e][o],1)}for(let i=0;i<a;i++){const i=n.SB(d,m,o,l,e);let a=0;for(let o=0;o<m;o++)for(let c=0;c<l;c++){let u=Math.floor(i[0][o][c]);if(!(u<0||r.mH(e)<h))for(let e=0;e<l;e++){const r=Math.floor(i[0][o][e]),l=i[2][o][c],h=i[2][o][e];if(r<0||!l&&!h)continue;const m=t(s[u],s[r]);a+=n.XV(d,u,m,r,1),a+=n.XV(d,r,m,u,1)}}if(a<=c*o*s.length)break}return n.oi(d)}}function l(t){return{initFromRandom:function(e,s,i,o,a){for(let l=0;l<i.length;l++){const c=r.M6(e,s.length,a);for(let e=0;e<c.length;e++){if(c[e]<0)continue;const r=t(s[c[e]],i[l]);n.XV(o,l,r,c[e],1)}}},initFromTree:function(e,s,i,r,a){for(let l=0;l<i.length;l++){const c=o.ii(i[l],e,a);for(let e=0;e<c.length;e++){if(c[e]<0)return;const o=t(s[c[e]],i[l]);n.XV(r,l,o,c[e],1)}}}}}function c(t){return function(e,s,o,r){const{indices:a,indptr:l}=i.Hp(s);for(let s=0;s<r.length;s++){const i=new Set(o[0][s]);for(;;){const c=n.w5(o,s);if(-1===c)break;const h=a.slice(l[c],l[c+1]);for(const a of h){if(a===c||-1===a||i.has(a))continue;const l=t(e[a],r[s]);n.Sr(o,s,l,a,1),i.add(a)}}}return o}}function h(t,e,s,i,o,r,a){const l=n.VA(s.length,i);if(o(i,e,s,l,a),t)for(let n of t)r(n,e,s,l,a);return l}},4972:(t,e,s)=>{"use strict";s.d(e,{HO:()=>h,Zv:()=>o,ii:()=>m});var n=s(9533);class i{constructor(t,e,s,n){this.hyperplanes=t,this.offsets=e,this.children=s,this.indices=n}}function o(t,e,s,o){const h=Math.max(10,e),u=n.w6(s).map(((e,s)=>function(t,e=30,s,i){return r(t,n.w6(t.length),e,s,i)}(t,h,s,o))),m=u.map((t=>function(t,e){const s=l(t),o=c(t),r=n.w6(s).map((()=>t.hyperplane?1:0)),h=n.ll(s),u=n.w6(s).map((()=>[-1,-1])),m=n.w6(o).map((()=>n.w6(e).map((()=>-1))));return a(t,r,h,u,m,0,0),new i(r,h,u,m)}(t,h)));return m}function r(t,e,s=30,i,o){if(e.length>s){const a=function(t,e,s){let i=n.AH(e.length,s),o=n.AH(e.length,s);o+=i===o?1:0,o%=e.length;const r=e[i],a=e[o];let l=0,c=0;c=t[r]-t[a],l-=c*(t[r]+t[a])/2;let h=0,u=0;const m=n.ll(e.length);for(let i=0;i<e.length;i++){let o=l;o+=c*t[e[i]],0===o?(m[i]=n.AH(2,s),0===m[i]?h+=1:u+=1):o>0?(m[i]=0,h+=1):(m[i]=1,u+=1)}const d=n.ll(h),p=n.ll(u);h=0,u=0;for(let t=0;t<m.length;t++)0===m[t]?(d[h]=e[t],h+=1):(p[u]=e[t],u+=1);return{indicesLeft:d,indicesRight:p,hyperplane:c,offset:l}}(t,e,o),{indicesLeft:l,indicesRight:c,hyperplane:h,offset:u}=a;return{leftChild:r(t,l,s,i+1,o),rightChild:r(t,c,s,i+1,o),isLeaf:!1,hyperplane:h,offset:u}}return{indices:e,isLeaf:!0}}function a(t,e,s,n,i,o,r){if(t.isLeaf)return n[o][0]=-r,i[r].splice(0,t.indices.length,...t.indices),{nodeNum:o,leafNum:r+=1};{e[o]=t.hyperplane,s[o]=t.offset,n[o][0]=o+1;const l=o;let c=a(t.leftChild,e,s,n,i,o+1,r);return o=c.nodeNum,r=c.leafNum,n[l][1]=o+1,c=a(t.rightChild,e,s,n,i,o+1,r),{nodeNum:c.nodeNum,leafNum:c.leafNum}}}function l(t){return t.isLeaf?1:1+l(t.leftChild)+l(t.rightChild)}function c(t){return t.isLeaf?1:c(t.leftChild)+c(t.rightChild)}function h(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,i){let o=e;return o+=t*s,0===o?n.AH(2,i):o>0?0:1}function m(t,e,s){let n=0;for(;e.children[n][0]>0;)n=0===u(e.hyperplanes[n],e.offsets[n],t,s)?e.children[n][0]:e.children[n][1];const i=-1*e.children[n][0];return e.indices[i]}},3585:(t,e,s)=>{"use strict";s.d(e,{uB:()=>u});var n=s(6490),i=s(6802),o=s(1595),r=s(4972),a=s(9533),l=s(3107);const c=1e-5,h=.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:n}=this.initializeSimplicialSetEmbedding();return this.optimizationState.head=e,this.optimizationState.tail=s,this.optimizationState.epochsPerSample=n,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,n=[t.length,t.length],o=new i.A7([],[],[],n);for(let t=0;t<e.length;t++){const n=e[t],i=s[t];for(let e=0;e<n.length;e++){const s=n[e],r=i[e];r>0&&o.set(t,s,r)}}const r=i.p4(o);return i.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:c,weights:h}=n.oi(l);c=c.map((t=>t.slice(0,this.nNeighbors))),h=h.map((t=>t.slice(0,this.nNeighbors)));const u=Math.max(0,this.localConnectivity-1),{sigmas:m,rhos:d}=this.smoothKNNDistance(h,this.nNeighbors,u),{rows:p,cols:g,vals:f}=this.computeMembershipStrengths(c,h,m,d),y=[t.length,e.length];let w=new i.A7(p,g,f,y);const C=i.Fv(w,"l1"),T=i.Hp(C),b=t.length,A=function(t,e,s){const n=a.ll(t.length).map((t=>a.ll(s[0].length)));for(let i=0;i<t.length;i++)for(let o=0;o<t[0].length;o++)for(let r=0;r<s[0].length;r++){const a=t[i][o];n[i][r]+=e[i][o]*s[a][r]}return n}(a.HU(T.indices,b,this.nNeighbors),a.HU(T.values,b,this.nNeighbors),this.embedding),S=this.nEpochs?this.nEpochs/3:w.nRows<=1e4?100:30,E=w.getValues().reduce(((t,e)=>e>t?e:t),0);w=w.map((t=>t<E/S?0:t)),w=i.RH(w);const M=this.makeEpochsPerSample(w.getValues(),S),v=w.getRows(),N=w.getCols();return this.assignOptimizationStateParameters({headEmbedding:A,tailEmbedding:this.embedding,head:v,tail:N,currentEpoch:0,nEpochs:S,nVertices:w.getDims()[1],epochsPerSample:M}),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,n=o.WX(e,this.random),i=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,i,this.random);const c=r.HO(this.rpForest),{indices:h,weights:u}=n(t,c,s,l);return{knnIndices:h,knnDistances:u}}fuzzySimplicialSet(t,e,s=1){const{knnIndices:n=[],knnDistances:o=[],localConnectivity:r}=this,{sigmas:a,rhos:l}=this.smoothKNNDistance(o,e,r),{rows:c,cols:h,vals:u}=this.computeMembershipStrengths(n,o,a,l),m=[t.length,t.length],d=new i.A7(c,h,u,m),p=i.p4(d),g=i.NT(d,p),f=i.$X(i.IH(d,p),g),y=i.cf(f,s),w=i.cf(g,1-s);return i.IH(y,w)}categoricalSimplicialSetIntersection(t,e,s,n=1){let o=function(t,e,s=1,n=5){return t.map(((t,i,o)=>-1===e[i]||-1===e[o]?t*Math.exp(-s):e[i]!==e[o]?t*Math.exp(-n):t))}(t,e,n,s);return o=i.RH(o),function(t){t=i.Fv(t,"max");const e=i.p4(t),s=i.NT(e,t);return t=i.IH(t,i.$X(e,s)),i.RH(t)}(o)}smoothKNNDistance(t,e,s=1,n=64,i=1){const o=Math.log(e)/Math.log(2)*i,r=a.ll(t.length),l=a.ll(t.length);for(let e=0;e<t.length;e++){let i=0,u=1/0,m=1;const d=t[e],p=d.filter((t=>t>0));if(p.length>=s){let t=Math.floor(s),n=s-t;t>0?(r[e]=p[t-1],n>c&&(r[e]+=n*(p[t]-p[t-1]))):r[e]=n*p[0]}else p.length>0&&(r[e]=a.Fp(p));for(let s=0;s<n;s++){let s=0;for(let n=1;n<t[e].length;n++){const i=t[e][n]-r[e];s+=i>0?Math.exp(-i/m):1}if(Math.abs(s-o)<c)break;s>o?(u=m,m=(i+u)/2):(i=m,u===1/0?m*=2:m=(i+u)/2)}if(l[e]=m,r[e]>0){const t=a.J6(d);l[e]<h*t&&(l[e]=h*t)}else{const s=a.J6(t.map(a.J6));l[e]<h*s&&(l[e]=h*s)}}return{sigmas:l,rhos:r}}computeMembershipStrengths(t,e,s,n){const i=t.length,o=t[0].length,r=a.ll(i*o),l=a.ll(i*o),c=a.ll(i*o);for(let a=0;a<i;a++)for(let i=0;i<o;i++){let h=0;-1!==t[a][i]&&(h=t[a][i]===a?0:e[a][i]-n[a]<=0?1:Math.exp(-(e[a][i]-n[a])/s[a]),r[a*o+i]=a,l[a*o+i]=t[a][i],c[a*o+i]=h)}return{rows:r,cols:l,vals:c}}initializeSimplicialSetEmbedding(){const t=this.getNEpochs(),{nComponents:e}=this,s=this.graph.getValues();let n=0;for(let t=0;t<s.length;t++){const e=s[t];n<s[t]&&(n=e)}const i=this.graph.map((e=>e<n/t?0:e));this.embedding=a.ll(i.nRows).map((()=>a.ll(e).map((()=>20*a.mH(this.random)-10))));const o=[],r=[],l=[],c=i.getAll();for(let t=0;t<c.length;t++){const e=c[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),n=a.Fp(t),i=t.map((t=>t/n*e));return i.forEach(((t,n)=>{t>0&&(s[n]=e/i[n])})),s}assignOptimizationStateParameters(t){Object.assign(this.optimizationState,t)}prepareForOptimizationLoop(){const{repulsionStrength:t,learningRate:e,negativeSampleRate:s}=this,{epochsPerSample:n,headEmbedding:i,tailEmbedding:o}=this.optimizationState,r=i[0].length,a=i.length===o.length,l=n.map((t=>t/s)),c=[...l],h=[...n];this.assignOptimizationStateParameters({epochOfNextSample:h,epochOfNextNegativeSample:c,epochsPerNegativeSample:l,moveOther:a,initialAlpha:e,alpha:e,gamma:t,dim:r})}initializeOptimization(){const t=this.embedding,e=this.embedding,{head:s,tail:n,epochsPerSample:i}=this.optimizationState,o=this.getNEpochs(),r=this.graph.nCols,{a:c,b:h}=function(t,e){const s=a.GE(0,3*t,300).map((t=>t<e?1:t)),n=a.ll(s.length).map(((n,i)=>s[i]>=e?Math.exp(-(s[i]-e)/t):n)),i={x:s,y:n},{parameterValues:o}=(0,l.Z)(i,(([t,e])=>s=>1/(1+t*s**(2*e))),{damping:1.5,initialValues:[.5,.5],gradientDifference:.1,maxIterations:100,errorTolerance:.01}),[r,c]=o;return{a:r,b:c}}(this.spread,this.minDist);this.assignOptimizationStateParameters({headEmbedding:t,tailEmbedding:e,head:s,tail:n,epochsPerSample:i,a:c,b:h,nEpochs:o,nVertices:r})}optimizeLayoutStep(t){const{optimizationState:e}=this,{head:s,tail:n,headEmbedding:i,tailEmbedding:o,epochsPerSample:r,epochOfNextSample:l,epochOfNextNegativeSample:c,epochsPerNegativeSample:h,moveOther:u,initialAlpha:m,alpha:d,gamma:f,a:y,b:w,dim:C,nEpochs:T,nVertices:b}=e;for(let e=0;e<r.length;e++){if(l[e]>t)continue;const m=s[e],T=n[e],A=i[m],S=o[T],E=g(A,S);let M=0;E>0&&(M=-2*y*w*Math.pow(E,w-1),M/=y*Math.pow(E,w)+1);for(let t=0;t<C;t++){const e=p(M*(A[t]-S[t]),4);A[t]+=e*d,u&&(S[t]+=-e*d)}l[e]+=r[e];const v=Math.floor((t-c[e])/h[e]);for(let t=0;t<v;t++){const t=a.AH(b,this.random),e=o[t],s=g(A,e);let n=0;if(s>0)n=2*f*w,n/=(.001+s)*(y*Math.pow(s,w)+1);else if(m===t)continue;for(let t=0;t<C;t++){let s=4;n>0&&(s=p(n*(A[t]-e[t]),4)),A[t]+=s*d}}c[e]+=v*h[e]}return e.alpha=m*(1-t/T),e.currentEpoch+=1,i}optimizeLayoutAsync(t=(()=>!0)){return new Promise(((e,s)=>{const n=async()=>{try{const{nEpochs:s,currentEpoch:i}=this.optimizationState;this.embedding=this.optimizeLayoutStep(i);const o=this.optimizationState.currentEpoch,r=!1===t(o),a=o===s;if(r||a)return e(a);setTimeout((()=>n()),0)}catch(t){s(t)}};setTimeout((()=>n()),0)}))}optimizeLayout(t=(()=>!0)){let e=!1,s=[];for(;!e;){const{nEpochs:n,currentEpoch:i}=this.optimizationState;s=this.optimizeLayoutStep(i);const o=this.optimizationState.currentEpoch,r=!1===t(o);e=o===n||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 p(t,e){return t>e?e:t<-e?-e:t}function g(t,e){let s=0;for(let n=0;n<t.length;n++)s+=Math.pow(t[n]-e[n],2);return s}},9533:(t,e,s)=>{"use strict";function n(t,e){return Math.floor(e()*t)}function i(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 c(t,e,s){return o(s).map(((n,i)=>t+i*((e-t)/(s-1))))}function h(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 i=l(t);for(let o=0;o<t;o++){let t=!0;for(;t;){const r=n(e,s);let a=!1;for(let t=0;t<o;t++)if(r===i[t]){a=!0;break}a||(t=!1),i[o]=r}}return i}function d(t,e,s){const n=[];let i=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 n=0;n<s;n++)e.push(t[o]),o+=1;n.push(e),i+=1}return n}s.d(e,{AH:()=>n,Fp:()=>u,GE:()=>c,HU:()=>d,J6:()=>h,M6:()=>m,VI:()=>a,cS:()=>o,ll:()=>l,mH:()=>i,w6:()=>r})},9657:(t,e,s)=>{"use strict";s.d(e,{Z:()=>n});class n{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,i=n._createBuffer(s);if(e)for(let t=0;t<i.length;t++)i[t]=-1;this._data=i,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,n){if(t<e||t>s)throw new Error(`Argument ${n} (${t}) out of range (${e}, ${s})`)}copy(t,e,s){for(let n=0;n<s;n++)e[n]=t[n]}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 n(t._length);s._length=t._length,s._data=n._createBuffer(s._length),s._version=0;const i=t.lengthInInts;for(let n=0;n<i;n++)s._data[n]=t._data[n]&e._data[n];return s}static _createBuffer(t){return new Uint32Array(Math.floor((t+31)/32))}static fromValues(t){const e=new n(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 n(t);for(let n=0;n<t;++n)s.setBit(n,e(n));return s._version=0,s}static fromString(t){return n.fromSeq(t.length,(e=>"1"==t.charAt(e)))}static fromUint32Array(t,e){const s=new n(t);return s._data=e,s}static fromBytes(t){const e=t.length,s=new n(8*e);s._data=new Uint32Array(Math.floor((e+3)/4)),s._length=8*e;let i=0,o=0;for(;e-o>=4;)s._data[i++]=255&t[o]|(255&t[o+1])<<8|(255&t[o+2])<<16|(255&t[o+3])<<24,o+=4;return e-o==3&&(s._data[i]=(255&t[o+2])<<16),e-o==2&&(s._data[i]|=(255&t[o+1])<<8),e-o==1&&(s._data[i]|=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 n(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,n=this.lengthInInts;for(let t=0;t<n;t++)this._data[t]=s;this.incrementVersion(e)}setIndexes(t,e=!0,s=!0,n=!0){s&&this.setAll(!e,!1);for(const s of t)this.setFast(s,e);this.incrementVersion(n)}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,n=!0,i=!0){if(s&&i&&this.setAll(!e,!1),i)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(n)}getRange(t,e){this.assureInRange(t,0,this._length-1,"from"),this.assureInRange(e,0,this._length,"to");const s=[];for(let n=t;n<e;++n)s.push(this.getBit(n));return n.fromValues(s)}getRangeAsList(t,e){this.assureInRange(t,0,this._length-1,"from"),this.assureInRange(e,0,this._length,"to");const s=[];for(let n=t;n<e;++n)s.push(this.getBit(n));return s}setRange(t,e,s,n=!0){this.assureInRange(t,0,this._length-1,"from"),this.assureInRange(e,0,this._length-1,"to");const i=Math.min(t,e),o=Math.max(t,e);if(s)for(let t=i;t<=o;t++)this.setTrue(t);else for(let t=i;t<=o;t++)this.setFalse(t);return this.incrementVersion(n),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 n=this._length;this.setLength(this._length+e);for(let s=n-1;s>=t;s--)this.setBit(s+e,this.getBit(s));for(let n=t;n<t+e;n++)this.setBit(n,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 n=-1;-1!=(n=t.findNext(n,!e));)this.setFast(s++,this.getBit(n));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+=n._onBitCount[255&t];let s=this._data[e];const i=31&this._length;for(0!=i&&(s&=~(4294967295<<i));0!=s;s>>>=8)this._selectedCount+=n._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 i=this.lengthInInts;let o=0;for(;o<i-1;o++)for(let e=this._data[o]&t._data[o];0!=e;e>>>=8)s+=n._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+=n._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 i=this.lengthInInts;for(let o=Math.floor(t/32);o<i;o++){let i=e?this._data[o]:~this._data[o];if(0!=s)i&=4294967295<<s&4294967295,s=0;else if(!e&&-4294967296==i)continue;for(let e=0;0!=i;e+=8,i>>>=8){const s=n._firstOnBit[255&i];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 i=Math.floor(t/32);i>=0;i--){let t=e?this._data[i]:~this._data[i];0!=s&&(t&=~(4294967295<<s),s=0);for(let e=24;0!=t;e-=8,t<<=8){const s=n._lastOnBit[t>>>24];if(s>=0)return s+32*i+e}}return-1}}n._onBitCount=Int8Array.from([0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,4,5,5,6,5,6,6,7,5,6,6,7,6,7,7,8]),n._firstOnBit=Int8Array.from([-1,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,7,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0]),n._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 n(t){return Math.random()*t}function i(t){return Math.floor(n(t))}s.d(e,{I:()=>i,t:()=>n})},8518:(t,e,s)=>{"use strict";s.d(e,{L:()=>i});var n=s(4588);function i(t,e,s){function i(t,e){let s=null,n=null;for(const i of t){const t=e(i);(null==n||t>n)&&(s=i,n=t)}return s}const o=[(0,n.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=i(r.values(),(t=>Math.min.apply(Math,o.map((function(e,n){return s(t,e)})))));null!=t&&(o.push(t),r.delete(t))}return o}},8467:(t,e,s)=>{"use strict";s.d(e,{X5:()=>w,ow:()=>T,bb:()=>y,W3:()=>f,gw:()=>C,l_:()=>m,f6:()=>g,jh:()=>d,Wh:()=>p,Bu:()=>u,zg:()=>h,AB:()=>A});var n=s(4469),i=s(976);s(9133),i.DataFrame.fromCsv('countries,fasta,smiles,molregno,LON,Zip Code,Street Address Line 1,ImageUrl,user_id,error_message,xray,flag,magnitude,CS-id,pdb_id,accel_a,time_offset,chart,fit,Questions,empty_number,empty_string\nBelgium,MSNFHNEHVMQFYRNNLKTKGVFGRQ,CC(C(=O)OCCCc1cccnc1)c2cccc(c2)C(=O)c3ccccc3,1480014,36.276729583740234,995042300,14016 ROUTE 31W,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,COMPND ATOM END,flag,1,1,1QBS,1,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[2.497360340644872, 1.7058694986686864, 5.278052678195135, 0.16000320889028383],""points"":[{""x"":0.10000000149011612,""y"":2.374499797821045},{""x"":0.6000000238418579,""y"":2.6242473125457764},{""x"":1.100000023841858,""y"":2.367267608642578},{""x"":1.600000023841858,""y"":2.6723148822784424},{""x"":2.0999999046325684,""y"":2.6537344455718994},{""x"":2.5999999046325684,""y"":2.3651671409606934},{""x"":3.0999999046325684,""y"":2.5654284954071045},{""x"":3.5999999046325684,""y"":2.4160959720611572},{""x"":4.099999904632568,""y"":2.286726713180542},{""x"":4.599999904632568,""y"":2.5100042819976807},{""x"":5.099999904632568,""y"":1.6676985025405884},{""x"":5.599999904632568,""y"":0.680136501789093},{""x"":6.099999904632568,""y"":0.3391543924808502},{""x"":6.599999904632568,""y"":0.09038983285427094},{""x"":7.099999904632568,""y"":0.19802775979042053}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[7.525235855508179, 1.3186911876809984, 5.335672608564294, 0.7860743343958098],""points"":[{""x"":0.10000000149011612,""y"":7.988070487976074},{""x"":0.6000000238418579,""y"":7.018453121185303},{""x"":1.100000023841858,""y"":8.115279197692871},{""x"":1.600000023841858,""y"":7.486658096313477},{""x"":2.0999999046325684,""y"":7.396438121795654},{""x"":2.5999999046325684,""y"":7.477052211761475},{""x"":3.0999999046325684,""y"":6.913095474243164},{""x"":3.5999999046325684,""y"":8.01385498046875},{""x"":4.099999904632568,""y"":6.985900402069092},{""x"":4.599999904632568,""y"":6.970335960388184},{""x"":5.099999904632568,""y"":5.448817253112793},{""x"":5.599999904632568,""y"":2.5534818172454834},{""x"":6.099999904632568,""y"":1.893947958946228},{""x"":6.599999904632568,""y"":0.6340042352676392},{""x"":7.099999904632568,""y"":0.8403874039649963}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,100,abc\nBurundi,MDYKETLLMPKTDFPMRGGLPNKEPQIQEKW,COc1ccc2cc(ccc2c1)C(C)C(=O)Oc3ccc(C)cc3OC,1480015,36.276729583740234,995073444,80 STATE HIGHWAY 310,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,COMPND ATOM END,flag,2,2,1ZP8,2,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[4.431460753103398, 2.1691498799246745, 5.266445597102774, 0.7825762827017926],""points"":[{""x"":0.10000000149011612,""y"":4.751083850860596},{""x"":0.6000000238418579,""y"":4.203000068664551},{""x"":1.100000023841858,""y"":4.415858745574951},{""x"":1.600000023841858,""y"":4.68414306640625},{""x"":2.0999999046325684,""y"":4.198400974273682},{""x"":2.5999999046325684,""y"":4.179222106933594},{""x"":3.0999999046325684,""y"":4.638473987579346},{""x"":3.5999999046325684,""y"":4.708553314208984},{""x"":4.099999904632568,""y"":4.291589260101318},{""x"":4.599999904632568,""y"":4.038082599639893},{""x"":5.099999904632568,""y"":3.4349939823150635},{""x"":5.599999904632568,""y"":1.2194708585739136},{""x"":6.099999904632568,""y"":1.1920831203460693},{""x"":6.599999904632568,""y"":0.5352635979652405},{""x"":7.099999904632568,""y"":0.3346920311450958}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[2.339458017970126, -1.0734184310171178, 4.746332950550934, 0.2482416857595658],""points"":[{""x"":0.10000000149011612,""y"":0.2139337658882141},{""x"":0.6000000238418579,""y"":0.4269562065601349},{""x"":1.100000023841858,""y"":0.2441573292016983},{""x"":1.600000023841858,""y"":0.146635964512825},{""x"":2.0999999046325684,""y"":0.08818462491035461},{""x"":2.5999999046325684,""y"":0.2560656666755676},{""x"":3.0999999046325684,""y"":0.42434045672416687},{""x"":3.5999999046325684,""y"":0.37111231684684753},{""x"":4.099999904632568,""y"":0.5581737160682678},{""x"":4.599999904632568,""y"":1.183590054512024},{""x"":5.099999904632568,""y"":1.5629843473434448},{""x"":5.599999904632568,""y"":2.3211288452148438},{""x"":6.099999904632568,""y"":2.229961633682251},{""x"":6.599999904632568,""y"":2.2560226917266846},{""x"":7.099999904632568,""y"":2.2142398357391357}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCameroon,MIEVFLFGIVLGLIPITLAGLFVTAYLQYRRGDQLDL,COc1ccc2cc(ccc2c1)C(C)C(=O)OCCCc3cccnc3,1480016,36.26095962524414,995153596,30-56 WHITESTONE EXPY,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,COMPND ATOM END,flag,3,3,2BDJ,3,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[4.6760652578642325, 0.9046956320756703, 5.651408971856738, 0.07738846012184185],""points"":[{""x"":0.10000000149011612,""y"":4.32425594329834},{""x"":0.6000000238418579,""y"":4.668442249298096},{""x"":1.100000023841858,""y"":4.379785060882568},{""x"":1.600000023841858,""y"":5.0345139503479},{""x"":2.0999999046325684,""y"":4.878653526306152},{""x"":2.5999999046325684,""y"":4.3451313972473145},{""x"":3.0999999046325684,""y"":4.336992263793945},{""x"":3.5999999046325684,""y"":5.037430286407471},{""x"":4.099999904632568,""y"":5.0092692375183105},{""x"":4.599999904632568,""y"":4.151902675628662},{""x"":5.099999904632568,""y"":3.4066951274871826},{""x"":5.599999904632568,""y"":2.3732759952545166},{""x"":6.099999904632568,""y"":1.673728108406067},{""x"":6.599999904632568,""y"":0.48574790358543396},{""x"":7.099999904632568,""y"":0.2783052325248718}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[2.938395863010111, -1.4658480661392117, 5.462702751996584, 0.3473139023615039],""points"":[{""x"":0.10000000149011612,""y"":0.4941710829734802},{""x"":0.6000000238418579,""y"":0.15323974192142487},{""x"":1.100000023841858,""y"":0.46373432874679565},{""x"":1.600000023841858,""y"":0.3370431363582611},{""x"":2.0999999046325684,""y"":0.5179030299186707},{""x"":2.5999999046325684,""y"":0.27899765968322754},{""x"":3.0999999046325684,""y"":0.22075064480304718},{""x"":3.5999999046325684,""y"":0.5789918899536133},{""x"":4.099999904632568,""y"":0.21169911324977875},{""x"":4.599999904632568,""y"":0.27857646346092224},{""x"":5.099999904632568,""y"":1.0906332731246948},{""x"":5.599999904632568,""y"":1.8520300388336182},{""x"":6.099999904632568,""y"":2.7177059650421143},{""x"":6.599999904632568,""y"":2.8680918216705322},{""x"":7.099999904632568,""y"":3.2413077354431152}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCanada,MMELVLKTIIGPIVVGVVLRIVDKWLNKDK,CC(C(=O)NCCS)c1cccc(c1)C(=O)c2ccccc2,1480017,36.26095962524414,99515,30-56 WHITESTONE EXPY,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,COMPND ATOM END,flag,4,4,1IAN,4,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[0.8597390975430008, 1.0957625732481946, 5.260537067987958, 0.07974187998177736],""points"":[{""x"":0.10000000149011612,""y"":0.8190152645111084},{""x"":0.6000000238418579,""y"":0.8421689867973328},{""x"":1.100000023841858,""y"":0.8740922212600708},{""x"":1.600000023841858,""y"":0.8924275040626526},{""x"":2.0999999046325684,""y"":0.8249067664146423},{""x"":2.5999999046325684,""y"":0.9327669143676758},{""x"":3.0999999046325684,""y"":0.8522974252700806},{""x"":3.5999999046325684,""y"":0.8174492716789246},{""x"":4.099999904632568,""y"":0.8394647240638733},{""x"":4.599999904632568,""y"":0.7139387726783752},{""x"":5.099999904632568,""y"":0.5561167597770691},{""x"":5.599999904632568,""y"":0.3276226818561554},{""x"":6.099999904632568,""y"":0.12479474395513535},{""x"":6.599999904632568,""y"":0.13006797432899475},{""x"":7.099999904632568,""y"":0.059702079743146896}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.760930219582546, 1.6591793293833013, 4.667155929720851, 0.7858109544121652],""points"":[{""x"":0.10000000149011612,""y"":6.156993389129639},{""x"":0.6000000238418579,""y"":5.236701965332031},{""x"":1.100000023841858,""y"":6.010560512542725},{""x"":1.600000023841858,""y"":5.495512962341309},{""x"":2.0999999046325684,""y"":6.087770462036133},{""x"":2.5999999046325684,""y"":5.79986572265625},{""x"":3.0999999046325684,""y"":5.597546577453613},{""x"":3.5999999046325684,""y"":5.520902156829834},{""x"":4.099999904632568,""y"":5.360654354095459},{""x"":4.599999904632568,""y"":3.5539746284484863},{""x"":5.099999904632568,""y"":1.577236294746399},{""x"":5.599999904632568,""y"":1.0001264810562134},{""x"":6.099999904632568,""y"":0.9305797815322876},{""x"":6.599999904632568,""y"":0.6033638715744019},{""x"":7.099999904632568,""y"":0.4203685522079468}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nColombia,MDRTDEVSNHTHDKPTLTWFEEIFEEYHSPFHN,FC(F)(F)c1ccc(OC2CCNCC2)cc1,1480029,36.3309440612793,995152050,1 COURT HOUSE SQUARE,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,COMPND ATOM END,flag,5,5,4UJ1,5,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[6.4995088314153655, 2.4270351004539914, 5.178659535348579, 0.625653346241577],""points"":[{""x"":0.10000000149011612,""y"":6.496231555938721},{""x"":0.6000000238418579,""y"":6.42543363571167},{""x"":1.100000023841858,""y"":7.040063858032227},{""x"":1.600000023841858,""y"":6.1115403175354},{""x"":2.0999999046325684,""y"":6.680728435516357},{""x"":2.5999999046325684,""y"":6.406774520874023},{""x"":3.0999999046325684,""y"":6.611269474029541},{""x"":3.5999999046325684,""y"":5.889094352722168},{""x"":4.099999904632568,""y"":6.75344705581665},{""x"":4.599999904632568,""y"":6.361435890197754},{""x"":5.099999904632568,""y"":4.1666975021362305},{""x"":5.599999904632568,""y"":1.172118902206421},{""x"":6.099999904632568,""y"":0.801048994064331},{""x"":6.599999904632568,""y"":0.4640021026134491},{""x"":7.099999904632568,""y"":0.0010357667924836278}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[1.4734381347446401, 1.1649805188074196, 4.82958608866421, 0.09500545496710007],""points"":[{""x"":0.10000000149011612,""y"":1.5279096364974976},{""x"":0.6000000238418579,""y"":1.3559974431991577},{""x"":1.100000023841858,""y"":1.5246378183364868},{""x"":1.600000023841858,""y"":1.5567657947540283},{""x"":2.0999999046325684,""y"":1.4114240407943726},{""x"":2.5999999046325684,""y"":1.4045010805130005},{""x"":3.0999999046325684,""y"":1.4769829511642456},{""x"":3.5999999046325684,""y"":1.4875500202178955},{""x"":4.099999904632568,""y"":1.2991987466812134},{""x"":4.599999904632568,""y"":0.922961413860321},{""x"":5.099999904632568,""y"":0.6520044803619385},{""x"":5.599999904632568,""y"":0.15350978076457977},{""x"":6.099999904632568,""y"":0.1078903079032898},{""x"":6.599999904632568,""y"":0.17276449501514435},{""x"":7.099999904632568,""y"":0.14066608250141144}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCosta Rica,MKSTKEEIQTIKTLLKDSRTAKYHKRLQIVL,CC(C)Cc1ccc(cc1)C(C)C(=O)N2CCCC2C(=O)OCCCc3ccccc3,1480018,36.3309440612793,995084218,4041 SOUTHWESTERN BLVD,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,COMPND ATOM END,flag,6,6,2BPW,6,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[2.4833641843311227, -1.8945978742090062, 4.671127708092568, 0.24159861311815153],""points"":[{""x"":0.10000000149011612,""y"":0.0969524160027504},{""x"":0.6000000238418579,""y"":0.028483040630817413},{""x"":1.100000023841858,""y"":0.22087176144123077},{""x"":1.600000023841858,""y"":0.0068915546871721745},{""x"":2.0999999046325684,""y"":0.4305879771709442},{""x"":2.5999999046325684,""y"":0.44774115085601807},{""x"":3.0999999046325684,""y"":0.45346319675445557},{""x"":3.5999999046325684,""y"":0.2370593100786209},{""x"":4.099999904632568,""y"":0.4657953977584839},{""x"":4.599999904632568,""y"":1.155200719833374},{""x"":5.099999904632568,""y"":2.2294070720672607},{""x"":5.599999904632568,""y"":2.4311530590057373},{""x"":6.099999904632568,""y"":2.33846116065979},{""x"":6.599999904632568,""y"":2.608201026916504},{""x"":7.099999904632568,""y"":2.8136143684387207}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.224573521642033, 1.4454033924198528, 5.6014197746076535, 0.2823216054197577],""points"":[{""x"":0.10000000149011612,""y"":4.95027494430542},{""x"":0.6000000238418579,""y"":5.1754679679870605},{""x"":1.100000023841858,""y"":5.276752948760986},{""x"":1.600000023841858,""y"":5.589294910430908},{""x"":2.0999999046325684,""y"":5.616994857788086},{""x"":2.5999999046325684,""y"":5.120813846588135},{""x"":3.0999999046325684,""y"":5.340766906738281},{""x"":3.5999999046325684,""y"":4.876471042633057},{""x"":4.099999904632568,""y"":4.94999361038208},{""x"":4.599999904632568,""y"":5.162564754486084},{""x"":5.099999904632568,""y"":4.399557590484619},{""x"":5.599999904632568,""y"":2.7977969646453857},{""x"":6.099999904632568,""y"":1.0229872465133667},{""x"":6.599999904632568,""y"":0.48275601863861084},{""x"":7.099999904632568,""y"":0.10408931970596313}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCuba,MHAILRYFIRRLFYHIFYKIYSLISKKHQSLPSDVRQF,COc1ccc2c(c1)c(CC(=O)N3CCCC3C(=O)Oc4ccc(C)cc4OC)c(C)n2C(=O)c5ccc(Cl)cc5,1480019,36.33115768432617,995081928,1227 US HIGHWAY 11,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,COMPND ATOM END,flag,7,7,1QBS,7,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[3.320838679713925, -1.2421619987316728, 4.831325425225256, 0.3236011098403072],""points"":[{""x"":0.10000000149011612,""y"":0.3727470338344574},{""x"":0.6000000238418579,""y"":0.12365014106035233},{""x"":1.100000023841858,""y"":0.48422467708587646},{""x"":1.600000023841858,""y"":0.2264465093612671},{""x"":2.0999999046325684,""y"":0.16821794211864471},{""x"":2.5999999046325684,""y"":0.3879014551639557},{""x"":3.0999999046325684,""y"":0.5470244884490967},{""x"":3.5999999046325684,""y"":0.3419053554534912},{""x"":4.099999904632568,""y"":0.7655120491981506},{""x"":4.599999904632568,""y"":1.2346516847610474},{""x"":5.099999904632568,""y"":2.453336715698242},{""x"":5.599999904632568,""y"":2.9565491676330566},{""x"":6.099999904632568,""y"":3.335299491882324},{""x"":6.599999904632568,""y"":3.240290880203247},{""x"":7.099999904632568,""y"":3.1107218265533447}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[3.6401853521511094, 1.26211588875013, 5.399028074402744, 0.5089580830068091],""points"":[{""x"":0.10000000149011612,""y"":3.8585598468780518},{""x"":0.6000000238418579,""y"":3.6077206134796143},{""x"":1.100000023841858,""y"":3.855252265930176},{""x"":1.600000023841858,""y"":3.619039297103882},{""x"":2.0999999046325684,""y"":3.839388370513916},{""x"":2.5999999046325684,""y"":3.335283041000366},{""x"":3.0999999046325684,""y"":3.571141481399536},{""x"":3.5999999046325684,""y"":3.4155046939849854},{""x"":4.099999904632568,""y"":3.7316646575927734},{""x"":4.599999904632568,""y"":3.0680155754089355},{""x"":5.099999904632568,""y"":2.891066551208496},{""x"":5.599999904632568,""y"":1.6022753715515137},{""x"":6.099999904632568,""y"":0.7652576565742493},{""x"":6.599999904632568,""y"":0.6875326037406921},{""x"":7.099999904632568,""y"":0.5828871726989746}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nItaly,MSNFHNEHVMQFYRNNLKTKGVFGRQ,CC(C)Cc1ccc(cc1)C(C)C(=O)N2CCCC2C(=O)OCCO[N+](=O)[O-],1480020,36.33115768432617,99502,"168-46 91ST AVE., 2ND FLR",https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,COMPND ATOM END,flag,8,8,1ZP8,8,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[2.293592105923809, 1.3781586549141835, 5.1025898038676605, 0.03493851245291291],""points"":[{""x"":0.10000000149011612,""y"":2.1287283897399902},{""x"":0.6000000238418579,""y"":2.267972230911255},{""x"":1.100000023841858,""y"":2.398442506790161},{""x"":1.600000023841858,""y"":2.5130622386932373},{""x"":2.0999999046325684,""y"":2.3255116939544678},{""x"":2.5999999046325684,""y"":2.127340793609619},{""x"":3.0999999046325684,""y"":2.47259783744812},{""x"":3.5999999046325684,""y"":2.131181478500366},{""x"":4.099999904632568,""y"":2.090421438217163},{""x"":4.599999904632568,""y"":2.02299165725708},{""x"":5.099999904632568,""y"":1.1105059385299683},{""x"":5.599999904632568,""y"":0.4494485855102539},{""x"":6.099999904632568,""y"":0.1375635862350464},{""x"":6.599999904632568,""y"":0.036351121962070465},{""x"":7.099999904632568,""y"":0.1619771122932434}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.953125499439879, 1.2528620255306528, 5.187637440149802, 0.3110348753260886],""points"":[{""x"":0.10000000149011612,""y"":5.6585283279418945},{""x"":0.6000000238418579,""y"":5.911152362823486},{""x"":1.100000023841858,""y"":5.924920082092285},{""x"":1.600000023841858,""y"":5.8469438552856445},{""x"":2.0999999046325684,""y"":5.929472923278809},{""x"":2.5999999046325684,""y"":6.190037727355957},{""x"":3.0999999046325684,""y"":6.236179828643799},{""x"":3.5999999046325684,""y"":6.141019344329834},{""x"":4.099999904632568,""y"":5.295210838317871},{""x"":4.599999904632568,""y"":5.265801906585693},{""x"":5.099999904632568,""y"":3.3722851276397705},{""x"":5.599999904632568,""y"":1.8299226760864258},{""x"":6.099999904632568,""y"":0.32690900564193726},{""x"":6.599999904632568,""y"":0.6274543404579163},{""x"":7.099999904632568,""y"":0.8441857099533081}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nRwanda,MPNSEPASLLELFNSIATQGELVRSLKAGNASK,CC(C)Cc1ccc(cc1)C(C)C(=O)N2CCCC2C(=O)OCCO,1480021,36.33137130737305,995037247,"168-46 91ST AVE., 2ND FLR",https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,COMPND ATOM END,flag,9,9,2BDJ,9,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[3.8209972202654474, 1.3779216716448506, 5.299882228439686, 0.06040645519069608],""points"":[{""x"":0.10000000149011612,""y"":3.7821109294891357},{""x"":0.6000000238418579,""y"":3.542433023452759},{""x"":1.100000023841858,""y"":3.7008674144744873},{""x"":1.600000023841858,""y"":3.717301607131958},{""x"":2.0999999046325684,""y"":4.024452209472656},{""x"":2.5999999046325684,""y"":4.013899326324463},{""x"":3.0999999046325684,""y"":3.945094347000122},{""x"":3.5999999046325684,""y"":3.866621971130371},{""x"":4.099999904632568,""y"":3.7461626529693604},{""x"":4.599999904632568,""y"":3.3454740047454834},{""x"":5.099999904632568,""y"":2.61944317817688},{""x"":5.599999904632568,""y"":0.999405026435852},{""x"":6.099999904632568,""y"":0.46259793639183044},{""x"":6.599999904632568,""y"":0.054134611040353775},{""x"":7.099999904632568,""y"":0.05711187422275543}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.6318079657726035, 1.8495493770000595, 5.391793312471116, 0.17060707587348442],""points"":[{""x"":0.10000000149011612,""y"":5.458079814910889},{""x"":0.6000000238418579,""y"":5.554427146911621},{""x"":1.100000023841858,""y"":5.799983024597168},{""x"":1.600000023841858,""y"":5.364140033721924},{""x"":2.0999999046325684,""y"":5.864485740661621},{""x"":2.5999999046325684,""y"":5.4509806632995605},{""x"":3.0999999046325684,""y"":5.702574729919434},{""x"":3.5999999046325684,""y"":5.7314534187316895},{""x"":4.099999904632568,""y"":5.5123443603515625},{""x"":4.599999904632568,""y"":5.724395751953125},{""x"":5.099999904632568,""y"":4.354506969451904},{""x"":5.599999904632568,""y"":1.7307666540145874},{""x"":6.099999904632568,""y"":0.6305936574935913},{""x"":6.599999904632568,""y"":0.035183437168598175},{""x"":7.099999904632568,""y"":0.7575169205665588}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nSwitzerland,IRVVGRYLIEVWKAAGMDMDKVLFLWSSDEI,CN1CCC(CC1)Oc2ccc(cc2)C(F)(F)F,1480028,36.33137130737305,99504,92-11 179TH PLACE,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,COMPND ATOM END,flag,9,10,1IAN,10,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[1.1190255865097471, 2.3163895161544437, 5.4968866182279195, 0.2035204047289052],""points"":[{""x"":0.10000000149011612,""y"":1.1057683229446411},{""x"":0.6000000238418579,""y"":1.1019697189331055},{""x"":1.100000023841858,""y"":1.0818607807159424},{""x"":1.600000023841858,""y"":1.062997817993164},{""x"":2.0999999046325684,""y"":1.046447515487671},{""x"":2.5999999046325684,""y"":1.1217249631881714},{""x"":3.0999999046325684,""y"":1.2166996002197266},{""x"":3.5999999046325684,""y"":1.215477705001831},{""x"":4.099999904632568,""y"":1.0581893920898438},{""x"":4.599999904632568,""y"":1.1747995615005493},{""x"":5.099999904632568,""y"":1.0181127786636353},{""x"":5.599999904632568,""y"":0.5344523191452026},{""x"":6.099999904632568,""y"":0.2569526433944702},{""x"":6.599999904632568,""y"":0.1912207305431366},{""x"":7.099999904632568,""y"":0.15060538053512573}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[3.1038581025805785, 2.0032224204185245, 5.087602825989163, 0.13277988512492753],""points"":[{""x"":0.10000000149011612,""y"":3.0498509407043457},{""x"":0.6000000238418579,""y"":2.805217742919922},{""x"":1.100000023841858,""y"":3.3415253162384033},{""x"":1.600000023841858,""y"":3.0549843311309814},{""x"":2.0999999046325684,""y"":3.250074863433838},{""x"":2.5999999046325684,""y"":3.0432586669921875},{""x"":3.0999999046325684,""y"":3.265852451324463},{""x"":3.5999999046325684,""y"":2.9475724697113037},{""x"":4.099999904632568,""y"":3.1929898262023926},{""x"":4.599999904632568,""y"":2.7460060119628906},{""x"":5.099999904632568,""y"":1.6175861358642578},{""x"":5.599999904632568,""y"":0.3006608486175537},{""x"":6.099999904632568,""y"":0.3444803059101105},{""x"":6.599999904632568,""y"":0.015537971630692482},{""x"":7.099999904632568,""y"":0.5527358055114746}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\n,,,,,,,,,,,,,,,,,,,,,').columns.add(i.Column.fromList(i.TYPE.BYTE_ARRAY,"BinaryImage",Array.from(new Uint8Array(11))));var o=function(t,e,s,n){return new(s||(s=Promise))((function(i,o){function r(t){try{l(n.next(t))}catch(t){o(t)}}function a(t){try{l(n.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof s?e:new s((function(t){t(e)}))).then(r,a)}l((n=n.apply(t,e||[])).next())}))};const r={};let a;var l;!function(t){t.notNull=function(t,e){if(null==t)throw new Error(`${null==e?"Value":e} not defined`)}}(l||(l={}));class c{constructor(t,e,s,n){var i;this.category=t,this.name=e,null!=n||(n={}),null!==(i=n.timeout)&&void 0!==i||(n.timeout=3e4),this.options=n,this.test=()=>o(this,void 0,void 0,(function*(){return new Promise(((t,e)=>o(this,void 0,void 0,(function*(){let n="";try{n=yield s()}catch(t){e(t)}t(n)}))))}))}}function h(t,e,s,n=0){return o(this,void 0,void 0,(function*(){return new Promise(((i,o)=>{const r=t.subscribe((t=>{try{e(t),i("OK")}catch(t){o(t)}r.unsubscribe(),clearTimeout(a)})),a=setTimeout((()=>{r.unsubscribe(),o("timeout")}),n);s()}))}))}function u(t,e,s){null==r[a]&&(r[a]={}),null==r[a].tests&&(r[a].tests=[]),r[a].tests.push(new c(a,t,e,s))}function m(t,e=!0,s){if(s=s?`${s}, `:"",t!==e)throw new Error(`${s}Expected "${e}", got "${t}"`)}function d(t,e,s=.001,n){if(t===Number.POSITIVE_INFINITY&&e===Number.POSITIVE_INFINITY||t===Number.NEGATIVE_INFINITY&&e===Number.NEGATIVE_INFINITY||t===Number.NaN&&e===Number.NaN||isNaN(t)&&isNaN(e))return;const i=Math.abs(t-e)<s;if(m(i,!0,`${null!=n?n:""} (tolerance = ${s})`),!i)throw new Error(`Expected ${e}, got ${t} (tolerance = ${s})`)}function p(t,e){for(const[s,n]of Object.entries(e)){if(!t.hasOwnProperty(s))throw new Error(`Expected property "${s}" not found`);const e=t[s];if(e instanceof Array&&n instanceof Array)g(e,n);else if(e instanceof Object&&n instanceof Object)p(e,n);else if(Number.isFinite(e)&&Number.isFinite(n))d(e,n);else if(e!=n)throw new Error(`Expected (${n}) for key '${s}', got (${e})`)}}function g(t,e){const s=t.length,n=e.length;if(s!=n)throw new Error(`Arrays are of different length: actual array length is ${s} and expected array length is ${n}`);for(let n=0;n<s;n++)if(t[n]instanceof Array&&e[n]instanceof Array)g(t[n],e[n]);else if(t[n]instanceof Object&&e[n]instanceof Object)p(t[n],e[n]);else if(t[n]!=e[n])throw new Error(`Expected ${e[n]} at position ${n}, got ${t[n]}`)}function f(t,e,s){var n;a=t,e(),r[a]&&(r[a].clear=null===(n=null==s?void 0:s.clear)||void 0===n||n,r[a].timeout=null==s?void 0:s.timeout)}function y(t){null==r[a]&&(r[a]={}),r[a].before=t}function w(t){null==r[a]&&(r[a]={}),r[a].after=t}function C(t){return o(this,void 0,void 0,(function*(){yield new Promise((e=>setTimeout(e,t)))}))}function T(t,e="Timeout exceeded",s=500,n=50){return o(this,void 0,void 0,(function*(){return new Promise(((i,o)=>{setTimeout((()=>{clearInterval(r),o(new Error(e))}),s);const r=setInterval((()=>{t()&&(clearInterval(r),i())}),n)}))}))}const b=i.DataFrame.fromColumns([i.Column.fromStrings("col",["val1","val2","val3"])]);function A(t,e,s){var r;return o(this,void 0,void 0,(function*(){(null==s?void 0:s.detectSemanticTypes)&&(yield n.data.detectSemanticTypes(e));let o=n.shell.addTableView(e);const a=`[name=viewer-${t.replace(/\s+/g,"-")} i]`,l=`${a} canvas,${a} svg,${a} img,\n ${a} input,${a} h1,${a} a,${a} .d4-viewer-error`,c=[];try{let h=o.addViewer(t);yield T((()=>null!==document.querySelector(l)),"cannot load viewer",3e3);const u=null===(r=document.querySelector(l))||void 0===r?void 0:r.tagName;if(c.push(Array.from(o.viewers).length),!(null==s?void 0:s.readOnly)){Array.from(e.row(0).cells).forEach((t=>t.value=null));const t=e.rowCount<20?Math.floor(e.rowCount/2):10;e.rows.select((e=>e.idx>=0&&e.idx<t)),yield C(50);for(let s=t;s<2*t;s++)e.filter.set(s,!1);yield C(50),e.currentRowIdx=1;const s=e.clone();e.columns.names().slice(0,Math.ceil(e.columns.length/2)).forEach((t=>e.columns.remove(t))),yield C(100),o.dataFrame=s}let d,p;try{d=h.getOptions(!0).look}catch(t){throw new Error("Viewer's .getOptions() error.",{cause:t})}try{p=h.getProperties()}catch(t){throw new Error("Viewer's .getProperties() error.",{cause:t})}const f={};Object.keys(d).filter((t=>"boolean"==typeof d[t])).forEach((t=>f[t]=!d[t])),p.filter((t=>null!==t.choices)).forEach((t=>f[t.name]=t.choices.find((e=>e!==d[t.name])))),h.setOptions(f),yield C(300);const y=o.saveLayout(),w=h.getOptions().look;o.resetLayout(),c.push(Array.from(o.viewers).length),o.loadLayout(y);const A=`${a} ${u}`;if(yield T((()=>null!==document.querySelector(A)),"cannot load viewer from layout",3e3),c.push(Array.from(o.viewers).length),h=Array.from(o.viewers).find((t=>"Grid"!==t.type)),g(c,[2,1,2]),m(JSON.stringify(h.getOptions().look),JSON.stringify(w)),!1!==(null==s?void 0:s.arbitraryDfTest)){n.shell.closeAll(),yield C(100),o=n.shell.addTableView(b);try{h=o.addViewer(t)}catch(t){return n.shell.closeAll(),void i.Balloon.closeAll()}yield T((()=>null!==document.querySelector(l)),"cannot load viewer on arbitrary dataset",3e3)}}finally{}}))}},3659:(t,e,s)=>{"use strict";s.d(e,{OW:()=>n});class n extends Float32Array{}},850:(t,e,s)=>{"use strict";s.d(e,{$G:()=>a,Fv:()=>u,MA:()=>l,On:()=>r,dP:()=>h,hu:()=>o,kO:()=>c});var n=s(3659),i=s(4588);function o(t=!1,e="Assertion error."){if(!t)throw new Error(e)}function r(t,e,s=1){const i=t.length;o(i==e.length,"Vector lengths do not match.");const r=new n.OW(i);for(let n=0;n<t.length;++n)r[n]=t[n]+s*e[n];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 n=0;n<t.length;n++)s+=t[n]*e[n];return s}function c(t,e,s=1){const o=function(t,e,s=0){return new Array(t).fill(s).map((()=>new n.OW(e).fill(s)))}(t,e);for(let n=0;n<t;++n)for(let t=0;t<e;++t)o[n][t]=(0,i.t)(s);return o}function h(t,e){let s=0;const n=t.length;if(n!==e.length)throw new Error("The dimensionality of the vectors must match");for(let i=0;i<n;++i)s+=Math.pow(t[i]-e[i],2);return Math.sqrt(s)}function u(t){const e=t.length;let s=0,n=0;for(let i=0;i<e;++i)s+=t[i],n+=Math.pow(t[i],2);const i=s/e,o=1/Math.sqrt(n/e-Math.pow(i,2));for(let s=0;s<e;++s)t[s]=(t[s]-i)*o;return t}},7659:(t,e,s)=>{"use strict";e.Z=void 0;var n=s(6215);Object.defineProperty(e,"Z",{enumerable:!0,get:function(){return n.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 n=Math.sqrt(-2*Math.log(s)/s);return this.vValue=e*n,this.returnV=!0,t*n}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 n=void 0!==s,i=[];for(let o=0;o<t;o++){const t=[];for(let i=0;i<e;i++)n?t.push(s):t.push(this.randn(0,1e-4));i.push(t)}return i}L2(t,e){const s=t.length;let n=0;for(let i=0;i<s;i++){const s=t[i],o=e[i];n+=(s-o)*(s-o)}return n}xtod(t){const e=t.length,s=this.zeros(e*e);for(let n=0;n<e;n++)for(let i=n+1;i<e;i++){const o=this.L2(t[n],t[i]);s[n*e+i]=o,s[i*e+n]=o}return s}d2p(t,e,s){const n=Math.sqrt(t.length),i=Math.floor(n);this.assert(i===n,"D should have square number of elements.");const o=Math.log(e),r=this.zeros(i*i),a=this.zeros(i);for(let e=0;e<i;e++){let n=-1/0,l=1/0,c=1,h=!1;const u=50;let m=0;for(;!h;){let r=0;for(let s=0;s<i;s++){let n=Math.exp(-t[e*i+s]*c);e===s&&(n=0),a[s]=n,r+=n}let d=0;for(let t=0;t<i;t++){let e;e=0===r?0:a[t]/r,a[t]=e,e>1e-7&&(d-=e*Math.log(e))}d>o?(n=c,l===1/0?c*=2:c=(c+l)/2):(l=c,n===-1/0?c/=2:c=(c+n)/2),m++,Math.abs(d-o)<s&&(h=!0),m>=u&&(h=!0)}for(let t=0;t<i;t++)r[e*i+t]=a[t]}const l=this.zeros(i*i),c=2*i;for(let t=0;t<i;t++)for(let e=0;e<i;e++)l[t*i+e]=Math.max((r[t*i+e]+r[e*i+t])/c,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 n=this.xtod(t);this.P=this.d2p(n,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 n=0;n<e;n++)for(let i=n+1;i<e;i++){const o=t[n][i];s[n*e+i]=o,s[i*e+n]=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,n=e.grad,i=this.zeros(this.dim);for(let e=0;e<t;e++)for(let t=0;t<this.dim;t++){const s=n[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*n[e][t];this.ystep[e][t]=l,this.Y[e][t]+=l,i[t]+=this.Y[e][t]}for(let e=0;e<t;e++)for(let s=0;s<this.dim;s++)this.Y[e][s]-=i[s]/t;return s}debugGrad(){const t=this.N,e=this.costGrad(this.Y),s=(e.cost,e.grad),n=1e-5;for(let e=0;e<t;e++)for(let t=0;t<this.dim;t++){const i=this.Y[e][t];this.Y[e][t]=i+n;const o=this.costGrad(this.Y);this.Y[e][t]=i-n;const r=this.costGrad(this.Y),a=s[e][t],l=(o.cost-r.cost)/(2*n);console.log(e+","+t+": gradcheck analytic: "+a+" vs. numerical: "+l),this.Y[e][t]=i}}costGrad(t){const e=this.N,s=this.dim,n=this.P,i=this.iter<100?4:1,o=this.zeros(e*e);let r=0;for(let n=0;n<e;n++)for(let i=n+1;i<e;i++){let a=0;for(let e=0;e<s;e++){const s=t[n][e]-t[i][e];a+=s*s}const l=1/(1+a);o[n*e+i]=l,o[i*e+n]=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 c=0;const h=[];for(let r=0;r<e;r++){const a=new Array(s);for(let t=0;t<s;t++)a[t]=0;for(let h=0;h<e;h++){c+=-n[r*e+h]*Math.log(l[r*e+h]);const u=4*(i*n[r*e+h]-l[r*e+h])*o[r*e+h];for(let e=0;e<s;e++)a[e]+=u*(t[r][e]-t[h][e])}h.push(a)}return{cost:c,grad:h}}}},5362:(t,e,s)=>{"use strict";s.d(e,{Z:()=>a});var n=s(7537),i=s.n(n),o=s(3645),r=s.n(o)()(i());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 n=s(7537),i=s.n(n),o=s(3645),r=s.n(o)()(i());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 n=s(7537),i=s.n(n),o=s(3645),r=s.n(o)()(i());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="",n=void 0!==e[5];return e[4]&&(s+="@supports (".concat(e[4],") {")),e[2]&&(s+="@media ".concat(e[2]," {")),n&&(s+="@layer".concat(e[5].length>0?" ".concat(e[5]):""," {")),s+=t(e),n&&(s+="}"),e[2]&&(s+="}"),e[4]&&(s+="}"),s})).join("")},e.i=function(t,s,n,i,o){"string"==typeof t&&(t=[[null,t,void 0]]);var r={};if(n)for(var a=0;a<this.length;a++){var l=this[a][0];null!=l&&(r[l]=!0)}for(var c=0;c<t.length;c++){var h=[].concat(t[c]);n&&r[h[0]]||(void 0!==o&&(void 0===h[5]||(h[1]="@layer".concat(h[5].length>0?" ".concat(h[5]):""," {").concat(h[1],"}")),h[5]=o),s&&(h[2]?(h[1]="@media ".concat(h[2]," {").concat(h[1],"}"),h[2]=s):h[2]=s),i&&(h[4]?(h[1]="@supports (".concat(h[4],") {").concat(h[1],"}"),h[4]=i):h[4]="".concat(i)),e.push(h))}},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 n=btoa(unescape(encodeURIComponent(JSON.stringify(s)))),i="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(n),o="/*# ".concat(i," */");return[e].concat([o]).join("\n")}return[e].join("\n")}},9133:function(t,e,s){var n;!function(e,i){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,n,i,o){for(var r,a,l,c,h,u,m,d,p,g,f,y,w;o>=64;){for(r=s[0],a=s[1],l=s[2],c=s[3],h=s[4],u=s[5],m=s[6],d=s[7],g=0;g<16;g++)f=i+4*g,t[g]=(255&n[f])<<24|(255&n[f+1])<<16|(255&n[f+2])<<8|255&n[f+3];for(g=16;g<64;g++)y=((p=t[g-2])>>>17|p<<15)^(p>>>19|p<<13)^p>>>10,w=((p=t[g-15])>>>7|p<<25)^(p>>>18|p<<14)^p>>>3,t[g]=(y+t[g-7]|0)+(w+t[g-16]|0);for(g=0;g<64;g++)y=(((h>>>6|h<<26)^(h>>>11|h<<21)^(h>>>25|h<<7))+(h&u^~h&m)|0)+(d+(e[g]+t[g]|0)|0)|0,w=((r>>>2|r<<30)^(r>>>13|r<<19)^(r>>>22|r<<10))+(r&a^r&l^a&l)|0,d=m,m=u,u=h,h=c+y|0,c=l,l=a,a=r,r=y+w|0;s[0]+=r,s[1]+=a,s[2]+=l,s[3]+=c,s[4]+=h,s[5]+=u,s[6]+=m,s[7]+=d,i+=64,o-=64}return i}var n=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 n=0;if(this.bytesHashed+=e,this.bufferLength>0){for(;this.bufferLength<64&&e>0;)this.buffer[this.bufferLength++]=t[n++],e--;64===this.bufferLength&&(s(this.temp,this.state,this.buffer,0,64),this.bufferLength=0)}for(e>=64&&(n=s(this.temp,this.state,t,n,e),e%=64);e>0;)this.buffer[this.bufferLength++]=t[n++],e--;return this},e.prototype.finish=function(t){if(!this.finished){var e=this.bytesHashed,n=this.bufferLength,i=e/536870912|0,o=e<<3,r=e%64<56?64:128;this.buffer[n]=128;for(var a=n+1;a<r-8;a++)this.buffer[a]=0;this.buffer[r-8]=i>>>24&255,this.buffer[r-7]=i>>>16&255,this.buffer[r-6]=i>>>8&255,this.buffer[r-5]=i>>>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=n;var i=function(){function t(t){this.inner=new n,this.outer=new n,this.blockSize=this.inner.blockSize,this.digestLength=this.inner.digestLength;var e=new Uint8Array(this.blockSize);if(t.length>this.blockSize)(new n).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 n).update(t),s=e.digest();return e.clean(),s}function r(t,e){var s=new i(t).update(e),n=s.digest();return s.clean(),n}function a(t,e,s,n){var i=n[0];if(0===i)throw new Error("hkdf: cannot expand more");e.reset(),i>1&&e.update(t),s&&e.update(s),e.update(n),e.finish(t),n[0]++}t.HMAC=i,t.hash=o,t.default=o,t.hmac=r;var l=new Uint8Array(t.digestLength);t.hkdf=function(t,e,s,n){void 0===e&&(e=l),void 0===n&&(n=32);for(var o=new Uint8Array([1]),c=r(e,t),h=new i(c),u=new Uint8Array(h.digestLength),m=u.length,d=new Uint8Array(n),p=0;p<n;p++)m===u.length&&(a(u,h,s,o),m=0),d[p]=u[m++];return h.clean(),u.fill(0),o.fill(0),d},t.pbkdf2=function(t,e,s,n){for(var o=new i(t),r=o.digestLength,a=new Uint8Array(4),l=new Uint8Array(r),c=new Uint8Array(r),h=new Uint8Array(n),u=0;u*r<n;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(c);for(var d=0;d<r;d++)l[d]=c[d];for(d=2;d<=s;d++){o.reset(),o.update(c).finish(c);for(var p=0;p<r;p++)l[p]^=c[p]}for(d=0;d<r&&u*r+d<n;d++)h[u*r+d]=l[d]}for(u=0;u<r;u++)l[u]=c[u]=0;for(u=0;u<4;u++)a[u]=0;return o.clean(),h}}(o);var r=o.default;for(var a in o)r[a]=o[a];"object"==typeof t.exports?t.exports=r:void 0===(n=function(){return r}.call(o,s,o,t))||(t.exports=n)}()},1811:(t,e,s)=>{"use strict";s.d(e,{T:()=>i});const n=new Uint32Array(65536),i=(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,i=e.length,o=1<<s-1;let r=-1,a=0,l=s,c=s;for(;c--;)n[t.charCodeAt(c)]|=1<<c;for(c=0;c<i;c++){let t=n[e.charCodeAt(c)];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(c=s;c--;)n[t.charCodeAt(c)]=0;return l})(t,e):((t,e)=>{const s=e.length,i=t.length,o=[],r=[],a=Math.ceil(s/32),l=Math.ceil(i/32);for(let t=0;t<a;t++)r[t]=-1,o[t]=0;let c=0;for(;c<l-1;c++){let a=0,l=-1;const h=32*c,u=Math.min(32,i)+h;for(let e=h;e<u;e++)n[t.charCodeAt(e)]|=1<<e;for(let t=0;t<s;t++){const s=n[e.charCodeAt(t)],i=r[t/32|0]>>>t&1,c=o[t/32|0]>>>t&1,h=s|a,u=((s|c)&l)+l^l|s|c;let m=a|~(u|l),d=l&u;m>>>31^i&&(r[t/32|0]^=1<<t),d>>>31^c&&(o[t/32|0]^=1<<t),m=m<<1|i,d=d<<1|c,l=d|~(h|m),a=m&h}for(let e=h;e<u;e++)n[t.charCodeAt(e)]=0}let h=0,u=-1;const m=32*c,d=Math.min(32,i-m)+m;for(let e=m;e<d;e++)n[t.charCodeAt(e)]|=1<<e;let p=i;for(let t=0;t<s;t++){const s=n[e.charCodeAt(t)],a=r[t/32|0]>>>t&1,l=o[t/32|0]>>>t&1,c=s|h,m=((s|l)&u)+u^u|s|l;let d=h|~(m|u),g=u&m;p+=d>>>i-1&1,p-=g>>>i-1&1,d>>>31^a&&(r[t/32|0]^=1<<t),g>>>31^l&&(o[t/32|0]^=1<<t),d=d<<1|a,g=g<<1|l,u=g|~(c|d),h=d&c}for(let e=m;e<d;e++)n[t.charCodeAt(e)]=0;return p})(t,e)}},7531:(t,e,s)=>{"use strict";s.d(e,{Z:()=>i});const n=Object.prototype.toString;function i(t){return n.call(t).endsWith("Array]")}},3979:(t,e)=>{"use strict";e.H$=void 0,e.H$=function(t,e,s){var n=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 n=0,i=t.length,o=e.length,r=Math.floor(Math.max(i,o)/2)-1,a=new Array(i),l=new Array(o),c=0;c<i;c++)for(var h=Math.max(0,c-r);h<=Math.min(o,c+r+1);h++)if(!a[c]&&!l[h]&&t[c]===e[h]){++n,a[c]=l[h]=!0;break}if(0===n)return 0;var u=0,m=0;for(c=0;c<i;c++)if(a[c]){for(;!l[m];)m++;t.charAt(c)!==e.charAt(m++)&&u++}return(n/i+n/o+(n-(u/=2))/n)/3}(t,e,s),i=0;if(n>.7){for(var o=Math.min(t.length,e.length),r=0;t[r]===e[r]&&r<4&&r<o;)++i,r++;n+=.1*i*(1-n)}return n}},5111:(t,e,s)=>{"use strict";s.d(e,{Z:()=>i});var n=s(6044);function i(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!(0,n.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,i=void 0===s?0:s,o=e.toIndex,r=void 0===o?t.length:o;if(i<0||i>=t.length||!Number.isInteger(i))throw new Error("fromIndex must be a positive integer smaller than length");if(r<=i||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[i],l=i+1;l<r;l++)t[l]>a&&(a=t[l]);return a}},6044:(t,e,s)=>{"use strict";s.d(e,{N:()=>i});const n=Object.prototype.toString;function i(t){return n.call(t).endsWith("Array]")}},1772:(t,e,s)=>{"use strict";s.d(e,{Z:()=>i});var n=s(994);function i(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!(0,n.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,i=void 0===s?0:s,o=e.toIndex,r=void 0===o?t.length:o;if(i<0||i>=t.length||!Number.isInteger(i))throw new Error("fromIndex must be a positive integer smaller than length");if(r<=i||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[i],l=i+1;l<r;l++)t[l]<a&&(a=t[l]);return a}},994:(t,e,s)=>{"use strict";s.d(e,{N:()=>i});const n=Object.prototype.toString;function i(t){return n.call(t).endsWith("Array]")}},5408:(t,e,s)=>{"use strict";s.d(e,{Z:()=>r});var n=s(6241),i=s(5111),o=s(1772);function r(t){var e,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!(0,n.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,n.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,i.Z)(t);if(r===a)throw new RangeError("minimum and maximum input values are equal. Cannot rescale a constant array");var l=s.min,c=void 0===l?s.autoMinMax?r:0:l,h=s.max,u=void 0===h?s.autoMinMax?a:1:h;if(c>=u)throw new RangeError("min option must be smaller than max option");for(var m=(u-c)/(a-r),d=0;d<t.length;d++)e[d]=(t[d]-r)*m+c;return e}},6241:(t,e,s)=>{"use strict";s.d(e,{N:()=>i});const n=Object.prototype.toString;function i(t){return n.call(t).endsWith("Array]")}},1353:(t,e,s)=>{"use strict";function n(t,e,s){let n=0;const i=s(e);for(let e=0;e<t.x.length;e++)n+=Math.abs(t.y[e]-i(t.x[e]));return n}s.d(e,{Z:()=>n})},3107:(t,e,s)=>{"use strict";s.d(e,{Z:()=>r});var n=s(7531),i=s(1353),o=s(8188);function r(t,e,s={}){let{maxIterations:r=100,gradientDifference:a=.1,damping:l=0,errorTolerance:c=.01,minValues:h,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,n.Z)(t.x)||t.x.length<2||!(0,n.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),p=d.length;if(u=u||new Array(p).fill(Number.MAX_SAFE_INTEGER),h=h||new Array(p).fill(Number.MIN_SAFE_INTEGER),u.length!==h.length)throw new Error("minValues and maxValues must be the same size");if(!(0,n.Z)(d))throw new Error("initialValues must be an array");let g,f=(0,i.Z)(t,d,e),y=f<=c;for(g=0;g<r&&!y;g++){d=(0,o.Z)(t,d,l,a,e);for(let t=0;t<p;t++)d[t]=Math.min(Math.max(h[t],d[t]),u[t]);if(f=(0,i.Z)(t,d,e),isNaN(f))break;y=f<=c}return{parameterValues:d,parameterError:f,iterations:g}}},8188:(t,e,s)=>{"use strict";s.d(e,{Z:()=>o});var n=s(1174),i=s(8345);function o(t,e,s,o,r){let a=s*o*o,l=n.Z.eye(e.length,e.length,a);const c=r(e);let h=new Float64Array(t.x.length);for(let e=0;e<t.x.length;e++)h[e]=c(t.x[e]);let u=function(t,e,s,i,o){const r=s.length,a=t.x.length;let l=new Array(r);for(let n=0;n<r;n++){l[n]=new Array(a);let r=s.slice();r[n]+=i;let c=o(r);for(let s=0;s<a;s++)l[n][s]=e[s]-c(t.x[s])}return new n.Z(l)}(t,h,e,o,r),m=function(t,e){const s=t.x.length;let i=new Array(s);for(let n=0;n<s;n++)i[n]=[t.y[n]-e[n]];return new n.Z(i)}(t,h),d=(0,i.S)(l.add(u.mmul(u.transpose())));return(e=(e=new n.Z([e])).sub(d.mmul(u).mmul(m).mul(o).transpose())).to1DArray()}},5776:(t,e,s)=>{"use strict";s.d(e,{N:()=>i});const n=Object.prototype.toString;function i(t){return n.call(t).endsWith("Array]")}},2313:(t,e,s)=>{"use strict";s.d(e,{Z:()=>o});var n=s(1174),i=s(8353);class o{constructor(t){let e,s,n,o,r,a,l,c,h,u=(t=i.Z.checkMatrix(t)).clone(),m=u.rows,d=u.columns,p=new Float64Array(m),g=1;for(e=0;e<m;e++)p[e]=e;for(c=new Float64Array(m),s=0;s<d;s++){for(e=0;e<m;e++)c[e]=u.get(e,s);for(e=0;e<m;e++){for(h=Math.min(e,s),r=0,n=0;n<h;n++)r+=u.get(e,n)*c[n];c[e]-=r,u.set(e,s,c[e])}for(o=s,e=s+1;e<m;e++)Math.abs(c[e])>Math.abs(c[o])&&(o=e);if(o!==s){for(n=0;n<d;n++)a=u.get(o,n),u.set(o,n,u.get(s,n)),u.set(s,n,a);l=p[o],p[o]=p[s],p[s]=l,g=-g}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=p,this.pivotSign=g}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=n.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,i,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(i=0;i<r;i++)a.set(s,i,a.get(s,i)-a.get(o,i)*e.get(s,o));for(o=l-1;o>=0;o--){for(i=0;i<r;i++)a.set(o,i,a.get(o,i)/e.get(o,o));for(s=0;s<o;s++)for(i=0;i<r;i++)a.set(s,i,a.get(s,i)-a.get(o,i)*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 n=0;n<s;n++)e*=t.get(n,n);return e}get lowerTriangularMatrix(){let t=this.LU,e=t.rows,s=t.columns,i=new n.Z(e,s);for(let n=0;n<e;n++)for(let e=0;e<s;e++)n>e?i.set(n,e,t.get(n,e)):n===e?i.set(n,e,1):i.set(n,e,0);return i}get upperTriangularMatrix(){let t=this.LU,e=t.rows,s=t.columns,i=new n.Z(e,s);for(let n=0;n<e;n++)for(let e=0;e<s;e++)n<=e?i.set(n,e,t.get(n,e)):i.set(n,e,0);return i}get pivotPermutationVector(){return Array.from(this.pivotVector)}}},7072:(t,e,s)=>{"use strict";s.d(e,{Z:()=>r});var n=s(1174),i=s(8353),o=s(6310);class r{constructor(t){let e,s,n,r,a=(t=i.Z.checkMatrix(t)).clone(),l=t.rows,c=t.columns,h=new Float64Array(c);for(n=0;n<c;n++){let t=0;for(e=n;e<l;e++)t=(0,o.G)(t,a.get(e,n));if(0!==t){for(a.get(n,n)<0&&(t=-t),e=n;e<l;e++)a.set(e,n,a.get(e,n)/t);for(a.set(n,n,a.get(n,n)+1),s=n+1;s<c;s++){for(r=0,e=n;e<l;e++)r+=a.get(e,n)*a.get(e,s);for(r=-r/a.get(n,n),e=n;e<l;e++)a.set(e,s,a.get(e,s)+r*a.get(e,n))}}h[n]=-t}this.QR=a,this.Rdiag=h}solve(t){t=n.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 i,o,r,a,l=t.columns,c=t.clone(),h=e.columns;for(r=0;r<h;r++)for(o=0;o<l;o++){for(a=0,i=r;i<s;i++)a+=e.get(i,r)*c.get(i,o);for(a=-a/e.get(r,r),i=r;i<s;i++)c.set(i,o,c.get(i,o)+a*e.get(i,r))}for(r=h-1;r>=0;r--){for(o=0;o<l;o++)c.set(r,o,c.get(r,o)/this.Rdiag[r]);for(i=0;i<r;i++)for(o=0;o<l;o++)c.set(i,o,c.get(i,o)-c.get(r,o)*e.get(i,r))}return c.subMatrix(0,h-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,i=s.columns,o=new n.Z(i,i);for(t=0;t<i;t++)for(e=0;e<i;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,i,o=this.QR,r=o.rows,a=o.columns,l=new n.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(i=0,t=s;t<r;t++)i+=o.get(t,s)*l.get(t,e);for(i=-i/o.get(s,s),t=s;t<r;t++)l.set(t,e,l.get(t,e)+i*o.get(t,s))}}return l}}},6943:(t,e,s)=>{"use strict";s.d(e,{Z:()=>r});var n=s(1174),i=s(8353),o=s(6310);class r{constructor(t,e={}){if((t=i.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:c=!1}=e;let h,u=Boolean(a),m=Boolean(l),d=!1;if(s<r)if(c){h=t.transpose(),s=h.rows,r=h.columns,d=!0;let e=u;u=m,m=e}else h=t.clone(),console.warn("Computing SVD on a matrix with more columns than rows. Consider enabling autoTranspose");else h=t.clone();let p=Math.min(s,r),g=Math.min(s+1,r),f=new Float64Array(g),y=new n.Z(s,p),w=new n.Z(r,r),C=new Float64Array(r),T=new Float64Array(s),b=new Float64Array(g);for(let t=0;t<g;t++)b[t]=t;let A=Math.min(s-1,r),S=Math.max(0,Math.min(r-2,s)),E=Math.max(A,S);for(let t=0;t<E;t++){if(t<A){f[t]=0;for(let e=t;e<s;e++)f[t]=(0,o.G)(f[t],h.get(e,t));if(0!==f[t]){h.get(t,t)<0&&(f[t]=-f[t]);for(let e=t;e<s;e++)h.set(e,t,h.get(e,t)/f[t]);h.set(t,t,h.get(t,t)+1)}f[t]=-f[t]}for(let e=t+1;e<r;e++){if(t<A&&0!==f[t]){let n=0;for(let i=t;i<s;i++)n+=h.get(i,t)*h.get(i,e);n=-n/h.get(t,t);for(let i=t;i<s;i++)h.set(i,e,h.get(i,e)+n*h.get(i,t))}C[e]=h.get(t,e)}if(u&&t<A)for(let e=t;e<s;e++)y.set(e,t,h.get(e,t));if(t<S){C[t]=0;for(let e=t+1;e<r;e++)C[t]=(0,o.G)(C[t],C[e]);if(0!==C[t]){C[t+1]<0&&(C[t]=0-C[t]);for(let e=t+1;e<r;e++)C[e]/=C[t];C[t+1]+=1}if(C[t]=-C[t],t+1<s&&0!==C[t]){for(let e=t+1;e<s;e++)T[e]=0;for(let e=t+1;e<s;e++)for(let s=t+1;s<r;s++)T[e]+=C[s]*h.get(e,s);for(let e=t+1;e<r;e++){let n=-C[e]/C[t+1];for(let i=t+1;i<s;i++)h.set(i,e,h.get(i,e)+n*T[i])}}if(m)for(let e=t+1;e<r;e++)w.set(e,t,C[e])}}let M=Math.min(r,s+1);if(A<r&&(f[A]=h.get(A,A)),s<M&&(f[M-1]=0),S+1<M&&(C[S]=h.get(S,M-1)),C[M-1]=0,u){for(let t=A;t<p;t++){for(let e=0;e<s;e++)y.set(e,t,0);y.set(t,t,1)}for(let t=A-1;t>=0;t--)if(0!==f[t]){for(let e=t+1;e<p;e++){let n=0;for(let i=t;i<s;i++)n+=y.get(i,t)*y.get(i,e);n=-n/y.get(t,t);for(let i=t;i<s;i++)y.set(i,e,y.get(i,e)+n*y.get(i,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<S&&0!==C[t])for(let e=t+1;e<r;e++){let s=0;for(let n=t+1;n<r;n++)s+=w.get(n,t)*w.get(n,e);s=-s/w.get(t+1,t);for(let n=t+1;n<r;n++)w.set(n,e,w.get(n,e)+s*w.get(n,t))}for(let e=0;e<r;e++)w.set(e,t,0);w.set(t,t,1)}let v=M-1,N=0,x=Number.EPSILON;for(;M>0;){let t,e;for(t=M-2;t>=-1&&-1!==t;t--){const e=Number.MIN_VALUE+x*Math.abs(f[t]+Math.abs(f[t+1]));if(Math.abs(C[t])<=e||Number.isNaN(C[t])){C[t]=0;break}}if(t===M-2)e=4;else{let s;for(s=M-1;s>=t&&s!==t;s--){let e=(s!==M?Math.abs(C[s]):0)+(s!==t+1?Math.abs(C[s-1]):0);if(Math.abs(f[s])<=x*e){f[s]=0;break}}s===t?e=3:s===M-1?e=1:(e=2,t=s)}switch(t++,e){case 1:{let e=C[M-2];C[M-2]=0;for(let s=M-2;s>=t;s--){let n=(0,o.G)(f[s],e),i=f[s]/n,a=e/n;if(f[s]=n,s!==t&&(e=-a*C[s-1],C[s-1]=i*C[s-1]),m)for(let t=0;t<r;t++)n=i*w.get(t,s)+a*w.get(t,M-1),w.set(t,M-1,-a*w.get(t,s)+i*w.get(t,M-1)),w.set(t,s,n)}break}case 2:{let e=C[t-1];C[t-1]=0;for(let n=t;n<M;n++){let i=(0,o.G)(f[n],e),r=f[n]/i,a=e/i;if(f[n]=i,e=-a*C[n],C[n]=r*C[n],u)for(let e=0;e<s;e++)i=r*y.get(e,n)+a*y.get(e,t-1),y.set(e,t-1,-a*y.get(e,n)+r*y.get(e,t-1)),y.set(e,n,i)}break}case 3:{const e=Math.max(Math.abs(f[M-1]),Math.abs(f[M-2]),Math.abs(C[M-2]),Math.abs(f[t]),Math.abs(C[t])),n=f[M-1]/e,i=f[M-2]/e,a=C[M-2]/e,l=f[t]/e,c=C[t]/e,h=((i+n)*(i-n)+a*a)/2,d=n*a*(n*a);let p=0;0===h&&0===d||(p=h<0?0-Math.sqrt(h*h+d):Math.sqrt(h*h+d),p=d/(h+p));let g=(l+n)*(l-n)+p,T=l*c;for(let e=t;e<M-1;e++){let n=(0,o.G)(g,T);0===n&&(n=Number.MIN_VALUE);let i=g/n,a=T/n;if(e!==t&&(C[e-1]=n),g=i*f[e]+a*C[e],C[e]=i*C[e]-a*f[e],T=a*f[e+1],f[e+1]=i*f[e+1],m)for(let t=0;t<r;t++)n=i*w.get(t,e)+a*w.get(t,e+1),w.set(t,e+1,-a*w.get(t,e)+i*w.get(t,e+1)),w.set(t,e,n);if(n=(0,o.G)(g,T),0===n&&(n=Number.MIN_VALUE),i=g/n,a=T/n,f[e]=n,g=i*C[e]+a*f[e+1],f[e+1]=-a*C[e]+i*f[e+1],T=a*C[e+1],C[e+1]=i*C[e+1],u&&e<s-1)for(let t=0;t<s;t++)n=i*y.get(t,e)+a*y.get(t,e+1),y.set(t,e+1,-a*y.get(t,e)+i*y.get(t,e+1)),y.set(t,e,n)}C[M-2]=g,N+=1;break}case 4:if(f[t]<=0&&(f[t]=f[t]<0?-f[t]:0,m))for(let e=0;e<=v;e++)w.set(e,t,-w.get(e,t));for(;t<v&&!(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=w.get(s,t+1),w.set(s,t+1,w.get(s,t)),w.set(s,t,e);if(u&&t<s-1)for(let n=0;n<s;n++)e=y.get(n,t+1),y.set(n,t+1,y.get(n,t)),y.set(n,t,e);t++}N=0,M--}}if(d){let t=w;w=y,y=t}this.m=s,this.n=r,this.s=f,this.U=y,this.V=w}solve(t){let e=t,s=this.threshold,i=this.s.length,o=n.Z.zeros(i,i);for(let t=0;t<i;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),c=a.rows,h=r.rows,u=n.Z.zeros(c,h);for(let t=0;t<c;t++)for(let e=0;e<h;e++){let s=0;for(let n=0;n<i;n++)s+=l.get(t,n)*r.get(e,n);u.set(t,e,s)}return u.mmul(e)}solveForDiagonal(t){return this.solve(n.Z.diag(t))}inverse(){let t=this.V,e=this.threshold,s=t.rows,i=t.columns,o=new n.Z(s,this.s.length);for(let n=0;n<s;n++)for(let s=0;s<i;s++)Math.abs(this.s[s])>e&&o.set(n,s,t.get(n,s)/this.s[s]);let r=this.U,a=r.rows,l=r.columns,c=new n.Z(s,a);for(let t=0;t<s;t++)for(let e=0;e<a;e++){let s=0;for(let n=0;n<l;n++)s+=o.get(t,n)*r.get(e,n);c.set(t,e,s)}return c}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 n=0,i=s.length;n<i;n++)s[n]>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 n.Z.diag(this.s)}}},6310:(t,e,s)=>{"use strict";function n(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:()=>n})},8345:(t,e,s)=>{"use strict";s.d(e,{S:()=>l});var n=s(2313),i=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 n.Z(t).solve(e):new i.Z(t).solve(e)}(t,r.Z.eye(t.rows))}},3559:(t,e,s)=>{"use strict";s.d(e,{M:()=>r,V:()=>o});const n=" ".repeat(2),i=" ".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${n}[\n${i}${function(t,e,s,n,o){const{rows:r,columns:l}=t,c=Math.min(r,e),h=Math.min(l,s),u=[];if("auto"===o){o=!1;t:for(let e=0;e<c;e++)for(let s=0;s<h;s++)if(t.get(e,s)<0){o=!0;break t}}for(let e=0;e<c;e++){let s=[];for(let i=0;i<h;i++)s.push(a(t.get(e,i),n,o));u.push(`${s.join(" ")}`)}return h!==l&&(u[u.length-1]+=` ... ${l-s} more columns`),c!==r&&u.push(`... ${r-e} more rows`),u.join(`\n${i}`)}(t,s,o,r,l)}\n${n}]\n${n}rows: ${t.rows}\n${n}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 n=t.toFixed(e);if(n.length>e&&(n=t.toFixed(Math.max(0,e-(n.length-e)))),n.length<=e&&!n.startsWith("0.000")&&!n.startsWith("-0.000"))return n;let i=t.toExponential(e);return i.length>e&&(i=t.toExponential(Math.max(0,e-(i.length-e)))),i.slice(0)}},5401:(t,e,s)=>{"use strict";function n(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:()=>n})},1174:(t,e,s)=>{"use strict";s.d(e,{X:()=>c,Z:()=>u});var n=s(5776),i=s(5408),o=s(3559),r=s(5401),a=s(9515),l=s(3018);class c{static from1DArray(t,e,s){if(t*e!==s.length)throw new RangeError("data length does not match given dimensions");let n=new u(t,e);for(let i=0;i<t;i++)for(let t=0;t<e;t++)n.set(i,t,s[i*e+t]);return n}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:n=Math.random}=s;let i=new u(t,e);for(let s=0;s<t;s++)for(let t=0;t<e;t++)i.set(s,t,n());return i}static randInt(t,e,s={}){if("object"!=typeof s)throw new TypeError("options must be an object");const{min:n=0,max:i=1e3,random:o=Math.random}=s;if(!Number.isInteger(n))throw new TypeError("min must be an integer");if(!Number.isInteger(i))throw new TypeError("max must be an integer");if(n>=i)throw new RangeError("min must be smaller than max");let r=i-n,a=new u(t,e);for(let s=0;s<t;s++)for(let t=0;t<e;t++){let e=n+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 n=Math.min(t,e),i=this.zeros(t,e);for(let t=0;t<n;t++)i.set(t,t,s);return i}static diag(t,e,s){let n=t.length;void 0===e&&(e=n),void 0===s&&(s=e);let i=Math.min(n,e,s),o=this.zeros(e,s);for(let e=0;e<i;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,n=t.columns,i=new u(s,n);for(let o=0;o<s;o++)for(let s=0;s<n;s++)i.set(o,s,Math.min(t.get(o,s),e.get(o,s)));return i}static max(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let s=t.rows,n=t.columns,i=new this(s,n);for(let o=0;o<s;o++)for(let s=0;s<n;s++)i.set(o,s,Math.max(t.get(o,s),e.get(o,s)));return i}static checkMatrix(t){return c.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,n=!0,i=!1;for(;t<this.rows&&n;){for(e=0,i=!1;e<this.columns&&!1===i;)0===this.get(t,e)?e++:1===this.get(t,e)&&e>s?(i=!0,s=e):(n=!1,i=!0);t++}return n}isReducedEchelonForm(){let t=0,e=0,s=-1,n=!0,i=!1;for(;t<this.rows&&n;){for(e=0,i=!1;e<this.columns&&!1===i;)0===this.get(t,e)?e++:1===this.get(t,e)&&e>s?(i=!0,s=e):(n=!1,i=!0);for(let s=e+1;s<this.rows;s++)0!==this.get(t,s)&&(n=!1);t++}return n}echelonForm(){let t=this.clone(),e=0,s=0;for(;e<t.rows&&s<t.columns;){let n=e;for(let i=e;i<t.rows;i++)t.get(i,s)>t.get(n,s)&&(n=i);if(0===t.get(n,s))s++;else{t.swapRows(e,n);let i=t.get(e,s);for(let n=s;n<t.columns;n++)t.set(e,n,t.get(e,n)/i);for(let n=e+1;n<t.rows;n++){let i=t.get(n,s)/t.get(e,s);t.set(n,s,0);for(let o=s+1;o<t.columns;o++)t.set(n,o,t.get(n,o)-t.get(e,o)*i)}e++,s++}}return t}reducedEchelonForm(){let t=this.echelonForm(),e=t.columns,s=t.rows,n=s-1;for(;n>=0;)if(0===t.maxRow(n))n--;else{let i=0,o=!1;for(;i<s&&!1===o;)1===t.get(n,i)?o=!0:i++;for(let s=0;s<n;s++){let o=t.get(s,i);for(let r=i;r<e;r++){let e=t.get(s,r)-o*t.get(n,r);t.set(s,r,e)}}n--}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 n=new u(this.rows*e,this.columns*s);for(let t=0;t<e;t++)for(let e=0;e<s;e++)n.setSubMatrix(this,this.rows*t,this.columns*e);return n}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 n=this.get(t,s);this.set(t,s,this.get(e,s)),this.set(e,s,n)}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 n=this.get(s,t);this.set(s,t,this.get(s,e)),this.set(s,e,n)}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 n=0;n<this.columns;n++)this.get(s,n)>t&&(t=this.get(s,n),e[0]=s,e[1]=n);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 n=0;n<this.columns;n++)this.get(s,n)<t&&(t=this.get(s,n),e[0]=s,e[1]=n);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 n=1;n<this.columns;n++)this.get(t,n)>e&&(e=this.get(t,n),s[1]=n);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 n=1;n<this.columns;n++)this.get(t,n)<e&&(e=this.get(t,n),s[1]=n);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 n=1;n<this.rows;n++)this.get(n,t)>e&&(e=this.get(n,t),s[0]=n);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 n=1;n<this.rows;n++)this.get(n,t)<e&&(e=this.get(n,t),s[0]=n);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){c.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 n=0;n<e.length;n++)s+=e[n]*t[n];return s}mmul(t){t=u.checkMatrix(t);let e=this.rows,s=this.columns,n=t.columns,i=new u(e,n),o=new Float64Array(s);for(let r=0;r<n;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 n=0;n<s;n++)e+=this.get(t,n)*o[n];i.set(t,r,e)}}return i}strassen2x2(t){t=u.checkMatrix(t);let e=new u(2,2);const s=this.get(0,0),n=t.get(0,0),i=this.get(0,1),o=t.get(0,1),r=this.get(1,0),a=t.get(1,0),l=this.get(1,1),c=t.get(1,1),h=(s+l)*(n+c),m=(r+l)*n,d=s*(o-c),p=l*(a-n),g=(s+i)*c,f=h+p-g+(i-l)*(a+c),y=d+g,w=m+p,C=h-m+d+(r-s)*(n+o);return e.set(0,0,f),e.set(0,1,y),e.set(1,0,w),e.set(1,1,C),e}strassen3x3(t){t=u.checkMatrix(t);let e=new u(3,3);const s=this.get(0,0),n=this.get(0,1),i=this.get(0,2),o=this.get(1,0),r=this.get(1,1),a=this.get(1,2),l=this.get(2,0),c=this.get(2,1),h=this.get(2,2),m=t.get(0,0),d=t.get(0,1),p=t.get(0,2),g=t.get(1,0),f=t.get(1,1),y=t.get(1,2),w=t.get(2,0),C=t.get(2,1),T=t.get(2,2),b=(s-o)*(-d+f),A=(-s+o+r)*(m-d+f),S=(o+r)*(-m+d),E=s*m,M=(-s+l+c)*(m-p+y),v=(-s+l)*(p-y),N=(l+c)*(-m+p),x=(-i+c+h)*(f+w-C),I=(i-h)*(f-C),L=i*w,P=(c+h)*(-w+C),R=(-i+r+a)*(y+w-T),_=(i-a)*(y-T),O=(r+a)*(-w+T),G=E+L+n*g,F=(s+n+i-o-r-c-h)*f+A+S+E+x+L+P,D=E+M+N+(s+n+i-r-a-l-c)*y+L+R+O,H=b+r*(-m+d+g-f-y-w+T)+A+E+L+R+_,W=b+A+S+E+a*C,k=L+R+_+O+o*p,B=E+M+v+c*(-m+p+g-f-y-w+C)+x+I+L,V=x+I+L+P+l*d,U=E+M+v+N+h*T;return e.set(0,0,G),e.set(0,1,F),e.set(0,2,D),e.set(1,0,H),e.set(1,1,W),e.set(1,2,k),e.set(2,0,B),e.set(2,1,V),e.set(2,2,U),e}mmulStrassen(t){t=u.checkMatrix(t);let e=this.clone(),s=e.rows,n=e.columns,i=t.rows,o=t.columns;function r(t,e,s){let n=t.rows,i=t.columns;if(n===e&&i===s)return t;{let n=c.zeros(e,s);return n=n.setSubMatrix(t,0,0),n}}n!==i&&console.warn(`Multiplying ${s} x ${n} and ${i} x ${o} matrix: dimensions do not match.`);let a=Math.max(s,i),l=Math.max(n,o);return e=r(e,a,l),function t(e,s,n,i){if(n<=512||i<=512)return e.mmul(s);n%2==1&&i%2==1?(e=r(e,n+1,i+1),s=r(s,n+1,i+1)):n%2==1?(e=r(e,n+1,i),s=r(s,n+1,i)):i%2==1&&(e=r(e,n,i+1),s=r(s,n,i+1));let o=parseInt(e.rows/2,10),a=parseInt(e.columns/2,10),l=e.subMatrix(0,o-1,0,a-1),h=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),p=s.subMatrix(o,s.rows-1,0,a-1),g=e.subMatrix(o,e.rows-1,a,e.columns-1),f=s.subMatrix(o,s.rows-1,a,s.columns-1),y=t(c.add(l,g),c.add(h,f),o,a),w=t(c.add(d,g),h,o,a),C=t(l,c.sub(m,f),o,a),T=t(g,c.sub(p,h),o,a),b=t(c.add(l,u),f,o,a),A=t(c.sub(d,l),c.add(h,m),o,a),S=t(c.sub(u,g),c.add(p,f),o,a),E=c.add(y,T);E.sub(b),E.add(S);let M=c.add(C,b),v=c.add(w,T),N=c.sub(y,w);N.add(C),N.add(A);let x=c.zeros(2*E.rows,2*E.columns);return x=x.setSubMatrix(E,0,0),x=x.setSubMatrix(M,E.rows,0),x=x.setSubMatrix(v,0,E.columns),x=x.setSubMatrix(N,E.rows,E.columns),x.subMatrix(0,n-1,0,i-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 n=new u(this.rows,this.columns);for(let t=0;t<this.rows;t++){const o=this.getRow(t);o.length>0&&(0,i.Z)(o,{min:e,max:s,output:o}),n.setRow(t,o)}return n}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 n=new u(this.rows,this.columns);for(let t=0;t<this.columns;t++){const o=this.getColumn(t);o.length&&(0,i.Z)(o,{min:e,max:s,output:o}),n.setColumn(t,o)}return n}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),n=this.get(e,this.columns-1-s);this.set(e,s,n),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),n=this.get(this.rows-1-s,e);this.set(s,e,n),this.set(this.rows-1-s,e,t)}return this}kroneckerProduct(t){t=u.checkMatrix(t);let e=this.rows,s=this.columns,n=t.rows,i=t.columns,o=new u(e*n,s*i);for(let r=0;r<e;r++)for(let e=0;e<s;e++)for(let s=0;s<n;s++)for(let a=0;a<i;a++)o.set(n*r+s,i*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,n=this.kroneckerProduct(u.eye(s,s)),i=u.eye(e,e).kroneckerProduct(t);return n.add(i)}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=h){for(let e=0;e<this.rows;e++)this.setRow(e,this.getRow(e).sort(t));return this}sortColumns(t=h){for(let e=0;e<this.columns;e++)this.setColumn(e,this.getColumn(e).sort(t));return this}subMatrix(t,e,s,n){(0,l.J5)(this,t,e,s,n);let i=new u(e-t+1,n-s+1);for(let o=t;o<=e;o++)for(let e=s;e<=n;e++)i.set(o-t,e-s,this.get(o,e));return i}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 n=new u(t.length,s-e+1);for(let i=0;i<t.length;i++)for(let o=e;o<=s;o++){if(t[i]<0||t[i]>=this.rows)throw new RangeError(`Row index out of range: ${t[i]}`);n.set(i,o-e,this.get(t[i],o))}return n}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 n=new u(s-e+1,t.length);for(let i=0;i<t.length;i++)for(let o=e;o<=s;o++){if(t[i]<0||t[i]>=this.columns)throw new RangeError(`Column index out of range: ${t[i]}`);n.set(o-e,i,this.get(o,t[i]))}return n}setSubMatrix(t,e,s){if((t=u.checkMatrix(t)).isEmpty())return this;let n=e+t.rows-1,i=s+t.columns-1;(0,l.J5)(this,e,n,s,i);for(let n=0;n<t.rows;n++)for(let i=0;i<t.columns;i++)this.set(e+n,s+i,t.get(n,i));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 n=0;n<t.length;n++){let i=t[n];for(let t=0;t<e.length;t++){let o=e[t];s.set(n,t,this.get(i,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:i=this.mean(t)}=e;if("boolean"!=typeof s)throw new TypeError("unbiased must be a boolean");switch(t){case"row":if(!(0,n.N)(i))throw new TypeError("mean must be an array");return(0,a.we)(this,s,i);case"column":if(!(0,n.N)(i))throw new TypeError("mean must be an array");return(0,a._G)(this,s,i);case void 0:if("number"!=typeof i)throw new TypeError("mean must be a number");return(0,a.C)(this,s,i);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,n.N)(s))throw new TypeError("center must be an array");return(0,a.rU)(this,s),this;case"column":if(!(0,n.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,n.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,n.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 h(t,e){return t-e}c.prototype.klass="Matrix","undefined"!=typeof Symbol&&(c.prototype[Symbol.for("nodejs.util.inspect.custom")]=o.V),c.random=c.rand,c.randomInt=c.randInt,c.diagonal=c.diag,c.prototype.diagonal=c.prototype.diag,c.identity=c.eye,c.prototype.negate=c.prototype.neg,c.prototype.tensorProduct=c.prototype.kroneckerProduct;class u extends c{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,n.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 n=0;n<t;n++){if(s[n].length!==e)throw new RangeError("Inconsistent array dimensions");if(!s[n].every((t=>"number"==typeof t)))throw new TypeError("Input data contains non-numeric values");this.data.push(Float64Array.from(s[n]))}}}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 n=0;n<t;n++)s[n]=this.data[e][n];for(let n=t+1;n<this.columns;n++)s[n-1]=this.data[e][n];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 n=new Float64Array(this.columns+1);let i=0;for(;i<t;i++)n[i]=this.data[s][i];for(n[i++]=e[s];i<this.columns+1;i++)n[i]=this.data[s][i-1];this.data[s]=n}return this.columns+=1,this}}(0,r.z)(c,u)},9515:(t,e,s)=>{"use strict";s.d(e,{C:()=>m,DU:()=>y,Dm:()=>o,Mj:()=>C,PI:()=>l,Pr:()=>w,Pw:()=>a,Y2:()=>T,_G:()=>u,_f:()=>p,bQ:()=>i,kn:()=>f,mm:()=>g,rU:()=>d,tT:()=>c,td:()=>b,we:()=>h,xo:()=>r});var n=s(3018);function i(t){let e=(0,n.B4)(t.rows);for(let s=0;s<t.rows;++s)for(let n=0;n<t.columns;++n)e[s]+=t.get(s,n);return e}function o(t){let e=(0,n.B4)(t.columns);for(let s=0;s<t.rows;++s)for(let n=0;n<t.columns;++n)e[n]+=t.get(s,n);return e}function r(t){let e=0;for(let s=0;s<t.rows;s++)for(let n=0;n<t.columns;n++)e+=t.get(s,n);return e}function a(t){let e=(0,n.B4)(t.rows,1);for(let s=0;s<t.rows;++s)for(let n=0;n<t.columns;++n)e[s]*=t.get(s,n);return e}function l(t){let e=(0,n.B4)(t.columns,1);for(let s=0;s<t.rows;++s)for(let n=0;n<t.columns;++n)e[n]*=t.get(s,n);return e}function c(t){let e=1;for(let s=0;s<t.rows;s++)for(let n=0;n<t.columns;n++)e*=t.get(s,n);return e}function h(t,e,s){const n=t.rows,i=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(r,e)-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 u(t,e,s){const n=t.rows,i=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(e,r)-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 m(t,e,s){const n=t.rows,i=t.columns,o=n*i;let r=0,a=0,l=0;for(let e=0;e<n;e++)for(let n=0;n<i;n++)l=t.get(e,n)-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 n=0;n<t.columns;n++)t.set(s,n,t.get(s,n)-e[s])}function p(t,e){for(let s=0;s<t.rows;s++)for(let n=0;n<t.columns;n++)t.set(s,n,t.get(s,n)-e[n])}function g(t,e){for(let s=0;s<t.rows;s++)for(let n=0;n<t.columns;n++)t.set(s,n,t.get(s,n)-e)}function f(t){const e=[];for(let s=0;s<t.rows;s++){let n=0;for(let e=0;e<t.columns;e++)n+=Math.pow(t.get(s,e),2)/(t.columns-1);e.push(Math.sqrt(n))}return e}function y(t,e){for(let s=0;s<t.rows;s++)for(let n=0;n<t.columns;n++)t.set(s,n,t.get(s,n)/e[s])}function w(t){const e=[];for(let s=0;s<t.columns;s++){let n=0;for(let e=0;e<t.rows;e++)n+=Math.pow(t.get(e,s),2)/(t.rows-1);e.push(Math.sqrt(n))}return e}function C(t,e){for(let s=0;s<t.rows;s++)for(let n=0;n<t.columns;n++)t.set(s,n,t.get(s,n)/e[n])}function T(t){const e=t.size-1;let s=0;for(let n=0;n<t.columns;n++)for(let i=0;i<t.rows;i++)s+=Math.pow(t.get(i,n),2)/e;return Math.sqrt(s)}function b(t,e){for(let s=0;s<t.rows;s++)for(let n=0;n<t.columns;n++)t.set(s,n,t.get(s,n)/e)}},3018:(t,e,s)=>{"use strict";s.d(e,{B4:()=>u,J5:()=>h,Um:()=>a,ZR:()=>l,bp:()=>o,cT:()=>d,g:()=>c,on:()=>r,zb:()=>i});var n=s(5776);function i(t,e,s){let n=s?t.rows:t.rows-1;if(e<0||e>n)throw new RangeError("Row index out of range")}function o(t,e,s){let n=s?t.columns:t.columns-1;if(e<0||e>n)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,n.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 c(t,e){if(!(0,n.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 h(t,e,s,n,i){if(5!==arguments.length)throw new RangeError("expected 4 arguments");if(m("startRow",e),m("endRow",s),m("startColumn",n),m("endColumn",i),e>s||n>i||e<0||e>=t.rows||s<0||s>=t.rows||n<0||n>=t.columns||i<0||i>=t.columns)throw new RangeError("Submatrix indices are out of range")}function u(t,e=0){let s=[];for(let n=0;n<t;n++)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:()=>i});var n=s(1174);class i extends n.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,n=0;n<e.length;n++)if(e[n].identifier===t){s=n;break}return s}function n(t,n){for(var o={},r=[],a=0;a<t.length;a++){var l=t[a],c=n.base?l[0]+n.base:l[0],h=o[c]||0,u="".concat(c," ").concat(h);o[c]=h+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 p=i(d,n);n.byIndex=a,e.splice(a,0,{identifier:u,updater:p,references:1})}r.push(u)}return r}function i(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,i){var o=n(t=t||[],i=i||{});return function(t){t=t||[];for(var r=0;r<o.length;r++){var a=s(o[r]);e[a].references--}for(var l=n(t,i),c=0;c<o.length;c++){var h=s(o[c]);0===e[h].references&&(e[h].updater(),e.splice(h,1))}o=l}}},569:t=>{"use strict";var e={};t.exports=function(t,s){var n=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(!n)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");n.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 n="";s.supports&&(n+="@supports (".concat(s.supports,") {")),s.media&&(n+="@media ".concat(s.media," {"));var i=void 0!==s.layer;i&&(n+="@layer".concat(s.layer.length>0?" ".concat(s.layer):""," {")),n+=s.css,i&&(n+="}"),s.media&&(n+="}"),s.supports&&(n+="}");var o=s.sourceMap;o&&"undefined"!=typeof btoa&&(n+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(o))))," */")),e.styleTagTransform(n,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:()=>h});var n=s(4469),i=s(976),o=s(6414),r=s.n(o),a=s(6423),l=s(499);const c=31;async function h(t,e=!1,s){const o=l.Cn.getOrCreate(t);let h;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())h=await n.functions.call("HELM:getMolFiles",{col:t}),h=function(t,e,s=!1){const n=new Array(t.length);for(let i=0;i<t.length;i++){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(i);o=l.indexOf("\n",o)+1,o=l.indexOf("\n",o)+1,o=l.indexOf("\n",o)+1;const h=parseInt(l.substring(o,o+3)),u=parseInt(l.substring(o+3,o+6));a+=`M V30 COUNTS ${h} ${u} 0 0 0\n`,a+="M V30 BEGIN ATOM\n";for(let t=0;t<h;t++){o=l.indexOf("\n",o)+1+c,r=l.indexOf(" ",o);const n=l.substring(o,r);a+=s?`M V30 ${t+1} R${e.get(n)} 0.000 0.000 0 0\n`:`M V30 ${t+1} At 0.000 0.000 0 0 MASS=${e.get(n)}\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",n[i]=a}return n}(h,s,e);else{h=new Array(t.length);for(let n=0;n<t.length;n++){const t=u(r()(o.splitted[n]).filter((t=>""!==t)).toArray(),s,e);h[n]=t}}return i.Column.fromStrings("monomericMols",h)}function u(t,e,s=!1){let n="\n Datagrok macromolecule handler\n\n 0 0 0 0 0 0 999 V3000\nM V30 BEGIN CTAB\n";n+=`M V30 COUNTS ${t.length} ${t.length?t.length-1:0} 0 0 0\n`,n+="M V30 BEGIN ATOM\n";for(let i=0;i<t.length;i++)n+=s?`M V30 ${i+1} R${e.get(t[i])} 0.000 0.000 0 0\n`:`M V30 ${i+1} At 0.000 0.000 0 0 MASS=${e.get(t[i])}\n`;n+="M V30 END ATOM\n",n+="M V30 BEGIN BOND\n";for(let e=0;e<t.length-1;e++)n+=`M V30 ${e+1} 1 ${e+1} ${e+2}\n`;return n+="M V30 END BOND\n",n+="M V30 END CTAB\n",n+="M END",n}},3377:(t,e,s)=>{"use strict";s.d(e,{_package:()=>pt});var n=s(976),i=s(8467);(0,i.W3)("_first",(()=>{(0,i.Bu)("_first",(async()=>{}))}));var o=s(2012),r=s(9976),a=s(6137);(0,i.W3)("Palettes",(()=>{(0,i.Bu)("testPaletteN",(async()=>{await async function(){const t=a.J.Chromatogram;(0,i.l_)(t instanceof r.B,!0),(0,i.l_)(t instanceof a.J,!0)}()})),(0,i.Bu)("testPaletteAA",(async()=>{await async function(){const t=o.f.Lesk,e=o.f.RasMol,s=o.f.GrokGroups;(0,i.l_)(t instanceof r.B,!0),(0,i.l_)(e instanceof r.B,!0),(0,i.l_)(s instanceof r.B,!0),(0,i.l_)(t instanceof o.f,!0),(0,i.l_)(e instanceof o.f,!0),(0,i.l_)(s instanceof o.f,!0)}()})),(0,i.Bu)("testPalettePtMe",(async()=>{const t=o.f.GrokGroups.get("MeNle"),e=o.f.GrokGroups.get("MeA"),s=o.f.GrokGroups.get("MeG"),n=o.f.GrokGroups.get("MeF"),r=o.f.GrokGroups.get("L"),a=o.f.GrokGroups.get("A"),l=o.f.GrokGroups.get("G"),c=o.f.GrokGroups.get("F");(0,i.l_)(t,r),(0,i.l_)(e,a),(0,i.l_)(s,l),(0,i.l_)(n,c)}))}));var l=s(4469),c=s(6423),h=s(8447),u=s(499);async function m(t){const e=n.Column.fromList(n.TYPE.STRING,"col1",t);if(await l.functions.call("Bio:detectMacromolecule",{col:e}),e.semType===n.SEMTYPE.MACROMOLECULE){const t=`Negative test detected semType='${e.semType}', units='${e.getTag(n.TAGS.UNITS)}'.`;throw new Error(t)}}async function d(t,e){const s=(await t()).getCol(e),i=await l.functions.call("Bio:detectMacromolecule",{col:s});if(i&&(s.semType=i),s.semType===n.SEMTYPE.MACROMOLECULE){const t=`Negative test detected semType='${s.semType}', units='${s.getTag(n.TAGS.UNITS)}'.`;throw new Error(t)}}async function p(t,e,s,o,r,a,c=null){const h=n.Column.fromList(n.TYPE.STRING,"seq",t),m=await l.functions.call("Bio:detectMacromolecule",{col:h});m&&(h.semType=m),(0,i.l_)(h.semType,n.SEMTYPE.MACROMOLECULE),(0,i.l_)(h.getTag(n.TAGS.UNITS),e),(0,i.l_)(h.getTag("aligned"),s),(0,i.l_)(h.getTag("alphabet"),o),c&&(0,i.l_)(h.getTag("separator"),c);const d=u.Cn.getOrCreate(h);(0,i.l_)(d.getAlphabetSize(),r),(0,i.l_)(d.getAlphabetIsMultichar(),a),d.isHelm()||((0,i.l_)(d.aligned,s),(0,i.l_)(d.alphabet,o))}async function g(t,e,s,o,r,a,c,h=null){const m=(await t()).col(e),d=await l.functions.call("Bio:detectMacromolecule",{col:m});d&&(m.semType=d),(0,i.l_)(m.semType,n.SEMTYPE.MACROMOLECULE),(0,i.l_)(m.getTag(n.TAGS.UNITS),s),(0,i.l_)(m.getTag("aligned"),o),(0,i.l_)(m.getTag("alphabet"),r),h&&(0,i.l_)(m.getTag("separator"),h);const p=u.Cn.getOrCreate(m);(0,i.l_)(p.getAlphabetSize(),a),(0,i.l_)(p.getAlphabetIsMultichar(),c),p.isHelm()||((0,i.l_)(p.aligned,o),(0,i.l_)(p.alphabet,r))}(0,i.W3)("detectors",(()=>{var t,e,s,o,r,a,c,u,w,C,T,b,A,S,E,M,v,N,x,I;const L=new(I=class{constructor(){this[t]="id,col1\n1,\n2,\n3,\n4,\n5,",this[e]="col1\n1\n2\n3",this[s]="col1\n4\n5\n6\n7",this[o]="col1\n8\n9\n10\n11\n12",this[r]="col1\nCCCCN1C(=O)CN=C(c2cc(F)ccc12)C3CCCCC3\nC1CCCCC1\nCCCCCC",this[a]="seq\nACGTCACGTC\nCAGTGTCAGTGT\nTTCAACTTCAAC",this[c]="seq\nACGUCACGUC\nCAGUGUCAGUGU\nUUCAACUUCAAC",this[u]="seq\nFWPHEY\nYNRQWYV\nMKPSEYV",this[w]="seq\n[meI][hHis][Aca]NT[dE][Thr_PO3H2][Aca]DN\n[meI][hHis][Aca][Cys_SEt]T[dK][Thr_PO3H2][Aca][Tyr_PO3H2][Aca]\n[Lys_Boc][hHis][Aca][Cys_SEt]T[dK][Thr_PO3H2][Aca][Tyr_PO3H2][Aca]",this[C]="seq\nA*C*G*T*C*A*C*G*T*C\nC*A*G*T*G*T*C*A*G*T*G*T\nT*T*C*A*A*C*T*T*C*A*A*C",this[T]="seq\nA*C*G*U*C*A*C*G*U*C\nC*A*G*U*G*U*C*A*G*U*G*U\nU*U*C*A*A*C*U*U*C*A*A*C",this[b]="seq\nF-W-P-H-E-Y-F-W-P-H-E-Y\nY-N-R-Q-W-Y-V-Y-N-R-Q-W-Y-V\nM-K-P-S-E-Y-V-M-K-P-S-E-Y-V",this[A]="seq\nabc-dfgg-abc1-cfr3-rty-wert-cfr3-rty-wert\nrut12-her2-rty-wert-abc-abc1-dfgg-abc-abc1-dfgg\nrut12-rty-her2-abc-cfr3-wert-rut12-cfr3-wert-rut12",this[S]="seq\nabc/dfgg/abc1/cfr3/rty/wert/abc/dfgg/abc1/cfr3/rty/wert\nrut12/her2/rty/wert//abc/abc1/dfgg/rut12/her2/rty/wert//abc/abc1/dfgg\nrut12/rty/her2/abc/cfr3//wert/rut12/rut12/rty/her2/abc/cfr3//wert/rut12",this[E]="seq\nA-C--G-T--C-T-A-C--G-T--C-T\nC-A-C--T--G-T-C-A-C--T--G-T\nA-C-C-G-T-A-C-T-A-C-C-G-T-A-C-T",this[M]="seq\nm1-M-m3-mon4-mon5-N-T-MON8-N9-m1-M-m3-mon4-mon5-N-T-MON8-N9\nm1-mon2-m3-mon4-mon5-Num--MON8-N9-m1-mon2-m3-mon4-mon5-Num--MON8-N9\n\nmon1-M-mon3-mon4-mon5---MON8-N9-mon1-M-mon3-mon4-mon5---MON8-N9",this[v]="seq\nAc(1)-F-K(AEEA-AEEA-R-Ac)-L-mF-V-Y-mNle-D-W-N-mF-C(1)-G-NH2\nAc(1)-F-K(AEEA-ARRA-W-Ac)-L-mF-V-Y-mNle-D-W-N-mF-C(1)-G-NH2\nAc(1)-F-K(AEEA-AEEA-Ac)-L-mF-V-Y-mNle-D-W-N-mF-C(1)-G-NH2",this[N]="seq\nAC-GT-CTAC-GT-CT\nCAC-T-GTCAC-T-GT\nACCGTACTACCGTACT",this[x]="seq\nFWR-WYV-KHPFWR-WYV-KHP\nYNR-WYV-KHPYNR-WYV-KHP\nMWRSWY-CKHPMWRSWY-CKHP"}},t="negEmpty",e="neg1",s="neg2",o="neg3",r="negSmiles",a="csvFastaDna1",c="fastaRna1",u="fastaPt1",w="fastaUn",C="sepDna",T="sepRna",b="sepPt",A="sepUn1",S="sepUn2",E="sepMsaDna1",M="sepMsaUnWEmpty",v="sepComplex",N="fastaMsaDna1",x="fastaMsaPt1",I),P={fastaFasta:"System:AppData/Bio/data/sample_FASTA.fasta",fastaPtCsv:"System:AppData/Bio/data/sample_FASTA_PT.csv",msaComplex:"System:AppData/Bio/samples/MSA.csv",fastaCsv:"System:AppData/Bio/samples/FASTA.csv",helmCsv:"System:AppData/Bio/samples/HELM.csv",peptidesComplex:"System:AppData/Bio/tests/peptides_complex_msa.csv",peptidesSimple:"System:AppData/Bio/tests/peptides_simple_msa.csv",testDemogCsv:"System:AppData/Bio/tests/testDemog.csv",testHelmCsv:"System:AppData/Bio/tests/testHelm.csv",testIdCsv:"System:AppData/Bio/tests/testId.csv",testSmilesCsv:"System:AppData/Bio/tests/testSmiles.csv",testSmiles2Csv:"System:AppData/Bio/tests/testSmiles2.csv",testSmilesShort:"System:AppData/Bio/tests/testSmilesShort.csv",testActivityCliffsCsv:"System:AppData/Bio/tests/testActivityCliffs.csv",testCerealCsv:"System:AppData/Bio/tests/testCereal.csv",testUnichemSources:"System:AppData/Bio/tests/testUnichemSources.csv",testDmvOffices:"System:AppData/Bio/tests/testDmvOffices.csv",testAlertCollection:"System:AppData/Bio/tests/testAlertCollection.csv",testSpgi100:"System:AppData/Bio/tests/testSpgi100.csv",testSpgi:"System:AppData/Bio/tests/SPGI-derived.csv",testUrl:"System:AppData/Bio/tests/testUrl.csv"},R={};function _(t,e=O){return async()=>(t in R||(R[t]=(async()=>await e(P[t]))().catch((e=>{throw delete R[t],e}))),R[t])}async function O(t){const e=await l.dapi.files.readAsText(t);return n.DataFrame.fromCsv(e)}const G=t=>async()=>{const e=L[t],s=n.DataFrame.fromCsv(e);return await l.data.detectSemanticTypes(s),s};(0,i.Bu)("NegativeEmpty",(async()=>{await d(G("negEmpty"),"col1")})),(0,i.Bu)("Negative1",(async()=>{await d(G("neg1"),"col1")})),(0,i.Bu)("Negative2",(async()=>{await d(G("neg2"),"col1")})),(0,i.Bu)("Negative3",(async()=>{await d(G("neg3"),"col1")})),(0,i.Bu)("NegativeSmiles",(async()=>{await d(G("negSmiles"),"col1")})),(0,i.Bu)("NegativeStartEnd",(async()=>{await m(["START","END"])})),(0,i.Bu)("NegativeStartEndIntermediate",(async()=>{await m(["START","END","INTERMEDIATE"])})),(0,i.Bu)("FastaDna1",(async()=>{await g(G("csvFastaDna1"),"seq",h.r2.FASTA,"SEQ","DNA",4,!1)})),(0,i.Bu)("FastaRna1",(async()=>{await g(G("fastaRna1"),"seq",h.r2.FASTA,"SEQ","RNA",4,!1)})),(0,i.Bu)("FastaPt1",(async()=>{await g(G("fastaPt1"),"seq",h.r2.FASTA,"SEQ","PT",20,!1)})),(0,i.Bu)("FastaPtGaps",(()=>p(["FW-PH-EYY","FYNRQWYV-","FKP-Q-SEYV"],h.r2.FASTA,"SEQ","PT",20,!1))),(0,i.Bu)("FastaPtGapsMsa",(()=>p(["FW-PH-EYY","FYNRQWYV-","FKP-Q-SEY"],h.r2.FASTA,"SEQ.MSA","PT",20,!1))),(0,i.Bu)("FastaUn",(async()=>{await g(G("fastaUn"),"seq",h.r2.FASTA,"SEQ.MSA","UN",12,!0)})),(0,i.Bu)("FastaMsaDna1",(async()=>{await g(G("fastaMsaDna1"),"seq",h.r2.FASTA,"SEQ.MSA","DNA",4,!1)})),(0,i.Bu)("FastaMsaPt1",(async()=>{await g(G("fastaMsaPt1"),"seq",h.r2.FASTA,"SEQ.MSA","PT",20,!1)})),(0,i.Bu)("SepDna",(async()=>{await g(G("sepDna"),"seq",h.r2.SEPARATOR,"SEQ","DNA",4,!1,"*")})),(0,i.Bu)("SepRna",(async()=>{await g(G("sepRna"),"seq",h.r2.SEPARATOR,"SEQ","RNA",4,!1,"*")})),(0,i.Bu)("SepPt",(async()=>{await g(G("sepPt"),"seq",h.r2.SEPARATOR,"SEQ","PT",20,!1,"-")})),(0,i.Bu)("SepUn1",(async()=>{await g(G("sepUn1"),"seq",h.r2.SEPARATOR,"SEQ","UN",8,!0,"-")})),(0,i.Bu)("SepUn2",(async()=>{await g(G("sepUn2"),"seq",h.r2.SEPARATOR,"SEQ","UN",9,!0,"/")})),(0,i.Bu)("SepMsaN1",(async()=>{await g(G("sepMsaDna1"),"seq",h.r2.SEPARATOR,"SEQ.MSA","DNA",4,!1,"-")})),(0,i.Bu)("SepMsaUnWEmpty",(async()=>{await g(G("sepMsaUnWEmpty"),"seq",h.r2.SEPARATOR,"SEQ.MSA","UN",14,!0)})),(0,i.Bu)("SepComplex",(async()=>{await g(G("sepComplex"),"seq",h.r2.SEPARATOR,"SEQ","UN",18,!0)})),(0,i.Bu)("samplesFastaCsv",(async()=>{await y(_("fastaCsv"),{Sequence:new f(h.r2.FASTA,"SEQ","PT",20,!1)})})),(0,i.Bu)("samplesFastaFasta",(async()=>{await y(_("fastaFasta"),{sequence:new f(h.r2.FASTA,"SEQ","PT",20,!1)})})),(0,i.Bu)("samplesPeptidesComplex",(async()=>{await y(_("peptidesComplex"),{})})),(0,i.Bu)("samplesMsaComplex",(async()=>{await y(_("msaComplex"),{MSA:new f(h.r2.SEPARATOR,"SEQ.MSA","UN",161,!0,"/")})})),(0,i.Bu)("samplesIdCsv",(async()=>{await y(_("testIdCsv"),{})})),(0,i.Bu)("samplesSarSmallCsv",(async()=>{await y(_("testSmilesCsv"),{})})),(0,i.Bu)("samplesHelmCsv",(async()=>{await y(_("helmCsv"),{HELM:new f(h.r2.HELM,null,null,160,!0)})})),(0,i.Bu)("samplesTestHelmCsv",(async()=>{await y(_("testHelmCsv"),{"HELM string":new f(h.r2.HELM,null,null,9,!0)})})),(0,i.Bu)("samplesTestDemogCsv",(async()=>{await y(_("testDemogCsv"),{})})),(0,i.Bu)("samplesTestSmiles2Csv",(async()=>{await y(_("testSmiles2Csv"),{})})),(0,i.Bu)("samplesTestSmilesShort",(async()=>{await y(_("testSmilesShort"),{})})),(0,i.Bu)("samplesTestActivityCliffsNegativeSmiles",(async()=>{await y(_("testActivityCliffsCsv"),{})})),(0,i.Bu)("samplesFastaPtCsv",(async()=>{await y(_("fastaPtCsv"),{sequence:new f(h.r2.FASTA,"SEQ","PT",20,!1)})})),(0,i.Bu)("samplesTestCerealCsv",(async()=>{await y(_("testCerealCsv"),{})})),(0,i.Bu)("samplesTestUnichemSources",(async()=>{await y(_("testUnichemSources"),{})})),(0,i.Bu)("samplesTestDmvOffices",(async()=>{await y(_("testDmvOffices"),{})})),(0,i.Bu)("samplesTestAlertCollection",(async()=>{await y(_("testAlertCollection"),{})})),(0,i.Bu)("samplesTestSpgi",(async()=>{await y(_("testSpgi"),{})})),(0,i.Bu)("samplesTestSpgi100",(async()=>{await y(_("testSpgi100"),{})})),(0,i.Bu)("samplesTestUrl",(async()=>{await y(_("testUrl"),{})}))}));class f{constructor(t,e,s,n,i,o){this.units=t,this.aligned=e,this.alphabet=s,this.alphabetSize=n,this.alphabetIsMultichar=i,this.separator=o}}async function y(t,e){const s=await t(),n=[];for(const i of s.columns.names())if(i in e){const s=e[i];try{await g(t,i,s.units,s.aligned,s.alphabet,s.alphabetSize,s.alphabetIsMultichar,s.separator)}catch(t){const e=t.toString();n.push(`Positive col '${i}' failed: ${e}`)}}else try{await d(t,i)}catch(t){const e=t.toString();n.push(`Negative col '${i}' failed: ${e}`)}if(n.length>0)throw new Error(n.join("\n"))}(0,i.W3)("detectors:weak-and-likely",(()=>{const t={fastaDnaWeak1:"id,colName\n1,TTTTTTTTTT\n2,TTTTTTTTTT\n3,TTTTTTTTTT\n4,TTTTTTTTTT",fastaDnaWeak1LikelyName:"id,seq\n1,TTTTTTT\n2,TTTTTTT\n3,TTTTTTT\n4,TTTTTTT",fastaRnaWeak1:"id,colName\n1,UUUUUUUUUU\n2,UUUUUUUUUU\n3,UUUUUUUUUU\n4,UUUUUUUUUU",fastaRnaWeak1LikelyName:"id,seq\n1,UUUUUUU\n2,UUUUUUU\n3,UUUUUUU\n4,UUUUUUU",fastaPtWeak1:"id,colName\n1,SLSLSPGKSLSLSPGK\n2,SLSLSPGKSLSLSPGK\n3,SLSLSPGKSLSLSPGK\n4,SLSLSPGKSLSLSPGK",fastaPtWeak1LikelyName:"id,seq\n1,SLSLSPGKSLSLSPGK\n2,SLSLSPGKSLSLSPGK\n3,SLSLSPGKSLSLSPGK\n4,SLSLSPGKSLSLSPGK",fastaUn1:"id,colName\n1,word\n2,other\n3,some\n4,another",fastaUn1LikelyName:"id,seq\n1,word\n2,other\n3,some\n4,another",fastaUn2LikelyName:'protein\nBoombastic\nMegafantastic\n"just-a-random-thought,oy!"',fastaUnMsa1LikelyName:"id,seq\n1,word\n2,male\n3,bare\n4,core"},e=e=>async()=>{const s=t[e],i=n.DataFrame.fromCsv(s);return await l.data.detectSemanticTypes(i),i};(0,i.Bu)("fastaDnaWeak1",(async()=>{await d(e("fastaDnaWeak1"),"colName")})),(0,i.Bu)("fastaDnaWeak1LikelyName",(async()=>{await g(e("fastaDnaWeak1LikelyName"),"seq",h.r2.FASTA,"SEQ.MSA","DNA",4,!1)})),(0,i.Bu)("fastaRnaWeak1",(async()=>{await d(e("fastaRnaWeak1"),"colName")})),(0,i.Bu)("fastaRnaWeak1LikelyName",(async()=>{await g(e("fastaRnaWeak1LikelyName"),"seq",h.r2.FASTA,"SEQ.MSA","RNA",4,!1)})),(0,i.Bu)("fastaPtWeak1",(async()=>{await d(e("fastaPtWeak1"),"colName")})),(0,i.Bu)("fastaPtWeak1LikelyName",(async()=>{await g(e("fastaPtWeak1LikelyName"),"seq",h.r2.FASTA,"SEQ.MSA","PT",20,!1)})),(0,i.Bu)("fastaUn1",(async()=>{await d(e("fastaUn1"),"colName")})),(0,i.Bu)("fastaUn1LikelyName",(async()=>{await d(e("fastaUn1LikelyName"),"seq")})),(0,i.Bu)("fastaUn2LikelyName",(async()=>{await d(e("fastaUn2LikelyName"),"protein")})),(0,i.Bu)("fastaUnMsa1LikelyName",(async()=>{await d(e("fastaUnMsa1LikelyName"),"seq")}))})),(0,i.W3)("detectorsBenchmark",(()=>{let t;async function e(e,o,r,a,l,c){return await async function(e,i,u,m){const d=(()=>{const e=function(t,e,s,i,o){let r;switch(t){case h.r2.FASTA:r=t=>{let e="";for(let s=0;s<t.length;s++){const n=t[s];e+=1==n.length?n:`[${n}]`}return e};break;case h.r2.SEPARATOR:r=(t,e)=>t.join(e);break;default:throw new Error(`Not supported notation '${t}'.`)}const a=(t,e)=>{const s=new Array(e);for(let n=0;n<e;n++)s[n]=t[Math.floor(Math.random()*t.length)];return r(s,o)},l=Array(i);for(let t=0;t<i;t++)l[t]=a(e,s);return n.Column.fromStrings("seq",l)}(o,[...(0,h.gM)(r)],a,l,c),i=t.prepare({col:e});return s(i),i})(),p=Date.now(),g=await(async t=>s(t))(d),f=Date.now();m(g);const y=f-p;if(y>e){const t=`ET ${y} ms is more than max allowed ${e} ms.`;throw console.error(t),new Error(t)}return console.log(`ET ${y} ms is OK.`),y}(e,0,0,(t=>{!function(t,e){const s=u.Cn.getOrCreate(t);(0,i.l_)(t.semType===e.semType,!0),(0,i.l_)(s.notation===e.notation,!0),(0,i.l_)(s.alphabet===e.alphabet,!0),(0,i.l_)(s.separator===e.separator,!0)}(t,{semType:n.SEMTYPE.MACROMOLECULE,notation:o,alphabet:r,separator:c})}))}function s(t){t.callSync();const e=t.getOutputParamValue(),s=t.inputs.col;return e&&(s.semType=e),s}(0,i.bb)((async()=>{const e=n.Func.find({package:"Bio",name:"detectMacromolecule"});t=e[0];const s=n.Column.fromStrings("seq",["ACGT","ACGT","ACGT"]);await t.prepare({col:s}).call()})),(0,i.Bu)("fastaDnaShorts50Few50",(async()=>{await e(10,h.r2.FASTA,"DNA",50,50)})),(0,i.Bu)("fastaDnaShorts50Many1E6",(async()=>{await e(20,h.r2.FASTA,"DNA",50,1e6)})),(0,i.Bu)("fastaDnaLong1e6Few50",(async()=>{await e(20,h.r2.FASTA,"DNA",1e6,50)})),(0,i.Bu)("separatorDnaShorts50Few50",(async()=>{await e(10,h.r2.SEPARATOR,"DNA",50,50,"/")})),(0,i.Bu)("separatorDnaShorts50Many1E6",(async()=>{await e(20,h.r2.SEPARATOR,"DNA",50,1e6,"/")})),(0,i.Bu)("separatorDnaLong1e6Few50",(async()=>{await e(20,h.r2.SEPARATOR,"DNA",1e6,50,"/")}))}));var w=s(6098),C=s(525);async function T(t){const e=await async function(t){return await pt.files.readAsText(t)}(t),s=n.DataFrame.fromCsv(e);return s.name=t.replace(".csv",""),s}async function b(t=1e4){const e=await l.dapi.docker.dockerContainers.filter("bio").first();"started"!==e.status&&"checking"!==e.status&&await(0,i.gw)(t)}async function A(t,e){const s=n.DataFrame.fromCsv(t),o=n.DataFrame.fromCsv(e),r=s.getCol("seq"),a=await l.functions.call("Bio:detectMacromolecule",{col:r});a&&(r.semType=a);const c=o.getCol("seq"),h=await(0,w.U)(r,!0);(0,i.f6)(h.toList(),c.toList())}async function S(t,e,s,o,r,a){const c=n.DataFrame.fromCsv(t),h=n.DataFrame.fromCsv(e),u=c.getCol("seq"),m=h.getCol("seq"),d=c.getCol("seq"),p=await l.functions.call("Bio:detectMacromolecule",{col:d});p&&(d.semType=p),await l.data.detectSemanticTypes(c),(0,i.l_)(u.semType,n.SEMTYPE.MACROMOLECULE),(0,i.l_)(u.getTag(n.TAGS.UNITS),s),r&&(0,i.l_)(u.getTag("alphabet"),r);const g=await(0,C.K)({col:u,pepsea:{method:a}});(0,i.l_)(g.semType,n.SEMTYPE.MACROMOLECULE),(0,i.l_)(g.getTag(n.TAGS.UNITS),o),(0,i.l_)(g.getTag("aligned"),"SEQ.MSA"),r&&(0,i.l_)(g.getTag("alphabet"),r),(0,i.f6)(g.toList(),m.toList())}(0,i.W3)("MSA",(async()=>{(0,i.Bu)("isCorrect",(async()=>{await A("seq\nFWRWYVKHP\nYNRWYVKHP\nMWRSWYCKHP","seq\nFWR-WYVKHP\nYNR-WYVKHP\nMWRSWYCKHP")})),(0,i.Bu)("isCorrectLong",(async()=>{await A("seq\nFWRWYVKHPFWRWYVKHPFWRWYVKHPFWRWYVKHPFWRWYVKHPFWRWYVKHPFWRWYVKHPFWRWYVKHP\nYNRWYVKHPYNRWYVKHPYNRWYVKHPYNRWYVKHPYNRWYVKHPYNRWYVKHPYNRWYVKHPYNRWYVKHP\nMWRSWYCKHPMWRSWYCKHPMWRSWYCKHPMWRSWYCKHPMWRSWYCKHPMWRSWYCKHPMWRSWYCKHPMWRSWYCKHP","seq\nFWR-WYVKHPFWR-WYVKHPFWR-WYVKHPFWR-WYVKHPFWR-WYVKHPFWR-WYVKHPFWR-WYVKHPFWR-WYVKHP\nYNR-WYVKHPYNR-WYVKHPYNR-WYVKHPYNR-WYVKHPYNR-WYVKHPYNR-WYVKHPYNR-WYVKHPYNR-WYVKHP\nMWRSWYCKHPMWRSWYCKHPMWRSWYCKHPMWRSWYCKHPMWRSWYCKHPMWRSWYCKHPMWRSWYCKHPMWRSWYCKHP")})),(0,i.Bu)("isCorrectHelm",(async()=>{await b(),await S("seq\n PEPTIDE1{meI.hHis.Aca.N.T.dE.Thr_PO3H2}$$$$\n PEPTIDE1{meI.Aca.N.T.dE.Thr_PO3H2}$$$$\n PEPTIDE1{hHis.Aca.N.T.dE.Thr_PO3H2}$$$$","seq\n meI.hHis.Aca.N.T.dE.Thr_PO3H2\n .meI.Aca.N.T.dE.Thr_PO3H2\n .hHis.Aca.N.T.dE.Thr_PO3H2",h.r2.HELM,h.r2.SEPARATOR,void 0,"mafft")}),{skipReason:"GROK-13221"}),(0,i.Bu)("isCorrectHelmLong",(async()=>{await b(),await S("seq\n PEPTIDE1{meI.hHis.Aca.N.T.dE.Thr_PO3H2.Aca.D-Tyr_Et.dV.E.N.D-Orn.D-aThr.Phe_4Me.Thr_PO3H2}$$$$\n PEPTIDE1{meI.hHis.Aca.Cys_SEt.T.dK.Tyr_PO3H2.D-Chg.dV.Phe_ab-dehydro.N.D-Orn.D-aThr.Phe_4Me}$$$$\n PEPTIDE1{Lys_Boc.hHis.Aca.Cys_SEt.T.dK.Tyr_PO3H2.D-Chg.dV.Thr_PO3H2.N.D-Orn.D-aThr.Phe_4Me}$$$$","seq\n meI.hHis.Aca.N.T.dE.Thr_PO3H2.Aca.D-Tyr_Et.dV.E.N.D-Orn.D-aThr.Phe_4Me.Thr_PO3H2\n meI.hHis.Aca.Cys_SEt.T.dK..Tyr_PO3H2.D-Chg.dV.Phe_ab-dehydro.N.D-Orn.D-aThr.Phe_4Me.\n Lys_Boc.hHis.Aca.Cys_SEt.T.dK..Tyr_PO3H2.D-Chg.dV.Thr_PO3H2.N.D-Orn.D-aThr.Phe_4Me.",h.r2.HELM,h.r2.SEPARATOR,void 0,"mafft")}),{skipReason:"GROK-13221"}),(0,i.Bu)("isCorrectSeparator",(async()=>{await S("seq\n F-W-P-H-E-Y\n Y-N-R-Q-W-Y-V\n M-K-P-S-E-Y-V","seq\n FWPHEY-\n YNRQWYV\n MKPSEYV",h.r2.SEPARATOR,h.r2.FASTA,"PT")})),(0,i.Bu)("isCorrectSeparatorLong",(async()=>{await S("seq\n M-I-E-V-F-L-F-G-I-V-L-G-L-I-P-I-T-L-A-G-L-F-V-T-A-Y-L-Q-Y-R-R-G-D-Q-L-D-L\n M-M-E-L-V-L-K-T-I-I-G-P-I-V-V-G-V-V-L-R-I-V-D-K-W-L-N-K-D-K\n M-D-R-T-D-E-V-S-N-H-T-H-D-K-P-T-L-T-W-F-E-E-I-F-E-E-Y-H-S-P-F-H-N","seq\n MIEV-FLFGIVLGLIPITLAGLFVTAYLQYRRGDQLDL\n MMEL-VLKTII-GPIVVGVVLRIVDKWLNKDK------\n MDRTDEVSNHTHDKPTLTWFEEIFEEYHSPFHN-----",h.r2.SEPARATOR,h.r2.FASTA,"PT")}))}));var E=s(3553),M=s(9416);async function v(t,e){const s=(0,h.kB)(t);console.debug(`Bio: tests: splitters: src=${JSON.stringify(t)}, res=${JSON.stringify(s)} .`),(0,i.f6)(s,e)}async function N(t,e){const s=(0,h.gP)(t);console.debug(`Bio: tests: splitters: src=${JSON.stringify(t)}, res=${JSON.stringify(s)} .`),(0,i.f6)(s,e)}(0,i.W3)("splitters",(async()=>{(0,i.bb)((async()=>{})),(0,i.X5)((async()=>{}));const t=["M[MeI]YKETLL[MeF]PKTDFPMRGGL[MeA]",["M","MeI","Y","K","E","T","L","L","MeF","P","K","T","D","F","P","M","R","G","G","L","MeA"]],e=["[meI][Pip][dK][Thr_PO3H2][L-hArg(Et,Et)][D-Tyr_Et][Tyr_ab-dehydroMe][dV]EN[D-Orn][D-aThr][Phe_4Me]",["meI","Pip","dK","Thr_PO3H2","L-hArg(Et,Et)","D-Tyr_Et","Tyr_ab-dehydroMe","dV","E","N","D-Orn","D-aThr","Phe_4Me"]],s=["PEPTIDE1{meI.hHis.Aca.N.T.dE.Thr_PO3H2.Aca.D-Tyr_Et.Tyr_ab-dehydroMe.dV.E.N.D-Orn.D-aThr.Phe_4Me}$$$",["meI","hHis","Aca","N","T","dE","Thr_PO3H2","Aca","D-Tyr_Et","Tyr_ab-dehydroMe","dV","E","N","D-Orn","D-aThr","Phe_4Me"]],o=["PEPTIDE1{meI.hHis.Aca.N.T.dK.Thr_PO3H2.Aca.D-Tyr_Et.D-Dap.dV.E.N.pnG.Phe_4Me}$$$",["meI","hHis","Aca","N","T","dK","Thr_PO3H2","Aca","D-Tyr_Et","D-Dap","dV","E","N","pnG","Phe_4Me"]],r=["PEPTIDE1{[meI].[hHis].[Aca].N.T.[dK].[Thr_PO3H2].[Aca].[D-Tyr_Et].[D-Dap].[dV].E.N.[pnG].[Phe_4Me]}$$$",["meI","hHis","Aca","N","T","dK","Thr_PO3H2","Aca","D-Tyr_Et","D-Dap","dV","E","N","pnG","Phe_4Me"]],a=["RNA1{R(U)P.R(T)P.R(G)P.R(C)P.R(A)}$$$$",["R(U)P","R(T)P","R(G)P","R(C)P","R(A)"]],h=["RNA1{P.R(U)P.R(T)}$$$$",["P","R(U)P","R(T)"]],u=["RNA1{P.R(U).P.R(T)}$$$$",["P","R(U)","P","R(T)"]];(0,i.Bu)("fastaMulti",(async()=>{await v(t[0],t[1])})),(0,i.Bu)("fastaFromHelm",(async()=>{await v(e[0],e[1])})),(0,i.Bu)("helm1",(async()=>{await N(s[0],s[1])})),(0,i.Bu)("helm2",(async()=>{await N(o[0],o[1])})),(0,i.Bu)("helm3-multichar",(async()=>{await N(r[0],r[1])})),(0,i.Bu)("testHelm1",(async()=>{await N(a[0],a[1])})),(0,i.Bu)("testHelm2",(async()=>{await N(h[0],h[1])})),(0,i.Bu)("testHelm3",(async()=>{await N(u[0],u[1])})),(0,i.Bu)("splitToMonomers",(async()=>{const t=await l.dapi.files.readCsv("System:AppData/Bio/samples/MSA.csv"),e=t.getCol("MSA"),s=await l.functions.call("Bio:detectMacromolecule",{col:e});s&&(e.semType=s),e.setTag("aligned",E.mU);const n=await(0,M.n)(t,e);(0,i.l_)(n.columns.names().includes("17"),!0),await l.data.detectSemanticTypes(n);const o=l.shell.addTableView(n);await(0,i.ow)((()=>o.grid.dataFrame!=t),"View grid has wrong data frame",100)})),(0,i.Bu)("getHelmMonomers",(async()=>{const t=n.DataFrame.fromCsv("HELM,Activity\nPEPTIDE1{hHis.N.T}$$$,5.30751\nPEPTIDE1{hHis.Aca.Cys_SEt}$$$,5.72388\n");await l.data.detectSemanticTypes(t);const e=["hHis","Aca","Cys_SEt","N","T"],s=t.getCol("HELM"),i=(0,c.getHelmMonomers)(s),o=e.filter((t=>!i.includes(t))),r=i.filter((t=>!e.includes(t)));if(o.length>0||r.length){const t=[];throw o.length>0&&t.push(`Missed monomers ${JSON.stringify(o)}.`),r.length>0&&t.push(`Unexpected monomers ${JSON.stringify(r)}.`),new Error(t.join(" "))}}))}));var x=s(7228),I=s(6584),L=s(2918);(0,i.W3)("monomerLibraries",(()=>{let t,e=null;(0,i.bb)((async()=>{t=await(0,x.JN)(),e=(0,I.nW)()})),(0,i.X5)((async()=>{await(0,I.tW)(e)})),(0,i.Bu)("default",(async()=>{await(0,I.tW)({exclude:[],explicit:[]}),await t.loadLibraries(!0);const e=t.getBioLib();(0,i.l_)(e.getPolymerTypes().length>0,!0)})),(0,i.Bu)("forTests",(async()=>{await(0,I.tb)(),await t.loadLibraries(!0);const e=t.getBioLib();(0,i.l_)(e.getPolymerTypes().length,2),(0,i.l_)(e.getMonomerSymbolsByType("PEPTIDE").length,322),(0,i.l_)(e.getMonomerSymbolsByType("RNA").length,383)})),(0,i.Bu)("empty",(async()=>{const e=await(0,I.nW)(),s=await(0,L.P4)();e.exclude=s,e.explicit=[],await(0,I.tW)(e),await t.loadLibraries(!0);const n=t.getBioLib();(0,i.l_)(0===n.getPolymerTypes().length,!0),n.getMonomerMolsByPolymerType("PEPTIDE")}))}));var P=s(4004);function R(){const t=[];return t.push(n.Column.fromList("string","MSA",new Array(10**6).fill("meI/hHis/Aca/N/T/dE/Thr_PO3H2/Aca/D-Tyr_Et/Tyr_ab-dehydroMe/dV/E/N/D-Orn/D-aThr//Phe_4Me"))),t.push(n.Column.fromList("string","Activity",new Array(10**6).fill("5.30751"))),t}function _(){const t=[],e="meI/hHis/Aca/N/T/dE/Thr_PO3H2/Aca/D-Tyr_Et/Tyr_ab-dehydroMe/dV/E/N/D-Orn/D-aThr".repeat(10**5);return t.push(n.Column.fromList("string","MSA",new Array(100).fill(e))),t.push(n.Column.fromList("string","Activity",new Array(100).fill("7.30751"))),t}async function O(t,e){const s=t(),o=n.DataFrame.fromColumns(s);await l.data.detectSemanticTypes(o);const r=Date.now(),a=(o.columns.byName("MSA"),l.shell.addTableView(o));await(0,i.ow)((()=>a.grid.dataFrame!==o),"View grid has wrong data frame ",100);const c=Date.now()-r;console.log(`Performance test: ${e}: ${c}ms`)}(0,i.W3)("renderers",(()=>{(0,i.Bu)("long sequence performance ",(async()=>{await O(_,"Long sequences")})),(0,i.Bu)("many sequence performance",(async()=>{await O(R,"Many sequences")})),(0,i.Bu)("many sequence performance",(async()=>{await O(R,"Many sequences")})),(0,i.Bu)("rendererMacromoleculeFasta",(async()=>{await async function(){const t=await l.dapi.files.readAsText("System:AppData/Bio/samples/FASTA.csv"),e=n.DataFrame.fromCsv(t),s=e.getCol("Sequence"),o=await l.functions.call("Bio:detectMacromolecule",{col:s});o&&(s.semType=o);const r=l.shell.addTableView(e);await l.data.detectSemanticTypes(e),await(0,i.ow)((()=>r.grid.dataFrame!=e),"View grid has wrong data frame",100);const a=s.getTag(n.TAGS.CELL_RENDERER);(0,i.l_)(a,"sequence")}()})),(0,i.Bu)("rendererMacromoleculeSeparator",(async()=>{await async function(){const t=await l.dapi.files.readAsText("System:AppData/Bio/data/sample_SEPARATOR_PT.csv"),e=n.DataFrame.fromCsv(t),s=e.getCol("sequence"),o=await l.functions.call("Bio:detectMacromolecule",{col:s});o&&(s.semType=o);const r=l.shell.addTableView(e);await l.data.detectSemanticTypes(e),await(0,i.ow)((()=>r.grid.dataFrame!=e),"View grid has wrong data frame",100);const a=s.getTag(n.TAGS.CELL_RENDERER);(0,i.l_)(a,"sequence")}()})),(0,i.Bu)("rendererMacromoleculeDifference",(async()=>{await async function(){const t=n.Column.fromStrings("SequencesDiff",["meI/hHis/Aca/N/T/dK/Thr_PO3H2/Aca#D-Tyr_Et/Tyr_ab-dehydroMe/meN/E/N/dV"]);t.setTag(n.TAGS.UNITS,h.r2.SEPARATOR),t.setTag("separator","/"),t.setTag("aligned","SEQ"),t.setTag("alphabet","UN"),t.setTag(".alphabetIsMultichar","true"),t.semType=E.Of.MACROMOLECULE_DIFFERENCE;const e=n.DataFrame.fromColumns([t]),s=l.shell.addTableView(e);await l.data.detectSemanticTypes(e),await(0,i.ow)((()=>s.grid.dataFrame!=e),"View grid has wrong data frame",100);const o=t.getTag(n.TAGS.CELL_RENDERER);(0,i.l_)(o,E.Of.MACROMOLECULE_DIFFERENCE)}()})),(0,i.Bu)("afterMsa",(async()=>{await async function(){const t=await l.dapi.files.readAsText("System:AppData/Bio/data/sample_FASTA.fasta"),e=(0,c.importFasta)(t)[0],s=e.getCol("sequence"),o=await l.functions.call("Bio:detectMacromolecule",{col:s});o&&(s.semType=o);const r=l.shell.addTableView(e);await l.data.detectSemanticTypes(e),console.log("Bio: tests/renderers/afterMsa, table view"),await(0,i.ow)((()=>r.grid.dataFrame!=e),"View grid has wrong data frame",100),console.log(`Bio: tests/renderers/afterMsa, src before test semType="${s.semType}", units="${s.getTag(n.TAGS.UNITS)}", cell.renderer="${s.getTag(n.TAGS.CELL_RENDERER)}"`),(0,i.l_)(s.semType,n.SEMTYPE.MACROMOLECULE),(0,i.l_)(s.getTag(n.TAGS.UNITS),h.r2.FASTA),(0,i.l_)(s.getTag("aligned"),"SEQ"),(0,i.l_)(s.getTag("alphabet"),"PT"),(0,i.l_)(s.getTag(n.TAGS.CELL_RENDERER),"sequence");const a=await(0,C.K)({col:s});r.grid.invalidate(),await(0,i.ow)((()=>r.grid.dataFrame!=e),"View grid has wrong data frame",100),(0,i.l_)(a.semType,n.SEMTYPE.MACROMOLECULE),(0,i.l_)(a.getTag(n.TAGS.UNITS),h.r2.FASTA),(0,i.l_)(a.getTag("aligned"),"SEQ.MSA"),(0,i.l_)(a.getTag("alphabet"),"PT"),(0,i.l_)(a.getTag(n.TAGS.CELL_RENDERER),"sequence"),u.Cn.getOrCreate(a)}()})),(0,i.Bu)("afterConvert",(async()=>{await async function(){const t=await l.dapi.files.readAsText("System:AppData/Bio/data/sample_FASTA_PT.csv"),e=n.DataFrame.fromCsv(t),s=e.col("sequence"),o=await l.functions.call("Bio:detectMacromolecule",{col:s});o&&(s.semType=o);const r=l.shell.addTableView(e);await l.data.detectSemanticTypes(e);const a=await(0,P.o)(s,h.r2.SEPARATOR,"/");await(0,i.ow)((()=>r.grid.dataFrame!=e),"View grid has wrong data frame",100);const c=a.getTag(n.TAGS.CELL_RENDERER);(0,i.l_)(c,"sequence"),u.Cn.getOrCreate(a)}()})),(0,i.Bu)("selectRendererBySemType",(async()=>{await async function(){const t=n.Column.fromStrings("SequencesDiff",["meI/hHis/Aca/N/T/dK/Thr_PO3H2/Aca#D-Tyr_Et/Tyr_ab-dehydroMe/meN/E/N/dV"]);t.setTag(n.TAGS.UNITS,h.r2.SEPARATOR),t.setTag("separator","/"),t.setTag("aligned","SEQ"),t.setTag("alphabet","UN"),t.setTag(".alphabetIsMultichar","true"),t.semType=E.Of.MACROMOLECULE_DIFFERENCE;const e=n.DataFrame.fromColumns([t]);l.shell.addTableView(e),await(0,i.gw)(100);const s=t.getTag(n.TAGS.CELL_RENDERER);if("MacromoleculeDifference"!==s)throw new Error(`Units 'separator', separator '/' and semType 'MacromoleculeDifference' have been manually set on column but after df was added as table, view renderer has set to '${s}' instead of correct 'MacromoleculeDifference'.`)}()}))}));var G=s(6414),F=s.n(G),D=s(9611);(0,i.W3)("renderers: monomerPlacer",(()=>{const t={splitter:{csv:"id,seq\nid1,m1-M-m3-mon4-mon5-N-T-MON8-N9\nid2,m1-mon2-m3-mon4-mon5-Num-MON8-N9\nid3,mon1-M-mon3-mon4-mon5-MON8-N9\n",testList:[{src:{row:0,x:-1},tgt:{pos:null}},{src:{row:1,x:0},tgt:{pos:null}},{src:{row:1,x:5},tgt:{pos:0}},{src:{row:1,x:6},tgt:{pos:0}},{src:{row:1,x:26},tgt:{pos:1}},{src:{row:1,x:160},tgt:{pos:6}},{src:{row:1,x:185},tgt:{pos:7}},{src:{row:2,x:140},tgt:{pos:5}},{src:{row:2,x:145},tgt:{pos:5}}]},splitterMsa:{csv:"id,seq\nid1,m1-M-m3-mon4-mon5-N-T-MON8-N9\nid2,m1-mon2-m3-mon4-mon5-Num--MON8-N9\nid3,\nid4,mon1-M-mon3-mon4-mon5---MON8-N9\n",testList:[{src:{row:0,x:-1},tgt:{pos:null}},{src:{row:1,x:0},tgt:{pos:null}},{src:{row:1,x:1},tgt:{pos:null}},{src:{row:1,x:4},tgt:{pos:null}},{src:{row:1,x:5},tgt:{pos:0}},{src:{row:1,x:37},tgt:{pos:0}},{src:{row:1,x:38},tgt:{pos:1}},{src:{row:1,x:170},tgt:{pos:4}},{src:{row:1,x:200},tgt:{pos:5}},{src:{row:2,x:20},tgt:{pos:null}},{src:{row:3,x:170},tgt:{pos:4}},{src:{row:3,x:200},tgt:{pos:5}},{src:{row:3,x:282},tgt:{pos:null}}]},fastaMsa:{csv:"id,seq\nid1,QQYNIYPLT\nid2,QQWSSFPYT\nid3,\nid3,QHIRE--LT\n",testList:[{src:{row:1,x:-1},tgt:{pos:null}},{src:{row:1,x:0},tgt:{pos:null}},{src:{row:1,x:1},tgt:{pos:null}},{src:{row:1,x:19},tgt:{pos:0}},{src:{row:1,x:170},tgt:{pos:8}},{src:{row:1,x:171},tgt:{pos:8}},{src:{row:2,x:5},tgt:{pos:null}},{src:{row:3,x:170},tgt:{pos:8}},{src:{row:3,x:181},tgt:{pos:null}}]}};for(const[e,s]of Object.entries(t))(0,i.Bu)(`getPosition-${e}`,(async()=>{const t=n.DataFrame.fromCsv(s.csv);await l.data.detectSemanticTypes(t);const e=t.getCol("seq"),i=new D.A(null,e,(()=>({unitsHandler:u.Cn.getOrCreate(e),monomerCharWidth:7,separatorWidth:12,monomerToShort:h.GU,monomerLengthLimit:3}))),o=s.testList;for(let t=0;t<e.length;++t)i.getCellMonomerLengths(t);const r=[];for(const[t,e]of F().enumerate(o)){const e={pos:i.getPosition(t.src.row,t.src.x)};t.tgt.pos!=e.pos&&r.push(`Test src ${JSON.stringify(t.src)} expected tgt ${JSON.stringify(t.tgt)}, but get ${JSON.stringify({res:e})}`)}if(r.length>0)throw new Error("Test failed error(s):\n"+r.join(", n"))}))})),(0,i.W3)("converters",(()=>{let t;!function(t){t.fastaPt="fastaPt",t.separatorPt="separatorPt",t.helmPt="helmPt",t.fastaDna="fastaDna",t.separatorDna="separatorDna",t.helmDna="helmDna",t.fastaRna="fastaRna",t.separatorRna="separatorRna",t.helmRna="helmRna",t.fastaGaps="fastaGaps",t.separatorGaps="separatorGaps",t.helmGaps="helmGaps",t.fastaUn="fastaUn",t.separatorUn="separatorUn",t.helmUn="helmUn",t.helmLoneDeoxyribose="helmLoneDeoxyribose",t.helmLoneRibose="helmLoneRibose",t.helmLonePhosphorus="helmLonePhosphorus",t.fastaLoneDeoxyribose="fastaLoneDeoxyribose",t.fastaLoneRibose="fastaLoneRibose",t.fastaLonePhosphorus="fastaLonePhosphorus"}(t||(t={}));const e={[t.fastaPt]:"seq\nFWPHEYFWPHEY\nYNRQWYVYNRQWYV\nMKPSEYVMKPSEYV",[t.separatorPt]:"seq\nF-W-P-H-E-Y-F-W-P-H-E-Y\nY-N-R-Q-W-Y-V-Y-N-R-Q-W-Y-V\nM-K-P-S-E-Y-V-M-K-P-S-E-Y-V",[t.helmPt]:"seq\nPEPTIDE1{F.W.P.H.E.Y.F.W.P.H.E.Y}$$$$\nPEPTIDE1{Y.N.R.Q.W.Y.V.Y.N.R.Q.W.Y.V}$$$$\nPEPTIDE1{M.K.P.S.E.Y.V.M.K.P.S.E.Y.V}$$$$",[t.fastaDna]:"seq\nACGTCACGTC\nCAGTGTCAGTGT\nTTCAACTTCAAC",[t.separatorDna]:"seq\nA/C/G/T/C/A/C/G/T/C\nC/A/G/T/G/T/C/A/G/T/G/T\nT/T/C/A/A/C/T/T/C/A/A/C",[t.helmDna]:"seq\nRNA1{d(A)p.d(C)p.d(G)p.d(T)p.d(C)p.d(A)p.d(C)p.d(G)p.d(T)p.d(C)p}$$$$\nRNA1{d(C)p.d(A)p.d(G)p.d(T)p.d(G)p.d(T)p.d(C)p.d(A)p.d(G)p.d(T)p.d(G)p.d(T)p}$$$$\nRNA1{d(T)p.d(T)p.d(C)p.d(A)p.d(A)p.d(C)p.d(T)p.d(T)p.d(C)p.d(A)p.d(A)p.d(C)p}$$$$",[t.fastaRna]:"seq\nACGUCACGUC\nCAGUGUCAGUGU\nUUCAACUUCAAC",[t.separatorRna]:"seq\nA*C*G*U*C*A*C*G*U*C\nC*A*G*U*G*U*C*A*G*U*G*U\nU*U*C*A*A*C*U*U*C*A*A*C",[t.helmRna]:"seq\nRNA1{r(A)p.r(C)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)p.r(U)p.r(G)p.r(U)p}$$$$\nRNA1{p.r(U)p.r(U)p.r(C)p.r(A)p.r(A)p.r(C)p.r(U)p.r(U)p.r(C)p.r(A)p.r(A)p.r(C)p.p.p}$$$$"};async function s(t){const s=e[t],i=n.DataFrame.fromCsv(s);return await l.data.detectSemanticTypes(i),i}function o(t,e){if(t===h.r2.SEPARATOR&&!e)throw new Error(`Argument 'separator' is mandatory for target notation '${t.toString()}'.`);return function(s){const o=u.Cn.getOrCreate(s).convert(t,e);return(0,i.l_)(o.getTag(n.TAGS.UNITS),t),o}}async function r(t,e,n){const o=e((await s(t)).getCol("seq")),r=(await s(n)).getCol("seq");(0,i.f6)(o.toList(),r.toList()),u.Cn.getOrCreate(o)}(0,i.Bu)("testFastaPtToSeparator",(async()=>{await r(t.fastaPt,o(h.r2.SEPARATOR,"-"),t.separatorPt)})),(0,i.Bu)("testFastaDnaToSeparator",(async()=>{await r(t.fastaDna,o(h.r2.SEPARATOR,"/"),t.separatorDna)})),(0,i.Bu)("testFastaRnaToSeparator",(async()=>{await r(t.fastaRna,o(h.r2.SEPARATOR,"*"),t.separatorRna)})),(0,i.Bu)("testFastaGapsToSeparator",(async()=>{await r(t.fastaGaps,o(h.r2.SEPARATOR,"/"),t.separatorGaps)})),(0,i.Bu)("testFastaUnToSeparator",(async()=>{await r(t.fastaUn,o(h.r2.SEPARATOR,"-"),t.separatorUn)})),(0,i.Bu)("testFastaPtToHelm",(async()=>{await r(t.fastaPt,o(h.r2.HELM),t.helmPt)})),(0,i.Bu)("testFastaDnaToHelm",(async()=>{await r(t.fastaDna,o(h.r2.HELM),t.helmDna)})),(0,i.Bu)("testFastaRnaToHelm",(async()=>{await r(t.fastaRna,o(h.r2.HELM),t.helmRna)})),(0,i.Bu)("testFastaGapsToHelm",(async()=>{await r(t.fastaGaps,o(h.r2.HELM),t.helmGaps)})),(0,i.Bu)("testSeparatorPtToFasta",(async()=>{await r(t.separatorPt,o(h.r2.FASTA),t.fastaPt)})),(0,i.Bu)("testSeparatorDnaToFasta",(async()=>{await r(t.separatorDna,o(h.r2.FASTA),t.fastaDna)})),(0,i.Bu)("testSeparatorRnaToFasta",(async()=>{await r(t.separatorRna,o(h.r2.FASTA),t.fastaRna)})),(0,i.Bu)("testSeparatorGapsToFasta",(async()=>{await r(t.separatorGaps,o(h.r2.FASTA),t.fastaGaps)})),(0,i.Bu)("testSeparatorUnToFasta",(async()=>{await r(t.separatorUn,o(h.r2.FASTA),t.fastaUn)})),(0,i.Bu)("testSeparatorPtToHelm",(async()=>{await r(t.separatorPt,o(h.r2.HELM),t.helmPt)})),(0,i.Bu)("testSeparatorDnaToHelm",(async()=>{await r(t.separatorDna,o(h.r2.HELM),t.helmDna)})),(0,i.Bu)("testSeparatorRnaToHelm",(async()=>{await r(t.separatorRna,o(h.r2.HELM),t.helmRna)})),(0,i.Bu)("testSeparatorGapsToHelm",(async()=>{await r(t.separatorGaps,o(h.r2.HELM),t.helmGaps)})),(0,i.Bu)("testHelmDnaToFasta",(async()=>{await r(t.helmDna,o(h.r2.FASTA),t.fastaDna)})),(0,i.Bu)("testHelmRnaToFasta",(async()=>{await r(t.helmRna,o(h.r2.FASTA),t.fastaRna)})),(0,i.Bu)("testHelmPtToFasta",(async()=>{await r(t.helmPt,o(h.r2.FASTA),t.fastaPt)})),(0,i.Bu)("testHelmUnToFasta",(async()=>{await r(t.helmUn,o(h.r2.FASTA),t.fastaUn)})),(0,i.Bu)("testHelmDnaToSeparator",(async()=>{await r(t.helmDna,o(h.r2.SEPARATOR,"/"),t.separatorDna)})),(0,i.Bu)("testHelmRnaToSeparator",(async()=>{await r(t.helmRna,o(h.r2.SEPARATOR,"*"),t.separatorRna)})),(0,i.Bu)("testHelmPtToSeparator",(async()=>{await r(t.helmPt,o(h.r2.SEPARATOR,"-"),t.separatorPt)})),(0,i.Bu)("testHelmUnToSeparator",(async()=>{await r(t.helmUn,o(h.r2.SEPARATOR,"-"),t.separatorUn)})),(0,i.Bu)("testHelmLoneRibose",(async()=>{await r(t.helmLoneRibose,o(h.r2.FASTA),t.fastaRna)})),(0,i.Bu)("testHelmLoneDeoxyribose",(async()=>{await r(t.helmLoneDeoxyribose,o(h.r2.SEPARATOR,"/"),t.separatorDna)})),(0,i.Bu)("testHelmLonePhosphorus",(async()=>{await r(t.helmLonePhosphorus,o(h.r2.FASTA),t.fastaRna)}))}));var H=s(5226);(0,i.W3)("fastaFileHandler",(()=>{const t=["description:1","description:2","description:3","description:4"],e=(n.Column.fromStrings("description",t),["MDYKETLLMPKTDFPMRGGLPNKEPQIQEKW","MIEVFLFGIVLGLIPITLAGLFVTAYLQYRRGDQLDL","MMELVLKTIIGPIVVGVVLRIVDKWLNKDK","MDRTDEVSNHTHDKPTLTWFEEIFEEYHSPFHN"]);function s(s){const n=new H.i(s),o=n.descriptionsArray,r=n.sequencesArray;(0,i.f6)([o,r],[t,e])}(0,i.Bu)("testNormalFormatting",(async()=>{s(">description:1\nMDYKETLLMPKTDFPMRGGLPNKEPQIQEKW\n\n>description:2\nMIEVFLFGIVLGLIPITLAGLFVTAYLQYRRGDQLDL\n\n>description:3\nMMELVLKTIIGPIVVGVVLRIVDKWLNKDK\n\n>description:4\nMDRTDEVSNHTHDKPTLTWFEEIFEEYHSPFHN\n")})),(0,i.Bu)("testExtraSpaces",(async()=>{s(">description:1\n MDYKETLLMPKTDFPMRGGLPNKEPQIQEKW\n\n>description:2\nMI EVF LFGIVLGLI PITLAGLFVTAY LQYRRGDQLDL\n\n>description:3\nM MELVLKTI IGPI VVGVVLR IVDKWLNKDK\n\n>description:4\nMDR TDEVSNHTHDKP TLTWFEEIFEEYHSPFHN\n ")})),(0,i.Bu)("testExtraNewlines",(async()=>{s(">description:1\n\nMDYKETLLMPKTDFPMRGGLPNKEPQIQEKW\n\n>description:2\nMIEVF\nLFGIVLGLI\nPITLAGLFVTA\nYLQYRRGDQLDL\n\n>description:3\nM\nME\n\nLVLKTIIG\n\nPIVVGVVLRI\nVDKWLNKDK\n\n\n>description:4\n\nMDRT\n\nDEVSNHTHDKP\n\nTLTWFEEIFEE\n\n\n\nYHSPFHN\n")}))}));var W=s(9943);(0,i.W3)("fastaExport",(()=>{let t;!function(t){t.single="single",t.multi="multi"}(t||(t={}));const e={[t.single]:{src:"MDYKETLLMPKTDFPMRGGLP",tgt:["MDYKETLLMP","KTDFPMRGGL","P"]},[t.multi]:{src:"M[MeI]YKETLL[MeF]PKTDFPMRGGL[MeA]",tgt:["M[MeI]YKETLL[MeF]P","KTDFPMRGGL","[MeA]"]}};let s;!function(t){t.test1="test1",t.test2="test2"}(s||(s={}));const o={[s.test1]:{srcCsv:"id,seq\n1,MDYKETLLMP\n2,KTDFPMRGGL\n3,P",idCols:["id"],seqCol:"seq",lineWidth:10,tgtFasta:">1\nMDYKETLLMP\n>2\nKTDFPMRGGL\n>3\nP\n"},[s.test2]:{srcCsv:"id,id2,seq\n1,seqA,M[MeI]YKETLL[MeF]P\n2,seqB,KTDFPMRGGL\n3,seqC,[MeA]\n",idCols:["id2","id"],seqCol:"seq",lineWidth:5,tgtFasta:">seqA|1\nM[MeI]YKE\nTLL[MeF]P\n>seqB|2\nKTDFP\nMRGGL\n>seqC|3\n[MeA]\n"}};function r(t,s=10){const n=h.kB,o=e[t].src,r=(0,W.sK)(o,n,s),a=e[t].tgt;(0,i.f6)(r,a)}async function a(t){const e=n.DataFrame.fromCsv(t.srcCsv),s=e.getCol(t.seqCol),o=t.idCols.map((t=>e.getCol(t))),r=(0,W.i$)(o,s,t.lineWidth);(0,i.l_)(r,t.tgtFasta)}(0,i.Bu)("wrapSequenceSingle",(async()=>{r(t.single,10)})),(0,i.Bu)("wrapSequenceMulti",(async()=>{r(t.multi,10)})),(0,i.Bu)("saveAsFastaTest1",(async()=>{a(o[s.test1])})),(0,i.Bu)("saveAsFastaTest2",(async()=>{a(o[s.test2])}))}));var k=s(7331),B=s(585);(0,i.W3)("bio",(()=>{const t="seq\nACGTCT\nCAGTGT\nTTCAAC";(0,i.Bu)("testGetStatsHelm1",(async()=>{const t=n.DataFrame.fromCsv("seq\nPEPTIDE1{meI}$$$$").getCol("seq"),e=(0,B.jY)(t,1,h.gP);(0,i.Wh)(e.freq,{meI:1}),(0,i.l_)(e.sameLength,!0)})),(0,i.Bu)("testGetStatsN1",(async()=>{await async function(t){const e=n.DataFrame.fromCsv(t).col("seq"),s=(0,B.jY)(e,5,h.kB);(0,i.Wh)(s.freq,{A:4,C:5,G:3,T:6}),(0,i.l_)(s.sameLength,!0)}(t)})),(0,i.Bu)("testGetAlphabetSimilarity",(async()=>{await async function(){const t=new Set(Object.keys(a.V.Names)),e=(0,h.KX)({A:2041,C:3015,G:3015,T:2048,"-":1e3},t);(0,i.l_)(e>.6,!0)}()})),(0,i.Bu)("testPickupPaletteN1",(async()=>{await async function(t){const e=n.DataFrame.fromCsv(t).col("seq"),s=(0,h.dQ)(e);(0,i.l_)(s instanceof a.J,!0)}(t)})),(0,i.Bu)("testPickupPaletteN1e",(async()=>{await async function(t){const e=n.DataFrame.fromCsv("seq\nACGTAT\nCAGTTG\nTTCG2C").col("seq"),s=(0,h.dQ)(e);(0,i.l_)(s instanceof a.J,!0)}()})),(0,i.Bu)("testPickupPaletteAA1",(async()=>{await async function(t){const e=n.DataFrame.fromCsv("seq\nFWPHEYV\nYNRQWYV\nMKPSEYV").col("seq"),s=(0,h.dQ)(e);(0,i.l_)(s instanceof o.f,!0)}()})),(0,i.Bu)("testPickupPaletteX",(async()=>{await async function(t){const e=n.DataFrame.fromCsv("seq\nXZJ{}2\n5Z4733\n3Z6></\n675687").col("seq"),s=(0,h.dQ)(e);(0,i.l_)(s instanceof k.kQ,!0)}()}))})),(0,i.W3)("WebLogo.monomerToShort",(()=>{(0,i.Bu)("longMonomerSingle",(async()=>{(0,i.l_)((0,h.GU)("S",5),"S")})),(0,i.Bu)("longMonomerShort",(async()=>{(0,i.l_)((0,h.GU)("Short",5),"Short")})),(0,i.Bu)("longMonomerLong56",(async()=>{(0,i.l_)((0,h.GU)("Long56",6),"Long56")})),(0,i.Bu)("longMonomerComplexFirstPartShort",(async()=>{(0,i.l_)((0,h.GU)("Long-long",5),"Long…")})),(0,i.Bu)("longMonomerComplexFirstPartLong56",(async()=>{(0,i.l_)((0,h.GU)("Long56-long",6),"Long5…")})),(0,i.Bu)("monomerToShort",(async()=>{const t=[["AbC","AbC"],["AbCd","Ab…"],["ABc","ABc"],["ABcd","AB…"],["A_b","A_b"],["A_bc","A…"],["Ab_c","Ab…"],["A1_b","A1…"],["Abc_d","Ab…"],["Abcd_e","Ab…"],["A-b","A-b"],["A-bc","A…"],["Ab-c","Ab…"],["A1-b","A1…"],["Abc-d","Ab…"],["Abcd-e","Ab…"],["A","A"],["Ab","Ab"],["Abc","Abc"],["Ab…","Ab…"],["Abcd","Ab…"],["Abcde","Ab…"]],e=t.map((t=>t[0])),s=t.map((t=>t[1])),n=e.map((t=>(0,h.GU)(t,3)));(0,i.f6)(n,s)}))}));var V=s(8415);function U(t,e){(0,i.l_)(t.name,e.name),(0,i.f6)(t.getMonomers(),e.getMonomers());for(const s of t.getMonomers())(0,i.l_)(t.getFreq(s).rowCount,e.getFreq(s).rowCount)}(0,i.W3)("WebLogo-positions",(()=>{const t="seq\nATC-G-TTGC--\nATC-G-TTGC--\n-TC-G-TTGC--\n-TC-GCTTGC--\n-TC-GCTTGC--";(0,i.Bu)("allPositions",(async()=>{const e=n.DataFrame.fromCsv(t),s=l.shell.addTableView(e),o=e.getCol("seq");o.semType=n.SEMTYPE.MACROMOLECULE,o.setTag(n.TAGS.UNITS,h.r2.FASTA),o.setTag("alphabet","DNA"),o.setTag("aligned","SEQ.MSA");const r=await e.plot.fromType("WebLogo");await(0,i.zg)(r.onLayoutCalculated,(()=>{}),(()=>{s.dockManager.dock(r.root,n.DOCK_TYPE.DOWN)}),500);const a=r.positions,c=[new V.CK(0,"1",{A:new V.yW(2),"-":new V.yW(3)}),new V.CK(1,"2",{T:new V.yW(5)}),new V.CK(2,"3",{C:new V.yW(5)}),new V.CK(3,"4",{"-":new V.yW(5)}),new V.CK(4,"5",{G:new V.yW(5)}),new V.CK(5,"6",{"-":new V.yW(3),C:new V.yW(2)}),new V.CK(6,"7",{T:new V.yW(5)}),new V.CK(7,"8",{T:new V.yW(5)}),new V.CK(8,"9",{G:new V.yW(5)}),new V.CK(9,"10",{C:new V.yW(5)}),new V.CK(10,"11",{"-":new V.yW(5)}),new V.CK(11,"12",{"-":new V.yW(5)})];(0,i.l_)(a.length,c.length);for(let t=0;t<a.length;t++){(0,i.l_)(a[t].name,c[t].name);for(const e of a[t].getMonomers())(0,i.l_)(a[t].getFreq(e).rowCount,c[t].getFreq(e).rowCount)}})),(0,i.Bu)("positions with shrinkEmptyTail option true (filtered)",(async()=>{const t=n.DataFrame.fromCsv("seq\n-TC-G-TTGC--\n-TC-GCTTGC--\n-T--C-GT-\n-T--C-GT-\n-T--C-GT-\n-T--CCGT-"),e=l.shell.addTableView(t),s=t.getCol("seq");s.semType=n.SEMTYPE.MACROMOLECULE,s.setTag(n.TAGS.UNITS,h.r2.FASTA),s.setTag("alphabet","DNA"),s.setTag("aligned","SEQ"),t.filter.init((t=>t>2)),t.filter.fireChanged();const o=await t.plot.fromType("WebLogo",{shrinkEmptyTail:!0});await(0,i.zg)(o.onLayoutCalculated,(()=>{}),(()=>{e.dockManager.dock(o.root,n.DOCK_TYPE.DOWN)}),500);const r=o.positions,a=[new V.CK(0,"1",{"-":new V.yW(3)}),new V.CK(1,"2",{T:new V.yW(3)}),new V.CK(2,"3",{"-":new V.yW(3)}),new V.CK(3,"4",{"-":new V.yW(3)}),new V.CK(4,"5",{C:new V.yW(3)}),new V.CK(5,"6",{"-":new V.yW(2),C:new V.yW(1)}),new V.CK(6,"7",{G:new V.yW(3)}),new V.CK(7,"8",{T:new V.yW(3)}),new V.CK(8,"9",{"-":new V.yW(3)})];(0,i.l_)(r.length,a.length);for(let t=0;t<r.length;t++){(0,i.l_)(r[t].name,a[t].name);for(const e of r[t].getMonomers())(0,i.l_)(r[t].getFreq(e).rowCount,a[t].getFreq(e).rowCount)}})),(0,i.Bu)("positions with skipEmptyPositions option",(async()=>{const e=n.DataFrame.fromCsv(t),s=l.shell.addTableView(e),o=e.getCol("seq");o.semType=n.SEMTYPE.MACROMOLECULE,o.setTag(n.TAGS.UNITS,h.r2.FASTA),o.setTag("alphabet","DNA"),o.setTag("aligned","SEQ.MSA");const r=await e.plot.fromType("WebLogo",{skipEmptyPositions:!0});await(0,i.zg)(r.onLayoutCalculated,(()=>{}),(()=>{s.dockManager.dock(r.root,n.DOCK_TYPE.DOWN)}),500);const a=r.positions,c=[new V.CK(0,"1",{A:new V.yW(2),"-":new V.yW(3)}),new V.CK(1,"2",{T:new V.yW(5)}),new V.CK(2,"3",{C:new V.yW(5)}),new V.CK(4,"5",{G:new V.yW(5)}),new V.CK(5,"6",{"-":new V.yW(3),C:new V.yW(2)}),new V.CK(6,"7",{T:new V.yW(5)}),new V.CK(7,"8",{T:new V.yW(5)}),new V.CK(8,"9",{G:new V.yW(5)}),new V.CK(9,"10",{C:new V.yW(5)})];(0,i.l_)(a.length,c.length);for(let t=0;t<a.length;t++)U(a[t],c[t])})),(0,i.Bu)("count sequences for monomer at position",(async()=>{const e=function(t,e,s,i){const o=n.DataFrame.fromCsv(t),r=o.getCol("seq");return r.semType=n.SEMTYPE.MACROMOLECULE,r.setTag(n.TAGS.UNITS,e),r.setTag("alphabet","DNA"),r.setTag("aligned","SEQ.MSA"),o}(t,h.r2.FASTA),s=e.getCol("seq"),o=l.shell.addTableView(e),r=await e.plot.fromType("WebLogo",{startPositionName:"3",endPositionName:"7",skipEmptyPositions:!0});await(0,i.zg)(r.onLayoutCalculated,(()=>{}),(()=>{o.dockManager.dock(r.root,n.DOCK_TYPE.DOWN)}),500);const a=r.positions,c=[new V.CK(2,"3",{C:new V.yW(5)}),new V.CK(4,"5",{G:new V.yW(5)}),new V.CK(5,"6",{"-":new V.yW(3),C:new V.yW(2)}),new V.CK(6,"7",{T:new V.yW(5)})];(0,i.l_)(a.length,c.length);for(let t=0;t<a.length;t++)U(a[t],c[t]);const m=a[1],d=u.Cn.getOrCreate(s),p=(0,V.eZ)(e,d,e.filter,"G",m);(0,i.l_)(p,5)})),(0,i.Bu)("empty",(async()=>{const t=n.DataFrame.fromColumns([(()=>{const t=n.Column.fromStrings("seq",[]);return t.setTag(n.TAGS.SEMTYPE,n.SEMTYPE.MACROMOLECULE),t.setTag(n.TAGS.UNITS,h.r2.FASTA),t.setTag("alphabet","DNA"),t})()]),e=l.shell.addTableView(t),s=await t.plot.fromType("WebLogo");await(0,i.zg)(s.onLayoutCalculated,(()=>{}),(()=>{e.dockManager.dock(s.root,n.DOCK_TYPE.DOWN)}),500),s.positions}))}));var $=s(2568);function Y(t,e){let s=null;for(const n of t.viewers)n.type===e&&(s=n);return s}(0,i.W3)("checkInputColumn",(()=>{const t="seq\nseq1,\nseq2,\nseq3,\nseq4";(0,i.Bu)("testMsaPos",(async()=>{const e=n.DataFrame.fromCsv(t).getCol("seq");e.semType=n.SEMTYPE.MACROMOLECULE,e.setTag(n.TAGS.UNITS,h.r2.FASTA),e.setTag("alphabet","DNA"),e.setTag("aligned","SEQ");const[s,o]=(0,$.l)(e,"Test",[h.r2.FASTA],["DNA","RNA","PT"]);(0,i.l_)(s,!0)})),(0,i.Bu)("testMsaNegHelm",(async()=>{const e=n.DataFrame.fromCsv(t).getCol("seq");e.semType=n.SEMTYPE.MACROMOLECULE,e.setTag(n.TAGS.UNITS,h.r2.HELM),e.setTag(".alphabetIsMultichar","true");const[s,o]=(0,$.l)(e,"Test",[h.r2.FASTA],["DNA","RNA","PT"]);(0,i.l_)(s,!1)})),(0,i.Bu)("testMsaNegUN",(async()=>{const e=n.DataFrame.fromCsv(t).getCol("seq");e.semType=n.SEMTYPE.MACROMOLECULE,e.setTag(n.TAGS.UNITS,h.r2.FASTA),e.setTag("alphabet","UN"),e.setTag(".alphabetSize","11"),e.setTag(".alphabetIsMultichar","true"),e.setTag("aligned","SEQ");const[s,o]=(0,$.l)(e,"Test",[h.r2.FASTA],["DNA","RNA","PT"]);(0,i.l_)(s,!1)})),(0,i.Bu)("testGetActionFunctionMeta",(async()=>{n.Func.find({package:"Bio",name:"multipleSequenceAlignmentDialog"})[0].inputs.find((t=>"sequence"==t.name))}))})),(0,i.W3)("similarity/diversity",(async()=>{(0,i.Bu)("similaritySearchViewer",(async()=>{await async function(){const t=await pt.files.readAsText("tests/sample_MSA_data.csv"),e=n.DataFrame.fromCsv(t);await l.data.detectSemanticTypes(e);const s=l.shell.addTableView(e),o=s.dataFrame.getCol("MSA");(0,i.l_)(o.semType,n.SEMTYPE.MACROMOLECULE);const r=await s.dataFrame.plot.fromType("Sequence Similarity Search");let a=!1;if(r.computeCompleted.subscribe((t=>{t&&(a=!0)})),s.dockManager.dock(r,n.DOCK_TYPE.RIGHT,null,"Similarity"),await r.renderPromise,await(0,i.ow)((()=>void 0!==Y(s,"Sequence Similarity Search")),"Sequence Similarity Search viewer has not been created",100),!r.initialized)throw new Error("The viewer is not initialized.");if(!r.moleculeColumn)throw new Error("The viewer has not molecule column (onTableAttached).");if(!r.beforeRender())throw new Error("The viewer is not able to render.");if(!r.computeRequested)throw new Error("The viewer has not compute requested even.");if(!a)throw new Error("The viewer has not compute completed.");const c=r;await(0,i.ow)((()=>0!==c.root.getElementsByClassName("d4-grid").length),"Sequence Similarity Search viewer grid has not been created",100);(0,i.l_)(c.fingerprint,"Morgan"),(0,i.l_)(c.distanceMetric,"Tanimoto"),(0,i.l_)(c.scores.get(0),n.FLOAT_NULL),(0,i.l_)(c.idxs.get(0),0),(0,i.l_)(c.molCol.get(0),"D-Tyr_Et/Tyr_ab-dehydroMe/dV/E/N/D-Orn/D-aThr//Phe_4Me"),(0,i.l_)(c.scores.get(1),.4722222089767456),(0,i.l_)(c.idxs.get(1),11),(0,i.l_)(c.molCol.get(1),"meI/hHis//Aca/meM/Tyr_ab-dehydroMe/dV/E/N/D-Orn/D-aThr//Phe_4Me"),s.dataFrame.currentRowIdx=1,await(0,i.ow)((()=>1===c.targetMoleculeIdx),"Target molecule has not been changed",5e3),await(0,i.ow)((()=>"meI/hHis/Aca/Cys_SEt/T/dK/Thr_PO3H2/Aca/Tyr_PO3H2/D-Chg/dV/Phe_ab-dehydro/N/D-Orn/D-aThr//Phe_4Me"===c.molCol.get(0)),"Incorrect first similar molecule",5e3)}()})),(0,i.Bu)("diversitySearchViewer",(async()=>{await async function(){const t=await pt.files.readAsText("tests/sample_MSA_data.csv"),e=n.DataFrame.fromCsv(t),s=l.shell.addTableView(e);await l.data.detectSemanticTypes(e);const o=s.dataFrame.getCol("MSA");(0,i.l_)(o.semType,n.SEMTYPE.MACROMOLECULE);const r=await s.dataFrame.plot.fromType("Sequence Diversity Search");let a=!1;if(r.computeCompleted.subscribe((t=>{t&&(a=!0)})),s.dockManager.dock(r,n.DOCK_TYPE.DOWN,null,"Diversity"),await r.renderPromise,await(0,i.ow)((()=>void 0!==Y(s,"Sequence Diversity Search")),"Sequence Diversity Search viewer has not been created",100),!r.initialized)throw new Error("The viewer is not initialized.");if(!r.moleculeColumn)throw new Error("The viewer has not molecule column (onTableAttached).");if(!r.beforeRender())throw new Error("The viewer is not able to render.");if(!r.computeRequested)throw new Error("The viewer has not compute requested even.");if(!a)throw new Error("The viewer has not compute completed.");const c=r;await(0,i.ow)((()=>0!==c.root.getElementsByClassName("d4-grid").length),"Sequence Diversity Search viewer grid has not been created",100),(0,i.l_)(c.fingerprint,"Morgan"),(0,i.l_)(c.distanceMetric,"Tanimoto"),(0,i.l_)(c.initialized,!0),(0,i.l_)(c.renderMolIds.length>0,!0)}()}))}));var K=s(4413);(0,i.W3)("substructureFilters",(async()=>{let t,e;(0,i.bb)((async()=>{t=await(0,x.JN)(),e=await(0,I.nW)(),await(0,I.tb)(),await t.loadLibraries(!0)})),(0,i.X5)((async()=>{await(0,I.tW)(e),await t.loadLibraries(!0)})),(0,i.Bu)("fasta",(async()=>{const t=await T("tests/filter_FASTA.csv"),e=new K.ST;await l.data.detectSemanticTypes(t),e.attach(t),e.bioFilter.substructure="MD",await(0,i.gw)(100),(0,i.l_)(e.dataFrame.filter.trueCount,3),(0,i.l_)(e.dataFrame.filter.get(0),!0),(0,i.l_)(e.dataFrame.filter.get(3),!0),(0,i.l_)(e.dataFrame.filter.get(8),!0),(0,i.l_)(e.dataFrame.filter.get(1),!1)})),(0,i.Bu)("separator",(async()=>{const t=await T("tests/filter_MSA.csv"),e=new K.ST;await l.data.detectSemanticTypes(t),e.attach(t),e.bioFilter.substructure="meI",await(0,i.gw)(100),(0,i.l_)(e.dataFrame.filter.trueCount,7),(0,i.l_)(e.dataFrame.filter.get(2),!1),e.bioFilter.substructure="/meI",await(0,i.gw)(100),(0,i.l_)(e.dataFrame.filter.trueCount,0),e.bioFilter.substructure="meI-hHis",e.bioFilter.separatorInput.value="-",await(0,i.gw)(100),(0,i.l_)(e.dataFrame.filter.trueCount,7),(0,i.l_)(e.dataFrame.filter.get(2),!1)})),(0,i.Bu)("helm",(async()=>{const t=await T("tests/filter_HELM.csv"),e=l.shell.addTableView(t),s=new K.ST;await l.data.detectSemanticTypes(t),pt.logger.debug("Bio/substructureFilters/helm, filter attaching."),s.attach(t),pt.logger.debug("Bio/substructureFilters/helm, filter attached."),pt.logger.debug("Bio/substructureFilters/helm, filter 1 changing."),s.bioFilter.helmSubstructure="PEPTIDE1{C}$$$$V2.0",pt.logger.debug("Bio/substructureFilters/helm, filter 1 change awaiting."),await(0,i.zg)(t.onRowsFiltered,(()=>{}),(()=>{s.bioFilter.onChanged.next()}),2e4),pt.logger.debug("Bio/substructureFilters/helm, filter 1 changed."),(0,i.l_)(s.dataFrame.filter.trueCount,2),(0,i.l_)(s.dataFrame.filter.get(0),!0),(0,i.l_)(s.dataFrame.filter.get(3),!0),pt.logger.debug("Bio/substructureFilters/helm, filter 2 changing."),s.bioFilter.helmSubstructure="PEPTIDE1{A.C}$$$$V2.0",pt.logger.debug("Bio/substructureFilters/helm, filter 2 change awaiting."),await(0,i.zg)(t.onRowsFiltered,(()=>{}),(()=>{s.bioFilter.onChanged.next()}),2e4),await async function(t,e=5e3){await(0,i.gw)(0),await(0,i.zg)(t.onAfterDrawContent,(()=>{}),(()=>{t.invalidate()}),e)}(e.grid),pt.logger.debug("Bio/substructureFilters/helm, filter 2 changed."),(0,i.l_)(s.dataFrame.filter.trueCount,1),(0,i.l_)(s.dataFrame.filter.get(3),!0)}),{timeout:3e4})}));var q=s(8341);(0,i.W3)("PepSeA",(()=>{(0,i.Bu)("Basic alignment",(async()=>{await b();const t=n.DataFrame.fromCsv('HELM,MSA\n "PEPTIDE1{F.L.R.G.W.[MeF].Y.S.N.N.C}$$$$","F.L.R.G.W.MeF.Y..S.N.N.C"\n "PEPTIDE1{F.L.R.G.Y.[MeF].Y.W.N.C}$$$$","F.L.R.G.Y.MeF.Y.W...N.C"\n "PEPTIDE1{F.G.Y.[MeF].Y.W.S.D.N.C}$$$$","F...G.Y.MeF.Y.W.S.D.N.C"\n "PEPTIDE1{F.L.R.G.Y.[MeF].Y.W.S.N.D.C}$$$$","F.L.R.G.Y.MeF.Y.W.S.N.D.C"\n "PEPTIDE1{F.V.R.G.Y.[MeF].Y.W.S.N.C}$$$$","F.V.R.G.Y.MeF.Y.W.S..N.C"'),e=await(0,q.f3)(t.getCol("HELM"),"msa(HELM)");(0,i.l_)(null!==e,!0,"PepSeA container has not started");const s=t.getCol("MSA");for(let t=0;t<e.length;++t)(0,i.l_)(e.get(t)==s.get(t),!0)}),{skipReason:"GROK-13221"})})),(0,i.W3)("viewers",(()=>{const t=n.Func.find({package:"Bio",tags:["viewer"]}).map((t=>t.friendlyName));for(const e of t)(0,i.Bu)(e,(async()=>{const t=await T("data/sample_FASTA_DNA.csv");await(0,i.AB)(e,t,{detectSemanticTypes:!0})}),{skipReason:{"Sequence Similarity Search":"GROK-13162","Sequence Diversity Search":"GROK-13162",WebLogo:"GROK-13162",VdRegions:"GROK-13162"}[e]})}));const Z="seq\nACGTCACGTC\nCAGTGTCAGTGT\nTTCAACTTCAAC",z="seq\nAC-GT-CTAC-GT-CT\nCAC-T-GTCAC-T-GT\nACCGTACTACCGTACT",X="seq\nabc-dfgg-abc1-cfr3-rty-wert-abc-dfgg-abc1-cfr3-rty-wert\nrut12-her2-rty-wert-abc-abc1-dfgg-rut12-her2-rty-wert-abc-abc1-dfgg\nrut12-rty-her2-abc-cfr3-wert-rut12-rut12-rty-her2-abc-cfr3-wert-rut12";var j;(0,i.W3)("UnitsHandler",(()=>{async function t(t){const e=n.DataFrame.fromCsv(t);await l.data.detectSemanticTypes(e);const s=u.Cn.getOrCreate(e.getCol("seq"));return[e,s]}(0,i.Bu)("Seq-Fasta",(async()=>{const[e,s]=await t(Z);(0,i.l_)(s.notation,h.r2.FASTA),(0,i.l_)(s.isMsa(),!1)})),(0,i.Bu)("Seq-Fasta-MSA",(async()=>{const[e,s]=await t(z);(0,i.l_)(s.notation,h.r2.FASTA),(0,i.l_)(s.isMsa(),!0)})),(0,i.Bu)("Seq-Fasta-units",(async()=>{const[e,s]=await t(Z);(0,i.l_)(s.notation,h.r2.FASTA),(0,i.l_)(s.isMsa(),!1)})),(0,i.Bu)("Seq-Fasta-MSA-units",(async()=>{const[e,s]=await t(z);(0,i.l_)(s.notation,h.r2.FASTA),(0,i.l_)(s.isMsa(),!0)})),(0,i.Bu)("Seq-Helm",(async()=>{const[e,s]=await t("seq\nPEPTIDE1{meI.hHis.Aca.N.T.dE.Thr_PO3H2.Aca.D-Tyr_Et.Tyr_ab-dehydroMe.dV.E.N.D-Orn.D-aThr.Phe_4Me}$$$$\nPEPTIDE1{meI.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.Aca.Tyr_PO3H2.D-Chg.dV.Phe_ab-dehydro.N.D-Orn.D-aThr.Phe_4Me}$$$$\nPEPTIDE1{Lys_Boc.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.Aca.Tyr_PO3H2.D-Chg.dV.Thr_PO3H2.N.D-Orn.D-aThr.Phe_4Me}$$$$\nPEPTIDE1{meI.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.Aca.Tyr_PO3H2.D-Chg.dV.Thr_PO3H2.N.D-Orn.D-aThr.Phe_4Me}$$$$");(0,i.l_)(s.notation,h.r2.HELM),(0,i.l_)(s.isHelm(),!0)})),(0,i.Bu)("Seq-UN",(async()=>{const[e,s]=await t(X);(0,i.l_)(s.notation,h.r2.SEPARATOR),(0,i.l_)(s.separator,"-"),(0,i.l_)(s.alphabet,"UN")})),(0,i.Bu)("Seq-UN-auto",(async()=>{const[e,s]=await t(X);(0,i.l_)(s.notation,h.r2.SEPARATOR),(0,i.l_)(s.separator,"-"),(0,i.l_)(s.alphabet,"UN")}))})),function(t){t.fasta="fasta",t.fastaMsa="fastaMsa",t.separator="separator",t.separatorMsa="separatorMsa",t.helm="helm"}(j||(j={})),(0,i.W3)("UnitsHandler",(()=>{u._9[h.r2.FASTA],u._9[h.r2.HELM];const t=u._9[h.r2.SEPARATOR],e={[j.fasta]:{src:{csv:"seq\nACGTCACGTC\nCAGTGTCAGTGT\nTTCAACTTCAAC"},tgt:{notation:h.r2.FASTA,splitted:["ACGTCACGTC","CAGTGTCAGTGT","TTCAACTTCAAC"]}},[j.fastaMsa]:{src:{csv:"seq\nAC-GT-CTAC-GT-CT\nCAC-T-GTCAC-T-GT\nACCGTACTACCGTACT"},tgt:{notation:h.r2.FASTA,splitted:["AC-GT-CTAC-GT-CT","CAC-T-GTCAC-T-GT","ACCGTACTACCGTACT"]}},[j.separator]:{src:{csv:"seq\nabc-dfgg-abc1-cfr3-rty-wert-abc-dfgg-abc1-cfr3-rty-wert\nrut12-her2-rty-wert-abc-abc1-dfgg-rut12-her2-rty-wert-abc\nrut12-rty-her2-abc-cfr3-wert-rut12-rut12-rty-her2-abc-cfr3"},tgt:{notation:h.r2.SEPARATOR,separator:"-",splitted:[["abc","dfgg","abc1","cfr3","rty","wert","abc","dfgg","abc1","cfr3","rty","wert"],["rut12","her2","rty","wert","abc","abc1","dfgg","rut12","her2","rty","wert","abc"],["rut12","rty","her2","abc","cfr3","wert","rut12","rut12","rty","her2","abc","cfr3"]]}},[j.separatorMsa]:{src:{csv:'seq\nrut0-dfgg-abc1-cfr3-rty-wert-abc-dfgg-abc1-cfr3-rty-wert\nrut1-her2-rty--abc1-dfgg-rut12-her2-rty--abc1-dfgg\nrut2-rty-her2---wert-rut12-rty-her2---wert\n"rut3-rty-her2-""-""-""-""-wert-rut12-rty-her2-""-""-""-""-wert"\n"""-""-rut4-her2-wert-rut12-rty-her2-wert"\n"rut5-rty-her2-wert-rut12-rty-her2-wert-""-"""'},tgt:{notation:h.r2.SEPARATOR,separator:"-",splitted:[["rut0","dfgg","abc1","cfr3","rty","wert","abc","dfgg","abc1","cfr3","rty","wert"],["rut1","her2","rty",t,"abc1","dfgg","rut12","her2","rty",t,"abc1","dfgg"],["rut2","rty","her2",t,t,"wert","rut12","rty","her2",t,t,"wert"],["rut3","rty","her2",t,t,"wert","rut12","rty","her2",t,t,"wert"],[t,"rut4","her2","wert","rut12","rty","her2","wert"],["rut5","rty","her2","wert","rut12","rty","her2","wert",t]]}},[j.helm]:{src:{csv:"seq\nPEPTIDE1{meI.hHis.Aca.N.T.dE.Thr_PO3H2.Aca.D-Tyr_Et.Thr_PO3H2.Aca.D-Tyr_Et}$$$$\nPEPTIDE1{meI.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.Aca.dK.Thr_PO3H2.Aca}$$$$\nPEPTIDE1{Lys_Boc.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.Aca.dK.Thr_PO3H2.Aca}$$$$\nPEPTIDE1{meI.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.T.dK.Thr_PO3H2}$$$$"},tgt:{notation:h.r2.HELM,splitted:[["meI","hHis","Aca","N","T","dE","Thr_PO3H2","Aca","D-Tyr_Et","Thr_PO3H2","Aca","D-Tyr_Et"],["meI","hHis","Aca","Cys_SEt","T","dK","Thr_PO3H2","Aca","dK","Thr_PO3H2","Aca"],["Lys_Boc","hHis","Aca","Cys_SEt","T","dK","Thr_PO3H2","Aca","dK","Thr_PO3H2","Aca"],["meI","hHis","Aca","Cys_SEt","T","dK","Thr_PO3H2","T","dK","Thr_PO3H2"]]}}};for(const[t,s]of Object.entries(e))(0,i.Bu)(`splitted-${t}`,(async()=>{const t=n.DataFrame.fromCsv(s.src.csv).getCol("seq"),e=await l.functions.call("Bio:detectMacromolecule",{col:t});e&&(t.semType=e),(0,i.l_)(t.semType,n.SEMTYPE.MACROMOLECULE);const o=u.Cn.getOrCreate(t);(0,i.l_)(o.notation,s.tgt.notation),(0,i.l_)(o.separator===s.tgt.separator,!0);const r=o.splitted;(0,i.f6)(r,s.tgt.splitted)}),t==j.separatorMsa?{skipReason:"#2468 CSV row starting with the quote character"}:void 0)})),(0,i.W3)("UnitsHandler: getRegion",(()=>{const t={fastaDna:{srcCsv:"seq\nATTCGT\nACTGCTC\nATTCCGTA",startIdx:2,endIdx:4,tgtCsv:"seq\nTCG\nTGC\nTCC",units:h.r2.FASTA,alphabet:"DNA",positionNames:{tag:"a, b, c, d, e, f, g, h",start:"c",end:"e"}},separatorPt:{srcCsv:"seq\nM-D-Y-K-E-T-L\nM-I-E-V-F-L-F-G-I\nM-M-",startIdx:5,endIdx:null,tgtCsv:"seq\nT-L--\nL-F-G-I\n---",units:h.r2.SEPARATOR,alphabet:"PT",positionNames:{tag:"1, 1A, 1B, 2, 3, 4, 4A, 4A, 4C",start:"4",end:null}},helm:{srcCsv:"seq\nPEPTIDE1{[meI].[hHis].[Aca].N.T.[dE].[Thr_PO3H2].[Aca].[D-Tyr_Et].[Tyr_ab-dehydroMe].[dV].E.N.[D-Orn]}$$$$\nPEPTIDE1{[meI].[hHis].[Aca].[Cys_SEt].T.[dK].[Thr_PO3H2].[Aca].[Tyr_PO3H2].[D-Chg].[dV].[Phe_ab-dehydro]}$$$$\nPEPTIDE1{[Lys_Boc].[hHis].[Aca].[Cys_SEt].T}$$$$",startIdx:3,endIdx:6,tgtCsv:"seq\nPEPTIDE1{N.T.[dE].[Thr_PO3H2]}$$$$\nPEPTIDE1{[Cys_SEt].T.[dK].[Thr_PO3H2]}$$$$\nPEPTIDE1{[Cys_SEt].T.*.*}$$$$",units:h.r2.HELM,alphabet:null,positionNames:{tag:null,start:"4",end:"7"}}};for(const[e,s]of Object.entries(t))(0,i.Bu)(`${e}-idx`,(async()=>{const t=n.DataFrame.fromCsv(s.srcCsv).getCol("seq"),e=await l.functions.call("Bio:detectMacromolecule",{col:t});e&&(t.semType=e);const o=u.Cn.getOrCreate(t).getRegion(s.startIdx,s.endIdx,"regSeq"),r=n.DataFrame.fromCsv(s.tgtCsv).getCol("seq");(0,i.l_)(t.getTag(n.TAGS.UNITS),s.units),(0,i.l_)(o.getTag(n.TAGS.UNITS),s.units),(0,i.l_)(t.getTag("alphabet"),s.alphabet),(0,i.l_)(o.getTag("alphabet"),s.alphabet),(0,i.f6)(o.toList(),r.toList())})),s.positionNames&&(0,i.Bu)(`${e}-positionNames`,(async()=>{const t=n.DataFrame.fromCsv(s.srcCsv).getCol("seq");s.positionNames.tag&&t.setTag(".positionNames",s.positionNames.tag);const e=await l.functions.call("Bio:detectMacromolecule",{col:t});e&&(t.semType=e);const o=await l.functions.call("Bio:getRegion",{sequence:t,start:s.positionNames.start,end:s.positionNames.end}),r=n.DataFrame.fromCsv(s.tgtCsv).getCol("seq");(0,i.l_)(t.getTag(n.TAGS.UNITS),s.units),(0,i.l_)(o.getTag(n.TAGS.UNITS),s.units),(0,i.l_)(t.getTag("alphabet"),s.alphabet),(0,i.l_)(o.getTag("alphabet"),s.alphabet),(0,i.f6)(o.toList(),r.toList())}))}));var Q=s(8601);const J=new n.FileSource("System:AppData/Bio"),tt={PT:"peptides-fasta",DNA:"dna-fasta",MSA:"msa-separator"},et={PT:"tests/to-atomic-level-peptides-fasta-input.csv",DNA:"tests/to-atomic-level-dna-fasta-input.csv",MSA:"tests/to-atomic-level-msa-separator-input.csv"},st={PT:"tests/to-atomic-level-peptides-fasta-output.csv",DNA:"tests/to-atomic-level-dna-fasta-output.csv",MSA:"tests/to-atomic-level-msa-separator-output.csv"},nt="molfile(sequence)";async function it(t,e="seq",s){const n=t.getCol(e),i=s.getBioLib(),o=await(0,Q.i0)(t,n,i);return o.warnings.length>0&&pt.logger.warning(`_toAtomicLevel() warnings ${o.warnings.join("\n")}`),o.col}function ot(t){return t.replaceAll("\r\n","\n").replace(/\n$/,"").split("\n").map((t=>t.trimEnd())).join("\n")}(0,i.W3)("toAtomicLevel",(async()=>{const t={},e={};let s,o,r;async function a(t,e){const s=t.getCol("sequence");await(0,c.toAtomicLevel)(t,s,!1);const n=t.getCol(nt),o=e.getCol(nt),r=F()(n.values()).map((t=>ot(t))).toArray(),a=F()(o.values()).map((t=>ot(t))).toArray();(0,i.f6)(r,a)}(0,i.bb)((async()=>{s=await(0,x.JN)(),o=await(0,I.nW)(),await(0,I.tb)(),await s.loadLibraries(!0);for(const s in tt)t[s]=n.DataFrame.fromCsv((await J.readAsText(et[s])).replace(/\n$/,"")),await l.data.detectSemanticTypes(t[s]),e[s]=n.DataFrame.fromCsv((await J.readAsText(st[s])).replace(/\n$/,""))})),(0,i.X5)((async()=>{await(0,I.tW)(o),await s.loadLibraries(!0)}));for(const s in tt)(0,i.Bu)(`${tt[s]}`,(async()=>{await a(t[s],e[s])}));!function(t){t.fastaDna="fastaDna",t.fastaRna="fastaRna",t.fastaPt="fastaPt",t.separatorDna="separatorDna",t.separatorRna="separatorRna",t.separatorPt="separatorPt",t.separatorUn="separatorUn",t.helm="helm"}(r||(r={}));const m={[r.fastaDna]:"seq\nACGTCACGTC\nCAGTGTCAGTGT\nTTCAACTTCAAC",[r.fastaRna]:"seq\nACGUCACGUC\nCAGUGUCAGUGU\nUUCAACUUCAAC",[r.fastaPt]:"seq\nFWPHEYFWPHEY\nYNRQWYVYNRQWYV\nMKPSEYVMKPSEYV",[r.separatorDna]:"seq\nA/C/G/T/C/A/C/G/T/C\nC/A/G/T/G/T/C/A/G/T/G/T\nT/T/C/A/A/C/T/T/C/A/A/C",[r.separatorRna]:"seq\nA*C*G*U*C*A*C*G*U*C\nC*A*G*U*G*U*C*A*G*U*G*U\nU*U*C*A*A*C*U*U*C*A*A*C",[r.separatorPt]:"seq\nF-W-P-H-E-Y-F-W-P-H-E-Y\nY-N-R-Q-W-Y-V-Y-N-R-Q-W-Y-V\nM-K-P-S-E-Y-V-M-K-P-S-E-Y-V",[r.separatorUn]:"seq\nmeI-hHis-Aca-N-T-dE-Thr_PO3H2-Aca-D-meI-hHis-Aca-N-T-dE-Thr_PO3H2-Aca-D\nmeI-hHis-Aca-Cys_SEt-T-dK-Thr_PO3H2-Aca-Tyr_PO3H2-meI-hHis-Aca-Cys_SEt-T-dK-Thr_PO3H2-Aca-Tyr_PO3H2\nLys_Boc-hHis-Aca-Cys_SEt-T-dK-Thr_PO3H2-Aca-Tyr_PO3H2-Lys_Boc-hHis-Aca-Cys_SEt-T-dK-Thr_PO3H2-Aca-Tyr_PO3H2",[r.helm]:"seq\nPEPTIDE1{meI.D-gGlu.Aca.N.T.dE.Thr_PO3H2.Aca.D.Thr_PO3H2.Aca.D}$$$\nPEPTIDE1{meI.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.Aca.Tyr_PO3H2.Thr_PO3H2.Aca.Tyr_PO3H2}$$$\nPEPTIDE1{Lys_Boc.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.Aca.Tyr_PO3H2.Thr_PO3H2.Aca.Tyr_PO3H2}$$$"};async function d(t){const e=m[t],s=n.DataFrame.fromCsv(e.replace(/\n$/,""));return await l.data.detectSemanticTypes(s),s}(0,i.Bu)("fastaDna",(async()=>{await it(await d(r.fastaDna),"seq",s)})),(0,i.Bu)("fastaRna",(async()=>{await it(await d(r.fastaRna),"seq",s)})),(0,i.Bu)("fastaPt",(async()=>{await it(await d(r.fastaPt),"seq",s)})),(0,i.Bu)("separatorDna",(async()=>{await it(await d(r.separatorDna),"seq",s)})),(0,i.Bu)("separatorDna",(async()=>{await it(await d(r.separatorRna),"seq",s)})),(0,i.Bu)("separatorPt",(async()=>{await it(await d(r.separatorPt),"seq",s)})),(0,i.Bu)("separatorUn",(async()=>{await it(await d(r.separatorUn),"seq",s)})),(0,i.Bu)("helm",(async()=>{await it(await d(r.helm),"seq",s)})),(0,i.Bu)("ptFasta2",(async()=>{const t=await pt.files.readAsText("tests/to-atomic-level-pt-fasta-2.mol"),e=n.DataFrame.fromCsv("seq\nAR"),o=e.getCol("seq");o.semType=n.SEMTYPE.MACROMOLECULE,o.setTag(n.TAGS.UNITS,h.r2.FASTA),o.setTag("alphabet","PT"),u.Cn.getOrCreate(o);const r=await it(e,"seq",s);(0,i.l_)(ot(r.get(0)),ot(t))}))}));var rt=s(489);async function at(t){const e=n.DataFrame.fromCsv(t),s=e.col("seq"),i=await l.functions.call("Bio:detectMacromolecule",{col:s});return i&&(s.semType=i),await l.data.detectSemanticTypes(e),u.Cn.getOrCreate(s)}function lt(t,e,s,n){const o=s(t,e);(0,i.l_)(Number(o.toFixed(3)),Number(n.toFixed(3)))}async function ct(t,e,s,n,o,r,a){await l.data.detectSemanticTypes(t);const h=await(0,c.activityCliffs)(t,t.getCol(s),t.getCol(n),o,e,a,{[`${c.BYPASS_LARGE_DATA_WARNING}`]:!0});(0,i.l_)(null!=h,!0);const u=Array.from(h.root.children).find((t=>{const e=t.className.split(" ");return["ui-btn","ui-btn-ok"].every((t=>e.includes(t)))}));(0,i.l_)(u.innerText.toLowerCase(),`${r} cliffs`)}(0,i.W3)("Distance",(async()=>{const t=[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]],e={F:0,W:1,R:2,Y:3},s="FWRWY",o="FWRWW",r="FWY",a="FWRWY",l="FWY",c="FWRRRRY";(0,i.Bu)("protein-distance-function",(async()=>{const t=(await at("seq\nFWRWYVKHPFWRWYVKHP\nYNRWYVKHPYNRWYVKHP\nMWRSWYCKHPMWRSWYCKHP")).getDistanceFunctionName();(0,i.l_)(t,rt.U.LEVENSHTEIN)})),(0,i.Bu)("DNA-distance-function",(async()=>{const t=(await at("seq\nATAACGATAACG\nATCGAATCGA\nATCGAATCGA")).getDistanceFunctionName();(0,i.l_)(t,rt.U.LEVENSHTEIN)})),(0,i.Bu)("MSA-distance-function",(async()=>{const t=(await at("seq\nATAACATAAC\nATCGAATCGA\nATCGAATCGA")).getDistanceFunctionName();(0,i.l_)(t,rt.U.HAMMING)})),(0,i.Bu)("levenstein-sub",(async()=>{const t=rt.o[rt.U.LEVENSHTEIN]();lt(s,o,t,.2)})),(0,i.Bu)("levenstein-del",(async()=>{const t=rt.o[rt.U.LEVENSHTEIN]();lt(r,a,t,.4)})),(0,i.Bu)("hamming",(async()=>{const t=rt.o[rt.U.HAMMING]();lt(r,a,t,.6)})),(0,i.Bu)("needleman-blosum62",(async()=>{const t=rt.o[rt.U.NEEDLEMANN_WUNSCH]({gapOpen:8,gapExtend:2});lt(s,o,t,-6)})),(0,i.Bu)("needleman-blosum62-del",(async()=>{const t=rt.o[rt.U.NEEDLEMANN_WUNSCH]({gapOpen:8,gapExtend:2});lt(r,a,t,-1.8)})),(0,i.Bu)("needleman-custom-sub",(async()=>{const n=rt.o[rt.U.NEEDLEMANN_WUNSCH]({scoringMatrix:t,alphabetIndexes:e,gapOpen:1,gapExtend:1});lt(s,o,n,.2)})),(0,i.Bu)("needleman-custom-del",(async()=>{const s=rt.o[rt.U.NEEDLEMANN_WUNSCH]({scoringMatrix:t,alphabetIndexes:e,gapOpen:1,gapExtend:1});lt(r,a,s,.8)})),(0,i.Bu)("needleman-custom-zero-extend",(async()=>{const s=rt.o[rt.U.NEEDLEMANN_WUNSCH]({scoringMatrix:t,alphabetIndexes:e,gapOpen:1,gapExtend:0});lt(l,c,s,.714)})),(0,i.Bu)("needleman-custom-half-extend",(async()=>{const s=rt.o[rt.U.NEEDLEMANN_WUNSCH]({scoringMatrix:t,alphabetIndexes:e,gapOpen:2,gapExtend:1});lt(l,c,s,1.286)})),(0,i.Bu)("needleman-custom-same-extend",(async()=>{const s=rt.o[rt.U.NEEDLEMANN_WUNSCH]({scoringMatrix:t,alphabetIndexes:e,gapOpen:1,gapExtend:1});n.Test.isInBenchmark?lt(Array(1e4).fill("FWRY").join(""),Array(1e4).fill("FYWRRY").join(""),s,.667):lt(l,c,s,1.143)}))}));var ht=s(116),ut=s(6361);(0,i.W3)("activityCliffs",(async()=>{let t,e,s=[],o=[];(0,i.bb)((async()=>{t=await(0,x.JN)(),e=await(0,I.nW)(),await(0,I.tb)(),await t.loadLibraries(!0),s=[],o=[]})),(0,i.X5)((async()=>{await(0,I.tW)(e),await t.loadLibraries(!0)})),(0,i.Bu)("activityCliffsOpens",(async()=>{const t=await T(n.Test.isInBenchmark?"test/peptides_motif-with-random_10000.csv":"tests/100_3_clustests.csv");o.push(t);const e=l.shell.addTableView(t);s.push(e);const i=n.Test.isInBenchmark?6:3;await ct(t,ht.AL.UMAP,"sequence","Activity",90,i,rt.U.LEVENSHTEIN)})),(0,i.Bu)("activityCliffsWithEmptyRows",(async()=>{const t=await T("tests/100_3_clustests_empty_vals.csv");o.push(t);const e=l.shell.addTableView(t);s.push(e),await ct(t,ht.AL.UMAP,"sequence","Activity",90,3,rt.U.LEVENSHTEIN)})),(0,i.Bu)("Helm",(async()=>{const t=await pt.files.readCsv("data/sample_HELM_50.csv");l.shell.addTableView(t),await ct(t,ht.AL.UMAP,"HELM","Activity",65,4,ut.gk.Tanimoto)}))}));var mt=s(3277);async function dt(t,e,s){const o=t.getCol(s),r=await l.functions.call("Bio:detectMacromolecule",{col:o});r&&(o.semType=r);const a=n.Func.find({package:"Bio",name:"macromoleculePreprocessingFunction"})[0];if(!a)throw new Error("Preprocessing function not found");const h=await(0,c.sequenceSpaceTopMenu)(t,t.col(s),e,rt.U.LEVENSHTEIN,!0,a,{[mt.sS]:!0});(0,i.l_)(null!=h,!0)}(0,i.W3)("sequenceSpace",(async()=>{let t,e,s,o;(0,i.Bu)("sequenceSpaceOpens",(async()=>{t=await T(n.Test.isInBenchmark?"test/peptides_motif-with-random_10000.csv":"tests/100_3_clustests.csv"),e=l.shell.addTableView(t),await dt(t,ht.AL.UMAP,"sequence")})),(0,i.Bu)("sequenceSpaceWithEmptyRows",(async()=>{s=await T("tests/100_3_clustests_empty_vals.csv"),o=l.shell.addTableView(s),await dt(s,ht.AL.UMAP,"sequence")}))})),(0,i.W3)("Scoring",(()=>{const t="sequence",e="expected_similarity",s="expected_identity",o=n.DataFrame.fromCsv(`${t},${e},${s}\nPEPTIDE1{Aca.Orn.gGlu.Pqa.D-His_1Bn.dH.hHis.4Abz.D-Tic.D-Dap.Y.Iva.meS.F.P.F.D-1Nal}$$$$,1.0,1.0\nPEPTIDE1{Iva.Gly_allyl.gGlu.Pqa.D-Dip.dH.hHis.4Abz.D-aHyp.D-Dap.Y.Iva.I.Tyr_26diMe.P.Asu.meC}$$$$,0.68,0.53\nPEPTIDE1{[1Nal].[1Nal].[1Nal].[1Nal].[1Nal].[1Nal].[1Nal].[1Nal].[1Nal].[1Nal].[1Nal].[1Nal].[1Nal].[1Nal].[1Nal].[1Nal].[1Nal]}$$$$V2.0,0.34,0.0`),r=o.getCol(t);r.setTag(n.TAGS.UNITS,h.r2.HELM),r.semType=n.SEMTYPE.MACROMOLECULE;const a=r.get(0);let l,u;(0,i.bb)((async()=>{l=await(0,x.JN)(),u=await(0,I.nW)(),await(0,I.tb)(),await l.loadLibraries(!0)})),(0,i.X5)((async()=>{await(0,I.tW)(u),await l.loadLibraries(!0)})),(0,i.Bu)("Identity",(async()=>{const t=await(0,c.sequenceIdentityScoring)(o,r,a);for(let e=0;e<t.length;e++)(0,i.jh)(t.get(e),o.get(s,e),.01,`Wrong identity score for sequence at position ${e}`)})),(0,i.Bu)("Similarity",(async()=>{const t=await(0,c.sequenceSimilarityScoring)(o,r,a);for(let s=0;s<t.length;s++)(0,i.jh)(t.get(s),o.get(e,s),.01,`Wrong similarity score for sequence at position ${s}`)}))}));const pt=new n.Package},6423:(t,e,s)=>{"use strict";s.r(e),s.d(e,{BYPASS_LARGE_DATA_WARNING:()=>ds,GetRegionEditor:()=>As,SeqActivityCliffsEditor:()=>Ms,SeqPaletteCustom:()=>fs,SequenceSpaceEditor:()=>Es,SplitToMonomersEditor:()=>Ss,SubsequenceSearchTopMenu:()=>on,_package:()=>ms,activityCliffs:()=>Ds,addCopyMenu:()=>pn,alignSequences:()=>Us,bioSubstructureFilter:()=>cn,compositionAnalysis:()=>$s,compositionAnalysisWidget:()=>Is,convertDialog:()=>qs,demoBioActivityCliffs:()=>yn,demoBioAtomicLevel:()=>wn,demoBioHelmMsaSequenceSpace:()=>Cn,demoBioSequenceSpace:()=>fn,demoBioSimilarityDiversity:()=>gn,detectMacromoleculeProbe:()=>An,diversitySearchTopMenu:()=>sn,diversitySearchViewer:()=>en,fastaSequenceCellRenderer:()=>Ns,getBioLib:()=>Cs,getHelmMonomers:()=>Qs,getMonomerLibHelper:()=>ps,getRegion:()=>Gs,getRegionApp:()=>mn,getRegionHelmApp:()=>dn,getRegionPanel:()=>Ts,getRegionTopMenu:()=>Fs,helmPreprocessingFunction:()=>Ws,hydrophobPalette:()=>gs,importBam:()=>Ks,importFasta:()=>Ys,initBio:()=>ys,libraryPanel:()=>bs,macroMolColumnPropertyPanel:()=>xs,macromoleculeDifferenceCellRenderer:()=>Ps,macromoleculePreprocessingFunction:()=>Hs,monomerCellRenderer:()=>zs,multipleSequenceAlignmentDialog:()=>Vs,packageSettingsEditor:()=>vs,polyTool:()=>Zs,polyToolColumnChoice:()=>Tn,saveAsFasta:()=>ln,sdfToJsonLib:()=>bn,searchSubsequenceEditor:()=>nn,separatorSequenceCellRenderer:()=>Ls,sequenceAlignment:()=>Rs,sequenceIdentityScoring:()=>rn,sequenceSimilarityScoring:()=>an,sequenceSpaceTopMenu:()=>ks,sequenceTooltip:()=>ws,similaritySearchTopMenu:()=>tn,similaritySearchViewer:()=>Js,splitToMonomersTopMenu:()=>js,testDetectMacromolecule:()=>Xs,toAtomicLevel:()=>Bs,vdRegionsViewer:()=>Os,webLogoAggApp:()=>un,webLogoLargeApp:()=>hn,webLogoViewer:()=>_s});var n=s(4469),i=s(3870),o=s(976),r=s(116),a=s(3277);o.SEMTYPE.MOLECULE,o.SEMTYPE.MACROMOLECULE;class l{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.editorSettings={},this.plotEmbeddingsInput=i.boolInput("Plot embeddings",!0),this.preprocessingFunctionInputRoot=null,this.columnFunctionsMap={},this.supportedFunctions={},this.availableMetrics=[],this.methodSettingsDiv=i.inputs([]),this.methodsParams={[r.AL.UMAP]:new r.bD,[r.AL.T_SNE]:new r.aP},this.editorSettings=t,o.Func.find({tags:[a.n3]}).forEach((t=>{const e=t.options.get(a.vO)??"",s=t.friendlyName??t.name,n=t.options.get(a.ts)??"",i=t.options.get(a.q6)??"",o=t.options.get(a.dB)??"";this.editorSettings.semtype&&!e.includes(this.editorSettings.semtype)||this.editorSettings.type&&!n.includes(this.editorSettings.type)||this.editorSettings.units&&!i.includes(this.editorSettings.units)||(this.supportedFunctions[s]={func:t,semTypes:e?e.split(","):[],types:n?n.split(","):[],units:i?i.split(","):[],distanceFunctions:o?o.split(","):[]})})),this.tableInput=i.tableInput("Table",n.shell.tv.dataFrame,n.shell.tables,(()=>{this.onTableInputChanged()})),this.onTableInputChanged(),this.regenerateColInput(),this.onColumnInputChanged();let e=!1;this.methodInput=i.choiceInput("Method",r.AL.UMAP,[r.AL.UMAP,r.AL.T_SNE],(()=>{e&&this.createAlgorithmSettingsDiv(this.methodSettingsDiv,this.methodsParams[this.methodInput.value])})),this.methodSettingsIcon=i.icons.settings((()=>{e=!e,e?this.createAlgorithmSettingsDiv(this.methodSettingsDiv,this.methodsParams[this.methodInput.value]):i.empty(this.methodSettingsDiv)}),"Modify methods parameters"),this.methodInput.root.classList.add("ml-dim-reduction-settings-input"),this.methodInput.root.prepend(this.methodSettingsIcon),this.methodSettingsDiv=i.inputs([]);const s=this.columnFunctionsMap[this.colInput.value.name];this.preprocessingFunctionInput=i.choiceInput("Encoding function",s[0],s,(()=>{this.onPreprocessingFunctionChanged()})),this.preprocessingFunctionInputRoot||(this.preprocessingFunctionInputRoot=this.preprocessingFunctionInput.root),this.similarityMetricInput=i.choiceInput("Similarity","",[],null),this.similarityMetricInput.nullable=!1,this.similarityMetricInputRoot||(this.similarityMetricInputRoot=this.similarityMetricInput.root),this.onPreprocessingFunctionChanged()}getColInput(){const t=this.tableInput.value?.columns.toList().find((t=>!!this.columnFunctionsMap[t.name]))??null,e=i.columnInput("Column",this.tableInput.value,t,(()=>this.onColumnInputChanged()),{filter:t=>!!this.columnFunctionsMap[t.name]});return this.colInputRoot||(this.colInputRoot=e.root),e}regenerateColInput(){let t=!1;this.colInputRoot&&(t=!0,i.empty(this.colInputRoot)),this.colInput=this.getColInput(),t&&Array.from(this.colInput.root.children).forEach((t=>this.colInputRoot.append(t))),this.onColumnInputChanged()}onTableInputChanged(){const t=this.tableInput.value;t&&(this.columnFunctionsMap={},t.columns.toList().forEach((t=>{Object.keys(this.supportedFunctions).forEach((e=>{const s=this.supportedFunctions[e].semTypes,n=this.supportedFunctions[e].types,i=this.supportedFunctions[e].units,r=!s.length||t.semType&&s.includes(t.semType),a=!n.length||n.includes(t.type),l=!i.length||t.getTag(o.TAGS.UNITS)&&i.includes(t.getTag(o.TAGS.UNITS));r&&a&&l&&(this.columnFunctionsMap[t.name]||(this.columnFunctionsMap[t.name]=[]),this.columnFunctionsMap[t.name].push(e))}))})),this.regenerateColInput())}onColumnInputChanged(){const t=this.colInput.value;if(console.log(t?.name),!t)return;const e=this.columnFunctionsMap[t.name];this.preprocessingFunctionInput=i.choiceInput("Preprocessing function",e[0],e,(()=>{this.onPreprocessingFunctionChanged()}));let s=!1;this.preprocessingFunctionInputRoot||(this.preprocessingFunctionInputRoot=this.preprocessingFunctionInput.root,s=!0),s||(i.empty(this.preprocessingFunctionInputRoot),Array.from(this.preprocessingFunctionInput.root.children).forEach((t=>this.preprocessingFunctionInputRoot.append(t)))),this.onPreprocessingFunctionChanged(),e.length<2?this.preprocessingFunctionInputRoot.style.display="none":this.preprocessingFunctionInputRoot.style.display="block"}onPreprocessingFunctionChanged(){const t=this.preprocessingFunctionInput.value,e=this.supportedFunctions[t].distanceFunctions;this.availableMetrics=[...e],this.similarityMetricInput=i.choiceInput("Similarity",this.availableMetrics[0],this.availableMetrics,null),this.similarityMetricInput.nullable=!1,this.similarityMetricInputRoot||(this.similarityMetricInputRoot=this.similarityMetricInput.root),i.empty(this.similarityMetricInputRoot),Array.from(this.similarityMetricInput.root.children).forEach((t=>this.similarityMetricInputRoot.append(t)))}createAlgorithmSettingsDiv(t,e){return i.empty(t),Object.keys(e).forEach((s=>{const n=e[s],o=i.floatInput(n.uiName,n.value,(()=>{n.value=o.value}));i.tooltip.bind(o.root,n.tooltip),t.append(o.root)})),t}getEditor(){return i.div([this.tableInput,this.colInputRoot,this.preprocessingFunctionInputRoot,this.methodInput,this.methodSettingsDiv,this.similarityMetricInputRoot,this.plotEmbeddingsInput],{style:{minWidth:"320px"},classes:"ui-form"})}getParams(){return{table:this.tableInput.value,col:this.colInput.value,methodName:this.methodInput.value,preprocessingFunction:this.supportedFunctions[this.preprocessingFunctionInput.value].func,similarityMetric:this.similarityMetricInput.value,plotEmbeddings:this.plotEmbeddingsInput.value,options:this.algorithmOptions}}}var c=s(850);const h="dimensionality-reducer-terminate-event";async function u(t,e,i,o,r,a){const l=await async function(t,e,i,o,r){return new Promise((function(a,l){const c=new Worker(new URL(s.p+s.u(935),s.b));c.postMessage({columnData:t.data,method:e,measure:t.metric,options:i,parallelDistanceWorkers:o});const u=n.events.onCustomEvent(h).subscribe((()=>{try{c?.terminate()}finally{u.unsubscribe()}}));c.onmessage=({data:{error:t,distance:e,embedding:s,epochNum:n,epochsLength:i}})=>{n&&i?r&&r(n,i,s):(u.unsubscribe(),t?l(t):a({distance:e,embedding:s}),setTimeout((()=>c.terminate()),0))}}))}({data:t,metric:i},e,o,r,a);return l.embedding=l.embedding.map((t=>(0,c.Fv)(t))),l}var m=s(5697),d=s(1040),p=s(489);const g={[o.SEMTYPE.MOLECULE]:"Molecules",[o.SEMTYPE.MACROMOLECULE]:"Sequences"},f="show-scatterplot-progress";class y{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=i.inputs([]),this.methodsParams={[r.AL.UMAP]:new r.bD,[r.AL.T_SNE]:new r.aP},this.tableInput=i.tableInput("Table",n.shell.tv.dataFrame,void 0,(()=>{this.onTableInputChanged(t)})),this.molColInput=i.columnInput(g[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=i.choiceInput("Method",r.AL.UMAP,[r.AL.UMAP,r.AL.T_SNE],(()=>{e&&this.createAlgorithmSettingsDiv(this.methodSettingsDiv,this.methodsParams[this.methodInput.value])})),this.initSimilarityMetricInput(t),this.methodSettingsIcon=i.icons.settings((()=>{e=!e,e?this.createAlgorithmSettingsDiv(this.methodSettingsDiv,this.methodsParams[this.methodInput.value]):i.empty(this.methodSettingsDiv)}),"Modify methods parameters"),this.methodInput.root.classList.add("ml-dim-reduction-settings-input"),this.methodInput.root.prepend(this.methodSettingsIcon),this.methodSettingsDiv=i.inputs([]);let e=!1;setTimeout((()=>{this.onColumnInputChanged(t)}))}createAlgorithmSettingsDiv(t,e){return i.empty(t),Object.keys(e).forEach((s=>{const n=e[s],o=i.floatInput(n.uiName,n.value,(()=>{n.value=o.value}));i.tooltip.bind(o.root,n.tooltip),t.append(o.root)})),t}onTableInputChanged(t){this.molColInput=i.columnInput(g[t],this.tableInput.value,this.tableInput.value.columns.bySemType(t)),this.molColInput.onChanged((()=>this.onColumnInputChanged(t))),i.empty(this.molColInputRoot),Array.from(this.molColInput.root.children).forEach((t=>this.molColInputRoot.append(t))),this.onColumnInputChanged(t)}initSimilarityMetricInput(t){const e=this.molColInput.value;if(!e)return;this.similarityMetricInputRoot&&i.empty(this.similarityMetricInputRoot);const s=t===o.SEMTYPE.MOLECULE||"helm"===e.getTag("units")?i.choiceInput("Similarity",d.gk.Tanimoto,m.Rt):i.choiceInput("Similarity",p.U.HAMMING,m.bc);this.similarityMetricInputRoot||(this.similarityMetricInputRoot=s.root),this.similarityMetricInputRoot&&Array.from(s.root.children).forEach((t=>this.similarityMetricInputRoot.append(t))),this.similarityMetricInput=s,this.similarityMetricInput.value=t===o.SEMTYPE.MOLECULE||"helm"===e.getTag("units")?d.gk.Tanimoto:p.U.HAMMING}onColumnInputChanged(t){const e=this.molColInput.value;if(!e)return;if(this.initSimilarityMetricInput(t),t!==o.SEMTYPE.MACROMOLECULE||"helm"===e.getTag("units"))return;const s=(e.getTag("aligned")??" ").toUpperCase().includes("MSA");this.similarityMetricInput.value=s?p.U.HAMMING:p.U.LEVENSHTEIN}}class w extends y{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=i.columnInput("Activities",this.tableInput.value,o.Utils.firstOrNull(e),null,{filter:t=>Array.from(e).includes(t)}),this.activitiesInputRoot=this.activitiesInput.root,this.similarityInput=i.intInput("Similarity cutoff",80),i.tooltip.bind(this.similarityInput.root,"Pairs of similar (cutoff is used) molecules with high difference in activity are considered 'cliffs'"),this.funcParamsDiv=i.div([this.tableInput,this.molColInput,this.activitiesInput,this.similarityInput,this.methodInput,this.methodSettingsDiv,this.similarityMetricInputRoot],{style:{minWidth:"320px"},classes:"ui-form"})}onTableInputChanged(t){super.onTableInputChanged(t),i.empty(this.activitiesInputRoot);const e=this.tableInput.value.columns.numerical;this.activitiesInput=i.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 C=s(701),T=s(3379),b=s.n(T),A=s(7795),S=s.n(A),E=s(569),M=s.n(E),v=s(3565),N=s.n(v),x=s(9216),I=s.n(x),L=s(4589),P=s.n(L),R=s(9414),_={};_.styleTagTransform=P(),_.setAttributes=N(),_.insert=M().bind(null,"head"),_.domAPI=S(),_.insertStyleElement=I(),b()(R.Z,_),R.Z&&R.Z.locals&&R.Z.locals;var O=s(2590),G=s(9657);let F=0;const D="cliffsDf",H="cliffs_col_encode_fn",W=new C.Subject,k="act_diff",B="sali",V="sim",U="line_index",$=["1_seq","2_seq"],Y="filterCliffs";async function K(t,e,s){const n=t.distance.map(((e,n)=>{const i=Math.abs(s.get(t.i[n])-s.get(t.j[n]));return 0!=e?i/e:1/0})),i=t.distance.map((t=>1-t)),o=t.i,r=t.j,a=new Set;return t.distance.forEach(((e,s)=>{a.add(t.i[s]),a.add(t.j[s])})),{simVals:i,saliVals:n,n1:o,n2:r,cliffsMolIds:a}}function q(t,e,s){const n=e.getBoundingClientRect(),i=t.clientX-n.left,o=t.clientY-n.top;let r=null,a=0;for(const t of s){const e=Math.abs(Math.hypot(t.a[0]-i,t.a[1]-o)+Math.hypot(t.b[0]-i,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 Z,z=s(499),X=s(5226),j=s(7228),Q=s(8457),J=s(585);async function tt(t,e,s,n){const i=(0,Q.O)(e),r=(0,J.vU)(e.getTag(o.TAGS.UNITS),e.getTag("separator"))(s),a=n===Z.IDENTITY?function(t,e){const s=e.columns.length,n=new Array(s),i=new Array(s),r=new Array(s);for(let o=0;o<s;++o){const s=e.columns.byIndex(o);n[o]=s.getRawData(),i[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)n[e][s]===r[e]&&++l[s];l[s]/=t.length}return a}(r,i):n===Z.SIMILARITY?await async function(t,e){const s=e.columns.toList();return await(0,j.Qx)(s,t)}(r,i):null;if(null===a)throw new Error(`In bio library: Unkown sequence scoring method: ${n}`);return a.name=t.columns.getUnusedName(a.name),t.columns.add(a),a}!function(t){t.IDENTITY="identity",t.SIMILARITY="similarity"}(Z||(Z={}));var et=s(7945),st=s(4293),nt=s(6414),it=s.n(nt);const ot="rgb(100,100,100)",rt="#808080",at="rgb(0,0,0)",lt=J.GU;var ct,ht;function ut(t,e,s,n,i,o,r=ot,a=0,l=!1,c=1,h="",u=!1,m=ht.classic,d=[],p=0,g=null,f=[],y=null,w={}){i.textAlign="start";let C=o.substring(0),T=u?"":h;m===ht.MSA&&(T="");let b=!0,A=!0,S="difference";null!=g&&null!=g.cell.column&&(b=g.cell.column.temp["color-code"]??!0,A=g.cell.column.temp["compare-with-current"]??!0,S=g.cell.column.temp["highlight-difference"]??"difference");const E=f[p];A&&f.length>0&&"difference"===S&&(c=C==E?.3:c),A&&f.length>0&&"equal"===S&&(c=C!=E?.3:c),null!=y&&(C=lt(C,y));const M=C+T;w[M]??(w[M]=i.measureText(M));let v=w[M];w[C]??(w[C]=i.measureText(C));let N=w[C].width;w[T]??(w[T]=i.measureText(T));const x=w[T].width,I=n/2-(v.fontBoundingBoxAscent+v.fontBoundingBoxDescent)/2+1;function L(s,n){const o=b?r:at;i.fillStyle=o,i.globalAlpha=c,m===ht.classic&&(i.fillText(C,t+s,e+I),i.fillStyle=rt,i.fillText(T,t+n,e+I)),m===ht.MSA&&i.fillText(C,t+s,e+I)}v=v.width,m===ht.MSA&&(N=d[p],v=d[p]);const P=(d[p]??0)-(d[0]??0);if(l||v>s)return L(P,P+N),t+P+N+x;{const e=(s-v)/2;return L(e,e+N),t+P+e+N}}!function(t){t.maxMonomerLength=".mm.cellRenderer.maxMonomerLength"}(ct||(ct={})),function(t){t.MSA="MSA",t.classic="classic"}(ht||(ht={}));var mt,dt=s(9611),pt=s(8447),gt=s(7331);!function(t){t.long="long",t.short="short"}(mt||(mt={}));const ft={true:"1",false:"0"};var yt=s(3553);const wt="rgb(100,100,100)",Ct=pt.GU;function Tt(t,e,s,n,i){return t?Math.max(Math.min(t.canvas.width/i-s,n)):Math.max(e.canvas.width/i-s,0)}function bt(t){const e=!it().enumerate(t).some((([e,s])=>e.length>1&&0!=s&&s!=t.length-1)),s=[],n=e?"":" ";for(const[e,i]of it().enumerate(t)){let o=e;i<t.length&&(o+=`${e?"":"-"}${n}`),s.push(o)}return[s,e]}class At 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=[i.div(t)];if(s._monomerStructureMap[t])o.push(s._monomerStructureMap[t]);else{const e=s.getMonomer(t);if(e){const i={autoCrop:!0,autoCropMargin:0,suppressChiralText:!0},r=n.chem.svgMol(e.smiles,void 0,void 0,i);o.push(r),s._monomerStructureMap[t]=r}}i.tooltip.show(i.divV(o),e.x+16,e.y+16)}else i.tooltip.hide()}render(t,e,s,n,i,r,a){let l,c=0,h=50;try{l=r.grid}catch(t){l=void 0;const[e,s]=(0,et.yf)(t);ms.logger.error(e,void 0,s)}const u=r.cell.column;if(!l||!u)return;const m=u.temp,d=m["monomer-width"];if("short"===(null!=d?d:"short")){const t=parseInt(u.getTag(ct.maxMonomerLength));h=(isNaN(t)?ms.properties?.MaxMonomerLength:t)??4}let p=u.temp["bio-seqCol"];p||(p=new dt.A(l,u,(()=>{const t=z.Cn.getOrCreate(u);return{unitsHandler:t,monomerCharWidth:7,separatorWidth:t.isMsa()?8:c,monomerToShort:Ct,monomerLengthLimit:h,monomerLib:Cs()}}))),u.tags[".mm.cellRenderer.settingsChanged"]===ft.true&&(c=m[".mm.cellRenderer.gapLength"]??c,p.setMonomerLengthLimit(h),p.setSeparatorWidth(p.isMsa()?8:c),u.setTag(".mm.cellRenderer.settingsChanged",ft.false));const[g,f]=p.getCellMonomerLengths(r.tableRowIndex);g.length,p.updated&&(m["bio-seqCol"]=p),t.save();try{const a=window.devicePixelRatio,l=-1!==r.gridRow?r.grid:null,c=r.cell.value,d=u.getTag("alphabet"),g=50;n=Tt(l,t,e,n,a),t.beginPath(),t.rect(e+this.padding,s+this.padding,n-this.padding-1,i-2*this.padding),t.clip(),t.font="12px monospace",t.textBaseline="top";const y=u.getTag(o.TAGS.UNITS),w=u.getTag("aligned"),C=(0,pt.py)(d),T=u.getTag("separator")??"",b=n/5,A=z.Cn.getOrCreate(u).getSplitter(b),S=m["reference-sequence"],E=m["current-word"],M=A(null!=S&&""!=S?S:E??""),v=A(c);let N=wt,x=ht.classic;w&&w.includes("MSA")&&y==pt.r2.SEPARATOR&&(x=ht.MSA);for(const[o,a]of it().enumerate(v)){N=C.get(o),t.fillStyle=wt;const l=a===v.length-1;if(ut(e+this.padding,s,n,i,t,o,N,0,!0,1,T,l,x,f,a,r,M,h,p._monomerLengthMap),g>n)break}}catch(t){const e=t instanceof Error?t.message:t?t.toString():"Error 'undefined'";ms.logger.error(`Bio: MacromoleculeSequenceCellRenderer.render() error: ${e}`)}finally{t.restore()}}}class St extends o.GridCellRenderer{get name(){return"MacromoleculeDifferenceCR"}get cellType(){return yt.Of.MACROMOLECULE_DIFFERENCE}get defaultHeight(){return 30}get defaultWidth(){return 230}render(t,e,s,n,i,r,a){const l=window.devicePixelRatio,c=r.grid,h=r.cell,u=r.tableColumn,m=h.value??"",d=u.tags.separator,p=u.tags[o.TAGS.UNITS];n=Tt(c,t,e,n,l);const[g,f]=m.split("#"),y=(0,J.vU)(p,d);Et(t,e,s,n,i,y(g),y(f),p)}}function Et(t,e,s,n,i,o,r,a,l,c){if(o.length!==r.length){const t=function(t,e){let s=0,n=0;const i=t.length>e.length?t:e,o=t.length>e.length?e:t;for(let t=0;t<o.length;t++)i[t]===o[t]&&s++;const r=i.length-o.length;for(let t=i.length-1;t>r;t--)i[t]===o[t-r]&&n++;const a=new Array(Math.abs(t.length-e.length)).fill("");function l(t){return s>n?t.concat(a):a.concat(t)}return t.length>e.length?e=l(e):t=l(t),{subParts1:t,subParts2:e}}(it()(o).toArray(),it()(r).toArray());o=t.subParts1,r=t.subParts2}const h=t.measureText(bt(o).join("")),u=t.measureText(bt(r).join("")),m=Math.max(h.width,u.width);l&&(n=m+4*o.length,t.canvas.width=m+4*o.length);let d=Math.max(e,e+(n-(m+4*o.length))/2)+5;const p=Math.max(s,s+(i-28)/2);t.save(),t.beginPath(),t.rect(e,s,l?m+4*o.length:n,i),t.clip(),t.font="12px monospace",t.textBaseline="top";let g=gt.UE.Color;"HELM"!=a&&(g=(0,pt.py)(a.substring(a.length-2)));for(let e=0;e<o.length;e++){const s=o[e],a=r[e],l=g.get(s);if(s!=a){const o=g.get(a),r=ut(d,p-7,n,i,t,s,l,0,!0),h=ut(d,p+7,n,i,t,a,o,0,!0);d=Math.max(h,r),c&&(c[e]=Mt(s,a,l,o,p,7,i))}else d=ut(d,p,n,i,t,s,l,0,!0,.5);d+=4}t.restore()}function Mt(t,e,s,n,i,o,r){const a=document.createElement("canvas"),l=a.getContext("2d");l.font="12px monospace";const c=l.measureText(bt([t]).join("")).width,h=l.measureText(bt([e]).join("")).width,u=Math.max(c,h);return a.height=r,a.width=u+4,l.font="12px monospace",l.textBaseline="top",ut(0,i-o,u,r,l,t,s,0,!0),ut(0,i+o,u,r,l,e,n,0,!0),a}var vt,Nt=s(8467),xt=s(9298);!function(t){t.Unknown="unknown",t.FR="framework",t.CDR="cdr"}(vt||(vt={}));const It=new class{constructor(){this.regionTypes=[vt.CDR],this.chains=["Heavy","Light"],this.skipEmptyPositions=!1,this.fitWidth=!1,this.positionWidth=16,this.positionHeight=xt.ES.Entropy,this.filterSource=xt.vS.filterSource}};var Lt=s(172),Pt=s(8415);const Rt=vt;var _t,Ot;!function(t){t.STYLE="Style",t.BEHAVIOR="Behavior",t.LAYOUT="Layout",t.DATA="Data"}(_t||(_t={})),function(t){t.skipEmptyPositions="skipEmptyPositions",t.regionTypes="regionTypes",t.chains="chains",t.fitWidth="fitWidth",t.positionWidth="positionWidth",t.positionHeight="positionHeight",t.filterSource="filterSource"}(Ot||(Ot={}));const Gt=It;class Ft extends o.JsViewer{constructor(){super(),this.viewed=!1,this.regionsFg=null,this.regionsRoot=null,this.isOpened=!1,this.panelNode=null,this.regions=[],this.viewerId=++Ft.viewerCounter,this.setDataInProgress=!1,this.host=null,this.mainLayout=null,this.logos=[],this.viewSubs=[],this.calcSizeRequested=!1,this._onRendered=new C.Subject,this.skipEmptyPositions=this.bool(Ot.skipEmptyPositions,Gt.skipEmptyPositions,{category:_t.DATA}),this.regionTypes=this.stringList(Ot.regionTypes,Gt.regionTypes,{category:_t.DATA,choices:Object.values(Rt).filter((t=>t!=Rt.Unknown))}),this.chains=this.stringList(Ot.chains,Gt.chains,{category:_t.DATA,choices:["Heavy","Light"]}),this.fitWidth=this.bool(Ot.fitWidth,Gt.fitWidth,{category:_t.LAYOUT}),this.positionWidth=this.float(Ot.positionWidth,Gt.positionWidth,{category:_t.LAYOUT,editor:"slider",min:0,max:64,description:"Internal WebLogo viewers property width of position."}),this.positionHeight=this.string(Ot.positionHeight,Gt.positionHeight,{category:_t.LAYOUT,choices:Object.keys(xt.ES)}),this.filterSource=this.string(Ot.filterSource,Gt.filterSource,{category:_t.BEHAVIOR,choices:Object.values(xt.Ct)}),this.viewSyncer=new Lt.c(ms.logger)}viewerToLog(){return`VdRegionsViewer<${this.viewerId}>`}async init(){this.subs.push((0,C.fromEvent)(this.root,"mousemove").subscribe(this.rootOnMouseMove.bind(this)))}detach(){const t=`${this.viewerToLog()}.detach()`,e=super.detach.bind(this);this.viewSyncer.sync(`${t}`,(async()=>{this.setDataInProgress||(this.viewed&&(await this.destroyView("detach"),this.viewed=!1),e())}))}onTableAttached(){super.onTableAttached(),this.setData(this.regions)}onPropertyChanged(t){if(super.onPropertyChanged(t),t){switch(t.name){case Ot.regionTypes:case Ot.chains:this.setData(this.regions)}switch(t.name){case Ot.skipEmptyPositions:for(let t=0;t<this.logos.length;++t)for(const e of this.chains)this.logos[t][e].setOptions({[Pt.bo.skipEmptyPositions]:this.skipEmptyPositions});this.calcSize();break;case Ot.fitWidth:case Ot.positionWidth:this.calcSize();break;case Ot.positionHeight:for(let t=0;t<this.logos.length;++t)for(const e of this.chains)this.logos[t][e].setOptions({[Pt.bo.positionHeight]:this.positionHeight});this.calcSize();break;case Ot.filterSource:this.filterSourceInput.value=this.filterSource;break;default:this.setData(this.regions)}}else console.warn("Bio: VdRegionsViewer.onPropertyChanged() property is null")}setData(t){const e=`${this.viewerToLog()}.setData()`;ms.logger.debug(`${e}, in, regions.length = ${t.length}`),this.viewSyncer.sync(`${e}`,(async()=>{if(!this.setDataInProgress){this.setDataInProgress=!0;try{this.viewed&&(await this.destroyView("setData"),this.viewed=!1),this.regions=t,this.viewed||(await this.buildView("setData"),this.viewed=!0)}finally{this.setDataInProgress=!1}}}))}async destroyView(t){ms.logger.debug(`Bio: VdRegionsViewer.destroyView( mainLayout = ${this.mainLayout?"value":"none"} ), purpose = '${t}', this.regions.length = ${this.regions.length}`),this.filterSourceInput&&i.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){ms.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(),n=[];for(let t=0;t<s.length;t++)for(const i of this.chains){const o=e.find((e=>e.order==s[t]&&e.chain==i));n.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,i,e]})())}const o=await Promise.all(n);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=i.table(this.chains,(t=>[...s.length>0?[i.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%",i.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=i.choiceInput("Data source",this.filterSource,Object.values(xt.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=i.div([this.mainLayout,this.filterSourceInput.root],{}),this.root.appendChild(this.host),this.root.style.overflowX="auto",this.calcSize(),this.viewSubs.push(i.onSizeChanged(this.root).subscribe(this.rootOnSizeChanged.bind(this))),ms.logger.debug("Bio: VdRegionsViewer.buildView() end")}calcSize(){ms.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,n=9,i=(this.root.clientWidth-t-(this.logos.length-1)*n-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({[Pt.bo.positionWidth]:i-s.positionMarginValue}),s.root.style.width=i*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({[Pt.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.viewerToLog()}.filterSourceInputOnValueChanged()`,e=this.filterSourceInput.value;this.viewSyncer.sync(`${t}`,(async()=>{if(this.filterSource!==e){this.props.getProperty(Ot.filterSource).set(this,e);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({[Pt.bo.filterSource]:this.filterSource})}}}))}get onRendered(){return this._onRendered}invalidate(){const t=`${this.viewerToLog()}.invalidate()`;this.viewSyncer.sync(`${t}`,(async()=>{this._onRendered.next()}))}async awaitRendered(t=5e3){await(0,Nt.zg)(this.onRendered,(()=>{}),(()=>{this.invalidate()}),t)}}Ft.viewerCounter=-1;var Dt=s(9017),Ht=s(7983);async function Wt(t){return t.seqCol.version!==t.seqCol.temp["last-invalidated-version"]&&await(0,Ht.HV)(t.seqCol,!1),await n.functions.call("Chem:getChemSpaceEmbeddings",{col:t.seqCol.temp["monomeric-mols"],methodName:t.methodName,similarityMetric:t.similarityMetric,xAxis:t.embedAxesNames[0],yAxis:t.embedAxesNames[1],options:t.options})}async function kt(t,e){const s=z.Cn.getOrCreate(t),n=t.toList(),i=s.getSplitter(),o=n.length;let r=36;const a=new Map;for(let e=0;e<o;e++){const s=n[e];if(null===n[e]||t.isNone(e)){n[e]=null;continue}n[e]="";const o=i(s);for(let t=0;t<o.length;t++){const s=o[t];a.has(s)||(a.set(s,String.fromCharCode(r)),r++),n[e]+=a.get(s)}}let l={};if(e===p.U.MONOMER_CHEMICAL_DISTANCE){const t=Array.from(a.keys()),e=await(0,j.PF)(t);e.scoringMatrix.forEach(((t,s)=>{t.forEach(((t,n)=>{e.scoringMatrix[s][n]=1-t}))}));const s={};Object.entries(e.alphabetIndexes).forEach((([t,e])=>{s[a.get(t)]=e})),l={scoringMatrix:e.scoringMatrix,alphabetIndexes:s}}else if(e===p.U.NEEDLEMANN_WUNSCH){const t=Array.from(a.keys()),e=await(0,j.PF)(t),s={};Object.entries(e.alphabetIndexes).forEach((([t,e])=>{s[a.get(t)]=e})),l={scoringMatrix:e.scoringMatrix,alphabetIndexes:s}}return{seqList:n,options:l}}async function Bt(t,e){if(z.Cn.getOrCreate(t.seqCol).isHelm())return await Wt(t);const{seqList:s,options:n}=await kt(t.seqCol,t.similarityMetric);t.options=t.options??{},t.options.distanceFnArgs=n;const i=await u(s,t.methodName,t.similarityMetric,t.options,!0,e),r=t.embedAxesNames.map(((t,e)=>o.Column.fromFloat32Array(t,i.embedding[e])));return{distance:i.distance,coordinates:new o.ColumnList(r)}}var Vt=s(6361);function Ut(t){const e=i.divH([]),s=i.divV([i.divText(t.seqCol.name),i.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,n)=>{const o=i.divText(t.activityCol.get(s).toFixed(2));o.style.display="flex",o.style.justifyContent="left",o.style.paddingLeft="30px",e.append(i.divV([i.divText(t.seqCol.get(s)),o]))})),e}function $t(t){const e=i.div();e.append(i.divText(t.seqCol.name,{style:{fontWeight:"bold"}}));const s=new Array(2),n=new Array(2);t.line.mols.forEach(((e,i)=>{s[i]=t.seqCol.get(e),n[i]=t.activityCol.get(e)}));const o={},r=z.Cn.getOrCreate(t.seqCol),a=r.getSplitter(),l=Kt(a(s[0]),a(s[1]),r.units,o);return e.append(i.div(l,{style:{width:"300px",overflow:"scroll"}})),e.append(qt(o)),e.append(Yt("Activity delta",Math.abs(n[0]-n[1]))),e.append(Yt("Cliff",t.sali)),e}function Yt(t,e){return i.divH([i.divText(`${t}: `,{style:{fontWeight:"bold",paddingRight:"5px"}}),i.divText(e.toFixed(2))],{style:{paddingTop:"10px"}})}function Kt(t,e,s,n){const i=document.createElement("canvas"),o=i.getContext("2d");return i.height=30,Et(o,0,0,0,30,t,e,s,!0,n),i}function qt(t){const e=i.div();if(Object.keys(t).length>0){const s=i.divV([]);s.append(i.divH([i.divText("Pos",{style:{fontWeight:"bold",width:"30px",borderBottom:"1px solid"}}),i.divText("Difference",{style:{fontWeight:"bold",borderBottom:"1px solid"}})]));for(const e of Object.keys(t))t[e].style.borderBottom="1px solid lightgray",s.append(i.divH([i.divText((parseInt(e)+1).toString(),{style:{width:"30px",borderBottom:"1px solid lightgray"}}),t[e]]));e.append(s)}return e}function Zt(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 n=t.plot.grid();return n.col(e[0]).visible=!1,n.col(e[1]).visible=!1,n}class zt 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",m.kg[0],{choices:m.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(i.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&&(n.shell.error(`${this.moleculeColumnName} is not Macromolecule type`),1))}}var Xt=s(7241),jt=s(2669);async function Qt(t){const e=t.toList();if(t.semType!==o.SEMTYPE.MACROMOLECULE)throw new Error("Column has to be of macromolecule type");const s=z.Cn.getOrCreate(t).getDistanceFunctionName(),n=new jt.m(!0,!1),i=await n.calc(e,s);return n.terminate(),i}function Jt(t){return(e,s)=>{const n=(e,s)=>t*e+s-Math.floor((e+2)*(e+1)/2);return e<=s?n(e,s):n(s,e)}}class te extends zt{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 C.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=z.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 i=s.plot.grid();i.col("indexes").visible=!1;const r=this.idxs?.getRawData().findIndex((t=>t==this.targetMoleculeIdx));i.cell("score",r).cell.value=null,n.shell.v.grid.root.addEventListener("click",(t=>{this.gridSelect=!1})),(0,st.Y)(this.root,i.root),this.computeCompleted.next(!0)}}async computeByChem(){const t=await(0,Xt.D)(this.moleculeColumn),e=(o.DataFrame.fromColumns([t]),await n.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 Qt(this.moleculeColumn),this.distanceMatrixComputed=!0):this.preComputeDistanceMatrix||(t=await async function(t,e){const n=t.toList();if(t.semType!==o.SEMTYPE.MACROMOLECULE)throw new Error("Column has to be of macromolecule type");const i=z.Cn.getOrCreate(t).getDistanceFunctionName(),r=Math.min(Math.max(navigator.hardwareConcurrency-2,1),n.length),a=new Array(r).fill(null).map((t=>new Worker(new URL(s.p+s.u(586),s.b)))),l=new Float32Array(n.length);let c=0,h=Number.MIN_VALUE;const u=a.map(((t,s)=>{const o=Math.floor(s*n.length/r),u=s===a.length-1?Math.floor((s+1)*n.length/r):n.length;return new Promise(((s,r)=>{t.onmessage=({data:{error:t,distanceArrayData:e,min:n,max:i}})=>{t?r(t):(c=Math.min(c,n),h=Math.max(h,i),l.set(e,o),s())},t.postMessage({fnName:i,values:n,templateIdx:e,start:o,end:u})}))}));try{await Promise.all(u),l.forEach(((t,e)=>{l[e]=(t-c)/(h-c)})),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,n=Jt(e),i=Array(e).fill(0).map(((e,s)=>({idx:s,score:s===this.targetMoleculeIdx?1:this.preComputeDistanceMatrix?1-this.mmDistanceMatrix[n(this.targetMoleculeIdx,s)]:1-t[s]})));i.sort(((t,e)=>e.score-t.score));const r=Math.min(this.limit,e),a=i.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=i.div(),s={},o=this.molCol?.name,r=t.col(o),a=z.Cn.getOrCreate(r),l=a.getSplitter(),c=l(this.moleculeColumn.get(this.targetMoleculeIdx)),h=l(t.get(o,t.currentRowIdx)),u=Kt(c,h,a.units,s);e.append(i.div(u,{style:{width:"300px",overflow:"scroll"}})),c.length!==h.length&&e.append(i.divV([i.divText("Different sequence length:",{style:{fontWeight:"bold"}}),i.divText(`target: ${c.length} monomers`),i.divText(`selected: ${h.length} monomers`)],{style:{paddingBottom:"10px"}})),e.append(qt(s));const m=i.accordion(),d=i.element("i");d.className="grok-icon svg-icon svg-view-layout",m.addTitle(i.span([d,i.label("Similarity search")])),m.addPane("Differences",(()=>e),!0),n.shell.o=m.root}}var ee=s(8518);class se extends zt{constructor(){super("diversity"),this.renderMolIds=null,this.columnNames=[],this.computeCompleted=new C.Subject,this.diverseColumnLabel=this.string("diverseColumnLabel",null)}async renderInt(t){if(this.beforeRender()&&this.dataFrame&&t&&this.moleculeColumn){const t=z.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 n=o.DataFrame.fromColumns([s]);n.onCurrentRowChanged.subscribe((t=>{this.dataFrame.currentRowIdx=this.renderMolIds[n.currentRowIdx]})),(0,st.Y)(this.root,n.plot.grid().root),this.computeCompleted.next(!0)}}async computeByChem(){const t=await(0,Xt.D)(this.moleculeColumn);o.DataFrame.fromColumns([t]),this.renderMolIds=await n.functions.call("Chem:callChemDiversitySearch",{col:t,metricName:this.distanceMetric,limit:this.limit,fingerprint:this.fingerprint})}async computeByMM(){const t=await Qt(this.moleculeColumn),e=this.moleculeColumn.length,s=Jt(e);this.renderMolIds=(0,ee.L)(e,Math.min(e,this.limit),((e,n)=>this.moleculeColumn.isNone(e)||this.moleculeColumn.isNone(n)?0:t[s(e,n)]))}}var ne,ie=s(4004),oe=s(9943),re=s(4413),ae=s(2918),le=function(t,e,s,n){return new(s||(s=Promise))((function(i,o){function r(t){try{l(n.next(t))}catch(t){o(t)}}function a(t){try{l(n.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof s?e:new s((function(t){t(e)}))).then(r,a)}l((n=n.apply(t,e||[])).next())}))};class ce{constructor(t,e,s=!1,n){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=i.div([],{id:"demo-script",classes:"tutorials-root tutorials-track demo-app-script"}),this._steps=[],this._mainHeader=i.panel([],"tutorials-main-header"),this._header=i.h2(""),this._headerDiv=i.divH([],"tutorials-root-header"),this._stopStartBtn=i.button(i.iconFA("pause"),(()=>this._changeStopState()),"Play / pause"),this._restartBtn=i.button(i.iconFA("redo"),(()=>this._restartScript()),"Restart"),this._nextStepBtn=i.button(i.iconFA("play"),(()=>{this._isStepProcessed||this._nextStep()}),"Next step"),this._activity=i.panel([],"tutorials-root-description"),this._progressDiv=i.divV([],"tutorials-root-progress"),this._progress=i.element("progress"),this._progressSteps=i.divText(""),this._closeBtn=i.button(i.iconFA("chevron-left"),(()=>this._closeDock()),"Back to demo"),this.name=t,this.description=e,this._isAutomatic=s,this._autoStartFirstStep=null!==(o=null==n?void 0:n.autoStartFirstStep)&&void 0!==o&&o,this._progress.max=0,this._progress.value=1,ce.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=i.divText(`Step: ${this._progress.value} of ${this.stepNumber}`),this._progressDiv.append(this._progressSteps)}_addDescription(){var t;this._activity.append(i.div(this.description,"tutorials-root-description"));for(let e=0;e<this.stepNumber;e++){let s=i.iconFA("clock");this._isAutomatic||0===e&&(s=i.iconFA("play",(()=>this._nextStep()),"Next step"),s.className="grok-icon fas fa-play");const n=i.div(this._steps[e].name,"grok-tutorial-entry-instruction"),o=i.div(null===(t=this._steps[e].options)||void 0===t?void 0:t.description,"grok-tutorial-step-description hidden"),r=i.divH([s,n],"grok-tutorial-entry");this._activity.append(r,o)}}_initRoot(){var t,e,s;n.shell.windows.showContextPanel=!0,n.shell.windows.showHelp=!1;const i=Array.from(n.shell.dockManager.rootNode.children)[0];this._node=n.shell.dockManager.dock(this._root,o.DOCK_TYPE.FILL,i,""),(null===(e=null===(t=i.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=i.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 le(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],n=this._activity.getElementsByClassName("grok-icon")[this._currentStep],o=this._activity.getElementsByClassName("grok-tutorial-step-description")[this._currentStep];n.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,n,a),yield(0,Nt.gw)(a));const l=i.iconFA("check");if(n.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=i.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 le(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 le(this,void 0,void 0,(function*(){const n=i.div([],"demo-script-countdown");e.classList.add("hidden");let o=s/1e3;const r=this._createSVGIndicator(o);n.append(r),t.prepend(n);const a=setInterval((()=>{o--,0===o&&(clearInterval(a),n.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(){n.shell.dockManager.close(this._node),n.shell.closeAll(),this._clearRoot(),this._setInitParams(),this.start()}_clearRoot(){this._root=i.div([],{id:"demo-script",classes:"tutorials-root tutorials-track demo-app-script"}),this._mainHeader=i.panel([],"tutorials-main-header"),this._header=i.h2(""),this._headerDiv=i.divH([],"tutorials-root-header"),this._activity=i.panel([],"tutorials-root-description"),this._progressDiv=i.divV([],"tutorials-root-progress"),this._progress=i.element("progress"),this._progressSteps=i.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(){n.shell.dockManager.close(this._node),this.cancelScript()}cancelScript(){this._isCancelled=!0,ce.currentObject=null}step(t,e,s){return this._steps[this.steps.length]={name:t,func:e,options:s},this}start(){return le(this,void 0,void 0,(function*(){this._initRoot(),n.shell.newView(this.name),this._isAutomatic?this._startScript():this._autoStartFirstStep&&(yield this._nextStep())}))}}function he(t){const e=t instanceof Error?t.message:t.toString(),s=t instanceof Error?t.stack:void 0;n.shell.error(e),ms.logger.error(t.message,void 0,s)}ce.currentObject=null,function(t){t.X="Embed_X",t.Y="Embed_Y"}(ne||(ne={}));const ue="data/sample_FASTA_PT_activity.csv";var me=s(1811),de=s(3914);async function pe(){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 ge(){return await n.functions.call("Dendrogram:getDendrogramService",{})}const fe="data/sample_FASTA_PT_activity.csv",ye="sequence";var we=s(3336),Ce=s.n(we);const Te="data/sample_FASTA_PT_activity.csv";var be=s(8341);const Ae="samples/HELM.csv";var Se=s(2568),Ee=s(525);class Me{constructor(t,e,s={}){this.urlParams=t,this.funcName=e,this.options=s}async init(t){this.df=t,await this.buildView()}async buildView(){const t=it()(this.urlParams.entries()).map((([t,e])=>`${t}=${encodeURIComponent(e)}`)).toArray().join("&");this.view=n.shell.addTableView(this.df),this.view.path=this.view.basePath=`func/${ms.name}.${this.funcName}?${t}`;const e={...this.options,sequenceColumnName:"sequence"};for(const[t,s]of this.urlParams.entries())switch(t){case Pt.bo.fixWidth:case Pt.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=i.tableInput("Table",n.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=i.columnInput("Sequence",this.tableInput.value,t,null,e),this.funcParamsDiv=i.inputs([this.tableInput,this.seqColInput],{style:{minWidth:"320px"}})}onTableInputChanged(){this.seqColInput=i.columnInput("Sequence",this.tableInput.value,this.tableInput.value.columns.bySemType(o.SEMTYPE.MACROMOLECULE))}}var Ne=s(9416);class xe{constructor(t){this.monomerLib=t}getCappedRotatedMonomer(t,e){const s=this.monomerLib.getMonomer(t,e);return s?s.molfile:null}}const Ie=new class{constructor(){this.tooltipHandlerTemp="tooltip-handler.Monomer"}},Le={autoCrop:!0,autoCropMargin:0,suppressChiralText:!0};class Pe{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 xe(ps().getBioLib()).getCappedRotatedMonomer(a,r),c=i.div(r),h=l?n.chem.svgMol(l,void 0,void 0,Le):null,u=t.grid.canvas.getBoundingClientRect(),m=t.bounds.right+u.left-4,d=t.bounds.bottom+u.top-4;return i.tooltip.show(i.divV([c,...h?[h]:[]]),m,d),!0}static getOrCreate(t){let e=t.temp[Ie.tooltipHandlerTemp];return e||(e=t.temp[Ie.tooltipHandlerTemp]=new Pe(t)),e}}class Re extends o.GridCellRenderer{get name(){return yt.Of.MONOMER}get cellType(){return yt.Of.MONOMER}get defaultHeight(){return 15}get defaultWidth(){return 40}render(t,e,s,n,i,o,r){if(o.gridRow<0)return;Pe.getOrCreate(o.gridColumn),t.font="12px monospace",t.textBaseline="middle",t.textAlign="center";const a=(0,pt.py)(o.cell.column.getTag("alphabet")),l=o.cell.value;if(!l)return;const c=a.get(l);t.fillStyle=c,t.fillText((0,pt.GU)(l,6),e+n/2,s+i/2,n)}}class _e 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 C.Subject}}class Oe 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;n.shell.error(e),this.logger.error(e,void 0,s)}}class Ge extends o.Widget{constructor(t){super(i.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=i.intInput("Max monomer length",ms.properties.MaxMonomerLength,(t=>{ms.properties.MaxMonomerLength=t})),e=i.boolInput("Tooltip WebLogo",ms.properties.TooltipWebLogo,(t=>{ms.properties.TooltipWebLogo=t})),s=i.choiceInput("Default Separator",ms.properties.DefaultSeparator,[".","/","-"],(t=>{ms.properties.DefaultSeparator=t}));this.root.appendChild(i.form([t,e,s]))}}var Fe=s(8770);class De extends o.Widget{constructor(t){super(i.divV([])),this.viewed=!1,this.seqCol=t}async init(){const t=z.Cn.getOrCreate(this.seqCol),e=ms.properties.TooltipWebLogo,s=this.seqCol.getTag(xt.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%")}}var He=s(9953);function We(t){t.setTag("quality",o.SEMTYPE.MACROMOLECULE),t.setTag("aligned","SEQ"),t.setTag("alphabet","PT")}var ke=s(922);async function Be(t,e){const s=new Ve(e,t),n=await s.convertToRdKitBeautifiedMolfileColumn();return n.semType=o.SEMTYPE.MOLECULE,n}class Ve{constructor(t,e){this.helmColumn=t,this.df=e,this.helmColumn=t}async convertToSmiles(){const t=await this.getSmilesList(),e=this.df.columns.getUnusedName(`smiles(${this.helmColumn.name})`);return o.Column.fromStrings(e,t.map((t=>null===t?"":t)))}async getSmilesList(){return(await this.convertToMolfileV2KColumn()).toList().map((t=>o.chem.convert(t,o.chem.Notation.MolBlock,o.chem.Notation.Smiles)))}async convertToRdKitBeautifiedMolfileColumn(){const t=await this.getSmilesList(),e=await n.functions.call("Chem:getRdKitModule"),s=t.map((t=>{if(""===t)return null;const s=e.get_mol(t);return s?(s.normalize_depiction(1),s.straighten_depiction(!0),s):null})),i=this.df.columns.getUnusedName(`molfile(${this.helmColumn.name})`);return o.Column.fromStrings(i,s.map((t=>null===t?"":t.get_molblock())))}async convertToMolfileV2KColumn(){const t=(await this.getPolymerGraphColumn()).toList().map(((t,e)=>{const s=this.helmColumn.get(e);if(!s)return"";let n="";try{n=this.getPolymerMolfile(s,t)}catch(t){const[e,s]=(0,et.yf)(t);ms.logger.error(e,void 0,s)}finally{return n}})),e=this.df.columns.getUnusedName(`molfileV2K(${this.helmColumn.name})`);return o.Column.fromList("string",e,t)}async getPolymerGraphColumn(){return await n.functions.call("HELM:getMolfiles",{col:this.helmColumn})}getPolymerMolfile(t,e){const s=new Ue(e),n=new Qe(t);return s.monomerSymbols.forEach(((t,e)=>{const i=s.getMonomerShifts(e);n.addMonomer(t,e,i)})),n.compileToMolfile()}}class Ue{constructor(t){this.molfileHandler=ke._.getInstance(t)}get monomerSymbols(){return this.molfileHandler.atomTypes}getMonomerShifts(t){return{x:this.molfileHandler.x[t],y:this.molfileHandler.y[t]}}}class $e{constructor(t,e){this.capGroupElements=[];const s=ae.NT.instance.getBioLib().getMonomer(e,t);if(!s)throw new Error(`Monomer ${t} is not found in the library`);this.molfileWrapper=new Ze(s.molfile,t),this.capGroupElements=s.rgroups.map((t=>(t.capGroupSmiles||t.capGroupSMILES).replace(/(\[|\]|\*|:|\d)/g,"")))}shiftCoordinates(t){this.molfileWrapper.shiftCoordinates(t)}getAtomLines(){return this.molfileWrapper.getAtomLines()}getBondLines(){return this.molfileWrapper.getBondLines()}removeBondedRGroups(t){this.molfileWrapper.removeRGroups(t)}capTrailingRGroups(){this.molfileWrapper.capRGroups(this.capGroupElements)}replaceRGroupWithAttachmentAtom(t,e){this.molfileWrapper.replaceRGroupWithAttachmentAtom(t,e)}getAttachmentAtomByRGroupId(t){return this.molfileWrapper.getAttachmentAtomByRGroupId(t)}deleteBondLineWithSpecifiedRGroup(t){this.molfileWrapper.deleteBondLineWithSpecifiedRGroup(t)}shiftBonds(t){this.molfileWrapper.shiftBonds(t)}}class Ye{constructor(t,e,s){this.atoms=e,this.bonds=s,this.rGroupBondPositionMap=new Map,this.rGroupIdToAtomicIndexMap=this.getRGroupIdToAtomicIdxMap(t)}getAtomicIdx(t){const e=this.rGroupIdToAtomicIndexMap.get(t);return void 0===e?null:e}removeRGroupsFromAtomBlock(t){t.forEach((t=>{if(void 0===this.rGroupIdToAtomicIndexMap.get(t))throw new Error(`Cannot find atomic index for R group ${t}`)}));const e=Array.from(this.rGroupIdToAtomicIndexMap.entries()).filter((([e,s])=>t.includes(e))).map((([t,e])=>e));this.atoms.deleteAtoms(e)}removeRGroups(t){this.removeRGroupsFromAtomBlock(t),t.forEach((t=>{const e=this.replaceRGroupInBondsByDummy(t);this.rGroupBondPositionMap.set(t,e)}))}replaceRGroupInBondsByDummy(t){const e=this.rGroupIdToAtomicIndexMap.get(t);if(this.rGroupBondPositionMap.has(t))throw new Error(`R group ${t} is already handled`);const s=this.bonds.getPositionsInBonds(e+1);if(0===s.length)throw new Error(`Cannot find position for R group ${t}`);if(s.length>1)throw new Error(`More than one position for R group ${t}`);const n=s[0];return this.bonds.replacePositionsInBondsByDummy([n]),this.bonds.removeAtomIdFromBonds(e+1),this.removeRGroupFromAtomicIdxMap(t,e),n}removeRGroupFromAtomicIdxMap(t,e){this.rGroupIdToAtomicIndexMap.delete(t);for(const[t,s]of this.rGroupIdToAtomicIndexMap)s>e&&this.rGroupIdToAtomicIndexMap.set(t,s-1)}getRGroupIdToAtomicIdxMap(t){const e=new Map;t.filter((t=>t.startsWith("M RGP"))).forEach((t=>{const s=function(t){const e=t.split(/\s+/).filter((t=>t)).slice(3).map((t=>parseInt(t))),s=new Array(e.length/2);for(let t=0;t<e.length;t+=2)s[t/2]=[e[t+1],e[t]-1];return s}(t);for(const[t,n]of s){if(e.has(t))throw new Error(`R group ${t} is already in the map`);e.set(t,n)}}));const s=t.map(((t,e)=>{if(t.startsWith("A "))return e})).filter((t=>void 0!==t)),n=s.map((e=>t[e])),i=s.map((e=>t[e+1]));n.forEach(((t,s)=>{const n=parseInt(t.split(/\s+/)[1])-1,o=parseInt(i[s].substring(1));if(e.has(o))throw new Error(`R group ${o} is already in the map`);e.set(o,n)}));const o=this.atoms.getRGroupAtomicIndices().filter((t=>!Array.from(e.values()).includes(t)));if(0!==o.length)throw new Error(`Unaccounted R group indices: ${o}`);return e}deleteBondLineWithSpecifiedRGroup(t){const e=this.rGroupBondPositionMap.get(t);if(!e)throw new Error(`Cannot find position for R group ${t}`);const{bondLineIdx:s}=e;this.bonds.deleteBondLines([s]),this.rGroupBondPositionMap.delete(t),this.rGroupIdToAtomicIndexMap.delete(t),this.rGroupBondPositionMap.forEach((t=>{t.bondLineIdx>s&&(t.bondLineIdx-=1)}))}replaceRGroupWithAttachmentAtom(t,e){const s=this.rGroupBondPositionMap.get(t);if(!s)throw new Error(`Cannot find position for R group ${t}`);const{bondLineIdx:n,nodeIdx:i}=s;this.bonds.bondedAtoms[n][i]=e}getAttachmentAtomIdByRGroupId(t){const e=this.rGroupBondPositionMap.get(t);if(!e)throw new Error(`Cannot find position for R group ${t}`);const{bondLineIdx:s,nodeIdx:n}=e;return this.bonds.bondedAtoms[s][(n+1)%2]}capRGroups(t){this.rGroupIdToAtomicIndexMap.forEach(((e,s)=>{const n=t[s-1];"H"===n?(this.removeRGroups([s]),this.deleteBondLineWithSpecifiedRGroup(s)):this.atoms.replaceElementSymbol(e,n)}))}}class Ke{constructor(t){this.bondedPairs=[],this.rawBondLines=[],this.rawBondLines=t,this.bondedPairs=this.rawBondLines.map((t=>[parseInt(t.substring(0,3)),parseInt(t.substring(3,6))]))}getBondLines(){return this.bondedPairs.map(((t,e)=>{if(t.some((t=>-1===t)))throw new Error(`Bonded pair ${t} contains -1`);return`${t[0].toString().padStart(3," ")}${t[1].toString().padStart(3," ")}${this.rawBondLines[e].substring(6)}`}))}get bondedAtoms(){return this.bondedPairs}deleteBondLines(t){this.rawBondLines=this.rawBondLines.filter(((e,s)=>!t.includes(s))),this.bondedPairs=this.bondedPairs.filter(((e,s)=>!t.includes(s)))}getPositionsInBonds(t){const e=[];return this.bondedPairs.forEach(((s,n)=>{s.forEach(((s,i)=>{s===t&&e.push({bondLineIdx:n,nodeIdx:i})}))})),e}replacePositionsInBondsByDummy(t,e){void 0===e&&(e=-1),t.forEach((t=>{const{bondLineIdx:s,nodeIdx:n}=t;this.bondedPairs[s][n]=e}))}removeAtomIdFromBonds(t){this.bondedPairs=this.bondedPairs.map((e=>e.map((e=>e>t?e-1:e))))}shift(t){this.bondedPairs=this.bondedPairs.map((e=>e.map((e=>e+t))))}}class qe{constructor(t){this.coordinates=[],this.rawAtomLines=[],this.rawAtomLines=t,this.coordinates=this.rawAtomLines.map((t=>({x:parseFloat(t.substring(0,10)),y:parseFloat(t.substring(10,20))})))}get atomCoordinates(){return this.coordinates}get atomLines(){return this.rawAtomLines.map(((t,e)=>{const s=this.coordinates[e];return`${s.x.toFixed(4).padStart(10," ")}${s.y.toFixed(4).padStart(10," ")}${t.substring(20)}`}))}replaceElementSymbol(t,e){this.rawAtomLines[t]=this.rawAtomLines[t].replace("R#",e)}deleteAtoms(t){this.coordinates=this.coordinates.filter(((e,s)=>!t.includes(s))),this.rawAtomLines=this.rawAtomLines.filter(((e,s)=>!t.includes(s)))}shift(t){this.coordinates=this.coordinates.map((e=>{const s=e.x+t.x,n=e.y+t.y;if(isNaN(s)||isNaN(n))throw new Error(`Cannot shift coordinates by ${t.x}, ${t.y}`);return{x:s,y:n}}))}rotate(t){this.coordinates=this.coordinates.map((e=>{const s=e.x,n=e.y,i=s*Math.cos(t)-n*Math.sin(t),o=s*Math.sin(t)+n*Math.cos(t);if(isNaN(i)||isNaN(o))throw new Error(`Cannot rotate coordinates by ${t}`);return{x:i,y:o}}))}getRGroupAtomicIndices(){return this.rawAtomLines.map(((t,e)=>{if(t.includes("R#"))return e})).filter((t=>void 0!==t))}}class Ze{constructor(t,e){this.monomerSymbol=e;const s=t.split("\n"),n=parseInt(s[3].substring(0,3)),i=parseInt(s[3].substring(3,6)),o=s.slice(4,4+n);this.atoms=new qe(o);const r=s.slice(4+n,4+n+i);this.bonds=new Ke(r),this.rGroups=new Ye(s,this.atoms,this.bonds),this.shiftMonomerToDefaultPosition()}deleteBondLineWithSpecifiedRGroup(t){this.rGroups.deleteBondLineWithSpecifiedRGroup(t)}shiftCoordinates(t){this.atoms.shift(t)}rotateCoordinates(t){this.atoms.rotate(t)}getBondLines(){return this.bonds.getBondLines()}getAtomLines(){return this.atoms.atomLines}removeRGroups(t){this.rGroups.removeRGroups(t)}replaceRGroupWithAttachmentAtom(t,e){this.rGroups.replaceRGroupWithAttachmentAtom(t,e)}getAttachmentAtomByRGroupId(t){return this.rGroups.getAttachmentAtomIdByRGroupId(t)}shiftR1GroupToOrigin(){const t=this.rGroups.getAtomicIdx(1);if(null===t)throw new Error(`Cannot find R1 group for monomer ${this.monomerSymbol}`);const{x:e,y:s}=this.atoms.atomCoordinates[t];this.atoms.shift({x:-e,y:-s})}alignR2AlongX(){const t=this.rGroups.getAtomicIdx(2);if(null===t)throw new Error(`Cannot find R2 group for monomer ${this.monomerSymbol}`);const e=this.atoms.atomCoordinates[t],s=e.y/e.x,n=Math.atan(s);if(isNaN(n))throw new Error(`Cannot calculate angle for R2 group for monomer ${this.monomerSymbol}`);this.rotateCoordinates(-n)}shiftMonomerToDefaultPosition(){this.shiftR1GroupToOrigin(),null!==this.rGroups.getAtomicIdx(2)&&this.alignR2AlongX()}shiftBonds(t){this.bonds.shift(t)}capRGroups(t){this.rGroups.capRGroups(t)}}class ze{constructor(t){this.simplePolymer=t,this.polymerType=this.getPolymerType(),this.idx=this.getIdx();const{monomers:e,monomerTypes:s}=this.getMonomerSymbolsAndTypes();this.monomers=e,this.monomerTypes=s}get id(){return this.polymerType+this.idx.toString()}getPolymerType(){const t=new RegExp("(PEPTIDE|RNA)[0-9]+{"),e=this.simplePolymer.match(t);if(!e)throw new Error(`Unsupported polymer type in ${this.simplePolymer}`);return e[1]}getIdx(){const t=new RegExp(`${this.polymerType}([0-9]+){`),e=this.simplePolymer.match(t);if(!e)throw new Error(`Cannot parse simple polymer id from ${this.simplePolymer}`);return parseInt(e[1])}getMonomerSymbolsAndTypes(){const t=new RegExp(`${this.polymerType}${this.idx}{|}`,"g"),e=this.simplePolymer.replace(t,"").split("."),s=[],n=[];return e.forEach((t=>{const e=t.split(/\(|\)/).map((t=>t.replace(/[\[\]]/g,"")));s.push(...e);const i=e.map(((t,e)=>e%2==0?0:1));n.push(...i)})),{monomers:s,monomerTypes:n}}getBondData(){const t=[],e=this.monomerTypes.map(((t,e)=>{if(0===t)return e})).filter((t=>void 0!==t)),s=this.monomerTypes.map(((t,e)=>{if(1===t)return e})).filter((t=>void 0!==t));for(let s=0;s<e.length-1;s++){const n=e[s],i=e[s+1];t.push([{monomerIdx:n,rGroupId:2},{monomerIdx:i,rGroupId:1}])}for(let e=0;e<s.length;e++){const n=s[e],i=n-1;t.push([{monomerIdx:i,rGroupId:3},{monomerIdx:n,rGroupId:1}])}return t}}class Xe{constructor(t){const e=t.split("|");e.forEach((t=>this.validateConnectionItem(t))),this.connectionItems=e}validateConnectionItem(t){const e="(PEPTIDE|RNA)",s=new RegExp(`${e}[0-9]+,${e}[0-9]+,[0-9]+:R[0-9]+-[0-9]+:R[0-9]+`,"g");if(!t.match(s))throw new Error(`Cannot parse connection item from ${t}`)}getConnectionData(){const t=[];return this.connectionItems.forEach((e=>{const s=[],n=e.split(",");n[2].split("-").forEach(((t,e)=>{const i=n[e],o=t.split(":"),r={monomerIdx:parseInt(o[0])-1,rGroupId:parseInt(o[1].slice(1))};s.push({polymerId:i,bond:r})})),t.push(s)})),t}}class je{constructor(t){this.helm=t;const e=this.helm.split("$"),s=e[0].split("|");this.simplePolymers=s.map((t=>new ze(t))),""!==e[1]&&(this.connectionList=new Xe(e[1])),this.bondData=this.getBondData()}toString(){return this.helm}getPolymerTypeByMonomerIdx(t){return this.getSimplePolymerByMonomerIdx(t).polymerType}getSimplePolymerByMonomerIdx(t){const e=this.getMonomerIdxShifts(),s=Object.values(e).sort(((t,e)=>t-e)).find((e=>t>=e));if(void 0===s)throw new Error(`Cannot find simple polymer for monomer ${t}`);const n=Object.keys(e).find((t=>e[t]===s));return this.simplePolymers.find((t=>t.id===n))}shiftBondMonomerIds(t,e){e.forEach((e=>{e.forEach((e=>{e.monomerIdx+=t}))}))}getMonomerIdxShifts(){const t={};let e=0;return this.simplePolymers.forEach((s=>{t[s.id]=e,e+=s.monomers.length})),t}getBondData(){const t=this.getMonomerIdxShifts(),e=[];return this.simplePolymers.forEach((s=>{const n=s.getBondData(),i=t[s.id];this.shiftBondMonomerIds(i,n),e.push(...n)})),this.connectionList&&this.connectionList.getConnectionData().forEach((s=>{const n=[];s.forEach((e=>{const s=t[e.polymerId],i=e.bond;i.monomerIdx+=s,n.push(i)})),e.push(n)})),e}}class Qe{constructor(t){this.monomerWrappers=[],this.helm=new je(t),this.bondedRGroupsMap=new Map,this.helm.bondData.forEach((t=>{t.forEach((t=>{const e=t.monomerIdx,s=t.rGroupId;this.bondedRGroupsMap.get(e)||this.bondedRGroupsMap.set(e,[]),this.bondedRGroupsMap.get(e).push(s)}))}))}addMonomer(t,e,s){const n=this.helm.getPolymerTypeByMonomerIdx(e),i=new $e(t,n);i.shiftCoordinates(s),this.monomerWrappers.push(i)}removeRGroups(){this.monomerWrappers.forEach(((t,e)=>{this.bondedRGroupsMap.has(e)&&t.removeBondedRGroups(this.bondedRGroupsMap.get(e)),t.capTrailingRGroups()}))}getAtomNumberShifts(){const t=[];let e=0;return this.monomerWrappers.forEach((s=>{t.push(e),e+=s.getAtomLines().length})),t}restoreBondsBetweenMonomers(){this.helm.bondData.forEach((t=>{const e=t.map((t=>t.monomerIdx)),s=t.map((t=>t.rGroupId)),n=e.map((t=>this.monomerWrappers[t])),i=n[1].getAttachmentAtomByRGroupId(s[1]);n[0].replaceRGroupWithAttachmentAtom(s[0],i),n[1].deleteBondLineWithSpecifiedRGroup(s[1])}))}compileToMolfile(){const t=[],e=[];this.removeRGroups();const s=this.getAtomNumberShifts();this.monomerWrappers.forEach(((t,e)=>{t.shiftBonds(s[e])})),this.restoreBondsBetweenMonomers(),this.monomerWrappers.forEach((s=>{t.push(...s.getAtomLines()),e.push(...s.getBondLines())}));const n=t.length;if(n>999)throw new Error(`Atom count in polymer ${this.helm.toString()} is ${n} and exceeds 999`);const i=e.length;return["\nDatagrok\n",`${n.toString().padStart(3," ")}${i.toString().padStart(3," ")} 0 0 1 0 0 V2000`,t.join("\n"),e.join("\n"),"M END\n"].join("\n")}}class Je{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 ts extends Je{constructor(t,e){super(t,e)}hasTerminals(t){return this.getLinkedPositions(t).every((t=>t>0))}getLinkedPositions(t){return[1,t.replace("PEPTIDE1{","").replace("}$$$$","").split(".").findIndex(((t,e)=>t===this.rightTerminal&&e>0))+1]}getTransformedHelm(t){const e=this.getLinkedPositions(t);return os(t,{monomerPosition:e[0],attachmentPoint:1},{monomerPosition:e[1],attachmentPoint:3})}}class es extends Je{constructor(t,e){super(t,e)}hasTerminals(t){return this.leftTerminal===He.M||this.rightTerminal===He.M||t.includes("PEPTIDE1{"+this.leftTerminal)&&t.includes(this.rightTerminal+"}$$$$")}getLinkedPositions(t){return[1,is(t)]}getTransformedHelm(t){const e=this.getLinkedPositions(t);return os(t,{monomerPosition:e[0],attachmentPoint:1},{monomerPosition:e[1],attachmentPoint:2})}}class ss extends Je{constructor(t,e){super(t,e)}hasTerminals(t){return this.leftTerminal===He.M||this.rightTerminal===He.M||this.getLinkedPositions(t).every((t=>t>0))}getLinkedPositions(t){const e=t.replace("PEPTIDE1{","").replace("}$$$$","").split("."),s=e.findIndex((t=>t===this.leftTerminal)),n=e.findIndex(((t,e)=>t===this.rightTerminal&&e>s));return[s+1,n+1]}getTransformedHelm(t){const e=this.getLinkedPositions(t);return os(t,{monomerPosition:e[0],attachmentPoint:3},{monomerPosition:e[1],attachmentPoint:3})}}class ns{constructor(){}static getInstance(t,e){const s=e.cyclizationType;return"R3-R3"===s?new ss(t,e):"N-Cys"===s?new ts(t,e):new es(t,e)}}function is(t){return t.replace("PEPTIDE1{","").replace("}$$$$","").split(".").length}function os(t,e,s){return t.replace("}$$$$",`}$PEPTIDE1,PEPTIDE1,${e.monomerPosition}:R${e.attachmentPoint}-${s.monomerPosition}:R${s.attachmentPoint}${"$".repeat(6)}`)}async function rs(t,e,s){const i=t.dataFrame,r=z.Cn.getOrCreate(t).convert(pt.r2.HELM),a=ns.getInstance(r,e).transform(),l=i.columns.getUnusedName(`${e.transformationType}(`+t.name+")"),c=o.Column.fromList("string",l,a);We(c),c.setTag("units",pt.r2.HELM);const h=await Be(i,c);h.name=i.columns.getUnusedName(`${e.transformationType}_molfile(`+t.name+")"),s&&(c.setTag("cell.renderer","helm"),i.columns.add(c)),i.columns.add(h,!0),await n.data.detectSemanticTypes(i)}function as(t,e,s,n){const i=z.Cn.getOrCreate(t);let o=null,r=null;for(let t=0;t<i.posList.length;++t)i.posList[t]==e&&(o=t),i.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(i.posList.length<r)throw new Error(`End position ${r} exceeds positions length`);const a=n||`${t.name}: (${e??""}-${s??""})`;return i.getRegion(o,r,a)}const ls={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(pt.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 cs{constructor(t,e){this.urlParams=t,this.funcName=e}async init(t){this.data=t??ls;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 n.data.detectSemanticTypes(this.data.df),this.view=n.shell.addTableView(this.data.df),this.view.path=this.view.basePath=`func/${ms.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 hs{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=i.tableInput("Table",this.call.inputParams.table.value??n.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=i.columnInput("Sequence",n.shell.tv.dataFrame,s,this.sequenceInputChanged.bind(this),r),this.inputs.start=i.choiceInput("Start",void 0,[],this.startInputChanged.bind(this)),this.inputs.end=i.choiceInput("End",void 0,[],this.endInputChanged.bind(this)),this.inputs.region=i.choiceInput("Region",null,[],this.regionInputChanged.bind(this)),this.inputs.name=i.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)i.tooltip.bind(this.inputs[t].captionLabel,e(t));this.sequenceInputChanged()}sequenceInputChanged(){const t=this.inputs.sequence.value;t&&z.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=z.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?z.Cn.getOrCreate(t):null,s=this.inputs.start.input,n=this.inputs.end.input;for(let t=s.options.length-1;t>=0;--t)s.options.remove(t);for(let t=n.options.length-1;t>=0;--t)n.options.remove(t);for(const t of e?.posList??[]){const e=document.createElement("option"),i=document.createElement("option");e.text=i.text=t,e.value=i.value=t,s.options.add(e),n.options.add(i)}s.value=e?.posList[0]??"",n.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,n=this.inputs.region.input;for(let t=n.options.length-1;t>=0;--t)n.options.remove(t);const i=document.createElement("option");if(i.text="",i.value=JSON.stringify(null),n.options.add(i),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),n.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 n=t.options.length-1;n>=0;--n){const i=t.options[n],o=JSON.parse(i.value);o&&e===o.start&&s===o.end&&(t.selectedIndex=n)}}}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,n=this.inputs.start.stringValue??"",i=this.inputs.end.stringValue??"";return null!=e?`${s.name}(${e.name}): ${e.start}-${e.end}`:`${s?.name}: (${n}-${i})`}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=i.inputs(Object.values(this.inputs),{style:{minWidth:"320px"}});i.dialog({title:"Get Region"}).add(t).onOK((async()=>{(async()=>{const t=this.getParams();await this.call.func.prepare(t).call(!0)})().catch((t=>{ms.handleErrorUI(t)}))})).show()}widget(){const t=i.inputs(Object.entries(this.inputs).filter((([t,e])=>!["table","sequence"].includes(t))).map((([t,e])=>e))),e=i.button("Get Region",(()=>{(async()=>{const t=this.getParams();await this.call.func.prepare(t).call(!0)})().catch((t=>{ms.handleErrorUI(t)}))}));return o.Widget.fromRoot(i.divV([t,i.div(e)]))}}var us=s(8601);const ms=new Oe,ds="bypassLargeDataWarning";function ps(){return ae.NT.instance}let gs=null;class fs{constructor(t){this._palette=t}get(t){return this._palette[t]}}async function ys(){ms.logger.debug("Bio: initBio(), started");const t=await n.functions.call("Chem:getRdKitModule");await Promise.all([(async()=>{await ae.NT.instance.loadLibraries()})(),(async()=>{const t=await ms.getProperties(),e=new _e(t);ms.properties=e})()]).finally((()=>{ms.completeInit()}));const e=ae.NT.instance.getBioLib(),s=[],i=[],o=e.getMonomerMolsByPolymerType("PEPTIDE");Object.keys(o).forEach((e=>{s.push(e);const n=o[e].replaceAll("#R","O "),r=t.get_mol(n),a=JSON.parse(r.get_descriptors()).CrippenClogP;i.push(a),r?.delete()}));const r=i.reduce(((t,e)=>t+e),0)/i.length||0,a={};for(let t=0;t<s.length;t++)a[s[t]]=i[t]<r?"#4682B4":"#DC143C";gs=new fs(a),ms.logger.debug("Bio: initBio(), completed")}function ws(t){const e=new De(t);return e.init().then((()=>{})).catch((t=>{const e=t instanceof Error?t.message:t.toString();n.shell.error(e)})),e}function Cs(){return ae.NT.instance.getBioLib()}function Ts(t){const e="getRegionTopMenu",s=o.Func.find({package:ms.name,name:e});if(1!==s.length)throw new Error(`Package '${ms.name}' func '${e}' not found`);const n=s[0].prepare({table:t.dataFrame,sequence:t});return new hs(n).widget()}async function bs(t){return(0,ae.cf)()}function As(t){try{new hs(t).dialog()}catch(t){const e=t instanceof Error?t.message:t.toString(),s=t instanceof Error?t.stack:void 0;n.shell.error(`Get region editor error: ${e}`),ms.logger.error(e,void 0,s)}}function Ss(t){const e=new ve;i.dialog({title:"Split to Monomers"}).add(e.paramsUI).onOK((async()=>t.func.prepare(e.funcParams).call(!0))).show()}function Es(t){const e=new l({semtype:o.SEMTYPE.MACROMOLECULE});i.dialog({title:"Sequence Space"}).add(e.getEditor()).onOK((async()=>{const s=e.getParams();return t.func.prepare({molecules:s.col,table:s.table,methodName:s.methodName,similarityMetric:s.similarityMetric,plotEmbeddings:s.plotEmbeddings,options:s.options,preprocessingFunction:s.preprocessingFunction}).call()})).show()}function Ms(t){const e=new w(o.SEMTYPE.MACROMOLECULE);i.dialog({title:"Activity Cliffs"}).add(e.paramsUI).onOK((async()=>t.func.prepare(e.funcParams).call(!0))).show()}function vs(t){const e=new Ge(t);return e.init().then(),e}function Ns(){return new At}function xs(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=i.choiceInput("Monomer width",null!=t?.temp["monomer-width"]?t.temp["monomer-width"]:mt.short,[mt.short,mt.long],(e=>{t.temp["monomer-width"]=e,t.setTag(".mm.cellRenderer.settingsChanged",ft.true),t.dataFrame.fireValuesChanged()}));s.setTooltip("In short mode, only the 'Max monomer length' characters are displayed, followed by .. if there are more");const n=parseInt(t.getTag(ct.maxMonomerLength)),r=i.intInput("Max monomer length",isNaN(n)?ms.properties.MaxMonomerLength:n,(e=>{t.setTag(ct.maxMonomerLength,e.toString()),t.setTag(".mm.cellRenderer.settingsChanged",ft.true),t.dataFrame.fireValuesChanged()}));r.setTooltip(`The max length of monomer name displayed without shortening in '${mt.short}' monomer width mode.`);const a=i.intInput("Monomer margin",t.temp[".mm.cellRenderer.gapLength"]??0,(e=>{t.temp[".mm.cellRenderer.gapLength"]=e,t.setTag(".mm.cellRenderer.settingsChanged",ft.true),t.dataFrame.fireValuesChanged()}));a.setTooltip("The size of margin between monomers (in pixels)");const l=i.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 c=i.stringInput("Reference sequence",null!=t?.temp["reference-sequence"]?t?.temp["reference-sequence"]:"",(e=>{t.temp["reference-sequence"]=e,t.dataFrame.fireValuesChanged()}));c.setTooltip("Reference sequence is not empty, then the sequence will be render \nas a difference from the reference sequence");const h=i.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()}));h.setTooltip('When on, all sequences get rendered in the "diff" mode');const u=i.inputs([s,r,a,c,l,h]);return new o.Widget(u)}(t)}function Is(t){return(0,Fe.t)(t)}function Ls(){return new At}function Ps(){return new St}function Rs(t,e,s,n,i){const o=new Dt.k(n,i,s,e);return"Local alignment"==t?o.smithWaterman():o.needlemanWunch()}function _s(){return new Pt.OZ}function Os(){return new Ft}function Gs(t,e,s,n){return as(t,e??null,s??null,n??null)}async function Fs(t,e,s,i,o){const r=as(e,s??null,i??null,o??null);e.dataFrame.columns.add(r),await n.data.detectSemanticTypes(e.dataFrame)}async function Ds(t,e,a,l,c,h,u){if(!(0,Se.n)(e,"Activity Cliffs"))return;const d=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}`))}(t),p={units:e.getTag(o.TAGS.UNITS),aligned:e.getTag("aligned"),separator:e.getTag("separator"),alphabet:e.getTag("alphabet")};let g=kt;const f=z.Cn.getOrCreate(e),y=h,w=e;let C=Bt;f.isHelm()&&(C=Wt,g=async(t,e)=>{await(0,Ht.HV)(t,!1);const s=t.temp["monomeric-mols"];return{seqList:(await n.functions.call("Chem:getMorganFingerprints",{molColumn:s})).toList().map((t=>G.Z.fromUint32Array(t.length,new Uint32Array(t.getBuffer().buffer)))),options:{}}});const T=async()=>await async function(t,e,r,a,l,c,h,u,d,p,g,f,y,w,C,T,b,A){F++;const S=h/100,E=r??e;let M=!1,v=!1;const N={};let x,I;const L={seqCol:E,methodName:d,similarityMetric:u,embedAxesNames:a,options:{...b??{},[H]:void 0}},{distance:P,coordinates:R}=await f(L);for(const e of R)t.columns.add(e);let _;if(e.semType===o.SEMTYPE.MOLECULE){const t=(await n.functions.call("Chem:getMorganFingerprints",{molColumn:E})).toList().map((t=>new G.Z(new Uint32Array(t.getBuffer().buffer),t.length))),e=1-(0,m.eo)(S),s=await(new O._).calc(t,u,e);_=await K(s,0,c)}else{let t=e.toList(),s={};if(b?.[H]){const{seqList:n,options:i}=await b[H](e,u);t=n,s=i}const n=await(new O._).calc(t,u,S,s);_=await K(n,0,c)}const Z=function(t,e,s,n,i,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(n[t])?a[s[t]]+=e[t]:a[n[t]]+=e[t]);return o.Column.fromList("double",`sali_${i[0].substring(i[0].lastIndexOf("_"))}`,a)}(E.length,_.saliVals,_.n1,_.n2,a,c);t.columns.add(Z);const z=function(t,e){const s="containsCliff",n=t.columns.names().filter((t=>t.includes(s))).length+1,i=`${s}_${n}`;return o.Column.bool(i,t.rowCount).init((t=>e.has(t)))}(t,_.cliffsMolIds);t.columns.add(z);const X=function(t){const e=t.filter((t=>t!==1/0)),s=e.reduce(((t,e)=>Math.min(t,e)),Number.MAX_VALUE),n=e.reduce(((t,e)=>Math.max(t,e)),s);return{max:n,min:s}}(_.saliVals),j=.8/(X.max-X.min),Q=n.shell.getTableView(t.name);Q.grid.columns.byName(z.name).visible=!1;const J=Q.addViewer(o.VIEWER.SCATTER_PLOT,{xColumnName:a[0],yColumnName:a[1],size:Z.name,color:c.name,showXSelector:!1,showYSelector:!1,showSizeSelector:!1,showColorSelector:!1,markerMinSize:5,markerMaxSize:25,title:l}),tt=J.getInfo().canvas,et=function(t,e,s,n,i){const r=new Array(t.n1.length).fill(null);for(let e=0;e<t.n1.length;e++){const s=t.n1[e],n=t.n2[e];r[e]={id:e,mols:[s,n],selected:!1,a:[],b:[]}}const a=o.DataFrame.create(r.length);return $.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),i),a.col(t).semType=n})),a.columns.addNewFloat(k).init((t=>Math.abs(s.get(r[t].mols[0])-s.get(r[t].mols[1])))),a.columns.addNewInt(U).init((t=>t)),a.columns.addNewFloat(B).init((e=>t.saliVals[e])),a.columns.addNewFloat(V).init((e=>t.simVals[e])),a.name=`${D}${F}`,{lines:r,linesDf:a}}(_,e,c,p,g),st=T?T(et.linesDf,$).sort([B],[!1]):et.linesDf.plot.grid().sort([B],[!1]);t.temp[".cliffsDfGrid"]=st;const nt=i.button(`${et.linesDf.rowCount} cliffs`,(()=>{Q.dockManager.dock(st,"down",null,"Activity cliffs",A??.2)}));nt.classList.add("scatter_plot_link","cliffs_grid"),J.root.append(nt);const it=i.switchInput("Show only cliffs",!1,(()=>{it.value?(J.dataFrame.setTag(Y,z.name),t.rows.match({[z.name]:!0}).filter(),W.next(z.name)):(J.dataFrame.setTag(Y,""),t.filter.setAll(!0,!0),W.next(""))}));it.root.classList.add("scatter_plot_link","show_only_cliffs"),J.root.append(it.root),W.subscribe((t=>{it.enabled=""===t||t===z.name}));const ot=n.events.onViewerClosed.subscribe((t=>{t.args.viewer===J&&(Q.dockManager.close(st.root),ot.unsubscribe(),Q.subs=Q.subs.filter((t=>t!==ot)))}));return Q.subs.push(ot),et.linesDf.onCurrentCellChanged.subscribe((()=>{M=!0;const s=et.linesDf.currentCol&&et.linesDf.currentCol.name===$[1]?1:0,o=-1!==et.linesDf.currentRowIdx?et.lines[et.linesDf.currentRowIdx]:null;J.dataFrame.currentRowIdx=o?o.mols[s]:-1,J.dataFrame.filter.set(0,!et.lines[0].selected),J.dataFrame.filter.set(0,et.lines[0].selected),o&&setTimeout((()=>{!function(t,e,s,o,r,a,l,c){const h=e.getPane("Cliff Details");i.empty(h.root);const u=c({cashedData:s,line:o,df:t,seqCol:r,activityCol:a,sali:l});h.root.append(u),setTimeout((()=>{n.shell.o=e.root}),500)}(t,x,N,o,e,c,et.linesDf.get(B,o.id),C);const s=J.dataFrame.getSortedOrder(Q.grid.sortByColumns,Q.grid.sortTypes);Q.grid.scrollToCell(e.name,s.indexOf(J.dataFrame.currentRowIdx))}),1e3)})),et.linesDf.onSelectionChanged.subscribe((e=>{if(!1===et.linesDf.selection.anyTrue)et.lines.forEach((t=>{t.selected=!1}));else if(-1!==et.linesDf.mouseOverRowIdx){const t=et.lines[et.linesDf.mouseOverRowIdx];t.selected=!t.selected}setTimeout((()=>{const e=o.BitSet.create(t.rowCount);et.lines.forEach((t=>{t.selected&&t.mols.forEach((s=>{e.set(s,t.selected,!0)}))})),t.selection.copyFrom(e),Q.grid.invalidate()}),300)})),t.onSelectionChanged.subscribe((e=>{v?v=!1:!1===t.selection.anyTrue&&"number"==typeof e&&(et.lines.forEach((t=>{t.selected=!1})),st.dataFrame.selection.setAll(!1,!1),st.invalidate())})),tt.addEventListener("mousemove",(function(n){clearTimeout(I),I=s.g.setTimeout((function(){const s=q(n,tt,et.lines);s&&-1===t.mouseOverRowIdx&&i.tooltip.show(w({cashedData:N,line:s,df:t,seqCol:e,activityCol:c}),n.clientX,n.clientY)}),500)})),tt.addEventListener("mousedown",(function(e){v=!0;const s=q(e,tt,et.lines);if(s&&-1===t.mouseOverRowIdx){e.ctrlKey?(s.selected=!s.selected,et.linesDf.selection.set(s.id,s.selected)):et.linesDf.currentRowIdx!==s.id&&(et.linesDf.currentRowIdx=s.id,t.currentRowIdx=s.mols[0],t.filter.set(0,!et.lines[0].selected),t.filter.set(0,et.lines[0].selected));const n=et.linesDf.getSortedOrder(st.sortByColumns,st.sortTypes);st.scrollToCell($[0],n.indexOf(s.id))}})),J.onEvent("d4-before-draw-scene").subscribe((e=>{const s=function(t,e,s,n,i,o,r){const a=n.lines,l=t.getInfo().canvas.getContext("2d"),c=t.dataFrame.columns.byName(e),h=t.dataFrame.columns.byName(s);for(let e=0;e<a.length;e++){const s=t.worldToScreen(c.get(a[e].mols[0]),h.get(a[e].mols[0])),u=t.worldToScreen(c.get(a[e].mols[1]),h.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",p=i[e]===1/0?1:.2+(i[e]-r)*o;l.strokeStyle=`rgba(${d},${p})`,l.lineWidth=a[e].id===n.linesDf.currentRowIdx?3:1,m.lineTo(a[e].b[0],a[e].b[1]),l.stroke(m)}return a}(J,a[0],a[1],et,_.saliVals,j,X.min);if(M){const t=s[et.linesDf.currentRowIdx];setTimeout((()=>{const{zoomLeft:e,zoomRight:s,zoomTop:n,zoomBottom:i}=function(t,e,s,n,i,o){const r=Math.abs(s-i),a=Math.abs(n-o),l=t/r,c=e/a,h=Math.min(l,c),u=t/h*5,m=e/h*5,d=(s<i?s:i)+r/2-u/2,p=(n>o?n:o)-a/2+m/2;return{zoomLeft:d,zoomRight:d+u,zoomTop:p,zoomBottom:p-m}}(J.viewport.width,J.viewport.height,J.dataFrame.get(a[0],t.mols[0]),J.dataFrame.get(a[1],t.mols[0]),J.dataFrame.get(a[0],t.mols[1]),J.dataFrame.get(a[1],t.mols[1]));J.zoom(e,n,s,i)}),300),M=!1}it.value?t.rows.match({[z.name]:!0}).filter():!0===it.enabled&&t.filter.setAll(!0,!1)})),J.addProperty("similarityLimit","double",S),x=function(){const t=i.accordion(),e=i.element("i");return e.className="grok-icon svg-icon svg-view-layout",t.addTitle(i.span([e,i.label("Activity cliffs")])),t.addPane("Cliff Details",(()=>i.divText("Cliff has not been selected")),!0),n.shell.o=t.root,t}(),J}(t,w,null,d,"Activity cliffs",a,l,y,c,o.SEMTYPE.MACROMOLECULE,p,C,0,Ut,$t,Zt,{...u??{},[H]:g}),b=c===r.AL.UMAP?2e5:2e4,A=c===r.AL.UMAP?5e3:2e3;if(t.rowCount>b)return void n.shell.warning(`Too many rows, maximum for sequence activity cliffs is ${b}`);const S=o.TaskBarProgressIndicator.create("Running sequence activity cliffs ...");return new Promise(((e,s)=>{t.rowCount>A&&!u?.[ds]?i.dialog().add(i.divText("Activity cliffs analysis might take several minutes.\n Do you want to continue?")).onOK((async()=>{T().then((t=>e(t))).catch((t=>s(t)))})).onCancel((()=>{e(void 0)})).show():T().then((t=>e(t))).catch((t=>s(t)))})).catch((t=>{const[e,s]=(0,et.yf)(t);throw ms.logger.error(e,void 0,s),t})).finally((()=>{S.close()}))}async function Hs(t,e){const{seqList:s,options:n}=await kt(t,e);return{entries:s,options:n}}async function Ws(t,e){t.version!==t.temp["last-invalidated-version"]&&await(0,Ht.HV)(t,!1);const s=t.temp["monomeric-mols"],i=await n.functions.call("Chem:getMorganFingerprints",{molColumn:s}),o=new Array(i.length).fill(null);for(let t=0;t<i.length;t++){if(i.isNone(t)||!i.get(t))continue;const e=i.get(t);o[t]=G.Z.fromUint32Array(e.length,new Uint32Array(e.getBuffer().buffer))}return{entries:o,options:{}}}async function ks(t,e,s,r,l,c,m){if(!(0,Se.n)(e,"Sequence Space"))return;c||(c=o.Func.find({name:"macromoleculePreprocessingFunction",package:"Bio"})[0]);const d=await async function(t,e,s,r,l,c=!1,m={},d={}){const p={showXAxis:!1,showYAxis:!1,showXSelector:!1,showYSelector:!1},g=async()=>{const g=o.TaskBarProgressIndicator.create(`Initializing ${d.scatterPlotName??"dimensionality reduction"} ...`);let y;try{const w=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}`))}(t);function C(e,s,r){let a=null,l=null;t.columns.names().includes(w[0])?(a=t.columns.byName(w[0]),l=t.columns.byName(w[1])):(a=t.columns.add(o.Column.float(w[0],t.rowCount)),l=t.columns.add(o.Column.float(w[1],t.rowCount)),c&&!y&&(y=n.shell.tableView(t.name).scatterPlot({...p,x:w[0],y:w[1],title:d.scatterPlotName??"Embedding space"}))),d[f]&&(y?.root&&i.setUpdateIndicator(y.root,!1),a.init((t=>r[0]?r[0][t]:void 0)),l.init((t=>r[1]?r[1][t]:void 0)));const h=e/s*100;g.update(h,`Running ${d.scatterPlotName??"dimensionality reduction"}... ${h.toFixed(0)}%`)}async function T(){t.columns.add(o.Column.float(w[0],t.rowCount)),t.columns.add(o.Column.float(w[1],t.rowCount));let f=null;c&&(y=n.shell.tableView(t.name).scatterPlot({...p,x:w[0],y:w[1],title:d.scatterPlotName??"Embedding space"}),i.setUpdateIndicator(y.root,!0));const T=n.events.onViewerClosed.subscribe((t=>{const e=t.args.viewer;e?.getOptions()?.look?.title&&y?.getOptions()?.look?.title&&e?.getOptions()?.look?.title===y?.getOptions()?.look?.title&&(n.events.fireCustomEvent(h,{}),T.unsubscribe(),f?.(),g.close())})),b=new Promise((async(t,n)=>{try{f=t;const n=l.inputs[0].name,i=l.inputs[1].name,{entries:o,options:c}=await l.apply({[n]:e,[i]:r});(m=m??{}).distanceFnArgs=c,t(await u(o,s,r,m,!0,d[a.sS]?void 0:C))}catch(t){n(t)}})),A=await b;return g.close(),T.unsubscribe(),A}const b=await T();if(b&&c&&y){i.setUpdateIndicator(y.root,!1);const A=t.columns.byName(w[0]),S=t.columns.byName(w[1]);return A.init((t=>b.embedding[0][t])),S.init((t=>b.embedding[1][t])),y}}catch(E){n.shell.error("Dimensionality reduction failed"),console.error(E),g.close(),y&&i.setUpdateIndicator(y.root,!1)}};return new Promise((async(e,s)=>{try{if(d.fastRowCount&&t.rowCount>d.fastRowCount&&!d[a.sS])i.dialog().add(i.divText("Analysis might take several minutes. Do you want to continue?")).onOK((async()=>{try{const t=await g();e(t)}catch(t){s(t)}})).onCancel((()=>e(void 0))).show();else{const t=await g();e(t)}}catch(t){s(t)}}))}(t,e,s,r,c,l,m,{fastRowCount:1e4,scatterPlotName:"Sequence space",bypassLargeDataWarning:m?.[ds]});return d}async function Bs(t,e,s){const r=o.TaskBarProgressIndicator.create("Converting to atomic level ...");try{await async function(t,e,s){if(0===o.Func.find({package:"Chem",name:"getRdKitModule"}).length)return void n.shell.warning('Transformation to atomic level requires package "Chem" installed.');if(s){const s=z.Cn.getOrCreate(e);return s.isHelm()||(e=s.convert(pt.r2.HELM)),void async function(t,e){const s=await Be(t,e);t.columns.add(s,!0),await n.data.detectSemanticTypes(t)}(t,e)}if(!(0,Se.n)(e,"To Atomic Level"))return;const r=ps().getBioLib(),a=await(0,us.i0)(t,e,r);null!==a.col&&(t.columns.add(a.col,!0),await n.data.detectSemanticTypes(t)),a.warnings&&a.warnings.length>0&&n.shell.warning(i.list(a.warnings))}(t,e,s)}finally{r.close()}}function Vs(){(0,Ee.K)()}async function Us(t=null,e=null){return(0,Ee.K)({col:t,clustersCol:e})}async function $s(){const t=n.shell.tv,e=t.dataFrame.columns.toList().filter((t=>t.semType==o.SEMTYPE.MACROMOLECULE&&(z.Cn.getOrCreate(t),!0))),s=async e=>{if(!(0,Se.n)(e,"Composition"))return;const s=t.addViewer("WebLogo",{sequenceColumnName:e.name});n.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)),n=e.find((t=>z.Cn.getOrCreate(t).isMsa())),o=i.choiceInput("Column",n?n.name:t[0],t);i.dialog({title:"Composition Analysis",helpUrl:"https://datagrok.ai/help/datagrok/solutions/domains/bio/#sequence-composition"}).add(i.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 n.shell.error("Current table does not contain sequences")}function Ys(t){return new X.i(t).importFasta()}function Ks(t){return console.log(t),[]}function qs(){const t=(0,st.B)()[0];(0,ie.O)(t)}function Zs(){let t;try{t=function(){function t(t){return t===h[0]?[He.M].concat(m.getMonomerSymbolsByType("PEPTIDE")):t===h[1]?[He.M].concat(m.getMonomerSymbolsByRGroup(3,"PEPTIDE")):["C"]}function e(){"N-Cys"===u.value?(d=t("N-O"),p=t("N-Cys")):(d=t(u.value),p=[...d]),g=i.choiceInput("R1:",d[0],d,(()=>{r.next()})),f=i.choiceInput("R2:",p[0],p,(()=>{r.next()})),r.next(),i.empty(y),[g,f].forEach((t=>{y.appendChild(t.root)}))}const s=new C.Subject,r=new C.Subject;s.subscribe((()=>{a.cyclizationType=u.value,e()})),r.subscribe((()=>{a.rightTerminal=f.value,a.leftTerminal=g.value}));const a={},l=["Cyclization"],c=i.choiceInput("Modification",l[0],l,(()=>a.transformationType=c.value)),h=["N-O","R3-R3","N-Cys"],u=i.choiceInput("Type",h[2],h,(()=>{s.next()})),m=ae.NT.instance.getBioLib();let d=[],p=[],g=i.choiceInput("R1:",d[0],d,(()=>{a.leftTerminal=g.value})),f=i.choiceInput("R2:",p[0],p,(()=>{a.rightTerminal=f.value}));const y=i.divV([g.root,f.root]);e(),a.cyclizationType=u.value,a.leftTerminal=g.value,a.rightTerminal=f.value,a.transformationType=c.value;const w=n.shell.t.columns.bySemTypeAll(o.SEMTYPE.MACROMOLECULE);if(!w)throw new Error("No dataframe with maceomolecule columns open");const T=i.columnInput("Column",n.shell.t,w[0],null,{filter:t=>t.semType===o.SEMTYPE.MACROMOLECULE}),b=i.boolInput("Get HELM",!0);i.tooltip.bind(b.root,"Add HELM column");const A=i.div([T,c,u,y,b]);return i.dialog("Poly Tool").add(A).onOK((async()=>{const t=T.value;t?rs(t,a,b.value):n.shell.warning("No marcomolecule column chosen!")}))}(),t.show()}catch(t){n.shell.warning("To run PolyTool, open a dataframe with macromolecules")}}function zs(){return new Re}async function Xs(t){const e=o.TaskBarProgressIndicator.create("Test detectMacromolecule..."),s=(await n.dapi.files.list(t,!0,"")).filter((t=>t.fileName.endsWith(".csv")));let i=0;const r=[];for(const a of s)try{const e=await n.dapi.files.readAsText(t+a.fullPath),s=o.DataFrame.fromCsv(e);for(const t of s.columns)await n.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{i+=1,e.update(100*i/s.length,`Test ${a.fileName}`)}n.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 js(t,e){await(0,Ne.n)(t,e)}function Qs(t){const e=z.Cn.getOrCreate(t).stats;return Object.keys(e.freq)}function Js(){return new te}function tn(){const t=n.shell.v,e=t.addViewer("Sequence Similarity Search");t.dockManager.dock(e,"down")}function en(){return new se}function sn(){const t=n.shell.v,e=t.addViewer("Sequence Diversity Search");t.dockManager.dock(e,"down")}function nn(t){const e=(0,st.B)();1===e.length?t.func.prepare({macromolecules:e[0]}).call(!0):new Ht.uH(e)}function on(t){n.shell.tv.getFiltersGroup({createDefaultFilters:!1}).updateOrAdd({type:"Bio:bioSubstructureFilter",column:t.name,columnName:t.name}),n.shell.tv.grid.scrollToCell(t,0)}async function rn(t,e,s){return tt(t,e,s,Z.IDENTITY)}async function an(t,e,s){return tt(t,e,s,Z.SIMILARITY)}function ln(){(0,oe.C2)()}function cn(){return new re.ST}async function hn(){const t=o.TaskBarProgressIndicator.create("WebLogo");try{const t=new URLSearchParams(window.location.search),e=new Me(t,"webLogoLargeApp"),s=await ms.files.readCsv("data/sample_PT_100000x5.csv");await n.data.detectSemanticTypes(s),await e.init(s)}finally{t.close()}}async function un(){const t=o.TaskBarProgressIndicator.create("WebLogo ...");try{const t=new URLSearchParams(window.location.search),e=new Me(t,"webLogoAggApp"),s=await ms.files.readCsv("data/sample_FASTA_PT_activity.csv");await n.data.detectSemanticTypes(s),await e.init(s)}finally{t.close()}}async function mn(){const t=o.TaskBarProgressIndicator.create("getRegion ...");try{const t=new URLSearchParams(window.location.search),e=new cs(t,"getRegionApp");await e.init()}finally{t.close()}}async function dn(){const t=o.TaskBarProgressIndicator.create("getRegion ...");try{const t=new URLSearchParams(window.location.search),e=await ms.files.readCsv("data/sample_HELM_empty_vals.csv"),s=new cs(t,"getRegionHelmApp");await s.init({df:e,colName:"HELM"})}finally{t.close()}}function pn(t,e){!function(t,e){const s=z.Cn.getOrCreate(t.column),i=Object.values(pt.r2).filter((t=>t!==s.units));e.group("Copy").items(i,(e=>{const s=z.Cn.getOrCreate(t.column),i=e===pt.r2.SEPARATOR?ms.properties.DefaultSeparator:void 0,o=s.getConverter(e,i)(t.value);navigator.clipboard?(navigator.clipboard.writeText(o),n.shell.info(`Value of notation '${e}' copied to clipboard`)):n.shell.warning("The clipboard functionality requires a secure origin — either HTTPS or localhost")}))}(t,e)}async function gn(){await async function(){let t,e;try{const s=new ce("Similarity, Diversity","Sequence similarity tracking and evaluation dataset diversity");await s.step("Load DNA sequences",(async()=>{n.shell.windows.showContextPanel=!1,n.shell.windows.showProperties=!1,e=await ms.files.readCsv(ue),t=n.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){he(t)}}()}async function fn(){await async function(){let t,e,s,i,r;try{const a=new ce("Sequence Space","Exploring sequence space of Macromolecules, comparison with hierarchical clustering results");await a.step("Load DNA sequences",(async()=>{[i,t,e]=await Promise.all([ms.files.readCsv(fe),pe(),ge()]),s=n.shell.addTableView(i),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,n.shell.windows.showContextPanel=!1,n.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,n){let i;{const t=Object.values(ne);for(let s=0;s<t.length;s++){const n=t[s];if(!e.col(n)){const i=s==t.length-1;e.columns.add(o.Column.float(n,e.rowCount),i)}}if(e.rowCount>=1){const n=e.getCol(s).toList(),i=Date.now();ms.logger.debug("Bio: demoBio01aUI(), calc reduceDimensionality start...");const o=await u(n,"UMAP",Vt.W.Levenshtein,{}),r=Date.now();ms.logger.debug(`Bio: demoBio01aUI(), calc reduceDimensionality ET: ${(r-i)/1e3} s`);for(let s=0;s<t.length;s++){const n=t[s],i=e.getCol(n),r=o.embedding[s];i.init((t=>r[t]))}const a=Date.now();ms.logger.debug(`MLB: MlbVrSpaceBrowser.buildView(), postprocess reduceDimensionality ET: ${(a-r)/1e3} s`)}i=await e.plot.fromType(o.VIEWER.SCATTER_PLOT,{xColumnName:ne.X,yColumnName:ne.Y,lassoTool:!0})}return t.dockManager.dock(i,o.DOCK_TYPE.RIGHT,null,"Sequence Space",.35),i}(s,i,ye)}),{description:"Reduce sequence space dimensionality to display on 2D representation.",delay:2e3}).step("Cluster sequences",(async()=>{const n=i.getCol(ye).toList(),o=de.H.calc(n,((t,e)=>me.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()=>{i.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=i.getCol("sequence_id");i.selection.init((e=>["c0_seq120","c0_seq105","c0_seq121","c0_seq93"].includes(t.get(e)))),i.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){he(t)}}()}async function yn(){await async function(){let t,e,s,i,a;const l=r.AL.UMAP;try{const r=new ce("Activity Cliffs","Activity Cliffs analysis on Macromolecules data");await r.step("Load DNA sequences",(async()=>{n.shell.windows.showContextPanel=!1,n.shell.windows.showProperties=!1,[s,t,e]=await Promise.all([ms.files.readCsv(Te),pe(),ge()]),i=n.shell.addTableView(s),i.grid.props.rowHeight=22,i.grid.columns.byName("cluster").visible=!1,i.grid.columns.byName("sequence").width=300,i.grid.columns.byName("is_cliff").visible=!1}),{description:"Load dataset with macromolecules of 'fasta' notation, 'DNA' alphabet.",delay:2e3}).step("Find activity cliffs",(async()=>{a=await Ds(s,s.getCol("Sequence"),s.getCol("Activity"),80,l,p.U.LEVENSHTEIN),i.dockManager.dock(a,o.DOCK_TYPE.RIGHT,null,"Activity Cliffs",.35),Ce()(a.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 n=o.TaskBarProgressIndicator.create("Running sequence clustering..."),r=s.getCol("sequence").toList(),a=de.H.calc(r,((t,e)=>me.T(t,e)/((t.length+e.length)/2))),l=await t.hierarchicalClusteringByDistance(a,"ward");n.close(),e.injectTreeForGrid(i.grid,l,void 0,150,void 0),i.grid.columns.byName("Activity").scrollIntoView()}),{description:"Perform hierarchical clustering to reveal relationships between sequences.",delay:2e3}).step("Browse the cliff",(async()=>{const t=a.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){he(t)}}()}async function wn(){await async function(){const t="HELM";let e,s,r;try{await new ce("Atomic Level","Atomic level structure of Macromolecules").step("Loading Macromolecules notation 'Helm'",(async()=>{n.shell.windows.showContextPanel=!1,n.shell.windows.showProperties=!1,e=await ms.files.readCsv("samples/HELM.csv"),s=n.shell.addTableView(e);for(let e=0;e<s.grid.columns.length;e++){const n=s.grid.columns.byIndex(e);[t,"Activity"].includes(n.name)||(n.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 Bs(e,s,!1)}),{description:"Get atomic level structures of Macromolecules.",delay:2e3}).step("Sketcher",(async()=>{const s=`molfile(${t})`;e.currentCell=e.cell(1,s);const n=e.currentCell.value,a=new o.chem.Sketcher(o.chem.SKETCHER_MODE.INPLACE);a.setMolFile(n),r=i.dialog().add(a).show(),await(0,Nt.gw)(3e3),r.close()}),{description:"Display atomic level structure within a sketcher.",delay:2e3}).start()}catch(t){he(t)}}()}async function Cn(){await async function(){let t,e,s,i,a,l;const c="msa(HELM)",h=r.AL.UMAP,u=(await be.lp.getDockerContainer()).id,m=be.lp.getDockerContainer();let d,g;try{const r=new ce("Helm, MSA, Sequence Space","MSA and composition analysis on Helm data");await r.step("Load peptides with non-natural aminoacids in 'HELM' notation",(async()=>{[d,e]=await Promise.all([(async()=>(await m).status)(),ms.files.readCsv(Ae)]),t=n.shell.addTableView(e),n.shell.windows.showContextPanel=!1,n.shell.windows.showProperties=!1,"started"===d||"checking"===d?(ms.logger.debug(`demoBio05UI(), PepSeA ('${be.lp.dcName}') docker container status = '${d}'.`),g=Promise.resolve()):(ms.logger.warning(`demoBio05UI(), PepSeA ('${be.lp.dcName}') docker container is trying to start...`),await n.dapi.docker.dockerContainers.run(u),g=async function(t,e,s=3e4,i){const o=window.performance.now(),r=new C.Subject,a=async()=>{const s=await n.dapi.docker.dockerContainers.find(t);return s.status===e&&r.next(s),s};let l;try{await(0,Nt.zg)(r,(t=>{const s=window.performance.now();i.debug(`awaitStatus(), docker container ('${t.name}') GET status = '${e}' in ${s-o} ms.`)}),(async()=>{const t=await a();i.debug(`awaitStatus(), docker container ('${t.name}') HAS status = '${t.status}'.`),l=window.setInterval(a,200)}),s)}finally{window.clearInterval(l)}}(u,"started",3e4,ms.logger))}),{description:"Load dataset with macromolecules of 'Helm' notation.",delay:2e3}).step("Align peptides with non-natural aminoacids with PepSeA",(async()=>{const t=o.TaskBarProgressIndicator.create("MSA by PepSeA ...");try{await g,s=e.getCol("HELM");const t=be.Jy[0],o=1.53,r=0;if(i=await(0,be.f3)(s,c,t,o,r,void 0),!i)throw new Error("Empty MSA result.");e.columns.add(i),await n.data.detectSemanticTypes(e)}finally{t.close()}}),{description:"Multiple sequence alignment (MSA) performed with PepSeA tool operating on non-natural aminoacids as well.",delay:2e3}).step("Build sequence space",(async()=>{const s=o.Func.find({package:"Bio",name:"macromoleculePreprocessingFunction"})[0];l=await ks(e,i,h,p.U.LEVENSHTEIN,!0,s),t.dockManager.dock(l,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()=>{a=await e.plot.fromType("WebLogo",{sequenceColumnName:c,positionWidth:40,maxHeight:50}),t.dockManager.dock(a,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){he(t)}}()}async function Tn(t,e){var s;We(s=e),s.setTag("units",pt.r2.SEPARATOR),s.setTag("separator","-"),await n.data.detectSemanticTypes(t)}async function bn(t){const e=(0,j.Xk)(t),s=JSON.stringify(e);o.Utils.download(`${t.name}.json`,s)}async function An(t,e,s){const i=await t.readAsString();await async function(t,e,s){const i=o.TaskBarProgressIndicator.create("detectMacromolecule probe ...");try{let r=0;const a=await n.functions.call("Bio:detectMacromoleculeEnableStore");let l=0;for(let c=0;c<s;++c){const h=o.DataFrame.fromCsv(t),u=e?h.getCol(e):h.columns.byIndex(0);await n.functions.call("Bio:detectMacromolecule",{col:u})!==o.SEMTYPE.MACROMOLECULE&&(++l,console.warn(`Reject reason: ${a.last.rejectReason}`));const m=c/s;m-r>=.1&&(r=m,i.update(100*m,`detectMacromolecule probe ${l}/${c}/${s} ...`),await(0,Nt.gw)(0))}l>0?n.shell.warning(`detectMacromolecule failed ${l} / ${s}`):n.shell.info(`detectMacromolecule success ${s}`)}finally{i.close()}}(i,e,s)}},9017:(t,e,s)=>{"use strict";s.d(e,{k:()=>o});class n{constructor(){this.value=0,this.parentI=0,this.parentJ=0}}class i{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="",n="",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,n=this.seq2.substr((e-1)*this.step,this.step)+n):this.dpGrid[t][e].parentJ==e?(n=o+n,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,n=e-1>=0?this.seq2.substr((e-1)*this.step,this.step)+n:o+n);const i=t;t=this.dpGrid[t][e].parentI,e=this.dpGrid[i][e].parentJ}return new i(s,n,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 n);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 n);this.dpGrid.push(t)}let t=0,e=0,s=0;for(let n=1;n<=this.len1;n++)for(let i=1;i<=this.len2;i++)this.fillOne(n,i),this.dpGrid[n][i].value<=0?(this.dpGrid[n][i].value=0,this.dpGrid[n][i].parentI=0,this.dpGrid[n][i].parentJ=0):0==this.dpGrid[this.dpGrid[n][i].parentI][this.dpGrid[n][i].parentJ].value&&(this.dpGrid[n][i].parentI=0,this.dpGrid[n][i].parentJ=0),this.dpGrid[n][i].value>t&&(t=this.dpGrid[n][i].value,e=n,s=i);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,n=""){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,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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.4,-1.3,-10.8,-11.5,-12.4,-8.2,-50,-12.5,-50,-8.9,-9.2,-10,-9.4,-7.9,-50,-14.3,-19.9,-11.4,-16.2,-19.2,-15.8,-15.9],[-6.3,-7.4,-8,-6,2.8,-.7,.9,.3,-7.5,-4.4,-8.4,-3.6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-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,-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,-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(n),this.setSequences(t,e),this.setGap(s)}}},7983:(t,e,s)=>{"use strict";s.d(e,{HV:()=>p,QF:()=>d,pf:()=>m,uH:()=>u});var n=s(4469),i=s(3870),o=s(976),r=s(7241),a=s(4293),l=s(8467),c=s(8447);const h="substr_helm";class u{constructor(t){this.col=t[0],this.createUI()}editHelmLinkAction(){(0,a.Y)(this.inputsDiv,this.grid.root),i.tools.waitForElementInDom(this.grid.root).then((()=>{setTimeout((()=>{this.grid.cell(h,0).element.children[0].dispatchEvent(new KeyboardEvent("keydown",{key:"Enter"}))}),100)}))}updateInputs(){const t=this.units===c.r2.HELM?i.divV([this.columnsInput,this.editHelmLink]):this.units===c.r2.SEPARATOR?i.inputs([this.columnsInput,this.substructureInput,this.separatorInput]):i.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=n.shell.tv.dataFrame,e={filter:t=>t.semType===o.SEMTYPE.MACROMOLECULE};this.columnsInput=i.columnInput("Column",t,this.col,(t=>{this.col=t,this.updateNotationDiv(),this.updateInputs()}),e),this.substructureInput=i.stringInput("Substructure",""),this.editHelmLink=i.link("Edit helm",(()=>this.editHelmLinkAction()),void 0,{style:{position:"relative",left:"95px"}});const s=o.DataFrame.create(1);s.columns.addNewString(h).init((t=>"")),s.col(h).semType=this.col.semType,s.col(h).setTag(o.TAGS.UNITS,c.r2.HELM),this.grid=s.plot.grid(),this.separatorInput=i.stringInput("Separator",this.separator),this.inputsDiv=i.div(),this.units=this.col.getTag(o.TAGS.UNITS),this.separator=this.col.getTag("separator"),this.updateInputs(),this.dialog=i.dialog("Substructure Search").add(i.divV([i.divText(`Notation: ${this.units}`,"notation-text"),this.inputsDiv])).onOK((async()=>{let t,e=this.units===c.r2.HELM?s.get(h,0):this.substructureInput.value;this.units===c.r2.SEPARATOR&&this.separatorInput.value!==this.separator&&""!==this.separatorInput.value&&(e=e.replaceAll(this.separatorInput.value,this.separator)),t=this.units===c.r2.HELM?await d(e,this.col):m(e,this.col),this.col.dataFrame.filter.and(t)})).show()}}function m(t,e,s){const n=s?function(t,e){const s=`${e}`.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),n=t.charAt(0)===e,i=t.charAt(t.length-1)===e,o=t.replace(new RegExp(`^${s}|${s}$`,"g"),"");return n?i?`${s}${o}${s}`:`${s}${o}${s}|${s}${o}$`:i?`^${o}${s}|${s}${o}${s}`:`^${o}${s}|${s}${o}${s}|${s}${o}$`}(t,s):t,i=o.BitSet.create(e.length);for(let s=0;s<e.length;s++){const o=e.get(s);(o.match(n)||o===t)&&i.set(s,!0,!1)}return i}async function d(t,e){e.version!==e.temp["last-invalidated-version"]&&await p(e,!0);const s=o.Column.string("helm",1).init((e=>t));s.semType=o.SEMTYPE.MACROMOLECULE,s.setTag(o.TAGS.UNITS,c.r2.HELM);const i=await(0,r.D)(s,!0,e.temp["monomers-dict"]);return(await n.functions.call("Chem:searchSubstructure",{molStringsColumn:e.temp["monomeric-mols"],molString:i.get(0),molBlockFailover:""})).get(0)}async function p(t,e){const s=o.TaskBarProgressIndicator.create(`Invalidating molfiles for ${t.name}`);try{await(0,l.gw)(10);const s=new Map,n=await(0,r.D)(t,e,s);t.temp["monomeric-mols"]=n,t.temp["monomers-dict"]=s,t.temp["last-invalidated-version"]=t.version}finally{s.close()}}},2568:(t,e,s)=>{"use strict";s.d(e,{l:()=>a,n:()=>r});var n=s(4469),i=s(976),o=s(499);function r(t,e,s=[],i=[],o=!0){const[r,l]=a(t,e,s,i);return o&&!r&&n.shell.warning(l),r}function a(t,e,s=[],r=[]){let a=!0,l="";const c=o.Cn.getOrCreate(t);if(t.semType!==i.SEMTYPE.MACROMOLECULE)n.shell.warning(e+" analysis is allowed for Macromolecules semantic type"),a=!1;else{const t=c.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(!c.isHelm()){const t=c.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]}},3553:(t,e,s)=>{"use strict";s.d(e,{Of:()=>o,WY:()=>h,jB:()=>u,mU:()=>a,rs:()=>c});var n,i,o,r=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"}(n||(n={})),function(t){t.AAR="AAR",t.POSITION="Pos",t.SELECTION="selection"}(i||(i={})),function(t){t.MONOMER="Monomer",t.MACROMOLECULE_DIFFERENCE="MacromoleculeDifference",t.ACTIVITY="activity",t.ACTIVITY_SCALED="activityScaled"}(o||(o={}));const a="MSA";var l,c;!function(t){t.CELL_CHANGING="isCellChanging"}(l||(l={})),function(t){t.SEPARATOR="."}(c||(c={}));const h="3.3.1",u={pepsea:{gapOpen:1.53,gapExtend:0,method:r.Jy[0]},kalign:{gapOpen:-1,gapExtend:-1,terminalGap:-1}}},4004:(t,e,s)=>{"use strict";s.d(e,{O:()=>m,o:()=>d});var n=s(976),i=s(3870),o=s(4469),r=s(3336),a=s.n(r),l=s(8447),c=s(499);let h=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=c.Cn.getOrCreate(e),r=s.notation;const m=i.divText("Current notation: "+r,{style:{"text-align":"center","font-weight":"bold","font-size":"14px",padding:"5px"}}),p=[l.r2.FASTA,l.r2.SEPARATOR,l.r2.HELM],g=i.columnInput("Column",o.shell.t,e,(t=>{t.semType===n.SEMTYPE.MACROMOLECULE?(e=t,s=c.Cn.getOrCreate(e),r=s.notation,r===l.r2.HELM&&(w.value="/"),m.textContent="Current notation: "+r,y=p.filter((t=>t!==r)),T=i.choiceInput("Convert to",y[0],y,C),C(),h?.clear(),h?.add(i.div([m,g.root,T.root,w.root]))):g.value=e})),f=["-",".","/"];let y=p.filter((t=>t!==r));const w=i.choiceInput("Separator",f[0],f),C=()=>{T.value!==l.r2.SEPARATOR?a()(w.root).hide():a()(w.root).show()};let T=i.choiceInput("Convert to",y[0],y,C);C(),T.onChanged((()=>{C()})),null==h&&(h=i.dialog("Convert Sequence Notation").add(i.div([m,g.root,T.root,w.root])).onOK((async()=>{const t=T.value,s=w.value??void 0;await d(e,t,s)})).show({x:350,y:100}),u.push(h.onClose.subscribe((t=>{u.forEach((t=>{t.unsubscribe()})),u=[],h=null}))))}async function d(t,e,s){const n=c.Cn.getOrCreate(t).convert(e,s);t.dataFrame.columns.add(n);const i=await o.functions.call("Bio:detectMacromolecule",{col:n});return i&&(n.semType=i),await o.data.detectSemanticTypes(t.dataFrame),n}},2918:(t,e,s)=>{"use strict";s.d(e,{NT:()=>T,P4:()=>f,cf:()=>w});var n=s(4469),i=s(3870),o=s(976),r=s(701),a=s(6584),l=s(922),c=s(1047);class h{constructor(t){this.rawLib=t}isValid(){return this.rawLib.every((t=>"object"==typeof t&&Object.values(c.Wc).every((e=>e in t&&"string"==typeof t[e]))))}getJsonMonomerLib(){const t=[];return this.rawLib.forEach((e=>{const s=this.prepareMonomer(e);t.push(s)})),t}prepareMonomer(t){const e={...c.Z2};Object.entries(c.Wc).forEach((([s,n])=>{const i=t[n];e[s]=i}));let s="smiles";const n=t[c.Wc[s]],i=new u(n),o=i.getCappedSmiles();return e[s]=o,s="rgroups",e[s]=m.getRGroups(i.getNumberOfRGroups()),s="molfile",e[s]=new d(i.getSmilesWithRGroups()).getMolfile(),e}}class u{constructor(t){let e=0;this.smilesWithRGroups=t.replace(/\[R(\d+)\]/g,((t,s)=>(++e,`[${s}*]`))),this.numberOfRGroups=e}getSmilesWithRGroups(){return this.smilesWithRGroups}getCappedSmiles(){return this.capRGroups()}getNumberOfRGroups(){return this.numberOfRGroups}capRGroups(){let t=this.smilesWithRGroups.replace("[1*]","[H:1]");return t=t.replace("[2*]","[OH:2]"),t.replace("[3*]","[H:3]")}}class m{constructor(){}static getRGroups(t){return c.nJ.slice(0,t)}}class d{constructor(t){this.smilesWithRGroups=t}getMolfile(){let t=o.chem.convert(this.smilesWithRGroups,o.chem.Notation.Smiles,o.chem.Notation.MolBlock);return t=this.restoreRGPLine(t),t=this.fixRGroupSymbols(t),t}restoreRGPLine(t){return t.replace("M ISO","M RGP")}fixRGroupSymbols(t){return t.replace(/\bR\b/g,"R#")}}var p=s(7228),g=s(6423);async function f(){return await Promise.all((await n.dapi.files.list(a.BX,!0,"")).map((async t=>t.fullPath.substring(a.BX.length))))}async function y(){const t=i.dialog({title:"Manage files"}).add(i.fileBrowser({path:"System:AppData/Bio/libraries"}).root).addButton("OK",(()=>t.close())).show()}async function w(){const t=i.button("Manage",y),e=i.inputs([]),s=await f(),r=await(0,a.nW)();for(const t of s){const s=i.boolInput(t,!r.exclude.includes(t),(()=>{1==s.value?r.exclude=r.exclude.filter((e=>e!=t)):r.exclude.includes(t)||r.exclude.push(t),(0,a.tW)(r).then((async()=>{await T.instance.loadLibraries(!0),n.shell.info("Monomer library user settings saved.")}))}));e.append(s.root)}return new o.Widget(i.divV([e,i.div(t)]))}class C{constructor(t,e){this._monomers={},this._onChanged=new r.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 n=this.getMonomerSymbolsByType(e).map((t=>this.getMonomer(e,t)));return n=n.filter((t=>null!==t)),0===n.length?[]:(n=n.filter((e=>{if(!e?.rgroups)return!1;let s=e?.rgroups.length>=t;return l._.getInstance(e.molfile).atomTypes.map(((t,e)=>"R#"===t?e:-1)).filter((t=>-1!==t)),s&&(s=!0),s})),n.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 T{constructor(){this._monomerLib=new C({}),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([f(),(0,a.nW)()]),n=e.filter((t=>!s.exclude.includes(t))).filter((t=>!(s.explicit.length>0)||s.explicit.includes(t))),i=await Promise.all(n.map((t=>this.readLibrary(a.BX,t).catch((e=>{const s=`Loading monomers from '${t}' error: ${e instanceof Error?e.message:e.toString()}`;return new C({},s)})))));this._monomerLib.updateLibs(i,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,r=[];const a=new o.FileSource(t);if(e.endsWith(".sdf"))1===o.Func.find({package:"Chem",name:"importSdf"}).length?(s=await a.readAsBytes(e),i=await n.functions.call("Chem:importSdf",{bytes:s}),r=(0,p.Xk)(i[0])):n.shell.warning("Chem package is not installed");else if(e.endsWith(".json")){const t=await a.readAsText(e);r=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)),{})))),s=new h(t);if(!s.isValid())throw new Error("Invalid format of CSV monomer lib");r=s.getJsonMonomerLib()}}var l;const c={},u=[];return r.forEach((t=>{u.includes(t.polymerType)||(c[t.polymerType]={},u.push(t.polymerType)),c[t.polymerType][t.symbol]=t})),new C(c)}async selectSpecifiedLibraries(t){const e=await this.getInvalidFileNames(t);if(e.length>0)throw new Error(`Cannot select libraries ${e}: no such library in the list`);const s=await(0,a.nW)();s.exclude=(await f()).filter((e=>!t.includes(e))),await(0,a.tW)(s)}async getInvalidFileNames(t){const e=await f();return t.filter((t=>!e.includes(t)))}static get instance(){return window.$monomerLibHelper||(window.$monomerLibHelper=new T),window.$monomerLibHelper}}},525:(t,e,s)=>{"use strict";s.d(e,{K:()=>x});var n=s(4469),i=s(976),o=s(3870),r=s(8447),a=s(499),l=s(6098),c=s(8341),h=s(2568),u=s(3553),m=s(6423),d=s(3379),p=s.n(d),g=s(7795),f=s.n(g),y=s(569),w=s.n(y),C=s(3565),T=s.n(C),b=s(9216),A=s.n(b),S=s(4589),E=s.n(S),M=s(9564),v={};v.styleTagTransform=E(),v.setAttributes=T(),v.insert=w().bind(null,"head"),v.domAPI=f(),v.insertStyleElement=A(),p()(M.Z,v),M.Z&&M.Z.locals&&M.Z.locals;class N extends Error{constructor(t,e){super(t,e)}}async function x(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 h=t.col?.dataFrame??n.shell.t,m=t.col??h.columns.bySemType(i.SEMTYPE.MACROMOLECULE);if(null==m){const t="MSAError: dataset doesn't conain any Macromolecule column";n.shell.warning(t),s(new N(t))}const d=o.choiceInput("Method",t.pepsea.method,c.Jy);d.setTooltip("Alignment method");const p=o.floatInput("Terminal gap",t?.kalign?.terminalGap??null);p.setTooltip("Penalty for opening a gap at the beginning or end of the sequence");const g=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 w=o.inputs([f,y,p]),C=o.button("Alignment parameters",(()=>{w.hidden=!w.hidden}),"Adjust alignment parameters such as penalties for opening and extending gaps");C.classList.add("msa-params-button"),w.hidden=!0,C.prepend(o.icons.settings((()=>null)));const T=[d.root.style],b=[p.root.style,g.style];let A;const S=o.columnInput("Sequence",h,m,(async()=>{A=await L(S.value,h,T,b,d,E,f,y,p)}),{filter:t=>t.semType===i.SEMTYPE.MACROMOLECULE});S.setTooltip("Sequences column to use for alignment");const E=o.columnInput("Clusters",h,t.clustersCol);if(E.nullable=!0,S.fireChanged(),t.col)return A=await L(t.col,h,T,b,d,E,f,y,p),void await I(S,h,A,e,s);o.dialog("MSA").add(S).add(E).add(d).add(w).add(C).add(g).onOK((async()=>{await I(S,h,A,e,s)})).show()}))}async function I(t,e,s,o,r){let a=null;const l=i.TaskBarProgressIndicator.create("Analyze for MSA ...");try{if(t.fireChanged(),t.value.semType!==i.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 n.data.detectSemanticTypes(e),o(a)}catch(t){const e=t instanceof Error?t.message:t.toString();n.shell.error(e),r(t)}finally{l.close()}}async function L(t,e,s,o,d,p,g,f,y){try{if(t.semType!==i.SEMTYPE.MACROMOLECULE)return;const n=e.columns.getUnusedName(`msa(${t.name})`);if((0,h.n)(t,t.name,[r.r2.FASTA,r.r2.SEPARATOR],["DNA","RNA","PT"],!1)){P(s,o,"kalign"),g.value=null,f.value=null,y.value=null;const e=a.Cn.getOrCreate(t),i=e.isFasta()?t:e.convert(r.r2.FASTA);return async()=>await(0,l.U)(i,!1,n,p.value)}if((0,h.n)(t,t.name,[r.r2.HELM],[],!1))return P(s,o,"pepsea"),g.value??(g.value=u.jB.pepsea.gapOpen),f.value??(f.value=u.jB.pepsea.gapExtend),async()=>await(0,c.f3)(t,n,d.value,g.value,f.value,p.value);if((0,h.n)(t,t.name,[r.r2.SEPARATOR],["UN"],!1)){const e=a.Cn.getOrCreate(t).convert(r.r2.HELM);return P(s,o,"pepsea"),g.value??(g.value=u.jB.pepsea.gapOpen),f.value??(f.value=u.jB.pepsea.gapExtend),async()=>await(0,c.f3)(e,n,d.value,g.value,f.value,p.value)}return g.value=null,f.value=null,y.value=null,void P(s,o,"kalign")}catch(t){const e=t instanceof Error?t.message:t.toString();n.shell.error(e),m._package.logger.error(e)}}function P(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:()=>O});var n=s(976),i=s(5226);const o=Symbol("Comlink.proxy"),r=Symbol("Comlink.endpoint"),a=Symbol("Comlink.releaseProxy"),l=Symbol("Comlink.thrown"),c=t=>"object"==typeof t&&null!==t||"function"==typeof t,h=new Map([["proxy",{canHandle:t=>c(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=>c(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(n){if(!n||!n.data)return;const{id:i,type:r,path:a}=Object.assign({path:[]},n.data),c=(n.data.argumentList||[]).map(T);let h;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":h=s;break;case"SET":e[a.slice(-1)[0]]=T(n.data.value),h=!0;break;case"APPLY":h=s.apply(e,c);break;case"CONSTRUCT":h=function(t){return Object.assign(t,{[o]:!0})}(new s(...c));break;case"ENDPOINT":{const{port1:e,port2:s}=new MessageChannel;u(t,s),h=function(t,e){return w.set(t,e),t}(e,[e])}break;case"RELEASE":h=void 0;break;default:return}}catch(t){h={value:t,[l]:0}}Promise.resolve(h).catch((t=>({value:t,[l]:0}))).then((t=>{const[n,o]=C(t);e.postMessage(Object.assign(Object.assign({},n),{id:i}),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 g(t,[],e)}function p(t){if(t)throw new Error("Proxy has been released and is not useable")}function g(t,e=[],s=function(){}){let n=!1;const i=new Proxy(s,{get(s,o){if(p(n),o===a)return()=>b(t,{type:"RELEASE",path:e.map((t=>t.toString()))}).then((()=>{m(t),n=!0}));if("then"===o){if(0===e.length)return{then:()=>i};const s=b(t,{type:"GET",path:e.map((t=>t.toString()))}).then(T);return s.then.bind(s)}return g(t,[...e,o])},set(s,i,o){p(n);const[r,a]=C(o);return b(t,{type:"SET",path:[...e,i].map((t=>t.toString())),value:r},a).then(T)},apply(s,i,o){p(n);const a=e[e.length-1];if(a===r)return b(t,{type:"ENDPOINT"}).then(T);if("bind"===a)return g(t,e.slice(0,-1));const[l,c]=y(o);return b(t,{type:"APPLY",path:e.map((t=>t.toString())),argumentList:l},c).then(T)},construct(s,i){p(n);const[o,r]=y(i);return b(t,{type:"CONSTRUCT",path:e.map((t=>t.toString())),argumentList:o},r).then(T)}});return i}function f(t){return Array.prototype.concat.apply([],t)}function y(t){const e=t.map(C);return[e.map((t=>t[0])),f(e.map((t=>t[1])))]}const w=new WeakMap;function C(t){for(const[e,s]of h)if(s.canHandle(t)){const[n,i]=s.serialize(t);return[{type:"HANDLER",name:e,value:n},i]}return[{type:"RAW",value:t},w.get(t)||[]]}function T(t){switch(t.type){case"HANDLER":return h.get(t.name).deserialize(t.value);case"RAW":return t.value}}function b(t,e,s){return new Promise((n=>{const i=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!==i||(t.removeEventListener("message",e),n(s.data))})),t.start&&t.start(),t.postMessage(Object.assign({id:i},e),s)}))}const A="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2NvbnN0ICQ9U3ltYm9sKCJDb21saW5rLnByb3h5IiksQT1TeW1ib2woIkNvbWxpbmsuZW5kcG9pbnQiKSxSPVN5bWJvbCgiQ29tbGluay5yZWxlYXNlUHJveHkiKSx5PVN5bWJvbCgiQ29tbGluay50aHJvd24iKSxfPWU9PnR5cGVvZiBlPT0ib2JqZWN0IiYmZSE9PW51bGx8fHR5cGVvZiBlPT0iZnVuY3Rpb24iLEw9e2NhbkhhbmRsZTplPT5fKGUpJiZlWyRdLHNlcmlhbGl6ZShlKXtjb25zdHtwb3J0MTpyLHBvcnQyOml9PW5ldyBNZXNzYWdlQ2hhbm5lbDtyZXR1cm4gdyhlLHIpLFtpLFtpXV19LGRlc2VyaWFsaXplKGUpe3JldHVybiBlL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text/javascript;charset=utf-8"});function E(){const t=S&&(window.URL||window.webkitURL).createObjectURL(S);try{return t?new Worker(t):new Worker("data:application/javascript;base64,"+A)}finally{t&&(window.URL||window.webkitURL).revokeObjectURL(t)}}const M={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 v{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({},M,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 E;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 N=s(850);class x{static getAvailableScales(){return Object.entries(this.scales).map((([t,e])=>t))}static getScale(t){return(0,N.hu)(!(void 0===this.scales[t]),`Scale '${t}' was not found.`),this.scales[t]}}x.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 I{constructor(t="categorial"){this.aa2num=x.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 n=["NH2","COOH"];if(t.startsWith(n[0])){const s=n[0].length;(0,N.hu)("-"==t[s],`Wrong sequence format: ${n[0]} without following '-' in '${t}'.`),e=s}if(t.endsWith(n[1])){const e=n[1].length+1;(0,N.hu)("-"==t[s-e],`Wrong sequence format: ${n[1]} without '-' precending in '${t}'.`),s-=e}return t.substring(e,s)}static _dropDefises(t){return t.replace(/(-)([^-]+)/g,"$2")}static clean(t){return I._dropDefises(I._truncateSequence(t))}encode(t){const e=t.length,s=new Array(e).fill(0);for(let n=0;n<e;++n){const e=t[n];(0,N.hu)(e in this.aa2num,`Unknown char '${e}' found in sequence '${t}'`),s[n]=this.encodeLettter(e)}return s}encodeLettter(t){return this.aa2num[t]}decode(t){let e="";for(let s=0;s<t.length;++s){const n=t[s];(0,N.hu)(n in this.num2aa,`Unknown code '${n}' found in vector '${t}'`),e+=this.num2aa[n]}return e}}var L=s(3553);const P="input.fa",R="result.fasta";function _(t){return t.reduce(((t,e,s)=>t+`>sample${s+1}\n${e}\n`),"")}async function O(t,e=!1,s="",o=null,r,a,l){let c=t.toList();e&&(c=c.map((t=>I.clean(t).replace(/\-/g,""))));const h=t.length;o??(o=n.Column.string("Clusters",h).init("0")),o.type!=n.COLUMN_TYPE.STRING&&(o=o.convertTo(n.TYPE.STRING)),o.compact();const u=o.categories,m=o.getRawData(),d=new Array(u.length),p=new Array(u.length);for(let t=0;t<h;++t){const e=m[t];(d[e]??(d[e]=[])).push(c[t]),(p[e]??(p[e]=[])).push(t)}const g=await new v(["base/1.0.0",{tool:"kalign",version:L.WY,reinit:!0}]),f=n.Column.string(s,h);for(let t=0;t<u.length;++t){const e=_(d[t]);await g.fs.writeFile(P,e);const s=`${void 0!==r?` --gpo ${r}`:""}${void 0!==a?` --gpe ${a}`:""}${void 0!==l?` --tgpe ${l}`:""}`,n=await g.exec(`kalign ${P} -f fasta -o ${R}${s}`);console.warn(n);const o=await g.cat(R);if(!o)throw new Error("kalign output no result");const c=new i.i(o).sequencesArray,h=p[t];for(let t=0;t<c.length;++t)f.set(h[t],c[t])}const y=t.getTag(n.TAGS.UNITS),w=t.getTag("alphabet");return f.setTag(n.TAGS.UNITS,y),f.setTag("aligned","SEQ.MSA"),f.setTag("alphabet",w),f.semType=n.SEMTYPE.MACROMOLECULE,f}},8341:(t,e,s)=>{"use strict";s.d(e,{Jy:()=>l,f3:()=>h,lp:()=>a});var n=s(4469),i=s(976),o=s(8447),r=s(3553);const a=new class{constructor(){this.dcName="bio"}async getDockerContainer(){return await n.dapi.docker.dockerContainers.filter(this.dcName).first()}},l=["mafft --auto","mafft","linsi","ginsi","einsi","fftns","fftnsi","nwns","nwnsi"],c=["AlignedSeq","AlignedSubpeptide","HELM","ID","PolymerID"];async function h(t,e,s="ginsi",l=1.53,h=0,m=null){const d=await a.getDockerContainer();if("started"!==d.status&&"checking"!==d.status)return n.log.warning("PepSeA container has not started yet"),null;const p=t.length;m??(m=i.Column.int("Clusters",p).init(0)),m.type!=i.COLUMN_TYPE.STRING&&(m=m.convertTo(i.TYPE.STRING));const g=m.categories,f=new Array(g.length);for(let e=0;e<p;++e){const s=m.get(e);if(""===s)continue;const n=g.indexOf(s),i=t.get(e);i&&(f[n]??(f[n]=[])).push({ID:e.toString(),HELM:i})}const y=new Array(p);for(const t of f){const e=(await u(d.id,t,s,l,h)).Alignment;for(const t of e)y[parseInt(t.ID)]=Object.entries(t).filter((t=>!c.includes(t[0]))).map((t=>"-"!==t[1]?t[1]:"")).join(r.rs.SEPARATOR)}const w=i.Column.fromStrings(e,y);return w.setTag(i.TAGS.UNITS,o.r2.SEPARATOR),w.setTag("separator",r.rs.SEPARATOR),w.setTag("aligned","SEQ.MSA"),w.setTag("alphabet","UN"),w.setTag(".alphabetIsMultichar","true"),w.semType=i.SEMTYPE.MACROMOLECULE,w}async function u(t,e,s,i,o){const r={method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(e)},a=`/align?method=${s}&gap_open=${i}&gap_extend=${o}`,l=await n.dapi.docker.dockerContainers.request(t,a,r);return JSON.parse(l??"{}")}},9953:(t,e,s)=>{"use strict";s.d(e,{M:()=>n});const n="<All>"},9943:(t,e,s)=>{"use strict";s.d(e,{C2:()=>u,i$:()=>m,sK:()=>d});var n=s(976),i=s(3870),o=s(4469),r=s(6414),a=s.n(r),l=s(8447),c=s(499);const h=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!==n.SEMTYPE.MACROMOLECULE)).toArray(),s=e.find((t=>-1!==t.name.toLowerCase().indexOf("id"))),r=s?[s.name]:[],l=i.multiChoiceInput("Seq id columns",r,e.map((t=>t.name))),u=a().count(0).take(t.columns.length).map((e=>t.columns.byIndex(e))).filter((t=>{const e=t.column;return!(!e||e.semType!==n.SEMTYPE.MACROMOLECULE)&&c.Cn.getOrCreate(e).isFasta()})).toArray(),d=u.length>0?u[0].name:[],p=i.choiceInput("Seq column",d,u.map((t=>t.name))),g=i.intInput("FASTA line width",h);i.dialog({title:"Save as FASTA"}).add(i.inputs([l,p,g])).onOK((()=>{const e=l.value?l.value.map((e=>t.columns.byName(e).column)):[],s=p.value?t.columns.byName(p.value).column:null,n=g.value??h;s||o.shell.warning("Seq column is mandatory to save as FASTA.");const i=m(e,s,n),r=document.createElement("a");r.setAttribute("href",`data:text/plain;charset=utf-8,${encodeURIComponent(i)}`),r.setAttribute("download",`${t.dataFrame.name}.fasta`),r.click()})).show()}function m(t,e,s=h,n="\n"){const i=l.kB,o=[];for(let r=0;r<e.length;r++){const a=t.map((t=>t.get(r).toString())).join("|"),l=d(e.get(r),i,s);o.push(`>${a}${n}`);for(const t of l)o.push(`${t}${n}`)}return"".concat(...o)}function d(t,e,s=h){const n=e(t);let i=0;const o=n.length,r=[];for(;i<o;){const t=a()(n).slice(i,i+s).toArray(),e=t.map((t=>t.length>1?`[${t}]`:t)).join("");r.push(e),i+=t.length}return r}},9416:(t,e,s)=>{"use strict";s.d(e,{n:()=>c});var n=s(4469),i=s(976),o=s(8467),r=s(2568),a=s(8457),l=s(3553);async function c(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 c=e.dataFrame;for(const t of s.columns)t.semType=l.Of.MONOMER,t.setTag("alphabet",e.getTag("alphabet"));const h=/(\d+)(?: \((\d+)\))?/,u=t=>{h.lastIndex=0;const e=t.match(h);return e?`${e[1]} (${parseInt(e[2]??0)+1})`:t};for(let t=0;t<s.columns.length;t++){const n=s.columns.byIndex(t);n.semType=l.Of.MONOMER,n.setTag("alphabet",e.getTag("alphabet"));const i=100;let o=0;for(;c.columns.byName(n.name)&&o<i;)n.name=u(n.name),o++;c.columns.add(n)}await n.data.detectSemanticTypes(c);for(let t=0;t<s.columns.length;t++){const e=s.columns.byIndex(t);e.setTag(i.TAGS.CELL_RENDERER,"Monomer"),e.setTag(".use-as-filter","false")}return c}},4293:(t,e,s)=>{"use strict";s.d(e,{B:()=>o,Y:()=>r});var n=s(4469),i=s(976);function o(){const t=n.shell.t.columns.bySemTypeAll(i.SEMTYPE.MACROMOLECULE);if(null!==t)return t;n.shell.error("Current table does not contain macromolecules")}function r(t,e){t.innerHTML="",t.append(e)}},8415:(t,e,s)=>{"use strict";s.d(e,{bo:()=>y,CK:()=>b,yW:()=>T,OZ:()=>E,eZ:()=>M});var n=s(4469),i=s(3870),o=s(976),r=s(6414),a=s.n(r),l=s(701),c=s(499),h=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=s(7945),p=s(8467),g=s(172);var f,y,w=s(8770),C=s(6423);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 T{constructor(t=0,e){this.valueList=null,this.valueIdx=0,this.value=this.rowCount=t,this.bounds=e}push(t){this.valueList||(this.valueList=new Array(this.rowCount),this.valueIdx=0),this.valueList[this.valueIdx]=t,++this.valueIdx}aggregate(t){this.value=t(this.valueList)??0,this.valueList=null}}class b{get label(){return this._label?this._label:this.name}constructor(t,e,s,n){this.sumRowCount=0,this.pos=t,this.name=e,this._freqs=s??{},n?.sumRowCount&&(this.sumRowCount=n.sumRowCount),n?.sumValueForHeight&&(this.sumPlotValue=n.sumValueForHeight),n?.label&&(this._label=n.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 T),e}aggregate(t){const e=function(t){return e=>{const s=function(t){let e;const s="agg";return e=t instanceof Float32Array?o.Column.fromFloat32Array(s,t):t instanceof Int32Array?o.Column.fromInt32Array(s,t):o.Column.fromList(o.COLUMN_TYPE.FLOAT,s,t),e}(e);return s.aggregate(t)}}(t);for(const[t,s]of Object.entries(this._freqs))s.aggregate(e)}getMinValue(){return Math.min(...Object.values(this._freqs).map((t=>t.value)))}calcPlotValue(t){for(const e of Object.values(this._freqs))e.plotValue=e.value-t}calcHeights(t){this.sumPlotValue=0;for(const t of Object.values(this._freqs))this.sumPlotValue+=t.plotValue;if(this.sumPlotValueForHeight=0,t===u.ES.Entropy){const t=Object.keys(this._freqs).length,e=.01*this.sumPlotValue,s=e/t;for(const t of Object.values(this._freqs)){const n=(t.plotValue+s)/(this.sumPlotValue+e);this.sumPlotValueForHeight+=-n*Math.log2(n)}}else if(t===u.ES.full)for(const[t,e]of Object.entries(this._freqs)){const t=e.plotValue/this.sumPlotValue;this.sumPlotValueForHeight+=t}}calcScreen(t,e,s,n,i,r,a,l,c,h){const m=i===u.ES.Entropy?n*(r-this.sumPlotValueForHeight)/r:n;let d=h*c+(n-m-1);const p=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].value-e[1].value));for(const[t,n]of p){const t=m*n.plotValue/this.sumPlotValue;n.bounds=new o.Rect((e-s)*c*a,d,l*c,t),d+=t}}render(t,e,s,n,i,o){for(const[r,a]of Object.entries(this._freqs))if(!e(r)){const e=(0,h.GU)(r,5),l=a.bounds,c=l.left;t.resetTransform(),t.strokeStyle="lightgray",t.lineWidth=1,t.rect(c,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/i,c,l.top),t.fillText(e,0,-n)}}getMonomerAt(t,e){const s=Object.entries(this._freqs).find((([s,n])=>n.bounds.contains(t,e)));return s?s[0]:void 0}buildCompositionTable(t){return(0,w._)(t,Object.assign({},...Object.entries(this._freqs).map((([t,e])=>({[t]:e.rowCount})))))}}!function(t){t.STYLE="Style",t.BEHAVIOR="Behavior",t.LAYOUT="Layout",t.DATA="Data"}(f||(f={})),function(t){t.sequenceColumnName="sequenceColumnName",t.valueAggrType="valueAggrType",t.valueColumnName="valueColumnName",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"}(y||(y={}));const A=u.vS;var S;!function(t){t[t.None=0]="None",t[t.Render=1]="Render",t[t.Layout=1]="Layout",t[t.Freqs=2]="Freqs"}(S||(S={}));class E 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.initialized=!1,this.palette=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.viewerId=++E.viewerCounter,this.setDataInProgress=!1,this.viewSubs=[],this._onSizeChanged=new l.Subject,this._onFreqsCalculated=new l.Subject,this._onLayoutCalculated=new l.Subject,this.requestedRenderLevel=S.Freqs,this.renderRequest=new l.Subject,this._onRendered=new l.Subject,this.textBaseline="top",this.unitsHandler=null,this.sequenceColumnName=this.string(y.sequenceColumnName,A.sequenceColumnName,{category:f.DATA});const t=[o.AGG.KEY,o.AGG.PIVOT,o.AGG.MISSING_VALUE_COUNT,o.AGG.SKEW,o.AGG.KURT,o.AGG.SELECTED_ROWS_COUNT],e=Object.values(o.AGG).filter((e=>!t.includes(e)));this.valueAggrType=this.string(y.valueAggrType,A.valueAggrType,{category:f.DATA,choices:e}),this.valueColumnName=this.string(y.valueColumnName,A.valueColumnName,{category:f.DATA}),this.startPositionName=this.string(y.startPositionName,A.startPositionName,{category:f.DATA}),this.endPositionName=this.string(y.endPositionName,A.endPositionName,{category:f.DATA}),this.skipEmptySequences=this.bool(y.skipEmptySequences,A.skipEmptySequences,{category:f.DATA}),this.skipEmptyPositions=this.bool(y.skipEmptyPositions,A.skipEmptyPositions,{category:f.DATA}),this.shrinkEmptyTail=this.bool(y.shrinkEmptyTail,A.shrinkEmptyTail,{category:f.DATA}),this.backgroundColor=this.int(y.backgroundColor,A.backgroundColor,{category:f.STYLE}),this.positionHeight=this.string(y.positionHeight,A.positionHeight,{category:f.STYLE,choices:Object.values(u.ES)}),this._positionWidth=this.positionWidth=this.float(y.positionWidth,A.positionWidth,{category:f.STYLE}),this.verticalAlignment=this.string(y.verticalAlignment,A.verticalAlignment,{category:f.LAYOUT,choices:Object.values(u.vw)}),this.horizontalAlignment=this.string(y.horizontalAlignment,A.horizontalAlignment,{category:f.LAYOUT,choices:Object.values(u.iD)}),this.fixWidth=this.bool(y.fixWidth,A.fixWidth,{category:f.LAYOUT,userEditable:!1}),this.fitArea=this.bool(y.fitArea,A.fitArea,{category:f.LAYOUT}),this.minHeight=this.float(y.minHeight,A.minHeight,{category:f.LAYOUT}),this.maxHeight=this.float(y.maxHeight,A.maxHeight,{category:f.LAYOUT}),this.showPositionLabels=this.bool(y.showPositionLabels,A.showPositionLabels,{category:f.LAYOUT}),this.positionMarginState=this.string(y.positionMarginState,A.positionMarginState,{category:f.LAYOUT,choices:Object.values(u.dE)});let s=0;"auto"===this.positionMarginState&&(s=4),this.positionMargin=this.int(y.positionMargin,s,{category:f.LAYOUT,min:0,max:16}),this.filterSource=this.string(y.filterSource,A.filterSource,{category:f.BEHAVIOR,choices:Object.values(u.Ct)}),this.slider=i.rangeSlider(0,100,0,20,!1,{style:"barbell"}),this.canvas=i.canvas(),this.canvas.classList.value="bio-wl-canvas",this.canvas.style.width="100%",this.viewSyncer=new g.c(C._package.logger)}viewerToLog(){return`MolstarViewer<${this.viewerId}>`}setData(){const t=`${this.viewerToLog()}.setData()`;C._package.logger.debug(`${t}, in`),this.viewSyncer.sync(`${t}`,(async()=>{if(!this.setDataInProgress){this.setDataInProgress=!0;try{this.viewed&&(this.renderRequestSub.unsubscribe(),await this.destroyView(),this.viewed=!1),this.updateSeqCol(),this.updateEditors(),this.viewed||(await this.buildView(),this.viewed=!0)}finally{this.setDataInProgress=!1}}})),C._package.logger.debug(`${t}, out`)}async destroyView(){for(const t of this.viewSubs)t.unsubscribe();this.viewSubs=[];const t=this.dataFrame?"data":"null";C._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.destroyView( dataFrame = ${t} ) start`),this.host.remove(),this.msgHost=void 0,this.host=void 0,C._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.destroyView() end`)}async buildView(){const t=this.dataFrame?"data":"null";C._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=i.div("No message",{classes:"bio-wl-msg"}),this.msgHost.style.display="none",this.canvas=i.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=i.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,i.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(i.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(S.Freqs,"buildView"),C._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.buildView() end`)}rootOnSizeChanged(){C._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.rootOnSizeChanged(), start `),this.render(S.Layout,"rootOnSizeChanged")}updateEditors(){this.props.getProperty(y.valueColumnName).choices=a()(this.dataFrame.columns.numerical).map((t=>t.name)).toArray()}updateSeqCol(){if(this.dataFrame&&(this.seqCol=this.sequenceColumnName?this.dataFrame.col(this.sequenceColumnName):null,null==this.seqCol&&(this.seqCol=(0,h.up)(this.dataFrame),this.sequenceColumnName=this.seqCol?this.seqCol.name:null),this.seqCol)){try{this.unitsHandler=c.Cn.getOrCreate(this.seqCol),this.palette=(0,h.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.palette=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"),n=this.seqCol.getTag(".positionLabels");this.positionNames=s?s.split(h.CI).map((t=>t.trim())):[...Array(e).keys()].map((t=>`${t+1}`)),this.positionLabels=n?n.split(h.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(S.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),n=Math.min(this.root.clientWidth,e);this.canvas.style.width=`${n}px`,this.canvas.style.height=`${s}px`,this.host.style.width=`${n}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=`${n+6}px`),this.host.style.width=`${this.host}px`;const i=e>n;if(this.setSliderVisibility(i),i){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=n*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),n=e>0?(this.root.clientWidth-this.positionMarginValue*this.Length)/e:0,i=this.root.clientHeight/s,o=Math.max(1,Math.min(n,i));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 c=r>l;if(this.setSliderVisibility(c),c){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 y.sequenceColumnName:this.updateSeqCol();break;case y.sequenceColumnName:case y.startPositionName:case y.endPositionName:case y.filterSource:case y.shrinkEmptyTail:case y.skipEmptyPositions:case y.positionHeight:this.updatePositions();break;case y.valueColumnName:case y.valueAggrType:this.render(S.Freqs,`onPropertyChanged(${t.name})`);break;case y.minHeight:case y.maxHeight:case y.positionWidth:case y.showPositionLabels:case y.fixWidth:case y.fitArea:case y.horizontalAlignment:case y.verticalAlignment:case y.positionMargin:case y.positionMarginState:this.render(S.Layout,`onPropertyChanged(${t.name})`);break;case y.backgroundColor:this.render(S.Render,`onPropertyChanged(${t.name})`)}}onTableAttached(){C._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.onTableAttached(), `),super.onTableAttached(),this.setData()}async detach(){const t=`${this.viewerToLog()}.detach()`;C._package.logger.debug(`${t}, in`);const e=super.detach.bind(this);this.viewSyncer.sync(`${t}`,(async()=>{this.setDataInProgress||(this.viewed&&(await this.destroyView(),this.viewed=!1),e())})),C._package.logger.debug(`${t}, out`)}get onSizeChanged(){return this._onSizeChanged}get onFreqsCalculated(){return this._onFreqsCalculated}get onLayoutCalculated(){return this._onLayoutCalculated}getMonomer(t,e){const s=t.x,n=Math.floor(t.x/(this._positionWidthWithMargin*e)+Math.floor(this.slider.min)),i=this.positions[n];if(!i)return[null,null,null];const o=i.getMonomerAt(s,t.y);return void 0===o?[i,null,null]:[i,o,i.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).rowCount!==t.sumRowCount})).toArray())}render(t,e){C._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(C._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.render.renderInt( renderLevel=${t} ), start `),this.msgHost&&(this.seqCol&&!this.palette?(this.msgHost.innerText=`Unknown palette (column semType: '${this.seqCol.semType}').`,this.msgHost.style.display=""):this.msgHost.style.display="none"),!this.seqCol||!this.dataFrame||!this.palette||null==this.host||null==this.slider)return;const e=window.devicePixelRatio,s=this.showPositionLabels?12:0;if(t>=S.Freqs&&(()=>{if(C._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=c.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(),n=this.dataFrame.rowCount,i=this.unitsHandler.splitted;for(let e=0;e<t;++e){for(let t=0;t<n;++t)if(s.get(t)){const s=i[t][this.startPosition+e]||this.unitsHandler.defaultGapSymbol,n=this.positions[e],o=n.getFreq(s);++n.sumRowCount,o.value=++o.rowCount}if(this.valueAggrType===o.AGG.TOTAL_COUNT)continue;let t=null;try{t=this.dataFrame.getCol(this.valueColumnName),t.matches("numerical")||(t=null)}catch{t=null}if(t){for(let o=0;o<n;++o)if(s.get(o)){const s=i[o][this.startPosition+e]||this.unitsHandler.defaultGapSymbol,n=t.get(o);this.positions[e].getFreq(s).push(n)}this.positions[e].aggregate(this.valueAggrType)}}const r=this.valueAggrType===o.AGG.TOTAL_COUNT?0:Math.min(0,Math.min(...this.positions.map((t=>t.getMinValue()))));for(let e=0;e<t;++e)this.positions[e].calcPlotValue(r),this.positions[e].calcHeights(this.positionHeight);this._removeEmptyPositions(),this._onFreqsCalculated.next()})(),this.calcLayout(e),-1===this.startPosition)return;const i=Math.max(Math.floor(this.slider.min),0),r=Math.min(this.positions.length-1,Math.floor(this.slider.max));t>=S.Layout&&((t,e,s,i)=>{C._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.render.calculateLayoutInt(), start `);const r=this.canvas.height-i*s;let l;if(this.valueAggrType===o.AGG.TOTAL_COUNT){const t=this.getAlphabetSize();this.positionHeight==u.ES.Entropy&&null==t&&n.shell.error("WebLogo: alphabet is undefined."),l=Math.log2(t)}else l=Math.max(...a().count(t).takeWhile((t=>t<=e)).map((t=>this.positions[t].sumPlotValueForHeight)));for(let n=t;n<=e;++n)n in this.positions?this.positions[n].calcScreen((t=>this.unitsHandler.isGap(t)),n,this.slider.min,r,this.positionHeight,l,this._positionWidthWithMargin,this._positionWidth,s,i):C._package.logger.warning(`Bio: WebLogoViewer<${this.viewerId}>.render.calculateLayoutInt() this.positions.length = ${this.positions.length}, jPos = ${n}`);C._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.render.calculateLayoutInt(), end `),this._onLayoutCalculated.next()})(i,r,window.devicePixelRatio,s);const l=this.canvas.getContext("2d");if(l){l.save();try{this.Length,l.resetTransform(),l.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),l.fillRect(0,0,this.canvas.width,this.canvas.height),l.textBaseline=this.textBaseline;const t=10*e;l.resetTransform(),l.fillStyle="black",l.textAlign="center",l.font=`${t.toFixed(1)}px Roboto, Roboto Local, sans-serif`,s>0&&this.positions.length>0&&function(t,e,s,n,i,o,r,a){t.save();try{t.textAlign="center";let l=null,c=null;for(let e=Math.floor(r);e<=Math.floor(a);e++){const s=o[e],n=t.measureText(s.name),i=n.actualBoundingBoxDescent-n.actualBoundingBoxAscent;l=null===l?n.width:Math.max(l,n.width),c=null===c?i:Math.max(c,i)}const h=l<n*e-2?1:(n*e-2)/l;for(let l=Math.floor(r);l<=Math.floor(a);l++){const a=o[l],u=(l-r)*s*e+n*e/2,m=(i*e-c)/2;t.setTransform(h,0,0,1,u,m),t.measureText(a.label),t.fillText(a.label,0,0)}}finally{t.restore()}}(l,e,this._positionWidthWithMargin,this._positionWidth,s,this.positions,this.slider.min,this.slider.max);const n="16px Roboto, Roboto Local, sans-serif",a=.25,c=12.2;for(let t=i;t<=r;t++)this.positions[t].render(l,(t=>this.unitsHandler.isGap(t)),n,a,c,this.palette)}finally{l.restore()}C._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.render.renderInt( recalcLevel=${t} ), end`)}}renderRequestOnDebounce(t){this.requestedRenderLevel=S.None,this.renderInt(t).catch((t=>{const[e,s]=(0,d.yf)(t);C._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};C._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.sliderOnValuesChanged( ${JSON.stringify(t)} ), start`),this.render(S.Layout,"sliderOnValuesChanged")}catch(t){const e=m(t);C._package.logger.error(`Bio: WebLogoViewer<${this.viewerId}>.sliderOnValuesChanged() error:\n`+e)}}dataFrameFilterOnChanged(t){C._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.dataFrameFilterChanged()`);try{this.updatePositions(),this.filterSource===u.Ct.Filtered&&this.render(S.Freqs,"dataFrameFilterOnChanged")}catch(t){const e=m(t);C._package.logger.error(`Bio: WebLogoViewer<${this.viewerId}>.dataFrameFilterOnChanged() error:\n`+e)}}dataFrameSelectionOnChanged(t){C._package.logger.debug(`Bio: WebLogoViewer<${this.viewerId}>.dataFrameSelectionOnChanged()`);try{this.filterSource===u.Ct.Selected&&this.render(S.Freqs,"dataFrameSelectionOnChanged")}catch(t){const e=m(t);C._package.logger.error(`Bio: WebLogoViewer<${this.viewerId}>.dataFrameSelectionOnChanged() error:\n`+e)}}canvasOnMouseMove(t){const e=window.devicePixelRatio;try{const s=t,n=this.canvas.getCursorPosition(s,e),[r,a]=this.getMonomer(n,e),l=this.showPositionLabels?12*e:0;if(null!==r&&null===a&&0<=n.y&&n.y<=l){const t=[i.divText(`Position ${r.label}`)];this.valueAggrType===o.AGG.TOTAL_COUNT&&t.push(r.buildCompositionTable(this.palette));const e=i.divV(t);i.tooltip.show(e,s.x+16,s.y+16)}else if(null!==r&&a&&this.dataFrame&&this.seqCol&&this.unitsHandler){const t=r.getFreq(a),e=[i.div(`${a}`),i.div(`${t.rowCount} rows`)];this.valueAggrType!==o.AGG.TOTAL_COUNT&&e.push(i.div(`${this.valueAggrType}: ${t.value.toFixed(3)}`));const n=i.divV(e);i.tooltip.show(n,s.x+16,s.y+16)}else i.tooltip.hide()}catch(t){const e=m(t);C._package.logger.error(`Bio: WebLogoViewer<${this.viewerId}>.canvasOnMouseMove() error:\n`+e)}}canvasOnMouseDown(t){try{const e=t,s=window.devicePixelRatio,[n,i]=this.getMonomer(this.canvas.getCursorPosition(e,s),s);if(null!==n&&null!==i&&this.dataFrame&&this.seqCol&&this.unitsHandler){const t=o.BitSet.create(this.dataFrame.selection.length,(t=>function(t,e,s,n,i,o){const r=e.splitted[n],a=o.pos<r.length?r[o.pos]:null;return a===i||""===a&&i===e.defaultGapSymbol}(this.dataFrame,this.unitsHandler,this.getFilter(),t,i,n)));this.dataFrame.selection.init((e=>t.get(e)))}}catch(t){const e=m(t);C._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),n=t.deltaY/100*Math.max(Math.floor(s/5),1);this.slider.scrollBy(this.slider.min+n)}catch(t){const e=m(t);C._package.logger.error(`Bio: WebLogoViewer<${this.viewerId}>.canvasOnWheel() error:\n`+e)}}get onRendered(){return this._onRendered}invalidate(){const t=`${this.viewerToLog()}.invalidate()`;this.viewSyncer.sync(`${t}`,(async()=>{this.invalidate(),this._onRendered.next()}))}async awaitRendered(t=5e3){await(0,p.zg)(this.onRendered,(()=>{}),(()=>{this.invalidate()}),t)}}function M(t,e,s,n,i){let o=0,r=-1;for(;-1!=(r=s.findNext(r,!0));){const t=e.splitted[r],s=i.pos;(s<t.length?t[s]:null)===n&&o++}return o}E.residuesSet="nucleotides",E.viewerCounter=-1},4413:(t,e,s)=>{"use strict";s.d(e,{ST:()=>g});var n=s(3870),i=s(976),o=s(4469),r=s(6414),a=s.n(r),l=s(7983),c=s(701),h=s(4293),u=s(8447),m=s(8467);const d=rxjs.operators;var p=s(3377);class g extends i.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=n.loader(),this.notation=void 0,this.root=n.divV([]),this.calculating=!1}attach(t){super.attach(t),this.column=t.columns.bySemType(i.SEMTYPE.MACROMOLECULE),this.columnName??(this.columnName=this.column?.name),this.notation??(this.notation=this.column?.getTag(i.TAGS.UNITS)),this.bioFilter=this.notation===u.r2.FASTA?new y:this.notation===u.r2.SEPARATOR?new w(this.column.getTag("separator")):new C,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(p._package.logger.debug("Bio: BioSubstructureFilter._onInputChanged(), start"),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 f{constructor(){this.onChanged=new c.Subject}get filterPanel(){return new HTMLElement}get substructure(){return""}set substructure(t){}async substructureSearch(t){return null}}class y extends f{constructor(){super(),this.substructureInput=n.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 w extends y{constructor(t){super(),this.colSeparator="",this.separatorInput=n.stringInput("","",(()=>{this.onChanged.next()}),{placeholder:"Separator"}),this.colSeparator=t,this.separatorInput.value=t}get filterPanel(){return n.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 C extends f{constructor(){super(),this._filterPanel=n.div("",{style:{cursor:"pointer"}}),this.helmSubstructure="",this.init()}async init(){this.helmEditor=await o.functions.call("HELM:helmWebEditor"),await n.tools.waitForElementInDom(this._filterPanel),this.updateFilterPanel(),this._filterPanel.addEventListener("click",(t=>{const{editorDiv:e,webEditor:s}=this.helmEditor.createWebEditor(this.helmSubstructure);n.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})})),n.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,h.Y)(this._filterPanel,this.helmEditor.host),this.helmEditor.editor.setHelm(t),this.helmEditor.resizeEditor(e,s);else{const t=n.divText("Click to edit","helm-substructure-filter");(0,h.Y)(this._filterPanel,t)}}async substructureSearch(t){n.setUpdateIndicator(this._filterPanel,!0),await(0,m.gw)(10);const e=await(0,l.QF)(this.substructure,t);return n.setUpdateIndicator(this._filterPanel,!1),e}resetFilter(){console.debug("Bio: HelmFilter.resetFilter()"),this.helmSubstructure="",this.updateFilterPanel(this.substructure)}}},8770:(t,e,s)=>{"use strict";s.d(e,{_:()=>M,t:()=>E});var n=s(3870),i=s(976),o=s(6414),r=s.n(o),a=s(8447),l=s(7331),c=s(3379),h=s.n(c),u=s(7795),m=s.n(u),d=s(569),p=s.n(d),g=s(3565),f=s.n(g),y=s(9216),w=s.n(y),C=s(4589),T=s.n(C),b=s(5362),A={};A.styleTagTransform=T(),A.setAttributes=f(),A.insert=p().bind(null,"head"),A.domAPI=m(),A.insertStyleElement=w(),h()(b.Z,A),b.Z&&b.Z.locals&&b.Z.locals;var S=s(499);function E(t){const e=n.div();e.classList.add("macromolecule-cell-comp-analysis-host");const s=t.cell.column.tags.alphabet;let o=l.UE.Color;switch(s){case"DNA":case"RNA":o=(0,a.py)("DNA");break;case"PT":o=(0,a.py)("PT")}const c={},h=S.Cn.getOrCreate(t.cell.column).getSplitter()(t.value);r()(h).filter((t=>!!t&&""!==t)).forEach((t=>{const e=c[t]||0;c[t]=e+1}));const u=M(o,c);return Array.from(u.rows).forEach((t=>{const e=t.getElementsByClassName("macromolecule-cell-comp-analysis-bar")[0].style.backgroundColor;t.cells[0].style.color=e})),e.appendChild(u),new i.Widget(e)}function M(t,e){let s=0,i=null;for(const t of Object.values(e))s+=t,i=null===i?t:Math.max(i,t);const o=i/s,r=Object.assign({},...Array.from(Object.entries(e)).sort(((t,e)=>e[1]-t[1])).map((([e,i])=>{const r=i/s,a=t.get(e),l=n.div("",{classes:"macromolecule-cell-comp-analysis-bar"});l.style.width=50*r/o+"px",l.style.backgroundColor=a;const c=n.div(`${(100*r).toFixed(2)}%`);return{[e]:n.div([l,c],{classes:"macromolecule-cell-comp-analysis-value"})}}))),a=n.tableFromMap(r);return Array.from(a.rows).forEach((t=>{const e=t.getElementsByClassName("macromolecule-cell-comp-analysis-bar")[0].style.backgroundColor;t.cells[0].style.color=e})),a}},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(n){var i=e[n];if(void 0!==i)return i.exports;var o=e[n]={id:n,exports:{}};return t[n].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 n in e)s.o(e,n)&&!s.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},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 n=e.getElementsByTagName("script");if(n.length)for(var i=n.length-1;i>-1&&!t;)t=n[i--].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 n=s(6423);bio=n})();
3
3
  //# sourceMappingURL=package.js.map