@datagrok/bio 2.4.25 → 2.4.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- var bio_test;(()=>{var t={2012:(t,e,n)=>{"use strict";n.d(e,{f:()=>o});var i=n(9976);class o extends i.B{static get Lesk(){return void 0===this.lesk&&(this.lesk=this.makePalette([[["G","A","S","T"],"orange"],[["C","V","I","L","P","F","Y","M","W"],"all_green"],[["N","Q","H"],"magenta"],[["D","E"],"red"],[["K","R"],"all_blue"]],!1,o)),this.lesk}static get GrokGroups(){return void 0===this.grokGroups&&(this.grokGroups=this.makePalette([[["C","U"],"yellow"],[["G","P"],"red"],[["A","V","I","L","M","F","Y","W"],"all_green"],[["R","H","K"],"light_blue"],[["D","E"],"dark_blue"],[["S","T","N","Q"],"orange"]],!1,o)),this.grokGroups}static get RasMol(){return void 0===this.rasMol&&(this.rasMol=new o({D:"#E60A0A",E:"#E60A0A",C:"#E6E600",M:"#E6E600",K:"#145AFF",R:"#145AFF",S:"#FA9600",T:"#FA9600",F:"#3232AA",Y:"#3232AA",N:"#00DCDC",Q:"#00DCDC",G:"#EBEBEB",L:"#0F820F",V:"#0F820F",I:"#0F820F",A:"#C8C8C8",W:"#B45AB4",H:"#8282D2",P:"#DC9682",others:"#BEA06E"})),this.rasMol}get(t){const e=t in o.aaSynonyms?o.aaSynonyms[t]:t;return super.get(e)}}o.aaSynonyms={MeNle:"L",MeA:"A",MeG:"G",MeF:"F"};class s{static getPalette(t="grok"){switch(t){case"grok":return o.GrokGroups;case"lesk":return o.Lesk;default:throw new Error(`ChemPalette: scheme \`${t}\` does not exist`)}}static getInnerOuter(t){let e=0,n="",i="";for(const o of t)"("==o?e++:")"==o?e--:e?n+=o:i+=o;return isNaN(parseInt(n))?[i,n]:[i,""]}static getColorAAPivot(t="",e="grok"){var n,i,o;const s=this.getPalette(e);let[r,a]=this.getInnerOuter(t);if(r=r.length>6?`${r.slice(0,3)}...`:r,a=a.length>6?`${a.slice(0,3)}...`:a,1==t.length||"("==t[1]){const e=null===(n=t[0])||void 0===n?void 0:n.toUpperCase();return e in s?[s.get(e),e,a,1]:[this.undefinedColor,r,a,1]}if("d"==t[0]&&t[1]in s&&(2==t.length||"("==t[2])){const e=null===(i=t[1])||void 0===i?void 0:i.toUpperCase();return e in s?[s.get(e),e,a,2]:[this.undefinedColor,r,a,2]}if(t.substring(0,3)in this.AAFullNames&&(3==t.length||"("==t[3])){const e=this.AAFullNames[t.substring(0,3)];return e in s?[s.get(e),e,a,3]:[this.undefinedColor,r,a,3]}if((null===(o=t[0])||void 0===o?void 0:o.toLowerCase())==t[0]&&t.substring(1,3)in this.AAFullNames&&(4==t.length||"("==t[4])){const e=this.AAFullNames[t.substring(1,3)];return e in s?[s.get(e),e,a,4]:[this.undefinedColor,r,a,4]}return[this.undefinedColor,r,a,0]}}s.SemType="Aminoacids",s.SemTypeMultipleAlignment="AminoacidsMultipleAlignment",s.undefinedColor="rgb(100,100,100)",s.Names={G:"Glycine",L:"Leucine",Y:"Tyrosine",S:"Serine",E:"Glutamic acid",Q:"Glutamine",D:"Aspartic acid",N:"Asparagine",F:"Phenylalanine",A:"Alanine",K:"Lysine",R:"Arginine",H:"Histidine",C:"Cysteine",V:"Valine",P:"Proline",W:"Tryptophan",I:"Isoleucine",M:"Methionine",T:"Threonine"},s.AASmiles={G:"NCC(=O)O",L:"N[C@H](CC(C)C)C(=O)O",Y:"NC(CC1=CC=C(O)C=C1)C(=O)O",S:"NC(CO)C(=O)O",E:"N[C@@H](CCC(O)=O)C(=O)O",Q:"N[C@@H](CCC(N)=O)C(=O)O",D:"N[C@@H](CC(O)=O)C(=O)O",N:"N[C@@H](CC(N)=O)C(=O)O",F:"NC(CC1=CC=CC=C1)C(=O)O",A:"N[C@H](C)C(=O)O",K:"NC(CCCCN)C(=O)O",R:"N[C@H](CCCNC(=N)C)C(=O)O",H:"NC(CC1=CN=C[N]1)C(=O)O",C:"N[C@@H](CS)C(=O)O",V:"NC(C(C)C)C(=O)O",P:"N(CCC1)C1C(=O)O",W:"N[C@@H](Cc1c2ccccc2n([H])c1)C(=O)O",I:"N[C@H]([C@H](C)CC)C(=O)O",M:"NC(CCSC)C(=O)O",T:"NC(C(O)C)C(=O)O"},s.AASmilesTruncated={G:"*C*",L:"CC(C)C[C@H](*)*",Y:"C1=CC(=CC=C1CC(*)*)O",S:"OCC(*)C*",E:"*[C@@H](CCC(O)=O)*",Q:"*N[C@@H](CCC(N)=O)*",D:"*[C@@H](CC(O)=O)*",N:"*[C@@H](CC(N)=O)*",F:"C1=CC=C(C=C1)CC(*)*",A:"C[C@H](*)*",K:"C(CCN)CC(*)*",R:"*[C@H](CCCNC(=N)C)*",H:"C1=C(NC=N1)CC(*)*",C:"C([C@@H](*)*)S",V:"CC(C)C(*)*",P:"C1CCN(*)C1*",W:"*[C@@H](Cc1c2ccccc2n([H])c1)*",I:"CC[C@H](C)[C@H](*)*",M:"CSCCC(*)*",T:"CC(O)C(*)*"},s.AAFullNames={Ala:"A",Arg:"R",Asn:"N",Asp:"D",Cys:"C",Gln:"Q",Glu:"E",Gly:"G",His:"H",Ile:"I",Leu:"L",Lys:"K",Met:"M",Phe:"F",Pro:"P",Ser:"S",Thr:"T",Trp:"W",Tyr:"Y",Val:"V"}},7228:(t,e,n)=>{"use strict";n.d(e,{DC:()=>r,JN:()=>l,Xk:()=>a});var i=n(976),o=(n(4469),n(1047)),s=(n(585),function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))});const r=["symbol","name","molfile","rgroups","polymerType","monomerType"];function a(t){const e=[];for(let n=0;n<t.rowCount;n++){const i={};Object.keys(o.K4).forEach((e=>{if("symbol"===e){const s=t.get(o.K4[e],n);i[e]="."===s?t.get(o.At,n):s}else if("rgroups"===e){const s=t.get(o.K4[e],n).split("\n"),r=[];s.forEach((t=>{const e={},n=t.substring(t.lastIndexOf("]")+1),i=t.match(/\[R(\d+)\]/)[1];e.capGroupSmiles="H"===n?`[*:${i}][H]`:`O[*:${i}]`,e.alternateId="H"===n?`R${i}-H`:`R${i}-OH`,e.capGroupName="H"===n?"H":"OH",e.label=`R${i}`,r.push(e)})),i[e]=r}else o.K4[e]&&(i[e]=t.get(o.K4[e],n))})),e.push(i)}return e}function l(){return s(this,void 0,void 0,(function*(){const t=i.Func.find({package:"Bio",name:"getMonomerLibHelper"});if(0===t.length)throw new Error('Package "Bio" must be installer for MonomerLibraryHelper.');return(yield t[0].prepare().call()).getOutputParamValue()}))}},6103:(t,e,n)=>{"use strict";n.d(e,{i0:()=>D});var i=n(4469),o=n(976),s=n(1047),r=n(585),a=n(7767),l=n(7604),c=n(499),h=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};const u=8,d="M RGP",f="A ",m=14,p=7,g="\nDatagrok macromolecule handler\n\n",v=" 0 0 0 0 0 0 999 V3000\n",y="M V30 BEGIN CTAB\n",b="M V30 END CTAB\n",w="M V30 COUNTS ",S=" 0 0 0\n",C="M V30 BEGIN ATOM\n",T="M V30 END ATOM\n",M="M V30 BEGIN BOND\n",E="M V30 END BOND\n",A=" CFG=",N="M V30 ",P="M END",x=1e4,_="d",R="r",L="p",I="O",G="H";function D(t,e,n){return h(this,void 0,void 0,(function*(){if(0===o.Func.find({package:"Chem",name:"getRdKitModule"}).length)return{col:null,warnings:['Transformation to atomic level requires the package "Chem" installed.']};if(e.semType!==o.SEMTYPE.MACROMOLECULE)return{col:null,warnings:[`Only the ${o.SEMTYPE.MACROMOLECULE} columns can be converted to atomic level, the chosen column has semType '${e.semType}'`]};let u=e;new c.C(e).isHelm()&&(u=new a.L(e).convert("separator","."),u.name=e.name);const d=new c.C(u).alphabet;let f;if("PT"===d||"UN"===d)f="PEPTIDE";else{if("RNA"!==d&&"DNA"!==d)return{col:null,warnings:[`Unexpected column's '${u.name}' alphabet '${d}'.`]};f="RNA"}const m=function(t){const e=t.length,n=new Array(e),i=t.getTag(o.TAGS.UNITS),s=t.getTag("separator"),a=(0,r.vU)(i,s);for(let i=0;i<e;++i){const e=t.get(i);n[i]=e?a(e).filter((t=>""!==t)):[]}return n}(u),p=yield function(t,e,n,o){return h(this,void 0,void 0,(function*(){const r=function(t,e,n){const i=new Map;for(const o of t.getTypes())for(const r of t.getMonomerNamesByType(o)){const a=t.getMonomer(o,r);if(a.polymerType===e&&("RNA"===e&&("Branch"===a.monomerType||"DNA"===n&&a.symbol===_||"RNA"===n&&a.symbol===R||a.symbol===L)||"PEPTIDE"===e&&"Branch"!==a.monomerType)){const t={};s.rx.forEach((e=>{t[e]=a[e]})),i.set(a.symbol,t)}}return i}(e,n,o),a=new Map,c=yield i.functions.call("Chem:getRdKitModule"),h={value:null};if("RNA"===n){const t="RNA"===o?[R,L]:[_,L];for(const e of t)W(a,e,r,c,n,h)}for(let e=0;e<t.length;++e){const i=t[e];for(const t of i)if(""!==t)try{W(a,t,r,c,n,h)}catch(e){const n=(0,l.O)(e);throw console.error(`bio lib: getMonomersDictFromLib() sym='${t}', error:\n`+n),new Error(`Сan't get monomer '${t}' from library: ${n}`)}}return a}))}(m,n,f,d),g=u.length,v=new Array(g),y=new Array(0);for(let t=0;t<g;++t)try{const e=m[t];v[t]=Z(e,p,d,f,0)}catch(e){const n=`Cannot get molfile of row #${t}: ${e instanceof Error?e.message:e.toString()}.`;y.push(n)}if(y.length>.05*g)throw new Error("Too many errors getting molfiles.");const b=`molfile(${u.name})`,w=t.columns.getUnusedName(b),S=o.Column.fromStrings(w,v);return S.semType=o.SEMTYPE.MOLECULE,S.setTag(o.TAGS.UNITS,o.UNITS.Molecule.MOLBLOCK),{col:S,warnings:y}}))}function W(t,e,n,i,o,s){if(!t.has(e)){const r=function(t,e,n,i,o){if(e.has(t)){const s=e.get(t),r=function(t){const e=[];for(const n of t){let t=n.capGroupSmiles;t||(t=n.capGroupSMILES),t=t.replace(/(\[|\]|\*|:|\d)/g,""),e.push(t)}return e}(s.rgroups),a=function(t){const e=new Map;let n=t.indexOf(f,0),i=n;for(;-1!==n;){i=t.indexOf("\n",n);const o=parseInt(t.substring(n,i).replace(/^A\s+/,""));n=t.indexOf("R",i),i=t.indexOf("\n",n);const s=parseInt(t.substring(n,i).replace(/^R/,""));e.set(o,s),n=t.indexOf(f,i)}for(n=t.indexOf(d,0),i=t.indexOf("\n",n);-1!==n;){n+=u,i=t.indexOf("\n",n);const o=t.substring(n,i).replaceAll(/\s+/g," ").split(" ").map((t=>parseInt(t))).slice(1);for(let t=0;t<o.length;t+=2){if(e.has(o[t])&&e.get(o[t])!==o[t+1])throw new Error(`r-group index ${o[t]} has already been added with a different value`);e.set(o[t],o[t+1])}n=t.indexOf(d,i)}return e}(s.molfile),l=function(t,e){const n=e.get_mol(t),i=n.get_v3Kmolblock();return n.delete(),i}(function(t){let e=t.indexOf(f,0);-1===e&&(e=t.indexOf(d));const n=t.indexOf(P,e);return t.substring(0,e)+t.substring(n)}(s.molfile),n),c=function(t){let e=(t=t.replaceAll("\r","")).indexOf(w)+m,n=t.indexOf(" ",e+1);const i=parseInt(t.substring(e,n));return e=n+1,n=t.indexOf(" ",e+1),{atomCount:i,bondCount:parseInt(t.substring(e,n))}}(l),h=function(t,e){const n=new Array(e),i=new Float32Array(e),o=new Float32Array(e),s=new Array(e);let r=t.indexOf(C);r=t.indexOf("\n",r);let a=r;for(let l=0;l<e;l++){r=t.indexOf(N,r)+p,a=t.indexOf(" ",r),r=a+1,a=t.indexOf(" ",r),n[l]=t.substring(r,a);const e=new Array(2);for(let n=0;n<2;++n)r=a+1,a=t.indexOf(" ",r),e[n]=parseFloat(t.substring(r,a));i[l]=e[0],o[l]=e[1],r=a,a=t.indexOf("\n",r)+1,s[l]=t.slice(r,a),r=a}return{atomTypes:n,x:i,y:o,kwargs:s}}(l,c.atomCount),g=function(t,e){const n=new Uint32Array(e),i=new Array(e),o=new Map,s=new Map;let r=t.indexOf(M);r=t.indexOf("\n",r);let a=r;for(let l=0;l<e;++l){const e=new Array(3);r=t.indexOf(N,a)+p,a=t.indexOf(" ",r);for(let n=0;n<3;++n)r=a+1,a=Math.min(t.indexOf("\n",r),t.indexOf(" ",r)),e[n]=parseInt(t.slice(r,a));n[l]=e[0],i[l]=e.slice(1);const c=t.indexOf("\n",r);let h=t.slice(a,c),u=h.indexOf(A);if(-1!==u){u=h.indexOf("=",u)+1;let t=h.indexOf(" ",u);-1===t&&(t=h.length);const e=parseInt(h.slice(u,t));o.set(l,e);const n=A+e.toString();h=h.replace(n,"")}h||s.set(l,h)}return{bondTypes:n,atomPairs:i,bondConfiguration:o,kwargs:s}}(l,c.bondCount),v={atoms:h,bonds:g,meta:F(h,g,r,a)};return"PEPTIDE"===i?function(t){const e=t.meta.terminalNodes[0]-1,n=t.meta.rNodes[0]-1,i=t.atoms.x,o=t.atoms.y;$(t,-i[e],-o[e]);const s=B(i[n],o[n]);Y(t.atoms,-s),i[t.meta.rNodes[1]-1]<0&&function(t){K(t,!1)}(t);const r=function(t){const e=function(t){var e;const n=new Map;for(const i of t.bonds.atomPairs)for(let t=0;t<2;t++){const o=i[t],s=i[(t+1)%2];n.has(o)?null===(e=n.get(o))||void 0===e||e.push(s):n.set(o,new Array(1).fill(s))}return n}(t);let n=0,i=0;for(;0===n;){const o=e.get(t.meta.terminalNodes[1])[i];t.atoms.atomTypes[o-1]===I&&o!==t.meta.rNodes[1]&&(n=o),i++}return n}(t);!function(t,e){t.atoms.y[t.meta.rNodes[1]-1]<0&&t.atoms.y[e-1]<0&&(function(t){K(t,!0)}(t),Y(t.atoms,-function(t,e){return B(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 n=t.atoms.x;n[t.meta.rNodes[1]-1]>n[e-1]&&function(t,e,n){const i=e-1,o=n-1,s=t.atoms.x,r=t.atoms.y,a=s[i],l=r[i];s[i]=s[o],r[i]=r[o],s[o]=a,r[o]=l}(t,e,t.meta.rNodes[1])}(t,r)}(v):t===R||t===_?function(t,e){const n=t.atoms.x,i=t.atoms.y;let o=t.meta.terminalNodes[0]-1;const s=t.meta.rNodes[1]-1;$(t,-n[o],-i[o]);const r=B(n[s],i[s]);Y(t.atoms,3*Math.PI/2-r),e.value=function(t){const e=t.atoms.x,n=t.atoms.y,i=t.meta.rNodes[2]-1,o=t.meta.terminalNodes[2]-1,s=e[i]-e[o],r=n[i]-n[o];return Math.atan(r/s)+Math.PI/2}(t),o=t.meta.terminalNodes[0]-1,$(t,-n[o],-i[o])}(v,o):t===L?function(t){const e=t.meta.terminalNodes[0]-1,n=t.meta.rNodes[0]-1,i=t.atoms.x,o=t.atoms.y;$(t,-i[e],-o[e]);const s=B(i[n],o[n]);Y(t.atoms,Math.PI/2-s)}(v):function(t,e){const n=t.atoms.x,i=t.atoms.y,o=t.meta.terminalNodes[0]-1,s=t.meta.rNodes[0]-1;$(t,-n[o],-i[o]);const r=B(n[s],i[s]),a=e.value;if(!a)throw new Error("The value of sugarBranchToOYAngle is null");Y(t.atoms,Math.PI-r+a);const l=function(t,e){return et(Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)))}({x:n[t.meta.rNodes[0]-1],y:i[t.meta.rNodes[0]-1]},{x:n[t.meta.terminalNodes[0]-1],y:i[t.meta.terminalNodes[0]-1]});if(1!=l)for(let t=0;t<n.length;++t)n[t]=et(n[t]/l),i[t]=et(i[t]/l)}(v,o),function(t,e,n){"PEPTIDE"===t?(k(e,t),V(e,e.meta.rNodes[1])):n===R||n===_?(V(e,e.meta.rNodes[1]),e.meta.rNodes[1]=e.meta.terminalNodes[1],H(e.bonds,e.meta),k(e,t),V(e,e.meta.rNodes[1]),V(e,e.meta.rNodes[0]),V(e,e.meta.rNodes[2])):n===L&&(e.meta.terminalNodes[0]=e.meta.rNodes[0],$(e,-e.atoms.x[e.meta.terminalNodes[0]-1],-e.atoms.y[e.meta.terminalNodes[0]-1]),k(e,t),V(e,e.meta.rNodes[1]))}(i,v,t),function(t){let e=0;for(;e<t.atoms.atomTypes.length;)t.atoms.atomTypes[e]===G&&(V(t,e+1),--e),++e}(v),v}return null}(e,n,i,o,s);if(!r)throw new Error(`Monomer with symbol '${e}' is absent the monomer library`);t.set(e,r)}}function F(t,e,n,i){const o={backboneShift:null,branchShift:null,terminalNodes:[],rNodes:[]};return void 0!==n&&void 0!==i?(function(t,e,n){for(const[i,o]of n)t.atomTypes[i-1]=e[o-1]}(t,n,i),function(t,e){e.rNodes=Array.from(t.keys());for(let n=0;n<e.rNodes.length;n++)for(const i of[1,2])if(t.get(e.rNodes[n])===i){const t=e.rNodes[i-1];e.rNodes[i-1]=e.rNodes[n],e.rNodes[n]=t}}(i,o)):o.rNodes=[0,t.x.length],H(e,o),o}function H(t,e){const n=e.rNodes;e.terminalNodes=new Array(n.length).fill(0);const i=e.terminalNodes,o=t.atomPairs;let s=0,r=0;for(;s<o.length&&r<i.length;){for(let t=0;t<i.length;++t)for(let e=0;e<2;++e)o[s][e]===n[t]&&(i[t]=o[s][(e+1)%2],n.length,++r);++s}}function k(t,e){t.meta.rNodes.length>1&&(t.meta.backboneShift=O(t,t.meta.rNodes[1]-1,t.meta.terminalNodes[0]-1)),"RNA"===e&&t.meta.rNodes.length>2&&(t.meta.branchShift=O(t,t.meta.rNodes[2]-1,t.meta.terminalNodes[0]-1))}function O(t,e,n){return[et(t.atoms.x[e]-t.atoms.x[n]),et(t.atoms.y[e]-t.atoms.y[n])]}function V(t,e){if(void 0!==e){const n=e-1,i=t.atoms,o=t.bonds,s=t.meta;i.atomTypes.splice(n,1),i.x=U(Float32Array,i.x,n,1),i.y=U(Float32Array,i.y,n,1),i.kwargs.splice(n,1);for(let t=0;t<s.terminalNodes.length;++t)s.terminalNodes[t]>e?--s.terminalNodes[t]:s.terminalNodes[t]===e&&(s.terminalNodes[t]=-1);for(let t=0;t<s.rNodes.length;++t)s.rNodes[t]>e?--s.rNodes[t]:s.rNodes[t]===e&&(s.rNodes[t]=-1);let r=0;for(;r<o.atomPairs.length;){const t=o.atomPairs[r][0],n=o.atomPairs[r][1];t===e||n===e?(o.atomPairs.splice(r,1),o.bondTypes=U(Uint32Array,o.bondTypes,r,1),o.bondConfiguration.has(r)&&o.bondConfiguration.delete(r),o.kwargs.has(r)&&o.kwargs.delete(r),--r):(o.atomPairs[r][0]=t>e?t-1:t,o.atomPairs[r][1]=n>e?n-1:n),++r}let a=Array.from(o.bondConfiguration.keys());a.forEach((t=>{if(o.bondConfiguration.has(t)&&t>n){const e=o.bondConfiguration.get(t);o.bondConfiguration.delete(t),o.bondConfiguration.set(t-1,e)}})),a=Array.from(o.kwargs.keys()),a.forEach((t=>{if(o.kwargs.has(t)&&t>n){const e=o.kwargs.get(t);o.kwargs.delete(t),o.kwargs.set(t-1,e)}}))}}function U(t,e,n,i){const o=new t(e.length-i);let s=0,r=0;for(;s<e.length;)s===n&&(s+=i),o[r]=e[s],++r,++s;return o}function B(t,e){let n;if(0===t)n=e>0?0:Math.PI;else if(0===e)n=t>0?-Math.PI/2:Math.PI/2;else{const i=e/t,o=Math.atan(i);n=t<0?Math.PI/2+o:-Math.PI/2+o}return n}function Y(t,e){if(0!==e){const n=t.x,i=t.y,o=Math.cos(e),s=Math.sin(e);for(let t=0;t<n.length;++t){const e=n[t];n[t]=et(e*o-i[t]*s),i[t]=et(e*s+i[t]*o)}}}function K(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 n=t.bonds.bondConfiguration;for(const[t,e]of n){const i=1===e?3:1;n.set(t,i)}}function $(t,e,n){const i=t.atoms.x,o=t.atoms.y;for(let t=0;t<i.length;++t)i[t]=et(i[t]+e),void 0!==n&&(o[t]=et(o[t]+n))}function Z(t,e,n,i,o){if(0===t.length)return"";const s=0===o?tt:nt,{atomCount:r,bondCount:a}=s(t,e,n,i,o),l=new Array(r),c=new Array(a);let h,u=null,d=null;0===o?"PEPTIDE"===i?h=q:(h=j,u="DNA"===n?e.get(_):e.get(R),d=e.get(L)):h=z;const f={i:0,nodeShift:0,bondShift:0,backbonePositionShift:new Array(2).fill(0),branchPositionShift:new Array(2).fill(0),backboneAttachNode:0,branchAttachNode:0,flipFactor:1},m={sugar:u,phosphate:d,seqLength:t.length,atomCount:r,bondCount:a};for(f.i=0;f.i<m.seqLength;++f.i)h(e.get(t[f.i]),l,c,f,m);!function(t,e,n,i,o){if(0===o){const o=n.nodeShift+1;t[i.atomCount]=N+o+" "+I+" "+et(n.backbonePositionShift[0])+" "+n.flipFactor*et(n.backbonePositionShift[1])+" 0.000000 0\n";const s=n.backboneAttachNode,r=o;e[i.bondCount]=N+n.bondShift+" 1 "+s+" "+r+"\n"}}(l,c,f,m,o);let p="";return p+=g,p+=v,p+=y,p+=w+r+" "+a+S,p+=C,p+=l.join(""),p+=T,p+=M,p+=c.join(""),p+=E,p+=b,p+=P,p}function q(t,e,n,i){i.flipFactor=Math.pow(-1,i.i%2),X(t,e,n,i)}function z(t,e,n,i){Q(t,e,n,i)}function X(t,e,n,i){!function(t,e,n){for(let i=0;i<t.atoms.atomTypes.length;++i){const o=n.nodeShift+i+1;e[n.nodeShift+i]=N+o+" "+t.atoms.atomTypes[i]+" "+et(n.backbonePositionShift[0]+t.atoms.x[i])+" "+et(n.backbonePositionShift[1]+n.flipFactor*t.atoms.y[i])+" "+t.atoms.kwargs[i]}}(t,e,i),J(t,n,i),function(t,e,n){if(0!==n.backboneAttachNode){const i=n.bondShift,o=n.backboneAttachNode,s=t.meta.terminalNodes[0]+n.nodeShift;e[n.bondShift-1]=N+i+" 1 "+o+" "+s+"\n"}}(t,n,i),null!==t.meta.branchShift&&t.meta.terminalNodes.length>2&&function(t,e){e.branchAttachNode=e.nodeShift+t.meta.terminalNodes[2];for(let n=0;n<2;++n)e.branchPositionShift[n]=e.backbonePositionShift[n]+t.meta.branchShift[n]}(t,i),function(t,e){e.backboneAttachNode=e.nodeShift+t.meta.terminalNodes[1],e.bondShift+=t.bonds.atomPairs.length+1,e.nodeShift+=t.atoms.atomTypes.length,e.backbonePositionShift[0]+=t.meta.backboneShift[0],e.backbonePositionShift[1]+=e.flipFactor*t.meta.backboneShift[1]}(t,i)}function j(t,e,n,i,o){if(0===i.i)X(o.sugar,e,n,i);else for(const t of[o.phosphate,o.sugar])X(t,e,n,i);Q(t,e,n,i)}function Q(t,e,n,i){!function(t,e,n){for(let i=0;i<t.atoms.atomTypes.length;++i){const o=n.nodeShift+i+1;e[n.nodeShift+i]=N+o+" "+t.atoms.atomTypes[i]+" "+et(n.branchPositionShift[0]+t.atoms.x[i])+" "+et(n.branchPositionShift[1]+n.flipFactor*t.atoms.y[i])+" "+t.atoms.kwargs[i]}}(t,e,i),J(t,n,i),function(t,e,n){const i=n.bondShift,o=n.branchAttachNode,s=t.meta.terminalNodes[0]+n.nodeShift;e[i-1]=N+i+" 1 "+o+" "+s+"\n"}(t,n,i);const o=i.bondShift,s=i.branchAttachNode,r=t.meta.terminalNodes[0]+i.nodeShift;n[o-1]=N+o+" 1 "+s+" "+r+"\n",i.bondShift+=t.bonds.atomPairs.length+1,i.nodeShift+=t.atoms.atomTypes.length}function J(t,e,n){for(let i=0;i<t.bonds.atomPairs.length;++i){const o=n.bondShift+i+1,s=t.bonds.atomPairs[i][0]+n.nodeShift,r=t.bonds.atomPairs[i][1]+n.nodeShift;let a="";if(t.bonds.bondConfiguration.has(i)){let e=t.bonds.bondConfiguration.get(i);n.flipFactor<0&&(e=1===e?3:1),a=" CFG="+e}const l=t.bonds.kwargs.has(i)?" "+t.bonds.kwargs.get(i):"";e[n.bondShift+i]=N+o+" "+t.bonds.bondTypes[i]+" "+s+" "+r+a+l+"\n"}}function tt(t,e,n,i,o){let s=0,r=0;for(const n of t){if(""===n)continue;const t=e.get(n);s+=t.atoms.x.length,r+=t.bonds.bondTypes.length}if(0===o)if("PEPTIDE"===i)s+=1,r+=t.length;else{const i="DNA"===n?e.get(_):e.get(R),o=e.get(L);s+=(t.length-1)*o.atoms.x.length,s+=t.length*i.atoms.x.length,s+=1,r+=(t.length-1)*o.bonds.bondTypes.length,r+=t.length*i.bonds.bondTypes.length,r-=1,r+=3*t.length}return{atomCount:s,bondCount:r}}function et(t){return Math.round(x*t)/x}function nt(t,e,n,i){let o=0,s=0;for(const n of t){const t=e.get(n);o+=t.atoms.x.length,s+=t.bonds.bondTypes.length}if("PEPTIDE"===i)o+=1,s+=t.length;else{const i="DNA"===n?e.get(_):e.get(R),r=e.get(L);o+=t.length*(r.atoms.x.length+i.atoms.x.length),o+=1,s+=t.length*(r.bonds.bondTypes.length+i.bonds.bondTypes.length),s+=3*t.length}return{atomCount:o,bondCount:s}}},6137:(t,e,n)=>{"use strict";n.d(e,{J:()=>o,V:()=>s});var i=n(9976);class o extends i.B{static get Chromatogram(){return void 0===this.chromatogram&&(this.chromatogram=new o({A:"green",C:"blue",G:"black",T:"red",U:"red",others:"gray"})),this.chromatogram}}class s{}s.SemType="Nucleotides",s.SemTypeMultipleAlignment="NucleotidesMultipleAlignment",s.Names={A:"Adenine",C:"Cytosine",G:"Guanine",T:"Thymine",U:"Uracil"}},9976:(t,e,n)=>{"use strict";n.d(e,{B:()=>i});class i{static makePalette(t,e=!1,n=i){const o={};return t.forEach((t=>{const n=t[0],i=t[1];n.forEach(((t,n)=>{o[t]=this.colourPalette[i][e?0:n]}))})),new n(o)}constructor(t){this._palette=t}get(t){return this._palette[t]}}i.undefinedColor="rgb(100,100,100)",i.colourPalette={orange:["rgb(255,187,120)","rgb(245,167,100)","rgb(235,137,70)","rgb(205, 111, 71)"],all_green:["rgb(44,160,44)","rgb(74,160,74)","rgb(23,103,57)","rgb(30,110,96)","rgb(60,131,95)","rgb(24,110,79)","rgb(152,223,138)","rgb(182, 223, 138)","rgb(152, 193, 138)"],all_blue:["rgb(31,119,180)","rgb(23,190,207)","rgb(122, 102, 189)","rgb(158,218,229)","rgb(141, 124, 217)","rgb(31, 120, 150)"],magenta:["rgb(162,106,192)","rgb(197,165,224)","rgb(208,113,218)"],red:["rgb(214,39,40)","rgb(255,152,150)"],st_blue:["rgb(23,190,207)","rgb(158,218,229)","rgb(31,119,180)"],dark_blue:["rgb(31,119,180)","rgb(31, 120, 150)"],light_blue:["rgb(23,190,207)","rgb(158,218,229)","rgb(108, 218, 229)","rgb(23,190,227)"],lilac_blue:["rgb(124,102,211)","rgb(149,134,217)","rgb(97, 81, 150)"],dark_green:["rgb(23,103,57)","rgb(30,110,96)","rgb(60,131,95)","rgb(24,110,79)"],green:["rgb(44,160,44)","rgb(74,160,74)"],light_green:["rgb(152,223,138)","rgb(182, 223, 138)","rgb(152, 193, 138)"],st_green:["rgb(44,160,44)","rgb(152,223,138)","rgb(39, 174, 96)","rgb(74,160,74)"],pink:["rgb(247,182,210)"],brown:["rgb(140,86,75)","rgb(102, 62, 54)"],gray:["rgb(127,127,127)","rgb(199,199,199)","rgb(196,156,148)","rgb(222, 222, 180)"],yellow:["rgb(188,189,34)"],white:["rgb(230,230,230)"]}},7331:(t,e,n)=>{"use strict";n.d(e,{UE:()=>c,kQ:()=>r});var i=n(976),o=n(9976);class s{static hashCode(t){let e=0;if(0===t.length)return e;for(let n=0;n<t.length;n++)e=(e<<5)-e+t.charCodeAt(n),e|=0;return e}}class r{}class a extends r{get(t){return"#666666"}}class l extends r{static buildPalette(){return[].concat(...Object.values(o.B.colourPalette))}get(t){const e=s.hashCode(t)%l.palette.length;return function(t){if(null==t)return"rgb(100,100,100)";const e=i.Color.fromHtml(t),n=i.Color.g(e),o=i.Color.r(e),s=i.Color.b(e),r=Math.sqrt(Math.pow(0-o,2)+Math.pow(0-n,2)+Math.pow(0-s,2));return r>210?`rgb(${o/r*210},${n/r*210},${s/r*210})`:i.Color.toRgb(e)}(l.palette[e])}}l.palette=l.buildPalette();class c extends o.B{static get Gray(){return void 0===this.gray&&(this.gray=new a),this.gray}static get Color(){return void 0===this.color&&(this.color=new l),this.color}}},1047:(t,e,n)=>{"use strict";n.d(e,{At:()=>o,K4:()=>s,rx:()=>i});const i=["symbol","molfile","rgroups","name"],o="MonomerName",s={monomerType:null,smiles:null,name:"MonomerName",author:null,molfile:"molecule",naturalAnalog:"MonomerNaturalAnalogCode",rgroups:"MonomerCaps",createDate:null,id:null,polymerType:"MonomerType",symbol:"MonomerCode"}},5226:(t,e,n)=>{"use strict";n.d(e,{i:()=>s});var i=n(976),o=n(499);class s{get descriptionsArray(){return this._descriptionsArray}get sequencesArray(){return this._sequencesArray}parseMacromolecule(t,e){return this._fileContent.slice(t,e).split(/\s/).join("")}parseColumns(){const t=/^>(.*)$/gm;let e,n=0;for(;e=t.exec(this._fileContent);){const i=this._fileContent.substring(e.index+1,t.lastIndex);this._descriptionsArray.push(i),0!==n&&this._sequencesArray.push(this.parseMacromolecule(n,e.index)),n=t.lastIndex+1}this._sequencesArray.push(this.parseMacromolecule(n,-1))}importFasta(){const t=i.Column.fromStrings("description",this.descriptionsArray),e=i.Column.fromStrings("sequence",this.sequencesArray);return e.semType=i.SEMTYPE.MACROMOLECULE,e.setTag(i.TAGS.UNITS,"fasta"),o.C.setUnitsToFastaColumn(e),[i.DataFrame.fromColumns([t,e])]}constructor(t){this._descriptionsArray=[],this._sequencesArray=[],this._fileContent=t,this.parseColumns()}}},1821:(t,e,n)=>{"use strict";n.d(e,{BM:()=>o,XS:()=>r,se:()=>s});var i=n(6286);const o=/\[(\w+)\]|(\w)|(-)/g,s=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"])}}},r=[new i.L("PT",s.fasta.peptide,.5),new i.L("DNA",s.fasta.dna,.55),new i.L("RNA",s.fasta.rna,.55)]},8447:(t,e,n)=>{"use strict";n.d(e,{GU:()=>i.GU,KX:()=>i.KX,dQ:()=>i.dQ,fy:()=>i.fy,gM:()=>i.gM,gP:()=>i.gP,kB:()=>i.kB,py:()=>i.py,up:()=>i.up,vU:()=>i.vU});var i=n(585)},6286:(t,e,n)=>{"use strict";n.d(e,{L:()=>i,d:()=>o});class i{constructor(t,e,n){this.name=t,this.alphabet=e,this.cutoff=n}}class o extends i{constructor(t,e,n){super(t.name,t.alphabet,t.cutoff),this.freq=e,this.similarity=n}}},585:(t,e,n)=>{"use strict";n.d(e,{Ar:()=>g,GU:()=>T,KX:()=>E,Mj:()=>S,dQ:()=>N,fy:()=>m,gM:()=>M,gP:()=>b,kB:()=>p,py:()=>P,up:()=>x,vU:()=>w,w4:()=>A});var i=n(976),o=n(6414),s=n.n(o),r=n(6286),a=n(1821),l=n(499),c=n(3659),h=n(850),u=n(2012),d=n(6137),f=n(7331);function m(t,e,n){const i={};let o=!0,s=null;for(const r of t.categories){const t=n(r);if(null==s?s=t.length:t.length!==s&&(o=!1),t.length>=e)for(const e of t)e in i||(i[e]=0),i[e]+=1}return{freq:i,sameLength:o}}function p(t){return s()(t.toString().matchAll(a.BM)).map((t=>{const e=t[0];return e.length>1?t[1]:e})).toArray()}function g(t,e=undefined){return n=>n.split(t,e)}const v=/(PEPTIDE1|DNA1|RNA1)\{([^}]+)}/g,y=/\[([^\[\]]+)]/g;function b(t){v.lastIndex=0;const e=v.exec(t.toString()),n=e?e[2]:null;return(n?n.split("."):[]).map((t=>{y.lastIndex=0;const e=y.exec(t);return e&&e.length>=2?e[1]:t}))}function w(t,e,n=undefined){if(t.toLowerCase().startsWith("fasta"))return p;if(t.toLowerCase().startsWith("separator"))return g(e,n);if(t.toLowerCase().startsWith("helm"))return b;throw new Error(`Unexpected units ${t} .`)}function S(t){if(t.semType!==i.SEMTYPE.MACROMOLECULE)throw new Error(`Get splitter for semType "${i.SEMTYPE.MACROMOLECULE}" only.`);return w(t.getTag(i.TAGS.UNITS),t.getTag("separator"))}const C=/(\w+)/g;function T(t,e){var n,i;const o=t.match(C),s=t.length>e||(null!==(n=null==o?void 0:o.length)&&void 0!==n?n:0)>1,r=null!==(i=null==o?void 0:o[0])&&void 0!==i?i:" ";return s?r.substring(0,e)+"…":r}function 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 E(t,e,n="-"){const i=new Set([...new Set(Object.keys(t)),...e]);i.delete(n);const o=[],s=[];for(const n of i)o.push(n in t?t[n]:0),s.push(e.has(n)?1:0);const r=new c.OW(o),a=new c.OW(s);return(0,h.MA)(r,a)/((0,h.$G)(r)*(0,h.$G)(a))}function A(t,e,n="-"){const i=e.map((e=>{const i=E(t,e.alphabet,n);return new r.d(e,t,i)}));let o;const s=Math.max(...i.map((t=>t.similarity>t.cutoff?t.similarity:-1)));return o=s>0?i.find((t=>t.similarity===s)).name:"UN",o}function N(t,e=5){let n;return n=t.semType==i.SEMTYPE.MACROMOLECULE?new l.C(t).alphabet:A(m(t,e,p).freq,a.XS),P(n)}function P(t){switch(t){case"PT":return u.f.GrokGroups;case"DNA":case"RNA":return d.J.Chromatogram;default:return f.UE.Color}}function x(t){var e;const n=t.columns.bySemTypeAll(i.SEMTYPE.MACROMOLECULE);let o=null!==(e=n.find((t=>{const e=t.getTag(i.TAGS.UNITS);return!!e&&-1!==e.indexOf("MSA")})))&&void 0!==e?e:null;return!o&&n.length>0&&(o=n[0]),o}},7767:(t,e,n)=>{"use strict";n.d(e,{L:()=>r});var i=n(976),o=n(499),s=n(585);class r extends o.C{get splitter(){return null===this._splitter&&(this._splitter=(0,s.Mj)(this.column)),this._splitter}toFasta(t){return"fasta"===t}toSeparator(t){return"separator"===t}toHelm(t){return"helm"===t}convertFastaToSeparator(t,e=null){null===e&&(e=this.defaultGapSymbol);const n=this.getNewColumn("separator",t);return n.init((n=>{const i=this.column.get(n),s=this.splitter(i);for(let t=0;t<s.length;t++)s[t]===e&&(s[t]=o.C._defaultGapSymbolsDict.SEPARATOR);return s.join(t)})),n.setTag(i.TAGS.UNITS,"separator"),n}getHelmWrappers(){const t=this.isDna()?"DNA1{":this.isRna()||this.isHelmCompatible()?"RNA1{":this.isPeptide()?"PEPTIDE1{":"Unknown";if("Unknown"===t)throw new Error("Neither peptide, nor nucleotide");return[t,this.isDna()?"D(":this.isRna()?"R(":"",this.isDna()||this.isRna()?")P":"","}$$$$"]}convertToHelmHelper(t,e,n,i,s,r){return`${n}${this.splitter(t).map((t=>t===e?o.C._defaultGapSymbolsDict.HELM:`${i}${t}${s}`)).join(".")}${r}`}convertStringToHelm(t,e=null){null===e&&(e=this.defaultGapSymbol);const[n,i,o,s]=this.getHelmWrappers();return this.convertToHelmHelper(t,e,n,i,o,s)}convertToHelm(t=null){null===t&&(t=this.defaultGapSymbol);const[e,n,o,s]=this.getHelmWrappers(),r=this.getNewColumn("helm");return r.init((i=>{const r=this.column.get(i);return this.convertToHelmHelper(r,t,e,n,o,s)})),r.setTag(i.TAGS.UNITS,"helm"),r}convertSeparatorToFasta(t=null){null===t&&(t=o.C._defaultGapSymbolsDict.FASTA);const e=this.getNewColumn("fasta");return e.init((e=>{const n=this.column.get(e),i=this.splitter(n),o=[];for(let e=0;e<i.length;e++){const n=i[e];if(0===n.length)o.push(t);else if(n.length>1){const t="["+n+"]";o.push(t)}else o.push(n)}return o.join("")})),e.setTag(i.TAGS.UNITS,"fasta"),e}convertHelmToFastaSeparator(t,e,n,i){i||(i=this.toFasta(e)?o.C._defaultGapSymbolsDict.FASTA:o.C._defaultGapSymbolsDict.SEPARATOR),n||(n=this.toFasta(e)?"":this.separator);const s=/(R\(|D\(|\)|P)/g,r=t.startsWith("DNA")||t.startsWith("RNA"),a=this.splitter(t),l=[];for(let t=0;t<a.length;t++){let n=a[t];if(r&&(n=n.replace(s,"")),n===o.C._defaultGapSymbolsDict.HELM)l.push(i);else if(this.toFasta(e)&&n.length>1){const t="["+n+"]";l.push(t)}else l.push(n)}return l.join(n)}convertHelm(t,e,n){const i=this.getNewColumn(t,e);i.init((i=>{const o=this.column.get(i);return this.convertHelmToFastaSeparator(o,t,e,n)}));const o=(0,s.Mj)(i),r=(0,s.fy)(i,5,o).sameLength?"SEQ.MSA":"SEQ";return i.setTag("aligned",r),i}convertHelmToSeparator(){return this.getNewColumn("separator")}convert(t,e=null){if(this.notation===t)throw new Error("tgt notation is invalid");if(this.toSeparator(t)&&null===e)throw new Error("tgt separator is not specified");if(this.isFasta()&&this.toSeparator(t)&&null!==e)return this.convertFastaToSeparator(e);if((this.isFasta()||this.isSeparator())&&this.toHelm(t))return this.convertToHelm();if(this.isSeparator()&&this.toFasta(t))return this.convertSeparatorToFasta();if(this.isHelm()&&this.toFasta(t))return this.convertHelm(t);if(this.isHelm()&&this.toSeparator(t))return this.convertHelm(t,e);throw new Error(`Not supported conversion from source notation '${this.notation}' to target notation '${t}'.`)}constructor(t){super(t),this._splitter=null}}},499:(t,e,n)=>{"use strict";n.d(e,{C:()=>l});var i=n(976),o=n(1821),s=n(585),r=n(489),a=n(7228);class l{static setUnitsToFastaColumn(t){if(t.semType!==i.SEMTYPE.MACROMOLECULE||"fasta"!==t.getTag(i.TAGS.UNITS))throw new Error(`The column of notation 'fasta' must be '${i.SEMTYPE.MACROMOLECULE}'.`);t.setTag(i.TAGS.UNITS,"fasta"),l.setTags(t,s.kB)}static setUnitsToSeparatorColumn(t,e){if(t.semType!==i.SEMTYPE.MACROMOLECULE||"separator"!==t.getTag(i.TAGS.UNITS))throw new Error(`The column of notation 'separator' must be '${i.SEMTYPE.MACROMOLECULE}'.`);if(!e)throw new Error("The column of notation 'separator' must have the separator tag.");t.setTag(i.TAGS.UNITS,"separator"),t.setTag("separator",e),l.setTags(t,(0,s.Ar)(e))}static setUnitsToHelmColumn(t){if(t.semType!==i.SEMTYPE.MACROMOLECULE)throw new Error(`The column of notation 'helm' must be '${i.SEMTYPE.MACROMOLECULE}'`);t.setTag(i.TAGS.UNITS,"helm"),l.setTags(t,s.gP)}static setTags(t,e){const n=t.getTag(i.TAGS.UNITS),r=(0,s.fy)(t,5,e);if(Object.keys(r.freq).some((t=>t.length>1)),["fasta","separator"].includes(n)){if(0===Object.keys(r.freq).length)throw new Error("Alphabet is empty");const e=r.sameLength?"SEQ.MSA":"SEQ";t.setTag("aligned",e);const n=(0,s.w4)(r.freq,o.XS);if(t.setTag("alphabet",n),"UN"===n){const e=Object.keys(r.freq).length,n=Object.keys(r.freq).some((t=>t.length>1));t.setTag(".alphabetSize",e.toString()),t.setTag(".alphabetIsMultichar",n?"true":"false")}}}get units(){return this._units}get column(){return this._column}get notation(){return this._notation}get defaultGapSymbol(){return this._defaultGapSymbol}get separator(){var t;const e=null!==(t=this.column.getTag("separator"))&&void 0!==t?t:void 0;if("separator"===this.notation&&void 0===e)throw new Error(`Separator is mandatory for column '${this.column.name}' of notation '${this.notation}'.`);return e}get aligned(){const t=this.column.getTag("aligned");if(!t&&(this.isFasta()||this.isSeparator()))throw new Error("Tag aligned not set");return t}get alphabet(){const t=this.column.getTag("alphabet");if(!t&&(this.isFasta()||this.isSeparator()))throw new Error("Tag alphabet not set");return t}get helmCompatible(){return this.column.getTag(".isHelmCompatible")}getAlphabetSize(){if("helm"==this.notation||"UN"==this.alphabet){const t=this.column.getTag(".alphabetSize");let e;if(t)e=parseInt(t);else{const t=(0,s.Mj)(this.column),n=(0,s.fy)(this.column,1,t);e=Object.keys(n.freq).length}return e}switch(this.alphabet){case"PT":return 20;case"DNA":case"RNA":return 4;case"NT":return console.warn("Unexpected alphabet 'NT'."),4;default:throw new Error(`Unexpected alphabet '${this.alphabet}'.`)}}getAlphabetIsMultichar(){return"helm"===this.notation||"UN"===this.alphabet&&"true"===this.column.getTag(".alphabetIsMultichar")}isFasta(){return"fasta"===this.notation}isSeparator(){return"separator"===this.notation}isHelm(){return"helm"===this.notation}isRna(){return"RNA"===this.alphabet}isDna(){return"DNA"===this.alphabet}isPeptide(){return"PT"===this.alphabet}isMsa(){return!!this.aligned&&this.aligned.toUpperCase().includes("MSA")}isHelmCompatible(){return"true"===this.helmCompatible}getNotation(){if(this.units.toLowerCase().startsWith("fasta"))return"fasta";if(this.units.toLowerCase().startsWith("separator"))return"separator";if(this.units.toLowerCase().startsWith("helm"))return"helm";throw new Error(`Column '${this.column.name}' has unexpected notation '${this.units}'.`)}getNewColumn(t,e){const n=this.column,o=n.length,s=t.toLowerCase()+"("+n.name+")",r=n.dataFrame.columns.getUnusedName(s),a=i.Column.fromList("string",r,new Array(o).fill(""));if(a.semType=i.SEMTYPE.MACROMOLECULE,a.setTag(i.TAGS.UNITS,t),"separator"===t){if(!e)throw new Error("Notation 'separator' requires separator value.");a.setTag("separator",e)}a.setTag(i.TAGS.CELL_RENDERER,"Macromolecule");const l=n.getTag("aligned");l&&a.setTag("aligned",l);const c=n.getTag("alphabet");c&&a.setTag("alphabet",c);let h=n.getTag(".alphabetSize");h&&a.setTag(".alphabetSize",h);const u=n.getTag(".alphabetIsMultichar");return void 0!==u&&a.setTag(".alphabetIsMultichar",u),"helm"==t&&(h=this.getAlphabetSize().toString(),a.setTag(".alphabetSize",h)),a}static getNewColumn(t){const e=new l(t),n=e.notation;return e.getNewColumn(n)}static unitsStringIsValid(t){return t=t.toLowerCase(),["fasta","separator","helm"].some((e=>t.startsWith(e.toLowerCase())))}static getNewColumnFromParams(t,e,n){if(!l.unitsStringIsValid(n))throw new Error("Invalid format of 'units' parameter");const o=i.Column.fromList("string",e,new Array(t).fill(""));return o.semType=i.SEMTYPE.MACROMOLECULE,o.setTag(i.TAGS.UNITS,n),o}getDistanceFunctionName(){if(!this.isFasta())throw new Error("Only FASTA notation is supported");if(this.isMsa())return r.U.HAMMING;switch(this.alphabet){case"DNA":case"RNA":default:return r.U.LEVENSHTEIN;case"PT":return r.U.NEEDLEMANN_WUNSCH}}getDistanceFunction(){return r.o[this.getDistanceFunctionName()]()}checkHelmCompatibility(){return t=this,e=void 0,i=function*(){if(this.column.tags.has(".isHelmCompatible"))return"true"===this.column.getTag(".isHelmCompatible");const t=(yield(0,a.JN)()).getBioLib().getMonomerNamesByType("PEPTIDE".toString()),e=new Set(t),n=(0,s.Ar)(this.separator);for(const t of this.column.categories){const i=n(t);for(const t of i)if(!e.has(t))return this.column.setTag(".isHelmCompatible","false"),!1}return this.column.setTag(".isHelmCompatible","true"),!0},new((n=void 0)||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}));var t,e,n,i}constructor(t){this._column=t;const e=this._column.getTag(i.TAGS.UNITS);if(null==e)throw new Error("Units are not specified in column");if(this._units=e,this._notation=this.getNotation(),this._defaultGapSymbol=this.isFasta()?l._defaultGapSymbolsDict.FASTA:this.isHelm()?l._defaultGapSymbolsDict.HELM:l._defaultGapSymbolsDict.SEPARATOR,!this.column.tags.has("aligned")||!this.column.tags.has("alphabet")||!this.column.tags.has(".alphabetIsMultichar")&&!this.isHelm()&&"UN"===this.alphabet)if(this.isFasta())l.setUnitsToFastaColumn(this.column);else if(this.isSeparator()){const e=t.getTag("separator");l.setUnitsToSeparatorColumn(this.column,e)}else{if(!this.isHelm())throw new Error(`Unexpected units '${this.column.getTag(i.TAGS.UNITS)}'.`);l.setUnitsToHelmColumn(this.column)}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.`)}}l._defaultGapSymbolsDict={HELM:"*",SEPARATOR:"",FASTA:"-"}},9298:(t,e,n)=>{"use strict";var i,o,s,r,a;n.d(e,{CI:()=>c,Ct:()=>a,DX:()=>h,ES:()=>i,dE:()=>r,iD:()=>s,vS:()=>l,vw:()=>o}),function(t){t.Entropy="Entropy",t.full="100%"}(i||(i={})),function(t){t.TOP="top",t.MIDDLE="middle",t.BOTTOM="bottom"}(o||(o={})),function(t){t.LEFT="left",t.CENTER="center",t.RIGHT="right"}(s||(s={})),function(t){t.AUTO="auto",t.ON="on",t.OFF="off"}(r||(r={})),function(t){t.Filtered="Filtered",t.Selected="Selected"}(a||(a={}));const l=new class{constructor(){this.sequenceColumnName=null,this.startPositionName=null,this.endPositionName=null,this.skipEmptySequences=!0,this.skipEmptyPositions=!1,this.shrinkEmptyTail=!0,this.backgroundColor=4294967295,this.positionHeight=i.full,this.positionWidth=16,this.verticalAlignment=o.MIDDLE,this.horizontalAlignment=s.CENTER,this.fixWidth=!1,this.fitArea=!0,this.minHeight=50,this.maxHeight=100,this.positionMarginState=r.AUTO,this.positionMargin=0,this.filterSource=a.Filtered}},c=", ";var h;!function(t){t.positionNames=".positionNames"}(h||(h={}))},779:(t,e,n)=>{"use strict";function i(){return(t,e)=>{let n=0;t.length!==e.length&&(n=Math.abs(t.length-e.length));let i=0;for(let n=0;n<Math.min(t.length,e.length);n++)t[n]!==e[n]&&i++;return i+n}}n.d(e,{j:()=>i})},489:(t,e,n)=>{"use strict";n.d(e,{U:()=>i.U,o:()=>i.o});var i=n(5540)},458:(t,e,n)=>{"use strict";n.d(e,{r:()=>o});var i=n(1811);function o(){return(t,e)=>(0,i.T)(t,e)}},5540:(t,e,n)=>{"use strict";n.d(e,{U:()=>i,o:()=>a});var i,o=n(779),s=n(458),r=n(6683);!function(t){t.HAMMING="Hamming",t.LEVENSHTEIN="Levenshtein",t.NEEDLEMANN_WUNSCH="Needlemann-Wunsch"}(i||(i={}));const a={[i.HAMMING]:o.j,[i.LEVENSHTEIN]:s.r,[i.NEEDLEMANN_WUNSCH]:r.n}},6683:(t,e,n)=>{"use strict";n.d(e,{n:()=>o});const i={gapOpen:8,gapExtend:2,scoringMatrix:[[4,-1,-2,-2,0,-1,-1,0,-2,-1,-1,-1,-1,-2,-1,1,0,-3,-2,0,-2,-1,0,-4],[-1,5,0,-2,-3,1,0,-2,0,-3,-2,2,-1,-3,-2,-1,-1,-3,-2,-3,-1,0,-1,-4],[-2,0,6,1,-3,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,-2,-2,-3,-3,-1,-2,-1,-4],[-2,0,1,-1,-3,0,0,-2,8,-3,-3,-1,-2,-1,-2,-1,-2,-2,2,-3,0,0,-1,-4],[-1,-3,-3,-3,-1,-3,-3,-4,-3,4,2,-3,1,0,-3,-2,-1,-3,-1,3,-3,-3,-1,-4],[-1,-2,-3,-4,-1,-2,-3,-4,-3,2,4,-2,2,0,-3,-2,-1,-2,-1,1,-4,-3,-1,-4],[-1,2,0,-1,-3,1,1,-2,-1,-3,-2,5,-1,-3,-1,0,-1,-3,-2,-2,0,1,-1,-4],[-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 o(t){return(e,n)=>{const{gapOpen:o,gapExtend:s,scoringMatrix:r,alphabetIndexes:a}=Object.assign(Object.assign({},i),t),l=[new Array(e.length+1).fill(0),new Array(e.length+1).fill(0)],c=new Array(e.length+1).fill(!1),h=new Array(e.length+1).fill(!1);let u=0,d=1;for(let t=1;t<e.length+1;t++)l[0][t]=-o-(t-1)*s;for(let t=1;t<n.length+1;t++){l[d][0]=-o-(t-1)*s;for(let i=1;i<e.length+1;i++){const f=l[u][i-1]+r[a[e[i-1]]][a[n[t-1]]],m=l[u][i]-(c[i]?s:o),p=l[d][i-1]-(h[i-1]?s:o);l[d][i]=Math.max(f,p,m),l[d][i]===f?(c[i]=!1,h[i]=!1):l[d][i]===p?(c[i]=!1,h[i]=!0):(c[i]=!0,h[i]=!1)}u=d,d=(d+1)%2}return-l[u][e.length]}}},1061:(t,e,n)=>{"use strict";n.d(e,{AB:()=>A,Bu:()=>f,QK:()=>r,W3:()=>y,Wh:()=>g,X5:()=>w,bb:()=>b,ci:()=>C,f6:()=>v,gw:()=>M,l_:()=>m});var i=n(4469),o=n(976),s=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};const r={},a="Auto Tests",l={};let c;var h;!function(t){t.notNull=function(t,e){if(null==t)throw new Error(`${null==e?"Value":e} not defined`)}}(h||(h={}));class u{constructor(t,e){this.catchUnhandled=!0,this.report=!1,void 0!==t&&(this.catchUnhandled=t),void 0!==e&&(this.report=e)}}class d{constructor(t,e,n,i){var o;this.category=t,this.name=e,null!=i||(i={}),null!==(o=i.timeout)&&void 0!==o||(i.timeout=3e4),this.options=i,this.test=()=>s(this,void 0,void 0,(function*(){return new Promise(((t,e)=>s(this,void 0,void 0,(function*(){let i="";try{i=yield n()}catch(t){e(t)}t(i)}))))}))}}function f(t,e,n){null==r[c]&&(r[c]={}),null==r[c].tests&&(r[c].tests=[]),r[c].tests.push(new d(c,t,e,n))}function m(t,e=!0,n){if(n=n?`${n}, `:"",t!==e)throw new Error(`${n}Expected "${e}", got "${t}"`)}function p(t,e,n=.001,i){if(t===Number.POSITIVE_INFINITY&&e===Number.POSITIVE_INFINITY||t===Number.NEGATIVE_INFINITY&&e===Number.NEGATIVE_INFINITY||t===Number.NaN&&e===Number.NaN||isNaN(t)&&isNaN(e))return;const o=Math.abs(t-e)<n;if(m(o,!0,`${null!=i?i:""} (tolerance = ${n})`),!o)throw new Error(`Expected ${e}, got ${t} (tolerance = ${n})`)}function g(t,e){for(const[n,i]of Object.entries(e)){if(!t.hasOwnProperty(n))throw new Error(`Expected property "${n}" not found`);const e=t[n];if(e instanceof Array&&i instanceof Array)v(e,i);else if(e instanceof Object&&i instanceof Object)g(e,i);else if(Number.isFinite(e)&&Number.isFinite(i))p(e,i);else if(e!=i)throw new Error(`Expected (${i}) for key '${n}', got (${e})`)}}function v(t,e){const n=t.length,i=e.length;if(n!=i)throw new Error(`Arrays are of different length: actual array length is ${n} and expected array length is ${i}`);for(let i=0;i<n;i++)if(t[i]instanceof Array&&e[i]instanceof Array)v(t[i],e[i]);else if(t[i]instanceof Object&&e[i]instanceof Object)g(t[i],e[i]);else if(t[i]!=e[i])throw new Error(`Expected ${e[i]} at position ${i}, got ${t[i]}`)}function y(t,e){c=t,e()}function b(t){null==r[c]&&(r[c]={}),r[c].before=t}function w(t){null==r[c]&&(r[c]={}),r[c].after=t}function S(t,e){return t.replace(new RegExp(e.name,"gi"),e.nqName)}function C(t){var e,n,c,h,f;return s(this,void 0,void 0,(function*(){const m=null===(n=null===(e=i.functions.getCurrentCall())||void 0===e?void 0:e.func)||void 0===n?void 0:n.package;yield function(t,e){return s(this,void 0,void 0,(function*(){if(l[t])return;const e=r;if(void 0!==e[a])return void(l[t]=!0);const n=[],o=yield i.dapi.functions.filter(`package.id = "${t}"`).list();for(const t of o){const e=t.options.test;if(e&&Array.isArray(e)&&e.length)for(let o=0;o<e.length;o++)n.push(new d(a,1===e.length?t.name:`${t.name} ${o+1}`,(()=>s(this,void 0,void 0,(function*(){if(!0!==(yield i.functions.eval(S(e[o],t))))throw`Failed: ${e[o]}`})))))}l[t]=!0,n.length&&(e[a]={tests:n})}))}(m.id);const p=[];console.log("Running tests"),null!=t||(t={}),null!==(c=(f=t).testContext)&&void 0!==c||(f.testContext=new u),i.shell.lastError="";for(const[e,n]of Object.entries(r)){if(null!=(null==t?void 0:t.category)&&!e.toLowerCase().startsWith(null==t?void 0:t.category.toLowerCase()))continue;console.log(`Started ${e} category`);try{n.before&&(yield n.before())}catch(t){n.beforeStatus=t.toString()}const i=null!==(h=n.tests)&&void 0!==h?h:[],o=[];for(let e=0;e<i.length;e++)o.push(yield T(i[e],null==t?void 0:t.test));const s=(yield Promise.all(o)).filter((t=>"skipped"!=t.result));try{n.after&&(yield n.after())}catch(t){n.afterStatus=t.toString()}n.afterStatus&&s.push({category:e,name:"init",result:n.afterStatus,success:!1,ms:0,skipped:!1}),n.beforeStatus&&s.push({category:e,name:"init",result:n.beforeStatus,success:!1,ms:0,skipped:!1}),p.push(...s)}if(t.testContext.catchUnhandled&&(yield M(1e3),i.shell.lastError.length>0&&p.push({category:"Unhandled exceptions",name:"exceptions",result:i.shell.lastError,success:!1,ms:0,skipped:!1})),t.testContext.report){const t=new o.Logger,e=p.filter((t=>t.success)).length,n=p.filter((t=>t.skipped)).length,i=p.filter((t=>!t.success)),s="Package @package tested: @successful successful, @skipped skipped, @failed failed tests",r={successful:e,skipped:n,failed:i.length,package:m};for(const t of i)Object.assign(r,{[`${t.category} | ${t.name}`]:t.result});t.log(s,r,"package-tested")}return p}))}function T(t,e){var n,i,o;return s(this,void 0,void 0,(function*(){let s;const r=null!=e&&!t.name.toLowerCase().startsWith(e.toLowerCase()),a=(null===(n=t.options)||void 0===n?void 0:n.skipReason)||r,l=r?"skipped":null===(i=t.options)||void 0===i?void 0:i.skipReason;a||console.log(`Started ${t.category} ${t.name}`);const c=new Date;try{s=a?{success:!0,result:l,ms:0,skipped:!0}:{success:!0,result:null!==(o=yield t.test())&&void 0!==o?o:"OK",ms:0,skipped:!1}}catch(t){s={success:!1,result:t.toString(),ms:0,skipped:!1}}const h=new Date;return s.ms=h-c,a||console.log(`Finished ${t.category} ${t.name} for ${s.ms} ms`),s.category=t.category,s.name=t.name,s}))}function M(t){return s(this,void 0,void 0,(function*(){yield new Promise((e=>setTimeout(e,t)))}))}function E(t,e="Timeout exceeded",n=500){return s(this,void 0,void 0,(function*(){return new Promise(((i,o)=>{setTimeout((()=>{clearInterval(s),o(new Error(e))}),n);const s=setInterval((()=>{t()&&(clearInterval(s),i())}),50)}))}))}function A(t,e,n=!1){return s(this,void 0,void 0,(function*(){n&&(yield i.data.detectSemanticTypes(e));const o=i.shell.addTableView(e),s=`[name=viewer-${t.replace(/\s+/g,"-")} i]`,r=`${s} canvas,${s} svg,${s} img,\n ${s} input,${s} h1,${s} a`,a=[];try{let n=o.addViewer(t);yield E((()=>null!==document.querySelector(r)),"cannot load viewer",3e3),a.push(Array.from(o.viewers).length),Array.from(e.row(0).cells).forEach((t=>t.value=null)),e.rows.select((t=>t.idx>1&&t.idx<7));for(let t=7;t<12;t++)e.filter.set(t,!1);e.currentRowIdx=1;const i=n.getOptions(!0).look,s={};Object.keys(i).filter((t=>"boolean"==typeof i[t])).forEach((t=>s[t]=!i[t])),n.setOptions(s),yield M(250);const l=o.saveLayout(),c=n.getOptions().look;o.resetLayout(),a.push(Array.from(o.viewers).length),o.loadLayout(l),yield E((()=>null!==document.querySelector(r)),"cannot load viewer from layout",3e3),yield M(250),a.push(Array.from(o.viewers).length),n=Array.from(o.viewers).find((t=>"Grid"!==t.type)),v(a,[2,1,2]),m(JSON.stringify(n.getOptions().look),JSON.stringify(c))}finally{o.close(),i.shell.closeTable(e)}}))}},7604:(t,e,n)=>{"use strict";function i(t){var e;return"string"==typeof t||t instanceof String?t:("object"==typeof t||t instanceof Object)&&"$thrownJsError"in t?i(t.$thrownJsError):t instanceof Error?null!==(e=t.stack)&&void 0!==e?e:t.message:t.toString()}n.d(e,{O:()=>i})},3659:(t,e,n)=>{"use strict";n.d(e,{OW:()=>i});class i extends Float32Array{}},850:(t,e,n)=>{"use strict";function i(t=!1,e="Assertion error."){if(!t)throw new Error(e)}function o(t){let e=0;for(let n=0;n<t.length;n++)e+=t[n]*t[n];return Math.sqrt(e)}function s(t,e){if(t.length!=e.length)throw new Error("The dimensionality of the vectors must match");let n=0;for(let i=0;i<t.length;i++)n+=t[i]*e[i];return n}n.d(e,{$G:()=>o,MA:()=>s,hu:()=>i}),n(3659)},7659:(t,e,n)=>{"use strict";e.Z=void 0;var i=n(6215);Object.defineProperty(e,"Z",{enumerable:!0,get:function(){return i.TSNE}})},6215:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.TSNE=void 0,e.TSNE=class{constructor(t){this.returnV=!1,this.vValue=0,this.iter=0,t=t||{},this.perplexity=this.getopt(t,"perplexity",30),this.dim=this.getopt(t,"dim",2),this.epsilon=this.getopt(t,"epsilon",10)}assert(t,e){if(!t)throw e||"Assertion failed"}getopt(t,e,n){return t.hasOwnProperty(e)?t[e]:n}gaussRandom(){if(this.returnV)return this.returnV=!1,this.vValue;const t=2*Math.random()-1,e=2*Math.random()-1,n=t*t+e*e;if(0===n||n>1)return this.gaussRandom();const i=Math.sqrt(-2*Math.log(n)/n);return this.vValue=e*i,this.returnV=!0,t*i}randn(t,e){return t+this.gaussRandom()*e}zeros(t){if(void 0===t||isNaN(t))return[];if("undefined"==typeof ArrayBuffer){const e=new Array(t);for(let n=0;n<t;n++)e[n]=0;return e}return new Float64Array(t)}randn2d(t,e,n){const i=void 0!==n,o=[];for(let s=0;s<t;s++){const t=[];for(let o=0;o<e;o++)i?t.push(n):t.push(this.randn(0,1e-4));o.push(t)}return o}L2(t,e){const n=t.length;let i=0;for(let o=0;o<n;o++){const n=t[o],s=e[o];i+=(n-s)*(n-s)}return i}xtod(t){const e=t.length,n=this.zeros(e*e);for(let i=0;i<e;i++)for(let o=i+1;o<e;o++){const s=this.L2(t[i],t[o]);n[i*e+o]=s,n[o*e+i]=s}return n}d2p(t,e,n){const i=Math.sqrt(t.length),o=Math.floor(i);this.assert(o===i,"D should have square number of elements.");const s=Math.log(e),r=this.zeros(o*o),a=this.zeros(o);for(let e=0;e<o;e++){let i=-1/0,l=1/0,c=1,h=!1;const u=50;let d=0;for(;!h;){let r=0;for(let n=0;n<o;n++){let i=Math.exp(-t[e*o+n]*c);e===n&&(i=0),a[n]=i,r+=i}let f=0;for(let t=0;t<o;t++){let e;e=0===r?0:a[t]/r,a[t]=e,e>1e-7&&(f-=e*Math.log(e))}f>s?(i=c,l===1/0?c*=2:c=(c+l)/2):(l=c,i===-1/0?c/=2:c=(c+i)/2),d++,Math.abs(f-s)<n&&(h=!0),d>=u&&(h=!0)}for(let t=0;t<o;t++)r[e*o+t]=a[t]}const l=this.zeros(o*o),c=2*o;for(let t=0;t<o;t++)for(let e=0;e<o;e++)l[t*o+e]=Math.max((r[t*o+e]+r[e*o+t])/c,1e-100);return l}sign(t){return t>0?1:t<0?-1:0}initDataRaw(t){const e=t.length,n=t[0].length;this.assert(e>0," X is empty? You must have some data!"),this.assert(n>0," X[0] is empty? Where is the data?");const i=this.xtod(t);this.P=this.d2p(i,this.perplexity,1e-4),this.N=e,this.initSolution()}initDataDist(t){const e=t.length;this.assert(e>0," X is empty? You must have some data!");const n=this.zeros(e*e);for(let i=0;i<e;i++)for(let o=i+1;o<e;o++){const s=t[i][o];n[i*e+o]=s,n[o*e+i]=s}this.P=this.d2p(n,this.perplexity,1e-4),this.N=e,this.initSolution()}initSolution(){this.Y=this.randn2d(this.N,this.dim),this.gains=this.randn2d(this.N,this.dim,1),this.ystep=this.randn2d(this.N,this.dim,0),this.iter=0}getSolution(){return this.Y}step(){this.iter+=1;const t=this.N,e=this.costGrad(this.Y),n=e.cost,i=e.grad,o=this.zeros(this.dim);for(let e=0;e<t;e++)for(let t=0;t<this.dim;t++){const n=i[e][t],s=this.ystep[e][t],r=this.gains[e][t];let a=this.sign(n)===this.sign(s)?.8*r:r+.2;a<.01&&(a=.01),this.gains[e][t]=a;const l=(this.iter<250?.5:.8)*s-this.epsilon*a*i[e][t];this.ystep[e][t]=l,this.Y[e][t]+=l,o[t]+=this.Y[e][t]}for(let e=0;e<t;e++)for(let n=0;n<this.dim;n++)this.Y[e][n]-=o[n]/t;return n}debugGrad(){const t=this.N,e=this.costGrad(this.Y),n=(e.cost,e.grad),i=1e-5;for(let e=0;e<t;e++)for(let t=0;t<this.dim;t++){const o=this.Y[e][t];this.Y[e][t]=o+i;const s=this.costGrad(this.Y);this.Y[e][t]=o-i;const r=this.costGrad(this.Y),a=n[e][t],l=(s.cost-r.cost)/(2*i);console.log(e+","+t+": gradcheck analytic: "+a+" vs. numerical: "+l),this.Y[e][t]=o}}costGrad(t){const e=this.N,n=this.dim,i=this.P,o=this.iter<100?4:1,s=this.zeros(e*e);let r=0;for(let i=0;i<e;i++)for(let o=i+1;o<e;o++){let a=0;for(let e=0;e<n;e++){const n=t[i][e]-t[o][e];a+=n*n}const l=1/(1+a);s[i*e+o]=l,s[o*e+i]=l,r+=2*l}const a=e*e,l=this.zeros(a);for(let t=0;t<a;t++)l[t]=Math.max(s[t]/r,1e-100);let c=0;const h=[];for(let r=0;r<e;r++){const a=new Array(n);for(let t=0;t<n;t++)a[t]=0;for(let h=0;h<e;h++){c+=-i[r*e+h]*Math.log(l[r*e+h]);const u=4*(o*i[r*e+h]-l[r*e+h])*s[r*e+h];for(let e=0;e<n;e++)a[e]+=u*(t[r][e]-t[h][e])}h.push(a)}return{cost:c,grad:h}}}},9414:(t,e,n)=>{"use strict";n.d(e,{Z:()=>a});var i=n(7537),o=n.n(i),s=n(3645),r=n.n(s)()(o());r.push([t.id,".scatter_plot_link {\n position: absolute!important;\n right: 10px;\n}\n\n.cliffs_grid {\n top: 10px;\n}\n\n.show_only_cliffs {\n top: 30px;\n}\n\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 n="",i=void 0!==e[5];return e[4]&&(n+="@supports (".concat(e[4],") {")),e[2]&&(n+="@media ".concat(e[2]," {")),i&&(n+="@layer".concat(e[5].length>0?" ".concat(e[5]):""," {")),n+=t(e),i&&(n+="}"),e[2]&&(n+="}"),e[4]&&(n+="}"),n})).join("")},e.i=function(t,n,i,o,s){"string"==typeof t&&(t=[[null,t,void 0]]);var r={};if(i)for(var a=0;a<this.length;a++){var l=this[a][0];null!=l&&(r[l]=!0)}for(var c=0;c<t.length;c++){var h=[].concat(t[c]);i&&r[h[0]]||(void 0!==s&&(void 0===h[5]||(h[1]="@layer".concat(h[5].length>0?" ".concat(h[5]):""," {").concat(h[1],"}")),h[5]=s),n&&(h[2]?(h[1]="@media ".concat(h[2]," {").concat(h[1],"}"),h[2]=n):h[2]=n),o&&(h[4]?(h[1]="@supports (".concat(h[4],") {").concat(h[1],"}"),h[4]=o):h[4]="".concat(o)),e.push(h))}},e}},7537:t=>{"use strict";t.exports=function(t){var e=t[1],n=t[3];if(!n)return e;if("function"==typeof btoa){var i=btoa(unescape(encodeURIComponent(JSON.stringify(n)))),o="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(i),s="/*# ".concat(o," */");return[e].concat([s]).join("\n")}return[e].join("\n")}},9133:function(t,e,n){var i;!function(e,o){var s={};!function(t){"use strict";t.__esModule=!0,t.digestLength=32,t.blockSize=64;var e=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function n(t,n,i,o,s){for(var r,a,l,c,h,u,d,f,m,p,g,v,y;s>=64;){for(r=n[0],a=n[1],l=n[2],c=n[3],h=n[4],u=n[5],d=n[6],f=n[7],p=0;p<16;p++)g=o+4*p,t[p]=(255&i[g])<<24|(255&i[g+1])<<16|(255&i[g+2])<<8|255&i[g+3];for(p=16;p<64;p++)v=((m=t[p-2])>>>17|m<<15)^(m>>>19|m<<13)^m>>>10,y=((m=t[p-15])>>>7|m<<25)^(m>>>18|m<<14)^m>>>3,t[p]=(v+t[p-7]|0)+(y+t[p-16]|0);for(p=0;p<64;p++)v=(((h>>>6|h<<26)^(h>>>11|h<<21)^(h>>>25|h<<7))+(h&u^~h&d)|0)+(f+(e[p]+t[p]|0)|0)|0,y=((r>>>2|r<<30)^(r>>>13|r<<19)^(r>>>22|r<<10))+(r&a^r&l^a&l)|0,f=d,d=u,u=h,h=c+v|0,c=l,l=a,a=r,r=v+y|0;n[0]+=r,n[1]+=a,n[2]+=l,n[3]+=c,n[4]+=h,n[5]+=u,n[6]+=d,n[7]+=f,o+=64,s-=64}return o}var i=function(){function e(){this.digestLength=t.digestLength,this.blockSize=t.blockSize,this.state=new Int32Array(8),this.temp=new Int32Array(64),this.buffer=new Uint8Array(128),this.bufferLength=0,this.bytesHashed=0,this.finished=!1,this.reset()}return e.prototype.reset=function(){return this.state[0]=1779033703,this.state[1]=3144134277,this.state[2]=1013904242,this.state[3]=2773480762,this.state[4]=1359893119,this.state[5]=2600822924,this.state[6]=528734635,this.state[7]=1541459225,this.bufferLength=0,this.bytesHashed=0,this.finished=!1,this},e.prototype.clean=function(){for(var t=0;t<this.buffer.length;t++)this.buffer[t]=0;for(t=0;t<this.temp.length;t++)this.temp[t]=0;this.reset()},e.prototype.update=function(t,e){if(void 0===e&&(e=t.length),this.finished)throw new Error("SHA256: can't update because hash was finished.");var i=0;if(this.bytesHashed+=e,this.bufferLength>0){for(;this.bufferLength<64&&e>0;)this.buffer[this.bufferLength++]=t[i++],e--;64===this.bufferLength&&(n(this.temp,this.state,this.buffer,0,64),this.bufferLength=0)}for(e>=64&&(i=n(this.temp,this.state,t,i,e),e%=64);e>0;)this.buffer[this.bufferLength++]=t[i++],e--;return this},e.prototype.finish=function(t){if(!this.finished){var e=this.bytesHashed,i=this.bufferLength,o=e/536870912|0,s=e<<3,r=e%64<56?64:128;this.buffer[i]=128;for(var a=i+1;a<r-8;a++)this.buffer[a]=0;this.buffer[r-8]=o>>>24&255,this.buffer[r-7]=o>>>16&255,this.buffer[r-6]=o>>>8&255,this.buffer[r-5]=o>>>0&255,this.buffer[r-4]=s>>>24&255,this.buffer[r-3]=s>>>16&255,this.buffer[r-2]=s>>>8&255,this.buffer[r-1]=s>>>0&255,n(this.temp,this.state,this.buffer,0,r),this.finished=!0}for(a=0;a<8;a++)t[4*a+0]=this.state[a]>>>24&255,t[4*a+1]=this.state[a]>>>16&255,t[4*a+2]=this.state[a]>>>8&255,t[4*a+3]=this.state[a]>>>0&255;return this},e.prototype.digest=function(){var t=new Uint8Array(this.digestLength);return this.finish(t),t},e.prototype._saveState=function(t){for(var e=0;e<this.state.length;e++)t[e]=this.state[e]},e.prototype._restoreState=function(t,e){for(var n=0;n<this.state.length;n++)this.state[n]=t[n];this.bytesHashed=e,this.finished=!1,this.bufferLength=0},e}();t.Hash=i;var o=function(){function t(t){this.inner=new i,this.outer=new i,this.blockSize=this.inner.blockSize,this.digestLength=this.inner.digestLength;var e=new Uint8Array(this.blockSize);if(t.length>this.blockSize)(new i).update(t).finish(e).clean();else for(var n=0;n<t.length;n++)e[n]=t[n];for(n=0;n<e.length;n++)e[n]^=54;for(this.inner.update(e),n=0;n<e.length;n++)e[n]^=106;for(this.outer.update(e),this.istate=new Uint32Array(8),this.ostate=new Uint32Array(8),this.inner._saveState(this.istate),this.outer._saveState(this.ostate),n=0;n<e.length;n++)e[n]=0}return t.prototype.reset=function(){return this.inner._restoreState(this.istate,this.inner.blockSize),this.outer._restoreState(this.ostate,this.outer.blockSize),this},t.prototype.clean=function(){for(var t=0;t<this.istate.length;t++)this.ostate[t]=this.istate[t]=0;this.inner.clean(),this.outer.clean()},t.prototype.update=function(t){return this.inner.update(t),this},t.prototype.finish=function(t){return this.outer.finished?this.outer.finish(t):(this.inner.finish(t),this.outer.update(t,this.digestLength).finish(t)),this},t.prototype.digest=function(){var t=new Uint8Array(this.digestLength);return this.finish(t),t},t}();function s(t){var e=(new i).update(t),n=e.digest();return e.clean(),n}function r(t,e){var n=new o(t).update(e),i=n.digest();return n.clean(),i}function a(t,e,n,i){var o=i[0];if(0===o)throw new Error("hkdf: cannot expand more");e.reset(),o>1&&e.update(t),n&&e.update(n),e.update(i),e.finish(t),i[0]++}t.HMAC=o,t.hash=s,t.default=s,t.hmac=r;var l=new Uint8Array(t.digestLength);t.hkdf=function(t,e,n,i){void 0===e&&(e=l),void 0===i&&(i=32);for(var s=new Uint8Array([1]),c=r(e,t),h=new o(c),u=new Uint8Array(h.digestLength),d=u.length,f=new Uint8Array(i),m=0;m<i;m++)d===u.length&&(a(u,h,n,s),d=0),f[m]=u[d++];return h.clean(),u.fill(0),s.fill(0),f},t.pbkdf2=function(t,e,n,i){for(var s=new o(t),r=s.digestLength,a=new Uint8Array(4),l=new Uint8Array(r),c=new Uint8Array(r),h=new Uint8Array(i),u=0;u*r<i;u++){var d=u+1;a[0]=d>>>24&255,a[1]=d>>>16&255,a[2]=d>>>8&255,a[3]=d>>>0&255,s.reset(),s.update(e),s.update(a),s.finish(c);for(var f=0;f<r;f++)l[f]=c[f];for(f=2;f<=n;f++){s.reset(),s.update(c).finish(c);for(var m=0;m<r;m++)l[m]^=c[m]}for(f=0;f<r&&u*r+f<i;f++)h[u*r+f]=l[f]}for(u=0;u<r;u++)l[u]=c[u]=0;for(u=0;u<4;u++)a[u]=0;return s.clean(),h}}(s);var r=s.default;for(var a in s)r[a]=s[a];"object"==typeof t.exports?t.exports=r:void 0===(i=function(){return r}.call(s,n,s,t))||(t.exports=i)}()},1811:(t,e,n)=>{"use strict";n.d(e,{T:()=>o});const i=new Uint32Array(65536),o=(t,e)=>{if(t.length<e.length){const n=e;e=t,t=n}return 0===e.length?t.length:t.length<=32?((t,e)=>{const n=t.length,o=e.length,s=1<<n-1;let r=-1,a=0,l=n,c=n;for(;c--;)i[t.charCodeAt(c)]|=1<<c;for(c=0;c<o;c++){let t=i[e.charCodeAt(c)];const n=t|a;t|=(t&r)+r^r,a|=~(t|r),r&=t,a&s&&l++,r&s&&l--,a=a<<1|1,r=r<<1|~(n|a),a&=n}for(c=n;c--;)i[t.charCodeAt(c)]=0;return l})(t,e):((t,e)=>{const n=e.length,o=t.length,s=[],r=[],a=Math.ceil(n/32),l=Math.ceil(o/32);for(let t=0;t<a;t++)r[t]=-1,s[t]=0;let c=0;for(;c<l-1;c++){let a=0,l=-1;const h=32*c,u=Math.min(32,o)+h;for(let e=h;e<u;e++)i[t.charCodeAt(e)]|=1<<e;for(let t=0;t<n;t++){const n=i[e.charCodeAt(t)],o=r[t/32|0]>>>t&1,c=s[t/32|0]>>>t&1,h=n|a,u=((n|c)&l)+l^l|n|c;let d=a|~(u|l),f=l&u;d>>>31^o&&(r[t/32|0]^=1<<t),f>>>31^c&&(s[t/32|0]^=1<<t),d=d<<1|o,f=f<<1|c,l=f|~(h|d),a=d&h}for(let e=h;e<u;e++)i[t.charCodeAt(e)]=0}let h=0,u=-1;const d=32*c,f=Math.min(32,o-d)+d;for(let e=d;e<f;e++)i[t.charCodeAt(e)]|=1<<e;let m=o;for(let t=0;t<n;t++){const n=i[e.charCodeAt(t)],a=r[t/32|0]>>>t&1,l=s[t/32|0]>>>t&1,c=n|h,d=((n|l)&u)+u^u|n|l;let f=h|~(d|u),p=u&d;m+=f>>>o-1&1,m-=p>>>o-1&1,f>>>31^a&&(r[t/32|0]^=1<<t),p>>>31^l&&(s[t/32|0]^=1<<t),f=f<<1|a,p=p<<1|l,u=p|~(c|f),h=f&c}for(let e=d;e<f;e++)i[t.charCodeAt(e)]=0;return m})(t,e)}},3979:(t,e)=>{"use strict";e.H$=void 0,e.H$=function(t,e,n){var i=function(t,e,n){if(0===t.length||0===e.length)return 0;if(n&&!n.caseSensitive&&(t=t.toUpperCase(),e=e.toUpperCase()),t===e)return 1;for(var i=0,o=t.length,s=e.length,r=Math.floor(Math.max(o,s)/2)-1,a=new Array(o),l=new Array(s),c=0;c<o;c++)for(var h=Math.max(0,c-r);h<=Math.min(s,c+r+1);h++)if(!a[c]&&!l[h]&&t[c]===e[h]){++i,a[c]=l[h]=!0;break}if(0===i)return 0;var u=0,d=0;for(c=0;c<o;c++)if(a[c]){for(;!l[d];)d++;t.charAt(c)!==e.charAt(d++)&&u++}return(i/o+i/s+(i-(u/=2))/i)/3}(t,e,n),o=0;if(i>.7){for(var s=Math.min(t.length,e.length),r=0;t[r]===e[r]&&r<4&&r<s;)++o,r++;i+=.1*o*(1-i)}return i}},9251:(t,e,n)=>{"use strict";n.r(e),n.d(e,{default:()=>D});const i=Object.prototype.toString;function o(t){return i.call(t).endsWith("Array]")}function s(t,e,n){let i=0;const o=n(e);for(let e=0;e<t.x.length;e++)i+=Math.abs(t.y[e]-o(t.x[e]));return i}const r=Object.prototype.toString;function a(t){return r.call(t).endsWith("Array]")}const l=Object.prototype.toString;function c(t){return l.call(t).endsWith("Array]")}const h=Object.prototype.toString;const u=Object.prototype.toString;function d(t){var e,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!c(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");if(void 0!==n.output){if(!c(n.output))throw new TypeError("output option must be an array if specified");e=n.output}else e=new Array(t.length);var i=function(t){var e,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(e=t,!u.call(e).endsWith("Array]"))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");var i=n.fromIndex,o=void 0===i?0:i,s=n.toIndex,r=void 0===s?t.length:s;if(o<0||o>=t.length||!Number.isInteger(o))throw new Error("fromIndex must be a positive integer smaller than length");if(r<=o||r>t.length||!Number.isInteger(r))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var a=t[o],l=o+1;l<r;l++)t[l]<a&&(a=t[l]);return a}(t),o=function(t){var e,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(e=t,!h.call(e).endsWith("Array]"))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");var i=n.fromIndex,o=void 0===i?0:i,s=n.toIndex,r=void 0===s?t.length:s;if(o<0||o>=t.length||!Number.isInteger(o))throw new Error("fromIndex must be a positive integer smaller than length");if(r<=o||r>t.length||!Number.isInteger(r))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var a=t[o],l=o+1;l<r;l++)t[l]>a&&(a=t[l]);return a}(t);if(i===o)throw new RangeError("minimum and maximum input values are equal. Cannot rescale a constant array");var s=n.min,r=void 0===s?n.autoMinMax?i:0:s,a=n.max,l=void 0===a?n.autoMinMax?o:1:a;if(r>=l)throw new RangeError("min option must be smaller than max option");for(var d=(l-r)/(o-i),f=0;f<t.length;f++)e[f]=(t[f]-i)*d+r;return e}const f=" ".repeat(2),m=" ".repeat(4);function p(t,e={}){const{maxRows:n=15,maxColumns:i=10,maxNumSize:o=8,padMinus:s="auto"}=e;return`${t.constructor.name} {\n${f}[\n${m}${function(t,e,n,i,o){const{rows:s,columns:r}=t,a=Math.min(s,e),l=Math.min(r,n),c=[];if("auto"===o){o=!1;t:for(let e=0;e<a;e++)for(let n=0;n<l;n++)if(t.get(e,n)<0){o=!0;break t}}for(let e=0;e<a;e++){let n=[];for(let s=0;s<l;s++)n.push(g(t.get(e,s),i,o));c.push(`${n.join(" ")}`)}return l!==r&&(c[c.length-1]+=` ... ${r-n} more columns`),a!==s&&c.push(`... ${s-e} more rows`),c.join(`\n${m}`)}(t,n,i,o,s)}\n${f}]\n${f}rows: ${t.rows}\n${f}columns: ${t.columns}\n}`}function g(t,e,n){return(t>=0&&n?` ${v(t,e-1)}`:v(t,e)).padEnd(e)}function v(t,e){let n=t.toString();if(n.length<=e)return n;let i=t.toFixed(e);if(i.length>e&&(i=t.toFixed(Math.max(0,e-(i.length-e)))),i.length<=e&&!i.startsWith("0.000")&&!i.startsWith("-0.000"))return i;let o=t.toExponential(e);return o.length>e&&(o=t.toExponential(Math.max(0,e-(o.length-e)))),o.slice(0)}function y(t,e,n){let i=n?t.rows:t.rows-1;if(e<0||e>i)throw new RangeError("Row index out of range")}function b(t,e,n){let i=n?t.columns:t.columns-1;if(e<0||e>i)throw new RangeError("Column index out of range")}function w(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 S(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 C(t,e,n,i,o){if(5!==arguments.length)throw new RangeError("expected 4 arguments");if(M("startRow",e),M("endRow",n),M("startColumn",i),M("endColumn",o),e>n||i>o||e<0||e>=t.rows||n<0||n>=t.rows||i<0||i>=t.columns||o<0||o>=t.columns)throw new RangeError("Submatrix indices are out of range")}function T(t,e=0){let n=[];for(let i=0;i<t;i++)n.push(e);return n}function M(t,e){if("number"!=typeof e)throw new TypeError(`${t} must be a number`)}function E(t){if(t.isEmpty())throw new Error("Empty matrix has no elements to index")}class A{static from1DArray(t,e,n){if(t*e!==n.length)throw new RangeError("data length does not match given dimensions");let i=new P(t,e);for(let o=0;o<t;o++)for(let t=0;t<e;t++)i.set(o,t,n[o*e+t]);return i}static rowVector(t){let e=new P(1,t.length);for(let n=0;n<t.length;n++)e.set(0,n,t[n]);return e}static columnVector(t){let e=new P(t.length,1);for(let n=0;n<t.length;n++)e.set(n,0,t[n]);return e}static zeros(t,e){return new P(t,e)}static ones(t,e){return new P(t,e).fill(1)}static rand(t,e,n={}){if("object"!=typeof n)throw new TypeError("options must be an object");const{random:i=Math.random}=n;let o=new P(t,e);for(let n=0;n<t;n++)for(let t=0;t<e;t++)o.set(n,t,i());return o}static randInt(t,e,n={}){if("object"!=typeof n)throw new TypeError("options must be an object");const{min:i=0,max:o=1e3,random:s=Math.random}=n;if(!Number.isInteger(i))throw new TypeError("min must be an integer");if(!Number.isInteger(o))throw new TypeError("max must be an integer");if(i>=o)throw new RangeError("min must be smaller than max");let r=o-i,a=new P(t,e);for(let n=0;n<t;n++)for(let t=0;t<e;t++){let e=i+Math.round(s()*r);a.set(n,t,e)}return a}static eye(t,e,n){void 0===e&&(e=t),void 0===n&&(n=1);let i=Math.min(t,e),o=this.zeros(t,e);for(let t=0;t<i;t++)o.set(t,t,n);return o}static diag(t,e,n){let i=t.length;void 0===e&&(e=i),void 0===n&&(n=e);let o=Math.min(i,e,n),s=this.zeros(e,n);for(let e=0;e<o;e++)s.set(e,e,t[e]);return s}static min(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let n=t.rows,i=t.columns,o=new P(n,i);for(let s=0;s<n;s++)for(let n=0;n<i;n++)o.set(s,n,Math.min(t.get(s,n),e.get(s,n)));return o}static max(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let n=t.rows,i=t.columns,o=new this(n,i);for(let s=0;s<n;s++)for(let n=0;n<i;n++)o.set(s,n,Math.max(t.get(s,n),e.get(s,n)));return o}static checkMatrix(t){return A.isMatrix(t)?t:new P(t)}static isMatrix(t){return null!=t&&"Matrix"===t.klass}get size(){return this.rows*this.columns}apply(t){if("function"!=typeof t)throw new TypeError("callback must be a function");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)t.call(this,e,n);return this}to1DArray(){let t=[];for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)t.push(this.get(e,n));return t}to2DArray(){let t=[];for(let e=0;e<this.rows;e++){t.push([]);for(let n=0;n<this.columns;n++)t[e].push(this.get(e,n))}return t}toJSON(){return this.to2DArray()}isRowVector(){return 1===this.rows}isColumnVector(){return 1===this.columns}isVector(){return 1===this.rows||1===this.columns}isSquare(){return this.rows===this.columns}isEmpty(){return 0===this.rows||0===this.columns}isSymmetric(){if(this.isSquare()){for(let t=0;t<this.rows;t++)for(let e=0;e<=t;e++)if(this.get(t,e)!==this.get(e,t))return!1;return!0}return!1}isEchelonForm(){let t=0,e=0,n=-1,i=!0,o=!1;for(;t<this.rows&&i;){for(e=0,o=!1;e<this.columns&&!1===o;)0===this.get(t,e)?e++:1===this.get(t,e)&&e>n?(o=!0,n=e):(i=!1,o=!0);t++}return i}isReducedEchelonForm(){let t=0,e=0,n=-1,i=!0,o=!1;for(;t<this.rows&&i;){for(e=0,o=!1;e<this.columns&&!1===o;)0===this.get(t,e)?e++:1===this.get(t,e)&&e>n?(o=!0,n=e):(i=!1,o=!0);for(let n=e+1;n<this.rows;n++)0!==this.get(t,n)&&(i=!1);t++}return i}echelonForm(){let t=this.clone(),e=0,n=0;for(;e<t.rows&&n<t.columns;){let i=e;for(let o=e;o<t.rows;o++)t.get(o,n)>t.get(i,n)&&(i=o);if(0===t.get(i,n))n++;else{t.swapRows(e,i);let o=t.get(e,n);for(let i=n;i<t.columns;i++)t.set(e,i,t.get(e,i)/o);for(let i=e+1;i<t.rows;i++){let o=t.get(i,n)/t.get(e,n);t.set(i,n,0);for(let s=n+1;s<t.columns;s++)t.set(i,s,t.get(i,s)-t.get(e,s)*o)}e++,n++}}return t}reducedEchelonForm(){let t=this.echelonForm(),e=t.columns,n=t.rows,i=n-1;for(;i>=0;)if(0===t.maxRow(i))i--;else{let o=0,s=!1;for(;o<n&&!1===s;)1===t.get(i,o)?s=!0:o++;for(let n=0;n<i;n++){let s=t.get(n,o);for(let r=o;r<e;r++){let e=t.get(n,r)-s*t.get(i,r);t.set(n,r,e)}}i--}return t}set(){throw new Error("set method is unimplemented")}get(){throw new Error("get method is unimplemented")}repeat(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{rows:e=1,columns:n=1}=t;if(!Number.isInteger(e)||e<=0)throw new TypeError("rows must be a positive integer");if(!Number.isInteger(n)||n<=0)throw new TypeError("columns must be a positive integer");let i=new P(this.rows*e,this.columns*n);for(let t=0;t<e;t++)for(let e=0;e<n;e++)i.setSubMatrix(this,this.rows*t,this.columns*e);return i}fill(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,t);return this}neg(){return this.mulS(-1)}getRow(t){y(this,t);let e=[];for(let n=0;n<this.columns;n++)e.push(this.get(t,n));return e}getRowVector(t){return P.rowVector(this.getRow(t))}setRow(t,e){y(this,t),e=w(this,e);for(let n=0;n<this.columns;n++)this.set(t,n,e[n]);return this}swapRows(t,e){y(this,t),y(this,e);for(let n=0;n<this.columns;n++){let i=this.get(t,n);this.set(t,n,this.get(e,n)),this.set(e,n,i)}return this}getColumn(t){b(this,t);let e=[];for(let n=0;n<this.rows;n++)e.push(this.get(n,t));return e}getColumnVector(t){return P.columnVector(this.getColumn(t))}setColumn(t,e){b(this,t),e=S(this,e);for(let n=0;n<this.rows;n++)this.set(n,t,e[n]);return this}swapColumns(t,e){b(this,t),b(this,e);for(let n=0;n<this.rows;n++){let i=this.get(n,t);this.set(n,t,this.get(n,e)),this.set(n,e,i)}return this}addRowVector(t){t=w(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)+t[n]);return this}subRowVector(t){t=w(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)-t[n]);return this}mulRowVector(t){t=w(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)*t[n]);return this}divRowVector(t){t=w(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)/t[n]);return this}addColumnVector(t){t=S(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)+t[e]);return this}subColumnVector(t){t=S(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)-t[e]);return this}mulColumnVector(t){t=S(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)*t[e]);return this}divColumnVector(t){t=S(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)/t[e]);return this}mulRow(t,e){y(this,t);for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)*e);return this}mulColumn(t,e){b(this,t);for(let n=0;n<this.rows;n++)this.set(n,t,this.get(n,t)*e);return this}max(t){if(this.isEmpty())return NaN;switch(t){case"row":{const t=new Array(this.rows).fill(Number.NEGATIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.get(e,n)>t[e]&&(t[e]=this.get(e,n));return t}case"column":{const t=new Array(this.columns).fill(Number.NEGATIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.get(e,n)>t[n]&&(t[n]=this.get(e,n));return t}case void 0:{let t=this.get(0,0);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.get(e,n)>t&&(t=this.get(e,n));return t}default:throw new Error(`invalid option: ${t}`)}}maxIndex(){E(this);let t=this.get(0,0),e=[0,0];for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.get(n,i)>t&&(t=this.get(n,i),e[0]=n,e[1]=i);return e}min(t){if(this.isEmpty())return NaN;switch(t){case"row":{const t=new Array(this.rows).fill(Number.POSITIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.get(e,n)<t[e]&&(t[e]=this.get(e,n));return t}case"column":{const t=new Array(this.columns).fill(Number.POSITIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.get(e,n)<t[n]&&(t[n]=this.get(e,n));return t}case void 0:{let t=this.get(0,0);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.get(e,n)<t&&(t=this.get(e,n));return t}default:throw new Error(`invalid option: ${t}`)}}minIndex(){E(this);let t=this.get(0,0),e=[0,0];for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.get(n,i)<t&&(t=this.get(n,i),e[0]=n,e[1]=i);return e}maxRow(t){if(y(this,t),this.isEmpty())return NaN;let e=this.get(t,0);for(let n=1;n<this.columns;n++)this.get(t,n)>e&&(e=this.get(t,n));return e}maxRowIndex(t){y(this,t),E(this);let e=this.get(t,0),n=[t,0];for(let i=1;i<this.columns;i++)this.get(t,i)>e&&(e=this.get(t,i),n[1]=i);return n}minRow(t){if(y(this,t),this.isEmpty())return NaN;let e=this.get(t,0);for(let n=1;n<this.columns;n++)this.get(t,n)<e&&(e=this.get(t,n));return e}minRowIndex(t){y(this,t),E(this);let e=this.get(t,0),n=[t,0];for(let i=1;i<this.columns;i++)this.get(t,i)<e&&(e=this.get(t,i),n[1]=i);return n}maxColumn(t){if(b(this,t),this.isEmpty())return NaN;let e=this.get(0,t);for(let n=1;n<this.rows;n++)this.get(n,t)>e&&(e=this.get(n,t));return e}maxColumnIndex(t){b(this,t),E(this);let e=this.get(0,t),n=[0,t];for(let i=1;i<this.rows;i++)this.get(i,t)>e&&(e=this.get(i,t),n[0]=i);return n}minColumn(t){if(b(this,t),this.isEmpty())return NaN;let e=this.get(0,t);for(let n=1;n<this.rows;n++)this.get(n,t)<e&&(e=this.get(n,t));return e}minColumnIndex(t){b(this,t),E(this);let e=this.get(0,t),n=[0,t];for(let i=1;i<this.rows;i++)this.get(i,t)<e&&(e=this.get(i,t),n[0]=i);return n}diag(){let t=Math.min(this.rows,this.columns),e=[];for(let n=0;n<t;n++)e.push(this.get(n,n));return e}norm(t="frobenius"){let e=0;if("max"===t)return this.max();if("frobenius"===t){for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)e+=this.get(t,n)*this.get(t,n);return Math.sqrt(e)}throw new RangeError(`unknown norm type: ${t}`)}cumulativeSum(){let t=0;for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)t+=this.get(e,n),this.set(e,n,t);return this}dot(t){A.isMatrix(t)&&(t=t.to1DArray());let e=this.to1DArray();if(e.length!==t.length)throw new RangeError("vectors do not have the same size");let n=0;for(let i=0;i<e.length;i++)n+=e[i]*t[i];return n}mmul(t){t=P.checkMatrix(t);let e=this.rows,n=this.columns,i=t.columns,o=new P(e,i),s=new Float64Array(n);for(let r=0;r<i;r++){for(let e=0;e<n;e++)s[e]=t.get(e,r);for(let t=0;t<e;t++){let e=0;for(let i=0;i<n;i++)e+=this.get(t,i)*s[i];o.set(t,r,e)}}return o}strassen2x2(t){t=P.checkMatrix(t);let e=new P(2,2);const n=this.get(0,0),i=t.get(0,0),o=this.get(0,1),s=t.get(0,1),r=this.get(1,0),a=t.get(1,0),l=this.get(1,1),c=t.get(1,1),h=(n+l)*(i+c),u=(r+l)*i,d=n*(s-c),f=l*(a-i),m=(n+o)*c,p=h+f-m+(o-l)*(a+c),g=d+m,v=u+f,y=h-u+d+(r-n)*(i+s);return e.set(0,0,p),e.set(0,1,g),e.set(1,0,v),e.set(1,1,y),e}strassen3x3(t){t=P.checkMatrix(t);let e=new P(3,3);const n=this.get(0,0),i=this.get(0,1),o=this.get(0,2),s=this.get(1,0),r=this.get(1,1),a=this.get(1,2),l=this.get(2,0),c=this.get(2,1),h=this.get(2,2),u=t.get(0,0),d=t.get(0,1),f=t.get(0,2),m=t.get(1,0),p=t.get(1,1),g=t.get(1,2),v=t.get(2,0),y=t.get(2,1),b=t.get(2,2),w=(n-s)*(-d+p),S=(-n+s+r)*(u-d+p),C=(s+r)*(-u+d),T=n*u,M=(-n+l+c)*(u-f+g),E=(-n+l)*(f-g),A=(l+c)*(-u+f),N=(-o+c+h)*(p+v-y),x=(o-h)*(p-y),_=o*v,R=(c+h)*(-v+y),L=(-o+r+a)*(g+v-b),I=(o-a)*(g-b),G=(r+a)*(-v+b),D=T+_+i*m,W=(n+i+o-s-r-c-h)*p+S+C+T+N+_+R,F=T+M+A+(n+i+o-r-a-l-c)*g+_+L+G,H=w+r*(-u+d+m-p-g-v+b)+S+T+_+L+I,k=w+S+C+T+a*y,O=_+L+I+G+s*f,V=T+M+E+c*(-u+f+m-p-g-v+y)+N+x+_,U=N+x+_+R+l*d,B=T+M+E+A+h*b;return e.set(0,0,D),e.set(0,1,W),e.set(0,2,F),e.set(1,0,H),e.set(1,1,k),e.set(1,2,O),e.set(2,0,V),e.set(2,1,U),e.set(2,2,B),e}mmulStrassen(t){t=P.checkMatrix(t);let e=this.clone(),n=e.rows,i=e.columns,o=t.rows,s=t.columns;function r(t,e,n){let i=t.rows,o=t.columns;if(i===e&&o===n)return t;{let i=A.zeros(e,n);return i=i.setSubMatrix(t,0,0),i}}i!==o&&console.warn(`Multiplying ${n} x ${i} and ${o} x ${s} matrix: dimensions do not match.`);let a=Math.max(n,o),l=Math.max(i,s);return e=r(e,a,l),function t(e,n,i,o){if(i<=512||o<=512)return e.mmul(n);i%2==1&&o%2==1?(e=r(e,i+1,o+1),n=r(n,i+1,o+1)):i%2==1?(e=r(e,i+1,o),n=r(n,i+1,o)):o%2==1&&(e=r(e,i,o+1),n=r(n,i,o+1));let s=parseInt(e.rows/2,10),a=parseInt(e.columns/2,10),l=e.subMatrix(0,s-1,0,a-1),c=n.subMatrix(0,s-1,0,a-1),h=e.subMatrix(0,s-1,a,e.columns-1),u=n.subMatrix(0,s-1,a,n.columns-1),d=e.subMatrix(s,e.rows-1,0,a-1),f=n.subMatrix(s,n.rows-1,0,a-1),m=e.subMatrix(s,e.rows-1,a,e.columns-1),p=n.subMatrix(s,n.rows-1,a,n.columns-1),g=t(A.add(l,m),A.add(c,p),s,a),v=t(A.add(d,m),c,s,a),y=t(l,A.sub(u,p),s,a),b=t(m,A.sub(f,c),s,a),w=t(A.add(l,h),p,s,a),S=t(A.sub(d,l),A.add(c,u),s,a),C=t(A.sub(h,m),A.add(f,p),s,a),T=A.add(g,b);T.sub(w),T.add(C);let M=A.add(y,w),E=A.add(v,b),N=A.sub(g,v);N.add(y),N.add(S);let P=A.zeros(2*T.rows,2*T.columns);return P=P.setSubMatrix(T,0,0),P=P.setSubMatrix(M,T.rows,0),P=P.setSubMatrix(E,0,T.columns),P=P.setSubMatrix(N,T.rows,T.columns),P.subMatrix(0,i-1,0,o-1)}(e,t=r(t,a,l),a,l)}scaleRows(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{min:e=0,max:n=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(n))throw new TypeError("max must be a number");if(e>=n)throw new RangeError("min must be smaller than max");let i=new P(this.rows,this.columns);for(let t=0;t<this.rows;t++){const o=this.getRow(t);o.length>0&&d(o,{min:e,max:n,output:o}),i.setRow(t,o)}return i}scaleColumns(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{min:e=0,max:n=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(n))throw new TypeError("max must be a number");if(e>=n)throw new RangeError("min must be smaller than max");let i=new P(this.rows,this.columns);for(let t=0;t<this.columns;t++){const o=this.getColumn(t);o.length&&d(o,{min:e,max:n,output:o}),i.setColumn(t,o)}return i}flipRows(){const t=Math.ceil(this.columns/2);for(let e=0;e<this.rows;e++)for(let n=0;n<t;n++){let t=this.get(e,n),i=this.get(e,this.columns-1-n);this.set(e,n,i),this.set(e,this.columns-1-n,t)}return this}flipColumns(){const t=Math.ceil(this.rows/2);for(let e=0;e<this.columns;e++)for(let n=0;n<t;n++){let t=this.get(n,e),i=this.get(this.rows-1-n,e);this.set(n,e,i),this.set(this.rows-1-n,e,t)}return this}kroneckerProduct(t){t=P.checkMatrix(t);let e=this.rows,n=this.columns,i=t.rows,o=t.columns,s=new P(e*i,n*o);for(let r=0;r<e;r++)for(let e=0;e<n;e++)for(let n=0;n<i;n++)for(let a=0;a<o;a++)s.set(i*r+n,o*e+a,this.get(r,e)*t.get(n,a));return s}kroneckerSum(t){if(t=P.checkMatrix(t),!this.isSquare()||!t.isSquare())throw new Error("Kronecker Sum needs two Square Matrices");let e=this.rows,n=t.rows,i=this.kroneckerProduct(P.eye(n,n)),o=P.eye(e,e).kroneckerProduct(t);return i.add(o)}transpose(){let t=new P(this.columns,this.rows);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)t.set(n,e,this.get(e,n));return t}sortRows(t=N){for(let e=0;e<this.rows;e++)this.setRow(e,this.getRow(e).sort(t));return this}sortColumns(t=N){for(let e=0;e<this.columns;e++)this.setColumn(e,this.getColumn(e).sort(t));return this}subMatrix(t,e,n,i){C(this,t,e,n,i);let o=new P(e-t+1,i-n+1);for(let s=t;s<=e;s++)for(let e=n;e<=i;e++)o.set(s-t,e-n,this.get(s,e));return o}subMatrixRow(t,e,n){if(void 0===e&&(e=0),void 0===n&&(n=this.columns-1),e>n||e<0||e>=this.columns||n<0||n>=this.columns)throw new RangeError("Argument out of range");let i=new P(t.length,n-e+1);for(let o=0;o<t.length;o++)for(let s=e;s<=n;s++){if(t[o]<0||t[o]>=this.rows)throw new RangeError(`Row index out of range: ${t[o]}`);i.set(o,s-e,this.get(t[o],s))}return i}subMatrixColumn(t,e,n){if(void 0===e&&(e=0),void 0===n&&(n=this.rows-1),e>n||e<0||e>=this.rows||n<0||n>=this.rows)throw new RangeError("Argument out of range");let i=new P(n-e+1,t.length);for(let o=0;o<t.length;o++)for(let s=e;s<=n;s++){if(t[o]<0||t[o]>=this.columns)throw new RangeError(`Column index out of range: ${t[o]}`);i.set(s-e,o,this.get(s,t[o]))}return i}setSubMatrix(t,e,n){if((t=P.checkMatrix(t)).isEmpty())return this;C(this,e,e+t.rows-1,n,n+t.columns-1);for(let i=0;i<t.rows;i++)for(let o=0;o<t.columns;o++)this.set(e+i,n+o,t.get(i,o));return this}selection(t,e){!function(t,e){if(!a(e))throw new TypeError("row indices must be an array");for(let n=0;n<e.length;n++)if(e[n]<0||e[n]>=t.rows)throw new RangeError("row indices are out of range")}(this,t),function(t,e){if(!a(e))throw new TypeError("column indices must be an array");for(let n=0;n<e.length;n++)if(e[n]<0||e[n]>=t.columns)throw new RangeError("column indices are out of range")}(this,e);let n=new P(t.length,e.length);for(let i=0;i<t.length;i++){let o=t[i];for(let t=0;t<e.length;t++){let s=e[t];n.set(i,t,this.get(o,s))}}return n}trace(){let t=Math.min(this.rows,this.columns),e=0;for(let n=0;n<t;n++)e+=this.get(n,n);return e}clone(){let t=new P(this.rows,this.columns);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)t.set(e,n,this.get(e,n));return t}sum(t){switch(t){case"row":return function(t){let e=T(t.rows);for(let n=0;n<t.rows;++n)for(let i=0;i<t.columns;++i)e[n]+=t.get(n,i);return e}(this);case"column":return function(t){let e=T(t.columns);for(let n=0;n<t.rows;++n)for(let i=0;i<t.columns;++i)e[i]+=t.get(n,i);return e}(this);case void 0:return function(t){let e=0;for(let n=0;n<t.rows;n++)for(let i=0;i<t.columns;i++)e+=t.get(n,i);return e}(this);default:throw new Error(`invalid option: ${t}`)}}product(t){switch(t){case"row":return function(t){let e=T(t.rows,1);for(let n=0;n<t.rows;++n)for(let i=0;i<t.columns;++i)e[n]*=t.get(n,i);return e}(this);case"column":return function(t){let e=T(t.columns,1);for(let n=0;n<t.rows;++n)for(let i=0;i<t.columns;++i)e[i]*=t.get(n,i);return e}(this);case void 0:return function(t){let e=1;for(let n=0;n<t.rows;n++)for(let i=0;i<t.columns;i++)e*=t.get(n,i);return e}(this);default:throw new Error(`invalid option: ${t}`)}}mean(t){const e=this.sum(t);switch(t){case"row":for(let t=0;t<this.rows;t++)e[t]/=this.columns;return e;case"column":for(let t=0;t<this.columns;t++)e[t]/=this.rows;return e;case void 0:return e/this.size;default:throw new Error(`invalid option: ${t}`)}}variance(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");const{unbiased:n=!0,mean:i=this.mean(t)}=e;if("boolean"!=typeof n)throw new TypeError("unbiased must be a boolean");switch(t){case"row":if(!a(i))throw new TypeError("mean must be an array");return function(t,e,n){const i=t.rows,o=t.columns,s=[];for(let r=0;r<i;r++){let i=0,a=0,l=0;for(let e=0;e<o;e++)l=t.get(r,e)-n[r],i+=l,a+=l*l;e?s.push((a-i*i/o)/(o-1)):s.push((a-i*i/o)/o)}return s}(this,n,i);case"column":if(!a(i))throw new TypeError("mean must be an array");return function(t,e,n){const i=t.rows,o=t.columns,s=[];for(let r=0;r<o;r++){let o=0,a=0,l=0;for(let e=0;e<i;e++)l=t.get(e,r)-n[r],o+=l,a+=l*l;e?s.push((a-o*o/i)/(i-1)):s.push((a-o*o/i)/i)}return s}(this,n,i);case void 0:if("number"!=typeof i)throw new TypeError("mean must be a number");return function(t,e,n){const i=t.rows,o=t.columns,s=i*o;let r=0,a=0,l=0;for(let e=0;e<i;e++)for(let i=0;i<o;i++)l=t.get(e,i)-n,r+=l,a+=l*l;return e?(a-r*r/s)/(s-1):(a-r*r/s)/s}(this,n,i);default:throw new Error(`invalid option: ${t}`)}}standardDeviation(t,e){"object"==typeof t&&(e=t,t=void 0);const n=this.variance(t,e);if(void 0===t)return Math.sqrt(n);for(let t=0;t<n.length;t++)n[t]=Math.sqrt(n[t]);return n}center(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");const{center:n=this.mean(t)}=e;switch(t){case"row":if(!a(n))throw new TypeError("center must be an array");return function(t,e){for(let n=0;n<t.rows;n++)for(let i=0;i<t.columns;i++)t.set(n,i,t.get(n,i)-e[n])}(this,n),this;case"column":if(!a(n))throw new TypeError("center must be an array");return function(t,e){for(let n=0;n<t.rows;n++)for(let i=0;i<t.columns;i++)t.set(n,i,t.get(n,i)-e[i])}(this,n),this;case void 0:if("number"!=typeof n)throw new TypeError("center must be a number");return function(t,e){for(let n=0;n<t.rows;n++)for(let i=0;i<t.columns;i++)t.set(n,i,t.get(n,i)-e)}(this,n),this;default:throw new Error(`invalid option: ${t}`)}}scale(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");let n=e.scale;switch(t){case"row":if(void 0===n)n=function(t){const e=[];for(let n=0;n<t.rows;n++){let i=0;for(let e=0;e<t.columns;e++)i+=Math.pow(t.get(n,e),2)/(t.columns-1);e.push(Math.sqrt(i))}return e}(this);else if(!a(n))throw new TypeError("scale must be an array");return function(t,e){for(let n=0;n<t.rows;n++)for(let i=0;i<t.columns;i++)t.set(n,i,t.get(n,i)/e[n])}(this,n),this;case"column":if(void 0===n)n=function(t){const e=[];for(let n=0;n<t.columns;n++){let i=0;for(let e=0;e<t.rows;e++)i+=Math.pow(t.get(e,n),2)/(t.rows-1);e.push(Math.sqrt(i))}return e}(this);else if(!a(n))throw new TypeError("scale must be an array");return function(t,e){for(let n=0;n<t.rows;n++)for(let i=0;i<t.columns;i++)t.set(n,i,t.get(n,i)/e[i])}(this,n),this;case void 0:if(void 0===n)n=function(t){const e=t.size-1;let n=0;for(let i=0;i<t.columns;i++)for(let o=0;o<t.rows;o++)n+=Math.pow(t.get(o,i),2)/e;return Math.sqrt(n)}(this);else if("number"!=typeof n)throw new TypeError("scale must be a number");return function(t,e){for(let n=0;n<t.rows;n++)for(let i=0;i<t.columns;i++)t.set(n,i,t.get(n,i)/e)}(this,n),this;default:throw new Error(`invalid option: ${t}`)}}toString(t){return p(this,t)}}function N(t,e){return t-e}A.prototype.klass="Matrix","undefined"!=typeof Symbol&&(A.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return p(this)}),A.random=A.rand,A.randomInt=A.randInt,A.diagonal=A.diag,A.prototype.diagonal=A.prototype.diag,A.identity=A.eye,A.prototype.negate=A.prototype.neg,A.prototype.tensorProduct=A.prototype.kroneckerProduct;class P extends A{constructor(t,e){if(super(),P.isMatrix(t))return t.clone();if(Number.isInteger(t)&&t>=0){if(this.data=[],!(Number.isInteger(e)&&e>=0))throw new TypeError("nColumns must be a positive integer");for(let n=0;n<t;n++)this.data.push(new Float64Array(e))}else{if(!a(t))throw new TypeError("First argument must be a positive number or an array");{const n=t;if("number"!=typeof(e=(t=n.length)?n[0].length:0))throw new TypeError("Data must be a 2D array with at least one element");this.data=[];for(let i=0;i<t;i++){if(n[i].length!==e)throw new RangeError("Inconsistent array dimensions");if(!n[i].every((t=>"number"==typeof t)))throw new TypeError("Input data contains non-numeric values");this.data.push(Float64Array.from(n[i]))}}}this.rows=t,this.columns=e}set(t,e,n){return this.data[t][e]=n,this}get(t,e){return this.data[t][e]}removeRow(t){return y(this,t),this.data.splice(t,1),this.rows-=1,this}addRow(t,e){return void 0===e&&(e=t,t=this.rows),y(this,t,!0),e=Float64Array.from(w(this,e)),this.data.splice(t,0,e),this.rows+=1,this}removeColumn(t){b(this,t);for(let e=0;e<this.rows;e++){const n=new Float64Array(this.columns-1);for(let i=0;i<t;i++)n[i]=this.data[e][i];for(let i=t+1;i<this.columns;i++)n[i-1]=this.data[e][i];this.data[e]=n}return this.columns-=1,this}addColumn(t,e){void 0===e&&(e=t,t=this.columns),b(this,t,!0),e=S(this,e);for(let n=0;n<this.rows;n++){const i=new Float64Array(this.columns+1);let o=0;for(;o<t;o++)i[o]=this.data[n][o];for(i[o++]=e[n];o<this.columns+1;o++)i[o]=this.data[n][o-1];this.data[n]=i}return this.columns+=1,this}}!function(t,e){t.prototype.add=function(t){return"number"==typeof t?this.addS(t):this.addM(t)},t.prototype.addS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)+t);return this},t.prototype.addM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)+t.get(e,n));return this},t.add=function(t,n){return new e(t).add(n)},t.prototype.sub=function(t){return"number"==typeof t?this.subS(t):this.subM(t)},t.prototype.subS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)-t);return this},t.prototype.subM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)-t.get(e,n));return this},t.sub=function(t,n){return new e(t).sub(n)},t.prototype.subtract=t.prototype.sub,t.prototype.subtractS=t.prototype.subS,t.prototype.subtractM=t.prototype.subM,t.subtract=t.sub,t.prototype.mul=function(t){return"number"==typeof t?this.mulS(t):this.mulM(t)},t.prototype.mulS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)*t);return this},t.prototype.mulM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)*t.get(e,n));return this},t.mul=function(t,n){return new e(t).mul(n)},t.prototype.multiply=t.prototype.mul,t.prototype.multiplyS=t.prototype.mulS,t.prototype.multiplyM=t.prototype.mulM,t.multiply=t.mul,t.prototype.div=function(t){return"number"==typeof t?this.divS(t):this.divM(t)},t.prototype.divS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)/t);return this},t.prototype.divM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)/t.get(e,n));return this},t.div=function(t,n){return new e(t).div(n)},t.prototype.divide=t.prototype.div,t.prototype.divideS=t.prototype.divS,t.prototype.divideM=t.prototype.divM,t.divide=t.div,t.prototype.mod=function(t){return"number"==typeof t?this.modS(t):this.modM(t)},t.prototype.modS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)%t);return this},t.prototype.modM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)%t.get(e,n));return this},t.mod=function(t,n){return new e(t).mod(n)},t.prototype.modulus=t.prototype.mod,t.prototype.modulusS=t.prototype.modS,t.prototype.modulusM=t.prototype.modM,t.modulus=t.mod,t.prototype.and=function(t){return"number"==typeof t?this.andS(t):this.andM(t)},t.prototype.andS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)&t);return this},t.prototype.andM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)&t.get(e,n));return this},t.and=function(t,n){return new e(t).and(n)},t.prototype.or=function(t){return"number"==typeof t?this.orS(t):this.orM(t)},t.prototype.orS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)|t);return this},t.prototype.orM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)|t.get(e,n));return this},t.or=function(t,n){return new e(t).or(n)},t.prototype.xor=function(t){return"number"==typeof t?this.xorS(t):this.xorM(t)},t.prototype.xorS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)^t);return this},t.prototype.xorM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)^t.get(e,n));return this},t.xor=function(t,n){return new e(t).xor(n)},t.prototype.leftShift=function(t){return"number"==typeof t?this.leftShiftS(t):this.leftShiftM(t)},t.prototype.leftShiftS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)<<t);return this},t.prototype.leftShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)<<t.get(e,n));return this},t.leftShift=function(t,n){return new e(t).leftShift(n)},t.prototype.signPropagatingRightShift=function(t){return"number"==typeof t?this.signPropagatingRightShiftS(t):this.signPropagatingRightShiftM(t)},t.prototype.signPropagatingRightShiftS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)>>t);return this},t.prototype.signPropagatingRightShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)>>t.get(e,n));return this},t.signPropagatingRightShift=function(t,n){return new e(t).signPropagatingRightShift(n)},t.prototype.rightShift=function(t){return"number"==typeof t?this.rightShiftS(t):this.rightShiftM(t)},t.prototype.rightShiftS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)>>>t);return this},t.prototype.rightShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)>>>t.get(e,n));return this},t.rightShift=function(t,n){return new e(t).rightShift(n)},t.prototype.zeroFillRightShift=t.prototype.rightShift,t.prototype.zeroFillRightShiftS=t.prototype.rightShiftS,t.prototype.zeroFillRightShiftM=t.prototype.rightShiftM,t.zeroFillRightShift=t.rightShift,t.prototype.not=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,~this.get(t,e));return this},t.not=function(t){return new e(t).not()},t.prototype.abs=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.abs(this.get(t,e)));return this},t.abs=function(t){return new e(t).abs()},t.prototype.acos=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.acos(this.get(t,e)));return this},t.acos=function(t){return new e(t).acos()},t.prototype.acosh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.acosh(this.get(t,e)));return this},t.acosh=function(t){return new e(t).acosh()},t.prototype.asin=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.asin(this.get(t,e)));return this},t.asin=function(t){return new e(t).asin()},t.prototype.asinh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.asinh(this.get(t,e)));return this},t.asinh=function(t){return new e(t).asinh()},t.prototype.atan=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.atan(this.get(t,e)));return this},t.atan=function(t){return new e(t).atan()},t.prototype.atanh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.atanh(this.get(t,e)));return this},t.atanh=function(t){return new e(t).atanh()},t.prototype.cbrt=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.cbrt(this.get(t,e)));return this},t.cbrt=function(t){return new e(t).cbrt()},t.prototype.ceil=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.ceil(this.get(t,e)));return this},t.ceil=function(t){return new e(t).ceil()},t.prototype.clz32=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.clz32(this.get(t,e)));return this},t.clz32=function(t){return new e(t).clz32()},t.prototype.cos=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.cos(this.get(t,e)));return this},t.cos=function(t){return new e(t).cos()},t.prototype.cosh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.cosh(this.get(t,e)));return this},t.cosh=function(t){return new e(t).cosh()},t.prototype.exp=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.exp(this.get(t,e)));return this},t.exp=function(t){return new e(t).exp()},t.prototype.expm1=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.expm1(this.get(t,e)));return this},t.expm1=function(t){return new e(t).expm1()},t.prototype.floor=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.floor(this.get(t,e)));return this},t.floor=function(t){return new e(t).floor()},t.prototype.fround=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.fround(this.get(t,e)));return this},t.fround=function(t){return new e(t).fround()},t.prototype.log=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log(this.get(t,e)));return this},t.log=function(t){return new e(t).log()},t.prototype.log1p=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log1p(this.get(t,e)));return this},t.log1p=function(t){return new e(t).log1p()},t.prototype.log10=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log10(this.get(t,e)));return this},t.log10=function(t){return new e(t).log10()},t.prototype.log2=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log2(this.get(t,e)));return this},t.log2=function(t){return new e(t).log2()},t.prototype.round=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.round(this.get(t,e)));return this},t.round=function(t){return new e(t).round()},t.prototype.sign=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sign(this.get(t,e)));return this},t.sign=function(t){return new e(t).sign()},t.prototype.sin=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sin(this.get(t,e)));return this},t.sin=function(t){return new e(t).sin()},t.prototype.sinh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sinh(this.get(t,e)));return this},t.sinh=function(t){return new e(t).sinh()},t.prototype.sqrt=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sqrt(this.get(t,e)));return this},t.sqrt=function(t){return new e(t).sqrt()},t.prototype.tan=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.tan(this.get(t,e)));return this},t.tan=function(t){return new e(t).tan()},t.prototype.tanh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.tanh(this.get(t,e)));return this},t.tanh=function(t){return new e(t).tanh()},t.prototype.trunc=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.trunc(this.get(t,e)));return this},t.trunc=function(t){return new e(t).trunc()},t.pow=function(t,n){return new e(t).pow(n)},t.prototype.pow=function(t){return"number"==typeof t?this.powS(t):this.powM(t)},t.prototype.powS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,Math.pow(this.get(e,n),t));return this},t.prototype.powM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,Math.pow(this.get(e,n),t.get(e,n)));return this}}(A,P);class x extends A{constructor(t){super(),this.data=t,this.rows=t.length,this.columns=t[0].length}set(t,e,n){return this.data[t][e]=n,this}get(t,e){return this.data[t][e]}}class _{constructor(t){let e,n,i,o,s,r,a,l,c,h=(t=x.checkMatrix(t)).clone(),u=h.rows,d=h.columns,f=new Float64Array(u),m=1;for(e=0;e<u;e++)f[e]=e;for(l=new Float64Array(u),n=0;n<d;n++){for(e=0;e<u;e++)l[e]=h.get(e,n);for(e=0;e<u;e++){for(c=Math.min(e,n),s=0,i=0;i<c;i++)s+=h.get(e,i)*l[i];l[e]-=s,h.set(e,n,l[e])}for(o=n,e=n+1;e<u;e++)Math.abs(l[e])>Math.abs(l[o])&&(o=e);if(o!==n){for(i=0;i<d;i++)r=h.get(o,i),h.set(o,i,h.get(n,i)),h.set(n,i,r);a=f[o],f[o]=f[n],f[n]=a,m=-m}if(n<u&&0!==h.get(n,n))for(e=n+1;e<u;e++)h.set(e,n,h.get(e,n)/h.get(n,n))}this.LU=h,this.pivotVector=f,this.pivotSign=m}isSingular(){let t=this.LU,e=t.columns;for(let n=0;n<e;n++)if(0===t.get(n,n))return!0;return!1}solve(t){t=P.checkMatrix(t);let e=this.LU;if(e.rows!==t.rows)throw new Error("Invalid matrix dimensions");if(this.isSingular())throw new Error("LU matrix is singular");let n,i,o,s=t.columns,r=t.subMatrixRow(this.pivotVector,0,s-1),a=e.columns;for(o=0;o<a;o++)for(n=o+1;n<a;n++)for(i=0;i<s;i++)r.set(n,i,r.get(n,i)-r.get(o,i)*e.get(n,o));for(o=a-1;o>=0;o--){for(i=0;i<s;i++)r.set(o,i,r.get(o,i)/e.get(o,o));for(n=0;n<o;n++)for(i=0;i<s;i++)r.set(n,i,r.get(n,i)-r.get(o,i)*e.get(n,o))}return r}get determinant(){let t=this.LU;if(!t.isSquare())throw new Error("Matrix must be square");let e=this.pivotSign,n=t.columns;for(let i=0;i<n;i++)e*=t.get(i,i);return e}get lowerTriangularMatrix(){let t=this.LU,e=t.rows,n=t.columns,i=new P(e,n);for(let o=0;o<e;o++)for(let e=0;e<n;e++)o>e?i.set(o,e,t.get(o,e)):o===e?i.set(o,e,1):i.set(o,e,0);return i}get upperTriangularMatrix(){let t=this.LU,e=t.rows,n=t.columns,i=new P(e,n);for(let o=0;o<e;o++)for(let e=0;e<n;e++)o<=e?i.set(o,e,t.get(o,e)):i.set(o,e,0);return i}get pivotPermutationVector(){return Array.from(this.pivotVector)}}function R(t,e){let n=0;return Math.abs(t)>Math.abs(e)?(n=e/t,Math.abs(t)*Math.sqrt(1+n*n)):0!==e?(n=t/e,Math.abs(e)*Math.sqrt(1+n*n)):0}class L{constructor(t){let e,n,i,o,s=(t=x.checkMatrix(t)).clone(),r=t.rows,a=t.columns,l=new Float64Array(a);for(i=0;i<a;i++){let t=0;for(e=i;e<r;e++)t=R(t,s.get(e,i));if(0!==t){for(s.get(i,i)<0&&(t=-t),e=i;e<r;e++)s.set(e,i,s.get(e,i)/t);for(s.set(i,i,s.get(i,i)+1),n=i+1;n<a;n++){for(o=0,e=i;e<r;e++)o+=s.get(e,i)*s.get(e,n);for(o=-o/s.get(i,i),e=i;e<r;e++)s.set(e,n,s.get(e,n)+o*s.get(e,i))}}l[i]=-t}this.QR=s,this.Rdiag=l}solve(t){t=P.checkMatrix(t);let e=this.QR,n=e.rows;if(t.rows!==n)throw new Error("Matrix row dimensions must agree");if(!this.isFullRank())throw new Error("Matrix is rank deficient");let i,o,s,r,a=t.columns,l=t.clone(),c=e.columns;for(s=0;s<c;s++)for(o=0;o<a;o++){for(r=0,i=s;i<n;i++)r+=e.get(i,s)*l.get(i,o);for(r=-r/e.get(s,s),i=s;i<n;i++)l.set(i,o,l.get(i,o)+r*e.get(i,s))}for(s=c-1;s>=0;s--){for(o=0;o<a;o++)l.set(s,o,l.get(s,o)/this.Rdiag[s]);for(i=0;i<s;i++)for(o=0;o<a;o++)l.set(i,o,l.get(i,o)-l.get(s,o)*e.get(i,s))}return l.subMatrix(0,c-1,0,a-1)}isFullRank(){let t=this.QR.columns;for(let e=0;e<t;e++)if(0===this.Rdiag[e])return!1;return!0}get upperTriangularMatrix(){let t,e,n=this.QR,i=n.columns,o=new P(i,i);for(t=0;t<i;t++)for(e=0;e<i;e++)t<e?o.set(t,e,n.get(t,e)):t===e?o.set(t,e,this.Rdiag[t]):o.set(t,e,0);return o}get orthogonalMatrix(){let t,e,n,i,o=this.QR,s=o.rows,r=o.columns,a=new P(s,r);for(n=r-1;n>=0;n--){for(t=0;t<s;t++)a.set(t,n,0);for(a.set(n,n,1),e=n;e<r;e++)if(0!==o.get(n,n)){for(i=0,t=n;t<s;t++)i+=o.get(t,n)*a.get(t,e);for(i=-i/o.get(n,n),t=n;t<s;t++)a.set(t,e,a.get(t,e)+i*o.get(t,n))}}return a}}class I{constructor(t,e={}){if((t=x.checkMatrix(t)).isEmpty())throw new Error("Matrix must be non-empty");let n=t.rows,i=t.columns;const{computeLeftSingularVectors:o=!0,computeRightSingularVectors:s=!0,autoTranspose:r=!1}=e;let a,l=Boolean(o),c=Boolean(s),h=!1;if(n<i)if(r){a=t.transpose(),n=a.rows,i=a.columns,h=!0;let e=l;l=c,c=e}else a=t.clone(),console.warn("Computing SVD on a matrix with more columns than rows. Consider enabling autoTranspose");else a=t.clone();let u=Math.min(n,i),d=Math.min(n+1,i),f=new Float64Array(d),m=new P(n,u),p=new P(i,i),g=new Float64Array(i),v=new Float64Array(n),y=new Float64Array(d);for(let t=0;t<d;t++)y[t]=t;let b=Math.min(n-1,i),w=Math.max(0,Math.min(i-2,n)),S=Math.max(b,w);for(let t=0;t<S;t++){if(t<b){f[t]=0;for(let e=t;e<n;e++)f[t]=R(f[t],a.get(e,t));if(0!==f[t]){a.get(t,t)<0&&(f[t]=-f[t]);for(let e=t;e<n;e++)a.set(e,t,a.get(e,t)/f[t]);a.set(t,t,a.get(t,t)+1)}f[t]=-f[t]}for(let e=t+1;e<i;e++){if(t<b&&0!==f[t]){let i=0;for(let o=t;o<n;o++)i+=a.get(o,t)*a.get(o,e);i=-i/a.get(t,t);for(let o=t;o<n;o++)a.set(o,e,a.get(o,e)+i*a.get(o,t))}g[e]=a.get(t,e)}if(l&&t<b)for(let e=t;e<n;e++)m.set(e,t,a.get(e,t));if(t<w){g[t]=0;for(let e=t+1;e<i;e++)g[t]=R(g[t],g[e]);if(0!==g[t]){g[t+1]<0&&(g[t]=0-g[t]);for(let e=t+1;e<i;e++)g[e]/=g[t];g[t+1]+=1}if(g[t]=-g[t],t+1<n&&0!==g[t]){for(let e=t+1;e<n;e++)v[e]=0;for(let e=t+1;e<n;e++)for(let n=t+1;n<i;n++)v[e]+=g[n]*a.get(e,n);for(let e=t+1;e<i;e++){let i=-g[e]/g[t+1];for(let o=t+1;o<n;o++)a.set(o,e,a.get(o,e)+i*v[o])}}if(c)for(let e=t+1;e<i;e++)p.set(e,t,g[e])}}let C=Math.min(i,n+1);if(b<i&&(f[b]=a.get(b,b)),n<C&&(f[C-1]=0),w+1<C&&(g[w]=a.get(w,C-1)),g[C-1]=0,l){for(let t=b;t<u;t++){for(let e=0;e<n;e++)m.set(e,t,0);m.set(t,t,1)}for(let t=b-1;t>=0;t--)if(0!==f[t]){for(let e=t+1;e<u;e++){let i=0;for(let o=t;o<n;o++)i+=m.get(o,t)*m.get(o,e);i=-i/m.get(t,t);for(let o=t;o<n;o++)m.set(o,e,m.get(o,e)+i*m.get(o,t))}for(let e=t;e<n;e++)m.set(e,t,-m.get(e,t));m.set(t,t,1+m.get(t,t));for(let e=0;e<t-1;e++)m.set(e,t,0)}else{for(let e=0;e<n;e++)m.set(e,t,0);m.set(t,t,1)}}if(c)for(let t=i-1;t>=0;t--){if(t<w&&0!==g[t])for(let e=t+1;e<i;e++){let n=0;for(let o=t+1;o<i;o++)n+=p.get(o,t)*p.get(o,e);n=-n/p.get(t+1,t);for(let o=t+1;o<i;o++)p.set(o,e,p.get(o,e)+n*p.get(o,t))}for(let e=0;e<i;e++)p.set(e,t,0);p.set(t,t,1)}let T=C-1,M=0,E=Number.EPSILON;for(;C>0;){let t,e;for(t=C-2;t>=-1&&-1!==t;t--){const e=Number.MIN_VALUE+E*Math.abs(f[t]+Math.abs(f[t+1]));if(Math.abs(g[t])<=e||Number.isNaN(g[t])){g[t]=0;break}}if(t===C-2)e=4;else{let n;for(n=C-1;n>=t&&n!==t;n--){let e=(n!==C?Math.abs(g[n]):0)+(n!==t+1?Math.abs(g[n-1]):0);if(Math.abs(f[n])<=E*e){f[n]=0;break}}n===t?e=3:n===C-1?e=1:(e=2,t=n)}switch(t++,e){case 1:{let e=g[C-2];g[C-2]=0;for(let n=C-2;n>=t;n--){let o=R(f[n],e),s=f[n]/o,r=e/o;if(f[n]=o,n!==t&&(e=-r*g[n-1],g[n-1]=s*g[n-1]),c)for(let t=0;t<i;t++)o=s*p.get(t,n)+r*p.get(t,C-1),p.set(t,C-1,-r*p.get(t,n)+s*p.get(t,C-1)),p.set(t,n,o)}break}case 2:{let e=g[t-1];g[t-1]=0;for(let i=t;i<C;i++){let o=R(f[i],e),s=f[i]/o,r=e/o;if(f[i]=o,e=-r*g[i],g[i]=s*g[i],l)for(let e=0;e<n;e++)o=s*m.get(e,i)+r*m.get(e,t-1),m.set(e,t-1,-r*m.get(e,i)+s*m.get(e,t-1)),m.set(e,i,o)}break}case 3:{const e=Math.max(Math.abs(f[C-1]),Math.abs(f[C-2]),Math.abs(g[C-2]),Math.abs(f[t]),Math.abs(g[t])),o=f[C-1]/e,s=f[C-2]/e,r=g[C-2]/e,a=f[t]/e,h=g[t]/e,u=((s+o)*(s-o)+r*r)/2,d=o*r*(o*r);let v=0;0===u&&0===d||(v=u<0?0-Math.sqrt(u*u+d):Math.sqrt(u*u+d),v=d/(u+v));let y=(a+o)*(a-o)+v,b=a*h;for(let e=t;e<C-1;e++){let o=R(y,b);0===o&&(o=Number.MIN_VALUE);let s=y/o,r=b/o;if(e!==t&&(g[e-1]=o),y=s*f[e]+r*g[e],g[e]=s*g[e]-r*f[e],b=r*f[e+1],f[e+1]=s*f[e+1],c)for(let t=0;t<i;t++)o=s*p.get(t,e)+r*p.get(t,e+1),p.set(t,e+1,-r*p.get(t,e)+s*p.get(t,e+1)),p.set(t,e,o);if(o=R(y,b),0===o&&(o=Number.MIN_VALUE),s=y/o,r=b/o,f[e]=o,y=s*g[e]+r*f[e+1],f[e+1]=-r*g[e]+s*f[e+1],b=r*g[e+1],g[e+1]=s*g[e+1],l&&e<n-1)for(let t=0;t<n;t++)o=s*m.get(t,e)+r*m.get(t,e+1),m.set(t,e+1,-r*m.get(t,e)+s*m.get(t,e+1)),m.set(t,e,o)}g[C-2]=y,M+=1;break}case 4:if(f[t]<=0&&(f[t]=f[t]<0?-f[t]:0,c))for(let e=0;e<=T;e++)p.set(e,t,-p.get(e,t));for(;t<T&&!(f[t]>=f[t+1]);){let e=f[t];if(f[t]=f[t+1],f[t+1]=e,c&&t<i-1)for(let n=0;n<i;n++)e=p.get(n,t+1),p.set(n,t+1,p.get(n,t)),p.set(n,t,e);if(l&&t<n-1)for(let i=0;i<n;i++)e=m.get(i,t+1),m.set(i,t+1,m.get(i,t)),m.set(i,t,e);t++}M=0,C--}}if(h){let t=p;p=m,m=t}this.m=n,this.n=i,this.s=f,this.U=m,this.V=p}solve(t){let e=t,n=this.threshold,i=this.s.length,o=P.zeros(i,i);for(let t=0;t<i;t++)Math.abs(this.s[t])<=n?o.set(t,t,0):o.set(t,t,1/this.s[t]);let s=this.U,r=this.rightSingularVectors,a=r.mmul(o),l=r.rows,c=s.rows,h=P.zeros(l,c);for(let t=0;t<l;t++)for(let e=0;e<c;e++){let n=0;for(let o=0;o<i;o++)n+=a.get(t,o)*s.get(e,o);h.set(t,e,n)}return h.mmul(e)}solveForDiagonal(t){return this.solve(P.diag(t))}inverse(){let t=this.V,e=this.threshold,n=t.rows,i=t.columns,o=new P(n,this.s.length);for(let s=0;s<n;s++)for(let n=0;n<i;n++)Math.abs(this.s[n])>e&&o.set(s,n,t.get(s,n)/this.s[n]);let s=this.U,r=s.rows,a=s.columns,l=new P(n,r);for(let t=0;t<n;t++)for(let e=0;e<r;e++){let n=0;for(let i=0;i<a;i++)n+=o.get(t,i)*s.get(e,i);l.set(t,e,n)}return l}get condition(){return this.s[0]/this.s[Math.min(this.m,this.n)-1]}get norm2(){return this.s[0]}get rank(){let t=Math.max(this.m,this.n)*this.s[0]*Number.EPSILON,e=0,n=this.s;for(let i=0,o=n.length;i<o;i++)n[i]>t&&e++;return e}get diagonal(){return Array.from(this.s)}get threshold(){return Number.EPSILON/2*Math.max(this.m,this.n)*this.s[0]}get leftSingularVectors(){return this.U}get rightSingularVectors(){return this.V}get diagonalMatrix(){return P.diag(this.s)}}function G(t,e,n,i,o){let s=n*i*i,r=P.eye(e.length,e.length,s);const a=o(e);let l=new Float64Array(t.x.length);for(let e=0;e<t.x.length;e++)l[e]=a(t.x[e]);let c=function(t,e,n,i,o){const s=n.length,r=t.x.length;let a=new Array(s);for(let l=0;l<s;l++){a[l]=new Array(r);let s=n.slice();s[l]+=i;let c=o(s);for(let n=0;n<r;n++)a[l][n]=e[n]-c(t.x[n])}return new P(a)}(t,l,e,i,o),h=function(t,e){const n=t.x.length;let i=new Array(n);for(let o=0;o<n;o++)i[o]=[t.y[o]-e[o]];return new P(i)}(t,l),u=function(t,e=!1){return t=x.checkMatrix(t),e?new I(t).inverse():function(t,e,n=!1){return t=x.checkMatrix(t),e=x.checkMatrix(e),n?new I(t).solve(e):t.isSquare()?new _(t).solve(e):new L(t).solve(e)}(t,P.eye(t.rows))}(r.add(c.mmul(c.transpose())));return(e=(e=new P([e])).sub(u.mmul(c).mmul(h).mul(i).transpose())).to1DArray()}function D(t,e,n={}){let{maxIterations:i=100,gradientDifference:r=.1,damping:a=0,errorTolerance:l=.01,minValues:c,maxValues:h,initialValues:u}=n;if(a<=0)throw new Error("The damping option must be a positive number");if(!t.x||!t.y)throw new Error("The data parameter must have x and y elements");if(!o(t.x)||t.x.length<2||!o(t.y)||t.y.length<2)throw new Error("The data parameter elements must be an array with more than 2 points");if(t.x.length!==t.y.length)throw new Error("The data parameter elements must have the same size");let d=u||new Array(e.length).fill(1),f=d.length;if(h=h||new Array(f).fill(Number.MAX_SAFE_INTEGER),c=c||new Array(f).fill(Number.MIN_SAFE_INTEGER),h.length!==c.length)throw new Error("minValues and maxValues must be the same size");if(!o(d))throw new Error("initialValues must be an array");let m,p=s(t,d,e),g=p<=l;for(m=0;m<i&&!g;m++){d=G(t,d,a,r,e);for(let t=0;t<f;t++)d[t]=Math.min(Math.max(c[t],d[t]),h[t]);if(p=s(t,d,e),isNaN(p))break;g=p<=l}return{parameterValues:d,parameterError:p,iterations:m}}},3379:t=>{"use strict";var e=[];function n(t){for(var n=-1,i=0;i<e.length;i++)if(e[i].identifier===t){n=i;break}return n}function i(t,i){for(var s={},r=[],a=0;a<t.length;a++){var l=t[a],c=i.base?l[0]+i.base:l[0],h=s[c]||0,u="".concat(c," ").concat(h);s[c]=h+1;var d=n(u),f={css:l[1],media:l[2],sourceMap:l[3],supports:l[4],layer:l[5]};if(-1!==d)e[d].references++,e[d].updater(f);else{var m=o(f,i);i.byIndex=a,e.splice(a,0,{identifier:u,updater:m,references:1})}r.push(u)}return r}function o(t,e){var n=e.domAPI(e);return n.update(t),function(e){if(e){if(e.css===t.css&&e.media===t.media&&e.sourceMap===t.sourceMap&&e.supports===t.supports&&e.layer===t.layer)return;n.update(t=e)}else n.remove()}}t.exports=function(t,o){var s=i(t=t||[],o=o||{});return function(t){t=t||[];for(var r=0;r<s.length;r++){var a=n(s[r]);e[a].references--}for(var l=i(t,o),c=0;c<s.length;c++){var h=n(s[c]);0===e[h].references&&(e[h].updater(),e.splice(h,1))}s=l}}},569:t=>{"use strict";var e={};t.exports=function(t,n){var i=function(t){if(void 0===e[t]){var n=document.querySelector(t);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(t){n=null}e[t]=n}return e[t]}(t);if(!i)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");i.appendChild(n)}},9216:t=>{"use strict";t.exports=function(t){var e=document.createElement("style");return t.setAttributes(e,t.attributes),t.insert(e,t.options),e}},3565:(t,e,n)=>{"use strict";t.exports=function(t){var e=n.nc;e&&t.setAttribute("nonce",e)}},7795:t=>{"use strict";t.exports=function(t){if("undefined"==typeof document)return{update:function(){},remove:function(){}};var e=t.insertStyleElement(t);return{update:function(n){!function(t,e,n){var i="";n.supports&&(i+="@supports (".concat(n.supports,") {")),n.media&&(i+="@media ".concat(n.media," {"));var o=void 0!==n.layer;o&&(i+="@layer".concat(n.layer.length>0?" ".concat(n.layer):""," {")),i+=n.css,o&&(i+="}"),n.media&&(i+="}"),n.supports&&(i+="}");var s=n.sourceMap;s&&"undefined"!=typeof btoa&&(i+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(s))))," */")),e.styleTagTransform(i,t,e.options)}(e,t,n)},remove:function(){!function(t){if(null===t.parentNode)return!1;t.parentNode.removeChild(t)}(e)}}}},4589:t=>{"use strict";t.exports=function(t,e){if(e.styleSheet)e.styleSheet.cssText=t;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(t))}}},7241:(t,e,n)=>{"use strict";n.d(e,{D:()=>c});var i=n(4469),o=n(976),s=n(473),r=n(8447),a=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};const l=31;function c(t,e=!1,n){return a(this,void 0,void 0,(function*(){const a=t.tags.separator,c=t.tags[o.TAGS.UNITS],u=(0,r.vU)(c,a);let d;null!=n||(n=new Map);const f="helm"===c?(0,s.getHelmMonomers)(t):Object.keys((0,r.fy)(t,0,u).freq).filter((t=>""!==t));for(let t=0;t<f.length;t++)n.has(f[t])||n.set(f[t],`${n.size+1}`);if("helm"===c)d=yield i.functions.call("HELM:getMolFiles",{col:t}),d=function(t,e,n=!1){const i=new Array(t.length);for(let o=0;o<t.length;o++){let s=0,r=0,a="\n Datagrok macromolecule handler\n\n 0 0 0 0 0 0 999 V3000\nM V30 BEGIN CTAB\n";const c=t.get(o);s=c.indexOf("\n",s)+1,s=c.indexOf("\n",s)+1,s=c.indexOf("\n",s)+1;const h=parseInt(c.substring(s,s+3)),u=parseInt(c.substring(s+3,s+6));a+=`M V30 COUNTS ${h} ${u} 0 0 0\n`,a+="M V30 BEGIN ATOM\n";for(let t=0;t<h;t++){s=c.indexOf("\n",s)+1+l,r=c.indexOf(" ",s);const i=c.substring(s,r);a+=n?`M V30 ${t+1} R${e.get(i)} 0.000 0.000 0 0\n`:`M V30 ${t+1} At 0.000 0.000 0 0 MASS=${e.get(i)}\n`}a+="M V30 END ATOM\n",a+="M V30 BEGIN BOND\n";for(let t=0;t<u;t++){s=c.indexOf("\n",s)+1;const e=parseInt(c.substring(s,s+3).trim()),n=parseInt(c.substring(s+3,s+6).trim());a+=`M V30 ${t+1} ${parseInt(c.substring(s+6,s+9).trim())} ${e} ${n}\n`}a+="M V30 END BOND\n",a+="M V30 END CTAB\n",a+="M END",i[o]=a}return i}(d,n,e);else{d=new Array(t.length);for(let i=0;i<t.length;i++){const o=h(u(t.get(i)).filter((t=>""!==t)),n,e);d[i]=o}}return o.Column.fromStrings("monomericMols",d)}))}function h(t,e,n=!1){let i="\n Datagrok macromolecule handler\n\n 0 0 0 0 0 0 999 V3000\nM V30 BEGIN CTAB\n";i+=`M V30 COUNTS ${t.length} ${t.length?t.length-1:0} 0 0 0\n`,i+="M V30 BEGIN ATOM\n";for(let o=0;o<t.length;o++)i+=n?`M V30 ${o+1} R${e.get(t[o])} 0.000 0.000 0 0\n`:`M V30 ${o+1} At 0.000 0.000 0 0 MASS=${e.get(t[o])}\n`;i+="M V30 END ATOM\n",i+="M V30 BEGIN BOND\n";for(let e=0;e<t.length-1;e++)i+=`M V30 ${e+1} 1 ${e+1} ${e+2}\n`;return i+="M V30 END BOND\n",i+="M V30 END CTAB\n",i+="M END",i}},473:(t,e,n)=>{"use strict";n.d(e,{_package:()=>Yt,activityCliffs:()=>$t,getHelmMonomers:()=>jt,getMonomerLibHelper:()=>Kt,importFasta:()=>zt,sequenceSpaceTopMenu:()=>Zt,splitToMonomers:()=>Xt,toAtomicLevel:()=>qt});var i=n(4469),o=n(3870),s=n(976),r=n(585);const a=r.GU;var l;!function(t){t.MSA="MSA",t.classic="classic"}(l||(l={}));const c=(t,e,n,i,o,s,r="rgb(100,100,100)",c=0,h=!1,u=1,d="",f=!1,m=l.classic,p={},g=0,v=null,y=[],b=null)=>{var w,S,C;o.textAlign="start";let T=s.substring(0),M=f?"":d;m===l.MSA&&(M="");let E=!0,A=!0,N="difference";null!=v&&null!=v.cell.column&&(E=null===(w=v.cell.column.temp["color-code"])||void 0===w||w,A=null===(S=v.cell.column.temp["compare-with-current"])||void 0===S||S,N=null!==(C=v.cell.column.temp["highlight-difference"])&&void 0!==C?C:"difference");const P=y[g];A&&y.length>0&&"difference"===N&&(u=T==P?.3:u),A&&y.length>0&&"equal"===N&&(u=T!=P?.3:u),null!=b&&(T=a(T,b));let x=o.measureText(T+M),_=o.measureText(T).width,R=o.measureText(T).width;const L=i/2-(x.fontBoundingBoxAscent+x.fontBoundingBoxDescent)/2+1;function I(n,i){const s=E?r:"rgb(0,0,0)";o.fillStyle=s,o.globalAlpha=u,m===l.classic&&(o.fillText(T,t+n,e+L),o.fillStyle="#808080",o.fillText(M,t+i,e+L)),m===l.MSA&&(o.fillStyle=s,o.fillText(T,t+n+(p[g]-R)/2,e+L))}if(x=x.width,m===l.MSA&&(_=p[g],x=p[g]),h||x>n)return I(5,5+_),t+_+o.measureText(M).width;{const e=(n-x)/2;return I(e,e+_),t+e+_}};var h=n(3553),u=n(8447),d=n(7331);function f(t){const e=!t.some(((e,n)=>e.length>1&&0!=n&&n!=t.length-1)),n=[],i=e?"":" ";return t.forEach(((e,o)=>{o<t.length&&(e+=`${e?"":"-"}${i}`),n.push(e)})),[n,e]}class m extends s.GridCellRenderer{get name(){return"sequence"}get cellType(){return"sequence"}get defaultHeight(){return 30}get defaultWidth(){return 230}onClick(t,e){t.cell.column.temp["current-word"]=t.cell.value,t.grid.invalidate()}onMouseMove(t,e){if("SEQ.MSA"!==t.cell.column.getTag("aligned"))return;const n=t.cell.column.temp,i=n["bio-sum-maxLengthWords"],o=n["bio-maxIndex"],s=e.offsetX-t.gridColumn.left+(t.gridColumn.left-t.bounds.x);let r=o;i[o+1]=s+1;if(s>i[0])for(;;)Math.floor((r+0)/2),s>=i[0]&&s<=i[1]||s<i[0]||i[1];i[0];const a=(t.cell.column.getTag("separator"),""),l=getSplitter("separator",a)(t.cell.value);l[0],ui.tooltip.hide()}render(t,e,n,i,o,s,r){const a=-1!==s.gridRow?s.grid:null,l=s.cell,c=s.cell.column.getTag("alphabet");getUpdatedWidth(a,t,e,i),t.save(),t.beginPath(),t.rect(e,n,i,o),t.clip(),t.font="12px monospace",t.textBaseline="top";const h=s.cell.column.getTag(DG.TAGS.UNITS),u=s.cell.column.getTag("aligned"),d=getPaletteByType(c),f=(s.cell.column.getTag("separator"),""),m=i/5,p=getSplitter(h,f,m),g=s.cell.column.temp,v=g["reference-sequence"],y=g["current-word"],b=(g["monomer-width"],p(null!=v&&""!=v?v:null!=y?y:""));let w={};if(s.cell.column.getTag(".calculatedCellRender")!==m.toString()){let t=0;for(;t<Math.min(s.cell.column.length,100);)p(s.cell.column.get(t)).forEach(((t,e)=>{const n=7*cell_renderer_monomerToShortFunction(t,8).length+5;n>(w[e],0)&&(w[e]=n)}));const e=21;for(let t=0;t<=0;t++){w[t]<e&&(w[t]=e);const n={};n[0]=w[0];for(let t=1;t<=0;t++)n[t]=n[t-1]+w[t];g["bio-sum-maxLengthWords"]=n,g["bio-maxIndex"]=0,g["bio-maxLengthWords"]=w,s.cell.column.setTag(".calculatedCellRender",m.toString())}}else g["bio-maxLengthWords"];const S=p(l.value);let C=e,T=cell_renderer_undefinedColor,M=DrawStyle.classic;u&&u.includes("MSA")&&"separator"==h&&DrawStyle.MSA,S.every(((e,r)=>{d.get(e),t.fillStyle=cell_renderer_undefinedColor;const a=r===S.length-1;return printLeftOrCentered(C,n,i,o,t,e,T,0,!0,1,f,a,M,w,r,s,b,8),50<=i})),t.restore()}}class p extends s.GridCellRenderer{get name(){return C.SEM_TYPES.MONOMER}get cellType(){return C.SEM_TYPES.MONOMER}get defaultHeight(){return 15}get defaultWidth(){return 30}render(t,e,n,i,o,s,r){t.font="12px monospace",t.textBaseline="middle",t.textAlign="center";const a=getPaletteByType(s.cell.column.getTag("alphabet")),l=s.cell.value;if(!l)return;const c=a.get(l);t.fillStyle=c,t.fillText(monomerToShort(l,3),e+i/2,n+o/2,i)}}class g extends s.GridCellRenderer{get name(){return"MacromoleculeDifferenceCR"}get cellType(){return C.SEM_TYPES.MACROMOLECULE_DIFFERENCE}get defaultHeight(){return 30}get defaultWidth(){return 230}render(t,e,n,i,o,s,r){const a=s.grid,l=(s.cell.value,""),c=s.tableColumn.tags.separator,h=s.tableColumn.tags[DG.TAGS.UNITS];getUpdatedWidth(a,t,e,i);const[u,d]=l.split("#"),f=getSplitter(h,c);v(t,e,n,i,o,f(u),f(d),h)}}function v(t,e,n,i,o,s,r,a,l,h){if(s.length!==r.length){const t=function(t,e){let n=0,i=0;const o=t.length>e.length?t:e;let s=t.length>e.length?e:t;for(let t=0;t<s.length;t++)o[t]===s[t]&&n++;const r=o.length-s.length;for(let t=o.length-1;t>r;t--)o[t]===s[t-r]&&i++;const a=new Array(Math.abs(t.length-e.length)).fill("");function l(t){return n>i?t.concat(a):a.concat(t)}return t.length>e.length?e=l(e):t=l(t),{subParts1:t,subParts2:e}}(s,r);s=t.subParts1,r=t.subParts2}const m=t.measureText(f(s).join("")),p=t.measureText(f(r).join("")),g=Math.max(m.width,p.width);l&&(i=g+4*s.length,t.canvas.width=g+4*s.length);let v=Math.max(e,e+(i-(g+4*s.length))/2);const b=Math.max(n,n+(o-28)/2);t.save(),t.beginPath(),t.rect(e,n,l?g+4*s.length:i,o),t.clip(),t.font="12px monospace",t.textBaseline="top";let w=d.UE.Color;"HELM"!=a&&(w=(0,u.py)(a.substring(a.length-2)));for(let e=0;e<s.length;e++){const n=s[e],a=r[e],l=w.get(n);if(n!=a){const s=w.get(a),r=c(v,b-7,i,o,t,n,l,0,!0),u=c(v,b+7,i,o,t,a,s,0,!0);v=Math.max(u,r),h&&(h[e]=y(n,a,l,s,b,7,o))}else v=c(v,b,i,o,t,n,l,0,!0,.5);v+=4}t.restore()}function y(t,e,n,i,o,s,r){const a=document.createElement("canvas"),l=a.getContext("2d");l.font="12px monospace";const h=l.measureText(f([t]).join("")).width,u=l.measureText(f([e]).join("")).width,d=Math.max(h,u);return a.height=r,a.width=d+4,l.font="12px monospace",l.textBaseline="top",c(0,o-s,d,r,l,t,n,0,!0),c(0,o+s,d,r,l,e,i,0,!0),a}var b,w,S=n(701),T=(n(2433),n(9298));(w=b||(b={})).Unknown="unknown",w.FR="framework",w.CDR="cdr",new class{constructor(){this.regionTypes=[b.CDR],this.chains=["Heavy","Light"],this.skipEmptyPositions=!1,this.positionWidth=16,this.positionHeight=T.ES.Entropy}};class M extends s.JsViewer{constructor(){super(),this.viewed=!1,this.regionsFg=null,this.regionsRoot=null,this.isOpened=!1,this.panelNode=null,this.regions=[],this.viewPromise=Promise.resolve(),this.host=null,this.filterSourceInput=null,this.mainLayout=null,this.logos=[],this.viewSubs=[],this.regionTypes=this.stringList("regionTypes",[vrt.CDR],{choices:Object.values(vrt).filter((t=>t!=vrt.Unknown))}),this.chains=this.stringList("chains",["Heavy","Light"],{choices:["Heavy","Light"]}),this.skipEmptyPositions=this.bool("skipEmptyPositions",!1),this.positionWidth=this.float("positionWidth",16),this.positionHeight=this.string("positionHeight",PositionHeight.Entropy,{choices:Object.keys(PositionHeight)})}init(){return __awaiter(this,void 0,void 0,(function*(){this.subs.push(ui.onSizeChanged(this.root).subscribe(this.rootOnSizeChanged.bind(this))),this.subs.push(rxjs.fromEvent(this.root,"mousemove").subscribe(this.rootOnMouseMove.bind(this)))}))}onTableAttached(){const t=Object.create(null,{onTableAttached:{get:()=>super.onTableAttached}});return __awaiter(this,void 0,void 0,(function*(){const e=t.onTableAttached.bind(this);this.viewPromise=this.viewPromise.then((()=>__awaiter(this,void 0,void 0,(function*(){e(),this.viewed||(yield this.buildView("onTableAttached"),this.viewed=!0)}))))}))}onPropertyChanged(t){if(super.onPropertyChanged(t),t)switch(t&&t.name,t.name){case"skipEmptyPositions":case"positionWidth":case"positionHeight":this.setData(this.dataFrame,this.regions)}else console.warn("Bio: VdRegionsViewer.onPropertyChanged() property is null")}setData(t,e){console.debug("Bio: VdRegionsViewer.setData()"),this.viewPromise=this.viewPromise.then((()=>__awaiter(this,void 0,void 0,(function*(){this.viewed&&(yield this.destroyView("setData"),this.viewed=!1)})))),this.regions=e,this.dataFrame=t,this.viewPromise=this.viewPromise.then((()=>__awaiter(this,void 0,void 0,(function*(){this.viewed||(yield this.buildView("setData"),this.viewed=!0)}))))}detach(){const t=super.detach.bind(this);this.viewPromise=this.viewPromise.then((()=>__awaiter(this,void 0,void 0,(function*(){this.viewed&&(yield this.destroyView("detach"),this.viewed=!1),t()}))))}destroyView(t){return __awaiter(this,void 0,void 0,(function*(){console.debug(`Bio: VdRegionsViewer.destroyView( mainLayout = ${this.mainLayout?"value":"none"} ), purpose = '${t}'`),this.filterSourceInput&&ui.empty(this.filterSourceInput.root),null!=this.mainLayout&&(this.mainLayout.remove(),this.host.remove(),this.host=null,this.mainLayout=null);for(const t of this.viewSubs)t.unsubscribe()}))}buildView(t){return __awaiter(this,void 0,void 0,(function*(){console.debug(`Bio: VdRegionsViewer.buildView() begin, purpose = '${t}'`);const e=this.regions.filter((t=>this.regionTypes.includes(t.type))),n=Array.from(new Set(e.map((t=>t.order)))).sort();this.logos=[];for(let t=0;t<n.length;t++){const i={};for(const o of this.chains){const s=e.find((e=>e.order==n[t]&&e.chain==o));i[o]=yield this.dataFrame.plot.fromType("WebLogo",{sequenceColumnName:s.sequenceColumnName,startPositionName:s.positionStartName,endPositionName:s.positionEndName,fixWidth:!0,skipEmptyPositions:this.skipEmptyPositions,positionWidth:this.positionWidth,positionHeight:this.positionHeight})}this.logos[t]=i}this.mainLayout=ui.table(this.chains,(t=>[...n.length>0?[ui.div(t,{style:{transform:"rotate(-90deg)",font:"12px Roboto, Roboto Local, sans-serif",textAlign:"center",width:"16px",marginTop:"24px",marginLeft:"6px"}})]:[],...[...Array(n.length).keys()].map((e=>{const n=this.logos[e][t];return n.root.style.height="100%",ui.div([n.root],{style:{marginTop:"4px",marginBottom:"4px"}})}))]),["",...[...Array(n.length).keys()].map((t=>e.find((e=>e.order==n[t]&&e.chain==this.chains[0])).name||"Name"))]),this.mainLayout.className="mlb-vd-regions-viewer-table2",this.filterSourceInput=ui.boolInput("",!1,this.filterSourceInputOnValueChanged.bind(this)),this.filterSourceInput.root.style.position="absolute",this.filterSourceInput.root.style.left="10px",this.filterSourceInput.root.style.top="-3px",ui.tooltip.bind(this.filterSourceInput.root,"Check to filter sequences for selected VRs"),Math.ceil(255*Math.random()).toString(16),this.host=ui.div([this.mainLayout,this.filterSourceInput.root],{}),this.root.appendChild(this.host),this.root.style.overflowX="auto",this.calcSize(),console.debug("Bio: VdRegionsViewer.buildView() end")}))}calcSize(){const t=(this.root.clientHeight-54)/this.chains.length,e=Math.min(t,Math.max(...this.logos.map((t=>Math.max(...Object.values(t).map((t=>t.maxHeight)))))));for(let t=0;t<this.logos.length;t++)for(let n=0;n<this.chains.length;n++){const i=this.chains[n];this.logos[t][i].root.style.height=`${e}px`}}rootOnSizeChanged(t){this.calcSize()}rootOnMouseMove(t){}filterSourceInputOnValueChanged(){const t=1==this.filterSourceInput.value?FilterSources.Selected:FilterSources.Filtered;for(let e=0;e<this.logos.length;e++)for(let n=0;n<this.chains.length;n++){const i=this.chains[n];this.logos[e][i].setOptions({[wlPROPS.filterSource]:t})}}}class E extends Float32Array{}function A(t){return Math.random()*t}function N(t){return Math.floor(A(t))}function P(t,e,n=0){return new Array(t).fill(n).map((()=>new E(e).fill(n)))}function x(t,e,n=1){const i=t.length;!function(t=!1,e="Assertion error."){if(!t)throw new Error(e)}(i==e.length,"Vector lengths do not match.");const o=new E(i);for(let i=0;i<t.length;++i)o[i]=t[i]+n*e[i];return o}function _(t,e){const n=function(t){let e=0;for(let n=0;n<t.length;++n)e+=t[n];return e}(function(t){const e=t.length,n=new E(e);for(let e=0;e<t.length;++e)n[e]=t[e]*t[e];return n}(x(t,e,-1)));return Math.sqrt(n)}var R=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};var L=n(7983),I=n(499),G=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};function D(t){return G(this,void 0,void 0,(function*(){const e=new I.C(t.seqCol);if(e.isFasta()){const i=e.getDistanceFunctionName(),o=yield function(t,e,i,o){return R(this,void 0,void 0,(function*(){const s=yield function(t,e,i){return new Promise((function(o,s){const r=new Worker(new URL(n.p+n.u(105),n.b));r.postMessage({columnData:t.data,method:e,measure:t.metric,options:i}),r.onmessage=({data:{error:t,distance:e,embedding:n}})=>{t?s(t):o({distance:e,embedding:n})}}))}({data:t,metric:i},e,o);return s.embedding=s.embedding.map((t=>function(t){let e=0,n=0;for(let n=0;n<t.length;++n)e+=t[n];e/=t.length;for(let i=0;i<t.length;++i)n+=(t[i]-e)*(t[i]-e);n=Math.sqrt(n/t.length);for(let i=0;i<t.length;++i)t[i]=(t[i]-e)/n;return t}(t))),s}))}(t.seqCol.toList(),t.methodName,i,t.options);console.log(o);const r=t.embedAxesNames.map(((t,e)=>s.Column.fromFloat32Array(t,o.embedding[e])));return{distance:o.distance,coordinates:new s.ColumnList(r)}}return yield function(t){return G(this,void 0,void 0,(function*(){return t.seqCol.version!==t.seqCol.temp["last-invalidated-version"]&&(yield(0,L.HV)(t.seqCol,!1)),yield i.functions.call("Chem:getChemSpaceEmbeddings",{col:t.seqCol.temp["monomeric-mols"],methodName:t.methodName,similarityMetric:t.similarityMetric,xAxis:t.embedAxesNames[0],yAxis:t.embedAxesNames[1],options:t.options})}))}(t)}))}function W(t){const e=["Embed_X","Embed_Y"],n=t.columns.names().filter((t=>t.includes(e[0]))).length+1;return e.map((t=>`${t}_${n}`))}function F(t){return 1/(1+t)}function H(t){return 1/t-1}var k=n(489),O=n(3379),V=n.n(O),U=n(7795),B=n.n(U),Y=n(569),K=n.n(Y),$=n(3565),Z=n.n($),q=n(9216),z=n.n(q),X=n(4589),j=n.n(X),Q=n(9414),J={};J.styleTagTransform=j(),J.setAttributes=Z(),J.insert=K().bind(null,"head"),J.domAPI=B(),J.insertStyleElement=z(),V()(Q.Z,J),Q.Z&&Q.Z.locals&&Q.Z.locals;var tt=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};let et=0;const nt="cliffsDf",it=new S.Subject,ot="act_diff",st="sali",rt="sim",at="line_index",lt=["1_seq","2_seq"],ct="filterCliffs";function ht(t,e,n){const i=e.getBoundingClientRect(),o=t.clientX-i.left,s=t.clientY-i.top;let r=null,a=0;for(const t of n){const e=Math.abs(Math.hypot(t.a[0]-o,t.a[1]-s)+Math.hypot(t.b[0]-o,t.b[1]-s)-Math.hypot(t.a[0]-t.b[0],t.a[1]-t.b[1]));(!a&&e<2||e<a)&&(a=e,r=t)}return r}var ut,dt,ft,mt,pt=n(1811),gt=n(3979);(mt=ut||(ut={})).Levenshtein="Levenshtein",mt.JaroWinkler="Jaro-Winkler",mt.Manhattan="Manhattan",function(t){t.Euclidean="Euclidean"}(dt||(dt={})),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"}(ft||(ft={}));const vt={[dt.Euclidean]:_},yt={[ut.Levenshtein]:pt.T,[ut.JaroWinkler]:gt.H$,[ut.Manhattan]:function(t,e){if(t.length!==e.length)return 1;{let n=0;for(let i=1;i<t.length;i++)n+=t[i]==e[i]?0:1;return n/t.length}}},bt={[ft.Tanimoto]:function(t,e){return H(function(t,e){const n=t.trueCount()+e.trueCount();if(0==n)return 1;const i=t.andWithCountBits(e,!0);return i/(n-i)}(t,e))},[ft.Dice]:function(t,e){return H(function(t,e){const n=t.trueCount()+e.trueCount();return 0==n?0:2*t.andWithCountBits(e,!0)/n}(t,e))},[ft.Asymmetric]:function(t,e){return H(function(t,e){const n=Math.min(t.trueCount(),e.trueCount());return 0==n?0:t.andWithCountBits(e,!0)/n}(t,e))},[ft.BraunBlanquet]:function(t,e){return H(function(t,e){const n=Math.max(t.trueCount(),e.trueCount());return 0==n?0:t.andWithCountBits(e,!0)/n}(t,e))},[ft.Cosine]:function(t,e){return H(function(t,e){const n=t.trueCount()*e.trueCount();return 0==n?0:t.andWithCountBits(e,!0)/Math.sqrt(n)}(t,e))},[ft.Kulczynski]:function(t,e){return H(function(t,e){const n=t.trueCount()+e.trueCount(),i=t.trueCount()*e.trueCount();return 0==i?0:t.andWithCountBits(e,!0)*n/(2*i)}(t,e))},[ft.McConnaughey]:function(t,e){return H(function(t,e){const n=t.trueCount()+e.trueCount(),i=t.trueCount()*e.trueCount();return 0==i?0:(t.andWithCountBits(e,!0)*n-i)/i}(t,e))},[ft.RogotGoldberg]:function(t,e){return H(function(t,e){const n=t.andWithCountBits(e,!0),i=t.countBits(!0)+e.countBits(!0),o=t.length,s=o-i+n;return n==o||s==o?1:n/i+s/(2*o-i)}(t,e))},[ft.Russel]:function(t,e){return H(function(t,e){return 0==t.length?0:t.andWithCountBits(e,!0)/t.length}(t,e))},[ft.Sokal]:function(t,e){return H(function(t,e){const n=t.trueCount()+e.trueCount(),i=t.andWithCountBits(e,!0);return i/(2*n-3*i)}(t,e))},[ft.Hamming]:function(t,e){return t.trueCount()+e.trueCount()-2*t.andWithCountBits(e,!0)},[ft.Euclidean]:function(t,e){return Math.sqrt(t.trueCount()+e.trueCount()-2*t.andWithCountBits(e,!0))}};var wt,St;(St=wt||(wt={})).Vector="Vector",St.String="String",St.BitArray="BitArray",St.MacroMolecule="MacroMolecule";const Ct={[wt.Vector]:{[dt.Euclidean]:vt[dt.Euclidean]},[wt.String]:{[ut.Levenshtein]:yt[ut.Levenshtein],[ut.JaroWinkler]:yt[ut.JaroWinkler],[ut.Manhattan]:yt[ut.Manhattan]},[wt.BitArray]:{[ft.Tanimoto]:bt[ft.Tanimoto],[ft.Dice]:bt[ft.Dice],[ft.Asymmetric]:bt[ft.Asymmetric],[ft.BraunBlanquet]:bt[ft.BraunBlanquet],[ft.Cosine]:bt[ft.Cosine],[ft.Kulczynski]:bt[ft.Kulczynski],[ft.McConnaughey]:bt[ft.McConnaughey],[ft.RogotGoldberg]:bt[ft.RogotGoldberg],[ft.Russel]:bt[ft.Russel],[ft.Sokal]:bt[ft.Sokal]},[wt.MacroMolecule]:{[k.U.HAMMING]:k.o[k.U.HAMMING],[k.U.LEVENSHTEIN]:k.o[k.U.LEVENSHTEIN],[k.U.NEEDLEMANN_WUNSCH]:k.o[k.U.NEEDLEMANN_WUNSCH]}};Object.keys(Ct).reduce(((t,e)=>{for(const n of Object.keys(Ct[e]))t[n]=e;return t}),{});var Tt=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};function Mt(t,e,n,o,r){return Tt(this,void 0,void 0,(function*(){e.version!==e.temp["last-invalidated-version"]&&(yield(0,L.HV)(e,!1));const n=s.DataFrame.create(e.length);return n.columns.addNewString(o).init((t=>e.temp["monomeric-mols"].get(t))),yield i.functions.call("Chem:getChemSimilaritiesMatrix",{dim:t,col:e.temp["monomeric-mols"],df:n,colName:o,simArr:r})}))}function Et(t){const e=o.divH([]),n=o.divV([o.divText(t.seqCol.name),o.divText(t.activityCol.name)]);return n.style.fontWeight="bold",n.style.display="flex",n.style.justifyContent="space-between",e.append(n),t.line.mols.forEach(((n,i)=>{const s=o.divText(t.activityCol.get(n).toFixed(2));s.style.display="flex",s.style.justifyContent="left",s.style.paddingLeft="30px",e.append(o.divV([o.divText(t.seqCol.get(n)),s]))})),e}function At(t){const e=o.div();e.append(o.divText(t.seqCol.name,{style:{fontWeight:"bold"}}));const n=new Array(2),i=new Array(2);t.line.mols.forEach(((e,o)=>{n[o]=t.seqCol.get(e),i[o]=t.activityCol.get(e)}));const r={},a=t.seqCol.getTag(s.TAGS.UNITS),l=t.seqCol.getTag("separator"),c=(0,u.vU)(a,l),h=function(t,e,n,i){const o=document.createElement("canvas"),s=o.getContext("2d");return o.height=30,v(s,0,0,0,30,t,e,n,!0,i),o}(c(n[0]),c(n[1]),a,r);return e.append(o.div(h,{style:{width:"300px",overflow:"scroll"}})),e.append(function(t){const e=o.div();if(Object.keys(t).length>0){const n=o.divV([]);n.append(o.divH([o.divText("Pos",{style:{fontWeight:"bold",width:"30px",borderBottom:"1px solid"}}),o.divText("Difference",{style:{fontWeight:"bold",borderBottom:"1px solid"}})]));for(const e of Object.keys(t))t[e].style.borderBottom="1px solid lightgray",n.append(o.divH([o.divText((parseInt(e)+1).toString(),{style:{width:"30px",borderBottom:"1px solid lightgray"}}),t[e]]));e.append(n)}return e}(r)),e.append(Nt("Activity delta",Math.abs(i[0]-i[1]))),e.append(Nt("Cliff",t.sali)),e}function Nt(t,e){return o.divH([o.divText(`${t}: `,{style:{fontWeight:"bold",paddingRight:"5px"}}),o.divText(e.toFixed(2))],{style:{paddingTop:"10px"}})}function Pt(t,e){const n=s.Column.string("seq_diff",t.rowCount).init((n=>`${t.get(e[0],n)}#${t.get(e[1],n)}`));n.semType="MacromoleculeDifference",n.setTag(s.TAGS.UNITS,t.col(e[0]).getTag(s.TAGS.UNITS)),n.setTag("separator",t.col(e[0]).getTag("separator")),t.columns.add(n);const i=t.plot.grid();return i.col(e[0]).visible=!1,i.col(e[1]).visible=!1,i}n(1047),n(4004),n(7228);var xt=n(6103),_t=n(5226);n(9133);class Rt extends s.JsViewer{constructor(t){super(),this.name="",this.metricsProperties=["distanceMetric","fingerprint"],this.fingerprintChoices=["Morgan","Pattern"],this.initialized=!1,this.tags=[DG.TAGS.UNITS,"aligned","separator","alphabet"],this.fingerprint=this.string("fingerprint",this.fingerprintChoices[0],{choices:this.fingerprintChoices}),this.limit=this.int("limit",10),this.distanceMetric=this.string("distanceMetric",CHEM_SIMILARITY_METRICS[0],{choices:CHEM_SIMILARITY_METRICS}),this.moleculeColumnName=this.string("moleculeColumnName"),this.name=t}init(){this.initialized=!0}detach(){this.subs.forEach((t=>t.unsubscribe()))}onTableAttached(){return sequence_search_base_viewer_awaiter(this,void 0,void 0,(function*(){if(this.init(),this.dataFrame){this.subs.push(DG.debounce(this.dataFrame.onRowsRemoved,50).subscribe((t=>sequence_search_base_viewer_awaiter(this,void 0,void 0,(function*(){return yield this.render()})))));const t="diversity"!==this.name;this.subs.push(DG.debounce(this.dataFrame.onCurrentRowChanged,50).subscribe((e=>sequence_search_base_viewer_awaiter(this,void 0,void 0,(function*(){return yield this.render(t)}))))),this.subs.push(DG.debounce(this.dataFrame.selection.onChanged,50).subscribe((t=>sequence_search_base_viewer_awaiter(this,void 0,void 0,(function*(){return yield this.render(!1)}))))),this.subs.push(DG.debounce(ui.onSizeChanged(this.root),50).subscribe((t=>sequence_search_base_viewer_awaiter(this,void 0,void 0,(function*(){return yield this.render(!1)}))))),this.moleculeColumn=this.dataFrame.columns.bySemType(DG.SEMTYPE.MACROMOLECULE),this.moleculeColumnName=(this.moleculeColumn,void 0),this.getProperty("limit").fromOptions({min:1,max:this.dataFrame.rowCount})}yield this.render()}))}onPropertyChanged(t){if(super.onPropertyChanged(t),this.initialized){if("moleculeColumnName"===t.name){const e=this.dataFrame.col(t.get(this));e.semType===DG.SEMTYPE.MACROMOLECULE&&(this.moleculeColumn=e)}this.render()}}render(t=!0){return sequence_search_base_viewer_awaiter(this,void 0,void 0,(function*(){}))}beforeRender(){return!(!this.initialized||this.dataFrame&&this.moleculeColumnName&&this.dataFrame.col(this.moleculeColumnName).semType!==DG.SEMTYPE.MACROMOLECULE&&(grok.shell.error(`${this.moleculeColumnName} is not Macromolecule type`),1))}}n(7241);var Lt=n(4293);n(9943),n(4413);var It=n(1061),Gt=n(1345);n(4221),n(7659);class Dt{constructor(t){var e,n,i,o,s,r,a;this.steps=null!==(e=null==t?void 0:t.steps)&&void 0!==e?e:0,this.cycles=null!==(n=null==t?void 0:t.cycles)&&void 0!==n?n:1e6,this.cutoff=null!==(i=null==t?void 0:t.cutoff)&&void 0!==i?i:0,this.lambda=null!==(o=null==t?void 0:t.lambda)&&void 0!==o?o:2,this.dlambda=null!==(s=null==t?void 0:t.dlambda)&&void 0!==s?s:.01,this.lambda2=this.lambda/2,this.dlambda2=this.dlambda/2,this.epsilon=null!==(r=null==t?void 0:t.epsilon)&&void 0!==r?r:1e-10,this.distanceFunction=null!==(a=null==t?void 0:t.distance)&&void 0!==a?a:_,this.distance=[]}initDistance(t){this.distance=function(t,e){const n=t.length,i=P(n,n,0);for(let o=0;o<n;++o)for(let s=o+1;s<n;++s){const n=null==t[o]||null==t[s]?0:e(t[o],t[s]);i[o][s]=i[s][o]=n}return i}(t,this.distanceFunction)}calcDistance(t,e,n){return this.distance[e][n]}embed(t){const e=t.length,n=function(t,e,n=1){const i=P(t,e);for(let o=0;o<t;++o)for(let t=0;t<e;++t)i[o][t]=A(n);return i}(e,Dt.dimension,40);let i=this.lambda2;0==this.steps&&(this.steps=t.length-1),this.initDistance(t);for(let o=0;o<this.cycles;++o){for(let o=0;o<this.steps;++o){const o=N(e);let s=N(e);for(;o==s;)s=N(e);const r=n[o],a=n[s],l=this.calcDistance(t,o,s),c=_(r,a);if(0==this.cutoff||l<=this.cutoff||c<l){const t=i*(l-c)/(c+this.epsilon),e=x(r,a,-1);n[o]=x(r,e,t),n[s]=x(a,e,-t)}}if(i-=this.dlambda2,i<=0)break}return n}}Dt.dimension=2;class Wt{constructor(t,e=!1){if(this._length=0,this._version=0,this._updateLevel=0,this._selectedCount=0,this._selectedCountVersion=-1,this._selectedIndexesVersion=-1,this._versionedName="",this._versionedNameVersion=-1,this.SHRINK_THRESHOLD=256,"number"==typeof t){const n=t,i=Wt._createBuffer(n);if(e)for(let t=0;t<i.length;t++)i[t]=-1;this._data=i,this._length=n}else{if(!(t instanceof Uint32Array))throw new Error("Invalid constructor");this._data=t,this._length=e}}getRawData(){return this._data}assureGoez(t,e){if(t<0)throw new Error(`${e} should be greater than zero`)}assureInRange(t,e,n,i){if(t<e||t>n)throw new Error(`Argument ${i} (${t}) out of range (${e}, ${n})`)}copy(t,e,n){for(let i=0;i<n;i++)e[i]=t[i]}copyFrom(t){if(this._length!=t._length)throw new Error(`Lengths differ (${this._length} != ${t._length})`);this.copy(t._data,this._data,this.lengthInInts),this._version++}get length(){return this._length}get buffer(){return this._data}set buffer(t){this._data=t,this._version++}get version(){return this._version}set version(t){this._version=t}incrementVersion(t=!0){this._version++}get lengthInInts(){return Math.floor((this._length+31)/32)}get versionedName(){return this._version==this._versionedNameVersion?this._versionedName:""}set versionedName(t){this._versionedName=t,this._versionedNameVersion=this._version}get self(){return this}setLength(t){if(t<0)throw new Error("should be >= 0");if(t==this._length)return;const e=Math.floor((t+31)/32);if(e>this._data.length||e+this.SHRINK_THRESHOLD<this._data.length){const t=new Uint32Array(e);this.copy(this._data,t,e>this._data.length?this._data.length:e),this._data=t}t>this._length&&(this._length%32>0&&(this._data[this.lengthInInts-1]&=(1<<(this._length%32&31))-1),this._data.fill(0,this.lengthInInts,e)),this._length=t,this._version++}static fromAnd(t,e){if(t._length!=e._length)throw new Error(`Lengths differ (${t._length} != ${e._length})`);const n=new Wt(t._length);n._length=t._length,n._data=Wt._createBuffer(n._length),n._version=0;const i=t.lengthInInts;for(let o=0;o<i;o++)n._data[o]=t._data[o]&e._data[o];return n}static _createBuffer(t){return new Uint32Array(Math.floor((t+31)/32))}static fromValues(t){const e=new Wt(t.length);e._version=0;for(let n=0;n<e._length;n++)t[n]&&(e._data[Math.floor(n/32)]|=1<<(n%32&31));return e}static fromSeq(t,e){const n=new Wt(t);for(let i=0;i<t;++i)n.setBit(i,e(i));return n._version=0,n}static fromString(t){return Wt.fromSeq(t.length,(e=>"1"==t.charAt(e)))}static fromUint32Array(t,e){const n=new Wt(t);return n._data=e,n}static fromBytes(t){const e=t.length,n=new Wt(8*e);n._data=new Uint32Array(Math.floor((e+3)/4)),n._length=8*e;let i=0,o=0;for(;e-o>=4;)n._data[i++]=255&t[o]|(255&t[o+1])<<8|(255&t[o+2])<<16|(255&t[o+3])<<24,o+=4;return e-o==3&&(n._data[i]=(255&t[o+2])<<16),e-o==2&&(n._data[i]|=(255&t[o+1])<<8),e-o==1&&(n._data[i]|=255&t[o]),n._version=0,n}toString(){return`${this._length} bits, ${this.countBits(!0)} set`}equals(t){if(this==t)return!0;if(null==t)return!1;if(this._length!=t._length)return!1;if(0==this._length)return!0;for(let e=0;e<this._data.length-1;e++)if(this._data[e]!=t._data[e])return!1;for(let e=8*(this._data.length-1);e<this._length;e++)if(this.getBit(e)!=t.getBit(e))return!1;return!0}clone(){const t=new Wt(0,!1);return t._data=Uint32Array.from(this._data),t._length=this._length,t._version=this._version,t}init(t,e){this.setAll(!1,!1);for(let e=0;e<this._length;e++)t(e)&&(this._data[Math.floor(e/32)]|=1<<(e%32&31));return this.incrementVersion(e),this}invert(t=!0){for(let t=0;t<this._data.length;t++)this._data[t]^=-1;this.incrementVersion(t)}setAll(t,e=!1){const n=t?-1:0,i=this.lengthInInts;for(let t=0;t<i;t++)this._data[t]=n;this.incrementVersion(e)}setIndexes(t,e=!0,n=!0,i=!0){n&&this.setAll(!e,!1);for(const n of t)this.setFast(n,e);this.incrementVersion(i)}everyIndex(t,e=!0){for(const n of t)if(this.getBit(n)!=e)return!1;return!0}anyIndex(t,e=!0){for(const n of t)if(this.getBit(n)==e)return!0;return!1}setWhere(t,e=!0,n=!0,i=!0,o=!0){if(n&&o&&this.setAll(!e,!1),o)for(let n=0;n<this._length;n++)t(n)&&this.setFast(n,e);else for(let n=0;n<this._length;n++)this.setFast(n,t(n)?e:!e);this.incrementVersion(i)}getRange(t,e){this.assureInRange(t,0,this._length-1,"from"),this.assureInRange(e,0,this._length,"to");const n=[];for(let i=t;i<e;++i)n.push(this.getBit(i));return Wt.fromValues(n)}getRangeAsList(t,e){this.assureInRange(t,0,this._length-1,"from"),this.assureInRange(e,0,this._length,"to");const n=[];for(let i=t;i<e;++i)n.push(this.getBit(i));return n}setRange(t,e,n,i=!0){this.assureInRange(t,0,this._length-1,"from"),this.assureInRange(e,0,this._length-1,"to");const o=Math.min(t,e),s=Math.max(t,e);if(n)for(let t=o;t<=s;t++)this.setTrue(t);else for(let t=o;t<=s;t++)this.setFalse(t);return this.incrementVersion(i),this}setRandom(t,e,n=!0){if(t<0||t>this._length)throw new Error("n must be >= 0 && <= Count");t>this._length/2&&this.setRandom(this._length-t,!e),this.setAll(!e);for(let n=0;n<t;){const t=Math.floor(Math.random()*this._length);this.getBit(t)!=e&&(this.setFast(t,e),n++)}this.incrementVersion(n)}and(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");for(let e=0,n=this.lengthInInts;e<n;e++)this._data[e]&=t._data[e];return this.incrementVersion(e),this}andNot(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");const n=this.lengthInInts;for(let e=0;e<n;e++)this._data[e]&=~t._data[e];return this.incrementVersion(e),this}notAnd(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");for(let e=0,n=this.lengthInInts;e<n;e++)this._data[e]=~this._data[e]&t._data[e];return this.incrementVersion(e),this}not(t=!0){for(let t=0,e=this.lengthInInts;t<e;t++)this._data[t]=~this._data[t];return this.incrementVersion(t),this}or(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");for(let e=0,n=this.lengthInInts;e<n;e++)this._data[e]|=t._data[e];return this.incrementVersion(e),this}xor(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");for(let e=0,n=this.lengthInInts;e<n;e++)this._data[e]^=t._data[e];return this.incrementVersion(e),this}insertAt(t,e,n=!1){if(this.assureInRange(t,0,this._length,"pos"),0==e)return;const i=this._length;this.setLength(this._length+e);for(let n=i-1;n>=t;n--)this.setBit(n+e,this.getBit(n));for(let i=t;i<t+e;i++)this.setBit(i,n)}removeAt(t,e=1){if(e<0)throw new Error("n cannot be negative");if(this.assureInRange(t,0,this._length-e,"pos"),this.contains(!0))for(let n=t;n<this._length-e;n++)this.setBit(n,this.getBit(n+e));this.setLength(this._length-e)}removeByMask(t,e=!0){if(this._length!=t.length)throw new Error("length != mask.length");if(t==this)this.setLength(t.countBits(!e)),this.setAll(!e);else{let n=0;for(let i=-1;-1!=(i=t.findNext(i,!e));)this.setFast(n++,this.getBit(i));this._length=n,this._version++}return this}getBit(t){return 0!=(this._data[Math.floor(t/32)]&1<<(31&t))}setBit(t,e,n=!0){this.setFast(t,e),this._version++}setFast(t,e){e?this._data[Math.floor(t/32)]|=1<<(31&t):this._data[Math.floor(t/32)]&=~(1<<(31&t))}setTrue(t){this._data[Math.floor(t/32)]|=1<<(31&t)}setFalse(t){this._data[Math.floor(t/32)]&=~(1<<(31&t))}trueCount(){return this.countBits(!0)}falseCount(){return this.countBits(!1)}countBits(t){if(0==this._length)return 0;if(this._selectedCountVersion!=this._version){this._selectedCount=0;const t=this.lengthInInts;let e=0;for(;e<t-1;e++)for(let t=this._data[e];0!=t;t>>>=8)this._selectedCount+=Wt._onBitCount[255&t];let n=this._data[e];const i=31&this._length;for(0!=i&&(n&=~(4294967295<<i));0!=n;n>>>=8)this._selectedCount+=Wt._onBitCount[255&n];this._selectedCountVersion=this._version}return t?this._selectedCount:this._length-this._selectedCount}countWhere(t){let e=0;if(this.trueCount()==this._length)for(let n=0;n<this._length;n++)e+=t(n)?1:0;else for(let n=-1;-1!=(n=this.findNext(n,!0));)e+=t(n)?1:0;return e}andWithCountBits(t,e){if(0==this._length)return 0;let n=0;const i=this.lengthInInts;let o=0;for(;o<i-1;o++)for(let e=this._data[o]&t._data[o];0!=e;e>>>=8)n+=Wt._onBitCount[255&e];let s=this._data[o]&t._data[o];const r=31&this._length;for(0!=r&&(s&=~(4294967295<<r));0!=s;s>>>=8)n+=Wt._onBitCount[255&s];return e?n:this._length-n}clear(){this.setLength(0)}contains(t){return this.findNext(-1,t)>=0}get allTrue(){return this.countBits(!0)==this._length}get allFalse(){return this.countBits(!1)==this._length}get anyTrue(){return this.countBits(!0)>0}get anyFalse(){return this.countBits(!1)>0}findNext(t,e=!0){if(this.assureInRange(t,-1,this._length,"index"),t>=this._length-1)return-1;let n=31&(t=t<0?0:t+1);const i=this.lengthInInts;for(let o=Math.floor(t/32);o<i;o++){let i=e?this._data[o]:~this._data[o];if(0!=n)i&=4294967295<<n&4294967295,n=0;else if(!e&&-4294967296==i)continue;for(let e=0;0!=i;e+=8,i>>>=8){const n=Wt._firstOnBit[255&i];if(n>=0)return(t=n+32*o+e)>=this._length?-1:t}}return-1}findPrev(t,e=!0){if(0==t)return-1;this.assureInRange(t,-1,this._length,"index");let n=1+(t=t<0?this._length-1:t-1)&31;for(let i=Math.floor(t/32);i>=0;i--){let t=e?this._data[i]:~this._data[i];0!=n&&(t&=~(4294967295<<n),n=0);for(let e=24;0!=t;e-=8,t<<=8){const n=Wt._lastOnBit[t>>>24];if(n>=0)return n+32*i+e}}return-1}}Wt._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]),Wt._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]),Wt._lastOnBit=Int8Array.from([-1,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7]),s.SEMTYPE.MOLECULE,s.SEMTYPE.MACROMOLECULE;var Ft,Ht=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};!function(t){t.notNull=function(t,e){if(null==t)throw new Error(`${null==e?"Value":e} not defined`)}}(Ft||(Ft={}));var kt,Ot=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};class Vt{constructor(t,e,n=!1,i){var s;this.name="",this.description="",this._isAutomatic=!1,this._autoStartFirstStep=!1,this._currentStep=0,this._isStopped=!1,this._isCancelled=!1,this._isStepProcessed=!1,this._root=o.div([],{id:"demo-script",classes:"tutorials-root tutorials-track demo-app-script"}),this._steps=[],this._mainHeader=o.panel([],"tutorials-main-header"),this._header=o.h2(""),this._headerDiv=o.divH([],"tutorials-root-header"),this._stopStartBtn=o.button(o.iconFA("pause"),(()=>this._changeStopState()),"Play / pause"),this._restartBtn=o.button(o.iconFA("redo"),(()=>this._restartScript()),"Restart"),this._nextStepBtn=o.button(o.iconFA("play"),(()=>{this._isStepProcessed||this._nextStep()}),"Next step"),this._activity=o.panel([],"tutorials-root-description"),this._progressDiv=o.divV([],"tutorials-root-progress"),this._progress=o.element("progress"),this._progressSteps=o.divText(""),this._closeBtn=o.button(o.iconFA("chevron-left"),(()=>this._closeDock()),"Back to demo"),this.name=t,this.description=e,this._isAutomatic=n,this._autoStartFirstStep=null!==(s=null==i?void 0:i.autoStartFirstStep)&&void 0!==s&&s,this._progress.max=0,this._progress.value=1,Vt.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=o.divText(`Step: ${this._progress.value} of ${this.stepNumber}`),this._progressDiv.append(this._progressSteps)}_addDescription(){var t;this._activity.append(o.div(this.description,"tutorials-root-description"));for(let e=0;e<this.stepNumber;e++){let n=o.iconFA("clock");this._isAutomatic||0===e&&(n=o.iconFA("play",(()=>this._nextStep()),"Next step"),n.className="grok-icon fas fa-play");const i=o.div(this._steps[e].name,"grok-tutorial-entry-instruction"),s=o.div(null===(t=this._steps[e].options)||void 0===t?void 0:t.description,"grok-tutorial-step-description hidden"),r=o.divH([n,i],"grok-tutorial-entry");this._activity.append(r,s)}}_initRoot(){var t,e,n;i.shell.windows.showContextPanel=!0,i.shell.windows.showHelp=!1;const o=Array.from(i.shell.dockManager.rootNode.children)[0];this._node=i.shell.dockManager.dock(this._root,s.DOCK_TYPE.FILL,o,""),(null===(e=null===(t=o.parent.container.containerElement.firstElementChild)||void 0===t?void 0:t.lastElementChild)||void 0===e?void 0:e.classList.contains("tab-handle-list-container"))&&(null===(n=o.parent.container.containerElement.firstElementChild)||void 0===n||n.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 Ot(this,void 0,void 0,(function*(){this._isStepProcessed=!0,this._isAutomatic||(this._nextStepBtn.classList.add("disabled"),this._nextStepBtn.firstChild.classList.add("fa-disabled"));const n=this._activity.getElementsByClassName("grok-tutorial-entry")[this._currentStep],i=this._activity.getElementsByClassName("grok-icon")[this._currentStep],s=this._activity.getElementsByClassName("grok-tutorial-step-description")[this._currentStep];i.className="grok-icon far fa-spinner-third fa-spin",s.classList.remove("hidden"),s.classList.add("visible");const r=n,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),yield this._countdown(n,i,a),yield function(t){return Ht(this,void 0,void 0,(function*(){yield new Promise((e=>setTimeout(e,t)))}))}(a);const l=o.iconFA("check");if(i.replaceWith(l),l.className="grok-icon far fa-check",this._progress.value++,this._progressSteps.innerText=`Step: ${this._progress.value} of ${this.stepNumber}`,this._currentStep++,this._isStepProcessed=!1,this._currentStep!==this.stepNumber){if(!this._isAutomatic){const t=this._activity.getElementsByClassName("grok-icon")[this._currentStep],e=o.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 Ot(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,n){return Ot(this,void 0,void 0,(function*(){const i=o.div([],"demo-script-countdown");e.classList.add("hidden");let s=n/1e3;const r=this._createSVGIndicator(s);i.append(r),t.prepend(i);const a=setInterval((()=>{s--,0===s&&(clearInterval(a),i.remove(),e.classList.remove("hidden"),e.classList.add("visible"))}),1e3)}))}_createSVGIndicator(t){const e=document.createElementNS("http://www.w3.org/2000/svg","svg"),n=document.createElementNS("http://www.w3.org/2000/svg","circle");return n.setAttributeNS(null,"cx","7"),n.setAttributeNS(null,"cy","7"),n.setAttributeNS(null,"r","6"),n.setAttributeNS(null,"style",`animation: countdown ${t}s linear infinite forwards`),e.append(n),e}_changeStopState(){const t=this._stopStartBtn.getElementsByClassName("grok-icon");t[0].className="grok-icon fas fa-play",this._isStopped=!this._isStopped,this._isStopped||(t[0].className="grok-icon fal fa-pause",this._isStepProcessed||this._startScript())}_restartScript(){i.shell.dockManager.close(this._node),i.shell.closeAll(),this._clearRoot(),this._setInitParams(),this.start()}_clearRoot(){this._root=o.div([],{id:"demo-script",classes:"tutorials-root tutorials-track demo-app-script"}),this._mainHeader=o.panel([],"tutorials-main-header"),this._header=o.h2(""),this._headerDiv=o.divH([],"tutorials-root-header"),this._activity=o.panel([],"tutorials-root-description"),this._progressDiv=o.divV([],"tutorials-root-progress"),this._progress=o.element("progress"),this._progressSteps=o.divText(""),this._progress.max=0,this._progress.value=1}_setInitParams(){this._currentStep=0,this._isStopped=!1,this._isCancelled=!1,this._stopStartBtn.getElementsByClassName("grok-icon")[0].className="grok-icon fal fa-pause",this._nextStepBtn.classList.remove("disabled")}_closeDock(){i.shell.dockManager.close(this._node),this.cancelScript()}cancelScript(){this._isCancelled=!0,Vt.currentObject=null}step(t,e,n){return this._steps[this.steps.length]={name:t,func:e,options:n},this}start(){return Ot(this,void 0,void 0,(function*(){this._initRoot(),i.shell.newView(this.name),this._isAutomatic?this._startScript():this._autoStartFirstStep&&(yield this._nextStep())}))}}Vt.currentObject=null,function(t){t.X="Embed_X",t.Y="Embed_Y"}(kt||(kt={})),n(3336),n(8341);var Ut=n(2568),Bt=(n(600),function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))});const Yt=new s.Package;function Kt(){return Gt.NT.instance}function $t(t,e,r,a,l,c){return Bt(this,void 0,void 0,(function*(){if(!(0,Ut.n)(e,"Activity Cliffs"))return;const h=W(t),u={units:e.getTag(s.TAGS.UNITS),aligned:e.getTag("aligned"),separator:e.getTag("separator"),alphabet:e.getTag("alphabet")},d=new I.C(e);let f="Tanimoto";return d.isFasta()&&(f=d.getDistanceFunctionName()),yield function(t,e,r,a,l,c,h,u,d,f,m,p,g,v,y,b,w,S){return tt(this,void 0,void 0,(function*(){et++;const C=h/100,T=null!=r?r:e;let M=!1,E=!1;const A={};let N,P;const x={seqCol:T,methodName:d,similarityMetric:u,embedAxesNames:a,options:w},{distance:_,coordinates:R}=yield p(x);for(const e of R)t.columns.add(e);let L=_;var I,G;Object.values(k.U).map((t=>t.toString())).includes(u)&&(L=yield(I=e,G=u,new Promise((function(t,e){const i=new Worker(new URL(n.p+n.u(367),n.b));i.postMessage({values:I.toList(),fnName:G,options:void 0}),i.onmessage=({data:{distanceMatrixData:n,error:o}})=>{o?e(o):t(n),i.terminate()}}))));const D=yield function(t,e,n,i){return tt(this,void 0,void 0,(function*(){const o=t.categories,r=t.getRawData(),a=s.Column.string("seq",t.length).init((t=>o[r[t]])),l=s.DataFrame.fromColumns([a]),c=t.length;let h=Array(c-1);return n?function(t,e,n){for(let i=0;i<t-1;++i){const o=new Float32Array(t-i-1).fill(0);for(let n=i+1;n<t;++n)o[n-i-1]=e[i][n]===s.FLOAT_NULL?0:F(e[i][n]);n[i]=s.Column.fromFloat32Array("similarity",o)}}(c,e,h):h=yield i(c,t,l,"seq",h),h}))}(T,L,!!L,g),W=function(t,e,n){const i=[],o=[],s=[],r=[],a=new Set;for(let l=0;l!=t.length;++l)for(let c=0;c!=t.length-l;++c){const h=t[l]?t[l].get(c):0;if(h>=e){s.push(l),r.push(l+c+1),a.add(l),a.add(l+c+1),i.push(h);const t=Math.abs(n.get(l)-n.get(l+c+1));1!=h?o.push(t/(1-h)):o.push(1/0)}}return{simVals:i,saliVals:o,n1:s,n2:r,cliffsMolIds:a}}(D,C,c),H=function(t,e,n,i,o,r){const a=new Array(t).fill(0);for(let t=0;t!=n.length;++t)e[t]!=1/0&&(r.get(n[t])>r.get(i[t])?a[n[t]]+=e[t]:a[i[t]]+=e[t]);return s.Column.fromList("double",`sali_${o[0].substring(o[0].lastIndexOf("_"))}`,a)}(T.length,W.saliVals,W.n1,W.n2,a,c);t.columns.add(H);const O=function(t,e){const n="containsCliff",i=t.columns.names().filter((t=>t.includes(n))).length+1,o=`${n}_${i}`;return s.Column.bool(o,t.rowCount).init((t=>e.has(t)))}(t,W.cliffsMolIds);t.columns.add(O);const V=function(t){const e=t.filter((t=>t!==1/0)),n=Math.min(...e);return{max:Math.max(...e),min:n}}(W.saliVals),U=.8/(V.max-V.min),B=i.shell.getTableView(t.name);B.grid.columns.byName(O.name).visible=!1;const Y=B.addViewer(s.VIEWER.SCATTER_PLOT,{xColumnName:a[0],yColumnName:a[1],size:H.name,color:c.name,showXSelector:!1,showYSelector:!1,showSizeSelector:!1,showColorSelector:!1,markerMinSize:5,markerMaxSize:25,title:l}),K=Y.getInfo().canvas,$=function(t,e,n,i,o){const r=new Array(t.n1.length).fill(null);for(let e=0;e<t.n1.length;e++){const n=t.n1[e],i=t.n2[e];r[e]={id:e,mols:[n,i],selected:!1,a:[],b:[]}}const a=s.DataFrame.create(r.length);return lt.forEach(((t,n)=>{a.columns.addNewString(t).init((t=>e.get(r[t].mols[n]))),function(t,e){Object.keys(e).forEach((n=>{t.tags[n]=e[n]}))}(a.col(t),o),a.col(t).semType=i})),a.columns.addNewFloat(ot).init((t=>Math.abs(n.get(r[t].mols[0])-n.get(r[t].mols[1])))),a.columns.addNewInt(at).init((t=>t)),a.columns.addNewFloat(st).init((e=>t.saliVals[e])),a.columns.addNewFloat(rt).init((e=>t.simVals[e])),a.name=`${nt}${et}`,{lines:r,linesDf:a}}(W,e,c,f,m),Z=b?b($.linesDf,lt).sort([st],[!1]):$.linesDf.plot.grid().sort([st],[!1]);t.temp[".cliffsDfGrid"]=Z;const q=o.button(`${$.linesDf.rowCount} cliffs`,(()=>{B.dockManager.dock(Z,"down",null,"Activity cliffs",null!=S?S:.2)}));q.classList.add("scatter_plot_link","cliffs_grid"),Y.root.append(q);const z=o.switchInput("Show only cliffs",!1,(()=>{z.value?(Y.dataFrame.setTag(ct,O.name),t.rows.match({[O.name]:!0}).filter(),it.next(O.name)):(Y.dataFrame.setTag(ct,""),t.filter.setAll(!0,!0),it.next(""))}));z.root.classList.add("scatter_plot_link","show_only_cliffs"),Y.root.append(z.root),it.subscribe((t=>{""!==t?t!==O.name&&(z.enabled=!1):z.enabled=!0}));const X=i.events.onViewerClosed.subscribe((t=>{t.args.viewer===Y&&(B.dockManager.close(Z.root),X.unsubscribe(),B.subs=B.subs.filter((t=>t!==X)))}));return B.subs.push(X),$.linesDf.onCurrentCellChanged.subscribe((()=>{M=!0;const n=$.linesDf.currentCol&&$.linesDf.currentCol.name===lt[1]?1:0,s=-1!==$.linesDf.currentRowIdx?$.lines[$.linesDf.currentRowIdx]:null;Y.dataFrame.currentRowIdx=s?s.mols[n]:-1,Y.dataFrame.filter.set(0,!$.lines[0].selected),Y.dataFrame.filter.set(0,$.lines[0].selected),s&&setTimeout((()=>{!function(t,e,n,s,r,a,l,c){const h=e.getPane("Cliff Details");o.empty(h.root);const u=c({cashedData:n,line:s,df:t,seqCol:r,activityCol:a,sali:l});h.root.append(u),setTimeout((()=>{i.shell.o=e.root}),500)}(t,N,A,s,e,c,$.linesDf.get(st,s.id),y);const n=Y.dataFrame.getSortedOrder(B.grid.sortByColumns,B.grid.sortTypes);B.grid.scrollToCell(e.name,n.indexOf(Y.dataFrame.currentRowIdx))}),1e3)})),$.linesDf.onSelectionChanged.subscribe((e=>{if(!1===$.linesDf.selection.anyTrue)$.lines.forEach((t=>{t.selected=!1}));else if(-1!==$.linesDf.mouseOverRowIdx){const t=$.lines[$.linesDf.mouseOverRowIdx];t.selected=!t.selected}setTimeout((()=>{const e=s.BitSet.create(t.rowCount);$.lines.forEach((t=>{t.selected&&t.mols.forEach((n=>{e.set(n,t.selected,!0)}))})),t.selection.copyFrom(e),B.grid.invalidate()}),300)})),t.onSelectionChanged.subscribe((e=>{E?E=!1:!1===t.selection.anyTrue&&"number"==typeof e&&($.lines.forEach((t=>{t.selected=!1})),Z.dataFrame.selection.setAll(!1,!1),Z.invalidate())})),K.addEventListener("mousemove",(function(i){clearTimeout(P),P=n.g.setTimeout((function(){const n=ht(i,K,$.lines);n&&-1===t.mouseOverRowIdx&&o.tooltip.show(v({cashedData:A,line:n,df:t,seqCol:e,activityCol:c}),i.clientX,i.clientY)}),500)})),K.addEventListener("mousedown",(function(e){E=!0;const n=ht(e,K,$.lines);if(n&&-1===t.mouseOverRowIdx){e.ctrlKey?(n.selected=!n.selected,$.linesDf.selection.set(n.id,n.selected)):$.linesDf.currentRowIdx!==n.id&&($.linesDf.currentRowIdx=n.id,t.currentRowIdx=n.mols[0],t.filter.set(0,!$.lines[0].selected),t.filter.set(0,$.lines[0].selected));const i=$.linesDf.getSortedOrder(Z.sortByColumns,Z.sortTypes);Z.scrollToCell(lt[0],i.indexOf(n.id))}})),Y.onEvent("d4-before-draw-scene").subscribe((e=>{const n=function(t,e,n,i,o,s,r){const a=i.lines,l=t.getInfo().canvas.getContext("2d"),c=t.dataFrame.columns.byName(e),h=t.dataFrame.columns.byName(n);for(let e=0;e<a.length;e++){const n=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=[n.x,n.y],a[e].b=[u.x,u.y];const d=new Path2D;d.moveTo(a[e].a[0],a[e].a[1]);const f=a[e].selected?"255,255,0":"0,128,0",m=o[e]===1/0?1:.2+(o[e]-r)*s;l.strokeStyle=`rgba(${f},${m})`,l.lineWidth=a[e].id===i.linesDf.currentRowIdx?3:1,d.lineTo(a[e].b[0],a[e].b[1]),l.stroke(d)}return a}(Y,a[0],a[1],$,W.saliVals,U,V.min);if(M){const t=n[$.linesDf.currentRowIdx];setTimeout((()=>{const{zoomLeft:e,zoomRight:n,zoomTop:i,zoomBottom:o}=function(t,e,n,i,o,s){const r=Math.abs(n-o),a=Math.abs(i-s),l=t/r,c=e/a,h=Math.min(l,c),u=t/h*5,d=e/h*5,f=(n<o?n:o)+r/2-u/2,m=(i>s?i:s)-a/2+d/2;return{zoomLeft:f,zoomRight:f+u,zoomTop:m,zoomBottom:m-d}}(Y.viewport.width,Y.viewport.height,Y.dataFrame.get(a[0],t.mols[0]),Y.dataFrame.get(a[1],t.mols[0]),Y.dataFrame.get(a[0],t.mols[1]),Y.dataFrame.get(a[1],t.mols[1]));Y.zoom(e,i,n,o)}),300),M=!1}z.value?t.rows.match({[O.name]:!0}).filter():!0===z.enabled&&t.filter.setAll(!0,!1)})),Y.addProperty("similarityLimit","double",C),N=function(){const t=o.accordion(),e=o.element("i");return e.className="grok-icon svg-icon svg-view-layout",t.addTitle(o.span([e,o.label("Activity cliffs")])),t.addPane("Cliff Details",(()=>o.divText("Cliff has not been selected")),!0),i.shell.o=t.root,t}(),Y}))}(t,e,null,h,"Activity cliffs",r,a,f,l,s.SEMTYPE.MACROMOLECULE,u,D,Mt,Et,At,Pt,c)}))}function Zt(t,e,n,o="Tanimoto",r,a){return Bt(this,void 0,void 0,(function*(){if(yield(0,It.gw)(10),!(0,Ut.n)(e,"Sequence space"))return;const l=W(t),c=s.DataFrame.fromColumns([e]).clone(),h=function(t,e){const n=e.categories.map(((t,e)=>t?null:e)).filter((t=>null!==t)),i=[...e.getRawData()],o=[];let s=0;for(let e=0;e<t.rowCount;e++)n.includes(i[e])&&(t.rows.removeAt(e-s),o.push(e),s+=1);return o}(c,e),u={seqCol:c.col(e.name),methodName:n,similarityMetric:o,embedAxesNames:l,options:a},d=(yield D(u)).coordinates;for(const e of d){const n=e.toList();h.forEach((t=>n.splice(t,0,null))),t.columns.add(s.Column.float(e.name,t.rowCount).init((t=>n[t])))}return r?i.shell.tableView(t.name).scatterPlot({x:l[0],y:l[1],title:"Sequence space"}):void 0}))}function qt(t,e){return Bt(this,void 0,void 0,(function*(){if(0===s.Func.find({package:"Chem",name:"getRdKitModule"}).length)return void i.shell.warning('Transformation to atomic level requires package "Chem" installed.');if(!(0,Ut.n)(e,"To Atomic Level"))return;const n=(yield Kt()).getBioLib(),r=yield(0,xt.i0)(t,e,n);null!==r.col&&(t.columns.add(r.col,!0),yield i.data.detectSemanticTypes(t)),r.warnings&&r.warnings.length>0&&i.shell.warning(o.list(r.warnings))}))}function zt(t){return new _t.i(t).importFasta()}function Xt(){const t=(0,Lt.m)(),e=function(t){const e=(0,r.Mj)(t),n=t=>{const e=a.columns.addNewString((t+1).toString());return i.push(e),e},i=[],o=t.length,a=s.DataFrame.create(o);for(let s=0;s<o;++s){const o=t.get(s);null!=o&&e(o).forEach(((t,e)=>{var o;((null!==(o=i[e])&&void 0!==o?o:null)||n(e)).set(s,t||"-",!1)}))}return a}(t),n=t.dataFrame;for(const i of e.columns){const e=n.columns.add(i);e.semType=h.Of.MONOMER,e.setTag(s.TAGS.CELL_RENDERER,h.Of.MONOMER),e.setTag("alphabet",t.getTag("alphabet"))}i.shell.tv.grid.invalidate()}function jt(t){const e=(0,u.fy)(t,1,u.gP);return Object.keys(e.freq)}},7983:(t,e,n)=>{"use strict";n.d(e,{HV:()=>h,QF:()=>c,pf:()=>l});var i=n(4469),o=(n(3870),n(976)),s=n(7241),r=(n(4293),n(1061)),a=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};function l(t,e,n){const i=n?function(t,e){const n=`${e}`.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),i=t.charAt(0)===e,o=t.charAt(t.length-1)===e,s=t.replace(new RegExp(`^${n}|${n}$`,"g"),"");return i?o?`${n}${s}${n}`:`${n}${s}${n}|${n}${s}$`:o?`^${s}${n}|${n}${s}${n}`:`^${s}${n}|${n}${s}${n}|${n}${s}$`}(t,n):t,s=o.BitSet.create(e.length);for(let n=0;n<e.length;n++){const o=e.get(n);(o.match(i)||o===t)&&s.set(n,!0,!1)}return s}function c(t,e){return a(this,void 0,void 0,(function*(){e.version!==e.temp["last-invalidated-version"]&&(yield h(e,!0));const n=o.Column.string("helm",1).init((e=>t));n.setTag(o.TAGS.UNITS,"helm");const r=yield(0,s.D)(n,!0,e.temp["monomers-dict"]);return(yield i.functions.call("Chem:searchSubstructure",{molStringsColumn:e.temp["monomeric-mols"],molString:r.get(0),molBlockFailover:""})).get(0)}))}function h(t,e){return a(this,void 0,void 0,(function*(){const n=o.TaskBarProgressIndicator.create(`Invalidating molfiles for ${t.name}`);yield(0,r.gw)(10);const i=new Map,a=yield(0,s.D)(t,e,i);t.temp["monomeric-mols"]=a,t.temp["monomers-dict"]=i,t.temp["last-invalidated-version"]=t.version,n.close()}))}},2568:(t,e,n)=>{"use strict";n.d(e,{l:()=>a,n:()=>r});var i=n(4469),o=n(976),s=n(499);function r(t,e,n=[],o=[],s=!0){const[r,l]=a(t,e,n,o);return s&&!r&&i.shell.warning(l),r}function a(t,e,n=[],r=[]){let a=!0,l="";const c=new s.C(t);if(t.semType!==o.SEMTYPE.MACROMOLECULE)i.shell.warning(e+" analysis is allowed for Macromolecules semantic type"),a=!1;else{const t=c.notation;if(n.length>0&&!n.some((e=>t.toUpperCase()==e.toUpperCase())))l=`${e} + ' analysis is allowed for Macromolecules with notation ${0==n.length?"any notation":`notation${n.length>1?"s":""} ${n.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,n)=>{"use strict";var i,o,s;n.d(e,{Of:()=>s,mU:()=>r,rs:()=>l}),function(t){t.SPLIT_COL="~split",t.ACTIVITY="~activity",t.ACTIVITY_SCALED="activity_scaled",t.ALIGNED_SEQUENCE="~aligned_sequence",t.AMINO_ACID_RESIDUE="AAR",t.POSITION="Pos",t.P_VALUE="pValue",t.MEAN_DIFFERENCE="Mean difference"}(i||(i={})),function(t){t.AAR="AAR",t.POSITION="Pos",t.SELECTION="selection"}(o||(o={})),function(t){t.MONOMER="Monomer",t.MACROMOLECULE_DIFFERENCE="MacromoleculeDifference",t.ACTIVITY="activity",t.ACTIVITY_SCALED="activityScaled"}(s||(s={}));const r="MSA";var a,l;!function(t){t.CELL_CHANGING="isCellChanging"}(a||(a={})),function(t){t.SEPARATOR="."}(l||(l={}))},4004:(t,e,n)=>{"use strict";n.d(e,{o:()=>r}),n(3870);var i=n(4469),o=(n(3336),n(7767)),s=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};function r(t,e,n){return s(this,void 0,void 0,(function*(){const s=new o.L(t).convert(e,n);t.dataFrame.columns.add(s);const r=yield i.functions.call("Bio:detectMacromolecule",{col:s});return r&&(s.semType=r),yield i.data.detectSemanticTypes(t.dataFrame),s}))}},1345:(t,e,n)=>{"use strict";n.d(e,{NT:()=>m,RV:()=>l,rb:()=>h});var i=n(976),o=n(4469),s=n(701),r=n(7228),a=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};const l="Libraries",c="System:AppData/Bio/libraries/",h={"HELMCoreLibrary.json":"HELMCoreLibrary.json"};function u(){return a(this,void 0,void 0,(function*(){return(yield o.dapi.files.list(`${c}`,!1,"")).map((t=>t.fileName))}))}function d(){return a(this,void 0,void 0,(function*(){const t=yield o.dapi.userDataStorage.getValue(l,"Settings",!0),e=t?JSON.parse(t):{exclude:[]};return e.exclude=e.exclude instanceof Array?e.exclude:[],e}))}class f{constructor(t){this._monomers={},this._onChanged=new s.Subject,this._monomers=t}getMonomer(t,e){return t in this._monomers&&e in this._monomers[t]?this._monomers[t][e]:null}getTypes(){return Object.keys(this._monomers)}getMonomerMolsByType(t){const e={};return Object.keys(this._monomers[t]).forEach((n=>{e[n]=this._monomers[t][n].molfile})),e}getMonomerNamesByType(t){return Object.keys(this._monomers[t])}get onChanged(){return this._onChanged}_updateInt(t){const e=t.getTypes(),n=this.getTypes();e.forEach((e=>{n.includes(e)||(this._monomers[e]={}),t.getMonomerNamesByType(e).forEach((n=>{this._monomers[e][n]=t.getMonomer(e,n)}))}))}update(t){this._updateInt(t),this._onChanged.next()}updateLibs(t,e=!1){e&&(this._monomers={});for(const e of t)this._updateInt(e);this._onChanged.next()}clear(){this._monomers={},this._onChanged.next()}}class m{constructor(){this._monomerLib=new f({}),this.loadLibrariesPromise=Promise.resolve()}getBioLib(){return this._monomerLib}loadLibraries(t=!1){return a(this,void 0,void 0,(function*(){return this.loadLibrariesPromise=this.loadLibrariesPromise.then((()=>a(this,void 0,void 0,(function*(){const[e,n]=yield Promise.all([u(),d()]),i=yield Promise.all(e.filter((t=>!n.exclude.includes(t))).map((t=>this.readLibrary(c,t))));this._monomerLib.updateLibs(i,t)}))))}))}readLibrary(t,e){return a(this,void 0,void 0,(function*(){let n,s,a=[];const l=new i.FileSource(t);if(e.endsWith(".sdf"))1===i.Func.find({package:"Chem",name:"importSdf"}).length?(n=yield l.readAsBytes(e),s=yield o.functions.call("Chem:importSdf",{bytes:n}),a=(0,r.Xk)(s[0])):o.shell.warning("Chem package is not installed");else{const t=yield l.readAsText(e);a=JSON.parse(t)}const c={},h=[];return a.forEach((t=>{const e={symbol:t.symbol,name:t.name,naturalAnalog:t.naturalAnalog,molfile:t.molfile,rgroups:t.rgroups,polymerType:t.polymerType,monomerType:t.monomerType,data:{}};Object.keys(t).forEach((n=>{r.DC.includes(n)||(e.data[n]=t[n])})),h.includes(t.polymerType)||(c[t.polymerType]={},h.push(t.polymerType)),c[t.polymerType][t.symbol]=e})),new f(c)}))}static get instance(){return m._instance||(m._instance=new m),m._instance}}m._instance=null},600:(t,e,n)=>{"use strict";n.d(e,{K:()=>f});var i=n(4469),o=n(976),s=n(3870),r=n(6098),a=n(8341),l=n(2568),c=n(7767),h=n(473),u=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};class d extends Error{constructor(t,e){super(t,e)}}function f(t={}){return u(this,void 0,void 0,(function*(){return new Promise(((e,n)=>u(this,void 0,void 0,(function*(){var r,l,c,h,f,g,v,y,b,w,S;null!==(r=t.clustersCol)&&void 0!==r||(t.clustersCol=null),null!==(l=t.pepsea)&&void 0!==l||(t.pepsea={}),null!==(c=(b=t.pepsea).method)&&void 0!==c||(b.method=a.J[0]),null!==(h=(w=t.pepsea).gapOpen)&&void 0!==h||(w.gapOpen=1.53),null!==(f=(S=t.pepsea).gapExtend)&&void 0!==f||(S.gapExtend=0);const C=null!==(v=null===(g=t.col)||void 0===g?void 0:g.dataFrame)&&void 0!==v?v:i.shell.t,T=null!==(y=t.col)&&void 0!==y?y:C.columns.bySemType(o.SEMTYPE.MACROMOLECULE);if(null==T){const t="MSAError: dataset doesn't conain any Macromolecule column";i.shell.warning(t),n(new d(t))}const M=s.choiceInput("Method",t.pepsea.method,a.J);M.setTooltip("Alignment method");const E=s.floatInput("Gap open",t.pepsea.gapOpen);E.setTooltip("Gap opening penalty at group-to-group alignment");const A=s.floatInput("Gap extend",t.pepsea.gapExtend);A.setTooltip("Gap extension penalty to skip the alignment");const N=[M.root.style,E.root.style,A.root.style];let P;const x=s.columnInput("Sequence",C,T,(()=>u(this,void 0,void 0,(function*(){P=yield p(x.value,C,N,M,_,E,A)}))));x.setTooltip("Sequences column to use for alignment");const _=s.columnInput("Clusters",C,t.clustersCol);if(_.nullable=!0,x.fireChanged(),t.col)return P=yield p(t.col,C,N,M,_,E,A),void(yield m(x,C,P,e,n));s.dialog("MSA").add(x).add(_).add(M).add(E).add(A).onOK((()=>u(this,void 0,void 0,(function*(){yield m(x,C,P,e,n)})))).show()}))))}))}function m(t,e,n,s,r){return u(this,void 0,void 0,(function*(){let a=null;const l=o.TaskBarProgressIndicator.create("Analyze for MSA ...");try{if(t.fireChanged(),t.value.semType!==o.SEMTYPE.MACROMOLECULE)throw new Error("Chosen column has to be of Macromolecule semantic type");if(void 0===n)throw new Error("Invalid column format");if(a=yield n(),null==a)return i.shell.warning("Wrong column format");e.columns.add(a),yield i.data.detectSemanticTypes(e),s(a)}catch(t){const e=t instanceof Error?t.message:t.toString();i.shell.error(e),r(t)}finally{l.close()}}))}function p(t,e,n,s,d,f,m){return u(this,void 0,void 0,(function*(){try{if(t.semType!==o.SEMTYPE.MACROMOLECULE)return;const i=e.columns.getUnusedName(`msa(${t.name})`);if((0,l.n)(t,t.name,["fasta","separator"],["DNA","RNA","PT"],!1)){for(const t of n)t.display="none";const e=new c.L(t),o=e.isFasta()?t:e.convert("fasta");return()=>u(this,void 0,void 0,(function*(){return yield(0,r.U)(o,!1,i,d.value)}))}if((0,l.n)(t,t.name,["helm"],[],!1)){for(const t of n)t.removeProperty("display");return()=>u(this,void 0,void 0,(function*(){return yield(0,a.f)(t,i,s.value,f.value,m.value,d.value)}))}if((0,l.n)(t,t.name,["separator"],["UN"],!1)){const e=new c.L(t);if(!(yield e.checkHelmCompatibility()))return;const o=e.convert("helm");for(const t of n)t.removeProperty("display");return console.log(o.toList()),()=>u(this,void 0,void 0,(function*(){return yield(0,a.f)(o,i,s.value,f.value,m.value,d.value)}))}for(const t of n)t.display="none";return}catch(t){const e=t instanceof Error?t.message:t.toString();i.shell.error(e),h._package.logger.error(e)}}))}},6098:(t,e,n)=>{"use strict";n.d(e,{U:()=>G});var i=n(976),o=n(5226);const s=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[s],serialize(t){const{port1:e,port2:n}=new MessageChannel;return u(t,e),[n,[n]]},deserialize:t=>(t.start(),f(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 n(i){if(!i||!i.data)return;const{id:o,type:r,path:a}=Object.assign({path:[]},i.data),c=(i.data.argumentList||[]).map(w);let h;try{const e=a.slice(0,-1).reduce(((t,e)=>t[e]),t),n=a.reduce(((t,e)=>t[e]),t);switch(r){case"GET":h=n;break;case"SET":e[a.slice(-1)[0]]=w(i.data.value),h=!0;break;case"APPLY":h=n.apply(e,c);break;case"CONSTRUCT":h=function(t){return Object.assign(t,{[s]:!0})}(new n(...c));break;case"ENDPOINT":{const{port1:e,port2:n}=new MessageChannel;u(t,n),h=function(t,e){return y.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[i,s]=b(t);e.postMessage(Object.assign(Object.assign({},i),{id:o}),s),"RELEASE"===r&&(e.removeEventListener("message",n),d(e))}))})),e.start&&e.start()}function d(t){(function(t){return"MessagePort"===t.constructor.name})(t)&&t.close()}function f(t,e){return p(t,[],e)}function m(t){if(t)throw new Error("Proxy has been released and is not useable")}function p(t,e=[],n=function(){}){let i=!1;const o=new Proxy(n,{get(n,s){if(m(i),s===a)return()=>S(t,{type:"RELEASE",path:e.map((t=>t.toString()))}).then((()=>{d(t),i=!0}));if("then"===s){if(0===e.length)return{then:()=>o};const n=S(t,{type:"GET",path:e.map((t=>t.toString()))}).then(w);return n.then.bind(n)}return p(t,[...e,s])},set(n,o,s){m(i);const[r,a]=b(s);return S(t,{type:"SET",path:[...e,o].map((t=>t.toString())),value:r},a).then(w)},apply(n,o,s){m(i);const a=e[e.length-1];if(a===r)return S(t,{type:"ENDPOINT"}).then(w);if("bind"===a)return p(t,e.slice(0,-1));const[l,c]=v(s);return S(t,{type:"APPLY",path:e.map((t=>t.toString())),argumentList:l},c).then(w)},construct(n,o){m(i);const[s,r]=v(o);return S(t,{type:"CONSTRUCT",path:e.map((t=>t.toString())),argumentList:s},r).then(w)}});return o}function g(t){return Array.prototype.concat.apply([],t)}function v(t){const e=t.map(b);return[e.map((t=>t[0])),g(e.map((t=>t[1])))]}const y=new WeakMap;function b(t){for(const[e,n]of h)if(n.canHandle(t)){const[i,o]=n.serialize(t);return[{type:"HANDLER",name:e,value:i},o]}return[{type:"RAW",value:t},y.get(t)||[]]}function w(t){switch(t.type){case"HANDLER":return h.get(t.name).deserialize(t.value);case"RAW":return t.value}}function S(t,e,n){return new Promise((i=>{const o=new Array(4).fill(0).map((()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16))).join("-");t.addEventListener("message",(function e(n){!n.data||!n.data.id||n.data.id!==o||(t.removeEventListener("message",e),i(n.data))})),t.start&&t.start(),t.postMessage(Object.assign({id:o},e),n)}))}const C="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2NvbnN0ICQ9U3ltYm9sKCJDb21saW5rLnByb3h5IiksQT1TeW1ib2woIkNvbWxpbmsuZW5kcG9pbnQiKSxSPVN5bWJvbCgiQ29tbGluay5yZWxlYXNlUHJveHkiKSx5PVN5bWJvbCgiQ29tbGluay50aHJvd24iKSxfPWU9PnR5cGVvZiBlPT0ib2JqZWN0IiYmZSE9PW51bGx8fHR5cGVvZiBlPT0iZnVuY3Rpb24iLEw9e2NhbkhhbmRsZTplPT5fKGUpJiZlWyRdLHNlcmlhbGl6ZShlKXtjb25zdHtwb3J0MTpyLHBvcnQyOml9PW5ldyBNZXNzYWdlQ2hhbm5lbDtyZXR1cm4gdyhlLHIpLFtpLFtpXV19LGRlc2VyaWFsaXplKGUpe3JldHVybiBlLnN0YXJ0KCksQyhlKX19LE89e2NhbkhhbmRsZTplPT5fKGUpJiZ5IGluIGUsc2VyaWFsaXplKHt2YWx1ZTplfSl7bGV0IHI7cmV0dXJuIGUgaW5zdGFuY2VvZiBFcnJvcj9yPXtpc0Vycm9yOiEwLHZhbHVlOnttZXNzYWdlOmUubWVzc2FnZSxuYW1lOmUubmFtZSxzdGFjazplLnN0YWNrfX06cj17aXNFcnJvcjohMSx2YWx1ZTplfSxbcixbXV19LGRlc2VyaWFsaXplKGUpe3Rocm93IGUuaXNFcnJvcj9PYmplY3QuYXNzaWduKG5ldyBFcnJvcihlLnZhbHVlLm1lc3NhZ2UpLGUudmFsdWUpOmUudmFsdWV9fSxFPW5ldyBNYXAoW1sicHJveHkiLExdLFsidGhyb3ciLE9dXSk7ZnVuY3Rpb24gdyhlLHI9c2VsZil7ci5hZGRFdmVudExpc3RlbmVyKCJtZXNzYWdlIixmdW5jdGlvbiBpKHMpe2lmKCFzfHwhcy5kYXRhKXJldHVybjtjb25zdHtpZDpvLHR5cGU6YSxwYXRoOm59PU9iamVjdC5hc3NpZ24oe3BhdGg6W119LHMuZGF0YSksdT0ocy5kYXRhLmFyZ3VtZW50TGlzdHx8W10pLm1hcChtKTtsZXQgbDt0cnl7Y29uc3QgYz1uLnNsaWNlKDAsLTEpLnJlZHVjZSgoZCxoKT0+ZFtoXSxlKSxmPW4ucmVkdWNlKChkLGgpPT5kW2hdLGUpO3N3aXRjaChhKXtjYXNlIkdFVCI6bD1mO2JyZWFrO2Nhc2UiU0VUIjpjW24uc2xpY2UoLTEpWzBdXT1tKHMuZGF0YS52YWx1ZSksbD0hMDticmVhaztjYXNlIkFQUExZIjpsPWYuYXBwbHkoYyx1KTticmVhaztjYXNlIkNPTlNUUlVDVCI6e2NvbnN0IGQ9bmV3IGYoLi4udSk7bD16KGQpfWJyZWFrO2Nhc2UiRU5EUE9JTlQiOntjb25zdHtwb3J0MTpkLHBvcnQyOmh9PW5ldyBNZXNzYWdlQ2hhbm5lbDt3KGUsaCksbD1OKGQsW2RdKX1icmVhaztjYXNlIlJFTEVBU0UiOmw9dm9pZCAwO2JyZWFrO2RlZmF1bHQ6cmV0dXJufX1jYXRjaChjKXtsPXt2YWx1ZTpjLFt5XTowfX1Qcm9taXNlLnJlc29sdmUobCkuY2F0Y2goYz0+KHt2YWx1ZTpjLFt5XTowfSkpLnRoZW4oYz0+e2NvbnN0W2YsZF09UyhjKTtyLnBvc3RNZXNzYWdlKE9iamVjdC5hc3NpZ24oT2JqZWN0LmFzc2lnbih7fSxmKSx7aWQ6b30pLGQpLGE9PT0iUkVMRUFTRSImJihyLnJlbW92ZUV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLGkpLEYocikpfSl9KSxyLnN0YXJ0JiZyLnN0YXJ0KCl9ZnVuY3Rpb24gVChlKXtyZXR1cm4gZS5jb25zdHJ1Y3Rvci5uYW1lPT09Ik1lc3NhZ2VQb3J0In1mdW5jdGlvbiBGKGUpe1QoZSkmJmUuY2xvc2UoKX1mdW5jdGlvbiBDKGUscil7cmV0dXJuIGIoZSxbXSxyKX1mdW5jdGlvbiBwKGUpe2lmKGUpdGhyb3cgbmV3IEVycm9yKCJQcm94eSBoYXMgYmVlbiByZWxlYXNlZCBhbmQgaXMgbm90IHVzZWFibGUiKX1mdW5jdGlvbiBiKGUscj1bXSxpPWZ1bmN0aW9uKCl7fSl7bGV0IHM9ITE7Y29uc3Qgbz1uZXcgUHJveHkoaSx7Z2V0KGEsbil7aWYocChzKSxuPT09UilyZXR1cm4oKT0+ZyhlLHt0eXBlOiJSRUxFQVNFIixwYXRoOnIubWFwKHU9PnUudG9TdHJpbmcoKSl9KS50aGVuKCgpPT57RihlKSxzPSEwfSk7aWYobj09PSJ0aGVuIil7aWYoci5sZW5ndGg9PT0wKXJldHVybnt0aGVuOigpPT5vfTtjb25zdCB1PWcoZSx7dHlwZToiR0VUIixwYXRoOnIubWFwKGw9PmwudG9TdHJpbmcoKSl9KS50aGVuKG0pO3JldHVybiB1LnRoZW4uYmluZCh1KX1yZXR1cm4gYihlLFsuLi5yLG5dKX0sc2V0KGEsbix1KXtwKHMpO2NvbnN0W2wsY109Uyh1KTtyZXR1cm4gZyhlLHt0eXBlOiJTRVQiLHBhdGg6Wy4uLnIsbl0ubWFwKGY9PmYudG9TdHJpbmcoKSksdmFsdWU6bH0sYykudGhlbihtKX0sYXBwbHkoYSxuLHUpe3Aocyk7Y29uc3QgbD1yW3IubGVuZ3RoLTFdO2lmKGw9PT1BKXJldHVybiBnKGUse3R5cGU6IkVORFBPSU5UIn0pLnRoZW4obSk7aWYobD09PSJiaW5kIilyZXR1cm4gYihlLHIuc2xpY2UoMCwtMSkpO2NvbnN0W2MsZl09TSh1KTtyZXR1cm4gZyhlLHt0eXBlOiJBUFBMWSIscGF0aDpyLm1hcChkPT5kLnRvU3RyaW5nKCkpLGFyZ3VtZW50TGlzdDpjfSxmKS50aGVuKG0pfSxjb25zdHJ1Y3QoYSxuKXtwKHMpO2NvbnN0W3UsbF09TShuKTtyZXR1cm4gZyhlLHt0eXBlOiJDT05TVFJVQ1QiLHBhdGg6ci5tYXAoYz0+Yy50b1N0cmluZygpKSxhcmd1bWVudExpc3Q6dX0sbCkudGhlbihtKX19KTtyZXR1cm4gb31mdW5jdGlvbiBEKGUpe3JldHVybiBBcnJheS5wcm90b3R5cGUuY29uY2F0LmFwcGx5KFtdLGUpfWZ1bmN0aW9uIE0oZSl7Y29uc3Qgcj1lLm1hcChTKTtyZXR1cm5bci5tYXAoaT0+aVswXSksRChyLm1hcChpPT5pWzFdKSldfWNvbnN0IFA9bmV3IFdlYWtNYXA7ZnVuY3Rpb24gTihlLHIpe3JldHVybiBQLnNldChlLHIpLGV9ZnVuY3Rpb24geihlKXtyZXR1cm4gT2JqZWN0LmFzc2lnbihlLHtbJF06ITB9KX1mdW5jdGlvbiBTKGUpe2Zvcihjb25zdFtyLGldb2YgRSlpZihpLmNhbkhhbmRsZShlKSl7Y29uc3RbcyxvXT1pLnNlcmlhbGl6ZShlKTtyZXR1cm5be3R5cGU6IkhBTkRMRVIiLG5hbWU6cix2YWx1ZTpzfSxvXX1yZXR1cm5be3R5cGU6IlJBVyIsdmFsdWU6ZX0sUC5nZXQoZSl8fFtdXX1mdW5jdGlvbiBtKGUpe3N3aXRjaChlLnR5cGUpe2Nhc2UiSEFORExFUiI6cmV0dXJuIEUuZ2V0KGUubmFtZSkuZGVzZXJpYWxpemUoZS52YWx1ZSk7Y2FzZSJSQVciOnJldHVybiBlLnZhbHVlfX1mdW5jdGlvbiBnKGUscixpKXtyZXR1cm4gbmV3IFByb21pc2Uocz0+e2NvbnN0IG89VSgpO2UuYWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsZnVuY3Rpb24gYShuKXshbi5kYXRhfHwhbi5kYXRhLmlkfHxuLmRhdGEuaWQhPT1vfHwoZS5yZW1vdmVFdmVudExpc3RlbmVyKCJtZXNzYWdlIixhKSxzKG4uZGF0YSkpfSksZS5zdGFydCYmZS5zdGFydCgpLGUucG9zdE1lc3NhZ2UoT2JqZWN0LmFzc2lnbih7aWQ6b30sciksaSl9KX1mdW5jdGlvbiBVKCl7cmV0dXJuIG5ldyBBcnJheSg0KS5maWxsKDApLm1hcCgoKT0+TWF0aC5mbG9vcihNYXRoLnJhbmRvbSgpKk51bWJlci5NQVhfU0FGRV9JTlRFR0VSKS50b1N0cmluZygxNikpLmpvaW4oIi0iKX1jb25zdCBXPWFzeW5jKCk9PldlYkFzc2VtYmx5LnZhbGlkYXRlKG5ldyBVaW50OEFycmF5KFswLDk3LDExNSwxMDksMSwwLDAsMCwxLDUsMSw5NiwwLDEsMTIzLDMsMiwxLDAsMTAsMTAsMSw4LDAsNjUsMCwyNTMsMTUsMjUzLDk4LDExXSkpLHg9ImVhZ2VyIixrPSJsYXp5IixqPXtzc3c6WyJzaW1kIl0sbWluaW1hcDI6WyJzaW1kIl19LHQ9e3Rvb2xzOltdLGNvbmZpZzp7fSxmaWxlczpbXSxiYXNlOnt9LGZzOnt9LGFzeW5jIGluaXQoKXtpZih0LnRvb2xzLmxlbmd0aD09PTApdGhyb3ciRXhwZWN0aW5nIGF0IGxlYXN0IDEgdG9vbC4iO2lmKG5ldyBTZXQodC50b29scy5tYXAocj0+YCR7ci50b29sfS8ke3IucHJvZ3JhbXx8ci50b29sfWApKS5zaXplIT09dC50b29scy5sZW5ndGgpdGhyb3ciRm91bmQgZHVwbGljYXRlIHRvb2xzOyBjYW4gb25seSBoYXZlIGVhY2ggdG9vbC9wcm9ncmFtIGNvbWJpbmF0aW9uIGF0IG1vc3Qgb25jZS4iO2lmKHQuYmFzZT10LnRvb2xzLmZpbmQocj0+ci5yZWluaXQhPT0hMCksIXQuYmFzZSl0aHJvdyJDb3VsZCBub3QgZmluZCBhIHRvb2wgd2l0aCBgcmVpbml0OiBmYWxzZWAgdG8gdXNlIGFzIHRoZSBiYXNlIG1vZHVsZS4gVG8gZml4IHRoaXMgaXNzdWUsIGluY2x1ZGUgdGhlIHRvb2wgYGJhc2UvMS4wLjBgIHdoZW4gaW5pdGlhbGl6aW5nIEFpb2xpLiI7cmV0dXJuIHQuYmFzZS5pc0Jhc2VNb2R1bGU9ITAsYXdhaXQgdGhpcy5fc2V0dXAodC5iYXNlKSxhd2FpdCB0aGlzLl9pbml0TW9kdWxlcygpLHQuX2xvZygiUmVhZHkiKSwhMH0sYXN5bmMgX2luaXRNb2R1bGVzKCl7YXdhaXQgUHJvbWlzZS5hbGwodC50b29scy5tYXAodGhpcy5fc2V0dXApKSxhd2FpdCB0aGlzLl9zZXR1cEZTKCl9LG1vdW50KGU9W10pe2NvbnN0IHI9YCR7dC5jb25maWcuZGlyU2hhcmVkfSR7dC5jb25maWcuZGlyRGF0YX1gLGk9YCR7dC5jb25maWcuZGlyU2hhcmVkfSR7dC5jb25maWcuZGlyTW91bnRlZH1gO2xldCBzPVtdLG89W10sYT1bXTshQXJyYXkuaXNBcnJheShlKSYmIShlIGluc3RhbmNlb2YgRmlsZUxpc3QpJiYoZT1bZV0pLHQuX2xvZyhgTW91bnRpbmcgJHtlLmxlbmd0aH0gZmlsZXNgKTtmb3IobGV0IG4gb2YgZSl7aWYobiBpbnN0YW5jZW9mIEZpbGV8fChuPT1udWxsP3ZvaWQgMDpuLmRhdGEpaW5zdGFuY2VvZiBCbG9iJiZuLm5hbWV8fHR5cGVvZihuPT1udWxsP3ZvaWQgMDpuLmRhdGEpPT0ic3RyaW5nIiYmbi5uYW1lKXR5cGVvZihuPT1udWxsP3ZvaWQgMDpuLmRhdGEpPT0ic3RyaW5nIiYmKG4uZGF0YT1uZXcgQmxvYihbbi5kYXRhXSx7dHlwZToidGV4dC9wbGFpbiJ9KSkscy5wdXNoKG4pO2Vsc2UgaWYobi5uYW1lJiZuLnVybClvLnB1c2gobik7ZWxzZSBpZih0eXBlb2Ygbj09InN0cmluZyImJm4uc3RhcnRzV2l0aCgiaHR0cCIpKW49e3VybDpuLG5hbWU6bi5zcGxpdCgiLy8iKS5wb3AoKS5yZXBsYWNlKC9cLy9nLCItIil9LG8ucHVzaChuKTtlbHNlIHRocm93J0Nhbm5vdCBtb3VudCBmaWxlKHMpIHNwZWNpZmllZC4gTXVzdCBiZSBhIEZpbGUsIEJsb2IsIGEgVVJMIHN0cmluZywgb3IgeyBuYW1lOiAiZmlsZS50eHQiLCBkYXRhOiAic3RyaW5nIiB9Lic7YS5wdXNoKG4ubmFtZSl9dHJ5e3QuZnMudW5tb3VudChpKX1jYXRjaHt9Zm9yKGxldCBuIG9mIG8pdC5mcy5jcmVhdGVMYXp5RmlsZShyLG4ubmFtZSxuLnVybCwhMCwhMCk7cmV0dXJuIHQuZmlsZXM9dC5maWxlcy5jb25jYXQocyksdC5iYXNlLm1vZHVsZS5GUy5tb3VudCh0LmJhc2UubW9kdWxlLldPUktFUkZTLHtmaWxlczp0LmZpbGVzLmZpbHRlcihuPT5uIGluc3RhbmNlb2YgRmlsZSksYmxvYnM6dC5maWxlcy5maWx0ZXIobj0+KG49PW51bGw/dm9pZCAwOm4uZGF0YSlpbnN0YW5jZW9mIEJsb2IpfSxpKSxzLm1hcChuPT57Y29uc3QgdT1gJHtpfS8ke24ubmFtZX1gLGw9YCR7cn0vJHtuLm5hbWV9YDt0cnl7dC5mcy51bmxpbmsobCl9Y2F0Y2h7fXQuX2xvZyhgQ3JlYXRpbmcgc3ltbGluazogJHtsfSAtLT4gJHt1fWApLHQuZnMuc3ltbGluayh1LGwpfSksYS5tYXAobj0+YCR7cn0vJHtufWApfSxhc3luYyBleGVjKGUscj1udWxsKXtpZih0Ll9sb2coYEV4ZWN1dGluZyAlYyR7ZX0lYyBhcmdzPSR7cn1gLCJjb2xvcjpkYXJrYmx1ZTsgZm9udC13ZWlnaHQ6Ym9sZCIsIiIpLCFlKXRocm93IkV4cGVjdGluZyBhIGNvbW1hbmQiO2xldCBpPWU7cj09bnVsbCYmKHI9ZS5zcGxpdCgiICIpLGk9ci5zaGlmdCgpKTtjb25zdCBzPXQudG9vbHMuZmluZChhPT57dmFyIHU7bGV0IG49aTtyZXR1cm4oKHU9YT09bnVsbD92b2lkIDA6YS5mZWF0dXJlcyk9PW51bGw/dm9pZCAwOnUuc2ltZCk9PT0hMCYmKG49YCR7bn0tc2ltZGApLGEucHJvZ3JhbT09bn0pO2lmKHM9PW51bGwpdGhyb3dgUHJvZ3JhbSAke2l9IG5vdCBmb3VuZC5gO3Muc3Rkb3V0PSIiLHMuc3RkZXJyPSIiLHMubG9hZGluZz09ayYmKHMubG9hZGluZz14LGF3YWl0IHRoaXMuX2luaXRNb2R1bGVzKCkpO3RyeXtzLm1vZHVsZS5jYWxsTWFpbihyKX1jYXRjaChhKXtjb25zb2xlLmVycm9yKGEpfXRyeXtzLm1vZHVsZS5GUy5jbG9zZShzLm1vZHVsZS5GUy5zdHJlYW1zWzFdKSxzLm1vZHVsZS5GUy5jbG9zZShzLm1vZHVsZS5GUy5zdHJlYW1zWzJdKX1jYXRjaHt9cy5tb2R1bGUuRlMuc3RyZWFtc1sxXT1zLm1vZHVsZS5GUy5vcGVuKCIvZGV2L3N0ZG91dCIsInciKSxzLm1vZHVsZS5GUy5zdHJlYW1zWzJdPXMubW9kdWxlLkZTLm9wZW4oIi9kZXYvc3RkZXJyIiwidyIpO2xldCBvPXtzdGRvdXQ6cy5zdGRvdXQsc3RkZXJyOnMuc3RkZXJyfTtpZih0LmNvbmZpZy5wcmludEludGVybGVhdmVkJiYobz1zLnN0ZG91dCkscy5yZWluaXQ9PT0hMCl7Y29uc3QgYT10LmJhc2UubW9kdWxlLkZTLmN3ZCgpO09iamVjdC5hc3NpZ24ocyxzLmNvbmZpZykscy5yZWFkeT0hMSxhd2FpdCB0aGlzLmluaXQoKSxzLmlzQmFzZU1vZHVsZSYmdGhpcy5tb3VudCgpLHRoaXMuY2QoYSl9cmV0dXJuIG99LGNhdChlKXtyZXR1cm4gdC5fZmlsZW9wKCJjYXQiLGUpfSxscyhlKXtyZXR1cm4gdC5fZmlsZW9wKCJscyIsZSl9LGRvd25sb2FkKGUpe3JldHVybiB0Ll9maWxlb3AoImRvd25sb2FkIixlKX0scHdkKCl7cmV0dXJuIHQuZnMuY3dkKCl9LGNkKGUpe2ZvcihsZXQgciBvZiB0LnRvb2xzKSFyLm1vZHVsZXx8ci5tb2R1bGUuRlMuY2hkaXIoZSl9LG1rZGlyKGUpe3JldHVybiB0LmZzLm1rZGlyKGUpLCEwfSxyZWFkKHtwYXRoOmUsbGVuZ3RoOnIsZmxhZzppPSJyIixvZmZzZXQ6cz0wLHBvc2l0aW9uOm89MH0pe2NvbnN0IGE9dC5mcy5vcGVuKGUsaSksbj1uZXcgVWludDhBcnJheShyKTtyZXR1cm4gdC5mcy5yZWFkKGEsbixzLHIsbyksdC5mcy5jbG9zZShhKSxufSx3cml0ZSh7cGF0aDplLGJ1ZmZlcjpyLGZsYWc6aT0idysiLG9mZnNldDpzPTAscG9zaXRpb246bz0wfSl7Y29uc3QgYT10LmZzLm9wZW4oZSxpKTt0LmZzLndyaXRlKGEscixzLHIubGVuZ3RoLG8pLHQuZnMuY2xvc2UoYSl9LF9zdGRpblR4dDoiIixfc3RkaW5QdHI6MCxnZXQgc3RkaW4oKXtyZXR1cm4gdC5fc3RkaW5UeHR9LHNldCBzdGRpbihlPSIiKXt0Ll9sb2coYFNldHRpbmcgc3RkaW4gdG8gJWMke2V9JWNgLCJjb2xvcjpkYXJrYmx1ZSIsIiIpLHQuX3N0ZGluVHh0PWUsdC5fc3RkaW5QdHI9MH0sYXN5bmMgX3NldHVwKGUpe2lmKGUucmVhZHkpcmV0dXJuO2lmKHQuX2xvZyhgU2V0dGluZyB1cCAke2UudG9vbH0gKGJhc2UgPSAke2UuaXNCYXNlTW9kdWxlPT09ITB9KS4uLmApLGUuY29uZmlnPU9iamVjdC5hc3NpZ24oe30sZSksZS51cmxQcmVmaXh8fChlLnVybFByZWZpeD1gJHt0LmNvbmZpZy51cmxDRE59LyR7ZS50b29sfS8ke2UudmVyc2lvbn1gKSxlLnByb2dyYW18fChlLnByb2dyYW09ZS50b29sKSxlLmZlYXR1cmVzfHwoZS5mZWF0dXJlcz17fSwoaltlLnByb2dyYW1dfHxbXSkuaW5jbHVkZXMoInNpbWQiKSYmKGF3YWl0IFcoKT8oZS5wcm9ncmFtKz0iLXNpbWQiLGUuZmVhdHVyZXMuc2ltZD0hMCk6dC5fbG9nKGBXZWJBc3NlbWJseSBTSU1EIGlzIG5vdCBzdXBwb3J0ZWQgaW4gdGhpcyBicm93c2VyOyB3aWxsIGxvYWQgbm9uLVNJTUQgdmVyc2lvbiBvZiAke2UucHJvZ3JhbX0uYCkpKSxlLmlzQmFzZU1vZHVsZSYmKGUubG9hZGluZz14KSxlLmxvYWRpbmc9PT1rKXt0Ll9sb2coYFdpbGwgbGF6eS1sb2FkICR7ZS50b29sfTsgc2tpcHBpbmcgaW5pdGlhbGl6YXRpb24uYCk7cmV0dXJufXNlbGYuaW1wb3J0U2NyaXB0cyhgJHtlLnVybFByZWZpeH0vJHtlLnByb2dyYW19LmpzYCksZS5tb2R1bGU9YXdhaXQgTW9kdWxlKHt0aGlzUHJvZ3JhbTplLnByb2dyYW0sbG9jYXRlRmlsZTooaSxzKT0+YCR7ZS51cmxQcmVmaXh9LyR7aX1gLHN0ZGluOigpPT50Ll9zdGRpblB0cjx0LnN0ZGluLmxlbmd0aD90LnN0ZGluLmNoYXJDb2RlQXQodC5fc3RkaW5QdHIrKyk6KHQuc3RkaW49IiIsbnVsbCkscHJpbnQ6aT0+ZS5zdGRvdXQrPWAke2l9CmAscHJpbnRFcnI6dC5jb25maWcucHJpbnRJbnRlcmxlYXZlZD9pPT5lLnN0ZG91dCs9YCR7aX0KYDppPT5lLnN0ZGVycis9YCR7aX0KYH0pO2NvbnN0IHI9ZS5tb2R1bGUuRlM7ZS5pc0Jhc2VNb2R1bGU/KHQuX2xvZyhgU2V0dGluZyB1cCAke2UudG9vbH0gd2l0aCBiYXNlIG1vZHVsZSBmaWxlc3lzdGVtLi4uYCksci5ta2Rpcih0LmNvbmZpZy5kaXJTaGFyZWQsNTExKSxyLm1rZGlyKGAke3QuY29uZmlnLmRpclNoYXJlZH0vJHt0LmNvbmZpZy5kaXJEYXRhfWAsNTExKSxyLm1rZGlyKGAke3QuY29uZmlnLmRpclNoYXJlZH0vJHt0LmNvbmZpZy5kaXJNb3VudGVkfWAsNTExKSxyLmNoZGlyKGAke3QuY29uZmlnLmRpclNoYXJlZH0vJHt0LmNvbmZpZy5kaXJEYXRhfWApLHQuZnM9cik6KHQuX2xvZyhgU2V0dGluZyB1cCAke2UudG9vbH0gd2l0aCBmaWxlc3lzdGVtLi4uYCksci5ta2Rpcih0LmNvbmZpZy5kaXJTaGFyZWQpLHIubW91bnQoZS5tb2R1bGUuUFJPWFlGUyx7cm9vdDp0LmNvbmZpZy5kaXJTaGFyZWQsZnM6dC5mc30sdC5jb25maWcuZGlyU2hhcmVkKSxyLmNoZGlyKHQuZnMuY3dkKCkpKSxlLnN0ZG91dD0iIixlLnN0ZGVycj0iIixlLnJlYWR5PSEwfSxhc3luYyBfc2V0dXBGUygpe2NvbnN0IGU9dC5mcztmb3IobGV0IHIgb2YgdC50b29scyl7aWYoIXIucmVhZHkpY29udGludWU7Y29uc3QgaT1yLm1vZHVsZS5GUyxzPWAvJHtyLnRvb2x9YCxvPWAke3QuY29uZmlnLmRpclNoYXJlZH0ke3N9YDshaS5hbmFseXplUGF0aChzKS5leGlzdHN8fGUuYW5hbHl6ZVBhdGgobykuZXhpc3RzfHwodC5fbG9nKGBNb3VudGluZyAke3N9IG9udG8gJHt0LmJhc2UudG9vbH0gZmlsZXN5c3RlbSBhdCAke299YCksZS5ta2RpcihvKSxlLm1vdW50KHQuYmFzZS5tb2R1bGUuUFJPWFlGUyx7cm9vdDpzLGZzOml9LG8pKX19LF9maWxlb3AoZSxyKXt0Ll9sb2coYFJ1bm5pbmcgJHtlfSAke3J9YCk7Y29uc3QgaT10LmZzLmFuYWx5emVQYXRoKHIpO2lmKCFpLmV4aXN0cylyZXR1cm4gdC5fbG9nKGBGaWxlICR7cn0gbm90IGZvdW5kLmApLCExO3N3aXRjaChlKXtjYXNlImNhdCI6cmV0dXJuIHQuZnMucmVhZEZpbGUocix7ZW5jb2Rpbmc6InV0ZjgifSk7Y2FzZSJscyI6cmV0dXJuIHQuZnMuaXNGaWxlKGkub2JqZWN0Lm1vZGUpP3QuZnMuc3RhdChyKTp0LmZzLnJlYWRkaXIocik7Y2FzZSJkb3dubG9hZCI6Y29uc3Qgcz1uZXcgQmxvYihbdGhpcy5jYXQocildKTtyZXR1cm4gVVJMLmNyZWF0ZU9iamVjdFVSTChzKX1yZXR1cm4hMX0sX2xvZyhlKXtpZighdC5jb25maWcuZGVidWcpcmV0dXJuO2xldCByPVsuLi5hcmd1bWVudHNdO3Iuc2hpZnQoKSxjb25zb2xlLmxvZyhgJWNbV2ViV29ya2VyXSVjICR7ZX1gLCJmb250LXdlaWdodDpib2xkIiwiIiwuLi5yKX19O3codCl9KSgpOwo=",T=typeof window<"u"&&window.Blob&&new Blob([atob(C)],{type:"text/javascript;charset=utf-8"});function M(){const t=T&&(window.URL||window.webkitURL).createObjectURL(T);try{return t?new Worker(t):new Worker("data:application/javascript;base64,"+C)}finally{t&&(window.URL||window.webkitURL).revokeObjectURL(t)}}const E={urlCDN:"https://biowasm.com/cdn/v3",urlCDNStg:"https://stg.biowasm.com/cdn/v3",dirShared:"/shared",dirMounted:"/mnt",dirData:"/data",printInterleaved:!0,callback:null,debug:!1,env:"prd"};class A{constructor(t,e={}){if(null==t)throw"Expecting array of tools as input to Aioli constructor.";return Array.isArray(t)||(t=[t]),e=Object.assign({},E,e),t=t.map(this._parseTool),"stg"===e.env&&(e.urlCDN=e.urlCDNStg),this.tools=t,this.config=e,null!=this.config.callback&&(this.callback=this.config.callback),delete this.config.callback,this.init()}async init(){const t=new M;this.callback&&(t.onmessage=t=>{"biowasm"===t.data.type&&this.callback(t.data.value)});const e=f(t);return e.tools=this.tools,e.config=this.config,await e.init(),e}_parseTool(t){if("string"!=typeof t)return t;const e=t.split("/");if(2!=e.length&&3!=e.length)throw"Expecting '<tool>/<version>' or '<tool>/<program>/<version>'";return{tool:e[0],program:3==e.length?e[1]:e[0],version:e[e.length-1]}}}var N=n(850);class P{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]}}P.scales={WimleyWhite:{"-":0,A:.17,C:-.24,D:-.07,E:-.01,F:-1.13,G:.01,H:.17,I:-.31,K:.99,L:-.56,M:-.23,N:.42,P:.45,Q:.58,R:.81,S:.13,T:.14,V:.07,W:-1.85,Y:-.94},categorial:{"-":0,A:1,C:2,D:3,E:4,F:5,G:6,H:7,I:8,K:9,L:10,M:11,N:12,P:13,Q:14,R:15,S:16,T:17,V:18,W:19,Y:20}};class x{constructor(t="categorial"){this.aa2num=P.getScale(t),this.num2aa={},Object.entries(this.aa2num).forEach((([t,e])=>this.num2aa[e]=t))}static _truncateSequence(t){let e=0,n=t.length;const i=["NH2","COOH"];if(t.startsWith(i[0])){const n=i[0].length;(0,N.hu)("-"==t[n],`Wrong sequence format: ${i[0]} without following '-' in '${t}'.`),e=n}if(t.endsWith(i[1])){const e=i[1].length+1;(0,N.hu)("-"==t[n-e],`Wrong sequence format: ${i[1]} without '-' precending in '${t}'.`),n-=e}return t.substring(e,n)}static _dropDefises(t){return t.replace(/(-)([^-]+)/g,"$2")}static clean(t){return x._dropDefises(x._truncateSequence(t))}encode(t){const e=t.length,n=new Array(e).fill(0);for(let i=0;i<e;++i){const e=t[i];(0,N.hu)(e in this.aa2num,`Unknown char '${e}' found in sequence '${t}'`),n[i]=this.encodeLettter(e)}return n}encodeLettter(t){return this.aa2num[t]}decode(t){let e="";for(let n=0;n<t.length;++n){const i=t[n];(0,N.hu)(i in this.num2aa,`Unknown code '${i}' found in vector '${t}'`),e+=this.num2aa[i]}return e}}var _=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};const R="input.fa",L="result.fasta";function I(t){return t.reduce(((t,e,n)=>t+`>sample${n+1}\n${e}\n`),"")}function G(t,e=!1,n="",s=null){var r,a;return _(this,void 0,void 0,(function*(){let l=t.toList();e&&(l=l.map((t=>x.clean(t).replace(/\-/g,""))));const c=t.length;null!=s||(s=i.Column.string("Clusters",c).init("0")),s.type!=i.COLUMN_TYPE.STRING&&(s=s.convertTo(i.TYPE.STRING)),s.compact();const h=s.categories,u=s.getRawData(),d=new Array(h.length),f=new Array(h.length);for(let t=0;t<c;++t){const e=u[t];(null!==(r=d[e])&&void 0!==r?r:d[e]=[]).push(l[t]),(null!==(a=f[e])&&void 0!==a?a:f[e]=[]).push(t)}const m=yield new A(["base/1.0.0",{tool:"kalign",version:"3.3.1",reinit:!0}]),p=i.Column.string(n,c);for(let t=0;t<h.length;++t){const e=I(d[t]);yield m.fs.writeFile(R,e);const n=yield m.exec(`kalign ${R} -f fasta -o ${L}`);console.warn(n);const i=yield m.cat(L);if(!i)throw new Error("kalign output no result");const s=new o.i(i).sequencesArray,r=f[t];for(let t=0;t<s.length;++t)p.set(r[t],s[t])}const g=t.getTag(i.TAGS.UNITS),v=t.getTag("alphabet");return p.setTag(i.TAGS.UNITS,g),p.setTag("aligned","SEQ.MSA"),p.setTag("alphabet",v),p.semType=i.SEMTYPE.MACROMOLECULE,p}))}},8341:(t,e,n)=>{"use strict";n.d(e,{J:()=>a,f:()=>c});var i=n(4469),o=n(976),s=n(3553),r=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};const a=["mafft --auto","mafft","linsi","ginsi","einsi","fftns","fftnsi","nwns","nwnsi"],l=["AlignedSeq","AlignedSubpeptide","HELM","ID","PolymerID"];function c(t,e,n="ginsi",a=1.53,c=0,u=null){var d;return r(this,void 0,void 0,(function*(){const r=t.length;null!=u||(u=o.Column.int("Clusters",r).init(0)),u.type!=o.COLUMN_TYPE.STRING&&(u=u.convertTo(o.TYPE.STRING));const f=u.categories,m=new Array(f.length);for(let e=0;e<r;++e){const n=u.get(e);if(""===n)continue;const i=f.indexOf(n),o=t.get(e);o&&(null!==(d=m[i])&&void 0!==d?d:m[i]=[]).push({ID:e.toString(),HELM:o})}const p=yield(void 0!==i.dapi.docker?i.dapi.docker.dockerContainers:i.dapi.dockerfiles).filter("bio").first(),g=new Array(r);for(const t of m){const e=(yield h(p.id,t,n,a,c)).Alignment;for(const t of e)g[parseInt(t.ID)]=Object.entries(t).filter((t=>!l.includes(t[0]))).map((t=>"-"!==t[1]?t[1]:"")).join(s.rs.SEPARATOR)}const v=o.Column.fromStrings(e,g);return v.setTag(o.TAGS.UNITS,"separator"),v.setTag("separator",s.rs.SEPARATOR),v.setTag("aligned","SEQ.MSA"),v.setTag("alphabet","UN"),v.setTag(".alphabetIsMultichar","true"),v.semType=o.SEMTYPE.MACROMOLECULE,v}))}function h(t,e,n,o,s){return r(this,void 0,void 0,(function*(){const r={method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(e)},a=`/align?method=${n}&gap_open=${o}&gap_extend=${s}`,l=yield(void 0!==i.dapi.docker?i.dapi.docker.dockerContainers:i.dapi.dockerfiles).request(t,a,r);return JSON.parse(null!=l?l:"{}")}))}},9943:(t,e,n)=>{"use strict";n.d(e,{i$:()=>s,sK:()=>r}),n(976),n(3870),n(4469),n(6414);var i=n(8447);n(499);const o=60;function s(t,e,n=o,s="\n"){const a=i.kB,l=[];for(let i=0;i<e.length;i++){const o=t.map((t=>t.get(i).toString())).join("|"),c=r(e.get(i),a,n);l.push(`>${o}${s}`);for(const t of c)l.push(`${t}${s}`)}return"".concat(...l)}function r(t,e,n=o){const i=e(t);let s=0;const r=i.length,a=[];for(;s<r;){const t=i.slice(s,s+n),e=t.map((t=>t.length>1?`[${t}]`:t)).join("");a.push(e),s+=t.length}return a}},4293:(t,e,n)=>{"use strict";n.d(e,{Y:()=>r,m:()=>s});var i=n(4469),o=n(976);function s(){const t=i.shell.t.columns.bySemType(o.SEMTYPE.MACROMOLECULE);if(null!==t)return t;i.shell.error("Current table does not contain macromolecules")}function r(t,e){t.innerHTML="",t.append(e)}},2433:(t,e,n)=>{"use strict";n.d(e,{CK:()=>g,eZ:()=>b,yW:()=>p});var i,o,s=n(4469),r=n(3870),a=n(976),l=n(6414),c=n.n(l),h=n(701),u=n(499),d=n(8447),f=n(9298),m=n(7604);HTMLCanvasElement.prototype.getCursorPosition=function(t,e){const n=this.getBoundingClientRect();return new a.Point((t.clientX-n.left)*e,(t.clientY-n.top)*e)},a.Rect.prototype.contains=function(t,e){return this.left<=t&&t<=this.right&&this.top<=e&&e<=this.bottom};class p{constructor(t=0,e=new a.Rect(0,0,0,0)){this.count=t,this.bounds=e}}class g{constructor(t,e,n={},i=0,o=0){this.pos=t,this.name=e,this.freq=n,this.rowCount=i,this.sumForHeightCalc=o}}!function(t){t.STYLE="Style",t.BEHAVIOR="Behavior",t.LAYOUT="Layout",t.DATA="Data"}(i||(i={})),function(t){t.sequenceColumnName="sequenceColumnName",t.startPositionName="startPositionName",t.endPositionName="endPositionName",t.skipEmptySequences="skipEmptySequences",t.skipEmptyPositions="skipEmptyPositions",t.shrinkEmptyTail="shrinkEmptyTail",t.backgroundColor="backgroundColor",t.positionHeight="positionHeight",t.positionWidth="positionWidth",t.verticalAlignment="verticalAlignment",t.horizontalAlignment="horizontalAlignment",t.fixWidth="fixWidth",t.fitArea="fitArea",t.minHeight="minHeight",t.maxHeight="maxHeight",t.positionMarginState="positionMarginState",t.positionMargin="positionMargin",t.filterSource="filterSource"}(o||(o={}));const v=f.vS;class y extends a.JsViewer{get filter(){let t;switch(this.filterSource){case f.Ct.Filtered:t=this.dataFrame.filter;break;case f.Ct.Selected:t=this.dataFrame.selection}return t}get Length(){return this.skipEmptyPositions?this.positions.length:this.startPosition<=this.endPosition?this.endPosition-this.startPosition+1:0}get positionWidthWithMargin(){return this._positionWidth+this.positionMarginValue}get positionMarginValue(){var t;return"auto"===this.positionMarginState&&!0===(null===(t=this.unitsHandler)||void 0===t?void 0:t.getAlphabetIsMultichar())||"enable"===this.positionMarginState?this.positionMargin:0}get countOfRenderPositions(){if(null==this.host)return 0;const t=window.devicePixelRatio;return t>1?this.canvasWidthWithRatio/this.positionWidthWithMargin:this.canvas.width/(this.positionWidthWithMargin*t)}get canvasWidthWithRatio(){return this.canvas.width*window.devicePixelRatio}get firstVisibleIndex(){return this.visibleSlider?Math.floor(this.slider.min):0}constructor(){super(),this.viewerId=-1,this.initialized=!1,this.cp=null,this.axisHeight=12,this.seqCol=null,this.splitter=null,this.positions=[],this.rowsMasked=0,this.rowsNull=0,this.visibleSlider=!1,this.allowResize=!0,this.turnOfResizeForOneSetValue=!1,this.backgroundColor=4294967295,this.positionMargin=0,this.positionNames=[],this.startPosition=-1,this.endPosition=-1,this.viewSubs=[],this.viewerId=y.viewerCount,y.viewerCount+=1,this.textBaseline="top",this.unitsHandler=null,this.sequenceColumnName=this.string(o.sequenceColumnName,v.sequenceColumnName,{category:i.DATA}),this.startPositionName=this.string(o.startPositionName,v.startPositionName,{category:i.DATA}),this.endPositionName=this.string(o.endPositionName,v.endPositionName,{category:i.DATA}),this.skipEmptySequences=this.bool(o.skipEmptySequences,v.skipEmptySequences,{category:i.DATA}),this.skipEmptyPositions=this.bool(o.skipEmptyPositions,v.skipEmptyPositions,{category:i.DATA}),this.shrinkEmptyTail=this.bool(o.shrinkEmptyTail,v.shrinkEmptyTail,{category:i.DATA}),this.backgroundColor=this.int(o.backgroundColor,v.backgroundColor,{category:i.STYLE}),this.positionHeight=this.string(o.positionHeight,v.positionHeight,{category:i.STYLE,choices:Object.values(f.ES)}),this._positionWidth=this.positionWidth=this.float(o.positionWidth,v.positionWidth,{category:i.STYLE}),this.verticalAlignment=this.string(o.verticalAlignment,v.verticalAlignment,{category:i.LAYOUT,choices:Object.values(f.vw)}),this.horizontalAlignment=this.string(o.horizontalAlignment,v.horizontalAlignment,{category:i.LAYOUT,choices:Object.values(f.iD)}),this.fixWidth=this.bool(o.fixWidth,v.fixWidth,{category:i.LAYOUT}),this.fitArea=this.bool(o.fitArea,v.fitArea,{category:i.LAYOUT}),this.minHeight=this.float(o.minHeight,v.minHeight,{category:i.LAYOUT}),this.maxHeight=this.float(o.maxHeight,v.maxHeight,{category:i.LAYOUT}),this.positionMarginState=this.string(o.positionMarginState,v.positionMarginState,{category:i.LAYOUT,choices:Object.values(f.dE)});let t=0;"auto"===this.positionMarginState&&(t=4),this.positionMargin=this.int(o.positionMargin,t,{category:i.LAYOUT,min:0,max:16}),this.filterSource=this.string(o.filterSource,v.filterSource,{category:i.BEHAVIOR,choices:Object.values(f.Ct)}),this.slider=r.rangeSlider(0,100,0,20,!1,{style:"barbell"}),this.canvas=r.canvas(),this.canvas.style.width="100%"}init(){this.initialized?console.error("Bio: WebLogoViewer.init() second initialization!"):(this.initialized=!0,this.helpUrl="/help/visualize/viewers/web-logo.md",this.msgHost=r.div("No message"),this.msgHost.style.display="none",this.canvas=r.canvas(),this.canvas.style.width="100%",this.slider.root.style.position="absolute",this.slider.root.style.zIndex="999",this.slider.root.style.display="none",this.slider.root.style.height="0.7em",this.visibleSlider=!1,this.subs.push(this.slider.onValuesChanged.subscribe(this.sliderOnValuesChanged.bind(this))),this.host=r.div([this.msgHost,this.canvas]),this.host.style.justifyContent="center",this.host.style.alignItems="center",this.host.style.position="relative",this.host.style.setProperty("overflow","hidden","important"),this.subs.push(h.fromEvent(this.canvas,"mousemove").subscribe(this.canvasOnMouseMove.bind(this))),this.subs.push(h.fromEvent(this.canvas,"mousedown").subscribe(this.canvasOnMouseDown.bind(this))),this.subs.push(h.fromEvent(this.canvas,"wheel").subscribe(this.canvasOnWheel.bind(this))),this.subs.push(r.onSizeChanged(this.root).subscribe(this.rootOnSizeChanged.bind(this))),this.root.append(this.host),this.root.append(this.slider.root),this._calculate(window.devicePixelRatio),this.updateSlider(),this.render(!0))}rootOnSizeChanged(){this._calculate(window.devicePixelRatio),this.updateSlider(),this.render(!0)}updateSeqCol(){if(this.dataFrame)if(this.seqCol=this.sequenceColumnName?this.dataFrame.col(this.sequenceColumnName):null,null==this.seqCol&&(this.seqCol=(0,d.up)(this.dataFrame),this.sequenceColumnName=this.seqCol?this.seqCol.name:null),this.seqCol){const t=this.seqCol.getTag(a.TAGS.UNITS),e=this.seqCol.getTag("separator");this.splitter=(0,d.vU)(t,e),this.unitsHandler=new u.C(this.seqCol),this.updatePositions(),this.cp=(0,d.dQ)(this.seqCol)}else this.splitter=null,this.positionNames=[],this.startPosition=-1,this.endPosition=-1,this.cp=null;this.render()}updatePositions(){if(!this.seqCol)return;let t;if(this.shrinkEmptyTail){const e=this.dataFrame.filter.getSelectedIndexes();t=Array.from(new Set(Array.from(Array(e.length).keys()).map((t=>this.seqCol.get(e[t])))))}else t=this.seqCol.categories;const e=t.length>0?Math.max(...t.map((t=>null!==t?this.splitter(t).length:0))):0,n=this.seqCol.getTag(f.DX.positionNames);this.positionNames=n?n.split(f.CI).map((t=>t.trim())):[...Array(e).keys()].map((t=>`${t+1}`)),this.startPosition=this.startPositionName&&this.positionNames&&this.positionNames.includes(this.startPositionName)?this.positionNames.indexOf(this.startPositionName):0,this.endPosition=this.endPositionName&&this.positionNames&&this.positionNames.includes(this.endPositionName)?this.positionNames.indexOf(this.endPositionName):e-1}get widthArea(){return this.Length*this.positionWidth/window.devicePixelRatio}get heightArea(){return Math.min(this.maxHeight,Math.max(this.minHeight,this.root.clientHeight))}get xScale(){return this.widthArea>0?(this.root.clientWidth-this.Length*this.positionMarginValue)/this.widthArea:0}get yScale(){return this.root.clientHeight/this.heightArea}checkIsHideSlider(){let t=!0;const e=Math.min(this.xScale,this.yScale);return(e==this.xScale||e<=1)&&this.fitArea&&(t=!1),this.fixWidth||Math.ceil(this.canvas.width/this.positionWidthWithMargin)>=this.Length||t}setSliderVisibility(t){t?(this.slider.root.style.display="inherit",this.visibleSlider=!0):(this.slider.root.style.display="none",this.visibleSlider=!1)}updateSlider(){if(this.checkIsHideSlider()?this.setSliderVisibility(!1):this.setSliderVisibility(!0),null!=this.slider&&null!=this.canvas){const t=Math.max(0,Math.floor(this.slider.min+this.canvas.width/this.positionWidthWithMargin)-this.Length);let e=Math.floor(this.slider.min-t),n=Math.floor(this.slider.min-t)+Math.floor(this.canvas.width/this.positionWidthWithMargin);this.checkIsHideSlider()&&(e=0,n=Math.max(e,this.Length-1)),this.turnOfResizeForOneSetValue=!0,this.slider.setValues(0,this.Length,e,n)}}onPropertyChanged(t){switch(super.onPropertyChanged(t),t.name){case o.sequenceColumnName:case o.startPositionName:case o.endPositionName:case o.filterSource:this.updateSeqCol();break;case o.positionWidth:this._positionWidth=this.positionWidth,this.updateSlider();break;case o.fixWidth:case o.fitArea:case o.positionMargin:this.updateSlider();break;case o.shrinkEmptyTail:case o.skipEmptyPositions:this.updatePositions()}this.render(!0)}onTableAttached(){super.onTableAttached();const t=this.dataFrame?"data":"null";console.debug(`Bio: WebLogoViewer<${this.viewerId}>.onTableAttached( dataFrame = ${t} ) start`),this.updateSeqCol(),void 0!==this.dataFrame&&(this.viewSubs.push(this.dataFrame.filter.onChanged.subscribe(this.dataFrameFilterOnChanged.bind(this))),this.viewSubs.push(this.dataFrame.selection.onChanged.subscribe(this.dataFrameSelectionOnChanged.bind(this)))),this.init(),console.debug(`Bio: WebLogoViewer<${this.viewerId}>.onTableAttached() end`)}detach(){const t=Object.create(null,{detach:{get:()=>super.detach}});return e=this,n=void 0,o=function*(){const e=this.dataFrame?"data":"null";console.debug(`Bio: WebLogoViewer<${this.viewerId}>.onTableAttached( dataFrame = ${e} ) start`),t.detach.call(this),this.viewSubs.forEach((t=>t.unsubscribe())),this.host.remove(),this.msgHost=void 0,this.host=void 0,this.initialized=!1,console.debug(`Bio: WebLogoViewer<${this.viewerId}>.onTableAttached() end`)},new((i=void 0)||(i=Promise))((function(t,s){function r(t){try{l(o.next(t))}catch(t){s(t)}}function a(t){try{l(o.throw(t))}catch(t){s(t)}}function l(e){var n;e.done?t(e.value):(n=e.value,n instanceof i?n:new i((function(t){t(n)}))).then(r,a)}l((o=o.apply(e,n||[])).next())}));var e,n,i,o}getMonomer(t){const e=t.x+this.firstVisibleIndex*this.positionWidthWithMargin,n=Math.floor(t.x/this.positionWidthWithMargin+this.firstVisibleIndex),i=this.positions[n];if(null==i)return[n,null,null];const o=Object.keys(i.freq).find((n=>i.freq[n].bounds.contains(e,t.y)));return void 0===o?[n,null,null]:[n,o,i.freq[o]]}_nullSequence(t="X"){return this.skipEmptySequences?"":new Array(this.Length).fill(t).join("")}removeWhere(t,e){const n=t.length;let i=0;for(let o=0;o<n;o++)e(t[o])||(t[i]=t[o],i++);return t.length=i,t}_removeEmptyPositions(){this.skipEmptyPositions&&this.removeWhere(this.positions,(t=>{var e;return(null===(e=null==t?void 0:t.freq["-"])||void 0===e?void 0:e.count)===t.rowCount}))}_calculate(t){if(!this.host||!this.seqCol||!this.dataFrame)return;this.unitsHandler=new u.C(this.seqCol),this.calcSize();const e=this.startPosition<=this.endPosition?this.endPosition-this.startPosition+1:0;this.positions=new Array(e);for(let t=0;t<this.Length;t++){const e=this.positionNames[this.startPosition+t];this.positions[t]=new g(this.startPosition+t,e)}const n=this.filter.getSelectedIndexes();this.rowsMasked=n.length,this.rowsNull=0;for(const t of n){let e=this.seqCol.get(t);e||(e=this._nullSequence(),++this.rowsNull);const n=this.splitter(e);for(let t=0;t<this.Length;t++){const e=this.positions[t].freq,i=n[this.startPosition+t]||"-";i in e||(e[i]=new p),e[i].count++}}for(let t=0;t<this.Length;t++){this.positions[t].rowCount=0;for(const e in this.positions[t].freq)this.positions[t].rowCount+=this.positions[t].freq[e].count;if(this.positionHeight==f.ES.Entropy){this.positions[t].sumForHeightCalc=0;for(const e in this.positions[t].freq){const n=this.positions[t].freq[e].count/this.positions[t].rowCount;this.positions[t].sumForHeightCalc+=-n*Math.log2(n)}}}this._removeEmptyPositions();const i=this.canvas.height-this.axisHeight*t;for(let e=0;e<this.Length;e++){const n=this.positions[e].freq,o=this.positions[e].rowCount,r=this.getAlphabetSize();this.positionHeight==f.ES.Entropy&&null==r&&s.shell.error("WebLogo: alphabet is undefined.");const l=Math.log2(r),c=this.positionHeight==f.ES.Entropy?i*(l-this.positions[e].sumForHeightCalc)/l:i;let h=this.axisHeight*t+(i-c-1);const u=Object.entries(n).sort(((t,e)=>"-"!==t[0]&&"-"!==e[0]?e[1].count-t[1].count:"-"===t[0]&&"-"===e[0]?0:"-"===t[0]?-1:1));for(const t of u){const n=t[1],i=c*n.count/o;n.bounds=new a.Rect(e*this.positionWidthWithMargin,h,this._positionWidth,i),h+=i}}}render(t=!0){var e;if(this.msgHost&&(this.seqCol&&!this.cp?(this.msgHost.innerText=`Unknown palette (column semType: '${this.seqCol.semType}').`,this.msgHost.style.display=""):this.msgHost.style.display="none"),!this.seqCol||!this.dataFrame||!this.cp||-1===this.startPosition||-1===this.endPosition||null==this.host||null==this.slider)return;const n=this.canvas.getContext("2d");if(!n)return;this.slider.root.style.width=`${this.host.clientWidth}px`;const i=window.devicePixelRatio;t&&this._calculate(i),n.resetTransform(),n.fillStyle=a.Color.toHtml(this.backgroundColor),n.fillRect(0,0,this.canvas.width,this.canvas.height),n.textBaseline=this.textBaseline;const o=this.countOfRenderPositions+1,s=this.visibleSlider?Math.floor(this.slider.min):0,r=Math.min(this.Length,s+o),l=10*i;n.resetTransform(),n.fillStyle="black",n.textAlign="center",n.font=`${l.toFixed(1)}px Roboto, Roboto Local, sans-serif`;const c=Math.max(...this.positions.map((t=>n.measureText(t.name).width))),h=c<this._positionWidth-2?1:(this._positionWidth-2)/c;for(let t=this.firstVisibleIndex;t<r;t++){const e=this.positions[t];n.resetTransform(),n.setTransform(h,0,0,1,t*this.positionWidthWithMargin+this._positionWidth/2-this.positionWidthWithMargin*s,0),n.fillText(e.name,0,0)}for(let t=this.firstVisibleIndex;t<r;t++)for(const[i,o]of Object.entries(this.positions[t].freq))if("-"!==i){const t=(0,d.GU)(i,5),s=o.bounds,r=s.left-this.positionWidthWithMargin*this.firstVisibleIndex;n.resetTransform(),n.strokeStyle="lightgray",n.lineWidth=1,n.rect(r,s.top,s.width,s.height),n.fillStyle=null!==(e=this.cp.get(i))&&void 0!==e?e:this.cp.get("other"),n.textAlign="left",n.font="16px Roboto, Roboto Local, sans-serif";const a=n.measureText(t);n.setTransform(s.width/a.width,0,0,s.height/12.2,r,s.top),n.fillText(t,0,-.25)}}calcSize(){if(!this.host)return;const t=window.devicePixelRatio;let e=this.widthArea,n=this.heightArea;if(this.fitArea&&!this.visibleSlider){const t=Math.max(1,Math.min(this.xScale,this.yScale));e*=t,n*=t,this._positionWidth=this.positionWidth*t}e=this.Length*this.positionWidthWithMargin/t,this.canvas.width=this.root.clientWidth*t,this.canvas.style.width=`${this.root.clientWidth}px`,this.host.style.setProperty("height",`${n}px`);const i=this.host.clientHeight;if(this.canvas.height=i*t,this.fixWidth)this.root.style.width=this.host.style.width=`${e}px`,this.root.style.height=`${n}px`,this.root.style.overflow="hidden",this.host.style.setProperty("overflow-y","hidden","important");else{this.root.style.width=this.host.style.width="100%",this.host.style.overflowX="auto!important",this.host.style.setProperty("text-align",this.horizontalAlignment);const t=this.visibleSlider?10:0;let o=0;switch(this.verticalAlignment){case"top":o=0;break;case"middle":o=Math.max(0,(this.root.clientHeight-n)/2);break;case"bottom":o=Math.max(0,this.root.clientHeight-n-t)}let s=0;switch(this.horizontalAlignment){case"left":s=0;break;case"center":s=Math.max(0,(this.root.clientWidth-e)/2);break;case"right":s=Math.max(0,this.root.clientWidth-e)}this.host.style.setProperty("margin-top",`${o}px`,"important"),this.host.style.setProperty("margin-left",`${s}px`,"important"),null!=this.slider&&this.slider.root.style.setProperty("margin-top",`${o+i}px`,"important"),this.root.clientHeight<=n?(this.host.style.setProperty("height",`${this.root.clientHeight}px`),this.host.style.setProperty("overflow-y",null)):this.host.style.setProperty("overflow-y","hidden","important")}}getAlphabetSize(){var t,e;return null!==(e=null===(t=this.unitsHandler)||void 0===t?void 0:t.getAlphabetSize())&&void 0!==e?e:0}sliderOnValuesChanged(t){if(null!=this.host)try{if(this.allowResize&&!this.turnOfResizeForOneSetValue&&this.visibleSlider){const t=Math.ceil(this.slider.max-this.slider.min),e=this.canvas.width/t-this.positionMarginValue;this.positionWidth=e,this._positionWidth=e}this.turnOfResizeForOneSetValue=!1,this.render(!0)}catch(t){const e=(0,m.O)(t);console.error("Bio: WebLogoViewer.sliderOnValuesChanged() error:\n"+e)}}dataFrameFilterOnChanged(t){console.debug("Bio: WebLogoViewer.dataFrameFilterChanged()");try{this.updatePositions(),this.render()}catch(t){const e=(0,m.O)(t);console.error("Bio: WebLogoViewer.dataFrameFilterOnChanged() error:\n"+e)}}dataFrameSelectionOnChanged(t){console.debug("Bio: WebLogoViewer.dataFrameSelectionOnChanged()");try{this.render()}catch(t){const e=(0,m.O)(t);console.error("Bio: WebLogoViewer.dataFrameSelectionOnChanged() error:\n"+e)}}canvasOnMouseMove(t){try{const e=t,n=window.devicePixelRatio,i=this.canvas.getCursorPosition(e,n),[o,s]=this.getMonomer(i);if(this.dataFrame&&this.seqCol&&this.splitter&&s){const t=this.positions[o],n=b(this.dataFrame,this.seqCol,this.filter,this.splitter,s,t),i=r.div([r.div(`${s}`),r.div(`${n} rows`)]);r.tooltip.show(i,e.x+16,e.y+16)}else r.tooltip.hide()}catch(t){const e=(0,m.O)(t);console.error("Bio: WebLogoViewer.canvasOnMouseMove() error:\n"+e)}}canvasOnMouseDown(t){try{const e=t,n=window.devicePixelRatio,[i,o]=this.getMonomer(this.canvas.getCursorPosition(e,n));if(this.dataFrame&&this.seqCol&&this.splitter&&o){const t=this.positions[i],e=a.BitSet.create(this.dataFrame.selection.length,(e=>function(t,e,n,i,o,s,r){if(!n.getSelectedIndexes().includes(i))return!1;const a=e.get(i),l=a?o(a)[r.pos]:null;return l===s||""===l&&"-"===s}(this.dataFrame,this.seqCol,this.filter,e,this.splitter,o,t)));this.dataFrame.selection.init((t=>e.get(t)))}}catch(t){const e=(0,m.O)(t);console.error("Bio: WebLogoViewer.canvasOnMouseDown() error:\n"+e)}}canvasOnWheel(t){try{if(!this.visibleSlider)return;const e=t.deltaY/100*Math.max(Math.floor(this.countOfRenderPositions/2),1);this.slider.scrollBy(this.slider.min+e)}catch(t){const e=(0,m.O)(t);console.error("Bio: WebLogoViewer.canvasOnWheel() error:\n"+e)}}}function b(t,e,n,i,o,s){return c().count(0).take(t.rowCount).filter((t=>n.get(t))).map((t=>{const n=e.get(t),o=n?i(n):[],r=s.pos;return r<o.length?o[r]:null})).toArray().filter((t=>t==o)).reduce(((t,e)=>t+1),0)}y.residuesSet="nucleotides",y.viewerCount=-1},4413:(t,e,n)=>{"use strict";n.d(e,{ST:()=>m});var i=n(3870),o=n(976),s=n(4469),r=n(6414),a=n.n(r),l=n(7983),c=n(701),h=n(4293),u=n(1061);const d=rxjs.operators;var f=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};class m extends o.Filter{get calculating(){return"initial"==this.loader.style.display}set calculating(t){this.loader.style.display=t?"initial":"none"}get filterSummary(){return this.bioFilter.substructure}get isFiltering(){return super.isFiltering&&""!==this.bioFilter.substructure}get isReadyToApplyFilter(){return!this.calculating&&null!=this.bitset}get _debounceTime(){if(null==this.column)return 1e3;const t=this.column.length;return t<500?0:t>1e4?1e3:Math.floor((t-500)/9500*1e3)}constructor(){super(),this.bioFilter=null,this.bitset=null,this.loader=i.loader(),this.notation=void 0,this.root=i.divV([]),this.calculating=!1}attach(t){var e,n,i,s,r;super.attach(t),this.column=t.columns.bySemType(o.SEMTYPE.MACROMOLECULE),null!==(e=this.columnName)&&void 0!==e||(this.columnName=null===(n=this.column)||void 0===n?void 0:n.name),null!==(i=this.notation)&&void 0!==i||(this.notation=null===(s=this.column)||void 0===s?void 0:s.getTag(o.TAGS.UNITS)),this.bioFilter="fasta"===this.notation?new g:"separator"===this.notation?new v(this.column.getTag("separator")):new y,this.root.appendChild(this.bioFilter.filterPanel),this.root.appendChild(this.loader),null===(r=this.onBioFilterChangedSubs)||void 0===r||r.unsubscribe();let a=this.bioFilter.onChanged;a=a.pipe((0,d.debounceTime)(this._debounceTime)),this.onBioFilterChangedSubs=a.subscribe((t=>f(this,void 0,void 0,(function*(){return yield this._onInputChanged()}))))}detach(){super.detach()}applyFilter(){var t;this.bitset&&!this.isDetached&&(null===(t=this.dataFrame)||void 0===t||t.filter.and(this.bitset))}saveState(){var t;const e=super.saveState();return e.bioSubstructure=null===(t=this.bioFilter)||void 0===t?void 0:t.substructure,e}applyState(t){super.applyState(t),t.bioSubstructure&&(this.bioFilter.substructure=t.bioSubstructure);const e=this;t.bioSubstructure&&setTimeout((function(){e._onInputChanged()}),1e3)}_onInputChanged(){var t,e,n;return f(this,void 0,void 0,(function*(){if(this.isFiltering){if(a()(this.dataFrame.rows.filters).has(`${this.columnName}: ${this.filterSummary}`))return;this.calculating=!0;try{this.bitset=yield null===(e=this.bioFilter)||void 0===e?void 0:e.substrucrureSearch(this.column),this.calculating=!1,null===(n=this.dataFrame)||void 0===n||n.rows.requestFilter()}finally{this.calculating=!1}}else this.bitset=null,null===(t=this.dataFrame)||void 0===t||t.rows.requestFilter()}))}}class p{constructor(){this.onChanged=new c.Subject}get filterPanel(){return new HTMLElement}get substructure(){return""}set substructure(t){}substrucrureSearch(t){return f(this,void 0,void 0,(function*(){return null}))}}class g extends p{constructor(){super(),this.substructureInput=i.stringInput("","",(()=>{this.onChanged.next()}),{placeholder:"Substructure"})}get filterPanel(){return this.substructureInput.root}get substructure(){return this.substructureInput.value}set substructure(t){this.substructureInput.value=t}substrucrureSearch(t){return f(this,void 0,void 0,(function*(){return yield(0,l.pf)(this.substructure,t)}))}}class v extends g{constructor(t){super(),this.colSeparator="",this.separatorInput=i.stringInput("","",(()=>{this.onChanged.next()}),{placeholder:"Separator"}),this.colSeparator=t,this.separatorInput.value=t}get filterPanel(){return i.divV([this.substructureInput.root,this.separatorInput.root])}get substructure(){return this.separatorInput.value&&this.separatorInput.value!==this.colSeparator?this.substructureInput.value.replaceAll(this.separatorInput.value,this.colSeparator):this.substructureInput.value}set substructure(t){this.substructureInput.value=t}substrucrureSearch(t){return f(this,void 0,void 0,(function*(){return yield(0,l.pf)(this.substructure,t,this.colSeparator)}))}}class y extends p{constructor(){super(),this._filterPanel=i.div("",{style:{cursor:"pointer"}}),this.helmSubstructure="",this.init()}init(){return f(this,void 0,void 0,(function*(){this.helmEditor=yield s.functions.call("HELM:helmWebEditor"),yield i.tools.waitForElementInDom(this._filterPanel),this.updateFilterPanel(),this._filterPanel.addEventListener("click",(t=>{const{editorDiv:e,webEditor:n}=this.helmEditor.createWebEditor(this.helmSubstructure);i.dialog({showHeader:!1,showFooter:!0}).add(e).onOK((()=>{const t=n.canvas.getHelm(!0).replace(/<\/span>/g,"").replace(/<span style='background:#bbf;'>/g,"");this.helmSubstructure=t,this.updateFilterPanel(this.substructure),setTimeout((()=>{this.onChanged.next()}),10)})).show({modal:!0,fullScreen:!0})})),i.onSizeChanged(this._filterPanel).subscribe((t=>{const e=this.helmEditor.webEditor.canvas.getHelm(!0).replace(/<\/span>/g,"").replace(/<span style='background:#bbf;'>/g,"");this.updateFilterPanel(e)}))}))}get filterPanel(){return this._filterPanel}get substructure(){return this.helmSubstructure}set substructure(t){this.helmEditor.editor.setHelm(t)}updateFilterPanel(t){const e=this._filterPanel.parentElement.clientWidth<100?100:this._filterPanel.parentElement.clientWidth,n=e/2;if(t)(0,h.Y)(this._filterPanel,this.helmEditor.host),this.helmEditor.editor.setHelm(t),this.helmEditor.resizeEditor(e,n);else{const t=i.divText("Click to edit","helm-substructure-filter");(0,h.Y)(this._filterPanel,t)}}substrucrureSearch(t){return f(this,void 0,void 0,(function*(){i.setUpdateIndicator(this._filterPanel,!0),yield(0,u.gw)(10);const e=yield(0,l.QF)(this.substructure,t);return i.setUpdateIndicator(this._filterPanel,!1),e}))}}},9378:function(t,e,n){"use strict";var i=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e.default=t,e};Object.defineProperty(e,"__esModule",{value:!0});var o=i(n(4517));function s(t,e){var n=function(n){return o.empty(t).map((function(){return o.filled(e,n)}))},i=[];return i.push(n(-1)),i.push(n(1/0)),i.push(n(0)),i}function r(t,e,n,i,o){e=Math.floor(e);var s=t[0][e],r=t[1][e];if(t[2][e],n>=r[0])return 0;for(var l=0;l<s.length;l++)if(i===s[l])return 0;return a(t,e,n,i,o)}function a(t,e,n,i,o){var s=t[0][e],r=t[1][e],a=t[2][e];if(n>=r[0])return 0;r[0]=n,s[0]=i,a[0]=o;for(var l=0,c=0;;){var h=2*l+1,u=h+1,d=t[0][0].length;if(h>=d)break;if(u>=d){if(!(r[h]>n))break;c=h}else if(r[h]>=r[u]){if(!(n<r[h]))break;c=h}else{if(!(n<r[u]))break;c=u}r[l]=r[c],s[l]=s[c],a[l]=a[c],l=c}return r[l]=n,s[l]=i,a[l]=o,1}function l(t,e,n,i){for(;2*i+1<n;){var o=2*i+1,s=o+1,r=i;if(t[r]<t[o]&&(r=o),s<n&&t[r]<t[s]&&(r=s),r===i)break;var a=t[i];t[i]=t[r],t[r]=a;var l=e[i];e[i]=e[r],e[r]=l,i=r}}e.makeHeap=s,e.rejectionSample=function(t,e,n){for(var i=o.zeros(t),s=0;s<t;s++){for(var r=!0,a=0;r;){a=o.tauRandInt(e,n);for(var l=!1,c=0;c<s;c++)if(a===i[c]){l=!0;break}l||(r=!1)}i[s]=a}return i},e.heapPush=r,e.uncheckedHeapPush=a,e.buildCandidates=function(t,e,n,i,a){for(var l=s(e,i),c=0;c<e;c++)for(var h=0;h<n;h++)if(!(t[0][c][h]<0)){var u=t[0][c][h],d=t[2][c][h],f=o.tauRand(a);r(l,c,f,u,d),r(l,u,f,c,d),t[2][c][h]=0}return l},e.deheapSort=function(t){for(var e=t[0],n=t[1],i=0;i<e.length;i++)for(var o=e[i],s=n[i],r=0;r<o.length-1;r++){var a=o.length-r-1,c=s.length-r-1,h=o[0];o[0]=o[a],o[a]=h;var u=s[0];s[0]=s[c],s[c]=u,l(s,o,c,0)}return{indices:e,weights:n}},e.smallestFlagged=function(t,e){for(var n=t[0][e],i=t[1][e],o=t[2][e],s=1/0,r=-1,a=0;a>n.length;a++)1===o[a]&&i[a]<s&&(s=i[a],r=a);return r>=0?(o[r]=0,Math.floor(n[r])):-1}},4221:(t,e,n)=>{"use strict";var i=n(4364);e.u=i.UMAP},5686:function(t,e,n){"use strict";var i,o=this&&this.__read||function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var i,o,s=n.call(t),r=[];try{for(;(void 0===e||e-- >0)&&!(i=s.next()).done;)r.push(i.value)}catch(t){o={error:t}}finally{try{i&&!i.done&&(n=s.return)&&n.call(s)}finally{if(o)throw o.error}}return r},s=this&&this.__values||function(t){var e="function"==typeof Symbol&&t[Symbol.iterator],n=0;return e?e.call(t):{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}}},r=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e.default=t,e};Object.defineProperty(e,"__esModule",{value:!0});var a=r(n(4517)),l=function(){function t(t,e,n,i){if(this.entries=new Map,this.nRows=0,this.nCols=0,t.length!==e.length||t.length!==n.length)throw new Error("rows, cols and values arrays must all have the same length");this.nRows=i[0],this.nCols=i[1];for(var o=0;o<n.length;o++){var s=t[o],r=e[o];this.checkDims(s,r);var a=this.makeKey(s,r);this.entries.set(a,{value:n[o],row:s,col:r})}}return t.prototype.makeKey=function(t,e){return t+":"+e},t.prototype.checkDims=function(t,e){if(!(t<this.nRows&&e<this.nCols))throw new Error("row and/or col specified outside of matrix dimensions")},t.prototype.set=function(t,e,n){this.checkDims(t,e);var i=this.makeKey(t,e);this.entries.has(i)?this.entries.get(i).value=n:this.entries.set(i,{value:n,row:t,col:e})},t.prototype.get=function(t,e,n){void 0===n&&(n=0),this.checkDims(t,e);var i=this.makeKey(t,e);return this.entries.has(i)?this.entries.get(i).value:n},t.prototype.getAll=function(t){void 0===t&&(t=!0);var e=[];return this.entries.forEach((function(t){e.push(t)})),t&&e.sort((function(t,e){return t.row===e.row?t.col-e.col:t.row-e.row})),e},t.prototype.getDims=function(){return[this.nRows,this.nCols]},t.prototype.getRows=function(){return Array.from(this.entries,(function(t){var e=o(t,2);return e[0],e[1].row}))},t.prototype.getCols=function(){return Array.from(this.entries,(function(t){var e=o(t,2);return e[0],e[1].col}))},t.prototype.getValues=function(){return Array.from(this.entries,(function(t){var e=o(t,2);return e[0],e[1].value}))},t.prototype.forEach=function(t){this.entries.forEach((function(e){return t(e.value,e.row,e.col)}))},t.prototype.map=function(e){var n=[];this.entries.forEach((function(t){n.push(e(t.value,t.row,t.col))}));var i=[this.nRows,this.nCols];return new t(this.getRows(),this.getCols(),n,i)},t.prototype.toArray=function(){var t=this,e=a.empty(this.nRows).map((function(){return a.zeros(t.nCols)}));return this.entries.forEach((function(t){e[t.row][t.col]=t.value})),e},t}();e.SparseMatrix=l,e.transpose=function(t){var e=[],n=[],i=[];t.forEach((function(t,o,s){e.push(o),n.push(s),i.push(t)}));var o=[t.nCols,t.nRows];return new l(n,e,i,o)},e.identity=function(t){for(var e=o(t,1)[0],n=new l([],[],[],t),i=0;i<e;i++)n.set(i,i,1);return n},e.pairwiseMultiply=function(t,e){return h(t,e,(function(t,e){return t*e}))},e.add=function(t,e){return h(t,e,(function(t,e){return t+e}))},e.subtract=function(t,e){return h(t,e,(function(t,e){return t-e}))},e.maximum=function(t,e){return h(t,e,(function(t,e){return t>e?t:e}))},e.multiplyScalar=function(t,e){return t.map((function(t){return t*e}))},e.eliminateZeros=function(t){for(var e=new Set,n=t.getValues(),i=t.getRows(),o=t.getCols(),s=0;s<n.length;s++)0===n[s]&&e.add(s);var r=function(t,n){return!e.has(n)},a=n.filter(r),c=i.filter(r),h=o.filter(r);return new l(c,h,a,t.getDims())},e.normalize=function(t,e){var n,i;void 0===e&&(e="l2");var o=c[e],r=new Map;t.forEach((function(t,e,n){var i=r.get(e)||[];i.push(n),r.set(e,i)}));var a=new l([],[],[],t.getDims()),h=function(e){for(var n=r.get(e).sort(),i=n.map((function(n){return t.get(e,n)})),s=o(i),l=0;l<s.length;l++)a.set(e,n[l],s[l])};try{for(var u=s(r.keys()),d=u.next();!d.done;d=u.next())h(d.value)}catch(t){n={error:t}}finally{try{d&&!d.done&&(i=u.return)&&i.call(u)}finally{if(n)throw n.error}}return a};var c=((i={}).max=function(t){for(var e=-1/0,n=0;n<t.length;n++)e=t[n]>e?t[n]:e;return t.map((function(t){return t/e}))},i.l1=function(t){for(var e=0,n=0;n<t.length;n++)e+=t[n];return t.map((function(t){return t/e}))},i.l2=function(t){for(var e=0,n=0;n<t.length;n++)e+=Math.pow(t[n],2);return t.map((function(t){return Math.sqrt(Math.pow(t,2)/e)}))},i);function h(t,e,n){for(var i=new Set,o=[],s=[],r=[],a=function(i,a){o.push(i),s.push(a);var l=n(t.get(i,a),e.get(i,a));r.push(l)},c=t.getValues(),h=t.getRows(),u=t.getCols(),d=0;d<c.length;d++){var f=(v=h[d])+":"+(y=u[d]);i.add(f),a(v,y)}var m=e.getValues(),p=e.getRows(),g=e.getCols();for(d=0;d<m.length;d++){var v,y;f=(v=p[d])+":"+(y=g[d]),i.has(f)||a(v,y)}var b=[t.nRows,t.nCols];return new l(o,s,r,b)}e.getCSR=function(t){var e=[];t.forEach((function(t,n,i){e.push({value:t,row:n,col:i})})),e.sort((function(t,e){return t.row===e.row?t.col-e.col:t.row-e.row}));for(var n=[],i=[],o=[],s=-1,r=0;r<e.length;r++){var a=e[r],l=a.row,c=a.col,h=a.value;l!==s&&(s=l,o.push(r)),n.push(c),i.push(h)}return{indices:n,values:i,indptr:o}}},760:function(t,e,n){"use strict";var i=this&&this.__values||function(t){var e="function"==typeof Symbol&&t[Symbol.iterator],n=0;return e?e.call(t):{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}}},o=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e.default=t,e};Object.defineProperty(e,"__esModule",{value:!0});var s=o(n(9378)),r=o(n(5686)),a=o(n(2320)),l=o(n(4517));e.makeNNDescent=function(t,e){return function(n,i,o,r,a,c,h,u){void 0===r&&(r=10),void 0===a&&(a=50),void 0===c&&(c=.001),void 0===h&&(h=.5),void 0===u&&(u=!0);for(var d=n.length,f=s.makeHeap(n.length,o),m=0;m<n.length;m++)for(var p=s.rejectionSample(o,n.length,e),g=0;g<p.length;g++){var v=t(n[m],n[p[g]]);s.heapPush(f,m,v,p[g],1),s.heapPush(f,p[g],v,m,1)}if(u)for(var y=0;y<i.length;y++)for(m=0;m<i[y].length&&!(i[y][m]<0);m++)for(g=m+1;g<i[y].length&&!(i[y][g]<0);g++)v=t(n[i[y][m]],n[i[y][g]]),s.heapPush(f,i[y][m],v,i[y][g],1),s.heapPush(f,i[y][g],v,i[y][m],1);for(y=0;y<r;y++){var b=s.buildCandidates(f,d,o,a,e),w=0;for(m=0;m<d;m++)for(g=0;g<a;g++){var S=Math.floor(b[0][m][g]);if(!(S<0||l.tauRand(e)<h))for(var C=0;C<a;C++){var T=Math.floor(b[0][m][C]),M=b[2][m][g],E=b[2][m][C];T<0||!M&&!E||(v=t(n[S],n[T]),w+=s.heapPush(f,S,v,T,1),w+=s.heapPush(f,T,v,S,1))}}if(w<=c*o*n.length)break}return s.deheapSort(f)}},e.makeInitializations=function(t){return{initFromRandom:function(e,n,i,o,r){for(var a=0;a<i.length;a++)for(var c=l.rejectionSample(e,n.length,r),h=0;h<c.length;h++)if(!(c[h]<0)){var u=t(n[c[h]],i[a]);s.heapPush(o,a,u,c[h],1)}},initFromTree:function(e,n,i,o,r){for(var l=0;l<i.length;l++)for(var c=a.searchFlatTree(i[l],e,r),h=0;h<c.length;h++){if(c[h]<0)return;var u=t(n[c[h]],i[l]);s.heapPush(o,l,u,c[h],1)}}}},e.makeInitializedNNSearch=function(t){return function(e,n,o,a){for(var l,c,h=r.getCSR(n),u=h.indices,d=h.indptr,f=0;f<a.length;f++)for(var m=new Set(o[0][f]);;){var p=s.smallestFlagged(o,f);if(-1===p)break;var g=u.slice(d[p],d[p+1]);try{for(var v=i(g),y=v.next();!y.done;y=v.next()){var b=y.value;if(b!==p&&-1!==b&&!m.has(b)){var w=t(e[b],a[f]);s.uncheckedHeapPush(o,f,w,b,1),m.add(b)}}}catch(t){l={error:t}}finally{try{y&&!y.done&&(c=v.return)&&c.call(v)}finally{if(l)throw l.error}}}return o}},e.initializeSearch=function(t,e,n,o,r,a,l){var c,h,u=s.makeHeap(n.length,o);if(r(o,e,n,u,l),t)try{for(var d=i(t),f=d.next();!f.done;f=d.next())a(f.value,e,n,u,l)}catch(t){c={error:t}}finally{try{f&&!f.done&&(h=d.return)&&h.call(d)}finally{if(c)throw c.error}}return u}},2320:function(t,e,n){"use strict";var i=this&&this.__read||function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var i,o,s=n.call(t),r=[];try{for(;(void 0===e||e-- >0)&&!(i=s.next()).done;)r.push(i.value)}catch(t){o={error:t}}finally{try{i&&!i.done&&(n=s.return)&&n.call(s)}finally{if(o)throw o.error}}return r},o=this&&this.__spread||function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(i(arguments[e]));return t},s=this&&this.__values||function(t){var e="function"==typeof Symbol&&t[Symbol.iterator],n=0;return e?e.call(t):{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}}},r=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e.default=t,e};Object.defineProperty(e,"__esModule",{value:!0});var a=r(n(4517)),l=function(t,e,n,i){this.hyperplanes=t,this.offsets=e,this.children=n,this.indices=i};function c(t,e,n,i,o){if(void 0===n&&(n=30),e.length>n){var s=function(t,e,n){var i=t[0].length,o=a.tauRandInt(e.length,n),s=a.tauRandInt(e.length,n);s=(s+=o===s?1:0)%e.length;for(var r=e[o],l=e[s],c=0,h=a.zeros(i),u=0;u<h.length;u++)h[u]=t[r][u]-t[l][u],c-=h[u]*(t[r][u]+t[l][u])/2;var d=0,f=0,m=a.zeros(e.length);for(u=0;u<e.length;u++){for(var p=c,g=0;g<i;g++)p+=h[g]*t[e[u]][g];0===p?(m[u]=a.tauRandInt(2,n),0===m[u]?d+=1:f+=1):p>0?(m[u]=0,d+=1):(m[u]=1,f+=1)}var v=a.zeros(d),y=a.zeros(f);for(d=0,f=0,u=0;u<m.length;u++)0===m[u]?(v[d]=e[u],d+=1):(y[f]=e[u],f+=1);return{indicesLeft:v,indicesRight:y,hyperplane:h,offset:c}}(t,e,o),r=s.indicesLeft,l=s.indicesRight,h=s.hyperplane,u=s.offset;return{leftChild:c(t,r,n,i+1,o),rightChild:c(t,l,n,i+1,o),isLeaf:!1,hyperplane:h,offset:u}}return{indices:e,isLeaf:!0}}function h(t,e,n,i,s,r,a){var l;if(t.isLeaf)return i[r][0]=-a,(l=s[a]).splice.apply(l,o([0,t.indices.length],t.indices)),{nodeNum:r,leafNum:a+=1};e[r]=t.hyperplane,n[r]=t.offset,i[r][0]=r+1;var c=r,u=h(t.leftChild,e,n,i,s,r+1,a);return r=u.nodeNum,a=u.leafNum,i[c][1]=r+1,{nodeNum:(u=h(t.rightChild,e,n,i,s,r+1,a)).nodeNum,leafNum:u.leafNum}}function u(t){return t.isLeaf?1:1+u(t.leftChild)+u(t.rightChild)}function d(t){return t.isLeaf?1:d(t.leftChild)+d(t.rightChild)}function f(t,e,n,i){for(var o=e,s=0;s<n.length;s++)o+=t[s]*n[s];return 0===o?a.tauRandInt(2,i):o>0?0:1}e.FlatTree=l,e.makeForest=function(t,e,n,i){var o=Math.max(10,e);return a.range(n).map((function(e,n){return function(t,e,n,i){return void 0===e&&(e=30),c(t,a.range(t.length),e,n,i)}(t,o,n,i)})).map((function(t){return function(t,e){var n=u(t),i=d(t),o=a.range(n).map((function(){return a.zeros(t.hyperplane?t.hyperplane.length:0)})),s=a.zeros(n),r=a.range(n).map((function(){return[-1,-1]})),c=a.range(i).map((function(){return a.range(e).map((function(){return-1}))}));return h(t,o,s,r,c,0,0),new l(o,s,r,c)}(t,o)}))},e.makeLeafArray=function(t){var e,n;if(t.length>0){var i=[];try{for(var r=s(t),a=r.next();!a.done;a=r.next()){var l=a.value;i.push.apply(i,o(l.indices))}}catch(t){e={error:t}}finally{try{a&&!a.done&&(n=r.return)&&n.call(r)}finally{if(e)throw e.error}}return i}return[[-1]]},e.searchFlatTree=function(t,e,n){for(var i=0;e.children[i][0]>0;)i=0===f(e.hyperplanes[i],e.offsets[i],t,n)?e.children[i][0]:e.children[i][1];var o=-1*e.children[i][0];return e.indices[o]}},4364:function(t,e,n){"use strict";var i=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){t.done?o(t.value):new n((function(e){e(t.value)})).then(r,a)}l((i=i.apply(t,e||[])).next())}))},o=this&&this.__generator||function(t,e){var n,i,o,s,r={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;r;)try{if(n=1,i&&(o=2&s[0]?i.return:s[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,s[1])).done)return o;switch(i=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return r.label++,{value:s[1],done:!1};case 5:r.label++,i=s[1],s=[0];continue;case 7:s=r.ops.pop(),r.trys.pop();continue;default:if(!((o=(o=r.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){r=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){r.label=s[1];break}if(6===s[0]&&r.label<o[1]){r.label=o[1],o=s;break}if(o&&r.label<o[2]){r.label=o[2],r.ops.push(s);break}o[2]&&r.ops.pop(),r.trys.pop();continue}s=e.call(t,r)}catch(t){s=[6,t],i=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,a])}}},s=this&&this.__read||function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var i,o,s=n.call(t),r=[];try{for(;(void 0===e||e-- >0)&&!(i=s.next()).done;)r.push(i.value)}catch(t){o={error:t}}finally{try{i&&!i.done&&(n=s.return)&&n.call(s)}finally{if(o)throw o.error}}return r},r=this&&this.__spread||function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(s(arguments[e]));return t},a=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e.default=t,e},l=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});var c=a(n(9378)),h=a(n(5686)),u=a(n(760)),d=a(n(2320)),f=a(n(4517)),m=l(n(9251)),p=1e-5,g=.001,v=function(){function t(t){void 0===t&&(t={});var e=this;this.learningRate=1,this.localConnectivity=1,this.minDist=.1,this.nComponents=2,this.nEpochs=0,this.nNeighbors=15,this.negativeSampleRate=5,this.random=Math.random,this.repulsionStrength=1,this.setOpMixRatio=1,this.spread=1,this.transformQueueSize=4,this.targetMetric="categorical",this.targetWeight=.5,this.targetNNeighbors=this.nNeighbors,this.distanceFn=y,this.isInitialized=!1,this.rpForest=[],this.embedding=[],this.optimizationState=new b;var n=function(n){void 0!==t[n]&&(e[n]=t[n])};n("distanceFn"),n("learningRate"),n("localConnectivity"),n("minDist"),n("nComponents"),n("nEpochs"),n("nNeighbors"),n("negativeSampleRate"),n("random"),n("repulsionStrength"),n("setOpMixRatio"),n("spread"),n("transformQueueSize")}return t.prototype.fit=function(t){return this.initializeFit(t),this.optimizeLayout(),this.embedding},t.prototype.fitAsync=function(t,e){return void 0===e&&(e=function(){return!0}),i(this,void 0,void 0,(function(){return o(this,(function(n){switch(n.label){case 0:return this.initializeFit(t),[4,this.optimizeLayoutAsync(e)];case 1:return n.sent(),[2,this.embedding]}}))}))},t.prototype.setSupervisedProjection=function(t,e){void 0===e&&(e={}),this.Y=t,this.targetMetric=e.targetMetric||this.targetMetric,this.targetWeight=e.targetWeight||this.targetWeight,this.targetNNeighbors=e.targetNNeighbors||this.targetNNeighbors},t.prototype.setPrecomputedKNN=function(t,e){this.knnIndices=t,this.knnDistances=e},t.prototype.initializeFit=function(t){if(t.length<=this.nNeighbors)throw new Error("Not enough data points ("+t.length+") to create nNeighbors: "+this.nNeighbors+". Add more data points or adjust the configuration.");if(this.X===t&&this.isInitialized)return this.getNEpochs();if(this.X=t,!this.knnIndices&&!this.knnDistances){var e=this.nearestNeighbors(t);this.knnIndices=e.knnIndices,this.knnDistances=e.knnDistances}this.graph=this.fuzzySimplicialSet(t,this.nNeighbors,this.setOpMixRatio),this.makeSearchFns(),this.searchGraph=this.makeSearchGraph(t),this.processGraphForSupervisedProjection();var n=this.initializeSimplicialSetEmbedding(),i=n.head,o=n.tail,s=n.epochsPerSample;return this.optimizationState.head=i,this.optimizationState.tail=o,this.optimizationState.epochsPerSample=s,this.initializeOptimization(),this.prepareForOptimizationLoop(),this.isInitialized=!0,this.getNEpochs()},t.prototype.makeSearchFns=function(){var t=u.makeInitializations(this.distanceFn),e=t.initFromTree,n=t.initFromRandom;this.initFromTree=e,this.initFromRandom=n,this.search=u.makeInitializedNNSearch(this.distanceFn)},t.prototype.makeSearchGraph=function(t){for(var e=this.knnIndices,n=this.knnDistances,i=[t.length,t.length],o=new h.SparseMatrix([],[],[],i),s=0;s<e.length;s++)for(var r=e[s],a=n[s],l=0;l<r.length;l++){var c=r[l],u=a[l];u>0&&o.set(s,c,u)}var d=h.transpose(o);return h.maximum(o,d)},t.prototype.transform=function(t){var e=this,n=this.X;if(void 0===n||0===n.length)throw new Error("No data has been fit.");var i=Math.floor(this.nNeighbors*this.transformQueueSize);i=Math.min(n.length,i);var o=u.initializeSearch(this.rpForest,n,t,i,this.initFromRandom,this.initFromTree,this.random),s=this.search(n,this.searchGraph,o,t),r=c.deheapSort(s),a=r.indices,l=r.weights;a=a.map((function(t){return t.slice(0,e.nNeighbors)})),l=l.map((function(t){return t.slice(0,e.nNeighbors)}));var d=Math.max(0,this.localConnectivity-1),m=this.smoothKNNDistance(l,this.nNeighbors,d),p=m.sigmas,g=m.rhos,v=this.computeMembershipStrengths(a,l,p,g),y=v.rows,b=v.cols,w=v.vals,S=[t.length,n.length],C=new h.SparseMatrix(y,b,w,S),T=h.normalize(C,"l1"),M=h.getCSR(T),A=t.length,N=E(f.reshape2d(M.indices,A,this.nNeighbors),f.reshape2d(M.values,A,this.nNeighbors),this.embedding),P=this.nEpochs?this.nEpochs/3:C.nRows<=1e4?100:30,x=C.getValues().reduce((function(t,e){return e>t?e:t}),0);C=C.map((function(t){return t<x/P?0:t})),C=h.eliminateZeros(C);var _=this.makeEpochsPerSample(C.getValues(),P),R=C.getRows(),L=C.getCols();return this.assignOptimizationStateParameters({headEmbedding:N,tailEmbedding:this.embedding,head:R,tail:L,currentEpoch:0,nEpochs:P,nVertices:C.getDims()[1],epochsPerSample:_}),this.prepareForOptimizationLoop(),this.optimizeLayout()},t.prototype.processGraphForSupervisedProjection=function(){var t=this.Y,e=this.X;if(t){if(t.length!==e.length)throw new Error("Length of X and y must be equal");if("categorical"===this.targetMetric){var n=this.targetWeight<1?1/(1-this.targetWeight)*2.5:1e12;this.graph=this.categoricalSimplicialSetIntersection(this.graph,t,n)}}},t.prototype.step=function(){var t=this.optimizationState.currentEpoch;return t<this.getNEpochs()&&this.optimizeLayoutStep(t),this.optimizationState.currentEpoch},t.prototype.getEmbedding=function(){return this.embedding},t.prototype.nearestNeighbors=function(t){var e,n=this.distanceFn,i=this.nNeighbors,o=u.makeNNDescent(n,this.random),s=5+Math.floor(.5==(e=Math.pow(t.length,.5)/20)?0:Math.round(e)),r=Math.max(5,Math.floor(Math.round(function(t){return Math.log(t)/Math.log(2)}(t.length))));this.rpForest=d.makeForest(t,i,s,this.random);var a=o(t,d.makeLeafArray(this.rpForest),i,r);return{knnIndices:a.indices,knnDistances:a.weights}},t.prototype.fuzzySimplicialSet=function(t,e,n){void 0===n&&(n=1);var i=this,o=i.knnIndices,s=void 0===o?[]:o,r=i.knnDistances,a=void 0===r?[]:r,l=i.localConnectivity,c=this.smoothKNNDistance(a,e,l),u=c.sigmas,d=c.rhos,f=this.computeMembershipStrengths(s,a,u,d),m=f.rows,p=f.cols,g=f.vals,v=[t.length,t.length],y=new h.SparseMatrix(m,p,g,v),b=h.transpose(y),w=h.pairwiseMultiply(y,b),S=h.subtract(h.add(y,b),w),C=h.multiplyScalar(S,n),T=h.multiplyScalar(w,1-n);return h.add(C,T)},t.prototype.categoricalSimplicialSetIntersection=function(t,e,n,i){void 0===i&&(i=1);var o=T(t,e,i,n);return M(o=h.eliminateZeros(o))},t.prototype.smoothKNNDistance=function(t,e,n,i,o){void 0===n&&(n=1),void 0===i&&(i=64),void 0===o&&(o=1);for(var s=Math.log(e)/Math.log(2)*o,r=f.zeros(t.length),a=f.zeros(t.length),l=0;l<t.length;l++){var c=0,h=1/0,u=1,d=t[l],m=d.filter((function(t){return t>0}));if(m.length>=n){var v=Math.floor(n),y=n-v;v>0?(r[l]=m[v-1],y>p&&(r[l]+=y*(m[v]-m[v-1]))):r[l]=y*m[0]}else m.length>0&&(r[l]=f.max(m));for(var b=0;b<i;b++){for(var w=0,S=1;S<t[l].length;S++){var C=t[l][S]-r[l];w+=C>0?Math.exp(-C/u):1}if(Math.abs(w-s)<p)break;w>s?u=(c+(h=u))/2:(c=u,h===1/0?u*=2:u=(c+h)/2)}if(a[l]=u,r[l]>0){var T=f.mean(d);a[l]<g*T&&(a[l]=g*T)}else{var M=f.mean(t.map(f.mean));a[l]<g*M&&(a[l]=g*M)}}return{sigmas:a,rhos:r}},t.prototype.computeMembershipStrengths=function(t,e,n,i){for(var o=t.length,s=t[0].length,r=f.zeros(o*s),a=f.zeros(o*s),l=f.zeros(o*s),c=0;c<o;c++)for(var h=0;h<s;h++){var u=0;-1!==t[c][h]&&(u=t[c][h]===c?0:e[c][h]-i[c]<=0?1:Math.exp(-(e[c][h]-i[c])/n[c]),r[c*s+h]=c,a[c*s+h]=t[c][h],l[c*s+h]=u)}return{rows:r,cols:a,vals:l}},t.prototype.initializeSimplicialSetEmbedding=function(){for(var t=this,e=this.getNEpochs(),n=this.nComponents,i=this.graph.getValues(),o=0,s=0;s<i.length;s++){var r=i[s];o<i[s]&&(o=r)}var a=this.graph.map((function(t){return t<o/e?0:t}));this.embedding=f.zeros(a.nRows).map((function(){return f.zeros(n).map((function(){return 20*f.tauRand(t.random)-10}))}));var l=[],c=[],h=[],u=a.getAll();for(s=0;s<u.length;s++){var d=u[s];d.value&&(l.push(d.value),h.push(d.row),c.push(d.col))}return{head:c,tail:h,epochsPerSample:this.makeEpochsPerSample(l,e)}},t.prototype.makeEpochsPerSample=function(t,e){var n=f.filled(t.length,-1),i=f.max(t),o=t.map((function(t){return t/i*e}));return o.forEach((function(t,i){t>0&&(n[i]=e/o[i])})),n},t.prototype.assignOptimizationStateParameters=function(t){Object.assign(this.optimizationState,t)},t.prototype.prepareForOptimizationLoop=function(){var t=this,e=t.repulsionStrength,n=t.learningRate,i=t.negativeSampleRate,o=this.optimizationState,s=o.epochsPerSample,a=o.headEmbedding,l=o.tailEmbedding,c=a[0].length,h=a.length===l.length,u=s.map((function(t){return t/i})),d=r(u),f=r(s);this.assignOptimizationStateParameters({epochOfNextSample:f,epochOfNextNegativeSample:d,epochsPerNegativeSample:u,moveOther:h,initialAlpha:n,alpha:n,gamma:e,dim:c})},t.prototype.initializeOptimization=function(){var t=this.embedding,e=this.embedding,n=this.optimizationState,i=n.head,o=n.tail,s=n.epochsPerSample,r=this.getNEpochs(),a=this.graph.nCols,l=C(this.spread,this.minDist),c=l.a,h=l.b;this.assignOptimizationStateParameters({headEmbedding:t,tailEmbedding:e,head:i,tail:o,epochsPerSample:s,a:c,b:h,nEpochs:r,nVertices:a})},t.prototype.optimizeLayoutStep=function(t){for(var e=this.optimizationState,n=e.head,i=e.tail,o=e.headEmbedding,s=e.tailEmbedding,r=e.epochsPerSample,a=e.epochOfNextSample,l=e.epochOfNextNegativeSample,c=e.epochsPerNegativeSample,h=e.moveOther,u=e.initialAlpha,d=e.alpha,m=e.gamma,p=e.a,g=e.b,v=e.dim,y=e.nEpochs,b=e.nVertices,C=0;C<r.length;C++)if(!(a[C]>t)){var T=n[C],M=i[C],E=o[T],A=s[M],N=S(E,A),P=0;N>0&&(P=-2*p*g*Math.pow(N,g-1),P/=p*Math.pow(N,g)+1);for(var x=0;x<v;x++){var _=w(P*(E[x]-A[x]),4);E[x]+=_*d,h&&(A[x]+=-_*d)}a[C]+=r[C];for(var R=Math.floor((t-l[C])/c[C]),L=0;L<R;L++){var I=f.tauRandInt(b,this.random),G=s[I],D=S(E,G),W=0;if(D>0)W=2*m*g,W/=(.001+D)*(p*Math.pow(D,g)+1);else if(T===I)continue;for(x=0;x<v;x++)_=4,W>0&&(_=w(W*(E[x]-G[x]),4)),E[x]+=_*d}l[C]+=R*c[C]}return e.alpha=u*(1-t/y),e.currentEpoch+=1,o},t.prototype.optimizeLayoutAsync=function(t){var e=this;return void 0===t&&(t=function(){return!0}),new Promise((function(n,s){var r=function(){return i(e,void 0,void 0,(function(){var e,i,a,l,c,h;return o(this,(function(o){try{if(e=this.optimizationState,i=e.nEpochs,a=e.currentEpoch,this.embedding=this.optimizeLayoutStep(a),l=this.optimizationState.currentEpoch,c=!1===t(l),h=l===i,c||h)return[2,n(h)];setTimeout((function(){return r()}),0)}catch(t){s(t)}return[2]}))}))};setTimeout((function(){return r()}),0)}))},t.prototype.optimizeLayout=function(t){void 0===t&&(t=function(){return!0});for(var e=!1,n=[];!e;){var i=this.optimizationState,o=i.nEpochs,s=i.currentEpoch;n=this.optimizeLayoutStep(s);var r=this.optimizationState.currentEpoch,a=!1===t(r);e=r===o||a}return n},t.prototype.getNEpochs=function(){var t=this.graph;if(this.nEpochs>0)return this.nEpochs;var e=t.nRows;return e<=2500?500:e<=5e3?400:e<=7500?300:200},t}();function y(t,e){for(var n=0,i=0;i<t.length;i++)n+=Math.pow(t[i]-e[i],2);return Math.sqrt(n)}e.UMAP=v,e.euclidean=y,e.cosine=function(t,e){for(var n=0,i=0,o=0,s=0;s<t.length;s++)n+=t[s]*e[s],i+=Math.pow(t[s],2),o+=Math.pow(e[s],2);return 0===i&&0===o?0:0===i||0===o?1:1-n/Math.sqrt(i*o)};var b=function(){this.currentEpoch=0,this.headEmbedding=[],this.tailEmbedding=[],this.head=[],this.tail=[],this.epochsPerSample=[],this.epochOfNextSample=[],this.epochOfNextNegativeSample=[],this.epochsPerNegativeSample=[],this.moveOther=!0,this.initialAlpha=1,this.alpha=1,this.gamma=1,this.a=1.5769434603113077,this.b=.8950608779109733,this.dim=2,this.nEpochs=500,this.nVertices=0};function w(t,e){return t>e?e:t<-e?-e:t}function S(t,e){for(var n=0,i=0;i<t.length;i++)n+=Math.pow(t[i]-e[i],2);return n}function C(t,e){var n=f.linear(0,3*t,300).map((function(t){return t<e?1:t})),i=f.zeros(n.length).map((function(i,o){return n[o]>=e?Math.exp(-(n[o]-e)/t):i})),o={x:n,y:i},r=m.default(o,(function(t){var e=s(t,2),n=e[0],i=e[1];return function(t){return 1/(1+n*Math.pow(t,2*i))}}),{damping:1.5,initialValues:[.5,.5],gradientDifference:.1,maxIterations:100,errorTolerance:.01}).parameterValues,a=s(r,2);return{a:a[0],b:a[1]}}function T(t,e,n,i){return void 0===n&&(n=1),void 0===i&&(i=5),t.map((function(t,o,s){return-1===e[o]||-1===e[s]?t*Math.exp(-n):e[o]!==e[s]?t*Math.exp(-i):t}))}function M(t){t=h.normalize(t,"max");var e=h.transpose(t),n=h.pairwiseMultiply(e,t);return t=h.add(t,h.subtract(e,n)),h.eliminateZeros(t)}function E(t,e,n){for(var i=f.zeros(t.length).map((function(t){return f.zeros(n[0].length)})),o=0;o<t.length;o++)for(var s=0;s<t[0].length;s++)for(var r=0;r<n[0].length;r++){var a=t[o][s];i[o][r]+=e[o][s]*n[a][r]}return i}e.findABParams=C,e.fastIntersection=T,e.resetLocalConnectivity=M,e.initTransform=E},4517:function(t,e){"use strict";var n=this&&this.__values||function(t){var e="function"==typeof Symbol&&t[Symbol.iterator],n=0;return e?e.call(t):{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}}};function i(t,e){return Math.floor(e()*t)}function o(t){for(var e=[],n=0;n<t;n++)e.push(void 0);return e}function s(t,e){return o(t).map((function(){return e}))}function r(t){return s(t,0)}function a(t){return t.reduce((function(t,e){return t+e}))}Object.defineProperty(e,"__esModule",{value:!0}),e.tauRandInt=i,e.tauRand=function(t){return t()},e.norm=function(t){var e,i,o=0;try{for(var s=n(t),r=s.next();!r.done;r=s.next()){var a=r.value;o+=Math.pow(a,2)}}catch(t){e={error:t}}finally{try{r&&!r.done&&(i=s.return)&&i.call(s)}finally{if(e)throw e.error}}return Math.sqrt(o)},e.empty=o,e.range=function(t){return o(t).map((function(t,e){return e}))},e.filled=s,e.zeros=r,e.ones=function(t){return s(t,1)},e.linear=function(t,e,n){return o(n).map((function(i,o){return t+o*((e-t)/(n-1))}))},e.sum=a,e.mean=function(t){return a(t)/t.length},e.max=function(t){for(var e=0,n=0;n<t.length;n++)e=t[n]>e?t[n]:e;return e},e.max2d=function(t){for(var e=0,n=0;n<t.length;n++)for(var i=0;i<t[n].length;i++)e=t[n][i]>e?t[n][i]:e;return e},e.rejectionSample=function(t,e,n){for(var o=r(t),s=0;s<t;s++)for(var a=!0;a;){for(var l=i(e,n),c=!1,h=0;h<s;h++)if(l===o[h]){c=!0;break}c||(a=!1),o[s]=l}return o},e.reshape2d=function(t,e,n){var i=[],o=0;if(t.length!==e*n)throw new Error("Array dimensions must match input length.");for(var s=0;s<e;s++){for(var r=[],a=0;a<n;a++)r.push(t[o]),o+=1;i.push(r)}return i}},3336:t=>{"use strict";t.exports=$},976:t=>{"use strict";t.exports=DG},4469:t=>{"use strict";t.exports=grok},701:t=>{"use strict";t.exports=rxjs},3870:t=>{"use strict";t.exports=ui},6414:t=>{"use strict";t.exports=wu}},e={};function n(i){var o=e[i];if(void 0!==o)return o.exports;var s=e[i]={id:i,exports:{}};return t[i].call(s.exports,s,s.exports,n),s.exports}n.m=t,n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var i in e)n.o(e,i)&&!n.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},n.u=t=>t+".js",n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},(()=>{var t;n.g.importScripts&&(t=n.g.location+"");var e=n.g.document;if(!t&&e&&(e.currentScript&&(t=e.currentScript.src),!t)){var i=e.getElementsByTagName("script");i.length&&(t=i[i.length-1].src)}if(!t)throw new Error("Automatic publicPath is not supported in this browser");t=t.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),n.p=t})(),n.b=document.baseURI||self.location.href,n.nc=void 0;var i={};(()=>{"use strict";n.r(i),n.d(i,{_package:()=>xt,test:()=>_t,tests:()=>e.QK});var t=n(976),e=n(1061);(0,e.W3)("_first",(()=>{(0,e.Bu)("_first",(()=>{return t=void 0,e=void 0,i=function*(){},new((n=void 0)||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}));var t,e,n,i}))}));var o=n(2012),s=n(9976),r=n(6137),a=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))},l=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};(0,e.W3)("Palettes",(()=>{(0,e.Bu)("testPaletteN",(()=>l(void 0,void 0,void 0,(function*(){yield function(){return a(this,void 0,void 0,(function*(){const t=r.J.Chromatogram;(0,e.l_)(t instanceof s.B,!0),(0,e.l_)(t instanceof r.J,!0)}))}()})))),(0,e.Bu)("testPaletteAA",(()=>l(void 0,void 0,void 0,(function*(){yield function(){return a(this,void 0,void 0,(function*(){const t=o.f.Lesk,n=o.f.RasMol,i=o.f.GrokGroups;(0,e.l_)(t instanceof s.B,!0),(0,e.l_)(n instanceof s.B,!0),(0,e.l_)(i instanceof s.B,!0),(0,e.l_)(t instanceof o.f,!0),(0,e.l_)(n instanceof o.f,!0),(0,e.l_)(i instanceof o.f,!0)}))}()})))),(0,e.Bu)("testPalettePtMe",(()=>l(void 0,void 0,void 0,(function*(){const t=o.f.GrokGroups.get("MeNle"),n=o.f.GrokGroups.get("MeA"),i=o.f.GrokGroups.get("MeG"),s=o.f.GrokGroups.get("MeF"),r=o.f.GrokGroups.get("L"),a=o.f.GrokGroups.get("A"),l=o.f.GrokGroups.get("G"),c=o.f.GrokGroups.get("F");(0,e.l_)(t,r),(0,e.l_)(n,a),(0,e.l_)(i,l),(0,e.l_)(s,c)}))))}));var c=n(4469),h=n(473),u=n(499),d=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};function f(e,n){return d(this,void 0,void 0,(function*(){const i=(yield e()).getCol(n),o=yield c.functions.call("Bio:detectMacromolecule",{col:i});if(o&&(i.semType=o),i.semType===t.SEMTYPE.MACROMOLECULE){const e=`Negative test detected semType='${i.semType}', units='${i.getTag(t.TAGS.UNITS)}'.`;throw new Error(e)}}))}function m(n,i,o,s,r,a,l,h=null){return d(this,void 0,void 0,(function*(){const d=(yield n()).col(i),f=yield c.functions.call("Bio:detectMacromolecule",{col:d});f&&(d.semType=f),(0,e.l_)(d.semType,t.SEMTYPE.MACROMOLECULE),(0,e.l_)(d.getTag(t.TAGS.UNITS),o),(0,e.l_)(d.getTag("aligned"),s),(0,e.l_)(d.getTag("alphabet"),r),h&&(0,e.l_)(d.getTag("separator"),h);const m=new u.C(d);(0,e.l_)(m.getAlphabetSize(),a),(0,e.l_)(m.getAlphabetIsMultichar(),l),m.isHelm()||((0,e.l_)(m.aligned,s),(0,e.l_)(m.alphabet,r))}))}(0,e.W3)("detectors",(()=>{var n,i,o,s,r,a,l,h,u,v,y,b,w,S,C,T,M,E;const A=new(E=class{constructor(){this[n]="id,col1\n1,\n2,\n3,\n4,\n5,",this[i]="col1\n1\n2\n3",this[o]="col1\n4\n5\n6\n7",this[s]="col1\n8\n9\n10\n11\n12",this[r]="col1\nCCCCN1C(=O)CN=C(c2cc(F)ccc12)C3CCCCC3\nC1CCCCC1\nCCCCCC\n",this[a]="seq\nACGTC\nCAGTGT\nTTCAAC\n",this[l]="seq\nACGUC\nCAGUGU\nUUCAAC\n",this[h]="seq\nFWPHEY\nYNRQWYV\nMKPSEYV\n",this[u]="seq\n[meI][hHis][Aca]NT[dE][Thr_PO3H2][Aca]D\n[meI][hHis][Aca][Cys_SEt]T[dK][Thr_PO3H2][Aca][Tyr_PO3H2]\n[Lys_Boc][hHis][Aca][Cys_SEt]T[dK][Thr_PO3H2][Aca][Tyr_PO3H2]\n",this[v]="seq\nA*C*G*T*C\nC*A*G*T*G*T\nT*T*C*A*A*C\n",this[y]="seq\nA*C*G*U*C\nC*A*G*U*G*U\nU*U*C*A*A*C\n",this[b]="seq\nF-W-P-H-E-Y\nY-N-R-Q-W-Y-V\nM-K-P-S-E-Y-V\n",this[w]="seq\nabc-dfgg-abc1-cfr3-rty-wert\nrut12-her2-rty-wert-abc-abc1-dfgg\nrut12-rty-her2-abc-cfr3-wert-rut12\n",this[S]="seq\nabc/dfgg/abc1/cfr3/rty/wert\nrut12/her2/rty/wert//abc/abc1/dfgg\nrut12/rty/her2/abc/cfr3//wert/rut12\n",this[C]="seq\nA-C--G-T--C-T\nC-A-C--T--G-T\nA-C-C-G-T-A-C-T\n",this[T]="seq\nAC-GT-CT\nCAC-T-GT\nACCGTACT\n",this[M]="seq\nFWR-WYV-KHP\nYNR-WYV-KHP\nMWRSWY-CKHP\n"}},n="negEmpty",i="neg1",o="neg2",s="neg3",r="negSmiles",a="csvFastaDna1",l="fastaRna1",h="fastaPt1",u="fastaUn",v="sepDna",y="sepRna",b="sepPt",w="sepUn1",S="sepUn2",C="sepMsaDna1",T="fastaMsaDna1",M="fastaMsaPt1",E),N={fastaFasta:"System:AppData/Bio/data/sample_FASTA.fasta",fastaPtCsv:"System:AppData/Bio/data/sample_FASTA_PT.csv",msaComplex:"System:AppData/Bio/samples/sample_MSA.csv",fastaCsv:"System:AppData/Bio/samples/sample_FASTA.csv",helmCsv:"System:AppData/Bio/samples/sample_HELM.csv",peptidesComplex:"System:AppData/Bio/tests/peptides_complex_msa.csv",peptidesSimple:"System:AppData/Bio/tests/peptides_simple_msa.csv",testDemogCsv:"System:AppData/Bio/tests/testDemog.csv",testHelmCsv:"System:AppData/Bio/tests/testHelm.csv",testIdCsv:"System:AppData/Bio/tests/testId.csv",testSmilesCsv:"System:AppData/Bio/tests/testSmiles.csv",testSmiles2Csv:"System:AppData/Bio/tests/testSmiles2.csv",testSmilesShort:"System:AppData/Bio/tests/testSmilesShort.csv",testActivityCliffsCsv:"System:AppData/Bio/tests/testActivityCliffs.csv",testCerealCsv:"System:AppData/Bio/tests/testCereal.csv",testUnichemSources:"System:AppData/Bio/tests/testUnichemSources.csv",testDmvOffices:"System:AppData/Bio/tests/testDmvOffices.csv",testAlertCollection:"System:AppData/Bio/tests/testAlertCollection.csv",testSpgi100:"System:AppData/Bio/tests/testSpgi100.csv",testSpgi:"System:AppData/Bio/tests/SPGI-derived.csv",testUrl:"System:AppData/Bio/tests/testUrl.csv"},P={};function x(t,e=_){return()=>d(this,void 0,void 0,(function*(){return t in P||(P[t]=(()=>d(this,void 0,void 0,(function*(){return yield e(N[t])})))()),P[t]}))}function _(e){return d(this,void 0,void 0,(function*(){const n=yield c.dapi.files.readAsText(e);return t.DataFrame.fromCsv(n)}))}const R=e=>()=>d(void 0,void 0,void 0,(function*(){const n=A[e],i=t.DataFrame.fromCsv(n);return yield c.data.detectSemanticTypes(i),i}));(0,e.Bu)("NegativeEmpty",(()=>d(void 0,void 0,void 0,(function*(){yield f(R("negEmpty"),"col1")})))),(0,e.Bu)("Negative1",(()=>d(void 0,void 0,void 0,(function*(){yield f(R("neg1"),"col1")})))),(0,e.Bu)("Negative2",(()=>d(void 0,void 0,void 0,(function*(){yield f(R("neg2"),"col1")})))),(0,e.Bu)("Negative3",(()=>d(void 0,void 0,void 0,(function*(){yield f(R("neg3"),"col1")})))),(0,e.Bu)("NegativeSmiles",(()=>d(void 0,void 0,void 0,(function*(){yield f(R("negSmiles"),"col1")})))),(0,e.Bu)("FastaDna1",(()=>d(void 0,void 0,void 0,(function*(){yield m(R("csvFastaDna1"),"seq","fasta","SEQ","DNA",4,!1)})))),(0,e.Bu)("FastaRna1",(()=>d(void 0,void 0,void 0,(function*(){yield m(R("fastaRna1"),"seq","fasta","SEQ","RNA",4,!1)})))),(0,e.Bu)("FastaPt1",(()=>d(void 0,void 0,void 0,(function*(){yield m(R("fastaPt1"),"seq","fasta","SEQ","PT",20,!1)})))),(0,e.Bu)("FastaUn",(()=>d(void 0,void 0,void 0,(function*(){yield m(R("fastaUn"),"seq","fasta","SEQ.MSA","UN",12,!0)})))),(0,e.Bu)("FastaMsaDna1",(()=>d(void 0,void 0,void 0,(function*(){yield m(R("fastaMsaDna1"),"seq","fasta","SEQ.MSA","DNA",4,!1)})))),(0,e.Bu)("FastaMsaPt1",(()=>d(void 0,void 0,void 0,(function*(){yield m(R("fastaMsaPt1"),"seq","fasta","SEQ.MSA","PT",20,!1)})))),(0,e.Bu)("SepDna",(()=>d(void 0,void 0,void 0,(function*(){yield m(R("sepDna"),"seq","separator","SEQ","DNA",4,!1,"*")})))),(0,e.Bu)("SepRna",(()=>d(void 0,void 0,void 0,(function*(){yield m(R("sepRna"),"seq","separator","SEQ","RNA",4,!1,"*")})))),(0,e.Bu)("SepPt",(()=>d(void 0,void 0,void 0,(function*(){yield m(R("sepPt"),"seq","separator","SEQ","PT",20,!1,"-")})))),(0,e.Bu)("SepUn1",(()=>d(void 0,void 0,void 0,(function*(){yield m(R("sepUn1"),"seq","separator","SEQ","UN",8,!0,"-")})))),(0,e.Bu)("SepUn2",(()=>d(void 0,void 0,void 0,(function*(){yield m(R("sepUn2"),"seq","separator","SEQ","UN",9,!0,"/")})))),(0,e.Bu)("SepMsaN1",(()=>d(void 0,void 0,void 0,(function*(){yield m(R("sepMsaDna1"),"seq","separator","SEQ.MSA","DNA",4,!1,"-")})))),(0,e.Bu)("samplesFastaCsv",(()=>d(void 0,void 0,void 0,(function*(){yield g(x("fastaCsv"),{Sequence:new p("fasta","SEQ","PT",20,!1)})})))),(0,e.Bu)("samplesFastaFasta",(()=>d(void 0,void 0,void 0,(function*(){yield g(x("fastaFasta"),{sequence:new p("fasta","SEQ","PT",20,!1)})})))),(0,e.Bu)("samplesPeptidesComplex",(()=>d(void 0,void 0,void 0,(function*(){yield g(x("peptidesComplex"),{})})))),(0,e.Bu)("samplesMsaComplex",(()=>d(void 0,void 0,void 0,(function*(){yield g(x("msaComplex"),{MSA:new p("separator","SEQ.MSA","UN",161,!0,"/")})})))),(0,e.Bu)("samplesIdCsv",(()=>d(void 0,void 0,void 0,(function*(){yield g(x("testIdCsv"),{})})))),(0,e.Bu)("samplesSarSmallCsv",(()=>d(void 0,void 0,void 0,(function*(){yield g(x("testSmilesCsv"),{})})))),(0,e.Bu)("samplesHelmCsv",(()=>d(void 0,void 0,void 0,(function*(){yield g(x("helmCsv"),{HELM:new p("helm",null,null,160,!0)})})))),(0,e.Bu)("samplesTestHelmCsv",(()=>d(void 0,void 0,void 0,(function*(){yield g(x("testHelmCsv"),{"HELM string":new p("helm",null,null,9,!0)})})))),(0,e.Bu)("samplesTestDemogCsv",(()=>d(void 0,void 0,void 0,(function*(){yield g(x("testDemogCsv"),{})})))),(0,e.Bu)("samplesTestSmiles2Csv",(()=>d(void 0,void 0,void 0,(function*(){yield g(x("testSmiles2Csv"),{})})))),(0,e.Bu)("samplesTestSmilesShort",(()=>d(void 0,void 0,void 0,(function*(){yield g(x("testSmilesShort"),{})})))),(0,e.Bu)("samplesTestActivityCliffsNegativeSmiles",(()=>d(void 0,void 0,void 0,(function*(){yield g(x("testActivityCliffsCsv"),{})})))),(0,e.Bu)("samplesFastaPtCsv",(()=>d(void 0,void 0,void 0,(function*(){yield g(x("fastaPtCsv"),{sequence:new p("fasta","SEQ","PT",20,!1)})})))),(0,e.Bu)("samplesTestCerealCsv",(()=>d(void 0,void 0,void 0,(function*(){yield g(x("testCerealCsv"),{})})))),(0,e.Bu)("samplesTestUnichemSources",(()=>d(void 0,void 0,void 0,(function*(){yield g(x("testUnichemSources"),{})})))),(0,e.Bu)("samplesTestDmvOffices",(()=>d(void 0,void 0,void 0,(function*(){yield g(x("testDmvOffices"),{})})))),(0,e.Bu)("samplesTestAlertCollection",(()=>d(void 0,void 0,void 0,(function*(){yield g(x("testAlertCollection"),{})})))),(0,e.Bu)("samplesTestSpgi",(()=>d(void 0,void 0,void 0,(function*(){yield g(x("testSpgi"),{})})))),(0,e.Bu)("samplesTestSpgi100",(()=>d(void 0,void 0,void 0,(function*(){yield g(x("testSpgi100"),{})})))),(0,e.Bu)("samplesTestUrl",(()=>d(void 0,void 0,void 0,(function*(){yield g(x("testUrl"),{})}))))}));class p{constructor(t,e,n,i,o,s){this.units=t,this.aligned=e,this.alphabet=n,this.alphabetSize=i,this.alphabetIsMultichar=o,this.separator=s}}function g(t,e){return d(this,void 0,void 0,(function*(){const n=yield t(),i=[];for(const o of n.columns.names())if(o in e){const n=e[o];try{yield m(t,o,n.units,n.aligned,n.alphabet,n.alphabetSize,n.alphabetIsMultichar,n.separator)}catch(t){const e=t.toString();i.push(`Positive col '${o}' failed: ${e}`)}}else try{yield f(t,o)}catch(t){const e=t.toString();i.push(`Negative col '${o}' failed: ${e}`)}if(i.length>0)throw new Error(i.join("\n"))}))}var v=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};(0,e.W3)("detectors:weak-and-likely",(()=>{const n={fastaDnaWeak1:"id,colName\n1,TTTTT\n2,TTTTT\n3,TTTTT\n4,TTTTT\n",fastaDnaWeak1LikelyName:"id,seq\n1,TTTTT\n2,TTTTT\n3,TTTTT\n4,TTTTT\n",fastaRnaWeak1:"id,colName\n1,UUUUU\n2,UUUUU\n3,UUUUU\n4,UUUUU\n",fastaRnaWeak1LikelyName:"id,seq\n1,UUUUU\n2,UUUUU\n3,UUUUU\n4,UUUUU\n",fastaPtWeak1:"id,colName\n1,SLSLSPGK\n2,SLSLSPGK\n3,SLSLSPGK\n4,SLSLSPGK\n",fastaPtWeak1LikelyName:"id,seq\n1,SLSLSPGK\n2,SLSLSPGK\n3,SLSLSPGK\n4,SLSLSPGK\n",fastaUn1:"id,colName\n1,word\n2,other\n3,some\n4,another\n",fastaUn1LikelyName:"id,seq\n1,word\n2,other\n3,some\n4,another\n",fastaUn2LikelyName:'protein\nBoombastic\nMegafantastic\n"just-a-random-thought,oy!"\n',fastaUnMsa1LikelyName:"id,seq\n1,word\n2,male\n3,bare\n4,core\n"},i=e=>()=>v(void 0,void 0,void 0,(function*(){const i=n[e],o=t.DataFrame.fromCsv(i);return yield c.data.detectSemanticTypes(o),o}));(0,e.Bu)("fastaDnaWeak1",(()=>v(void 0,void 0,void 0,(function*(){yield f(i("fastaDnaWeak1"),"colName")})))),(0,e.Bu)("fastaDnaWeak1LikelyName",(()=>v(void 0,void 0,void 0,(function*(){yield m(i("fastaDnaWeak1LikelyName"),"seq","fasta","SEQ.MSA","DNA",4,!1)})))),(0,e.Bu)("fastaRnaWeak1",(()=>v(void 0,void 0,void 0,(function*(){yield f(i("fastaRnaWeak1"),"colName")})))),(0,e.Bu)("fastaRnaWeak1LikelyName",(()=>v(void 0,void 0,void 0,(function*(){yield m(i("fastaRnaWeak1LikelyName"),"seq","fasta","SEQ.MSA","RNA",4,!1)})))),(0,e.Bu)("fastaPtWeak1",(()=>v(void 0,void 0,void 0,(function*(){yield f(i("fastaPtWeak1"),"colName")})))),(0,e.Bu)("fastaPtWeak1LikelyName",(()=>v(void 0,void 0,void 0,(function*(){yield m(i("fastaPtWeak1LikelyName"),"seq","fasta","SEQ.MSA","PT",20,!1)})))),(0,e.Bu)("fastaUn1",(()=>v(void 0,void 0,void 0,(function*(){yield f(i("fastaUn1"),"colName")})))),(0,e.Bu)("fastaUn1LikelyName",(()=>v(void 0,void 0,void 0,(function*(){yield f(i("fastaUn1LikelyName"),"seq")})))),(0,e.Bu)("fastaUn2LikelyName",(()=>v(void 0,void 0,void 0,(function*(){yield f(i("fastaUn2LikelyName"),"protein")})))),(0,e.Bu)("fastaUnMsa1LikelyName",(()=>v(void 0,void 0,void 0,(function*(){yield f(i("fastaUnMsa1LikelyName"),"seq")}))))}));var y=n(8447),b=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};(0,e.W3)("detectorsBenchmark",(()=>{let n;function i(i,o,s,r,a,l){return b(this,void 0,void 0,(function*(){return yield function(i,c,h,d){return b(this,void 0,void 0,(function*(){const i=(()=>{const e=function(e,n,i,o,s){let r;switch(e){case"fasta":r=t=>{let e="";for(let n=0;n<t.length;n++){const i=t[n];e+=1==i.length?i:`[${i}]`}return e};break;case"separator":r=(t,e)=>t.join(e);break;default:throw new Error(`Not supported notation '${e}'.`)}const a=(t,e)=>{const n=new Array(e);for(let i=0;i<e;i++)n[i]=t[Math.floor(Math.random()*t.length)];return r(n,s)},l=Array(o);for(let t=0;t<o;t++)l[t]=a(n,i);return t.Column.fromStrings("seq",l)}(o,[...(0,y.gM)(s)],r,a,l);return n.prepare({col:e})})(),c=Date.now(),d=yield h(i),f=Date.now();(function(t,n){const i=new u.C(t);(0,e.l_)(t.semType,n.semType),(0,e.l_)(i.notation,n.notation),(0,e.l_)(i.alphabet,n.alphabet),(0,e.l_)(i.separator,n.separator)})(d,{semType:t.SEMTYPE.MACROMOLECULE,notation:o,alphabet:s,separator:l});const m=f-c;if(m>10){const t=`ET ${m} ms is more than max allowed 10 ms.`;throw console.error(t),new Error(t)}return console.log(`ET ${m} ms is OK.`),m}))}(0,0,(t=>b(this,void 0,void 0,(function*(){return function(t){t.callSync();const e=t.getOutputParamValue(),n=t.inputs.col;return e&&(n.semType=e),n}(t)}))))}))}(0,e.bb)((()=>b(void 0,void 0,void 0,(function*(){const e=t.Func.find({package:"Bio",name:"detectMacromolecule"});n=e[0];const i=t.Column.fromStrings("seq",["ACGT","ACGT","ACGT"]);yield n.prepare({col:i}).call()})))),(0,e.Bu)("fastaDnaShorts50Few50",(()=>b(void 0,void 0,void 0,(function*(){yield i(0,"fasta","DNA",50,50)}))),{skipReason:"#1192"}),(0,e.Bu)("fastaDnaShorts50Many1E6",(()=>b(void 0,void 0,void 0,(function*(){yield i(0,"fasta","DNA",50,1e6)}))),{skipReason:"#1192"}),(0,e.Bu)("fastaDnaLong1e6Few50",(()=>b(void 0,void 0,void 0,(function*(){yield i(0,"fasta","DNA",1e6,50)}))),{skipReason:"#1192"}),(0,e.Bu)("separatorDnaShorts50Few50",(()=>b(void 0,void 0,void 0,(function*(){yield i(0,"separator","DNA",50,50,"/")}))),{skipReason:"#1192"}),(0,e.Bu)("separatorDnaShorts50Many1E6",(()=>b(void 0,void 0,void 0,(function*(){yield i(0,"separator","DNA",50,1e6,"/")}))),{}),(0,e.Bu)("separatorDnaLong1e6Few50",(()=>b(void 0,void 0,void 0,(function*(){yield i(0,"separator","DNA",1e6,50,"/")}))),{skipReason:"#1192"})}));var w=n(6098),S=n(600),C=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};function T(n,i){return C(this,void 0,void 0,(function*(){const o=t.DataFrame.fromCsv(n),s=t.DataFrame.fromCsv(i),r=o.getCol("seq"),a=yield c.functions.call("Bio:detectMacromolecule",{col:r});a&&(r.semType=a);const l=s.getCol("seq"),h=yield(0,w.U)(r,!0);(0,e.f6)(h.toList(),l.toList())}))}function M(n,i,o,s,r,a){return C(this,void 0,void 0,(function*(){const l=t.DataFrame.fromCsv(n),h=t.DataFrame.fromCsv(i),u=l.getCol("seq"),d=h.getCol("seq"),f=l.getCol("seq"),m=yield c.functions.call("Bio:detectMacromolecule",{col:f});m&&(f.semType=m),yield c.data.detectSemanticTypes(l),(0,e.l_)(u.semType,t.SEMTYPE.MACROMOLECULE),(0,e.l_)(u.getTag(t.TAGS.UNITS),o),r&&(0,e.l_)(u.getTag("alphabet"),r);const p=yield(0,S.K)({col:u,pepsea:{method:a}});(0,e.l_)(p.semType,t.SEMTYPE.MACROMOLECULE),(0,e.l_)(p.getTag(t.TAGS.UNITS),s),(0,e.l_)(p.getTag("aligned"),"SEQ.MSA"),r&&(0,e.l_)(p.getTag("alphabet"),r),(0,e.f6)(p.toList(),d.toList())}))}new t.Package,(0,e.W3)("MSA",(()=>C(void 0,void 0,void 0,(function*(){(0,e.Bu)("isCorrect",(()=>C(void 0,void 0,void 0,(function*(){yield T("seq\nFWRWYVKHP\nYNRWYVKHP\nMWRSWYCKHP","seq\nFWR-WYVKHP\nYNR-WYVKHP\nMWRSWYCKHP")})))),(0,e.Bu)("isCorrectLong",(()=>C(void 0,void 0,void 0,(function*(){yield T("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,e.Bu)("isCorrectHelm",(()=>C(void 0,void 0,void 0,(function*(){yield M("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","helm","separator",void 0,"mafft")}))),{skipReason:"GROK-13053"}),(0,e.Bu)("isCorrectHelmLong",(()=>C(void 0,void 0,void 0,(function*(){yield M("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.","helm","separator",void 0,"mafft")}))),{skipReason:"GROK-13053"}),(0,e.Bu)("isCorrectSeparator",(()=>C(void 0,void 0,void 0,(function*(){yield M("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","separator","fasta","PT")})))),(0,e.Bu)("isCorrectSeparatorLong",(()=>C(void 0,void 0,void 0,(function*(){yield M("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-----","separator","fasta","PT")}))))}))));var E=n(3553),A=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};function N(t,n){return A(this,void 0,void 0,(function*(){const i=(0,y.gP)(t);console.debug(`Bio: tests: splitters: src=${JSON.stringify(t)}, res=${JSON.stringify(i)} .`),(0,e.f6)(i,n)}))}(0,e.W3)("splitters",(()=>{let n,i;(0,e.bb)((()=>A(void 0,void 0,void 0,(function*(){n=[],i=[]})))),(0,e.X5)((()=>A(void 0,void 0,void 0,(function*(){i.forEach((t=>{c.shell.closeTable(t)})),n.forEach((t=>t.close()))}))));const o=["M[MeI]YKETLL[MeF]PKTDFPMRGGL[MeA]",["M","MeI","Y","K","E","T","L","L","MeF","P","K","T","D","F","P","M","R","G","G","L","MeA"]],s=["PEPTIDE1{meI.hHis.Aca.N.T.dE.Thr_PO3H2.Aca.D-Tyr_Et.Tyr_ab-dehydroMe.dV.E.N.D-Orn.D-aThr.Phe_4Me}$$$",["meI","hHis","Aca","N","T","dE","Thr_PO3H2","Aca","D-Tyr_Et","Tyr_ab-dehydroMe","dV","E","N","D-Orn","D-aThr","Phe_4Me"]],r=["PEPTIDE1{meI.hHis.Aca.N.T.dK.Thr_PO3H2.Aca.D-Tyr_Et.D-Dap.dV.E.N.pnG.Phe_4Me}$$$",["meI","hHis","Aca","N","T","dK","Thr_PO3H2","Aca","D-Tyr_Et","D-Dap","dV","E","N","pnG","Phe_4Me"]],a=["PEPTIDE1{[meI].[hHis].[Aca].N.T.[dK].[Thr_PO3H2].[Aca].[D-Tyr_Et].[D-Dap].[dV].E.N.[pnG].[Phe_4Me]}$$$",["meI","hHis","Aca","N","T","dK","Thr_PO3H2","Aca","D-Tyr_Et","D-Dap","dV","E","N","pnG","Phe_4Me"]],l=["RNA1{R(U)P.R(T)P.R(G)P.R(C)P.R(A)}$$$$",["R(U)P","R(T)P","R(G)P","R(C)P","R(A)"]],u=["RNA1{P.R(U)P.R(T)}$$$$",["P","R(U)P","R(T)"]],d=["RNA1{P.R(U).P.R(T)}$$$$",["P","R(U)","P","R(T)"]];(0,e.Bu)("fastaMulti",(()=>A(void 0,void 0,void 0,(function*(){yield function(t,n){return A(this,void 0,void 0,(function*(){const i=(0,y.kB)(t);console.debug(`Bio: tests: splitters: src=${JSON.stringify(t)}, res=${JSON.stringify(i)} .`),(0,e.f6)(i,n)}))}(o[0],o[1])})))),(0,e.Bu)("helm1",(()=>A(void 0,void 0,void 0,(function*(){yield N(s[0],s[1])})))),(0,e.Bu)("helm2",(()=>A(void 0,void 0,void 0,(function*(){yield N(r[0],r[1])})))),(0,e.Bu)("helm3-multichar",(()=>A(void 0,void 0,void 0,(function*(){yield N(a[0],a[1])})))),(0,e.Bu)("testHelm1",(()=>A(void 0,void 0,void 0,(function*(){yield N(l[0],l[1])})))),(0,e.Bu)("testHelm2",(()=>A(void 0,void 0,void 0,(function*(){yield N(u[0],u[1])})))),(0,e.Bu)("testHelm3",(()=>A(void 0,void 0,void 0,(function*(){yield N(d[0],d[1])})))),(0,e.Bu)("splitToMonomers",(()=>A(void 0,void 0,void 0,(function*(){const t=yield c.dapi.files.readCsv("System:AppData/Bio/samples/sample_MSA.csv"),o=t.getCol("MSA"),s=yield c.functions.call("Bio:detectMacromolecule",{col:o});s&&(o.semType=s),o.setTag("aligned",E.mU);const r=c.shell.addTableView(t);yield c.data.detectSemanticTypes(t),i.push(t),n.push(r),(0,h.splitToMonomers)(),(0,e.l_)(t.columns.names().includes("17"),!0)}))),{skipReason:"GROK-12766"}),(0,e.Bu)("getHelmMonomers",(()=>A(void 0,void 0,void 0,(function*(){const e=t.DataFrame.fromCsv("HELM,Activity\nPEPTIDE1{hHis.N.T}$$$,5.30751\nPEPTIDE1{hHis.Aca.Cys_SEt}$$$,5.72388\n"),n=["hHis","Aca","Cys_SEt","N","T"],i=e.getCol("HELM"),o=(0,h.getHelmMonomers)(i),s=n.filter((t=>!o.includes(t))),r=o.filter((t=>!n.includes(t)));if(s.length>0||r.length){const t=[];throw s.length>0&&t.push(`Missed monomers ${JSON.stringify(s)}.`),r.length>0&&t.push(`Unexpected monomers ${JSON.stringify(r)}.`),new Error(t.join(" "))}}))))}));var P=n(7228),x=n(1345),_=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};(0,e.W3)("monomerLibraries",(()=>{let t,n=null;(0,e.bb)((()=>_(void 0,void 0,void 0,(function*(){t=yield(0,P.JN)(),n=yield c.dapi.userDataStorage.get(x.RV,!0)})))),(0,e.X5)((()=>_(void 0,void 0,void 0,(function*(){yield c.dapi.userDataStorage.put(x.RV,n,!0)})))),(0,e.Bu)("default",(()=>_(void 0,void 0,void 0,(function*(){yield c.dapi.userDataStorage.put(x.RV,{},!0),yield t.loadLibraries(!0);const n=t.getBioLib();(0,e.l_)(n.getTypes().length>0,!0)}))))}));var R=n(4004);function L(){const e=[];return e.push(t.Column.fromList("string","MSA",new Array(Math.pow(10,6)).fill("meI/hHis/Aca/N/T/dE/Thr_PO3H2/Aca/D-Tyr_Et/Tyr_ab-dehydroMe/dV/E/N/D-Orn/D-aThr//Phe_4Me"))),e.push(t.Column.fromList("string","Activity",new Array(Math.pow(10,6)).fill("5.30751"))),e}function I(){const e=[],n="meI/hHis/Aca/N/T/dE/Thr_PO3H2/Aca/D-Tyr_Et/Tyr_ab-dehydroMe/dV/E/N/D-Orn/D-aThr".repeat(Math.pow(10,5));return e.push(t.Column.fromList("string","MSA",new Array(Math.pow(10,2)).fill(n))),e.push(t.Column.fromList("string","Activity",new Array(Math.pow(10,2)).fill("7.30751"))),e}function G(e,n){const i=e(),o=t.DataFrame.fromColumns(i),s=Date.now();var r;(r=o.columns.byName("MSA")).semType=t.SEMTYPE.MACROMOLECULE,r.setTag(t.TAGS.UNITS,"separator"),r.setTag("aligned","SEQ.MSA"),r.setTag("alphabet","UN"),r.setTag("separator","/"),c.shell.addTableView(o);const a=Date.now()-s;console.log(`Performance test: ${n}: ${a}ms`)}var D=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};(0,e.W3)("renderers",(()=>{let n,i;(0,e.bb)((()=>D(void 0,void 0,void 0,(function*(){n=[],i=[]})))),(0,e.X5)((()=>D(void 0,void 0,void 0,(function*(){})))),(0,e.Bu)("long sequence performance ",(()=>D(void 0,void 0,void 0,(function*(){G(I,"Long sequences")})))),(0,e.Bu)("many sequence performance",(()=>D(void 0,void 0,void 0,(function*(){G(L,"Many sequences")})))),(0,e.Bu)("rendererMacromoleculeFasta",(()=>D(void 0,void 0,void 0,(function*(){yield function(){return D(this,void 0,void 0,(function*(){const o=yield c.dapi.files.readAsText("System:AppData/Bio/samples/sample_FASTA.csv"),s=t.DataFrame.fromCsv(o),r=s.getCol("Sequence"),a=yield c.functions.call("Bio:detectMacromolecule",{col:r});a&&(r.semType=a);const l=c.shell.addTableView(s);yield c.data.detectSemanticTypes(s),i.push(s),n.push(l);const h=r.getTag(t.TAGS.CELL_RENDERER);(0,e.l_)(h,"sequence")}))}()})))),(0,e.Bu)("rendererMacromoleculeSeparator",(()=>D(void 0,void 0,void 0,(function*(){yield function(){return D(this,void 0,void 0,(function*(){const o=yield c.dapi.files.readAsText("System:AppData/Bio/data/sample_SEPARATOR_PT.csv"),s=t.DataFrame.fromCsv(o),r=s.getCol("sequence"),a=yield c.functions.call("Bio:detectMacromolecule",{col:r});a&&(r.semType=a);const l=c.shell.addTableView(s);yield c.data.detectSemanticTypes(s),i.push(s),n.push(l);const h=r.getTag(t.TAGS.CELL_RENDERER);(0,e.l_)(h,"sequence")}))}()})))),(0,e.Bu)("rendererMacromoleculeDifference",(()=>D(void 0,void 0,void 0,(function*(){yield function(){return D(this,void 0,void 0,(function*(){const o=t.Column.fromStrings("SequencesDiff",["meI/hHis/Aca/N/T/dK/Thr_PO3H2/Aca#D-Tyr_Et/Tyr_ab-dehydroMe/meN/E/N/dV"]);o.tags[t.TAGS.UNITS]="separator",o.tags.separator="/",o.semType=E.Of.MACROMOLECULE_DIFFERENCE;const s=t.DataFrame.fromColumns([o]),r=c.shell.addTableView(s);yield c.data.detectSemanticTypes(s),i.push(s),n.push(r);const a=o.getTag(t.TAGS.CELL_RENDERER);(0,e.l_)(a,E.Of.MACROMOLECULE_DIFFERENCE)}))}()})))),(0,e.Bu)("afterMsa",(()=>D(void 0,void 0,void 0,(function*(){yield function(){return D(this,void 0,void 0,(function*(){const o=yield c.dapi.files.readAsText("System:AppData/Bio/data/sample_FASTA.fasta"),s=(0,h.importFasta)(o)[0],r=s.getCol("sequence"),a=yield c.functions.call("Bio:detectMacromolecule",{col:r});a&&(r.semType=a);const l=c.shell.addTableView(s);yield c.data.detectSemanticTypes(s),console.log("Bio: tests/renderers/afterMsa, table view"),console.log(`Bio: tests/renderers/afterMsa, src before test semType="${r.semType}", units="${r.getTag(t.TAGS.UNITS)}", cell.renderer="${r.getTag(t.TAGS.CELL_RENDERER)}"`),(0,e.l_)(r.semType,t.SEMTYPE.MACROMOLECULE),(0,e.l_)(r.getTag(t.TAGS.UNITS),"fasta"),(0,e.l_)(r.getTag("aligned"),"SEQ"),(0,e.l_)(r.getTag("alphabet"),"PT"),(0,e.l_)(r.getTag(t.TAGS.CELL_RENDERER),"sequence");const d=yield(0,S.K)({col:r});l.grid.invalidate(),(0,e.l_)(d.semType,t.SEMTYPE.MACROMOLECULE),(0,e.l_)(d.getTag(t.TAGS.UNITS),"fasta"),(0,e.l_)(d.getTag("aligned"),"SEQ.MSA"),(0,e.l_)(d.getTag("alphabet"),"PT"),(0,e.l_)(d.getTag(t.TAGS.CELL_RENDERER),"sequence"),new u.C(d),i.push(s),n.push(l)}))}()})))),(0,e.Bu)("afterConvert",(()=>D(void 0,void 0,void 0,(function*(){yield function(){return D(this,void 0,void 0,(function*(){const o=yield c.dapi.files.readAsText("System:AppData/Bio/data/sample_FASTA_PT.csv"),s=t.DataFrame.fromCsv(o),r=s.col("sequence"),a=yield c.functions.call("Bio:detectMacromolecule",{col:r});a&&(r.semType=a);const l=c.shell.addTableView(s);yield c.data.detectSemanticTypes(s),n.push(l),i.push(s);const h=yield(0,R.o)(r,"separator","/"),d=h.getTag(t.TAGS.CELL_RENDERER);(0,e.l_)(d,"sequence"),new u.C(h)}))}()}))),{skipReason:"GROK-12765"}),(0,e.Bu)("selectRendererBySemType",(()=>D(void 0,void 0,void 0,(function*(){yield function(){return D(this,void 0,void 0,(function*(){const o=t.Column.fromStrings("SequencesDiff",["meI/hHis/Aca/N/T/dK/Thr_PO3H2/Aca#D-Tyr_Et/Tyr_ab-dehydroMe/meN/E/N/dV"]);o.tags[t.TAGS.UNITS]="separator",o.tags.separator="/",o.semType=E.Of.MACROMOLECULE_DIFFERENCE;const s=t.DataFrame.fromColumns([o]),r=c.shell.addTableView(s);i.push(s),n.push(r),yield(0,e.gw)(100);const a=o.getTag(t.TAGS.CELL_RENDERER);if("MacromoleculeDifference"!==a)throw new Error(`Units 'separator', separator '/' and semType 'MacromoleculeDifference' have been manually set on column but after df was added as table, view renderer has set to '${a}' instead of correct 'MacromoleculeDifference'.`)}))}()})))),(0,e.Bu)("setRendererManually",(()=>D(void 0,void 0,void 0,(function*(){yield function(){return D(this,void 0,void 0,(function*(){const o=t.Column.fromStrings("SequencesDiff",["meI/hHis/Aca/N/T/dK/Thr_PO3H2/Aca#D-Tyr_Et/Tyr_ab-dehydroMe/meN/E/N/dV"]);o.tags[t.TAGS.UNITS]="separator",o.tags.separator="/",o.semType=t.SEMTYPE.MACROMOLECULE;const s="MacromoleculeDifference";o.setTag(t.TAGS.CELL_RENDERER,s);const r=t.DataFrame.fromColumns([o]);yield c.data.detectSemanticTypes(r);const a=c.shell.addTableView(r);i.push(r),n.push(a),yield(0,e.gw)(100);const l=o.getTag(t.TAGS.CELL_RENDERER);if(l!==s)throw new Error(`Tag 'cell.renderer' has been manually set to '${s}' for column but after df was added as table, tag 'cell.renderer' has reset to '${l}' instead of manual '${s}'.`)}))}()}))),{skipReason:"GROK-11212"})}));var W=n(7767),F=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};(0,e.W3)("converters",(()=>{let n;!function(t){t.fastaPt="fastaPt",t.separatorPt="separatorPt",t.helmPt="helmPt",t.fastaDna="fastaDna",t.separatorDna="separatorDna",t.helmDna="helmDna",t.fastaRna="fastaRna",t.separatorRna="separatorRna",t.helmRna="helmRna",t.fastaGaps="fastaGaps",t.separatorGaps="separatorGaps",t.helmGaps="helmGaps",t.fastaUn="fastaUn",t.separatorUn="separatorUn",t.helmUn="helmUn",t.helmLoneDeoxyribose="helmLoneDeoxyribose",t.helmLoneRibose="helmLoneRibose",t.helmLonePhosphorus="helmLonePhosphorus",t.fastaLoneDeoxyribose="fastaLoneDeoxyribose",t.fastaLoneRibose="fastaLoneRibose",t.fastaLonePhosphorus="fastaLonePhosphorus"}(n||(n={}));const i={fastaPt:"seq\nFWPHEY\nYNRQWYV\nMKPSEYV\n",separatorPt:"seq\nF-W-P-H-E-Y\nY-N-R-Q-W-Y-V\nM-K-P-S-E-Y-V\n",helmPt:"seq\nPEPTIDE1{F.W.P.H.E.Y}$$$$\nPEPTIDE1{Y.N.R.Q.W.Y.V}$$$$\nPEPTIDE1{M.K.P.S.E.Y.V}$$$$\n",fastaDna:"seq\nACGTC\nCAGTGT\nTTCAAC\n",separatorDna:"seq\nA/C/G/T/C\nC/A/G/T/G/T\nT/T/C/A/A/C\n",helmDna:"seq\nDNA1{D(A)P.D(C)P.D(G)P.D(T)P.D(C)P}$$$$\nDNA1{D(C)P.D(A)P.D(G)P.D(T)P.D(G)P.D(T)P}$$$$\nDNA1{D(T)P.D(T)P.D(C)P.D(A)P.D(A)P.D(C)P}$$$$\n",fastaRna:"seq\nACGUC\nCAGUGU\nUUCAAC\n",separatorRna:"seq\nA*C*G*U*C\nC*A*G*U*G*U\nU*U*C*A*A*C\n",helmRna:"seq\nRNA1{R(A)P.R(C)P.R(G)P.R(U)P.R(C)P}$$$$\nRNA1{R(C)P.R(A)P.R(G)P.R(U)P.R(G)P.R(U)P}$$$$\nRNA1{R(U)P.R(U)P.R(C)P.R(A)P.R(A)P.R(C)P}$$$$\n",fastaGaps:"seq\nFW-PH-EYY\nFYNRQWYV-\nFKP-Q-SEYV\n",separatorGaps:"seq\nF/W//P/H//E/Y/Y\nF/Y/N/R/Q/W/Y/V/\nF/K/P//Q//S/E/Y/V\n",helmGaps:"seq\nPEPTIDE1{F.W.*.P.H.*.E.Y.Y}$$$$\nPEPTIDE1{F.Y.N.R.Q.W.Y.V.*}$$$$\nPEPTIDE1{F.K.P.*.Q.*.S.E.Y.V}$$$$\n",fastaUn:"seq\n[meI][hHis][Aca]NT[dE][Thr_PO3H2][Aca]D\n[meI][hHis][Aca][Cys_SEt]T[dK][Thr_PO3H2][Aca][Tyr_PO3H2]\n[Lys_Boc][hHis][Aca][Cys_SEt]T[dK][Thr_PO3H2][Aca][Tyr_PO3H2]\n",separatorUn:"seq\nmeI-hHis-Aca-N-T-dE-Thr_PO3H2-Aca-D\nmeI-hHis-Aca-Cys_SEt-T-dK-Thr_PO3H2-Aca-Tyr_PO3H2\nLys_Boc-hHis-Aca-Cys_SEt-T-dK-Thr_PO3H2-Aca-Tyr_PO3H2\n",helmUn:"seq\nPEPTIDE1{meI.hHis.Aca.N.T.dE.Thr_PO3H2.Aca.D}$$$$\nPEPTIDE1{meI.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.Aca.Tyr_PO3H2}$$$$\nPEPTIDE1{Lys_Boc.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.Aca.Tyr_PO3H2}$$$$\n",helmLoneDeoxyribose:"seq\nDNA1{D(A).D(C).D(G).D(T).D(C)}$$$$\nDNA1{D(C).D(A).D(G).D(T).D(G).D(T)P}$$$$\nDNA1{D(T).D(T).D(C).D(A).D(A).D(C)P}$$$$\n",helmLoneRibose:"seq\nRNA1{R(A).R(C).R(G).R(U).R(C)}$$$$\nRNA1{R(C).R(A).R(G).R(U).R(G).R(U)P}$$$$\nRNA1{R(U).R(U).R(C).R(A).R(A).R(C)P}$$$$\n",helmLonePhosphorus:"seq\nRNA1{P.P.R(A)P.R(C)P.R(G)P.R(U)P.R(C)P}$$$$\nRNA1{P.P.R(C)P.R(A)P.P.R(G)P.R(U)P.R(G)P.R(U)P}$$$$\nRNA1{P.R(U)P.R(U)P.R(C)P.R(A)P.R(A)P.R(C)P.P.P}$$$$\n"};function o(e){return F(this,void 0,void 0,(function*(){const n=i[e],o=t.DataFrame.fromCsv(n);return yield c.data.detectSemanticTypes(o),o}))}function s(t,n=null){if("separator"===t&&!n)throw new Error(`Argument 'separator' is mandatory for target notation '${t.toString()}'.`);return function(i){const o=new W.L(i).convert(t,n);return(0,e.l_)(o.getTag("units"),t),o}}function r(t,n,i){return F(this,void 0,void 0,(function*(){const s=(yield o(t)).getCol("seq"),r=n(s),a=(yield o(i)).getCol("seq");(0,e.f6)(r.toList(),a.toList()),new u.C(r)}))}(0,e.Bu)("testFastaPtToSeparator",(()=>F(void 0,void 0,void 0,(function*(){yield r(n.fastaPt,s("separator","-"),n.separatorPt)})))),(0,e.Bu)("testFastaDnaToSeparator",(()=>F(void 0,void 0,void 0,(function*(){yield r(n.fastaDna,s("separator","/"),n.separatorDna)})))),(0,e.Bu)("testFastaRnaToSeparator",(()=>F(void 0,void 0,void 0,(function*(){yield r(n.fastaRna,s("separator","*"),n.separatorRna)})))),(0,e.Bu)("testFastaGapsToSeparator",(()=>F(void 0,void 0,void 0,(function*(){yield r(n.fastaGaps,s("separator","/"),n.separatorGaps)})))),(0,e.Bu)("testFastaUnToSeparator",(()=>F(void 0,void 0,void 0,(function*(){yield r(n.fastaUn,s("separator","-"),n.separatorUn)})))),(0,e.Bu)("testFastaPtToHelm",(()=>F(void 0,void 0,void 0,(function*(){yield r(n.fastaPt,s("helm"),n.helmPt)})))),(0,e.Bu)("testFastaDnaToHelm",(()=>F(void 0,void 0,void 0,(function*(){yield r(n.fastaDna,s("helm"),n.helmDna)})))),(0,e.Bu)("testFastaRnaToHelm",(()=>F(void 0,void 0,void 0,(function*(){yield r(n.fastaRna,s("helm"),n.helmRna)})))),(0,e.Bu)("testFastaGapsToHelm",(()=>F(void 0,void 0,void 0,(function*(){yield r(n.fastaGaps,s("helm"),n.helmGaps)})))),(0,e.Bu)("testSeparatorPtToFasta",(()=>F(void 0,void 0,void 0,(function*(){yield r(n.separatorPt,s("fasta"),n.fastaPt)})))),(0,e.Bu)("testSeparatorDnaToFasta",(()=>F(void 0,void 0,void 0,(function*(){yield r(n.separatorDna,s("fasta"),n.fastaDna)})))),(0,e.Bu)("testSeparatorRnaToFasta",(()=>F(void 0,void 0,void 0,(function*(){yield r(n.separatorRna,s("fasta"),n.fastaRna)})))),(0,e.Bu)("testSeparatorGapsToFasta",(()=>F(void 0,void 0,void 0,(function*(){yield r(n.separatorGaps,s("fasta"),n.fastaGaps)})))),(0,e.Bu)("testSeparatorUnToFasta",(()=>F(void 0,void 0,void 0,(function*(){yield r(n.separatorUn,s("fasta"),n.fastaUn)})))),(0,e.Bu)("testSeparatorPtToHelm",(()=>F(void 0,void 0,void 0,(function*(){yield r(n.separatorPt,s("helm"),n.helmPt)})))),(0,e.Bu)("testSeparatorDnaToHelm",(()=>F(void 0,void 0,void 0,(function*(){yield r(n.separatorDna,s("helm"),n.helmDna)})))),(0,e.Bu)("testSeparatorRnaToHelm",(()=>F(void 0,void 0,void 0,(function*(){yield r(n.separatorRna,s("helm"),n.helmRna)})))),(0,e.Bu)("testSeparatorGapsToHelm",(()=>F(void 0,void 0,void 0,(function*(){yield r(n.separatorGaps,s("helm"),n.helmGaps)})))),(0,e.Bu)("testHelmDnaToFasta",(()=>F(void 0,void 0,void 0,(function*(){yield r(n.helmDna,s("fasta"),n.fastaDna)})))),(0,e.Bu)("testHelmRnaToFasta",(()=>F(void 0,void 0,void 0,(function*(){yield r(n.helmRna,s("fasta"),n.fastaRna)})))),(0,e.Bu)("testHelmPtToFasta",(()=>F(void 0,void 0,void 0,(function*(){yield r(n.helmPt,s("fasta"),n.fastaPt)})))),(0,e.Bu)("testHelmUnToFasta",(()=>F(void 0,void 0,void 0,(function*(){yield r(n.helmUn,s("fasta"),n.fastaUn)})))),(0,e.Bu)("testHelmDnaToSeparator",(()=>F(void 0,void 0,void 0,(function*(){yield r(n.helmDna,s("separator","/"),n.separatorDna)})))),(0,e.Bu)("testHelmRnaToSeparator",(()=>F(void 0,void 0,void 0,(function*(){yield r(n.helmRna,s("separator","*"),n.separatorRna)})))),(0,e.Bu)("testHelmPtToSeparator",(()=>F(void 0,void 0,void 0,(function*(){yield r(n.helmPt,s("separator","-"),n.separatorPt)})))),(0,e.Bu)("testHelmUnToSeparator",(()=>F(void 0,void 0,void 0,(function*(){yield r(n.helmUn,s("separator","-"),n.separatorUn)})))),(0,e.Bu)("testHelmLoneRibose",(()=>F(void 0,void 0,void 0,(function*(){yield r(n.helmLoneRibose,s("fasta"),n.fastaRna)})))),(0,e.Bu)("testHelmLoneDeoxyribose",(()=>F(void 0,void 0,void 0,(function*(){yield r(n.helmLoneDeoxyribose,s("separator","/"),n.separatorDna)})))),(0,e.Bu)("testHelmLonePhosphorus",(()=>F(void 0,void 0,void 0,(function*(){yield r(n.helmLonePhosphorus,s("fasta"),n.fastaRna)}))))}));var H=n(5226),k=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};(0,e.W3)("fastaFileHandler",(()=>{const n=["description:1","description:2","description:3","description:4"],i=(t.Column.fromStrings("description",n),["MDYKETLLMPKTDFPMRGGLPNKEPQIQEKW","MIEVFLFGIVLGLIPITLAGLFVTAYLQYRRGDQLDL","MMELVLKTIIGPIVVGVVLRIVDKWLNKDK","MDRTDEVSNHTHDKPTLTWFEEIFEEYHSPFHN"]);function o(t){const o=new H.i(t),s=o.descriptionsArray,r=o.sequencesArray;(0,e.f6)([s,r],[n,i])}(0,e.Bu)("testNormalFormatting",(()=>k(void 0,void 0,void 0,(function*(){o(">description:1\nMDYKETLLMPKTDFPMRGGLPNKEPQIQEKW\n\n>description:2\nMIEVFLFGIVLGLIPITLAGLFVTAYLQYRRGDQLDL\n\n>description:3\nMMELVLKTIIGPIVVGVVLRIVDKWLNKDK\n\n>description:4\nMDRTDEVSNHTHDKPTLTWFEEIFEEYHSPFHN\n")})))),(0,e.Bu)("testExtraSpaces",(()=>k(void 0,void 0,void 0,(function*(){o(">description:1\n MDYKETLLMPKTDFPMRGGLPNKEPQIQEKW\n\n>description:2\nMI EVF LFGIVLGLI PITLAGLFVTAY LQYRRGDQLDL\n\n>description:3\nM MELVLKTI IGPI VVGVVLR IVDKWLNKDK\n\n>description:4\nMDR TDEVSNHTHDKP TLTWFEEIFEEYHSPFHN\n ")})))),(0,e.Bu)("testExtraNewlines",(()=>k(void 0,void 0,void 0,(function*(){o(">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 O=n(9943),V=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};(0,e.W3)("fastaExport",(()=>{let n;!function(t){t.single="single",t.multi="multi"}(n||(n={}));const i={[n.single]:{src:"MDYKETLLMPKTDFPMRGGLP",tgt:["MDYKETLLMP","KTDFPMRGGL","P"]},[n.multi]:{src:"M[MeI]YKETLL[MeF]PKTDFPMRGGL[MeA]",tgt:["M[MeI]YKETLL[MeF]P","KTDFPMRGGL","[MeA]"]}};let o;!function(t){t.test1="test1",t.test2="test2"}(o||(o={}));const s={[o.test1]:{srcCsv:"id,seq\n1,MDYKETLLMP\n2,KTDFPMRGGL\n3,P",idCols:["id"],seqCol:"seq",lineWidth:10,tgtFasta:">1\nMDYKETLLMP\n>2\nKTDFPMRGGL\n>3\nP\n"},[o.test2]:{srcCsv:"id,id2,seq\n1,seqA,M[MeI]YKETLL[MeF]P\n2,seqB,KTDFPMRGGL\n3,seqC,[MeA]\n",idCols:["id2","id"],seqCol:"seq",lineWidth:5,tgtFasta:">seqA|1\nM[MeI]YKE\nTLL[MeF]P\n>seqB|2\nKTDFP\nMRGGL\n>seqC|3\n[MeA]\n"}};function r(t,n=10){const o=y.kB,s=i[t].src,r=(0,O.sK)(s,o,n),a=i[t].tgt;(0,e.f6)(r,a)}function a(n){return V(this,void 0,void 0,(function*(){const i=t.DataFrame.fromCsv(n.srcCsv),o=i.getCol(n.seqCol),s=n.idCols.map((t=>i.getCol(t))),r=(0,O.i$)(s,o,n.lineWidth);(0,e.l_)(r,n.tgtFasta)}))}(0,e.Bu)("wrapSequenceSingle",(()=>V(void 0,void 0,void 0,(function*(){r(n.single,10)})))),(0,e.Bu)("wrapSequenceMulti",(()=>V(void 0,void 0,void 0,(function*(){r(n.multi,10)})))),(0,e.Bu)("saveAsFastaTest1",(()=>V(void 0,void 0,void 0,(function*(){a(s[o.test1])})))),(0,e.Bu)("saveAsFastaTest2",(()=>V(void 0,void 0,void 0,(function*(){a(s[o.test2])}))))}));var U=n(7331),B=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};(0,e.W3)("bio",(()=>{const n="seq\nACGTCT\nCAGTGT\nTTCAAC\n";(0,e.Bu)("testGetStatsHelm1",(()=>B(void 0,void 0,void 0,(function*(){const n=t.DataFrame.fromCsv("seq\nPEPTIDE1{meI}$$$$\n").getCol("seq"),i=(0,y.fy)(n,1,y.gP);(0,e.Wh)(i.freq,{meI:1}),(0,e.l_)(i.sameLength,!0)})))),(0,e.Bu)("testGetStatsN1",(()=>B(void 0,void 0,void 0,(function*(){yield function(n){return B(this,void 0,void 0,(function*(){const i=t.DataFrame.fromCsv(n).col("seq"),o=(0,y.fy)(i,5,y.kB);(0,e.Wh)(o.freq,{A:4,C:5,G:3,T:6}),(0,e.l_)(o.sameLength,!0)}))}(n)})))),(0,e.Bu)("testGetAlphabetSimilarity",(()=>B(void 0,void 0,void 0,(function*(){yield function(){return B(this,void 0,void 0,(function*(){const t=new Set(Object.keys(r.V.Names)),n=(0,y.KX)({A:2041,C:3015,G:3015,T:2048,"-":1e3},t);(0,e.l_)(n>.6,!0)}))}()})))),(0,e.Bu)("testPickupPaletteN1",(()=>B(void 0,void 0,void 0,(function*(){yield function(n){return B(this,void 0,void 0,(function*(){const i=t.DataFrame.fromCsv(n).col("seq"),o=(0,y.dQ)(i);(0,e.l_)(o instanceof r.J,!0)}))}(n)})))),(0,e.Bu)("testPickupPaletteN1e",(()=>B(void 0,void 0,void 0,(function*(){yield function(n){return B(this,void 0,void 0,(function*(){const n=t.DataFrame.fromCsv("seq\nACGTAT\nCAGTTG\nTTCG2C\n").col("seq"),i=(0,y.dQ)(n);(0,e.l_)(i instanceof r.J,!0)}))}()})))),(0,e.Bu)("testPickupPaletteAA1",(()=>B(void 0,void 0,void 0,(function*(){yield function(n){return B(this,void 0,void 0,(function*(){const n=t.DataFrame.fromCsv("seq\nFWPHEYV\nYNRQWYV\nMKPSEYV\n").col("seq"),i=(0,y.dQ)(n);(0,e.l_)(i instanceof o.f,!0)}))}()})))),(0,e.Bu)("testPickupPaletteX",(()=>B(void 0,void 0,void 0,(function*(){yield function(n){return B(this,void 0,void 0,(function*(){const n=t.DataFrame.fromCsv("seq\nXZJ{}2\n5Z4733\n3Z6></\n675687\n").col("seq"),i=(0,y.dQ)(n);(0,e.l_)(i instanceof U.kQ,!0)}))}()}))))})),(0,e.W3)("WebLogo.monomerToShort",(()=>{(0,e.Bu)("longMonomerSingle",(()=>B(void 0,void 0,void 0,(function*(){yield(0,e.l_)((0,y.GU)("S",5),"S")})))),(0,e.Bu)("longMonomerShort",(()=>B(void 0,void 0,void 0,(function*(){yield(0,e.l_)((0,y.GU)("Short",5),"Short")})))),(0,e.Bu)("longMonomerLong56",(()=>B(void 0,void 0,void 0,(function*(){yield(0,e.l_)((0,y.GU)("Long56",5),"Long5…")})))),(0,e.Bu)("longMonomerComplexFirstPartShort",(()=>B(void 0,void 0,void 0,(function*(){yield(0,e.l_)((0,y.GU)("Long-long",5),"Long…")})))),(0,e.Bu)("longMonomerComplexFirstPartLong56",(()=>B(void 0,void 0,void 0,(function*(){yield(0,e.l_)((0,y.GU)("Long56-long",5),"Long5…")}))))}));var Y=n(2433),K=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};function $(t,n){(0,e.l_)(t.name,n.name),(0,e.f6)(Object.keys(t.freq),Object.keys(n.freq));for(const i in t.freq)(0,e.l_)(t.freq[i].count,n.freq[i].count)}(0,e.W3)("WebLogo-positions",(()=>{let n,i;const o="seq\nATC-G-TTGC--\nATC-G-TTGC--\n-TC-G-TTGC--\n-TC-GCTTGC--\n-TC-GCTTGC--";(0,e.bb)((()=>K(void 0,void 0,void 0,(function*(){n=[],i=[]})))),(0,e.X5)((()=>K(void 0,void 0,void 0,(function*(){})))),(0,e.Bu)("allPositions",(()=>K(void 0,void 0,void 0,(function*(){const s=t.DataFrame.fromCsv(o),r=c.shell.addTableView(s),a=s.getCol("seq");a.semType=t.SEMTYPE.MACROMOLECULE,a.setTag(t.TAGS.UNITS,"fasta"),a.setTag("alphabet","DNA"),a.setTag("aligned","SEQ.MSA");const l=yield s.plot.fromType("WebLogo");r.dockManager.dock(l.root,t.DOCK_TYPE.DOWN),n.push(r),i.push(s);const h=l.positions,u=[new Y.CK(0,"1",{A:new Y.yW(2),"-":new Y.yW(3)}),new Y.CK(1,"2",{T:new Y.yW(5)}),new Y.CK(2,"3",{C:new Y.yW(5)}),new Y.CK(3,"4",{"-":new Y.yW(5)}),new Y.CK(4,"5",{G:new Y.yW(5)}),new Y.CK(5,"6",{"-":new Y.yW(3),C:new Y.yW(2)}),new Y.CK(6,"7",{T:new Y.yW(5)}),new Y.CK(7,"8",{T:new Y.yW(5)}),new Y.CK(8,"9",{G:new Y.yW(5)}),new Y.CK(9,"10",{C:new Y.yW(5)}),new Y.CK(10,"11",{"-":new Y.yW(5)}),new Y.CK(11,"12",{"-":new Y.yW(5)})];(0,e.l_)(h.length,u.length);for(let t=0;t<h.length;t++){(0,e.l_)(h[t].name,u[t].name);for(const n in h[t].freq)(0,e.l_)(h[t].freq[n].count,u[t].freq[n].count)}})))),(0,e.Bu)("positions with shrinkEmptyTail option true (filtered)",(()=>K(void 0,void 0,void 0,(function*(){const o=t.DataFrame.fromCsv("seq\n-TC-G-TTGC--\n-TC-GCTTGC--\n-T--C-GT-\n-T--C-GT-\n-T--C-GT-\n-T--CCGT-"),s=c.shell.addTableView(o),r=o.getCol("seq");r.semType=t.SEMTYPE.MACROMOLECULE,r.setTag(t.TAGS.UNITS,"fasta"),r.setTag("alphabet","DNA"),r.setTag("aligned","SEQ"),o.filter.init((t=>t>2)),o.filter.fireChanged();const a=yield o.plot.fromType("WebLogo",{shrinkEmptyTail:!0});s.dockManager.dock(a.root,t.DOCK_TYPE.DOWN),n.push(s),i.push(o);const l=a.positions,h=[new Y.CK(0,"1",{"-":new Y.yW(3)}),new Y.CK(1,"2",{T:new Y.yW(3)}),new Y.CK(2,"3",{"-":new Y.yW(3)}),new Y.CK(3,"4",{"-":new Y.yW(3)}),new Y.CK(4,"5",{C:new Y.yW(3)}),new Y.CK(5,"6",{"-":new Y.yW(2),C:new Y.yW(1)}),new Y.CK(6,"7",{G:new Y.yW(3)}),new Y.CK(7,"8",{T:new Y.yW(3)}),new Y.CK(8,"9",{"-":new Y.yW(3)})];(0,e.l_)(l.length,h.length);for(let t=0;t<l.length;t++){(0,e.l_)(l[t].name,h[t].name);for(const n in l[t].freq)(0,e.l_)(l[t].freq[n].count,h[t].freq[n].count)}})))),(0,e.Bu)("positions with skipEmptyPositions option",(()=>K(void 0,void 0,void 0,(function*(){const s=t.DataFrame.fromCsv(o),r=c.shell.addTableView(s),a=s.getCol("seq");a.semType=t.SEMTYPE.MACROMOLECULE,a.setTag(t.TAGS.UNITS,"fasta"),a.setTag("alphabet","DNA"),a.setTag("aligned","SEQ.MSA");const l=yield s.plot.fromType("WebLogo",{skipEmptyPositions:!0});r.dockManager.dock(l.root,t.DOCK_TYPE.DOWN),n.push(r),i.push(s);const h=l.positions,u=[new Y.CK(0,"1",{A:new Y.yW(2),"-":new Y.yW(3)}),new Y.CK(1,"2",{T:new Y.yW(5)}),new Y.CK(2,"3",{C:new Y.yW(5)}),new Y.CK(4,"5",{G:new Y.yW(5)}),new Y.CK(5,"6",{"-":new Y.yW(3),C:new Y.yW(2)}),new Y.CK(6,"7",{T:new Y.yW(5)}),new Y.CK(7,"8",{T:new Y.yW(5)}),new Y.CK(8,"9",{G:new Y.yW(5)}),new Y.CK(9,"10",{C:new Y.yW(5)})];(0,e.l_)(h.length,u.length);for(let t=0;t<h.length;t++)$(h[t],u[t])})))),(0,e.Bu)("count sequences for monomer at position",(()=>K(void 0,void 0,void 0,(function*(){const s=function(e,n,i,o){const s=t.DataFrame.fromCsv(e),r=s.getCol("seq");return r.semType=t.SEMTYPE.MACROMOLECULE,r.setTag(t.TAGS.UNITS,"fasta"),r.setTag("alphabet","DNA"),r.setTag("aligned","SEQ.MSA"),s}(o),r=s.getCol("seq"),a=c.shell.addTableView(s),l=yield s.plot.fromType("WebLogo",{startPositionName:"3",endPositionName:"7",skipEmptyPositions:!0});a.dockManager.dock(l.root,t.DOCK_TYPE.DOWN),n.push(a),i.push(s);const h=l.positions,u=[new Y.CK(2,"3",{C:new Y.yW(5)}),new Y.CK(4,"5",{G:new Y.yW(5)}),new Y.CK(5,"6",{"-":new Y.yW(3),C:new Y.yW(2)}),new Y.CK(6,"7",{T:new Y.yW(5)})];(0,e.l_)(h.length,u.length);for(let t=0;t<h.length;t++)$(h[t],u[t]);const d=l.splitter,f=h[1],m=(0,Y.eZ)(s,r,s.filter,d,"G",f);(0,e.l_)(m,5)}))))}));var Z=n(2568),q=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};(0,e.W3)("checkInputColumn",(()=>{const n="seq\nseq1,\nseq2,\nseq3,\nseq4";(0,e.Bu)("testMsaPos",(()=>q(void 0,void 0,void 0,(function*(){t.Func.find({package:"Bio",name:"multipleSequenceAlignmentDialog"})[0].inputs.find((t=>"sequence"==t.name));const i=t.DataFrame.fromCsv(n).getCol("seq");i.semType=t.SEMTYPE.MACROMOLECULE,i.setTag(t.TAGS.UNITS,"fasta"),i.setTag("alphabet","DNA"),i.setTag("aligned","SEQ");const[o,s]=(0,Z.l)(i,"Test",["fasta"],["DNA","RNA","PT"]);(0,e.l_)(o,!0)})))),(0,e.Bu)("testMsaNegHelm",(()=>q(void 0,void 0,void 0,(function*(){const i=t.DataFrame.fromCsv(n).getCol("seq");i.semType=t.SEMTYPE.MACROMOLECULE,i.setTag(t.TAGS.UNITS,"helm"),i.setTag(".alphabetIsMultichar","true");const[o,s]=(0,Z.l)(i,"Test",["fasta"],["DNA","RNA","PT"]);(0,e.l_)(o,!1)})))),(0,e.Bu)("testMsaNegUN",(()=>q(void 0,void 0,void 0,(function*(){const i=t.DataFrame.fromCsv(n).getCol("seq");i.semType=t.SEMTYPE.MACROMOLECULE,i.setTag(t.TAGS.UNITS,"fasta"),i.setTag("alphabet","UN"),i.setTag(".alphabetSize","11"),i.setTag(".alphabetIsMultichar","true"),i.setTag("aligned","SEQ");const[o,s]=(0,Z.l)(i,"Test",["fasta"],["DNA","RNA","PT"]);(0,e.l_)(o,!1)})))),(0,e.Bu)("testGetActionFunctionMeta",(()=>q(void 0,void 0,void 0,(function*(){t.Func.find({package:"Bio",name:"multipleSequenceAlignmentDialog"})[0].inputs.find((t=>"sequence"==t.name))}))))}));var z=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};function X(e){return z(this,void 0,void 0,(function*(){const n=yield function(t){return z(this,void 0,void 0,(function*(){return yield xt.files.readAsText(t)}))}(e),i=t.DataFrame.fromCsv(n);return i.name=e.replace(".csv",""),i}))}function j(t){return z(this,void 0,void 0,(function*(){const e=yield X(t);return e.name=t.replace(".csv",""),c.shell.addTableView(e)}))}var Q=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};let J,tt;function et(t,e){for(const n of t.view.viewers)if(n.type===e)return n}function nt(t){return Q(this,void 0,void 0,(function*(){const e=new Promise(((e,n)=>{t.computeCompleted.subscribe((t=>Q(this,void 0,void 0,(function*(){try{e(!0)}catch(t){n(t)}}))))}));yield e}))}(0,e.W3)("similarity/diversity",(()=>Q(void 0,void 0,void 0,(function*(){(0,e.bb)((()=>Q(void 0,void 0,void 0,(function*(){J=[],tt=[]})))),(0,e.X5)((()=>Q(void 0,void 0,void 0,(function*(){for(const t of J)t.close();for(const t of tt)c.shell.closeTable(t)})))),(0,e.Bu)("similaritySearchViewer",(()=>Q(void 0,void 0,void 0,(function*(){yield function(){return Q(this,void 0,void 0,(function*(){const n=yield j("tests/sample_MSA_data.csv"),i=n.addViewer("Sequence Similarity Search");yield(0,e.gw)(100);const o=et(i,"Sequence Similarity Search");J.push(o),J.push(n),o.molCol||(yield nt(o)),(0,e.l_)(o.fingerprint,"Morgan"),(0,e.l_)(o.distanceMetric,"Tanimoto"),(0,e.l_)(o.scores.get(0),t.FLOAT_NULL),(0,e.l_)(o.idxs.get(0),0),(0,e.l_)(o.molCol.get(0),"D-Tyr_Et/Tyr_ab-dehydroMe/dV/E/N/D-Orn/D-aThr//Phe_4Me"),(0,e.l_)(o.scores.get(1),.4722222089767456),(0,e.l_)(o.idxs.get(1),11),(0,e.l_)(o.molCol.get(1),"meI/hHis//Aca/meM/Tyr_ab-dehydroMe/dV/E/N/D-Orn/D-aThr//Phe_4Me");const s=nt(o);n.dataFrame.currentRowIdx=1,yield s,(0,e.l_)(o.targetMoleculeIdx,1),(0,e.l_)(o.molCol.get(0),"meI/hHis/Aca/Cys_SEt/T/dK/Thr_PO3H2/Aca/Tyr_PO3H2/D-Chg/dV/Phe_ab-dehydro/N/D-Orn/D-aThr//Phe_4Me")}))}()})))),(0,e.Bu)("diversitySearchViewer",(()=>Q(void 0,void 0,void 0,(function*(){yield function(){return Q(this,void 0,void 0,(function*(){const t=yield j("tests/sample_MSA_data.csv"),n=t.addViewer("Sequence Diversity Search");yield(0,e.gw)(10);const i=et(n,"Sequence Diversity Search");J.push(i),J.push(t),i.renderMolIds||(yield nt(i)),(0,e.l_)(i.fingerprint,"Morgan"),(0,e.l_)(i.distanceMetric,"Tanimoto"),(0,e.l_)(i.initialized,!0),(0,e.l_)(i.renderMolIds.length>0,!0)}))}()}))))}))));var it=n(4413),ot=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};(0,e.W3)("substructureFilters",(()=>ot(void 0,void 0,void 0,(function*(){let t,n;(0,e.bb)((()=>ot(void 0,void 0,void 0,(function*(){t=yield(0,P.JN)(),n=yield c.dapi.userDataStorage.get(x.RV,!0),yield c.dapi.userDataStorage.post(x.RV,x.rb,!0),yield t.loadLibraries(!0)})))),(0,e.X5)((()=>ot(void 0,void 0,void 0,(function*(){yield c.dapi.userDataStorage.put(x.RV,n,!0),yield t.loadLibraries(!0)})))),(0,e.Bu)("fasta",(()=>ot(void 0,void 0,void 0,(function*(){const t=yield X("tests/filter_FASTA.csv"),n=new it.ST;yield c.data.detectSemanticTypes(t),n.attach(t),n.bioFilter.substructure="MD",yield(0,e.gw)(100),(0,e.l_)(n.dataFrame.filter.trueCount,3),(0,e.l_)(n.dataFrame.filter.get(0),!0),(0,e.l_)(n.dataFrame.filter.get(3),!0),(0,e.l_)(n.dataFrame.filter.get(8),!0),(0,e.l_)(n.dataFrame.filter.get(1),!1)})))),(0,e.Bu)("separator",(()=>ot(void 0,void 0,void 0,(function*(){const t=yield X("tests/filter_MSA.csv"),n=new it.ST;yield c.data.detectSemanticTypes(t),n.attach(t),n.bioFilter.substructure="meI",yield(0,e.gw)(100),(0,e.l_)(n.dataFrame.filter.trueCount,7),(0,e.l_)(n.dataFrame.filter.get(2),!1),n.bioFilter.substructure="/meI",yield(0,e.gw)(100),(0,e.l_)(n.dataFrame.filter.trueCount,0),n.bioFilter.substructure="meI-hHis",n.bioFilter.separatorInput.value="-",yield(0,e.gw)(100),(0,e.l_)(n.dataFrame.filter.trueCount,7),(0,e.l_)(n.dataFrame.filter.get(2),!1)})))),(0,e.Bu)("helm",(()=>ot(void 0,void 0,void 0,(function*(){const t=yield X("tests/filter_HELM.csv"),n=c.shell.addTableView(t),i=new it.ST;yield c.data.detectSemanticTypes(t),i.attach(t);const o=new Promise(((e,n)=>{t.onFilterChanged.subscribe((t=>ot(void 0,void 0,void 0,(function*(){try{e(!0)}catch(t){n(t)}}))))}));i.bioFilter.helmSubstructure="PEPTIDE1{C}$$$$V2.0",i.bioFilter.onChanged.next(),yield o,(0,e.l_)(i.dataFrame.filter.trueCount,2),(0,e.l_)(i.dataFrame.filter.get(0),!0),(0,e.l_)(i.dataFrame.filter.get(3),!0),i.bioFilter.helmSubstructure="PEPTIDE1{A.C}$$$$V2.0",i.bioFilter.onChanged.next(),yield(0,e.gw)(100),(0,e.l_)(i.dataFrame.filter.trueCount,1),(0,e.l_)(i.dataFrame.filter.get(3),!0),n.close()}))),{skipReason:"GROK-12779"})}))));var st=n(8341);(0,e.W3)("PepSeA",(()=>{(0,e.Bu)("Basic alignment",(()=>{return n=void 0,i=void 0,s=function*(){const n=t.DataFrame.fromCsv('HELM,MSA\n "PEPTIDE1{F.L.R.G.W.[MeF].Y.S.N.N.C}$$$$","F.L.R.G.W.MeF.Y..S.N.N.C"\n "PEPTIDE1{F.L.R.G.Y.[MeF].Y.W.N.C}$$$$","F.L.R.G.Y.MeF.Y.W...N.C"\n "PEPTIDE1{F.G.Y.[MeF].Y.W.S.D.N.C}$$$$","F...G.Y.MeF.Y.W.S.D.N.C"\n "PEPTIDE1{F.L.R.G.Y.[MeF].Y.W.S.N.D.C}$$$$","F.L.R.G.Y.MeF.Y.W.S.N.D.C"\n "PEPTIDE1{F.V.R.G.Y.[MeF].Y.W.S.N.C}$$$$","F.V.R.G.Y.MeF.Y.W.S..N.C"'),i=yield(0,st.f)(n.getCol("HELM"),"msa(HELM)"),o=n.getCol("MSA");for(let t=0;t<i.length;++t)(0,e.l_)(i.get(t)==o.get(t),!0)},new((o=void 0)||(o=Promise))((function(t,e){function r(t){try{l(s.next(t))}catch(t){e(t)}}function a(t){try{l(s.throw(t))}catch(t){e(t)}}function l(e){var n;e.done?t(e.value):(n=e.value,n instanceof o?n:new o((function(t){t(n)}))).then(r,a)}l((s=s.apply(n,i||[])).next())}));var n,i,o,s}),{skipReason:"GROK-12764"})}));(0,e.W3)("viewers",(()=>{const n=t.Func.find({package:"Bio",tags:["viewer"]}).map((t=>t.friendlyName));for(const t of n)(0,e.Bu)(t,(()=>{return n=void 0,i=void 0,s=function*(){yield(0,e.AB)(t,yield X("data/sample_FASTA_DNA.csv"),!0)},new((o=void 0)||(o=Promise))((function(t,e){function r(t){try{l(s.next(t))}catch(t){e(t)}}function a(t){try{l(s.throw(t))}catch(t){e(t)}}function l(e){var n;e.done?t(e.value):(n=e.value,n instanceof o?n:new o((function(t){t(n)}))).then(r,a)}l((s=s.apply(n,i||[])).next())}));var n,i,o,s}))}));var rt=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};const at="seq\nACGTC\nCAGTGT\nTTCAAC\n",lt="seq\nAC-GT-CT\nCAC-T-GT\nACCGTACT\n",ct="seq\nabc-dfgg-abc1-cfr3-rty-wert\nrut12-her2-rty-wert-abc-abc1-dfgg\nrut12-rty-her2-abc-cfr3-wert-rut12\n";(0,e.W3)("UnitsHandler",(()=>{function n(e){return rt(this,void 0,void 0,(function*(){const n=t.DataFrame.fromCsv(e);yield c.data.detectSemanticTypes(n);const i=new u.C(n.getCol("seq"));return[n,i]}))}function i(e,n,i){return rt(this,void 0,void 0,(function*(){const o=t.DataFrame.fromCsv(e),s=o.getCol("seq");s.setTag(n,i),s.semType=t.SEMTYPE.MACROMOLECULE,"separator"===i&&s.setTag("separator","-");const r=new u.C(o.getCol("seq"));return[o,r]}))}(0,e.Bu)("Seq-Fasta",(()=>rt(void 0,void 0,void 0,(function*(){const[t,i]=yield n(at);(0,e.l_)(i.notation,"fasta"),(0,e.l_)(i.isMsa(),!1)})))),(0,e.Bu)("Seq-Fasta-MSA",(()=>rt(void 0,void 0,void 0,(function*(){const[t,i]=yield n(lt);(0,e.l_)(i.notation,"fasta"),(0,e.l_)(i.isMsa(),!0)})))),(0,e.Bu)("Seq-Fasta-units",(()=>rt(void 0,void 0,void 0,(function*(){const[n,o]=yield i(at,t.TAGS.UNITS,"fasta");(0,e.l_)(o.notation,"fasta"),(0,e.l_)(o.isMsa(),!1)})))),(0,e.Bu)("Seq-Fasta-MSA-units",(()=>rt(void 0,void 0,void 0,(function*(){const[n,o]=yield i(lt,t.TAGS.UNITS,"fasta");(0,e.l_)(o.notation,"fasta"),(0,e.l_)(o.isMsa(),!0)})))),(0,e.Bu)("Seq-Helm",(()=>rt(void 0,void 0,void 0,(function*(){const[n,o]=yield i("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}$$$$\n",t.TAGS.UNITS,"helm");(0,e.l_)(o.notation,"helm"),(0,e.l_)(o.isHelm(),!0)})))),(0,e.Bu)("Seq-UN",(()=>rt(void 0,void 0,void 0,(function*(){const[n,o]=yield i(ct,t.TAGS.UNITS,"separator");(0,e.l_)(o.notation,"separator"),(0,e.l_)(o.separator,"-"),(0,e.l_)(o.alphabet,"UN")})))),(0,e.Bu)("Seq-UN-auto",(()=>rt(void 0,void 0,void 0,(function*(){const[t,i]=yield n(ct);(0,e.l_)(i.notation,"separator"),(0,e.l_)(i.separator,"-"),(0,e.l_)(i.alphabet,"UN")}))))}));var ht=n(6103),ut=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};const dt=new t.FileSource("System:AppData/Bio"),ft={PT:"peptides fasta",DNA:"dna fasta",MSA:"msa separator"},mt={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"},pt={PT:"tests/to-atomic-level-peptides-output.csv",DNA:"tests/to-atomic-level-dna-output.csv",MSA:"tests/to-atomic-level-msa-output.csv"},gt="molfile(sequence)";function vt(t,e="seq",n){return ut(this,void 0,void 0,(function*(){const i=t.getCol(e),o=n.getBioLib();yield(0,ht.i0)(t,i,o)}))}(0,e.W3)("toAtomicLevel",(()=>ut(void 0,void 0,void 0,(function*(){const n={},i={};let o,s,r=null;function a(t,n){return ut(this,void 0,void 0,(function*(){const i=t.getCol("sequence");yield(0,h.toAtomicLevel)(t,i);const o=t.getCol(gt),s=n.getCol(gt),r=[...o.values()],a=[...s.values()];(0,e.f6)(r,a)}))}(0,e.bb)((()=>ut(void 0,void 0,void 0,(function*(){o=yield(0,h.getMonomerLibHelper)(),r=yield c.dapi.userDataStorage.get(x.RV,!0),yield c.dapi.userDataStorage.put(x.RV,{},!0),yield o.loadLibraries(!0);for(const t in ft)n[t]=yield dt.readCsv(mt[t]),yield c.data.detectSemanticTypes(n[t]),i[t]=yield dt.readCsv(pt[t])})))),(0,e.X5)((()=>ut(void 0,void 0,void 0,(function*(){yield c.dapi.userDataStorage.put(x.RV,r,!0),yield o.loadLibraries(!0)}))));for(const t in ft)(0,e.Bu)(`${ft[t]}`,(()=>ut(void 0,void 0,void 0,(function*(){yield a(n[t],i[t])}))),{skipReason:"GROK-13100"});!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"}(s||(s={}));const l={[s.fastaDna]:"seq\nACGTC\nCAGTGT\nTTCAAC\n",[s.fastaRna]:"seq\nACGUC\nCAGUGU\nUUCAAC\n",[s.fastaPt]:"seq\nFWPHEY\nYNRQWYV\nMKPSEYV\n",[s.separatorDna]:"seq\nA/C/G/T/C\nC/A/G/T/G/T\nT/T/C/A/A/C\n",[s.separatorRna]:"seq\nA*C*G*U*C\nC*A*G*U*G*U\nU*U*C*A*A*C\n",[s.separatorPt]:"seq\nF-W-P-H-E-Y\nY-N-R-Q-W-Y-V\nM-K-P-S-E-Y-V\n",[s.separatorUn]:"seq\nmeI-hHis-Aca-N-T-dE-Thr_PO3H2-Aca-D\nmeI-hHis-Aca-Cys_SEt-T-dK-Thr_PO3H2-Aca-Tyr_PO3H2\nLys_Boc-hHis-Aca-Cys_SEt-T-dK-Thr_PO3H2-Aca-Tyr_PO3H2\n",[s.helm]:"seq\nPEPTIDE1{meI.D-gGlu.Aca.N.T.dE.Thr_PO3H2.Aca.D}$$$\nPEPTIDE1{meI.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.Aca.Tyr_PO3H2}$$$\nPEPTIDE1{Lys_Boc.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.Aca.Tyr_PO3H2}$$$\n"};function u(e){return ut(this,void 0,void 0,(function*(){const n=l[e],i=t.DataFrame.fromCsv(n);return yield c.data.detectSemanticTypes(i),i}))}(0,e.Bu)("fastaDna",(()=>ut(void 0,void 0,void 0,(function*(){yield vt(yield u(s.fastaDna),"seq",o)})))),(0,e.Bu)("fastaRna",(()=>ut(void 0,void 0,void 0,(function*(){yield vt(yield u(s.fastaRna),"seq",o)})))),(0,e.Bu)("fastaPt",(()=>ut(void 0,void 0,void 0,(function*(){yield vt(yield u(s.fastaPt),"seq",o)})))),(0,e.Bu)("separatorDna",(()=>ut(void 0,void 0,void 0,(function*(){yield vt(yield u(s.separatorDna),"seq",o)})))),(0,e.Bu)("separatorDna",(()=>ut(void 0,void 0,void 0,(function*(){yield vt(yield u(s.separatorRna),"seq",o)})))),(0,e.Bu)("separatorPt",(()=>ut(void 0,void 0,void 0,(function*(){yield vt(yield u(s.separatorPt),"seq",o)})))),(0,e.Bu)("separatorUn",(()=>ut(void 0,void 0,void 0,(function*(){yield vt(yield u(s.separatorUn),"seq",o)})))),(0,e.Bu)("helm",(()=>ut(void 0,void 0,void 0,(function*(){yield vt(yield u(s.helm),"seq",o)}))))}))));var yt=n(489),bt=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};function wt(e){return bt(this,void 0,void 0,(function*(){const n=t.DataFrame.fromCsv(e),i=n.col("seq"),o=yield c.functions.call("Bio:detectMacromolecule",{col:i});return o&&(i.semType=o),yield c.data.detectSemanticTypes(n),new u.C(i)}))}function St(t,n,i,o){const s=i(t,n);(0,e.l_)(s,o)}(0,e.W3)("Distance",(()=>bt(void 0,void 0,void 0,(function*(){const t=[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]],n={F:0,W:1,R:2,Y:3},i="FWRWY",o="FWRWW",s="FWY",r="FWRWY",a="FWY",l="FWRRRRY";(0,e.Bu)("protein-distance-function",(()=>bt(void 0,void 0,void 0,(function*(){const t=(yield wt("seq\n FWRWYVKHP\n YNRWYVKHP\n MWRSWYCKHP")).getDistanceFunctionName();(0,e.l_)(t,yt.U.NEEDLEMANN_WUNSCH)})))),(0,e.Bu)("DNA-distance-function",(()=>bt(void 0,void 0,void 0,(function*(){const t=(yield wt("seq\n ATAACG\n ATCGA\n ATCGA")).getDistanceFunctionName();(0,e.l_)(t,yt.U.LEVENSHTEIN)})))),(0,e.Bu)("MSA-distance-function",(()=>bt(void 0,void 0,void 0,(function*(){const t=(yield wt("seq\n ATAAC\n ATCGA\n ATCGA")).getDistanceFunctionName();(0,e.l_)(t,yt.U.HAMMING)})))),(0,e.Bu)("levenstein-sub",(()=>bt(void 0,void 0,void 0,(function*(){const t=yt.o[yt.U.LEVENSHTEIN]();St(i,o,t,1)})))),(0,e.Bu)("levenstein-del",(()=>bt(void 0,void 0,void 0,(function*(){const t=yt.o[yt.U.LEVENSHTEIN]();St(s,r,t,2)})))),(0,e.Bu)("hamming",(()=>bt(void 0,void 0,void 0,(function*(){const t=yt.o[yt.U.HAMMING]();St(s,r,t,3)})))),(0,e.Bu)("needleman-blosum62",(()=>bt(void 0,void 0,void 0,(function*(){const t=yt.o[yt.U.NEEDLEMANN_WUNSCH]();St(i,o,t,-35)})))),(0,e.Bu)("needleman-blosum62-del",(()=>bt(void 0,void 0,void 0,(function*(){const t=yt.o[yt.U.NEEDLEMANN_WUNSCH]();St(s,r,t,-14)})))),(0,e.Bu)("needleman-custom-sub",(()=>bt(void 0,void 0,void 0,(function*(){const e=yt.o[yt.U.NEEDLEMANN_WUNSCH]({scoringMatrix:t,alphabetIndexes:n,gapOpen:1,gapExtend:1});St(i,o,e,-4)})))),(0,e.Bu)("needleman-custom-del",(()=>bt(void 0,void 0,void 0,(function*(){const e=yt.o[yt.U.NEEDLEMANN_WUNSCH]({scoringMatrix:t,alphabetIndexes:n,gapOpen:1,gapExtend:1});St(s,r,e,-1)})))),(0,e.Bu)("needleman-custom-zero-extend",(()=>bt(void 0,void 0,void 0,(function*(){const e=yt.o[yt.U.NEEDLEMANN_WUNSCH]({scoringMatrix:t,alphabetIndexes:n,gapOpen:1,gapExtend:0});St(a,l,e,-2)})))),(0,e.Bu)("needleman-custom-half-extend",(()=>bt(void 0,void 0,void 0,(function*(){const e=yt.o[yt.U.NEEDLEMANN_WUNSCH]({scoringMatrix:t,alphabetIndexes:n,gapOpen:2,gapExtend:1});St(a,l,e,2)})))),(0,e.Bu)("needleman-custom-same-extend",(()=>bt(void 0,void 0,void 0,(function*(){const e=yt.o[yt.U.NEEDLEMANN_WUNSCH]({scoringMatrix:t,alphabetIndexes:n,gapOpen:1,gapExtend:1});St(a,l,e,1)}))))}))));var Ct=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};function Tt(t,n,i,o){return Ct(this,void 0,void 0,(function*(){yield c.data.detectSemanticTypes(t);const s=yield(0,h.activityCliffs)(t,t.getCol(o),t.getCol("Activity"),50,i);(0,e.l_)(null!=s,!0);const r=Array.from(s.root.children).find((t=>{const e=t.className.split(" ");return["ui-btn","ui-btn-ok"].every((t=>e.includes(t)))}));(0,e.l_)(r.innerText.toLowerCase(),`${n} cliffs`)}))}var Mt=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};(0,e.W3)("activityCliffs",(()=>Mt(void 0,void 0,void 0,(function*(){let t,n,i,o,s=[],r=[];(0,e.bb)((()=>Mt(void 0,void 0,void 0,(function*(){s=[],r=[]})))),(0,e.X5)((()=>Mt(void 0,void 0,void 0,(function*(){})))),(0,e.Bu)("activityCliffsOpens",(()=>Mt(void 0,void 0,void 0,(function*(){n=yield X("tests/sample_MSA_data.csv"),r.push(n),t=c.shell.addTableView(n),s.push(t),yield Tt(n,57,"UMAP","MSA")}))),{skipReason:"GROK-12774"}),(0,e.Bu)("activityCliffsWithEmptyRows",(()=>Mt(void 0,void 0,void 0,(function*(){o=yield X("tests/sample_MSA_data_empty_vals.csv"),r.push(o),i=c.shell.addTableView(o),s.push(i),yield Tt(o,57,"UMAP","MSA")}))),{skipReason:"GROK-12774"})}))));var Et=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};function At(t,n,i){return Et(this,void 0,void 0,(function*(){const o=t.getCol(i),s=yield c.functions.call("Bio:detectMacromolecule",{col:o});s&&(o.semType=s);const r=yield(0,h.sequenceSpaceTopMenu)(t,t.col(i),n,"Levenshtein",!0);(0,e.l_)(null!=r,!0)}))}var Nt=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};(0,e.W3)("sequenceSpace",(()=>Nt(void 0,void 0,void 0,(function*(){let t,n,i,o;(0,e.Bu)("sequenceSpaceOpens",(()=>Nt(void 0,void 0,void 0,(function*(){t=yield X("tests/sample_MSA_data.csv"),n=c.shell.addTableView(t),yield At(t,"UMAP","MSA"),c.shell.closeTable(t),n.close()}))),{skipReason:"GROK-12775"}),(0,e.Bu)("sequenceSpaceWithEmptyRows",(()=>Nt(void 0,void 0,void 0,(function*(){i=yield X("tests/sample_MSA_data_empty_vals.csv"),o=c.shell.addTableView(i),yield At(i,"UMAP","MSA"),c.shell.closeTable(i),o.close()}))),{skipReason:"GROK-12775"})}))));var Pt=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};const xt=new t.Package;function _t(n,i,o){return Pt(this,void 0,void 0,(function*(){const s=yield(0,e.ci)({category:n,test:i,testContext:o});return t.DataFrame.fromObjects(s)}))}})(),bio_test=i})();
1
+ var bio_test;(()=>{var t={2012:(t,e,n)=>{"use strict";n.d(e,{f:()=>o});var i=n(9976);class o extends i.B{static get Lesk(){return void 0===this.lesk&&(this.lesk=this.makePalette([[["G","A","S","T"],"orange"],[["C","V","I","L","P","F","Y","M","W"],"all_green"],[["N","Q","H"],"magenta"],[["D","E"],"red"],[["K","R"],"all_blue"]],!1,o)),this.lesk}static get GrokGroups(){return void 0===this.grokGroups&&(this.grokGroups=this.makePalette([[["C","U"],"yellow"],[["G","P"],"red"],[["A","V","I","L","M","F","Y","W"],"all_green"],[["R","H","K"],"light_blue"],[["D","E"],"dark_blue"],[["S","T","N","Q"],"orange"]],!1,o)),this.grokGroups}static get RasMol(){return void 0===this.rasMol&&(this.rasMol=new o({D:"#E60A0A",E:"#E60A0A",C:"#E6E600",M:"#E6E600",K:"#145AFF",R:"#145AFF",S:"#FA9600",T:"#FA9600",F:"#3232AA",Y:"#3232AA",N:"#00DCDC",Q:"#00DCDC",G:"#EBEBEB",L:"#0F820F",V:"#0F820F",I:"#0F820F",A:"#C8C8C8",W:"#B45AB4",H:"#8282D2",P:"#DC9682",others:"#BEA06E"})),this.rasMol}get(t){const e=t in o.aaSynonyms?o.aaSynonyms[t]:t;return super.get(e)}}o.aaSynonyms={MeNle:"L",MeA:"A",MeG:"G",MeF:"F"};class s{static getPalette(t="grok"){switch(t){case"grok":return o.GrokGroups;case"lesk":return o.Lesk;default:throw new Error(`ChemPalette: scheme \`${t}\` does not exist`)}}static getInnerOuter(t){let e=0,n="",i="";for(const o of t)"("==o?e++:")"==o?e--:e?n+=o:i+=o;return isNaN(parseInt(n))?[i,n]:[i,""]}static getColorAAPivot(t="",e="grok"){var n,i,o;const s=this.getPalette(e);let[r,a]=this.getInnerOuter(t);if(r=r.length>6?`${r.slice(0,3)}...`:r,a=a.length>6?`${a.slice(0,3)}...`:a,1==t.length||"("==t[1]){const e=null===(n=t[0])||void 0===n?void 0:n.toUpperCase();return e in s?[s.get(e),e,a,1]:[this.undefinedColor,r,a,1]}if("d"==t[0]&&t[1]in s&&(2==t.length||"("==t[2])){const e=null===(i=t[1])||void 0===i?void 0:i.toUpperCase();return e in s?[s.get(e),e,a,2]:[this.undefinedColor,r,a,2]}if(t.substring(0,3)in this.AAFullNames&&(3==t.length||"("==t[3])){const e=this.AAFullNames[t.substring(0,3)];return e in s?[s.get(e),e,a,3]:[this.undefinedColor,r,a,3]}if((null===(o=t[0])||void 0===o?void 0:o.toLowerCase())==t[0]&&t.substring(1,3)in this.AAFullNames&&(4==t.length||"("==t[4])){const e=this.AAFullNames[t.substring(1,3)];return e in s?[s.get(e),e,a,4]:[this.undefinedColor,r,a,4]}return[this.undefinedColor,r,a,0]}}s.SemType="Aminoacids",s.SemTypeMultipleAlignment="AminoacidsMultipleAlignment",s.undefinedColor="rgb(100,100,100)",s.Names={G:"Glycine",L:"Leucine",Y:"Tyrosine",S:"Serine",E:"Glutamic acid",Q:"Glutamine",D:"Aspartic acid",N:"Asparagine",F:"Phenylalanine",A:"Alanine",K:"Lysine",R:"Arginine",H:"Histidine",C:"Cysteine",V:"Valine",P:"Proline",W:"Tryptophan",I:"Isoleucine",M:"Methionine",T:"Threonine"},s.AASmiles={G:"NCC(=O)O",L:"N[C@H](CC(C)C)C(=O)O",Y:"NC(CC1=CC=C(O)C=C1)C(=O)O",S:"NC(CO)C(=O)O",E:"N[C@@H](CCC(O)=O)C(=O)O",Q:"N[C@@H](CCC(N)=O)C(=O)O",D:"N[C@@H](CC(O)=O)C(=O)O",N:"N[C@@H](CC(N)=O)C(=O)O",F:"NC(CC1=CC=CC=C1)C(=O)O",A:"N[C@H](C)C(=O)O",K:"NC(CCCCN)C(=O)O",R:"N[C@H](CCCNC(=N)C)C(=O)O",H:"NC(CC1=CN=C[N]1)C(=O)O",C:"N[C@@H](CS)C(=O)O",V:"NC(C(C)C)C(=O)O",P:"N(CCC1)C1C(=O)O",W:"N[C@@H](Cc1c2ccccc2n([H])c1)C(=O)O",I:"N[C@H]([C@H](C)CC)C(=O)O",M:"NC(CCSC)C(=O)O",T:"NC(C(O)C)C(=O)O"},s.AASmilesTruncated={G:"*C*",L:"CC(C)C[C@H](*)*",Y:"C1=CC(=CC=C1CC(*)*)O",S:"OCC(*)C*",E:"*[C@@H](CCC(O)=O)*",Q:"*N[C@@H](CCC(N)=O)*",D:"*[C@@H](CC(O)=O)*",N:"*[C@@H](CC(N)=O)*",F:"C1=CC=C(C=C1)CC(*)*",A:"C[C@H](*)*",K:"C(CCN)CC(*)*",R:"*[C@H](CCCNC(=N)C)*",H:"C1=C(NC=N1)CC(*)*",C:"C([C@@H](*)*)S",V:"CC(C)C(*)*",P:"C1CCN(*)C1*",W:"*[C@@H](Cc1c2ccccc2n([H])c1)*",I:"CC[C@H](C)[C@H](*)*",M:"CSCCC(*)*",T:"CC(O)C(*)*"},s.AAFullNames={Ala:"A",Arg:"R",Asn:"N",Asp:"D",Cys:"C",Gln:"Q",Glu:"E",Gly:"G",His:"H",Ile:"I",Leu:"L",Lys:"K",Met:"M",Phe:"F",Pro:"P",Ser:"S",Thr:"T",Trp:"W",Tyr:"Y",Val:"V"}},7228:(t,e,n)=>{"use strict";n.d(e,{DC:()=>r,JN:()=>l,Xk:()=>a});var i=n(976),o=(n(4469),n(1047)),s=(n(585),function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))});const r=["symbol","name","molfile","rgroups","polymerType","monomerType"];function a(t){const e=[];for(let n=0;n<t.rowCount;n++){const i={};Object.keys(o.K4).forEach((e=>{if("symbol"===e){const s=t.get(o.K4[e],n);i[e]="."===s?t.get(o.At,n):s}else if("rgroups"===e){const s=t.get(o.K4[e],n).split("\n"),r=[];s.forEach((t=>{const e={},n=t.substring(t.lastIndexOf("]")+1),i=t.match(/\[R(\d+)\]/)[1];e.capGroupSmiles="H"===n?`[*:${i}][H]`:`O[*:${i}]`,e.alternateId="H"===n?`R${i}-H`:`R${i}-OH`,e.capGroupName="H"===n?"H":"OH",e.label=`R${i}`,r.push(e)})),i[e]=r}else o.K4[e]&&(i[e]=t.get(o.K4[e],n))})),e.push(i)}return e}function l(){return s(this,void 0,void 0,(function*(){const t=i.Func.find({package:"Bio",name:"getMonomerLibHelper"});if(0===t.length)throw new Error('Package "Bio" must be installer for MonomerLibraryHelper.');return(yield t[0].prepare().call()).getOutputParamValue()}))}},6103:(t,e,n)=>{"use strict";n.d(e,{i0:()=>D});var i=n(4469),o=n(976),s=n(1047),r=n(585),a=n(7767),l=n(7604),c=n(499),h=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};const u=8,d="M RGP",f="A ",m=14,p=7,g="\nDatagrok macromolecule handler\n\n",v=" 0 0 0 0 0 0 999 V3000\n",y="M V30 BEGIN CTAB\n",b="M V30 END CTAB\n",w="M V30 COUNTS ",S=" 0 0 0\n",C="M V30 BEGIN ATOM\n",T="M V30 END ATOM\n",M="M V30 BEGIN BOND\n",E="M V30 END BOND\n",A=" CFG=",N="M V30 ",P="M END",x=1e4,_="d",R="r",L="p",I="O",G="H";function D(t,e,n){return h(this,void 0,void 0,(function*(){if(0===o.Func.find({package:"Chem",name:"getRdKitModule"}).length)return{col:null,warnings:['Transformation to atomic level requires the package "Chem" installed.']};if(e.semType!==o.SEMTYPE.MACROMOLECULE)return{col:null,warnings:[`Only the ${o.SEMTYPE.MACROMOLECULE} columns can be converted to atomic level, the chosen column has semType '${e.semType}'`]};let u=e;new c.C(e).isHelm()&&(u=new a.L(e).convert("separator","."),u.name=e.name);const d=new c.C(u).alphabet;let f;if("PT"===d||"UN"===d)f="PEPTIDE";else{if("RNA"!==d&&"DNA"!==d)return{col:null,warnings:[`Unexpected column's '${u.name}' alphabet '${d}'.`]};f="RNA"}const m=function(t){const e=t.length,n=new Array(e),i=t.getTag(o.TAGS.UNITS),s=t.getTag("separator"),a=(0,r.vU)(i,s);for(let i=0;i<e;++i){const e=t.get(i);n[i]=e?a(e).filter((t=>""!==t)):[]}return n}(u),p=yield function(t,e,n,o){return h(this,void 0,void 0,(function*(){const r=function(t,e,n){const i=new Map;for(const o of t.getTypes())for(const r of t.getMonomerNamesByType(o)){const a=t.getMonomer(o,r);if(a.polymerType===e&&("RNA"===e&&("Branch"===a.monomerType||"DNA"===n&&a.symbol===_||"RNA"===n&&a.symbol===R||a.symbol===L)||"PEPTIDE"===e&&"Branch"!==a.monomerType)){const t={};s.rx.forEach((e=>{t[e]=a[e]})),i.set(a.symbol,t)}}return i}(e,n,o),a=new Map,c=yield i.functions.call("Chem:getRdKitModule"),h={value:null};if("RNA"===n){const t="RNA"===o?[R,L]:[_,L];for(const e of t)W(a,e,r,c,n,h)}for(let e=0;e<t.length;++e){const i=t[e];for(const t of i)if(""!==t)try{W(a,t,r,c,n,h)}catch(e){const n=(0,l.O)(e);throw console.error(`bio lib: getMonomersDictFromLib() sym='${t}', error:\n`+n),new Error(`Сan't get monomer '${t}' from library: ${n}`)}}return a}))}(m,n,f,d),g=u.length,v=new Array(g),y=new Array(0);for(let t=0;t<g;++t)try{const e=m[t];v[t]=Z(e,p,d,f,0)}catch(e){const n=`Cannot get molfile of row #${t}: ${e instanceof Error?e.message:e.toString()}.`;y.push(n)}if(y.length>.05*g)throw new Error("Too many errors getting molfiles.");const b=`molfile(${u.name})`,w=t.columns.getUnusedName(b),S=o.Column.fromStrings(w,v);return S.semType=o.SEMTYPE.MOLECULE,S.setTag(o.TAGS.UNITS,o.UNITS.Molecule.MOLBLOCK),{col:S,warnings:y}}))}function W(t,e,n,i,o,s){if(!t.has(e)){const r=function(t,e,n,i,o){if(e.has(t)){const s=e.get(t),r=function(t){const e=[];for(const n of t){let t=n.capGroupSmiles;t||(t=n.capGroupSMILES),t=t.replace(/(\[|\]|\*|:|\d)/g,""),e.push(t)}return e}(s.rgroups),a=function(t){const e=new Map;let n=t.indexOf(f,0),i=n;for(;-1!==n;){i=t.indexOf("\n",n);const o=parseInt(t.substring(n,i).replace(/^A\s+/,""));n=t.indexOf("R",i),i=t.indexOf("\n",n);const s=parseInt(t.substring(n,i).replace(/^R/,""));e.set(o,s),n=t.indexOf(f,i)}for(n=t.indexOf(d,0),i=t.indexOf("\n",n);-1!==n;){n+=u,i=t.indexOf("\n",n);const o=t.substring(n,i).replaceAll(/\s+/g," ").split(" ").map((t=>parseInt(t))).slice(1);for(let t=0;t<o.length;t+=2){if(e.has(o[t])&&e.get(o[t])!==o[t+1])throw new Error(`r-group index ${o[t]} has already been added with a different value`);e.set(o[t],o[t+1])}n=t.indexOf(d,i)}return e}(s.molfile),l=function(t,e){const n=e.get_mol(t),i=n.get_v3Kmolblock();return n.delete(),i}(function(t){let e=t.indexOf(f,0);-1===e&&(e=t.indexOf(d));const n=t.indexOf(P,e);return t.substring(0,e)+t.substring(n)}(s.molfile),n),c=function(t){let e=(t=t.replaceAll("\r","")).indexOf(w)+m,n=t.indexOf(" ",e+1);const i=parseInt(t.substring(e,n));return e=n+1,n=t.indexOf(" ",e+1),{atomCount:i,bondCount:parseInt(t.substring(e,n))}}(l),h=function(t,e){const n=new Array(e),i=new Float32Array(e),o=new Float32Array(e),s=new Array(e);let r=t.indexOf(C);r=t.indexOf("\n",r);let a=r;for(let l=0;l<e;l++){r=t.indexOf(N,r)+p,a=t.indexOf(" ",r),r=a+1,a=t.indexOf(" ",r),n[l]=t.substring(r,a);const e=new Array(2);for(let n=0;n<2;++n)r=a+1,a=t.indexOf(" ",r),e[n]=parseFloat(t.substring(r,a));i[l]=e[0],o[l]=e[1],r=a,a=t.indexOf("\n",r)+1,s[l]=t.slice(r,a),r=a}return{atomTypes:n,x:i,y:o,kwargs:s}}(l,c.atomCount),g=function(t,e){const n=new Uint32Array(e),i=new Array(e),o=new Map,s=new Map;let r=t.indexOf(M);r=t.indexOf("\n",r);let a=r;for(let l=0;l<e;++l){const e=new Array(3);r=t.indexOf(N,a)+p,a=t.indexOf(" ",r);for(let n=0;n<3;++n)r=a+1,a=Math.min(t.indexOf("\n",r),t.indexOf(" ",r)),e[n]=parseInt(t.slice(r,a));n[l]=e[0],i[l]=e.slice(1);const c=t.indexOf("\n",r);let h=t.slice(a,c),u=h.indexOf(A);if(-1!==u){u=h.indexOf("=",u)+1;let t=h.indexOf(" ",u);-1===t&&(t=h.length);const e=parseInt(h.slice(u,t));o.set(l,e);const n=A+e.toString();h=h.replace(n,"")}h||s.set(l,h)}return{bondTypes:n,atomPairs:i,bondConfiguration:o,kwargs:s}}(l,c.bondCount),v={atoms:h,bonds:g,meta:F(h,g,r,a)};return"PEPTIDE"===i?function(t){const e=t.meta.terminalNodes[0]-1,n=t.meta.rNodes[0]-1,i=t.atoms.x,o=t.atoms.y;$(t,-i[e],-o[e]);const s=B(i[n],o[n]);Y(t.atoms,-s),i[t.meta.rNodes[1]-1]<0&&function(t){K(t,!1)}(t);const r=function(t){const e=function(t){var e;const n=new Map;for(const i of t.bonds.atomPairs)for(let t=0;t<2;t++){const o=i[t],s=i[(t+1)%2];n.has(o)?null===(e=n.get(o))||void 0===e||e.push(s):n.set(o,new Array(1).fill(s))}return n}(t);let n=0,i=0;for(;0===n;){const o=e.get(t.meta.terminalNodes[1])[i];t.atoms.atomTypes[o-1]===I&&o!==t.meta.rNodes[1]&&(n=o),i++}return n}(t);!function(t,e){t.atoms.y[t.meta.rNodes[1]-1]<0&&t.atoms.y[e-1]<0&&(function(t){K(t,!0)}(t),Y(t.atoms,-function(t,e){return B(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 n=t.atoms.x;n[t.meta.rNodes[1]-1]>n[e-1]&&function(t,e,n){const i=e-1,o=n-1,s=t.atoms.x,r=t.atoms.y,a=s[i],l=r[i];s[i]=s[o],r[i]=r[o],s[o]=a,r[o]=l}(t,e,t.meta.rNodes[1])}(t,r)}(v):t===R||t===_?function(t,e){const n=t.atoms.x,i=t.atoms.y;let o=t.meta.terminalNodes[0]-1;const s=t.meta.rNodes[1]-1;$(t,-n[o],-i[o]);const r=B(n[s],i[s]);Y(t.atoms,3*Math.PI/2-r),e.value=function(t){const e=t.atoms.x,n=t.atoms.y,i=t.meta.rNodes[2]-1,o=t.meta.terminalNodes[2]-1,s=e[i]-e[o],r=n[i]-n[o];return Math.atan(r/s)+Math.PI/2}(t),o=t.meta.terminalNodes[0]-1,$(t,-n[o],-i[o])}(v,o):t===L?function(t){const e=t.meta.terminalNodes[0]-1,n=t.meta.rNodes[0]-1,i=t.atoms.x,o=t.atoms.y;$(t,-i[e],-o[e]);const s=B(i[n],o[n]);Y(t.atoms,Math.PI/2-s)}(v):function(t,e){const n=t.atoms.x,i=t.atoms.y,o=t.meta.terminalNodes[0]-1,s=t.meta.rNodes[0]-1;$(t,-n[o],-i[o]);const r=B(n[s],i[s]),a=e.value;if(!a)throw new Error("The value of sugarBranchToOYAngle is null");Y(t.atoms,Math.PI-r+a);const l=function(t,e){return et(Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)))}({x:n[t.meta.rNodes[0]-1],y:i[t.meta.rNodes[0]-1]},{x:n[t.meta.terminalNodes[0]-1],y:i[t.meta.terminalNodes[0]-1]});if(1!=l)for(let t=0;t<n.length;++t)n[t]=et(n[t]/l),i[t]=et(i[t]/l)}(v,o),function(t,e,n){"PEPTIDE"===t?(k(e,t),V(e,e.meta.rNodes[1])):n===R||n===_?(V(e,e.meta.rNodes[1]),e.meta.rNodes[1]=e.meta.terminalNodes[1],H(e.bonds,e.meta),k(e,t),V(e,e.meta.rNodes[1]),V(e,e.meta.rNodes[0]),V(e,e.meta.rNodes[2])):n===L&&(e.meta.terminalNodes[0]=e.meta.rNodes[0],$(e,-e.atoms.x[e.meta.terminalNodes[0]-1],-e.atoms.y[e.meta.terminalNodes[0]-1]),k(e,t),V(e,e.meta.rNodes[1]))}(i,v,t),function(t){let e=0;for(;e<t.atoms.atomTypes.length;)t.atoms.atomTypes[e]===G&&(V(t,e+1),--e),++e}(v),v}return null}(e,n,i,o,s);if(!r)throw new Error(`Monomer with symbol '${e}' is absent the monomer library`);t.set(e,r)}}function F(t,e,n,i){const o={backboneShift:null,branchShift:null,terminalNodes:[],rNodes:[]};return void 0!==n&&void 0!==i?(function(t,e,n){for(const[i,o]of n)t.atomTypes[i-1]=e[o-1]}(t,n,i),function(t,e){e.rNodes=Array.from(t.keys());for(let n=0;n<e.rNodes.length;n++)for(const i of[1,2])if(t.get(e.rNodes[n])===i){const t=e.rNodes[i-1];e.rNodes[i-1]=e.rNodes[n],e.rNodes[n]=t}}(i,o)):o.rNodes=[0,t.x.length],H(e,o),o}function H(t,e){const n=e.rNodes;e.terminalNodes=new Array(n.length).fill(0);const i=e.terminalNodes,o=t.atomPairs;let s=0,r=0;for(;s<o.length&&r<i.length;){for(let t=0;t<i.length;++t)for(let e=0;e<2;++e)o[s][e]===n[t]&&(i[t]=o[s][(e+1)%2],n.length,++r);++s}}function k(t,e){t.meta.rNodes.length>1&&(t.meta.backboneShift=O(t,t.meta.rNodes[1]-1,t.meta.terminalNodes[0]-1)),"RNA"===e&&t.meta.rNodes.length>2&&(t.meta.branchShift=O(t,t.meta.rNodes[2]-1,t.meta.terminalNodes[0]-1))}function O(t,e,n){return[et(t.atoms.x[e]-t.atoms.x[n]),et(t.atoms.y[e]-t.atoms.y[n])]}function V(t,e){if(void 0!==e){const n=e-1,i=t.atoms,o=t.bonds,s=t.meta;i.atomTypes.splice(n,1),i.x=U(Float32Array,i.x,n,1),i.y=U(Float32Array,i.y,n,1),i.kwargs.splice(n,1);for(let t=0;t<s.terminalNodes.length;++t)s.terminalNodes[t]>e?--s.terminalNodes[t]:s.terminalNodes[t]===e&&(s.terminalNodes[t]=-1);for(let t=0;t<s.rNodes.length;++t)s.rNodes[t]>e?--s.rNodes[t]:s.rNodes[t]===e&&(s.rNodes[t]=-1);let r=0;for(;r<o.atomPairs.length;){const t=o.atomPairs[r][0],n=o.atomPairs[r][1];t===e||n===e?(o.atomPairs.splice(r,1),o.bondTypes=U(Uint32Array,o.bondTypes,r,1),o.bondConfiguration.has(r)&&o.bondConfiguration.delete(r),o.kwargs.has(r)&&o.kwargs.delete(r),--r):(o.atomPairs[r][0]=t>e?t-1:t,o.atomPairs[r][1]=n>e?n-1:n),++r}let a=Array.from(o.bondConfiguration.keys());a.forEach((t=>{if(o.bondConfiguration.has(t)&&t>n){const e=o.bondConfiguration.get(t);o.bondConfiguration.delete(t),o.bondConfiguration.set(t-1,e)}})),a=Array.from(o.kwargs.keys()),a.forEach((t=>{if(o.kwargs.has(t)&&t>n){const e=o.kwargs.get(t);o.kwargs.delete(t),o.kwargs.set(t-1,e)}}))}}function U(t,e,n,i){const o=new t(e.length-i);let s=0,r=0;for(;s<e.length;)s===n&&(s+=i),o[r]=e[s],++r,++s;return o}function B(t,e){let n;if(0===t)n=e>0?0:Math.PI;else if(0===e)n=t>0?-Math.PI/2:Math.PI/2;else{const i=e/t,o=Math.atan(i);n=t<0?Math.PI/2+o:-Math.PI/2+o}return n}function Y(t,e){if(0!==e){const n=t.x,i=t.y,o=Math.cos(e),s=Math.sin(e);for(let t=0;t<n.length;++t){const e=n[t];n[t]=et(e*o-i[t]*s),i[t]=et(e*s+i[t]*o)}}}function K(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 n=t.bonds.bondConfiguration;for(const[t,e]of n){const i=1===e?3:1;n.set(t,i)}}function $(t,e,n){const i=t.atoms.x,o=t.atoms.y;for(let t=0;t<i.length;++t)i[t]=et(i[t]+e),void 0!==n&&(o[t]=et(o[t]+n))}function Z(t,e,n,i,o){if(0===t.length)return"";const s=0===o?tt:nt,{atomCount:r,bondCount:a}=s(t,e,n,i,o),l=new Array(r),c=new Array(a);let h,u=null,d=null;0===o?"PEPTIDE"===i?h=q:(h=j,u="DNA"===n?e.get(_):e.get(R),d=e.get(L)):h=z;const f={i:0,nodeShift:0,bondShift:0,backbonePositionShift:new Array(2).fill(0),branchPositionShift:new Array(2).fill(0),backboneAttachNode:0,branchAttachNode:0,flipFactor:1},m={sugar:u,phosphate:d,seqLength:t.length,atomCount:r,bondCount:a};for(f.i=0;f.i<m.seqLength;++f.i)h(e.get(t[f.i]),l,c,f,m);!function(t,e,n,i,o){if(0===o){const o=n.nodeShift+1;t[i.atomCount]=N+o+" "+I+" "+et(n.backbonePositionShift[0])+" "+n.flipFactor*et(n.backbonePositionShift[1])+" 0.000000 0\n";const s=n.backboneAttachNode,r=o;e[i.bondCount]=N+n.bondShift+" 1 "+s+" "+r+"\n"}}(l,c,f,m,o);let p="";return p+=g,p+=v,p+=y,p+=w+r+" "+a+S,p+=C,p+=l.join(""),p+=T,p+=M,p+=c.join(""),p+=E,p+=b,p+=P,p}function q(t,e,n,i){i.flipFactor=Math.pow(-1,i.i%2),X(t,e,n,i)}function z(t,e,n,i){Q(t,e,n,i)}function X(t,e,n,i){!function(t,e,n){for(let i=0;i<t.atoms.atomTypes.length;++i){const o=n.nodeShift+i+1;e[n.nodeShift+i]=N+o+" "+t.atoms.atomTypes[i]+" "+et(n.backbonePositionShift[0]+t.atoms.x[i])+" "+et(n.backbonePositionShift[1]+n.flipFactor*t.atoms.y[i])+" "+t.atoms.kwargs[i]}}(t,e,i),J(t,n,i),function(t,e,n){if(0!==n.backboneAttachNode){const i=n.bondShift,o=n.backboneAttachNode,s=t.meta.terminalNodes[0]+n.nodeShift;e[n.bondShift-1]=N+i+" 1 "+o+" "+s+"\n"}}(t,n,i),null!==t.meta.branchShift&&t.meta.terminalNodes.length>2&&function(t,e){e.branchAttachNode=e.nodeShift+t.meta.terminalNodes[2];for(let n=0;n<2;++n)e.branchPositionShift[n]=e.backbonePositionShift[n]+t.meta.branchShift[n]}(t,i),function(t,e){e.backboneAttachNode=e.nodeShift+t.meta.terminalNodes[1],e.bondShift+=t.bonds.atomPairs.length+1,e.nodeShift+=t.atoms.atomTypes.length,e.backbonePositionShift[0]+=t.meta.backboneShift[0],e.backbonePositionShift[1]+=e.flipFactor*t.meta.backboneShift[1]}(t,i)}function j(t,e,n,i,o){if(0===i.i)X(o.sugar,e,n,i);else for(const t of[o.phosphate,o.sugar])X(t,e,n,i);Q(t,e,n,i)}function Q(t,e,n,i){!function(t,e,n){for(let i=0;i<t.atoms.atomTypes.length;++i){const o=n.nodeShift+i+1;e[n.nodeShift+i]=N+o+" "+t.atoms.atomTypes[i]+" "+et(n.branchPositionShift[0]+t.atoms.x[i])+" "+et(n.branchPositionShift[1]+n.flipFactor*t.atoms.y[i])+" "+t.atoms.kwargs[i]}}(t,e,i),J(t,n,i),function(t,e,n){const i=n.bondShift,o=n.branchAttachNode,s=t.meta.terminalNodes[0]+n.nodeShift;e[i-1]=N+i+" 1 "+o+" "+s+"\n"}(t,n,i);const o=i.bondShift,s=i.branchAttachNode,r=t.meta.terminalNodes[0]+i.nodeShift;n[o-1]=N+o+" 1 "+s+" "+r+"\n",i.bondShift+=t.bonds.atomPairs.length+1,i.nodeShift+=t.atoms.atomTypes.length}function J(t,e,n){for(let i=0;i<t.bonds.atomPairs.length;++i){const o=n.bondShift+i+1,s=t.bonds.atomPairs[i][0]+n.nodeShift,r=t.bonds.atomPairs[i][1]+n.nodeShift;let a="";if(t.bonds.bondConfiguration.has(i)){let e=t.bonds.bondConfiguration.get(i);n.flipFactor<0&&(e=1===e?3:1),a=" CFG="+e}const l=t.bonds.kwargs.has(i)?" "+t.bonds.kwargs.get(i):"";e[n.bondShift+i]=N+o+" "+t.bonds.bondTypes[i]+" "+s+" "+r+a+l+"\n"}}function tt(t,e,n,i,o){let s=0,r=0;for(const n of t){if(""===n)continue;const t=e.get(n);s+=t.atoms.x.length,r+=t.bonds.bondTypes.length}if(0===o)if("PEPTIDE"===i)s+=1,r+=t.length;else{const i="DNA"===n?e.get(_):e.get(R),o=e.get(L);s+=(t.length-1)*o.atoms.x.length,s+=t.length*i.atoms.x.length,s+=1,r+=(t.length-1)*o.bonds.bondTypes.length,r+=t.length*i.bonds.bondTypes.length,r-=1,r+=3*t.length}return{atomCount:s,bondCount:r}}function et(t){return Math.round(x*t)/x}function nt(t,e,n,i){let o=0,s=0;for(const n of t){const t=e.get(n);o+=t.atoms.x.length,s+=t.bonds.bondTypes.length}if("PEPTIDE"===i)o+=1,s+=t.length;else{const i="DNA"===n?e.get(_):e.get(R),r=e.get(L);o+=t.length*(r.atoms.x.length+i.atoms.x.length),o+=1,s+=t.length*(r.bonds.bondTypes.length+i.bonds.bondTypes.length),s+=3*t.length}return{atomCount:o,bondCount:s}}},6137:(t,e,n)=>{"use strict";n.d(e,{J:()=>o,V:()=>s});var i=n(9976);class o extends i.B{static get Chromatogram(){return void 0===this.chromatogram&&(this.chromatogram=new o({A:"green",C:"blue",G:"black",T:"red",U:"red",others:"gray"})),this.chromatogram}}class s{}s.SemType="Nucleotides",s.SemTypeMultipleAlignment="NucleotidesMultipleAlignment",s.Names={A:"Adenine",C:"Cytosine",G:"Guanine",T:"Thymine",U:"Uracil"}},9976:(t,e,n)=>{"use strict";n.d(e,{B:()=>i});class i{static makePalette(t,e=!1,n=i){const o={};return t.forEach((t=>{const n=t[0],i=t[1];n.forEach(((t,n)=>{o[t]=this.colourPalette[i][e?0:n]}))})),new n(o)}constructor(t){this._palette=t}get(t){return this._palette[t]}}i.undefinedColor="rgb(100,100,100)",i.colourPalette={orange:["rgb(255,187,120)","rgb(245,167,100)","rgb(235,137,70)","rgb(205, 111, 71)"],all_green:["rgb(44,160,44)","rgb(74,160,74)","rgb(23,103,57)","rgb(30,110,96)","rgb(60,131,95)","rgb(24,110,79)","rgb(152,223,138)","rgb(182, 223, 138)","rgb(152, 193, 138)"],all_blue:["rgb(31,119,180)","rgb(23,190,207)","rgb(122, 102, 189)","rgb(158,218,229)","rgb(141, 124, 217)","rgb(31, 120, 150)"],magenta:["rgb(162,106,192)","rgb(197,165,224)","rgb(208,113,218)"],red:["rgb(214,39,40)","rgb(255,152,150)"],st_blue:["rgb(23,190,207)","rgb(158,218,229)","rgb(31,119,180)"],dark_blue:["rgb(31,119,180)","rgb(31, 120, 150)"],light_blue:["rgb(23,190,207)","rgb(158,218,229)","rgb(108, 218, 229)","rgb(23,190,227)"],lilac_blue:["rgb(124,102,211)","rgb(149,134,217)","rgb(97, 81, 150)"],dark_green:["rgb(23,103,57)","rgb(30,110,96)","rgb(60,131,95)","rgb(24,110,79)"],green:["rgb(44,160,44)","rgb(74,160,74)"],light_green:["rgb(152,223,138)","rgb(182, 223, 138)","rgb(152, 193, 138)"],st_green:["rgb(44,160,44)","rgb(152,223,138)","rgb(39, 174, 96)","rgb(74,160,74)"],pink:["rgb(247,182,210)"],brown:["rgb(140,86,75)","rgb(102, 62, 54)"],gray:["rgb(127,127,127)","rgb(199,199,199)","rgb(196,156,148)","rgb(222, 222, 180)"],yellow:["rgb(188,189,34)"],white:["rgb(230,230,230)"]}},7331:(t,e,n)=>{"use strict";n.d(e,{UE:()=>c,kQ:()=>r});var i=n(976),o=n(9976);class s{static hashCode(t){let e=0;if(0===t.length)return e;for(let n=0;n<t.length;n++)e=(e<<5)-e+t.charCodeAt(n),e|=0;return e}}class r{}class a extends r{get(t){return"#666666"}}class l extends r{static buildPalette(){return[].concat(...Object.values(o.B.colourPalette))}get(t){const e=s.hashCode(t)%l.palette.length;return function(t){if(null==t)return"rgb(100,100,100)";const e=i.Color.fromHtml(t),n=i.Color.g(e),o=i.Color.r(e),s=i.Color.b(e),r=Math.sqrt(Math.pow(0-o,2)+Math.pow(0-n,2)+Math.pow(0-s,2));return r>210?`rgb(${o/r*210},${n/r*210},${s/r*210})`:i.Color.toRgb(e)}(l.palette[e])}}l.palette=l.buildPalette();class c extends o.B{static get Gray(){return void 0===this.gray&&(this.gray=new a),this.gray}static get Color(){return void 0===this.color&&(this.color=new l),this.color}}},1047:(t,e,n)=>{"use strict";n.d(e,{At:()=>o,K4:()=>s,rx:()=>i});const i=["symbol","molfile","rgroups","name"],o="MonomerName",s={monomerType:null,smiles:null,name:"MonomerName",author:null,molfile:"molecule",naturalAnalog:"MonomerNaturalAnalogCode",rgroups:"MonomerCaps",createDate:null,id:null,polymerType:"MonomerType",symbol:"MonomerCode"}},5226:(t,e,n)=>{"use strict";n.d(e,{i:()=>s});var i=n(976),o=n(499);class s{get descriptionsArray(){return this._descriptionsArray}get sequencesArray(){return this._sequencesArray}parseMacromolecule(t,e){return this._fileContent.slice(t,e).split(/\s/).join("")}parseColumns(){const t=/^>(.*)$/gm;let e,n=0;for(;e=t.exec(this._fileContent);){const i=this._fileContent.substring(e.index+1,t.lastIndex);this._descriptionsArray.push(i),0!==n&&this._sequencesArray.push(this.parseMacromolecule(n,e.index)),n=t.lastIndex+1}this._sequencesArray.push(this.parseMacromolecule(n,-1))}importFasta(){const t=i.Column.fromStrings("description",this.descriptionsArray),e=i.Column.fromStrings("sequence",this.sequencesArray);return e.semType=i.SEMTYPE.MACROMOLECULE,e.setTag(i.TAGS.UNITS,"fasta"),o.C.setUnitsToFastaColumn(e),[i.DataFrame.fromColumns([t,e])]}constructor(t){this._descriptionsArray=[],this._sequencesArray=[],this._fileContent=t,this.parseColumns()}}},1821:(t,e,n)=>{"use strict";n.d(e,{BM:()=>o,XS:()=>r,se:()=>s});var i=n(6286);const o=/\[(\w+)\]|(\w)|(-)/g,s=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"])}}},r=[new i.L("PT",s.fasta.peptide,.5),new i.L("DNA",s.fasta.dna,.55),new i.L("RNA",s.fasta.rna,.55)]},8447:(t,e,n)=>{"use strict";n.d(e,{GU:()=>i.GU,KX:()=>i.KX,dQ:()=>i.dQ,fy:()=>i.fy,gM:()=>i.gM,gP:()=>i.gP,kB:()=>i.kB,py:()=>i.py,up:()=>i.up,vU:()=>i.vU});var i=n(585)},6286:(t,e,n)=>{"use strict";n.d(e,{L:()=>i,d:()=>o});class i{constructor(t,e,n){this.name=t,this.alphabet=e,this.cutoff=n}}class o extends i{constructor(t,e,n){super(t.name,t.alphabet,t.cutoff),this.freq=e,this.similarity=n}}},585:(t,e,n)=>{"use strict";n.d(e,{Ar:()=>g,GU:()=>T,KX:()=>E,Mj:()=>S,dQ:()=>N,fy:()=>m,gM:()=>M,gP:()=>b,kB:()=>p,py:()=>P,up:()=>x,vU:()=>w,w4:()=>A});var i=n(976),o=n(6414),s=n.n(o),r=n(6286),a=n(1821),l=n(499),c=n(3659),h=n(850),u=n(2012),d=n(6137),f=n(7331);function m(t,e,n){const i={};let o=!0,s=null;for(const r of t.categories){const t=n(r);if(null==s?s=t.length:t.length!==s&&(o=!1),t.length>=e)for(const e of t)e in i||(i[e]=0),i[e]+=1}return{freq:i,sameLength:o}}function p(t){return s()(t.toString().matchAll(a.BM)).map((t=>{const e=t[0];return e.length>1?t[1]:e})).toArray()}function g(t,e=undefined){return n=>n.split(t,e)}const v=/(PEPTIDE1|DNA1|RNA1)\{([^}]+)}/g,y=/\[([^\[\]]+)]/g;function b(t){v.lastIndex=0;const e=v.exec(t.toString()),n=e?e[2]:null;return(n?n.split("."):[]).map((t=>{y.lastIndex=0;const e=y.exec(t);return e&&e.length>=2?e[1]:t}))}function w(t,e,n=undefined){if(t.toLowerCase().startsWith("fasta"))return p;if(t.toLowerCase().startsWith("separator"))return g(e,n);if(t.toLowerCase().startsWith("helm"))return b;throw new Error(`Unexpected units ${t} .`)}function S(t){if(t.semType!==i.SEMTYPE.MACROMOLECULE)throw new Error(`Get splitter for semType "${i.SEMTYPE.MACROMOLECULE}" only.`);return w(t.getTag(i.TAGS.UNITS),t.getTag("separator"))}const C=/(\w+)/g;function T(t,e){var n,i;const o=t.match(C),s=t.length>e||(null!==(n=null==o?void 0:o.length)&&void 0!==n?n:0)>1,r=null!==(i=null==o?void 0:o[0])&&void 0!==i?i:" ";return s?r.substring(0,e)+"…":r}function 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 E(t,e,n="-"){const i=new Set([...new Set(Object.keys(t)),...e]);i.delete(n);const o=[],s=[];for(const n of i)o.push(n in t?t[n]:0),s.push(e.has(n)?1:0);const r=new c.OW(o),a=new c.OW(s);return(0,h.MA)(r,a)/((0,h.$G)(r)*(0,h.$G)(a))}function A(t,e,n="-"){const i=e.map((e=>{const i=E(t,e.alphabet,n);return new r.d(e,t,i)}));let o;const s=Math.max(...i.map((t=>t.similarity>t.cutoff?t.similarity:-1)));return o=s>0?i.find((t=>t.similarity===s)).name:"UN",o}function N(t,e=5){let n;return n=t.semType==i.SEMTYPE.MACROMOLECULE?new l.C(t).alphabet:A(m(t,e,p).freq,a.XS),P(n)}function P(t){switch(t){case"PT":return u.f.GrokGroups;case"DNA":case"RNA":return d.J.Chromatogram;default:return f.UE.Color}}function x(t){var e;const n=t.columns.bySemTypeAll(i.SEMTYPE.MACROMOLECULE);let o=null!==(e=n.find((t=>{const e=t.getTag(i.TAGS.UNITS);return!!e&&-1!==e.indexOf("MSA")})))&&void 0!==e?e:null;return!o&&n.length>0&&(o=n[0]),o}},7767:(t,e,n)=>{"use strict";n.d(e,{L:()=>r});var i=n(976),o=n(499),s=n(585);class r extends o.C{get splitter(){return null===this._splitter&&(this._splitter=(0,s.Mj)(this.column)),this._splitter}toFasta(t){return"fasta"===t}toSeparator(t){return"separator"===t}toHelm(t){return"helm"===t}convertFastaToSeparator(t,e=null){null===e&&(e=this.defaultGapSymbol);const n=this.getNewColumn("separator",t);return n.init((n=>{const i=this.column.get(n),s=this.splitter(i);for(let t=0;t<s.length;t++)s[t]===e&&(s[t]=o.C._defaultGapSymbolsDict.SEPARATOR);return s.join(t)})),n.setTag(i.TAGS.UNITS,"separator"),n}getHelmWrappers(){const t=this.isDna()?"DNA1{":this.isRna()||this.isHelmCompatible()?"RNA1{":this.isPeptide()?"PEPTIDE1{":"Unknown";if("Unknown"===t)throw new Error("Neither peptide, nor nucleotide");return[t,this.isDna()?"D(":this.isRna()?"R(":"",this.isDna()||this.isRna()?")P":"","}$$$$"]}convertToHelmHelper(t,e,n,i,s,r){return`${n}${this.splitter(t).map((t=>t===e?o.C._defaultGapSymbolsDict.HELM:`${i}${t}${s}`)).join(".")}${r}`}convertStringToHelm(t,e=null){null===e&&(e=this.defaultGapSymbol);const[n,i,o,s]=this.getHelmWrappers();return this.convertToHelmHelper(t,e,n,i,o,s)}convertToHelm(t=null){null===t&&(t=this.defaultGapSymbol);const[e,n,o,s]=this.getHelmWrappers(),r=this.getNewColumn("helm");return r.init((i=>{const r=this.column.get(i);return this.convertToHelmHelper(r,t,e,n,o,s)})),r.setTag(i.TAGS.UNITS,"helm"),r}convertSeparatorToFasta(t=null){null===t&&(t=o.C._defaultGapSymbolsDict.FASTA);const e=this.getNewColumn("fasta");return e.init((e=>{const n=this.column.get(e),i=this.splitter(n),o=[];for(let e=0;e<i.length;e++){const n=i[e];if(0===n.length)o.push(t);else if(n.length>1){const t="["+n+"]";o.push(t)}else o.push(n)}return o.join("")})),e.setTag(i.TAGS.UNITS,"fasta"),e}convertHelmToFastaSeparator(t,e,n,i){i||(i=this.toFasta(e)?o.C._defaultGapSymbolsDict.FASTA:o.C._defaultGapSymbolsDict.SEPARATOR),n||(n=this.toFasta(e)?"":this.separator);const s=/(R\(|D\(|\)|P)/g,r=t.startsWith("DNA")||t.startsWith("RNA"),a=this.splitter(t),l=[];for(let t=0;t<a.length;t++){let n=a[t];if(r&&(n=n.replace(s,"")),n===o.C._defaultGapSymbolsDict.HELM)l.push(i);else if(this.toFasta(e)&&n.length>1){const t="["+n+"]";l.push(t)}else l.push(n)}return l.join(n)}convertHelm(t,e,n){const i=this.getNewColumn(t,e);i.init((i=>{const o=this.column.get(i);return this.convertHelmToFastaSeparator(o,t,e,n)}));const o=(0,s.Mj)(i),r=(0,s.fy)(i,5,o).sameLength?"SEQ.MSA":"SEQ";return i.setTag("aligned",r),i}convertHelmToSeparator(){return this.getNewColumn("separator")}convert(t,e=null){if(this.notation===t)throw new Error("tgt notation is invalid");if(this.toSeparator(t)&&null===e)throw new Error("tgt separator is not specified");if(this.isFasta()&&this.toSeparator(t)&&null!==e)return this.convertFastaToSeparator(e);if((this.isFasta()||this.isSeparator())&&this.toHelm(t))return this.convertToHelm();if(this.isSeparator()&&this.toFasta(t))return this.convertSeparatorToFasta();if(this.isHelm()&&this.toFasta(t))return this.convertHelm(t);if(this.isHelm()&&this.toSeparator(t))return this.convertHelm(t,e);throw new Error(`Not supported conversion from source notation '${this.notation}' to target notation '${t}'.`)}constructor(t){super(t),this._splitter=null}}},499:(t,e,n)=>{"use strict";n.d(e,{C:()=>l});var i=n(976),o=n(1821),s=n(585),r=n(489),a=n(7228);class l{static setUnitsToFastaColumn(t){if(t.semType!==i.SEMTYPE.MACROMOLECULE||"fasta"!==t.getTag(i.TAGS.UNITS))throw new Error(`The column of notation 'fasta' must be '${i.SEMTYPE.MACROMOLECULE}'.`);t.setTag(i.TAGS.UNITS,"fasta"),l.setTags(t,s.kB)}static setUnitsToSeparatorColumn(t,e){if(t.semType!==i.SEMTYPE.MACROMOLECULE||"separator"!==t.getTag(i.TAGS.UNITS))throw new Error(`The column of notation 'separator' must be '${i.SEMTYPE.MACROMOLECULE}'.`);if(!e)throw new Error("The column of notation 'separator' must have the separator tag.");t.setTag(i.TAGS.UNITS,"separator"),t.setTag("separator",e),l.setTags(t,(0,s.Ar)(e))}static setUnitsToHelmColumn(t){if(t.semType!==i.SEMTYPE.MACROMOLECULE)throw new Error(`The column of notation 'helm' must be '${i.SEMTYPE.MACROMOLECULE}'`);t.setTag(i.TAGS.UNITS,"helm"),l.setTags(t,s.gP)}static setTags(t,e){const n=t.getTag(i.TAGS.UNITS),r=(0,s.fy)(t,5,e);if(Object.keys(r.freq).some((t=>t.length>1)),["fasta","separator"].includes(n)){if(0===Object.keys(r.freq).length)throw new Error("Alphabet is empty");const e=r.sameLength?"SEQ.MSA":"SEQ";t.setTag("aligned",e);const n=(0,s.w4)(r.freq,o.XS);if(t.setTag("alphabet",n),"UN"===n){const e=Object.keys(r.freq).length,n=Object.keys(r.freq).some((t=>t.length>1));t.setTag(".alphabetSize",e.toString()),t.setTag(".alphabetIsMultichar",n?"true":"false")}}}get units(){return this._units}get column(){return this._column}get notation(){return this._notation}get defaultGapSymbol(){return this._defaultGapSymbol}get separator(){var t;const e=null!==(t=this.column.getTag("separator"))&&void 0!==t?t:void 0;if("separator"===this.notation&&void 0===e)throw new Error(`Separator is mandatory for column '${this.column.name}' of notation '${this.notation}'.`);return e}get aligned(){const t=this.column.getTag("aligned");if(!t&&(this.isFasta()||this.isSeparator()))throw new Error("Tag aligned not set");return t}get alphabet(){const t=this.column.getTag("alphabet");if(!t&&(this.isFasta()||this.isSeparator()))throw new Error("Tag alphabet not set");return t}get helmCompatible(){return this.column.getTag(".isHelmCompatible")}getAlphabetSize(){if("helm"==this.notation||"UN"==this.alphabet){const t=this.column.getTag(".alphabetSize");let e;if(t)e=parseInt(t);else{const t=(0,s.Mj)(this.column),n=(0,s.fy)(this.column,1,t);e=Object.keys(n.freq).length}return e}switch(this.alphabet){case"PT":return 20;case"DNA":case"RNA":return 4;case"NT":return console.warn("Unexpected alphabet 'NT'."),4;default:throw new Error(`Unexpected alphabet '${this.alphabet}'.`)}}getAlphabetIsMultichar(){return"helm"===this.notation||"UN"===this.alphabet&&"true"===this.column.getTag(".alphabetIsMultichar")}isFasta(){return"fasta"===this.notation}isSeparator(){return"separator"===this.notation}isHelm(){return"helm"===this.notation}isRna(){return"RNA"===this.alphabet}isDna(){return"DNA"===this.alphabet}isPeptide(){return"PT"===this.alphabet}isMsa(){return!!this.aligned&&this.aligned.toUpperCase().includes("MSA")}isHelmCompatible(){return"true"===this.helmCompatible}getNotation(){if(this.units.toLowerCase().startsWith("fasta"))return"fasta";if(this.units.toLowerCase().startsWith("separator"))return"separator";if(this.units.toLowerCase().startsWith("helm"))return"helm";throw new Error(`Column '${this.column.name}' has unexpected notation '${this.units}'.`)}getNewColumn(t,e){const n=this.column,o=n.length,s=t.toLowerCase()+"("+n.name+")",r=n.dataFrame.columns.getUnusedName(s),a=i.Column.fromList("string",r,new Array(o).fill(""));if(a.semType=i.SEMTYPE.MACROMOLECULE,a.setTag(i.TAGS.UNITS,t),"separator"===t){if(!e)throw new Error("Notation 'separator' requires separator value.");a.setTag("separator",e)}a.setTag(i.TAGS.CELL_RENDERER,"Macromolecule");const l=n.getTag("aligned");l&&a.setTag("aligned",l);const c=n.getTag("alphabet");c&&a.setTag("alphabet",c);let h=n.getTag(".alphabetSize");h&&a.setTag(".alphabetSize",h);const u=n.getTag(".alphabetIsMultichar");return void 0!==u&&a.setTag(".alphabetIsMultichar",u),"helm"==t&&(h=this.getAlphabetSize().toString(),a.setTag(".alphabetSize",h)),a}static getNewColumn(t){const e=new l(t),n=e.notation;return e.getNewColumn(n)}static unitsStringIsValid(t){return t=t.toLowerCase(),["fasta","separator","helm"].some((e=>t.startsWith(e.toLowerCase())))}static getNewColumnFromParams(t,e,n){if(!l.unitsStringIsValid(n))throw new Error("Invalid format of 'units' parameter");const o=i.Column.fromList("string",e,new Array(t).fill(""));return o.semType=i.SEMTYPE.MACROMOLECULE,o.setTag(i.TAGS.UNITS,n),o}getDistanceFunctionName(){if(!this.isFasta())throw new Error("Only FASTA notation is supported");if(this.isMsa())return r.U.HAMMING;switch(this.alphabet){case"DNA":case"RNA":default:return r.U.LEVENSHTEIN;case"PT":return r.U.NEEDLEMANN_WUNSCH}}getDistanceFunction(){return r.o[this.getDistanceFunctionName()]()}checkHelmCompatibility(){return t=this,e=void 0,i=function*(){if(this.column.tags.has(".isHelmCompatible"))return"true"===this.column.getTag(".isHelmCompatible");const t=(yield(0,a.JN)()).getBioLib().getMonomerNamesByType("PEPTIDE".toString()),e=new Set(t),n=(0,s.Ar)(this.separator);for(const t of this.column.categories){const i=n(t);for(const t of i)if(!e.has(t))return this.column.setTag(".isHelmCompatible","false"),!1}return this.column.setTag(".isHelmCompatible","true"),!0},new((n=void 0)||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}));var t,e,n,i}constructor(t){this._column=t;const e=this._column.getTag(i.TAGS.UNITS);if(null==e)throw new Error("Units are not specified in column");if(this._units=e,this._notation=this.getNotation(),this._defaultGapSymbol=this.isFasta()?l._defaultGapSymbolsDict.FASTA:this.isHelm()?l._defaultGapSymbolsDict.HELM:l._defaultGapSymbolsDict.SEPARATOR,!this.column.tags.has("aligned")||!this.column.tags.has("alphabet")||!this.column.tags.has(".alphabetIsMultichar")&&!this.isHelm()&&"UN"===this.alphabet)if(this.isFasta())l.setUnitsToFastaColumn(this.column);else if(this.isSeparator()){const e=t.getTag("separator");l.setUnitsToSeparatorColumn(this.column,e)}else{if(!this.isHelm())throw new Error(`Unexpected units '${this.column.getTag(i.TAGS.UNITS)}'.`);l.setUnitsToHelmColumn(this.column)}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.`)}}l._defaultGapSymbolsDict={HELM:"*",SEPARATOR:"",FASTA:"-"}},9298:(t,e,n)=>{"use strict";var i,o,s,r,a;n.d(e,{CI:()=>c,Ct:()=>a,DX:()=>h,ES:()=>i,dE:()=>r,iD:()=>s,vS:()=>l,vw:()=>o}),function(t){t.Entropy="Entropy",t.full="100%"}(i||(i={})),function(t){t.TOP="top",t.MIDDLE="middle",t.BOTTOM="bottom"}(o||(o={})),function(t){t.LEFT="left",t.CENTER="center",t.RIGHT="right"}(s||(s={})),function(t){t.AUTO="auto",t.ON="on",t.OFF="off"}(r||(r={})),function(t){t.Filtered="Filtered",t.Selected="Selected"}(a||(a={}));const l=new class{constructor(){this.sequenceColumnName=null,this.startPositionName=null,this.endPositionName=null,this.skipEmptySequences=!0,this.skipEmptyPositions=!1,this.shrinkEmptyTail=!0,this.backgroundColor=4294967295,this.positionHeight=i.full,this.positionWidth=16,this.verticalAlignment=o.MIDDLE,this.horizontalAlignment=s.CENTER,this.fixWidth=!1,this.fitArea=!0,this.minHeight=50,this.maxHeight=100,this.positionMarginState=r.AUTO,this.positionMargin=0,this.filterSource=a.Filtered}},c=", ";var h;!function(t){t.positionNames=".positionNames"}(h||(h={}))},779:(t,e,n)=>{"use strict";function i(){return(t,e)=>{let n=0;t.length!==e.length&&(n=Math.abs(t.length-e.length));let i=0;for(let n=0;n<Math.min(t.length,e.length);n++)t[n]!==e[n]&&i++;return i+n}}n.d(e,{j:()=>i})},489:(t,e,n)=>{"use strict";n.d(e,{U:()=>i.U,o:()=>i.o});var i=n(5540)},458:(t,e,n)=>{"use strict";n.d(e,{r:()=>o});var i=n(1811);function o(){return(t,e)=>(0,i.T)(t,e)}},5540:(t,e,n)=>{"use strict";n.d(e,{U:()=>i,o:()=>a});var i,o=n(779),s=n(458),r=n(6683);!function(t){t.HAMMING="Hamming",t.LEVENSHTEIN="Levenshtein",t.NEEDLEMANN_WUNSCH="Needlemann-Wunsch"}(i||(i={}));const a={[i.HAMMING]:o.j,[i.LEVENSHTEIN]:s.r,[i.NEEDLEMANN_WUNSCH]:r.n}},6683:(t,e,n)=>{"use strict";n.d(e,{n:()=>o});const i={gapOpen:8,gapExtend:2,scoringMatrix:[[4,-1,-2,-2,0,-1,-1,0,-2,-1,-1,-1,-1,-2,-1,1,0,-3,-2,0,-2,-1,0,-4],[-1,5,0,-2,-3,1,0,-2,0,-3,-2,2,-1,-3,-2,-1,-1,-3,-2,-3,-1,0,-1,-4],[-2,0,6,1,-3,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,-2,-2,-3,-3,-1,-2,-1,-4],[-2,0,1,-1,-3,0,0,-2,8,-3,-3,-1,-2,-1,-2,-1,-2,-2,2,-3,0,0,-1,-4],[-1,-3,-3,-3,-1,-3,-3,-4,-3,4,2,-3,1,0,-3,-2,-1,-3,-1,3,-3,-3,-1,-4],[-1,-2,-3,-4,-1,-2,-3,-4,-3,2,4,-2,2,0,-3,-2,-1,-2,-1,1,-4,-3,-1,-4],[-1,2,0,-1,-3,1,1,-2,-1,-3,-2,5,-1,-3,-1,0,-1,-3,-2,-2,0,1,-1,-4],[-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 o(t){return(e,n)=>{const{gapOpen:o,gapExtend:s,scoringMatrix:r,alphabetIndexes:a}=Object.assign(Object.assign({},i),t),l=[new Array(e.length+1).fill(0),new Array(e.length+1).fill(0)],c=new Array(e.length+1).fill(!1),h=new Array(e.length+1).fill(!1);let u=0,d=1;for(let t=1;t<e.length+1;t++)l[0][t]=-o-(t-1)*s;for(let t=1;t<n.length+1;t++){l[d][0]=-o-(t-1)*s;for(let i=1;i<e.length+1;i++){const f=l[u][i-1]+r[a[e[i-1]]][a[n[t-1]]],m=l[u][i]-(c[i]?s:o),p=l[d][i-1]-(h[i-1]?s:o);l[d][i]=Math.max(f,p,m),l[d][i]===f?(c[i]=!1,h[i]=!1):l[d][i]===p?(c[i]=!1,h[i]=!0):(c[i]=!0,h[i]=!1)}u=d,d=(d+1)%2}return-l[u][e.length]}}},1061:(t,e,n)=>{"use strict";n.d(e,{AB:()=>A,Bu:()=>f,QK:()=>r,W3:()=>y,Wh:()=>g,X5:()=>w,bb:()=>b,ci:()=>C,f6:()=>v,gw:()=>M,l_:()=>m});var i=n(4469),o=n(976),s=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};const r={},a="Auto Tests",l={};let c;var h;!function(t){t.notNull=function(t,e){if(null==t)throw new Error(`${null==e?"Value":e} not defined`)}}(h||(h={}));class u{constructor(t,e){this.catchUnhandled=!0,this.report=!1,void 0!==t&&(this.catchUnhandled=t),void 0!==e&&(this.report=e)}}class d{constructor(t,e,n,i){var o;this.category=t,this.name=e,null!=i||(i={}),null!==(o=i.timeout)&&void 0!==o||(i.timeout=3e4),this.options=i,this.test=()=>s(this,void 0,void 0,(function*(){return new Promise(((t,e)=>s(this,void 0,void 0,(function*(){let i="";try{i=yield n()}catch(t){e(t)}t(i)}))))}))}}function f(t,e,n){null==r[c]&&(r[c]={}),null==r[c].tests&&(r[c].tests=[]),r[c].tests.push(new d(c,t,e,n))}function m(t,e=!0,n){if(n=n?`${n}, `:"",t!==e)throw new Error(`${n}Expected "${e}", got "${t}"`)}function p(t,e,n=.001,i){if(t===Number.POSITIVE_INFINITY&&e===Number.POSITIVE_INFINITY||t===Number.NEGATIVE_INFINITY&&e===Number.NEGATIVE_INFINITY||t===Number.NaN&&e===Number.NaN||isNaN(t)&&isNaN(e))return;const o=Math.abs(t-e)<n;if(m(o,!0,`${null!=i?i:""} (tolerance = ${n})`),!o)throw new Error(`Expected ${e}, got ${t} (tolerance = ${n})`)}function g(t,e){for(const[n,i]of Object.entries(e)){if(!t.hasOwnProperty(n))throw new Error(`Expected property "${n}" not found`);const e=t[n];if(e instanceof Array&&i instanceof Array)v(e,i);else if(e instanceof Object&&i instanceof Object)g(e,i);else if(Number.isFinite(e)&&Number.isFinite(i))p(e,i);else if(e!=i)throw new Error(`Expected (${i}) for key '${n}', got (${e})`)}}function v(t,e){const n=t.length,i=e.length;if(n!=i)throw new Error(`Arrays are of different length: actual array length is ${n} and expected array length is ${i}`);for(let i=0;i<n;i++)if(t[i]instanceof Array&&e[i]instanceof Array)v(t[i],e[i]);else if(t[i]instanceof Object&&e[i]instanceof Object)g(t[i],e[i]);else if(t[i]!=e[i])throw new Error(`Expected ${e[i]} at position ${i}, got ${t[i]}`)}function y(t,e){c=t,e()}function b(t){null==r[c]&&(r[c]={}),r[c].before=t}function w(t){null==r[c]&&(r[c]={}),r[c].after=t}function S(t,e){return t.replace(new RegExp(e.name,"gi"),e.nqName)}function C(t){var e,n,c,h,f;return s(this,void 0,void 0,(function*(){const m=null===(n=null===(e=i.functions.getCurrentCall())||void 0===e?void 0:e.func)||void 0===n?void 0:n.package;yield function(t,e){return s(this,void 0,void 0,(function*(){if(l[t])return;const e=r;if(void 0!==e[a])return void(l[t]=!0);const n=[],o=yield i.dapi.functions.filter(`package.id = "${t}"`).list();for(const t of o){const e=t.options.test;if(e&&Array.isArray(e)&&e.length)for(let o=0;o<e.length;o++)n.push(new d(a,1===e.length?t.name:`${t.name} ${o+1}`,(()=>s(this,void 0,void 0,(function*(){if(!0!==(yield i.functions.eval(S(e[o],t))))throw`Failed: ${e[o]}`})))))}l[t]=!0,n.length&&(e[a]={tests:n})}))}(m.id);const p=[];console.log("Running tests"),null!=t||(t={}),null!==(c=(f=t).testContext)&&void 0!==c||(f.testContext=new u),i.shell.lastError="";for(const[e,n]of Object.entries(r)){if(null!=(null==t?void 0:t.category)&&!e.toLowerCase().startsWith(null==t?void 0:t.category.toLowerCase()))continue;console.log(`Started ${e} category`);try{n.before&&(yield n.before())}catch(t){n.beforeStatus=t.toString()}const i=null!==(h=n.tests)&&void 0!==h?h:[],o=[];for(let e=0;e<i.length;e++)o.push(yield T(i[e],null==t?void 0:t.test));const s=(yield Promise.all(o)).filter((t=>"skipped"!=t.result));try{n.after&&(yield n.after())}catch(t){n.afterStatus=t.toString()}n.afterStatus&&s.push({category:e,name:"init",result:n.afterStatus,success:!1,ms:0,skipped:!1}),n.beforeStatus&&s.push({category:e,name:"init",result:n.beforeStatus,success:!1,ms:0,skipped:!1}),p.push(...s)}if(t.testContext.catchUnhandled&&(yield M(1e3),i.shell.lastError.length>0&&p.push({category:"Unhandled exceptions",name:"exceptions",result:i.shell.lastError,success:!1,ms:0,skipped:!1})),t.testContext.report){const t=new o.Logger,e=p.filter((t=>t.success)).length,n=p.filter((t=>t.skipped)).length,i=p.filter((t=>!t.success)),s="Package @package tested: @successful successful, @skipped skipped, @failed failed tests",r={successful:e,skipped:n,failed:i.length,package:m};for(const t of i)Object.assign(r,{[`${t.category} | ${t.name}`]:t.result});t.log(s,r,"package-tested")}return p}))}function T(t,e){var n,i,o;return s(this,void 0,void 0,(function*(){let s;const r=null!=e&&!t.name.toLowerCase().startsWith(e.toLowerCase()),a=(null===(n=t.options)||void 0===n?void 0:n.skipReason)||r,l=r?"skipped":null===(i=t.options)||void 0===i?void 0:i.skipReason;a||console.log(`Started ${t.category} ${t.name}`);const c=new Date;try{s=a?{success:!0,result:l,ms:0,skipped:!0}:{success:!0,result:null!==(o=yield t.test())&&void 0!==o?o:"OK",ms:0,skipped:!1}}catch(t){s={success:!1,result:t.toString(),ms:0,skipped:!1}}const h=new Date;return s.ms=h-c,a||console.log(`Finished ${t.category} ${t.name} for ${s.ms} ms`),s.category=t.category,s.name=t.name,s}))}function M(t){return s(this,void 0,void 0,(function*(){yield new Promise((e=>setTimeout(e,t)))}))}function E(t,e="Timeout exceeded",n=500){return s(this,void 0,void 0,(function*(){return new Promise(((i,o)=>{setTimeout((()=>{clearInterval(s),o(new Error(e))}),n);const s=setInterval((()=>{t()&&(clearInterval(s),i())}),50)}))}))}function A(t,e,n=!1){return s(this,void 0,void 0,(function*(){n&&(yield i.data.detectSemanticTypes(e));const o=i.shell.addTableView(e),s=`[name=viewer-${t.replace(/\s+/g,"-")} i]`,r=`${s} canvas,${s} svg,${s} img,\n ${s} input,${s} h1,${s} a`,a=[];try{let n=o.addViewer(t);yield E((()=>null!==document.querySelector(r)),"cannot load viewer",3e3),a.push(Array.from(o.viewers).length),Array.from(e.row(0).cells).forEach((t=>t.value=null)),e.rows.select((t=>t.idx>1&&t.idx<7));for(let t=7;t<12;t++)e.filter.set(t,!1);e.currentRowIdx=1;const i=n.getOptions(!0).look,s={};Object.keys(i).filter((t=>"boolean"==typeof i[t])).forEach((t=>s[t]=!i[t])),n.setOptions(s),yield M(250);const l=o.saveLayout(),c=n.getOptions().look;o.resetLayout(),a.push(Array.from(o.viewers).length),o.loadLayout(l),yield E((()=>null!==document.querySelector(r)),"cannot load viewer from layout",3e3),yield M(250),a.push(Array.from(o.viewers).length),n=Array.from(o.viewers).find((t=>"Grid"!==t.type)),v(a,[2,1,2]),m(JSON.stringify(n.getOptions().look),JSON.stringify(c))}finally{o.close(),i.shell.closeTable(e)}}))}},7604:(t,e,n)=>{"use strict";function i(t){var e;return"string"==typeof t||t instanceof String?t:("object"==typeof t||t instanceof Object)&&"$thrownJsError"in t?i(t.$thrownJsError):t instanceof Error?null!==(e=t.stack)&&void 0!==e?e:t.message:t.toString()}n.d(e,{O:()=>i})},3659:(t,e,n)=>{"use strict";n.d(e,{OW:()=>i});class i extends Float32Array{}},850:(t,e,n)=>{"use strict";function i(t=!1,e="Assertion error."){if(!t)throw new Error(e)}function o(t){let e=0;for(let n=0;n<t.length;n++)e+=t[n]*t[n];return Math.sqrt(e)}function s(t,e){if(t.length!=e.length)throw new Error("The dimensionality of the vectors must match");let n=0;for(let i=0;i<t.length;i++)n+=t[i]*e[i];return n}n.d(e,{$G:()=>o,MA:()=>s,hu:()=>i}),n(3659)},7659:(t,e,n)=>{"use strict";e.Z=void 0;var i=n(6215);Object.defineProperty(e,"Z",{enumerable:!0,get:function(){return i.TSNE}})},6215:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.TSNE=void 0,e.TSNE=class{constructor(t){this.returnV=!1,this.vValue=0,this.iter=0,t=t||{},this.perplexity=this.getopt(t,"perplexity",30),this.dim=this.getopt(t,"dim",2),this.epsilon=this.getopt(t,"epsilon",10)}assert(t,e){if(!t)throw e||"Assertion failed"}getopt(t,e,n){return t.hasOwnProperty(e)?t[e]:n}gaussRandom(){if(this.returnV)return this.returnV=!1,this.vValue;const t=2*Math.random()-1,e=2*Math.random()-1,n=t*t+e*e;if(0===n||n>1)return this.gaussRandom();const i=Math.sqrt(-2*Math.log(n)/n);return this.vValue=e*i,this.returnV=!0,t*i}randn(t,e){return t+this.gaussRandom()*e}zeros(t){if(void 0===t||isNaN(t))return[];if("undefined"==typeof ArrayBuffer){const e=new Array(t);for(let n=0;n<t;n++)e[n]=0;return e}return new Float64Array(t)}randn2d(t,e,n){const i=void 0!==n,o=[];for(let s=0;s<t;s++){const t=[];for(let o=0;o<e;o++)i?t.push(n):t.push(this.randn(0,1e-4));o.push(t)}return o}L2(t,e){const n=t.length;let i=0;for(let o=0;o<n;o++){const n=t[o],s=e[o];i+=(n-s)*(n-s)}return i}xtod(t){const e=t.length,n=this.zeros(e*e);for(let i=0;i<e;i++)for(let o=i+1;o<e;o++){const s=this.L2(t[i],t[o]);n[i*e+o]=s,n[o*e+i]=s}return n}d2p(t,e,n){const i=Math.sqrt(t.length),o=Math.floor(i);this.assert(o===i,"D should have square number of elements.");const s=Math.log(e),r=this.zeros(o*o),a=this.zeros(o);for(let e=0;e<o;e++){let i=-1/0,l=1/0,c=1,h=!1;const u=50;let d=0;for(;!h;){let r=0;for(let n=0;n<o;n++){let i=Math.exp(-t[e*o+n]*c);e===n&&(i=0),a[n]=i,r+=i}let f=0;for(let t=0;t<o;t++){let e;e=0===r?0:a[t]/r,a[t]=e,e>1e-7&&(f-=e*Math.log(e))}f>s?(i=c,l===1/0?c*=2:c=(c+l)/2):(l=c,i===-1/0?c/=2:c=(c+i)/2),d++,Math.abs(f-s)<n&&(h=!0),d>=u&&(h=!0)}for(let t=0;t<o;t++)r[e*o+t]=a[t]}const l=this.zeros(o*o),c=2*o;for(let t=0;t<o;t++)for(let e=0;e<o;e++)l[t*o+e]=Math.max((r[t*o+e]+r[e*o+t])/c,1e-100);return l}sign(t){return t>0?1:t<0?-1:0}initDataRaw(t){const e=t.length,n=t[0].length;this.assert(e>0," X is empty? You must have some data!"),this.assert(n>0," X[0] is empty? Where is the data?");const i=this.xtod(t);this.P=this.d2p(i,this.perplexity,1e-4),this.N=e,this.initSolution()}initDataDist(t){const e=t.length;this.assert(e>0," X is empty? You must have some data!");const n=this.zeros(e*e);for(let i=0;i<e;i++)for(let o=i+1;o<e;o++){const s=t[i][o];n[i*e+o]=s,n[o*e+i]=s}this.P=this.d2p(n,this.perplexity,1e-4),this.N=e,this.initSolution()}initSolution(){this.Y=this.randn2d(this.N,this.dim),this.gains=this.randn2d(this.N,this.dim,1),this.ystep=this.randn2d(this.N,this.dim,0),this.iter=0}getSolution(){return this.Y}step(){this.iter+=1;const t=this.N,e=this.costGrad(this.Y),n=e.cost,i=e.grad,o=this.zeros(this.dim);for(let e=0;e<t;e++)for(let t=0;t<this.dim;t++){const n=i[e][t],s=this.ystep[e][t],r=this.gains[e][t];let a=this.sign(n)===this.sign(s)?.8*r:r+.2;a<.01&&(a=.01),this.gains[e][t]=a;const l=(this.iter<250?.5:.8)*s-this.epsilon*a*i[e][t];this.ystep[e][t]=l,this.Y[e][t]+=l,o[t]+=this.Y[e][t]}for(let e=0;e<t;e++)for(let n=0;n<this.dim;n++)this.Y[e][n]-=o[n]/t;return n}debugGrad(){const t=this.N,e=this.costGrad(this.Y),n=(e.cost,e.grad),i=1e-5;for(let e=0;e<t;e++)for(let t=0;t<this.dim;t++){const o=this.Y[e][t];this.Y[e][t]=o+i;const s=this.costGrad(this.Y);this.Y[e][t]=o-i;const r=this.costGrad(this.Y),a=n[e][t],l=(s.cost-r.cost)/(2*i);console.log(e+","+t+": gradcheck analytic: "+a+" vs. numerical: "+l),this.Y[e][t]=o}}costGrad(t){const e=this.N,n=this.dim,i=this.P,o=this.iter<100?4:1,s=this.zeros(e*e);let r=0;for(let i=0;i<e;i++)for(let o=i+1;o<e;o++){let a=0;for(let e=0;e<n;e++){const n=t[i][e]-t[o][e];a+=n*n}const l=1/(1+a);s[i*e+o]=l,s[o*e+i]=l,r+=2*l}const a=e*e,l=this.zeros(a);for(let t=0;t<a;t++)l[t]=Math.max(s[t]/r,1e-100);let c=0;const h=[];for(let r=0;r<e;r++){const a=new Array(n);for(let t=0;t<n;t++)a[t]=0;for(let h=0;h<e;h++){c+=-i[r*e+h]*Math.log(l[r*e+h]);const u=4*(o*i[r*e+h]-l[r*e+h])*s[r*e+h];for(let e=0;e<n;e++)a[e]+=u*(t[r][e]-t[h][e])}h.push(a)}return{cost:c,grad:h}}}},9414:(t,e,n)=>{"use strict";n.d(e,{Z:()=>a});var i=n(7537),o=n.n(i),s=n(3645),r=n.n(s)()(o());r.push([t.id,".scatter_plot_link {\n position: absolute!important;\n right: 10px;\n}\n\n.cliffs_grid {\n top: 10px;\n}\n\n.show_only_cliffs {\n top: 30px;\n}\n\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 n="",i=void 0!==e[5];return e[4]&&(n+="@supports (".concat(e[4],") {")),e[2]&&(n+="@media ".concat(e[2]," {")),i&&(n+="@layer".concat(e[5].length>0?" ".concat(e[5]):""," {")),n+=t(e),i&&(n+="}"),e[2]&&(n+="}"),e[4]&&(n+="}"),n})).join("")},e.i=function(t,n,i,o,s){"string"==typeof t&&(t=[[null,t,void 0]]);var r={};if(i)for(var a=0;a<this.length;a++){var l=this[a][0];null!=l&&(r[l]=!0)}for(var c=0;c<t.length;c++){var h=[].concat(t[c]);i&&r[h[0]]||(void 0!==s&&(void 0===h[5]||(h[1]="@layer".concat(h[5].length>0?" ".concat(h[5]):""," {").concat(h[1],"}")),h[5]=s),n&&(h[2]?(h[1]="@media ".concat(h[2]," {").concat(h[1],"}"),h[2]=n):h[2]=n),o&&(h[4]?(h[1]="@supports (".concat(h[4],") {").concat(h[1],"}"),h[4]=o):h[4]="".concat(o)),e.push(h))}},e}},7537:t=>{"use strict";t.exports=function(t){var e=t[1],n=t[3];if(!n)return e;if("function"==typeof btoa){var i=btoa(unescape(encodeURIComponent(JSON.stringify(n)))),o="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(i),s="/*# ".concat(o," */");return[e].concat([s]).join("\n")}return[e].join("\n")}},9133:function(t,e,n){var i;!function(e,o){var s={};!function(t){"use strict";t.__esModule=!0,t.digestLength=32,t.blockSize=64;var e=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function n(t,n,i,o,s){for(var r,a,l,c,h,u,d,f,m,p,g,v,y;s>=64;){for(r=n[0],a=n[1],l=n[2],c=n[3],h=n[4],u=n[5],d=n[6],f=n[7],p=0;p<16;p++)g=o+4*p,t[p]=(255&i[g])<<24|(255&i[g+1])<<16|(255&i[g+2])<<8|255&i[g+3];for(p=16;p<64;p++)v=((m=t[p-2])>>>17|m<<15)^(m>>>19|m<<13)^m>>>10,y=((m=t[p-15])>>>7|m<<25)^(m>>>18|m<<14)^m>>>3,t[p]=(v+t[p-7]|0)+(y+t[p-16]|0);for(p=0;p<64;p++)v=(((h>>>6|h<<26)^(h>>>11|h<<21)^(h>>>25|h<<7))+(h&u^~h&d)|0)+(f+(e[p]+t[p]|0)|0)|0,y=((r>>>2|r<<30)^(r>>>13|r<<19)^(r>>>22|r<<10))+(r&a^r&l^a&l)|0,f=d,d=u,u=h,h=c+v|0,c=l,l=a,a=r,r=v+y|0;n[0]+=r,n[1]+=a,n[2]+=l,n[3]+=c,n[4]+=h,n[5]+=u,n[6]+=d,n[7]+=f,o+=64,s-=64}return o}var i=function(){function e(){this.digestLength=t.digestLength,this.blockSize=t.blockSize,this.state=new Int32Array(8),this.temp=new Int32Array(64),this.buffer=new Uint8Array(128),this.bufferLength=0,this.bytesHashed=0,this.finished=!1,this.reset()}return e.prototype.reset=function(){return this.state[0]=1779033703,this.state[1]=3144134277,this.state[2]=1013904242,this.state[3]=2773480762,this.state[4]=1359893119,this.state[5]=2600822924,this.state[6]=528734635,this.state[7]=1541459225,this.bufferLength=0,this.bytesHashed=0,this.finished=!1,this},e.prototype.clean=function(){for(var t=0;t<this.buffer.length;t++)this.buffer[t]=0;for(t=0;t<this.temp.length;t++)this.temp[t]=0;this.reset()},e.prototype.update=function(t,e){if(void 0===e&&(e=t.length),this.finished)throw new Error("SHA256: can't update because hash was finished.");var i=0;if(this.bytesHashed+=e,this.bufferLength>0){for(;this.bufferLength<64&&e>0;)this.buffer[this.bufferLength++]=t[i++],e--;64===this.bufferLength&&(n(this.temp,this.state,this.buffer,0,64),this.bufferLength=0)}for(e>=64&&(i=n(this.temp,this.state,t,i,e),e%=64);e>0;)this.buffer[this.bufferLength++]=t[i++],e--;return this},e.prototype.finish=function(t){if(!this.finished){var e=this.bytesHashed,i=this.bufferLength,o=e/536870912|0,s=e<<3,r=e%64<56?64:128;this.buffer[i]=128;for(var a=i+1;a<r-8;a++)this.buffer[a]=0;this.buffer[r-8]=o>>>24&255,this.buffer[r-7]=o>>>16&255,this.buffer[r-6]=o>>>8&255,this.buffer[r-5]=o>>>0&255,this.buffer[r-4]=s>>>24&255,this.buffer[r-3]=s>>>16&255,this.buffer[r-2]=s>>>8&255,this.buffer[r-1]=s>>>0&255,n(this.temp,this.state,this.buffer,0,r),this.finished=!0}for(a=0;a<8;a++)t[4*a+0]=this.state[a]>>>24&255,t[4*a+1]=this.state[a]>>>16&255,t[4*a+2]=this.state[a]>>>8&255,t[4*a+3]=this.state[a]>>>0&255;return this},e.prototype.digest=function(){var t=new Uint8Array(this.digestLength);return this.finish(t),t},e.prototype._saveState=function(t){for(var e=0;e<this.state.length;e++)t[e]=this.state[e]},e.prototype._restoreState=function(t,e){for(var n=0;n<this.state.length;n++)this.state[n]=t[n];this.bytesHashed=e,this.finished=!1,this.bufferLength=0},e}();t.Hash=i;var o=function(){function t(t){this.inner=new i,this.outer=new i,this.blockSize=this.inner.blockSize,this.digestLength=this.inner.digestLength;var e=new Uint8Array(this.blockSize);if(t.length>this.blockSize)(new i).update(t).finish(e).clean();else for(var n=0;n<t.length;n++)e[n]=t[n];for(n=0;n<e.length;n++)e[n]^=54;for(this.inner.update(e),n=0;n<e.length;n++)e[n]^=106;for(this.outer.update(e),this.istate=new Uint32Array(8),this.ostate=new Uint32Array(8),this.inner._saveState(this.istate),this.outer._saveState(this.ostate),n=0;n<e.length;n++)e[n]=0}return t.prototype.reset=function(){return this.inner._restoreState(this.istate,this.inner.blockSize),this.outer._restoreState(this.ostate,this.outer.blockSize),this},t.prototype.clean=function(){for(var t=0;t<this.istate.length;t++)this.ostate[t]=this.istate[t]=0;this.inner.clean(),this.outer.clean()},t.prototype.update=function(t){return this.inner.update(t),this},t.prototype.finish=function(t){return this.outer.finished?this.outer.finish(t):(this.inner.finish(t),this.outer.update(t,this.digestLength).finish(t)),this},t.prototype.digest=function(){var t=new Uint8Array(this.digestLength);return this.finish(t),t},t}();function s(t){var e=(new i).update(t),n=e.digest();return e.clean(),n}function r(t,e){var n=new o(t).update(e),i=n.digest();return n.clean(),i}function a(t,e,n,i){var o=i[0];if(0===o)throw new Error("hkdf: cannot expand more");e.reset(),o>1&&e.update(t),n&&e.update(n),e.update(i),e.finish(t),i[0]++}t.HMAC=o,t.hash=s,t.default=s,t.hmac=r;var l=new Uint8Array(t.digestLength);t.hkdf=function(t,e,n,i){void 0===e&&(e=l),void 0===i&&(i=32);for(var s=new Uint8Array([1]),c=r(e,t),h=new o(c),u=new Uint8Array(h.digestLength),d=u.length,f=new Uint8Array(i),m=0;m<i;m++)d===u.length&&(a(u,h,n,s),d=0),f[m]=u[d++];return h.clean(),u.fill(0),s.fill(0),f},t.pbkdf2=function(t,e,n,i){for(var s=new o(t),r=s.digestLength,a=new Uint8Array(4),l=new Uint8Array(r),c=new Uint8Array(r),h=new Uint8Array(i),u=0;u*r<i;u++){var d=u+1;a[0]=d>>>24&255,a[1]=d>>>16&255,a[2]=d>>>8&255,a[3]=d>>>0&255,s.reset(),s.update(e),s.update(a),s.finish(c);for(var f=0;f<r;f++)l[f]=c[f];for(f=2;f<=n;f++){s.reset(),s.update(c).finish(c);for(var m=0;m<r;m++)l[m]^=c[m]}for(f=0;f<r&&u*r+f<i;f++)h[u*r+f]=l[f]}for(u=0;u<r;u++)l[u]=c[u]=0;for(u=0;u<4;u++)a[u]=0;return s.clean(),h}}(s);var r=s.default;for(var a in s)r[a]=s[a];"object"==typeof t.exports?t.exports=r:void 0===(i=function(){return r}.call(s,n,s,t))||(t.exports=i)}()},1811:(t,e,n)=>{"use strict";n.d(e,{T:()=>o});const i=new Uint32Array(65536),o=(t,e)=>{if(t.length<e.length){const n=e;e=t,t=n}return 0===e.length?t.length:t.length<=32?((t,e)=>{const n=t.length,o=e.length,s=1<<n-1;let r=-1,a=0,l=n,c=n;for(;c--;)i[t.charCodeAt(c)]|=1<<c;for(c=0;c<o;c++){let t=i[e.charCodeAt(c)];const n=t|a;t|=(t&r)+r^r,a|=~(t|r),r&=t,a&s&&l++,r&s&&l--,a=a<<1|1,r=r<<1|~(n|a),a&=n}for(c=n;c--;)i[t.charCodeAt(c)]=0;return l})(t,e):((t,e)=>{const n=e.length,o=t.length,s=[],r=[],a=Math.ceil(n/32),l=Math.ceil(o/32);for(let t=0;t<a;t++)r[t]=-1,s[t]=0;let c=0;for(;c<l-1;c++){let a=0,l=-1;const h=32*c,u=Math.min(32,o)+h;for(let e=h;e<u;e++)i[t.charCodeAt(e)]|=1<<e;for(let t=0;t<n;t++){const n=i[e.charCodeAt(t)],o=r[t/32|0]>>>t&1,c=s[t/32|0]>>>t&1,h=n|a,u=((n|c)&l)+l^l|n|c;let d=a|~(u|l),f=l&u;d>>>31^o&&(r[t/32|0]^=1<<t),f>>>31^c&&(s[t/32|0]^=1<<t),d=d<<1|o,f=f<<1|c,l=f|~(h|d),a=d&h}for(let e=h;e<u;e++)i[t.charCodeAt(e)]=0}let h=0,u=-1;const d=32*c,f=Math.min(32,o-d)+d;for(let e=d;e<f;e++)i[t.charCodeAt(e)]|=1<<e;let m=o;for(let t=0;t<n;t++){const n=i[e.charCodeAt(t)],a=r[t/32|0]>>>t&1,l=s[t/32|0]>>>t&1,c=n|h,d=((n|l)&u)+u^u|n|l;let f=h|~(d|u),p=u&d;m+=f>>>o-1&1,m-=p>>>o-1&1,f>>>31^a&&(r[t/32|0]^=1<<t),p>>>31^l&&(s[t/32|0]^=1<<t),f=f<<1|a,p=p<<1|l,u=p|~(c|f),h=f&c}for(let e=d;e<f;e++)i[t.charCodeAt(e)]=0;return m})(t,e)}},3979:(t,e)=>{"use strict";e.H$=void 0,e.H$=function(t,e,n){var i=function(t,e,n){if(0===t.length||0===e.length)return 0;if(n&&!n.caseSensitive&&(t=t.toUpperCase(),e=e.toUpperCase()),t===e)return 1;for(var i=0,o=t.length,s=e.length,r=Math.floor(Math.max(o,s)/2)-1,a=new Array(o),l=new Array(s),c=0;c<o;c++)for(var h=Math.max(0,c-r);h<=Math.min(s,c+r+1);h++)if(!a[c]&&!l[h]&&t[c]===e[h]){++i,a[c]=l[h]=!0;break}if(0===i)return 0;var u=0,d=0;for(c=0;c<o;c++)if(a[c]){for(;!l[d];)d++;t.charAt(c)!==e.charAt(d++)&&u++}return(i/o+i/s+(i-(u/=2))/i)/3}(t,e,n),o=0;if(i>.7){for(var s=Math.min(t.length,e.length),r=0;t[r]===e[r]&&r<4&&r<s;)++o,r++;i+=.1*o*(1-i)}return i}},9251:(t,e,n)=>{"use strict";n.r(e),n.d(e,{default:()=>D});const i=Object.prototype.toString;function o(t){return i.call(t).endsWith("Array]")}function s(t,e,n){let i=0;const o=n(e);for(let e=0;e<t.x.length;e++)i+=Math.abs(t.y[e]-o(t.x[e]));return i}const r=Object.prototype.toString;function a(t){return r.call(t).endsWith("Array]")}const l=Object.prototype.toString;function c(t){return l.call(t).endsWith("Array]")}const h=Object.prototype.toString;const u=Object.prototype.toString;function d(t){var e,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!c(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");if(void 0!==n.output){if(!c(n.output))throw new TypeError("output option must be an array if specified");e=n.output}else e=new Array(t.length);var i=function(t){var e,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(e=t,!u.call(e).endsWith("Array]"))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");var i=n.fromIndex,o=void 0===i?0:i,s=n.toIndex,r=void 0===s?t.length:s;if(o<0||o>=t.length||!Number.isInteger(o))throw new Error("fromIndex must be a positive integer smaller than length");if(r<=o||r>t.length||!Number.isInteger(r))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var a=t[o],l=o+1;l<r;l++)t[l]<a&&(a=t[l]);return a}(t),o=function(t){var e,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(e=t,!h.call(e).endsWith("Array]"))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");var i=n.fromIndex,o=void 0===i?0:i,s=n.toIndex,r=void 0===s?t.length:s;if(o<0||o>=t.length||!Number.isInteger(o))throw new Error("fromIndex must be a positive integer smaller than length");if(r<=o||r>t.length||!Number.isInteger(r))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var a=t[o],l=o+1;l<r;l++)t[l]>a&&(a=t[l]);return a}(t);if(i===o)throw new RangeError("minimum and maximum input values are equal. Cannot rescale a constant array");var s=n.min,r=void 0===s?n.autoMinMax?i:0:s,a=n.max,l=void 0===a?n.autoMinMax?o:1:a;if(r>=l)throw new RangeError("min option must be smaller than max option");for(var d=(l-r)/(o-i),f=0;f<t.length;f++)e[f]=(t[f]-i)*d+r;return e}const f=" ".repeat(2),m=" ".repeat(4);function p(t,e={}){const{maxRows:n=15,maxColumns:i=10,maxNumSize:o=8,padMinus:s="auto"}=e;return`${t.constructor.name} {\n${f}[\n${m}${function(t,e,n,i,o){const{rows:s,columns:r}=t,a=Math.min(s,e),l=Math.min(r,n),c=[];if("auto"===o){o=!1;t:for(let e=0;e<a;e++)for(let n=0;n<l;n++)if(t.get(e,n)<0){o=!0;break t}}for(let e=0;e<a;e++){let n=[];for(let s=0;s<l;s++)n.push(g(t.get(e,s),i,o));c.push(`${n.join(" ")}`)}return l!==r&&(c[c.length-1]+=` ... ${r-n} more columns`),a!==s&&c.push(`... ${s-e} more rows`),c.join(`\n${m}`)}(t,n,i,o,s)}\n${f}]\n${f}rows: ${t.rows}\n${f}columns: ${t.columns}\n}`}function g(t,e,n){return(t>=0&&n?` ${v(t,e-1)}`:v(t,e)).padEnd(e)}function v(t,e){let n=t.toString();if(n.length<=e)return n;let i=t.toFixed(e);if(i.length>e&&(i=t.toFixed(Math.max(0,e-(i.length-e)))),i.length<=e&&!i.startsWith("0.000")&&!i.startsWith("-0.000"))return i;let o=t.toExponential(e);return o.length>e&&(o=t.toExponential(Math.max(0,e-(o.length-e)))),o.slice(0)}function y(t,e,n){let i=n?t.rows:t.rows-1;if(e<0||e>i)throw new RangeError("Row index out of range")}function b(t,e,n){let i=n?t.columns:t.columns-1;if(e<0||e>i)throw new RangeError("Column index out of range")}function w(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 S(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 C(t,e,n,i,o){if(5!==arguments.length)throw new RangeError("expected 4 arguments");if(M("startRow",e),M("endRow",n),M("startColumn",i),M("endColumn",o),e>n||i>o||e<0||e>=t.rows||n<0||n>=t.rows||i<0||i>=t.columns||o<0||o>=t.columns)throw new RangeError("Submatrix indices are out of range")}function T(t,e=0){let n=[];for(let i=0;i<t;i++)n.push(e);return n}function M(t,e){if("number"!=typeof e)throw new TypeError(`${t} must be a number`)}function E(t){if(t.isEmpty())throw new Error("Empty matrix has no elements to index")}class A{static from1DArray(t,e,n){if(t*e!==n.length)throw new RangeError("data length does not match given dimensions");let i=new P(t,e);for(let o=0;o<t;o++)for(let t=0;t<e;t++)i.set(o,t,n[o*e+t]);return i}static rowVector(t){let e=new P(1,t.length);for(let n=0;n<t.length;n++)e.set(0,n,t[n]);return e}static columnVector(t){let e=new P(t.length,1);for(let n=0;n<t.length;n++)e.set(n,0,t[n]);return e}static zeros(t,e){return new P(t,e)}static ones(t,e){return new P(t,e).fill(1)}static rand(t,e,n={}){if("object"!=typeof n)throw new TypeError("options must be an object");const{random:i=Math.random}=n;let o=new P(t,e);for(let n=0;n<t;n++)for(let t=0;t<e;t++)o.set(n,t,i());return o}static randInt(t,e,n={}){if("object"!=typeof n)throw new TypeError("options must be an object");const{min:i=0,max:o=1e3,random:s=Math.random}=n;if(!Number.isInteger(i))throw new TypeError("min must be an integer");if(!Number.isInteger(o))throw new TypeError("max must be an integer");if(i>=o)throw new RangeError("min must be smaller than max");let r=o-i,a=new P(t,e);for(let n=0;n<t;n++)for(let t=0;t<e;t++){let e=i+Math.round(s()*r);a.set(n,t,e)}return a}static eye(t,e,n){void 0===e&&(e=t),void 0===n&&(n=1);let i=Math.min(t,e),o=this.zeros(t,e);for(let t=0;t<i;t++)o.set(t,t,n);return o}static diag(t,e,n){let i=t.length;void 0===e&&(e=i),void 0===n&&(n=e);let o=Math.min(i,e,n),s=this.zeros(e,n);for(let e=0;e<o;e++)s.set(e,e,t[e]);return s}static min(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let n=t.rows,i=t.columns,o=new P(n,i);for(let s=0;s<n;s++)for(let n=0;n<i;n++)o.set(s,n,Math.min(t.get(s,n),e.get(s,n)));return o}static max(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let n=t.rows,i=t.columns,o=new this(n,i);for(let s=0;s<n;s++)for(let n=0;n<i;n++)o.set(s,n,Math.max(t.get(s,n),e.get(s,n)));return o}static checkMatrix(t){return A.isMatrix(t)?t:new P(t)}static isMatrix(t){return null!=t&&"Matrix"===t.klass}get size(){return this.rows*this.columns}apply(t){if("function"!=typeof t)throw new TypeError("callback must be a function");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)t.call(this,e,n);return this}to1DArray(){let t=[];for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)t.push(this.get(e,n));return t}to2DArray(){let t=[];for(let e=0;e<this.rows;e++){t.push([]);for(let n=0;n<this.columns;n++)t[e].push(this.get(e,n))}return t}toJSON(){return this.to2DArray()}isRowVector(){return 1===this.rows}isColumnVector(){return 1===this.columns}isVector(){return 1===this.rows||1===this.columns}isSquare(){return this.rows===this.columns}isEmpty(){return 0===this.rows||0===this.columns}isSymmetric(){if(this.isSquare()){for(let t=0;t<this.rows;t++)for(let e=0;e<=t;e++)if(this.get(t,e)!==this.get(e,t))return!1;return!0}return!1}isEchelonForm(){let t=0,e=0,n=-1,i=!0,o=!1;for(;t<this.rows&&i;){for(e=0,o=!1;e<this.columns&&!1===o;)0===this.get(t,e)?e++:1===this.get(t,e)&&e>n?(o=!0,n=e):(i=!1,o=!0);t++}return i}isReducedEchelonForm(){let t=0,e=0,n=-1,i=!0,o=!1;for(;t<this.rows&&i;){for(e=0,o=!1;e<this.columns&&!1===o;)0===this.get(t,e)?e++:1===this.get(t,e)&&e>n?(o=!0,n=e):(i=!1,o=!0);for(let n=e+1;n<this.rows;n++)0!==this.get(t,n)&&(i=!1);t++}return i}echelonForm(){let t=this.clone(),e=0,n=0;for(;e<t.rows&&n<t.columns;){let i=e;for(let o=e;o<t.rows;o++)t.get(o,n)>t.get(i,n)&&(i=o);if(0===t.get(i,n))n++;else{t.swapRows(e,i);let o=t.get(e,n);for(let i=n;i<t.columns;i++)t.set(e,i,t.get(e,i)/o);for(let i=e+1;i<t.rows;i++){let o=t.get(i,n)/t.get(e,n);t.set(i,n,0);for(let s=n+1;s<t.columns;s++)t.set(i,s,t.get(i,s)-t.get(e,s)*o)}e++,n++}}return t}reducedEchelonForm(){let t=this.echelonForm(),e=t.columns,n=t.rows,i=n-1;for(;i>=0;)if(0===t.maxRow(i))i--;else{let o=0,s=!1;for(;o<n&&!1===s;)1===t.get(i,o)?s=!0:o++;for(let n=0;n<i;n++){let s=t.get(n,o);for(let r=o;r<e;r++){let e=t.get(n,r)-s*t.get(i,r);t.set(n,r,e)}}i--}return t}set(){throw new Error("set method is unimplemented")}get(){throw new Error("get method is unimplemented")}repeat(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{rows:e=1,columns:n=1}=t;if(!Number.isInteger(e)||e<=0)throw new TypeError("rows must be a positive integer");if(!Number.isInteger(n)||n<=0)throw new TypeError("columns must be a positive integer");let i=new P(this.rows*e,this.columns*n);for(let t=0;t<e;t++)for(let e=0;e<n;e++)i.setSubMatrix(this,this.rows*t,this.columns*e);return i}fill(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,t);return this}neg(){return this.mulS(-1)}getRow(t){y(this,t);let e=[];for(let n=0;n<this.columns;n++)e.push(this.get(t,n));return e}getRowVector(t){return P.rowVector(this.getRow(t))}setRow(t,e){y(this,t),e=w(this,e);for(let n=0;n<this.columns;n++)this.set(t,n,e[n]);return this}swapRows(t,e){y(this,t),y(this,e);for(let n=0;n<this.columns;n++){let i=this.get(t,n);this.set(t,n,this.get(e,n)),this.set(e,n,i)}return this}getColumn(t){b(this,t);let e=[];for(let n=0;n<this.rows;n++)e.push(this.get(n,t));return e}getColumnVector(t){return P.columnVector(this.getColumn(t))}setColumn(t,e){b(this,t),e=S(this,e);for(let n=0;n<this.rows;n++)this.set(n,t,e[n]);return this}swapColumns(t,e){b(this,t),b(this,e);for(let n=0;n<this.rows;n++){let i=this.get(n,t);this.set(n,t,this.get(n,e)),this.set(n,e,i)}return this}addRowVector(t){t=w(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)+t[n]);return this}subRowVector(t){t=w(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)-t[n]);return this}mulRowVector(t){t=w(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)*t[n]);return this}divRowVector(t){t=w(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)/t[n]);return this}addColumnVector(t){t=S(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)+t[e]);return this}subColumnVector(t){t=S(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)-t[e]);return this}mulColumnVector(t){t=S(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)*t[e]);return this}divColumnVector(t){t=S(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)/t[e]);return this}mulRow(t,e){y(this,t);for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)*e);return this}mulColumn(t,e){b(this,t);for(let n=0;n<this.rows;n++)this.set(n,t,this.get(n,t)*e);return this}max(t){if(this.isEmpty())return NaN;switch(t){case"row":{const t=new Array(this.rows).fill(Number.NEGATIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.get(e,n)>t[e]&&(t[e]=this.get(e,n));return t}case"column":{const t=new Array(this.columns).fill(Number.NEGATIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.get(e,n)>t[n]&&(t[n]=this.get(e,n));return t}case void 0:{let t=this.get(0,0);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.get(e,n)>t&&(t=this.get(e,n));return t}default:throw new Error(`invalid option: ${t}`)}}maxIndex(){E(this);let t=this.get(0,0),e=[0,0];for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.get(n,i)>t&&(t=this.get(n,i),e[0]=n,e[1]=i);return e}min(t){if(this.isEmpty())return NaN;switch(t){case"row":{const t=new Array(this.rows).fill(Number.POSITIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.get(e,n)<t[e]&&(t[e]=this.get(e,n));return t}case"column":{const t=new Array(this.columns).fill(Number.POSITIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.get(e,n)<t[n]&&(t[n]=this.get(e,n));return t}case void 0:{let t=this.get(0,0);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.get(e,n)<t&&(t=this.get(e,n));return t}default:throw new Error(`invalid option: ${t}`)}}minIndex(){E(this);let t=this.get(0,0),e=[0,0];for(let n=0;n<this.rows;n++)for(let i=0;i<this.columns;i++)this.get(n,i)<t&&(t=this.get(n,i),e[0]=n,e[1]=i);return e}maxRow(t){if(y(this,t),this.isEmpty())return NaN;let e=this.get(t,0);for(let n=1;n<this.columns;n++)this.get(t,n)>e&&(e=this.get(t,n));return e}maxRowIndex(t){y(this,t),E(this);let e=this.get(t,0),n=[t,0];for(let i=1;i<this.columns;i++)this.get(t,i)>e&&(e=this.get(t,i),n[1]=i);return n}minRow(t){if(y(this,t),this.isEmpty())return NaN;let e=this.get(t,0);for(let n=1;n<this.columns;n++)this.get(t,n)<e&&(e=this.get(t,n));return e}minRowIndex(t){y(this,t),E(this);let e=this.get(t,0),n=[t,0];for(let i=1;i<this.columns;i++)this.get(t,i)<e&&(e=this.get(t,i),n[1]=i);return n}maxColumn(t){if(b(this,t),this.isEmpty())return NaN;let e=this.get(0,t);for(let n=1;n<this.rows;n++)this.get(n,t)>e&&(e=this.get(n,t));return e}maxColumnIndex(t){b(this,t),E(this);let e=this.get(0,t),n=[0,t];for(let i=1;i<this.rows;i++)this.get(i,t)>e&&(e=this.get(i,t),n[0]=i);return n}minColumn(t){if(b(this,t),this.isEmpty())return NaN;let e=this.get(0,t);for(let n=1;n<this.rows;n++)this.get(n,t)<e&&(e=this.get(n,t));return e}minColumnIndex(t){b(this,t),E(this);let e=this.get(0,t),n=[0,t];for(let i=1;i<this.rows;i++)this.get(i,t)<e&&(e=this.get(i,t),n[0]=i);return n}diag(){let t=Math.min(this.rows,this.columns),e=[];for(let n=0;n<t;n++)e.push(this.get(n,n));return e}norm(t="frobenius"){let e=0;if("max"===t)return this.max();if("frobenius"===t){for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)e+=this.get(t,n)*this.get(t,n);return Math.sqrt(e)}throw new RangeError(`unknown norm type: ${t}`)}cumulativeSum(){let t=0;for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)t+=this.get(e,n),this.set(e,n,t);return this}dot(t){A.isMatrix(t)&&(t=t.to1DArray());let e=this.to1DArray();if(e.length!==t.length)throw new RangeError("vectors do not have the same size");let n=0;for(let i=0;i<e.length;i++)n+=e[i]*t[i];return n}mmul(t){t=P.checkMatrix(t);let e=this.rows,n=this.columns,i=t.columns,o=new P(e,i),s=new Float64Array(n);for(let r=0;r<i;r++){for(let e=0;e<n;e++)s[e]=t.get(e,r);for(let t=0;t<e;t++){let e=0;for(let i=0;i<n;i++)e+=this.get(t,i)*s[i];o.set(t,r,e)}}return o}strassen2x2(t){t=P.checkMatrix(t);let e=new P(2,2);const n=this.get(0,0),i=t.get(0,0),o=this.get(0,1),s=t.get(0,1),r=this.get(1,0),a=t.get(1,0),l=this.get(1,1),c=t.get(1,1),h=(n+l)*(i+c),u=(r+l)*i,d=n*(s-c),f=l*(a-i),m=(n+o)*c,p=h+f-m+(o-l)*(a+c),g=d+m,v=u+f,y=h-u+d+(r-n)*(i+s);return e.set(0,0,p),e.set(0,1,g),e.set(1,0,v),e.set(1,1,y),e}strassen3x3(t){t=P.checkMatrix(t);let e=new P(3,3);const n=this.get(0,0),i=this.get(0,1),o=this.get(0,2),s=this.get(1,0),r=this.get(1,1),a=this.get(1,2),l=this.get(2,0),c=this.get(2,1),h=this.get(2,2),u=t.get(0,0),d=t.get(0,1),f=t.get(0,2),m=t.get(1,0),p=t.get(1,1),g=t.get(1,2),v=t.get(2,0),y=t.get(2,1),b=t.get(2,2),w=(n-s)*(-d+p),S=(-n+s+r)*(u-d+p),C=(s+r)*(-u+d),T=n*u,M=(-n+l+c)*(u-f+g),E=(-n+l)*(f-g),A=(l+c)*(-u+f),N=(-o+c+h)*(p+v-y),x=(o-h)*(p-y),_=o*v,R=(c+h)*(-v+y),L=(-o+r+a)*(g+v-b),I=(o-a)*(g-b),G=(r+a)*(-v+b),D=T+_+i*m,W=(n+i+o-s-r-c-h)*p+S+C+T+N+_+R,F=T+M+A+(n+i+o-r-a-l-c)*g+_+L+G,H=w+r*(-u+d+m-p-g-v+b)+S+T+_+L+I,k=w+S+C+T+a*y,O=_+L+I+G+s*f,V=T+M+E+c*(-u+f+m-p-g-v+y)+N+x+_,U=N+x+_+R+l*d,B=T+M+E+A+h*b;return e.set(0,0,D),e.set(0,1,W),e.set(0,2,F),e.set(1,0,H),e.set(1,1,k),e.set(1,2,O),e.set(2,0,V),e.set(2,1,U),e.set(2,2,B),e}mmulStrassen(t){t=P.checkMatrix(t);let e=this.clone(),n=e.rows,i=e.columns,o=t.rows,s=t.columns;function r(t,e,n){let i=t.rows,o=t.columns;if(i===e&&o===n)return t;{let i=A.zeros(e,n);return i=i.setSubMatrix(t,0,0),i}}i!==o&&console.warn(`Multiplying ${n} x ${i} and ${o} x ${s} matrix: dimensions do not match.`);let a=Math.max(n,o),l=Math.max(i,s);return e=r(e,a,l),function t(e,n,i,o){if(i<=512||o<=512)return e.mmul(n);i%2==1&&o%2==1?(e=r(e,i+1,o+1),n=r(n,i+1,o+1)):i%2==1?(e=r(e,i+1,o),n=r(n,i+1,o)):o%2==1&&(e=r(e,i,o+1),n=r(n,i,o+1));let s=parseInt(e.rows/2,10),a=parseInt(e.columns/2,10),l=e.subMatrix(0,s-1,0,a-1),c=n.subMatrix(0,s-1,0,a-1),h=e.subMatrix(0,s-1,a,e.columns-1),u=n.subMatrix(0,s-1,a,n.columns-1),d=e.subMatrix(s,e.rows-1,0,a-1),f=n.subMatrix(s,n.rows-1,0,a-1),m=e.subMatrix(s,e.rows-1,a,e.columns-1),p=n.subMatrix(s,n.rows-1,a,n.columns-1),g=t(A.add(l,m),A.add(c,p),s,a),v=t(A.add(d,m),c,s,a),y=t(l,A.sub(u,p),s,a),b=t(m,A.sub(f,c),s,a),w=t(A.add(l,h),p,s,a),S=t(A.sub(d,l),A.add(c,u),s,a),C=t(A.sub(h,m),A.add(f,p),s,a),T=A.add(g,b);T.sub(w),T.add(C);let M=A.add(y,w),E=A.add(v,b),N=A.sub(g,v);N.add(y),N.add(S);let P=A.zeros(2*T.rows,2*T.columns);return P=P.setSubMatrix(T,0,0),P=P.setSubMatrix(M,T.rows,0),P=P.setSubMatrix(E,0,T.columns),P=P.setSubMatrix(N,T.rows,T.columns),P.subMatrix(0,i-1,0,o-1)}(e,t=r(t,a,l),a,l)}scaleRows(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{min:e=0,max:n=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(n))throw new TypeError("max must be a number");if(e>=n)throw new RangeError("min must be smaller than max");let i=new P(this.rows,this.columns);for(let t=0;t<this.rows;t++){const o=this.getRow(t);o.length>0&&d(o,{min:e,max:n,output:o}),i.setRow(t,o)}return i}scaleColumns(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{min:e=0,max:n=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(n))throw new TypeError("max must be a number");if(e>=n)throw new RangeError("min must be smaller than max");let i=new P(this.rows,this.columns);for(let t=0;t<this.columns;t++){const o=this.getColumn(t);o.length&&d(o,{min:e,max:n,output:o}),i.setColumn(t,o)}return i}flipRows(){const t=Math.ceil(this.columns/2);for(let e=0;e<this.rows;e++)for(let n=0;n<t;n++){let t=this.get(e,n),i=this.get(e,this.columns-1-n);this.set(e,n,i),this.set(e,this.columns-1-n,t)}return this}flipColumns(){const t=Math.ceil(this.rows/2);for(let e=0;e<this.columns;e++)for(let n=0;n<t;n++){let t=this.get(n,e),i=this.get(this.rows-1-n,e);this.set(n,e,i),this.set(this.rows-1-n,e,t)}return this}kroneckerProduct(t){t=P.checkMatrix(t);let e=this.rows,n=this.columns,i=t.rows,o=t.columns,s=new P(e*i,n*o);for(let r=0;r<e;r++)for(let e=0;e<n;e++)for(let n=0;n<i;n++)for(let a=0;a<o;a++)s.set(i*r+n,o*e+a,this.get(r,e)*t.get(n,a));return s}kroneckerSum(t){if(t=P.checkMatrix(t),!this.isSquare()||!t.isSquare())throw new Error("Kronecker Sum needs two Square Matrices");let e=this.rows,n=t.rows,i=this.kroneckerProduct(P.eye(n,n)),o=P.eye(e,e).kroneckerProduct(t);return i.add(o)}transpose(){let t=new P(this.columns,this.rows);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)t.set(n,e,this.get(e,n));return t}sortRows(t=N){for(let e=0;e<this.rows;e++)this.setRow(e,this.getRow(e).sort(t));return this}sortColumns(t=N){for(let e=0;e<this.columns;e++)this.setColumn(e,this.getColumn(e).sort(t));return this}subMatrix(t,e,n,i){C(this,t,e,n,i);let o=new P(e-t+1,i-n+1);for(let s=t;s<=e;s++)for(let e=n;e<=i;e++)o.set(s-t,e-n,this.get(s,e));return o}subMatrixRow(t,e,n){if(void 0===e&&(e=0),void 0===n&&(n=this.columns-1),e>n||e<0||e>=this.columns||n<0||n>=this.columns)throw new RangeError("Argument out of range");let i=new P(t.length,n-e+1);for(let o=0;o<t.length;o++)for(let s=e;s<=n;s++){if(t[o]<0||t[o]>=this.rows)throw new RangeError(`Row index out of range: ${t[o]}`);i.set(o,s-e,this.get(t[o],s))}return i}subMatrixColumn(t,e,n){if(void 0===e&&(e=0),void 0===n&&(n=this.rows-1),e>n||e<0||e>=this.rows||n<0||n>=this.rows)throw new RangeError("Argument out of range");let i=new P(n-e+1,t.length);for(let o=0;o<t.length;o++)for(let s=e;s<=n;s++){if(t[o]<0||t[o]>=this.columns)throw new RangeError(`Column index out of range: ${t[o]}`);i.set(s-e,o,this.get(s,t[o]))}return i}setSubMatrix(t,e,n){if((t=P.checkMatrix(t)).isEmpty())return this;C(this,e,e+t.rows-1,n,n+t.columns-1);for(let i=0;i<t.rows;i++)for(let o=0;o<t.columns;o++)this.set(e+i,n+o,t.get(i,o));return this}selection(t,e){!function(t,e){if(!a(e))throw new TypeError("row indices must be an array");for(let n=0;n<e.length;n++)if(e[n]<0||e[n]>=t.rows)throw new RangeError("row indices are out of range")}(this,t),function(t,e){if(!a(e))throw new TypeError("column indices must be an array");for(let n=0;n<e.length;n++)if(e[n]<0||e[n]>=t.columns)throw new RangeError("column indices are out of range")}(this,e);let n=new P(t.length,e.length);for(let i=0;i<t.length;i++){let o=t[i];for(let t=0;t<e.length;t++){let s=e[t];n.set(i,t,this.get(o,s))}}return n}trace(){let t=Math.min(this.rows,this.columns),e=0;for(let n=0;n<t;n++)e+=this.get(n,n);return e}clone(){let t=new P(this.rows,this.columns);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)t.set(e,n,this.get(e,n));return t}sum(t){switch(t){case"row":return function(t){let e=T(t.rows);for(let n=0;n<t.rows;++n)for(let i=0;i<t.columns;++i)e[n]+=t.get(n,i);return e}(this);case"column":return function(t){let e=T(t.columns);for(let n=0;n<t.rows;++n)for(let i=0;i<t.columns;++i)e[i]+=t.get(n,i);return e}(this);case void 0:return function(t){let e=0;for(let n=0;n<t.rows;n++)for(let i=0;i<t.columns;i++)e+=t.get(n,i);return e}(this);default:throw new Error(`invalid option: ${t}`)}}product(t){switch(t){case"row":return function(t){let e=T(t.rows,1);for(let n=0;n<t.rows;++n)for(let i=0;i<t.columns;++i)e[n]*=t.get(n,i);return e}(this);case"column":return function(t){let e=T(t.columns,1);for(let n=0;n<t.rows;++n)for(let i=0;i<t.columns;++i)e[i]*=t.get(n,i);return e}(this);case void 0:return function(t){let e=1;for(let n=0;n<t.rows;n++)for(let i=0;i<t.columns;i++)e*=t.get(n,i);return e}(this);default:throw new Error(`invalid option: ${t}`)}}mean(t){const e=this.sum(t);switch(t){case"row":for(let t=0;t<this.rows;t++)e[t]/=this.columns;return e;case"column":for(let t=0;t<this.columns;t++)e[t]/=this.rows;return e;case void 0:return e/this.size;default:throw new Error(`invalid option: ${t}`)}}variance(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");const{unbiased:n=!0,mean:i=this.mean(t)}=e;if("boolean"!=typeof n)throw new TypeError("unbiased must be a boolean");switch(t){case"row":if(!a(i))throw new TypeError("mean must be an array");return function(t,e,n){const i=t.rows,o=t.columns,s=[];for(let r=0;r<i;r++){let i=0,a=0,l=0;for(let e=0;e<o;e++)l=t.get(r,e)-n[r],i+=l,a+=l*l;e?s.push((a-i*i/o)/(o-1)):s.push((a-i*i/o)/o)}return s}(this,n,i);case"column":if(!a(i))throw new TypeError("mean must be an array");return function(t,e,n){const i=t.rows,o=t.columns,s=[];for(let r=0;r<o;r++){let o=0,a=0,l=0;for(let e=0;e<i;e++)l=t.get(e,r)-n[r],o+=l,a+=l*l;e?s.push((a-o*o/i)/(i-1)):s.push((a-o*o/i)/i)}return s}(this,n,i);case void 0:if("number"!=typeof i)throw new TypeError("mean must be a number");return function(t,e,n){const i=t.rows,o=t.columns,s=i*o;let r=0,a=0,l=0;for(let e=0;e<i;e++)for(let i=0;i<o;i++)l=t.get(e,i)-n,r+=l,a+=l*l;return e?(a-r*r/s)/(s-1):(a-r*r/s)/s}(this,n,i);default:throw new Error(`invalid option: ${t}`)}}standardDeviation(t,e){"object"==typeof t&&(e=t,t=void 0);const n=this.variance(t,e);if(void 0===t)return Math.sqrt(n);for(let t=0;t<n.length;t++)n[t]=Math.sqrt(n[t]);return n}center(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");const{center:n=this.mean(t)}=e;switch(t){case"row":if(!a(n))throw new TypeError("center must be an array");return function(t,e){for(let n=0;n<t.rows;n++)for(let i=0;i<t.columns;i++)t.set(n,i,t.get(n,i)-e[n])}(this,n),this;case"column":if(!a(n))throw new TypeError("center must be an array");return function(t,e){for(let n=0;n<t.rows;n++)for(let i=0;i<t.columns;i++)t.set(n,i,t.get(n,i)-e[i])}(this,n),this;case void 0:if("number"!=typeof n)throw new TypeError("center must be a number");return function(t,e){for(let n=0;n<t.rows;n++)for(let i=0;i<t.columns;i++)t.set(n,i,t.get(n,i)-e)}(this,n),this;default:throw new Error(`invalid option: ${t}`)}}scale(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");let n=e.scale;switch(t){case"row":if(void 0===n)n=function(t){const e=[];for(let n=0;n<t.rows;n++){let i=0;for(let e=0;e<t.columns;e++)i+=Math.pow(t.get(n,e),2)/(t.columns-1);e.push(Math.sqrt(i))}return e}(this);else if(!a(n))throw new TypeError("scale must be an array");return function(t,e){for(let n=0;n<t.rows;n++)for(let i=0;i<t.columns;i++)t.set(n,i,t.get(n,i)/e[n])}(this,n),this;case"column":if(void 0===n)n=function(t){const e=[];for(let n=0;n<t.columns;n++){let i=0;for(let e=0;e<t.rows;e++)i+=Math.pow(t.get(e,n),2)/(t.rows-1);e.push(Math.sqrt(i))}return e}(this);else if(!a(n))throw new TypeError("scale must be an array");return function(t,e){for(let n=0;n<t.rows;n++)for(let i=0;i<t.columns;i++)t.set(n,i,t.get(n,i)/e[i])}(this,n),this;case void 0:if(void 0===n)n=function(t){const e=t.size-1;let n=0;for(let i=0;i<t.columns;i++)for(let o=0;o<t.rows;o++)n+=Math.pow(t.get(o,i),2)/e;return Math.sqrt(n)}(this);else if("number"!=typeof n)throw new TypeError("scale must be a number");return function(t,e){for(let n=0;n<t.rows;n++)for(let i=0;i<t.columns;i++)t.set(n,i,t.get(n,i)/e)}(this,n),this;default:throw new Error(`invalid option: ${t}`)}}toString(t){return p(this,t)}}function N(t,e){return t-e}A.prototype.klass="Matrix","undefined"!=typeof Symbol&&(A.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return p(this)}),A.random=A.rand,A.randomInt=A.randInt,A.diagonal=A.diag,A.prototype.diagonal=A.prototype.diag,A.identity=A.eye,A.prototype.negate=A.prototype.neg,A.prototype.tensorProduct=A.prototype.kroneckerProduct;class P extends A{constructor(t,e){if(super(),P.isMatrix(t))return t.clone();if(Number.isInteger(t)&&t>=0){if(this.data=[],!(Number.isInteger(e)&&e>=0))throw new TypeError("nColumns must be a positive integer");for(let n=0;n<t;n++)this.data.push(new Float64Array(e))}else{if(!a(t))throw new TypeError("First argument must be a positive number or an array");{const n=t;if("number"!=typeof(e=(t=n.length)?n[0].length:0))throw new TypeError("Data must be a 2D array with at least one element");this.data=[];for(let i=0;i<t;i++){if(n[i].length!==e)throw new RangeError("Inconsistent array dimensions");if(!n[i].every((t=>"number"==typeof t)))throw new TypeError("Input data contains non-numeric values");this.data.push(Float64Array.from(n[i]))}}}this.rows=t,this.columns=e}set(t,e,n){return this.data[t][e]=n,this}get(t,e){return this.data[t][e]}removeRow(t){return y(this,t),this.data.splice(t,1),this.rows-=1,this}addRow(t,e){return void 0===e&&(e=t,t=this.rows),y(this,t,!0),e=Float64Array.from(w(this,e)),this.data.splice(t,0,e),this.rows+=1,this}removeColumn(t){b(this,t);for(let e=0;e<this.rows;e++){const n=new Float64Array(this.columns-1);for(let i=0;i<t;i++)n[i]=this.data[e][i];for(let i=t+1;i<this.columns;i++)n[i-1]=this.data[e][i];this.data[e]=n}return this.columns-=1,this}addColumn(t,e){void 0===e&&(e=t,t=this.columns),b(this,t,!0),e=S(this,e);for(let n=0;n<this.rows;n++){const i=new Float64Array(this.columns+1);let o=0;for(;o<t;o++)i[o]=this.data[n][o];for(i[o++]=e[n];o<this.columns+1;o++)i[o]=this.data[n][o-1];this.data[n]=i}return this.columns+=1,this}}!function(t,e){t.prototype.add=function(t){return"number"==typeof t?this.addS(t):this.addM(t)},t.prototype.addS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)+t);return this},t.prototype.addM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)+t.get(e,n));return this},t.add=function(t,n){return new e(t).add(n)},t.prototype.sub=function(t){return"number"==typeof t?this.subS(t):this.subM(t)},t.prototype.subS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)-t);return this},t.prototype.subM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)-t.get(e,n));return this},t.sub=function(t,n){return new e(t).sub(n)},t.prototype.subtract=t.prototype.sub,t.prototype.subtractS=t.prototype.subS,t.prototype.subtractM=t.prototype.subM,t.subtract=t.sub,t.prototype.mul=function(t){return"number"==typeof t?this.mulS(t):this.mulM(t)},t.prototype.mulS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)*t);return this},t.prototype.mulM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)*t.get(e,n));return this},t.mul=function(t,n){return new e(t).mul(n)},t.prototype.multiply=t.prototype.mul,t.prototype.multiplyS=t.prototype.mulS,t.prototype.multiplyM=t.prototype.mulM,t.multiply=t.mul,t.prototype.div=function(t){return"number"==typeof t?this.divS(t):this.divM(t)},t.prototype.divS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)/t);return this},t.prototype.divM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)/t.get(e,n));return this},t.div=function(t,n){return new e(t).div(n)},t.prototype.divide=t.prototype.div,t.prototype.divideS=t.prototype.divS,t.prototype.divideM=t.prototype.divM,t.divide=t.div,t.prototype.mod=function(t){return"number"==typeof t?this.modS(t):this.modM(t)},t.prototype.modS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)%t);return this},t.prototype.modM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)%t.get(e,n));return this},t.mod=function(t,n){return new e(t).mod(n)},t.prototype.modulus=t.prototype.mod,t.prototype.modulusS=t.prototype.modS,t.prototype.modulusM=t.prototype.modM,t.modulus=t.mod,t.prototype.and=function(t){return"number"==typeof t?this.andS(t):this.andM(t)},t.prototype.andS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)&t);return this},t.prototype.andM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)&t.get(e,n));return this},t.and=function(t,n){return new e(t).and(n)},t.prototype.or=function(t){return"number"==typeof t?this.orS(t):this.orM(t)},t.prototype.orS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)|t);return this},t.prototype.orM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)|t.get(e,n));return this},t.or=function(t,n){return new e(t).or(n)},t.prototype.xor=function(t){return"number"==typeof t?this.xorS(t):this.xorM(t)},t.prototype.xorS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)^t);return this},t.prototype.xorM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)^t.get(e,n));return this},t.xor=function(t,n){return new e(t).xor(n)},t.prototype.leftShift=function(t){return"number"==typeof t?this.leftShiftS(t):this.leftShiftM(t)},t.prototype.leftShiftS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)<<t);return this},t.prototype.leftShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)<<t.get(e,n));return this},t.leftShift=function(t,n){return new e(t).leftShift(n)},t.prototype.signPropagatingRightShift=function(t){return"number"==typeof t?this.signPropagatingRightShiftS(t):this.signPropagatingRightShiftM(t)},t.prototype.signPropagatingRightShiftS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)>>t);return this},t.prototype.signPropagatingRightShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)>>t.get(e,n));return this},t.signPropagatingRightShift=function(t,n){return new e(t).signPropagatingRightShift(n)},t.prototype.rightShift=function(t){return"number"==typeof t?this.rightShiftS(t):this.rightShiftM(t)},t.prototype.rightShiftS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)>>>t);return this},t.prototype.rightShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)>>>t.get(e,n));return this},t.rightShift=function(t,n){return new e(t).rightShift(n)},t.prototype.zeroFillRightShift=t.prototype.rightShift,t.prototype.zeroFillRightShiftS=t.prototype.rightShiftS,t.prototype.zeroFillRightShiftM=t.prototype.rightShiftM,t.zeroFillRightShift=t.rightShift,t.prototype.not=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,~this.get(t,e));return this},t.not=function(t){return new e(t).not()},t.prototype.abs=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.abs(this.get(t,e)));return this},t.abs=function(t){return new e(t).abs()},t.prototype.acos=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.acos(this.get(t,e)));return this},t.acos=function(t){return new e(t).acos()},t.prototype.acosh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.acosh(this.get(t,e)));return this},t.acosh=function(t){return new e(t).acosh()},t.prototype.asin=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.asin(this.get(t,e)));return this},t.asin=function(t){return new e(t).asin()},t.prototype.asinh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.asinh(this.get(t,e)));return this},t.asinh=function(t){return new e(t).asinh()},t.prototype.atan=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.atan(this.get(t,e)));return this},t.atan=function(t){return new e(t).atan()},t.prototype.atanh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.atanh(this.get(t,e)));return this},t.atanh=function(t){return new e(t).atanh()},t.prototype.cbrt=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.cbrt(this.get(t,e)));return this},t.cbrt=function(t){return new e(t).cbrt()},t.prototype.ceil=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.ceil(this.get(t,e)));return this},t.ceil=function(t){return new e(t).ceil()},t.prototype.clz32=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.clz32(this.get(t,e)));return this},t.clz32=function(t){return new e(t).clz32()},t.prototype.cos=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.cos(this.get(t,e)));return this},t.cos=function(t){return new e(t).cos()},t.prototype.cosh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.cosh(this.get(t,e)));return this},t.cosh=function(t){return new e(t).cosh()},t.prototype.exp=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.exp(this.get(t,e)));return this},t.exp=function(t){return new e(t).exp()},t.prototype.expm1=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.expm1(this.get(t,e)));return this},t.expm1=function(t){return new e(t).expm1()},t.prototype.floor=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.floor(this.get(t,e)));return this},t.floor=function(t){return new e(t).floor()},t.prototype.fround=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.fround(this.get(t,e)));return this},t.fround=function(t){return new e(t).fround()},t.prototype.log=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log(this.get(t,e)));return this},t.log=function(t){return new e(t).log()},t.prototype.log1p=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log1p(this.get(t,e)));return this},t.log1p=function(t){return new e(t).log1p()},t.prototype.log10=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log10(this.get(t,e)));return this},t.log10=function(t){return new e(t).log10()},t.prototype.log2=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log2(this.get(t,e)));return this},t.log2=function(t){return new e(t).log2()},t.prototype.round=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.round(this.get(t,e)));return this},t.round=function(t){return new e(t).round()},t.prototype.sign=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sign(this.get(t,e)));return this},t.sign=function(t){return new e(t).sign()},t.prototype.sin=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sin(this.get(t,e)));return this},t.sin=function(t){return new e(t).sin()},t.prototype.sinh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sinh(this.get(t,e)));return this},t.sinh=function(t){return new e(t).sinh()},t.prototype.sqrt=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sqrt(this.get(t,e)));return this},t.sqrt=function(t){return new e(t).sqrt()},t.prototype.tan=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.tan(this.get(t,e)));return this},t.tan=function(t){return new e(t).tan()},t.prototype.tanh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.tanh(this.get(t,e)));return this},t.tanh=function(t){return new e(t).tanh()},t.prototype.trunc=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.trunc(this.get(t,e)));return this},t.trunc=function(t){return new e(t).trunc()},t.pow=function(t,n){return new e(t).pow(n)},t.prototype.pow=function(t){return"number"==typeof t?this.powS(t):this.powM(t)},t.prototype.powS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,Math.pow(this.get(e,n),t));return this},t.prototype.powM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,Math.pow(this.get(e,n),t.get(e,n)));return this}}(A,P);class x extends A{constructor(t){super(),this.data=t,this.rows=t.length,this.columns=t[0].length}set(t,e,n){return this.data[t][e]=n,this}get(t,e){return this.data[t][e]}}class _{constructor(t){let e,n,i,o,s,r,a,l,c,h=(t=x.checkMatrix(t)).clone(),u=h.rows,d=h.columns,f=new Float64Array(u),m=1;for(e=0;e<u;e++)f[e]=e;for(l=new Float64Array(u),n=0;n<d;n++){for(e=0;e<u;e++)l[e]=h.get(e,n);for(e=0;e<u;e++){for(c=Math.min(e,n),s=0,i=0;i<c;i++)s+=h.get(e,i)*l[i];l[e]-=s,h.set(e,n,l[e])}for(o=n,e=n+1;e<u;e++)Math.abs(l[e])>Math.abs(l[o])&&(o=e);if(o!==n){for(i=0;i<d;i++)r=h.get(o,i),h.set(o,i,h.get(n,i)),h.set(n,i,r);a=f[o],f[o]=f[n],f[n]=a,m=-m}if(n<u&&0!==h.get(n,n))for(e=n+1;e<u;e++)h.set(e,n,h.get(e,n)/h.get(n,n))}this.LU=h,this.pivotVector=f,this.pivotSign=m}isSingular(){let t=this.LU,e=t.columns;for(let n=0;n<e;n++)if(0===t.get(n,n))return!0;return!1}solve(t){t=P.checkMatrix(t);let e=this.LU;if(e.rows!==t.rows)throw new Error("Invalid matrix dimensions");if(this.isSingular())throw new Error("LU matrix is singular");let n,i,o,s=t.columns,r=t.subMatrixRow(this.pivotVector,0,s-1),a=e.columns;for(o=0;o<a;o++)for(n=o+1;n<a;n++)for(i=0;i<s;i++)r.set(n,i,r.get(n,i)-r.get(o,i)*e.get(n,o));for(o=a-1;o>=0;o--){for(i=0;i<s;i++)r.set(o,i,r.get(o,i)/e.get(o,o));for(n=0;n<o;n++)for(i=0;i<s;i++)r.set(n,i,r.get(n,i)-r.get(o,i)*e.get(n,o))}return r}get determinant(){let t=this.LU;if(!t.isSquare())throw new Error("Matrix must be square");let e=this.pivotSign,n=t.columns;for(let i=0;i<n;i++)e*=t.get(i,i);return e}get lowerTriangularMatrix(){let t=this.LU,e=t.rows,n=t.columns,i=new P(e,n);for(let o=0;o<e;o++)for(let e=0;e<n;e++)o>e?i.set(o,e,t.get(o,e)):o===e?i.set(o,e,1):i.set(o,e,0);return i}get upperTriangularMatrix(){let t=this.LU,e=t.rows,n=t.columns,i=new P(e,n);for(let o=0;o<e;o++)for(let e=0;e<n;e++)o<=e?i.set(o,e,t.get(o,e)):i.set(o,e,0);return i}get pivotPermutationVector(){return Array.from(this.pivotVector)}}function R(t,e){let n=0;return Math.abs(t)>Math.abs(e)?(n=e/t,Math.abs(t)*Math.sqrt(1+n*n)):0!==e?(n=t/e,Math.abs(e)*Math.sqrt(1+n*n)):0}class L{constructor(t){let e,n,i,o,s=(t=x.checkMatrix(t)).clone(),r=t.rows,a=t.columns,l=new Float64Array(a);for(i=0;i<a;i++){let t=0;for(e=i;e<r;e++)t=R(t,s.get(e,i));if(0!==t){for(s.get(i,i)<0&&(t=-t),e=i;e<r;e++)s.set(e,i,s.get(e,i)/t);for(s.set(i,i,s.get(i,i)+1),n=i+1;n<a;n++){for(o=0,e=i;e<r;e++)o+=s.get(e,i)*s.get(e,n);for(o=-o/s.get(i,i),e=i;e<r;e++)s.set(e,n,s.get(e,n)+o*s.get(e,i))}}l[i]=-t}this.QR=s,this.Rdiag=l}solve(t){t=P.checkMatrix(t);let e=this.QR,n=e.rows;if(t.rows!==n)throw new Error("Matrix row dimensions must agree");if(!this.isFullRank())throw new Error("Matrix is rank deficient");let i,o,s,r,a=t.columns,l=t.clone(),c=e.columns;for(s=0;s<c;s++)for(o=0;o<a;o++){for(r=0,i=s;i<n;i++)r+=e.get(i,s)*l.get(i,o);for(r=-r/e.get(s,s),i=s;i<n;i++)l.set(i,o,l.get(i,o)+r*e.get(i,s))}for(s=c-1;s>=0;s--){for(o=0;o<a;o++)l.set(s,o,l.get(s,o)/this.Rdiag[s]);for(i=0;i<s;i++)for(o=0;o<a;o++)l.set(i,o,l.get(i,o)-l.get(s,o)*e.get(i,s))}return l.subMatrix(0,c-1,0,a-1)}isFullRank(){let t=this.QR.columns;for(let e=0;e<t;e++)if(0===this.Rdiag[e])return!1;return!0}get upperTriangularMatrix(){let t,e,n=this.QR,i=n.columns,o=new P(i,i);for(t=0;t<i;t++)for(e=0;e<i;e++)t<e?o.set(t,e,n.get(t,e)):t===e?o.set(t,e,this.Rdiag[t]):o.set(t,e,0);return o}get orthogonalMatrix(){let t,e,n,i,o=this.QR,s=o.rows,r=o.columns,a=new P(s,r);for(n=r-1;n>=0;n--){for(t=0;t<s;t++)a.set(t,n,0);for(a.set(n,n,1),e=n;e<r;e++)if(0!==o.get(n,n)){for(i=0,t=n;t<s;t++)i+=o.get(t,n)*a.get(t,e);for(i=-i/o.get(n,n),t=n;t<s;t++)a.set(t,e,a.get(t,e)+i*o.get(t,n))}}return a}}class I{constructor(t,e={}){if((t=x.checkMatrix(t)).isEmpty())throw new Error("Matrix must be non-empty");let n=t.rows,i=t.columns;const{computeLeftSingularVectors:o=!0,computeRightSingularVectors:s=!0,autoTranspose:r=!1}=e;let a,l=Boolean(o),c=Boolean(s),h=!1;if(n<i)if(r){a=t.transpose(),n=a.rows,i=a.columns,h=!0;let e=l;l=c,c=e}else a=t.clone(),console.warn("Computing SVD on a matrix with more columns than rows. Consider enabling autoTranspose");else a=t.clone();let u=Math.min(n,i),d=Math.min(n+1,i),f=new Float64Array(d),m=new P(n,u),p=new P(i,i),g=new Float64Array(i),v=new Float64Array(n),y=new Float64Array(d);for(let t=0;t<d;t++)y[t]=t;let b=Math.min(n-1,i),w=Math.max(0,Math.min(i-2,n)),S=Math.max(b,w);for(let t=0;t<S;t++){if(t<b){f[t]=0;for(let e=t;e<n;e++)f[t]=R(f[t],a.get(e,t));if(0!==f[t]){a.get(t,t)<0&&(f[t]=-f[t]);for(let e=t;e<n;e++)a.set(e,t,a.get(e,t)/f[t]);a.set(t,t,a.get(t,t)+1)}f[t]=-f[t]}for(let e=t+1;e<i;e++){if(t<b&&0!==f[t]){let i=0;for(let o=t;o<n;o++)i+=a.get(o,t)*a.get(o,e);i=-i/a.get(t,t);for(let o=t;o<n;o++)a.set(o,e,a.get(o,e)+i*a.get(o,t))}g[e]=a.get(t,e)}if(l&&t<b)for(let e=t;e<n;e++)m.set(e,t,a.get(e,t));if(t<w){g[t]=0;for(let e=t+1;e<i;e++)g[t]=R(g[t],g[e]);if(0!==g[t]){g[t+1]<0&&(g[t]=0-g[t]);for(let e=t+1;e<i;e++)g[e]/=g[t];g[t+1]+=1}if(g[t]=-g[t],t+1<n&&0!==g[t]){for(let e=t+1;e<n;e++)v[e]=0;for(let e=t+1;e<n;e++)for(let n=t+1;n<i;n++)v[e]+=g[n]*a.get(e,n);for(let e=t+1;e<i;e++){let i=-g[e]/g[t+1];for(let o=t+1;o<n;o++)a.set(o,e,a.get(o,e)+i*v[o])}}if(c)for(let e=t+1;e<i;e++)p.set(e,t,g[e])}}let C=Math.min(i,n+1);if(b<i&&(f[b]=a.get(b,b)),n<C&&(f[C-1]=0),w+1<C&&(g[w]=a.get(w,C-1)),g[C-1]=0,l){for(let t=b;t<u;t++){for(let e=0;e<n;e++)m.set(e,t,0);m.set(t,t,1)}for(let t=b-1;t>=0;t--)if(0!==f[t]){for(let e=t+1;e<u;e++){let i=0;for(let o=t;o<n;o++)i+=m.get(o,t)*m.get(o,e);i=-i/m.get(t,t);for(let o=t;o<n;o++)m.set(o,e,m.get(o,e)+i*m.get(o,t))}for(let e=t;e<n;e++)m.set(e,t,-m.get(e,t));m.set(t,t,1+m.get(t,t));for(let e=0;e<t-1;e++)m.set(e,t,0)}else{for(let e=0;e<n;e++)m.set(e,t,0);m.set(t,t,1)}}if(c)for(let t=i-1;t>=0;t--){if(t<w&&0!==g[t])for(let e=t+1;e<i;e++){let n=0;for(let o=t+1;o<i;o++)n+=p.get(o,t)*p.get(o,e);n=-n/p.get(t+1,t);for(let o=t+1;o<i;o++)p.set(o,e,p.get(o,e)+n*p.get(o,t))}for(let e=0;e<i;e++)p.set(e,t,0);p.set(t,t,1)}let T=C-1,M=0,E=Number.EPSILON;for(;C>0;){let t,e;for(t=C-2;t>=-1&&-1!==t;t--){const e=Number.MIN_VALUE+E*Math.abs(f[t]+Math.abs(f[t+1]));if(Math.abs(g[t])<=e||Number.isNaN(g[t])){g[t]=0;break}}if(t===C-2)e=4;else{let n;for(n=C-1;n>=t&&n!==t;n--){let e=(n!==C?Math.abs(g[n]):0)+(n!==t+1?Math.abs(g[n-1]):0);if(Math.abs(f[n])<=E*e){f[n]=0;break}}n===t?e=3:n===C-1?e=1:(e=2,t=n)}switch(t++,e){case 1:{let e=g[C-2];g[C-2]=0;for(let n=C-2;n>=t;n--){let o=R(f[n],e),s=f[n]/o,r=e/o;if(f[n]=o,n!==t&&(e=-r*g[n-1],g[n-1]=s*g[n-1]),c)for(let t=0;t<i;t++)o=s*p.get(t,n)+r*p.get(t,C-1),p.set(t,C-1,-r*p.get(t,n)+s*p.get(t,C-1)),p.set(t,n,o)}break}case 2:{let e=g[t-1];g[t-1]=0;for(let i=t;i<C;i++){let o=R(f[i],e),s=f[i]/o,r=e/o;if(f[i]=o,e=-r*g[i],g[i]=s*g[i],l)for(let e=0;e<n;e++)o=s*m.get(e,i)+r*m.get(e,t-1),m.set(e,t-1,-r*m.get(e,i)+s*m.get(e,t-1)),m.set(e,i,o)}break}case 3:{const e=Math.max(Math.abs(f[C-1]),Math.abs(f[C-2]),Math.abs(g[C-2]),Math.abs(f[t]),Math.abs(g[t])),o=f[C-1]/e,s=f[C-2]/e,r=g[C-2]/e,a=f[t]/e,h=g[t]/e,u=((s+o)*(s-o)+r*r)/2,d=o*r*(o*r);let v=0;0===u&&0===d||(v=u<0?0-Math.sqrt(u*u+d):Math.sqrt(u*u+d),v=d/(u+v));let y=(a+o)*(a-o)+v,b=a*h;for(let e=t;e<C-1;e++){let o=R(y,b);0===o&&(o=Number.MIN_VALUE);let s=y/o,r=b/o;if(e!==t&&(g[e-1]=o),y=s*f[e]+r*g[e],g[e]=s*g[e]-r*f[e],b=r*f[e+1],f[e+1]=s*f[e+1],c)for(let t=0;t<i;t++)o=s*p.get(t,e)+r*p.get(t,e+1),p.set(t,e+1,-r*p.get(t,e)+s*p.get(t,e+1)),p.set(t,e,o);if(o=R(y,b),0===o&&(o=Number.MIN_VALUE),s=y/o,r=b/o,f[e]=o,y=s*g[e]+r*f[e+1],f[e+1]=-r*g[e]+s*f[e+1],b=r*g[e+1],g[e+1]=s*g[e+1],l&&e<n-1)for(let t=0;t<n;t++)o=s*m.get(t,e)+r*m.get(t,e+1),m.set(t,e+1,-r*m.get(t,e)+s*m.get(t,e+1)),m.set(t,e,o)}g[C-2]=y,M+=1;break}case 4:if(f[t]<=0&&(f[t]=f[t]<0?-f[t]:0,c))for(let e=0;e<=T;e++)p.set(e,t,-p.get(e,t));for(;t<T&&!(f[t]>=f[t+1]);){let e=f[t];if(f[t]=f[t+1],f[t+1]=e,c&&t<i-1)for(let n=0;n<i;n++)e=p.get(n,t+1),p.set(n,t+1,p.get(n,t)),p.set(n,t,e);if(l&&t<n-1)for(let i=0;i<n;i++)e=m.get(i,t+1),m.set(i,t+1,m.get(i,t)),m.set(i,t,e);t++}M=0,C--}}if(h){let t=p;p=m,m=t}this.m=n,this.n=i,this.s=f,this.U=m,this.V=p}solve(t){let e=t,n=this.threshold,i=this.s.length,o=P.zeros(i,i);for(let t=0;t<i;t++)Math.abs(this.s[t])<=n?o.set(t,t,0):o.set(t,t,1/this.s[t]);let s=this.U,r=this.rightSingularVectors,a=r.mmul(o),l=r.rows,c=s.rows,h=P.zeros(l,c);for(let t=0;t<l;t++)for(let e=0;e<c;e++){let n=0;for(let o=0;o<i;o++)n+=a.get(t,o)*s.get(e,o);h.set(t,e,n)}return h.mmul(e)}solveForDiagonal(t){return this.solve(P.diag(t))}inverse(){let t=this.V,e=this.threshold,n=t.rows,i=t.columns,o=new P(n,this.s.length);for(let s=0;s<n;s++)for(let n=0;n<i;n++)Math.abs(this.s[n])>e&&o.set(s,n,t.get(s,n)/this.s[n]);let s=this.U,r=s.rows,a=s.columns,l=new P(n,r);for(let t=0;t<n;t++)for(let e=0;e<r;e++){let n=0;for(let i=0;i<a;i++)n+=o.get(t,i)*s.get(e,i);l.set(t,e,n)}return l}get condition(){return this.s[0]/this.s[Math.min(this.m,this.n)-1]}get norm2(){return this.s[0]}get rank(){let t=Math.max(this.m,this.n)*this.s[0]*Number.EPSILON,e=0,n=this.s;for(let i=0,o=n.length;i<o;i++)n[i]>t&&e++;return e}get diagonal(){return Array.from(this.s)}get threshold(){return Number.EPSILON/2*Math.max(this.m,this.n)*this.s[0]}get leftSingularVectors(){return this.U}get rightSingularVectors(){return this.V}get diagonalMatrix(){return P.diag(this.s)}}function G(t,e,n,i,o){let s=n*i*i,r=P.eye(e.length,e.length,s);const a=o(e);let l=new Float64Array(t.x.length);for(let e=0;e<t.x.length;e++)l[e]=a(t.x[e]);let c=function(t,e,n,i,o){const s=n.length,r=t.x.length;let a=new Array(s);for(let l=0;l<s;l++){a[l]=new Array(r);let s=n.slice();s[l]+=i;let c=o(s);for(let n=0;n<r;n++)a[l][n]=e[n]-c(t.x[n])}return new P(a)}(t,l,e,i,o),h=function(t,e){const n=t.x.length;let i=new Array(n);for(let o=0;o<n;o++)i[o]=[t.y[o]-e[o]];return new P(i)}(t,l),u=function(t,e=!1){return t=x.checkMatrix(t),e?new I(t).inverse():function(t,e,n=!1){return t=x.checkMatrix(t),e=x.checkMatrix(e),n?new I(t).solve(e):t.isSquare()?new _(t).solve(e):new L(t).solve(e)}(t,P.eye(t.rows))}(r.add(c.mmul(c.transpose())));return(e=(e=new P([e])).sub(u.mmul(c).mmul(h).mul(i).transpose())).to1DArray()}function D(t,e,n={}){let{maxIterations:i=100,gradientDifference:r=.1,damping:a=0,errorTolerance:l=.01,minValues:c,maxValues:h,initialValues:u}=n;if(a<=0)throw new Error("The damping option must be a positive number");if(!t.x||!t.y)throw new Error("The data parameter must have x and y elements");if(!o(t.x)||t.x.length<2||!o(t.y)||t.y.length<2)throw new Error("The data parameter elements must be an array with more than 2 points");if(t.x.length!==t.y.length)throw new Error("The data parameter elements must have the same size");let d=u||new Array(e.length).fill(1),f=d.length;if(h=h||new Array(f).fill(Number.MAX_SAFE_INTEGER),c=c||new Array(f).fill(Number.MIN_SAFE_INTEGER),h.length!==c.length)throw new Error("minValues and maxValues must be the same size");if(!o(d))throw new Error("initialValues must be an array");let m,p=s(t,d,e),g=p<=l;for(m=0;m<i&&!g;m++){d=G(t,d,a,r,e);for(let t=0;t<f;t++)d[t]=Math.min(Math.max(c[t],d[t]),h[t]);if(p=s(t,d,e),isNaN(p))break;g=p<=l}return{parameterValues:d,parameterError:p,iterations:m}}},3379:t=>{"use strict";var e=[];function n(t){for(var n=-1,i=0;i<e.length;i++)if(e[i].identifier===t){n=i;break}return n}function i(t,i){for(var s={},r=[],a=0;a<t.length;a++){var l=t[a],c=i.base?l[0]+i.base:l[0],h=s[c]||0,u="".concat(c," ").concat(h);s[c]=h+1;var d=n(u),f={css:l[1],media:l[2],sourceMap:l[3],supports:l[4],layer:l[5]};if(-1!==d)e[d].references++,e[d].updater(f);else{var m=o(f,i);i.byIndex=a,e.splice(a,0,{identifier:u,updater:m,references:1})}r.push(u)}return r}function o(t,e){var n=e.domAPI(e);return n.update(t),function(e){if(e){if(e.css===t.css&&e.media===t.media&&e.sourceMap===t.sourceMap&&e.supports===t.supports&&e.layer===t.layer)return;n.update(t=e)}else n.remove()}}t.exports=function(t,o){var s=i(t=t||[],o=o||{});return function(t){t=t||[];for(var r=0;r<s.length;r++){var a=n(s[r]);e[a].references--}for(var l=i(t,o),c=0;c<s.length;c++){var h=n(s[c]);0===e[h].references&&(e[h].updater(),e.splice(h,1))}s=l}}},569:t=>{"use strict";var e={};t.exports=function(t,n){var i=function(t){if(void 0===e[t]){var n=document.querySelector(t);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(t){n=null}e[t]=n}return e[t]}(t);if(!i)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");i.appendChild(n)}},9216:t=>{"use strict";t.exports=function(t){var e=document.createElement("style");return t.setAttributes(e,t.attributes),t.insert(e,t.options),e}},3565:(t,e,n)=>{"use strict";t.exports=function(t){var e=n.nc;e&&t.setAttribute("nonce",e)}},7795:t=>{"use strict";t.exports=function(t){if("undefined"==typeof document)return{update:function(){},remove:function(){}};var e=t.insertStyleElement(t);return{update:function(n){!function(t,e,n){var i="";n.supports&&(i+="@supports (".concat(n.supports,") {")),n.media&&(i+="@media ".concat(n.media," {"));var o=void 0!==n.layer;o&&(i+="@layer".concat(n.layer.length>0?" ".concat(n.layer):""," {")),i+=n.css,o&&(i+="}"),n.media&&(i+="}"),n.supports&&(i+="}");var s=n.sourceMap;s&&"undefined"!=typeof btoa&&(i+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(s))))," */")),e.styleTagTransform(i,t,e.options)}(e,t,n)},remove:function(){!function(t){if(null===t.parentNode)return!1;t.parentNode.removeChild(t)}(e)}}}},4589:t=>{"use strict";t.exports=function(t,e){if(e.styleSheet)e.styleSheet.cssText=t;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(t))}}},7241:(t,e,n)=>{"use strict";n.d(e,{D:()=>c});var i=n(4469),o=n(976),s=n(473),r=n(8447),a=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};const l=31;function c(t,e=!1,n){return a(this,void 0,void 0,(function*(){const a=t.tags.separator,c=t.tags[o.TAGS.UNITS],u=(0,r.vU)(c,a);let d;null!=n||(n=new Map);const f="helm"===c?(0,s.getHelmMonomers)(t):Object.keys((0,r.fy)(t,0,u).freq).filter((t=>""!==t));for(let t=0;t<f.length;t++)n.has(f[t])||n.set(f[t],`${n.size+1}`);if("helm"===c)d=yield i.functions.call("HELM:getMolFiles",{col:t}),d=function(t,e,n=!1){const i=new Array(t.length);for(let o=0;o<t.length;o++){let s=0,r=0,a="\n Datagrok macromolecule handler\n\n 0 0 0 0 0 0 999 V3000\nM V30 BEGIN CTAB\n";const c=t.get(o);s=c.indexOf("\n",s)+1,s=c.indexOf("\n",s)+1,s=c.indexOf("\n",s)+1;const h=parseInt(c.substring(s,s+3)),u=parseInt(c.substring(s+3,s+6));a+=`M V30 COUNTS ${h} ${u} 0 0 0\n`,a+="M V30 BEGIN ATOM\n";for(let t=0;t<h;t++){s=c.indexOf("\n",s)+1+l,r=c.indexOf(" ",s);const i=c.substring(s,r);a+=n?`M V30 ${t+1} R${e.get(i)} 0.000 0.000 0 0\n`:`M V30 ${t+1} At 0.000 0.000 0 0 MASS=${e.get(i)}\n`}a+="M V30 END ATOM\n",a+="M V30 BEGIN BOND\n";for(let t=0;t<u;t++){s=c.indexOf("\n",s)+1;const e=parseInt(c.substring(s,s+3).trim()),n=parseInt(c.substring(s+3,s+6).trim());a+=`M V30 ${t+1} ${parseInt(c.substring(s+6,s+9).trim())} ${e} ${n}\n`}a+="M V30 END BOND\n",a+="M V30 END CTAB\n",a+="M END",i[o]=a}return i}(d,n,e);else{d=new Array(t.length);for(let i=0;i<t.length;i++){const o=h(u(t.get(i)).filter((t=>""!==t)),n,e);d[i]=o}}return o.Column.fromStrings("monomericMols",d)}))}function h(t,e,n=!1){let i="\n Datagrok macromolecule handler\n\n 0 0 0 0 0 0 999 V3000\nM V30 BEGIN CTAB\n";i+=`M V30 COUNTS ${t.length} ${t.length?t.length-1:0} 0 0 0\n`,i+="M V30 BEGIN ATOM\n";for(let o=0;o<t.length;o++)i+=n?`M V30 ${o+1} R${e.get(t[o])} 0.000 0.000 0 0\n`:`M V30 ${o+1} At 0.000 0.000 0 0 MASS=${e.get(t[o])}\n`;i+="M V30 END ATOM\n",i+="M V30 BEGIN BOND\n";for(let e=0;e<t.length-1;e++)i+=`M V30 ${e+1} 1 ${e+1} ${e+2}\n`;return i+="M V30 END BOND\n",i+="M V30 END CTAB\n",i+="M END",i}},473:(t,e,n)=>{"use strict";n.d(e,{_package:()=>Yt,activityCliffs:()=>$t,getHelmMonomers:()=>jt,getMonomerLibHelper:()=>Kt,importFasta:()=>zt,sequenceSpaceTopMenu:()=>Zt,splitToMonomers:()=>Xt,toAtomicLevel:()=>qt});var i=n(4469),o=n(3870),s=n(976),r=n(585);const a=r.GU;var l;!function(t){t.MSA="MSA",t.classic="classic"}(l||(l={}));const c=(t,e,n,i,o,s,r="rgb(100,100,100)",c=0,h=!1,u=1,d="",f=!1,m=l.classic,p={},g=0,v=null,y=[],b=null)=>{var w,S,C;o.textAlign="start";let T=s.substring(0),M=f?"":d;m===l.MSA&&(M="");let E=!0,A=!0,N="difference";null!=v&&null!=v.cell.column&&(E=null===(w=v.cell.column.temp["color-code"])||void 0===w||w,A=null===(S=v.cell.column.temp["compare-with-current"])||void 0===S||S,N=null!==(C=v.cell.column.temp["highlight-difference"])&&void 0!==C?C:"difference");const P=y[g];A&&y.length>0&&"difference"===N&&(u=T==P?.3:u),A&&y.length>0&&"equal"===N&&(u=T!=P?.3:u),null!=b&&(T=a(T,b));let x=o.measureText(T+M),_=o.measureText(T).width,R=o.measureText(T).width;const L=i/2-(x.fontBoundingBoxAscent+x.fontBoundingBoxDescent)/2+1;function I(n,i){const s=E?r:"rgb(0,0,0)";o.fillStyle=s,o.globalAlpha=u,m===l.classic&&(o.fillText(T,t+n,e+L),o.fillStyle="#808080",o.fillText(M,t+i,e+L)),m===l.MSA&&(o.fillStyle=s,o.fillText(T,t+n+(p[g]-R)/2,e+L))}if(x=x.width,m===l.MSA&&(_=p[g],x=p[g]),h||x>n)return I(5,5+_),t+_+o.measureText(M).width;{const e=(n-x)/2;return I(e,e+_),t+e+_}};var h=n(3553),u=n(8447),d=n(7331);function f(t){const e=!t.some(((e,n)=>e.length>1&&0!=n&&n!=t.length-1)),n=[],i=e?"":" ";return t.forEach(((e,o)=>{o<t.length&&(e+=`${e?"":"-"}${i}`),n.push(e)})),[n,e]}class m extends s.GridCellRenderer{get name(){return"sequence"}get cellType(){return"sequence"}get defaultHeight(){return 30}get defaultWidth(){return 230}onClick(t,e){t.cell.column.temp["current-word"]=t.cell.value,t.grid.invalidate()}onMouseMove(t,e){if("SEQ.MSA"!==t.cell.column.getTag("aligned"))return;const n=t.cell.column.temp,i=n["bio-sum-maxLengthWords"],o=n["bio-maxIndex"],s=e.offsetX-t.gridColumn.left+(t.gridColumn.left-t.bounds.x);let r=o;i[o+1]=s+1;if(s>i[0])for(;;)Math.floor((r+0)/2),s>=i[0]&&s<=i[1]||s<i[0]||i[1];i[0];const a=(t.cell.column.getTag("separator"),""),l=getSplitter("separator",a)(t.cell.value);l[0],ui.tooltip.hide()}render(t,e,n,i,o,s,r){const a=-1!==s.gridRow?s.grid:null,l=s.cell,c=s.cell.column.getTag("alphabet");getUpdatedWidth(a,t,e,i),t.save(),t.beginPath(),t.rect(e,n,i,o),t.clip(),t.font="12px monospace",t.textBaseline="top";const h=s.cell.column.getTag(DG.TAGS.UNITS),u=s.cell.column.getTag("aligned"),d=getPaletteByType(c),f=(s.cell.column.getTag("separator"),""),m=i/5,p=getSplitter(h,f,m),g=s.cell.column.temp,v=g["reference-sequence"],y=g["current-word"],b=(g["monomer-width"],p(null!=v&&""!=v?v:null!=y?y:""));let w={};if(s.cell.column.getTag(".calculatedCellRender")!==m.toString()){let t=0;for(;t<Math.min(s.cell.column.length,100);)p(s.cell.column.get(t)).forEach(((t,e)=>{const n=7*cell_renderer_monomerToShortFunction(t,8).length+5;n>(w[e],0)&&(w[e]=n)}));const e=21;for(let t=0;t<=0;t++){w[t]<e&&(w[t]=e);const n={};n[0]=w[0];for(let t=1;t<=0;t++)n[t]=n[t-1]+w[t];g["bio-sum-maxLengthWords"]=n,g["bio-maxIndex"]=0,g["bio-maxLengthWords"]=w,s.cell.column.setTag(".calculatedCellRender",m.toString())}}else g["bio-maxLengthWords"];const S=p(l.value);let C=e,T=cell_renderer_undefinedColor,M=DrawStyle.classic;u&&u.includes("MSA")&&"separator"==h&&DrawStyle.MSA,S.every(((e,r)=>{d.get(e),t.fillStyle=cell_renderer_undefinedColor;const a=r===S.length-1;return printLeftOrCentered(C,n,i,o,t,e,T,0,!0,1,f,a,M,w,r,s,b,8),50<=i})),t.restore()}}class p extends s.GridCellRenderer{get name(){return C.SEM_TYPES.MONOMER}get cellType(){return C.SEM_TYPES.MONOMER}get defaultHeight(){return 15}get defaultWidth(){return 30}render(t,e,n,i,o,s,r){t.font="12px monospace",t.textBaseline="middle",t.textAlign="center";const a=getPaletteByType(s.cell.column.getTag("alphabet")),l=s.cell.value;if(!l)return;const c=a.get(l);t.fillStyle=c,t.fillText(monomerToShort(l,3),e+i/2,n+o/2,i)}}class g extends s.GridCellRenderer{get name(){return"MacromoleculeDifferenceCR"}get cellType(){return C.SEM_TYPES.MACROMOLECULE_DIFFERENCE}get defaultHeight(){return 30}get defaultWidth(){return 230}render(t,e,n,i,o,s,r){const a=s.grid,l=(s.cell.value,""),c=s.tableColumn.tags.separator,h=s.tableColumn.tags[DG.TAGS.UNITS];getUpdatedWidth(a,t,e,i);const[u,d]=l.split("#"),f=getSplitter(h,c);v(t,e,n,i,o,f(u),f(d),h)}}function v(t,e,n,i,o,s,r,a,l,h){if(s.length!==r.length){const t=function(t,e){let n=0,i=0;const o=t.length>e.length?t:e;let s=t.length>e.length?e:t;for(let t=0;t<s.length;t++)o[t]===s[t]&&n++;const r=o.length-s.length;for(let t=o.length-1;t>r;t--)o[t]===s[t-r]&&i++;const a=new Array(Math.abs(t.length-e.length)).fill("");function l(t){return n>i?t.concat(a):a.concat(t)}return t.length>e.length?e=l(e):t=l(t),{subParts1:t,subParts2:e}}(s,r);s=t.subParts1,r=t.subParts2}const m=t.measureText(f(s).join("")),p=t.measureText(f(r).join("")),g=Math.max(m.width,p.width);l&&(i=g+4*s.length,t.canvas.width=g+4*s.length);let v=Math.max(e,e+(i-(g+4*s.length))/2);const b=Math.max(n,n+(o-28)/2);t.save(),t.beginPath(),t.rect(e,n,l?g+4*s.length:i,o),t.clip(),t.font="12px monospace",t.textBaseline="top";let w=d.UE.Color;"HELM"!=a&&(w=(0,u.py)(a.substring(a.length-2)));for(let e=0;e<s.length;e++){const n=s[e],a=r[e],l=w.get(n);if(n!=a){const s=w.get(a),r=c(v,b-7,i,o,t,n,l,0,!0),u=c(v,b+7,i,o,t,a,s,0,!0);v=Math.max(u,r),h&&(h[e]=y(n,a,l,s,b,7,o))}else v=c(v,b,i,o,t,n,l,0,!0,.5);v+=4}t.restore()}function y(t,e,n,i,o,s,r){const a=document.createElement("canvas"),l=a.getContext("2d");l.font="12px monospace";const h=l.measureText(f([t]).join("")).width,u=l.measureText(f([e]).join("")).width,d=Math.max(h,u);return a.height=r,a.width=d+4,l.font="12px monospace",l.textBaseline="top",c(0,o-s,d,r,l,t,n,0,!0),c(0,o+s,d,r,l,e,i,0,!0),a}var b,w,S=n(701),T=(n(2433),n(9298));(w=b||(b={})).Unknown="unknown",w.FR="framework",w.CDR="cdr",new class{constructor(){this.regionTypes=[b.CDR],this.chains=["Heavy","Light"],this.skipEmptyPositions=!1,this.positionWidth=16,this.positionHeight=T.ES.Entropy}};class M extends s.JsViewer{constructor(){super(),this.viewed=!1,this.regionsFg=null,this.regionsRoot=null,this.isOpened=!1,this.panelNode=null,this.regions=[],this.viewPromise=Promise.resolve(),this.host=null,this.filterSourceInput=null,this.mainLayout=null,this.logos=[],this.viewSubs=[],this.regionTypes=this.stringList("regionTypes",[vrt.CDR],{choices:Object.values(vrt).filter((t=>t!=vrt.Unknown))}),this.chains=this.stringList("chains",["Heavy","Light"],{choices:["Heavy","Light"]}),this.skipEmptyPositions=this.bool("skipEmptyPositions",!1),this.positionWidth=this.float("positionWidth",16),this.positionHeight=this.string("positionHeight",PositionHeight.Entropy,{choices:Object.keys(PositionHeight)})}init(){return __awaiter(this,void 0,void 0,(function*(){this.subs.push(ui.onSizeChanged(this.root).subscribe(this.rootOnSizeChanged.bind(this))),this.subs.push(rxjs.fromEvent(this.root,"mousemove").subscribe(this.rootOnMouseMove.bind(this)))}))}onTableAttached(){const t=Object.create(null,{onTableAttached:{get:()=>super.onTableAttached}});return __awaiter(this,void 0,void 0,(function*(){const e=t.onTableAttached.bind(this);this.viewPromise=this.viewPromise.then((()=>__awaiter(this,void 0,void 0,(function*(){e(),this.viewed||(yield this.buildView("onTableAttached"),this.viewed=!0)}))))}))}onPropertyChanged(t){if(super.onPropertyChanged(t),t)switch(t&&t.name,t.name){case"skipEmptyPositions":case"positionWidth":case"positionHeight":this.setData(this.dataFrame,this.regions)}else console.warn("Bio: VdRegionsViewer.onPropertyChanged() property is null")}setData(t,e){console.debug("Bio: VdRegionsViewer.setData()"),this.viewPromise=this.viewPromise.then((()=>__awaiter(this,void 0,void 0,(function*(){this.viewed&&(yield this.destroyView("setData"),this.viewed=!1)})))),this.regions=e,this.dataFrame=t,this.viewPromise=this.viewPromise.then((()=>__awaiter(this,void 0,void 0,(function*(){this.viewed||(yield this.buildView("setData"),this.viewed=!0)}))))}detach(){const t=super.detach.bind(this);this.viewPromise=this.viewPromise.then((()=>__awaiter(this,void 0,void 0,(function*(){this.viewed&&(yield this.destroyView("detach"),this.viewed=!1),t()}))))}destroyView(t){return __awaiter(this,void 0,void 0,(function*(){console.debug(`Bio: VdRegionsViewer.destroyView( mainLayout = ${this.mainLayout?"value":"none"} ), purpose = '${t}'`),this.filterSourceInput&&ui.empty(this.filterSourceInput.root),null!=this.mainLayout&&(this.mainLayout.remove(),this.host.remove(),this.host=null,this.mainLayout=null);for(const t of this.viewSubs)t.unsubscribe()}))}buildView(t){return __awaiter(this,void 0,void 0,(function*(){console.debug(`Bio: VdRegionsViewer.buildView() begin, purpose = '${t}'`);const e=this.regions.filter((t=>this.regionTypes.includes(t.type))),n=Array.from(new Set(e.map((t=>t.order)))).sort();this.logos=[];for(let t=0;t<n.length;t++){const i={};for(const o of this.chains){const s=e.find((e=>e.order==n[t]&&e.chain==o));i[o]=yield this.dataFrame.plot.fromType("WebLogo",{sequenceColumnName:s.sequenceColumnName,startPositionName:s.positionStartName,endPositionName:s.positionEndName,fixWidth:!0,skipEmptyPositions:this.skipEmptyPositions,positionWidth:this.positionWidth,positionHeight:this.positionHeight})}this.logos[t]=i}this.mainLayout=ui.table(this.chains,(t=>[...n.length>0?[ui.div(t,{style:{transform:"rotate(-90deg)",font:"12px Roboto, Roboto Local, sans-serif",textAlign:"center",width:"16px",marginTop:"24px",marginLeft:"6px"}})]:[],...[...Array(n.length).keys()].map((e=>{const n=this.logos[e][t];return n.root.style.height="100%",ui.div([n.root],{style:{marginTop:"4px",marginBottom:"4px"}})}))]),["",...[...Array(n.length).keys()].map((t=>e.find((e=>e.order==n[t]&&e.chain==this.chains[0])).name||"Name"))]),this.mainLayout.className="mlb-vd-regions-viewer-table2",this.filterSourceInput=ui.boolInput("",!1,this.filterSourceInputOnValueChanged.bind(this)),this.filterSourceInput.root.style.position="absolute",this.filterSourceInput.root.style.left="10px",this.filterSourceInput.root.style.top="-3px",ui.tooltip.bind(this.filterSourceInput.root,"Check to filter sequences for selected VRs"),Math.ceil(255*Math.random()).toString(16),this.host=ui.div([this.mainLayout,this.filterSourceInput.root],{}),this.root.appendChild(this.host),this.root.style.overflowX="auto",this.calcSize(),console.debug("Bio: VdRegionsViewer.buildView() end")}))}calcSize(){const t=(this.root.clientHeight-54)/this.chains.length,e=Math.min(t,Math.max(...this.logos.map((t=>Math.max(...Object.values(t).map((t=>t.maxHeight)))))));for(let t=0;t<this.logos.length;t++)for(let n=0;n<this.chains.length;n++){const i=this.chains[n];this.logos[t][i].root.style.height=`${e}px`}}rootOnSizeChanged(t){this.calcSize()}rootOnMouseMove(t){}filterSourceInputOnValueChanged(){const t=1==this.filterSourceInput.value?FilterSources.Selected:FilterSources.Filtered;for(let e=0;e<this.logos.length;e++)for(let n=0;n<this.chains.length;n++){const i=this.chains[n];this.logos[e][i].setOptions({[wlPROPS.filterSource]:t})}}}class E extends Float32Array{}function A(t){return Math.random()*t}function N(t){return Math.floor(A(t))}function P(t,e,n=0){return new Array(t).fill(n).map((()=>new E(e).fill(n)))}function x(t,e,n=1){const i=t.length;!function(t=!1,e="Assertion error."){if(!t)throw new Error(e)}(i==e.length,"Vector lengths do not match.");const o=new E(i);for(let i=0;i<t.length;++i)o[i]=t[i]+n*e[i];return o}function _(t,e){const n=function(t){let e=0;for(let n=0;n<t.length;++n)e+=t[n];return e}(function(t){const e=t.length,n=new E(e);for(let e=0;e<t.length;++e)n[e]=t[e]*t[e];return n}(x(t,e,-1)));return Math.sqrt(n)}var R=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};var L=n(7983),I=n(499),G=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};function D(t){return G(this,void 0,void 0,(function*(){const e=new I.C(t.seqCol);if(e.isFasta()){const i=e.getDistanceFunctionName(),o=yield function(t,e,i,o){return R(this,void 0,void 0,(function*(){const s=yield function(t,e,i){return new Promise((function(o,s){const r=new Worker(new URL(n.p+n.u(105),n.b));r.postMessage({columnData:t.data,method:e,measure:t.metric,options:i}),r.onmessage=({data:{error:t,distance:e,embedding:n}})=>{t?s(t):o({distance:e,embedding:n})}}))}({data:t,metric:i},e,o);return s.embedding=s.embedding.map((t=>function(t){let e=0,n=0;for(let n=0;n<t.length;++n)e+=t[n];e/=t.length;for(let i=0;i<t.length;++i)n+=(t[i]-e)*(t[i]-e);n=Math.sqrt(n/t.length);for(let i=0;i<t.length;++i)t[i]=(t[i]-e)/n;return t}(t))),s}))}(t.seqCol.toList(),t.methodName,i,t.options);console.log(o);const r=t.embedAxesNames.map(((t,e)=>s.Column.fromFloat32Array(t,o.embedding[e])));return{distance:o.distance,coordinates:new s.ColumnList(r)}}return yield function(t){return G(this,void 0,void 0,(function*(){return t.seqCol.version!==t.seqCol.temp["last-invalidated-version"]&&(yield(0,L.HV)(t.seqCol,!1)),yield i.functions.call("Chem:getChemSpaceEmbeddings",{col:t.seqCol.temp["monomeric-mols"],methodName:t.methodName,similarityMetric:t.similarityMetric,xAxis:t.embedAxesNames[0],yAxis:t.embedAxesNames[1],options:t.options})}))}(t)}))}function W(t){const e=["Embed_X","Embed_Y"],n=t.columns.names().filter((t=>t.includes(e[0]))).length+1;return e.map((t=>`${t}_${n}`))}function F(t){return 1/(1+t)}function H(t){return 1/t-1}var k=n(489),O=n(3379),V=n.n(O),U=n(7795),B=n.n(U),Y=n(569),K=n.n(Y),$=n(3565),Z=n.n($),q=n(9216),z=n.n(q),X=n(4589),j=n.n(X),Q=n(9414),J={};J.styleTagTransform=j(),J.setAttributes=Z(),J.insert=K().bind(null,"head"),J.domAPI=B(),J.insertStyleElement=z(),V()(Q.Z,J),Q.Z&&Q.Z.locals&&Q.Z.locals;var tt=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};let et=0;const nt="cliffsDf",it=new S.Subject,ot="act_diff",st="sali",rt="sim",at="line_index",lt=["1_seq","2_seq"],ct="filterCliffs";function ht(t,e,n){const i=e.getBoundingClientRect(),o=t.clientX-i.left,s=t.clientY-i.top;let r=null,a=0;for(const t of n){const e=Math.abs(Math.hypot(t.a[0]-o,t.a[1]-s)+Math.hypot(t.b[0]-o,t.b[1]-s)-Math.hypot(t.a[0]-t.b[0],t.a[1]-t.b[1]));(!a&&e<2||e<a)&&(a=e,r=t)}return r}var ut,dt,ft,mt,pt=n(1811),gt=n(3979);(mt=ut||(ut={})).Levenshtein="Levenshtein",mt.JaroWinkler="Jaro-Winkler",mt.Manhattan="Manhattan",function(t){t.Euclidean="Euclidean"}(dt||(dt={})),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"}(ft||(ft={}));const vt={[dt.Euclidean]:_},yt={[ut.Levenshtein]:pt.T,[ut.JaroWinkler]:gt.H$,[ut.Manhattan]:function(t,e){if(t.length!==e.length)return 1;{let n=0;for(let i=1;i<t.length;i++)n+=t[i]==e[i]?0:1;return n/t.length}}},bt={[ft.Tanimoto]:function(t,e){return H(function(t,e){const n=t.trueCount()+e.trueCount();if(0==n)return 1;const i=t.andWithCountBits(e,!0);return i/(n-i)}(t,e))},[ft.Dice]:function(t,e){return H(function(t,e){const n=t.trueCount()+e.trueCount();return 0==n?0:2*t.andWithCountBits(e,!0)/n}(t,e))},[ft.Asymmetric]:function(t,e){return H(function(t,e){const n=Math.min(t.trueCount(),e.trueCount());return 0==n?0:t.andWithCountBits(e,!0)/n}(t,e))},[ft.BraunBlanquet]:function(t,e){return H(function(t,e){const n=Math.max(t.trueCount(),e.trueCount());return 0==n?0:t.andWithCountBits(e,!0)/n}(t,e))},[ft.Cosine]:function(t,e){return H(function(t,e){const n=t.trueCount()*e.trueCount();return 0==n?0:t.andWithCountBits(e,!0)/Math.sqrt(n)}(t,e))},[ft.Kulczynski]:function(t,e){return H(function(t,e){const n=t.trueCount()+e.trueCount(),i=t.trueCount()*e.trueCount();return 0==i?0:t.andWithCountBits(e,!0)*n/(2*i)}(t,e))},[ft.McConnaughey]:function(t,e){return H(function(t,e){const n=t.trueCount()+e.trueCount(),i=t.trueCount()*e.trueCount();return 0==i?0:(t.andWithCountBits(e,!0)*n-i)/i}(t,e))},[ft.RogotGoldberg]:function(t,e){return H(function(t,e){const n=t.andWithCountBits(e,!0),i=t.countBits(!0)+e.countBits(!0),o=t.length,s=o-i+n;return n==o||s==o?1:n/i+s/(2*o-i)}(t,e))},[ft.Russel]:function(t,e){return H(function(t,e){return 0==t.length?0:t.andWithCountBits(e,!0)/t.length}(t,e))},[ft.Sokal]:function(t,e){return H(function(t,e){const n=t.trueCount()+e.trueCount(),i=t.andWithCountBits(e,!0);return i/(2*n-3*i)}(t,e))},[ft.Hamming]:function(t,e){return t.trueCount()+e.trueCount()-2*t.andWithCountBits(e,!0)},[ft.Euclidean]:function(t,e){return Math.sqrt(t.trueCount()+e.trueCount()-2*t.andWithCountBits(e,!0))}};var wt,St;(St=wt||(wt={})).Vector="Vector",St.String="String",St.BitArray="BitArray",St.MacroMolecule="MacroMolecule";const Ct={[wt.Vector]:{[dt.Euclidean]:vt[dt.Euclidean]},[wt.String]:{[ut.Levenshtein]:yt[ut.Levenshtein],[ut.JaroWinkler]:yt[ut.JaroWinkler],[ut.Manhattan]:yt[ut.Manhattan]},[wt.BitArray]:{[ft.Tanimoto]:bt[ft.Tanimoto],[ft.Dice]:bt[ft.Dice],[ft.Asymmetric]:bt[ft.Asymmetric],[ft.BraunBlanquet]:bt[ft.BraunBlanquet],[ft.Cosine]:bt[ft.Cosine],[ft.Kulczynski]:bt[ft.Kulczynski],[ft.McConnaughey]:bt[ft.McConnaughey],[ft.RogotGoldberg]:bt[ft.RogotGoldberg],[ft.Russel]:bt[ft.Russel],[ft.Sokal]:bt[ft.Sokal]},[wt.MacroMolecule]:{[k.U.HAMMING]:k.o[k.U.HAMMING],[k.U.LEVENSHTEIN]:k.o[k.U.LEVENSHTEIN],[k.U.NEEDLEMANN_WUNSCH]:k.o[k.U.NEEDLEMANN_WUNSCH]}};Object.keys(Ct).reduce(((t,e)=>{for(const n of Object.keys(Ct[e]))t[n]=e;return t}),{});var Tt=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};function Mt(t,e,n,o,r){return Tt(this,void 0,void 0,(function*(){e.version!==e.temp["last-invalidated-version"]&&(yield(0,L.HV)(e,!1));const n=s.DataFrame.create(e.length);return n.columns.addNewString(o).init((t=>e.temp["monomeric-mols"].get(t))),yield i.functions.call("Chem:getChemSimilaritiesMatrix",{dim:t,col:e.temp["monomeric-mols"],df:n,colName:o,simArr:r})}))}function Et(t){const e=o.divH([]),n=o.divV([o.divText(t.seqCol.name),o.divText(t.activityCol.name)]);return n.style.fontWeight="bold",n.style.display="flex",n.style.justifyContent="space-between",e.append(n),t.line.mols.forEach(((n,i)=>{const s=o.divText(t.activityCol.get(n).toFixed(2));s.style.display="flex",s.style.justifyContent="left",s.style.paddingLeft="30px",e.append(o.divV([o.divText(t.seqCol.get(n)),s]))})),e}function At(t){const e=o.div();e.append(o.divText(t.seqCol.name,{style:{fontWeight:"bold"}}));const n=new Array(2),i=new Array(2);t.line.mols.forEach(((e,o)=>{n[o]=t.seqCol.get(e),i[o]=t.activityCol.get(e)}));const r={},a=t.seqCol.getTag(s.TAGS.UNITS),l=t.seqCol.getTag("separator"),c=(0,u.vU)(a,l),h=function(t,e,n,i){const o=document.createElement("canvas"),s=o.getContext("2d");return o.height=30,v(s,0,0,0,30,t,e,n,!0,i),o}(c(n[0]),c(n[1]),a,r);return e.append(o.div(h,{style:{width:"300px",overflow:"scroll"}})),e.append(function(t){const e=o.div();if(Object.keys(t).length>0){const n=o.divV([]);n.append(o.divH([o.divText("Pos",{style:{fontWeight:"bold",width:"30px",borderBottom:"1px solid"}}),o.divText("Difference",{style:{fontWeight:"bold",borderBottom:"1px solid"}})]));for(const e of Object.keys(t))t[e].style.borderBottom="1px solid lightgray",n.append(o.divH([o.divText((parseInt(e)+1).toString(),{style:{width:"30px",borderBottom:"1px solid lightgray"}}),t[e]]));e.append(n)}return e}(r)),e.append(Nt("Activity delta",Math.abs(i[0]-i[1]))),e.append(Nt("Cliff",t.sali)),e}function Nt(t,e){return o.divH([o.divText(`${t}: `,{style:{fontWeight:"bold",paddingRight:"5px"}}),o.divText(e.toFixed(2))],{style:{paddingTop:"10px"}})}function Pt(t,e){const n=s.Column.string("seq_diff",t.rowCount).init((n=>`${t.get(e[0],n)}#${t.get(e[1],n)}`));n.semType="MacromoleculeDifference",n.setTag(s.TAGS.UNITS,t.col(e[0]).getTag(s.TAGS.UNITS)),n.setTag("separator",t.col(e[0]).getTag("separator")),t.columns.add(n);const i=t.plot.grid();return i.col(e[0]).visible=!1,i.col(e[1]).visible=!1,i}n(4004),n(7228);var xt=n(6103),_t=n(5226);n(9133);class Rt extends s.JsViewer{constructor(t){super(),this.name="",this.metricsProperties=["distanceMetric","fingerprint"],this.fingerprintChoices=["Morgan","Pattern"],this.initialized=!1,this.tags=[DG.TAGS.UNITS,"aligned","separator","alphabet"],this.fingerprint=this.string("fingerprint",this.fingerprintChoices[0],{choices:this.fingerprintChoices}),this.limit=this.int("limit",10),this.distanceMetric=this.string("distanceMetric",CHEM_SIMILARITY_METRICS[0],{choices:CHEM_SIMILARITY_METRICS}),this.moleculeColumnName=this.string("moleculeColumnName"),this.name=t}init(){this.initialized=!0}detach(){this.subs.forEach((t=>t.unsubscribe()))}onTableAttached(){return sequence_search_base_viewer_awaiter(this,void 0,void 0,(function*(){if(this.init(),this.dataFrame){this.subs.push(DG.debounce(this.dataFrame.onRowsRemoved,50).subscribe((t=>sequence_search_base_viewer_awaiter(this,void 0,void 0,(function*(){return yield this.render()})))));const t="diversity"!==this.name;this.subs.push(DG.debounce(this.dataFrame.onCurrentRowChanged,50).subscribe((e=>sequence_search_base_viewer_awaiter(this,void 0,void 0,(function*(){return yield this.render(t)}))))),this.subs.push(DG.debounce(this.dataFrame.selection.onChanged,50).subscribe((t=>sequence_search_base_viewer_awaiter(this,void 0,void 0,(function*(){return yield this.render(!1)}))))),this.subs.push(DG.debounce(ui.onSizeChanged(this.root),50).subscribe((t=>sequence_search_base_viewer_awaiter(this,void 0,void 0,(function*(){return yield this.render(!1)}))))),this.moleculeColumn=this.dataFrame.columns.bySemType(DG.SEMTYPE.MACROMOLECULE),this.moleculeColumnName=(this.moleculeColumn,void 0),this.getProperty("limit").fromOptions({min:1,max:this.dataFrame.rowCount})}yield this.render()}))}onPropertyChanged(t){if(super.onPropertyChanged(t),this.initialized){if("moleculeColumnName"===t.name){const e=this.dataFrame.col(t.get(this));e.semType===DG.SEMTYPE.MACROMOLECULE&&(this.moleculeColumn=e)}this.render()}}render(t=!0){return sequence_search_base_viewer_awaiter(this,void 0,void 0,(function*(){}))}beforeRender(){return!(!this.initialized||this.dataFrame&&this.moleculeColumnName&&this.dataFrame.col(this.moleculeColumnName).semType!==DG.SEMTYPE.MACROMOLECULE&&(grok.shell.error(`${this.moleculeColumnName} is not Macromolecule type`),1))}}n(7241);var Lt=n(4293);n(9943),n(4413);var It=n(1061),Gt=n(1345);n(4221),n(7659);class Dt{constructor(t){var e,n,i,o,s,r,a;this.steps=null!==(e=null==t?void 0:t.steps)&&void 0!==e?e:0,this.cycles=null!==(n=null==t?void 0:t.cycles)&&void 0!==n?n:1e6,this.cutoff=null!==(i=null==t?void 0:t.cutoff)&&void 0!==i?i:0,this.lambda=null!==(o=null==t?void 0:t.lambda)&&void 0!==o?o:2,this.dlambda=null!==(s=null==t?void 0:t.dlambda)&&void 0!==s?s:.01,this.lambda2=this.lambda/2,this.dlambda2=this.dlambda/2,this.epsilon=null!==(r=null==t?void 0:t.epsilon)&&void 0!==r?r:1e-10,this.distanceFunction=null!==(a=null==t?void 0:t.distance)&&void 0!==a?a:_,this.distance=[]}initDistance(t){this.distance=function(t,e){const n=t.length,i=P(n,n,0);for(let o=0;o<n;++o)for(let s=o+1;s<n;++s){const n=null==t[o]||null==t[s]?0:e(t[o],t[s]);i[o][s]=i[s][o]=n}return i}(t,this.distanceFunction)}calcDistance(t,e,n){return this.distance[e][n]}embed(t){const e=t.length,n=function(t,e,n=1){const i=P(t,e);for(let o=0;o<t;++o)for(let t=0;t<e;++t)i[o][t]=A(n);return i}(e,Dt.dimension,40);let i=this.lambda2;0==this.steps&&(this.steps=t.length-1),this.initDistance(t);for(let o=0;o<this.cycles;++o){for(let o=0;o<this.steps;++o){const o=N(e);let s=N(e);for(;o==s;)s=N(e);const r=n[o],a=n[s],l=this.calcDistance(t,o,s),c=_(r,a);if(0==this.cutoff||l<=this.cutoff||c<l){const t=i*(l-c)/(c+this.epsilon),e=x(r,a,-1);n[o]=x(r,e,t),n[s]=x(a,e,-t)}}if(i-=this.dlambda2,i<=0)break}return n}}Dt.dimension=2;class Wt{constructor(t,e=!1){if(this._length=0,this._version=0,this._updateLevel=0,this._selectedCount=0,this._selectedCountVersion=-1,this._selectedIndexesVersion=-1,this._versionedName="",this._versionedNameVersion=-1,this.SHRINK_THRESHOLD=256,"number"==typeof t){const n=t,i=Wt._createBuffer(n);if(e)for(let t=0;t<i.length;t++)i[t]=-1;this._data=i,this._length=n}else{if(!(t instanceof Uint32Array))throw new Error("Invalid constructor");this._data=t,this._length=e}}getRawData(){return this._data}assureGoez(t,e){if(t<0)throw new Error(`${e} should be greater than zero`)}assureInRange(t,e,n,i){if(t<e||t>n)throw new Error(`Argument ${i} (${t}) out of range (${e}, ${n})`)}copy(t,e,n){for(let i=0;i<n;i++)e[i]=t[i]}copyFrom(t){if(this._length!=t._length)throw new Error(`Lengths differ (${this._length} != ${t._length})`);this.copy(t._data,this._data,this.lengthInInts),this._version++}get length(){return this._length}get buffer(){return this._data}set buffer(t){this._data=t,this._version++}get version(){return this._version}set version(t){this._version=t}incrementVersion(t=!0){this._version++}get lengthInInts(){return Math.floor((this._length+31)/32)}get versionedName(){return this._version==this._versionedNameVersion?this._versionedName:""}set versionedName(t){this._versionedName=t,this._versionedNameVersion=this._version}get self(){return this}setLength(t){if(t<0)throw new Error("should be >= 0");if(t==this._length)return;const e=Math.floor((t+31)/32);if(e>this._data.length||e+this.SHRINK_THRESHOLD<this._data.length){const t=new Uint32Array(e);this.copy(this._data,t,e>this._data.length?this._data.length:e),this._data=t}t>this._length&&(this._length%32>0&&(this._data[this.lengthInInts-1]&=(1<<(this._length%32&31))-1),this._data.fill(0,this.lengthInInts,e)),this._length=t,this._version++}static fromAnd(t,e){if(t._length!=e._length)throw new Error(`Lengths differ (${t._length} != ${e._length})`);const n=new Wt(t._length);n._length=t._length,n._data=Wt._createBuffer(n._length),n._version=0;const i=t.lengthInInts;for(let o=0;o<i;o++)n._data[o]=t._data[o]&e._data[o];return n}static _createBuffer(t){return new Uint32Array(Math.floor((t+31)/32))}static fromValues(t){const e=new Wt(t.length);e._version=0;for(let n=0;n<e._length;n++)t[n]&&(e._data[Math.floor(n/32)]|=1<<(n%32&31));return e}static fromSeq(t,e){const n=new Wt(t);for(let i=0;i<t;++i)n.setBit(i,e(i));return n._version=0,n}static fromString(t){return Wt.fromSeq(t.length,(e=>"1"==t.charAt(e)))}static fromUint32Array(t,e){const n=new Wt(t);return n._data=e,n}static fromBytes(t){const e=t.length,n=new Wt(8*e);n._data=new Uint32Array(Math.floor((e+3)/4)),n._length=8*e;let i=0,o=0;for(;e-o>=4;)n._data[i++]=255&t[o]|(255&t[o+1])<<8|(255&t[o+2])<<16|(255&t[o+3])<<24,o+=4;return e-o==3&&(n._data[i]=(255&t[o+2])<<16),e-o==2&&(n._data[i]|=(255&t[o+1])<<8),e-o==1&&(n._data[i]|=255&t[o]),n._version=0,n}toString(){return`${this._length} bits, ${this.countBits(!0)} set`}equals(t){if(this==t)return!0;if(null==t)return!1;if(this._length!=t._length)return!1;if(0==this._length)return!0;for(let e=0;e<this._data.length-1;e++)if(this._data[e]!=t._data[e])return!1;for(let e=8*(this._data.length-1);e<this._length;e++)if(this.getBit(e)!=t.getBit(e))return!1;return!0}clone(){const t=new Wt(0,!1);return t._data=Uint32Array.from(this._data),t._length=this._length,t._version=this._version,t}init(t,e){this.setAll(!1,!1);for(let e=0;e<this._length;e++)t(e)&&(this._data[Math.floor(e/32)]|=1<<(e%32&31));return this.incrementVersion(e),this}invert(t=!0){for(let t=0;t<this._data.length;t++)this._data[t]^=-1;this.incrementVersion(t)}setAll(t,e=!1){const n=t?-1:0,i=this.lengthInInts;for(let t=0;t<i;t++)this._data[t]=n;this.incrementVersion(e)}setIndexes(t,e=!0,n=!0,i=!0){n&&this.setAll(!e,!1);for(const n of t)this.setFast(n,e);this.incrementVersion(i)}everyIndex(t,e=!0){for(const n of t)if(this.getBit(n)!=e)return!1;return!0}anyIndex(t,e=!0){for(const n of t)if(this.getBit(n)==e)return!0;return!1}setWhere(t,e=!0,n=!0,i=!0,o=!0){if(n&&o&&this.setAll(!e,!1),o)for(let n=0;n<this._length;n++)t(n)&&this.setFast(n,e);else for(let n=0;n<this._length;n++)this.setFast(n,t(n)?e:!e);this.incrementVersion(i)}getRange(t,e){this.assureInRange(t,0,this._length-1,"from"),this.assureInRange(e,0,this._length,"to");const n=[];for(let i=t;i<e;++i)n.push(this.getBit(i));return Wt.fromValues(n)}getRangeAsList(t,e){this.assureInRange(t,0,this._length-1,"from"),this.assureInRange(e,0,this._length,"to");const n=[];for(let i=t;i<e;++i)n.push(this.getBit(i));return n}setRange(t,e,n,i=!0){this.assureInRange(t,0,this._length-1,"from"),this.assureInRange(e,0,this._length-1,"to");const o=Math.min(t,e),s=Math.max(t,e);if(n)for(let t=o;t<=s;t++)this.setTrue(t);else for(let t=o;t<=s;t++)this.setFalse(t);return this.incrementVersion(i),this}setRandom(t,e,n=!0){if(t<0||t>this._length)throw new Error("n must be >= 0 && <= Count");t>this._length/2&&this.setRandom(this._length-t,!e),this.setAll(!e);for(let n=0;n<t;){const t=Math.floor(Math.random()*this._length);this.getBit(t)!=e&&(this.setFast(t,e),n++)}this.incrementVersion(n)}and(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");for(let e=0,n=this.lengthInInts;e<n;e++)this._data[e]&=t._data[e];return this.incrementVersion(e),this}andNot(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");const n=this.lengthInInts;for(let e=0;e<n;e++)this._data[e]&=~t._data[e];return this.incrementVersion(e),this}notAnd(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");for(let e=0,n=this.lengthInInts;e<n;e++)this._data[e]=~this._data[e]&t._data[e];return this.incrementVersion(e),this}not(t=!0){for(let t=0,e=this.lengthInInts;t<e;t++)this._data[t]=~this._data[t];return this.incrementVersion(t),this}or(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");for(let e=0,n=this.lengthInInts;e<n;e++)this._data[e]|=t._data[e];return this.incrementVersion(e),this}xor(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");for(let e=0,n=this.lengthInInts;e<n;e++)this._data[e]^=t._data[e];return this.incrementVersion(e),this}insertAt(t,e,n=!1){if(this.assureInRange(t,0,this._length,"pos"),0==e)return;const i=this._length;this.setLength(this._length+e);for(let n=i-1;n>=t;n--)this.setBit(n+e,this.getBit(n));for(let i=t;i<t+e;i++)this.setBit(i,n)}removeAt(t,e=1){if(e<0)throw new Error("n cannot be negative");if(this.assureInRange(t,0,this._length-e,"pos"),this.contains(!0))for(let n=t;n<this._length-e;n++)this.setBit(n,this.getBit(n+e));this.setLength(this._length-e)}removeByMask(t,e=!0){if(this._length!=t.length)throw new Error("length != mask.length");if(t==this)this.setLength(t.countBits(!e)),this.setAll(!e);else{let n=0;for(let i=-1;-1!=(i=t.findNext(i,!e));)this.setFast(n++,this.getBit(i));this._length=n,this._version++}return this}getBit(t){return 0!=(this._data[Math.floor(t/32)]&1<<(31&t))}setBit(t,e,n=!0){this.setFast(t,e),this._version++}setFast(t,e){e?this._data[Math.floor(t/32)]|=1<<(31&t):this._data[Math.floor(t/32)]&=~(1<<(31&t))}setTrue(t){this._data[Math.floor(t/32)]|=1<<(31&t)}setFalse(t){this._data[Math.floor(t/32)]&=~(1<<(31&t))}trueCount(){return this.countBits(!0)}falseCount(){return this.countBits(!1)}countBits(t){if(0==this._length)return 0;if(this._selectedCountVersion!=this._version){this._selectedCount=0;const t=this.lengthInInts;let e=0;for(;e<t-1;e++)for(let t=this._data[e];0!=t;t>>>=8)this._selectedCount+=Wt._onBitCount[255&t];let n=this._data[e];const i=31&this._length;for(0!=i&&(n&=~(4294967295<<i));0!=n;n>>>=8)this._selectedCount+=Wt._onBitCount[255&n];this._selectedCountVersion=this._version}return t?this._selectedCount:this._length-this._selectedCount}countWhere(t){let e=0;if(this.trueCount()==this._length)for(let n=0;n<this._length;n++)e+=t(n)?1:0;else for(let n=-1;-1!=(n=this.findNext(n,!0));)e+=t(n)?1:0;return e}andWithCountBits(t,e){if(0==this._length)return 0;let n=0;const i=this.lengthInInts;let o=0;for(;o<i-1;o++)for(let e=this._data[o]&t._data[o];0!=e;e>>>=8)n+=Wt._onBitCount[255&e];let s=this._data[o]&t._data[o];const r=31&this._length;for(0!=r&&(s&=~(4294967295<<r));0!=s;s>>>=8)n+=Wt._onBitCount[255&s];return e?n:this._length-n}clear(){this.setLength(0)}contains(t){return this.findNext(-1,t)>=0}get allTrue(){return this.countBits(!0)==this._length}get allFalse(){return this.countBits(!1)==this._length}get anyTrue(){return this.countBits(!0)>0}get anyFalse(){return this.countBits(!1)>0}findNext(t,e=!0){if(this.assureInRange(t,-1,this._length,"index"),t>=this._length-1)return-1;let n=31&(t=t<0?0:t+1);const i=this.lengthInInts;for(let o=Math.floor(t/32);o<i;o++){let i=e?this._data[o]:~this._data[o];if(0!=n)i&=4294967295<<n&4294967295,n=0;else if(!e&&-4294967296==i)continue;for(let e=0;0!=i;e+=8,i>>>=8){const n=Wt._firstOnBit[255&i];if(n>=0)return(t=n+32*o+e)>=this._length?-1:t}}return-1}findPrev(t,e=!0){if(0==t)return-1;this.assureInRange(t,-1,this._length,"index");let n=1+(t=t<0?this._length-1:t-1)&31;for(let i=Math.floor(t/32);i>=0;i--){let t=e?this._data[i]:~this._data[i];0!=n&&(t&=~(4294967295<<n),n=0);for(let e=24;0!=t;e-=8,t<<=8){const n=Wt._lastOnBit[t>>>24];if(n>=0)return n+32*i+e}}return-1}}Wt._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]),Wt._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]),Wt._lastOnBit=Int8Array.from([-1,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7]),s.SEMTYPE.MOLECULE,s.SEMTYPE.MACROMOLECULE;var Ft,Ht=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};!function(t){t.notNull=function(t,e){if(null==t)throw new Error(`${null==e?"Value":e} not defined`)}}(Ft||(Ft={}));var kt,Ot=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};class Vt{constructor(t,e,n=!1,i){var s;this.name="",this.description="",this._isAutomatic=!1,this._autoStartFirstStep=!1,this._currentStep=0,this._isStopped=!1,this._isCancelled=!1,this._isStepProcessed=!1,this._root=o.div([],{id:"demo-script",classes:"tutorials-root tutorials-track demo-app-script"}),this._steps=[],this._mainHeader=o.panel([],"tutorials-main-header"),this._header=o.h2(""),this._headerDiv=o.divH([],"tutorials-root-header"),this._stopStartBtn=o.button(o.iconFA("pause"),(()=>this._changeStopState()),"Play / pause"),this._restartBtn=o.button(o.iconFA("redo"),(()=>this._restartScript()),"Restart"),this._nextStepBtn=o.button(o.iconFA("play"),(()=>{this._isStepProcessed||this._nextStep()}),"Next step"),this._activity=o.panel([],"tutorials-root-description"),this._progressDiv=o.divV([],"tutorials-root-progress"),this._progress=o.element("progress"),this._progressSteps=o.divText(""),this._closeBtn=o.button(o.iconFA("chevron-left"),(()=>this._closeDock()),"Back to demo"),this.name=t,this.description=e,this._isAutomatic=n,this._autoStartFirstStep=null!==(s=null==i?void 0:i.autoStartFirstStep)&&void 0!==s&&s,this._progress.max=0,this._progress.value=1,Vt.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=o.divText(`Step: ${this._progress.value} of ${this.stepNumber}`),this._progressDiv.append(this._progressSteps)}_addDescription(){var t;this._activity.append(o.div(this.description,"tutorials-root-description"));for(let e=0;e<this.stepNumber;e++){let n=o.iconFA("clock");this._isAutomatic||0===e&&(n=o.iconFA("play",(()=>this._nextStep()),"Next step"),n.className="grok-icon fas fa-play");const i=o.div(this._steps[e].name,"grok-tutorial-entry-instruction"),s=o.div(null===(t=this._steps[e].options)||void 0===t?void 0:t.description,"grok-tutorial-step-description hidden"),r=o.divH([n,i],"grok-tutorial-entry");this._activity.append(r,s)}}_initRoot(){var t,e,n;i.shell.windows.showContextPanel=!0,i.shell.windows.showHelp=!1;const o=Array.from(i.shell.dockManager.rootNode.children)[0];this._node=i.shell.dockManager.dock(this._root,s.DOCK_TYPE.FILL,o,""),(null===(e=null===(t=o.parent.container.containerElement.firstElementChild)||void 0===t?void 0:t.lastElementChild)||void 0===e?void 0:e.classList.contains("tab-handle-list-container"))&&(null===(n=o.parent.container.containerElement.firstElementChild)||void 0===n||n.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 Ot(this,void 0,void 0,(function*(){this._isStepProcessed=!0,this._isAutomatic||(this._nextStepBtn.classList.add("disabled"),this._nextStepBtn.firstChild.classList.add("fa-disabled"));const n=this._activity.getElementsByClassName("grok-tutorial-entry")[this._currentStep],i=this._activity.getElementsByClassName("grok-icon")[this._currentStep],s=this._activity.getElementsByClassName("grok-tutorial-step-description")[this._currentStep];i.className="grok-icon far fa-spinner-third fa-spin",s.classList.remove("hidden"),s.classList.add("visible");const r=n,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),yield this._countdown(n,i,a),yield function(t){return Ht(this,void 0,void 0,(function*(){yield new Promise((e=>setTimeout(e,t)))}))}(a);const l=o.iconFA("check");if(i.replaceWith(l),l.className="grok-icon far fa-check",this._progress.value++,this._progressSteps.innerText=`Step: ${this._progress.value} of ${this.stepNumber}`,this._currentStep++,this._isStepProcessed=!1,this._currentStep!==this.stepNumber){if(!this._isAutomatic){const t=this._activity.getElementsByClassName("grok-icon")[this._currentStep],e=o.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 Ot(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,n){return Ot(this,void 0,void 0,(function*(){const i=o.div([],"demo-script-countdown");e.classList.add("hidden");let s=n/1e3;const r=this._createSVGIndicator(s);i.append(r),t.prepend(i);const a=setInterval((()=>{s--,0===s&&(clearInterval(a),i.remove(),e.classList.remove("hidden"),e.classList.add("visible"))}),1e3)}))}_createSVGIndicator(t){const e=document.createElementNS("http://www.w3.org/2000/svg","svg"),n=document.createElementNS("http://www.w3.org/2000/svg","circle");return n.setAttributeNS(null,"cx","7"),n.setAttributeNS(null,"cy","7"),n.setAttributeNS(null,"r","6"),n.setAttributeNS(null,"style",`animation: countdown ${t}s linear infinite forwards`),e.append(n),e}_changeStopState(){const t=this._stopStartBtn.getElementsByClassName("grok-icon");t[0].className="grok-icon fas fa-play",this._isStopped=!this._isStopped,this._isStopped||(t[0].className="grok-icon fal fa-pause",this._isStepProcessed||this._startScript())}_restartScript(){i.shell.dockManager.close(this._node),i.shell.closeAll(),this._clearRoot(),this._setInitParams(),this.start()}_clearRoot(){this._root=o.div([],{id:"demo-script",classes:"tutorials-root tutorials-track demo-app-script"}),this._mainHeader=o.panel([],"tutorials-main-header"),this._header=o.h2(""),this._headerDiv=o.divH([],"tutorials-root-header"),this._activity=o.panel([],"tutorials-root-description"),this._progressDiv=o.divV([],"tutorials-root-progress"),this._progress=o.element("progress"),this._progressSteps=o.divText(""),this._progress.max=0,this._progress.value=1}_setInitParams(){this._currentStep=0,this._isStopped=!1,this._isCancelled=!1,this._stopStartBtn.getElementsByClassName("grok-icon")[0].className="grok-icon fal fa-pause",this._nextStepBtn.classList.remove("disabled")}_closeDock(){i.shell.dockManager.close(this._node),this.cancelScript()}cancelScript(){this._isCancelled=!0,Vt.currentObject=null}step(t,e,n){return this._steps[this.steps.length]={name:t,func:e,options:n},this}start(){return Ot(this,void 0,void 0,(function*(){this._initRoot(),i.shell.newView(this.name),this._isAutomatic?this._startScript():this._autoStartFirstStep&&(yield this._nextStep())}))}}Vt.currentObject=null,function(t){t.X="Embed_X",t.Y="Embed_Y"}(kt||(kt={})),n(3336),n(8341);var Ut=n(2568),Bt=(n(600),function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))});const Yt=new s.Package;function Kt(){return Gt.NT.instance}function $t(t,e,r,a,l,c){return Bt(this,void 0,void 0,(function*(){if(!(0,Ut.n)(e,"Activity Cliffs"))return;const h=W(t),u={units:e.getTag(s.TAGS.UNITS),aligned:e.getTag("aligned"),separator:e.getTag("separator"),alphabet:e.getTag("alphabet")},d=new I.C(e);let f="Tanimoto";return d.isFasta()&&(f=d.getDistanceFunctionName()),yield function(t,e,r,a,l,c,h,u,d,f,m,p,g,v,y,b,w,S){return tt(this,void 0,void 0,(function*(){et++;const C=h/100,T=null!=r?r:e;let M=!1,E=!1;const A={};let N,P;const x={seqCol:T,methodName:d,similarityMetric:u,embedAxesNames:a,options:w},{distance:_,coordinates:R}=yield p(x);for(const e of R)t.columns.add(e);let L=_;var I,G;Object.values(k.U).map((t=>t.toString())).includes(u)&&(L=yield(I=e,G=u,new Promise((function(t,e){const i=new Worker(new URL(n.p+n.u(367),n.b));i.postMessage({values:I.toList(),fnName:G,options:void 0}),i.onmessage=({data:{distanceMatrixData:n,error:o}})=>{o?e(o):t(n),i.terminate()}}))));const D=yield function(t,e,n,i){return tt(this,void 0,void 0,(function*(){const o=t.categories,r=t.getRawData(),a=s.Column.string("seq",t.length).init((t=>o[r[t]])),l=s.DataFrame.fromColumns([a]),c=t.length;let h=Array(c-1);return n?function(t,e,n){for(let i=0;i<t-1;++i){const o=new Float32Array(t-i-1).fill(0);for(let n=i+1;n<t;++n)o[n-i-1]=e[i][n]===s.FLOAT_NULL?0:F(e[i][n]);n[i]=s.Column.fromFloat32Array("similarity",o)}}(c,e,h):h=yield i(c,t,l,"seq",h),h}))}(T,L,!!L,g),W=function(t,e,n){const i=[],o=[],s=[],r=[],a=new Set;for(let l=0;l!=t.length;++l)for(let c=0;c!=t.length-l;++c){const h=t[l]?t[l].get(c):0;if(h>=e){s.push(l),r.push(l+c+1),a.add(l),a.add(l+c+1),i.push(h);const t=Math.abs(n.get(l)-n.get(l+c+1));1!=h?o.push(t/(1-h)):o.push(1/0)}}return{simVals:i,saliVals:o,n1:s,n2:r,cliffsMolIds:a}}(D,C,c),H=function(t,e,n,i,o,r){const a=new Array(t).fill(0);for(let t=0;t!=n.length;++t)e[t]!=1/0&&(r.get(n[t])>r.get(i[t])?a[n[t]]+=e[t]:a[i[t]]+=e[t]);return s.Column.fromList("double",`sali_${o[0].substring(o[0].lastIndexOf("_"))}`,a)}(T.length,W.saliVals,W.n1,W.n2,a,c);t.columns.add(H);const O=function(t,e){const n="containsCliff",i=t.columns.names().filter((t=>t.includes(n))).length+1,o=`${n}_${i}`;return s.Column.bool(o,t.rowCount).init((t=>e.has(t)))}(t,W.cliffsMolIds);t.columns.add(O);const V=function(t){const e=t.filter((t=>t!==1/0)),n=Math.min(...e);return{max:Math.max(...e),min:n}}(W.saliVals),U=.8/(V.max-V.min),B=i.shell.getTableView(t.name);B.grid.columns.byName(O.name).visible=!1;const Y=B.addViewer(s.VIEWER.SCATTER_PLOT,{xColumnName:a[0],yColumnName:a[1],size:H.name,color:c.name,showXSelector:!1,showYSelector:!1,showSizeSelector:!1,showColorSelector:!1,markerMinSize:5,markerMaxSize:25,title:l}),K=Y.getInfo().canvas,$=function(t,e,n,i,o){const r=new Array(t.n1.length).fill(null);for(let e=0;e<t.n1.length;e++){const n=t.n1[e],i=t.n2[e];r[e]={id:e,mols:[n,i],selected:!1,a:[],b:[]}}const a=s.DataFrame.create(r.length);return lt.forEach(((t,n)=>{a.columns.addNewString(t).init((t=>e.get(r[t].mols[n]))),function(t,e){Object.keys(e).forEach((n=>{t.tags[n]=e[n]}))}(a.col(t),o),a.col(t).semType=i})),a.columns.addNewFloat(ot).init((t=>Math.abs(n.get(r[t].mols[0])-n.get(r[t].mols[1])))),a.columns.addNewInt(at).init((t=>t)),a.columns.addNewFloat(st).init((e=>t.saliVals[e])),a.columns.addNewFloat(rt).init((e=>t.simVals[e])),a.name=`${nt}${et}`,{lines:r,linesDf:a}}(W,e,c,f,m),Z=b?b($.linesDf,lt).sort([st],[!1]):$.linesDf.plot.grid().sort([st],[!1]);t.temp[".cliffsDfGrid"]=Z;const q=o.button(`${$.linesDf.rowCount} cliffs`,(()=>{B.dockManager.dock(Z,"down",null,"Activity cliffs",null!=S?S:.2)}));q.classList.add("scatter_plot_link","cliffs_grid"),Y.root.append(q);const z=o.switchInput("Show only cliffs",!1,(()=>{z.value?(Y.dataFrame.setTag(ct,O.name),t.rows.match({[O.name]:!0}).filter(),it.next(O.name)):(Y.dataFrame.setTag(ct,""),t.filter.setAll(!0,!0),it.next(""))}));z.root.classList.add("scatter_plot_link","show_only_cliffs"),Y.root.append(z.root),it.subscribe((t=>{""!==t?t!==O.name&&(z.enabled=!1):z.enabled=!0}));const X=i.events.onViewerClosed.subscribe((t=>{t.args.viewer===Y&&(B.dockManager.close(Z.root),X.unsubscribe(),B.subs=B.subs.filter((t=>t!==X)))}));return B.subs.push(X),$.linesDf.onCurrentCellChanged.subscribe((()=>{M=!0;const n=$.linesDf.currentCol&&$.linesDf.currentCol.name===lt[1]?1:0,s=-1!==$.linesDf.currentRowIdx?$.lines[$.linesDf.currentRowIdx]:null;Y.dataFrame.currentRowIdx=s?s.mols[n]:-1,Y.dataFrame.filter.set(0,!$.lines[0].selected),Y.dataFrame.filter.set(0,$.lines[0].selected),s&&setTimeout((()=>{!function(t,e,n,s,r,a,l,c){const h=e.getPane("Cliff Details");o.empty(h.root);const u=c({cashedData:n,line:s,df:t,seqCol:r,activityCol:a,sali:l});h.root.append(u),setTimeout((()=>{i.shell.o=e.root}),500)}(t,N,A,s,e,c,$.linesDf.get(st,s.id),y);const n=Y.dataFrame.getSortedOrder(B.grid.sortByColumns,B.grid.sortTypes);B.grid.scrollToCell(e.name,n.indexOf(Y.dataFrame.currentRowIdx))}),1e3)})),$.linesDf.onSelectionChanged.subscribe((e=>{if(!1===$.linesDf.selection.anyTrue)$.lines.forEach((t=>{t.selected=!1}));else if(-1!==$.linesDf.mouseOverRowIdx){const t=$.lines[$.linesDf.mouseOverRowIdx];t.selected=!t.selected}setTimeout((()=>{const e=s.BitSet.create(t.rowCount);$.lines.forEach((t=>{t.selected&&t.mols.forEach((n=>{e.set(n,t.selected,!0)}))})),t.selection.copyFrom(e),B.grid.invalidate()}),300)})),t.onSelectionChanged.subscribe((e=>{E?E=!1:!1===t.selection.anyTrue&&"number"==typeof e&&($.lines.forEach((t=>{t.selected=!1})),Z.dataFrame.selection.setAll(!1,!1),Z.invalidate())})),K.addEventListener("mousemove",(function(i){clearTimeout(P),P=n.g.setTimeout((function(){const n=ht(i,K,$.lines);n&&-1===t.mouseOverRowIdx&&o.tooltip.show(v({cashedData:A,line:n,df:t,seqCol:e,activityCol:c}),i.clientX,i.clientY)}),500)})),K.addEventListener("mousedown",(function(e){E=!0;const n=ht(e,K,$.lines);if(n&&-1===t.mouseOverRowIdx){e.ctrlKey?(n.selected=!n.selected,$.linesDf.selection.set(n.id,n.selected)):$.linesDf.currentRowIdx!==n.id&&($.linesDf.currentRowIdx=n.id,t.currentRowIdx=n.mols[0],t.filter.set(0,!$.lines[0].selected),t.filter.set(0,$.lines[0].selected));const i=$.linesDf.getSortedOrder(Z.sortByColumns,Z.sortTypes);Z.scrollToCell(lt[0],i.indexOf(n.id))}})),Y.onEvent("d4-before-draw-scene").subscribe((e=>{const n=function(t,e,n,i,o,s,r){const a=i.lines,l=t.getInfo().canvas.getContext("2d"),c=t.dataFrame.columns.byName(e),h=t.dataFrame.columns.byName(n);for(let e=0;e<a.length;e++){const n=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=[n.x,n.y],a[e].b=[u.x,u.y];const d=new Path2D;d.moveTo(a[e].a[0],a[e].a[1]);const f=a[e].selected?"255,255,0":"0,128,0",m=o[e]===1/0?1:.2+(o[e]-r)*s;l.strokeStyle=`rgba(${f},${m})`,l.lineWidth=a[e].id===i.linesDf.currentRowIdx?3:1,d.lineTo(a[e].b[0],a[e].b[1]),l.stroke(d)}return a}(Y,a[0],a[1],$,W.saliVals,U,V.min);if(M){const t=n[$.linesDf.currentRowIdx];setTimeout((()=>{const{zoomLeft:e,zoomRight:n,zoomTop:i,zoomBottom:o}=function(t,e,n,i,o,s){const r=Math.abs(n-o),a=Math.abs(i-s),l=t/r,c=e/a,h=Math.min(l,c),u=t/h*5,d=e/h*5,f=(n<o?n:o)+r/2-u/2,m=(i>s?i:s)-a/2+d/2;return{zoomLeft:f,zoomRight:f+u,zoomTop:m,zoomBottom:m-d}}(Y.viewport.width,Y.viewport.height,Y.dataFrame.get(a[0],t.mols[0]),Y.dataFrame.get(a[1],t.mols[0]),Y.dataFrame.get(a[0],t.mols[1]),Y.dataFrame.get(a[1],t.mols[1]));Y.zoom(e,i,n,o)}),300),M=!1}z.value?t.rows.match({[O.name]:!0}).filter():!0===z.enabled&&t.filter.setAll(!0,!1)})),Y.addProperty("similarityLimit","double",C),N=function(){const t=o.accordion(),e=o.element("i");return e.className="grok-icon svg-icon svg-view-layout",t.addTitle(o.span([e,o.label("Activity cliffs")])),t.addPane("Cliff Details",(()=>o.divText("Cliff has not been selected")),!0),i.shell.o=t.root,t}(),Y}))}(t,e,null,h,"Activity cliffs",r,a,f,l,s.SEMTYPE.MACROMOLECULE,u,D,Mt,Et,At,Pt,c)}))}function Zt(t,e,n,o="Tanimoto",r,a){return Bt(this,void 0,void 0,(function*(){if(yield(0,It.gw)(10),!(0,Ut.n)(e,"Sequence space"))return;const l=W(t),c=s.DataFrame.fromColumns([e]).clone(),h=function(t,e){const n=e.categories.map(((t,e)=>t?null:e)).filter((t=>null!==t)),i=[...e.getRawData()],o=[];let s=0;for(let e=0;e<t.rowCount;e++)n.includes(i[e])&&(t.rows.removeAt(e-s),o.push(e),s+=1);return o}(c,e),u={seqCol:c.col(e.name),methodName:n,similarityMetric:o,embedAxesNames:l,options:a},d=(yield D(u)).coordinates;for(const e of d){const n=e.toList();h.forEach((t=>n.splice(t,0,null))),t.columns.add(s.Column.float(e.name,t.rowCount).init((t=>n[t])))}return r?i.shell.tableView(t.name).scatterPlot({x:l[0],y:l[1],title:"Sequence space"}):void 0}))}function qt(t,e){return Bt(this,void 0,void 0,(function*(){if(0===s.Func.find({package:"Chem",name:"getRdKitModule"}).length)return void i.shell.warning('Transformation to atomic level requires package "Chem" installed.');if(!(0,Ut.n)(e,"To Atomic Level"))return;const n=(yield Kt()).getBioLib(),r=yield(0,xt.i0)(t,e,n);null!==r.col&&(t.columns.add(r.col,!0),yield i.data.detectSemanticTypes(t)),r.warnings&&r.warnings.length>0&&i.shell.warning(o.list(r.warnings))}))}function zt(t){return new _t.i(t).importFasta()}function Xt(){const t=(0,Lt.m)(),e=function(t){const e=(0,r.Mj)(t),n=t=>{const e=a.columns.addNewString((t+1).toString());return i.push(e),e},i=[],o=t.length,a=s.DataFrame.create(o);for(let s=0;s<o;++s){const o=t.get(s);null!=o&&e(o).forEach(((t,e)=>{var o;((null!==(o=i[e])&&void 0!==o?o:null)||n(e)).set(s,t||"-",!1)}))}return a}(t),n=t.dataFrame;for(const i of e.columns){const e=n.columns.add(i);e.semType=h.Of.MONOMER,e.setTag(s.TAGS.CELL_RENDERER,h.Of.MONOMER),e.setTag("alphabet",t.getTag("alphabet"))}i.shell.tv.grid.invalidate()}function jt(t){const e=(0,u.fy)(t,1,u.gP);return Object.keys(e.freq)}},7983:(t,e,n)=>{"use strict";n.d(e,{HV:()=>h,QF:()=>c,pf:()=>l});var i=n(4469),o=(n(3870),n(976)),s=n(7241),r=(n(4293),n(1061)),a=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};function l(t,e,n){const i=n?function(t,e){const n=`${e}`.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),i=t.charAt(0)===e,o=t.charAt(t.length-1)===e,s=t.replace(new RegExp(`^${n}|${n}$`,"g"),"");return i?o?`${n}${s}${n}`:`${n}${s}${n}|${n}${s}$`:o?`^${s}${n}|${n}${s}${n}`:`^${s}${n}|${n}${s}${n}|${n}${s}$`}(t,n):t,s=o.BitSet.create(e.length);for(let n=0;n<e.length;n++){const o=e.get(n);(o.match(i)||o===t)&&s.set(n,!0,!1)}return s}function c(t,e){return a(this,void 0,void 0,(function*(){e.version!==e.temp["last-invalidated-version"]&&(yield h(e,!0));const n=o.Column.string("helm",1).init((e=>t));n.setTag(o.TAGS.UNITS,"helm");const r=yield(0,s.D)(n,!0,e.temp["monomers-dict"]);return(yield i.functions.call("Chem:searchSubstructure",{molStringsColumn:e.temp["monomeric-mols"],molString:r.get(0),molBlockFailover:""})).get(0)}))}function h(t,e){return a(this,void 0,void 0,(function*(){const n=o.TaskBarProgressIndicator.create(`Invalidating molfiles for ${t.name}`);yield(0,r.gw)(10);const i=new Map,a=yield(0,s.D)(t,e,i);t.temp["monomeric-mols"]=a,t.temp["monomers-dict"]=i,t.temp["last-invalidated-version"]=t.version,n.close()}))}},2568:(t,e,n)=>{"use strict";n.d(e,{l:()=>a,n:()=>r});var i=n(4469),o=n(976),s=n(499);function r(t,e,n=[],o=[],s=!0){const[r,l]=a(t,e,n,o);return s&&!r&&i.shell.warning(l),r}function a(t,e,n=[],r=[]){let a=!0,l="";const c=new s.C(t);if(t.semType!==o.SEMTYPE.MACROMOLECULE)i.shell.warning(e+" analysis is allowed for Macromolecules semantic type"),a=!1;else{const t=c.notation;if(n.length>0&&!n.some((e=>t.toUpperCase()==e.toUpperCase())))l=`${e} + ' analysis is allowed for Macromolecules with notation ${0==n.length?"any notation":`notation${n.length>1?"s":""} ${n.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,n)=>{"use strict";var i,o,s;n.d(e,{Of:()=>s,mU:()=>r,rs:()=>l}),function(t){t.SPLIT_COL="~split",t.ACTIVITY="~activity",t.ACTIVITY_SCALED="activity_scaled",t.ALIGNED_SEQUENCE="~aligned_sequence",t.AMINO_ACID_RESIDUE="AAR",t.POSITION="Pos",t.P_VALUE="pValue",t.MEAN_DIFFERENCE="Mean difference"}(i||(i={})),function(t){t.AAR="AAR",t.POSITION="Pos",t.SELECTION="selection"}(o||(o={})),function(t){t.MONOMER="Monomer",t.MACROMOLECULE_DIFFERENCE="MacromoleculeDifference",t.ACTIVITY="activity",t.ACTIVITY_SCALED="activityScaled"}(s||(s={}));const r="MSA";var a,l;!function(t){t.CELL_CHANGING="isCellChanging"}(a||(a={})),function(t){t.SEPARATOR="."}(l||(l={}))},4004:(t,e,n)=>{"use strict";n.d(e,{o:()=>r}),n(3870);var i=n(4469),o=(n(3336),n(7767)),s=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};function r(t,e,n){return s(this,void 0,void 0,(function*(){const s=new o.L(t).convert(e,n);t.dataFrame.columns.add(s);const r=yield i.functions.call("Bio:detectMacromolecule",{col:s});return r&&(s.semType=r),yield i.data.detectSemanticTypes(t.dataFrame),s}))}},1345:(t,e,n)=>{"use strict";n.d(e,{NT:()=>m,RV:()=>l,rb:()=>h});var i=n(976),o=n(4469),s=n(701),r=n(7228),a=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};const l="Libraries",c="System:AppData/Bio/libraries/",h={"HELMCoreLibrary.json":"HELMCoreLibrary.json"};function u(){return a(this,void 0,void 0,(function*(){return(yield o.dapi.files.list(`${c}`,!1,"")).map((t=>t.fileName))}))}function d(){return a(this,void 0,void 0,(function*(){const t=yield o.dapi.userDataStorage.getValue(l,"Settings",!0),e=t?JSON.parse(t):{exclude:[]};return e.exclude=e.exclude instanceof Array?e.exclude:[],e}))}class f{constructor(t){this._monomers={},this._onChanged=new s.Subject,this._monomers=t}getMonomer(t,e){return t in this._monomers&&e in this._monomers[t]?this._monomers[t][e]:null}getTypes(){return Object.keys(this._monomers)}getMonomerMolsByType(t){const e={};return Object.keys(this._monomers[t]).forEach((n=>{e[n]=this._monomers[t][n].molfile})),e}getMonomerNamesByType(t){return Object.keys(this._monomers[t])}get onChanged(){return this._onChanged}_updateInt(t){const e=t.getTypes(),n=this.getTypes();e.forEach((e=>{n.includes(e)||(this._monomers[e]={}),t.getMonomerNamesByType(e).forEach((n=>{this._monomers[e][n]=t.getMonomer(e,n)}))}))}update(t){this._updateInt(t),this._onChanged.next()}updateLibs(t,e=!1){e&&(this._monomers={});for(const e of t)this._updateInt(e);this._onChanged.next()}clear(){this._monomers={},this._onChanged.next()}}class m{constructor(){this._monomerLib=new f({}),this.loadLibrariesPromise=Promise.resolve()}getBioLib(){return this._monomerLib}loadLibraries(t=!1){return a(this,void 0,void 0,(function*(){return this.loadLibrariesPromise=this.loadLibrariesPromise.then((()=>a(this,void 0,void 0,(function*(){const[e,n]=yield Promise.all([u(),d()]),i=yield Promise.all(e.filter((t=>!n.exclude.includes(t))).map((t=>this.readLibrary(c,t))));this._monomerLib.updateLibs(i,t)}))))}))}readLibrary(t,e){return a(this,void 0,void 0,(function*(){let n,s,a=[];const l=new i.FileSource(t);if(e.endsWith(".sdf"))1===i.Func.find({package:"Chem",name:"importSdf"}).length?(n=yield l.readAsBytes(e),s=yield o.functions.call("Chem:importSdf",{bytes:n}),a=(0,r.Xk)(s[0])):o.shell.warning("Chem package is not installed");else{const t=yield l.readAsText(e);a=JSON.parse(t)}const c={},h=[];return a.forEach((t=>{const e={symbol:t.symbol,name:t.name,naturalAnalog:t.naturalAnalog,molfile:t.molfile,rgroups:t.rgroups,polymerType:t.polymerType,monomerType:t.monomerType,data:{}};Object.keys(t).forEach((n=>{r.DC.includes(n)||(e.data[n]=t[n])})),h.includes(t.polymerType)||(c[t.polymerType]={},h.push(t.polymerType)),c[t.polymerType][t.symbol]=e})),new f(c)}))}static get instance(){return m._instance||(m._instance=new m),m._instance}}m._instance=null},600:(t,e,n)=>{"use strict";n.d(e,{K:()=>f});var i=n(4469),o=n(976),s=n(3870),r=n(6098),a=n(8341),l=n(2568),c=n(7767),h=n(473),u=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};class d extends Error{constructor(t,e){super(t,e)}}function f(t={}){return u(this,void 0,void 0,(function*(){return new Promise(((e,n)=>u(this,void 0,void 0,(function*(){var r,l,c,h,f,g,v,y,b,w,S;null!==(r=t.clustersCol)&&void 0!==r||(t.clustersCol=null),null!==(l=t.pepsea)&&void 0!==l||(t.pepsea={}),null!==(c=(b=t.pepsea).method)&&void 0!==c||(b.method=a.J[0]),null!==(h=(w=t.pepsea).gapOpen)&&void 0!==h||(w.gapOpen=1.53),null!==(f=(S=t.pepsea).gapExtend)&&void 0!==f||(S.gapExtend=0);const C=null!==(v=null===(g=t.col)||void 0===g?void 0:g.dataFrame)&&void 0!==v?v:i.shell.t,T=null!==(y=t.col)&&void 0!==y?y:C.columns.bySemType(o.SEMTYPE.MACROMOLECULE);if(null==T){const t="MSAError: dataset doesn't conain any Macromolecule column";i.shell.warning(t),n(new d(t))}const M=s.choiceInput("Method",t.pepsea.method,a.J);M.setTooltip("Alignment method");const E=s.floatInput("Gap open",t.pepsea.gapOpen);E.setTooltip("Gap opening penalty at group-to-group alignment");const A=s.floatInput("Gap extend",t.pepsea.gapExtend);A.setTooltip("Gap extension penalty to skip the alignment");const N=[M.root.style,E.root.style,A.root.style];let P;const x=s.columnInput("Sequence",C,T,(()=>u(this,void 0,void 0,(function*(){P=yield p(x.value,C,N,M,_,E,A)}))));x.setTooltip("Sequences column to use for alignment");const _=s.columnInput("Clusters",C,t.clustersCol);if(_.nullable=!0,x.fireChanged(),t.col)return P=yield p(t.col,C,N,M,_,E,A),void(yield m(x,C,P,e,n));s.dialog("MSA").add(x).add(_).add(M).add(E).add(A).onOK((()=>u(this,void 0,void 0,(function*(){yield m(x,C,P,e,n)})))).show()}))))}))}function m(t,e,n,s,r){return u(this,void 0,void 0,(function*(){let a=null;const l=o.TaskBarProgressIndicator.create("Analyze for MSA ...");try{if(t.fireChanged(),t.value.semType!==o.SEMTYPE.MACROMOLECULE)throw new Error("Chosen column has to be of Macromolecule semantic type");if(void 0===n)throw new Error("Invalid column format");if(a=yield n(),null==a)return i.shell.warning("Wrong column format");e.columns.add(a),yield i.data.detectSemanticTypes(e),s(a)}catch(t){const e=t instanceof Error?t.message:t.toString();i.shell.error(e),r(t)}finally{l.close()}}))}function p(t,e,n,s,d,f,m){return u(this,void 0,void 0,(function*(){try{if(t.semType!==o.SEMTYPE.MACROMOLECULE)return;const i=e.columns.getUnusedName(`msa(${t.name})`);if((0,l.n)(t,t.name,["fasta","separator"],["DNA","RNA","PT"],!1)){for(const t of n)t.display="none";const e=new c.L(t),o=e.isFasta()?t:e.convert("fasta");return()=>u(this,void 0,void 0,(function*(){return yield(0,r.U)(o,!1,i,d.value)}))}if((0,l.n)(t,t.name,["helm"],[],!1)){for(const t of n)t.removeProperty("display");return()=>u(this,void 0,void 0,(function*(){return yield(0,a.f)(t,i,s.value,f.value,m.value,d.value)}))}if((0,l.n)(t,t.name,["separator"],["UN"],!1)){const e=new c.L(t);if(!(yield e.checkHelmCompatibility()))return;const o=e.convert("helm");for(const t of n)t.removeProperty("display");return console.log(o.toList()),()=>u(this,void 0,void 0,(function*(){return yield(0,a.f)(o,i,s.value,f.value,m.value,d.value)}))}for(const t of n)t.display="none";return}catch(t){const e=t instanceof Error?t.message:t.toString();i.shell.error(e),h._package.logger.error(e)}}))}},6098:(t,e,n)=>{"use strict";n.d(e,{U:()=>G});var i=n(976),o=n(5226);const s=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[s],serialize(t){const{port1:e,port2:n}=new MessageChannel;return u(t,e),[n,[n]]},deserialize:t=>(t.start(),f(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 n(i){if(!i||!i.data)return;const{id:o,type:r,path:a}=Object.assign({path:[]},i.data),c=(i.data.argumentList||[]).map(w);let h;try{const e=a.slice(0,-1).reduce(((t,e)=>t[e]),t),n=a.reduce(((t,e)=>t[e]),t);switch(r){case"GET":h=n;break;case"SET":e[a.slice(-1)[0]]=w(i.data.value),h=!0;break;case"APPLY":h=n.apply(e,c);break;case"CONSTRUCT":h=function(t){return Object.assign(t,{[s]:!0})}(new n(...c));break;case"ENDPOINT":{const{port1:e,port2:n}=new MessageChannel;u(t,n),h=function(t,e){return y.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[i,s]=b(t);e.postMessage(Object.assign(Object.assign({},i),{id:o}),s),"RELEASE"===r&&(e.removeEventListener("message",n),d(e))}))})),e.start&&e.start()}function d(t){(function(t){return"MessagePort"===t.constructor.name})(t)&&t.close()}function f(t,e){return p(t,[],e)}function m(t){if(t)throw new Error("Proxy has been released and is not useable")}function p(t,e=[],n=function(){}){let i=!1;const o=new Proxy(n,{get(n,s){if(m(i),s===a)return()=>S(t,{type:"RELEASE",path:e.map((t=>t.toString()))}).then((()=>{d(t),i=!0}));if("then"===s){if(0===e.length)return{then:()=>o};const n=S(t,{type:"GET",path:e.map((t=>t.toString()))}).then(w);return n.then.bind(n)}return p(t,[...e,s])},set(n,o,s){m(i);const[r,a]=b(s);return S(t,{type:"SET",path:[...e,o].map((t=>t.toString())),value:r},a).then(w)},apply(n,o,s){m(i);const a=e[e.length-1];if(a===r)return S(t,{type:"ENDPOINT"}).then(w);if("bind"===a)return p(t,e.slice(0,-1));const[l,c]=v(s);return S(t,{type:"APPLY",path:e.map((t=>t.toString())),argumentList:l},c).then(w)},construct(n,o){m(i);const[s,r]=v(o);return S(t,{type:"CONSTRUCT",path:e.map((t=>t.toString())),argumentList:s},r).then(w)}});return o}function g(t){return Array.prototype.concat.apply([],t)}function v(t){const e=t.map(b);return[e.map((t=>t[0])),g(e.map((t=>t[1])))]}const y=new WeakMap;function b(t){for(const[e,n]of h)if(n.canHandle(t)){const[i,o]=n.serialize(t);return[{type:"HANDLER",name:e,value:i},o]}return[{type:"RAW",value:t},y.get(t)||[]]}function w(t){switch(t.type){case"HANDLER":return h.get(t.name).deserialize(t.value);case"RAW":return t.value}}function S(t,e,n){return new Promise((i=>{const o=new Array(4).fill(0).map((()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16))).join("-");t.addEventListener("message",(function e(n){!n.data||!n.data.id||n.data.id!==o||(t.removeEventListener("message",e),i(n.data))})),t.start&&t.start(),t.postMessage(Object.assign({id:o},e),n)}))}const C="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2NvbnN0ICQ9U3ltYm9sKCJDb21saW5rLnByb3h5IiksQT1TeW1ib2woIkNvbWxpbmsuZW5kcG9pbnQiKSxSPVN5bWJvbCgiQ29tbGluay5yZWxlYXNlUHJveHkiKSx5PVN5bWJvbCgiQ29tbGluay50aHJvd24iKSxfPWU9PnR5cGVvZiBlPT0ib2JqZWN0IiYmZSE9PW51bGx8fHR5cGVvZiBlPT0iZnVuY3Rpb24iLEw9e2NhbkhhbmRsZTplPT5fKGUpJiZlWyRdLHNlcmlhbGl6ZShlKXtjb25zdHtwb3J0MTpyLHBvcnQyOml9PW5ldyBNZXNzYWdlQ2hhbm5lbDtyZXR1cm4gdyhlLHIpLFtpLFtpXV19LGRlc2VyaWFsaXplKGUpe3JldHVybiBlLnN0YXJ0KCksQyhlKX19LE89e2NhbkhhbmRsZTplPT5fKGUpJiZ5IGluIGUsc2VyaWFsaXplKHt2YWx1ZTplfSl7bGV0IHI7cmV0dXJuIGUgaW5zdGFuY2VvZiBFcnJvcj9yPXtpc0Vycm9yOiEwLHZhbHVlOnttZXNzYWdlOmUubWVzc2FnZSxuYW1lOmUubmFtZSxzdGFjazplLnN0YWNrfX06cj17aXNFcnJvcjohMSx2YWx1ZTplfSxbcixbXV19LGRlc2VyaWFsaXplKGUpe3Rocm93IGUuaXNFcnJvcj9PYmplY3QuYXNzaWduKG5ldyBFcnJvcihlLnZhbHVlLm1lc3NhZ2UpLGUudmFsdWUpOmUudmFsdWV9fSxFPW5ldyBNYXAoW1sicHJveHkiLExdLFsidGhyb3ciLE9dXSk7ZnVuY3Rpb24gdyhlLHI9c2VsZil7ci5hZGRFdmVudExpc3RlbmVyKCJtZXNzYWdlIixmdW5jdGlvbiBpKHMpe2lmKCFzfHwhcy5kYXRhKXJldHVybjtjb25zdHtpZDpvLHR5cGU6YSxwYXRoOm59PU9iamVjdC5hc3NpZ24oe3BhdGg6W119LHMuZGF0YSksdT0ocy5kYXRhLmFyZ3VtZW50TGlzdHx8W10pLm1hcChtKTtsZXQgbDt0cnl7Y29uc3QgYz1uLnNsaWNlKDAsLTEpLnJlZHVjZSgoZCxoKT0+ZFtoXSxlKSxmPW4ucmVkdWNlKChkLGgpPT5kW2hdLGUpO3N3aXRjaChhKXtjYXNlIkdFVCI6bD1mO2JyZWFrO2Nhc2UiU0VUIjpjW24uc2xpY2UoLTEpWzBdXT1tKHMuZGF0YS52YWx1ZSksbD0hMDticmVhaztjYXNlIkFQUExZIjpsPWYuYXBwbHkoYyx1KTticmVhaztjYXNlIkNPTlNUUlVDVCI6e2NvbnN0IGQ9bmV3IGYoLi4udSk7bD16KGQpfWJyZWFrO2Nhc2UiRU5EUE9JTlQiOntjb25zdHtwb3J0MTpkLHBvcnQyOmh9PW5ldyBNZXNzYWdlQ2hhbm5lbDt3KGUsaCksbD1OKGQsW2RdKX1icmVhaztjYXNlIlJFTEVBU0UiOmw9dm9pZCAwO2JyZWFrO2RlZmF1bHQ6cmV0dXJufX1jYXRjaChjKXtsPXt2YWx1ZTpjLFt5XTowfX1Qcm9taXNlLnJlc29sdmUobCkuY2F0Y2goYz0+KHt2YWx1ZTpjLFt5XTowfSkpLnRoZW4oYz0+e2NvbnN0W2YsZF09UyhjKTtyLnBvc3RNZXNzYWdlKE9iamVjdC5hc3NpZ24oT2JqZWN0LmFzc2lnbih7fSxmKSx7aWQ6b30pLGQpLGE9PT0iUkVMRUFTRSImJihyLnJlbW92ZUV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLGkpLEYocikpfSl9KSxyLnN0YXJ0JiZyLnN0YXJ0KCl9ZnVuY3Rpb24gVChlKXtyZXR1cm4gZS5jb25zdHJ1Y3Rvci5uYW1lPT09Ik1lc3NhZ2VQb3J0In1mdW5jdGlvbiBGKGUpe1QoZSkmJmUuY2xvc2UoKX1mdW5jdGlvbiBDKGUscil7cmV0dXJuIGIoZSxbXSxyKX1mdW5jdGlvbiBwKGUpe2lmKGUpdGhyb3cgbmV3IEVycm9yKCJQcm94eSBoYXMgYmVlbiByZWxlYXNlZCBhbmQgaXMgbm90IHVzZWFibGUiKX1mdW5jdGlvbiBiKGUscj1bXSxpPWZ1bmN0aW9uKCl7fSl7bGV0IHM9ITE7Y29uc3Qgbz1uZXcgUHJveHkoaSx7Z2V0KGEsbil7aWYocChzKSxuPT09UilyZXR1cm4oKT0+ZyhlLHt0eXBlOiJSRUxFQVNFIixwYXRoOnIubWFwKHU9PnUudG9TdHJpbmcoKSl9KS50aGVuKCgpPT57RihlKSxzPSEwfSk7aWYobj09PSJ0aGVuIil7aWYoci5sZW5ndGg9PT0wKXJldHVybnt0aGVuOigpPT5vfTtjb25zdCB1PWcoZSx7dHlwZToiR0VUIixwYXRoOnIubWFwKGw9PmwudG9TdHJpbmcoKSl9KS50aGVuKG0pO3JldHVybiB1LnRoZW4uYmluZCh1KX1yZXR1cm4gYihlLFsuLi5yLG5dKX0sc2V0KGEsbix1KXtwKHMpO2NvbnN0W2wsY109Uyh1KTtyZXR1cm4gZyhlLHt0eXBlOiJTRVQiLHBhdGg6Wy4uLnIsbl0ubWFwKGY9PmYudG9TdHJpbmcoKSksdmFsdWU6bH0sYykudGhlbihtKX0sYXBwbHkoYSxuLHUpe3Aocyk7Y29uc3QgbD1yW3IubGVuZ3RoLTFdO2lmKGw9PT1BKXJldHVybiBnKGUse3R5cGU6IkVORFBPSU5UIn0pLnRoZW4obSk7aWYobD09PSJiaW5kIilyZXR1cm4gYihlLHIuc2xpY2UoMCwtMSkpO2NvbnN0W2MsZl09TSh1KTtyZXR1cm4gZyhlLHt0eXBlOiJBUFBMWSIscGF0aDpyLm1hcChkPT5kLnRvU3RyaW5nKCkpLGFyZ3VtZW50TGlzdDpjfSxmKS50aGVuKG0pfSxjb25zdHJ1Y3QoYSxuKXtwKHMpO2NvbnN0W3UsbF09TShuKTtyZXR1cm4gZyhlLHt0eXBlOiJDT05TVFJVQ1QiLHBhdGg6ci5tYXAoYz0+Yy50b1N0cmluZygpKSxhcmd1bWVudExpc3Q6dX0sbCkudGhlbihtKX19KTtyZXR1cm4gb31mdW5jdGlvbiBEKGUpe3JldHVybiBBcnJheS5wcm90b3R5cGUuY29uY2F0LmFwcGx5KFtdLGUpfWZ1bmN0aW9uIE0oZSl7Y29uc3Qgcj1lLm1hcChTKTtyZXR1cm5bci5tYXAoaT0+aVswXSksRChyLm1hcChpPT5pWzFdKSldfWNvbnN0IFA9bmV3IFdlYWtNYXA7ZnVuY3Rpb24gTihlLHIpe3JldHVybiBQLnNldChlLHIpLGV9ZnVuY3Rpb24geihlKXtyZXR1cm4gT2JqZWN0LmFzc2lnbihlLHtbJF06ITB9KX1mdW5jdGlvbiBTKGUpe2Zvcihjb25zdFtyLGldb2YgRSlpZihpLmNhbkhhbmRsZShlKSl7Y29uc3RbcyxvXT1pLnNlcmlhbGl6ZShlKTtyZXR1cm5be3R5cGU6IkhBTkRMRVIiLG5hbWU6cix2YWx1ZTpzfSxvXX1yZXR1cm5be3R5cGU6IlJBVyIsdmFsdWU6ZX0sUC5nZXQoZSl8fFtdXX1mdW5jdGlvbiBtKGUpe3N3aXRjaChlLnR5cGUpe2Nhc2UiSEFORExFUiI6cmV0dXJuIEUuZ2V0KGUubmFtZSkuZGVzZXJpYWxpemUoZS52YWx1ZSk7Y2FzZSJSQVciOnJldHVybiBlLnZhbHVlfX1mdW5jdGlvbiBnKGUscixpKXtyZXR1cm4gbmV3IFByb21pc2Uocz0+e2NvbnN0IG89VSgpO2UuYWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsZnVuY3Rpb24gYShuKXshbi5kYXRhfHwhbi5kYXRhLmlkfHxuLmRhdGEuaWQhPT1vfHwoZS5yZW1vdmVFdmVudExpc3RlbmVyKCJtZXNzYWdlIixhKSxzKG4uZGF0YSkpfSksZS5zdGFydCYmZS5zdGFydCgpLGUucG9zdE1lc3NhZ2UoT2JqZWN0LmFzc2lnbih7aWQ6b30sciksaSl9KX1mdW5jdGlvbiBVKCl7cmV0dXJuIG5ldyBBcnJheSg0KS5maWxsKDApLm1hcCgoKT0+TWF0aC5mbG9vcihNYXRoLnJhbmRvbSgpKk51bWJlci5NQVhfU0FGRV9JTlRFR0VSKS50b1N0cmluZygxNikpLmpvaW4oIi0iKX1jb25zdCBXPWFzeW5jKCk9PldlYkFzc2VtYmx5LnZhbGlkYXRlKG5ldyBVaW50OEFycmF5KFswLDk3LDExNSwxMDksMSwwLDAsMCwxLDUsMSw5NiwwLDEsMTIzLDMsMiwxLDAsMTAsMTAsMSw4LDAsNjUsMCwyNTMsMTUsMjUzLDk4LDExXSkpLHg9ImVhZ2VyIixrPSJsYXp5IixqPXtzc3c6WyJzaW1kIl0sbWluaW1hcDI6WyJzaW1kIl19LHQ9e3Rvb2xzOltdLGNvbmZpZzp7fSxmaWxlczpbXSxiYXNlOnt9LGZzOnt9LGFzeW5jIGluaXQoKXtpZih0LnRvb2xzLmxlbmd0aD09PTApdGhyb3ciRXhwZWN0aW5nIGF0IGxlYXN0IDEgdG9vbC4iO2lmKG5ldyBTZXQodC50b29scy5tYXAocj0+YCR7ci50b29sfS8ke3IucHJvZ3JhbXx8ci50b29sfWApKS5zaXplIT09dC50b29scy5sZW5ndGgpdGhyb3ciRm91bmQgZHVwbGljYXRlIHRvb2xzOyBjYW4gb25seSBoYXZlIGVhY2ggdG9vbC9wcm9ncmFtIGNvbWJpbmF0aW9uIGF0IG1vc3Qgb25jZS4iO2lmKHQuYmFzZT10LnRvb2xzLmZpbmQocj0+ci5yZWluaXQhPT0hMCksIXQuYmFzZSl0aHJvdyJDb3VsZCBub3QgZmluZCBhIHRvb2wgd2l0aCBgcmVpbml0OiBmYWxzZWAgdG8gdXNlIGFzIHRoZSBiYXNlIG1vZHVsZS4gVG8gZml4IHRoaXMgaXNzdWUsIGluY2x1ZGUgdGhlIHRvb2wgYGJhc2UvMS4wLjBgIHdoZW4gaW5pdGlhbGl6aW5nIEFpb2xpLiI7cmV0dXJuIHQuYmFzZS5pc0Jhc2VNb2R1bGU9ITAsYXdhaXQgdGhpcy5fc2V0dXAodC5iYXNlKSxhd2FpdCB0aGlzLl9pbml0TW9kdWxlcygpLHQuX2xvZygiUmVhZHkiKSwhMH0sYXN5bmMgX2luaXRNb2R1bGVzKCl7YXdhaXQgUHJvbWlzZS5hbGwodC50b29scy5tYXAodGhpcy5fc2V0dXApKSxhd2FpdCB0aGlzLl9zZXR1cEZTKCl9LG1vdW50KGU9W10pe2NvbnN0IHI9YCR7dC5jb25maWcuZGlyU2hhcmVkfSR7dC5jb25maWcuZGlyRGF0YX1gLGk9YCR7dC5jb25maWcuZGlyU2hhcmVkfSR7dC5jb25maWcuZGlyTW91bnRlZH1gO2xldCBzPVtdLG89W10sYT1bXTshQXJyYXkuaXNBcnJheShlKSYmIShlIGluc3RhbmNlb2YgRmlsZUxpc3QpJiYoZT1bZV0pLHQuX2xvZyhgTW91bnRpbmcgJHtlLmxlbmd0aH0gZmlsZXNgKTtmb3IobGV0IG4gb2YgZSl7aWYobiBpbnN0YW5jZW9mIEZpbGV8fChuPT1udWxsP3ZvaWQgMDpuLmRhdGEpaW5zdGFuY2VvZiBCbG9iJiZuLm5hbWV8fHR5cGVvZihuPT1udWxsP3ZvaWQgMDpuLmRhdGEpPT0ic3RyaW5nIiYmbi5uYW1lKXR5cGVvZihuPT1udWxsP3ZvaWQgMDpuLmRhdGEpPT0ic3RyaW5nIiYmKG4uZGF0YT1uZXcgQmxvYihbbi5kYXRhXSx7dHlwZToidGV4dC9wbGFpbiJ9KSkscy5wdXNoKG4pO2Vsc2UgaWYobi5uYW1lJiZuLnVybClvLnB1c2gobik7ZWxzZSBpZih0eXBlb2Ygbj09InN0cmluZyImJm4uc3RhcnRzV2l0aCgiaHR0cCIpKW49e3VybDpuLG5hbWU6bi5zcGxpdCgiLy8iKS5wb3AoKS5yZXBsYWNlKC9cLy9nLCItIil9LG8ucHVzaChuKTtlbHNlIHRocm93J0Nhbm5vdCBtb3VudCBmaWxlKHMpIHNwZWNpZmllZC4gTXVzdCBiZSBhIEZpbGUsIEJsb2IsIGEgVVJMIHN0cmluZywgb3IgeyBuYW1lOiAiZmlsZS50eHQiLCBkYXRhOiAic3RyaW5nIiB9Lic7YS5wdXNoKG4ubmFtZSl9dHJ5e3QuZnMudW5tb3VudChpKX1jYXRjaHt9Zm9yKGxldCBuIG9mIG8pdC5mcy5jcmVhdGVMYXp5RmlsZShyLG4ubmFtZSxuLnVybCwhMCwhMCk7cmV0dXJuIHQuZmlsZXM9dC5maWxlcy5jb25jYXQocyksdC5iYXNlLm1vZHVsZS5GUy5tb3VudCh0LmJhc2UubW9kdWxlLldPUktFUkZTLHtmaWxlczp0LmZpbGVzLmZpbHRlcihuPT5uIGluc3RhbmNlb2YgRmlsZSksYmxvYnM6dC5maWxlcy5maWx0ZXIobj0+KG49PW51bGw/dm9pZCAwOm4uZGF0YSlpbnN0YW5jZW9mIEJsb2IpfSxpKSxzLm1hcChuPT57Y29uc3QgdT1gJHtpfS8ke24ubmFtZX1gLGw9YCR7cn0vJHtuLm5hbWV9YDt0cnl7dC5mcy51bmxpbmsobCl9Y2F0Y2h7fXQuX2xvZyhgQ3JlYXRpbmcgc3ltbGluazogJHtsfSAtLT4gJHt1fWApLHQuZnMuc3ltbGluayh1LGwpfSksYS5tYXAobj0+YCR7cn0vJHtufWApfSxhc3luYyBleGVjKGUscj1udWxsKXtpZih0Ll9sb2coYEV4ZWN1dGluZyAlYyR7ZX0lYyBhcmdzPSR7cn1gLCJjb2xvcjpkYXJrYmx1ZTsgZm9udC13ZWlnaHQ6Ym9sZCIsIiIpLCFlKXRocm93IkV4cGVjdGluZyBhIGNvbW1hbmQiO2xldCBpPWU7cj09bnVsbCYmKHI9ZS5zcGxpdCgiICIpLGk9ci5zaGlmdCgpKTtjb25zdCBzPXQudG9vbHMuZmluZChhPT57dmFyIHU7bGV0IG49aTtyZXR1cm4oKHU9YT09bnVsbD92b2lkIDA6YS5mZWF0dXJlcyk9PW51bGw/dm9pZCAwOnUuc2ltZCk9PT0hMCYmKG49YCR7bn0tc2ltZGApLGEucHJvZ3JhbT09bn0pO2lmKHM9PW51bGwpdGhyb3dgUHJvZ3JhbSAke2l9IG5vdCBmb3VuZC5gO3Muc3Rkb3V0PSIiLHMuc3RkZXJyPSIiLHMubG9hZGluZz09ayYmKHMubG9hZGluZz14LGF3YWl0IHRoaXMuX2luaXRNb2R1bGVzKCkpO3RyeXtzLm1vZHVsZS5jYWxsTWFpbihyKX1jYXRjaChhKXtjb25zb2xlLmVycm9yKGEpfXRyeXtzLm1vZHVsZS5GUy5jbG9zZShzLm1vZHVsZS5GUy5zdHJlYW1zWzFdKSxzLm1vZHVsZS5GUy5jbG9zZShzLm1vZHVsZS5GUy5zdHJlYW1zWzJdKX1jYXRjaHt9cy5tb2R1bGUuRlMuc3RyZWFtc1sxXT1zLm1vZHVsZS5GUy5vcGVuKCIvZGV2L3N0ZG91dCIsInciKSxzLm1vZHVsZS5GUy5zdHJlYW1zWzJdPXMubW9kdWxlLkZTLm9wZW4oIi9kZXYvc3RkZXJyIiwidyIpO2xldCBvPXtzdGRvdXQ6cy5zdGRvdXQsc3RkZXJyOnMuc3RkZXJyfTtpZih0LmNvbmZpZy5wcmludEludGVybGVhdmVkJiYobz1zLnN0ZG91dCkscy5yZWluaXQ9PT0hMCl7Y29uc3QgYT10LmJhc2UubW9kdWxlLkZTLmN3ZCgpO09iamVjdC5hc3NpZ24ocyxzLmNvbmZpZykscy5yZWFkeT0hMSxhd2FpdCB0aGlzLmluaXQoKSxzLmlzQmFzZU1vZHVsZSYmdGhpcy5tb3VudCgpLHRoaXMuY2QoYSl9cmV0dXJuIG99LGNhdChlKXtyZXR1cm4gdC5fZmlsZW9wKCJjYXQiLGUpfSxscyhlKXtyZXR1cm4gdC5fZmlsZW9wKCJscyIsZSl9LGRvd25sb2FkKGUpe3JldHVybiB0Ll9maWxlb3AoImRvd25sb2FkIixlKX0scHdkKCl7cmV0dXJuIHQuZnMuY3dkKCl9LGNkKGUpe2ZvcihsZXQgciBvZiB0LnRvb2xzKSFyLm1vZHVsZXx8ci5tb2R1bGUuRlMuY2hkaXIoZSl9LG1rZGlyKGUpe3JldHVybiB0LmZzLm1rZGlyKGUpLCEwfSxyZWFkKHtwYXRoOmUsbGVuZ3RoOnIsZmxhZzppPSJyIixvZmZzZXQ6cz0wLHBvc2l0aW9uOm89MH0pe2NvbnN0IGE9dC5mcy5vcGVuKGUsaSksbj1uZXcgVWludDhBcnJheShyKTtyZXR1cm4gdC5mcy5yZWFkKGEsbixzLHIsbyksdC5mcy5jbG9zZShhKSxufSx3cml0ZSh7cGF0aDplLGJ1ZmZlcjpyLGZsYWc6aT0idysiLG9mZnNldDpzPTAscG9zaXRpb246bz0wfSl7Y29uc3QgYT10LmZzLm9wZW4oZSxpKTt0LmZzLndyaXRlKGEscixzLHIubGVuZ3RoLG8pLHQuZnMuY2xvc2UoYSl9LF9zdGRpblR4dDoiIixfc3RkaW5QdHI6MCxnZXQgc3RkaW4oKXtyZXR1cm4gdC5fc3RkaW5UeHR9LHNldCBzdGRpbihlPSIiKXt0Ll9sb2coYFNldHRpbmcgc3RkaW4gdG8gJWMke2V9JWNgLCJjb2xvcjpkYXJrYmx1ZSIsIiIpLHQuX3N0ZGluVHh0PWUsdC5fc3RkaW5QdHI9MH0sYXN5bmMgX3NldHVwKGUpe2lmKGUucmVhZHkpcmV0dXJuO2lmKHQuX2xvZyhgU2V0dGluZyB1cCAke2UudG9vbH0gKGJhc2UgPSAke2UuaXNCYXNlTW9kdWxlPT09ITB9KS4uLmApLGUuY29uZmlnPU9iamVjdC5hc3NpZ24oe30sZSksZS51cmxQcmVmaXh8fChlLnVybFByZWZpeD1gJHt0LmNvbmZpZy51cmxDRE59LyR7ZS50b29sfS8ke2UudmVyc2lvbn1gKSxlLnByb2dyYW18fChlLnByb2dyYW09ZS50b29sKSxlLmZlYXR1cmVzfHwoZS5mZWF0dXJlcz17fSwoaltlLnByb2dyYW1dfHxbXSkuaW5jbHVkZXMoInNpbWQiKSYmKGF3YWl0IFcoKT8oZS5wcm9ncmFtKz0iLXNpbWQiLGUuZmVhdHVyZXMuc2ltZD0hMCk6dC5fbG9nKGBXZWJBc3NlbWJseSBTSU1EIGlzIG5vdCBzdXBwb3J0ZWQgaW4gdGhpcyBicm93c2VyOyB3aWxsIGxvYWQgbm9uLVNJTUQgdmVyc2lvbiBvZiAke2UucHJvZ3JhbX0uYCkpKSxlLmlzQmFzZU1vZHVsZSYmKGUubG9hZGluZz14KSxlLmxvYWRpbmc9PT1rKXt0Ll9sb2coYFdpbGwgbGF6eS1sb2FkICR7ZS50b29sfTsgc2tpcHBpbmcgaW5pdGlhbGl6YXRpb24uYCk7cmV0dXJufXNlbGYuaW1wb3J0U2NyaXB0cyhgJHtlLnVybFByZWZpeH0vJHtlLnByb2dyYW19LmpzYCksZS5tb2R1bGU9YXdhaXQgTW9kdWxlKHt0aGlzUHJvZ3JhbTplLnByb2dyYW0sbG9jYXRlRmlsZTooaSxzKT0+YCR7ZS51cmxQcmVmaXh9LyR7aX1gLHN0ZGluOigpPT50Ll9zdGRpblB0cjx0LnN0ZGluLmxlbmd0aD90LnN0ZGluLmNoYXJDb2RlQXQodC5fc3RkaW5QdHIrKyk6KHQuc3RkaW49IiIsbnVsbCkscHJpbnQ6aT0+ZS5zdGRvdXQrPWAke2l9CmAscHJpbnRFcnI6dC5jb25maWcucHJpbnRJbnRlcmxlYXZlZD9pPT5lLnN0ZG91dCs9YCR7aX0KYDppPT5lLnN0ZGVycis9YCR7aX0KYH0pO2NvbnN0IHI9ZS5tb2R1bGUuRlM7ZS5pc0Jhc2VNb2R1bGU/KHQuX2xvZyhgU2V0dGluZyB1cCAke2UudG9vbH0gd2l0aCBiYXNlIG1vZHVsZSBmaWxlc3lzdGVtLi4uYCksci5ta2Rpcih0LmNvbmZpZy5kaXJTaGFyZWQsNTExKSxyLm1rZGlyKGAke3QuY29uZmlnLmRpclNoYXJlZH0vJHt0LmNvbmZpZy5kaXJEYXRhfWAsNTExKSxyLm1rZGlyKGAke3QuY29uZmlnLmRpclNoYXJlZH0vJHt0LmNvbmZpZy5kaXJNb3VudGVkfWAsNTExKSxyLmNoZGlyKGAke3QuY29uZmlnLmRpclNoYXJlZH0vJHt0LmNvbmZpZy5kaXJEYXRhfWApLHQuZnM9cik6KHQuX2xvZyhgU2V0dGluZyB1cCAke2UudG9vbH0gd2l0aCBmaWxlc3lzdGVtLi4uYCksci5ta2Rpcih0LmNvbmZpZy5kaXJTaGFyZWQpLHIubW91bnQoZS5tb2R1bGUuUFJPWFlGUyx7cm9vdDp0LmNvbmZpZy5kaXJTaGFyZWQsZnM6dC5mc30sdC5jb25maWcuZGlyU2hhcmVkKSxyLmNoZGlyKHQuZnMuY3dkKCkpKSxlLnN0ZG91dD0iIixlLnN0ZGVycj0iIixlLnJlYWR5PSEwfSxhc3luYyBfc2V0dXBGUygpe2NvbnN0IGU9dC5mcztmb3IobGV0IHIgb2YgdC50b29scyl7aWYoIXIucmVhZHkpY29udGludWU7Y29uc3QgaT1yLm1vZHVsZS5GUyxzPWAvJHtyLnRvb2x9YCxvPWAke3QuY29uZmlnLmRpclNoYXJlZH0ke3N9YDshaS5hbmFseXplUGF0aChzKS5leGlzdHN8fGUuYW5hbHl6ZVBhdGgobykuZXhpc3RzfHwodC5fbG9nKGBNb3VudGluZyAke3N9IG9udG8gJHt0LmJhc2UudG9vbH0gZmlsZXN5c3RlbSBhdCAke299YCksZS5ta2RpcihvKSxlLm1vdW50KHQuYmFzZS5tb2R1bGUuUFJPWFlGUyx7cm9vdDpzLGZzOml9LG8pKX19LF9maWxlb3AoZSxyKXt0Ll9sb2coYFJ1bm5pbmcgJHtlfSAke3J9YCk7Y29uc3QgaT10LmZzLmFuYWx5emVQYXRoKHIpO2lmKCFpLmV4aXN0cylyZXR1cm4gdC5fbG9nKGBGaWxlICR7cn0gbm90IGZvdW5kLmApLCExO3N3aXRjaChlKXtjYXNlImNhdCI6cmV0dXJuIHQuZnMucmVhZEZpbGUocix7ZW5jb2Rpbmc6InV0ZjgifSk7Y2FzZSJscyI6cmV0dXJuIHQuZnMuaXNGaWxlKGkub2JqZWN0Lm1vZGUpP3QuZnMuc3RhdChyKTp0LmZzLnJlYWRkaXIocik7Y2FzZSJkb3dubG9hZCI6Y29uc3Qgcz1uZXcgQmxvYihbdGhpcy5jYXQocildKTtyZXR1cm4gVVJMLmNyZWF0ZU9iamVjdFVSTChzKX1yZXR1cm4hMX0sX2xvZyhlKXtpZighdC5jb25maWcuZGVidWcpcmV0dXJuO2xldCByPVsuLi5hcmd1bWVudHNdO3Iuc2hpZnQoKSxjb25zb2xlLmxvZyhgJWNbV2ViV29ya2VyXSVjICR7ZX1gLCJmb250LXdlaWdodDpib2xkIiwiIiwuLi5yKX19O3codCl9KSgpOwo=",T=typeof window<"u"&&window.Blob&&new Blob([atob(C)],{type:"text/javascript;charset=utf-8"});function M(){const t=T&&(window.URL||window.webkitURL).createObjectURL(T);try{return t?new Worker(t):new Worker("data:application/javascript;base64,"+C)}finally{t&&(window.URL||window.webkitURL).revokeObjectURL(t)}}const E={urlCDN:"https://biowasm.com/cdn/v3",urlCDNStg:"https://stg.biowasm.com/cdn/v3",dirShared:"/shared",dirMounted:"/mnt",dirData:"/data",printInterleaved:!0,callback:null,debug:!1,env:"prd"};class A{constructor(t,e={}){if(null==t)throw"Expecting array of tools as input to Aioli constructor.";return Array.isArray(t)||(t=[t]),e=Object.assign({},E,e),t=t.map(this._parseTool),"stg"===e.env&&(e.urlCDN=e.urlCDNStg),this.tools=t,this.config=e,null!=this.config.callback&&(this.callback=this.config.callback),delete this.config.callback,this.init()}async init(){const t=new M;this.callback&&(t.onmessage=t=>{"biowasm"===t.data.type&&this.callback(t.data.value)});const e=f(t);return e.tools=this.tools,e.config=this.config,await e.init(),e}_parseTool(t){if("string"!=typeof t)return t;const e=t.split("/");if(2!=e.length&&3!=e.length)throw"Expecting '<tool>/<version>' or '<tool>/<program>/<version>'";return{tool:e[0],program:3==e.length?e[1]:e[0],version:e[e.length-1]}}}var N=n(850);class P{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]}}P.scales={WimleyWhite:{"-":0,A:.17,C:-.24,D:-.07,E:-.01,F:-1.13,G:.01,H:.17,I:-.31,K:.99,L:-.56,M:-.23,N:.42,P:.45,Q:.58,R:.81,S:.13,T:.14,V:.07,W:-1.85,Y:-.94},categorial:{"-":0,A:1,C:2,D:3,E:4,F:5,G:6,H:7,I:8,K:9,L:10,M:11,N:12,P:13,Q:14,R:15,S:16,T:17,V:18,W:19,Y:20}};class x{constructor(t="categorial"){this.aa2num=P.getScale(t),this.num2aa={},Object.entries(this.aa2num).forEach((([t,e])=>this.num2aa[e]=t))}static _truncateSequence(t){let e=0,n=t.length;const i=["NH2","COOH"];if(t.startsWith(i[0])){const n=i[0].length;(0,N.hu)("-"==t[n],`Wrong sequence format: ${i[0]} without following '-' in '${t}'.`),e=n}if(t.endsWith(i[1])){const e=i[1].length+1;(0,N.hu)("-"==t[n-e],`Wrong sequence format: ${i[1]} without '-' precending in '${t}'.`),n-=e}return t.substring(e,n)}static _dropDefises(t){return t.replace(/(-)([^-]+)/g,"$2")}static clean(t){return x._dropDefises(x._truncateSequence(t))}encode(t){const e=t.length,n=new Array(e).fill(0);for(let i=0;i<e;++i){const e=t[i];(0,N.hu)(e in this.aa2num,`Unknown char '${e}' found in sequence '${t}'`),n[i]=this.encodeLettter(e)}return n}encodeLettter(t){return this.aa2num[t]}decode(t){let e="";for(let n=0;n<t.length;++n){const i=t[n];(0,N.hu)(i in this.num2aa,`Unknown code '${i}' found in vector '${t}'`),e+=this.num2aa[i]}return e}}var _=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};const R="input.fa",L="result.fasta";function I(t){return t.reduce(((t,e,n)=>t+`>sample${n+1}\n${e}\n`),"")}function G(t,e=!1,n="",s=null){var r,a;return _(this,void 0,void 0,(function*(){let l=t.toList();e&&(l=l.map((t=>x.clean(t).replace(/\-/g,""))));const c=t.length;null!=s||(s=i.Column.string("Clusters",c).init("0")),s.type!=i.COLUMN_TYPE.STRING&&(s=s.convertTo(i.TYPE.STRING)),s.compact();const h=s.categories,u=s.getRawData(),d=new Array(h.length),f=new Array(h.length);for(let t=0;t<c;++t){const e=u[t];(null!==(r=d[e])&&void 0!==r?r:d[e]=[]).push(l[t]),(null!==(a=f[e])&&void 0!==a?a:f[e]=[]).push(t)}const m=yield new A(["base/1.0.0",{tool:"kalign",version:"3.3.1",reinit:!0}]),p=i.Column.string(n,c);for(let t=0;t<h.length;++t){const e=I(d[t]);yield m.fs.writeFile(R,e);const n=yield m.exec(`kalign ${R} -f fasta -o ${L}`);console.warn(n);const i=yield m.cat(L);if(!i)throw new Error("kalign output no result");const s=new o.i(i).sequencesArray,r=f[t];for(let t=0;t<s.length;++t)p.set(r[t],s[t])}const g=t.getTag(i.TAGS.UNITS),v=t.getTag("alphabet");return p.setTag(i.TAGS.UNITS,g),p.setTag("aligned","SEQ.MSA"),p.setTag("alphabet",v),p.semType=i.SEMTYPE.MACROMOLECULE,p}))}},8341:(t,e,n)=>{"use strict";n.d(e,{J:()=>a,f:()=>c});var i=n(4469),o=n(976),s=n(3553),r=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};const a=["mafft --auto","mafft","linsi","ginsi","einsi","fftns","fftnsi","nwns","nwnsi"],l=["AlignedSeq","AlignedSubpeptide","HELM","ID","PolymerID"];function c(t,e,n="ginsi",a=1.53,c=0,u=null){var d;return r(this,void 0,void 0,(function*(){const r=t.length;null!=u||(u=o.Column.int("Clusters",r).init(0)),u.type!=o.COLUMN_TYPE.STRING&&(u=u.convertTo(o.TYPE.STRING));const f=u.categories,m=new Array(f.length);for(let e=0;e<r;++e){const n=u.get(e);if(""===n)continue;const i=f.indexOf(n),o=t.get(e);o&&(null!==(d=m[i])&&void 0!==d?d:m[i]=[]).push({ID:e.toString(),HELM:o})}const p=yield(void 0!==i.dapi.docker?i.dapi.docker.dockerContainers:i.dapi.dockerfiles).filter("bio").first(),g=new Array(r);for(const t of m){const e=(yield h(p.id,t,n,a,c)).Alignment;for(const t of e)g[parseInt(t.ID)]=Object.entries(t).filter((t=>!l.includes(t[0]))).map((t=>"-"!==t[1]?t[1]:"")).join(s.rs.SEPARATOR)}const v=o.Column.fromStrings(e,g);return v.setTag(o.TAGS.UNITS,"separator"),v.setTag("separator",s.rs.SEPARATOR),v.setTag("aligned","SEQ.MSA"),v.setTag("alphabet","UN"),v.setTag(".alphabetIsMultichar","true"),v.semType=o.SEMTYPE.MACROMOLECULE,v}))}function h(t,e,n,o,s){return r(this,void 0,void 0,(function*(){const r={method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(e)},a=`/align?method=${n}&gap_open=${o}&gap_extend=${s}`,l=yield(void 0!==i.dapi.docker?i.dapi.docker.dockerContainers:i.dapi.dockerfiles).request(t,a,r);return JSON.parse(null!=l?l:"{}")}))}},9943:(t,e,n)=>{"use strict";n.d(e,{i$:()=>s,sK:()=>r}),n(976),n(3870),n(4469),n(6414);var i=n(8447);n(499);const o=60;function s(t,e,n=o,s="\n"){const a=i.kB,l=[];for(let i=0;i<e.length;i++){const o=t.map((t=>t.get(i).toString())).join("|"),c=r(e.get(i),a,n);l.push(`>${o}${s}`);for(const t of c)l.push(`${t}${s}`)}return"".concat(...l)}function r(t,e,n=o){const i=e(t);let s=0;const r=i.length,a=[];for(;s<r;){const t=i.slice(s,s+n),e=t.map((t=>t.length>1?`[${t}]`:t)).join("");a.push(e),s+=t.length}return a}},4293:(t,e,n)=>{"use strict";n.d(e,{Y:()=>r,m:()=>s});var i=n(4469),o=n(976);function s(){const t=i.shell.t.columns.bySemType(o.SEMTYPE.MACROMOLECULE);if(null!==t)return t;i.shell.error("Current table does not contain macromolecules")}function r(t,e){t.innerHTML="",t.append(e)}},2433:(t,e,n)=>{"use strict";n.d(e,{CK:()=>g,eZ:()=>b,yW:()=>p});var i,o,s=n(4469),r=n(3870),a=n(976),l=n(6414),c=n.n(l),h=n(701),u=n(499),d=n(8447),f=n(9298),m=n(7604);HTMLCanvasElement.prototype.getCursorPosition=function(t,e){const n=this.getBoundingClientRect();return new a.Point((t.clientX-n.left)*e,(t.clientY-n.top)*e)},a.Rect.prototype.contains=function(t,e){return this.left<=t&&t<=this.right&&this.top<=e&&e<=this.bottom};class p{constructor(t=0,e=new a.Rect(0,0,0,0)){this.count=t,this.bounds=e}}class g{constructor(t,e,n={},i=0,o=0){this.pos=t,this.name=e,this.freq=n,this.rowCount=i,this.sumForHeightCalc=o}}!function(t){t.STYLE="Style",t.BEHAVIOR="Behavior",t.LAYOUT="Layout",t.DATA="Data"}(i||(i={})),function(t){t.sequenceColumnName="sequenceColumnName",t.startPositionName="startPositionName",t.endPositionName="endPositionName",t.skipEmptySequences="skipEmptySequences",t.skipEmptyPositions="skipEmptyPositions",t.shrinkEmptyTail="shrinkEmptyTail",t.backgroundColor="backgroundColor",t.positionHeight="positionHeight",t.positionWidth="positionWidth",t.verticalAlignment="verticalAlignment",t.horizontalAlignment="horizontalAlignment",t.fixWidth="fixWidth",t.fitArea="fitArea",t.minHeight="minHeight",t.maxHeight="maxHeight",t.positionMarginState="positionMarginState",t.positionMargin="positionMargin",t.filterSource="filterSource"}(o||(o={}));const v=f.vS;class y extends a.JsViewer{get filter(){let t;switch(this.filterSource){case f.Ct.Filtered:t=this.dataFrame.filter;break;case f.Ct.Selected:t=this.dataFrame.selection}return t}get Length(){return this.skipEmptyPositions?this.positions.length:this.startPosition<=this.endPosition?this.endPosition-this.startPosition+1:0}get positionWidthWithMargin(){return this._positionWidth+this.positionMarginValue}get positionMarginValue(){var t;return"auto"===this.positionMarginState&&!0===(null===(t=this.unitsHandler)||void 0===t?void 0:t.getAlphabetIsMultichar())||"enable"===this.positionMarginState?this.positionMargin:0}get countOfRenderPositions(){if(null==this.host)return 0;const t=window.devicePixelRatio;return t>1?this.canvasWidthWithRatio/this.positionWidthWithMargin:this.canvas.width/(this.positionWidthWithMargin*t)}get canvasWidthWithRatio(){return this.canvas.width*window.devicePixelRatio}get firstVisibleIndex(){return this.visibleSlider?Math.floor(this.slider.min):0}constructor(){super(),this.viewerId=-1,this.initialized=!1,this.cp=null,this.axisHeight=12,this.seqCol=null,this.splitter=null,this.positions=[],this.rowsMasked=0,this.rowsNull=0,this.visibleSlider=!1,this.allowResize=!0,this.turnOfResizeForOneSetValue=!1,this.backgroundColor=4294967295,this.positionMargin=0,this.positionNames=[],this.startPosition=-1,this.endPosition=-1,this.viewSubs=[],this.viewerId=y.viewerCount,y.viewerCount+=1,this.textBaseline="top",this.unitsHandler=null,this.sequenceColumnName=this.string(o.sequenceColumnName,v.sequenceColumnName,{category:i.DATA}),this.startPositionName=this.string(o.startPositionName,v.startPositionName,{category:i.DATA}),this.endPositionName=this.string(o.endPositionName,v.endPositionName,{category:i.DATA}),this.skipEmptySequences=this.bool(o.skipEmptySequences,v.skipEmptySequences,{category:i.DATA}),this.skipEmptyPositions=this.bool(o.skipEmptyPositions,v.skipEmptyPositions,{category:i.DATA}),this.shrinkEmptyTail=this.bool(o.shrinkEmptyTail,v.shrinkEmptyTail,{category:i.DATA}),this.backgroundColor=this.int(o.backgroundColor,v.backgroundColor,{category:i.STYLE}),this.positionHeight=this.string(o.positionHeight,v.positionHeight,{category:i.STYLE,choices:Object.values(f.ES)}),this._positionWidth=this.positionWidth=this.float(o.positionWidth,v.positionWidth,{category:i.STYLE}),this.verticalAlignment=this.string(o.verticalAlignment,v.verticalAlignment,{category:i.LAYOUT,choices:Object.values(f.vw)}),this.horizontalAlignment=this.string(o.horizontalAlignment,v.horizontalAlignment,{category:i.LAYOUT,choices:Object.values(f.iD)}),this.fixWidth=this.bool(o.fixWidth,v.fixWidth,{category:i.LAYOUT}),this.fitArea=this.bool(o.fitArea,v.fitArea,{category:i.LAYOUT}),this.minHeight=this.float(o.minHeight,v.minHeight,{category:i.LAYOUT}),this.maxHeight=this.float(o.maxHeight,v.maxHeight,{category:i.LAYOUT}),this.positionMarginState=this.string(o.positionMarginState,v.positionMarginState,{category:i.LAYOUT,choices:Object.values(f.dE)});let t=0;"auto"===this.positionMarginState&&(t=4),this.positionMargin=this.int(o.positionMargin,t,{category:i.LAYOUT,min:0,max:16}),this.filterSource=this.string(o.filterSource,v.filterSource,{category:i.BEHAVIOR,choices:Object.values(f.Ct)}),this.slider=r.rangeSlider(0,100,0,20,!1,{style:"barbell"}),this.canvas=r.canvas(),this.canvas.style.width="100%"}init(){this.initialized?console.error("Bio: WebLogoViewer.init() second initialization!"):(this.initialized=!0,this.helpUrl="/help/visualize/viewers/web-logo.md",this.msgHost=r.div("No message"),this.msgHost.style.display="none",this.canvas=r.canvas(),this.canvas.style.width="100%",this.slider.root.style.position="absolute",this.slider.root.style.zIndex="999",this.slider.root.style.display="none",this.slider.root.style.height="0.7em",this.visibleSlider=!1,this.subs.push(this.slider.onValuesChanged.subscribe(this.sliderOnValuesChanged.bind(this))),this.host=r.div([this.msgHost,this.canvas]),this.host.style.justifyContent="center",this.host.style.alignItems="center",this.host.style.position="relative",this.host.style.setProperty("overflow","hidden","important"),this.subs.push(h.fromEvent(this.canvas,"mousemove").subscribe(this.canvasOnMouseMove.bind(this))),this.subs.push(h.fromEvent(this.canvas,"mousedown").subscribe(this.canvasOnMouseDown.bind(this))),this.subs.push(h.fromEvent(this.canvas,"wheel").subscribe(this.canvasOnWheel.bind(this))),this.subs.push(r.onSizeChanged(this.root).subscribe(this.rootOnSizeChanged.bind(this))),this.root.append(this.host),this.root.append(this.slider.root),this._calculate(window.devicePixelRatio),this.updateSlider(),this.render(!0))}rootOnSizeChanged(){this._calculate(window.devicePixelRatio),this.updateSlider(),this.render(!0)}updateSeqCol(){if(this.dataFrame)if(this.seqCol=this.sequenceColumnName?this.dataFrame.col(this.sequenceColumnName):null,null==this.seqCol&&(this.seqCol=(0,d.up)(this.dataFrame),this.sequenceColumnName=this.seqCol?this.seqCol.name:null),this.seqCol){const t=this.seqCol.getTag(a.TAGS.UNITS),e=this.seqCol.getTag("separator");this.splitter=(0,d.vU)(t,e),this.unitsHandler=new u.C(this.seqCol),this.updatePositions(),this.cp=(0,d.dQ)(this.seqCol)}else this.splitter=null,this.positionNames=[],this.startPosition=-1,this.endPosition=-1,this.cp=null;this.render()}updatePositions(){if(!this.seqCol)return;let t;if(this.shrinkEmptyTail){const e=this.dataFrame.filter.getSelectedIndexes();t=Array.from(new Set(Array.from(Array(e.length).keys()).map((t=>this.seqCol.get(e[t])))))}else t=this.seqCol.categories;const e=t.length>0?Math.max(...t.map((t=>null!==t?this.splitter(t).length:0))):0,n=this.seqCol.getTag(f.DX.positionNames);this.positionNames=n?n.split(f.CI).map((t=>t.trim())):[...Array(e).keys()].map((t=>`${t+1}`)),this.startPosition=this.startPositionName&&this.positionNames&&this.positionNames.includes(this.startPositionName)?this.positionNames.indexOf(this.startPositionName):0,this.endPosition=this.endPositionName&&this.positionNames&&this.positionNames.includes(this.endPositionName)?this.positionNames.indexOf(this.endPositionName):e-1}get widthArea(){return this.Length*this.positionWidth/window.devicePixelRatio}get heightArea(){return Math.min(this.maxHeight,Math.max(this.minHeight,this.root.clientHeight))}get xScale(){return this.widthArea>0?(this.root.clientWidth-this.Length*this.positionMarginValue)/this.widthArea:0}get yScale(){return this.root.clientHeight/this.heightArea}checkIsHideSlider(){let t=!0;const e=Math.min(this.xScale,this.yScale);return(e==this.xScale||e<=1)&&this.fitArea&&(t=!1),this.fixWidth||Math.ceil(this.canvas.width/this.positionWidthWithMargin)>=this.Length||t}setSliderVisibility(t){t?(this.slider.root.style.display="inherit",this.visibleSlider=!0):(this.slider.root.style.display="none",this.visibleSlider=!1)}updateSlider(){if(this.checkIsHideSlider()?this.setSliderVisibility(!1):this.setSliderVisibility(!0),null!=this.slider&&null!=this.canvas){const t=Math.max(0,Math.floor(this.slider.min+this.canvas.width/this.positionWidthWithMargin)-this.Length);let e=Math.floor(this.slider.min-t),n=Math.floor(this.slider.min-t)+Math.floor(this.canvas.width/this.positionWidthWithMargin);this.checkIsHideSlider()&&(e=0,n=Math.max(e,this.Length-1)),this.turnOfResizeForOneSetValue=!0,this.slider.setValues(0,this.Length,e,n)}}onPropertyChanged(t){switch(super.onPropertyChanged(t),t.name){case o.sequenceColumnName:case o.startPositionName:case o.endPositionName:case o.filterSource:this.updateSeqCol();break;case o.positionWidth:this._positionWidth=this.positionWidth,this.updateSlider();break;case o.fixWidth:case o.fitArea:case o.positionMargin:this.updateSlider();break;case o.shrinkEmptyTail:case o.skipEmptyPositions:this.updatePositions()}this.render(!0)}onTableAttached(){super.onTableAttached();const t=this.dataFrame?"data":"null";console.debug(`Bio: WebLogoViewer<${this.viewerId}>.onTableAttached( dataFrame = ${t} ) start`),this.updateSeqCol(),void 0!==this.dataFrame&&(this.viewSubs.push(this.dataFrame.filter.onChanged.subscribe(this.dataFrameFilterOnChanged.bind(this))),this.viewSubs.push(this.dataFrame.selection.onChanged.subscribe(this.dataFrameSelectionOnChanged.bind(this)))),this.init(),console.debug(`Bio: WebLogoViewer<${this.viewerId}>.onTableAttached() end`)}detach(){const t=Object.create(null,{detach:{get:()=>super.detach}});return e=this,n=void 0,o=function*(){const e=this.dataFrame?"data":"null";console.debug(`Bio: WebLogoViewer<${this.viewerId}>.onTableAttached( dataFrame = ${e} ) start`),t.detach.call(this),this.viewSubs.forEach((t=>t.unsubscribe())),this.host.remove(),this.msgHost=void 0,this.host=void 0,this.initialized=!1,console.debug(`Bio: WebLogoViewer<${this.viewerId}>.onTableAttached() end`)},new((i=void 0)||(i=Promise))((function(t,s){function r(t){try{l(o.next(t))}catch(t){s(t)}}function a(t){try{l(o.throw(t))}catch(t){s(t)}}function l(e){var n;e.done?t(e.value):(n=e.value,n instanceof i?n:new i((function(t){t(n)}))).then(r,a)}l((o=o.apply(e,n||[])).next())}));var e,n,i,o}getMonomer(t){const e=t.x+this.firstVisibleIndex*this.positionWidthWithMargin,n=Math.floor(t.x/this.positionWidthWithMargin+this.firstVisibleIndex),i=this.positions[n];if(null==i)return[n,null,null];const o=Object.keys(i.freq).find((n=>i.freq[n].bounds.contains(e,t.y)));return void 0===o?[n,null,null]:[n,o,i.freq[o]]}_nullSequence(t="X"){return this.skipEmptySequences?"":new Array(this.Length).fill(t).join("")}removeWhere(t,e){const n=t.length;let i=0;for(let o=0;o<n;o++)e(t[o])||(t[i]=t[o],i++);return t.length=i,t}_removeEmptyPositions(){this.skipEmptyPositions&&this.removeWhere(this.positions,(t=>{var e;return(null===(e=null==t?void 0:t.freq["-"])||void 0===e?void 0:e.count)===t.rowCount}))}_calculate(t){if(!this.host||!this.seqCol||!this.dataFrame)return;this.unitsHandler=new u.C(this.seqCol),this.calcSize();const e=this.startPosition<=this.endPosition?this.endPosition-this.startPosition+1:0;this.positions=new Array(e);for(let t=0;t<this.Length;t++){const e=this.positionNames[this.startPosition+t];this.positions[t]=new g(this.startPosition+t,e)}const n=this.filter.getSelectedIndexes();this.rowsMasked=n.length,this.rowsNull=0;for(const t of n){let e=this.seqCol.get(t);e||(e=this._nullSequence(),++this.rowsNull);const n=this.splitter(e);for(let t=0;t<this.Length;t++){const e=this.positions[t].freq,i=n[this.startPosition+t]||"-";i in e||(e[i]=new p),e[i].count++}}for(let t=0;t<this.Length;t++){this.positions[t].rowCount=0;for(const e in this.positions[t].freq)this.positions[t].rowCount+=this.positions[t].freq[e].count;if(this.positionHeight==f.ES.Entropy){this.positions[t].sumForHeightCalc=0;for(const e in this.positions[t].freq){const n=this.positions[t].freq[e].count/this.positions[t].rowCount;this.positions[t].sumForHeightCalc+=-n*Math.log2(n)}}}this._removeEmptyPositions();const i=this.canvas.height-this.axisHeight*t;for(let e=0;e<this.Length;e++){const n=this.positions[e].freq,o=this.positions[e].rowCount,r=this.getAlphabetSize();this.positionHeight==f.ES.Entropy&&null==r&&s.shell.error("WebLogo: alphabet is undefined.");const l=Math.log2(r),c=this.positionHeight==f.ES.Entropy?i*(l-this.positions[e].sumForHeightCalc)/l:i;let h=this.axisHeight*t+(i-c-1);const u=Object.entries(n).sort(((t,e)=>"-"!==t[0]&&"-"!==e[0]?e[1].count-t[1].count:"-"===t[0]&&"-"===e[0]?0:"-"===t[0]?-1:1));for(const t of u){const n=t[1],i=c*n.count/o;n.bounds=new a.Rect(e*this.positionWidthWithMargin,h,this._positionWidth,i),h+=i}}}render(t=!0){var e;if(this.msgHost&&(this.seqCol&&!this.cp?(this.msgHost.innerText=`Unknown palette (column semType: '${this.seqCol.semType}').`,this.msgHost.style.display=""):this.msgHost.style.display="none"),!this.seqCol||!this.dataFrame||!this.cp||-1===this.startPosition||-1===this.endPosition||null==this.host||null==this.slider)return;const n=this.canvas.getContext("2d");if(!n)return;this.slider.root.style.width=`${this.host.clientWidth}px`;const i=window.devicePixelRatio;t&&this._calculate(i),n.resetTransform(),n.fillStyle=a.Color.toHtml(this.backgroundColor),n.fillRect(0,0,this.canvas.width,this.canvas.height),n.textBaseline=this.textBaseline;const o=this.countOfRenderPositions+1,s=this.visibleSlider?Math.floor(this.slider.min):0,r=Math.min(this.Length,s+o),l=10*i;n.resetTransform(),n.fillStyle="black",n.textAlign="center",n.font=`${l.toFixed(1)}px Roboto, Roboto Local, sans-serif`;const c=Math.max(...this.positions.map((t=>n.measureText(t.name).width))),h=c<this._positionWidth-2?1:(this._positionWidth-2)/c;for(let t=this.firstVisibleIndex;t<r;t++){const e=this.positions[t];n.resetTransform(),n.setTransform(h,0,0,1,t*this.positionWidthWithMargin+this._positionWidth/2-this.positionWidthWithMargin*s,0),n.fillText(e.name,0,0)}for(let t=this.firstVisibleIndex;t<r;t++)for(const[i,o]of Object.entries(this.positions[t].freq))if("-"!==i){const t=(0,d.GU)(i,5),s=o.bounds,r=s.left-this.positionWidthWithMargin*this.firstVisibleIndex;n.resetTransform(),n.strokeStyle="lightgray",n.lineWidth=1,n.rect(r,s.top,s.width,s.height),n.fillStyle=null!==(e=this.cp.get(i))&&void 0!==e?e:this.cp.get("other"),n.textAlign="left",n.font="16px Roboto, Roboto Local, sans-serif";const a=n.measureText(t);n.setTransform(s.width/a.width,0,0,s.height/12.2,r,s.top),n.fillText(t,0,-.25)}}calcSize(){if(!this.host)return;const t=window.devicePixelRatio;let e=this.widthArea,n=this.heightArea;if(this.fitArea&&!this.visibleSlider){const t=Math.max(1,Math.min(this.xScale,this.yScale));e*=t,n*=t,this._positionWidth=this.positionWidth*t}e=this.Length*this.positionWidthWithMargin/t,this.canvas.width=this.root.clientWidth*t,this.canvas.style.width=`${this.root.clientWidth}px`,this.host.style.setProperty("height",`${n}px`);const i=this.host.clientHeight;if(this.canvas.height=i*t,this.fixWidth)this.root.style.width=this.host.style.width=`${e}px`,this.root.style.height=`${n}px`,this.root.style.overflow="hidden",this.host.style.setProperty("overflow-y","hidden","important");else{this.root.style.width=this.host.style.width="100%",this.host.style.overflowX="auto!important",this.host.style.setProperty("text-align",this.horizontalAlignment);const t=this.visibleSlider?10:0;let o=0;switch(this.verticalAlignment){case"top":o=0;break;case"middle":o=Math.max(0,(this.root.clientHeight-n)/2);break;case"bottom":o=Math.max(0,this.root.clientHeight-n-t)}let s=0;switch(this.horizontalAlignment){case"left":s=0;break;case"center":s=Math.max(0,(this.root.clientWidth-e)/2);break;case"right":s=Math.max(0,this.root.clientWidth-e)}this.host.style.setProperty("margin-top",`${o}px`,"important"),this.host.style.setProperty("margin-left",`${s}px`,"important"),null!=this.slider&&this.slider.root.style.setProperty("margin-top",`${o+i}px`,"important"),this.root.clientHeight<=n?(this.host.style.setProperty("height",`${this.root.clientHeight}px`),this.host.style.setProperty("overflow-y",null)):this.host.style.setProperty("overflow-y","hidden","important")}}getAlphabetSize(){var t,e;return null!==(e=null===(t=this.unitsHandler)||void 0===t?void 0:t.getAlphabetSize())&&void 0!==e?e:0}sliderOnValuesChanged(t){if(null!=this.host)try{if(this.allowResize&&!this.turnOfResizeForOneSetValue&&this.visibleSlider){const t=Math.ceil(this.slider.max-this.slider.min),e=this.canvas.width/t-this.positionMarginValue;this.positionWidth=e,this._positionWidth=e}this.turnOfResizeForOneSetValue=!1,this.render(!0)}catch(t){const e=(0,m.O)(t);console.error("Bio: WebLogoViewer.sliderOnValuesChanged() error:\n"+e)}}dataFrameFilterOnChanged(t){console.debug("Bio: WebLogoViewer.dataFrameFilterChanged()");try{this.updatePositions(),this.render()}catch(t){const e=(0,m.O)(t);console.error("Bio: WebLogoViewer.dataFrameFilterOnChanged() error:\n"+e)}}dataFrameSelectionOnChanged(t){console.debug("Bio: WebLogoViewer.dataFrameSelectionOnChanged()");try{this.render()}catch(t){const e=(0,m.O)(t);console.error("Bio: WebLogoViewer.dataFrameSelectionOnChanged() error:\n"+e)}}canvasOnMouseMove(t){try{const e=t,n=window.devicePixelRatio,i=this.canvas.getCursorPosition(e,n),[o,s]=this.getMonomer(i);if(this.dataFrame&&this.seqCol&&this.splitter&&s){const t=this.positions[o],n=b(this.dataFrame,this.seqCol,this.filter,this.splitter,s,t),i=r.div([r.div(`${s}`),r.div(`${n} rows`)]);r.tooltip.show(i,e.x+16,e.y+16)}else r.tooltip.hide()}catch(t){const e=(0,m.O)(t);console.error("Bio: WebLogoViewer.canvasOnMouseMove() error:\n"+e)}}canvasOnMouseDown(t){try{const e=t,n=window.devicePixelRatio,[i,o]=this.getMonomer(this.canvas.getCursorPosition(e,n));if(this.dataFrame&&this.seqCol&&this.splitter&&o){const t=this.positions[i],e=a.BitSet.create(this.dataFrame.selection.length,(e=>function(t,e,n,i,o,s,r){if(!n.getSelectedIndexes().includes(i))return!1;const a=e.get(i),l=a?o(a)[r.pos]:null;return l===s||""===l&&"-"===s}(this.dataFrame,this.seqCol,this.filter,e,this.splitter,o,t)));this.dataFrame.selection.init((t=>e.get(t)))}}catch(t){const e=(0,m.O)(t);console.error("Bio: WebLogoViewer.canvasOnMouseDown() error:\n"+e)}}canvasOnWheel(t){try{if(!this.visibleSlider)return;const e=t.deltaY/100*Math.max(Math.floor(this.countOfRenderPositions/2),1);this.slider.scrollBy(this.slider.min+e)}catch(t){const e=(0,m.O)(t);console.error("Bio: WebLogoViewer.canvasOnWheel() error:\n"+e)}}}function b(t,e,n,i,o,s){return c().count(0).take(t.rowCount).filter((t=>n.get(t))).map((t=>{const n=e.get(t),o=n?i(n):[],r=s.pos;return r<o.length?o[r]:null})).toArray().filter((t=>t==o)).reduce(((t,e)=>t+1),0)}y.residuesSet="nucleotides",y.viewerCount=-1},4413:(t,e,n)=>{"use strict";n.d(e,{ST:()=>m});var i=n(3870),o=n(976),s=n(4469),r=n(6414),a=n.n(r),l=n(7983),c=n(701),h=n(4293),u=n(1061);const d=rxjs.operators;var f=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};class m extends o.Filter{get calculating(){return"initial"==this.loader.style.display}set calculating(t){this.loader.style.display=t?"initial":"none"}get filterSummary(){return this.bioFilter.substructure}get isFiltering(){return super.isFiltering&&""!==this.bioFilter.substructure}get isReadyToApplyFilter(){return!this.calculating&&null!=this.bitset}get _debounceTime(){if(null==this.column)return 1e3;const t=this.column.length;return t<500?0:t>1e4?1e3:Math.floor((t-500)/9500*1e3)}constructor(){super(),this.bioFilter=null,this.bitset=null,this.loader=i.loader(),this.notation=void 0,this.root=i.divV([]),this.calculating=!1}attach(t){var e,n,i,s,r;super.attach(t),this.column=t.columns.bySemType(o.SEMTYPE.MACROMOLECULE),null!==(e=this.columnName)&&void 0!==e||(this.columnName=null===(n=this.column)||void 0===n?void 0:n.name),null!==(i=this.notation)&&void 0!==i||(this.notation=null===(s=this.column)||void 0===s?void 0:s.getTag(o.TAGS.UNITS)),this.bioFilter="fasta"===this.notation?new g:"separator"===this.notation?new v(this.column.getTag("separator")):new y,this.root.appendChild(this.bioFilter.filterPanel),this.root.appendChild(this.loader),null===(r=this.onBioFilterChangedSubs)||void 0===r||r.unsubscribe();let a=this.bioFilter.onChanged;a=a.pipe((0,d.debounceTime)(this._debounceTime)),this.onBioFilterChangedSubs=a.subscribe((t=>f(this,void 0,void 0,(function*(){return yield this._onInputChanged()}))))}detach(){super.detach()}applyFilter(){var t;this.bitset&&!this.isDetached&&(null===(t=this.dataFrame)||void 0===t||t.filter.and(this.bitset))}saveState(){var t;const e=super.saveState();return e.bioSubstructure=null===(t=this.bioFilter)||void 0===t?void 0:t.substructure,e}applyState(t){super.applyState(t),t.bioSubstructure&&(this.bioFilter.substructure=t.bioSubstructure);const e=this;t.bioSubstructure&&setTimeout((function(){e._onInputChanged()}),1e3)}_onInputChanged(){var t,e,n;return f(this,void 0,void 0,(function*(){if(this.isFiltering){if(a()(this.dataFrame.rows.filters).has(`${this.columnName}: ${this.filterSummary}`))return;this.calculating=!0;try{this.bitset=yield null===(e=this.bioFilter)||void 0===e?void 0:e.substrucrureSearch(this.column),this.calculating=!1,null===(n=this.dataFrame)||void 0===n||n.rows.requestFilter()}finally{this.calculating=!1}}else this.bitset=null,null===(t=this.dataFrame)||void 0===t||t.rows.requestFilter()}))}}class p{constructor(){this.onChanged=new c.Subject}get filterPanel(){return new HTMLElement}get substructure(){return""}set substructure(t){}substrucrureSearch(t){return f(this,void 0,void 0,(function*(){return null}))}}class g extends p{constructor(){super(),this.substructureInput=i.stringInput("","",(()=>{this.onChanged.next()}),{placeholder:"Substructure"})}get filterPanel(){return this.substructureInput.root}get substructure(){return this.substructureInput.value}set substructure(t){this.substructureInput.value=t}substrucrureSearch(t){return f(this,void 0,void 0,(function*(){return yield(0,l.pf)(this.substructure,t)}))}}class v extends g{constructor(t){super(),this.colSeparator="",this.separatorInput=i.stringInput("","",(()=>{this.onChanged.next()}),{placeholder:"Separator"}),this.colSeparator=t,this.separatorInput.value=t}get filterPanel(){return i.divV([this.substructureInput.root,this.separatorInput.root])}get substructure(){return this.separatorInput.value&&this.separatorInput.value!==this.colSeparator?this.substructureInput.value.replaceAll(this.separatorInput.value,this.colSeparator):this.substructureInput.value}set substructure(t){this.substructureInput.value=t}substrucrureSearch(t){return f(this,void 0,void 0,(function*(){return yield(0,l.pf)(this.substructure,t,this.colSeparator)}))}}class y extends p{constructor(){super(),this._filterPanel=i.div("",{style:{cursor:"pointer"}}),this.helmSubstructure="",this.init()}init(){return f(this,void 0,void 0,(function*(){this.helmEditor=yield s.functions.call("HELM:helmWebEditor"),yield i.tools.waitForElementInDom(this._filterPanel),this.updateFilterPanel(),this._filterPanel.addEventListener("click",(t=>{const{editorDiv:e,webEditor:n}=this.helmEditor.createWebEditor(this.helmSubstructure);i.dialog({showHeader:!1,showFooter:!0}).add(e).onOK((()=>{const t=n.canvas.getHelm(!0).replace(/<\/span>/g,"").replace(/<span style='background:#bbf;'>/g,"");this.helmSubstructure=t,this.updateFilterPanel(this.substructure),setTimeout((()=>{this.onChanged.next()}),10)})).show({modal:!0,fullScreen:!0})})),i.onSizeChanged(this._filterPanel).subscribe((t=>{const e=this.helmEditor.webEditor.canvas.getHelm(!0).replace(/<\/span>/g,"").replace(/<span style='background:#bbf;'>/g,"");this.updateFilterPanel(e)}))}))}get filterPanel(){return this._filterPanel}get substructure(){return this.helmSubstructure}set substructure(t){this.helmEditor.editor.setHelm(t)}updateFilterPanel(t){const e=this._filterPanel.parentElement.clientWidth<100?100:this._filterPanel.parentElement.clientWidth,n=e/2;if(t)(0,h.Y)(this._filterPanel,this.helmEditor.host),this.helmEditor.editor.setHelm(t),this.helmEditor.resizeEditor(e,n);else{const t=i.divText("Click to edit","helm-substructure-filter");(0,h.Y)(this._filterPanel,t)}}substrucrureSearch(t){return f(this,void 0,void 0,(function*(){i.setUpdateIndicator(this._filterPanel,!0),yield(0,u.gw)(10);const e=yield(0,l.QF)(this.substructure,t);return i.setUpdateIndicator(this._filterPanel,!1),e}))}}},9378:function(t,e,n){"use strict";var i=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e.default=t,e};Object.defineProperty(e,"__esModule",{value:!0});var o=i(n(4517));function s(t,e){var n=function(n){return o.empty(t).map((function(){return o.filled(e,n)}))},i=[];return i.push(n(-1)),i.push(n(1/0)),i.push(n(0)),i}function r(t,e,n,i,o){e=Math.floor(e);var s=t[0][e],r=t[1][e];if(t[2][e],n>=r[0])return 0;for(var l=0;l<s.length;l++)if(i===s[l])return 0;return a(t,e,n,i,o)}function a(t,e,n,i,o){var s=t[0][e],r=t[1][e],a=t[2][e];if(n>=r[0])return 0;r[0]=n,s[0]=i,a[0]=o;for(var l=0,c=0;;){var h=2*l+1,u=h+1,d=t[0][0].length;if(h>=d)break;if(u>=d){if(!(r[h]>n))break;c=h}else if(r[h]>=r[u]){if(!(n<r[h]))break;c=h}else{if(!(n<r[u]))break;c=u}r[l]=r[c],s[l]=s[c],a[l]=a[c],l=c}return r[l]=n,s[l]=i,a[l]=o,1}function l(t,e,n,i){for(;2*i+1<n;){var o=2*i+1,s=o+1,r=i;if(t[r]<t[o]&&(r=o),s<n&&t[r]<t[s]&&(r=s),r===i)break;var a=t[i];t[i]=t[r],t[r]=a;var l=e[i];e[i]=e[r],e[r]=l,i=r}}e.makeHeap=s,e.rejectionSample=function(t,e,n){for(var i=o.zeros(t),s=0;s<t;s++){for(var r=!0,a=0;r;){a=o.tauRandInt(e,n);for(var l=!1,c=0;c<s;c++)if(a===i[c]){l=!0;break}l||(r=!1)}i[s]=a}return i},e.heapPush=r,e.uncheckedHeapPush=a,e.buildCandidates=function(t,e,n,i,a){for(var l=s(e,i),c=0;c<e;c++)for(var h=0;h<n;h++)if(!(t[0][c][h]<0)){var u=t[0][c][h],d=t[2][c][h],f=o.tauRand(a);r(l,c,f,u,d),r(l,u,f,c,d),t[2][c][h]=0}return l},e.deheapSort=function(t){for(var e=t[0],n=t[1],i=0;i<e.length;i++)for(var o=e[i],s=n[i],r=0;r<o.length-1;r++){var a=o.length-r-1,c=s.length-r-1,h=o[0];o[0]=o[a],o[a]=h;var u=s[0];s[0]=s[c],s[c]=u,l(s,o,c,0)}return{indices:e,weights:n}},e.smallestFlagged=function(t,e){for(var n=t[0][e],i=t[1][e],o=t[2][e],s=1/0,r=-1,a=0;a>n.length;a++)1===o[a]&&i[a]<s&&(s=i[a],r=a);return r>=0?(o[r]=0,Math.floor(n[r])):-1}},4221:(t,e,n)=>{"use strict";var i=n(4364);e.u=i.UMAP},5686:function(t,e,n){"use strict";var i,o=this&&this.__read||function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var i,o,s=n.call(t),r=[];try{for(;(void 0===e||e-- >0)&&!(i=s.next()).done;)r.push(i.value)}catch(t){o={error:t}}finally{try{i&&!i.done&&(n=s.return)&&n.call(s)}finally{if(o)throw o.error}}return r},s=this&&this.__values||function(t){var e="function"==typeof Symbol&&t[Symbol.iterator],n=0;return e?e.call(t):{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}}},r=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e.default=t,e};Object.defineProperty(e,"__esModule",{value:!0});var a=r(n(4517)),l=function(){function t(t,e,n,i){if(this.entries=new Map,this.nRows=0,this.nCols=0,t.length!==e.length||t.length!==n.length)throw new Error("rows, cols and values arrays must all have the same length");this.nRows=i[0],this.nCols=i[1];for(var o=0;o<n.length;o++){var s=t[o],r=e[o];this.checkDims(s,r);var a=this.makeKey(s,r);this.entries.set(a,{value:n[o],row:s,col:r})}}return t.prototype.makeKey=function(t,e){return t+":"+e},t.prototype.checkDims=function(t,e){if(!(t<this.nRows&&e<this.nCols))throw new Error("row and/or col specified outside of matrix dimensions")},t.prototype.set=function(t,e,n){this.checkDims(t,e);var i=this.makeKey(t,e);this.entries.has(i)?this.entries.get(i).value=n:this.entries.set(i,{value:n,row:t,col:e})},t.prototype.get=function(t,e,n){void 0===n&&(n=0),this.checkDims(t,e);var i=this.makeKey(t,e);return this.entries.has(i)?this.entries.get(i).value:n},t.prototype.getAll=function(t){void 0===t&&(t=!0);var e=[];return this.entries.forEach((function(t){e.push(t)})),t&&e.sort((function(t,e){return t.row===e.row?t.col-e.col:t.row-e.row})),e},t.prototype.getDims=function(){return[this.nRows,this.nCols]},t.prototype.getRows=function(){return Array.from(this.entries,(function(t){var e=o(t,2);return e[0],e[1].row}))},t.prototype.getCols=function(){return Array.from(this.entries,(function(t){var e=o(t,2);return e[0],e[1].col}))},t.prototype.getValues=function(){return Array.from(this.entries,(function(t){var e=o(t,2);return e[0],e[1].value}))},t.prototype.forEach=function(t){this.entries.forEach((function(e){return t(e.value,e.row,e.col)}))},t.prototype.map=function(e){var n=[];this.entries.forEach((function(t){n.push(e(t.value,t.row,t.col))}));var i=[this.nRows,this.nCols];return new t(this.getRows(),this.getCols(),n,i)},t.prototype.toArray=function(){var t=this,e=a.empty(this.nRows).map((function(){return a.zeros(t.nCols)}));return this.entries.forEach((function(t){e[t.row][t.col]=t.value})),e},t}();e.SparseMatrix=l,e.transpose=function(t){var e=[],n=[],i=[];t.forEach((function(t,o,s){e.push(o),n.push(s),i.push(t)}));var o=[t.nCols,t.nRows];return new l(n,e,i,o)},e.identity=function(t){for(var e=o(t,1)[0],n=new l([],[],[],t),i=0;i<e;i++)n.set(i,i,1);return n},e.pairwiseMultiply=function(t,e){return h(t,e,(function(t,e){return t*e}))},e.add=function(t,e){return h(t,e,(function(t,e){return t+e}))},e.subtract=function(t,e){return h(t,e,(function(t,e){return t-e}))},e.maximum=function(t,e){return h(t,e,(function(t,e){return t>e?t:e}))},e.multiplyScalar=function(t,e){return t.map((function(t){return t*e}))},e.eliminateZeros=function(t){for(var e=new Set,n=t.getValues(),i=t.getRows(),o=t.getCols(),s=0;s<n.length;s++)0===n[s]&&e.add(s);var r=function(t,n){return!e.has(n)},a=n.filter(r),c=i.filter(r),h=o.filter(r);return new l(c,h,a,t.getDims())},e.normalize=function(t,e){var n,i;void 0===e&&(e="l2");var o=c[e],r=new Map;t.forEach((function(t,e,n){var i=r.get(e)||[];i.push(n),r.set(e,i)}));var a=new l([],[],[],t.getDims()),h=function(e){for(var n=r.get(e).sort(),i=n.map((function(n){return t.get(e,n)})),s=o(i),l=0;l<s.length;l++)a.set(e,n[l],s[l])};try{for(var u=s(r.keys()),d=u.next();!d.done;d=u.next())h(d.value)}catch(t){n={error:t}}finally{try{d&&!d.done&&(i=u.return)&&i.call(u)}finally{if(n)throw n.error}}return a};var c=((i={}).max=function(t){for(var e=-1/0,n=0;n<t.length;n++)e=t[n]>e?t[n]:e;return t.map((function(t){return t/e}))},i.l1=function(t){for(var e=0,n=0;n<t.length;n++)e+=t[n];return t.map((function(t){return t/e}))},i.l2=function(t){for(var e=0,n=0;n<t.length;n++)e+=Math.pow(t[n],2);return t.map((function(t){return Math.sqrt(Math.pow(t,2)/e)}))},i);function h(t,e,n){for(var i=new Set,o=[],s=[],r=[],a=function(i,a){o.push(i),s.push(a);var l=n(t.get(i,a),e.get(i,a));r.push(l)},c=t.getValues(),h=t.getRows(),u=t.getCols(),d=0;d<c.length;d++){var f=(v=h[d])+":"+(y=u[d]);i.add(f),a(v,y)}var m=e.getValues(),p=e.getRows(),g=e.getCols();for(d=0;d<m.length;d++){var v,y;f=(v=p[d])+":"+(y=g[d]),i.has(f)||a(v,y)}var b=[t.nRows,t.nCols];return new l(o,s,r,b)}e.getCSR=function(t){var e=[];t.forEach((function(t,n,i){e.push({value:t,row:n,col:i})})),e.sort((function(t,e){return t.row===e.row?t.col-e.col:t.row-e.row}));for(var n=[],i=[],o=[],s=-1,r=0;r<e.length;r++){var a=e[r],l=a.row,c=a.col,h=a.value;l!==s&&(s=l,o.push(r)),n.push(c),i.push(h)}return{indices:n,values:i,indptr:o}}},760:function(t,e,n){"use strict";var i=this&&this.__values||function(t){var e="function"==typeof Symbol&&t[Symbol.iterator],n=0;return e?e.call(t):{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}}},o=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e.default=t,e};Object.defineProperty(e,"__esModule",{value:!0});var s=o(n(9378)),r=o(n(5686)),a=o(n(2320)),l=o(n(4517));e.makeNNDescent=function(t,e){return function(n,i,o,r,a,c,h,u){void 0===r&&(r=10),void 0===a&&(a=50),void 0===c&&(c=.001),void 0===h&&(h=.5),void 0===u&&(u=!0);for(var d=n.length,f=s.makeHeap(n.length,o),m=0;m<n.length;m++)for(var p=s.rejectionSample(o,n.length,e),g=0;g<p.length;g++){var v=t(n[m],n[p[g]]);s.heapPush(f,m,v,p[g],1),s.heapPush(f,p[g],v,m,1)}if(u)for(var y=0;y<i.length;y++)for(m=0;m<i[y].length&&!(i[y][m]<0);m++)for(g=m+1;g<i[y].length&&!(i[y][g]<0);g++)v=t(n[i[y][m]],n[i[y][g]]),s.heapPush(f,i[y][m],v,i[y][g],1),s.heapPush(f,i[y][g],v,i[y][m],1);for(y=0;y<r;y++){var b=s.buildCandidates(f,d,o,a,e),w=0;for(m=0;m<d;m++)for(g=0;g<a;g++){var S=Math.floor(b[0][m][g]);if(!(S<0||l.tauRand(e)<h))for(var C=0;C<a;C++){var T=Math.floor(b[0][m][C]),M=b[2][m][g],E=b[2][m][C];T<0||!M&&!E||(v=t(n[S],n[T]),w+=s.heapPush(f,S,v,T,1),w+=s.heapPush(f,T,v,S,1))}}if(w<=c*o*n.length)break}return s.deheapSort(f)}},e.makeInitializations=function(t){return{initFromRandom:function(e,n,i,o,r){for(var a=0;a<i.length;a++)for(var c=l.rejectionSample(e,n.length,r),h=0;h<c.length;h++)if(!(c[h]<0)){var u=t(n[c[h]],i[a]);s.heapPush(o,a,u,c[h],1)}},initFromTree:function(e,n,i,o,r){for(var l=0;l<i.length;l++)for(var c=a.searchFlatTree(i[l],e,r),h=0;h<c.length;h++){if(c[h]<0)return;var u=t(n[c[h]],i[l]);s.heapPush(o,l,u,c[h],1)}}}},e.makeInitializedNNSearch=function(t){return function(e,n,o,a){for(var l,c,h=r.getCSR(n),u=h.indices,d=h.indptr,f=0;f<a.length;f++)for(var m=new Set(o[0][f]);;){var p=s.smallestFlagged(o,f);if(-1===p)break;var g=u.slice(d[p],d[p+1]);try{for(var v=i(g),y=v.next();!y.done;y=v.next()){var b=y.value;if(b!==p&&-1!==b&&!m.has(b)){var w=t(e[b],a[f]);s.uncheckedHeapPush(o,f,w,b,1),m.add(b)}}}catch(t){l={error:t}}finally{try{y&&!y.done&&(c=v.return)&&c.call(v)}finally{if(l)throw l.error}}}return o}},e.initializeSearch=function(t,e,n,o,r,a,l){var c,h,u=s.makeHeap(n.length,o);if(r(o,e,n,u,l),t)try{for(var d=i(t),f=d.next();!f.done;f=d.next())a(f.value,e,n,u,l)}catch(t){c={error:t}}finally{try{f&&!f.done&&(h=d.return)&&h.call(d)}finally{if(c)throw c.error}}return u}},2320:function(t,e,n){"use strict";var i=this&&this.__read||function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var i,o,s=n.call(t),r=[];try{for(;(void 0===e||e-- >0)&&!(i=s.next()).done;)r.push(i.value)}catch(t){o={error:t}}finally{try{i&&!i.done&&(n=s.return)&&n.call(s)}finally{if(o)throw o.error}}return r},o=this&&this.__spread||function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(i(arguments[e]));return t},s=this&&this.__values||function(t){var e="function"==typeof Symbol&&t[Symbol.iterator],n=0;return e?e.call(t):{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}}},r=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e.default=t,e};Object.defineProperty(e,"__esModule",{value:!0});var a=r(n(4517)),l=function(t,e,n,i){this.hyperplanes=t,this.offsets=e,this.children=n,this.indices=i};function c(t,e,n,i,o){if(void 0===n&&(n=30),e.length>n){var s=function(t,e,n){var i=t[0].length,o=a.tauRandInt(e.length,n),s=a.tauRandInt(e.length,n);s=(s+=o===s?1:0)%e.length;for(var r=e[o],l=e[s],c=0,h=a.zeros(i),u=0;u<h.length;u++)h[u]=t[r][u]-t[l][u],c-=h[u]*(t[r][u]+t[l][u])/2;var d=0,f=0,m=a.zeros(e.length);for(u=0;u<e.length;u++){for(var p=c,g=0;g<i;g++)p+=h[g]*t[e[u]][g];0===p?(m[u]=a.tauRandInt(2,n),0===m[u]?d+=1:f+=1):p>0?(m[u]=0,d+=1):(m[u]=1,f+=1)}var v=a.zeros(d),y=a.zeros(f);for(d=0,f=0,u=0;u<m.length;u++)0===m[u]?(v[d]=e[u],d+=1):(y[f]=e[u],f+=1);return{indicesLeft:v,indicesRight:y,hyperplane:h,offset:c}}(t,e,o),r=s.indicesLeft,l=s.indicesRight,h=s.hyperplane,u=s.offset;return{leftChild:c(t,r,n,i+1,o),rightChild:c(t,l,n,i+1,o),isLeaf:!1,hyperplane:h,offset:u}}return{indices:e,isLeaf:!0}}function h(t,e,n,i,s,r,a){var l;if(t.isLeaf)return i[r][0]=-a,(l=s[a]).splice.apply(l,o([0,t.indices.length],t.indices)),{nodeNum:r,leafNum:a+=1};e[r]=t.hyperplane,n[r]=t.offset,i[r][0]=r+1;var c=r,u=h(t.leftChild,e,n,i,s,r+1,a);return r=u.nodeNum,a=u.leafNum,i[c][1]=r+1,{nodeNum:(u=h(t.rightChild,e,n,i,s,r+1,a)).nodeNum,leafNum:u.leafNum}}function u(t){return t.isLeaf?1:1+u(t.leftChild)+u(t.rightChild)}function d(t){return t.isLeaf?1:d(t.leftChild)+d(t.rightChild)}function f(t,e,n,i){for(var o=e,s=0;s<n.length;s++)o+=t[s]*n[s];return 0===o?a.tauRandInt(2,i):o>0?0:1}e.FlatTree=l,e.makeForest=function(t,e,n,i){var o=Math.max(10,e);return a.range(n).map((function(e,n){return function(t,e,n,i){return void 0===e&&(e=30),c(t,a.range(t.length),e,n,i)}(t,o,n,i)})).map((function(t){return function(t,e){var n=u(t),i=d(t),o=a.range(n).map((function(){return a.zeros(t.hyperplane?t.hyperplane.length:0)})),s=a.zeros(n),r=a.range(n).map((function(){return[-1,-1]})),c=a.range(i).map((function(){return a.range(e).map((function(){return-1}))}));return h(t,o,s,r,c,0,0),new l(o,s,r,c)}(t,o)}))},e.makeLeafArray=function(t){var e,n;if(t.length>0){var i=[];try{for(var r=s(t),a=r.next();!a.done;a=r.next()){var l=a.value;i.push.apply(i,o(l.indices))}}catch(t){e={error:t}}finally{try{a&&!a.done&&(n=r.return)&&n.call(r)}finally{if(e)throw e.error}}return i}return[[-1]]},e.searchFlatTree=function(t,e,n){for(var i=0;e.children[i][0]>0;)i=0===f(e.hyperplanes[i],e.offsets[i],t,n)?e.children[i][0]:e.children[i][1];var o=-1*e.children[i][0];return e.indices[o]}},4364:function(t,e,n){"use strict";var i=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){t.done?o(t.value):new n((function(e){e(t.value)})).then(r,a)}l((i=i.apply(t,e||[])).next())}))},o=this&&this.__generator||function(t,e){var n,i,o,s,r={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;r;)try{if(n=1,i&&(o=2&s[0]?i.return:s[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,s[1])).done)return o;switch(i=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return r.label++,{value:s[1],done:!1};case 5:r.label++,i=s[1],s=[0];continue;case 7:s=r.ops.pop(),r.trys.pop();continue;default:if(!((o=(o=r.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){r=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){r.label=s[1];break}if(6===s[0]&&r.label<o[1]){r.label=o[1],o=s;break}if(o&&r.label<o[2]){r.label=o[2],r.ops.push(s);break}o[2]&&r.ops.pop(),r.trys.pop();continue}s=e.call(t,r)}catch(t){s=[6,t],i=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,a])}}},s=this&&this.__read||function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var i,o,s=n.call(t),r=[];try{for(;(void 0===e||e-- >0)&&!(i=s.next()).done;)r.push(i.value)}catch(t){o={error:t}}finally{try{i&&!i.done&&(n=s.return)&&n.call(s)}finally{if(o)throw o.error}}return r},r=this&&this.__spread||function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(s(arguments[e]));return t},a=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e.default=t,e},l=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});var c=a(n(9378)),h=a(n(5686)),u=a(n(760)),d=a(n(2320)),f=a(n(4517)),m=l(n(9251)),p=1e-5,g=.001,v=function(){function t(t){void 0===t&&(t={});var e=this;this.learningRate=1,this.localConnectivity=1,this.minDist=.1,this.nComponents=2,this.nEpochs=0,this.nNeighbors=15,this.negativeSampleRate=5,this.random=Math.random,this.repulsionStrength=1,this.setOpMixRatio=1,this.spread=1,this.transformQueueSize=4,this.targetMetric="categorical",this.targetWeight=.5,this.targetNNeighbors=this.nNeighbors,this.distanceFn=y,this.isInitialized=!1,this.rpForest=[],this.embedding=[],this.optimizationState=new b;var n=function(n){void 0!==t[n]&&(e[n]=t[n])};n("distanceFn"),n("learningRate"),n("localConnectivity"),n("minDist"),n("nComponents"),n("nEpochs"),n("nNeighbors"),n("negativeSampleRate"),n("random"),n("repulsionStrength"),n("setOpMixRatio"),n("spread"),n("transformQueueSize")}return t.prototype.fit=function(t){return this.initializeFit(t),this.optimizeLayout(),this.embedding},t.prototype.fitAsync=function(t,e){return void 0===e&&(e=function(){return!0}),i(this,void 0,void 0,(function(){return o(this,(function(n){switch(n.label){case 0:return this.initializeFit(t),[4,this.optimizeLayoutAsync(e)];case 1:return n.sent(),[2,this.embedding]}}))}))},t.prototype.setSupervisedProjection=function(t,e){void 0===e&&(e={}),this.Y=t,this.targetMetric=e.targetMetric||this.targetMetric,this.targetWeight=e.targetWeight||this.targetWeight,this.targetNNeighbors=e.targetNNeighbors||this.targetNNeighbors},t.prototype.setPrecomputedKNN=function(t,e){this.knnIndices=t,this.knnDistances=e},t.prototype.initializeFit=function(t){if(t.length<=this.nNeighbors)throw new Error("Not enough data points ("+t.length+") to create nNeighbors: "+this.nNeighbors+". Add more data points or adjust the configuration.");if(this.X===t&&this.isInitialized)return this.getNEpochs();if(this.X=t,!this.knnIndices&&!this.knnDistances){var e=this.nearestNeighbors(t);this.knnIndices=e.knnIndices,this.knnDistances=e.knnDistances}this.graph=this.fuzzySimplicialSet(t,this.nNeighbors,this.setOpMixRatio),this.makeSearchFns(),this.searchGraph=this.makeSearchGraph(t),this.processGraphForSupervisedProjection();var n=this.initializeSimplicialSetEmbedding(),i=n.head,o=n.tail,s=n.epochsPerSample;return this.optimizationState.head=i,this.optimizationState.tail=o,this.optimizationState.epochsPerSample=s,this.initializeOptimization(),this.prepareForOptimizationLoop(),this.isInitialized=!0,this.getNEpochs()},t.prototype.makeSearchFns=function(){var t=u.makeInitializations(this.distanceFn),e=t.initFromTree,n=t.initFromRandom;this.initFromTree=e,this.initFromRandom=n,this.search=u.makeInitializedNNSearch(this.distanceFn)},t.prototype.makeSearchGraph=function(t){for(var e=this.knnIndices,n=this.knnDistances,i=[t.length,t.length],o=new h.SparseMatrix([],[],[],i),s=0;s<e.length;s++)for(var r=e[s],a=n[s],l=0;l<r.length;l++){var c=r[l],u=a[l];u>0&&o.set(s,c,u)}var d=h.transpose(o);return h.maximum(o,d)},t.prototype.transform=function(t){var e=this,n=this.X;if(void 0===n||0===n.length)throw new Error("No data has been fit.");var i=Math.floor(this.nNeighbors*this.transformQueueSize);i=Math.min(n.length,i);var o=u.initializeSearch(this.rpForest,n,t,i,this.initFromRandom,this.initFromTree,this.random),s=this.search(n,this.searchGraph,o,t),r=c.deheapSort(s),a=r.indices,l=r.weights;a=a.map((function(t){return t.slice(0,e.nNeighbors)})),l=l.map((function(t){return t.slice(0,e.nNeighbors)}));var d=Math.max(0,this.localConnectivity-1),m=this.smoothKNNDistance(l,this.nNeighbors,d),p=m.sigmas,g=m.rhos,v=this.computeMembershipStrengths(a,l,p,g),y=v.rows,b=v.cols,w=v.vals,S=[t.length,n.length],C=new h.SparseMatrix(y,b,w,S),T=h.normalize(C,"l1"),M=h.getCSR(T),A=t.length,N=E(f.reshape2d(M.indices,A,this.nNeighbors),f.reshape2d(M.values,A,this.nNeighbors),this.embedding),P=this.nEpochs?this.nEpochs/3:C.nRows<=1e4?100:30,x=C.getValues().reduce((function(t,e){return e>t?e:t}),0);C=C.map((function(t){return t<x/P?0:t})),C=h.eliminateZeros(C);var _=this.makeEpochsPerSample(C.getValues(),P),R=C.getRows(),L=C.getCols();return this.assignOptimizationStateParameters({headEmbedding:N,tailEmbedding:this.embedding,head:R,tail:L,currentEpoch:0,nEpochs:P,nVertices:C.getDims()[1],epochsPerSample:_}),this.prepareForOptimizationLoop(),this.optimizeLayout()},t.prototype.processGraphForSupervisedProjection=function(){var t=this.Y,e=this.X;if(t){if(t.length!==e.length)throw new Error("Length of X and y must be equal");if("categorical"===this.targetMetric){var n=this.targetWeight<1?1/(1-this.targetWeight)*2.5:1e12;this.graph=this.categoricalSimplicialSetIntersection(this.graph,t,n)}}},t.prototype.step=function(){var t=this.optimizationState.currentEpoch;return t<this.getNEpochs()&&this.optimizeLayoutStep(t),this.optimizationState.currentEpoch},t.prototype.getEmbedding=function(){return this.embedding},t.prototype.nearestNeighbors=function(t){var e,n=this.distanceFn,i=this.nNeighbors,o=u.makeNNDescent(n,this.random),s=5+Math.floor(.5==(e=Math.pow(t.length,.5)/20)?0:Math.round(e)),r=Math.max(5,Math.floor(Math.round(function(t){return Math.log(t)/Math.log(2)}(t.length))));this.rpForest=d.makeForest(t,i,s,this.random);var a=o(t,d.makeLeafArray(this.rpForest),i,r);return{knnIndices:a.indices,knnDistances:a.weights}},t.prototype.fuzzySimplicialSet=function(t,e,n){void 0===n&&(n=1);var i=this,o=i.knnIndices,s=void 0===o?[]:o,r=i.knnDistances,a=void 0===r?[]:r,l=i.localConnectivity,c=this.smoothKNNDistance(a,e,l),u=c.sigmas,d=c.rhos,f=this.computeMembershipStrengths(s,a,u,d),m=f.rows,p=f.cols,g=f.vals,v=[t.length,t.length],y=new h.SparseMatrix(m,p,g,v),b=h.transpose(y),w=h.pairwiseMultiply(y,b),S=h.subtract(h.add(y,b),w),C=h.multiplyScalar(S,n),T=h.multiplyScalar(w,1-n);return h.add(C,T)},t.prototype.categoricalSimplicialSetIntersection=function(t,e,n,i){void 0===i&&(i=1);var o=T(t,e,i,n);return M(o=h.eliminateZeros(o))},t.prototype.smoothKNNDistance=function(t,e,n,i,o){void 0===n&&(n=1),void 0===i&&(i=64),void 0===o&&(o=1);for(var s=Math.log(e)/Math.log(2)*o,r=f.zeros(t.length),a=f.zeros(t.length),l=0;l<t.length;l++){var c=0,h=1/0,u=1,d=t[l],m=d.filter((function(t){return t>0}));if(m.length>=n){var v=Math.floor(n),y=n-v;v>0?(r[l]=m[v-1],y>p&&(r[l]+=y*(m[v]-m[v-1]))):r[l]=y*m[0]}else m.length>0&&(r[l]=f.max(m));for(var b=0;b<i;b++){for(var w=0,S=1;S<t[l].length;S++){var C=t[l][S]-r[l];w+=C>0?Math.exp(-C/u):1}if(Math.abs(w-s)<p)break;w>s?u=(c+(h=u))/2:(c=u,h===1/0?u*=2:u=(c+h)/2)}if(a[l]=u,r[l]>0){var T=f.mean(d);a[l]<g*T&&(a[l]=g*T)}else{var M=f.mean(t.map(f.mean));a[l]<g*M&&(a[l]=g*M)}}return{sigmas:a,rhos:r}},t.prototype.computeMembershipStrengths=function(t,e,n,i){for(var o=t.length,s=t[0].length,r=f.zeros(o*s),a=f.zeros(o*s),l=f.zeros(o*s),c=0;c<o;c++)for(var h=0;h<s;h++){var u=0;-1!==t[c][h]&&(u=t[c][h]===c?0:e[c][h]-i[c]<=0?1:Math.exp(-(e[c][h]-i[c])/n[c]),r[c*s+h]=c,a[c*s+h]=t[c][h],l[c*s+h]=u)}return{rows:r,cols:a,vals:l}},t.prototype.initializeSimplicialSetEmbedding=function(){for(var t=this,e=this.getNEpochs(),n=this.nComponents,i=this.graph.getValues(),o=0,s=0;s<i.length;s++){var r=i[s];o<i[s]&&(o=r)}var a=this.graph.map((function(t){return t<o/e?0:t}));this.embedding=f.zeros(a.nRows).map((function(){return f.zeros(n).map((function(){return 20*f.tauRand(t.random)-10}))}));var l=[],c=[],h=[],u=a.getAll();for(s=0;s<u.length;s++){var d=u[s];d.value&&(l.push(d.value),h.push(d.row),c.push(d.col))}return{head:c,tail:h,epochsPerSample:this.makeEpochsPerSample(l,e)}},t.prototype.makeEpochsPerSample=function(t,e){var n=f.filled(t.length,-1),i=f.max(t),o=t.map((function(t){return t/i*e}));return o.forEach((function(t,i){t>0&&(n[i]=e/o[i])})),n},t.prototype.assignOptimizationStateParameters=function(t){Object.assign(this.optimizationState,t)},t.prototype.prepareForOptimizationLoop=function(){var t=this,e=t.repulsionStrength,n=t.learningRate,i=t.negativeSampleRate,o=this.optimizationState,s=o.epochsPerSample,a=o.headEmbedding,l=o.tailEmbedding,c=a[0].length,h=a.length===l.length,u=s.map((function(t){return t/i})),d=r(u),f=r(s);this.assignOptimizationStateParameters({epochOfNextSample:f,epochOfNextNegativeSample:d,epochsPerNegativeSample:u,moveOther:h,initialAlpha:n,alpha:n,gamma:e,dim:c})},t.prototype.initializeOptimization=function(){var t=this.embedding,e=this.embedding,n=this.optimizationState,i=n.head,o=n.tail,s=n.epochsPerSample,r=this.getNEpochs(),a=this.graph.nCols,l=C(this.spread,this.minDist),c=l.a,h=l.b;this.assignOptimizationStateParameters({headEmbedding:t,tailEmbedding:e,head:i,tail:o,epochsPerSample:s,a:c,b:h,nEpochs:r,nVertices:a})},t.prototype.optimizeLayoutStep=function(t){for(var e=this.optimizationState,n=e.head,i=e.tail,o=e.headEmbedding,s=e.tailEmbedding,r=e.epochsPerSample,a=e.epochOfNextSample,l=e.epochOfNextNegativeSample,c=e.epochsPerNegativeSample,h=e.moveOther,u=e.initialAlpha,d=e.alpha,m=e.gamma,p=e.a,g=e.b,v=e.dim,y=e.nEpochs,b=e.nVertices,C=0;C<r.length;C++)if(!(a[C]>t)){var T=n[C],M=i[C],E=o[T],A=s[M],N=S(E,A),P=0;N>0&&(P=-2*p*g*Math.pow(N,g-1),P/=p*Math.pow(N,g)+1);for(var x=0;x<v;x++){var _=w(P*(E[x]-A[x]),4);E[x]+=_*d,h&&(A[x]+=-_*d)}a[C]+=r[C];for(var R=Math.floor((t-l[C])/c[C]),L=0;L<R;L++){var I=f.tauRandInt(b,this.random),G=s[I],D=S(E,G),W=0;if(D>0)W=2*m*g,W/=(.001+D)*(p*Math.pow(D,g)+1);else if(T===I)continue;for(x=0;x<v;x++)_=4,W>0&&(_=w(W*(E[x]-G[x]),4)),E[x]+=_*d}l[C]+=R*c[C]}return e.alpha=u*(1-t/y),e.currentEpoch+=1,o},t.prototype.optimizeLayoutAsync=function(t){var e=this;return void 0===t&&(t=function(){return!0}),new Promise((function(n,s){var r=function(){return i(e,void 0,void 0,(function(){var e,i,a,l,c,h;return o(this,(function(o){try{if(e=this.optimizationState,i=e.nEpochs,a=e.currentEpoch,this.embedding=this.optimizeLayoutStep(a),l=this.optimizationState.currentEpoch,c=!1===t(l),h=l===i,c||h)return[2,n(h)];setTimeout((function(){return r()}),0)}catch(t){s(t)}return[2]}))}))};setTimeout((function(){return r()}),0)}))},t.prototype.optimizeLayout=function(t){void 0===t&&(t=function(){return!0});for(var e=!1,n=[];!e;){var i=this.optimizationState,o=i.nEpochs,s=i.currentEpoch;n=this.optimizeLayoutStep(s);var r=this.optimizationState.currentEpoch,a=!1===t(r);e=r===o||a}return n},t.prototype.getNEpochs=function(){var t=this.graph;if(this.nEpochs>0)return this.nEpochs;var e=t.nRows;return e<=2500?500:e<=5e3?400:e<=7500?300:200},t}();function y(t,e){for(var n=0,i=0;i<t.length;i++)n+=Math.pow(t[i]-e[i],2);return Math.sqrt(n)}e.UMAP=v,e.euclidean=y,e.cosine=function(t,e){for(var n=0,i=0,o=0,s=0;s<t.length;s++)n+=t[s]*e[s],i+=Math.pow(t[s],2),o+=Math.pow(e[s],2);return 0===i&&0===o?0:0===i||0===o?1:1-n/Math.sqrt(i*o)};var b=function(){this.currentEpoch=0,this.headEmbedding=[],this.tailEmbedding=[],this.head=[],this.tail=[],this.epochsPerSample=[],this.epochOfNextSample=[],this.epochOfNextNegativeSample=[],this.epochsPerNegativeSample=[],this.moveOther=!0,this.initialAlpha=1,this.alpha=1,this.gamma=1,this.a=1.5769434603113077,this.b=.8950608779109733,this.dim=2,this.nEpochs=500,this.nVertices=0};function w(t,e){return t>e?e:t<-e?-e:t}function S(t,e){for(var n=0,i=0;i<t.length;i++)n+=Math.pow(t[i]-e[i],2);return n}function C(t,e){var n=f.linear(0,3*t,300).map((function(t){return t<e?1:t})),i=f.zeros(n.length).map((function(i,o){return n[o]>=e?Math.exp(-(n[o]-e)/t):i})),o={x:n,y:i},r=m.default(o,(function(t){var e=s(t,2),n=e[0],i=e[1];return function(t){return 1/(1+n*Math.pow(t,2*i))}}),{damping:1.5,initialValues:[.5,.5],gradientDifference:.1,maxIterations:100,errorTolerance:.01}).parameterValues,a=s(r,2);return{a:a[0],b:a[1]}}function T(t,e,n,i){return void 0===n&&(n=1),void 0===i&&(i=5),t.map((function(t,o,s){return-1===e[o]||-1===e[s]?t*Math.exp(-n):e[o]!==e[s]?t*Math.exp(-i):t}))}function M(t){t=h.normalize(t,"max");var e=h.transpose(t),n=h.pairwiseMultiply(e,t);return t=h.add(t,h.subtract(e,n)),h.eliminateZeros(t)}function E(t,e,n){for(var i=f.zeros(t.length).map((function(t){return f.zeros(n[0].length)})),o=0;o<t.length;o++)for(var s=0;s<t[0].length;s++)for(var r=0;r<n[0].length;r++){var a=t[o][s];i[o][r]+=e[o][s]*n[a][r]}return i}e.findABParams=C,e.fastIntersection=T,e.resetLocalConnectivity=M,e.initTransform=E},4517:function(t,e){"use strict";var n=this&&this.__values||function(t){var e="function"==typeof Symbol&&t[Symbol.iterator],n=0;return e?e.call(t):{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}}};function i(t,e){return Math.floor(e()*t)}function o(t){for(var e=[],n=0;n<t;n++)e.push(void 0);return e}function s(t,e){return o(t).map((function(){return e}))}function r(t){return s(t,0)}function a(t){return t.reduce((function(t,e){return t+e}))}Object.defineProperty(e,"__esModule",{value:!0}),e.tauRandInt=i,e.tauRand=function(t){return t()},e.norm=function(t){var e,i,o=0;try{for(var s=n(t),r=s.next();!r.done;r=s.next()){var a=r.value;o+=Math.pow(a,2)}}catch(t){e={error:t}}finally{try{r&&!r.done&&(i=s.return)&&i.call(s)}finally{if(e)throw e.error}}return Math.sqrt(o)},e.empty=o,e.range=function(t){return o(t).map((function(t,e){return e}))},e.filled=s,e.zeros=r,e.ones=function(t){return s(t,1)},e.linear=function(t,e,n){return o(n).map((function(i,o){return t+o*((e-t)/(n-1))}))},e.sum=a,e.mean=function(t){return a(t)/t.length},e.max=function(t){for(var e=0,n=0;n<t.length;n++)e=t[n]>e?t[n]:e;return e},e.max2d=function(t){for(var e=0,n=0;n<t.length;n++)for(var i=0;i<t[n].length;i++)e=t[n][i]>e?t[n][i]:e;return e},e.rejectionSample=function(t,e,n){for(var o=r(t),s=0;s<t;s++)for(var a=!0;a;){for(var l=i(e,n),c=!1,h=0;h<s;h++)if(l===o[h]){c=!0;break}c||(a=!1),o[s]=l}return o},e.reshape2d=function(t,e,n){var i=[],o=0;if(t.length!==e*n)throw new Error("Array dimensions must match input length.");for(var s=0;s<e;s++){for(var r=[],a=0;a<n;a++)r.push(t[o]),o+=1;i.push(r)}return i}},3336:t=>{"use strict";t.exports=$},976:t=>{"use strict";t.exports=DG},4469:t=>{"use strict";t.exports=grok},701:t=>{"use strict";t.exports=rxjs},3870:t=>{"use strict";t.exports=ui},6414:t=>{"use strict";t.exports=wu}},e={};function n(i){var o=e[i];if(void 0!==o)return o.exports;var s=e[i]={id:i,exports:{}};return t[i].call(s.exports,s,s.exports,n),s.exports}n.m=t,n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var i in e)n.o(e,i)&&!n.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},n.u=t=>t+".js",n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},(()=>{var t;n.g.importScripts&&(t=n.g.location+"");var e=n.g.document;if(!t&&e&&(e.currentScript&&(t=e.currentScript.src),!t)){var i=e.getElementsByTagName("script");i.length&&(t=i[i.length-1].src)}if(!t)throw new Error("Automatic publicPath is not supported in this browser");t=t.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),n.p=t})(),n.b=document.baseURI||self.location.href,n.nc=void 0;var i={};(()=>{"use strict";n.r(i),n.d(i,{_package:()=>xt,test:()=>_t,tests:()=>e.QK});var t=n(976),e=n(1061);(0,e.W3)("_first",(()=>{(0,e.Bu)("_first",(()=>{return t=void 0,e=void 0,i=function*(){},new((n=void 0)||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}));var t,e,n,i}))}));var o=n(2012),s=n(9976),r=n(6137),a=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))},l=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};(0,e.W3)("Palettes",(()=>{(0,e.Bu)("testPaletteN",(()=>l(void 0,void 0,void 0,(function*(){yield function(){return a(this,void 0,void 0,(function*(){const t=r.J.Chromatogram;(0,e.l_)(t instanceof s.B,!0),(0,e.l_)(t instanceof r.J,!0)}))}()})))),(0,e.Bu)("testPaletteAA",(()=>l(void 0,void 0,void 0,(function*(){yield function(){return a(this,void 0,void 0,(function*(){const t=o.f.Lesk,n=o.f.RasMol,i=o.f.GrokGroups;(0,e.l_)(t instanceof s.B,!0),(0,e.l_)(n instanceof s.B,!0),(0,e.l_)(i instanceof s.B,!0),(0,e.l_)(t instanceof o.f,!0),(0,e.l_)(n instanceof o.f,!0),(0,e.l_)(i instanceof o.f,!0)}))}()})))),(0,e.Bu)("testPalettePtMe",(()=>l(void 0,void 0,void 0,(function*(){const t=o.f.GrokGroups.get("MeNle"),n=o.f.GrokGroups.get("MeA"),i=o.f.GrokGroups.get("MeG"),s=o.f.GrokGroups.get("MeF"),r=o.f.GrokGroups.get("L"),a=o.f.GrokGroups.get("A"),l=o.f.GrokGroups.get("G"),c=o.f.GrokGroups.get("F");(0,e.l_)(t,r),(0,e.l_)(n,a),(0,e.l_)(i,l),(0,e.l_)(s,c)}))))}));var c=n(4469),h=n(473),u=n(499),d=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};function f(e,n){return d(this,void 0,void 0,(function*(){const i=(yield e()).getCol(n),o=yield c.functions.call("Bio:detectMacromolecule",{col:i});if(o&&(i.semType=o),i.semType===t.SEMTYPE.MACROMOLECULE){const e=`Negative test detected semType='${i.semType}', units='${i.getTag(t.TAGS.UNITS)}'.`;throw new Error(e)}}))}function m(n,i,o,s,r,a,l,h=null){return d(this,void 0,void 0,(function*(){const d=(yield n()).col(i),f=yield c.functions.call("Bio:detectMacromolecule",{col:d});f&&(d.semType=f),(0,e.l_)(d.semType,t.SEMTYPE.MACROMOLECULE),(0,e.l_)(d.getTag(t.TAGS.UNITS),o),(0,e.l_)(d.getTag("aligned"),s),(0,e.l_)(d.getTag("alphabet"),r),h&&(0,e.l_)(d.getTag("separator"),h);const m=new u.C(d);(0,e.l_)(m.getAlphabetSize(),a),(0,e.l_)(m.getAlphabetIsMultichar(),l),m.isHelm()||((0,e.l_)(m.aligned,s),(0,e.l_)(m.alphabet,r))}))}(0,e.W3)("detectors",(()=>{var n,i,o,s,r,a,l,h,u,v,y,b,w,S,C,T,M,E;const A=new(E=class{constructor(){this[n]="id,col1\n1,\n2,\n3,\n4,\n5,",this[i]="col1\n1\n2\n3",this[o]="col1\n4\n5\n6\n7",this[s]="col1\n8\n9\n10\n11\n12",this[r]="col1\nCCCCN1C(=O)CN=C(c2cc(F)ccc12)C3CCCCC3\nC1CCCCC1\nCCCCCC\n",this[a]="seq\nACGTC\nCAGTGT\nTTCAAC\n",this[l]="seq\nACGUC\nCAGUGU\nUUCAAC\n",this[h]="seq\nFWPHEY\nYNRQWYV\nMKPSEYV\n",this[u]="seq\n[meI][hHis][Aca]NT[dE][Thr_PO3H2][Aca]D\n[meI][hHis][Aca][Cys_SEt]T[dK][Thr_PO3H2][Aca][Tyr_PO3H2]\n[Lys_Boc][hHis][Aca][Cys_SEt]T[dK][Thr_PO3H2][Aca][Tyr_PO3H2]\n",this[v]="seq\nA*C*G*T*C\nC*A*G*T*G*T\nT*T*C*A*A*C\n",this[y]="seq\nA*C*G*U*C\nC*A*G*U*G*U\nU*U*C*A*A*C\n",this[b]="seq\nF-W-P-H-E-Y\nY-N-R-Q-W-Y-V\nM-K-P-S-E-Y-V\n",this[w]="seq\nabc-dfgg-abc1-cfr3-rty-wert\nrut12-her2-rty-wert-abc-abc1-dfgg\nrut12-rty-her2-abc-cfr3-wert-rut12\n",this[S]="seq\nabc/dfgg/abc1/cfr3/rty/wert\nrut12/her2/rty/wert//abc/abc1/dfgg\nrut12/rty/her2/abc/cfr3//wert/rut12\n",this[C]="seq\nA-C--G-T--C-T\nC-A-C--T--G-T\nA-C-C-G-T-A-C-T\n",this[T]="seq\nAC-GT-CT\nCAC-T-GT\nACCGTACT\n",this[M]="seq\nFWR-WYV-KHP\nYNR-WYV-KHP\nMWRSWY-CKHP\n"}},n="negEmpty",i="neg1",o="neg2",s="neg3",r="negSmiles",a="csvFastaDna1",l="fastaRna1",h="fastaPt1",u="fastaUn",v="sepDna",y="sepRna",b="sepPt",w="sepUn1",S="sepUn2",C="sepMsaDna1",T="fastaMsaDna1",M="fastaMsaPt1",E),N={fastaFasta:"System:AppData/Bio/data/sample_FASTA.fasta",fastaPtCsv:"System:AppData/Bio/data/sample_FASTA_PT.csv",msaComplex:"System:AppData/Bio/samples/sample_MSA.csv",fastaCsv:"System:AppData/Bio/samples/sample_FASTA.csv",helmCsv:"System:AppData/Bio/samples/sample_HELM.csv",peptidesComplex:"System:AppData/Bio/tests/peptides_complex_msa.csv",peptidesSimple:"System:AppData/Bio/tests/peptides_simple_msa.csv",testDemogCsv:"System:AppData/Bio/tests/testDemog.csv",testHelmCsv:"System:AppData/Bio/tests/testHelm.csv",testIdCsv:"System:AppData/Bio/tests/testId.csv",testSmilesCsv:"System:AppData/Bio/tests/testSmiles.csv",testSmiles2Csv:"System:AppData/Bio/tests/testSmiles2.csv",testSmilesShort:"System:AppData/Bio/tests/testSmilesShort.csv",testActivityCliffsCsv:"System:AppData/Bio/tests/testActivityCliffs.csv",testCerealCsv:"System:AppData/Bio/tests/testCereal.csv",testUnichemSources:"System:AppData/Bio/tests/testUnichemSources.csv",testDmvOffices:"System:AppData/Bio/tests/testDmvOffices.csv",testAlertCollection:"System:AppData/Bio/tests/testAlertCollection.csv",testSpgi100:"System:AppData/Bio/tests/testSpgi100.csv",testSpgi:"System:AppData/Bio/tests/SPGI-derived.csv",testUrl:"System:AppData/Bio/tests/testUrl.csv"},P={};function x(t,e=_){return()=>d(this,void 0,void 0,(function*(){return t in P||(P[t]=(()=>d(this,void 0,void 0,(function*(){return yield e(N[t])})))()),P[t]}))}function _(e){return d(this,void 0,void 0,(function*(){const n=yield c.dapi.files.readAsText(e);return t.DataFrame.fromCsv(n)}))}const R=e=>()=>d(void 0,void 0,void 0,(function*(){const n=A[e],i=t.DataFrame.fromCsv(n);return yield c.data.detectSemanticTypes(i),i}));(0,e.Bu)("NegativeEmpty",(()=>d(void 0,void 0,void 0,(function*(){yield f(R("negEmpty"),"col1")})))),(0,e.Bu)("Negative1",(()=>d(void 0,void 0,void 0,(function*(){yield f(R("neg1"),"col1")})))),(0,e.Bu)("Negative2",(()=>d(void 0,void 0,void 0,(function*(){yield f(R("neg2"),"col1")})))),(0,e.Bu)("Negative3",(()=>d(void 0,void 0,void 0,(function*(){yield f(R("neg3"),"col1")})))),(0,e.Bu)("NegativeSmiles",(()=>d(void 0,void 0,void 0,(function*(){yield f(R("negSmiles"),"col1")})))),(0,e.Bu)("FastaDna1",(()=>d(void 0,void 0,void 0,(function*(){yield m(R("csvFastaDna1"),"seq","fasta","SEQ","DNA",4,!1)})))),(0,e.Bu)("FastaRna1",(()=>d(void 0,void 0,void 0,(function*(){yield m(R("fastaRna1"),"seq","fasta","SEQ","RNA",4,!1)})))),(0,e.Bu)("FastaPt1",(()=>d(void 0,void 0,void 0,(function*(){yield m(R("fastaPt1"),"seq","fasta","SEQ","PT",20,!1)})))),(0,e.Bu)("FastaUn",(()=>d(void 0,void 0,void 0,(function*(){yield m(R("fastaUn"),"seq","fasta","SEQ.MSA","UN",12,!0)})))),(0,e.Bu)("FastaMsaDna1",(()=>d(void 0,void 0,void 0,(function*(){yield m(R("fastaMsaDna1"),"seq","fasta","SEQ.MSA","DNA",4,!1)})))),(0,e.Bu)("FastaMsaPt1",(()=>d(void 0,void 0,void 0,(function*(){yield m(R("fastaMsaPt1"),"seq","fasta","SEQ.MSA","PT",20,!1)})))),(0,e.Bu)("SepDna",(()=>d(void 0,void 0,void 0,(function*(){yield m(R("sepDna"),"seq","separator","SEQ","DNA",4,!1,"*")})))),(0,e.Bu)("SepRna",(()=>d(void 0,void 0,void 0,(function*(){yield m(R("sepRna"),"seq","separator","SEQ","RNA",4,!1,"*")})))),(0,e.Bu)("SepPt",(()=>d(void 0,void 0,void 0,(function*(){yield m(R("sepPt"),"seq","separator","SEQ","PT",20,!1,"-")})))),(0,e.Bu)("SepUn1",(()=>d(void 0,void 0,void 0,(function*(){yield m(R("sepUn1"),"seq","separator","SEQ","UN",8,!0,"-")})))),(0,e.Bu)("SepUn2",(()=>d(void 0,void 0,void 0,(function*(){yield m(R("sepUn2"),"seq","separator","SEQ","UN",9,!0,"/")})))),(0,e.Bu)("SepMsaN1",(()=>d(void 0,void 0,void 0,(function*(){yield m(R("sepMsaDna1"),"seq","separator","SEQ.MSA","DNA",4,!1,"-")})))),(0,e.Bu)("samplesFastaCsv",(()=>d(void 0,void 0,void 0,(function*(){yield g(x("fastaCsv"),{Sequence:new p("fasta","SEQ","PT",20,!1)})})))),(0,e.Bu)("samplesFastaFasta",(()=>d(void 0,void 0,void 0,(function*(){yield g(x("fastaFasta"),{sequence:new p("fasta","SEQ","PT",20,!1)})})))),(0,e.Bu)("samplesPeptidesComplex",(()=>d(void 0,void 0,void 0,(function*(){yield g(x("peptidesComplex"),{})})))),(0,e.Bu)("samplesMsaComplex",(()=>d(void 0,void 0,void 0,(function*(){yield g(x("msaComplex"),{MSA:new p("separator","SEQ.MSA","UN",161,!0,"/")})})))),(0,e.Bu)("samplesIdCsv",(()=>d(void 0,void 0,void 0,(function*(){yield g(x("testIdCsv"),{})})))),(0,e.Bu)("samplesSarSmallCsv",(()=>d(void 0,void 0,void 0,(function*(){yield g(x("testSmilesCsv"),{})})))),(0,e.Bu)("samplesHelmCsv",(()=>d(void 0,void 0,void 0,(function*(){yield g(x("helmCsv"),{HELM:new p("helm",null,null,160,!0)})})))),(0,e.Bu)("samplesTestHelmCsv",(()=>d(void 0,void 0,void 0,(function*(){yield g(x("testHelmCsv"),{"HELM string":new p("helm",null,null,9,!0)})})))),(0,e.Bu)("samplesTestDemogCsv",(()=>d(void 0,void 0,void 0,(function*(){yield g(x("testDemogCsv"),{})})))),(0,e.Bu)("samplesTestSmiles2Csv",(()=>d(void 0,void 0,void 0,(function*(){yield g(x("testSmiles2Csv"),{})})))),(0,e.Bu)("samplesTestSmilesShort",(()=>d(void 0,void 0,void 0,(function*(){yield g(x("testSmilesShort"),{})})))),(0,e.Bu)("samplesTestActivityCliffsNegativeSmiles",(()=>d(void 0,void 0,void 0,(function*(){yield g(x("testActivityCliffsCsv"),{})})))),(0,e.Bu)("samplesFastaPtCsv",(()=>d(void 0,void 0,void 0,(function*(){yield g(x("fastaPtCsv"),{sequence:new p("fasta","SEQ","PT",20,!1)})})))),(0,e.Bu)("samplesTestCerealCsv",(()=>d(void 0,void 0,void 0,(function*(){yield g(x("testCerealCsv"),{})})))),(0,e.Bu)("samplesTestUnichemSources",(()=>d(void 0,void 0,void 0,(function*(){yield g(x("testUnichemSources"),{})})))),(0,e.Bu)("samplesTestDmvOffices",(()=>d(void 0,void 0,void 0,(function*(){yield g(x("testDmvOffices"),{})})))),(0,e.Bu)("samplesTestAlertCollection",(()=>d(void 0,void 0,void 0,(function*(){yield g(x("testAlertCollection"),{})})))),(0,e.Bu)("samplesTestSpgi",(()=>d(void 0,void 0,void 0,(function*(){yield g(x("testSpgi"),{})})))),(0,e.Bu)("samplesTestSpgi100",(()=>d(void 0,void 0,void 0,(function*(){yield g(x("testSpgi100"),{})})))),(0,e.Bu)("samplesTestUrl",(()=>d(void 0,void 0,void 0,(function*(){yield g(x("testUrl"),{})}))))}));class p{constructor(t,e,n,i,o,s){this.units=t,this.aligned=e,this.alphabet=n,this.alphabetSize=i,this.alphabetIsMultichar=o,this.separator=s}}function g(t,e){return d(this,void 0,void 0,(function*(){const n=yield t(),i=[];for(const o of n.columns.names())if(o in e){const n=e[o];try{yield m(t,o,n.units,n.aligned,n.alphabet,n.alphabetSize,n.alphabetIsMultichar,n.separator)}catch(t){const e=t.toString();i.push(`Positive col '${o}' failed: ${e}`)}}else try{yield f(t,o)}catch(t){const e=t.toString();i.push(`Negative col '${o}' failed: ${e}`)}if(i.length>0)throw new Error(i.join("\n"))}))}var v=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};(0,e.W3)("detectors:weak-and-likely",(()=>{const n={fastaDnaWeak1:"id,colName\n1,TTTTT\n2,TTTTT\n3,TTTTT\n4,TTTTT\n",fastaDnaWeak1LikelyName:"id,seq\n1,TTTTT\n2,TTTTT\n3,TTTTT\n4,TTTTT\n",fastaRnaWeak1:"id,colName\n1,UUUUU\n2,UUUUU\n3,UUUUU\n4,UUUUU\n",fastaRnaWeak1LikelyName:"id,seq\n1,UUUUU\n2,UUUUU\n3,UUUUU\n4,UUUUU\n",fastaPtWeak1:"id,colName\n1,SLSLSPGK\n2,SLSLSPGK\n3,SLSLSPGK\n4,SLSLSPGK\n",fastaPtWeak1LikelyName:"id,seq\n1,SLSLSPGK\n2,SLSLSPGK\n3,SLSLSPGK\n4,SLSLSPGK\n",fastaUn1:"id,colName\n1,word\n2,other\n3,some\n4,another\n",fastaUn1LikelyName:"id,seq\n1,word\n2,other\n3,some\n4,another\n",fastaUn2LikelyName:'protein\nBoombastic\nMegafantastic\n"just-a-random-thought,oy!"\n',fastaUnMsa1LikelyName:"id,seq\n1,word\n2,male\n3,bare\n4,core\n"},i=e=>()=>v(void 0,void 0,void 0,(function*(){const i=n[e],o=t.DataFrame.fromCsv(i);return yield c.data.detectSemanticTypes(o),o}));(0,e.Bu)("fastaDnaWeak1",(()=>v(void 0,void 0,void 0,(function*(){yield f(i("fastaDnaWeak1"),"colName")})))),(0,e.Bu)("fastaDnaWeak1LikelyName",(()=>v(void 0,void 0,void 0,(function*(){yield m(i("fastaDnaWeak1LikelyName"),"seq","fasta","SEQ.MSA","DNA",4,!1)})))),(0,e.Bu)("fastaRnaWeak1",(()=>v(void 0,void 0,void 0,(function*(){yield f(i("fastaRnaWeak1"),"colName")})))),(0,e.Bu)("fastaRnaWeak1LikelyName",(()=>v(void 0,void 0,void 0,(function*(){yield m(i("fastaRnaWeak1LikelyName"),"seq","fasta","SEQ.MSA","RNA",4,!1)})))),(0,e.Bu)("fastaPtWeak1",(()=>v(void 0,void 0,void 0,(function*(){yield f(i("fastaPtWeak1"),"colName")})))),(0,e.Bu)("fastaPtWeak1LikelyName",(()=>v(void 0,void 0,void 0,(function*(){yield m(i("fastaPtWeak1LikelyName"),"seq","fasta","SEQ.MSA","PT",20,!1)})))),(0,e.Bu)("fastaUn1",(()=>v(void 0,void 0,void 0,(function*(){yield f(i("fastaUn1"),"colName")})))),(0,e.Bu)("fastaUn1LikelyName",(()=>v(void 0,void 0,void 0,(function*(){yield f(i("fastaUn1LikelyName"),"seq")})))),(0,e.Bu)("fastaUn2LikelyName",(()=>v(void 0,void 0,void 0,(function*(){yield f(i("fastaUn2LikelyName"),"protein")})))),(0,e.Bu)("fastaUnMsa1LikelyName",(()=>v(void 0,void 0,void 0,(function*(){yield f(i("fastaUnMsa1LikelyName"),"seq")}))))}));var y=n(8447),b=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};(0,e.W3)("detectorsBenchmark",(()=>{let n;function i(i,o,s,r,a,l){return b(this,void 0,void 0,(function*(){return yield function(i,c,h,d){return b(this,void 0,void 0,(function*(){const i=(()=>{const e=function(e,n,i,o,s){let r;switch(e){case"fasta":r=t=>{let e="";for(let n=0;n<t.length;n++){const i=t[n];e+=1==i.length?i:`[${i}]`}return e};break;case"separator":r=(t,e)=>t.join(e);break;default:throw new Error(`Not supported notation '${e}'.`)}const a=(t,e)=>{const n=new Array(e);for(let i=0;i<e;i++)n[i]=t[Math.floor(Math.random()*t.length)];return r(n,s)},l=Array(o);for(let t=0;t<o;t++)l[t]=a(n,i);return t.Column.fromStrings("seq",l)}(o,[...(0,y.gM)(s)],r,a,l);return n.prepare({col:e})})(),c=Date.now(),d=yield h(i),f=Date.now();(function(t,n){const i=new u.C(t);(0,e.l_)(t.semType,n.semType),(0,e.l_)(i.notation,n.notation),(0,e.l_)(i.alphabet,n.alphabet),(0,e.l_)(i.separator,n.separator)})(d,{semType:t.SEMTYPE.MACROMOLECULE,notation:o,alphabet:s,separator:l});const m=f-c;if(m>10){const t=`ET ${m} ms is more than max allowed 10 ms.`;throw console.error(t),new Error(t)}return console.log(`ET ${m} ms is OK.`),m}))}(0,0,(t=>b(this,void 0,void 0,(function*(){return function(t){t.callSync();const e=t.getOutputParamValue(),n=t.inputs.col;return e&&(n.semType=e),n}(t)}))))}))}(0,e.bb)((()=>b(void 0,void 0,void 0,(function*(){const e=t.Func.find({package:"Bio",name:"detectMacromolecule"});n=e[0];const i=t.Column.fromStrings("seq",["ACGT","ACGT","ACGT"]);yield n.prepare({col:i}).call()})))),(0,e.Bu)("fastaDnaShorts50Few50",(()=>b(void 0,void 0,void 0,(function*(){yield i(0,"fasta","DNA",50,50)}))),{skipReason:"#1192"}),(0,e.Bu)("fastaDnaShorts50Many1E6",(()=>b(void 0,void 0,void 0,(function*(){yield i(0,"fasta","DNA",50,1e6)}))),{skipReason:"#1192"}),(0,e.Bu)("fastaDnaLong1e6Few50",(()=>b(void 0,void 0,void 0,(function*(){yield i(0,"fasta","DNA",1e6,50)}))),{skipReason:"#1192"}),(0,e.Bu)("separatorDnaShorts50Few50",(()=>b(void 0,void 0,void 0,(function*(){yield i(0,"separator","DNA",50,50,"/")}))),{skipReason:"#1192"}),(0,e.Bu)("separatorDnaShorts50Many1E6",(()=>b(void 0,void 0,void 0,(function*(){yield i(0,"separator","DNA",50,1e6,"/")}))),{}),(0,e.Bu)("separatorDnaLong1e6Few50",(()=>b(void 0,void 0,void 0,(function*(){yield i(0,"separator","DNA",1e6,50,"/")}))),{skipReason:"#1192"})}));var w=n(6098),S=n(600),C=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};function T(n,i){return C(this,void 0,void 0,(function*(){const o=t.DataFrame.fromCsv(n),s=t.DataFrame.fromCsv(i),r=o.getCol("seq"),a=yield c.functions.call("Bio:detectMacromolecule",{col:r});a&&(r.semType=a);const l=s.getCol("seq"),h=yield(0,w.U)(r,!0);(0,e.f6)(h.toList(),l.toList())}))}function M(n,i,o,s,r,a){return C(this,void 0,void 0,(function*(){const l=t.DataFrame.fromCsv(n),h=t.DataFrame.fromCsv(i),u=l.getCol("seq"),d=h.getCol("seq"),f=l.getCol("seq"),m=yield c.functions.call("Bio:detectMacromolecule",{col:f});m&&(f.semType=m),yield c.data.detectSemanticTypes(l),(0,e.l_)(u.semType,t.SEMTYPE.MACROMOLECULE),(0,e.l_)(u.getTag(t.TAGS.UNITS),o),r&&(0,e.l_)(u.getTag("alphabet"),r);const p=yield(0,S.K)({col:u,pepsea:{method:a}});(0,e.l_)(p.semType,t.SEMTYPE.MACROMOLECULE),(0,e.l_)(p.getTag(t.TAGS.UNITS),s),(0,e.l_)(p.getTag("aligned"),"SEQ.MSA"),r&&(0,e.l_)(p.getTag("alphabet"),r),(0,e.f6)(p.toList(),d.toList())}))}new t.Package,(0,e.W3)("MSA",(()=>C(void 0,void 0,void 0,(function*(){(0,e.Bu)("isCorrect",(()=>C(void 0,void 0,void 0,(function*(){yield T("seq\nFWRWYVKHP\nYNRWYVKHP\nMWRSWYCKHP","seq\nFWR-WYVKHP\nYNR-WYVKHP\nMWRSWYCKHP")})))),(0,e.Bu)("isCorrectLong",(()=>C(void 0,void 0,void 0,(function*(){yield T("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,e.Bu)("isCorrectHelm",(()=>C(void 0,void 0,void 0,(function*(){yield M("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","helm","separator",void 0,"mafft")}))),{skipReason:"GROK-13053"}),(0,e.Bu)("isCorrectHelmLong",(()=>C(void 0,void 0,void 0,(function*(){yield M("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.","helm","separator",void 0,"mafft")}))),{skipReason:"GROK-13053"}),(0,e.Bu)("isCorrectSeparator",(()=>C(void 0,void 0,void 0,(function*(){yield M("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","separator","fasta","PT")})))),(0,e.Bu)("isCorrectSeparatorLong",(()=>C(void 0,void 0,void 0,(function*(){yield M("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-----","separator","fasta","PT")}))))}))));var E=n(3553),A=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};function N(t,n){return A(this,void 0,void 0,(function*(){const i=(0,y.gP)(t);console.debug(`Bio: tests: splitters: src=${JSON.stringify(t)}, res=${JSON.stringify(i)} .`),(0,e.f6)(i,n)}))}(0,e.W3)("splitters",(()=>{let n,i;(0,e.bb)((()=>A(void 0,void 0,void 0,(function*(){n=[],i=[]})))),(0,e.X5)((()=>A(void 0,void 0,void 0,(function*(){i.forEach((t=>{c.shell.closeTable(t)})),n.forEach((t=>t.close()))}))));const o=["M[MeI]YKETLL[MeF]PKTDFPMRGGL[MeA]",["M","MeI","Y","K","E","T","L","L","MeF","P","K","T","D","F","P","M","R","G","G","L","MeA"]],s=["PEPTIDE1{meI.hHis.Aca.N.T.dE.Thr_PO3H2.Aca.D-Tyr_Et.Tyr_ab-dehydroMe.dV.E.N.D-Orn.D-aThr.Phe_4Me}$$$",["meI","hHis","Aca","N","T","dE","Thr_PO3H2","Aca","D-Tyr_Et","Tyr_ab-dehydroMe","dV","E","N","D-Orn","D-aThr","Phe_4Me"]],r=["PEPTIDE1{meI.hHis.Aca.N.T.dK.Thr_PO3H2.Aca.D-Tyr_Et.D-Dap.dV.E.N.pnG.Phe_4Me}$$$",["meI","hHis","Aca","N","T","dK","Thr_PO3H2","Aca","D-Tyr_Et","D-Dap","dV","E","N","pnG","Phe_4Me"]],a=["PEPTIDE1{[meI].[hHis].[Aca].N.T.[dK].[Thr_PO3H2].[Aca].[D-Tyr_Et].[D-Dap].[dV].E.N.[pnG].[Phe_4Me]}$$$",["meI","hHis","Aca","N","T","dK","Thr_PO3H2","Aca","D-Tyr_Et","D-Dap","dV","E","N","pnG","Phe_4Me"]],l=["RNA1{R(U)P.R(T)P.R(G)P.R(C)P.R(A)}$$$$",["R(U)P","R(T)P","R(G)P","R(C)P","R(A)"]],u=["RNA1{P.R(U)P.R(T)}$$$$",["P","R(U)P","R(T)"]],d=["RNA1{P.R(U).P.R(T)}$$$$",["P","R(U)","P","R(T)"]];(0,e.Bu)("fastaMulti",(()=>A(void 0,void 0,void 0,(function*(){yield function(t,n){return A(this,void 0,void 0,(function*(){const i=(0,y.kB)(t);console.debug(`Bio: tests: splitters: src=${JSON.stringify(t)}, res=${JSON.stringify(i)} .`),(0,e.f6)(i,n)}))}(o[0],o[1])})))),(0,e.Bu)("helm1",(()=>A(void 0,void 0,void 0,(function*(){yield N(s[0],s[1])})))),(0,e.Bu)("helm2",(()=>A(void 0,void 0,void 0,(function*(){yield N(r[0],r[1])})))),(0,e.Bu)("helm3-multichar",(()=>A(void 0,void 0,void 0,(function*(){yield N(a[0],a[1])})))),(0,e.Bu)("testHelm1",(()=>A(void 0,void 0,void 0,(function*(){yield N(l[0],l[1])})))),(0,e.Bu)("testHelm2",(()=>A(void 0,void 0,void 0,(function*(){yield N(u[0],u[1])})))),(0,e.Bu)("testHelm3",(()=>A(void 0,void 0,void 0,(function*(){yield N(d[0],d[1])})))),(0,e.Bu)("splitToMonomers",(()=>A(void 0,void 0,void 0,(function*(){const t=yield c.dapi.files.readCsv("System:AppData/Bio/samples/sample_MSA.csv"),o=t.getCol("MSA"),s=yield c.functions.call("Bio:detectMacromolecule",{col:o});s&&(o.semType=s),o.setTag("aligned",E.mU);const r=c.shell.addTableView(t);yield c.data.detectSemanticTypes(t),i.push(t),n.push(r),(0,h.splitToMonomers)(),(0,e.l_)(t.columns.names().includes("17"),!0)}))),{skipReason:"GROK-12766"}),(0,e.Bu)("getHelmMonomers",(()=>A(void 0,void 0,void 0,(function*(){const e=t.DataFrame.fromCsv("HELM,Activity\nPEPTIDE1{hHis.N.T}$$$,5.30751\nPEPTIDE1{hHis.Aca.Cys_SEt}$$$,5.72388\n"),n=["hHis","Aca","Cys_SEt","N","T"],i=e.getCol("HELM"),o=(0,h.getHelmMonomers)(i),s=n.filter((t=>!o.includes(t))),r=o.filter((t=>!n.includes(t)));if(s.length>0||r.length){const t=[];throw s.length>0&&t.push(`Missed monomers ${JSON.stringify(s)}.`),r.length>0&&t.push(`Unexpected monomers ${JSON.stringify(r)}.`),new Error(t.join(" "))}}))))}));var P=n(7228),x=n(1345),_=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};(0,e.W3)("monomerLibraries",(()=>{let t,n=null;(0,e.bb)((()=>_(void 0,void 0,void 0,(function*(){t=yield(0,P.JN)(),n=yield c.dapi.userDataStorage.get(x.RV,!0)})))),(0,e.X5)((()=>_(void 0,void 0,void 0,(function*(){yield c.dapi.userDataStorage.put(x.RV,n,!0)})))),(0,e.Bu)("default",(()=>_(void 0,void 0,void 0,(function*(){yield c.dapi.userDataStorage.put(x.RV,{},!0),yield t.loadLibraries(!0);const n=t.getBioLib();(0,e.l_)(n.getTypes().length>0,!0)}))))}));var R=n(4004);function L(){const e=[];return e.push(t.Column.fromList("string","MSA",new Array(Math.pow(10,6)).fill("meI/hHis/Aca/N/T/dE/Thr_PO3H2/Aca/D-Tyr_Et/Tyr_ab-dehydroMe/dV/E/N/D-Orn/D-aThr//Phe_4Me"))),e.push(t.Column.fromList("string","Activity",new Array(Math.pow(10,6)).fill("5.30751"))),e}function I(){const e=[],n="meI/hHis/Aca/N/T/dE/Thr_PO3H2/Aca/D-Tyr_Et/Tyr_ab-dehydroMe/dV/E/N/D-Orn/D-aThr".repeat(Math.pow(10,5));return e.push(t.Column.fromList("string","MSA",new Array(Math.pow(10,2)).fill(n))),e.push(t.Column.fromList("string","Activity",new Array(Math.pow(10,2)).fill("7.30751"))),e}function G(e,n){const i=e(),o=t.DataFrame.fromColumns(i),s=Date.now();var r;(r=o.columns.byName("MSA")).semType=t.SEMTYPE.MACROMOLECULE,r.setTag(t.TAGS.UNITS,"separator"),r.setTag("aligned","SEQ.MSA"),r.setTag("alphabet","UN"),r.setTag("separator","/"),c.shell.addTableView(o);const a=Date.now()-s;console.log(`Performance test: ${n}: ${a}ms`)}var D=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};(0,e.W3)("renderers",(()=>{let n,i;(0,e.bb)((()=>D(void 0,void 0,void 0,(function*(){n=[],i=[]})))),(0,e.X5)((()=>D(void 0,void 0,void 0,(function*(){})))),(0,e.Bu)("long sequence performance ",(()=>D(void 0,void 0,void 0,(function*(){G(I,"Long sequences")})))),(0,e.Bu)("many sequence performance",(()=>D(void 0,void 0,void 0,(function*(){G(L,"Many sequences")})))),(0,e.Bu)("rendererMacromoleculeFasta",(()=>D(void 0,void 0,void 0,(function*(){yield function(){return D(this,void 0,void 0,(function*(){const o=yield c.dapi.files.readAsText("System:AppData/Bio/samples/sample_FASTA.csv"),s=t.DataFrame.fromCsv(o),r=s.getCol("Sequence"),a=yield c.functions.call("Bio:detectMacromolecule",{col:r});a&&(r.semType=a);const l=c.shell.addTableView(s);yield c.data.detectSemanticTypes(s),i.push(s),n.push(l);const h=r.getTag(t.TAGS.CELL_RENDERER);(0,e.l_)(h,"sequence")}))}()})))),(0,e.Bu)("rendererMacromoleculeSeparator",(()=>D(void 0,void 0,void 0,(function*(){yield function(){return D(this,void 0,void 0,(function*(){const o=yield c.dapi.files.readAsText("System:AppData/Bio/data/sample_SEPARATOR_PT.csv"),s=t.DataFrame.fromCsv(o),r=s.getCol("sequence"),a=yield c.functions.call("Bio:detectMacromolecule",{col:r});a&&(r.semType=a);const l=c.shell.addTableView(s);yield c.data.detectSemanticTypes(s),i.push(s),n.push(l);const h=r.getTag(t.TAGS.CELL_RENDERER);(0,e.l_)(h,"sequence")}))}()})))),(0,e.Bu)("rendererMacromoleculeDifference",(()=>D(void 0,void 0,void 0,(function*(){yield function(){return D(this,void 0,void 0,(function*(){const o=t.Column.fromStrings("SequencesDiff",["meI/hHis/Aca/N/T/dK/Thr_PO3H2/Aca#D-Tyr_Et/Tyr_ab-dehydroMe/meN/E/N/dV"]);o.tags[t.TAGS.UNITS]="separator",o.tags.separator="/",o.semType=E.Of.MACROMOLECULE_DIFFERENCE;const s=t.DataFrame.fromColumns([o]),r=c.shell.addTableView(s);yield c.data.detectSemanticTypes(s),i.push(s),n.push(r);const a=o.getTag(t.TAGS.CELL_RENDERER);(0,e.l_)(a,E.Of.MACROMOLECULE_DIFFERENCE)}))}()})))),(0,e.Bu)("afterMsa",(()=>D(void 0,void 0,void 0,(function*(){yield function(){return D(this,void 0,void 0,(function*(){const o=yield c.dapi.files.readAsText("System:AppData/Bio/data/sample_FASTA.fasta"),s=(0,h.importFasta)(o)[0],r=s.getCol("sequence"),a=yield c.functions.call("Bio:detectMacromolecule",{col:r});a&&(r.semType=a);const l=c.shell.addTableView(s);yield c.data.detectSemanticTypes(s),console.log("Bio: tests/renderers/afterMsa, table view"),console.log(`Bio: tests/renderers/afterMsa, src before test semType="${r.semType}", units="${r.getTag(t.TAGS.UNITS)}", cell.renderer="${r.getTag(t.TAGS.CELL_RENDERER)}"`),(0,e.l_)(r.semType,t.SEMTYPE.MACROMOLECULE),(0,e.l_)(r.getTag(t.TAGS.UNITS),"fasta"),(0,e.l_)(r.getTag("aligned"),"SEQ"),(0,e.l_)(r.getTag("alphabet"),"PT"),(0,e.l_)(r.getTag(t.TAGS.CELL_RENDERER),"sequence");const d=yield(0,S.K)({col:r});l.grid.invalidate(),(0,e.l_)(d.semType,t.SEMTYPE.MACROMOLECULE),(0,e.l_)(d.getTag(t.TAGS.UNITS),"fasta"),(0,e.l_)(d.getTag("aligned"),"SEQ.MSA"),(0,e.l_)(d.getTag("alphabet"),"PT"),(0,e.l_)(d.getTag(t.TAGS.CELL_RENDERER),"sequence"),new u.C(d),i.push(s),n.push(l)}))}()})))),(0,e.Bu)("afterConvert",(()=>D(void 0,void 0,void 0,(function*(){yield function(){return D(this,void 0,void 0,(function*(){const o=yield c.dapi.files.readAsText("System:AppData/Bio/data/sample_FASTA_PT.csv"),s=t.DataFrame.fromCsv(o),r=s.col("sequence"),a=yield c.functions.call("Bio:detectMacromolecule",{col:r});a&&(r.semType=a);const l=c.shell.addTableView(s);yield c.data.detectSemanticTypes(s),n.push(l),i.push(s);const h=yield(0,R.o)(r,"separator","/"),d=h.getTag(t.TAGS.CELL_RENDERER);(0,e.l_)(d,"sequence"),new u.C(h)}))}()}))),{skipReason:"GROK-12765"}),(0,e.Bu)("selectRendererBySemType",(()=>D(void 0,void 0,void 0,(function*(){yield function(){return D(this,void 0,void 0,(function*(){const o=t.Column.fromStrings("SequencesDiff",["meI/hHis/Aca/N/T/dK/Thr_PO3H2/Aca#D-Tyr_Et/Tyr_ab-dehydroMe/meN/E/N/dV"]);o.tags[t.TAGS.UNITS]="separator",o.tags.separator="/",o.semType=E.Of.MACROMOLECULE_DIFFERENCE;const s=t.DataFrame.fromColumns([o]),r=c.shell.addTableView(s);i.push(s),n.push(r),yield(0,e.gw)(100);const a=o.getTag(t.TAGS.CELL_RENDERER);if("MacromoleculeDifference"!==a)throw new Error(`Units 'separator', separator '/' and semType 'MacromoleculeDifference' have been manually set on column but after df was added as table, view renderer has set to '${a}' instead of correct 'MacromoleculeDifference'.`)}))}()})))),(0,e.Bu)("setRendererManually",(()=>D(void 0,void 0,void 0,(function*(){yield function(){return D(this,void 0,void 0,(function*(){const o=t.Column.fromStrings("SequencesDiff",["meI/hHis/Aca/N/T/dK/Thr_PO3H2/Aca#D-Tyr_Et/Tyr_ab-dehydroMe/meN/E/N/dV"]);o.tags[t.TAGS.UNITS]="separator",o.tags.separator="/",o.semType=t.SEMTYPE.MACROMOLECULE;const s="MacromoleculeDifference";o.setTag(t.TAGS.CELL_RENDERER,s);const r=t.DataFrame.fromColumns([o]);yield c.data.detectSemanticTypes(r);const a=c.shell.addTableView(r);i.push(r),n.push(a),yield(0,e.gw)(100);const l=o.getTag(t.TAGS.CELL_RENDERER);if(l!==s)throw new Error(`Tag 'cell.renderer' has been manually set to '${s}' for column but after df was added as table, tag 'cell.renderer' has reset to '${l}' instead of manual '${s}'.`)}))}()}))),{skipReason:"GROK-11212"})}));var W=n(7767),F=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};(0,e.W3)("converters",(()=>{let n;!function(t){t.fastaPt="fastaPt",t.separatorPt="separatorPt",t.helmPt="helmPt",t.fastaDna="fastaDna",t.separatorDna="separatorDna",t.helmDna="helmDna",t.fastaRna="fastaRna",t.separatorRna="separatorRna",t.helmRna="helmRna",t.fastaGaps="fastaGaps",t.separatorGaps="separatorGaps",t.helmGaps="helmGaps",t.fastaUn="fastaUn",t.separatorUn="separatorUn",t.helmUn="helmUn",t.helmLoneDeoxyribose="helmLoneDeoxyribose",t.helmLoneRibose="helmLoneRibose",t.helmLonePhosphorus="helmLonePhosphorus",t.fastaLoneDeoxyribose="fastaLoneDeoxyribose",t.fastaLoneRibose="fastaLoneRibose",t.fastaLonePhosphorus="fastaLonePhosphorus"}(n||(n={}));const i={fastaPt:"seq\nFWPHEY\nYNRQWYV\nMKPSEYV\n",separatorPt:"seq\nF-W-P-H-E-Y\nY-N-R-Q-W-Y-V\nM-K-P-S-E-Y-V\n",helmPt:"seq\nPEPTIDE1{F.W.P.H.E.Y}$$$$\nPEPTIDE1{Y.N.R.Q.W.Y.V}$$$$\nPEPTIDE1{M.K.P.S.E.Y.V}$$$$\n",fastaDna:"seq\nACGTC\nCAGTGT\nTTCAAC\n",separatorDna:"seq\nA/C/G/T/C\nC/A/G/T/G/T\nT/T/C/A/A/C\n",helmDna:"seq\nDNA1{D(A)P.D(C)P.D(G)P.D(T)P.D(C)P}$$$$\nDNA1{D(C)P.D(A)P.D(G)P.D(T)P.D(G)P.D(T)P}$$$$\nDNA1{D(T)P.D(T)P.D(C)P.D(A)P.D(A)P.D(C)P}$$$$\n",fastaRna:"seq\nACGUC\nCAGUGU\nUUCAAC\n",separatorRna:"seq\nA*C*G*U*C\nC*A*G*U*G*U\nU*U*C*A*A*C\n",helmRna:"seq\nRNA1{R(A)P.R(C)P.R(G)P.R(U)P.R(C)P}$$$$\nRNA1{R(C)P.R(A)P.R(G)P.R(U)P.R(G)P.R(U)P}$$$$\nRNA1{R(U)P.R(U)P.R(C)P.R(A)P.R(A)P.R(C)P}$$$$\n",fastaGaps:"seq\nFW-PH-EYY\nFYNRQWYV-\nFKP-Q-SEYV\n",separatorGaps:"seq\nF/W//P/H//E/Y/Y\nF/Y/N/R/Q/W/Y/V/\nF/K/P//Q//S/E/Y/V\n",helmGaps:"seq\nPEPTIDE1{F.W.*.P.H.*.E.Y.Y}$$$$\nPEPTIDE1{F.Y.N.R.Q.W.Y.V.*}$$$$\nPEPTIDE1{F.K.P.*.Q.*.S.E.Y.V}$$$$\n",fastaUn:"seq\n[meI][hHis][Aca]NT[dE][Thr_PO3H2][Aca]D\n[meI][hHis][Aca][Cys_SEt]T[dK][Thr_PO3H2][Aca][Tyr_PO3H2]\n[Lys_Boc][hHis][Aca][Cys_SEt]T[dK][Thr_PO3H2][Aca][Tyr_PO3H2]\n",separatorUn:"seq\nmeI-hHis-Aca-N-T-dE-Thr_PO3H2-Aca-D\nmeI-hHis-Aca-Cys_SEt-T-dK-Thr_PO3H2-Aca-Tyr_PO3H2\nLys_Boc-hHis-Aca-Cys_SEt-T-dK-Thr_PO3H2-Aca-Tyr_PO3H2\n",helmUn:"seq\nPEPTIDE1{meI.hHis.Aca.N.T.dE.Thr_PO3H2.Aca.D}$$$$\nPEPTIDE1{meI.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.Aca.Tyr_PO3H2}$$$$\nPEPTIDE1{Lys_Boc.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.Aca.Tyr_PO3H2}$$$$\n",helmLoneDeoxyribose:"seq\nDNA1{D(A).D(C).D(G).D(T).D(C)}$$$$\nDNA1{D(C).D(A).D(G).D(T).D(G).D(T)P}$$$$\nDNA1{D(T).D(T).D(C).D(A).D(A).D(C)P}$$$$\n",helmLoneRibose:"seq\nRNA1{R(A).R(C).R(G).R(U).R(C)}$$$$\nRNA1{R(C).R(A).R(G).R(U).R(G).R(U)P}$$$$\nRNA1{R(U).R(U).R(C).R(A).R(A).R(C)P}$$$$\n",helmLonePhosphorus:"seq\nRNA1{P.P.R(A)P.R(C)P.R(G)P.R(U)P.R(C)P}$$$$\nRNA1{P.P.R(C)P.R(A)P.P.R(G)P.R(U)P.R(G)P.R(U)P}$$$$\nRNA1{P.R(U)P.R(U)P.R(C)P.R(A)P.R(A)P.R(C)P.P.P}$$$$\n"};function o(e){return F(this,void 0,void 0,(function*(){const n=i[e],o=t.DataFrame.fromCsv(n);return yield c.data.detectSemanticTypes(o),o}))}function s(t,n=null){if("separator"===t&&!n)throw new Error(`Argument 'separator' is mandatory for target notation '${t.toString()}'.`);return function(i){const o=new W.L(i).convert(t,n);return(0,e.l_)(o.getTag("units"),t),o}}function r(t,n,i){return F(this,void 0,void 0,(function*(){const s=(yield o(t)).getCol("seq"),r=n(s),a=(yield o(i)).getCol("seq");(0,e.f6)(r.toList(),a.toList()),new u.C(r)}))}(0,e.Bu)("testFastaPtToSeparator",(()=>F(void 0,void 0,void 0,(function*(){yield r(n.fastaPt,s("separator","-"),n.separatorPt)})))),(0,e.Bu)("testFastaDnaToSeparator",(()=>F(void 0,void 0,void 0,(function*(){yield r(n.fastaDna,s("separator","/"),n.separatorDna)})))),(0,e.Bu)("testFastaRnaToSeparator",(()=>F(void 0,void 0,void 0,(function*(){yield r(n.fastaRna,s("separator","*"),n.separatorRna)})))),(0,e.Bu)("testFastaGapsToSeparator",(()=>F(void 0,void 0,void 0,(function*(){yield r(n.fastaGaps,s("separator","/"),n.separatorGaps)})))),(0,e.Bu)("testFastaUnToSeparator",(()=>F(void 0,void 0,void 0,(function*(){yield r(n.fastaUn,s("separator","-"),n.separatorUn)})))),(0,e.Bu)("testFastaPtToHelm",(()=>F(void 0,void 0,void 0,(function*(){yield r(n.fastaPt,s("helm"),n.helmPt)})))),(0,e.Bu)("testFastaDnaToHelm",(()=>F(void 0,void 0,void 0,(function*(){yield r(n.fastaDna,s("helm"),n.helmDna)})))),(0,e.Bu)("testFastaRnaToHelm",(()=>F(void 0,void 0,void 0,(function*(){yield r(n.fastaRna,s("helm"),n.helmRna)})))),(0,e.Bu)("testFastaGapsToHelm",(()=>F(void 0,void 0,void 0,(function*(){yield r(n.fastaGaps,s("helm"),n.helmGaps)})))),(0,e.Bu)("testSeparatorPtToFasta",(()=>F(void 0,void 0,void 0,(function*(){yield r(n.separatorPt,s("fasta"),n.fastaPt)})))),(0,e.Bu)("testSeparatorDnaToFasta",(()=>F(void 0,void 0,void 0,(function*(){yield r(n.separatorDna,s("fasta"),n.fastaDna)})))),(0,e.Bu)("testSeparatorRnaToFasta",(()=>F(void 0,void 0,void 0,(function*(){yield r(n.separatorRna,s("fasta"),n.fastaRna)})))),(0,e.Bu)("testSeparatorGapsToFasta",(()=>F(void 0,void 0,void 0,(function*(){yield r(n.separatorGaps,s("fasta"),n.fastaGaps)})))),(0,e.Bu)("testSeparatorUnToFasta",(()=>F(void 0,void 0,void 0,(function*(){yield r(n.separatorUn,s("fasta"),n.fastaUn)})))),(0,e.Bu)("testSeparatorPtToHelm",(()=>F(void 0,void 0,void 0,(function*(){yield r(n.separatorPt,s("helm"),n.helmPt)})))),(0,e.Bu)("testSeparatorDnaToHelm",(()=>F(void 0,void 0,void 0,(function*(){yield r(n.separatorDna,s("helm"),n.helmDna)})))),(0,e.Bu)("testSeparatorRnaToHelm",(()=>F(void 0,void 0,void 0,(function*(){yield r(n.separatorRna,s("helm"),n.helmRna)})))),(0,e.Bu)("testSeparatorGapsToHelm",(()=>F(void 0,void 0,void 0,(function*(){yield r(n.separatorGaps,s("helm"),n.helmGaps)})))),(0,e.Bu)("testHelmDnaToFasta",(()=>F(void 0,void 0,void 0,(function*(){yield r(n.helmDna,s("fasta"),n.fastaDna)})))),(0,e.Bu)("testHelmRnaToFasta",(()=>F(void 0,void 0,void 0,(function*(){yield r(n.helmRna,s("fasta"),n.fastaRna)})))),(0,e.Bu)("testHelmPtToFasta",(()=>F(void 0,void 0,void 0,(function*(){yield r(n.helmPt,s("fasta"),n.fastaPt)})))),(0,e.Bu)("testHelmUnToFasta",(()=>F(void 0,void 0,void 0,(function*(){yield r(n.helmUn,s("fasta"),n.fastaUn)})))),(0,e.Bu)("testHelmDnaToSeparator",(()=>F(void 0,void 0,void 0,(function*(){yield r(n.helmDna,s("separator","/"),n.separatorDna)})))),(0,e.Bu)("testHelmRnaToSeparator",(()=>F(void 0,void 0,void 0,(function*(){yield r(n.helmRna,s("separator","*"),n.separatorRna)})))),(0,e.Bu)("testHelmPtToSeparator",(()=>F(void 0,void 0,void 0,(function*(){yield r(n.helmPt,s("separator","-"),n.separatorPt)})))),(0,e.Bu)("testHelmUnToSeparator",(()=>F(void 0,void 0,void 0,(function*(){yield r(n.helmUn,s("separator","-"),n.separatorUn)})))),(0,e.Bu)("testHelmLoneRibose",(()=>F(void 0,void 0,void 0,(function*(){yield r(n.helmLoneRibose,s("fasta"),n.fastaRna)})))),(0,e.Bu)("testHelmLoneDeoxyribose",(()=>F(void 0,void 0,void 0,(function*(){yield r(n.helmLoneDeoxyribose,s("separator","/"),n.separatorDna)})))),(0,e.Bu)("testHelmLonePhosphorus",(()=>F(void 0,void 0,void 0,(function*(){yield r(n.helmLonePhosphorus,s("fasta"),n.fastaRna)}))))}));var H=n(5226),k=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};(0,e.W3)("fastaFileHandler",(()=>{const n=["description:1","description:2","description:3","description:4"],i=(t.Column.fromStrings("description",n),["MDYKETLLMPKTDFPMRGGLPNKEPQIQEKW","MIEVFLFGIVLGLIPITLAGLFVTAYLQYRRGDQLDL","MMELVLKTIIGPIVVGVVLRIVDKWLNKDK","MDRTDEVSNHTHDKPTLTWFEEIFEEYHSPFHN"]);function o(t){const o=new H.i(t),s=o.descriptionsArray,r=o.sequencesArray;(0,e.f6)([s,r],[n,i])}(0,e.Bu)("testNormalFormatting",(()=>k(void 0,void 0,void 0,(function*(){o(">description:1\nMDYKETLLMPKTDFPMRGGLPNKEPQIQEKW\n\n>description:2\nMIEVFLFGIVLGLIPITLAGLFVTAYLQYRRGDQLDL\n\n>description:3\nMMELVLKTIIGPIVVGVVLRIVDKWLNKDK\n\n>description:4\nMDRTDEVSNHTHDKPTLTWFEEIFEEYHSPFHN\n")})))),(0,e.Bu)("testExtraSpaces",(()=>k(void 0,void 0,void 0,(function*(){o(">description:1\n MDYKETLLMPKTDFPMRGGLPNKEPQIQEKW\n\n>description:2\nMI EVF LFGIVLGLI PITLAGLFVTAY LQYRRGDQLDL\n\n>description:3\nM MELVLKTI IGPI VVGVVLR IVDKWLNKDK\n\n>description:4\nMDR TDEVSNHTHDKP TLTWFEEIFEEYHSPFHN\n ")})))),(0,e.Bu)("testExtraNewlines",(()=>k(void 0,void 0,void 0,(function*(){o(">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 O=n(9943),V=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};(0,e.W3)("fastaExport",(()=>{let n;!function(t){t.single="single",t.multi="multi"}(n||(n={}));const i={[n.single]:{src:"MDYKETLLMPKTDFPMRGGLP",tgt:["MDYKETLLMP","KTDFPMRGGL","P"]},[n.multi]:{src:"M[MeI]YKETLL[MeF]PKTDFPMRGGL[MeA]",tgt:["M[MeI]YKETLL[MeF]P","KTDFPMRGGL","[MeA]"]}};let o;!function(t){t.test1="test1",t.test2="test2"}(o||(o={}));const s={[o.test1]:{srcCsv:"id,seq\n1,MDYKETLLMP\n2,KTDFPMRGGL\n3,P",idCols:["id"],seqCol:"seq",lineWidth:10,tgtFasta:">1\nMDYKETLLMP\n>2\nKTDFPMRGGL\n>3\nP\n"},[o.test2]:{srcCsv:"id,id2,seq\n1,seqA,M[MeI]YKETLL[MeF]P\n2,seqB,KTDFPMRGGL\n3,seqC,[MeA]\n",idCols:["id2","id"],seqCol:"seq",lineWidth:5,tgtFasta:">seqA|1\nM[MeI]YKE\nTLL[MeF]P\n>seqB|2\nKTDFP\nMRGGL\n>seqC|3\n[MeA]\n"}};function r(t,n=10){const o=y.kB,s=i[t].src,r=(0,O.sK)(s,o,n),a=i[t].tgt;(0,e.f6)(r,a)}function a(n){return V(this,void 0,void 0,(function*(){const i=t.DataFrame.fromCsv(n.srcCsv),o=i.getCol(n.seqCol),s=n.idCols.map((t=>i.getCol(t))),r=(0,O.i$)(s,o,n.lineWidth);(0,e.l_)(r,n.tgtFasta)}))}(0,e.Bu)("wrapSequenceSingle",(()=>V(void 0,void 0,void 0,(function*(){r(n.single,10)})))),(0,e.Bu)("wrapSequenceMulti",(()=>V(void 0,void 0,void 0,(function*(){r(n.multi,10)})))),(0,e.Bu)("saveAsFastaTest1",(()=>V(void 0,void 0,void 0,(function*(){a(s[o.test1])})))),(0,e.Bu)("saveAsFastaTest2",(()=>V(void 0,void 0,void 0,(function*(){a(s[o.test2])}))))}));var U=n(7331),B=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};(0,e.W3)("bio",(()=>{const n="seq\nACGTCT\nCAGTGT\nTTCAAC\n";(0,e.Bu)("testGetStatsHelm1",(()=>B(void 0,void 0,void 0,(function*(){const n=t.DataFrame.fromCsv("seq\nPEPTIDE1{meI}$$$$\n").getCol("seq"),i=(0,y.fy)(n,1,y.gP);(0,e.Wh)(i.freq,{meI:1}),(0,e.l_)(i.sameLength,!0)})))),(0,e.Bu)("testGetStatsN1",(()=>B(void 0,void 0,void 0,(function*(){yield function(n){return B(this,void 0,void 0,(function*(){const i=t.DataFrame.fromCsv(n).col("seq"),o=(0,y.fy)(i,5,y.kB);(0,e.Wh)(o.freq,{A:4,C:5,G:3,T:6}),(0,e.l_)(o.sameLength,!0)}))}(n)})))),(0,e.Bu)("testGetAlphabetSimilarity",(()=>B(void 0,void 0,void 0,(function*(){yield function(){return B(this,void 0,void 0,(function*(){const t=new Set(Object.keys(r.V.Names)),n=(0,y.KX)({A:2041,C:3015,G:3015,T:2048,"-":1e3},t);(0,e.l_)(n>.6,!0)}))}()})))),(0,e.Bu)("testPickupPaletteN1",(()=>B(void 0,void 0,void 0,(function*(){yield function(n){return B(this,void 0,void 0,(function*(){const i=t.DataFrame.fromCsv(n).col("seq"),o=(0,y.dQ)(i);(0,e.l_)(o instanceof r.J,!0)}))}(n)})))),(0,e.Bu)("testPickupPaletteN1e",(()=>B(void 0,void 0,void 0,(function*(){yield function(n){return B(this,void 0,void 0,(function*(){const n=t.DataFrame.fromCsv("seq\nACGTAT\nCAGTTG\nTTCG2C\n").col("seq"),i=(0,y.dQ)(n);(0,e.l_)(i instanceof r.J,!0)}))}()})))),(0,e.Bu)("testPickupPaletteAA1",(()=>B(void 0,void 0,void 0,(function*(){yield function(n){return B(this,void 0,void 0,(function*(){const n=t.DataFrame.fromCsv("seq\nFWPHEYV\nYNRQWYV\nMKPSEYV\n").col("seq"),i=(0,y.dQ)(n);(0,e.l_)(i instanceof o.f,!0)}))}()})))),(0,e.Bu)("testPickupPaletteX",(()=>B(void 0,void 0,void 0,(function*(){yield function(n){return B(this,void 0,void 0,(function*(){const n=t.DataFrame.fromCsv("seq\nXZJ{}2\n5Z4733\n3Z6></\n675687\n").col("seq"),i=(0,y.dQ)(n);(0,e.l_)(i instanceof U.kQ,!0)}))}()}))))})),(0,e.W3)("WebLogo.monomerToShort",(()=>{(0,e.Bu)("longMonomerSingle",(()=>B(void 0,void 0,void 0,(function*(){yield(0,e.l_)((0,y.GU)("S",5),"S")})))),(0,e.Bu)("longMonomerShort",(()=>B(void 0,void 0,void 0,(function*(){yield(0,e.l_)((0,y.GU)("Short",5),"Short")})))),(0,e.Bu)("longMonomerLong56",(()=>B(void 0,void 0,void 0,(function*(){yield(0,e.l_)((0,y.GU)("Long56",5),"Long5…")})))),(0,e.Bu)("longMonomerComplexFirstPartShort",(()=>B(void 0,void 0,void 0,(function*(){yield(0,e.l_)((0,y.GU)("Long-long",5),"Long…")})))),(0,e.Bu)("longMonomerComplexFirstPartLong56",(()=>B(void 0,void 0,void 0,(function*(){yield(0,e.l_)((0,y.GU)("Long56-long",5),"Long5…")}))))}));var Y=n(2433),K=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};function $(t,n){(0,e.l_)(t.name,n.name),(0,e.f6)(Object.keys(t.freq),Object.keys(n.freq));for(const i in t.freq)(0,e.l_)(t.freq[i].count,n.freq[i].count)}(0,e.W3)("WebLogo-positions",(()=>{let n,i;const o="seq\nATC-G-TTGC--\nATC-G-TTGC--\n-TC-G-TTGC--\n-TC-GCTTGC--\n-TC-GCTTGC--";(0,e.bb)((()=>K(void 0,void 0,void 0,(function*(){n=[],i=[]})))),(0,e.X5)((()=>K(void 0,void 0,void 0,(function*(){})))),(0,e.Bu)("allPositions",(()=>K(void 0,void 0,void 0,(function*(){const s=t.DataFrame.fromCsv(o),r=c.shell.addTableView(s),a=s.getCol("seq");a.semType=t.SEMTYPE.MACROMOLECULE,a.setTag(t.TAGS.UNITS,"fasta"),a.setTag("alphabet","DNA"),a.setTag("aligned","SEQ.MSA");const l=yield s.plot.fromType("WebLogo");r.dockManager.dock(l.root,t.DOCK_TYPE.DOWN),n.push(r),i.push(s);const h=l.positions,u=[new Y.CK(0,"1",{A:new Y.yW(2),"-":new Y.yW(3)}),new Y.CK(1,"2",{T:new Y.yW(5)}),new Y.CK(2,"3",{C:new Y.yW(5)}),new Y.CK(3,"4",{"-":new Y.yW(5)}),new Y.CK(4,"5",{G:new Y.yW(5)}),new Y.CK(5,"6",{"-":new Y.yW(3),C:new Y.yW(2)}),new Y.CK(6,"7",{T:new Y.yW(5)}),new Y.CK(7,"8",{T:new Y.yW(5)}),new Y.CK(8,"9",{G:new Y.yW(5)}),new Y.CK(9,"10",{C:new Y.yW(5)}),new Y.CK(10,"11",{"-":new Y.yW(5)}),new Y.CK(11,"12",{"-":new Y.yW(5)})];(0,e.l_)(h.length,u.length);for(let t=0;t<h.length;t++){(0,e.l_)(h[t].name,u[t].name);for(const n in h[t].freq)(0,e.l_)(h[t].freq[n].count,u[t].freq[n].count)}})))),(0,e.Bu)("positions with shrinkEmptyTail option true (filtered)",(()=>K(void 0,void 0,void 0,(function*(){const o=t.DataFrame.fromCsv("seq\n-TC-G-TTGC--\n-TC-GCTTGC--\n-T--C-GT-\n-T--C-GT-\n-T--C-GT-\n-T--CCGT-"),s=c.shell.addTableView(o),r=o.getCol("seq");r.semType=t.SEMTYPE.MACROMOLECULE,r.setTag(t.TAGS.UNITS,"fasta"),r.setTag("alphabet","DNA"),r.setTag("aligned","SEQ"),o.filter.init((t=>t>2)),o.filter.fireChanged();const a=yield o.plot.fromType("WebLogo",{shrinkEmptyTail:!0});s.dockManager.dock(a.root,t.DOCK_TYPE.DOWN),n.push(s),i.push(o);const l=a.positions,h=[new Y.CK(0,"1",{"-":new Y.yW(3)}),new Y.CK(1,"2",{T:new Y.yW(3)}),new Y.CK(2,"3",{"-":new Y.yW(3)}),new Y.CK(3,"4",{"-":new Y.yW(3)}),new Y.CK(4,"5",{C:new Y.yW(3)}),new Y.CK(5,"6",{"-":new Y.yW(2),C:new Y.yW(1)}),new Y.CK(6,"7",{G:new Y.yW(3)}),new Y.CK(7,"8",{T:new Y.yW(3)}),new Y.CK(8,"9",{"-":new Y.yW(3)})];(0,e.l_)(l.length,h.length);for(let t=0;t<l.length;t++){(0,e.l_)(l[t].name,h[t].name);for(const n in l[t].freq)(0,e.l_)(l[t].freq[n].count,h[t].freq[n].count)}})))),(0,e.Bu)("positions with skipEmptyPositions option",(()=>K(void 0,void 0,void 0,(function*(){const s=t.DataFrame.fromCsv(o),r=c.shell.addTableView(s),a=s.getCol("seq");a.semType=t.SEMTYPE.MACROMOLECULE,a.setTag(t.TAGS.UNITS,"fasta"),a.setTag("alphabet","DNA"),a.setTag("aligned","SEQ.MSA");const l=yield s.plot.fromType("WebLogo",{skipEmptyPositions:!0});r.dockManager.dock(l.root,t.DOCK_TYPE.DOWN),n.push(r),i.push(s);const h=l.positions,u=[new Y.CK(0,"1",{A:new Y.yW(2),"-":new Y.yW(3)}),new Y.CK(1,"2",{T:new Y.yW(5)}),new Y.CK(2,"3",{C:new Y.yW(5)}),new Y.CK(4,"5",{G:new Y.yW(5)}),new Y.CK(5,"6",{"-":new Y.yW(3),C:new Y.yW(2)}),new Y.CK(6,"7",{T:new Y.yW(5)}),new Y.CK(7,"8",{T:new Y.yW(5)}),new Y.CK(8,"9",{G:new Y.yW(5)}),new Y.CK(9,"10",{C:new Y.yW(5)})];(0,e.l_)(h.length,u.length);for(let t=0;t<h.length;t++)$(h[t],u[t])})))),(0,e.Bu)("count sequences for monomer at position",(()=>K(void 0,void 0,void 0,(function*(){const s=function(e,n,i,o){const s=t.DataFrame.fromCsv(e),r=s.getCol("seq");return r.semType=t.SEMTYPE.MACROMOLECULE,r.setTag(t.TAGS.UNITS,"fasta"),r.setTag("alphabet","DNA"),r.setTag("aligned","SEQ.MSA"),s}(o),r=s.getCol("seq"),a=c.shell.addTableView(s),l=yield s.plot.fromType("WebLogo",{startPositionName:"3",endPositionName:"7",skipEmptyPositions:!0});a.dockManager.dock(l.root,t.DOCK_TYPE.DOWN),n.push(a),i.push(s);const h=l.positions,u=[new Y.CK(2,"3",{C:new Y.yW(5)}),new Y.CK(4,"5",{G:new Y.yW(5)}),new Y.CK(5,"6",{"-":new Y.yW(3),C:new Y.yW(2)}),new Y.CK(6,"7",{T:new Y.yW(5)})];(0,e.l_)(h.length,u.length);for(let t=0;t<h.length;t++)$(h[t],u[t]);const d=l.splitter,f=h[1],m=(0,Y.eZ)(s,r,s.filter,d,"G",f);(0,e.l_)(m,5)}))))}));var Z=n(2568),q=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};(0,e.W3)("checkInputColumn",(()=>{const n="seq\nseq1,\nseq2,\nseq3,\nseq4";(0,e.Bu)("testMsaPos",(()=>q(void 0,void 0,void 0,(function*(){t.Func.find({package:"Bio",name:"multipleSequenceAlignmentDialog"})[0].inputs.find((t=>"sequence"==t.name));const i=t.DataFrame.fromCsv(n).getCol("seq");i.semType=t.SEMTYPE.MACROMOLECULE,i.setTag(t.TAGS.UNITS,"fasta"),i.setTag("alphabet","DNA"),i.setTag("aligned","SEQ");const[o,s]=(0,Z.l)(i,"Test",["fasta"],["DNA","RNA","PT"]);(0,e.l_)(o,!0)})))),(0,e.Bu)("testMsaNegHelm",(()=>q(void 0,void 0,void 0,(function*(){const i=t.DataFrame.fromCsv(n).getCol("seq");i.semType=t.SEMTYPE.MACROMOLECULE,i.setTag(t.TAGS.UNITS,"helm"),i.setTag(".alphabetIsMultichar","true");const[o,s]=(0,Z.l)(i,"Test",["fasta"],["DNA","RNA","PT"]);(0,e.l_)(o,!1)})))),(0,e.Bu)("testMsaNegUN",(()=>q(void 0,void 0,void 0,(function*(){const i=t.DataFrame.fromCsv(n).getCol("seq");i.semType=t.SEMTYPE.MACROMOLECULE,i.setTag(t.TAGS.UNITS,"fasta"),i.setTag("alphabet","UN"),i.setTag(".alphabetSize","11"),i.setTag(".alphabetIsMultichar","true"),i.setTag("aligned","SEQ");const[o,s]=(0,Z.l)(i,"Test",["fasta"],["DNA","RNA","PT"]);(0,e.l_)(o,!1)})))),(0,e.Bu)("testGetActionFunctionMeta",(()=>q(void 0,void 0,void 0,(function*(){t.Func.find({package:"Bio",name:"multipleSequenceAlignmentDialog"})[0].inputs.find((t=>"sequence"==t.name))}))))}));var z=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};function X(e){return z(this,void 0,void 0,(function*(){const n=yield function(t){return z(this,void 0,void 0,(function*(){return yield xt.files.readAsText(t)}))}(e),i=t.DataFrame.fromCsv(n);return i.name=e.replace(".csv",""),i}))}function j(t){return z(this,void 0,void 0,(function*(){const e=yield X(t);return e.name=t.replace(".csv",""),c.shell.addTableView(e)}))}var Q=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};let J,tt;function et(t,e){for(const n of t.view.viewers)if(n.type===e)return n}function nt(t){return Q(this,void 0,void 0,(function*(){const e=new Promise(((e,n)=>{t.computeCompleted.subscribe((t=>Q(this,void 0,void 0,(function*(){try{e(!0)}catch(t){n(t)}}))))}));yield e}))}(0,e.W3)("similarity/diversity",(()=>Q(void 0,void 0,void 0,(function*(){(0,e.bb)((()=>Q(void 0,void 0,void 0,(function*(){J=[],tt=[]})))),(0,e.X5)((()=>Q(void 0,void 0,void 0,(function*(){for(const t of J)t.close();for(const t of tt)c.shell.closeTable(t)})))),(0,e.Bu)("similaritySearchViewer",(()=>Q(void 0,void 0,void 0,(function*(){yield function(){return Q(this,void 0,void 0,(function*(){const n=yield j("tests/sample_MSA_data.csv"),i=n.addViewer("Sequence Similarity Search");yield(0,e.gw)(100);const o=et(i,"Sequence Similarity Search");J.push(o),J.push(n),o.molCol||(yield nt(o)),(0,e.l_)(o.fingerprint,"Morgan"),(0,e.l_)(o.distanceMetric,"Tanimoto"),(0,e.l_)(o.scores.get(0),t.FLOAT_NULL),(0,e.l_)(o.idxs.get(0),0),(0,e.l_)(o.molCol.get(0),"D-Tyr_Et/Tyr_ab-dehydroMe/dV/E/N/D-Orn/D-aThr//Phe_4Me"),(0,e.l_)(o.scores.get(1),.4722222089767456),(0,e.l_)(o.idxs.get(1),11),(0,e.l_)(o.molCol.get(1),"meI/hHis//Aca/meM/Tyr_ab-dehydroMe/dV/E/N/D-Orn/D-aThr//Phe_4Me");const s=nt(o);n.dataFrame.currentRowIdx=1,yield s,(0,e.l_)(o.targetMoleculeIdx,1),(0,e.l_)(o.molCol.get(0),"meI/hHis/Aca/Cys_SEt/T/dK/Thr_PO3H2/Aca/Tyr_PO3H2/D-Chg/dV/Phe_ab-dehydro/N/D-Orn/D-aThr//Phe_4Me")}))}()})))),(0,e.Bu)("diversitySearchViewer",(()=>Q(void 0,void 0,void 0,(function*(){yield function(){return Q(this,void 0,void 0,(function*(){const t=yield j("tests/sample_MSA_data.csv"),n=t.addViewer("Sequence Diversity Search");yield(0,e.gw)(10);const i=et(n,"Sequence Diversity Search");J.push(i),J.push(t),i.renderMolIds||(yield nt(i)),(0,e.l_)(i.fingerprint,"Morgan"),(0,e.l_)(i.distanceMetric,"Tanimoto"),(0,e.l_)(i.initialized,!0),(0,e.l_)(i.renderMolIds.length>0,!0)}))}()}))))}))));var it=n(4413),ot=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};(0,e.W3)("substructureFilters",(()=>ot(void 0,void 0,void 0,(function*(){let t,n;(0,e.bb)((()=>ot(void 0,void 0,void 0,(function*(){t=yield(0,P.JN)(),n=yield c.dapi.userDataStorage.get(x.RV,!0),yield c.dapi.userDataStorage.post(x.RV,x.rb,!0),yield t.loadLibraries(!0)})))),(0,e.X5)((()=>ot(void 0,void 0,void 0,(function*(){yield c.dapi.userDataStorage.put(x.RV,n,!0),yield t.loadLibraries(!0)})))),(0,e.Bu)("fasta",(()=>ot(void 0,void 0,void 0,(function*(){const t=yield X("tests/filter_FASTA.csv"),n=new it.ST;yield c.data.detectSemanticTypes(t),n.attach(t),n.bioFilter.substructure="MD",yield(0,e.gw)(100),(0,e.l_)(n.dataFrame.filter.trueCount,3),(0,e.l_)(n.dataFrame.filter.get(0),!0),(0,e.l_)(n.dataFrame.filter.get(3),!0),(0,e.l_)(n.dataFrame.filter.get(8),!0),(0,e.l_)(n.dataFrame.filter.get(1),!1)})))),(0,e.Bu)("separator",(()=>ot(void 0,void 0,void 0,(function*(){const t=yield X("tests/filter_MSA.csv"),n=new it.ST;yield c.data.detectSemanticTypes(t),n.attach(t),n.bioFilter.substructure="meI",yield(0,e.gw)(100),(0,e.l_)(n.dataFrame.filter.trueCount,7),(0,e.l_)(n.dataFrame.filter.get(2),!1),n.bioFilter.substructure="/meI",yield(0,e.gw)(100),(0,e.l_)(n.dataFrame.filter.trueCount,0),n.bioFilter.substructure="meI-hHis",n.bioFilter.separatorInput.value="-",yield(0,e.gw)(100),(0,e.l_)(n.dataFrame.filter.trueCount,7),(0,e.l_)(n.dataFrame.filter.get(2),!1)})))),(0,e.Bu)("helm",(()=>ot(void 0,void 0,void 0,(function*(){const t=yield X("tests/filter_HELM.csv"),n=c.shell.addTableView(t),i=new it.ST;yield c.data.detectSemanticTypes(t),i.attach(t);const o=new Promise(((e,n)=>{t.onFilterChanged.subscribe((t=>ot(void 0,void 0,void 0,(function*(){try{e(!0)}catch(t){n(t)}}))))}));i.bioFilter.helmSubstructure="PEPTIDE1{C}$$$$V2.0",i.bioFilter.onChanged.next(),yield o,(0,e.l_)(i.dataFrame.filter.trueCount,2),(0,e.l_)(i.dataFrame.filter.get(0),!0),(0,e.l_)(i.dataFrame.filter.get(3),!0),i.bioFilter.helmSubstructure="PEPTIDE1{A.C}$$$$V2.0",i.bioFilter.onChanged.next(),yield(0,e.gw)(100),(0,e.l_)(i.dataFrame.filter.trueCount,1),(0,e.l_)(i.dataFrame.filter.get(3),!0),n.close()}))),{skipReason:"GROK-12779"})}))));var st=n(8341);(0,e.W3)("PepSeA",(()=>{(0,e.Bu)("Basic alignment",(()=>{return n=void 0,i=void 0,s=function*(){const n=t.DataFrame.fromCsv('HELM,MSA\n "PEPTIDE1{F.L.R.G.W.[MeF].Y.S.N.N.C}$$$$","F.L.R.G.W.MeF.Y..S.N.N.C"\n "PEPTIDE1{F.L.R.G.Y.[MeF].Y.W.N.C}$$$$","F.L.R.G.Y.MeF.Y.W...N.C"\n "PEPTIDE1{F.G.Y.[MeF].Y.W.S.D.N.C}$$$$","F...G.Y.MeF.Y.W.S.D.N.C"\n "PEPTIDE1{F.L.R.G.Y.[MeF].Y.W.S.N.D.C}$$$$","F.L.R.G.Y.MeF.Y.W.S.N.D.C"\n "PEPTIDE1{F.V.R.G.Y.[MeF].Y.W.S.N.C}$$$$","F.V.R.G.Y.MeF.Y.W.S..N.C"'),i=yield(0,st.f)(n.getCol("HELM"),"msa(HELM)"),o=n.getCol("MSA");for(let t=0;t<i.length;++t)(0,e.l_)(i.get(t)==o.get(t),!0)},new((o=void 0)||(o=Promise))((function(t,e){function r(t){try{l(s.next(t))}catch(t){e(t)}}function a(t){try{l(s.throw(t))}catch(t){e(t)}}function l(e){var n;e.done?t(e.value):(n=e.value,n instanceof o?n:new o((function(t){t(n)}))).then(r,a)}l((s=s.apply(n,i||[])).next())}));var n,i,o,s}),{skipReason:"GROK-12764"})}));(0,e.W3)("viewers",(()=>{const n=t.Func.find({package:"Bio",tags:["viewer"]}).map((t=>t.friendlyName));for(const t of n)(0,e.Bu)(t,(()=>{return n=void 0,i=void 0,s=function*(){yield(0,e.AB)(t,yield X("data/sample_FASTA_DNA.csv"),!0)},new((o=void 0)||(o=Promise))((function(t,e){function r(t){try{l(s.next(t))}catch(t){e(t)}}function a(t){try{l(s.throw(t))}catch(t){e(t)}}function l(e){var n;e.done?t(e.value):(n=e.value,n instanceof o?n:new o((function(t){t(n)}))).then(r,a)}l((s=s.apply(n,i||[])).next())}));var n,i,o,s}))}));var rt=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};const at="seq\nACGTC\nCAGTGT\nTTCAAC\n",lt="seq\nAC-GT-CT\nCAC-T-GT\nACCGTACT\n",ct="seq\nabc-dfgg-abc1-cfr3-rty-wert\nrut12-her2-rty-wert-abc-abc1-dfgg\nrut12-rty-her2-abc-cfr3-wert-rut12\n";(0,e.W3)("UnitsHandler",(()=>{function n(e){return rt(this,void 0,void 0,(function*(){const n=t.DataFrame.fromCsv(e);yield c.data.detectSemanticTypes(n);const i=new u.C(n.getCol("seq"));return[n,i]}))}function i(e,n,i){return rt(this,void 0,void 0,(function*(){const o=t.DataFrame.fromCsv(e),s=o.getCol("seq");s.setTag(n,i),s.semType=t.SEMTYPE.MACROMOLECULE,"separator"===i&&s.setTag("separator","-");const r=new u.C(o.getCol("seq"));return[o,r]}))}(0,e.Bu)("Seq-Fasta",(()=>rt(void 0,void 0,void 0,(function*(){const[t,i]=yield n(at);(0,e.l_)(i.notation,"fasta"),(0,e.l_)(i.isMsa(),!1)})))),(0,e.Bu)("Seq-Fasta-MSA",(()=>rt(void 0,void 0,void 0,(function*(){const[t,i]=yield n(lt);(0,e.l_)(i.notation,"fasta"),(0,e.l_)(i.isMsa(),!0)})))),(0,e.Bu)("Seq-Fasta-units",(()=>rt(void 0,void 0,void 0,(function*(){const[n,o]=yield i(at,t.TAGS.UNITS,"fasta");(0,e.l_)(o.notation,"fasta"),(0,e.l_)(o.isMsa(),!1)})))),(0,e.Bu)("Seq-Fasta-MSA-units",(()=>rt(void 0,void 0,void 0,(function*(){const[n,o]=yield i(lt,t.TAGS.UNITS,"fasta");(0,e.l_)(o.notation,"fasta"),(0,e.l_)(o.isMsa(),!0)})))),(0,e.Bu)("Seq-Helm",(()=>rt(void 0,void 0,void 0,(function*(){const[n,o]=yield i("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}$$$$\n",t.TAGS.UNITS,"helm");(0,e.l_)(o.notation,"helm"),(0,e.l_)(o.isHelm(),!0)})))),(0,e.Bu)("Seq-UN",(()=>rt(void 0,void 0,void 0,(function*(){const[n,o]=yield i(ct,t.TAGS.UNITS,"separator");(0,e.l_)(o.notation,"separator"),(0,e.l_)(o.separator,"-"),(0,e.l_)(o.alphabet,"UN")})))),(0,e.Bu)("Seq-UN-auto",(()=>rt(void 0,void 0,void 0,(function*(){const[t,i]=yield n(ct);(0,e.l_)(i.notation,"separator"),(0,e.l_)(i.separator,"-"),(0,e.l_)(i.alphabet,"UN")}))))}));var ht=n(6103),ut=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};const dt=new t.FileSource("System:AppData/Bio"),ft={PT:"peptides fasta",DNA:"dna fasta",MSA:"msa separator"},mt={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"},pt={PT:"tests/to-atomic-level-peptides-output.csv",DNA:"tests/to-atomic-level-dna-output.csv",MSA:"tests/to-atomic-level-msa-output.csv"},gt="molfile(sequence)";function vt(t,e="seq",n){return ut(this,void 0,void 0,(function*(){const i=t.getCol(e),o=n.getBioLib();yield(0,ht.i0)(t,i,o)}))}(0,e.W3)("toAtomicLevel",(()=>ut(void 0,void 0,void 0,(function*(){const n={},i={};let o,s,r=null;function a(t,n){return ut(this,void 0,void 0,(function*(){const i=t.getCol("sequence");yield(0,h.toAtomicLevel)(t,i);const o=t.getCol(gt),s=n.getCol(gt),r=[...o.values()],a=[...s.values()];(0,e.f6)(r,a)}))}(0,e.bb)((()=>ut(void 0,void 0,void 0,(function*(){o=yield(0,h.getMonomerLibHelper)(),r=yield c.dapi.userDataStorage.get(x.RV,!0),yield c.dapi.userDataStorage.put(x.RV,{},!0),yield o.loadLibraries(!0);for(const t in ft)n[t]=yield dt.readCsv(mt[t]),yield c.data.detectSemanticTypes(n[t]),i[t]=yield dt.readCsv(pt[t])})))),(0,e.X5)((()=>ut(void 0,void 0,void 0,(function*(){yield c.dapi.userDataStorage.put(x.RV,r,!0),yield o.loadLibraries(!0)}))));for(const t in ft)(0,e.Bu)(`${ft[t]}`,(()=>ut(void 0,void 0,void 0,(function*(){yield a(n[t],i[t])}))),{skipReason:"GROK-13100"});!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"}(s||(s={}));const l={[s.fastaDna]:"seq\nACGTC\nCAGTGT\nTTCAAC\n",[s.fastaRna]:"seq\nACGUC\nCAGUGU\nUUCAAC\n",[s.fastaPt]:"seq\nFWPHEY\nYNRQWYV\nMKPSEYV\n",[s.separatorDna]:"seq\nA/C/G/T/C\nC/A/G/T/G/T\nT/T/C/A/A/C\n",[s.separatorRna]:"seq\nA*C*G*U*C\nC*A*G*U*G*U\nU*U*C*A*A*C\n",[s.separatorPt]:"seq\nF-W-P-H-E-Y\nY-N-R-Q-W-Y-V\nM-K-P-S-E-Y-V\n",[s.separatorUn]:"seq\nmeI-hHis-Aca-N-T-dE-Thr_PO3H2-Aca-D\nmeI-hHis-Aca-Cys_SEt-T-dK-Thr_PO3H2-Aca-Tyr_PO3H2\nLys_Boc-hHis-Aca-Cys_SEt-T-dK-Thr_PO3H2-Aca-Tyr_PO3H2\n",[s.helm]:"seq\nPEPTIDE1{meI.D-gGlu.Aca.N.T.dE.Thr_PO3H2.Aca.D}$$$\nPEPTIDE1{meI.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.Aca.Tyr_PO3H2}$$$\nPEPTIDE1{Lys_Boc.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.Aca.Tyr_PO3H2}$$$\n"};function u(e){return ut(this,void 0,void 0,(function*(){const n=l[e],i=t.DataFrame.fromCsv(n);return yield c.data.detectSemanticTypes(i),i}))}(0,e.Bu)("fastaDna",(()=>ut(void 0,void 0,void 0,(function*(){yield vt(yield u(s.fastaDna),"seq",o)})))),(0,e.Bu)("fastaRna",(()=>ut(void 0,void 0,void 0,(function*(){yield vt(yield u(s.fastaRna),"seq",o)})))),(0,e.Bu)("fastaPt",(()=>ut(void 0,void 0,void 0,(function*(){yield vt(yield u(s.fastaPt),"seq",o)})))),(0,e.Bu)("separatorDna",(()=>ut(void 0,void 0,void 0,(function*(){yield vt(yield u(s.separatorDna),"seq",o)})))),(0,e.Bu)("separatorDna",(()=>ut(void 0,void 0,void 0,(function*(){yield vt(yield u(s.separatorRna),"seq",o)})))),(0,e.Bu)("separatorPt",(()=>ut(void 0,void 0,void 0,(function*(){yield vt(yield u(s.separatorPt),"seq",o)})))),(0,e.Bu)("separatorUn",(()=>ut(void 0,void 0,void 0,(function*(){yield vt(yield u(s.separatorUn),"seq",o)})))),(0,e.Bu)("helm",(()=>ut(void 0,void 0,void 0,(function*(){yield vt(yield u(s.helm),"seq",o)}))))}))));var yt=n(489),bt=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};function wt(e){return bt(this,void 0,void 0,(function*(){const n=t.DataFrame.fromCsv(e),i=n.col("seq"),o=yield c.functions.call("Bio:detectMacromolecule",{col:i});return o&&(i.semType=o),yield c.data.detectSemanticTypes(n),new u.C(i)}))}function St(t,n,i,o){const s=i(t,n);(0,e.l_)(s,o)}(0,e.W3)("Distance",(()=>bt(void 0,void 0,void 0,(function*(){const t=[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]],n={F:0,W:1,R:2,Y:3},i="FWRWY",o="FWRWW",s="FWY",r="FWRWY",a="FWY",l="FWRRRRY";(0,e.Bu)("protein-distance-function",(()=>bt(void 0,void 0,void 0,(function*(){const t=(yield wt("seq\n FWRWYVKHP\n YNRWYVKHP\n MWRSWYCKHP")).getDistanceFunctionName();(0,e.l_)(t,yt.U.NEEDLEMANN_WUNSCH)})))),(0,e.Bu)("DNA-distance-function",(()=>bt(void 0,void 0,void 0,(function*(){const t=(yield wt("seq\n ATAACG\n ATCGA\n ATCGA")).getDistanceFunctionName();(0,e.l_)(t,yt.U.LEVENSHTEIN)})))),(0,e.Bu)("MSA-distance-function",(()=>bt(void 0,void 0,void 0,(function*(){const t=(yield wt("seq\n ATAAC\n ATCGA\n ATCGA")).getDistanceFunctionName();(0,e.l_)(t,yt.U.HAMMING)})))),(0,e.Bu)("levenstein-sub",(()=>bt(void 0,void 0,void 0,(function*(){const t=yt.o[yt.U.LEVENSHTEIN]();St(i,o,t,1)})))),(0,e.Bu)("levenstein-del",(()=>bt(void 0,void 0,void 0,(function*(){const t=yt.o[yt.U.LEVENSHTEIN]();St(s,r,t,2)})))),(0,e.Bu)("hamming",(()=>bt(void 0,void 0,void 0,(function*(){const t=yt.o[yt.U.HAMMING]();St(s,r,t,3)})))),(0,e.Bu)("needleman-blosum62",(()=>bt(void 0,void 0,void 0,(function*(){const t=yt.o[yt.U.NEEDLEMANN_WUNSCH]();St(i,o,t,-35)})))),(0,e.Bu)("needleman-blosum62-del",(()=>bt(void 0,void 0,void 0,(function*(){const t=yt.o[yt.U.NEEDLEMANN_WUNSCH]();St(s,r,t,-14)})))),(0,e.Bu)("needleman-custom-sub",(()=>bt(void 0,void 0,void 0,(function*(){const e=yt.o[yt.U.NEEDLEMANN_WUNSCH]({scoringMatrix:t,alphabetIndexes:n,gapOpen:1,gapExtend:1});St(i,o,e,-4)})))),(0,e.Bu)("needleman-custom-del",(()=>bt(void 0,void 0,void 0,(function*(){const e=yt.o[yt.U.NEEDLEMANN_WUNSCH]({scoringMatrix:t,alphabetIndexes:n,gapOpen:1,gapExtend:1});St(s,r,e,-1)})))),(0,e.Bu)("needleman-custom-zero-extend",(()=>bt(void 0,void 0,void 0,(function*(){const e=yt.o[yt.U.NEEDLEMANN_WUNSCH]({scoringMatrix:t,alphabetIndexes:n,gapOpen:1,gapExtend:0});St(a,l,e,-2)})))),(0,e.Bu)("needleman-custom-half-extend",(()=>bt(void 0,void 0,void 0,(function*(){const e=yt.o[yt.U.NEEDLEMANN_WUNSCH]({scoringMatrix:t,alphabetIndexes:n,gapOpen:2,gapExtend:1});St(a,l,e,2)})))),(0,e.Bu)("needleman-custom-same-extend",(()=>bt(void 0,void 0,void 0,(function*(){const e=yt.o[yt.U.NEEDLEMANN_WUNSCH]({scoringMatrix:t,alphabetIndexes:n,gapOpen:1,gapExtend:1});St(a,l,e,1)}))))}))));var Ct=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};function Tt(t,n,i,o){return Ct(this,void 0,void 0,(function*(){yield c.data.detectSemanticTypes(t);const s=yield(0,h.activityCliffs)(t,t.getCol(o),t.getCol("Activity"),50,i);(0,e.l_)(null!=s,!0);const r=Array.from(s.root.children).find((t=>{const e=t.className.split(" ");return["ui-btn","ui-btn-ok"].every((t=>e.includes(t)))}));(0,e.l_)(r.innerText.toLowerCase(),`${n} cliffs`)}))}var Mt=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};(0,e.W3)("activityCliffs",(()=>Mt(void 0,void 0,void 0,(function*(){let t,n,i,o,s=[],r=[];(0,e.bb)((()=>Mt(void 0,void 0,void 0,(function*(){s=[],r=[]})))),(0,e.X5)((()=>Mt(void 0,void 0,void 0,(function*(){})))),(0,e.Bu)("activityCliffsOpens",(()=>Mt(void 0,void 0,void 0,(function*(){n=yield X("tests/sample_MSA_data.csv"),r.push(n),t=c.shell.addTableView(n),s.push(t),yield Tt(n,57,"UMAP","MSA")}))),{skipReason:"GROK-12774"}),(0,e.Bu)("activityCliffsWithEmptyRows",(()=>Mt(void 0,void 0,void 0,(function*(){o=yield X("tests/sample_MSA_data_empty_vals.csv"),r.push(o),i=c.shell.addTableView(o),s.push(i),yield Tt(o,57,"UMAP","MSA")}))),{skipReason:"GROK-12774"})}))));var Et=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};function At(t,n,i){return Et(this,void 0,void 0,(function*(){const o=t.getCol(i),s=yield c.functions.call("Bio:detectMacromolecule",{col:o});s&&(o.semType=s);const r=yield(0,h.sequenceSpaceTopMenu)(t,t.col(i),n,"Levenshtein",!0);(0,e.l_)(null!=r,!0)}))}var Nt=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};(0,e.W3)("sequenceSpace",(()=>Nt(void 0,void 0,void 0,(function*(){let t,n,i,o;(0,e.Bu)("sequenceSpaceOpens",(()=>Nt(void 0,void 0,void 0,(function*(){t=yield X("tests/sample_MSA_data.csv"),n=c.shell.addTableView(t),yield At(t,"UMAP","MSA"),c.shell.closeTable(t),n.close()}))),{skipReason:"GROK-12775"}),(0,e.Bu)("sequenceSpaceWithEmptyRows",(()=>Nt(void 0,void 0,void 0,(function*(){i=yield X("tests/sample_MSA_data_empty_vals.csv"),o=c.shell.addTableView(i),yield At(i,"UMAP","MSA"),c.shell.closeTable(i),o.close()}))),{skipReason:"GROK-12775"})}))));var Pt=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};const xt=new t.Package;function _t(n,i,o){return Pt(this,void 0,void 0,(function*(){const s=yield(0,e.ci)({category:n,test:i,testContext:o});return t.DataFrame.fromObjects(s)}))}})(),bio_test=i})();
2
2
  //# sourceMappingURL=package-test.js.map