@datagrok/sequence-translator 1.10.16 → 1.10.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -0
- package/CLAUDE.md +274 -253
- package/CREDITS.md +236 -0
- package/detectors.js +8 -0
- package/dist/package-test.js +1 -1
- package/dist/package-test.js.map +1 -1
- package/dist/package.js +1 -1
- package/dist/package.js.map +1 -1
- package/package.json +3 -3
- package/src/apps/common/model/oligo-toolkit-package.ts +13 -1
- package/src/oligo-renderer/analog-cache.ts +48 -0
- package/src/oligo-renderer/canvas-renderer.ts +129 -15
- package/src/oligo-renderer/cell-renderer.ts +8 -2
- package/src/oligo-renderer/helm-parser.ts +3 -2
- package/src/oligo-renderer/legend-panel.ts +31 -6
- package/src/oligo-renderer/types.ts +21 -0
- package/src/package-api.ts +11 -0
- package/src/package-test.ts +1 -0
- package/src/package.g.ts +14 -0
- package/src/package.ts +60 -2
- package/src/polytool/pt-chem-enum-dialog.ts +50 -10
- package/src/polytool/pt-chem-enum.ts +76 -7
- package/src/polytool/pt-enumerate-seq-dialog.ts +18 -4
- package/src/tests/oligo-cell-editor-tests.ts +83 -0
- package/src/tests/oligo-renderer-tests.ts +64 -1
- package/test-console-output-1.log +196 -147
- package/test-record-1.mp4 +0 -0
package/dist/package-test.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/*! For license information please see package-test.js.LICENSE.txt */
|
|
2
|
-
var sequencetranslator_test;(()=>{var e={6717:(e,t,n)=>{"use strict";n.d(t,{j:()=>r});var o=n(6082);async function r(){const e=o.Func.find({package:"Chem",name:"getRdKitModule"});if(0===e.length)throw new Error('Package "Chem" must be installed for getRdKitModule.');return(await e[0].prepare().call()).getOutputParamValue()}},3599:(e,t,n)=>{"use strict";n.d(t,{o:()=>o.o});var o=n(6869)},9124:(e,t,n)=>{"use strict";n.d(t,{b2:()=>i});var o=n(7389),r=n(6082);async function i(){const e="Helm",t=r.Func.find({package:e,name:"getHelmHelper"});if(0===t.length)throw new Error(`Package '${e}' must be installed for HelmHelper.`);return(await t[0].prepare().call()).getOutputParamValue()}r.JsInputBase,Error,o.input.helmAsync=async function(e,t){return(await i()).createHelmInput(e,t)}},8438:(e,t,n)=>{"use strict";function o(e){return e.startsWith("[")&&e.endsWith("]")?e.slice(1,-1):e}n.d(t,{D:()=>o})},8123:(e,t,n)=>{"use strict";n.d(t,{u:()=>o});const o={V2K_RGP_SHIFT:8,V2K_RGP_LINE:"M RGP",V2K_A_LINE:"A ",V3K_COUNTS_SHIFT:14,V3K_IDX_SHIFT:7,V3K_HEADER_FIRST_LINE:"\nDatagrok macromolecule handler\n\n",V3K_HEADER_SECOND_LINE:" 0 0 0 0 0 0 999 V3000\n",V3K_BEGIN_CTAB_BLOCK:"M V30 BEGIN CTAB\n",V3K_END_CTAB_BLOCK:"M V30 END CTAB\n",V3K_BEGIN_COUNTS_LINE:"M V30 COUNTS ",V3K_COUNTS_LINE_ENDING:" 0 0 0\n",V3K_BEGIN_ATOM_BLOCK:"M V30 BEGIN ATOM\n",V3K_END_ATOM_BLOCK:"M V30 END ATOM\n",V3K_BEGIN_BOND_BLOCK:"M V30 BEGIN BOND\n",V3K_END_BOND_BLOCK:"M V30 END BOND\n",V3K_BOND_CONFIG:" CFG=",V3K_BEGIN_DATA_LINE:"M V30 ",V3K_END:"M END",PRECISION_FACTOR:1e4,DEOXYRIBOSE:{polymerType:"RNA",symbol:"d"},RIBOSE:{polymerType:"RNA",symbol:"r"},PHOSPHATE:{polymerType:"RNA",symbol:"p"},OXYGEN:"O",HYDROGEN:"H"}},6197:(e,t,n)=>{"use strict";n.d(t,{Y:()=>r});var o=n(3599);function r(e){let t;switch(e){case o.o.BASE:case o.o.SUGAR:case o.o.LINKER:case o.o.NUCLEOTIDE:case"nucleotide":t="RNA";break;case o.o.AA:t="PEPTIDE";break;case o.o.CHEM:t="CHEM";break;case o.o.BLOB:t="BLOB";break;default:t="PEPTIDE",console.warn(`Unexpected HelmType '${e}'`)}return t}},9235:(e,t,n)=>{"use strict";n.d(t,{H:()=>c,R:()=>l});var o=n(6082),r=n(1991),i=n.n(r),s=n(330),a=n(3599);async function l(e,t,r,l,c,u,h,d){const p=e.length,m=e.dataFrame,f=Math.max(navigator.hardwareConcurrency-2,1),g=new Array(f).fill(null).map((()=>new Worker(new URL(n.p+n.u(455),n.b)))),y=p/f,b=new Array(f),v=u.getSeqHandler(e),C="RNA"==l?a.o.NUCLEOTIDE:a.o.AA,x=i().count(0).take(e.length).map((e=>{const t=v.getSplitted(e);return i().count(0).take(t.length).map((e=>({position:e,symbol:t.getCanonical(e),biotype:C}))).toArray()})).toArray();for(let e=0;e<f;e++){const n=g[e],o=Math.floor(e*y),i=e===f-1?p:Math.floor((e+1)*y);b[e]=new Promise((e=>{n.onmessage=t=>{e(t.data)}})),n.postMessage({seqList:x,rolesList:d,monomersDict:t,alphabet:r,polymerType:l,start:o,end:i})}const w=[],A=[];await Promise.all(b).then((e=>{for(const t of e)w.push(...t.molfiles),A.push(...t.warnings)})),setTimeout((()=>{g.forEach((e=>{e.terminate()}))}),0);const T=(0,s.qj)(m,e.name),E=o.Column.fromType(o.COLUMN_TYPE.STRING,T,e.length).init((e=>w[e]?.molfile));return E.semType=o.SEMTYPE.MOLECULE,E.meta.units=o.UNITS.Molecule.MOLBLOCK,E.setTag(".sequence-src-col",e.name),{molCol:E,warnings:A}}function c(e,t){const n={},r={};for(const i of e){const e=t.getWebEditorMonomer(i.biotype,i.symbol).backgroundcolor,a=(0,s.vG)(e??o.Color.toRgb(o.Color.mouseOverRows))??[1,0,0,.7];for(const e of i.atoms)n[e]=a;for(const e of i.bonds)r[e]=a}return{atoms:Object.keys(n).map((e=>parseInt(e))),bonds:Object.keys(r).map((e=>parseInt(e))),highlightAtomColors:n,highlightBondColors:r}}},3561:(e,t,n)=>{"use strict";n.d(t,{Hb:()=>l,YN:()=>f,gU:()=>c});var o=n(8123),r=n(294),i=n(3151),s=n(439),a=n(6197);function l(e,t,n){const o=new Map;for(const n of e.getMonomerSymbolsByType(t)){const r=e.getMonomer(t,n);if("RNA"===t||"PEPTIDE"===t&&"Branch"!==r.monomerType){const e={};i.f6.forEach((t=>{e[t]=r[t]})),o.set(n,e)}}return o}function c(e,t,n,i,l){if(0===e.length)return r.vF.createEmpty();const c="RNA"===i&&!!l&&l.length===e.length,{atomCount:m,bondCount:g,needsCapping:y}=function(e,t,n,i,l,c){let u=0,h=0,d=0,p=!0,m=null,f=null;for(let n=0;n<e.length;++n){const o=e[n];if(o.symbol!==s._S){if("*"==o.symbol)throw new Error("Gap canonical symbol is '', not '*");m=(0,r.xb)(t,{symbol:o.symbol,polymerType:(0,a.Y)(o.biotype)}),u+=m.atoms.x.length,h+=m.bonds.bondTypes.length,d++,l&&n%3==2&&(f=m)}}if("PEPTIDE"===i)u+=1,h+=d,d>0&&((m?.meta?.rNodes?.length??0)<2||m?.terminalR2Atom?.toLowerCase()===o.u.HYDROGEN.toLowerCase())&&(p=!1,u-=1,h-=1);else if(l)h+=d,c&&c.length>0&&c[c.length-1]===r.ZN.TERMINAL_3P?p=!1:u+=1;else{const i=n===s.YI.DNA?(0,r.xb)(t,o.u.DEOXYRIBOSE):(0,r.xb)(t,o.u.RIBOSE),a=(0,r.xb)(t,o.u.PHOSPHATE);u+=(e.length-1)*a.atoms.x.length,u+=e.length*i.atoms.x.length,u+=1,h+=(e.length-1)*a.bonds.bondTypes.length,h+=e.length*i.bonds.bondTypes.length,h-=1,h+=3*e.length}return{atomCount:u,bondCount:h,needsCapping:p}}(e,t,n,i,c,l),b=new Array(m),v=new Array(g);let C,x=null,w=null;"PEPTIDE"===i?C=u:(C=d,c||(x=n===s.YI.DNA?(0,r.xb)(t,o.u.DEOXYRIBOSE):(0,r.xb)(t,o.u.RIBOSE),w=(0,r.xb)(t,o.u.PHOSPHATE)));const A={i:0,nodeShift:0,bondShift:0,backbonePositionShift:new Array(2).fill(0),branchPositionShift:new Array(2).fill(0),backboneAttachNode:0,branchAttachNode:0,flipFactor:1},T={sugar:x,phosphate:w,seqLength:c?Math.ceil(e.length/3):e.length,atomCount:m,bondCount:g},E=new r.Cg,S=[];let N,I=0;if(c)!function(e,t,n,o,i,s,l,c,u,d,m){const f=t.length>0&&t[0]===r.ZN.TERMINAL_5P,g=t.length>0&&t[t.length-1]===r.ZN.TERMINAL_3P,y=f?1:0,b=(g?t.length-1:t.length)-y,v=Math.ceil(b/3),C=b===3*v,x=(e,t)=>{const l=(0,r.xb)(n,{symbol:e.symbol,polymerType:(0,a.Y)(e.biotype)}),p=s.nodeShift,f=s.bondShift;h(l,o,i,s),l.stereoAtoms?.forEach((e=>u.push(e+m()))),d(l.atoms.x.length);const g=[];for(let e=p;e<s.nodeShift;++e)g.push(e);const y=[];for(let e=f;e<s.bondShift;++e)y.push(e);c.set(t,{biotype:e.biotype,symbol:e.symbol,atoms:g,bonds:y})};f&&(s.i=0,x(e[0],0));for(let t=0;t<v;++t){s.i=t+(f?1:0);const l=y+3*t,g=l+1,b=e[l],v=e[g],C=(0,r.xb)(n,{symbol:b.symbol,polymerType:(0,a.Y)(b.biotype)}),w=(0,r.xb)(n,{symbol:v.symbol,polymerType:(0,a.Y)(v.biotype)});if(t>=1){const n=y+3*(t-1)+2;x(e[n],n)}const A=s.nodeShift,T=s.bondShift;h(C,o,i,s),C.stereoAtoms?.forEach((e=>u.push(e+m()))),d(C.atoms.x.length);const E=[];for(let e=A;e<s.nodeShift;++e)E.push(e);const S=[];for(let e=T;e<s.bondShift;++e)S.push(e);c.set(l,{biotype:b.biotype,symbol:b.symbol,atoms:E,bonds:S});const N=s.nodeShift,I=s.bondShift;p(w,o,i,s),w.stereoAtoms?.forEach((e=>u.push(e+m()))),d(w.atoms.x.length);const M=[];for(let e=N;e<s.nodeShift;++e)M.push(e);const P=[];for(let e=I;e<s.bondShift;++e)P.push(e);c.set(g,{biotype:v.biotype,symbol:v.symbol,atoms:M,bonds:P})}if(C){const t=y+3*(v-1)+2;x(e[t],t)}g&&(s.i=v+(f?1:0),x(e[t.length-1],t.length-1))}(e,l,t,b,v,A,0,E,S,(e=>{I+=e}),(()=>I));else for(A.i=0;A.i<T.seqLength;++A.i){const n=e[A.i];if(n.symbol===s._S)continue;const o=(0,r.xb)(t,{symbol:n.symbol,polymerType:(0,a.Y)(n.biotype)});N=o.terminalR2Atom;const i=A.nodeShift,l=A.bondShift;C(o,b,v,A,T),o.stereoAtoms?.forEach((e=>S.push(e+I))),I+=o.atoms.x.length;const c=A.nodeShift-i,u=new Array(c);for(let e=0;e<c;++e)u[e]=i+e;const h=A.bondShift-l,d=new Array(h);for(let e=0;e<h;++e)d[e]=l+e;E.set(A.i,{biotype:n.biotype,symbol:n.symbol,atoms:u,bonds:d})}y&&function(e,t,n,r,i=o.u.OXYGEN){const s=n.nodeShift+1;e[r.atomCount]=o.u.V3K_BEGIN_DATA_LINE+s+" "+(i??o.u.OXYGEN)+" "+f(n.backbonePositionShift[0])+" "+n.flipFactor*f(n.backbonePositionShift[1])+" 0.000000 0\n";const a=n.backboneAttachNode,l=s;t[r.bondCount]=o.u.V3K_BEGIN_DATA_LINE+n.bondShift+" 1 "+a+" "+l+"\n"}(b,v,A,T,N??o.u.OXYGEN);const M=o.u.V3K_BEGIN_COUNTS_LINE+m+" "+g+o.u.V3K_COUNTS_LINE_ENDING;let P="";return P+=o.u.V3K_HEADER_FIRST_LINE,P+=o.u.V3K_HEADER_SECOND_LINE,P+=o.u.V3K_BEGIN_CTAB_BLOCK,P+=M,P+=o.u.V3K_BEGIN_ATOM_BLOCK,P+=b.join(""),P+=o.u.V3K_END_ATOM_BLOCK,P+=o.u.V3K_BEGIN_BOND_BLOCK,P+=v.join(""),P+=o.u.V3K_END_BOND_BLOCK,S.length>0&&(P+=function(e){const t=[];let n=`M V30 MDLV30/STEABS ATOMS=(${e.length}`;for(let o=0;o<e.length;o++){const r=`${n} ${e[o]}`;r.length>76?(t.push(`${n} -\n`),n=`M V30 ${e[o]}`):n=r,o===e.length-1&&t.push(`${n})\n`)}return`M V30 BEGIN COLLECTION\n${t.join("")}M V30 END COLLECTION\n`}(S)),P+=o.u.V3K_END_CTAB_BLOCK,P+=o.u.V3K_END,{molfile:P,monomers:E}}function u(e,t,n,o){o.flipFactor=(-1)**(o.i%2),h(e,t,n,o)}function h(e,t,n,r){!function(e,t,n){for(let r=0;r<e.atoms.atomTypes.length;++r){const i=n.nodeShift+r+1;t[n.nodeShift+r]=o.u.V3K_BEGIN_DATA_LINE+i+" "+e.atoms.atomTypes[r]+" "+f(n.backbonePositionShift[0]+e.atoms.x[r])+" "+f(n.backbonePositionShift[1]+n.flipFactor*e.atoms.y[r])+" "+e.atoms.kwargs[r]}}(e,t,r),m(e,n,r),function(e,t,n){if(0!==n.backboneAttachNode){const r=n.bondShift,i=n.backboneAttachNode,s=e.meta.terminalNodes[0]+n.nodeShift;t[n.bondShift-1]=o.u.V3K_BEGIN_DATA_LINE+r+" 1 "+i+" "+s+"\n"}}(e,n,r),null!==e.meta.branchShift&&e.meta.terminalNodes.length>2&&function(e,t){t.branchAttachNode=t.nodeShift+e.meta.terminalNodes[2];for(let n=0;n<2;++n)t.branchPositionShift[n]=t.backbonePositionShift[n]+e.meta.branchShift[n]}(e,r),function(e,t){t.backboneAttachNode=t.nodeShift+e.meta.terminalNodes[1],t.bondShift+=e.bonds.atomPairs.length+1,t.nodeShift+=e.atoms.atomTypes.length,t.backbonePositionShift[0]+=e.meta.backboneShift?.[0]??0,t.backbonePositionShift[1]+=t.flipFactor*(e.meta.backboneShift?.[1]??0)}(e,r)}function d(e,t,n,o,r){if(0===o.i)h(r.sugar,t,n,o);else for(const e of[r.phosphate,r.sugar])h(e,t,n,o);p(e,t,n,o)}function p(e,t,n,r){!function(e,t,n){for(let r=0;r<e.atoms.atomTypes.length;++r){const i=n.nodeShift+r+1;t[n.nodeShift+r]=o.u.V3K_BEGIN_DATA_LINE+i+" "+e.atoms.atomTypes[r]+" "+f(n.branchPositionShift[0]+e.atoms.x[r])+" "+f(n.branchPositionShift[1]+n.flipFactor*e.atoms.y[r])+" "+e.atoms.kwargs[r]}}(e,t,r),m(e,n,r),function(e,t,n){const r=n.bondShift,i=n.branchAttachNode,s=e.meta.terminalNodes[0]+n.nodeShift;t[r-1]=o.u.V3K_BEGIN_DATA_LINE+r+" 1 "+i+" "+s+"\n"}(e,n,r);const i=r.bondShift,s=r.branchAttachNode,a=e.meta.terminalNodes[0]+r.nodeShift;n[i-1]=o.u.V3K_BEGIN_DATA_LINE+i+" 1 "+s+" "+a+"\n",r.bondShift+=e.bonds.atomPairs.length+1,r.nodeShift+=e.atoms.atomTypes.length}function m(e,t,n){for(let r=0;r<e.bonds.atomPairs.length;++r){const i=n.bondShift+r+1,s=e.bonds.atomPairs[r][0]+n.nodeShift,a=e.bonds.atomPairs[r][1]+n.nodeShift;let l="";if(e.bonds.bondConfiguration.has(r)){let t=e.bonds.bondConfiguration.get(r);n.flipFactor<0&&(t=1===t?3:1),l=" CFG="+t}const c=e.bonds.kwargs.has(r)?" "+e.bonds.kwargs.get(r):"";t[n.bondShift+r]=o.u.V3K_BEGIN_DATA_LINE+i+" "+e.bonds.bondTypes[r]+" "+s+" "+a+l+c+"\n"}}function f(e){return Math.round(o.u.PRECISION_FACTOR*e)/o.u.PRECISION_FACTOR}},6077:(e,t,n)=>{"use strict";n.d(t,{C4:()=>f,eM:()=>y});var o=n(4328),r=n(6082),i=n(1991),s=n.n(i),a=n(439),l=n(3561),c=n(9235),u=n(294),h=n(9192),d=n(330),p=n(3599),m=n(8123);async function f(e,t,n,i,l){if(t.semType!==r.SEMTYPE.MACROMOLECULE)return{molCol:null,warnings:[`Only the ${r.SEMTYPE.MACROMOLECULE} columns can be converted to atomic level, the chosen column has semType '${t.semType}'`]};let f=t;const b=i.getSeqHandler(t),v=b.notation===a.Hi.HELM&&function(e,t){const n=t.getSeqHandler(e);if(n.notation!==a.Hi.HELM)return!1;let o=!1;for(let t=0;t<e.length;++t){const e=n.getSplitted(t);if(0===e.length)continue;const r=e.graphInfo,i=r?.polymerTypes;if(!i||i.length!==e.length)return!1;for(const e of i)if("RNA"!==e)return!1;o=!0}return o}(t,i);let C,x;v||b.notation===a.Hi.SEPARATOR||b.notation===a.Hi.BILN||(f=b.convert(a.Hi.SEPARATOR,"."),f.name=t.name);try{v?(C="RNA",x=function(e,t){const n=t.getSeqHandler(e);for(let t=0;t<e.length;++t){const e=n.getSplitted(t);for(let t=0;t<e.length;++t)if(t%3==0&&e.getCanonical(t)===m.u.DEOXYRIBOSE.symbol)return a.YI.DNA}return a.YI.RNA}(t,i)):(x=i.getSeqHandler(f).alphabet,C=(0,d.pz)(x))}catch(e){const[t,n]=(0,h.AP)(e);return{molCol:null,warnings:[t]}}const w=function(e,t){const n=e.length,r=new Array(n),i=t.getSeqHandler(e);let a=!1;const l=i.defaultBiotype;for(let e=0;e<n;++e){const t=i.getSplitted(e);a||(a=0===t.length),r[e]=s().count(0).take(t.length).filter((e=>!t.isGap(e))).map((e=>({position:e,biotype:l,symbol:t.getCanonical(e)}))).toArray()}return a&&o.shell.warning(`Some values in the "${e.name}" column are empty`),r}(f,i),A=v?function(e,t,n){const o=new Array(e.length);for(let r=0;r<e.length;++r){const i=e[r];if(0===i.length){o[r]=void 0;continue}const s=i.length>=1&&null!==g(t,n,i[0].symbol),a=i.length>=1&&!(s&&1===i.length)&&null!==g(t,n,i[i.length-1].symbol),l=i.length-(s?1:0)-(a?1:0);if(l<0||l%3!=0&&l%3!=2){o[r]=void 0;continue}const c=new Array(i.length);let h=0;for(let e=0;e<i.length;++e)0===e&&s?c[e]=u.ZN.TERMINAL_5P:e===i.length-1&&a?c[e]=u.ZN.TERMINAL_3P:(c[e]=h%3,h++);o[r]=c}return o}(w,n,C):new Array(w.length).fill(void 0);if(v)for(const e of w)for(const t of e)t.biotype=p.o.NUCLEOTIDE;const T=y(w,A,C,x,n,l),E=f.length,S=await(0,c.R)(f,T,x,C,n,i,l,A);S.warnings.length>.05*E&&o.shell.warning(`Molfile conversion resulted in ${S.warnings.length} errors`);const N=r.Func.find({name:"convertToV3KViaOCL"})[0];if(N&&S.molCol)try{const e=S.molCol.toList(),t=await N.apply({mols:e});S.molCol.init((n=>t[n]?t[n]:e[n]))}catch(e){console.error(e)}return S}function g(e,t,n){const o=e.getMonomer(t,n);if(!o||!o.rgroups||1!==o.rgroups.length)return null;if("Branch"===o.monomerType)return null;const r=o.rgroups[0].label;return"R1"===r?"r1-only":"R2"===r?"r2-only":null}function y(e,t,n,o,r,i){const s=(0,l.Hb)(r,n,o),c={},h={value:null};if("RNA"===n&&t.some((e=>void 0===e))){const e=o===a.YI.RNA?[m.u.RIBOSE,m.u.PHOSPHATE]:[m.u.DEOXYRIBOSE,m.u.PHOSPHATE];for(const t of e)b(c,t.symbol,s,i,n,h,void 0)}for(let o=0;o<e.length;++o){const r=e[o],a=t[o];for(let e=0;e<r.length;++e){const t=r[e].symbol;if(""===t)continue;const o=a?a[e]:void 0;try{if("RNA"===n&&void 0===o&&3===t.split(/\(|\)/).filter((e=>!!e)).length){const e=t.split(/\(|\)/)[1];b(c,e,s,i,n,h,u.ZN.BASE),c[n]?.[e]&&(c[n][t]=c[n][e])}else b(c,t,s,i,n,h,o)}catch(e){const n=e instanceof Error?e.message:e.toString(),o=e instanceof Error?e.stack:void 0;throw console.error(`bio lib: getMonomersDictFromLib() sym='${t}', error:\n${n}\n${o}`),new Error(`Can't get monomer '${t}' from library: ${n}`)}}}return c}function b(e,t,n,o,r,i,s){const a={polymerType:r,symbol:t};if(!(0,u.bq)(e,a)){const c=function(e,t,n,o,r,i){if(t.has(e)){const a=t.get(e),c=function(e){const t=[];for(const n of e){let e=n.capGroupSmiles;e||(e=n.capGroupSMILES),e=e.replace(/(\[|\]|\*|:|\d)/g,"").replace("OH","O").replace("Oh","O"),t.push(e)}return t}(a.rgroups),h=(s=a.molfile).includes("V3000")?function(e){const t=new Map,n=/M V30 (\d+) R#.+RGROUPS=\((\d+) (\d+)\).*/gm;let o;for(;null!==(o=n.exec(e));)o.index===n.lastIndex&&n.lastIndex++,t.set(parseInt(o[1]),parseInt(o[3]));return t}(s):function(e){const t=new Map;let n=e.indexOf(m.u.V2K_A_LINE,0),o=n;for(;-1!==n;){o=e.indexOf("\n",n);const r=parseInt(e.substring(n,o).replace(/^A\s+/,""));n=e.indexOf("R",o),o=e.indexOf("\n",n);const i=parseInt(e.substring(n,o).replace(/^R/,""));t.set(r,i),n=e.indexOf(m.u.V2K_A_LINE,o)}for(n=e.indexOf(m.u.V2K_RGP_LINE,0),o=e.indexOf("\n",n);-1!==n;){n+=m.u.V2K_RGP_SHIFT,o=e.indexOf("\n",n);const r=e.substring(n,o).replaceAll(/\s+/g," ").split(" ").map((e=>parseInt(e))).slice(1);for(let e=0;e<r.length;e+=2){if(t.has(r[e])&&t.get(r[e])!==r[e+1])throw new Error(`r-group index ${r[e]} has already been added with a different value`);t.set(r[e],r[e+1])}n=e.indexOf(m.u.V2K_RGP_LINE,o)}return t}(s),d=a.molfile.includes("V3000")?a.molfile:function(e,t){const n=t.get_mol(function(e){return e.split("\n").map((e=>{const t=e.indexOf(" R# "),n=e.indexOf(" R ");if(-1===t&&-1===n)return e;const o=-1!==t?t:n,r=e.split("");for(let e=o+5;e<r.length;e++)" "!==r[e]&&(r[e]="0");return r.join("")})).join("\n")}(e)),o=n.get_v3Kmolblock();return n.delete(),o}(function(e){let t=e.indexOf(m.u.V2K_A_LINE,0);-1===t&&(t=e.indexOf(m.u.V2K_RGP_LINE));const n=e.indexOf(m.u.V3K_END,t);return e.substring(0,t)+e.substring(n)}(a.molfile),n),p=function(e){let t=(e=e.replaceAll("\r","")).indexOf(m.u.V3K_BEGIN_COUNTS_LINE)+m.u.V3K_COUNTS_SHIFT,n=e.indexOf(" ",t+1);const o=parseInt(e.substring(t,n));return t=n+1,n=e.indexOf(" ",t+1),{atomCount:o,bondCount:parseInt(e.substring(t,n))}}(d),f=function(e,t){const n=new Array(t),o=new Float32Array(t),r=new Float32Array(t),i=new Array(t);let s=e.indexOf(m.u.V3K_BEGIN_ATOM_BLOCK);s=e.indexOf("\n",s);let a=s;for(let l=0;l<t;l++){s=e.indexOf(m.u.V3K_BEGIN_DATA_LINE,s)+m.u.V3K_IDX_SHIFT,a=e.indexOf(" ",s),s=a+1,a=e.indexOf(" ",s),n[l]=e.substring(s,a);const t=new Array(2);for(let n=0;n<2;++n)s=a+1,a=e.indexOf(" ",s),t[n]=parseFloat(e.substring(s,a));o[l]=t[0],r[l]=t[1],s=a,a=e.indexOf("\n",s)+1,i[l]=e.slice(s,a),s=a}return{atomTypes:n,x:o,y:r,kwargs:i}}(d,p.atomCount),g=function(e,t){const n=new Uint32Array(t),o=new Array(t),r=new Map,i=new Map;let s=e.indexOf(m.u.V3K_BEGIN_BOND_BLOCK);s=e.indexOf("\n",s);let a=s;for(let l=0;l<t;++l){const t=new Array(3);s=e.indexOf(m.u.V3K_BEGIN_DATA_LINE,a)+m.u.V3K_IDX_SHIFT,a=e.indexOf(" ",s);for(let n=0;n<3;++n)s=a+1,a=Math.min(e.indexOf("\n",s),e.indexOf(" ",s)),t[n]=parseInt(e.slice(s,a));n[l]=t[0],o[l]=t.slice(1);const c=e.indexOf("\n",s);let u=e.slice(a,c),h=u.indexOf(m.u.V3K_BOND_CONFIG);if(-1!==h){h=u.indexOf("=",h)+1;let e=u.indexOf(" ",h);-1===e&&(e=u.length);const t=parseInt(u.slice(h,e));r.set(l,t);const n=m.u.V3K_BOND_CONFIG+t.toString();u=u.replace(n,"")}u||i.set(l,u)}return{bondTypes:n,atomPairs:o,bondConfiguration:r,kwargs:i}}(d,p.bondCount),y=function(e,t,n,o){const r={backboneShift:null,branchShift:null,terminalNodes:[],rNodes:[]};if(n&&o&&[1,2].some((e=>!Array.from(o.values()).find((t=>t==e))))){const r=[1,2].find((e=>!Array.from(o.values()).find((t=>t==e)))),i=[1,2].find((e=>Array.from(o.values()).find((t=>t==e)))),s=Array.from(o.keys()).find((e=>o.get(e)===i))-1,a=e.x[s],l=e.y[s],c=t.atomPairs.find((e=>e.includes(s+1))).find((e=>e!==s+1))-1;let u=e.x.reduce(((t,n,o)=>{if(o===s)return t;if(o===c)return t;const r=e.y[o];return Math.sqrt((n-a)**2+(r-l)**2)>Math.sqrt((e.x[t]-a)**2+(e.y[t]-l)**2)?o:t}),-1);if(-1===u&&(u=e.x.length,e.x=new Float32Array([...e.x,-a]),e.y=new Float32Array([...e.y,-l]),e.atomTypes=[...e.atomTypes,"H"],e.kwargs=[...e.kwargs,""],t.atomPairs.push([c+1,u+1]),t.bondTypes=new Uint32Array([...t.bondTypes,1]),t.kwargs.set(t.atomPairs.length-1,"")),o.set(u+1,r),1===r)n.unshift(e.atomTypes[u]);else{if(2!==r)throw new Error(`Unexpected missing R-group: ${r}`);n.splice(1,0,e.atomTypes[u])}}return function(e,t,n){for(const[o,r]of n)e.atomTypes[o-1]=t[r-1]}(e,n,o),function(e,t){t.rNodes=Array.from(e.keys());for(let n=0;n<t.rNodes.length;n++)for(const o of[1,2])if(e.get(t.rNodes[n])===o){const e=t.rNodes[o-1];t.rNodes[o-1]=t.rNodes[n],t.rNodes[n]=e}}(o,r),v(t,r),r}(f,g,c,h),b=function(e){let t=[],n=e.indexOf("M V30 MDLV30/STEABS ATOMS=(");for(;-1!==n;){n+=28;const o=e.indexOf(")",n);t=t.concat(e.substring(n,o).split(" ").slice(1).map((e=>parseInt(e)))),n=o,n=e.indexOf("M V30 MDLV30/STEABS ATOMS=(",n)}return t}(d),x={atoms:f,bonds:g,meta:y,stereoAtoms:b};if("PEPTIDE"===o)T(x);else{const t=i===u.ZN.SUGAR||void 0===i&&(e===m.u.RIBOSE.symbol||e===m.u.DEOXYRIBOSE.symbol),n=i===u.ZN.PHOSPHATE||void 0===i&&e===m.u.PHOSPHATE.symbol;if(i===u.ZN.TERMINAL_5P||i===u.ZN.TERMINAL_3P){const e=a.rgroups?.[0]?.label,t="R1"===e?0:"R2"===e?1:-1,n=i===u.ZN.TERMINAL_5P?1:0;-1!==t&&t!==n&&([x.meta.rNodes[0],x.meta.rNodes[1]]=[x.meta.rNodes[1],x.meta.rNodes[0]],[x.meta.terminalNodes[0],x.meta.terminalNodes[1]]=[x.meta.terminalNodes[1],x.meta.terminalNodes[0]]),T(x)}else t?function(e,t){const n=e.atoms.x,o=e.atoms.y;let r=e.meta.terminalNodes[0]-1;const i=e.meta.rNodes[1]-1;M(e,-n[r],-o[r]);const s=E(n[e.meta.rNodes[2]-1],o[e.meta.rNodes[2]-1]);S(e.atoms,-s),n[e.meta.rNodes[0]-1]>n[e.meta.rNodes[1]-1]&&N(e);const a=E(n[i],o[i]);S(e.atoms,3*Math.PI/2-a),t.value=function(e){const t=e.atoms.x,n=e.atoms.y,o=e.meta.rNodes[2]-1,r=e.meta.terminalNodes[2]-1,i=t[o]-t[r],s=n[o]-n[r];return Math.atan2(i,s)}(e),r=e.meta.terminalNodes[0]-1,M(e,-n[r],-o[r])}(x,r):n?function(e){const t=e.meta.rNodes[1]-1,n=e.meta.rNodes[0]-1,o=e.atoms.x,r=e.atoms.y;M(e,-o[t],-r[t]);const i=E(o[n],r[n]);S(e.atoms,Math.PI/2-i)}(x):function(e,t){const n=e.atoms.x,o=e.atoms.y,r=e.meta.terminalNodes[0]-1,i=e.meta.rNodes[0]-1;M(e,-n[r],-o[r]);const s=E(n[i],o[i]),a=t.value;if(!a)throw new Error("The value of sugarBranchToOYAngle is null");S(e.atoms,Math.PI-s+a);const c=function(e,t){return(0,l.YN)(Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2))}({x:n[e.meta.rNodes[0]-1],y:o[e.meta.rNodes[0]-1]},{x:n[e.meta.terminalNodes[0]-1],y:o[e.meta.terminalNodes[0]-1]});if(1!=c)for(let e=0;e<n.length;++e)n[e]=(0,l.YN)(n[e]/c),o[e]=(0,l.YN)(o[e]/c)}(x,r)}return function(e,t,n,o){if("PEPTIDE"===e){C(t,e);const n=w(t,t.meta.rNodes[1]);n?.removedAtom&&(t.terminalR2Atom=n.removedAtom)}else if(o===u.ZN.TERMINAL_5P)C(t,e),w(t,t.meta.rNodes[1]);else if(o===u.ZN.TERMINAL_3P)w(t,t.meta.rNodes[0]);else{const r=o===u.ZN.SUGAR||void 0===o&&(n===m.u.RIBOSE.symbol||n===m.u.DEOXYRIBOSE.symbol),i=o===u.ZN.PHOSPHATE||void 0===o&&n===m.u.PHOSPHATE.symbol;if(r)w(t,t.meta.rNodes[1]),t.meta.rNodes[1]=t.meta.terminalNodes[1],v(t.bonds,t.meta),C(t,e),w(t,t.meta.rNodes[1]),w(t,t.meta.rNodes[0]),w(t,t.meta.rNodes[2]);else if(i){const n=t.meta.rNodes[0]-1,o=t.atoms.atomTypes[n];o?.toUpperCase()===m.u.HYDROGEN||(t.meta.terminalNodes[0]=t.meta.rNodes[0],M(t,-t.atoms.x[t.meta.terminalNodes[0]-1],-t.atoms.y[t.meta.terminalNodes[0]-1])),C(t,e),w(t,t.meta.rNodes[1])}}}(o,x,e,i),function(e){let t=0;for(;t<e.atoms.atomTypes.length;)e.atoms.atomTypes[t]===m.u.HYDROGEN&&(w(e,t+1),--t),++t}(x),function(e){let t=0;for(;t<e.atoms.atomTypes.length;)"oh"===e.atoms.atomTypes[t]?.toLowerCase()&&(e.atoms.atomTypes[t]="O"),"?"===e.atoms.atomTypes[t]&&(e.atoms.atomTypes[t]="H"),++t}(x),function(e){const t=" RGROUPS=(1 1)";for(let n=0;n<(e.atoms.kwargs?.length??0);n++){const o=e.atoms.kwargs[n];o&&o.includes(t)&&(e.atoms.kwargs[n]=o.replace(t,""))}}(x),x}var s;return null}(t,n,o,r,i,s);if(!c)throw new Error(`Monomer with symbol '${t}' is absent the monomer library`);(0,u.LQ)(e,a,c)}}function v(e,t){const n=t.rNodes;t.terminalNodes=new Array(n.length).fill(0);const o=t.terminalNodes,r=e.atomPairs;let i=0,s=0;for(;i<r.length&&s<o.length;){for(let e=0;e<o.length;++e)for(let t=0;t<2;++t)r[i][t]===n[e]&&(o[e]=r[i][(t+1)%2],n.length,++s);++i}}function C(e,t){e.meta.rNodes.length>1&&(e.meta.backboneShift=x(e,e.meta.rNodes[1]-1,e.meta.terminalNodes[0]-1)),"RNA"===t&&e.meta.rNodes.length>2&&(e.meta.branchShift=x(e,e.meta.rNodes[2]-1,e.meta.terminalNodes[0]-1))}function x(e,t,n){return[(0,l.YN)(e.atoms.x[t]-e.atoms.x[n]),(0,l.YN)(e.atoms.y[t]-e.atoms.y[n])]}function w(e,t){if(void 0!==t){const n=t-1,o=e.atoms,r=e.bonds,i=e.meta,s=o.atomTypes.splice(n,1)[0];o.x=A(Float32Array,o.x,n,1),o.y=A(Float32Array,o.y,n,1),o.kwargs.splice(n,1);for(let e=0;e<i.terminalNodes.length;++e)i.terminalNodes[e]>t?--i.terminalNodes[e]:i.terminalNodes[e]===t&&(i.terminalNodes[e]=-1);for(let e=0;e<i.rNodes.length;++e)i.rNodes[e]>t?--i.rNodes[e]:i.rNodes[e]===t&&(i.rNodes[e]=-1);let a=0;for(;a<r.atomPairs.length;){const e=r.atomPairs[a][0],n=r.atomPairs[a][1];e===t||n===t?(r.atomPairs.splice(a,1),r.bondTypes=A(Uint32Array,r.bondTypes,a,1),r.bondConfiguration.has(a)&&r.bondConfiguration.delete(a),r.kwargs.has(a)&&r.kwargs.delete(a),--a):(r.atomPairs[a][0]=e>t?e-1:e,r.atomPairs[a][1]=n>t?n-1:n),++a}let l=Array.from(r.bondConfiguration.keys());return l.forEach((e=>{if(r.bondConfiguration.has(e)&&e>n){const t=r.bondConfiguration.get(e);r.bondConfiguration.delete(e),r.bondConfiguration.set(e-1,t)}})),l=Array.from(r.kwargs.keys()),l.forEach((e=>{if(r.kwargs.has(e)&&e>n){const t=r.kwargs.get(e);r.kwargs.delete(e),r.kwargs.set(e-1,t)}})),s?{removedAtom:s}:void 0}}function A(e,t,n,o){const r=new e(t.length-o);let i=0,s=0;for(;i<t.length;)i===n&&(i+=o),r[s]=t[i],++s,++i;return r}function T(e){const t=e.meta.terminalNodes[0]-1,n=e.meta.rNodes[0]-1,o=e.atoms.x,r=e.atoms.y;M(e,-o[t],-r[t]);const i=E(o[n],r[n]);S(e.atoms,-i),o[e.meta.rNodes[1]-1]<0&&N(e);const s=function(e){const t=function(e){const t=new Map;for(const n of e.bonds.atomPairs)for(let e=0;e<2;e++){const o=n[e],r=n[(e+1)%2];t.has(o)?t.get(o)?.push(r):t.set(o,new Array(1).fill(r))}return t}(e);let n=0;const o=e.atoms.atomTypes.length;let r=0;if(e.meta.terminalNodes.length<2)return null;for(;0===n;){const i=t.get(e.meta.terminalNodes[1])[r];if(e.atoms.atomTypes[i-1]===m.u.OXYGEN&&i!==e.meta.rNodes[1]&&(n=i),r++,r>o)return null}return n}(e);null!=s&&(function(e,t){e.atoms.y[e.meta.rNodes[1]-1]<0&&e.atoms.y[t-1]<0&&(function(e){I(e,!0)}(e),S(e.atoms,-function(e,t){return E(e,t)+Math.PI/2}(e.atoms.x[e.meta.terminalNodes[1]-1],e.atoms.y[e.meta.terminalNodes[1]-1])))}(e,s),function(e,t){const n=e.atoms.x;n[e.meta.rNodes[1]-1]>n[t-1]&&function(e,t,n){const o=t-1,r=n-1,i=e.atoms.x,s=e.atoms.y,a=i[o],l=s[o];i[o]=i[r],s[o]=s[r],i[r]=a,s[r]=l}(e,t,e.meta.rNodes[1])}(e,s))}function E(e,t){let n;if(0===e)n=t>0?0:Math.PI;else if(0===t)n=e>0?-Math.PI/2:Math.PI/2;else{const o=t/e,r=Math.atan(o);n=e<0?Math.PI/2+r:-Math.PI/2+r}return n}function S(e,t){if(0!==t){const n=e.x,o=e.y,r=Math.cos(t),i=Math.sin(t);for(let e=0;e<n.length;++e){const t=n[e];n[e]=(0,l.YN)(t*r-o[e]*i),o[e]=(0,l.YN)(t*i+o[e]*r)}}}function N(e){I(e,!1)}function I(e,t){if(t){const t=e.atoms.y;for(let e=0;e<t.length;e++)t[e]=-t[e]}else{const t=e.atoms.x;for(let e=0;e<t.length;e++)t[e]=-t[e]}const n=e.bonds.bondConfiguration;for(const[e,t]of n){const o=1===t?3:1;n.set(e,o)}}function M(e,t,n){const o=e.atoms.x,r=e.atoms.y;for(let e=0;e<o.length;++e)o[e]=(0,l.YN)(o[e]+t),void 0!==n&&(r[e]=(0,l.YN)(r[e]+n))}},294:(e,t,n)=>{"use strict";function o(e,t){return e[t.polymerType]?.[t.symbol]}function r(e,t){return!!e[t.polymerType]?.[t.symbol]}function i(e,t,n){let o=e[t.polymerType];o||(o=e[t.polymerType]={}),o[t.symbol]=n}var s;n.d(t,{Cg:()=>a,LQ:()=>i,ZN:()=>s,bq:()=>r,vF:()=>l,xb:()=>o}),function(e){e[e.SUGAR=0]="SUGAR",e[e.BASE=1]="BASE",e[e.PHOSPHATE=2]="PHOSPHATE",e[e.TERMINAL_5P=3]="TERMINAL_5P",e[e.TERMINAL_3P=4]="TERMINAL_3P"}(s||(s={}));class a extends Map{constructor(e){super(e)}}class l{constructor(e,t){this.molfile=e,this.monomers=t}static createEmpty(){return new l("",new a(null))}}},330:(e,t,n)=>{"use strict";n.d(t,{pz:()=>i,qj:()=>r,vG:()=>s});var o=n(2003);function r(e,t){return function(e,t){return e?e.columns.getUnusedName(t):t}(e,`molfile(${t})`)}function i(e){let t;if(e===o.YI.PT||e===o.YI.UN)t="PEPTIDE";else{if(e!==o.YI.RNA&&e!==o.YI.DNA)throw new Error(`Unexpected alphabet '${e}'.`);t="RNA"}return t}function s(e){const t=7===e.length?/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e):/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return t?[parseInt(t[1],16)/256,parseInt(t[2],16)/256,parseInt(t[3],16)/256,t.length>4?parseInt(t[4],16)/256:.3]:null}},4971:(e,t,n)=>{"use strict";n.d(t,{pj:()=>r});var o=n(6082);async function r(){const e=o.Func.find({package:"Bio",name:"getMonomerLibHelper"});if(0===e.length)throw new Error('Package "Bio" must be installed for MonomerLibHelper.');return(await e[0].prepare().call()).getOutputParamValue()}},3151:(e,t,n)=>{"use strict";n.d(t,{f6:()=>o,pe:()=>r});const o=["symbol","molfile","rgroups","name"],r={monomerType:"Backbone",smiles:"",name:"",author:"Datagrok",molfile:"",naturalAnalog:"",rgroups:[],createDate:null,id:0,polymerType:"PEPTIDE",symbol:""};new RegExp("[rd]\\((\\w)\\)p?","g")},9192:(e,t,n)=>{"use strict";function o(e){return"string"==typeof e||e instanceof String?e:"StateError"===e.constructor.name?e.message:"StateError"===e.constructor.name&&"$thrownJsError"in e?o(e.$thrownJsError):e instanceof Error?e.message:e.toString()}function r(e){return e instanceof Error?e.stack:"StateError"===e.constructor.name&&"$thrownJsError"in e?r(e.$thrownJsError):void 0}function i(e){return[o(e),r(e)]}n.d(t,{AP:()=>i})},439:(e,t,n)=>{"use strict";n.d(t,{Hi:()=>o,VR:()=>u,YI:()=>r,_S:()=>l,b9:()=>c,gp:()=>i,qE:()=>i});var o,r,i,s=n(2738);!function(e){e.FASTA="fasta",e.SEPARATOR="separator",e.HELM="helm",e.CUSTOM="custom",e.BILN="biln"}(o||(o={})),function(e){e.DNA="DNA",e.RNA="RNA",e.PT="PT",e.UN="UN"}(r||(r={})),function(e){e.aligned="aligned",e.alphabet="alphabet",e.alphabetSize=".alphabetSize",e.alphabetIsMultichar=".alphabetIsMultichar",e.separator="separator",e.isHelmCompatible=".isHelmCompatible",e.positionNames=".positionNames",e.positionLabels=".positionLabels",e.regions=".regions",e.positionShift=".positionShift",e.selectedPosition=".selectedPosition",e.polymerTypeColumnName=".polymerTypeColumnName",e.annotations=".annotations",e.numberingScheme=".numberingScheme",e.annotationColumnName=".annotationColumnName"}(i||(i={}));const a=new class{constructor(){this.fasta={peptide:new Set(["G","L","Y","S","E","Q","D","N","F","A","K","R","H","C","V","P","W","I","M","T"]),dna:new Set(["A","C","G","T"]),rna:new Set(["A","C","G","U"])}}},l=(new s.aD(r.PT,a.fasta.peptide,.5),new s.aD(r.DNA,a.fasta.dna,.55),new s.aD(r.RNA,a.fasta.rna,.55),""),c={[o.FASTA]:"-",[o.SEPARATOR]:"",[o.HELM]:"*",[o.BILN]:""},u="notationProviderConstructor"},2003:(e,t,n)=>{"use strict";n.d(t,{Hi:()=>o.Hi,YI:()=>o.YI,dh:()=>r.dh,gp:()=>o.gp,qp:()=>r.qp,zS:()=>r.zS});var o=n(439),r=n(7291)},2738:(e,t,n)=>{"use strict";n.d(t,{$G:()=>r,aD:()=>i});var o=n(439);class r{static get notationName(){return"Custom"}static get implementsFromHelm(){return!1}static convertFromHelm(e,t){throw new Error("Method convertFromHelm not implemented for this notation provider")}static async getProviderConstructors(){if(window?.DG){const e=window.DG.Func.find({meta:{role:o.VR}});return Promise.all(e.map((e=>e.apply({}))))}return[]}}class i{constructor(e,t,n){this.name=e,this.alphabet=t,this.cutoff=n}}},7291:(e,t,n)=>{"use strict";n.d(t,{Mu:()=>b,dh:()=>C,zS:()=>E,MD:()=>S,qp:()=>A});var o=n(6082),r=n(1991),i=n.n(r),s=(n(2738),n(439));class a{static makePalette(e,t=!1,n=a){const o={};return e.forEach((e=>{const n=e[0],r=e[1];n.forEach(((e,n)=>{o[e]=this.colourPalette[r][t?0:n]}))})),new n(o)}constructor(e){this._palette=e}get(e,t){return this._palette[e]}}a.undefinedColor="rgb(100,100,100)",a.colourPalette={orange:["rgb(255,187,120)","rgb(245,167,100)","rgb(235,137,70)","rgb(205, 111, 71)"],all_green:["rgb(44,160,44)","rgb(74,160,74)","rgb(23,103,57)","rgb(30,110,96)","rgb(60,131,95)","rgb(24,110,79)","rgb(152,223,138)","rgb(182, 223, 138)","rgb(152, 193, 138)"],all_blue:["rgb(31,119,180)","rgb(23,190,207)","rgb(122, 102, 189)","rgb(158,218,229)","rgb(141, 124, 217)","rgb(31, 120, 150)"],magenta:["rgb(162,106,192)","rgb(197,165,224)","rgb(208,113,218)"],red:["rgb(214,39,40)","rgb(255,152,150)"],st_blue:["rgb(23,190,207)","rgb(158,218,229)","rgb(31,119,180)"],dark_blue:["rgb(31,119,180)","rgb(31, 120, 150)"],light_blue:["rgb(23,190,207)","rgb(158,218,229)","rgb(108, 218, 229)","rgb(23,190,227)"],lilac_blue:["rgb(124,102,211)","rgb(149,134,217)","rgb(97, 81, 150)"],dark_green:["rgb(23,103,57)","rgb(30,110,96)","rgb(60,131,95)","rgb(24,110,79)"],green:["rgb(44,160,44)","rgb(74,160,74)"],light_green:["rgb(152,223,138)","rgb(182, 223, 138)","rgb(152, 193, 138)"],st_green:["rgb(44,160,44)","rgb(152,223,138)","rgb(39, 174, 96)","rgb(74,160,74)"],pink:["rgb(247,182,210)"],brown:["rgb(140,86,75)","rgb(102, 62, 54)"],gray:["rgb(127,127,127)","rgb(199,199,199)","rgb(196,156,148)","rgb(222, 222, 180)"],yellow:["rgb(188,189,34)"],white:["rgb(230,230,230)"]};class l extends a{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,l)),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,l)),this.grokGroups}static get RasMol(){return void 0===this.rasMol&&(this.rasMol=new l({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(e){const t=e in l.aaSynonyms?l.aaSynonyms[e]:e;return super.get(t)}}l.aaSynonyms={MeNle:"L",MeA:"A",MeG:"G",MeF:"F"};class c{static getPalette(e="grok"){switch(e){case"grok":return l.GrokGroups;case"lesk":return l.Lesk;default:throw new Error(`ChemPalette: scheme \`${e}\` does not exist`)}}static getInnerOuter(e){let t=0,n="",o="";for(const r of e)"("==r?t++:")"==r?t--:t?n+=r:o+=r;return isNaN(parseInt(n))?[o,n]:[o,""]}static getColorAAPivot(e="",t="grok"){const n=this.getPalette(t);let[o,r]=this.getInnerOuter(e);if(o=o.length>6?`${o.slice(0,3)}...`:o,r=r.length>6?`${r.slice(0,3)}...`:r,1==e.length||"("==e[1]){const t=e[0]?.toUpperCase();return t in n?[n.get(t),t,r,1]:[this.undefinedColor,o,r,1]}if("d"==e[0]&&e[1]in n&&(2==e.length||"("==e[2])){const t=e[1]?.toUpperCase();return t in n?[n.get(t),t,r,2]:[this.undefinedColor,o,r,2]}if(e.substring(0,3)in this.AAFullNames&&(3==e.length||"("==e[3])){const t=this.AAFullNames[e.substring(0,3)];return t in n?[n.get(t),t,r,3]:[this.undefinedColor,o,r,3]}if(e[0]?.toLowerCase()==e[0]&&e.substring(1,3)in this.AAFullNames&&(4==e.length||"("==e[4])){const t=this.AAFullNames[e.substring(1,3)];return t in n?[n.get(t),t,r,4]:[this.undefinedColor,o,r,4]}return[this.undefinedColor,o,r,0]}}c.SemType="Aminoacids",c.SemTypeMultipleAlignment="AminoacidsMultipleAlignment",c.undefinedColor="rgb(100,100,100)",c.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"},c.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"},c.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(*)*"},c.AAFullNames={Ala:"A",Arg:"R",Asn:"N",Asp:"D",Cys:"C",Gln:"Q",Glu:"E",Gly:"G",His:"H",Ile:"I",Leu:"L",Lys:"K",Met:"M",Phe:"F",Pro:"P",Ser:"S",Thr:"T",Trp:"W",Tyr:"Y",Val:"V"};class u{}u.SemType="Nucleotides",u.SemTypeMultipleAlignment="NucleotidesMultipleAlignment",u.Names={A:"Adenine",C:"Cytosine",G:"Guanine",T:"Thymine",U:"Uracil"};var h=n(4971);function d(e,t=!0){if(null==e)return"rgb(100,100,100)";const n=o.Color.fromHtml(e);if(t){const e=o.Color.g(n),t=o.Color.r(n),r=o.Color.b(n),i=Math.sqrt(Math.pow(0-t,2)+Math.pow(0-e,2)+Math.pow(0-r,2));if(i>210)return`rgb(${t/i*210},${e/i*210},${r/i*210})`}return o.Color.toRgb(n)}class p{static hashCode(e){let t=0;if(0===e.length)return t;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return t}}class m{}class f extends m{static get palette(){return f._pallete||(f._pallete=f.buildPalette()),f._pallete}static buildPalette(){return(0,h.pj)().then((e=>{e.awaitLoaded(1/0).then((()=>{const t=e.getMonomerLib();t.onChanged.subscribe((()=>{f.customMonomerColors={},f.polymerTypes=t.getPolymerTypes();for(const e of this.polymerTypes){const n=t.getMonomerSymbolsByType(e);for(const o of n){const n=t.getMonomer(e,o);n?.meta?.colors?.default?.background&&(this.customMonomerColors[o]||(this.customMonomerColors[o]={}),this.customMonomerColors[o][e]=d(n.meta.colors.default.background))}}}))}))})),[].concat(...Object.values(a.colourPalette))}get(e,t){const n=f.palette.length,o=f.customMonomerColors[e],r=t??"PEPTIDE";if(o&&o[r])return o[r];const i=p.hashCode(e)%n;return d(f.palette[i])}}f._pallete=null,f.customMonomerColors={},f.polymerTypes=[];var g=n(8438),y=n(3599);class b{get length(){return this.mList.length}get graphInfo(){}isGap(e){return this.getOriginal(e)===this.gapOriginalMonomer}getCanonical(e){if(this.length<=e)throw new Error("Index out of bounds");const t=this.mList[e];return t!==this.gapOriginalMonomer?t:s._S}getOriginal(e){if(this.length<=e)throw new Error("Index out of bounds");return this.mList[e]}getCanonicalRegion(e,t){const n=Math.min(Math.max(0,e),this.length),o=Math.max(Math.min(this.length,t),0)-n,r=this.gapOriginalMonomer;return new Array(o).fill(null).map(((e,t)=>{const o=this.mList[t+n];return o===r?s._S:o}))}getOriginalRegion(e,t){const n=Math.min(Math.max(0,e),this.length),o=Math.max(Math.min(this.length,t),0);return new Array(o-n).fill(null).map(((e,t)=>this.mList[t+n]))}get gapOriginal(){return this.gapOriginalMonomer}constructor(e,t){this.mList=e,this.gapOriginalMonomer=t}}class v extends b{constructor(e,t,n,o){super(e.flat(),o),this.mListSeparated=e,this.connections=t,this._graphInfo=void 0,this.polymerTypes=e.map(((e,t)=>new Array(e.length).fill(n[t]))).flat()}get graphInfo(){return this._graphInfo??(this._graphInfo=this.parseConnections()),this._graphInfo}parseConnections(){const e={connections:[],disjointSeqStarts:[],polymerTypes:this.polymerTypes};if((this.connections?.length??0)>0){let t=0;for(let n=0;n<this.mListSeparated.length;++n)e.disjointSeqStarts.push(t),t+=this.mListSeparated[n].length;const n=(this.connections??"").split("|").filter((e=>(e?.length??0)>0)),o=/^(PEPTIDE|RNA|BLOB|CHEM)\d{1,2}$/,r=/^\d{1,2}:R\d{1}-\d{1,2}:R\d{1}$/;for(const t of n){const n=t.split(",");if(3!==n.length||!r.test(n[2])||!o.test(n[0])||!o.test(n[1]))continue;const i=parseInt(n[0].replace(/^(PEPTIDE|RNA|BLOB|CHEM)/,""))-1,s=parseInt(n[1].replace(/^(PEPTIDE|RNA|BLOB|CHEM)/,""))-1,a=n[0].replace(/\d{1,2}$/,""),l=n[1].replace(/\d{1,2}$/,"");if(i<0||i>=this.mListSeparated.length||s<0||s>=this.mListSeparated.length)continue;const c=n[2].split("-");if(2!==c.length)continue;const u=c[0].split(":"),h=c[1].split(":");if(2!==u.length||2!==h.length)continue;const d=parseInt(u[0])-1,p=parseInt(h[0])-1;d<0||d>=this.mListSeparated[i].length||p<0||p>=this.mListSeparated[s].length||e.connections.push({seq1Type:a,seq2Type:l,seqIndex1:i,seqIndex2:s,monomerIndex1:d,monomerIndex2:p,rGroup1:parseInt(u[1].substring(1)),rGroup2:parseInt(h[1].substring(1))})}}return e}}function C(e,t=void 0){return n=>{if(n){let o;const r=new RegExp(`(?<=^|\\${e})("-"|'-'|[^\\${e}]*)(?=\\${e}|$)`,"g");return null!=t?(r.lastIndex=0,o=i()(n.matchAll(r)).take(t).map((e=>e[0])).toArray()):o=n.replaceAll('"-"',"").replaceAll("'-'","").split(e,t),new b(o,s.b9[s.Hi.SEPARATOR])}return new b([],s.b9[s.Hi.SEPARATOR])}}const x=/^((?:[^\[\]()]|\[[^\[\]]*\])+)\(((?:[^\[\]()]|\[[^\[\]]*\])+)\)((?:[^\[\]()]|\[[^\[\]]*\])+)$/,w=/^((?:[^\[\]()]|\[[^\[\]]*\])+)\(((?:[^\[\]()]|\[[^\[\]]*\])+)\)$/,A=e=>{const t=e.indexOf("}$"),n=e.substring(0,t+1),o=e.indexOf("$",t+2),r=e.substring(t+2,o),i=n.split("}|");for(let e=0;e<i.length-1;e++)i[e]=i[e]+"}";const a=i.map((e=>e.replace(/\d{1,2}\{.+\}/,""))),l=i.map(((e,t)=>(e.match(/(?<=\{).+(?=})/)?.[0]?.split(".")??[]).flatMap((e=>{if("RNA"===a[t]){const t=x.exec(e);if(null!=t)return[(0,g.D)(t[1]),(0,g.D)(t[2]),(0,g.D)(t[3])];const n=w.exec(e);if(null!=n)return[(0,g.D)(n[1]),(0,g.D)(n[2])]}return[(0,g.D)(e)]}))));return new v(l,r??"",a,s.b9[s.Hi.HELM])},T=/([^\W_]+)/g;function E(e,t){if(e.length<=t)return e;const n=e.match(T),o=e.length>t||(n?.length??0)>1,r=n?.[0]??" ";return o?r.substring(0,t-1)+"…":r}function S(e){switch(e){case"PEPTIDE":default:return y.o.AA;case"RNA":return y.o.NUCLEOTIDE;case"CHEM":return y.o.CHEM;case"BLOB":return y.o.BLOB}}},8312:(e,t,n)=>{"use strict";n.d(t,{Q:()=>r});var o=n(6082);async function r(){const e=o.Func.find({package:"Bio",name:"getSeqHelper"});if(0===e.length)throw new Error("Package 'Bio' must be installed for SeqHelper.");return(await e[0].prepare().call()).getOutputParamValue()}},6869:(e,t,n)=>{"use strict";var o;n.d(t,{o:()=>o}),function(e){e.BASE="HELM_BASE",e.SUGAR="HELM_SUGAR",e.LINKER="HELM_LINKER",e.AA="HELM_AA",e.CHEM="HELM_CHEM",e.BLOB="HELM_BLOB",e.NUCLEOTIDE="HELM_NUCLETIDE"}(o||(o={}))},2074:(e,t,n)=>{"use strict";n.d(t,{A:()=>a});var o=n(1354),r=n.n(o),i=n(6314),s=n.n(i)()(r());s.push([e.id,".st-colored-text-input > textarea {\n width: 100%;\n color: transparent !important;\n caret-color: var(--grey-6);\n -webkit-text-fill-color: transparent !important;\n background-color: transparent;\n position: relative;\n z-index: 1;\n resize: none;\n height: 22px; /* Fine tuned value to avoid \"jumping\" of the textarea upon autoresize */\n}\n\n.st-colored-text-input > div {\n /* The values here are fine tuned to those of the ui.input textarea in order\n * to achieve precise overlap */\n overflow: auto;\n position: absolute;\n pointer-events: none;\n cursor: text;\n z-index: 0;\n max-width: 100%;\n padding: 2px;\n line-height: normal;\n font-family: 'Roboto', 'Roboto Local', sans-serif;\n font-size: 13px;\n padding-top: 6px !important;\n color: transparent;\n white-space: pre-wrap;\n word-wrap: break-word;\n}\n","",{version:3,sources:["webpack://./src/apps/common/view/components/colored-input/style.css"],names:[],mappings:"AAAA;EACE,WAAW;EACX,6BAA6B;EAC7B,0BAA0B;EAC1B,+CAA+C;EAC/C,6BAA6B;EAC7B,kBAAkB;EAClB,UAAU;EACV,YAAY;EACZ,YAAY,EAAE,wEAAwE;AACxF;;AAEA;EACE;iCAC+B;EAC/B,cAAc;EACd,kBAAkB;EAClB,oBAAoB;EACpB,YAAY;EACZ,UAAU;EACV,eAAe;EACf,YAAY;EACZ,mBAAmB;EACnB,iDAAiD;EACjD,eAAe;EACf,2BAA2B;EAC3B,kBAAkB;EAClB,qBAAqB;EACrB,qBAAqB;AACvB",sourcesContent:[".st-colored-text-input > textarea {\n width: 100%;\n color: transparent !important;\n caret-color: var(--grey-6);\n -webkit-text-fill-color: transparent !important;\n background-color: transparent;\n position: relative;\n z-index: 1;\n resize: none;\n height: 22px; /* Fine tuned value to avoid \"jumping\" of the textarea upon autoresize */\n}\n\n.st-colored-text-input > div {\n /* The values here are fine tuned to those of the ui.input textarea in order\n * to achieve precise overlap */\n overflow: auto;\n position: absolute;\n pointer-events: none;\n cursor: text;\n z-index: 0;\n max-width: 100%;\n padding: 2px;\n line-height: normal;\n font-family: 'Roboto', 'Roboto Local', sans-serif;\n font-size: 13px;\n padding-top: 6px !important;\n color: transparent;\n white-space: pre-wrap;\n word-wrap: break-word;\n}\n"],sourceRoot:""}]);const a=s},9252:(e,t,n)=>{"use strict";n.d(t,{A:()=>a});var o=n(1354),r=n.n(o),i=n(6314),s=n.n(i)()(r());s.push([e.id,"/* Naming convention: class names should begin with st and app name to avoid naming collitions */\n\n.st-pattern-text-input > textarea {\n resize: none;\n}\n","",{version:3,sources:["webpack://./src/apps/pattern/view/style.css"],names:[],mappings:"AAAA,gGAAgG;;AAEhG;EACE,YAAY;AACd",sourcesContent:["/* Naming convention: class names should begin with st and app name to avoid naming collitions */\n\n.st-pattern-text-input > textarea {\n resize: none;\n}\n"],sourceRoot:""}]);const a=s},8507:(e,t,n)=>{"use strict";n.d(t,{A:()=>a});var o=n(1354),r=n.n(o),i=n(6314),s=n.n(i)()(r());s.push([e.id,"/* Naming convention: class names should begin with st and app name to avoid naming collitions */\n\n.st-structure-body {\n padding-right: 20px;\n height: 100%;\n display: flex;\n flex-direction: column;\n}\n\n.st-structure-mol-img {\n flex: 1 1 0;\n min-height: 100px;\n min-width: 0;\n transform: translateX(-50px);\n overflow: hidden;\n}\n\n.st-structure-mol-img canvas {\n max-width: 100% !important;\n height: auto !important;\n}\n\n.st-structure-bool-button-block {\n justify-content: right;\n margin-bottom: 10px;\n}\n\n.st-structure-bottom {\n flex: 1 1 0;\n padding-top: 20px;\n min-height: 0;\n}\n\n.st-structure-clear-buttons {\n justify-content: space-between;\n padding: 13px 10px 13px 10px;\n}\n\n.st-direction-inputs {\n align-items: end;\n}\n\n.st-structure-inputs {\n flex-grow: 2;\n padding-left: 10px;\n}","",{version:3,sources:["webpack://./src/apps/structure/view/style.css"],names:[],mappings:"AAAA,gGAAgG;;AAEhG;EACE,mBAAmB;EACnB,YAAY;EACZ,aAAa;EACb,sBAAsB;AACxB;;AAEA;EACE,WAAW;EACX,iBAAiB;EACjB,YAAY;EACZ,4BAA4B;EAC5B,gBAAgB;AAClB;;AAEA;EACE,0BAA0B;EAC1B,uBAAuB;AACzB;;AAEA;EACE,sBAAsB;EACtB,mBAAmB;AACrB;;AAEA;EACE,WAAW;EACX,iBAAiB;EACjB,aAAa;AACf;;AAEA;EACE,8BAA8B;EAC9B,4BAA4B;AAC9B;;AAEA;EACE,gBAAgB;AAClB;;AAEA;EACE,YAAY;EACZ,kBAAkB;AACpB",sourcesContent:["/* Naming convention: class names should begin with st and app name to avoid naming collitions */\n\n.st-structure-body {\n padding-right: 20px;\n height: 100%;\n display: flex;\n flex-direction: column;\n}\n\n.st-structure-mol-img {\n flex: 1 1 0;\n min-height: 100px;\n min-width: 0;\n transform: translateX(-50px);\n overflow: hidden;\n}\n\n.st-structure-mol-img canvas {\n max-width: 100% !important;\n height: auto !important;\n}\n\n.st-structure-bool-button-block {\n justify-content: right;\n margin-bottom: 10px;\n}\n\n.st-structure-bottom {\n flex: 1 1 0;\n padding-top: 20px;\n min-height: 0;\n}\n\n.st-structure-clear-buttons {\n justify-content: space-between;\n padding: 13px 10px 13px 10px;\n}\n\n.st-direction-inputs {\n align-items: end;\n}\n\n.st-structure-inputs {\n flex-grow: 2;\n padding-left: 10px;\n}"],sourceRoot:""}]);const a=s},5254:(e,t,n)=>{"use strict";n.d(t,{A:()=>a});var o=n(1354),r=n.n(o),i=n(6314),s=n.n(i)()(r());s.push([e.id,"/* Naming convention: class names should begin with st and app name to avoid naming collitions */\n.st-translator-input-table {\n /* width: 100%; */\n margin-right: 20px;\n}\n\n.st-translator-input-table td:has(textarea) {\n width: 100%;\n}\n\n.st-translator-input-table td:has(select) {\n min-width: 120px;\n vertical-align: top;\n}\n\n.st-translator-output-table {\n margin-top: 20px;\n margin-right: 20px;\n margin-bottom: 10px;\n}\n\n.st-translator-output-table table {\n width: 100%;\n table-layout: fixed;\n}\n\n.st-translator-output-table td {\n padding-top: 6px;\n padding-bottom: 6px;\n}\n.st-translator-output-table tr:nth-child(even) {\n background-color: var(--grey-1);\n}\n\n.st-translator-output-table td:nth-child(odd) {\n width: 120px;\n vertical-align: top;\n}\n\n.st-translator-output-table td a {\n overflow-wrap: break-word;\n}\n","",{version:3,sources:["webpack://./src/apps/translator/view/style.css"],names:[],mappings:"AAAA,gGAAgG;AAChG;EACE,iBAAiB;EACjB,kBAAkB;AACpB;;AAEA;EACE,WAAW;AACb;;AAEA;EACE,gBAAgB;EAChB,mBAAmB;AACrB;;AAEA;EACE,gBAAgB;EAChB,kBAAkB;EAClB,mBAAmB;AACrB;;AAEA;EACE,WAAW;EACX,mBAAmB;AACrB;;AAEA;EACE,gBAAgB;EAChB,mBAAmB;AACrB;AACA;EACE,+BAA+B;AACjC;;AAEA;EACE,YAAY;EACZ,mBAAmB;AACrB;;AAEA;EACE,yBAAyB;AAC3B",sourcesContent:["/* Naming convention: class names should begin with st and app name to avoid naming collitions */\n.st-translator-input-table {\n /* width: 100%; */\n margin-right: 20px;\n}\n\n.st-translator-input-table td:has(textarea) {\n width: 100%;\n}\n\n.st-translator-input-table td:has(select) {\n min-width: 120px;\n vertical-align: top;\n}\n\n.st-translator-output-table {\n margin-top: 20px;\n margin-right: 20px;\n margin-bottom: 10px;\n}\n\n.st-translator-output-table table {\n width: 100%;\n table-layout: fixed;\n}\n\n.st-translator-output-table td {\n padding-top: 6px;\n padding-bottom: 6px;\n}\n.st-translator-output-table tr:nth-child(even) {\n background-color: var(--grey-1);\n}\n\n.st-translator-output-table td:nth-child(odd) {\n width: 120px;\n vertical-align: top;\n}\n\n.st-translator-output-table td a {\n overflow-wrap: break-word;\n}\n"],sourceRoot:""}]);const a=s},890:(e,t,n)=>{"use strict";n.d(t,{A:()=>a});var o=n(1354),r=n.n(o),i=n(6314),s=n.n(i)()(r());s.push([e.id,".monomer-card-rule-root {\n border: 2px solid var(--grey-2);\n border-radius: 5px;\n padding: 5px;\n margin: 5px;\n overflow: hidden;\n align-items: center;\n cursor: pointer;\n width: 200px;\n height: 240px;\n min-width: 200px;\n min-height: 240px;\n}\n\n.monomer-card-info-rules {\n width: 100%;\n overflow: hidden;\n text-overflow: ellipsis;\n margin-bottom: 10px;\n}\n\n.monomer-card-info-rules > div:nth-child(2) {\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n\n.monomer-card-info-rules > div:nth-child(1) {\n font-weight: bold;\n margin-right: 5px;\n text-wrap: nowrap;\n}\n","",{version:3,sources:["webpack://./src/polytool/conversion/style.css"],names:[],mappings:"AAAA;IACI,+BAA+B;IAC/B,kBAAkB;IAClB,YAAY;IACZ,WAAW;IACX,gBAAgB;IAChB,mBAAmB;IACnB,eAAe;IACf,YAAY;IACZ,aAAa;IACb,gBAAgB;IAChB,iBAAiB;AACrB;;AAEA;IACI,WAAW;IACX,gBAAgB;IAChB,uBAAuB;IACvB,mBAAmB;AACvB;;AAEA;IACI,mBAAmB;IACnB,gBAAgB;IAChB,uBAAuB;AAC3B;;AAEA;IACI,iBAAiB;IACjB,iBAAiB;IACjB,iBAAiB;AACrB",sourcesContent:[".monomer-card-rule-root {\n border: 2px solid var(--grey-2);\n border-radius: 5px;\n padding: 5px;\n margin: 5px;\n overflow: hidden;\n align-items: center;\n cursor: pointer;\n width: 200px;\n height: 240px;\n min-width: 200px;\n min-height: 240px;\n}\n\n.monomer-card-info-rules {\n width: 100%;\n overflow: hidden;\n text-overflow: ellipsis;\n margin-bottom: 10px;\n}\n\n.monomer-card-info-rules > div:nth-child(2) {\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n\n.monomer-card-info-rules > div:nth-child(1) {\n font-weight: bold;\n margin-right: 5px;\n text-wrap: nowrap;\n}\n"],sourceRoot:""}]);const a=s},6314:e=>{"use strict";e.exports=function(e){var t=[];return t.toString=function(){return this.map((function(t){var n="",o=void 0!==t[5];return t[4]&&(n+="@supports (".concat(t[4],") {")),t[2]&&(n+="@media ".concat(t[2]," {")),o&&(n+="@layer".concat(t[5].length>0?" ".concat(t[5]):""," {")),n+=e(t),o&&(n+="}"),t[2]&&(n+="}"),t[4]&&(n+="}"),n})).join("")},t.i=function(e,n,o,r,i){"string"==typeof e&&(e=[[null,e,void 0]]);var s={};if(o)for(var a=0;a<this.length;a++){var l=this[a][0];null!=l&&(s[l]=!0)}for(var c=0;c<e.length;c++){var u=[].concat(e[c]);o&&s[u[0]]||(void 0!==i&&(void 0===u[5]||(u[1]="@layer".concat(u[5].length>0?" ".concat(u[5]):""," {").concat(u[1],"}")),u[5]=i),n&&(u[2]?(u[1]="@media ".concat(u[2]," {").concat(u[1],"}"),u[2]=n):u[2]=n),r&&(u[4]?(u[1]="@supports (".concat(u[4],") {").concat(u[1],"}"),u[4]=r):u[4]="".concat(r)),t.push(u))}},t}},1354:e=>{"use strict";e.exports=function(e){var t=e[1],n=e[3];if(!n)return t;if("function"==typeof btoa){var o=btoa(unescape(encodeURIComponent(JSON.stringify(n)))),r="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(o),i="/*# ".concat(r," */");return[t].concat([i]).join("\n")}return[t].join("\n")}},9982:function(e,t,n){var o;!function(){var t={};!function(e){"use strict";e.__esModule=!0,e.digestLength=32,e.blockSize=64;var t=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(e,n,o,r,i){for(var s,a,l,c,u,h,d,p,m,f,g,y,b;i>=64;){for(s=n[0],a=n[1],l=n[2],c=n[3],u=n[4],h=n[5],d=n[6],p=n[7],f=0;f<16;f++)g=r+4*f,e[f]=(255&o[g])<<24|(255&o[g+1])<<16|(255&o[g+2])<<8|255&o[g+3];for(f=16;f<64;f++)y=((m=e[f-2])>>>17|m<<15)^(m>>>19|m<<13)^m>>>10,b=((m=e[f-15])>>>7|m<<25)^(m>>>18|m<<14)^m>>>3,e[f]=(y+e[f-7]|0)+(b+e[f-16]|0);for(f=0;f<64;f++)y=(((u>>>6|u<<26)^(u>>>11|u<<21)^(u>>>25|u<<7))+(u&h^~u&d)|0)+(p+(t[f]+e[f]|0)|0)|0,b=((s>>>2|s<<30)^(s>>>13|s<<19)^(s>>>22|s<<10))+(s&a^s&l^a&l)|0,p=d,d=h,h=u,u=c+y|0,c=l,l=a,a=s,s=y+b|0;n[0]+=s,n[1]+=a,n[2]+=l,n[3]+=c,n[4]+=u,n[5]+=h,n[6]+=d,n[7]+=p,r+=64,i-=64}return r}var o=function(){function t(){this.digestLength=e.digestLength,this.blockSize=e.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 t.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},t.prototype.clean=function(){for(var e=0;e<this.buffer.length;e++)this.buffer[e]=0;for(e=0;e<this.temp.length;e++)this.temp[e]=0;this.reset()},t.prototype.update=function(e,t){if(void 0===t&&(t=e.length),this.finished)throw new Error("SHA256: can't update because hash was finished.");var o=0;if(this.bytesHashed+=t,this.bufferLength>0){for(;this.bufferLength<64&&t>0;)this.buffer[this.bufferLength++]=e[o++],t--;64===this.bufferLength&&(n(this.temp,this.state,this.buffer,0,64),this.bufferLength=0)}for(t>=64&&(o=n(this.temp,this.state,e,o,t),t%=64);t>0;)this.buffer[this.bufferLength++]=e[o++],t--;return this},t.prototype.finish=function(e){if(!this.finished){var t=this.bytesHashed,o=this.bufferLength,r=t/536870912|0,i=t<<3,s=t%64<56?64:128;this.buffer[o]=128;for(var a=o+1;a<s-8;a++)this.buffer[a]=0;this.buffer[s-8]=r>>>24&255,this.buffer[s-7]=r>>>16&255,this.buffer[s-6]=r>>>8&255,this.buffer[s-5]=r>>>0&255,this.buffer[s-4]=i>>>24&255,this.buffer[s-3]=i>>>16&255,this.buffer[s-2]=i>>>8&255,this.buffer[s-1]=i>>>0&255,n(this.temp,this.state,this.buffer,0,s),this.finished=!0}for(a=0;a<8;a++)e[4*a+0]=this.state[a]>>>24&255,e[4*a+1]=this.state[a]>>>16&255,e[4*a+2]=this.state[a]>>>8&255,e[4*a+3]=this.state[a]>>>0&255;return this},t.prototype.digest=function(){var e=new Uint8Array(this.digestLength);return this.finish(e),e},t.prototype._saveState=function(e){for(var t=0;t<this.state.length;t++)e[t]=this.state[t]},t.prototype._restoreState=function(e,t){for(var n=0;n<this.state.length;n++)this.state[n]=e[n];this.bytesHashed=t,this.finished=!1,this.bufferLength=0},t}();e.Hash=o;var r=function(){function e(e){this.inner=new o,this.outer=new o,this.blockSize=this.inner.blockSize,this.digestLength=this.inner.digestLength;var t=new Uint8Array(this.blockSize);if(e.length>this.blockSize)(new o).update(e).finish(t).clean();else for(var n=0;n<e.length;n++)t[n]=e[n];for(n=0;n<t.length;n++)t[n]^=54;for(this.inner.update(t),n=0;n<t.length;n++)t[n]^=106;for(this.outer.update(t),this.istate=new Uint32Array(8),this.ostate=new Uint32Array(8),this.inner._saveState(this.istate),this.outer._saveState(this.ostate),n=0;n<t.length;n++)t[n]=0}return e.prototype.reset=function(){return this.inner._restoreState(this.istate,this.inner.blockSize),this.outer._restoreState(this.ostate,this.outer.blockSize),this},e.prototype.clean=function(){for(var e=0;e<this.istate.length;e++)this.ostate[e]=this.istate[e]=0;this.inner.clean(),this.outer.clean()},e.prototype.update=function(e){return this.inner.update(e),this},e.prototype.finish=function(e){return this.outer.finished?this.outer.finish(e):(this.inner.finish(e),this.outer.update(e,this.digestLength).finish(e)),this},e.prototype.digest=function(){var e=new Uint8Array(this.digestLength);return this.finish(e),e},e}();function i(e){var t=(new o).update(e),n=t.digest();return t.clean(),n}function s(e,t){var n=new r(e).update(t),o=n.digest();return n.clean(),o}function a(e,t,n,o){var r=o[0];if(0===r)throw new Error("hkdf: cannot expand more");t.reset(),r>1&&t.update(e),n&&t.update(n),t.update(o),t.finish(e),o[0]++}e.HMAC=r,e.hash=i,e.default=i,e.hmac=s;var l=new Uint8Array(e.digestLength);e.hkdf=function(e,t,n,o){void 0===t&&(t=l),void 0===o&&(o=32);for(var i=new Uint8Array([1]),c=s(t,e),u=new r(c),h=new Uint8Array(u.digestLength),d=h.length,p=new Uint8Array(o),m=0;m<o;m++)d===h.length&&(a(h,u,n,i),d=0),p[m]=h[d++];return u.clean(),h.fill(0),i.fill(0),p},e.pbkdf2=function(e,t,n,o){for(var i=new r(e),s=i.digestLength,a=new Uint8Array(4),l=new Uint8Array(s),c=new Uint8Array(s),u=new Uint8Array(o),h=0;h*s<o;h++){var d=h+1;a[0]=d>>>24&255,a[1]=d>>>16&255,a[2]=d>>>8&255,a[3]=d>>>0&255,i.reset(),i.update(t),i.update(a),i.finish(c);for(var p=0;p<s;p++)l[p]=c[p];for(p=2;p<=n;p++){i.reset(),i.update(c).finish(c);for(var m=0;m<s;m++)l[m]^=c[m]}for(p=0;p<s&&h*s+p<o;p++)u[h*s+p]=l[p]}for(h=0;h<s;h++)l[h]=c[h]=0;for(h=0;h<4;h++)a[h]=0;return i.clean(),u}}(t);var r=t.default;for(var i in t)r[i]=t[i];"object"==typeof e.exports?e.exports=r:void 0===(o=function(){return r}.call(t,n,t,e))||(e.exports=o)}()},2543:function(e,t,n){var o;e=n.nmd(e),function(){var r,i="Expected a function",s="__lodash_hash_undefined__",a="__lodash_placeholder__",l=32,c=128,u=1/0,h=9007199254740991,d=NaN,p=4294967295,m=[["ary",c],["bind",1],["bindKey",2],["curry",8],["curryRight",16],["flip",512],["partial",l],["partialRight",64],["rearg",256]],f="[object Arguments]",g="[object Array]",y="[object Boolean]",b="[object Date]",v="[object Error]",C="[object Function]",x="[object GeneratorFunction]",w="[object Map]",A="[object Number]",T="[object Object]",E="[object Promise]",S="[object RegExp]",N="[object Set]",I="[object String]",M="[object Symbol]",P="[object WeakMap]",_="[object ArrayBuffer]",L="[object DataView]",O="[object Float32Array]",R="[object Float64Array]",$="[object Int8Array]",D="[object Int16Array]",B="[object Int32Array]",F="[object Uint8Array]",k="[object Uint8ClampedArray]",H="[object Uint16Array]",G="[object Uint32Array]",U=/\b__p \+= '';/g,V=/\b(__p \+=) '' \+/g,j=/(__e\(.*?\)|\b__t\)) \+\n'';/g,q=/&(?:amp|lt|gt|quot|#39);/g,W=/[&<>"']/g,z=RegExp(q.source),Y=RegExp(W.source),K=/<%-([\s\S]+?)%>/g,Q=/<%([\s\S]+?)%>/g,J=/<%=([\s\S]+?)%>/g,X=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Z=/^\w*$/,ee=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,te=/[\\^$.*+?()[\]{}|]/g,ne=RegExp(te.source),oe=/^\s+/,re=/\s/,ie=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,se=/\{\n\/\* \[wrapped with (.+)\] \*/,ae=/,? & /,le=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,ce=/[()=,{}\[\]\/\s]/,ue=/\\(\\)?/g,he=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,de=/\w*$/,pe=/^[-+]0x[0-9a-f]+$/i,me=/^0b[01]+$/i,fe=/^\[object .+?Constructor\]$/,ge=/^0o[0-7]+$/i,ye=/^(?:0|[1-9]\d*)$/,be=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,ve=/($^)/,Ce=/['\n\r\u2028\u2029\\]/g,xe="\\ud800-\\udfff",we="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",Ae="\\u2700-\\u27bf",Te="a-z\\xdf-\\xf6\\xf8-\\xff",Ee="A-Z\\xc0-\\xd6\\xd8-\\xde",Se="\\ufe0e\\ufe0f",Ne="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Ie="["+xe+"]",Me="["+Ne+"]",Pe="["+we+"]",_e="\\d+",Le="["+Ae+"]",Oe="["+Te+"]",Re="[^"+xe+Ne+_e+Ae+Te+Ee+"]",$e="\\ud83c[\\udffb-\\udfff]",De="[^"+xe+"]",Be="(?:\\ud83c[\\udde6-\\uddff]){2}",Fe="[\\ud800-\\udbff][\\udc00-\\udfff]",ke="["+Ee+"]",He="\\u200d",Ge="(?:"+Oe+"|"+Re+")",Ue="(?:"+ke+"|"+Re+")",Ve="(?:['’](?:d|ll|m|re|s|t|ve))?",je="(?:['’](?:D|LL|M|RE|S|T|VE))?",qe="(?:"+Pe+"|"+$e+")?",We="["+Se+"]?",ze=We+qe+"(?:"+He+"(?:"+[De,Be,Fe].join("|")+")"+We+qe+")*",Ye="(?:"+[Le,Be,Fe].join("|")+")"+ze,Ke="(?:"+[De+Pe+"?",Pe,Be,Fe,Ie].join("|")+")",Qe=RegExp("['’]","g"),Je=RegExp(Pe,"g"),Xe=RegExp($e+"(?="+$e+")|"+Ke+ze,"g"),Ze=RegExp([ke+"?"+Oe+"+"+Ve+"(?="+[Me,ke,"$"].join("|")+")",Ue+"+"+je+"(?="+[Me,ke+Ge,"$"].join("|")+")",ke+"?"+Ge+"+"+Ve,ke+"+"+je,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",_e,Ye].join("|"),"g"),et=RegExp("["+He+xe+we+Se+"]"),tt=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,nt=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],ot=-1,rt={};rt[O]=rt[R]=rt[$]=rt[D]=rt[B]=rt[F]=rt[k]=rt[H]=rt[G]=!0,rt[f]=rt[g]=rt[_]=rt[y]=rt[L]=rt[b]=rt[v]=rt[C]=rt[w]=rt[A]=rt[T]=rt[S]=rt[N]=rt[I]=rt[P]=!1;var it={};it[f]=it[g]=it[_]=it[L]=it[y]=it[b]=it[O]=it[R]=it[$]=it[D]=it[B]=it[w]=it[A]=it[T]=it[S]=it[N]=it[I]=it[M]=it[F]=it[k]=it[H]=it[G]=!0,it[v]=it[C]=it[P]=!1;var st={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},at=parseFloat,lt=parseInt,ct="object"==typeof n.g&&n.g&&n.g.Object===Object&&n.g,ut="object"==typeof self&&self&&self.Object===Object&&self,ht=ct||ut||Function("return this")(),dt=t&&!t.nodeType&&t,pt=dt&&e&&!e.nodeType&&e,mt=pt&&pt.exports===dt,ft=mt&&ct.process,gt=function(){try{return pt&&pt.require&&pt.require("util").types||ft&&ft.binding&&ft.binding("util")}catch(e){}}(),yt=gt&>.isArrayBuffer,bt=gt&>.isDate,vt=gt&>.isMap,Ct=gt&>.isRegExp,xt=gt&>.isSet,wt=gt&>.isTypedArray;function At(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}function Tt(e,t,n,o){for(var r=-1,i=null==e?0:e.length;++r<i;){var s=e[r];t(o,s,n(s),e)}return o}function Et(e,t){for(var n=-1,o=null==e?0:e.length;++n<o&&!1!==t(e[n],n,e););return e}function St(e,t){for(var n=null==e?0:e.length;n--&&!1!==t(e[n],n,e););return e}function Nt(e,t){for(var n=-1,o=null==e?0:e.length;++n<o;)if(!t(e[n],n,e))return!1;return!0}function It(e,t){for(var n=-1,o=null==e?0:e.length,r=0,i=[];++n<o;){var s=e[n];t(s,n,e)&&(i[r++]=s)}return i}function Mt(e,t){return!(null==e||!e.length)&&kt(e,t,0)>-1}function Pt(e,t,n){for(var o=-1,r=null==e?0:e.length;++o<r;)if(n(t,e[o]))return!0;return!1}function _t(e,t){for(var n=-1,o=null==e?0:e.length,r=Array(o);++n<o;)r[n]=t(e[n],n,e);return r}function Lt(e,t){for(var n=-1,o=t.length,r=e.length;++n<o;)e[r+n]=t[n];return e}function Ot(e,t,n,o){var r=-1,i=null==e?0:e.length;for(o&&i&&(n=e[++r]);++r<i;)n=t(n,e[r],r,e);return n}function Rt(e,t,n,o){var r=null==e?0:e.length;for(o&&r&&(n=e[--r]);r--;)n=t(n,e[r],r,e);return n}function $t(e,t){for(var n=-1,o=null==e?0:e.length;++n<o;)if(t(e[n],n,e))return!0;return!1}var Dt=Vt("length");function Bt(e,t,n){var o;return n(e,(function(e,n,r){if(t(e,n,r))return o=n,!1})),o}function Ft(e,t,n,o){for(var r=e.length,i=n+(o?1:-1);o?i--:++i<r;)if(t(e[i],i,e))return i;return-1}function kt(e,t,n){return t==t?function(e,t,n){for(var o=n-1,r=e.length;++o<r;)if(e[o]===t)return o;return-1}(e,t,n):Ft(e,Gt,n)}function Ht(e,t,n,o){for(var r=n-1,i=e.length;++r<i;)if(o(e[r],t))return r;return-1}function Gt(e){return e!=e}function Ut(e,t){var n=null==e?0:e.length;return n?Wt(e,t)/n:d}function Vt(e){return function(t){return null==t?r:t[e]}}function jt(e){return function(t){return null==e?r:e[t]}}function qt(e,t,n,o,r){return r(e,(function(e,r,i){n=o?(o=!1,e):t(n,e,r,i)})),n}function Wt(e,t){for(var n,o=-1,i=e.length;++o<i;){var s=t(e[o]);s!==r&&(n=n===r?s:n+s)}return n}function zt(e,t){for(var n=-1,o=Array(e);++n<e;)o[n]=t(n);return o}function Yt(e){return e?e.slice(0,dn(e)+1).replace(oe,""):e}function Kt(e){return function(t){return e(t)}}function Qt(e,t){return _t(t,(function(t){return e[t]}))}function Jt(e,t){return e.has(t)}function Xt(e,t){for(var n=-1,o=e.length;++n<o&&kt(t,e[n],0)>-1;);return n}function Zt(e,t){for(var n=e.length;n--&&kt(t,e[n],0)>-1;);return n}var en=jt({À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"}),tn=jt({"&":"&","<":"<",">":">",'"':""","'":"'"});function nn(e){return"\\"+st[e]}function on(e){return et.test(e)}function rn(e){var t=-1,n=Array(e.size);return e.forEach((function(e,o){n[++t]=[o,e]})),n}function sn(e,t){return function(n){return e(t(n))}}function an(e,t){for(var n=-1,o=e.length,r=0,i=[];++n<o;){var s=e[n];s!==t&&s!==a||(e[n]=a,i[r++]=n)}return i}function ln(e){var t=-1,n=Array(e.size);return e.forEach((function(e){n[++t]=e})),n}function cn(e){var t=-1,n=Array(e.size);return e.forEach((function(e){n[++t]=[e,e]})),n}function un(e){return on(e)?function(e){for(var t=Xe.lastIndex=0;Xe.test(e);)++t;return t}(e):Dt(e)}function hn(e){return on(e)?function(e){return e.match(Xe)||[]}(e):function(e){return e.split("")}(e)}function dn(e){for(var t=e.length;t--&&re.test(e.charAt(t)););return t}var pn=jt({"&":"&","<":"<",">":">",""":'"',"'":"'"}),mn=function e(t){var n,o=(t=null==t?ht:mn.defaults(ht.Object(),t,mn.pick(ht,nt))).Array,re=t.Date,xe=t.Error,we=t.Function,Ae=t.Math,Te=t.Object,Ee=t.RegExp,Se=t.String,Ne=t.TypeError,Ie=o.prototype,Me=we.prototype,Pe=Te.prototype,_e=t["__core-js_shared__"],Le=Me.toString,Oe=Pe.hasOwnProperty,Re=0,$e=(n=/[^.]+$/.exec(_e&&_e.keys&&_e.keys.IE_PROTO||""))?"Symbol(src)_1."+n:"",De=Pe.toString,Be=Le.call(Te),Fe=ht._,ke=Ee("^"+Le.call(Oe).replace(te,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),He=mt?t.Buffer:r,Ge=t.Symbol,Ue=t.Uint8Array,Ve=He?He.allocUnsafe:r,je=sn(Te.getPrototypeOf,Te),qe=Te.create,We=Pe.propertyIsEnumerable,ze=Ie.splice,Ye=Ge?Ge.isConcatSpreadable:r,Ke=Ge?Ge.iterator:r,Xe=Ge?Ge.toStringTag:r,et=function(){try{var e=ci(Te,"defineProperty");return e({},"",{}),e}catch(e){}}(),st=t.clearTimeout!==ht.clearTimeout&&t.clearTimeout,ct=re&&re.now!==ht.Date.now&&re.now,ut=t.setTimeout!==ht.setTimeout&&t.setTimeout,dt=Ae.ceil,pt=Ae.floor,ft=Te.getOwnPropertySymbols,gt=He?He.isBuffer:r,Dt=t.isFinite,jt=Ie.join,fn=sn(Te.keys,Te),gn=Ae.max,yn=Ae.min,bn=re.now,vn=t.parseInt,Cn=Ae.random,xn=Ie.reverse,wn=ci(t,"DataView"),An=ci(t,"Map"),Tn=ci(t,"Promise"),En=ci(t,"Set"),Sn=ci(t,"WeakMap"),Nn=ci(Te,"create"),In=Sn&&new Sn,Mn={},Pn=Bi(wn),_n=Bi(An),Ln=Bi(Tn),On=Bi(En),Rn=Bi(Sn),$n=Ge?Ge.prototype:r,Dn=$n?$n.valueOf:r,Bn=$n?$n.toString:r;function Fn(e){if(ea(e)&&!Vs(e)&&!(e instanceof Un)){if(e instanceof Gn)return e;if(Oe.call(e,"__wrapped__"))return Fi(e)}return new Gn(e)}var kn=function(){function e(){}return function(t){if(!Zs(t))return{};if(qe)return qe(t);e.prototype=t;var n=new e;return e.prototype=r,n}}();function Hn(){}function Gn(e,t){this.__wrapped__=e,this.__actions__=[],this.__chain__=!!t,this.__index__=0,this.__values__=r}function Un(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=p,this.__views__=[]}function Vn(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var o=e[t];this.set(o[0],o[1])}}function jn(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var o=e[t];this.set(o[0],o[1])}}function qn(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var o=e[t];this.set(o[0],o[1])}}function Wn(e){var t=-1,n=null==e?0:e.length;for(this.__data__=new qn;++t<n;)this.add(e[t])}function zn(e){var t=this.__data__=new jn(e);this.size=t.size}function Yn(e,t){var n=Vs(e),o=!n&&Us(e),r=!n&&!o&&zs(e),i=!n&&!o&&!r&&la(e),s=n||o||r||i,a=s?zt(e.length,Se):[],l=a.length;for(var c in e)!t&&!Oe.call(e,c)||s&&("length"==c||r&&("offset"==c||"parent"==c)||i&&("buffer"==c||"byteLength"==c||"byteOffset"==c)||gi(c,l))||a.push(c);return a}function Kn(e){var t=e.length;return t?e[Wo(0,t-1)]:r}function Qn(e,t){return Li(Nr(e),io(t,0,e.length))}function Jn(e){return Li(Nr(e))}function Xn(e,t,n){(n!==r&&!ks(e[t],n)||n===r&&!(t in e))&&oo(e,t,n)}function Zn(e,t,n){var o=e[t];Oe.call(e,t)&&ks(o,n)&&(n!==r||t in e)||oo(e,t,n)}function eo(e,t){for(var n=e.length;n--;)if(ks(e[n][0],t))return n;return-1}function to(e,t,n,o){return uo(e,(function(e,r,i){t(o,e,n(e),i)})),o}function no(e,t){return e&&Ir(t,Pa(t),e)}function oo(e,t,n){"__proto__"==t&&et?et(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n}function ro(e,t){for(var n=-1,i=t.length,s=o(i),a=null==e;++n<i;)s[n]=a?r:Ea(e,t[n]);return s}function io(e,t,n){return e==e&&(n!==r&&(e=e<=n?e:n),t!==r&&(e=e>=t?e:t)),e}function so(e,t,n,o,i,s){var a,l=1&t,c=2&t,u=4&t;if(n&&(a=i?n(e,o,i,s):n(e)),a!==r)return a;if(!Zs(e))return e;var h=Vs(e);if(h){if(a=function(e){var t=e.length,n=new e.constructor(t);return t&&"string"==typeof e[0]&&Oe.call(e,"index")&&(n.index=e.index,n.input=e.input),n}(e),!l)return Nr(e,a)}else{var d=di(e),p=d==C||d==x;if(zs(e))return xr(e,l);if(d==T||d==f||p&&!i){if(a=c||p?{}:mi(e),!l)return c?function(e,t){return Ir(e,hi(e),t)}(e,function(e,t){return e&&Ir(t,_a(t),e)}(a,e)):function(e,t){return Ir(e,ui(e),t)}(e,no(a,e))}else{if(!it[d])return i?e:{};a=function(e,t,n){var o,r=e.constructor;switch(t){case _:return wr(e);case y:case b:return new r(+e);case L:return function(e,t){var n=t?wr(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}(e,n);case O:case R:case $:case D:case B:case F:case k:case H:case G:return Ar(e,n);case w:return new r;case A:case I:return new r(e);case S:return function(e){var t=new e.constructor(e.source,de.exec(e));return t.lastIndex=e.lastIndex,t}(e);case N:return new r;case M:return o=e,Dn?Te(Dn.call(o)):{}}}(e,d,l)}}s||(s=new zn);var m=s.get(e);if(m)return m;s.set(e,a),ia(e)?e.forEach((function(o){a.add(so(o,t,n,o,e,s))})):ta(e)&&e.forEach((function(o,r){a.set(r,so(o,t,n,r,e,s))}));var g=h?r:(u?c?ni:ti:c?_a:Pa)(e);return Et(g||e,(function(o,r){g&&(o=e[r=o]),Zn(a,r,so(o,t,n,r,e,s))})),a}function ao(e,t,n){var o=n.length;if(null==e)return!o;for(e=Te(e);o--;){var i=n[o],s=t[i],a=e[i];if(a===r&&!(i in e)||!s(a))return!1}return!0}function lo(e,t,n){if("function"!=typeof e)throw new Ne(i);return Ii((function(){e.apply(r,n)}),t)}function co(e,t,n,o){var r=-1,i=Mt,s=!0,a=e.length,l=[],c=t.length;if(!a)return l;n&&(t=_t(t,Kt(n))),o?(i=Pt,s=!1):t.length>=200&&(i=Jt,s=!1,t=new Wn(t));e:for(;++r<a;){var u=e[r],h=null==n?u:n(u);if(u=o||0!==u?u:0,s&&h==h){for(var d=c;d--;)if(t[d]===h)continue e;l.push(u)}else i(t,h,o)||l.push(u)}return l}Fn.templateSettings={escape:K,evaluate:Q,interpolate:J,variable:"",imports:{_:Fn}},Fn.prototype=Hn.prototype,Fn.prototype.constructor=Fn,Gn.prototype=kn(Hn.prototype),Gn.prototype.constructor=Gn,Un.prototype=kn(Hn.prototype),Un.prototype.constructor=Un,Vn.prototype.clear=function(){this.__data__=Nn?Nn(null):{},this.size=0},Vn.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},Vn.prototype.get=function(e){var t=this.__data__;if(Nn){var n=t[e];return n===s?r:n}return Oe.call(t,e)?t[e]:r},Vn.prototype.has=function(e){var t=this.__data__;return Nn?t[e]!==r:Oe.call(t,e)},Vn.prototype.set=function(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=Nn&&t===r?s:t,this},jn.prototype.clear=function(){this.__data__=[],this.size=0},jn.prototype.delete=function(e){var t=this.__data__,n=eo(t,e);return!(n<0||(n==t.length-1?t.pop():ze.call(t,n,1),--this.size,0))},jn.prototype.get=function(e){var t=this.__data__,n=eo(t,e);return n<0?r:t[n][1]},jn.prototype.has=function(e){return eo(this.__data__,e)>-1},jn.prototype.set=function(e,t){var n=this.__data__,o=eo(n,e);return o<0?(++this.size,n.push([e,t])):n[o][1]=t,this},qn.prototype.clear=function(){this.size=0,this.__data__={hash:new Vn,map:new(An||jn),string:new Vn}},qn.prototype.delete=function(e){var t=ai(this,e).delete(e);return this.size-=t?1:0,t},qn.prototype.get=function(e){return ai(this,e).get(e)},qn.prototype.has=function(e){return ai(this,e).has(e)},qn.prototype.set=function(e,t){var n=ai(this,e),o=n.size;return n.set(e,t),this.size+=n.size==o?0:1,this},Wn.prototype.add=Wn.prototype.push=function(e){return this.__data__.set(e,s),this},Wn.prototype.has=function(e){return this.__data__.has(e)},zn.prototype.clear=function(){this.__data__=new jn,this.size=0},zn.prototype.delete=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n},zn.prototype.get=function(e){return this.__data__.get(e)},zn.prototype.has=function(e){return this.__data__.has(e)},zn.prototype.set=function(e,t){var n=this.__data__;if(n instanceof jn){var o=n.__data__;if(!An||o.length<199)return o.push([e,t]),this.size=++n.size,this;n=this.__data__=new qn(o)}return n.set(e,t),this.size=n.size,this};var uo=_r(vo),ho=_r(Co,!0);function po(e,t){var n=!0;return uo(e,(function(e,o,r){return n=!!t(e,o,r)})),n}function mo(e,t,n){for(var o=-1,i=e.length;++o<i;){var s=e[o],a=t(s);if(null!=a&&(l===r?a==a&&!aa(a):n(a,l)))var l=a,c=s}return c}function fo(e,t){var n=[];return uo(e,(function(e,o,r){t(e,o,r)&&n.push(e)})),n}function go(e,t,n,o,r){var i=-1,s=e.length;for(n||(n=fi),r||(r=[]);++i<s;){var a=e[i];t>0&&n(a)?t>1?go(a,t-1,n,o,r):Lt(r,a):o||(r[r.length]=a)}return r}var yo=Lr(),bo=Lr(!0);function vo(e,t){return e&&yo(e,t,Pa)}function Co(e,t){return e&&bo(e,t,Pa)}function xo(e,t){return It(t,(function(t){return Qs(e[t])}))}function wo(e,t){for(var n=0,o=(t=yr(t,e)).length;null!=e&&n<o;)e=e[Di(t[n++])];return n&&n==o?e:r}function Ao(e,t,n){var o=t(e);return Vs(e)?o:Lt(o,n(e))}function To(e){return null==e?e===r?"[object Undefined]":"[object Null]":Xe&&Xe in Te(e)?function(e){var t=Oe.call(e,Xe),n=e[Xe];try{e[Xe]=r;var o=!0}catch(e){}var i=De.call(e);return o&&(t?e[Xe]=n:delete e[Xe]),i}(e):function(e){return De.call(e)}(e)}function Eo(e,t){return e>t}function So(e,t){return null!=e&&Oe.call(e,t)}function No(e,t){return null!=e&&t in Te(e)}function Io(e,t,n){for(var i=n?Pt:Mt,s=e[0].length,a=e.length,l=a,c=o(a),u=1/0,h=[];l--;){var d=e[l];l&&t&&(d=_t(d,Kt(t))),u=yn(d.length,u),c[l]=!n&&(t||s>=120&&d.length>=120)?new Wn(l&&d):r}d=e[0];var p=-1,m=c[0];e:for(;++p<s&&h.length<u;){var f=d[p],g=t?t(f):f;if(f=n||0!==f?f:0,!(m?Jt(m,g):i(h,g,n))){for(l=a;--l;){var y=c[l];if(!(y?Jt(y,g):i(e[l],g,n)))continue e}m&&m.push(g),h.push(f)}}return h}function Mo(e,t,n){var o=null==(e=Ei(e,t=yr(t,e)))?e:e[Di(Ki(t))];return null==o?r:At(o,e,n)}function Po(e){return ea(e)&&To(e)==f}function _o(e,t,n,o,i){return e===t||(null==e||null==t||!ea(e)&&!ea(t)?e!=e&&t!=t:function(e,t,n,o,i,s){var a=Vs(e),l=Vs(t),c=a?g:di(e),u=l?g:di(t),h=(c=c==f?T:c)==T,d=(u=u==f?T:u)==T,p=c==u;if(p&&zs(e)){if(!zs(t))return!1;a=!0,h=!1}if(p&&!h)return s||(s=new zn),a||la(e)?Zr(e,t,n,o,i,s):function(e,t,n,o,r,i,s){switch(n){case L:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case _:return!(e.byteLength!=t.byteLength||!i(new Ue(e),new Ue(t)));case y:case b:case A:return ks(+e,+t);case v:return e.name==t.name&&e.message==t.message;case S:case I:return e==t+"";case w:var a=rn;case N:var l=1&o;if(a||(a=ln),e.size!=t.size&&!l)return!1;var c=s.get(e);if(c)return c==t;o|=2,s.set(e,t);var u=Zr(a(e),a(t),o,r,i,s);return s.delete(e),u;case M:if(Dn)return Dn.call(e)==Dn.call(t)}return!1}(e,t,c,n,o,i,s);if(!(1&n)){var m=h&&Oe.call(e,"__wrapped__"),C=d&&Oe.call(t,"__wrapped__");if(m||C){var x=m?e.value():e,E=C?t.value():t;return s||(s=new zn),i(x,E,n,o,s)}}return!!p&&(s||(s=new zn),function(e,t,n,o,i,s){var a=1&n,l=ti(e),c=l.length;if(c!=ti(t).length&&!a)return!1;for(var u=c;u--;){var h=l[u];if(!(a?h in t:Oe.call(t,h)))return!1}var d=s.get(e),p=s.get(t);if(d&&p)return d==t&&p==e;var m=!0;s.set(e,t),s.set(t,e);for(var f=a;++u<c;){var g=e[h=l[u]],y=t[h];if(o)var b=a?o(y,g,h,t,e,s):o(g,y,h,e,t,s);if(!(b===r?g===y||i(g,y,n,o,s):b)){m=!1;break}f||(f="constructor"==h)}if(m&&!f){var v=e.constructor,C=t.constructor;v==C||!("constructor"in e)||!("constructor"in t)||"function"==typeof v&&v instanceof v&&"function"==typeof C&&C instanceof C||(m=!1)}return s.delete(e),s.delete(t),m}(e,t,n,o,i,s))}(e,t,n,o,_o,i))}function Lo(e,t,n,o){var i=n.length,s=i,a=!o;if(null==e)return!s;for(e=Te(e);i--;){var l=n[i];if(a&&l[2]?l[1]!==e[l[0]]:!(l[0]in e))return!1}for(;++i<s;){var c=(l=n[i])[0],u=e[c],h=l[1];if(a&&l[2]){if(u===r&&!(c in e))return!1}else{var d=new zn;if(o)var p=o(u,h,c,e,t,d);if(!(p===r?_o(h,u,3,o,d):p))return!1}}return!0}function Oo(e){return!(!Zs(e)||(t=e,$e&&$e in t))&&(Qs(e)?ke:fe).test(Bi(e));var t}function Ro(e){return"function"==typeof e?e:null==e?nl:"object"==typeof e?Vs(e)?ko(e[0],e[1]):Fo(e):hl(e)}function $o(e){if(!xi(e))return fn(e);var t=[];for(var n in Te(e))Oe.call(e,n)&&"constructor"!=n&&t.push(n);return t}function Do(e,t){return e<t}function Bo(e,t){var n=-1,r=qs(e)?o(e.length):[];return uo(e,(function(e,o,i){r[++n]=t(e,o,i)})),r}function Fo(e){var t=li(e);return 1==t.length&&t[0][2]?Ai(t[0][0],t[0][1]):function(n){return n===e||Lo(n,e,t)}}function ko(e,t){return bi(e)&&wi(t)?Ai(Di(e),t):function(n){var o=Ea(n,e);return o===r&&o===t?Sa(n,e):_o(t,o,3)}}function Ho(e,t,n,o,i){e!==t&&yo(t,(function(s,a){if(i||(i=new zn),Zs(s))!function(e,t,n,o,i,s,a){var l=Si(e,n),c=Si(t,n),u=a.get(c);if(u)Xn(e,n,u);else{var h=s?s(l,c,n+"",e,t,a):r,d=h===r;if(d){var p=Vs(c),m=!p&&zs(c),f=!p&&!m&&la(c);h=c,p||m||f?Vs(l)?h=l:Ws(l)?h=Nr(l):m?(d=!1,h=xr(c,!0)):f?(d=!1,h=Ar(c,!0)):h=[]:oa(c)||Us(c)?(h=l,Us(l)?h=ga(l):Zs(l)&&!Qs(l)||(h=mi(c))):d=!1}d&&(a.set(c,h),i(h,c,o,s,a),a.delete(c)),Xn(e,n,h)}}(e,t,a,n,Ho,o,i);else{var l=o?o(Si(e,a),s,a+"",e,t,i):r;l===r&&(l=s),Xn(e,a,l)}}),_a)}function Go(e,t){var n=e.length;if(n)return gi(t+=t<0?n:0,n)?e[t]:r}function Uo(e,t,n){t=t.length?_t(t,(function(e){return Vs(e)?function(t){return wo(t,1===e.length?e[0]:e)}:e})):[nl];var o=-1;t=_t(t,Kt(si()));var r=Bo(e,(function(e,n,r){var i=_t(t,(function(t){return t(e)}));return{criteria:i,index:++o,value:e}}));return function(e){var t=e.length;for(e.sort((function(e,t){return function(e,t,n){for(var o=-1,r=e.criteria,i=t.criteria,s=r.length,a=n.length;++o<s;){var l=Tr(r[o],i[o]);if(l)return o>=a?l:l*("desc"==n[o]?-1:1)}return e.index-t.index}(e,t,n)}));t--;)e[t]=e[t].value;return e}(r)}function Vo(e,t,n){for(var o=-1,r=t.length,i={};++o<r;){var s=t[o],a=wo(e,s);n(a,s)&&Jo(i,yr(s,e),a)}return i}function jo(e,t,n,o){var r=o?Ht:kt,i=-1,s=t.length,a=e;for(e===t&&(t=Nr(t)),n&&(a=_t(e,Kt(n)));++i<s;)for(var l=0,c=t[i],u=n?n(c):c;(l=r(a,u,l,o))>-1;)a!==e&&ze.call(a,l,1),ze.call(e,l,1);return e}function qo(e,t){for(var n=e?t.length:0,o=n-1;n--;){var r=t[n];if(n==o||r!==i){var i=r;gi(r)?ze.call(e,r,1):cr(e,r)}}return e}function Wo(e,t){return e+pt(Cn()*(t-e+1))}function zo(e,t){var n="";if(!e||t<1||t>h)return n;do{t%2&&(n+=e),(t=pt(t/2))&&(e+=e)}while(t);return n}function Yo(e,t){return Mi(Ti(e,t,nl),e+"")}function Ko(e){return Kn(ka(e))}function Qo(e,t){var n=ka(e);return Li(n,io(t,0,n.length))}function Jo(e,t,n,o){if(!Zs(e))return e;for(var i=-1,s=(t=yr(t,e)).length,a=s-1,l=e;null!=l&&++i<s;){var c=Di(t[i]),u=n;if("__proto__"===c||"constructor"===c||"prototype"===c)return e;if(i!=a){var h=l[c];(u=o?o(h,c,l):r)===r&&(u=Zs(h)?h:gi(t[i+1])?[]:{})}Zn(l,c,u),l=l[c]}return e}var Xo=In?function(e,t){return In.set(e,t),e}:nl,Zo=et?function(e,t){return et(e,"toString",{configurable:!0,enumerable:!1,value:Za(t),writable:!0})}:nl;function er(e){return Li(ka(e))}function tr(e,t,n){var r=-1,i=e.length;t<0&&(t=-t>i?0:i+t),(n=n>i?i:n)<0&&(n+=i),i=t>n?0:n-t>>>0,t>>>=0;for(var s=o(i);++r<i;)s[r]=e[r+t];return s}function nr(e,t){var n;return uo(e,(function(e,o,r){return!(n=t(e,o,r))})),!!n}function or(e,t,n){var o=0,r=null==e?o:e.length;if("number"==typeof t&&t==t&&r<=2147483647){for(;o<r;){var i=o+r>>>1,s=e[i];null!==s&&!aa(s)&&(n?s<=t:s<t)?o=i+1:r=i}return r}return rr(e,t,nl,n)}function rr(e,t,n,o){var i=0,s=null==e?0:e.length;if(0===s)return 0;for(var a=(t=n(t))!=t,l=null===t,c=aa(t),u=t===r;i<s;){var h=pt((i+s)/2),d=n(e[h]),p=d!==r,m=null===d,f=d==d,g=aa(d);if(a)var y=o||f;else y=u?f&&(o||p):l?f&&p&&(o||!m):c?f&&p&&!m&&(o||!g):!m&&!g&&(o?d<=t:d<t);y?i=h+1:s=h}return yn(s,4294967294)}function ir(e,t){for(var n=-1,o=e.length,r=0,i=[];++n<o;){var s=e[n],a=t?t(s):s;if(!n||!ks(a,l)){var l=a;i[r++]=0===s?0:s}}return i}function sr(e){return"number"==typeof e?e:aa(e)?d:+e}function ar(e){if("string"==typeof e)return e;if(Vs(e))return _t(e,ar)+"";if(aa(e))return Bn?Bn.call(e):"";var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}function lr(e,t,n){var o=-1,r=Mt,i=e.length,s=!0,a=[],l=a;if(n)s=!1,r=Pt;else if(i>=200){var c=t?null:zr(e);if(c)return ln(c);s=!1,r=Jt,l=new Wn}else l=t?[]:a;e:for(;++o<i;){var u=e[o],h=t?t(u):u;if(u=n||0!==u?u:0,s&&h==h){for(var d=l.length;d--;)if(l[d]===h)continue e;t&&l.push(h),a.push(u)}else r(l,h,n)||(l!==a&&l.push(h),a.push(u))}return a}function cr(e,t){return null==(e=Ei(e,t=yr(t,e)))||delete e[Di(Ki(t))]}function ur(e,t,n,o){return Jo(e,t,n(wo(e,t)),o)}function hr(e,t,n,o){for(var r=e.length,i=o?r:-1;(o?i--:++i<r)&&t(e[i],i,e););return n?tr(e,o?0:i,o?i+1:r):tr(e,o?i+1:0,o?r:i)}function dr(e,t){var n=e;return n instanceof Un&&(n=n.value()),Ot(t,(function(e,t){return t.func.apply(t.thisArg,Lt([e],t.args))}),n)}function pr(e,t,n){var r=e.length;if(r<2)return r?lr(e[0]):[];for(var i=-1,s=o(r);++i<r;)for(var a=e[i],l=-1;++l<r;)l!=i&&(s[i]=co(s[i]||a,e[l],t,n));return lr(go(s,1),t,n)}function mr(e,t,n){for(var o=-1,i=e.length,s=t.length,a={};++o<i;){var l=o<s?t[o]:r;n(a,e[o],l)}return a}function fr(e){return Ws(e)?e:[]}function gr(e){return"function"==typeof e?e:nl}function yr(e,t){return Vs(e)?e:bi(e,t)?[e]:$i(ya(e))}var br=Yo;function vr(e,t,n){var o=e.length;return n=n===r?o:n,!t&&n>=o?e:tr(e,t,n)}var Cr=st||function(e){return ht.clearTimeout(e)};function xr(e,t){if(t)return e.slice();var n=e.length,o=Ve?Ve(n):new e.constructor(n);return e.copy(o),o}function wr(e){var t=new e.constructor(e.byteLength);return new Ue(t).set(new Ue(e)),t}function Ar(e,t){var n=t?wr(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}function Tr(e,t){if(e!==t){var n=e!==r,o=null===e,i=e==e,s=aa(e),a=t!==r,l=null===t,c=t==t,u=aa(t);if(!l&&!u&&!s&&e>t||s&&a&&c&&!l&&!u||o&&a&&c||!n&&c||!i)return 1;if(!o&&!s&&!u&&e<t||u&&n&&i&&!o&&!s||l&&n&&i||!a&&i||!c)return-1}return 0}function Er(e,t,n,r){for(var i=-1,s=e.length,a=n.length,l=-1,c=t.length,u=gn(s-a,0),h=o(c+u),d=!r;++l<c;)h[l]=t[l];for(;++i<a;)(d||i<s)&&(h[n[i]]=e[i]);for(;u--;)h[l++]=e[i++];return h}function Sr(e,t,n,r){for(var i=-1,s=e.length,a=-1,l=n.length,c=-1,u=t.length,h=gn(s-l,0),d=o(h+u),p=!r;++i<h;)d[i]=e[i];for(var m=i;++c<u;)d[m+c]=t[c];for(;++a<l;)(p||i<s)&&(d[m+n[a]]=e[i++]);return d}function Nr(e,t){var n=-1,r=e.length;for(t||(t=o(r));++n<r;)t[n]=e[n];return t}function Ir(e,t,n,o){var i=!n;n||(n={});for(var s=-1,a=t.length;++s<a;){var l=t[s],c=o?o(n[l],e[l],l,n,e):r;c===r&&(c=e[l]),i?oo(n,l,c):Zn(n,l,c)}return n}function Mr(e,t){return function(n,o){var r=Vs(n)?Tt:to,i=t?t():{};return r(n,e,si(o,2),i)}}function Pr(e){return Yo((function(t,n){var o=-1,i=n.length,s=i>1?n[i-1]:r,a=i>2?n[2]:r;for(s=e.length>3&&"function"==typeof s?(i--,s):r,a&&yi(n[0],n[1],a)&&(s=i<3?r:s,i=1),t=Te(t);++o<i;){var l=n[o];l&&e(t,l,o,s)}return t}))}function _r(e,t){return function(n,o){if(null==n)return n;if(!qs(n))return e(n,o);for(var r=n.length,i=t?r:-1,s=Te(n);(t?i--:++i<r)&&!1!==o(s[i],i,s););return n}}function Lr(e){return function(t,n,o){for(var r=-1,i=Te(t),s=o(t),a=s.length;a--;){var l=s[e?a:++r];if(!1===n(i[l],l,i))break}return t}}function Or(e){return function(t){var n=on(t=ya(t))?hn(t):r,o=n?n[0]:t.charAt(0),i=n?vr(n,1).join(""):t.slice(1);return o[e]()+i}}function Rr(e){return function(t){return Ot(Qa(Ua(t).replace(Qe,"")),e,"")}}function $r(e){return function(){var t=arguments;switch(t.length){case 0:return new e;case 1:return new e(t[0]);case 2:return new e(t[0],t[1]);case 3:return new e(t[0],t[1],t[2]);case 4:return new e(t[0],t[1],t[2],t[3]);case 5:return new e(t[0],t[1],t[2],t[3],t[4]);case 6:return new e(t[0],t[1],t[2],t[3],t[4],t[5]);case 7:return new e(t[0],t[1],t[2],t[3],t[4],t[5],t[6])}var n=kn(e.prototype),o=e.apply(n,t);return Zs(o)?o:n}}function Dr(e){return function(t,n,o){var i=Te(t);if(!qs(t)){var s=si(n,3);t=Pa(t),n=function(e){return s(i[e],e,i)}}var a=e(t,n,o);return a>-1?i[s?t[a]:a]:r}}function Br(e){return ei((function(t){var n=t.length,o=n,s=Gn.prototype.thru;for(e&&t.reverse();o--;){var a=t[o];if("function"!=typeof a)throw new Ne(i);if(s&&!l&&"wrapper"==ri(a))var l=new Gn([],!0)}for(o=l?o:n;++o<n;){var c=ri(a=t[o]),u="wrapper"==c?oi(a):r;l=u&&vi(u[0])&&424==u[1]&&!u[4].length&&1==u[9]?l[ri(u[0])].apply(l,u[3]):1==a.length&&vi(a)?l[c]():l.thru(a)}return function(){var e=arguments,o=e[0];if(l&&1==e.length&&Vs(o))return l.plant(o).value();for(var r=0,i=n?t[r].apply(this,e):o;++r<n;)i=t[r].call(this,i);return i}}))}function Fr(e,t,n,i,s,a,l,u,h,d){var p=t&c,m=1&t,f=2&t,g=24&t,y=512&t,b=f?r:$r(e);return function c(){for(var v=arguments.length,C=o(v),x=v;x--;)C[x]=arguments[x];if(g)var w=ii(c),A=function(e,t){for(var n=e.length,o=0;n--;)e[n]===t&&++o;return o}(C,w);if(i&&(C=Er(C,i,s,g)),a&&(C=Sr(C,a,l,g)),v-=A,g&&v<d){var T=an(C,w);return qr(e,t,Fr,c.placeholder,n,C,T,u,h,d-v)}var E=m?n:this,S=f?E[e]:e;return v=C.length,u?C=function(e,t){for(var n=e.length,o=yn(t.length,n),i=Nr(e);o--;){var s=t[o];e[o]=gi(s,n)?i[s]:r}return e}(C,u):y&&v>1&&C.reverse(),p&&h<v&&(C.length=h),this&&this!==ht&&this instanceof c&&(S=b||$r(S)),S.apply(E,C)}}function kr(e,t){return function(n,o){return function(e,t,n,o){return vo(e,(function(e,r,i){t(o,n(e),r,i)})),o}(n,e,t(o),{})}}function Hr(e,t){return function(n,o){var i;if(n===r&&o===r)return t;if(n!==r&&(i=n),o!==r){if(i===r)return o;"string"==typeof n||"string"==typeof o?(n=ar(n),o=ar(o)):(n=sr(n),o=sr(o)),i=e(n,o)}return i}}function Gr(e){return ei((function(t){return t=_t(t,Kt(si())),Yo((function(n){var o=this;return e(t,(function(e){return At(e,o,n)}))}))}))}function Ur(e,t){var n=(t=t===r?" ":ar(t)).length;if(n<2)return n?zo(t,e):t;var o=zo(t,dt(e/un(t)));return on(t)?vr(hn(o),0,e).join(""):o.slice(0,e)}function Vr(e){return function(t,n,i){return i&&"number"!=typeof i&&yi(t,n,i)&&(n=i=r),t=da(t),n===r?(n=t,t=0):n=da(n),function(e,t,n,r){for(var i=-1,s=gn(dt((t-e)/(n||1)),0),a=o(s);s--;)a[r?s:++i]=e,e+=n;return a}(t,n,i=i===r?t<n?1:-1:da(i),e)}}function jr(e){return function(t,n){return"string"==typeof t&&"string"==typeof n||(t=fa(t),n=fa(n)),e(t,n)}}function qr(e,t,n,o,i,s,a,c,u,h){var d=8&t;t|=d?l:64,4&(t&=~(d?64:l))||(t&=-4);var p=[e,t,i,d?s:r,d?a:r,d?r:s,d?r:a,c,u,h],m=n.apply(r,p);return vi(e)&&Ni(m,p),m.placeholder=o,Pi(m,e,t)}function Wr(e){var t=Ae[e];return function(e,n){if(e=fa(e),(n=null==n?0:yn(pa(n),292))&&Dt(e)){var o=(ya(e)+"e").split("e");return+((o=(ya(t(o[0]+"e"+(+o[1]+n)))+"e").split("e"))[0]+"e"+(+o[1]-n))}return t(e)}}var zr=En&&1/ln(new En([,-0]))[1]==u?function(e){return new En(e)}:al;function Yr(e){return function(t){var n=di(t);return n==w?rn(t):n==N?cn(t):function(e,t){return _t(t,(function(t){return[t,e[t]]}))}(t,e(t))}}function Kr(e,t,n,s,u,h,d,p){var m=2&t;if(!m&&"function"!=typeof e)throw new Ne(i);var f=s?s.length:0;if(f||(t&=-97,s=u=r),d=d===r?d:gn(pa(d),0),p=p===r?p:pa(p),f-=u?u.length:0,64&t){var g=s,y=u;s=u=r}var b=m?r:oi(e),v=[e,t,n,s,u,g,y,h,d,p];if(b&&function(e,t){var n=e[1],o=t[1],r=n|o,i=r<131,s=o==c&&8==n||o==c&&256==n&&e[7].length<=t[8]||384==o&&t[7].length<=t[8]&&8==n;if(!i&&!s)return e;1&o&&(e[2]=t[2],r|=1&n?0:4);var l=t[3];if(l){var u=e[3];e[3]=u?Er(u,l,t[4]):l,e[4]=u?an(e[3],a):t[4]}(l=t[5])&&(u=e[5],e[5]=u?Sr(u,l,t[6]):l,e[6]=u?an(e[5],a):t[6]),(l=t[7])&&(e[7]=l),o&c&&(e[8]=null==e[8]?t[8]:yn(e[8],t[8])),null==e[9]&&(e[9]=t[9]),e[0]=t[0],e[1]=r}(v,b),e=v[0],t=v[1],n=v[2],s=v[3],u=v[4],!(p=v[9]=v[9]===r?m?0:e.length:gn(v[9]-f,0))&&24&t&&(t&=-25),t&&1!=t)C=8==t||16==t?function(e,t,n){var i=$r(e);return function s(){for(var a=arguments.length,l=o(a),c=a,u=ii(s);c--;)l[c]=arguments[c];var h=a<3&&l[0]!==u&&l[a-1]!==u?[]:an(l,u);return(a-=h.length)<n?qr(e,t,Fr,s.placeholder,r,l,h,r,r,n-a):At(this&&this!==ht&&this instanceof s?i:e,this,l)}}(e,t,p):t!=l&&33!=t||u.length?Fr.apply(r,v):function(e,t,n,r){var i=1&t,s=$r(e);return function t(){for(var a=-1,l=arguments.length,c=-1,u=r.length,h=o(u+l),d=this&&this!==ht&&this instanceof t?s:e;++c<u;)h[c]=r[c];for(;l--;)h[c++]=arguments[++a];return At(d,i?n:this,h)}}(e,t,n,s);else var C=function(e,t,n){var o=1&t,r=$r(e);return function t(){return(this&&this!==ht&&this instanceof t?r:e).apply(o?n:this,arguments)}}(e,t,n);return Pi((b?Xo:Ni)(C,v),e,t)}function Qr(e,t,n,o){return e===r||ks(e,Pe[n])&&!Oe.call(o,n)?t:e}function Jr(e,t,n,o,i,s){return Zs(e)&&Zs(t)&&(s.set(t,e),Ho(e,t,r,Jr,s),s.delete(t)),e}function Xr(e){return oa(e)?r:e}function Zr(e,t,n,o,i,s){var a=1&n,l=e.length,c=t.length;if(l!=c&&!(a&&c>l))return!1;var u=s.get(e),h=s.get(t);if(u&&h)return u==t&&h==e;var d=-1,p=!0,m=2&n?new Wn:r;for(s.set(e,t),s.set(t,e);++d<l;){var f=e[d],g=t[d];if(o)var y=a?o(g,f,d,t,e,s):o(f,g,d,e,t,s);if(y!==r){if(y)continue;p=!1;break}if(m){if(!$t(t,(function(e,t){if(!Jt(m,t)&&(f===e||i(f,e,n,o,s)))return m.push(t)}))){p=!1;break}}else if(f!==g&&!i(f,g,n,o,s)){p=!1;break}}return s.delete(e),s.delete(t),p}function ei(e){return Mi(Ti(e,r,ji),e+"")}function ti(e){return Ao(e,Pa,ui)}function ni(e){return Ao(e,_a,hi)}var oi=In?function(e){return In.get(e)}:al;function ri(e){for(var t=e.name+"",n=Mn[t],o=Oe.call(Mn,t)?n.length:0;o--;){var r=n[o],i=r.func;if(null==i||i==e)return r.name}return t}function ii(e){return(Oe.call(Fn,"placeholder")?Fn:e).placeholder}function si(){var e=Fn.iteratee||ol;return e=e===ol?Ro:e,arguments.length?e(arguments[0],arguments[1]):e}function ai(e,t){var n,o,r=e.__data__;return("string"==(o=typeof(n=t))||"number"==o||"symbol"==o||"boolean"==o?"__proto__"!==n:null===n)?r["string"==typeof t?"string":"hash"]:r.map}function li(e){for(var t=Pa(e),n=t.length;n--;){var o=t[n],r=e[o];t[n]=[o,r,wi(r)]}return t}function ci(e,t){var n=function(e,t){return null==e?r:e[t]}(e,t);return Oo(n)?n:r}var ui=ft?function(e){return null==e?[]:(e=Te(e),It(ft(e),(function(t){return We.call(e,t)})))}:ml,hi=ft?function(e){for(var t=[];e;)Lt(t,ui(e)),e=je(e);return t}:ml,di=To;function pi(e,t,n){for(var o=-1,r=(t=yr(t,e)).length,i=!1;++o<r;){var s=Di(t[o]);if(!(i=null!=e&&n(e,s)))break;e=e[s]}return i||++o!=r?i:!!(r=null==e?0:e.length)&&Xs(r)&&gi(s,r)&&(Vs(e)||Us(e))}function mi(e){return"function"!=typeof e.constructor||xi(e)?{}:kn(je(e))}function fi(e){return Vs(e)||Us(e)||!!(Ye&&e&&e[Ye])}function gi(e,t){var n=typeof e;return!!(t=null==t?h:t)&&("number"==n||"symbol"!=n&&ye.test(e))&&e>-1&&e%1==0&&e<t}function yi(e,t,n){if(!Zs(n))return!1;var o=typeof t;return!!("number"==o?qs(n)&&gi(t,n.length):"string"==o&&t in n)&&ks(n[t],e)}function bi(e,t){if(Vs(e))return!1;var n=typeof e;return!("number"!=n&&"symbol"!=n&&"boolean"!=n&&null!=e&&!aa(e))||Z.test(e)||!X.test(e)||null!=t&&e in Te(t)}function vi(e){var t=ri(e),n=Fn[t];if("function"!=typeof n||!(t in Un.prototype))return!1;if(e===n)return!0;var o=oi(n);return!!o&&e===o[0]}(wn&&di(new wn(new ArrayBuffer(1)))!=L||An&&di(new An)!=w||Tn&&di(Tn.resolve())!=E||En&&di(new En)!=N||Sn&&di(new Sn)!=P)&&(di=function(e){var t=To(e),n=t==T?e.constructor:r,o=n?Bi(n):"";if(o)switch(o){case Pn:return L;case _n:return w;case Ln:return E;case On:return N;case Rn:return P}return t});var Ci=_e?Qs:fl;function xi(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||Pe)}function wi(e){return e==e&&!Zs(e)}function Ai(e,t){return function(n){return null!=n&&n[e]===t&&(t!==r||e in Te(n))}}function Ti(e,t,n){return t=gn(t===r?e.length-1:t,0),function(){for(var r=arguments,i=-1,s=gn(r.length-t,0),a=o(s);++i<s;)a[i]=r[t+i];i=-1;for(var l=o(t+1);++i<t;)l[i]=r[i];return l[t]=n(a),At(e,this,l)}}function Ei(e,t){return t.length<2?e:wo(e,tr(t,0,-1))}function Si(e,t){if(("constructor"!==t||"function"!=typeof e[t])&&"__proto__"!=t)return e[t]}var Ni=_i(Xo),Ii=ut||function(e,t){return ht.setTimeout(e,t)},Mi=_i(Zo);function Pi(e,t,n){var o=t+"";return Mi(e,function(e,t){var n=t.length;if(!n)return e;var o=n-1;return t[o]=(n>1?"& ":"")+t[o],t=t.join(n>2?", ":" "),e.replace(ie,"{\n/* [wrapped with "+t+"] */\n")}(o,function(e,t){return Et(m,(function(n){var o="_."+n[0];t&n[1]&&!Mt(e,o)&&e.push(o)})),e.sort()}(function(e){var t=e.match(se);return t?t[1].split(ae):[]}(o),n)))}function _i(e){var t=0,n=0;return function(){var o=bn(),i=16-(o-n);if(n=o,i>0){if(++t>=800)return arguments[0]}else t=0;return e.apply(r,arguments)}}function Li(e,t){var n=-1,o=e.length,i=o-1;for(t=t===r?o:t;++n<t;){var s=Wo(n,i),a=e[s];e[s]=e[n],e[n]=a}return e.length=t,e}var Oi,Ri,$i=(Oi=Os((function(e){var t=[];return 46===e.charCodeAt(0)&&t.push(""),e.replace(ee,(function(e,n,o,r){t.push(o?r.replace(ue,"$1"):n||e)})),t}),(function(e){return 500===Ri.size&&Ri.clear(),e})),Ri=Oi.cache,Oi);function Di(e){if("string"==typeof e||aa(e))return e;var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}function Bi(e){if(null!=e){try{return Le.call(e)}catch(e){}try{return e+""}catch(e){}}return""}function Fi(e){if(e instanceof Un)return e.clone();var t=new Gn(e.__wrapped__,e.__chain__);return t.__actions__=Nr(e.__actions__),t.__index__=e.__index__,t.__values__=e.__values__,t}var ki=Yo((function(e,t){return Ws(e)?co(e,go(t,1,Ws,!0)):[]})),Hi=Yo((function(e,t){var n=Ki(t);return Ws(n)&&(n=r),Ws(e)?co(e,go(t,1,Ws,!0),si(n,2)):[]})),Gi=Yo((function(e,t){var n=Ki(t);return Ws(n)&&(n=r),Ws(e)?co(e,go(t,1,Ws,!0),r,n):[]}));function Ui(e,t,n){var o=null==e?0:e.length;if(!o)return-1;var r=null==n?0:pa(n);return r<0&&(r=gn(o+r,0)),Ft(e,si(t,3),r)}function Vi(e,t,n){var o=null==e?0:e.length;if(!o)return-1;var i=o-1;return n!==r&&(i=pa(n),i=n<0?gn(o+i,0):yn(i,o-1)),Ft(e,si(t,3),i,!0)}function ji(e){return null!=e&&e.length?go(e,1):[]}function qi(e){return e&&e.length?e[0]:r}var Wi=Yo((function(e){var t=_t(e,fr);return t.length&&t[0]===e[0]?Io(t):[]})),zi=Yo((function(e){var t=Ki(e),n=_t(e,fr);return t===Ki(n)?t=r:n.pop(),n.length&&n[0]===e[0]?Io(n,si(t,2)):[]})),Yi=Yo((function(e){var t=Ki(e),n=_t(e,fr);return(t="function"==typeof t?t:r)&&n.pop(),n.length&&n[0]===e[0]?Io(n,r,t):[]}));function Ki(e){var t=null==e?0:e.length;return t?e[t-1]:r}var Qi=Yo(Ji);function Ji(e,t){return e&&e.length&&t&&t.length?jo(e,t):e}var Xi=ei((function(e,t){var n=null==e?0:e.length,o=ro(e,t);return qo(e,_t(t,(function(e){return gi(e,n)?+e:e})).sort(Tr)),o}));function Zi(e){return null==e?e:xn.call(e)}var es=Yo((function(e){return lr(go(e,1,Ws,!0))})),ts=Yo((function(e){var t=Ki(e);return Ws(t)&&(t=r),lr(go(e,1,Ws,!0),si(t,2))})),ns=Yo((function(e){var t=Ki(e);return t="function"==typeof t?t:r,lr(go(e,1,Ws,!0),r,t)}));function os(e){if(!e||!e.length)return[];var t=0;return e=It(e,(function(e){if(Ws(e))return t=gn(e.length,t),!0})),zt(t,(function(t){return _t(e,Vt(t))}))}function rs(e,t){if(!e||!e.length)return[];var n=os(e);return null==t?n:_t(n,(function(e){return At(t,r,e)}))}var is=Yo((function(e,t){return Ws(e)?co(e,t):[]})),ss=Yo((function(e){return pr(It(e,Ws))})),as=Yo((function(e){var t=Ki(e);return Ws(t)&&(t=r),pr(It(e,Ws),si(t,2))})),ls=Yo((function(e){var t=Ki(e);return t="function"==typeof t?t:r,pr(It(e,Ws),r,t)})),cs=Yo(os),us=Yo((function(e){var t=e.length,n=t>1?e[t-1]:r;return n="function"==typeof n?(e.pop(),n):r,rs(e,n)}));function hs(e){var t=Fn(e);return t.__chain__=!0,t}function ds(e,t){return t(e)}var ps=ei((function(e){var t=e.length,n=t?e[0]:0,o=this.__wrapped__,i=function(t){return ro(t,e)};return!(t>1||this.__actions__.length)&&o instanceof Un&&gi(n)?((o=o.slice(n,+n+(t?1:0))).__actions__.push({func:ds,args:[i],thisArg:r}),new Gn(o,this.__chain__).thru((function(e){return t&&!e.length&&e.push(r),e}))):this.thru(i)})),ms=Mr((function(e,t,n){Oe.call(e,n)?++e[n]:oo(e,n,1)})),fs=Dr(Ui),gs=Dr(Vi);function ys(e,t){return(Vs(e)?Et:uo)(e,si(t,3))}function bs(e,t){return(Vs(e)?St:ho)(e,si(t,3))}var vs=Mr((function(e,t,n){Oe.call(e,n)?e[n].push(t):oo(e,n,[t])})),Cs=Yo((function(e,t,n){var r=-1,i="function"==typeof t,s=qs(e)?o(e.length):[];return uo(e,(function(e){s[++r]=i?At(t,e,n):Mo(e,t,n)})),s})),xs=Mr((function(e,t,n){oo(e,n,t)}));function ws(e,t){return(Vs(e)?_t:Bo)(e,si(t,3))}var As=Mr((function(e,t,n){e[n?0:1].push(t)}),(function(){return[[],[]]})),Ts=Yo((function(e,t){if(null==e)return[];var n=t.length;return n>1&&yi(e,t[0],t[1])?t=[]:n>2&&yi(t[0],t[1],t[2])&&(t=[t[0]]),Uo(e,go(t,1),[])})),Es=ct||function(){return ht.Date.now()};function Ss(e,t,n){return t=n?r:t,t=e&&null==t?e.length:t,Kr(e,c,r,r,r,r,t)}function Ns(e,t){var n;if("function"!=typeof t)throw new Ne(i);return e=pa(e),function(){return--e>0&&(n=t.apply(this,arguments)),e<=1&&(t=r),n}}var Is=Yo((function(e,t,n){var o=1;if(n.length){var r=an(n,ii(Is));o|=l}return Kr(e,o,t,n,r)})),Ms=Yo((function(e,t,n){var o=3;if(n.length){var r=an(n,ii(Ms));o|=l}return Kr(t,o,e,n,r)}));function Ps(e,t,n){var o,s,a,l,c,u,h=0,d=!1,p=!1,m=!0;if("function"!=typeof e)throw new Ne(i);function f(t){var n=o,i=s;return o=s=r,h=t,l=e.apply(i,n)}function g(e){var n=e-u;return u===r||n>=t||n<0||p&&e-h>=a}function y(){var e=Es();if(g(e))return b(e);c=Ii(y,function(e){var n=t-(e-u);return p?yn(n,a-(e-h)):n}(e))}function b(e){return c=r,m&&o?f(e):(o=s=r,l)}function v(){var e=Es(),n=g(e);if(o=arguments,s=this,u=e,n){if(c===r)return function(e){return h=e,c=Ii(y,t),d?f(e):l}(u);if(p)return Cr(c),c=Ii(y,t),f(u)}return c===r&&(c=Ii(y,t)),l}return t=fa(t)||0,Zs(n)&&(d=!!n.leading,a=(p="maxWait"in n)?gn(fa(n.maxWait)||0,t):a,m="trailing"in n?!!n.trailing:m),v.cancel=function(){c!==r&&Cr(c),h=0,o=u=s=c=r},v.flush=function(){return c===r?l:b(Es())},v}var _s=Yo((function(e,t){return lo(e,1,t)})),Ls=Yo((function(e,t,n){return lo(e,fa(t)||0,n)}));function Os(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new Ne(i);var n=function(){var o=arguments,r=t?t.apply(this,o):o[0],i=n.cache;if(i.has(r))return i.get(r);var s=e.apply(this,o);return n.cache=i.set(r,s)||i,s};return n.cache=new(Os.Cache||qn),n}function Rs(e){if("function"!=typeof e)throw new Ne(i);return function(){var t=arguments;switch(t.length){case 0:return!e.call(this);case 1:return!e.call(this,t[0]);case 2:return!e.call(this,t[0],t[1]);case 3:return!e.call(this,t[0],t[1],t[2])}return!e.apply(this,t)}}Os.Cache=qn;var $s=br((function(e,t){var n=(t=1==t.length&&Vs(t[0])?_t(t[0],Kt(si())):_t(go(t,1),Kt(si()))).length;return Yo((function(o){for(var r=-1,i=yn(o.length,n);++r<i;)o[r]=t[r].call(this,o[r]);return At(e,this,o)}))})),Ds=Yo((function(e,t){var n=an(t,ii(Ds));return Kr(e,l,r,t,n)})),Bs=Yo((function(e,t){var n=an(t,ii(Bs));return Kr(e,64,r,t,n)})),Fs=ei((function(e,t){return Kr(e,256,r,r,r,t)}));function ks(e,t){return e===t||e!=e&&t!=t}var Hs=jr(Eo),Gs=jr((function(e,t){return e>=t})),Us=Po(function(){return arguments}())?Po:function(e){return ea(e)&&Oe.call(e,"callee")&&!We.call(e,"callee")},Vs=o.isArray,js=yt?Kt(yt):function(e){return ea(e)&&To(e)==_};function qs(e){return null!=e&&Xs(e.length)&&!Qs(e)}function Ws(e){return ea(e)&&qs(e)}var zs=gt||fl,Ys=bt?Kt(bt):function(e){return ea(e)&&To(e)==b};function Ks(e){if(!ea(e))return!1;var t=To(e);return t==v||"[object DOMException]"==t||"string"==typeof e.message&&"string"==typeof e.name&&!oa(e)}function Qs(e){if(!Zs(e))return!1;var t=To(e);return t==C||t==x||"[object AsyncFunction]"==t||"[object Proxy]"==t}function Js(e){return"number"==typeof e&&e==pa(e)}function Xs(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=h}function Zs(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function ea(e){return null!=e&&"object"==typeof e}var ta=vt?Kt(vt):function(e){return ea(e)&&di(e)==w};function na(e){return"number"==typeof e||ea(e)&&To(e)==A}function oa(e){if(!ea(e)||To(e)!=T)return!1;var t=je(e);if(null===t)return!0;var n=Oe.call(t,"constructor")&&t.constructor;return"function"==typeof n&&n instanceof n&&Le.call(n)==Be}var ra=Ct?Kt(Ct):function(e){return ea(e)&&To(e)==S},ia=xt?Kt(xt):function(e){return ea(e)&&di(e)==N};function sa(e){return"string"==typeof e||!Vs(e)&&ea(e)&&To(e)==I}function aa(e){return"symbol"==typeof e||ea(e)&&To(e)==M}var la=wt?Kt(wt):function(e){return ea(e)&&Xs(e.length)&&!!rt[To(e)]},ca=jr(Do),ua=jr((function(e,t){return e<=t}));function ha(e){if(!e)return[];if(qs(e))return sa(e)?hn(e):Nr(e);if(Ke&&e[Ke])return function(e){for(var t,n=[];!(t=e.next()).done;)n.push(t.value);return n}(e[Ke]());var t=di(e);return(t==w?rn:t==N?ln:ka)(e)}function da(e){return e?(e=fa(e))===u||e===-1/0?17976931348623157e292*(e<0?-1:1):e==e?e:0:0===e?e:0}function pa(e){var t=da(e),n=t%1;return t==t?n?t-n:t:0}function ma(e){return e?io(pa(e),0,p):0}function fa(e){if("number"==typeof e)return e;if(aa(e))return d;if(Zs(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=Zs(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=Yt(e);var n=me.test(e);return n||ge.test(e)?lt(e.slice(2),n?2:8):pe.test(e)?d:+e}function ga(e){return Ir(e,_a(e))}function ya(e){return null==e?"":ar(e)}var ba=Pr((function(e,t){if(xi(t)||qs(t))Ir(t,Pa(t),e);else for(var n in t)Oe.call(t,n)&&Zn(e,n,t[n])})),va=Pr((function(e,t){Ir(t,_a(t),e)})),Ca=Pr((function(e,t,n,o){Ir(t,_a(t),e,o)})),xa=Pr((function(e,t,n,o){Ir(t,Pa(t),e,o)})),wa=ei(ro),Aa=Yo((function(e,t){e=Te(e);var n=-1,o=t.length,i=o>2?t[2]:r;for(i&&yi(t[0],t[1],i)&&(o=1);++n<o;)for(var s=t[n],a=_a(s),l=-1,c=a.length;++l<c;){var u=a[l],h=e[u];(h===r||ks(h,Pe[u])&&!Oe.call(e,u))&&(e[u]=s[u])}return e})),Ta=Yo((function(e){return e.push(r,Jr),At(Oa,r,e)}));function Ea(e,t,n){var o=null==e?r:wo(e,t);return o===r?n:o}function Sa(e,t){return null!=e&&pi(e,t,No)}var Na=kr((function(e,t,n){null!=t&&"function"!=typeof t.toString&&(t=De.call(t)),e[t]=n}),Za(nl)),Ia=kr((function(e,t,n){null!=t&&"function"!=typeof t.toString&&(t=De.call(t)),Oe.call(e,t)?e[t].push(n):e[t]=[n]}),si),Ma=Yo(Mo);function Pa(e){return qs(e)?Yn(e):$o(e)}function _a(e){return qs(e)?Yn(e,!0):function(e){if(!Zs(e))return function(e){var t=[];if(null!=e)for(var n in Te(e))t.push(n);return t}(e);var t=xi(e),n=[];for(var o in e)("constructor"!=o||!t&&Oe.call(e,o))&&n.push(o);return n}(e)}var La=Pr((function(e,t,n){Ho(e,t,n)})),Oa=Pr((function(e,t,n,o){Ho(e,t,n,o)})),Ra=ei((function(e,t){var n={};if(null==e)return n;var o=!1;t=_t(t,(function(t){return t=yr(t,e),o||(o=t.length>1),t})),Ir(e,ni(e),n),o&&(n=so(n,7,Xr));for(var r=t.length;r--;)cr(n,t[r]);return n})),$a=ei((function(e,t){return null==e?{}:function(e,t){return Vo(e,t,(function(t,n){return Sa(e,n)}))}(e,t)}));function Da(e,t){if(null==e)return{};var n=_t(ni(e),(function(e){return[e]}));return t=si(t),Vo(e,n,(function(e,n){return t(e,n[0])}))}var Ba=Yr(Pa),Fa=Yr(_a);function ka(e){return null==e?[]:Qt(e,Pa(e))}var Ha=Rr((function(e,t,n){return t=t.toLowerCase(),e+(n?Ga(t):t)}));function Ga(e){return Ka(ya(e).toLowerCase())}function Ua(e){return(e=ya(e))&&e.replace(be,en).replace(Je,"")}var Va=Rr((function(e,t,n){return e+(n?"-":"")+t.toLowerCase()})),ja=Rr((function(e,t,n){return e+(n?" ":"")+t.toLowerCase()})),qa=Or("toLowerCase"),Wa=Rr((function(e,t,n){return e+(n?"_":"")+t.toLowerCase()})),za=Rr((function(e,t,n){return e+(n?" ":"")+Ka(t)})),Ya=Rr((function(e,t,n){return e+(n?" ":"")+t.toUpperCase()})),Ka=Or("toUpperCase");function Qa(e,t,n){return e=ya(e),(t=n?r:t)===r?function(e){return tt.test(e)}(e)?function(e){return e.match(Ze)||[]}(e):function(e){return e.match(le)||[]}(e):e.match(t)||[]}var Ja=Yo((function(e,t){try{return At(e,r,t)}catch(e){return Ks(e)?e:new xe(e)}})),Xa=ei((function(e,t){return Et(t,(function(t){t=Di(t),oo(e,t,Is(e[t],e))})),e}));function Za(e){return function(){return e}}var el=Br(),tl=Br(!0);function nl(e){return e}function ol(e){return Ro("function"==typeof e?e:so(e,1))}var rl=Yo((function(e,t){return function(n){return Mo(n,e,t)}})),il=Yo((function(e,t){return function(n){return Mo(e,n,t)}}));function sl(e,t,n){var o=Pa(t),r=xo(t,o);null!=n||Zs(t)&&(r.length||!o.length)||(n=t,t=e,e=this,r=xo(t,Pa(t)));var i=!(Zs(n)&&"chain"in n&&!n.chain),s=Qs(e);return Et(r,(function(n){var o=t[n];e[n]=o,s&&(e.prototype[n]=function(){var t=this.__chain__;if(i||t){var n=e(this.__wrapped__);return(n.__actions__=Nr(this.__actions__)).push({func:o,args:arguments,thisArg:e}),n.__chain__=t,n}return o.apply(e,Lt([this.value()],arguments))})})),e}function al(){}var ll=Gr(_t),cl=Gr(Nt),ul=Gr($t);function hl(e){return bi(e)?Vt(Di(e)):function(e){return function(t){return wo(t,e)}}(e)}var dl=Vr(),pl=Vr(!0);function ml(){return[]}function fl(){return!1}var gl,yl=Hr((function(e,t){return e+t}),0),bl=Wr("ceil"),vl=Hr((function(e,t){return e/t}),1),Cl=Wr("floor"),xl=Hr((function(e,t){return e*t}),1),wl=Wr("round"),Al=Hr((function(e,t){return e-t}),0);return Fn.after=function(e,t){if("function"!=typeof t)throw new Ne(i);return e=pa(e),function(){if(--e<1)return t.apply(this,arguments)}},Fn.ary=Ss,Fn.assign=ba,Fn.assignIn=va,Fn.assignInWith=Ca,Fn.assignWith=xa,Fn.at=wa,Fn.before=Ns,Fn.bind=Is,Fn.bindAll=Xa,Fn.bindKey=Ms,Fn.castArray=function(){if(!arguments.length)return[];var e=arguments[0];return Vs(e)?e:[e]},Fn.chain=hs,Fn.chunk=function(e,t,n){t=(n?yi(e,t,n):t===r)?1:gn(pa(t),0);var i=null==e?0:e.length;if(!i||t<1)return[];for(var s=0,a=0,l=o(dt(i/t));s<i;)l[a++]=tr(e,s,s+=t);return l},Fn.compact=function(e){for(var t=-1,n=null==e?0:e.length,o=0,r=[];++t<n;){var i=e[t];i&&(r[o++]=i)}return r},Fn.concat=function(){var e=arguments.length;if(!e)return[];for(var t=o(e-1),n=arguments[0],r=e;r--;)t[r-1]=arguments[r];return Lt(Vs(n)?Nr(n):[n],go(t,1))},Fn.cond=function(e){var t=null==e?0:e.length,n=si();return e=t?_t(e,(function(e){if("function"!=typeof e[1])throw new Ne(i);return[n(e[0]),e[1]]})):[],Yo((function(n){for(var o=-1;++o<t;){var r=e[o];if(At(r[0],this,n))return At(r[1],this,n)}}))},Fn.conforms=function(e){return function(e){var t=Pa(e);return function(n){return ao(n,e,t)}}(so(e,1))},Fn.constant=Za,Fn.countBy=ms,Fn.create=function(e,t){var n=kn(e);return null==t?n:no(n,t)},Fn.curry=function e(t,n,o){var i=Kr(t,8,r,r,r,r,r,n=o?r:n);return i.placeholder=e.placeholder,i},Fn.curryRight=function e(t,n,o){var i=Kr(t,16,r,r,r,r,r,n=o?r:n);return i.placeholder=e.placeholder,i},Fn.debounce=Ps,Fn.defaults=Aa,Fn.defaultsDeep=Ta,Fn.defer=_s,Fn.delay=Ls,Fn.difference=ki,Fn.differenceBy=Hi,Fn.differenceWith=Gi,Fn.drop=function(e,t,n){var o=null==e?0:e.length;return o?tr(e,(t=n||t===r?1:pa(t))<0?0:t,o):[]},Fn.dropRight=function(e,t,n){var o=null==e?0:e.length;return o?tr(e,0,(t=o-(t=n||t===r?1:pa(t)))<0?0:t):[]},Fn.dropRightWhile=function(e,t){return e&&e.length?hr(e,si(t,3),!0,!0):[]},Fn.dropWhile=function(e,t){return e&&e.length?hr(e,si(t,3),!0):[]},Fn.fill=function(e,t,n,o){var i=null==e?0:e.length;return i?(n&&"number"!=typeof n&&yi(e,t,n)&&(n=0,o=i),function(e,t,n,o){var i=e.length;for((n=pa(n))<0&&(n=-n>i?0:i+n),(o=o===r||o>i?i:pa(o))<0&&(o+=i),o=n>o?0:ma(o);n<o;)e[n++]=t;return e}(e,t,n,o)):[]},Fn.filter=function(e,t){return(Vs(e)?It:fo)(e,si(t,3))},Fn.flatMap=function(e,t){return go(ws(e,t),1)},Fn.flatMapDeep=function(e,t){return go(ws(e,t),u)},Fn.flatMapDepth=function(e,t,n){return n=n===r?1:pa(n),go(ws(e,t),n)},Fn.flatten=ji,Fn.flattenDeep=function(e){return null!=e&&e.length?go(e,u):[]},Fn.flattenDepth=function(e,t){return null!=e&&e.length?go(e,t=t===r?1:pa(t)):[]},Fn.flip=function(e){return Kr(e,512)},Fn.flow=el,Fn.flowRight=tl,Fn.fromPairs=function(e){for(var t=-1,n=null==e?0:e.length,o={};++t<n;){var r=e[t];o[r[0]]=r[1]}return o},Fn.functions=function(e){return null==e?[]:xo(e,Pa(e))},Fn.functionsIn=function(e){return null==e?[]:xo(e,_a(e))},Fn.groupBy=vs,Fn.initial=function(e){return null!=e&&e.length?tr(e,0,-1):[]},Fn.intersection=Wi,Fn.intersectionBy=zi,Fn.intersectionWith=Yi,Fn.invert=Na,Fn.invertBy=Ia,Fn.invokeMap=Cs,Fn.iteratee=ol,Fn.keyBy=xs,Fn.keys=Pa,Fn.keysIn=_a,Fn.map=ws,Fn.mapKeys=function(e,t){var n={};return t=si(t,3),vo(e,(function(e,o,r){oo(n,t(e,o,r),e)})),n},Fn.mapValues=function(e,t){var n={};return t=si(t,3),vo(e,(function(e,o,r){oo(n,o,t(e,o,r))})),n},Fn.matches=function(e){return Fo(so(e,1))},Fn.matchesProperty=function(e,t){return ko(e,so(t,1))},Fn.memoize=Os,Fn.merge=La,Fn.mergeWith=Oa,Fn.method=rl,Fn.methodOf=il,Fn.mixin=sl,Fn.negate=Rs,Fn.nthArg=function(e){return e=pa(e),Yo((function(t){return Go(t,e)}))},Fn.omit=Ra,Fn.omitBy=function(e,t){return Da(e,Rs(si(t)))},Fn.once=function(e){return Ns(2,e)},Fn.orderBy=function(e,t,n,o){return null==e?[]:(Vs(t)||(t=null==t?[]:[t]),Vs(n=o?r:n)||(n=null==n?[]:[n]),Uo(e,t,n))},Fn.over=ll,Fn.overArgs=$s,Fn.overEvery=cl,Fn.overSome=ul,Fn.partial=Ds,Fn.partialRight=Bs,Fn.partition=As,Fn.pick=$a,Fn.pickBy=Da,Fn.property=hl,Fn.propertyOf=function(e){return function(t){return null==e?r:wo(e,t)}},Fn.pull=Qi,Fn.pullAll=Ji,Fn.pullAllBy=function(e,t,n){return e&&e.length&&t&&t.length?jo(e,t,si(n,2)):e},Fn.pullAllWith=function(e,t,n){return e&&e.length&&t&&t.length?jo(e,t,r,n):e},Fn.pullAt=Xi,Fn.range=dl,Fn.rangeRight=pl,Fn.rearg=Fs,Fn.reject=function(e,t){return(Vs(e)?It:fo)(e,Rs(si(t,3)))},Fn.remove=function(e,t){var n=[];if(!e||!e.length)return n;var o=-1,r=[],i=e.length;for(t=si(t,3);++o<i;){var s=e[o];t(s,o,e)&&(n.push(s),r.push(o))}return qo(e,r),n},Fn.rest=function(e,t){if("function"!=typeof e)throw new Ne(i);return Yo(e,t=t===r?t:pa(t))},Fn.reverse=Zi,Fn.sampleSize=function(e,t,n){return t=(n?yi(e,t,n):t===r)?1:pa(t),(Vs(e)?Qn:Qo)(e,t)},Fn.set=function(e,t,n){return null==e?e:Jo(e,t,n)},Fn.setWith=function(e,t,n,o){return o="function"==typeof o?o:r,null==e?e:Jo(e,t,n,o)},Fn.shuffle=function(e){return(Vs(e)?Jn:er)(e)},Fn.slice=function(e,t,n){var o=null==e?0:e.length;return o?(n&&"number"!=typeof n&&yi(e,t,n)?(t=0,n=o):(t=null==t?0:pa(t),n=n===r?o:pa(n)),tr(e,t,n)):[]},Fn.sortBy=Ts,Fn.sortedUniq=function(e){return e&&e.length?ir(e):[]},Fn.sortedUniqBy=function(e,t){return e&&e.length?ir(e,si(t,2)):[]},Fn.split=function(e,t,n){return n&&"number"!=typeof n&&yi(e,t,n)&&(t=n=r),(n=n===r?p:n>>>0)?(e=ya(e))&&("string"==typeof t||null!=t&&!ra(t))&&!(t=ar(t))&&on(e)?vr(hn(e),0,n):e.split(t,n):[]},Fn.spread=function(e,t){if("function"!=typeof e)throw new Ne(i);return t=null==t?0:gn(pa(t),0),Yo((function(n){var o=n[t],r=vr(n,0,t);return o&&Lt(r,o),At(e,this,r)}))},Fn.tail=function(e){var t=null==e?0:e.length;return t?tr(e,1,t):[]},Fn.take=function(e,t,n){return e&&e.length?tr(e,0,(t=n||t===r?1:pa(t))<0?0:t):[]},Fn.takeRight=function(e,t,n){var o=null==e?0:e.length;return o?tr(e,(t=o-(t=n||t===r?1:pa(t)))<0?0:t,o):[]},Fn.takeRightWhile=function(e,t){return e&&e.length?hr(e,si(t,3),!1,!0):[]},Fn.takeWhile=function(e,t){return e&&e.length?hr(e,si(t,3)):[]},Fn.tap=function(e,t){return t(e),e},Fn.throttle=function(e,t,n){var o=!0,r=!0;if("function"!=typeof e)throw new Ne(i);return Zs(n)&&(o="leading"in n?!!n.leading:o,r="trailing"in n?!!n.trailing:r),Ps(e,t,{leading:o,maxWait:t,trailing:r})},Fn.thru=ds,Fn.toArray=ha,Fn.toPairs=Ba,Fn.toPairsIn=Fa,Fn.toPath=function(e){return Vs(e)?_t(e,Di):aa(e)?[e]:Nr($i(ya(e)))},Fn.toPlainObject=ga,Fn.transform=function(e,t,n){var o=Vs(e),r=o||zs(e)||la(e);if(t=si(t,4),null==n){var i=e&&e.constructor;n=r?o?new i:[]:Zs(e)&&Qs(i)?kn(je(e)):{}}return(r?Et:vo)(e,(function(e,o,r){return t(n,e,o,r)})),n},Fn.unary=function(e){return Ss(e,1)},Fn.union=es,Fn.unionBy=ts,Fn.unionWith=ns,Fn.uniq=function(e){return e&&e.length?lr(e):[]},Fn.uniqBy=function(e,t){return e&&e.length?lr(e,si(t,2)):[]},Fn.uniqWith=function(e,t){return t="function"==typeof t?t:r,e&&e.length?lr(e,r,t):[]},Fn.unset=function(e,t){return null==e||cr(e,t)},Fn.unzip=os,Fn.unzipWith=rs,Fn.update=function(e,t,n){return null==e?e:ur(e,t,gr(n))},Fn.updateWith=function(e,t,n,o){return o="function"==typeof o?o:r,null==e?e:ur(e,t,gr(n),o)},Fn.values=ka,Fn.valuesIn=function(e){return null==e?[]:Qt(e,_a(e))},Fn.without=is,Fn.words=Qa,Fn.wrap=function(e,t){return Ds(gr(t),e)},Fn.xor=ss,Fn.xorBy=as,Fn.xorWith=ls,Fn.zip=cs,Fn.zipObject=function(e,t){return mr(e||[],t||[],Zn)},Fn.zipObjectDeep=function(e,t){return mr(e||[],t||[],Jo)},Fn.zipWith=us,Fn.entries=Ba,Fn.entriesIn=Fa,Fn.extend=va,Fn.extendWith=Ca,sl(Fn,Fn),Fn.add=yl,Fn.attempt=Ja,Fn.camelCase=Ha,Fn.capitalize=Ga,Fn.ceil=bl,Fn.clamp=function(e,t,n){return n===r&&(n=t,t=r),n!==r&&(n=(n=fa(n))==n?n:0),t!==r&&(t=(t=fa(t))==t?t:0),io(fa(e),t,n)},Fn.clone=function(e){return so(e,4)},Fn.cloneDeep=function(e){return so(e,5)},Fn.cloneDeepWith=function(e,t){return so(e,5,t="function"==typeof t?t:r)},Fn.cloneWith=function(e,t){return so(e,4,t="function"==typeof t?t:r)},Fn.conformsTo=function(e,t){return null==t||ao(e,t,Pa(t))},Fn.deburr=Ua,Fn.defaultTo=function(e,t){return null==e||e!=e?t:e},Fn.divide=vl,Fn.endsWith=function(e,t,n){e=ya(e),t=ar(t);var o=e.length,i=n=n===r?o:io(pa(n),0,o);return(n-=t.length)>=0&&e.slice(n,i)==t},Fn.eq=ks,Fn.escape=function(e){return(e=ya(e))&&Y.test(e)?e.replace(W,tn):e},Fn.escapeRegExp=function(e){return(e=ya(e))&&ne.test(e)?e.replace(te,"\\$&"):e},Fn.every=function(e,t,n){var o=Vs(e)?Nt:po;return n&&yi(e,t,n)&&(t=r),o(e,si(t,3))},Fn.find=fs,Fn.findIndex=Ui,Fn.findKey=function(e,t){return Bt(e,si(t,3),vo)},Fn.findLast=gs,Fn.findLastIndex=Vi,Fn.findLastKey=function(e,t){return Bt(e,si(t,3),Co)},Fn.floor=Cl,Fn.forEach=ys,Fn.forEachRight=bs,Fn.forIn=function(e,t){return null==e?e:yo(e,si(t,3),_a)},Fn.forInRight=function(e,t){return null==e?e:bo(e,si(t,3),_a)},Fn.forOwn=function(e,t){return e&&vo(e,si(t,3))},Fn.forOwnRight=function(e,t){return e&&Co(e,si(t,3))},Fn.get=Ea,Fn.gt=Hs,Fn.gte=Gs,Fn.has=function(e,t){return null!=e&&pi(e,t,So)},Fn.hasIn=Sa,Fn.head=qi,Fn.identity=nl,Fn.includes=function(e,t,n,o){e=qs(e)?e:ka(e),n=n&&!o?pa(n):0;var r=e.length;return n<0&&(n=gn(r+n,0)),sa(e)?n<=r&&e.indexOf(t,n)>-1:!!r&&kt(e,t,n)>-1},Fn.indexOf=function(e,t,n){var o=null==e?0:e.length;if(!o)return-1;var r=null==n?0:pa(n);return r<0&&(r=gn(o+r,0)),kt(e,t,r)},Fn.inRange=function(e,t,n){return t=da(t),n===r?(n=t,t=0):n=da(n),function(e,t,n){return e>=yn(t,n)&&e<gn(t,n)}(e=fa(e),t,n)},Fn.invoke=Ma,Fn.isArguments=Us,Fn.isArray=Vs,Fn.isArrayBuffer=js,Fn.isArrayLike=qs,Fn.isArrayLikeObject=Ws,Fn.isBoolean=function(e){return!0===e||!1===e||ea(e)&&To(e)==y},Fn.isBuffer=zs,Fn.isDate=Ys,Fn.isElement=function(e){return ea(e)&&1===e.nodeType&&!oa(e)},Fn.isEmpty=function(e){if(null==e)return!0;if(qs(e)&&(Vs(e)||"string"==typeof e||"function"==typeof e.splice||zs(e)||la(e)||Us(e)))return!e.length;var t=di(e);if(t==w||t==N)return!e.size;if(xi(e))return!$o(e).length;for(var n in e)if(Oe.call(e,n))return!1;return!0},Fn.isEqual=function(e,t){return _o(e,t)},Fn.isEqualWith=function(e,t,n){var o=(n="function"==typeof n?n:r)?n(e,t):r;return o===r?_o(e,t,r,n):!!o},Fn.isError=Ks,Fn.isFinite=function(e){return"number"==typeof e&&Dt(e)},Fn.isFunction=Qs,Fn.isInteger=Js,Fn.isLength=Xs,Fn.isMap=ta,Fn.isMatch=function(e,t){return e===t||Lo(e,t,li(t))},Fn.isMatchWith=function(e,t,n){return n="function"==typeof n?n:r,Lo(e,t,li(t),n)},Fn.isNaN=function(e){return na(e)&&e!=+e},Fn.isNative=function(e){if(Ci(e))throw new xe("Unsupported core-js use. Try https://npms.io/search?q=ponyfill.");return Oo(e)},Fn.isNil=function(e){return null==e},Fn.isNull=function(e){return null===e},Fn.isNumber=na,Fn.isObject=Zs,Fn.isObjectLike=ea,Fn.isPlainObject=oa,Fn.isRegExp=ra,Fn.isSafeInteger=function(e){return Js(e)&&e>=-9007199254740991&&e<=h},Fn.isSet=ia,Fn.isString=sa,Fn.isSymbol=aa,Fn.isTypedArray=la,Fn.isUndefined=function(e){return e===r},Fn.isWeakMap=function(e){return ea(e)&&di(e)==P},Fn.isWeakSet=function(e){return ea(e)&&"[object WeakSet]"==To(e)},Fn.join=function(e,t){return null==e?"":jt.call(e,t)},Fn.kebabCase=Va,Fn.last=Ki,Fn.lastIndexOf=function(e,t,n){var o=null==e?0:e.length;if(!o)return-1;var i=o;return n!==r&&(i=(i=pa(n))<0?gn(o+i,0):yn(i,o-1)),t==t?function(e,t,n){for(var o=n+1;o--;)if(e[o]===t)return o;return o}(e,t,i):Ft(e,Gt,i,!0)},Fn.lowerCase=ja,Fn.lowerFirst=qa,Fn.lt=ca,Fn.lte=ua,Fn.max=function(e){return e&&e.length?mo(e,nl,Eo):r},Fn.maxBy=function(e,t){return e&&e.length?mo(e,si(t,2),Eo):r},Fn.mean=function(e){return Ut(e,nl)},Fn.meanBy=function(e,t){return Ut(e,si(t,2))},Fn.min=function(e){return e&&e.length?mo(e,nl,Do):r},Fn.minBy=function(e,t){return e&&e.length?mo(e,si(t,2),Do):r},Fn.stubArray=ml,Fn.stubFalse=fl,Fn.stubObject=function(){return{}},Fn.stubString=function(){return""},Fn.stubTrue=function(){return!0},Fn.multiply=xl,Fn.nth=function(e,t){return e&&e.length?Go(e,pa(t)):r},Fn.noConflict=function(){return ht._===this&&(ht._=Fe),this},Fn.noop=al,Fn.now=Es,Fn.pad=function(e,t,n){e=ya(e);var o=(t=pa(t))?un(e):0;if(!t||o>=t)return e;var r=(t-o)/2;return Ur(pt(r),n)+e+Ur(dt(r),n)},Fn.padEnd=function(e,t,n){e=ya(e);var o=(t=pa(t))?un(e):0;return t&&o<t?e+Ur(t-o,n):e},Fn.padStart=function(e,t,n){e=ya(e);var o=(t=pa(t))?un(e):0;return t&&o<t?Ur(t-o,n)+e:e},Fn.parseInt=function(e,t,n){return n||null==t?t=0:t&&(t=+t),vn(ya(e).replace(oe,""),t||0)},Fn.random=function(e,t,n){if(n&&"boolean"!=typeof n&&yi(e,t,n)&&(t=n=r),n===r&&("boolean"==typeof t?(n=t,t=r):"boolean"==typeof e&&(n=e,e=r)),e===r&&t===r?(e=0,t=1):(e=da(e),t===r?(t=e,e=0):t=da(t)),e>t){var o=e;e=t,t=o}if(n||e%1||t%1){var i=Cn();return yn(e+i*(t-e+at("1e-"+((i+"").length-1))),t)}return Wo(e,t)},Fn.reduce=function(e,t,n){var o=Vs(e)?Ot:qt,r=arguments.length<3;return o(e,si(t,4),n,r,uo)},Fn.reduceRight=function(e,t,n){var o=Vs(e)?Rt:qt,r=arguments.length<3;return o(e,si(t,4),n,r,ho)},Fn.repeat=function(e,t,n){return t=(n?yi(e,t,n):t===r)?1:pa(t),zo(ya(e),t)},Fn.replace=function(){var e=arguments,t=ya(e[0]);return e.length<3?t:t.replace(e[1],e[2])},Fn.result=function(e,t,n){var o=-1,i=(t=yr(t,e)).length;for(i||(i=1,e=r);++o<i;){var s=null==e?r:e[Di(t[o])];s===r&&(o=i,s=n),e=Qs(s)?s.call(e):s}return e},Fn.round=wl,Fn.runInContext=e,Fn.sample=function(e){return(Vs(e)?Kn:Ko)(e)},Fn.size=function(e){if(null==e)return 0;if(qs(e))return sa(e)?un(e):e.length;var t=di(e);return t==w||t==N?e.size:$o(e).length},Fn.snakeCase=Wa,Fn.some=function(e,t,n){var o=Vs(e)?$t:nr;return n&&yi(e,t,n)&&(t=r),o(e,si(t,3))},Fn.sortedIndex=function(e,t){return or(e,t)},Fn.sortedIndexBy=function(e,t,n){return rr(e,t,si(n,2))},Fn.sortedIndexOf=function(e,t){var n=null==e?0:e.length;if(n){var o=or(e,t);if(o<n&&ks(e[o],t))return o}return-1},Fn.sortedLastIndex=function(e,t){return or(e,t,!0)},Fn.sortedLastIndexBy=function(e,t,n){return rr(e,t,si(n,2),!0)},Fn.sortedLastIndexOf=function(e,t){if(null!=e&&e.length){var n=or(e,t,!0)-1;if(ks(e[n],t))return n}return-1},Fn.startCase=za,Fn.startsWith=function(e,t,n){return e=ya(e),n=null==n?0:io(pa(n),0,e.length),t=ar(t),e.slice(n,n+t.length)==t},Fn.subtract=Al,Fn.sum=function(e){return e&&e.length?Wt(e,nl):0},Fn.sumBy=function(e,t){return e&&e.length?Wt(e,si(t,2)):0},Fn.template=function(e,t,n){var o=Fn.templateSettings;n&&yi(e,t,n)&&(t=r),e=ya(e),t=Ca({},t,o,Qr);var i,s,a=Ca({},t.imports,o.imports,Qr),l=Pa(a),c=Qt(a,l),u=0,h=t.interpolate||ve,d="__p += '",p=Ee((t.escape||ve).source+"|"+h.source+"|"+(h===J?he:ve).source+"|"+(t.evaluate||ve).source+"|$","g"),m="//# sourceURL="+(Oe.call(t,"sourceURL")?(t.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++ot+"]")+"\n";e.replace(p,(function(t,n,o,r,a,l){return o||(o=r),d+=e.slice(u,l).replace(Ce,nn),n&&(i=!0,d+="' +\n__e("+n+") +\n'"),a&&(s=!0,d+="';\n"+a+";\n__p += '"),o&&(d+="' +\n((__t = ("+o+")) == null ? '' : __t) +\n'"),u=l+t.length,t})),d+="';\n";var f=Oe.call(t,"variable")&&t.variable;if(f){if(ce.test(f))throw new xe("Invalid `variable` option passed into `_.template`")}else d="with (obj) {\n"+d+"\n}\n";d=(s?d.replace(U,""):d).replace(V,"$1").replace(j,"$1;"),d="function("+(f||"obj")+") {\n"+(f?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(i?", __e = _.escape":"")+(s?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+d+"return __p\n}";var g=Ja((function(){return we(l,m+"return "+d).apply(r,c)}));if(g.source=d,Ks(g))throw g;return g},Fn.times=function(e,t){if((e=pa(e))<1||e>h)return[];var n=p,o=yn(e,p);t=si(t),e-=p;for(var r=zt(o,t);++n<e;)t(n);return r},Fn.toFinite=da,Fn.toInteger=pa,Fn.toLength=ma,Fn.toLower=function(e){return ya(e).toLowerCase()},Fn.toNumber=fa,Fn.toSafeInteger=function(e){return e?io(pa(e),-9007199254740991,h):0===e?e:0},Fn.toString=ya,Fn.toUpper=function(e){return ya(e).toUpperCase()},Fn.trim=function(e,t,n){if((e=ya(e))&&(n||t===r))return Yt(e);if(!e||!(t=ar(t)))return e;var o=hn(e),i=hn(t);return vr(o,Xt(o,i),Zt(o,i)+1).join("")},Fn.trimEnd=function(e,t,n){if((e=ya(e))&&(n||t===r))return e.slice(0,dn(e)+1);if(!e||!(t=ar(t)))return e;var o=hn(e);return vr(o,0,Zt(o,hn(t))+1).join("")},Fn.trimStart=function(e,t,n){if((e=ya(e))&&(n||t===r))return e.replace(oe,"");if(!e||!(t=ar(t)))return e;var o=hn(e);return vr(o,Xt(o,hn(t))).join("")},Fn.truncate=function(e,t){var n=30,o="...";if(Zs(t)){var i="separator"in t?t.separator:i;n="length"in t?pa(t.length):n,o="omission"in t?ar(t.omission):o}var s=(e=ya(e)).length;if(on(e)){var a=hn(e);s=a.length}if(n>=s)return e;var l=n-un(o);if(l<1)return o;var c=a?vr(a,0,l).join(""):e.slice(0,l);if(i===r)return c+o;if(a&&(l+=c.length-l),ra(i)){if(e.slice(l).search(i)){var u,h=c;for(i.global||(i=Ee(i.source,ya(de.exec(i))+"g")),i.lastIndex=0;u=i.exec(h);)var d=u.index;c=c.slice(0,d===r?l:d)}}else if(e.indexOf(ar(i),l)!=l){var p=c.lastIndexOf(i);p>-1&&(c=c.slice(0,p))}return c+o},Fn.unescape=function(e){return(e=ya(e))&&z.test(e)?e.replace(q,pn):e},Fn.uniqueId=function(e){var t=++Re;return ya(e)+t},Fn.upperCase=Ya,Fn.upperFirst=Ka,Fn.each=ys,Fn.eachRight=bs,Fn.first=qi,sl(Fn,(gl={},vo(Fn,(function(e,t){Oe.call(Fn.prototype,t)||(gl[t]=e)})),gl),{chain:!1}),Fn.VERSION="4.17.21",Et(["bind","bindKey","curry","curryRight","partial","partialRight"],(function(e){Fn[e].placeholder=Fn})),Et(["drop","take"],(function(e,t){Un.prototype[e]=function(n){n=n===r?1:gn(pa(n),0);var o=this.__filtered__&&!t?new Un(this):this.clone();return o.__filtered__?o.__takeCount__=yn(n,o.__takeCount__):o.__views__.push({size:yn(n,p),type:e+(o.__dir__<0?"Right":"")}),o},Un.prototype[e+"Right"]=function(t){return this.reverse()[e](t).reverse()}})),Et(["filter","map","takeWhile"],(function(e,t){var n=t+1,o=1==n||3==n;Un.prototype[e]=function(e){var t=this.clone();return t.__iteratees__.push({iteratee:si(e,3),type:n}),t.__filtered__=t.__filtered__||o,t}})),Et(["head","last"],(function(e,t){var n="take"+(t?"Right":"");Un.prototype[e]=function(){return this[n](1).value()[0]}})),Et(["initial","tail"],(function(e,t){var n="drop"+(t?"":"Right");Un.prototype[e]=function(){return this.__filtered__?new Un(this):this[n](1)}})),Un.prototype.compact=function(){return this.filter(nl)},Un.prototype.find=function(e){return this.filter(e).head()},Un.prototype.findLast=function(e){return this.reverse().find(e)},Un.prototype.invokeMap=Yo((function(e,t){return"function"==typeof e?new Un(this):this.map((function(n){return Mo(n,e,t)}))})),Un.prototype.reject=function(e){return this.filter(Rs(si(e)))},Un.prototype.slice=function(e,t){e=pa(e);var n=this;return n.__filtered__&&(e>0||t<0)?new Un(n):(e<0?n=n.takeRight(-e):e&&(n=n.drop(e)),t!==r&&(n=(t=pa(t))<0?n.dropRight(-t):n.take(t-e)),n)},Un.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},Un.prototype.toArray=function(){return this.take(p)},vo(Un.prototype,(function(e,t){var n=/^(?:filter|find|map|reject)|While$/.test(t),o=/^(?:head|last)$/.test(t),i=Fn[o?"take"+("last"==t?"Right":""):t],s=o||/^find/.test(t);i&&(Fn.prototype[t]=function(){var t=this.__wrapped__,a=o?[1]:arguments,l=t instanceof Un,c=a[0],u=l||Vs(t),h=function(e){var t=i.apply(Fn,Lt([e],a));return o&&d?t[0]:t};u&&n&&"function"==typeof c&&1!=c.length&&(l=u=!1);var d=this.__chain__,p=!!this.__actions__.length,m=s&&!d,f=l&&!p;if(!s&&u){t=f?t:new Un(this);var g=e.apply(t,a);return g.__actions__.push({func:ds,args:[h],thisArg:r}),new Gn(g,d)}return m&&f?e.apply(this,a):(g=this.thru(h),m?o?g.value()[0]:g.value():g)})})),Et(["pop","push","shift","sort","splice","unshift"],(function(e){var t=Ie[e],n=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",o=/^(?:pop|shift)$/.test(e);Fn.prototype[e]=function(){var e=arguments;if(o&&!this.__chain__){var r=this.value();return t.apply(Vs(r)?r:[],e)}return this[n]((function(n){return t.apply(Vs(n)?n:[],e)}))}})),vo(Un.prototype,(function(e,t){var n=Fn[t];if(n){var o=n.name+"";Oe.call(Mn,o)||(Mn[o]=[]),Mn[o].push({name:t,func:n})}})),Mn[Fr(r,2).name]=[{name:"wrapper",func:r}],Un.prototype.clone=function(){var e=new Un(this.__wrapped__);return e.__actions__=Nr(this.__actions__),e.__dir__=this.__dir__,e.__filtered__=this.__filtered__,e.__iteratees__=Nr(this.__iteratees__),e.__takeCount__=this.__takeCount__,e.__views__=Nr(this.__views__),e},Un.prototype.reverse=function(){if(this.__filtered__){var e=new Un(this);e.__dir__=-1,e.__filtered__=!0}else(e=this.clone()).__dir__*=-1;return e},Un.prototype.value=function(){var e=this.__wrapped__.value(),t=this.__dir__,n=Vs(e),o=t<0,r=n?e.length:0,i=function(e,t,n){for(var o=-1,r=n.length;++o<r;){var i=n[o],s=i.size;switch(i.type){case"drop":e+=s;break;case"dropRight":t-=s;break;case"take":t=yn(t,e+s);break;case"takeRight":e=gn(e,t-s)}}return{start:e,end:t}}(0,r,this.__views__),s=i.start,a=i.end,l=a-s,c=o?a:s-1,u=this.__iteratees__,h=u.length,d=0,p=yn(l,this.__takeCount__);if(!n||!o&&r==l&&p==l)return dr(e,this.__actions__);var m=[];e:for(;l--&&d<p;){for(var f=-1,g=e[c+=t];++f<h;){var y=u[f],b=y.iteratee,v=y.type,C=b(g);if(2==v)g=C;else if(!C){if(1==v)continue e;break e}}m[d++]=g}return m},Fn.prototype.at=ps,Fn.prototype.chain=function(){return hs(this)},Fn.prototype.commit=function(){return new Gn(this.value(),this.__chain__)},Fn.prototype.next=function(){this.__values__===r&&(this.__values__=ha(this.value()));var e=this.__index__>=this.__values__.length;return{done:e,value:e?r:this.__values__[this.__index__++]}},Fn.prototype.plant=function(e){for(var t,n=this;n instanceof Hn;){var o=Fi(n);o.__index__=0,o.__values__=r,t?i.__wrapped__=o:t=o;var i=o;n=n.__wrapped__}return i.__wrapped__=e,t},Fn.prototype.reverse=function(){var e=this.__wrapped__;if(e instanceof Un){var t=e;return this.__actions__.length&&(t=new Un(this)),(t=t.reverse()).__actions__.push({func:ds,args:[Zi],thisArg:r}),new Gn(t,this.__chain__)}return this.thru(Zi)},Fn.prototype.toJSON=Fn.prototype.valueOf=Fn.prototype.value=function(){return dr(this.__wrapped__,this.__actions__)},Fn.prototype.first=Fn.prototype.head,Ke&&(Fn.prototype[Ke]=function(){return this}),Fn}();ht._=mn,(o=function(){return mn}.call(t,n,t,e))===r||(e.exports=o)}.call(this)},4802:e=>{e.exports=function e(t,n,o){function r(s,a){if(!n[s]){if(!t[s]){if(i)return i(s,!0);throw new Error("Cannot find module '"+s+"'")}a=n[s]={exports:{}},t[s][0].call(a.exports,(function(e){return r(t[s][1][e]||e)}),a,a.exports,e,t,n,o)}return n[s].exports}for(var i=void 0,s=0;s<o.length;s++)r(o[s]);return r}({1:[function(e,t,n){(function(o,r,i,s,a,l,c,u,h){"use strict";var d=e("crypto");function p(e,t){var n;return void 0===(n="passthrough"!==(t=g(e,t)).algorithm?d.createHash(t.algorithm):new v).write&&(n.write=n.update,n.end=n.update),b(t,n).dispatch(e),n.update||n.end(""),n.digest?n.digest("buffer"===t.encoding?void 0:t.encoding):(e=n.read(),"buffer"!==t.encoding?e.toString(t.encoding):e)}(n=t.exports=p).sha1=function(e){return p(e)},n.keys=function(e){return p(e,{excludeValues:!0,algorithm:"sha1",encoding:"hex"})},n.MD5=function(e){return p(e,{algorithm:"md5",encoding:"hex"})},n.keysMD5=function(e){return p(e,{algorithm:"md5",encoding:"hex",excludeValues:!0})};var m=d.getHashes?d.getHashes().slice():["sha1","md5"],f=(m.push("passthrough"),["buffer","hex","binary","base64"]);function g(e,t){var n={};if(n.algorithm=(t=t||{}).algorithm||"sha1",n.encoding=t.encoding||"hex",n.excludeValues=!!t.excludeValues,n.algorithm=n.algorithm.toLowerCase(),n.encoding=n.encoding.toLowerCase(),n.ignoreUnknown=!0===t.ignoreUnknown,n.respectType=!1!==t.respectType,n.respectFunctionNames=!1!==t.respectFunctionNames,n.respectFunctionProperties=!1!==t.respectFunctionProperties,n.unorderedArrays=!0===t.unorderedArrays,n.unorderedSets=!1!==t.unorderedSets,n.unorderedObjects=!1!==t.unorderedObjects,n.replacer=t.replacer||void 0,n.excludeKeys=t.excludeKeys||void 0,void 0===e)throw new Error("Object argument required.");for(var o=0;o<m.length;++o)m[o].toLowerCase()===n.algorithm.toLowerCase()&&(n.algorithm=m[o]);if(-1===m.indexOf(n.algorithm))throw new Error('Algorithm "'+n.algorithm+'" not supported. supported values: '+m.join(", "));if(-1===f.indexOf(n.encoding)&&"passthrough"!==n.algorithm)throw new Error('Encoding "'+n.encoding+'" not supported. supported values: '+f.join(", "));return n}function y(e){if("function"==typeof e)return null!=/^function\s+\w*\s*\(\s*\)\s*{\s+\[native code\]\s+}$/i.exec(Function.prototype.toString.call(e))}function b(e,t,n){function o(e){return t.update?t.update(e,"utf8"):t.write(e,"utf8")}return n=n||[],{dispatch:function(t){return this["_"+(null===(t=e.replacer?e.replacer(t):t)?"null":typeof t)](t)},_object:function(t){var r,s=Object.prototype.toString.call(t),a=/\[object (.*)\]/i.exec(s);if(a=(a=a?a[1]:"unknown:["+s+"]").toLowerCase(),0<=(s=n.indexOf(t)))return this.dispatch("[CIRCULAR:"+s+"]");if(n.push(t),void 0!==i&&i.isBuffer&&i.isBuffer(t))return o("buffer:"),o(t);if("object"===a||"function"===a||"asyncfunction"===a)return s=Object.keys(t),e.unorderedObjects&&(s=s.sort()),!1===e.respectType||y(t)||s.splice(0,0,"prototype","__proto__","constructor"),e.excludeKeys&&(s=s.filter((function(t){return!e.excludeKeys(t)}))),o("object:"+s.length+":"),r=this,s.forEach((function(n){r.dispatch(n),o(":"),e.excludeValues||r.dispatch(t[n]),o(",")}));if(!this["_"+a]){if(e.ignoreUnknown)return o("["+a+"]");throw new Error('Unknown object type "'+a+'"')}this["_"+a](t)},_array:function(t,r){r=void 0!==r?r:!1!==e.unorderedArrays;var i=this;if(o("array:"+t.length+":"),!r||t.length<=1)return t.forEach((function(e){return i.dispatch(e)}));var s=[];return r=t.map((function(t){var o=new v,r=n.slice();return b(e,o,r).dispatch(t),s=s.concat(r.slice(n.length)),o.read().toString()})),n=n.concat(s),r.sort(),this._array(r,!1)},_date:function(e){return o("date:"+e.toJSON())},_symbol:function(e){return o("symbol:"+e.toString())},_error:function(e){return o("error:"+e.toString())},_boolean:function(e){return o("bool:"+e.toString())},_string:function(e){o("string:"+e.length+":"),o(e.toString())},_function:function(t){o("fn:"),y(t)?this.dispatch("[native]"):this.dispatch(t.toString()),!1!==e.respectFunctionNames&&this.dispatch("function-name:"+String(t.name)),e.respectFunctionProperties&&this._object(t)},_number:function(e){return o("number:"+e.toString())},_xml:function(e){return o("xml:"+e.toString())},_null:function(){return o("Null")},_undefined:function(){return o("Undefined")},_regexp:function(e){return o("regex:"+e.toString())},_uint8array:function(e){return o("uint8array:"),this.dispatch(Array.prototype.slice.call(e))},_uint8clampedarray:function(e){return o("uint8clampedarray:"),this.dispatch(Array.prototype.slice.call(e))},_int8array:function(e){return o("int8array:"),this.dispatch(Array.prototype.slice.call(e))},_uint16array:function(e){return o("uint16array:"),this.dispatch(Array.prototype.slice.call(e))},_int16array:function(e){return o("int16array:"),this.dispatch(Array.prototype.slice.call(e))},_uint32array:function(e){return o("uint32array:"),this.dispatch(Array.prototype.slice.call(e))},_int32array:function(e){return o("int32array:"),this.dispatch(Array.prototype.slice.call(e))},_float32array:function(e){return o("float32array:"),this.dispatch(Array.prototype.slice.call(e))},_float64array:function(e){return o("float64array:"),this.dispatch(Array.prototype.slice.call(e))},_arraybuffer:function(e){return o("arraybuffer:"),this.dispatch(new Uint8Array(e))},_url:function(e){return o("url:"+e.toString())},_map:function(t){return o("map:"),t=Array.from(t),this._array(t,!1!==e.unorderedSets)},_set:function(t){return o("set:"),t=Array.from(t),this._array(t,!1!==e.unorderedSets)},_file:function(e){return o("file:"),this.dispatch([e.name,e.size,e.type,e.lastModfied])},_blob:function(){if(e.ignoreUnknown)return o("[blob]");throw Error('Hashing Blob objects is currently not supported\n(see https://github.com/puleos/object-hash/issues/26)\nUse "options.replacer" or "options.ignoreUnknown"\n')},_domwindow:function(){return o("domwindow")},_bigint:function(e){return o("bigint:"+e.toString())},_process:function(){return o("process")},_timer:function(){return o("timer")},_pipe:function(){return o("pipe")},_tcp:function(){return o("tcp")},_udp:function(){return o("udp")},_tty:function(){return o("tty")},_statwatcher:function(){return o("statwatcher")},_securecontext:function(){return o("securecontext")},_connection:function(){return o("connection")},_zlib:function(){return o("zlib")},_context:function(){return o("context")},_nodescript:function(){return o("nodescript")},_httpparser:function(){return o("httpparser")},_dataview:function(){return o("dataview")},_signal:function(){return o("signal")},_fsevent:function(){return o("fsevent")},_tlswrap:function(){return o("tlswrap")}}}function v(){return{buf:"",write:function(e){this.buf+=e},end:function(e){this.buf+=e},read:function(){return this.buf}}}n.writeToStream=function(e,t,n){return void 0===n&&(n=t,t={}),b(t=g(e,t),n).dispatch(e)}}).call(this,e("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/fake_9a5aa49d.js","/")},{buffer:3,crypto:5,lYpoI2:11}],2:[function(e,t,n){(function(e,t,o,r,i,s,a,l,c){!function(e){"use strict";var t="undefined"!=typeof Uint8Array?Uint8Array:Array,n="+".charCodeAt(0),o="/".charCodeAt(0),r="0".charCodeAt(0),i="a".charCodeAt(0),s="A".charCodeAt(0),a="-".charCodeAt(0),l="_".charCodeAt(0);function c(e){return(e=e.charCodeAt(0))===n||e===a?62:e===o||e===l?63:e<r?-1:e<r+10?e-r+26+26:e<s+26?e-s:e<i+26?e-i+26:void 0}e.toByteArray=function(e){var n,o;if(0<e.length%4)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.length,i=(r="="===e.charAt(r-2)?2:"="===e.charAt(r-1)?1:0,new t(3*e.length/4-r)),s=0<r?e.length-4:e.length,a=0;function l(e){i[a++]=e}for(n=0;n<s;n+=4,0)l((16711680&(o=c(e.charAt(n))<<18|c(e.charAt(n+1))<<12|c(e.charAt(n+2))<<6|c(e.charAt(n+3))))>>16),l((65280&o)>>8),l(255&o);return 2==r?l(255&(o=c(e.charAt(n))<<2|c(e.charAt(n+1))>>4)):1==r&&(l((o=c(e.charAt(n))<<10|c(e.charAt(n+1))<<4|c(e.charAt(n+2))>>2)>>8&255),l(255&o)),i},e.fromByteArray=function(e){var t,n,o,r,i=e.length%3,s="";function a(e){return"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(e)}for(t=0,o=e.length-i;t<o;t+=3)s+=a((r=n=(e[t]<<16)+(e[t+1]<<8)+e[t+2])>>18&63)+a(r>>12&63)+a(r>>6&63)+a(63&r);switch(i){case 1:s=(s+=a((n=e[e.length-1])>>2))+a(n<<4&63)+"==";break;case 2:s=(s=(s+=a((n=(e[e.length-2]<<8)+e[e.length-1])>>10))+a(n>>4&63))+a(n<<2&63)+"="}return s}}(void 0===n?this.base64js={}:n)}).call(this,e("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/base64-js/lib/b64.js","/node_modules/gulp-browserify/node_modules/base64-js/lib")},{buffer:3,lYpoI2:11}],3:[function(e,t,n){(function(t,o,r,i,s,a,l,c,u){var h=e("base64-js"),d=e("ieee754");function r(e,t,n){if(!(this instanceof r))return new r(e,t,n);var o,i,s,a,l=typeof e;if("base64"===t&&"string"==l)for(e=(a=e).trim?a.trim():a.replace(/^\s+|\s+$/g,"");e.length%4!=0;)e+="=";if("number"==l)o=N(e);else if("string"==l)o=r.byteLength(e,t);else{if("object"!=l)throw new Error("First argument needs to be a number, array or string.");o=N(e.length)}if(r._useTypedArrays?i=r._augment(new Uint8Array(o)):((i=this).length=o,i._isBuffer=!0),r._useTypedArrays&&"number"==typeof e.byteLength)i._set(e);else if(I(a=e)||r.isBuffer(a)||a&&"object"==typeof a&&"number"==typeof a.length)for(s=0;s<o;s++)r.isBuffer(e)?i[s]=e.readUInt8(s):i[s]=e[s];else if("string"==l)i.write(e,0,t);else if("number"==l&&!r._useTypedArrays&&!n)for(s=0;s<o;s++)i[s]=0;return i}function p(e,t,n,o){var r;if(o||(B("boolean"==typeof n,"missing or invalid endian"),B(null!=t,"missing offset"),B(t+1<e.length,"Trying to read beyond buffer length")),!((o=e.length)<=t))return n?(r=e[t],t+1<o&&(r|=e[t+1]<<8)):(r=e[t]<<8,t+1<o&&(r|=e[t+1])),r}function m(e,t,n,o){var r;if(o||(B("boolean"==typeof n,"missing or invalid endian"),B(null!=t,"missing offset"),B(t+3<e.length,"Trying to read beyond buffer length")),!((o=e.length)<=t))return n?(t+2<o&&(r=e[t+2]<<16),t+1<o&&(r|=e[t+1]<<8),r|=e[t],t+3<o&&(r+=e[t+3]<<24>>>0)):(t+1<o&&(r=e[t+1]<<16),t+2<o&&(r|=e[t+2]<<8),t+3<o&&(r|=e[t+3]),r+=e[t]<<24>>>0),r}function f(e,t,n,o){if(o||(B("boolean"==typeof n,"missing or invalid endian"),B(null!=t,"missing offset"),B(t+1<e.length,"Trying to read beyond buffer length")),!(e.length<=t))return 32768&(o=p(e,t,n,!0))?-1*(65535-o+1):o}function g(e,t,n,o){if(o||(B("boolean"==typeof n,"missing or invalid endian"),B(null!=t,"missing offset"),B(t+3<e.length,"Trying to read beyond buffer length")),!(e.length<=t))return 2147483648&(o=m(e,t,n,!0))?-1*(4294967295-o+1):o}function y(e,t,n,o){return o||(B("boolean"==typeof n,"missing or invalid endian"),B(t+3<e.length,"Trying to read beyond buffer length")),d.read(e,t,n,23,4)}function b(e,t,n,o){return o||(B("boolean"==typeof n,"missing or invalid endian"),B(t+7<e.length,"Trying to read beyond buffer length")),d.read(e,t,n,52,8)}function v(e,t,n,o,r){if(r||(B(null!=t,"missing value"),B("boolean"==typeof o,"missing or invalid endian"),B(null!=n,"missing offset"),B(n+1<e.length,"trying to write beyond buffer length"),R(t,65535)),!((r=e.length)<=n))for(var i=0,s=Math.min(r-n,2);i<s;i++)e[n+i]=(t&255<<8*(o?i:1-i))>>>8*(o?i:1-i)}function C(e,t,n,o,r){if(r||(B(null!=t,"missing value"),B("boolean"==typeof o,"missing or invalid endian"),B(null!=n,"missing offset"),B(n+3<e.length,"trying to write beyond buffer length"),R(t,4294967295)),!((r=e.length)<=n))for(var i=0,s=Math.min(r-n,4);i<s;i++)e[n+i]=t>>>8*(o?i:3-i)&255}function x(e,t,n,o,r){r||(B(null!=t,"missing value"),B("boolean"==typeof o,"missing or invalid endian"),B(null!=n,"missing offset"),B(n+1<e.length,"Trying to write beyond buffer length"),$(t,32767,-32768)),e.length<=n||v(e,0<=t?t:65535+t+1,n,o,r)}function w(e,t,n,o,r){r||(B(null!=t,"missing value"),B("boolean"==typeof o,"missing or invalid endian"),B(null!=n,"missing offset"),B(n+3<e.length,"Trying to write beyond buffer length"),$(t,2147483647,-2147483648)),e.length<=n||C(e,0<=t?t:4294967295+t+1,n,o,r)}function A(e,t,n,o,r){r||(B(null!=t,"missing value"),B("boolean"==typeof o,"missing or invalid endian"),B(null!=n,"missing offset"),B(n+3<e.length,"Trying to write beyond buffer length"),D(t,34028234663852886e22,-34028234663852886e22)),e.length<=n||d.write(e,t,n,o,23,4)}function T(e,t,n,o,r){r||(B(null!=t,"missing value"),B("boolean"==typeof o,"missing or invalid endian"),B(null!=n,"missing offset"),B(n+7<e.length,"Trying to write beyond buffer length"),D(t,17976931348623157e292,-17976931348623157e292)),e.length<=n||d.write(e,t,n,o,52,8)}n.Buffer=r,n.SlowBuffer=r,n.INSPECT_MAX_BYTES=50,r.poolSize=8192,r._useTypedArrays=function(){try{var e=new ArrayBuffer(0),t=new Uint8Array(e);return t.foo=function(){return 42},42===t.foo()&&"function"==typeof t.subarray}catch(e){return!1}}(),r.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},r.isBuffer=function(e){return!(null==e||!e._isBuffer)},r.byteLength=function(e,t){var n;switch(e+="",t||"utf8"){case"hex":n=e.length/2;break;case"utf8":case"utf-8":n=P(e).length;break;case"ascii":case"binary":case"raw":n=e.length;break;case"base64":n=_(e).length;break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":n=2*e.length;break;default:throw new Error("Unknown encoding")}return n},r.concat=function(e,t){if(B(I(e),"Usage: Buffer.concat(list, [totalLength])\nlist should be an Array."),0===e.length)return new r(0);if(1===e.length)return e[0];if("number"!=typeof t)for(i=t=0;i<e.length;i++)t+=e[i].length;for(var n=new r(t),o=0,i=0;i<e.length;i++){var s=e[i];s.copy(n,o),o+=s.length}return n},r.prototype.write=function(e,t,n,o){isFinite(t)?isFinite(n)||(o=n,n=void 0):(c=o,o=t,t=n,n=c),t=Number(t)||0;var i,s,a,l,c=this.length-t;switch((!n||c<(n=Number(n)))&&(n=c),o=String(o||"utf8").toLowerCase()){case"hex":i=function(e,t,n,o){n=Number(n)||0;var i=e.length-n;(!o||i<(o=Number(o)))&&(o=i),B((i=t.length)%2==0,"Invalid hex string"),i/2<o&&(o=i/2);for(var s=0;s<o;s++){var a=parseInt(t.substr(2*s,2),16);B(!isNaN(a),"Invalid hex string"),e[n+s]=a}return r._charsWritten=2*s,s}(this,e,t,n);break;case"utf8":case"utf-8":s=this,a=t,l=n,i=r._charsWritten=L(P(e),s,a,l);break;case"ascii":case"binary":i=function(e,t,n,o){return r._charsWritten=L(function(e){for(var t=[],n=0;n<e.length;n++)t.push(255&e.charCodeAt(n));return t}(t),e,n,o)}(this,e,t,n);break;case"base64":s=this,a=t,l=n,i=r._charsWritten=L(_(e),s,a,l);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":i=function(e,t,n,o){return r._charsWritten=L(function(e){for(var t,n,o=[],r=0;r<e.length;r++)t=(n=e.charCodeAt(r))>>8,n%=256,o.push(n),o.push(t);return o}(t),e,n,o)}(this,e,t,n);break;default:throw new Error("Unknown encoding")}return i},r.prototype.toString=function(e,t,n){var o,r,i,s,a=this;if(e=String(e||"utf8").toLowerCase(),t=Number(t)||0,(n=void 0!==n?Number(n):a.length)===t)return"";switch(e){case"hex":o=function(e,t,n){var o=e.length;(!t||t<0)&&(t=0),(!n||n<0||o<n)&&(n=o);for(var r="",i=t;i<n;i++)r+=M(e[i]);return r}(a,t,n);break;case"utf8":case"utf-8":o=function(e,t,n){var o="",r="";n=Math.min(e.length,n);for(var i=t;i<n;i++)e[i]<=127?(o+=O(r)+String.fromCharCode(e[i]),r=""):r+="%"+e[i].toString(16);return o+O(r)}(a,t,n);break;case"ascii":case"binary":o=function(e,t,n){var o="";n=Math.min(e.length,n);for(var r=t;r<n;r++)o+=String.fromCharCode(e[r]);return o}(a,t,n);break;case"base64":r=a,s=n,o=0===(i=t)&&s===r.length?h.fromByteArray(r):h.fromByteArray(r.slice(i,s));break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":o=function(e,t,n){for(var o=e.slice(t,n),r="",i=0;i<o.length;i+=2)r+=String.fromCharCode(o[i]+256*o[i+1]);return r}(a,t,n);break;default:throw new Error("Unknown encoding")}return o},r.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},r.prototype.copy=function(e,t,n,o){if(t=t||0,(o=o||0===o?o:this.length)!==(n=n||0)&&0!==e.length&&0!==this.length){B(n<=o,"sourceEnd < sourceStart"),B(0<=t&&t<e.length,"targetStart out of bounds"),B(0<=n&&n<this.length,"sourceStart out of bounds"),B(0<=o&&o<=this.length,"sourceEnd out of bounds"),o>this.length&&(o=this.length);var i=(o=e.length-t<o-n?e.length-t+n:o)-n;if(i<100||!r._useTypedArrays)for(var s=0;s<i;s++)e[s+t]=this[s+n];else e._set(this.subarray(n,n+i),t)}},r.prototype.slice=function(e,t){var n=this.length;if(e=S(e,n,0),t=S(t,n,n),r._useTypedArrays)return r._augment(this.subarray(e,t));for(var o=t-e,i=new r(o,void 0,!0),s=0;s<o;s++)i[s]=this[s+e];return i},r.prototype.get=function(e){return console.log(".get() is deprecated. Access using array indexes instead."),this.readUInt8(e)},r.prototype.set=function(e,t){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(e,t)},r.prototype.readUInt8=function(e,t){if(t||(B(null!=e,"missing offset"),B(e<this.length,"Trying to read beyond buffer length")),!(e>=this.length))return this[e]},r.prototype.readUInt16LE=function(e,t){return p(this,e,!0,t)},r.prototype.readUInt16BE=function(e,t){return p(this,e,!1,t)},r.prototype.readUInt32LE=function(e,t){return m(this,e,!0,t)},r.prototype.readUInt32BE=function(e,t){return m(this,e,!1,t)},r.prototype.readInt8=function(e,t){if(t||(B(null!=e,"missing offset"),B(e<this.length,"Trying to read beyond buffer length")),!(e>=this.length))return 128&this[e]?-1*(255-this[e]+1):this[e]},r.prototype.readInt16LE=function(e,t){return f(this,e,!0,t)},r.prototype.readInt16BE=function(e,t){return f(this,e,!1,t)},r.prototype.readInt32LE=function(e,t){return g(this,e,!0,t)},r.prototype.readInt32BE=function(e,t){return g(this,e,!1,t)},r.prototype.readFloatLE=function(e,t){return y(this,e,!0,t)},r.prototype.readFloatBE=function(e,t){return y(this,e,!1,t)},r.prototype.readDoubleLE=function(e,t){return b(this,e,!0,t)},r.prototype.readDoubleBE=function(e,t){return b(this,e,!1,t)},r.prototype.writeUInt8=function(e,t,n){n||(B(null!=e,"missing value"),B(null!=t,"missing offset"),B(t<this.length,"trying to write beyond buffer length"),R(e,255)),t>=this.length||(this[t]=e)},r.prototype.writeUInt16LE=function(e,t,n){v(this,e,t,!0,n)},r.prototype.writeUInt16BE=function(e,t,n){v(this,e,t,!1,n)},r.prototype.writeUInt32LE=function(e,t,n){C(this,e,t,!0,n)},r.prototype.writeUInt32BE=function(e,t,n){C(this,e,t,!1,n)},r.prototype.writeInt8=function(e,t,n){n||(B(null!=e,"missing value"),B(null!=t,"missing offset"),B(t<this.length,"Trying to write beyond buffer length"),$(e,127,-128)),t>=this.length||(0<=e?this.writeUInt8(e,t,n):this.writeUInt8(255+e+1,t,n))},r.prototype.writeInt16LE=function(e,t,n){x(this,e,t,!0,n)},r.prototype.writeInt16BE=function(e,t,n){x(this,e,t,!1,n)},r.prototype.writeInt32LE=function(e,t,n){w(this,e,t,!0,n)},r.prototype.writeInt32BE=function(e,t,n){w(this,e,t,!1,n)},r.prototype.writeFloatLE=function(e,t,n){A(this,e,t,!0,n)},r.prototype.writeFloatBE=function(e,t,n){A(this,e,t,!1,n)},r.prototype.writeDoubleLE=function(e,t,n){T(this,e,t,!0,n)},r.prototype.writeDoubleBE=function(e,t,n){T(this,e,t,!1,n)},r.prototype.fill=function(e,t,n){if(t=t||0,n=n||this.length,B("number"==typeof(e="string"==typeof(e=e||0)?e.charCodeAt(0):e)&&!isNaN(e),"value is not a number"),B(t<=n,"end < start"),n!==t&&0!==this.length){B(0<=t&&t<this.length,"start out of bounds"),B(0<=n&&n<=this.length,"end out of bounds");for(var o=t;o<n;o++)this[o]=e}},r.prototype.inspect=function(){for(var e=[],t=this.length,o=0;o<t;o++)if(e[o]=M(this[o]),o===n.INSPECT_MAX_BYTES){e[o+1]="...";break}return"<Buffer "+e.join(" ")+">"},r.prototype.toArrayBuffer=function(){if("undefined"==typeof Uint8Array)throw new Error("Buffer.toArrayBuffer not supported in this browser");if(r._useTypedArrays)return new r(this).buffer;for(var e=new Uint8Array(this.length),t=0,n=e.length;t<n;t+=1)e[t]=this[t];return e.buffer};var E=r.prototype;function S(e,t,n){return"number"!=typeof e?n:t<=(e=~~e)?t:0<=e||0<=(e+=t)?e:0}function N(e){return(e=~~Math.ceil(+e))<0?0:e}function I(e){return(Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)})(e)}function M(e){return e<16?"0"+e.toString(16):e.toString(16)}function P(e){for(var t=[],n=0;n<e.length;n++){var o=e.charCodeAt(n);if(o<=127)t.push(e.charCodeAt(n));else for(var r=n,i=(55296<=o&&o<=57343&&n++,encodeURIComponent(e.slice(r,n+1)).substr(1).split("%")),s=0;s<i.length;s++)t.push(parseInt(i[s],16))}return t}function _(e){return h.toByteArray(e)}function L(e,t,n,o){for(var r=0;r<o&&!(r+n>=t.length||r>=e.length);r++)t[r+n]=e[r];return r}function O(e){try{return decodeURIComponent(e)}catch(e){return String.fromCharCode(65533)}}function R(e,t){B("number"==typeof e,"cannot write a non-number as a number"),B(0<=e,"specified a negative value for writing an unsigned value"),B(e<=t,"value is larger than maximum value for type"),B(Math.floor(e)===e,"value has a fractional component")}function $(e,t,n){B("number"==typeof e,"cannot write a non-number as a number"),B(e<=t,"value larger than maximum allowed value"),B(n<=e,"value smaller than minimum allowed value"),B(Math.floor(e)===e,"value has a fractional component")}function D(e,t,n){B("number"==typeof e,"cannot write a non-number as a number"),B(e<=t,"value larger than maximum allowed value"),B(n<=e,"value smaller than minimum allowed value")}function B(e,t){if(!e)throw new Error(t||"Failed assertion")}r._augment=function(e){return e._isBuffer=!0,e._get=e.get,e._set=e.set,e.get=E.get,e.set=E.set,e.write=E.write,e.toString=E.toString,e.toLocaleString=E.toString,e.toJSON=E.toJSON,e.copy=E.copy,e.slice=E.slice,e.readUInt8=E.readUInt8,e.readUInt16LE=E.readUInt16LE,e.readUInt16BE=E.readUInt16BE,e.readUInt32LE=E.readUInt32LE,e.readUInt32BE=E.readUInt32BE,e.readInt8=E.readInt8,e.readInt16LE=E.readInt16LE,e.readInt16BE=E.readInt16BE,e.readInt32LE=E.readInt32LE,e.readInt32BE=E.readInt32BE,e.readFloatLE=E.readFloatLE,e.readFloatBE=E.readFloatBE,e.readDoubleLE=E.readDoubleLE,e.readDoubleBE=E.readDoubleBE,e.writeUInt8=E.writeUInt8,e.writeUInt16LE=E.writeUInt16LE,e.writeUInt16BE=E.writeUInt16BE,e.writeUInt32LE=E.writeUInt32LE,e.writeUInt32BE=E.writeUInt32BE,e.writeInt8=E.writeInt8,e.writeInt16LE=E.writeInt16LE,e.writeInt16BE=E.writeInt16BE,e.writeInt32LE=E.writeInt32LE,e.writeInt32BE=E.writeInt32BE,e.writeFloatLE=E.writeFloatLE,e.writeFloatBE=E.writeFloatBE,e.writeDoubleLE=E.writeDoubleLE,e.writeDoubleBE=E.writeDoubleBE,e.fill=E.fill,e.inspect=E.inspect,e.toArrayBuffer=E.toArrayBuffer,e}}).call(this,e("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/buffer/index.js","/node_modules/gulp-browserify/node_modules/buffer")},{"base64-js":2,buffer:3,ieee754:10,lYpoI2:11}],4:[function(e,t,n){(function(n,o,r,i,s,a,l,c,u){r=e("buffer").Buffer;var h=new r(4);h.fill(0),t.exports={hash:function(e,t,n,o){for(var i=t(function(e,t){e.length%4!=0&&(n=e.length+(4-e.length%4),e=r.concat([e,h],n));for(var n,o=[],i=t?e.readInt32BE:e.readInt32LE,s=0;s<e.length;s+=4)o.push(i.call(e,s));return o}(e=r.isBuffer(e)?e:new r(e),o),8*e.length),s=(t=o,new r(n)),a=t?s.writeInt32BE:s.writeInt32LE,l=0;l<i.length;l++)a.call(s,i[l],4*l,!0);return s}}}).call(this,e("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/helpers.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{buffer:3,lYpoI2:11}],5:[function(e,t,n){(function(t,o,r,i,s,a,l,c,u){r=e("buffer").Buffer;var h=e("./sha"),d=e("./sha256"),p=e("./rng"),m={sha1:h,sha256:d,md5:e("./md5")},f=64,g=new r(f);function y(e,t){var n=m[e=e||"sha1"],o=[];return n||b("algorithm:",e,"is not yet supported"),{update:function(e){return r.isBuffer(e)||(e=new r(e)),o.push(e),e.length,this},digest:function(e){var i=r.concat(o);return i=t?function(e,t,n){r.isBuffer(t)||(t=new r(t)),r.isBuffer(n)||(n=new r(n)),t.length>f?t=e(t):t.length<f&&(t=r.concat([t,g],f));for(var o=new r(f),i=new r(f),s=0;s<f;s++)o[s]=54^t[s],i[s]=92^t[s];return n=e(r.concat([o,n])),e(r.concat([i,n]))}(n,t,i):n(i),o=null,e?i.toString(e):i}}}function b(){var e=[].slice.call(arguments).join(" ");throw new Error([e,"we accept pull requests","http://github.com/dominictarr/crypto-browserify"].join("\n"))}g.fill(0),n.createHash=function(e){return y(e)},n.createHmac=y,n.randomBytes=function(e,t){if(!t||!t.call)return new r(p(e));try{t.call(this,void 0,new r(p(e)))}catch(e){t(e)}};var v,C=["createCredentials","createCipher","createCipheriv","createDecipher","createDecipheriv","createSign","createVerify","createDiffieHellman","pbkdf2"],x=function(e){n[e]=function(){b("sorry,",e,"is not implemented yet")}};for(v in C)x(C[v])}).call(this,e("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/index.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{"./md5":6,"./rng":7,"./sha":8,"./sha256":9,buffer:3,lYpoI2:11}],6:[function(e,t,n){(function(n,o,r,i,s,a,l,c,u){var h=e("./helpers");function d(e,t){e[t>>5]|=128<<t%32,e[14+(t+64>>>9<<4)]=t;for(var n=1732584193,o=-271733879,r=-1732584194,i=271733878,s=0;s<e.length;s+=16){var a=n,l=o,c=r,u=i;n=m(n,o,r,i,e[s+0],7,-680876936),i=m(i,n,o,r,e[s+1],12,-389564586),r=m(r,i,n,o,e[s+2],17,606105819),o=m(o,r,i,n,e[s+3],22,-1044525330),n=m(n,o,r,i,e[s+4],7,-176418897),i=m(i,n,o,r,e[s+5],12,1200080426),r=m(r,i,n,o,e[s+6],17,-1473231341),o=m(o,r,i,n,e[s+7],22,-45705983),n=m(n,o,r,i,e[s+8],7,1770035416),i=m(i,n,o,r,e[s+9],12,-1958414417),r=m(r,i,n,o,e[s+10],17,-42063),o=m(o,r,i,n,e[s+11],22,-1990404162),n=m(n,o,r,i,e[s+12],7,1804603682),i=m(i,n,o,r,e[s+13],12,-40341101),r=m(r,i,n,o,e[s+14],17,-1502002290),n=f(n,o=m(o,r,i,n,e[s+15],22,1236535329),r,i,e[s+1],5,-165796510),i=f(i,n,o,r,e[s+6],9,-1069501632),r=f(r,i,n,o,e[s+11],14,643717713),o=f(o,r,i,n,e[s+0],20,-373897302),n=f(n,o,r,i,e[s+5],5,-701558691),i=f(i,n,o,r,e[s+10],9,38016083),r=f(r,i,n,o,e[s+15],14,-660478335),o=f(o,r,i,n,e[s+4],20,-405537848),n=f(n,o,r,i,e[s+9],5,568446438),i=f(i,n,o,r,e[s+14],9,-1019803690),r=f(r,i,n,o,e[s+3],14,-187363961),o=f(o,r,i,n,e[s+8],20,1163531501),n=f(n,o,r,i,e[s+13],5,-1444681467),i=f(i,n,o,r,e[s+2],9,-51403784),r=f(r,i,n,o,e[s+7],14,1735328473),n=g(n,o=f(o,r,i,n,e[s+12],20,-1926607734),r,i,e[s+5],4,-378558),i=g(i,n,o,r,e[s+8],11,-2022574463),r=g(r,i,n,o,e[s+11],16,1839030562),o=g(o,r,i,n,e[s+14],23,-35309556),n=g(n,o,r,i,e[s+1],4,-1530992060),i=g(i,n,o,r,e[s+4],11,1272893353),r=g(r,i,n,o,e[s+7],16,-155497632),o=g(o,r,i,n,e[s+10],23,-1094730640),n=g(n,o,r,i,e[s+13],4,681279174),i=g(i,n,o,r,e[s+0],11,-358537222),r=g(r,i,n,o,e[s+3],16,-722521979),o=g(o,r,i,n,e[s+6],23,76029189),n=g(n,o,r,i,e[s+9],4,-640364487),i=g(i,n,o,r,e[s+12],11,-421815835),r=g(r,i,n,o,e[s+15],16,530742520),n=y(n,o=g(o,r,i,n,e[s+2],23,-995338651),r,i,e[s+0],6,-198630844),i=y(i,n,o,r,e[s+7],10,1126891415),r=y(r,i,n,o,e[s+14],15,-1416354905),o=y(o,r,i,n,e[s+5],21,-57434055),n=y(n,o,r,i,e[s+12],6,1700485571),i=y(i,n,o,r,e[s+3],10,-1894986606),r=y(r,i,n,o,e[s+10],15,-1051523),o=y(o,r,i,n,e[s+1],21,-2054922799),n=y(n,o,r,i,e[s+8],6,1873313359),i=y(i,n,o,r,e[s+15],10,-30611744),r=y(r,i,n,o,e[s+6],15,-1560198380),o=y(o,r,i,n,e[s+13],21,1309151649),n=y(n,o,r,i,e[s+4],6,-145523070),i=y(i,n,o,r,e[s+11],10,-1120210379),r=y(r,i,n,o,e[s+2],15,718787259),o=y(o,r,i,n,e[s+9],21,-343485551),n=b(n,a),o=b(o,l),r=b(r,c),i=b(i,u)}return Array(n,o,r,i)}function p(e,t,n,o,r,i){return b((t=b(b(t,e),b(o,i)))<<r|t>>>32-r,n)}function m(e,t,n,o,r,i,s){return p(t&n|~t&o,e,t,r,i,s)}function f(e,t,n,o,r,i,s){return p(t&o|n&~o,e,t,r,i,s)}function g(e,t,n,o,r,i,s){return p(t^n^o,e,t,r,i,s)}function y(e,t,n,o,r,i,s){return p(n^(t|~o),e,t,r,i,s)}function b(e,t){var n=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(n>>16)<<16|65535&n}t.exports=function(e){return h.hash(e,d,16)}}).call(this,e("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/md5.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{"./helpers":4,buffer:3,lYpoI2:11}],7:[function(e,t,n){(function(e,n,o,r,i,s,a,l,c){t.exports=function(e){for(var t,n=new Array(e),o=0;o<e;o++)!(3&o)&&(t=4294967296*Math.random()),n[o]=t>>>((3&o)<<3)&255;return n}}).call(this,e("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/rng.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{buffer:3,lYpoI2:11}],8:[function(e,t,n){(function(n,o,r,i,s,a,l,c,u){var h=e("./helpers");function d(e,t){e[t>>5]|=128<<24-t%32,e[15+(t+64>>9<<4)]=t;for(var n,o,r,i=Array(80),s=1732584193,a=-271733879,l=-1732584194,c=271733878,u=-1009589776,h=0;h<e.length;h+=16){for(var d=s,f=a,g=l,y=c,b=u,v=0;v<80;v++){i[v]=v<16?e[h+v]:m(i[v-3]^i[v-8]^i[v-14]^i[v-16],1);var C=p(p(m(s,5),(C=a,o=l,r=c,(n=v)<20?C&o|~C&r:!(n<40)&&n<60?C&o|C&r|o&r:C^o^r)),p(p(u,i[v]),(n=v)<20?1518500249:n<40?1859775393:n<60?-1894007588:-899497514));u=c,c=l,l=m(a,30),a=s,s=C}s=p(s,d),a=p(a,f),l=p(l,g),c=p(c,y),u=p(u,b)}return Array(s,a,l,c,u)}function p(e,t){var n=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(n>>16)<<16|65535&n}function m(e,t){return e<<t|e>>>32-t}t.exports=function(e){return h.hash(e,d,20,!0)}}).call(this,e("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/sha.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{"./helpers":4,buffer:3,lYpoI2:11}],9:[function(e,t,n){(function(n,o,r,i,s,a,l,c,u){function h(e,t){var n=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(n>>16)<<16|65535&n}function d(e,t){var n,o=new Array(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),r=new Array(1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225),i=new Array(64);e[t>>5]|=128<<24-t%32,e[15+(t+64>>9<<4)]=t;for(var s,a,l=0;l<e.length;l+=16){for(var c=r[0],u=r[1],d=r[2],p=r[3],g=r[4],y=r[5],b=r[6],v=r[7],C=0;C<64;C++)i[C]=C<16?e[C+l]:h(h(h((a=i[C-2],m(a,17)^m(a,19)^f(a,10)),i[C-7]),(a=i[C-15],m(a,7)^m(a,18)^f(a,3))),i[C-16]),n=h(h(h(h(v,m(a=g,6)^m(a,11)^m(a,25)),g&y^~g&b),o[C]),i[C]),s=h(m(s=c,2)^m(s,13)^m(s,22),c&u^c&d^u&d),v=b,b=y,y=g,g=h(p,n),p=d,d=u,u=c,c=h(n,s);r[0]=h(c,r[0]),r[1]=h(u,r[1]),r[2]=h(d,r[2]),r[3]=h(p,r[3]),r[4]=h(g,r[4]),r[5]=h(y,r[5]),r[6]=h(b,r[6]),r[7]=h(v,r[7])}return r}var p=e("./helpers"),m=function(e,t){return e>>>t|e<<32-t},f=function(e,t){return e>>>t};t.exports=function(e){return p.hash(e,d,32,!0)}}).call(this,e("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/sha256.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{"./helpers":4,buffer:3,lYpoI2:11}],10:[function(e,t,n){(function(e,t,o,r,i,s,a,l,c){n.read=function(e,t,n,o,r){var i,s,a=8*r-o-1,l=(1<<a)-1,c=l>>1,u=-7,h=n?r-1:0,d=n?-1:1;for(r=e[t+h],h+=d,i=r&(1<<-u)-1,r>>=-u,u+=a;0<u;i=256*i+e[t+h],h+=d,u-=8);for(s=i&(1<<-u)-1,i>>=-u,u+=o;0<u;s=256*s+e[t+h],h+=d,u-=8);if(0===i)i=1-c;else{if(i===l)return s?NaN:1/0*(r?-1:1);s+=Math.pow(2,o),i-=c}return(r?-1:1)*s*Math.pow(2,i-o)},n.write=function(e,t,n,o,r,i){var s,a,l=8*i-r-1,c=(1<<l)-1,u=c>>1,h=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,d=o?0:i-1,p=o?1:-1;for(i=t<0||0===t&&1/t<0?1:0,t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=c):(s=Math.floor(Math.log(t)/Math.LN2),t*(o=Math.pow(2,-s))<1&&(s--,o*=2),2<=(t+=1<=s+u?h/o:h*Math.pow(2,1-u))*o&&(s++,o/=2),c<=s+u?(a=0,s=c):1<=s+u?(a=(t*o-1)*Math.pow(2,r),s+=u):(a=t*Math.pow(2,u-1)*Math.pow(2,r),s=0));8<=r;e[n+d]=255&a,d+=p,a/=256,r-=8);for(s=s<<r|a,l+=r;0<l;e[n+d]=255&s,d+=p,s/=256,l-=8);e[n+d-p]|=128*i}}).call(this,e("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/ieee754/index.js","/node_modules/gulp-browserify/node_modules/ieee754")},{buffer:3,lYpoI2:11}],11:[function(e,t,n){(function(e,n,o,r,i,s,a,l,c){var u,h,d;function p(){}(e=t.exports={}).nextTick=(h="undefined"!=typeof window&&window.setImmediate,d="undefined"!=typeof window&&window.postMessage&&window.addEventListener,h?function(e){return window.setImmediate(e)}:d?(u=[],window.addEventListener("message",(function(e){var t=e.source;t!==window&&null!==t||"process-tick"!==e.data||(e.stopPropagation(),0<u.length&&u.shift()())}),!0),function(e){u.push(e),window.postMessage("process-tick","*")}):function(e){setTimeout(e,0)}),e.title="browser",e.browser=!0,e.env={},e.argv=[],e.on=p,e.addListener=p,e.once=p,e.off=p,e.removeListener=p,e.removeAllListeners=p,e.emit=p,e.binding=function(e){throw new Error("process.binding is not supported")},e.cwd=function(){return"/"},e.chdir=function(e){throw new Error("process.chdir is not supported")}}).call(this,e("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/process/browser.js","/node_modules/gulp-browserify/node_modules/process")},{buffer:3,lYpoI2:11}]},{},[1])(1)},9146:(e,t)=>{"use strict";var n;!function(){var o=t||{}||this||window;void 0===(n=function(){return o}.apply(t,[]))||(e.exports=n),o.default=o;var r="http://www.w3.org/2000/xmlns/",i="http://www.w3.org/2000/svg",s=/url\(["']?(.+?)["']?\)/,a={woff2:"font/woff2",woff:"font/woff",otf:"application/x-font-opentype",ttf:"application/x-font-ttf",eot:"application/vnd.ms-fontobject",sfnt:"application/font-sfnt",svg:"image/svg+xml"},l=function(e){return e instanceof HTMLElement||e instanceof SVGElement},c=function(e){if(!l(e))throw new Error("an HTMLElement or SVGElement is required; got "+e)},u=function(e){return new Promise((function(t,n){l(e)?t(e):n(new Error("an HTMLElement or SVGElement is required; got "+e))}))},h=function(e,t,n){var o=e.viewBox&&e.viewBox.baseVal&&e.viewBox.baseVal[n]||null!==t.getAttribute(n)&&!t.getAttribute(n).match(/%$/)&&parseInt(t.getAttribute(n))||e.getBoundingClientRect()[n]||parseInt(t.style[n])||parseInt(window.getComputedStyle(e).getPropertyValue(n));return null==o||isNaN(parseFloat(o))?0:o},d=function(e){for(var t=window.atob(e.split(",")[1]),n=e.split(",")[0].split(":")[1].split(";")[0],o=new ArrayBuffer(t.length),r=new Uint8Array(o),i=0;i<t.length;i++)r[i]=t.charCodeAt(i);return new Blob([o],{type:n})},p={},m=null,f=function(e,t){var n=t||{},o=n.selectorRemap,r=n.modifyStyle,i=n.modifyCss,l=n.fonts,c=n.excludeUnusedCss,u=i||function(e,t){return(o?o(e):e)+"{"+(r?r(t):t)+"}\n"},h=[],d=void 0===l,f=l||[];return(m||(m=Array.from(document.styleSheets).map((function(e){try{return{rules:e.cssRules,href:e.href}}catch(t){return console.warn("Stylesheet could not be loaded: "+e.href,t),{}}})))).forEach((function(t){var n=t.rules,o=t.href;n&&Array.from(n).forEach((function(t){if(void 0!==t.style)if(function(e,t){if(t)try{return e.querySelector(t)||e.parentNode&&e.parentNode.querySelector(t)}catch(e){console.warn('Invalid CSS selector "'+t+'"',e)}}(e,t.selectorText))h.push(u(t.selectorText,t.style.cssText));else if(d&&t.cssText.match(/^@font-face/)){var n=function(e,t){var n=e.cssText.match(s),o=n&&n[1]||"";if(o&&!o.match(/^data:/)&&"about:blank"!==o){var r,i,l=o.startsWith("../")?t+"/../"+o:o.startsWith("./")?t+"/."+o:o;return{text:e.cssText,format:(r=l,i=Object.keys(a).filter((function(e){return r.indexOf("."+e)>0})).map((function(e){return a[e]})),i?i[0]:(console.error("Unknown font format for "+r+". Fonts may not be working correctly."),"application/octet-stream")),url:l}}}(t,o);n&&f.push(n)}else c||h.push(t.cssText)}))})),function(e){return Promise.all(e.map((function(e){return new Promise((function(t,n){if(p[e.url])return t(p[e.url]);var o=new XMLHttpRequest;o.addEventListener("load",(function(){var n=function(e){for(var t="",n=new Uint8Array(e),o=0;o<n.byteLength;o++)t+=String.fromCharCode(n[o]);return window.btoa(t)}(o.response),r=e.text.replace(s,'url("data:'+e.format+";base64,"+n+'")')+"\n";p[e.url]=r,t(r)})),o.addEventListener("error",(function(n){console.warn("Failed to load font from: "+e.url,n),p[e.url]=null,t(null)})),o.addEventListener("abort",(function(n){console.warn("Aborted loading font from: "+e.url,n),t(null)})),o.open("GET",e.url),o.responseType="arraybuffer",o.send()}))}))).then((function(e){return e.filter((function(e){return e})).join("")}))}(f).then((function(e){return h.join("\n")+e}))},g=function(){if(!navigator.msSaveOrOpenBlob&&!("download"in document.createElement("a")))return{popup:window.open()}};o.prepareSvg=function(e,t,n){c(e);var o=t||{},s=o.left,a=void 0===s?0:s,l=o.top,u=void 0===l?0:l,d=o.width,p=o.height,m=o.scale,g=void 0===m?1:m,y=o.responsive,b=void 0!==y&&y,v=o.excludeCss,C=void 0!==v&&v;return function(e){return Promise.all(Array.from(e.querySelectorAll("image")).map((function(e){var t,n=e.getAttributeNS("http://www.w3.org/1999/xlink","href")||e.getAttribute("href");return n?((t=n)&&0===t.lastIndexOf("http",0)&&-1===t.lastIndexOf(window.location.host)&&(n+=(-1===n.indexOf("?")?"?":"&")+"t="+(new Date).valueOf()),new Promise((function(t,o){var r=document.createElement("canvas"),i=new Image;i.crossOrigin="anonymous",i.src=n,i.onerror=function(){return o(new Error("Could not load "+n))},i.onload=function(){r.width=i.width,r.height=i.height,r.getContext("2d").drawImage(i,0,0),e.setAttributeNS("http://www.w3.org/1999/xlink","href",r.toDataURL("image/png")),t(!0)}}))):Promise.resolve(null)})))}(e).then((function(){var o=e.cloneNode(!0);o.style.backgroundColor=(t||{}).backgroundColor||e.style.backgroundColor;var s=function(e,t,n,o){if("svg"===e.tagName)return{width:n||h(e,t,"width"),height:o||h(e,t,"height")};if(e.getBBox){var r=e.getBBox(),i=r.x,s=r.y;return{width:i+r.width,height:s+r.height}}}(e,o,d,p),l=s.width,c=s.height;if("svg"!==e.tagName){if(!e.getBBox)return void console.error("Attempted to render non-SVG element",e);null!=o.getAttribute("transform")&&o.setAttribute("transform",o.getAttribute("transform").replace(/translate\(.*?\)/,""));var m=document.createElementNS("http://www.w3.org/2000/svg","svg");m.appendChild(o),o=m}if(o.setAttribute("version","1.1"),o.setAttribute("viewBox",[a,u,l,c].join(" ")),o.getAttribute("xmlns")||o.setAttributeNS(r,"xmlns",i),o.getAttribute("xmlns:xlink")||o.setAttributeNS(r,"xmlns:xlink","http://www.w3.org/1999/xlink"),b?(o.removeAttribute("width"),o.removeAttribute("height"),o.setAttribute("preserveAspectRatio","xMinYMin meet")):(o.setAttribute("width",l*g),o.setAttribute("height",c*g)),Array.from(o.querySelectorAll("foreignObject > *")).forEach((function(e){e.setAttributeNS(r,"xmlns","svg"===e.tagName?i:"http://www.w3.org/1999/xhtml")})),!C)return f(e,t).then((function(e){var t=document.createElement("style");t.setAttribute("type","text/css"),t.innerHTML="<![CDATA[\n"+e+"\n]]>";var r=document.createElement("defs");r.appendChild(t),o.insertBefore(r,o.firstChild);var i=document.createElement("div");i.appendChild(o);var s=i.innerHTML.replace(/NS\d+:href/gi,'xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href');if("function"!=typeof n)return{src:s,width:l,height:c};n(s,l,c)}));var y=document.createElement("div");y.appendChild(o);var v=y.innerHTML;if("function"!=typeof n)return{src:v,width:l,height:c};n(v,l,c)}))},o.svgAsDataUri=function(e,t,n){return c(e),o.prepareSvg(e,t).then((function(e){var t=e.src,o=e.width,r=e.height,i="data:image/svg+xml;base64,"+window.btoa(decodeURIComponent(encodeURIComponent('<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [<!ENTITY nbsp " ">]>'+t).replace(/%([0-9A-F]{2})/g,(function(e,t){var n=String.fromCharCode("0x"+t);return"%"===n?"%25":n}))));return"function"==typeof n&&n(i,o,r),i}))},o.svgAsPngUri=function(e,t,n){c(e);var r=t||{},i=r.encoderType,s=void 0===i?"image/png":i,a=r.encoderOptions,l=void 0===a?.8:a,u=r.canvg,h=function(e){var t=e.src,o=e.width,r=e.height,i=document.createElement("canvas"),a=i.getContext("2d"),c=window.devicePixelRatio||1;i.width=o*c,i.height=r*c,i.style.width=i.width+"px",i.style.height=i.height+"px",a.setTransform(c,0,0,c,0,0),u?u(i,t):a.drawImage(t,0,0);var h=void 0;try{h=i.toDataURL(s,l)}catch(e){if("undefined"!=typeof SecurityError&&e instanceof SecurityError||"SecurityError"===e.name)return void console.error("Rendered SVG images cannot be downloaded in this browser.");throw e}return"function"==typeof n&&n(h,i.width,i.height),Promise.resolve(h)};return u?o.prepareSvg(e,t).then(h):o.svgAsDataUri(e,t).then((function(e){return new Promise((function(t,n){var o=new Image;o.onload=function(){return t(h({src:o,width:o.width,height:o.height}))},o.onerror=function(){n("There was an error loading the data URI as an image on the following SVG\n"+window.atob(e.slice(26))+"Open the following link to see browser's diagnosis\n"+e)},o.src=e}))}))},o.download=function(e,t,n){if(navigator.msSaveOrOpenBlob)navigator.msSaveOrOpenBlob(d(t),e);else{var o=document.createElement("a");if("download"in o){o.download=e,o.style.display="none",document.body.appendChild(o);try{var r=d(t),i=URL.createObjectURL(r);o.href=i,o.onclick=function(){return requestAnimationFrame((function(){return URL.revokeObjectURL(i)}))}}catch(e){console.error(e),console.warn("Error while getting object URL. Falling back to string URL."),o.href=t}o.click(),document.body.removeChild(o)}else n&&n.popup&&(n.popup.document.title=e,n.popup.location.replace(t))}},o.saveSvg=function(e,t,n){var r=g();return u(e).then((function(e){return o.svgAsDataUri(e,n||{})})).then((function(e){return o.download(t,e,r)}))},o.saveSvgAsPng=function(e,t,n){var r=g();return u(e).then((function(e){return o.svgAsPngUri(e,n||{})})).then((function(e){return o.download(t,e,r)}))}}()},5072:e=>{"use strict";var t=[];function n(e){for(var n=-1,o=0;o<t.length;o++)if(t[o].identifier===e){n=o;break}return n}function o(e,o){for(var i={},s=[],a=0;a<e.length;a++){var l=e[a],c=o.base?l[0]+o.base:l[0],u=i[c]||0,h="".concat(c," ").concat(u);i[c]=u+1;var d=n(h),p={css:l[1],media:l[2],sourceMap:l[3],supports:l[4],layer:l[5]};if(-1!==d)t[d].references++,t[d].updater(p);else{var m=r(p,o);o.byIndex=a,t.splice(a,0,{identifier:h,updater:m,references:1})}s.push(h)}return s}function r(e,t){var n=t.domAPI(t);return n.update(e),function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap&&t.supports===e.supports&&t.layer===e.layer)return;n.update(e=t)}else n.remove()}}e.exports=function(e,r){var i=o(e=e||[],r=r||{});return function(e){e=e||[];for(var s=0;s<i.length;s++){var a=n(i[s]);t[a].references--}for(var l=o(e,r),c=0;c<i.length;c++){var u=n(i[c]);0===t[u].references&&(t[u].updater(),t.splice(u,1))}i=l}}},7659:e=>{"use strict";var t={};e.exports=function(e,n){var o=function(e){if(void 0===t[e]){var n=document.querySelector(e);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(e){n=null}t[e]=n}return t[e]}(e);if(!o)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");o.appendChild(n)}},540:e=>{"use strict";e.exports=function(e){var t=document.createElement("style");return e.setAttributes(t,e.attributes),e.insert(t,e.options),t}},5056:(e,t,n)=>{"use strict";e.exports=function(e){var t=n.nc;t&&e.setAttribute("nonce",t)}},7825:e=>{"use strict";e.exports=function(e){if("undefined"==typeof document)return{update:function(){},remove:function(){}};var t=e.insertStyleElement(e);return{update:function(n){!function(e,t,n){var o="";n.supports&&(o+="@supports (".concat(n.supports,") {")),n.media&&(o+="@media ".concat(n.media," {"));var r=void 0!==n.layer;r&&(o+="@layer".concat(n.layer.length>0?" ".concat(n.layer):""," {")),o+=n.css,r&&(o+="}"),n.media&&(o+="}"),n.supports&&(o+="}");var i=n.sourceMap;i&&"undefined"!=typeof btoa&&(o+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(i))))," */")),t.styleTagTransform(o,e,t.options)}(t,e,n)},remove:function(){!function(e){if(null===e.parentNode)return!1;e.parentNode.removeChild(e)}(t)}}}},1113:e=>{"use strict";e.exports=function(e,t){if(t.styleSheet)t.styleSheet.cssText=e;else{for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(document.createTextNode(e))}}},6686:(e,t,n)=>{"use strict";n.d(t,{AL:()=>o,NO:()=>r});const o=["A","G","C","U"];var r;!function(e){e.HELM="HELM",e.AXOLABS="Axolabs"}(r||(r={}))},9537:(e,t,n)=>{"use strict";n.d(t,{iL:()=>i,q7:()=>r,ti:()=>o});const o={NUCLEOSIDE:"nucleoside",LINKAGE:"phosphateBackbone"},r="p",i="<?>"},3480:(e,t,n)=>{"use strict";n.d(t,{C6:()=>l,Hs:()=>a,OT:()=>c,bD:()=>s});var o=n(6686),r=n(5067),i=n(9537);function s(e,t,n,r){const i=Object.keys(r.jsonData.codesToHelmDict).concat([o.NO.HELM]);if(!e||-1!==t&&n!==o.NO.HELM)return{};if(!i.includes(n))throw new Error(`${n} format is not supported by SequenceTranslator`);const s=i.filter((e=>e!=n)).sort(((e,t)=>e.localeCompare(t))),l=r.createFormatConverter(e,n),c=Object.fromEntries(s.map((e=>{let t;try{t=l.convertTo(e)}catch{t=null}return[e,t]})).filter((([e,t])=>t))),u=a(n===o.NO.HELM?e:c[o.NO.HELM],r.monomerLibWrapper);return u&&(c.Nucleotides=u),c}function a(e,t){const n=new RegExp("\\([^()]*\\)","g"),r=e.match(n);return r?r.map((e=>{const n=e.replace(/[\[\]()]/g,"");return o.AL.includes(n)?n:t.getNaturalAnalogBySymbol(n)})).map((e=>e||i.iL)).join(""):null}function l(e,t,n,i){const s=i.createFormatConverter(e,t);return n===r.qP?a(s.convertTo(o.NO.HELM),i.monomerLibWrapper):s.convertTo(n)}function c(e){return Object.keys(e.jsonData.codesToHelmDict).concat([o.NO.HELM,r.qP]).sort()}},5067:(e,t,n)=>{"use strict";n.d(t,{U_:()=>r,n_:()=>o,qP:()=>i});const o="Copied",r="Copy sequence",i="Nucleotides"},5733:(e,t,n)=>{"use strict";n.d(t,{CB:()=>M,Z4:()=>C,aA:()=>g});var o=n(1536);const r={showLetters:!0,pairAlign:!0},i=1.25,s=.5,a=.32,l=5,c=17,u=4,h=30,d=.85,p=.5,m=.22,f=.55;function g(e,t,n,o={}){const d={...r,...o},p=n.sense.monomers.length,m=n.antisense?n.antisense.monomers.length:0,f=m>0,g=f?2:1,b=Math.max(1,p,m),C=Math.max(0,e-h-2*u)/(b+Math.max(0,b-1)*a),x=g+Math.max(0,g-1)*s,w=(t-2*u)/x/i;let A=Math.min(c,C,w);const T=A<l;A<l&&(A=l);const E=A*i,S=Math.max(2,A*a),N=E*s,I=Math.max(7,Math.min(13,.62*A)),M=g*E+(g-1)*N,P=Math.max(u,(t-M)/2),_=P,L=f?P+E+N:-1,O=u+h,R=e-u,$={chipW:A,chipH:E,chipGap:S,strandGap:N,fontSize:I,labelW:h,padding:u,senseY:_,antiY:L,seqX:O,textOnlyFallback:T};if(T)return{...$,senseChips:[],antiChips:[],senseLinks:[],antiLinks:[],antiReversed:!1};const D=f&&d.pairAlign,B=v(n.sense.monomers,!1,A,I,S),F=f?v(n.antisense.monomers,D,A,I,S):0,k=Math.max(B,F),H=O+(k-B),G=O+(k-F),U=y(n.sense,!1,_,H,R,$,"sense"),V=f?y(n.antisense,D,L,G,R,$,"antisense"):{chips:[],links:[]};return{...$,senseChips:U.chips,antiChips:V.chips,senseLinks:U.links,antiLinks:V.links,antiReversed:D}}function y(e,t,n,o,r,i,s){const a=t?e.monomers.slice().reverse():e.monomers,l=[],c=[];let u=o;for(let e=0;e<a.length;e++){const t=a[e],o="conjugate"===t.kind?b(t.symbol,i.chipW,i.fontSize):i.chipW;if(u+o>r)break;if(l.push({x:u,w:o,monomer:t,origIdx:t.position,strand:s}),"nucleotide"===t.kind&&e<a.length-1){const e=t;e.phosphate&&c.push({x:u+o,w:i.chipGap,y:n,h:i.chipH,phosphateSymbol:e.phosphate,ownerOrigIdx:e.position,strand:s})}u+=o+i.chipGap}return{chips:l,links:c}}function b(e,t,n){const r=.55*n,i=(0,o.rK)(e).meta.short.length*r,s=.6*t;return Math.max(t,Math.min(4*t,i+s))}function v(e,t,n,o,r){const i=t?e.slice().reverse():e;let s=0;for(const e of i){if("conjugate"!==e.kind)break;s+=b(e.symbol,n,o)+r}return s}function C(e,t,n,o,i,s,a={}){const l={...r,...a},c=g(o,i,s,l);if(e.save(),e.beginPath(),e.rect(t,n,o,i),e.clip(),e.translate(t,n),c.textOnlyFallback)return function(e,t,n,o,r){const i=o.sense.monomers.length,s=o.antisense?o.antisense.monomers.length:0,a=o.antisense?`${i}+${s} nt duplex`:`${i} nt`;e.fillStyle="#8b949e",e.font=`${Math.max(8,r.fontSize)}px ui-monospace, Menlo, monospace`,e.textBaseline="middle",e.textAlign="left",e.fillText(a,4,n/2)}(e,0,i,s,c),e.restore(),c;x(e,"S","5'",c.padding,c.senseY+c.chipH/2,c);for(const t of c.senseLinks)E(e,t);if(A(e,c.senseChips,c,l),w(e,c.senseChips,s.sense.monomers.length,c),c.antiY>=0&&s.antisense){x(e,"AS",c.antiReversed?"3'":"5'",c.padding,c.antiY+c.chipH/2,c);for(const t of c.antiLinks)E(e,t);A(e,c.antiChips,c,l),w(e,c.antiChips,s.antisense.monomers.length,c)}return e.restore(),c}function x(e,t,n,o,r,i){e.fillStyle="#8b949e",e.font=`${Math.max(8,i.fontSize-1)}px ui-monospace, Menlo, monospace`,e.textBaseline="middle",e.textAlign="left",e.fillText(`${t} ${n}`,o,r)}function w(e,t,n,o){if(t.length>=n)return;const r=t[t.length-1];r&&(e.fillStyle="#6e7681",e.font=`${Math.max(7,o.fontSize-1)}px ui-monospace, Menlo, monospace`,e.textBaseline="middle",e.textAlign="left",e.fillText("…",r.x+r.w+1,o.senseY+o.chipH/2))}function A(e,t,n,o){const r="sense"===t[0]?.strand?n.senseY:n.antiY;for(const i of t)"conjugate"===i.monomer.kind?S(e,i.monomer.symbol,i.x,r,i.w,n.chipH,n.fontSize):T(e,i.monomer,i.x,r,i.w,n.chipH,n.fontSize,o)}function T(e,t,n,r,i,s,a,l){const c=(0,o.xh)(t.sugar,t.base),u=o.L1[t.base??""]??o.FN,h=function(e){const t=(0,o.Jy)(e);return"r"!==t&&"d"!==t}(t.sugar),f=Math.min(2.5,i/4);if(N(e,n,r,i,s,f),e.fillStyle=function(e,t){const n=`${e}|${t}`,o=I.get(n);if(o)return o;const r=document.createElement("span");r.style.color=e,document.body.appendChild(r);const i=getComputedStyle(r).color;document.body.removeChild(r);const s=i.match(/\d+/g),a=s?`rgba(${s[0]},${s[1]},${s[2]},${t})`:e;return I.size>256&&I.clear(),I.set(n,a),a}(u,d),e.fill(),e.lineWidth=p,e.strokeStyle="rgba(0,0,0,0.22)",e.stroke(),h){const t=Math.max(2,s*m);e.save(),N(e,n,r,i,s,f),e.clip(),e.fillStyle=c.color,e.fillRect(n,r+s-t,i,t),e.restore()}if(l.showLetters&&t.base&&a>=8){const o=h?Math.max(2,s*m):0;e.fillStyle="#1a1a1a",e.font=`600 ${a}px system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif`,e.textBaseline="middle",e.textAlign="center",e.fillText(t.base,n+i/2,r+(s-o)/2+.5)}}function E(e,t){const n=(0,o.bM)(t.phosphateSymbol);if("PS"!==n.meta.short&&"PS₂"!==n.meta.short&&"MeP"!==n.meta.short)return;const r=Math.max(2.5,t.w*f),i=t.x+(t.w-r)/2;e.fillStyle=n.color,e.fillRect(i,t.y+1,r,t.h-2)}function S(e,t,n,r,i,s,a){const l=(0,o.rK)(t);N(e,n,r,i,s,s/2),e.fillStyle=l.color,e.fill(),e.lineWidth=.5,e.strokeStyle="rgba(0,0,0,0.2)",e.stroke(),a>=8&&(e.fillStyle="#ffffff",e.font=`600 ${Math.max(8,a-1)}px system-ui, sans-serif`,e.textBaseline="middle",e.textAlign="center",e.fillText(l.meta.short,n+i/2,r+s/2+.5))}function N(e,t,n,o,r,i){e.beginPath(),e.moveTo(t+i,n),e.lineTo(t+o-i,n),e.quadraticCurveTo(t+o,n,t+o,n+i),e.lineTo(t+o,n+r-i),e.quadraticCurveTo(t+o,n+r,t+o-i,n+r),e.lineTo(t+i,n+r),e.quadraticCurveTo(t,n+r,t,n+r-i),e.lineTo(t,n+i),e.quadraticCurveTo(t,n,t+i,n),e.closePath()}const I=new Map;function M(e,t,n,o){if(o.textOnlyFallback)return null;if(t>=o.senseY&&t<=o.senseY+o.chipH){const r=P(e,o.senseChips);if(r)return{strand:"sense",position:r.origIdx,monomer:r.monomer};const i=_(e,t,o.senseLinks);if(i)return L(i,n.sense,"sense")}if(o.antiY>=0&&t>=o.antiY&&t<=o.antiY+o.chipH){const r=P(e,o.antiChips);if(r)return{strand:"antisense",position:r.origIdx,monomer:r.monomer};const i=_(e,t,o.antiLinks);if(i&&n.antisense)return L(i,n.antisense,"antisense")}return null}function P(e,t){for(const n of t)if(e>=n.x&&e<n.x+n.w)return n;return null}function _(e,t,n){for(const o of n)if(e>=o.x&&e<o.x+o.w&&t>=o.y&&t<o.y+o.h)return o;return null}function L(e,t,n){const o=t.monomers.find((t=>t.position===e.ownerOrigIdx));return{strand:n,position:e.ownerOrigIdx,monomer:o,linkage:{phosphateSymbol:e.phosphateSymbol}}}},5613:(e,t,n)=>{"use strict";n.d(t,{On:()=>r,nj:()=>u,yO:()=>l});var o=n(1536);function r(e){const t=((e??"").split("$")[0]??"").split("|").map((e=>e.trim())).filter((e=>e.length>0)).map(i);return{sense:t[0]??{type:"RNA",monomers:[]},antisense:t[1]??null,raw:e}}function i(e){const t=e.match(/^(RNA|DNA|CHEM|PEPTIDE|BLOB)\d+\{(.*)\}$/);return t?{type:t[1],monomers:s(t[2])}:{type:"CHEM",monomers:[]}}function s(e){const t=[];let n=0,o="",r=0;for(const i of e){if("["===i||"("===i)n++;else if("]"===i||")"===i)n--;else if("."===i&&0===n){o&&t.push(a(o,r++)),o="";continue}o+=i}return o&&t.push(a(o,r)),t}function a(e,t){let n=0,o="",r=null,i="";const s=e;if("["===e[0]){const t=e.indexOf("]");o=e.substring(1,t),n=t+1}else o=e[0]??"",n=1;if("("===e[n]){const t=e.indexOf(")",n);r=e.substring(n+1,t),n=t+1}if(n<e.length)if("["===e[n]){const t=e.indexOf("]",n);i=e.substring(n+1,t),n=t+1}else i=e.substring(n);return null===r?{kind:"conjugate",position:t,symbol:o,raw:s}:{kind:"nucleotide",position:t,sugar:o,base:r,phosphate:i,raw:s}}function l(e){return/^\s*(?:RNA|DNA|PEPTIDE|CHEM|BLOB)\d+\s*\{/.test(e??"")}function c(e){if("conjugate"===e.kind)return`[${e.symbol}]`;const t=e,n=(0,o.Jy)(t.sugar),r=(0,o.$T)(t.phosphate),i=1===n.length?n:`[${n}]`,s=r?1===r.length?r:`[${r}]`:"";return`${i}${t.base?`(${t.base})`:""}${s}`}function u(e){return`${(e??"").split("$")[0].split("|").map((e=>e.trim())).filter(Boolean).map((e=>{const t=e.match(/^((?:RNA|DNA|PEPTIDE|CHEM|BLOB)\d+)\{(.*)\}$/);if(!t)return e;const[,n,o]=t;return`${n}{${function(e){return s(e).map(c).join(".")}(o)}}`})).join("|")}$$$$`}},1536:(e,t,n)=>{"use strict";n.d(t,{$T:()=>m,D2:()=>r,FN:()=>h,Jy:()=>p,L1:()=>u,P4:()=>a,bM:()=>g,e8:()=>d,mU:()=>o,pt:()=>c,rK:()=>y,xh:()=>f});const o="OligoNucleotide",r="helm",i=Object.freeze({r:{name:"Ribose",short:"RNA",color:"#D0D0D0",category:"sugar"},d:{name:"Deoxyribose",short:"DNA",color:"#BDBDBD",category:"sugar"},m:{name:"2'-O-Methyl",short:"2'-OMe",color:"#4A90E2",category:"sugar"},"25r":{name:"2'-O-Methyl (2,5)",short:"2'-OMe",color:"#4A90E2",category:"sugar"},fl2r:{name:"2'-Fluoro",short:"2'-F",color:"#50C878",category:"sugar"},lna:{name:"LNA",short:"LNA",color:"#E89D3C",category:"sugar"},cet:{name:"cEt",short:"cEt",color:"#E07B30",category:"sugar"},ena:{name:"ENA",short:"ENA",color:"#D26C20",category:"sugar"},moe:{name:"2'-MOE",short:"2'-MOE",color:"#66CDAA",category:"sugar"},Rgna:{name:"(R)-GNA",short:"GNA",color:"#C7A981",category:"sugar"},Sgna:{name:"(S)-GNA",short:"GNA",color:"#C7A981",category:"sugar"},una:{name:"UNA",short:"UNA",color:"#ED68B8",category:"sugar"},fana:{name:"FANA",short:"FANA",color:"#76B947",category:"sugar"},hna:{name:"HNA",short:"HNA",color:"#A4D080",category:"sugar"}}),s=Object.freeze({R:"r",dR:"d",mR:"m",fR:"fl2r",LR:"lna",L:"lna",MOE:"moe",GNA:"Sgna",UNA:"una"}),a=Object.freeze({p:{name:"Phosphate",short:"PO",color:"#888888",category:"phosphate"},sp:{name:"Phosphorothioate",short:"PS",color:"#6B46C1",category:"phosphate"},s2p:{name:"Phosphorodithioate",short:"PS₂",color:"#7E2BC4",category:"phosphate"},mp:{name:"Methylphosphonate",short:"MeP",color:"#9B5DE5",category:"phosphate"}}),l=Object.freeze({P:"p",sP:"sp"}),c=Object.freeze({GalNAc:{name:"GalNAc",short:"GalNAc",color:"#E91E63",category:"conjugate"},L3:{name:"GalNAc-L3 linker",short:"L3",color:"#E91E63",category:"conjugate"},Chol:{name:"Cholesterol",short:"Chol",color:"#B57F50",category:"conjugate"},Bio:{name:"Biotin",short:"Bio",color:"#FFC107",category:"conjugate"}}),u=Object.freeze({A:"#C1E7C5",C:"#C5DCF0",G:"#E8DCA9",U:"#F0C5C5",T:"#F0C5C5"}),h="#BCBCBC";function d(e){let t=0;for(let n=0;n<e.length;n++)t=31*t+e.charCodeAt(n)|0;return`hsl(${(t>>>0)%360}, 42%, 60%)`}function p(e){return s[e]??e}function m(e){return l[e]??e}function f(e,t){const n=p(e),o=i[n];if(o)return("r"===n||"d"===n)&&t&&u[t]?{color:u[t],meta:o}:{color:o.color,meta:o};const r=d(n);return{color:r,meta:{name:n,short:n,color:r,category:"sugar"}}}function g(e){if(!e)return{color:"#888",meta:{name:"(none)",short:"",color:"#888",category:"phosphate"}};const t=m(e),n=a[t];if(n)return{color:n.color,meta:n};const o=d(t);return{color:o,meta:{name:t,short:t,color:o,category:"phosphate"}}}function y(e){const t=c[e];return t?{color:t.color,meta:t}:{color:d(e),meta:{name:e,short:e.length>6?e.slice(0,6):e,color:d(e),category:"conjugate"}}}},9022:(e,t,n)=>{"use strict";n.d(t,{PackageFunctions:()=>Cr,_package:()=>br});var o=n(4328),r=n(6082),i=n(439),s=n(7291);const a=new class{constructor(){this.seqHandler="seq-handler",this.notationProvider="seq-handler.notation-provider"}};r.SemanticValue;var l=n(4971);class c{constructor(e,t,n=""){this.target=e,this.debugEnabled=t,this.prefix=n}error(e,t,n){return this.target.error(this.prefix+e,t,n)}warning(e,t){return this.target.warning(this.prefix+e,t)}info(e,t){return this.target.info(this.prefix+e,t)}debug(e,t){if(this.debugEnabled)return this.target.debug(this.prefix+e,t)}}const u="System:AppData/SequenceTranslator/monomers-sample",h="pattern-app-data.json",d="formats-to-helm.json",p="codes-to-symbols.json",m="linkers.json";var f=n(6686);function g(e){return e.sort(((e,t)=>t.length-e.length))}function y(e,t){const n=document.createElement("a");n.setAttribute("href","data:text/plain;charset=utf-8,"+t),n.setAttribute("download",e),n.click()}async function b(e,t,n="Oligo app"){try{return await e()}catch(e){const t=e.hasOwnProperty("message")?e.message:e.toString();throw o.shell.error(`${n} error: `+t),e}finally{t&&t()}}class v{constructor(e,t){this.sequence=e,this.th=t,this.libWrapper=this.th.monomerLibWrapper}getInvalidCodeIndex(e){if(e===f.NO.HELM)return this.sequence.length;const t=["r","d"],n=g(this.libWrapper.getCodesByFormat(e));let o=0;for(;o<this.sequence.length;){const e=n.find((e=>e===this.sequence.substring(o,o+e.length)));if(!e)break;if(o>1&&f.AL.includes(this.sequence[o])&&t.includes(this.sequence[o-2]))break;if(t.includes(this.sequence[o+1])&&f.AL.includes(this.sequence[o])){o++;break}o+=e.length}return o===this.sequence.length&&(o=-1),o}isValidSequence(e){return-1===this.getInvalidCodeIndex(e)}}class C{constructor(e,t,n,o){this.patternAppData=e,this.codesToHelmDict=t,this.codesToSymbolsDict=n,this.monomersWithPhosphate=o}}async function x(e){const t=await Promise.all([h,d,p,m].map((t=>async function(e,t){const n=e.endsWith("/")?`${e}${t}`:`${e}/${t}`;try{const e=await o.dapi.files.readAsText(n);return JSON.parse(e)}catch(e){console.error(`Error loading json from '${n}':`,e)}}(e,t))));return new C(t[0],t[1],t[2],t[3])}class w{constructor(e,t){if(this.lib=e,this.jsonData=t,null===this.lib)throw new Error("SequenceTranslator: monomer library is null");this.allMonomers=this.getAllMonomers()}formatMonomerForViewer(e){const t={};return t.name=e.symbol,t.symbol=e.symbol,t.molfile=e.molfile,this.getAllFormats().forEach((n=>{if(n===f.NO.HELM)return;const o=this.jsonData.codesToSymbolsDict[n],r=Object.keys(o).filter((t=>o[t]===e.symbol));t[n]=r.join(", ")})),t}getAllMonomers(){const e=this.lib.getPolymerTypes();let t=[];for(const n of e){const e=this.lib.getMonomerSymbolsByType(n).map((e=>this.lib.getMonomer(n,e))).filter((e=>null!==e));t=t.concat(e)}return t}getMonomer(e){const t=this.lib.getMonomer("RNA",e);if(void 0===t)throw new Error(`SequenceTranslator: no monomer with symbol ${e}`);return t}getMolfileBySymbol(e){return this.getMonomer(e).molfile}getNaturalAnalogBySymbol(e){const t=this.getMonomer(e).naturalAnalog;if(!t)throw new Error(`ST: no natural analog for ${e}`);return t}isModification(e){return!!this.getMolfileBySymbol(e).includes("MODIFICATION")}getCodeToSymbolMap(e){return new Map(Object.entries(this.jsonData.codesToSymbolsDict[e]))}getCodesByFormat(e){return Object.keys(this.jsonData.codesToSymbolsDict[e])}getAllFormats(){return Object.keys(this.jsonData.codesToSymbolsDict)}getTableForViewer(){const e=this.allMonomers.map((e=>this.formatMonomerForViewer(e)));return r.DataFrame.fromObjects(e)}getCodesToWeightsMap(){const e=new Map;return Object.entries(this.jsonData.codesToSymbolsDict).forEach((([t,n])=>{Object.entries(n).forEach((([t,n])=>{const o=this.getMonomer(n),r=o.meta?.molecularWeight;e.set(t,r)}))})),e}}var A=n(9537);const T=(e,t)=>t.length-e.length;class E{constructor(e){this.th=e,this.formats=this.getFormats()}getFormatNames(){return this.formats.sort()}getCodesByFormat(e){if(this.validateFormat(e),this.isHelm(e))throw new Error("Codes cannot be obtained for HELM");return this.getFormatCodes(e)}getHelmToFormatDict(e){return this.validateFormat(e),function(e){const t={};return Object.values(e).forEach((e=>{Object.entries(e).forEach((([e,n])=>{const o=n.replace(/\)p/g,")").replace(/\]p/g,"]");void 0===t[o]?t[o]=[e]:t[o].push(e)}))})),Object.entries(t).forEach((([e,n])=>{const o=n.sort(T);t[e]=o[0]})),t}(this.th.jsonData.codesToHelmDict[e])}getFormatToHelmDict(e){this.validateFormat(e);const t=this.th.jsonData.codesToHelmDict[e];return Object.assign({},...Object.values(t))}getTargetFormatHelmCodes(e){this.validateFormat(e);const t=this.getHelmToFormatDict(e);return Object.keys(t).sort(T)}getTargetFormatHelmCodesRegExp(e){this.validateFormat(e);const t=this.getTargetFormatHelmCodes(e);return new RegExp(S(t)+"|.","g")}getFormatRegExp(e){if(this.validateFormat(e),this.isHelm(e))throw new Error("Helm RegExp can be built for non-HELM target formats");return this.getNonHelmFormatRegExp(e)}getPhosphateHelmCodesRegExp(e){this.validateFormat(e);const t=this.th.jsonData.codesToHelmDict[e],n=S(Array.from(new Set(Object.values(t[A.ti.LINKAGE]))).sort(T));return new RegExp(`${A.q7}.(${n})`,"g")}isValidFormat(e){return this.formats.includes(e)}getFormats(){return Object.keys(this.th.jsonData.codesToHelmDict)}validateFormat(e){if(!this.isValidFormat(e))throw new Error(`Invalid format: ${e}`)}isHelm(e){return e===f.NO.HELM}getFormatCodes(e){const t=this.getFormatToHelmDict(e);return Object.keys(t).sort(T)}getNonHelmFormatRegExp(e){const t=this.getCodesByFormat(e);return new RegExp(S(t)+"|\\([^()]*\\)|.","g")}}function S(e){return e.map((e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"))).map((e=>e.includes("(")||e.includes(")")?e:`(?<!\\([^()]*)${e}(?![^()]*\\))`)).join("|")}const N={LEFT:"RNA1{",RIGHT:"}$$$$"};class I{constructor(e,t,n){this.sequence=e,this.sourceFormat=t,this.th=n,this.formats=new E(this.th)}convertTo(e){const t=this.formats.getFormatNames();if(this.sourceFormat===f.NO.HELM&&t.includes(e))return this.helmToFormat(this.sequence,e);if(t.includes(this.sourceFormat)&&e===f.NO.HELM)return this.formatToHelm(this.sequence,this.sourceFormat);if([this.sourceFormat,e].every((e=>t.includes(e)))){const t=this.formatToHelm(this.sequence,this.sourceFormat);return this.helmToFormat(t,e)}throw new Error(`ST: unsupported translation direction ${this.sourceFormat} -> ${e}`)}helmToFormat(e,t){const n=new RegExp(S(Object.values(N)),"g");let o=e.replace(n,"");const r=this.formats.getHelmToFormatDict(t),i=this.formats.getTargetFormatHelmCodes(t),s=this.formats.getTargetFormatHelmCodesRegExp(t);return o=o.replace(s,(e=>i.includes(e)?r[e]:"p"===e||"."===e?e:"?")).replace(/\?+/g,A.iL).replace(/p\.|\./g,""),o=o.replace(/<empty>/g,""),o=o.replace(/\/\//g,"/"),o}formatToHelm(e,t){const n=this.formats.getFormatToHelmDict(t),o=this.formats.getCodesByFormat(t),r=this.formats.getFormatRegExp(t),i=this.formats.getPhosphateHelmCodesRegExp(t);let s=e?e.replace(r,(e=>o.includes(e)?n[e]+".":"?")):"";return s=s.replace(/\?+/g,`${A.iL}.`),s=s.slice(0,-1),s[s.length-1]===A.q7&&(s=s.slice(0,-1)),s=s.replace(i,((e,t)=>t)),s=s.replace(/<empty>/g,""),`${N.LEFT+s+N.RIGHT}`}}class M{constructor(e,t){this.sequence=e,this.th=t,this.libWrapper=this.th.monomerLibWrapper,this.formats=Object.keys(this.th.jsonData.codesToHelmDict)}getFormat(){if(this.sequence.startsWith("RNA"))return f.NO.HELM;const e=this.getListOfPossibleSynthesizersByFirstMatchedCode();if(0===e.length)return null;const t=this.th.createSequenceValidator(this.sequence),n=Array(e.length).fill(0);for(let o=0;o<e.length;++o){const r=e[o];n[o]=t.getInvalidCodeIndex(r)}const o=n.some((e=>-1===e))?-1:Math.max(...n);return e[n.indexOf(o)]}getListOfPossibleSynthesizersByFirstMatchedCode(){const e=this.sequence,t=[];for(const n of this.formats){const o=g(this.libWrapper.getCodesByFormat(n));let r=0;for(let t=0;t<e.length;t++)if(")"===e[t]&&t!==e.length-1){r=t+1;break}o.some((t=>t===e.slice(r,r+t.length)))&&t.push(n)}return t}}var P=n(7389);const _=$;var L=n.n(_);function O(e,t){let n=0;const o=t.createFormatDetector(e).getFormat();null!==o&&(n=new v(e,t).getInvalidCodeIndex(o));const r=n<0||""===e,i=P.span([]);L()(i).css("-webkit-text-fill-color","var(--grey-6)");const s=P.span([]);return L()(s).css("-webkit-text-fill-color","red"),r?i.innerHTML=e:(i.innerHTML=e.slice(0,n),s.innerHTML=e.slice(n)),[i,s]}class R extends r.Package{get helmHelper(){if(!this._helmHelper)throw new Error("Package SequenceTranslator .helmHelper is not initialized");return this._helmHelper}get seqHelper(){return this._helmHelper.seqHelper}get monomerLib(){if(!this._monomerLib)throw new Error("Monomer lib not loaded");return this._monomerLib}get jsonData(){if(!this._jsonData)throw new Error("Json data not loaded");return this._jsonData}get monomerLibWrapper(){if(!this._monomerLibWrapper)throw new Error("Monomer lib wrapper not loaded");return this._monomerLibWrapper}get initPromise(){return this._initPromise}constructor(e={debug:!1}){super(),this.highlightInvalidSubsequence=e=>O(e,this),super._logger=new c(super.logger,e.debug)}startInit(e){this._initPromise=e}completeInit(e){this._helmHelper=e}async initLibData(){return this.initLibDataPromise||(this.initLibDataPromise=(async()=>{const e=await this.getSettings();let t=e instanceof Map?e.get("MonomersPath"):e.MonomersPath;t&&await o.dapi.files.exists(t)||(this.logger.warning(`Monomers path '${t}' not found. Fallback to monomers sample path '${u}'.`),t=u),[this._jsonData,this._monomerLib]=await Promise.all([x(t),D(t)]),this._monomerLibWrapper=new w(this.monomerLib,this.jsonData)})()),this.initLibDataPromise}async getTranslationHelper(){return await o.functions.call(`${this.name}:getTranslationHelper`)}createSequenceValidator(e){return new v(e,this)}createFormatConverter(e,t){return new I(e,t,this)}createFormatDetector(e){return new M(e,this)}}async function D(e){const t=r.TaskBarProgressIndicator.create("Initializing Oligo Toolkit monomer library ...");try{const t=await(0,l.pj)(),n=(e.endsWith("/")?e:e+"/")+"monomer-lib.json";return await t.readLibraryFromFilePath(n)}finally{t.close()}}class B{constructor(e,t){this.appName=e,this.parentAppName=t}async getAppView(){const e=r.TaskBarProgressIndicator.create(`Loading ${this.appName}...`),t=o.shell.v?.root;t&&P.setUpdateIndicator(t,!0);try{return await this.constructView()}finally{e.close(),t&&P.setUpdateIndicator(t,!1)}}}class F extends B{constructor(e){super(e),this.view=r.View.create(),this.configureView()}async constructView(){await this.initView();const e=this.parentAppName?this.parentAppName+"/"+this.appName:this.appName;return this.view.path=`/apps/${br.name}/${e.replace(/\s/g,"")}/`,this.view}async initView(){const e=await this.getContent();this.view.append(e)}configureView(){this.view.box=!0,this.view.name=this.appName;const e=o.shell.windows;e.showProperties=!1,e.showToolbox=!1,e.showHelp=!1}getView(){return this.view}}const k=["SS","AS"],H={SS:"Sense strand",AS:"Anti sense"},G=["3'","5'"],U="OligoToolkit";var V,j,q,W;!function(e){e.IS_ANTISENSE_STRAND_INCLUDED="isAntisenseStrandIncluded",e.NUCLEOTIDE_SEQUENCES="nucleotideSequences",e.PHOSPHOROTHIOATE_LINKAGE_FLAGS="phosphorothioateLinkageFlags",e.STRAND_TERMINUS_MODIFICATIONS="strandTerminusModifications"}(V||(V={})),function(e){e.PATTERN_NAME="patternName",e.PATTERN_COMMENT="patternComment",e.NUCLEOTIDES_WITH_NUMERIC_LABELS="nucleotidesWithNumericLabels"}(j||(j={})),function(e){e.PATTERN_CONFIG="patternConfig",e.AUTHOR_ID="authorID",e.DATE="date"}(q||(q={})),function(e){e.CREATE="create",e.MODIFY="modify"}(W||(W={}));const z=[V.IS_ANTISENSE_STRAND_INCLUDED,V.NUCLEOTIDE_SEQUENCES,V.PHOSPHOROTHIOATE_LINKAGE_FLAGS,V.STRAND_TERMINUS_MODIFICATIONS],Y=(j.PATTERN_NAME,j.PATTERN_COMMENT,j.NUCLEOTIDES_WITH_NUMERIC_LABELS,{patternConfig:{patternName:"<default example>",isAntisenseStrandIncluded:!0,nucleotideSequences:{SS:["RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA"],AS:["RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA"]},phosphorothioateLinkageFlags:{SS:[!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0],AS:[!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0]},strandTerminusModifications:{SS:{"3'":"","5'":""},AS:{"3'":"","5'":""}},patternComment:"",nucleotidesWithNumericLabels:["RNA"]},authorID:""}),K="2024-01-01T18:00:00.000Z";class Q extends Error{constructor(e){super(e),this.name="PatternNameExistsError"}}class J extends Error{constructor(e){super(e),this.name="PatternExistsError"}}var X=n(4802),Z=n.n(X);class ee{constructor(e){this.th=e,this.otherUsersPatternNameToHash=new Map,this.currentUserPatternNameToHash=new Map}static async getInstance(){const e=await br.getTranslationHelper(),t=new ee(e);t.currentUserName=await t.fetchCurrentUserName(),t.currentUserId=await t.fetchCurrentUserId();const n=t.fetchPatterns();return await t.initializePatternMaps(n),t}getCurrentUserPatternNames(){return Array.from(this.currentUserPatternNameToHash.keys()).sort(((e,t)=>e.toLowerCase().localeCompare(t.toLowerCase())))}getOtherUsersPatternNames(){return Array.from(this.otherUsersPatternNameToHash.keys()).sort(((e,t)=>e.toLowerCase().localeCompare(t.toLowerCase())))}getCurrentUserName(){return this.currentUserName}validatePatternNameUniqueness(e){if(this.currentUserPatternNameToHash.has(e))throw new Q(`Pattern with name ${e} already exists`)}validatePatternUniqueness(e){if(Array.from(this.currentUserPatternNameToHash.values()).concat(Array.from(this.otherUsersPatternNameToHash.values())).includes(e))throw new J(e)}getPatternHash(e,t){const n=t?this.currentUserPatternNameToHash.get(e):this.otherUsersPatternNameToHash.get(e);if(void 0===n)throw new Error(`Pattern with name ${e} not found`);return n}async getPatternRecordByHash(e){if(null===e||""===e)return null;try{const t=o.userSettings.getValue(U,e,!1)??"null";return JSON.parse(t)}catch{return null}}async getPatternConfig(e){if(""===e||null===e)return null;const t=await this.getPatternRecordByHash(e);return null===t?null:t[q.PATTERN_CONFIG]}getDefaultPatternRecord(){const e=Y;return e[q.AUTHOR_ID]=this.currentUserId,e}getDefaultPatternConfig(){return Y[q.PATTERN_CONFIG]}getAuthorCategoryByHash(e){if(this.isCurrentUserPattern(e))return this.getCurrentUserAuthorshipCategory();if(this.isOtherUserPattern(e))return this.getOtherUsersAuthorshipCategory();throw new Error(`Pattern with hash ${e} not found`)}isCurrentUserPattern(e){return Array.from(this.currentUserPatternNameToHash.values()).includes(e)}isOtherUserPattern(e){return Array.from(this.otherUsersPatternNameToHash.values()).includes(e)}getPatternNameByHash(e){const t=[this.currentUserPatternNameToHash,this.otherUsersPatternNameToHash];for(const n of t)for(const[t,o]of n.entries())if(o===e)return t;throw new Error(`Pattern with hash ${e} not found`)}getHashOfPatternToBeLoadedAfterDeletion(){const e=this.getCurrentUserPatternNames()[0];if(!e)throw new Error("Cannot load pattern after deletion, as there are no patterns left");const t=this.currentUserPatternNameToHash.get(e);if(void 0===t)throw new Error(`Pattern with name ${e} not found`);return t}async getRecordFromPattern(e){return{[q.PATTERN_CONFIG]:e,[q.AUTHOR_ID]:await o.dapi.users.current().then((e=>e.id))}}getHash(e){const t=z.reduce(((t,n)=>(t[n]=e[n],t)),{});return Z().sha1(t)}async savePatternToUserStorage(e){const t=e.getPatternConfig();try{const n=this.getHash(t);this.validatePatternUniqueness(n);const r=t[j.PATTERN_NAME];this.validatePatternNameUniqueness(r);const i=await this.getRecordFromPattern(t),s=(new Date).toISOString();i[q.DATE]={[W.CREATE]:s,[W.MODIFY]:s};const a=JSON.stringify(i);o.userSettings.add(U,n,a,!1),this.currentUserPatternNameToHash.set(r,n),e.selectAuthor(this.getCurrentUserAuthorshipCategory()),e.updatePatternList(),e.requestPatternLoad(n),e.updateUrlState(n)}catch(e){if(e instanceof Q||e instanceof J)throw e;console.error("Error while saving pattern to user storage",e)}}async overwriteExistingPatternInUserStorage(e){const t=e.getPatternConfig(),n=t[j.PATTERN_NAME],r=this.currentUserPatternNameToHash.get(n);if(void 0===r)throw new Error("Old hash is undefined");const i=this.getHash(t),s=await this.getRecordFromPattern(t),a=(new Date).toISOString();s[q.DATE]={[W.MODIFY]:a};const l=o.userSettings.getValue(U,r,!1)??"null",c=JSON.parse(l);void 0!==c[q.DATE]&&null!=c[q.DATE][W.CREATE]&&(s[q.DATE][W.CREATE]=c[q.DATE][W.CREATE]);const u=JSON.stringify(s);o.userSettings.add(U,i,u,!1),o.userSettings.delete(U,r,!1),this.currentUserPatternNameToHash.set(n,i),e.requestPatternLoad(i),e.updateUrlState(i)}async deletePattern(e,t){const n=this.currentUserPatternNameToHash.get(e);if(e===this.getDefaultPatternName())return void o.shell.warning("Cannot delete default pattern");if(void 0===n)throw new Error(`Pattern with name ${e} not found`);o.userSettings.delete(U,n,!1),this.currentUserPatternNameToHash.delete(e),t.updatePatternList();const r=this.getHashOfPatternToBeLoadedAfterDeletion();t.requestPatternLoad(r)}fetchDefaultNucleobase(){return this.fetchAvailableNucleotideBases()[0]}fetchAvailableNucleotideBases(){const e=Object.keys(this.th.jsonData.patternAppData)[0];return Object.keys(this.th.jsonData.patternAppData[e])}async fetchCurrentUserName(){return(await o.dapi.users.current()).friendlyName}async fetchCurrentUserId(){return(await o.dapi.users.current()).id}fetchPatterns(){return o.userSettings.get(U,!1)??{}}async initializePatternMaps(e){if(!this.currentUserId)throw new Error("Current user ID is not set");const t=new Map;for(const[n,o]of Object.entries(e))await this.extractDataFromRecordToMaps(n,o,t);this.setDefaultPattern()}setDefaultPattern(){const e=Y[q.PATTERN_CONFIG];this.currentUserPatternNameToHash.set(e[j.PATTERN_NAME],"")}async extractDataFromRecordToMaps(e,t,n){const r=JSON.parse(t),i=r[q.PATTERN_CONFIG].patternName,s=r[q.AUTHOR_ID];if(this.isCurrentUserId(s))this.currentUserPatternNameToHash.set(i,e);else{if(!n.has(s)){let e="<UNKNOWN_USER>";try{e=(await o.dapi.users.find(s)).friendlyName}catch(e){}n.set(s,e)}const t=i+` (created by ${n.get(s)})`;this.otherUsersPatternNameToHash.set(t,e)}}getDefaultPatternName(){return Y[q.PATTERN_CONFIG][j.PATTERN_NAME]}getCurrentUserAuthorshipCategory(){return this.currentUserName+" (me)"}getOtherUsersAuthorshipCategory(){return"Other users"}isCurrentUserId(e){return e===this.currentUserId}}const te=rxjs,ne=rxjs.operators;function oe(e){return e.endsWith("(o)")}function re(e){const t=Object.values(e).flat().reduce(((e,t)=>(e[t]=(e[t]||0)+1,e)),{});return Object.entries(t).reduce(((e,t)=>e[1]>t[1]?e:t),["",0])[0]}var ie;function se(e){const t=Array.from(new Set(e));return Array.from(t).sort(((e,t)=>e.toLowerCase().localeCompare(t.toLowerCase())))}!function(e){e.getTruncatedStrandData=function(e,t,n){return{nucleotides:e.slice(0,n),ptoFlags:t.slice(0,n+1)}},e.getExtendedStrandData=function(e,t,n,o){const r=n-e.length,i=e.concat(new Array(n-e.length).fill(o)),s=0===e.length?n+1:r;return{nucleotides:i,ptoFlags:t.concat(new Array(s).fill(!0))}}}(ie||(ie={}));var ae=n(2543),le=n.n(ae);class ce{constructor(e,t){this.dataManager=e,this._patternListUpdated$=new te.Subject,this._patternLoadRequested$=new te.Subject,this._patternLoaded$=new te.Subject,this._uniqueNucleotides$=new te.BehaviorSubject([]),this._patternDeletionRequested$=new te.Subject,this._tableSelection$=new te.BehaviorSubject(null),this._svgSaveRequested$=new te.Subject,this._loadPatternInNewTabRequested$=new te.Subject,this._urlStateUpdated$=new te.Subject,this._patternHasUnsavedChanges$=new te.BehaviorSubject(!1),this._selectedStrandColumn=new te.BehaviorSubject(null),this._selectedIdColumn=new te.BehaviorSubject(null),this.initializeAuthorSelection(t),this.initializePatternState(t),this._lastLoadedPatternConfig=new te.BehaviorSubject(le().cloneDeep(this.getPatternConfig())),this.setupSubscriptions()}setupSubscriptions(){this._nucleotideSequences$.subscribe((()=>{this.updateUniqueNucleotides(),this.updateSequenceBase()})),this._isAntisenseStrandActive$.subscribe((e=>{e||G.forEach((e=>{this.updateTerminusModification("AS",e,"")}))})),this.patternStateChanged$.pipe((0,ne.debounceTime)(20)).subscribe((()=>{const e=this._lastLoadedPatternConfig.getValue(),t=this.getPatternConfig(),n=!le().isEqual(t,e);this._patternHasUnsavedChanges$.next(n)}))}updateUniqueNucleotides(){const e=(t=this._nucleotideSequences$.getValue(),se(Object.values(t).flat()));var t;this._uniqueNucleotides$.next(e)}updateSequenceBase(){const e=re(this._nucleotideSequences$.getValue());this._sequenceBase$.next(e)}get nucleotideSequencesChanged$(){return this._nucleotideSequences$.asObservable()}initializeAuthorSelection(e){const t=e[q.AUTHOR_ID];this.dataManager.isCurrentUserId(t)?this._patternAuthorSelection$=new te.BehaviorSubject(this.dataManager.getCurrentUserAuthorshipCategory()):this._patternAuthorSelection$=new te.BehaviorSubject(this.dataManager.getOtherUsersAuthorshipCategory())}initializePatternState(e){const t=e[q.PATTERN_CONFIG];this._patternName$=new te.BehaviorSubject(t[j.PATTERN_NAME]),this._isAntisenseStrandActive$=new te.BehaviorSubject(t[V.IS_ANTISENSE_STRAND_INCLUDED]),this._nucleotideSequences$=new te.BehaviorSubject(t[V.NUCLEOTIDE_SEQUENCES]),this._phosphorothioateLinkageFlags=new te.BehaviorSubject(t[V.PHOSPHOROTHIOATE_LINKAGE_FLAGS]),this._terminalModifications=new te.BehaviorSubject(t[V.STRAND_TERMINUS_MODIFICATIONS]),this._comment$=new te.BehaviorSubject(t[j.PATTERN_COMMENT]),this._modificationsWithNumericLabels$=new te.BehaviorSubject(t[j.NUCLEOTIDES_WITH_NUMERIC_LABELS]),this._sequenceBase$=new te.BehaviorSubject(re(t[V.NUCLEOTIDE_SEQUENCES]))}getPatternName(){return this._patternName$.getValue()}updatePatternName(e){this._patternName$.next(e)}get antisenseStrandToggled$(){return this._isAntisenseStrandActive$.asObservable()}isAntisenseStrandActive(){return this._isAntisenseStrandActive$.getValue()}toggleAntisenseStrand(e){e?this.updateStrandLength("AS",this.getNucleotideSequences().SS.length):this.updateStrandLength("AS",0),this._isAntisenseStrandActive$.next(e)}getNucleotideSequences(){return this._nucleotideSequences$.getValue()}updateNucleotideSequences(e){this._nucleotideSequences$.next(e)}updateStrandLength(e,t){const n=this.getNucleotideSequences()[e];if(n.length===t)return;const o=this.getPhosphorothioateLinkageFlags()[e];if(0===t)return void this.setNewStrandData([],[],e);if(n.length>t){const{nucleotides:r,ptoFlags:i}=ie.getTruncatedStrandData(n,o,t);return void this.setNewStrandData(r,i,e)}const r=this.getSequenceBase(),{nucleotides:i,ptoFlags:s}=ie.getExtendedStrandData(n,o,t,r);this.setNewStrandData(i,s,e)}setNewStrandData(e,t,n){this.updateNucleotideSequences({...this.getNucleotideSequences(),[n]:e}),this.updatePhosphorothioateLinkageFlags({...this.getPhosphorothioateLinkageFlags(),[n]:t})}getPhosphorothioateLinkageFlags(){return this._phosphorothioateLinkageFlags.getValue()}updatePhosphorothioateLinkageFlags(e){this._phosphorothioateLinkageFlags.next(e)}get phosphorothioateLingeFlagsChanged$(){return this._phosphorothioateLinkageFlags.asObservable()}getTerminalModifications(){return this._terminalModifications.getValue()}updateTerminalModifications(e){this._terminalModifications.next(e)}updateTerminusModification(e,t,n){const o=this.getTerminalModifications();o[e][t]=n,this.updateTerminalModifications(o)}terminalModificationsUpdated$(){return this._terminalModifications.asObservable()}getComment(){return this._comment$.getValue()}updateComment(e){this._comment$.next(e)}getModificationsWithNumericLabels(){return this._modificationsWithNumericLabels$.getValue()}updateModificationsWithNumericLabels(e){const t=function(e){return se(e).filter((e=>!oe(e)))}(e);this._modificationsWithNumericLabels$.next(t)}get patternLoadRequested$(){return this._patternLoadRequested$.asObservable()}requestPatternLoad(e){this._patternLoadRequested$.next(e)}get patternListUpdated$(){return this._patternListUpdated$.asObservable()}updatePatternList(){this._patternListUpdated$.next()}get tableSelectionChanged$(){return this._tableSelection$.asObservable()}selectTable(e){this._tableSelection$.next(e)}getTableSelection(){return this._tableSelection$.getValue()}requestPatternDeletion(e){this._patternDeletionRequested$.next(e)}get patternDeletionRequested$(){return this._patternDeletionRequested$.asObservable()}replaceSequenceBase(e){const t=this._nucleotideSequences$.getValue(),n={};k.forEach((o=>{n[o]=t[o].map((()=>e))})),this._nucleotideSequences$.next(n);const o=this._modificationsWithNumericLabels$.getValue();o.includes(e)||this.updateModificationsWithNumericLabels(o.concat(e))}get patternStateChanged$(){return te.merge(this._patternName$.pipe((0,ne.debounceTime)(300),(0,ne.map)((()=>{}))),this._isAntisenseStrandActive$,this._nucleotideSequences$,this._phosphorothioateLinkageFlags,this._terminalModifications,this._comment$.pipe((0,ne.debounceTime)(300)),this._modificationsWithNumericLabels$)}getSequenceBase(){return this._sequenceBase$.getValue()}uniqueNucleotidesChanged$(){return this.patternStateChanged$.pipe((0,ne.switchMap)((()=>this._uniqueNucleotides$)))}getUniqueNucleotides(){return this._uniqueNucleotides$.getValue()}get svgSaveRequested$(){return this._svgSaveRequested$.asObservable()}requestSvgSave(){this._svgSaveRequested$.next()}setAllPTOLinkages(e){const t=this.getPhosphorothioateLinkageFlags();k.forEach((n=>{t[n]=t[n].map((()=>e))})),this.updatePhosphorothioateLinkageFlags(t)}setPatternConfig(e){this._patternName$.next(e[j.PATTERN_NAME]),this._isAntisenseStrandActive$.next(e[V.IS_ANTISENSE_STRAND_INCLUDED]),this._nucleotideSequences$.next(e[V.NUCLEOTIDE_SEQUENCES]),this._phosphorothioateLinkageFlags.next(e[V.PHOSPHOROTHIOATE_LINKAGE_FLAGS]),this._terminalModifications.next(e[V.STRAND_TERMINUS_MODIFICATIONS]),this._comment$.next(e[j.PATTERN_COMMENT]),this._modificationsWithNumericLabels$.next(e[j.NUCLEOTIDES_WITH_NUMERIC_LABELS])}setLastLoadedPatternConfig(e){this._lastLoadedPatternConfig.next(le().cloneDeep(e))}getPatternConfig(){return{[j.PATTERN_NAME]:this.getPatternName(),[V.IS_ANTISENSE_STRAND_INCLUDED]:this.isAntisenseStrandActive(),[V.NUCLEOTIDE_SEQUENCES]:this.getNucleotideSequences(),[V.PHOSPHOROTHIOATE_LINKAGE_FLAGS]:this.getPhosphorothioateLinkageFlags(),[V.STRAND_TERMINUS_MODIFICATIONS]:this.getTerminalModifications(),[j.PATTERN_COMMENT]:this.getComment(),[j.NUCLEOTIDES_WITH_NUMERIC_LABELS]:this.getModificationsWithNumericLabels()}}setPhosphorothioateLinkageFlag(e,t,n){const o=this.getPhosphorothioateLinkageFlags();o[e][t]=n,this.updatePhosphorothioateLinkageFlags(o)}setNucleotide(e,t,n){const o=this.getNucleotideSequences();o[e][t]=n;const r=this.getModificationsWithNumericLabels();this.updateModificationsWithNumericLabels(r.concat(n)),this.updateNucleotideSequences(o)}get strandsUpdated$(){return te.merge(this._isAntisenseStrandActive$.asObservable().pipe((0,ne.map)((()=>{}))),this._nucleotideSequences$.asObservable().pipe((0,ne.map)((()=>{}))),this._patternLoaded$.asObservable().pipe((0,ne.map)((()=>{})))).pipe((0,ne.debounceTime)(10))}get strandsLinkagesAndTerminalsUpdated$(){return te.merge(this.strandsUpdated$,this._phosphorothioateLinkageFlags.asObservable().pipe((0,ne.map)((()=>{}))),this._terminalModifications.asObservable().pipe((0,ne.map)((()=>{}))))}updateControlsUponPatternLoaded(e){this._patternLoaded$.next(e)}get patternLoaded$(){return this._patternLoaded$.asObservable()}get userSelection$(){return this._patternAuthorSelection$.asObservable().pipe((0,ne.skip)(1))}selectAuthor(e){if("string"!=typeof e)throw new Error("Selected user must be defined");this._patternAuthorSelection$.next(e)}getSelectedAuthor(){return this._patternAuthorSelection$.getValue()}get loadPatternInNewTabRequested$(){return this._loadPatternInNewTabRequested$.asObservable()}requestLoadPatternInNewTab(e){this._loadPatternInNewTabRequested$.next(e)}updateUrlState(e){this._urlStateUpdated$.next(e)}get urlStateUpdated$(){return this._urlStateUpdated$.asObservable()}get patternHasUnsavedChanges$(){return this._patternHasUnsavedChanges$.asObservable()}selectStrandColumn(e,t){this._selectedStrandColumn.next({...this._selectedStrandColumn.getValue(),[e]:t})}getSelectedStrandColumn(e){const t=this._selectedStrandColumn.getValue();return t?t[e]:null}selectIdColumn(e){this._selectedIdColumn.next(e)}getSelectedIdColumn(){return this._selectedIdColumn.getValue()}get updateSvgContainer$(){return this.patternStateChanged$.pipe((0,ne.debounceTime)(100))}}const ue="pattern";class he{constructor(){this.urlSearchParams=new URLSearchParams(window.location.search)}subscribeToObservables(e){e.urlStateUpdated$.subscribe((e=>this.setPatternURL(e))),e.loadPatternInNewTabRequested$.subscribe((e=>{const t=`${window.location.origin}${window.location.pathname}?${ue}=${e}`;window.open(t,"_blank")})),window.addEventListener("popstate",(()=>{this.urlSearchParams=new URLSearchParams(window.location.search);const t=this.getPatternHash();null!==t&&e.requestPatternLoad(t)}))}getPatternHash(){return this.urlSearchParams.get(ue)}setPatternURL(e){null!==e&&""!==e?(this.urlSearchParams.set(ue,e),window.history.pushState({},"",`${window.location.pathname}?${this.urlSearchParams}`)):this.clearPatternURL()}clearPatternURL(){this.urlSearchParams.delete(ue),window.history.pushState({},"",`${window.location.pathname}`)}}var de=n(5072),pe=n.n(de),me=n(7825),fe=n.n(me),ge=n(7659),ye=n.n(ge),be=n(5056),ve=n.n(be),Ce=n(540),xe=n.n(Ce),we=n(1113),Ae=n.n(we),Te=n(9252),Ee={};Ee.styleTagTransform=Ae(),Ee.setAttributes=ve(),Ee.insert=ye().bind(null,"head"),Ee.domAPI=fe(),Ee.insertStyleElement=xe(),pe()(Te.A,Ee),Te.A&&Te.A.locals&&Te.A.locals;class Se{constructor(e){this.eventBus=e,this.columnControlsContainer=P.div([]),this.eventBus.tableSelectionChanged$.subscribe((()=>this.handleTableChoice())),this.refreshColumnControls()}getColumnControlsContainer(){return this.columnControlsContainer}get selectedTable(){return this.eventBus.getTableSelection()}handleTableChoice(){this.refreshColumnControls()}refreshColumnControls(){L()(this.columnControlsContainer).empty(),L()(this.columnControlsContainer).append(this.constructColumnControls())}constructColumnControls(){const e=this.createStrandColumnInput(),t=e.SS,n=e.AS;this.eventBus.antisenseStrandToggled$.subscribe((e=>{L()(n).toggle(e)}));const o=this.createIdColumnInput();return[t,n,o]}createStrandColumnInput(){const e=this.selectedTable?this.selectedTable.columns.names().sort(((e,t)=>e.localeCompare(t))):[];return Object.fromEntries(k.map((t=>{const n=P.input.choice(`${H[t]} column`,{value:e[0],items:e,onValueChanged:e=>this.eventBus.selectStrandColumn(t,e)});return this.eventBus.selectStrandColumn(t,e[0]),[t,n.root]})))}createIdColumnInput(){const e=this.selectedTable?this.selectedTable.columns.names():[],t=P.input.choice("ID column",{value:e[0],items:e,onValueChanged:e=>this.eventBus.selectIdColumn(e)});return this.eventBus.selectIdColumn(e[0]),t.root}}class Ne{constructor(e){this.eventBus=e,this.availableTables=[],this.tableInputContainer=P.div([]),this.subscribeToTableEvents(),this.refreshTableInput()}getTableInputContainer(){return this.tableInputContainer}subscribeToTableEvents(){o.events.onTableAdded.subscribe((e=>this.handleTableAdded(e))),o.events.onTableRemoved.subscribe((e=>this.handleTableRemoved(e))),this.eventBus.tableSelectionChanged$.subscribe((()=>this.handleTableChoice()))}getTableFromEventData(e){if(!e&&e.args&&e.args.dataFrame instanceof r.DataFrame)throw new Error("EventData does not contain a dataframe",e);return e.args.dataFrame}handleTableAdded(e){const t=this.getTableFromEventData(e);this.availableTables.some((e=>e.name===t.name))||(this.availableTables.push(t),this.eventBus.selectTable(t),this.refreshTableInput())}handleTableRemoved(e){const t=this.getTableFromEventData(e);this.availableTables=this.availableTables.filter((e=>e.name!==t.name));const n=this.availableTables[0];this.eventBus.selectTable(n||null),this.refreshTableInput()}refreshTableInput(){const e=this.createTableInput();L()(this.tableInputContainer).empty(),this.tableInputContainer.append(e.root)}createTableInput(){const e=this.eventBus.getTableSelection();return P.input.table("Tables",{value:e,items:this.availableTables,onValueChanged:e=>{null!==e&&this.eventBus.selectTable(e)}})}handleTableChoice(){const e=this.eventBus.getTableSelection();e&&(this.isTableDisplayed(e)||this.displayTable(e))}isTableDisplayed(e){return o.shell.tableNames.includes(e.name)}displayTable(e){const t=o.shell.v;o.shell.addTableView(e),o.shell.v=t}}function Ie(e,t,n,o){const r=function(e,t,n){const o=new Array(e.length+t.filter((e=>e)).length+G.length);o[0]=n["5'"],o[o.length-1]=n["3'"];let r=1;return t[0]&&(o[r]="ps",r++),e.forEach(((e,n)=>{o[n+r]=e,t[n+1]&&(o[n+r+1]="ps",r++)})),o}(e.split("").map(((e,n)=>{const o=function(e,t,n){const o=Object.keys(n.patternAppData)[0],r=n.patternAppData[o][t].substitution;return e.replace(/([AGCTU])/,r)}(e,t[n],br.jsonData);return o})),n,o);return r.join("")}class Me{constructor(e){this.eventBus=e,this.tableInputManager=new Ne(e),this.columnInputManager=new Se(e)}createControls(){const e=P.h1("Bulk convert"),t=this.tableInputManager.getTableInputContainer(),n=this.columnInputManager.getColumnControlsContainer(),o=P.bigButton("Convert",(()=>this.processConvertButtonClick()));return[e,t,n,P.buttonsInput([o])]}processConvertButtonClick(){!function(e){const t=e.getTableSelection();if(!t)return void o.shell.warning("Please select a table");const n=k.filter((t=>!("AS"===t&&!e.isAntisenseStrandActive()))).map((t=>({strand:t,column:e.getSelectedStrandColumn(t)}))).filter((e=>e.column));if(0===n.length)return void o.shell.warning("Select a sense strand column");const r=e.getSelectedIdColumn();if(!r)throw new Error("No ID column selected");t.getCol(r);const i=n.map((e=>({strand:e.strand,column:t.getCol(e.column)})));!function(e,t){const n=t.getNucleotideSequences();return e.every((e=>{const t=n[e.strand].length;return e.column.toList().every((e=>e.length===t))}))}(i,e)?o.shell.warning("Some strands in the table input do not match pattern length"):i.forEach((n=>{const o=n.column,r=n.strand,i=e.getNucleotideSequences()[r],s=e.getTerminalModifications()[r],a=e.getPhosphorothioateLinkageFlags()[r],l=`${e.getPatternName()}(${o.name})`;t.columns.addNewString(l).init((e=>Ie(o.get(e),i,a,s)))}))}(this.eventBus)}}class Pe{constructor(e,t,n){this.eventBus=e,this.initialPatternConfig=t,this.subscriptions=n}create(){return P.divV([P.h1("PTO"),P.divH([this.createAllPtoActivationInput().root,...this.createFirstPtoInputs().map((e=>e.root))],{style:{gap:"12px"}})])}areAllPtoLinkagesSet(e){return k.map((t=>e[t].filter((e=>e)).length)).reduce(((e,t)=>e+t),0)===k.map((e=>this.initialPatternConfig.nucleotideSequences[e].length)).reduce(((e,t)=>e+t),0)+k.filter((t=>e[t].length)).length}createAllPtoActivationInput(){const e=this.initialPatternConfig.phosphorothioateLinkageFlags,t=this.areAllPtoLinkagesSet(e),n=P.input.bool("All PTO",{value:t});n.onInput.subscribe((()=>{const e=n.value;this.eventBus.setAllPTOLinkages(e)}));const o=this.eventBus.phosphorothioateLingeFlagsChanged$.subscribe((()=>{const e=this.eventBus.getPatternConfig().phosphorothioateLinkageFlags,t=this.areAllPtoLinkagesSet(e);n.value=t}));return this.subscriptions.add(o),this.addStyleToPtoInput(n),P.tooltip.bind(n.captionLabel,"Activate all phosphothioates"),n}addStyleToPtoInput(e){const t=e.captionLabel;t.classList.add("ui-label-right"),Object.assign(t.style,{textAlign:"left",maxWidth:"100px",minWidth:"40px",width:"auto"})}createFirstPtoInputs(){return k.map((e=>{if(!this.eventBus.isAntisenseStrandActive()&&"AS"===e)return;const t=this.isFirstPtoActive(e),n=P.input.bool(`First ${e} PTO`,{value:t});n.onInput.subscribe((()=>{const t=n.value;this.eventBus.setPhosphorothioateLinkageFlag(e,0,t)}));const o=this.eventBus.phosphorothioateLingeFlagsChanged$.subscribe((t=>{const o=t[e][0];n.value=o}));return this.subscriptions.add(o),this.addStyleToPtoInput(n),P.tooltip.bind(n.captionLabel,`Activate first phosphothioate in ${e}`),n})).filter((e=>void 0!==e))}isFirstPtoActive(e){return this.initialPatternConfig.phosphorothioateLinkageFlags[e][0]}}class _e{constructor(e,t,n){this.eventBus=e,this.dataManager=t,this.subscriptions=n;const o=this.eventBus.nucleotideSequencesChanged$.subscribe((()=>{this.displayedInputLabels=this.computeDisplayedInputLabels()}));this.subscriptions.add(o)}create(){const e=k.map((e=>this.constructControlsPanel(e)));return P.divH(e,{style:{gap:"24px"}})}constructControlsPanel(e){if(!this.eventBus.isAntisenseStrandActive()&&"AS"===e)return P.div([]);const t=this.constructHeader(),n=this.createControls(e);return P.block([P.h1(`${H[e]}`),t,n],{style:{paddingTop:"12px"}})}constructHeader(){return P.divH([P.div([P.divText("#")],{style:{width:"20px"}}),P.block75([P.divText("Modification")]),P.div([P.divText("PTO")])])}createControls(e){const t=this.createNucleobaseInputs(e),n=this.createLabelDivs(e),o=this.createPTOFlagInputs(e);return P.div(t.map(((e,t)=>P.divH([n[t],P.block75([e.root]),o[t].root],{style:{alignItems:"center"}}))))}createNucleobaseInputs(e){const t=this.dataManager.fetchAvailableNucleotideBases().sort(((e,t)=>e.toLowerCase().localeCompare(t.toLowerCase())));return this.eventBus.getNucleotideSequences()[e].map(((n,o)=>{const r=P.input.choice("",{value:n,items:t});return r.onInput.subscribe((()=>{const t=r.value;this.eventBus.setNucleotide(e,o,t)})),r}))}createPTOFlagInputs(e){return this.eventBus.getPhosphorothioateLinkageFlags()[e].slice(1).map(((t,n)=>{const o=P.input.bool("",{value:t});o.onInput.subscribe((()=>{const t=o.value;this.eventBus.setPhosphorothioateLinkageFlag(e,n+1,t)}));const r=this.eventBus.phosphorothioateLingeFlagsChanged$.subscribe((t=>{const r=t[e][n+1];o.value=r}));return this.subscriptions.add(r),o}))}computeDisplayedInputLabels(){const e=this.eventBus.getNucleotideSequences(),t=new Map;return k.forEach((n=>{let o=1;const r=e[n].map((e=>{if(oe(e))return"";const t=String(o);return o++,t}));t.set(n,r)})),t}createLabelDivs(e){const t=this.createLabels(e).map((e=>P.div([e],{style:{width:"20px"}}))),n=this.eventBus.nucleotideSequencesChanged$.subscribe((()=>{this.createLabels(e).forEach(((e,n)=>{L()(t[n]).empty(),L()(t[n]).append(e)}))}));return this.subscriptions.add(n),t}createLabels(e){return this.eventBus.getNucleotideSequences()[e].map(((t,n)=>{const o=this.displayedInputLabels.get(e)[n];return P.label(o)}))}}class Le{constructor(){this.rxjsSubscriptions=[],this.dgSubscriptions=[]}add(e){e instanceof te.Subscription?this.rxjsSubscriptions.push(e):this.dgSubscriptions.push(e)}unsubscribeAll(){for(const e of[this.rxjsSubscriptions,this.dgSubscriptions])e.forEach((e=>e.unsubscribe())),e.length=0}}class Oe{constructor(e,t){this.eventBus=e,this.dataManager=t,this.subscriptions=new Le}static open(e,t){Oe.isDialogOpen||(Oe.instance||(Oe.instance=new Oe(e,t)),Oe.instance.openDialog())}openDialog(){this.initialPatternConfig=le().cloneDeep(this.eventBus.getPatternConfig()),Oe.isDialogOpen=!0,this.createDialog().show()}createDialog(){const e=P.divV([]);this.subscriptions.add(this.eventBus.strandsUpdated$.subscribe((()=>this.onStrandsUpdated(e))));const t=P.dialog("Edit strands").add(e).onOK((()=>{})).onCancel((()=>this.resetToInitialState()));return this.subscriptions.add(t.onClose.subscribe((()=>{Oe.isDialogOpen=!1,this.subscriptions.unsubscribeAll()}))),t}onStrandsUpdated(e){const t=new Pe(this.eventBus,this.initialPatternConfig,this.subscriptions).create(),n=new _e(this.eventBus,this.dataManager,this.subscriptions).create();L()(e).empty(),L()(e).append(t,n)}resetToInitialState(){this.eventBus.setPatternConfig(this.initialPatternConfig)}}Oe.isDialogOpen=!1;class Re{constructor(e){this.eventBus=e,this.subscriptions=new Le}static open(e){Re.isDialogOpen||(Re.instance||(Re.instance=new Re(e)),Re.instance.openDialog())}openDialog(){this.initialPatternConfig=le().cloneDeep(this.eventBus.getPatternConfig()),Re.isDialogOpen=!0,this.createDialog().show()}createDialog(){const e=P.divV([]);this.subscriptions.add(this.eventBus.strandsUpdated$.subscribe((()=>this.onStrandsUpdated(e))));const t=P.dialog("Edit terminal modifications").add(e).onOK((()=>{})).onCancel((()=>this.resetToInitialState()));return this.subscriptions.add(t.onClose.subscribe((()=>{Re.isDialogOpen=!1,this.subscriptions.unsubscribeAll()}))),t}onStrandsUpdated(e){const t=new $e(this.eventBus).create();L()(e).empty(),L()(e).append(t)}resetToInitialState(){this.eventBus.setPatternConfig(this.initialPatternConfig)}}Re.isDialogOpen=!1;class $e{constructor(e){this.eventBus=e}create(){const e=k.map((e=>this.constructControlsPanel(e)));return P.divH(e,{style:{gap:"24px"}})}constructControlsPanel(e){if(!this.eventBus.isAntisenseStrandActive()&&"AS"===e)return P.div([]);const t=this.createInputs(e);return P.block([P.h1(`${H[e]}`),t],{style:{paddingTop:"12px"}})}createInputs(e){const t=("SS"===e?[...G].reverse():G).map((t=>this.createInputForTerminus(e,t)));return P.form(t)}createInputForTerminus(e,t){const n=this.eventBus.getTerminalModifications()[e][t],o=P.input.textArea(t,{value:n});return this.applyStylingToInput(o),o.onInput.subscribe((()=>{const n=o.value;null!==n&&this.eventBus.updateTerminusModification(e,t,n)})),o}applyStylingToInput(e){const t=e.root.getElementsByTagName("textarea")[0];L()(t).css("resize","none")}}class De{constructor(e,t){this.eventBus=e,this.dataManager=t}createControls(){const e=this.createAntisenseStrandToggle(),t=this.createStrandLengthInputs(),n=t.SS.root,o=t.AS.root,r=this.createSequenceBaseInput().root,i=this.createPatternCommentInput().root,s=this.createPatternNameInputBlock(),a=this.createEditPatternButton(),l=this.createEditTerminalModificationsButton();return[P.h1("Edit"),e,n,o,r,s,i,P.buttonsInput([l,a])]}createEditPatternButton(){const e=P.button("Edit strands",(()=>Oe.open(this.eventBus,this.dataManager)));return P.tooltip.bind(e,"Edit strand modifications and PTOs"),e}createEditTerminalModificationsButton(){const e=P.button("Edit terminals",(()=>Re.open(this.eventBus)));return P.tooltip.bind(e,"Edit terminal modifications"),L()(e).css("margin-right","20px"),e}createAntisenseStrandToggle(){const e=P.input.toggle(`${H.AS} strand`,{value:this.eventBus.isAntisenseStrandActive()});return e.onInput.subscribe((()=>this.eventBus.toggleAntisenseStrand(e.value))),this.eventBus.patternLoaded$.subscribe((()=>{e.value=this.eventBus.isAntisenseStrandActive()})),e.setTooltip("Toggle antisense strand"),e.root}createStrandLengthInputs(){const e=e=>{const n=this.eventBus.getNucleotideSequences()[e].length,o=P.input.int(`${H[e]} length`,{value:n});return o.onInput.subscribe((()=>t(e,o))),this.eventBus.nucleotideSequencesChanged$.subscribe((()=>{o.value=this.eventBus.getNucleotideSequences()[e].length})),o.setTooltip(`Number of nucleotides in ${e}, including overhangs`),[e,o]},t=(e,t)=>{const n=t.value;null!==n&&(n<=0&&(o.shell.warning("Sequence length must be greater than 0"),t.value=1),n>34&&(o.shell.warning("Sequence length must be less than 35"),t.value=34),this.eventBus.updateStrandLength(e,t.value))},n=Object.fromEntries(k.map((t=>e(t))));return this.eventBus.antisenseStrandToggled$.subscribe((e=>{L()(n.AS.root).toggle(e)})),n}createSequenceBaseInput(){const e=this.dataManager.fetchAvailableNucleotideBases().sort(((e,t)=>e.toLowerCase().localeCompare(t.toLowerCase()))),t=this.dataManager.fetchDefaultNucleobase(),n=P.input.choice("Sequence basis",{value:t,items:e});return n.onInput.subscribe((()=>this.eventBus.replaceSequenceBase(n.value))),this.eventBus.nucleotideSequencesChanged$.subscribe((()=>{n.value=this.eventBus.getSequenceBase()})),n.setTooltip("Most frequent nucleobase in the strands"),n}createPatternCommentInput(){const e=P.input.textArea("Comment",{value:this.eventBus.getComment()});return L()(e.root).addClass("st-pattern-text-input"),e.onInput.subscribe((()=>this.eventBus.updateComment(e.value))),this.eventBus.patternLoaded$.subscribe((()=>{e.value=this.eventBus.getComment()})),e}createPatternNameInputBlock(){const e=P.input.textArea("Pattern name",{value:this.eventBus.getPatternName()});return L()(e.root).addClass("st-pattern-text-input"),e.onInput.subscribe((()=>this.eventBus.updatePatternName(e.value))),this.eventBus.patternLoaded$.subscribe((()=>{e.value=this.eventBus.getPatternName()})),e.setTooltip("Name under which pattern will be saved"),e.root}}class Be{constructor(e,t){this.eventBus=e,this.dataManager=t,this.subscriptions=new Le,this.authorSelectedByUser=!1,this.eventBus.patternLoadRequested$.subscribe((e=>this.handlePatternChoice(e))),this.eventBus.patternDeletionRequested$.subscribe((async e=>{await this.dataManager.deletePattern(e,this.eventBus)}))}async handlePatternChoice(e){let t=await this.dataManager.getPatternConfig(e);null===t&&(t=this.dataManager.getDefaultPatternConfig()),this.eventBus.setPatternConfig(t),this.eventBus.updateControlsUponPatternLoaded(e),this.eventBus.setLastLoadedPatternConfig(t)}isCurrentUserSelected(){return this.eventBus.getSelectedAuthor()!==this.dataManager.getOtherUsersAuthorshipCategory()}createControls(){const e=this.getPatternInputsContainer();return[P.h1("Load"),e]}getPatternInputsContainer(){const e=P.divH(this.createPatternInputs());return this.eventBus.patternListUpdated$.subscribe((()=>{this.subscriptions.unsubscribeAll(),L()(e).empty(),L()(e).append(this.createPatternInputs())})),e}createPatternInputs(){const e=this.createAuthorChoiceInput(),t=this.createPatternChoiceInputContainer(),n=this.createDeletePatternButton();return[e.root,t,n]}createPatternChoiceInputContainer(){const e=this.createPatternChoiceInput(),t=P.div([e.root]),n=this.eventBus.userSelection$.subscribe((()=>{L()(t).empty(),L()(t).append(this.createPatternChoiceInput().root)}));return this.subscriptions.add(n),t}createAuthorChoiceInput(){const e=[this.dataManager.getCurrentUserAuthorshipCategory()];this.dataManager.getOtherUsersPatternNames().length>0&&e.push(this.dataManager.getOtherUsersAuthorshipCategory());const t=P.input.choice("Author",{value:this.eventBus.getSelectedAuthor(),items:e});return t.onInput.subscribe((()=>{if(this.authorSelectedByUser=!0,null===t.value)throw new Error("author choice must be non-null");this.eventBus.selectAuthor(t.value)})),this.setAuthorChoiceInputStyle(t),t.setTooltip("Select pattern author"),t}setAuthorChoiceInputStyle(e){L()(e.input).css({"max-width":"100px","min-width":"100px"}),L()(e.root).css({"padding-right":"30px","padding-left":"30px"})}createPatternChoiceInput(){const e=this.isCurrentUserSelected()?this.dataManager.getCurrentUserPatternNames():this.dataManager.getOtherUsersPatternNames();if(this.authorSelectedByUser){const t=this.dataManager.getPatternHash(e[0],this.isCurrentUserSelected());this.eventBus.requestPatternLoad(t),this.eventBus.updateUrlState(t),this.authorSelectedByUser=!1}const t=this.getPatternName(e),n=P.input.choice("Pattern",{value:t,items:e});return n.setTooltip("Select pattern to load"),L()(n.input).css({"max-width":"100px","min-width":"100px"}),this.subscriptions.add(n.onInput.subscribe((()=>{const e=this.dataManager.getPatternHash(n.value,this.isCurrentUserSelected());this.eventBus.requestPatternLoad(e),this.eventBus.updateUrlState(e)}))),this.subscriptions.add(this.eventBus.patternLoaded$.subscribe((()=>{const t=this.eventBus.getPatternName();n.value!==t&&(n.value=this.getPatternName(e))}))),n}getPatternName(e){return e.find((e=>e.split(" (")[0]===this.eventBus.getPatternName()))??e[0]}createDeletePatternButton(){const e=P.button(P.iconFA("trash-alt"),(()=>{this.eventBus.getPatternName()!==this.dataManager.getDefaultPatternName()?this.showDeletePatternDialog():o.shell.warning("Cannot delete example pattern")}));P.tooltip.bind(e,"Delete pattern from user storage");const t=this.eventBus.userSelection$.subscribe((()=>{e.disabled=!this.isCurrentUserSelected()}));return this.subscriptions.add(t),e}showDeletePatternDialog(){const e=P.dialog("Delete pattern"),t=this.eventBus.getPatternName();e.add(P.divText(`Are you sure you want to delete pattern ${t}?`)),e.onOK((()=>this.eventBus.requestPatternDeletion(t))),e.show()}}class Fe{constructor(e,t){this.eventBus=e,this.dataManager=t}getLayout(){const e=new Be(this.eventBus,this.dataManager),t=new De(this.eventBus,this.dataManager),n=new Me(this.eventBus),o=e.createControls(),r=t.createControls(),i=n.createControls(),s=P.div(o);L()(s).css({"padding-bottom":"20px"});const a=P.div([...r,...i],"ui-form"),l=P.div([s,a]);return L()(l).css({padding:"25px"}),P.box(l,{style:{maxWidth:"450px"}})}}var ke=n(9146);class He{constructor(e,t,n){this.svgElementFactory=e,this.config=t,this.yShift=n}shiftElements(e){this.svgElements.forEach((t=>{const n=t.getAttribute("transform")||"",o=`translate(${e.x},${e.y})`;t.setAttribute("transform",`${n} ${o}`)}))}}class Ge{constructor(){}static getInstance(){return Ge.instance||(Ge.instance=new Ge,Ge.instance.canvas=document.createElement("canvas")),Ge.instance}static getTextDimensions(e,t){const n=Ge.getInstance().canvas.getContext("2d");if(!n)throw new Error("Canvas 2D context is not available");return n.font=`${t}px Arial`,{width:1.1*n.measureText(e).width,height:1.1*t}}}function Ue(e){const t=Object.keys(br.jsonData.patternAppData)[0];if(!t)throw new Error(`No format found in '${h}'`);return br.jsonData.patternAppData[t][e].color||""}class Ve extends He{constructor(e,t,n){super(e,t,n);const o=k.filter((e=>t.nucleotideSequences[e].length>0));this.strands=o.map((e=>new je(this.svgElementFactory,t,n,e))),this.terminalModifications=o.map(((e,o)=>new We(this.svgElementFactory,t,n,e,this.strands[o]))),this.labels=o.map(((e,o)=>new qe(this.svgElementFactory,t,n,e,this.terminalModifications[o])))}get svgElements(){return[...this.strands,...this.terminalModifications,...this.labels].map((e=>e.svgElements)).flat()}getContentWidth(){return Math.max(...this.labels.map((e=>e.getContentWidth())))}getContentHeight(){return this.strands.reduce(((e,t)=>e+t.getContentHeight()),0)}}class je extends He{constructor(e,t,n,o){super(e,t,n),this.svgElementFactory=e,this.config=t,this.yShift=n,this.strand=o,this.nucleotideNumericLabels=this.computeNucleotideNumericLabels(),"AS"===this.strand&&(this.config.phosphorothioateLinkageFlags[this.strand].reverse(),this.config.nucleotideSequences[this.strand].reverse(),this.nucleotideNumericLabels.reverse()),this._svgElements=[this.createStrandCircles(),this.createPTOLinkageStars()].flat()}computeNucleotideNumericLabels(){let e=0;return this.config.nucleotideSequences[this.strand].map((t=>oe(t)?null:(e++,e)))}get svgElements(){return this._svgElements}getStrandCircleYShift(){return ze(this.strand,this.yShift)}createStrandCircles(){const e={x:80,y:this.getStrandCircleYShift()};return this.config.nucleotideSequences[this.strand].map(((t,n)=>this.createNucleotideElementGroup(t,n,e))).flat()}createNucleotideElementGroup(e,t,n){return[...this.createNucleotideCircleElements(e,t,n),this.config.nucleotidesWithNumericLabels.includes(e)?this.createNucleotideNumericLabel(t,n):null].filter((e=>null!==e))}createNucleotideCircleElements(e,t,n){const o=Ue(e),r={...n,x:n.x+30*t};return[this.svgElementFactory.createCircleElement(r,15,o),this.createNucleotideLetterLabel(t,n,e)]}getNucleotideCircleCenterPosition(e,t){return{x:t.x+30*e,y:t.y}}createNucleotideLetterLabel(e,t,n){if(!f.AL.includes(n))return null;const o=function(e){return!oe(e)&&f.AL.includes(e)?e:""}(n),r=function(e){const t=Ue(e),n=t.match(/\d+/g)?.map(Number);if(!n||n.length<3)return"#ffffff";const[o,r,i]=n;return.299*o+.587*r+.114*i>186?"#333333":"#ffffff"}(n),i=this.getPositionForNucleotideLabel(e,t);return this.svgElementFactory.createTextElement(o,i,17,r)}getPositionForNucleotideLabel(e,t){const n=this.getNucleotideCircleCenterPosition(e,t),o=Ge.getTextDimensions("A",17);return{x:n.x-o.width/2,y:n.y+o.height/3}}getNumericLabelYShift(e){return"SS"===this.strand?e.y-20:e.y+15+5+15}createNucleotideNumericLabel(e,t){const n=this.nucleotideNumericLabels[e];if(null===n)return null;const o=Ge.getTextDimensions(n.toString(),15).width,r={x:t.x+30*e-o/2,y:this.getNumericLabelYShift(t)};return this.svgElementFactory.createTextElement(n.toString(),r,15,"var(--grey-6)")}createPTOLinkageStars(){const e=this.config.phosphorothioateLinkageFlags[this.strand],t=this.getStrandCircleYShift()+12;return e.map(((e,n)=>{if(!e)return null;const o={x:65+30*n,y:t};return this.svgElementFactory.createStarElement(o,"red")})).filter((e=>null!==e))}getContentWidth(){return 30*this.config.nucleotideSequences[this.strand].length}getContentHeight(){return 62}}class qe extends He{constructor(e,t,n,o,r){super(e,t,n),this.svgElementFactory=e,this.config=t,this.yShift=n,this.strand=o,this.terminalModifications=r,this._svgElements=this.createSVGElements()}createSVGElements(){return[this.createLeftLabel(),this.createRightLabel()]}getLeftLabelWidth(){return 55}getRightLabelWidth(){return 20}createLeftLabel(){const e="SS"===this.strand?"5'":"3'",t=`${this.strand}: ${e} `,n=Ge.getTextDimensions(t,17),o={x:10,y:ze(this.strand,this.yShift)+n.height/3};return this.svgElementFactory.createTextElement(t,o,17,"var(--grey-6)")}createRightLabel(){const e=" "+("SS"===this.strand?"3'":"5'"),t=Ge.getTextDimensions(e,17),n={x:65+this.terminalModifications.getContentWidth()+5,y:ze(this.strand,this.yShift)+t.height/3};return this.svgElementFactory.createTextElement(e,n,17,"var(--grey-6)")}get svgElements(){return this._svgElements}getContentWidth(){return this.terminalModifications.getContentWidth()+this.getLeftLabelWidth()+this.getRightLabelWidth()+10}getContentHeight(){return this.terminalModifications.getContentHeight()}}class We extends He{constructor(e,t,n,o,r){super(e,t,n),this.svgElementFactory=e,this.config=t,this.yShift=n,this.strand=o,this.strandSvgWrapper=r,this._svgElements=this.createSVGElements()}createSVGElements(){return this.createTerminalModifications()}getTerminalModification(e){return this.config.strandTerminusModifications[this.strand][e]}getTerminalModificationTextDimensions(e){const t=this.getTerminalModification(e);return Ge.getTextDimensions(t,17)}getLeftTerminus(){return"SS"===this.strand?"5'":"3'"}createTerminalModification(e){const t=this.getTerminalModification(e),n=this.getTerminalModificationTextDimensions(e),o=e===this.getLeftTerminus(),r={x:o?65:65+this.getTerminalModificationTextDimensions(this.getLeftTerminus()).width+this.strandSvgWrapper.getContentWidth(),y:ze(this.strand,this.yShift)+n.height/3};return o&&this.strandSvgWrapper.shiftElements({x:n.width,y:0}),this.svgElementFactory.createTextElement(t,r,17,"red")}createTerminalModifications(){return("AS"===this.strand?G:Array.from(G).reverse()).map((e=>this.createTerminalModification(e)))}get svgElements(){return this._svgElements}getContentWidth(){return this.strandSvgWrapper.getContentWidth()+G.map((e=>this.getTerminalModificationTextDimensions(e).width)).reduce(((e,t)=>e+t),0)}getContentHeight(){return this.strandSvgWrapper.getContentHeight()}}function ze(e,t){return"SS"===e?t+5+15+15:t+52+10+15}class Ye{constructor(){this.xmlNamespace="http://www.w3.org/2000/svg"}createElement(e){return document.createElementNS(this.xmlNamespace,e)}setAttributes(e,t){Object.entries(t).forEach((([t,n])=>{e.setAttribute(t,String(n))}))}createCanvas(e,t){const n=this.createElement("svg");return this.setAttributes(n,{id:"mySvg",width:e,height:t}),n}createCircleElement(e,t,n){const o=this.createElement("circle");return this.setAttributes(o,{cx:e.x,cy:e.y,r:t,fill:n}),o}createTextElement(e,t,n,o){const r=this.createElement("text");return this.setAttributes(r,{x:t.x,y:t.y,"font-size":n,"font-weight":"normal","font-family":"Arial",fill:o}),r.textContent=e,r}createStarElement(e,t){const n=this.createElement("polygon"),o=this.computeStarVertexCoordinates(e).map((e=>e.join(","))).join(" ");return this.setAttributes(n,{points:o,fill:t}),n}computeStarVertexCoordinates(e){const t=Math.PI/5,n=-t/2;return Array.from({length:10},((o,r)=>{const i=r%2==0?6:3,s=r*t+n;return[e.x+Math.cos(s)*i,e.y+Math.sin(s)*i]}))}createRectangleElement(e,t,n,o){const r=this.createElement("rect");return this.setAttributes(r,{x:e.x,y:e.y,width:t,height:n,fill:o}),r}}class Ke extends He{constructor(e,t,n){super(e,t,n),this.svgElementFactory=e,this.config=t,this.yShift=n,this._svgElements=[],this.titleText=this.getTitleText(),this._svgElements=[this.getTitle()]}get svgElements(){return this._svgElements}getTitle(){return this.svgElementFactory.createTextElement(this.titleText,{x:15,y:this.yShift+17},17,"black")}getContentWidth(){return Ge.getTextDimensions(this.titleText,17).width}getContentHeight(){return Ge.getTextDimensions(this.titleText,17).height}getTitleText(){const e=`${this.config.nucleotideSequences.SS.length}`,t=this.config.isAntisenseStrandIncluded?`/${this.config.nucleotideSequences.AS.length}`:"";return`${this.config.patternName} for ${e}${t}-mer`}}class Qe extends He{constructor(e,t,n){super(e,t,n),this._svgElements=[];const{elements:o,width:r}=this.createLegendItems();this._svgElements=o,this.width=r}isPhosphorothioatePresent(){return Object.values(this.config.phosphorothioateLinkageFlags).flat().some((e=>e))}getModificationTypesList(){return[...new Set(Object.values(this.config.nucleotideSequences).flat().sort(((e,t)=>e.toLowerCase().localeCompare(t.toLowerCase()))))]}get svgElements(){return this._svgElements}createLegendItem(e,t){const n={x:t,y:this.yShift-6},o=e.includes("linkage")?this.svgElementFactory.createStarElement(n,"red"):this.svgElementFactory.createCircleElement(n,6,Ue(e));t+=12;const r={y:this.yShift,x:t};return{elements:[o,this.svgElementFactory.createTextElement(e,r,15,"var(--grey-6)")],width:12+Ge.getTextDimensions(e,15).width}}createLegendItems(){let e=10;const t=[],n=t=>e+=t+15;if(this.isPhosphorothioatePresent()){const{elements:o,width:r}=this.createLegendItem("PTO linkage",e);n(r),t.push(o)}return this.getModificationTypesList().forEach((o=>{const{elements:r,width:i}=this.createLegendItem(o,e);n(i),t.push(r)})),{elements:t.flat(),width:e}}getContentHeight(){return 20}getContentWidth(){return this.width}}class Je{constructor(e){this.svgElementFactory=new Ye;const t=le().cloneDeep(e);let n=10;this.title=new Ke(this.svgElementFactory,t,n),n+=this.title.getContentHeight(),this.strands=new Ve(this.svgElementFactory,t,n),n+=this.strands.getContentHeight()+10,this.legend=new Qe(this.svgElementFactory,t,n)}renderPattern(){const e=this.getGlobalWidth(),t=this.getGlobalHeight(),n=this.svgElementFactory.createCanvas(e,t),o=[this.title,this.strands,this.legend].map((e=>e.svgElements)).flat();return n.append(...o),n}getGlobalWidth(){const e=[this.title,this.strands,this.legend];return Math.max(...e.map((e=>e.getContentWidth())))}getGlobalHeight(){return[this.title,this.strands,this.legend].reduce(((e,t)=>e+t.getContentHeight()),10)}}class Xe{constructor(e){this.eventBus=e,this.svgDisplayDiv=P.div([]),e.updateSvgContainer$.subscribe((()=>this.updateSvgContainer())),e.svgSaveRequested$.subscribe((()=>this.saveSvgAsPng()))}static createSvgDiv(e){return new Xe(e).svgDisplayDiv}updateSvgContainer(){$(this.svgDisplayDiv).empty();const e=this.eventBus.getPatternConfig();this.svgElement=this.createSvg(e),this.svgDisplayDiv.append(this.svgElement)}createSvg(e){return new Je(e).renderPattern()}saveSvgAsPng(){const e=this.eventBus.getPatternName();ke.saveSvgAsPng(this.svgElement,e,{backgroundColor:"white"})}}class Ze{constructor(e){this.eventBus=e,this.togglesContainer=P.div([]),this.eventBus.uniqueNucleotidesChanged$().subscribe((()=>{this.updateContainer()}))}getContainer(){return this.togglesContainer}updateContainer(){L()(this.togglesContainer).empty(),L()(this.togglesContainer).append(this.createInputs())}createInputs(){const e=this.eventBus.getUniqueNucleotides().filter((e=>!oe(e))).map((e=>this.createSingleInput(e)));return e.sort(((e,t)=>e.captionLabel.textContent.localeCompare(t.captionLabel.textContent))),P.divH(e.map((e=>e.root)))}createSingleInput(e){const t=this.eventBus.getModificationsWithNumericLabels().includes(e),n=P.input.bool(e,{value:t,onValueChanged:t=>this.handleNumericLabelToggle(e,t)});return L()(n.root).css("padding-right","20px"),n.setTooltip(`Show numeric labels for ${e}`),n}handleNumericLabelToggle(e,t){const n=this.eventBus.getModificationsWithNumericLabels();if(n.includes(e)===t)return;const o=t?n.concat(e):n.filter((t=>t!==e));this.eventBus.updateModificationsWithNumericLabels(o)}}class et{constructor(e,t){this.eventBus=e,this.dataManager=t,this.subscriptions=new Le}createContainer(){return P.div([P.h1("Translation example"),this.createTranslationExamples()],{style:{paddingTop:"20px"}})}createTranslationExamples(){const e=P.divH([...this.getExampleElements()],"ui-form");return this.eventBus.antisenseStrandToggled$.subscribe((()=>{this.subscriptions.unsubscribeAll(),L()(e).empty(),L()(e).append(this.getExampleElements())})),e}getExampleElements(){return k.map((e=>new tt(e,this.eventBus,this.subscriptions).create()))}}class tt{constructor(e,t,n){this.strand=e,this.eventBus=t,this.subscriptions=n}create(){return this.eventBus.isAntisenseStrandActive()||"AS"!==this.strand?(this.inputExample=this.createInputExample(),this.outputExample=this.createOutputExample(this.inputExample.value),this.subscribeToEvents(),P.block50([P.h2(H[this.strand]),this.inputExample.root,this.outputExample.root],{style:{paddingRight:"20px"}})):P.div([])}subscribeToEvents(){const e=this.eventBus.strandsLinkagesAndTerminalsUpdated$.subscribe((()=>{const e=this.generateExampleSequence();this.inputExample.value=e,this.outputExample.value=this.computeOutputValue(e)}));"AS"===this.strand&&this.subscriptions.add(e)}createInputExample(){const e=this.createTextInputForExamples(),t=this.generateExampleSequence();return e.value=t,e.setTooltip(`Example raw nucleotides input for ${H[this.strand]}`),e}generateExampleSequence(){return this.eventBus.getNucleotideSequences()[this.strand].map(((e,t)=>f.AL[t%f.AL.length])).join("")}createOutputExample(e){const t=this.createTextInputForExamples();return t.value=this.computeOutputValue(e),t.setTooltip(`Pattern applied to the example input for ${H[this.strand]}`),t}computeOutputValue(e){const t=this.eventBus.getNucleotideSequences()[this.strand],n=this.eventBus.getTerminalModifications()[this.strand];return Ie(e,t,this.eventBus.getPhosphorothioateLinkageFlags()[this.strand],n)}createTextInputForExamples(){const e=P.input.textArea("",{value:""});return this.applyStylingToInput(e),e}applyStylingToInput(e){const t=e.root.getElementsByTagName("textarea")[0];t.setAttribute("readonly","true"),L()(t).css("resize","none"),L()(e.root).css("opacity","75%")}}class nt{constructor(e,t){this.eventBus=e,this.dataManager=t,this.svgDisplay=Xe.createSvgDiv(e)}getLayout(){const e=new Ze(this.eventBus).getContainer(),t=this.generateDownloadControls(),n=new et(this.eventBus,this.dataManager).createContainer();return P.panel([this.svgDisplay,e,t,n],{style:{overflowX:"scroll",padding:"12px 24px"}})}generateDownloadControls(){return P.divH([this.createSavePatternButton(),this.createDownloadPngButton(),this.createShareLinkButton(),this.createInfoButton()],{style:{gap:"12px",marginTop:"12px"}})}createDownloadPngButton(){const e=P.button("Get PNG",(()=>this.eventBus.requestSvgSave()));return P.tooltip.bind(e,"Download pattern as PNG"),e}createInfoButton(){const e=P.button(P.iconFA("info-circle"),(()=>this.openInfoDialog()));return this.eventBus.patternHasUnsavedChanges$.subscribe((t=>{e.disabled=t})),P.tooltip.bind(e,"View pattern metadata"),e}async openInfoDialog(){let e=this.dataManager.getCurrentUserName(),t=this.dataManager.getDefaultPatternName(),n=K,r=K;const i=new URLSearchParams(window.location.search).get("pattern");if(null!==i){const s=await this.dataManager.getPatternRecordByHash(i);if(null!==s){const i=s[q.AUTHOR_ID];if(e=(await o.dapi.users.find(i)).friendlyName,t=s[q.PATTERN_CONFIG][j.PATTERN_NAME],void 0!==s[q.DATE]){const e=s[q.DATE][W.CREATE];void 0!==e&&(n=e);const t=s[q.DATE][W.MODIFY];void 0!==t&&(r=t)}}}const s=P.divV([P.divText(`Pattern Name: ${t}`),P.divText(`Author: ${e}`),P.divText(`Created: ${rt(new Date(n))}`),P.divText(`Modified: ${rt(new Date(r))}`)]);o.shell.info(s)}createShareLinkButton(){const e=P.button(P.iconFA("link"),(()=>navigator.clipboard.writeText(window.location.href).then((()=>o.shell.info("Link to pattern copied to clipboard")))));return this.eventBus.patternHasUnsavedChanges$.subscribe((t=>{e.disabled=t})),P.tooltip.bind(e,"Share pattern link"),e}createSavePatternButton(){const e=P.button("Save",(()=>this.processSaveButtonClick()));return this.eventBus.patternHasUnsavedChanges$.subscribe((t=>{e.disabled=!t})),P.tooltip.bind(e,"Save pattern to user storage"),e}processSaveButtonClick(){const e=this.eventBus.getPatternName();e!==this.dataManager.getDefaultPatternName()?""!==e?this.dataManager.savePatternToUserStorage(this.eventBus).then((()=>{o.shell.info(`Pattern ${e} saved`)})).catch((e=>this.handleErrorWhileSavingPattern(e))):o.shell.warning("Insert pattern name"):o.shell.warning("Cannot save default pattern")}handleErrorWhileSavingPattern(e){e instanceof Q?new ot(this.eventBus,this.dataManager).show():e instanceof J?o.shell.warning(P.div([P.divText("Pattern already exists"),P.button("Load",(()=>{const t=e.message;this.eventBus.requestLoadPatternInNewTab(t)}))])):console.error("Error while saving pattern",e)}}class ot{constructor(e,t){this.eventBus=e,this.dataManager=t}show(){const e=this.eventBus.getPatternName(),t=P.dialog(`Pattern "${e}" already exists`);t.add(P.divText(`Pattern "${e}" already exists. Do you want to overwrite it?`)),t.show(),t.onOK((()=>this.processOverwriteNamesakePattern()))}processOverwriteNamesakePattern(){const e=this.eventBus.getPatternName();this.dataManager.overwriteExistingPatternInUserStorage(this.eventBus).then((()=>{o.shell.info(`Pattern ${e} overwritten`)})).catch((e=>{console.error("Error while overwriting pattern in user storage",e),o.shell.error("Error while overwriting pattern")}))}}function rt(e){return e.toLocaleString().split(":").slice(0,-1).join(":")}class it extends F{constructor(e){super("Oligo Pattern"),this.th=e}getContent(){return async function(){const e=await ee.getInstance(),t=new he,n=await async function(e,t){const n=t.getPatternHash();if(!n)return t.clearPatternURL(),e.getDefaultPatternRecord();let o=await e.getPatternRecordByHash(n);return o||(t.clearPatternURL(),o=e.getDefaultPatternRecord()),o}(e,t),o=new ce(e,n);t.subscribeToObservables(o);const r=new Fe(o,e).getLayout(),i=new nt(o,e).getLayout();return P.splitH([r,i],{},!0)}()}}var st=n(8507),at={};function lt(e){var t;return"string"==typeof e||e instanceof String?e:("object"==typeof e||e instanceof Object)&&"$thrownJsError"in e?lt(e.$thrownJsError):e instanceof Error?null!==(t=e.stack)&&void 0!==t?t:e.message:e.toString()}at.styleTagTransform=Ae(),at.setAttributes=ve(),at.insert=ye().bind(null,"head"),at.domAPI=fe(),at.insertStyleElement=xe(),pe()(st.A,at),st.A&&st.A.locals&&st.A.locals;var ct,ut=n(2074),ht={};ht.styleTagTransform=Ae(),ht.setAttributes=ve(),ht.insert=ye().bind(null,"head"),ht.domAPI=fe(),ht.insertStyleElement=xe(),pe()(ut.A,ht),ut.A&&ut.A.locals&&ut.A.locals;class dt{constructor(e,t,n=!0){this.textInputBase=e,this.painter=t,L()(this.root).addClass("st-colored-text-input"),n&&this.textInputBase.onChanged.subscribe((()=>{L()(this.textArea).css("height",0),L()(this.textArea).css("height",this.textArea.scrollHeight+"px")})),this.highlights=P.div([]),this.root.appendChild(this.highlights),this.colorize(),this.textInputBase.onChanged.subscribe((()=>this.colorize()))}get textArea(){return this.textInputBase.root.getElementsByTagName("textarea").item(0)}get inputBase(){return this.textInputBase}get root(){return this.textInputBase.root}colorize(){const e=this.painter(this.textInputBase.value);this.highlights.innerHTML="",e.forEach((e=>this.highlights.appendChild(e)))}}!function(e){e.TYPE="V2000",e[e.NUM_OF_HEADER_LINES=3]="NUM_OF_HEADER_LINES",e[e.NUM_OF_COUNTS_DIGITS=3]="NUM_OF_COUNTS_DIGITS",e[e.ATOM_TYPE_COL=4]="ATOM_TYPE_COL",e[e.FIRST_BONDED_ATOM_COL=1]="FIRST_BONDED_ATOM_COL",e[e.BOND_TYPE_COL=3]="BOND_TYPE_COL",e[e.RGP_SHIFT=8]="RGP_SHIFT",e[e.MAX_ATOM_COUNT=999]="MAX_ATOM_COUNT",e.RGP_LINE_START="M RGP",e.ATOM_ALIAS_LINE_START="A ",e.END="M END"}(ct||(ct={}));class pt{constructor(e){this.init(e)}init(e){this.fileContent=e.replace(/\r/g,""),this._atomCount=void 0,this._atomTypes=void 0,this._bondCount=void 0,this._bondTypes=void 0,this.xyzAtomCoordinates=void 0,this._pairsOfBondedAtoms=void 0}get atomCount(){return void 0===this._atomCount&&this.setAtomAndBondCounts(),this._atomCount}get bondCount(){return void 0===this._bondCount&&this.setAtomAndBondCounts(),this._bondCount}get x(){var e;return null!==(e=this.xyzAtomCoordinates)&&void 0!==e||(this.xyzAtomCoordinates=this.parseAtomCoordinates()),this.xyzAtomCoordinates.x}get y(){var e;return null!==(e=this.xyzAtomCoordinates)&&void 0!==e||(this.xyzAtomCoordinates=this.parseAtomCoordinates()),this.xyzAtomCoordinates.y}get z(){var e;return null!==(e=this.xyzAtomCoordinates)&&void 0!==e||(this.xyzAtomCoordinates=this.parseAtomCoordinates()),this.xyzAtomCoordinates.z}get atomTypes(){var e;return null!==(e=this._atomTypes)&&void 0!==e||(this._atomTypes=this.parseAtomTypes()),this._atomTypes}get pairsOfBondedAtoms(){var e;return null!==(e=this._pairsOfBondedAtoms)&&void 0!==e||(this._pairsOfBondedAtoms=this.parseBondedAtomPairs()),this._pairsOfBondedAtoms}get bondTypes(){var e;return null!==(e=this._bondTypes)&&void 0!==e||(this._bondTypes=this.parseBondTypes()),this._bondTypes}setAtomAndBondCounts(){const{atomCount:e,bondCount:t}=this.parseAtomAndBondCounts();this._atomCount=e,this._bondCount=t}getNextColumnIdx(e){for(;!this.isWhitespace(e);)++e;for(;this.isWhitespace(e);)++e;return e}shiftIdxToSpecifiedColumn(e,t){let n=e;const o=this.isWhitespace(n)?t:t-1;for(let e=0;e<o;e++)n=this.getNextColumnIdx(n);return n}parseAtomTypes(){const e=this.atomCount,t=new Array(e);let n=this.getAtomBlockIdx();for(let o=0;o<e;o++)n=this.shiftIdxToAtomType(n),t[o]=this.parseAtomType(n),n=this.getNextLineIdx(n);return t}parseAtomCoordinates(){const e=new Float32Array(this.atomCount),t=new Float32Array(this.atomCount),n=new Float32Array(this.atomCount);let o=this.getAtomBlockIdx();for(let r=0;r<this.atomCount;r++){o=this.shiftIdxToXColumn(o);for(const i of[e,t,n])i[r]=this.parseFloatValue(o),o=this.getNextColumnIdx(o);o=this.getNextLineIdx(o)}return{x:e,y:t,z:n}}parseBondedAtomPairs(){const e=new Array(this.bondCount);let t=this.getBondBlockIdx();for(let n=0;n<this.bondCount;n++){t=this.shiftIdxToBondedAtomsPair(t);const o=new Uint16Array(2);o[0]=this.parseIntValue(t),t=this.getNextColumnIdx(t),o[1]=this.parseIntValue(t),e[n]=o,t=this.getNextLineIdx(t)}return e}parseBondTypes(){const e=this.bondCount,t=new Uint16Array(e);let n=this.getBondBlockIdx();for(let o=0;o<e;o++)n=this.shiftIdxToBondType(n),t[o]=this.parseIntValue(n),n=this.getNextLineIdx(n);return t}isWhitespace(e){const t=this.fileContent[e];return" "===t||"\t"===t}getNextLineIdx(e){return"\n"!==this.fileContent[e]?this.fileContent.indexOf("\n",e)+1:e+1}parseFloatValue(e){return this.parseNumericValue(parseFloat,e)}parseIntValue(e){return this.parseNumericValue(parseInt,e)}parseNumericValue(e,t){let n=t+1;for(;!this.isWhitespace(n);)++n;return e(this.fileContent.substring(t,n))}}class mt extends pt{constructor(e){super(e),this.init(e)}init(e){super.init(e)}parseAtomType(e){let t=e,n=t;return this.isQuote(t)?(n=this.getNextIdenticalChar(t),t++):n=this.fileContent.indexOf(" ",n),this.fileContent.substring(t,n)}isQuote(e){const t=this.fileContent[e].charCodeAt(0);return 39===t||34===t}getNextIdenticalChar(e){const t=this.fileContent[e];return t?this.fileContent.indexOf(t,e+1):-1}isQuery(){return this.isQueryOrFragment(((e,t)=>{return 39===e||34===e||76===e&&!((n=this.fileContent.charCodeAt(t+1))>64&&n<91||n>96&&n<123);var n}))}isFragment(){return this.isQueryOrFragment((e=>82===e||42===e))}isQueryOrFragment(e){const t=this.atomCount;let n=this.getAtomBlockIdx();for(let o=0;o<t;o++){if(n=this.shiftIdxToAtomType(n),e(this.fileContent.charCodeAt(n),n))return!0;n=this.getNextLineIdx(n)}return!1}}class ft extends mt{constructor(e){super(e)}getAtomLines(){const e=this.getAtomBlockIdx(),t=this.getBondBlockIdx();return this.fileContent.substring(e,t).split("\n").slice(0,this.atomCount)}getBondLines(){const e=this.getBondBlockIdx();return this.fileContent.substring(e).split("\n").slice(0,this.bondCount)}getRGroupIdToAtomicIdxMap(){const e=new Map,t=this.fileContent.split("\n");t.filter((e=>e.startsWith(ct.RGP_LINE_START))).forEach((t=>{const n=this.getAtomIdxToRgpIdxList(t);for(const[t,o]of n){if(e.has(t))throw new Error(`R group ${t} is already in the map`);e.set(t,o)}}));const n=t.map(((e,t)=>{if(e.startsWith(ct.ATOM_ALIAS_LINE_START))return t})).filter((e=>void 0!==e)),o=n.map((e=>t[e])),r=n.map((e=>t[e+1]));o.forEach(((t,n)=>{const o=parseInt(t.split(/\s+/)[1])-1,i=parseInt(r[n].substring(1));if(e.has(i))throw new Error(`R group ${i} is already in the map`);e.set(i,o)}));const i=this.getRGroupAtomicIndices().filter((t=>!Array.from(e.values()).includes(t)));if(0!==i.length)throw new Error(`Unaccounted R group indices: ${i}`);return e}getAtomIdxToRgpIdxList(e){const t=e.split(/\s+/).filter((e=>e)).slice(3).map((e=>parseInt(e))),n=new Array(t.length/2);for(let e=0;e<t.length;e+=2)n[e/2]=[t[e+1],t[e]-1];return n}getRGroupAtomicIndices(){return this.atomTypes.map(((e,t)=>{if(e.includes("R#"))return t})).filter((e=>void 0!==e))}static isValidMolfile(e){return-1!==e.indexOf(ct.TYPE)&&-1!==e.indexOf(ct.END)}shiftIdxToAtomType(e){return this.shiftIdxToSpecifiedColumn(e,ct.ATOM_TYPE_COL)}getCountsLineIdx(){let e=0;for(let t=0;t<ct.NUM_OF_HEADER_LINES;++t)e=this.getNextLineIdx(e);return e}getAtomBlockIdx(){let e=this.getCountsLineIdx();return e=this.getNextLineIdx(e),e}shiftIdxToXColumn(e){return this.getNextColumnIdx(e)}shiftIdxToBondedAtomsPair(e){return this.shiftIdxToSpecifiedColumn(e,ct.FIRST_BONDED_ATOM_COL)}shiftIdxToBondType(e){return this.shiftIdxToSpecifiedColumn(e,ct.BOND_TYPE_COL)}getBondBlockIdx(){let e=this.getAtomBlockIdx();for(let t=0;t<this.atomCount;t++)e=this.getNextLineIdx(e);return e}parseAtomAndBondCounts(){let e=this.getCountsLineIdx(),t=e+ct.NUM_OF_COUNTS_DIGITS;const n=parseInt(this.fileContent.substring(e,t));return e=t,t+=ct.NUM_OF_COUNTS_DIGITS,{atomCount:n,bondCount:parseInt(this.fileContent.substring(e,t))}}}class gt extends mt{constructor(e){super(e),this.init(e)}getAtomLines(){const e=this.getAtomBlockIdx(),t=this.getBondBlockIdx();return this.fileContent.substring(e,t).split("\n").slice(0,this.atomCount)}getBondLines(){const e=this.getBondBlockIdx();return this.fileContent.substring(e).split("\n").slice(0,this.bondCount)}getRGroupIdToAtomicIdxMap(){const e=new Map;return this.getAtomLines().forEach(((t,n)=>{const o=t.match(/RGROUPS=\(([\d\s]+)\)/);if(o){const t=o[1].split(/\s+/).map((e=>parseInt(e)));if(t.length>2)throw new Error(`R group data ${t} has more than 2 elements`);const r=t[1];if(e.has(r))throw new Error(`R group ${r} is already in the map`);e.set(r,n)}})),e}shiftIdxToAtomType(e){return this.shiftIdxToSpecifiedColumn(e,4)}getCountsLineIdx(){return this.fileContent.indexOf("M V30 COUNTS ")}getAtomBlockIdx(){let e=this.fileContent.indexOf("M V30 BEGIN ATOM");return e=this.getNextLineIdx(e),e}shiftIdxToXColumn(e){let t=this.shiftIdxToAtomType(e);return this.isQuote(t)?(t=this.getNextIdenticalChar(t),t=this.getNextColumnIdx(t),t):this.shiftIdxToSpecifiedColumn(e,5)}shiftIdxToBondedAtomsPair(e){return this.shiftIdxToSpecifiedColumn(e,5)}shiftIdxToBondType(e){return this.shiftIdxToSpecifiedColumn(e,4)}getBondBlockIdx(){return this.getNextLineIdx(this.fileContent.indexOf("M V30 BEGIN BOND"))}static isValidMolfile(e){return-1!==e.indexOf("V3000")&&-1!==e.indexOf("M END")}parseAtomAndBondCounts(){let e=this.fileContent.indexOf("M V30 COUNTS ")+14,t=this.fileContent.indexOf(" ",e+1);const n=parseInt(this.fileContent.substring(e,t));return e=t+1,t=this.fileContent.indexOf(" ",e+1),{atomCount:n,bondCount:parseInt(this.fileContent.substring(e,t))}}}class yt{constructor(){}static getInstance(e){if(yt.isMolfileV2K(e))return new ft(e);if(yt.isMolfileV3K(e))return new gt(e);throw new Error("Malformed molfile")}static isMolfileV2K(e){return ft.isValidMolfile(e)}static isMolfileV3K(e){return gt.isValidMolfile(e)}}const bt=class extends Error{constructor(e){super(e)}};class vt{constructor(e){this.molblock=e}get molblock(){return this._validMolBlock}set molblock(e){if(""!==e){try{this.validateMolBlock(e)}catch(t){t instanceof bt&&(e="");const n=lt(t);console.error(n)}this._validMolBlock=e}else this._validMolBlock=e}validateMolBlock(e){if(""===e)throw new bt("MoleculeImage: invalid molblock")}async drawMolBlockOnCanvas(e){try{await o.functions.call("Chem:canvasMol",{x:0,y:0,w:e.width,h:e.height,canvas:e,molString:this.molblock,scaffoldMolString:"",options:{normalizeDepiction:!1,straightenDepiction:!1}})}catch(e){const t=lt(e);console.error(t)}}getMoleculeDimensions(){const e=yt.getInstance(this.molblock),t=Math.max(...e.x)-Math.min(...e.x);return{height:Math.max(...e.y)-Math.min(...e.y),width:t}}async zoomIn(){const e=P.dialog({title:"Molecule",showFooter:!1}),t=.7*L()(window).height(),n=this.getMoleculeDimensions(),o=t/n.height,r=t,i=n.width*o,s=P.canvas(i,r);await this.drawMolBlockOnCanvas(s);const a=P.block([s],{style:{overflowX:"scroll"}});e.add(a).showModal(!0),L()(e.root).find(".d4-dialog-contents").removeClass("ui-form"),L()(e.root).find(".d4-dialog-contents").removeClass("ui-panel"),L()(e.root).find(".d4-dialog-contents").addClass("ui-box"),L()(e.root).find(".d4-dialog-contents").css("padding","0")}async drawMolecule(e,t,n){e.innerHTML="";const o=P.canvas(t*window.devicePixelRatio,n*window.devicePixelRatio);o.style.width=`${t}px`,o.style.height=`${n}px`,o.style.cursor="zoom-in",this.drawMolBlockOnCanvas(o),o.addEventListener("click",(async()=>{await this.zoomIn()})),e.append(P.tooltip.bind(o,"Click to zoom"))}}class Ct extends Error{constructor(e,t){super(e,t)}}class xt{constructor(e,t){this.sequence=e,this.codeMap=t}parseSequence(){const e=this.parseRawSequence();return this.addLinkers(e)}addLinkers(e){const t=[];return e.forEach(((n,o)=>{const r=this.getSymbolForCode(n);o>0&&function(e){return br.jsonData.monomersWithPhosphate.left.includes(e)}(r)&&t.pop(),t.push(r);const i=wt(r),s=o===e.length-1,a=o+1<e.length&&wt(this.getSymbolForCode(e[o+1]));i||function(e){return br.jsonData.monomersWithPhosphate.right.includes(e)}(r)||a||s||t.push("p")})),t}getSymbolForCode(e){let t=this.codeMap.get(e);return t??(t=e),t}parseRawSequence(){const e=this.getAllCodesOfFormat(),t=[];let n=0;for(;n<this.sequence.length;){const o=e.find((e=>e===this.sequence.substring(n,n+e.length)));if(void 0===o)throw new Ct(`Unable to match a monomer for the rest of the sequence '${this.sequence.slice(n)}'.`);t.push(o),n+=o.length}return t}getAllCodesOfFormat(){return g(Array.from(this.codeMap.keys()))}}function wt(e){return br.jsonData.monomersWithPhosphate.phosphate.includes(e)}class At{constructor(e,t=!1,n){this.invert=t,this.lib=br.monomerLibWrapper;const o=this.lib.getCodeToSymbolMap(n);this.parser=new xt(e,o)}convert(){const e=this.parser.parseSequence(),t=[];e.forEach(((e,n)=>{const o=this.getMonomerMolfile(e,n);t.push(o)}));let n=this.getPolymerMolfile(t);return this.invert&&(n=this.reflect(n),n=this.invertBondConfiguration(n)),n}invertBondConfiguration(e){const t=e.indexOf("M V30 BEGIN BOND"),n=e.indexOf("M V30 END BOND");let o=e.substring(t,n);return o=o.replace(/(CFG=)([13])/g,((e,t,n)=>"1"===n?`${t}3`:"3"===n?`${t}1`:e)),e.substring(0,t)+o+e.substring(n)}getMonomerMolfile(e,t){const n=this.lib.getMolfileBySymbol(e);return this.lib.isModification(e)?0===t?this.reflect(n):n:this.rotateNucleotidesV3000(n)}getPolymerMolfile(e){return this.linkV3000(e)}reflect(e){const t=this.extractAtomDataV3000(e),n=t.atomIndex.length,o=t.atomIndex.indexOf(1),r=t.atomIndex.indexOf(n),i=(t.x[r]+t.x[o])/2,s=(t.y[r]+t.y[o])/2;for(let e=0;e<n;e++)t.x[e]-=i,t.y[e]-=s;for(let e=0;e<n;e++)t.x[e]=-t.x[e];const a=t.x[o];for(let e=0;e<n;e++)t.x[e]-=a;let l=e.indexOf("M V30 BEGIN ATOM");l=e.indexOf("\n",l);let c=l;for(let o=0;o<n;o++)l=e.indexOf("V30",l)+4,l=e.indexOf(" ",l)+1,l=e.indexOf(" ",l)+1,c=e.indexOf(" ",l)+1,c=e.indexOf(" ",c),l=(e=e.slice(0,l)+t.x[o]+" "+t.y[o]+e.slice(c)).indexOf("\n",l)+1;return e}extractAtomDataV3000(e){const t=this.extractAtomsBondsNumbersV3000(e);let n=e.indexOf("M V30 BEGIN ATOM");n=e.indexOf("\n",n);let o=n;const r=Array(t.natom),i=Array(t.natom),s=Array(t.natom),a=Array(t.natom);for(let l=0;l<t.natom;l++)n=e.indexOf("V30",n)+4,o=e.indexOf(" ",n),r[l]=parseInt(e.substring(n,o)),n=o+1,o=e.indexOf(" ",n),i[l]=e.substring(n,o),n=o+1,o=e.indexOf(" ",n),s[l]=parseFloat(e.substring(n,o)),n=o+1,o=e.indexOf(" ",n),a[l]=parseFloat(e.substring(n,o)),n=e.indexOf("\n",n)+1;return{atomIndex:r,atomType:i,x:s,y:a}}extractAtomsBondsNumbersV3000(e){let t=(e=e.replaceAll("\r","")).indexOf("COUNTS")+7,n=e.indexOf(" ",t);const o=parseInt(e.substring(t,n));return t=n+1,n=e.indexOf(" ",t),{natom:o,nbond:parseInt(e.substring(t,n))}}rotateNucleotidesV3000(e){const t=this.extractAtomDataV3000(e),n=t.atomIndex.length,o=t.atomIndex.indexOf(1),r=t.atomIndex.indexOf(n);n>8&&this.fix5Prime(t,o,r);const i=(t.x[r]+t.x[o])/2,s=(t.y[r]+t.y[o])/2;for(let e=0;e<n;e++)t.x[e]-=i,t.y[e]-=s;let a=0;if(0===t.x[o])a=t.y[o]>t.y[r]?Math.PI/2:3*Math.PI/2;else if(0===t.y[o])a=t.x[o]>t.x[r]?Math.PI:0;else{const e=t.y[o]/t.x[o];a=e>0?t.x[o]>0?Math.PI-Math.atan(e):2*Math.PI-Math.atan(e):t.x[o]>0?-Math.PI-Math.atan(e):Math.atan(e)}const l=Math.cos(a),c=Math.sin(a);for(let e=0;e<n;e++){const n=t.x[e];t.x[e]=n*l-t.y[e]*c,t.y[e]=n*c+t.y[e]*l}const u=t.x[o];for(let e=0;e<n;e++)t.x[e]-=u;let h=e.indexOf("M V30 BEGIN ATOM");h=e.indexOf("\n",h);let d=h;for(let o=0;o<n;o++)h=e.indexOf("V30",h)+4,h=e.indexOf(" ",h)+1,h=e.indexOf(" ",h)+1,d=e.indexOf(" ",h)+1,d=e.indexOf(" ",d),h=(e=e.slice(0,h)+t.x[o]+" "+t.y[o]+e.slice(d)).indexOf("\n",h)+1;return e}linkV3000(e,t=!0){let n="\n Datagrok macromolecule handler\n\n";n+=" 0 0 0 0 0 0 999 V3000\n",n+="M V30 BEGIN CTAB\n";let o="",r="",i="";const s=[];let a=0,l=0,c=0;for(let t=0;t<e.length;t++){const n=e[t].includes("MODIFICATION")&&0===t;let i=0;n&&(i=this.extractAtomDataV3000(e[t]).atomIndex.length),e[t]=e[t].replaceAll("(-\nM V30 ","(").replaceAll("-\nM V30 ","").replaceAll(" )",")");const u=this.extractAtomsBondsNumbersV3000(e[t]),h=this.extractAtomDataV3000(e[t]);let d=e[t].indexOf("M V30 BEGIN ATOM");d=e[t].indexOf("\n",d);let p=d,m=d;for(let o=0;o<u.natom;o++)if(1!==h.atomIndex[o]||0===t){p=e[t].indexOf("V30",p)+4,m=e[t].indexOf(" ",p);let o=0;n?(o=parseInt(e[t].substring(p,m)),1===o?o=i:o===i&&(o=1),o+=a):o=parseInt(e[t].substring(p,m))+a,e[t]=e[t].slice(0,p)+o+e[t].slice(m),p=e[t].indexOf(" ",p)+1,p=e[t].indexOf(" ",p)+1,m=e[t].indexOf(" ",p);const r=c-h.x[0];let s=Math.round(1e4*(parseFloat(e[t].substring(p,m))+r))/1e4;e[t]=e[t].slice(0,p)+s+e[t].slice(m),p=e[t].indexOf(" ",p)+1,m=e[t].indexOf(" ",p),s=Math.round(1e4*parseFloat(e[t].substring(p,m)))/1e4,e[t]=e[t].slice(0,p)+s+e[t].slice(m),p=e[t].indexOf("\n",p)+1}else p=e[t].indexOf("M V30",p)-1,m=e[t].indexOf("\n",p+1),e[t]=e[t].slice(0,p)+e[t].slice(m);const f=e[t].indexOf("M V30 END ATOM");o+=e[t].substring(d+1,f);let g=e[t].indexOf("M V30 BEGIN BOND");g=e[t].indexOf("\n",g),p=g,m=g;for(let o=0;o<u.nbond;o++){p=e[t].indexOf("V30",p)+4,m=e[t].indexOf(" ",p);const o=parseInt(e[t].substring(p,m))+l;e[t]=e[t].slice(0,p)+o+e[t].slice(m),p=e[t].indexOf(" ",p)+1,p=e[t].indexOf(" ",p)+1,m=e[t].indexOf(" ",p);let r=0;n?(r=parseInt(e[t].substring(p,m)),1===r?r=i:r===i&&(r=1),r+=a):r=parseInt(e[t].substring(p,m))+a,e[t]=e[t].slice(0,p)+r+e[t].slice(m),p=e[t].indexOf(" ",p)+1,m=Math.min(e[t].indexOf("\n",p),e[t].indexOf(" ",p)),r=0,n?(r=parseInt(e[t].substring(p,m)),1===r?r=i:r===i&&(r=1),r+=a):r=parseInt(e[t].substring(p,m))+a,e[t]=e[t].slice(0,p)+r+e[t].slice(m),p=e[t].indexOf("\n",p)+1}const y=e[t].indexOf("M V30 END BOND");r+=e[t].substring(g+1,y);let b=e[t].indexOf("M V30 MDLV30/STEABS ATOMS=(");for(;-1!==b;){b+=28;const n=e[t].indexOf(")",b);e[t].substring(b,n).split(" ").slice(1).forEach((e=>{s.push(parseInt(e)+a)})),b=n,b=e[t].indexOf("M V30 MDLV30/STEABS ATOMS=(",b)}a+=u.natom-1,l+=u.nbond,c+=n?Math.max(...h.x):h.x[u.natom-1]-h.x[0]}const u=Math.ceil(s.length/4);i+="M V30 MDLV30/STEABS ATOMS=("+s.length+" -\n";for(let e=0;e<u;e++){i+="M V30 ";const t=e+1===u?s.length-4*(u-1):4;for(let n=0;n<t;n++)i+=n+1===t?e===u-1?s[4*e+n]+")\n":s[4*e+n]+" -\n":s[4*e+n]+" "}return a++,n+="M V30 COUNTS "+a+" "+l+" 0 0 0\n",n+="M V30 BEGIN ATOM\n",n+=o,n+="M V30 END ATOM\n",n+="M V30 BEGIN BOND\n",n+=r,n+="M V30 END BOND\n",t&&s.length>0?(n+="M V30 BEGIN COLLECTION\n",n+=i,n+="M V30 END COLLECTION\n"):n=n.replace(/ CFG=\d/g," "),n+="M V30 END CTAB\n",n+="M END",n}fix5Prime(e,t,n){const o=t+1,r=e.x[o],i=e.y[o],s=e.x[n]-r,a=e.y[n]-i,l=e.x[t]-r,c=e.y[t]-i,u=l*Math.cos(2*Math.PI/3)-c*Math.sin(2*Math.PI/3),h=l*Math.sin(2*Math.PI/3)+c*Math.cos(2*Math.PI/3),d=l-s,p=c-a,m=u-s,f=h-a;Math.sqrt(f*f+m*m)>=Math.sqrt(p*p+d*d)&&(e.x[t]=u+r,e.y[t]=h+i)}}function Tt(e,t=!0){let n="\n Datagrok macromolecule handler\n\n";n+=" 0 0 0 0 0 0 999 V3000\n",n+="M V30 BEGIN CTAB\n";let o="",r="",i="";const s=[];let a=0,l=0,c=0;if(e.antiStrands.length>0)for(let t=0;t<e.antiStrands.length;t++)e.antiStrands[t]=Et(e.antiStrands[t]);let u=!1;const h=e.senseStrands.concat(e.antiStrands);let d=0;for(let t=0;t<h.length;t++){h[t]=h[t].replaceAll("(-\nM V30 ","(").replaceAll("-\nM V30 ","").replaceAll(" )",")");const n=St(h[t]),i=Nt(h[t]);if(t>=e.senseStrands.length?!1===u&&(u=!0,c=0):d=Math.min(d,Math.min(...i.y.filter((e=>e<0)))),u){const e=Math.min(...i.x)-c,t=Math.max(...i.y)+5;for(let t=0;t<i.x.length;t++)i.x[t]-=e;for(let e=0;e<i.y.length;e++)i.y[e]-=t-d}let p=h[t].indexOf("M V30 BEGIN ATOM");p=h[t].indexOf("\n",p);let m=p,f=p;for(let e=0;e<n.natom;e++){m=h[t].indexOf("V30",m)+4,f=h[t].indexOf(" ",m);const n=parseInt(h[t].substring(m,f))+a;h[t]=h[t].slice(0,m)+n+h[t].slice(f),m=h[t].indexOf(" ",m)+1,m=h[t].indexOf(" ",m)+1,f=h[t].indexOf(" ",m);let o=Math.round(1e4*i.x[e])/1e4;h[t]=h[t].slice(0,m)+o+h[t].slice(f),m=h[t].indexOf(" ",m)+1,f=h[t].indexOf(" ",m),o=Math.round(1e4*i.y[e])/1e4,h[t]=h[t].slice(0,m)+o+h[t].slice(f),m=h[t].indexOf("\n",m)+1}const g=h[t].indexOf("M V30 END ATOM");o+=h[t].substring(p+1,g);let y=h[t].indexOf("M V30 BEGIN BOND");y=h[t].indexOf("\n",y),m=y,f=y;for(let e=0;e<n.nbond;e++){m=h[t].indexOf("V30",m)+4,f=h[t].indexOf(" ",m);const e=parseInt(h[t].substring(m,f))+l;h[t]=h[t].slice(0,m)+e+h[t].slice(f),m=h[t].indexOf(" ",m)+1,m=h[t].indexOf(" ",m)+1,f=h[t].indexOf(" ",m);let n=parseInt(h[t].substring(m,f))+a;h[t]=h[t].slice(0,m)+n+h[t].slice(f),m=h[t].indexOf(" ",m)+1,f=Math.min(h[t].indexOf("\n",m),h[t].indexOf(" ",m)),n=parseInt(h[t].substring(m,f))+a,h[t]=h[t].slice(0,m)+n+h[t].slice(f),m=h[t].indexOf("\n",m)+1}const b=h[t].indexOf("M V30 END BOND");r+=h[t].substring(y+1,b);let v=h[t].indexOf("M V30 MDLV30/STEABS ATOMS=(");for(;-1!==v;){v+=28;const e=h[t].indexOf(")",v);h[t].substring(v,e).split(" ").slice(1).forEach((e=>{s.push(parseInt(e)+a)})),v=e,v=h[t].indexOf("M V30 MDLV30/STEABS ATOMS=(",v)}a+=n.natom,l+=n.nbond,c+=Math.max(...i.x)+5}const p=Math.ceil(s.length/4);i+="M V30 MDLV30/STEABS ATOMS=("+s.length+" -\n";for(let e=0;e<p;e++){i+="M V30 ";const t=e+1===p?s.length-4*(p-1):4;for(let n=0;n<t;n++)i+=n+1===t?e===p-1?s[4*e+n]+")\n":s[4*e+n]+" -\n":s[4*e+n]+" "}return n+="M V30 COUNTS "+a+" "+l+" 0 0 0\n",n+="M V30 BEGIN ATOM\n",n+=o,n+="M V30 END ATOM\n",n+="M V30 BEGIN BOND\n",n+=r,n+="M V30 END BOND\n",t&&s.length>0?(n+="M V30 BEGIN COLLECTION\n",n+=i,n+="M V30 END COLLECTION\n"):n=n.replace(/ CFG=\d/g," "),n+="M V30 END CTAB\n",n+="M END",n}function Et(e){const t=Nt(e),n=t.atomIndex.length,o=(Math.max(...t.x)+Math.min(...t.x))/2,r=(Math.max(...t.y)+Math.min(...t.y))/2;for(let e=0;e<n;e++)t.x[e]-=o,t.y[e]-=r;const i=Math.PI,s=Math.cos(i),a=Math.sin(i);for(let e=0;e<n;e++){const n=t.x[e];t.x[e]=n*s-t.y[e]*a,t.y[e]=n*a+t.y[e]*s}const l=Math.max(...t.y);for(let e=0;e<n;e++)t.x[e]+=o,t.y[e]-=l;let c=e.indexOf("M V30 BEGIN ATOM");c=e.indexOf("\n",c);let u=c;for(let o=0;o<n;o++)c=e.indexOf("V30",c)+4,c=e.indexOf(" ",c)+1,c=e.indexOf(" ",c)+1,u=e.indexOf(" ",c)+1,u=e.indexOf(" ",u),c=(e=e.slice(0,c)+t.x[o]+" "+t.y[o]+e.slice(u)).indexOf("\n",c)+1;return e}function St(e){let t=(e=e.replaceAll("\r","")).indexOf("COUNTS")+7,n=e.indexOf(" ",t);const o=parseInt(e.substring(t,n));return t=n+1,n=e.indexOf(" ",t),{natom:o,nbond:parseInt(e.substring(t,n))}}function Nt(e){const t=St(e);let n=e.indexOf("M V30 BEGIN ATOM");n=e.indexOf("\n",n);let o=n;const r=Array(t.natom),i=Array(t.natom),s=Array(t.natom),a=Array(t.natom);for(let l=0;l<t.natom;l++)n=e.indexOf("V30",n)+4,o=e.indexOf(" ",n),r[l]=parseInt(e.substring(n,o)),n=o+1,o=e.indexOf(" ",n),i[l]=e.substring(n,o),n=o+1,o=e.indexOf(" ",n),s[l]=parseFloat(e.substring(n,o)),n=o+1,o=e.indexOf(" ",n),a[l]=parseFloat(e.substring(n,o)),n=e.indexOf("\n",n)+1;return{atomIndex:r,atomType:i,x:s,y:a}}function It(e,t,n){if(""===e)return"";const o=n.createFormatDetector(e).getFormat();if(!o)return"";let r="";try{r=new At(e,t,o).convert()}catch(e){const t=lt(e);console.error(t)}return r}function Mt(e,t,n,o,r){const i=[e,t,n].filter((e=>""!==e.strand));return 1===i.length?It(i[0].strand,i[0].invert,r):Tt({senseStrands:[It(e.strand,e.invert,r)],antiStrands:[It(t.strand,t.invert,r),It(n.strand,n.invert,r)].filter((e=>""!==e))},o)}const Pt=["ss","as","as2"];class _t{constructor(){this.th=br,this.onInput=new te.Subject,this.onInvalidInput=new te.Subject,this.inputBase=Object.fromEntries(Pt.map((e=>{const t=P.input.textArea(e.toUpperCase(),{value:"",onValueChanged:()=>{this.onInput.next(),L()(t.root.getElementsByTagName("div")).css("padding-left","38px")}});return[e,t]}))),this.useChiralInput=P.input.bool("Use chiral",{value:!0}),this.saveAllStrandsInput=P.input.bool("Save as one entity",{value:!0}),P.tooltip.bind(this.saveAllStrandsInput.root,"Save SDF with all strands in one molfile"),this.directionInversion=Object.fromEntries(Pt.map((e=>[e,!1]))),this.moleculeImgDiv=P.block([]),L()(this.moleculeImgDiv).addClass("st-structure-mol-img"),r.debounce(this.onInput,300).subscribe((async()=>{await this.updateMoleculeImg()})),r.debounce(this.onInvalidInput,1e3).subscribe((async()=>{o.shell.warning("Insert Sense strand")}))}async getHtmlDivElement(e){const t=this.getTableInput(e),n=this.getBoolInputsAndButton();await this.updateMoleculeImg();const o=P.divH([this.moleculeImgDiv,n]);L()(o).addClass("st-structure-bottom");const r=P.divV([t,o]);return L()(r).addClass("st-structure-body"),r}getBoolInputsAndButton(){const e=P.buttonsInput([P.bigButton("Save SDF",(()=>{const e=this.getStrandData();!function(e,t,n,r,i,s){const a=[e.strand,t.strand,n.strand].filter((e=>""!==e));if(0===a.length||1===a.length&&""===e.strand)o.shell.warning("Enter SENSE_STRAND and optionally ANTISENSE_STRAND/AS2 to save SDF");else{let l;if(i)l=Mt(e,t,n,r,s)+"\n$$$$\n";else{const h=It(e.strand,e.invert,s),d=It(t.strand,t.invert,s),p=It(n.strand,n.invert,s);l=h+"\n> <Sequence>\nSense Strand\n$$$$\n",d&&(l+=d+"\n> <Sequence>\nAnti Sense\n$$$$\n"),p&&(l+=p+"\n> <Sequence>\nAnti Sense 2\n$$$$\n")}const c=new Date;function u(e){return e>=10?e.toString():"0"+e.toString()}y(`SequenceTranslator-${c.getFullYear()+"-"+u(c.getMonth()+1)+"-"+u(c.getDate())+"_"+u(c.getHours())+"-"+u(c.getMinutes())+"-"+u(c.getSeconds())}.sdf`,encodeURIComponent(l))}}(e.ss,e.as,e.as2,this.useChiralInput.value,this.saveAllStrandsInput.value,this.th)}))]),t=[this.saveAllStrandsInput.root,this.useChiralInput.root,e],n=P.divV(t);for(const e of t)L()(e).addClass("st-structure-bool-button-block");return n}getTableInput(e){const t=Object.fromEntries(Pt.map((t=>[t,new dt(this.inputBase[t],e.highlightInvalidSubsequence)]))),n=Object.fromEntries(Pt.map(((e,t)=>{const n=0===t?"5′ → 3′":"3′ → 5′";return[e,P.input.choice(`${e.toUpperCase()} direction`,{value:n,items:["5′ → 3′","3′ → 5′"]})]})));Pt.forEach(((e,t)=>{n[e].onChanged.subscribe((n=>{let o="3′ → 5′"===n;t>0&&(o=!o),this.directionInversion[e]=o,this.onInput.next()}))}));const o=["Sense Strand","Anti Sense","Anti Sense 2"],r=new Map(Pt.map(((e,t)=>[e,o[t]]))),i=(Object.fromEntries(Pt.map((e=>[e,P.label(r.get(e))]))),Object.fromEntries(Pt.map((e=>{const n=P.icons.delete((()=>{t[e].inputBase.value=""}),"Delete"),o=P.button(n,(()=>{}));return P.tooltip.bind(o,`Clear ${e.toUpperCase()}`),[e,n]})))),s=P.form([],"st-structure-inputs"),a=P.divV([],"st-structure-clear-buttons"),l=P.form([],"st-direction-inputs");for(const e of Pt)s.append(this.inputBase[e].root),a.append(i[e]),l.append(n[e].root);return P.divH([s,a,l])}getStrandData(){return Object.fromEntries(Pt.map((e=>{const t=this.directionInversion[e];return[e,{strand:this.inputBase[e].value.replace(/\s*/g,""),invert:t}]})))}getMolfile(e,t,n){return Mt(e,t,n,this.useChiralInput.value,this.th)}async updateMoleculeImg(){let e="";try{const t=this.getStrandData();Object.values(t).some((e=>""!==e.strand))&&(e=this.getMolfile(t.ss,t.as,t.as2))}catch(e){const t=lt(e);console.error(t)}const t=new vt(e);await t.drawMolecule(this.moleculeImgDiv,650,150)}}class Lt extends F{constructor(e){super("Oligo Structure"),this.th=e,this.layout=new _t}getContent(){return this.layout.getHtmlDivElement(this.th)}}var Ot=n(2003);async function Rt(e){try{const t={overflowX:"scroll"},n=P.div([],{style:t}),r=Nt(e),i=.7*L()(window).height(),s=Math.max(...r.x)-Math.min(...r.x),a=Math.max(...r.y)-Math.min(...r.y),l=i/a,c=l*s,u=l*a,h=P.canvas(c*window.devicePixelRatio,u*window.devicePixelRatio);h.style.width=`${c}px`,h.style.height=`${u}px`,await async function(e,t){await o.functions.call("Chem:canvasMol",{x:0,y:0,w:e.width,h:e.height,canvas:e,molString:t,scaffoldMolString:"",options:{normalizeDepiction:!1,straightenDepiction:!1}})}(h,e),n.appendChild(h),P.dialog("Molecule").add(n).showModal(!0)}catch(e){const t=lt(e);console.error(t)}}class $t{static async view(){const e=br.monomerLibWrapper.getTableForViewer();e.name="Monomer Library";const t=o.shell.addTableView(e);t.grid.props.allowEdit=!1,t.grid.onCellDoubleClick.subscribe((async e=>{const t=e.cell.value;"Molecule"===e.tableColumn?.semType&&await Rt(t)}))}}var Dt=n(3480),Bt=n(5067),Ft=n(5254),kt={};kt.styleTagTransform=Ae(),kt.setAttributes=ve(),kt.insert=ye().bind(null,"head"),kt.domAPI=fe(),kt.insertStyleElement=xe(),pe()(Ft.A,kt),Ft.A&&Ft.A.locals&&Ft.A.locals;const Ht=["Sequence"];class Gt{constructor(e){this.th=e,this.inputFormats=Object.keys(br.jsonData.codesToHelmDict).concat(f.NO.HELM),this.seqHelper=br.seqHelper,this.onInput=new te.Subject,this.moleculeImgDiv=P.div([]),this.moleculeImgDiv.className="mol-host",this.moleculeImgDiv.style.border="1px solid var(--grey-2)",this.moleculeImgDiv.style.borderRadius="1px",this.moleculeImgDiv.style.marginTop="12px",this.outputTableDiv=P.div([]),this.formatChoiceInput=P.input.choice("",{value:f.NO.HELM,items:this.inputFormats,onValueChanged:async(e,t)=>{this.format=e,this.updateTable(),await this.updateMolImg()}}),this.sequenceInputBase=P.input.textArea("",{value:"Afcgacsu",onValueChanged:()=>{this.onInput.next()}}),this.init(),r.debounce(this.onInput,300).subscribe((async()=>{this.init(),this.formatChoiceInput.value=this.format,this.updateTable(),await this.updateMolImg()})),this.eventBus=qt.getInstance()}async getHtmlElement(){const e=this.constructSingleSequenceControls(),t=this.constructBulkTranslationControls(),n=P.box(P.panel([e,t,P.block([P.box(this.moleculeImgDiv)])]));return this.formatChoiceInput.value=this.format,this.updateTable(),await this.updateMolImg(),n}constructBulkTranslationControls(){const e=P.h1("Bulk");P.tooltip.bind(e,"Bulk translation from table input");const t=new Ut(this.eventBus).createUIComponents(),n=P.input.choice("Input format",{value:f.NO.AXOLABS,items:this.inputFormats,onValueChanged:e=>this.eventBus.selectInputFormat(e)}),o=P.input.choice("Output format",{value:Bt.qP,items:(0,Dt.OT)(this.th),onValueChanged:e=>this.eventBus.selectOutputFormat(e)}),r=this.createConvertBulkButton(),i=P.div([...t,n,o,r],"ui-form");return P.block25([e,i])}createConvertBulkButton(){const e=P.bigButton("Convert",(()=>this.processConvertBulkButtonClick()));return P.tooltip.bind(e,"Convert sequences from table input"),L()(e).css({float:"right","margin-top":"20px"}),e}processConvertBulkButtonClick(){const e=this.eventBus.getSelectedTable();if(!e)return void o.shell.warning("No table selected");const t=this.eventBus.getSelectedInputFormat(),n=this.eventBus.getSelectedOutputFormat(),i=this.eventBus.getSelectedColumn("Sequence");if(!i)return void o.shell.warning("No sequence column selected");const s=`${i.name} (${n})`,a=r.Column.fromList(r.TYPE.STRING,s,i.toList().map((e=>(0,Dt.C6)(e,t,n,this.th))));if(n===Bt.qP||n===f.NO.HELM){a.semType=r.SEMTYPE.MACROMOLECULE;const e=n==Bt.qP?Ot.Hi.FASTA:Ot.Hi.HELM;a.meta.units=e;const t=this.seqHelper.getSeqHandler(a);(n==Bt.qP?this.seqHelper.setUnitsToFastaColumn:this.seqHelper.setUnitsToHelmColumn)(t)}e.columns.add(a),o.data.detectSemanticTypes(e),o.shell.v=o.shell.getTableView(e.name)}constructSingleSequenceControls(){const e=new dt(this.sequenceInputBase,(e=>O(e,this.th))),t=P.button("Get SDF",(()=>{this.saveMolfile()}),"Save structure as SDF"),n=P.button("Copy SMILES",(()=>{this.copySmiles()}),"Copy SMILES for the sequence"),o=P.div([this.formatChoiceInput]),r=P.button(P.icons.delete((()=>{e.inputBase.value=""}),"Delete"),(()=>{}));P.tooltip.bind(r,"Clear input");const i={format:o,textInput:e.root,clearBtn:r},s=P.table([i],(e=>[e.format,e.textInput,e.clearBtn]));s.classList.add("st-translator-input-table");const a=P.block([this.outputTableDiv,t,n]);return P.block75([P.h1("Single sequence"),s,a])}saveMolfile(){try{const e=new At(this.sequence,!1,this.formatChoiceInput.value).convert()+"\n$$$$";y(this.sequence+".sdf",encodeURIComponent(e))}catch(e){o.shell.warning("Unable to save SDF: "+e.message)}}copySmiles(){const e=r.chem.convert(this.molfile,r.chem.Notation.MolBlock,r.chem.Notation.Smiles);navigator.clipboard.writeText(e).then((()=>o.shell.info(Bt.n_)))}updateTable(){this.outputTableDiv.innerHTML="";const e=this.format?this.th.createSequenceValidator(this.sequence).getInvalidCodeIndex(this.format):0,t=(0,Dt.bD)(this.sequence,e,this.format,this.th),n=[];for(const e of Object.keys(t)){const r="indexOfFirstInvalidChar"in t?P.divH([]):P.link(t[e],(()=>navigator.clipboard.writeText(t[e]).then((()=>o.shell.info(Bt.n_)))),Bt.U_,"");n.push({format:e,sequence:r})}const r=P.table(n,(e=>[e.format,e.sequence]),["FORMAT","SEQUENCE"]);this.outputTableDiv.append(r),this.outputTableDiv.classList.add("st-translator-output-table")}async updateMolImg(){const e=new vt(this.molfile);await e.drawMolecule(this.moleculeImgDiv,500,170)}init(){this.sequence=this.getFormattedSequence(),this.format=this.th.createFormatDetector(this.sequence).getFormat(),this.molfile=this.getMolfile()}getFormattedSequence(){return this.sequenceInputBase.value.replace(/\s/g,"")}getMolfile(){if(!this.format)return"";if(this.format===f.NO.HELM){const e=this.th.createFormatConverter(this.sequence,this.format).convertTo(f.NO.AXOLABS);return new At(e,!1,f.NO.AXOLABS).convert()}return new At(this.sequence,!1,this.format).convert()}}class Ut{constructor(e){this.tableInputManager=new Vt(e),this.columnInputManager=new jt(e)}createUIComponents(){return[this.tableInputManager.getTableInputContainer(),this.columnInputManager.getColumnControlsContainer()]}}class Vt{constructor(e){this.eventBus=e,this.availableTables=[],this.tableInputContainer=P.div([]),this.subscribeToTableEvents(),this.refreshTableInput()}getTableInputContainer(){return this.tableInputContainer}subscribeToTableEvents(){o.events.onTableAdded.subscribe((e=>this.handleTableAdded(e))),o.events.onTableRemoved.subscribe((e=>this.handleTableRemoved(e))),this.eventBus.tableSelected$.subscribe((()=>this.handleTableChoice()))}getTableFromEventData(e){return e.args.dataFrame}handleTableAdded(e){const t=this.getTableFromEventData(e);this.availableTables.some((e=>e.name===t.name))||(this.availableTables.push(t),this.eventBus.selectTable(t),this.refreshTableInput())}handleTableRemoved(e){const t=this.getTableFromEventData(e);this.availableTables=this.availableTables.filter((e=>e.name!==t.name));const n=this.availableTables[0];this.eventBus.selectTable(n||null),this.refreshTableInput()}refreshTableInput(){const e=this.createTableInput();L()(this.tableInputContainer).empty(),this.tableInputContainer.append(e.root)}createTableInput(){const e=this.eventBus.getSelectedTable();return P.input.table("Table",{value:e,items:this.availableTables,onValueChanged:e=>{null!==e&&this.eventBus.selectTable(e)}})}handleTableChoice(){const e=this.eventBus.getSelectedTable();e&&(this.isTableDisplayed(e)||this.displayTable(e))}isTableDisplayed(e){return o.shell.tableNames.includes(e.name)}displayTable(e){const t=o.shell.v;o.shell.addTableView(e),o.shell.v=t}}class jt{constructor(e){this.eventBus=e,this.columnControlsContainer=P.div([]),this.eventBus.tableSelected$.subscribe((()=>this.handleTableChoice())),this.refreshColumnControls()}getColumnControlsContainer(){return this.columnControlsContainer}handleTableChoice(){this.refreshColumnControls()}refreshColumnControls(){const e=this.createColumnInputs();L()(this.columnControlsContainer).empty();const t=e.map((e=>e.root));this.columnControlsContainer.append(...t)}createColumnInputs(){const e=this.eventBus.getSelectedTable(),t=null!==e?e.columns.names().sort(((e,t)=>e.localeCompare(t))):[];return Ht.map((n=>this.createColumnInput(n,t,e)))}createColumnInput(e,t,n){const o=e.toLowerCase(),r=t.find((e=>e.toLowerCase().includes(o)))||t[0];return this.selectColumnIfTableNotNull(n,r,e),P.input.choice(`${e}`,{value:r,items:t,onValueChanged:t=>this.selectColumnIfTableNotNull(n,t,e)})}selectColumnIfTableNotNull(e,t,n){if(null!==e&&t){const o=e.col(t);o&&this.eventBus.selectColumn(n,o)}}}class qt{constructor(){this._tableSelection$=new te.BehaviorSubject(null),this._columnSelection=Object.fromEntries(Ht.map((e=>[e,new te.BehaviorSubject(null)]))),this._inputFormatSelection$=new te.BehaviorSubject(f.NO.AXOLABS),this._outputFormatSelection$=new te.BehaviorSubject(Bt.qP)}static getInstance(){return void 0===qt._instance&&(qt._instance=new qt),qt._instance}get tableSelected$(){return this._tableSelection$.asObservable()}getSelectedTable(){return this._tableSelection$.getValue()}selectTable(e){this._tableSelection$.next(e)}selectColumn(e,t){this._columnSelection[e].next(t)}getSelectedColumn(e){return this._columnSelection[e].getValue()}getSelectedInputFormat(){return this._inputFormatSelection$.getValue()}selectInputFormat(e){this._inputFormatSelection$.next(e)}selectOutputFormat(e){this._outputFormatSelection$.next(e)}getSelectedOutputFormat(){return this._outputFormatSelection$.getValue()}}class Wt extends F{constructor(e){super("Oligo Translator"),this.th=e,this.th=br,this.layout=new Gt(this.th);const t=P.iconFA("book",$t.view,"View monomer library");this.topPanel=[t],this.view.setRibbonPanels([this.topPanel])}getContent(){return this.layout.getHtmlElement()}}class zt extends F{constructor(e,t){super(e),this.content=t}getContent(){return Promise.resolve(this.content)}}class Yt extends B{constructor(e,t){super("Oligo Toolkit"),this.externalViewFactories=e,this.th=t;const n=this.getViewFactories(this.th);this.multiView=new r.MultiView({viewFactories:n})}getViewFactories(e){function t(t){r.View.create();const n=new t(e);return n.initView().catch((e=>console.error(`Failed to initialize ${t.name}: ${e}`))),()=>n.getView()}let n={TRANSLATOR:t(Wt),PATTERN:t(it),STRUCTURE:t(Lt)};return this.externalViewFactories&&(n=Object.assign({},n,this.externalViewFactories)),n}getCurrentPanePath(){let e=this.multiView.tabs.currentPane.name;return e=e.charAt(0).toUpperCase()+e.substring(1).toLowerCase(),`/apps/${br.name}/OligoToolkit/${e}`}setUrl(){this.multiView.path=this.getCurrentPanePath()}async constructView(){return this.multiView.tabs.onTabChanged.subscribe((()=>this.setUrl())),this.setUrl(),this.multiView}}function Kt(e){const t=P.input.textArea("",{value:""});return{coloredInput:new dt(t,e.highlightInvalidSubsequence),codes:e.jsonData.codesToSymbolsDict}}var Qt=n(5733),Jt=n(5613),Xt=n(1536);const Zt=110,en=90;function tn(e,t,n=!1){return P.divH([P.divText(e,{style:{color:"var(--grey-4, #888)",width:"90px",flexShrink:"0"}}),P.divText(t,{style:n?{fontFamily:"ui-monospace, Menlo, monospace",wordBreak:"break-all"}:{}})],{style:{gap:"6px"}})}let nn=null;function on(e,t,n){const o=[t];"sugar"===n?o.push((0,Xt.Jy)(t)):"phosphate"===n&&o.push((0,Xt.$T)(t));const r=e.getPolymerTypes().filter((e=>"RNA"===e||"CHEM"===e)).concat(e.getPolymerTypes().filter((e=>"RNA"!==e&&"CHEM"!==e)));for(const t of o)for(const n of r){const o=e.getMonomer(n,t);if(o&&o.molfile)return o.molfile}return null}function rn(e){let t=e.symbol;return"sugar"===e.kind?t=(0,Xt.Jy)(e.symbol):"phosphate"===e.kind&&(t=(0,Xt.$T)(e.symbol)),`${e.kind}:${t}`}function sn(e){const t=P.div([],{style:{borderRadius:"4px",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"10px",color:"var(--grey-4, #888)",textAlign:"center",padding:"4px"}}),n=P.divText(e,{style:{fontSize:"10px",color:"var(--grey-5, #555)",textAlign:"center",marginTop:"2px",letterSpacing:"0.04em",textTransform:"uppercase",fontWeight:"600"}});return{root:P.divV([t,n],{style:{display:"inline-flex"}}),body:t}}const an=new Map;function ln(e,t,n){try{let r=an.get(n);r||(r=o.chem.drawMolecule(t,Zt,en,!1),an.size>256&&an.clear(),an.set(n,r)),e.innerHTML="",e.appendChild(r)}catch{e.textContent="Render failed"}}const cn="OligoNucleotide";class un extends r.GridCellRenderer{constructor(){super(...arguments),this.modelCache=new Map,this.layoutCache=new Map}get name(){return cn}get cellType(){return cn}get defaultWidth(){return 320}get defaultHeight(){return 64}render(e,t,n,o,r,i,s){const a=i.cell.value;if(!a||!(0,Jt.yO)(a))return e.save(),e.beginPath(),e.rect(t,n,o,r),e.clip(),e.fillStyle="#8b949e",e.font="11px ui-monospace, Menlo, monospace",e.textBaseline="middle",e.textAlign="left",e.fillText(a??"",t+4,n+r/2),void e.restore();const l=this.getOrParse(a),c=(0,Qt.Z4)(e,t,n,o,r,l);this.layoutCache.set(this.cellKey(i),c),this.layoutCache.size>5e3&&this.layoutCache.clear()}onMouseMove(e,t){const n=e.cell.value;if(!n||!(0,Jt.yO)(n))return void P.tooltip.hide();const o=this.getOrParse(n),r=this.layoutCache.get(this.cellKey(e));if(!r)return;const i=e.bounds,s=t.offsetX-i.x,a=t.offsetY-i.y,c=(0,Qt.CB)(s,a,o,r);c?function(e,t,n){const o=function(e){const t=e.monomer,n=P.divText("",{style:{fontWeight:"600",marginBottom:"4px"}}),o=[];if(e.linkage){const t=(0,Xt.bM)(e.linkage.phosphateSymbol);n.textContent=`${t.meta.name} linkage`,o.push(tn("Strand","sense"===e.strand?"Sense":"Antisense"),tn("Between",`pos ${e.position+1} – ${e.position+2}`),tn("HELM symbol",`[${(0,Xt.$T)(e.linkage.phosphateSymbol)}]`,!0))}else if("nucleotide"===t.kind){const r=t,i=(0,Xt.xh)(r.sugar,r.base),s=(0,Xt.bM)(r.phosphate);n.textContent=`${r.base??"?"}${e.position+1} — ${i.meta.name}`,o.push(tn("Strand","sense"===e.strand?"Sense":"Antisense"),tn("Position",String(e.position+1)),tn("Base",r.base??"—"),tn("Sugar",i.meta.name),tn("3'-linkage",s.meta.name),tn("HELM",r.raw,!0))}else{const r=(0,Xt.rK)(t.symbol);n.textContent=r.meta.name,o.push(tn("Strand","sense"===e.strand?"Sense":"Antisense"),tn("Position",String(e.position+1)),tn("Type","Terminal conjugate / linker"),tn("HELM",t.raw,!0))}const r=P.div([],{style:{marginTop:"8px",display:"flex",flexDirection:"row",gap:"6px",flexWrap:"wrap"}});r.dataset.role="struct";const i=P.divText("Loading structures…",{style:{fontSize:"11px",color:"var(--grey-4, #888)"}});return r.appendChild(i),P.divV([n,...o,r],{style:{fontSize:"12px",lineHeight:"1.45",minWidth:"240px",maxWidth:"380px"}})}(e);P.tooltip.show(o,t+14,n+14),async function(e,t){const n=e.querySelector('[data-role="struct"]');if(!n)return;let o,r;if(t.linkage)o=[{label:"Linkage",symbol:t.linkage.phosphateSymbol,kind:"phosphate"}];else if("nucleotide"===t.monomer.kind){const e=t.monomer;o=[{label:"Sugar",symbol:e.sugar,kind:"sugar"}],e.base&&o.push({label:"Base",symbol:e.base,kind:"base"}),e.phosphate&&o.push({label:"3'-linkage",symbol:e.phosphate,kind:"phosphate"})}else o=[{label:"Conjugate",symbol:t.monomer.symbol,kind:"conjugate"}];try{r=await(nn||(nn=(async()=>(await(0,l.pj)()).getMonomerLib())()),nn)}catch{return n.innerHTML="",void n.appendChild(P.divText("Monomer library unavailable",{style:{fontSize:"11px",color:"var(--grey-4, #888)"}}))}n.innerHTML="";for(const e of o){const t=sn(e.label);n.appendChild(t.root);const o=on(r,e.symbol,e.kind);o?ln(t.body,o,rn(e)):t.body.textContent=`Not in HELMCore: ${e.symbol}`}}(o,e)}(c,t.clientX,t.clientY):P.tooltip.hide()}onMouseLeave(e,t){P.tooltip.hide()}getOrParse(e){let t=this.modelCache.get(e);return t||(t=(0,Jt.On)(e),this.modelCache.size>5e3&&this.modelCache.clear(),this.modelCache.set(e,t)),t}cellKey(e){return`${e.tableColumn?.name??e.gridColumn?.name??"?"}::${e.tableRowIndex??-1}`}}function hn(e,t){e.set(t,(e.get(t)??0)+1)}function dn(e,t){const n=[],o=new Map;for(const[t,n]of e.entries()){const e=(0,Xt.xh)(t,null).meta;"RNA"!==e.short&&"DNA"!==e.short&&o.set(e.short,(o.get(e.short)??0)+n)}for(const[e,t]of o.entries())n.push(`${e} ×${t}`);const r=new Map;for(const[e,n]of t.entries()){const t=(0,Xt.bM)(e).meta;"PO"!==t.short&&r.set(t.short,(r.get(t.short)??0)+n)}for(const[e,t]of r.entries())n.push(`${e} ×${t}`);return n.length?n.join(", "):"unmodified"}function pn(e,t){return P.divV([P.divText(e,{style:{fontWeight:"600",marginTop:"8px",marginBottom:"4px",color:"var(--grey-5, #555)",textTransform:"uppercase",fontSize:"10px",letterSpacing:"0.04em"}}),t])}const mn=/^(RNA|DNA|PEPTIDE|CHEM|BLOB)\d+\{/;function fn(e,t){const n=P.div([],{style:{minHeight:"60px"}});return n.appendChild(P.divText("Building structure…",{style:{fontSize:"11px",color:"var(--grey-4, #888)",padding:"4px"}})),(async()=>{try{const t=r.SemanticValue.fromTableCell(e),i=await o.functions.call("Bio:toAtomicLevelPanel",{sequence:t});n.innerHTML="",n.appendChild(i?.root??P.divText("Structure not available",{style:{fontSize:"11px",color:"var(--grey-4, #888)"}}))}catch(e){n.innerHTML="",n.appendChild(P.divText(`${t} render failed: ${e?.message??String(e)}`,{style:{fontSize:"11px",color:"var(--grey-4, #888)"}}))}})(),n}function gn(e){return e.semType=Xt.mU,e.meta.units=Xt.D2,e.setTag("cell.renderer",Xt.mU),e.setTag("quality",Xt.mU),e}function yn(e,t){return e.split("$")[0].replace(/^(RNA|DNA|PEPTIDE|CHEM|BLOB)\d+\{/,`$1${t}{`)}var bn=n(9124),vn=n(9192),Cn=n(8312),xn=n(1991),wn=n.n(xn);const An="object"==typeof performance&&performance&&"function"==typeof performance.now?performance:Date,Tn=new Set,En="object"==typeof process&&process?process:{},Sn=(e,t,n,o)=>{"function"==typeof En.emitWarning?En.emitWarning(e,t,n,o):console.error(`[${n}] ${t}: ${e}`)};let Nn=globalThis.AbortController,In=globalThis.AbortSignal;if(void 0===Nn){In=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(e,t){this._onabort.push(t)}},Nn=class{constructor(){t()}signal=new In;abort(e){if(!this.signal.aborted){this.signal.reason=e,this.signal.aborted=!0;for(const t of this.signal._onabort)t(e);this.signal.onabort?.(e)}}};let e="1"!==En.env?.LRU_CACHE_IGNORE_AC_WARNING;const t=()=>{e&&(e=!1,Sn("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",t))}}Symbol("type");const Mn=e=>e&&e===Math.floor(e)&&e>0&&isFinite(e),Pn=e=>Mn(e)?e<=Math.pow(2,8)?Uint8Array:e<=Math.pow(2,16)?Uint16Array:e<=Math.pow(2,32)?Uint32Array:e<=Number.MAX_SAFE_INTEGER?_n:null:null;class _n extends Array{constructor(e){super(e),this.fill(0)}}class Ln{heap;length;static#e=!1;static create(e){const t=Pn(e);if(!t)return[];Ln.#e=!0;const n=new Ln(e,t);return Ln.#e=!1,n}constructor(e,t){if(!Ln.#e)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new t(e),this.length=0}push(e){this.heap[this.length++]=e}pop(){return this.heap[--this.length]}}class On{#t;#n;#o;#r;#i;#s;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#a;#l;#c;#u;#h;#d;#p;#m;#f;#g;#y;#b;#v;#C;#x;#w;#A;static unsafeExposeInternals(e){return{starts:e.#v,ttls:e.#C,sizes:e.#b,keyMap:e.#c,keyList:e.#u,valList:e.#h,next:e.#d,prev:e.#p,get head(){return e.#m},get tail(){return e.#f},free:e.#g,isBackgroundFetch:t=>e.#T(t),backgroundFetch:(t,n,o,r)=>e.#E(t,n,o,r),moveToTail:t=>e.#S(t),indexes:t=>e.#N(t),rindexes:t=>e.#I(t),isStale:t=>e.#M(t)}}get max(){return this.#t}get maxSize(){return this.#n}get calculatedSize(){return this.#l}get size(){return this.#a}get fetchMethod(){return this.#i}get memoMethod(){return this.#s}get dispose(){return this.#o}get disposeAfter(){return this.#r}constructor(e){const{max:t=0,ttl:n,ttlResolution:o=1,ttlAutopurge:r,updateAgeOnGet:i,updateAgeOnHas:s,allowStale:a,dispose:l,disposeAfter:c,noDisposeOnSet:u,noUpdateTTL:h,maxSize:d=0,maxEntrySize:p=0,sizeCalculation:m,fetchMethod:f,memoMethod:g,noDeleteOnFetchRejection:y,noDeleteOnStaleGet:b,allowStaleOnFetchRejection:v,allowStaleOnFetchAbort:C,ignoreFetchAbort:x}=e;if(0!==t&&!Mn(t))throw new TypeError("max option must be a nonnegative integer");const w=t?Pn(t):Array;if(!w)throw new Error("invalid max value: "+t);if(this.#t=t,this.#n=d,this.maxEntrySize=p||this.#n,this.sizeCalculation=m,this.sizeCalculation){if(!this.#n&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if("function"!=typeof this.sizeCalculation)throw new TypeError("sizeCalculation set to non-function")}if(void 0!==g&&"function"!=typeof g)throw new TypeError("memoMethod must be a function if defined");if(this.#s=g,void 0!==f&&"function"!=typeof f)throw new TypeError("fetchMethod must be a function if specified");if(this.#i=f,this.#w=!!f,this.#c=new Map,this.#u=new Array(t).fill(void 0),this.#h=new Array(t).fill(void 0),this.#d=new w(t),this.#p=new w(t),this.#m=0,this.#f=0,this.#g=Ln.create(t),this.#a=0,this.#l=0,"function"==typeof l&&(this.#o=l),"function"==typeof c?(this.#r=c,this.#y=[]):(this.#r=void 0,this.#y=void 0),this.#x=!!this.#o,this.#A=!!this.#r,this.noDisposeOnSet=!!u,this.noUpdateTTL=!!h,this.noDeleteOnFetchRejection=!!y,this.allowStaleOnFetchRejection=!!v,this.allowStaleOnFetchAbort=!!C,this.ignoreFetchAbort=!!x,0!==this.maxEntrySize){if(0!==this.#n&&!Mn(this.#n))throw new TypeError("maxSize must be a positive integer if specified");if(!Mn(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#P()}if(this.allowStale=!!a,this.noDeleteOnStaleGet=!!b,this.updateAgeOnGet=!!i,this.updateAgeOnHas=!!s,this.ttlResolution=Mn(o)||0===o?o:1,this.ttlAutopurge=!!r,this.ttl=n||0,this.ttl){if(!Mn(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#_()}if(0===this.#t&&0===this.ttl&&0===this.#n)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#t&&!this.#n){const e="LRU_CACHE_UNBOUNDED";(e=>!Tn.has(e))(e)&&(Tn.add(e),Sn("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",e,On))}}getRemainingTTL(e){return this.#c.has(e)?1/0:0}#_(){const e=new _n(this.#t),t=new _n(this.#t);this.#C=e,this.#v=t,this.#L=(n,o,r=An.now())=>{if(t[n]=0!==o?r:0,e[n]=o,0!==o&&this.ttlAutopurge){const e=setTimeout((()=>{this.#M(n)&&this.#O(this.#u[n],"expire")}),o+1);e.unref&&e.unref()}},this.#R=n=>{t[n]=0!==e[n]?An.now():0},this.#$=(r,i)=>{if(e[i]){const s=e[i],a=t[i];if(!s||!a)return;r.ttl=s,r.start=a,r.now=n||o();const l=r.now-a;r.remainingTTL=s-l}};let n=0;const o=()=>{const e=An.now();if(this.ttlResolution>0){n=e;const t=setTimeout((()=>n=0),this.ttlResolution);t.unref&&t.unref()}return e};this.getRemainingTTL=r=>{const i=this.#c.get(r);if(void 0===i)return 0;const s=e[i],a=t[i];return s&&a?s-((n||o())-a):1/0},this.#M=r=>{const i=t[r],s=e[r];return!!s&&!!i&&(n||o())-i>s}}#R=()=>{};#$=()=>{};#L=()=>{};#M=()=>!1;#P(){const e=new _n(this.#t);this.#l=0,this.#b=e,this.#D=t=>{this.#l-=e[t],e[t]=0},this.#B=(e,t,n,o)=>{if(this.#T(t))return 0;if(!Mn(n)){if(!o)throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");if("function"!=typeof o)throw new TypeError("sizeCalculation must be a function");if(n=o(t,e),!Mn(n))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}return n},this.#F=(t,n,o)=>{if(e[t]=n,this.#n){const n=this.#n-e[t];for(;this.#l>n;)this.#k(!0)}this.#l+=e[t],o&&(o.entrySize=n,o.totalCalculatedSize=this.#l)}}#D=e=>{};#F=(e,t,n)=>{};#B=(e,t,n,o)=>{if(n||o)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#N({allowStale:e=this.allowStale}={}){if(this.#a)for(let t=this.#f;this.#H(t)&&(!e&&this.#M(t)||(yield t),t!==this.#m);)t=this.#p[t]}*#I({allowStale:e=this.allowStale}={}){if(this.#a)for(let t=this.#m;this.#H(t)&&(!e&&this.#M(t)||(yield t),t!==this.#f);)t=this.#d[t]}#H(e){return void 0!==e&&this.#c.get(this.#u[e])===e}*entries(){for(const e of this.#N())void 0===this.#h[e]||void 0===this.#u[e]||this.#T(this.#h[e])||(yield[this.#u[e],this.#h[e]])}*rentries(){for(const e of this.#I())void 0===this.#h[e]||void 0===this.#u[e]||this.#T(this.#h[e])||(yield[this.#u[e],this.#h[e]])}*keys(){for(const e of this.#N()){const t=this.#u[e];void 0===t||this.#T(this.#h[e])||(yield t)}}*rkeys(){for(const e of this.#I()){const t=this.#u[e];void 0===t||this.#T(this.#h[e])||(yield t)}}*values(){for(const e of this.#N())void 0===this.#h[e]||this.#T(this.#h[e])||(yield this.#h[e])}*rvalues(){for(const e of this.#I())void 0===this.#h[e]||this.#T(this.#h[e])||(yield this.#h[e])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(e,t={}){for(const n of this.#N()){const o=this.#h[n],r=this.#T(o)?o.__staleWhileFetching:o;if(void 0!==r&&e(r,this.#u[n],this))return this.get(this.#u[n],t)}}forEach(e,t=this){for(const n of this.#N()){const o=this.#h[n],r=this.#T(o)?o.__staleWhileFetching:o;void 0!==r&&e.call(t,r,this.#u[n],this)}}rforEach(e,t=this){for(const n of this.#I()){const o=this.#h[n],r=this.#T(o)?o.__staleWhileFetching:o;void 0!==r&&e.call(t,r,this.#u[n],this)}}purgeStale(){let e=!1;for(const t of this.#I({allowStale:!0}))this.#M(t)&&(this.#O(this.#u[t],"expire"),e=!0);return e}info(e){const t=this.#c.get(e);if(void 0===t)return;const n=this.#h[t],o=this.#T(n)?n.__staleWhileFetching:n;if(void 0===o)return;const r={value:o};if(this.#C&&this.#v){const e=this.#C[t],n=this.#v[t];if(e&&n){const t=e-(An.now()-n);r.ttl=t,r.start=Date.now()}}return this.#b&&(r.size=this.#b[t]),r}dump(){const e=[];for(const t of this.#N({allowStale:!0})){const n=this.#u[t],o=this.#h[t],r=this.#T(o)?o.__staleWhileFetching:o;if(void 0===r||void 0===n)continue;const i={value:r};if(this.#C&&this.#v){i.ttl=this.#C[t];const e=An.now()-this.#v[t];i.start=Math.floor(Date.now()-e)}this.#b&&(i.size=this.#b[t]),e.unshift([n,i])}return e}load(e){this.clear();for(const[t,n]of e){if(n.start){const e=Date.now()-n.start;n.start=An.now()-e}this.set(t,n.value,n)}}set(e,t,n={}){if(void 0===t)return this.delete(e),this;const{ttl:o=this.ttl,start:r,noDisposeOnSet:i=this.noDisposeOnSet,sizeCalculation:s=this.sizeCalculation,status:a}=n;let{noUpdateTTL:l=this.noUpdateTTL}=n;const c=this.#B(e,t,n.size||0,s);if(this.maxEntrySize&&c>this.maxEntrySize)return a&&(a.set="miss",a.maxEntrySizeExceeded=!0),this.#O(e,"set"),this;let u=0===this.#a?void 0:this.#c.get(e);if(void 0===u)u=0===this.#a?this.#f:0!==this.#g.length?this.#g.pop():this.#a===this.#t?this.#k(!1):this.#a,this.#u[u]=e,this.#h[u]=t,this.#c.set(e,u),this.#d[this.#f]=u,this.#p[u]=this.#f,this.#f=u,this.#a++,this.#F(u,c,a),a&&(a.set="add"),l=!1;else{this.#S(u);const n=this.#h[u];if(t!==n){if(this.#w&&this.#T(n)){n.__abortController.abort(new Error("replaced"));const{__staleWhileFetching:t}=n;void 0===t||i||(this.#x&&this.#o?.(t,e,"set"),this.#A&&this.#y?.push([t,e,"set"]))}else i||(this.#x&&this.#o?.(n,e,"set"),this.#A&&this.#y?.push([n,e,"set"]));if(this.#D(u),this.#F(u,c,a),this.#h[u]=t,a){a.set="replace";const e=n&&this.#T(n)?n.__staleWhileFetching:n;void 0!==e&&(a.oldValue=e)}}else a&&(a.set="update")}if(0===o||this.#C||this.#_(),this.#C&&(l||this.#L(u,o,r),a&&this.#$(a,u)),!i&&this.#A&&this.#y){const e=this.#y;let t;for(;t=e?.shift();)this.#r?.(...t)}return this}pop(){try{for(;this.#a;){const e=this.#h[this.#m];if(this.#k(!0),this.#T(e)){if(e.__staleWhileFetching)return e.__staleWhileFetching}else if(void 0!==e)return e}}finally{if(this.#A&&this.#y){const e=this.#y;let t;for(;t=e?.shift();)this.#r?.(...t)}}}#k(e){const t=this.#m,n=this.#u[t],o=this.#h[t];return this.#w&&this.#T(o)?o.__abortController.abort(new Error("evicted")):(this.#x||this.#A)&&(this.#x&&this.#o?.(o,n,"evict"),this.#A&&this.#y?.push([o,n,"evict"])),this.#D(t),e&&(this.#u[t]=void 0,this.#h[t]=void 0,this.#g.push(t)),1===this.#a?(this.#m=this.#f=0,this.#g.length=0):this.#m=this.#d[t],this.#c.delete(n),this.#a--,t}has(e,t={}){const{updateAgeOnHas:n=this.updateAgeOnHas,status:o}=t,r=this.#c.get(e);if(void 0!==r){const e=this.#h[r];if(this.#T(e)&&void 0===e.__staleWhileFetching)return!1;if(!this.#M(r))return n&&this.#R(r),o&&(o.has="hit",this.#$(o,r)),!0;o&&(o.has="stale",this.#$(o,r))}else o&&(o.has="miss");return!1}peek(e,t={}){const{allowStale:n=this.allowStale}=t,o=this.#c.get(e);if(void 0===o||!n&&this.#M(o))return;const r=this.#h[o];return this.#T(r)?r.__staleWhileFetching:r}#E(e,t,n,o){const r=void 0===t?void 0:this.#h[t];if(this.#T(r))return r;const i=new Nn,{signal:s}=n;s?.addEventListener("abort",(()=>i.abort(s.reason)),{signal:i.signal});const a={signal:i.signal,options:n,context:o},l=(o,r=!1)=>{const{aborted:s}=i.signal,l=n.ignoreFetchAbort&&void 0!==o;if(n.status&&(s&&!r?(n.status.fetchAborted=!0,n.status.fetchError=i.signal.reason,l&&(n.status.fetchAbortIgnored=!0)):n.status.fetchResolved=!0),s&&!l&&!r)return c(i.signal.reason);const h=u;return this.#h[t]===u&&(void 0===o?h.__staleWhileFetching?this.#h[t]=h.__staleWhileFetching:this.#O(e,"fetch"):(n.status&&(n.status.fetchUpdated=!0),this.set(e,o,a.options))),o},c=o=>{const{aborted:r}=i.signal,s=r&&n.allowStaleOnFetchAbort,a=s||n.allowStaleOnFetchRejection,l=a||n.noDeleteOnFetchRejection,c=u;if(this.#h[t]===u&&(l&&void 0!==c.__staleWhileFetching?s||(this.#h[t]=c.__staleWhileFetching):this.#O(e,"fetch")),a)return n.status&&void 0!==c.__staleWhileFetching&&(n.status.returnedStale=!0),c.__staleWhileFetching;if(c.__returned===c)throw o};n.status&&(n.status.fetchDispatched=!0);const u=new Promise(((t,o)=>{const s=this.#i?.(e,r,a);s&&s instanceof Promise&&s.then((e=>t(void 0===e?void 0:e)),o),i.signal.addEventListener("abort",(()=>{n.ignoreFetchAbort&&!n.allowStaleOnFetchAbort||(t(void 0),n.allowStaleOnFetchAbort&&(t=e=>l(e,!0)))}))})).then(l,(e=>(n.status&&(n.status.fetchRejected=!0,n.status.fetchError=e),c(e)))),h=Object.assign(u,{__abortController:i,__staleWhileFetching:r,__returned:void 0});return void 0===t?(this.set(e,h,{...a.options,status:void 0}),t=this.#c.get(e)):this.#h[t]=h,h}#T(e){if(!this.#w)return!1;const t=e;return!!t&&t instanceof Promise&&t.hasOwnProperty("__staleWhileFetching")&&t.__abortController instanceof Nn}async fetch(e,t={}){const{allowStale:n=this.allowStale,updateAgeOnGet:o=this.updateAgeOnGet,noDeleteOnStaleGet:r=this.noDeleteOnStaleGet,ttl:i=this.ttl,noDisposeOnSet:s=this.noDisposeOnSet,size:a=0,sizeCalculation:l=this.sizeCalculation,noUpdateTTL:c=this.noUpdateTTL,noDeleteOnFetchRejection:u=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:h=this.allowStaleOnFetchRejection,ignoreFetchAbort:d=this.ignoreFetchAbort,allowStaleOnFetchAbort:p=this.allowStaleOnFetchAbort,context:m,forceRefresh:f=!1,status:g,signal:y}=t;if(!this.#w)return g&&(g.fetch="get"),this.get(e,{allowStale:n,updateAgeOnGet:o,noDeleteOnStaleGet:r,status:g});const b={allowStale:n,updateAgeOnGet:o,noDeleteOnStaleGet:r,ttl:i,noDisposeOnSet:s,size:a,sizeCalculation:l,noUpdateTTL:c,noDeleteOnFetchRejection:u,allowStaleOnFetchRejection:h,allowStaleOnFetchAbort:p,ignoreFetchAbort:d,status:g,signal:y};let v=this.#c.get(e);if(void 0===v){g&&(g.fetch="miss");const t=this.#E(e,v,b,m);return t.__returned=t}{const t=this.#h[v];if(this.#T(t)){const e=n&&void 0!==t.__staleWhileFetching;return g&&(g.fetch="inflight",e&&(g.returnedStale=!0)),e?t.__staleWhileFetching:t.__returned=t}const r=this.#M(v);if(!f&&!r)return g&&(g.fetch="hit"),this.#S(v),o&&this.#R(v),g&&this.#$(g,v),t;const i=this.#E(e,v,b,m),s=void 0!==i.__staleWhileFetching&&n;return g&&(g.fetch=r?"stale":"refresh",s&&r&&(g.returnedStale=!0)),s?i.__staleWhileFetching:i.__returned=i}}async forceFetch(e,t={}){const n=await this.fetch(e,t);if(void 0===n)throw new Error("fetch() returned undefined");return n}memo(e,t={}){const n=this.#s;if(!n)throw new Error("no memoMethod provided to constructor");const{context:o,forceRefresh:r,...i}=t,s=this.get(e,i);if(!r&&void 0!==s)return s;const a=n(e,s,{options:i,context:o});return this.set(e,a,i),a}get(e,t={}){const{allowStale:n=this.allowStale,updateAgeOnGet:o=this.updateAgeOnGet,noDeleteOnStaleGet:r=this.noDeleteOnStaleGet,status:i}=t,s=this.#c.get(e);if(void 0!==s){const t=this.#h[s],a=this.#T(t);return i&&this.#$(i,s),this.#M(s)?(i&&(i.get="stale"),a?(i&&n&&void 0!==t.__staleWhileFetching&&(i.returnedStale=!0),n?t.__staleWhileFetching:void 0):(r||this.#O(e,"expire"),i&&n&&(i.returnedStale=!0),n?t:void 0)):(i&&(i.get="hit"),a?t.__staleWhileFetching:(this.#S(s),o&&this.#R(s),t))}i&&(i.get="miss")}#G(e,t){this.#p[t]=e,this.#d[e]=t}#S(e){e!==this.#f&&(e===this.#m?this.#m=this.#d[e]:this.#G(this.#p[e],this.#d[e]),this.#G(this.#f,e),this.#f=e)}delete(e){return this.#O(e,"delete")}#O(e,t){let n=!1;if(0!==this.#a){const o=this.#c.get(e);if(void 0!==o)if(n=!0,1===this.#a)this.#U(t);else{this.#D(o);const n=this.#h[o];if(this.#T(n)?n.__abortController.abort(new Error("deleted")):(this.#x||this.#A)&&(this.#x&&this.#o?.(n,e,t),this.#A&&this.#y?.push([n,e,t])),this.#c.delete(e),this.#u[o]=void 0,this.#h[o]=void 0,o===this.#f)this.#f=this.#p[o];else if(o===this.#m)this.#m=this.#d[o];else{const e=this.#p[o];this.#d[e]=this.#d[o];const t=this.#d[o];this.#p[t]=this.#p[o]}this.#a--,this.#g.push(o)}}if(this.#A&&this.#y?.length){const e=this.#y;let t;for(;t=e?.shift();)this.#r?.(...t)}return n}clear(){return this.#U("delete")}#U(e){for(const t of this.#I({allowStale:!0})){const n=this.#h[t];if(this.#T(n))n.__abortController.abort(new Error("deleted"));else{const o=this.#u[t];this.#x&&this.#o?.(n,o,e),this.#A&&this.#y?.push([n,o,e])}}if(this.#c.clear(),this.#h.fill(void 0),this.#u.fill(void 0),this.#C&&this.#v&&(this.#C.fill(0),this.#v.fill(0)),this.#b&&this.#b.fill(0),this.#m=0,this.#f=0,this.#g.length=0,this.#l=0,this.#a=0,this.#A&&this.#y){const e=this.#y;let t;for(;t=e?.shift();)this.#r?.(...t)}}}function Rn(){var e;return null!==(e=window.$monomerHover)&&void 0!==e?e:null}function $n(e){window.$monomerHover=e}function Dn(e,t){let n=e["substruct-providers"];n||(n=e["substruct-providers"]=[]),n.push(t),e["substruct-providers"]=n}var Bn=n(6077),Fn=n(3561),kn=n(9235);const Hn="MonomerHoverLinks";function Gn(e,t){let n=e[Hn];n||(n=e[Hn]=[]),n.push(t),e[Hn]=n}function Un(e,t){try{const n=e.tableColumn;if(!n)return;const o=function(e){return e.temp[Hn]??[]}(n);for(let n=o.length-1;n>=0;--n){const r=o[n],i=e.grid.col(r.targetCol.name);if(i&&!r.handler(e,t,i))break}}catch(e){console.error(e)}}var Vn=n(6717),jn=n(6694),qn=n(4229),Wn=n(5174);function zn(e,t=!0){const[n,r]=(0,vn.AP)(e);return br.logger.error(n,void 0,r),t&&o.shell.error(n),[n,r]}const Yn={symbol:"Short Name",name:"Medium Name",smiles:"SMILES"},Kn=[{capGroupSmiles:"[*:1][H]",alternateId:"R1-H",capGroupName:"H",label:"R1"},{capGroupSmiles:"O[*:2]",alternateId:"R2-OH",capGroupName:"OH",label:"R2"},{capGroupSmiles:"[*:3][H]",alternateId:"R3-H",capGroupName:"H",label:"R3"}],Qn="Get HELM",Jn="Chirality engine",Xn="Highlight monomers",Zn="PolyTool Conversion",eo="PolyTool Helm Enumeration",to="Rules used",no={single:"Each position is enumerated independently. Total results = sum of monomers across all positions.",parallel:"The i-th result uses the i-th monomer from every position (zip). All positions must have the same number of monomers. Total results = number of monomers per position.",matrix:"Cartesian product of all positions. Total results = product of monomer counts across all positions."};var oo=n(5412);async function ro(e,t,n,i,s,a){const l=r.TaskBarProgressIndicator.create("PolyTool converting...");try{const l=(e,t)=>e?e.columns.getUnusedName(t):t,c=await(0,bn.b2)(),u=e.dataFrame,h=await(0,jn.Q4)(a),[d,p,m]=(0,qn.b)(e.toList(),h,c),f=l(u,`transformed(${e.name})`),g=r.Column.fromType(r.COLUMN_TYPE.STRING,f,d.length).init((e=>d[e]));g.semType=r.SEMTYPE.MACROMOLECULE,g.meta.units=Ot.Hi.HELM,g.setTag(r.TAGS.CELL_RENDERER,"helm"),t&&u&&u.columns.add(g,!0);const y=await(0,Vn.j)(),b=await(0,Cn.Q)(),v=await(0,Wn.A)(h),C=g.temp;C[".mm.cellRenderer.overriddenLibrary"]=v,g.temp=C;const x=await(0,oo.m)(g,d,p,i,s,n,v,y,b);return x.name=l(u,`molfile(${e.name})`),x.semType=r.SEMTYPE.MOLECULE,u&&(u.columns.add(x,!0),await o.data.detectSemanticTypes(u)),function(e,t,n,o,r,i,s){const a=new On({max:100});function l(e,t){const n=e.get(t);if(null==n)return null;let s=a.get(n);return s||a.set(n,s=function(e,t){const n=r.getSeqHandler(e),s=n.getSplitted(t),a=n.defaultBiotype,l=wn().count(0).take(s.length).map((e=>({position:e,symbol:s.getCanonical(e),biotype:a}))).toArray(),c=n.alphabet,u=c==Ot.YI.RNA||c==Ot.YI.DNA?"RNA":"PEPTIDE",h=(0,Bn.eM)([l],[void 0],u,c,o,i);return(0,Fn.gU)(l,h,c,u).monomers}(e,t)),s}const c={targetCol:n,handler:(e,n,r)=>{if(!e||!r.grid||!t.dataFrame)return!0;const i=r.grid,a=e.tableRowIndex,c=e.gridRow,u=i.cell(r.name,c),h=s[c],d=Rn();if(!d||d&&(d.dataFrameId!=t.dataFrame?.id||d.gridRowIdx!=c||d.seqColName!=t.name||d.seqPosition!=n?.position)){if(d&&($n(null),d.gridCell.render()),!n)return $n(null),!0;$n({gridCell:u,dataFrameId:t.dataFrame.id,gridRowIdx:c,seqColName:t.name,seqPosition:n?n.position:-1,getSubstruct:()=>{if(!n||"*"===n.symbol)return;const e=l(t,a);if(!e)return;const r=[],i=h[n.position];for(const t of i){const n=e.get(t);if(!n)return{atoms:[],bonds:[],highlightAtomColors:[],highlightBondColors:[]};r.push((0,kn.H)([n],o))}return function(e){var t,n,o,r;const i={atoms:[],bonds:[],highlightAtomColors:{},highlightBondColors:{}};for(const s of e)i.atoms=[...null!==(t=i.atoms)&&void 0!==t?t:[],...null!==(n=s.atoms)&&void 0!==n?n:[]],i.bonds=[...null!==(o=i.bonds)&&void 0!==o?o:[],...null!==(r=s.bonds)&&void 0!==r?r:[]],i.highlightAtomColors=Object.assign(Object.assign({},i.highlightAtomColors),s.highlightAtomColors),i.highlightBondColors=Object.assign(Object.assign({},i.highlightBondColors),s.highlightBondColors);return i}(r)}}),u.render()}return!0},getSubstruct:e=>{if("true"!=n.getTag(".sequence-src-highlight-monomers"))return;if(null==e)return;if(!t.get(e))return;const r=l(t,e);return r?(0,kn.H)(r.values(),o):void 0}};Gn(e.temp,c),Dn(n.temp,c)}(e,g,x,v,b,y,m),[g,x]}finally{l.close()}}var io=n(3309);const so="PolyTool Chem Enumeration",ao={[io.PI.Zip]:"Zip: every R-group list must have the same length N. The i-th result uses the i-th entry from every list. Produces N results per core.",[io.PI.Cartesian]:"Cartesian: every combination of entries across R-group lists. Produces ∏|Rᵢ| results per core."},lo=110,co=104,uo=100,ho=72,po=320,mo=260;function fo(e,t,n,r){P.empty(e);try{const i=o.chem.drawMolecule(t,n,r);i.style.width=`${n}px`,i.style.height=`${r}px`,i.style.maxWidth=`${n}px`,i.style.maxHeight=`${r}px`,i.style.display="block",e.appendChild(i)}catch{e.appendChild(P.divText("—",{style:{color:"var(--grey-4)"}}))}}function go(e){const t=P.div([],{style:{width:`${uo}px`,height:`${ho}px`,display:"flex",alignItems:"center",justifyContent:"center",background:"transparent",overflow:"hidden",flex:"0 0 auto"}});e.smiles&&!e.error?fo(t,e.smiles,uo,ho):t.appendChild(P.divText("—",{style:{color:"var(--grey-4)"}}));const n=P.divText(e.subtitle,{style:{fontSize:"10px",color:e.error?"var(--red-3)":"var(--grey-5)",textAlign:"center",padding:"2px 4px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"}}),o=P.divV([t,n],{style:{width:`${lo}px`,minWidth:`${lo}px`,height:`${co}px`,border:"2px solid "+(e.error?"var(--red-3)":"var(--grey-2)"),borderRadius:"4px",position:"relative",background:"var(--white)",boxSizing:"border-box",margin:"0 4px 0 0",overflow:"hidden",flex:"0 0 auto"}});if(e.smiles&&!e.error){let t=null;P.tooltip.bind(o,(()=>(t||(t=P.div([],{style:{width:`${po}px`,height:`${mo}px`}}),fo(t,e.smiles,po,mo)),t)))}else e.error&&P.tooltip.bind(o,e.error);const r=P.divH([],{style:{position:"absolute",top:"2px",right:"2px",gap:"2px",background:"rgba(255,255,255,0.85)",borderRadius:"4px",padding:"1px 2px",display:"none"}});if(e.onEdit){const t=P.icons.edit((t=>{t.stopPropagation(),e.onEdit()}),"Edit");r.appendChild(t)}if(e.onRemove){const t=P.icons.delete((t=>{t.stopPropagation(),e.onRemove()}),"Remove");r.appendChild(t)}return o.addEventListener("mouseenter",(()=>{r.style.display="flex"})),o.addEventListener("mouseleave",(()=>{r.style.display="none"})),(e.onEdit||e.onRemove)&&o.appendChild(r),o}async function yo(e,t){const n=e.getMolFile();if(!n||""===n.trim())return null;if(!r.chem.isMolBlock(n))return n.trim();try{return(await o.functions.call("Chem:convertMolNotation",{molecule:n,sourceNotation:r.chem.Notation.MolBlock,targetNotation:r.chem.Notation.Smiles})??"").toString().trim()||null}catch{return null}}async function bo(e,t){return new Promise((n=>{const o=new r.chem.Sketcher(r.chem.SKETCHER_MODE.INPLACE);o.syncCurrentObject=!1,t&&o.setMolFile(t);const i=P.divText("",{style:{fontSize:"11px",padding:"4px 0",minHeight:"18px"}});let s=null,a=null;const l=async()=>{s=await yo(o);const e=s?(0,io.Qk)(s):[];s?0===e.length?(i.innerText="No R-group detected — add e.g. [*:1] to mark an attachment point.",i.style.color="var(--red-3)"):(i.innerText=`Detected R-groups: ${e.map((e=>"R"+e)).join(", ")}.`,i.style.color="var(--green-2)"):(i.innerText="Draw a molecule with at least one R-group label.",i.style.color="var(--grey-4)"),a&&(a.disabled=!(s&&e.length>0))};o.onChanged.subscribe((()=>{l()}));const c=P.divV([o.root,i]),u=P.dialog({title:t?"Edit Core":"Draw Core"}).add(c).onOK((()=>n(s?(0,io.KS)(s,"",e):null))).onCancel((()=>n(null)));u.show({resizable:!0}),a=u.getButton("OK"),a.disabled=!0,l()}))}async function vo(e,t,n){return new Promise((o=>{const i=new r.chem.Sketcher(r.chem.SKETCHER_MODE.INPLACE);i.syncCurrentObject=!1,t&&i.setMolFile(t);const s=P.input.int("Target R#",{value:n,min:1}),a=P.divText("",{style:{fontSize:"11px",padding:"4px 0",minHeight:"18px"}});let l=null,c=[],u=null,h=!1;s.onChanged.subscribe((()=>{h=!0,d()}));const d=()=>{const e=s.value,t=null!=l&&null!=e&&e>=1&&1===c.length;u&&(u.disabled=!t)},p=async()=>{l=await yo(i),c=l?(0,io.Qk)(l):[],l?0===c.length?(a.innerText="No R-group detected — add [*:N] to mark the attachment point.",a.style.color="var(--red-3)"):c.length>1?(a.innerText=`R-group must contain exactly one attachment point. Found ${c.length}: ${c.map((e=>"R"+e)).join(", ")}.`,a.style.color="var(--red-3)"):(h&&null!=s.value||(s.value=c[0]),a.innerText=`Detected R${c[0]}. Target R# is used for joining; change it to remap.`,a.style.color="var(--green-2)"):(a.innerText="Draw an R-group with exactly one attachment point.",a.style.color="var(--grey-4)"),d()};i.onChanged.subscribe((()=>{p()}));const m=P.divV([i.root,s.root,a]),f=P.dialog({title:t?"Edit R-Group":"Draw R-Group"}).add(m).onOK((()=>{const t=s.value;o(l&&null!=t?(0,io.ah)(l,t,"",e):null)})).onCancel((()=>o(null)));f.show({resizable:!0}),u=f.getButton("OK"),u.disabled=!0,p()}))}async function Co(e,t,n){return new Promise((i=>{const s=e=>e.semType===r.SEMTYPE.MOLECULE,a=P.input.table("Table",{value:o.shell.t??void 0}),l=P.input.choice("Column",{items:[],nullable:!0}),c="rgroups"===e?P.input.int("Target R#",{value:1,min:1}):null,u=P.input.bool("Remove duplicates",{value:n});P.tooltip.bind(u.input,"cores"===e?"When checked, identical cores in the selected column are collapsed into one entry.":"When checked, identical R-groups are collapsed. Leave off for Zip mode if your lists are intentionally aligned by position.");const h=e=>{const t=a.value;if(!t)return l.items=[],void(l.value=null);const n=t.columns.toList().filter(s);if(l.items=n.map((e=>e.name)),e){const e=n.find((e=>e.semType===r.SEMTYPE.MOLECULE));l.value=(e??n[0])?.name??null}},d=P.div([],{style:{height:`${co+26}px`,overflow:"hidden",padding:"4px"}}),p=P.divText("",{style:{fontSize:"11px",color:"var(--grey-5)",margin:"4px 0"}}),m=xo();let f={},g=null,y=null;const b=()=>{m.setErrors([]),f={};const n=(()=>{const e=a.value,t=l.value;return e&&t?e.col(t):null})();if(!n)return p.innerText="",g&&(g.disabled=!0),void(y&&y.setData(0,(()=>P.div())));const o=[];for(let e=0;e<n.length;e++){if(n.isNone(e))continue;const t=n.get(e);null!=t&&""!==String(t).trim()&&o.push(String(t))}const r=u.value,i=[],s=[];if("cores"===e){const e=o.map((e=>(0,io.KS)(e,"",t)));let n=e,a=0;if(r){const t=new Set;n=[];for(const o of e){const e=o.error?`err:${o.originalSmiles}`:o.smiles;t.has(e)?a++:(t.add(e),n.push(o))}}f.cores=n,n.forEach(((e,t)=>{e.error&&s.push(`Core ${t+1}: ${e.error}`),i.push({smi:e.error?"":e.smiles,err:e.error,subtitle:e.error?"invalid":e.rNumbers.map((e=>"R"+e)).join(", ")})})),p.innerText=`${n.length} core${1===n.length?"":"s"}`+(r&&a?` (${a} duplicate${1===a?"":"s"} skipped)`:"")+"."}else{const e=c.value??1,n=o.map((n=>(0,io.ah)(n,e,"",t)));let a=n,l=0;if(r){const e=new Set;a=[];for(const t of n){const n=t.error?`err:${t.originalSmiles}`:t.smiles;e.has(n)?l++:(e.add(n),a.push(t))}}f.rGroups=a,a.forEach(((e,t)=>{e.error&&s.push(`R-group ${t+1}: ${e.error}`),i.push({smi:e.error?"":e.smiles,err:e.error,subtitle:e.error?"invalid":`R${e.rNumber}${null!=e.sourceRNumber&&e.sourceRNumber!==e.rNumber?` (from R${e.sourceRNumber})`:""}`})})),p.innerText=`${a.length} R-group${1===a.length?"":"s"} for R${e}`+(r&&l?` (${l} duplicate${1===l?"":"s"} skipped)`:"")+"."}m.setErrors(s),y?y.setData(i.length,(e=>go({smiles:i[e].smi,subtitle:i[e].subtitle,error:i[e].err}))):(y=P.virtualView(i.length,(e=>go({smiles:i[e].smi,subtitle:i[e].subtitle,error:i[e].err})),!1,1),y.root.style.height=`${co+12}px`,y.root.style.width="100%",d.appendChild(y.root)),g&&(g.disabled=0===o.length)};a.onChanged.subscribe((async()=>{const e=a.value;e&&(await e.meta.detectSemanticTypes(),await o.data.detectSemanticTypes(e)),h(!0),b()})),l.onChanged.subscribe((()=>{if("rgroups"===e&&l.value){const e=function(e){const t=e.match(/r[\s_\-:]*(\d+)/i);return t?parseInt(t[1],10):null}(l.value);null!=e&&(c.value=e)}b()})),c&&c.onChanged.subscribe((()=>b())),u.onChanged.subscribe((()=>b()));const v=P.divV([a.root,l.root,...c?[c.root]:[],u.root,P.divH([p,m.root],{style:{alignItems:"center",gap:"8px"}}),d]),C=P.dialog({title:"cores"===e?"Import Cores":"Import R-Groups"}).add(v).onOK((()=>i(f))).onCancel((()=>i(null)));C.show({resizable:!0,width:640}),g=C.getButton("OK"),g.disabled=!0,a.value&&a.value.meta.detectSemanticTypes().then((()=>{h(!0),b()}))}))}function xo(){const e=P.div([],{style:{display:"none",alignItems:"center",gap:"4px",padding:"2px 8px",borderRadius:"10px",background:"var(--red-2)",color:"var(--red-3)",fontSize:"11px",fontWeight:"600",cursor:"help"}});return{root:e,setErrors(t){0!==t.length?(e.style.display="inline-flex",e.innerText=`⚠ ${t.length} issue${1===t.length?"":"s"}`,P.tooltip.bind(e,t.join("\n"))):e.style.display="none"}}}async function wo(e){await br.initPromise;try{const t=await(0,Vn.j)();let n=null;if(e){const i=await async function(e){try{if(!e||e.rowIndex<0||e.column?.semType!==r.SEMTYPE.MOLECULE)return null;const t=e.value;return t?r.chem.isMolBlock(t)?t:await o.functions.call("Chem:convertMolNotation",{molecule:t,sourceNotation:e.column.getTag(r.TAGS.UNITS)??r.chem.Notation.Unknown,targetNotation:r.chem.Notation.MolBlock})??null:null}catch{return null}}(e);if(i){const e=await o.functions.call("Chem:convertMolNotation",{molecule:i,sourceNotation:r.chem.Notation.MolBlock,targetNotation:r.chem.Notation.Smiles});if(e){const r=(0,io.KS)(e,"",t);r.error?o.shell.info("Selected molecule has no R-group — add at least one R-label to use it as a core."):n=r}}}const i=Ao(t,n),s=P.dialog({title:so}).add(i.root).onOK((async()=>{await i.execute()}));i.bindActionButton(s.getButton("OK")),s.show({resizable:!0,width:960})}catch(e){zn(e)}}function Ao(e,t){const n={cores:t?[t]:[],rGroupsByNum:new Map,mode:io.PI.Cartesian,appendToTable:null},i=co+16,s=P.divText("No cores — draw or import at least one.",{style:{color:"var(--grey-4)",padding:"20px 12px",fontSize:"12px"}}),a=P.div([],{style:{width:"100%",height:`${i}px`,overflow:"hidden"}});let l=null;const c=t=>{const o=n.cores[t];return go({smiles:o.error?"":o.smiles,subtitle:o.error?"invalid":`core ${t+1} · ${o.rNumbers.map((e=>"R"+e)).join(", ")}`,error:o.error,onEdit:async()=>{const r=await bo(e,o.smiles);r&&(n.cores[t]=r,A())},onRemove:()=>{n.cores.splice(t,1),A()}})};function u(e){e.style.width="100%",e.style.height=`${i}px`,e.style.setProperty("overflow-y","hidden","important"),e.style.setProperty("overflow-x","auto","important");const t=e.firstElementChild;t&&(t.style.setProperty("overflow-y","hidden","important"),t.style.setProperty("overflow-x","auto","important"),t.style.height=`${i}px`)}const h=P.div([],{style:{width:"100%",padding:"2px 0",flex:"1 1 auto",minHeight:"0",overflowY:"auto",overflowX:"hidden"}}),d=P.divText("No R-groups — draw or import for each R number used by your cores.",{style:{color:"var(--grey-4)",padding:"12px",fontSize:"12px"}}),p=new Map,m=P.div([],{style:{width:"100%",display:"flex",flexWrap:"wrap",gap:"6px",alignContent:"flex-start",padding:"2px 0",maxHeight:"450px",overflow:"scroll"}}),f=P.divText("",{style:{fontSize:"12px",color:"var(--grey-6)"}}),g=xo(),y=P.input.choice("Enumerator type",{value:n.mode,items:Object.values(io.PI),onValueChanged:e=>{n.mode=e,b(),A()}}),b=()=>P.tooltip.bind(y.input,ao[n.mode]??"");b();const v=P.input.table("Append to table",{items:o.shell.tables,nullable:!0,onValueChanged:e=>{n.appendToTable=e}});let C,x,w=null;const A=()=>{(()=>{if(0===n.cores.length)return a.firstChild&&P.empty(a),l=null,s.parentElement!==a.parentElement&&a.parentElement?.insertBefore(s,a.nextSibling),a.style.display="none",void(s.style.display="block");a.style.display="block",s.style.display="none",l?l.setData(n.cores.length,c):(l=P.virtualView(n.cores.length,c,!1,1),u(l.root),a.appendChild(l.root))})(),(()=>{if(P.empty(h),p.clear(),0===n.rGroupsByNum.size)return void h.appendChild(d);const t=[...n.rGroupsByNum.keys()].sort(((e,t)=>e-t));for(const o of t){const t=n.rGroupsByNum.get(o),r=P.divText(`R${o} (${t.length})`,{style:{fontWeight:"600",fontSize:"12px",color:"var(--grey-6)",alignSelf:"center"}}),i=P.button("Remove all",(()=>{n.rGroupsByNum.delete(o),A()}));i.style.marginLeft="4px",P.tooltip.bind(i,`Remove all R${o} groups`);const s=P.divH([r,i],{style:{alignItems:"center",justifyContent:"flex-start",gap:"0",margin:"6px 0 2px"}}),a=r=>{const i=t[r],s=null!=i.sourceRNumber&&i.sourceRNumber!==i.rNumber?` (from R${i.sourceRNumber})`:"";return go({smiles:i.error?"":i.smiles,subtitle:i.error?"invalid":`r group ${r+1} · R${i.rNumber}${s}`,error:i.error,onEdit:async()=>{const o=await vo(e,i.smiles,i.rNumber);if(o){if(o.rNumber!==i.rNumber){t.splice(r,1),0===t.length&&n.rGroupsByNum.delete(i.rNumber);const e=n.rGroupsByNum.get(o.rNumber)??[];e.push(o),n.rGroupsByNum.set(o.rNumber,e)}else t[r]=o;A()}},onRemove:()=>{t.splice(r,1),0===t.length&&n.rGroupsByNum.delete(o),A()}})},l=P.virtualView(t.length,a,!1,1);u(l.root);const c=P.divV([s,l.root]);h.appendChild(c),p.set(o,{row:c,vv:l,header:s})}})();const t=(0,io.XB)({cores:n.cores,rGroups:n.rGroupsByNum,mode:n.mode});f.innerText=t.predictedCount>0?`${t.predictedCount.toLocaleString()} molecule${1===t.predictedCount?"":"s"} will be generated`:"",g.setErrors((()=>{const e=[];n.cores.forEach(((t,n)=>{t.error&&e.push(`Core ${n+1}: ${t.error}`)}));const t=[...n.rGroupsByNum.keys()].sort(((e,t)=>e-t));for(const o of t)n.rGroupsByNum.get(o).forEach(((t,n)=>{t.error&&e.push(`R${o} group ${n+1}: ${t.error}`)}));const o=(0,io.XB)({cores:n.cores,rGroups:n.rGroupsByNum,mode:n.mode});for(const t of o.errors)/^Core "/.test(t)||e.push(t);return e})()),w&&(w.disabled=!t.ok),C&&(C.disabled=0===n.cores.length),x&&(x.disabled=0===n.rGroupsByNum.size),(()=>{P.empty(m);const e=(0,io.xD)({cores:n.cores,rGroups:n.rGroupsByNum,mode:n.mode,maxResults:Math.min(io.u8,1e3)},12);0!==e.length?e.forEach(((e,t)=>{const n=[...e.rGroupSmilesByNum.keys()].sort(((e,t)=>e-t)).map((e=>"R"+e)).join(",");m.appendChild(go({smiles:e.smiles,subtitle:`sample ${t+1} · ${n}`}))})):m.appendChild(P.divText("Preview will appear once cores and R-groups are valid.",{style:{color:"var(--grey-4)",padding:"20px 12px",fontSize:"12px"}}))})()},T=(e,t,n,o)=>{const r=[P.divText(e,{style:{fontWeight:"600",fontSize:"12px",color:"var(--grey-6)",alignSelf:"center",minWidth:"60px"}})];if(t){const n=P.button("+ Draw",t);n.style.marginLeft="4px",P.tooltip.bind(n,`${e}: open sketcher`),r.push(n)}if(n){const t=P.button("↓ Import…",n);t.style.marginLeft="4px",P.tooltip.bind(t,`${e}: pick a table + column`),r.push(t)}let i;return o&&(i=P.button("Remove all",o),i.style.marginLeft="4px",P.tooltip.bind(i,`Remove all ${e.toLowerCase()}`),r.push(i)),{root:P.divH(r,{style:{alignItems:"center",justifyContent:"flex-start",gap:"0",margin:"0 0 2px",flex:"0 0 auto"}}),clearBtn:i}},E={display:"flex",flexDirection:"column",minHeight:"150px",padding:"4px 0"},S=T("Cores",(async()=>{const t=await bo(e);t&&(n.cores.push(t),A())}),(async()=>{const t=await Co("cores",e,n.mode===io.PI.Cartesian);t?.cores&&(n.cores.push(...t.cores),A())}),(()=>{n.cores.splice(0,n.cores.length),A()}));C=S.clearBtn;const N=P.divV([S.root,P.div([a,s],{style:{padding:"0"}})],{style:E}),I=T("R-Groups",(async()=>{const t=await vo(e);if(!t)return;const o=n.rGroupsByNum.get(t.rNumber)??[];o.push(t),n.rGroupsByNum.set(t.rNumber,o),A()}),(async()=>{const t=await Co("rgroups",e,n.mode===io.PI.Cartesian);if(t?.rGroups){for(const e of t.rGroups){const t=n.rGroupsByNum.get(e.rNumber)??[];t.push(e),n.rGroupsByNum.set(e.rNumber,t)}A()}}),(()=>{n.rGroupsByNum.clear(),A()}));x=I.clearBtn;const M=P.divV([I.root,h],{style:{display:"flex",flexDirection:"column",maxHeight:"300px",padding:"4px 0"}}),_=P.divV([T("Preview").root,m],{style:{...E,width:"100%",height:"100%",overflowY:"auto",overflowX:"hidden"}}),L=P.divV([N,M],{style:{flex:"0 0 60%",width:"60%",display:"flex",flexDirection:"column",gap:"4px",paddingRight:"8px",borderRight:"1px solid var(--grey-2)"}}),O=P.divV([_],{style:{flex:"0 0 40%",width:"40%",display:"flex",flexDirection:"column",paddingLeft:"8px"}}),R=P.divH([L,O],{style:{width:"100%",alignItems:"stretch",gap:"0"}}),$=P.divH([y.root,f,g.root],{style:{alignItems:"center",gap:"16px",padding:"4px 0"}}),D=P.div([v.root],{style:{padding:"2px 0"}}),B=P.divV([R,$,D],{style:{width:"100%",padding:"4px",display:"flex",flexDirection:"column",gap:"4px"}});return A(),{root:B,state:n,execute:()=>async function(e){const t=r.TaskBarProgressIndicator.create("Enumerating...");try{t.update(10,"Building molecules...");const n=(0,io.jp)({cores:e.cores,rGroups:e.rGroupsByNum,mode:e.mode});if(!n)return void o.shell.warning("Enumeration failed — check validation messages in the dialog.");if(0===n.length)return void o.shell.warning("No molecules produced.");const i=new Set;for(const e of n)for(const t of e.rGroupSmilesByNum.keys())i.add(t);const s=[...i].sort(((e,t)=>e-t)),a=r.Column.fromStrings("Enumerated",n.map((e=>e.smiles)));a.semType=r.SEMTYPE.MOLECULE;const l=r.Column.fromStrings("Core",n.map((e=>e.coreSmiles)));l.semType=r.SEMTYPE.MOLECULE;const c=s.map((e=>r.Column.fromStrings(`R${e}`,n.map((t=>t.rGroupSmilesByNum.get(e)??"")))));for(const e of c)e.semType=r.SEMTYPE.MOLECULE;const u=r.DataFrame.fromColumns([a,l,...c]);u.name="Chem Enumeration",t.update(40,`Canonicalizing ${n.length.toLocaleString()} molecule(s)...`);try{await o.functions.call("Chem:convertNotation",{data:u,molecules:a,targetNotation:r.chem.Notation.Smiles,overwrite:!0,join:!1,kekulize:!1})}catch(e){br.logger.warning(`Canonicalization skipped: ${e?.message??e}`)}t.update(90,"Finalizing..."),await o.data.detectSemanticTypes(u),e.appendToTable?(e.appendToTable.append(u,!0),await e.appendToTable.meta.detectSemanticTypes()):o.shell.addTableView(u)}catch(e){zn(e)}finally{t.close()}}(n),bindActionButton:e=>{w=e,A()}}}var To=n(6197);class Eo extends r.InputBase{constructor(e,t){super(P.input.column(e,t).dart,t?.onValueChanged),this.options=t}setColumnInputTable(e){P.input.setColumnInputTable(this,e,this.options?.filter)}}P.input.column2=function(e,t){return new Eo(e,t)};var So=n(1296),No=n(3820);class Io extends r.JsInputBase{get inputType(){return"Positions"}get dataType(){return r.TYPE.DATA_FRAME}getInput(){return this.gridHost}getValue(){return this.grid.dataFrame}setValue(e){this.setDataFrame(e)}getStringValue(){return this.grid.dataFrame.toCsv()}setStringValue(e){this.setDataFrame(r.DataFrame.fromCsv(e))}clearInput(){const e=r.DataFrame.fromColumns([r.Column.fromType(r.COLUMN_TYPE.STRING,"Remove",0),r.Column.fromType(r.COLUMN_TYPE.INT,"Position",0),r.Column.fromType(r.COLUMN_TYPE.STRING,"Monomers",0)]);this.setDataFrame(e)}get placeholdersValue(){return function(e){const t=[];for(let n=0;n<e.rowCount;n++){if(e.getCol("Position").isNone(n))continue;const o=parseInt(e.get("Position",n))-1;if(!isNaN(o)){const r=Mo(e.get("Monomers",n));t.push({position:o,monomers:r})}}return t}(this.grid.dataFrame)}invalidateGrid(){if(this.grid){const e=this.grid.root.style.width;this.grid.root.style.width="99.9%",setTimeout((()=>{e?this.grid.root.style.width=e:this.grid.root.style.removeProperty("width")}),100)}}constructor(e,t,n){super(),this.name=e,this.onMonomerCellEdit=null,this.subs=[],this.dataFrameSubs=[],this.caption=e??"",this.root.classList.add("ui-input-polytool-pos-grid"),this.root.append(this.gridHost=P.div([],{classes:"ui-input-editor",style:{width:"100%",height:"100%",marginTop:"-8px",marginBottom:"8px",paddingBottom:"4px"}})),this.render(t,n).then((()=>{}))}detach(){for(const e of this.subs)e.unsubscribe();for(const e of this.dataFrameSubs)e.unsubscribe()}async render(e,t){let n;const o=r.DataFrame.fromColumns([n=r.Column.fromType(r.COLUMN_TYPE.STRING,"Remove",0),r.Column.fromType(r.COLUMN_TYPE.INT,"Position",0),r.Column.fromType(r.COLUMN_TYPE.STRING,"Monomers",0)]);n.setTag(r.TAGS.FRIENDLY_NAME,""),this.grid=await o.plot.fromType(r.VIEWER.GRID,t),this.grid.sort(["Position"]),this.grid.columns.byIndex(1).width=this.grid.props.rowHeight+2,this.grid.onCellRender.subscribe((e=>{const t=e.cell;t.tableColumn?.name==n.name&&(t?.tableRowIndex??-1)>=0&&(t.element=P.div(P.icons.delete((()=>{this.grid.dataFrame.rows.removeAt(t.tableRowIndex)}),"Delete"),{style:{height:`${t.grid.props.rowHeight}px`,color:"var(--grey-6)",display:"flex",flexDirection:"row",justifyContent:"center"}}))}));const i=this.grid.columns.byName("Monomers");i&&(i.editable=!1),this.subs.push(this.grid.onCellDoubleClick.subscribe((e=>{"Monomers"===e.tableColumn?.name&&null!=e.tableRowIndex&&e.tableRowIndex>=0&&this.handleMonomerCellDoubleClick(e.tableRowIndex)}))),this.updateGridHeight(e??this.grid.dataFrame.rowCount+.7),this.subs.push(P.onSizeChanged(this.grid.root).subscribe(this.gridRootOnSizeChanged.bind(this))),this.subs.push((0,te.fromEvent)(this.grid.root,"keydown").subscribe((e=>{"Enter"===e.key&&e.stopPropagation()}))),this.setDataFrame(o),this.grid.root.style.width="100%",this.gridHost.append(this.grid.root)}setDataFrame(e){for(const e of this.dataFrameSubs)e.unsubscribe();this.grid.dataFrame=e,this.dataFrameSubs.push(this.grid.dataFrame.onRowsRemoved.subscribe((()=>{this.updateGridHeight(this.grid.dataFrame.rowCount+.7),this.fireChanged()}))),this.dataFrameSubs.push(this.grid.dataFrame.onRowsAdded.subscribe((()=>{this.updateGridHeight(this.grid.dataFrame.rowCount+.7)}))),this.dataFrameSubs.push(this.grid.dataFrame.onDataChanged.subscribe((()=>{this.fireChanged()}))),this.updateGridHeight(this.grid.dataFrame.rowCount+.7),this.fireChanged()}addPosition(e,t){const n=this.grid.dataFrame,o=n.columns.byName("Position").toList();let r=o.indexOf(e+1);-1===r&&(r=o.findIndex((e=>isNaN(e))),-1===r&&(r=n.rows.addNew(["",e+1,t??""]).idx),this.grid.cell("Monomers",r)),n.currentCell=n.cell(r,"Monomers")}setMonomersValue(e,t){const n=this.grid.dataFrame;n.rowCount<=e||n.set("Monomers",e,t)}static async create(e,t,n){return new Io(e,n,t)}updateGridHeight(e){const t=this.grid.colHeaderHeight+e*this.grid.props.rowHeight+6+2;this.grid.root.style.height=`${t}px`}async handleMonomerCellDoubleClick(e){if(!this.onMonomerCellEdit)return;const t=this.grid.dataFrame,n=parseInt(t.get("Position",e))-1;if(isNaN(n))return;const o=Mo(t.get("Monomers",e)??""),r=await this.onMonomerCellEdit(n,o);null!==r&&t.set("Monomers",e,r.join(", "))}gridRootOnSizeChanged(){this.grid.columns.byIndex(3).width=this.grid.root.clientWidth-this.grid.horzScroll.root.offsetWidth-this.grid.columns.byIndex(0).width-this.grid.columns.byIndex(1).width-this.grid.columns.byIndex(2).width-10}}function Mo(e){return e.split(/,(?![^(]*\))/).map((e=>('"'===(e=e.trim()).slice(0,1)&&'"'===e.slice(-1)&&(e=e.slice(1,-1)),"'"===e.slice(0,1)&&"'"===e.slice(-1)&&(e=e.slice(1,-1)),e.trim()))).filter((e=>!!e))}class Po{constructor(e,t,n,o){this.currentMenu=null,this.menuItems=[],this.highlightedIndex=-1,this.monomerLib=e,this.polymerType=t,this.helmType=(0,s.MD)(t),this.allSymbols=e.getMonomerSymbolsByType(t),this.libHelper=o,this.selectedMonomers=n?[...n]:[],this.tagsHost=P.div([],{style:{display:"flex",flexWrap:"wrap",gap:"4px",marginTop:"4px",maxHeight:"150px",overflowY:"auto"}}),this.countLabel=P.divText("",{style:{fontSize:"11px",color:"var(--grey-4)",marginTop:"4px"}});const r=P.input.string("Search",{value:""});this.inputEl=r.input,this.inputEl.setAttribute("autocomplete","off"),this.inputEl.placeholder="Type to search monomers...",this.setupInputListeners();const i=this.createLibrarySection(),a=this.createCollectionSection(),l=P.button("Clear all",(()=>{this.selectedMonomers.length=0,this.renderTags()}));l.style.fontSize="11px",l.style.marginTop="4px",this.renderTags(),this.root=P.div([r.root,i,a,P.divH([this.countLabel,l],{style:{justifyContent:"space-between",alignItems:"center"}}),this.tagsHost],{style:{minWidth:"300px"}})}getSelectedMonomers(){return[...this.selectedMonomers]}setSelectedMonomers(e){this.selectedMonomers.length=0,this.selectedMonomers.push(...e),this.renderTags()}setPolymerType(e){this.polymerType=e,this.helmType=(0,s.MD)(e),this.allSymbols=this.monomerLib.getMonomerSymbolsByType(e)}focus(){this.inputEl.focus()}updateCountLabel(){this.countLabel.textContent=this.selectedMonomers.length>0?`${this.selectedMonomers.length} monomer(s) selected`:""}renderTags(){this.tagsHost.innerHTML="";for(const e of this.selectedMonomers){const t=P.iconFA("times",(()=>{const t=this.selectedMonomers.indexOf(e);t>=0&&(this.selectedMonomers.splice(t,1),this.renderTags(),this.updateCountLabel())}),"Remove");t.style.marginLeft="4px",t.style.cursor="pointer";const n=P.div([P.span([e]),t],{style:{display:"inline-flex",alignItems:"center",padding:"2px 6px",borderRadius:"4px",backgroundColor:"var(--grey-2)",border:"1px solid var(--grey-3)",fontSize:"12px",cursor:"default"}});n.addEventListener("mouseenter",(()=>{const t=this.monomerLib.getTooltip(this.helmType,e);P.tooltip.show(t,n.getBoundingClientRect().left,n.getBoundingClientRect().bottom+16)})),n.addEventListener("mouseleave",(()=>{P.tooltip.hide()})),this.tagsHost.appendChild(n)}this.updateCountLabel()}addMonomer(e){this.selectedMonomers.includes(e)||(this.selectedMonomers.push(e),this.renderTags()),this.inputEl.value="",this.hideMenu(),this.inputEl.focus()}addMonomers(e){let t=!1;for(const n of e)this.selectedMonomers.includes(n)||(this.selectedMonomers.push(n),t=!0);t&&this.renderTags()}hideMenu(){this.currentMenu&&(this.currentMenu.hide(),this.currentMenu=null),this.menuItems=[],this.highlightedIndex=-1}getSuggestions(e){const t=e.toLowerCase(),n=[];for(const e of this.allSymbols){if(this.selectedMonomers.includes(e))continue;const o=this.monomerLib.getMonomer(this.polymerType,e),r=e.toLowerCase(),i=o?.name?.toLowerCase()??"";r.startsWith(t)?n.push({symbol:e,monomer:o,rank:0}):r.includes(t)?n.push({symbol:e,monomer:o,rank:1}):i.includes(t)&&n.push({symbol:e,monomer:o,rank:2})}return n.sort(((e,t)=>e.rank-t.rank||e.symbol.localeCompare(t.symbol))),n.slice(0,20)}showSuggestions(){this.hideMenu();const e=this.inputEl.value.trim();if(!e)return;const t=this.getSuggestions(e);if(0===t.length)return;this.currentMenu=r.Menu.popup();const n=t.reduce(((e,t)=>{const n=t.monomer?.name?`${t.symbol} - ${t.monomer.name}`:t.symbol;return e.length<n.length?n:e}),"");this.currentMenu.item(n,(()=>{}));const o=new MouseEvent("mousemove",{clientX:this.inputEl.getBoundingClientRect().left,clientY:this.inputEl.getBoundingClientRect().bottom});this.currentMenu.show({causedBy:o,y:this.inputEl.offsetHeight+this.inputEl.offsetTop,x:this.inputEl.offsetLeft}),setTimeout((()=>{this.currentMenu?.clear();for(const e of t){const t=e.monomer?.name?`${e.symbol} - ${e.monomer.name}`:e.symbol;this.currentMenu?.item(t,(()=>{this.addMonomer(e.symbol)}))}const e=document.querySelector(".d4-menu-popup:last-of-type");e&&(this.menuItems=Array.from(e.querySelectorAll(".d4-menu-item"))),this.highlightedIndex=-1}),0)}updateHighlight(e){0!==this.menuItems.length&&(this.highlightedIndex>=0&&this.highlightedIndex<this.menuItems.length&&this.menuItems[this.highlightedIndex].classList.remove("d4-menu-item-hover"),this.highlightedIndex=e,this.highlightedIndex>=0&&this.highlightedIndex<this.menuItems.length&&(this.menuItems[this.highlightedIndex].classList.add("d4-menu-item-hover"),this.menuItems[this.highlightedIndex].scrollIntoView({block:"nearest"})))}setupInputListeners(){this.inputEl.addEventListener("input",(()=>{this.showSuggestions()})),this.inputEl.addEventListener("paste",(e=>{const t=e.clipboardData?.getData("text");if(!t)return;const n=t.split(/[\n\r]+/).map((e=>e.trim())).filter((e=>e.length>0)),o=[];for(const e of n){const t=e.split(/,(?![^(]*\))/).map((e=>('"'===(e=e.trim()).slice(0,1)&&'"'===e.slice(-1)&&(e=e.slice(1,-1)),"'"===e.slice(0,1)&&"'"===e.slice(-1)&&(e=e.slice(1,-1)),e.trim()))).filter((e=>!!e));1===t.length&&e.includes(" ")&&!e.includes(",")?o.push(...e.split(/\s+/).map((e=>e.trim())).filter((e=>e.length>0))):o.push(...t)}if(!(o.length<=1)){e.preventDefault();for(const e of o)this.selectedMonomers.includes(e)||this.selectedMonomers.push(e);this.renderTags(),this.inputEl.value="",this.hideMenu(),this.inputEl.focus()}})),this.inputEl.addEventListener("keydown",(e=>{if("ArrowDown"===e.key){if(e.preventDefault(),this.menuItems.length>0){const e=(this.highlightedIndex+1)%this.menuItems.length;this.updateHighlight(e)}}else if("ArrowUp"===e.key){if(e.preventDefault(),this.menuItems.length>0){const e=(this.highlightedIndex-1+this.menuItems.length)%this.menuItems.length;this.updateHighlight(e)}}else if("Enter"===e.key)if(e.preventDefault(),e.stopPropagation(),this.highlightedIndex>=0&&this.highlightedIndex<this.menuItems.length)this.menuItems[this.highlightedIndex].click();else{const e=this.inputEl.value.trim();e&&this.addMonomer(e)}else"Escape"===e.key&&this.hideMenu()}))}createLibrarySection(){const e=P.div([],{style:{marginTop:"8px"}});if(!this.libHelper)return e;const t=this.libHelper,n=P.input.choice("Add from library",{items:[],nullable:!0}),o=P.divText("",{style:{fontSize:"11px",color:"var(--green-2)",marginLeft:"8px",minHeight:"16px"}});return t.getAvaliableLibraryNames().then((e=>{n.items=e})),n.onChanged.subscribe((async()=>{const e=n.value;if(e){o.textContent="Loading...";try{const n=await t.readSingleLibraryByName(e);if(n){const t=n.getMonomerSymbolsByType(this.polymerType),r=this.selectedMonomers.length;this.addMonomers(t);const i=this.selectedMonomers.length-r;o.textContent=`Added ${i} monomer(s) from "${e}"`}else o.textContent=`Library "${e}" not found`}catch(e){o.textContent="Error loading library"}n.value=null,setTimeout((()=>{o.textContent=""}),4e3)}})),e.appendChild(P.divV([n.root,o])),e}createCollectionSection(){const e=P.div([],{style:{marginTop:"4px"}});if(!this.libHelper)return e;const t=this.libHelper,n=P.input.choice("Add from collection",{items:[],nullable:!0}),o=P.divText("",{style:{fontSize:"11px",color:"var(--green-2)",marginLeft:"8px",minHeight:"16px"}});return t.listMonomerCollections().then((e=>{n.items=e})),n.onChanged.subscribe((async()=>{const e=n.value;if(e){o.textContent="Loading...";try{const n=(await t.readMonomerCollection(e)).monomerSymbols??[],r=this.selectedMonomers.length;this.addMonomers(n);const i=this.selectedMonomers.length-r,s=e.replace(/\.json$/,"");o.textContent=`Added ${i} monomer(s) from "${s}"`}catch(e){o.textContent="Error loading collection"}n.value=null,setTimeout((()=>{o.textContent=""}),4e3)}})),e.appendChild(P.divV([n.root,o])),e}}async function _o(e,t,n,o){return new Promise((r=>{const i=new Po(e,t,n,o);P.dialog({title:"Select Monomers",showFooter:!0}).add(P.div([i.root],{style:{minWidth:"400px",minHeight:"250px",maxWidth:"800px"}})).onOK((()=>{r(i.getSelectedMonomers())})).onCancel((()=>{r(null)})).show({resizable:!0}),i.focus()}))}class Lo extends r.JsInputBase{get inputType(){return"Breadth"}get dataType(){return r.TYPE.DATA_FRAME}getInput(){return this.gridHost}getValue(){return this.grid.dataFrame}setValue(e){this.setDataFrame(e)}invalidateGrid(){if(this.grid){const e=this.grid.root.style.width;this.grid.root.style.width="99.9%",setTimeout((()=>{e?this.grid.root.style.width=e:this.grid.root.style.removeProperty("width")}),100)}}getStringValue(){return this.grid.dataFrame.toCsv()}setStringValue(e){this.setDataFrame(r.DataFrame.fromCsv(e))}get placeholdersBreadthValue(){return function(e){const t=[];for(let n=0;n<e.rowCount;n++){const o=parseInt(e.get("Start",n))-1,r=parseInt(e.get("End",n))-1;if(!isNaN(o)&&!isNaN(r)){const i=Mo(e.get("Monomers",n));t.push({start:o,end:r,monomers:i})}}return t}(this.grid.dataFrame)}constructor(e,t,n){super(),this.name=e,this.onMonomerCellEdit=null,this.subs=[],this.dataFrameSubs=[],this.caption=e??"",this.root.classList.add("ui-input-polytool-pos-grid"),this.root.append(this.gridHost=P.div([],{classes:"ui-input-editor",style:{width:"100%",height:"100%",marginTop:"-8px",marginBottom:"8px",paddingBottom:"4px"}})),this.render(t,n).then((()=>{}))}detach(){for(const e of this.subs)e.unsubscribe();for(const e of this.dataFrameSubs)e.unsubscribe()}clearInput(){const e=r.DataFrame.fromColumns([r.Column.fromType(r.COLUMN_TYPE.STRING,"Remove",0),r.Column.fromType(r.COLUMN_TYPE.INT,"Start",0),r.Column.fromType(r.COLUMN_TYPE.INT,"End",0),r.Column.fromType(r.COLUMN_TYPE.STRING,"Monomers",0)]);this.setDataFrame(e)}async render(e,t){let n;const o=r.DataFrame.fromColumns([n=r.Column.fromType(r.COLUMN_TYPE.STRING,"Remove",0),r.Column.fromType(r.COLUMN_TYPE.INT,"Start",0),r.Column.fromType(r.COLUMN_TYPE.INT,"End",0),r.Column.fromType(r.COLUMN_TYPE.STRING,"Monomers",0)]);n.setTag(r.TAGS.FRIENDLY_NAME,""),this.grid=await o.plot.fromType(r.VIEWER.GRID,t),this.grid.sort(["Start","End"]),this.grid.columns.byIndex(1).width=this.grid.props.rowHeight+2,this.grid.onCellRender.subscribe((e=>{const t=e.cell;t.tableColumn?.name==n.name&&(t?.tableRowIndex??-1)>=0&&(t.element=P.div(P.icons.delete((()=>{this.grid.dataFrame.rows.removeAt(t.tableRowIndex)}),"Delete"),{style:{height:`${t.grid.props.rowHeight}px`,color:"var(--grey-6)",display:"flex",flexDirection:"row",justifyContent:"center"}}))}));const i=this.grid.columns.byName("Monomers");i&&(i.editable=!1),this.subs.push(this.grid.onCellDoubleClick.subscribe((e=>{"Monomers"===e.tableColumn?.name&&null!=e.tableRowIndex&&e.tableRowIndex>=0&&this.handleMonomerCellDoubleClick(e.tableRowIndex)}))),this.updateGridHeight(e??this.grid.dataFrame.rowCount+.7),this.subs.push(P.onSizeChanged(this.grid.root).subscribe(this.gridRootOnSizeChanged.bind(this))),this.subs.push((0,te.fromEvent)(this.grid.root,"keydown").subscribe((e=>{"Enter"===e.key&&e.stopPropagation()}))),this.setDataFrame(o),this.grid.root.style.width="100%",this.gridHost.append(this.grid.root)}setDataFrame(e){for(const e of this.dataFrameSubs)e.unsubscribe();this.grid.dataFrame=e,this.dataFrameSubs.push(this.grid.dataFrame.onRowsRemoved.subscribe((()=>{this.updateGridHeight(this.grid.dataFrame.rowCount+.7),this.fireChanged()}))),this.dataFrameSubs.push(this.grid.dataFrame.onRowsAdded.subscribe((()=>{this.updateGridHeight(this.grid.dataFrame.rowCount+.7)}))),this.dataFrameSubs.push(this.grid.dataFrame.onDataChanged.subscribe((()=>{this.fireChanged()}))),this.updateGridHeight(this.grid.dataFrame.rowCount+.7),this.fireChanged()}static async create(e,t,n){return new Lo(e,n,t)}updateGridHeight(e){const t=this.grid.colHeaderHeight+e*this.grid.props.rowHeight+6+2;this.grid.root.style.height=`${t}px`}async handleMonomerCellDoubleClick(e){if(!this.onMonomerCellEdit)return;const t=this.grid.dataFrame,n=parseInt(t.get("Start",e))-1,o=parseInt(t.get("End",e))-1;if(isNaN(n)||isNaN(o))return;const r=Mo(t.get("Monomers",e)??""),i=await this.onMonomerCellEdit(n,o,r);null!==i&&t.set("Monomers",e,i.join(", "))}gridRootOnSizeChanged(){this.grid.columns.byIndex(4).width=this.grid.root.clientWidth-this.grid.horzScroll.root.offsetWidth-this.grid.columns.byIndex(0).width-this.grid.columns.byIndex(1).width-this.grid.columns.byIndex(2).width-this.grid.columns.byIndex(3).width-10}}var Oo=n(6307),Ro=n(2738);n(9982),DG.DataFrame.fromCsv('countries,fasta,smiles,molregno,LON,Zip Code,Street Address Line 1,ImageUrl,user_id,error_message,xray,flag,magnitude,CS-id,pdb_id,accel_a,time_offset,chart,fit,Questions,empty_number,empty_string\nBelgium,MSNFHNEHVMQFYRNNLKTKGVFGRQ,CC(C(=O)OCCCc1cccnc1)c2cccc(c2)C(=O)c3ccccc3,1480014,36.276729583740234,995042300,14016 ROUTE 31W,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,1,1,1QBS,1,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[2.497360340644872, 1.7058694986686864, 5.278052678195135, 0.16000320889028383],""points"":[{""x"":0.10000000149011612,""y"":2.374499797821045},{""x"":0.6000000238418579,""y"":2.6242473125457764},{""x"":1.100000023841858,""y"":2.367267608642578},{""x"":1.600000023841858,""y"":2.6723148822784424},{""x"":2.0999999046325684,""y"":2.6537344455718994},{""x"":2.5999999046325684,""y"":2.3651671409606934},{""x"":3.0999999046325684,""y"":2.5654284954071045},{""x"":3.5999999046325684,""y"":2.4160959720611572},{""x"":4.099999904632568,""y"":2.286726713180542},{""x"":4.599999904632568,""y"":2.5100042819976807},{""x"":5.099999904632568,""y"":1.6676985025405884},{""x"":5.599999904632568,""y"":0.680136501789093},{""x"":6.099999904632568,""y"":0.3391543924808502},{""x"":6.599999904632568,""y"":0.09038983285427094},{""x"":7.099999904632568,""y"":0.19802775979042053}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[7.525235855508179, 1.3186911876809984, 5.335672608564294, 0.7860743343958098],""points"":[{""x"":0.10000000149011612,""y"":7.988070487976074},{""x"":0.6000000238418579,""y"":7.018453121185303},{""x"":1.100000023841858,""y"":8.115279197692871},{""x"":1.600000023841858,""y"":7.486658096313477},{""x"":2.0999999046325684,""y"":7.396438121795654},{""x"":2.5999999046325684,""y"":7.477052211761475},{""x"":3.0999999046325684,""y"":6.913095474243164},{""x"":3.5999999046325684,""y"":8.01385498046875},{""x"":4.099999904632568,""y"":6.985900402069092},{""x"":4.599999904632568,""y"":6.970335960388184},{""x"":5.099999904632568,""y"":5.448817253112793},{""x"":5.599999904632568,""y"":2.5534818172454834},{""x"":6.099999904632568,""y"":1.893947958946228},{""x"":6.599999904632568,""y"":0.6340042352676392},{""x"":7.099999904632568,""y"":0.8403874039649963}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,100,abc\nBurundi,MDYKETLLMPKTDFPMRGGLPNKEPQIQEKW,COc1ccc2cc(ccc2c1)C(C)C(=O)Oc3ccc(C)cc3OC,1480015,36.276729583740234,995073444,80 STATE HIGHWAY 310,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,2,2,1ZP8,2,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[4.431460753103398, 2.1691498799246745, 5.266445597102774, 0.7825762827017926],""points"":[{""x"":0.10000000149011612,""y"":4.751083850860596},{""x"":0.6000000238418579,""y"":4.203000068664551},{""x"":1.100000023841858,""y"":4.415858745574951},{""x"":1.600000023841858,""y"":4.68414306640625},{""x"":2.0999999046325684,""y"":4.198400974273682},{""x"":2.5999999046325684,""y"":4.179222106933594},{""x"":3.0999999046325684,""y"":4.638473987579346},{""x"":3.5999999046325684,""y"":4.708553314208984},{""x"":4.099999904632568,""y"":4.291589260101318},{""x"":4.599999904632568,""y"":4.038082599639893},{""x"":5.099999904632568,""y"":3.4349939823150635},{""x"":5.599999904632568,""y"":1.2194708585739136},{""x"":6.099999904632568,""y"":1.1920831203460693},{""x"":6.599999904632568,""y"":0.5352635979652405},{""x"":7.099999904632568,""y"":0.3346920311450958}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[2.339458017970126, -1.0734184310171178, 4.746332950550934, 0.2482416857595658],""points"":[{""x"":0.10000000149011612,""y"":0.2139337658882141},{""x"":0.6000000238418579,""y"":0.4269562065601349},{""x"":1.100000023841858,""y"":0.2441573292016983},{""x"":1.600000023841858,""y"":0.146635964512825},{""x"":2.0999999046325684,""y"":0.08818462491035461},{""x"":2.5999999046325684,""y"":0.2560656666755676},{""x"":3.0999999046325684,""y"":0.42434045672416687},{""x"":3.5999999046325684,""y"":0.37111231684684753},{""x"":4.099999904632568,""y"":0.5581737160682678},{""x"":4.599999904632568,""y"":1.183590054512024},{""x"":5.099999904632568,""y"":1.5629843473434448},{""x"":5.599999904632568,""y"":2.3211288452148438},{""x"":6.099999904632568,""y"":2.229961633682251},{""x"":6.599999904632568,""y"":2.2560226917266846},{""x"":7.099999904632568,""y"":2.2142398357391357}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCameroon,MIEVFLFGIVLGLIPITLAGLFVTAYLQYRRGDQLDL,COc1ccc2cc(ccc2c1)C(C)C(=O)OCCCc3cccnc3,1480016,36.26095962524414,995153596,30-56 WHITESTONE EXPY,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,3,3,2BDJ,3,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[4.6760652578642325, 0.9046956320756703, 5.651408971856738, 0.07738846012184185],""points"":[{""x"":0.10000000149011612,""y"":4.32425594329834},{""x"":0.6000000238418579,""y"":4.668442249298096},{""x"":1.100000023841858,""y"":4.379785060882568},{""x"":1.600000023841858,""y"":5.0345139503479},{""x"":2.0999999046325684,""y"":4.878653526306152},{""x"":2.5999999046325684,""y"":4.3451313972473145},{""x"":3.0999999046325684,""y"":4.336992263793945},{""x"":3.5999999046325684,""y"":5.037430286407471},{""x"":4.099999904632568,""y"":5.0092692375183105},{""x"":4.599999904632568,""y"":4.151902675628662},{""x"":5.099999904632568,""y"":3.4066951274871826},{""x"":5.599999904632568,""y"":2.3732759952545166},{""x"":6.099999904632568,""y"":1.673728108406067},{""x"":6.599999904632568,""y"":0.48574790358543396},{""x"":7.099999904632568,""y"":0.2783052325248718}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[2.938395863010111, -1.4658480661392117, 5.462702751996584, 0.3473139023615039],""points"":[{""x"":0.10000000149011612,""y"":0.4941710829734802},{""x"":0.6000000238418579,""y"":0.15323974192142487},{""x"":1.100000023841858,""y"":0.46373432874679565},{""x"":1.600000023841858,""y"":0.3370431363582611},{""x"":2.0999999046325684,""y"":0.5179030299186707},{""x"":2.5999999046325684,""y"":0.27899765968322754},{""x"":3.0999999046325684,""y"":0.22075064480304718},{""x"":3.5999999046325684,""y"":0.5789918899536133},{""x"":4.099999904632568,""y"":0.21169911324977875},{""x"":4.599999904632568,""y"":0.27857646346092224},{""x"":5.099999904632568,""y"":1.0906332731246948},{""x"":5.599999904632568,""y"":1.8520300388336182},{""x"":6.099999904632568,""y"":2.7177059650421143},{""x"":6.599999904632568,""y"":2.8680918216705322},{""x"":7.099999904632568,""y"":3.2413077354431152}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCanada,MMELVLKTIIGPIVVGVVLRIVDKWLNKDK,CC(C(=O)NCCS)c1cccc(c1)C(=O)c2ccccc2,1480017,36.26095962524414,99515,30-56 WHITESTONE EXPY,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,4,4,1IAN,4,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[0.8597390975430008, 1.0957625732481946, 5.260537067987958, 0.07974187998177736],""points"":[{""x"":0.10000000149011612,""y"":0.8190152645111084},{""x"":0.6000000238418579,""y"":0.8421689867973328},{""x"":1.100000023841858,""y"":0.8740922212600708},{""x"":1.600000023841858,""y"":0.8924275040626526},{""x"":2.0999999046325684,""y"":0.8249067664146423},{""x"":2.5999999046325684,""y"":0.9327669143676758},{""x"":3.0999999046325684,""y"":0.8522974252700806},{""x"":3.5999999046325684,""y"":0.8174492716789246},{""x"":4.099999904632568,""y"":0.8394647240638733},{""x"":4.599999904632568,""y"":0.7139387726783752},{""x"":5.099999904632568,""y"":0.5561167597770691},{""x"":5.599999904632568,""y"":0.3276226818561554},{""x"":6.099999904632568,""y"":0.12479474395513535},{""x"":6.599999904632568,""y"":0.13006797432899475},{""x"":7.099999904632568,""y"":0.059702079743146896}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.760930219582546, 1.6591793293833013, 4.667155929720851, 0.7858109544121652],""points"":[{""x"":0.10000000149011612,""y"":6.156993389129639},{""x"":0.6000000238418579,""y"":5.236701965332031},{""x"":1.100000023841858,""y"":6.010560512542725},{""x"":1.600000023841858,""y"":5.495512962341309},{""x"":2.0999999046325684,""y"":6.087770462036133},{""x"":2.5999999046325684,""y"":5.79986572265625},{""x"":3.0999999046325684,""y"":5.597546577453613},{""x"":3.5999999046325684,""y"":5.520902156829834},{""x"":4.099999904632568,""y"":5.360654354095459},{""x"":4.599999904632568,""y"":3.5539746284484863},{""x"":5.099999904632568,""y"":1.577236294746399},{""x"":5.599999904632568,""y"":1.0001264810562134},{""x"":6.099999904632568,""y"":0.9305797815322876},{""x"":6.599999904632568,""y"":0.6033638715744019},{""x"":7.099999904632568,""y"":0.4203685522079468}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nColombia,MDRTDEVSNHTHDKPTLTWFEEIFEEYHSPFHN,FC(F)(F)c1ccc(OC2CCNCC2)cc1,1480029,36.3309440612793,995152050,1 COURT HOUSE SQUARE,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,5,5,4UJ1,5,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[6.4995088314153655, 2.4270351004539914, 5.178659535348579, 0.625653346241577],""points"":[{""x"":0.10000000149011612,""y"":6.496231555938721},{""x"":0.6000000238418579,""y"":6.42543363571167},{""x"":1.100000023841858,""y"":7.040063858032227},{""x"":1.600000023841858,""y"":6.1115403175354},{""x"":2.0999999046325684,""y"":6.680728435516357},{""x"":2.5999999046325684,""y"":6.406774520874023},{""x"":3.0999999046325684,""y"":6.611269474029541},{""x"":3.5999999046325684,""y"":5.889094352722168},{""x"":4.099999904632568,""y"":6.75344705581665},{""x"":4.599999904632568,""y"":6.361435890197754},{""x"":5.099999904632568,""y"":4.1666975021362305},{""x"":5.599999904632568,""y"":1.172118902206421},{""x"":6.099999904632568,""y"":0.801048994064331},{""x"":6.599999904632568,""y"":0.4640021026134491},{""x"":7.099999904632568,""y"":0.0010357667924836278}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[1.4734381347446401, 1.1649805188074196, 4.82958608866421, 0.09500545496710007],""points"":[{""x"":0.10000000149011612,""y"":1.5279096364974976},{""x"":0.6000000238418579,""y"":1.3559974431991577},{""x"":1.100000023841858,""y"":1.5246378183364868},{""x"":1.600000023841858,""y"":1.5567657947540283},{""x"":2.0999999046325684,""y"":1.4114240407943726},{""x"":2.5999999046325684,""y"":1.4045010805130005},{""x"":3.0999999046325684,""y"":1.4769829511642456},{""x"":3.5999999046325684,""y"":1.4875500202178955},{""x"":4.099999904632568,""y"":1.2991987466812134},{""x"":4.599999904632568,""y"":0.922961413860321},{""x"":5.099999904632568,""y"":0.6520044803619385},{""x"":5.599999904632568,""y"":0.15350978076457977},{""x"":6.099999904632568,""y"":0.1078903079032898},{""x"":6.599999904632568,""y"":0.17276449501514435},{""x"":7.099999904632568,""y"":0.14066608250141144}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCosta Rica,MKSTKEEIQTIKTLLKDSRTAKYHKRLQIVL,CC(C)Cc1ccc(cc1)C(C)C(=O)N2CCCC2C(=O)OCCCc3ccccc3,1480018,36.3309440612793,995084218,4041 SOUTHWESTERN BLVD,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,6,6,2BPW,6,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[2.4833641843311227, -1.8945978742090062, 4.671127708092568, 0.24159861311815153],""points"":[{""x"":0.10000000149011612,""y"":0.0969524160027504},{""x"":0.6000000238418579,""y"":0.028483040630817413},{""x"":1.100000023841858,""y"":0.22087176144123077},{""x"":1.600000023841858,""y"":0.0068915546871721745},{""x"":2.0999999046325684,""y"":0.4305879771709442},{""x"":2.5999999046325684,""y"":0.44774115085601807},{""x"":3.0999999046325684,""y"":0.45346319675445557},{""x"":3.5999999046325684,""y"":0.2370593100786209},{""x"":4.099999904632568,""y"":0.4657953977584839},{""x"":4.599999904632568,""y"":1.155200719833374},{""x"":5.099999904632568,""y"":2.2294070720672607},{""x"":5.599999904632568,""y"":2.4311530590057373},{""x"":6.099999904632568,""y"":2.33846116065979},{""x"":6.599999904632568,""y"":2.608201026916504},{""x"":7.099999904632568,""y"":2.8136143684387207}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.224573521642033, 1.4454033924198528, 5.6014197746076535, 0.2823216054197577],""points"":[{""x"":0.10000000149011612,""y"":4.95027494430542},{""x"":0.6000000238418579,""y"":5.1754679679870605},{""x"":1.100000023841858,""y"":5.276752948760986},{""x"":1.600000023841858,""y"":5.589294910430908},{""x"":2.0999999046325684,""y"":5.616994857788086},{""x"":2.5999999046325684,""y"":5.120813846588135},{""x"":3.0999999046325684,""y"":5.340766906738281},{""x"":3.5999999046325684,""y"":4.876471042633057},{""x"":4.099999904632568,""y"":4.94999361038208},{""x"":4.599999904632568,""y"":5.162564754486084},{""x"":5.099999904632568,""y"":4.399557590484619},{""x"":5.599999904632568,""y"":2.7977969646453857},{""x"":6.099999904632568,""y"":1.0229872465133667},{""x"":6.599999904632568,""y"":0.48275601863861084},{""x"":7.099999904632568,""y"":0.10408931970596313}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCuba,MHAILRYFIRRLFYHIFYKIYSLISKKHQSLPSDVRQF,COc1ccc2c(c1)c(CC(=O)N3CCCC3C(=O)Oc4ccc(C)cc4OC)c(C)n2C(=O)c5ccc(Cl)cc5,1480019,36.33115768432617,995081928,1227 US HIGHWAY 11,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,7,7,1QBS,7,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[3.320838679713925, -1.2421619987316728, 4.831325425225256, 0.3236011098403072],""points"":[{""x"":0.10000000149011612,""y"":0.3727470338344574},{""x"":0.6000000238418579,""y"":0.12365014106035233},{""x"":1.100000023841858,""y"":0.48422467708587646},{""x"":1.600000023841858,""y"":0.2264465093612671},{""x"":2.0999999046325684,""y"":0.16821794211864471},{""x"":2.5999999046325684,""y"":0.3879014551639557},{""x"":3.0999999046325684,""y"":0.5470244884490967},{""x"":3.5999999046325684,""y"":0.3419053554534912},{""x"":4.099999904632568,""y"":0.7655120491981506},{""x"":4.599999904632568,""y"":1.2346516847610474},{""x"":5.099999904632568,""y"":2.453336715698242},{""x"":5.599999904632568,""y"":2.9565491676330566},{""x"":6.099999904632568,""y"":3.335299491882324},{""x"":6.599999904632568,""y"":3.240290880203247},{""x"":7.099999904632568,""y"":3.1107218265533447}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[3.6401853521511094, 1.26211588875013, 5.399028074402744, 0.5089580830068091],""points"":[{""x"":0.10000000149011612,""y"":3.8585598468780518},{""x"":0.6000000238418579,""y"":3.6077206134796143},{""x"":1.100000023841858,""y"":3.855252265930176},{""x"":1.600000023841858,""y"":3.619039297103882},{""x"":2.0999999046325684,""y"":3.839388370513916},{""x"":2.5999999046325684,""y"":3.335283041000366},{""x"":3.0999999046325684,""y"":3.571141481399536},{""x"":3.5999999046325684,""y"":3.4155046939849854},{""x"":4.099999904632568,""y"":3.7316646575927734},{""x"":4.599999904632568,""y"":3.0680155754089355},{""x"":5.099999904632568,""y"":2.891066551208496},{""x"":5.599999904632568,""y"":1.6022753715515137},{""x"":6.099999904632568,""y"":0.7652576565742493},{""x"":6.599999904632568,""y"":0.6875326037406921},{""x"":7.099999904632568,""y"":0.5828871726989746}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nItaly,MSNFHNEHVMQFYRNNLKTKGVFGRQ,CC(C)Cc1ccc(cc1)C(C)C(=O)N2CCCC2C(=O)OCCO[N+](=O)[O-],1480020,36.33115768432617,99502,"168-46 91ST AVE., 2ND FLR",https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,8,8,1ZP8,8,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[2.293592105923809, 1.3781586549141835, 5.1025898038676605, 0.03493851245291291],""points"":[{""x"":0.10000000149011612,""y"":2.1287283897399902},{""x"":0.6000000238418579,""y"":2.267972230911255},{""x"":1.100000023841858,""y"":2.398442506790161},{""x"":1.600000023841858,""y"":2.5130622386932373},{""x"":2.0999999046325684,""y"":2.3255116939544678},{""x"":2.5999999046325684,""y"":2.127340793609619},{""x"":3.0999999046325684,""y"":2.47259783744812},{""x"":3.5999999046325684,""y"":2.131181478500366},{""x"":4.099999904632568,""y"":2.090421438217163},{""x"":4.599999904632568,""y"":2.02299165725708},{""x"":5.099999904632568,""y"":1.1105059385299683},{""x"":5.599999904632568,""y"":0.4494485855102539},{""x"":6.099999904632568,""y"":0.1375635862350464},{""x"":6.599999904632568,""y"":0.036351121962070465},{""x"":7.099999904632568,""y"":0.1619771122932434}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.953125499439879, 1.2528620255306528, 5.187637440149802, 0.3110348753260886],""points"":[{""x"":0.10000000149011612,""y"":5.6585283279418945},{""x"":0.6000000238418579,""y"":5.911152362823486},{""x"":1.100000023841858,""y"":5.924920082092285},{""x"":1.600000023841858,""y"":5.8469438552856445},{""x"":2.0999999046325684,""y"":5.929472923278809},{""x"":2.5999999046325684,""y"":6.190037727355957},{""x"":3.0999999046325684,""y"":6.236179828643799},{""x"":3.5999999046325684,""y"":6.141019344329834},{""x"":4.099999904632568,""y"":5.295210838317871},{""x"":4.599999904632568,""y"":5.265801906585693},{""x"":5.099999904632568,""y"":3.3722851276397705},{""x"":5.599999904632568,""y"":1.8299226760864258},{""x"":6.099999904632568,""y"":0.32690900564193726},{""x"":6.599999904632568,""y"":0.6274543404579163},{""x"":7.099999904632568,""y"":0.8441857099533081}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nRwanda,MPNSEPASLLELFNSIATQGELVRSLKAGNASK,CC(C)Cc1ccc(cc1)C(C)C(=O)N2CCCC2C(=O)OCCO,1480021,36.33137130737305,995037247,"168-46 91ST AVE., 2ND FLR",https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,9,9,2BDJ,9,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[3.8209972202654474, 1.3779216716448506, 5.299882228439686, 0.06040645519069608],""points"":[{""x"":0.10000000149011612,""y"":3.7821109294891357},{""x"":0.6000000238418579,""y"":3.542433023452759},{""x"":1.100000023841858,""y"":3.7008674144744873},{""x"":1.600000023841858,""y"":3.717301607131958},{""x"":2.0999999046325684,""y"":4.024452209472656},{""x"":2.5999999046325684,""y"":4.013899326324463},{""x"":3.0999999046325684,""y"":3.945094347000122},{""x"":3.5999999046325684,""y"":3.866621971130371},{""x"":4.099999904632568,""y"":3.7461626529693604},{""x"":4.599999904632568,""y"":3.3454740047454834},{""x"":5.099999904632568,""y"":2.61944317817688},{""x"":5.599999904632568,""y"":0.999405026435852},{""x"":6.099999904632568,""y"":0.46259793639183044},{""x"":6.599999904632568,""y"":0.054134611040353775},{""x"":7.099999904632568,""y"":0.05711187422275543}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.6318079657726035, 1.8495493770000595, 5.391793312471116, 0.17060707587348442],""points"":[{""x"":0.10000000149011612,""y"":5.458079814910889},{""x"":0.6000000238418579,""y"":5.554427146911621},{""x"":1.100000023841858,""y"":5.799983024597168},{""x"":1.600000023841858,""y"":5.364140033721924},{""x"":2.0999999046325684,""y"":5.864485740661621},{""x"":2.5999999046325684,""y"":5.4509806632995605},{""x"":3.0999999046325684,""y"":5.702574729919434},{""x"":3.5999999046325684,""y"":5.7314534187316895},{""x"":4.099999904632568,""y"":5.5123443603515625},{""x"":4.599999904632568,""y"":5.724395751953125},{""x"":5.099999904632568,""y"":4.354506969451904},{""x"":5.599999904632568,""y"":1.7307666540145874},{""x"":6.099999904632568,""y"":0.6305936574935913},{""x"":6.599999904632568,""y"":0.035183437168598175},{""x"":7.099999904632568,""y"":0.7575169205665588}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nSwitzerland,IRVVGRYLIEVWKAAGMDMDKVLFLWSSDEI,CN1CCC(CC1)Oc2ccc(cc2)C(F)(F)F,1480028,36.33137130737305,99504,92-11 179TH PLACE,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,9,10,1IAN,10,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[1.1190255865097471, 2.3163895161544437, 5.4968866182279195, 0.2035204047289052],""points"":[{""x"":0.10000000149011612,""y"":1.1057683229446411},{""x"":0.6000000238418579,""y"":1.1019697189331055},{""x"":1.100000023841858,""y"":1.0818607807159424},{""x"":1.600000023841858,""y"":1.062997817993164},{""x"":2.0999999046325684,""y"":1.046447515487671},{""x"":2.5999999046325684,""y"":1.1217249631881714},{""x"":3.0999999046325684,""y"":1.2166996002197266},{""x"":3.5999999046325684,""y"":1.215477705001831},{""x"":4.099999904632568,""y"":1.0581893920898438},{""x"":4.599999904632568,""y"":1.1747995615005493},{""x"":5.099999904632568,""y"":1.0181127786636353},{""x"":5.599999904632568,""y"":0.5344523191452026},{""x"":6.099999904632568,""y"":0.2569526433944702},{""x"":6.599999904632568,""y"":0.1912207305431366},{""x"":7.099999904632568,""y"":0.15060538053512573}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[3.1038581025805785, 2.0032224204185245, 5.087602825989163, 0.13277988512492753],""points"":[{""x"":0.10000000149011612,""y"":3.0498509407043457},{""x"":0.6000000238418579,""y"":2.805217742919922},{""x"":1.100000023841858,""y"":3.3415253162384033},{""x"":1.600000023841858,""y"":3.0549843311309814},{""x"":2.0999999046325684,""y"":3.250074863433838},{""x"":2.5999999046325684,""y"":3.0432586669921875},{""x"":3.0999999046325684,""y"":3.265852451324463},{""x"":3.5999999046325684,""y"":2.9475724697113037},{""x"":4.099999904632568,""y"":3.1929898262023926},{""x"":4.599999904632568,""y"":2.7460060119628906},{""x"":5.099999904632568,""y"":1.6175861358642578},{""x"":5.599999904632568,""y"":0.3006608486175537},{""x"":6.099999904632568,""y"":0.3444803059101105},{""x"":6.599999904632568,""y"":0.015537971630692482},{""x"":7.099999904632568,""y"":0.5527358055114746}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\n,,,,,,,,,,,,,,,,,,,,,').columns.add(DG.Column.fromList(DG.TYPE.BYTE_ARRAY,"BinaryImage",Array.from(new Uint8Array(11))));var $o;console.log.bind(console),console.info.bind(console),console.warn.bind(console),console.error.bind(console),function(e){e.notNull=function(e,t){if(null==e)throw new Error(`${null==t?"Value":t} not defined`)}}($o||($o={})),DG.DataFrame.fromColumns([DG.Column.fromStrings("col",["val1","val2","val3"])]);class Do{onKeyDown(e,t){}onKeyPress(e,t){}onMouseEnter(e,t){}onMouseLeave(e,t){}onMouseDown(e,t){}onMouseUp(e,t){}onMouseMove(e,t){}onClick(e,t){}onDoubleClick(e,t){}}class Bo extends Do{constructor(e,t,n){super(),this.gridCol=e,this.tableCol=t,this.logger=n,this.subs=[],this.dirty=!0,this.destroyed=!1,this.viewerId=++Bo.viewerCounter,this.errors=[],this._onRendered=new te.Subject,this.tableCol&&this.tableCol.dataFrame&&(this.subs.push(this.tableCol.dataFrame.onDataChanged.subscribe((()=>{this.dirty=!0}))),this.subs.push(this.tableCol.dataFrame.onColumnsRemoved.subscribe((e=>{try{this.destroyed||!this.tableCol||this.tableCol.dataFrame||this.destroy()}catch(e){this.logger.error(e)}})))),this.tableCol&&this.subs.push(o.events.onTableRemoved.subscribe((e=>{try{const t=e.args.dataFrame;this.tableCol?.dataFrame.id!==t.id||this.destroyed||this.destroy()}catch(e){this.logger.error(e)}}))),this.gridCol&&this.subs.push(o.events.onViewRemoving.subscribe((e=>{try{const t=e.args.view;this.gridCol?.dart&&this.gridCol.grid&&this.gridCol?.grid?.dart&&this.gridCol?.grid?.view?.id===t.id&&!this.destroyed&&this.destroy()}catch(e){this.logger.error(e)}})))}toLog(){return`${this.constructor.name}<${this.viewerId}>`}destroy(){for(const e of this.subs)e.unsubscribe();this.destroyed=!0}invalidateGrid(){this.gridCol&&this.gridCol.dart&&this.gridCol.grid?.invalidate()}reset(){this.dirty=!1}get onRendered(){return this._onRendered}invalidate(e){this.invalidateGrid()}async awaitRendered(e=1e4,t=`${e} timeout`){const n=`${this.toLog()}.awaitRendered()`;if(this.logger.debug(`${n}, start, testEvent before`),await function(e,t,n,o=0,r="timeout"){return function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function s(e){try{l(o.next(e))}catch(e){i(e)}}function a(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}l((o=o.apply(e,t||[])).next())}))}(this,void 0,void 0,(function*(){return new Promise(((i,s)=>{const a=e.subscribe((e=>{try{t(e),i("OK")}catch(e){s(e)}finally{a.unsubscribe(),clearTimeout(l)}})),l=setTimeout((()=>{a.unsubscribe(),s(r)}),o);n()}))}))}(this._onRendered,(()=>{}),(()=>{this.invalidate()}),e,`${n}, ${t}`),this.errors.length>0){const e=this.errors[0];throw this.errors=[],e}this.logger.debug(`${n}, end`)}}Bo.viewerCounter=-1;const Fo="rgb(100,100,100)",ko="rgb(0,0,0)",Ho=s.zS;var Go,Uo,Vo;!function(e){e.maxMonomerLength=".mm.cellRenderer.maxMonomerLength"}(Go||(Go={})),function(e){e.applyToBackground=".m.cellRenderer.applyToBackground"}(Uo||(Uo={})),function(e){e.MSA="MSA",e.classic="classic"}(Vo||(Vo={}));const jo=new class{constructor(){this.color=Fo,this.pivot=0,this.left=!1,this.transparencyRate=0,this.separator="",this.last=!1,this.drawStyle=Vo.classic,this.maxWord=[],this.wordIdx=0,this.gridCell=null,this.referenceSequence=null,this.maxLengthOfMonomer=null,this.monomerTextSizeMap={},this.logger=void 0,this.selectedPosition=void 0,this.isMultiLineContext=!1,this.lineNumber=0}};function qo(e,t,n,o,i,s,a){var l,c,u;const h={...jo,...a};if(h.isMultiLineContext){e.textBaseline="middle",e.textAlign="center";let r=t;null!=h.maxLengthOfMonomer&&(r=Ho(r,h.maxLengthOfMonomer));const a=Math.max(.1,1-(h.transparencyRate??0));e.globalAlpha=a;const l=e.measureText(r),c=l.fontBoundingBoxAscent+l.fontBoundingBoxDescent,u=o+(s-c)/2+l.fontBoundingBoxAscent;let d=h.color??Fo;return d&&d!==Fo||(d=ko),e.fillStyle=d,h.selectedPosition===h.wordIdx+1&&(e.save(),e.fillStyle="rgba(60, 177, 115, 0.2)",e.fillRect(n,o,i,s),e.restore(),e.fillStyle=d),e.fillText(r,n+i/2,u),e.globalAlpha=1,e.textBaseline="top",e.textAlign="start",n+i}a.logger?.debug("Bio: printLeftOrCentered(), start"),e.textAlign="start";let d=t.substring(0),p=h.last?"":h.separator;h.drawStyle===Vo.MSA&&(p="");let m=!0,f=!0,g="difference";if(null!=h.gridCell&&null!=h.gridCell.cell.column&&(m=h.gridCell.cell.column.temp["color-code"]??!0,f=h.gridCell.cell.column.temp["compare-with-current"]??!0,g=h.gridCell.cell.column.temp["highlight-difference"]??"difference"),h.referenceSequence){const e=h.referenceSequence[h.wordIdx];f&&h.referenceSequence.length>0&&"difference"===g&&(h.transparencyRate=d==e?.7:h.transparencyRate),f&&h.referenceSequence.length>0&&"equal"===g&&(h.transparencyRate=d!=e?.7:h.transparencyRate)}null!=h.maxLengthOfMonomer&&(d=Ho(d,h.maxLengthOfMonomer));const y=d+p;(l=h.monomerTextSizeMap)[y]??(l[y]=e.measureText(y));let b=h.monomerTextSizeMap[y];(c=h.monomerTextSizeMap)[d]??(c[d]=e.measureText(d));let v=h.monomerTextSizeMap[d].width;const C=s/2-(b.fontBoundingBoxAscent+b.fontBoundingBoxDescent)/2+1;(u=h.monomerTextSizeMap)[p]??(u[p]=e.measureText(p));const x=h.monomerTextSizeMap[p].width;function w(t,i){let a=m?h.color:ko;h.selectedPosition===h.wordIdx+1&&(e.fillStyle="rgba(60, 177, 115, 0.2)",e.fillRect(n+t-4,o-5,h.monomerTextSizeMap[d].width+8,s+10),a=r.Color.toHtml(r.Color.setAlpha(r.Color.fromHtml(a),255))),e.fillStyle=a,e.globalAlpha=1-h.transparencyRate,h.drawStyle===Vo.classic&&(e.fillText(d,n+t,o+C),e.fillStyle="#808080",e.fillText(p,n+i,o+C)),h.drawStyle===Vo.MSA&&e.fillText(d,n+t,o+C),e.globalAlpha=1}b=b.width,h.drawStyle===Vo.MSA&&(v=h.maxWord[h.wordIdx],b=h.maxWord[h.wordIdx]);const A=(h.maxWord[h.wordIdx]??0)-(h.maxWord[0]??0);if(h.left||b>i)return w(A,A+v),n+A+v+x;{const e=(i-b)/2;return w(e,e+v),n+A+e+v}}var Wo,zo,Yo;!function(e){e.Region="region",e.Point="point",e.Motif="motif"}(Wo||(Wo={})),function(e){e.Structure="structure",e.Liability="liability",e.PTM="ptm",e.Custom="custom"}(zo||(zo={})),function(e){e.High="high",e.Medium="medium",e.Low="low",e.Info="info"}(Yo||(Yo={}));const Ko={structure:{FR:["#0095ff","#289dfd","#48adff","#3ba5fc"],CDR:["#ffdca3","#facb83","#f7a224"]},liability:{deamidation:"#E53935",isomerization:"#FF9800",oxidation:"#9C27B0",glycosylation:"#4CAF50",freeCysteine:"#607D8B"}};class Qo{constructor(e){this.tableCol=e,this._cache=null,this._rowCache=null,this._annotCol=null,this._annotColLookupVersion=-1}hasAnnotations(){return this._ensureCache(),null!==this._cache&&this._cache.annotations.length>0}getAnnotations(){return this._ensureCache(),this._cache?.annotations??[]}getRegionNameAtPosition(e,t){if(null!=t){const n=this._findRowRegionHit(t,e);if(n){const e=this._cache?.annotations.find((e=>e.id===n.annotationId));return e?.name??null}if(this._rowHasRegionData(t))return null}return this._ensureCache(),this._cache?.positionRegionNames.get(e)??null}getHitsAtPosition(e,t){if(this._ensureRowCache(),!this._rowCache)return[];const n=this._rowCache.data[e];return n?n.filter((e=>null==e.endPositionIndex&&(e.positionIndex===t||e.matchedMonomers.length>1&&t>e.positionIndex&&t<e.positionIndex+e.matchedMonomers.length))):[]}drawPositionBackground(e,t,n,o,r,i,s,a){if(this._ensureCache(),!this._cache)return;let l;this._ensureRowCache();const c=this._findRowRegionHit(s,i);if(c){const e=this._cache.annotations.find((e=>e.id===c.annotationId));l=e?.color??(e?this._getDefaultRegionColor(e):void 0)}if(l||this._rowHasRegionData(s)||(l=this._cache.positionRegionColors.get(i)),l&&(e.save(),e.globalAlpha=.25,e.fillStyle=l,e.fillRect(t,n,o,r),e.restore()),this._rowCache){const l=this._rowCache.data[s];if(l)for(const s of l)if(null==s.endPositionIndex&&i>=s.positionIndex&&i<s.positionIndex+s.matchedMonomers.length){const i=this._cache.annotations.find((e=>e.id===s.annotationId));if(i?.color){const s=null!=a?a+1:n+r-3;e.fillStyle=i.color,e.fillRect(t,s,o,3)}break}}}getTooltipInfo(e,t){this._ensureCache();const n=[];if(!this._cache)return n;this._ensureRowCache();let o=null;const r=this._findRowRegionHit(t,e);if(r){const e=this._cache.annotations.find((e=>e.id===r.annotationId));if(e){o=e.name;const t=e.sourceScheme??"";n.push(`Region: ${e.name}${t?` (${t} ${e.start}-${e.end})`:""}`)}}if(!o&&!this._rowHasRegionData(t)){const t=this._cache.positionRegionNames.get(e);if(t){const e=this._cache.annotations.find((e=>e.name===t&&e.category===zo.Structure)),o=e?.sourceScheme??"";n.push(`Region: ${t}${o?` (${o} ${e?.start}-${e?.end})`:""}`)}}if(this._rowCache){const o=this._rowCache.data[t];if(o)for(const t of o)if(null==t.endPositionIndex&&e>=t.positionIndex&&e<t.positionIndex+t.matchedMonomers.length){const e=this._cache.annotations.find((e=>e.id===t.annotationId));if(e){const t=e.severity?` - ${e.severity.charAt(0).toUpperCase()+e.severity.slice(1)}`:"";n.push(`⚠ ${e.name}${t}`)}}}return n}_findRowRegionHit(e,t){if(this._ensureRowCache(),!this._rowCache)return null;const n=this._rowCache.data[e];if(!n)return null;for(const e of n)if(null!=e.endPositionIndex&&t>=e.positionIndex&&t<=e.endPositionIndex)return e;return null}_rowHasRegionData(e){if(this._ensureRowCache(),!this._rowCache)return!1;const t=this._rowCache.data[e];return!!t&&t.some((e=>null!=e.endPositionIndex))}_ensureCache(){const e=this.tableCol.version;if(this._cache&&this._cache.colVersion===e)return;const t=this.tableCol.getTag(i.gp.annotations);if(!t)return void(this._cache=null);let n;try{n=JSON.parse(t)}catch{return void(this._cache=null)}if(!n||0===n.length)return void(this._cache=null);const o=new Map,r=new Map,s=this._getPosList();for(const e of n){if(e.category!==zo.Structure)continue;if(null==e.start||null==e.end)continue;const t=s.indexOf(e.start),n=s.indexOf(e.end);if(t<0||n<0)continue;const i=e.color??this._getDefaultRegionColor(e);for(let s=t;s<=n;s++)o.set(s,i),r.set(s,e.name)}this._cache={colVersion:e,annotations:n,positionRegionColors:o,positionRegionNames:r}}_ensureRowCache(){const e=this.tableCol.version;if(this._annotColLookupVersion!==e){this._annotColLookupVersion=e;const t=this.tableCol.getTag(i.gp.annotationColumnName);if(t)try{this._annotCol=this.tableCol.dataFrame.columns.byName(t)}catch{this._annotCol=null}else this._annotCol=null}if(!this._annotCol)return void(this._rowCache=null);const t=this._annotCol.version;if(this._rowCache&&this._rowCache.colVersion===t)return;const n=new Array(this._annotCol.length);for(let e=0;e<this._annotCol.length;e++){const t=this._annotCol.get(e);if(t)try{n[e]=JSON.parse(t)}catch{n[e]=null}else n[e]=null}this._rowCache={colVersion:t,data:n}}_getPosList(){const e=this.tableCol.getTag(i.gp.positionNames);return e?e.split(", "):[]}_getDefaultRegionColor(e){if(e.name.startsWith("CDR")){const t=parseInt(e.name.replace("CDR",""))-1;return Ko.structure.CDR[t%Ko.structure.CDR.length]}if(e.name.startsWith("FR")){const t=parseInt(e.name.replace("FR",""))-1;return Ko.structure.FR[t%Ko.structure.FR.length]}return"#90CAF9"}}var Jo=n(3599);const Xo="bio.macromolecule.highlightMonomers",Zo=r.Color.argb(255,255,220,0);r.Color.argb(255,230,140,0);const er="rgb(100,100,100)";class tr extends Bo{get separatorWidth(){return this.props?.fontCharWidth?this.props?.fontCharWidth:5}getAnnotationRenderer(){return this._annotationRenderer||(this._annotationRenderer=new Qo(this.tableCol)),this._annotationRenderer.hasAnnotations()?this._annotationRenderer:null}constructor(e,t,n,o,i){if(super(e,t,n),this.monomerLengthLimit=o,this.propsProvider=i,this.colWidth=0,this._monomerLengthList=null,this._processedMaxVisibleSeqLength=0,this._monomerLengthMap={},this._monomerStructureMap={},this._ellipsisBounds=void 0,this._totalLinesNeeded=0,this._lineHeight=20,this._cellBounds=new Map,this.sysMonomerLib=null,this._annotationRenderer=null,this.padding=5,this._leftThreeDotsPadding=0,this.props=this.propsProvider(),this._processedRows=r.BitSet.create(this.tableCol.length),this.gridCol&&this.subs.push(this.gridCol.grid.onAfterDrawContent.subscribe((()=>{this._onRendered.next()}))),this.tableCol&&this.gridCol){this.subs.push(this.tableCol.dataFrame.onCurrentRowChanged.subscribe((()=>{-1===this.tableCol.dataFrame.currentRowIdx&&(this.tableCol.temp["reference-sequence"]=null,this.tableCol.temp["current-word"]=null,this.invalidateGrid())})));const e=[Ot.gp.positionShift,"renderMultiline"];this.subs.push(r.debounce(this.tableCol.dataFrame.onMetadataChanged.pipe(ne.filter((t=>t.args.source===this.tableCol&&e.includes(t.args.key)))),200).subscribe((e=>{this.reset()}))),this.subs.push(r.debounce(this.tableCol.dataFrame.onMetadataChanged.pipe(ne.filter((e=>e.args.source===this.tableCol&&e.args.key===Ot.gp.positionShift))),200).subscribe((e=>{this.reset()})))}}calculateFontBasedSpacing(e){const t=e.measureText("M");let n=12;if(this.tableCol?.temp[".mm.cellRenderer.fontSize"]){const e=this.tableCol.temp[".mm.cellRenderer.fontSize"];"number"!=typeof e||isNaN(e)||(n=Math.max(e,1))}return{lineHeight:Math.max(1.4*n,t.fontBoundingBoxAscent+t.fontBoundingBoxDescent+4),monomerSpacing:Math.max(2,.2*this.props.fontCharWidth)}}shouldUseMultilineRendering(e){return"true"===e.getTag("renderMultiline")}calculateMultiLineLayoutDynamic(e,t,n,o,r,i){if(this.dirty)try{this.reset()}catch(e){const[t,n]=(0,vn.AP)(e);this.logger.error(t,void 0,n)}const{lineHeight:s,monomerSpacing:a}=this.calculateFontBasedSpacing(e),l=t-2*this.padding;let c=0;const u=[];if(o.length>0)for(let t=r;t<o.length;t++){const n=o.getOriginal(t),r=this.props.monomerToShort(n,i);u.push({text:r,posIdx:t}),c=Math.max(c,e.measureText(r).width)}if(0===u.length)return{lineLayouts:[],lineHeight:s};const h=c;let d=Math.floor((l+a)/(h+a));d=Math.max(1,d);const p=n-2*this.padding,m=Math.max(0,Math.floor(p/s)),f=[];let g=0;for(let e=0;e<m&&g<u.length;e++){const t=[];for(let e=0;e<d&&g<u.length;e++){const n=u[g],o=this.padding+e*(h+a);t.push({posIdx:n.posIdx,x:o,width:h,om:n.text,isSeparator:!1}),g++}f.push({lineIdx:e,elements:t})}return{lineLayouts:f,lineHeight:s}}async init(){await Promise.all([(async()=>{this.seqHelper=await(0,Cn.Q)(),this.invalidateGrid()})(),(async()=>{const e=await(0,l.pj)();this.sysMonomerLib=e.getMonomerLib()})()]),this.subs.push(this.sysMonomerLib.onChanged.subscribe((()=>{this.reset()}))),this.subs.push(o.events.onCustomEvent("bio-macromolecule-monomer-highlight").subscribe((e=>this.handleHighlightEvent(e)))),this.reset()}handleHighlightEvent(e){var t;if(!e||!this.tableCol||!this.tableCol.dataFrame)return;if(e.columnName!==this.tableCol.name)return;const n=this.tableCol.dataFrame;if(e.tableId&&n.id!==e.tableId)return;if(e.tableName&&n.name!==e.tableName)return;const o=(t=this.tableCol.temp)[Xo]??(t[Xo]=new Map);null==e.monomers||0===e.monomers.length?o.delete(e.rowIdx):o.set(e.rowIdx,{monomers:e.monomers.slice(),fillColor:e.fillColor,strokeColor:e.strokeColor}),this.invalidateGrid()}getHighlightForRow(e){if(null==e)return null;const t=this.tableCol.temp[Xo];return t?.get(e)??null}drawHighlightBackground(e,t,n,o,i,s,a){const l=this.getHighlightForRow(t);if(!l||!l.monomers||0===l.monomers.length)return;if(!l.monomers.includes(n))return;const c=(u=l.fillColor??Zo,`rgba(${r.Color.r(u)},${r.Color.g(u)},${r.Color.b(u)},0.4)`);var u;e.save();try{e.fillStyle=c,e.fillRect(o,i,s,a)}finally{e.restore()}}static getFontSettings(e){let t=12;return e&&e.temp[".mm.cellRenderer.fontSize"]&&"number"==typeof e.temp[".mm.cellRenderer.fontSize"]&&!isNaN(e.temp[".mm.cellRenderer.fontSize"])&&(t=Math.max(e.temp[".mm.cellRenderer.fontSize"],1)),{font:`${t}px monospace`,fontWidth:.6*t}}toLog(){return`MonomerPlacer<${this.viewerId}>`}getMonomerLib(){return this.tableCol.temp[".mm.cellRenderer.overriddenLibrary"]??this.sysMonomerLib}reset(){this.propsProvider&&(this.props=this.propsProvider()),this._processedRows=r.BitSet.create(this.tableCol.length),this._monomerLengthList=null,this._monomerLengthMap={},this._monomerStructureMap={},this._cellBounds.clear(),super.reset(),this.invalidateGrid()}invalidateGrid(){this.gridCol&&this.gridCol.dart&&this.gridCol.grid?.invalidate()}getCellMonomerLengths(e,t){const n=this.seqHelper.getSeqHandler(this.tableCol);if(this.colWidth<t&&(this.colWidth=t,this.dirty=!0),this.dirty)try{this.reset()}catch(e){const[t,n]=(0,vn.AP)(e);this.logger.error(t,void 0,n)}const o=n.isMsa()?this.getCellMonomerLengthsForSeqMsa():this.getCellMonomerLengthsForSeq(e);return[o,this.getSummedMonomerLengths(o)]}getSummedMonomerLengths(e){const t=new Array(e.length+1);t[0]=this.padding;for(let n=1;n<t.length;n++)t[n]=t[n-1]+e[n-1];let n=t[0];for(let e=1;e<t.length;e++)t[e]?n=t[e]:t[e]=n;return t}getCellMonomerLengthsForSeqValue(e,t){const n=this.seqHelper.getSeqHandler(this.tableCol),o=this.props.separatorWidth+1*this.props.fontCharWidth,r=this.positionShift,i=Math.ceil(t/o)+r,s=n.splitter(e),a=Math.min(i,s.length),l=new Array(a-r);let c=0;for(let e=r;e<a;++e){const o=s.getOriginal(e),i=this.props.monomerToShort(o,this.monomerLengthLimit),a=(n.isSeparator()?this.separatorWidth:this.props.separatorWidth)+i.length*this.props.fontCharWidth;if(l[e-r]=a,c+=a,c>t)break}return l}getCellMonomerLengthsForSeq(e){this.toLog(),null==this._monomerLengthList&&(this._monomerLengthList=new Array(this.tableCol.length).fill(null));const t=this.positionShift,n=this.seqHelper.getSeqHandler(this.tableCol),o=this.props.separatorWidth+1*this.props.fontCharWidth,r=Math.ceil(this.colWidth/o)+t,i=n.getSplitted(e),s=Math.min(r,i.length);let a=this._monomerLengthList[e];if(null==a||a.length!=s-t){a=this._monomerLengthList[e]=new Array(i.length);let o=0;for(let e=t;e<s;++e){const r=i.getOriginal(e),s=this.props.monomerToShort(r,this.monomerLengthLimit),l=(n.isSeparator()?this.separatorWidth:this.props.separatorWidth)+s.length*this.props.fontCharWidth;if(a[e-t]=l,o+=l,o>this.colWidth)break}}return a}getCellMonomerLengthsForSeqMsa(){var e;this.toLog(),null==this._monomerLengthList&&(this._monomerLengthList=new Array(1).fill(null)),(e=this._monomerLengthList)[0]??(e[0]=new Array(0));const t=this._monomerLengthList[0],{startIdx:n,endIdx:o}=(()=>{try{const e=this.gridCol&&this.gridCol.dart?this.gridCol.grid:null;return e&&e.dart?{startIdx:Math.max(Math.floor((e?.vertScroll.min??0)-10),0),endIdx:Math.min(Math.ceil((e?.vertScroll.max??0)+10),this.tableCol.length)}:{startIdx:0,endIdx:Math.min(this.tableCol.length,10)}}catch(e){return{startIdx:0,endIdx:Math.min(this.tableCol.length,10)}}})(),r=this.props.separatorWidth+1*this.props.fontCharWidth,i=this.positionShift,s=Math.ceil(this.colWidth/r)+i;for(let e=n;e<o;e++){if(this._processedRows.get(e)&&s<=this._processedMaxVisibleSeqLength)continue;const n=this.seqHelper.getSeqHandler(this.tableCol).getSplitted(e,s),o=Math.min(s,n.length);o-i>t.length&&t.push(...new Array(o-i-t.length).fill(r));let a=0;for(let e=i;e<o;++e){const o=n.getOriginal(e),r=this.props.monomerToShort(o,this.monomerLengthLimit),s=this.props.separatorWidth+r.length*this.props.fontCharWidth;if(t[e-i]=Math.max(t[e-i]??0,s),a+=s,a>=this.colWidth)break}this._processedMaxVisibleSeqLength=Math.max(this._processedMaxVisibleSeqLength,s),this._processedRows.set(e,!0)}return t}getPosition(e,t,n,o){const[r,i]=this.getCellMonomerLengths(e,n);return 0===this.seqHelper.getSeqHandler(this.tableCol).getSplitted(e).length?null:function(e,t,n){if((n??0)>0&&t<(e[0]??0)+n)return-1;t-=n??0;let o,r=100,i=0,s=e.length-1;for(;i<=s;){if(o=Math.floor((s+i)/2),e[o]<=t&&t<e[o+1])return o;if(t<e[o]?s=o-1:i=o+1,--r<=0)throw new Error(`Get position for pointer x = ${t} searching has not converged on ${JSON.stringify(e)}. `)}return null}(i,t,o)}setMonomerLengthLimit(e){this.monomerLengthLimit!=e&&(this.monomerLengthLimit=e,this.dirty=!0)}setSeparatorWidth(e){this.separatorWidth!=e&&(this.props.separatorWidth=e,this.dirty=!0)}get positionShift(){const e=Number.parseInt(this.tableCol?.tags[Ot.gp.positionShift]??"0")??0;return isNaN(e)?0:Math.max(e,0)}render(e,t,n,o,i,s,a){const l=s.grid?.dart&&s.grid?.canvas===e.canvas;if(!this.seqHelper)return;const c=this.tableCol,u=this.positionShift;e.save();try{const a=this.seqHelper.getSeqHandler(c);let h=this.monomerLengthLimit;if(Go.maxMonomerLength in c.tags){const e=parseInt(c.getTag(Go.maxMonomerLength));h=!isNaN(e)&&e?e:50}if(".mm.cellRenderer.maxMonomerLength"in c.temp){const e=c.temp[".mm.cellRenderer.maxMonomerLength"],t="number"==typeof e?e:parseInt(e);h=!isNaN(t)&&t?t:50}if("1"===c.temp[".mm.cellRenderer.settingsChanged"]||this.monomerLengthLimit!=h){let e=0;const t=8;e=c.temp[".mm.cellRenderer.gapLength"]??e,this.setMonomerLengthLimit(h),this.setSeparatorWidth(a.isMsa()?t:e),c.temp[".mm.cellRenderer.settingsChanged"]="0",this.dirty=!0}const d=s.cell.rowIndex,p=s.cell.value;l&&(o=function(e,t,n,o,r){return e?Math.max(Math.min(e.canvas.width/r-n,o)):Math.max(t.canvas.width/r-n,0)}(s.grid,e,t,o,window.devicePixelRatio)),e.beginPath(),e.rect(t,n,o,i),e.clip(),e.font=this.props?.font??"12px monospace",e.textBaseline="top";const m=c.meta.units,f=c.getTag(Ot.gp.aligned),g=c.getTag(Ot.gp.separator)??"",y=l?a.getSplitted(d):a.splitter(p);let b=Vo.classic;f?.includes("MSA")&&m===Ot.Hi.SEPARATOR&&(b=Vo.MSA);const v=c.temp["reference-sequence"],C=this.tableCol.temp["current-word"],x=(()=>{const e=(0,a.splitter)(null!=v&&""!==v?v:C??"");return wn().count(0).take(e.length).slice(u).map((t=>e.getCanonical(t))).toArray()})(),w=Number.parseInt(c.getTag(Ot.gp.selectedPosition)??"-200"),A=this.shouldUseMultilineRendering(c),T=this.getAnnotationRenderer();if(A){const l=[],d=this.calculateMultiLineLayoutDynamic(e,o,i,y,u,h);let p=n+this.padding;1===d.lineLayouts.length&&(p=n+(i-d.lineHeight)/2);for(const o of d.lineLayouts){const i=p+o.lineIdx*d.lineHeight;for(const h of o.elements){const p=t+h.x,m=h,f=m.posIdx,g=y.getCanonical(f);let b=er;const v=this.getMonomerLib();v&&(b=v.getMonomerTextColor(a.defaultBiotype,g));let C=0;if(s.tableRowIndex!==c.dataFrame.currentRowIdx&&x.length>0){const e=f-u;e>=0&&e<x.length&&g===x[e]&&(C=.7)}l.push({lineIdx:o.lineIdx,monomerIdx:f-u,bounds:new r.Rect(h.x,i-n,h.width,d.lineHeight),sequencePosition:f}),T&&T.drawPositionBackground(e,p,i,h.width+2,d.lineHeight,f,s.tableRowIndex),this.drawHighlightBackground(e,s.tableRowIndex,f,p,i,h.width+2,d.lineHeight),qo(e,m.om,p,i,h.width,d.lineHeight,{color:b,isMultiLineContext:!0,transparencyRate:C,selectedPosition:isNaN(w)||w<1?void 0:w,wordIdx:f})}}null!==s.tableRowIndex&&this._cellBounds.set(s.tableRowIndex,l)}else{this._leftThreeDotsPadding=this.shouldRenderShiftedThreeDots(u)?e.measureText("...").width:0;let[,r]=this.getCellMonomerLengths(s.tableRowIndex,o);l||(r=this.getSummedMonomerLengths(this.getCellMonomerLengthsForSeqValue(p,o)));const c=this.props.separatorWidth+1*this.props.fontCharWidth,d=Math.min(y.length,Math.ceil(o/c)+u);let m;const f=e.measureText("M"),v=f.fontBoundingBoxAscent+f.fontBoundingBoxDescent,C=4,A=Math.min(i,v+C),E=n+(i-A)/2;T&&(m=n+(i/2-v/2+1)+v);for(let l=u;l<d;++l){const c=l<y.length?y.getOriginal(l):a.defaultGapOriginal,d=l<y.length?y.getCanonical(l):a.defaultGapOriginal;let p=er;this.getMonomerLib()&&(p=this.getMonomerLib().getMonomerTextColor(a.defaultBiotype,d));const f=l===y.length-1,v=(y?.graphInfo?.disjointSeqStarts?.indexOf(l+1)??0)>0?"|":g,C=l-u,S=(r[C]??0)-(r[0]??0),N=(C+1<r.length?(r[C+1]??0)-(r[0]??0):S+this.props.fontCharWidth)-S,I=t+this.padding+this._leftThreeDotsPadding+S;T&&null!=s.tableRowIndex&&T.drawPositionBackground(e,I,n,N,i,l,s.tableRowIndex,m),this.drawHighlightBackground(e,s.tableRowIndex,l,I,E,N,A);const M={color:p,pivot:0,left:!0,transparencyRate:0,separator:v,last:f,drawStyle:b,maxWord:r,wordIdx:l-u,gridCell:s,referenceSequence:x,maxLengthOfMonomer:h,monomerTextSizeMap:this._monomerLengthMap,logger:this.logger,selectedPosition:isNaN(w)||w<1?void 0:w-u};qo(e,c,t+this.padding+this._leftThreeDotsPadding,n,o,i,M)}if(this.shouldRenderShiftedThreeDots(u)){const a={color:er,pivot:0,left:!0,transparencyRate:0,separator:g,last:!1,drawStyle:b,maxWord:r,wordIdx:0,gridCell:s,maxLengthOfMonomer:h,monomerTextSizeMap:this._monomerLengthMap,logger:this.logger};qo(e,"...",t+this.padding,n,o,i,a)}}}catch(e){const[t,n]=(0,vn.AP)(e);this.logger.error(t,void 0,n),this.errors.push(e)}finally{e.restore()}}shouldRenderShiftedThreeDots(e){return e>0&&(!this.gridCol||!this.gridCol.dart||!this.gridCol.grid||!this.gridCol.grid.dart||(this.gridCol.grid.props.colHeaderHeight??0)<=50)}onMouseMove(e,t){const n=`${this.toLog()}.onMouseMove()`;if(!this.seqHelper||null==e.tableRowIndex)return;const o=this.positionShift,r=e.bounds,i=t.offsetX-e.gridColumn.left+(e.gridColumn.left-r.x),s=t.offsetY-r.y;this.gridCol?.grid?.canvas&&(this.gridCol.grid.canvas.style.cursor="default");let a=null;const l=this._cellBounds.get(e.tableRowIndex);if(l){for(const e of l)if(e.bounds.contains(i,s)){a=e.monomerIdx;break}}else{const t=this.shouldRenderShiftedThreeDots(o)&&(this._leftThreeDotsPadding??0)>0?this._leftThreeDotsPadding:0;a=this.getPosition(e.tableRowIndex,i,r.width,t)}this.logger.debug(`${n}, argsX: ${i}, argsY: ${s}, left: ${a}`);const c=this.seqHelper.getSeqHandler(this.tableCol),u=c.getSplitted(e.tableRowIndex);if(null!==a&&a>=0&&a+o<u.length){const n=c.alphabet??Ot.YI.UN,r={position:a,biotype:n===Ot.YI.RNA||n===Ot.YI.DNA?Jo.o.NUCLEOTIDE:Jo.o.AA,symbol:u.getCanonical(a+o)},i=[];let s=this._monomerStructureMap[r.symbol];if(!s){const e=this.getMonomerLib();s=this._monomerStructureMap[r.symbol]=e?e.getTooltip(r.biotype,r.symbol):P.divText("Monomer library is not available")}i.push(s);const l=this.getAnnotationRenderer();if(l){const t=l.getTooltipInfo(a+o,e.tableRowIndex);if(t.length>0){const e=document.createElement("hr");e.style.margin="4px 0",e.style.border="none",e.style.borderTop="1px solid #ccc",i.push(e);for(const e of t)i.push(P.divText(e,{style:{fontSize:"12px",marginBottom:"2px"}}))}}P.tooltip.show(P.divV(i),t.x+16,t.y+16),Un(e,r)}else-1===a?P.tooltip.show(P.divText(`${Math.min(o,u.length)} hidden monomers`),t.x+16,t.y+16):P.tooltip.hide(),Un(e,null)}}class nr extends tr{constructor(e,t,n,o){super(e,t,br.logger,n,(()=>{const e=o.getSeqHandler(t),{font:n,fontWidth:r}=tr.getFontSettings(t);return{seqHandler:e,font:n,fontCharWidth:r,separatorWidth:11,monomerToShort:Ot.zS}}))}onMouseMove(e,t){super.onMouseMove(e,t)}}class or extends Ro.$G{static get notationName(){return"Harmonized Sequence"}static get implementsFromHelm(){return!1}static convertFromHelm(e,t){throw new Error("converting from helm not supported yet")}get defaultGapOriginal(){return""}constructor(e,t){super(),this.separator=e,this.helmHelper=t,this.separatorSplitter=(0,Ot.dh)(this.separator),this.splitter=this._splitter.bind(this)}setUnits(){}_splitter(e){const t=this.separatorSplitter(e);return new rr(wn().count(0).take(t.length).map((e=>t.getOriginal(e))).toArray(),i.b9[i.Hi.SEPARATOR])}getHelm(e,t){return Oo.s.fromSeparator(e,this.helmHelper).getHelm()}createCellRendererBack(e,t){const n=new nr(e,t,4,this.helmHelper.seqHelper);return n.init().then((()=>{})),n}}class rr extends s.Mu{getCanonical(e){if(this.isGap(e))return i._S;const t=this.getOriginal(e);let n=t;return t.startsWith("{")?n=t.slice(1):t.endsWith("}")?n=t.slice(0,-1):t.startsWith("(")?n=t.replace(/^\(.\d+\)/,""):t.endsWith(")")&&(n=t.replace(/\(\d+\)$/,"")),n}constructor(e,t){super(e,t)}}async function ir(e){await br.initPromise;const t=window.innerWidth,n=window.innerHeight;try{let i;function s(){if(null==i)return;const e=L()(i.root).find("div.d4-dialog-contents").get(0),t=e.clientHeight,n={0:1},o=Object.values(n).reduce(((e,t)=>e+t),0),r=t-wn().count(0).take(e.children.length).filter((e=>!(e in n))).map((t=>e.children[t])).filter((e=>e instanceof HTMLElement)).map((e=>e.offsetHeight)).reduce(((e,t)=>e+t),0)-38;for(const t of wn().count(0).take(e.children.length))if(t in n){const i=e.children[t],s=r*n[t]/o;i.style.height=`${s}px`}}i=await async function(e,t){const n="ST: PT: HelmDialog()";let i;const s=[];let c=So.aK.Single;const u=()=>{for(const e of s)e.unsubscribe();i.placeholders.detach()};try{const h=await(0,l.pj)(),d=h.getMonomerLib(),p=await(0,Cn.Q)(),m=await(0,bn.b2)(),f=m.buildMonomersFuncsFromLib(d),g=e=>{let t,n,o=null;if(e&&e.rowIndex>=0&&e?.column.semType==r.SEMTYPE.MACROMOLECULE){if(t=p.getSeqHandler(e.column).getValue(e.rowIndex),e.column.temp?.[a.notationProvider]&&!(e.column.temp[a.notationProvider]instanceof or)){let n;o=e.column.temp[a.notationProvider].getHelm(t.value,{}),r.DataFrame.fromColumns([n=r.Column.fromList(r.COLUMN_TYPE.STRING,"seq",[o])]),n.semType=r.SEMTYPE.MACROMOLECULE,n.meta.units=Ot.Hi.HELM,t=p.getSeqHandler(n).getValue(0)}n=t.tags["polytool-data-role"]??"macromolecule"}else{const e=r.Column.fromList(r.COLUMN_TYPE.STRING,"seq",[No.d]);e.semType=r.SEMTYPE.MACROMOLECULE,r.DataFrame.fromColumns([e]),e.meta.units=Ot.Hi.HELM,t=p.getSeqHandler(e).getValue(0),n="macromolecule"}return[t,n]};let y,b,[v,C]=g(e),x=null;const w=P.divText("",{style:{color:"red"}}),A=P.divText("",{style:{fontSize:"11px",color:"var(--grey-4)",marginTop:"2px",marginLeft:"4px",whiteSpace:"nowrap"}});i={macromolecule:m.createHelmInput("Macromolecule",{editable:!1,editorOptions:{drawOptions:{monomerNumbering:1,getMonomer:(t,n)=>{const o=t;if("ATOM"!==o.T)return f.getMonomer(t,n);try{if(v.isDna()||v.isRna()){const e=v.getSplittedWithSugarsAndPhosphates().getCanonical(o.bio.continuousId-1);return f.getMonomer(o.bio.type,e)}if(e?.column?.temp?.[a.notationProvider]instanceof or){const e=v.getSplitted().getCanonical(o.bio.continuousId-1);return f.getMonomer(o.bio.type,e)}{const e=o.elem;return f.getMonomer(o.bio.type,e)}}catch(e){return f.getMonomer(t,n)}}}}}),placeholders:await Io.create("Placeholders",{showAddNewRowIcon:!0,showRemoveRowIcon:!0,showRowHeader:!1,showCellTooltip:!1}),enumeratorType:P.input.choice("Enumerator type",{value:c,items:Object.values(So.aK)}),placeholdersBreadth:await Lo.create("Breadth",{showAddNewRowIcon:!0,showRemoveRowIcon:!0,showRowHeader:!1,showCellTooltip:!1}),keepOriginal:P.input.bool("Keep original",{value:!1}),toAtomicLevel:P.input.bool("To atomic level",{value:!1,onValueChanged:(e,t)=>{N()}}),generateHelm:P.input.bool(Qn,{value:!0}),chiralityEngine:P.input.bool(Jn,{value:!1}),highlightMonomers:P.input.bool(Xn,{value:!1}),rules:{header:P.inlineText([to]),form:await(b=new jn._v(jn.MU,jn.yy,".json",{onValueChanged:e=>{y=e}})).getForm()},trivialName:P.input.string("Trivial name",{value:"",onValueChanged:e=>{const t=e?.trim();x=t?{value:t,colName:"Trivial name"}:null}}),appendToTable:P.input.table("Append to table",{items:o.shell.tables,nullable:!0})};const T=()=>{const e=no[i.enumeratorType.value]??"";P.tooltip.bind(i.enumeratorType.input,e)};if(T(),e?.dataFrame){const t=P.iconFA("columns",(t=>{r.Menu.popup().singleColumnSelector(e.dataFrame,{columnFilter:t=>t.type===r.COLUMN_TYPE.STRING&&t!==e.column,onChange:(t,n,o)=>{o&&(i.trivialName.value=n.get(e.rowIndex)??"")}}).show({x:t.clientX,y:t.clientY})}),"Pick trivial name from a column");i.trivialName.addOptions(t)}i.trivialName.root.style.maxWidth="450px",i.placeholders.onMonomerCellEdit=async(e,t)=>{const n=i.macromolecule.molValue;if(e<0||e>=n.atoms.length)return null;const o=n.atoms[e].biotype(),r=(0,To.Y)(o);return _o(d,r,t,h)},i.placeholdersBreadth.onMonomerCellEdit=async(e,t,n)=>{const o=i.macromolecule.molValue;if(e<0||e>=o.atoms.length)return null;const r=o.atoms[e].biotype(),s=(0,To.Y)(r);return _o(d,s,n,h)};let E=null;i.placeholders.addValidator((e=>{E=null;const t=[];setTimeout((()=>{M()}),100);try{if(i.enumeratorType.value===So.aK.Parallel){const e=i.placeholders.placeholdersValue.filter((e=>e.monomers.length>0));if(e.length>1){const t=e[0].monomers.length,n=e.find((e=>e.monomers.length!==t));n&&(E=`Parallel mode requires all positions to have the same number of monomers. Position ${e[0].position+1} has ${t}, but position ${n.position+1} has ${n.monomers.length}.`)}}if("macromolecule"!==C)return null;const e=[];for(const n of i.placeholders.placeholdersValue){const o=n.position;if(null==o)continue;if(o>=i.macromolecule.molValue.atoms.length){t.push(`There is no monomer at position ${o+1}.`);continue}const r=i.macromolecule.molValue.atoms[o];if(r){const t=r.biotype(),o=(0,To.Y)(t);for(const t of n.monomers){const n=d.getMonomer(o,t);n&&n.lib||e.push({polymerType:o,symbol:t})}}}const n={};for(const t of e){let e=n[t.polymerType];e||(e=n[t.polymerType]=[]),e.push(t.symbol)}const o=Object.entries(n).map((([e,t])=>`${e}: ${t.join(", ")}`)).join("\n");Object.keys(o).length>0&&t.push(`Placeholders contain missed monomers: ${o}`),E=t.length>0?t.join("\n"):E}catch(e){const[t,n]=zn(e,!1);E=t}return setTimeout((()=>{M()}),0),E})),i.enumeratorType.onChanged.subscribe((e=>{c=i.enumeratorType.value,T(),i.placeholders.fireChanged()})),s.push(i.macromolecule.onMouseMove.subscribe((e=>{try{br.logger.debug(`${n}, placeholdersInput.onMouseMove()`);const t=e.offsetX,o=e.offsetY,r=i.macromolecule.molValue,s=m.getHoveredAtom(t,o,r,i.macromolecule.root.clientHeight);if(s){const t=s._parent.atoms.indexOf(s),n=i.placeholders.placeholdersValue.find((e=>e.position===t))?.monomers;if(n){const t=P.divText(n.join(", "));i.macromolecule.showTooltip(t,s),e.preventDefault(),e.stopPropagation()}}}catch(e){zn(e,!1)}}))),s.push(i.macromolecule.onClick.subscribe((e=>{try{br.logger.debug(`${n}, placeholdersInput.onClick()`);const t=e.offsetX,o=e.offsetY,r=i.macromolecule.molValue,s=m.getHoveredAtom(t,o,r,i.macromolecule.root.clientHeight);if(s){const e=s._parent.atoms.indexOf(s);i.placeholders.addPosition(e,"")}}catch(e){zn(e)}}))),s.push(i.placeholders.onChanged.subscribe((()=>{S(),_()}))),s.push(i.placeholdersBreadth.onChanged.subscribe((()=>{_()}))),s.push(i.keepOriginal.onChanged.subscribe((()=>{_()}))),s.push(P.onSizeChanged(i.placeholders.root).subscribe((()=>{t&&t()}))),s.push(o.events.onCurrentCellChanged.subscribe((()=>{const e=o.shell.tv.dataFrame.currentCell;e.column.semType===r.SEMTYPE.MACROMOLECULE&&([v,C]=g(e),O(v,C,e))}))),i.macromolecule.root.style.setProperty("min-width","250px","important");const S=()=>{const e=new Set(i.placeholders.placeholdersValue.map((e=>e.position))),t=i.macromolecule.molValue;for(let n=0;n<t.atoms.length;n++)t.atoms[n].highlighted=e.has(n);i.macromolecule.redraw()},N=()=>{i.toAtomicLevel.value&&"template"===C?(i.generateHelm.root.style.removeProperty("display"),i.chiralityEngine.root.style.removeProperty("display"),i.highlightMonomers.root.style.removeProperty("display"),i.rules.header.style.removeProperty("display"),i.rules.form.style.removeProperty("display")):(i.generateHelm.root.style.display=i.chiralityEngine.root.style.display=i.highlightMonomers.root.style.display="none",i.rules.header.style.display=i.rules.form.style.display="none"),t&&t()};let I=null;const M=()=>{const e=E,t=w;e?(t.innerText=e,t.style.removeProperty("display"),I&&(I.disabled=!0)):(t.innerText="",t.style.setProperty("display","none"),I&&(I.disabled=!1))},_=()=>{try{const e=i.placeholders.placeholdersValue.filter((e=>e.monomers.length>0)),t=i.placeholdersBreadth.placeholdersBreadthValue.filter((e=>e.monomers.length>0&&null!=e.start&&null!=e.end));let n=0;switch(i.enumeratorType.value){case So.aK.Single:n=e.reduce(((e,t)=>e+t.monomers.length),0);break;case So.aK.Parallel:e.length>0&&(n=e.every((t=>t.monomers.length===e[0].monomers.length))?e[0].monomers.length:0);break;case So.aK.Matrix:n=e.length>0?e.reduce(((e,t)=>e*t.monomers.length),1):0}let o=0;t.length>0&&(o=t.reduce(((e,t)=>{const n=Math.abs(t.end-t.start)+1;return e*(t.monomers.length*n)}),1));let r=n+o;i.keepOriginal.value&&r>0&&(r+=1),A.textContent=r>0?`${r} sequence${1!==r?"s":""} will be generated`:""}catch(e){A.textContent=""}},L=e=>{t&&t()},O=(e,t,n)=>{i.macromolecule.value=e;const o=n?.dataFrame;L(o)};O(v,C,e),N(),_();const R=async()=>{try{const t=i.macromolecule.stringValue;if(void 0===t||""===t)o.shell.warning("PolyTool: no molecule was provided");else{if(0===Object.keys(i.placeholders.placeholdersValue).length&&0===Object.keys(i.placeholdersBreadth.placeholdersBreadthValue).length)return void o.shell.warning(`${eo}: placeholders are empty`);await(0,bn.b2)();const n=i.placeholders.placeholdersValue,r=i.enumeratorType.value;if(r===So.aK.Parallel){const e=n.filter((e=>e.monomers.length>0));if(e.length>1){const t=e[0].monomers.length;if(e.some((e=>e.monomers.length!==t)))return void o.shell.warning("Parallel mode requires all positions to have the same number of monomers")}}const s={placeholders:n,type:r,breadthPlaceholders:i.placeholdersBreadth.placeholdersBreadthValue,keepOriginal:i.keepOriginal.value};if(e?.column?.temp?.[a.notationProvider]&&!(e.column.temp[a.notationProvider]instanceof or)){const t=e.column.temp[a.notationProvider];if(t.constructor.implementsFromHelm){const e=t.constructor;s.fromHelmNotation={notationName:e.notationName,convert:t=>e.convertFromHelm(t,{})}}}const l=i.toAtomicLevel.value,c=await sr(t,C,x,s,!!l&&{generateHelm:i.generateHelm.value,chiralityEngine:i.chiralityEngine.value,highlightMonomers:i.highlightMonomers.value,rules:await b.getActive()},m),u=i.appendToTable.value;u?(u.append(c,!0),u.meta.detectSemanticTypes()):o.shell.addTableView(c)}}catch(e){zn(e)}},$=P.dialog({title:eo,showFooter:!0}).add(i.macromolecule.root).add(P.divH([P.divV([i.placeholders.root,P.divH([i.enumeratorType.root,A],{style:{alignItems:"center"}})],{style:{width:"50%"}}),P.divV([i.placeholdersBreadth.root],{style:{width:"50%"}})],{style:{width:"100%"}})).add(P.divH([P.divV([i.trivialName.root,i.keepOriginal.root,i.appendToTable.root],{style:{width:"50%"}}),P.divV([P.divH([i.toAtomicLevel.root,i.generateHelm.root]),P.divH([i.chiralityEngine.root,i.highlightMonomers.root]),i.rules.header,i.rules.form],{style:{width:"50%"}})],{style:{width:"100%"}})).add(w).onOK((()=>{if(E)return M(),void o.shell.warning("Please fix validation errors before running enumeration");R()}));return I=$.getButton("OK"),s.push($.onClose.subscribe((()=>{u()}))),$.history((()=>({description:`${i.enumeratorType.value} ${i.placeholders.placeholdersValue?.map((e=>(e.position?.toString()??"")+": "+e.monomers?.join(", "))).join("; ")}`,placeholders:i.placeholders.stringValue,enumeratorType:i.enumeratorType.value,placeholdersBreadth:i.placeholdersBreadth.stringValue,trivialName:i.trivialName.value,keepOriginal:i.keepOriginal.value,toAtomicLevel:i.toAtomicLevel.value,generateHelm:i.generateHelm.value,chiralityEngine:i.chiralityEngine.value,highlightMonomers:i.highlightMonomers.value,rules:y})),(e=>{i.enumeratorType.value=e.enumeratorType??So.aK.Single,i.placeholders.stringValue=e.placeholders,i.placeholdersBreadth.stringValue=e.placeholdersBreadth,e.trivialName&&(i.trivialName.value=e.trivialName),i.keepOriginal.value=e.keepOriginal??!1,i.toAtomicLevel.value=e.toAtomicLevel??!0,i.generateHelm.value=e.generateHelm??!0,i.chiralityEngine.value=e.chiralityEngine??!1,i.highlightMonomers.value=e.highlightMonomers??!1,b.setActive(e.rules),setTimeout((()=>{i.placeholders.invalidateGrid(),i.placeholdersBreadth.invalidateGrid(),_()}),100)})),$}catch(e){throw u(),e}}(e,s);let c=!0;P.onSizeChanged(i.root).subscribe((()=>{if(c){const e=.7*t,o=.7*n;i.root.style.width=`${Math.min(t,e)}px`,i.root.style.height=`${Math.min(n,o)}px`,i.root.style.left=`${Math.floor((t-i.root.offsetWidth)/2)}px`,i.root.style.top=`${Math.floor((n-i.root.offsetHeight)/2)}px`,c=!1}s()})),s(),br.logger.debug("PolyToolEnumerateHelmUI: dialog before show"),i.show({width:Math.max(350,.7*t),resizable:!0}),br.logger.debug("PolyToolEnumerateHelmUI: dialog after show")}catch(u){const[h,d]=(0,vn.AP)(u);br.logger.error(h,void 0,d)}}async function sr(e,t,n,i,s,a){const c=r.TaskBarProgressIndicator.create("PolyTool enumerating...");try{const c=await(0,l.pj)(),u=await(0,Vn.j)(),h=c.getMonomerLib(),d=(0,No.o)(e,n?.value??"",i);let p;switch(t){case"macromolecule":p=r.Column.fromType(r.COLUMN_TYPE.STRING,"Enumerated",d.length).init((e=>d[e][0]));break;case"template":{const e=new Array(d.length);for(let t=0;t<d.length;t++){const n=d[t][0],o=Oo.s.fromHelm(n,a);e[t]=o.getNotation()}p=r.Column.fromList(r.COLUMN_TYPE.STRING,"Enumerated",e),p.semType=r.SEMTYPE.MACROMOLECULE,p.setTag("polytool-data-role","template"),Cr.applyNotationProviderForCyclized(p,"-");break}}const m=r.DataFrame.fromColumns([p]);if("macromolecule"===t&&i.fromHelmNotation){const e=r.Column.fromType(r.COLUMN_TYPE.STRING,`${i.fromHelmNotation.notationName}(${p.name})`,m.rowCount).init((e=>p.isNone(e)?null:i.fromHelmNotation.convert(p.get(e))));m.columns.add(e)}if(await o.data.detectSemanticTypes(m),"template"==t&&Cr.applyNotationProviderForCyclized(p,"-"),s){let e;if("macromolecule"===t){e=p;const t=await a.seqHelper.helmToAtomicLevel(e,s.chiralityEngine,s.highlightMonomers);m.columns.add(t.molCol,!1);const n=t.molCol;await async function(e,t,n,o,r,i=!1){const s=o.getSeqHandler(e),a=s.alphabet==Ot.YI.RNA||s.alphabet==Ot.YI.DNA,l=s.isHelm()&&a,c=!s.isHelm()&&a,u=e=>null==e?null:l?i?e:Math.floor(e/3):c&&i?3*e+1:e,h=i?await o.getHelmToMolfileConverter(n):null,d=new On({max:100});function p(e,t){const s=e.get(t);if(null==s)return null;let a=d.get(s);return a||d.set(s,a=function(e,t){const s=o.getSeqHandler(e);if(i){const e=s.getHelm(t);return o.helmToAtomicLevelSingle(e,h,!1,!1).monomers}{const e=s.getSplitted(t),o=s.defaultBiotype,i=wn().count(0).take(e.length).map((t=>({position:t,symbol:e.getCanonical(t),biotype:o}))).toArray(),a=s.alphabet,l=a==Ot.YI.RNA||a==Ot.YI.DNA?"RNA":"PEPTIDE",c=(0,Bn.eM)([i],[void 0],l,a,n,r);return(0,Fn.gU)(i,c,a,l).monomers}}(e,t)),a}const m={targetCol:t,handler:(t,o,r)=>{const i=r.grid,s=t.tableRowIndex,a=t.gridRow,l=i.cell(r.name,a),c=Rn();if(!c||c&&(c.dataFrameId!=e.dataFrame.id||c.gridRowIdx!=a||c.seqColName!=e.name||c.seqPosition!=o?.position)){if(c&&($n(null),c.gridCell.render()),!o)return $n(null),!0;$n({gridCell:l,dataFrameId:e.dataFrame.id,gridRowIdx:a,seqColName:e.name,seqPosition:u(o?.position)??-1,getSubstruct:()=>{if(!o||"*"===o.symbol)return;const t=p(e,s);if(!t)return;const r=t.get(u(o?.position));return r?(0,kn.H)([r],n):{atoms:[],bonds:[],highlightAtomColors:[],highlightBondColors:[]}}}),l.render()}return!0},getSubstruct:o=>{if("true"!=t.getTag(".sequence-src-highlight-monomers"))return;if(null==o)return;if(!e.get(o))return;const r=p(e,o);return r?(0,kn.H)(r.values(),n):void 0}};return Gn(e.temp,m),Dn(t.temp,m),m}(e,n,h,a.seqHelper,u,!0)}else"template"===t&&(e=(await ro(p,s.generateHelm,!1,s.chiralityEngine,!1,s.rules))[0])}if(n){const e=r.Column.fromType(r.COLUMN_TYPE.STRING,n.colName,d.length).init((e=>d[e][1]));m.columns.add(e)}return m}finally{c.close()}}var ar,lr=n(3151);class cr{constructor(e){this.rawLib=e}isValid(){return this.rawLib.every((e=>"object"==typeof e&&Object.values(Yn).every((t=>t in e&&"string"==typeof e[t]))))}getJsonMonomerLib(){const e=[];return this.rawLib.forEach((t=>{const n=this.prepareMonomer(t);e.push(n)})),e}prepareMonomer(e){const t={...lr.pe};Object.entries(Yn).forEach((([n,o])=>{const r=e[o];t[n]=r}));let n="smiles";const o=e[Yn[n]],r=new ur(o),i=r.getCappedSmiles();return t[n]=i,n="rgroups",t[n]=hr.getRGroups(r.getNumberOfRGroups()),n="molfile",t[n]=new dr(r.getSmilesWithRGroups()).getMolfile(),t}}class ur{constructor(e){let t=0;this.smilesWithRGroups=e.replace(/\[R(\d+)\]/g,((e,n)=>(++t,`[${n}*]`))),this.numberOfRGroups=t}getSmilesWithRGroups(){return this.smilesWithRGroups}getCappedSmiles(){return this.capRGroups()}getNumberOfRGroups(){return this.numberOfRGroups}capRGroups(){let e=this.smilesWithRGroups.replace("[1*]","[H:1]");return e=e.replace("[2*]","[OH:2]"),e.replace("[3*]","[H:3]")}}class hr{constructor(){}static getRGroups(e){return Kn.slice(0,e)}}class dr{constructor(e){this.smilesWithRGroups=e}getMolfile(){let e=r.chem.convert(this.smilesWithRGroups,r.chem.Notation.Smiles,r.chem.Notation.MolBlock);return e=this.restoreRGPLine(e),e=this.fixRGroupSymbols(e),e}restoreRGPLine(e){return e.replace("M ISO","M RGP")}fixRGroupSymbols(e){return e.replace(/\bR\b/g,"R#")}}class pr{constructor(e,t){this.fileName=e,this.fileContent=t,this.validateFileType();const n=r.DataFrame.fromCsv(this.fileContent),o=this.toJson(n);this.polyToolMonomerLib=new cr(o),this.validateContent()}async getJson(){return this.polyToolMonomerLib.getJsonMonomerLib()}toJson(e){return Array.from({length:e.rowCount},((t,n)=>e.columns.names().reduce(((t,o)=>(t[o]=e.get(o,n),t)),{})))}validateFileType(){if(!this.fileName.endsWith(".csv"))throw new Error(`File ${this.fileName} is not an CSV file`)}validateContent(){if(!this.polyToolMonomerLib.isValid())throw new Error("Invalid format of CSV monomer lib")}}!function(e){e.table="table",e.seqCol="seqCol",e.generateHelm="generateHelm",e.chiralityEngine="chiralityEngine",e.rules="rules"}(ar||(ar={}));class mr{constructor(e){this.call=e,this.ruleInputs=new jn._v(jn.MU,jn.yy,".json")}async initInputs(){const e=e=>this.call.inputParams[e],t=await this.ruleInputs.getForm();this.inputs={table:(()=>{const t=e(ar.table);return P.input.table(t.property.caption,{value:t.value})})(),seqCol:(()=>{const t=e(ar.seqCol);return P.input.column(t.property.caption,{value:t.value,table:t.value.dataFrame})})(),generateHelm:P.input.forProperty(e(ar.generateHelm).property),chiralityEngine:P.input.forProperty(e(ar.chiralityEngine).property),rules:{header:P.inlineText([to]),form:t}}}static async create(e){const t=new mr(e);return await t.initInputs(),t}async getParams(){return{table:this.inputs.table.value,seqCol:this.inputs.seqCol.value,generateHelm:this.inputs.generateHelm.value,chiralityEngine:this.inputs.chiralityEngine.value,rules:await this.ruleInputs.getActive()}}async showDialog(){const e=P.div([this.inputs.table,this.inputs.seqCol,this.inputs.generateHelm,this.inputs.chiralityEngine,this.inputs.rules.header,this.inputs.rules.form],{style:{minWidth:"320px"}});return new Promise(((t,n)=>{P.dialog({title:Zn}).add(e).onOK((async()=>{const e=await this.getParams(),n=(await this.call.func.prepare(e).call(!0)).getOutputParamValue();t(n)})).onCancel((()=>{n(new Error("Cancelled by user"))})).show()}))}widget(){throw new Error("not implemented")}}var fr=function(e,t,n,o){var r,i=arguments.length,s=i<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,o);else for(var a=e.length-1;a>=0;a--)(r=e[a])&&(s=(i<3?r(s):i>3?r(t,n,s):r(t,n))||s);return i>3&&s&&Object.defineProperty(t,n,s),s},gr=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},yr=function(e,t){return function(n,o){t(n,o,e)}};o.decorators||(o.decorators={}),["func","init","param","panel","editor","demo","app","appTreeBrowser","fileHandler","fileExporter","model","viewer","filter","cellRenderer","autostart","dashboard","folderViewer","semTypeDetector","packageSettingsEditor","functionAnalysis","converter","fileViewer","model","treeBrowser","polyfill"].forEach((e=>{o.decorators[e]||(o.decorators[e]=function(e){return function(e,t,n){}})}));const br=new R({debug:!0});let vr=null;class Cr{static async oligoToolkitApp(){await br.initLibData();const e=await async function(e){const t={"Mermadesynthesis:merMadeSynthesis":{tabName:"SYNTHESIZE",parameters:Kt(e)}},n={};for(const[e,r]of Object.entries(t)){let t;try{t=await o.functions.call(e,r.parameters);const i=new zt(r.tabName,t);i.initView(),n[r.tabName]=()=>i.getView()}catch(t){console.warn(`Plugin ${e} not loaded, reason:`,t);continue}}return n}(br);if(!e)throw new Error("External app view factories not loaded");const t=new Yt(e,br);return await t.getAppView()}static async init(){return null===vr&&br.startInit(vr=async function(){const[e]=await Promise.all([(0,bn.b2)()]);br.completeInit(e)}()),vr}static async oligoTranslatorApp(){return await xr("Oligo Translator")}static async oligoPatternApp(){return await xr("Oligo Pattern")}static async oligoStructureApp(){return await xr("Oligo Structure")}static async getTranslationHelper(){return await br.initLibData(),br}static getCodeToWeightsMap(){const e=br.monomerLibWrapper.getCodesToWeightsMap();return Object.fromEntries(e)}static validateSequence(e){const t=br.createSequenceValidator(e),n=br.createFormatDetector(e).getFormat();return null!==n&&t.isValidSequence(n)}static getMolfileFromGcrsSequence(e,t){return new At(e,t,"GCRS").convert()}static linkStrands(e){return Tt(e,!0)}static async demoTranslateSequence(){await async function(){await b((async()=>{const e=await Cr.oligoTranslatorApp();o.shell.addView(e)}))}()}static async demoOligoPattern(){await async function(){await b((async()=>{const e=await Cr.oligoPatternApp();o.shell.addView(e)}))}()}static async demoOligoStructure(){await async function(){await b((async()=>{const e=await Cr.oligoStructureApp();o.shell.addView(e),["Afcgacsu","Afcgacsu","Afcgacsu"].forEach((async(e,t)=>{await async function(e,t){await r.delay(500);const n=document.querySelectorAll(".st-colored-text-input > textarea")[e];n.value=t;const o=new Event("input");n.dispatchEvent(o)}(t,e)}))}))}()}static async translateOligonucleotideSequence(e,t,n){return await br.initLibData(),br.createFormatConverter(e,t).convertTo(n)}static async polyToolConvertTopMenu(){await async function(){await br.initPromise;let e=null;try{e=await async function(){const e=[],t=()=>{for(const t of e)t.unsubscribe()};try{let n;const i=o.shell.t.columns.bySemTypeAll(r.SEMTYPE.MACROMOLECULE),s=i.filter((e=>br.seqHelper.getSeqHandler(e).notation===Ot.Hi.CUSTOM));if(!n){if(i.length<1)throw new Error("No dataframe with macromolecule columns open");if(s.length<1){const e=r.Func.find({package:"Bio",name:"toAtomicLevel"})[0];return e?(e.prepare().edit(),null):(o.shell.warning("Polytool requires a macromolecule column with custom notation. \n\nUse Top menu | Bio | Transform | To Atomic Level."),null)}n=i[0]}const a=P.input.column("Column",{table:n.dataFrame,value:n,filter:e=>s.includes(e)}),l=P.input.bool(Qn,{value:!0});P.tooltip.bind(l.root,"Add HELM column");const c=P.input.bool("Linearize",{value:!0});P.tooltip.bind(c.root,"Make representation linear if possible");const u=P.input.bool(Jn,{value:!0}),h=P.input.bool(Xn,{value:!0});let d;const p=new jn._v(jn.MU,jn.yy,".json",{onValueChanged:e=>{d=e}}),m=P.inlineText([to]);P.tooltip.bind(m,"Add or specify rules to use");const f=await p.getForm(),g=P.divV([a,l,c,u,h,m,f]),y=async()=>{try{const e=await p.getActive();await ro(a.value,l.value,c.value,u.value,h.value,e)}catch(e){zn(e)}},b=P.dialog(Zn).add(g).onOK((()=>{y()}));return e.push(b.onClose.subscribe((()=>{t()}))),b.history((()=>({generateHelm:l.value,chiralityEngine:u.value,rules:d})),(e=>{l.value=e.generateHelm,u.value=e.chiralityEngine,p.setActive(e.rules)})),b}catch(e){throw t(),e}}(),e?.show()}catch(e){const[t,n]=(0,vn.AP)(e);o.shell.warning("To run PolyTool Conversion, open a dataframe with macromolecules"),br.logger.error(t,void 0,n)}}()}static async getPolyToolConvertEditor(e){const t=await mr.create(e);return await t.showDialog()}static async polyToolConvert2(e,t,n,o,r){return(await ro(t,n,!1,o,!1,r))[0]}static async polyToolEnumerateHelmTopMenu(){await ir(o.shell.tv?.dataFrame.currentCell)}static async polyToolEnumerateChemTopMenu(){wo()}static async chemEnumerateReactionsTopMenu(){wo()}static async polyToolColumnChoice(e,t){var n;(function(e){e.semType=r.SEMTYPE.MACROMOLECULE,e.setTag("aligned","SEQ"),e.setTag("alphabet",Ot.YI.PT)})(n=t),n.meta.units=Ot.Hi.SEPARATOR,n.setTag("separator","-"),await o.data.detectSemanticTypes(e)}static async createMonomerLibraryForPolyTool(e){const t=await e.readAsString(),n=new pr(e.fileName,t),o=await n.getJson(),i=e.fileName.replace(/\.csv$/,".json"),s=JSON.stringify(o,null,2);r.Utils.download(i,s)}static async ptEnumeratorHelmApp(){await ir()}static async ptEnumeratorChemApp(){return await async function(){await br.initPromise;try{const e=Ao(await(0,Vn.j)(),null),t=P.bigButton("Enumerate",(async()=>{await e.execute()}));e.bindActionButton(t);const n=r.View.create();return n.name=so,n.box=!0,n.root.appendChild(P.divV([e.root,P.div([t],{style:{padding:"8px 4px 0"}})],{style:{height:"100%",width:"100%",padding:"8px"}})),n}catch(e){return zn(e),null}}()}static async getPtHelmEnumeratorDialog(e){return ir(e)}static async getPtChemEnumeratorDialog(e){return wo(e)}static async enumerateSingleHelmSequence(e,t,n,o=!1){return await sr(e,"macromolecule",null,{type:So.aK.Single,placeholders:t.map(((e,t)=>({position:e,monomers:n[t]})))},!!o&&{generateHelm:!0,chiralityEngine:!0,highlightMonomers:!1,rules:[]},br.helmHelper)}static async enumerateSingleHelmSequenceWithNaturalAAs(e,t=!1){const n=(0,Ot.qp)(e).length,o=Array.from({length:n},((e,t)=>t)),r=o.map((e=>["A","C","D","E","F","G","H","I","K","L","M","N","P","Q","R","S","T","V","W","Y"]));return await Cr.enumerateSingleHelmSequence(e,o,r,t)}static async getPolyToolCombineDialog(){!async function(){const e=[],t=P.divV([]),n=i=>{const s=(()=>{const e=P.divH([]),t=P.input.table("Table",{value:void 0,tooltipText:"Table with sequences"}),n=P.input.choice("Column",{items:[],value:void 0,tooltipText:"Sequence column"});return t.onChanged.subscribe((async()=>{const e=t.value;if(!e)return n.items=[],void(n.value=null);await e.meta.detectSemanticTypes(),await o.data.detectSemanticTypes(e);const i=Array.from(e.columns.categorical),s=i.map((e=>e.name));n.items=s,n.value=i.find((e=>e.semType===r.SEMTYPE.MACROMOLECULE))?.name??s.find((e=>{const t=e.toLowerCase();return t.includes("seq")||t.includes("pep")}))??s[0]})),e.appendChild(t.root),e.appendChild(n.root),e.style.alignItems="center",{root:e,getValue:()=>({table:t.value,column:n.value})}})(),a=P.icons.delete((()=>{if(!s.root.parentElement||e.length<2)return;s.root.remove();const t=e.indexOf(s);-1!==t&&e.splice(t,1)}),"Remove"),l=P.icons.add((()=>{let t=e.indexOf(s);-1===t&&(t=e.length),n(t+1)}),"Add");s.root.appendChild(a),s.root.appendChild(l),a.style.marginLeft="8px",a.style.marginRight="8px",a.style.color="var(--blue-1)",l.style.color="var(--blue-1)";const c=e[i];c?t.insertBefore(s.root,c.root):t.appendChild(s.root),e.splice(i,0,s)};n(0);const i=P.input.string("Separator",{value:"-",tooltipText:"Separator for sequences",nullable:!1});P.dialog("Combine Sequences").add(t).add(i.root).onOK((async()=>{if(!function(){const t=e.map((e=>e.getValue())),n=t.map((e=>e.table)),o=t.map((e=>e.column));return n.every((e=>!!e))&&o.every((e=>!!e))}())return void o.shell.error("Please fill all the fields");const t=e.map((e=>e.getValue())),n=t.map((e=>e.table)),s=t.map((e=>e.column)),a=i.value,l=s.map(((e,t)=>n[t].col(e).toList().filter((e=>!!e))));let c=0;const u=l.reduce(((e,t)=>e*t.length),1);if(u>1e7)return void o.shell.error("Too many combinations. Maximum allowed is 10M");const h=new Array(u).fill(null),d=(e,t)=>{if(t===l.length)return void(h[c++]=e);const n=`${e}${e?a:""}`,o=l[t];for(let e=0;e<l[t].length;e++)d(n+o[e],t+1)};d("",0);const p=r.DataFrame.fromColumns([r.Column.fromStrings("Combined Sequences",h)]);p.name="Combined Sequences",await p.meta.detectSemanticTypes(),await o.data.detectSemanticTypes(p),o.shell.addTableView(p)})).show({resizable:!0})}()}static oligoNucleotideCellRenderer(){return new un}static oligoNucleotidePanel(e){return function(e){const t=e.value??"",n=(0,Jt.On)(t),o=n.sense.monomers.filter((e=>"nucleotide"===e.kind)).length,i=n.antisense?n.antisense.monomers.filter((e=>"nucleotide"===e.kind)).length:0,s=new Map,a=new Map,l=new Map,c=[...n.sense.monomers,...n.antisense?.monomers??[]];for(const e of c)if("nucleotide"===e.kind){const t=e;hn(s,t.sugar),t.phosphate&&hn(a,t.phosphate)}else hn(l,e.symbol);const u=P.divV([],{style:{fontSize:"12px"}});return u.appendChild(pn("Summary",P.tableFromMap({"Sense length":`${o} nt`,"Antisense length":i?`${i} nt`:"single-strand","Modifications used":dn(s,a),Conjugates:l.size?Array.from(l.entries()).map((([e,t])=>`${(0,Xt.rK)(e).meta.name} ×${t}`)).join(", "):"—"}))),u.appendChild(pn("Legend",function(e,t,n){const o=[],r=new Map;for(const[t,n]of e.entries()){const e=(0,Xt.Jy)(t);"r"!==e&&"d"!==e&&r.set(e,(r.get(e)??0)+n)}for(const[e,t]of r.entries()){const n=(0,Xt.xh)(e,null).meta;o.push({label:n.name,color:n.color,count:t})}const i=new Map;for(const[e,n]of t.entries()){const t=(0,Xt.$T)(e);"p"!==t&&i.set(t,(i.get(t)??0)+n)}for(const[e,t]of i.entries()){const n=(0,Xt.bM)(e).meta;o.push({label:`${n.name} (linkage)`,color:n.color,count:t})}for(const[e,t]of n.entries()){const n=(0,Xt.rK)(e).meta;o.push({label:n.name,color:n.color,count:t})}if(0===o.length)return P.divText("No modifications. Chip color reflects the base (A/C/G/U).",{style:{fontSize:"12px",color:"var(--grey-4, #888)",lineHeight:"1.4"}});const s=o.map((({label:e,color:t,count:n})=>P.divH([P.div([],{style:{width:"14px",height:"14px",borderRadius:"3px",background:t,border:"1px solid rgba(0,0,0,0.15)",flexShrink:"0"}}),P.divText(e,{style:{fontSize:"12px",flex:"1"}}),P.divText(`×${n}`,{style:{fontSize:"11px",color:"var(--grey-4, #888)",fontVariantNumeric:"tabular-nums"}})],{style:{gap:"6px",alignItems:"center",marginBottom:"3px"}})));return P.divV(s)}(s,a,l))),r.Widget.fromRoot(u)}(e)}static oligoNucleotideStructuresPanel(e){return function(e){const t=(e.value??"").split("$")[0].split("|").map((e=>e.trim())).filter((e=>e.length>0));if(0===t.length)return r.Widget.fromRoot(P.divText("No HELM chains found",{style:{fontSize:"12px",color:"var(--grey-4, #888)"}}));const n=t.map((e=>(0,Jt.nj)(e.replace(mn,"$11{")+"$$$$"))),o=1===t.length?["Strand"]:["Sense","Antisense"],i=r.Column.fromStrings("helm",n);i.semType=r.SEMTYPE.MACROMOLECULE,i.meta.units="helm",i.setTag("aligned","SEQ"),i.setTag("alphabet","RNA"),i.setTag("cell.renderer","helm");const s=r.DataFrame.fromColumns([i]),a=P.accordion("oligo chemical structures");for(let e=0;e<s.rowCount;e++){const t=o[e],n=s.cell(e,"helm");a.addPane(t,(()=>fn(n,t)))}return r.Widget.fromRoot(a.root)}(e)}static async convertHelmToOligoNucleotide(e,t){const n=function(e,t){const n=new Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.get(e)??"";const o=r.Column.fromStrings(e.columns.getUnusedName(`${t.name} (oligo)`),n);return gn(o),e.columns.add(o),o}(e,t);return await o.data.detectSemanticTypes(e),n}static async combineSenseAntisenseToOligoNucleotide(e,t,n){const i=function(e,t,n){if(t.length!==n.length)throw new Error("Sense and antisense columns must have the same length");const o=new Array(t.length);for(let e=0;e<t.length;e++){const r=t.get(e)??"",i=n.get(e)??"";if(!(0,Jt.yO)(r)){o[e]="";continue}const s=yn(r,1),a=(0,Jt.yO)(i)?yn(i,2):"",l=a?`${s}|${a}`:s;o[e]=`${l}$$$$`}const i=r.Column.fromStrings(e.columns.getUnusedName(`${t.name}+${n.name} (oligo)`),o);return gn(i),e.columns.add(i),i}(e,t,n);return await o.data.detectSemanticTypes(e),i}static applyNotationProviderForCyclized(e,t){e.setTag("aligned","SEQ"),e.setTag("alphabet","UN"),e.setTag(".alphabetIsMultichar","true"),e.meta.units=i.Hi.CUSTOM,t&&!e.tags[i.qE.separator]&&(e.tags[i.qE.separator]=t),e.tags["polytool-data-role"]="template",e.temp[a.notationProvider]=new or(t,br.helmHelper)}static async harmonizedSequenceNotationProviderConstructor(){return or}}async function xr(e){await br.initLibData();const t=function(e,t){switch(e){case"Oligo Translator":return new Wt(t);case"Oligo Pattern":return new it(t);case"Oligo Structure":return new Lt(t);default:throw new Error(`Unknown app name: ${e}`)}}(e,br);return await t.getAppView()}fr([o.decorators.app({icon:"img/icons/toolkit.png",browsePath:"Peptides | Oligo Toolkit",name:"Oligo Toolkit",tags:["app"]}),gr("design:type",Function),gr("design:paramtypes",[]),gr("design:returntype",Promise)],Cr,"oligoToolkitApp",null),fr([o.decorators.init({tags:["init"]}),gr("design:type",Function),gr("design:paramtypes",[]),gr("design:returntype",Promise)],Cr,"init",null),fr([o.decorators.app({icon:"img/icons/translator.png",browsePath:"Peptides | Oligo Toolkit",name:"Oligo Translator",tags:["app"]}),gr("design:type",Function),gr("design:paramtypes",[]),gr("design:returntype",Promise)],Cr,"oligoTranslatorApp",null),fr([o.decorators.app({icon:"img/icons/pattern.png",browsePath:"Peptides | Oligo Toolkit",name:"Oligo Pattern",tags:["app"]}),gr("design:type",Function),gr("design:paramtypes",[]),gr("design:returntype",Promise)],Cr,"oligoPatternApp",null),fr([o.decorators.app({icon:"img/icons/structure.png",browsePath:"Peptides | Oligo Toolkit",name:"Oligo Structure",tags:["app"]}),gr("design:type",Function),gr("design:paramtypes",[]),gr("design:returntype",Promise)],Cr,"oligoStructureApp",null),fr([o.decorators.func({outputs:[{type:"object",name:"result"}]}),gr("design:type",Function),gr("design:paramtypes",[]),gr("design:returntype",Promise)],Cr,"getTranslationHelper",null),fr([o.decorators.func({outputs:[{type:"object",name:"result"}]}),gr("design:type",Function),gr("design:paramtypes",[]),gr("design:returntype",Object)],Cr,"getCodeToWeightsMap",null),fr([o.decorators.func(),gr("design:type",Function),gr("design:paramtypes",[String]),gr("design:returntype",Boolean)],Cr,"validateSequence",null),fr([o.decorators.func({name:"validateSequence"}),gr("design:type",Function),gr("design:paramtypes",[String,Boolean]),gr("design:returntype",String)],Cr,"getMolfileFromGcrsSequence",null),fr([o.decorators.func(),yr(0,o.decorators.param({type:"object"})),gr("design:type",Function),gr("design:paramtypes",[Object]),gr("design:returntype",String)],Cr,"linkStrands",null),fr([o.decorators.func({meta:{demoPath:"Bioinformatics | Oligo Toolkit | Translator",path:"/apps/Tutorials/Demo/Bioinformatics/Oligonucleotide%20Sequence:%20Translate",demoSkip:"GROK-14320"},name:"demoOligoTranslator",description:"Translate oligonucleotide sequences across various formats accepted by different synthesizers"}),gr("design:type",Function),gr("design:paramtypes",[]),gr("design:returntype",Promise)],Cr,"demoTranslateSequence",null),fr([o.decorators.func({meta:{demoPath:"Bioinformatics | Oligo Toolkit | Pattern",path:"%20/apps/Tutorials/Demo/Bioinformatics/Oligonucleotide%20Sequence:%20Visualize%20duplex"},description:"Design a modification pattern for an oligonucleotide sequence"}),gr("design:type",Function),gr("design:paramtypes",[]),gr("design:returntype",Promise)],Cr,"demoOligoPattern",null),fr([o.decorators.func({meta:{demoPath:"Bioinformatics | Oligo Toolkit | Structure",path:"%20/apps/Tutorials/Demo/Bioinformatics/Oligonucleotide%20Sequence:%20Visualize%20duplex"},description:"Visualize duplex and save SDF"}),gr("design:type",Function),gr("design:paramtypes",[]),gr("design:returntype",Promise)],Cr,"demoOligoStructure",null),fr([o.decorators.func(),gr("design:type",Function),gr("design:paramtypes",[String,String,String]),gr("design:returntype",Promise)],Cr,"translateOligonucleotideSequence",null),fr([o.decorators.func({"top-menu":"Bio | PolyTool | Convert...",name:"polyToolConvert",description:"editor for Performing conversion of sequences in custom notation to molfiles"}),gr("design:type",Function),gr("design:paramtypes",[]),gr("design:returntype",Promise)],Cr,"polyToolConvertTopMenu",null),fr([o.decorators.editor({tags:["editor"]}),gr("design:type",Function),gr("design:paramtypes",[r.FuncCall]),gr("design:returntype",Promise)],Cr,"getPolyToolConvertEditor",null),fr([o.decorators.func({editor:"SequenceTranslator:getPolyToolConvertEditor"}),yr(1,o.decorators.param({options:{caption:"Sequence"}})),yr(2,o.decorators.param({options:{initialValue:"true"}})),yr(3,o.decorators.param({options:{initialValue:"true"}})),yr(4,o.decorators.param({type:"object"})),gr("design:type",Function),gr("design:paramtypes",[r.DataFrame,r.Column,Boolean,Boolean,Array]),gr("design:returntype",Promise)],Cr,"polyToolConvert2",null),fr([o.decorators.func({"top-menu":"Bio | PolyTool | Enumerate HELM...",name:"polyToolEnumerateHelm",description:"Dialog for configuring enumeration of a HELM sequence"}),gr("design:type",Function),gr("design:paramtypes",[]),gr("design:returntype",Promise)],Cr,"polyToolEnumerateHelmTopMenu",null),fr([o.decorators.func({"top-menu":"Bio | PolyTool | Enumerate Chem...",name:"polyToolEnumerateChem",description:"Perform enumeration of a molecule using different fragments at specified positions"}),gr("design:type",Function),gr("design:paramtypes",[]),gr("design:returntype",Promise)],Cr,"polyToolEnumerateChemTopMenu",null),fr([o.decorators.func({"top-menu":"Chem | Transform | Reactions | Enumerate...",name:"chemEnumerateReactions",description:"Enumerate cores and R-group lists into a molecule table (Zip or Cartesian)"}),gr("design:type",Function),gr("design:paramtypes",[]),gr("design:returntype",Promise)],Cr,"chemEnumerateReactionsTopMenu",null),fr([o.decorators.func(),yr(0,o.decorators.param({options:{description:"Input data table"}})),gr("design:type",Function),gr("design:paramtypes",[r.DataFrame,r.Column]),gr("design:returntype",Promise)],Cr,"polyToolColumnChoice",null),fr([o.decorators.func(),gr("design:type",Function),gr("design:paramtypes",[r.FileInfo]),gr("design:returntype",Promise)],Cr,"createMonomerLibraryForPolyTool",null),fr([o.decorators.func({meta:{icon:"img/icons/structure.png",browsePath:"Peptides | PolyTool",role:"app"},name:"HELM Enumerator",tags:["app"]}),gr("design:type",Function),gr("design:paramtypes",[]),gr("design:returntype",Promise)],Cr,"ptEnumeratorHelmApp",null),fr([o.decorators.func({meta:{icon:"img/icons/structure.png",browsePath:"Chem | PolyTool",role:"app"},name:"Chem Enumerator",tags:["app"],outputs:[{type:"view",name:"result"}]}),gr("design:type",Function),gr("design:paramtypes",[]),gr("design:returntype",Promise)],Cr,"ptEnumeratorChemApp",null),fr([o.decorators.func({name:"Polytool Helm Enumerator dialog"}),yr(0,o.decorators.param({type:"object",options:{nullable:!0}})),gr("design:type",Function),gr("design:paramtypes",[r.Cell]),gr("design:returntype",Promise)],Cr,"getPtHelmEnumeratorDialog",null),fr([o.decorators.func({name:"Polytool Chem Enumerator dialog"}),yr(0,o.decorators.param({type:"object",options:{nullable:!0}})),gr("design:type",Function),gr("design:paramtypes",[r.Cell]),gr("design:returntype",Promise)],Cr,"getPtChemEnumeratorDialog",null),fr([o.decorators.func({name:"Enumerate Single HELM Sequence",description:"Enumerate provided HELM sequence on provided positions with provided monomers and generates new table",outputs:[{type:"dataframe",name:"result"}]}),gr("design:type",Function),gr("design:paramtypes",[String,Array,Array,Boolean]),gr("design:returntype",Promise)],Cr,"enumerateSingleHelmSequence",null),fr([o.decorators.func({name:"Enumerate Single HELM Sequence with natural amino acids",description:'Enumerate provided HELM sequence on all positions with natural amino acids and generates new table. Generated table has sequence column called "Enumerated", and molecule column called "Molfile(Enumerated) if toAtomicLevel is set to true. Keywords: Optimize, enumerate, HELM optimization, Maximize Minimize property. When you want to optimize certain peptide using for example logS, set toAtomicLevel to true and use generated molecule column to calculate given property using chem package functions.',outputs:[{type:"dataframe",name:"result"}]}),gr("design:type",Function),gr("design:paramtypes",[String,Boolean]),gr("design:returntype",Promise)],Cr,"enumerateSingleHelmSequenceWithNaturalAAs",null),fr([o.decorators.func({name:"Combine Sequences","top-menu":"Bio | PolyTool | Combine Sequences..."}),gr("design:type",Function),gr("design:paramtypes",[]),gr("design:returntype",Promise)],Cr,"getPolyToolCombineDialog",null),fr([o.decorators.func({name:"oligoNucleotideCellRenderer",description:"Renders OligoNucleotide (siRNA / ASO) duplex view in grid cells",tags:["cellRenderer"],meta:{cellType:"OligoNucleotide",columnTags:"quality=OligoNucleotide",role:"cellRenderer"},outputs:[{type:"grid_cell_renderer",name:"result"}]}),gr("design:type",Function),gr("design:paramtypes",[]),gr("design:returntype",r.GridCellRenderer)],Cr,"oligoNucleotideCellRenderer",null),fr([o.decorators.func({name:"Oligo-Nucleotide",description:"Modifications, lengths, conjugates and color legend for an OligoNucleotide cell",tags:["panel","widgets"],outputs:[{type:"widget",name:"result"}]}),yr(0,o.decorators.param({type:"semantic_value",options:{semType:"OligoNucleotide"}})),gr("design:type",Function),gr("design:paramtypes",[r.SemanticValue]),gr("design:returntype",r.Widget)],Cr,"oligoNucleotidePanel",null),fr([o.decorators.func({name:"Oligo Structures",description:"Sense and antisense full molecular structures rendered separately",tags:["panel","widgets"],outputs:[{type:"widget",name:"result"}]}),yr(0,o.decorators.param({type:"semantic_value",options:{semType:"OligoNucleotide"}})),gr("design:type",Function),gr("design:paramtypes",[r.SemanticValue]),gr("design:returntype",r.Widget)],Cr,"oligoNucleotideStructuresPanel",null),fr([o.decorators.func({name:"convertHelmToOligoNucleotide",description:"Create a new column tagged as OligoNucleotide so HELM duplex cells render with the oligo view"}),yr(1,o.decorators.param({options:{caption:"HELM column",semType:"Macromolecule"}})),gr("design:type",Function),gr("design:paramtypes",[r.DataFrame,r.Column]),gr("design:returntype",Promise)],Cr,"convertHelmToOligoNucleotide",null),fr([o.decorators.func({name:"combineSenseAntisenseToOligoNucleotide",description:"Combine separate sense + antisense HELM columns into one OligoNucleotide column"}),yr(1,o.decorators.param({options:{caption:"Sense",semType:"Macromolecule"}})),yr(2,o.decorators.param({options:{caption:"Antisense",semType:"Macromolecule"}})),gr("design:type",Function),gr("design:paramtypes",[r.DataFrame,r.Column,r.Column]),gr("design:returntype",Promise)],Cr,"combineSenseAntisenseToOligoNucleotide",null),fr([o.decorators.func({name:"applyNotationProviderForHarmonizedSequence"}),yr(0,o.decorators.param({type:"column"})),gr("design:type",Function),gr("design:paramtypes",[r.Column,String]),gr("design:returntype",void 0)],Cr,"applyNotationProviderForCyclized",null),fr([o.decorators.func({name:"harmonizedSequenceNotationProviderConstructor",meta:{role:"notationProviderConstructor"}}),gr("design:type",Function),gr("design:paramtypes",[]),gr("design:returntype",Promise)],Cr,"harmonizedSequenceNotationProviderConstructor",null)},5412:(e,t,n)=>{"use strict";n.d(t,{m:()=>l});var o=n(6082),r=n(4328),i=n(4971),s=n(6077),a=n(2003);async function l(e,t,n,l,c,u,h,d,p){const m=(await p.helmToAtomicLevel(e,l,c,h)).molCol,f=n.filter((e=>e)).length;if(u&&f>0){const e=new Array(f);let l=0;for(let o=0;o<n.length;o++)n[o]&&(e[l]=t[o],l++);const c=o.Column.fromStrings("helm",e);c.semType=o.SEMTYPE.MACROMOLECULE,c.meta.units=a.Hi.HELM,c.setTag(o.TAGS.CELL_RENDERER,"helm");const u=(await(0,i.pj)()).getMonomerLib();try{const e=await(0,s.C4)(o.DataFrame.create(0),c,u,p,d);l=0;for(let t=0;t<n.length;t++)n[t]&&(m.set(t,e.molCol.get(l)),l++)}catch(e){r.shell.warning("PolyTool was not able to linearize sequences")}}return function(e){for(let t=0;t<e.length;t++)e.set(t,e.get(t).replaceAll("undefined","H")),e.set(t,e.get(t).replaceAll("Oh","O").replaceAll("OH","O")),e.set(t,e.get(t).replaceAll("0.000000 3","0.000000 0")),e.set(t,e.get(t).replaceAll("?","O")),e.set(t,e.get(t).replaceAll(" 0 3\n"," 0 0\n")),e.set(t,e.get(t).replaceAll("RGROUPS=(1 1)",""))}(m),m}},6307:(e,t,n)=>{"use strict";n.d(t,{s:()=>p});var o=n(2125),r=n(8438),i=n(6694);function s(e,t){let n="";for(let e=0;e<t.length;e++){e>0&&(n+="|"),n+=`PEPTIDE${e+1}{`;for(let o=0;o<t[e].length;o++){o>0&&(n+=".");const r=t[e][o];n+=r.length>1?`[${r}]`:r}n+="}"}n+="$";for(let r=0;r<e.length;r++)r>0&&(n+="|"),n+=`PEPTIDE${e[r].fChain+1},PEPTIDE${e[r].sChain+1},`,n+=`${(0,o.M)(e[r].fMonomer-1,t)[0]+1}:R${e[r].fR}-`,n+=`${(0,o.M)(e[r].sMonomer-1,t)[0]+1}:R${e[r].sR}`;return n+="$$$V2.0",n}function a(e,t,n,o=0,r=[],i=[]){let[s,a,l,c,u]=[!1,!1,!1,-1,-1];for(let h=0;h<e.length;h++)if(e[h].includes(t)){if(s){if(l&&(n||e[h]==i[o]+t)){a=!0,u=h;break}if(l||!n&&e[h]!=r[o]+t)continue;a=!0,u=h;break}if(n)s=!0,l=!0,c=h;else if(e[h]==r[o]+t)s=!0,l=!0,c=h;else{if(e[h]!=i[o]+t)continue;s=!0,l=!!n,c=h}}return[s,a,l,c,u]}function l(e,t){const n=[];for(let o=0;o<t.length;o++){const r=`(${t[o].code})`,[s,l]=(0,i.Ln)(t[o]);if(s.length>0)for(let t=0;t<s.length;t++){const[i,c,u,h,d]=a(e,r,!1,t,s,l);i&&c&&(u?n.push({firstIdx:h,secondIdx:d,ruleIdx:o}):n.push({firstIdx:d,secondIdx:h,ruleIdx:o}))}else{const[t,i,s,l,c]=a(e,r,!0);if(!t||!i)continue;s?n.push({firstIdx:l,secondIdx:c,ruleIdx:o}):n.push({firstIdx:c,secondIdx:l,ruleIdx:o})}}return n}function c(e,t,n){const o=[],r=[],i=[],s=[],a=n.length;for(let l=0;l<a;l++){if(-1==n[l].firstIdx)continue;const a=n[l].ruleIdx,c=e[a].code;t[n[l].firstIdx]=t[n[l].firstIdx].replace(`(${c})`,""),t[n[l].secondIdx]=t[n[l].secondIdx].replace(`(${c})`,""),o.push(n[l].firstIdx+1),r.push(n[l].secondIdx+1),i.push(e[a].firstLinkingGroup),s.push(e[a].secondLinkingGroup)}return[o,r,i,s]}function u(e,t,n){const o=[],r=[],i=[],s=n.length;for(let a=0;a<s;a++){if(-1==n[a].firstIdx)continue;const s=n[a].firstIdx,l=n[a].secondIdx,c=n[a].ruleIdx,u=e[c].code;t[s]=t[s].replace(`(${u})`,"")+`_${e[c].name}`,t[l]=t[l].replace(`(${u})`,"")+`_${e[c].name}`,o.push(s+1),r.push(l+1),i.push(n[a].ruleIdx)}return[o,r,i]}var h=n(3599);function d(e,t,n){const o=n.createHelmWebEditor().editor.m;let r=0;const i=new JSDraw2.Point(0,0);for(let e=0;e<t.length;e++)for(let n=0;n<t[e].length;n++){if(t[e][n]){const s=t[e][n],a={type:h.o.AA,i:e,j:n,continuousId:r},l=new JSDraw2.Atom(i,s,a);if(o.addAtom(l),0!==n){const e=o.atoms[r-1],t=o.atoms[r],n=new JSDraw2.Bond(e,t);n.r1=2,n.r2=1,o.addBond(n)}r++,i.x+=JSDraw2.Editor.BONDLENGTH}i.y+=4*JSDraw2.Editor.BONDLENGTH}for(let t=0;t<e.length;t++){const n=o.atoms[e[t].fMonomer-1],r=o.atoms[e[t].sMonomer-1],i=new JSDraw2.Bond(n,r);i.r1=e[t].fR,i.r2=e[t].sR,o.addBond(i)}return o}class p{constructor(e,t,n){this.helmHelper=n,this.underRules=!1,this.posToPosUnderRules=[],this.linkages=t,this.monomers=e,this.mol=d(t,e,n)}static fromSeparator(e,t){const[n,o]=function(e){const t=[],n=[],o=/(\(.\d+\))?\{[^\}]*\}/g,r=[];r.push(e.replaceAll(o,""));const i=e.matchAll(o);for(const e of i){const t=e[0];t&&r.push(t)}let s=0;for(let e=0;e<r.length;e++){const o=r[e].split("-"),i=new Array(o.length);let a=0;for(let t=0;t<o.length;t++){const r=o[t].replace("{","").replace("}","");""!==r?(i[t]=r,s++,a++):n.push({fChain:e,sChain:e+1,fMonomer:s,sMonomer:s+1,fR:1,sR:1})}t.push(i.slice(0,a))}return[n,t]}(e);return new p(o,n,t)}static fromHelm(e,t){const[n,i]=function(e){const t=/(\w+\{.*\})\$(.*)\$(.*)\$(.*)\$/g.exec(e),n=[t[1],t[2],t[3],t[4]],i=n[0].split("|"),s=n[1].split("|"),a=new Array(i.length),l=[];for(let e=0;e<i.length;e++){const t=i[e].indexOf("{"),n=i[e].indexOf("}");a[e]=i[e].slice(t+1,n).split(".").map((e=>(0,r.D)(e)))}for(let e=0;e<s.length;e++)if(""!==s[e]&&"V2.0"!==s[e]){const t=s[e].split(","),n=parseInt(t[0].replace("PEPTIDE",""))-1,r=parseInt(t[1].replace("PEPTIDE",""))-1,i=t[2].split("-"),c=i[0].split(":"),u=i[1].split(":");l.push({fChain:n,sChain:r,fMonomer:(0,o.j)(parseInt(c[0]),n,a),sMonomer:(0,o.j)(parseInt(u[0]),r,a),fR:parseInt(c[1].replace("R","")),sR:parseInt(u[1].replace("R",""))})}return[l,a]}(e);return new p(i,n,t)}getNotation(){return function(e){const t=e.atoms,n=e.bonds,o=[],r=[];for(let e=0;e<n.length;e++)n[e].a1.bio.i!==n[e].a2.bio.i&&r.push(e);for(let e=0;e<t.length;e++){const n=t[e].bio?.i;n+1>o.length?o.push(1):o[n]++}const i=new Array(o.length);let s=0;for(let e=0;e<o.length;e++){const n=new Array(o[e]);for(let r=0;r<o[e];r++)n[r]=t[s].elem,s++;i[e]=n}let a="";for(let e=0;e<i.length;e++){let t="";for(let n=0;n<i[e].length;n++)t+=`${0==n?"":"-"}${i[e][n]}`;if(0!==e){const e=/(\(.\d+\))/,n=t.match(e);t=t.replace(n?.[0],""),t=`${n?n?.[0]:""}{${t}}`}else if(i.length>1){const e=0==n[r[0]].a1.bio.i&&0==n[r[0]].a1.bio.j,o=1==n[r[0]].a2.bio.i&&0==n[r[0]].a1.bio.j;e&&o&&(t+="-")}a+=t}return a}(this.mol)}getHelm(){return this.underRules?s(this.linkagesUnderRules,this.monomersUnderRules):s(this.linkages,this.monomers)}applyRules(e){const t=this.getNotation(),[n,o,r]=function(e,t){const n=[],o=[],r=[],i=t.heterodimerCode,s=t.homodimerCode,a=null!==i?e.split(`(${t.heterodimerCode})`):"";null!==i&&a.length>1?(r.push({fChain:0,sChain:1,fMonomer:1,sMonomer:1,fR:1,sR:1}),n.push(a[1].replaceAll("{","").replaceAll("}","")),n.push(a[2].replaceAll("{","").replaceAll("}","")),o.push(!1),o.push(!1)):(n.push(e),o.push(!1));for(let e=0;e<n.length;e++)if(null!==s&&n[e].includes(`(${s})`)){const t=n.length;r.push({fChain:e,sChain:t,fMonomer:1,sMonomer:1,fR:1,sR:1});const i=n[e].replace(`(${s})`,""),a=i.indexOf("{"),l=i.slice(0,a),c=i.replace(l,"").replaceAll("{","").replaceAll("}","");n[e]=l+c,n.push(c),o.push(!0)}return[r,n,o]}(t,e),i=new Array(o.length);let s=0;for(let e=0;e<o.length;e++)if(i[e]=o[e].split("-"),r[e]){const t=this.posToPosUnderRules.length-i[e].length;for(let n=0;n<i[e].length;n++)this.posToPosUnderRules[t+n].push(s),s++}else for(let t=0;t<i[e].length;t++)this.posToPosUnderRules.push([s]),s++;!function(e,t,n){for(let o=0;o<e.length;o++){const r=e[o],i=l(r,n.linkRules),[s,a,u,h]=c(n.linkRules,r,i);for(let e=0;e<s.length;e++)t.push({fChain:o,sChain:o,fMonomer:s[e],sMonomer:a[e],fR:u[e],sR:h[e]});e[o]=r}}(i,n,e),function(e,t,n){for(let o=0;o<e.length;o++){const r=l(e[o],n.reactionRules),[i,s,a]=u(n.reactionRules,e[o],r);i.length>=1&&(t.push({fChain:o,sChain:e.length,fMonomer:i[0],sMonomer:1,fR:3,sR:1}),t.push({fChain:o,sChain:e.length,fMonomer:s[0],sMonomer:1,fR:3,sR:2}),e.push([n.reactionRules[a[0]].name]))}}(i,n,e),this.underRules=!0,this.linkagesUnderRules=n,this.monomersUnderRules=i,this.molUnderRules=d(n,i,this.helmHelper)}check(e=!1){const t=[],n=this.monomers.map((e=>e.length)).reduce(((e,t)=>e+t),0);this.mol.atoms.length!==n&&t.push(`The mol atoms count ${this.mol.atoms.length} does not match the total number ${n} of chains' monomers.`);const o=this.monomers.map((e=>e.length-1)).reduce(((e,t)=>e+t),0)+this.linkages.length;this.mol.bonds.length!==o&&t.push(`The mol bonds count ${this.mol.bonds.length} does not match the total number ${o} in- and inter-chain linkages.`);let r=0;for(let e=0;e<this.monomers.length;++e){const n=this.monomers[e];for(let e=0;e<n.length;++e)try{const o=n[e],i=this.mol.atoms[r];i.bio.continuousId!==r&&t.push(`Atom #${r} has incorrect .bio.continuousId: ${i.bio.continuousId}.`),i.elem!==o&&t.push(`Atom #${r} elem: '${i.elem}' does not match chain monomer: '${o}'.`)}finally{r++}}if(e&&t.length>0)throw new Error(`Chain errors:\n${t.map((e=>` ${e}`)).join("\n")}`);return t}}},4229:(e,t,n)=>{"use strict";n.d(t,{b:()=>s});var o=n(9192),r=n(6307),i=n(9022);function s(e,t,n){const s=new Array(e.length),a=new Array(e.length),l=new Array(e.length);for(let c=0;c<e.length;c++)try{if(null==e[c])s[c]="";else{const o=r.s.fromSeparator(e[c],n);o.applyRules(t),a[c]=!(o.monomersUnderRules.length>1||o.linkagesUnderRules.length>0),s[c]=o.getHelm(),l[c]=o.posToPosUnderRules}}catch(e){const[t,n]=(0,o.AP)(e);i._package.logger.error(t,void 0,n),s[c]=""}return[s,a,l]}},2125:(e,t,n)=>{"use strict";function o(e,t){let n,o=e;for(n=0;n<t.length&&o>=t[n].length;++n)o-=t[n].length;return[o,n]}function r(e,t,n){let o=0;for(let e=0;e<t;++e)o+=n[e].length;return o+e}n.d(t,{M:()=>o,j:()=>r})},6694:(e,t,n)=>{"use strict";n.d(t,{MU:()=>V,yy:()=>j,_v:()=>J,Ln:()=>te,Q4:()=>ee});var o=n(6082),r=n(4328),i=n(7389),s=n(1991),a=n.n(s),l=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function s(e){try{l(o.next(e))}catch(e){i(e)}}function a(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}l((o=o.apply(e,t||[])).next())}))};class c{constructor(e,t,n=".csv",o){this.path=e,this.userStorageName=t,this.ext=n,this.options=o,this.inputs=null,"/"!==this.path[this.path.length-1]&&(this.path+="/"),"."!==this.ext[0]&&(this.ext="."+this.ext)}getUserSettings(){return l(this,void 0,void 0,(function*(){if(this.settings)return this.settings;const e=r.userSettings.getValue(this.userStorageName,"Settings"),t=e?JSON.parse(e):{excluded:[],explicit:[]};return t.explicit=t.explicit instanceof Array?t.explicit:[],t.excluded=t.excluded instanceof Array?t.excluded:[],this.settings=t}))}setUserSettings(e){this.settings=e,r.userSettings.add(this.userStorageName,"Settings",JSON.stringify(e))}getAllAvailable(){return l(this,void 0,void 0,(function*(){return(yield r.dapi.files.list(this.path)).map((e=>e.fullPath.replace(`${this.path}`,"")))}))}getActive(){return l(this,void 0,void 0,(function*(){const e=yield this.getUserSettings();return e.explicit.length>0?e.explicit:(yield this.getAllAvailable()).filter((t=>!e.excluded.includes(t)))}))}setActive(e){const t=new Set(e);for(const[e,n]of this.inputs.entries())n.value=t.has(e)}createInput(e,t){const n=i.input.bool(e,{value:t,onValueChanged:t=>this.updateSelectionStatus(e,t)});return n.addOptions(i.button(i.iconFA("trash"),(()=>{i.dialog({title:"Warning"}).add(i.divText(`Delete file '${e}'?`)).onOK((()=>{n.root.remove(),this.availableRemove(e)})).show()}),`Delete ${e}`)),n}getInputs(){return l(this,void 0,void 0,(function*(){this.inputs=new Map;const e=yield this.getAllAvailable(),t=yield this.getActive(),n=new Array(e.length);for(let o=0;o<e.length;o++){const r=t.includes(e[o]);n[o]=this.createInput(e[o],r),this.inputs.set(e[o],n[o])}return this.fireOnValueChanged(),n}))}getForm(){return l(this,void 0,void 0,(function*(){const e=yield this.getInputs(),t=i.divV(e);return i.divV([t,i.button("ADD",(()=>l(this,void 0,void 0,(function*(){let e="";if(e=yield this.getNewAvailable(),""!==e){const n=this.createInput(e,!0);t.append(n.root),this.inputs.set(e,n),this.fireOnValueChanged()}}))))])}))}fireOnValueChanged(){var e;null===(e=this.options)||void 0===e||e.onValueChanged(a()(this.inputs.entries()).filter((([e,t])=>t.value)).map((([e,t])=>e)).toArray())}updateSelectionStatus(e,t){return l(this,void 0,void 0,(function*(){const n=yield this.getUserSettings();if(!n.excluded.includes(e)!==t){if(t){const t=n.excluded.indexOf(e);t>-1&&n.excluded.splice(t,1)}else n.excluded.push(e);this.fireOnValueChanged(),this.setUserSettings(n)}}))}availableRemove(e){return l(this,void 0,void 0,(function*(){this.inputs.delete(e),this.fireOnValueChanged();const t=yield this.getUserSettings(),n=t.excluded.indexOf(e);n>-1&&t.excluded.splice(n,1),this.setUserSettings(t),yield r.dapi.files.delete(this.path+e),r.shell.info(`File ${e} successfully deleted`)}))}getNewAvailable(){return l(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{o.Utils.openFile({accept:this.ext,open:t=>l(this,void 0,void 0,(function*(){const n=t.name,o=yield t.arrayBuffer();yield r.dapi.files.write(this.path+`${t.name}`,new Uint8Array(o)),e(n)}))})}))}))}}var u=n(9022),h=n(9124),d=n(4229),p=n(439),m=n(5174),f=n(5412),g=n(6717),y=n(8312);function b(e){let t=e.replaceAll(/\[R[1-9]\]/g,(e=>`[*:${e[2]}]`));return t=t.replaceAll(/\[\d\*\]/g,(e=>`[*:${e[1]}]`)),t.replaceAll(/\[\d\*\:\d\]/g,(e=>`[*:${e[1]}]`))}function v(e){return e.replaceAll(/\[\*\:\d\]/g,(e=>`[C:${e[3]}]`))}function C(e){return e.replaceAll(/\[C\:\d\]/g,(e=>`[*:${e[3]}]`))}function x(e,t){const n=t?.firstReactantSmiles?C(t.firstReactantSmiles):"[*:1]C",o=t?.secondReactantSmiles?C(t.secondReactantSmiles):"[*:2]C",s=t?.productSmiles?C(t.productSmiles):"[*:1]CC[*:2]",a=t?.code,l=t?.firstMonomers??[],c=t?.secondMonomers??[],u=t?.resultMonomerName??"",h=i.input.int("Code",{value:a,nullable:!1,showPlusMinus:!1,showSlider:!1,tooltipText:"Reaction code"}),d=i.input.string("First monomers",{value:l.join(","),nullable:!1,tooltipText:"Comma-separated list of monomers for the first reactant"}),p=i.input.string("Second monomers",{value:c.join(","),nullable:!1,tooltipText:"Comma-separated list of monomers for the second reactant"}),m=i.input.string("Result monomer name",{value:u,nullable:!1,tooltipText:"Name of the resulting pseudo-monomer generated by the reaction of the two reactants"}),f=i.input.molecule("First reactant",{value:n,nullable:!1,tooltipText:"Reactant fragment of first monomer(s). Use numbered R groups in correspondence with the rest of the molecule."}),g=i.input.molecule("Second reactant",{value:o,nullable:!1,tooltipText:"Reactant fragment of second monomer(s). Use numbered R groups in correspondence with the rest of the molecule."}),y=i.input.molecule("Product",{value:s,nullable:!1,tooltipText:"Product fragment of the resulting monomer from the reaction of the two reactants. Use numbered R groups in correspondence with the reactants."}),x=()=>{if(!f||!g||!y)return"Inputs not initialized yet";const e=v(b(r.chem.convert(f.value??"",r.chem.Notation.Unknown,r.chem.Notation.Smiles))),t=v(b(r.chem.convert(g.value??"",r.chem.Notation.Unknown,r.chem.Notation.Smiles))),n=v(b(r.chem.convert(y.value??"",r.chem.Notation.Unknown,r.chem.Notation.Smiles)));return e&&t&&n?-1==e.indexOf("[C:1]")?"First Reactant must contain R1-group":-1==t.indexOf("[C:2]")?"Second Reactant must contain R2-group":-1==n.indexOf("[C:1]")||-1==n.indexOf("[C:2]")?"Product must contain R1- and R2-groups":null:"First/Second Reactants and Product must all be set"};f.addValidator(x),g.addValidator(x),y.addValidator(x);const w=i.dialog(t?"Edit Reaction Rule":"Add Reaction Rule").add(h).add(m).add(d).add(p).add(f).add(g).add(y);w.addButton("Save",(()=>{const n=x();if(null!=n)return void r.shell.warning(n);const o=v(b(r.chem.convert(f.value??"",r.chem.Notation.Unknown,r.chem.Notation.Smiles))),i=v(b(r.chem.convert(g.value??"",r.chem.Notation.Unknown,r.chem.Notation.Smiles))),s=v(b(r.chem.convert(y.value??"",r.chem.Notation.Unknown,r.chem.Notation.Smiles)));e({code:h.value,resultMonomerName:m.value,firstMonomers:d.value.split(",").map((e=>e.trim())).filter((e=>e.length>0)),secondMonomers:p.value.split(",").map((e=>e.trim())).filter((e=>e.length>0)),firstReactantSmiles:o,secondReactantSmiles:i,productSmiles:s,rowIndex:t?.rowIndex}),w.close()})),w.show()}const w="Links",A="Reactions";class T{constructor(e,t){this.v=null,this.substituteReactionGridDataFrame=null,this.rules=e;const n=this.rules.getLinkRulesDf();this.linkRuleDataFrame=n.res,this.addLinkRulesFunc=n.addNewRow;const o=this.rules.getSynthesisRulesDf();this.addSynthRulesFunc=e=>{o.addNewRow(e),this.rules.setSynthesisRules(o.df),this.synthRuleDataFrame=o.df,this.substituteReactionGridDataFrame?.(),this.save()},this.synthRuleDataFrame=o.df,this.fileName=t;const r=this.rules.homodimerCode?this.rules.homodimerCode:"",s=this.rules.heterodimerCode?this.rules.heterodimerCode:"";this.homoDimerInput=i.input.string("Homo dimer",{value:r,onValueChanged:()=>{},nullable:!1}),this.heteroDimerInput=i.input.string("Hetero dimer",{value:s,onValueChanged:()=>{},nullable:!1})}async getAndAddView(){if(this.v)try{const e=Array.from(r.shell.views).find((e=>e.name===this.v.name));if(!e)throw this.v.detach(),this.v.close(),new Error("View is closed, making it null in catch statement");r.shell.v=e}catch(e){this.v=null}return this.v||(this.v=o.View.create(),this.v.name=`Manage Polytool Rules - ${this.fileName}`,this.v.append(await this.getForm()),this.v=r.shell.addView(this.v),r.shell.v=this.v),this.v}static async getInstance(e){if(!this.instances[e]){const t=await ee([e]);this.instances[e]=new T(t,e)}return this.instances[e]}save(){this.rules.homodimerCode=this.homoDimerInput.value,this.rules.heterodimerCode=this.heteroDimerInput.value,this.rules.setLinkRules(this.linkRuleDataFrame),this.rules.setSynthesisRules(this.synthRuleDataFrame);const e={homodimerCode:this.rules.homodimerCode,heterodimerCode:this.rules.heterodimerCode,linkRules:this.rules.linkRules,reactionRules:this.rules.reactionRules},t=JSON.stringify(e,void 0,2);u._package.files.writeAsText(`polytool-rules/${this.fileName}`,t),r.shell.info(`Polytool rules at ${this.fileName} was updated`)}createGridDiv(e,t,n){const o=i.h1(e,"polytool-grid-header");i.tooltip.bind(o,n),o.style.marginTop="10px",o.style.marginRight="10px",t.root.style.height="100%";const r=i.splitV([i.box(o,{style:{maxHeight:"60px"}}),t.root]);return r.style.height="100%",r}async getLinkExamplesGrid(){const e=[];for(let t=0;t<this.rules.linkRules.length;t++){const n=this.rules.linkRules[t].code,[o,r]=te(this.rules.linkRules[t]);for(let t=0;t<o.length;t++){const i=`${o[t]}(${n})-A-A-A-A-${r[t]}(${n})`;e.push(i)}}const t=await(0,h.b2)(),[n,r,i]=(0,d.b)(e,this.rules,t),s=o.Column.fromStrings("Monomers",e),a=o.Column.fromStrings("Helm",n);return u.PackageFunctions.applyNotationProviderForCyclized(s,"-"),s.semType=o.SEMTYPE.MACROMOLECULE,a.semType=o.SEMTYPE.MACROMOLECULE,a.meta.units=p.Hi.HELM,a.setTag(o.TAGS.CELL_RENDERER,"helm"),o.DataFrame.fromColumns([s,a]).plot.grid()}async getReactionExamplesGrid(){const e=[];for(let t=0;t<this.rules.reactionRules.length;t++){const n=this.rules.reactionRules[t].code,[o,r]=te(this.rules.reactionRules[t]);for(let t=0;t<o.length;t++){const i=`${o[t]}(${n})-A-A-A-A-${r[t]}(${n})`;e.push(i)}}const t=await(0,h.b2)(),[n,r,i]=(0,d.b)(e,this.rules,t),s=o.Column.fromStrings("Monomers",e),a=o.Column.fromStrings("Helm",n),l=o.DataFrame.fromColumns([s,a]);s.semType=o.SEMTYPE.MACROMOLECULE;const c=await(0,g.j)(),b=await(0,y.Q)();u.PackageFunctions.applyNotationProviderForCyclized(s,"-"),s.tags[o.TAGS.CELL_RENDERER]="Sequence",a.semType=o.SEMTYPE.MACROMOLECULE,a.meta.units=p.Hi.HELM,a.setTag(o.TAGS.CELL_RENDERER,"helm");const v=await(0,m.A)(this.rules),C=a.temp;C[".mm.cellRenderer.overriddenLibrary"]=v,a.temp=C;const x=await(0,f.m)(a,e,r,!0,!1,!1,v,c,b);return x.name="molfile(sequence)",x.semType=o.SEMTYPE.MOLECULE,l.columns.add(x),l.plot.grid()}async getForm(){const e=this.linkRuleDataFrame.plot.grid({showAddNewRowIcon:!1,allowEdit:!1,rowHeight:60});e.onCellDoubleClick.subscribe((()=>{if(!e.dataFrame||-1==e.dataFrame.currentRowIdx||null==e.dataFrame.currentRowIdx)return;const t=e.dataFrame.currentRowIdx,n={row:t,code:this.linkRuleDataFrame.get("code",t),firstMonomers:this.linkRuleDataFrame.get("firstMonomers",t),secondMonomers:this.linkRuleDataFrame.get("secondMonomers",t),firstLinkingGroup:this.linkRuleDataFrame.get("firstLinkingGroup",t),secondLinkingGroup:this.linkRuleDataFrame.get("secondLinkingGroup",t)};this.getAddNewLinkRuleDialog(n)}));const t=this.createGridDiv("Rules",e,"specification for monomers to link and linking positions"),n=this.createGridDiv("Examples",await this.getLinkExamplesGrid(),"specification for monomers to link and linking positions");t.style.width="50%",n.style.width="50%";const o=i.h1("Monomers","polytool-grid-header");i.tooltip.bind(o,"Click different cobination to see how monomers will link"),this.linkCards=await this.rules.getLinkCards();const r=i.splitV([i.box(o,{style:{maxHeight:"30px"}}),this.linkCards[0].root]);this.linkCards[0].render(),await this.linkCards[0].reset(),this.linkRuleDataFrame.currentRowIdx=0,this.linkRuleDataFrame.onCurrentRowChanged.subscribe((async()=>{const e=this.linkRuleDataFrame.currentRowIdx;-1!==e&&null!=e&&(i.empty(r),r.append(i.splitV([i.box(o,{style:{maxHeight:"30px"}}),this.linkCards[e].root])),this.linkCards[e].render(),await this.linkCards[e].reset())}));const s=i.splitH([t,r],null,!0),a=this.synthRuleDataFrame.plot.grid({showAddNewRowIcon:!1,allowEdit:!1,rowHeight:130});a.onCellDoubleClick.subscribe((()=>{if(!a.dataFrame||-1==a.dataFrame.currentRowIdx||null==a.dataFrame.currentRowIdx)return;const e=a.dataFrame.currentRowIdx;x((e=>this.addSynthRulesFunc(e)),{rowIndex:e,code:this.synthRuleDataFrame.get("code",e),firstMonomers:this.synthRuleDataFrame.get("firstMonomers",e).split(",").map((e=>e.trim())).filter((e=>e)),secondMonomers:this.synthRuleDataFrame.get("secondMonomers",e).split(",").map((e=>e.trim())).filter((e=>e)),resultMonomerName:this.synthRuleDataFrame.get("name",e),firstReactantSmiles:this.synthRuleDataFrame.get("firstReactant",e),secondReactantSmiles:this.synthRuleDataFrame.get("secondReactant",e),productSmiles:this.synthRuleDataFrame.get("product",e)})}));const l=this.createGridDiv("Rules",a),c=await this.getReactionExamplesGrid(),u=this.createGridDiv("Examples",c);this.substituteReactionGridDataFrame=async()=>{const e=await this.getReactionExamplesGrid();c.dataFrame=e.dataFrame},l.style.width="50%",u.style.width="50%";const h=i.divH([l,u]),d=i.divV([this.homoDimerInput,this.heteroDimerInput]),p=i.tabControl({Links:s,Reactions:h,Dimers:d},!1);i.tooltip.bind(p.getPane(w).header,"Specify rules to link monomers based on HELM notation"),i.tooltip.bind(p.getPane(A).header,"Specify rules to perform reactions within monomers"),i.tooltip.bind(p.getPane("Dimers").header,"Specify symbols for homodimeric and heterodimeric codes"),p.root.style.height="100%",p.root.style.width="100%",p.root.classList.add("rules-manager-form-tab-control"),p.header.style.marginBottom="10px";const m=i.divV([p.root]),f=[i.bigButton("Save",(()=>{this.save()})),i.button("Add rule",(()=>{const e=p.currentPane.name;e==w?this.getAddNewLinkRuleDialog():e==A&&x((e=>this.addSynthRulesFunc(e)))})),i.button("Remove rule",(()=>{const t=p.currentPane.name;if(t==w){if(null==this.linkRuleDataFrame||-1==this.linkRuleDataFrame.currentRowIdx||null==this.linkRuleDataFrame.currentRowIdx)return;const t=e.dataFrame.currentRowIdx;i.dialog("Are you sure you want to remove the rule?").add(i.divText("This action is irreversible!")).onOK((()=>{this.linkRuleDataFrame.rows.removeAt(t),this.rules.setLinkRules(this.linkRuleDataFrame),this.save()})).show()}else if(t==A){if(null==this.synthRuleDataFrame||-1==this.synthRuleDataFrame.currentRowIdx||null==this.synthRuleDataFrame.currentRowIdx)return;const e=a.dataFrame.currentRowIdx;i.dialog("Are you sure you want to remove the rule?").add(i.divText("This action is irreversible!")).onOK((()=>{this.synthRuleDataFrame.rows.removeAt(e),this.rules.setSynthesisRules(this.synthRuleDataFrame),this.substituteReactionGridDataFrame?.(),this.save()})).show()}}))];return this.v.setRibbonPanels([f]),m.style.height="100%",m.style.alignItems="center",p.root}getAddNewLinkRuleDialog(e){const t=i.input.int("Code",{nullable:!1,value:e?.code}),n=i.input.string("First monomers",{placeholder:"E.g. C,D,E",value:e?.firstMonomers,tooltipText:"Comma separated list of first monomers applicable for the rule. If left empty, all monomers will be considered",nullable:!0}),o=i.input.string("Second monomers",{placeholder:"E.g. C,D,E",value:e?.secondMonomers,tooltipText:"Comma separated list of second monomers applicable for the rule. If left empty, all monomers will be considered",nullable:!0}),r=e?.firstLinkingGroup?`R${e.firstLinkingGroup}`:"R3",s=e?.secondLinkingGroup?`R${e.secondLinkingGroup}`:"R3",a=i.input.choice("First linking group",{value:r,items:["R1","R2","R3","R4"],tooltipText:"Specifies which R-group of the first monomer will be used for linking",nullable:!1}),l=i.input.choice("Second linking group",{value:s,items:["R1","R2","R3","R4"],tooltipText:"Specifies which R-group of the second monomer will be used for linking",nullable:!1});i.dialog("Add new link rule").add(t).add(n).add(o).add(a).add(l).onOK((async()=>{const r=t.value,i=(n.value??"").split(",").map((e=>e.trim())).filter((e=>e)).join(","),s=(o.value??"").split(",").map((e=>e.trim())).filter((e=>e)).join(","),c=parseInt(a.value.substring(1)),u=parseInt(l.value.substring(1));this.addLinkRulesFunc({code:r,firstMonomers:i??"",secondMonomers:s??"",firstLinkingGroup:c,secondLinkingGroup:u,row:e?.row}),this.rules.setLinkRules(this.linkRuleDataFrame),this.linkCards=await this.rules.getLinkCards(),this.save()})).show()}}T.instances={};var E=n(5072),S=n.n(E),N=n(7825),I=n.n(N),M=n(7659),P=n.n(M),_=n(5056),L=n.n(_),O=n(540),R=n.n(O),$=n(1113),D=n.n($),B=n(890),F={};F.styleTagTransform=D(),F.setAttributes=L(),F.insert=P().bind(null,"head"),F.domAPI=I(),F.insertStyleElement=R(),S()(B.A,F),B.A&&B.A.locals&&B.A.locals;var k=n(2003);class H{get selected(){return this._selected}set selected(e){this._selected=e,this.root.style.border=e?"2px solid var(--green-2)":"2px solid var(--grey-2)"}constructor(e,t){this.monomer=e,this.monomerSymbol=t,this.root=i.divV([],{classes:"monomer-card-rule-root"}),this._selected=!1}render(){if(i.empty(this.root),this.root.appendChild(i.h2(this.monomerSymbol,{style:{textAlign:"center"}})),this.monomer){const e=this.monomer.smiles&&r.chem.checkSmiles(this.monomer.smiles)?r.chem.drawMolecule(this.monomer.smiles,150,120):r.chem.drawMolecule(this.monomer.molfile??"",150,120);this.root.appendChild(e);const t=i.divH([i.divText("Monomer Name: "),i.divText(this.monomer.name)],{classes:"monomer-card-info-rules"});if(this.root.appendChild(t),i.tooltip.bind(t,this.monomer.name),this.monomer.lib?.source){const e=i.divH([i.divText("Source: "),i.divText(this.monomer.lib.source)],{classes:"monomer-card-info-rules"});this.root.appendChild(e),i.tooltip.bind(e,this.monomer.lib.source)}const n=i.divH([i.divText("Polymer Type: "),i.divText(this.monomer.polymerType)],{classes:"monomer-card-info-rules"});this.root.appendChild(n),i.tooltip.bind(n,this.monomer.polymerType),i.tooltip.bind(this.root,"Select Monomer")}else this.root.appendChild(i.divV([`Monomer ${this.monomerSymbol} not found in libraries`],{style:{textAlign:"center",height:"100%"}}))}}class G{constructor(e,t,n,o,r){this.firstMonomers=e,this.secondMonomers=t,this.code=o,this.rules=r,this.root=i.divH([],{style:{width:"100%",overflow:"hidden",visibility:"visible"},classes:"monomer-cards"});const s=!e?.length,a=!t?.length;s&&(this.firstMonomers=e=["C","D","E","F","G"]),a&&(this.secondMonomers=t=["D","C","E","F","G"]),this.actionable=!0;const l=i.divH([],{style:{overflowX:"auto",width:"100%"}}),c=i.divH([],{style:{overflowX:"auto",width:"100%"}});this.resulting=i.divH([],{style:{overflowX:"auto",width:"100%",minHeight:"150px"}});const u=i.h2("First Monomer"+(s?" (Applied to all monomers, example list shown)":""),{style:{width:"100%"}}),h=i.h2("Second Monomer"+(a?" (Applied to all monomers, example list shown)":""),{style:{width:"100%"}}),d=i.divV([u,l,h,c,this.resulting]);this.cardsFirst=e.map((e=>new H(n.getMonomer("PEPTIDE",e),e))),this.cardsSecond=t.map((e=>new H(n.getMonomer("PEPTIDE",e),e))),this.cardsFirst.forEach((e=>{e.root.onclick=()=>{this.cardsFirst.forEach((e=>e.selected=!1)),e.selected=!0,this.firstCard=e,this.reset()},l.appendChild(e.root)})),this.cardsSecond.forEach((e=>{e.root.onclick=()=>{this.cardsSecond.forEach((e=>e.selected=!1)),e.selected=!0,this.secondCard=e,this.reset()},c.appendChild(e.root)})),this.cardsFirst[0].selected=!0,this.cardsSecond[0].selected=!0,this.firstCard=this.cardsFirst[0],this.secondCard=this.cardsSecond[0],this.root.appendChild(d)}async reset(){if(this.actionable){const e=[`${this.firstCard.monomer?.symbol}(${this.code})-A-A-A-A-${this.secondCard.monomer?.symbol}(${this.code})`],t=await(0,h.b2)(),[n,s,a]=(0,d.b)(e,this.rules,t),l=o.Column.fromType(o.COLUMN_TYPE.STRING,"helm",n.length).init((e=>n[e]));l.semType=o.SEMTYPE.MACROMOLECULE,l.meta.units=k.Hi.HELM,l.setTag(o.TAGS.CELL_RENDERER,"helm");const c=await(0,g.j)(),u=await(0,y.Q)(),p=await(0,m.A)(this.rules),b=l.temp;l.temp=b;const v=(await(0,f.m)(l,n,s,!0,!1,!1,p,c,u)).get(0),C=v&&r.chem.checkSmiles(v)?r.chem.drawMolecule(v,200,200):r.chem.drawMolecule(v??"",200,200);v&&(C.style.cursor="pointer",C.onclick=()=>{const e=window.innerWidth-200,t=window.innerHeight-200,n=r.chem.checkSmiles(v)?r.chem.drawMolecule(v,e,t):r.chem.drawMolecule(v??"",e,t);i.dialog({title:"Molecule"}).add(n).showModal(!0)},i.tooltip.bind(C,"Click to expand"));const x=i.divV([i.h2("Example Result:"),i.h2(e[0])],{style:{width:"200px"}});i.empty(this.resulting),this.resulting.append(i.divH([x,C],{style:{overflowX:"auto",width:"100%",minHeight:"150px"}}))}}render(){this.actionable&&(this.cardsFirst.forEach((e=>e.render())),this.cardsSecond.forEach((e=>e.render())))}}var U=n(4971);const V="System:AppData/SequenceTranslator/polytool-rules/",j="Polytool",q="code",W="firstMonomers",z="secondMonomers",Y="name",K="firstLinkingGroup",Q="secondLinkingGroup";class J extends c{constructor(e,t,n,o){super(e,t,n,o)}createInput(e,t){const n=super.createInput(e,t),r=i.icons.edit((async()=>{const t=await T.getInstance(e);o.Dialog.getOpenDialogs()?.filter((e=>e.root.contains(r))).forEach((e=>e.close())),await t.getAndAddView()}),"Edit rules");return n.addOptions(r),n}async getForm(){const e=await super.getForm();return this.processRulesForm(e),e}async processRulesForm(e){const t=Array.from(e.getElementsByTagName("label")??[]).filter((e=>e.textContent?.endsWith(".json")&&null!=e.parentElement));for(const e of t){const t=e.textContent.trim(),n=e.parentElement.getElementsByTagName("input")[0];i.tooltip.bind(n,i.wait((async()=>{var e;return(e=J.ruleDescriptions)[t]??(e[t]=(async()=>{try{const e=JSON.parse(await r.dapi.files.readAsText(`${V}/${t}`)),n=i.divV([i.h1(t)]),o=e.linkRules??[];if(o.length>0){n.appendChild(i.h3("Linkage Rules"));const e=i.table(o,(e=>[e.code?.toString()??"",X((e.firstMonomers??[]).join(", ")),X((e.secondMonomers??[]).join(", ")),e.firstLinkingGroup?.toString()??"",e.secondLinkingGroup?.toString()??""]),["Code","M1","M2","L1","L2"]);n.appendChild(e)}const s=e.reactionRules??[];if(s.length>0){n.appendChild(i.h3("Synthesis Rules"));const e=i.table(s,(e=>[e.code?.toString()??"",X((e.firstMonomers??[]).join(", ")),X((e.secondMonomers??[]).join(", ")),X(e.name??""),r.chem.drawMolecule(e.reaction?.split(">>")[1]??"",70,70)]),["Code","M1","M2","Name","Product"]);n.appendChild(e)}return n}catch(e){return u._package.logger.error(`Failed to load rule ${t}: ${e?.toString?.()}`),console.error(e),i.divText(`Failed to load rule ${t}`)}})()),await J.ruleDescriptions[t]})))}}}function X(e,t=30){return e.length<=t?e:`${e.substring(0,t)}...`}J.ruleDescriptions={};class Z{constructor(e,t,n,o){this.homodimerCode=e,this.heterodimerCode=t,this.linkRules=n,this.reactionRules=o}set homodimer(e){this.homodimerCode=e}set heterodimer(e){this.heterodimerCode=e}addLinkRules(e){for(let t=0;t<e.length;t++)this.linkRules.push(e[t])}addSynthesisRules(e){for(let t=0;t<e.length;t++)this.reactionRules.push(e[t])}getLinkRulesDf(){const e=this.linkRules.length,t=o.Column.int(q,e);t.setTag("friendlyName","Code");const n=o.Column.string(W,e);n.temp[".mm.cellRenderer.fontSize"]=16,n.setTag("friendlyName","First monomers"),n.semType=o.SEMTYPE.MACROMOLECULE,u.PackageFunctions.applyNotationProviderForCyclized(n,",");const r=o.Column.string(z,e);r.setTag("friendlyName","Second monomers"),r.temp[".mm.cellRenderer.fontSize"]=16,r.semType=o.SEMTYPE.MACROMOLECULE,u.PackageFunctions.applyNotationProviderForCyclized(r,",");const i=o.Column.int(K,e);i.setTag("friendlyName","First group");const s=o.Column.int(Q,e);s.setTag("friendlyName","Second group");for(let o=0;o<e;o++)t.set(o,this.linkRules[o].code),n.set(o,this.linkRules[o].firstMonomers.toString()),r.set(o,this.linkRules[o].secondMonomers.toString()),i.set(o,this.linkRules[o].firstLinkingGroup),s.set(o,this.linkRules[o].secondLinkingGroup);const a=o.DataFrame.fromColumns([t,n,r,i,s]);return{res:a,addNewRow:e=>{if(null!=e.row&&e.row<a.rowCount&&e.row>=0)t.set(e.row,e.code),n.set(e.row,e.firstMonomers),r.set(e.row,e.secondMonomers),i.set(e.row,e.firstLinkingGroup),s.set(e.row,e.secondLinkingGroup);else{const{code:t,firstMonomers:n,secondMonomers:o,firstLinkingGroup:r,secondLinkingGroup:i}=e;a.rows.addNew([t,n??"",o??"",r??1,i??2])}}}}async getLinkCards(){const e=this.linkRules.length,t=new Array(e),n=(await(0,U.pj)()).getMonomerLib();for(let o=0;o<e;o++)t[o]=new G(this.linkRules[o].firstMonomers,this.linkRules[o].secondMonomers,n,this.linkRules[o].code,this);return t}getSynthesisRulesDf(){const e=this.reactionRules.length,t=o.Column.int(q,e);t.setTag("friendlyName","Code");const n=o.Column.string(W,e);n.setTag("friendlyName","First monomers");const r=o.Column.string(z,e);r.setTag("friendlyName","Second monomers"),n.semType=o.SEMTYPE.MACROMOLECULE,n.temp[".mm.cellRenderer.fontSize"]=16,u.PackageFunctions.applyNotationProviderForCyclized(n,","),r.semType=o.SEMTYPE.MACROMOLECULE,r.temp[".mm.cellRenderer.fontSize"]=16,u.PackageFunctions.applyNotationProviderForCyclized(r,","),r.setTag(o.TAGS.CELL_RENDERER,"Sequence"),n.setTag(o.TAGS.CELL_RENDERER,"Sequence");const i=o.Column.string(Y,e);i.setTag("friendlyName","Name");const s=o.Column.string("firstReactant",e);s.setTag("friendlyName","First reactant");const a=o.Column.string("secondReactant",e);a.setTag("friendlyName","Second reactant");const l=o.Column.string("product",e);l.setTag("friendlyName","Product");for(let o=0;o<e;o++){t.set(o,this.reactionRules[o].code),n.set(o,this.reactionRules[o].firstMonomers.toString()),r.set(o,this.reactionRules[o].secondMonomers.toString()),i.set(o,this.reactionRules[o].name);const e=this.reactionRules[o].reaction.split(">>"),c=e[0].split(".");s.set(o,c[0]),a.set(o,c[1]),l.set(o,e[1])}s.semType=o.SEMTYPE.MOLECULE,a.semType=o.SEMTYPE.MOLECULE,l.semType=o.SEMTYPE.MOLECULE;const c=o.DataFrame.fromColumns([i,s,a,l,t,n,r]);return{df:c,addNewRow:e=>{if(null!=e.rowIndex&&e.rowIndex<c.rowCount&&e.rowIndex>=0)i.set(e.rowIndex,e.resultMonomerName),t.set(e.rowIndex,e.code),n.set(e.rowIndex,e.firstMonomers.join(",")),r.set(e.rowIndex,e.secondMonomers.join(",")),s.set(e.rowIndex,e.firstReactantSmiles),a.set(e.rowIndex,e.secondReactantSmiles),l.set(e.rowIndex,e.productSmiles);else{const{resultMonomerName:t,code:n,firstMonomers:o,secondMonomers:r,firstReactantSmiles:i,secondReactantSmiles:s,productSmiles:a}=e;c.rows.addNew([t,i,s,a,n,o.join(","),r.join(",")])}}}}setLinkRules(e){const t=e.rowCount,n=new Array(t),o=e.columns.byName(q),r=e.columns.byName(W),i=e.columns.byName(z),s=e.columns.byName(K),a=e.columns.byName(Q);for(let e=0;e<t;e++){const t=r.get(e).split(","),l=i.get(e).split(","),c={code:o.get(e),firstMonomers:""!==t[0]?t:[],secondMonomers:""!==l[0]?l:[],firstLinkingGroup:s.get(e),secondLinkingGroup:a.get(e)};n[e]=c}this.linkRules=n}setSynthesisRules(e){const t=e.rowCount,n=new Array(t),o=e.columns.byName(q),r=e.columns.byName(W),i=e.columns.byName(z),s=e.columns.byName(Y),a=e.columns.byName("firstReactant"),l=e.columns.byName("secondReactant"),c=e.columns.byName("product");for(let e=0;e<t;e++){const t=`${a.get(e)}.${l.get(e)}>>${c.get(e)}`,u=r.get(e).split(","),h=i.get(e).split(","),d={code:o.get(e),firstMonomers:""!==u[0]?u:[],secondMonomers:""!==h[0]?h:[],reaction:t,name:s.get(e)};n[e]=d}this.reactionRules=n}}async function ee(e){const t=new o.FileSource(V),n=new Z(null,null,[],[]);for(let o=0;o<e.length;o++){const r=await t.readAsText(e[o].replace(V,"")),i=JSON.parse(r);n.homodimer=i.homodimerCode,n.heterodimer=i.heterodimerCode,n.addLinkRules(i.linkRules),n.addSynthesisRules(i.reactionRules)}return n}function te(e){const t=e.firstMonomers.length*e.secondMonomers.length,n=new Array(t),o=new Array(t);let r=0;for(let t=0;t<e.firstMonomers.length;t++)for(let i=0;i<e.secondMonomers.length;i++)n[r]=e.firstMonomers[t],o[r]=e.secondMonomers[i],r++;return[n,o]}},5174:(e,t,n)=>{"use strict";n.d(t,{A:()=>u,T:()=>h});var o=n(6717),r=n(1296),i=n(9192),s=n(4328),a=n(1991),l=n.n(a),c=n(4971);async function u(e){const t=(await(0,c.pj)()).getMonomerLib(),n=await(0,o.j)(),r={};let i=[],a=[];for(let o=0;o<e.reactionRules.length;o++)try{[i,a]=h(n,t,e.reactionRules[o])}catch(e){i=[],a=[],console.error(e),s.shell.warning(e)}finally{for(let e=0;e<i.length;e++)null!=i[e]&&null!=a[e]&&(r[i[e]]=a[e])}const u={PEPTIDE:r};return t.override(u,"ST-PT-reactions."+l().repeat(1).map((()=>Math.floor(36*Math.random()).toString(36))).take(4).toArray().join(""))}function h(e,t,n){const o=n.reaction,r=n.name,s=n.firstMonomers.length+n.secondMonomers.length+1,a=n.reaction.split(">>"),l=a[0].split("."),c=new Array(s),u=new Array(s),h=new Array(s),f=p(e,o),g=`${l[0]}>>[C:1]C`,y=`${l[1]}>>[C:2]C`,b=p(e,g),v=p(e,y);let C=0;for(let o=0;o<n.firstMonomers.length;o++){const i=t.getMonomer("PEPTIDE",n.firstMonomers[o]);if(i&&i.molfile)try{const t=d(e,i.molfile,b,i.name);h[C]=t,c[C]=`${i.symbol}_${r}`}catch(e){console.error(e)}C++}for(let o=0;o<n.secondMonomers.length;o++){const i=t.getMonomer("PEPTIDE",n.secondMonomers[o]);if(i&&i.molfile)try{const t=d(e,i.molfile,v,i.name);h[C]=t,c[C]=`${i.symbol}_${r}`}catch(e){console.error(e)}C++}let x=null;a[1]=a[1].replace("[C:1]","[1*]").replace("[C:2]","[2*]").replace("[C:3]","[3*]");let w="";try{x=e.get_mol(a[1]),w=x?.get_molblock()}catch(e){const[t,n]=(0,i.AP)(e);throw console.error(`Can not assemble monomer '${r}': ${t}.`),e}finally{x?.delete()}h[C]=w,c[C]=r;for(let e=0;e<s-1;e++)h[e]&&(h[e]=h[e].replace(" 0.0000 0.0000 0.0000 C "," 0.0000 0.0000 0.0000 R# ").replace("M RGP 2","M RGP 3 2 3"));h[s-1]=function(e){const t=e.replace("M RAD","M RGP").replace("M ISO","M RGP").split("\n"),n=t.findIndex((e=>e.startsWith("M RGP"))),o=Number(t[n].substring(9,13)),r=Number(t[n].substring(17,21)),i=Number(t[n].substring(13,17)),s=Number(t[n].substring(21,25));t[n]=t[n].substring(0,13)+` ${i}`+t[n].substring(17,21)+` ${s}`,t[3+o]=t[3+o].substring(0,30)+" R# 0 0 0 0 0 0 0 0 0 0 0 0",t[3+r]=t[3+r].substring(0,30)+" R# 0 0 0 0 0 0 0 0 0 0 0 0";let a="";for(let e=0;e<t.length;e++)a+=t[e]+"\n";return a}(h[s-1]);for(let e=0;e<s;e++){const t=e==s-1;if(!h[e]||!c[e])continue;const n={symbol:c[e],name:c[e],molfile:h[e],author:"",id:0,rgroups:m(t),smiles:"",polymerType:"PEPTIDE",monomerType:"Backbone",createDate:null};n.meta=Object.assign(n.meta??{},{colors:{default:{line:"#2083D5",text:"#2083D5",background:"#F2F2F5"}}}),c[e]=c[e],u[e]=n}return f.delete(),b.delete(),v.delete(),[c,u]}function d(e,t,n,o){let r=null,s=null,a=null,l=null,c="";try{r=new e.MolList,s=e.get_mol(t),r.append(s),a=n.run_reactants(r,1),l=a.get(0).next(),c=l?.get_molblock()}catch(e){const[t,n]=(0,i.AP)(e);throw console.error(`Can not assemble monomer '${o}': ${t}.`),e}finally{r?.delete(),s?.delete(),a?.delete(),l?.delete()}return c}function p(e,t){let n=null;try{if(n=e.get_rxn(t),!n)throw new r.J5(t)}catch(e){n?.delete();const[o,r]=(0,i.AP)(e);throw console.error(`Can not assemble monomer '${t}': ${o}.`),e}return n}function m(e){if(e){const e=new Array(2),t={capGroupSMILES:"[*:1][H]",alternateId:"R1-H",capGroupName:"H",label:"R1"},n={capGroupSMILES:"[*:2][H]",alternateId:"R2-H",capGroupName:"H",label:"R2"};return e[0]=t,e[1]=n,e}return[{capGroupSMILES:"[*:3][H]",alternateId:"R3-H",capGroupName:"H",label:"R3"}]}},3309:(e,t,n)=>{"use strict";n.d(t,{BG:()=>y,HL:()=>A,Ii:()=>C,KS:()=>h,PI:()=>r,Qk:()=>c,XB:()=>f,ah:()=>d,aj:()=>u,j7:()=>l,jp:()=>T,k5:()=>m,u8:()=>o,xD:()=>E,yw:()=>v,z9:()=>b});const o=1e6,r={Zip:"Zip",Cartesian:"Cartesian"},i=String.raw`\[(?:(\d+)\*|\*:(\d+)|\*(\d+)|R(\d+)|R:(\d+))\]`;function s(){return new RegExp(i,"g")}function a(e){for(const t of e)if(void 0!==t)return parseInt(t,10);return null}function l(e){return e.replace(s(),((e,t,n,o,r,i)=>{const s=a([t,n,o,r,i]);return null===s?e:`[*:${s}]`}))}function c(e){const t=new Set;for(const n of e.matchAll(s())){const e=a([n[1],n[2],n[3],n[4],n[5]]);null!==e&&t.add(e)}return[...t].sort(((e,t)=>e-t))}function u(e,t){return e.replace(s(),(()=>`[*:${t}]`))}function h(e,t,n){const o=(e??"").trim();if(""===o)return{smiles:"",originalSmiles:e,rNumbers:[],id:t,error:"Empty SMILES"};const r=l(o),i=c(r);if(0===i.length)return{smiles:r,originalSmiles:e,rNumbers:i,id:t,error:"Core must contain at least one R group"};if(n){const o=p(r,n);if(o)return{smiles:r,originalSmiles:e,rNumbers:i,id:t,error:`Invalid SMILES: ${o}`}}return{smiles:r,originalSmiles:e,rNumbers:i,id:t}}function d(e,t,n,o){const r=(e??"").trim();if(""===r)return{smiles:"",originalSmiles:e,rNumber:t,id:n,error:"Empty SMILES"};const i=l(r),s=c(i);if(0===s.length)return{smiles:i,originalSmiles:e,rNumber:t,id:n,error:"R-group must contain exactly one R label (found none)"};if(s.length>1)return{smiles:i,originalSmiles:e,rNumber:t,id:n,sourceRNumber:s[0],error:`R-group must contain exactly one R label (found ${s.length}: ${s.map((e=>"R"+e)).join(", ")})`};const a=s[0],h=u(i,t);if(o){const r=p(h,o);if(r)return{smiles:h,originalSmiles:e,rNumber:t,id:n,sourceRNumber:a,error:`Invalid SMILES: ${r}`}}return{smiles:h,originalSmiles:e,rNumber:t,id:n,sourceRNumber:a}}function p(e,t){let n=null;try{return n=t.get_mol(e),n&&n.is_valid()?null:"failed to parse"}catch(e){return(e?.message??String(e)).toString().slice(0,120)}finally{n?.delete()}}function m(e,t,n){const o=[],i=[];for(const n of e.rNumbers){const e=t.get(n);e&&0!==e.length?i.push(e.filter((e=>!e.error)).length):o.push(n)}if(o.length>0)return{count:0,uncovered:o};if(i.some((e=>0===e)))return{count:0,uncovered:o};if(n===r.Zip){if(0===i.length)return{count:0,uncovered:o};const e=i[0];return{count:i.every((t=>t===e))?e:-1,uncovered:o}}return{count:i.reduce(((e,t)=>e*t),1),uncovered:o}}function f(e){const t=e.maxResults??o,n=[];let i=0;const s=e.cores.filter((e=>!e.error));0===s.length&&n.push("No valid cores provided.");const a=new Set;for(const e of s)for(const t of e.rNumbers)a.add(t);const l=new Map;for(const t of a){const o=(e.rGroups.get(t)??[]).filter((e=>!e.error)).length;l.set(t,o),0===o&&n.push(`No valid R-group provided for R${t}.`)}if(e.mode===r.Zip){const e=[...l.values()].filter((e=>e>0));e.length>1&&!e.every((t=>t===e[0]))&&n.push(`Zip mode requires every R-group list to have the same number of entries. Got ${[...l.entries()].map((([e,t])=>`R${e}=${t}`)).join(", ")}.`)}for(const o of s){const{count:r,uncovered:s}=m(o,e.rGroups,e.mode);if(s.length>0)n.push(`Core "${o.id}" references uncovered R-number${s.length>1?"s":""}: ${s.map((e=>"R"+e)).join(", ")}.`);else if(!(r<0)&&(i+=r,i>t))break}const c=i>t;return c&&n.push(`Too many combinations (> ${t.toLocaleString()}). Reduce the number of cores or R-groups, or switch to Zip mode.`),{ok:0===n.length,errors:n,predictedCount:i,overCap:c}}function g(e,t){if(0===t.size)return null;const n=b(e),o=new Map;for(const[e,n]of t)o.set(e,b(n));const r=C([n,...o.values()],t.size);if(r.length<t.size)return null;const i=new Map;let s=0;for(const e of t.keys())i.set(e,x(r[s++]));let a=n;for(const[e,t]of i)a=v(a,e,t);const l=[];for(const[e,t]of o)l.push(v(t,e,i.get(e)));return[a,...l].join(".")}function y(e,t,n){const o=g(e,t);if(!o)return null;let r=null;try{return r=n.get_mol(o),r&&r.is_valid()?r.get_smiles():null}catch{return null}finally{r?.delete()}}function b(e){const t=e.match(/^(\[\*:\d+\])([-=#:/\\])?(\[[^\]]+\]|Br|Cl|[BCNOPSFIbcnops])(.*)$/s);if(!t)return e;const[,n,o,r,i]=t;return`${r}(${o??""}${n})${i}`}function v(e,t,n){const o=`[*:${t}]`,r=new RegExp(`\\(\\s*\\[\\*:${t}\\]\\s*\\)`,"g");return(e=e.replace(r,n)).split(o).join(n)}function C(e,t){const n=new Set;for(const t of e){const e=t.replace(/\[[^\]]*\]/g,"");for(const t of e.matchAll(/%(\d{2})/g))n.add(parseInt(t[1],10));for(const t of e){const e=t.charCodeAt(0)-48;e>=0&&e<=9&&n.add(e)}}const o=[];for(let e=1;e<100&&o.length<t;e++)n.has(e)||o.push(e);return o}function x(e){if(e<0||e>99)throw new Error(`Ring digit out of range: ${e}`);return e<=9?`${e}`:`%${e.toString().padStart(2,"0")}`}function*w(e){const t=e.maxResults??o;let n=0;for(const o of e.cores){if(o.error)continue;const i=o.rNumbers,s=[];let a=!1;for(const t of i){const n=(e.rGroups.get(t)??[]).filter((e=>!e.error));if(0===n.length){a=!0;break}s.push(n)}if(!a)if(e.mode===r.Zip){if(0===s.length)continue;const e=s[0].length;if(!s.every((t=>t.length===e)))continue;for(let r=0;r<e;r++){const e=new Map;for(let t=0;t<i.length;t++)e.set(i[t],s[t][r]);if(yield{core:o,assignment:e},++n>=t)return}}else{const e=new Array(s.length).fill(0);for(;;){const r=new Map;for(let t=0;t<i.length;t++)r.set(i[t],s[t][e[t]]);if(yield{core:o,assignment:r},++n>=t)return;let a=e.length-1;for(;a>=0&&(e[a]++,!(e[a]<s[a].length));)e[a]=0,a--;if(a<0)break}}}}function A(e,t){if(!f(e).ok)return null;const n=[];for(const{core:o,assignment:r}of w(e)){const e=new Map;for(const[t,n]of r)e.set(t,n.smiles);const i=y(o.smiles,e,t);if(!i)continue;const s=new Map;for(const[e,t]of r)s.set(e,t.originalSmiles);n.push({smiles:i,coreSmiles:o.originalSmiles,rGroupSmilesByNum:s})}return n}function T(e){if(!f(e).ok)return null;const t=[];for(const{core:n,assignment:o}of w(e)){const e=new Map;for(const[t,n]of o)e.set(t,n.smiles);const r=g(n.smiles,e);if(!r)continue;const i=new Map;for(const[e,t]of o)i.set(e,t.originalSmiles);t.push({smiles:r,coreSmiles:n.originalSmiles,rGroupSmilesByNum:i})}return t}function E(e,t,n=Math.random){const o=[];let r=0;for(const{core:i,assignment:s}of w(e)){const e=new Map;for(const[t,n]of s)e.set(t,n.smiles);const a=g(i.smiles,e);if(!a)continue;const l=new Map;for(const[e,t]of s)l.set(e,t.originalSmiles);const c={smiles:a,coreSmiles:i.originalSmiles,rGroupSmilesByNum:l};if(o.length<t)o.push(c);else{const e=Math.floor(n()*(r+1));e<t&&(o[e]=c)}r++}return o}},3820:(e,t,n)=>{"use strict";n.d(t,{d:()=>r,o:()=>s});var o=n(1296);const r="PEPTIDE1{R.[Aca].T.G.H.F.G.A.A.Y.P.E.[meI]}$$$$";function i(e,t,n,o){const r=new Array(o.length*(n-t+1));for(let i=0;i<o.length;++i){const s=n-t+1;for(let n=0;n<s;++n){const a=t+n,l=o[i],c=r[i*s+n]=e.clone(),u=c.atoms[a].elem;c.atoms[a].elem=l;const h=u?.length>1?`[${u}]`:u,d=l?.length>1?`[${l}]`:l;c.name=`${e.name}-${h}${a+1}${d}`}}return r}function s(e,t,n){const r=new JSDraw2.MolHandler,s=new org.helm.webeditor.Plugin(r);org.helm.webeditor.IO.parseHelm(s,e,new JSDraw2.Point(0,0),void 0);const a=r.m;a.name=t;let l=[];if(n.placeholders)switch(n.type){case o.aK.Single:l=function(e,t){return t.map((t=>i(e,t.position,t.position,t.monomers))).reduce(((e,t)=>e.concat(t)),[])}(r.m,n.placeholders);break;case o.aK.Parallel:l=function(e,t){if(0===t.length)return[];const n=t[0].monomers.length;for(const e of t)if(e.monomers.length!==n)throw new Error("Parallel enumeration requires all positions to have the same number of monomers");const o=new Array(n);for(let r=0;r<n;r++){const n=e.clone(),i=[];for(const e of t){const t=e.position,o=e.monomers[r],s=n.atoms[t].elem;n.atoms[t].elem=o;const a=s?.length>1?`[${s}]`:s,l=o?.length>1?`[${o}]`:o;i.push(`${a}${t+1}${l}`)}n.name=`${e.name}-${i.join("-")}`,o[r]=n}return o}(r.m,n.placeholders);break;case o.aK.Matrix:l=function(e,t){let n=[e];for(const e of t){const t=n.map((t=>i(t,e.position,e.position,e.monomers)));n=t.reduce(((e,t)=>e.concat(t)),[])}return n}(r.m,n.placeholders)}let c=[];n.breadthPlaceholders&&(c=function(e,t){if(0==t.length)return[];let n=[e];for(const e of t){const t=n.map((t=>i(t,e.start,e.end,e.monomers)));n=t.reduce(((e,t)=>e.concat(t)),[])}return n}(r.m,n.breadthPlaceholders)),l=l.concat(c),n.keepOriginal&&(l=[a,...l]);const u=l.map((e=>[org.helm.webeditor.IO.getHelm(e),e.name]));return u}},1296:(e,t,n)=>{"use strict";var o;n.d(t,{J5:()=>r,aK:()=>o}),function(e){e.Single="single",e.Parallel="parallel",e.Matrix="matrix"}(o||(o={})),Error;class r extends Error{constructor(e,t){super(`Invalid reaction '${e}'.`),this.type="InvalidReactionError"}}},6082:e=>{"use strict";e.exports=DG},4328:e=>{"use strict";e.exports=grok},7389:e=>{"use strict";e.exports=ui},1991:e=>{"use strict";e.exports=wu}},t={};function n(o){var r=t[o];if(void 0!==r)return r.exports;var i=t[o]={id:o,loaded:!1,exports:{}};return e[o].call(i.exports,i,i.exports,n),i.loaded=!0,i.exports}n.m=e,n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var o in t)n.o(t,o)&&!n.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},n.u=e=>e+".js",n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),(()=>{var e;n.g.importScripts&&(e=n.g.location+"");var t=n.g.document;if(!e&&t&&(t.currentScript&&"SCRIPT"===t.currentScript.tagName.toUpperCase()&&(e=t.currentScript.src),!e)){var o=t.getElementsByTagName("script");if(o.length)for(var r=o.length-1;r>-1&&(!e||!/^http(s?):/.test(e));)e=o[r--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),n.p=e})(),n.b=document.baseURI||self.location.href,n.nc=void 0;var o={};(()=>{"use strict";n.r(o),n.d(o,{_package:()=>we,initAutoTests:()=>Te,test:()=>Ae,tests:()=>h});var e=n(6082);n(9982);const t=DG.DataFrame.fromCsv('countries,fasta,smiles,molregno,LON,Zip Code,Street Address Line 1,ImageUrl,user_id,error_message,xray,flag,magnitude,CS-id,pdb_id,accel_a,time_offset,chart,fit,Questions,empty_number,empty_string\nBelgium,MSNFHNEHVMQFYRNNLKTKGVFGRQ,CC(C(=O)OCCCc1cccnc1)c2cccc(c2)C(=O)c3ccccc3,1480014,36.276729583740234,995042300,14016 ROUTE 31W,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,1,1,1QBS,1,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[2.497360340644872, 1.7058694986686864, 5.278052678195135, 0.16000320889028383],""points"":[{""x"":0.10000000149011612,""y"":2.374499797821045},{""x"":0.6000000238418579,""y"":2.6242473125457764},{""x"":1.100000023841858,""y"":2.367267608642578},{""x"":1.600000023841858,""y"":2.6723148822784424},{""x"":2.0999999046325684,""y"":2.6537344455718994},{""x"":2.5999999046325684,""y"":2.3651671409606934},{""x"":3.0999999046325684,""y"":2.5654284954071045},{""x"":3.5999999046325684,""y"":2.4160959720611572},{""x"":4.099999904632568,""y"":2.286726713180542},{""x"":4.599999904632568,""y"":2.5100042819976807},{""x"":5.099999904632568,""y"":1.6676985025405884},{""x"":5.599999904632568,""y"":0.680136501789093},{""x"":6.099999904632568,""y"":0.3391543924808502},{""x"":6.599999904632568,""y"":0.09038983285427094},{""x"":7.099999904632568,""y"":0.19802775979042053}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[7.525235855508179, 1.3186911876809984, 5.335672608564294, 0.7860743343958098],""points"":[{""x"":0.10000000149011612,""y"":7.988070487976074},{""x"":0.6000000238418579,""y"":7.018453121185303},{""x"":1.100000023841858,""y"":8.115279197692871},{""x"":1.600000023841858,""y"":7.486658096313477},{""x"":2.0999999046325684,""y"":7.396438121795654},{""x"":2.5999999046325684,""y"":7.477052211761475},{""x"":3.0999999046325684,""y"":6.913095474243164},{""x"":3.5999999046325684,""y"":8.01385498046875},{""x"":4.099999904632568,""y"":6.985900402069092},{""x"":4.599999904632568,""y"":6.970335960388184},{""x"":5.099999904632568,""y"":5.448817253112793},{""x"":5.599999904632568,""y"":2.5534818172454834},{""x"":6.099999904632568,""y"":1.893947958946228},{""x"":6.599999904632568,""y"":0.6340042352676392},{""x"":7.099999904632568,""y"":0.8403874039649963}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,100,abc\nBurundi,MDYKETLLMPKTDFPMRGGLPNKEPQIQEKW,COc1ccc2cc(ccc2c1)C(C)C(=O)Oc3ccc(C)cc3OC,1480015,36.276729583740234,995073444,80 STATE HIGHWAY 310,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,2,2,1ZP8,2,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[4.431460753103398, 2.1691498799246745, 5.266445597102774, 0.7825762827017926],""points"":[{""x"":0.10000000149011612,""y"":4.751083850860596},{""x"":0.6000000238418579,""y"":4.203000068664551},{""x"":1.100000023841858,""y"":4.415858745574951},{""x"":1.600000023841858,""y"":4.68414306640625},{""x"":2.0999999046325684,""y"":4.198400974273682},{""x"":2.5999999046325684,""y"":4.179222106933594},{""x"":3.0999999046325684,""y"":4.638473987579346},{""x"":3.5999999046325684,""y"":4.708553314208984},{""x"":4.099999904632568,""y"":4.291589260101318},{""x"":4.599999904632568,""y"":4.038082599639893},{""x"":5.099999904632568,""y"":3.4349939823150635},{""x"":5.599999904632568,""y"":1.2194708585739136},{""x"":6.099999904632568,""y"":1.1920831203460693},{""x"":6.599999904632568,""y"":0.5352635979652405},{""x"":7.099999904632568,""y"":0.3346920311450958}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[2.339458017970126, -1.0734184310171178, 4.746332950550934, 0.2482416857595658],""points"":[{""x"":0.10000000149011612,""y"":0.2139337658882141},{""x"":0.6000000238418579,""y"":0.4269562065601349},{""x"":1.100000023841858,""y"":0.2441573292016983},{""x"":1.600000023841858,""y"":0.146635964512825},{""x"":2.0999999046325684,""y"":0.08818462491035461},{""x"":2.5999999046325684,""y"":0.2560656666755676},{""x"":3.0999999046325684,""y"":0.42434045672416687},{""x"":3.5999999046325684,""y"":0.37111231684684753},{""x"":4.099999904632568,""y"":0.5581737160682678},{""x"":4.599999904632568,""y"":1.183590054512024},{""x"":5.099999904632568,""y"":1.5629843473434448},{""x"":5.599999904632568,""y"":2.3211288452148438},{""x"":6.099999904632568,""y"":2.229961633682251},{""x"":6.599999904632568,""y"":2.2560226917266846},{""x"":7.099999904632568,""y"":2.2142398357391357}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCameroon,MIEVFLFGIVLGLIPITLAGLFVTAYLQYRRGDQLDL,COc1ccc2cc(ccc2c1)C(C)C(=O)OCCCc3cccnc3,1480016,36.26095962524414,995153596,30-56 WHITESTONE EXPY,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,3,3,2BDJ,3,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[4.6760652578642325, 0.9046956320756703, 5.651408971856738, 0.07738846012184185],""points"":[{""x"":0.10000000149011612,""y"":4.32425594329834},{""x"":0.6000000238418579,""y"":4.668442249298096},{""x"":1.100000023841858,""y"":4.379785060882568},{""x"":1.600000023841858,""y"":5.0345139503479},{""x"":2.0999999046325684,""y"":4.878653526306152},{""x"":2.5999999046325684,""y"":4.3451313972473145},{""x"":3.0999999046325684,""y"":4.336992263793945},{""x"":3.5999999046325684,""y"":5.037430286407471},{""x"":4.099999904632568,""y"":5.0092692375183105},{""x"":4.599999904632568,""y"":4.151902675628662},{""x"":5.099999904632568,""y"":3.4066951274871826},{""x"":5.599999904632568,""y"":2.3732759952545166},{""x"":6.099999904632568,""y"":1.673728108406067},{""x"":6.599999904632568,""y"":0.48574790358543396},{""x"":7.099999904632568,""y"":0.2783052325248718}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[2.938395863010111, -1.4658480661392117, 5.462702751996584, 0.3473139023615039],""points"":[{""x"":0.10000000149011612,""y"":0.4941710829734802},{""x"":0.6000000238418579,""y"":0.15323974192142487},{""x"":1.100000023841858,""y"":0.46373432874679565},{""x"":1.600000023841858,""y"":0.3370431363582611},{""x"":2.0999999046325684,""y"":0.5179030299186707},{""x"":2.5999999046325684,""y"":0.27899765968322754},{""x"":3.0999999046325684,""y"":0.22075064480304718},{""x"":3.5999999046325684,""y"":0.5789918899536133},{""x"":4.099999904632568,""y"":0.21169911324977875},{""x"":4.599999904632568,""y"":0.27857646346092224},{""x"":5.099999904632568,""y"":1.0906332731246948},{""x"":5.599999904632568,""y"":1.8520300388336182},{""x"":6.099999904632568,""y"":2.7177059650421143},{""x"":6.599999904632568,""y"":2.8680918216705322},{""x"":7.099999904632568,""y"":3.2413077354431152}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCanada,MMELVLKTIIGPIVVGVVLRIVDKWLNKDK,CC(C(=O)NCCS)c1cccc(c1)C(=O)c2ccccc2,1480017,36.26095962524414,99515,30-56 WHITESTONE EXPY,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,4,4,1IAN,4,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[0.8597390975430008, 1.0957625732481946, 5.260537067987958, 0.07974187998177736],""points"":[{""x"":0.10000000149011612,""y"":0.8190152645111084},{""x"":0.6000000238418579,""y"":0.8421689867973328},{""x"":1.100000023841858,""y"":0.8740922212600708},{""x"":1.600000023841858,""y"":0.8924275040626526},{""x"":2.0999999046325684,""y"":0.8249067664146423},{""x"":2.5999999046325684,""y"":0.9327669143676758},{""x"":3.0999999046325684,""y"":0.8522974252700806},{""x"":3.5999999046325684,""y"":0.8174492716789246},{""x"":4.099999904632568,""y"":0.8394647240638733},{""x"":4.599999904632568,""y"":0.7139387726783752},{""x"":5.099999904632568,""y"":0.5561167597770691},{""x"":5.599999904632568,""y"":0.3276226818561554},{""x"":6.099999904632568,""y"":0.12479474395513535},{""x"":6.599999904632568,""y"":0.13006797432899475},{""x"":7.099999904632568,""y"":0.059702079743146896}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.760930219582546, 1.6591793293833013, 4.667155929720851, 0.7858109544121652],""points"":[{""x"":0.10000000149011612,""y"":6.156993389129639},{""x"":0.6000000238418579,""y"":5.236701965332031},{""x"":1.100000023841858,""y"":6.010560512542725},{""x"":1.600000023841858,""y"":5.495512962341309},{""x"":2.0999999046325684,""y"":6.087770462036133},{""x"":2.5999999046325684,""y"":5.79986572265625},{""x"":3.0999999046325684,""y"":5.597546577453613},{""x"":3.5999999046325684,""y"":5.520902156829834},{""x"":4.099999904632568,""y"":5.360654354095459},{""x"":4.599999904632568,""y"":3.5539746284484863},{""x"":5.099999904632568,""y"":1.577236294746399},{""x"":5.599999904632568,""y"":1.0001264810562134},{""x"":6.099999904632568,""y"":0.9305797815322876},{""x"":6.599999904632568,""y"":0.6033638715744019},{""x"":7.099999904632568,""y"":0.4203685522079468}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nColombia,MDRTDEVSNHTHDKPTLTWFEEIFEEYHSPFHN,FC(F)(F)c1ccc(OC2CCNCC2)cc1,1480029,36.3309440612793,995152050,1 COURT HOUSE SQUARE,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,5,5,4UJ1,5,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[6.4995088314153655, 2.4270351004539914, 5.178659535348579, 0.625653346241577],""points"":[{""x"":0.10000000149011612,""y"":6.496231555938721},{""x"":0.6000000238418579,""y"":6.42543363571167},{""x"":1.100000023841858,""y"":7.040063858032227},{""x"":1.600000023841858,""y"":6.1115403175354},{""x"":2.0999999046325684,""y"":6.680728435516357},{""x"":2.5999999046325684,""y"":6.406774520874023},{""x"":3.0999999046325684,""y"":6.611269474029541},{""x"":3.5999999046325684,""y"":5.889094352722168},{""x"":4.099999904632568,""y"":6.75344705581665},{""x"":4.599999904632568,""y"":6.361435890197754},{""x"":5.099999904632568,""y"":4.1666975021362305},{""x"":5.599999904632568,""y"":1.172118902206421},{""x"":6.099999904632568,""y"":0.801048994064331},{""x"":6.599999904632568,""y"":0.4640021026134491},{""x"":7.099999904632568,""y"":0.0010357667924836278}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[1.4734381347446401, 1.1649805188074196, 4.82958608866421, 0.09500545496710007],""points"":[{""x"":0.10000000149011612,""y"":1.5279096364974976},{""x"":0.6000000238418579,""y"":1.3559974431991577},{""x"":1.100000023841858,""y"":1.5246378183364868},{""x"":1.600000023841858,""y"":1.5567657947540283},{""x"":2.0999999046325684,""y"":1.4114240407943726},{""x"":2.5999999046325684,""y"":1.4045010805130005},{""x"":3.0999999046325684,""y"":1.4769829511642456},{""x"":3.5999999046325684,""y"":1.4875500202178955},{""x"":4.099999904632568,""y"":1.2991987466812134},{""x"":4.599999904632568,""y"":0.922961413860321},{""x"":5.099999904632568,""y"":0.6520044803619385},{""x"":5.599999904632568,""y"":0.15350978076457977},{""x"":6.099999904632568,""y"":0.1078903079032898},{""x"":6.599999904632568,""y"":0.17276449501514435},{""x"":7.099999904632568,""y"":0.14066608250141144}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCosta Rica,MKSTKEEIQTIKTLLKDSRTAKYHKRLQIVL,CC(C)Cc1ccc(cc1)C(C)C(=O)N2CCCC2C(=O)OCCCc3ccccc3,1480018,36.3309440612793,995084218,4041 SOUTHWESTERN BLVD,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,6,6,2BPW,6,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[2.4833641843311227, -1.8945978742090062, 4.671127708092568, 0.24159861311815153],""points"":[{""x"":0.10000000149011612,""y"":0.0969524160027504},{""x"":0.6000000238418579,""y"":0.028483040630817413},{""x"":1.100000023841858,""y"":0.22087176144123077},{""x"":1.600000023841858,""y"":0.0068915546871721745},{""x"":2.0999999046325684,""y"":0.4305879771709442},{""x"":2.5999999046325684,""y"":0.44774115085601807},{""x"":3.0999999046325684,""y"":0.45346319675445557},{""x"":3.5999999046325684,""y"":0.2370593100786209},{""x"":4.099999904632568,""y"":0.4657953977584839},{""x"":4.599999904632568,""y"":1.155200719833374},{""x"":5.099999904632568,""y"":2.2294070720672607},{""x"":5.599999904632568,""y"":2.4311530590057373},{""x"":6.099999904632568,""y"":2.33846116065979},{""x"":6.599999904632568,""y"":2.608201026916504},{""x"":7.099999904632568,""y"":2.8136143684387207}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.224573521642033, 1.4454033924198528, 5.6014197746076535, 0.2823216054197577],""points"":[{""x"":0.10000000149011612,""y"":4.95027494430542},{""x"":0.6000000238418579,""y"":5.1754679679870605},{""x"":1.100000023841858,""y"":5.276752948760986},{""x"":1.600000023841858,""y"":5.589294910430908},{""x"":2.0999999046325684,""y"":5.616994857788086},{""x"":2.5999999046325684,""y"":5.120813846588135},{""x"":3.0999999046325684,""y"":5.340766906738281},{""x"":3.5999999046325684,""y"":4.876471042633057},{""x"":4.099999904632568,""y"":4.94999361038208},{""x"":4.599999904632568,""y"":5.162564754486084},{""x"":5.099999904632568,""y"":4.399557590484619},{""x"":5.599999904632568,""y"":2.7977969646453857},{""x"":6.099999904632568,""y"":1.0229872465133667},{""x"":6.599999904632568,""y"":0.48275601863861084},{""x"":7.099999904632568,""y"":0.10408931970596313}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCuba,MHAILRYFIRRLFYHIFYKIYSLISKKHQSLPSDVRQF,COc1ccc2c(c1)c(CC(=O)N3CCCC3C(=O)Oc4ccc(C)cc4OC)c(C)n2C(=O)c5ccc(Cl)cc5,1480019,36.33115768432617,995081928,1227 US HIGHWAY 11,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,7,7,1QBS,7,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[3.320838679713925, -1.2421619987316728, 4.831325425225256, 0.3236011098403072],""points"":[{""x"":0.10000000149011612,""y"":0.3727470338344574},{""x"":0.6000000238418579,""y"":0.12365014106035233},{""x"":1.100000023841858,""y"":0.48422467708587646},{""x"":1.600000023841858,""y"":0.2264465093612671},{""x"":2.0999999046325684,""y"":0.16821794211864471},{""x"":2.5999999046325684,""y"":0.3879014551639557},{""x"":3.0999999046325684,""y"":0.5470244884490967},{""x"":3.5999999046325684,""y"":0.3419053554534912},{""x"":4.099999904632568,""y"":0.7655120491981506},{""x"":4.599999904632568,""y"":1.2346516847610474},{""x"":5.099999904632568,""y"":2.453336715698242},{""x"":5.599999904632568,""y"":2.9565491676330566},{""x"":6.099999904632568,""y"":3.335299491882324},{""x"":6.599999904632568,""y"":3.240290880203247},{""x"":7.099999904632568,""y"":3.1107218265533447}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[3.6401853521511094, 1.26211588875013, 5.399028074402744, 0.5089580830068091],""points"":[{""x"":0.10000000149011612,""y"":3.8585598468780518},{""x"":0.6000000238418579,""y"":3.6077206134796143},{""x"":1.100000023841858,""y"":3.855252265930176},{""x"":1.600000023841858,""y"":3.619039297103882},{""x"":2.0999999046325684,""y"":3.839388370513916},{""x"":2.5999999046325684,""y"":3.335283041000366},{""x"":3.0999999046325684,""y"":3.571141481399536},{""x"":3.5999999046325684,""y"":3.4155046939849854},{""x"":4.099999904632568,""y"":3.7316646575927734},{""x"":4.599999904632568,""y"":3.0680155754089355},{""x"":5.099999904632568,""y"":2.891066551208496},{""x"":5.599999904632568,""y"":1.6022753715515137},{""x"":6.099999904632568,""y"":0.7652576565742493},{""x"":6.599999904632568,""y"":0.6875326037406921},{""x"":7.099999904632568,""y"":0.5828871726989746}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nItaly,MSNFHNEHVMQFYRNNLKTKGVFGRQ,CC(C)Cc1ccc(cc1)C(C)C(=O)N2CCCC2C(=O)OCCO[N+](=O)[O-],1480020,36.33115768432617,99502,"168-46 91ST AVE., 2ND FLR",https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,8,8,1ZP8,8,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[2.293592105923809, 1.3781586549141835, 5.1025898038676605, 0.03493851245291291],""points"":[{""x"":0.10000000149011612,""y"":2.1287283897399902},{""x"":0.6000000238418579,""y"":2.267972230911255},{""x"":1.100000023841858,""y"":2.398442506790161},{""x"":1.600000023841858,""y"":2.5130622386932373},{""x"":2.0999999046325684,""y"":2.3255116939544678},{""x"":2.5999999046325684,""y"":2.127340793609619},{""x"":3.0999999046325684,""y"":2.47259783744812},{""x"":3.5999999046325684,""y"":2.131181478500366},{""x"":4.099999904632568,""y"":2.090421438217163},{""x"":4.599999904632568,""y"":2.02299165725708},{""x"":5.099999904632568,""y"":1.1105059385299683},{""x"":5.599999904632568,""y"":0.4494485855102539},{""x"":6.099999904632568,""y"":0.1375635862350464},{""x"":6.599999904632568,""y"":0.036351121962070465},{""x"":7.099999904632568,""y"":0.1619771122932434}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.953125499439879, 1.2528620255306528, 5.187637440149802, 0.3110348753260886],""points"":[{""x"":0.10000000149011612,""y"":5.6585283279418945},{""x"":0.6000000238418579,""y"":5.911152362823486},{""x"":1.100000023841858,""y"":5.924920082092285},{""x"":1.600000023841858,""y"":5.8469438552856445},{""x"":2.0999999046325684,""y"":5.929472923278809},{""x"":2.5999999046325684,""y"":6.190037727355957},{""x"":3.0999999046325684,""y"":6.236179828643799},{""x"":3.5999999046325684,""y"":6.141019344329834},{""x"":4.099999904632568,""y"":5.295210838317871},{""x"":4.599999904632568,""y"":5.265801906585693},{""x"":5.099999904632568,""y"":3.3722851276397705},{""x"":5.599999904632568,""y"":1.8299226760864258},{""x"":6.099999904632568,""y"":0.32690900564193726},{""x"":6.599999904632568,""y"":0.6274543404579163},{""x"":7.099999904632568,""y"":0.8441857099533081}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nRwanda,MPNSEPASLLELFNSIATQGELVRSLKAGNASK,CC(C)Cc1ccc(cc1)C(C)C(=O)N2CCCC2C(=O)OCCO,1480021,36.33137130737305,995037247,"168-46 91ST AVE., 2ND FLR",https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,9,9,2BDJ,9,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[3.8209972202654474, 1.3779216716448506, 5.299882228439686, 0.06040645519069608],""points"":[{""x"":0.10000000149011612,""y"":3.7821109294891357},{""x"":0.6000000238418579,""y"":3.542433023452759},{""x"":1.100000023841858,""y"":3.7008674144744873},{""x"":1.600000023841858,""y"":3.717301607131958},{""x"":2.0999999046325684,""y"":4.024452209472656},{""x"":2.5999999046325684,""y"":4.013899326324463},{""x"":3.0999999046325684,""y"":3.945094347000122},{""x"":3.5999999046325684,""y"":3.866621971130371},{""x"":4.099999904632568,""y"":3.7461626529693604},{""x"":4.599999904632568,""y"":3.3454740047454834},{""x"":5.099999904632568,""y"":2.61944317817688},{""x"":5.599999904632568,""y"":0.999405026435852},{""x"":6.099999904632568,""y"":0.46259793639183044},{""x"":6.599999904632568,""y"":0.054134611040353775},{""x"":7.099999904632568,""y"":0.05711187422275543}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.6318079657726035, 1.8495493770000595, 5.391793312471116, 0.17060707587348442],""points"":[{""x"":0.10000000149011612,""y"":5.458079814910889},{""x"":0.6000000238418579,""y"":5.554427146911621},{""x"":1.100000023841858,""y"":5.799983024597168},{""x"":1.600000023841858,""y"":5.364140033721924},{""x"":2.0999999046325684,""y"":5.864485740661621},{""x"":2.5999999046325684,""y"":5.4509806632995605},{""x"":3.0999999046325684,""y"":5.702574729919434},{""x"":3.5999999046325684,""y"":5.7314534187316895},{""x"":4.099999904632568,""y"":5.5123443603515625},{""x"":4.599999904632568,""y"":5.724395751953125},{""x"":5.099999904632568,""y"":4.354506969451904},{""x"":5.599999904632568,""y"":1.7307666540145874},{""x"":6.099999904632568,""y"":0.6305936574935913},{""x"":6.599999904632568,""y"":0.035183437168598175},{""x"":7.099999904632568,""y"":0.7575169205665588}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nSwitzerland,IRVVGRYLIEVWKAAGMDMDKVLFLWSSDEI,CN1CCC(CC1)Oc2ccc(cc2)C(F)(F)F,1480028,36.33137130737305,99504,92-11 179TH PLACE,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,9,10,1IAN,10,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[1.1190255865097471, 2.3163895161544437, 5.4968866182279195, 0.2035204047289052],""points"":[{""x"":0.10000000149011612,""y"":1.1057683229446411},{""x"":0.6000000238418579,""y"":1.1019697189331055},{""x"":1.100000023841858,""y"":1.0818607807159424},{""x"":1.600000023841858,""y"":1.062997817993164},{""x"":2.0999999046325684,""y"":1.046447515487671},{""x"":2.5999999046325684,""y"":1.1217249631881714},{""x"":3.0999999046325684,""y"":1.2166996002197266},{""x"":3.5999999046325684,""y"":1.215477705001831},{""x"":4.099999904632568,""y"":1.0581893920898438},{""x"":4.599999904632568,""y"":1.1747995615005493},{""x"":5.099999904632568,""y"":1.0181127786636353},{""x"":5.599999904632568,""y"":0.5344523191452026},{""x"":6.099999904632568,""y"":0.2569526433944702},{""x"":6.599999904632568,""y"":0.1912207305431366},{""x"":7.099999904632568,""y"":0.15060538053512573}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[3.1038581025805785, 2.0032224204185245, 5.087602825989163, 0.13277988512492753],""points"":[{""x"":0.10000000149011612,""y"":3.0498509407043457},{""x"":0.6000000238418579,""y"":2.805217742919922},{""x"":1.100000023841858,""y"":3.3415253162384033},{""x"":1.600000023841858,""y"":3.0549843311309814},{""x"":2.0999999046325684,""y"":3.250074863433838},{""x"":2.5999999046325684,""y"":3.0432586669921875},{""x"":3.0999999046325684,""y"":3.265852451324463},{""x"":3.5999999046325684,""y"":2.9475724697113037},{""x"":4.099999904632568,""y"":3.1929898262023926},{""x"":4.599999904632568,""y"":2.7460060119628906},{""x"":5.099999904632568,""y"":1.6175861358642578},{""x"":5.599999904632568,""y"":0.3006608486175537},{""x"":6.099999904632568,""y"":0.3444803059101105},{""x"":6.599999904632568,""y"":0.015537971630692482},{""x"":7.099999904632568,""y"":0.5527358055114746}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\n,,,,,,,,,,,,,,,,,,,,,');t.columns.add(DG.Column.fromList(DG.TYPE.BYTE_ARRAY,"BinaryImage",Array.from(new Uint8Array(11))));var r=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function s(e){try{l(o.next(e))}catch(e){i(e)}}function a(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}l((o=o.apply(e,t||[])).next())}))};const i=3e4,s=108e5,a=console.log.bind(console),l=console.info.bind(console),c=console.warn.bind(console),u=console.error.bind(console),h={},d="Auto Tests",p="Demo",m="Detectors",f="Core",g={};let y;var b;!function(e){e.notNull=function(e,t){if(null==e)throw new Error(`${null==t?"Value":t} not defined`)}}(b||(b={}));class v{constructor(e,t,n){this.catchUnhandled=!0,this.report=!1,this.returnOnFail=!1,void 0!==e&&(this.catchUnhandled=e),void 0!==t&&(this.report=t),void 0!==n&&(this.returnOnFail=n)}}class C{constructor(e,t,n,o){var s;this.category=e,this.name=t,null!=o||(o={}),null!==(s=o.timeout)&&void 0!==s||(o.timeout=i),this.options=o,this.test=()=>r(this,void 0,void 0,(function*(){return new Promise(((e,t)=>r(this,void 0,void 0,(function*(){var o;let r="";try{DG.Test.isInDebug;let e=yield n();try{r=null!==(o=null==e?void 0:e.toString())&&void 0!==o?o:""}catch(e){r="Can't convert test's result to string",console.error(`Can't convert test's result to string in the ${this.category}:${this.name} test`)}}catch(e){t(e)}e(r)}))))}))}}function x(e,t,n){null==h[y]&&(h[y]={}),null==h[y].tests&&(h[y].tests=[]),h[y].tests.push(new C(y,e,t,n))}function w(e,t=!0,n){if(n=n?`${n}, `:"",e!==t)throw new Error(`${n}Expected "${t}", got "${e}"`)}function A(e,t,n=.001,o){if(e===Number.POSITIVE_INFINITY&&t===Number.POSITIVE_INFINITY||e===Number.NEGATIVE_INFINITY&&t===Number.NEGATIVE_INFINITY||e===Number.NaN&&t===Number.NaN||isNaN(e)&&isNaN(t))return;const r=Math.abs(e-t)<n;if(w(r,!0,`${null!=o?o:""} (tolerance = ${n}; a = ${e}, e = ${t})`),!r)throw new Error(`Expected ${t}, got ${e} (tolerance = ${n})`)}function T(e,t){for(const[n,o]of Object.entries(t)){if(!e.hasOwnProperty(n))throw new Error(`Expected property "${n}" not found`);const t=e[n];if(t instanceof Array&&o instanceof Array)E(t,o);else if(t instanceof Object&&o instanceof Object)T(t,o);else if(Number.isFinite(t)&&Number.isFinite(o))A(t,o);else if(t!=o)throw new Error(`Expected (${o}) for key '${n}', got (${t})`)}}function E(e,t){const n=e.length,o=t.length;if(n!=o)throw new Error(`Arrays are of different length: actual array length is ${n} and expected array length is ${o}`);for(let o=0;o<n;o++)if(e[o]instanceof Array&&t[o]instanceof Array)E(e[o],t[o]);else if(e[o]instanceof Object&&t[o]instanceof Object)T(e[o],t[o]);else if(e[o]!=t[o])throw new Error(`Expected ${t[o]} at position ${o}, got ${e[o]}`)}function S(e,t,n){var o;y=e,t(),h[y]&&(h[y].clear=null===(o=null==n?void 0:n.clear)||void 0===o||o,h[y].timeout=null==n?void 0:n.timeout,h[y].benchmarks=null==n?void 0:n.benchmarks,h[y].stressTests=null==n?void 0:n.stressTests,h[y].owner=null==n?void 0:n.owner)}function N(e){null==h[y]&&(h[y]={}),h[y].before=e}function I(e){null==h[y]&&(h[y]={}),h[y].after=e}function M(e,t){return e.replace(new RegExp(t.name,"gi"),t.nqName)}function P(e,n){var o,a,l,c,u,y,b,v,x,A;return r(this,void 0,void 0,(function*(){const T=e.id;if(g[T])return;const E=n?n.tests:h;if("DevTools"===e.name||n&&"DevTools"===n._package.name)for(const e of window.dartTests){const t=e.name.split(/\s*\|\s*!/g);let n=null!==(o=t.pop())&&void 0!==o?o:e.name,r=t.length?f+": "+t.join(": "):f,s=n.split(" | ");n=s[s.length-1],s.unshift(r),s.pop(),r=s.join(": "),void 0===E[r]&&(E[r]={tests:[],clear:!0}),E[r].tests.push(new C(r,n,e.test,{isAggregated:!1,timeout:null!==(l=null===(a=e.options)||void 0===a?void 0:a.timeout)&&void 0!==l?l:i,skipReason:null===(c=e.options)||void 0===c?void 0:c.skipReason,owner:null===(u=e.options)||void 0===u?void 0:u.owner,benchmark:null!==(b=null===(y=e.options)||void 0===y?void 0:y.benchmark)&&void 0!==b&&b}))}const S=[],N=[],I=[],P=yield grok.dapi.functions.filter(`package.id = "${T}"`).list(),_=new RegExp(/skip:\s*([^,\s]+)|wait:\s*(\d+)|cat:\s*([^,\s]+)|timeout:\s*(\d+)/g);for(const n of P){const o=n.options.test,a=n.options.demoPath;if(o&&Array.isArray(o)&&o.length)for(let e=0;e<o.length;e++){const t=o[e].matchAll(_),a={};Array.from(t).forEach((e=>{e[0].startsWith("skip")?a.skip=e[1]:e[0].startsWith("wait")?a.wait=parseInt(e[2]):e[0].startsWith("cat")?a.cat=e[3]:e[0].startsWith("timeout")&&(a.timeout=parseInt(e[4]))}));const l=new C(null!==(v=a.cat)&&void 0!==v?v:d,1===o.length?n.name:`${n.name} ${e+1}`,(()=>r(this,void 0,void 0,(function*(){const t=yield grok.functions.eval(M(o[e],n));if(a.wait&&(yield R(a.wait)),"boolean"==typeof t&&!t)throw`Failed: ${o[e]}, expected true, got ${t}`}))),{skipReason:a.skip,timeout:DG.Test.isInBenchmark?null!==(x=a.benchmarkTimeout)&&void 0!==x?x:s:null!==(A=a.timeout)&&void 0!==A?A:i});if(a.cat){const e=a.cat;void 0===E[e]&&(E[e]={tests:[],clear:!0}),E[e].tests||(E[e].tests=[]),E[e].tests.push(l)}else S.push(l)}if(a){const e=n.options.demoWait?parseInt(n.options.demoWait):void 0,t=new C(p,n.friendlyName,(()=>r(this,void 0,void 0,(function*(){yield R(300),grok.shell.clearLastError(),yield n.apply(),yield R(e||2e3);const t=yield grok.shell.lastError;if(t)throw new Error(t)}))),{skipReason:n.options.demoSkip});N.push(t)}if(n.hasTag("semTypeDetector")){let o=t;n.options.testData&&(o=yield grok.data.files.openTable(`System:AppData/${e.nqName}/${n.options.testData}`));const i=new C(m,n.friendlyName,(()=>r(this,void 0,void 0,(function*(){const t=[];console.log(`System:AppData/${e.nqName}/${n.options.testData}`);for(const e of o.clone().columns){const o=yield n.apply([e]);t.push(o||e.semType)}const r=t.filter((e=>e));w(r.length,1),n.options.testDataColumnName&&w(r[0],n.options.testDataColumnName)}))),{skipReason:n.options.skipTest});I.push(i)}}g[T]=!0,S.length>0&&(E[d]={tests:S,clear:!0}),N.length>0&&(E[p]={tests:N,clear:!0}),I.length>0&&(E[m]={tests:I,clear:!1})}))}function _(e){return r(this,void 0,void 0,(function*(){return`${e.toString()}\n${e.stack?yield DG.Logger.translateStackTrace(e.stack):""}`}))}function L(e,t,n,o,s,l){var c,h,d,p,m,f,g,y,b,v,C,x,w,A;return r(this,void 0,void 0,(function*(){let r;n.length=0;const T=null!=t&&e.name.toLowerCase()!==t.toLowerCase();let E=(null===(c=e.options)||void 0===c?void 0:c.skipReason)||T,S=T?"skipped":null===(h=e.options)||void 0===h?void 0:h.skipReason;if(DG.Test.isInBenchmark&&!(null===(d=e.options)||void 0===d?void 0:d.benchmark))return void a(`Package testing: Skipped {{${e.category}}} {{${e.name}}} doesnt available in benchmark mode`);E&&!DG.Test.isInBenchmark&&a(`Package testing: Skipped {{${e.category}}} {{${e.name}}}`),E||a(`Package testing: Started {{${e.category}}} {{${e.name}}}`);const N=Date.now(),I=new Date(N).toISOString();try{if(E)r={name:e.name,owner:null!==(m=null===(p=e.options)||void 0===p?void 0:p.owner)&&void 0!==m?m:"",category:e.category,logs:"",date:I,success:!0,result:S,ms:0,skipped:!0,package:null!=s?s:"",flaking:DG.Test.isReproducing};else{let t=null!=o?o:i;DG.Test.isProfiling&&console.profile(`${e.category}: ${e.name}`),r={name:e.name,owner:null!==(g=null===(f=e.options)||void 0===f?void 0:f.owner)&&void 0!==g?g:"",category:e.category,logs:"",date:I,success:!0,result:null!==(y=(yield $(e.test,t)).toString())&&void 0!==y?y:"OK",ms:0,skipped:!1,package:null!=s?s:"",flaking:DG.Test.isReproducing},DG.Test.isProfiling&&(console.profileEnd(`${e.category}: ${e.name}`),grok.shell.info(`Profiling of ${e.category}: ${e.name} finished \n Please ensure that you have opened DevTools (F12) / Performance panel before test starts.`))}}catch(t){u(t),r={name:e.name,owner:null!==(v=null===(b=e.options)||void 0===b?void 0:b.owner)&&void 0!==v?v:"",category:e.category,logs:"",date:I,success:!1,result:yield _(t),ms:0,skipped:!1,package:null!=s?s:"",flaking:!1}}if((null===(C=e.options)||void 0===C?void 0:C.isAggregated)&&r.result.constructor===DG.DataFrame){const e=r.result.col("success");if(e&&(r.success=e.stats.sum===e.length),!l){const e=r.result;e.columns.remove("stack"),e.rows.removeWhere((e=>e.get("success"))),r.result=e}r.result=r.result.toCsv()}if(r.logs=n.join("\n"),r.ms=Date.now()-N,E||a(`Package testing: Finished {{${e.category}}} {{${e.name}}} with {{${r.success?"success":"error"}}} for ${r.ms} ms`),r.success||a(`Package testing: Result for {{${e.category}}} {{${e.name}}}: ${r.result}`),r.category=e.category,r.name=e.name,r.owner=null!==(w=null===(x=e.options)||void 0===x?void 0:x.owner)&&void 0!==w?w:"",!T){let t={success:r.success,result:r.result,ms:r.ms,date:r.date,skipped:r.skipped,category:e.category,name:e.name,logs:r.logs,owner:r.owner,flaking:DG.Test.isReproducing&&r.success,package:r.package};if(r.result.constructor==Object){const e=Object.keys(r.result).reduce(((e,t)=>Object.assign(Object.assign({},e),{["result."+t]:r.result[t]})),{});t=Object.assign(Object.assign({},t),e)}t.result instanceof DG.DataFrame&&(t.result=JSON.stringify(null===(A=t.result)||void 0===A?void 0:A.toJson())||""),yield grok.shell.reportTest("package",t)}return r}))}function O(e){const t=e.slice();return t.sort((()=>Math.random()-.5)),t}function R(e){return r(this,void 0,void 0,(function*(){yield new Promise((t=>setTimeout(t,e)))}))}function $(e,t,n="EXECUTION TIMEOUT"){return r(this,void 0,void 0,(function*(){let o=null;const r=new Promise(((e,r)=>{o=setTimeout((()=>{r(n)}),t)}));try{return yield Promise.race([e(),r])}finally{o&&clearTimeout(o)}}))}DG.DataFrame.fromColumns([DG.Column.fromStrings("col",["val1","val2","val3"])]);var D=n(4328),B=n(6686);class F extends e.Package{async getTranslationHelper(){return await D.functions.call(`${this.name}:getTranslationHelper`)}}function k(e,t,n){return n.createFormatConverter(e,t).convertTo(B.NO.HELM)}function H(e,t,n){return n.createFormatConverter(e,B.NO.HELM).convertTo(t)}const G={Axolabs:{UfAfsCfsGfuacg:"RNA1{[fR](U)p.[fR](A)[sp].[fR](C)[sp].[fR](G)p.[25r](U)p.[25r](A)p.[25r](C)p.[25r](G)}$$$$"},BioSpring:{"A*GC*123456789":"RNA1{r(A)[sp].r(G)p.r(C)[sp].[fR](U)p.[fR](A)p.[fR](C)p.[fR](G)p.[25r](U)p.[25r](A)p.[25r](C)p.[25r](G)p.d([m5C])}$$$$"},Mermade12:{hefglijkLIJKHEFG:"RNA1{[25r](U)[sp].[25r](A)[sp].[25r](C)[sp].[25r](G)[sp].[fR](U)[sp].[fR](A)[sp].[fR](C)[sp].[fR](G)[sp].[fR](U)p.[fR](A)p.[fR](C)p.[fR](G)p.[25r](U)p.[25r](A)p.[25r](C)p.[25r](G)}$$$$"}},U={"RNA1{[fR](U)p.[fR](A)[sp].[fR](C)[sp].[fR](G)p.[25r](U)p.[25r](A)p.[25r](C)p.[25r](G)}$$$$":"UACGUACG","RNA1{r(A)[sp].r(G)p.r(C)[sp].[fR](U)p.[fR](A)p.[fR](C)p.[fR](G)p.[25r](U)p.[25r](A)p.[25r](C)p.[25r](G)p}$$$$":"AGCUACGUACG","RNA1{[25r](U)[sp].[25r](A)[sp].[25r](C)[sp].[25r](G)[sp].[fR](U)[sp].[fR](A)[sp].[fR](C)[sp].[fR](G)[sp].[fR](U)p.[fR](A)p.[fR](C)p.[fR](G)p.[25r](U)p.[25r](A)p.[25r](C)p.[25r](G)}$$$$":"UACGUACGUACGUACG"};S("Formats to HELM",(()=>{let e;N((async()=>{e=await we.getTranslationHelper()}));for(const t of Object.keys(G))for(const[n,o]of Object.entries(G[t]))x(`${t} to HELM`,(async()=>{const r=o;w(k(n,t,e),r)}))})),S("HELM to Formats",(()=>{let e;N((async()=>{e=await we.getTranslationHelper()}));for(const t of Object.keys(G))for(const[n,o]of Object.entries(G[t]))x(`${t} to HELM`,(async()=>{const r=n;w(H(o,t,e),r)}))}));var V=n(3480);S("HELM to Nucleotides",(()=>{let e;N((async()=>{e=await we.getTranslationHelper()})),Object.entries(U).forEach((([t,n],o)=>{x(`Sequence ${o+1} to nucleotides`,(async()=>{const o=n;w((0,V.Hs)(t,e.monomerLibWrapper),o)}))}))}));const j={[B.NO.AXOLABS]:"Afcgacsu",[B.NO.HELM]:"RNA1{[fR](A)p.[25r](C)p.[25r](G)p.[25r](A)p.[25r](C)[sp].[25r](U)}$$$$"};S("Formats support",(()=>{let e;N((async()=>{e=await we.getTranslationHelper()})),Object.entries(j).forEach((([t,n])=>{x(`All formats for ${t}`,(async()=>{const o=function(e,t,n){const o=n.createSequenceValidator(e).getInvalidCodeIndex(t);return(0,V.bD)(e,o,t,n)}(n,t,e),r=Object.keys(o).length;w(!0,Object.keys(G).length+1<=r)}))}))}));var q=n(9192);S("files",(()=>{let t;N((async()=>{t=await we.getTranslationHelper()})),x("list",(async()=>{let n;const o=e.DataFrame.fromColumns([e.Column.string("subTest"),n=e.Column.bool("success"),e.Column.string("format"),e.Column.string("src"),e.Column.string("res"),e.Column.string("tgt"),e.Column.string("error"),e.Column.string("stack")]),r=await we.files.list("tests",!0,".csv");for(const n of r){const r=e.DataFrame.fromCsv(await n.readAsString()),i=r.columns.byIndex(0),s=i.name,a=r.columns.byIndex(1),l=r.rowCount;for(let e=0;e<l;++e){const r=o.rows.addNew();r.subTest=`${n.name}, row: ${e}`;try{const n=i.get(e),o=a.get(e);r.format=s,r.src=n,r.tgt=o,w(r.res=k(n,s,t),o),r.success=!0}catch(e){const[t,n]=(0,q.AP)(e);r.error=t,r.stack=n,r.success=!1}}}0==o.rowCount&&o.rows.addNew(["empty",!0,"",""]);const i=n.toList().findIndex((e=>1!=e));if(-1!=i){const e=o.rows.get(i);throw new Error(`Subtest '${e.subTest}' failed: ${e.error}`)}return o}),{skipReason:"Can not create test in async manner based on files in Shares."})}));var W=n(8312),z=n(2003);class Y{constructor(e,t,n,o,r,i){this.units=e,this.aligned=t,this.alphabet=n,this.alphabetSize=o,this.alphabetIsMultichar=r,this.separator=i}}async function K(t,n){const o=(await t()).getCol(n),r=await D.functions.call("Bio:detectMacromolecule",{col:o});if(r&&(o.semType=r),o.semType===e.SEMTYPE.MACROMOLECULE){const e=`Negative test detected semType='${o.semType}', units='${o.meta.units}'.`;throw new Error(e)}}async function Q(t,n,o,r,i,s,a,l,c=null){const u=(await t()).col(n),h=await D.functions.call("Bio:detectMacromolecule",{col:u});h&&(u.semType=h),w(u.semType,e.SEMTYPE.MACROMOLECULE),w(u.meta.units,r),w(u.getTag(z.gp.aligned),i),w(u.getTag(z.gp.alphabet),s),c&&w(u.getTag(z.gp.separator),c);const d=o.getSeqHandler(u);w(d.getAlphabetSize(),a),w(d.getAlphabetIsMultichar(),l),d.isHelm()||(w(d.aligned,i),w(d.alphabet,s))}S("PolyTool: detectors",(()=>{let t;N((async()=>{t=await(0,W.Q)()}));const n={cyclized1:{csv:"n,seq\n1,R-F-C(1)-T-G-H-F-Y-G-H-F-Y-G-H-F-Y-P-C(1)-meI\n2,C(1)-T-G-H-F-Y-P-C(1)-meI\n3,R-F-C(1)-T-G-H-F-Y-P-C(1)\n4,C(1)-T-G-H-F-H-P-C(1)\n5,R-F-D(2)-T-G-H-F-Y-P-NH2(2)\n6,R-F-aG(4)-T-G-H-F-Y-P-azG(4)-meI",pos:{seq:new Y(z.Hi.CUSTOM,"SEQ",z.YI.UN,13,!0,"-")}}};for(const[o,r]of Object.entries(n))x(`${o}`,(async()=>{const n=async()=>e.DataFrame.fromCsv(r.csv);for(const e of r.neg??[])await K(n,e);for(const[e,o]of Object.entries(r.pos??{}))await Q(n,e,t,o.units,o.aligned,o.alphabet,o.alphabetSize,o.alphabetIsMultichar,o.separator)}),{skipReason:"3156"})}));var J=n(4971);const X="Libraries",Z="Settings",ee="DuplicateMonomerPreferences",te=4e3,ne="nextChunk";let oe=Promise.resolve();async function re(){let e;return oe=oe.then((async()=>{const t=await D.userSettings.getValue(X,Z,!0);e=t?JSON.parse(t):{exclude:[],explicit:[],duplicateMonomerPreferences:{}};const n=await async function(){let e=await D.userSettings.getValue(X,ee,!0)??"";if(!e)return{};for(;e.endsWith(ne);){const t=`${ee}${e.charAt(e.length-9-1)}`,n=await D.userSettings.getValue(X,t,!0)??"";e=e.slice(0,e.length-9-1)+n}return JSON.parse(e)}();e.exclude=e.exclude instanceof Array?e.exclude:[],e.explicit=e.explicit instanceof Array?e.explicit:[],e.duplicateMonomerPreferences=e.duplicateMonomerPreferences instanceof Object?e.duplicateMonomerPreferences:{};for(const t in n){e.duplicateMonomerPreferences[t]=e.duplicateMonomerPreferences[t]??{};for(const o in n[t])for(const r of n[t][o])e.duplicateMonomerPreferences[t][r]=o}})),await oe,e}async function ie(e){oe=oe.then((async()=>{e.duplicateMonomerPreferences=e.duplicateMonomerPreferences??{};const t={};for(const n in e.duplicateMonomerPreferences){t[n]={};for(const o in e.duplicateMonomerPreferences[n]){const r=e.duplicateMonomerPreferences[n][o];t[n][r]=t[n][r]??[],t[n][r].push(o)}}await async function(e){const t=JSON.stringify(e),n=Math.ceil(t.length/te);for(let e=0;e<n;e++){const o=0===e?ee:`${ee}${e}`,r=e<n-1?`${e+1}`:"",i=t.slice(e*te,(e+1)*te),s=r?i+r+ne:i;await D.userSettings.add(X,o,s,!0)}}(t),e.duplicateMonomerPreferences={},await D.userSettings.add(X,Z,JSON.stringify(e),!0)})),await oe}var se=n(6717),ae=n(9124),le=n(4229),ce=n(5174),ue=n(6694);S("PolyTool: Convert",(()=>{let t,n,o,i,s;N((async()=>{o=await(0,se.j)(),t=await(0,ae.b2)(),n=await(0,W.Q)(),i=await(0,J.pj)(),s=await re(),await i.loadMonomerLibForTests()})),I((async()=>{await ie(s),await i.loadMonomerLib(!0)}));const a={"cyclized-C(1)-2-1":{src:{seq:"R-F-C(1)-T-G-H-F-Y-P-C(1)-meI"},tgt:{helm:"PEPTIDE1{R.F.C.T.G.H.F.Y.P.C.[meI]}$PEPTIDE1,PEPTIDE1,3:R3-10:R3$$$V2.0",mol:{atomCount:95,bondCount:100,inchiKey:"LMJUFVBPWWJJPN-AJJYTACESA-N"}}},"cyclized-C(1)-0-1":{src:{seq:"C(1)-T-G-H-F-Y-P-C(1)-meI"},tgt:{helm:"PEPTIDE1{C.T.G.H.F.Y.P.C.[meI]}$PEPTIDE1,PEPTIDE1,1:R3-8:R3$$$V2.0",mol:{atomCount:73,bondCount:77,inchiKey:"KLFRBMUPPMMGJM-HXTBFBBASA-N"}}},"cyclized-C(1)-0-0":{src:{seq:"C(1)-T-G-H-F-Y-P-C(1)"},tgt:{helm:"PEPTIDE1{C.T.G.H.F.Y.P.C}$PEPTIDE1,PEPTIDE1,1:R3-8:R3$$$V2.0",mol:{atomCount:64,bondCount:68,inchiKey:"LOSMDBLEXLWPLB-OFZKBENXSA-N"}}},"cyclized-D(2)-NH2(2)-3-0":{src:{seq:"R-F-D(2)-T-G-H-F-Y-P-NH2(2)"},tgt:{helm:"PEPTIDE1{R.F.D.T.G.H.F.Y.P.[NH2]}$PEPTIDE1,PEPTIDE1,3:R3-10:R2$$$V2.0",mol:{atomCount:81,bondCount:86,inchiKey:"CBMGNYKOZWNVNK-AHGCAHLCSA-N"}}},"cyclized-D(2)-NH2(2)-0-0":{src:{seq:"D(2)-T-G-H-F-Y-P-NH2(2)"},tgt:{helm:"PEPTIDE1{D.T.G.H.F.Y.P.[NH2]}$PEPTIDE1,PEPTIDE1,1:R3-8:R2$$$V2.0",mol:{atomCount:59,bondCount:63,inchiKey:"HGRHAUQBJXFERJ-MUFWPYSASA-N"}}}};for(const[e,n]of Object.entries(a))x(`toHelm-${e}`,(async()=>{const e=await(0,ue.Q4)(["rules_example.json"]);w((0,le.b)([n.src.seq],e,t)[0][0],n.tgt.helm)}));for(const[r,i]of Object.entries(a))x(`toAtomicLevel-${r}`,(async()=>{const r=await(0,ue.Q4)(["rules_example.json"]),[s,a,l]=(0,le.b)([i.src.seq],r,t),c=await(0,ce.A)(r),u=e.Column.fromStrings("helm",s);u.semType=e.SEMTYPE.MACROMOLECULE,u.meta.units=z.Hi.HELM;const h=await n.helmToAtomicLevel(u,!1,!1,c);if(h.warnings&&h.warnings.length>0)throw new Error(h.warnings[0]);w(null!=h.molCol,!0,".molCol is not null");const d=h.molCol.get(0),p=o.get_mol(d);try{T({atomCount:p.get_num_atoms(),bondCount:p.get_num_bonds(),inchiKey:o.get_inchikey_for_inchi(p.get_inchi())},i.tgt.mol)}finally{p.delete()}}));x("ui-col-wo-table",(async()=>{const t=we.name,n=Object.values(a).map((e=>e.src.seq)),o=Object.values(a).map((e=>e.tgt.helm)),r=e.Column.fromStrings("seq",n),i=await D.functions.call(`${t}:polyToolConvert2`,{seqCol:r,generateHelm:!0,chiralityEngine:!0,rules:["rules_example.json"]});E(i.toList(),o),w(i.semType,e.SEMTYPE.MACROMOLECULE),w(i.meta.units,z.Hi.HELM),w(i.dataFrame,null)})),x("ui-col",(async()=>{const t=we.name,n=Object.values(a).map((e=>e.src.seq)),o=Object.values(a).map((e=>e.tgt.helm)),i=e.Column.fromStrings("seq",n),s=e.DataFrame.fromColumns([i]),l=D.shell.addTableView(s),c=await D.functions.call(`${t}:polyToolConvert2`,{seqCol:i,generateHelm:!0,chiralityEngine:!0,rules:["rules_example.json"]});E(c.toList(),o),w(c.semType,e.SEMTYPE.MACROMOLECULE),w(c.meta.units,z.Hi.HELM),w(c.dataFrame.id,s.id),await function(e,t,n,o=0,i="timeout"){return r(this,void 0,void 0,(function*(){return new Promise(((r,s)=>{const a=e.subscribe((e=>{try{t(e),r("OK")}catch(e){s(e)}finally{a.unsubscribe(),clearTimeout(l)}})),l=setTimeout((()=>{a.unsubscribe(),s(i)}),o);n()}))}))}(l.grid.onAfterDrawContent,(()=>{}),(async()=>{l.grid.invalidate()}),15e3),w(c.getTag(e.TAGS.CELL_RENDERER),"helm")}))}));var he=n(1296),de=n(3820);S("PolyTool: Enumerate",(()=>{let e,t,n;N((async()=>{e=await(0,ae.b2)(),t=await(0,J.pj)(),n=await re(),await t.loadMonomerLibForTests()})),I((async()=>{await ie(n),await t.loadMonomerLib(!0)}));const o={single1:{src:"PEPTIDE1{[Ac(1)].F.W.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",params:{type:he.aK.Single,placeholders:[{position:4,monomers:["K","P","F4COO"]},{position:6,monomers:["Y","T"]}]},tgt:[{seq:"PEPTIDE1{[Ac(1)].F.W.G.K.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-P5K"},{seq:"PEPTIDE1{[Ac(1)].F.W.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-P5P"},{seq:"PEPTIDE1{[Ac(1)].F.W.G.[F4COO].L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-P5[F4COO]"},{seq:"PEPTIDE1{[Ac(1)].F.W.G.P.L.Y.[C(1)].G.[NH2]}$$$$V2.0",name:"-[Tic]7Y"},{seq:"PEPTIDE1{[Ac(1)].F.W.G.P.L.T.[C(1)].G.[NH2]}$$$$V2.0",name:"-[Tic]7T"}]},"single-with-original":{src:"PEPTIDE1{[Ac(1)].F.W.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",params:{type:he.aK.Single,placeholders:[{position:4,monomers:["K","P","F4COO"]},{position:6,monomers:["Y","T"]}],keepOriginal:!0},tgt:[{seq:"PEPTIDE1{[Ac(1)].F.W.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:""},{seq:"PEPTIDE1{[Ac(1)].F.W.G.K.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-P5K"},{seq:"PEPTIDE1{[Ac(1)].F.W.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-P5P"},{seq:"PEPTIDE1{[Ac(1)].F.W.G.[F4COO].L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-P5[F4COO]"},{seq:"PEPTIDE1{[Ac(1)].F.W.G.P.L.Y.[C(1)].G.[NH2]}$$$$V2.0",name:"-[Tic]7Y"},{seq:"PEPTIDE1{[Ac(1)].F.W.G.P.L.T.[C(1)].G.[NH2]}$$$$V2.0",name:"-[Tic]7T"}]},parallel1:{src:"PEPTIDE1{[Ac(1)].F.W.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",params:{type:he.aK.Parallel,placeholders:[{position:1,monomers:["D","L"]},{position:6,monomers:["Y","T"]}]},tgt:[{seq:"PEPTIDE1{[Ac(1)].D.W.G.P.L.Y.[C(1)].G.[NH2]}$$$$V2.0",name:"-F2D-[Tic]7Y"},{seq:"PEPTIDE1{[Ac(1)].L.W.G.P.L.T.[C(1)].G.[NH2]}$$$$V2.0",name:"-F2L-[Tic]7T"}]},"parallel-three-positions":{src:"PEPTIDE1{[Ac(1)].F.W.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",params:{type:he.aK.Parallel,placeholders:[{position:1,monomers:["D","L","K"]},{position:4,monomers:["K","P","F4COO"]},{position:6,monomers:["Y","T","A"]}]},tgt:[{seq:"PEPTIDE1{[Ac(1)].D.W.G.K.L.Y.[C(1)].G.[NH2]}$$$$V2.0",name:"-F2D-P5K-[Tic]7Y"},{seq:"PEPTIDE1{[Ac(1)].L.W.G.P.L.T.[C(1)].G.[NH2]}$$$$V2.0",name:"-F2L-P5P-[Tic]7T"},{seq:"PEPTIDE1{[Ac(1)].K.W.G.[F4COO].L.A.[C(1)].G.[NH2]}$$$$V2.0",name:"-F2K-P5[F4COO]-[Tic]7A"}]},"parallel-with-original":{src:"PEPTIDE1{[Ac(1)].F.W.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",params:{type:he.aK.Parallel,placeholders:[{position:1,monomers:["D","L"]},{position:6,monomers:["Y","T"]}],keepOriginal:!0},tgt:[{seq:"PEPTIDE1{[Ac(1)].F.W.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:""},{seq:"PEPTIDE1{[Ac(1)].D.W.G.P.L.Y.[C(1)].G.[NH2]}$$$$V2.0",name:"-F2D-[Tic]7Y"},{seq:"PEPTIDE1{[Ac(1)].L.W.G.P.L.T.[C(1)].G.[NH2]}$$$$V2.0",name:"-F2L-[Tic]7T"}]},"parallel-single-position":{src:"PEPTIDE1{[Ac(1)].F.W.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",params:{type:he.aK.Parallel,placeholders:[{position:4,monomers:["K","P","F4COO"]}]},tgt:[{seq:"PEPTIDE1{[Ac(1)].F.W.G.K.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-P5K"},{seq:"PEPTIDE1{[Ac(1)].F.W.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-P5P"},{seq:"PEPTIDE1{[Ac(1)].F.W.G.[F4COO].L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-P5[F4COO]"}]},matrix1:{src:"PEPTIDE1{[Ac(1)].F.W.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",params:{type:he.aK.Matrix,placeholders:[{position:1,monomers:["D","L"]},{position:4,monomers:["K","P","F4COO"]},{position:6,monomers:["Y","T"]}]},tgt:[{seq:"PEPTIDE1{[Ac(1)].D.W.G.K.L.Y.[C(1)].G.[NH2]}$$$$V2.0",name:"-F2D-P5K-[Tic]7Y"},{seq:"PEPTIDE1{[Ac(1)].D.W.G.K.L.T.[C(1)].G.[NH2]}$$$$V2.0",name:"-F2D-P5K-[Tic]7T"},{seq:"PEPTIDE1{[Ac(1)].D.W.G.P.L.Y.[C(1)].G.[NH2]}$$$$V2.0",name:"-F2D-P5P-[Tic]7Y"},{seq:"PEPTIDE1{[Ac(1)].D.W.G.P.L.T.[C(1)].G.[NH2]}$$$$V2.0",name:"-F2D-P5P-[Tic]7T"},{seq:"PEPTIDE1{[Ac(1)].D.W.G.[F4COO].L.Y.[C(1)].G.[NH2]}$$$$V2.0",name:"-F2D-P5[F4COO]-[Tic]7Y"},{seq:"PEPTIDE1{[Ac(1)].D.W.G.[F4COO].L.T.[C(1)].G.[NH2]}$$$$V2.0",name:"-F2D-P5[F4COO]-[Tic]7T"},{seq:"PEPTIDE1{[Ac(1)].L.W.G.K.L.Y.[C(1)].G.[NH2]}$$$$V2.0",name:"-F2L-P5K-[Tic]7Y"},{seq:"PEPTIDE1{[Ac(1)].L.W.G.K.L.T.[C(1)].G.[NH2]}$$$$V2.0",name:"-F2L-P5K-[Tic]7T"},{seq:"PEPTIDE1{[Ac(1)].L.W.G.P.L.Y.[C(1)].G.[NH2]}$$$$V2.0",name:"-F2L-P5P-[Tic]7Y"},{seq:"PEPTIDE1{[Ac(1)].L.W.G.P.L.T.[C(1)].G.[NH2]}$$$$V2.0",name:"-F2L-P5P-[Tic]7T"},{seq:"PEPTIDE1{[Ac(1)].L.W.G.[F4COO].L.Y.[C(1)].G.[NH2]}$$$$V2.0",name:"-F2L-P5[F4COO]-[Tic]7Y"},{seq:"PEPTIDE1{[Ac(1)].L.W.G.[F4COO].L.T.[C(1)].G.[NH2]}$$$$V2.0",name:"-F2L-P5[F4COO]-[Tic]7T"}]}};for(const[e,t]of Object.entries(o))x(`${e}`,(async()=>{E((0,de.o)(t.src,"",t.params),t.tgt.map((e=>[e.seq,e.name])))}))})),S("PolyTool: Enumerate",(()=>{let e,t,n;N((async()=>{e=await(0,ae.b2)(),t=await(0,J.pj)(),n=await re(),await t.loadMonomerLibForTests()})),I((async()=>{await ie(n),await t.loadMonomerLib(!0)}));const o={breadth1:{src:"PEPTIDE1{[Ac(1)].F.W.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",params:{type:he.aK.Single,breadthPlaceholders:[{start:2,end:4,monomers:["K"]}]},tgt:[{seq:"PEPTIDE1{[Ac(1)].F.K.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-W3K"},{seq:"PEPTIDE1{[Ac(1)].F.W.K.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-G4K"},{seq:"PEPTIDE1{[Ac(1)].F.W.G.K.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-P5K"}]},"breadth1-with-original":{src:"PEPTIDE1{[Ac(1)].F.W.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",params:{type:he.aK.Single,breadthPlaceholders:[{start:2,end:4,monomers:["K"]}],keepOriginal:!0},tgt:[{seq:"PEPTIDE1{[Ac(1)].F.W.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:""},{seq:"PEPTIDE1{[Ac(1)].F.K.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-W3K"},{seq:"PEPTIDE1{[Ac(1)].F.W.K.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-G4K"},{seq:"PEPTIDE1{[Ac(1)].F.W.G.K.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-P5K"}]},breadth2:{src:"PEPTIDE1{[Ac(1)].F.W.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",params:{type:he.aK.Single,breadthPlaceholders:[{start:2,end:4,monomers:["K","Y"]}]},tgt:[{seq:"PEPTIDE1{[Ac(1)].F.K.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-W3K"},{seq:"PEPTIDE1{[Ac(1)].F.W.K.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-G4K"},{seq:"PEPTIDE1{[Ac(1)].F.W.G.K.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-P5K"},{seq:"PEPTIDE1{[Ac(1)].F.Y.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-W3Y"},{seq:"PEPTIDE1{[Ac(1)].F.W.Y.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-G4Y"},{seq:"PEPTIDE1{[Ac(1)].F.W.G.Y.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-P5Y"}]},"breadth-double":{src:"PEPTIDE1{[Ac(1)].F.W.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",params:{type:he.aK.Single,breadthPlaceholders:[{start:2,end:4,monomers:["K"]},{start:2,end:4,monomers:["Y"]}]},tgt:[{seq:"PEPTIDE1{[Ac(1)].F.Y.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-W3K-K3Y"},{seq:"PEPTIDE1{[Ac(1)].F.K.Y.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-W3K-G4Y"},{seq:"PEPTIDE1{[Ac(1)].F.K.G.Y.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-W3K-P5Y"},{seq:"PEPTIDE1{[Ac(1)].F.Y.K.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-G4K-W3Y"},{seq:"PEPTIDE1{[Ac(1)].F.W.Y.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-G4K-K4Y"},{seq:"PEPTIDE1{[Ac(1)].F.W.K.Y.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-G4K-P5Y"},{seq:"PEPTIDE1{[Ac(1)].F.Y.G.K.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-P5K-W3Y"},{seq:"PEPTIDE1{[Ac(1)].F.W.Y.K.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-P5K-G4Y"},{seq:"PEPTIDE1{[Ac(1)].F.W.G.Y.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-P5K-K5Y"}]}};for(const[e,t]of Object.entries(o))x(`${e}`,(async()=>{E((0,de.o)(t.src,"",t.params),t.tgt.map((e=>[e.seq,e.name])))}))}));var pe=n(3309);function me(e,t){const n=t.get_mol(e);try{return w(n.is_valid(),!0,`RDKit rejected SMILES: ${e}`),n.get_smiles()}finally{n.delete()}}S("PolyTool: ChemEnum: R-labels",(()=>{x("extract from every supported form",(async()=>{E((0,pe.Qk)("C[1*]"),[1]),E((0,pe.Qk)("C[*:1]"),[1]),E((0,pe.Qk)("C[*1]"),[1]),E((0,pe.Qk)("C[R1]"),[1]),E((0,pe.Qk)("C[R:1]"),[1])})),x("extract multi-digit numbers",(async()=>{E((0,pe.Qk)("C1CC(C[*:100])(N[*:1])C([*:101])N1[*:2]"),[1,2,100,101]),E((0,pe.Qk)("C[R100]N[R:101]"),[100,101])})),x("normalize all spellings to [*:N]",(async()=>{w((0,pe.j7)("C[1*]"),"C[*:1]"),w((0,pe.j7)("C[*:1]"),"C[*:1]"),w((0,pe.j7)("C[*1]"),"C[*:1]"),w((0,pe.j7)("C[R1]"),"C[*:1]"),w((0,pe.j7)("C[R:1]"),"C[*:1]"),w((0,pe.j7)("C[R100]N[R:101]"),"C[*:100]N[*:101]")})),x("remap the one-and-only R-label to a new slot",(async()=>{w((0,pe.aj)("C[1*]",5),"C[*:5]"),w((0,pe.aj)("C[R:3]CC",1),"C[*:1]CC"),w((0,pe.aj)("[*:7]C",2),"[*:2]C")})),x("deduplicate repeated R numbers",(async()=>{E((0,pe.Qk)("C[*:1]C[*:1]"),[1])})),x("normalize does not touch regular bracket atoms",(async()=>{w((0,pe.j7)("C[NH3+]C[*:1]"),"C[NH3+]C[*:1]"),w((0,pe.j7)("[13C]C[*:2]"),"[13C]C[*:2]")}))})),S("PolyTool: ChemEnum: SMILES surgery",(()=>{x("moveStartRLabelToBranch: bare atom at start",(async()=>{w((0,pe.z9)("[*:1]CC"),"C([*:1])C"),w((0,pe.z9)("[*:1]Cl"),"Cl([*:1])"),w((0,pe.z9)("[*:1][NH3+]C"),"[NH3+]([*:1])C")})),x("moveStartRLabelToBranch: with explicit bond",(async()=>{w((0,pe.z9)("[*:1]=CC"),"C(=[*:1])C"),w((0,pe.z9)("[*:1]#C"),"C(#[*:1])")})),x("moveStartRLabelToBranch: leaves interior unchanged",(async()=>{w((0,pe.z9)("CC[*:1]"),"CC[*:1]"),w((0,pe.z9)("CC([*:1])CC"),"CC([*:1])CC")})),x("substituteRLabelWithRingDigit collapses branch form",(async()=>{w((0,pe.yw)("CC([*:1])CC",1,"9"),"CC9CC"),w((0,pe.yw)("CC([*:2])([*:1])CC",1,"%50"),"CC([*:2])%50CC")})),x("substituteRLabelWithRingDigit handles trailing form",(async()=>{w((0,pe.yw)("CC[*:1]",1,"7"),"CC7"),w((0,pe.yw)("CC=[*:2]",2,"%42"),"CC=%42")})),x("pickFreeRingDigits avoids digits already in use",(async()=>{const e=(0,pe.Ii)(["C1CCCCC1[*:1]","[*:1]C"],2);w(e.includes(1),!1),w(e.length,2)})),x("pickFreeRingDigits ignores digits inside bracket atoms",(async()=>{E((0,pe.Ii)(["C[*:1]","[*:1]C"],1),[1])}))})),S("PolyTool: ChemEnum: validators",(()=>{x("core without any R-label is rejected",(async()=>{w(null!=(0,pe.KS)("CCO","row 1").error,!0)})),x("r-group with zero R-labels is rejected",(async()=>{w(null!=(0,pe.ah)("CC",1,"row 1").error,!0)})),x("r-group with multiple R-labels is rejected",(async()=>{w(null!=(0,pe.ah)("[*:1]CC[*:2]",1,"row 1").error,!0)})),x("r-group with wrong R-number is auto-remapped",(async()=>{const e=(0,pe.ah)("CC[*:3]",1,"row 1");w(null==e.error,!0),w(e.rNumber,1),w(e.sourceRNumber,3),w(e.smiles,"CC[*:1]")}))})),S("PolyTool: ChemEnum: count & validate",(()=>{x("zip length mismatch is flagged",(async()=>{const e=(0,pe.KS)("C[*:1]C[*:2]","c1"),t=(0,pe.XB)({cores:[e],rGroups:new Map([[1,[(0,pe.ah)("C[*:1]",1,"r1-a"),(0,pe.ah)("N[*:1]",1,"r1-b")]],[2,[(0,pe.ah)("O[*:2]",2,"r2-a")]]]),mode:pe.PI.Zip});w(t.ok,!1),w(t.errors.some((e=>e.includes("Zip"))),!0)})),x("cartesian count = product across Rs, summed over cores",(async()=>{const e=(0,pe.KS)("C[*:1]","a"),t=(0,pe.KS)("C[*:1]N[*:2]","b"),n=(0,pe.XB)({cores:[e,t],rGroups:new Map([[1,[(0,pe.ah)("C[*:1]",1,"a"),(0,pe.ah)("N[*:1]",1,"b"),(0,pe.ah)("O[*:1]",1,"c")]],[2,[(0,pe.ah)("C[*:2]",2,"a"),(0,pe.ah)("N[*:2]",2,"b")]]]),mode:pe.PI.Cartesian});w(n.predictedCount,9),w(n.ok,!0)})),x("zip count = N per core, summed",(async()=>{const e=(0,pe.KS)("C[*:1]","a"),t=(0,pe.KS)("C[*:1]N[*:2]","b");w((0,pe.XB)({cores:[e,t],rGroups:new Map([[1,[(0,pe.ah)("C[*:1]",1,"a"),(0,pe.ah)("N[*:1]",1,"b")]],[2,[(0,pe.ah)("O[*:2]",2,"a"),(0,pe.ah)("S[*:2]",2,"b")]]]),mode:pe.PI.Zip}).predictedCount,4)})),x("uncovered R-number is flagged per core",(async()=>{const e=(0,pe.KS)("C[*:1]N[*:7]","c"),t=(0,pe.XB)({cores:[e],rGroups:new Map([[1,[(0,pe.ah)("O[*:1]",1,"a")]]]),mode:pe.PI.Cartesian});w(t.ok,!1),w(t.errors.some((e=>e.includes("R7"))),!0)})),x("hard cap rejects over-limit enumerations",(async()=>{const e=(0,pe.KS)("C[*:1]N[*:2]","c"),t=Array.from({length:1e3},((e,t)=>(0,pe.ah)("C[*:1]",1,`r1-${t}`))),n=Array.from({length:1001},((e,t)=>(0,pe.ah)("O[*:2]",2,`r2-${t}`))),o=(0,pe.XB)({cores:[e],rGroups:new Map([[1,t],[2,n]]),mode:pe.PI.Cartesian,maxResults:1e6});w(o.overCap,!0),w(o.ok,!1)})),x("countForCore: zip with mismatched per-core lengths → -1",(async()=>{const e=(0,pe.KS)("C[*:1]N[*:2]","c"),{count:t}=(0,pe.k5)(e,new Map([[1,[(0,pe.ah)("C[*:1]",1,"a"),(0,pe.ah)("N[*:1]",1,"b")]],[2,[(0,pe.ah)("O[*:2]",2,"a")]]]),pe.PI.Zip);w(t,-1)}))})),S("PolyTool: ChemEnum: assembly",(()=>{let e;N((async()=>{e=await(0,se.j)()})),x("single R-group: joins correctly",(async()=>{const t=(0,pe.BG)("C[*:1]",new Map([[1,"O[*:1]"]]),e);w(null!=t,!0),w(t,me("CO",e))})),x("multi R-group: R1 and R2 both joined",(async()=>{const t=(0,pe.BG)("C[*:1]N[*:2]",new Map([[1,"O[*:1]"],[2,"S[*:2]"]]),e);w(null!=t,!0),w(t,me("OCNS",e))})),x("R-label at SMILES start is handled",(async()=>{const t=(0,pe.BG)("[*:1]CC",new Map([[1,"Br[*:1]"]]),e);w(null!=t,!0),w(t,me("BrCC",e))})),x("core uses existing ring digit 1 — free digit is picked",(async()=>{const t=(0,pe.BG)("C1CCCCC1[*:1]",new Map([[1,"O[*:1]"]]),e);w(null!=t,!0),w(t,me("OC1CCCCC1",e))})),x("multi-digit R numbers (R100, R101)",(async()=>{const t=(0,pe.BG)("C1CC(C[*:100])(N[*:1])C([*:101])N1[*:2]",new Map([[1,"C[*:1]"],[2,"C[*:2]"],[100,"C[*:100]"],[101,"C[*:101]"]]),e);w(null!=t,!0);const n=e.get_mol(t);try{w(n.is_valid(),!0),w(t.includes("[*:"),!1)}finally{n.delete()}}))})),S("PolyTool: ChemEnum: enumerate",(()=>{let e;N((async()=>{e=await(0,se.j)()})),x("cartesian across two cores with different R-sets",(async()=>{const t=(0,pe.KS)("C[*:1]","A"),n=(0,pe.KS)("C[*:1]N[*:2]","B"),o=[(0,pe.ah)("O[*:1]",1,"r1-a"),(0,pe.ah)("S[*:1]",1,"r1-b")],r=[(0,pe.ah)("C[*:2]",2,"r2-a"),(0,pe.ah)("N[*:2]",2,"r2-b"),(0,pe.ah)("F[*:2]",2,"r2-c")],i=(0,pe.HL)({cores:[t,n],rGroups:new Map([[1,o],[2,r]]),mode:pe.PI.Cartesian},e);w(i.length,8);const s=i.filter((e=>"C[*:1]"===e.coreSmiles)),a=i.filter((e=>"C[*:1]N[*:2]"===e.coreSmiles));w(s.length,2),w(a.length,6)})),x("zip across two cores with shared R-list length",(async()=>{const t=(0,pe.KS)("C[*:1]","A"),n=(0,pe.KS)("C[*:1]N[*:2]","B"),o=[(0,pe.ah)("O[*:1]",1,"r1-a"),(0,pe.ah)("S[*:1]",1,"r1-b")],r=[(0,pe.ah)("C[*:2]",2,"r2-a"),(0,pe.ah)("N[*:2]",2,"r2-b")],i=(0,pe.HL)({cores:[t,n],rGroups:new Map([[1,o],[2,r]]),mode:pe.PI.Zip},e);w(i.length,4);const s=i.filter((e=>"C[*:1]N[*:2]"===e.coreSmiles));w(s.length,2),w(s[0].rGroupSmilesByNum.get(1),"O[*:1]"),w(s[0].rGroupSmilesByNum.get(2),"C[*:2]"),w(s[1].rGroupSmilesByNum.get(1),"S[*:1]"),w(s[1].rGroupSmilesByNum.get(2),"N[*:2]")})),x("invalid params return null from enumerate()",(async()=>{const t=(0,pe.KS)("C[*:1]N[*:2]","c");w((0,pe.HL)({cores:[t],rGroups:new Map([[1,[(0,pe.ah)("O[*:1]",1,"x")]]]),mode:pe.PI.Cartesian},e),null)}))})),S("PolyTool: ChemEnum: CSV fixtures",(()=>{let t;async function n(t){const n=await we.files.readAsText(t);return e.DataFrame.fromCsv(n)}N((async()=>{t=await(0,se.j)()})),x("cores file parses and all rows validate",(async()=>{const e=(await n("tests/chem_enum_cores.csv")).col("Core"),o=Array.from({length:e.length},((n,o)=>(0,pe.KS)(e.get(o),`Cores[${o}]`,t)));w(o.length,4),w(o.every((e=>!e.error)),!0,o.map((e=>e.error??"")).filter((e=>e)).join("; "));for(const e of o)w(e.rNumbers.includes(1)&&e.rNumbers.includes(2),!0,`core ${e.id} R-numbers: ${e.rNumbers}`)})),x("r-groups file: columns R1, R2, R3 populate their slots",(async()=>{const e=await n("tests/chem_enum_rgroups.csv"),o=(n,o)=>{const r=e.col(n),i=[];for(let e=0;e<r.length;e++){const s=r.get(e);null!=s&&""!==String(s).trim()&&i.push((0,pe.ah)(String(s),o,`${n}[${e}]`,t))}return i},r=o("R1",1),i=o("R2",2),s=o("R3",3);w(r.length,4),w(i.length,4),w(s.length,1);for(const e of[r,i,s])w(e.every((e=>!e.error)),!0,e.map((e=>e.error??"")).filter((e=>e)).join("; "))})),x("end-to-end cartesian with CSV fixtures produces valid, canonical SMILES",(async()=>{const e=await n("tests/chem_enum_cores.csv"),o=await n("tests/chem_enum_rgroups.csv"),r=e.col("Core"),i=Array.from({length:r.length},((e,n)=>(0,pe.KS)(r.get(n),`Cores[${n}]`,t))),s=new Map;for(const e of["R1","R2","R3"]){const n=parseInt(e.substring(1),10),r=o.col(e),i=[];for(let o=0;o<r.length;o++){const s=r.get(o);null!=s&&""!==String(s).trim()&&i.push((0,pe.ah)(String(s),n,`${e}[${o}]`,t))}s.set(n,i)}const a=(0,pe.HL)({cores:i,rGroups:s,mode:pe.PI.Cartesian},t);w(null!=a&&a.length>0,!0);for(const e of a){w(e.smiles.includes("[*:"),!1,`residual R-label in result: ${e.smiles}`);const n=t.get_mol(e.smiles);try{w(n.is_valid(),!0,`invalid SMILES: ${e.smiles}`)}finally{n.delete()}}}))}));var fe=n(6307),ge=n(2125);S("PolyTool: Chain: parseNotation",(()=>{let e;N((async()=>{e=await(0,ae.b2)()}));const t={cyclized:{src:{seq:"R-F-C(1)-T-G-H-F-Y-P-C(1)-meI"},tgt:{helm:"PEPTIDE1{R.F.[C(1)].T.G.H.F.Y.P.[C(1)].[meI]}$$$$V2.0"}},dimerized1:{src:{seq:"(#3)Succ-{A(CHOL)-F-C(1)-T-G-H-Y-P-C(1)-NH2}"},tgt:{helm:"PEPTIDE1{[(#3)Succ]}|PEPTIDE2{[A(CHOL)].F.[C(1)].T.G.H.Y.P.[C(1)].[NH2]}$PEPTIDE1,PEPTIDE2,1:R1-1:R1$$$V2.0"}},dimerized2:{src:{seq:"($3)Succ-{R-F-C(1)-T-G-H-F-P-C(1)-NH2}($2){A(CHOL)-F-C(1)-T-G-H-F-P-C(1)-NH2}"},tgt:{helm:"PEPTIDE1{[($3)Succ]}|PEPTIDE2{R.F.[C(1)].T.G.H.F.P.[C(1)].[NH2]}|PEPTIDE3{[($2)A(CHOL)].F.[C(1)].T.G.H.F.P.[C(1)].[NH2]}$PEPTIDE1,PEPTIDE2,1:R1-1:R1$$$V2.0"}}};for(const[n,o]of Object.entries(t))x(`${n}`,(async()=>{await(0,ue.Q4)(["rules_example.json"]);const t=await fe.s.fromSeparator(o.src.seq,e),n=t.mol,r=e.createHelmWebEditor();r.editor.setMol(n);const i=r.editor.getHelm(),s=t.getHelm();w(i,o.tgt.helm),w(s,o.tgt.helm)}),"reaction2"==n?{skipReason:"reverse reaction"}:void 0);const n={"0-in-4-4-3":{inIdx:0,spIdx:0,outIdx:0,monomers:[["0","1","2","3"],["4","5","6","7"],["8","9","10"]]},"3-in-4-4-3":{inIdx:3,spIdx:0,outIdx:3,monomers:[["0","1","2","3"],["4","5","6","7"],["8","9","10"]]},"4-in-4-4-3":{inIdx:0,spIdx:1,outIdx:4,monomers:[["0","1","2","3"],["4","5","6","7"],["8","9","10"]]},"7-in-4-4-3":{inIdx:3,spIdx:1,outIdx:7,monomers:[["0","1","2","3"],["4","5","6","7"],["8","9","10"]]},"8-in-4-4-3":{inIdx:0,spIdx:2,outIdx:8,monomers:[["0","1","2","3"],["4","5","6","7"],["8","9","10"]]},"0-in-1-1-6-3":{inIdx:0,spIdx:0,outIdx:0,monomers:[["0"],["1"],["2","3","4","5","6","7"],["8","9","10"]]},"1-in-1-1-6-3":{inIdx:0,spIdx:1,outIdx:1,monomers:[["0"],["1"],["2","3","4","5","6","7"],["8","9","10"]]},"2-in-1-1-6-3":{inIdx:0,spIdx:2,outIdx:2,monomers:[["0"],["1"],["2","3","4","5","6","7"],["8","9","10"]]},"3-in-1-1-6-3":{inIdx:1,spIdx:2,outIdx:3,monomers:[["0"],["1"],["2","3","4","5","6","7"],["8","9","10"]]},"7-in-1-1-6-3":{inIdx:5,spIdx:2,outIdx:7,monomers:[["0"],["1"],["2","3","4","5","6","7"],["8","9","10"]]},"8-in-1-1-6-3":{inIdx:0,spIdx:3,outIdx:8,monomers:[["0"],["1"],["2","3","4","5","6","7"],["8","9","10"]]}};for(const[e,{inIdx:t,spIdx:o,outIdx:r,monomers:i}]of Object.entries(n))x(`innerIdx-${e}`,(async()=>{const[e,n]=(0,ge.M)(r,i);w(e,t),w(n,o)}));for(const[e,{inIdx:t,spIdx:o,outIdx:r,monomers:i}]of Object.entries(n))x(`outerIdx-${e}`,(async()=>{w((0,ge.j)(t,o,i),r)}))})),S("PolyTool: Chain",(()=>{let e;N((async()=>{e=await(0,ae.b2)()}));const t={cyclized:{data:{templateSeq:"R-F-C(1)-T-G-H-F-Y-P-C(1)-meI",templateHelm:"PEPTIDE1{R.F.[C(1)].T.G.H.F.Y.P.[C(1)].[meI]}$$$$V2.0",mmHelm:"PEPTIDE1{R.F.C.T.G.H.F.Y.P.C.[meI]}$PEPTIDE1,PEPTIDE1,3:R3-10:R3$$$V2.0"},tgt:{templateChain:{monomerCount:[11],linkageCount:0},mmChain:{monomerCount:[11],linkageCount:0}}},dimerized1:{data:{templateSeq:"(#3)Succ-{A(CHOL)-F-C(1)-T-G-H-Y-P-C(1)-NH2}",templateHelm:"PEPTIDE1{[(#3)Succ]}|PEPTIDE2{[A(CHOL)].F.[C(1)].T.G.H.Y.P.[C(1)].[NH2]}$PEPTIDE1,PEPTIDE2,1:R1-1:R1$$$V2.0",mmHelm:"PEPTIDE1{[(#3)Succ].[{A(CHOL)].F.C.T.G.H.Y.P.C.[NH2}]}$PEPTIDE1,PEPTIDE1,4:R3-10:R3$$$V2.0"},tgt:{templateChain:{monomerCount:[1,10],linkageCount:1},mmChain:{monomerCount:[11],linkageCount:1}}},dimerized2:{data:{templateSeq:"($3)Succ-{R-F-C(1)-T-G-H-F-P-C(1)-NH2}($3){A(CHOL)-F-C(1)-Y-H-G-D-N-C(1)-meI}",templateHelm:"PEPTIDE1{[($3)Succ]}|PEPTIDE2{R.F.[C(1)].T.G.H.F.P.[C(1)].[NH2]}|PEPTIDE3{[($3)A(CHOL)].F.[C(1)].Y.H.G.D.N.[C(1)].[meI]}$PEPTIDE1,PEPTIDE2,1:R1-1:R1$$$V2.0",mmHelm:"PEPTIDE1{[($3)Succ].[{R].F.C.T.G.H.F.P.C.[NH2}($3){A(CHOL)].F.[C(1)].Y.H.G.D.N.[C(1)].[meI}]}$PEPTIDE1,PEPTIDE1,4:R3-10:R3$$$V2.0"},tgt:{templateChain:{monomerCount:[1,10,10],linkageCount:1},mmChain:{monomerCount:[20],linkageCount:1}}}};for(const[n,{data:o,tgt:r}]of Object.entries(t))x(`fromNotation-${n}`,(async()=>{const t=await(0,ue.Q4)(["rules_example.json"]),n=fe.s.fromSeparator(o.templateSeq,e);n.applyRules(t),n.check(!0),E(n.monomers.map((e=>e.length)),r.mmChain.monomerCount),w(n.linkages.length,r.mmChain.linkageCount),w(n.getHelm(),o.mmHelm)}),{skipReason:"3157"});for(const[n,{data:o,tgt:r}]of Object.entries(t))x(`parseNotation-${n}`,(async()=>{await(0,ue.Q4)(["rules_example.json"]);const t=fe.s.fromSeparator(o.templateSeq,e);t.check(!0),E(t.monomers.map((e=>e.length)),r.templateChain.monomerCount),w(t.linkages.length,r.templateChain.linkageCount),w(t.getHelm(),o.templateHelm),w(t.getNotation(),o.templateSeq)}));for(const[n,{data:o,tgt:r}]of Object.entries(t))x(`parseHelm-${n}`,(async()=>{await(0,ue.Q4)(["rules_example.json"]);const t=fe.s.fromHelm(o.templateHelm,e);t.check(!0),E(t.monomers.map((e=>e.length)),r.templateChain.monomerCount),w(t.linkages.length,r.templateChain.linkageCount),w(t.getHelm(),o.templateHelm),w(t.getNotation(),o.templateSeq)}));for(const[n,{data:o,tgt:r}]of Object.entries(t))x(`applyRules-${n}`,(async()=>{const t=await(0,ue.Q4)(["rules_example.json"]),n=fe.s.fromSeparator(o.templateSeq,e);n.applyRules(t),n.check(!0),E(n.monomers.map((e=>e.length)),r.mmChain.monomerCount),w(n.linkages.length,r.mmChain.linkageCount),w(n.getHelm(),o.mmHelm)}),{skipReason:"applyRules is not implemented"})})),S("toAtomicLevel",(()=>{let t,n,o;N((async()=>{n=await(0,J.pj)(),t=await re(),o=await(0,se.j)(),await n.loadMonomerLibForTests()})),I((async()=>{await ie(t),await n.loadMonomerLib(!0)})),x("override",(async()=>{const t=n.getMonomerLib(),r=await we.files.readAsText("tests/polytool-reaction-lib.json"),i=JSON.parse(r).find((e=>"GGaz"===e.symbol));w(null!=i,!0,"Monomer 'GGaz' not found.");const s={PEPTIDE:{GGaz:i}},a=t.override(s,"test"),l=await(0,W.Q)(),c=e.Column.fromList(e.COLUMN_TYPE.STRING,"helm",["PEPTIDE1{F.P.Y.[GGaz].H.A.A.G.G.A.C}|PEPTIDE2{A.A.A}$PEPTIDE1,PEPTIDE2,4:R4-1:R1|PEPTIDE1,PEPTIDE1,11:R2-4:R3$$$V2.0"]);c.semType=e.SEMTYPE.MACROMOLECULE,c.meta.units=z.Hi.HELM;const u=await l.helmToAtomicLevel(c,!1,!1,a);w(null!=u.molCol,!0,"Result molCol is null");const h=u.molCol.get(0);w(!!h,!0,"Molfile is empty");const d=o.get_mol(h);try{const e=d.get_inchi(),t=o.get_inchikey_for_inchi(e);w(d.get_num_bonds(),103),w(d.get_num_atoms(),98),w(t,"XPQUTLNSNIMERR-WKBTUBAPSA-N")}finally{d.delete()}})),x("getNewMonomer",(async()=>{const e=await(0,se.j)(),t=n.getMonomerLib(),o=(await(0,ue.Q4)(["rules_example.json"])).reactionRules.find((e=>"GGaz"==e.name)),[r,i]=(0,ce.T)(e,t,o);w(r?.[0],"azG_GGaz");const s=e.get_mol(i[0].molfile);try{const t=s.get_inchi();e.get_inchikey_for_inchi(t),w(s.get_num_bonds(),7),w(s.get_num_atoms(),8)}finally{s.delete()}}))}));var ye=n(5613),be=n(5733),ve=n(1536);const Ce="RNA1{m(G)[sp].m(A)[sp].[fl2r](C)p.[fl2r](U)p.r(G)p.r(A)p.r(A)p.r(U)p.r(A)p.r(U)p.r(A)p.r(A)p.r(A)p.r(C)p.r(U)p.r(U)p.m(G)p.m(U)[sp].m(G)[sp].[L3]}|RNA2{[fl2r](C)[sp].m(A)[sp].m(A)p.m(G)p.r(U)p.r(U)p.r(U)p.r(A)p.r(U)p.r(A)p.r(U)p.r(U)p.r(C)p.r(A)p.r(U)p.m(C)p.m(A)[sp].m(G)[sp].r(U)}$$$$",xe="RNA1{[lna](C)[sp].[lna](A)[sp].[lna](G)[sp].d(T)[sp].d(C)[sp].d(A)[sp]}$$$$";S("OligoRenderer: parser",(()=>{x("looksLikeHelm — positive",(async()=>{w((0,ye.yO)(Ce),!0),w((0,ye.yO)("RNA1{R(A)P}"),!0),w((0,ye.yO)("PEPTIDE1{A.C.G}"),!0)})),x("looksLikeHelm — negative",(async()=>{w((0,ye.yO)(""),!1),w((0,ye.yO)("AUCGUACGUAGCUAGCAU"),!1),w((0,ye.yO)("Af Cf Gf Uf"),!1)})),x("parses two-strand duplex",(async()=>{const e=(0,ye.On)(Ce);w(e.sense.type,"RNA"),w(e.sense.monomers.length,20),w(null!==e.antisense,!0),w(e.antisense.monomers.length,19)})),x("parses single-strand",(async()=>{const e=(0,ye.On)(xe);w(e.sense.monomers.length,6),w(e.antisense,null);const t=e.sense.monomers[0];w(t.kind,"nucleotide"),"nucleotide"===t.kind&&(w(t.sugar,"lna"),w(t.base,"C"),w(t.phosphate,"sp"))})),x("single-char unbracketed deoxyribose `d` parses correctly",(async()=>{const e=(0,ye.On)("RNA1{d(T)p.d(C)p.d(G)}$$$$");w(e.sense.monomers.length,3);const t=e.sense.monomers[0];"nucleotide"===t.kind&&(w(t.sugar,"d"),w(t.base,"T"),w(t.phosphate,"p"))})),x("parses bracketed conjugate",(async()=>{const e=(0,ye.On)(Ce),t=e.sense.monomers[e.sense.monomers.length-1];w(t.kind,"conjugate"),"conjugate"===t.kind&&w(t.symbol,"L3")})),x("handles empty / malformed without throwing",(async()=>{const e=(0,ye.On)("");w(e.sense.monomers.length,0),w(e.antisense,null),w((0,ye.On)("not a helm string").sense.monomers.length,0)})),x("passes through unknown sugar/phosphate symbols",(async()=>{const e=(0,ye.On)("RNA1{[xr](A)[zp].[yr](C)p}$$$$").sense.monomers[0];"nucleotide"===e.kind&&(w(e.sugar,"xr"),w(e.phosphate,"zp"))}))})),S("OligoRenderer: modification dictionary",(()=>{x("resolves HELMCore canonical sugars",(async()=>{w((0,ve.xh)("m","A").meta.short,"2'-OMe"),w((0,ve.xh)("fl2r","C").meta.short,"2'-F"),w((0,ve.xh)("lna","G").meta.short,"LNA"),w((0,ve.xh)("moe","A").meta.short,"2'-MOE")})),x("aliases legacy uppercase symbols to canonical",(async()=>{w((0,ve.xh)("mR","A").meta.name,(0,ve.xh)("m","A").meta.name),w((0,ve.xh)("fR","C").meta.name,(0,ve.xh)("fl2r","C").meta.name),w((0,ve.xh)("LR","G").meta.name,(0,ve.xh)("lna","G").meta.name),w((0,ve.xh)("dR","T").meta.name,(0,ve.xh)("d","T").meta.name)})),x("uses base-canonical color for unmodified ribose",(async()=>{const e=(0,ve.xh)("r","A"),t=(0,ve.xh)("r","C");w(e.color!==t.color,!0,`Unmodified A and C must use distinct canonical colors, got ${e.color} for both`)})),x("falls back to hash color for unknown sugar",(async()=>{const e=(0,ve.xh)("zzz","A");w(e.color.startsWith("hsl("),!0),w(e.meta.name,"zzz")})),x("hashColor is deterministic",(async()=>{w((0,ve.e8)("foo"),(0,ve.e8)("foo")),w((0,ve.e8)("foo")!==(0,ve.e8)("bar"),!0)})),x("PS phosphate (canonical and legacy) resolve to same color",(async()=>{w((0,ve.bM)("sp").color,ve.P4.sp.color),w((0,ve.bM)("sP").color,ve.P4.sp.color)})),x("GalNAc / L3 / Chol resolve as conjugates",(async()=>{w((0,ve.rK)("GalNAc").meta.category,"conjugate"),w((0,ve.rK)("L3").meta.category,"conjugate"),w((0,ve.rK)("Chol").meta.color,ve.pt.Chol.color)}))})),S("OligoRenderer: layout",(()=>{x("comfortable cell — chips fit width and height",(async()=>{const e=(0,ye.On)(Ce),t=(0,be.aA)(500,70,e);w(t.textOnlyFallback,!1),w(t.chipW>5,!0,"chip width should be larger than minimum"),w(t.chipW<=17,!0,"chip width should respect max (17)"),w(t.antiY>t.senseY,!0),w(t.senseChips.length>0,!0),w(t.antiChips.length>0,!0)})),x("compact cell — both strands still fit in 28px row",(async()=>{const e=(0,ye.On)(Ce),t=(0,be.aA)(300,28,e);w(t.antiY>0,!0),w(2*t.chipH+t.strandGap<=28,!0,"two strands must fit within 28px row")})),x("very narrow cell triggers text-only fallback",(async()=>{const e=(0,ye.On)(Ce),t=(0,be.aA)(60,30,e);w(t.textOnlyFallback,!0),w(t.senseChips.length,0)})),x("aspect ratio is preserved across sizes",(async()=>{const e=(0,ye.On)(Ce);for(const[t,n]of[[300,50],[500,70],[800,90]]){const o=(0,be.aA)(t,n,e),r=o.chipH/o.chipW;w(Math.abs(r-1.25)<.01,!0,`aspect ratio drifted at ${t}x${n}: got ${r.toFixed(3)}`)}})),x("single-strand layout",(async()=>{const e=(0,ye.On)(xe),t=(0,be.aA)(400,50,e);w(t.antiY,-1),w(t.antiChips.length,0)})),x("antisense reversed by default for pair-alignment",(async()=>{const e=(0,ye.On)(Ce),t=(0,be.aA)(800,70,e);w(t.antiReversed,!0);const n=e.antisense.monomers[e.antisense.monomers.length-1];w(t.antiChips[0].monomer===n,!0)})),x("pairAlign: false leaves antisense in data order",(async()=>{const e=(0,ye.On)(Ce),t=(0,be.aA)(800,70,e,{pairAlign:!1});w(t.antiReversed,!1),w(t.antiChips[0].monomer===e.antisense.monomers[0],!0)})),x("conjugate occupies a wider position; following chip does not overlap",(async()=>{const e=(0,ye.On)("RNA1{m(G)p.m(A)p.m(C)p.[L3]}|RNA2{m(C)p.m(A)p.m(A)p.r(G)}$$$$"),t=(0,be.aA)(600,70,e),n=t.senseChips[3];w(n.monomer.kind,"conjugate"),w(n.w>=t.chipW,!0,"conjugate must be at least chip-wide")}))})),S("OligoRenderer: hit testing",(()=>{x("hits each chip via stored positions",(async()=>{const e=(0,ye.On)(Ce),t=(0,be.aA)(800,70,e),n=t.senseChips[0],o=(0,be.CB)(n.x+n.w/2,t.senseY+t.chipH/2,e,t);w(null!==o,!0),w(o.strand,"sense"),w(o.position,0);const r=e.sense.monomers[0],i="nucleotide"===r.kind&&"sp"===r.phosphate,s=n.x+n.w+.1*t.chipGap,a=(0,be.CB)(s,t.senseY+t.chipH/2,e,t);i?(w(null!==a,!0),w(void 0!==a.linkage,!0)):w(a,null)})),x("antisense hit returns original position despite reversed display",(async()=>{const e=(0,ye.On)(Ce),t=(0,be.aA)(800,70,e),n=t.antiChips[0],o=(0,be.CB)(n.x+n.w/2,t.antiY+t.chipH/2,e,t);w(null!==o,!0),w(o.strand,"antisense"),w(o.position,e.antisense.monomers.length-1,"leftmost AS chip in pair-aligned display = last monomer in data")})),x("hovering between two chips with PS linkage returns the linkage",(async()=>{const e=(0,ye.On)("RNA1{m(G)[sp].m(A)p.m(C)p}$$$$"),t=(0,be.aA)(600,70,e),n=t.senseChips[0],o=t.senseChips[1],r=(n.x+n.w+o.x)/2,i=(0,be.CB)(r,t.senseY+t.chipH/2,e,t);w(null!==i,!0),w(void 0!==i.linkage,!0),w(i.linkage.phosphateSymbol,"sp")}))})),S("OligoRenderer: drawing smoke",(()=>{x("draws without error on offscreen canvas",(async()=>{const e=document.createElement("canvas");e.width=500,e.height=70;const t=e.getContext("2d"),n=(0,ye.On)(Ce);w((0,be.Z4)(t,0,0,500,70,n).textOnlyFallback,!1)})),x("handles unknown modifications without throwing",(async()=>{const e=document.createElement("canvas");e.width=200,e.height=50;const t=e.getContext("2d"),n=(0,ye.On)("RNA1{[xr](A)[zp].[yr](C)p}$$$$");(0,be.Z4)(t,0,0,200,50,n),w(!0,!0)})),x("renders legacy uppercase symbols via alias map",(async()=>{const e=document.createElement("canvas");e.width=400,e.height=50;const t=e.getContext("2d"),n=(0,ye.On)("RNA1{[mR](G)[sP].[mR](A)[sP].[fR](C)P.R(U)P}|RNA2{[mR](C)[sP].R(A)P.R(U)P.R(G)P}$$$$");(0,be.Z4)(t,0,0,400,50,n),w(n.sense.monomers.length,4),w(null!==n.antisense,!0)}))}));const we=new F;async function Ae(t,n,o){const d=await function(e){var t,n,o;return r(this,void 0,void 0,(function*(){const d=(null==e?void 0:e.nodeOptions)?e.nodeOptions.package:grok.functions.getCurrentCall().func.package;if(!d)throw new Error("Can't run tests outside of the package");const p=null===(t=d.packageOwner)||void 0===t?void 0:t.match(/<([^>]*)>/),m=p?p[1]:"";null!=d&&(yield P(d));const f=[];console.log("Running tests..."),console.log(e),null!=e||(e={}),null!==(n=(o=e).testContext)&&void 0!==n||(o.testContext=new v),grok.shell.clearLastError();const g=function(){const e=[];return console.log=(...t)=>{e.push(...t),a(...t)},console.info=(...t)=>{e.push(...t),l(...t)},console.warn=(...t)=>{e.push(...t),c(...t)},console.error=(...t)=>{e.push(...t),u(...t)},e}();yield function(e,t){var n,o,i,s,h,p;return r(this,void 0,void 0,(function*(){try{let l=null!=(null==t?void 0:t.skipToCategory),c=!1;for(const[u,g]of Object.entries(e)){if(null===(n=t.exclude)||void 0===n?void 0:n.some((e=>u.startsWith(e))))continue;if(null!=(null==t?void 0:t.category)&&!u.toLowerCase().startsWith(null==t?void 0:t.category.toLowerCase().trim()))continue;if(l)if(c)l=!1;else{if(null==(null==t?void 0:t.skipToCategory)||u.toLowerCase().trim()!==(null==t?void 0:t.skipToCategory.toLowerCase().trim()))continue;c=!0}const e=null===(o=g.tests)||void 0===o?void 0:o.every((e=>{var n;return(null===(n=e.options)||void 0===n?void 0:n.skipReason)||null!=(null==t?void 0:t.test)&&t.test.toLowerCase()!==e.name.toLowerCase()}));if(!e){const e=(null!==(i=g.tests)&&void 0!==i?i:[]).filter((e=>{var n;return(null===(n=e.options)||void 0===n?void 0:n.skipReason)||null!=(null==t?void 0:t.test)&&t.test.toLowerCase()!==e.name.toLowerCase()})).length;a(`Package testing: Started {{${u}}}${e>0?` skipped {{${e}}}`:""}`),g.beforeStatus=yield y(g.before,u)}let v,C=null!==(s=g.tests)&&void 0!==s?s:[];t.stressTest&&(C=C.filter((e=>{var t;return null===(t=e.options)||void 0===t?void 0:t.stressTest})),C=O(C)),(null!==(p=null===(h=t.tags)||void 0===h?void 0:h.length)&&void 0!==p?p:0)>0&&(C=C.filter((e=>{var n,o;return null===(o=null===(n=e.options)||void 0===n?void 0:n.tags)||void 0===o?void 0:o.some((e=>{var n;return(null!==(n=null==t?void 0:t.tags)&&void 0!==n?n:[]).includes(e)}))}))),g.beforeStatus?(v=Array.from(C.map((e=>({date:(new Date).toISOString(),category:u,name:e.name,success:!1,result:"before() failed",ms:0,skipped:!1,logs:"",owner:m,package:d.name,widgetsDifference:0,flaking:DG.Test.isReproducing})))),v.forEach((e=>r(this,void 0,void 0,(function*(){return yield grok.shell.reportTest("package",e)}))))):v=yield b(g,t,l);const x=v.filter((e=>"skipped"!=e.result));if(e||(g.afterStatus=yield y(g.after,u)),g.afterStatus&&(a(`Package testing: Category after() {{${u}}} failed`),a(`Package testing: Result for {{${u}}} after: ${g.afterStatus}`),x.push({date:(new Date).toISOString(),category:u,name:"after",success:!1,result:g.afterStatus,ms:0,skipped:!1,logs:"",owner:m,package:d.name,widgetsDifference:0,flaking:DG.Test.isReproducing})),g.beforeStatus&&(a(`Package testing: Category before() {{${u}}} failed`),a(`Package testing: Result for {{${u}}} before: ${g.beforeStatus}`),x.push({date:(new Date).toISOString(),category:u,name:"before",success:!1,result:g.beforeStatus,ms:0,skipped:!1,logs:"",owner:m,package:d.name,widgetsDifference:0,flaking:DG.Test.isReproducing})),f.push(...x),t.returnOnFail&&x.some((e=>!e.success&&!e.skipped&&e.name!==t.skipToTest)))break}}finally{console.log=a,console.info=l,console.warn=c,console.error=u}if(t.testContext.catchUnhandled&&!DG.Test.isInBenchmark){yield R(1e3);const e=yield grok.shell.lastError;if(null!=e){const t={logs:"",date:(new Date).toISOString(),category:"Unhandled exceptions",name:"Exception",result:null!=e?e:"",success:!e,ms:0,skipped:!1,owner:null!=m?m:"",package:d.name,widgetsDifference:0};a(`Package testing: Unhandled Exception: ${e}`),f.push(Object.assign(Object.assign({},t),{flaking:DG.Test.isReproducing&&!e})),t.package=d.name,yield grok.shell.reportTest("package",t)}}}))}(h,e);for(let e of f)e.result=e.result.toString().replace(/"/g,"'"),null!=e.logs&&(e.logs=e.logs.toString().replace(/"/g,"'"));return f;function y(e,t){return r(this,void 0,void 0,(function*(){let n;try{void 0!==e&&(yield $((()=>r(this,void 0,void 0,(function*(){yield e()}))),1e5,`before ${t}: timeout error`))}catch(e){n=yield _(e)}return n}))}function b(e,t,n){var o,a,l,c,u,h,p,f,y,b,v,x,w,A,T,E,S,N;return r(this,void 0,void 0,(function*(){let r=null!==(o=e.tests)&&void 0!==o?o:[];const I=[],M=C();if(e.clear){let o=n&&null!=t.skipToTest;for(let n=0;n<r.length;n++){r[n].options&&void 0===(null===(a=r[n].options)||void 0===a?void 0:a.benchmark)&&(r[n].options||(r[n].options={}),r[n].options.benchmark=null!==(l=e.benchmarks)&&void 0!==l&&l);let x=r[n];if(t.test&&t.test.toLowerCase()!==x.name.toLowerCase())continue;if(o){if(null==(null==t?void 0:t.skipToTest)||x.name.toLowerCase().trim()!==(null==t?void 0:t.skipToTest.toLowerCase().trim()))continue;o=!1}(null==x?void 0:x.options)&&(x.options.owner=null!==(p=null!==(h=null!==(u=null===(c=r[n].options)||void 0===c?void 0:c.owner)&&void 0!==u?u:null==e?void 0:e.owner)&&void 0!==h?h:m)&&void 0!==p?p:"");let w=yield L(x,null==t?void 0:t.test,g,DG.Test.isInBenchmark?null!==(y=null===(f=r[n].options)||void 0===f?void 0:f.benchmarkTimeout)&&void 0!==y?y:s:null!==(v=null===(b=r[n].options)||void 0===b?void 0:b.timeout)&&void 0!==v?v:i,d.name,t.verbose);if(w&&(I.push(Object.assign(Object.assign({},w),{widgetsDifference:C()-M})),t.returnOnFail&&t.skipToTest!==x.name&&!w.success&&!w.skipped))return I;t.nodeOptions||(grok.shell.closeAll(),DG.Balloon.closeAll())}}else{let o=n&&null!=t.skipToTest;for(let n=0;n<r.length;n++){let i=r[n];if(t.test&&t.test.toLowerCase()!==i.name.toLowerCase())continue;if(o){null!=(null==t?void 0:t.skipToTest)&&i.name.toLowerCase().trim()===(null==t?void 0:t.skipToTest.toLowerCase().trim())&&(o=!1);continue}(null==i?void 0:i.options)&&(i.options.owner=null!==(T=null!==(A=null!==(w=null===(x=r[n].options)||void 0===x?void 0:x.owner)&&void 0!==w?w:null==e?void 0:e.owner)&&void 0!==A?A:m)&&void 0!==T?T:"");let a=yield L(i,null==t?void 0:t.test,g,DG.Test.isInBenchmark?null!==(S=null===(E=r[n].options)||void 0===E?void 0:E.benchmarkTimeout)&&void 0!==S?S:s:null===(N=r[n].options)||void 0===N?void 0:N.timeout,d.name,t.verbose);if(a&&(I.push(Object.assign(Object.assign({},a),{widgetsDifference:C()-M})),t.returnOnFail&&t.skipToTest!==i.name&&!a.success&&!a.skipped))return I}}return I}))}function C(){var e;if("undefined"!=typeof process)return 0;let t=-1;try{t=DG.Widget.getAll().length}catch(t){console.warn(null!==(e=t.message)&&void 0!==e?e:t)}return t}}))}({category:t,test:n,testContext:o,verbose:!0});return e.DataFrame.fromObjects(d)}async function Te(){await P(we,we.getModule("package-test.js"))}})(),sequencetranslator_test=o})();
|
|
2
|
+
var sequencetranslator_test;(()=>{var e={6717:(e,t,n)=>{"use strict";n.d(t,{j:()=>r});var o=n(6082);async function r(){const e=o.Func.find({package:"Chem",name:"getRdKitModule"});if(0===e.length)throw new Error('Package "Chem" must be installed for getRdKitModule.');return(await e[0].prepare().call()).getOutputParamValue()}},3599:(e,t,n)=>{"use strict";n.d(t,{o:()=>o.o});var o=n(6869)},9124:(e,t,n)=>{"use strict";n.d(t,{b2:()=>i});var o=n(7389),r=n(6082);async function i(){const e="Helm",t=r.Func.find({package:e,name:"getHelmHelper"});if(0===t.length)throw new Error(`Package '${e}' must be installed for HelmHelper.`);return(await t[0].prepare().call()).getOutputParamValue()}r.JsInputBase,Error,o.input.helmAsync=async function(e,t){return(await i()).createHelmInput(e,t)}},8438:(e,t,n)=>{"use strict";function o(e){return e.startsWith("[")&&e.endsWith("]")?e.slice(1,-1):e}n.d(t,{D:()=>o})},8123:(e,t,n)=>{"use strict";n.d(t,{u:()=>o});const o={V2K_RGP_SHIFT:8,V2K_RGP_LINE:"M RGP",V2K_A_LINE:"A ",V3K_COUNTS_SHIFT:14,V3K_IDX_SHIFT:7,V3K_HEADER_FIRST_LINE:"\nDatagrok macromolecule handler\n\n",V3K_HEADER_SECOND_LINE:" 0 0 0 0 0 0 999 V3000\n",V3K_BEGIN_CTAB_BLOCK:"M V30 BEGIN CTAB\n",V3K_END_CTAB_BLOCK:"M V30 END CTAB\n",V3K_BEGIN_COUNTS_LINE:"M V30 COUNTS ",V3K_COUNTS_LINE_ENDING:" 0 0 0\n",V3K_BEGIN_ATOM_BLOCK:"M V30 BEGIN ATOM\n",V3K_END_ATOM_BLOCK:"M V30 END ATOM\n",V3K_BEGIN_BOND_BLOCK:"M V30 BEGIN BOND\n",V3K_END_BOND_BLOCK:"M V30 END BOND\n",V3K_BOND_CONFIG:" CFG=",V3K_BEGIN_DATA_LINE:"M V30 ",V3K_END:"M END",PRECISION_FACTOR:1e4,DEOXYRIBOSE:{polymerType:"RNA",symbol:"d"},RIBOSE:{polymerType:"RNA",symbol:"r"},PHOSPHATE:{polymerType:"RNA",symbol:"p"},OXYGEN:"O",HYDROGEN:"H"}},6197:(e,t,n)=>{"use strict";n.d(t,{Y:()=>r});var o=n(3599);function r(e){let t;switch(e){case o.o.BASE:case o.o.SUGAR:case o.o.LINKER:case o.o.NUCLEOTIDE:case"nucleotide":t="RNA";break;case o.o.AA:t="PEPTIDE";break;case o.o.CHEM:t="CHEM";break;case o.o.BLOB:t="BLOB";break;default:t="PEPTIDE",console.warn(`Unexpected HelmType '${e}'`)}return t}},9235:(e,t,n)=>{"use strict";n.d(t,{H:()=>c,R:()=>l});var o=n(6082),r=n(1991),i=n.n(r),s=n(330),a=n(3599);async function l(e,t,r,l,c,u,h,d){const p=e.length,m=e.dataFrame,f=Math.max(navigator.hardwareConcurrency-2,1),g=new Array(f).fill(null).map((()=>new Worker(new URL(n.p+n.u(455),n.b)))),y=p/f,b=new Array(f),v=u.getSeqHandler(e),C="RNA"==l?a.o.NUCLEOTIDE:a.o.AA,x=i().count(0).take(e.length).map((e=>{const t=v.getSplitted(e);return i().count(0).take(t.length).map((e=>({position:e,symbol:t.getCanonical(e),biotype:C}))).toArray()})).toArray();for(let e=0;e<f;e++){const n=g[e],o=Math.floor(e*y),i=e===f-1?p:Math.floor((e+1)*y);b[e]=new Promise((e=>{n.onmessage=t=>{e(t.data)}})),n.postMessage({seqList:x,rolesList:d,monomersDict:t,alphabet:r,polymerType:l,start:o,end:i})}const w=[],A=[];await Promise.all(b).then((e=>{for(const t of e)w.push(...t.molfiles),A.push(...t.warnings)})),setTimeout((()=>{g.forEach((e=>{e.terminate()}))}),0);const T=(0,s.qj)(m,e.name),E=o.Column.fromType(o.COLUMN_TYPE.STRING,T,e.length).init((e=>w[e]?.molfile));return E.semType=o.SEMTYPE.MOLECULE,E.meta.units=o.UNITS.Molecule.MOLBLOCK,E.setTag(".sequence-src-col",e.name),{molCol:E,warnings:A}}function c(e,t){const n={},r={};for(const i of e){const e=t.getWebEditorMonomer(i.biotype,i.symbol).backgroundcolor,a=(0,s.vG)(e??o.Color.toRgb(o.Color.mouseOverRows))??[1,0,0,.7];for(const e of i.atoms)n[e]=a;for(const e of i.bonds)r[e]=a}return{atoms:Object.keys(n).map((e=>parseInt(e))),bonds:Object.keys(r).map((e=>parseInt(e))),highlightAtomColors:n,highlightBondColors:r}}},3561:(e,t,n)=>{"use strict";n.d(t,{Hb:()=>l,YN:()=>f,gU:()=>c});var o=n(8123),r=n(294),i=n(3151),s=n(439),a=n(6197);function l(e,t,n){const o=new Map;for(const n of e.getMonomerSymbolsByType(t)){const r=e.getMonomer(t,n);if("RNA"===t||"PEPTIDE"===t&&"Branch"!==r.monomerType){const e={};i.f6.forEach((t=>{e[t]=r[t]})),o.set(n,e)}}return o}function c(e,t,n,i,l){if(0===e.length)return r.vF.createEmpty();const c="RNA"===i&&!!l&&l.length===e.length,{atomCount:m,bondCount:g,needsCapping:y}=function(e,t,n,i,l,c){let u=0,h=0,d=0,p=!0,m=null,f=null;for(let n=0;n<e.length;++n){const o=e[n];if(o.symbol!==s._S){if("*"==o.symbol)throw new Error("Gap canonical symbol is '', not '*");m=(0,r.xb)(t,{symbol:o.symbol,polymerType:(0,a.Y)(o.biotype)}),u+=m.atoms.x.length,h+=m.bonds.bondTypes.length,d++,l&&n%3==2&&(f=m)}}if("PEPTIDE"===i)u+=1,h+=d,d>0&&((m?.meta?.rNodes?.length??0)<2||m?.terminalR2Atom?.toLowerCase()===o.u.HYDROGEN.toLowerCase())&&(p=!1,u-=1,h-=1);else if(l)h+=d,c&&c.length>0&&c[c.length-1]===r.ZN.TERMINAL_3P?p=!1:u+=1;else{const i=n===s.YI.DNA?(0,r.xb)(t,o.u.DEOXYRIBOSE):(0,r.xb)(t,o.u.RIBOSE),a=(0,r.xb)(t,o.u.PHOSPHATE);u+=(e.length-1)*a.atoms.x.length,u+=e.length*i.atoms.x.length,u+=1,h+=(e.length-1)*a.bonds.bondTypes.length,h+=e.length*i.bonds.bondTypes.length,h-=1,h+=3*e.length}return{atomCount:u,bondCount:h,needsCapping:p}}(e,t,n,i,c,l),b=new Array(m),v=new Array(g);let C,x=null,w=null;"PEPTIDE"===i?C=u:(C=d,c||(x=n===s.YI.DNA?(0,r.xb)(t,o.u.DEOXYRIBOSE):(0,r.xb)(t,o.u.RIBOSE),w=(0,r.xb)(t,o.u.PHOSPHATE)));const A={i:0,nodeShift:0,bondShift:0,backbonePositionShift:new Array(2).fill(0),branchPositionShift:new Array(2).fill(0),backboneAttachNode:0,branchAttachNode:0,flipFactor:1},T={sugar:x,phosphate:w,seqLength:c?Math.ceil(e.length/3):e.length,atomCount:m,bondCount:g},E=new r.Cg,S=[];let N,I=0;if(c)!function(e,t,n,o,i,s,l,c,u,d,m){const f=t.length>0&&t[0]===r.ZN.TERMINAL_5P,g=t.length>0&&t[t.length-1]===r.ZN.TERMINAL_3P,y=f?1:0,b=(g?t.length-1:t.length)-y,v=Math.ceil(b/3),C=b===3*v,x=(e,t)=>{const l=(0,r.xb)(n,{symbol:e.symbol,polymerType:(0,a.Y)(e.biotype)}),p=s.nodeShift,f=s.bondShift;h(l,o,i,s),l.stereoAtoms?.forEach((e=>u.push(e+m()))),d(l.atoms.x.length);const g=[];for(let e=p;e<s.nodeShift;++e)g.push(e);const y=[];for(let e=f;e<s.bondShift;++e)y.push(e);c.set(t,{biotype:e.biotype,symbol:e.symbol,atoms:g,bonds:y})};f&&(s.i=0,x(e[0],0));for(let t=0;t<v;++t){s.i=t+(f?1:0);const l=y+3*t,g=l+1,b=e[l],v=e[g],C=(0,r.xb)(n,{symbol:b.symbol,polymerType:(0,a.Y)(b.biotype)}),w=(0,r.xb)(n,{symbol:v.symbol,polymerType:(0,a.Y)(v.biotype)});if(t>=1){const n=y+3*(t-1)+2;x(e[n],n)}const A=s.nodeShift,T=s.bondShift;h(C,o,i,s),C.stereoAtoms?.forEach((e=>u.push(e+m()))),d(C.atoms.x.length);const E=[];for(let e=A;e<s.nodeShift;++e)E.push(e);const S=[];for(let e=T;e<s.bondShift;++e)S.push(e);c.set(l,{biotype:b.biotype,symbol:b.symbol,atoms:E,bonds:S});const N=s.nodeShift,I=s.bondShift;p(w,o,i,s),w.stereoAtoms?.forEach((e=>u.push(e+m()))),d(w.atoms.x.length);const M=[];for(let e=N;e<s.nodeShift;++e)M.push(e);const P=[];for(let e=I;e<s.bondShift;++e)P.push(e);c.set(g,{biotype:v.biotype,symbol:v.symbol,atoms:M,bonds:P})}if(C){const t=y+3*(v-1)+2;x(e[t],t)}g&&(s.i=v+(f?1:0),x(e[t.length-1],t.length-1))}(e,l,t,b,v,A,0,E,S,(e=>{I+=e}),(()=>I));else for(A.i=0;A.i<T.seqLength;++A.i){const n=e[A.i];if(n.symbol===s._S)continue;const o=(0,r.xb)(t,{symbol:n.symbol,polymerType:(0,a.Y)(n.biotype)});N=o.terminalR2Atom;const i=A.nodeShift,l=A.bondShift;C(o,b,v,A,T),o.stereoAtoms?.forEach((e=>S.push(e+I))),I+=o.atoms.x.length;const c=A.nodeShift-i,u=new Array(c);for(let e=0;e<c;++e)u[e]=i+e;const h=A.bondShift-l,d=new Array(h);for(let e=0;e<h;++e)d[e]=l+e;E.set(A.i,{biotype:n.biotype,symbol:n.symbol,atoms:u,bonds:d})}y&&function(e,t,n,r,i=o.u.OXYGEN){const s=n.nodeShift+1;e[r.atomCount]=o.u.V3K_BEGIN_DATA_LINE+s+" "+(i??o.u.OXYGEN)+" "+f(n.backbonePositionShift[0])+" "+n.flipFactor*f(n.backbonePositionShift[1])+" 0.000000 0\n";const a=n.backboneAttachNode,l=s;t[r.bondCount]=o.u.V3K_BEGIN_DATA_LINE+n.bondShift+" 1 "+a+" "+l+"\n"}(b,v,A,T,N??o.u.OXYGEN);const M=o.u.V3K_BEGIN_COUNTS_LINE+m+" "+g+o.u.V3K_COUNTS_LINE_ENDING;let P="";return P+=o.u.V3K_HEADER_FIRST_LINE,P+=o.u.V3K_HEADER_SECOND_LINE,P+=o.u.V3K_BEGIN_CTAB_BLOCK,P+=M,P+=o.u.V3K_BEGIN_ATOM_BLOCK,P+=b.join(""),P+=o.u.V3K_END_ATOM_BLOCK,P+=o.u.V3K_BEGIN_BOND_BLOCK,P+=v.join(""),P+=o.u.V3K_END_BOND_BLOCK,S.length>0&&(P+=function(e){const t=[];let n=`M V30 MDLV30/STEABS ATOMS=(${e.length}`;for(let o=0;o<e.length;o++){const r=`${n} ${e[o]}`;r.length>76?(t.push(`${n} -\n`),n=`M V30 ${e[o]}`):n=r,o===e.length-1&&t.push(`${n})\n`)}return`M V30 BEGIN COLLECTION\n${t.join("")}M V30 END COLLECTION\n`}(S)),P+=o.u.V3K_END_CTAB_BLOCK,P+=o.u.V3K_END,{molfile:P,monomers:E}}function u(e,t,n,o){o.flipFactor=(-1)**(o.i%2),h(e,t,n,o)}function h(e,t,n,r){!function(e,t,n){for(let r=0;r<e.atoms.atomTypes.length;++r){const i=n.nodeShift+r+1;t[n.nodeShift+r]=o.u.V3K_BEGIN_DATA_LINE+i+" "+e.atoms.atomTypes[r]+" "+f(n.backbonePositionShift[0]+e.atoms.x[r])+" "+f(n.backbonePositionShift[1]+n.flipFactor*e.atoms.y[r])+" "+e.atoms.kwargs[r]}}(e,t,r),m(e,n,r),function(e,t,n){if(0!==n.backboneAttachNode){const r=n.bondShift,i=n.backboneAttachNode,s=e.meta.terminalNodes[0]+n.nodeShift;t[n.bondShift-1]=o.u.V3K_BEGIN_DATA_LINE+r+" 1 "+i+" "+s+"\n"}}(e,n,r),null!==e.meta.branchShift&&e.meta.terminalNodes.length>2&&function(e,t){t.branchAttachNode=t.nodeShift+e.meta.terminalNodes[2];for(let n=0;n<2;++n)t.branchPositionShift[n]=t.backbonePositionShift[n]+e.meta.branchShift[n]}(e,r),function(e,t){t.backboneAttachNode=t.nodeShift+e.meta.terminalNodes[1],t.bondShift+=e.bonds.atomPairs.length+1,t.nodeShift+=e.atoms.atomTypes.length,t.backbonePositionShift[0]+=e.meta.backboneShift?.[0]??0,t.backbonePositionShift[1]+=t.flipFactor*(e.meta.backboneShift?.[1]??0)}(e,r)}function d(e,t,n,o,r){if(0===o.i)h(r.sugar,t,n,o);else for(const e of[r.phosphate,r.sugar])h(e,t,n,o);p(e,t,n,o)}function p(e,t,n,r){!function(e,t,n){for(let r=0;r<e.atoms.atomTypes.length;++r){const i=n.nodeShift+r+1;t[n.nodeShift+r]=o.u.V3K_BEGIN_DATA_LINE+i+" "+e.atoms.atomTypes[r]+" "+f(n.branchPositionShift[0]+e.atoms.x[r])+" "+f(n.branchPositionShift[1]+n.flipFactor*e.atoms.y[r])+" "+e.atoms.kwargs[r]}}(e,t,r),m(e,n,r),function(e,t,n){const r=n.bondShift,i=n.branchAttachNode,s=e.meta.terminalNodes[0]+n.nodeShift;t[r-1]=o.u.V3K_BEGIN_DATA_LINE+r+" 1 "+i+" "+s+"\n"}(e,n,r);const i=r.bondShift,s=r.branchAttachNode,a=e.meta.terminalNodes[0]+r.nodeShift;n[i-1]=o.u.V3K_BEGIN_DATA_LINE+i+" 1 "+s+" "+a+"\n",r.bondShift+=e.bonds.atomPairs.length+1,r.nodeShift+=e.atoms.atomTypes.length}function m(e,t,n){for(let r=0;r<e.bonds.atomPairs.length;++r){const i=n.bondShift+r+1,s=e.bonds.atomPairs[r][0]+n.nodeShift,a=e.bonds.atomPairs[r][1]+n.nodeShift;let l="";if(e.bonds.bondConfiguration.has(r)){let t=e.bonds.bondConfiguration.get(r);n.flipFactor<0&&(t=1===t?3:1),l=" CFG="+t}const c=e.bonds.kwargs.has(r)?" "+e.bonds.kwargs.get(r):"";t[n.bondShift+r]=o.u.V3K_BEGIN_DATA_LINE+i+" "+e.bonds.bondTypes[r]+" "+s+" "+a+l+c+"\n"}}function f(e){return Math.round(o.u.PRECISION_FACTOR*e)/o.u.PRECISION_FACTOR}},6077:(e,t,n)=>{"use strict";n.d(t,{C4:()=>f,eM:()=>y});var o=n(4328),r=n(6082),i=n(1991),s=n.n(i),a=n(439),l=n(3561),c=n(9235),u=n(294),h=n(9192),d=n(330),p=n(3599),m=n(8123);async function f(e,t,n,i,l){if(t.semType!==r.SEMTYPE.MACROMOLECULE)return{molCol:null,warnings:[`Only the ${r.SEMTYPE.MACROMOLECULE} columns can be converted to atomic level, the chosen column has semType '${t.semType}'`]};let f=t;const b=i.getSeqHandler(t),v=b.notation===a.Hi.HELM&&function(e,t){const n=t.getSeqHandler(e);if(n.notation!==a.Hi.HELM)return!1;let o=!1;for(let t=0;t<e.length;++t){const e=n.getSplitted(t);if(0===e.length)continue;const r=e.graphInfo,i=r?.polymerTypes;if(!i||i.length!==e.length)return!1;for(const e of i)if("RNA"!==e)return!1;o=!0}return o}(t,i);let C,x;v||b.notation===a.Hi.SEPARATOR||b.notation===a.Hi.BILN||(f=b.convert(a.Hi.SEPARATOR,"."),f.name=t.name);try{v?(C="RNA",x=function(e,t){const n=t.getSeqHandler(e);for(let t=0;t<e.length;++t){const e=n.getSplitted(t);for(let t=0;t<e.length;++t)if(t%3==0&&e.getCanonical(t)===m.u.DEOXYRIBOSE.symbol)return a.YI.DNA}return a.YI.RNA}(t,i)):(x=i.getSeqHandler(f).alphabet,C=(0,d.pz)(x))}catch(e){const[t,n]=(0,h.AP)(e);return{molCol:null,warnings:[t]}}const w=function(e,t){const n=e.length,r=new Array(n),i=t.getSeqHandler(e);let a=!1;const l=i.defaultBiotype;for(let e=0;e<n;++e){const t=i.getSplitted(e);a||(a=0===t.length),r[e]=s().count(0).take(t.length).filter((e=>!t.isGap(e))).map((e=>({position:e,biotype:l,symbol:t.getCanonical(e)}))).toArray()}return a&&o.shell.warning(`Some values in the "${e.name}" column are empty`),r}(f,i),A=v?function(e,t,n){const o=new Array(e.length);for(let r=0;r<e.length;++r){const i=e[r];if(0===i.length){o[r]=void 0;continue}const s=i.length>=1&&null!==g(t,n,i[0].symbol),a=i.length>=1&&!(s&&1===i.length)&&null!==g(t,n,i[i.length-1].symbol),l=i.length-(s?1:0)-(a?1:0);if(l<0||l%3!=0&&l%3!=2){o[r]=void 0;continue}const c=new Array(i.length);let h=0;for(let e=0;e<i.length;++e)0===e&&s?c[e]=u.ZN.TERMINAL_5P:e===i.length-1&&a?c[e]=u.ZN.TERMINAL_3P:(c[e]=h%3,h++);o[r]=c}return o}(w,n,C):new Array(w.length).fill(void 0);if(v)for(const e of w)for(const t of e)t.biotype=p.o.NUCLEOTIDE;const T=y(w,A,C,x,n,l),E=f.length,S=await(0,c.R)(f,T,x,C,n,i,l,A);S.warnings.length>.05*E&&o.shell.warning(`Molfile conversion resulted in ${S.warnings.length} errors`);const N=r.Func.find({name:"convertToV3KViaOCL"})[0];if(N&&S.molCol)try{const e=S.molCol.toList(),t=await N.apply({mols:e});S.molCol.init((n=>t[n]?t[n]:e[n]))}catch(e){console.error(e)}return S}function g(e,t,n){const o=e.getMonomer(t,n);if(!o||!o.rgroups||1!==o.rgroups.length)return null;if("Branch"===o.monomerType)return null;const r=o.rgroups[0].label;return"R1"===r?"r1-only":"R2"===r?"r2-only":null}function y(e,t,n,o,r,i){const s=(0,l.Hb)(r,n,o),c={},h={value:null};if("RNA"===n&&t.some((e=>void 0===e))){const e=o===a.YI.RNA?[m.u.RIBOSE,m.u.PHOSPHATE]:[m.u.DEOXYRIBOSE,m.u.PHOSPHATE];for(const t of e)b(c,t.symbol,s,i,n,h,void 0)}for(let o=0;o<e.length;++o){const r=e[o],a=t[o];for(let e=0;e<r.length;++e){const t=r[e].symbol;if(""===t)continue;const o=a?a[e]:void 0;try{if("RNA"===n&&void 0===o&&3===t.split(/\(|\)/).filter((e=>!!e)).length){const e=t.split(/\(|\)/)[1];b(c,e,s,i,n,h,u.ZN.BASE),c[n]?.[e]&&(c[n][t]=c[n][e])}else b(c,t,s,i,n,h,o)}catch(e){const n=e instanceof Error?e.message:e.toString(),o=e instanceof Error?e.stack:void 0;throw console.error(`bio lib: getMonomersDictFromLib() sym='${t}', error:\n${n}\n${o}`),new Error(`Can't get monomer '${t}' from library: ${n}`)}}}return c}function b(e,t,n,o,r,i,s){const a={polymerType:r,symbol:t};if(!(0,u.bq)(e,a)){const c=function(e,t,n,o,r,i){if(t.has(e)){const a=t.get(e),c=function(e){const t=[];for(const n of e){let e=n.capGroupSmiles;e||(e=n.capGroupSMILES),e=e.replace(/(\[|\]|\*|:|\d)/g,"").replace("OH","O").replace("Oh","O"),t.push(e)}return t}(a.rgroups),h=(s=a.molfile).includes("V3000")?function(e){const t=new Map,n=/M V30 (\d+) R#.+RGROUPS=\((\d+) (\d+)\).*/gm;let o;for(;null!==(o=n.exec(e));)o.index===n.lastIndex&&n.lastIndex++,t.set(parseInt(o[1]),parseInt(o[3]));return t}(s):function(e){const t=new Map;let n=e.indexOf(m.u.V2K_A_LINE,0),o=n;for(;-1!==n;){o=e.indexOf("\n",n);const r=parseInt(e.substring(n,o).replace(/^A\s+/,""));n=e.indexOf("R",o),o=e.indexOf("\n",n);const i=parseInt(e.substring(n,o).replace(/^R/,""));t.set(r,i),n=e.indexOf(m.u.V2K_A_LINE,o)}for(n=e.indexOf(m.u.V2K_RGP_LINE,0),o=e.indexOf("\n",n);-1!==n;){n+=m.u.V2K_RGP_SHIFT,o=e.indexOf("\n",n);const r=e.substring(n,o).replaceAll(/\s+/g," ").split(" ").map((e=>parseInt(e))).slice(1);for(let e=0;e<r.length;e+=2){if(t.has(r[e])&&t.get(r[e])!==r[e+1])throw new Error(`r-group index ${r[e]} has already been added with a different value`);t.set(r[e],r[e+1])}n=e.indexOf(m.u.V2K_RGP_LINE,o)}return t}(s),d=a.molfile.includes("V3000")?a.molfile:function(e,t){const n=t.get_mol(function(e){return e.split("\n").map((e=>{const t=e.indexOf(" R# "),n=e.indexOf(" R ");if(-1===t&&-1===n)return e;const o=-1!==t?t:n,r=e.split("");for(let e=o+5;e<r.length;e++)" "!==r[e]&&(r[e]="0");return r.join("")})).join("\n")}(e)),o=n.get_v3Kmolblock();return n.delete(),o}(function(e){let t=e.indexOf(m.u.V2K_A_LINE,0);-1===t&&(t=e.indexOf(m.u.V2K_RGP_LINE));const n=e.indexOf(m.u.V3K_END,t);return e.substring(0,t)+e.substring(n)}(a.molfile),n),p=function(e){let t=(e=e.replaceAll("\r","")).indexOf(m.u.V3K_BEGIN_COUNTS_LINE)+m.u.V3K_COUNTS_SHIFT,n=e.indexOf(" ",t+1);const o=parseInt(e.substring(t,n));return t=n+1,n=e.indexOf(" ",t+1),{atomCount:o,bondCount:parseInt(e.substring(t,n))}}(d),f=function(e,t){const n=new Array(t),o=new Float32Array(t),r=new Float32Array(t),i=new Array(t);let s=e.indexOf(m.u.V3K_BEGIN_ATOM_BLOCK);s=e.indexOf("\n",s);let a=s;for(let l=0;l<t;l++){s=e.indexOf(m.u.V3K_BEGIN_DATA_LINE,s)+m.u.V3K_IDX_SHIFT,a=e.indexOf(" ",s),s=a+1,a=e.indexOf(" ",s),n[l]=e.substring(s,a);const t=new Array(2);for(let n=0;n<2;++n)s=a+1,a=e.indexOf(" ",s),t[n]=parseFloat(e.substring(s,a));o[l]=t[0],r[l]=t[1],s=a,a=e.indexOf("\n",s)+1,i[l]=e.slice(s,a),s=a}return{atomTypes:n,x:o,y:r,kwargs:i}}(d,p.atomCount),g=function(e,t){const n=new Uint32Array(t),o=new Array(t),r=new Map,i=new Map;let s=e.indexOf(m.u.V3K_BEGIN_BOND_BLOCK);s=e.indexOf("\n",s);let a=s;for(let l=0;l<t;++l){const t=new Array(3);s=e.indexOf(m.u.V3K_BEGIN_DATA_LINE,a)+m.u.V3K_IDX_SHIFT,a=e.indexOf(" ",s);for(let n=0;n<3;++n)s=a+1,a=Math.min(e.indexOf("\n",s),e.indexOf(" ",s)),t[n]=parseInt(e.slice(s,a));n[l]=t[0],o[l]=t.slice(1);const c=e.indexOf("\n",s);let u=e.slice(a,c),h=u.indexOf(m.u.V3K_BOND_CONFIG);if(-1!==h){h=u.indexOf("=",h)+1;let e=u.indexOf(" ",h);-1===e&&(e=u.length);const t=parseInt(u.slice(h,e));r.set(l,t);const n=m.u.V3K_BOND_CONFIG+t.toString();u=u.replace(n,"")}u||i.set(l,u)}return{bondTypes:n,atomPairs:o,bondConfiguration:r,kwargs:i}}(d,p.bondCount),y=function(e,t,n,o){const r={backboneShift:null,branchShift:null,terminalNodes:[],rNodes:[]};if(n&&o&&[1,2].some((e=>!Array.from(o.values()).find((t=>t==e))))){const r=[1,2].find((e=>!Array.from(o.values()).find((t=>t==e)))),i=[1,2].find((e=>Array.from(o.values()).find((t=>t==e)))),s=Array.from(o.keys()).find((e=>o.get(e)===i))-1,a=e.x[s],l=e.y[s],c=t.atomPairs.find((e=>e.includes(s+1))).find((e=>e!==s+1))-1;let u=e.x.reduce(((t,n,o)=>{if(o===s)return t;if(o===c)return t;const r=e.y[o];return Math.sqrt((n-a)**2+(r-l)**2)>Math.sqrt((e.x[t]-a)**2+(e.y[t]-l)**2)?o:t}),-1);if(-1===u&&(u=e.x.length,e.x=new Float32Array([...e.x,-a]),e.y=new Float32Array([...e.y,-l]),e.atomTypes=[...e.atomTypes,"H"],e.kwargs=[...e.kwargs,""],t.atomPairs.push([c+1,u+1]),t.bondTypes=new Uint32Array([...t.bondTypes,1]),t.kwargs.set(t.atomPairs.length-1,"")),o.set(u+1,r),1===r)n.unshift(e.atomTypes[u]);else{if(2!==r)throw new Error(`Unexpected missing R-group: ${r}`);n.splice(1,0,e.atomTypes[u])}}return function(e,t,n){for(const[o,r]of n)e.atomTypes[o-1]=t[r-1]}(e,n,o),function(e,t){t.rNodes=Array.from(e.keys());for(let n=0;n<t.rNodes.length;n++)for(const o of[1,2])if(e.get(t.rNodes[n])===o){const e=t.rNodes[o-1];t.rNodes[o-1]=t.rNodes[n],t.rNodes[n]=e}}(o,r),v(t,r),r}(f,g,c,h),b=function(e){let t=[],n=e.indexOf("M V30 MDLV30/STEABS ATOMS=(");for(;-1!==n;){n+=28;const o=e.indexOf(")",n);t=t.concat(e.substring(n,o).split(" ").slice(1).map((e=>parseInt(e)))),n=o,n=e.indexOf("M V30 MDLV30/STEABS ATOMS=(",n)}return t}(d),x={atoms:f,bonds:g,meta:y,stereoAtoms:b};if("PEPTIDE"===o)T(x);else{const t=i===u.ZN.SUGAR||void 0===i&&(e===m.u.RIBOSE.symbol||e===m.u.DEOXYRIBOSE.symbol),n=i===u.ZN.PHOSPHATE||void 0===i&&e===m.u.PHOSPHATE.symbol;if(i===u.ZN.TERMINAL_5P||i===u.ZN.TERMINAL_3P){const e=a.rgroups?.[0]?.label,t="R1"===e?0:"R2"===e?1:-1,n=i===u.ZN.TERMINAL_5P?1:0;-1!==t&&t!==n&&([x.meta.rNodes[0],x.meta.rNodes[1]]=[x.meta.rNodes[1],x.meta.rNodes[0]],[x.meta.terminalNodes[0],x.meta.terminalNodes[1]]=[x.meta.terminalNodes[1],x.meta.terminalNodes[0]]),T(x)}else t?function(e,t){const n=e.atoms.x,o=e.atoms.y;if(0===e.meta.terminalNodes.length)return;const r=e.meta.terminalNodes[0]-1,i=e.meta.terminalNodes.length>1?e.meta.terminalNodes[1]-1:-1;P(e,-n[r],-o[r]);let s=0,a=0;if(i>=0&&i!==r?(s=n[i],a=o[i]):e.meta.rNodes.length>1&&e.meta.rNodes[1]-1>=0&&(s=n[e.meta.rNodes[1]-1],a=o[e.meta.rNodes[1]-1]),0!==s||0!==a){const t=E(s,a);S(e.atoms,-t-Math.PI/2)}let l=null;e.meta.rNodes.length>2&&e.meta.rNodes[2]-1>=0?l=o[e.meta.rNodes[2]-1]:e.meta.terminalNodes.length>2&&e.meta.terminalNodes[2]-1>=0&&(l=o[e.meta.terminalNodes[2]-1]),null!==l&&l<0&&N(e),function(e){if(e.meta.rNodes.length<=2||e.meta.terminalNodes.length<=2)return;const t=e.meta.rNodes[2]-1,n=e.meta.terminalNodes[2]-1;if(t<0||n<0)return;const o=e.atoms.x,r=e.atoms.y,i=new Set;for(const t of e.meta.rNodes)t>=1&&i.add(t-1);let s=-1/0;for(let e=0;e<r.length;++e)!i.has(e)&&r[e]>s&&(s=r[e]);if(!Number.isFinite(s))return;if(r[n]>=s-.5)return;o[t]=o[n],r[t]=s+1.5}(e),e.meta.rNodes.length>2&&e.meta.terminalNodes.length>2&&e.meta.rNodes[2]-1>=0&&e.meta.terminalNodes[2]-1>=0?t.value=function(e){const t=e.atoms.x,n=e.atoms.y,o=e.meta.rNodes[2]-1,r=e.meta.terminalNodes[2]-1,i=t[o]-t[r],s=n[o]-n[r];return Math.atan2(i,s)}(e):t.value=0;const c=e.meta.terminalNodes[0]-1;P(e,-n[c],-o[c])}(x,r):n?function(e){const t=e.atoms.x,n=e.atoms.y;if(0===e.meta.terminalNodes.length)return;const o=e.meta.terminalNodes[0]-1,r=e.meta.terminalNodes.length>1?e.meta.terminalNodes[1]-1:-1;P(e,-t[o],-n[o]);let i=0,s=0;if(r>=0&&r!==o?(i=t[r],s=n[r]):e.meta.rNodes.length>1&&e.meta.rNodes[1]-1>=0?(i=t[e.meta.rNodes[1]-1],s=n[e.meta.rNodes[1]-1]):e.meta.rNodes.length>0&&e.meta.rNodes[0]-1>=0&&(i=-t[e.meta.rNodes[0]-1],s=-n[e.meta.rNodes[0]-1]),0!==i||0!==s){const t=E(i,s);S(e.atoms,-t-Math.PI/2)}if(e.meta.rNodes.length>=2){const n=e.meta.rNodes[0]-1,o=e.meta.rNodes[1]-1;n>=0&&o>=0&&t[n]>t[o]&&I(e)}}(x):function(e,t){const n=e.atoms.x,o=e.atoms.y,r=e.meta.terminalNodes[0]-1,i=e.meta.rNodes[0]-1;P(e,-n[r],-o[r]);const s=E(n[i],o[i]),a=t.value;if(null===a)throw new Error("The value of sugarBranchToOYAngle is null");S(e.atoms,Math.PI-s+a);const c=function(e,t){return(0,l.YN)(Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2))}({x:n[e.meta.rNodes[0]-1],y:o[e.meta.rNodes[0]-1]},{x:n[e.meta.terminalNodes[0]-1],y:o[e.meta.terminalNodes[0]-1]});if(1!=c)for(let e=0;e<n.length;++e)n[e]=(0,l.YN)(n[e]/c),o[e]=(0,l.YN)(o[e]/c)}(x,r)}return function(e,t,n,o){if("PEPTIDE"===e){C(t,e);const n=w(t,t.meta.rNodes[1]);n?.removedAtom&&(t.terminalR2Atom=n.removedAtom)}else if(o===u.ZN.TERMINAL_5P)C(t,e),w(t,t.meta.rNodes[1]);else if(o===u.ZN.TERMINAL_3P)w(t,t.meta.rNodes[0]);else{const r=o===u.ZN.SUGAR||void 0===o&&(n===m.u.RIBOSE.symbol||n===m.u.DEOXYRIBOSE.symbol),i=o===u.ZN.PHOSPHATE||void 0===o&&n===m.u.PHOSPHATE.symbol;if(r)w(t,t.meta.rNodes[1]),t.meta.rNodes[1]=t.meta.terminalNodes[1],v(t.bonds,t.meta),C(t,e),w(t,t.meta.rNodes[1]),w(t,t.meta.rNodes[0]),w(t,t.meta.rNodes[2]);else if(i){const n=t.meta.rNodes[0]-1,o=t.atoms.atomTypes[n];o?.toUpperCase()===m.u.HYDROGEN&&(t.atoms.atomTypes[n]=m.u.OXYGEN),t.meta.terminalNodes[0]=t.meta.rNodes[0],P(t,-t.atoms.x[t.meta.terminalNodes[0]-1],-t.atoms.y[t.meta.terminalNodes[0]-1]),C(t,e),w(t,t.meta.rNodes[1])}}}(o,x,e,i),function(e){let t=0;for(;t<e.atoms.atomTypes.length;)e.atoms.atomTypes[t]===m.u.HYDROGEN&&(w(e,t+1),--t),++t}(x),function(e){let t=0;for(;t<e.atoms.atomTypes.length;)"oh"===e.atoms.atomTypes[t]?.toLowerCase()&&(e.atoms.atomTypes[t]="O"),"?"===e.atoms.atomTypes[t]&&(e.atoms.atomTypes[t]="H"),++t}(x),function(e){const t=" RGROUPS=(1 1)";for(let n=0;n<(e.atoms.kwargs?.length??0);n++){const o=e.atoms.kwargs[n];o&&o.includes(t)&&(e.atoms.kwargs[n]=o.replace(t,""))}}(x),x}var s;return null}(t,n,o,r,i,s);if(!c)throw new Error(`Monomer with symbol '${t}' is absent the monomer library`);(0,u.LQ)(e,a,c)}}function v(e,t){const n=t.rNodes;t.terminalNodes=new Array(n.length).fill(0);const o=t.terminalNodes,r=e.atomPairs;let i=0,s=0;for(;i<r.length&&s<o.length;){for(let e=0;e<o.length;++e)for(let t=0;t<2;++t)r[i][t]===n[e]&&(o[e]=r[i][(t+1)%2],n.length,++s);++i}}function C(e,t){e.meta.rNodes.length>1&&(e.meta.backboneShift=x(e,e.meta.rNodes[1]-1,e.meta.terminalNodes[0]-1)),"RNA"===t&&e.meta.rNodes.length>2&&(e.meta.branchShift=x(e,e.meta.rNodes[2]-1,e.meta.terminalNodes[0]-1))}function x(e,t,n){return[(0,l.YN)(e.atoms.x[t]-e.atoms.x[n]),(0,l.YN)(e.atoms.y[t]-e.atoms.y[n])]}function w(e,t){if(void 0!==t){const n=t-1,o=e.atoms,r=e.bonds,i=e.meta,s=o.atomTypes.splice(n,1)[0];o.x=A(Float32Array,o.x,n,1),o.y=A(Float32Array,o.y,n,1),o.kwargs.splice(n,1);for(let e=0;e<i.terminalNodes.length;++e)i.terminalNodes[e]>t?--i.terminalNodes[e]:i.terminalNodes[e]===t&&(i.terminalNodes[e]=-1);for(let e=0;e<i.rNodes.length;++e)i.rNodes[e]>t?--i.rNodes[e]:i.rNodes[e]===t&&(i.rNodes[e]=-1);let a=0;for(;a<r.atomPairs.length;){const e=r.atomPairs[a][0],n=r.atomPairs[a][1];e===t||n===t?(r.atomPairs.splice(a,1),r.bondTypes=A(Uint32Array,r.bondTypes,a,1),r.bondConfiguration.has(a)&&r.bondConfiguration.delete(a),r.kwargs.has(a)&&r.kwargs.delete(a),--a):(r.atomPairs[a][0]=e>t?e-1:e,r.atomPairs[a][1]=n>t?n-1:n),++a}let l=Array.from(r.bondConfiguration.keys());return l.forEach((e=>{if(r.bondConfiguration.has(e)&&e>n){const t=r.bondConfiguration.get(e);r.bondConfiguration.delete(e),r.bondConfiguration.set(e-1,t)}})),l=Array.from(r.kwargs.keys()),l.forEach((e=>{if(r.kwargs.has(e)&&e>n){const t=r.kwargs.get(e);r.kwargs.delete(e),r.kwargs.set(e-1,t)}})),s?{removedAtom:s}:void 0}}function A(e,t,n,o){const r=new e(t.length-o);let i=0,s=0;for(;i<t.length;)i===n&&(i+=o),r[s]=t[i],++s,++i;return r}function T(e){const t=e.meta.terminalNodes[0]-1,n=e.meta.rNodes[0]-1,o=e.atoms.x,r=e.atoms.y;P(e,-o[t],-r[t]);const i=E(o[n],r[n]);S(e.atoms,-i),o[e.meta.rNodes[1]-1]<0&&I(e);const s=function(e){const t=function(e){const t=new Map;for(const n of e.bonds.atomPairs)for(let e=0;e<2;e++){const o=n[e],r=n[(e+1)%2];t.has(o)?t.get(o)?.push(r):t.set(o,new Array(1).fill(r))}return t}(e);let n=0;const o=e.atoms.atomTypes.length;let r=0;if(e.meta.terminalNodes.length<2)return null;for(;0===n;){const i=t.get(e.meta.terminalNodes[1])[r];if(e.atoms.atomTypes[i-1]===m.u.OXYGEN&&i!==e.meta.rNodes[1]&&(n=i),r++,r>o)return null}return n}(e);null!=s&&(function(e,t){e.atoms.y[e.meta.rNodes[1]-1]<0&&e.atoms.y[t-1]<0&&(N(e),S(e.atoms,-function(e,t){return E(e,t)+Math.PI/2}(e.atoms.x[e.meta.terminalNodes[1]-1],e.atoms.y[e.meta.terminalNodes[1]-1])))}(e,s),function(e,t){const n=e.atoms.x;n[e.meta.rNodes[1]-1]>n[t-1]&&function(e,t,n){const o=t-1,r=n-1,i=e.atoms.x,s=e.atoms.y,a=i[o],l=s[o];i[o]=i[r],s[o]=s[r],i[r]=a,s[r]=l}(e,t,e.meta.rNodes[1])}(e,s))}function E(e,t){let n;if(0===e)n=t>0?0:Math.PI;else if(0===t)n=e>0?-Math.PI/2:Math.PI/2;else{const o=t/e,r=Math.atan(o);n=e<0?Math.PI/2+r:-Math.PI/2+r}return n}function S(e,t){if(0!==t){const n=e.x,o=e.y,r=Math.cos(t),i=Math.sin(t);for(let e=0;e<n.length;++e){const t=n[e];n[e]=(0,l.YN)(t*r-o[e]*i),o[e]=(0,l.YN)(t*i+o[e]*r)}}}function N(e){M(e,!0)}function I(e){M(e,!1)}function M(e,t){if(t){const t=e.atoms.y;for(let e=0;e<t.length;e++)t[e]=-t[e]}else{const t=e.atoms.x;for(let e=0;e<t.length;e++)t[e]=-t[e]}const n=e.bonds.bondConfiguration;for(const[e,t]of n){const o=1===t?3:1;n.set(e,o)}}function P(e,t,n){const o=e.atoms.x,r=e.atoms.y;for(let e=0;e<o.length;++e)o[e]=(0,l.YN)(o[e]+t),void 0!==n&&(r[e]=(0,l.YN)(r[e]+n))}},294:(e,t,n)=>{"use strict";function o(e,t){return e[t.polymerType]?.[t.symbol]}function r(e,t){return!!e[t.polymerType]?.[t.symbol]}function i(e,t,n){let o=e[t.polymerType];o||(o=e[t.polymerType]={}),o[t.symbol]=n}var s;n.d(t,{Cg:()=>a,LQ:()=>i,ZN:()=>s,bq:()=>r,vF:()=>l,xb:()=>o}),function(e){e[e.SUGAR=0]="SUGAR",e[e.BASE=1]="BASE",e[e.PHOSPHATE=2]="PHOSPHATE",e[e.TERMINAL_5P=3]="TERMINAL_5P",e[e.TERMINAL_3P=4]="TERMINAL_3P"}(s||(s={}));class a extends Map{constructor(e){super(e)}}class l{constructor(e,t){this.molfile=e,this.monomers=t}static createEmpty(){return new l("",new a(null))}}},330:(e,t,n)=>{"use strict";n.d(t,{pz:()=>i,qj:()=>r,vG:()=>s});var o=n(2003);function r(e,t){return function(e,t){return e?e.columns.getUnusedName(t):t}(e,`molfile(${t})`)}function i(e){let t;if(e===o.YI.PT||e===o.YI.UN)t="PEPTIDE";else{if(e!==o.YI.RNA&&e!==o.YI.DNA)throw new Error(`Unexpected alphabet '${e}'.`);t="RNA"}return t}function s(e){const t=7===e.length?/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e):/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return t?[parseInt(t[1],16)/256,parseInt(t[2],16)/256,parseInt(t[3],16)/256,t.length>4?parseInt(t[4],16)/256:.3]:null}},4971:(e,t,n)=>{"use strict";n.d(t,{pj:()=>r});var o=n(6082);async function r(){const e=o.Func.find({package:"Bio",name:"getMonomerLibHelper"});if(0===e.length)throw new Error('Package "Bio" must be installed for MonomerLibHelper.');return(await e[0].prepare().call()).getOutputParamValue()}},3151:(e,t,n)=>{"use strict";n.d(t,{f6:()=>o,pe:()=>r});const o=["symbol","molfile","rgroups","name"],r={monomerType:"Backbone",smiles:"",name:"",author:"Datagrok",molfile:"",naturalAnalog:"",rgroups:[],createDate:null,id:0,polymerType:"PEPTIDE",symbol:""};new RegExp("[rd]\\((\\w)\\)p?","g")},9192:(e,t,n)=>{"use strict";function o(e){return"string"==typeof e||e instanceof String?e:"StateError"===e.constructor.name?e.message:"StateError"===e.constructor.name&&"$thrownJsError"in e?o(e.$thrownJsError):e instanceof Error?e.message:e.toString()}function r(e){return e instanceof Error?e.stack:"StateError"===e.constructor.name&&"$thrownJsError"in e?r(e.$thrownJsError):void 0}function i(e){return[o(e),r(e)]}n.d(t,{AP:()=>i})},439:(e,t,n)=>{"use strict";n.d(t,{Hi:()=>o,VR:()=>u,YI:()=>r,_S:()=>l,b9:()=>c,gp:()=>i,qE:()=>i});var o,r,i,s=n(2738);!function(e){e.FASTA="fasta",e.SEPARATOR="separator",e.HELM="helm",e.CUSTOM="custom",e.BILN="biln"}(o||(o={})),function(e){e.DNA="DNA",e.RNA="RNA",e.PT="PT",e.UN="UN"}(r||(r={})),function(e){e.aligned="aligned",e.alphabet="alphabet",e.alphabetSize=".alphabetSize",e.alphabetIsMultichar=".alphabetIsMultichar",e.separator="separator",e.isHelmCompatible=".isHelmCompatible",e.positionNames=".positionNames",e.positionLabels=".positionLabels",e.regions=".regions",e.positionShift=".positionShift",e.selectedPosition=".selectedPosition",e.polymerTypeColumnName=".polymerTypeColumnName",e.annotations=".annotations",e.numberingScheme=".numberingScheme",e.annotationColumnName=".annotationColumnName"}(i||(i={}));const a=new class{constructor(){this.fasta={peptide:new Set(["G","L","Y","S","E","Q","D","N","F","A","K","R","H","C","V","P","W","I","M","T"]),dna:new Set(["A","C","G","T"]),rna:new Set(["A","C","G","U"])}}},l=(new s.aD(r.PT,a.fasta.peptide,.5),new s.aD(r.DNA,a.fasta.dna,.55),new s.aD(r.RNA,a.fasta.rna,.55),""),c={[o.FASTA]:"-",[o.SEPARATOR]:"",[o.HELM]:"*",[o.BILN]:""},u="notationProviderConstructor"},2003:(e,t,n)=>{"use strict";n.d(t,{Hi:()=>o.Hi,YI:()=>o.YI,dh:()=>r.dh,gp:()=>o.gp,qp:()=>r.qp,zS:()=>r.zS});var o=n(439),r=n(7291)},2738:(e,t,n)=>{"use strict";n.d(t,{$G:()=>r,aD:()=>i});var o=n(439);class r{static get notationName(){return"Custom"}static get implementsFromHelm(){return!1}static convertFromHelm(e,t){throw new Error("Method convertFromHelm not implemented for this notation provider")}static async getProviderConstructors(){if(window?.DG){const e=window.DG.Func.find({meta:{role:o.VR}});return Promise.all(e.map((e=>e.apply({}))))}return[]}}class i{constructor(e,t,n){this.name=e,this.alphabet=t,this.cutoff=n}}},7291:(e,t,n)=>{"use strict";n.d(t,{Mu:()=>b,dh:()=>C,zS:()=>E,MD:()=>S,qp:()=>A});var o=n(6082),r=n(1991),i=n.n(r),s=(n(2738),n(439));class a{static makePalette(e,t=!1,n=a){const o={};return e.forEach((e=>{const n=e[0],r=e[1];n.forEach(((e,n)=>{o[e]=this.colourPalette[r][t?0:n]}))})),new n(o)}constructor(e){this._palette=e}get(e,t){return this._palette[e]}}a.undefinedColor="rgb(100,100,100)",a.colourPalette={orange:["rgb(255,187,120)","rgb(245,167,100)","rgb(235,137,70)","rgb(205, 111, 71)"],all_green:["rgb(44,160,44)","rgb(74,160,74)","rgb(23,103,57)","rgb(30,110,96)","rgb(60,131,95)","rgb(24,110,79)","rgb(152,223,138)","rgb(182, 223, 138)","rgb(152, 193, 138)"],all_blue:["rgb(31,119,180)","rgb(23,190,207)","rgb(122, 102, 189)","rgb(158,218,229)","rgb(141, 124, 217)","rgb(31, 120, 150)"],magenta:["rgb(162,106,192)","rgb(197,165,224)","rgb(208,113,218)"],red:["rgb(214,39,40)","rgb(255,152,150)"],st_blue:["rgb(23,190,207)","rgb(158,218,229)","rgb(31,119,180)"],dark_blue:["rgb(31,119,180)","rgb(31, 120, 150)"],light_blue:["rgb(23,190,207)","rgb(158,218,229)","rgb(108, 218, 229)","rgb(23,190,227)"],lilac_blue:["rgb(124,102,211)","rgb(149,134,217)","rgb(97, 81, 150)"],dark_green:["rgb(23,103,57)","rgb(30,110,96)","rgb(60,131,95)","rgb(24,110,79)"],green:["rgb(44,160,44)","rgb(74,160,74)"],light_green:["rgb(152,223,138)","rgb(182, 223, 138)","rgb(152, 193, 138)"],st_green:["rgb(44,160,44)","rgb(152,223,138)","rgb(39, 174, 96)","rgb(74,160,74)"],pink:["rgb(247,182,210)"],brown:["rgb(140,86,75)","rgb(102, 62, 54)"],gray:["rgb(127,127,127)","rgb(199,199,199)","rgb(196,156,148)","rgb(222, 222, 180)"],yellow:["rgb(188,189,34)"],white:["rgb(230,230,230)"]};class l extends a{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,l)),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,l)),this.grokGroups}static get RasMol(){return void 0===this.rasMol&&(this.rasMol=new l({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(e){const t=e in l.aaSynonyms?l.aaSynonyms[e]:e;return super.get(t)}}l.aaSynonyms={MeNle:"L",MeA:"A",MeG:"G",MeF:"F"};class c{static getPalette(e="grok"){switch(e){case"grok":return l.GrokGroups;case"lesk":return l.Lesk;default:throw new Error(`ChemPalette: scheme \`${e}\` does not exist`)}}static getInnerOuter(e){let t=0,n="",o="";for(const r of e)"("==r?t++:")"==r?t--:t?n+=r:o+=r;return isNaN(parseInt(n))?[o,n]:[o,""]}static getColorAAPivot(e="",t="grok"){const n=this.getPalette(t);let[o,r]=this.getInnerOuter(e);if(o=o.length>6?`${o.slice(0,3)}...`:o,r=r.length>6?`${r.slice(0,3)}...`:r,1==e.length||"("==e[1]){const t=e[0]?.toUpperCase();return t in n?[n.get(t),t,r,1]:[this.undefinedColor,o,r,1]}if("d"==e[0]&&e[1]in n&&(2==e.length||"("==e[2])){const t=e[1]?.toUpperCase();return t in n?[n.get(t),t,r,2]:[this.undefinedColor,o,r,2]}if(e.substring(0,3)in this.AAFullNames&&(3==e.length||"("==e[3])){const t=this.AAFullNames[e.substring(0,3)];return t in n?[n.get(t),t,r,3]:[this.undefinedColor,o,r,3]}if(e[0]?.toLowerCase()==e[0]&&e.substring(1,3)in this.AAFullNames&&(4==e.length||"("==e[4])){const t=this.AAFullNames[e.substring(1,3)];return t in n?[n.get(t),t,r,4]:[this.undefinedColor,o,r,4]}return[this.undefinedColor,o,r,0]}}c.SemType="Aminoacids",c.SemTypeMultipleAlignment="AminoacidsMultipleAlignment",c.undefinedColor="rgb(100,100,100)",c.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"},c.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"},c.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(*)*"},c.AAFullNames={Ala:"A",Arg:"R",Asn:"N",Asp:"D",Cys:"C",Gln:"Q",Glu:"E",Gly:"G",His:"H",Ile:"I",Leu:"L",Lys:"K",Met:"M",Phe:"F",Pro:"P",Ser:"S",Thr:"T",Trp:"W",Tyr:"Y",Val:"V"};class u{}u.SemType="Nucleotides",u.SemTypeMultipleAlignment="NucleotidesMultipleAlignment",u.Names={A:"Adenine",C:"Cytosine",G:"Guanine",T:"Thymine",U:"Uracil"};var h=n(4971);function d(e,t=!0){if(null==e)return"rgb(100,100,100)";const n=o.Color.fromHtml(e);if(t){const e=o.Color.g(n),t=o.Color.r(n),r=o.Color.b(n),i=Math.sqrt(Math.pow(0-t,2)+Math.pow(0-e,2)+Math.pow(0-r,2));if(i>210)return`rgb(${t/i*210},${e/i*210},${r/i*210})`}return o.Color.toRgb(n)}class p{static hashCode(e){let t=0;if(0===e.length)return t;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return t}}class m{}class f extends m{static get palette(){return f._pallete||(f._pallete=f.buildPalette()),f._pallete}static buildPalette(){return(0,h.pj)().then((e=>{e.awaitLoaded(1/0).then((()=>{const t=e.getMonomerLib();t.onChanged.subscribe((()=>{f.customMonomerColors={},f.polymerTypes=t.getPolymerTypes();for(const e of this.polymerTypes){const n=t.getMonomerSymbolsByType(e);for(const o of n){const n=t.getMonomer(e,o);n?.meta?.colors?.default?.background&&(this.customMonomerColors[o]||(this.customMonomerColors[o]={}),this.customMonomerColors[o][e]=d(n.meta.colors.default.background))}}}))}))})),[].concat(...Object.values(a.colourPalette))}get(e,t){const n=f.palette.length,o=f.customMonomerColors[e],r=t??"PEPTIDE";if(o&&o[r])return o[r];const i=p.hashCode(e)%n;return d(f.palette[i])}}f._pallete=null,f.customMonomerColors={},f.polymerTypes=[];var g=n(8438),y=n(3599);class b{get length(){return this.mList.length}get graphInfo(){}isGap(e){return this.getOriginal(e)===this.gapOriginalMonomer}getCanonical(e){if(this.length<=e)throw new Error("Index out of bounds");const t=this.mList[e];return t!==this.gapOriginalMonomer?t:s._S}getOriginal(e){if(this.length<=e)throw new Error("Index out of bounds");return this.mList[e]}getCanonicalRegion(e,t){const n=Math.min(Math.max(0,e),this.length),o=Math.max(Math.min(this.length,t),0)-n,r=this.gapOriginalMonomer;return new Array(o).fill(null).map(((e,t)=>{const o=this.mList[t+n];return o===r?s._S:o}))}getOriginalRegion(e,t){const n=Math.min(Math.max(0,e),this.length),o=Math.max(Math.min(this.length,t),0);return new Array(o-n).fill(null).map(((e,t)=>this.mList[t+n]))}get gapOriginal(){return this.gapOriginalMonomer}constructor(e,t){this.mList=e,this.gapOriginalMonomer=t}}class v extends b{constructor(e,t,n,o){super(e.flat(),o),this.mListSeparated=e,this.connections=t,this._graphInfo=void 0,this.polymerTypes=e.map(((e,t)=>new Array(e.length).fill(n[t]))).flat()}get graphInfo(){return this._graphInfo??(this._graphInfo=this.parseConnections()),this._graphInfo}parseConnections(){const e={connections:[],disjointSeqStarts:[],polymerTypes:this.polymerTypes};if((this.connections?.length??0)>0){let t=0;for(let n=0;n<this.mListSeparated.length;++n)e.disjointSeqStarts.push(t),t+=this.mListSeparated[n].length;const n=(this.connections??"").split("|").filter((e=>(e?.length??0)>0)),o=/^(PEPTIDE|RNA|BLOB|CHEM)\d{1,2}$/,r=/^\d{1,2}:R\d{1}-\d{1,2}:R\d{1}$/;for(const t of n){const n=t.split(",");if(3!==n.length||!r.test(n[2])||!o.test(n[0])||!o.test(n[1]))continue;const i=parseInt(n[0].replace(/^(PEPTIDE|RNA|BLOB|CHEM)/,""))-1,s=parseInt(n[1].replace(/^(PEPTIDE|RNA|BLOB|CHEM)/,""))-1,a=n[0].replace(/\d{1,2}$/,""),l=n[1].replace(/\d{1,2}$/,"");if(i<0||i>=this.mListSeparated.length||s<0||s>=this.mListSeparated.length)continue;const c=n[2].split("-");if(2!==c.length)continue;const u=c[0].split(":"),h=c[1].split(":");if(2!==u.length||2!==h.length)continue;const d=parseInt(u[0])-1,p=parseInt(h[0])-1;d<0||d>=this.mListSeparated[i].length||p<0||p>=this.mListSeparated[s].length||e.connections.push({seq1Type:a,seq2Type:l,seqIndex1:i,seqIndex2:s,monomerIndex1:d,monomerIndex2:p,rGroup1:parseInt(u[1].substring(1)),rGroup2:parseInt(h[1].substring(1))})}}return e}}function C(e,t=void 0){return n=>{if(n){let o;const r=new RegExp(`(?<=^|\\${e})("-"|'-'|[^\\${e}]*)(?=\\${e}|$)`,"g");return null!=t?(r.lastIndex=0,o=i()(n.matchAll(r)).take(t).map((e=>e[0])).toArray()):o=n.replaceAll('"-"',"").replaceAll("'-'","").split(e,t),new b(o,s.b9[s.Hi.SEPARATOR])}return new b([],s.b9[s.Hi.SEPARATOR])}}const x=/^((?:[^\[\]()]|\[[^\[\]]*\])+)\(((?:[^\[\]()]|\[[^\[\]]*\])+)\)((?:[^\[\]()]|\[[^\[\]]*\])+)$/,w=/^((?:[^\[\]()]|\[[^\[\]]*\])+)\(((?:[^\[\]()]|\[[^\[\]]*\])+)\)$/,A=e=>{const t=e.indexOf("}$"),n=e.substring(0,t+1),o=e.indexOf("$",t+2),r=e.substring(t+2,o),i=n.split("}|");for(let e=0;e<i.length-1;e++)i[e]=i[e]+"}";const a=i.map((e=>e.replace(/\d{1,2}\{.+\}/,""))),l=i.map(((e,t)=>(e.match(/(?<=\{).+(?=})/)?.[0]?.split(".")??[]).flatMap((e=>{if("RNA"===a[t]){const t=x.exec(e);if(null!=t)return[(0,g.D)(t[1]),(0,g.D)(t[2]),(0,g.D)(t[3])];const n=w.exec(e);if(null!=n)return[(0,g.D)(n[1]),(0,g.D)(n[2])]}return[(0,g.D)(e)]}))));return new v(l,r??"",a,s.b9[s.Hi.HELM])},T=/([^\W_]+)/g;function E(e,t){if(e.length<=t)return e;const n=e.match(T),o=e.length>t||(n?.length??0)>1,r=n?.[0]??" ";return o?r.substring(0,t-1)+"…":r}function S(e){switch(e){case"PEPTIDE":default:return y.o.AA;case"RNA":return y.o.NUCLEOTIDE;case"CHEM":return y.o.CHEM;case"BLOB":return y.o.BLOB}}},8312:(e,t,n)=>{"use strict";n.d(t,{Q:()=>r});var o=n(6082);async function r(){const e=o.Func.find({package:"Bio",name:"getSeqHelper"});if(0===e.length)throw new Error("Package 'Bio' must be installed for SeqHelper.");return(await e[0].prepare().call()).getOutputParamValue()}},6869:(e,t,n)=>{"use strict";var o;n.d(t,{o:()=>o}),function(e){e.BASE="HELM_BASE",e.SUGAR="HELM_SUGAR",e.LINKER="HELM_LINKER",e.AA="HELM_AA",e.CHEM="HELM_CHEM",e.BLOB="HELM_BLOB",e.NUCLEOTIDE="HELM_NUCLETIDE"}(o||(o={}))},2074:(e,t,n)=>{"use strict";n.d(t,{A:()=>a});var o=n(1354),r=n.n(o),i=n(6314),s=n.n(i)()(r());s.push([e.id,".st-colored-text-input > textarea {\n width: 100%;\n color: transparent !important;\n caret-color: var(--grey-6);\n -webkit-text-fill-color: transparent !important;\n background-color: transparent;\n position: relative;\n z-index: 1;\n resize: none;\n height: 22px; /* Fine tuned value to avoid \"jumping\" of the textarea upon autoresize */\n}\n\n.st-colored-text-input > div {\n /* The values here are fine tuned to those of the ui.input textarea in order\n * to achieve precise overlap */\n overflow: auto;\n position: absolute;\n pointer-events: none;\n cursor: text;\n z-index: 0;\n max-width: 100%;\n padding: 2px;\n line-height: normal;\n font-family: 'Roboto', 'Roboto Local', sans-serif;\n font-size: 13px;\n padding-top: 6px !important;\n color: transparent;\n white-space: pre-wrap;\n word-wrap: break-word;\n}\n","",{version:3,sources:["webpack://./src/apps/common/view/components/colored-input/style.css"],names:[],mappings:"AAAA;EACE,WAAW;EACX,6BAA6B;EAC7B,0BAA0B;EAC1B,+CAA+C;EAC/C,6BAA6B;EAC7B,kBAAkB;EAClB,UAAU;EACV,YAAY;EACZ,YAAY,EAAE,wEAAwE;AACxF;;AAEA;EACE;iCAC+B;EAC/B,cAAc;EACd,kBAAkB;EAClB,oBAAoB;EACpB,YAAY;EACZ,UAAU;EACV,eAAe;EACf,YAAY;EACZ,mBAAmB;EACnB,iDAAiD;EACjD,eAAe;EACf,2BAA2B;EAC3B,kBAAkB;EAClB,qBAAqB;EACrB,qBAAqB;AACvB",sourcesContent:[".st-colored-text-input > textarea {\n width: 100%;\n color: transparent !important;\n caret-color: var(--grey-6);\n -webkit-text-fill-color: transparent !important;\n background-color: transparent;\n position: relative;\n z-index: 1;\n resize: none;\n height: 22px; /* Fine tuned value to avoid \"jumping\" of the textarea upon autoresize */\n}\n\n.st-colored-text-input > div {\n /* The values here are fine tuned to those of the ui.input textarea in order\n * to achieve precise overlap */\n overflow: auto;\n position: absolute;\n pointer-events: none;\n cursor: text;\n z-index: 0;\n max-width: 100%;\n padding: 2px;\n line-height: normal;\n font-family: 'Roboto', 'Roboto Local', sans-serif;\n font-size: 13px;\n padding-top: 6px !important;\n color: transparent;\n white-space: pre-wrap;\n word-wrap: break-word;\n}\n"],sourceRoot:""}]);const a=s},9252:(e,t,n)=>{"use strict";n.d(t,{A:()=>a});var o=n(1354),r=n.n(o),i=n(6314),s=n.n(i)()(r());s.push([e.id,"/* Naming convention: class names should begin with st and app name to avoid naming collitions */\n\n.st-pattern-text-input > textarea {\n resize: none;\n}\n","",{version:3,sources:["webpack://./src/apps/pattern/view/style.css"],names:[],mappings:"AAAA,gGAAgG;;AAEhG;EACE,YAAY;AACd",sourcesContent:["/* Naming convention: class names should begin with st and app name to avoid naming collitions */\n\n.st-pattern-text-input > textarea {\n resize: none;\n}\n"],sourceRoot:""}]);const a=s},8507:(e,t,n)=>{"use strict";n.d(t,{A:()=>a});var o=n(1354),r=n.n(o),i=n(6314),s=n.n(i)()(r());s.push([e.id,"/* Naming convention: class names should begin with st and app name to avoid naming collitions */\n\n.st-structure-body {\n padding-right: 20px;\n height: 100%;\n display: flex;\n flex-direction: column;\n}\n\n.st-structure-mol-img {\n flex: 1 1 0;\n min-height: 100px;\n min-width: 0;\n transform: translateX(-50px);\n overflow: hidden;\n}\n\n.st-structure-mol-img canvas {\n max-width: 100% !important;\n height: auto !important;\n}\n\n.st-structure-bool-button-block {\n justify-content: right;\n margin-bottom: 10px;\n}\n\n.st-structure-bottom {\n flex: 1 1 0;\n padding-top: 20px;\n min-height: 0;\n}\n\n.st-structure-clear-buttons {\n justify-content: space-between;\n padding: 13px 10px 13px 10px;\n}\n\n.st-direction-inputs {\n align-items: end;\n}\n\n.st-structure-inputs {\n flex-grow: 2;\n padding-left: 10px;\n}","",{version:3,sources:["webpack://./src/apps/structure/view/style.css"],names:[],mappings:"AAAA,gGAAgG;;AAEhG;EACE,mBAAmB;EACnB,YAAY;EACZ,aAAa;EACb,sBAAsB;AACxB;;AAEA;EACE,WAAW;EACX,iBAAiB;EACjB,YAAY;EACZ,4BAA4B;EAC5B,gBAAgB;AAClB;;AAEA;EACE,0BAA0B;EAC1B,uBAAuB;AACzB;;AAEA;EACE,sBAAsB;EACtB,mBAAmB;AACrB;;AAEA;EACE,WAAW;EACX,iBAAiB;EACjB,aAAa;AACf;;AAEA;EACE,8BAA8B;EAC9B,4BAA4B;AAC9B;;AAEA;EACE,gBAAgB;AAClB;;AAEA;EACE,YAAY;EACZ,kBAAkB;AACpB",sourcesContent:["/* Naming convention: class names should begin with st and app name to avoid naming collitions */\n\n.st-structure-body {\n padding-right: 20px;\n height: 100%;\n display: flex;\n flex-direction: column;\n}\n\n.st-structure-mol-img {\n flex: 1 1 0;\n min-height: 100px;\n min-width: 0;\n transform: translateX(-50px);\n overflow: hidden;\n}\n\n.st-structure-mol-img canvas {\n max-width: 100% !important;\n height: auto !important;\n}\n\n.st-structure-bool-button-block {\n justify-content: right;\n margin-bottom: 10px;\n}\n\n.st-structure-bottom {\n flex: 1 1 0;\n padding-top: 20px;\n min-height: 0;\n}\n\n.st-structure-clear-buttons {\n justify-content: space-between;\n padding: 13px 10px 13px 10px;\n}\n\n.st-direction-inputs {\n align-items: end;\n}\n\n.st-structure-inputs {\n flex-grow: 2;\n padding-left: 10px;\n}"],sourceRoot:""}]);const a=s},5254:(e,t,n)=>{"use strict";n.d(t,{A:()=>a});var o=n(1354),r=n.n(o),i=n(6314),s=n.n(i)()(r());s.push([e.id,"/* Naming convention: class names should begin with st and app name to avoid naming collitions */\n.st-translator-input-table {\n /* width: 100%; */\n margin-right: 20px;\n}\n\n.st-translator-input-table td:has(textarea) {\n width: 100%;\n}\n\n.st-translator-input-table td:has(select) {\n min-width: 120px;\n vertical-align: top;\n}\n\n.st-translator-output-table {\n margin-top: 20px;\n margin-right: 20px;\n margin-bottom: 10px;\n}\n\n.st-translator-output-table table {\n width: 100%;\n table-layout: fixed;\n}\n\n.st-translator-output-table td {\n padding-top: 6px;\n padding-bottom: 6px;\n}\n.st-translator-output-table tr:nth-child(even) {\n background-color: var(--grey-1);\n}\n\n.st-translator-output-table td:nth-child(odd) {\n width: 120px;\n vertical-align: top;\n}\n\n.st-translator-output-table td a {\n overflow-wrap: break-word;\n}\n","",{version:3,sources:["webpack://./src/apps/translator/view/style.css"],names:[],mappings:"AAAA,gGAAgG;AAChG;EACE,iBAAiB;EACjB,kBAAkB;AACpB;;AAEA;EACE,WAAW;AACb;;AAEA;EACE,gBAAgB;EAChB,mBAAmB;AACrB;;AAEA;EACE,gBAAgB;EAChB,kBAAkB;EAClB,mBAAmB;AACrB;;AAEA;EACE,WAAW;EACX,mBAAmB;AACrB;;AAEA;EACE,gBAAgB;EAChB,mBAAmB;AACrB;AACA;EACE,+BAA+B;AACjC;;AAEA;EACE,YAAY;EACZ,mBAAmB;AACrB;;AAEA;EACE,yBAAyB;AAC3B",sourcesContent:["/* Naming convention: class names should begin with st and app name to avoid naming collitions */\n.st-translator-input-table {\n /* width: 100%; */\n margin-right: 20px;\n}\n\n.st-translator-input-table td:has(textarea) {\n width: 100%;\n}\n\n.st-translator-input-table td:has(select) {\n min-width: 120px;\n vertical-align: top;\n}\n\n.st-translator-output-table {\n margin-top: 20px;\n margin-right: 20px;\n margin-bottom: 10px;\n}\n\n.st-translator-output-table table {\n width: 100%;\n table-layout: fixed;\n}\n\n.st-translator-output-table td {\n padding-top: 6px;\n padding-bottom: 6px;\n}\n.st-translator-output-table tr:nth-child(even) {\n background-color: var(--grey-1);\n}\n\n.st-translator-output-table td:nth-child(odd) {\n width: 120px;\n vertical-align: top;\n}\n\n.st-translator-output-table td a {\n overflow-wrap: break-word;\n}\n"],sourceRoot:""}]);const a=s},890:(e,t,n)=>{"use strict";n.d(t,{A:()=>a});var o=n(1354),r=n.n(o),i=n(6314),s=n.n(i)()(r());s.push([e.id,".monomer-card-rule-root {\n border: 2px solid var(--grey-2);\n border-radius: 5px;\n padding: 5px;\n margin: 5px;\n overflow: hidden;\n align-items: center;\n cursor: pointer;\n width: 200px;\n height: 240px;\n min-width: 200px;\n min-height: 240px;\n}\n\n.monomer-card-info-rules {\n width: 100%;\n overflow: hidden;\n text-overflow: ellipsis;\n margin-bottom: 10px;\n}\n\n.monomer-card-info-rules > div:nth-child(2) {\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n\n.monomer-card-info-rules > div:nth-child(1) {\n font-weight: bold;\n margin-right: 5px;\n text-wrap: nowrap;\n}\n","",{version:3,sources:["webpack://./src/polytool/conversion/style.css"],names:[],mappings:"AAAA;IACI,+BAA+B;IAC/B,kBAAkB;IAClB,YAAY;IACZ,WAAW;IACX,gBAAgB;IAChB,mBAAmB;IACnB,eAAe;IACf,YAAY;IACZ,aAAa;IACb,gBAAgB;IAChB,iBAAiB;AACrB;;AAEA;IACI,WAAW;IACX,gBAAgB;IAChB,uBAAuB;IACvB,mBAAmB;AACvB;;AAEA;IACI,mBAAmB;IACnB,gBAAgB;IAChB,uBAAuB;AAC3B;;AAEA;IACI,iBAAiB;IACjB,iBAAiB;IACjB,iBAAiB;AACrB",sourcesContent:[".monomer-card-rule-root {\n border: 2px solid var(--grey-2);\n border-radius: 5px;\n padding: 5px;\n margin: 5px;\n overflow: hidden;\n align-items: center;\n cursor: pointer;\n width: 200px;\n height: 240px;\n min-width: 200px;\n min-height: 240px;\n}\n\n.monomer-card-info-rules {\n width: 100%;\n overflow: hidden;\n text-overflow: ellipsis;\n margin-bottom: 10px;\n}\n\n.monomer-card-info-rules > div:nth-child(2) {\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n\n.monomer-card-info-rules > div:nth-child(1) {\n font-weight: bold;\n margin-right: 5px;\n text-wrap: nowrap;\n}\n"],sourceRoot:""}]);const a=s},6314:e=>{"use strict";e.exports=function(e){var t=[];return t.toString=function(){return this.map((function(t){var n="",o=void 0!==t[5];return t[4]&&(n+="@supports (".concat(t[4],") {")),t[2]&&(n+="@media ".concat(t[2]," {")),o&&(n+="@layer".concat(t[5].length>0?" ".concat(t[5]):""," {")),n+=e(t),o&&(n+="}"),t[2]&&(n+="}"),t[4]&&(n+="}"),n})).join("")},t.i=function(e,n,o,r,i){"string"==typeof e&&(e=[[null,e,void 0]]);var s={};if(o)for(var a=0;a<this.length;a++){var l=this[a][0];null!=l&&(s[l]=!0)}for(var c=0;c<e.length;c++){var u=[].concat(e[c]);o&&s[u[0]]||(void 0!==i&&(void 0===u[5]||(u[1]="@layer".concat(u[5].length>0?" ".concat(u[5]):""," {").concat(u[1],"}")),u[5]=i),n&&(u[2]?(u[1]="@media ".concat(u[2]," {").concat(u[1],"}"),u[2]=n):u[2]=n),r&&(u[4]?(u[1]="@supports (".concat(u[4],") {").concat(u[1],"}"),u[4]=r):u[4]="".concat(r)),t.push(u))}},t}},1354:e=>{"use strict";e.exports=function(e){var t=e[1],n=e[3];if(!n)return t;if("function"==typeof btoa){var o=btoa(unescape(encodeURIComponent(JSON.stringify(n)))),r="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(o),i="/*# ".concat(r," */");return[t].concat([i]).join("\n")}return[t].join("\n")}},9982:function(e,t,n){var o;!function(){var t={};!function(e){"use strict";e.__esModule=!0,e.digestLength=32,e.blockSize=64;var t=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(e,n,o,r,i){for(var s,a,l,c,u,h,d,p,m,f,g,y,b;i>=64;){for(s=n[0],a=n[1],l=n[2],c=n[3],u=n[4],h=n[5],d=n[6],p=n[7],f=0;f<16;f++)g=r+4*f,e[f]=(255&o[g])<<24|(255&o[g+1])<<16|(255&o[g+2])<<8|255&o[g+3];for(f=16;f<64;f++)y=((m=e[f-2])>>>17|m<<15)^(m>>>19|m<<13)^m>>>10,b=((m=e[f-15])>>>7|m<<25)^(m>>>18|m<<14)^m>>>3,e[f]=(y+e[f-7]|0)+(b+e[f-16]|0);for(f=0;f<64;f++)y=(((u>>>6|u<<26)^(u>>>11|u<<21)^(u>>>25|u<<7))+(u&h^~u&d)|0)+(p+(t[f]+e[f]|0)|0)|0,b=((s>>>2|s<<30)^(s>>>13|s<<19)^(s>>>22|s<<10))+(s&a^s&l^a&l)|0,p=d,d=h,h=u,u=c+y|0,c=l,l=a,a=s,s=y+b|0;n[0]+=s,n[1]+=a,n[2]+=l,n[3]+=c,n[4]+=u,n[5]+=h,n[6]+=d,n[7]+=p,r+=64,i-=64}return r}var o=function(){function t(){this.digestLength=e.digestLength,this.blockSize=e.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 t.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},t.prototype.clean=function(){for(var e=0;e<this.buffer.length;e++)this.buffer[e]=0;for(e=0;e<this.temp.length;e++)this.temp[e]=0;this.reset()},t.prototype.update=function(e,t){if(void 0===t&&(t=e.length),this.finished)throw new Error("SHA256: can't update because hash was finished.");var o=0;if(this.bytesHashed+=t,this.bufferLength>0){for(;this.bufferLength<64&&t>0;)this.buffer[this.bufferLength++]=e[o++],t--;64===this.bufferLength&&(n(this.temp,this.state,this.buffer,0,64),this.bufferLength=0)}for(t>=64&&(o=n(this.temp,this.state,e,o,t),t%=64);t>0;)this.buffer[this.bufferLength++]=e[o++],t--;return this},t.prototype.finish=function(e){if(!this.finished){var t=this.bytesHashed,o=this.bufferLength,r=t/536870912|0,i=t<<3,s=t%64<56?64:128;this.buffer[o]=128;for(var a=o+1;a<s-8;a++)this.buffer[a]=0;this.buffer[s-8]=r>>>24&255,this.buffer[s-7]=r>>>16&255,this.buffer[s-6]=r>>>8&255,this.buffer[s-5]=r>>>0&255,this.buffer[s-4]=i>>>24&255,this.buffer[s-3]=i>>>16&255,this.buffer[s-2]=i>>>8&255,this.buffer[s-1]=i>>>0&255,n(this.temp,this.state,this.buffer,0,s),this.finished=!0}for(a=0;a<8;a++)e[4*a+0]=this.state[a]>>>24&255,e[4*a+1]=this.state[a]>>>16&255,e[4*a+2]=this.state[a]>>>8&255,e[4*a+3]=this.state[a]>>>0&255;return this},t.prototype.digest=function(){var e=new Uint8Array(this.digestLength);return this.finish(e),e},t.prototype._saveState=function(e){for(var t=0;t<this.state.length;t++)e[t]=this.state[t]},t.prototype._restoreState=function(e,t){for(var n=0;n<this.state.length;n++)this.state[n]=e[n];this.bytesHashed=t,this.finished=!1,this.bufferLength=0},t}();e.Hash=o;var r=function(){function e(e){this.inner=new o,this.outer=new o,this.blockSize=this.inner.blockSize,this.digestLength=this.inner.digestLength;var t=new Uint8Array(this.blockSize);if(e.length>this.blockSize)(new o).update(e).finish(t).clean();else for(var n=0;n<e.length;n++)t[n]=e[n];for(n=0;n<t.length;n++)t[n]^=54;for(this.inner.update(t),n=0;n<t.length;n++)t[n]^=106;for(this.outer.update(t),this.istate=new Uint32Array(8),this.ostate=new Uint32Array(8),this.inner._saveState(this.istate),this.outer._saveState(this.ostate),n=0;n<t.length;n++)t[n]=0}return e.prototype.reset=function(){return this.inner._restoreState(this.istate,this.inner.blockSize),this.outer._restoreState(this.ostate,this.outer.blockSize),this},e.prototype.clean=function(){for(var e=0;e<this.istate.length;e++)this.ostate[e]=this.istate[e]=0;this.inner.clean(),this.outer.clean()},e.prototype.update=function(e){return this.inner.update(e),this},e.prototype.finish=function(e){return this.outer.finished?this.outer.finish(e):(this.inner.finish(e),this.outer.update(e,this.digestLength).finish(e)),this},e.prototype.digest=function(){var e=new Uint8Array(this.digestLength);return this.finish(e),e},e}();function i(e){var t=(new o).update(e),n=t.digest();return t.clean(),n}function s(e,t){var n=new r(e).update(t),o=n.digest();return n.clean(),o}function a(e,t,n,o){var r=o[0];if(0===r)throw new Error("hkdf: cannot expand more");t.reset(),r>1&&t.update(e),n&&t.update(n),t.update(o),t.finish(e),o[0]++}e.HMAC=r,e.hash=i,e.default=i,e.hmac=s;var l=new Uint8Array(e.digestLength);e.hkdf=function(e,t,n,o){void 0===t&&(t=l),void 0===o&&(o=32);for(var i=new Uint8Array([1]),c=s(t,e),u=new r(c),h=new Uint8Array(u.digestLength),d=h.length,p=new Uint8Array(o),m=0;m<o;m++)d===h.length&&(a(h,u,n,i),d=0),p[m]=h[d++];return u.clean(),h.fill(0),i.fill(0),p},e.pbkdf2=function(e,t,n,o){for(var i=new r(e),s=i.digestLength,a=new Uint8Array(4),l=new Uint8Array(s),c=new Uint8Array(s),u=new Uint8Array(o),h=0;h*s<o;h++){var d=h+1;a[0]=d>>>24&255,a[1]=d>>>16&255,a[2]=d>>>8&255,a[3]=d>>>0&255,i.reset(),i.update(t),i.update(a),i.finish(c);for(var p=0;p<s;p++)l[p]=c[p];for(p=2;p<=n;p++){i.reset(),i.update(c).finish(c);for(var m=0;m<s;m++)l[m]^=c[m]}for(p=0;p<s&&h*s+p<o;p++)u[h*s+p]=l[p]}for(h=0;h<s;h++)l[h]=c[h]=0;for(h=0;h<4;h++)a[h]=0;return i.clean(),u}}(t);var r=t.default;for(var i in t)r[i]=t[i];"object"==typeof e.exports?e.exports=r:void 0===(o=function(){return r}.call(t,n,t,e))||(e.exports=o)}()},2543:function(e,t,n){var o;e=n.nmd(e),function(){var r,i="Expected a function",s="__lodash_hash_undefined__",a="__lodash_placeholder__",l=32,c=128,u=1/0,h=9007199254740991,d=NaN,p=4294967295,m=[["ary",c],["bind",1],["bindKey",2],["curry",8],["curryRight",16],["flip",512],["partial",l],["partialRight",64],["rearg",256]],f="[object Arguments]",g="[object Array]",y="[object Boolean]",b="[object Date]",v="[object Error]",C="[object Function]",x="[object GeneratorFunction]",w="[object Map]",A="[object Number]",T="[object Object]",E="[object Promise]",S="[object RegExp]",N="[object Set]",I="[object String]",M="[object Symbol]",P="[object WeakMap]",_="[object ArrayBuffer]",L="[object DataView]",O="[object Float32Array]",R="[object Float64Array]",$="[object Int8Array]",D="[object Int16Array]",B="[object Int32Array]",F="[object Uint8Array]",k="[object Uint8ClampedArray]",H="[object Uint16Array]",G="[object Uint32Array]",U=/\b__p \+= '';/g,V=/\b(__p \+=) '' \+/g,j=/(__e\(.*?\)|\b__t\)) \+\n'';/g,q=/&(?:amp|lt|gt|quot|#39);/g,W=/[&<>"']/g,z=RegExp(q.source),Y=RegExp(W.source),K=/<%-([\s\S]+?)%>/g,Q=/<%([\s\S]+?)%>/g,J=/<%=([\s\S]+?)%>/g,X=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Z=/^\w*$/,ee=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,te=/[\\^$.*+?()[\]{}|]/g,ne=RegExp(te.source),oe=/^\s+/,re=/\s/,ie=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,se=/\{\n\/\* \[wrapped with (.+)\] \*/,ae=/,? & /,le=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,ce=/[()=,{}\[\]\/\s]/,ue=/\\(\\)?/g,he=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,de=/\w*$/,pe=/^[-+]0x[0-9a-f]+$/i,me=/^0b[01]+$/i,fe=/^\[object .+?Constructor\]$/,ge=/^0o[0-7]+$/i,ye=/^(?:0|[1-9]\d*)$/,be=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,ve=/($^)/,Ce=/['\n\r\u2028\u2029\\]/g,xe="\\ud800-\\udfff",we="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",Ae="\\u2700-\\u27bf",Te="a-z\\xdf-\\xf6\\xf8-\\xff",Ee="A-Z\\xc0-\\xd6\\xd8-\\xde",Se="\\ufe0e\\ufe0f",Ne="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Ie="["+xe+"]",Me="["+Ne+"]",Pe="["+we+"]",_e="\\d+",Le="["+Ae+"]",Oe="["+Te+"]",Re="[^"+xe+Ne+_e+Ae+Te+Ee+"]",$e="\\ud83c[\\udffb-\\udfff]",De="[^"+xe+"]",Be="(?:\\ud83c[\\udde6-\\uddff]){2}",Fe="[\\ud800-\\udbff][\\udc00-\\udfff]",ke="["+Ee+"]",He="\\u200d",Ge="(?:"+Oe+"|"+Re+")",Ue="(?:"+ke+"|"+Re+")",Ve="(?:['’](?:d|ll|m|re|s|t|ve))?",je="(?:['’](?:D|LL|M|RE|S|T|VE))?",qe="(?:"+Pe+"|"+$e+")?",We="["+Se+"]?",ze=We+qe+"(?:"+He+"(?:"+[De,Be,Fe].join("|")+")"+We+qe+")*",Ye="(?:"+[Le,Be,Fe].join("|")+")"+ze,Ke="(?:"+[De+Pe+"?",Pe,Be,Fe,Ie].join("|")+")",Qe=RegExp("['’]","g"),Je=RegExp(Pe,"g"),Xe=RegExp($e+"(?="+$e+")|"+Ke+ze,"g"),Ze=RegExp([ke+"?"+Oe+"+"+Ve+"(?="+[Me,ke,"$"].join("|")+")",Ue+"+"+je+"(?="+[Me,ke+Ge,"$"].join("|")+")",ke+"?"+Ge+"+"+Ve,ke+"+"+je,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",_e,Ye].join("|"),"g"),et=RegExp("["+He+xe+we+Se+"]"),tt=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,nt=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],ot=-1,rt={};rt[O]=rt[R]=rt[$]=rt[D]=rt[B]=rt[F]=rt[k]=rt[H]=rt[G]=!0,rt[f]=rt[g]=rt[_]=rt[y]=rt[L]=rt[b]=rt[v]=rt[C]=rt[w]=rt[A]=rt[T]=rt[S]=rt[N]=rt[I]=rt[P]=!1;var it={};it[f]=it[g]=it[_]=it[L]=it[y]=it[b]=it[O]=it[R]=it[$]=it[D]=it[B]=it[w]=it[A]=it[T]=it[S]=it[N]=it[I]=it[M]=it[F]=it[k]=it[H]=it[G]=!0,it[v]=it[C]=it[P]=!1;var st={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},at=parseFloat,lt=parseInt,ct="object"==typeof n.g&&n.g&&n.g.Object===Object&&n.g,ut="object"==typeof self&&self&&self.Object===Object&&self,ht=ct||ut||Function("return this")(),dt=t&&!t.nodeType&&t,pt=dt&&e&&!e.nodeType&&e,mt=pt&&pt.exports===dt,ft=mt&&ct.process,gt=function(){try{return pt&&pt.require&&pt.require("util").types||ft&&ft.binding&&ft.binding("util")}catch(e){}}(),yt=gt&>.isArrayBuffer,bt=gt&>.isDate,vt=gt&>.isMap,Ct=gt&>.isRegExp,xt=gt&>.isSet,wt=gt&>.isTypedArray;function At(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}function Tt(e,t,n,o){for(var r=-1,i=null==e?0:e.length;++r<i;){var s=e[r];t(o,s,n(s),e)}return o}function Et(e,t){for(var n=-1,o=null==e?0:e.length;++n<o&&!1!==t(e[n],n,e););return e}function St(e,t){for(var n=null==e?0:e.length;n--&&!1!==t(e[n],n,e););return e}function Nt(e,t){for(var n=-1,o=null==e?0:e.length;++n<o;)if(!t(e[n],n,e))return!1;return!0}function It(e,t){for(var n=-1,o=null==e?0:e.length,r=0,i=[];++n<o;){var s=e[n];t(s,n,e)&&(i[r++]=s)}return i}function Mt(e,t){return!(null==e||!e.length)&&kt(e,t,0)>-1}function Pt(e,t,n){for(var o=-1,r=null==e?0:e.length;++o<r;)if(n(t,e[o]))return!0;return!1}function _t(e,t){for(var n=-1,o=null==e?0:e.length,r=Array(o);++n<o;)r[n]=t(e[n],n,e);return r}function Lt(e,t){for(var n=-1,o=t.length,r=e.length;++n<o;)e[r+n]=t[n];return e}function Ot(e,t,n,o){var r=-1,i=null==e?0:e.length;for(o&&i&&(n=e[++r]);++r<i;)n=t(n,e[r],r,e);return n}function Rt(e,t,n,o){var r=null==e?0:e.length;for(o&&r&&(n=e[--r]);r--;)n=t(n,e[r],r,e);return n}function $t(e,t){for(var n=-1,o=null==e?0:e.length;++n<o;)if(t(e[n],n,e))return!0;return!1}var Dt=Vt("length");function Bt(e,t,n){var o;return n(e,(function(e,n,r){if(t(e,n,r))return o=n,!1})),o}function Ft(e,t,n,o){for(var r=e.length,i=n+(o?1:-1);o?i--:++i<r;)if(t(e[i],i,e))return i;return-1}function kt(e,t,n){return t==t?function(e,t,n){for(var o=n-1,r=e.length;++o<r;)if(e[o]===t)return o;return-1}(e,t,n):Ft(e,Gt,n)}function Ht(e,t,n,o){for(var r=n-1,i=e.length;++r<i;)if(o(e[r],t))return r;return-1}function Gt(e){return e!=e}function Ut(e,t){var n=null==e?0:e.length;return n?Wt(e,t)/n:d}function Vt(e){return function(t){return null==t?r:t[e]}}function jt(e){return function(t){return null==e?r:e[t]}}function qt(e,t,n,o,r){return r(e,(function(e,r,i){n=o?(o=!1,e):t(n,e,r,i)})),n}function Wt(e,t){for(var n,o=-1,i=e.length;++o<i;){var s=t(e[o]);s!==r&&(n=n===r?s:n+s)}return n}function zt(e,t){for(var n=-1,o=Array(e);++n<e;)o[n]=t(n);return o}function Yt(e){return e?e.slice(0,dn(e)+1).replace(oe,""):e}function Kt(e){return function(t){return e(t)}}function Qt(e,t){return _t(t,(function(t){return e[t]}))}function Jt(e,t){return e.has(t)}function Xt(e,t){for(var n=-1,o=e.length;++n<o&&kt(t,e[n],0)>-1;);return n}function Zt(e,t){for(var n=e.length;n--&&kt(t,e[n],0)>-1;);return n}var en=jt({À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"}),tn=jt({"&":"&","<":"<",">":">",'"':""","'":"'"});function nn(e){return"\\"+st[e]}function on(e){return et.test(e)}function rn(e){var t=-1,n=Array(e.size);return e.forEach((function(e,o){n[++t]=[o,e]})),n}function sn(e,t){return function(n){return e(t(n))}}function an(e,t){for(var n=-1,o=e.length,r=0,i=[];++n<o;){var s=e[n];s!==t&&s!==a||(e[n]=a,i[r++]=n)}return i}function ln(e){var t=-1,n=Array(e.size);return e.forEach((function(e){n[++t]=e})),n}function cn(e){var t=-1,n=Array(e.size);return e.forEach((function(e){n[++t]=[e,e]})),n}function un(e){return on(e)?function(e){for(var t=Xe.lastIndex=0;Xe.test(e);)++t;return t}(e):Dt(e)}function hn(e){return on(e)?function(e){return e.match(Xe)||[]}(e):function(e){return e.split("")}(e)}function dn(e){for(var t=e.length;t--&&re.test(e.charAt(t)););return t}var pn=jt({"&":"&","<":"<",">":">",""":'"',"'":"'"}),mn=function e(t){var n,o=(t=null==t?ht:mn.defaults(ht.Object(),t,mn.pick(ht,nt))).Array,re=t.Date,xe=t.Error,we=t.Function,Ae=t.Math,Te=t.Object,Ee=t.RegExp,Se=t.String,Ne=t.TypeError,Ie=o.prototype,Me=we.prototype,Pe=Te.prototype,_e=t["__core-js_shared__"],Le=Me.toString,Oe=Pe.hasOwnProperty,Re=0,$e=(n=/[^.]+$/.exec(_e&&_e.keys&&_e.keys.IE_PROTO||""))?"Symbol(src)_1."+n:"",De=Pe.toString,Be=Le.call(Te),Fe=ht._,ke=Ee("^"+Le.call(Oe).replace(te,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),He=mt?t.Buffer:r,Ge=t.Symbol,Ue=t.Uint8Array,Ve=He?He.allocUnsafe:r,je=sn(Te.getPrototypeOf,Te),qe=Te.create,We=Pe.propertyIsEnumerable,ze=Ie.splice,Ye=Ge?Ge.isConcatSpreadable:r,Ke=Ge?Ge.iterator:r,Xe=Ge?Ge.toStringTag:r,et=function(){try{var e=ci(Te,"defineProperty");return e({},"",{}),e}catch(e){}}(),st=t.clearTimeout!==ht.clearTimeout&&t.clearTimeout,ct=re&&re.now!==ht.Date.now&&re.now,ut=t.setTimeout!==ht.setTimeout&&t.setTimeout,dt=Ae.ceil,pt=Ae.floor,ft=Te.getOwnPropertySymbols,gt=He?He.isBuffer:r,Dt=t.isFinite,jt=Ie.join,fn=sn(Te.keys,Te),gn=Ae.max,yn=Ae.min,bn=re.now,vn=t.parseInt,Cn=Ae.random,xn=Ie.reverse,wn=ci(t,"DataView"),An=ci(t,"Map"),Tn=ci(t,"Promise"),En=ci(t,"Set"),Sn=ci(t,"WeakMap"),Nn=ci(Te,"create"),In=Sn&&new Sn,Mn={},Pn=Bi(wn),_n=Bi(An),Ln=Bi(Tn),On=Bi(En),Rn=Bi(Sn),$n=Ge?Ge.prototype:r,Dn=$n?$n.valueOf:r,Bn=$n?$n.toString:r;function Fn(e){if(ea(e)&&!Vs(e)&&!(e instanceof Un)){if(e instanceof Gn)return e;if(Oe.call(e,"__wrapped__"))return Fi(e)}return new Gn(e)}var kn=function(){function e(){}return function(t){if(!Zs(t))return{};if(qe)return qe(t);e.prototype=t;var n=new e;return e.prototype=r,n}}();function Hn(){}function Gn(e,t){this.__wrapped__=e,this.__actions__=[],this.__chain__=!!t,this.__index__=0,this.__values__=r}function Un(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=p,this.__views__=[]}function Vn(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var o=e[t];this.set(o[0],o[1])}}function jn(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var o=e[t];this.set(o[0],o[1])}}function qn(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var o=e[t];this.set(o[0],o[1])}}function Wn(e){var t=-1,n=null==e?0:e.length;for(this.__data__=new qn;++t<n;)this.add(e[t])}function zn(e){var t=this.__data__=new jn(e);this.size=t.size}function Yn(e,t){var n=Vs(e),o=!n&&Us(e),r=!n&&!o&&zs(e),i=!n&&!o&&!r&&la(e),s=n||o||r||i,a=s?zt(e.length,Se):[],l=a.length;for(var c in e)!t&&!Oe.call(e,c)||s&&("length"==c||r&&("offset"==c||"parent"==c)||i&&("buffer"==c||"byteLength"==c||"byteOffset"==c)||gi(c,l))||a.push(c);return a}function Kn(e){var t=e.length;return t?e[Wo(0,t-1)]:r}function Qn(e,t){return Li(Nr(e),io(t,0,e.length))}function Jn(e){return Li(Nr(e))}function Xn(e,t,n){(n!==r&&!ks(e[t],n)||n===r&&!(t in e))&&oo(e,t,n)}function Zn(e,t,n){var o=e[t];Oe.call(e,t)&&ks(o,n)&&(n!==r||t in e)||oo(e,t,n)}function eo(e,t){for(var n=e.length;n--;)if(ks(e[n][0],t))return n;return-1}function to(e,t,n,o){return uo(e,(function(e,r,i){t(o,e,n(e),i)})),o}function no(e,t){return e&&Ir(t,Pa(t),e)}function oo(e,t,n){"__proto__"==t&&et?et(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n}function ro(e,t){for(var n=-1,i=t.length,s=o(i),a=null==e;++n<i;)s[n]=a?r:Ea(e,t[n]);return s}function io(e,t,n){return e==e&&(n!==r&&(e=e<=n?e:n),t!==r&&(e=e>=t?e:t)),e}function so(e,t,n,o,i,s){var a,l=1&t,c=2&t,u=4&t;if(n&&(a=i?n(e,o,i,s):n(e)),a!==r)return a;if(!Zs(e))return e;var h=Vs(e);if(h){if(a=function(e){var t=e.length,n=new e.constructor(t);return t&&"string"==typeof e[0]&&Oe.call(e,"index")&&(n.index=e.index,n.input=e.input),n}(e),!l)return Nr(e,a)}else{var d=di(e),p=d==C||d==x;if(zs(e))return xr(e,l);if(d==T||d==f||p&&!i){if(a=c||p?{}:mi(e),!l)return c?function(e,t){return Ir(e,hi(e),t)}(e,function(e,t){return e&&Ir(t,_a(t),e)}(a,e)):function(e,t){return Ir(e,ui(e),t)}(e,no(a,e))}else{if(!it[d])return i?e:{};a=function(e,t,n){var o,r=e.constructor;switch(t){case _:return wr(e);case y:case b:return new r(+e);case L:return function(e,t){var n=t?wr(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}(e,n);case O:case R:case $:case D:case B:case F:case k:case H:case G:return Ar(e,n);case w:return new r;case A:case I:return new r(e);case S:return function(e){var t=new e.constructor(e.source,de.exec(e));return t.lastIndex=e.lastIndex,t}(e);case N:return new r;case M:return o=e,Dn?Te(Dn.call(o)):{}}}(e,d,l)}}s||(s=new zn);var m=s.get(e);if(m)return m;s.set(e,a),ia(e)?e.forEach((function(o){a.add(so(o,t,n,o,e,s))})):ta(e)&&e.forEach((function(o,r){a.set(r,so(o,t,n,r,e,s))}));var g=h?r:(u?c?ni:ti:c?_a:Pa)(e);return Et(g||e,(function(o,r){g&&(o=e[r=o]),Zn(a,r,so(o,t,n,r,e,s))})),a}function ao(e,t,n){var o=n.length;if(null==e)return!o;for(e=Te(e);o--;){var i=n[o],s=t[i],a=e[i];if(a===r&&!(i in e)||!s(a))return!1}return!0}function lo(e,t,n){if("function"!=typeof e)throw new Ne(i);return Ii((function(){e.apply(r,n)}),t)}function co(e,t,n,o){var r=-1,i=Mt,s=!0,a=e.length,l=[],c=t.length;if(!a)return l;n&&(t=_t(t,Kt(n))),o?(i=Pt,s=!1):t.length>=200&&(i=Jt,s=!1,t=new Wn(t));e:for(;++r<a;){var u=e[r],h=null==n?u:n(u);if(u=o||0!==u?u:0,s&&h==h){for(var d=c;d--;)if(t[d]===h)continue e;l.push(u)}else i(t,h,o)||l.push(u)}return l}Fn.templateSettings={escape:K,evaluate:Q,interpolate:J,variable:"",imports:{_:Fn}},Fn.prototype=Hn.prototype,Fn.prototype.constructor=Fn,Gn.prototype=kn(Hn.prototype),Gn.prototype.constructor=Gn,Un.prototype=kn(Hn.prototype),Un.prototype.constructor=Un,Vn.prototype.clear=function(){this.__data__=Nn?Nn(null):{},this.size=0},Vn.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},Vn.prototype.get=function(e){var t=this.__data__;if(Nn){var n=t[e];return n===s?r:n}return Oe.call(t,e)?t[e]:r},Vn.prototype.has=function(e){var t=this.__data__;return Nn?t[e]!==r:Oe.call(t,e)},Vn.prototype.set=function(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=Nn&&t===r?s:t,this},jn.prototype.clear=function(){this.__data__=[],this.size=0},jn.prototype.delete=function(e){var t=this.__data__,n=eo(t,e);return!(n<0||(n==t.length-1?t.pop():ze.call(t,n,1),--this.size,0))},jn.prototype.get=function(e){var t=this.__data__,n=eo(t,e);return n<0?r:t[n][1]},jn.prototype.has=function(e){return eo(this.__data__,e)>-1},jn.prototype.set=function(e,t){var n=this.__data__,o=eo(n,e);return o<0?(++this.size,n.push([e,t])):n[o][1]=t,this},qn.prototype.clear=function(){this.size=0,this.__data__={hash:new Vn,map:new(An||jn),string:new Vn}},qn.prototype.delete=function(e){var t=ai(this,e).delete(e);return this.size-=t?1:0,t},qn.prototype.get=function(e){return ai(this,e).get(e)},qn.prototype.has=function(e){return ai(this,e).has(e)},qn.prototype.set=function(e,t){var n=ai(this,e),o=n.size;return n.set(e,t),this.size+=n.size==o?0:1,this},Wn.prototype.add=Wn.prototype.push=function(e){return this.__data__.set(e,s),this},Wn.prototype.has=function(e){return this.__data__.has(e)},zn.prototype.clear=function(){this.__data__=new jn,this.size=0},zn.prototype.delete=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n},zn.prototype.get=function(e){return this.__data__.get(e)},zn.prototype.has=function(e){return this.__data__.has(e)},zn.prototype.set=function(e,t){var n=this.__data__;if(n instanceof jn){var o=n.__data__;if(!An||o.length<199)return o.push([e,t]),this.size=++n.size,this;n=this.__data__=new qn(o)}return n.set(e,t),this.size=n.size,this};var uo=_r(vo),ho=_r(Co,!0);function po(e,t){var n=!0;return uo(e,(function(e,o,r){return n=!!t(e,o,r)})),n}function mo(e,t,n){for(var o=-1,i=e.length;++o<i;){var s=e[o],a=t(s);if(null!=a&&(l===r?a==a&&!aa(a):n(a,l)))var l=a,c=s}return c}function fo(e,t){var n=[];return uo(e,(function(e,o,r){t(e,o,r)&&n.push(e)})),n}function go(e,t,n,o,r){var i=-1,s=e.length;for(n||(n=fi),r||(r=[]);++i<s;){var a=e[i];t>0&&n(a)?t>1?go(a,t-1,n,o,r):Lt(r,a):o||(r[r.length]=a)}return r}var yo=Lr(),bo=Lr(!0);function vo(e,t){return e&&yo(e,t,Pa)}function Co(e,t){return e&&bo(e,t,Pa)}function xo(e,t){return It(t,(function(t){return Qs(e[t])}))}function wo(e,t){for(var n=0,o=(t=yr(t,e)).length;null!=e&&n<o;)e=e[Di(t[n++])];return n&&n==o?e:r}function Ao(e,t,n){var o=t(e);return Vs(e)?o:Lt(o,n(e))}function To(e){return null==e?e===r?"[object Undefined]":"[object Null]":Xe&&Xe in Te(e)?function(e){var t=Oe.call(e,Xe),n=e[Xe];try{e[Xe]=r;var o=!0}catch(e){}var i=De.call(e);return o&&(t?e[Xe]=n:delete e[Xe]),i}(e):function(e){return De.call(e)}(e)}function Eo(e,t){return e>t}function So(e,t){return null!=e&&Oe.call(e,t)}function No(e,t){return null!=e&&t in Te(e)}function Io(e,t,n){for(var i=n?Pt:Mt,s=e[0].length,a=e.length,l=a,c=o(a),u=1/0,h=[];l--;){var d=e[l];l&&t&&(d=_t(d,Kt(t))),u=yn(d.length,u),c[l]=!n&&(t||s>=120&&d.length>=120)?new Wn(l&&d):r}d=e[0];var p=-1,m=c[0];e:for(;++p<s&&h.length<u;){var f=d[p],g=t?t(f):f;if(f=n||0!==f?f:0,!(m?Jt(m,g):i(h,g,n))){for(l=a;--l;){var y=c[l];if(!(y?Jt(y,g):i(e[l],g,n)))continue e}m&&m.push(g),h.push(f)}}return h}function Mo(e,t,n){var o=null==(e=Ei(e,t=yr(t,e)))?e:e[Di(Ki(t))];return null==o?r:At(o,e,n)}function Po(e){return ea(e)&&To(e)==f}function _o(e,t,n,o,i){return e===t||(null==e||null==t||!ea(e)&&!ea(t)?e!=e&&t!=t:function(e,t,n,o,i,s){var a=Vs(e),l=Vs(t),c=a?g:di(e),u=l?g:di(t),h=(c=c==f?T:c)==T,d=(u=u==f?T:u)==T,p=c==u;if(p&&zs(e)){if(!zs(t))return!1;a=!0,h=!1}if(p&&!h)return s||(s=new zn),a||la(e)?Zr(e,t,n,o,i,s):function(e,t,n,o,r,i,s){switch(n){case L:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case _:return!(e.byteLength!=t.byteLength||!i(new Ue(e),new Ue(t)));case y:case b:case A:return ks(+e,+t);case v:return e.name==t.name&&e.message==t.message;case S:case I:return e==t+"";case w:var a=rn;case N:var l=1&o;if(a||(a=ln),e.size!=t.size&&!l)return!1;var c=s.get(e);if(c)return c==t;o|=2,s.set(e,t);var u=Zr(a(e),a(t),o,r,i,s);return s.delete(e),u;case M:if(Dn)return Dn.call(e)==Dn.call(t)}return!1}(e,t,c,n,o,i,s);if(!(1&n)){var m=h&&Oe.call(e,"__wrapped__"),C=d&&Oe.call(t,"__wrapped__");if(m||C){var x=m?e.value():e,E=C?t.value():t;return s||(s=new zn),i(x,E,n,o,s)}}return!!p&&(s||(s=new zn),function(e,t,n,o,i,s){var a=1&n,l=ti(e),c=l.length;if(c!=ti(t).length&&!a)return!1;for(var u=c;u--;){var h=l[u];if(!(a?h in t:Oe.call(t,h)))return!1}var d=s.get(e),p=s.get(t);if(d&&p)return d==t&&p==e;var m=!0;s.set(e,t),s.set(t,e);for(var f=a;++u<c;){var g=e[h=l[u]],y=t[h];if(o)var b=a?o(y,g,h,t,e,s):o(g,y,h,e,t,s);if(!(b===r?g===y||i(g,y,n,o,s):b)){m=!1;break}f||(f="constructor"==h)}if(m&&!f){var v=e.constructor,C=t.constructor;v==C||!("constructor"in e)||!("constructor"in t)||"function"==typeof v&&v instanceof v&&"function"==typeof C&&C instanceof C||(m=!1)}return s.delete(e),s.delete(t),m}(e,t,n,o,i,s))}(e,t,n,o,_o,i))}function Lo(e,t,n,o){var i=n.length,s=i,a=!o;if(null==e)return!s;for(e=Te(e);i--;){var l=n[i];if(a&&l[2]?l[1]!==e[l[0]]:!(l[0]in e))return!1}for(;++i<s;){var c=(l=n[i])[0],u=e[c],h=l[1];if(a&&l[2]){if(u===r&&!(c in e))return!1}else{var d=new zn;if(o)var p=o(u,h,c,e,t,d);if(!(p===r?_o(h,u,3,o,d):p))return!1}}return!0}function Oo(e){return!(!Zs(e)||(t=e,$e&&$e in t))&&(Qs(e)?ke:fe).test(Bi(e));var t}function Ro(e){return"function"==typeof e?e:null==e?nl:"object"==typeof e?Vs(e)?ko(e[0],e[1]):Fo(e):hl(e)}function $o(e){if(!xi(e))return fn(e);var t=[];for(var n in Te(e))Oe.call(e,n)&&"constructor"!=n&&t.push(n);return t}function Do(e,t){return e<t}function Bo(e,t){var n=-1,r=qs(e)?o(e.length):[];return uo(e,(function(e,o,i){r[++n]=t(e,o,i)})),r}function Fo(e){var t=li(e);return 1==t.length&&t[0][2]?Ai(t[0][0],t[0][1]):function(n){return n===e||Lo(n,e,t)}}function ko(e,t){return bi(e)&&wi(t)?Ai(Di(e),t):function(n){var o=Ea(n,e);return o===r&&o===t?Sa(n,e):_o(t,o,3)}}function Ho(e,t,n,o,i){e!==t&&yo(t,(function(s,a){if(i||(i=new zn),Zs(s))!function(e,t,n,o,i,s,a){var l=Si(e,n),c=Si(t,n),u=a.get(c);if(u)Xn(e,n,u);else{var h=s?s(l,c,n+"",e,t,a):r,d=h===r;if(d){var p=Vs(c),m=!p&&zs(c),f=!p&&!m&&la(c);h=c,p||m||f?Vs(l)?h=l:Ws(l)?h=Nr(l):m?(d=!1,h=xr(c,!0)):f?(d=!1,h=Ar(c,!0)):h=[]:oa(c)||Us(c)?(h=l,Us(l)?h=ga(l):Zs(l)&&!Qs(l)||(h=mi(c))):d=!1}d&&(a.set(c,h),i(h,c,o,s,a),a.delete(c)),Xn(e,n,h)}}(e,t,a,n,Ho,o,i);else{var l=o?o(Si(e,a),s,a+"",e,t,i):r;l===r&&(l=s),Xn(e,a,l)}}),_a)}function Go(e,t){var n=e.length;if(n)return gi(t+=t<0?n:0,n)?e[t]:r}function Uo(e,t,n){t=t.length?_t(t,(function(e){return Vs(e)?function(t){return wo(t,1===e.length?e[0]:e)}:e})):[nl];var o=-1;t=_t(t,Kt(si()));var r=Bo(e,(function(e,n,r){var i=_t(t,(function(t){return t(e)}));return{criteria:i,index:++o,value:e}}));return function(e){var t=e.length;for(e.sort((function(e,t){return function(e,t,n){for(var o=-1,r=e.criteria,i=t.criteria,s=r.length,a=n.length;++o<s;){var l=Tr(r[o],i[o]);if(l)return o>=a?l:l*("desc"==n[o]?-1:1)}return e.index-t.index}(e,t,n)}));t--;)e[t]=e[t].value;return e}(r)}function Vo(e,t,n){for(var o=-1,r=t.length,i={};++o<r;){var s=t[o],a=wo(e,s);n(a,s)&&Jo(i,yr(s,e),a)}return i}function jo(e,t,n,o){var r=o?Ht:kt,i=-1,s=t.length,a=e;for(e===t&&(t=Nr(t)),n&&(a=_t(e,Kt(n)));++i<s;)for(var l=0,c=t[i],u=n?n(c):c;(l=r(a,u,l,o))>-1;)a!==e&&ze.call(a,l,1),ze.call(e,l,1);return e}function qo(e,t){for(var n=e?t.length:0,o=n-1;n--;){var r=t[n];if(n==o||r!==i){var i=r;gi(r)?ze.call(e,r,1):cr(e,r)}}return e}function Wo(e,t){return e+pt(Cn()*(t-e+1))}function zo(e,t){var n="";if(!e||t<1||t>h)return n;do{t%2&&(n+=e),(t=pt(t/2))&&(e+=e)}while(t);return n}function Yo(e,t){return Mi(Ti(e,t,nl),e+"")}function Ko(e){return Kn(ka(e))}function Qo(e,t){var n=ka(e);return Li(n,io(t,0,n.length))}function Jo(e,t,n,o){if(!Zs(e))return e;for(var i=-1,s=(t=yr(t,e)).length,a=s-1,l=e;null!=l&&++i<s;){var c=Di(t[i]),u=n;if("__proto__"===c||"constructor"===c||"prototype"===c)return e;if(i!=a){var h=l[c];(u=o?o(h,c,l):r)===r&&(u=Zs(h)?h:gi(t[i+1])?[]:{})}Zn(l,c,u),l=l[c]}return e}var Xo=In?function(e,t){return In.set(e,t),e}:nl,Zo=et?function(e,t){return et(e,"toString",{configurable:!0,enumerable:!1,value:Za(t),writable:!0})}:nl;function er(e){return Li(ka(e))}function tr(e,t,n){var r=-1,i=e.length;t<0&&(t=-t>i?0:i+t),(n=n>i?i:n)<0&&(n+=i),i=t>n?0:n-t>>>0,t>>>=0;for(var s=o(i);++r<i;)s[r]=e[r+t];return s}function nr(e,t){var n;return uo(e,(function(e,o,r){return!(n=t(e,o,r))})),!!n}function or(e,t,n){var o=0,r=null==e?o:e.length;if("number"==typeof t&&t==t&&r<=2147483647){for(;o<r;){var i=o+r>>>1,s=e[i];null!==s&&!aa(s)&&(n?s<=t:s<t)?o=i+1:r=i}return r}return rr(e,t,nl,n)}function rr(e,t,n,o){var i=0,s=null==e?0:e.length;if(0===s)return 0;for(var a=(t=n(t))!=t,l=null===t,c=aa(t),u=t===r;i<s;){var h=pt((i+s)/2),d=n(e[h]),p=d!==r,m=null===d,f=d==d,g=aa(d);if(a)var y=o||f;else y=u?f&&(o||p):l?f&&p&&(o||!m):c?f&&p&&!m&&(o||!g):!m&&!g&&(o?d<=t:d<t);y?i=h+1:s=h}return yn(s,4294967294)}function ir(e,t){for(var n=-1,o=e.length,r=0,i=[];++n<o;){var s=e[n],a=t?t(s):s;if(!n||!ks(a,l)){var l=a;i[r++]=0===s?0:s}}return i}function sr(e){return"number"==typeof e?e:aa(e)?d:+e}function ar(e){if("string"==typeof e)return e;if(Vs(e))return _t(e,ar)+"";if(aa(e))return Bn?Bn.call(e):"";var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}function lr(e,t,n){var o=-1,r=Mt,i=e.length,s=!0,a=[],l=a;if(n)s=!1,r=Pt;else if(i>=200){var c=t?null:zr(e);if(c)return ln(c);s=!1,r=Jt,l=new Wn}else l=t?[]:a;e:for(;++o<i;){var u=e[o],h=t?t(u):u;if(u=n||0!==u?u:0,s&&h==h){for(var d=l.length;d--;)if(l[d]===h)continue e;t&&l.push(h),a.push(u)}else r(l,h,n)||(l!==a&&l.push(h),a.push(u))}return a}function cr(e,t){return null==(e=Ei(e,t=yr(t,e)))||delete e[Di(Ki(t))]}function ur(e,t,n,o){return Jo(e,t,n(wo(e,t)),o)}function hr(e,t,n,o){for(var r=e.length,i=o?r:-1;(o?i--:++i<r)&&t(e[i],i,e););return n?tr(e,o?0:i,o?i+1:r):tr(e,o?i+1:0,o?r:i)}function dr(e,t){var n=e;return n instanceof Un&&(n=n.value()),Ot(t,(function(e,t){return t.func.apply(t.thisArg,Lt([e],t.args))}),n)}function pr(e,t,n){var r=e.length;if(r<2)return r?lr(e[0]):[];for(var i=-1,s=o(r);++i<r;)for(var a=e[i],l=-1;++l<r;)l!=i&&(s[i]=co(s[i]||a,e[l],t,n));return lr(go(s,1),t,n)}function mr(e,t,n){for(var o=-1,i=e.length,s=t.length,a={};++o<i;){var l=o<s?t[o]:r;n(a,e[o],l)}return a}function fr(e){return Ws(e)?e:[]}function gr(e){return"function"==typeof e?e:nl}function yr(e,t){return Vs(e)?e:bi(e,t)?[e]:$i(ya(e))}var br=Yo;function vr(e,t,n){var o=e.length;return n=n===r?o:n,!t&&n>=o?e:tr(e,t,n)}var Cr=st||function(e){return ht.clearTimeout(e)};function xr(e,t){if(t)return e.slice();var n=e.length,o=Ve?Ve(n):new e.constructor(n);return e.copy(o),o}function wr(e){var t=new e.constructor(e.byteLength);return new Ue(t).set(new Ue(e)),t}function Ar(e,t){var n=t?wr(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}function Tr(e,t){if(e!==t){var n=e!==r,o=null===e,i=e==e,s=aa(e),a=t!==r,l=null===t,c=t==t,u=aa(t);if(!l&&!u&&!s&&e>t||s&&a&&c&&!l&&!u||o&&a&&c||!n&&c||!i)return 1;if(!o&&!s&&!u&&e<t||u&&n&&i&&!o&&!s||l&&n&&i||!a&&i||!c)return-1}return 0}function Er(e,t,n,r){for(var i=-1,s=e.length,a=n.length,l=-1,c=t.length,u=gn(s-a,0),h=o(c+u),d=!r;++l<c;)h[l]=t[l];for(;++i<a;)(d||i<s)&&(h[n[i]]=e[i]);for(;u--;)h[l++]=e[i++];return h}function Sr(e,t,n,r){for(var i=-1,s=e.length,a=-1,l=n.length,c=-1,u=t.length,h=gn(s-l,0),d=o(h+u),p=!r;++i<h;)d[i]=e[i];for(var m=i;++c<u;)d[m+c]=t[c];for(;++a<l;)(p||i<s)&&(d[m+n[a]]=e[i++]);return d}function Nr(e,t){var n=-1,r=e.length;for(t||(t=o(r));++n<r;)t[n]=e[n];return t}function Ir(e,t,n,o){var i=!n;n||(n={});for(var s=-1,a=t.length;++s<a;){var l=t[s],c=o?o(n[l],e[l],l,n,e):r;c===r&&(c=e[l]),i?oo(n,l,c):Zn(n,l,c)}return n}function Mr(e,t){return function(n,o){var r=Vs(n)?Tt:to,i=t?t():{};return r(n,e,si(o,2),i)}}function Pr(e){return Yo((function(t,n){var o=-1,i=n.length,s=i>1?n[i-1]:r,a=i>2?n[2]:r;for(s=e.length>3&&"function"==typeof s?(i--,s):r,a&&yi(n[0],n[1],a)&&(s=i<3?r:s,i=1),t=Te(t);++o<i;){var l=n[o];l&&e(t,l,o,s)}return t}))}function _r(e,t){return function(n,o){if(null==n)return n;if(!qs(n))return e(n,o);for(var r=n.length,i=t?r:-1,s=Te(n);(t?i--:++i<r)&&!1!==o(s[i],i,s););return n}}function Lr(e){return function(t,n,o){for(var r=-1,i=Te(t),s=o(t),a=s.length;a--;){var l=s[e?a:++r];if(!1===n(i[l],l,i))break}return t}}function Or(e){return function(t){var n=on(t=ya(t))?hn(t):r,o=n?n[0]:t.charAt(0),i=n?vr(n,1).join(""):t.slice(1);return o[e]()+i}}function Rr(e){return function(t){return Ot(Qa(Ua(t).replace(Qe,"")),e,"")}}function $r(e){return function(){var t=arguments;switch(t.length){case 0:return new e;case 1:return new e(t[0]);case 2:return new e(t[0],t[1]);case 3:return new e(t[0],t[1],t[2]);case 4:return new e(t[0],t[1],t[2],t[3]);case 5:return new e(t[0],t[1],t[2],t[3],t[4]);case 6:return new e(t[0],t[1],t[2],t[3],t[4],t[5]);case 7:return new e(t[0],t[1],t[2],t[3],t[4],t[5],t[6])}var n=kn(e.prototype),o=e.apply(n,t);return Zs(o)?o:n}}function Dr(e){return function(t,n,o){var i=Te(t);if(!qs(t)){var s=si(n,3);t=Pa(t),n=function(e){return s(i[e],e,i)}}var a=e(t,n,o);return a>-1?i[s?t[a]:a]:r}}function Br(e){return ei((function(t){var n=t.length,o=n,s=Gn.prototype.thru;for(e&&t.reverse();o--;){var a=t[o];if("function"!=typeof a)throw new Ne(i);if(s&&!l&&"wrapper"==ri(a))var l=new Gn([],!0)}for(o=l?o:n;++o<n;){var c=ri(a=t[o]),u="wrapper"==c?oi(a):r;l=u&&vi(u[0])&&424==u[1]&&!u[4].length&&1==u[9]?l[ri(u[0])].apply(l,u[3]):1==a.length&&vi(a)?l[c]():l.thru(a)}return function(){var e=arguments,o=e[0];if(l&&1==e.length&&Vs(o))return l.plant(o).value();for(var r=0,i=n?t[r].apply(this,e):o;++r<n;)i=t[r].call(this,i);return i}}))}function Fr(e,t,n,i,s,a,l,u,h,d){var p=t&c,m=1&t,f=2&t,g=24&t,y=512&t,b=f?r:$r(e);return function c(){for(var v=arguments.length,C=o(v),x=v;x--;)C[x]=arguments[x];if(g)var w=ii(c),A=function(e,t){for(var n=e.length,o=0;n--;)e[n]===t&&++o;return o}(C,w);if(i&&(C=Er(C,i,s,g)),a&&(C=Sr(C,a,l,g)),v-=A,g&&v<d){var T=an(C,w);return qr(e,t,Fr,c.placeholder,n,C,T,u,h,d-v)}var E=m?n:this,S=f?E[e]:e;return v=C.length,u?C=function(e,t){for(var n=e.length,o=yn(t.length,n),i=Nr(e);o--;){var s=t[o];e[o]=gi(s,n)?i[s]:r}return e}(C,u):y&&v>1&&C.reverse(),p&&h<v&&(C.length=h),this&&this!==ht&&this instanceof c&&(S=b||$r(S)),S.apply(E,C)}}function kr(e,t){return function(n,o){return function(e,t,n,o){return vo(e,(function(e,r,i){t(o,n(e),r,i)})),o}(n,e,t(o),{})}}function Hr(e,t){return function(n,o){var i;if(n===r&&o===r)return t;if(n!==r&&(i=n),o!==r){if(i===r)return o;"string"==typeof n||"string"==typeof o?(n=ar(n),o=ar(o)):(n=sr(n),o=sr(o)),i=e(n,o)}return i}}function Gr(e){return ei((function(t){return t=_t(t,Kt(si())),Yo((function(n){var o=this;return e(t,(function(e){return At(e,o,n)}))}))}))}function Ur(e,t){var n=(t=t===r?" ":ar(t)).length;if(n<2)return n?zo(t,e):t;var o=zo(t,dt(e/un(t)));return on(t)?vr(hn(o),0,e).join(""):o.slice(0,e)}function Vr(e){return function(t,n,i){return i&&"number"!=typeof i&&yi(t,n,i)&&(n=i=r),t=da(t),n===r?(n=t,t=0):n=da(n),function(e,t,n,r){for(var i=-1,s=gn(dt((t-e)/(n||1)),0),a=o(s);s--;)a[r?s:++i]=e,e+=n;return a}(t,n,i=i===r?t<n?1:-1:da(i),e)}}function jr(e){return function(t,n){return"string"==typeof t&&"string"==typeof n||(t=fa(t),n=fa(n)),e(t,n)}}function qr(e,t,n,o,i,s,a,c,u,h){var d=8&t;t|=d?l:64,4&(t&=~(d?64:l))||(t&=-4);var p=[e,t,i,d?s:r,d?a:r,d?r:s,d?r:a,c,u,h],m=n.apply(r,p);return vi(e)&&Ni(m,p),m.placeholder=o,Pi(m,e,t)}function Wr(e){var t=Ae[e];return function(e,n){if(e=fa(e),(n=null==n?0:yn(pa(n),292))&&Dt(e)){var o=(ya(e)+"e").split("e");return+((o=(ya(t(o[0]+"e"+(+o[1]+n)))+"e").split("e"))[0]+"e"+(+o[1]-n))}return t(e)}}var zr=En&&1/ln(new En([,-0]))[1]==u?function(e){return new En(e)}:al;function Yr(e){return function(t){var n=di(t);return n==w?rn(t):n==N?cn(t):function(e,t){return _t(t,(function(t){return[t,e[t]]}))}(t,e(t))}}function Kr(e,t,n,s,u,h,d,p){var m=2&t;if(!m&&"function"!=typeof e)throw new Ne(i);var f=s?s.length:0;if(f||(t&=-97,s=u=r),d=d===r?d:gn(pa(d),0),p=p===r?p:pa(p),f-=u?u.length:0,64&t){var g=s,y=u;s=u=r}var b=m?r:oi(e),v=[e,t,n,s,u,g,y,h,d,p];if(b&&function(e,t){var n=e[1],o=t[1],r=n|o,i=r<131,s=o==c&&8==n||o==c&&256==n&&e[7].length<=t[8]||384==o&&t[7].length<=t[8]&&8==n;if(!i&&!s)return e;1&o&&(e[2]=t[2],r|=1&n?0:4);var l=t[3];if(l){var u=e[3];e[3]=u?Er(u,l,t[4]):l,e[4]=u?an(e[3],a):t[4]}(l=t[5])&&(u=e[5],e[5]=u?Sr(u,l,t[6]):l,e[6]=u?an(e[5],a):t[6]),(l=t[7])&&(e[7]=l),o&c&&(e[8]=null==e[8]?t[8]:yn(e[8],t[8])),null==e[9]&&(e[9]=t[9]),e[0]=t[0],e[1]=r}(v,b),e=v[0],t=v[1],n=v[2],s=v[3],u=v[4],!(p=v[9]=v[9]===r?m?0:e.length:gn(v[9]-f,0))&&24&t&&(t&=-25),t&&1!=t)C=8==t||16==t?function(e,t,n){var i=$r(e);return function s(){for(var a=arguments.length,l=o(a),c=a,u=ii(s);c--;)l[c]=arguments[c];var h=a<3&&l[0]!==u&&l[a-1]!==u?[]:an(l,u);return(a-=h.length)<n?qr(e,t,Fr,s.placeholder,r,l,h,r,r,n-a):At(this&&this!==ht&&this instanceof s?i:e,this,l)}}(e,t,p):t!=l&&33!=t||u.length?Fr.apply(r,v):function(e,t,n,r){var i=1&t,s=$r(e);return function t(){for(var a=-1,l=arguments.length,c=-1,u=r.length,h=o(u+l),d=this&&this!==ht&&this instanceof t?s:e;++c<u;)h[c]=r[c];for(;l--;)h[c++]=arguments[++a];return At(d,i?n:this,h)}}(e,t,n,s);else var C=function(e,t,n){var o=1&t,r=$r(e);return function t(){return(this&&this!==ht&&this instanceof t?r:e).apply(o?n:this,arguments)}}(e,t,n);return Pi((b?Xo:Ni)(C,v),e,t)}function Qr(e,t,n,o){return e===r||ks(e,Pe[n])&&!Oe.call(o,n)?t:e}function Jr(e,t,n,o,i,s){return Zs(e)&&Zs(t)&&(s.set(t,e),Ho(e,t,r,Jr,s),s.delete(t)),e}function Xr(e){return oa(e)?r:e}function Zr(e,t,n,o,i,s){var a=1&n,l=e.length,c=t.length;if(l!=c&&!(a&&c>l))return!1;var u=s.get(e),h=s.get(t);if(u&&h)return u==t&&h==e;var d=-1,p=!0,m=2&n?new Wn:r;for(s.set(e,t),s.set(t,e);++d<l;){var f=e[d],g=t[d];if(o)var y=a?o(g,f,d,t,e,s):o(f,g,d,e,t,s);if(y!==r){if(y)continue;p=!1;break}if(m){if(!$t(t,(function(e,t){if(!Jt(m,t)&&(f===e||i(f,e,n,o,s)))return m.push(t)}))){p=!1;break}}else if(f!==g&&!i(f,g,n,o,s)){p=!1;break}}return s.delete(e),s.delete(t),p}function ei(e){return Mi(Ti(e,r,ji),e+"")}function ti(e){return Ao(e,Pa,ui)}function ni(e){return Ao(e,_a,hi)}var oi=In?function(e){return In.get(e)}:al;function ri(e){for(var t=e.name+"",n=Mn[t],o=Oe.call(Mn,t)?n.length:0;o--;){var r=n[o],i=r.func;if(null==i||i==e)return r.name}return t}function ii(e){return(Oe.call(Fn,"placeholder")?Fn:e).placeholder}function si(){var e=Fn.iteratee||ol;return e=e===ol?Ro:e,arguments.length?e(arguments[0],arguments[1]):e}function ai(e,t){var n,o,r=e.__data__;return("string"==(o=typeof(n=t))||"number"==o||"symbol"==o||"boolean"==o?"__proto__"!==n:null===n)?r["string"==typeof t?"string":"hash"]:r.map}function li(e){for(var t=Pa(e),n=t.length;n--;){var o=t[n],r=e[o];t[n]=[o,r,wi(r)]}return t}function ci(e,t){var n=function(e,t){return null==e?r:e[t]}(e,t);return Oo(n)?n:r}var ui=ft?function(e){return null==e?[]:(e=Te(e),It(ft(e),(function(t){return We.call(e,t)})))}:ml,hi=ft?function(e){for(var t=[];e;)Lt(t,ui(e)),e=je(e);return t}:ml,di=To;function pi(e,t,n){for(var o=-1,r=(t=yr(t,e)).length,i=!1;++o<r;){var s=Di(t[o]);if(!(i=null!=e&&n(e,s)))break;e=e[s]}return i||++o!=r?i:!!(r=null==e?0:e.length)&&Xs(r)&&gi(s,r)&&(Vs(e)||Us(e))}function mi(e){return"function"!=typeof e.constructor||xi(e)?{}:kn(je(e))}function fi(e){return Vs(e)||Us(e)||!!(Ye&&e&&e[Ye])}function gi(e,t){var n=typeof e;return!!(t=null==t?h:t)&&("number"==n||"symbol"!=n&&ye.test(e))&&e>-1&&e%1==0&&e<t}function yi(e,t,n){if(!Zs(n))return!1;var o=typeof t;return!!("number"==o?qs(n)&&gi(t,n.length):"string"==o&&t in n)&&ks(n[t],e)}function bi(e,t){if(Vs(e))return!1;var n=typeof e;return!("number"!=n&&"symbol"!=n&&"boolean"!=n&&null!=e&&!aa(e))||Z.test(e)||!X.test(e)||null!=t&&e in Te(t)}function vi(e){var t=ri(e),n=Fn[t];if("function"!=typeof n||!(t in Un.prototype))return!1;if(e===n)return!0;var o=oi(n);return!!o&&e===o[0]}(wn&&di(new wn(new ArrayBuffer(1)))!=L||An&&di(new An)!=w||Tn&&di(Tn.resolve())!=E||En&&di(new En)!=N||Sn&&di(new Sn)!=P)&&(di=function(e){var t=To(e),n=t==T?e.constructor:r,o=n?Bi(n):"";if(o)switch(o){case Pn:return L;case _n:return w;case Ln:return E;case On:return N;case Rn:return P}return t});var Ci=_e?Qs:fl;function xi(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||Pe)}function wi(e){return e==e&&!Zs(e)}function Ai(e,t){return function(n){return null!=n&&n[e]===t&&(t!==r||e in Te(n))}}function Ti(e,t,n){return t=gn(t===r?e.length-1:t,0),function(){for(var r=arguments,i=-1,s=gn(r.length-t,0),a=o(s);++i<s;)a[i]=r[t+i];i=-1;for(var l=o(t+1);++i<t;)l[i]=r[i];return l[t]=n(a),At(e,this,l)}}function Ei(e,t){return t.length<2?e:wo(e,tr(t,0,-1))}function Si(e,t){if(("constructor"!==t||"function"!=typeof e[t])&&"__proto__"!=t)return e[t]}var Ni=_i(Xo),Ii=ut||function(e,t){return ht.setTimeout(e,t)},Mi=_i(Zo);function Pi(e,t,n){var o=t+"";return Mi(e,function(e,t){var n=t.length;if(!n)return e;var o=n-1;return t[o]=(n>1?"& ":"")+t[o],t=t.join(n>2?", ":" "),e.replace(ie,"{\n/* [wrapped with "+t+"] */\n")}(o,function(e,t){return Et(m,(function(n){var o="_."+n[0];t&n[1]&&!Mt(e,o)&&e.push(o)})),e.sort()}(function(e){var t=e.match(se);return t?t[1].split(ae):[]}(o),n)))}function _i(e){var t=0,n=0;return function(){var o=bn(),i=16-(o-n);if(n=o,i>0){if(++t>=800)return arguments[0]}else t=0;return e.apply(r,arguments)}}function Li(e,t){var n=-1,o=e.length,i=o-1;for(t=t===r?o:t;++n<t;){var s=Wo(n,i),a=e[s];e[s]=e[n],e[n]=a}return e.length=t,e}var Oi,Ri,$i=(Oi=Os((function(e){var t=[];return 46===e.charCodeAt(0)&&t.push(""),e.replace(ee,(function(e,n,o,r){t.push(o?r.replace(ue,"$1"):n||e)})),t}),(function(e){return 500===Ri.size&&Ri.clear(),e})),Ri=Oi.cache,Oi);function Di(e){if("string"==typeof e||aa(e))return e;var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}function Bi(e){if(null!=e){try{return Le.call(e)}catch(e){}try{return e+""}catch(e){}}return""}function Fi(e){if(e instanceof Un)return e.clone();var t=new Gn(e.__wrapped__,e.__chain__);return t.__actions__=Nr(e.__actions__),t.__index__=e.__index__,t.__values__=e.__values__,t}var ki=Yo((function(e,t){return Ws(e)?co(e,go(t,1,Ws,!0)):[]})),Hi=Yo((function(e,t){var n=Ki(t);return Ws(n)&&(n=r),Ws(e)?co(e,go(t,1,Ws,!0),si(n,2)):[]})),Gi=Yo((function(e,t){var n=Ki(t);return Ws(n)&&(n=r),Ws(e)?co(e,go(t,1,Ws,!0),r,n):[]}));function Ui(e,t,n){var o=null==e?0:e.length;if(!o)return-1;var r=null==n?0:pa(n);return r<0&&(r=gn(o+r,0)),Ft(e,si(t,3),r)}function Vi(e,t,n){var o=null==e?0:e.length;if(!o)return-1;var i=o-1;return n!==r&&(i=pa(n),i=n<0?gn(o+i,0):yn(i,o-1)),Ft(e,si(t,3),i,!0)}function ji(e){return null!=e&&e.length?go(e,1):[]}function qi(e){return e&&e.length?e[0]:r}var Wi=Yo((function(e){var t=_t(e,fr);return t.length&&t[0]===e[0]?Io(t):[]})),zi=Yo((function(e){var t=Ki(e),n=_t(e,fr);return t===Ki(n)?t=r:n.pop(),n.length&&n[0]===e[0]?Io(n,si(t,2)):[]})),Yi=Yo((function(e){var t=Ki(e),n=_t(e,fr);return(t="function"==typeof t?t:r)&&n.pop(),n.length&&n[0]===e[0]?Io(n,r,t):[]}));function Ki(e){var t=null==e?0:e.length;return t?e[t-1]:r}var Qi=Yo(Ji);function Ji(e,t){return e&&e.length&&t&&t.length?jo(e,t):e}var Xi=ei((function(e,t){var n=null==e?0:e.length,o=ro(e,t);return qo(e,_t(t,(function(e){return gi(e,n)?+e:e})).sort(Tr)),o}));function Zi(e){return null==e?e:xn.call(e)}var es=Yo((function(e){return lr(go(e,1,Ws,!0))})),ts=Yo((function(e){var t=Ki(e);return Ws(t)&&(t=r),lr(go(e,1,Ws,!0),si(t,2))})),ns=Yo((function(e){var t=Ki(e);return t="function"==typeof t?t:r,lr(go(e,1,Ws,!0),r,t)}));function os(e){if(!e||!e.length)return[];var t=0;return e=It(e,(function(e){if(Ws(e))return t=gn(e.length,t),!0})),zt(t,(function(t){return _t(e,Vt(t))}))}function rs(e,t){if(!e||!e.length)return[];var n=os(e);return null==t?n:_t(n,(function(e){return At(t,r,e)}))}var is=Yo((function(e,t){return Ws(e)?co(e,t):[]})),ss=Yo((function(e){return pr(It(e,Ws))})),as=Yo((function(e){var t=Ki(e);return Ws(t)&&(t=r),pr(It(e,Ws),si(t,2))})),ls=Yo((function(e){var t=Ki(e);return t="function"==typeof t?t:r,pr(It(e,Ws),r,t)})),cs=Yo(os),us=Yo((function(e){var t=e.length,n=t>1?e[t-1]:r;return n="function"==typeof n?(e.pop(),n):r,rs(e,n)}));function hs(e){var t=Fn(e);return t.__chain__=!0,t}function ds(e,t){return t(e)}var ps=ei((function(e){var t=e.length,n=t?e[0]:0,o=this.__wrapped__,i=function(t){return ro(t,e)};return!(t>1||this.__actions__.length)&&o instanceof Un&&gi(n)?((o=o.slice(n,+n+(t?1:0))).__actions__.push({func:ds,args:[i],thisArg:r}),new Gn(o,this.__chain__).thru((function(e){return t&&!e.length&&e.push(r),e}))):this.thru(i)})),ms=Mr((function(e,t,n){Oe.call(e,n)?++e[n]:oo(e,n,1)})),fs=Dr(Ui),gs=Dr(Vi);function ys(e,t){return(Vs(e)?Et:uo)(e,si(t,3))}function bs(e,t){return(Vs(e)?St:ho)(e,si(t,3))}var vs=Mr((function(e,t,n){Oe.call(e,n)?e[n].push(t):oo(e,n,[t])})),Cs=Yo((function(e,t,n){var r=-1,i="function"==typeof t,s=qs(e)?o(e.length):[];return uo(e,(function(e){s[++r]=i?At(t,e,n):Mo(e,t,n)})),s})),xs=Mr((function(e,t,n){oo(e,n,t)}));function ws(e,t){return(Vs(e)?_t:Bo)(e,si(t,3))}var As=Mr((function(e,t,n){e[n?0:1].push(t)}),(function(){return[[],[]]})),Ts=Yo((function(e,t){if(null==e)return[];var n=t.length;return n>1&&yi(e,t[0],t[1])?t=[]:n>2&&yi(t[0],t[1],t[2])&&(t=[t[0]]),Uo(e,go(t,1),[])})),Es=ct||function(){return ht.Date.now()};function Ss(e,t,n){return t=n?r:t,t=e&&null==t?e.length:t,Kr(e,c,r,r,r,r,t)}function Ns(e,t){var n;if("function"!=typeof t)throw new Ne(i);return e=pa(e),function(){return--e>0&&(n=t.apply(this,arguments)),e<=1&&(t=r),n}}var Is=Yo((function(e,t,n){var o=1;if(n.length){var r=an(n,ii(Is));o|=l}return Kr(e,o,t,n,r)})),Ms=Yo((function(e,t,n){var o=3;if(n.length){var r=an(n,ii(Ms));o|=l}return Kr(t,o,e,n,r)}));function Ps(e,t,n){var o,s,a,l,c,u,h=0,d=!1,p=!1,m=!0;if("function"!=typeof e)throw new Ne(i);function f(t){var n=o,i=s;return o=s=r,h=t,l=e.apply(i,n)}function g(e){var n=e-u;return u===r||n>=t||n<0||p&&e-h>=a}function y(){var e=Es();if(g(e))return b(e);c=Ii(y,function(e){var n=t-(e-u);return p?yn(n,a-(e-h)):n}(e))}function b(e){return c=r,m&&o?f(e):(o=s=r,l)}function v(){var e=Es(),n=g(e);if(o=arguments,s=this,u=e,n){if(c===r)return function(e){return h=e,c=Ii(y,t),d?f(e):l}(u);if(p)return Cr(c),c=Ii(y,t),f(u)}return c===r&&(c=Ii(y,t)),l}return t=fa(t)||0,Zs(n)&&(d=!!n.leading,a=(p="maxWait"in n)?gn(fa(n.maxWait)||0,t):a,m="trailing"in n?!!n.trailing:m),v.cancel=function(){c!==r&&Cr(c),h=0,o=u=s=c=r},v.flush=function(){return c===r?l:b(Es())},v}var _s=Yo((function(e,t){return lo(e,1,t)})),Ls=Yo((function(e,t,n){return lo(e,fa(t)||0,n)}));function Os(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new Ne(i);var n=function(){var o=arguments,r=t?t.apply(this,o):o[0],i=n.cache;if(i.has(r))return i.get(r);var s=e.apply(this,o);return n.cache=i.set(r,s)||i,s};return n.cache=new(Os.Cache||qn),n}function Rs(e){if("function"!=typeof e)throw new Ne(i);return function(){var t=arguments;switch(t.length){case 0:return!e.call(this);case 1:return!e.call(this,t[0]);case 2:return!e.call(this,t[0],t[1]);case 3:return!e.call(this,t[0],t[1],t[2])}return!e.apply(this,t)}}Os.Cache=qn;var $s=br((function(e,t){var n=(t=1==t.length&&Vs(t[0])?_t(t[0],Kt(si())):_t(go(t,1),Kt(si()))).length;return Yo((function(o){for(var r=-1,i=yn(o.length,n);++r<i;)o[r]=t[r].call(this,o[r]);return At(e,this,o)}))})),Ds=Yo((function(e,t){var n=an(t,ii(Ds));return Kr(e,l,r,t,n)})),Bs=Yo((function(e,t){var n=an(t,ii(Bs));return Kr(e,64,r,t,n)})),Fs=ei((function(e,t){return Kr(e,256,r,r,r,t)}));function ks(e,t){return e===t||e!=e&&t!=t}var Hs=jr(Eo),Gs=jr((function(e,t){return e>=t})),Us=Po(function(){return arguments}())?Po:function(e){return ea(e)&&Oe.call(e,"callee")&&!We.call(e,"callee")},Vs=o.isArray,js=yt?Kt(yt):function(e){return ea(e)&&To(e)==_};function qs(e){return null!=e&&Xs(e.length)&&!Qs(e)}function Ws(e){return ea(e)&&qs(e)}var zs=gt||fl,Ys=bt?Kt(bt):function(e){return ea(e)&&To(e)==b};function Ks(e){if(!ea(e))return!1;var t=To(e);return t==v||"[object DOMException]"==t||"string"==typeof e.message&&"string"==typeof e.name&&!oa(e)}function Qs(e){if(!Zs(e))return!1;var t=To(e);return t==C||t==x||"[object AsyncFunction]"==t||"[object Proxy]"==t}function Js(e){return"number"==typeof e&&e==pa(e)}function Xs(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=h}function Zs(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function ea(e){return null!=e&&"object"==typeof e}var ta=vt?Kt(vt):function(e){return ea(e)&&di(e)==w};function na(e){return"number"==typeof e||ea(e)&&To(e)==A}function oa(e){if(!ea(e)||To(e)!=T)return!1;var t=je(e);if(null===t)return!0;var n=Oe.call(t,"constructor")&&t.constructor;return"function"==typeof n&&n instanceof n&&Le.call(n)==Be}var ra=Ct?Kt(Ct):function(e){return ea(e)&&To(e)==S},ia=xt?Kt(xt):function(e){return ea(e)&&di(e)==N};function sa(e){return"string"==typeof e||!Vs(e)&&ea(e)&&To(e)==I}function aa(e){return"symbol"==typeof e||ea(e)&&To(e)==M}var la=wt?Kt(wt):function(e){return ea(e)&&Xs(e.length)&&!!rt[To(e)]},ca=jr(Do),ua=jr((function(e,t){return e<=t}));function ha(e){if(!e)return[];if(qs(e))return sa(e)?hn(e):Nr(e);if(Ke&&e[Ke])return function(e){for(var t,n=[];!(t=e.next()).done;)n.push(t.value);return n}(e[Ke]());var t=di(e);return(t==w?rn:t==N?ln:ka)(e)}function da(e){return e?(e=fa(e))===u||e===-1/0?17976931348623157e292*(e<0?-1:1):e==e?e:0:0===e?e:0}function pa(e){var t=da(e),n=t%1;return t==t?n?t-n:t:0}function ma(e){return e?io(pa(e),0,p):0}function fa(e){if("number"==typeof e)return e;if(aa(e))return d;if(Zs(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=Zs(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=Yt(e);var n=me.test(e);return n||ge.test(e)?lt(e.slice(2),n?2:8):pe.test(e)?d:+e}function ga(e){return Ir(e,_a(e))}function ya(e){return null==e?"":ar(e)}var ba=Pr((function(e,t){if(xi(t)||qs(t))Ir(t,Pa(t),e);else for(var n in t)Oe.call(t,n)&&Zn(e,n,t[n])})),va=Pr((function(e,t){Ir(t,_a(t),e)})),Ca=Pr((function(e,t,n,o){Ir(t,_a(t),e,o)})),xa=Pr((function(e,t,n,o){Ir(t,Pa(t),e,o)})),wa=ei(ro),Aa=Yo((function(e,t){e=Te(e);var n=-1,o=t.length,i=o>2?t[2]:r;for(i&&yi(t[0],t[1],i)&&(o=1);++n<o;)for(var s=t[n],a=_a(s),l=-1,c=a.length;++l<c;){var u=a[l],h=e[u];(h===r||ks(h,Pe[u])&&!Oe.call(e,u))&&(e[u]=s[u])}return e})),Ta=Yo((function(e){return e.push(r,Jr),At(Oa,r,e)}));function Ea(e,t,n){var o=null==e?r:wo(e,t);return o===r?n:o}function Sa(e,t){return null!=e&&pi(e,t,No)}var Na=kr((function(e,t,n){null!=t&&"function"!=typeof t.toString&&(t=De.call(t)),e[t]=n}),Za(nl)),Ia=kr((function(e,t,n){null!=t&&"function"!=typeof t.toString&&(t=De.call(t)),Oe.call(e,t)?e[t].push(n):e[t]=[n]}),si),Ma=Yo(Mo);function Pa(e){return qs(e)?Yn(e):$o(e)}function _a(e){return qs(e)?Yn(e,!0):function(e){if(!Zs(e))return function(e){var t=[];if(null!=e)for(var n in Te(e))t.push(n);return t}(e);var t=xi(e),n=[];for(var o in e)("constructor"!=o||!t&&Oe.call(e,o))&&n.push(o);return n}(e)}var La=Pr((function(e,t,n){Ho(e,t,n)})),Oa=Pr((function(e,t,n,o){Ho(e,t,n,o)})),Ra=ei((function(e,t){var n={};if(null==e)return n;var o=!1;t=_t(t,(function(t){return t=yr(t,e),o||(o=t.length>1),t})),Ir(e,ni(e),n),o&&(n=so(n,7,Xr));for(var r=t.length;r--;)cr(n,t[r]);return n})),$a=ei((function(e,t){return null==e?{}:function(e,t){return Vo(e,t,(function(t,n){return Sa(e,n)}))}(e,t)}));function Da(e,t){if(null==e)return{};var n=_t(ni(e),(function(e){return[e]}));return t=si(t),Vo(e,n,(function(e,n){return t(e,n[0])}))}var Ba=Yr(Pa),Fa=Yr(_a);function ka(e){return null==e?[]:Qt(e,Pa(e))}var Ha=Rr((function(e,t,n){return t=t.toLowerCase(),e+(n?Ga(t):t)}));function Ga(e){return Ka(ya(e).toLowerCase())}function Ua(e){return(e=ya(e))&&e.replace(be,en).replace(Je,"")}var Va=Rr((function(e,t,n){return e+(n?"-":"")+t.toLowerCase()})),ja=Rr((function(e,t,n){return e+(n?" ":"")+t.toLowerCase()})),qa=Or("toLowerCase"),Wa=Rr((function(e,t,n){return e+(n?"_":"")+t.toLowerCase()})),za=Rr((function(e,t,n){return e+(n?" ":"")+Ka(t)})),Ya=Rr((function(e,t,n){return e+(n?" ":"")+t.toUpperCase()})),Ka=Or("toUpperCase");function Qa(e,t,n){return e=ya(e),(t=n?r:t)===r?function(e){return tt.test(e)}(e)?function(e){return e.match(Ze)||[]}(e):function(e){return e.match(le)||[]}(e):e.match(t)||[]}var Ja=Yo((function(e,t){try{return At(e,r,t)}catch(e){return Ks(e)?e:new xe(e)}})),Xa=ei((function(e,t){return Et(t,(function(t){t=Di(t),oo(e,t,Is(e[t],e))})),e}));function Za(e){return function(){return e}}var el=Br(),tl=Br(!0);function nl(e){return e}function ol(e){return Ro("function"==typeof e?e:so(e,1))}var rl=Yo((function(e,t){return function(n){return Mo(n,e,t)}})),il=Yo((function(e,t){return function(n){return Mo(e,n,t)}}));function sl(e,t,n){var o=Pa(t),r=xo(t,o);null!=n||Zs(t)&&(r.length||!o.length)||(n=t,t=e,e=this,r=xo(t,Pa(t)));var i=!(Zs(n)&&"chain"in n&&!n.chain),s=Qs(e);return Et(r,(function(n){var o=t[n];e[n]=o,s&&(e.prototype[n]=function(){var t=this.__chain__;if(i||t){var n=e(this.__wrapped__);return(n.__actions__=Nr(this.__actions__)).push({func:o,args:arguments,thisArg:e}),n.__chain__=t,n}return o.apply(e,Lt([this.value()],arguments))})})),e}function al(){}var ll=Gr(_t),cl=Gr(Nt),ul=Gr($t);function hl(e){return bi(e)?Vt(Di(e)):function(e){return function(t){return wo(t,e)}}(e)}var dl=Vr(),pl=Vr(!0);function ml(){return[]}function fl(){return!1}var gl,yl=Hr((function(e,t){return e+t}),0),bl=Wr("ceil"),vl=Hr((function(e,t){return e/t}),1),Cl=Wr("floor"),xl=Hr((function(e,t){return e*t}),1),wl=Wr("round"),Al=Hr((function(e,t){return e-t}),0);return Fn.after=function(e,t){if("function"!=typeof t)throw new Ne(i);return e=pa(e),function(){if(--e<1)return t.apply(this,arguments)}},Fn.ary=Ss,Fn.assign=ba,Fn.assignIn=va,Fn.assignInWith=Ca,Fn.assignWith=xa,Fn.at=wa,Fn.before=Ns,Fn.bind=Is,Fn.bindAll=Xa,Fn.bindKey=Ms,Fn.castArray=function(){if(!arguments.length)return[];var e=arguments[0];return Vs(e)?e:[e]},Fn.chain=hs,Fn.chunk=function(e,t,n){t=(n?yi(e,t,n):t===r)?1:gn(pa(t),0);var i=null==e?0:e.length;if(!i||t<1)return[];for(var s=0,a=0,l=o(dt(i/t));s<i;)l[a++]=tr(e,s,s+=t);return l},Fn.compact=function(e){for(var t=-1,n=null==e?0:e.length,o=0,r=[];++t<n;){var i=e[t];i&&(r[o++]=i)}return r},Fn.concat=function(){var e=arguments.length;if(!e)return[];for(var t=o(e-1),n=arguments[0],r=e;r--;)t[r-1]=arguments[r];return Lt(Vs(n)?Nr(n):[n],go(t,1))},Fn.cond=function(e){var t=null==e?0:e.length,n=si();return e=t?_t(e,(function(e){if("function"!=typeof e[1])throw new Ne(i);return[n(e[0]),e[1]]})):[],Yo((function(n){for(var o=-1;++o<t;){var r=e[o];if(At(r[0],this,n))return At(r[1],this,n)}}))},Fn.conforms=function(e){return function(e){var t=Pa(e);return function(n){return ao(n,e,t)}}(so(e,1))},Fn.constant=Za,Fn.countBy=ms,Fn.create=function(e,t){var n=kn(e);return null==t?n:no(n,t)},Fn.curry=function e(t,n,o){var i=Kr(t,8,r,r,r,r,r,n=o?r:n);return i.placeholder=e.placeholder,i},Fn.curryRight=function e(t,n,o){var i=Kr(t,16,r,r,r,r,r,n=o?r:n);return i.placeholder=e.placeholder,i},Fn.debounce=Ps,Fn.defaults=Aa,Fn.defaultsDeep=Ta,Fn.defer=_s,Fn.delay=Ls,Fn.difference=ki,Fn.differenceBy=Hi,Fn.differenceWith=Gi,Fn.drop=function(e,t,n){var o=null==e?0:e.length;return o?tr(e,(t=n||t===r?1:pa(t))<0?0:t,o):[]},Fn.dropRight=function(e,t,n){var o=null==e?0:e.length;return o?tr(e,0,(t=o-(t=n||t===r?1:pa(t)))<0?0:t):[]},Fn.dropRightWhile=function(e,t){return e&&e.length?hr(e,si(t,3),!0,!0):[]},Fn.dropWhile=function(e,t){return e&&e.length?hr(e,si(t,3),!0):[]},Fn.fill=function(e,t,n,o){var i=null==e?0:e.length;return i?(n&&"number"!=typeof n&&yi(e,t,n)&&(n=0,o=i),function(e,t,n,o){var i=e.length;for((n=pa(n))<0&&(n=-n>i?0:i+n),(o=o===r||o>i?i:pa(o))<0&&(o+=i),o=n>o?0:ma(o);n<o;)e[n++]=t;return e}(e,t,n,o)):[]},Fn.filter=function(e,t){return(Vs(e)?It:fo)(e,si(t,3))},Fn.flatMap=function(e,t){return go(ws(e,t),1)},Fn.flatMapDeep=function(e,t){return go(ws(e,t),u)},Fn.flatMapDepth=function(e,t,n){return n=n===r?1:pa(n),go(ws(e,t),n)},Fn.flatten=ji,Fn.flattenDeep=function(e){return null!=e&&e.length?go(e,u):[]},Fn.flattenDepth=function(e,t){return null!=e&&e.length?go(e,t=t===r?1:pa(t)):[]},Fn.flip=function(e){return Kr(e,512)},Fn.flow=el,Fn.flowRight=tl,Fn.fromPairs=function(e){for(var t=-1,n=null==e?0:e.length,o={};++t<n;){var r=e[t];o[r[0]]=r[1]}return o},Fn.functions=function(e){return null==e?[]:xo(e,Pa(e))},Fn.functionsIn=function(e){return null==e?[]:xo(e,_a(e))},Fn.groupBy=vs,Fn.initial=function(e){return null!=e&&e.length?tr(e,0,-1):[]},Fn.intersection=Wi,Fn.intersectionBy=zi,Fn.intersectionWith=Yi,Fn.invert=Na,Fn.invertBy=Ia,Fn.invokeMap=Cs,Fn.iteratee=ol,Fn.keyBy=xs,Fn.keys=Pa,Fn.keysIn=_a,Fn.map=ws,Fn.mapKeys=function(e,t){var n={};return t=si(t,3),vo(e,(function(e,o,r){oo(n,t(e,o,r),e)})),n},Fn.mapValues=function(e,t){var n={};return t=si(t,3),vo(e,(function(e,o,r){oo(n,o,t(e,o,r))})),n},Fn.matches=function(e){return Fo(so(e,1))},Fn.matchesProperty=function(e,t){return ko(e,so(t,1))},Fn.memoize=Os,Fn.merge=La,Fn.mergeWith=Oa,Fn.method=rl,Fn.methodOf=il,Fn.mixin=sl,Fn.negate=Rs,Fn.nthArg=function(e){return e=pa(e),Yo((function(t){return Go(t,e)}))},Fn.omit=Ra,Fn.omitBy=function(e,t){return Da(e,Rs(si(t)))},Fn.once=function(e){return Ns(2,e)},Fn.orderBy=function(e,t,n,o){return null==e?[]:(Vs(t)||(t=null==t?[]:[t]),Vs(n=o?r:n)||(n=null==n?[]:[n]),Uo(e,t,n))},Fn.over=ll,Fn.overArgs=$s,Fn.overEvery=cl,Fn.overSome=ul,Fn.partial=Ds,Fn.partialRight=Bs,Fn.partition=As,Fn.pick=$a,Fn.pickBy=Da,Fn.property=hl,Fn.propertyOf=function(e){return function(t){return null==e?r:wo(e,t)}},Fn.pull=Qi,Fn.pullAll=Ji,Fn.pullAllBy=function(e,t,n){return e&&e.length&&t&&t.length?jo(e,t,si(n,2)):e},Fn.pullAllWith=function(e,t,n){return e&&e.length&&t&&t.length?jo(e,t,r,n):e},Fn.pullAt=Xi,Fn.range=dl,Fn.rangeRight=pl,Fn.rearg=Fs,Fn.reject=function(e,t){return(Vs(e)?It:fo)(e,Rs(si(t,3)))},Fn.remove=function(e,t){var n=[];if(!e||!e.length)return n;var o=-1,r=[],i=e.length;for(t=si(t,3);++o<i;){var s=e[o];t(s,o,e)&&(n.push(s),r.push(o))}return qo(e,r),n},Fn.rest=function(e,t){if("function"!=typeof e)throw new Ne(i);return Yo(e,t=t===r?t:pa(t))},Fn.reverse=Zi,Fn.sampleSize=function(e,t,n){return t=(n?yi(e,t,n):t===r)?1:pa(t),(Vs(e)?Qn:Qo)(e,t)},Fn.set=function(e,t,n){return null==e?e:Jo(e,t,n)},Fn.setWith=function(e,t,n,o){return o="function"==typeof o?o:r,null==e?e:Jo(e,t,n,o)},Fn.shuffle=function(e){return(Vs(e)?Jn:er)(e)},Fn.slice=function(e,t,n){var o=null==e?0:e.length;return o?(n&&"number"!=typeof n&&yi(e,t,n)?(t=0,n=o):(t=null==t?0:pa(t),n=n===r?o:pa(n)),tr(e,t,n)):[]},Fn.sortBy=Ts,Fn.sortedUniq=function(e){return e&&e.length?ir(e):[]},Fn.sortedUniqBy=function(e,t){return e&&e.length?ir(e,si(t,2)):[]},Fn.split=function(e,t,n){return n&&"number"!=typeof n&&yi(e,t,n)&&(t=n=r),(n=n===r?p:n>>>0)?(e=ya(e))&&("string"==typeof t||null!=t&&!ra(t))&&!(t=ar(t))&&on(e)?vr(hn(e),0,n):e.split(t,n):[]},Fn.spread=function(e,t){if("function"!=typeof e)throw new Ne(i);return t=null==t?0:gn(pa(t),0),Yo((function(n){var o=n[t],r=vr(n,0,t);return o&&Lt(r,o),At(e,this,r)}))},Fn.tail=function(e){var t=null==e?0:e.length;return t?tr(e,1,t):[]},Fn.take=function(e,t,n){return e&&e.length?tr(e,0,(t=n||t===r?1:pa(t))<0?0:t):[]},Fn.takeRight=function(e,t,n){var o=null==e?0:e.length;return o?tr(e,(t=o-(t=n||t===r?1:pa(t)))<0?0:t,o):[]},Fn.takeRightWhile=function(e,t){return e&&e.length?hr(e,si(t,3),!1,!0):[]},Fn.takeWhile=function(e,t){return e&&e.length?hr(e,si(t,3)):[]},Fn.tap=function(e,t){return t(e),e},Fn.throttle=function(e,t,n){var o=!0,r=!0;if("function"!=typeof e)throw new Ne(i);return Zs(n)&&(o="leading"in n?!!n.leading:o,r="trailing"in n?!!n.trailing:r),Ps(e,t,{leading:o,maxWait:t,trailing:r})},Fn.thru=ds,Fn.toArray=ha,Fn.toPairs=Ba,Fn.toPairsIn=Fa,Fn.toPath=function(e){return Vs(e)?_t(e,Di):aa(e)?[e]:Nr($i(ya(e)))},Fn.toPlainObject=ga,Fn.transform=function(e,t,n){var o=Vs(e),r=o||zs(e)||la(e);if(t=si(t,4),null==n){var i=e&&e.constructor;n=r?o?new i:[]:Zs(e)&&Qs(i)?kn(je(e)):{}}return(r?Et:vo)(e,(function(e,o,r){return t(n,e,o,r)})),n},Fn.unary=function(e){return Ss(e,1)},Fn.union=es,Fn.unionBy=ts,Fn.unionWith=ns,Fn.uniq=function(e){return e&&e.length?lr(e):[]},Fn.uniqBy=function(e,t){return e&&e.length?lr(e,si(t,2)):[]},Fn.uniqWith=function(e,t){return t="function"==typeof t?t:r,e&&e.length?lr(e,r,t):[]},Fn.unset=function(e,t){return null==e||cr(e,t)},Fn.unzip=os,Fn.unzipWith=rs,Fn.update=function(e,t,n){return null==e?e:ur(e,t,gr(n))},Fn.updateWith=function(e,t,n,o){return o="function"==typeof o?o:r,null==e?e:ur(e,t,gr(n),o)},Fn.values=ka,Fn.valuesIn=function(e){return null==e?[]:Qt(e,_a(e))},Fn.without=is,Fn.words=Qa,Fn.wrap=function(e,t){return Ds(gr(t),e)},Fn.xor=ss,Fn.xorBy=as,Fn.xorWith=ls,Fn.zip=cs,Fn.zipObject=function(e,t){return mr(e||[],t||[],Zn)},Fn.zipObjectDeep=function(e,t){return mr(e||[],t||[],Jo)},Fn.zipWith=us,Fn.entries=Ba,Fn.entriesIn=Fa,Fn.extend=va,Fn.extendWith=Ca,sl(Fn,Fn),Fn.add=yl,Fn.attempt=Ja,Fn.camelCase=Ha,Fn.capitalize=Ga,Fn.ceil=bl,Fn.clamp=function(e,t,n){return n===r&&(n=t,t=r),n!==r&&(n=(n=fa(n))==n?n:0),t!==r&&(t=(t=fa(t))==t?t:0),io(fa(e),t,n)},Fn.clone=function(e){return so(e,4)},Fn.cloneDeep=function(e){return so(e,5)},Fn.cloneDeepWith=function(e,t){return so(e,5,t="function"==typeof t?t:r)},Fn.cloneWith=function(e,t){return so(e,4,t="function"==typeof t?t:r)},Fn.conformsTo=function(e,t){return null==t||ao(e,t,Pa(t))},Fn.deburr=Ua,Fn.defaultTo=function(e,t){return null==e||e!=e?t:e},Fn.divide=vl,Fn.endsWith=function(e,t,n){e=ya(e),t=ar(t);var o=e.length,i=n=n===r?o:io(pa(n),0,o);return(n-=t.length)>=0&&e.slice(n,i)==t},Fn.eq=ks,Fn.escape=function(e){return(e=ya(e))&&Y.test(e)?e.replace(W,tn):e},Fn.escapeRegExp=function(e){return(e=ya(e))&&ne.test(e)?e.replace(te,"\\$&"):e},Fn.every=function(e,t,n){var o=Vs(e)?Nt:po;return n&&yi(e,t,n)&&(t=r),o(e,si(t,3))},Fn.find=fs,Fn.findIndex=Ui,Fn.findKey=function(e,t){return Bt(e,si(t,3),vo)},Fn.findLast=gs,Fn.findLastIndex=Vi,Fn.findLastKey=function(e,t){return Bt(e,si(t,3),Co)},Fn.floor=Cl,Fn.forEach=ys,Fn.forEachRight=bs,Fn.forIn=function(e,t){return null==e?e:yo(e,si(t,3),_a)},Fn.forInRight=function(e,t){return null==e?e:bo(e,si(t,3),_a)},Fn.forOwn=function(e,t){return e&&vo(e,si(t,3))},Fn.forOwnRight=function(e,t){return e&&Co(e,si(t,3))},Fn.get=Ea,Fn.gt=Hs,Fn.gte=Gs,Fn.has=function(e,t){return null!=e&&pi(e,t,So)},Fn.hasIn=Sa,Fn.head=qi,Fn.identity=nl,Fn.includes=function(e,t,n,o){e=qs(e)?e:ka(e),n=n&&!o?pa(n):0;var r=e.length;return n<0&&(n=gn(r+n,0)),sa(e)?n<=r&&e.indexOf(t,n)>-1:!!r&&kt(e,t,n)>-1},Fn.indexOf=function(e,t,n){var o=null==e?0:e.length;if(!o)return-1;var r=null==n?0:pa(n);return r<0&&(r=gn(o+r,0)),kt(e,t,r)},Fn.inRange=function(e,t,n){return t=da(t),n===r?(n=t,t=0):n=da(n),function(e,t,n){return e>=yn(t,n)&&e<gn(t,n)}(e=fa(e),t,n)},Fn.invoke=Ma,Fn.isArguments=Us,Fn.isArray=Vs,Fn.isArrayBuffer=js,Fn.isArrayLike=qs,Fn.isArrayLikeObject=Ws,Fn.isBoolean=function(e){return!0===e||!1===e||ea(e)&&To(e)==y},Fn.isBuffer=zs,Fn.isDate=Ys,Fn.isElement=function(e){return ea(e)&&1===e.nodeType&&!oa(e)},Fn.isEmpty=function(e){if(null==e)return!0;if(qs(e)&&(Vs(e)||"string"==typeof e||"function"==typeof e.splice||zs(e)||la(e)||Us(e)))return!e.length;var t=di(e);if(t==w||t==N)return!e.size;if(xi(e))return!$o(e).length;for(var n in e)if(Oe.call(e,n))return!1;return!0},Fn.isEqual=function(e,t){return _o(e,t)},Fn.isEqualWith=function(e,t,n){var o=(n="function"==typeof n?n:r)?n(e,t):r;return o===r?_o(e,t,r,n):!!o},Fn.isError=Ks,Fn.isFinite=function(e){return"number"==typeof e&&Dt(e)},Fn.isFunction=Qs,Fn.isInteger=Js,Fn.isLength=Xs,Fn.isMap=ta,Fn.isMatch=function(e,t){return e===t||Lo(e,t,li(t))},Fn.isMatchWith=function(e,t,n){return n="function"==typeof n?n:r,Lo(e,t,li(t),n)},Fn.isNaN=function(e){return na(e)&&e!=+e},Fn.isNative=function(e){if(Ci(e))throw new xe("Unsupported core-js use. Try https://npms.io/search?q=ponyfill.");return Oo(e)},Fn.isNil=function(e){return null==e},Fn.isNull=function(e){return null===e},Fn.isNumber=na,Fn.isObject=Zs,Fn.isObjectLike=ea,Fn.isPlainObject=oa,Fn.isRegExp=ra,Fn.isSafeInteger=function(e){return Js(e)&&e>=-9007199254740991&&e<=h},Fn.isSet=ia,Fn.isString=sa,Fn.isSymbol=aa,Fn.isTypedArray=la,Fn.isUndefined=function(e){return e===r},Fn.isWeakMap=function(e){return ea(e)&&di(e)==P},Fn.isWeakSet=function(e){return ea(e)&&"[object WeakSet]"==To(e)},Fn.join=function(e,t){return null==e?"":jt.call(e,t)},Fn.kebabCase=Va,Fn.last=Ki,Fn.lastIndexOf=function(e,t,n){var o=null==e?0:e.length;if(!o)return-1;var i=o;return n!==r&&(i=(i=pa(n))<0?gn(o+i,0):yn(i,o-1)),t==t?function(e,t,n){for(var o=n+1;o--;)if(e[o]===t)return o;return o}(e,t,i):Ft(e,Gt,i,!0)},Fn.lowerCase=ja,Fn.lowerFirst=qa,Fn.lt=ca,Fn.lte=ua,Fn.max=function(e){return e&&e.length?mo(e,nl,Eo):r},Fn.maxBy=function(e,t){return e&&e.length?mo(e,si(t,2),Eo):r},Fn.mean=function(e){return Ut(e,nl)},Fn.meanBy=function(e,t){return Ut(e,si(t,2))},Fn.min=function(e){return e&&e.length?mo(e,nl,Do):r},Fn.minBy=function(e,t){return e&&e.length?mo(e,si(t,2),Do):r},Fn.stubArray=ml,Fn.stubFalse=fl,Fn.stubObject=function(){return{}},Fn.stubString=function(){return""},Fn.stubTrue=function(){return!0},Fn.multiply=xl,Fn.nth=function(e,t){return e&&e.length?Go(e,pa(t)):r},Fn.noConflict=function(){return ht._===this&&(ht._=Fe),this},Fn.noop=al,Fn.now=Es,Fn.pad=function(e,t,n){e=ya(e);var o=(t=pa(t))?un(e):0;if(!t||o>=t)return e;var r=(t-o)/2;return Ur(pt(r),n)+e+Ur(dt(r),n)},Fn.padEnd=function(e,t,n){e=ya(e);var o=(t=pa(t))?un(e):0;return t&&o<t?e+Ur(t-o,n):e},Fn.padStart=function(e,t,n){e=ya(e);var o=(t=pa(t))?un(e):0;return t&&o<t?Ur(t-o,n)+e:e},Fn.parseInt=function(e,t,n){return n||null==t?t=0:t&&(t=+t),vn(ya(e).replace(oe,""),t||0)},Fn.random=function(e,t,n){if(n&&"boolean"!=typeof n&&yi(e,t,n)&&(t=n=r),n===r&&("boolean"==typeof t?(n=t,t=r):"boolean"==typeof e&&(n=e,e=r)),e===r&&t===r?(e=0,t=1):(e=da(e),t===r?(t=e,e=0):t=da(t)),e>t){var o=e;e=t,t=o}if(n||e%1||t%1){var i=Cn();return yn(e+i*(t-e+at("1e-"+((i+"").length-1))),t)}return Wo(e,t)},Fn.reduce=function(e,t,n){var o=Vs(e)?Ot:qt,r=arguments.length<3;return o(e,si(t,4),n,r,uo)},Fn.reduceRight=function(e,t,n){var o=Vs(e)?Rt:qt,r=arguments.length<3;return o(e,si(t,4),n,r,ho)},Fn.repeat=function(e,t,n){return t=(n?yi(e,t,n):t===r)?1:pa(t),zo(ya(e),t)},Fn.replace=function(){var e=arguments,t=ya(e[0]);return e.length<3?t:t.replace(e[1],e[2])},Fn.result=function(e,t,n){var o=-1,i=(t=yr(t,e)).length;for(i||(i=1,e=r);++o<i;){var s=null==e?r:e[Di(t[o])];s===r&&(o=i,s=n),e=Qs(s)?s.call(e):s}return e},Fn.round=wl,Fn.runInContext=e,Fn.sample=function(e){return(Vs(e)?Kn:Ko)(e)},Fn.size=function(e){if(null==e)return 0;if(qs(e))return sa(e)?un(e):e.length;var t=di(e);return t==w||t==N?e.size:$o(e).length},Fn.snakeCase=Wa,Fn.some=function(e,t,n){var o=Vs(e)?$t:nr;return n&&yi(e,t,n)&&(t=r),o(e,si(t,3))},Fn.sortedIndex=function(e,t){return or(e,t)},Fn.sortedIndexBy=function(e,t,n){return rr(e,t,si(n,2))},Fn.sortedIndexOf=function(e,t){var n=null==e?0:e.length;if(n){var o=or(e,t);if(o<n&&ks(e[o],t))return o}return-1},Fn.sortedLastIndex=function(e,t){return or(e,t,!0)},Fn.sortedLastIndexBy=function(e,t,n){return rr(e,t,si(n,2),!0)},Fn.sortedLastIndexOf=function(e,t){if(null!=e&&e.length){var n=or(e,t,!0)-1;if(ks(e[n],t))return n}return-1},Fn.startCase=za,Fn.startsWith=function(e,t,n){return e=ya(e),n=null==n?0:io(pa(n),0,e.length),t=ar(t),e.slice(n,n+t.length)==t},Fn.subtract=Al,Fn.sum=function(e){return e&&e.length?Wt(e,nl):0},Fn.sumBy=function(e,t){return e&&e.length?Wt(e,si(t,2)):0},Fn.template=function(e,t,n){var o=Fn.templateSettings;n&&yi(e,t,n)&&(t=r),e=ya(e),t=Ca({},t,o,Qr);var i,s,a=Ca({},t.imports,o.imports,Qr),l=Pa(a),c=Qt(a,l),u=0,h=t.interpolate||ve,d="__p += '",p=Ee((t.escape||ve).source+"|"+h.source+"|"+(h===J?he:ve).source+"|"+(t.evaluate||ve).source+"|$","g"),m="//# sourceURL="+(Oe.call(t,"sourceURL")?(t.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++ot+"]")+"\n";e.replace(p,(function(t,n,o,r,a,l){return o||(o=r),d+=e.slice(u,l).replace(Ce,nn),n&&(i=!0,d+="' +\n__e("+n+") +\n'"),a&&(s=!0,d+="';\n"+a+";\n__p += '"),o&&(d+="' +\n((__t = ("+o+")) == null ? '' : __t) +\n'"),u=l+t.length,t})),d+="';\n";var f=Oe.call(t,"variable")&&t.variable;if(f){if(ce.test(f))throw new xe("Invalid `variable` option passed into `_.template`")}else d="with (obj) {\n"+d+"\n}\n";d=(s?d.replace(U,""):d).replace(V,"$1").replace(j,"$1;"),d="function("+(f||"obj")+") {\n"+(f?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(i?", __e = _.escape":"")+(s?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+d+"return __p\n}";var g=Ja((function(){return we(l,m+"return "+d).apply(r,c)}));if(g.source=d,Ks(g))throw g;return g},Fn.times=function(e,t){if((e=pa(e))<1||e>h)return[];var n=p,o=yn(e,p);t=si(t),e-=p;for(var r=zt(o,t);++n<e;)t(n);return r},Fn.toFinite=da,Fn.toInteger=pa,Fn.toLength=ma,Fn.toLower=function(e){return ya(e).toLowerCase()},Fn.toNumber=fa,Fn.toSafeInteger=function(e){return e?io(pa(e),-9007199254740991,h):0===e?e:0},Fn.toString=ya,Fn.toUpper=function(e){return ya(e).toUpperCase()},Fn.trim=function(e,t,n){if((e=ya(e))&&(n||t===r))return Yt(e);if(!e||!(t=ar(t)))return e;var o=hn(e),i=hn(t);return vr(o,Xt(o,i),Zt(o,i)+1).join("")},Fn.trimEnd=function(e,t,n){if((e=ya(e))&&(n||t===r))return e.slice(0,dn(e)+1);if(!e||!(t=ar(t)))return e;var o=hn(e);return vr(o,0,Zt(o,hn(t))+1).join("")},Fn.trimStart=function(e,t,n){if((e=ya(e))&&(n||t===r))return e.replace(oe,"");if(!e||!(t=ar(t)))return e;var o=hn(e);return vr(o,Xt(o,hn(t))).join("")},Fn.truncate=function(e,t){var n=30,o="...";if(Zs(t)){var i="separator"in t?t.separator:i;n="length"in t?pa(t.length):n,o="omission"in t?ar(t.omission):o}var s=(e=ya(e)).length;if(on(e)){var a=hn(e);s=a.length}if(n>=s)return e;var l=n-un(o);if(l<1)return o;var c=a?vr(a,0,l).join(""):e.slice(0,l);if(i===r)return c+o;if(a&&(l+=c.length-l),ra(i)){if(e.slice(l).search(i)){var u,h=c;for(i.global||(i=Ee(i.source,ya(de.exec(i))+"g")),i.lastIndex=0;u=i.exec(h);)var d=u.index;c=c.slice(0,d===r?l:d)}}else if(e.indexOf(ar(i),l)!=l){var p=c.lastIndexOf(i);p>-1&&(c=c.slice(0,p))}return c+o},Fn.unescape=function(e){return(e=ya(e))&&z.test(e)?e.replace(q,pn):e},Fn.uniqueId=function(e){var t=++Re;return ya(e)+t},Fn.upperCase=Ya,Fn.upperFirst=Ka,Fn.each=ys,Fn.eachRight=bs,Fn.first=qi,sl(Fn,(gl={},vo(Fn,(function(e,t){Oe.call(Fn.prototype,t)||(gl[t]=e)})),gl),{chain:!1}),Fn.VERSION="4.17.21",Et(["bind","bindKey","curry","curryRight","partial","partialRight"],(function(e){Fn[e].placeholder=Fn})),Et(["drop","take"],(function(e,t){Un.prototype[e]=function(n){n=n===r?1:gn(pa(n),0);var o=this.__filtered__&&!t?new Un(this):this.clone();return o.__filtered__?o.__takeCount__=yn(n,o.__takeCount__):o.__views__.push({size:yn(n,p),type:e+(o.__dir__<0?"Right":"")}),o},Un.prototype[e+"Right"]=function(t){return this.reverse()[e](t).reverse()}})),Et(["filter","map","takeWhile"],(function(e,t){var n=t+1,o=1==n||3==n;Un.prototype[e]=function(e){var t=this.clone();return t.__iteratees__.push({iteratee:si(e,3),type:n}),t.__filtered__=t.__filtered__||o,t}})),Et(["head","last"],(function(e,t){var n="take"+(t?"Right":"");Un.prototype[e]=function(){return this[n](1).value()[0]}})),Et(["initial","tail"],(function(e,t){var n="drop"+(t?"":"Right");Un.prototype[e]=function(){return this.__filtered__?new Un(this):this[n](1)}})),Un.prototype.compact=function(){return this.filter(nl)},Un.prototype.find=function(e){return this.filter(e).head()},Un.prototype.findLast=function(e){return this.reverse().find(e)},Un.prototype.invokeMap=Yo((function(e,t){return"function"==typeof e?new Un(this):this.map((function(n){return Mo(n,e,t)}))})),Un.prototype.reject=function(e){return this.filter(Rs(si(e)))},Un.prototype.slice=function(e,t){e=pa(e);var n=this;return n.__filtered__&&(e>0||t<0)?new Un(n):(e<0?n=n.takeRight(-e):e&&(n=n.drop(e)),t!==r&&(n=(t=pa(t))<0?n.dropRight(-t):n.take(t-e)),n)},Un.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},Un.prototype.toArray=function(){return this.take(p)},vo(Un.prototype,(function(e,t){var n=/^(?:filter|find|map|reject)|While$/.test(t),o=/^(?:head|last)$/.test(t),i=Fn[o?"take"+("last"==t?"Right":""):t],s=o||/^find/.test(t);i&&(Fn.prototype[t]=function(){var t=this.__wrapped__,a=o?[1]:arguments,l=t instanceof Un,c=a[0],u=l||Vs(t),h=function(e){var t=i.apply(Fn,Lt([e],a));return o&&d?t[0]:t};u&&n&&"function"==typeof c&&1!=c.length&&(l=u=!1);var d=this.__chain__,p=!!this.__actions__.length,m=s&&!d,f=l&&!p;if(!s&&u){t=f?t:new Un(this);var g=e.apply(t,a);return g.__actions__.push({func:ds,args:[h],thisArg:r}),new Gn(g,d)}return m&&f?e.apply(this,a):(g=this.thru(h),m?o?g.value()[0]:g.value():g)})})),Et(["pop","push","shift","sort","splice","unshift"],(function(e){var t=Ie[e],n=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",o=/^(?:pop|shift)$/.test(e);Fn.prototype[e]=function(){var e=arguments;if(o&&!this.__chain__){var r=this.value();return t.apply(Vs(r)?r:[],e)}return this[n]((function(n){return t.apply(Vs(n)?n:[],e)}))}})),vo(Un.prototype,(function(e,t){var n=Fn[t];if(n){var o=n.name+"";Oe.call(Mn,o)||(Mn[o]=[]),Mn[o].push({name:t,func:n})}})),Mn[Fr(r,2).name]=[{name:"wrapper",func:r}],Un.prototype.clone=function(){var e=new Un(this.__wrapped__);return e.__actions__=Nr(this.__actions__),e.__dir__=this.__dir__,e.__filtered__=this.__filtered__,e.__iteratees__=Nr(this.__iteratees__),e.__takeCount__=this.__takeCount__,e.__views__=Nr(this.__views__),e},Un.prototype.reverse=function(){if(this.__filtered__){var e=new Un(this);e.__dir__=-1,e.__filtered__=!0}else(e=this.clone()).__dir__*=-1;return e},Un.prototype.value=function(){var e=this.__wrapped__.value(),t=this.__dir__,n=Vs(e),o=t<0,r=n?e.length:0,i=function(e,t,n){for(var o=-1,r=n.length;++o<r;){var i=n[o],s=i.size;switch(i.type){case"drop":e+=s;break;case"dropRight":t-=s;break;case"take":t=yn(t,e+s);break;case"takeRight":e=gn(e,t-s)}}return{start:e,end:t}}(0,r,this.__views__),s=i.start,a=i.end,l=a-s,c=o?a:s-1,u=this.__iteratees__,h=u.length,d=0,p=yn(l,this.__takeCount__);if(!n||!o&&r==l&&p==l)return dr(e,this.__actions__);var m=[];e:for(;l--&&d<p;){for(var f=-1,g=e[c+=t];++f<h;){var y=u[f],b=y.iteratee,v=y.type,C=b(g);if(2==v)g=C;else if(!C){if(1==v)continue e;break e}}m[d++]=g}return m},Fn.prototype.at=ps,Fn.prototype.chain=function(){return hs(this)},Fn.prototype.commit=function(){return new Gn(this.value(),this.__chain__)},Fn.prototype.next=function(){this.__values__===r&&(this.__values__=ha(this.value()));var e=this.__index__>=this.__values__.length;return{done:e,value:e?r:this.__values__[this.__index__++]}},Fn.prototype.plant=function(e){for(var t,n=this;n instanceof Hn;){var o=Fi(n);o.__index__=0,o.__values__=r,t?i.__wrapped__=o:t=o;var i=o;n=n.__wrapped__}return i.__wrapped__=e,t},Fn.prototype.reverse=function(){var e=this.__wrapped__;if(e instanceof Un){var t=e;return this.__actions__.length&&(t=new Un(this)),(t=t.reverse()).__actions__.push({func:ds,args:[Zi],thisArg:r}),new Gn(t,this.__chain__)}return this.thru(Zi)},Fn.prototype.toJSON=Fn.prototype.valueOf=Fn.prototype.value=function(){return dr(this.__wrapped__,this.__actions__)},Fn.prototype.first=Fn.prototype.head,Ke&&(Fn.prototype[Ke]=function(){return this}),Fn}();ht._=mn,(o=function(){return mn}.call(t,n,t,e))===r||(e.exports=o)}.call(this)},4802:e=>{e.exports=function e(t,n,o){function r(s,a){if(!n[s]){if(!t[s]){if(i)return i(s,!0);throw new Error("Cannot find module '"+s+"'")}a=n[s]={exports:{}},t[s][0].call(a.exports,(function(e){return r(t[s][1][e]||e)}),a,a.exports,e,t,n,o)}return n[s].exports}for(var i=void 0,s=0;s<o.length;s++)r(o[s]);return r}({1:[function(e,t,n){(function(o,r,i,s,a,l,c,u,h){"use strict";var d=e("crypto");function p(e,t){var n;return void 0===(n="passthrough"!==(t=g(e,t)).algorithm?d.createHash(t.algorithm):new v).write&&(n.write=n.update,n.end=n.update),b(t,n).dispatch(e),n.update||n.end(""),n.digest?n.digest("buffer"===t.encoding?void 0:t.encoding):(e=n.read(),"buffer"!==t.encoding?e.toString(t.encoding):e)}(n=t.exports=p).sha1=function(e){return p(e)},n.keys=function(e){return p(e,{excludeValues:!0,algorithm:"sha1",encoding:"hex"})},n.MD5=function(e){return p(e,{algorithm:"md5",encoding:"hex"})},n.keysMD5=function(e){return p(e,{algorithm:"md5",encoding:"hex",excludeValues:!0})};var m=d.getHashes?d.getHashes().slice():["sha1","md5"],f=(m.push("passthrough"),["buffer","hex","binary","base64"]);function g(e,t){var n={};if(n.algorithm=(t=t||{}).algorithm||"sha1",n.encoding=t.encoding||"hex",n.excludeValues=!!t.excludeValues,n.algorithm=n.algorithm.toLowerCase(),n.encoding=n.encoding.toLowerCase(),n.ignoreUnknown=!0===t.ignoreUnknown,n.respectType=!1!==t.respectType,n.respectFunctionNames=!1!==t.respectFunctionNames,n.respectFunctionProperties=!1!==t.respectFunctionProperties,n.unorderedArrays=!0===t.unorderedArrays,n.unorderedSets=!1!==t.unorderedSets,n.unorderedObjects=!1!==t.unorderedObjects,n.replacer=t.replacer||void 0,n.excludeKeys=t.excludeKeys||void 0,void 0===e)throw new Error("Object argument required.");for(var o=0;o<m.length;++o)m[o].toLowerCase()===n.algorithm.toLowerCase()&&(n.algorithm=m[o]);if(-1===m.indexOf(n.algorithm))throw new Error('Algorithm "'+n.algorithm+'" not supported. supported values: '+m.join(", "));if(-1===f.indexOf(n.encoding)&&"passthrough"!==n.algorithm)throw new Error('Encoding "'+n.encoding+'" not supported. supported values: '+f.join(", "));return n}function y(e){if("function"==typeof e)return null!=/^function\s+\w*\s*\(\s*\)\s*{\s+\[native code\]\s+}$/i.exec(Function.prototype.toString.call(e))}function b(e,t,n){function o(e){return t.update?t.update(e,"utf8"):t.write(e,"utf8")}return n=n||[],{dispatch:function(t){return this["_"+(null===(t=e.replacer?e.replacer(t):t)?"null":typeof t)](t)},_object:function(t){var r,s=Object.prototype.toString.call(t),a=/\[object (.*)\]/i.exec(s);if(a=(a=a?a[1]:"unknown:["+s+"]").toLowerCase(),0<=(s=n.indexOf(t)))return this.dispatch("[CIRCULAR:"+s+"]");if(n.push(t),void 0!==i&&i.isBuffer&&i.isBuffer(t))return o("buffer:"),o(t);if("object"===a||"function"===a||"asyncfunction"===a)return s=Object.keys(t),e.unorderedObjects&&(s=s.sort()),!1===e.respectType||y(t)||s.splice(0,0,"prototype","__proto__","constructor"),e.excludeKeys&&(s=s.filter((function(t){return!e.excludeKeys(t)}))),o("object:"+s.length+":"),r=this,s.forEach((function(n){r.dispatch(n),o(":"),e.excludeValues||r.dispatch(t[n]),o(",")}));if(!this["_"+a]){if(e.ignoreUnknown)return o("["+a+"]");throw new Error('Unknown object type "'+a+'"')}this["_"+a](t)},_array:function(t,r){r=void 0!==r?r:!1!==e.unorderedArrays;var i=this;if(o("array:"+t.length+":"),!r||t.length<=1)return t.forEach((function(e){return i.dispatch(e)}));var s=[];return r=t.map((function(t){var o=new v,r=n.slice();return b(e,o,r).dispatch(t),s=s.concat(r.slice(n.length)),o.read().toString()})),n=n.concat(s),r.sort(),this._array(r,!1)},_date:function(e){return o("date:"+e.toJSON())},_symbol:function(e){return o("symbol:"+e.toString())},_error:function(e){return o("error:"+e.toString())},_boolean:function(e){return o("bool:"+e.toString())},_string:function(e){o("string:"+e.length+":"),o(e.toString())},_function:function(t){o("fn:"),y(t)?this.dispatch("[native]"):this.dispatch(t.toString()),!1!==e.respectFunctionNames&&this.dispatch("function-name:"+String(t.name)),e.respectFunctionProperties&&this._object(t)},_number:function(e){return o("number:"+e.toString())},_xml:function(e){return o("xml:"+e.toString())},_null:function(){return o("Null")},_undefined:function(){return o("Undefined")},_regexp:function(e){return o("regex:"+e.toString())},_uint8array:function(e){return o("uint8array:"),this.dispatch(Array.prototype.slice.call(e))},_uint8clampedarray:function(e){return o("uint8clampedarray:"),this.dispatch(Array.prototype.slice.call(e))},_int8array:function(e){return o("int8array:"),this.dispatch(Array.prototype.slice.call(e))},_uint16array:function(e){return o("uint16array:"),this.dispatch(Array.prototype.slice.call(e))},_int16array:function(e){return o("int16array:"),this.dispatch(Array.prototype.slice.call(e))},_uint32array:function(e){return o("uint32array:"),this.dispatch(Array.prototype.slice.call(e))},_int32array:function(e){return o("int32array:"),this.dispatch(Array.prototype.slice.call(e))},_float32array:function(e){return o("float32array:"),this.dispatch(Array.prototype.slice.call(e))},_float64array:function(e){return o("float64array:"),this.dispatch(Array.prototype.slice.call(e))},_arraybuffer:function(e){return o("arraybuffer:"),this.dispatch(new Uint8Array(e))},_url:function(e){return o("url:"+e.toString())},_map:function(t){return o("map:"),t=Array.from(t),this._array(t,!1!==e.unorderedSets)},_set:function(t){return o("set:"),t=Array.from(t),this._array(t,!1!==e.unorderedSets)},_file:function(e){return o("file:"),this.dispatch([e.name,e.size,e.type,e.lastModfied])},_blob:function(){if(e.ignoreUnknown)return o("[blob]");throw Error('Hashing Blob objects is currently not supported\n(see https://github.com/puleos/object-hash/issues/26)\nUse "options.replacer" or "options.ignoreUnknown"\n')},_domwindow:function(){return o("domwindow")},_bigint:function(e){return o("bigint:"+e.toString())},_process:function(){return o("process")},_timer:function(){return o("timer")},_pipe:function(){return o("pipe")},_tcp:function(){return o("tcp")},_udp:function(){return o("udp")},_tty:function(){return o("tty")},_statwatcher:function(){return o("statwatcher")},_securecontext:function(){return o("securecontext")},_connection:function(){return o("connection")},_zlib:function(){return o("zlib")},_context:function(){return o("context")},_nodescript:function(){return o("nodescript")},_httpparser:function(){return o("httpparser")},_dataview:function(){return o("dataview")},_signal:function(){return o("signal")},_fsevent:function(){return o("fsevent")},_tlswrap:function(){return o("tlswrap")}}}function v(){return{buf:"",write:function(e){this.buf+=e},end:function(e){this.buf+=e},read:function(){return this.buf}}}n.writeToStream=function(e,t,n){return void 0===n&&(n=t,t={}),b(t=g(e,t),n).dispatch(e)}}).call(this,e("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/fake_9a5aa49d.js","/")},{buffer:3,crypto:5,lYpoI2:11}],2:[function(e,t,n){(function(e,t,o,r,i,s,a,l,c){!function(e){"use strict";var t="undefined"!=typeof Uint8Array?Uint8Array:Array,n="+".charCodeAt(0),o="/".charCodeAt(0),r="0".charCodeAt(0),i="a".charCodeAt(0),s="A".charCodeAt(0),a="-".charCodeAt(0),l="_".charCodeAt(0);function c(e){return(e=e.charCodeAt(0))===n||e===a?62:e===o||e===l?63:e<r?-1:e<r+10?e-r+26+26:e<s+26?e-s:e<i+26?e-i+26:void 0}e.toByteArray=function(e){var n,o;if(0<e.length%4)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.length,i=(r="="===e.charAt(r-2)?2:"="===e.charAt(r-1)?1:0,new t(3*e.length/4-r)),s=0<r?e.length-4:e.length,a=0;function l(e){i[a++]=e}for(n=0;n<s;n+=4,0)l((16711680&(o=c(e.charAt(n))<<18|c(e.charAt(n+1))<<12|c(e.charAt(n+2))<<6|c(e.charAt(n+3))))>>16),l((65280&o)>>8),l(255&o);return 2==r?l(255&(o=c(e.charAt(n))<<2|c(e.charAt(n+1))>>4)):1==r&&(l((o=c(e.charAt(n))<<10|c(e.charAt(n+1))<<4|c(e.charAt(n+2))>>2)>>8&255),l(255&o)),i},e.fromByteArray=function(e){var t,n,o,r,i=e.length%3,s="";function a(e){return"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(e)}for(t=0,o=e.length-i;t<o;t+=3)s+=a((r=n=(e[t]<<16)+(e[t+1]<<8)+e[t+2])>>18&63)+a(r>>12&63)+a(r>>6&63)+a(63&r);switch(i){case 1:s=(s+=a((n=e[e.length-1])>>2))+a(n<<4&63)+"==";break;case 2:s=(s=(s+=a((n=(e[e.length-2]<<8)+e[e.length-1])>>10))+a(n>>4&63))+a(n<<2&63)+"="}return s}}(void 0===n?this.base64js={}:n)}).call(this,e("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/base64-js/lib/b64.js","/node_modules/gulp-browserify/node_modules/base64-js/lib")},{buffer:3,lYpoI2:11}],3:[function(e,t,n){(function(t,o,r,i,s,a,l,c,u){var h=e("base64-js"),d=e("ieee754");function r(e,t,n){if(!(this instanceof r))return new r(e,t,n);var o,i,s,a,l=typeof e;if("base64"===t&&"string"==l)for(e=(a=e).trim?a.trim():a.replace(/^\s+|\s+$/g,"");e.length%4!=0;)e+="=";if("number"==l)o=N(e);else if("string"==l)o=r.byteLength(e,t);else{if("object"!=l)throw new Error("First argument needs to be a number, array or string.");o=N(e.length)}if(r._useTypedArrays?i=r._augment(new Uint8Array(o)):((i=this).length=o,i._isBuffer=!0),r._useTypedArrays&&"number"==typeof e.byteLength)i._set(e);else if(I(a=e)||r.isBuffer(a)||a&&"object"==typeof a&&"number"==typeof a.length)for(s=0;s<o;s++)r.isBuffer(e)?i[s]=e.readUInt8(s):i[s]=e[s];else if("string"==l)i.write(e,0,t);else if("number"==l&&!r._useTypedArrays&&!n)for(s=0;s<o;s++)i[s]=0;return i}function p(e,t,n,o){var r;if(o||(B("boolean"==typeof n,"missing or invalid endian"),B(null!=t,"missing offset"),B(t+1<e.length,"Trying to read beyond buffer length")),!((o=e.length)<=t))return n?(r=e[t],t+1<o&&(r|=e[t+1]<<8)):(r=e[t]<<8,t+1<o&&(r|=e[t+1])),r}function m(e,t,n,o){var r;if(o||(B("boolean"==typeof n,"missing or invalid endian"),B(null!=t,"missing offset"),B(t+3<e.length,"Trying to read beyond buffer length")),!((o=e.length)<=t))return n?(t+2<o&&(r=e[t+2]<<16),t+1<o&&(r|=e[t+1]<<8),r|=e[t],t+3<o&&(r+=e[t+3]<<24>>>0)):(t+1<o&&(r=e[t+1]<<16),t+2<o&&(r|=e[t+2]<<8),t+3<o&&(r|=e[t+3]),r+=e[t]<<24>>>0),r}function f(e,t,n,o){if(o||(B("boolean"==typeof n,"missing or invalid endian"),B(null!=t,"missing offset"),B(t+1<e.length,"Trying to read beyond buffer length")),!(e.length<=t))return 32768&(o=p(e,t,n,!0))?-1*(65535-o+1):o}function g(e,t,n,o){if(o||(B("boolean"==typeof n,"missing or invalid endian"),B(null!=t,"missing offset"),B(t+3<e.length,"Trying to read beyond buffer length")),!(e.length<=t))return 2147483648&(o=m(e,t,n,!0))?-1*(4294967295-o+1):o}function y(e,t,n,o){return o||(B("boolean"==typeof n,"missing or invalid endian"),B(t+3<e.length,"Trying to read beyond buffer length")),d.read(e,t,n,23,4)}function b(e,t,n,o){return o||(B("boolean"==typeof n,"missing or invalid endian"),B(t+7<e.length,"Trying to read beyond buffer length")),d.read(e,t,n,52,8)}function v(e,t,n,o,r){if(r||(B(null!=t,"missing value"),B("boolean"==typeof o,"missing or invalid endian"),B(null!=n,"missing offset"),B(n+1<e.length,"trying to write beyond buffer length"),R(t,65535)),!((r=e.length)<=n))for(var i=0,s=Math.min(r-n,2);i<s;i++)e[n+i]=(t&255<<8*(o?i:1-i))>>>8*(o?i:1-i)}function C(e,t,n,o,r){if(r||(B(null!=t,"missing value"),B("boolean"==typeof o,"missing or invalid endian"),B(null!=n,"missing offset"),B(n+3<e.length,"trying to write beyond buffer length"),R(t,4294967295)),!((r=e.length)<=n))for(var i=0,s=Math.min(r-n,4);i<s;i++)e[n+i]=t>>>8*(o?i:3-i)&255}function x(e,t,n,o,r){r||(B(null!=t,"missing value"),B("boolean"==typeof o,"missing or invalid endian"),B(null!=n,"missing offset"),B(n+1<e.length,"Trying to write beyond buffer length"),$(t,32767,-32768)),e.length<=n||v(e,0<=t?t:65535+t+1,n,o,r)}function w(e,t,n,o,r){r||(B(null!=t,"missing value"),B("boolean"==typeof o,"missing or invalid endian"),B(null!=n,"missing offset"),B(n+3<e.length,"Trying to write beyond buffer length"),$(t,2147483647,-2147483648)),e.length<=n||C(e,0<=t?t:4294967295+t+1,n,o,r)}function A(e,t,n,o,r){r||(B(null!=t,"missing value"),B("boolean"==typeof o,"missing or invalid endian"),B(null!=n,"missing offset"),B(n+3<e.length,"Trying to write beyond buffer length"),D(t,34028234663852886e22,-34028234663852886e22)),e.length<=n||d.write(e,t,n,o,23,4)}function T(e,t,n,o,r){r||(B(null!=t,"missing value"),B("boolean"==typeof o,"missing or invalid endian"),B(null!=n,"missing offset"),B(n+7<e.length,"Trying to write beyond buffer length"),D(t,17976931348623157e292,-17976931348623157e292)),e.length<=n||d.write(e,t,n,o,52,8)}n.Buffer=r,n.SlowBuffer=r,n.INSPECT_MAX_BYTES=50,r.poolSize=8192,r._useTypedArrays=function(){try{var e=new ArrayBuffer(0),t=new Uint8Array(e);return t.foo=function(){return 42},42===t.foo()&&"function"==typeof t.subarray}catch(e){return!1}}(),r.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},r.isBuffer=function(e){return!(null==e||!e._isBuffer)},r.byteLength=function(e,t){var n;switch(e+="",t||"utf8"){case"hex":n=e.length/2;break;case"utf8":case"utf-8":n=P(e).length;break;case"ascii":case"binary":case"raw":n=e.length;break;case"base64":n=_(e).length;break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":n=2*e.length;break;default:throw new Error("Unknown encoding")}return n},r.concat=function(e,t){if(B(I(e),"Usage: Buffer.concat(list, [totalLength])\nlist should be an Array."),0===e.length)return new r(0);if(1===e.length)return e[0];if("number"!=typeof t)for(i=t=0;i<e.length;i++)t+=e[i].length;for(var n=new r(t),o=0,i=0;i<e.length;i++){var s=e[i];s.copy(n,o),o+=s.length}return n},r.prototype.write=function(e,t,n,o){isFinite(t)?isFinite(n)||(o=n,n=void 0):(c=o,o=t,t=n,n=c),t=Number(t)||0;var i,s,a,l,c=this.length-t;switch((!n||c<(n=Number(n)))&&(n=c),o=String(o||"utf8").toLowerCase()){case"hex":i=function(e,t,n,o){n=Number(n)||0;var i=e.length-n;(!o||i<(o=Number(o)))&&(o=i),B((i=t.length)%2==0,"Invalid hex string"),i/2<o&&(o=i/2);for(var s=0;s<o;s++){var a=parseInt(t.substr(2*s,2),16);B(!isNaN(a),"Invalid hex string"),e[n+s]=a}return r._charsWritten=2*s,s}(this,e,t,n);break;case"utf8":case"utf-8":s=this,a=t,l=n,i=r._charsWritten=L(P(e),s,a,l);break;case"ascii":case"binary":i=function(e,t,n,o){return r._charsWritten=L(function(e){for(var t=[],n=0;n<e.length;n++)t.push(255&e.charCodeAt(n));return t}(t),e,n,o)}(this,e,t,n);break;case"base64":s=this,a=t,l=n,i=r._charsWritten=L(_(e),s,a,l);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":i=function(e,t,n,o){return r._charsWritten=L(function(e){for(var t,n,o=[],r=0;r<e.length;r++)t=(n=e.charCodeAt(r))>>8,n%=256,o.push(n),o.push(t);return o}(t),e,n,o)}(this,e,t,n);break;default:throw new Error("Unknown encoding")}return i},r.prototype.toString=function(e,t,n){var o,r,i,s,a=this;if(e=String(e||"utf8").toLowerCase(),t=Number(t)||0,(n=void 0!==n?Number(n):a.length)===t)return"";switch(e){case"hex":o=function(e,t,n){var o=e.length;(!t||t<0)&&(t=0),(!n||n<0||o<n)&&(n=o);for(var r="",i=t;i<n;i++)r+=M(e[i]);return r}(a,t,n);break;case"utf8":case"utf-8":o=function(e,t,n){var o="",r="";n=Math.min(e.length,n);for(var i=t;i<n;i++)e[i]<=127?(o+=O(r)+String.fromCharCode(e[i]),r=""):r+="%"+e[i].toString(16);return o+O(r)}(a,t,n);break;case"ascii":case"binary":o=function(e,t,n){var o="";n=Math.min(e.length,n);for(var r=t;r<n;r++)o+=String.fromCharCode(e[r]);return o}(a,t,n);break;case"base64":r=a,s=n,o=0===(i=t)&&s===r.length?h.fromByteArray(r):h.fromByteArray(r.slice(i,s));break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":o=function(e,t,n){for(var o=e.slice(t,n),r="",i=0;i<o.length;i+=2)r+=String.fromCharCode(o[i]+256*o[i+1]);return r}(a,t,n);break;default:throw new Error("Unknown encoding")}return o},r.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},r.prototype.copy=function(e,t,n,o){if(t=t||0,(o=o||0===o?o:this.length)!==(n=n||0)&&0!==e.length&&0!==this.length){B(n<=o,"sourceEnd < sourceStart"),B(0<=t&&t<e.length,"targetStart out of bounds"),B(0<=n&&n<this.length,"sourceStart out of bounds"),B(0<=o&&o<=this.length,"sourceEnd out of bounds"),o>this.length&&(o=this.length);var i=(o=e.length-t<o-n?e.length-t+n:o)-n;if(i<100||!r._useTypedArrays)for(var s=0;s<i;s++)e[s+t]=this[s+n];else e._set(this.subarray(n,n+i),t)}},r.prototype.slice=function(e,t){var n=this.length;if(e=S(e,n,0),t=S(t,n,n),r._useTypedArrays)return r._augment(this.subarray(e,t));for(var o=t-e,i=new r(o,void 0,!0),s=0;s<o;s++)i[s]=this[s+e];return i},r.prototype.get=function(e){return console.log(".get() is deprecated. Access using array indexes instead."),this.readUInt8(e)},r.prototype.set=function(e,t){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(e,t)},r.prototype.readUInt8=function(e,t){if(t||(B(null!=e,"missing offset"),B(e<this.length,"Trying to read beyond buffer length")),!(e>=this.length))return this[e]},r.prototype.readUInt16LE=function(e,t){return p(this,e,!0,t)},r.prototype.readUInt16BE=function(e,t){return p(this,e,!1,t)},r.prototype.readUInt32LE=function(e,t){return m(this,e,!0,t)},r.prototype.readUInt32BE=function(e,t){return m(this,e,!1,t)},r.prototype.readInt8=function(e,t){if(t||(B(null!=e,"missing offset"),B(e<this.length,"Trying to read beyond buffer length")),!(e>=this.length))return 128&this[e]?-1*(255-this[e]+1):this[e]},r.prototype.readInt16LE=function(e,t){return f(this,e,!0,t)},r.prototype.readInt16BE=function(e,t){return f(this,e,!1,t)},r.prototype.readInt32LE=function(e,t){return g(this,e,!0,t)},r.prototype.readInt32BE=function(e,t){return g(this,e,!1,t)},r.prototype.readFloatLE=function(e,t){return y(this,e,!0,t)},r.prototype.readFloatBE=function(e,t){return y(this,e,!1,t)},r.prototype.readDoubleLE=function(e,t){return b(this,e,!0,t)},r.prototype.readDoubleBE=function(e,t){return b(this,e,!1,t)},r.prototype.writeUInt8=function(e,t,n){n||(B(null!=e,"missing value"),B(null!=t,"missing offset"),B(t<this.length,"trying to write beyond buffer length"),R(e,255)),t>=this.length||(this[t]=e)},r.prototype.writeUInt16LE=function(e,t,n){v(this,e,t,!0,n)},r.prototype.writeUInt16BE=function(e,t,n){v(this,e,t,!1,n)},r.prototype.writeUInt32LE=function(e,t,n){C(this,e,t,!0,n)},r.prototype.writeUInt32BE=function(e,t,n){C(this,e,t,!1,n)},r.prototype.writeInt8=function(e,t,n){n||(B(null!=e,"missing value"),B(null!=t,"missing offset"),B(t<this.length,"Trying to write beyond buffer length"),$(e,127,-128)),t>=this.length||(0<=e?this.writeUInt8(e,t,n):this.writeUInt8(255+e+1,t,n))},r.prototype.writeInt16LE=function(e,t,n){x(this,e,t,!0,n)},r.prototype.writeInt16BE=function(e,t,n){x(this,e,t,!1,n)},r.prototype.writeInt32LE=function(e,t,n){w(this,e,t,!0,n)},r.prototype.writeInt32BE=function(e,t,n){w(this,e,t,!1,n)},r.prototype.writeFloatLE=function(e,t,n){A(this,e,t,!0,n)},r.prototype.writeFloatBE=function(e,t,n){A(this,e,t,!1,n)},r.prototype.writeDoubleLE=function(e,t,n){T(this,e,t,!0,n)},r.prototype.writeDoubleBE=function(e,t,n){T(this,e,t,!1,n)},r.prototype.fill=function(e,t,n){if(t=t||0,n=n||this.length,B("number"==typeof(e="string"==typeof(e=e||0)?e.charCodeAt(0):e)&&!isNaN(e),"value is not a number"),B(t<=n,"end < start"),n!==t&&0!==this.length){B(0<=t&&t<this.length,"start out of bounds"),B(0<=n&&n<=this.length,"end out of bounds");for(var o=t;o<n;o++)this[o]=e}},r.prototype.inspect=function(){for(var e=[],t=this.length,o=0;o<t;o++)if(e[o]=M(this[o]),o===n.INSPECT_MAX_BYTES){e[o+1]="...";break}return"<Buffer "+e.join(" ")+">"},r.prototype.toArrayBuffer=function(){if("undefined"==typeof Uint8Array)throw new Error("Buffer.toArrayBuffer not supported in this browser");if(r._useTypedArrays)return new r(this).buffer;for(var e=new Uint8Array(this.length),t=0,n=e.length;t<n;t+=1)e[t]=this[t];return e.buffer};var E=r.prototype;function S(e,t,n){return"number"!=typeof e?n:t<=(e=~~e)?t:0<=e||0<=(e+=t)?e:0}function N(e){return(e=~~Math.ceil(+e))<0?0:e}function I(e){return(Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)})(e)}function M(e){return e<16?"0"+e.toString(16):e.toString(16)}function P(e){for(var t=[],n=0;n<e.length;n++){var o=e.charCodeAt(n);if(o<=127)t.push(e.charCodeAt(n));else for(var r=n,i=(55296<=o&&o<=57343&&n++,encodeURIComponent(e.slice(r,n+1)).substr(1).split("%")),s=0;s<i.length;s++)t.push(parseInt(i[s],16))}return t}function _(e){return h.toByteArray(e)}function L(e,t,n,o){for(var r=0;r<o&&!(r+n>=t.length||r>=e.length);r++)t[r+n]=e[r];return r}function O(e){try{return decodeURIComponent(e)}catch(e){return String.fromCharCode(65533)}}function R(e,t){B("number"==typeof e,"cannot write a non-number as a number"),B(0<=e,"specified a negative value for writing an unsigned value"),B(e<=t,"value is larger than maximum value for type"),B(Math.floor(e)===e,"value has a fractional component")}function $(e,t,n){B("number"==typeof e,"cannot write a non-number as a number"),B(e<=t,"value larger than maximum allowed value"),B(n<=e,"value smaller than minimum allowed value"),B(Math.floor(e)===e,"value has a fractional component")}function D(e,t,n){B("number"==typeof e,"cannot write a non-number as a number"),B(e<=t,"value larger than maximum allowed value"),B(n<=e,"value smaller than minimum allowed value")}function B(e,t){if(!e)throw new Error(t||"Failed assertion")}r._augment=function(e){return e._isBuffer=!0,e._get=e.get,e._set=e.set,e.get=E.get,e.set=E.set,e.write=E.write,e.toString=E.toString,e.toLocaleString=E.toString,e.toJSON=E.toJSON,e.copy=E.copy,e.slice=E.slice,e.readUInt8=E.readUInt8,e.readUInt16LE=E.readUInt16LE,e.readUInt16BE=E.readUInt16BE,e.readUInt32LE=E.readUInt32LE,e.readUInt32BE=E.readUInt32BE,e.readInt8=E.readInt8,e.readInt16LE=E.readInt16LE,e.readInt16BE=E.readInt16BE,e.readInt32LE=E.readInt32LE,e.readInt32BE=E.readInt32BE,e.readFloatLE=E.readFloatLE,e.readFloatBE=E.readFloatBE,e.readDoubleLE=E.readDoubleLE,e.readDoubleBE=E.readDoubleBE,e.writeUInt8=E.writeUInt8,e.writeUInt16LE=E.writeUInt16LE,e.writeUInt16BE=E.writeUInt16BE,e.writeUInt32LE=E.writeUInt32LE,e.writeUInt32BE=E.writeUInt32BE,e.writeInt8=E.writeInt8,e.writeInt16LE=E.writeInt16LE,e.writeInt16BE=E.writeInt16BE,e.writeInt32LE=E.writeInt32LE,e.writeInt32BE=E.writeInt32BE,e.writeFloatLE=E.writeFloatLE,e.writeFloatBE=E.writeFloatBE,e.writeDoubleLE=E.writeDoubleLE,e.writeDoubleBE=E.writeDoubleBE,e.fill=E.fill,e.inspect=E.inspect,e.toArrayBuffer=E.toArrayBuffer,e}}).call(this,e("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/buffer/index.js","/node_modules/gulp-browserify/node_modules/buffer")},{"base64-js":2,buffer:3,ieee754:10,lYpoI2:11}],4:[function(e,t,n){(function(n,o,r,i,s,a,l,c,u){r=e("buffer").Buffer;var h=new r(4);h.fill(0),t.exports={hash:function(e,t,n,o){for(var i=t(function(e,t){e.length%4!=0&&(n=e.length+(4-e.length%4),e=r.concat([e,h],n));for(var n,o=[],i=t?e.readInt32BE:e.readInt32LE,s=0;s<e.length;s+=4)o.push(i.call(e,s));return o}(e=r.isBuffer(e)?e:new r(e),o),8*e.length),s=(t=o,new r(n)),a=t?s.writeInt32BE:s.writeInt32LE,l=0;l<i.length;l++)a.call(s,i[l],4*l,!0);return s}}}).call(this,e("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/helpers.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{buffer:3,lYpoI2:11}],5:[function(e,t,n){(function(t,o,r,i,s,a,l,c,u){r=e("buffer").Buffer;var h=e("./sha"),d=e("./sha256"),p=e("./rng"),m={sha1:h,sha256:d,md5:e("./md5")},f=64,g=new r(f);function y(e,t){var n=m[e=e||"sha1"],o=[];return n||b("algorithm:",e,"is not yet supported"),{update:function(e){return r.isBuffer(e)||(e=new r(e)),o.push(e),e.length,this},digest:function(e){var i=r.concat(o);return i=t?function(e,t,n){r.isBuffer(t)||(t=new r(t)),r.isBuffer(n)||(n=new r(n)),t.length>f?t=e(t):t.length<f&&(t=r.concat([t,g],f));for(var o=new r(f),i=new r(f),s=0;s<f;s++)o[s]=54^t[s],i[s]=92^t[s];return n=e(r.concat([o,n])),e(r.concat([i,n]))}(n,t,i):n(i),o=null,e?i.toString(e):i}}}function b(){var e=[].slice.call(arguments).join(" ");throw new Error([e,"we accept pull requests","http://github.com/dominictarr/crypto-browserify"].join("\n"))}g.fill(0),n.createHash=function(e){return y(e)},n.createHmac=y,n.randomBytes=function(e,t){if(!t||!t.call)return new r(p(e));try{t.call(this,void 0,new r(p(e)))}catch(e){t(e)}};var v,C=["createCredentials","createCipher","createCipheriv","createDecipher","createDecipheriv","createSign","createVerify","createDiffieHellman","pbkdf2"],x=function(e){n[e]=function(){b("sorry,",e,"is not implemented yet")}};for(v in C)x(C[v])}).call(this,e("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/index.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{"./md5":6,"./rng":7,"./sha":8,"./sha256":9,buffer:3,lYpoI2:11}],6:[function(e,t,n){(function(n,o,r,i,s,a,l,c,u){var h=e("./helpers");function d(e,t){e[t>>5]|=128<<t%32,e[14+(t+64>>>9<<4)]=t;for(var n=1732584193,o=-271733879,r=-1732584194,i=271733878,s=0;s<e.length;s+=16){var a=n,l=o,c=r,u=i;n=m(n,o,r,i,e[s+0],7,-680876936),i=m(i,n,o,r,e[s+1],12,-389564586),r=m(r,i,n,o,e[s+2],17,606105819),o=m(o,r,i,n,e[s+3],22,-1044525330),n=m(n,o,r,i,e[s+4],7,-176418897),i=m(i,n,o,r,e[s+5],12,1200080426),r=m(r,i,n,o,e[s+6],17,-1473231341),o=m(o,r,i,n,e[s+7],22,-45705983),n=m(n,o,r,i,e[s+8],7,1770035416),i=m(i,n,o,r,e[s+9],12,-1958414417),r=m(r,i,n,o,e[s+10],17,-42063),o=m(o,r,i,n,e[s+11],22,-1990404162),n=m(n,o,r,i,e[s+12],7,1804603682),i=m(i,n,o,r,e[s+13],12,-40341101),r=m(r,i,n,o,e[s+14],17,-1502002290),n=f(n,o=m(o,r,i,n,e[s+15],22,1236535329),r,i,e[s+1],5,-165796510),i=f(i,n,o,r,e[s+6],9,-1069501632),r=f(r,i,n,o,e[s+11],14,643717713),o=f(o,r,i,n,e[s+0],20,-373897302),n=f(n,o,r,i,e[s+5],5,-701558691),i=f(i,n,o,r,e[s+10],9,38016083),r=f(r,i,n,o,e[s+15],14,-660478335),o=f(o,r,i,n,e[s+4],20,-405537848),n=f(n,o,r,i,e[s+9],5,568446438),i=f(i,n,o,r,e[s+14],9,-1019803690),r=f(r,i,n,o,e[s+3],14,-187363961),o=f(o,r,i,n,e[s+8],20,1163531501),n=f(n,o,r,i,e[s+13],5,-1444681467),i=f(i,n,o,r,e[s+2],9,-51403784),r=f(r,i,n,o,e[s+7],14,1735328473),n=g(n,o=f(o,r,i,n,e[s+12],20,-1926607734),r,i,e[s+5],4,-378558),i=g(i,n,o,r,e[s+8],11,-2022574463),r=g(r,i,n,o,e[s+11],16,1839030562),o=g(o,r,i,n,e[s+14],23,-35309556),n=g(n,o,r,i,e[s+1],4,-1530992060),i=g(i,n,o,r,e[s+4],11,1272893353),r=g(r,i,n,o,e[s+7],16,-155497632),o=g(o,r,i,n,e[s+10],23,-1094730640),n=g(n,o,r,i,e[s+13],4,681279174),i=g(i,n,o,r,e[s+0],11,-358537222),r=g(r,i,n,o,e[s+3],16,-722521979),o=g(o,r,i,n,e[s+6],23,76029189),n=g(n,o,r,i,e[s+9],4,-640364487),i=g(i,n,o,r,e[s+12],11,-421815835),r=g(r,i,n,o,e[s+15],16,530742520),n=y(n,o=g(o,r,i,n,e[s+2],23,-995338651),r,i,e[s+0],6,-198630844),i=y(i,n,o,r,e[s+7],10,1126891415),r=y(r,i,n,o,e[s+14],15,-1416354905),o=y(o,r,i,n,e[s+5],21,-57434055),n=y(n,o,r,i,e[s+12],6,1700485571),i=y(i,n,o,r,e[s+3],10,-1894986606),r=y(r,i,n,o,e[s+10],15,-1051523),o=y(o,r,i,n,e[s+1],21,-2054922799),n=y(n,o,r,i,e[s+8],6,1873313359),i=y(i,n,o,r,e[s+15],10,-30611744),r=y(r,i,n,o,e[s+6],15,-1560198380),o=y(o,r,i,n,e[s+13],21,1309151649),n=y(n,o,r,i,e[s+4],6,-145523070),i=y(i,n,o,r,e[s+11],10,-1120210379),r=y(r,i,n,o,e[s+2],15,718787259),o=y(o,r,i,n,e[s+9],21,-343485551),n=b(n,a),o=b(o,l),r=b(r,c),i=b(i,u)}return Array(n,o,r,i)}function p(e,t,n,o,r,i){return b((t=b(b(t,e),b(o,i)))<<r|t>>>32-r,n)}function m(e,t,n,o,r,i,s){return p(t&n|~t&o,e,t,r,i,s)}function f(e,t,n,o,r,i,s){return p(t&o|n&~o,e,t,r,i,s)}function g(e,t,n,o,r,i,s){return p(t^n^o,e,t,r,i,s)}function y(e,t,n,o,r,i,s){return p(n^(t|~o),e,t,r,i,s)}function b(e,t){var n=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(n>>16)<<16|65535&n}t.exports=function(e){return h.hash(e,d,16)}}).call(this,e("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/md5.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{"./helpers":4,buffer:3,lYpoI2:11}],7:[function(e,t,n){(function(e,n,o,r,i,s,a,l,c){t.exports=function(e){for(var t,n=new Array(e),o=0;o<e;o++)!(3&o)&&(t=4294967296*Math.random()),n[o]=t>>>((3&o)<<3)&255;return n}}).call(this,e("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/rng.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{buffer:3,lYpoI2:11}],8:[function(e,t,n){(function(n,o,r,i,s,a,l,c,u){var h=e("./helpers");function d(e,t){e[t>>5]|=128<<24-t%32,e[15+(t+64>>9<<4)]=t;for(var n,o,r,i=Array(80),s=1732584193,a=-271733879,l=-1732584194,c=271733878,u=-1009589776,h=0;h<e.length;h+=16){for(var d=s,f=a,g=l,y=c,b=u,v=0;v<80;v++){i[v]=v<16?e[h+v]:m(i[v-3]^i[v-8]^i[v-14]^i[v-16],1);var C=p(p(m(s,5),(C=a,o=l,r=c,(n=v)<20?C&o|~C&r:!(n<40)&&n<60?C&o|C&r|o&r:C^o^r)),p(p(u,i[v]),(n=v)<20?1518500249:n<40?1859775393:n<60?-1894007588:-899497514));u=c,c=l,l=m(a,30),a=s,s=C}s=p(s,d),a=p(a,f),l=p(l,g),c=p(c,y),u=p(u,b)}return Array(s,a,l,c,u)}function p(e,t){var n=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(n>>16)<<16|65535&n}function m(e,t){return e<<t|e>>>32-t}t.exports=function(e){return h.hash(e,d,20,!0)}}).call(this,e("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/sha.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{"./helpers":4,buffer:3,lYpoI2:11}],9:[function(e,t,n){(function(n,o,r,i,s,a,l,c,u){function h(e,t){var n=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(n>>16)<<16|65535&n}function d(e,t){var n,o=new Array(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),r=new Array(1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225),i=new Array(64);e[t>>5]|=128<<24-t%32,e[15+(t+64>>9<<4)]=t;for(var s,a,l=0;l<e.length;l+=16){for(var c=r[0],u=r[1],d=r[2],p=r[3],g=r[4],y=r[5],b=r[6],v=r[7],C=0;C<64;C++)i[C]=C<16?e[C+l]:h(h(h((a=i[C-2],m(a,17)^m(a,19)^f(a,10)),i[C-7]),(a=i[C-15],m(a,7)^m(a,18)^f(a,3))),i[C-16]),n=h(h(h(h(v,m(a=g,6)^m(a,11)^m(a,25)),g&y^~g&b),o[C]),i[C]),s=h(m(s=c,2)^m(s,13)^m(s,22),c&u^c&d^u&d),v=b,b=y,y=g,g=h(p,n),p=d,d=u,u=c,c=h(n,s);r[0]=h(c,r[0]),r[1]=h(u,r[1]),r[2]=h(d,r[2]),r[3]=h(p,r[3]),r[4]=h(g,r[4]),r[5]=h(y,r[5]),r[6]=h(b,r[6]),r[7]=h(v,r[7])}return r}var p=e("./helpers"),m=function(e,t){return e>>>t|e<<32-t},f=function(e,t){return e>>>t};t.exports=function(e){return p.hash(e,d,32,!0)}}).call(this,e("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/sha256.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{"./helpers":4,buffer:3,lYpoI2:11}],10:[function(e,t,n){(function(e,t,o,r,i,s,a,l,c){n.read=function(e,t,n,o,r){var i,s,a=8*r-o-1,l=(1<<a)-1,c=l>>1,u=-7,h=n?r-1:0,d=n?-1:1;for(r=e[t+h],h+=d,i=r&(1<<-u)-1,r>>=-u,u+=a;0<u;i=256*i+e[t+h],h+=d,u-=8);for(s=i&(1<<-u)-1,i>>=-u,u+=o;0<u;s=256*s+e[t+h],h+=d,u-=8);if(0===i)i=1-c;else{if(i===l)return s?NaN:1/0*(r?-1:1);s+=Math.pow(2,o),i-=c}return(r?-1:1)*s*Math.pow(2,i-o)},n.write=function(e,t,n,o,r,i){var s,a,l=8*i-r-1,c=(1<<l)-1,u=c>>1,h=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,d=o?0:i-1,p=o?1:-1;for(i=t<0||0===t&&1/t<0?1:0,t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=c):(s=Math.floor(Math.log(t)/Math.LN2),t*(o=Math.pow(2,-s))<1&&(s--,o*=2),2<=(t+=1<=s+u?h/o:h*Math.pow(2,1-u))*o&&(s++,o/=2),c<=s+u?(a=0,s=c):1<=s+u?(a=(t*o-1)*Math.pow(2,r),s+=u):(a=t*Math.pow(2,u-1)*Math.pow(2,r),s=0));8<=r;e[n+d]=255&a,d+=p,a/=256,r-=8);for(s=s<<r|a,l+=r;0<l;e[n+d]=255&s,d+=p,s/=256,l-=8);e[n+d-p]|=128*i}}).call(this,e("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/ieee754/index.js","/node_modules/gulp-browserify/node_modules/ieee754")},{buffer:3,lYpoI2:11}],11:[function(e,t,n){(function(e,n,o,r,i,s,a,l,c){var u,h,d;function p(){}(e=t.exports={}).nextTick=(h="undefined"!=typeof window&&window.setImmediate,d="undefined"!=typeof window&&window.postMessage&&window.addEventListener,h?function(e){return window.setImmediate(e)}:d?(u=[],window.addEventListener("message",(function(e){var t=e.source;t!==window&&null!==t||"process-tick"!==e.data||(e.stopPropagation(),0<u.length&&u.shift()())}),!0),function(e){u.push(e),window.postMessage("process-tick","*")}):function(e){setTimeout(e,0)}),e.title="browser",e.browser=!0,e.env={},e.argv=[],e.on=p,e.addListener=p,e.once=p,e.off=p,e.removeListener=p,e.removeAllListeners=p,e.emit=p,e.binding=function(e){throw new Error("process.binding is not supported")},e.cwd=function(){return"/"},e.chdir=function(e){throw new Error("process.chdir is not supported")}}).call(this,e("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/process/browser.js","/node_modules/gulp-browserify/node_modules/process")},{buffer:3,lYpoI2:11}]},{},[1])(1)},9146:(e,t)=>{"use strict";var n;!function(){var o=t||{}||this||window;void 0===(n=function(){return o}.apply(t,[]))||(e.exports=n),o.default=o;var r="http://www.w3.org/2000/xmlns/",i="http://www.w3.org/2000/svg",s=/url\(["']?(.+?)["']?\)/,a={woff2:"font/woff2",woff:"font/woff",otf:"application/x-font-opentype",ttf:"application/x-font-ttf",eot:"application/vnd.ms-fontobject",sfnt:"application/font-sfnt",svg:"image/svg+xml"},l=function(e){return e instanceof HTMLElement||e instanceof SVGElement},c=function(e){if(!l(e))throw new Error("an HTMLElement or SVGElement is required; got "+e)},u=function(e){return new Promise((function(t,n){l(e)?t(e):n(new Error("an HTMLElement or SVGElement is required; got "+e))}))},h=function(e,t,n){var o=e.viewBox&&e.viewBox.baseVal&&e.viewBox.baseVal[n]||null!==t.getAttribute(n)&&!t.getAttribute(n).match(/%$/)&&parseInt(t.getAttribute(n))||e.getBoundingClientRect()[n]||parseInt(t.style[n])||parseInt(window.getComputedStyle(e).getPropertyValue(n));return null==o||isNaN(parseFloat(o))?0:o},d=function(e){for(var t=window.atob(e.split(",")[1]),n=e.split(",")[0].split(":")[1].split(";")[0],o=new ArrayBuffer(t.length),r=new Uint8Array(o),i=0;i<t.length;i++)r[i]=t.charCodeAt(i);return new Blob([o],{type:n})},p={},m=null,f=function(e,t){var n=t||{},o=n.selectorRemap,r=n.modifyStyle,i=n.modifyCss,l=n.fonts,c=n.excludeUnusedCss,u=i||function(e,t){return(o?o(e):e)+"{"+(r?r(t):t)+"}\n"},h=[],d=void 0===l,f=l||[];return(m||(m=Array.from(document.styleSheets).map((function(e){try{return{rules:e.cssRules,href:e.href}}catch(t){return console.warn("Stylesheet could not be loaded: "+e.href,t),{}}})))).forEach((function(t){var n=t.rules,o=t.href;n&&Array.from(n).forEach((function(t){if(void 0!==t.style)if(function(e,t){if(t)try{return e.querySelector(t)||e.parentNode&&e.parentNode.querySelector(t)}catch(e){console.warn('Invalid CSS selector "'+t+'"',e)}}(e,t.selectorText))h.push(u(t.selectorText,t.style.cssText));else if(d&&t.cssText.match(/^@font-face/)){var n=function(e,t){var n=e.cssText.match(s),o=n&&n[1]||"";if(o&&!o.match(/^data:/)&&"about:blank"!==o){var r,i,l=o.startsWith("../")?t+"/../"+o:o.startsWith("./")?t+"/."+o:o;return{text:e.cssText,format:(r=l,i=Object.keys(a).filter((function(e){return r.indexOf("."+e)>0})).map((function(e){return a[e]})),i?i[0]:(console.error("Unknown font format for "+r+". Fonts may not be working correctly."),"application/octet-stream")),url:l}}}(t,o);n&&f.push(n)}else c||h.push(t.cssText)}))})),function(e){return Promise.all(e.map((function(e){return new Promise((function(t,n){if(p[e.url])return t(p[e.url]);var o=new XMLHttpRequest;o.addEventListener("load",(function(){var n=function(e){for(var t="",n=new Uint8Array(e),o=0;o<n.byteLength;o++)t+=String.fromCharCode(n[o]);return window.btoa(t)}(o.response),r=e.text.replace(s,'url("data:'+e.format+";base64,"+n+'")')+"\n";p[e.url]=r,t(r)})),o.addEventListener("error",(function(n){console.warn("Failed to load font from: "+e.url,n),p[e.url]=null,t(null)})),o.addEventListener("abort",(function(n){console.warn("Aborted loading font from: "+e.url,n),t(null)})),o.open("GET",e.url),o.responseType="arraybuffer",o.send()}))}))).then((function(e){return e.filter((function(e){return e})).join("")}))}(f).then((function(e){return h.join("\n")+e}))},g=function(){if(!navigator.msSaveOrOpenBlob&&!("download"in document.createElement("a")))return{popup:window.open()}};o.prepareSvg=function(e,t,n){c(e);var o=t||{},s=o.left,a=void 0===s?0:s,l=o.top,u=void 0===l?0:l,d=o.width,p=o.height,m=o.scale,g=void 0===m?1:m,y=o.responsive,b=void 0!==y&&y,v=o.excludeCss,C=void 0!==v&&v;return function(e){return Promise.all(Array.from(e.querySelectorAll("image")).map((function(e){var t,n=e.getAttributeNS("http://www.w3.org/1999/xlink","href")||e.getAttribute("href");return n?((t=n)&&0===t.lastIndexOf("http",0)&&-1===t.lastIndexOf(window.location.host)&&(n+=(-1===n.indexOf("?")?"?":"&")+"t="+(new Date).valueOf()),new Promise((function(t,o){var r=document.createElement("canvas"),i=new Image;i.crossOrigin="anonymous",i.src=n,i.onerror=function(){return o(new Error("Could not load "+n))},i.onload=function(){r.width=i.width,r.height=i.height,r.getContext("2d").drawImage(i,0,0),e.setAttributeNS("http://www.w3.org/1999/xlink","href",r.toDataURL("image/png")),t(!0)}}))):Promise.resolve(null)})))}(e).then((function(){var o=e.cloneNode(!0);o.style.backgroundColor=(t||{}).backgroundColor||e.style.backgroundColor;var s=function(e,t,n,o){if("svg"===e.tagName)return{width:n||h(e,t,"width"),height:o||h(e,t,"height")};if(e.getBBox){var r=e.getBBox(),i=r.x,s=r.y;return{width:i+r.width,height:s+r.height}}}(e,o,d,p),l=s.width,c=s.height;if("svg"!==e.tagName){if(!e.getBBox)return void console.error("Attempted to render non-SVG element",e);null!=o.getAttribute("transform")&&o.setAttribute("transform",o.getAttribute("transform").replace(/translate\(.*?\)/,""));var m=document.createElementNS("http://www.w3.org/2000/svg","svg");m.appendChild(o),o=m}if(o.setAttribute("version","1.1"),o.setAttribute("viewBox",[a,u,l,c].join(" ")),o.getAttribute("xmlns")||o.setAttributeNS(r,"xmlns",i),o.getAttribute("xmlns:xlink")||o.setAttributeNS(r,"xmlns:xlink","http://www.w3.org/1999/xlink"),b?(o.removeAttribute("width"),o.removeAttribute("height"),o.setAttribute("preserveAspectRatio","xMinYMin meet")):(o.setAttribute("width",l*g),o.setAttribute("height",c*g)),Array.from(o.querySelectorAll("foreignObject > *")).forEach((function(e){e.setAttributeNS(r,"xmlns","svg"===e.tagName?i:"http://www.w3.org/1999/xhtml")})),!C)return f(e,t).then((function(e){var t=document.createElement("style");t.setAttribute("type","text/css"),t.innerHTML="<![CDATA[\n"+e+"\n]]>";var r=document.createElement("defs");r.appendChild(t),o.insertBefore(r,o.firstChild);var i=document.createElement("div");i.appendChild(o);var s=i.innerHTML.replace(/NS\d+:href/gi,'xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href');if("function"!=typeof n)return{src:s,width:l,height:c};n(s,l,c)}));var y=document.createElement("div");y.appendChild(o);var v=y.innerHTML;if("function"!=typeof n)return{src:v,width:l,height:c};n(v,l,c)}))},o.svgAsDataUri=function(e,t,n){return c(e),o.prepareSvg(e,t).then((function(e){var t=e.src,o=e.width,r=e.height,i="data:image/svg+xml;base64,"+window.btoa(decodeURIComponent(encodeURIComponent('<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [<!ENTITY nbsp " ">]>'+t).replace(/%([0-9A-F]{2})/g,(function(e,t){var n=String.fromCharCode("0x"+t);return"%"===n?"%25":n}))));return"function"==typeof n&&n(i,o,r),i}))},o.svgAsPngUri=function(e,t,n){c(e);var r=t||{},i=r.encoderType,s=void 0===i?"image/png":i,a=r.encoderOptions,l=void 0===a?.8:a,u=r.canvg,h=function(e){var t=e.src,o=e.width,r=e.height,i=document.createElement("canvas"),a=i.getContext("2d"),c=window.devicePixelRatio||1;i.width=o*c,i.height=r*c,i.style.width=i.width+"px",i.style.height=i.height+"px",a.setTransform(c,0,0,c,0,0),u?u(i,t):a.drawImage(t,0,0);var h=void 0;try{h=i.toDataURL(s,l)}catch(e){if("undefined"!=typeof SecurityError&&e instanceof SecurityError||"SecurityError"===e.name)return void console.error("Rendered SVG images cannot be downloaded in this browser.");throw e}return"function"==typeof n&&n(h,i.width,i.height),Promise.resolve(h)};return u?o.prepareSvg(e,t).then(h):o.svgAsDataUri(e,t).then((function(e){return new Promise((function(t,n){var o=new Image;o.onload=function(){return t(h({src:o,width:o.width,height:o.height}))},o.onerror=function(){n("There was an error loading the data URI as an image on the following SVG\n"+window.atob(e.slice(26))+"Open the following link to see browser's diagnosis\n"+e)},o.src=e}))}))},o.download=function(e,t,n){if(navigator.msSaveOrOpenBlob)navigator.msSaveOrOpenBlob(d(t),e);else{var o=document.createElement("a");if("download"in o){o.download=e,o.style.display="none",document.body.appendChild(o);try{var r=d(t),i=URL.createObjectURL(r);o.href=i,o.onclick=function(){return requestAnimationFrame((function(){return URL.revokeObjectURL(i)}))}}catch(e){console.error(e),console.warn("Error while getting object URL. Falling back to string URL."),o.href=t}o.click(),document.body.removeChild(o)}else n&&n.popup&&(n.popup.document.title=e,n.popup.location.replace(t))}},o.saveSvg=function(e,t,n){var r=g();return u(e).then((function(e){return o.svgAsDataUri(e,n||{})})).then((function(e){return o.download(t,e,r)}))},o.saveSvgAsPng=function(e,t,n){var r=g();return u(e).then((function(e){return o.svgAsPngUri(e,n||{})})).then((function(e){return o.download(t,e,r)}))}}()},5072:e=>{"use strict";var t=[];function n(e){for(var n=-1,o=0;o<t.length;o++)if(t[o].identifier===e){n=o;break}return n}function o(e,o){for(var i={},s=[],a=0;a<e.length;a++){var l=e[a],c=o.base?l[0]+o.base:l[0],u=i[c]||0,h="".concat(c," ").concat(u);i[c]=u+1;var d=n(h),p={css:l[1],media:l[2],sourceMap:l[3],supports:l[4],layer:l[5]};if(-1!==d)t[d].references++,t[d].updater(p);else{var m=r(p,o);o.byIndex=a,t.splice(a,0,{identifier:h,updater:m,references:1})}s.push(h)}return s}function r(e,t){var n=t.domAPI(t);return n.update(e),function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap&&t.supports===e.supports&&t.layer===e.layer)return;n.update(e=t)}else n.remove()}}e.exports=function(e,r){var i=o(e=e||[],r=r||{});return function(e){e=e||[];for(var s=0;s<i.length;s++){var a=n(i[s]);t[a].references--}for(var l=o(e,r),c=0;c<i.length;c++){var u=n(i[c]);0===t[u].references&&(t[u].updater(),t.splice(u,1))}i=l}}},7659:e=>{"use strict";var t={};e.exports=function(e,n){var o=function(e){if(void 0===t[e]){var n=document.querySelector(e);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(e){n=null}t[e]=n}return t[e]}(e);if(!o)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");o.appendChild(n)}},540:e=>{"use strict";e.exports=function(e){var t=document.createElement("style");return e.setAttributes(t,e.attributes),e.insert(t,e.options),t}},5056:(e,t,n)=>{"use strict";e.exports=function(e){var t=n.nc;t&&e.setAttribute("nonce",t)}},7825:e=>{"use strict";e.exports=function(e){if("undefined"==typeof document)return{update:function(){},remove:function(){}};var t=e.insertStyleElement(e);return{update:function(n){!function(e,t,n){var o="";n.supports&&(o+="@supports (".concat(n.supports,") {")),n.media&&(o+="@media ".concat(n.media," {"));var r=void 0!==n.layer;r&&(o+="@layer".concat(n.layer.length>0?" ".concat(n.layer):""," {")),o+=n.css,r&&(o+="}"),n.media&&(o+="}"),n.supports&&(o+="}");var i=n.sourceMap;i&&"undefined"!=typeof btoa&&(o+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(i))))," */")),t.styleTagTransform(o,e,t.options)}(t,e,n)},remove:function(){!function(e){if(null===e.parentNode)return!1;e.parentNode.removeChild(e)}(t)}}}},1113:e=>{"use strict";e.exports=function(e,t){if(t.styleSheet)t.styleSheet.cssText=e;else{for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(document.createTextNode(e))}}},6686:(e,t,n)=>{"use strict";n.d(t,{AL:()=>o,NO:()=>r});const o=["A","G","C","U"];var r;!function(e){e.HELM="HELM",e.AXOLABS="Axolabs"}(r||(r={}))},9537:(e,t,n)=>{"use strict";n.d(t,{iL:()=>i,q7:()=>r,ti:()=>o});const o={NUCLEOSIDE:"nucleoside",LINKAGE:"phosphateBackbone"},r="p",i="<?>"},3480:(e,t,n)=>{"use strict";n.d(t,{C6:()=>l,Hs:()=>a,OT:()=>c,bD:()=>s});var o=n(6686),r=n(5067),i=n(9537);function s(e,t,n,r){const i=Object.keys(r.jsonData.codesToHelmDict).concat([o.NO.HELM]);if(!e||-1!==t&&n!==o.NO.HELM)return{};if(!i.includes(n))throw new Error(`${n} format is not supported by SequenceTranslator`);const s=i.filter((e=>e!=n)).sort(((e,t)=>e.localeCompare(t))),l=r.createFormatConverter(e,n),c=Object.fromEntries(s.map((e=>{let t;try{t=l.convertTo(e)}catch{t=null}return[e,t]})).filter((([e,t])=>t))),u=a(n===o.NO.HELM?e:c[o.NO.HELM],r.monomerLibWrapper);return u&&(c.Nucleotides=u),c}function a(e,t){const n=new RegExp("\\([^()]*\\)","g"),r=e.match(n);return r?r.map((e=>{const n=e.replace(/[\[\]()]/g,"");return o.AL.includes(n)?n:t.getNaturalAnalogBySymbol(n)})).map((e=>e||i.iL)).join(""):null}function l(e,t,n,i){const s=i.createFormatConverter(e,t);return n===r.qP?a(s.convertTo(o.NO.HELM),i.monomerLibWrapper):s.convertTo(n)}function c(e){return Object.keys(e.jsonData.codesToHelmDict).concat([o.NO.HELM,r.qP]).sort()}},5067:(e,t,n)=>{"use strict";n.d(t,{U_:()=>r,n_:()=>o,qP:()=>i});const o="Copied",r="Copy sequence",i="Nucleotides"},9154:(e,t,n)=>{"use strict";n.d(t,{Y:()=>i});var o=n(6345);const r=new Map;function i(e){if(!e)return null;const t=r.get(e);if(void 0!==t)return t;let n=null;try{n=o._package.bioMonomerLib}catch{}if(!n)return null;const i=function(e,t){for(const n of e.getPolymerTypes()){const o=e.getMonomer(n,t),r=o?.naturalAnalog;if(r&&"string"==typeof r&&1===r.length)return r.toUpperCase()}return null}(n,e);return r.set(e,i),i}},5733:(e,t,n)=>{"use strict";n.d(t,{CB:()=>L,Z4:()=>A,aA:()=>y});var o=n(1536),r=n(9154);const i={showLetters:!0,pairAlign:!0},s=1.25,a=.5,l=.32,c=5,u=17,h=4,d=30,p=.85,m=.5,f=.22,g=.55;function y(e,t,n,o={}){const r={...i,...o},p=n.sense.monomers.length,m=n.antisense?n.antisense.monomers.length:0,f=m>0,g=f?2:1,y=Math.max(1,p,m),A=Math.max(0,e-d-2*h)/(y+Math.max(0,y-1)*l),T=g+Math.max(0,g-1)*a,E=(t-2*h)/T/s;let S=Math.min(u,A,E);const N=S<c;S<c&&(S=c);const I=S*s,M=Math.max(2,S*l),P=I*a,_=Math.max(7,Math.min(13,.62*S)),L=g*I+(g-1)*P,O=Math.max(h,(t-L)/2),R=O,$=f?O+I+P:-1,D=h+d,B=e-h,F={chipW:S,chipH:I,chipGap:M,strandGap:P,fontSize:_,labelW:d,padding:h,senseY:R,antiY:$,seqX:D,textOnlyFallback:N};if(N)return{...F,senseChips:[],antiChips:[],senseLinks:[],antiLinks:[],antiReversed:!1};const k=f&&r.pairAlign,H=C(n.sense.monomers,!1,S,_,M),G=f?C(n.antisense.monomers,k,S,_,M):0,U=Math.max(H,G),V=D+(U-H),j=D+(U-G),q=n.sense.monomers,W=f?k?n.antisense.monomers.slice().reverse():n.antisense.monomers:[];let z=function(e,t,n,o){const r=e.map((e=>x(e,n,o))),i=t.map((e=>x(e,n,o))),s=e.findIndex((e=>"nucleotide"===e.kind)),a=t.findIndex((e=>"nucleotide"===e.kind));if(s>=0&&a>=0){const n=Math.min(e.length-s,t.length-a);for(let e=0;e<n;e++){const t=s+e,n=a+e,o=Math.max(r[t],i[n]);r[t]=o,i[n]=o}}return{sense:r,anti:i}}(q,W,S,_);const Y=B-(D+U);w(z.sense,H,M,Y)&&w(z.anti,G,M,Y)||(z=function(e,t,n,o){const r=e=>"conjugate"===e.kind?v(e.symbol,n,o):n;return{sense:e.map(r),anti:t.map(r)}}(q,W,S,_));const K=b(n.sense,!1,R,V,B,F,"sense",z.sense),Q=f?b(n.antisense,k,$,j,B,F,"antisense",z.anti):{chips:[],links:[]};return{...F,senseChips:K.chips,antiChips:Q.chips,senseLinks:K.links,antiLinks:Q.links,antiReversed:k}}function b(e,t,n,o,r,i,s,a){const l=t?e.monomers.slice().reverse():e.monomers,c=[],u=[];let h=o;for(let e=0;e<l.length;e++){const t=l[e],o=a[e]??i.chipW;if(h+o>r)break;if(c.push({x:h,w:o,monomer:t,origIdx:t.position,strand:s}),"nucleotide"===t.kind&&e<l.length-1){const e=t;e.phosphate&&u.push({x:h+o,w:i.chipGap,y:n,h:i.chipH,phosphateSymbol:e.phosphate,ownerOrigIdx:e.position,strand:s})}h+=o+i.chipGap}return{chips:c,links:u}}function v(e,t,n){const r=.55*n,i=(0,o.rK)(e).meta.short.length*r,s=.6*t;return Math.max(t,Math.min(4*t,i+s))}function C(e,t,n,o,r){const i=t?e.slice().reverse():e;let s=0;for(const e of i){if("conjugate"!==e.kind)break;s+=v(e.symbol,n,o)+r}return s}function x(e,t,n){if("conjugate"===e.kind)return v(e.symbol,t,n);const o=e.base??"";if(o.length<=2)return t;const r=.55*n,i=o.length*r,s=.4*t;return Math.max(t,Math.min(3*t,i+s))}function w(e,t,n,o){let r=t;for(let t=0;t<e.length;t++)r+=e[t],t<e.length-1&&(r+=n);return r<=o}function A(e,t,n,o,r,s,a={}){const l={...i,...a},c=y(o,r,s,l);if(e.save(),e.beginPath(),e.rect(t,n,o,r),e.clip(),e.translate(t,n),c.textOnlyFallback)return function(e,t,n,o,r){const i=o.sense.monomers.length,s=o.antisense?o.antisense.monomers.length:0,a=o.antisense?`${i}+${s} nt duplex`:`${i} nt`;e.fillStyle="#8b949e",e.font=`${Math.max(8,r.fontSize)}px ui-monospace, Menlo, monospace`,e.textBaseline="middle",e.textAlign="left",e.fillText(a,4,n/2)}(e,0,r,s,c),e.restore(),c;T(e,"S","5'",c.padding,c.senseY+c.chipH/2,c);for(const t of c.senseLinks)I(e,t);if(S(e,c.senseChips,c,l),E(e,c.senseChips,s.sense.monomers.length,c),c.antiY>=0&&s.antisense){T(e,"AS",c.antiReversed?"3'":"5'",c.padding,c.antiY+c.chipH/2,c);for(const t of c.antiLinks)I(e,t);S(e,c.antiChips,c,l),E(e,c.antiChips,s.antisense.monomers.length,c)}return e.restore(),c}function T(e,t,n,o,r,i){e.fillStyle="#8b949e",e.font=`${Math.max(8,i.fontSize-1)}px ui-monospace, Menlo, monospace`,e.textBaseline="middle",e.textAlign="left",e.fillText(`${t} ${n}`,o,r)}function E(e,t,n,o){if(t.length>=n)return;const r=t[t.length-1];r&&(e.fillStyle="#6e7681",e.font=`${Math.max(7,o.fontSize-1)}px ui-monospace, Menlo, monospace`,e.textBaseline="middle",e.textAlign="left",e.fillText("…",r.x+r.w+1,o.senseY+o.chipH/2))}function S(e,t,n,o){const r="sense"===t[0]?.strand?n.senseY:n.antiY;for(const i of t)"conjugate"===i.monomer.kind?M(e,i.monomer.symbol,i.x,r,i.w,n.chipH,n.fontSize):N(e,i.monomer,i.x,r,i.w,n.chipH,n.fontSize,o)}function N(e,t,n,i,s,a,l,c){const u=(0,o.xh)(t.sugar,t.base),h=function(e){if(!e)return o.FN;if(o.L1[e])return o.L1[e];if((0,o.kT)(e))return o.L1[e]??o.FN;const t=(0,r.Y)(e);return t&&o.L1[t]?o.L1[t]:o.FN}(t.base),d=function(e){const t=(0,o.Jy)(e);return"r"!==t&&"d"!==t}(t.sugar),g=Math.min(2.5,s/4);if(P(e,n,i,s,a,g),e.fillStyle=function(e,t){const n=`${e}|${t}`,o=_.get(n);if(o)return o;const r=document.createElement("span");r.style.color=e,document.body.appendChild(r);const i=getComputedStyle(r).color;document.body.removeChild(r);const s=i.match(/\d+/g),a=s?`rgba(${s[0]},${s[1]},${s[2]},${t})`:e;return _.size>256&&_.clear(),_.set(n,a),a}(h,p),e.fill(),e.lineWidth=m,e.strokeStyle="rgba(0,0,0,0.22)",e.stroke(),d){const t=Math.max(2,a*f);e.save(),P(e,n,i,s,a,g),e.clip(),e.fillStyle=u.color,e.fillRect(n,i+a-t,s,t),e.restore()}if(c.showLetters&&t.base&&l>=8){const r=d?Math.max(2,a*f):0,c=function(e,t,n){if(e.length<=2)return e;const r=.55*n;return e.length*r+4<=t?e:(0,o.Av)(e)}(t.base,s,l);e.fillStyle="#1a1a1a",e.font=`600 ${l}px system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif`,e.textBaseline="middle",e.textAlign="center",e.fillText(c,n+s/2,i+(a-r)/2+.5)}}function I(e,t){if("p"===(0,o.$T)(t.phosphateSymbol))return;const n=(0,o.bM)(t.phosphateSymbol),r=Math.max(2.5,t.w*g),i=t.x+(t.w-r)/2;e.fillStyle=n.color,e.fillRect(i,t.y+1,r,t.h-2)}function M(e,t,n,r,i,s,a){const l=(0,o.rK)(t);P(e,n,r,i,s,s/2),e.fillStyle=l.color,e.fill(),e.lineWidth=.5,e.strokeStyle="rgba(0,0,0,0.2)",e.stroke(),a>=8&&(e.fillStyle="#ffffff",e.font=`600 ${Math.max(8,a-1)}px system-ui, sans-serif`,e.textBaseline="middle",e.textAlign="center",e.fillText(l.meta.short,n+i/2,r+s/2+.5))}function P(e,t,n,o,r,i){e.beginPath(),e.moveTo(t+i,n),e.lineTo(t+o-i,n),e.quadraticCurveTo(t+o,n,t+o,n+i),e.lineTo(t+o,n+r-i),e.quadraticCurveTo(t+o,n+r,t+o-i,n+r),e.lineTo(t+i,n+r),e.quadraticCurveTo(t,n+r,t,n+r-i),e.lineTo(t,n+i),e.quadraticCurveTo(t,n,t+i,n),e.closePath()}const _=new Map;function L(e,t,n,o){if(o.textOnlyFallback)return null;if(t>=o.senseY&&t<=o.senseY+o.chipH){const r=O(e,o.senseChips);if(r)return{strand:"sense",position:r.origIdx,monomer:r.monomer};const i=R(e,t,o.senseLinks);if(i)return $(i,n.sense,"sense")}if(o.antiY>=0&&t>=o.antiY&&t<=o.antiY+o.chipH){const r=O(e,o.antiChips);if(r)return{strand:"antisense",position:r.origIdx,monomer:r.monomer};const i=R(e,t,o.antiLinks);if(i&&n.antisense)return $(i,n.antisense,"antisense")}return null}function O(e,t){for(const n of t)if(e>=n.x&&e<n.x+n.w)return n;return null}function R(e,t,n){for(const o of n)if(e>=o.x&&e<o.x+o.w&&t>=o.y&&t<o.y+o.h)return o;return null}function $(e,t,n){const o=t.monomers.find((t=>t.position===e.ownerOrigIdx));return{strand:n,position:e.ownerOrigIdx,monomer:o,linkage:{phosphateSymbol:e.phosphateSymbol}}}},4900:(e,t,n)=>{"use strict";n.d(t,{P:()=>s,xE:()=>l,zZ:()=>a});var o=n(6082),r=n(5613),i=n(1536);function s(e){return e.semType=i.mU,e.meta.units=i.D2,e.setTag("cell.renderer",i.mU),e.setTag("quality",i.mU),e}function a(e,t,n){const r=new Array(t.length);for(let e=0;e<t.length;e++)r[e]=t.get(e)??"";const i=o.Column.fromStrings(e.columns.getUnusedName(n??`${t.name} (oligo)`),r);return s(i),e.columns.add(i),i}function l(e,t,n,i){if(t.length!==n.length)throw new Error("Sense and antisense columns must have the same length");const a=new Array(t.length);for(let e=0;e<t.length;e++){const o=t.get(e)??"",i=n.get(e)??"";if(!(0,r.yO)(o)){a[e]="";continue}const s=c(o,1),l=(0,r.yO)(i)?c(i,2):"",u=l?`${s}|${l}`:s;a[e]=`${u}$$$$`}const l=o.Column.fromStrings(e.columns.getUnusedName(i??`${t.name}+${n.name} (oligo)`),a);return s(l),e.columns.add(l),l}function c(e,t){return e.split("$")[0].replace(/^(RNA|DNA|PEPTIDE|CHEM|BLOB)\d+\{/,`$1${t}{`)}},5613:(e,t,n)=>{"use strict";n.d(t,{On:()=>i,nj:()=>h,yO:()=>c});var o=n(8438),r=n(1536);function i(e){const t=((e??"").split("$")[0]??"").split("|").map((e=>e.trim())).filter((e=>e.length>0)).map(s);return{sense:t[0]??{type:"RNA",monomers:[]},antisense:t[1]??null,raw:e}}function s(e){const t=e.match(/^(RNA|DNA|CHEM|PEPTIDE|BLOB)\d+\{(.*)\}$/);return t?{type:t[1],monomers:a(t[2])}:{type:"CHEM",monomers:[]}}function a(e){const t=[];let n=0,o="",r=0;for(const i of e){if("["===i||"("===i)n++;else if("]"===i||")"===i)n--;else if("."===i&&0===n){o&&t.push(l(o,r++)),o="";continue}o+=i}return o&&t.push(l(o,r)),t}function l(e,t){let n=0,r="",i=null,s="";const a=e;if("["===e[0]){const t=e.indexOf("]");r=e.substring(1,t),n=t+1}else r=e[0]??"",n=1;if("("===e[n]){const t=e.indexOf(")",n);i=(0,o.D)(e.substring(n+1,t)),n=t+1}if(n<e.length)if("["===e[n]){const t=e.indexOf("]",n);s=e.substring(n+1,t),n=t+1}else s=e.substring(n);return null===i?{kind:"conjugate",position:t,symbol:r,raw:a}:{kind:"nucleotide",position:t,sugar:r,base:i,phosphate:s,raw:a}}function c(e){return/^\s*(?:RNA|DNA|PEPTIDE|CHEM|BLOB)\d+\s*\{/.test(e??"")}function u(e){if("conjugate"===e.kind)return`[${e.symbol}]`;const t=e,n=(0,r.Jy)(t.sugar),o=(0,r.$T)(t.phosphate),i=1===n.length?n:`[${n}]`,s=o?1===o.length?o:`[${o}]`:"";return`${i}${t.base?1===t.base.length?`(${t.base})`:`([${t.base}])`:""}${s}`}function h(e){return`${(e??"").split("$")[0].split("|").map((e=>e.trim())).filter(Boolean).map((e=>{const t=e.match(/^((?:RNA|DNA|PEPTIDE|CHEM|BLOB)\d+)\{(.*)\}$/);if(!t)return e;const[,n,o]=t;return`${n}{${function(e){return a(e).map(u).join(".")}(o)}}`})).join("|")}$$$$`}},1536:(e,t,n)=>{"use strict";n.d(t,{$T:()=>y,Av:()=>m,D2:()=>r,FN:()=>d,Jy:()=>g,L1:()=>u,P4:()=>a,bM:()=>v,e8:()=>f,kT:()=>p,mU:()=>o,pt:()=>c,rK:()=>C,xh:()=>b});const o="OligoNucleotide",r="helm",i=Object.freeze({r:{name:"Ribose",short:"RNA",color:"#D0D0D0",category:"sugar"},d:{name:"Deoxyribose",short:"DNA",color:"#BDBDBD",category:"sugar"},m:{name:"2'-O-Methyl",short:"2'-OMe",color:"#4A90E2",category:"sugar"},"25r":{name:"2'-O-Methyl (2,5)",short:"2'-OMe",color:"#4A90E2",category:"sugar"},fl2r:{name:"2'-Fluoro",short:"2'-F",color:"#50C878",category:"sugar"},lna:{name:"LNA",short:"LNA",color:"#E89D3C",category:"sugar"},cet:{name:"cEt",short:"cEt",color:"#E07B30",category:"sugar"},ena:{name:"ENA",short:"ENA",color:"#D26C20",category:"sugar"},moe:{name:"2'-MOE",short:"2'-MOE",color:"#66CDAA",category:"sugar"},Rgna:{name:"(R)-GNA",short:"GNA",color:"#C7A981",category:"sugar"},Sgna:{name:"(S)-GNA",short:"GNA",color:"#C7A981",category:"sugar"},una:{name:"UNA",short:"UNA",color:"#ED68B8",category:"sugar"},fana:{name:"FANA",short:"FANA",color:"#76B947",category:"sugar"},hna:{name:"HNA",short:"HNA",color:"#A4D080",category:"sugar"}}),s=Object.freeze({R:"r",dR:"d",mR:"m",fR:"fl2r",LR:"lna",L:"lna",MOE:"moe",GNA:"Sgna",UNA:"una"}),a=Object.freeze({p:{name:"Phosphate",short:"PO",color:"#888888",category:"phosphate"},sp:{name:"Phosphorothioate",short:"PS",color:"#6B46C1",category:"phosphate"},s2p:{name:"Phosphorodithioate",short:"PS₂",color:"#7E2BC4",category:"phosphate"},mp:{name:"Methylphosphonate",short:"MeP",color:"#9B5DE5",category:"phosphate"}}),l=Object.freeze({P:"p",sP:"sp"}),c=Object.freeze({GalNAc:{name:"GalNAc",short:"GalNAc",color:"#E91E63",category:"conjugate"},L3:{name:"GalNAc-L3 linker",short:"L3",color:"#E91E63",category:"conjugate"},Chol:{name:"Cholesterol",short:"Chol",color:"#B57F50",category:"conjugate"},Bio:{name:"Biotin",short:"Bio",color:"#FFC107",category:"conjugate"}}),u=Object.freeze({A:"#C1E7C5",C:"#C5DCF0",G:"#E8DCA9",U:"#F0C5C5",T:"#F0C5C5"}),h=new Set(["A","C","G","U","T"]),d="#BCBCBC";function p(e){return!!e&&h.has(e)}function m(e){return e?e.length<=2?e:e[0]+"…":""}function f(e){let t=0;for(let n=0;n<e.length;n++)t=31*t+e.charCodeAt(n)|0;return`hsl(${(t>>>0)%360}, 42%, 60%)`}function g(e){return s[e]??e}function y(e){return l[e]??e}function b(e,t){const n=g(e),o=i[n];if(o)return("r"===n||"d"===n)&&t&&u[t]?{color:u[t],meta:o}:{color:o.color,meta:o};const r=f(n);return{color:r,meta:{name:n,short:n,color:r,category:"sugar"}}}function v(e){if(!e)return{color:"#888",meta:{name:"(none)",short:"",color:"#888",category:"phosphate"}};const t=y(e),n=a[t];if(n)return{color:n.color,meta:n};const o=f(t);return{color:o,meta:{name:t,short:t,color:o,category:"phosphate"}}}function C(e){const t=c[e];return t?{color:t.color,meta:t}:{color:f(e),meta:{name:e,short:e.length>6?e.slice(0,6):e,color:f(e),category:"conjugate"}}}},6345:(e,t,n)=>{"use strict";n.d(t,{PackageFunctions:()=>Cr,_package:()=>br});var o=n(4328),r=n(7389),i=n(6082),s=n(439),a=n(7291);const l=new class{constructor(){this.seqHandler="seq-handler",this.notationProvider="seq-handler.notation-provider"}};i.SemanticValue;var c=n(4971);class u{constructor(e,t,n=""){this.target=e,this.debugEnabled=t,this.prefix=n}error(e,t,n){return this.target.error(this.prefix+e,t,n)}warning(e,t){return this.target.warning(this.prefix+e,t)}info(e,t){return this.target.info(this.prefix+e,t)}debug(e,t){if(this.debugEnabled)return this.target.debug(this.prefix+e,t)}}const h="System:AppData/SequenceTranslator/monomers-sample",d="pattern-app-data.json",p="formats-to-helm.json",m="codes-to-symbols.json",f="linkers.json";var g=n(6686);function y(e){return e.sort(((e,t)=>t.length-e.length))}function b(e,t){const n=document.createElement("a");n.setAttribute("href","data:text/plain;charset=utf-8,"+t),n.setAttribute("download",e),n.click()}async function v(e,t,n="Oligo app"){try{return await e()}catch(e){const t=e.hasOwnProperty("message")?e.message:e.toString();throw o.shell.error(`${n} error: `+t),e}finally{t&&t()}}class C{constructor(e,t){this.sequence=e,this.th=t,this.libWrapper=this.th.monomerLibWrapper}getInvalidCodeIndex(e){if(e===g.NO.HELM)return this.sequence.length;const t=["r","d"],n=y(this.libWrapper.getCodesByFormat(e));let o=0;for(;o<this.sequence.length;){const e=n.find((e=>e===this.sequence.substring(o,o+e.length)));if(!e)break;if(o>1&&g.AL.includes(this.sequence[o])&&t.includes(this.sequence[o-2]))break;if(t.includes(this.sequence[o+1])&&g.AL.includes(this.sequence[o])){o++;break}o+=e.length}return o===this.sequence.length&&(o=-1),o}isValidSequence(e){return-1===this.getInvalidCodeIndex(e)}}class x{constructor(e,t,n,o){this.patternAppData=e,this.codesToHelmDict=t,this.codesToSymbolsDict=n,this.monomersWithPhosphate=o}}async function w(e){const t=await Promise.all([d,p,m,f].map((t=>async function(e,t){const n=e.endsWith("/")?`${e}${t}`:`${e}/${t}`;try{const e=await o.dapi.files.readAsText(n);return JSON.parse(e)}catch(e){console.error(`Error loading json from '${n}':`,e)}}(e,t))));return new x(t[0],t[1],t[2],t[3])}class A{constructor(e,t){if(this.lib=e,this.jsonData=t,null===this.lib)throw new Error("SequenceTranslator: monomer library is null");this.allMonomers=this.getAllMonomers()}formatMonomerForViewer(e){const t={};return t.name=e.symbol,t.symbol=e.symbol,t.molfile=e.molfile,this.getAllFormats().forEach((n=>{if(n===g.NO.HELM)return;const o=this.jsonData.codesToSymbolsDict[n],r=Object.keys(o).filter((t=>o[t]===e.symbol));t[n]=r.join(", ")})),t}getAllMonomers(){const e=this.lib.getPolymerTypes();let t=[];for(const n of e){const e=this.lib.getMonomerSymbolsByType(n).map((e=>this.lib.getMonomer(n,e))).filter((e=>null!==e));t=t.concat(e)}return t}getMonomer(e){const t=this.lib.getMonomer("RNA",e);if(void 0===t)throw new Error(`SequenceTranslator: no monomer with symbol ${e}`);return t}getMolfileBySymbol(e){return this.getMonomer(e).molfile}getNaturalAnalogBySymbol(e){const t=this.getMonomer(e).naturalAnalog;if(!t)throw new Error(`ST: no natural analog for ${e}`);return t}isModification(e){return!!this.getMolfileBySymbol(e).includes("MODIFICATION")}getCodeToSymbolMap(e){return new Map(Object.entries(this.jsonData.codesToSymbolsDict[e]))}getCodesByFormat(e){return Object.keys(this.jsonData.codesToSymbolsDict[e])}getAllFormats(){return Object.keys(this.jsonData.codesToSymbolsDict)}getTableForViewer(){const e=this.allMonomers.map((e=>this.formatMonomerForViewer(e)));return i.DataFrame.fromObjects(e)}getCodesToWeightsMap(){const e=new Map;return Object.entries(this.jsonData.codesToSymbolsDict).forEach((([t,n])=>{Object.entries(n).forEach((([t,n])=>{const o=this.getMonomer(n),r=o.meta?.molecularWeight;e.set(t,r)}))})),e}}var T=n(9537);const E=(e,t)=>t.length-e.length;class S{constructor(e){this.th=e,this.formats=this.getFormats()}getFormatNames(){return this.formats.sort()}getCodesByFormat(e){if(this.validateFormat(e),this.isHelm(e))throw new Error("Codes cannot be obtained for HELM");return this.getFormatCodes(e)}getHelmToFormatDict(e){return this.validateFormat(e),function(e){const t={};return Object.values(e).forEach((e=>{Object.entries(e).forEach((([e,n])=>{const o=n.replace(/\)p/g,")").replace(/\]p/g,"]");void 0===t[o]?t[o]=[e]:t[o].push(e)}))})),Object.entries(t).forEach((([e,n])=>{const o=n.sort(E);t[e]=o[0]})),t}(this.th.jsonData.codesToHelmDict[e])}getFormatToHelmDict(e){this.validateFormat(e);const t=this.th.jsonData.codesToHelmDict[e];return Object.assign({},...Object.values(t))}getTargetFormatHelmCodes(e){this.validateFormat(e);const t=this.getHelmToFormatDict(e);return Object.keys(t).sort(E)}getTargetFormatHelmCodesRegExp(e){this.validateFormat(e);const t=this.getTargetFormatHelmCodes(e);return new RegExp(N(t)+"|.","g")}getFormatRegExp(e){if(this.validateFormat(e),this.isHelm(e))throw new Error("Helm RegExp can be built for non-HELM target formats");return this.getNonHelmFormatRegExp(e)}getPhosphateHelmCodesRegExp(e){this.validateFormat(e);const t=this.th.jsonData.codesToHelmDict[e],n=N(Array.from(new Set(Object.values(t[T.ti.LINKAGE]))).sort(E));return new RegExp(`${T.q7}.(${n})`,"g")}isValidFormat(e){return this.formats.includes(e)}getFormats(){return Object.keys(this.th.jsonData.codesToHelmDict)}validateFormat(e){if(!this.isValidFormat(e))throw new Error(`Invalid format: ${e}`)}isHelm(e){return e===g.NO.HELM}getFormatCodes(e){const t=this.getFormatToHelmDict(e);return Object.keys(t).sort(E)}getNonHelmFormatRegExp(e){const t=this.getCodesByFormat(e);return new RegExp(N(t)+"|\\([^()]*\\)|.","g")}}function N(e){return e.map((e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"))).map((e=>e.includes("(")||e.includes(")")?e:`(?<!\\([^()]*)${e}(?![^()]*\\))`)).join("|")}const I={LEFT:"RNA1{",RIGHT:"}$$$$"};class M{constructor(e,t,n){this.sequence=e,this.sourceFormat=t,this.th=n,this.formats=new S(this.th)}convertTo(e){const t=this.formats.getFormatNames();if(this.sourceFormat===g.NO.HELM&&t.includes(e))return this.helmToFormat(this.sequence,e);if(t.includes(this.sourceFormat)&&e===g.NO.HELM)return this.formatToHelm(this.sequence,this.sourceFormat);if([this.sourceFormat,e].every((e=>t.includes(e)))){const t=this.formatToHelm(this.sequence,this.sourceFormat);return this.helmToFormat(t,e)}throw new Error(`ST: unsupported translation direction ${this.sourceFormat} -> ${e}`)}helmToFormat(e,t){const n=new RegExp(N(Object.values(I)),"g");let o=e.replace(n,"");const r=this.formats.getHelmToFormatDict(t),i=this.formats.getTargetFormatHelmCodes(t),s=this.formats.getTargetFormatHelmCodesRegExp(t);return o=o.replace(s,(e=>i.includes(e)?r[e]:"p"===e||"."===e?e:"?")).replace(/\?+/g,T.iL).replace(/p\.|\./g,""),o=o.replace(/<empty>/g,""),o=o.replace(/\/\//g,"/"),o}formatToHelm(e,t){const n=this.formats.getFormatToHelmDict(t),o=this.formats.getCodesByFormat(t),r=this.formats.getFormatRegExp(t),i=this.formats.getPhosphateHelmCodesRegExp(t);let s=e?e.replace(r,(e=>o.includes(e)?n[e]+".":"?")):"";return s=s.replace(/\?+/g,`${T.iL}.`),s=s.slice(0,-1),s[s.length-1]===T.q7&&(s=s.slice(0,-1)),s=s.replace(i,((e,t)=>t)),s=s.replace(/<empty>/g,""),`${I.LEFT+s+I.RIGHT}`}}class P{constructor(e,t){this.sequence=e,this.th=t,this.libWrapper=this.th.monomerLibWrapper,this.formats=Object.keys(this.th.jsonData.codesToHelmDict)}getFormat(){if(this.sequence.startsWith("RNA"))return g.NO.HELM;const e=this.getListOfPossibleSynthesizersByFirstMatchedCode();if(0===e.length)return null;const t=this.th.createSequenceValidator(this.sequence),n=Array(e.length).fill(0);for(let o=0;o<e.length;++o){const r=e[o];n[o]=t.getInvalidCodeIndex(r)}const o=n.some((e=>-1===e))?-1:Math.max(...n);return e[n.indexOf(o)]}getListOfPossibleSynthesizersByFirstMatchedCode(){const e=this.sequence,t=[];for(const n of this.formats){const o=y(this.libWrapper.getCodesByFormat(n));let r=0;for(let t=0;t<e.length;t++)if(")"===e[t]&&t!==e.length-1){r=t+1;break}o.some((t=>t===e.slice(r,r+t.length)))&&t.push(n)}return t}}var _=n(1757),L=n.n(_);function O(e,t){let n=0;const o=t.createFormatDetector(e).getFormat();null!==o&&(n=new C(e,t).getInvalidCodeIndex(o));const i=n<0||""===e,s=r.span([]);L()(s).css("-webkit-text-fill-color","var(--grey-6)");const a=r.span([]);return L()(a).css("-webkit-text-fill-color","red"),i?s.innerHTML=e:(s.innerHTML=e.slice(0,n),a.innerHTML=e.slice(n)),[s,a]}class R extends i.Package{get helmHelper(){if(!this._helmHelper)throw new Error("Package SequenceTranslator .helmHelper is not initialized");return this._helmHelper}get seqHelper(){return this._helmHelper.seqHelper}get bioMonomerLib(){if(!this._bioMonomerLib)throw new Error("Package SequenceTranslator .bioMonomerLib is not initialized");return this._bioMonomerLib}get monomerLib(){if(!this._monomerLib)throw new Error("Monomer lib not loaded");return this._monomerLib}get jsonData(){if(!this._jsonData)throw new Error("Json data not loaded");return this._jsonData}get monomerLibWrapper(){if(!this._monomerLibWrapper)throw new Error("Monomer lib wrapper not loaded");return this._monomerLibWrapper}get initPromise(){return this._initPromise}constructor(e={debug:!1}){super(),this.highlightInvalidSubsequence=e=>O(e,this),super._logger=new u(super.logger,e.debug)}startInit(e){this._initPromise=e}completeInit(e,t){this._helmHelper=e,this._bioMonomerLib=t}async initLibData(){return this.initLibDataPromise||(this.initLibDataPromise=(async()=>{const e=await this.getSettings();let t=e instanceof Map?e.get("MonomersPath"):e.MonomersPath;t&&await o.dapi.files.exists(t)||(this.logger.warning(`Monomers path '${t}' not found. Fallback to monomers sample path '${h}'.`),t=h),[this._jsonData,this._monomerLib]=await Promise.all([w(t),D(t)]),this._monomerLibWrapper=new A(this.monomerLib,this.jsonData)})()),this.initLibDataPromise}async getTranslationHelper(){return await o.functions.call(`${this.name}:getTranslationHelper`)}createSequenceValidator(e){return new C(e,this)}createFormatConverter(e,t){return new M(e,t,this)}createFormatDetector(e){return new P(e,this)}}async function D(e){const t=i.TaskBarProgressIndicator.create("Initializing Oligo Toolkit monomer library ...");try{const t=await(0,c.pj)(),n=(e.endsWith("/")?e:e+"/")+"monomer-lib.json";return await t.readLibraryFromFilePath(n)}finally{t.close()}}class B{constructor(e,t){this.appName=e,this.parentAppName=t}async getAppView(){const e=i.TaskBarProgressIndicator.create(`Loading ${this.appName}...`),t=o.shell.v?.root;t&&r.setUpdateIndicator(t,!0);try{return await this.constructView()}finally{e.close(),t&&r.setUpdateIndicator(t,!1)}}}class F extends B{constructor(e){super(e),this.view=i.View.create(),this.configureView()}async constructView(){await this.initView();const e=this.parentAppName?this.parentAppName+"/"+this.appName:this.appName;return this.view.path=`/apps/${br.name}/${e.replace(/\s/g,"")}/`,this.view}async initView(){const e=await this.getContent();this.view.append(e)}configureView(){this.view.box=!0,this.view.name=this.appName;const e=o.shell.windows;e.showProperties=!1,e.showToolbox=!1,e.showHelp=!1}getView(){return this.view}}const k=["SS","AS"],H={SS:"Sense strand",AS:"Anti sense"},G=["3'","5'"],U="OligoToolkit";var V,j,q,W;!function(e){e.IS_ANTISENSE_STRAND_INCLUDED="isAntisenseStrandIncluded",e.NUCLEOTIDE_SEQUENCES="nucleotideSequences",e.PHOSPHOROTHIOATE_LINKAGE_FLAGS="phosphorothioateLinkageFlags",e.STRAND_TERMINUS_MODIFICATIONS="strandTerminusModifications"}(V||(V={})),function(e){e.PATTERN_NAME="patternName",e.PATTERN_COMMENT="patternComment",e.NUCLEOTIDES_WITH_NUMERIC_LABELS="nucleotidesWithNumericLabels"}(j||(j={})),function(e){e.PATTERN_CONFIG="patternConfig",e.AUTHOR_ID="authorID",e.DATE="date"}(q||(q={})),function(e){e.CREATE="create",e.MODIFY="modify"}(W||(W={}));const z=[V.IS_ANTISENSE_STRAND_INCLUDED,V.NUCLEOTIDE_SEQUENCES,V.PHOSPHOROTHIOATE_LINKAGE_FLAGS,V.STRAND_TERMINUS_MODIFICATIONS],Y=(j.PATTERN_NAME,j.PATTERN_COMMENT,j.NUCLEOTIDES_WITH_NUMERIC_LABELS,{patternConfig:{patternName:"<default example>",isAntisenseStrandIncluded:!0,nucleotideSequences:{SS:["RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA"],AS:["RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA","RNA"]},phosphorothioateLinkageFlags:{SS:[!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0],AS:[!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0]},strandTerminusModifications:{SS:{"3'":"","5'":""},AS:{"3'":"","5'":""}},patternComment:"",nucleotidesWithNumericLabels:["RNA"]},authorID:""}),K="2024-01-01T18:00:00.000Z";class Q extends Error{constructor(e){super(e),this.name="PatternNameExistsError"}}class J extends Error{constructor(e){super(e),this.name="PatternExistsError"}}var X=n(4802),Z=n.n(X);class ee{constructor(e){this.th=e,this.otherUsersPatternNameToHash=new Map,this.currentUserPatternNameToHash=new Map}static async getInstance(){const e=await br.getTranslationHelper(),t=new ee(e);t.currentUserName=await t.fetchCurrentUserName(),t.currentUserId=await t.fetchCurrentUserId();const n=t.fetchPatterns();return await t.initializePatternMaps(n),t}getCurrentUserPatternNames(){return Array.from(this.currentUserPatternNameToHash.keys()).sort(((e,t)=>e.toLowerCase().localeCompare(t.toLowerCase())))}getOtherUsersPatternNames(){return Array.from(this.otherUsersPatternNameToHash.keys()).sort(((e,t)=>e.toLowerCase().localeCompare(t.toLowerCase())))}getCurrentUserName(){return this.currentUserName}validatePatternNameUniqueness(e){if(this.currentUserPatternNameToHash.has(e))throw new Q(`Pattern with name ${e} already exists`)}validatePatternUniqueness(e){if(Array.from(this.currentUserPatternNameToHash.values()).concat(Array.from(this.otherUsersPatternNameToHash.values())).includes(e))throw new J(e)}getPatternHash(e,t){const n=t?this.currentUserPatternNameToHash.get(e):this.otherUsersPatternNameToHash.get(e);if(void 0===n)throw new Error(`Pattern with name ${e} not found`);return n}async getPatternRecordByHash(e){if(null===e||""===e)return null;try{const t=o.userSettings.getValue(U,e,!1)??"null";return JSON.parse(t)}catch{return null}}async getPatternConfig(e){if(""===e||null===e)return null;const t=await this.getPatternRecordByHash(e);return null===t?null:t[q.PATTERN_CONFIG]}getDefaultPatternRecord(){const e=Y;return e[q.AUTHOR_ID]=this.currentUserId,e}getDefaultPatternConfig(){return Y[q.PATTERN_CONFIG]}getAuthorCategoryByHash(e){if(this.isCurrentUserPattern(e))return this.getCurrentUserAuthorshipCategory();if(this.isOtherUserPattern(e))return this.getOtherUsersAuthorshipCategory();throw new Error(`Pattern with hash ${e} not found`)}isCurrentUserPattern(e){return Array.from(this.currentUserPatternNameToHash.values()).includes(e)}isOtherUserPattern(e){return Array.from(this.otherUsersPatternNameToHash.values()).includes(e)}getPatternNameByHash(e){const t=[this.currentUserPatternNameToHash,this.otherUsersPatternNameToHash];for(const n of t)for(const[t,o]of n.entries())if(o===e)return t;throw new Error(`Pattern with hash ${e} not found`)}getHashOfPatternToBeLoadedAfterDeletion(){const e=this.getCurrentUserPatternNames()[0];if(!e)throw new Error("Cannot load pattern after deletion, as there are no patterns left");const t=this.currentUserPatternNameToHash.get(e);if(void 0===t)throw new Error(`Pattern with name ${e} not found`);return t}async getRecordFromPattern(e){return{[q.PATTERN_CONFIG]:e,[q.AUTHOR_ID]:await o.dapi.users.current().then((e=>e.id))}}getHash(e){const t=z.reduce(((t,n)=>(t[n]=e[n],t)),{});return Z().sha1(t)}async savePatternToUserStorage(e){const t=e.getPatternConfig();try{const n=this.getHash(t);this.validatePatternUniqueness(n);const r=t[j.PATTERN_NAME];this.validatePatternNameUniqueness(r);const i=await this.getRecordFromPattern(t),s=(new Date).toISOString();i[q.DATE]={[W.CREATE]:s,[W.MODIFY]:s};const a=JSON.stringify(i);o.userSettings.add(U,n,a,!1),this.currentUserPatternNameToHash.set(r,n),e.selectAuthor(this.getCurrentUserAuthorshipCategory()),e.updatePatternList(),e.requestPatternLoad(n),e.updateUrlState(n)}catch(e){if(e instanceof Q||e instanceof J)throw e;console.error("Error while saving pattern to user storage",e)}}async overwriteExistingPatternInUserStorage(e){const t=e.getPatternConfig(),n=t[j.PATTERN_NAME],r=this.currentUserPatternNameToHash.get(n);if(void 0===r)throw new Error("Old hash is undefined");const i=this.getHash(t),s=await this.getRecordFromPattern(t),a=(new Date).toISOString();s[q.DATE]={[W.MODIFY]:a};const l=o.userSettings.getValue(U,r,!1)??"null",c=JSON.parse(l);void 0!==c[q.DATE]&&null!=c[q.DATE][W.CREATE]&&(s[q.DATE][W.CREATE]=c[q.DATE][W.CREATE]);const u=JSON.stringify(s);o.userSettings.add(U,i,u,!1),o.userSettings.delete(U,r,!1),this.currentUserPatternNameToHash.set(n,i),e.requestPatternLoad(i),e.updateUrlState(i)}async deletePattern(e,t){const n=this.currentUserPatternNameToHash.get(e);if(e===this.getDefaultPatternName())return void o.shell.warning("Cannot delete default pattern");if(void 0===n)throw new Error(`Pattern with name ${e} not found`);o.userSettings.delete(U,n,!1),this.currentUserPatternNameToHash.delete(e),t.updatePatternList();const r=this.getHashOfPatternToBeLoadedAfterDeletion();t.requestPatternLoad(r)}fetchDefaultNucleobase(){return this.fetchAvailableNucleotideBases()[0]}fetchAvailableNucleotideBases(){const e=Object.keys(this.th.jsonData.patternAppData)[0];return Object.keys(this.th.jsonData.patternAppData[e])}async fetchCurrentUserName(){return(await o.dapi.users.current()).friendlyName}async fetchCurrentUserId(){return(await o.dapi.users.current()).id}fetchPatterns(){return o.userSettings.get(U,!1)??{}}async initializePatternMaps(e){if(!this.currentUserId)throw new Error("Current user ID is not set");const t=new Map;for(const[n,o]of Object.entries(e))await this.extractDataFromRecordToMaps(n,o,t);this.setDefaultPattern()}setDefaultPattern(){const e=Y[q.PATTERN_CONFIG];this.currentUserPatternNameToHash.set(e[j.PATTERN_NAME],"")}async extractDataFromRecordToMaps(e,t,n){const r=JSON.parse(t),i=r[q.PATTERN_CONFIG].patternName,s=r[q.AUTHOR_ID];if(this.isCurrentUserId(s))this.currentUserPatternNameToHash.set(i,e);else{if(!n.has(s)){let e="<UNKNOWN_USER>";try{e=(await o.dapi.users.find(s)).friendlyName}catch(e){}n.set(s,e)}const t=i+` (created by ${n.get(s)})`;this.otherUsersPatternNameToHash.set(t,e)}}getDefaultPatternName(){return Y[q.PATTERN_CONFIG][j.PATTERN_NAME]}getCurrentUserAuthorshipCategory(){return this.currentUserName+" (me)"}getOtherUsersAuthorshipCategory(){return"Other users"}isCurrentUserId(e){return e===this.currentUserId}}const te=rxjs,ne=rxjs.operators;function oe(e){return e.endsWith("(o)")}function re(e){const t=Object.values(e).flat().reduce(((e,t)=>(e[t]=(e[t]||0)+1,e)),{});return Object.entries(t).reduce(((e,t)=>e[1]>t[1]?e:t),["",0])[0]}var ie;function se(e){const t=Array.from(new Set(e));return Array.from(t).sort(((e,t)=>e.toLowerCase().localeCompare(t.toLowerCase())))}!function(e){e.getTruncatedStrandData=function(e,t,n){return{nucleotides:e.slice(0,n),ptoFlags:t.slice(0,n+1)}},e.getExtendedStrandData=function(e,t,n,o){const r=n-e.length,i=e.concat(new Array(n-e.length).fill(o)),s=0===e.length?n+1:r;return{nucleotides:i,ptoFlags:t.concat(new Array(s).fill(!0))}}}(ie||(ie={}));var ae=n(2543),le=n.n(ae);class ce{constructor(e,t){this.dataManager=e,this._patternListUpdated$=new te.Subject,this._patternLoadRequested$=new te.Subject,this._patternLoaded$=new te.Subject,this._uniqueNucleotides$=new te.BehaviorSubject([]),this._patternDeletionRequested$=new te.Subject,this._tableSelection$=new te.BehaviorSubject(null),this._svgSaveRequested$=new te.Subject,this._loadPatternInNewTabRequested$=new te.Subject,this._urlStateUpdated$=new te.Subject,this._patternHasUnsavedChanges$=new te.BehaviorSubject(!1),this._selectedStrandColumn=new te.BehaviorSubject(null),this._selectedIdColumn=new te.BehaviorSubject(null),this.initializeAuthorSelection(t),this.initializePatternState(t),this._lastLoadedPatternConfig=new te.BehaviorSubject(le().cloneDeep(this.getPatternConfig())),this.setupSubscriptions()}setupSubscriptions(){this._nucleotideSequences$.subscribe((()=>{this.updateUniqueNucleotides(),this.updateSequenceBase()})),this._isAntisenseStrandActive$.subscribe((e=>{e||G.forEach((e=>{this.updateTerminusModification("AS",e,"")}))})),this.patternStateChanged$.pipe((0,ne.debounceTime)(20)).subscribe((()=>{const e=this._lastLoadedPatternConfig.getValue(),t=this.getPatternConfig(),n=!le().isEqual(t,e);this._patternHasUnsavedChanges$.next(n)}))}updateUniqueNucleotides(){const e=(t=this._nucleotideSequences$.getValue(),se(Object.values(t).flat()));var t;this._uniqueNucleotides$.next(e)}updateSequenceBase(){const e=re(this._nucleotideSequences$.getValue());this._sequenceBase$.next(e)}get nucleotideSequencesChanged$(){return this._nucleotideSequences$.asObservable()}initializeAuthorSelection(e){const t=e[q.AUTHOR_ID];this.dataManager.isCurrentUserId(t)?this._patternAuthorSelection$=new te.BehaviorSubject(this.dataManager.getCurrentUserAuthorshipCategory()):this._patternAuthorSelection$=new te.BehaviorSubject(this.dataManager.getOtherUsersAuthorshipCategory())}initializePatternState(e){const t=e[q.PATTERN_CONFIG];this._patternName$=new te.BehaviorSubject(t[j.PATTERN_NAME]),this._isAntisenseStrandActive$=new te.BehaviorSubject(t[V.IS_ANTISENSE_STRAND_INCLUDED]),this._nucleotideSequences$=new te.BehaviorSubject(t[V.NUCLEOTIDE_SEQUENCES]),this._phosphorothioateLinkageFlags=new te.BehaviorSubject(t[V.PHOSPHOROTHIOATE_LINKAGE_FLAGS]),this._terminalModifications=new te.BehaviorSubject(t[V.STRAND_TERMINUS_MODIFICATIONS]),this._comment$=new te.BehaviorSubject(t[j.PATTERN_COMMENT]),this._modificationsWithNumericLabels$=new te.BehaviorSubject(t[j.NUCLEOTIDES_WITH_NUMERIC_LABELS]),this._sequenceBase$=new te.BehaviorSubject(re(t[V.NUCLEOTIDE_SEQUENCES]))}getPatternName(){return this._patternName$.getValue()}updatePatternName(e){this._patternName$.next(e)}get antisenseStrandToggled$(){return this._isAntisenseStrandActive$.asObservable()}isAntisenseStrandActive(){return this._isAntisenseStrandActive$.getValue()}toggleAntisenseStrand(e){e?this.updateStrandLength("AS",this.getNucleotideSequences().SS.length):this.updateStrandLength("AS",0),this._isAntisenseStrandActive$.next(e)}getNucleotideSequences(){return this._nucleotideSequences$.getValue()}updateNucleotideSequences(e){this._nucleotideSequences$.next(e)}updateStrandLength(e,t){const n=this.getNucleotideSequences()[e];if(n.length===t)return;const o=this.getPhosphorothioateLinkageFlags()[e];if(0===t)return void this.setNewStrandData([],[],e);if(n.length>t){const{nucleotides:r,ptoFlags:i}=ie.getTruncatedStrandData(n,o,t);return void this.setNewStrandData(r,i,e)}const r=this.getSequenceBase(),{nucleotides:i,ptoFlags:s}=ie.getExtendedStrandData(n,o,t,r);this.setNewStrandData(i,s,e)}setNewStrandData(e,t,n){this.updateNucleotideSequences({...this.getNucleotideSequences(),[n]:e}),this.updatePhosphorothioateLinkageFlags({...this.getPhosphorothioateLinkageFlags(),[n]:t})}getPhosphorothioateLinkageFlags(){return this._phosphorothioateLinkageFlags.getValue()}updatePhosphorothioateLinkageFlags(e){this._phosphorothioateLinkageFlags.next(e)}get phosphorothioateLingeFlagsChanged$(){return this._phosphorothioateLinkageFlags.asObservable()}getTerminalModifications(){return this._terminalModifications.getValue()}updateTerminalModifications(e){this._terminalModifications.next(e)}updateTerminusModification(e,t,n){const o=this.getTerminalModifications();o[e][t]=n,this.updateTerminalModifications(o)}terminalModificationsUpdated$(){return this._terminalModifications.asObservable()}getComment(){return this._comment$.getValue()}updateComment(e){this._comment$.next(e)}getModificationsWithNumericLabels(){return this._modificationsWithNumericLabels$.getValue()}updateModificationsWithNumericLabels(e){const t=function(e){return se(e).filter((e=>!oe(e)))}(e);this._modificationsWithNumericLabels$.next(t)}get patternLoadRequested$(){return this._patternLoadRequested$.asObservable()}requestPatternLoad(e){this._patternLoadRequested$.next(e)}get patternListUpdated$(){return this._patternListUpdated$.asObservable()}updatePatternList(){this._patternListUpdated$.next()}get tableSelectionChanged$(){return this._tableSelection$.asObservable()}selectTable(e){this._tableSelection$.next(e)}getTableSelection(){return this._tableSelection$.getValue()}requestPatternDeletion(e){this._patternDeletionRequested$.next(e)}get patternDeletionRequested$(){return this._patternDeletionRequested$.asObservable()}replaceSequenceBase(e){const t=this._nucleotideSequences$.getValue(),n={};k.forEach((o=>{n[o]=t[o].map((()=>e))})),this._nucleotideSequences$.next(n);const o=this._modificationsWithNumericLabels$.getValue();o.includes(e)||this.updateModificationsWithNumericLabels(o.concat(e))}get patternStateChanged$(){return te.merge(this._patternName$.pipe((0,ne.debounceTime)(300),(0,ne.map)((()=>{}))),this._isAntisenseStrandActive$,this._nucleotideSequences$,this._phosphorothioateLinkageFlags,this._terminalModifications,this._comment$.pipe((0,ne.debounceTime)(300)),this._modificationsWithNumericLabels$)}getSequenceBase(){return this._sequenceBase$.getValue()}uniqueNucleotidesChanged$(){return this.patternStateChanged$.pipe((0,ne.switchMap)((()=>this._uniqueNucleotides$)))}getUniqueNucleotides(){return this._uniqueNucleotides$.getValue()}get svgSaveRequested$(){return this._svgSaveRequested$.asObservable()}requestSvgSave(){this._svgSaveRequested$.next()}setAllPTOLinkages(e){const t=this.getPhosphorothioateLinkageFlags();k.forEach((n=>{t[n]=t[n].map((()=>e))})),this.updatePhosphorothioateLinkageFlags(t)}setPatternConfig(e){this._patternName$.next(e[j.PATTERN_NAME]),this._isAntisenseStrandActive$.next(e[V.IS_ANTISENSE_STRAND_INCLUDED]),this._nucleotideSequences$.next(e[V.NUCLEOTIDE_SEQUENCES]),this._phosphorothioateLinkageFlags.next(e[V.PHOSPHOROTHIOATE_LINKAGE_FLAGS]),this._terminalModifications.next(e[V.STRAND_TERMINUS_MODIFICATIONS]),this._comment$.next(e[j.PATTERN_COMMENT]),this._modificationsWithNumericLabels$.next(e[j.NUCLEOTIDES_WITH_NUMERIC_LABELS])}setLastLoadedPatternConfig(e){this._lastLoadedPatternConfig.next(le().cloneDeep(e))}getPatternConfig(){return{[j.PATTERN_NAME]:this.getPatternName(),[V.IS_ANTISENSE_STRAND_INCLUDED]:this.isAntisenseStrandActive(),[V.NUCLEOTIDE_SEQUENCES]:this.getNucleotideSequences(),[V.PHOSPHOROTHIOATE_LINKAGE_FLAGS]:this.getPhosphorothioateLinkageFlags(),[V.STRAND_TERMINUS_MODIFICATIONS]:this.getTerminalModifications(),[j.PATTERN_COMMENT]:this.getComment(),[j.NUCLEOTIDES_WITH_NUMERIC_LABELS]:this.getModificationsWithNumericLabels()}}setPhosphorothioateLinkageFlag(e,t,n){const o=this.getPhosphorothioateLinkageFlags();o[e][t]=n,this.updatePhosphorothioateLinkageFlags(o)}setNucleotide(e,t,n){const o=this.getNucleotideSequences();o[e][t]=n;const r=this.getModificationsWithNumericLabels();this.updateModificationsWithNumericLabels(r.concat(n)),this.updateNucleotideSequences(o)}get strandsUpdated$(){return te.merge(this._isAntisenseStrandActive$.asObservable().pipe((0,ne.map)((()=>{}))),this._nucleotideSequences$.asObservable().pipe((0,ne.map)((()=>{}))),this._patternLoaded$.asObservable().pipe((0,ne.map)((()=>{})))).pipe((0,ne.debounceTime)(10))}get strandsLinkagesAndTerminalsUpdated$(){return te.merge(this.strandsUpdated$,this._phosphorothioateLinkageFlags.asObservable().pipe((0,ne.map)((()=>{}))),this._terminalModifications.asObservable().pipe((0,ne.map)((()=>{}))))}updateControlsUponPatternLoaded(e){this._patternLoaded$.next(e)}get patternLoaded$(){return this._patternLoaded$.asObservable()}get userSelection$(){return this._patternAuthorSelection$.asObservable().pipe((0,ne.skip)(1))}selectAuthor(e){if("string"!=typeof e)throw new Error("Selected user must be defined");this._patternAuthorSelection$.next(e)}getSelectedAuthor(){return this._patternAuthorSelection$.getValue()}get loadPatternInNewTabRequested$(){return this._loadPatternInNewTabRequested$.asObservable()}requestLoadPatternInNewTab(e){this._loadPatternInNewTabRequested$.next(e)}updateUrlState(e){this._urlStateUpdated$.next(e)}get urlStateUpdated$(){return this._urlStateUpdated$.asObservable()}get patternHasUnsavedChanges$(){return this._patternHasUnsavedChanges$.asObservable()}selectStrandColumn(e,t){this._selectedStrandColumn.next({...this._selectedStrandColumn.getValue(),[e]:t})}getSelectedStrandColumn(e){const t=this._selectedStrandColumn.getValue();return t?t[e]:null}selectIdColumn(e){this._selectedIdColumn.next(e)}getSelectedIdColumn(){return this._selectedIdColumn.getValue()}get updateSvgContainer$(){return this.patternStateChanged$.pipe((0,ne.debounceTime)(100))}}const ue="pattern";class he{constructor(){this.urlSearchParams=new URLSearchParams(window.location.search)}subscribeToObservables(e){e.urlStateUpdated$.subscribe((e=>this.setPatternURL(e))),e.loadPatternInNewTabRequested$.subscribe((e=>{const t=`${window.location.origin}${window.location.pathname}?${ue}=${e}`;window.open(t,"_blank")})),window.addEventListener("popstate",(()=>{this.urlSearchParams=new URLSearchParams(window.location.search);const t=this.getPatternHash();null!==t&&e.requestPatternLoad(t)}))}getPatternHash(){return this.urlSearchParams.get(ue)}setPatternURL(e){null!==e&&""!==e?(this.urlSearchParams.set(ue,e),window.history.pushState({},"",`${window.location.pathname}?${this.urlSearchParams}`)):this.clearPatternURL()}clearPatternURL(){this.urlSearchParams.delete(ue),window.history.pushState({},"",`${window.location.pathname}`)}}var de=n(5072),pe=n.n(de),me=n(7825),fe=n.n(me),ge=n(7659),ye=n.n(ge),be=n(5056),ve=n.n(be),Ce=n(540),xe=n.n(Ce),we=n(1113),Ae=n.n(we),Te=n(9252),Ee={};Ee.styleTagTransform=Ae(),Ee.setAttributes=ve(),Ee.insert=ye().bind(null,"head"),Ee.domAPI=fe(),Ee.insertStyleElement=xe(),pe()(Te.A,Ee),Te.A&&Te.A.locals&&Te.A.locals;class Se{constructor(e){this.eventBus=e,this.columnControlsContainer=r.div([]),this.eventBus.tableSelectionChanged$.subscribe((()=>this.handleTableChoice())),this.refreshColumnControls()}getColumnControlsContainer(){return this.columnControlsContainer}get selectedTable(){return this.eventBus.getTableSelection()}handleTableChoice(){this.refreshColumnControls()}refreshColumnControls(){L()(this.columnControlsContainer).empty(),L()(this.columnControlsContainer).append(this.constructColumnControls())}constructColumnControls(){const e=this.createStrandColumnInput(),t=e.SS,n=e.AS;this.eventBus.antisenseStrandToggled$.subscribe((e=>{L()(n).toggle(e)}));const o=this.createIdColumnInput();return[t,n,o]}createStrandColumnInput(){const e=this.selectedTable?this.selectedTable.columns.names().sort(((e,t)=>e.localeCompare(t))):[];return Object.fromEntries(k.map((t=>{const n=r.input.choice(`${H[t]} column`,{value:e[0],items:e,onValueChanged:e=>this.eventBus.selectStrandColumn(t,e)});return this.eventBus.selectStrandColumn(t,e[0]),[t,n.root]})))}createIdColumnInput(){const e=this.selectedTable?this.selectedTable.columns.names():[],t=r.input.choice("ID column",{value:e[0],items:e,onValueChanged:e=>this.eventBus.selectIdColumn(e)});return this.eventBus.selectIdColumn(e[0]),t.root}}class Ne{constructor(e){this.eventBus=e,this.availableTables=[],this.tableInputContainer=r.div([]),this.subscribeToTableEvents(),this.refreshTableInput()}getTableInputContainer(){return this.tableInputContainer}subscribeToTableEvents(){o.events.onTableAdded.subscribe((e=>this.handleTableAdded(e))),o.events.onTableRemoved.subscribe((e=>this.handleTableRemoved(e))),this.eventBus.tableSelectionChanged$.subscribe((()=>this.handleTableChoice()))}getTableFromEventData(e){if(!e&&e.args&&e.args.dataFrame instanceof i.DataFrame)throw new Error("EventData does not contain a dataframe",e);return e.args.dataFrame}handleTableAdded(e){const t=this.getTableFromEventData(e);this.availableTables.some((e=>e.name===t.name))||(this.availableTables.push(t),this.eventBus.selectTable(t),this.refreshTableInput())}handleTableRemoved(e){const t=this.getTableFromEventData(e);this.availableTables=this.availableTables.filter((e=>e.name!==t.name));const n=this.availableTables[0];this.eventBus.selectTable(n||null),this.refreshTableInput()}refreshTableInput(){const e=this.createTableInput();L()(this.tableInputContainer).empty(),this.tableInputContainer.append(e.root)}createTableInput(){const e=this.eventBus.getTableSelection();return r.input.table("Tables",{value:e,items:this.availableTables,onValueChanged:e=>{null!==e&&this.eventBus.selectTable(e)}})}handleTableChoice(){const e=this.eventBus.getTableSelection();e&&(this.isTableDisplayed(e)||this.displayTable(e))}isTableDisplayed(e){return o.shell.tableNames.includes(e.name)}displayTable(e){const t=o.shell.v;o.shell.addTableView(e),o.shell.v=t}}function Ie(e,t,n,o){const r=function(e,t,n){const o=new Array(e.length+t.filter((e=>e)).length+G.length);o[0]=n["5'"],o[o.length-1]=n["3'"];let r=1;return t[0]&&(o[r]="ps",r++),e.forEach(((e,n)=>{o[n+r]=e,t[n+1]&&(o[n+r+1]="ps",r++)})),o}(e.split("").map(((e,n)=>{const o=function(e,t,n){const o=Object.keys(n.patternAppData)[0],r=n.patternAppData[o][t].substitution;return e.replace(/([AGCTU])/,r)}(e,t[n],br.jsonData);return o})),n,o);return r.join("")}class Me{constructor(e){this.eventBus=e,this.tableInputManager=new Ne(e),this.columnInputManager=new Se(e)}createControls(){const e=r.h1("Bulk convert"),t=this.tableInputManager.getTableInputContainer(),n=this.columnInputManager.getColumnControlsContainer(),o=r.bigButton("Convert",(()=>this.processConvertButtonClick()));return[e,t,n,r.buttonsInput([o])]}processConvertButtonClick(){!function(e){const t=e.getTableSelection();if(!t)return void o.shell.warning("Please select a table");const n=k.filter((t=>!("AS"===t&&!e.isAntisenseStrandActive()))).map((t=>({strand:t,column:e.getSelectedStrandColumn(t)}))).filter((e=>e.column));if(0===n.length)return void o.shell.warning("Select a sense strand column");const r=e.getSelectedIdColumn();if(!r)throw new Error("No ID column selected");t.getCol(r);const i=n.map((e=>({strand:e.strand,column:t.getCol(e.column)})));!function(e,t){const n=t.getNucleotideSequences();return e.every((e=>{const t=n[e.strand].length;return e.column.toList().every((e=>e.length===t))}))}(i,e)?o.shell.warning("Some strands in the table input do not match pattern length"):i.forEach((n=>{const o=n.column,r=n.strand,i=e.getNucleotideSequences()[r],s=e.getTerminalModifications()[r],a=e.getPhosphorothioateLinkageFlags()[r],l=`${e.getPatternName()}(${o.name})`;t.columns.addNewString(l).init((e=>Ie(o.get(e),i,a,s)))}))}(this.eventBus)}}class Pe{constructor(e,t,n){this.eventBus=e,this.initialPatternConfig=t,this.subscriptions=n}create(){return r.divV([r.h1("PTO"),r.divH([this.createAllPtoActivationInput().root,...this.createFirstPtoInputs().map((e=>e.root))],{style:{gap:"12px"}})])}areAllPtoLinkagesSet(e){return k.map((t=>e[t].filter((e=>e)).length)).reduce(((e,t)=>e+t),0)===k.map((e=>this.initialPatternConfig.nucleotideSequences[e].length)).reduce(((e,t)=>e+t),0)+k.filter((t=>e[t].length)).length}createAllPtoActivationInput(){const e=this.initialPatternConfig.phosphorothioateLinkageFlags,t=this.areAllPtoLinkagesSet(e),n=r.input.bool("All PTO",{value:t});n.onInput.subscribe((()=>{const e=n.value;this.eventBus.setAllPTOLinkages(e)}));const o=this.eventBus.phosphorothioateLingeFlagsChanged$.subscribe((()=>{const e=this.eventBus.getPatternConfig().phosphorothioateLinkageFlags,t=this.areAllPtoLinkagesSet(e);n.value=t}));return this.subscriptions.add(o),this.addStyleToPtoInput(n),r.tooltip.bind(n.captionLabel,"Activate all phosphothioates"),n}addStyleToPtoInput(e){const t=e.captionLabel;t.classList.add("ui-label-right"),Object.assign(t.style,{textAlign:"left",maxWidth:"100px",minWidth:"40px",width:"auto"})}createFirstPtoInputs(){return k.map((e=>{if(!this.eventBus.isAntisenseStrandActive()&&"AS"===e)return;const t=this.isFirstPtoActive(e),n=r.input.bool(`First ${e} PTO`,{value:t});n.onInput.subscribe((()=>{const t=n.value;this.eventBus.setPhosphorothioateLinkageFlag(e,0,t)}));const o=this.eventBus.phosphorothioateLingeFlagsChanged$.subscribe((t=>{const o=t[e][0];n.value=o}));return this.subscriptions.add(o),this.addStyleToPtoInput(n),r.tooltip.bind(n.captionLabel,`Activate first phosphothioate in ${e}`),n})).filter((e=>void 0!==e))}isFirstPtoActive(e){return this.initialPatternConfig.phosphorothioateLinkageFlags[e][0]}}class _e{constructor(e,t,n){this.eventBus=e,this.dataManager=t,this.subscriptions=n;const o=this.eventBus.nucleotideSequencesChanged$.subscribe((()=>{this.displayedInputLabels=this.computeDisplayedInputLabels()}));this.subscriptions.add(o)}create(){const e=k.map((e=>this.constructControlsPanel(e)));return r.divH(e,{style:{gap:"24px"}})}constructControlsPanel(e){if(!this.eventBus.isAntisenseStrandActive()&&"AS"===e)return r.div([]);const t=this.constructHeader(),n=this.createControls(e);return r.block([r.h1(`${H[e]}`),t,n],{style:{paddingTop:"12px"}})}constructHeader(){return r.divH([r.div([r.divText("#")],{style:{width:"20px"}}),r.block75([r.divText("Modification")]),r.div([r.divText("PTO")])])}createControls(e){const t=this.createNucleobaseInputs(e),n=this.createLabelDivs(e),o=this.createPTOFlagInputs(e);return r.div(t.map(((e,t)=>r.divH([n[t],r.block75([e.root]),o[t].root],{style:{alignItems:"center"}}))))}createNucleobaseInputs(e){const t=this.dataManager.fetchAvailableNucleotideBases().sort(((e,t)=>e.toLowerCase().localeCompare(t.toLowerCase())));return this.eventBus.getNucleotideSequences()[e].map(((n,o)=>{const i=r.input.choice("",{value:n,items:t});return i.onInput.subscribe((()=>{const t=i.value;this.eventBus.setNucleotide(e,o,t)})),i}))}createPTOFlagInputs(e){return this.eventBus.getPhosphorothioateLinkageFlags()[e].slice(1).map(((t,n)=>{const o=r.input.bool("",{value:t});o.onInput.subscribe((()=>{const t=o.value;this.eventBus.setPhosphorothioateLinkageFlag(e,n+1,t)}));const i=this.eventBus.phosphorothioateLingeFlagsChanged$.subscribe((t=>{const r=t[e][n+1];o.value=r}));return this.subscriptions.add(i),o}))}computeDisplayedInputLabels(){const e=this.eventBus.getNucleotideSequences(),t=new Map;return k.forEach((n=>{let o=1;const r=e[n].map((e=>{if(oe(e))return"";const t=String(o);return o++,t}));t.set(n,r)})),t}createLabelDivs(e){const t=this.createLabels(e).map((e=>r.div([e],{style:{width:"20px"}}))),n=this.eventBus.nucleotideSequencesChanged$.subscribe((()=>{this.createLabels(e).forEach(((e,n)=>{L()(t[n]).empty(),L()(t[n]).append(e)}))}));return this.subscriptions.add(n),t}createLabels(e){return this.eventBus.getNucleotideSequences()[e].map(((t,n)=>{const o=this.displayedInputLabels.get(e)[n];return r.label(o)}))}}class Le{constructor(){this.rxjsSubscriptions=[],this.dgSubscriptions=[]}add(e){e instanceof te.Subscription?this.rxjsSubscriptions.push(e):this.dgSubscriptions.push(e)}unsubscribeAll(){for(const e of[this.rxjsSubscriptions,this.dgSubscriptions])e.forEach((e=>e.unsubscribe())),e.length=0}}class Oe{constructor(e,t){this.eventBus=e,this.dataManager=t,this.subscriptions=new Le}static open(e,t){Oe.isDialogOpen||(Oe.instance||(Oe.instance=new Oe(e,t)),Oe.instance.openDialog())}openDialog(){this.initialPatternConfig=le().cloneDeep(this.eventBus.getPatternConfig()),Oe.isDialogOpen=!0,this.createDialog().show()}createDialog(){const e=r.divV([]);this.subscriptions.add(this.eventBus.strandsUpdated$.subscribe((()=>this.onStrandsUpdated(e))));const t=r.dialog("Edit strands").add(e).onOK((()=>{})).onCancel((()=>this.resetToInitialState()));return this.subscriptions.add(t.onClose.subscribe((()=>{Oe.isDialogOpen=!1,this.subscriptions.unsubscribeAll()}))),t}onStrandsUpdated(e){const t=new Pe(this.eventBus,this.initialPatternConfig,this.subscriptions).create(),n=new _e(this.eventBus,this.dataManager,this.subscriptions).create();L()(e).empty(),L()(e).append(t,n)}resetToInitialState(){this.eventBus.setPatternConfig(this.initialPatternConfig)}}Oe.isDialogOpen=!1;class Re{constructor(e){this.eventBus=e,this.subscriptions=new Le}static open(e){Re.isDialogOpen||(Re.instance||(Re.instance=new Re(e)),Re.instance.openDialog())}openDialog(){this.initialPatternConfig=le().cloneDeep(this.eventBus.getPatternConfig()),Re.isDialogOpen=!0,this.createDialog().show()}createDialog(){const e=r.divV([]);this.subscriptions.add(this.eventBus.strandsUpdated$.subscribe((()=>this.onStrandsUpdated(e))));const t=r.dialog("Edit terminal modifications").add(e).onOK((()=>{})).onCancel((()=>this.resetToInitialState()));return this.subscriptions.add(t.onClose.subscribe((()=>{Re.isDialogOpen=!1,this.subscriptions.unsubscribeAll()}))),t}onStrandsUpdated(e){const t=new $e(this.eventBus).create();L()(e).empty(),L()(e).append(t)}resetToInitialState(){this.eventBus.setPatternConfig(this.initialPatternConfig)}}Re.isDialogOpen=!1;class $e{constructor(e){this.eventBus=e}create(){const e=k.map((e=>this.constructControlsPanel(e)));return r.divH(e,{style:{gap:"24px"}})}constructControlsPanel(e){if(!this.eventBus.isAntisenseStrandActive()&&"AS"===e)return r.div([]);const t=this.createInputs(e);return r.block([r.h1(`${H[e]}`),t],{style:{paddingTop:"12px"}})}createInputs(e){const t=("SS"===e?[...G].reverse():G).map((t=>this.createInputForTerminus(e,t)));return r.form(t)}createInputForTerminus(e,t){const n=this.eventBus.getTerminalModifications()[e][t],o=r.input.textArea(t,{value:n});return this.applyStylingToInput(o),o.onInput.subscribe((()=>{const n=o.value;null!==n&&this.eventBus.updateTerminusModification(e,t,n)})),o}applyStylingToInput(e){const t=e.root.getElementsByTagName("textarea")[0];L()(t).css("resize","none")}}class De{constructor(e,t){this.eventBus=e,this.dataManager=t}createControls(){const e=this.createAntisenseStrandToggle(),t=this.createStrandLengthInputs(),n=t.SS.root,o=t.AS.root,i=this.createSequenceBaseInput().root,s=this.createPatternCommentInput().root,a=this.createPatternNameInputBlock(),l=this.createEditPatternButton(),c=this.createEditTerminalModificationsButton();return[r.h1("Edit"),e,n,o,i,a,s,r.buttonsInput([c,l])]}createEditPatternButton(){const e=r.button("Edit strands",(()=>Oe.open(this.eventBus,this.dataManager)));return r.tooltip.bind(e,"Edit strand modifications and PTOs"),e}createEditTerminalModificationsButton(){const e=r.button("Edit terminals",(()=>Re.open(this.eventBus)));return r.tooltip.bind(e,"Edit terminal modifications"),L()(e).css("margin-right","20px"),e}createAntisenseStrandToggle(){const e=r.input.toggle(`${H.AS} strand`,{value:this.eventBus.isAntisenseStrandActive()});return e.onInput.subscribe((()=>this.eventBus.toggleAntisenseStrand(e.value))),this.eventBus.patternLoaded$.subscribe((()=>{e.value=this.eventBus.isAntisenseStrandActive()})),e.setTooltip("Toggle antisense strand"),e.root}createStrandLengthInputs(){const e=e=>{const n=this.eventBus.getNucleotideSequences()[e].length,o=r.input.int(`${H[e]} length`,{value:n});return o.onInput.subscribe((()=>t(e,o))),this.eventBus.nucleotideSequencesChanged$.subscribe((()=>{o.value=this.eventBus.getNucleotideSequences()[e].length})),o.setTooltip(`Number of nucleotides in ${e}, including overhangs`),[e,o]},t=(e,t)=>{const n=t.value;null!==n&&(n<=0&&(o.shell.warning("Sequence length must be greater than 0"),t.value=1),n>34&&(o.shell.warning("Sequence length must be less than 35"),t.value=34),this.eventBus.updateStrandLength(e,t.value))},n=Object.fromEntries(k.map((t=>e(t))));return this.eventBus.antisenseStrandToggled$.subscribe((e=>{L()(n.AS.root).toggle(e)})),n}createSequenceBaseInput(){const e=this.dataManager.fetchAvailableNucleotideBases().sort(((e,t)=>e.toLowerCase().localeCompare(t.toLowerCase()))),t=this.dataManager.fetchDefaultNucleobase(),n=r.input.choice("Sequence basis",{value:t,items:e});return n.onInput.subscribe((()=>this.eventBus.replaceSequenceBase(n.value))),this.eventBus.nucleotideSequencesChanged$.subscribe((()=>{n.value=this.eventBus.getSequenceBase()})),n.setTooltip("Most frequent nucleobase in the strands"),n}createPatternCommentInput(){const e=r.input.textArea("Comment",{value:this.eventBus.getComment()});return L()(e.root).addClass("st-pattern-text-input"),e.onInput.subscribe((()=>this.eventBus.updateComment(e.value))),this.eventBus.patternLoaded$.subscribe((()=>{e.value=this.eventBus.getComment()})),e}createPatternNameInputBlock(){const e=r.input.textArea("Pattern name",{value:this.eventBus.getPatternName()});return L()(e.root).addClass("st-pattern-text-input"),e.onInput.subscribe((()=>this.eventBus.updatePatternName(e.value))),this.eventBus.patternLoaded$.subscribe((()=>{e.value=this.eventBus.getPatternName()})),e.setTooltip("Name under which pattern will be saved"),e.root}}class Be{constructor(e,t){this.eventBus=e,this.dataManager=t,this.subscriptions=new Le,this.authorSelectedByUser=!1,this.eventBus.patternLoadRequested$.subscribe((e=>this.handlePatternChoice(e))),this.eventBus.patternDeletionRequested$.subscribe((async e=>{await this.dataManager.deletePattern(e,this.eventBus)}))}async handlePatternChoice(e){let t=await this.dataManager.getPatternConfig(e);null===t&&(t=this.dataManager.getDefaultPatternConfig()),this.eventBus.setPatternConfig(t),this.eventBus.updateControlsUponPatternLoaded(e),this.eventBus.setLastLoadedPatternConfig(t)}isCurrentUserSelected(){return this.eventBus.getSelectedAuthor()!==this.dataManager.getOtherUsersAuthorshipCategory()}createControls(){const e=this.getPatternInputsContainer();return[r.h1("Load"),e]}getPatternInputsContainer(){const e=r.divH(this.createPatternInputs());return this.eventBus.patternListUpdated$.subscribe((()=>{this.subscriptions.unsubscribeAll(),L()(e).empty(),L()(e).append(this.createPatternInputs())})),e}createPatternInputs(){const e=this.createAuthorChoiceInput(),t=this.createPatternChoiceInputContainer(),n=this.createDeletePatternButton();return[e.root,t,n]}createPatternChoiceInputContainer(){const e=this.createPatternChoiceInput(),t=r.div([e.root]),n=this.eventBus.userSelection$.subscribe((()=>{L()(t).empty(),L()(t).append(this.createPatternChoiceInput().root)}));return this.subscriptions.add(n),t}createAuthorChoiceInput(){const e=[this.dataManager.getCurrentUserAuthorshipCategory()];this.dataManager.getOtherUsersPatternNames().length>0&&e.push(this.dataManager.getOtherUsersAuthorshipCategory());const t=r.input.choice("Author",{value:this.eventBus.getSelectedAuthor(),items:e});return t.onInput.subscribe((()=>{if(this.authorSelectedByUser=!0,null===t.value)throw new Error("author choice must be non-null");this.eventBus.selectAuthor(t.value)})),this.setAuthorChoiceInputStyle(t),t.setTooltip("Select pattern author"),t}setAuthorChoiceInputStyle(e){L()(e.input).css({"max-width":"100px","min-width":"100px"}),L()(e.root).css({"padding-right":"30px","padding-left":"30px"})}createPatternChoiceInput(){const e=this.isCurrentUserSelected()?this.dataManager.getCurrentUserPatternNames():this.dataManager.getOtherUsersPatternNames();if(this.authorSelectedByUser){const t=this.dataManager.getPatternHash(e[0],this.isCurrentUserSelected());this.eventBus.requestPatternLoad(t),this.eventBus.updateUrlState(t),this.authorSelectedByUser=!1}const t=this.getPatternName(e),n=r.input.choice("Pattern",{value:t,items:e});return n.setTooltip("Select pattern to load"),L()(n.input).css({"max-width":"100px","min-width":"100px"}),this.subscriptions.add(n.onInput.subscribe((()=>{const e=this.dataManager.getPatternHash(n.value,this.isCurrentUserSelected());this.eventBus.requestPatternLoad(e),this.eventBus.updateUrlState(e)}))),this.subscriptions.add(this.eventBus.patternLoaded$.subscribe((()=>{const t=this.eventBus.getPatternName();n.value!==t&&(n.value=this.getPatternName(e))}))),n}getPatternName(e){return e.find((e=>e.split(" (")[0]===this.eventBus.getPatternName()))??e[0]}createDeletePatternButton(){const e=r.button(r.iconFA("trash-alt"),(()=>{this.eventBus.getPatternName()!==this.dataManager.getDefaultPatternName()?this.showDeletePatternDialog():o.shell.warning("Cannot delete example pattern")}));r.tooltip.bind(e,"Delete pattern from user storage");const t=this.eventBus.userSelection$.subscribe((()=>{e.disabled=!this.isCurrentUserSelected()}));return this.subscriptions.add(t),e}showDeletePatternDialog(){const e=r.dialog("Delete pattern"),t=this.eventBus.getPatternName();e.add(r.divText(`Are you sure you want to delete pattern ${t}?`)),e.onOK((()=>this.eventBus.requestPatternDeletion(t))),e.show()}}class Fe{constructor(e,t){this.eventBus=e,this.dataManager=t}getLayout(){const e=new Be(this.eventBus,this.dataManager),t=new De(this.eventBus,this.dataManager),n=new Me(this.eventBus),o=e.createControls(),i=t.createControls(),s=n.createControls(),a=r.div(o);L()(a).css({"padding-bottom":"20px"});const l=r.div([...i,...s],"ui-form"),c=r.div([a,l]);return L()(c).css({padding:"25px"}),r.box(c,{style:{maxWidth:"450px"}})}}var ke=n(9146);class He{constructor(e,t,n){this.svgElementFactory=e,this.config=t,this.yShift=n}shiftElements(e){this.svgElements.forEach((t=>{const n=t.getAttribute("transform")||"",o=`translate(${e.x},${e.y})`;t.setAttribute("transform",`${n} ${o}`)}))}}class Ge{constructor(){}static getInstance(){return Ge.instance||(Ge.instance=new Ge,Ge.instance.canvas=document.createElement("canvas")),Ge.instance}static getTextDimensions(e,t){const n=Ge.getInstance().canvas.getContext("2d");if(!n)throw new Error("Canvas 2D context is not available");return n.font=`${t}px Arial`,{width:1.1*n.measureText(e).width,height:1.1*t}}}function Ue(e){const t=Object.keys(br.jsonData.patternAppData)[0];if(!t)throw new Error(`No format found in '${d}'`);return br.jsonData.patternAppData[t][e].color||""}class Ve extends He{constructor(e,t,n){super(e,t,n);const o=k.filter((e=>t.nucleotideSequences[e].length>0));this.strands=o.map((e=>new je(this.svgElementFactory,t,n,e))),this.terminalModifications=o.map(((e,o)=>new We(this.svgElementFactory,t,n,e,this.strands[o]))),this.labels=o.map(((e,o)=>new qe(this.svgElementFactory,t,n,e,this.terminalModifications[o])))}get svgElements(){return[...this.strands,...this.terminalModifications,...this.labels].map((e=>e.svgElements)).flat()}getContentWidth(){return Math.max(...this.labels.map((e=>e.getContentWidth())))}getContentHeight(){return this.strands.reduce(((e,t)=>e+t.getContentHeight()),0)}}class je extends He{constructor(e,t,n,o){super(e,t,n),this.svgElementFactory=e,this.config=t,this.yShift=n,this.strand=o,this.nucleotideNumericLabels=this.computeNucleotideNumericLabels(),"AS"===this.strand&&(this.config.phosphorothioateLinkageFlags[this.strand].reverse(),this.config.nucleotideSequences[this.strand].reverse(),this.nucleotideNumericLabels.reverse()),this._svgElements=[this.createStrandCircles(),this.createPTOLinkageStars()].flat()}computeNucleotideNumericLabels(){let e=0;return this.config.nucleotideSequences[this.strand].map((t=>oe(t)?null:(e++,e)))}get svgElements(){return this._svgElements}getStrandCircleYShift(){return ze(this.strand,this.yShift)}createStrandCircles(){const e={x:80,y:this.getStrandCircleYShift()};return this.config.nucleotideSequences[this.strand].map(((t,n)=>this.createNucleotideElementGroup(t,n,e))).flat()}createNucleotideElementGroup(e,t,n){return[...this.createNucleotideCircleElements(e,t,n),this.config.nucleotidesWithNumericLabels.includes(e)?this.createNucleotideNumericLabel(t,n):null].filter((e=>null!==e))}createNucleotideCircleElements(e,t,n){const o=Ue(e),r={...n,x:n.x+30*t};return[this.svgElementFactory.createCircleElement(r,15,o),this.createNucleotideLetterLabel(t,n,e)]}getNucleotideCircleCenterPosition(e,t){return{x:t.x+30*e,y:t.y}}createNucleotideLetterLabel(e,t,n){if(!g.AL.includes(n))return null;const o=function(e){return!oe(e)&&g.AL.includes(e)?e:""}(n),r=function(e){const t=Ue(e),n=t.match(/\d+/g)?.map(Number);if(!n||n.length<3)return"#ffffff";const[o,r,i]=n;return.299*o+.587*r+.114*i>186?"#333333":"#ffffff"}(n),i=this.getPositionForNucleotideLabel(e,t);return this.svgElementFactory.createTextElement(o,i,17,r)}getPositionForNucleotideLabel(e,t){const n=this.getNucleotideCircleCenterPosition(e,t),o=Ge.getTextDimensions("A",17);return{x:n.x-o.width/2,y:n.y+o.height/3}}getNumericLabelYShift(e){return"SS"===this.strand?e.y-20:e.y+15+5+15}createNucleotideNumericLabel(e,t){const n=this.nucleotideNumericLabels[e];if(null===n)return null;const o=Ge.getTextDimensions(n.toString(),15).width,r={x:t.x+30*e-o/2,y:this.getNumericLabelYShift(t)};return this.svgElementFactory.createTextElement(n.toString(),r,15,"var(--grey-6)")}createPTOLinkageStars(){const e=this.config.phosphorothioateLinkageFlags[this.strand],t=this.getStrandCircleYShift()+12;return e.map(((e,n)=>{if(!e)return null;const o={x:65+30*n,y:t};return this.svgElementFactory.createStarElement(o,"red")})).filter((e=>null!==e))}getContentWidth(){return 30*this.config.nucleotideSequences[this.strand].length}getContentHeight(){return 62}}class qe extends He{constructor(e,t,n,o,r){super(e,t,n),this.svgElementFactory=e,this.config=t,this.yShift=n,this.strand=o,this.terminalModifications=r,this._svgElements=this.createSVGElements()}createSVGElements(){return[this.createLeftLabel(),this.createRightLabel()]}getLeftLabelWidth(){return 55}getRightLabelWidth(){return 20}createLeftLabel(){const e="SS"===this.strand?"5'":"3'",t=`${this.strand}: ${e} `,n=Ge.getTextDimensions(t,17),o={x:10,y:ze(this.strand,this.yShift)+n.height/3};return this.svgElementFactory.createTextElement(t,o,17,"var(--grey-6)")}createRightLabel(){const e=" "+("SS"===this.strand?"3'":"5'"),t=Ge.getTextDimensions(e,17),n={x:65+this.terminalModifications.getContentWidth()+5,y:ze(this.strand,this.yShift)+t.height/3};return this.svgElementFactory.createTextElement(e,n,17,"var(--grey-6)")}get svgElements(){return this._svgElements}getContentWidth(){return this.terminalModifications.getContentWidth()+this.getLeftLabelWidth()+this.getRightLabelWidth()+10}getContentHeight(){return this.terminalModifications.getContentHeight()}}class We extends He{constructor(e,t,n,o,r){super(e,t,n),this.svgElementFactory=e,this.config=t,this.yShift=n,this.strand=o,this.strandSvgWrapper=r,this._svgElements=this.createSVGElements()}createSVGElements(){return this.createTerminalModifications()}getTerminalModification(e){return this.config.strandTerminusModifications[this.strand][e]}getTerminalModificationTextDimensions(e){const t=this.getTerminalModification(e);return Ge.getTextDimensions(t,17)}getLeftTerminus(){return"SS"===this.strand?"5'":"3'"}createTerminalModification(e){const t=this.getTerminalModification(e),n=this.getTerminalModificationTextDimensions(e),o=e===this.getLeftTerminus(),r={x:o?65:65+this.getTerminalModificationTextDimensions(this.getLeftTerminus()).width+this.strandSvgWrapper.getContentWidth(),y:ze(this.strand,this.yShift)+n.height/3};return o&&this.strandSvgWrapper.shiftElements({x:n.width,y:0}),this.svgElementFactory.createTextElement(t,r,17,"red")}createTerminalModifications(){return("AS"===this.strand?G:Array.from(G).reverse()).map((e=>this.createTerminalModification(e)))}get svgElements(){return this._svgElements}getContentWidth(){return this.strandSvgWrapper.getContentWidth()+G.map((e=>this.getTerminalModificationTextDimensions(e).width)).reduce(((e,t)=>e+t),0)}getContentHeight(){return this.strandSvgWrapper.getContentHeight()}}function ze(e,t){return"SS"===e?t+5+15+15:t+52+10+15}class Ye{constructor(){this.xmlNamespace="http://www.w3.org/2000/svg"}createElement(e){return document.createElementNS(this.xmlNamespace,e)}setAttributes(e,t){Object.entries(t).forEach((([t,n])=>{e.setAttribute(t,String(n))}))}createCanvas(e,t){const n=this.createElement("svg");return this.setAttributes(n,{id:"mySvg",width:e,height:t}),n}createCircleElement(e,t,n){const o=this.createElement("circle");return this.setAttributes(o,{cx:e.x,cy:e.y,r:t,fill:n}),o}createTextElement(e,t,n,o){const r=this.createElement("text");return this.setAttributes(r,{x:t.x,y:t.y,"font-size":n,"font-weight":"normal","font-family":"Arial",fill:o}),r.textContent=e,r}createStarElement(e,t){const n=this.createElement("polygon"),o=this.computeStarVertexCoordinates(e).map((e=>e.join(","))).join(" ");return this.setAttributes(n,{points:o,fill:t}),n}computeStarVertexCoordinates(e){const t=Math.PI/5,n=-t/2;return Array.from({length:10},((o,r)=>{const i=r%2==0?6:3,s=r*t+n;return[e.x+Math.cos(s)*i,e.y+Math.sin(s)*i]}))}createRectangleElement(e,t,n,o){const r=this.createElement("rect");return this.setAttributes(r,{x:e.x,y:e.y,width:t,height:n,fill:o}),r}}class Ke extends He{constructor(e,t,n){super(e,t,n),this.svgElementFactory=e,this.config=t,this.yShift=n,this._svgElements=[],this.titleText=this.getTitleText(),this._svgElements=[this.getTitle()]}get svgElements(){return this._svgElements}getTitle(){return this.svgElementFactory.createTextElement(this.titleText,{x:15,y:this.yShift+17},17,"black")}getContentWidth(){return Ge.getTextDimensions(this.titleText,17).width}getContentHeight(){return Ge.getTextDimensions(this.titleText,17).height}getTitleText(){const e=`${this.config.nucleotideSequences.SS.length}`,t=this.config.isAntisenseStrandIncluded?`/${this.config.nucleotideSequences.AS.length}`:"";return`${this.config.patternName} for ${e}${t}-mer`}}class Qe extends He{constructor(e,t,n){super(e,t,n),this._svgElements=[];const{elements:o,width:r}=this.createLegendItems();this._svgElements=o,this.width=r}isPhosphorothioatePresent(){return Object.values(this.config.phosphorothioateLinkageFlags).flat().some((e=>e))}getModificationTypesList(){return[...new Set(Object.values(this.config.nucleotideSequences).flat().sort(((e,t)=>e.toLowerCase().localeCompare(t.toLowerCase()))))]}get svgElements(){return this._svgElements}createLegendItem(e,t){const n={x:t,y:this.yShift-6},o=e.includes("linkage")?this.svgElementFactory.createStarElement(n,"red"):this.svgElementFactory.createCircleElement(n,6,Ue(e));t+=12;const r={y:this.yShift,x:t};return{elements:[o,this.svgElementFactory.createTextElement(e,r,15,"var(--grey-6)")],width:12+Ge.getTextDimensions(e,15).width}}createLegendItems(){let e=10;const t=[],n=t=>e+=t+15;if(this.isPhosphorothioatePresent()){const{elements:o,width:r}=this.createLegendItem("PTO linkage",e);n(r),t.push(o)}return this.getModificationTypesList().forEach((o=>{const{elements:r,width:i}=this.createLegendItem(o,e);n(i),t.push(r)})),{elements:t.flat(),width:e}}getContentHeight(){return 20}getContentWidth(){return this.width}}class Je{constructor(e){this.svgElementFactory=new Ye;const t=le().cloneDeep(e);let n=10;this.title=new Ke(this.svgElementFactory,t,n),n+=this.title.getContentHeight(),this.strands=new Ve(this.svgElementFactory,t,n),n+=this.strands.getContentHeight()+10,this.legend=new Qe(this.svgElementFactory,t,n)}renderPattern(){const e=this.getGlobalWidth(),t=this.getGlobalHeight(),n=this.svgElementFactory.createCanvas(e,t),o=[this.title,this.strands,this.legend].map((e=>e.svgElements)).flat();return n.append(...o),n}getGlobalWidth(){const e=[this.title,this.strands,this.legend];return Math.max(...e.map((e=>e.getContentWidth())))}getGlobalHeight(){return[this.title,this.strands,this.legend].reduce(((e,t)=>e+t.getContentHeight()),10)}}class Xe{constructor(e){this.eventBus=e,this.svgDisplayDiv=r.div([]),e.updateSvgContainer$.subscribe((()=>this.updateSvgContainer())),e.svgSaveRequested$.subscribe((()=>this.saveSvgAsPng()))}static createSvgDiv(e){return new Xe(e).svgDisplayDiv}updateSvgContainer(){$(this.svgDisplayDiv).empty();const e=this.eventBus.getPatternConfig();this.svgElement=this.createSvg(e),this.svgDisplayDiv.append(this.svgElement)}createSvg(e){return new Je(e).renderPattern()}saveSvgAsPng(){const e=this.eventBus.getPatternName();ke.saveSvgAsPng(this.svgElement,e,{backgroundColor:"white"})}}class Ze{constructor(e){this.eventBus=e,this.togglesContainer=r.div([]),this.eventBus.uniqueNucleotidesChanged$().subscribe((()=>{this.updateContainer()}))}getContainer(){return this.togglesContainer}updateContainer(){L()(this.togglesContainer).empty(),L()(this.togglesContainer).append(this.createInputs())}createInputs(){const e=this.eventBus.getUniqueNucleotides().filter((e=>!oe(e))).map((e=>this.createSingleInput(e)));return e.sort(((e,t)=>e.captionLabel.textContent.localeCompare(t.captionLabel.textContent))),r.divH(e.map((e=>e.root)))}createSingleInput(e){const t=this.eventBus.getModificationsWithNumericLabels().includes(e),n=r.input.bool(e,{value:t,onValueChanged:t=>this.handleNumericLabelToggle(e,t)});return L()(n.root).css("padding-right","20px"),n.setTooltip(`Show numeric labels for ${e}`),n}handleNumericLabelToggle(e,t){const n=this.eventBus.getModificationsWithNumericLabels();if(n.includes(e)===t)return;const o=t?n.concat(e):n.filter((t=>t!==e));this.eventBus.updateModificationsWithNumericLabels(o)}}class et{constructor(e,t){this.eventBus=e,this.dataManager=t,this.subscriptions=new Le}createContainer(){return r.div([r.h1("Translation example"),this.createTranslationExamples()],{style:{paddingTop:"20px"}})}createTranslationExamples(){const e=r.divH([...this.getExampleElements()],"ui-form");return this.eventBus.antisenseStrandToggled$.subscribe((()=>{this.subscriptions.unsubscribeAll(),L()(e).empty(),L()(e).append(this.getExampleElements())})),e}getExampleElements(){return k.map((e=>new tt(e,this.eventBus,this.subscriptions).create()))}}class tt{constructor(e,t,n){this.strand=e,this.eventBus=t,this.subscriptions=n}create(){return this.eventBus.isAntisenseStrandActive()||"AS"!==this.strand?(this.inputExample=this.createInputExample(),this.outputExample=this.createOutputExample(this.inputExample.value),this.subscribeToEvents(),r.block50([r.h2(H[this.strand]),this.inputExample.root,this.outputExample.root],{style:{paddingRight:"20px"}})):r.div([])}subscribeToEvents(){const e=this.eventBus.strandsLinkagesAndTerminalsUpdated$.subscribe((()=>{const e=this.generateExampleSequence();this.inputExample.value=e,this.outputExample.value=this.computeOutputValue(e)}));"AS"===this.strand&&this.subscriptions.add(e)}createInputExample(){const e=this.createTextInputForExamples(),t=this.generateExampleSequence();return e.value=t,e.setTooltip(`Example raw nucleotides input for ${H[this.strand]}`),e}generateExampleSequence(){return this.eventBus.getNucleotideSequences()[this.strand].map(((e,t)=>g.AL[t%g.AL.length])).join("")}createOutputExample(e){const t=this.createTextInputForExamples();return t.value=this.computeOutputValue(e),t.setTooltip(`Pattern applied to the example input for ${H[this.strand]}`),t}computeOutputValue(e){const t=this.eventBus.getNucleotideSequences()[this.strand],n=this.eventBus.getTerminalModifications()[this.strand];return Ie(e,t,this.eventBus.getPhosphorothioateLinkageFlags()[this.strand],n)}createTextInputForExamples(){const e=r.input.textArea("",{value:""});return this.applyStylingToInput(e),e}applyStylingToInput(e){const t=e.root.getElementsByTagName("textarea")[0];t.setAttribute("readonly","true"),L()(t).css("resize","none"),L()(e.root).css("opacity","75%")}}class nt{constructor(e,t){this.eventBus=e,this.dataManager=t,this.svgDisplay=Xe.createSvgDiv(e)}getLayout(){const e=new Ze(this.eventBus).getContainer(),t=this.generateDownloadControls(),n=new et(this.eventBus,this.dataManager).createContainer();return r.panel([this.svgDisplay,e,t,n],{style:{overflowX:"scroll",padding:"12px 24px"}})}generateDownloadControls(){return r.divH([this.createSavePatternButton(),this.createDownloadPngButton(),this.createShareLinkButton(),this.createInfoButton()],{style:{gap:"12px",marginTop:"12px"}})}createDownloadPngButton(){const e=r.button("Get PNG",(()=>this.eventBus.requestSvgSave()));return r.tooltip.bind(e,"Download pattern as PNG"),e}createInfoButton(){const e=r.button(r.iconFA("info-circle"),(()=>this.openInfoDialog()));return this.eventBus.patternHasUnsavedChanges$.subscribe((t=>{e.disabled=t})),r.tooltip.bind(e,"View pattern metadata"),e}async openInfoDialog(){let e=this.dataManager.getCurrentUserName(),t=this.dataManager.getDefaultPatternName(),n=K,i=K;const s=new URLSearchParams(window.location.search).get("pattern");if(null!==s){const r=await this.dataManager.getPatternRecordByHash(s);if(null!==r){const s=r[q.AUTHOR_ID];if(e=(await o.dapi.users.find(s)).friendlyName,t=r[q.PATTERN_CONFIG][j.PATTERN_NAME],void 0!==r[q.DATE]){const e=r[q.DATE][W.CREATE];void 0!==e&&(n=e);const t=r[q.DATE][W.MODIFY];void 0!==t&&(i=t)}}}const a=r.divV([r.divText(`Pattern Name: ${t}`),r.divText(`Author: ${e}`),r.divText(`Created: ${rt(new Date(n))}`),r.divText(`Modified: ${rt(new Date(i))}`)]);o.shell.info(a)}createShareLinkButton(){const e=r.button(r.iconFA("link"),(()=>navigator.clipboard.writeText(window.location.href).then((()=>o.shell.info("Link to pattern copied to clipboard")))));return this.eventBus.patternHasUnsavedChanges$.subscribe((t=>{e.disabled=t})),r.tooltip.bind(e,"Share pattern link"),e}createSavePatternButton(){const e=r.button("Save",(()=>this.processSaveButtonClick()));return this.eventBus.patternHasUnsavedChanges$.subscribe((t=>{e.disabled=!t})),r.tooltip.bind(e,"Save pattern to user storage"),e}processSaveButtonClick(){const e=this.eventBus.getPatternName();e!==this.dataManager.getDefaultPatternName()?""!==e?this.dataManager.savePatternToUserStorage(this.eventBus).then((()=>{o.shell.info(`Pattern ${e} saved`)})).catch((e=>this.handleErrorWhileSavingPattern(e))):o.shell.warning("Insert pattern name"):o.shell.warning("Cannot save default pattern")}handleErrorWhileSavingPattern(e){e instanceof Q?new ot(this.eventBus,this.dataManager).show():e instanceof J?o.shell.warning(r.div([r.divText("Pattern already exists"),r.button("Load",(()=>{const t=e.message;this.eventBus.requestLoadPatternInNewTab(t)}))])):console.error("Error while saving pattern",e)}}class ot{constructor(e,t){this.eventBus=e,this.dataManager=t}show(){const e=this.eventBus.getPatternName(),t=r.dialog(`Pattern "${e}" already exists`);t.add(r.divText(`Pattern "${e}" already exists. Do you want to overwrite it?`)),t.show(),t.onOK((()=>this.processOverwriteNamesakePattern()))}processOverwriteNamesakePattern(){const e=this.eventBus.getPatternName();this.dataManager.overwriteExistingPatternInUserStorage(this.eventBus).then((()=>{o.shell.info(`Pattern ${e} overwritten`)})).catch((e=>{console.error("Error while overwriting pattern in user storage",e),o.shell.error("Error while overwriting pattern")}))}}function rt(e){return e.toLocaleString().split(":").slice(0,-1).join(":")}class it extends F{constructor(e){super("Oligo Pattern"),this.th=e}getContent(){return async function(){const e=await ee.getInstance(),t=new he,n=await async function(e,t){const n=t.getPatternHash();if(!n)return t.clearPatternURL(),e.getDefaultPatternRecord();let o=await e.getPatternRecordByHash(n);return o||(t.clearPatternURL(),o=e.getDefaultPatternRecord()),o}(e,t),o=new ce(e,n);t.subscribeToObservables(o);const i=new Fe(o,e).getLayout(),s=new nt(o,e).getLayout();return r.splitH([i,s],{},!0)}()}}var st=n(8507),at={};function lt(e){var t;return"string"==typeof e||e instanceof String?e:("object"==typeof e||e instanceof Object)&&"$thrownJsError"in e?lt(e.$thrownJsError):e instanceof Error?null!==(t=e.stack)&&void 0!==t?t:e.message:e.toString()}at.styleTagTransform=Ae(),at.setAttributes=ve(),at.insert=ye().bind(null,"head"),at.domAPI=fe(),at.insertStyleElement=xe(),pe()(st.A,at),st.A&&st.A.locals&&st.A.locals;var ct,ut=n(2074),ht={};ht.styleTagTransform=Ae(),ht.setAttributes=ve(),ht.insert=ye().bind(null,"head"),ht.domAPI=fe(),ht.insertStyleElement=xe(),pe()(ut.A,ht),ut.A&&ut.A.locals&&ut.A.locals;class dt{constructor(e,t,n=!0){this.textInputBase=e,this.painter=t,L()(this.root).addClass("st-colored-text-input"),n&&this.textInputBase.onChanged.subscribe((()=>{L()(this.textArea).css("height",0),L()(this.textArea).css("height",this.textArea.scrollHeight+"px")})),this.highlights=r.div([]),this.root.appendChild(this.highlights),this.colorize(),this.textInputBase.onChanged.subscribe((()=>this.colorize()))}get textArea(){return this.textInputBase.root.getElementsByTagName("textarea").item(0)}get inputBase(){return this.textInputBase}get root(){return this.textInputBase.root}colorize(){const e=this.painter(this.textInputBase.value);this.highlights.innerHTML="",e.forEach((e=>this.highlights.appendChild(e)))}}!function(e){e.TYPE="V2000",e[e.NUM_OF_HEADER_LINES=3]="NUM_OF_HEADER_LINES",e[e.NUM_OF_COUNTS_DIGITS=3]="NUM_OF_COUNTS_DIGITS",e[e.ATOM_TYPE_COL=4]="ATOM_TYPE_COL",e[e.FIRST_BONDED_ATOM_COL=1]="FIRST_BONDED_ATOM_COL",e[e.BOND_TYPE_COL=3]="BOND_TYPE_COL",e[e.RGP_SHIFT=8]="RGP_SHIFT",e[e.MAX_ATOM_COUNT=999]="MAX_ATOM_COUNT",e.RGP_LINE_START="M RGP",e.ATOM_ALIAS_LINE_START="A ",e.END="M END"}(ct||(ct={}));class pt{constructor(e){this.init(e)}init(e){this.fileContent=e.replace(/\r/g,""),this._atomCount=void 0,this._atomTypes=void 0,this._bondCount=void 0,this._bondTypes=void 0,this.xyzAtomCoordinates=void 0,this._pairsOfBondedAtoms=void 0}get atomCount(){return void 0===this._atomCount&&this.setAtomAndBondCounts(),this._atomCount}get bondCount(){return void 0===this._bondCount&&this.setAtomAndBondCounts(),this._bondCount}get x(){var e;return null!==(e=this.xyzAtomCoordinates)&&void 0!==e||(this.xyzAtomCoordinates=this.parseAtomCoordinates()),this.xyzAtomCoordinates.x}get y(){var e;return null!==(e=this.xyzAtomCoordinates)&&void 0!==e||(this.xyzAtomCoordinates=this.parseAtomCoordinates()),this.xyzAtomCoordinates.y}get z(){var e;return null!==(e=this.xyzAtomCoordinates)&&void 0!==e||(this.xyzAtomCoordinates=this.parseAtomCoordinates()),this.xyzAtomCoordinates.z}get atomTypes(){var e;return null!==(e=this._atomTypes)&&void 0!==e||(this._atomTypes=this.parseAtomTypes()),this._atomTypes}get pairsOfBondedAtoms(){var e;return null!==(e=this._pairsOfBondedAtoms)&&void 0!==e||(this._pairsOfBondedAtoms=this.parseBondedAtomPairs()),this._pairsOfBondedAtoms}get bondTypes(){var e;return null!==(e=this._bondTypes)&&void 0!==e||(this._bondTypes=this.parseBondTypes()),this._bondTypes}setAtomAndBondCounts(){const{atomCount:e,bondCount:t}=this.parseAtomAndBondCounts();this._atomCount=e,this._bondCount=t}getNextColumnIdx(e){for(;!this.isWhitespace(e);)++e;for(;this.isWhitespace(e);)++e;return e}shiftIdxToSpecifiedColumn(e,t){let n=e;const o=this.isWhitespace(n)?t:t-1;for(let e=0;e<o;e++)n=this.getNextColumnIdx(n);return n}parseAtomTypes(){const e=this.atomCount,t=new Array(e);let n=this.getAtomBlockIdx();for(let o=0;o<e;o++)n=this.shiftIdxToAtomType(n),t[o]=this.parseAtomType(n),n=this.getNextLineIdx(n);return t}parseAtomCoordinates(){const e=new Float32Array(this.atomCount),t=new Float32Array(this.atomCount),n=new Float32Array(this.atomCount);let o=this.getAtomBlockIdx();for(let r=0;r<this.atomCount;r++){o=this.shiftIdxToXColumn(o);for(const i of[e,t,n])i[r]=this.parseFloatValue(o),o=this.getNextColumnIdx(o);o=this.getNextLineIdx(o)}return{x:e,y:t,z:n}}parseBondedAtomPairs(){const e=new Array(this.bondCount);let t=this.getBondBlockIdx();for(let n=0;n<this.bondCount;n++){t=this.shiftIdxToBondedAtomsPair(t);const o=new Uint16Array(2);o[0]=this.parseIntValue(t),t=this.getNextColumnIdx(t),o[1]=this.parseIntValue(t),e[n]=o,t=this.getNextLineIdx(t)}return e}parseBondTypes(){const e=this.bondCount,t=new Uint16Array(e);let n=this.getBondBlockIdx();for(let o=0;o<e;o++)n=this.shiftIdxToBondType(n),t[o]=this.parseIntValue(n),n=this.getNextLineIdx(n);return t}isWhitespace(e){const t=this.fileContent[e];return" "===t||"\t"===t}getNextLineIdx(e){return"\n"!==this.fileContent[e]?this.fileContent.indexOf("\n",e)+1:e+1}parseFloatValue(e){return this.parseNumericValue(parseFloat,e)}parseIntValue(e){return this.parseNumericValue(parseInt,e)}parseNumericValue(e,t){let n=t+1;for(;!this.isWhitespace(n);)++n;return e(this.fileContent.substring(t,n))}}class mt extends pt{constructor(e){super(e),this.init(e)}init(e){super.init(e)}parseAtomType(e){let t=e,n=t;return this.isQuote(t)?(n=this.getNextIdenticalChar(t),t++):n=this.fileContent.indexOf(" ",n),this.fileContent.substring(t,n)}isQuote(e){const t=this.fileContent[e].charCodeAt(0);return 39===t||34===t}getNextIdenticalChar(e){const t=this.fileContent[e];return t?this.fileContent.indexOf(t,e+1):-1}isQuery(){return this.isQueryOrFragment(((e,t)=>{return 39===e||34===e||76===e&&!((n=this.fileContent.charCodeAt(t+1))>64&&n<91||n>96&&n<123);var n}))}isFragment(){return this.isQueryOrFragment((e=>82===e||42===e))}isQueryOrFragment(e){const t=this.atomCount;let n=this.getAtomBlockIdx();for(let o=0;o<t;o++){if(n=this.shiftIdxToAtomType(n),e(this.fileContent.charCodeAt(n),n))return!0;n=this.getNextLineIdx(n)}return!1}}class ft extends mt{constructor(e){super(e)}getAtomLines(){const e=this.getAtomBlockIdx(),t=this.getBondBlockIdx();return this.fileContent.substring(e,t).split("\n").slice(0,this.atomCount)}getBondLines(){const e=this.getBondBlockIdx();return this.fileContent.substring(e).split("\n").slice(0,this.bondCount)}getRGroupIdToAtomicIdxMap(){const e=new Map,t=this.fileContent.split("\n");t.filter((e=>e.startsWith(ct.RGP_LINE_START))).forEach((t=>{const n=this.getAtomIdxToRgpIdxList(t);for(const[t,o]of n){if(e.has(t))throw new Error(`R group ${t} is already in the map`);e.set(t,o)}}));const n=t.map(((e,t)=>{if(e.startsWith(ct.ATOM_ALIAS_LINE_START))return t})).filter((e=>void 0!==e)),o=n.map((e=>t[e])),r=n.map((e=>t[e+1]));o.forEach(((t,n)=>{const o=parseInt(t.split(/\s+/)[1])-1,i=parseInt(r[n].substring(1));if(e.has(i))throw new Error(`R group ${i} is already in the map`);e.set(i,o)}));const i=this.getRGroupAtomicIndices().filter((t=>!Array.from(e.values()).includes(t)));if(0!==i.length)throw new Error(`Unaccounted R group indices: ${i}`);return e}getAtomIdxToRgpIdxList(e){const t=e.split(/\s+/).filter((e=>e)).slice(3).map((e=>parseInt(e))),n=new Array(t.length/2);for(let e=0;e<t.length;e+=2)n[e/2]=[t[e+1],t[e]-1];return n}getRGroupAtomicIndices(){return this.atomTypes.map(((e,t)=>{if(e.includes("R#"))return t})).filter((e=>void 0!==e))}static isValidMolfile(e){return-1!==e.indexOf(ct.TYPE)&&-1!==e.indexOf(ct.END)}shiftIdxToAtomType(e){return this.shiftIdxToSpecifiedColumn(e,ct.ATOM_TYPE_COL)}getCountsLineIdx(){let e=0;for(let t=0;t<ct.NUM_OF_HEADER_LINES;++t)e=this.getNextLineIdx(e);return e}getAtomBlockIdx(){let e=this.getCountsLineIdx();return e=this.getNextLineIdx(e),e}shiftIdxToXColumn(e){return this.getNextColumnIdx(e)}shiftIdxToBondedAtomsPair(e){return this.shiftIdxToSpecifiedColumn(e,ct.FIRST_BONDED_ATOM_COL)}shiftIdxToBondType(e){return this.shiftIdxToSpecifiedColumn(e,ct.BOND_TYPE_COL)}getBondBlockIdx(){let e=this.getAtomBlockIdx();for(let t=0;t<this.atomCount;t++)e=this.getNextLineIdx(e);return e}parseAtomAndBondCounts(){let e=this.getCountsLineIdx(),t=e+ct.NUM_OF_COUNTS_DIGITS;const n=parseInt(this.fileContent.substring(e,t));return e=t,t+=ct.NUM_OF_COUNTS_DIGITS,{atomCount:n,bondCount:parseInt(this.fileContent.substring(e,t))}}}class gt extends mt{constructor(e){super(e),this.init(e)}getAtomLines(){const e=this.getAtomBlockIdx(),t=this.getBondBlockIdx();return this.fileContent.substring(e,t).split("\n").slice(0,this.atomCount)}getBondLines(){const e=this.getBondBlockIdx();return this.fileContent.substring(e).split("\n").slice(0,this.bondCount)}getRGroupIdToAtomicIdxMap(){const e=new Map;return this.getAtomLines().forEach(((t,n)=>{const o=t.match(/RGROUPS=\(([\d\s]+)\)/);if(o){const t=o[1].split(/\s+/).map((e=>parseInt(e)));if(t.length>2)throw new Error(`R group data ${t} has more than 2 elements`);const r=t[1];if(e.has(r))throw new Error(`R group ${r} is already in the map`);e.set(r,n)}})),e}shiftIdxToAtomType(e){return this.shiftIdxToSpecifiedColumn(e,4)}getCountsLineIdx(){return this.fileContent.indexOf("M V30 COUNTS ")}getAtomBlockIdx(){let e=this.fileContent.indexOf("M V30 BEGIN ATOM");return e=this.getNextLineIdx(e),e}shiftIdxToXColumn(e){let t=this.shiftIdxToAtomType(e);return this.isQuote(t)?(t=this.getNextIdenticalChar(t),t=this.getNextColumnIdx(t),t):this.shiftIdxToSpecifiedColumn(e,5)}shiftIdxToBondedAtomsPair(e){return this.shiftIdxToSpecifiedColumn(e,5)}shiftIdxToBondType(e){return this.shiftIdxToSpecifiedColumn(e,4)}getBondBlockIdx(){return this.getNextLineIdx(this.fileContent.indexOf("M V30 BEGIN BOND"))}static isValidMolfile(e){return-1!==e.indexOf("V3000")&&-1!==e.indexOf("M END")}parseAtomAndBondCounts(){let e=this.fileContent.indexOf("M V30 COUNTS ")+14,t=this.fileContent.indexOf(" ",e+1);const n=parseInt(this.fileContent.substring(e,t));return e=t+1,t=this.fileContent.indexOf(" ",e+1),{atomCount:n,bondCount:parseInt(this.fileContent.substring(e,t))}}}class yt{constructor(){}static getInstance(e){if(yt.isMolfileV2K(e))return new ft(e);if(yt.isMolfileV3K(e))return new gt(e);throw new Error("Malformed molfile")}static isMolfileV2K(e){return ft.isValidMolfile(e)}static isMolfileV3K(e){return gt.isValidMolfile(e)}}const bt=class extends Error{constructor(e){super(e)}};class vt{constructor(e){this.molblock=e}get molblock(){return this._validMolBlock}set molblock(e){if(""!==e){try{this.validateMolBlock(e)}catch(t){t instanceof bt&&(e="");const n=lt(t);console.error(n)}this._validMolBlock=e}else this._validMolBlock=e}validateMolBlock(e){if(""===e)throw new bt("MoleculeImage: invalid molblock")}async drawMolBlockOnCanvas(e){try{await o.functions.call("Chem:canvasMol",{x:0,y:0,w:e.width,h:e.height,canvas:e,molString:this.molblock,scaffoldMolString:"",options:{normalizeDepiction:!1,straightenDepiction:!1}})}catch(e){const t=lt(e);console.error(t)}}getMoleculeDimensions(){const e=yt.getInstance(this.molblock),t=Math.max(...e.x)-Math.min(...e.x);return{height:Math.max(...e.y)-Math.min(...e.y),width:t}}async zoomIn(){const e=r.dialog({title:"Molecule",showFooter:!1}),t=.7*L()(window).height(),n=this.getMoleculeDimensions(),o=t/n.height,i=t,s=n.width*o,a=r.canvas(s,i);await this.drawMolBlockOnCanvas(a);const l=r.block([a],{style:{overflowX:"scroll"}});e.add(l).showModal(!0),L()(e.root).find(".d4-dialog-contents").removeClass("ui-form"),L()(e.root).find(".d4-dialog-contents").removeClass("ui-panel"),L()(e.root).find(".d4-dialog-contents").addClass("ui-box"),L()(e.root).find(".d4-dialog-contents").css("padding","0")}async drawMolecule(e,t,n){e.innerHTML="";const o=r.canvas(t*window.devicePixelRatio,n*window.devicePixelRatio);o.style.width=`${t}px`,o.style.height=`${n}px`,o.style.cursor="zoom-in",this.drawMolBlockOnCanvas(o),o.addEventListener("click",(async()=>{await this.zoomIn()})),e.append(r.tooltip.bind(o,"Click to zoom"))}}class Ct extends Error{constructor(e,t){super(e,t)}}class xt{constructor(e,t){this.sequence=e,this.codeMap=t}parseSequence(){const e=this.parseRawSequence();return this.addLinkers(e)}addLinkers(e){const t=[];return e.forEach(((n,o)=>{const r=this.getSymbolForCode(n);o>0&&function(e){return br.jsonData.monomersWithPhosphate.left.includes(e)}(r)&&t.pop(),t.push(r);const i=wt(r),s=o===e.length-1,a=o+1<e.length&&wt(this.getSymbolForCode(e[o+1]));i||function(e){return br.jsonData.monomersWithPhosphate.right.includes(e)}(r)||a||s||t.push("p")})),t}getSymbolForCode(e){let t=this.codeMap.get(e);return t??(t=e),t}parseRawSequence(){const e=this.getAllCodesOfFormat(),t=[];let n=0;for(;n<this.sequence.length;){const o=e.find((e=>e===this.sequence.substring(n,n+e.length)));if(void 0===o)throw new Ct(`Unable to match a monomer for the rest of the sequence '${this.sequence.slice(n)}'.`);t.push(o),n+=o.length}return t}getAllCodesOfFormat(){return y(Array.from(this.codeMap.keys()))}}function wt(e){return br.jsonData.monomersWithPhosphate.phosphate.includes(e)}class At{constructor(e,t=!1,n){this.invert=t,this.lib=br.monomerLibWrapper;const o=this.lib.getCodeToSymbolMap(n);this.parser=new xt(e,o)}convert(){const e=this.parser.parseSequence(),t=[];e.forEach(((e,n)=>{const o=this.getMonomerMolfile(e,n);t.push(o)}));let n=this.getPolymerMolfile(t);return this.invert&&(n=this.reflect(n),n=this.invertBondConfiguration(n)),n}invertBondConfiguration(e){const t=e.indexOf("M V30 BEGIN BOND"),n=e.indexOf("M V30 END BOND");let o=e.substring(t,n);return o=o.replace(/(CFG=)([13])/g,((e,t,n)=>"1"===n?`${t}3`:"3"===n?`${t}1`:e)),e.substring(0,t)+o+e.substring(n)}getMonomerMolfile(e,t){const n=this.lib.getMolfileBySymbol(e);return this.lib.isModification(e)?0===t?this.reflect(n):n:this.rotateNucleotidesV3000(n)}getPolymerMolfile(e){return this.linkV3000(e)}reflect(e){const t=this.extractAtomDataV3000(e),n=t.atomIndex.length,o=t.atomIndex.indexOf(1),r=t.atomIndex.indexOf(n),i=(t.x[r]+t.x[o])/2,s=(t.y[r]+t.y[o])/2;for(let e=0;e<n;e++)t.x[e]-=i,t.y[e]-=s;for(let e=0;e<n;e++)t.x[e]=-t.x[e];const a=t.x[o];for(let e=0;e<n;e++)t.x[e]-=a;let l=e.indexOf("M V30 BEGIN ATOM");l=e.indexOf("\n",l);let c=l;for(let o=0;o<n;o++)l=e.indexOf("V30",l)+4,l=e.indexOf(" ",l)+1,l=e.indexOf(" ",l)+1,c=e.indexOf(" ",l)+1,c=e.indexOf(" ",c),l=(e=e.slice(0,l)+t.x[o]+" "+t.y[o]+e.slice(c)).indexOf("\n",l)+1;return e}extractAtomDataV3000(e){const t=this.extractAtomsBondsNumbersV3000(e);let n=e.indexOf("M V30 BEGIN ATOM");n=e.indexOf("\n",n);let o=n;const r=Array(t.natom),i=Array(t.natom),s=Array(t.natom),a=Array(t.natom);for(let l=0;l<t.natom;l++)n=e.indexOf("V30",n)+4,o=e.indexOf(" ",n),r[l]=parseInt(e.substring(n,o)),n=o+1,o=e.indexOf(" ",n),i[l]=e.substring(n,o),n=o+1,o=e.indexOf(" ",n),s[l]=parseFloat(e.substring(n,o)),n=o+1,o=e.indexOf(" ",n),a[l]=parseFloat(e.substring(n,o)),n=e.indexOf("\n",n)+1;return{atomIndex:r,atomType:i,x:s,y:a}}extractAtomsBondsNumbersV3000(e){let t=(e=e.replaceAll("\r","")).indexOf("COUNTS")+7,n=e.indexOf(" ",t);const o=parseInt(e.substring(t,n));return t=n+1,n=e.indexOf(" ",t),{natom:o,nbond:parseInt(e.substring(t,n))}}rotateNucleotidesV3000(e){const t=this.extractAtomDataV3000(e),n=t.atomIndex.length,o=t.atomIndex.indexOf(1),r=t.atomIndex.indexOf(n);n>8&&this.fix5Prime(t,o,r);const i=(t.x[r]+t.x[o])/2,s=(t.y[r]+t.y[o])/2;for(let e=0;e<n;e++)t.x[e]-=i,t.y[e]-=s;let a=0;if(0===t.x[o])a=t.y[o]>t.y[r]?Math.PI/2:3*Math.PI/2;else if(0===t.y[o])a=t.x[o]>t.x[r]?Math.PI:0;else{const e=t.y[o]/t.x[o];a=e>0?t.x[o]>0?Math.PI-Math.atan(e):2*Math.PI-Math.atan(e):t.x[o]>0?-Math.PI-Math.atan(e):Math.atan(e)}const l=Math.cos(a),c=Math.sin(a);for(let e=0;e<n;e++){const n=t.x[e];t.x[e]=n*l-t.y[e]*c,t.y[e]=n*c+t.y[e]*l}const u=t.x[o];for(let e=0;e<n;e++)t.x[e]-=u;let h=e.indexOf("M V30 BEGIN ATOM");h=e.indexOf("\n",h);let d=h;for(let o=0;o<n;o++)h=e.indexOf("V30",h)+4,h=e.indexOf(" ",h)+1,h=e.indexOf(" ",h)+1,d=e.indexOf(" ",h)+1,d=e.indexOf(" ",d),h=(e=e.slice(0,h)+t.x[o]+" "+t.y[o]+e.slice(d)).indexOf("\n",h)+1;return e}linkV3000(e,t=!0){let n="\n Datagrok macromolecule handler\n\n";n+=" 0 0 0 0 0 0 999 V3000\n",n+="M V30 BEGIN CTAB\n";let o="",r="",i="";const s=[];let a=0,l=0,c=0;for(let t=0;t<e.length;t++){const n=e[t].includes("MODIFICATION")&&0===t;let i=0;n&&(i=this.extractAtomDataV3000(e[t]).atomIndex.length),e[t]=e[t].replaceAll("(-\nM V30 ","(").replaceAll("-\nM V30 ","").replaceAll(" )",")");const u=this.extractAtomsBondsNumbersV3000(e[t]),h=this.extractAtomDataV3000(e[t]);let d=e[t].indexOf("M V30 BEGIN ATOM");d=e[t].indexOf("\n",d);let p=d,m=d;for(let o=0;o<u.natom;o++)if(1!==h.atomIndex[o]||0===t){p=e[t].indexOf("V30",p)+4,m=e[t].indexOf(" ",p);let o=0;n?(o=parseInt(e[t].substring(p,m)),1===o?o=i:o===i&&(o=1),o+=a):o=parseInt(e[t].substring(p,m))+a,e[t]=e[t].slice(0,p)+o+e[t].slice(m),p=e[t].indexOf(" ",p)+1,p=e[t].indexOf(" ",p)+1,m=e[t].indexOf(" ",p);const r=c-h.x[0];let s=Math.round(1e4*(parseFloat(e[t].substring(p,m))+r))/1e4;e[t]=e[t].slice(0,p)+s+e[t].slice(m),p=e[t].indexOf(" ",p)+1,m=e[t].indexOf(" ",p),s=Math.round(1e4*parseFloat(e[t].substring(p,m)))/1e4,e[t]=e[t].slice(0,p)+s+e[t].slice(m),p=e[t].indexOf("\n",p)+1}else p=e[t].indexOf("M V30",p)-1,m=e[t].indexOf("\n",p+1),e[t]=e[t].slice(0,p)+e[t].slice(m);const f=e[t].indexOf("M V30 END ATOM");o+=e[t].substring(d+1,f);let g=e[t].indexOf("M V30 BEGIN BOND");g=e[t].indexOf("\n",g),p=g,m=g;for(let o=0;o<u.nbond;o++){p=e[t].indexOf("V30",p)+4,m=e[t].indexOf(" ",p);const o=parseInt(e[t].substring(p,m))+l;e[t]=e[t].slice(0,p)+o+e[t].slice(m),p=e[t].indexOf(" ",p)+1,p=e[t].indexOf(" ",p)+1,m=e[t].indexOf(" ",p);let r=0;n?(r=parseInt(e[t].substring(p,m)),1===r?r=i:r===i&&(r=1),r+=a):r=parseInt(e[t].substring(p,m))+a,e[t]=e[t].slice(0,p)+r+e[t].slice(m),p=e[t].indexOf(" ",p)+1,m=Math.min(e[t].indexOf("\n",p),e[t].indexOf(" ",p)),r=0,n?(r=parseInt(e[t].substring(p,m)),1===r?r=i:r===i&&(r=1),r+=a):r=parseInt(e[t].substring(p,m))+a,e[t]=e[t].slice(0,p)+r+e[t].slice(m),p=e[t].indexOf("\n",p)+1}const y=e[t].indexOf("M V30 END BOND");r+=e[t].substring(g+1,y);let b=e[t].indexOf("M V30 MDLV30/STEABS ATOMS=(");for(;-1!==b;){b+=28;const n=e[t].indexOf(")",b);e[t].substring(b,n).split(" ").slice(1).forEach((e=>{s.push(parseInt(e)+a)})),b=n,b=e[t].indexOf("M V30 MDLV30/STEABS ATOMS=(",b)}a+=u.natom-1,l+=u.nbond,c+=n?Math.max(...h.x):h.x[u.natom-1]-h.x[0]}const u=Math.ceil(s.length/4);i+="M V30 MDLV30/STEABS ATOMS=("+s.length+" -\n";for(let e=0;e<u;e++){i+="M V30 ";const t=e+1===u?s.length-4*(u-1):4;for(let n=0;n<t;n++)i+=n+1===t?e===u-1?s[4*e+n]+")\n":s[4*e+n]+" -\n":s[4*e+n]+" "}return a++,n+="M V30 COUNTS "+a+" "+l+" 0 0 0\n",n+="M V30 BEGIN ATOM\n",n+=o,n+="M V30 END ATOM\n",n+="M V30 BEGIN BOND\n",n+=r,n+="M V30 END BOND\n",t&&s.length>0?(n+="M V30 BEGIN COLLECTION\n",n+=i,n+="M V30 END COLLECTION\n"):n=n.replace(/ CFG=\d/g," "),n+="M V30 END CTAB\n",n+="M END",n}fix5Prime(e,t,n){const o=t+1,r=e.x[o],i=e.y[o],s=e.x[n]-r,a=e.y[n]-i,l=e.x[t]-r,c=e.y[t]-i,u=l*Math.cos(2*Math.PI/3)-c*Math.sin(2*Math.PI/3),h=l*Math.sin(2*Math.PI/3)+c*Math.cos(2*Math.PI/3),d=l-s,p=c-a,m=u-s,f=h-a;Math.sqrt(f*f+m*m)>=Math.sqrt(p*p+d*d)&&(e.x[t]=u+r,e.y[t]=h+i)}}function Tt(e,t=!0){let n="\n Datagrok macromolecule handler\n\n";n+=" 0 0 0 0 0 0 999 V3000\n",n+="M V30 BEGIN CTAB\n";let o="",r="",i="";const s=[];let a=0,l=0,c=0;if(e.antiStrands.length>0)for(let t=0;t<e.antiStrands.length;t++)e.antiStrands[t]=Et(e.antiStrands[t]);let u=!1;const h=e.senseStrands.concat(e.antiStrands);let d=0;for(let t=0;t<h.length;t++){h[t]=h[t].replaceAll("(-\nM V30 ","(").replaceAll("-\nM V30 ","").replaceAll(" )",")");const n=St(h[t]),i=Nt(h[t]);if(t>=e.senseStrands.length?!1===u&&(u=!0,c=0):d=Math.min(d,Math.min(...i.y.filter((e=>e<0)))),u){const e=Math.min(...i.x)-c,t=Math.max(...i.y)+5;for(let t=0;t<i.x.length;t++)i.x[t]-=e;for(let e=0;e<i.y.length;e++)i.y[e]-=t-d}let p=h[t].indexOf("M V30 BEGIN ATOM");p=h[t].indexOf("\n",p);let m=p,f=p;for(let e=0;e<n.natom;e++){m=h[t].indexOf("V30",m)+4,f=h[t].indexOf(" ",m);const n=parseInt(h[t].substring(m,f))+a;h[t]=h[t].slice(0,m)+n+h[t].slice(f),m=h[t].indexOf(" ",m)+1,m=h[t].indexOf(" ",m)+1,f=h[t].indexOf(" ",m);let o=Math.round(1e4*i.x[e])/1e4;h[t]=h[t].slice(0,m)+o+h[t].slice(f),m=h[t].indexOf(" ",m)+1,f=h[t].indexOf(" ",m),o=Math.round(1e4*i.y[e])/1e4,h[t]=h[t].slice(0,m)+o+h[t].slice(f),m=h[t].indexOf("\n",m)+1}const g=h[t].indexOf("M V30 END ATOM");o+=h[t].substring(p+1,g);let y=h[t].indexOf("M V30 BEGIN BOND");y=h[t].indexOf("\n",y),m=y,f=y;for(let e=0;e<n.nbond;e++){m=h[t].indexOf("V30",m)+4,f=h[t].indexOf(" ",m);const e=parseInt(h[t].substring(m,f))+l;h[t]=h[t].slice(0,m)+e+h[t].slice(f),m=h[t].indexOf(" ",m)+1,m=h[t].indexOf(" ",m)+1,f=h[t].indexOf(" ",m);let n=parseInt(h[t].substring(m,f))+a;h[t]=h[t].slice(0,m)+n+h[t].slice(f),m=h[t].indexOf(" ",m)+1,f=Math.min(h[t].indexOf("\n",m),h[t].indexOf(" ",m)),n=parseInt(h[t].substring(m,f))+a,h[t]=h[t].slice(0,m)+n+h[t].slice(f),m=h[t].indexOf("\n",m)+1}const b=h[t].indexOf("M V30 END BOND");r+=h[t].substring(y+1,b);let v=h[t].indexOf("M V30 MDLV30/STEABS ATOMS=(");for(;-1!==v;){v+=28;const e=h[t].indexOf(")",v);h[t].substring(v,e).split(" ").slice(1).forEach((e=>{s.push(parseInt(e)+a)})),v=e,v=h[t].indexOf("M V30 MDLV30/STEABS ATOMS=(",v)}a+=n.natom,l+=n.nbond,c+=Math.max(...i.x)+5}const p=Math.ceil(s.length/4);i+="M V30 MDLV30/STEABS ATOMS=("+s.length+" -\n";for(let e=0;e<p;e++){i+="M V30 ";const t=e+1===p?s.length-4*(p-1):4;for(let n=0;n<t;n++)i+=n+1===t?e===p-1?s[4*e+n]+")\n":s[4*e+n]+" -\n":s[4*e+n]+" "}return n+="M V30 COUNTS "+a+" "+l+" 0 0 0\n",n+="M V30 BEGIN ATOM\n",n+=o,n+="M V30 END ATOM\n",n+="M V30 BEGIN BOND\n",n+=r,n+="M V30 END BOND\n",t&&s.length>0?(n+="M V30 BEGIN COLLECTION\n",n+=i,n+="M V30 END COLLECTION\n"):n=n.replace(/ CFG=\d/g," "),n+="M V30 END CTAB\n",n+="M END",n}function Et(e){const t=Nt(e),n=t.atomIndex.length,o=(Math.max(...t.x)+Math.min(...t.x))/2,r=(Math.max(...t.y)+Math.min(...t.y))/2;for(let e=0;e<n;e++)t.x[e]-=o,t.y[e]-=r;const i=Math.PI,s=Math.cos(i),a=Math.sin(i);for(let e=0;e<n;e++){const n=t.x[e];t.x[e]=n*s-t.y[e]*a,t.y[e]=n*a+t.y[e]*s}const l=Math.max(...t.y);for(let e=0;e<n;e++)t.x[e]+=o,t.y[e]-=l;let c=e.indexOf("M V30 BEGIN ATOM");c=e.indexOf("\n",c);let u=c;for(let o=0;o<n;o++)c=e.indexOf("V30",c)+4,c=e.indexOf(" ",c)+1,c=e.indexOf(" ",c)+1,u=e.indexOf(" ",c)+1,u=e.indexOf(" ",u),c=(e=e.slice(0,c)+t.x[o]+" "+t.y[o]+e.slice(u)).indexOf("\n",c)+1;return e}function St(e){let t=(e=e.replaceAll("\r","")).indexOf("COUNTS")+7,n=e.indexOf(" ",t);const o=parseInt(e.substring(t,n));return t=n+1,n=e.indexOf(" ",t),{natom:o,nbond:parseInt(e.substring(t,n))}}function Nt(e){const t=St(e);let n=e.indexOf("M V30 BEGIN ATOM");n=e.indexOf("\n",n);let o=n;const r=Array(t.natom),i=Array(t.natom),s=Array(t.natom),a=Array(t.natom);for(let l=0;l<t.natom;l++)n=e.indexOf("V30",n)+4,o=e.indexOf(" ",n),r[l]=parseInt(e.substring(n,o)),n=o+1,o=e.indexOf(" ",n),i[l]=e.substring(n,o),n=o+1,o=e.indexOf(" ",n),s[l]=parseFloat(e.substring(n,o)),n=o+1,o=e.indexOf(" ",n),a[l]=parseFloat(e.substring(n,o)),n=e.indexOf("\n",n)+1;return{atomIndex:r,atomType:i,x:s,y:a}}function It(e,t,n){if(""===e)return"";const o=n.createFormatDetector(e).getFormat();if(!o)return"";let r="";try{r=new At(e,t,o).convert()}catch(e){const t=lt(e);console.error(t)}return r}function Mt(e,t,n,o,r){const i=[e,t,n].filter((e=>""!==e.strand));return 1===i.length?It(i[0].strand,i[0].invert,r):Tt({senseStrands:[It(e.strand,e.invert,r)],antiStrands:[It(t.strand,t.invert,r),It(n.strand,n.invert,r)].filter((e=>""!==e))},o)}const Pt=["ss","as","as2"];class _t{constructor(){this.th=br,this.onInput=new te.Subject,this.onInvalidInput=new te.Subject,this.inputBase=Object.fromEntries(Pt.map((e=>{const t=r.input.textArea(e.toUpperCase(),{value:"",onValueChanged:()=>{this.onInput.next(),L()(t.root.getElementsByTagName("div")).css("padding-left","38px")}});return[e,t]}))),this.useChiralInput=r.input.bool("Use chiral",{value:!0}),this.saveAllStrandsInput=r.input.bool("Save as one entity",{value:!0}),r.tooltip.bind(this.saveAllStrandsInput.root,"Save SDF with all strands in one molfile"),this.directionInversion=Object.fromEntries(Pt.map((e=>[e,!1]))),this.moleculeImgDiv=r.block([]),L()(this.moleculeImgDiv).addClass("st-structure-mol-img"),i.debounce(this.onInput,300).subscribe((async()=>{await this.updateMoleculeImg()})),i.debounce(this.onInvalidInput,1e3).subscribe((async()=>{o.shell.warning("Insert Sense strand")}))}async getHtmlDivElement(e){const t=this.getTableInput(e),n=this.getBoolInputsAndButton();await this.updateMoleculeImg();const o=r.divH([this.moleculeImgDiv,n]);L()(o).addClass("st-structure-bottom");const i=r.divV([t,o]);return L()(i).addClass("st-structure-body"),i}getBoolInputsAndButton(){const e=r.buttonsInput([r.bigButton("Save SDF",(()=>{const e=this.getStrandData();!function(e,t,n,r,i,s){const a=[e.strand,t.strand,n.strand].filter((e=>""!==e));if(0===a.length||1===a.length&&""===e.strand)o.shell.warning("Enter SENSE_STRAND and optionally ANTISENSE_STRAND/AS2 to save SDF");else{let l;if(i)l=Mt(e,t,n,r,s)+"\n$$$$\n";else{const h=It(e.strand,e.invert,s),d=It(t.strand,t.invert,s),p=It(n.strand,n.invert,s);l=h+"\n> <Sequence>\nSense Strand\n$$$$\n",d&&(l+=d+"\n> <Sequence>\nAnti Sense\n$$$$\n"),p&&(l+=p+"\n> <Sequence>\nAnti Sense 2\n$$$$\n")}const c=new Date;function u(e){return e>=10?e.toString():"0"+e.toString()}b(`SequenceTranslator-${c.getFullYear()+"-"+u(c.getMonth()+1)+"-"+u(c.getDate())+"_"+u(c.getHours())+"-"+u(c.getMinutes())+"-"+u(c.getSeconds())}.sdf`,encodeURIComponent(l))}}(e.ss,e.as,e.as2,this.useChiralInput.value,this.saveAllStrandsInput.value,this.th)}))]),t=[this.saveAllStrandsInput.root,this.useChiralInput.root,e],n=r.divV(t);for(const e of t)L()(e).addClass("st-structure-bool-button-block");return n}getTableInput(e){const t=Object.fromEntries(Pt.map((t=>[t,new dt(this.inputBase[t],e.highlightInvalidSubsequence)]))),n=Object.fromEntries(Pt.map(((e,t)=>{const n=0===t?"5′ → 3′":"3′ → 5′";return[e,r.input.choice(`${e.toUpperCase()} direction`,{value:n,items:["5′ → 3′","3′ → 5′"]})]})));Pt.forEach(((e,t)=>{n[e].onChanged.subscribe((n=>{let o="3′ → 5′"===n;t>0&&(o=!o),this.directionInversion[e]=o,this.onInput.next()}))}));const o=["Sense Strand","Anti Sense","Anti Sense 2"],i=new Map(Pt.map(((e,t)=>[e,o[t]]))),s=(Object.fromEntries(Pt.map((e=>[e,r.label(i.get(e))]))),Object.fromEntries(Pt.map((e=>{const n=r.icons.delete((()=>{t[e].inputBase.value=""}),"Delete"),o=r.button(n,(()=>{}));return r.tooltip.bind(o,`Clear ${e.toUpperCase()}`),[e,n]})))),a=r.form([],"st-structure-inputs"),l=r.divV([],"st-structure-clear-buttons"),c=r.form([],"st-direction-inputs");for(const e of Pt)a.append(this.inputBase[e].root),l.append(s[e]),c.append(n[e].root);return r.divH([a,l,c])}getStrandData(){return Object.fromEntries(Pt.map((e=>{const t=this.directionInversion[e];return[e,{strand:this.inputBase[e].value.replace(/\s*/g,""),invert:t}]})))}getMolfile(e,t,n){return Mt(e,t,n,this.useChiralInput.value,this.th)}async updateMoleculeImg(){let e="";try{const t=this.getStrandData();Object.values(t).some((e=>""!==e.strand))&&(e=this.getMolfile(t.ss,t.as,t.as2))}catch(e){const t=lt(e);console.error(t)}const t=new vt(e);await t.drawMolecule(this.moleculeImgDiv,650,150)}}class Lt extends F{constructor(e){super("Oligo Structure"),this.th=e,this.layout=new _t}getContent(){return this.layout.getHtmlDivElement(this.th)}}var Ot=n(2003);async function Rt(e){try{const t={overflowX:"scroll"},n=r.div([],{style:t}),i=Nt(e),s=.7*L()(window).height(),a=Math.max(...i.x)-Math.min(...i.x),l=Math.max(...i.y)-Math.min(...i.y),c=s/l,u=c*a,h=c*l,d=r.canvas(u*window.devicePixelRatio,h*window.devicePixelRatio);d.style.width=`${u}px`,d.style.height=`${h}px`,await async function(e,t){await o.functions.call("Chem:canvasMol",{x:0,y:0,w:e.width,h:e.height,canvas:e,molString:t,scaffoldMolString:"",options:{normalizeDepiction:!1,straightenDepiction:!1}})}(d,e),n.appendChild(d),r.dialog("Molecule").add(n).showModal(!0)}catch(e){const t=lt(e);console.error(t)}}class $t{static async view(){const e=br.monomerLibWrapper.getTableForViewer();e.name="Monomer Library";const t=o.shell.addTableView(e);t.grid.props.allowEdit=!1,t.grid.onCellDoubleClick.subscribe((async e=>{const t=e.cell.value;"Molecule"===e.tableColumn?.semType&&await Rt(t)}))}}var Dt=n(3480),Bt=n(5067),Ft=n(5254),kt={};kt.styleTagTransform=Ae(),kt.setAttributes=ve(),kt.insert=ye().bind(null,"head"),kt.domAPI=fe(),kt.insertStyleElement=xe(),pe()(Ft.A,kt),Ft.A&&Ft.A.locals&&Ft.A.locals;const Ht=["Sequence"];class Gt{constructor(e){this.th=e,this.inputFormats=Object.keys(br.jsonData.codesToHelmDict).concat(g.NO.HELM),this.seqHelper=br.seqHelper,this.onInput=new te.Subject,this.moleculeImgDiv=r.div([]),this.moleculeImgDiv.className="mol-host",this.moleculeImgDiv.style.border="1px solid var(--grey-2)",this.moleculeImgDiv.style.borderRadius="1px",this.moleculeImgDiv.style.marginTop="12px",this.outputTableDiv=r.div([]),this.formatChoiceInput=r.input.choice("",{value:g.NO.HELM,items:this.inputFormats,onValueChanged:async(e,t)=>{this.format=e,this.updateTable(),await this.updateMolImg()}}),this.sequenceInputBase=r.input.textArea("",{value:"Afcgacsu",onValueChanged:()=>{this.onInput.next()}}),this.init(),i.debounce(this.onInput,300).subscribe((async()=>{this.init(),this.formatChoiceInput.value=this.format,this.updateTable(),await this.updateMolImg()})),this.eventBus=qt.getInstance()}async getHtmlElement(){const e=this.constructSingleSequenceControls(),t=this.constructBulkTranslationControls(),n=r.box(r.panel([e,t,r.block([r.box(this.moleculeImgDiv)])]));return this.formatChoiceInput.value=this.format,this.updateTable(),await this.updateMolImg(),n}constructBulkTranslationControls(){const e=r.h1("Bulk");r.tooltip.bind(e,"Bulk translation from table input");const t=new Ut(this.eventBus).createUIComponents(),n=r.input.choice("Input format",{value:g.NO.AXOLABS,items:this.inputFormats,onValueChanged:e=>this.eventBus.selectInputFormat(e)}),o=r.input.choice("Output format",{value:Bt.qP,items:(0,Dt.OT)(this.th),onValueChanged:e=>this.eventBus.selectOutputFormat(e)}),i=this.createConvertBulkButton(),s=r.div([...t,n,o,i],"ui-form");return r.block25([e,s])}createConvertBulkButton(){const e=r.bigButton("Convert",(()=>this.processConvertBulkButtonClick()));return r.tooltip.bind(e,"Convert sequences from table input"),L()(e).css({float:"right","margin-top":"20px"}),e}processConvertBulkButtonClick(){const e=this.eventBus.getSelectedTable();if(!e)return void o.shell.warning("No table selected");const t=this.eventBus.getSelectedInputFormat(),n=this.eventBus.getSelectedOutputFormat(),r=this.eventBus.getSelectedColumn("Sequence");if(!r)return void o.shell.warning("No sequence column selected");const s=`${r.name} (${n})`,a=i.Column.fromList(i.TYPE.STRING,s,r.toList().map((e=>(0,Dt.C6)(e,t,n,this.th))));if(n===Bt.qP||n===g.NO.HELM){a.semType=i.SEMTYPE.MACROMOLECULE;const e=n==Bt.qP?Ot.Hi.FASTA:Ot.Hi.HELM;a.meta.units=e;const t=this.seqHelper.getSeqHandler(a);(n==Bt.qP?this.seqHelper.setUnitsToFastaColumn:this.seqHelper.setUnitsToHelmColumn)(t)}e.columns.add(a),o.data.detectSemanticTypes(e),o.shell.v=o.shell.getTableView(e.name)}constructSingleSequenceControls(){const e=new dt(this.sequenceInputBase,(e=>O(e,this.th))),t=r.button("Get SDF",(()=>{this.saveMolfile()}),"Save structure as SDF"),n=r.button("Copy SMILES",(()=>{this.copySmiles()}),"Copy SMILES for the sequence"),o=r.div([this.formatChoiceInput]),i=r.button(r.icons.delete((()=>{e.inputBase.value=""}),"Delete"),(()=>{}));r.tooltip.bind(i,"Clear input");const s={format:o,textInput:e.root,clearBtn:i},a=r.table([s],(e=>[e.format,e.textInput,e.clearBtn]));a.classList.add("st-translator-input-table");const l=r.block([this.outputTableDiv,t,n]);return r.block75([r.h1("Single sequence"),a,l])}saveMolfile(){try{const e=new At(this.sequence,!1,this.formatChoiceInput.value).convert()+"\n$$$$";b(this.sequence+".sdf",encodeURIComponent(e))}catch(e){o.shell.warning("Unable to save SDF: "+e.message)}}copySmiles(){const e=i.chem.convert(this.molfile,i.chem.Notation.MolBlock,i.chem.Notation.Smiles);navigator.clipboard.writeText(e).then((()=>o.shell.info(Bt.n_)))}updateTable(){this.outputTableDiv.innerHTML="";const e=this.format?this.th.createSequenceValidator(this.sequence).getInvalidCodeIndex(this.format):0,t=(0,Dt.bD)(this.sequence,e,this.format,this.th),n=[];for(const e of Object.keys(t)){const i="indexOfFirstInvalidChar"in t?r.divH([]):r.link(t[e],(()=>navigator.clipboard.writeText(t[e]).then((()=>o.shell.info(Bt.n_)))),Bt.U_,"");n.push({format:e,sequence:i})}const i=r.table(n,(e=>[e.format,e.sequence]),["FORMAT","SEQUENCE"]);this.outputTableDiv.append(i),this.outputTableDiv.classList.add("st-translator-output-table")}async updateMolImg(){const e=new vt(this.molfile);await e.drawMolecule(this.moleculeImgDiv,500,170)}init(){this.sequence=this.getFormattedSequence(),this.format=this.th.createFormatDetector(this.sequence).getFormat(),this.molfile=this.getMolfile()}getFormattedSequence(){return this.sequenceInputBase.value.replace(/\s/g,"")}getMolfile(){if(!this.format)return"";if(this.format===g.NO.HELM){const e=this.th.createFormatConverter(this.sequence,this.format).convertTo(g.NO.AXOLABS);return new At(e,!1,g.NO.AXOLABS).convert()}return new At(this.sequence,!1,this.format).convert()}}class Ut{constructor(e){this.tableInputManager=new Vt(e),this.columnInputManager=new jt(e)}createUIComponents(){return[this.tableInputManager.getTableInputContainer(),this.columnInputManager.getColumnControlsContainer()]}}class Vt{constructor(e){this.eventBus=e,this.availableTables=[],this.tableInputContainer=r.div([]),this.subscribeToTableEvents(),this.refreshTableInput()}getTableInputContainer(){return this.tableInputContainer}subscribeToTableEvents(){o.events.onTableAdded.subscribe((e=>this.handleTableAdded(e))),o.events.onTableRemoved.subscribe((e=>this.handleTableRemoved(e))),this.eventBus.tableSelected$.subscribe((()=>this.handleTableChoice()))}getTableFromEventData(e){return e.args.dataFrame}handleTableAdded(e){const t=this.getTableFromEventData(e);this.availableTables.some((e=>e.name===t.name))||(this.availableTables.push(t),this.eventBus.selectTable(t),this.refreshTableInput())}handleTableRemoved(e){const t=this.getTableFromEventData(e);this.availableTables=this.availableTables.filter((e=>e.name!==t.name));const n=this.availableTables[0];this.eventBus.selectTable(n||null),this.refreshTableInput()}refreshTableInput(){const e=this.createTableInput();L()(this.tableInputContainer).empty(),this.tableInputContainer.append(e.root)}createTableInput(){const e=this.eventBus.getSelectedTable();return r.input.table("Table",{value:e,items:this.availableTables,onValueChanged:e=>{null!==e&&this.eventBus.selectTable(e)}})}handleTableChoice(){const e=this.eventBus.getSelectedTable();e&&(this.isTableDisplayed(e)||this.displayTable(e))}isTableDisplayed(e){return o.shell.tableNames.includes(e.name)}displayTable(e){const t=o.shell.v;o.shell.addTableView(e),o.shell.v=t}}class jt{constructor(e){this.eventBus=e,this.columnControlsContainer=r.div([]),this.eventBus.tableSelected$.subscribe((()=>this.handleTableChoice())),this.refreshColumnControls()}getColumnControlsContainer(){return this.columnControlsContainer}handleTableChoice(){this.refreshColumnControls()}refreshColumnControls(){const e=this.createColumnInputs();L()(this.columnControlsContainer).empty();const t=e.map((e=>e.root));this.columnControlsContainer.append(...t)}createColumnInputs(){const e=this.eventBus.getSelectedTable(),t=null!==e?e.columns.names().sort(((e,t)=>e.localeCompare(t))):[];return Ht.map((n=>this.createColumnInput(n,t,e)))}createColumnInput(e,t,n){const o=e.toLowerCase(),i=t.find((e=>e.toLowerCase().includes(o)))||t[0];return this.selectColumnIfTableNotNull(n,i,e),r.input.choice(`${e}`,{value:i,items:t,onValueChanged:t=>this.selectColumnIfTableNotNull(n,t,e)})}selectColumnIfTableNotNull(e,t,n){if(null!==e&&t){const o=e.col(t);o&&this.eventBus.selectColumn(n,o)}}}class qt{constructor(){this._tableSelection$=new te.BehaviorSubject(null),this._columnSelection=Object.fromEntries(Ht.map((e=>[e,new te.BehaviorSubject(null)]))),this._inputFormatSelection$=new te.BehaviorSubject(g.NO.AXOLABS),this._outputFormatSelection$=new te.BehaviorSubject(Bt.qP)}static getInstance(){return void 0===qt._instance&&(qt._instance=new qt),qt._instance}get tableSelected$(){return this._tableSelection$.asObservable()}getSelectedTable(){return this._tableSelection$.getValue()}selectTable(e){this._tableSelection$.next(e)}selectColumn(e,t){this._columnSelection[e].next(t)}getSelectedColumn(e){return this._columnSelection[e].getValue()}getSelectedInputFormat(){return this._inputFormatSelection$.getValue()}selectInputFormat(e){this._inputFormatSelection$.next(e)}selectOutputFormat(e){this._outputFormatSelection$.next(e)}getSelectedOutputFormat(){return this._outputFormatSelection$.getValue()}}class Wt extends F{constructor(e){super("Oligo Translator"),this.th=e,this.th=br,this.layout=new Gt(this.th);const t=r.iconFA("book",$t.view,"View monomer library");this.topPanel=[t],this.view.setRibbonPanels([this.topPanel])}getContent(){return this.layout.getHtmlElement()}}class zt extends F{constructor(e,t){super(e),this.content=t}getContent(){return Promise.resolve(this.content)}}class Yt extends B{constructor(e,t){super("Oligo Toolkit"),this.externalViewFactories=e,this.th=t;const n=this.getViewFactories(this.th);this.multiView=new i.MultiView({viewFactories:n})}getViewFactories(e){function t(t){i.View.create();const n=new t(e);return n.initView().catch((e=>console.error(`Failed to initialize ${t.name}: ${e}`))),()=>n.getView()}let n={TRANSLATOR:t(Wt),PATTERN:t(it),STRUCTURE:t(Lt)};return this.externalViewFactories&&(n=Object.assign({},n,this.externalViewFactories)),n}getCurrentPanePath(){let e=this.multiView.tabs.currentPane.name;return e=e.charAt(0).toUpperCase()+e.substring(1).toLowerCase(),`/apps/${br.name}/OligoToolkit/${e}`}setUrl(){this.multiView.path=this.getCurrentPanePath()}async constructView(){return this.multiView.tabs.onTabChanged.subscribe((()=>this.setUrl())),this.setUrl(),this.multiView}}function Kt(e){const t=r.input.textArea("",{value:""});return{coloredInput:new dt(t,e.highlightInvalidSubsequence),codes:e.jsonData.codesToSymbolsDict}}var Qt=n(5733),Jt=n(5613),Xt=n(1536);const Zt=110,en=90;function tn(e,t,n=!1){return r.divH([r.divText(e,{style:{color:"var(--grey-4, #888)",width:"90px",flexShrink:"0"}}),r.divText(t,{style:n?{fontFamily:"ui-monospace, Menlo, monospace",wordBreak:"break-all"}:{}})],{style:{gap:"6px"}})}let nn=null;function on(e,t,n){const o=[t];"sugar"===n?o.push((0,Xt.Jy)(t)):"phosphate"===n&&o.push((0,Xt.$T)(t));const r=e.getPolymerTypes().filter((e=>"RNA"===e||"CHEM"===e)).concat(e.getPolymerTypes().filter((e=>"RNA"!==e&&"CHEM"!==e)));for(const t of o)for(const n of r){const o=e.getMonomer(n,t);if(o&&o.molfile)return o.molfile}return null}function rn(e){let t=e.symbol;return"sugar"===e.kind?t=(0,Xt.Jy)(e.symbol):"phosphate"===e.kind&&(t=(0,Xt.$T)(e.symbol)),`${e.kind}:${t}`}function sn(e){const t=r.div([],{style:{borderRadius:"4px",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"10px",color:"var(--grey-4, #888)",textAlign:"center",padding:"4px"}}),n=r.divText(e,{style:{fontSize:"10px",color:"var(--grey-5, #555)",textAlign:"center",marginTop:"2px",letterSpacing:"0.04em",textTransform:"uppercase",fontWeight:"600"}});return{root:r.divV([t,n],{style:{display:"inline-flex"}}),body:t}}const an=new Map;function ln(e,t,n){try{let r=an.get(n);r||(r=o.chem.drawMolecule(t,Zt,en,!1),an.size>256&&an.clear(),an.set(n,r)),e.innerHTML="",e.appendChild(r)}catch{e.textContent="Render failed"}}const cn="OligoNucleotide";class un extends i.GridCellRenderer{constructor(){super(...arguments),this.modelCache=new Map,this.layoutCache=new Map}get name(){return cn}get cellType(){return cn}get defaultWidth(){return 320}get defaultHeight(){return 64}render(e,t,n,o,r,i,s){const a=i.cell.value;if(!a||!(0,Jt.yO)(a))return e.save(),e.beginPath(),e.rect(t,n,o,r),e.clip(),e.fillStyle="#8b949e",e.font="11px ui-monospace, Menlo, monospace",e.textBaseline="middle",e.textAlign="left",e.fillText(a??"",t+4,n+r/2),void e.restore();const l=this.getOrParse(a),c=(0,Qt.Z4)(e,t,n,o,r,l);this.layoutCache.set(this.cellKey(i),c),this.layoutCache.size>5e3&&this.layoutCache.clear()}onMouseMove(e,t){const n=e.cell.value;if(!n||!(0,Jt.yO)(n))return void r.tooltip.hide();const o=this.getOrParse(n),i=this.layoutCache.get(this.cellKey(e));if(!i)return;const s=e.bounds,a=t.offsetX-s.x,l=t.offsetY-s.y,u=(0,Qt.CB)(a,l,o,i);u?function(e,t,n){const o=function(e){const t=e.monomer,n=r.divText("",{style:{fontWeight:"600",marginBottom:"4px"}}),o=[];if(e.linkage){const t=(0,Xt.bM)(e.linkage.phosphateSymbol);n.textContent=`${t.meta.name} linkage`,o.push(tn("Strand","sense"===e.strand?"Sense":"Antisense"),tn("Between",`pos ${e.position+1} – ${e.position+2}`),tn("HELM symbol",`[${(0,Xt.$T)(e.linkage.phosphateSymbol)}]`,!0))}else if("nucleotide"===t.kind){const r=t,i=(0,Xt.xh)(r.sugar,r.base),s=(0,Xt.bM)(r.phosphate);n.textContent=`${r.base??"?"}${e.position+1} — ${i.meta.name}`,o.push(tn("Strand","sense"===e.strand?"Sense":"Antisense"),tn("Position",String(e.position+1)),tn("Base",r.base??"—"),tn("Sugar",i.meta.name),tn("3'-linkage",s.meta.name),tn("HELM",r.raw,!0))}else{const r=(0,Xt.rK)(t.symbol);n.textContent=r.meta.name,o.push(tn("Strand","sense"===e.strand?"Sense":"Antisense"),tn("Position",String(e.position+1)),tn("Type","Terminal conjugate / linker"),tn("HELM",t.raw,!0))}const i=r.div([],{style:{marginTop:"8px",display:"flex",flexDirection:"row",gap:"6px",flexWrap:"wrap"}});i.dataset.role="struct";const s=r.divText("Loading structures…",{style:{fontSize:"11px",color:"var(--grey-4, #888)"}});return i.appendChild(s),r.divV([n,...o,i],{style:{fontSize:"12px",lineHeight:"1.45",minWidth:"240px",maxWidth:"380px"}})}(e);r.tooltip.show(o,t+14,n+14),async function(e,t){const n=e.querySelector('[data-role="struct"]');if(!n)return;let o,i;if(t.linkage)o=[{label:"Linkage",symbol:t.linkage.phosphateSymbol,kind:"phosphate"}];else if("nucleotide"===t.monomer.kind){const e=t.monomer;o=[{label:"Sugar",symbol:e.sugar,kind:"sugar"}],e.base&&o.push({label:"Base",symbol:e.base,kind:"base"}),e.phosphate&&o.push({label:"3'-linkage",symbol:e.phosphate,kind:"phosphate"})}else o=[{label:"Conjugate",symbol:t.monomer.symbol,kind:"conjugate"}];try{i=await(nn||(nn=(async()=>(await(0,c.pj)()).getMonomerLib())()),nn)}catch{return n.innerHTML="",void n.appendChild(r.divText("Monomer library unavailable",{style:{fontSize:"11px",color:"var(--grey-4, #888)"}}))}n.innerHTML="";for(const e of o){const t=sn(e.label);n.appendChild(t.root);const o=on(i,e.symbol,e.kind);o?ln(t.body,o,rn(e)):t.body.textContent=`Not in HELMCore: ${e.symbol}`}}(o,e)}(u,t.clientX,t.clientY):r.tooltip.hide()}onMouseLeave(e,t){r.tooltip.hide()}getOrParse(e){let t=this.modelCache.get(e);return t||(t=(0,Jt.On)(e),this.modelCache.size>5e3&&this.modelCache.clear(),this.modelCache.set(e,t)),t}cellKey(e){const t=e.tableColumn;return`${t?.name??e.gridColumn?.name??"?"}@${t?.version??0}::${e.tableRowIndex??-1}`}}var hn=n(9154);function dn(e,t){e.set(t,(e.get(t)??0)+1)}function pn(e,t,n){const o=[],r=new Map;for(const[t,n]of e.entries()){const e=(0,Xt.xh)(t,null).meta;"RNA"!==e.short&&"DNA"!==e.short&&r.set(e.short,(r.get(e.short)??0)+n)}for(const[e,t]of r.entries())o.push(`${e} ×${t}`);const i=new Map;for(const[e,n]of t.entries()){const t=(0,Xt.bM)(e).meta;"PO"!==t.short&&i.set(t.short,(i.get(t.short)??0)+n)}for(const[e,t]of i.entries())o.push(`${e} ×${t}`);for(const[e,t]of n.entries())o.push(`${e} ×${t}`);return o.length?o.join(", "):"unmodified"}function mn(e,t){return r.divV([r.divText(e,{style:{fontWeight:"600",marginTop:"8px",marginBottom:"4px",color:"var(--grey-5, #555)",textTransform:"uppercase",fontSize:"10px",letterSpacing:"0.04em"}}),t])}const fn=/^(RNA|DNA|PEPTIDE|CHEM|BLOB)\d+\{/;function gn(e,t){const n=r.div([],{style:{minHeight:"60px"}});return n.appendChild(r.divText("Building structure…",{style:{fontSize:"11px",color:"var(--grey-4, #888)",padding:"4px"}})),(async()=>{try{const t=i.SemanticValue.fromTableCell(e),s=await o.functions.call("Bio:toAtomicLevelPanel",{sequence:t});n.innerHTML="",n.appendChild(s?.root??r.divText("Structure not available",{style:{fontSize:"11px",color:"var(--grey-4, #888)"}}))}catch(e){n.innerHTML="",n.appendChild(r.divText(`${t} render failed: ${e?.message??String(e)}`,{style:{fontSize:"11px",color:"var(--grey-4, #888)"}}))}})(),n}var yn=n(4900),bn=n(9124),vn=n(9192),Cn=n(8312),xn=n(1991),wn=n.n(xn);const An="object"==typeof performance&&performance&&"function"==typeof performance.now?performance:Date,Tn=new Set,En="object"==typeof process&&process?process:{},Sn=(e,t,n,o)=>{"function"==typeof En.emitWarning?En.emitWarning(e,t,n,o):console.error(`[${n}] ${t}: ${e}`)};let Nn=globalThis.AbortController,In=globalThis.AbortSignal;if(void 0===Nn){In=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(e,t){this._onabort.push(t)}},Nn=class{constructor(){t()}signal=new In;abort(e){if(!this.signal.aborted){this.signal.reason=e,this.signal.aborted=!0;for(const t of this.signal._onabort)t(e);this.signal.onabort?.(e)}}};let e="1"!==En.env?.LRU_CACHE_IGNORE_AC_WARNING;const t=()=>{e&&(e=!1,Sn("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",t))}}Symbol("type");const Mn=e=>e&&e===Math.floor(e)&&e>0&&isFinite(e),Pn=e=>Mn(e)?e<=Math.pow(2,8)?Uint8Array:e<=Math.pow(2,16)?Uint16Array:e<=Math.pow(2,32)?Uint32Array:e<=Number.MAX_SAFE_INTEGER?_n:null:null;class _n extends Array{constructor(e){super(e),this.fill(0)}}class Ln{heap;length;static#e=!1;static create(e){const t=Pn(e);if(!t)return[];Ln.#e=!0;const n=new Ln(e,t);return Ln.#e=!1,n}constructor(e,t){if(!Ln.#e)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new t(e),this.length=0}push(e){this.heap[this.length++]=e}pop(){return this.heap[--this.length]}}class On{#t;#n;#o;#r;#i;#s;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#a;#l;#c;#u;#h;#d;#p;#m;#f;#g;#y;#b;#v;#C;#x;#w;#A;static unsafeExposeInternals(e){return{starts:e.#v,ttls:e.#C,sizes:e.#b,keyMap:e.#c,keyList:e.#u,valList:e.#h,next:e.#d,prev:e.#p,get head(){return e.#m},get tail(){return e.#f},free:e.#g,isBackgroundFetch:t=>e.#T(t),backgroundFetch:(t,n,o,r)=>e.#E(t,n,o,r),moveToTail:t=>e.#S(t),indexes:t=>e.#N(t),rindexes:t=>e.#I(t),isStale:t=>e.#M(t)}}get max(){return this.#t}get maxSize(){return this.#n}get calculatedSize(){return this.#l}get size(){return this.#a}get fetchMethod(){return this.#i}get memoMethod(){return this.#s}get dispose(){return this.#o}get disposeAfter(){return this.#r}constructor(e){const{max:t=0,ttl:n,ttlResolution:o=1,ttlAutopurge:r,updateAgeOnGet:i,updateAgeOnHas:s,allowStale:a,dispose:l,disposeAfter:c,noDisposeOnSet:u,noUpdateTTL:h,maxSize:d=0,maxEntrySize:p=0,sizeCalculation:m,fetchMethod:f,memoMethod:g,noDeleteOnFetchRejection:y,noDeleteOnStaleGet:b,allowStaleOnFetchRejection:v,allowStaleOnFetchAbort:C,ignoreFetchAbort:x}=e;if(0!==t&&!Mn(t))throw new TypeError("max option must be a nonnegative integer");const w=t?Pn(t):Array;if(!w)throw new Error("invalid max value: "+t);if(this.#t=t,this.#n=d,this.maxEntrySize=p||this.#n,this.sizeCalculation=m,this.sizeCalculation){if(!this.#n&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if("function"!=typeof this.sizeCalculation)throw new TypeError("sizeCalculation set to non-function")}if(void 0!==g&&"function"!=typeof g)throw new TypeError("memoMethod must be a function if defined");if(this.#s=g,void 0!==f&&"function"!=typeof f)throw new TypeError("fetchMethod must be a function if specified");if(this.#i=f,this.#w=!!f,this.#c=new Map,this.#u=new Array(t).fill(void 0),this.#h=new Array(t).fill(void 0),this.#d=new w(t),this.#p=new w(t),this.#m=0,this.#f=0,this.#g=Ln.create(t),this.#a=0,this.#l=0,"function"==typeof l&&(this.#o=l),"function"==typeof c?(this.#r=c,this.#y=[]):(this.#r=void 0,this.#y=void 0),this.#x=!!this.#o,this.#A=!!this.#r,this.noDisposeOnSet=!!u,this.noUpdateTTL=!!h,this.noDeleteOnFetchRejection=!!y,this.allowStaleOnFetchRejection=!!v,this.allowStaleOnFetchAbort=!!C,this.ignoreFetchAbort=!!x,0!==this.maxEntrySize){if(0!==this.#n&&!Mn(this.#n))throw new TypeError("maxSize must be a positive integer if specified");if(!Mn(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#P()}if(this.allowStale=!!a,this.noDeleteOnStaleGet=!!b,this.updateAgeOnGet=!!i,this.updateAgeOnHas=!!s,this.ttlResolution=Mn(o)||0===o?o:1,this.ttlAutopurge=!!r,this.ttl=n||0,this.ttl){if(!Mn(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#_()}if(0===this.#t&&0===this.ttl&&0===this.#n)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#t&&!this.#n){const e="LRU_CACHE_UNBOUNDED";(e=>!Tn.has(e))(e)&&(Tn.add(e),Sn("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",e,On))}}getRemainingTTL(e){return this.#c.has(e)?1/0:0}#_(){const e=new _n(this.#t),t=new _n(this.#t);this.#C=e,this.#v=t,this.#L=(n,o,r=An.now())=>{if(t[n]=0!==o?r:0,e[n]=o,0!==o&&this.ttlAutopurge){const e=setTimeout((()=>{this.#M(n)&&this.#O(this.#u[n],"expire")}),o+1);e.unref&&e.unref()}},this.#R=n=>{t[n]=0!==e[n]?An.now():0},this.#$=(r,i)=>{if(e[i]){const s=e[i],a=t[i];if(!s||!a)return;r.ttl=s,r.start=a,r.now=n||o();const l=r.now-a;r.remainingTTL=s-l}};let n=0;const o=()=>{const e=An.now();if(this.ttlResolution>0){n=e;const t=setTimeout((()=>n=0),this.ttlResolution);t.unref&&t.unref()}return e};this.getRemainingTTL=r=>{const i=this.#c.get(r);if(void 0===i)return 0;const s=e[i],a=t[i];return s&&a?s-((n||o())-a):1/0},this.#M=r=>{const i=t[r],s=e[r];return!!s&&!!i&&(n||o())-i>s}}#R=()=>{};#$=()=>{};#L=()=>{};#M=()=>!1;#P(){const e=new _n(this.#t);this.#l=0,this.#b=e,this.#D=t=>{this.#l-=e[t],e[t]=0},this.#B=(e,t,n,o)=>{if(this.#T(t))return 0;if(!Mn(n)){if(!o)throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");if("function"!=typeof o)throw new TypeError("sizeCalculation must be a function");if(n=o(t,e),!Mn(n))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}return n},this.#F=(t,n,o)=>{if(e[t]=n,this.#n){const n=this.#n-e[t];for(;this.#l>n;)this.#k(!0)}this.#l+=e[t],o&&(o.entrySize=n,o.totalCalculatedSize=this.#l)}}#D=e=>{};#F=(e,t,n)=>{};#B=(e,t,n,o)=>{if(n||o)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#N({allowStale:e=this.allowStale}={}){if(this.#a)for(let t=this.#f;this.#H(t)&&(!e&&this.#M(t)||(yield t),t!==this.#m);)t=this.#p[t]}*#I({allowStale:e=this.allowStale}={}){if(this.#a)for(let t=this.#m;this.#H(t)&&(!e&&this.#M(t)||(yield t),t!==this.#f);)t=this.#d[t]}#H(e){return void 0!==e&&this.#c.get(this.#u[e])===e}*entries(){for(const e of this.#N())void 0===this.#h[e]||void 0===this.#u[e]||this.#T(this.#h[e])||(yield[this.#u[e],this.#h[e]])}*rentries(){for(const e of this.#I())void 0===this.#h[e]||void 0===this.#u[e]||this.#T(this.#h[e])||(yield[this.#u[e],this.#h[e]])}*keys(){for(const e of this.#N()){const t=this.#u[e];void 0===t||this.#T(this.#h[e])||(yield t)}}*rkeys(){for(const e of this.#I()){const t=this.#u[e];void 0===t||this.#T(this.#h[e])||(yield t)}}*values(){for(const e of this.#N())void 0===this.#h[e]||this.#T(this.#h[e])||(yield this.#h[e])}*rvalues(){for(const e of this.#I())void 0===this.#h[e]||this.#T(this.#h[e])||(yield this.#h[e])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(e,t={}){for(const n of this.#N()){const o=this.#h[n],r=this.#T(o)?o.__staleWhileFetching:o;if(void 0!==r&&e(r,this.#u[n],this))return this.get(this.#u[n],t)}}forEach(e,t=this){for(const n of this.#N()){const o=this.#h[n],r=this.#T(o)?o.__staleWhileFetching:o;void 0!==r&&e.call(t,r,this.#u[n],this)}}rforEach(e,t=this){for(const n of this.#I()){const o=this.#h[n],r=this.#T(o)?o.__staleWhileFetching:o;void 0!==r&&e.call(t,r,this.#u[n],this)}}purgeStale(){let e=!1;for(const t of this.#I({allowStale:!0}))this.#M(t)&&(this.#O(this.#u[t],"expire"),e=!0);return e}info(e){const t=this.#c.get(e);if(void 0===t)return;const n=this.#h[t],o=this.#T(n)?n.__staleWhileFetching:n;if(void 0===o)return;const r={value:o};if(this.#C&&this.#v){const e=this.#C[t],n=this.#v[t];if(e&&n){const t=e-(An.now()-n);r.ttl=t,r.start=Date.now()}}return this.#b&&(r.size=this.#b[t]),r}dump(){const e=[];for(const t of this.#N({allowStale:!0})){const n=this.#u[t],o=this.#h[t],r=this.#T(o)?o.__staleWhileFetching:o;if(void 0===r||void 0===n)continue;const i={value:r};if(this.#C&&this.#v){i.ttl=this.#C[t];const e=An.now()-this.#v[t];i.start=Math.floor(Date.now()-e)}this.#b&&(i.size=this.#b[t]),e.unshift([n,i])}return e}load(e){this.clear();for(const[t,n]of e){if(n.start){const e=Date.now()-n.start;n.start=An.now()-e}this.set(t,n.value,n)}}set(e,t,n={}){if(void 0===t)return this.delete(e),this;const{ttl:o=this.ttl,start:r,noDisposeOnSet:i=this.noDisposeOnSet,sizeCalculation:s=this.sizeCalculation,status:a}=n;let{noUpdateTTL:l=this.noUpdateTTL}=n;const c=this.#B(e,t,n.size||0,s);if(this.maxEntrySize&&c>this.maxEntrySize)return a&&(a.set="miss",a.maxEntrySizeExceeded=!0),this.#O(e,"set"),this;let u=0===this.#a?void 0:this.#c.get(e);if(void 0===u)u=0===this.#a?this.#f:0!==this.#g.length?this.#g.pop():this.#a===this.#t?this.#k(!1):this.#a,this.#u[u]=e,this.#h[u]=t,this.#c.set(e,u),this.#d[this.#f]=u,this.#p[u]=this.#f,this.#f=u,this.#a++,this.#F(u,c,a),a&&(a.set="add"),l=!1;else{this.#S(u);const n=this.#h[u];if(t!==n){if(this.#w&&this.#T(n)){n.__abortController.abort(new Error("replaced"));const{__staleWhileFetching:t}=n;void 0===t||i||(this.#x&&this.#o?.(t,e,"set"),this.#A&&this.#y?.push([t,e,"set"]))}else i||(this.#x&&this.#o?.(n,e,"set"),this.#A&&this.#y?.push([n,e,"set"]));if(this.#D(u),this.#F(u,c,a),this.#h[u]=t,a){a.set="replace";const e=n&&this.#T(n)?n.__staleWhileFetching:n;void 0!==e&&(a.oldValue=e)}}else a&&(a.set="update")}if(0===o||this.#C||this.#_(),this.#C&&(l||this.#L(u,o,r),a&&this.#$(a,u)),!i&&this.#A&&this.#y){const e=this.#y;let t;for(;t=e?.shift();)this.#r?.(...t)}return this}pop(){try{for(;this.#a;){const e=this.#h[this.#m];if(this.#k(!0),this.#T(e)){if(e.__staleWhileFetching)return e.__staleWhileFetching}else if(void 0!==e)return e}}finally{if(this.#A&&this.#y){const e=this.#y;let t;for(;t=e?.shift();)this.#r?.(...t)}}}#k(e){const t=this.#m,n=this.#u[t],o=this.#h[t];return this.#w&&this.#T(o)?o.__abortController.abort(new Error("evicted")):(this.#x||this.#A)&&(this.#x&&this.#o?.(o,n,"evict"),this.#A&&this.#y?.push([o,n,"evict"])),this.#D(t),e&&(this.#u[t]=void 0,this.#h[t]=void 0,this.#g.push(t)),1===this.#a?(this.#m=this.#f=0,this.#g.length=0):this.#m=this.#d[t],this.#c.delete(n),this.#a--,t}has(e,t={}){const{updateAgeOnHas:n=this.updateAgeOnHas,status:o}=t,r=this.#c.get(e);if(void 0!==r){const e=this.#h[r];if(this.#T(e)&&void 0===e.__staleWhileFetching)return!1;if(!this.#M(r))return n&&this.#R(r),o&&(o.has="hit",this.#$(o,r)),!0;o&&(o.has="stale",this.#$(o,r))}else o&&(o.has="miss");return!1}peek(e,t={}){const{allowStale:n=this.allowStale}=t,o=this.#c.get(e);if(void 0===o||!n&&this.#M(o))return;const r=this.#h[o];return this.#T(r)?r.__staleWhileFetching:r}#E(e,t,n,o){const r=void 0===t?void 0:this.#h[t];if(this.#T(r))return r;const i=new Nn,{signal:s}=n;s?.addEventListener("abort",(()=>i.abort(s.reason)),{signal:i.signal});const a={signal:i.signal,options:n,context:o},l=(o,r=!1)=>{const{aborted:s}=i.signal,l=n.ignoreFetchAbort&&void 0!==o;if(n.status&&(s&&!r?(n.status.fetchAborted=!0,n.status.fetchError=i.signal.reason,l&&(n.status.fetchAbortIgnored=!0)):n.status.fetchResolved=!0),s&&!l&&!r)return c(i.signal.reason);const h=u;return this.#h[t]===u&&(void 0===o?h.__staleWhileFetching?this.#h[t]=h.__staleWhileFetching:this.#O(e,"fetch"):(n.status&&(n.status.fetchUpdated=!0),this.set(e,o,a.options))),o},c=o=>{const{aborted:r}=i.signal,s=r&&n.allowStaleOnFetchAbort,a=s||n.allowStaleOnFetchRejection,l=a||n.noDeleteOnFetchRejection,c=u;if(this.#h[t]===u&&(l&&void 0!==c.__staleWhileFetching?s||(this.#h[t]=c.__staleWhileFetching):this.#O(e,"fetch")),a)return n.status&&void 0!==c.__staleWhileFetching&&(n.status.returnedStale=!0),c.__staleWhileFetching;if(c.__returned===c)throw o};n.status&&(n.status.fetchDispatched=!0);const u=new Promise(((t,o)=>{const s=this.#i?.(e,r,a);s&&s instanceof Promise&&s.then((e=>t(void 0===e?void 0:e)),o),i.signal.addEventListener("abort",(()=>{n.ignoreFetchAbort&&!n.allowStaleOnFetchAbort||(t(void 0),n.allowStaleOnFetchAbort&&(t=e=>l(e,!0)))}))})).then(l,(e=>(n.status&&(n.status.fetchRejected=!0,n.status.fetchError=e),c(e)))),h=Object.assign(u,{__abortController:i,__staleWhileFetching:r,__returned:void 0});return void 0===t?(this.set(e,h,{...a.options,status:void 0}),t=this.#c.get(e)):this.#h[t]=h,h}#T(e){if(!this.#w)return!1;const t=e;return!!t&&t instanceof Promise&&t.hasOwnProperty("__staleWhileFetching")&&t.__abortController instanceof Nn}async fetch(e,t={}){const{allowStale:n=this.allowStale,updateAgeOnGet:o=this.updateAgeOnGet,noDeleteOnStaleGet:r=this.noDeleteOnStaleGet,ttl:i=this.ttl,noDisposeOnSet:s=this.noDisposeOnSet,size:a=0,sizeCalculation:l=this.sizeCalculation,noUpdateTTL:c=this.noUpdateTTL,noDeleteOnFetchRejection:u=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:h=this.allowStaleOnFetchRejection,ignoreFetchAbort:d=this.ignoreFetchAbort,allowStaleOnFetchAbort:p=this.allowStaleOnFetchAbort,context:m,forceRefresh:f=!1,status:g,signal:y}=t;if(!this.#w)return g&&(g.fetch="get"),this.get(e,{allowStale:n,updateAgeOnGet:o,noDeleteOnStaleGet:r,status:g});const b={allowStale:n,updateAgeOnGet:o,noDeleteOnStaleGet:r,ttl:i,noDisposeOnSet:s,size:a,sizeCalculation:l,noUpdateTTL:c,noDeleteOnFetchRejection:u,allowStaleOnFetchRejection:h,allowStaleOnFetchAbort:p,ignoreFetchAbort:d,status:g,signal:y};let v=this.#c.get(e);if(void 0===v){g&&(g.fetch="miss");const t=this.#E(e,v,b,m);return t.__returned=t}{const t=this.#h[v];if(this.#T(t)){const e=n&&void 0!==t.__staleWhileFetching;return g&&(g.fetch="inflight",e&&(g.returnedStale=!0)),e?t.__staleWhileFetching:t.__returned=t}const r=this.#M(v);if(!f&&!r)return g&&(g.fetch="hit"),this.#S(v),o&&this.#R(v),g&&this.#$(g,v),t;const i=this.#E(e,v,b,m),s=void 0!==i.__staleWhileFetching&&n;return g&&(g.fetch=r?"stale":"refresh",s&&r&&(g.returnedStale=!0)),s?i.__staleWhileFetching:i.__returned=i}}async forceFetch(e,t={}){const n=await this.fetch(e,t);if(void 0===n)throw new Error("fetch() returned undefined");return n}memo(e,t={}){const n=this.#s;if(!n)throw new Error("no memoMethod provided to constructor");const{context:o,forceRefresh:r,...i}=t,s=this.get(e,i);if(!r&&void 0!==s)return s;const a=n(e,s,{options:i,context:o});return this.set(e,a,i),a}get(e,t={}){const{allowStale:n=this.allowStale,updateAgeOnGet:o=this.updateAgeOnGet,noDeleteOnStaleGet:r=this.noDeleteOnStaleGet,status:i}=t,s=this.#c.get(e);if(void 0!==s){const t=this.#h[s],a=this.#T(t);return i&&this.#$(i,s),this.#M(s)?(i&&(i.get="stale"),a?(i&&n&&void 0!==t.__staleWhileFetching&&(i.returnedStale=!0),n?t.__staleWhileFetching:void 0):(r||this.#O(e,"expire"),i&&n&&(i.returnedStale=!0),n?t:void 0)):(i&&(i.get="hit"),a?t.__staleWhileFetching:(this.#S(s),o&&this.#R(s),t))}i&&(i.get="miss")}#G(e,t){this.#p[t]=e,this.#d[e]=t}#S(e){e!==this.#f&&(e===this.#m?this.#m=this.#d[e]:this.#G(this.#p[e],this.#d[e]),this.#G(this.#f,e),this.#f=e)}delete(e){return this.#O(e,"delete")}#O(e,t){let n=!1;if(0!==this.#a){const o=this.#c.get(e);if(void 0!==o)if(n=!0,1===this.#a)this.#U(t);else{this.#D(o);const n=this.#h[o];if(this.#T(n)?n.__abortController.abort(new Error("deleted")):(this.#x||this.#A)&&(this.#x&&this.#o?.(n,e,t),this.#A&&this.#y?.push([n,e,t])),this.#c.delete(e),this.#u[o]=void 0,this.#h[o]=void 0,o===this.#f)this.#f=this.#p[o];else if(o===this.#m)this.#m=this.#d[o];else{const e=this.#p[o];this.#d[e]=this.#d[o];const t=this.#d[o];this.#p[t]=this.#p[o]}this.#a--,this.#g.push(o)}}if(this.#A&&this.#y?.length){const e=this.#y;let t;for(;t=e?.shift();)this.#r?.(...t)}return n}clear(){return this.#U("delete")}#U(e){for(const t of this.#I({allowStale:!0})){const n=this.#h[t];if(this.#T(n))n.__abortController.abort(new Error("deleted"));else{const o=this.#u[t];this.#x&&this.#o?.(n,o,e),this.#A&&this.#y?.push([n,o,e])}}if(this.#c.clear(),this.#h.fill(void 0),this.#u.fill(void 0),this.#C&&this.#v&&(this.#C.fill(0),this.#v.fill(0)),this.#b&&this.#b.fill(0),this.#m=0,this.#f=0,this.#g.length=0,this.#l=0,this.#a=0,this.#A&&this.#y){const e=this.#y;let t;for(;t=e?.shift();)this.#r?.(...t)}}}function Rn(){var e;return null!==(e=window.$monomerHover)&&void 0!==e?e:null}function $n(e){window.$monomerHover=e}function Dn(e,t){let n=e["substruct-providers"];n||(n=e["substruct-providers"]=[]),n.push(t),e["substruct-providers"]=n}var Bn=n(6077),Fn=n(3561),kn=n(9235);const Hn="MonomerHoverLinks";function Gn(e,t){let n=e[Hn];n||(n=e[Hn]=[]),n.push(t),e[Hn]=n}function Un(e,t){try{const n=e.tableColumn;if(!n)return;const o=function(e){return e.temp[Hn]??[]}(n);for(let n=o.length-1;n>=0;--n){const r=o[n],i=e.grid.col(r.targetCol.name);if(i&&!r.handler(e,t,i))break}}catch(e){console.error(e)}}var Vn=n(6717),jn=n(6694),qn=n(4229),Wn=n(5174);function zn(e,t=!0){const[n,r]=(0,vn.AP)(e);return br.logger.error(n,void 0,r),t&&o.shell.error(n),[n,r]}const Yn={symbol:"Short Name",name:"Medium Name",smiles:"SMILES"},Kn=[{capGroupSmiles:"[*:1][H]",alternateId:"R1-H",capGroupName:"H",label:"R1"},{capGroupSmiles:"O[*:2]",alternateId:"R2-OH",capGroupName:"OH",label:"R2"},{capGroupSmiles:"[*:3][H]",alternateId:"R3-H",capGroupName:"H",label:"R3"}],Qn="Get HELM",Jn="Chirality engine",Xn="Highlight monomers",Zn="PolyTool Conversion",eo="PolyTool Helm Enumeration",to="Rules used",no={single:"Each position is enumerated independently. Total results = sum of monomers across all positions.",parallel:"The i-th result uses the i-th monomer from every position (zip). All positions must have the same number of monomers. Total results = number of monomers per position.",matrix:"Cartesian product of all positions. Total results = product of monomer counts across all positions."};var oo=n(5412);async function ro(e,t,n,r,s,a){const l=i.TaskBarProgressIndicator.create("PolyTool converting...");try{const l=(e,t)=>e?e.columns.getUnusedName(t):t,c=await(0,bn.b2)(),u=e.dataFrame,h=await(0,jn.Q4)(a),[d,p,m]=(0,qn.b)(e.toList(),h,c),f=l(u,`transformed(${e.name})`),g=i.Column.fromType(i.COLUMN_TYPE.STRING,f,d.length).init((e=>d[e]));g.semType=i.SEMTYPE.MACROMOLECULE,g.meta.units=Ot.Hi.HELM,g.setTag(i.TAGS.CELL_RENDERER,"helm"),t&&u&&u.columns.add(g,!0);const y=await(0,Vn.j)(),b=await(0,Cn.Q)(),v=await(0,Wn.A)(h),C=g.temp;C[".mm.cellRenderer.overriddenLibrary"]=v,g.temp=C;const x=await(0,oo.m)(g,d,p,r,s,n,v,y,b);return x.name=l(u,`molfile(${e.name})`),x.semType=i.SEMTYPE.MOLECULE,u&&(u.columns.add(x,!0),await o.data.detectSemanticTypes(u)),function(e,t,n,o,r,i,s){const a=new On({max:100});function l(e,t){const n=e.get(t);if(null==n)return null;let s=a.get(n);return s||a.set(n,s=function(e,t){const n=r.getSeqHandler(e),s=n.getSplitted(t),a=n.defaultBiotype,l=wn().count(0).take(s.length).map((e=>({position:e,symbol:s.getCanonical(e),biotype:a}))).toArray(),c=n.alphabet,u=c==Ot.YI.RNA||c==Ot.YI.DNA?"RNA":"PEPTIDE",h=(0,Bn.eM)([l],[void 0],u,c,o,i);return(0,Fn.gU)(l,h,c,u).monomers}(e,t)),s}const c={targetCol:n,handler:(e,n,r)=>{if(!e||!r.grid||!t.dataFrame)return!0;const i=r.grid,a=e.tableRowIndex,c=e.gridRow,u=i.cell(r.name,c),h=s[c],d=Rn();if(!d||d&&(d.dataFrameId!=t.dataFrame?.id||d.gridRowIdx!=c||d.seqColName!=t.name||d.seqPosition!=n?.position)){if(d&&($n(null),d.gridCell.render()),!n)return $n(null),!0;$n({gridCell:u,dataFrameId:t.dataFrame.id,gridRowIdx:c,seqColName:t.name,seqPosition:n?n.position:-1,getSubstruct:()=>{if(!n||"*"===n.symbol)return;const e=l(t,a);if(!e)return;const r=[],i=h[n.position];for(const t of i){const n=e.get(t);if(!n)return{atoms:[],bonds:[],highlightAtomColors:[],highlightBondColors:[]};r.push((0,kn.H)([n],o))}return function(e){var t,n,o,r;const i={atoms:[],bonds:[],highlightAtomColors:{},highlightBondColors:{}};for(const s of e)i.atoms=[...null!==(t=i.atoms)&&void 0!==t?t:[],...null!==(n=s.atoms)&&void 0!==n?n:[]],i.bonds=[...null!==(o=i.bonds)&&void 0!==o?o:[],...null!==(r=s.bonds)&&void 0!==r?r:[]],i.highlightAtomColors=Object.assign(Object.assign({},i.highlightAtomColors),s.highlightAtomColors),i.highlightBondColors=Object.assign(Object.assign({},i.highlightBondColors),s.highlightBondColors);return i}(r)}}),u.render()}return!0},getSubstruct:e=>{if("true"!=n.getTag(".sequence-src-highlight-monomers"))return;if(null==e)return;if(!t.get(e))return;const r=l(t,e);return r?(0,kn.H)(r.values(),o):void 0}};Gn(e.temp,c),Dn(n.temp,c)}(e,g,x,v,b,y,m),[g,x]}finally{l.close()}}var io=n(3309);const so="PolyTool Chem Enumeration",ao={[io.PI.Zip]:"Zip: every R-group list must have the same length N. The i-th result uses the i-th entry from every list. Produces N results per core.",[io.PI.Cartesian]:"Cartesian: every combination of entries across R-group lists. Produces ∏|Rᵢ| results per core."},lo=110,co=104,uo=100,ho=72,po=320,mo=260;function fo(e,t,n,i){r.empty(e);try{const r=o.chem.drawMolecule(t,n,i);r.style.width=`${n}px`,r.style.height=`${i}px`,r.style.maxWidth=`${n}px`,r.style.maxHeight=`${i}px`,r.style.display="block",e.appendChild(r)}catch{e.appendChild(r.divText("—",{style:{color:"var(--grey-4)"}}))}}function go(e){const t=r.div([],{style:{width:`${uo}px`,height:`${ho}px`,display:"flex",alignItems:"center",justifyContent:"center",background:"transparent",overflow:"hidden",flex:"0 0 auto"}});e.smiles&&!e.error?fo(t,e.smiles,uo,ho):t.appendChild(r.divText("—",{style:{color:"var(--grey-4)"}}));const n=r.divText(e.subtitle,{style:{fontSize:"10px",color:e.error?"var(--red-3)":"var(--grey-5)",textAlign:"center",padding:"2px 4px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"}}),o=r.divV([t,n],{style:{width:`${lo}px`,minWidth:`${lo}px`,height:`${co}px`,border:"2px solid "+(e.error?"var(--red-3)":"var(--grey-2)"),borderRadius:"4px",position:"relative",background:"var(--white)",boxSizing:"border-box",margin:"0 4px 0 0",overflow:"hidden",flex:"0 0 auto"}});if(e.smiles&&!e.error){let t=null;r.tooltip.bind(o,(()=>(t||(t=r.div([],{style:{width:`${po}px`,height:`${mo}px`}}),fo(t,e.smiles,po,mo)),t)))}else e.error&&r.tooltip.bind(o,e.error);const i=r.divH([],{style:{position:"absolute",top:"2px",right:"2px",gap:"2px",background:"rgba(255,255,255,0.85)",borderRadius:"4px",padding:"1px 2px",display:"none"}});if(e.onEdit){const t=r.icons.edit((t=>{t.stopPropagation(),e.onEdit()}),"Edit");t.style.color="var(--blue-3)",i.appendChild(t)}if(e.onDuplicate){const t=r.icons.copy((t=>{t.stopPropagation(),e.onDuplicate()}),"Duplicate");t.style.color="var(--blue-3)",i.appendChild(t)}if(e.onRemove){const t=r.icons.delete((t=>{t.stopPropagation(),e.onRemove()}),"Remove");t.style.color="var(--red-3)",i.appendChild(t)}return o.addEventListener("mouseenter",(()=>{i.style.display="flex"})),o.addEventListener("mouseleave",(()=>{i.style.display="none"})),(e.onEdit||e.onDuplicate||e.onRemove)&&o.appendChild(i),o}async function yo(e,t){const n=e.getMolFile();if(!n||""===n.trim())return null;if(!i.chem.isMolBlock(n))return n.trim();try{return(await o.functions.call("Chem:convertMolNotation",{molecule:n,sourceNotation:i.chem.Notation.MolBlock,targetNotation:i.chem.Notation.Smiles})??"").toString().trim()||null}catch{return null}}async function bo(e,t){return new Promise((n=>{const o=new i.chem.Sketcher(i.chem.SKETCHER_MODE.INPLACE);o.syncCurrentObject=!1,t&&o.setMolFile(t);const s=r.divText("",{style:{fontSize:"11px",padding:"4px 0",minHeight:"18px"}});let a=null,l=null;const c=async()=>{a=await yo(o);const e=a?(0,io.Qk)(a):[];a?0===e.length?(s.innerText="No R-group detected — add e.g. [*:1] to mark an attachment point.",s.style.color="var(--red-3)"):(s.innerText=`Detected R-groups: ${e.map((e=>"R"+e)).join(", ")}.`,s.style.color="var(--green-2)"):(s.innerText="Draw a molecule with at least one R-group label.",s.style.color="var(--grey-4)"),l&&(l.disabled=!(a&&e.length>0))};o.onChanged.subscribe((()=>{c()}));const u=r.divV([o.root,s]),h=r.dialog({title:t?"Edit Core":"Draw Core"}).add(u).onOK((()=>n(a?(0,io.KS)(a,"",e):null))).onCancel((()=>n(null)));h.show({resizable:!0}),l=h.getButton("OK"),l.disabled=!0,c()}))}async function vo(e,t,n){return new Promise((o=>{const s=new i.chem.Sketcher(i.chem.SKETCHER_MODE.INPLACE);s.syncCurrentObject=!1,t&&s.setMolFile(t);const a=r.input.int("Target R#",{value:n,min:1}),l=r.divText("",{style:{fontSize:"11px",padding:"4px 0",minHeight:"18px"}});let c=null,u=[],h=!1,d=null,p=!1;a.onChanged.subscribe((()=>{p=!0,m()}));const m=()=>{const e=a.value,t=null!=c&&null!=e&&e>=1&&(1===u.length||h);d&&(d.disabled=!t)},f=async()=>{if(c=await yo(s),u=c?(0,io.Qk)(c):[],h=!1,c&&0===u.length){const t=(0,io.ah)(c,a.value??1,"",e);h=!!t.isSingleAtom}if(c)if(0!==u.length||h)if(0===u.length&&h){const e=a.value;l.innerText=`Single atom — will be substituted into [*:${e??"?"}] in the core.`,l.style.color="var(--green-2)"}else u.length>1?(l.innerText=`R-group must contain exactly one attachment point. Found ${u.length}: ${u.map((e=>"R"+e)).join(", ")}.`,l.style.color="var(--red-3)"):(p&&null!=a.value||(a.value=u[0]),l.innerText=`Detected R${u[0]}. Target R# is used for joining; change it to remap.`,l.style.color="var(--green-2)");else l.innerText="No R-group detected — add [*:N] to mark the attachment point, or draw a single atom (e.g. N, O, Cl).",l.style.color="var(--red-3)";else l.innerText="Draw an R-group with one attachment point, or a single atom (e.g. N, O, Cl).",l.style.color="var(--grey-4)";m()};s.onChanged.subscribe((()=>{f()}));const g=r.divV([s.root,a.root,l]),y=r.dialog({title:t?"Edit R-Group":"Draw R-Group"}).add(g).onOK((()=>{const t=a.value;o(c&&null!=t?(0,io.ah)(c,t,"",e):null)})).onCancel((()=>o(null)));y.show({resizable:!0}),d=y.getButton("OK"),d.disabled=!0,f()}))}async function Co(e,t,n){return new Promise((s=>{const a=e=>e.semType===i.SEMTYPE.MOLECULE,l=r.input.table("Table",{value:o.shell.t??void 0}),c=r.input.choice("Column",{items:[],nullable:!0}),u="rgroups"===e?r.input.int("Target R#",{value:1,min:1}):null;u&&r.tooltip.bind(u.input,"Target R-number for these R-groups. Single-atom rows (no [*:N] label, e.g. just N or O) get substituted into the core's R# slot directly.");const h=r.input.bool("Remove duplicates",{value:n});r.tooltip.bind(h.input,"cores"===e?"When checked, identical cores in the selected column are collapsed into one entry.":"When checked, identical R-groups are collapsed. Leave off for Zip mode if your lists are intentionally aligned by position.");const d=e=>{const t=l.value;if(!t)return c.items=[],void(c.value=null);const n=t.columns.toList().filter(a);if(c.items=n.map((e=>e.name)),e){const e=n.find((e=>e.semType===i.SEMTYPE.MOLECULE));c.value=(e??n[0])?.name??null}},p=r.div([],{style:{height:`${co+26}px`,overflow:"hidden",padding:"4px"}}),m=r.divText("",{style:{fontSize:"11px",color:"var(--grey-5)",margin:"4px 0"}}),f=xo();let g={},y=null,b=null;const v=()=>{f.setErrors([]),g={};const n=(()=>{const e=l.value,t=c.value;return e&&t?e.col(t):null})();if(!n)return m.innerText="",y&&(y.disabled=!0),void(b&&b.setData(0,(()=>r.div())));const o=[];for(let e=0;e<n.length;e++){if(n.isNone(e))continue;const t=n.get(e);null!=t&&""!==String(t).trim()&&o.push(String(t))}const i=h.value,s=[],a=[];if("cores"===e){const e=o.map((e=>(0,io.KS)(e,"",t)));let n=e,r=0;if(i){const t=new Set;n=[];for(const o of e){const e=o.error?`err:${o.originalSmiles}`:o.smiles;t.has(e)?r++:(t.add(e),n.push(o))}}g.cores=n,n.forEach(((e,t)=>{e.error&&a.push(`Core ${t+1}: ${e.error}`),s.push({smi:e.error?"":e.smiles,err:e.error,subtitle:e.error?"invalid":e.rNumbers.map((e=>"R"+e)).join(", ")})})),m.innerText=`${n.length} core${1===n.length?"":"s"}`+(i&&r?` (${r} duplicate${1===r?"":"s"} skipped)`:"")+"."}else{const e=u.value??1,n=o.map((n=>(0,io.ah)(n,e,"",t)));let r=n,l=0;if(i){const e=new Set;r=[];for(const t of n){const n=t.error?`err:${t.originalSmiles}`:t.smiles;e.has(n)?l++:(e.add(n),r.push(t))}}g.rGroups=r,r.forEach(((e,t)=>{e.error&&a.push(`R-group ${t+1}: ${e.error}`);const n=e.error?"invalid":e.isSingleAtom?`R${e.rNumber} · atom`:`R${e.rNumber}${null!=e.sourceRNumber&&e.sourceRNumber!==e.rNumber?` (from R${e.sourceRNumber})`:""}`;s.push({smi:e.error?"":e.smiles,err:e.error,subtitle:n})})),m.innerText=`${r.length} R-group${1===r.length?"":"s"} for R${e}`+(i&&l?` (${l} duplicate${1===l?"":"s"} skipped)`:"")+"."}f.setErrors(a),b?b.setData(s.length,(e=>go({smiles:s[e].smi,subtitle:s[e].subtitle,error:s[e].err}))):(b=r.virtualView(s.length,(e=>go({smiles:s[e].smi,subtitle:s[e].subtitle,error:s[e].err})),!1,1),b.root.style.height=`${co+12}px`,b.root.style.width="100%",p.appendChild(b.root)),y&&(y.disabled=0===o.length)};l.onChanged.subscribe((async()=>{const e=l.value;e&&(await e.meta.detectSemanticTypes(),await o.data.detectSemanticTypes(e)),d(!0),v()})),c.onChanged.subscribe((()=>{if("rgroups"===e&&c.value){const e=function(e){const t=e.match(/r[\s_\-:]*(\d+)/i);return t?parseInt(t[1],10):null}(c.value);null!=e&&(u.value=e)}v()})),u&&u.onChanged.subscribe((()=>v())),h.onChanged.subscribe((()=>v()));const C=r.divV([l.root,c.root,...u?[u.root]:[],h.root,r.divH([m,f.root],{style:{alignItems:"center",gap:"8px"}}),p]),x=r.dialog({title:"cores"===e?"Import Cores":"Import R-Groups"}).add(C).onOK((()=>s(g))).onCancel((()=>s(null)));x.show({resizable:!0,width:640}),y=x.getButton("OK"),y.disabled=!0,l.value&&l.value.meta.detectSemanticTypes().then((()=>{d(!0),v()}))}))}function xo(){const e=r.div([],{style:{display:"none",alignItems:"center",gap:"4px",padding:"2px 8px",borderRadius:"10px",background:"var(--red-2)",color:"var(--red-3)",fontSize:"11px",fontWeight:"600",cursor:"help"}});return{root:e,setErrors(t){0!==t.length?(e.style.display="inline-flex",e.innerText=`⚠ ${t.length} issue${1===t.length?"":"s"}`,r.tooltip.bind(e,t.join("\n"))):e.style.display="none"}}}async function wo(e){await br.initPromise;try{const t=await(0,Vn.j)();let n=null;if(e){const r=await async function(e){try{if(!e||e.rowIndex<0||e.column?.semType!==i.SEMTYPE.MOLECULE)return null;const t=e.value;return t?i.chem.isMolBlock(t)?t:await o.functions.call("Chem:convertMolNotation",{molecule:t,sourceNotation:e.column.getTag(i.TAGS.UNITS)??i.chem.Notation.Unknown,targetNotation:i.chem.Notation.MolBlock})??null:null}catch{return null}}(e);if(r){const e=await o.functions.call("Chem:convertMolNotation",{molecule:r,sourceNotation:i.chem.Notation.MolBlock,targetNotation:i.chem.Notation.Smiles});if(e){const r=(0,io.KS)(e,"",t);r.error?o.shell.info("Selected molecule has no R-group — add at least one R-label to use it as a core."):n=r}}}const s=Ao(t,n),a=r.dialog({title:so}).add(s.root).onOK((async()=>{await s.execute()}));s.bindActionButton(a.getButton("OK")),a.show({resizable:!0,width:960})}catch(e){zn(e)}}function Ao(e,t){const n={cores:t?[t]:[],rGroupsByNum:new Map,mode:io.PI.Cartesian,appendToTable:null},s=co+16,a=r.divText("No cores — draw or import at least one.",{style:{color:"var(--grey-4)",padding:"20px 12px",fontSize:"12px"}}),l=r.div([],{style:{width:"100%",height:`${s}px`,overflow:"hidden"}});let c=null;const u=t=>{const o=n.cores[t];return go({smiles:o.error?"":o.smiles,subtitle:o.error?"invalid":`core ${t+1} · ${o.rNumbers.map((e=>"R"+e)).join(", ")}`,error:o.error,onEdit:async()=>{const r=await bo(e,o.smiles);r&&(n.cores[t]=r,T())},onDuplicate:async()=>{const t=await bo(e,o.smiles);t&&(n.cores.push(t),T())},onRemove:()=>{n.cores.splice(t,1),T()}})};function h(e){e.style.width="100%",e.style.height=`${s}px`,e.style.setProperty("overflow-y","hidden","important"),e.style.setProperty("overflow-x","auto","important");const t=e.firstElementChild;t&&(t.style.setProperty("overflow-y","hidden","important"),t.style.setProperty("overflow-x","auto","important"),t.style.height=`${s}px`)}const d=r.div([],{style:{width:"100%",padding:"2px 0",flex:"1 1 auto",minHeight:"0",overflowY:"auto",overflowX:"hidden"}}),p=r.divText("No R-groups — draw or import for each R number used by your cores.",{style:{color:"var(--grey-4)",padding:"12px",fontSize:"12px"}}),m=new Map,f=r.div([],{style:{width:"100%",display:"flex",flexWrap:"wrap",gap:"6px",alignContent:"flex-start",padding:"2px 0",maxHeight:"450px",overflow:"scroll"}}),g=r.divText("",{style:{fontSize:"12px",color:"var(--grey-6)"}}),y=xo(),b=r.input.choice("Enumerator type",{value:n.mode,items:Object.values(io.PI),onValueChanged:e=>{n.mode=e,v(),T()}}),v=()=>r.tooltip.bind(b.input,ao[n.mode]??"");v();const C=r.input.table("Append to table",{items:o.shell.tables,nullable:!0,onValueChanged:e=>{n.appendToTable=e}});let x,w,A=null;const T=()=>{(()=>{if(0===n.cores.length)return l.firstChild&&r.empty(l),c=null,a.parentElement!==l.parentElement&&l.parentElement?.insertBefore(a,l.nextSibling),l.style.display="none",void(a.style.display="block");l.style.display="block",a.style.display="none",c?c.setData(n.cores.length,u):(c=r.virtualView(n.cores.length,u,!1,1),h(c.root),l.appendChild(c.root))})(),(()=>{if(r.empty(d),m.clear(),0===n.rGroupsByNum.size)return void d.appendChild(p);const t=[...n.rGroupsByNum.keys()].sort(((e,t)=>e-t));for(const o of t){const t=n.rGroupsByNum.get(o),i=r.divText(`R${o} (${t.length})`,{style:{fontWeight:"600",fontSize:"12px",color:"var(--grey-6)",alignSelf:"center"}}),s=r.button("Remove all",(()=>{n.rGroupsByNum.delete(o),T()}));s.style.marginLeft="4px",r.tooltip.bind(s,`Remove all R${o} groups`);const a=r.divH([i,s],{style:{alignItems:"center",justifyContent:"flex-start",gap:"0",margin:"6px 0 2px"}}),l=r=>{const i=t[r],s=null!=i.sourceRNumber&&i.sourceRNumber!==i.rNumber?` (from R${i.sourceRNumber})`:"",a=i.error?"invalid":i.isSingleAtom?`r group ${r+1} · R${i.rNumber} · atom`:`r group ${r+1} · R${i.rNumber}${s}`;return go({smiles:i.error?"":i.smiles,subtitle:a,error:i.error,onEdit:async()=>{const o=await vo(e,i.smiles,i.rNumber);if(o){if(o.rNumber!==i.rNumber){t.splice(r,1),0===t.length&&n.rGroupsByNum.delete(i.rNumber);const e=n.rGroupsByNum.get(o.rNumber)??[];e.push(o),n.rGroupsByNum.set(o.rNumber,e)}else t[r]=o;T()}},onDuplicate:async()=>{const t=await vo(e,i.smiles,i.rNumber);if(!t)return;const o=n.rGroupsByNum.get(t.rNumber)??[];o.push(t),n.rGroupsByNum.set(t.rNumber,o),T()},onRemove:()=>{t.splice(r,1),0===t.length&&n.rGroupsByNum.delete(o),T()}})},c=r.virtualView(t.length,l,!1,1);h(c.root);const u=r.divV([a,c.root]);d.appendChild(u),m.set(o,{row:u,vv:c,header:a})}})();const t=(0,io.XB)({cores:n.cores,rGroups:n.rGroupsByNum,mode:n.mode});g.innerText=t.predictedCount>0?`${t.predictedCount.toLocaleString()} molecule${1===t.predictedCount?"":"s"} will be generated`:"",y.setErrors((()=>{const e=[];n.cores.forEach(((t,n)=>{t.error&&e.push(`Core ${n+1}: ${t.error}`)}));const t=[...n.rGroupsByNum.keys()].sort(((e,t)=>e-t));for(const o of t)n.rGroupsByNum.get(o).forEach(((t,n)=>{t.error&&e.push(`R${o} group ${n+1}: ${t.error}`)}));const o=(0,io.XB)({cores:n.cores,rGroups:n.rGroupsByNum,mode:n.mode});for(const t of o.errors)/^Core "/.test(t)||e.push(t);return e})()),A&&(A.disabled=!t.ok),x&&(x.disabled=0===n.cores.length),w&&(w.disabled=0===n.rGroupsByNum.size),(()=>{r.empty(f);const e=(0,io.xD)({cores:n.cores,rGroups:n.rGroupsByNum,mode:n.mode,maxResults:Math.min(io.u8,1e3)},12);0!==e.length?e.forEach(((e,t)=>{const n=[...e.rGroupSmilesByNum.keys()].sort(((e,t)=>e-t)).map((e=>"R"+e)).join(",");f.appendChild(go({smiles:e.smiles,subtitle:`sample ${t+1} · ${n}`}))})):f.appendChild(r.divText("Preview will appear once cores and R-groups are valid.",{style:{color:"var(--grey-4)",padding:"20px 12px",fontSize:"12px"}}))})()},E=(e,t,n,o)=>{const i=[r.divText(e,{style:{fontWeight:"600",fontSize:"12px",color:"var(--grey-6)",alignSelf:"center",minWidth:"60px"}})];if(t){const n=r.button("+ Draw",t);n.style.marginLeft="4px",r.tooltip.bind(n,`${e}: open sketcher`),i.push(n)}if(n){const t=r.button("↓ Import…",n);t.style.marginLeft="4px",r.tooltip.bind(t,`${e}: pick a table + column`),i.push(t)}let s;return o&&(s=r.button("Remove all",o),s.style.marginLeft="4px",r.tooltip.bind(s,`Remove all ${e.toLowerCase()}`),i.push(s)),{root:r.divH(i,{style:{alignItems:"center",justifyContent:"flex-start",gap:"0",margin:"0 0 2px",flex:"0 0 auto"}}),clearBtn:s}},S={display:"flex",flexDirection:"column",minHeight:"150px",padding:"4px 0"},N=E("Cores",(async()=>{const t=await bo(e);t&&(n.cores.push(t),T())}),(async()=>{const t=await Co("cores",e,n.mode===io.PI.Cartesian);t?.cores&&(n.cores.push(...t.cores),T())}),(()=>{n.cores.splice(0,n.cores.length),T()}));x=N.clearBtn;const I=r.divV([N.root,r.div([l,a],{style:{padding:"0"}})],{style:S}),M=E("R-Groups",(async()=>{const t=await vo(e);if(!t)return;const o=n.rGroupsByNum.get(t.rNumber)??[];o.push(t),n.rGroupsByNum.set(t.rNumber,o),T()}),(async()=>{const t=await Co("rgroups",e,n.mode===io.PI.Cartesian);if(t?.rGroups){for(const e of t.rGroups){const t=n.rGroupsByNum.get(e.rNumber)??[];t.push(e),n.rGroupsByNum.set(e.rNumber,t)}T()}}),(()=>{n.rGroupsByNum.clear(),T()}));w=M.clearBtn;const P=r.divV([M.root,d],{style:{display:"flex",flexDirection:"column",maxHeight:"300px",padding:"4px 0"}}),_=r.divV([E("Preview").root,f],{style:{...S,width:"100%",height:"100%",overflowY:"auto",overflowX:"hidden"}}),L=r.divV([I,P],{style:{flex:"0 0 60%",width:"60%",display:"flex",flexDirection:"column",gap:"4px",paddingRight:"8px",borderRight:"1px solid var(--grey-2)"}}),O=r.divV([_],{style:{flex:"0 0 40%",width:"40%",display:"flex",flexDirection:"column",paddingLeft:"8px"}}),R=r.divH([L,O],{style:{width:"100%",alignItems:"stretch",gap:"0"}}),$=r.divH([b.root,g,y.root],{style:{alignItems:"center",gap:"16px",padding:"4px 0"}}),D=r.div([C.root],{style:{padding:"2px 0"}}),B=r.divV([R,$,D],{style:{width:"100%",padding:"4px",display:"flex",flexDirection:"column",gap:"4px"}});return T(),{root:B,state:n,execute:()=>async function(e){const t=i.TaskBarProgressIndicator.create("Enumerating...");try{t.update(10,"Building molecules...");const n=(0,io.jp)({cores:e.cores,rGroups:e.rGroupsByNum,mode:e.mode});if(!n)return void o.shell.warning("Enumeration failed — check validation messages in the dialog.");if(0===n.length)return void o.shell.warning("No molecules produced.");const r=new Set;for(const e of n)for(const t of e.rGroupSmilesByNum.keys())r.add(t);const s=[...r].sort(((e,t)=>e-t)),a=i.Column.fromStrings("Enumerated",n.map((e=>e.smiles)));a.semType=i.SEMTYPE.MOLECULE;const l=i.Column.fromStrings("Core",n.map((e=>e.coreSmiles)));l.semType=i.SEMTYPE.MOLECULE;const c=s.map((e=>i.Column.fromStrings(`R${e}`,n.map((t=>t.rGroupSmilesByNum.get(e)??"")))));for(const e of c)e.semType=i.SEMTYPE.MOLECULE;const u=i.DataFrame.fromColumns([a,l,...c]);u.name="Chem Enumeration",t.update(40,`Canonicalizing ${n.length.toLocaleString()} molecule(s)...`);try{await o.functions.call("Chem:convertNotation",{data:u,molecules:a,targetNotation:i.chem.Notation.Smiles,overwrite:!0,join:!1,kekulize:!1})}catch(e){br.logger.warning(`Canonicalization skipped: ${e?.message??e}`)}t.update(90,"Finalizing..."),await o.data.detectSemanticTypes(u),e.appendToTable?(e.appendToTable.append(u,!0),await e.appendToTable.meta.detectSemanticTypes()):o.shell.addTableView(u)}catch(e){zn(e)}finally{t.close()}}(n),bindActionButton:e=>{A=e,T()}}}var To=n(6197);class Eo extends i.InputBase{constructor(e,t){super(r.input.column(e,t).dart,t?.onValueChanged),this.options=t}setColumnInputTable(e){r.input.setColumnInputTable(this,e,this.options?.filter)}}r.input.column2=function(e,t){return new Eo(e,t)};var So=n(1296),No=n(3820);class Io extends i.JsInputBase{get inputType(){return"Positions"}get dataType(){return i.TYPE.DATA_FRAME}getInput(){return this.gridHost}getValue(){return this.grid.dataFrame}setValue(e){this.setDataFrame(e)}getStringValue(){return this.grid.dataFrame.toCsv()}setStringValue(e){this.setDataFrame(i.DataFrame.fromCsv(e))}clearInput(){const e=i.DataFrame.fromColumns([i.Column.fromType(i.COLUMN_TYPE.STRING,"Remove",0),i.Column.fromType(i.COLUMN_TYPE.INT,"Position",0),i.Column.fromType(i.COLUMN_TYPE.STRING,"Monomers",0)]);this.setDataFrame(e)}get placeholdersValue(){return function(e){const t=[];for(let n=0;n<e.rowCount;n++){if(e.getCol("Position").isNone(n))continue;const o=parseInt(e.get("Position",n))-1;if(!isNaN(o)){const r=Mo(e.get("Monomers",n));t.push({position:o,monomers:r})}}return t}(this.grid.dataFrame)}invalidateGrid(){if(this.grid){const e=this.grid.root.style.width;this.grid.root.style.width="99.9%",setTimeout((()=>{e?this.grid.root.style.width=e:this.grid.root.style.removeProperty("width")}),100)}}constructor(e,t,n){super(),this.name=e,this.onMonomerCellEdit=null,this.subs=[],this.dataFrameSubs=[],this.caption=e??"",this.root.classList.add("ui-input-polytool-pos-grid"),this.root.append(this.gridHost=r.div([],{classes:"ui-input-editor",style:{width:"100%",height:"100%",marginTop:"-8px",marginBottom:"8px",paddingBottom:"4px"}})),this.render(t,n).then((()=>{}))}detach(){for(const e of this.subs)e.unsubscribe();for(const e of this.dataFrameSubs)e.unsubscribe()}async render(e,t){let n;const o=i.DataFrame.fromColumns([n=i.Column.fromType(i.COLUMN_TYPE.STRING,"Remove",0),i.Column.fromType(i.COLUMN_TYPE.INT,"Position",0),i.Column.fromType(i.COLUMN_TYPE.STRING,"Monomers",0)]);n.setTag(i.TAGS.FRIENDLY_NAME,""),this.grid=await o.plot.fromType(i.VIEWER.GRID,t),this.grid.sort(["Position"]),this.grid.columns.byIndex(1).width=this.grid.props.rowHeight+2,this.grid.onCellRender.subscribe((e=>{const t=e.cell;t.tableColumn?.name==n.name&&(t?.tableRowIndex??-1)>=0&&(t.element=r.div(r.icons.delete((()=>{this.grid.dataFrame.rows.removeAt(t.tableRowIndex)}),"Delete"),{style:{height:`${t.grid.props.rowHeight}px`,color:"var(--grey-6)",display:"flex",flexDirection:"row",justifyContent:"center"}}))}));const s=this.grid.columns.byName("Monomers");s&&(s.editable=!1),this.subs.push(this.grid.onCellDoubleClick.subscribe((e=>{"Monomers"===e.tableColumn?.name&&null!=e.tableRowIndex&&e.tableRowIndex>=0&&this.handleMonomerCellDoubleClick(e.tableRowIndex)}))),this.updateGridHeight(e??this.grid.dataFrame.rowCount+.7),this.subs.push(r.onSizeChanged(this.grid.root).subscribe(this.gridRootOnSizeChanged.bind(this))),this.subs.push((0,te.fromEvent)(this.grid.root,"keydown").subscribe((e=>{"Enter"===e.key&&e.stopPropagation()}))),this.setDataFrame(o),this.grid.root.style.width="100%",this.gridHost.append(this.grid.root)}setDataFrame(e){for(const e of this.dataFrameSubs)e.unsubscribe();this.grid.dataFrame=e,this.dataFrameSubs.push(this.grid.dataFrame.onRowsRemoved.subscribe((()=>{this.updateGridHeight(this.grid.dataFrame.rowCount+.7),this.fireChanged()}))),this.dataFrameSubs.push(this.grid.dataFrame.onRowsAdded.subscribe((()=>{this.updateGridHeight(this.grid.dataFrame.rowCount+.7)}))),this.dataFrameSubs.push(this.grid.dataFrame.onDataChanged.subscribe((()=>{this.fireChanged()}))),this.updateGridHeight(this.grid.dataFrame.rowCount+.7),this.fireChanged()}addPosition(e,t){const n=this.grid.dataFrame,o=n.columns.byName("Position").toList();let r=o.indexOf(e+1);-1===r&&(r=o.findIndex((e=>isNaN(e))),-1===r&&(r=n.rows.addNew(["",e+1,t??""]).idx),this.grid.cell("Monomers",r)),n.currentCell=n.cell(r,"Monomers")}setMonomersValue(e,t){const n=this.grid.dataFrame;n.rowCount<=e||n.set("Monomers",e,t)}static async create(e,t,n){return new Io(e,n,t)}updateGridHeight(e){const t=this.grid.colHeaderHeight+e*this.grid.props.rowHeight+6+2;this.grid.root.style.height=`${t}px`}async handleMonomerCellDoubleClick(e){if(!this.onMonomerCellEdit)return;const t=this.grid.dataFrame,n=parseInt(t.get("Position",e))-1;if(isNaN(n))return;const o=Mo(t.get("Monomers",e)??""),r=await this.onMonomerCellEdit(n,o);null!==r&&t.set("Monomers",e,r.join(", "))}gridRootOnSizeChanged(){this.grid.columns.byIndex(3).width=this.grid.root.clientWidth-this.grid.horzScroll.root.offsetWidth-this.grid.columns.byIndex(0).width-this.grid.columns.byIndex(1).width-this.grid.columns.byIndex(2).width-10}}function Mo(e){return e.split(/,(?![^(]*\))/).map((e=>('"'===(e=e.trim()).slice(0,1)&&'"'===e.slice(-1)&&(e=e.slice(1,-1)),"'"===e.slice(0,1)&&"'"===e.slice(-1)&&(e=e.slice(1,-1)),e.trim()))).filter((e=>!!e))}class Po{constructor(e,t,n,o){this.currentMenu=null,this.menuItems=[],this.highlightedIndex=-1,this.monomerLib=e,this.polymerType=t,this.helmType=(0,a.MD)(t),this.allSymbols=e.getMonomerSymbolsByType(t),this.libHelper=o,this.selectedMonomers=n?[...n]:[],this.tagsHost=r.div([],{style:{display:"flex",flexWrap:"wrap",gap:"4px",marginTop:"4px",maxHeight:"150px",overflowY:"auto"}}),this.countLabel=r.divText("",{style:{fontSize:"11px",color:"var(--grey-4)",marginTop:"4px"}});const i=r.input.string("Search",{value:""});this.inputEl=i.input,this.inputEl.setAttribute("autocomplete","off"),this.inputEl.placeholder="Type to search monomers...",this.setupInputListeners();const s=this.createLibrarySection(),l=this.createCollectionSection(),c=r.button("Clear all",(()=>{this.selectedMonomers.length=0,this.renderTags()}));c.style.fontSize="11px",c.style.marginTop="4px",this.renderTags(),this.root=r.div([i.root,s,l,r.divH([this.countLabel,c],{style:{justifyContent:"space-between",alignItems:"center"}}),this.tagsHost],{style:{minWidth:"300px"}})}getSelectedMonomers(){return[...this.selectedMonomers]}setSelectedMonomers(e){this.selectedMonomers.length=0,this.selectedMonomers.push(...e),this.renderTags()}setPolymerType(e){this.polymerType=e,this.helmType=(0,a.MD)(e),this.allSymbols=this.monomerLib.getMonomerSymbolsByType(e)}focus(){this.inputEl.focus()}updateCountLabel(){this.countLabel.textContent=this.selectedMonomers.length>0?`${this.selectedMonomers.length} monomer(s) selected`:""}renderTags(){this.tagsHost.innerHTML="";for(const e of this.selectedMonomers){const t=r.iconFA("times",(()=>{const t=this.selectedMonomers.indexOf(e);t>=0&&(this.selectedMonomers.splice(t,1),this.renderTags(),this.updateCountLabel())}),"Remove");t.style.marginLeft="4px",t.style.cursor="pointer";const n=r.div([r.span([e]),t],{style:{display:"inline-flex",alignItems:"center",padding:"2px 6px",borderRadius:"4px",backgroundColor:"var(--grey-2)",border:"1px solid var(--grey-3)",fontSize:"12px",cursor:"default"}});n.addEventListener("mouseenter",(()=>{const t=this.monomerLib.getTooltip(this.helmType,e);r.tooltip.show(t,n.getBoundingClientRect().left,n.getBoundingClientRect().bottom+16)})),n.addEventListener("mouseleave",(()=>{r.tooltip.hide()})),this.tagsHost.appendChild(n)}this.updateCountLabel()}addMonomer(e){this.selectedMonomers.includes(e)||(this.selectedMonomers.push(e),this.renderTags()),this.inputEl.value="",this.hideMenu(),this.inputEl.focus()}addMonomers(e){let t=!1;for(const n of e)this.selectedMonomers.includes(n)||(this.selectedMonomers.push(n),t=!0);t&&this.renderTags()}hideMenu(){this.currentMenu&&(this.currentMenu.hide(),this.currentMenu=null),this.menuItems=[],this.highlightedIndex=-1}getSuggestions(e){const t=e.toLowerCase(),n=[];for(const e of this.allSymbols){if(this.selectedMonomers.includes(e))continue;const o=this.monomerLib.getMonomer(this.polymerType,e),r=e.toLowerCase(),i=o?.name?.toLowerCase()??"";r.startsWith(t)?n.push({symbol:e,monomer:o,rank:0}):r.includes(t)?n.push({symbol:e,monomer:o,rank:1}):i.includes(t)&&n.push({symbol:e,monomer:o,rank:2})}return n.sort(((e,t)=>e.rank-t.rank||e.symbol.localeCompare(t.symbol))),n.slice(0,20)}showSuggestions(){this.hideMenu();const e=this.inputEl.value.trim();if(!e)return;const t=this.getSuggestions(e);if(0===t.length)return;this.currentMenu=i.Menu.popup();const n=t.reduce(((e,t)=>{const n=t.monomer?.name?`${t.symbol} - ${t.monomer.name}`:t.symbol;return e.length<n.length?n:e}),"");this.currentMenu.item(n,(()=>{}));const o=new MouseEvent("mousemove",{clientX:this.inputEl.getBoundingClientRect().left,clientY:this.inputEl.getBoundingClientRect().bottom});this.currentMenu.show({causedBy:o,y:this.inputEl.offsetHeight+this.inputEl.offsetTop,x:this.inputEl.offsetLeft}),setTimeout((()=>{this.currentMenu?.clear();for(const e of t){const t=e.monomer?.name?`${e.symbol} - ${e.monomer.name}`:e.symbol;this.currentMenu?.item(t,(()=>{this.addMonomer(e.symbol)}))}const e=document.querySelector(".d4-menu-popup:last-of-type");e&&(this.menuItems=Array.from(e.querySelectorAll(".d4-menu-item"))),this.highlightedIndex=-1}),0)}updateHighlight(e){0!==this.menuItems.length&&(this.highlightedIndex>=0&&this.highlightedIndex<this.menuItems.length&&this.menuItems[this.highlightedIndex].classList.remove("d4-menu-item-hover"),this.highlightedIndex=e,this.highlightedIndex>=0&&this.highlightedIndex<this.menuItems.length&&(this.menuItems[this.highlightedIndex].classList.add("d4-menu-item-hover"),this.menuItems[this.highlightedIndex].scrollIntoView({block:"nearest"})))}setupInputListeners(){this.inputEl.addEventListener("input",(()=>{this.showSuggestions()})),this.inputEl.addEventListener("paste",(e=>{const t=e.clipboardData?.getData("text");if(!t)return;const n=t.split(/[\n\r]+/).map((e=>e.trim())).filter((e=>e.length>0)),o=[];for(const e of n){const t=e.split(/,(?![^(]*\))/).map((e=>('"'===(e=e.trim()).slice(0,1)&&'"'===e.slice(-1)&&(e=e.slice(1,-1)),"'"===e.slice(0,1)&&"'"===e.slice(-1)&&(e=e.slice(1,-1)),e.trim()))).filter((e=>!!e));1===t.length&&e.includes(" ")&&!e.includes(",")?o.push(...e.split(/\s+/).map((e=>e.trim())).filter((e=>e.length>0))):o.push(...t)}if(!(o.length<=1)){e.preventDefault();for(const e of o)this.selectedMonomers.includes(e)||this.selectedMonomers.push(e);this.renderTags(),this.inputEl.value="",this.hideMenu(),this.inputEl.focus()}})),this.inputEl.addEventListener("keydown",(e=>{if("ArrowDown"===e.key){if(e.preventDefault(),this.menuItems.length>0){const e=(this.highlightedIndex+1)%this.menuItems.length;this.updateHighlight(e)}}else if("ArrowUp"===e.key){if(e.preventDefault(),this.menuItems.length>0){const e=(this.highlightedIndex-1+this.menuItems.length)%this.menuItems.length;this.updateHighlight(e)}}else if("Enter"===e.key)if(e.preventDefault(),e.stopPropagation(),this.highlightedIndex>=0&&this.highlightedIndex<this.menuItems.length)this.menuItems[this.highlightedIndex].click();else{const e=this.inputEl.value.trim();e&&this.addMonomer(e)}else"Escape"===e.key&&this.hideMenu()}))}createLibrarySection(){const e=r.div([],{style:{marginTop:"8px"}});if(!this.libHelper)return e;const t=this.libHelper,n=r.input.choice("Add from library",{items:[],nullable:!0}),o=r.divText("",{style:{fontSize:"11px",color:"var(--green-2)",marginLeft:"8px",minHeight:"16px"}});return t.getAvaliableLibraryNames().then((e=>{n.items=e})),n.onChanged.subscribe((async()=>{const e=n.value;if(e){o.textContent="Loading...";try{const n=await t.readSingleLibraryByName(e);if(n){const t=n.getMonomerSymbolsByType(this.polymerType),r=this.selectedMonomers.length;this.addMonomers(t);const i=this.selectedMonomers.length-r;o.textContent=`Added ${i} monomer(s) from "${e}"`}else o.textContent=`Library "${e}" not found`}catch(e){o.textContent="Error loading library"}n.value=null,setTimeout((()=>{o.textContent=""}),4e3)}})),e.appendChild(r.divV([n.root,o])),e}createCollectionSection(){const e=r.div([],{style:{marginTop:"4px"}});if(!this.libHelper)return e;const t=this.libHelper,n=r.input.choice("Add from collection",{items:[],nullable:!0}),o=r.divText("",{style:{fontSize:"11px",color:"var(--green-2)",marginLeft:"8px",minHeight:"16px"}});return t.listMonomerCollections().then((e=>{n.items=e})),n.onChanged.subscribe((async()=>{const e=n.value;if(e){o.textContent="Loading...";try{const n=(await t.readMonomerCollection(e)).monomerSymbols??[],r=this.selectedMonomers.length;this.addMonomers(n);const i=this.selectedMonomers.length-r,s=e.replace(/\.json$/,"");o.textContent=`Added ${i} monomer(s) from "${s}"`}catch(e){o.textContent="Error loading collection"}n.value=null,setTimeout((()=>{o.textContent=""}),4e3)}})),e.appendChild(r.divV([n.root,o])),e}}async function _o(e,t,n,o){return new Promise((i=>{const s=new Po(e,t,n,o);r.dialog({title:"Select Monomers",showFooter:!0}).add(r.div([s.root],{style:{minWidth:"400px",minHeight:"250px",maxWidth:"800px"}})).onOK((()=>{i(s.getSelectedMonomers())})).onCancel((()=>{i(null)})).show({resizable:!0}),s.focus()}))}class Lo extends i.JsInputBase{get inputType(){return"Breadth"}get dataType(){return i.TYPE.DATA_FRAME}getInput(){return this.gridHost}getValue(){return this.grid.dataFrame}setValue(e){this.setDataFrame(e)}invalidateGrid(){if(this.grid){const e=this.grid.root.style.width;this.grid.root.style.width="99.9%",setTimeout((()=>{e?this.grid.root.style.width=e:this.grid.root.style.removeProperty("width")}),100)}}getStringValue(){return this.grid.dataFrame.toCsv()}setStringValue(e){this.setDataFrame(i.DataFrame.fromCsv(e))}get placeholdersBreadthValue(){return function(e){const t=[];for(let n=0;n<e.rowCount;n++){const o=parseInt(e.get("Start",n))-1,r=parseInt(e.get("End",n))-1;if(!isNaN(o)&&!isNaN(r)){const i=Mo(e.get("Monomers",n));t.push({start:o,end:r,monomers:i})}}return t}(this.grid.dataFrame)}constructor(e,t,n){super(),this.name=e,this.onMonomerCellEdit=null,this.subs=[],this.dataFrameSubs=[],this.caption=e??"",this.root.classList.add("ui-input-polytool-pos-grid"),this.root.append(this.gridHost=r.div([],{classes:"ui-input-editor",style:{width:"100%",height:"100%",marginTop:"-8px",marginBottom:"8px",paddingBottom:"4px"}})),this.render(t,n).then((()=>{}))}detach(){for(const e of this.subs)e.unsubscribe();for(const e of this.dataFrameSubs)e.unsubscribe()}clearInput(){const e=i.DataFrame.fromColumns([i.Column.fromType(i.COLUMN_TYPE.STRING,"Remove",0),i.Column.fromType(i.COLUMN_TYPE.INT,"Start",0),i.Column.fromType(i.COLUMN_TYPE.INT,"End",0),i.Column.fromType(i.COLUMN_TYPE.STRING,"Monomers",0)]);this.setDataFrame(e)}async render(e,t){let n;const o=i.DataFrame.fromColumns([n=i.Column.fromType(i.COLUMN_TYPE.STRING,"Remove",0),i.Column.fromType(i.COLUMN_TYPE.INT,"Start",0),i.Column.fromType(i.COLUMN_TYPE.INT,"End",0),i.Column.fromType(i.COLUMN_TYPE.STRING,"Monomers",0)]);n.setTag(i.TAGS.FRIENDLY_NAME,""),this.grid=await o.plot.fromType(i.VIEWER.GRID,t),this.grid.sort(["Start","End"]),this.grid.columns.byIndex(1).width=this.grid.props.rowHeight+2,this.grid.onCellRender.subscribe((e=>{const t=e.cell;t.tableColumn?.name==n.name&&(t?.tableRowIndex??-1)>=0&&(t.element=r.div(r.icons.delete((()=>{this.grid.dataFrame.rows.removeAt(t.tableRowIndex)}),"Delete"),{style:{height:`${t.grid.props.rowHeight}px`,color:"var(--grey-6)",display:"flex",flexDirection:"row",justifyContent:"center"}}))}));const s=this.grid.columns.byName("Monomers");s&&(s.editable=!1),this.subs.push(this.grid.onCellDoubleClick.subscribe((e=>{"Monomers"===e.tableColumn?.name&&null!=e.tableRowIndex&&e.tableRowIndex>=0&&this.handleMonomerCellDoubleClick(e.tableRowIndex)}))),this.updateGridHeight(e??this.grid.dataFrame.rowCount+.7),this.subs.push(r.onSizeChanged(this.grid.root).subscribe(this.gridRootOnSizeChanged.bind(this))),this.subs.push((0,te.fromEvent)(this.grid.root,"keydown").subscribe((e=>{"Enter"===e.key&&e.stopPropagation()}))),this.setDataFrame(o),this.grid.root.style.width="100%",this.gridHost.append(this.grid.root)}setDataFrame(e){for(const e of this.dataFrameSubs)e.unsubscribe();this.grid.dataFrame=e,this.dataFrameSubs.push(this.grid.dataFrame.onRowsRemoved.subscribe((()=>{this.updateGridHeight(this.grid.dataFrame.rowCount+.7),this.fireChanged()}))),this.dataFrameSubs.push(this.grid.dataFrame.onRowsAdded.subscribe((()=>{this.updateGridHeight(this.grid.dataFrame.rowCount+.7)}))),this.dataFrameSubs.push(this.grid.dataFrame.onDataChanged.subscribe((()=>{this.fireChanged()}))),this.updateGridHeight(this.grid.dataFrame.rowCount+.7),this.fireChanged()}static async create(e,t,n){return new Lo(e,n,t)}updateGridHeight(e){const t=this.grid.colHeaderHeight+e*this.grid.props.rowHeight+6+2;this.grid.root.style.height=`${t}px`}async handleMonomerCellDoubleClick(e){if(!this.onMonomerCellEdit)return;const t=this.grid.dataFrame,n=parseInt(t.get("Start",e))-1,o=parseInt(t.get("End",e))-1;if(isNaN(n)||isNaN(o))return;const r=Mo(t.get("Monomers",e)??""),i=await this.onMonomerCellEdit(n,o,r);null!==i&&t.set("Monomers",e,i.join(", "))}gridRootOnSizeChanged(){this.grid.columns.byIndex(4).width=this.grid.root.clientWidth-this.grid.horzScroll.root.offsetWidth-this.grid.columns.byIndex(0).width-this.grid.columns.byIndex(1).width-this.grid.columns.byIndex(2).width-this.grid.columns.byIndex(3).width-10}}var Oo=n(6307),Ro=n(2738);n(9982),DG.DataFrame.fromCsv('countries,fasta,smiles,molregno,LON,Zip Code,Street Address Line 1,ImageUrl,user_id,error_message,xray,flag,magnitude,CS-id,pdb_id,accel_a,time_offset,chart,fit,Questions,empty_number,empty_string\nBelgium,MSNFHNEHVMQFYRNNLKTKGVFGRQ,CC(C(=O)OCCCc1cccnc1)c2cccc(c2)C(=O)c3ccccc3,1480014,36.276729583740234,995042300,14016 ROUTE 31W,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,1,1,1QBS,1,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[2.497360340644872, 1.7058694986686864, 5.278052678195135, 0.16000320889028383],""points"":[{""x"":0.10000000149011612,""y"":2.374499797821045},{""x"":0.6000000238418579,""y"":2.6242473125457764},{""x"":1.100000023841858,""y"":2.367267608642578},{""x"":1.600000023841858,""y"":2.6723148822784424},{""x"":2.0999999046325684,""y"":2.6537344455718994},{""x"":2.5999999046325684,""y"":2.3651671409606934},{""x"":3.0999999046325684,""y"":2.5654284954071045},{""x"":3.5999999046325684,""y"":2.4160959720611572},{""x"":4.099999904632568,""y"":2.286726713180542},{""x"":4.599999904632568,""y"":2.5100042819976807},{""x"":5.099999904632568,""y"":1.6676985025405884},{""x"":5.599999904632568,""y"":0.680136501789093},{""x"":6.099999904632568,""y"":0.3391543924808502},{""x"":6.599999904632568,""y"":0.09038983285427094},{""x"":7.099999904632568,""y"":0.19802775979042053}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[7.525235855508179, 1.3186911876809984, 5.335672608564294, 0.7860743343958098],""points"":[{""x"":0.10000000149011612,""y"":7.988070487976074},{""x"":0.6000000238418579,""y"":7.018453121185303},{""x"":1.100000023841858,""y"":8.115279197692871},{""x"":1.600000023841858,""y"":7.486658096313477},{""x"":2.0999999046325684,""y"":7.396438121795654},{""x"":2.5999999046325684,""y"":7.477052211761475},{""x"":3.0999999046325684,""y"":6.913095474243164},{""x"":3.5999999046325684,""y"":8.01385498046875},{""x"":4.099999904632568,""y"":6.985900402069092},{""x"":4.599999904632568,""y"":6.970335960388184},{""x"":5.099999904632568,""y"":5.448817253112793},{""x"":5.599999904632568,""y"":2.5534818172454834},{""x"":6.099999904632568,""y"":1.893947958946228},{""x"":6.599999904632568,""y"":0.6340042352676392},{""x"":7.099999904632568,""y"":0.8403874039649963}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,100,abc\nBurundi,MDYKETLLMPKTDFPMRGGLPNKEPQIQEKW,COc1ccc2cc(ccc2c1)C(C)C(=O)Oc3ccc(C)cc3OC,1480015,36.276729583740234,995073444,80 STATE HIGHWAY 310,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,2,2,1ZP8,2,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[4.431460753103398, 2.1691498799246745, 5.266445597102774, 0.7825762827017926],""points"":[{""x"":0.10000000149011612,""y"":4.751083850860596},{""x"":0.6000000238418579,""y"":4.203000068664551},{""x"":1.100000023841858,""y"":4.415858745574951},{""x"":1.600000023841858,""y"":4.68414306640625},{""x"":2.0999999046325684,""y"":4.198400974273682},{""x"":2.5999999046325684,""y"":4.179222106933594},{""x"":3.0999999046325684,""y"":4.638473987579346},{""x"":3.5999999046325684,""y"":4.708553314208984},{""x"":4.099999904632568,""y"":4.291589260101318},{""x"":4.599999904632568,""y"":4.038082599639893},{""x"":5.099999904632568,""y"":3.4349939823150635},{""x"":5.599999904632568,""y"":1.2194708585739136},{""x"":6.099999904632568,""y"":1.1920831203460693},{""x"":6.599999904632568,""y"":0.5352635979652405},{""x"":7.099999904632568,""y"":0.3346920311450958}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[2.339458017970126, -1.0734184310171178, 4.746332950550934, 0.2482416857595658],""points"":[{""x"":0.10000000149011612,""y"":0.2139337658882141},{""x"":0.6000000238418579,""y"":0.4269562065601349},{""x"":1.100000023841858,""y"":0.2441573292016983},{""x"":1.600000023841858,""y"":0.146635964512825},{""x"":2.0999999046325684,""y"":0.08818462491035461},{""x"":2.5999999046325684,""y"":0.2560656666755676},{""x"":3.0999999046325684,""y"":0.42434045672416687},{""x"":3.5999999046325684,""y"":0.37111231684684753},{""x"":4.099999904632568,""y"":0.5581737160682678},{""x"":4.599999904632568,""y"":1.183590054512024},{""x"":5.099999904632568,""y"":1.5629843473434448},{""x"":5.599999904632568,""y"":2.3211288452148438},{""x"":6.099999904632568,""y"":2.229961633682251},{""x"":6.599999904632568,""y"":2.2560226917266846},{""x"":7.099999904632568,""y"":2.2142398357391357}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCameroon,MIEVFLFGIVLGLIPITLAGLFVTAYLQYRRGDQLDL,COc1ccc2cc(ccc2c1)C(C)C(=O)OCCCc3cccnc3,1480016,36.26095962524414,995153596,30-56 WHITESTONE EXPY,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,3,3,2BDJ,3,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[4.6760652578642325, 0.9046956320756703, 5.651408971856738, 0.07738846012184185],""points"":[{""x"":0.10000000149011612,""y"":4.32425594329834},{""x"":0.6000000238418579,""y"":4.668442249298096},{""x"":1.100000023841858,""y"":4.379785060882568},{""x"":1.600000023841858,""y"":5.0345139503479},{""x"":2.0999999046325684,""y"":4.878653526306152},{""x"":2.5999999046325684,""y"":4.3451313972473145},{""x"":3.0999999046325684,""y"":4.336992263793945},{""x"":3.5999999046325684,""y"":5.037430286407471},{""x"":4.099999904632568,""y"":5.0092692375183105},{""x"":4.599999904632568,""y"":4.151902675628662},{""x"":5.099999904632568,""y"":3.4066951274871826},{""x"":5.599999904632568,""y"":2.3732759952545166},{""x"":6.099999904632568,""y"":1.673728108406067},{""x"":6.599999904632568,""y"":0.48574790358543396},{""x"":7.099999904632568,""y"":0.2783052325248718}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[2.938395863010111, -1.4658480661392117, 5.462702751996584, 0.3473139023615039],""points"":[{""x"":0.10000000149011612,""y"":0.4941710829734802},{""x"":0.6000000238418579,""y"":0.15323974192142487},{""x"":1.100000023841858,""y"":0.46373432874679565},{""x"":1.600000023841858,""y"":0.3370431363582611},{""x"":2.0999999046325684,""y"":0.5179030299186707},{""x"":2.5999999046325684,""y"":0.27899765968322754},{""x"":3.0999999046325684,""y"":0.22075064480304718},{""x"":3.5999999046325684,""y"":0.5789918899536133},{""x"":4.099999904632568,""y"":0.21169911324977875},{""x"":4.599999904632568,""y"":0.27857646346092224},{""x"":5.099999904632568,""y"":1.0906332731246948},{""x"":5.599999904632568,""y"":1.8520300388336182},{""x"":6.099999904632568,""y"":2.7177059650421143},{""x"":6.599999904632568,""y"":2.8680918216705322},{""x"":7.099999904632568,""y"":3.2413077354431152}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCanada,MMELVLKTIIGPIVVGVVLRIVDKWLNKDK,CC(C(=O)NCCS)c1cccc(c1)C(=O)c2ccccc2,1480017,36.26095962524414,99515,30-56 WHITESTONE EXPY,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,4,4,1IAN,4,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[0.8597390975430008, 1.0957625732481946, 5.260537067987958, 0.07974187998177736],""points"":[{""x"":0.10000000149011612,""y"":0.8190152645111084},{""x"":0.6000000238418579,""y"":0.8421689867973328},{""x"":1.100000023841858,""y"":0.8740922212600708},{""x"":1.600000023841858,""y"":0.8924275040626526},{""x"":2.0999999046325684,""y"":0.8249067664146423},{""x"":2.5999999046325684,""y"":0.9327669143676758},{""x"":3.0999999046325684,""y"":0.8522974252700806},{""x"":3.5999999046325684,""y"":0.8174492716789246},{""x"":4.099999904632568,""y"":0.8394647240638733},{""x"":4.599999904632568,""y"":0.7139387726783752},{""x"":5.099999904632568,""y"":0.5561167597770691},{""x"":5.599999904632568,""y"":0.3276226818561554},{""x"":6.099999904632568,""y"":0.12479474395513535},{""x"":6.599999904632568,""y"":0.13006797432899475},{""x"":7.099999904632568,""y"":0.059702079743146896}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.760930219582546, 1.6591793293833013, 4.667155929720851, 0.7858109544121652],""points"":[{""x"":0.10000000149011612,""y"":6.156993389129639},{""x"":0.6000000238418579,""y"":5.236701965332031},{""x"":1.100000023841858,""y"":6.010560512542725},{""x"":1.600000023841858,""y"":5.495512962341309},{""x"":2.0999999046325684,""y"":6.087770462036133},{""x"":2.5999999046325684,""y"":5.79986572265625},{""x"":3.0999999046325684,""y"":5.597546577453613},{""x"":3.5999999046325684,""y"":5.520902156829834},{""x"":4.099999904632568,""y"":5.360654354095459},{""x"":4.599999904632568,""y"":3.5539746284484863},{""x"":5.099999904632568,""y"":1.577236294746399},{""x"":5.599999904632568,""y"":1.0001264810562134},{""x"":6.099999904632568,""y"":0.9305797815322876},{""x"":6.599999904632568,""y"":0.6033638715744019},{""x"":7.099999904632568,""y"":0.4203685522079468}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nColombia,MDRTDEVSNHTHDKPTLTWFEEIFEEYHSPFHN,FC(F)(F)c1ccc(OC2CCNCC2)cc1,1480029,36.3309440612793,995152050,1 COURT HOUSE SQUARE,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,5,5,4UJ1,5,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[6.4995088314153655, 2.4270351004539914, 5.178659535348579, 0.625653346241577],""points"":[{""x"":0.10000000149011612,""y"":6.496231555938721},{""x"":0.6000000238418579,""y"":6.42543363571167},{""x"":1.100000023841858,""y"":7.040063858032227},{""x"":1.600000023841858,""y"":6.1115403175354},{""x"":2.0999999046325684,""y"":6.680728435516357},{""x"":2.5999999046325684,""y"":6.406774520874023},{""x"":3.0999999046325684,""y"":6.611269474029541},{""x"":3.5999999046325684,""y"":5.889094352722168},{""x"":4.099999904632568,""y"":6.75344705581665},{""x"":4.599999904632568,""y"":6.361435890197754},{""x"":5.099999904632568,""y"":4.1666975021362305},{""x"":5.599999904632568,""y"":1.172118902206421},{""x"":6.099999904632568,""y"":0.801048994064331},{""x"":6.599999904632568,""y"":0.4640021026134491},{""x"":7.099999904632568,""y"":0.0010357667924836278}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[1.4734381347446401, 1.1649805188074196, 4.82958608866421, 0.09500545496710007],""points"":[{""x"":0.10000000149011612,""y"":1.5279096364974976},{""x"":0.6000000238418579,""y"":1.3559974431991577},{""x"":1.100000023841858,""y"":1.5246378183364868},{""x"":1.600000023841858,""y"":1.5567657947540283},{""x"":2.0999999046325684,""y"":1.4114240407943726},{""x"":2.5999999046325684,""y"":1.4045010805130005},{""x"":3.0999999046325684,""y"":1.4769829511642456},{""x"":3.5999999046325684,""y"":1.4875500202178955},{""x"":4.099999904632568,""y"":1.2991987466812134},{""x"":4.599999904632568,""y"":0.922961413860321},{""x"":5.099999904632568,""y"":0.6520044803619385},{""x"":5.599999904632568,""y"":0.15350978076457977},{""x"":6.099999904632568,""y"":0.1078903079032898},{""x"":6.599999904632568,""y"":0.17276449501514435},{""x"":7.099999904632568,""y"":0.14066608250141144}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCosta Rica,MKSTKEEIQTIKTLLKDSRTAKYHKRLQIVL,CC(C)Cc1ccc(cc1)C(C)C(=O)N2CCCC2C(=O)OCCCc3ccccc3,1480018,36.3309440612793,995084218,4041 SOUTHWESTERN BLVD,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,6,6,2BPW,6,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[2.4833641843311227, -1.8945978742090062, 4.671127708092568, 0.24159861311815153],""points"":[{""x"":0.10000000149011612,""y"":0.0969524160027504},{""x"":0.6000000238418579,""y"":0.028483040630817413},{""x"":1.100000023841858,""y"":0.22087176144123077},{""x"":1.600000023841858,""y"":0.0068915546871721745},{""x"":2.0999999046325684,""y"":0.4305879771709442},{""x"":2.5999999046325684,""y"":0.44774115085601807},{""x"":3.0999999046325684,""y"":0.45346319675445557},{""x"":3.5999999046325684,""y"":0.2370593100786209},{""x"":4.099999904632568,""y"":0.4657953977584839},{""x"":4.599999904632568,""y"":1.155200719833374},{""x"":5.099999904632568,""y"":2.2294070720672607},{""x"":5.599999904632568,""y"":2.4311530590057373},{""x"":6.099999904632568,""y"":2.33846116065979},{""x"":6.599999904632568,""y"":2.608201026916504},{""x"":7.099999904632568,""y"":2.8136143684387207}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.224573521642033, 1.4454033924198528, 5.6014197746076535, 0.2823216054197577],""points"":[{""x"":0.10000000149011612,""y"":4.95027494430542},{""x"":0.6000000238418579,""y"":5.1754679679870605},{""x"":1.100000023841858,""y"":5.276752948760986},{""x"":1.600000023841858,""y"":5.589294910430908},{""x"":2.0999999046325684,""y"":5.616994857788086},{""x"":2.5999999046325684,""y"":5.120813846588135},{""x"":3.0999999046325684,""y"":5.340766906738281},{""x"":3.5999999046325684,""y"":4.876471042633057},{""x"":4.099999904632568,""y"":4.94999361038208},{""x"":4.599999904632568,""y"":5.162564754486084},{""x"":5.099999904632568,""y"":4.399557590484619},{""x"":5.599999904632568,""y"":2.7977969646453857},{""x"":6.099999904632568,""y"":1.0229872465133667},{""x"":6.599999904632568,""y"":0.48275601863861084},{""x"":7.099999904632568,""y"":0.10408931970596313}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCuba,MHAILRYFIRRLFYHIFYKIYSLISKKHQSLPSDVRQF,COc1ccc2c(c1)c(CC(=O)N3CCCC3C(=O)Oc4ccc(C)cc4OC)c(C)n2C(=O)c5ccc(Cl)cc5,1480019,36.33115768432617,995081928,1227 US HIGHWAY 11,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,7,7,1QBS,7,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[3.320838679713925, -1.2421619987316728, 4.831325425225256, 0.3236011098403072],""points"":[{""x"":0.10000000149011612,""y"":0.3727470338344574},{""x"":0.6000000238418579,""y"":0.12365014106035233},{""x"":1.100000023841858,""y"":0.48422467708587646},{""x"":1.600000023841858,""y"":0.2264465093612671},{""x"":2.0999999046325684,""y"":0.16821794211864471},{""x"":2.5999999046325684,""y"":0.3879014551639557},{""x"":3.0999999046325684,""y"":0.5470244884490967},{""x"":3.5999999046325684,""y"":0.3419053554534912},{""x"":4.099999904632568,""y"":0.7655120491981506},{""x"":4.599999904632568,""y"":1.2346516847610474},{""x"":5.099999904632568,""y"":2.453336715698242},{""x"":5.599999904632568,""y"":2.9565491676330566},{""x"":6.099999904632568,""y"":3.335299491882324},{""x"":6.599999904632568,""y"":3.240290880203247},{""x"":7.099999904632568,""y"":3.1107218265533447}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[3.6401853521511094, 1.26211588875013, 5.399028074402744, 0.5089580830068091],""points"":[{""x"":0.10000000149011612,""y"":3.8585598468780518},{""x"":0.6000000238418579,""y"":3.6077206134796143},{""x"":1.100000023841858,""y"":3.855252265930176},{""x"":1.600000023841858,""y"":3.619039297103882},{""x"":2.0999999046325684,""y"":3.839388370513916},{""x"":2.5999999046325684,""y"":3.335283041000366},{""x"":3.0999999046325684,""y"":3.571141481399536},{""x"":3.5999999046325684,""y"":3.4155046939849854},{""x"":4.099999904632568,""y"":3.7316646575927734},{""x"":4.599999904632568,""y"":3.0680155754089355},{""x"":5.099999904632568,""y"":2.891066551208496},{""x"":5.599999904632568,""y"":1.6022753715515137},{""x"":6.099999904632568,""y"":0.7652576565742493},{""x"":6.599999904632568,""y"":0.6875326037406921},{""x"":7.099999904632568,""y"":0.5828871726989746}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nItaly,MSNFHNEHVMQFYRNNLKTKGVFGRQ,CC(C)Cc1ccc(cc1)C(C)C(=O)N2CCCC2C(=O)OCCO[N+](=O)[O-],1480020,36.33115768432617,99502,"168-46 91ST AVE., 2ND FLR",https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,8,8,1ZP8,8,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[2.293592105923809, 1.3781586549141835, 5.1025898038676605, 0.03493851245291291],""points"":[{""x"":0.10000000149011612,""y"":2.1287283897399902},{""x"":0.6000000238418579,""y"":2.267972230911255},{""x"":1.100000023841858,""y"":2.398442506790161},{""x"":1.600000023841858,""y"":2.5130622386932373},{""x"":2.0999999046325684,""y"":2.3255116939544678},{""x"":2.5999999046325684,""y"":2.127340793609619},{""x"":3.0999999046325684,""y"":2.47259783744812},{""x"":3.5999999046325684,""y"":2.131181478500366},{""x"":4.099999904632568,""y"":2.090421438217163},{""x"":4.599999904632568,""y"":2.02299165725708},{""x"":5.099999904632568,""y"":1.1105059385299683},{""x"":5.599999904632568,""y"":0.4494485855102539},{""x"":6.099999904632568,""y"":0.1375635862350464},{""x"":6.599999904632568,""y"":0.036351121962070465},{""x"":7.099999904632568,""y"":0.1619771122932434}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.953125499439879, 1.2528620255306528, 5.187637440149802, 0.3110348753260886],""points"":[{""x"":0.10000000149011612,""y"":5.6585283279418945},{""x"":0.6000000238418579,""y"":5.911152362823486},{""x"":1.100000023841858,""y"":5.924920082092285},{""x"":1.600000023841858,""y"":5.8469438552856445},{""x"":2.0999999046325684,""y"":5.929472923278809},{""x"":2.5999999046325684,""y"":6.190037727355957},{""x"":3.0999999046325684,""y"":6.236179828643799},{""x"":3.5999999046325684,""y"":6.141019344329834},{""x"":4.099999904632568,""y"":5.295210838317871},{""x"":4.599999904632568,""y"":5.265801906585693},{""x"":5.099999904632568,""y"":3.3722851276397705},{""x"":5.599999904632568,""y"":1.8299226760864258},{""x"":6.099999904632568,""y"":0.32690900564193726},{""x"":6.599999904632568,""y"":0.6274543404579163},{""x"":7.099999904632568,""y"":0.8441857099533081}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nRwanda,MPNSEPASLLELFNSIATQGELVRSLKAGNASK,CC(C)Cc1ccc(cc1)C(C)C(=O)N2CCCC2C(=O)OCCO,1480021,36.33137130737305,995037247,"168-46 91ST AVE., 2ND FLR",https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,9,9,2BDJ,9,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[3.8209972202654474, 1.3779216716448506, 5.299882228439686, 0.06040645519069608],""points"":[{""x"":0.10000000149011612,""y"":3.7821109294891357},{""x"":0.6000000238418579,""y"":3.542433023452759},{""x"":1.100000023841858,""y"":3.7008674144744873},{""x"":1.600000023841858,""y"":3.717301607131958},{""x"":2.0999999046325684,""y"":4.024452209472656},{""x"":2.5999999046325684,""y"":4.013899326324463},{""x"":3.0999999046325684,""y"":3.945094347000122},{""x"":3.5999999046325684,""y"":3.866621971130371},{""x"":4.099999904632568,""y"":3.7461626529693604},{""x"":4.599999904632568,""y"":3.3454740047454834},{""x"":5.099999904632568,""y"":2.61944317817688},{""x"":5.599999904632568,""y"":0.999405026435852},{""x"":6.099999904632568,""y"":0.46259793639183044},{""x"":6.599999904632568,""y"":0.054134611040353775},{""x"":7.099999904632568,""y"":0.05711187422275543}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.6318079657726035, 1.8495493770000595, 5.391793312471116, 0.17060707587348442],""points"":[{""x"":0.10000000149011612,""y"":5.458079814910889},{""x"":0.6000000238418579,""y"":5.554427146911621},{""x"":1.100000023841858,""y"":5.799983024597168},{""x"":1.600000023841858,""y"":5.364140033721924},{""x"":2.0999999046325684,""y"":5.864485740661621},{""x"":2.5999999046325684,""y"":5.4509806632995605},{""x"":3.0999999046325684,""y"":5.702574729919434},{""x"":3.5999999046325684,""y"":5.7314534187316895},{""x"":4.099999904632568,""y"":5.5123443603515625},{""x"":4.599999904632568,""y"":5.724395751953125},{""x"":5.099999904632568,""y"":4.354506969451904},{""x"":5.599999904632568,""y"":1.7307666540145874},{""x"":6.099999904632568,""y"":0.6305936574935913},{""x"":6.599999904632568,""y"":0.035183437168598175},{""x"":7.099999904632568,""y"":0.7575169205665588}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nSwitzerland,IRVVGRYLIEVWKAAGMDMDKVLFLWSSDEI,CN1CCC(CC1)Oc2ccc(cc2)C(F)(F)F,1480028,36.33137130737305,99504,92-11 179TH PLACE,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,9,10,1IAN,10,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[1.1190255865097471, 2.3163895161544437, 5.4968866182279195, 0.2035204047289052],""points"":[{""x"":0.10000000149011612,""y"":1.1057683229446411},{""x"":0.6000000238418579,""y"":1.1019697189331055},{""x"":1.100000023841858,""y"":1.0818607807159424},{""x"":1.600000023841858,""y"":1.062997817993164},{""x"":2.0999999046325684,""y"":1.046447515487671},{""x"":2.5999999046325684,""y"":1.1217249631881714},{""x"":3.0999999046325684,""y"":1.2166996002197266},{""x"":3.5999999046325684,""y"":1.215477705001831},{""x"":4.099999904632568,""y"":1.0581893920898438},{""x"":4.599999904632568,""y"":1.1747995615005493},{""x"":5.099999904632568,""y"":1.0181127786636353},{""x"":5.599999904632568,""y"":0.5344523191452026},{""x"":6.099999904632568,""y"":0.2569526433944702},{""x"":6.599999904632568,""y"":0.1912207305431366},{""x"":7.099999904632568,""y"":0.15060538053512573}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[3.1038581025805785, 2.0032224204185245, 5.087602825989163, 0.13277988512492753],""points"":[{""x"":0.10000000149011612,""y"":3.0498509407043457},{""x"":0.6000000238418579,""y"":2.805217742919922},{""x"":1.100000023841858,""y"":3.3415253162384033},{""x"":1.600000023841858,""y"":3.0549843311309814},{""x"":2.0999999046325684,""y"":3.250074863433838},{""x"":2.5999999046325684,""y"":3.0432586669921875},{""x"":3.0999999046325684,""y"":3.265852451324463},{""x"":3.5999999046325684,""y"":2.9475724697113037},{""x"":4.099999904632568,""y"":3.1929898262023926},{""x"":4.599999904632568,""y"":2.7460060119628906},{""x"":5.099999904632568,""y"":1.6175861358642578},{""x"":5.599999904632568,""y"":0.3006608486175537},{""x"":6.099999904632568,""y"":0.3444803059101105},{""x"":6.599999904632568,""y"":0.015537971630692482},{""x"":7.099999904632568,""y"":0.5527358055114746}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\n,,,,,,,,,,,,,,,,,,,,,').columns.add(DG.Column.fromList(DG.TYPE.BYTE_ARRAY,"BinaryImage",Array.from(new Uint8Array(11))));var $o;console.log.bind(console),console.info.bind(console),console.warn.bind(console),console.error.bind(console),function(e){e.notNull=function(e,t){if(null==e)throw new Error(`${null==t?"Value":t} not defined`)}}($o||($o={})),DG.DataFrame.fromColumns([DG.Column.fromStrings("col",["val1","val2","val3"])]);class Do{onKeyDown(e,t){}onKeyPress(e,t){}onMouseEnter(e,t){}onMouseLeave(e,t){}onMouseDown(e,t){}onMouseUp(e,t){}onMouseMove(e,t){}onClick(e,t){}onDoubleClick(e,t){}}class Bo extends Do{constructor(e,t,n){super(),this.gridCol=e,this.tableCol=t,this.logger=n,this.subs=[],this.dirty=!0,this.destroyed=!1,this.viewerId=++Bo.viewerCounter,this.errors=[],this._onRendered=new te.Subject,this.tableCol&&this.tableCol.dataFrame&&(this.subs.push(this.tableCol.dataFrame.onDataChanged.subscribe((()=>{this.dirty=!0}))),this.subs.push(this.tableCol.dataFrame.onColumnsRemoved.subscribe((e=>{try{this.destroyed||!this.tableCol||this.tableCol.dataFrame||this.destroy()}catch(e){this.logger.error(e)}})))),this.tableCol&&this.subs.push(o.events.onTableRemoved.subscribe((e=>{try{const t=e.args.dataFrame;this.tableCol?.dataFrame.id!==t.id||this.destroyed||this.destroy()}catch(e){this.logger.error(e)}}))),this.gridCol&&this.subs.push(o.events.onViewRemoving.subscribe((e=>{try{const t=e.args.view;this.gridCol?.dart&&this.gridCol.grid&&this.gridCol?.grid?.dart&&this.gridCol?.grid?.view?.id===t.id&&!this.destroyed&&this.destroy()}catch(e){this.logger.error(e)}})))}toLog(){return`${this.constructor.name}<${this.viewerId}>`}destroy(){for(const e of this.subs)e.unsubscribe();this.destroyed=!0}invalidateGrid(){this.gridCol&&this.gridCol.dart&&this.gridCol.grid?.invalidate()}reset(){this.dirty=!1}get onRendered(){return this._onRendered}invalidate(e){this.invalidateGrid()}async awaitRendered(e=1e4,t=`${e} timeout`){const n=`${this.toLog()}.awaitRendered()`;if(this.logger.debug(`${n}, start, testEvent before`),await function(e,t,n,o=0,r="timeout"){return function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function s(e){try{l(o.next(e))}catch(e){i(e)}}function a(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}l((o=o.apply(e,t||[])).next())}))}(this,void 0,void 0,(function*(){return new Promise(((i,s)=>{const a=e.subscribe((e=>{try{t(e),i("OK")}catch(e){s(e)}finally{a.unsubscribe(),clearTimeout(l)}})),l=setTimeout((()=>{a.unsubscribe(),s(r)}),o);n()}))}))}(this._onRendered,(()=>{}),(()=>{this.invalidate()}),e,`${n}, ${t}`),this.errors.length>0){const e=this.errors[0];throw this.errors=[],e}this.logger.debug(`${n}, end`)}}Bo.viewerCounter=-1;const Fo="rgb(100,100,100)",ko="rgb(0,0,0)",Ho=a.zS;var Go,Uo,Vo;!function(e){e.maxMonomerLength=".mm.cellRenderer.maxMonomerLength"}(Go||(Go={})),function(e){e.applyToBackground=".m.cellRenderer.applyToBackground"}(Uo||(Uo={})),function(e){e.MSA="MSA",e.classic="classic"}(Vo||(Vo={}));const jo=new class{constructor(){this.color=Fo,this.pivot=0,this.left=!1,this.transparencyRate=0,this.separator="",this.last=!1,this.drawStyle=Vo.classic,this.maxWord=[],this.wordIdx=0,this.gridCell=null,this.referenceSequence=null,this.maxLengthOfMonomer=null,this.monomerTextSizeMap={},this.logger=void 0,this.selectedPosition=void 0,this.isMultiLineContext=!1,this.lineNumber=0}};function qo(e,t,n,o,r,s,a){var l,c,u;const h={...jo,...a};if(h.isMultiLineContext){e.textBaseline="middle",e.textAlign="center";let i=t;null!=h.maxLengthOfMonomer&&(i=Ho(i,h.maxLengthOfMonomer));const a=Math.max(.1,1-(h.transparencyRate??0));e.globalAlpha=a;const l=e.measureText(i),c=l.fontBoundingBoxAscent+l.fontBoundingBoxDescent,u=o+(s-c)/2+l.fontBoundingBoxAscent;let d=h.color??Fo;return d&&d!==Fo||(d=ko),e.fillStyle=d,h.selectedPosition===h.wordIdx+1&&(e.save(),e.fillStyle="rgba(60, 177, 115, 0.2)",e.fillRect(n,o,r,s),e.restore(),e.fillStyle=d),e.fillText(i,n+r/2,u),e.globalAlpha=1,e.textBaseline="top",e.textAlign="start",n+r}a.logger?.debug("Bio: printLeftOrCentered(), start"),e.textAlign="start";let d=t.substring(0),p=h.last?"":h.separator;h.drawStyle===Vo.MSA&&(p="");let m=!0,f=!0,g="difference";if(null!=h.gridCell&&null!=h.gridCell.cell.column&&(m=h.gridCell.cell.column.temp["color-code"]??!0,f=h.gridCell.cell.column.temp["compare-with-current"]??!0,g=h.gridCell.cell.column.temp["highlight-difference"]??"difference"),h.referenceSequence){const e=h.referenceSequence[h.wordIdx];f&&h.referenceSequence.length>0&&"difference"===g&&(h.transparencyRate=d==e?.7:h.transparencyRate),f&&h.referenceSequence.length>0&&"equal"===g&&(h.transparencyRate=d!=e?.7:h.transparencyRate)}null!=h.maxLengthOfMonomer&&(d=Ho(d,h.maxLengthOfMonomer));const y=d+p;(l=h.monomerTextSizeMap)[y]??(l[y]=e.measureText(y));let b=h.monomerTextSizeMap[y];(c=h.monomerTextSizeMap)[d]??(c[d]=e.measureText(d));let v=h.monomerTextSizeMap[d].width;const C=s/2-(b.fontBoundingBoxAscent+b.fontBoundingBoxDescent)/2+1;(u=h.monomerTextSizeMap)[p]??(u[p]=e.measureText(p));const x=h.monomerTextSizeMap[p].width;function w(t,r){let a=m?h.color:ko;h.selectedPosition===h.wordIdx+1&&(e.fillStyle="rgba(60, 177, 115, 0.2)",e.fillRect(n+t-4,o-5,h.monomerTextSizeMap[d].width+8,s+10),a=i.Color.toHtml(i.Color.setAlpha(i.Color.fromHtml(a),255))),e.fillStyle=a,e.globalAlpha=1-h.transparencyRate,h.drawStyle===Vo.classic&&(e.fillText(d,n+t,o+C),e.fillStyle="#808080",e.fillText(p,n+r,o+C)),h.drawStyle===Vo.MSA&&e.fillText(d,n+t,o+C),e.globalAlpha=1}b=b.width,h.drawStyle===Vo.MSA&&(v=h.maxWord[h.wordIdx],b=h.maxWord[h.wordIdx]);const A=(h.maxWord[h.wordIdx]??0)-(h.maxWord[0]??0);if(h.left||b>r)return w(A,A+v),n+A+v+x;{const e=(r-b)/2;return w(e,e+v),n+A+e+v}}var Wo,zo,Yo;!function(e){e.Region="region",e.Point="point",e.Motif="motif"}(Wo||(Wo={})),function(e){e.Structure="structure",e.Liability="liability",e.PTM="ptm",e.Custom="custom"}(zo||(zo={})),function(e){e.High="high",e.Medium="medium",e.Low="low",e.Info="info"}(Yo||(Yo={}));const Ko={structure:{FR:["#0095ff","#289dfd","#48adff","#3ba5fc"],CDR:["#ffdca3","#facb83","#f7a224"]},liability:{deamidation:"#E53935",isomerization:"#FF9800",oxidation:"#9C27B0",glycosylation:"#4CAF50",freeCysteine:"#607D8B"}};class Qo{constructor(e){this.tableCol=e,this._cache=null,this._rowCache=null,this._annotCol=null,this._annotColLookupVersion=-1}hasAnnotations(){return this._ensureCache(),null!==this._cache&&this._cache.annotations.length>0}getAnnotations(){return this._ensureCache(),this._cache?.annotations??[]}getRegionNameAtPosition(e,t){if(null!=t){const n=this._findRowRegionHit(t,e);if(n){const e=this._cache?.annotations.find((e=>e.id===n.annotationId));return e?.name??null}if(this._rowHasRegionData(t))return null}return this._ensureCache(),this._cache?.positionRegionNames.get(e)??null}getHitsAtPosition(e,t){if(this._ensureRowCache(),!this._rowCache)return[];const n=this._rowCache.data[e];return n?n.filter((e=>null==e.endPositionIndex&&(e.positionIndex===t||e.matchedMonomers.length>1&&t>e.positionIndex&&t<e.positionIndex+e.matchedMonomers.length))):[]}drawPositionBackground(e,t,n,o,r,i,s,a){if(this._ensureCache(),!this._cache)return;let l;this._ensureRowCache();const c=this._findRowRegionHit(s,i);if(c){const e=this._cache.annotations.find((e=>e.id===c.annotationId));l=e?.color??(e?this._getDefaultRegionColor(e):void 0)}if(l||this._rowHasRegionData(s)||(l=this._cache.positionRegionColors.get(i)),l&&(e.save(),e.globalAlpha=.25,e.fillStyle=l,e.fillRect(t,n,o,r),e.restore()),this._rowCache){const l=this._rowCache.data[s];if(l)for(const s of l)if(null==s.endPositionIndex&&i>=s.positionIndex&&i<s.positionIndex+s.matchedMonomers.length){const i=this._cache.annotations.find((e=>e.id===s.annotationId));if(i?.color){const s=null!=a?a+1:n+r-3;e.fillStyle=i.color,e.fillRect(t,s,o,3)}break}}}getTooltipInfo(e,t){this._ensureCache();const n=[];if(!this._cache)return n;this._ensureRowCache();let o=null;const r=this._findRowRegionHit(t,e);if(r){const e=this._cache.annotations.find((e=>e.id===r.annotationId));if(e){o=e.name;const t=e.sourceScheme??"";n.push(`Region: ${e.name}${t?` (${t} ${e.start}-${e.end})`:""}`)}}if(!o&&!this._rowHasRegionData(t)){const t=this._cache.positionRegionNames.get(e);if(t){const e=this._cache.annotations.find((e=>e.name===t&&e.category===zo.Structure)),o=e?.sourceScheme??"";n.push(`Region: ${t}${o?` (${o} ${e?.start}-${e?.end})`:""}`)}}if(this._rowCache){const o=this._rowCache.data[t];if(o)for(const t of o)if(null==t.endPositionIndex&&e>=t.positionIndex&&e<t.positionIndex+t.matchedMonomers.length){const e=this._cache.annotations.find((e=>e.id===t.annotationId));if(e){const t=e.severity?` - ${e.severity.charAt(0).toUpperCase()+e.severity.slice(1)}`:"";n.push(`⚠ ${e.name}${t}`)}}}return n}_findRowRegionHit(e,t){if(this._ensureRowCache(),!this._rowCache)return null;const n=this._rowCache.data[e];if(!n)return null;for(const e of n)if(null!=e.endPositionIndex&&t>=e.positionIndex&&t<=e.endPositionIndex)return e;return null}_rowHasRegionData(e){if(this._ensureRowCache(),!this._rowCache)return!1;const t=this._rowCache.data[e];return!!t&&t.some((e=>null!=e.endPositionIndex))}_ensureCache(){const e=this.tableCol.version;if(this._cache&&this._cache.colVersion===e)return;const t=this.tableCol.getTag(s.gp.annotations);if(!t)return void(this._cache=null);let n;try{n=JSON.parse(t)}catch{return void(this._cache=null)}if(!n||0===n.length)return void(this._cache=null);const o=new Map,r=new Map,i=this._getPosList();for(const e of n){if(e.category!==zo.Structure)continue;if(null==e.start||null==e.end)continue;const t=i.indexOf(e.start),n=i.indexOf(e.end);if(t<0||n<0)continue;const s=e.color??this._getDefaultRegionColor(e);for(let i=t;i<=n;i++)o.set(i,s),r.set(i,e.name)}this._cache={colVersion:e,annotations:n,positionRegionColors:o,positionRegionNames:r}}_ensureRowCache(){const e=this.tableCol.version;if(this._annotColLookupVersion!==e){this._annotColLookupVersion=e;const t=this.tableCol.getTag(s.gp.annotationColumnName);if(t)try{this._annotCol=this.tableCol.dataFrame.columns.byName(t)}catch{this._annotCol=null}else this._annotCol=null}if(!this._annotCol)return void(this._rowCache=null);const t=this._annotCol.version;if(this._rowCache&&this._rowCache.colVersion===t)return;const n=new Array(this._annotCol.length);for(let e=0;e<this._annotCol.length;e++){const t=this._annotCol.get(e);if(t)try{n[e]=JSON.parse(t)}catch{n[e]=null}else n[e]=null}this._rowCache={colVersion:t,data:n}}_getPosList(){const e=this.tableCol.getTag(s.gp.positionNames);return e?e.split(", "):[]}_getDefaultRegionColor(e){if(e.name.startsWith("CDR")){const t=parseInt(e.name.replace("CDR",""))-1;return Ko.structure.CDR[t%Ko.structure.CDR.length]}if(e.name.startsWith("FR")){const t=parseInt(e.name.replace("FR",""))-1;return Ko.structure.FR[t%Ko.structure.FR.length]}return"#90CAF9"}}var Jo=n(3599);const Xo="bio.macromolecule.highlightMonomers",Zo=i.Color.argb(255,255,220,0);i.Color.argb(255,230,140,0);const er="rgb(100,100,100)";class tr extends Bo{get separatorWidth(){return this.props?.fontCharWidth?this.props?.fontCharWidth:5}getAnnotationRenderer(){return this._annotationRenderer||(this._annotationRenderer=new Qo(this.tableCol)),this._annotationRenderer.hasAnnotations()?this._annotationRenderer:null}constructor(e,t,n,o,r){if(super(e,t,n),this.monomerLengthLimit=o,this.propsProvider=r,this.colWidth=0,this._monomerLengthList=null,this._processedMaxVisibleSeqLength=0,this._monomerLengthMap={},this._monomerStructureMap={},this._ellipsisBounds=void 0,this._totalLinesNeeded=0,this._lineHeight=20,this._cellBounds=new Map,this.sysMonomerLib=null,this._annotationRenderer=null,this.padding=5,this._leftThreeDotsPadding=0,this.props=this.propsProvider(),this._processedRows=i.BitSet.create(this.tableCol.length),this.gridCol&&this.subs.push(this.gridCol.grid.onAfterDrawContent.subscribe((()=>{this._onRendered.next()}))),this.tableCol&&this.gridCol){this.subs.push(this.tableCol.dataFrame.onCurrentRowChanged.subscribe((()=>{-1===this.tableCol.dataFrame.currentRowIdx&&(this.tableCol.temp["reference-sequence"]=null,this.tableCol.temp["current-word"]=null,this.invalidateGrid())})));const e=[Ot.gp.positionShift,"renderMultiline"];this.subs.push(i.debounce(this.tableCol.dataFrame.onMetadataChanged.pipe(ne.filter((t=>t.args.source===this.tableCol&&e.includes(t.args.key)))),200).subscribe((e=>{this.reset()}))),this.subs.push(i.debounce(this.tableCol.dataFrame.onMetadataChanged.pipe(ne.filter((e=>e.args.source===this.tableCol&&e.args.key===Ot.gp.positionShift))),200).subscribe((e=>{this.reset()})))}}calculateFontBasedSpacing(e){const t=e.measureText("M");let n=12;if(this.tableCol?.temp[".mm.cellRenderer.fontSize"]){const e=this.tableCol.temp[".mm.cellRenderer.fontSize"];"number"!=typeof e||isNaN(e)||(n=Math.max(e,1))}return{lineHeight:Math.max(1.4*n,t.fontBoundingBoxAscent+t.fontBoundingBoxDescent+4),monomerSpacing:Math.max(2,.2*this.props.fontCharWidth)}}shouldUseMultilineRendering(e){return"true"===e.getTag("renderMultiline")}calculateMultiLineLayoutDynamic(e,t,n,o,r,i){if(this.dirty)try{this.reset()}catch(e){const[t,n]=(0,vn.AP)(e);this.logger.error(t,void 0,n)}const{lineHeight:s,monomerSpacing:a}=this.calculateFontBasedSpacing(e),l=t-2*this.padding;let c=0;const u=[];if(o.length>0)for(let t=r;t<o.length;t++){const n=o.getOriginal(t),r=this.props.monomerToShort(n,i);u.push({text:r,posIdx:t}),c=Math.max(c,e.measureText(r).width)}if(0===u.length)return{lineLayouts:[],lineHeight:s};const h=c;let d=Math.floor((l+a)/(h+a));d=Math.max(1,d);const p=n-2*this.padding,m=Math.max(0,Math.floor(p/s)),f=[];let g=0;for(let e=0;e<m&&g<u.length;e++){const t=[];for(let e=0;e<d&&g<u.length;e++){const n=u[g],o=this.padding+e*(h+a);t.push({posIdx:n.posIdx,x:o,width:h,om:n.text,isSeparator:!1}),g++}f.push({lineIdx:e,elements:t})}return{lineLayouts:f,lineHeight:s}}async init(){await Promise.all([(async()=>{this.seqHelper=await(0,Cn.Q)(),this.invalidateGrid()})(),(async()=>{const e=await(0,c.pj)();this.sysMonomerLib=e.getMonomerLib()})()]),this.subs.push(this.sysMonomerLib.onChanged.subscribe((()=>{this.reset()}))),this.subs.push(o.events.onCustomEvent("bio-macromolecule-monomer-highlight").subscribe((e=>this.handleHighlightEvent(e)))),this.reset()}handleHighlightEvent(e){var t;if(!e||!this.tableCol||!this.tableCol.dataFrame)return;if(e.columnName!==this.tableCol.name)return;const n=this.tableCol.dataFrame;if(e.tableId&&n.id!==e.tableId)return;if(e.tableName&&n.name!==e.tableName)return;const o=(t=this.tableCol.temp)[Xo]??(t[Xo]=new Map);null==e.monomers||0===e.monomers.length?o.delete(e.rowIdx):o.set(e.rowIdx,{monomers:e.monomers.slice(),fillColor:e.fillColor,strokeColor:e.strokeColor}),this.invalidateGrid()}getHighlightForRow(e){if(null==e)return null;const t=this.tableCol.temp[Xo];return t?.get(e)??null}drawHighlightBackground(e,t,n,o,r,s,a){const l=this.getHighlightForRow(t);if(!l||!l.monomers||0===l.monomers.length)return;if(!l.monomers.includes(n))return;const c=(u=l.fillColor??Zo,`rgba(${i.Color.r(u)},${i.Color.g(u)},${i.Color.b(u)},0.4)`);var u;e.save();try{e.fillStyle=c,e.fillRect(o,r,s,a)}finally{e.restore()}}static getFontSettings(e){let t=12;return e&&e.temp[".mm.cellRenderer.fontSize"]&&"number"==typeof e.temp[".mm.cellRenderer.fontSize"]&&!isNaN(e.temp[".mm.cellRenderer.fontSize"])&&(t=Math.max(e.temp[".mm.cellRenderer.fontSize"],1)),{font:`${t}px monospace`,fontWidth:.6*t}}toLog(){return`MonomerPlacer<${this.viewerId}>`}getMonomerLib(){return this.tableCol.temp[".mm.cellRenderer.overriddenLibrary"]??this.sysMonomerLib}reset(){this.propsProvider&&(this.props=this.propsProvider()),this._processedRows=i.BitSet.create(this.tableCol.length),this._monomerLengthList=null,this._monomerLengthMap={},this._monomerStructureMap={},this._cellBounds.clear(),super.reset(),this.invalidateGrid()}invalidateGrid(){this.gridCol&&this.gridCol.dart&&this.gridCol.grid?.invalidate()}getCellMonomerLengths(e,t){const n=this.seqHelper.getSeqHandler(this.tableCol);if(this.colWidth<t&&(this.colWidth=t,this.dirty=!0),this.dirty)try{this.reset()}catch(e){const[t,n]=(0,vn.AP)(e);this.logger.error(t,void 0,n)}const o=n.isMsa()?this.getCellMonomerLengthsForSeqMsa():this.getCellMonomerLengthsForSeq(e);return[o,this.getSummedMonomerLengths(o)]}getSummedMonomerLengths(e){const t=new Array(e.length+1);t[0]=this.padding;for(let n=1;n<t.length;n++)t[n]=t[n-1]+e[n-1];let n=t[0];for(let e=1;e<t.length;e++)t[e]?n=t[e]:t[e]=n;return t}getCellMonomerLengthsForSeqValue(e,t){const n=this.seqHelper.getSeqHandler(this.tableCol),o=this.props.separatorWidth+1*this.props.fontCharWidth,r=this.positionShift,i=Math.ceil(t/o)+r,s=n.splitter(e),a=Math.min(i,s.length),l=new Array(a-r);let c=0;for(let e=r;e<a;++e){const o=s.getOriginal(e),i=this.props.monomerToShort(o,this.monomerLengthLimit),a=(n.isSeparator()?this.separatorWidth:this.props.separatorWidth)+i.length*this.props.fontCharWidth;if(l[e-r]=a,c+=a,c>t)break}return l}getCellMonomerLengthsForSeq(e){this.toLog(),null==this._monomerLengthList&&(this._monomerLengthList=new Array(this.tableCol.length).fill(null));const t=this.positionShift,n=this.seqHelper.getSeqHandler(this.tableCol),o=this.props.separatorWidth+1*this.props.fontCharWidth,r=Math.ceil(this.colWidth/o)+t,i=n.getSplitted(e),s=Math.min(r,i.length);let a=this._monomerLengthList[e];if(null==a||a.length!=s-t){a=this._monomerLengthList[e]=new Array(i.length);let o=0;for(let e=t;e<s;++e){const r=i.getOriginal(e),s=this.props.monomerToShort(r,this.monomerLengthLimit),l=(n.isSeparator()?this.separatorWidth:this.props.separatorWidth)+s.length*this.props.fontCharWidth;if(a[e-t]=l,o+=l,o>this.colWidth)break}}return a}getCellMonomerLengthsForSeqMsa(){var e;this.toLog(),null==this._monomerLengthList&&(this._monomerLengthList=new Array(1).fill(null)),(e=this._monomerLengthList)[0]??(e[0]=new Array(0));const t=this._monomerLengthList[0],{startIdx:n,endIdx:o}=(()=>{try{const e=this.gridCol&&this.gridCol.dart?this.gridCol.grid:null;return e&&e.dart?{startIdx:Math.max(Math.floor((e?.vertScroll.min??0)-10),0),endIdx:Math.min(Math.ceil((e?.vertScroll.max??0)+10),this.tableCol.length)}:{startIdx:0,endIdx:Math.min(this.tableCol.length,10)}}catch(e){return{startIdx:0,endIdx:Math.min(this.tableCol.length,10)}}})(),r=this.props.separatorWidth+1*this.props.fontCharWidth,i=this.positionShift,s=Math.ceil(this.colWidth/r)+i;for(let e=n;e<o;e++){if(this._processedRows.get(e)&&s<=this._processedMaxVisibleSeqLength)continue;const n=this.seqHelper.getSeqHandler(this.tableCol).getSplitted(e,s),o=Math.min(s,n.length);o-i>t.length&&t.push(...new Array(o-i-t.length).fill(r));let a=0;for(let e=i;e<o;++e){const o=n.getOriginal(e),r=this.props.monomerToShort(o,this.monomerLengthLimit),s=this.props.separatorWidth+r.length*this.props.fontCharWidth;if(t[e-i]=Math.max(t[e-i]??0,s),a+=s,a>=this.colWidth)break}this._processedMaxVisibleSeqLength=Math.max(this._processedMaxVisibleSeqLength,s),this._processedRows.set(e,!0)}return t}getPosition(e,t,n,o){const[r,i]=this.getCellMonomerLengths(e,n);return 0===this.seqHelper.getSeqHandler(this.tableCol).getSplitted(e).length?null:function(e,t,n){if((n??0)>0&&t<(e[0]??0)+n)return-1;t-=n??0;let o,r=100,i=0,s=e.length-1;for(;i<=s;){if(o=Math.floor((s+i)/2),e[o]<=t&&t<e[o+1])return o;if(t<e[o]?s=o-1:i=o+1,--r<=0)throw new Error(`Get position for pointer x = ${t} searching has not converged on ${JSON.stringify(e)}. `)}return null}(i,t,o)}setMonomerLengthLimit(e){this.monomerLengthLimit!=e&&(this.monomerLengthLimit=e,this.dirty=!0)}setSeparatorWidth(e){this.separatorWidth!=e&&(this.props.separatorWidth=e,this.dirty=!0)}get positionShift(){const e=Number.parseInt(this.tableCol?.tags[Ot.gp.positionShift]??"0")??0;return isNaN(e)?0:Math.max(e,0)}render(e,t,n,o,r,s,a){const l=s.grid?.dart&&s.grid?.canvas===e.canvas;if(!this.seqHelper)return;const c=this.tableCol,u=this.positionShift;e.save();try{const a=this.seqHelper.getSeqHandler(c);let h=this.monomerLengthLimit;if(Go.maxMonomerLength in c.tags){const e=parseInt(c.getTag(Go.maxMonomerLength));h=!isNaN(e)&&e?e:50}if(".mm.cellRenderer.maxMonomerLength"in c.temp){const e=c.temp[".mm.cellRenderer.maxMonomerLength"],t="number"==typeof e?e:parseInt(e);h=!isNaN(t)&&t?t:50}if("1"===c.temp[".mm.cellRenderer.settingsChanged"]||this.monomerLengthLimit!=h){let e=0;const t=8;e=c.temp[".mm.cellRenderer.gapLength"]??e,this.setMonomerLengthLimit(h),this.setSeparatorWidth(a.isMsa()?t:e),c.temp[".mm.cellRenderer.settingsChanged"]="0",this.dirty=!0}const d=s.cell.rowIndex,p=s.cell.value;l&&(o=function(e,t,n,o,r){return e?Math.max(Math.min(e.canvas.width/r-n,o)):Math.max(t.canvas.width/r-n,0)}(s.grid,e,t,o,window.devicePixelRatio)),e.beginPath(),e.rect(t,n,o,r),e.clip(),e.font=this.props?.font??"12px monospace",e.textBaseline="top";const m=c.meta.units,f=c.getTag(Ot.gp.aligned),g=c.getTag(Ot.gp.separator)??"",y=l?a.getSplitted(d):a.splitter(p);let b=Vo.classic;f?.includes("MSA")&&m===Ot.Hi.SEPARATOR&&(b=Vo.MSA);const v=c.temp["reference-sequence"],C=this.tableCol.temp["current-word"],x=(()=>{const e=(0,a.splitter)(null!=v&&""!==v?v:C??"");return wn().count(0).take(e.length).slice(u).map((t=>e.getCanonical(t))).toArray()})(),w=Number.parseInt(c.getTag(Ot.gp.selectedPosition)??"-200"),A=this.shouldUseMultilineRendering(c),T=this.getAnnotationRenderer();if(A){const l=[],d=this.calculateMultiLineLayoutDynamic(e,o,r,y,u,h);let p=n+this.padding;1===d.lineLayouts.length&&(p=n+(r-d.lineHeight)/2);for(const o of d.lineLayouts){const r=p+o.lineIdx*d.lineHeight;for(const h of o.elements){const p=t+h.x,m=h,f=m.posIdx,g=y.getCanonical(f);let b=er;const v=this.getMonomerLib();v&&(b=v.getMonomerTextColor(a.defaultBiotype,g));let C=0;if(s.tableRowIndex!==c.dataFrame.currentRowIdx&&x.length>0){const e=f-u;e>=0&&e<x.length&&g===x[e]&&(C=.7)}l.push({lineIdx:o.lineIdx,monomerIdx:f-u,bounds:new i.Rect(h.x,r-n,h.width,d.lineHeight),sequencePosition:f}),T&&T.drawPositionBackground(e,p,r,h.width+2,d.lineHeight,f,s.tableRowIndex),this.drawHighlightBackground(e,s.tableRowIndex,f,p,r,h.width+2,d.lineHeight),qo(e,m.om,p,r,h.width,d.lineHeight,{color:b,isMultiLineContext:!0,transparencyRate:C,selectedPosition:isNaN(w)||w<1?void 0:w,wordIdx:f})}}null!==s.tableRowIndex&&this._cellBounds.set(s.tableRowIndex,l)}else{this._leftThreeDotsPadding=this.shouldRenderShiftedThreeDots(u)?e.measureText("...").width:0;let[,i]=this.getCellMonomerLengths(s.tableRowIndex,o);l||(i=this.getSummedMonomerLengths(this.getCellMonomerLengthsForSeqValue(p,o)));const c=this.props.separatorWidth+1*this.props.fontCharWidth,d=Math.min(y.length,Math.ceil(o/c)+u);let m;const f=e.measureText("M"),v=f.fontBoundingBoxAscent+f.fontBoundingBoxDescent,C=4,A=Math.min(r,v+C),E=n+(r-A)/2;T&&(m=n+(r/2-v/2+1)+v);for(let l=u;l<d;++l){const c=l<y.length?y.getOriginal(l):a.defaultGapOriginal,d=l<y.length?y.getCanonical(l):a.defaultGapOriginal;let p=er;this.getMonomerLib()&&(p=this.getMonomerLib().getMonomerTextColor(a.defaultBiotype,d));const f=l===y.length-1,v=(y?.graphInfo?.disjointSeqStarts?.indexOf(l+1)??0)>0?"|":g,C=l-u,S=(i[C]??0)-(i[0]??0),N=(C+1<i.length?(i[C+1]??0)-(i[0]??0):S+this.props.fontCharWidth)-S,I=t+this.padding+this._leftThreeDotsPadding+S;T&&null!=s.tableRowIndex&&T.drawPositionBackground(e,I,n,N,r,l,s.tableRowIndex,m),this.drawHighlightBackground(e,s.tableRowIndex,l,I,E,N,A);const M={color:p,pivot:0,left:!0,transparencyRate:0,separator:v,last:f,drawStyle:b,maxWord:i,wordIdx:l-u,gridCell:s,referenceSequence:x,maxLengthOfMonomer:h,monomerTextSizeMap:this._monomerLengthMap,logger:this.logger,selectedPosition:isNaN(w)||w<1?void 0:w-u};qo(e,c,t+this.padding+this._leftThreeDotsPadding,n,o,r,M)}if(this.shouldRenderShiftedThreeDots(u)){const a={color:er,pivot:0,left:!0,transparencyRate:0,separator:g,last:!1,drawStyle:b,maxWord:i,wordIdx:0,gridCell:s,maxLengthOfMonomer:h,monomerTextSizeMap:this._monomerLengthMap,logger:this.logger};qo(e,"...",t+this.padding,n,o,r,a)}}}catch(e){const[t,n]=(0,vn.AP)(e);this.logger.error(t,void 0,n),this.errors.push(e)}finally{e.restore()}}shouldRenderShiftedThreeDots(e){return e>0&&(!this.gridCol||!this.gridCol.dart||!this.gridCol.grid||!this.gridCol.grid.dart||(this.gridCol.grid.props.colHeaderHeight??0)<=50)}onMouseMove(e,t){const n=`${this.toLog()}.onMouseMove()`;if(!this.seqHelper||null==e.tableRowIndex)return;const o=this.positionShift,i=e.bounds,s=t.offsetX-e.gridColumn.left+(e.gridColumn.left-i.x),a=t.offsetY-i.y;this.gridCol?.grid?.canvas&&(this.gridCol.grid.canvas.style.cursor="default");let l=null;const c=this._cellBounds.get(e.tableRowIndex);if(c){for(const e of c)if(e.bounds.contains(s,a)){l=e.monomerIdx;break}}else{const t=this.shouldRenderShiftedThreeDots(o)&&(this._leftThreeDotsPadding??0)>0?this._leftThreeDotsPadding:0;l=this.getPosition(e.tableRowIndex,s,i.width,t)}this.logger.debug(`${n}, argsX: ${s}, argsY: ${a}, left: ${l}`);const u=this.seqHelper.getSeqHandler(this.tableCol),h=u.getSplitted(e.tableRowIndex);if(null!==l&&l>=0&&l+o<h.length){const n=u.alphabet??Ot.YI.UN,i={position:l,biotype:n===Ot.YI.RNA||n===Ot.YI.DNA?Jo.o.NUCLEOTIDE:Jo.o.AA,symbol:h.getCanonical(l+o)},s=[];let a=this._monomerStructureMap[i.symbol];if(!a){const e=this.getMonomerLib();a=this._monomerStructureMap[i.symbol]=e?e.getTooltip(i.biotype,i.symbol):r.divText("Monomer library is not available")}s.push(a);const c=this.getAnnotationRenderer();if(c){const t=c.getTooltipInfo(l+o,e.tableRowIndex);if(t.length>0){const e=document.createElement("hr");e.style.margin="4px 0",e.style.border="none",e.style.borderTop="1px solid #ccc",s.push(e);for(const e of t)s.push(r.divText(e,{style:{fontSize:"12px",marginBottom:"2px"}}))}}r.tooltip.show(r.divV(s),t.x+16,t.y+16),Un(e,i)}else-1===l?r.tooltip.show(r.divText(`${Math.min(o,h.length)} hidden monomers`),t.x+16,t.y+16):r.tooltip.hide(),Un(e,null)}}class nr extends tr{constructor(e,t,n,o){super(e,t,br.logger,n,(()=>{const e=o.getSeqHandler(t),{font:n,fontWidth:r}=tr.getFontSettings(t);return{seqHandler:e,font:n,fontCharWidth:r,separatorWidth:11,monomerToShort:Ot.zS}}))}onMouseMove(e,t){super.onMouseMove(e,t)}}class or extends Ro.$G{static get notationName(){return"Harmonized Sequence"}static get implementsFromHelm(){return!1}static convertFromHelm(e,t){throw new Error("converting from helm not supported yet")}get defaultGapOriginal(){return""}constructor(e,t){super(),this.separator=e,this.helmHelper=t,this.separatorSplitter=(0,Ot.dh)(this.separator),this.splitter=this._splitter.bind(this)}setUnits(){}_splitter(e){const t=this.separatorSplitter(e);return new rr(wn().count(0).take(t.length).map((e=>t.getOriginal(e))).toArray(),s.b9[s.Hi.SEPARATOR])}getHelm(e,t){return Oo.s.fromSeparator(e,this.helmHelper).getHelm()}createCellRendererBack(e,t){const n=new nr(e,t,4,this.helmHelper.seqHelper);return n.init().then((()=>{})),n}}class rr extends a.Mu{getCanonical(e){if(this.isGap(e))return s._S;const t=this.getOriginal(e);let n=t;return t.startsWith("{")?n=t.slice(1):t.endsWith("}")?n=t.slice(0,-1):t.startsWith("(")?n=t.replace(/^\(.\d+\)/,""):t.endsWith(")")&&(n=t.replace(/\(\d+\)$/,"")),n}constructor(e,t){super(e,t)}}async function ir(e,t=!1){await br.initPromise;const n=window.innerWidth,s=window.innerHeight;try{let a;function u(){if(null==a)return;const e=L()(a.root).find("div.d4-dialog-contents").get(0),t=e.clientHeight,n={0:1},o=Object.values(n).reduce(((e,t)=>e+t),0),r=t-wn().count(0).take(e.children.length).filter((e=>!(e in n))).map((t=>e.children[t])).filter((e=>e instanceof HTMLElement)).map((e=>e.offsetHeight)).reduce(((e,t)=>e+t),0)-38;for(const t of wn().count(0).take(e.children.length))if(t in n){const i=e.children[t],s=r*n[t]/o;i.style.height=`${s}px`}}a=await async function(e,t,n=!1){const s="ST: PT: HelmDialog()";let a;const u=[];let h=So.aK.Single;const d=()=>{for(const e of u)e.unsubscribe();a.placeholders.detach()};try{const p=await(0,c.pj)(),m=p.getMonomerLib(),f=await(0,Cn.Q)(),g=await(0,bn.b2)(),y=g.buildMonomersFuncsFromLib(m),b=e=>{let t,n,o=null;if(e&&e.rowIndex>=0&&e?.column.semType==i.SEMTYPE.MACROMOLECULE){if(t=f.getSeqHandler(e.column).getValue(e.rowIndex),e.column.temp?.[l.notationProvider]&&!(e.column.temp[l.notationProvider]instanceof or)){let n;o=e.column.temp[l.notationProvider].getHelm(t.value,{}),i.DataFrame.fromColumns([n=i.Column.fromList(i.COLUMN_TYPE.STRING,"seq",[o])]),n.semType=i.SEMTYPE.MACROMOLECULE,n.meta.units=Ot.Hi.HELM,t=f.getSeqHandler(n).getValue(0)}n=t.tags["polytool-data-role"]??"macromolecule"}else{const e=i.Column.fromList(i.COLUMN_TYPE.STRING,"seq",[No.d]);e.semType=i.SEMTYPE.MACROMOLECULE,i.DataFrame.fromColumns([e]),e.meta.units=Ot.Hi.HELM,t=f.getSeqHandler(e).getValue(0),n="macromolecule"}return[t,n]};let v,C,[x,w]=b(e),A=null;const T=r.divText("",{style:{color:"red"}}),E=r.divText("",{style:{fontSize:"11px",color:"var(--grey-4)",marginTop:"2px",marginLeft:"4px",whiteSpace:"nowrap"}});a={macromolecule:g.createHelmInput("Macromolecule",{editable:!1,editorOptions:{drawOptions:{monomerNumbering:1,getMonomer:(t,n)=>{const o=t;if("ATOM"!==o.T)return y.getMonomer(t,n);try{if(x.isDna()||x.isRna()){const e=x.getSplittedWithSugarsAndPhosphates().getCanonical(o.bio.continuousId-1);return y.getMonomer(o.bio.type,e)}if(e?.column?.temp?.[l.notationProvider]instanceof or){const e=x.getSplitted().getCanonical(o.bio.continuousId-1);return y.getMonomer(o.bio.type,e)}{const e=o.elem;return y.getMonomer(o.bio.type,e)}}catch(e){return y.getMonomer(t,n)}}}}}),placeholders:await Io.create("Placeholders",{showAddNewRowIcon:!0,showRemoveRowIcon:!0,showRowHeader:!1,showCellTooltip:!1}),enumeratorType:r.input.choice("Enumerator type",{value:h,items:Object.values(So.aK)}),placeholdersBreadth:await Lo.create("Breadth",{showAddNewRowIcon:!0,showRemoveRowIcon:!0,showRowHeader:!1,showCellTooltip:!1}),keepOriginal:r.input.bool("Keep original",{value:!1}),toAtomicLevel:r.input.bool("To atomic level",{value:!1,onValueChanged:(e,t)=>{M()}}),generateHelm:r.input.bool(Qn,{value:!0}),chiralityEngine:r.input.bool(Jn,{value:!1}),highlightMonomers:r.input.bool(Xn,{value:!1}),rules:{header:r.inlineText([to]),form:await(C=new jn._v(jn.MU,jn.yy,".json",{onValueChanged:e=>{v=e}})).getForm()},trivialName:r.input.string("Trivial name",{value:"",onValueChanged:e=>{const t=e?.trim();A=t?{value:t,colName:"Trivial name"}:null}}),appendToTable:r.input.table("Append to table",{items:o.shell.tables,nullable:!0})};const S=()=>{const e=no[a.enumeratorType.value]??"";r.tooltip.bind(a.enumeratorType.input,e)};if(S(),e?.dataFrame){const t=r.iconFA("columns",(t=>{i.Menu.popup().singleColumnSelector(e.dataFrame,{columnFilter:t=>t.type===i.COLUMN_TYPE.STRING&&t!==e.column,onChange:(t,n,o)=>{o&&(a.trivialName.value=n.get(e.rowIndex)??"")}}).show({x:t.clientX,y:t.clientY})}),"Pick trivial name from a column");a.trivialName.addOptions(t)}a.trivialName.root.style.maxWidth="450px",a.placeholders.onMonomerCellEdit=async(e,t)=>{const n=a.macromolecule.molValue;if(e<0||e>=n.atoms.length)return null;const o=n.atoms[e].biotype(),r=(0,To.Y)(o);return _o(m,r,t,p)},a.placeholdersBreadth.onMonomerCellEdit=async(e,t,n)=>{const o=a.macromolecule.molValue;if(e<0||e>=o.atoms.length)return null;const r=o.atoms[e].biotype(),i=(0,To.Y)(r);return _o(m,i,n,p)};let N=null;a.placeholders.addValidator((e=>{N=null;const t=[];setTimeout((()=>{_()}),100);try{if(a.enumeratorType.value===So.aK.Parallel){const e=a.placeholders.placeholdersValue.filter((e=>e.monomers.length>0));if(e.length>1){const t=e[0].monomers.length,n=e.find((e=>e.monomers.length!==t));n&&(N=`Parallel mode requires all positions to have the same number of monomers. Position ${e[0].position+1} has ${t}, but position ${n.position+1} has ${n.monomers.length}.`)}}if("macromolecule"!==w)return null;const e=[];for(const n of a.placeholders.placeholdersValue){const o=n.position;if(null==o)continue;if(o>=a.macromolecule.molValue.atoms.length){t.push(`There is no monomer at position ${o+1}.`);continue}const r=a.macromolecule.molValue.atoms[o];if(r){const t=r.biotype(),o=(0,To.Y)(t);for(const t of n.monomers){const n=m.getMonomer(o,t);n&&n.lib||e.push({polymerType:o,symbol:t})}}}const n={};for(const t of e){let e=n[t.polymerType];e||(e=n[t.polymerType]=[]),e.push(t.symbol)}const o=Object.entries(n).map((([e,t])=>`${e}: ${t.join(", ")}`)).join("\n");Object.keys(o).length>0&&t.push(`Placeholders contain missed monomers: ${o}`),N=t.length>0?t.join("\n"):N}catch(e){const[t,n]=zn(e,!1);N=t}return setTimeout((()=>{_()}),0),N})),a.enumeratorType.onChanged.subscribe((e=>{h=a.enumeratorType.value,S(),a.placeholders.fireChanged()})),u.push(a.macromolecule.onMouseMove.subscribe((e=>{try{br.logger.debug(`${s}, placeholdersInput.onMouseMove()`);const t=e.offsetX,n=e.offsetY,o=a.macromolecule.molValue,i=g.getHoveredAtom(t,n,o,a.macromolecule.root.clientHeight);if(i){const t=i._parent.atoms.indexOf(i),n=a.placeholders.placeholdersValue.find((e=>e.position===t))?.monomers;if(n){const t=r.divText(n.join(", "));a.macromolecule.showTooltip(t,i),e.preventDefault(),e.stopPropagation()}}}catch(e){zn(e,!1)}}))),u.push(a.macromolecule.onClick.subscribe((e=>{try{br.logger.debug(`${s}, placeholdersInput.onClick()`);const t=e.offsetX,n=e.offsetY,o=a.macromolecule.molValue,r=g.getHoveredAtom(t,n,o,a.macromolecule.root.clientHeight);if(r){const e=r._parent.atoms.indexOf(r);a.placeholders.addPosition(e,"")}}catch(e){zn(e)}}))),u.push(a.placeholders.onChanged.subscribe((()=>{I(),L()}))),u.push(a.placeholdersBreadth.onChanged.subscribe((()=>{L()}))),u.push(a.keepOriginal.onChanged.subscribe((()=>{L()}))),u.push(r.onSizeChanged(a.placeholders.root).subscribe((()=>{t&&t()}))),u.push(o.events.onCurrentCellChanged.subscribe((()=>{const e=o.shell.tv.dataFrame.currentCell;e.column.semType===i.SEMTYPE.MACROMOLECULE&&([x,w]=b(e),R(x,w,e))}))),a.macromolecule.root.style.setProperty("min-width","250px","important");const I=()=>{const e=new Set(a.placeholders.placeholdersValue.map((e=>e.position))),t=a.macromolecule.molValue;for(let n=0;n<t.atoms.length;n++)t.atoms[n].highlighted=e.has(n);a.macromolecule.redraw()},M=()=>{a.toAtomicLevel.value&&"template"===w?(a.generateHelm.root.style.removeProperty("display"),a.chiralityEngine.root.style.removeProperty("display"),a.highlightMonomers.root.style.removeProperty("display"),a.rules.header.style.removeProperty("display"),a.rules.form.style.removeProperty("display")):(a.generateHelm.root.style.display=a.chiralityEngine.root.style.display=a.highlightMonomers.root.style.display="none",a.rules.header.style.display=a.rules.form.style.display="none"),t&&t()};let P=null;const _=()=>{const e=N,t=T;e?(t.innerText=e,t.style.removeProperty("display"),P&&(P.disabled=!0)):(t.innerText="",t.style.setProperty("display","none"),P&&(P.disabled=!1))},L=()=>{try{const e=a.placeholders.placeholdersValue.filter((e=>e.monomers.length>0)),t=a.placeholdersBreadth.placeholdersBreadthValue.filter((e=>e.monomers.length>0&&null!=e.start&&null!=e.end));let n=0;switch(a.enumeratorType.value){case So.aK.Single:n=e.reduce(((e,t)=>e+t.monomers.length),0);break;case So.aK.Parallel:e.length>0&&(n=e.every((t=>t.monomers.length===e[0].monomers.length))?e[0].monomers.length:0);break;case So.aK.Matrix:n=e.length>0?e.reduce(((e,t)=>e*t.monomers.length),1):0}let o=0;t.length>0&&(o=t.reduce(((e,t)=>{const n=Math.abs(t.end-t.start)+1;return e*(t.monomers.length*n)}),1));let r=n+o;a.keepOriginal.value&&r>0&&(r+=1),E.textContent=r>0?`${r} sequence${1!==r?"s":""} will be generated`:""}catch(e){E.textContent=""}},O=e=>{t&&t()},R=(e,t,n)=>{a.macromolecule.value=e;const o=n?.dataFrame;O(o)};R(x,w,e),M(),L();const $=async()=>{try{const t=a.macromolecule.stringValue;if(void 0===t||""===t)o.shell.warning("PolyTool: no molecule was provided");else{if(0===Object.keys(a.placeholders.placeholdersValue).length&&0===Object.keys(a.placeholdersBreadth.placeholdersBreadthValue).length)return void o.shell.warning(`${eo}: placeholders are empty`);await(0,bn.b2)();const r=a.placeholders.placeholdersValue,s=a.enumeratorType.value;if(s===So.aK.Parallel){const e=r.filter((e=>e.monomers.length>0));if(e.length>1){const t=e[0].monomers.length;if(e.some((e=>e.monomers.length!==t)))return void o.shell.warning("Parallel mode requires all positions to have the same number of monomers")}}const c={placeholders:r,type:s,breadthPlaceholders:a.placeholdersBreadth.placeholdersBreadthValue,keepOriginal:a.keepOriginal.value};if(e?.column?.temp?.[l.notationProvider]&&!(e.column.temp[l.notationProvider]instanceof or)){const t=e.column.temp[l.notationProvider];if(t.constructor.implementsFromHelm){const e=t.constructor;c.fromHelmNotation={notationName:e.notationName,convert:t=>e.convertFromHelm(t,{})}}}const u=a.toAtomicLevel.value,h=await sr(t,w,A,c,!!u&&{generateHelm:a.generateHelm.value,chiralityEngine:a.chiralityEngine.value,highlightMonomers:a.highlightMonomers.value,rules:await C.getActive()},g);if(n){const e=h.col("Enumerated");e&&e.type===i.COLUMN_TYPE.STRING&&(0,yn.P)(e)}const d=a.appendToTable.value;d?(d.append(h,!0),d.meta.detectSemanticTypes()):o.shell.addTableView(h)}}catch(e){zn(e)}},D=r.dialog({title:eo,showFooter:!0}).add(a.macromolecule.root).add(r.divH([r.divV([a.placeholders.root,r.divH([a.enumeratorType.root,E],{style:{alignItems:"center"}})],{style:{width:"50%"}}),r.divV([a.placeholdersBreadth.root],{style:{width:"50%"}})],{style:{width:"100%"}})).add(r.divH([r.divV([a.trivialName.root,a.keepOriginal.root,a.appendToTable.root],{style:{width:"50%"}}),r.divV([r.divH([a.toAtomicLevel.root,a.generateHelm.root]),r.divH([a.chiralityEngine.root,a.highlightMonomers.root]),a.rules.header,a.rules.form],{style:{width:"50%"}})],{style:{width:"100%"}})).add(T).onOK((()=>{if(N)return _(),void o.shell.warning("Please fix validation errors before running enumeration");$()}));return P=D.getButton("OK"),u.push(D.onClose.subscribe((()=>{d()}))),D.history((()=>({description:`${a.enumeratorType.value} ${a.placeholders.placeholdersValue?.map((e=>(e.position?.toString()??"")+": "+e.monomers?.join(", "))).join("; ")}`,placeholders:a.placeholders.stringValue,enumeratorType:a.enumeratorType.value,placeholdersBreadth:a.placeholdersBreadth.stringValue,trivialName:a.trivialName.value,keepOriginal:a.keepOriginal.value,toAtomicLevel:a.toAtomicLevel.value,generateHelm:a.generateHelm.value,chiralityEngine:a.chiralityEngine.value,highlightMonomers:a.highlightMonomers.value,rules:v})),(e=>{a.enumeratorType.value=e.enumeratorType??So.aK.Single,a.placeholders.stringValue=e.placeholders,a.placeholdersBreadth.stringValue=e.placeholdersBreadth,e.trivialName&&(a.trivialName.value=e.trivialName),a.keepOriginal.value=e.keepOriginal??!1,a.toAtomicLevel.value=e.toAtomicLevel??!0,a.generateHelm.value=e.generateHelm??!0,a.chiralityEngine.value=e.chiralityEngine??!1,a.highlightMonomers.value=e.highlightMonomers??!1,C.setActive(e.rules),setTimeout((()=>{a.placeholders.invalidateGrid(),a.placeholdersBreadth.invalidateGrid(),L()}),100)})),D}catch(e){throw d(),e}}(e,u,t);let h=!0;r.onSizeChanged(a.root).subscribe((()=>{if(h){const e=.7*n,t=.7*s;a.root.style.width=`${Math.min(n,e)}px`,a.root.style.height=`${Math.min(s,t)}px`,a.root.style.left=`${Math.floor((n-a.root.offsetWidth)/2)}px`,a.root.style.top=`${Math.floor((s-a.root.offsetHeight)/2)}px`,h=!1}u()})),u(),br.logger.debug("PolyToolEnumerateHelmUI: dialog before show"),a.show({width:Math.max(350,.7*n),resizable:!0}),br.logger.debug("PolyToolEnumerateHelmUI: dialog after show")}catch(d){const[p,m]=(0,vn.AP)(d);br.logger.error(p,void 0,m)}}async function sr(e,t,n,r,s,a){const l=i.TaskBarProgressIndicator.create("PolyTool enumerating...");try{const l=await(0,c.pj)(),u=await(0,Vn.j)(),h=l.getMonomerLib(),d=(0,No.o)(e,n?.value??"",r);let p;switch(t){case"macromolecule":p=i.Column.fromType(i.COLUMN_TYPE.STRING,"Enumerated",d.length).init((e=>d[e][0]));break;case"template":{const e=new Array(d.length);for(let t=0;t<d.length;t++){const n=d[t][0],o=Oo.s.fromHelm(n,a);e[t]=o.getNotation()}p=i.Column.fromList(i.COLUMN_TYPE.STRING,"Enumerated",e),p.semType=i.SEMTYPE.MACROMOLECULE,p.setTag("polytool-data-role","template"),Cr.applyNotationProviderForCyclized(p,"-");break}}const m=i.DataFrame.fromColumns([p]);if("macromolecule"===t&&r.fromHelmNotation){const e=i.Column.fromType(i.COLUMN_TYPE.STRING,`${r.fromHelmNotation.notationName}(${p.name})`,m.rowCount).init((e=>p.isNone(e)?null:r.fromHelmNotation.convert(p.get(e))));m.columns.add(e)}if(await o.data.detectSemanticTypes(m),"template"==t&&Cr.applyNotationProviderForCyclized(p,"-"),s){let e;if("macromolecule"===t){e=p;const t=await a.seqHelper.helmToAtomicLevel(e,s.chiralityEngine,s.highlightMonomers);m.columns.add(t.molCol,!1);const n=t.molCol;await async function(e,t,n,o,r,i=!1){const s=o.getSeqHandler(e),a=s.alphabet==Ot.YI.RNA||s.alphabet==Ot.YI.DNA,l=s.isHelm()&&a,c=!s.isHelm()&&a,u=e=>null==e?null:l?i?e:Math.floor(e/3):c&&i?3*e+1:e,h=i?await o.getHelmToMolfileConverter(n):null,d=new On({max:100});function p(e,t){const s=e.get(t);if(null==s)return null;let a=d.get(s);return a||d.set(s,a=function(e,t){const s=o.getSeqHandler(e);if(i){const e=s.getHelm(t);return o.helmToAtomicLevelSingle(e,h,!1,!1).monomers}{const e=s.getSplitted(t),o=s.defaultBiotype,i=wn().count(0).take(e.length).map((t=>({position:t,symbol:e.getCanonical(t),biotype:o}))).toArray(),a=s.alphabet,l=a==Ot.YI.RNA||a==Ot.YI.DNA?"RNA":"PEPTIDE",c=(0,Bn.eM)([i],[void 0],l,a,n,r);return(0,Fn.gU)(i,c,a,l).monomers}}(e,t)),a}const m={targetCol:t,handler:(t,o,r)=>{const i=r.grid,s=t.tableRowIndex,a=t.gridRow,l=i.cell(r.name,a),c=Rn();if(!c||c&&(c.dataFrameId!=e.dataFrame.id||c.gridRowIdx!=a||c.seqColName!=e.name||c.seqPosition!=o?.position)){if(c&&($n(null),c.gridCell.render()),!o)return $n(null),!0;$n({gridCell:l,dataFrameId:e.dataFrame.id,gridRowIdx:a,seqColName:e.name,seqPosition:u(o?.position)??-1,getSubstruct:()=>{if(!o||"*"===o.symbol)return;const t=p(e,s);if(!t)return;const r=t.get(u(o?.position));return r?(0,kn.H)([r],n):{atoms:[],bonds:[],highlightAtomColors:[],highlightBondColors:[]}}}),l.render()}return!0},getSubstruct:o=>{if("true"!=t.getTag(".sequence-src-highlight-monomers"))return;if(null==o)return;if(!e.get(o))return;const r=p(e,o);return r?(0,kn.H)(r.values(),n):void 0}};return Gn(e.temp,m),Dn(t.temp,m),m}(e,n,h,a.seqHelper,u,!0)}else"template"===t&&(e=(await ro(p,s.generateHelm,!1,s.chiralityEngine,!1,s.rules))[0])}if(n){const e=i.Column.fromType(i.COLUMN_TYPE.STRING,n.colName,d.length).init((e=>d[e][1]));m.columns.add(e)}return m}finally{l.close()}}var ar,lr=n(3151);class cr{constructor(e){this.rawLib=e}isValid(){return this.rawLib.every((e=>"object"==typeof e&&Object.values(Yn).every((t=>t in e&&"string"==typeof e[t]))))}getJsonMonomerLib(){const e=[];return this.rawLib.forEach((t=>{const n=this.prepareMonomer(t);e.push(n)})),e}prepareMonomer(e){const t={...lr.pe};Object.entries(Yn).forEach((([n,o])=>{const r=e[o];t[n]=r}));let n="smiles";const o=e[Yn[n]],r=new ur(o),i=r.getCappedSmiles();return t[n]=i,n="rgroups",t[n]=hr.getRGroups(r.getNumberOfRGroups()),n="molfile",t[n]=new dr(r.getSmilesWithRGroups()).getMolfile(),t}}class ur{constructor(e){let t=0;this.smilesWithRGroups=e.replace(/\[R(\d+)\]/g,((e,n)=>(++t,`[${n}*]`))),this.numberOfRGroups=t}getSmilesWithRGroups(){return this.smilesWithRGroups}getCappedSmiles(){return this.capRGroups()}getNumberOfRGroups(){return this.numberOfRGroups}capRGroups(){let e=this.smilesWithRGroups.replace("[1*]","[H:1]");return e=e.replace("[2*]","[OH:2]"),e.replace("[3*]","[H:3]")}}class hr{constructor(){}static getRGroups(e){return Kn.slice(0,e)}}class dr{constructor(e){this.smilesWithRGroups=e}getMolfile(){let e=i.chem.convert(this.smilesWithRGroups,i.chem.Notation.Smiles,i.chem.Notation.MolBlock);return e=this.restoreRGPLine(e),e=this.fixRGroupSymbols(e),e}restoreRGPLine(e){return e.replace("M ISO","M RGP")}fixRGroupSymbols(e){return e.replace(/\bR\b/g,"R#")}}class pr{constructor(e,t){this.fileName=e,this.fileContent=t,this.validateFileType();const n=i.DataFrame.fromCsv(this.fileContent),o=this.toJson(n);this.polyToolMonomerLib=new cr(o),this.validateContent()}async getJson(){return this.polyToolMonomerLib.getJsonMonomerLib()}toJson(e){return Array.from({length:e.rowCount},((t,n)=>e.columns.names().reduce(((t,o)=>(t[o]=e.get(o,n),t)),{})))}validateFileType(){if(!this.fileName.endsWith(".csv"))throw new Error(`File ${this.fileName} is not an CSV file`)}validateContent(){if(!this.polyToolMonomerLib.isValid())throw new Error("Invalid format of CSV monomer lib")}}!function(e){e.table="table",e.seqCol="seqCol",e.generateHelm="generateHelm",e.chiralityEngine="chiralityEngine",e.rules="rules"}(ar||(ar={}));class mr{constructor(e){this.call=e,this.ruleInputs=new jn._v(jn.MU,jn.yy,".json")}async initInputs(){const e=e=>this.call.inputParams[e],t=await this.ruleInputs.getForm();this.inputs={table:(()=>{const t=e(ar.table);return r.input.table(t.property.caption,{value:t.value})})(),seqCol:(()=>{const t=e(ar.seqCol);return r.input.column(t.property.caption,{value:t.value,table:t.value.dataFrame})})(),generateHelm:r.input.forProperty(e(ar.generateHelm).property),chiralityEngine:r.input.forProperty(e(ar.chiralityEngine).property),rules:{header:r.inlineText([to]),form:t}}}static async create(e){const t=new mr(e);return await t.initInputs(),t}async getParams(){return{table:this.inputs.table.value,seqCol:this.inputs.seqCol.value,generateHelm:this.inputs.generateHelm.value,chiralityEngine:this.inputs.chiralityEngine.value,rules:await this.ruleInputs.getActive()}}async showDialog(){const e=r.div([this.inputs.table,this.inputs.seqCol,this.inputs.generateHelm,this.inputs.chiralityEngine,this.inputs.rules.header,this.inputs.rules.form],{style:{minWidth:"320px"}});return new Promise(((t,n)=>{r.dialog({title:Zn}).add(e).onOK((async()=>{const e=await this.getParams(),n=(await this.call.func.prepare(e).call(!0)).getOutputParamValue();t(n)})).onCancel((()=>{n(new Error("Cancelled by user"))})).show()}))}widget(){throw new Error("not implemented")}}var fr=function(e,t,n,o){var r,i=arguments.length,s=i<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,o);else for(var a=e.length-1;a>=0;a--)(r=e[a])&&(s=(i<3?r(s):i>3?r(t,n,s):r(t,n))||s);return i>3&&s&&Object.defineProperty(t,n,s),s},gr=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},yr=function(e,t){return function(n,o){t(n,o,e)}};o.decorators||(o.decorators={}),["func","init","param","panel","editor","demo","app","appTreeBrowser","fileHandler","fileExporter","model","viewer","filter","cellRenderer","autostart","dashboard","folderViewer","semTypeDetector","packageSettingsEditor","functionAnalysis","converter","fileViewer","model","treeBrowser","polyfill"].forEach((e=>{o.decorators[e]||(o.decorators[e]=function(e){return function(e,t,n){}})}));const br=new R({debug:!0});let vr=null;class Cr{static async oligoToolkitApp(){await br.initLibData();const e=await async function(e){const t={"Mermadesynthesis:merMadeSynthesis":{tabName:"SYNTHESIZE",parameters:Kt(e)}},n={};for(const[e,r]of Object.entries(t)){let t;try{t=await o.functions.call(e,r.parameters);const i=new zt(r.tabName,t);i.initView(),n[r.tabName]=()=>i.getView()}catch(t){console.warn(`Plugin ${e} not loaded, reason:`,t);continue}}return n}(br);if(!e)throw new Error("External app view factories not loaded");const t=new Yt(e,br);return await t.getAppView()}static async init(){return null===vr&&br.startInit(vr=async function(){const[e,t]=await Promise.all([(0,bn.b2)(),(0,c.pj)()]);br.completeInit(e,t.getMonomerLib())}()),vr}static async oligoTranslatorApp(){return await xr("Oligo Translator")}static async oligoPatternApp(){return await xr("Oligo Pattern")}static async oligoStructureApp(){return await xr("Oligo Structure")}static async getTranslationHelper(){return await br.initLibData(),br}static getCodeToWeightsMap(){const e=br.monomerLibWrapper.getCodesToWeightsMap();return Object.fromEntries(e)}static validateSequence(e){const t=br.createSequenceValidator(e),n=br.createFormatDetector(e).getFormat();return null!==n&&t.isValidSequence(n)}static getMolfileFromGcrsSequence(e,t){return new At(e,t,"GCRS").convert()}static linkStrands(e){return Tt(e,!0)}static async demoTranslateSequence(){await async function(){await v((async()=>{const e=await Cr.oligoTranslatorApp();o.shell.addView(e)}))}()}static async demoOligoPattern(){await async function(){await v((async()=>{const e=await Cr.oligoPatternApp();o.shell.addView(e)}))}()}static async demoOligoStructure(){await async function(){await v((async()=>{const e=await Cr.oligoStructureApp();o.shell.addView(e),["Afcgacsu","Afcgacsu","Afcgacsu"].forEach((async(e,t)=>{await async function(e,t){await i.delay(500);const n=document.querySelectorAll(".st-colored-text-input > textarea")[e];n.value=t;const o=new Event("input");n.dispatchEvent(o)}(t,e)}))}))}()}static async translateOligonucleotideSequence(e,t,n){return await br.initLibData(),br.createFormatConverter(e,t).convertTo(n)}static async polyToolConvertTopMenu(){await async function(){await br.initPromise;let e=null;try{e=await async function(){const e=[],t=()=>{for(const t of e)t.unsubscribe()};try{let n;const s=o.shell.t.columns.bySemTypeAll(i.SEMTYPE.MACROMOLECULE),a=s.filter((e=>br.seqHelper.getSeqHandler(e).notation===Ot.Hi.CUSTOM));if(!n){if(s.length<1)throw new Error("No dataframe with macromolecule columns open");if(a.length<1){const e=i.Func.find({package:"Bio",name:"toAtomicLevel"})[0];return e?(e.prepare().edit(),null):(o.shell.warning("Polytool requires a macromolecule column with custom notation. \n\nUse Top menu | Bio | Transform | To Atomic Level."),null)}n=s[0]}const l=r.input.column("Column",{table:n.dataFrame,value:n,filter:e=>a.includes(e)}),c=r.input.bool(Qn,{value:!0});r.tooltip.bind(c.root,"Add HELM column");const u=r.input.bool("Linearize",{value:!0});r.tooltip.bind(u.root,"Make representation linear if possible");const h=r.input.bool(Jn,{value:!0}),d=r.input.bool(Xn,{value:!0});let p;const m=new jn._v(jn.MU,jn.yy,".json",{onValueChanged:e=>{p=e}}),f=r.inlineText([to]);r.tooltip.bind(f,"Add or specify rules to use");const g=await m.getForm(),y=r.divV([l,c,u,h,d,f,g]),b=async()=>{try{const e=await m.getActive();await ro(l.value,c.value,u.value,h.value,d.value,e)}catch(e){zn(e)}},v=r.dialog(Zn).add(y).onOK((()=>{b()}));return e.push(v.onClose.subscribe((()=>{t()}))),v.history((()=>({generateHelm:c.value,chiralityEngine:h.value,rules:p})),(e=>{c.value=e.generateHelm,h.value=e.chiralityEngine,m.setActive(e.rules)})),v}catch(e){throw t(),e}}(),e?.show()}catch(e){const[t,n]=(0,vn.AP)(e);o.shell.warning("To run PolyTool Conversion, open a dataframe with macromolecules"),br.logger.error(t,void 0,n)}}()}static async getPolyToolConvertEditor(e){const t=await mr.create(e);return await t.showDialog()}static async polyToolConvert2(e,t,n,o,r){return(await ro(t,n,!1,o,!1,r))[0]}static async polyToolEnumerateHelmTopMenu(){await ir(o.shell.tv?.dataFrame.currentCell)}static async polyToolEnumerateChemTopMenu(){wo()}static async chemEnumerateReactionsTopMenu(){wo()}static async polyToolColumnChoice(e,t){var n;(function(e){e.semType=i.SEMTYPE.MACROMOLECULE,e.setTag("aligned","SEQ"),e.setTag("alphabet",Ot.YI.PT)})(n=t),n.meta.units=Ot.Hi.SEPARATOR,n.setTag("separator","-"),await o.data.detectSemanticTypes(e)}static async createMonomerLibraryForPolyTool(e){const t=await e.readAsString(),n=new pr(e.fileName,t),o=await n.getJson(),r=e.fileName.replace(/\.csv$/,".json"),s=JSON.stringify(o,null,2);i.Utils.download(r,s)}static async ptEnumeratorHelmApp(){await ir()}static async ptEnumeratorChemApp(){return await async function(){await br.initPromise;try{const e=Ao(await(0,Vn.j)(),null),t=r.bigButton("Enumerate",(async()=>{await e.execute()}));e.bindActionButton(t);const n=i.View.create();return n.name=so,n.box=!0,n.root.appendChild(r.divV([e.root,r.div([t],{style:{padding:"8px 4px 0"}})],{style:{height:"100%",width:"100%",padding:"8px"}})),n}catch(e){return zn(e),null}}()}static async getPtHelmEnumeratorDialog(e){return ir(e)}static async getPtChemEnumeratorDialog(e){return wo(e)}static async getPtOligoEnumeratorDialog(e){if(!e||null==e.value)return ir(void 0,!0);const t=String(e.value),n=i.Column.fromStrings("helm",[t]);return n.semType=i.SEMTYPE.MACROMOLECULE,n.meta.units="helm",n.setTag("aligned","SEQ"),n.setTag("alphabet","RNA"),n.setTag("cell.renderer","helm"),ir(i.DataFrame.fromColumns([n]).cell(0,"helm"),!0)}static async enumerateSingleHelmSequence(e,t,n,o=!1){return await sr(e,"macromolecule",null,{type:So.aK.Single,placeholders:t.map(((e,t)=>({position:e,monomers:n[t]})))},!!o&&{generateHelm:!0,chiralityEngine:!0,highlightMonomers:!1,rules:[]},br.helmHelper)}static async enumerateSingleHelmSequenceWithNaturalAAs(e,t=!1){const n=(0,Ot.qp)(e).length,o=Array.from({length:n},((e,t)=>t)),r=o.map((e=>["A","C","D","E","F","G","H","I","K","L","M","N","P","Q","R","S","T","V","W","Y"]));return await Cr.enumerateSingleHelmSequence(e,o,r,t)}static async getPolyToolCombineDialog(){!async function(){const e=[],t=r.divV([]),n=s=>{const a=(()=>{const e=r.divH([]),t=r.input.table("Table",{value:void 0,tooltipText:"Table with sequences"}),n=r.input.choice("Column",{items:[],value:void 0,tooltipText:"Sequence column"});return t.onChanged.subscribe((async()=>{const e=t.value;if(!e)return n.items=[],void(n.value=null);await e.meta.detectSemanticTypes(),await o.data.detectSemanticTypes(e);const r=Array.from(e.columns.categorical),s=r.map((e=>e.name));n.items=s,n.value=r.find((e=>e.semType===i.SEMTYPE.MACROMOLECULE))?.name??s.find((e=>{const t=e.toLowerCase();return t.includes("seq")||t.includes("pep")}))??s[0]})),e.appendChild(t.root),e.appendChild(n.root),e.style.alignItems="center",{root:e,getValue:()=>({table:t.value,column:n.value})}})(),l=r.icons.delete((()=>{if(!a.root.parentElement||e.length<2)return;a.root.remove();const t=e.indexOf(a);-1!==t&&e.splice(t,1)}),"Remove"),c=r.icons.add((()=>{let t=e.indexOf(a);-1===t&&(t=e.length),n(t+1)}),"Add");a.root.appendChild(l),a.root.appendChild(c),l.style.marginLeft="8px",l.style.marginRight="8px",l.style.color="var(--blue-1)",c.style.color="var(--blue-1)";const u=e[s];u?t.insertBefore(a.root,u.root):t.appendChild(a.root),e.splice(s,0,a)};n(0);const s=r.input.string("Separator",{value:"-",tooltipText:"Separator for sequences",nullable:!1});r.dialog("Combine Sequences").add(t).add(s.root).onOK((async()=>{if(!function(){const t=e.map((e=>e.getValue())),n=t.map((e=>e.table)),o=t.map((e=>e.column));return n.every((e=>!!e))&&o.every((e=>!!e))}())return void o.shell.error("Please fill all the fields");const t=e.map((e=>e.getValue())),n=t.map((e=>e.table)),r=t.map((e=>e.column)),a=s.value,l=r.map(((e,t)=>n[t].col(e).toList().filter((e=>!!e))));let c=0;const u=l.reduce(((e,t)=>e*t.length),1);if(u>1e7)return void o.shell.error("Too many combinations. Maximum allowed is 10M");const h=new Array(u).fill(null),d=(e,t)=>{if(t===l.length)return void(h[c++]=e);const n=`${e}${e?a:""}`,o=l[t];for(let e=0;e<l[t].length;e++)d(n+o[e],t+1)};d("",0);const p=i.DataFrame.fromColumns([i.Column.fromStrings("Combined Sequences",h)]);p.name="Combined Sequences",await p.meta.detectSemanticTypes(),await o.data.detectSemanticTypes(p),o.shell.addTableView(p)})).show({resizable:!0})}()}static oligoNucleotideCellRenderer(){return new un}static async editOligoNucleotideCell(e){const t=await(0,bn.b2)(),n=r.div(),o=t.createWebEditorApp(n,e.cell.value??"");r.dialog({showHeader:!1,showFooter:!0}).add(n).onOK((()=>{const t=o.canvas.getHelm(!0).replace(/<\/span>/g,"").replace(/<span style='background:#bbf;'>/g,"");e.setValue(t)})).show({modal:!0,fullScreen:!0})}static oligoNucleotidePanel(e){return function(e){const t=e.value??"",n=(0,Jt.On)(t),o=n.sense.monomers.filter((e=>"nucleotide"===e.kind)).length,s=n.antisense?n.antisense.monomers.filter((e=>"nucleotide"===e.kind)).length:0,a=new Map,l=new Map,c=new Map,u=new Map,h=[...n.sense.monomers,...n.antisense?.monomers??[]];for(const e of h)if("nucleotide"===e.kind){const t=e;dn(a,t.sugar),t.phosphate&&dn(l,t.phosphate),t.base&&!(0,Xt.kT)(t.base)&&dn(u,t.base)}else dn(c,e.symbol);const d=r.divV([],{style:{fontSize:"12px"}});return d.appendChild(mn("Summary",r.tableFromMap({"Sense length":`${o} nt`,"Antisense length":s?`${s} nt`:"single-strand","Modifications used":pn(a,l,u),Conjugates:c.size?Array.from(c.entries()).map((([e,t])=>`${(0,Xt.rK)(e).meta.name} ×${t}`)).join(", "):"—"}))),d.appendChild(mn("Legend",function(e,t,n,o){const i=[],s=new Map;for(const[t,n]of e.entries()){const e=(0,Xt.Jy)(t);"r"!==e&&"d"!==e&&s.set(e,(s.get(e)??0)+n)}for(const[e,t]of s.entries()){const n=(0,Xt.xh)(e,null).meta;i.push({label:n.name,color:n.color,count:t})}const a=new Map;for(const[e,n]of t.entries()){const t=(0,Xt.$T)(e);"p"!==t&&a.set(t,(a.get(t)??0)+n)}for(const[e,t]of a.entries()){const n=(0,Xt.bM)(e).meta;i.push({label:`${n.name} (linkage)`,color:n.color,count:t})}for(const[e,t]of o.entries()){const n=(0,hn.Y)(e),o=n&&Xt.L1[n]?Xt.L1[n]:Xt.FN,r=n?`${e} (base, analog ${n})`:`${e} (base)`;i.push({label:r,color:o,count:t})}for(const[e,t]of n.entries()){const n=(0,Xt.rK)(e).meta;i.push({label:n.name,color:n.color,count:t})}if(0===i.length)return r.divText("No modifications. Chip color reflects the base (A/C/G/U).",{style:{fontSize:"12px",color:"var(--grey-4, #888)",lineHeight:"1.4"}});const l=i.map((({label:e,color:t,count:n})=>r.divH([r.div([],{style:{width:"14px",height:"14px",borderRadius:"3px",background:t,border:"1px solid rgba(0,0,0,0.15)",flexShrink:"0"}}),r.divText(e,{style:{fontSize:"12px",flex:"1"}}),r.divText(`×${n}`,{style:{fontSize:"11px",color:"var(--grey-4, #888)",fontVariantNumeric:"tabular-nums"}})],{style:{gap:"6px",alignItems:"center",marginBottom:"3px"}})));return r.divV(l)}(a,l,c,u))),i.Widget.fromRoot(d)}(e)}static oligoNucleotideStructuresPanel(e){return function(e){const t=(e.value??"").split("$")[0].split("|").map((e=>e.trim())).filter((e=>e.length>0));if(0===t.length)return i.Widget.fromRoot(r.divText("No HELM chains found",{style:{fontSize:"12px",color:"var(--grey-4, #888)"}}));const n=t.map((e=>(0,Jt.nj)(e.replace(fn,"$11{")+"$$$$"))),o=1===t.length?["Strand"]:["Sense","Antisense"],s=i.Column.fromStrings("helm",n);s.semType=i.SEMTYPE.MACROMOLECULE,s.meta.units="helm",s.setTag("aligned","SEQ"),s.setTag("alphabet","RNA"),s.setTag("cell.renderer","helm");const a=i.DataFrame.fromColumns([s]),l=r.accordion("oligo chemical structures");for(let e=0;e<a.rowCount;e++){const t=o[e],n=a.cell(e,"helm");l.addPane(t,(()=>gn(n,t)))}return i.Widget.fromRoot(l.root)}(e)}static async convertHelmToOligoNucleotide(e,t){const n=(0,yn.zZ)(e,t);return await o.data.detectSemanticTypes(e),n}static async combineSenseAntisenseToOligoNucleotide(e,t,n){const r=(0,yn.xE)(e,t,n);return await o.data.detectSemanticTypes(e),r}static applyNotationProviderForCyclized(e,t){e.setTag("aligned","SEQ"),e.setTag("alphabet","UN"),e.setTag(".alphabetIsMultichar","true"),e.meta.units=s.Hi.CUSTOM,t&&!e.tags[s.qE.separator]&&(e.tags[s.qE.separator]=t),e.tags["polytool-data-role"]="template",e.temp[l.notationProvider]=new or(t,br.helmHelper)}static async harmonizedSequenceNotationProviderConstructor(){return or}}async function xr(e){await br.initLibData();const t=function(e,t){switch(e){case"Oligo Translator":return new Wt(t);case"Oligo Pattern":return new it(t);case"Oligo Structure":return new Lt(t);default:throw new Error(`Unknown app name: ${e}`)}}(e,br);return await t.getAppView()}fr([o.decorators.app({icon:"img/icons/toolkit.png",browsePath:"Peptides | Oligo Toolkit",name:"Oligo Toolkit",tags:["app"]}),gr("design:type",Function),gr("design:paramtypes",[]),gr("design:returntype",Promise)],Cr,"oligoToolkitApp",null),fr([o.decorators.init({tags:["init"]}),gr("design:type",Function),gr("design:paramtypes",[]),gr("design:returntype",Promise)],Cr,"init",null),fr([o.decorators.app({icon:"img/icons/translator.png",browsePath:"Peptides | Oligo Toolkit",name:"Oligo Translator",tags:["app"]}),gr("design:type",Function),gr("design:paramtypes",[]),gr("design:returntype",Promise)],Cr,"oligoTranslatorApp",null),fr([o.decorators.app({icon:"img/icons/pattern.png",browsePath:"Peptides | Oligo Toolkit",name:"Oligo Pattern",tags:["app"]}),gr("design:type",Function),gr("design:paramtypes",[]),gr("design:returntype",Promise)],Cr,"oligoPatternApp",null),fr([o.decorators.app({icon:"img/icons/structure.png",browsePath:"Peptides | Oligo Toolkit",name:"Oligo Structure",tags:["app"]}),gr("design:type",Function),gr("design:paramtypes",[]),gr("design:returntype",Promise)],Cr,"oligoStructureApp",null),fr([o.decorators.func({outputs:[{type:"object",name:"result"}]}),gr("design:type",Function),gr("design:paramtypes",[]),gr("design:returntype",Promise)],Cr,"getTranslationHelper",null),fr([o.decorators.func({outputs:[{type:"object",name:"result"}]}),gr("design:type",Function),gr("design:paramtypes",[]),gr("design:returntype",Object)],Cr,"getCodeToWeightsMap",null),fr([o.decorators.func(),gr("design:type",Function),gr("design:paramtypes",[String]),gr("design:returntype",Boolean)],Cr,"validateSequence",null),fr([o.decorators.func({name:"validateSequence"}),gr("design:type",Function),gr("design:paramtypes",[String,Boolean]),gr("design:returntype",String)],Cr,"getMolfileFromGcrsSequence",null),fr([o.decorators.func(),yr(0,o.decorators.param({type:"object"})),gr("design:type",Function),gr("design:paramtypes",[Object]),gr("design:returntype",String)],Cr,"linkStrands",null),fr([o.decorators.func({meta:{demoPath:"Bioinformatics | Oligo Toolkit | Translator",path:"/apps/Tutorials/Demo/Bioinformatics/Oligonucleotide%20Sequence:%20Translate",demoSkip:"GROK-14320"},name:"demoOligoTranslator",description:"Translate oligonucleotide sequences across various formats accepted by different synthesizers"}),gr("design:type",Function),gr("design:paramtypes",[]),gr("design:returntype",Promise)],Cr,"demoTranslateSequence",null),fr([o.decorators.func({meta:{demoPath:"Bioinformatics | Oligo Toolkit | Pattern",path:"%20/apps/Tutorials/Demo/Bioinformatics/Oligonucleotide%20Sequence:%20Visualize%20duplex"},description:"Design a modification pattern for an oligonucleotide sequence"}),gr("design:type",Function),gr("design:paramtypes",[]),gr("design:returntype",Promise)],Cr,"demoOligoPattern",null),fr([o.decorators.func({meta:{demoPath:"Bioinformatics | Oligo Toolkit | Structure",path:"%20/apps/Tutorials/Demo/Bioinformatics/Oligonucleotide%20Sequence:%20Visualize%20duplex"},description:"Visualize duplex and save SDF"}),gr("design:type",Function),gr("design:paramtypes",[]),gr("design:returntype",Promise)],Cr,"demoOligoStructure",null),fr([o.decorators.func(),gr("design:type",Function),gr("design:paramtypes",[String,String,String]),gr("design:returntype",Promise)],Cr,"translateOligonucleotideSequence",null),fr([o.decorators.func({"top-menu":"Bio | PolyTool | Convert...",name:"polyToolConvert",description:"editor for Performing conversion of sequences in custom notation to molfiles"}),gr("design:type",Function),gr("design:paramtypes",[]),gr("design:returntype",Promise)],Cr,"polyToolConvertTopMenu",null),fr([o.decorators.editor({tags:["editor"]}),gr("design:type",Function),gr("design:paramtypes",[i.FuncCall]),gr("design:returntype",Promise)],Cr,"getPolyToolConvertEditor",null),fr([o.decorators.func({editor:"SequenceTranslator:getPolyToolConvertEditor"}),yr(1,o.decorators.param({options:{caption:"Sequence"}})),yr(2,o.decorators.param({options:{initialValue:"true"}})),yr(3,o.decorators.param({options:{initialValue:"true"}})),yr(4,o.decorators.param({type:"object"})),gr("design:type",Function),gr("design:paramtypes",[i.DataFrame,i.Column,Boolean,Boolean,Array]),gr("design:returntype",Promise)],Cr,"polyToolConvert2",null),fr([o.decorators.func({"top-menu":"Bio | PolyTool | Enumerate HELM...",name:"polyToolEnumerateHelm",description:"Dialog for configuring enumeration of a HELM sequence"}),gr("design:type",Function),gr("design:paramtypes",[]),gr("design:returntype",Promise)],Cr,"polyToolEnumerateHelmTopMenu",null),fr([o.decorators.func({"top-menu":"Bio | PolyTool | Enumerate Chem...",name:"polyToolEnumerateChem",description:"Perform enumeration of a molecule using different fragments at specified positions"}),gr("design:type",Function),gr("design:paramtypes",[]),gr("design:returntype",Promise)],Cr,"polyToolEnumerateChemTopMenu",null),fr([o.decorators.func({"top-menu":"Chem | Transform | Reactions | Enumerate...",name:"chemEnumerateReactions",description:"Enumerate cores and R-group lists into a molecule table (Zip or Cartesian)"}),gr("design:type",Function),gr("design:paramtypes",[]),gr("design:returntype",Promise)],Cr,"chemEnumerateReactionsTopMenu",null),fr([o.decorators.func(),yr(0,o.decorators.param({options:{description:"Input data table"}})),gr("design:type",Function),gr("design:paramtypes",[i.DataFrame,i.Column]),gr("design:returntype",Promise)],Cr,"polyToolColumnChoice",null),fr([o.decorators.func(),gr("design:type",Function),gr("design:paramtypes",[i.FileInfo]),gr("design:returntype",Promise)],Cr,"createMonomerLibraryForPolyTool",null),fr([o.decorators.func({meta:{icon:"img/icons/structure.png",browsePath:"Peptides | PolyTool",role:"app"},name:"HELM Enumerator",tags:["app"]}),gr("design:type",Function),gr("design:paramtypes",[]),gr("design:returntype",Promise)],Cr,"ptEnumeratorHelmApp",null),fr([o.decorators.func({meta:{icon:"img/icons/structure.png",browsePath:"Chem | PolyTool",role:"app"},name:"Chem Enumerator",tags:["app"],outputs:[{type:"view",name:"result"}]}),gr("design:type",Function),gr("design:paramtypes",[]),gr("design:returntype",Promise)],Cr,"ptEnumeratorChemApp",null),fr([o.decorators.func({name:"Polytool Helm Enumerator dialog"}),yr(0,o.decorators.param({type:"object",options:{nullable:!0}})),gr("design:type",Function),gr("design:paramtypes",[i.Cell]),gr("design:returntype",Promise)],Cr,"getPtHelmEnumeratorDialog",null),fr([o.decorators.func({name:"Polytool Chem Enumerator dialog"}),yr(0,o.decorators.param({type:"object",options:{nullable:!0}})),gr("design:type",Function),gr("design:paramtypes",[i.Cell]),gr("design:returntype",Promise)],Cr,"getPtChemEnumeratorDialog",null),fr([o.decorators.func({name:"Polytool Oligo Enumerator dialog"}),yr(0,o.decorators.param({type:"object",options:{nullable:!0}})),gr("design:type",Function),gr("design:paramtypes",[i.Cell]),gr("design:returntype",Promise)],Cr,"getPtOligoEnumeratorDialog",null),fr([o.decorators.func({name:"Enumerate Single HELM Sequence",description:"Enumerate provided HELM sequence on provided positions with provided monomers and generates new table",outputs:[{type:"dataframe",name:"result"}]}),gr("design:type",Function),gr("design:paramtypes",[String,Array,Array,Boolean]),gr("design:returntype",Promise)],Cr,"enumerateSingleHelmSequence",null),fr([o.decorators.func({name:"Enumerate Single HELM Sequence with natural amino acids",description:'Enumerate provided HELM sequence on all positions with natural amino acids and generates new table. Generated table has sequence column called "Enumerated", and molecule column called "Molfile(Enumerated) if toAtomicLevel is set to true. Keywords: Optimize, enumerate, HELM optimization, Maximize Minimize property. When you want to optimize certain peptide using for example logS, set toAtomicLevel to true and use generated molecule column to calculate given property using chem package functions.',outputs:[{type:"dataframe",name:"result"}]}),gr("design:type",Function),gr("design:paramtypes",[String,Boolean]),gr("design:returntype",Promise)],Cr,"enumerateSingleHelmSequenceWithNaturalAAs",null),fr([o.decorators.func({name:"Combine Sequences","top-menu":"Bio | PolyTool | Combine Sequences..."}),gr("design:type",Function),gr("design:paramtypes",[]),gr("design:returntype",Promise)],Cr,"getPolyToolCombineDialog",null),fr([o.decorators.func({name:"oligoNucleotideCellRenderer",description:"Renders OligoNucleotide (siRNA / ASO) duplex view in grid cells",tags:["cellRenderer"],meta:{cellType:"OligoNucleotide",columnTags:"quality=OligoNucleotide",role:"cellRenderer"},outputs:[{type:"grid_cell_renderer",name:"result"}]}),gr("design:type",Function),gr("design:paramtypes",[]),gr("design:returntype",i.GridCellRenderer)],Cr,"oligoNucleotideCellRenderer",null),fr([o.decorators.func({name:"editOligoNucleotideCell",description:"OligoNucleotide",tags:["cellEditor"],meta:{role:"cellEditor"}}),yr(0,o.decorators.param({type:"grid_cell"})),gr("design:type",Function),gr("design:paramtypes",[i.GridCell]),gr("design:returntype",Promise)],Cr,"editOligoNucleotideCell",null),fr([o.decorators.func({name:"Oligo-Nucleotide",description:"Modifications, lengths, conjugates and color legend for an OligoNucleotide cell",tags:["panel","widgets"],outputs:[{type:"widget",name:"result"}]}),yr(0,o.decorators.param({type:"semantic_value",options:{semType:"OligoNucleotide"}})),gr("design:type",Function),gr("design:paramtypes",[i.SemanticValue]),gr("design:returntype",i.Widget)],Cr,"oligoNucleotidePanel",null),fr([o.decorators.func({name:"Oligo Structures",description:"Sense and antisense full molecular structures rendered separately",tags:["panel","widgets"],outputs:[{type:"widget",name:"result"}]}),yr(0,o.decorators.param({type:"semantic_value",options:{semType:"OligoNucleotide"}})),gr("design:type",Function),gr("design:paramtypes",[i.SemanticValue]),gr("design:returntype",i.Widget)],Cr,"oligoNucleotideStructuresPanel",null),fr([o.decorators.func({name:"convertHelmToOligoNucleotide",description:"Create a new column tagged as OligoNucleotide so HELM duplex cells render with the oligo view"}),yr(1,o.decorators.param({options:{caption:"HELM column",semType:"Macromolecule"}})),gr("design:type",Function),gr("design:paramtypes",[i.DataFrame,i.Column]),gr("design:returntype",Promise)],Cr,"convertHelmToOligoNucleotide",null),fr([o.decorators.func({name:"combineSenseAntisenseToOligoNucleotide",description:"Combine separate sense + antisense HELM columns into one OligoNucleotide column"}),yr(1,o.decorators.param({options:{caption:"Sense",semType:"Macromolecule"}})),yr(2,o.decorators.param({options:{caption:"Antisense",semType:"Macromolecule"}})),gr("design:type",Function),gr("design:paramtypes",[i.DataFrame,i.Column,i.Column]),gr("design:returntype",Promise)],Cr,"combineSenseAntisenseToOligoNucleotide",null),fr([o.decorators.func({name:"applyNotationProviderForHarmonizedSequence"}),yr(0,o.decorators.param({type:"column"})),gr("design:type",Function),gr("design:paramtypes",[i.Column,String]),gr("design:returntype",void 0)],Cr,"applyNotationProviderForCyclized",null),fr([o.decorators.func({name:"harmonizedSequenceNotationProviderConstructor",meta:{role:"notationProviderConstructor"}}),gr("design:type",Function),gr("design:paramtypes",[]),gr("design:returntype",Promise)],Cr,"harmonizedSequenceNotationProviderConstructor",null)},5412:(e,t,n)=>{"use strict";n.d(t,{m:()=>l});var o=n(6082),r=n(4328),i=n(4971),s=n(6077),a=n(2003);async function l(e,t,n,l,c,u,h,d,p){const m=(await p.helmToAtomicLevel(e,l,c,h)).molCol,f=n.filter((e=>e)).length;if(u&&f>0){const e=new Array(f);let l=0;for(let o=0;o<n.length;o++)n[o]&&(e[l]=t[o],l++);const c=o.Column.fromStrings("helm",e);c.semType=o.SEMTYPE.MACROMOLECULE,c.meta.units=a.Hi.HELM,c.setTag(o.TAGS.CELL_RENDERER,"helm");const u=(await(0,i.pj)()).getMonomerLib();try{const e=await(0,s.C4)(o.DataFrame.create(0),c,u,p,d);l=0;for(let t=0;t<n.length;t++)n[t]&&(m.set(t,e.molCol.get(l)),l++)}catch(e){r.shell.warning("PolyTool was not able to linearize sequences")}}return function(e){for(let t=0;t<e.length;t++)e.set(t,e.get(t).replaceAll("undefined","H")),e.set(t,e.get(t).replaceAll("Oh","O").replaceAll("OH","O")),e.set(t,e.get(t).replaceAll("0.000000 3","0.000000 0")),e.set(t,e.get(t).replaceAll("?","O")),e.set(t,e.get(t).replaceAll(" 0 3\n"," 0 0\n")),e.set(t,e.get(t).replaceAll("RGROUPS=(1 1)",""))}(m),m}},6307:(e,t,n)=>{"use strict";n.d(t,{s:()=>p});var o=n(2125),r=n(8438),i=n(6694);function s(e,t){let n="";for(let e=0;e<t.length;e++){e>0&&(n+="|"),n+=`PEPTIDE${e+1}{`;for(let o=0;o<t[e].length;o++){o>0&&(n+=".");const r=t[e][o];n+=r.length>1?`[${r}]`:r}n+="}"}n+="$";for(let r=0;r<e.length;r++)r>0&&(n+="|"),n+=`PEPTIDE${e[r].fChain+1},PEPTIDE${e[r].sChain+1},`,n+=`${(0,o.M)(e[r].fMonomer-1,t)[0]+1}:R${e[r].fR}-`,n+=`${(0,o.M)(e[r].sMonomer-1,t)[0]+1}:R${e[r].sR}`;return n+="$$$V2.0",n}function a(e,t,n,o=0,r=[],i=[]){let[s,a,l,c,u]=[!1,!1,!1,-1,-1];for(let h=0;h<e.length;h++)if(e[h].includes(t)){if(s){if(l&&(n||e[h]==i[o]+t)){a=!0,u=h;break}if(l||!n&&e[h]!=r[o]+t)continue;a=!0,u=h;break}if(n)s=!0,l=!0,c=h;else if(e[h]==r[o]+t)s=!0,l=!0,c=h;else{if(e[h]!=i[o]+t)continue;s=!0,l=!!n,c=h}}return[s,a,l,c,u]}function l(e,t){const n=[];for(let o=0;o<t.length;o++){const r=`(${t[o].code})`,[s,l]=(0,i.Ln)(t[o]);if(s.length>0)for(let t=0;t<s.length;t++){const[i,c,u,h,d]=a(e,r,!1,t,s,l);i&&c&&(u?n.push({firstIdx:h,secondIdx:d,ruleIdx:o}):n.push({firstIdx:d,secondIdx:h,ruleIdx:o}))}else{const[t,i,s,l,c]=a(e,r,!0);if(!t||!i)continue;s?n.push({firstIdx:l,secondIdx:c,ruleIdx:o}):n.push({firstIdx:c,secondIdx:l,ruleIdx:o})}}return n}function c(e,t,n){const o=[],r=[],i=[],s=[],a=n.length;for(let l=0;l<a;l++){if(-1==n[l].firstIdx)continue;const a=n[l].ruleIdx,c=e[a].code;t[n[l].firstIdx]=t[n[l].firstIdx].replace(`(${c})`,""),t[n[l].secondIdx]=t[n[l].secondIdx].replace(`(${c})`,""),o.push(n[l].firstIdx+1),r.push(n[l].secondIdx+1),i.push(e[a].firstLinkingGroup),s.push(e[a].secondLinkingGroup)}return[o,r,i,s]}function u(e,t,n){const o=[],r=[],i=[],s=n.length;for(let a=0;a<s;a++){if(-1==n[a].firstIdx)continue;const s=n[a].firstIdx,l=n[a].secondIdx,c=n[a].ruleIdx,u=e[c].code;t[s]=t[s].replace(`(${u})`,"")+`_${e[c].name}`,t[l]=t[l].replace(`(${u})`,"")+`_${e[c].name}`,o.push(s+1),r.push(l+1),i.push(n[a].ruleIdx)}return[o,r,i]}var h=n(3599);function d(e,t,n){const o=n.createHelmWebEditor().editor.m;let r=0;const i=new JSDraw2.Point(0,0);for(let e=0;e<t.length;e++)for(let n=0;n<t[e].length;n++){if(t[e][n]){const s=t[e][n],a={type:h.o.AA,i:e,j:n,continuousId:r},l=new JSDraw2.Atom(i,s,a);if(o.addAtom(l),0!==n){const e=o.atoms[r-1],t=o.atoms[r],n=new JSDraw2.Bond(e,t);n.r1=2,n.r2=1,o.addBond(n)}r++,i.x+=JSDraw2.Editor.BONDLENGTH}i.y+=4*JSDraw2.Editor.BONDLENGTH}for(let t=0;t<e.length;t++){const n=o.atoms[e[t].fMonomer-1],r=o.atoms[e[t].sMonomer-1],i=new JSDraw2.Bond(n,r);i.r1=e[t].fR,i.r2=e[t].sR,o.addBond(i)}return o}class p{constructor(e,t,n){this.helmHelper=n,this.underRules=!1,this.posToPosUnderRules=[],this.linkages=t,this.monomers=e,this.mol=d(t,e,n)}static fromSeparator(e,t){const[n,o]=function(e){const t=[],n=[],o=/(\(.\d+\))?\{[^\}]*\}/g,r=[];r.push(e.replaceAll(o,""));const i=e.matchAll(o);for(const e of i){const t=e[0];t&&r.push(t)}let s=0;for(let e=0;e<r.length;e++){const o=r[e].split("-"),i=new Array(o.length);let a=0;for(let t=0;t<o.length;t++){const r=o[t].replace("{","").replace("}","");""!==r?(i[t]=r,s++,a++):n.push({fChain:e,sChain:e+1,fMonomer:s,sMonomer:s+1,fR:1,sR:1})}t.push(i.slice(0,a))}return[n,t]}(e);return new p(o,n,t)}static fromHelm(e,t){const[n,i]=function(e){const t=/(\w+\{.*\})\$(.*)\$(.*)\$(.*)\$/g.exec(e),n=[t[1],t[2],t[3],t[4]],i=n[0].split("|"),s=n[1].split("|"),a=new Array(i.length),l=[];for(let e=0;e<i.length;e++){const t=i[e].indexOf("{"),n=i[e].indexOf("}");a[e]=i[e].slice(t+1,n).split(".").map((e=>(0,r.D)(e)))}for(let e=0;e<s.length;e++)if(""!==s[e]&&"V2.0"!==s[e]){const t=s[e].split(","),n=parseInt(t[0].replace("PEPTIDE",""))-1,r=parseInt(t[1].replace("PEPTIDE",""))-1,i=t[2].split("-"),c=i[0].split(":"),u=i[1].split(":");l.push({fChain:n,sChain:r,fMonomer:(0,o.j)(parseInt(c[0]),n,a),sMonomer:(0,o.j)(parseInt(u[0]),r,a),fR:parseInt(c[1].replace("R","")),sR:parseInt(u[1].replace("R",""))})}return[l,a]}(e);return new p(i,n,t)}getNotation(){return function(e){const t=e.atoms,n=e.bonds,o=[],r=[];for(let e=0;e<n.length;e++)n[e].a1.bio.i!==n[e].a2.bio.i&&r.push(e);for(let e=0;e<t.length;e++){const n=t[e].bio?.i;n+1>o.length?o.push(1):o[n]++}const i=new Array(o.length);let s=0;for(let e=0;e<o.length;e++){const n=new Array(o[e]);for(let r=0;r<o[e];r++)n[r]=t[s].elem,s++;i[e]=n}let a="";for(let e=0;e<i.length;e++){let t="";for(let n=0;n<i[e].length;n++)t+=`${0==n?"":"-"}${i[e][n]}`;if(0!==e){const e=/(\(.\d+\))/,n=t.match(e);t=t.replace(n?.[0],""),t=`${n?n?.[0]:""}{${t}}`}else if(i.length>1){const e=0==n[r[0]].a1.bio.i&&0==n[r[0]].a1.bio.j,o=1==n[r[0]].a2.bio.i&&0==n[r[0]].a1.bio.j;e&&o&&(t+="-")}a+=t}return a}(this.mol)}getHelm(){return this.underRules?s(this.linkagesUnderRules,this.monomersUnderRules):s(this.linkages,this.monomers)}applyRules(e){const t=this.getNotation(),[n,o,r]=function(e,t){const n=[],o=[],r=[],i=t.heterodimerCode,s=t.homodimerCode,a=null!==i?e.split(`(${t.heterodimerCode})`):"";null!==i&&a.length>1?(r.push({fChain:0,sChain:1,fMonomer:1,sMonomer:1,fR:1,sR:1}),n.push(a[1].replaceAll("{","").replaceAll("}","")),n.push(a[2].replaceAll("{","").replaceAll("}","")),o.push(!1),o.push(!1)):(n.push(e),o.push(!1));for(let e=0;e<n.length;e++)if(null!==s&&n[e].includes(`(${s})`)){const t=n.length;r.push({fChain:e,sChain:t,fMonomer:1,sMonomer:1,fR:1,sR:1});const i=n[e].replace(`(${s})`,""),a=i.indexOf("{"),l=i.slice(0,a),c=i.replace(l,"").replaceAll("{","").replaceAll("}","");n[e]=l+c,n.push(c),o.push(!0)}return[r,n,o]}(t,e),i=new Array(o.length);let s=0;for(let e=0;e<o.length;e++)if(i[e]=o[e].split("-"),r[e]){const t=this.posToPosUnderRules.length-i[e].length;for(let n=0;n<i[e].length;n++)this.posToPosUnderRules[t+n].push(s),s++}else for(let t=0;t<i[e].length;t++)this.posToPosUnderRules.push([s]),s++;!function(e,t,n){for(let o=0;o<e.length;o++){const r=e[o],i=l(r,n.linkRules),[s,a,u,h]=c(n.linkRules,r,i);for(let e=0;e<s.length;e++)t.push({fChain:o,sChain:o,fMonomer:s[e],sMonomer:a[e],fR:u[e],sR:h[e]});e[o]=r}}(i,n,e),function(e,t,n){for(let o=0;o<e.length;o++){const r=l(e[o],n.reactionRules),[i,s,a]=u(n.reactionRules,e[o],r);i.length>=1&&(t.push({fChain:o,sChain:e.length,fMonomer:i[0],sMonomer:1,fR:3,sR:1}),t.push({fChain:o,sChain:e.length,fMonomer:s[0],sMonomer:1,fR:3,sR:2}),e.push([n.reactionRules[a[0]].name]))}}(i,n,e),this.underRules=!0,this.linkagesUnderRules=n,this.monomersUnderRules=i,this.molUnderRules=d(n,i,this.helmHelper)}check(e=!1){const t=[],n=this.monomers.map((e=>e.length)).reduce(((e,t)=>e+t),0);this.mol.atoms.length!==n&&t.push(`The mol atoms count ${this.mol.atoms.length} does not match the total number ${n} of chains' monomers.`);const o=this.monomers.map((e=>e.length-1)).reduce(((e,t)=>e+t),0)+this.linkages.length;this.mol.bonds.length!==o&&t.push(`The mol bonds count ${this.mol.bonds.length} does not match the total number ${o} in- and inter-chain linkages.`);let r=0;for(let e=0;e<this.monomers.length;++e){const n=this.monomers[e];for(let e=0;e<n.length;++e)try{const o=n[e],i=this.mol.atoms[r];i.bio.continuousId!==r&&t.push(`Atom #${r} has incorrect .bio.continuousId: ${i.bio.continuousId}.`),i.elem!==o&&t.push(`Atom #${r} elem: '${i.elem}' does not match chain monomer: '${o}'.`)}finally{r++}}if(e&&t.length>0)throw new Error(`Chain errors:\n${t.map((e=>` ${e}`)).join("\n")}`);return t}}},4229:(e,t,n)=>{"use strict";n.d(t,{b:()=>s});var o=n(9192),r=n(6307),i=n(6345);function s(e,t,n){const s=new Array(e.length),a=new Array(e.length),l=new Array(e.length);for(let c=0;c<e.length;c++)try{if(null==e[c])s[c]="";else{const o=r.s.fromSeparator(e[c],n);o.applyRules(t),a[c]=!(o.monomersUnderRules.length>1||o.linkagesUnderRules.length>0),s[c]=o.getHelm(),l[c]=o.posToPosUnderRules}}catch(e){const[t,n]=(0,o.AP)(e);i._package.logger.error(t,void 0,n),s[c]=""}return[s,a,l]}},2125:(e,t,n)=>{"use strict";function o(e,t){let n,o=e;for(n=0;n<t.length&&o>=t[n].length;++n)o-=t[n].length;return[o,n]}function r(e,t,n){let o=0;for(let e=0;e<t;++e)o+=n[e].length;return o+e}n.d(t,{M:()=>o,j:()=>r})},6694:(e,t,n)=>{"use strict";n.d(t,{MU:()=>V,yy:()=>j,_v:()=>J,Ln:()=>te,Q4:()=>ee});var o=n(6082),r=n(4328),i=n(7389),s=n(1991),a=n.n(s),l=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function s(e){try{l(o.next(e))}catch(e){i(e)}}function a(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}l((o=o.apply(e,t||[])).next())}))};class c{constructor(e,t,n=".csv",o){this.path=e,this.userStorageName=t,this.ext=n,this.options=o,this.inputs=null,"/"!==this.path[this.path.length-1]&&(this.path+="/"),"."!==this.ext[0]&&(this.ext="."+this.ext)}getUserSettings(){return l(this,void 0,void 0,(function*(){if(this.settings)return this.settings;const e=r.userSettings.getValue(this.userStorageName,"Settings"),t=e?JSON.parse(e):{excluded:[],explicit:[]};return t.explicit=t.explicit instanceof Array?t.explicit:[],t.excluded=t.excluded instanceof Array?t.excluded:[],this.settings=t}))}setUserSettings(e){this.settings=e,r.userSettings.add(this.userStorageName,"Settings",JSON.stringify(e))}getAllAvailable(){return l(this,void 0,void 0,(function*(){return(yield r.dapi.files.list(this.path)).map((e=>e.fullPath.replace(`${this.path}`,"")))}))}getActive(){return l(this,void 0,void 0,(function*(){const e=yield this.getUserSettings();return e.explicit.length>0?e.explicit:(yield this.getAllAvailable()).filter((t=>!e.excluded.includes(t)))}))}setActive(e){const t=new Set(e);for(const[e,n]of this.inputs.entries())n.value=t.has(e)}createInput(e,t){const n=i.input.bool(e,{value:t,onValueChanged:t=>this.updateSelectionStatus(e,t)});return n.addOptions(i.button(i.iconFA("trash"),(()=>{i.dialog({title:"Warning"}).add(i.divText(`Delete file '${e}'?`)).onOK((()=>{n.root.remove(),this.availableRemove(e)})).show()}),`Delete ${e}`)),n}getInputs(){return l(this,void 0,void 0,(function*(){this.inputs=new Map;const e=yield this.getAllAvailable(),t=yield this.getActive(),n=new Array(e.length);for(let o=0;o<e.length;o++){const r=t.includes(e[o]);n[o]=this.createInput(e[o],r),this.inputs.set(e[o],n[o])}return this.fireOnValueChanged(),n}))}getForm(){return l(this,void 0,void 0,(function*(){const e=yield this.getInputs(),t=i.divV(e);return i.divV([t,i.button("ADD",(()=>l(this,void 0,void 0,(function*(){let e="";if(e=yield this.getNewAvailable(),""!==e){const n=this.createInput(e,!0);t.append(n.root),this.inputs.set(e,n),this.fireOnValueChanged()}}))))])}))}fireOnValueChanged(){var e;null===(e=this.options)||void 0===e||e.onValueChanged(a()(this.inputs.entries()).filter((([e,t])=>t.value)).map((([e,t])=>e)).toArray())}updateSelectionStatus(e,t){return l(this,void 0,void 0,(function*(){const n=yield this.getUserSettings();if(!n.excluded.includes(e)!==t){if(t){const t=n.excluded.indexOf(e);t>-1&&n.excluded.splice(t,1)}else n.excluded.push(e);this.fireOnValueChanged(),this.setUserSettings(n)}}))}availableRemove(e){return l(this,void 0,void 0,(function*(){this.inputs.delete(e),this.fireOnValueChanged();const t=yield this.getUserSettings(),n=t.excluded.indexOf(e);n>-1&&t.excluded.splice(n,1),this.setUserSettings(t),yield r.dapi.files.delete(this.path+e),r.shell.info(`File ${e} successfully deleted`)}))}getNewAvailable(){return l(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{o.Utils.openFile({accept:this.ext,open:t=>l(this,void 0,void 0,(function*(){const n=t.name,o=yield t.arrayBuffer();yield r.dapi.files.write(this.path+`${t.name}`,new Uint8Array(o)),e(n)}))})}))}))}}var u=n(6345),h=n(9124),d=n(4229),p=n(439),m=n(5174),f=n(5412),g=n(6717),y=n(8312);function b(e){let t=e.replaceAll(/\[R[1-9]\]/g,(e=>`[*:${e[2]}]`));return t=t.replaceAll(/\[\d\*\]/g,(e=>`[*:${e[1]}]`)),t.replaceAll(/\[\d\*\:\d\]/g,(e=>`[*:${e[1]}]`))}function v(e){return e.replaceAll(/\[\*\:\d\]/g,(e=>`[C:${e[3]}]`))}function C(e){return e.replaceAll(/\[C\:\d\]/g,(e=>`[*:${e[3]}]`))}function x(e,t){const n=t?.firstReactantSmiles?C(t.firstReactantSmiles):"[*:1]C",o=t?.secondReactantSmiles?C(t.secondReactantSmiles):"[*:2]C",s=t?.productSmiles?C(t.productSmiles):"[*:1]CC[*:2]",a=t?.code,l=t?.firstMonomers??[],c=t?.secondMonomers??[],u=t?.resultMonomerName??"",h=i.input.int("Code",{value:a,nullable:!1,showPlusMinus:!1,showSlider:!1,tooltipText:"Reaction code"}),d=i.input.string("First monomers",{value:l.join(","),nullable:!1,tooltipText:"Comma-separated list of monomers for the first reactant"}),p=i.input.string("Second monomers",{value:c.join(","),nullable:!1,tooltipText:"Comma-separated list of monomers for the second reactant"}),m=i.input.string("Result monomer name",{value:u,nullable:!1,tooltipText:"Name of the resulting pseudo-monomer generated by the reaction of the two reactants"}),f=i.input.molecule("First reactant",{value:n,nullable:!1,tooltipText:"Reactant fragment of first monomer(s). Use numbered R groups in correspondence with the rest of the molecule."}),g=i.input.molecule("Second reactant",{value:o,nullable:!1,tooltipText:"Reactant fragment of second monomer(s). Use numbered R groups in correspondence with the rest of the molecule."}),y=i.input.molecule("Product",{value:s,nullable:!1,tooltipText:"Product fragment of the resulting monomer from the reaction of the two reactants. Use numbered R groups in correspondence with the reactants."}),x=()=>{if(!f||!g||!y)return"Inputs not initialized yet";const e=v(b(r.chem.convert(f.value??"",r.chem.Notation.Unknown,r.chem.Notation.Smiles))),t=v(b(r.chem.convert(g.value??"",r.chem.Notation.Unknown,r.chem.Notation.Smiles))),n=v(b(r.chem.convert(y.value??"",r.chem.Notation.Unknown,r.chem.Notation.Smiles)));return e&&t&&n?-1==e.indexOf("[C:1]")?"First Reactant must contain R1-group":-1==t.indexOf("[C:2]")?"Second Reactant must contain R2-group":-1==n.indexOf("[C:1]")||-1==n.indexOf("[C:2]")?"Product must contain R1- and R2-groups":null:"First/Second Reactants and Product must all be set"};f.addValidator(x),g.addValidator(x),y.addValidator(x);const w=i.dialog(t?"Edit Reaction Rule":"Add Reaction Rule").add(h).add(m).add(d).add(p).add(f).add(g).add(y);w.addButton("Save",(()=>{const n=x();if(null!=n)return void r.shell.warning(n);const o=v(b(r.chem.convert(f.value??"",r.chem.Notation.Unknown,r.chem.Notation.Smiles))),i=v(b(r.chem.convert(g.value??"",r.chem.Notation.Unknown,r.chem.Notation.Smiles))),s=v(b(r.chem.convert(y.value??"",r.chem.Notation.Unknown,r.chem.Notation.Smiles)));e({code:h.value,resultMonomerName:m.value,firstMonomers:d.value.split(",").map((e=>e.trim())).filter((e=>e.length>0)),secondMonomers:p.value.split(",").map((e=>e.trim())).filter((e=>e.length>0)),firstReactantSmiles:o,secondReactantSmiles:i,productSmiles:s,rowIndex:t?.rowIndex}),w.close()})),w.show()}const w="Links",A="Reactions";class T{constructor(e,t){this.v=null,this.substituteReactionGridDataFrame=null,this.rules=e;const n=this.rules.getLinkRulesDf();this.linkRuleDataFrame=n.res,this.addLinkRulesFunc=n.addNewRow;const o=this.rules.getSynthesisRulesDf();this.addSynthRulesFunc=e=>{o.addNewRow(e),this.rules.setSynthesisRules(o.df),this.synthRuleDataFrame=o.df,this.substituteReactionGridDataFrame?.(),this.save()},this.synthRuleDataFrame=o.df,this.fileName=t;const r=this.rules.homodimerCode?this.rules.homodimerCode:"",s=this.rules.heterodimerCode?this.rules.heterodimerCode:"";this.homoDimerInput=i.input.string("Homo dimer",{value:r,onValueChanged:()=>{},nullable:!1}),this.heteroDimerInput=i.input.string("Hetero dimer",{value:s,onValueChanged:()=>{},nullable:!1})}async getAndAddView(){if(this.v)try{const e=Array.from(r.shell.views).find((e=>e.name===this.v.name));if(!e)throw this.v.detach(),this.v.close(),new Error("View is closed, making it null in catch statement");r.shell.v=e}catch(e){this.v=null}return this.v||(this.v=o.View.create(),this.v.name=`Manage Polytool Rules - ${this.fileName}`,this.v.append(await this.getForm()),this.v=r.shell.addView(this.v),r.shell.v=this.v),this.v}static async getInstance(e){if(!this.instances[e]){const t=await ee([e]);this.instances[e]=new T(t,e)}return this.instances[e]}save(){this.rules.homodimerCode=this.homoDimerInput.value,this.rules.heterodimerCode=this.heteroDimerInput.value,this.rules.setLinkRules(this.linkRuleDataFrame),this.rules.setSynthesisRules(this.synthRuleDataFrame);const e={homodimerCode:this.rules.homodimerCode,heterodimerCode:this.rules.heterodimerCode,linkRules:this.rules.linkRules,reactionRules:this.rules.reactionRules},t=JSON.stringify(e,void 0,2);u._package.files.writeAsText(`polytool-rules/${this.fileName}`,t),r.shell.info(`Polytool rules at ${this.fileName} was updated`)}createGridDiv(e,t,n){const o=i.h1(e,"polytool-grid-header");i.tooltip.bind(o,n),o.style.marginTop="10px",o.style.marginRight="10px",t.root.style.height="100%";const r=i.splitV([i.box(o,{style:{maxHeight:"60px"}}),t.root]);return r.style.height="100%",r}async getLinkExamplesGrid(){const e=[];for(let t=0;t<this.rules.linkRules.length;t++){const n=this.rules.linkRules[t].code,[o,r]=te(this.rules.linkRules[t]);for(let t=0;t<o.length;t++){const i=`${o[t]}(${n})-A-A-A-A-${r[t]}(${n})`;e.push(i)}}const t=await(0,h.b2)(),[n,r,i]=(0,d.b)(e,this.rules,t),s=o.Column.fromStrings("Monomers",e),a=o.Column.fromStrings("Helm",n);return u.PackageFunctions.applyNotationProviderForCyclized(s,"-"),s.semType=o.SEMTYPE.MACROMOLECULE,a.semType=o.SEMTYPE.MACROMOLECULE,a.meta.units=p.Hi.HELM,a.setTag(o.TAGS.CELL_RENDERER,"helm"),o.DataFrame.fromColumns([s,a]).plot.grid()}async getReactionExamplesGrid(){const e=[];for(let t=0;t<this.rules.reactionRules.length;t++){const n=this.rules.reactionRules[t].code,[o,r]=te(this.rules.reactionRules[t]);for(let t=0;t<o.length;t++){const i=`${o[t]}(${n})-A-A-A-A-${r[t]}(${n})`;e.push(i)}}const t=await(0,h.b2)(),[n,r,i]=(0,d.b)(e,this.rules,t),s=o.Column.fromStrings("Monomers",e),a=o.Column.fromStrings("Helm",n),l=o.DataFrame.fromColumns([s,a]);s.semType=o.SEMTYPE.MACROMOLECULE;const c=await(0,g.j)(),b=await(0,y.Q)();u.PackageFunctions.applyNotationProviderForCyclized(s,"-"),s.tags[o.TAGS.CELL_RENDERER]="Sequence",a.semType=o.SEMTYPE.MACROMOLECULE,a.meta.units=p.Hi.HELM,a.setTag(o.TAGS.CELL_RENDERER,"helm");const v=await(0,m.A)(this.rules),C=a.temp;C[".mm.cellRenderer.overriddenLibrary"]=v,a.temp=C;const x=await(0,f.m)(a,e,r,!0,!1,!1,v,c,b);return x.name="molfile(sequence)",x.semType=o.SEMTYPE.MOLECULE,l.columns.add(x),l.plot.grid()}async getForm(){const e=this.linkRuleDataFrame.plot.grid({showAddNewRowIcon:!1,allowEdit:!1,rowHeight:60});e.onCellDoubleClick.subscribe((()=>{if(!e.dataFrame||-1==e.dataFrame.currentRowIdx||null==e.dataFrame.currentRowIdx)return;const t=e.dataFrame.currentRowIdx,n={row:t,code:this.linkRuleDataFrame.get("code",t),firstMonomers:this.linkRuleDataFrame.get("firstMonomers",t),secondMonomers:this.linkRuleDataFrame.get("secondMonomers",t),firstLinkingGroup:this.linkRuleDataFrame.get("firstLinkingGroup",t),secondLinkingGroup:this.linkRuleDataFrame.get("secondLinkingGroup",t)};this.getAddNewLinkRuleDialog(n)}));const t=this.createGridDiv("Rules",e,"specification for monomers to link and linking positions"),n=this.createGridDiv("Examples",await this.getLinkExamplesGrid(),"specification for monomers to link and linking positions");t.style.width="50%",n.style.width="50%";const o=i.h1("Monomers","polytool-grid-header");i.tooltip.bind(o,"Click different cobination to see how monomers will link"),this.linkCards=await this.rules.getLinkCards();const r=i.splitV([i.box(o,{style:{maxHeight:"30px"}}),this.linkCards[0].root]);this.linkCards[0].render(),await this.linkCards[0].reset(),this.linkRuleDataFrame.currentRowIdx=0,this.linkRuleDataFrame.onCurrentRowChanged.subscribe((async()=>{const e=this.linkRuleDataFrame.currentRowIdx;-1!==e&&null!=e&&(i.empty(r),r.append(i.splitV([i.box(o,{style:{maxHeight:"30px"}}),this.linkCards[e].root])),this.linkCards[e].render(),await this.linkCards[e].reset())}));const s=i.splitH([t,r],null,!0),a=this.synthRuleDataFrame.plot.grid({showAddNewRowIcon:!1,allowEdit:!1,rowHeight:130});a.onCellDoubleClick.subscribe((()=>{if(!a.dataFrame||-1==a.dataFrame.currentRowIdx||null==a.dataFrame.currentRowIdx)return;const e=a.dataFrame.currentRowIdx;x((e=>this.addSynthRulesFunc(e)),{rowIndex:e,code:this.synthRuleDataFrame.get("code",e),firstMonomers:this.synthRuleDataFrame.get("firstMonomers",e).split(",").map((e=>e.trim())).filter((e=>e)),secondMonomers:this.synthRuleDataFrame.get("secondMonomers",e).split(",").map((e=>e.trim())).filter((e=>e)),resultMonomerName:this.synthRuleDataFrame.get("name",e),firstReactantSmiles:this.synthRuleDataFrame.get("firstReactant",e),secondReactantSmiles:this.synthRuleDataFrame.get("secondReactant",e),productSmiles:this.synthRuleDataFrame.get("product",e)})}));const l=this.createGridDiv("Rules",a),c=await this.getReactionExamplesGrid(),u=this.createGridDiv("Examples",c);this.substituteReactionGridDataFrame=async()=>{const e=await this.getReactionExamplesGrid();c.dataFrame=e.dataFrame},l.style.width="50%",u.style.width="50%";const h=i.divH([l,u]),d=i.divV([this.homoDimerInput,this.heteroDimerInput]),p=i.tabControl({Links:s,Reactions:h,Dimers:d},!1);i.tooltip.bind(p.getPane(w).header,"Specify rules to link monomers based on HELM notation"),i.tooltip.bind(p.getPane(A).header,"Specify rules to perform reactions within monomers"),i.tooltip.bind(p.getPane("Dimers").header,"Specify symbols for homodimeric and heterodimeric codes"),p.root.style.height="100%",p.root.style.width="100%",p.root.classList.add("rules-manager-form-tab-control"),p.header.style.marginBottom="10px";const m=i.divV([p.root]),f=[i.bigButton("Save",(()=>{this.save()})),i.button("Add rule",(()=>{const e=p.currentPane.name;e==w?this.getAddNewLinkRuleDialog():e==A&&x((e=>this.addSynthRulesFunc(e)))})),i.button("Remove rule",(()=>{const t=p.currentPane.name;if(t==w){if(null==this.linkRuleDataFrame||-1==this.linkRuleDataFrame.currentRowIdx||null==this.linkRuleDataFrame.currentRowIdx)return;const t=e.dataFrame.currentRowIdx;i.dialog("Are you sure you want to remove the rule?").add(i.divText("This action is irreversible!")).onOK((()=>{this.linkRuleDataFrame.rows.removeAt(t),this.rules.setLinkRules(this.linkRuleDataFrame),this.save()})).show()}else if(t==A){if(null==this.synthRuleDataFrame||-1==this.synthRuleDataFrame.currentRowIdx||null==this.synthRuleDataFrame.currentRowIdx)return;const e=a.dataFrame.currentRowIdx;i.dialog("Are you sure you want to remove the rule?").add(i.divText("This action is irreversible!")).onOK((()=>{this.synthRuleDataFrame.rows.removeAt(e),this.rules.setSynthesisRules(this.synthRuleDataFrame),this.substituteReactionGridDataFrame?.(),this.save()})).show()}}))];return this.v.setRibbonPanels([f]),m.style.height="100%",m.style.alignItems="center",p.root}getAddNewLinkRuleDialog(e){const t=i.input.int("Code",{nullable:!1,value:e?.code}),n=i.input.string("First monomers",{placeholder:"E.g. C,D,E",value:e?.firstMonomers,tooltipText:"Comma separated list of first monomers applicable for the rule. If left empty, all monomers will be considered",nullable:!0}),o=i.input.string("Second monomers",{placeholder:"E.g. C,D,E",value:e?.secondMonomers,tooltipText:"Comma separated list of second monomers applicable for the rule. If left empty, all monomers will be considered",nullable:!0}),r=e?.firstLinkingGroup?`R${e.firstLinkingGroup}`:"R3",s=e?.secondLinkingGroup?`R${e.secondLinkingGroup}`:"R3",a=i.input.choice("First linking group",{value:r,items:["R1","R2","R3","R4"],tooltipText:"Specifies which R-group of the first monomer will be used for linking",nullable:!1}),l=i.input.choice("Second linking group",{value:s,items:["R1","R2","R3","R4"],tooltipText:"Specifies which R-group of the second monomer will be used for linking",nullable:!1});i.dialog("Add new link rule").add(t).add(n).add(o).add(a).add(l).onOK((async()=>{const r=t.value,i=(n.value??"").split(",").map((e=>e.trim())).filter((e=>e)).join(","),s=(o.value??"").split(",").map((e=>e.trim())).filter((e=>e)).join(","),c=parseInt(a.value.substring(1)),u=parseInt(l.value.substring(1));this.addLinkRulesFunc({code:r,firstMonomers:i??"",secondMonomers:s??"",firstLinkingGroup:c,secondLinkingGroup:u,row:e?.row}),this.rules.setLinkRules(this.linkRuleDataFrame),this.linkCards=await this.rules.getLinkCards(),this.save()})).show()}}T.instances={};var E=n(5072),S=n.n(E),N=n(7825),I=n.n(N),M=n(7659),P=n.n(M),_=n(5056),L=n.n(_),O=n(540),R=n.n(O),$=n(1113),D=n.n($),B=n(890),F={};F.styleTagTransform=D(),F.setAttributes=L(),F.insert=P().bind(null,"head"),F.domAPI=I(),F.insertStyleElement=R(),S()(B.A,F),B.A&&B.A.locals&&B.A.locals;var k=n(2003);class H{get selected(){return this._selected}set selected(e){this._selected=e,this.root.style.border=e?"2px solid var(--green-2)":"2px solid var(--grey-2)"}constructor(e,t){this.monomer=e,this.monomerSymbol=t,this.root=i.divV([],{classes:"monomer-card-rule-root"}),this._selected=!1}render(){if(i.empty(this.root),this.root.appendChild(i.h2(this.monomerSymbol,{style:{textAlign:"center"}})),this.monomer){const e=this.monomer.smiles&&r.chem.checkSmiles(this.monomer.smiles)?r.chem.drawMolecule(this.monomer.smiles,150,120):r.chem.drawMolecule(this.monomer.molfile??"",150,120);this.root.appendChild(e);const t=i.divH([i.divText("Monomer Name: "),i.divText(this.monomer.name)],{classes:"monomer-card-info-rules"});if(this.root.appendChild(t),i.tooltip.bind(t,this.monomer.name),this.monomer.lib?.source){const e=i.divH([i.divText("Source: "),i.divText(this.monomer.lib.source)],{classes:"monomer-card-info-rules"});this.root.appendChild(e),i.tooltip.bind(e,this.monomer.lib.source)}const n=i.divH([i.divText("Polymer Type: "),i.divText(this.monomer.polymerType)],{classes:"monomer-card-info-rules"});this.root.appendChild(n),i.tooltip.bind(n,this.monomer.polymerType),i.tooltip.bind(this.root,"Select Monomer")}else this.root.appendChild(i.divV([`Monomer ${this.monomerSymbol} not found in libraries`],{style:{textAlign:"center",height:"100%"}}))}}class G{constructor(e,t,n,o,r){this.firstMonomers=e,this.secondMonomers=t,this.code=o,this.rules=r,this.root=i.divH([],{style:{width:"100%",overflow:"hidden",visibility:"visible"},classes:"monomer-cards"});const s=!e?.length,a=!t?.length;s&&(this.firstMonomers=e=["C","D","E","F","G"]),a&&(this.secondMonomers=t=["D","C","E","F","G"]),this.actionable=!0;const l=i.divH([],{style:{overflowX:"auto",width:"100%"}}),c=i.divH([],{style:{overflowX:"auto",width:"100%"}});this.resulting=i.divH([],{style:{overflowX:"auto",width:"100%",minHeight:"150px"}});const u=i.h2("First Monomer"+(s?" (Applied to all monomers, example list shown)":""),{style:{width:"100%"}}),h=i.h2("Second Monomer"+(a?" (Applied to all monomers, example list shown)":""),{style:{width:"100%"}}),d=i.divV([u,l,h,c,this.resulting]);this.cardsFirst=e.map((e=>new H(n.getMonomer("PEPTIDE",e),e))),this.cardsSecond=t.map((e=>new H(n.getMonomer("PEPTIDE",e),e))),this.cardsFirst.forEach((e=>{e.root.onclick=()=>{this.cardsFirst.forEach((e=>e.selected=!1)),e.selected=!0,this.firstCard=e,this.reset()},l.appendChild(e.root)})),this.cardsSecond.forEach((e=>{e.root.onclick=()=>{this.cardsSecond.forEach((e=>e.selected=!1)),e.selected=!0,this.secondCard=e,this.reset()},c.appendChild(e.root)})),this.cardsFirst[0].selected=!0,this.cardsSecond[0].selected=!0,this.firstCard=this.cardsFirst[0],this.secondCard=this.cardsSecond[0],this.root.appendChild(d)}async reset(){if(this.actionable){const e=[`${this.firstCard.monomer?.symbol}(${this.code})-A-A-A-A-${this.secondCard.monomer?.symbol}(${this.code})`],t=await(0,h.b2)(),[n,s,a]=(0,d.b)(e,this.rules,t),l=o.Column.fromType(o.COLUMN_TYPE.STRING,"helm",n.length).init((e=>n[e]));l.semType=o.SEMTYPE.MACROMOLECULE,l.meta.units=k.Hi.HELM,l.setTag(o.TAGS.CELL_RENDERER,"helm");const c=await(0,g.j)(),u=await(0,y.Q)(),p=await(0,m.A)(this.rules),b=l.temp;l.temp=b;const v=(await(0,f.m)(l,n,s,!0,!1,!1,p,c,u)).get(0),C=v&&r.chem.checkSmiles(v)?r.chem.drawMolecule(v,200,200):r.chem.drawMolecule(v??"",200,200);v&&(C.style.cursor="pointer",C.onclick=()=>{const e=window.innerWidth-200,t=window.innerHeight-200,n=r.chem.checkSmiles(v)?r.chem.drawMolecule(v,e,t):r.chem.drawMolecule(v??"",e,t);i.dialog({title:"Molecule"}).add(n).showModal(!0)},i.tooltip.bind(C,"Click to expand"));const x=i.divV([i.h2("Example Result:"),i.h2(e[0])],{style:{width:"200px"}});i.empty(this.resulting),this.resulting.append(i.divH([x,C],{style:{overflowX:"auto",width:"100%",minHeight:"150px"}}))}}render(){this.actionable&&(this.cardsFirst.forEach((e=>e.render())),this.cardsSecond.forEach((e=>e.render())))}}var U=n(4971);const V="System:AppData/SequenceTranslator/polytool-rules/",j="Polytool",q="code",W="firstMonomers",z="secondMonomers",Y="name",K="firstLinkingGroup",Q="secondLinkingGroup";class J extends c{constructor(e,t,n,o){super(e,t,n,o)}createInput(e,t){const n=super.createInput(e,t),r=i.icons.edit((async()=>{const t=await T.getInstance(e);o.Dialog.getOpenDialogs()?.filter((e=>e.root.contains(r))).forEach((e=>e.close())),await t.getAndAddView()}),"Edit rules");return n.addOptions(r),n}async getForm(){const e=await super.getForm();return this.processRulesForm(e),e}async processRulesForm(e){const t=Array.from(e.getElementsByTagName("label")??[]).filter((e=>e.textContent?.endsWith(".json")&&null!=e.parentElement));for(const e of t){const t=e.textContent.trim(),n=e.parentElement.getElementsByTagName("input")[0];i.tooltip.bind(n,i.wait((async()=>{var e;return(e=J.ruleDescriptions)[t]??(e[t]=(async()=>{try{const e=JSON.parse(await r.dapi.files.readAsText(`${V}/${t}`)),n=i.divV([i.h1(t)]),o=e.linkRules??[];if(o.length>0){n.appendChild(i.h3("Linkage Rules"));const e=i.table(o,(e=>[e.code?.toString()??"",X((e.firstMonomers??[]).join(", ")),X((e.secondMonomers??[]).join(", ")),e.firstLinkingGroup?.toString()??"",e.secondLinkingGroup?.toString()??""]),["Code","M1","M2","L1","L2"]);n.appendChild(e)}const s=e.reactionRules??[];if(s.length>0){n.appendChild(i.h3("Synthesis Rules"));const e=i.table(s,(e=>[e.code?.toString()??"",X((e.firstMonomers??[]).join(", ")),X((e.secondMonomers??[]).join(", ")),X(e.name??""),r.chem.drawMolecule(e.reaction?.split(">>")[1]??"",70,70)]),["Code","M1","M2","Name","Product"]);n.appendChild(e)}return n}catch(e){return u._package.logger.error(`Failed to load rule ${t}: ${e?.toString?.()}`),console.error(e),i.divText(`Failed to load rule ${t}`)}})()),await J.ruleDescriptions[t]})))}}}function X(e,t=30){return e.length<=t?e:`${e.substring(0,t)}...`}J.ruleDescriptions={};class Z{constructor(e,t,n,o){this.homodimerCode=e,this.heterodimerCode=t,this.linkRules=n,this.reactionRules=o}set homodimer(e){this.homodimerCode=e}set heterodimer(e){this.heterodimerCode=e}addLinkRules(e){for(let t=0;t<e.length;t++)this.linkRules.push(e[t])}addSynthesisRules(e){for(let t=0;t<e.length;t++)this.reactionRules.push(e[t])}getLinkRulesDf(){const e=this.linkRules.length,t=o.Column.int(q,e);t.setTag("friendlyName","Code");const n=o.Column.string(W,e);n.temp[".mm.cellRenderer.fontSize"]=16,n.setTag("friendlyName","First monomers"),n.semType=o.SEMTYPE.MACROMOLECULE,u.PackageFunctions.applyNotationProviderForCyclized(n,",");const r=o.Column.string(z,e);r.setTag("friendlyName","Second monomers"),r.temp[".mm.cellRenderer.fontSize"]=16,r.semType=o.SEMTYPE.MACROMOLECULE,u.PackageFunctions.applyNotationProviderForCyclized(r,",");const i=o.Column.int(K,e);i.setTag("friendlyName","First group");const s=o.Column.int(Q,e);s.setTag("friendlyName","Second group");for(let o=0;o<e;o++)t.set(o,this.linkRules[o].code),n.set(o,this.linkRules[o].firstMonomers.toString()),r.set(o,this.linkRules[o].secondMonomers.toString()),i.set(o,this.linkRules[o].firstLinkingGroup),s.set(o,this.linkRules[o].secondLinkingGroup);const a=o.DataFrame.fromColumns([t,n,r,i,s]);return{res:a,addNewRow:e=>{if(null!=e.row&&e.row<a.rowCount&&e.row>=0)t.set(e.row,e.code),n.set(e.row,e.firstMonomers),r.set(e.row,e.secondMonomers),i.set(e.row,e.firstLinkingGroup),s.set(e.row,e.secondLinkingGroup);else{const{code:t,firstMonomers:n,secondMonomers:o,firstLinkingGroup:r,secondLinkingGroup:i}=e;a.rows.addNew([t,n??"",o??"",r??1,i??2])}}}}async getLinkCards(){const e=this.linkRules.length,t=new Array(e),n=(await(0,U.pj)()).getMonomerLib();for(let o=0;o<e;o++)t[o]=new G(this.linkRules[o].firstMonomers,this.linkRules[o].secondMonomers,n,this.linkRules[o].code,this);return t}getSynthesisRulesDf(){const e=this.reactionRules.length,t=o.Column.int(q,e);t.setTag("friendlyName","Code");const n=o.Column.string(W,e);n.setTag("friendlyName","First monomers");const r=o.Column.string(z,e);r.setTag("friendlyName","Second monomers"),n.semType=o.SEMTYPE.MACROMOLECULE,n.temp[".mm.cellRenderer.fontSize"]=16,u.PackageFunctions.applyNotationProviderForCyclized(n,","),r.semType=o.SEMTYPE.MACROMOLECULE,r.temp[".mm.cellRenderer.fontSize"]=16,u.PackageFunctions.applyNotationProviderForCyclized(r,","),r.setTag(o.TAGS.CELL_RENDERER,"Sequence"),n.setTag(o.TAGS.CELL_RENDERER,"Sequence");const i=o.Column.string(Y,e);i.setTag("friendlyName","Name");const s=o.Column.string("firstReactant",e);s.setTag("friendlyName","First reactant");const a=o.Column.string("secondReactant",e);a.setTag("friendlyName","Second reactant");const l=o.Column.string("product",e);l.setTag("friendlyName","Product");for(let o=0;o<e;o++){t.set(o,this.reactionRules[o].code),n.set(o,this.reactionRules[o].firstMonomers.toString()),r.set(o,this.reactionRules[o].secondMonomers.toString()),i.set(o,this.reactionRules[o].name);const e=this.reactionRules[o].reaction.split(">>"),c=e[0].split(".");s.set(o,c[0]),a.set(o,c[1]),l.set(o,e[1])}s.semType=o.SEMTYPE.MOLECULE,a.semType=o.SEMTYPE.MOLECULE,l.semType=o.SEMTYPE.MOLECULE;const c=o.DataFrame.fromColumns([i,s,a,l,t,n,r]);return{df:c,addNewRow:e=>{if(null!=e.rowIndex&&e.rowIndex<c.rowCount&&e.rowIndex>=0)i.set(e.rowIndex,e.resultMonomerName),t.set(e.rowIndex,e.code),n.set(e.rowIndex,e.firstMonomers.join(",")),r.set(e.rowIndex,e.secondMonomers.join(",")),s.set(e.rowIndex,e.firstReactantSmiles),a.set(e.rowIndex,e.secondReactantSmiles),l.set(e.rowIndex,e.productSmiles);else{const{resultMonomerName:t,code:n,firstMonomers:o,secondMonomers:r,firstReactantSmiles:i,secondReactantSmiles:s,productSmiles:a}=e;c.rows.addNew([t,i,s,a,n,o.join(","),r.join(",")])}}}}setLinkRules(e){const t=e.rowCount,n=new Array(t),o=e.columns.byName(q),r=e.columns.byName(W),i=e.columns.byName(z),s=e.columns.byName(K),a=e.columns.byName(Q);for(let e=0;e<t;e++){const t=r.get(e).split(","),l=i.get(e).split(","),c={code:o.get(e),firstMonomers:""!==t[0]?t:[],secondMonomers:""!==l[0]?l:[],firstLinkingGroup:s.get(e),secondLinkingGroup:a.get(e)};n[e]=c}this.linkRules=n}setSynthesisRules(e){const t=e.rowCount,n=new Array(t),o=e.columns.byName(q),r=e.columns.byName(W),i=e.columns.byName(z),s=e.columns.byName(Y),a=e.columns.byName("firstReactant"),l=e.columns.byName("secondReactant"),c=e.columns.byName("product");for(let e=0;e<t;e++){const t=`${a.get(e)}.${l.get(e)}>>${c.get(e)}`,u=r.get(e).split(","),h=i.get(e).split(","),d={code:o.get(e),firstMonomers:""!==u[0]?u:[],secondMonomers:""!==h[0]?h:[],reaction:t,name:s.get(e)};n[e]=d}this.reactionRules=n}}async function ee(e){const t=new o.FileSource(V),n=new Z(null,null,[],[]);for(let o=0;o<e.length;o++){const r=await t.readAsText(e[o].replace(V,"")),i=JSON.parse(r);n.homodimer=i.homodimerCode,n.heterodimer=i.heterodimerCode,n.addLinkRules(i.linkRules),n.addSynthesisRules(i.reactionRules)}return n}function te(e){const t=e.firstMonomers.length*e.secondMonomers.length,n=new Array(t),o=new Array(t);let r=0;for(let t=0;t<e.firstMonomers.length;t++)for(let i=0;i<e.secondMonomers.length;i++)n[r]=e.firstMonomers[t],o[r]=e.secondMonomers[i],r++;return[n,o]}},5174:(e,t,n)=>{"use strict";n.d(t,{A:()=>u,T:()=>h});var o=n(6717),r=n(1296),i=n(9192),s=n(4328),a=n(1991),l=n.n(a),c=n(4971);async function u(e){const t=(await(0,c.pj)()).getMonomerLib(),n=await(0,o.j)(),r={};let i=[],a=[];for(let o=0;o<e.reactionRules.length;o++)try{[i,a]=h(n,t,e.reactionRules[o])}catch(e){i=[],a=[],console.error(e),s.shell.warning(e)}finally{for(let e=0;e<i.length;e++)null!=i[e]&&null!=a[e]&&(r[i[e]]=a[e])}const u={PEPTIDE:r};return t.override(u,"ST-PT-reactions."+l().repeat(1).map((()=>Math.floor(36*Math.random()).toString(36))).take(4).toArray().join(""))}function h(e,t,n){const o=n.reaction,r=n.name,s=n.firstMonomers.length+n.secondMonomers.length+1,a=n.reaction.split(">>"),l=a[0].split("."),c=new Array(s),u=new Array(s),h=new Array(s),f=p(e,o),g=`${l[0]}>>[C:1]C`,y=`${l[1]}>>[C:2]C`,b=p(e,g),v=p(e,y);let C=0;for(let o=0;o<n.firstMonomers.length;o++){const i=t.getMonomer("PEPTIDE",n.firstMonomers[o]);if(i&&i.molfile)try{const t=d(e,i.molfile,b,i.name);h[C]=t,c[C]=`${i.symbol}_${r}`}catch(e){console.error(e)}C++}for(let o=0;o<n.secondMonomers.length;o++){const i=t.getMonomer("PEPTIDE",n.secondMonomers[o]);if(i&&i.molfile)try{const t=d(e,i.molfile,v,i.name);h[C]=t,c[C]=`${i.symbol}_${r}`}catch(e){console.error(e)}C++}let x=null;a[1]=a[1].replace("[C:1]","[1*]").replace("[C:2]","[2*]").replace("[C:3]","[3*]");let w="";try{x=e.get_mol(a[1]),w=x?.get_molblock()}catch(e){const[t,n]=(0,i.AP)(e);throw console.error(`Can not assemble monomer '${r}': ${t}.`),e}finally{x?.delete()}h[C]=w,c[C]=r;for(let e=0;e<s-1;e++)h[e]&&(h[e]=h[e].replace(" 0.0000 0.0000 0.0000 C "," 0.0000 0.0000 0.0000 R# ").replace("M RGP 2","M RGP 3 2 3"));h[s-1]=function(e){const t=e.replace("M RAD","M RGP").replace("M ISO","M RGP").split("\n"),n=t.findIndex((e=>e.startsWith("M RGP"))),o=Number(t[n].substring(9,13)),r=Number(t[n].substring(17,21)),i=Number(t[n].substring(13,17)),s=Number(t[n].substring(21,25));t[n]=t[n].substring(0,13)+` ${i}`+t[n].substring(17,21)+` ${s}`,t[3+o]=t[3+o].substring(0,30)+" R# 0 0 0 0 0 0 0 0 0 0 0 0",t[3+r]=t[3+r].substring(0,30)+" R# 0 0 0 0 0 0 0 0 0 0 0 0";let a="";for(let e=0;e<t.length;e++)a+=t[e]+"\n";return a}(h[s-1]);for(let e=0;e<s;e++){const t=e==s-1;if(!h[e]||!c[e])continue;const n={symbol:c[e],name:c[e],molfile:h[e],author:"",id:0,rgroups:m(t),smiles:"",polymerType:"PEPTIDE",monomerType:"Backbone",createDate:null};n.meta=Object.assign(n.meta??{},{colors:{default:{line:"#2083D5",text:"#2083D5",background:"#F2F2F5"}}}),c[e]=c[e],u[e]=n}return f.delete(),b.delete(),v.delete(),[c,u]}function d(e,t,n,o){let r=null,s=null,a=null,l=null,c="";try{r=new e.MolList,s=e.get_mol(t),r.append(s),a=n.run_reactants(r,1),l=a.get(0).next(),c=l?.get_molblock()}catch(e){const[t,n]=(0,i.AP)(e);throw console.error(`Can not assemble monomer '${o}': ${t}.`),e}finally{r?.delete(),s?.delete(),a?.delete(),l?.delete()}return c}function p(e,t){let n=null;try{if(n=e.get_rxn(t),!n)throw new r.J5(t)}catch(e){n?.delete();const[o,r]=(0,i.AP)(e);throw console.error(`Can not assemble monomer '${t}': ${o}.`),e}return n}function m(e){if(e){const e=new Array(2),t={capGroupSMILES:"[*:1][H]",alternateId:"R1-H",capGroupName:"H",label:"R1"},n={capGroupSMILES:"[*:2][H]",alternateId:"R2-H",capGroupName:"H",label:"R2"};return e[0]=t,e[1]=n,e}return[{capGroupSMILES:"[*:3][H]",alternateId:"R3-H",capGroupName:"H",label:"R3"}]}},3309:(e,t,n)=>{"use strict";n.d(t,{BG:()=>b,HL:()=>T,Ii:()=>x,KS:()=>h,PI:()=>r,Qk:()=>c,XB:()=>f,ah:()=>d,aj:()=>u,j7:()=>l,jp:()=>E,k5:()=>m,u8:()=>o,xD:()=>S,yw:()=>C,z9:()=>v});const o=1e6,r={Zip:"Zip",Cartesian:"Cartesian"},i=String.raw`\[(?:(\d+)\*|\*:(\d+)|\*(\d+)|R(\d+)|R:(\d+))\]`;function s(){return new RegExp(i,"g")}function a(e){for(const t of e)if(void 0!==t)return parseInt(t,10);return null}function l(e){return e.replace(s(),((e,t,n,o,r,i)=>{const s=a([t,n,o,r,i]);return null===s?e:`[*:${s}]`}))}function c(e){const t=new Set;for(const n of e.matchAll(s())){const e=a([n[1],n[2],n[3],n[4],n[5]]);null!==e&&t.add(e)}return[...t].sort(((e,t)=>e-t))}function u(e,t){return e.replace(s(),(()=>`[*:${t}]`))}function h(e,t,n){const o=(e??"").trim();if(""===o)return{smiles:"",originalSmiles:e,rNumbers:[],id:t,error:"Empty SMILES"};const r=l(o),i=c(r);if(0===i.length)return{smiles:r,originalSmiles:e,rNumbers:i,id:t,error:"Core must contain at least one R group"};if(n){const o=p(r,n);if(o)return{smiles:r,originalSmiles:e,rNumbers:i,id:t,error:`Invalid SMILES: ${o}`}}return{smiles:r,originalSmiles:e,rNumbers:i,id:t}}function d(e,t,n,o){const r=(e??"").trim();if(""===r)return{smiles:"",originalSmiles:e,rNumber:t,id:n,error:"Empty SMILES"};const i=l(r),s=c(i);if(0===s.length){if(o){const r=function(e,t){let n=null;try{if(n=t.get_mol(e),!n||!n.is_valid())return null;if(1!==n.get_num_atoms(!0))return null;n.remove_hs_in_place();const o=n.get_smiles();return o&&o.length>0?o:null}catch{return null}finally{n?.delete()}}(i,o);if(r)return{smiles:r,originalSmiles:e,rNumber:t,id:n,isSingleAtom:!0}}return{smiles:i,originalSmiles:e,rNumber:t,id:n,error:"R-group must contain exactly one R label, or be a single atom (e.g. N, O, Cl)"}}if(s.length>1)return{smiles:i,originalSmiles:e,rNumber:t,id:n,sourceRNumber:s[0],error:`R-group must contain exactly one R label (found ${s.length}: ${s.map((e=>"R"+e)).join(", ")})`};const a=s[0],h=u(i,t);if(o){const r=p(h,o);if(r)return{smiles:h,originalSmiles:e,rNumber:t,id:n,sourceRNumber:a,error:`Invalid SMILES: ${r}`}}return{smiles:h,originalSmiles:e,rNumber:t,id:n,sourceRNumber:a}}function p(e,t){let n=null;try{return n=t.get_mol(e),n&&n.is_valid()?null:"failed to parse"}catch(e){return(e?.message??String(e)).toString().slice(0,120)}finally{n?.delete()}}function m(e,t,n){const o=[],i=[];for(const n of e.rNumbers){const e=t.get(n);e&&0!==e.length?i.push(e.filter((e=>!e.error)).length):o.push(n)}if(o.length>0)return{count:0,uncovered:o};if(i.some((e=>0===e)))return{count:0,uncovered:o};if(n===r.Zip){if(0===i.length)return{count:0,uncovered:o};const e=i[0];return{count:i.every((t=>t===e))?e:-1,uncovered:o}}return{count:i.reduce(((e,t)=>e*t),1),uncovered:o}}function f(e){const t=e.maxResults??o,n=[];let i=0;const s=e.cores.filter((e=>!e.error));0===s.length&&n.push("No valid cores provided.");const a=new Set;for(const e of s)for(const t of e.rNumbers)a.add(t);const l=new Map;for(const t of a){const o=(e.rGroups.get(t)??[]).filter((e=>!e.error)).length;l.set(t,o),0===o&&n.push(`No valid R-group provided for R${t}.`)}if(e.mode===r.Zip){const e=[...l.values()].filter((e=>e>0));e.length>1&&!e.every((t=>t===e[0]))&&n.push(`Zip mode requires every R-group list to have the same number of entries. Got ${[...l.entries()].map((([e,t])=>`R${e}=${t}`)).join(", ")}.`)}for(const o of s){const{count:r,uncovered:s}=m(o,e.rGroups,e.mode);if(s.length>0)n.push(`Core "${o.id}" references uncovered R-number${s.length>1?"s":""}: ${s.map((e=>"R"+e)).join(", ")}.`);else if(!(r<0)&&(i+=r,i>t))break}const c=i>t;return c&&n.push(`Too many combinations (> ${t.toLocaleString()}). Reduce the number of cores or R-groups, or switch to Zip mode.`),{ok:0===n.length,errors:n,predictedCount:i,overCap:c}}function g(e,t){if(0===t.size)return null;const n=new Map,o=new Map;for(const[e,r]of t)c(r).includes(e)?o.set(e,r):n.set(e,r);let r=e;for(const[e,t]of n)r=y(r,e,t);if(0===o.size)return r;const i=v(r),s=new Map;for(const[e,t]of o)s.set(e,v(t));const a=x([i,...s.values()],o.size);if(a.length<o.size)return null;const l=new Map;let u=0;for(const e of o.keys())l.set(e,w(a[u++]));let h=i;for(const[e,t]of l)h=C(h,e,t);const d=[];for(const[e,t]of s)d.push(C(t,e,l.get(e)));return[h,...d].join(".")}function y(e,t,n){return e.split(`[*:${t}]`).join(n)}function b(e,t,n){const o=g(e,t);if(!o)return null;let r=null;try{return r=n.get_mol(o),r&&r.is_valid()?r.get_smiles():null}catch{return null}finally{r?.delete()}}function v(e){const t=e.match(/^(\[\*:\d+\])([-=#:/\\])?(\[[^\]]+\]|Br|Cl|[BCNOPSFIbcnops])(.*)$/s);if(!t)return e;const[,n,o,r,i]=t;return`${r}(${o??""}${n})${i}`}function C(e,t,n){const o=`[*:${t}]`,r=new RegExp(`\\(\\s*\\[\\*:${t}\\]\\s*\\)`,"g");return(e=e.replace(r,n)).split(o).join(n)}function x(e,t){const n=new Set;for(const t of e){const e=t.replace(/\[[^\]]*\]/g,"");for(const t of e.matchAll(/%(\d{2})/g))n.add(parseInt(t[1],10));for(const t of e){const e=t.charCodeAt(0)-48;e>=0&&e<=9&&n.add(e)}}const o=[];for(let e=1;e<100&&o.length<t;e++)n.has(e)||o.push(e);return o}function w(e){if(e<0||e>99)throw new Error(`Ring digit out of range: ${e}`);return e<=9?`${e}`:`%${e.toString().padStart(2,"0")}`}function*A(e){const t=e.maxResults??o;let n=0;for(const o of e.cores){if(o.error)continue;const i=o.rNumbers,s=[];let a=!1;for(const t of i){const n=(e.rGroups.get(t)??[]).filter((e=>!e.error));if(0===n.length){a=!0;break}s.push(n)}if(!a)if(e.mode===r.Zip){if(0===s.length)continue;const e=s[0].length;if(!s.every((t=>t.length===e)))continue;for(let r=0;r<e;r++){const e=new Map;for(let t=0;t<i.length;t++)e.set(i[t],s[t][r]);if(yield{core:o,assignment:e},++n>=t)return}}else{const e=new Array(s.length).fill(0);for(;;){const r=new Map;for(let t=0;t<i.length;t++)r.set(i[t],s[t][e[t]]);if(yield{core:o,assignment:r},++n>=t)return;let a=e.length-1;for(;a>=0&&(e[a]++,!(e[a]<s[a].length));)e[a]=0,a--;if(a<0)break}}}}function T(e,t){if(!f(e).ok)return null;const n=[];for(const{core:o,assignment:r}of A(e)){const e=new Map;for(const[t,n]of r)e.set(t,n.smiles);const i=b(o.smiles,e,t);if(!i)continue;const s=new Map;for(const[e,t]of r)s.set(e,t.originalSmiles);n.push({smiles:i,coreSmiles:o.originalSmiles,rGroupSmilesByNum:s})}return n}function E(e){if(!f(e).ok)return null;const t=[];for(const{core:n,assignment:o}of A(e)){const e=new Map;for(const[t,n]of o)e.set(t,n.smiles);const r=g(n.smiles,e);if(!r)continue;const i=new Map;for(const[e,t]of o)i.set(e,t.originalSmiles);t.push({smiles:r,coreSmiles:n.originalSmiles,rGroupSmilesByNum:i})}return t}function S(e,t,n=Math.random){const o=[];let r=0;for(const{core:i,assignment:s}of A(e)){const e=new Map;for(const[t,n]of s)e.set(t,n.smiles);const a=g(i.smiles,e);if(!a)continue;const l=new Map;for(const[e,t]of s)l.set(e,t.originalSmiles);const c={smiles:a,coreSmiles:i.originalSmiles,rGroupSmilesByNum:l};if(o.length<t)o.push(c);else{const e=Math.floor(n()*(r+1));e<t&&(o[e]=c)}r++}return o}},3820:(e,t,n)=>{"use strict";n.d(t,{d:()=>r,o:()=>s});var o=n(1296);const r="PEPTIDE1{R.[Aca].T.G.H.F.G.A.A.Y.P.E.[meI]}$$$$";function i(e,t,n,o){const r=new Array(o.length*(n-t+1));for(let i=0;i<o.length;++i){const s=n-t+1;for(let n=0;n<s;++n){const a=t+n,l=o[i],c=r[i*s+n]=e.clone(),u=c.atoms[a].elem;c.atoms[a].elem=l;const h=u?.length>1?`[${u}]`:u,d=l?.length>1?`[${l}]`:l;c.name=`${e.name}-${h}${a+1}${d}`}}return r}function s(e,t,n){const r=new JSDraw2.MolHandler,s=new org.helm.webeditor.Plugin(r);org.helm.webeditor.IO.parseHelm(s,e,new JSDraw2.Point(0,0),void 0);const a=r.m;a.name=t;let l=[];if(n.placeholders)switch(n.type){case o.aK.Single:l=function(e,t){return t.map((t=>i(e,t.position,t.position,t.monomers))).reduce(((e,t)=>e.concat(t)),[])}(r.m,n.placeholders);break;case o.aK.Parallel:l=function(e,t){if(0===t.length)return[];const n=t[0].monomers.length;for(const e of t)if(e.monomers.length!==n)throw new Error("Parallel enumeration requires all positions to have the same number of monomers");const o=new Array(n);for(let r=0;r<n;r++){const n=e.clone(),i=[];for(const e of t){const t=e.position,o=e.monomers[r],s=n.atoms[t].elem;n.atoms[t].elem=o;const a=s?.length>1?`[${s}]`:s,l=o?.length>1?`[${o}]`:o;i.push(`${a}${t+1}${l}`)}n.name=`${e.name}-${i.join("-")}`,o[r]=n}return o}(r.m,n.placeholders);break;case o.aK.Matrix:l=function(e,t){let n=[e];for(const e of t){const t=n.map((t=>i(t,e.position,e.position,e.monomers)));n=t.reduce(((e,t)=>e.concat(t)),[])}return n}(r.m,n.placeholders)}let c=[];n.breadthPlaceholders&&(c=function(e,t){if(0==t.length)return[];let n=[e];for(const e of t){const t=n.map((t=>i(t,e.start,e.end,e.monomers)));n=t.reduce(((e,t)=>e.concat(t)),[])}return n}(r.m,n.breadthPlaceholders)),l=l.concat(c),n.keepOriginal&&(l=[a,...l]);const u=l.map((e=>[org.helm.webeditor.IO.getHelm(e),e.name]));return u}},1296:(e,t,n)=>{"use strict";var o;n.d(t,{J5:()=>r,aK:()=>o}),function(e){e.Single="single",e.Parallel="parallel",e.Matrix="matrix"}(o||(o={})),Error;class r extends Error{constructor(e,t){super(`Invalid reaction '${e}'.`),this.type="InvalidReactionError"}}},1757:e=>{"use strict";e.exports=$},6082:e=>{"use strict";e.exports=DG},4328:e=>{"use strict";e.exports=grok},7389:e=>{"use strict";e.exports=ui},1991:e=>{"use strict";e.exports=wu}},t={};function n(o){var r=t[o];if(void 0!==r)return r.exports;var i=t[o]={id:o,loaded:!1,exports:{}};return e[o].call(i.exports,i,i.exports,n),i.loaded=!0,i.exports}n.m=e,n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var o in t)n.o(t,o)&&!n.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},n.u=e=>e+".js",n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),(()=>{var e;n.g.importScripts&&(e=n.g.location+"");var t=n.g.document;if(!e&&t&&(t.currentScript&&"SCRIPT"===t.currentScript.tagName.toUpperCase()&&(e=t.currentScript.src),!e)){var o=t.getElementsByTagName("script");if(o.length)for(var r=o.length-1;r>-1&&(!e||!/^http(s?):/.test(e));)e=o[r--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),n.p=e})(),n.b=document.baseURI||self.location.href,n.nc=void 0;var o={};(()=>{"use strict";n.r(o),n.d(o,{_package:()=>Ie,initAutoTests:()=>Pe,test:()=>Me,tests:()=>h});var e=n(6082);n(9982);const t=DG.DataFrame.fromCsv('countries,fasta,smiles,molregno,LON,Zip Code,Street Address Line 1,ImageUrl,user_id,error_message,xray,flag,magnitude,CS-id,pdb_id,accel_a,time_offset,chart,fit,Questions,empty_number,empty_string\nBelgium,MSNFHNEHVMQFYRNNLKTKGVFGRQ,CC(C(=O)OCCCc1cccnc1)c2cccc(c2)C(=O)c3ccccc3,1480014,36.276729583740234,995042300,14016 ROUTE 31W,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,1,1,1QBS,1,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[2.497360340644872, 1.7058694986686864, 5.278052678195135, 0.16000320889028383],""points"":[{""x"":0.10000000149011612,""y"":2.374499797821045},{""x"":0.6000000238418579,""y"":2.6242473125457764},{""x"":1.100000023841858,""y"":2.367267608642578},{""x"":1.600000023841858,""y"":2.6723148822784424},{""x"":2.0999999046325684,""y"":2.6537344455718994},{""x"":2.5999999046325684,""y"":2.3651671409606934},{""x"":3.0999999046325684,""y"":2.5654284954071045},{""x"":3.5999999046325684,""y"":2.4160959720611572},{""x"":4.099999904632568,""y"":2.286726713180542},{""x"":4.599999904632568,""y"":2.5100042819976807},{""x"":5.099999904632568,""y"":1.6676985025405884},{""x"":5.599999904632568,""y"":0.680136501789093},{""x"":6.099999904632568,""y"":0.3391543924808502},{""x"":6.599999904632568,""y"":0.09038983285427094},{""x"":7.099999904632568,""y"":0.19802775979042053}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[7.525235855508179, 1.3186911876809984, 5.335672608564294, 0.7860743343958098],""points"":[{""x"":0.10000000149011612,""y"":7.988070487976074},{""x"":0.6000000238418579,""y"":7.018453121185303},{""x"":1.100000023841858,""y"":8.115279197692871},{""x"":1.600000023841858,""y"":7.486658096313477},{""x"":2.0999999046325684,""y"":7.396438121795654},{""x"":2.5999999046325684,""y"":7.477052211761475},{""x"":3.0999999046325684,""y"":6.913095474243164},{""x"":3.5999999046325684,""y"":8.01385498046875},{""x"":4.099999904632568,""y"":6.985900402069092},{""x"":4.599999904632568,""y"":6.970335960388184},{""x"":5.099999904632568,""y"":5.448817253112793},{""x"":5.599999904632568,""y"":2.5534818172454834},{""x"":6.099999904632568,""y"":1.893947958946228},{""x"":6.599999904632568,""y"":0.6340042352676392},{""x"":7.099999904632568,""y"":0.8403874039649963}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,100,abc\nBurundi,MDYKETLLMPKTDFPMRGGLPNKEPQIQEKW,COc1ccc2cc(ccc2c1)C(C)C(=O)Oc3ccc(C)cc3OC,1480015,36.276729583740234,995073444,80 STATE HIGHWAY 310,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,2,2,1ZP8,2,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[4.431460753103398, 2.1691498799246745, 5.266445597102774, 0.7825762827017926],""points"":[{""x"":0.10000000149011612,""y"":4.751083850860596},{""x"":0.6000000238418579,""y"":4.203000068664551},{""x"":1.100000023841858,""y"":4.415858745574951},{""x"":1.600000023841858,""y"":4.68414306640625},{""x"":2.0999999046325684,""y"":4.198400974273682},{""x"":2.5999999046325684,""y"":4.179222106933594},{""x"":3.0999999046325684,""y"":4.638473987579346},{""x"":3.5999999046325684,""y"":4.708553314208984},{""x"":4.099999904632568,""y"":4.291589260101318},{""x"":4.599999904632568,""y"":4.038082599639893},{""x"":5.099999904632568,""y"":3.4349939823150635},{""x"":5.599999904632568,""y"":1.2194708585739136},{""x"":6.099999904632568,""y"":1.1920831203460693},{""x"":6.599999904632568,""y"":0.5352635979652405},{""x"":7.099999904632568,""y"":0.3346920311450958}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[2.339458017970126, -1.0734184310171178, 4.746332950550934, 0.2482416857595658],""points"":[{""x"":0.10000000149011612,""y"":0.2139337658882141},{""x"":0.6000000238418579,""y"":0.4269562065601349},{""x"":1.100000023841858,""y"":0.2441573292016983},{""x"":1.600000023841858,""y"":0.146635964512825},{""x"":2.0999999046325684,""y"":0.08818462491035461},{""x"":2.5999999046325684,""y"":0.2560656666755676},{""x"":3.0999999046325684,""y"":0.42434045672416687},{""x"":3.5999999046325684,""y"":0.37111231684684753},{""x"":4.099999904632568,""y"":0.5581737160682678},{""x"":4.599999904632568,""y"":1.183590054512024},{""x"":5.099999904632568,""y"":1.5629843473434448},{""x"":5.599999904632568,""y"":2.3211288452148438},{""x"":6.099999904632568,""y"":2.229961633682251},{""x"":6.599999904632568,""y"":2.2560226917266846},{""x"":7.099999904632568,""y"":2.2142398357391357}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCameroon,MIEVFLFGIVLGLIPITLAGLFVTAYLQYRRGDQLDL,COc1ccc2cc(ccc2c1)C(C)C(=O)OCCCc3cccnc3,1480016,36.26095962524414,995153596,30-56 WHITESTONE EXPY,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,3,3,2BDJ,3,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[4.6760652578642325, 0.9046956320756703, 5.651408971856738, 0.07738846012184185],""points"":[{""x"":0.10000000149011612,""y"":4.32425594329834},{""x"":0.6000000238418579,""y"":4.668442249298096},{""x"":1.100000023841858,""y"":4.379785060882568},{""x"":1.600000023841858,""y"":5.0345139503479},{""x"":2.0999999046325684,""y"":4.878653526306152},{""x"":2.5999999046325684,""y"":4.3451313972473145},{""x"":3.0999999046325684,""y"":4.336992263793945},{""x"":3.5999999046325684,""y"":5.037430286407471},{""x"":4.099999904632568,""y"":5.0092692375183105},{""x"":4.599999904632568,""y"":4.151902675628662},{""x"":5.099999904632568,""y"":3.4066951274871826},{""x"":5.599999904632568,""y"":2.3732759952545166},{""x"":6.099999904632568,""y"":1.673728108406067},{""x"":6.599999904632568,""y"":0.48574790358543396},{""x"":7.099999904632568,""y"":0.2783052325248718}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[2.938395863010111, -1.4658480661392117, 5.462702751996584, 0.3473139023615039],""points"":[{""x"":0.10000000149011612,""y"":0.4941710829734802},{""x"":0.6000000238418579,""y"":0.15323974192142487},{""x"":1.100000023841858,""y"":0.46373432874679565},{""x"":1.600000023841858,""y"":0.3370431363582611},{""x"":2.0999999046325684,""y"":0.5179030299186707},{""x"":2.5999999046325684,""y"":0.27899765968322754},{""x"":3.0999999046325684,""y"":0.22075064480304718},{""x"":3.5999999046325684,""y"":0.5789918899536133},{""x"":4.099999904632568,""y"":0.21169911324977875},{""x"":4.599999904632568,""y"":0.27857646346092224},{""x"":5.099999904632568,""y"":1.0906332731246948},{""x"":5.599999904632568,""y"":1.8520300388336182},{""x"":6.099999904632568,""y"":2.7177059650421143},{""x"":6.599999904632568,""y"":2.8680918216705322},{""x"":7.099999904632568,""y"":3.2413077354431152}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCanada,MMELVLKTIIGPIVVGVVLRIVDKWLNKDK,CC(C(=O)NCCS)c1cccc(c1)C(=O)c2ccccc2,1480017,36.26095962524414,99515,30-56 WHITESTONE EXPY,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,4,4,1IAN,4,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[0.8597390975430008, 1.0957625732481946, 5.260537067987958, 0.07974187998177736],""points"":[{""x"":0.10000000149011612,""y"":0.8190152645111084},{""x"":0.6000000238418579,""y"":0.8421689867973328},{""x"":1.100000023841858,""y"":0.8740922212600708},{""x"":1.600000023841858,""y"":0.8924275040626526},{""x"":2.0999999046325684,""y"":0.8249067664146423},{""x"":2.5999999046325684,""y"":0.9327669143676758},{""x"":3.0999999046325684,""y"":0.8522974252700806},{""x"":3.5999999046325684,""y"":0.8174492716789246},{""x"":4.099999904632568,""y"":0.8394647240638733},{""x"":4.599999904632568,""y"":0.7139387726783752},{""x"":5.099999904632568,""y"":0.5561167597770691},{""x"":5.599999904632568,""y"":0.3276226818561554},{""x"":6.099999904632568,""y"":0.12479474395513535},{""x"":6.599999904632568,""y"":0.13006797432899475},{""x"":7.099999904632568,""y"":0.059702079743146896}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.760930219582546, 1.6591793293833013, 4.667155929720851, 0.7858109544121652],""points"":[{""x"":0.10000000149011612,""y"":6.156993389129639},{""x"":0.6000000238418579,""y"":5.236701965332031},{""x"":1.100000023841858,""y"":6.010560512542725},{""x"":1.600000023841858,""y"":5.495512962341309},{""x"":2.0999999046325684,""y"":6.087770462036133},{""x"":2.5999999046325684,""y"":5.79986572265625},{""x"":3.0999999046325684,""y"":5.597546577453613},{""x"":3.5999999046325684,""y"":5.520902156829834},{""x"":4.099999904632568,""y"":5.360654354095459},{""x"":4.599999904632568,""y"":3.5539746284484863},{""x"":5.099999904632568,""y"":1.577236294746399},{""x"":5.599999904632568,""y"":1.0001264810562134},{""x"":6.099999904632568,""y"":0.9305797815322876},{""x"":6.599999904632568,""y"":0.6033638715744019},{""x"":7.099999904632568,""y"":0.4203685522079468}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nColombia,MDRTDEVSNHTHDKPTLTWFEEIFEEYHSPFHN,FC(F)(F)c1ccc(OC2CCNCC2)cc1,1480029,36.3309440612793,995152050,1 COURT HOUSE SQUARE,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,5,5,4UJ1,5,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[6.4995088314153655, 2.4270351004539914, 5.178659535348579, 0.625653346241577],""points"":[{""x"":0.10000000149011612,""y"":6.496231555938721},{""x"":0.6000000238418579,""y"":6.42543363571167},{""x"":1.100000023841858,""y"":7.040063858032227},{""x"":1.600000023841858,""y"":6.1115403175354},{""x"":2.0999999046325684,""y"":6.680728435516357},{""x"":2.5999999046325684,""y"":6.406774520874023},{""x"":3.0999999046325684,""y"":6.611269474029541},{""x"":3.5999999046325684,""y"":5.889094352722168},{""x"":4.099999904632568,""y"":6.75344705581665},{""x"":4.599999904632568,""y"":6.361435890197754},{""x"":5.099999904632568,""y"":4.1666975021362305},{""x"":5.599999904632568,""y"":1.172118902206421},{""x"":6.099999904632568,""y"":0.801048994064331},{""x"":6.599999904632568,""y"":0.4640021026134491},{""x"":7.099999904632568,""y"":0.0010357667924836278}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[1.4734381347446401, 1.1649805188074196, 4.82958608866421, 0.09500545496710007],""points"":[{""x"":0.10000000149011612,""y"":1.5279096364974976},{""x"":0.6000000238418579,""y"":1.3559974431991577},{""x"":1.100000023841858,""y"":1.5246378183364868},{""x"":1.600000023841858,""y"":1.5567657947540283},{""x"":2.0999999046325684,""y"":1.4114240407943726},{""x"":2.5999999046325684,""y"":1.4045010805130005},{""x"":3.0999999046325684,""y"":1.4769829511642456},{""x"":3.5999999046325684,""y"":1.4875500202178955},{""x"":4.099999904632568,""y"":1.2991987466812134},{""x"":4.599999904632568,""y"":0.922961413860321},{""x"":5.099999904632568,""y"":0.6520044803619385},{""x"":5.599999904632568,""y"":0.15350978076457977},{""x"":6.099999904632568,""y"":0.1078903079032898},{""x"":6.599999904632568,""y"":0.17276449501514435},{""x"":7.099999904632568,""y"":0.14066608250141144}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCosta Rica,MKSTKEEIQTIKTLLKDSRTAKYHKRLQIVL,CC(C)Cc1ccc(cc1)C(C)C(=O)N2CCCC2C(=O)OCCCc3ccccc3,1480018,36.3309440612793,995084218,4041 SOUTHWESTERN BLVD,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,6,6,2BPW,6,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[2.4833641843311227, -1.8945978742090062, 4.671127708092568, 0.24159861311815153],""points"":[{""x"":0.10000000149011612,""y"":0.0969524160027504},{""x"":0.6000000238418579,""y"":0.028483040630817413},{""x"":1.100000023841858,""y"":0.22087176144123077},{""x"":1.600000023841858,""y"":0.0068915546871721745},{""x"":2.0999999046325684,""y"":0.4305879771709442},{""x"":2.5999999046325684,""y"":0.44774115085601807},{""x"":3.0999999046325684,""y"":0.45346319675445557},{""x"":3.5999999046325684,""y"":0.2370593100786209},{""x"":4.099999904632568,""y"":0.4657953977584839},{""x"":4.599999904632568,""y"":1.155200719833374},{""x"":5.099999904632568,""y"":2.2294070720672607},{""x"":5.599999904632568,""y"":2.4311530590057373},{""x"":6.099999904632568,""y"":2.33846116065979},{""x"":6.599999904632568,""y"":2.608201026916504},{""x"":7.099999904632568,""y"":2.8136143684387207}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.224573521642033, 1.4454033924198528, 5.6014197746076535, 0.2823216054197577],""points"":[{""x"":0.10000000149011612,""y"":4.95027494430542},{""x"":0.6000000238418579,""y"":5.1754679679870605},{""x"":1.100000023841858,""y"":5.276752948760986},{""x"":1.600000023841858,""y"":5.589294910430908},{""x"":2.0999999046325684,""y"":5.616994857788086},{""x"":2.5999999046325684,""y"":5.120813846588135},{""x"":3.0999999046325684,""y"":5.340766906738281},{""x"":3.5999999046325684,""y"":4.876471042633057},{""x"":4.099999904632568,""y"":4.94999361038208},{""x"":4.599999904632568,""y"":5.162564754486084},{""x"":5.099999904632568,""y"":4.399557590484619},{""x"":5.599999904632568,""y"":2.7977969646453857},{""x"":6.099999904632568,""y"":1.0229872465133667},{""x"":6.599999904632568,""y"":0.48275601863861084},{""x"":7.099999904632568,""y"":0.10408931970596313}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCuba,MHAILRYFIRRLFYHIFYKIYSLISKKHQSLPSDVRQF,COc1ccc2c(c1)c(CC(=O)N3CCCC3C(=O)Oc4ccc(C)cc4OC)c(C)n2C(=O)c5ccc(Cl)cc5,1480019,36.33115768432617,995081928,1227 US HIGHWAY 11,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,7,7,1QBS,7,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[3.320838679713925, -1.2421619987316728, 4.831325425225256, 0.3236011098403072],""points"":[{""x"":0.10000000149011612,""y"":0.3727470338344574},{""x"":0.6000000238418579,""y"":0.12365014106035233},{""x"":1.100000023841858,""y"":0.48422467708587646},{""x"":1.600000023841858,""y"":0.2264465093612671},{""x"":2.0999999046325684,""y"":0.16821794211864471},{""x"":2.5999999046325684,""y"":0.3879014551639557},{""x"":3.0999999046325684,""y"":0.5470244884490967},{""x"":3.5999999046325684,""y"":0.3419053554534912},{""x"":4.099999904632568,""y"":0.7655120491981506},{""x"":4.599999904632568,""y"":1.2346516847610474},{""x"":5.099999904632568,""y"":2.453336715698242},{""x"":5.599999904632568,""y"":2.9565491676330566},{""x"":6.099999904632568,""y"":3.335299491882324},{""x"":6.599999904632568,""y"":3.240290880203247},{""x"":7.099999904632568,""y"":3.1107218265533447}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[3.6401853521511094, 1.26211588875013, 5.399028074402744, 0.5089580830068091],""points"":[{""x"":0.10000000149011612,""y"":3.8585598468780518},{""x"":0.6000000238418579,""y"":3.6077206134796143},{""x"":1.100000023841858,""y"":3.855252265930176},{""x"":1.600000023841858,""y"":3.619039297103882},{""x"":2.0999999046325684,""y"":3.839388370513916},{""x"":2.5999999046325684,""y"":3.335283041000366},{""x"":3.0999999046325684,""y"":3.571141481399536},{""x"":3.5999999046325684,""y"":3.4155046939849854},{""x"":4.099999904632568,""y"":3.7316646575927734},{""x"":4.599999904632568,""y"":3.0680155754089355},{""x"":5.099999904632568,""y"":2.891066551208496},{""x"":5.599999904632568,""y"":1.6022753715515137},{""x"":6.099999904632568,""y"":0.7652576565742493},{""x"":6.599999904632568,""y"":0.6875326037406921},{""x"":7.099999904632568,""y"":0.5828871726989746}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nItaly,MSNFHNEHVMQFYRNNLKTKGVFGRQ,CC(C)Cc1ccc(cc1)C(C)C(=O)N2CCCC2C(=O)OCCO[N+](=O)[O-],1480020,36.33115768432617,99502,"168-46 91ST AVE., 2ND FLR",https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,8,8,1ZP8,8,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[2.293592105923809, 1.3781586549141835, 5.1025898038676605, 0.03493851245291291],""points"":[{""x"":0.10000000149011612,""y"":2.1287283897399902},{""x"":0.6000000238418579,""y"":2.267972230911255},{""x"":1.100000023841858,""y"":2.398442506790161},{""x"":1.600000023841858,""y"":2.5130622386932373},{""x"":2.0999999046325684,""y"":2.3255116939544678},{""x"":2.5999999046325684,""y"":2.127340793609619},{""x"":3.0999999046325684,""y"":2.47259783744812},{""x"":3.5999999046325684,""y"":2.131181478500366},{""x"":4.099999904632568,""y"":2.090421438217163},{""x"":4.599999904632568,""y"":2.02299165725708},{""x"":5.099999904632568,""y"":1.1105059385299683},{""x"":5.599999904632568,""y"":0.4494485855102539},{""x"":6.099999904632568,""y"":0.1375635862350464},{""x"":6.599999904632568,""y"":0.036351121962070465},{""x"":7.099999904632568,""y"":0.1619771122932434}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.953125499439879, 1.2528620255306528, 5.187637440149802, 0.3110348753260886],""points"":[{""x"":0.10000000149011612,""y"":5.6585283279418945},{""x"":0.6000000238418579,""y"":5.911152362823486},{""x"":1.100000023841858,""y"":5.924920082092285},{""x"":1.600000023841858,""y"":5.8469438552856445},{""x"":2.0999999046325684,""y"":5.929472923278809},{""x"":2.5999999046325684,""y"":6.190037727355957},{""x"":3.0999999046325684,""y"":6.236179828643799},{""x"":3.5999999046325684,""y"":6.141019344329834},{""x"":4.099999904632568,""y"":5.295210838317871},{""x"":4.599999904632568,""y"":5.265801906585693},{""x"":5.099999904632568,""y"":3.3722851276397705},{""x"":5.599999904632568,""y"":1.8299226760864258},{""x"":6.099999904632568,""y"":0.32690900564193726},{""x"":6.599999904632568,""y"":0.6274543404579163},{""x"":7.099999904632568,""y"":0.8441857099533081}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nRwanda,MPNSEPASLLELFNSIATQGELVRSLKAGNASK,CC(C)Cc1ccc(cc1)C(C)C(=O)N2CCCC2C(=O)OCCO,1480021,36.33137130737305,995037247,"168-46 91ST AVE., 2ND FLR",https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,9,9,2BDJ,9,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[3.8209972202654474, 1.3779216716448506, 5.299882228439686, 0.06040645519069608],""points"":[{""x"":0.10000000149011612,""y"":3.7821109294891357},{""x"":0.6000000238418579,""y"":3.542433023452759},{""x"":1.100000023841858,""y"":3.7008674144744873},{""x"":1.600000023841858,""y"":3.717301607131958},{""x"":2.0999999046325684,""y"":4.024452209472656},{""x"":2.5999999046325684,""y"":4.013899326324463},{""x"":3.0999999046325684,""y"":3.945094347000122},{""x"":3.5999999046325684,""y"":3.866621971130371},{""x"":4.099999904632568,""y"":3.7461626529693604},{""x"":4.599999904632568,""y"":3.3454740047454834},{""x"":5.099999904632568,""y"":2.61944317817688},{""x"":5.599999904632568,""y"":0.999405026435852},{""x"":6.099999904632568,""y"":0.46259793639183044},{""x"":6.599999904632568,""y"":0.054134611040353775},{""x"":7.099999904632568,""y"":0.05711187422275543}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.6318079657726035, 1.8495493770000595, 5.391793312471116, 0.17060707587348442],""points"":[{""x"":0.10000000149011612,""y"":5.458079814910889},{""x"":0.6000000238418579,""y"":5.554427146911621},{""x"":1.100000023841858,""y"":5.799983024597168},{""x"":1.600000023841858,""y"":5.364140033721924},{""x"":2.0999999046325684,""y"":5.864485740661621},{""x"":2.5999999046325684,""y"":5.4509806632995605},{""x"":3.0999999046325684,""y"":5.702574729919434},{""x"":3.5999999046325684,""y"":5.7314534187316895},{""x"":4.099999904632568,""y"":5.5123443603515625},{""x"":4.599999904632568,""y"":5.724395751953125},{""x"":5.099999904632568,""y"":4.354506969451904},{""x"":5.599999904632568,""y"":1.7307666540145874},{""x"":6.099999904632568,""y"":0.6305936574935913},{""x"":6.599999904632568,""y"":0.035183437168598175},{""x"":7.099999904632568,""y"":0.7575169205665588}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nSwitzerland,IRVVGRYLIEVWKAAGMDMDKVLFLWSSDEI,CN1CCC(CC1)Oc2ccc(cc2)C(F)(F)F,1480028,36.33137130737305,99504,92-11 179TH PLACE,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,9,10,1IAN,10,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[1.1190255865097471, 2.3163895161544437, 5.4968866182279195, 0.2035204047289052],""points"":[{""x"":0.10000000149011612,""y"":1.1057683229446411},{""x"":0.6000000238418579,""y"":1.1019697189331055},{""x"":1.100000023841858,""y"":1.0818607807159424},{""x"":1.600000023841858,""y"":1.062997817993164},{""x"":2.0999999046325684,""y"":1.046447515487671},{""x"":2.5999999046325684,""y"":1.1217249631881714},{""x"":3.0999999046325684,""y"":1.2166996002197266},{""x"":3.5999999046325684,""y"":1.215477705001831},{""x"":4.099999904632568,""y"":1.0581893920898438},{""x"":4.599999904632568,""y"":1.1747995615005493},{""x"":5.099999904632568,""y"":1.0181127786636353},{""x"":5.599999904632568,""y"":0.5344523191452026},{""x"":6.099999904632568,""y"":0.2569526433944702},{""x"":6.599999904632568,""y"":0.1912207305431366},{""x"":7.099999904632568,""y"":0.15060538053512573}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[3.1038581025805785, 2.0032224204185245, 5.087602825989163, 0.13277988512492753],""points"":[{""x"":0.10000000149011612,""y"":3.0498509407043457},{""x"":0.6000000238418579,""y"":2.805217742919922},{""x"":1.100000023841858,""y"":3.3415253162384033},{""x"":1.600000023841858,""y"":3.0549843311309814},{""x"":2.0999999046325684,""y"":3.250074863433838},{""x"":2.5999999046325684,""y"":3.0432586669921875},{""x"":3.0999999046325684,""y"":3.265852451324463},{""x"":3.5999999046325684,""y"":2.9475724697113037},{""x"":4.099999904632568,""y"":3.1929898262023926},{""x"":4.599999904632568,""y"":2.7460060119628906},{""x"":5.099999904632568,""y"":1.6175861358642578},{""x"":5.599999904632568,""y"":0.3006608486175537},{""x"":6.099999904632568,""y"":0.3444803059101105},{""x"":6.599999904632568,""y"":0.015537971630692482},{""x"":7.099999904632568,""y"":0.5527358055114746}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\n,,,,,,,,,,,,,,,,,,,,,');t.columns.add(DG.Column.fromList(DG.TYPE.BYTE_ARRAY,"BinaryImage",Array.from(new Uint8Array(11))));var r=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function s(e){try{l(o.next(e))}catch(e){i(e)}}function a(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}l((o=o.apply(e,t||[])).next())}))};const i=3e4,s=108e5,a=console.log.bind(console),l=console.info.bind(console),c=console.warn.bind(console),u=console.error.bind(console),h={},d="Auto Tests",p="Demo",m="Detectors",f="Core",g={};let y;var b;!function(e){e.notNull=function(e,t){if(null==e)throw new Error(`${null==t?"Value":t} not defined`)}}(b||(b={}));class v{constructor(e,t,n){this.catchUnhandled=!0,this.report=!1,this.returnOnFail=!1,void 0!==e&&(this.catchUnhandled=e),void 0!==t&&(this.report=t),void 0!==n&&(this.returnOnFail=n)}}class C{constructor(e,t,n,o){var s;this.category=e,this.name=t,null!=o||(o={}),null!==(s=o.timeout)&&void 0!==s||(o.timeout=i),this.options=o,this.test=()=>r(this,void 0,void 0,(function*(){return new Promise(((e,t)=>r(this,void 0,void 0,(function*(){var o;let r="";try{DG.Test.isInDebug;let e=yield n();try{r=null!==(o=null==e?void 0:e.toString())&&void 0!==o?o:""}catch(e){r="Can't convert test's result to string",console.error(`Can't convert test's result to string in the ${this.category}:${this.name} test`)}}catch(e){t(e)}e(r)}))))}))}}function x(e,t,n){null==h[y]&&(h[y]={}),null==h[y].tests&&(h[y].tests=[]),h[y].tests.push(new C(y,e,t,n))}function w(e,t=!0,n){if(n=n?`${n}, `:"",e!==t)throw new Error(`${n}Expected "${t}", got "${e}"`)}function A(e,t,n=.001,o){if(e===Number.POSITIVE_INFINITY&&t===Number.POSITIVE_INFINITY||e===Number.NEGATIVE_INFINITY&&t===Number.NEGATIVE_INFINITY||e===Number.NaN&&t===Number.NaN||isNaN(e)&&isNaN(t))return;const r=Math.abs(e-t)<n;if(w(r,!0,`${null!=o?o:""} (tolerance = ${n}; a = ${e}, e = ${t})`),!r)throw new Error(`Expected ${t}, got ${e} (tolerance = ${n})`)}function T(e,t){for(const[n,o]of Object.entries(t)){if(!e.hasOwnProperty(n))throw new Error(`Expected property "${n}" not found`);const t=e[n];if(t instanceof Array&&o instanceof Array)E(t,o);else if(t instanceof Object&&o instanceof Object)T(t,o);else if(Number.isFinite(t)&&Number.isFinite(o))A(t,o);else if(t!=o)throw new Error(`Expected (${o}) for key '${n}', got (${t})`)}}function E(e,t){const n=e.length,o=t.length;if(n!=o)throw new Error(`Arrays are of different length: actual array length is ${n} and expected array length is ${o}`);for(let o=0;o<n;o++)if(e[o]instanceof Array&&t[o]instanceof Array)E(e[o],t[o]);else if(e[o]instanceof Object&&t[o]instanceof Object)T(e[o],t[o]);else if(e[o]!=t[o])throw new Error(`Expected ${t[o]} at position ${o}, got ${e[o]}`)}function S(e,t,n){var o;y=e,t(),h[y]&&(h[y].clear=null===(o=null==n?void 0:n.clear)||void 0===o||o,h[y].timeout=null==n?void 0:n.timeout,h[y].benchmarks=null==n?void 0:n.benchmarks,h[y].stressTests=null==n?void 0:n.stressTests,h[y].owner=null==n?void 0:n.owner)}function N(e){null==h[y]&&(h[y]={}),h[y].before=e}function I(e){null==h[y]&&(h[y]={}),h[y].after=e}function M(e,t){return e.replace(new RegExp(t.name,"gi"),t.nqName)}function P(e,n){var o,a,l,c,u,y,b,v,x,A;return r(this,void 0,void 0,(function*(){const T=e.id;if(g[T])return;const E=n?n.tests:h;if("DevTools"===e.name||n&&"DevTools"===n._package.name)for(const e of window.dartTests){const t=e.name.split(/\s*\|\s*!/g);let n=null!==(o=t.pop())&&void 0!==o?o:e.name,r=t.length?f+": "+t.join(": "):f,s=n.split(" | ");n=s[s.length-1],s.unshift(r),s.pop(),r=s.join(": "),void 0===E[r]&&(E[r]={tests:[],clear:!0}),E[r].tests.push(new C(r,n,e.test,{isAggregated:!1,timeout:null!==(l=null===(a=e.options)||void 0===a?void 0:a.timeout)&&void 0!==l?l:i,skipReason:null===(c=e.options)||void 0===c?void 0:c.skipReason,owner:null===(u=e.options)||void 0===u?void 0:u.owner,benchmark:null!==(b=null===(y=e.options)||void 0===y?void 0:y.benchmark)&&void 0!==b&&b}))}const S=[],N=[],I=[],P=yield grok.dapi.functions.filter(`package.id = "${T}"`).list(),_=new RegExp(/skip:\s*([^,\s]+)|wait:\s*(\d+)|cat:\s*([^,\s]+)|timeout:\s*(\d+)/g);for(const n of P){const o=n.options.test,a=n.options.demoPath;if(o&&Array.isArray(o)&&o.length)for(let e=0;e<o.length;e++){const t=o[e].matchAll(_),a={};Array.from(t).forEach((e=>{e[0].startsWith("skip")?a.skip=e[1]:e[0].startsWith("wait")?a.wait=parseInt(e[2]):e[0].startsWith("cat")?a.cat=e[3]:e[0].startsWith("timeout")&&(a.timeout=parseInt(e[4]))}));const l=new C(null!==(v=a.cat)&&void 0!==v?v:d,1===o.length?n.name:`${n.name} ${e+1}`,(()=>r(this,void 0,void 0,(function*(){const t=yield grok.functions.eval(M(o[e],n));if(a.wait&&(yield R(a.wait)),"boolean"==typeof t&&!t)throw`Failed: ${o[e]}, expected true, got ${t}`}))),{skipReason:a.skip,timeout:DG.Test.isInBenchmark?null!==(x=a.benchmarkTimeout)&&void 0!==x?x:s:null!==(A=a.timeout)&&void 0!==A?A:i});if(a.cat){const e=a.cat;void 0===E[e]&&(E[e]={tests:[],clear:!0}),E[e].tests||(E[e].tests=[]),E[e].tests.push(l)}else S.push(l)}if(a){const e=n.options.demoWait?parseInt(n.options.demoWait):void 0,t=new C(p,n.friendlyName,(()=>r(this,void 0,void 0,(function*(){yield R(300),grok.shell.clearLastError(),yield n.apply(),yield R(e||2e3);const t=yield grok.shell.lastError;if(t)throw new Error(t)}))),{skipReason:n.options.demoSkip});N.push(t)}if(n.hasTag("semTypeDetector")){let o=t;n.options.testData&&(o=yield grok.data.files.openTable(`System:AppData/${e.nqName}/${n.options.testData}`));const i=new C(m,n.friendlyName,(()=>r(this,void 0,void 0,(function*(){const t=[];console.log(`System:AppData/${e.nqName}/${n.options.testData}`);for(const e of o.clone().columns){const o=yield n.apply([e]);t.push(o||e.semType)}const r=t.filter((e=>e));w(r.length,1),n.options.testDataColumnName&&w(r[0],n.options.testDataColumnName)}))),{skipReason:n.options.skipTest});I.push(i)}}g[T]=!0,S.length>0&&(E[d]={tests:S,clear:!0}),N.length>0&&(E[p]={tests:N,clear:!0}),I.length>0&&(E[m]={tests:I,clear:!1})}))}function _(e){return r(this,void 0,void 0,(function*(){return`${e.toString()}\n${e.stack?yield DG.Logger.translateStackTrace(e.stack):""}`}))}function L(e,t,n,o,s,l){var c,h,d,p,m,f,g,y,b,v,C,x,w,A;return r(this,void 0,void 0,(function*(){let r;n.length=0;const T=null!=t&&e.name.toLowerCase()!==t.toLowerCase();let E=(null===(c=e.options)||void 0===c?void 0:c.skipReason)||T,S=T?"skipped":null===(h=e.options)||void 0===h?void 0:h.skipReason;if(DG.Test.isInBenchmark&&!(null===(d=e.options)||void 0===d?void 0:d.benchmark))return void a(`Package testing: Skipped {{${e.category}}} {{${e.name}}} doesnt available in benchmark mode`);E&&!DG.Test.isInBenchmark&&a(`Package testing: Skipped {{${e.category}}} {{${e.name}}}`),E||a(`Package testing: Started {{${e.category}}} {{${e.name}}}`);const N=Date.now(),I=new Date(N).toISOString();try{if(E)r={name:e.name,owner:null!==(m=null===(p=e.options)||void 0===p?void 0:p.owner)&&void 0!==m?m:"",category:e.category,logs:"",date:I,success:!0,result:S,ms:0,skipped:!0,package:null!=s?s:"",flaking:DG.Test.isReproducing};else{let t=null!=o?o:i;DG.Test.isProfiling&&console.profile(`${e.category}: ${e.name}`),r={name:e.name,owner:null!==(g=null===(f=e.options)||void 0===f?void 0:f.owner)&&void 0!==g?g:"",category:e.category,logs:"",date:I,success:!0,result:null!==(y=(yield D(e.test,t)).toString())&&void 0!==y?y:"OK",ms:0,skipped:!1,package:null!=s?s:"",flaking:DG.Test.isReproducing},DG.Test.isProfiling&&(console.profileEnd(`${e.category}: ${e.name}`),grok.shell.info(`Profiling of ${e.category}: ${e.name} finished \n Please ensure that you have opened DevTools (F12) / Performance panel before test starts.`))}}catch(t){u(t),r={name:e.name,owner:null!==(v=null===(b=e.options)||void 0===b?void 0:b.owner)&&void 0!==v?v:"",category:e.category,logs:"",date:I,success:!1,result:yield _(t),ms:0,skipped:!1,package:null!=s?s:"",flaking:!1}}if((null===(C=e.options)||void 0===C?void 0:C.isAggregated)&&r.result.constructor===DG.DataFrame){const e=r.result.col("success");if(e&&(r.success=e.stats.sum===e.length),!l){const e=r.result;e.columns.remove("stack"),e.rows.removeWhere((e=>e.get("success"))),r.result=e}r.result=r.result.toCsv()}if(r.logs=n.join("\n"),r.ms=Date.now()-N,E||a(`Package testing: Finished {{${e.category}}} {{${e.name}}} with {{${r.success?"success":"error"}}} for ${r.ms} ms`),r.success||a(`Package testing: Result for {{${e.category}}} {{${e.name}}}: ${r.result}`),r.category=e.category,r.name=e.name,r.owner=null!==(w=null===(x=e.options)||void 0===x?void 0:x.owner)&&void 0!==w?w:"",!T){let t={success:r.success,result:r.result,ms:r.ms,date:r.date,skipped:r.skipped,category:e.category,name:e.name,logs:r.logs,owner:r.owner,flaking:DG.Test.isReproducing&&r.success,package:r.package};if(r.result.constructor==Object){const e=Object.keys(r.result).reduce(((e,t)=>Object.assign(Object.assign({},e),{["result."+t]:r.result[t]})),{});t=Object.assign(Object.assign({},t),e)}t.result instanceof DG.DataFrame&&(t.result=JSON.stringify(null===(A=t.result)||void 0===A?void 0:A.toJson())||""),yield grok.shell.reportTest("package",t)}return r}))}function O(e){const t=e.slice();return t.sort((()=>Math.random()-.5)),t}function R(e){return r(this,void 0,void 0,(function*(){yield new Promise((t=>setTimeout(t,e)))}))}function $(e,t="Timeout exceeded",n=500,o=50){return r(this,void 0,void 0,(function*(){return new Promise(((r,i)=>{setTimeout((()=>{clearInterval(s),i(new Error(t))}),n);const s=setInterval((()=>{e()&&(clearInterval(s),r(null))}),o)}))}))}function D(e,t,n="EXECUTION TIMEOUT"){return r(this,void 0,void 0,(function*(){let o=null;const r=new Promise(((e,r)=>{o=setTimeout((()=>{r(n)}),t)}));try{return yield Promise.race([e(),r])}finally{o&&clearTimeout(o)}}))}DG.DataFrame.fromColumns([DG.Column.fromStrings("col",["val1","val2","val3"])]);var B=n(4328),F=n(6686);class k extends e.Package{async getTranslationHelper(){return await B.functions.call(`${this.name}:getTranslationHelper`)}}function H(e,t,n){return n.createFormatConverter(e,t).convertTo(F.NO.HELM)}function G(e,t,n){return n.createFormatConverter(e,F.NO.HELM).convertTo(t)}const U={Axolabs:{UfAfsCfsGfuacg:"RNA1{[fR](U)p.[fR](A)[sp].[fR](C)[sp].[fR](G)p.[25r](U)p.[25r](A)p.[25r](C)p.[25r](G)}$$$$"},BioSpring:{"A*GC*123456789":"RNA1{r(A)[sp].r(G)p.r(C)[sp].[fR](U)p.[fR](A)p.[fR](C)p.[fR](G)p.[25r](U)p.[25r](A)p.[25r](C)p.[25r](G)p.d([m5C])}$$$$"},Mermade12:{hefglijkLIJKHEFG:"RNA1{[25r](U)[sp].[25r](A)[sp].[25r](C)[sp].[25r](G)[sp].[fR](U)[sp].[fR](A)[sp].[fR](C)[sp].[fR](G)[sp].[fR](U)p.[fR](A)p.[fR](C)p.[fR](G)p.[25r](U)p.[25r](A)p.[25r](C)p.[25r](G)}$$$$"}},V={"RNA1{[fR](U)p.[fR](A)[sp].[fR](C)[sp].[fR](G)p.[25r](U)p.[25r](A)p.[25r](C)p.[25r](G)}$$$$":"UACGUACG","RNA1{r(A)[sp].r(G)p.r(C)[sp].[fR](U)p.[fR](A)p.[fR](C)p.[fR](G)p.[25r](U)p.[25r](A)p.[25r](C)p.[25r](G)p}$$$$":"AGCUACGUACG","RNA1{[25r](U)[sp].[25r](A)[sp].[25r](C)[sp].[25r](G)[sp].[fR](U)[sp].[fR](A)[sp].[fR](C)[sp].[fR](G)[sp].[fR](U)p.[fR](A)p.[fR](C)p.[fR](G)p.[25r](U)p.[25r](A)p.[25r](C)p.[25r](G)}$$$$":"UACGUACGUACGUACG"};S("Formats to HELM",(()=>{let e;N((async()=>{e=await Ie.getTranslationHelper()}));for(const t of Object.keys(U))for(const[n,o]of Object.entries(U[t]))x(`${t} to HELM`,(async()=>{const r=o;w(H(n,t,e),r)}))})),S("HELM to Formats",(()=>{let e;N((async()=>{e=await Ie.getTranslationHelper()}));for(const t of Object.keys(U))for(const[n,o]of Object.entries(U[t]))x(`${t} to HELM`,(async()=>{const r=n;w(G(o,t,e),r)}))}));var j=n(3480);S("HELM to Nucleotides",(()=>{let e;N((async()=>{e=await Ie.getTranslationHelper()})),Object.entries(V).forEach((([t,n],o)=>{x(`Sequence ${o+1} to nucleotides`,(async()=>{const o=n;w((0,j.Hs)(t,e.monomerLibWrapper),o)}))}))}));const q={[F.NO.AXOLABS]:"Afcgacsu",[F.NO.HELM]:"RNA1{[fR](A)p.[25r](C)p.[25r](G)p.[25r](A)p.[25r](C)[sp].[25r](U)}$$$$"};S("Formats support",(()=>{let e;N((async()=>{e=await Ie.getTranslationHelper()})),Object.entries(q).forEach((([t,n])=>{x(`All formats for ${t}`,(async()=>{const o=function(e,t,n){const o=n.createSequenceValidator(e).getInvalidCodeIndex(t);return(0,j.bD)(e,o,t,n)}(n,t,e),r=Object.keys(o).length;w(!0,Object.keys(U).length+1<=r)}))}))}));var W=n(9192);S("files",(()=>{let t;N((async()=>{t=await Ie.getTranslationHelper()})),x("list",(async()=>{let n;const o=e.DataFrame.fromColumns([e.Column.string("subTest"),n=e.Column.bool("success"),e.Column.string("format"),e.Column.string("src"),e.Column.string("res"),e.Column.string("tgt"),e.Column.string("error"),e.Column.string("stack")]),r=await Ie.files.list("tests",!0,".csv");for(const n of r){const r=e.DataFrame.fromCsv(await n.readAsString()),i=r.columns.byIndex(0),s=i.name,a=r.columns.byIndex(1),l=r.rowCount;for(let e=0;e<l;++e){const r=o.rows.addNew();r.subTest=`${n.name}, row: ${e}`;try{const n=i.get(e),o=a.get(e);r.format=s,r.src=n,r.tgt=o,w(r.res=H(n,s,t),o),r.success=!0}catch(e){const[t,n]=(0,W.AP)(e);r.error=t,r.stack=n,r.success=!1}}}0==o.rowCount&&o.rows.addNew(["empty",!0,"",""]);const i=n.toList().findIndex((e=>1!=e));if(-1!=i){const e=o.rows.get(i);throw new Error(`Subtest '${e.subTest}' failed: ${e.error}`)}return o}),{skipReason:"Can not create test in async manner based on files in Shares."})}));var z=n(8312),Y=n(2003);class K{constructor(e,t,n,o,r,i){this.units=e,this.aligned=t,this.alphabet=n,this.alphabetSize=o,this.alphabetIsMultichar=r,this.separator=i}}async function Q(t,n){const o=(await t()).getCol(n),r=await B.functions.call("Bio:detectMacromolecule",{col:o});if(r&&(o.semType=r),o.semType===e.SEMTYPE.MACROMOLECULE){const e=`Negative test detected semType='${o.semType}', units='${o.meta.units}'.`;throw new Error(e)}}async function J(t,n,o,r,i,s,a,l,c=null){const u=(await t()).col(n),h=await B.functions.call("Bio:detectMacromolecule",{col:u});h&&(u.semType=h),w(u.semType,e.SEMTYPE.MACROMOLECULE),w(u.meta.units,r),w(u.getTag(Y.gp.aligned),i),w(u.getTag(Y.gp.alphabet),s),c&&w(u.getTag(Y.gp.separator),c);const d=o.getSeqHandler(u);w(d.getAlphabetSize(),a),w(d.getAlphabetIsMultichar(),l),d.isHelm()||(w(d.aligned,i),w(d.alphabet,s))}S("PolyTool: detectors",(()=>{let t;N((async()=>{t=await(0,z.Q)()}));const n={cyclized1:{csv:"n,seq\n1,R-F-C(1)-T-G-H-F-Y-G-H-F-Y-G-H-F-Y-P-C(1)-meI\n2,C(1)-T-G-H-F-Y-P-C(1)-meI\n3,R-F-C(1)-T-G-H-F-Y-P-C(1)\n4,C(1)-T-G-H-F-H-P-C(1)\n5,R-F-D(2)-T-G-H-F-Y-P-NH2(2)\n6,R-F-aG(4)-T-G-H-F-Y-P-azG(4)-meI",pos:{seq:new K(Y.Hi.CUSTOM,"SEQ",Y.YI.UN,13,!0,"-")}}};for(const[o,r]of Object.entries(n))x(`${o}`,(async()=>{const n=async()=>e.DataFrame.fromCsv(r.csv);for(const e of r.neg??[])await Q(n,e);for(const[e,o]of Object.entries(r.pos??{}))await J(n,e,t,o.units,o.aligned,o.alphabet,o.alphabetSize,o.alphabetIsMultichar,o.separator)}),{skipReason:"3156"})}));var X=n(4971);const Z="Libraries",ee="Settings",te="DuplicateMonomerPreferences",ne=4e3,oe="nextChunk";let re=Promise.resolve();async function ie(){let e;return re=re.then((async()=>{const t=await B.userSettings.getValue(Z,ee,!0);e=t?JSON.parse(t):{exclude:[],explicit:[],duplicateMonomerPreferences:{}};const n=await async function(){let e=await B.userSettings.getValue(Z,te,!0)??"";if(!e)return{};for(;e.endsWith(oe);){const t=`${te}${e.charAt(e.length-9-1)}`,n=await B.userSettings.getValue(Z,t,!0)??"";e=e.slice(0,e.length-9-1)+n}return JSON.parse(e)}();e.exclude=e.exclude instanceof Array?e.exclude:[],e.explicit=e.explicit instanceof Array?e.explicit:[],e.duplicateMonomerPreferences=e.duplicateMonomerPreferences instanceof Object?e.duplicateMonomerPreferences:{};for(const t in n){e.duplicateMonomerPreferences[t]=e.duplicateMonomerPreferences[t]??{};for(const o in n[t])for(const r of n[t][o])e.duplicateMonomerPreferences[t][r]=o}})),await re,e}async function se(e){re=re.then((async()=>{e.duplicateMonomerPreferences=e.duplicateMonomerPreferences??{};const t={};for(const n in e.duplicateMonomerPreferences){t[n]={};for(const o in e.duplicateMonomerPreferences[n]){const r=e.duplicateMonomerPreferences[n][o];t[n][r]=t[n][r]??[],t[n][r].push(o)}}await async function(e){const t=JSON.stringify(e),n=Math.ceil(t.length/ne);for(let e=0;e<n;e++){const o=0===e?te:`${te}${e}`,r=e<n-1?`${e+1}`:"",i=t.slice(e*ne,(e+1)*ne),s=r?i+r+oe:i;await B.userSettings.add(Z,o,s,!0)}}(t),e.duplicateMonomerPreferences={},await B.userSettings.add(Z,ee,JSON.stringify(e),!0)})),await re}var ae=n(6717),le=n(9124),ce=n(4229),ue=n(5174),he=n(6694);S("PolyTool: Convert",(()=>{let t,n,o,i,s;N((async()=>{o=await(0,ae.j)(),t=await(0,le.b2)(),n=await(0,z.Q)(),i=await(0,X.pj)(),s=await ie(),await i.loadMonomerLibForTests()})),I((async()=>{await se(s),await i.loadMonomerLib(!0)}));const a={"cyclized-C(1)-2-1":{src:{seq:"R-F-C(1)-T-G-H-F-Y-P-C(1)-meI"},tgt:{helm:"PEPTIDE1{R.F.C.T.G.H.F.Y.P.C.[meI]}$PEPTIDE1,PEPTIDE1,3:R3-10:R3$$$V2.0",mol:{atomCount:95,bondCount:100,inchiKey:"LMJUFVBPWWJJPN-AJJYTACESA-N"}}},"cyclized-C(1)-0-1":{src:{seq:"C(1)-T-G-H-F-Y-P-C(1)-meI"},tgt:{helm:"PEPTIDE1{C.T.G.H.F.Y.P.C.[meI]}$PEPTIDE1,PEPTIDE1,1:R3-8:R3$$$V2.0",mol:{atomCount:73,bondCount:77,inchiKey:"KLFRBMUPPMMGJM-HXTBFBBASA-N"}}},"cyclized-C(1)-0-0":{src:{seq:"C(1)-T-G-H-F-Y-P-C(1)"},tgt:{helm:"PEPTIDE1{C.T.G.H.F.Y.P.C}$PEPTIDE1,PEPTIDE1,1:R3-8:R3$$$V2.0",mol:{atomCount:64,bondCount:68,inchiKey:"LOSMDBLEXLWPLB-OFZKBENXSA-N"}}},"cyclized-D(2)-NH2(2)-3-0":{src:{seq:"R-F-D(2)-T-G-H-F-Y-P-NH2(2)"},tgt:{helm:"PEPTIDE1{R.F.D.T.G.H.F.Y.P.[NH2]}$PEPTIDE1,PEPTIDE1,3:R3-10:R2$$$V2.0",mol:{atomCount:81,bondCount:86,inchiKey:"CBMGNYKOZWNVNK-AHGCAHLCSA-N"}}},"cyclized-D(2)-NH2(2)-0-0":{src:{seq:"D(2)-T-G-H-F-Y-P-NH2(2)"},tgt:{helm:"PEPTIDE1{D.T.G.H.F.Y.P.[NH2]}$PEPTIDE1,PEPTIDE1,1:R3-8:R2$$$V2.0",mol:{atomCount:59,bondCount:63,inchiKey:"HGRHAUQBJXFERJ-MUFWPYSASA-N"}}}};for(const[e,n]of Object.entries(a))x(`toHelm-${e}`,(async()=>{const e=await(0,he.Q4)(["rules_example.json"]);w((0,ce.b)([n.src.seq],e,t)[0][0],n.tgt.helm)}));for(const[r,i]of Object.entries(a))x(`toAtomicLevel-${r}`,(async()=>{const r=await(0,he.Q4)(["rules_example.json"]),[s,a,l]=(0,ce.b)([i.src.seq],r,t),c=await(0,ue.A)(r),u=e.Column.fromStrings("helm",s);u.semType=e.SEMTYPE.MACROMOLECULE,u.meta.units=Y.Hi.HELM;const h=await n.helmToAtomicLevel(u,!1,!1,c);if(h.warnings&&h.warnings.length>0)throw new Error(h.warnings[0]);w(null!=h.molCol,!0,".molCol is not null");const d=h.molCol.get(0),p=o.get_mol(d);try{T({atomCount:p.get_num_atoms(),bondCount:p.get_num_bonds(),inchiKey:o.get_inchikey_for_inchi(p.get_inchi())},i.tgt.mol)}finally{p.delete()}}));x("ui-col-wo-table",(async()=>{const t=Ie.name,n=Object.values(a).map((e=>e.src.seq)),o=Object.values(a).map((e=>e.tgt.helm)),r=e.Column.fromStrings("seq",n),i=await B.functions.call(`${t}:polyToolConvert2`,{seqCol:r,generateHelm:!0,chiralityEngine:!0,rules:["rules_example.json"]});E(i.toList(),o),w(i.semType,e.SEMTYPE.MACROMOLECULE),w(i.meta.units,Y.Hi.HELM),w(i.dataFrame,null)})),x("ui-col",(async()=>{const t=Ie.name,n=Object.values(a).map((e=>e.src.seq)),o=Object.values(a).map((e=>e.tgt.helm)),i=e.Column.fromStrings("seq",n),s=e.DataFrame.fromColumns([i]),l=B.shell.addTableView(s),c=await B.functions.call(`${t}:polyToolConvert2`,{seqCol:i,generateHelm:!0,chiralityEngine:!0,rules:["rules_example.json"]});E(c.toList(),o),w(c.semType,e.SEMTYPE.MACROMOLECULE),w(c.meta.units,Y.Hi.HELM),w(c.dataFrame.id,s.id),await function(e,t,n,o=0,i="timeout"){return r(this,void 0,void 0,(function*(){return new Promise(((r,s)=>{const a=e.subscribe((e=>{try{t(e),r("OK")}catch(e){s(e)}finally{a.unsubscribe(),clearTimeout(l)}})),l=setTimeout((()=>{a.unsubscribe(),s(i)}),o);n()}))}))}(l.grid.onAfterDrawContent,(()=>{}),(async()=>{l.grid.invalidate()}),15e3),w(c.getTag(e.TAGS.CELL_RENDERER),"helm")}))}));var de=n(1296),pe=n(3820);S("PolyTool: Enumerate",(()=>{let e,t,n;N((async()=>{e=await(0,le.b2)(),t=await(0,X.pj)(),n=await ie(),await t.loadMonomerLibForTests()})),I((async()=>{await se(n),await t.loadMonomerLib(!0)}));const o={single1:{src:"PEPTIDE1{[Ac(1)].F.W.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",params:{type:de.aK.Single,placeholders:[{position:4,monomers:["K","P","F4COO"]},{position:6,monomers:["Y","T"]}]},tgt:[{seq:"PEPTIDE1{[Ac(1)].F.W.G.K.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-P5K"},{seq:"PEPTIDE1{[Ac(1)].F.W.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-P5P"},{seq:"PEPTIDE1{[Ac(1)].F.W.G.[F4COO].L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-P5[F4COO]"},{seq:"PEPTIDE1{[Ac(1)].F.W.G.P.L.Y.[C(1)].G.[NH2]}$$$$V2.0",name:"-[Tic]7Y"},{seq:"PEPTIDE1{[Ac(1)].F.W.G.P.L.T.[C(1)].G.[NH2]}$$$$V2.0",name:"-[Tic]7T"}]},"single-with-original":{src:"PEPTIDE1{[Ac(1)].F.W.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",params:{type:de.aK.Single,placeholders:[{position:4,monomers:["K","P","F4COO"]},{position:6,monomers:["Y","T"]}],keepOriginal:!0},tgt:[{seq:"PEPTIDE1{[Ac(1)].F.W.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:""},{seq:"PEPTIDE1{[Ac(1)].F.W.G.K.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-P5K"},{seq:"PEPTIDE1{[Ac(1)].F.W.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-P5P"},{seq:"PEPTIDE1{[Ac(1)].F.W.G.[F4COO].L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-P5[F4COO]"},{seq:"PEPTIDE1{[Ac(1)].F.W.G.P.L.Y.[C(1)].G.[NH2]}$$$$V2.0",name:"-[Tic]7Y"},{seq:"PEPTIDE1{[Ac(1)].F.W.G.P.L.T.[C(1)].G.[NH2]}$$$$V2.0",name:"-[Tic]7T"}]},parallel1:{src:"PEPTIDE1{[Ac(1)].F.W.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",params:{type:de.aK.Parallel,placeholders:[{position:1,monomers:["D","L"]},{position:6,monomers:["Y","T"]}]},tgt:[{seq:"PEPTIDE1{[Ac(1)].D.W.G.P.L.Y.[C(1)].G.[NH2]}$$$$V2.0",name:"-F2D-[Tic]7Y"},{seq:"PEPTIDE1{[Ac(1)].L.W.G.P.L.T.[C(1)].G.[NH2]}$$$$V2.0",name:"-F2L-[Tic]7T"}]},"parallel-three-positions":{src:"PEPTIDE1{[Ac(1)].F.W.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",params:{type:de.aK.Parallel,placeholders:[{position:1,monomers:["D","L","K"]},{position:4,monomers:["K","P","F4COO"]},{position:6,monomers:["Y","T","A"]}]},tgt:[{seq:"PEPTIDE1{[Ac(1)].D.W.G.K.L.Y.[C(1)].G.[NH2]}$$$$V2.0",name:"-F2D-P5K-[Tic]7Y"},{seq:"PEPTIDE1{[Ac(1)].L.W.G.P.L.T.[C(1)].G.[NH2]}$$$$V2.0",name:"-F2L-P5P-[Tic]7T"},{seq:"PEPTIDE1{[Ac(1)].K.W.G.[F4COO].L.A.[C(1)].G.[NH2]}$$$$V2.0",name:"-F2K-P5[F4COO]-[Tic]7A"}]},"parallel-with-original":{src:"PEPTIDE1{[Ac(1)].F.W.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",params:{type:de.aK.Parallel,placeholders:[{position:1,monomers:["D","L"]},{position:6,monomers:["Y","T"]}],keepOriginal:!0},tgt:[{seq:"PEPTIDE1{[Ac(1)].F.W.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:""},{seq:"PEPTIDE1{[Ac(1)].D.W.G.P.L.Y.[C(1)].G.[NH2]}$$$$V2.0",name:"-F2D-[Tic]7Y"},{seq:"PEPTIDE1{[Ac(1)].L.W.G.P.L.T.[C(1)].G.[NH2]}$$$$V2.0",name:"-F2L-[Tic]7T"}]},"parallel-single-position":{src:"PEPTIDE1{[Ac(1)].F.W.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",params:{type:de.aK.Parallel,placeholders:[{position:4,monomers:["K","P","F4COO"]}]},tgt:[{seq:"PEPTIDE1{[Ac(1)].F.W.G.K.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-P5K"},{seq:"PEPTIDE1{[Ac(1)].F.W.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-P5P"},{seq:"PEPTIDE1{[Ac(1)].F.W.G.[F4COO].L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-P5[F4COO]"}]},matrix1:{src:"PEPTIDE1{[Ac(1)].F.W.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",params:{type:de.aK.Matrix,placeholders:[{position:1,monomers:["D","L"]},{position:4,monomers:["K","P","F4COO"]},{position:6,monomers:["Y","T"]}]},tgt:[{seq:"PEPTIDE1{[Ac(1)].D.W.G.K.L.Y.[C(1)].G.[NH2]}$$$$V2.0",name:"-F2D-P5K-[Tic]7Y"},{seq:"PEPTIDE1{[Ac(1)].D.W.G.K.L.T.[C(1)].G.[NH2]}$$$$V2.0",name:"-F2D-P5K-[Tic]7T"},{seq:"PEPTIDE1{[Ac(1)].D.W.G.P.L.Y.[C(1)].G.[NH2]}$$$$V2.0",name:"-F2D-P5P-[Tic]7Y"},{seq:"PEPTIDE1{[Ac(1)].D.W.G.P.L.T.[C(1)].G.[NH2]}$$$$V2.0",name:"-F2D-P5P-[Tic]7T"},{seq:"PEPTIDE1{[Ac(1)].D.W.G.[F4COO].L.Y.[C(1)].G.[NH2]}$$$$V2.0",name:"-F2D-P5[F4COO]-[Tic]7Y"},{seq:"PEPTIDE1{[Ac(1)].D.W.G.[F4COO].L.T.[C(1)].G.[NH2]}$$$$V2.0",name:"-F2D-P5[F4COO]-[Tic]7T"},{seq:"PEPTIDE1{[Ac(1)].L.W.G.K.L.Y.[C(1)].G.[NH2]}$$$$V2.0",name:"-F2L-P5K-[Tic]7Y"},{seq:"PEPTIDE1{[Ac(1)].L.W.G.K.L.T.[C(1)].G.[NH2]}$$$$V2.0",name:"-F2L-P5K-[Tic]7T"},{seq:"PEPTIDE1{[Ac(1)].L.W.G.P.L.Y.[C(1)].G.[NH2]}$$$$V2.0",name:"-F2L-P5P-[Tic]7Y"},{seq:"PEPTIDE1{[Ac(1)].L.W.G.P.L.T.[C(1)].G.[NH2]}$$$$V2.0",name:"-F2L-P5P-[Tic]7T"},{seq:"PEPTIDE1{[Ac(1)].L.W.G.[F4COO].L.Y.[C(1)].G.[NH2]}$$$$V2.0",name:"-F2L-P5[F4COO]-[Tic]7Y"},{seq:"PEPTIDE1{[Ac(1)].L.W.G.[F4COO].L.T.[C(1)].G.[NH2]}$$$$V2.0",name:"-F2L-P5[F4COO]-[Tic]7T"}]}};for(const[e,t]of Object.entries(o))x(`${e}`,(async()=>{E((0,pe.o)(t.src,"",t.params),t.tgt.map((e=>[e.seq,e.name])))}))})),S("PolyTool: Enumerate",(()=>{let e,t,n;N((async()=>{e=await(0,le.b2)(),t=await(0,X.pj)(),n=await ie(),await t.loadMonomerLibForTests()})),I((async()=>{await se(n),await t.loadMonomerLib(!0)}));const o={breadth1:{src:"PEPTIDE1{[Ac(1)].F.W.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",params:{type:de.aK.Single,breadthPlaceholders:[{start:2,end:4,monomers:["K"]}]},tgt:[{seq:"PEPTIDE1{[Ac(1)].F.K.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-W3K"},{seq:"PEPTIDE1{[Ac(1)].F.W.K.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-G4K"},{seq:"PEPTIDE1{[Ac(1)].F.W.G.K.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-P5K"}]},"breadth1-with-original":{src:"PEPTIDE1{[Ac(1)].F.W.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",params:{type:de.aK.Single,breadthPlaceholders:[{start:2,end:4,monomers:["K"]}],keepOriginal:!0},tgt:[{seq:"PEPTIDE1{[Ac(1)].F.W.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:""},{seq:"PEPTIDE1{[Ac(1)].F.K.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-W3K"},{seq:"PEPTIDE1{[Ac(1)].F.W.K.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-G4K"},{seq:"PEPTIDE1{[Ac(1)].F.W.G.K.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-P5K"}]},breadth2:{src:"PEPTIDE1{[Ac(1)].F.W.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",params:{type:de.aK.Single,breadthPlaceholders:[{start:2,end:4,monomers:["K","Y"]}]},tgt:[{seq:"PEPTIDE1{[Ac(1)].F.K.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-W3K"},{seq:"PEPTIDE1{[Ac(1)].F.W.K.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-G4K"},{seq:"PEPTIDE1{[Ac(1)].F.W.G.K.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-P5K"},{seq:"PEPTIDE1{[Ac(1)].F.Y.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-W3Y"},{seq:"PEPTIDE1{[Ac(1)].F.W.Y.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-G4Y"},{seq:"PEPTIDE1{[Ac(1)].F.W.G.Y.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-P5Y"}]},"breadth-double":{src:"PEPTIDE1{[Ac(1)].F.W.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",params:{type:de.aK.Single,breadthPlaceholders:[{start:2,end:4,monomers:["K"]},{start:2,end:4,monomers:["Y"]}]},tgt:[{seq:"PEPTIDE1{[Ac(1)].F.Y.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-W3K-K3Y"},{seq:"PEPTIDE1{[Ac(1)].F.K.Y.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-W3K-G4Y"},{seq:"PEPTIDE1{[Ac(1)].F.K.G.Y.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-W3K-P5Y"},{seq:"PEPTIDE1{[Ac(1)].F.Y.K.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-G4K-W3Y"},{seq:"PEPTIDE1{[Ac(1)].F.W.Y.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-G4K-K4Y"},{seq:"PEPTIDE1{[Ac(1)].F.W.K.Y.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-G4K-P5Y"},{seq:"PEPTIDE1{[Ac(1)].F.Y.G.K.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-P5K-W3Y"},{seq:"PEPTIDE1{[Ac(1)].F.W.Y.K.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-P5K-G4Y"},{seq:"PEPTIDE1{[Ac(1)].F.W.G.Y.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",name:"-P5K-K5Y"}]}};for(const[e,t]of Object.entries(o))x(`${e}`,(async()=>{E((0,pe.o)(t.src,"",t.params),t.tgt.map((e=>[e.seq,e.name])))}))}));var me=n(3309);function fe(e,t){const n=t.get_mol(e);try{return w(n.is_valid(),!0,`RDKit rejected SMILES: ${e}`),n.get_smiles()}finally{n.delete()}}S("PolyTool: ChemEnum: R-labels",(()=>{x("extract from every supported form",(async()=>{E((0,me.Qk)("C[1*]"),[1]),E((0,me.Qk)("C[*:1]"),[1]),E((0,me.Qk)("C[*1]"),[1]),E((0,me.Qk)("C[R1]"),[1]),E((0,me.Qk)("C[R:1]"),[1])})),x("extract multi-digit numbers",(async()=>{E((0,me.Qk)("C1CC(C[*:100])(N[*:1])C([*:101])N1[*:2]"),[1,2,100,101]),E((0,me.Qk)("C[R100]N[R:101]"),[100,101])})),x("normalize all spellings to [*:N]",(async()=>{w((0,me.j7)("C[1*]"),"C[*:1]"),w((0,me.j7)("C[*:1]"),"C[*:1]"),w((0,me.j7)("C[*1]"),"C[*:1]"),w((0,me.j7)("C[R1]"),"C[*:1]"),w((0,me.j7)("C[R:1]"),"C[*:1]"),w((0,me.j7)("C[R100]N[R:101]"),"C[*:100]N[*:101]")})),x("remap the one-and-only R-label to a new slot",(async()=>{w((0,me.aj)("C[1*]",5),"C[*:5]"),w((0,me.aj)("C[R:3]CC",1),"C[*:1]CC"),w((0,me.aj)("[*:7]C",2),"[*:2]C")})),x("deduplicate repeated R numbers",(async()=>{E((0,me.Qk)("C[*:1]C[*:1]"),[1])})),x("normalize does not touch regular bracket atoms",(async()=>{w((0,me.j7)("C[NH3+]C[*:1]"),"C[NH3+]C[*:1]"),w((0,me.j7)("[13C]C[*:2]"),"[13C]C[*:2]")}))})),S("PolyTool: ChemEnum: SMILES surgery",(()=>{x("moveStartRLabelToBranch: bare atom at start",(async()=>{w((0,me.z9)("[*:1]CC"),"C([*:1])C"),w((0,me.z9)("[*:1]Cl"),"Cl([*:1])"),w((0,me.z9)("[*:1][NH3+]C"),"[NH3+]([*:1])C")})),x("moveStartRLabelToBranch: with explicit bond",(async()=>{w((0,me.z9)("[*:1]=CC"),"C(=[*:1])C"),w((0,me.z9)("[*:1]#C"),"C(#[*:1])")})),x("moveStartRLabelToBranch: leaves interior unchanged",(async()=>{w((0,me.z9)("CC[*:1]"),"CC[*:1]"),w((0,me.z9)("CC([*:1])CC"),"CC([*:1])CC")})),x("substituteRLabelWithRingDigit collapses branch form",(async()=>{w((0,me.yw)("CC([*:1])CC",1,"9"),"CC9CC"),w((0,me.yw)("CC([*:2])([*:1])CC",1,"%50"),"CC([*:2])%50CC")})),x("substituteRLabelWithRingDigit handles trailing form",(async()=>{w((0,me.yw)("CC[*:1]",1,"7"),"CC7"),w((0,me.yw)("CC=[*:2]",2,"%42"),"CC=%42")})),x("pickFreeRingDigits avoids digits already in use",(async()=>{const e=(0,me.Ii)(["C1CCCCC1[*:1]","[*:1]C"],2);w(e.includes(1),!1),w(e.length,2)})),x("pickFreeRingDigits ignores digits inside bracket atoms",(async()=>{E((0,me.Ii)(["C[*:1]","[*:1]C"],1),[1])}))})),S("PolyTool: ChemEnum: validators",(()=>{x("core without any R-label is rejected",(async()=>{w(null!=(0,me.KS)("CCO","row 1").error,!0)})),x("r-group with zero R-labels is rejected",(async()=>{w(null!=(0,me.ah)("CC",1,"row 1").error,!0)})),x("r-group with multiple R-labels is rejected",(async()=>{w(null!=(0,me.ah)("[*:1]CC[*:2]",1,"row 1").error,!0)})),x("r-group with wrong R-number is auto-remapped",(async()=>{const e=(0,me.ah)("CC[*:3]",1,"row 1");w(null==e.error,!0),w(e.rNumber,1),w(e.sourceRNumber,3),w(e.smiles,"CC[*:1]")}))})),S("PolyTool: ChemEnum: count & validate",(()=>{x("zip length mismatch is flagged",(async()=>{const e=(0,me.KS)("C[*:1]C[*:2]","c1"),t=(0,me.XB)({cores:[e],rGroups:new Map([[1,[(0,me.ah)("C[*:1]",1,"r1-a"),(0,me.ah)("N[*:1]",1,"r1-b")]],[2,[(0,me.ah)("O[*:2]",2,"r2-a")]]]),mode:me.PI.Zip});w(t.ok,!1),w(t.errors.some((e=>e.includes("Zip"))),!0)})),x("cartesian count = product across Rs, summed over cores",(async()=>{const e=(0,me.KS)("C[*:1]","a"),t=(0,me.KS)("C[*:1]N[*:2]","b"),n=(0,me.XB)({cores:[e,t],rGroups:new Map([[1,[(0,me.ah)("C[*:1]",1,"a"),(0,me.ah)("N[*:1]",1,"b"),(0,me.ah)("O[*:1]",1,"c")]],[2,[(0,me.ah)("C[*:2]",2,"a"),(0,me.ah)("N[*:2]",2,"b")]]]),mode:me.PI.Cartesian});w(n.predictedCount,9),w(n.ok,!0)})),x("zip count = N per core, summed",(async()=>{const e=(0,me.KS)("C[*:1]","a"),t=(0,me.KS)("C[*:1]N[*:2]","b");w((0,me.XB)({cores:[e,t],rGroups:new Map([[1,[(0,me.ah)("C[*:1]",1,"a"),(0,me.ah)("N[*:1]",1,"b")]],[2,[(0,me.ah)("O[*:2]",2,"a"),(0,me.ah)("S[*:2]",2,"b")]]]),mode:me.PI.Zip}).predictedCount,4)})),x("uncovered R-number is flagged per core",(async()=>{const e=(0,me.KS)("C[*:1]N[*:7]","c"),t=(0,me.XB)({cores:[e],rGroups:new Map([[1,[(0,me.ah)("O[*:1]",1,"a")]]]),mode:me.PI.Cartesian});w(t.ok,!1),w(t.errors.some((e=>e.includes("R7"))),!0)})),x("hard cap rejects over-limit enumerations",(async()=>{const e=(0,me.KS)("C[*:1]N[*:2]","c"),t=Array.from({length:1e3},((e,t)=>(0,me.ah)("C[*:1]",1,`r1-${t}`))),n=Array.from({length:1001},((e,t)=>(0,me.ah)("O[*:2]",2,`r2-${t}`))),o=(0,me.XB)({cores:[e],rGroups:new Map([[1,t],[2,n]]),mode:me.PI.Cartesian,maxResults:1e6});w(o.overCap,!0),w(o.ok,!1)})),x("countForCore: zip with mismatched per-core lengths → -1",(async()=>{const e=(0,me.KS)("C[*:1]N[*:2]","c"),{count:t}=(0,me.k5)(e,new Map([[1,[(0,me.ah)("C[*:1]",1,"a"),(0,me.ah)("N[*:1]",1,"b")]],[2,[(0,me.ah)("O[*:2]",2,"a")]]]),me.PI.Zip);w(t,-1)}))})),S("PolyTool: ChemEnum: assembly",(()=>{let e;N((async()=>{e=await(0,ae.j)()})),x("single R-group: joins correctly",(async()=>{const t=(0,me.BG)("C[*:1]",new Map([[1,"O[*:1]"]]),e);w(null!=t,!0),w(t,fe("CO",e))})),x("multi R-group: R1 and R2 both joined",(async()=>{const t=(0,me.BG)("C[*:1]N[*:2]",new Map([[1,"O[*:1]"],[2,"S[*:2]"]]),e);w(null!=t,!0),w(t,fe("OCNS",e))})),x("R-label at SMILES start is handled",(async()=>{const t=(0,me.BG)("[*:1]CC",new Map([[1,"Br[*:1]"]]),e);w(null!=t,!0),w(t,fe("BrCC",e))})),x("core uses existing ring digit 1 — free digit is picked",(async()=>{const t=(0,me.BG)("C1CCCCC1[*:1]",new Map([[1,"O[*:1]"]]),e);w(null!=t,!0),w(t,fe("OC1CCCCC1",e))})),x("multi-digit R numbers (R100, R101)",(async()=>{const t=(0,me.BG)("C1CC(C[*:100])(N[*:1])C([*:101])N1[*:2]",new Map([[1,"C[*:1]"],[2,"C[*:2]"],[100,"C[*:100]"],[101,"C[*:101]"]]),e);w(null!=t,!0);const n=e.get_mol(t);try{w(n.is_valid(),!0),w(t.includes("[*:"),!1)}finally{n.delete()}}))})),S("PolyTool: ChemEnum: enumerate",(()=>{let e;N((async()=>{e=await(0,ae.j)()})),x("cartesian across two cores with different R-sets",(async()=>{const t=(0,me.KS)("C[*:1]","A"),n=(0,me.KS)("C[*:1]N[*:2]","B"),o=[(0,me.ah)("O[*:1]",1,"r1-a"),(0,me.ah)("S[*:1]",1,"r1-b")],r=[(0,me.ah)("C[*:2]",2,"r2-a"),(0,me.ah)("N[*:2]",2,"r2-b"),(0,me.ah)("F[*:2]",2,"r2-c")],i=(0,me.HL)({cores:[t,n],rGroups:new Map([[1,o],[2,r]]),mode:me.PI.Cartesian},e);w(i.length,8);const s=i.filter((e=>"C[*:1]"===e.coreSmiles)),a=i.filter((e=>"C[*:1]N[*:2]"===e.coreSmiles));w(s.length,2),w(a.length,6)})),x("zip across two cores with shared R-list length",(async()=>{const t=(0,me.KS)("C[*:1]","A"),n=(0,me.KS)("C[*:1]N[*:2]","B"),o=[(0,me.ah)("O[*:1]",1,"r1-a"),(0,me.ah)("S[*:1]",1,"r1-b")],r=[(0,me.ah)("C[*:2]",2,"r2-a"),(0,me.ah)("N[*:2]",2,"r2-b")],i=(0,me.HL)({cores:[t,n],rGroups:new Map([[1,o],[2,r]]),mode:me.PI.Zip},e);w(i.length,4);const s=i.filter((e=>"C[*:1]N[*:2]"===e.coreSmiles));w(s.length,2),w(s[0].rGroupSmilesByNum.get(1),"O[*:1]"),w(s[0].rGroupSmilesByNum.get(2),"C[*:2]"),w(s[1].rGroupSmilesByNum.get(1),"S[*:1]"),w(s[1].rGroupSmilesByNum.get(2),"N[*:2]")})),x("invalid params return null from enumerate()",(async()=>{const t=(0,me.KS)("C[*:1]N[*:2]","c");w((0,me.HL)({cores:[t],rGroups:new Map([[1,[(0,me.ah)("O[*:1]",1,"x")]]]),mode:me.PI.Cartesian},e),null)}))})),S("PolyTool: ChemEnum: CSV fixtures",(()=>{let t;async function n(t){const n=await Ie.files.readAsText(t);return e.DataFrame.fromCsv(n)}N((async()=>{t=await(0,ae.j)()})),x("cores file parses and all rows validate",(async()=>{const e=(await n("tests/chem_enum_cores.csv")).col("Core"),o=Array.from({length:e.length},((n,o)=>(0,me.KS)(e.get(o),`Cores[${o}]`,t)));w(o.length,4),w(o.every((e=>!e.error)),!0,o.map((e=>e.error??"")).filter((e=>e)).join("; "));for(const e of o)w(e.rNumbers.includes(1)&&e.rNumbers.includes(2),!0,`core ${e.id} R-numbers: ${e.rNumbers}`)})),x("r-groups file: columns R1, R2, R3 populate their slots",(async()=>{const e=await n("tests/chem_enum_rgroups.csv"),o=(n,o)=>{const r=e.col(n),i=[];for(let e=0;e<r.length;e++){const s=r.get(e);null!=s&&""!==String(s).trim()&&i.push((0,me.ah)(String(s),o,`${n}[${e}]`,t))}return i},r=o("R1",1),i=o("R2",2),s=o("R3",3);w(r.length,4),w(i.length,4),w(s.length,1);for(const e of[r,i,s])w(e.every((e=>!e.error)),!0,e.map((e=>e.error??"")).filter((e=>e)).join("; "))})),x("end-to-end cartesian with CSV fixtures produces valid, canonical SMILES",(async()=>{const e=await n("tests/chem_enum_cores.csv"),o=await n("tests/chem_enum_rgroups.csv"),r=e.col("Core"),i=Array.from({length:r.length},((e,n)=>(0,me.KS)(r.get(n),`Cores[${n}]`,t))),s=new Map;for(const e of["R1","R2","R3"]){const n=parseInt(e.substring(1),10),r=o.col(e),i=[];for(let o=0;o<r.length;o++){const s=r.get(o);null!=s&&""!==String(s).trim()&&i.push((0,me.ah)(String(s),n,`${e}[${o}]`,t))}s.set(n,i)}const a=(0,me.HL)({cores:i,rGroups:s,mode:me.PI.Cartesian},t);w(null!=a&&a.length>0,!0);for(const e of a){w(e.smiles.includes("[*:"),!1,`residual R-label in result: ${e.smiles}`);const n=t.get_mol(e.smiles);try{w(n.is_valid(),!0,`invalid SMILES: ${e.smiles}`)}finally{n.delete()}}}))}));var ge=n(6307),ye=n(2125);S("PolyTool: Chain: parseNotation",(()=>{let e;N((async()=>{e=await(0,le.b2)()}));const t={cyclized:{src:{seq:"R-F-C(1)-T-G-H-F-Y-P-C(1)-meI"},tgt:{helm:"PEPTIDE1{R.F.[C(1)].T.G.H.F.Y.P.[C(1)].[meI]}$$$$V2.0"}},dimerized1:{src:{seq:"(#3)Succ-{A(CHOL)-F-C(1)-T-G-H-Y-P-C(1)-NH2}"},tgt:{helm:"PEPTIDE1{[(#3)Succ]}|PEPTIDE2{[A(CHOL)].F.[C(1)].T.G.H.Y.P.[C(1)].[NH2]}$PEPTIDE1,PEPTIDE2,1:R1-1:R1$$$V2.0"}},dimerized2:{src:{seq:"($3)Succ-{R-F-C(1)-T-G-H-F-P-C(1)-NH2}($2){A(CHOL)-F-C(1)-T-G-H-F-P-C(1)-NH2}"},tgt:{helm:"PEPTIDE1{[($3)Succ]}|PEPTIDE2{R.F.[C(1)].T.G.H.F.P.[C(1)].[NH2]}|PEPTIDE3{[($2)A(CHOL)].F.[C(1)].T.G.H.F.P.[C(1)].[NH2]}$PEPTIDE1,PEPTIDE2,1:R1-1:R1$$$V2.0"}}};for(const[n,o]of Object.entries(t))x(`${n}`,(async()=>{await(0,he.Q4)(["rules_example.json"]);const t=await ge.s.fromSeparator(o.src.seq,e),n=t.mol,r=e.createHelmWebEditor();r.editor.setMol(n);const i=r.editor.getHelm(),s=t.getHelm();w(i,o.tgt.helm),w(s,o.tgt.helm)}),"reaction2"==n?{skipReason:"reverse reaction"}:void 0);const n={"0-in-4-4-3":{inIdx:0,spIdx:0,outIdx:0,monomers:[["0","1","2","3"],["4","5","6","7"],["8","9","10"]]},"3-in-4-4-3":{inIdx:3,spIdx:0,outIdx:3,monomers:[["0","1","2","3"],["4","5","6","7"],["8","9","10"]]},"4-in-4-4-3":{inIdx:0,spIdx:1,outIdx:4,monomers:[["0","1","2","3"],["4","5","6","7"],["8","9","10"]]},"7-in-4-4-3":{inIdx:3,spIdx:1,outIdx:7,monomers:[["0","1","2","3"],["4","5","6","7"],["8","9","10"]]},"8-in-4-4-3":{inIdx:0,spIdx:2,outIdx:8,monomers:[["0","1","2","3"],["4","5","6","7"],["8","9","10"]]},"0-in-1-1-6-3":{inIdx:0,spIdx:0,outIdx:0,monomers:[["0"],["1"],["2","3","4","5","6","7"],["8","9","10"]]},"1-in-1-1-6-3":{inIdx:0,spIdx:1,outIdx:1,monomers:[["0"],["1"],["2","3","4","5","6","7"],["8","9","10"]]},"2-in-1-1-6-3":{inIdx:0,spIdx:2,outIdx:2,monomers:[["0"],["1"],["2","3","4","5","6","7"],["8","9","10"]]},"3-in-1-1-6-3":{inIdx:1,spIdx:2,outIdx:3,monomers:[["0"],["1"],["2","3","4","5","6","7"],["8","9","10"]]},"7-in-1-1-6-3":{inIdx:5,spIdx:2,outIdx:7,monomers:[["0"],["1"],["2","3","4","5","6","7"],["8","9","10"]]},"8-in-1-1-6-3":{inIdx:0,spIdx:3,outIdx:8,monomers:[["0"],["1"],["2","3","4","5","6","7"],["8","9","10"]]}};for(const[e,{inIdx:t,spIdx:o,outIdx:r,monomers:i}]of Object.entries(n))x(`innerIdx-${e}`,(async()=>{const[e,n]=(0,ye.M)(r,i);w(e,t),w(n,o)}));for(const[e,{inIdx:t,spIdx:o,outIdx:r,monomers:i}]of Object.entries(n))x(`outerIdx-${e}`,(async()=>{w((0,ye.j)(t,o,i),r)}))})),S("PolyTool: Chain",(()=>{let e;N((async()=>{e=await(0,le.b2)()}));const t={cyclized:{data:{templateSeq:"R-F-C(1)-T-G-H-F-Y-P-C(1)-meI",templateHelm:"PEPTIDE1{R.F.[C(1)].T.G.H.F.Y.P.[C(1)].[meI]}$$$$V2.0",mmHelm:"PEPTIDE1{R.F.C.T.G.H.F.Y.P.C.[meI]}$PEPTIDE1,PEPTIDE1,3:R3-10:R3$$$V2.0"},tgt:{templateChain:{monomerCount:[11],linkageCount:0},mmChain:{monomerCount:[11],linkageCount:0}}},dimerized1:{data:{templateSeq:"(#3)Succ-{A(CHOL)-F-C(1)-T-G-H-Y-P-C(1)-NH2}",templateHelm:"PEPTIDE1{[(#3)Succ]}|PEPTIDE2{[A(CHOL)].F.[C(1)].T.G.H.Y.P.[C(1)].[NH2]}$PEPTIDE1,PEPTIDE2,1:R1-1:R1$$$V2.0",mmHelm:"PEPTIDE1{[(#3)Succ].[{A(CHOL)].F.C.T.G.H.Y.P.C.[NH2}]}$PEPTIDE1,PEPTIDE1,4:R3-10:R3$$$V2.0"},tgt:{templateChain:{monomerCount:[1,10],linkageCount:1},mmChain:{monomerCount:[11],linkageCount:1}}},dimerized2:{data:{templateSeq:"($3)Succ-{R-F-C(1)-T-G-H-F-P-C(1)-NH2}($3){A(CHOL)-F-C(1)-Y-H-G-D-N-C(1)-meI}",templateHelm:"PEPTIDE1{[($3)Succ]}|PEPTIDE2{R.F.[C(1)].T.G.H.F.P.[C(1)].[NH2]}|PEPTIDE3{[($3)A(CHOL)].F.[C(1)].Y.H.G.D.N.[C(1)].[meI]}$PEPTIDE1,PEPTIDE2,1:R1-1:R1$$$V2.0",mmHelm:"PEPTIDE1{[($3)Succ].[{R].F.C.T.G.H.F.P.C.[NH2}($3){A(CHOL)].F.[C(1)].Y.H.G.D.N.[C(1)].[meI}]}$PEPTIDE1,PEPTIDE1,4:R3-10:R3$$$V2.0"},tgt:{templateChain:{monomerCount:[1,10,10],linkageCount:1},mmChain:{monomerCount:[20],linkageCount:1}}}};for(const[n,{data:o,tgt:r}]of Object.entries(t))x(`fromNotation-${n}`,(async()=>{const t=await(0,he.Q4)(["rules_example.json"]),n=ge.s.fromSeparator(o.templateSeq,e);n.applyRules(t),n.check(!0),E(n.monomers.map((e=>e.length)),r.mmChain.monomerCount),w(n.linkages.length,r.mmChain.linkageCount),w(n.getHelm(),o.mmHelm)}),{skipReason:"3157"});for(const[n,{data:o,tgt:r}]of Object.entries(t))x(`parseNotation-${n}`,(async()=>{await(0,he.Q4)(["rules_example.json"]);const t=ge.s.fromSeparator(o.templateSeq,e);t.check(!0),E(t.monomers.map((e=>e.length)),r.templateChain.monomerCount),w(t.linkages.length,r.templateChain.linkageCount),w(t.getHelm(),o.templateHelm),w(t.getNotation(),o.templateSeq)}));for(const[n,{data:o,tgt:r}]of Object.entries(t))x(`parseHelm-${n}`,(async()=>{await(0,he.Q4)(["rules_example.json"]);const t=ge.s.fromHelm(o.templateHelm,e);t.check(!0),E(t.monomers.map((e=>e.length)),r.templateChain.monomerCount),w(t.linkages.length,r.templateChain.linkageCount),w(t.getHelm(),o.templateHelm),w(t.getNotation(),o.templateSeq)}));for(const[n,{data:o,tgt:r}]of Object.entries(t))x(`applyRules-${n}`,(async()=>{const t=await(0,he.Q4)(["rules_example.json"]),n=ge.s.fromSeparator(o.templateSeq,e);n.applyRules(t),n.check(!0),E(n.monomers.map((e=>e.length)),r.mmChain.monomerCount),w(n.linkages.length,r.mmChain.linkageCount),w(n.getHelm(),o.mmHelm)}),{skipReason:"applyRules is not implemented"})})),S("toAtomicLevel",(()=>{let t,n,o;N((async()=>{n=await(0,X.pj)(),t=await ie(),o=await(0,ae.j)(),await n.loadMonomerLibForTests()})),I((async()=>{await se(t),await n.loadMonomerLib(!0)})),x("override",(async()=>{const t=n.getMonomerLib(),r=await Ie.files.readAsText("tests/polytool-reaction-lib.json"),i=JSON.parse(r).find((e=>"GGaz"===e.symbol));w(null!=i,!0,"Monomer 'GGaz' not found.");const s={PEPTIDE:{GGaz:i}},a=t.override(s,"test"),l=await(0,z.Q)(),c=e.Column.fromList(e.COLUMN_TYPE.STRING,"helm",["PEPTIDE1{F.P.Y.[GGaz].H.A.A.G.G.A.C}|PEPTIDE2{A.A.A}$PEPTIDE1,PEPTIDE2,4:R4-1:R1|PEPTIDE1,PEPTIDE1,11:R2-4:R3$$$V2.0"]);c.semType=e.SEMTYPE.MACROMOLECULE,c.meta.units=Y.Hi.HELM;const u=await l.helmToAtomicLevel(c,!1,!1,a);w(null!=u.molCol,!0,"Result molCol is null");const h=u.molCol.get(0);w(!!h,!0,"Molfile is empty");const d=o.get_mol(h);try{const e=d.get_inchi(),t=o.get_inchikey_for_inchi(e);w(d.get_num_bonds(),103),w(d.get_num_atoms(),98),w(t,"XPQUTLNSNIMERR-WKBTUBAPSA-N")}finally{d.delete()}})),x("getNewMonomer",(async()=>{const e=await(0,ae.j)(),t=n.getMonomerLib(),o=(await(0,he.Q4)(["rules_example.json"])).reactionRules.find((e=>"GGaz"==e.name)),[r,i]=(0,ue.T)(e,t,o);w(r?.[0],"azG_GGaz");const s=e.get_mol(i[0].molfile);try{const t=s.get_inchi();e.get_inchikey_for_inchi(t),w(s.get_num_bonds(),7),w(s.get_num_atoms(),8)}finally{s.delete()}}))}));var be=n(5613),ve=n(5733),Ce=n(1536);const xe="RNA1{m(G)[sp].m(A)[sp].[fl2r](C)p.[fl2r](U)p.r(G)p.r(A)p.r(A)p.r(U)p.r(A)p.r(U)p.r(A)p.r(A)p.r(A)p.r(C)p.r(U)p.r(U)p.m(G)p.m(U)[sp].m(G)[sp].[L3]}|RNA2{[fl2r](C)[sp].m(A)[sp].m(A)p.m(G)p.r(U)p.r(U)p.r(U)p.r(A)p.r(U)p.r(A)p.r(U)p.r(U)p.r(C)p.r(A)p.r(U)p.m(C)p.m(A)[sp].m(G)[sp].r(U)}$$$$",we="RNA1{[lna](C)[sp].[lna](A)[sp].[lna](G)[sp].d(T)[sp].d(C)[sp].d(A)[sp]}$$$$";S("OligoRenderer: parser",(()=>{x("looksLikeHelm — positive",(async()=>{w((0,be.yO)(xe),!0),w((0,be.yO)("RNA1{R(A)P}"),!0),w((0,be.yO)("PEPTIDE1{A.C.G}"),!0)})),x("looksLikeHelm — negative",(async()=>{w((0,be.yO)(""),!1),w((0,be.yO)("AUCGUACGUAGCUAGCAU"),!1),w((0,be.yO)("Af Cf Gf Uf"),!1)})),x("parses two-strand duplex",(async()=>{const e=(0,be.On)(xe);w(e.sense.type,"RNA"),w(e.sense.monomers.length,20),w(null!==e.antisense,!0),w(e.antisense.monomers.length,19)})),x("parses single-strand",(async()=>{const e=(0,be.On)(we);w(e.sense.monomers.length,6),w(e.antisense,null);const t=e.sense.monomers[0];w(t.kind,"nucleotide"),"nucleotide"===t.kind&&(w(t.sugar,"lna"),w(t.base,"C"),w(t.phosphate,"sp"))})),x("single-char unbracketed deoxyribose `d` parses correctly",(async()=>{const e=(0,be.On)("RNA1{d(T)p.d(C)p.d(G)}$$$$");w(e.sense.monomers.length,3);const t=e.sense.monomers[0];"nucleotide"===t.kind&&(w(t.sugar,"d"),w(t.base,"T"),w(t.phosphate,"p"))})),x("parses bracketed conjugate",(async()=>{const e=(0,be.On)(xe),t=e.sense.monomers[e.sense.monomers.length-1];w(t.kind,"conjugate"),"conjugate"===t.kind&&w(t.symbol,"L3")})),x("handles empty / malformed without throwing",(async()=>{const e=(0,be.On)("");w(e.sense.monomers.length,0),w(e.antisense,null),w((0,be.On)("not a helm string").sense.monomers.length,0)})),x("passes through unknown sugar/phosphate symbols",(async()=>{const e=(0,be.On)("RNA1{[xr](A)[zp].[yr](C)p}$$$$").sense.monomers[0];"nucleotide"===e.kind&&(w(e.sugar,"xr"),w(e.phosphate,"zp"))})),x("parser strips brackets from multi-char base in parens",(async()=>{const e=(0,be.On)("RNA1{r([5Br-dC])p}$$$$").sense.monomers[0];w(e.kind,"nucleotide"),w(e.sugar,"r"),w(e.base,"5Br-dC"),w(e.phosphate,"p")})),x("parser strips brackets from multi-char base on both strands",(async()=>{const e=(0,be.On)("RNA1{r([5meC])p.[fl2r]([5Br-dC])[sp]}|RNA2{r([5fU])p}$$$$"),t=e.sense.monomers[0],n=e.sense.monomers[1],o=e.antisense.monomers[0];w(t.base,"5meC"),w(n.sugar,"fl2r"),w(n.base,"5Br-dC"),w(n.phosphate,"sp"),w(o.base,"5fU")})),x("parser leaves bare-letter base unchanged",(async()=>{w((0,be.On)("RNA1{r(A)p.r(G)p.r(C)p.r(T)p.r(U)p}$$$$").sense.monomers.map((e=>e.base)).join(","),"A,G,C,T,U")})),x("canonicalizeHelm re-brackets multi-char base on output",(async()=>{const e=(0,be.nj)("RNA1{r([5Br-dC])p}$$$$");w(e.includes("([5Br-dC])"),!0,`expected canonicalized HELM to contain '([5Br-dC])', got: ${e}`),w(e.includes("(5Br-dC)")&&!e.includes("([5Br-dC])"),!1,`must not emit unbracketed (5Br-dC) without wrapping brackets, got: ${e}`)})),x("canonicalizeHelm keeps single-letter base unbracketed",(async()=>{const e=(0,be.nj)("RNA1{r(A)p}$$$$");w(e.includes("r(A)p"),!0,`expected single-letter base to stay unbracketed, got: ${e}`),w(e.includes("([A])"),!1,`single-letter base must NOT be wrapped in brackets, got: ${e}`)}))})),S("OligoRenderer: modification dictionary",(()=>{x("resolves HELMCore canonical sugars",(async()=>{w((0,Ce.xh)("m","A").meta.short,"2'-OMe"),w((0,Ce.xh)("fl2r","C").meta.short,"2'-F"),w((0,Ce.xh)("lna","G").meta.short,"LNA"),w((0,Ce.xh)("moe","A").meta.short,"2'-MOE")})),x("aliases legacy uppercase symbols to canonical",(async()=>{w((0,Ce.xh)("mR","A").meta.name,(0,Ce.xh)("m","A").meta.name),w((0,Ce.xh)("fR","C").meta.name,(0,Ce.xh)("fl2r","C").meta.name),w((0,Ce.xh)("LR","G").meta.name,(0,Ce.xh)("lna","G").meta.name),w((0,Ce.xh)("dR","T").meta.name,(0,Ce.xh)("d","T").meta.name)})),x("uses base-canonical color for unmodified ribose",(async()=>{const e=(0,Ce.xh)("r","A"),t=(0,Ce.xh)("r","C");w(e.color!==t.color,!0,`Unmodified A and C must use distinct canonical colors, got ${e.color} for both`)})),x("falls back to hash color for unknown sugar",(async()=>{const e=(0,Ce.xh)("zzz","A");w(e.color.startsWith("hsl("),!0),w(e.meta.name,"zzz")})),x("hashColor is deterministic",(async()=>{w((0,Ce.e8)("foo"),(0,Ce.e8)("foo")),w((0,Ce.e8)("foo")!==(0,Ce.e8)("bar"),!0)})),x("PS phosphate (canonical and legacy) resolve to same color",(async()=>{w((0,Ce.bM)("sp").color,Ce.P4.sp.color),w((0,Ce.bM)("sP").color,Ce.P4.sp.color)})),x("GalNAc / L3 / Chol resolve as conjugates",(async()=>{w((0,Ce.rK)("GalNAc").meta.category,"conjugate"),w((0,Ce.rK)("L3").meta.category,"conjugate"),w((0,Ce.rK)("Chol").meta.color,Ce.pt.Chol.color)}))})),S("OligoRenderer: layout",(()=>{x("comfortable cell — chips fit width and height",(async()=>{const e=(0,be.On)(xe),t=(0,ve.aA)(500,70,e);w(t.textOnlyFallback,!1),w(t.chipW>5,!0,"chip width should be larger than minimum"),w(t.chipW<=17,!0,"chip width should respect max (17)"),w(t.antiY>t.senseY,!0),w(t.senseChips.length>0,!0),w(t.antiChips.length>0,!0)})),x("compact cell — both strands still fit in 28px row",(async()=>{const e=(0,be.On)(xe),t=(0,ve.aA)(300,28,e);w(t.antiY>0,!0),w(2*t.chipH+t.strandGap<=28,!0,"two strands must fit within 28px row")})),x("very narrow cell triggers text-only fallback",(async()=>{const e=(0,be.On)(xe),t=(0,ve.aA)(60,30,e);w(t.textOnlyFallback,!0),w(t.senseChips.length,0)})),x("aspect ratio is preserved across sizes",(async()=>{const e=(0,be.On)(xe);for(const[t,n]of[[300,50],[500,70],[800,90]]){const o=(0,ve.aA)(t,n,e),r=o.chipH/o.chipW;w(Math.abs(r-1.25)<.01,!0,`aspect ratio drifted at ${t}x${n}: got ${r.toFixed(3)}`)}})),x("single-strand layout",(async()=>{const e=(0,be.On)(we),t=(0,ve.aA)(400,50,e);w(t.antiY,-1),w(t.antiChips.length,0)})),x("antisense reversed by default for pair-alignment",(async()=>{const e=(0,be.On)(xe),t=(0,ve.aA)(800,70,e);w(t.antiReversed,!0);const n=e.antisense.monomers[e.antisense.monomers.length-1];w(t.antiChips[0].monomer===n,!0)})),x("pairAlign: false leaves antisense in data order",(async()=>{const e=(0,be.On)(xe),t=(0,ve.aA)(800,70,e,{pairAlign:!1});w(t.antiReversed,!1),w(t.antiChips[0].monomer===e.antisense.monomers[0],!0)})),x("conjugate occupies a wider position; following chip does not overlap",(async()=>{const e=(0,be.On)("RNA1{m(G)p.m(A)p.m(C)p.[L3]}|RNA2{m(C)p.m(A)p.m(A)p.r(G)}$$$$"),t=(0,ve.aA)(600,70,e),n=t.senseChips[3];w(n.monomer.kind,"conjugate"),w(n.w>=t.chipW,!0,"conjugate must be at least chip-wide")}))})),S("OligoRenderer: hit testing",(()=>{x("hits each chip via stored positions",(async()=>{const e=(0,be.On)(xe),t=(0,ve.aA)(800,70,e),n=t.senseChips[0],o=(0,ve.CB)(n.x+n.w/2,t.senseY+t.chipH/2,e,t);w(null!==o,!0),w(o.strand,"sense"),w(o.position,0);const r=e.sense.monomers[0],i="nucleotide"===r.kind&&"sp"===r.phosphate,s=n.x+n.w+.1*t.chipGap,a=(0,ve.CB)(s,t.senseY+t.chipH/2,e,t);i?(w(null!==a,!0),w(void 0!==a.linkage,!0)):w(a,null)})),x("antisense hit returns original position despite reversed display",(async()=>{const e=(0,be.On)(xe),t=(0,ve.aA)(800,70,e),n=t.antiChips[0],o=(0,ve.CB)(n.x+n.w/2,t.antiY+t.chipH/2,e,t);w(null!==o,!0),w(o.strand,"antisense"),w(o.position,e.antisense.monomers.length-1,"leftmost AS chip in pair-aligned display = last monomer in data")})),x("hovering between two chips with PS linkage returns the linkage",(async()=>{const e=(0,be.On)("RNA1{m(G)[sp].m(A)p.m(C)p}$$$$"),t=(0,ve.aA)(600,70,e),n=t.senseChips[0],o=t.senseChips[1],r=(n.x+n.w+o.x)/2,i=(0,ve.CB)(r,t.senseY+t.chipH/2,e,t);w(null!==i,!0),w(void 0!==i.linkage,!0),w(i.linkage.phosphateSymbol,"sp")}))})),S("OligoRenderer: drawing smoke",(()=>{x("draws without error on offscreen canvas",(async()=>{const e=document.createElement("canvas");e.width=500,e.height=70;const t=e.getContext("2d"),n=(0,be.On)(xe);w((0,ve.Z4)(t,0,0,500,70,n).textOnlyFallback,!1)})),x("handles unknown modifications without throwing",(async()=>{const e=document.createElement("canvas");e.width=200,e.height=50;const t=e.getContext("2d"),n=(0,be.On)("RNA1{[xr](A)[zp].[yr](C)p}$$$$");(0,ve.Z4)(t,0,0,200,50,n),w(!0,!0)})),x("renders legacy uppercase symbols via alias map",(async()=>{const e=document.createElement("canvas");e.width=400,e.height=50;const t=e.getContext("2d"),n=(0,be.On)("RNA1{[mR](G)[sP].[mR](A)[sP].[fR](C)P.R(U)P}|RNA2{[mR](C)[sP].R(A)P.R(U)P.R(G)P}$$$$");(0,ve.Z4)(t,0,0,400,50,n),w(n.sense.monomers.length,4),w(null!==n.antisense,!0)}))}));var Ae=n(1757),Te=n.n(Ae),Ee=n(4900);const Se="RNA1{r(A)p.r(C)p.r(G)p.r(U)p}|RNA2{r(U)p.r(C)p.r(G)p.r(A)p}$$$$";function Ne(){return Te()(".d4-dialog").length}S("OligoCellEditor",(()=>{I((async()=>{Te()(".d4-dialog .ui-btn-cancel, .d4-dialog .d4-dialog-header .grok-icon.fa-times").trigger("click"),B.shell.closeAll()})),x("cellEditor opens HELM editor for OligoNucleotide cell and saves on OK",(async()=>{const t=e.Column.fromStrings("seq",[Se]);(0,Ee.P)(t);const n=e.DataFrame.fromColumns([t]);n.name="oligo-edit-test";const o=B.shell.addTableView(n);await $((()=>Te()(o.root).find(".d4-grid canvas").length>0),"Grid canvas did not appear",5e3);const r=e.Func.find({tags:["cellEditor"],package:"SequenceTranslator"}).filter((e=>"OligoNucleotide"===e.description));w(r.length,1),w(r[0].name,"editOligoNucleotideCell");const i=o.grid.cell("seq",0);w(null!=i,!0),w(i.cell.value,Se);const s=Ne();await r[0].apply({cell:i}),await $((()=>Ne()>s),"HELM editor dialog did not open within 15s",15e3),await $((()=>Te()(".d4-dialog .ui-btn-ok, .d4-dialog button.ui-btn.ui-btn-ok").length>0),"OK button did not appear in HELM editor dialog within 15s",15e3),await R(1e3);const a=Te()(".d4-dialog .ui-btn-ok, .d4-dialog button.ui-btn.ui-btn-ok").first();w(a.length>0,!0,"OK button not found in dialog"),a.trigger("click"),await $((()=>Ne()<=s),"Dialog did not close after OK",5e3);const l=i.cell.value;w("string"==typeof l&&l.includes("RNA1{")&&l.includes("RNA2{")&&l.includes("$$$$"),!0,`Expected cell value to remain valid HELM after OK; got: ${l}`)}))}));const Ie=new k;async function Me(t,n,o){const d=await function(e){var t,n,o;return r(this,void 0,void 0,(function*(){const d=(null==e?void 0:e.nodeOptions)?e.nodeOptions.package:grok.functions.getCurrentCall().func.package;if(!d)throw new Error("Can't run tests outside of the package");const p=null===(t=d.packageOwner)||void 0===t?void 0:t.match(/<([^>]*)>/),m=p?p[1]:"";null!=d&&(yield P(d));const f=[];console.log("Running tests..."),console.log(e),null!=e||(e={}),null!==(n=(o=e).testContext)&&void 0!==n||(o.testContext=new v),grok.shell.clearLastError();const g=function(){const e=[];return console.log=(...t)=>{e.push(...t),a(...t)},console.info=(...t)=>{e.push(...t),l(...t)},console.warn=(...t)=>{e.push(...t),c(...t)},console.error=(...t)=>{e.push(...t),u(...t)},e}();yield function(e,t){var n,o,i,s,h,p;return r(this,void 0,void 0,(function*(){try{let l=null!=(null==t?void 0:t.skipToCategory),c=!1;for(const[u,g]of Object.entries(e)){if(null===(n=t.exclude)||void 0===n?void 0:n.some((e=>u.startsWith(e))))continue;if(null!=(null==t?void 0:t.category)&&!u.toLowerCase().startsWith(null==t?void 0:t.category.toLowerCase().trim()))continue;if(l)if(c)l=!1;else{if(null==(null==t?void 0:t.skipToCategory)||u.toLowerCase().trim()!==(null==t?void 0:t.skipToCategory.toLowerCase().trim()))continue;c=!0}const e=null===(o=g.tests)||void 0===o?void 0:o.every((e=>{var n;return(null===(n=e.options)||void 0===n?void 0:n.skipReason)||null!=(null==t?void 0:t.test)&&t.test.toLowerCase()!==e.name.toLowerCase()}));if(!e){const e=(null!==(i=g.tests)&&void 0!==i?i:[]).filter((e=>{var n;return(null===(n=e.options)||void 0===n?void 0:n.skipReason)||null!=(null==t?void 0:t.test)&&t.test.toLowerCase()!==e.name.toLowerCase()})).length;a(`Package testing: Started {{${u}}}${e>0?` skipped {{${e}}}`:""}`),g.beforeStatus=yield y(g.before,u)}let v,C=null!==(s=g.tests)&&void 0!==s?s:[];t.stressTest&&(C=C.filter((e=>{var t;return null===(t=e.options)||void 0===t?void 0:t.stressTest})),C=O(C)),(null!==(p=null===(h=t.tags)||void 0===h?void 0:h.length)&&void 0!==p?p:0)>0&&(C=C.filter((e=>{var n,o;return null===(o=null===(n=e.options)||void 0===n?void 0:n.tags)||void 0===o?void 0:o.some((e=>{var n;return(null!==(n=null==t?void 0:t.tags)&&void 0!==n?n:[]).includes(e)}))}))),g.beforeStatus?(v=Array.from(C.map((e=>({date:(new Date).toISOString(),category:u,name:e.name,success:!1,result:"before() failed",ms:0,skipped:!1,logs:"",owner:m,package:d.name,widgetsDifference:0,flaking:DG.Test.isReproducing})))),v.forEach((e=>r(this,void 0,void 0,(function*(){return yield grok.shell.reportTest("package",e)}))))):v=yield b(g,t,l);const x=v.filter((e=>"skipped"!=e.result));if(e||(g.afterStatus=yield y(g.after,u)),g.afterStatus&&(a(`Package testing: Category after() {{${u}}} failed`),a(`Package testing: Result for {{${u}}} after: ${g.afterStatus}`),x.push({date:(new Date).toISOString(),category:u,name:"after",success:!1,result:g.afterStatus,ms:0,skipped:!1,logs:"",owner:m,package:d.name,widgetsDifference:0,flaking:DG.Test.isReproducing})),g.beforeStatus&&(a(`Package testing: Category before() {{${u}}} failed`),a(`Package testing: Result for {{${u}}} before: ${g.beforeStatus}`),x.push({date:(new Date).toISOString(),category:u,name:"before",success:!1,result:g.beforeStatus,ms:0,skipped:!1,logs:"",owner:m,package:d.name,widgetsDifference:0,flaking:DG.Test.isReproducing})),f.push(...x),t.returnOnFail&&x.some((e=>!e.success&&!e.skipped&&e.name!==t.skipToTest)))break}}finally{console.log=a,console.info=l,console.warn=c,console.error=u}if(t.testContext.catchUnhandled&&!DG.Test.isInBenchmark){yield R(1e3);const e=yield grok.shell.lastError;if(null!=e){const t={logs:"",date:(new Date).toISOString(),category:"Unhandled exceptions",name:"Exception",result:null!=e?e:"",success:!e,ms:0,skipped:!1,owner:null!=m?m:"",package:d.name,widgetsDifference:0};a(`Package testing: Unhandled Exception: ${e}`),f.push(Object.assign(Object.assign({},t),{flaking:DG.Test.isReproducing&&!e})),t.package=d.name,yield grok.shell.reportTest("package",t)}}}))}(h,e);for(let e of f)e.result=e.result.toString().replace(/"/g,"'"),null!=e.logs&&(e.logs=e.logs.toString().replace(/"/g,"'"));return f;function y(e,t){return r(this,void 0,void 0,(function*(){let n;try{void 0!==e&&(yield D((()=>r(this,void 0,void 0,(function*(){yield e()}))),1e5,`before ${t}: timeout error`))}catch(e){n=yield _(e)}return n}))}function b(e,t,n){var o,a,l,c,u,h,p,f,y,b,v,x,w,A,T,E,S,N;return r(this,void 0,void 0,(function*(){let r=null!==(o=e.tests)&&void 0!==o?o:[];const I=[],M=C();if(e.clear){let o=n&&null!=t.skipToTest;for(let n=0;n<r.length;n++){r[n].options&&void 0===(null===(a=r[n].options)||void 0===a?void 0:a.benchmark)&&(r[n].options||(r[n].options={}),r[n].options.benchmark=null!==(l=e.benchmarks)&&void 0!==l&&l);let x=r[n];if(t.test&&t.test.toLowerCase()!==x.name.toLowerCase())continue;if(o){if(null==(null==t?void 0:t.skipToTest)||x.name.toLowerCase().trim()!==(null==t?void 0:t.skipToTest.toLowerCase().trim()))continue;o=!1}(null==x?void 0:x.options)&&(x.options.owner=null!==(p=null!==(h=null!==(u=null===(c=r[n].options)||void 0===c?void 0:c.owner)&&void 0!==u?u:null==e?void 0:e.owner)&&void 0!==h?h:m)&&void 0!==p?p:"");let w=yield L(x,null==t?void 0:t.test,g,DG.Test.isInBenchmark?null!==(y=null===(f=r[n].options)||void 0===f?void 0:f.benchmarkTimeout)&&void 0!==y?y:s:null!==(v=null===(b=r[n].options)||void 0===b?void 0:b.timeout)&&void 0!==v?v:i,d.name,t.verbose);if(w&&(I.push(Object.assign(Object.assign({},w),{widgetsDifference:C()-M})),t.returnOnFail&&t.skipToTest!==x.name&&!w.success&&!w.skipped))return I;t.nodeOptions||(grok.shell.closeAll(),DG.Balloon.closeAll())}}else{let o=n&&null!=t.skipToTest;for(let n=0;n<r.length;n++){let i=r[n];if(t.test&&t.test.toLowerCase()!==i.name.toLowerCase())continue;if(o){null!=(null==t?void 0:t.skipToTest)&&i.name.toLowerCase().trim()===(null==t?void 0:t.skipToTest.toLowerCase().trim())&&(o=!1);continue}(null==i?void 0:i.options)&&(i.options.owner=null!==(T=null!==(A=null!==(w=null===(x=r[n].options)||void 0===x?void 0:x.owner)&&void 0!==w?w:null==e?void 0:e.owner)&&void 0!==A?A:m)&&void 0!==T?T:"");let a=yield L(i,null==t?void 0:t.test,g,DG.Test.isInBenchmark?null!==(S=null===(E=r[n].options)||void 0===E?void 0:E.benchmarkTimeout)&&void 0!==S?S:s:null===(N=r[n].options)||void 0===N?void 0:N.timeout,d.name,t.verbose);if(a&&(I.push(Object.assign(Object.assign({},a),{widgetsDifference:C()-M})),t.returnOnFail&&t.skipToTest!==i.name&&!a.success&&!a.skipped))return I}}return I}))}function C(){var e;if("undefined"!=typeof process)return 0;let t=-1;try{t=DG.Widget.getAll().length}catch(t){console.warn(null!==(e=t.message)&&void 0!==e?e:t)}return t}}))}({category:t,test:n,testContext:o,verbose:!0});return e.DataFrame.fromObjects(d)}async function Pe(){await P(Ie,Ie.getModule("package-test.js"))}})(),sequencetranslator_test=o})();
|
|
3
3
|
//# sourceMappingURL=package-test.js.map
|