@datagrok/sequence-translator 1.10.3 → 1.10.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/package-test.js +1 -1
- package/dist/package-test.js.map +1 -1
- package/dist/package.js +1 -1
- package/dist/package.js.map +1 -1
- package/package.json +1 -1
- package/src/package-api.ts +17 -3
- package/src/package.g.ts +23 -3
- package/src/package.ts +43 -5
- package/src/polytool/pt-enumerate-seq-dialog.ts +1 -1
- package/test-console-output-1.log +54 -54
- 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 t={6717:(t,e,n)=>{"use strict";n.d(e,{j:()=>o});var r=n(6082);async function o(){const t=r.Func.find({package:"Chem",name:"getRdKitModule"});if(0===t.length)throw new Error('Package "Chem" must be installed for getRdKitModule.');return(await t[0].prepare().call()).getOutputParamValue()}},3599:(t,e,n)=>{"use strict";n.d(e,{o:()=>r.o});var r=n(6869)},9124:(t,e,n)=>{"use strict";n.d(e,{b2:()=>i});var r=n(7389),o=n(6082);async function i(){const t="Helm",e=o.Func.find({package:t,name:"getHelmHelper"});if(0===e.length)throw new Error(`Package '${t}' must be installed for HelmHelper.`);return(await e[0].prepare().call()).getOutputParamValue()}o.JsInputBase,Error,r.input.helmAsync=async function(t,e){return(await i()).createHelmInput(t,e)}},8438:(t,e,n)=>{"use strict";function r(t){return t.startsWith("[")&&t.endsWith("]")?t.slice(1,-1):t}n.d(e,{D:()=>r})},8123:(t,e,n)=>{"use strict";n.d(e,{u:()=>r});const r={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:(t,e,n)=>{"use strict";n.d(e,{Y:()=>o});var r=n(3599);function o(t){let e;switch(t){case r.o.BASE:case r.o.SUGAR:case r.o.LINKER:case r.o.NUCLEOTIDE:case"nucleotide":e="RNA";break;case r.o.AA:e="PEPTIDE";break;case r.o.CHEM:e="CHEM";break;case r.o.BLOB:e="BLOB";break;default:e="PEPTIDE",console.warn(`Unexpected HelmType '${t}'`)}return e}},9235:(t,e,n)=>{"use strict";n.d(e,{H:()=>u,R:()=>l});var r=n(6082),o=n(1991),i=n.n(o),s=n(330),a=n(3599);async function l(t,e,o,l,u,c,h){const d=t.length,f=t.dataFrame,p=Math.max(navigator.hardwareConcurrency-2,1),m=new Array(p).fill(null).map((()=>new Worker(new URL(n.p+n.u(455),n.b)))),g=d/p,y=new Array(p),b=c.getSeqHandler(t),v="RNA"==l?a.o.NUCLEOTIDE:a.o.AA,C=i().count(0).take(t.length).map((t=>{const e=b.getSplitted(t);return i().count(0).take(e.length).map((t=>({position:t,symbol:e.getCanonical(t),biotype:v}))).toArray()})).toArray();for(let t=0;t<p;t++){const n=m[t],r=Math.floor(t*g),i=t===p-1?d:Math.floor((t+1)*g);y[t]=new Promise((t=>{n.onmessage=e=>{t(e.data)}})),n.postMessage({seqList:C,monomersDict:e,alphabet:o,polymerType:l,start:r,end:i})}const w=[],A=[];await Promise.all(y).then((t=>{for(const e of t)w.push(...e.molfiles),A.push(...e.warnings)})),setTimeout((()=>{m.forEach((t=>{t.terminate()}))}),0);const x=(0,s.qj)(f,t.name),E=r.Column.fromType(r.COLUMN_TYPE.STRING,x,t.length).init((t=>w[t]?.molfile));return E.semType=r.SEMTYPE.MOLECULE,E.meta.units=r.UNITS.Molecule.MOLBLOCK,E.setTag(".sequence-src-col",t.name),{molCol:E,warnings:A}}function u(t,e){const n={},o={};for(const i of t){const t=e.getWebEditorMonomer(i.biotype,i.symbol).backgroundcolor,a=(0,s.vG)(t??r.Color.toRgb(r.Color.mouseOverRows))??[1,0,0,.7];for(const t of i.atoms)n[t]=a;for(const t of i.bonds)o[t]=a}return{atoms:Object.keys(n).map((t=>parseInt(t))),bonds:Object.keys(o).map((t=>parseInt(t))),highlightAtomColors:n,highlightBondColors:o}}},3561:(t,e,n)=>{"use strict";n.d(e,{Hb:()=>l,YN:()=>m,gU:()=>u});var r=n(8123),o=n(294),i=n(3151),s=n(439),a=n(6197);function l(t,e,n){const o=new Map;for(const a of t.getMonomerSymbolsByType(e)){const l=t.getMonomer(e,a);if("RNA"===e&&("Branch"===l.monomerType||n===s.YI.DNA&&l.symbol===r.u.DEOXYRIBOSE.symbol||n===s.YI.RNA&&l.symbol===r.u.RIBOSE.symbol||l.symbol===r.u.PHOSPHATE.symbol)||"PEPTIDE"===e&&"Branch"!==l.monomerType){const t={};i.f6.forEach((e=>{t[e]=l[e]})),o.set(a,t)}}return o}function u(t,e,n,i){if(0===t.length)return o.vF.createEmpty();const l=p,{atomCount:u,bondCount:h,needsCapping:f}=l(t,e,n,i),g=new Array(u),y=new Array(h);let b,v=null,C=null;"PEPTIDE"===i?b=c:(b=d,v=n===s.YI.DNA?(0,o.xb)(e,r.u.DEOXYRIBOSE):(0,o.xb)(e,r.u.RIBOSE),C=(0,o.xb)(e,r.u.PHOSPHATE));const w={i:0,nodeShift:0,bondShift:0,backbonePositionShift:new Array(2).fill(0),branchPositionShift:new Array(2).fill(0),backboneAttachNode:0,branchAttachNode:0,flipFactor:1},A={sugar:v,phosphate:C,seqLength:t.length,atomCount:u,bondCount:h},x=new o.Cg,E=[];let T,S=0;for(w.i=0;w.i<A.seqLength;++w.i){const n=t[w.i];if(n.symbol===s._S)continue;const r=(0,o.xb)(e,{symbol:n.symbol,polymerType:(0,a.Y)(n.biotype)});T=r.terminalR2Atom;const i=w.nodeShift,l=w.bondShift;b(r,g,y,w,A),r.stereoAtoms?.forEach((t=>E.push(t+S))),S+=r.atoms.x.length;const u=w.nodeShift-i,c=new Array(u);for(let t=0;t<u;++t)c[t]=i+t;const h=w.bondShift-l,d=new Array(h);for(let t=0;t<h;++t)d[t]=l+t;x.set(w.i,{biotype:n.biotype,symbol:n.symbol,atoms:c,bonds:d})}f&&function(t,e,n,o,i=r.u.OXYGEN){const s=n.nodeShift+1;t[o.atomCount]=r.u.V3K_BEGIN_DATA_LINE+s+" "+(i??r.u.OXYGEN)+" "+m(n.backbonePositionShift[0])+" "+n.flipFactor*m(n.backbonePositionShift[1])+" 0.000000 0\n";const a=n.backboneAttachNode,l=s;e[o.bondCount]=r.u.V3K_BEGIN_DATA_LINE+n.bondShift+" 1 "+a+" "+l+"\n"}(g,y,w,A,T??r.u.OXYGEN);const I=r.u.V3K_BEGIN_COUNTS_LINE+u+" "+h+r.u.V3K_COUNTS_LINE_ENDING;let _="";return _+=r.u.V3K_HEADER_FIRST_LINE,_+=r.u.V3K_HEADER_SECOND_LINE,_+=r.u.V3K_BEGIN_CTAB_BLOCK,_+=I,_+=r.u.V3K_BEGIN_ATOM_BLOCK,_+=g.join(""),_+=r.u.V3K_END_ATOM_BLOCK,_+=r.u.V3K_BEGIN_BOND_BLOCK,_+=y.join(""),_+=r.u.V3K_END_BOND_BLOCK,E.length>0&&(_+=function(t){const e=[];let n=`M V30 MDLV30/STEABS ATOMS=(${t.length}`;for(let r=0;r<t.length;r++){const o=`${n} ${t[r]}`;o.length>76?(e.push(`${n} -\n`),n=`M V30 ${t[r]}`):n=o,r===t.length-1&&e.push(`${n})\n`)}return`M V30 BEGIN COLLECTION\n${e.join("")}M V30 END COLLECTION\n`}(E)),_+=r.u.V3K_END_CTAB_BLOCK,_+=r.u.V3K_END,{molfile:_,monomers:x}}function c(t,e,n,r){r.flipFactor=(-1)**(r.i%2),h(t,e,n,r)}function h(t,e,n,o){!function(t,e,n){for(let o=0;o<t.atoms.atomTypes.length;++o){const i=n.nodeShift+o+1;e[n.nodeShift+o]=r.u.V3K_BEGIN_DATA_LINE+i+" "+t.atoms.atomTypes[o]+" "+m(n.backbonePositionShift[0]+t.atoms.x[o])+" "+m(n.backbonePositionShift[1]+n.flipFactor*t.atoms.y[o])+" "+t.atoms.kwargs[o]}}(t,e,o),f(t,n,o),function(t,e,n){if(0!==n.backboneAttachNode){const o=n.bondShift,i=n.backboneAttachNode,s=t.meta.terminalNodes[0]+n.nodeShift;e[n.bondShift-1]=r.u.V3K_BEGIN_DATA_LINE+o+" 1 "+i+" "+s+"\n"}}(t,n,o),null!==t.meta.branchShift&&t.meta.terminalNodes.length>2&&function(t,e){e.branchAttachNode=e.nodeShift+t.meta.terminalNodes[2];for(let n=0;n<2;++n)e.branchPositionShift[n]=e.backbonePositionShift[n]+t.meta.branchShift[n]}(t,o),function(t,e){e.backboneAttachNode=e.nodeShift+t.meta.terminalNodes[1],e.bondShift+=t.bonds.atomPairs.length+1,e.nodeShift+=t.atoms.atomTypes.length,e.backbonePositionShift[0]+=t.meta.backboneShift?.[0]??0,e.backbonePositionShift[1]+=e.flipFactor*(t.meta.backboneShift?.[1]??0)}(t,o)}function d(t,e,n,o,i){if(0===o.i)h(i.sugar,e,n,o);else for(const t of[i.phosphate,i.sugar])h(t,e,n,o);!function(t,e,n,o){(function(t,e,n){for(let o=0;o<t.atoms.atomTypes.length;++o){const i=n.nodeShift+o+1;e[n.nodeShift+o]=r.u.V3K_BEGIN_DATA_LINE+i+" "+t.atoms.atomTypes[o]+" "+m(n.branchPositionShift[0]+t.atoms.x[o])+" "+m(n.branchPositionShift[1]+n.flipFactor*t.atoms.y[o])+" "+t.atoms.kwargs[o]}})(t,e,o),f(t,n,o),function(t,e,n){const o=n.bondShift,i=n.branchAttachNode,s=t.meta.terminalNodes[0]+n.nodeShift;e[o-1]=r.u.V3K_BEGIN_DATA_LINE+o+" 1 "+i+" "+s+"\n"}(t,n,o);const i=o.bondShift,s=o.branchAttachNode,a=t.meta.terminalNodes[0]+o.nodeShift;n[i-1]=r.u.V3K_BEGIN_DATA_LINE+i+" 1 "+s+" "+a+"\n",o.bondShift+=t.bonds.atomPairs.length+1,o.nodeShift+=t.atoms.atomTypes.length}(t,e,n,o)}function f(t,e,n){for(let o=0;o<t.bonds.atomPairs.length;++o){const i=n.bondShift+o+1,s=t.bonds.atomPairs[o][0]+n.nodeShift,a=t.bonds.atomPairs[o][1]+n.nodeShift;let l="";if(t.bonds.bondConfiguration.has(o)){let e=t.bonds.bondConfiguration.get(o);n.flipFactor<0&&(e=1===e?3:1),l=" CFG="+e}const u=t.bonds.kwargs.has(o)?" "+t.bonds.kwargs.get(o):"";e[n.bondShift+o]=r.u.V3K_BEGIN_DATA_LINE+i+" "+t.bonds.bondTypes[o]+" "+s+" "+a+l+u+"\n"}}function p(t,e,n,i){let l=0,u=0,c=0,h=!0,d=null;for(const n of t)if(n.symbol!==s._S){if("*"==n.symbol)throw new Error("Gap canonical symbol is '', not '*");d=(0,o.xb)(e,{symbol:n.symbol,polymerType:(0,a.Y)(n.biotype)}),l+=d.atoms.x.length,u+=d.bonds.bondTypes.length,c++}if("PEPTIDE"===i)l+=1,u+=c,c>0&&((d?.meta?.rNodes?.length??0)<2||d?.terminalR2Atom?.toLowerCase()===r.u.HYDROGEN.toLowerCase())&&(h=!1,l-=1,u-=1);else{const i=n===s.YI.DNA?(0,o.xb)(e,r.u.DEOXYRIBOSE):(0,o.xb)(e,r.u.RIBOSE),a=(0,o.xb)(e,r.u.PHOSPHATE);l+=(t.length-1)*a.atoms.x.length,l+=t.length*i.atoms.x.length,l+=1,u+=(t.length-1)*a.bonds.bondTypes.length,u+=t.length*i.bonds.bondTypes.length,u-=1,u+=3*t.length}return{atomCount:l,bondCount:u,needsCapping:h}}function m(t){return Math.round(r.u.PRECISION_FACTOR*t)/r.u.PRECISION_FACTOR}},6077:(t,e,n)=>{"use strict";n.d(e,{C4:()=>p,eM:()=>m});var r=n(4328),o=n(6082),i=n(1991),s=n.n(i),a=n(439),l=n(3561),u=n(9235),c=n(294),h=n(9192),d=n(330),f=n(8123);async function p(t,e,n,i,l){if(e.semType!==o.SEMTYPE.MACROMOLECULE)return{molCol:null,warnings:[`Only the ${o.SEMTYPE.MACROMOLECULE} columns can be converted to atomic level, the chosen column has semType '${e.semType}'`]};let c=e;const f=i.getSeqHandler(e);let p,g;f.notation!==a.Hi.SEPARATOR&&f.notation!==a.Hi.BILN&&(c=f.convert(a.Hi.SEPARATOR,"."),c.name=e.name);try{g=i.getSeqHandler(c).alphabet,p=(0,d.pz)(g)}catch(t){const[e,n]=(0,h.AP)(t);return{molCol:null,warnings:[e]}}const y=function(t,e){const n=t.length,o=new Array(n),i=e.getSeqHandler(t);let a=!1;const l=i.defaultBiotype;for(let t=0;t<n;++t){const e=i.getSplitted(t);a||(a=0===e.length),o[t]=s().count(0).take(e.length).filter((t=>!e.isGap(t))).map((t=>({position:t,biotype:l,symbol:e.getCanonical(t)}))).toArray()}return a&&r.shell.warning(`Some values in the "${t.name}" column are empty`),o}(c,i),b=m(y,p,g,n,l),v=c.length,C=await(0,u.R)(c,b,g,p,n,i,l);C.warnings.length>.05*v&&r.shell.warning(`Molfile conversion resulted in ${C.warnings.length} errors`);const w=o.Func.find({name:"convertToV3KViaOCL"})[0];if(w&&C.molCol)try{const t=C.molCol.toList(),e=await w.apply({mols:t});C.molCol.init((n=>e[n]?e[n]:t[n]))}catch(t){console.error(t)}return C}function m(t,e,n,r,o){const i=(0,l.Hb)(r,e,n),s={},u={value:null};if("RNA"===e){const t=n===a.YI.RNA?[f.u.RIBOSE,f.u.PHOSPHATE]:[f.u.DEOXYRIBOSE,f.u.PHOSPHATE];for(const n of t)g(s,n.symbol,i,o,e,u)}for(let n=0;n<t.length;++n){const r=t[n];for(const t of r){const n=t.symbol;if(""!==n)try{if("RNA"===e&&3===n.split(/\(|\)/).filter((t=>!!t)).length){const t=n.split(/\(|\)/)[1];g(s,t,i,o,e,u),s[e]?.[t]&&(s[e][n]=s[e][t])}else g(s,n,i,o,e,u)}catch(t){const e=t instanceof Error?t.message:t.toString(),r=t instanceof Error?t.stack:void 0;throw console.error(`bio lib: getMonomersDictFromLib() sym='${n}', error:\n${e}\n${r}`),new Error(`Can't get monomer '${n}' from library: ${e}`)}}}return s}function g(t,e,n,r,o,i){const s={polymerType:o,symbol:e};if(!(0,c.bq)(t,s)){const a=function(t,e,n,r,o){if(e.has(t)){const s=e.get(t),a=function(t){const e=[];for(const n of t){let t=n.capGroupSmiles;t||(t=n.capGroupSMILES),t=t.replace(/(\[|\]|\*|:|\d)/g,"").replace("OH","O").replace("Oh","O"),e.push(t)}return e}(s.rgroups),u=(i=s.molfile).includes("V3000")?function(t){const e=new Map,n=/M V30 (\d+) R#.+RGROUPS=\((\d+) (\d+)\).*/gm;let r;for(;null!==(r=n.exec(t));)r.index===n.lastIndex&&n.lastIndex++,e.set(parseInt(r[1]),parseInt(r[3]));return e}(i):function(t){const e=new Map;let n=t.indexOf(f.u.V2K_A_LINE,0),r=n;for(;-1!==n;){r=t.indexOf("\n",n);const o=parseInt(t.substring(n,r).replace(/^A\s+/,""));n=t.indexOf("R",r),r=t.indexOf("\n",n);const i=parseInt(t.substring(n,r).replace(/^R/,""));e.set(o,i),n=t.indexOf(f.u.V2K_A_LINE,r)}for(n=t.indexOf(f.u.V2K_RGP_LINE,0),r=t.indexOf("\n",n);-1!==n;){n+=f.u.V2K_RGP_SHIFT,r=t.indexOf("\n",n);const o=t.substring(n,r).replaceAll(/\s+/g," ").split(" ").map((t=>parseInt(t))).slice(1);for(let t=0;t<o.length;t+=2){if(e.has(o[t])&&e.get(o[t])!==o[t+1])throw new Error(`r-group index ${o[t]} has already been added with a different value`);e.set(o[t],o[t+1])}n=t.indexOf(f.u.V2K_RGP_LINE,r)}return e}(i),c=s.molfile.includes("V3000")?s.molfile:function(t,e){const n=e.get_mol(function(t){return t.split("\n").map((t=>{const e=t.indexOf(" R# "),n=t.indexOf(" R ");if(-1===e&&-1===n)return t;const r=-1!==e?e:n,o=t.split("");for(let t=r+5;t<o.length;t++)" "!==o[t]&&(o[t]="0");return o.join("")})).join("\n")}(t)),r=n.get_v3Kmolblock();return n.delete(),r}(function(t){let e=t.indexOf(f.u.V2K_A_LINE,0);-1===e&&(e=t.indexOf(f.u.V2K_RGP_LINE));const n=t.indexOf(f.u.V3K_END,e);return t.substring(0,e)+t.substring(n)}(s.molfile),n),h=function(t){let e=(t=t.replaceAll("\r","")).indexOf(f.u.V3K_BEGIN_COUNTS_LINE)+f.u.V3K_COUNTS_SHIFT,n=t.indexOf(" ",e+1);const r=parseInt(t.substring(e,n));return e=n+1,n=t.indexOf(" ",e+1),{atomCount:r,bondCount:parseInt(t.substring(e,n))}}(c),d=function(t,e){const n=new Array(e),r=new Float32Array(e),o=new Float32Array(e),i=new Array(e);let s=t.indexOf(f.u.V3K_BEGIN_ATOM_BLOCK);s=t.indexOf("\n",s);let a=s;for(let l=0;l<e;l++){s=t.indexOf(f.u.V3K_BEGIN_DATA_LINE,s)+f.u.V3K_IDX_SHIFT,a=t.indexOf(" ",s),s=a+1,a=t.indexOf(" ",s),n[l]=t.substring(s,a);const e=new Array(2);for(let n=0;n<2;++n)s=a+1,a=t.indexOf(" ",s),e[n]=parseFloat(t.substring(s,a));r[l]=e[0],o[l]=e[1],s=a,a=t.indexOf("\n",s)+1,i[l]=t.slice(s,a),s=a}return{atomTypes:n,x:r,y:o,kwargs:i}}(c,h.atomCount),p=function(t,e){const n=new Uint32Array(e),r=new Array(e),o=new Map,i=new Map;let s=t.indexOf(f.u.V3K_BEGIN_BOND_BLOCK);s=t.indexOf("\n",s);let a=s;for(let l=0;l<e;++l){const e=new Array(3);s=t.indexOf(f.u.V3K_BEGIN_DATA_LINE,a)+f.u.V3K_IDX_SHIFT,a=t.indexOf(" ",s);for(let n=0;n<3;++n)s=a+1,a=Math.min(t.indexOf("\n",s),t.indexOf(" ",s)),e[n]=parseInt(t.slice(s,a));n[l]=e[0],r[l]=e.slice(1);const u=t.indexOf("\n",s);let c=t.slice(a,u),h=c.indexOf(f.u.V3K_BOND_CONFIG);if(-1!==h){h=c.indexOf("=",h)+1;let t=c.indexOf(" ",h);-1===t&&(t=c.length);const e=parseInt(c.slice(h,t));o.set(l,e);const n=f.u.V3K_BOND_CONFIG+e.toString();c=c.replace(n,"")}c||i.set(l,c)}return{bondTypes:n,atomPairs:r,bondConfiguration:o,kwargs:i}}(c,h.bondCount),m=function(t,e,n,r){const o={backboneShift:null,branchShift:null,terminalNodes:[],rNodes:[]};if(n&&r&&[1,2].some((t=>!Array.from(r.values()).find((e=>e==t))))){const o=[1,2].find((t=>!Array.from(r.values()).find((e=>e==t)))),i=[1,2].find((t=>Array.from(r.values()).find((e=>e==t)))),s=Array.from(r.keys()).find((t=>r.get(t)===i))-1,a=t.x[s],l=t.y[s],u=e.atomPairs.find((t=>t.includes(s+1))).find((t=>t!==s+1))-1;let c=t.x.reduce(((e,n,r)=>{if(r===s)return e;if(r===u)return e;const o=t.y[r];return Math.sqrt((n-a)**2+(o-l)**2)>Math.sqrt((t.x[e]-a)**2+(t.y[e]-l)**2)?r:e}),-1);if(-1===c&&(c=t.x.length,t.x=new Float32Array([...t.x,-a]),t.y=new Float32Array([...t.y,-l]),t.atomTypes=[...t.atomTypes,"H"],t.kwargs=[...t.kwargs,""],e.atomPairs.push([u+1,c+1]),e.bondTypes=new Uint32Array([...e.bondTypes,1]),e.kwargs.set(e.atomPairs.length-1,"")),r.set(c+1,o),1===o)n.unshift(t.atomTypes[c]);else{if(2!==o)throw new Error(`Unexpected missing R-group: ${o}`);n.splice(1,0,t.atomTypes[c])}}return function(t,e,n){for(const[r,o]of n)t.atomTypes[r-1]=e[o-1]}(t,n,r),function(t,e){e.rNodes=Array.from(t.keys());for(let n=0;n<e.rNodes.length;n++)for(const r of[1,2])if(t.get(e.rNodes[n])===r){const t=e.rNodes[r-1];e.rNodes[r-1]=e.rNodes[n],e.rNodes[n]=t}}(r,o),y(e,o),o}(d,p,a,u),g=function(t){let e=[],n=t.indexOf("M V30 MDLV30/STEABS ATOMS=(");for(;-1!==n;){n+=28;const r=t.indexOf(")",n);e=e.concat(t.substring(n,r).split(" ").slice(1).map((t=>parseInt(t)))),n=r,n=t.indexOf("M V30 MDLV30/STEABS ATOMS=(",n)}return e}(c),v={atoms:d,bonds:p,meta:m,stereoAtoms:g};return"PEPTIDE"===r?function(t){const e=t.meta.terminalNodes[0]-1,n=t.meta.rNodes[0]-1,r=t.atoms.x,o=t.atoms.y;S(t,-r[e],-o[e]);const i=A(r[n],o[n]);x(t.atoms,-i),r[t.meta.rNodes[1]-1]<0&&E(t);const s=function(t){const e=function(t){const e=new Map;for(const n of t.bonds.atomPairs)for(let t=0;t<2;t++){const r=n[t],o=n[(t+1)%2];e.has(r)?e.get(r)?.push(o):e.set(r,new Array(1).fill(o))}return e}(t);let n=0;const r=t.atoms.atomTypes.length;let o=0;if(t.meta.terminalNodes.length<2)return null;for(;0===n;){const i=e.get(t.meta.terminalNodes[1])[o];if(t.atoms.atomTypes[i-1]===f.u.OXYGEN&&i!==t.meta.rNodes[1]&&(n=i),o++,o>r)return null}return n}(t);null!=s&&(function(t,e){t.atoms.y[t.meta.rNodes[1]-1]<0&&t.atoms.y[e-1]<0&&(function(t){T(t,!0)}(t),x(t.atoms,-function(t,e){return A(t,e)+Math.PI/2}(t.atoms.x[t.meta.terminalNodes[1]-1],t.atoms.y[t.meta.terminalNodes[1]-1])))}(t,s),function(t,e){const n=t.atoms.x;n[t.meta.rNodes[1]-1]>n[e-1]&&function(t,e,n){const r=e-1,o=n-1,i=t.atoms.x,s=t.atoms.y,a=i[r],l=s[r];i[r]=i[o],s[r]=s[o],i[o]=a,s[o]=l}(t,e,t.meta.rNodes[1])}(t,s))}(v):t===f.u.RIBOSE.symbol||t===f.u.DEOXYRIBOSE.symbol?function(t,e){const n=t.atoms.x,r=t.atoms.y;let o=t.meta.terminalNodes[0]-1;const i=t.meta.rNodes[1]-1;S(t,-n[o],-r[o]);const s=A(n[t.meta.rNodes[2]-1],r[t.meta.rNodes[2]-1]);x(t.atoms,-s),n[t.meta.rNodes[0]-1]>n[t.meta.rNodes[1]-1]&&E(t);const a=A(n[i],r[i]);x(t.atoms,3*Math.PI/2-a),e.value=function(t){const e=t.atoms.x,n=t.atoms.y,r=t.meta.rNodes[2]-1,o=t.meta.terminalNodes[2]-1,i=e[r]-e[o],s=n[r]-n[o];return Math.atan2(i,s)}(t),o=t.meta.terminalNodes[0]-1,S(t,-n[o],-r[o])}(v,o):t===f.u.PHOSPHATE.symbol?function(t){const e=t.meta.rNodes[1]-1,n=t.meta.rNodes[0]-1,r=t.atoms.x,o=t.atoms.y;S(t,-r[e],-o[e]);const i=A(r[n],o[n]);x(t.atoms,Math.PI/2-i)}(v):function(t,e){const n=t.atoms.x,r=t.atoms.y,o=t.meta.terminalNodes[0]-1,i=t.meta.rNodes[0]-1;S(t,-n[o],-r[o]);const s=A(n[i],r[i]),a=e.value;if(!a)throw new Error("The value of sugarBranchToOYAngle is null");x(t.atoms,Math.PI-s+a);const u=function(t,e){return(0,l.YN)(Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2))}({x:n[t.meta.rNodes[0]-1],y:r[t.meta.rNodes[0]-1]},{x:n[t.meta.terminalNodes[0]-1],y:r[t.meta.terminalNodes[0]-1]});if(1!=u)for(let t=0;t<n.length;++t)n[t]=(0,l.YN)(n[t]/u),r[t]=(0,l.YN)(r[t]/u)}(v,o),function(t,e,n){if("PEPTIDE"===t){b(e,t);const n=C(e,e.meta.rNodes[1]);n?.removedAtom&&(e.terminalR2Atom=n.removedAtom)}else n===f.u.RIBOSE.symbol||n===f.u.DEOXYRIBOSE.symbol?(C(e,e.meta.rNodes[1]),e.meta.rNodes[1]=e.meta.terminalNodes[1],y(e.bonds,e.meta),b(e,t),C(e,e.meta.rNodes[1]),C(e,e.meta.rNodes[0]),C(e,e.meta.rNodes[2])):n===f.u.PHOSPHATE.symbol&&(e.meta.terminalNodes[0]=e.meta.rNodes[0],S(e,-e.atoms.x[e.meta.terminalNodes[0]-1],-e.atoms.y[e.meta.terminalNodes[0]-1]),b(e,t),C(e,e.meta.rNodes[1]))}(r,v,t),function(t){let e=0;for(;e<t.atoms.atomTypes.length;)t.atoms.atomTypes[e]===f.u.HYDROGEN&&(C(t,e+1),--e),++e}(v),function(t){let e=0;for(;e<t.atoms.atomTypes.length;)"oh"===t.atoms.atomTypes[e]?.toLowerCase()&&(t.atoms.atomTypes[e]="O"),"?"===t.atoms.atomTypes[e]&&(t.atoms.atomTypes[e]="H"),++e}(v),function(t){const e=" RGROUPS=(1 1)";for(let n=0;n<(t.atoms.kwargs?.length??0);n++){const r=t.atoms.kwargs[n];r&&r.includes(e)&&(t.atoms.kwargs[n]=r.replace(e,""))}}(v),v}var i;return null}(e,n,r,o,i);if(!a)throw new Error(`Monomer with symbol '${e}' is absent the monomer library`);(0,c.LQ)(t,s,a)}}function y(t,e){const n=e.rNodes;e.terminalNodes=new Array(n.length).fill(0);const r=e.terminalNodes,o=t.atomPairs;let i=0,s=0;for(;i<o.length&&s<r.length;){for(let t=0;t<r.length;++t)for(let e=0;e<2;++e)o[i][e]===n[t]&&(r[t]=o[i][(e+1)%2],n.length,++s);++i}}function b(t,e){t.meta.rNodes.length>1&&(t.meta.backboneShift=v(t,t.meta.rNodes[1]-1,t.meta.terminalNodes[0]-1)),"RNA"===e&&t.meta.rNodes.length>2&&(t.meta.branchShift=v(t,t.meta.rNodes[2]-1,t.meta.terminalNodes[0]-1))}function v(t,e,n){return[(0,l.YN)(t.atoms.x[e]-t.atoms.x[n]),(0,l.YN)(t.atoms.y[e]-t.atoms.y[n])]}function C(t,e){if(void 0!==e){const n=e-1,r=t.atoms,o=t.bonds,i=t.meta,s=r.atomTypes.splice(n,1)[0];r.x=w(Float32Array,r.x,n,1),r.y=w(Float32Array,r.y,n,1),r.kwargs.splice(n,1);for(let t=0;t<i.terminalNodes.length;++t)i.terminalNodes[t]>e?--i.terminalNodes[t]:i.terminalNodes[t]===e&&(i.terminalNodes[t]=-1);for(let t=0;t<i.rNodes.length;++t)i.rNodes[t]>e?--i.rNodes[t]:i.rNodes[t]===e&&(i.rNodes[t]=-1);let a=0;for(;a<o.atomPairs.length;){const t=o.atomPairs[a][0],n=o.atomPairs[a][1];t===e||n===e?(o.atomPairs.splice(a,1),o.bondTypes=w(Uint32Array,o.bondTypes,a,1),o.bondConfiguration.has(a)&&o.bondConfiguration.delete(a),o.kwargs.has(a)&&o.kwargs.delete(a),--a):(o.atomPairs[a][0]=t>e?t-1:t,o.atomPairs[a][1]=n>e?n-1:n),++a}let l=Array.from(o.bondConfiguration.keys());return l.forEach((t=>{if(o.bondConfiguration.has(t)&&t>n){const e=o.bondConfiguration.get(t);o.bondConfiguration.delete(t),o.bondConfiguration.set(t-1,e)}})),l=Array.from(o.kwargs.keys()),l.forEach((t=>{if(o.kwargs.has(t)&&t>n){const e=o.kwargs.get(t);o.kwargs.delete(t),o.kwargs.set(t-1,e)}})),s?{removedAtom:s}:void 0}}function w(t,e,n,r){const o=new t(e.length-r);let i=0,s=0;for(;i<e.length;)i===n&&(i+=r),o[s]=e[i],++s,++i;return o}function A(t,e){let n;if(0===t)n=e>0?0:Math.PI;else if(0===e)n=t>0?-Math.PI/2:Math.PI/2;else{const r=e/t,o=Math.atan(r);n=t<0?Math.PI/2+o:-Math.PI/2+o}return n}function x(t,e){if(0!==e){const n=t.x,r=t.y,o=Math.cos(e),i=Math.sin(e);for(let t=0;t<n.length;++t){const e=n[t];n[t]=(0,l.YN)(e*o-r[t]*i),r[t]=(0,l.YN)(e*i+r[t]*o)}}}function E(t){T(t,!1)}function T(t,e){if(e){const e=t.atoms.y;for(let t=0;t<e.length;t++)e[t]=-e[t]}else{const e=t.atoms.x;for(let t=0;t<e.length;t++)e[t]=-e[t]}const n=t.bonds.bondConfiguration;for(const[t,e]of n){const r=1===e?3:1;n.set(t,r)}}function S(t,e,n){const r=t.atoms.x,o=t.atoms.y;for(let t=0;t<r.length;++t)r[t]=(0,l.YN)(r[t]+e),void 0!==n&&(o[t]=(0,l.YN)(o[t]+n))}},294:(t,e,n)=>{"use strict";function r(t,e){return t[e.polymerType]?.[e.symbol]}function o(t,e){return!!t[e.polymerType]?.[e.symbol]}function i(t,e,n){let r=t[e.polymerType];r||(r=t[e.polymerType]={}),r[e.symbol]=n}n.d(e,{Cg:()=>s,LQ:()=>i,bq:()=>o,vF:()=>a,xb:()=>r});class s extends Map{constructor(t){super(t)}}class a{constructor(t,e){this.molfile=t,this.monomers=e}static createEmpty(){return new a("",new s(null))}}},330:(t,e,n)=>{"use strict";n.d(e,{pz:()=>i,qj:()=>o,vG:()=>s});var r=n(2003);function o(t,e){return function(t,e){return t?t.columns.getUnusedName(e):e}(t,`molfile(${e})`)}function i(t){let e;if(t===r.YI.PT||t===r.YI.UN)e="PEPTIDE";else{if(t!==r.YI.RNA&&t!==r.YI.DNA)throw new Error(`Unexpected alphabet '${t}'.`);e="RNA"}return e}function s(t){const e=7===t.length?/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t):/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return e?[parseInt(e[1],16)/256,parseInt(e[2],16)/256,parseInt(e[3],16)/256,e.length>4?parseInt(e[4],16)/256:.3]:null}},4971:(t,e,n)=>{"use strict";n.d(e,{pj:()=>o});var r=n(6082);async function o(){const t=r.Func.find({package:"Bio",name:"getMonomerLibHelper"});if(0===t.length)throw new Error('Package "Bio" must be installed for MonomerLibHelper.');return(await t[0].prepare().call()).getOutputParamValue()}},3151:(t,e,n)=>{"use strict";n.d(e,{f6:()=>r,pe:()=>o});const r=["symbol","molfile","rgroups","name"],o={monomerType:"Backbone",smiles:"",name:"",author:"Datagrok",molfile:"",naturalAnalog:"",rgroups:[],createDate:null,id:0,polymerType:"PEPTIDE",symbol:""};new RegExp("[rd]\\((\\w)\\)p?","g")},9192:(t,e,n)=>{"use strict";function r(t){return"string"==typeof t||t instanceof String?t:"StateError"===t.constructor.name?t.message:"StateError"===t.constructor.name&&"$thrownJsError"in t?r(t.$thrownJsError):t instanceof Error?t.message:t.toString()}function o(t){return t instanceof Error?t.stack:"StateError"===t.constructor.name&&"$thrownJsError"in t?o(t.$thrownJsError):void 0}function i(t){return[r(t),o(t)]}n.d(e,{AP:()=>i})},439:(t,e,n)=>{"use strict";n.d(e,{Hi:()=>r,YI:()=>o,_S:()=>l,b9:()=>u,gp:()=>i});var r,o,i,s=n(2738);!function(t){t.FASTA="fasta",t.SEPARATOR="separator",t.HELM="helm",t.CUSTOM="custom",t.BILN="biln"}(r||(r={})),function(t){t.DNA="DNA",t.RNA="RNA",t.PT="PT",t.UN="UN"}(o||(o={})),function(t){t.aligned="aligned",t.alphabet="alphabet",t.alphabetSize=".alphabetSize",t.alphabetIsMultichar=".alphabetIsMultichar",t.separator="separator",t.isHelmCompatible=".isHelmCompatible",t.positionNames=".positionNames",t.positionLabels=".positionLabels",t.regions=".regions",t.positionShift=".positionShift",t.selectedPosition=".selectedPosition",t.polymerTypeColumnName=".polymerTypeColumnName"}(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.a(o.PT,a.fasta.peptide,.5),new s.a(o.DNA,a.fasta.dna,.55),new s.a(o.RNA,a.fasta.rna,.55),""),u={[r.FASTA]:"-",[r.SEPARATOR]:"",[r.HELM]:"*",[r.BILN]:""}},2003:(t,e,n)=>{"use strict";n.d(e,{Hi:()=>r.Hi,YI:()=>r.YI,dh:()=>o.dh,gp:()=>r.gp,zS:()=>o.zS});var r=n(439),o=n(7291)},2738:(t,e,n)=>{"use strict";n.d(e,{a:()=>r});class r{constructor(t,e,n){this.name=t,this.alphabet=e,this.cutoff=n}}},7291:(t,e,n)=>{"use strict";n.d(e,{Mu:()=>y,dh:()=>v,zS:()=>A,qp:()=>C});var r=n(6082),o=n(1991),i=n.n(o),s=(n(2738),n(439));class a{static makePalette(t,e=!1,n=a){const r={};return t.forEach((t=>{const n=t[0],o=t[1];n.forEach(((t,n)=>{r[t]=this.colourPalette[o][e?0:n]}))})),new n(r)}constructor(t){this._palette=t}get(t,e){return this._palette[t]}}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(t){const e=t in l.aaSynonyms?l.aaSynonyms[t]:t;return super.get(e)}}l.aaSynonyms={MeNle:"L",MeA:"A",MeG:"G",MeF:"F"};class u{static getPalette(t="grok"){switch(t){case"grok":return l.GrokGroups;case"lesk":return l.Lesk;default:throw new Error(`ChemPalette: scheme \`${t}\` does not exist`)}}static getInnerOuter(t){let e=0,n="",r="";for(const o of t)"("==o?e++:")"==o?e--:e?n+=o:r+=o;return isNaN(parseInt(n))?[r,n]:[r,""]}static getColorAAPivot(t="",e="grok"){const n=this.getPalette(e);let[r,o]=this.getInnerOuter(t);if(r=r.length>6?`${r.slice(0,3)}...`:r,o=o.length>6?`${o.slice(0,3)}...`:o,1==t.length||"("==t[1]){const e=t[0]?.toUpperCase();return e in n?[n.get(e),e,o,1]:[this.undefinedColor,r,o,1]}if("d"==t[0]&&t[1]in n&&(2==t.length||"("==t[2])){const e=t[1]?.toUpperCase();return e in n?[n.get(e),e,o,2]:[this.undefinedColor,r,o,2]}if(t.substring(0,3)in this.AAFullNames&&(3==t.length||"("==t[3])){const e=this.AAFullNames[t.substring(0,3)];return e in n?[n.get(e),e,o,3]:[this.undefinedColor,r,o,3]}if(t[0]?.toLowerCase()==t[0]&&t.substring(1,3)in this.AAFullNames&&(4==t.length||"("==t[4])){const e=this.AAFullNames[t.substring(1,3)];return e in n?[n.get(e),e,o,4]:[this.undefinedColor,r,o,4]}return[this.undefinedColor,r,o,0]}}u.SemType="Aminoacids",u.SemTypeMultipleAlignment="AminoacidsMultipleAlignment",u.undefinedColor="rgb(100,100,100)",u.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"},u.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"},u.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(*)*"},u.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 c{}c.SemType="Nucleotides",c.SemTypeMultipleAlignment="NucleotidesMultipleAlignment",c.Names={A:"Adenine",C:"Cytosine",G:"Guanine",T:"Thymine",U:"Uracil"};var h=n(4971);function d(t,e=!0){if(null==t)return"rgb(100,100,100)";const n=r.Color.fromHtml(t);if(e){const t=r.Color.g(n),e=r.Color.r(n),o=r.Color.b(n),i=Math.sqrt(Math.pow(0-e,2)+Math.pow(0-t,2)+Math.pow(0-o,2));if(i>210)return`rgb(${e/i*210},${t/i*210},${o/i*210})`}return r.Color.toRgb(n)}class f{static hashCode(t){let e=0;if(0===t.length)return e;for(let n=0;n<t.length;n++)e=(e<<5)-e+t.charCodeAt(n),e|=0;return e}}class p{}class m extends p{static get palette(){return m._pallete||(m._pallete=m.buildPalette()),m._pallete}static buildPalette(){return(0,h.pj)().then((t=>{t.awaitLoaded(1/0).then((()=>{const e=t.getMonomerLib();e.onChanged.subscribe((()=>{m.customMonomerColors={},m.polymerTypes=e.getPolymerTypes();for(const t of this.polymerTypes){const n=e.getMonomerSymbolsByType(t);for(const r of n){const n=e.getMonomer(t,r);n?.meta?.colors?.default?.background&&(this.customMonomerColors[r]||(this.customMonomerColors[r]={}),this.customMonomerColors[r][t]=d(n.meta.colors.default.background))}}}))}))})),[].concat(...Object.values(a.colourPalette))}get(t,e){const n=m.palette.length,r=m.customMonomerColors[t],o=e??"PEPTIDE";if(r&&r[o])return r[o];const i=f.hashCode(t)%n;return d(m.palette[i])}}m._pallete=null,m.customMonomerColors={},m.polymerTypes=[];var g=n(8438);n(3599);class y{get length(){return this.mList.length}get graphInfo(){}isGap(t){return this.getOriginal(t)===this.gapOriginalMonomer}getCanonical(t){if(this.length<=t)throw new Error("Index out of bounds");const e=this.mList[t];return e!==this.gapOriginalMonomer?e:s._S}getOriginal(t){if(this.length<=t)throw new Error("Index out of bounds");return this.mList[t]}getCanonicalRegion(t,e){const n=Math.min(Math.max(0,t),this.length),r=Math.max(Math.min(this.length,e),0)-n,o=this.gapOriginalMonomer;return new Array(r).fill(null).map(((t,e)=>{const r=this.mList[e+n];return r===o?s._S:r}))}getOriginalRegion(t,e){const n=Math.min(Math.max(0,t),this.length),r=Math.max(Math.min(this.length,e),0);return new Array(r-n).fill(null).map(((t,e)=>this.mList[e+n]))}get gapOriginal(){return this.gapOriginalMonomer}constructor(t,e){this.mList=t,this.gapOriginalMonomer=e}}class b extends y{constructor(t,e,n,r){super(t.flat(),r),this.mListSeparated=t,this.connections=e,this._graphInfo=void 0,this.polymerTypes=t.map(((t,e)=>new Array(t.length).fill(n[e]))).flat()}get graphInfo(){return this._graphInfo??(this._graphInfo=this.parseConnections()),this._graphInfo}parseConnections(){const t={connections:[],disjointSeqStarts:[],polymerTypes:this.polymerTypes};if((this.connections?.length??0)>0){let e=0;for(let n=0;n<this.mListSeparated.length;++n)t.disjointSeqStarts.push(e),e+=this.mListSeparated[n].length;const n=(this.connections??"").split("|").filter((t=>(t?.length??0)>0)),r=/^(PEPTIDE|RNA|BLOB|CHEM)\d{1,2}$/,o=/^\d{1,2}:R\d{1}-\d{1,2}:R\d{1}$/;for(const e of n){const n=e.split(",");if(3!==n.length||!o.test(n[2])||!r.test(n[0])||!r.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 u=n[2].split("-");if(2!==u.length)continue;const c=u[0].split(":"),h=u[1].split(":");if(2!==c.length||2!==h.length)continue;const d=parseInt(c[0])-1,f=parseInt(h[0])-1;d<0||d>=this.mListSeparated[i].length||f<0||f>=this.mListSeparated[s].length||t.connections.push({seq1Type:a,seq2Type:l,seqIndex1:i,seqIndex2:s,monomerIndex1:d,monomerIndex2:f,rGroup1:parseInt(c[1].substring(1)),rGroup2:parseInt(h[1].substring(1))})}}return t}}function v(t,e=void 0){return n=>{if(n){let r;const o=new RegExp(`(?<=^|\\${t})("-"|'-'|[^\\${t}]*)(?=\\${t}|$)`,"g");return null!=e?(o.lastIndex=0,r=i()(n.matchAll(o)).take(e).map((t=>t[0])).toArray()):r=n.replaceAll('"-"',"").replaceAll("'-'","").split(t,e),new y(r,s.b9[s.Hi.SEPARATOR])}return new y([],s.b9[s.Hi.SEPARATOR])}}const C=t=>{const e=t.indexOf("}$"),n=t.substring(0,e+1),r=t.indexOf("$",e+2),o=t.substring(e+2,r),i=n.split("}|");for(let t=0;t<i.length-1;t++)i[t]=i[t]+"}";const a=i.map((t=>(t.match(/(?<=\{).+(?=})/)?.[0]?.split(".")??[]).map((t=>(0,g.D)(t))))),l=i.map((t=>t.replace(/\d{1,2}\{.+\}/,"")));return new b(a,o??"",l,s.b9[s.Hi.HELM])},w=/([^\W_]+)/g;function A(t,e){if(t.length<=e)return t;const n=t.match(w),r=t.length>e||(n?.length??0)>1,o=n?.[0]??" ";return r?o.substring(0,e-1)+"…":o}},8312:(t,e,n)=>{"use strict";n.d(e,{Q:()=>o});var r=n(6082);async function o(){const t=r.Func.find({package:"Bio",name:"getSeqHelper"});if(0===t.length)throw new Error("Package 'Bio' must be installed for SeqHelper.");return(await t[0].prepare().call()).getOutputParamValue()}},6869:(t,e,n)=>{"use strict";var r;n.d(e,{o:()=>r}),function(t){t.BASE="HELM_BASE",t.SUGAR="HELM_SUGAR",t.LINKER="HELM_LINKER",t.AA="HELM_AA",t.CHEM="HELM_CHEM",t.BLOB="HELM_BLOB",t.NUCLEOTIDE="HELM_NUCLETIDE"}(r||(r={}))},8070:(t,e,n)=>{"use strict";n.d(e,{Pl:()=>M,gM:()=>P,L1:()=>N,cb:()=>k,E3:()=>T,J6:()=>_,Xk:()=>I,Xb:()=>O,N$:()=>R,t6:()=>E,PE:()=>x,CN:()=>f});var r=n(4328),o=n(6082);n(9982);const i=o.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,,,,,,,,,,,,,,,,,,,,,');i.columns.add(o.Column.fromList(o.TYPE.BYTE_ARRAY,"BinaryImage",Array.from(new Uint8Array(11))));var s=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{l(r.next(t))}catch(t){i(t)}}function a(t){try{l(r.throw(t))}catch(t){i(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}l((r=r.apply(t,e||[])).next())}))};const a=3e4,l=108e5,u=console.log.bind(console),c=console.info.bind(console),h=console.warn.bind(console),d=console.error.bind(console),f={},p="Auto Tests",m="Demo",g="Detectors",y="Core",b={};let v;var C;!function(t){t.notNull=function(t,e){if(null==t)throw new Error(`${null==e?"Value":e} not defined`)}}(C||(C={}));class w{constructor(t,e){this.catchUnhandled=!0,this.report=!1,void 0!==t&&(this.catchUnhandled=t),void 0!==e&&(this.report=e)}}class A{constructor(t,e,n,r){var i;this.category=t,this.name=e,null!=r||(r={}),null!==(i=r.timeout)&&void 0!==i||(r.timeout=a),this.options=r,this.test=()=>s(this,void 0,void 0,(function*(){return new Promise(((t,e)=>s(this,void 0,void 0,(function*(){var r;let i="";try{o.Test.isInDebug;let t=yield n();try{i=null!==(r=null==t?void 0:t.toString())&&void 0!==r?r:""}catch(t){i="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(t){e(t)}t(i)}))))}))}}function x(t,e,n,r=0,o="timeout"){return s(this,void 0,void 0,(function*(){return new Promise(((i,s)=>{const a=t.subscribe((t=>{try{e(t),i("OK")}catch(t){s(t)}finally{a.unsubscribe(),clearTimeout(l)}})),l=setTimeout((()=>{a.unsubscribe(),s(o)}),r);n()}))}))}function E(t,e,n){null==f[v]&&(f[v]={}),null==f[v].tests&&(f[v].tests=[]),f[v].tests.push(new A(v,t,e,n))}function T(t,e=!0,n){if(n=n?`${n}, `:"",t!==e)throw new Error(`${n}Expected "${e}", got "${t}"`)}function S(t,e,n=.001,r){if(t===Number.POSITIVE_INFINITY&&e===Number.POSITIVE_INFINITY||t===Number.NEGATIVE_INFINITY&&e===Number.NEGATIVE_INFINITY||t===Number.NaN&&e===Number.NaN||isNaN(t)&&isNaN(e))return;const o=Math.abs(t-e)<n;if(T(o,!0,`${null!=r?r:""} (tolerance = ${n})`),!o)throw new Error(`Expected ${e}, got ${t} (tolerance = ${n})`)}function I(t,e){for(const[n,r]of Object.entries(e)){if(!t.hasOwnProperty(n))throw new Error(`Expected property "${n}" not found`);const e=t[n];if(e instanceof Array&&r instanceof Array)_(e,r);else if(e instanceof Object&&r instanceof Object)I(e,r);else if(Number.isFinite(e)&&Number.isFinite(r))S(e,r);else if(e!=r)throw new Error(`Expected (${r}) for key '${n}', got (${e})`)}}function _(t,e){const n=t.length,r=e.length;if(n!=r)throw new Error(`Arrays are of different length: actual array length is ${n} and expected array length is ${r}`);for(let r=0;r<n;r++)if(t[r]instanceof Array&&e[r]instanceof Array)_(t[r],e[r]);else if(t[r]instanceof Object&&e[r]instanceof Object)I(t[r],e[r]);else if(t[r]!=e[r])throw new Error(`Expected ${e[r]} at position ${r}, got ${t[r]}`)}function N(t,e,n){var r;v=t,e(),f[v]&&(f[v].clear=null===(r=null==n?void 0:n.clear)||void 0===r||r,f[v].timeout=null==n?void 0:n.timeout,f[v].benchmarks=null==n?void 0:n.benchmarks,f[v].stressTests=null==n?void 0:n.stressTests,f[v].owner=null==n?void 0:n.owner)}function P(t){null==f[v]&&(f[v]={}),f[v].before=t}function M(t){null==f[v]&&(f[v]={}),f[v].after=t}function L(t,e){return t.replace(new RegExp(e.name,"gi"),e.nqName)}function O(t,e){var n,u,c,h,d,v,C,w,x,E;return s(this,void 0,void 0,(function*(){const S=t.id;if(b[S])return;const I=e?e.tests:f;if("DevTools"===t.name||e&&"DevTools"===e._package.name)for(const t of window.dartTests){const e=t.name.split(/\s*\|\s*!/g);let r=null!==(n=e.pop())&&void 0!==n?n:t.name,o=e.length?y+": "+e.join(": "):y,i=r.split(" | ");r=i[i.length-1],i.unshift(o),i.pop(),o=i.join(": "),void 0===I[o]&&(I[o]={tests:[],clear:!0}),I[o].tests.push(new A(o,r,t.test,{isAggregated:!1,timeout:null!==(c=null===(u=t.options)||void 0===u?void 0:u.timeout)&&void 0!==c?c:a,skipReason:null===(h=t.options)||void 0===h?void 0:h.skipReason,owner:null===(d=t.options)||void 0===d?void 0:d.owner,benchmark:null!==(C=null===(v=t.options)||void 0===v?void 0:v.benchmark)&&void 0!==C&&C}))}const _=[],N=[],P=[],M=yield r.dapi.functions.filter(`package.id = "${S}"`).list(),O=new RegExp(/skip:\s*([^,\s]+)|wait:\s*(\d+)|cat:\s*([^,\s]+)|timeout:\s*(\d+)/g);for(const e of M){const n=e.options.test,u=e.options.demoPath;if(n&&Array.isArray(n)&&n.length)for(let t=0;t<n.length;t++){const i=n[t].matchAll(O),u={};Array.from(i).forEach((t=>{t[0].startsWith("skip")?u.skip=t[1]:t[0].startsWith("wait")?u.wait=parseInt(t[2]):t[0].startsWith("cat")?u.cat=t[3]:t[0].startsWith("timeout")&&(u.timeout=parseInt(t[4]))}));const c=new A(null!==(w=u.cat)&&void 0!==w?w:p,1===n.length?e.name:`${e.name} ${t+1}`,(()=>s(this,void 0,void 0,(function*(){const o=yield r.functions.eval(L(n[t],e));if(u.wait&&(yield k(u.wait)),"boolean"==typeof o&&!o)throw`Failed: ${n[t]}, expected true, got ${o}`}))),{skipReason:u.skip,timeout:o.Test.isInBenchmark?null!==(x=u.benchmarkTimeout)&&void 0!==x?x:l:null!==(E=u.timeout)&&void 0!==E?E:a});if(u.cat){const t=u.cat;void 0===I[t]&&(I[t]={tests:[],clear:!0}),I[t].tests||(I[t].tests=[]),I[t].tests.push(c)}else _.push(c)}if(u){const t=e.options.demoWait?parseInt(e.options.demoWait):void 0,n=new A(m,e.friendlyName,(()=>s(this,void 0,void 0,(function*(){yield k(300),r.shell.clearLastError(),yield e.apply(),yield k(t||2e3);const n=yield r.shell.lastError;if(n)throw new Error(n)}))),{skipReason:e.options.demoSkip});N.push(n)}if(e.hasTag("semTypeDetector")){let n=i;e.options.testData&&(n=yield r.data.files.openTable(`System:AppData/${t.nqName}/${e.options.testData}`));const o=new A(g,e.friendlyName,(()=>s(this,void 0,void 0,(function*(){const r=[];console.log(`System:AppData/${t.nqName}/${e.options.testData}`);for(const t of n.clone().columns){const n=yield e.apply([t]);r.push(n||t.semType)}const o=r.filter((t=>t));T(o.length,1),e.options.testDataColumnName&&T(o[0],e.options.testDataColumnName)}))),{skipReason:e.options.skipTest});P.push(o)}}b[S]=!0,_.length>0&&(I[p]={tests:_,clear:!0}),N.length>0&&(I[m]={tests:N,clear:!0}),P.length>0&&(I[g]={tests:P,clear:!1})}))}function R(t){var e,n,i,p,m,g;return s(this,void 0,void 0,(function*(){console.log("--------------------");const y=null===(n=null===(e=r.functions.getCurrentCall())||void 0===e?void 0:e.func)||void 0===n?void 0:n.package,b=(null!==(p=(null!==(i=null==y?void 0:y.packageOwner)&&void 0!==i?i:"").match(new RegExp("[^<]*<([^>]*)>")))&&void 0!==p?p:["",""])[1];yield O(y);const v=[];console.log("Running tests"),console.log(t),null!=t||(t={}),null!==(m=(g=t).testContext)&&void 0!==m||(g.testContext=new w),r.shell.clearLastError();const C=function(){const t=[];return console.log=(...e)=>{t.push(...e),u(...e)},console.info=(...e)=>{t.push(...e),c(...e)},console.warn=(...e)=>{t.push(...e),h(...e)},console.error=(...e)=>{t.push(...e),d(...e)},t}();yield function(t,e){var n,i,a,l,f,p,m;return s(this,void 0,void 0,(function*(){try{for(const[r,c]of Object.entries(t)){if(!(null==e?void 0:e.category)||(null===(n=e.exclude)||void 0===n?void 0:n.some((t=>r.startsWith(t)))))continue;if((!r.toLowerCase().startsWith(`${null==e?void 0:e.category.toLowerCase().trim()} :`)||e.test)&&r.toLowerCase().trim()!==(null==e?void 0:e.category.toLowerCase().trim()))continue;u(`Started ${r} category`);const t=null===(i=c.tests)||void 0===i?void 0:i.every((t=>{var e;return null===(e=t.options)||void 0===e?void 0:e.skipReason}));t||(c.beforeStatus=yield A(c.before,null!==(a=e.category)&&void 0!==a?a:""));let h,d=null!==(l=c.tests)&&void 0!==l?l:[];e.stressTest&&(d=d.filter((t=>{var e;return null===(e=t.options)||void 0===e?void 0:e.stressTest})),d=$(d)),(null!==(p=null===(f=e.tags)||void 0===f?void 0:f.length)&&void 0!==p?p:0)>0&&(d=d.filter((t=>{var n,r;return null===(r=null===(n=t.options)||void 0===n?void 0:n.tags)||void 0===r?void 0:r.some((t=>{var n;return(null!==(n=null==e?void 0:e.tags)&&void 0!==n?n:[]).includes(t)}))}))),c.beforeStatus?(h=Array.from(d.map((t=>({date:(new Date).toISOString(),category:r,name:t.name,success:!1,result:"before() failed",ms:0,skipped:!1,logs:"",owner:null==y?void 0:y.packageOwner,package:y.name,widgetsDifference:0,flaking:o.Test.isReproducing})))),h.forEach((t=>s(this,void 0,void 0,(function*(){return D("package",t)}))))):h=yield x(c,e);const g=h.filter((t=>"skipped"!=t.result));t||(c.afterStatus=yield A(c.after,null!==(m=e.category)&&void 0!==m?m:"")),c.afterStatus&&g.push({date:(new Date).toISOString(),category:r,name:"after",success:!1,result:c.afterStatus,ms:0,skipped:!1,logs:"",owner:null==y?void 0:y.packageOwner,package:y.name,widgetsDifference:0,flaking:o.Test.isReproducing}),c.beforeStatus&&g.push({date:(new Date).toISOString(),category:r,name:"before",success:!1,result:c.beforeStatus,ms:0,skipped:!1,logs:"",owner:null==y?void 0:y.packageOwner,package:y.name,widgetsDifference:0,flaking:o.Test.isReproducing}),v.push(...g)}}finally{console.log=u,console.info=c,console.warn=h,console.error=d}if(e.testContext.catchUnhandled&&!o.Test.isInBenchmark){yield k(1e3);const t=yield r.shell.lastError,e={logs:"",date:(new Date).toISOString(),category:"Unhandled exceptions",name:"Exception",result:null!=t?t:"",success:!t,ms:0,skipped:!1,owner:null!=b?b:"",package:y.name,widgetsDifference:0};v.push(Object.assign(Object.assign({},e),{flaking:o.Test.isReproducing&&!t})),e.package=y.name,yield D("package",e)}}))}(f,t);for(let t of v)t.result=t.result.toString().replace(/"/g,"'"),null!=t.logs&&(t.logs=t.logs.toString().replace(/"/g,"'"));return v;function A(t,e){return s(this,void 0,void 0,(function*(){let n;try{void 0!==t&&(yield H((()=>s(this,void 0,void 0,(function*(){yield t()}))),1e5,`before ${e}: timeout error`))}catch(t){n=yield B(t)}return n}))}function x(t,e){var n,i,u,c,h,d,f,p,m,g,v,w,A,x,T,S,I,_;return s(this,void 0,void 0,(function*(){let s=null!==(n=t.tests)&&void 0!==n?n:[];const N=[],P=E();if(t.clear)for(let n=0;n<s.length;n++){s[n].options&&void 0===(null===(i=s[n].options)||void 0===i?void 0:i.benchmark)&&(s[n].options||(s[n].options={}),s[n].options.benchmark=null!==(u=t.benchmarks)&&void 0!==u&&u);let w=s[n];if(e.test&&e.test.toLowerCase()!==w.name.toLowerCase())continue;(null==w?void 0:w.options)&&(w.options.owner=null!==(f=null!==(d=null!==(h=null===(c=s[n].options)||void 0===c?void 0:c.owner)&&void 0!==h?h:null==t?void 0:t.owner)&&void 0!==d?d:b)&&void 0!==f?f:"");let A=yield F(w,null==e?void 0:e.test,C,o.Test.isInBenchmark?null!==(m=null===(p=s[n].options)||void 0===p?void 0:p.benchmarkTimeout)&&void 0!==m?m:l:null!==(v=null===(g=s[n].options)||void 0===g?void 0:g.timeout)&&void 0!==v?v:a,y.name,e.verbose);A&&N.push(Object.assign(Object.assign({},A),{widgetsDifference:E()-P})),r.shell.closeAll(),o.Balloon.closeAll()}else for(let n=0;n<s.length;n++){let r=s[n];if(e.test&&e.test.toLowerCase()!==r.name.toLowerCase())continue;(null==r?void 0:r.options)&&(r.options.owner=null!==(T=null!==(x=null!==(A=null===(w=s[n].options)||void 0===w?void 0:w.owner)&&void 0!==A?A:null==t?void 0:t.owner)&&void 0!==x?x:b)&&void 0!==T?T:"");let i=yield F(r,null==e?void 0:e.test,C,o.Test.isInBenchmark?null!==(I=null===(S=s[n].options)||void 0===S?void 0:S.benchmarkTimeout)&&void 0!==I?I:l:null===(_=s[n].options)||void 0===_?void 0:_.timeout,y.name,e.verbose);i&&N.push(Object.assign(Object.assign({},i),{widgetsDifference:E()-P}))}return N}))}function E(){var t;let e=-1;try{e=o.Widget.getAll().length}catch(e){console.warn(null!==(t=e.message)&&void 0!==t?t:e)}return e}}))}function D(t,e){return s(this,void 0,void 0,(function*(){null!=r.shell.reportTest?yield r.shell.reportTest(t,e):yield fetch(`${r.dapi.root}/log/tests/${t}`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"same-origin",body:JSON.stringify(e)})}))}function B(t){return s(this,void 0,void 0,(function*(){return`${t.toString()}\n${t.stack?yield o.Logger.translateStackTrace(t.stack):""}`}))}function F(t,e,n,i,l,c){var h,f,p,m,g,y,b,v,C,w,A,x,T,S;return s(this,void 0,void 0,(function*(){let s;n.length=0;const I=null!=e&&t.name.toLowerCase()!==e.toLowerCase();let _=(null===(h=t.options)||void 0===h?void 0:h.skipReason)||I,N=I?"skipped":null===(f=t.options)||void 0===f?void 0:f.skipReason;if(console.log(E.name,_),o.Test.isInBenchmark&&!(null===(p=t.options)||void 0===p?void 0:p.benchmark))return void u(`SKIPPED: ${t.category} ${t.name} doesnt available in benchmark mode`);_||u(`Started ${t.category} ${t.name}`);const P=Date.now(),M=new Date(P).toISOString();try{if(_)s={name:t.name,owner:null!==(g=null===(m=t.options)||void 0===m?void 0:m.owner)&&void 0!==g?g:"",category:t.category,logs:"",date:M,success:!0,result:N,ms:0,skipped:!0,package:null!=l?l:"",flaking:o.Test.isReproducing};else{let e=null!=i?i:a;o.Test.isProfiling&&console.profile(`${t.category}: ${t.name}`),s={name:t.name,owner:null!==(b=null===(y=t.options)||void 0===y?void 0:y.owner)&&void 0!==b?b:"",category:t.category,logs:"",date:M,success:!0,result:null!==(v=(yield H(t.test,e)).toString())&&void 0!==v?v:"OK",ms:0,skipped:!1,package:null!=l?l:"",flaking:o.Test.isReproducing},o.Test.isProfiling&&(console.profileEnd(`${t.category}: ${t.name}`),r.shell.info(`Profiling of ${t.category}: ${t.name} finished \n Please ensure that you have opened DevTools (F12) / Performance panel before test starts.`))}}catch(e){d(e),s={name:t.name,owner:null!==(w=null===(C=t.options)||void 0===C?void 0:C.owner)&&void 0!==w?w:"",category:t.category,logs:"",date:M,success:!1,result:yield B(e),ms:0,skipped:!1,package:null!=l?l:"",flaking:!1}}if((null===(A=t.options)||void 0===A?void 0:A.isAggregated)&&s.result.constructor===o.DataFrame){const t=s.result.col("success");if(t&&(s.success=t.stats.sum===t.length),!c){const t=s.result;t.columns.remove("stack"),t.rows.removeWhere((t=>t.get("success"))),s.result=t}s.result=s.result.toCsv()}if(s.logs=n.join("\n"),s.ms=Date.now()-P,_||u(`Finished ${t.category} ${t.name} for ${s.ms} ms`),s.category=t.category,s.name=t.name,s.owner=null!==(T=null===(x=t.options)||void 0===x?void 0:x.owner)&&void 0!==T?T:"",!I){let e={success:s.success,result:s.result,ms:s.ms,date:s.date,skipped:s.skipped,category:t.category,name:t.name,logs:s.logs,owner:s.owner,flaking:o.Test.isReproducing&&s.success,package:s.package};if(s.result.constructor==Object){const t=Object.keys(s.result).reduce(((t,e)=>Object.assign(Object.assign({},t),{["result."+e]:s.result[e]})),{});e=Object.assign(Object.assign({},e),t)}e.result instanceof o.DataFrame&&(e.result=JSON.stringify(null===(S=e.result)||void 0===S?void 0:S.toJson())||""),yield D("package",e)}return s}))}function $(t){const e=t.slice();return e.sort((()=>Math.random()-.5)),e}function k(t){return s(this,void 0,void 0,(function*(){yield new Promise((e=>setTimeout(e,t)))}))}function H(t,e,n="EXECUTION TIMEOUT"){return s(this,void 0,void 0,(function*(){let r=null;const o=new Promise(((t,o)=>{r=setTimeout((()=>{o(n)}),e)}));try{return yield Promise.race([t(),o])}finally{r&&clearTimeout(r)}}))}o.DataFrame.fromColumns([o.Column.fromStrings("col",["val1","val2","val3"])])},2074:(t,e,n)=>{"use strict";n.d(e,{A:()=>a});var r=n(1354),o=n.n(r),i=n(6314),s=n.n(i)()(o());s.push([t.id,".st-colored-text-input > textarea {\n width: 100%;\n -webkit-text-fill-color: transparent;\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,oCAAoC;EACpC,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 -webkit-text-fill-color: transparent;\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:(t,e,n)=>{"use strict";n.d(e,{A:()=>a});var r=n(1354),o=n.n(r),i=n(6314),s=n.n(i)()(o());s.push([t.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:(t,e,n)=>{"use strict";n.d(e,{A:()=>a});var r=n(1354),o=n.n(r),i=n(6314),s=n.n(i)()(o());s.push([t.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}\n\n.st-structure-mol-img {\n margin-right: 30px;\n float: right;\n}\n\n.st-structure-bool-button-block {\n justify-content: right;\n margin-bottom: 10px;\n}\n\n.st-structure-bottom {\n flex-direction: row-reverse;\n padding-top: 20px;\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;AACrB;;AAEA;EACE,kBAAkB;EAClB,YAAY;AACd;;AAEA;EACE,sBAAsB;EACtB,mBAAmB;AACrB;;AAEA;EACE,2BAA2B;EAC3B,iBAAiB;AACnB;;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}\n\n.st-structure-mol-img {\n margin-right: 30px;\n float: right;\n}\n\n.st-structure-bool-button-block {\n justify-content: right;\n margin-bottom: 10px;\n}\n\n.st-structure-bottom {\n flex-direction: row-reverse;\n padding-top: 20px;\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:(t,e,n)=>{"use strict";n.d(e,{A:()=>a});var r=n(1354),o=n.n(r),i=n(6314),s=n.n(i)()(o());s.push([t.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:(t,e,n)=>{"use strict";n.d(e,{A:()=>a});var r=n(1354),o=n.n(r),i=n(6314),s=n.n(i)()(o());s.push([t.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:t=>{"use strict";t.exports=function(t){var e=[];return e.toString=function(){return this.map((function(e){var n="",r=void 0!==e[5];return e[4]&&(n+="@supports (".concat(e[4],") {")),e[2]&&(n+="@media ".concat(e[2]," {")),r&&(n+="@layer".concat(e[5].length>0?" ".concat(e[5]):""," {")),n+=t(e),r&&(n+="}"),e[2]&&(n+="}"),e[4]&&(n+="}"),n})).join("")},e.i=function(t,n,r,o,i){"string"==typeof t&&(t=[[null,t,void 0]]);var s={};if(r)for(var a=0;a<this.length;a++){var l=this[a][0];null!=l&&(s[l]=!0)}for(var u=0;u<t.length;u++){var c=[].concat(t[u]);r&&s[c[0]]||(void 0!==i&&(void 0===c[5]||(c[1]="@layer".concat(c[5].length>0?" ".concat(c[5]):""," {").concat(c[1],"}")),c[5]=i),n&&(c[2]?(c[1]="@media ".concat(c[2]," {").concat(c[1],"}"),c[2]=n):c[2]=n),o&&(c[4]?(c[1]="@supports (".concat(c[4],") {").concat(c[1],"}"),c[4]=o):c[4]="".concat(o)),e.push(c))}},e}},1354:t=>{"use strict";t.exports=function(t){var e=t[1],n=t[3];if(!n)return e;if("function"==typeof btoa){var r=btoa(unescape(encodeURIComponent(JSON.stringify(n)))),o="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(r),i="/*# ".concat(o," */");return[e].concat([i]).join("\n")}return[e].join("\n")}},9982:function(t,e,n){var r;!function(){var e={};!function(t){"use strict";t.__esModule=!0,t.digestLength=32,t.blockSize=64;var e=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function n(t,n,r,o,i){for(var s,a,l,u,c,h,d,f,p,m,g,y,b;i>=64;){for(s=n[0],a=n[1],l=n[2],u=n[3],c=n[4],h=n[5],d=n[6],f=n[7],m=0;m<16;m++)g=o+4*m,t[m]=(255&r[g])<<24|(255&r[g+1])<<16|(255&r[g+2])<<8|255&r[g+3];for(m=16;m<64;m++)y=((p=t[m-2])>>>17|p<<15)^(p>>>19|p<<13)^p>>>10,b=((p=t[m-15])>>>7|p<<25)^(p>>>18|p<<14)^p>>>3,t[m]=(y+t[m-7]|0)+(b+t[m-16]|0);for(m=0;m<64;m++)y=(((c>>>6|c<<26)^(c>>>11|c<<21)^(c>>>25|c<<7))+(c&h^~c&d)|0)+(f+(e[m]+t[m]|0)|0)|0,b=((s>>>2|s<<30)^(s>>>13|s<<19)^(s>>>22|s<<10))+(s&a^s&l^a&l)|0,f=d,d=h,h=c,c=u+y|0,u=l,l=a,a=s,s=y+b|0;n[0]+=s,n[1]+=a,n[2]+=l,n[3]+=u,n[4]+=c,n[5]+=h,n[6]+=d,n[7]+=f,o+=64,i-=64}return o}var r=function(){function e(){this.digestLength=t.digestLength,this.blockSize=t.blockSize,this.state=new Int32Array(8),this.temp=new Int32Array(64),this.buffer=new Uint8Array(128),this.bufferLength=0,this.bytesHashed=0,this.finished=!1,this.reset()}return e.prototype.reset=function(){return this.state[0]=1779033703,this.state[1]=3144134277,this.state[2]=1013904242,this.state[3]=2773480762,this.state[4]=1359893119,this.state[5]=2600822924,this.state[6]=528734635,this.state[7]=1541459225,this.bufferLength=0,this.bytesHashed=0,this.finished=!1,this},e.prototype.clean=function(){for(var t=0;t<this.buffer.length;t++)this.buffer[t]=0;for(t=0;t<this.temp.length;t++)this.temp[t]=0;this.reset()},e.prototype.update=function(t,e){if(void 0===e&&(e=t.length),this.finished)throw new Error("SHA256: can't update because hash was finished.");var r=0;if(this.bytesHashed+=e,this.bufferLength>0){for(;this.bufferLength<64&&e>0;)this.buffer[this.bufferLength++]=t[r++],e--;64===this.bufferLength&&(n(this.temp,this.state,this.buffer,0,64),this.bufferLength=0)}for(e>=64&&(r=n(this.temp,this.state,t,r,e),e%=64);e>0;)this.buffer[this.bufferLength++]=t[r++],e--;return this},e.prototype.finish=function(t){if(!this.finished){var e=this.bytesHashed,r=this.bufferLength,o=e/536870912|0,i=e<<3,s=e%64<56?64:128;this.buffer[r]=128;for(var a=r+1;a<s-8;a++)this.buffer[a]=0;this.buffer[s-8]=o>>>24&255,this.buffer[s-7]=o>>>16&255,this.buffer[s-6]=o>>>8&255,this.buffer[s-5]=o>>>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++)t[4*a+0]=this.state[a]>>>24&255,t[4*a+1]=this.state[a]>>>16&255,t[4*a+2]=this.state[a]>>>8&255,t[4*a+3]=this.state[a]>>>0&255;return this},e.prototype.digest=function(){var t=new Uint8Array(this.digestLength);return this.finish(t),t},e.prototype._saveState=function(t){for(var e=0;e<this.state.length;e++)t[e]=this.state[e]},e.prototype._restoreState=function(t,e){for(var n=0;n<this.state.length;n++)this.state[n]=t[n];this.bytesHashed=e,this.finished=!1,this.bufferLength=0},e}();t.Hash=r;var o=function(){function t(t){this.inner=new r,this.outer=new r,this.blockSize=this.inner.blockSize,this.digestLength=this.inner.digestLength;var e=new Uint8Array(this.blockSize);if(t.length>this.blockSize)(new r).update(t).finish(e).clean();else for(var n=0;n<t.length;n++)e[n]=t[n];for(n=0;n<e.length;n++)e[n]^=54;for(this.inner.update(e),n=0;n<e.length;n++)e[n]^=106;for(this.outer.update(e),this.istate=new Uint32Array(8),this.ostate=new Uint32Array(8),this.inner._saveState(this.istate),this.outer._saveState(this.ostate),n=0;n<e.length;n++)e[n]=0}return t.prototype.reset=function(){return this.inner._restoreState(this.istate,this.inner.blockSize),this.outer._restoreState(this.ostate,this.outer.blockSize),this},t.prototype.clean=function(){for(var t=0;t<this.istate.length;t++)this.ostate[t]=this.istate[t]=0;this.inner.clean(),this.outer.clean()},t.prototype.update=function(t){return this.inner.update(t),this},t.prototype.finish=function(t){return this.outer.finished?this.outer.finish(t):(this.inner.finish(t),this.outer.update(t,this.digestLength).finish(t)),this},t.prototype.digest=function(){var t=new Uint8Array(this.digestLength);return this.finish(t),t},t}();function i(t){var e=(new r).update(t),n=e.digest();return e.clean(),n}function s(t,e){var n=new o(t).update(e),r=n.digest();return n.clean(),r}function a(t,e,n,r){var o=r[0];if(0===o)throw new Error("hkdf: cannot expand more");e.reset(),o>1&&e.update(t),n&&e.update(n),e.update(r),e.finish(t),r[0]++}t.HMAC=o,t.hash=i,t.default=i,t.hmac=s;var l=new Uint8Array(t.digestLength);t.hkdf=function(t,e,n,r){void 0===e&&(e=l),void 0===r&&(r=32);for(var i=new Uint8Array([1]),u=s(e,t),c=new o(u),h=new Uint8Array(c.digestLength),d=h.length,f=new Uint8Array(r),p=0;p<r;p++)d===h.length&&(a(h,c,n,i),d=0),f[p]=h[d++];return c.clean(),h.fill(0),i.fill(0),f},t.pbkdf2=function(t,e,n,r){for(var i=new o(t),s=i.digestLength,a=new Uint8Array(4),l=new Uint8Array(s),u=new Uint8Array(s),c=new Uint8Array(r),h=0;h*s<r;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(e),i.update(a),i.finish(u);for(var f=0;f<s;f++)l[f]=u[f];for(f=2;f<=n;f++){i.reset(),i.update(u).finish(u);for(var p=0;p<s;p++)l[p]^=u[p]}for(f=0;f<s&&h*s+f<r;f++)c[h*s+f]=l[f]}for(h=0;h<s;h++)l[h]=u[h]=0;for(h=0;h<4;h++)a[h]=0;return i.clean(),c}}(e);var o=e.default;for(var i in e)o[i]=e[i];"object"==typeof t.exports?t.exports=o:void 0===(r=function(){return o}.call(e,n,e,t))||(t.exports=r)}()},2543:function(t,e,n){var r;t=n.nmd(t),function(){var o,i="Expected a function",s="__lodash_hash_undefined__",a="__lodash_placeholder__",l=32,u=128,c=1/0,h=9007199254740991,d=NaN,f=4294967295,p=[["ary",u],["bind",1],["bindKey",2],["curry",8],["curryRight",16],["flip",512],["partial",l],["partialRight",64],["rearg",256]],m="[object Arguments]",g="[object Array]",y="[object Boolean]",b="[object Date]",v="[object Error]",C="[object Function]",w="[object GeneratorFunction]",A="[object Map]",x="[object Number]",E="[object Object]",T="[object Promise]",S="[object RegExp]",I="[object Set]",_="[object String]",N="[object Symbol]",P="[object WeakMap]",M="[object ArrayBuffer]",L="[object DataView]",O="[object Float32Array]",R="[object Float64Array]",D="[object Int8Array]",B="[object Int16Array]",F="[object Int32Array]",$="[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,J=/<%([\s\S]+?)%>/g,Q=/<%=([\s\S]+?)%>/g,X=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Z=/^\w*$/,tt=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,et=/[\\^$.*+?()[\]{}|]/g,nt=RegExp(et.source),rt=/^\s+/,ot=/\s/,it=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,st=/\{\n\/\* \[wrapped with (.+)\] \*/,at=/,? & /,lt=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,ut=/[()=,{}\[\]\/\s]/,ct=/\\(\\)?/g,ht=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,dt=/\w*$/,ft=/^[-+]0x[0-9a-f]+$/i,pt=/^0b[01]+$/i,mt=/^\[object .+?Constructor\]$/,gt=/^0o[0-7]+$/i,yt=/^(?:0|[1-9]\d*)$/,bt=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,vt=/($^)/,Ct=/['\n\r\u2028\u2029\\]/g,wt="\\ud800-\\udfff",At="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",xt="\\u2700-\\u27bf",Et="a-z\\xdf-\\xf6\\xf8-\\xff",Tt="A-Z\\xc0-\\xd6\\xd8-\\xde",St="\\ufe0e\\ufe0f",It="\\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",_t="["+wt+"]",Nt="["+It+"]",Pt="["+At+"]",Mt="\\d+",Lt="["+xt+"]",Ot="["+Et+"]",Rt="[^"+wt+It+Mt+xt+Et+Tt+"]",Dt="\\ud83c[\\udffb-\\udfff]",Bt="[^"+wt+"]",Ft="(?:\\ud83c[\\udde6-\\uddff]){2}",$t="[\\ud800-\\udbff][\\udc00-\\udfff]",kt="["+Tt+"]",Ht="\\u200d",Gt="(?:"+Ot+"|"+Rt+")",Ut="(?:"+kt+"|"+Rt+")",Vt="(?:['’](?:d|ll|m|re|s|t|ve))?",jt="(?:['’](?:D|LL|M|RE|S|T|VE))?",qt="(?:"+Pt+"|"+Dt+")?",Wt="["+St+"]?",zt=Wt+qt+"(?:"+Ht+"(?:"+[Bt,Ft,$t].join("|")+")"+Wt+qt+")*",Yt="(?:"+[Lt,Ft,$t].join("|")+")"+zt,Kt="(?:"+[Bt+Pt+"?",Pt,Ft,$t,_t].join("|")+")",Jt=RegExp("['’]","g"),Qt=RegExp(Pt,"g"),Xt=RegExp(Dt+"(?="+Dt+")|"+Kt+zt,"g"),Zt=RegExp([kt+"?"+Ot+"+"+Vt+"(?="+[Nt,kt,"$"].join("|")+")",Ut+"+"+jt+"(?="+[Nt,kt+Gt,"$"].join("|")+")",kt+"?"+Gt+"+"+Vt,kt+"+"+jt,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Mt,Yt].join("|"),"g"),te=RegExp("["+Ht+wt+At+St+"]"),ee=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,ne=["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"],re=-1,oe={};oe[O]=oe[R]=oe[D]=oe[B]=oe[F]=oe[$]=oe[k]=oe[H]=oe[G]=!0,oe[m]=oe[g]=oe[M]=oe[y]=oe[L]=oe[b]=oe[v]=oe[C]=oe[A]=oe[x]=oe[E]=oe[S]=oe[I]=oe[_]=oe[P]=!1;var ie={};ie[m]=ie[g]=ie[M]=ie[L]=ie[y]=ie[b]=ie[O]=ie[R]=ie[D]=ie[B]=ie[F]=ie[A]=ie[x]=ie[E]=ie[S]=ie[I]=ie[_]=ie[N]=ie[$]=ie[k]=ie[H]=ie[G]=!0,ie[v]=ie[C]=ie[P]=!1;var se={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},ae=parseFloat,le=parseInt,ue="object"==typeof n.g&&n.g&&n.g.Object===Object&&n.g,ce="object"==typeof self&&self&&self.Object===Object&&self,he=ue||ce||Function("return this")(),de=e&&!e.nodeType&&e,fe=de&&t&&!t.nodeType&&t,pe=fe&&fe.exports===de,me=pe&&ue.process,ge=function(){try{return fe&&fe.require&&fe.require("util").types||me&&me.binding&&me.binding("util")}catch(t){}}(),ye=ge&&ge.isArrayBuffer,be=ge&&ge.isDate,ve=ge&&ge.isMap,Ce=ge&&ge.isRegExp,we=ge&&ge.isSet,Ae=ge&&ge.isTypedArray;function xe(t,e,n){switch(n.length){case 0:return t.call(e);case 1:return t.call(e,n[0]);case 2:return t.call(e,n[0],n[1]);case 3:return t.call(e,n[0],n[1],n[2])}return t.apply(e,n)}function Ee(t,e,n,r){for(var o=-1,i=null==t?0:t.length;++o<i;){var s=t[o];e(r,s,n(s),t)}return r}function Te(t,e){for(var n=-1,r=null==t?0:t.length;++n<r&&!1!==e(t[n],n,t););return t}function Se(t,e){for(var n=null==t?0:t.length;n--&&!1!==e(t[n],n,t););return t}function Ie(t,e){for(var n=-1,r=null==t?0:t.length;++n<r;)if(!e(t[n],n,t))return!1;return!0}function _e(t,e){for(var n=-1,r=null==t?0:t.length,o=0,i=[];++n<r;){var s=t[n];e(s,n,t)&&(i[o++]=s)}return i}function Ne(t,e){return!(null==t||!t.length)&&ke(t,e,0)>-1}function Pe(t,e,n){for(var r=-1,o=null==t?0:t.length;++r<o;)if(n(e,t[r]))return!0;return!1}function Me(t,e){for(var n=-1,r=null==t?0:t.length,o=Array(r);++n<r;)o[n]=e(t[n],n,t);return o}function Le(t,e){for(var n=-1,r=e.length,o=t.length;++n<r;)t[o+n]=e[n];return t}function Oe(t,e,n,r){var o=-1,i=null==t?0:t.length;for(r&&i&&(n=t[++o]);++o<i;)n=e(n,t[o],o,t);return n}function Re(t,e,n,r){var o=null==t?0:t.length;for(r&&o&&(n=t[--o]);o--;)n=e(n,t[o],o,t);return n}function De(t,e){for(var n=-1,r=null==t?0:t.length;++n<r;)if(e(t[n],n,t))return!0;return!1}var Be=Ve("length");function Fe(t,e,n){var r;return n(t,(function(t,n,o){if(e(t,n,o))return r=n,!1})),r}function $e(t,e,n,r){for(var o=t.length,i=n+(r?1:-1);r?i--:++i<o;)if(e(t[i],i,t))return i;return-1}function ke(t,e,n){return e==e?function(t,e,n){for(var r=n-1,o=t.length;++r<o;)if(t[r]===e)return r;return-1}(t,e,n):$e(t,Ge,n)}function He(t,e,n,r){for(var o=n-1,i=t.length;++o<i;)if(r(t[o],e))return o;return-1}function Ge(t){return t!=t}function Ue(t,e){var n=null==t?0:t.length;return n?We(t,e)/n:d}function Ve(t){return function(e){return null==e?o:e[t]}}function je(t){return function(e){return null==t?o:t[e]}}function qe(t,e,n,r,o){return o(t,(function(t,o,i){n=r?(r=!1,t):e(n,t,o,i)})),n}function We(t,e){for(var n,r=-1,i=t.length;++r<i;){var s=e(t[r]);s!==o&&(n=n===o?s:n+s)}return n}function ze(t,e){for(var n=-1,r=Array(t);++n<t;)r[n]=e(n);return r}function Ye(t){return t?t.slice(0,dn(t)+1).replace(rt,""):t}function Ke(t){return function(e){return t(e)}}function Je(t,e){return Me(e,(function(e){return t[e]}))}function Qe(t,e){return t.has(e)}function Xe(t,e){for(var n=-1,r=t.length;++n<r&&ke(e,t[n],0)>-1;);return n}function Ze(t,e){for(var n=t.length;n--&&ke(e,t[n],0)>-1;);return n}var tn=je({À:"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"}),en=je({"&":"&","<":"<",">":">",'"':""","'":"'"});function nn(t){return"\\"+se[t]}function rn(t){return te.test(t)}function on(t){var e=-1,n=Array(t.size);return t.forEach((function(t,r){n[++e]=[r,t]})),n}function sn(t,e){return function(n){return t(e(n))}}function an(t,e){for(var n=-1,r=t.length,o=0,i=[];++n<r;){var s=t[n];s!==e&&s!==a||(t[n]=a,i[o++]=n)}return i}function ln(t){var e=-1,n=Array(t.size);return t.forEach((function(t){n[++e]=t})),n}function un(t){var e=-1,n=Array(t.size);return t.forEach((function(t){n[++e]=[t,t]})),n}function cn(t){return rn(t)?function(t){for(var e=Xt.lastIndex=0;Xt.test(t);)++e;return e}(t):Be(t)}function hn(t){return rn(t)?function(t){return t.match(Xt)||[]}(t):function(t){return t.split("")}(t)}function dn(t){for(var e=t.length;e--&&ot.test(t.charAt(e)););return e}var fn=je({"&":"&","<":"<",">":">",""":'"',"'":"'"}),pn=function t(e){var n,r=(e=null==e?he:pn.defaults(he.Object(),e,pn.pick(he,ne))).Array,ot=e.Date,wt=e.Error,At=e.Function,xt=e.Math,Et=e.Object,Tt=e.RegExp,St=e.String,It=e.TypeError,_t=r.prototype,Nt=At.prototype,Pt=Et.prototype,Mt=e["__core-js_shared__"],Lt=Nt.toString,Ot=Pt.hasOwnProperty,Rt=0,Dt=(n=/[^.]+$/.exec(Mt&&Mt.keys&&Mt.keys.IE_PROTO||""))?"Symbol(src)_1."+n:"",Bt=Pt.toString,Ft=Lt.call(Et),$t=he._,kt=Tt("^"+Lt.call(Ot).replace(et,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Ht=pe?e.Buffer:o,Gt=e.Symbol,Ut=e.Uint8Array,Vt=Ht?Ht.allocUnsafe:o,jt=sn(Et.getPrototypeOf,Et),qt=Et.create,Wt=Pt.propertyIsEnumerable,zt=_t.splice,Yt=Gt?Gt.isConcatSpreadable:o,Kt=Gt?Gt.iterator:o,Xt=Gt?Gt.toStringTag:o,te=function(){try{var t=ui(Et,"defineProperty");return t({},"",{}),t}catch(t){}}(),se=e.clearTimeout!==he.clearTimeout&&e.clearTimeout,ue=ot&&ot.now!==he.Date.now&&ot.now,ce=e.setTimeout!==he.setTimeout&&e.setTimeout,de=xt.ceil,fe=xt.floor,me=Et.getOwnPropertySymbols,ge=Ht?Ht.isBuffer:o,Be=e.isFinite,je=_t.join,mn=sn(Et.keys,Et),gn=xt.max,yn=xt.min,bn=ot.now,vn=e.parseInt,Cn=xt.random,wn=_t.reverse,An=ui(e,"DataView"),xn=ui(e,"Map"),En=ui(e,"Promise"),Tn=ui(e,"Set"),Sn=ui(e,"WeakMap"),In=ui(Et,"create"),_n=Sn&&new Sn,Nn={},Pn=Fi(An),Mn=Fi(xn),Ln=Fi(En),On=Fi(Tn),Rn=Fi(Sn),Dn=Gt?Gt.prototype:o,Bn=Dn?Dn.valueOf:o,Fn=Dn?Dn.toString:o;function $n(t){if(ta(t)&&!Vs(t)&&!(t instanceof Un)){if(t instanceof Gn)return t;if(Ot.call(t,"__wrapped__"))return $i(t)}return new Gn(t)}var kn=function(){function t(){}return function(e){if(!Zs(e))return{};if(qt)return qt(e);t.prototype=e;var n=new t;return t.prototype=o,n}}();function Hn(){}function Gn(t,e){this.__wrapped__=t,this.__actions__=[],this.__chain__=!!e,this.__index__=0,this.__values__=o}function Un(t){this.__wrapped__=t,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=f,this.__views__=[]}function Vn(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function jn(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function qn(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function Wn(t){var e=-1,n=null==t?0:t.length;for(this.__data__=new qn;++e<n;)this.add(t[e])}function zn(t){var e=this.__data__=new jn(t);this.size=e.size}function Yn(t,e){var n=Vs(t),r=!n&&Us(t),o=!n&&!r&&zs(t),i=!n&&!r&&!o&&la(t),s=n||r||o||i,a=s?ze(t.length,St):[],l=a.length;for(var u in t)!e&&!Ot.call(t,u)||s&&("length"==u||o&&("offset"==u||"parent"==u)||i&&("buffer"==u||"byteLength"==u||"byteOffset"==u)||gi(u,l))||a.push(u);return a}function Kn(t){var e=t.length;return e?t[qr(0,e-1)]:o}function Jn(t,e){return Li(Io(t),ir(e,0,t.length))}function Qn(t){return Li(Io(t))}function Xn(t,e,n){(n!==o&&!ks(t[e],n)||n===o&&!(e in t))&&rr(t,e,n)}function Zn(t,e,n){var r=t[e];Ot.call(t,e)&&ks(r,n)&&(n!==o||e in t)||rr(t,e,n)}function tr(t,e){for(var n=t.length;n--;)if(ks(t[n][0],e))return n;return-1}function er(t,e,n,r){return cr(t,(function(t,o,i){e(r,t,n(t),i)})),r}function nr(t,e){return t&&_o(e,Pa(e),t)}function rr(t,e,n){"__proto__"==e&&te?te(t,e,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[e]=n}function or(t,e){for(var n=-1,i=e.length,s=r(i),a=null==t;++n<i;)s[n]=a?o:Ta(t,e[n]);return s}function ir(t,e,n){return t==t&&(n!==o&&(t=t<=n?t:n),e!==o&&(t=t>=e?t:e)),t}function sr(t,e,n,r,i,s){var a,l=1&e,u=2&e,c=4&e;if(n&&(a=i?n(t,r,i,s):n(t)),a!==o)return a;if(!Zs(t))return t;var h=Vs(t);if(h){if(a=function(t){var e=t.length,n=new t.constructor(e);return e&&"string"==typeof t[0]&&Ot.call(t,"index")&&(n.index=t.index,n.input=t.input),n}(t),!l)return Io(t,a)}else{var d=di(t),f=d==C||d==w;if(zs(t))return wo(t,l);if(d==E||d==m||f&&!i){if(a=u||f?{}:pi(t),!l)return u?function(t,e){return _o(t,hi(t),e)}(t,function(t,e){return t&&_o(e,Ma(e),t)}(a,t)):function(t,e){return _o(t,ci(t),e)}(t,nr(a,t))}else{if(!ie[d])return i?t:{};a=function(t,e,n){var r,o=t.constructor;switch(e){case M:return Ao(t);case y:case b:return new o(+t);case L:return function(t,e){var n=e?Ao(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.byteLength)}(t,n);case O:case R:case D:case B:case F:case $:case k:case H:case G:return xo(t,n);case A:return new o;case x:case _:return new o(t);case S:return function(t){var e=new t.constructor(t.source,dt.exec(t));return e.lastIndex=t.lastIndex,e}(t);case I:return new o;case N:return r=t,Bn?Et(Bn.call(r)):{}}}(t,d,l)}}s||(s=new zn);var p=s.get(t);if(p)return p;s.set(t,a),ia(t)?t.forEach((function(r){a.add(sr(r,e,n,r,t,s))})):ea(t)&&t.forEach((function(r,o){a.set(o,sr(r,e,n,o,t,s))}));var g=h?o:(c?u?ni:ei:u?Ma:Pa)(t);return Te(g||t,(function(r,o){g&&(r=t[o=r]),Zn(a,o,sr(r,e,n,o,t,s))})),a}function ar(t,e,n){var r=n.length;if(null==t)return!r;for(t=Et(t);r--;){var i=n[r],s=e[i],a=t[i];if(a===o&&!(i in t)||!s(a))return!1}return!0}function lr(t,e,n){if("function"!=typeof t)throw new It(i);return _i((function(){t.apply(o,n)}),e)}function ur(t,e,n,r){var o=-1,i=Ne,s=!0,a=t.length,l=[],u=e.length;if(!a)return l;n&&(e=Me(e,Ke(n))),r?(i=Pe,s=!1):e.length>=200&&(i=Qe,s=!1,e=new Wn(e));t:for(;++o<a;){var c=t[o],h=null==n?c:n(c);if(c=r||0!==c?c:0,s&&h==h){for(var d=u;d--;)if(e[d]===h)continue t;l.push(c)}else i(e,h,r)||l.push(c)}return l}$n.templateSettings={escape:K,evaluate:J,interpolate:Q,variable:"",imports:{_:$n}},$n.prototype=Hn.prototype,$n.prototype.constructor=$n,Gn.prototype=kn(Hn.prototype),Gn.prototype.constructor=Gn,Un.prototype=kn(Hn.prototype),Un.prototype.constructor=Un,Vn.prototype.clear=function(){this.__data__=In?In(null):{},this.size=0},Vn.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},Vn.prototype.get=function(t){var e=this.__data__;if(In){var n=e[t];return n===s?o:n}return Ot.call(e,t)?e[t]:o},Vn.prototype.has=function(t){var e=this.__data__;return In?e[t]!==o:Ot.call(e,t)},Vn.prototype.set=function(t,e){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=In&&e===o?s:e,this},jn.prototype.clear=function(){this.__data__=[],this.size=0},jn.prototype.delete=function(t){var e=this.__data__,n=tr(e,t);return!(n<0||(n==e.length-1?e.pop():zt.call(e,n,1),--this.size,0))},jn.prototype.get=function(t){var e=this.__data__,n=tr(e,t);return n<0?o:e[n][1]},jn.prototype.has=function(t){return tr(this.__data__,t)>-1},jn.prototype.set=function(t,e){var n=this.__data__,r=tr(n,t);return r<0?(++this.size,n.push([t,e])):n[r][1]=e,this},qn.prototype.clear=function(){this.size=0,this.__data__={hash:new Vn,map:new(xn||jn),string:new Vn}},qn.prototype.delete=function(t){var e=ai(this,t).delete(t);return this.size-=e?1:0,e},qn.prototype.get=function(t){return ai(this,t).get(t)},qn.prototype.has=function(t){return ai(this,t).has(t)},qn.prototype.set=function(t,e){var n=ai(this,t),r=n.size;return n.set(t,e),this.size+=n.size==r?0:1,this},Wn.prototype.add=Wn.prototype.push=function(t){return this.__data__.set(t,s),this},Wn.prototype.has=function(t){return this.__data__.has(t)},zn.prototype.clear=function(){this.__data__=new jn,this.size=0},zn.prototype.delete=function(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n},zn.prototype.get=function(t){return this.__data__.get(t)},zn.prototype.has=function(t){return this.__data__.has(t)},zn.prototype.set=function(t,e){var n=this.__data__;if(n instanceof jn){var r=n.__data__;if(!xn||r.length<199)return r.push([t,e]),this.size=++n.size,this;n=this.__data__=new qn(r)}return n.set(t,e),this.size=n.size,this};var cr=Mo(br),hr=Mo(vr,!0);function dr(t,e){var n=!0;return cr(t,(function(t,r,o){return n=!!e(t,r,o)})),n}function fr(t,e,n){for(var r=-1,i=t.length;++r<i;){var s=t[r],a=e(s);if(null!=a&&(l===o?a==a&&!aa(a):n(a,l)))var l=a,u=s}return u}function pr(t,e){var n=[];return cr(t,(function(t,r,o){e(t,r,o)&&n.push(t)})),n}function mr(t,e,n,r,o){var i=-1,s=t.length;for(n||(n=mi),o||(o=[]);++i<s;){var a=t[i];e>0&&n(a)?e>1?mr(a,e-1,n,r,o):Le(o,a):r||(o[o.length]=a)}return o}var gr=Lo(),yr=Lo(!0);function br(t,e){return t&&gr(t,e,Pa)}function vr(t,e){return t&&yr(t,e,Pa)}function Cr(t,e){return _e(e,(function(e){return Js(t[e])}))}function wr(t,e){for(var n=0,r=(e=yo(e,t)).length;null!=t&&n<r;)t=t[Bi(e[n++])];return n&&n==r?t:o}function Ar(t,e,n){var r=e(t);return Vs(t)?r:Le(r,n(t))}function xr(t){return null==t?t===o?"[object Undefined]":"[object Null]":Xt&&Xt in Et(t)?function(t){var e=Ot.call(t,Xt),n=t[Xt];try{t[Xt]=o;var r=!0}catch(t){}var i=Bt.call(t);return r&&(e?t[Xt]=n:delete t[Xt]),i}(t):function(t){return Bt.call(t)}(t)}function Er(t,e){return t>e}function Tr(t,e){return null!=t&&Ot.call(t,e)}function Sr(t,e){return null!=t&&e in Et(t)}function Ir(t,e,n){for(var i=n?Pe:Ne,s=t[0].length,a=t.length,l=a,u=r(a),c=1/0,h=[];l--;){var d=t[l];l&&e&&(d=Me(d,Ke(e))),c=yn(d.length,c),u[l]=!n&&(e||s>=120&&d.length>=120)?new Wn(l&&d):o}d=t[0];var f=-1,p=u[0];t:for(;++f<s&&h.length<c;){var m=d[f],g=e?e(m):m;if(m=n||0!==m?m:0,!(p?Qe(p,g):i(h,g,n))){for(l=a;--l;){var y=u[l];if(!(y?Qe(y,g):i(t[l],g,n)))continue t}p&&p.push(g),h.push(m)}}return h}function _r(t,e,n){var r=null==(t=Ti(t,e=yo(e,t)))?t:t[Bi(Ki(e))];return null==r?o:xe(r,t,n)}function Nr(t){return ta(t)&&xr(t)==m}function Pr(t,e,n,r,i){return t===e||(null==t||null==e||!ta(t)&&!ta(e)?t!=t&&e!=e:function(t,e,n,r,i,s){var a=Vs(t),l=Vs(e),u=a?g:di(t),c=l?g:di(e),h=(u=u==m?E:u)==E,d=(c=c==m?E:c)==E,f=u==c;if(f&&zs(t)){if(!zs(e))return!1;a=!0,h=!1}if(f&&!h)return s||(s=new zn),a||la(t)?Zo(t,e,n,r,i,s):function(t,e,n,r,o,i,s){switch(n){case L:if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case M:return!(t.byteLength!=e.byteLength||!i(new Ut(t),new Ut(e)));case y:case b:case x:return ks(+t,+e);case v:return t.name==e.name&&t.message==e.message;case S:case _:return t==e+"";case A:var a=on;case I:var l=1&r;if(a||(a=ln),t.size!=e.size&&!l)return!1;var u=s.get(t);if(u)return u==e;r|=2,s.set(t,e);var c=Zo(a(t),a(e),r,o,i,s);return s.delete(t),c;case N:if(Bn)return Bn.call(t)==Bn.call(e)}return!1}(t,e,u,n,r,i,s);if(!(1&n)){var p=h&&Ot.call(t,"__wrapped__"),C=d&&Ot.call(e,"__wrapped__");if(p||C){var w=p?t.value():t,T=C?e.value():e;return s||(s=new zn),i(w,T,n,r,s)}}return!!f&&(s||(s=new zn),function(t,e,n,r,i,s){var a=1&n,l=ei(t),u=l.length;if(u!=ei(e).length&&!a)return!1;for(var c=u;c--;){var h=l[c];if(!(a?h in e:Ot.call(e,h)))return!1}var d=s.get(t),f=s.get(e);if(d&&f)return d==e&&f==t;var p=!0;s.set(t,e),s.set(e,t);for(var m=a;++c<u;){var g=t[h=l[c]],y=e[h];if(r)var b=a?r(y,g,h,e,t,s):r(g,y,h,t,e,s);if(!(b===o?g===y||i(g,y,n,r,s):b)){p=!1;break}m||(m="constructor"==h)}if(p&&!m){var v=t.constructor,C=e.constructor;v==C||!("constructor"in t)||!("constructor"in e)||"function"==typeof v&&v instanceof v&&"function"==typeof C&&C instanceof C||(p=!1)}return s.delete(t),s.delete(e),p}(t,e,n,r,i,s))}(t,e,n,r,Pr,i))}function Mr(t,e,n,r){var i=n.length,s=i,a=!r;if(null==t)return!s;for(t=Et(t);i--;){var l=n[i];if(a&&l[2]?l[1]!==t[l[0]]:!(l[0]in t))return!1}for(;++i<s;){var u=(l=n[i])[0],c=t[u],h=l[1];if(a&&l[2]){if(c===o&&!(u in t))return!1}else{var d=new zn;if(r)var f=r(c,h,u,t,e,d);if(!(f===o?Pr(h,c,3,r,d):f))return!1}}return!0}function Lr(t){return!(!Zs(t)||(e=t,Dt&&Dt in e))&&(Js(t)?kt:mt).test(Fi(t));var e}function Or(t){return"function"==typeof t?t:null==t?nl:"object"==typeof t?Vs(t)?$r(t[0],t[1]):Fr(t):hl(t)}function Rr(t){if(!wi(t))return mn(t);var e=[];for(var n in Et(t))Ot.call(t,n)&&"constructor"!=n&&e.push(n);return e}function Dr(t,e){return t<e}function Br(t,e){var n=-1,o=qs(t)?r(t.length):[];return cr(t,(function(t,r,i){o[++n]=e(t,r,i)})),o}function Fr(t){var e=li(t);return 1==e.length&&e[0][2]?xi(e[0][0],e[0][1]):function(n){return n===t||Mr(n,t,e)}}function $r(t,e){return bi(t)&&Ai(e)?xi(Bi(t),e):function(n){var r=Ta(n,t);return r===o&&r===e?Sa(n,t):Pr(e,r,3)}}function kr(t,e,n,r,i){t!==e&&gr(e,(function(s,a){if(i||(i=new zn),Zs(s))!function(t,e,n,r,i,s,a){var l=Si(t,n),u=Si(e,n),c=a.get(u);if(c)Xn(t,n,c);else{var h=s?s(l,u,n+"",t,e,a):o,d=h===o;if(d){var f=Vs(u),p=!f&&zs(u),m=!f&&!p&&la(u);h=u,f||p||m?Vs(l)?h=l:Ws(l)?h=Io(l):p?(d=!1,h=wo(u,!0)):m?(d=!1,h=xo(u,!0)):h=[]:ra(u)||Us(u)?(h=l,Us(l)?h=ga(l):Zs(l)&&!Js(l)||(h=pi(u))):d=!1}d&&(a.set(u,h),i(h,u,r,s,a),a.delete(u)),Xn(t,n,h)}}(t,e,a,n,kr,r,i);else{var l=r?r(Si(t,a),s,a+"",t,e,i):o;l===o&&(l=s),Xn(t,a,l)}}),Ma)}function Hr(t,e){var n=t.length;if(n)return gi(e+=e<0?n:0,n)?t[e]:o}function Gr(t,e,n){e=e.length?Me(e,(function(t){return Vs(t)?function(e){return wr(e,1===t.length?t[0]:t)}:t})):[nl];var r=-1;e=Me(e,Ke(si()));var o=Br(t,(function(t,n,o){var i=Me(e,(function(e){return e(t)}));return{criteria:i,index:++r,value:t}}));return function(t){var e=t.length;for(t.sort((function(t,e){return function(t,e,n){for(var r=-1,o=t.criteria,i=e.criteria,s=o.length,a=n.length;++r<s;){var l=Eo(o[r],i[r]);if(l)return r>=a?l:l*("desc"==n[r]?-1:1)}return t.index-e.index}(t,e,n)}));e--;)t[e]=t[e].value;return t}(o)}function Ur(t,e,n){for(var r=-1,o=e.length,i={};++r<o;){var s=e[r],a=wr(t,s);n(a,s)&&Jr(i,yo(s,t),a)}return i}function Vr(t,e,n,r){var o=r?He:ke,i=-1,s=e.length,a=t;for(t===e&&(e=Io(e)),n&&(a=Me(t,Ke(n)));++i<s;)for(var l=0,u=e[i],c=n?n(u):u;(l=o(a,c,l,r))>-1;)a!==t&&zt.call(a,l,1),zt.call(t,l,1);return t}function jr(t,e){for(var n=t?e.length:0,r=n-1;n--;){var o=e[n];if(n==r||o!==i){var i=o;gi(o)?zt.call(t,o,1):lo(t,o)}}return t}function qr(t,e){return t+fe(Cn()*(e-t+1))}function Wr(t,e){var n="";if(!t||e<1||e>h)return n;do{e%2&&(n+=t),(e=fe(e/2))&&(t+=t)}while(e);return n}function zr(t,e){return Ni(Ei(t,e,nl),t+"")}function Yr(t){return Kn(ka(t))}function Kr(t,e){var n=ka(t);return Li(n,ir(e,0,n.length))}function Jr(t,e,n,r){if(!Zs(t))return t;for(var i=-1,s=(e=yo(e,t)).length,a=s-1,l=t;null!=l&&++i<s;){var u=Bi(e[i]),c=n;if("__proto__"===u||"constructor"===u||"prototype"===u)return t;if(i!=a){var h=l[u];(c=r?r(h,u,l):o)===o&&(c=Zs(h)?h:gi(e[i+1])?[]:{})}Zn(l,u,c),l=l[u]}return t}var Qr=_n?function(t,e){return _n.set(t,e),t}:nl,Xr=te?function(t,e){return te(t,"toString",{configurable:!0,enumerable:!1,value:Za(e),writable:!0})}:nl;function Zr(t){return Li(ka(t))}function to(t,e,n){var o=-1,i=t.length;e<0&&(e=-e>i?0:i+e),(n=n>i?i:n)<0&&(n+=i),i=e>n?0:n-e>>>0,e>>>=0;for(var s=r(i);++o<i;)s[o]=t[o+e];return s}function eo(t,e){var n;return cr(t,(function(t,r,o){return!(n=e(t,r,o))})),!!n}function no(t,e,n){var r=0,o=null==t?r:t.length;if("number"==typeof e&&e==e&&o<=2147483647){for(;r<o;){var i=r+o>>>1,s=t[i];null!==s&&!aa(s)&&(n?s<=e:s<e)?r=i+1:o=i}return o}return ro(t,e,nl,n)}function ro(t,e,n,r){var i=0,s=null==t?0:t.length;if(0===s)return 0;for(var a=(e=n(e))!=e,l=null===e,u=aa(e),c=e===o;i<s;){var h=fe((i+s)/2),d=n(t[h]),f=d!==o,p=null===d,m=d==d,g=aa(d);if(a)var y=r||m;else y=c?m&&(r||f):l?m&&f&&(r||!p):u?m&&f&&!p&&(r||!g):!p&&!g&&(r?d<=e:d<e);y?i=h+1:s=h}return yn(s,4294967294)}function oo(t,e){for(var n=-1,r=t.length,o=0,i=[];++n<r;){var s=t[n],a=e?e(s):s;if(!n||!ks(a,l)){var l=a;i[o++]=0===s?0:s}}return i}function io(t){return"number"==typeof t?t:aa(t)?d:+t}function so(t){if("string"==typeof t)return t;if(Vs(t))return Me(t,so)+"";if(aa(t))return Fn?Fn.call(t):"";var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}function ao(t,e,n){var r=-1,o=Ne,i=t.length,s=!0,a=[],l=a;if(n)s=!1,o=Pe;else if(i>=200){var u=e?null:zo(t);if(u)return ln(u);s=!1,o=Qe,l=new Wn}else l=e?[]:a;t:for(;++r<i;){var c=t[r],h=e?e(c):c;if(c=n||0!==c?c:0,s&&h==h){for(var d=l.length;d--;)if(l[d]===h)continue t;e&&l.push(h),a.push(c)}else o(l,h,n)||(l!==a&&l.push(h),a.push(c))}return a}function lo(t,e){return null==(t=Ti(t,e=yo(e,t)))||delete t[Bi(Ki(e))]}function uo(t,e,n,r){return Jr(t,e,n(wr(t,e)),r)}function co(t,e,n,r){for(var o=t.length,i=r?o:-1;(r?i--:++i<o)&&e(t[i],i,t););return n?to(t,r?0:i,r?i+1:o):to(t,r?i+1:0,r?o:i)}function ho(t,e){var n=t;return n instanceof Un&&(n=n.value()),Oe(e,(function(t,e){return e.func.apply(e.thisArg,Le([t],e.args))}),n)}function fo(t,e,n){var o=t.length;if(o<2)return o?ao(t[0]):[];for(var i=-1,s=r(o);++i<o;)for(var a=t[i],l=-1;++l<o;)l!=i&&(s[i]=ur(s[i]||a,t[l],e,n));return ao(mr(s,1),e,n)}function po(t,e,n){for(var r=-1,i=t.length,s=e.length,a={};++r<i;){var l=r<s?e[r]:o;n(a,t[r],l)}return a}function mo(t){return Ws(t)?t:[]}function go(t){return"function"==typeof t?t:nl}function yo(t,e){return Vs(t)?t:bi(t,e)?[t]:Di(ya(t))}var bo=zr;function vo(t,e,n){var r=t.length;return n=n===o?r:n,!e&&n>=r?t:to(t,e,n)}var Co=se||function(t){return he.clearTimeout(t)};function wo(t,e){if(e)return t.slice();var n=t.length,r=Vt?Vt(n):new t.constructor(n);return t.copy(r),r}function Ao(t){var e=new t.constructor(t.byteLength);return new Ut(e).set(new Ut(t)),e}function xo(t,e){var n=e?Ao(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.length)}function Eo(t,e){if(t!==e){var n=t!==o,r=null===t,i=t==t,s=aa(t),a=e!==o,l=null===e,u=e==e,c=aa(e);if(!l&&!c&&!s&&t>e||s&&a&&u&&!l&&!c||r&&a&&u||!n&&u||!i)return 1;if(!r&&!s&&!c&&t<e||c&&n&&i&&!r&&!s||l&&n&&i||!a&&i||!u)return-1}return 0}function To(t,e,n,o){for(var i=-1,s=t.length,a=n.length,l=-1,u=e.length,c=gn(s-a,0),h=r(u+c),d=!o;++l<u;)h[l]=e[l];for(;++i<a;)(d||i<s)&&(h[n[i]]=t[i]);for(;c--;)h[l++]=t[i++];return h}function So(t,e,n,o){for(var i=-1,s=t.length,a=-1,l=n.length,u=-1,c=e.length,h=gn(s-l,0),d=r(h+c),f=!o;++i<h;)d[i]=t[i];for(var p=i;++u<c;)d[p+u]=e[u];for(;++a<l;)(f||i<s)&&(d[p+n[a]]=t[i++]);return d}function Io(t,e){var n=-1,o=t.length;for(e||(e=r(o));++n<o;)e[n]=t[n];return e}function _o(t,e,n,r){var i=!n;n||(n={});for(var s=-1,a=e.length;++s<a;){var l=e[s],u=r?r(n[l],t[l],l,n,t):o;u===o&&(u=t[l]),i?rr(n,l,u):Zn(n,l,u)}return n}function No(t,e){return function(n,r){var o=Vs(n)?Ee:er,i=e?e():{};return o(n,t,si(r,2),i)}}function Po(t){return zr((function(e,n){var r=-1,i=n.length,s=i>1?n[i-1]:o,a=i>2?n[2]:o;for(s=t.length>3&&"function"==typeof s?(i--,s):o,a&&yi(n[0],n[1],a)&&(s=i<3?o:s,i=1),e=Et(e);++r<i;){var l=n[r];l&&t(e,l,r,s)}return e}))}function Mo(t,e){return function(n,r){if(null==n)return n;if(!qs(n))return t(n,r);for(var o=n.length,i=e?o:-1,s=Et(n);(e?i--:++i<o)&&!1!==r(s[i],i,s););return n}}function Lo(t){return function(e,n,r){for(var o=-1,i=Et(e),s=r(e),a=s.length;a--;){var l=s[t?a:++o];if(!1===n(i[l],l,i))break}return e}}function Oo(t){return function(e){var n=rn(e=ya(e))?hn(e):o,r=n?n[0]:e.charAt(0),i=n?vo(n,1).join(""):e.slice(1);return r[t]()+i}}function Ro(t){return function(e){return Oe(Ja(Ua(e).replace(Jt,"")),t,"")}}function Do(t){return function(){var e=arguments;switch(e.length){case 0:return new t;case 1:return new t(e[0]);case 2:return new t(e[0],e[1]);case 3:return new t(e[0],e[1],e[2]);case 4:return new t(e[0],e[1],e[2],e[3]);case 5:return new t(e[0],e[1],e[2],e[3],e[4]);case 6:return new t(e[0],e[1],e[2],e[3],e[4],e[5]);case 7:return new t(e[0],e[1],e[2],e[3],e[4],e[5],e[6])}var n=kn(t.prototype),r=t.apply(n,e);return Zs(r)?r:n}}function Bo(t){return function(e,n,r){var i=Et(e);if(!qs(e)){var s=si(n,3);e=Pa(e),n=function(t){return s(i[t],t,i)}}var a=t(e,n,r);return a>-1?i[s?e[a]:a]:o}}function Fo(t){return ti((function(e){var n=e.length,r=n,s=Gn.prototype.thru;for(t&&e.reverse();r--;){var a=e[r];if("function"!=typeof a)throw new It(i);if(s&&!l&&"wrapper"==oi(a))var l=new Gn([],!0)}for(r=l?r:n;++r<n;){var u=oi(a=e[r]),c="wrapper"==u?ri(a):o;l=c&&vi(c[0])&&424==c[1]&&!c[4].length&&1==c[9]?l[oi(c[0])].apply(l,c[3]):1==a.length&&vi(a)?l[u]():l.thru(a)}return function(){var t=arguments,r=t[0];if(l&&1==t.length&&Vs(r))return l.plant(r).value();for(var o=0,i=n?e[o].apply(this,t):r;++o<n;)i=e[o].call(this,i);return i}}))}function $o(t,e,n,i,s,a,l,c,h,d){var f=e&u,p=1&e,m=2&e,g=24&e,y=512&e,b=m?o:Do(t);return function u(){for(var v=arguments.length,C=r(v),w=v;w--;)C[w]=arguments[w];if(g)var A=ii(u),x=function(t,e){for(var n=t.length,r=0;n--;)t[n]===e&&++r;return r}(C,A);if(i&&(C=To(C,i,s,g)),a&&(C=So(C,a,l,g)),v-=x,g&&v<d){var E=an(C,A);return qo(t,e,$o,u.placeholder,n,C,E,c,h,d-v)}var T=p?n:this,S=m?T[t]:t;return v=C.length,c?C=function(t,e){for(var n=t.length,r=yn(e.length,n),i=Io(t);r--;){var s=e[r];t[r]=gi(s,n)?i[s]:o}return t}(C,c):y&&v>1&&C.reverse(),f&&h<v&&(C.length=h),this&&this!==he&&this instanceof u&&(S=b||Do(S)),S.apply(T,C)}}function ko(t,e){return function(n,r){return function(t,e,n,r){return br(t,(function(t,o,i){e(r,n(t),o,i)})),r}(n,t,e(r),{})}}function Ho(t,e){return function(n,r){var i;if(n===o&&r===o)return e;if(n!==o&&(i=n),r!==o){if(i===o)return r;"string"==typeof n||"string"==typeof r?(n=so(n),r=so(r)):(n=io(n),r=io(r)),i=t(n,r)}return i}}function Go(t){return ti((function(e){return e=Me(e,Ke(si())),zr((function(n){var r=this;return t(e,(function(t){return xe(t,r,n)}))}))}))}function Uo(t,e){var n=(e=e===o?" ":so(e)).length;if(n<2)return n?Wr(e,t):e;var r=Wr(e,de(t/cn(e)));return rn(e)?vo(hn(r),0,t).join(""):r.slice(0,t)}function Vo(t){return function(e,n,i){return i&&"number"!=typeof i&&yi(e,n,i)&&(n=i=o),e=da(e),n===o?(n=e,e=0):n=da(n),function(t,e,n,o){for(var i=-1,s=gn(de((e-t)/(n||1)),0),a=r(s);s--;)a[o?s:++i]=t,t+=n;return a}(e,n,i=i===o?e<n?1:-1:da(i),t)}}function jo(t){return function(e,n){return"string"==typeof e&&"string"==typeof n||(e=ma(e),n=ma(n)),t(e,n)}}function qo(t,e,n,r,i,s,a,u,c,h){var d=8&e;e|=d?l:64,4&(e&=~(d?64:l))||(e&=-4);var f=[t,e,i,d?s:o,d?a:o,d?o:s,d?o:a,u,c,h],p=n.apply(o,f);return vi(t)&&Ii(p,f),p.placeholder=r,Pi(p,t,e)}function Wo(t){var e=xt[t];return function(t,n){if(t=ma(t),(n=null==n?0:yn(fa(n),292))&&Be(t)){var r=(ya(t)+"e").split("e");return+((r=(ya(e(r[0]+"e"+(+r[1]+n)))+"e").split("e"))[0]+"e"+(+r[1]-n))}return e(t)}}var zo=Tn&&1/ln(new Tn([,-0]))[1]==c?function(t){return new Tn(t)}:al;function Yo(t){return function(e){var n=di(e);return n==A?on(e):n==I?un(e):function(t,e){return Me(e,(function(e){return[e,t[e]]}))}(e,t(e))}}function Ko(t,e,n,s,c,h,d,f){var p=2&e;if(!p&&"function"!=typeof t)throw new It(i);var m=s?s.length:0;if(m||(e&=-97,s=c=o),d=d===o?d:gn(fa(d),0),f=f===o?f:fa(f),m-=c?c.length:0,64&e){var g=s,y=c;s=c=o}var b=p?o:ri(t),v=[t,e,n,s,c,g,y,h,d,f];if(b&&function(t,e){var n=t[1],r=e[1],o=n|r,i=o<131,s=r==u&&8==n||r==u&&256==n&&t[7].length<=e[8]||384==r&&e[7].length<=e[8]&&8==n;if(!i&&!s)return t;1&r&&(t[2]=e[2],o|=1&n?0:4);var l=e[3];if(l){var c=t[3];t[3]=c?To(c,l,e[4]):l,t[4]=c?an(t[3],a):e[4]}(l=e[5])&&(c=t[5],t[5]=c?So(c,l,e[6]):l,t[6]=c?an(t[5],a):e[6]),(l=e[7])&&(t[7]=l),r&u&&(t[8]=null==t[8]?e[8]:yn(t[8],e[8])),null==t[9]&&(t[9]=e[9]),t[0]=e[0],t[1]=o}(v,b),t=v[0],e=v[1],n=v[2],s=v[3],c=v[4],!(f=v[9]=v[9]===o?p?0:t.length:gn(v[9]-m,0))&&24&e&&(e&=-25),e&&1!=e)C=8==e||16==e?function(t,e,n){var i=Do(t);return function s(){for(var a=arguments.length,l=r(a),u=a,c=ii(s);u--;)l[u]=arguments[u];var h=a<3&&l[0]!==c&&l[a-1]!==c?[]:an(l,c);return(a-=h.length)<n?qo(t,e,$o,s.placeholder,o,l,h,o,o,n-a):xe(this&&this!==he&&this instanceof s?i:t,this,l)}}(t,e,f):e!=l&&33!=e||c.length?$o.apply(o,v):function(t,e,n,o){var i=1&e,s=Do(t);return function e(){for(var a=-1,l=arguments.length,u=-1,c=o.length,h=r(c+l),d=this&&this!==he&&this instanceof e?s:t;++u<c;)h[u]=o[u];for(;l--;)h[u++]=arguments[++a];return xe(d,i?n:this,h)}}(t,e,n,s);else var C=function(t,e,n){var r=1&e,o=Do(t);return function e(){return(this&&this!==he&&this instanceof e?o:t).apply(r?n:this,arguments)}}(t,e,n);return Pi((b?Qr:Ii)(C,v),t,e)}function Jo(t,e,n,r){return t===o||ks(t,Pt[n])&&!Ot.call(r,n)?e:t}function Qo(t,e,n,r,i,s){return Zs(t)&&Zs(e)&&(s.set(e,t),kr(t,e,o,Qo,s),s.delete(e)),t}function Xo(t){return ra(t)?o:t}function Zo(t,e,n,r,i,s){var a=1&n,l=t.length,u=e.length;if(l!=u&&!(a&&u>l))return!1;var c=s.get(t),h=s.get(e);if(c&&h)return c==e&&h==t;var d=-1,f=!0,p=2&n?new Wn:o;for(s.set(t,e),s.set(e,t);++d<l;){var m=t[d],g=e[d];if(r)var y=a?r(g,m,d,e,t,s):r(m,g,d,t,e,s);if(y!==o){if(y)continue;f=!1;break}if(p){if(!De(e,(function(t,e){if(!Qe(p,e)&&(m===t||i(m,t,n,r,s)))return p.push(e)}))){f=!1;break}}else if(m!==g&&!i(m,g,n,r,s)){f=!1;break}}return s.delete(t),s.delete(e),f}function ti(t){return Ni(Ei(t,o,ji),t+"")}function ei(t){return Ar(t,Pa,ci)}function ni(t){return Ar(t,Ma,hi)}var ri=_n?function(t){return _n.get(t)}:al;function oi(t){for(var e=t.name+"",n=Nn[e],r=Ot.call(Nn,e)?n.length:0;r--;){var o=n[r],i=o.func;if(null==i||i==t)return o.name}return e}function ii(t){return(Ot.call($n,"placeholder")?$n:t).placeholder}function si(){var t=$n.iteratee||rl;return t=t===rl?Or:t,arguments.length?t(arguments[0],arguments[1]):t}function ai(t,e){var n,r,o=t.__data__;return("string"==(r=typeof(n=e))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?o["string"==typeof e?"string":"hash"]:o.map}function li(t){for(var e=Pa(t),n=e.length;n--;){var r=e[n],o=t[r];e[n]=[r,o,Ai(o)]}return e}function ui(t,e){var n=function(t,e){return null==t?o:t[e]}(t,e);return Lr(n)?n:o}var ci=me?function(t){return null==t?[]:(t=Et(t),_e(me(t),(function(e){return Wt.call(t,e)})))}:pl,hi=me?function(t){for(var e=[];t;)Le(e,ci(t)),t=jt(t);return e}:pl,di=xr;function fi(t,e,n){for(var r=-1,o=(e=yo(e,t)).length,i=!1;++r<o;){var s=Bi(e[r]);if(!(i=null!=t&&n(t,s)))break;t=t[s]}return i||++r!=o?i:!!(o=null==t?0:t.length)&&Xs(o)&&gi(s,o)&&(Vs(t)||Us(t))}function pi(t){return"function"!=typeof t.constructor||wi(t)?{}:kn(jt(t))}function mi(t){return Vs(t)||Us(t)||!!(Yt&&t&&t[Yt])}function gi(t,e){var n=typeof t;return!!(e=null==e?h:e)&&("number"==n||"symbol"!=n&&yt.test(t))&&t>-1&&t%1==0&&t<e}function yi(t,e,n){if(!Zs(n))return!1;var r=typeof e;return!!("number"==r?qs(n)&&gi(e,n.length):"string"==r&&e in n)&&ks(n[e],t)}function bi(t,e){if(Vs(t))return!1;var n=typeof t;return!("number"!=n&&"symbol"!=n&&"boolean"!=n&&null!=t&&!aa(t))||Z.test(t)||!X.test(t)||null!=e&&t in Et(e)}function vi(t){var e=oi(t),n=$n[e];if("function"!=typeof n||!(e in Un.prototype))return!1;if(t===n)return!0;var r=ri(n);return!!r&&t===r[0]}(An&&di(new An(new ArrayBuffer(1)))!=L||xn&&di(new xn)!=A||En&&di(En.resolve())!=T||Tn&&di(new Tn)!=I||Sn&&di(new Sn)!=P)&&(di=function(t){var e=xr(t),n=e==E?t.constructor:o,r=n?Fi(n):"";if(r)switch(r){case Pn:return L;case Mn:return A;case Ln:return T;case On:return I;case Rn:return P}return e});var Ci=Mt?Js:ml;function wi(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||Pt)}function Ai(t){return t==t&&!Zs(t)}function xi(t,e){return function(n){return null!=n&&n[t]===e&&(e!==o||t in Et(n))}}function Ei(t,e,n){return e=gn(e===o?t.length-1:e,0),function(){for(var o=arguments,i=-1,s=gn(o.length-e,0),a=r(s);++i<s;)a[i]=o[e+i];i=-1;for(var l=r(e+1);++i<e;)l[i]=o[i];return l[e]=n(a),xe(t,this,l)}}function Ti(t,e){return e.length<2?t:wr(t,to(e,0,-1))}function Si(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}var Ii=Mi(Qr),_i=ce||function(t,e){return he.setTimeout(t,e)},Ni=Mi(Xr);function Pi(t,e,n){var r=e+"";return Ni(t,function(t,e){var n=e.length;if(!n)return t;var r=n-1;return e[r]=(n>1?"& ":"")+e[r],e=e.join(n>2?", ":" "),t.replace(it,"{\n/* [wrapped with "+e+"] */\n")}(r,function(t,e){return Te(p,(function(n){var r="_."+n[0];e&n[1]&&!Ne(t,r)&&t.push(r)})),t.sort()}(function(t){var e=t.match(st);return e?e[1].split(at):[]}(r),n)))}function Mi(t){var e=0,n=0;return function(){var r=bn(),i=16-(r-n);if(n=r,i>0){if(++e>=800)return arguments[0]}else e=0;return t.apply(o,arguments)}}function Li(t,e){var n=-1,r=t.length,i=r-1;for(e=e===o?r:e;++n<e;){var s=qr(n,i),a=t[s];t[s]=t[n],t[n]=a}return t.length=e,t}var Oi,Ri,Di=(Oi=Os((function(t){var e=[];return 46===t.charCodeAt(0)&&e.push(""),t.replace(tt,(function(t,n,r,o){e.push(r?o.replace(ct,"$1"):n||t)})),e}),(function(t){return 500===Ri.size&&Ri.clear(),t})),Ri=Oi.cache,Oi);function Bi(t){if("string"==typeof t||aa(t))return t;var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}function Fi(t){if(null!=t){try{return Lt.call(t)}catch(t){}try{return t+""}catch(t){}}return""}function $i(t){if(t instanceof Un)return t.clone();var e=new Gn(t.__wrapped__,t.__chain__);return e.__actions__=Io(t.__actions__),e.__index__=t.__index__,e.__values__=t.__values__,e}var ki=zr((function(t,e){return Ws(t)?ur(t,mr(e,1,Ws,!0)):[]})),Hi=zr((function(t,e){var n=Ki(e);return Ws(n)&&(n=o),Ws(t)?ur(t,mr(e,1,Ws,!0),si(n,2)):[]})),Gi=zr((function(t,e){var n=Ki(e);return Ws(n)&&(n=o),Ws(t)?ur(t,mr(e,1,Ws,!0),o,n):[]}));function Ui(t,e,n){var r=null==t?0:t.length;if(!r)return-1;var o=null==n?0:fa(n);return o<0&&(o=gn(r+o,0)),$e(t,si(e,3),o)}function Vi(t,e,n){var r=null==t?0:t.length;if(!r)return-1;var i=r-1;return n!==o&&(i=fa(n),i=n<0?gn(r+i,0):yn(i,r-1)),$e(t,si(e,3),i,!0)}function ji(t){return null!=t&&t.length?mr(t,1):[]}function qi(t){return t&&t.length?t[0]:o}var Wi=zr((function(t){var e=Me(t,mo);return e.length&&e[0]===t[0]?Ir(e):[]})),zi=zr((function(t){var e=Ki(t),n=Me(t,mo);return e===Ki(n)?e=o:n.pop(),n.length&&n[0]===t[0]?Ir(n,si(e,2)):[]})),Yi=zr((function(t){var e=Ki(t),n=Me(t,mo);return(e="function"==typeof e?e:o)&&n.pop(),n.length&&n[0]===t[0]?Ir(n,o,e):[]}));function Ki(t){var e=null==t?0:t.length;return e?t[e-1]:o}var Ji=zr(Qi);function Qi(t,e){return t&&t.length&&e&&e.length?Vr(t,e):t}var Xi=ti((function(t,e){var n=null==t?0:t.length,r=or(t,e);return jr(t,Me(e,(function(t){return gi(t,n)?+t:t})).sort(Eo)),r}));function Zi(t){return null==t?t:wn.call(t)}var ts=zr((function(t){return ao(mr(t,1,Ws,!0))})),es=zr((function(t){var e=Ki(t);return Ws(e)&&(e=o),ao(mr(t,1,Ws,!0),si(e,2))})),ns=zr((function(t){var e=Ki(t);return e="function"==typeof e?e:o,ao(mr(t,1,Ws,!0),o,e)}));function rs(t){if(!t||!t.length)return[];var e=0;return t=_e(t,(function(t){if(Ws(t))return e=gn(t.length,e),!0})),ze(e,(function(e){return Me(t,Ve(e))}))}function os(t,e){if(!t||!t.length)return[];var n=rs(t);return null==e?n:Me(n,(function(t){return xe(e,o,t)}))}var is=zr((function(t,e){return Ws(t)?ur(t,e):[]})),ss=zr((function(t){return fo(_e(t,Ws))})),as=zr((function(t){var e=Ki(t);return Ws(e)&&(e=o),fo(_e(t,Ws),si(e,2))})),ls=zr((function(t){var e=Ki(t);return e="function"==typeof e?e:o,fo(_e(t,Ws),o,e)})),us=zr(rs),cs=zr((function(t){var e=t.length,n=e>1?t[e-1]:o;return n="function"==typeof n?(t.pop(),n):o,os(t,n)}));function hs(t){var e=$n(t);return e.__chain__=!0,e}function ds(t,e){return e(t)}var fs=ti((function(t){var e=t.length,n=e?t[0]:0,r=this.__wrapped__,i=function(e){return or(e,t)};return!(e>1||this.__actions__.length)&&r instanceof Un&&gi(n)?((r=r.slice(n,+n+(e?1:0))).__actions__.push({func:ds,args:[i],thisArg:o}),new Gn(r,this.__chain__).thru((function(t){return e&&!t.length&&t.push(o),t}))):this.thru(i)})),ps=No((function(t,e,n){Ot.call(t,n)?++t[n]:rr(t,n,1)})),ms=Bo(Ui),gs=Bo(Vi);function ys(t,e){return(Vs(t)?Te:cr)(t,si(e,3))}function bs(t,e){return(Vs(t)?Se:hr)(t,si(e,3))}var vs=No((function(t,e,n){Ot.call(t,n)?t[n].push(e):rr(t,n,[e])})),Cs=zr((function(t,e,n){var o=-1,i="function"==typeof e,s=qs(t)?r(t.length):[];return cr(t,(function(t){s[++o]=i?xe(e,t,n):_r(t,e,n)})),s})),ws=No((function(t,e,n){rr(t,n,e)}));function As(t,e){return(Vs(t)?Me:Br)(t,si(e,3))}var xs=No((function(t,e,n){t[n?0:1].push(e)}),(function(){return[[],[]]})),Es=zr((function(t,e){if(null==t)return[];var n=e.length;return n>1&&yi(t,e[0],e[1])?e=[]:n>2&&yi(e[0],e[1],e[2])&&(e=[e[0]]),Gr(t,mr(e,1),[])})),Ts=ue||function(){return he.Date.now()};function Ss(t,e,n){return e=n?o:e,e=t&&null==e?t.length:e,Ko(t,u,o,o,o,o,e)}function Is(t,e){var n;if("function"!=typeof e)throw new It(i);return t=fa(t),function(){return--t>0&&(n=e.apply(this,arguments)),t<=1&&(e=o),n}}var _s=zr((function(t,e,n){var r=1;if(n.length){var o=an(n,ii(_s));r|=l}return Ko(t,r,e,n,o)})),Ns=zr((function(t,e,n){var r=3;if(n.length){var o=an(n,ii(Ns));r|=l}return Ko(e,r,t,n,o)}));function Ps(t,e,n){var r,s,a,l,u,c,h=0,d=!1,f=!1,p=!0;if("function"!=typeof t)throw new It(i);function m(e){var n=r,i=s;return r=s=o,h=e,l=t.apply(i,n)}function g(t){var n=t-c;return c===o||n>=e||n<0||f&&t-h>=a}function y(){var t=Ts();if(g(t))return b(t);u=_i(y,function(t){var n=e-(t-c);return f?yn(n,a-(t-h)):n}(t))}function b(t){return u=o,p&&r?m(t):(r=s=o,l)}function v(){var t=Ts(),n=g(t);if(r=arguments,s=this,c=t,n){if(u===o)return function(t){return h=t,u=_i(y,e),d?m(t):l}(c);if(f)return Co(u),u=_i(y,e),m(c)}return u===o&&(u=_i(y,e)),l}return e=ma(e)||0,Zs(n)&&(d=!!n.leading,a=(f="maxWait"in n)?gn(ma(n.maxWait)||0,e):a,p="trailing"in n?!!n.trailing:p),v.cancel=function(){u!==o&&Co(u),h=0,r=c=s=u=o},v.flush=function(){return u===o?l:b(Ts())},v}var Ms=zr((function(t,e){return lr(t,1,e)})),Ls=zr((function(t,e,n){return lr(t,ma(e)||0,n)}));function Os(t,e){if("function"!=typeof t||null!=e&&"function"!=typeof e)throw new It(i);var n=function(){var r=arguments,o=e?e.apply(this,r):r[0],i=n.cache;if(i.has(o))return i.get(o);var s=t.apply(this,r);return n.cache=i.set(o,s)||i,s};return n.cache=new(Os.Cache||qn),n}function Rs(t){if("function"!=typeof t)throw new It(i);return function(){var e=arguments;switch(e.length){case 0:return!t.call(this);case 1:return!t.call(this,e[0]);case 2:return!t.call(this,e[0],e[1]);case 3:return!t.call(this,e[0],e[1],e[2])}return!t.apply(this,e)}}Os.Cache=qn;var Ds=bo((function(t,e){var n=(e=1==e.length&&Vs(e[0])?Me(e[0],Ke(si())):Me(mr(e,1),Ke(si()))).length;return zr((function(r){for(var o=-1,i=yn(r.length,n);++o<i;)r[o]=e[o].call(this,r[o]);return xe(t,this,r)}))})),Bs=zr((function(t,e){var n=an(e,ii(Bs));return Ko(t,l,o,e,n)})),Fs=zr((function(t,e){var n=an(e,ii(Fs));return Ko(t,64,o,e,n)})),$s=ti((function(t,e){return Ko(t,256,o,o,o,e)}));function ks(t,e){return t===e||t!=t&&e!=e}var Hs=jo(Er),Gs=jo((function(t,e){return t>=e})),Us=Nr(function(){return arguments}())?Nr:function(t){return ta(t)&&Ot.call(t,"callee")&&!Wt.call(t,"callee")},Vs=r.isArray,js=ye?Ke(ye):function(t){return ta(t)&&xr(t)==M};function qs(t){return null!=t&&Xs(t.length)&&!Js(t)}function Ws(t){return ta(t)&&qs(t)}var zs=ge||ml,Ys=be?Ke(be):function(t){return ta(t)&&xr(t)==b};function Ks(t){if(!ta(t))return!1;var e=xr(t);return e==v||"[object DOMException]"==e||"string"==typeof t.message&&"string"==typeof t.name&&!ra(t)}function Js(t){if(!Zs(t))return!1;var e=xr(t);return e==C||e==w||"[object AsyncFunction]"==e||"[object Proxy]"==e}function Qs(t){return"number"==typeof t&&t==fa(t)}function Xs(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=h}function Zs(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function ta(t){return null!=t&&"object"==typeof t}var ea=ve?Ke(ve):function(t){return ta(t)&&di(t)==A};function na(t){return"number"==typeof t||ta(t)&&xr(t)==x}function ra(t){if(!ta(t)||xr(t)!=E)return!1;var e=jt(t);if(null===e)return!0;var n=Ot.call(e,"constructor")&&e.constructor;return"function"==typeof n&&n instanceof n&&Lt.call(n)==Ft}var oa=Ce?Ke(Ce):function(t){return ta(t)&&xr(t)==S},ia=we?Ke(we):function(t){return ta(t)&&di(t)==I};function sa(t){return"string"==typeof t||!Vs(t)&&ta(t)&&xr(t)==_}function aa(t){return"symbol"==typeof t||ta(t)&&xr(t)==N}var la=Ae?Ke(Ae):function(t){return ta(t)&&Xs(t.length)&&!!oe[xr(t)]},ua=jo(Dr),ca=jo((function(t,e){return t<=e}));function ha(t){if(!t)return[];if(qs(t))return sa(t)?hn(t):Io(t);if(Kt&&t[Kt])return function(t){for(var e,n=[];!(e=t.next()).done;)n.push(e.value);return n}(t[Kt]());var e=di(t);return(e==A?on:e==I?ln:ka)(t)}function da(t){return t?(t=ma(t))===c||t===-1/0?17976931348623157e292*(t<0?-1:1):t==t?t:0:0===t?t:0}function fa(t){var e=da(t),n=e%1;return e==e?n?e-n:e:0}function pa(t){return t?ir(fa(t),0,f):0}function ma(t){if("number"==typeof t)return t;if(aa(t))return d;if(Zs(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=Zs(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=Ye(t);var n=pt.test(t);return n||gt.test(t)?le(t.slice(2),n?2:8):ft.test(t)?d:+t}function ga(t){return _o(t,Ma(t))}function ya(t){return null==t?"":so(t)}var ba=Po((function(t,e){if(wi(e)||qs(e))_o(e,Pa(e),t);else for(var n in e)Ot.call(e,n)&&Zn(t,n,e[n])})),va=Po((function(t,e){_o(e,Ma(e),t)})),Ca=Po((function(t,e,n,r){_o(e,Ma(e),t,r)})),wa=Po((function(t,e,n,r){_o(e,Pa(e),t,r)})),Aa=ti(or),xa=zr((function(t,e){t=Et(t);var n=-1,r=e.length,i=r>2?e[2]:o;for(i&&yi(e[0],e[1],i)&&(r=1);++n<r;)for(var s=e[n],a=Ma(s),l=-1,u=a.length;++l<u;){var c=a[l],h=t[c];(h===o||ks(h,Pt[c])&&!Ot.call(t,c))&&(t[c]=s[c])}return t})),Ea=zr((function(t){return t.push(o,Qo),xe(Oa,o,t)}));function Ta(t,e,n){var r=null==t?o:wr(t,e);return r===o?n:r}function Sa(t,e){return null!=t&&fi(t,e,Sr)}var Ia=ko((function(t,e,n){null!=e&&"function"!=typeof e.toString&&(e=Bt.call(e)),t[e]=n}),Za(nl)),_a=ko((function(t,e,n){null!=e&&"function"!=typeof e.toString&&(e=Bt.call(e)),Ot.call(t,e)?t[e].push(n):t[e]=[n]}),si),Na=zr(_r);function Pa(t){return qs(t)?Yn(t):Rr(t)}function Ma(t){return qs(t)?Yn(t,!0):function(t){if(!Zs(t))return function(t){var e=[];if(null!=t)for(var n in Et(t))e.push(n);return e}(t);var e=wi(t),n=[];for(var r in t)("constructor"!=r||!e&&Ot.call(t,r))&&n.push(r);return n}(t)}var La=Po((function(t,e,n){kr(t,e,n)})),Oa=Po((function(t,e,n,r){kr(t,e,n,r)})),Ra=ti((function(t,e){var n={};if(null==t)return n;var r=!1;e=Me(e,(function(e){return e=yo(e,t),r||(r=e.length>1),e})),_o(t,ni(t),n),r&&(n=sr(n,7,Xo));for(var o=e.length;o--;)lo(n,e[o]);return n})),Da=ti((function(t,e){return null==t?{}:function(t,e){return Ur(t,e,(function(e,n){return Sa(t,n)}))}(t,e)}));function Ba(t,e){if(null==t)return{};var n=Me(ni(t),(function(t){return[t]}));return e=si(e),Ur(t,n,(function(t,n){return e(t,n[0])}))}var Fa=Yo(Pa),$a=Yo(Ma);function ka(t){return null==t?[]:Je(t,Pa(t))}var Ha=Ro((function(t,e,n){return e=e.toLowerCase(),t+(n?Ga(e):e)}));function Ga(t){return Ka(ya(t).toLowerCase())}function Ua(t){return(t=ya(t))&&t.replace(bt,tn).replace(Qt,"")}var Va=Ro((function(t,e,n){return t+(n?"-":"")+e.toLowerCase()})),ja=Ro((function(t,e,n){return t+(n?" ":"")+e.toLowerCase()})),qa=Oo("toLowerCase"),Wa=Ro((function(t,e,n){return t+(n?"_":"")+e.toLowerCase()})),za=Ro((function(t,e,n){return t+(n?" ":"")+Ka(e)})),Ya=Ro((function(t,e,n){return t+(n?" ":"")+e.toUpperCase()})),Ka=Oo("toUpperCase");function Ja(t,e,n){return t=ya(t),(e=n?o:e)===o?function(t){return ee.test(t)}(t)?function(t){return t.match(Zt)||[]}(t):function(t){return t.match(lt)||[]}(t):t.match(e)||[]}var Qa=zr((function(t,e){try{return xe(t,o,e)}catch(t){return Ks(t)?t:new wt(t)}})),Xa=ti((function(t,e){return Te(e,(function(e){e=Bi(e),rr(t,e,_s(t[e],t))})),t}));function Za(t){return function(){return t}}var tl=Fo(),el=Fo(!0);function nl(t){return t}function rl(t){return Or("function"==typeof t?t:sr(t,1))}var ol=zr((function(t,e){return function(n){return _r(n,t,e)}})),il=zr((function(t,e){return function(n){return _r(t,n,e)}}));function sl(t,e,n){var r=Pa(e),o=Cr(e,r);null!=n||Zs(e)&&(o.length||!r.length)||(n=e,e=t,t=this,o=Cr(e,Pa(e)));var i=!(Zs(n)&&"chain"in n&&!n.chain),s=Js(t);return Te(o,(function(n){var r=e[n];t[n]=r,s&&(t.prototype[n]=function(){var e=this.__chain__;if(i||e){var n=t(this.__wrapped__);return(n.__actions__=Io(this.__actions__)).push({func:r,args:arguments,thisArg:t}),n.__chain__=e,n}return r.apply(t,Le([this.value()],arguments))})})),t}function al(){}var ll=Go(Me),ul=Go(Ie),cl=Go(De);function hl(t){return bi(t)?Ve(Bi(t)):function(t){return function(e){return wr(e,t)}}(t)}var dl=Vo(),fl=Vo(!0);function pl(){return[]}function ml(){return!1}var gl,yl=Ho((function(t,e){return t+e}),0),bl=Wo("ceil"),vl=Ho((function(t,e){return t/e}),1),Cl=Wo("floor"),wl=Ho((function(t,e){return t*e}),1),Al=Wo("round"),xl=Ho((function(t,e){return t-e}),0);return $n.after=function(t,e){if("function"!=typeof e)throw new It(i);return t=fa(t),function(){if(--t<1)return e.apply(this,arguments)}},$n.ary=Ss,$n.assign=ba,$n.assignIn=va,$n.assignInWith=Ca,$n.assignWith=wa,$n.at=Aa,$n.before=Is,$n.bind=_s,$n.bindAll=Xa,$n.bindKey=Ns,$n.castArray=function(){if(!arguments.length)return[];var t=arguments[0];return Vs(t)?t:[t]},$n.chain=hs,$n.chunk=function(t,e,n){e=(n?yi(t,e,n):e===o)?1:gn(fa(e),0);var i=null==t?0:t.length;if(!i||e<1)return[];for(var s=0,a=0,l=r(de(i/e));s<i;)l[a++]=to(t,s,s+=e);return l},$n.compact=function(t){for(var e=-1,n=null==t?0:t.length,r=0,o=[];++e<n;){var i=t[e];i&&(o[r++]=i)}return o},$n.concat=function(){var t=arguments.length;if(!t)return[];for(var e=r(t-1),n=arguments[0],o=t;o--;)e[o-1]=arguments[o];return Le(Vs(n)?Io(n):[n],mr(e,1))},$n.cond=function(t){var e=null==t?0:t.length,n=si();return t=e?Me(t,(function(t){if("function"!=typeof t[1])throw new It(i);return[n(t[0]),t[1]]})):[],zr((function(n){for(var r=-1;++r<e;){var o=t[r];if(xe(o[0],this,n))return xe(o[1],this,n)}}))},$n.conforms=function(t){return function(t){var e=Pa(t);return function(n){return ar(n,t,e)}}(sr(t,1))},$n.constant=Za,$n.countBy=ps,$n.create=function(t,e){var n=kn(t);return null==e?n:nr(n,e)},$n.curry=function t(e,n,r){var i=Ko(e,8,o,o,o,o,o,n=r?o:n);return i.placeholder=t.placeholder,i},$n.curryRight=function t(e,n,r){var i=Ko(e,16,o,o,o,o,o,n=r?o:n);return i.placeholder=t.placeholder,i},$n.debounce=Ps,$n.defaults=xa,$n.defaultsDeep=Ea,$n.defer=Ms,$n.delay=Ls,$n.difference=ki,$n.differenceBy=Hi,$n.differenceWith=Gi,$n.drop=function(t,e,n){var r=null==t?0:t.length;return r?to(t,(e=n||e===o?1:fa(e))<0?0:e,r):[]},$n.dropRight=function(t,e,n){var r=null==t?0:t.length;return r?to(t,0,(e=r-(e=n||e===o?1:fa(e)))<0?0:e):[]},$n.dropRightWhile=function(t,e){return t&&t.length?co(t,si(e,3),!0,!0):[]},$n.dropWhile=function(t,e){return t&&t.length?co(t,si(e,3),!0):[]},$n.fill=function(t,e,n,r){var i=null==t?0:t.length;return i?(n&&"number"!=typeof n&&yi(t,e,n)&&(n=0,r=i),function(t,e,n,r){var i=t.length;for((n=fa(n))<0&&(n=-n>i?0:i+n),(r=r===o||r>i?i:fa(r))<0&&(r+=i),r=n>r?0:pa(r);n<r;)t[n++]=e;return t}(t,e,n,r)):[]},$n.filter=function(t,e){return(Vs(t)?_e:pr)(t,si(e,3))},$n.flatMap=function(t,e){return mr(As(t,e),1)},$n.flatMapDeep=function(t,e){return mr(As(t,e),c)},$n.flatMapDepth=function(t,e,n){return n=n===o?1:fa(n),mr(As(t,e),n)},$n.flatten=ji,$n.flattenDeep=function(t){return null!=t&&t.length?mr(t,c):[]},$n.flattenDepth=function(t,e){return null!=t&&t.length?mr(t,e=e===o?1:fa(e)):[]},$n.flip=function(t){return Ko(t,512)},$n.flow=tl,$n.flowRight=el,$n.fromPairs=function(t){for(var e=-1,n=null==t?0:t.length,r={};++e<n;){var o=t[e];r[o[0]]=o[1]}return r},$n.functions=function(t){return null==t?[]:Cr(t,Pa(t))},$n.functionsIn=function(t){return null==t?[]:Cr(t,Ma(t))},$n.groupBy=vs,$n.initial=function(t){return null!=t&&t.length?to(t,0,-1):[]},$n.intersection=Wi,$n.intersectionBy=zi,$n.intersectionWith=Yi,$n.invert=Ia,$n.invertBy=_a,$n.invokeMap=Cs,$n.iteratee=rl,$n.keyBy=ws,$n.keys=Pa,$n.keysIn=Ma,$n.map=As,$n.mapKeys=function(t,e){var n={};return e=si(e,3),br(t,(function(t,r,o){rr(n,e(t,r,o),t)})),n},$n.mapValues=function(t,e){var n={};return e=si(e,3),br(t,(function(t,r,o){rr(n,r,e(t,r,o))})),n},$n.matches=function(t){return Fr(sr(t,1))},$n.matchesProperty=function(t,e){return $r(t,sr(e,1))},$n.memoize=Os,$n.merge=La,$n.mergeWith=Oa,$n.method=ol,$n.methodOf=il,$n.mixin=sl,$n.negate=Rs,$n.nthArg=function(t){return t=fa(t),zr((function(e){return Hr(e,t)}))},$n.omit=Ra,$n.omitBy=function(t,e){return Ba(t,Rs(si(e)))},$n.once=function(t){return Is(2,t)},$n.orderBy=function(t,e,n,r){return null==t?[]:(Vs(e)||(e=null==e?[]:[e]),Vs(n=r?o:n)||(n=null==n?[]:[n]),Gr(t,e,n))},$n.over=ll,$n.overArgs=Ds,$n.overEvery=ul,$n.overSome=cl,$n.partial=Bs,$n.partialRight=Fs,$n.partition=xs,$n.pick=Da,$n.pickBy=Ba,$n.property=hl,$n.propertyOf=function(t){return function(e){return null==t?o:wr(t,e)}},$n.pull=Ji,$n.pullAll=Qi,$n.pullAllBy=function(t,e,n){return t&&t.length&&e&&e.length?Vr(t,e,si(n,2)):t},$n.pullAllWith=function(t,e,n){return t&&t.length&&e&&e.length?Vr(t,e,o,n):t},$n.pullAt=Xi,$n.range=dl,$n.rangeRight=fl,$n.rearg=$s,$n.reject=function(t,e){return(Vs(t)?_e:pr)(t,Rs(si(e,3)))},$n.remove=function(t,e){var n=[];if(!t||!t.length)return n;var r=-1,o=[],i=t.length;for(e=si(e,3);++r<i;){var s=t[r];e(s,r,t)&&(n.push(s),o.push(r))}return jr(t,o),n},$n.rest=function(t,e){if("function"!=typeof t)throw new It(i);return zr(t,e=e===o?e:fa(e))},$n.reverse=Zi,$n.sampleSize=function(t,e,n){return e=(n?yi(t,e,n):e===o)?1:fa(e),(Vs(t)?Jn:Kr)(t,e)},$n.set=function(t,e,n){return null==t?t:Jr(t,e,n)},$n.setWith=function(t,e,n,r){return r="function"==typeof r?r:o,null==t?t:Jr(t,e,n,r)},$n.shuffle=function(t){return(Vs(t)?Qn:Zr)(t)},$n.slice=function(t,e,n){var r=null==t?0:t.length;return r?(n&&"number"!=typeof n&&yi(t,e,n)?(e=0,n=r):(e=null==e?0:fa(e),n=n===o?r:fa(n)),to(t,e,n)):[]},$n.sortBy=Es,$n.sortedUniq=function(t){return t&&t.length?oo(t):[]},$n.sortedUniqBy=function(t,e){return t&&t.length?oo(t,si(e,2)):[]},$n.split=function(t,e,n){return n&&"number"!=typeof n&&yi(t,e,n)&&(e=n=o),(n=n===o?f:n>>>0)?(t=ya(t))&&("string"==typeof e||null!=e&&!oa(e))&&!(e=so(e))&&rn(t)?vo(hn(t),0,n):t.split(e,n):[]},$n.spread=function(t,e){if("function"!=typeof t)throw new It(i);return e=null==e?0:gn(fa(e),0),zr((function(n){var r=n[e],o=vo(n,0,e);return r&&Le(o,r),xe(t,this,o)}))},$n.tail=function(t){var e=null==t?0:t.length;return e?to(t,1,e):[]},$n.take=function(t,e,n){return t&&t.length?to(t,0,(e=n||e===o?1:fa(e))<0?0:e):[]},$n.takeRight=function(t,e,n){var r=null==t?0:t.length;return r?to(t,(e=r-(e=n||e===o?1:fa(e)))<0?0:e,r):[]},$n.takeRightWhile=function(t,e){return t&&t.length?co(t,si(e,3),!1,!0):[]},$n.takeWhile=function(t,e){return t&&t.length?co(t,si(e,3)):[]},$n.tap=function(t,e){return e(t),t},$n.throttle=function(t,e,n){var r=!0,o=!0;if("function"!=typeof t)throw new It(i);return Zs(n)&&(r="leading"in n?!!n.leading:r,o="trailing"in n?!!n.trailing:o),Ps(t,e,{leading:r,maxWait:e,trailing:o})},$n.thru=ds,$n.toArray=ha,$n.toPairs=Fa,$n.toPairsIn=$a,$n.toPath=function(t){return Vs(t)?Me(t,Bi):aa(t)?[t]:Io(Di(ya(t)))},$n.toPlainObject=ga,$n.transform=function(t,e,n){var r=Vs(t),o=r||zs(t)||la(t);if(e=si(e,4),null==n){var i=t&&t.constructor;n=o?r?new i:[]:Zs(t)&&Js(i)?kn(jt(t)):{}}return(o?Te:br)(t,(function(t,r,o){return e(n,t,r,o)})),n},$n.unary=function(t){return Ss(t,1)},$n.union=ts,$n.unionBy=es,$n.unionWith=ns,$n.uniq=function(t){return t&&t.length?ao(t):[]},$n.uniqBy=function(t,e){return t&&t.length?ao(t,si(e,2)):[]},$n.uniqWith=function(t,e){return e="function"==typeof e?e:o,t&&t.length?ao(t,o,e):[]},$n.unset=function(t,e){return null==t||lo(t,e)},$n.unzip=rs,$n.unzipWith=os,$n.update=function(t,e,n){return null==t?t:uo(t,e,go(n))},$n.updateWith=function(t,e,n,r){return r="function"==typeof r?r:o,null==t?t:uo(t,e,go(n),r)},$n.values=ka,$n.valuesIn=function(t){return null==t?[]:Je(t,Ma(t))},$n.without=is,$n.words=Ja,$n.wrap=function(t,e){return Bs(go(e),t)},$n.xor=ss,$n.xorBy=as,$n.xorWith=ls,$n.zip=us,$n.zipObject=function(t,e){return po(t||[],e||[],Zn)},$n.zipObjectDeep=function(t,e){return po(t||[],e||[],Jr)},$n.zipWith=cs,$n.entries=Fa,$n.entriesIn=$a,$n.extend=va,$n.extendWith=Ca,sl($n,$n),$n.add=yl,$n.attempt=Qa,$n.camelCase=Ha,$n.capitalize=Ga,$n.ceil=bl,$n.clamp=function(t,e,n){return n===o&&(n=e,e=o),n!==o&&(n=(n=ma(n))==n?n:0),e!==o&&(e=(e=ma(e))==e?e:0),ir(ma(t),e,n)},$n.clone=function(t){return sr(t,4)},$n.cloneDeep=function(t){return sr(t,5)},$n.cloneDeepWith=function(t,e){return sr(t,5,e="function"==typeof e?e:o)},$n.cloneWith=function(t,e){return sr(t,4,e="function"==typeof e?e:o)},$n.conformsTo=function(t,e){return null==e||ar(t,e,Pa(e))},$n.deburr=Ua,$n.defaultTo=function(t,e){return null==t||t!=t?e:t},$n.divide=vl,$n.endsWith=function(t,e,n){t=ya(t),e=so(e);var r=t.length,i=n=n===o?r:ir(fa(n),0,r);return(n-=e.length)>=0&&t.slice(n,i)==e},$n.eq=ks,$n.escape=function(t){return(t=ya(t))&&Y.test(t)?t.replace(W,en):t},$n.escapeRegExp=function(t){return(t=ya(t))&&nt.test(t)?t.replace(et,"\\$&"):t},$n.every=function(t,e,n){var r=Vs(t)?Ie:dr;return n&&yi(t,e,n)&&(e=o),r(t,si(e,3))},$n.find=ms,$n.findIndex=Ui,$n.findKey=function(t,e){return Fe(t,si(e,3),br)},$n.findLast=gs,$n.findLastIndex=Vi,$n.findLastKey=function(t,e){return Fe(t,si(e,3),vr)},$n.floor=Cl,$n.forEach=ys,$n.forEachRight=bs,$n.forIn=function(t,e){return null==t?t:gr(t,si(e,3),Ma)},$n.forInRight=function(t,e){return null==t?t:yr(t,si(e,3),Ma)},$n.forOwn=function(t,e){return t&&br(t,si(e,3))},$n.forOwnRight=function(t,e){return t&&vr(t,si(e,3))},$n.get=Ta,$n.gt=Hs,$n.gte=Gs,$n.has=function(t,e){return null!=t&&fi(t,e,Tr)},$n.hasIn=Sa,$n.head=qi,$n.identity=nl,$n.includes=function(t,e,n,r){t=qs(t)?t:ka(t),n=n&&!r?fa(n):0;var o=t.length;return n<0&&(n=gn(o+n,0)),sa(t)?n<=o&&t.indexOf(e,n)>-1:!!o&&ke(t,e,n)>-1},$n.indexOf=function(t,e,n){var r=null==t?0:t.length;if(!r)return-1;var o=null==n?0:fa(n);return o<0&&(o=gn(r+o,0)),ke(t,e,o)},$n.inRange=function(t,e,n){return e=da(e),n===o?(n=e,e=0):n=da(n),function(t,e,n){return t>=yn(e,n)&&t<gn(e,n)}(t=ma(t),e,n)},$n.invoke=Na,$n.isArguments=Us,$n.isArray=Vs,$n.isArrayBuffer=js,$n.isArrayLike=qs,$n.isArrayLikeObject=Ws,$n.isBoolean=function(t){return!0===t||!1===t||ta(t)&&xr(t)==y},$n.isBuffer=zs,$n.isDate=Ys,$n.isElement=function(t){return ta(t)&&1===t.nodeType&&!ra(t)},$n.isEmpty=function(t){if(null==t)return!0;if(qs(t)&&(Vs(t)||"string"==typeof t||"function"==typeof t.splice||zs(t)||la(t)||Us(t)))return!t.length;var e=di(t);if(e==A||e==I)return!t.size;if(wi(t))return!Rr(t).length;for(var n in t)if(Ot.call(t,n))return!1;return!0},$n.isEqual=function(t,e){return Pr(t,e)},$n.isEqualWith=function(t,e,n){var r=(n="function"==typeof n?n:o)?n(t,e):o;return r===o?Pr(t,e,o,n):!!r},$n.isError=Ks,$n.isFinite=function(t){return"number"==typeof t&&Be(t)},$n.isFunction=Js,$n.isInteger=Qs,$n.isLength=Xs,$n.isMap=ea,$n.isMatch=function(t,e){return t===e||Mr(t,e,li(e))},$n.isMatchWith=function(t,e,n){return n="function"==typeof n?n:o,Mr(t,e,li(e),n)},$n.isNaN=function(t){return na(t)&&t!=+t},$n.isNative=function(t){if(Ci(t))throw new wt("Unsupported core-js use. Try https://npms.io/search?q=ponyfill.");return Lr(t)},$n.isNil=function(t){return null==t},$n.isNull=function(t){return null===t},$n.isNumber=na,$n.isObject=Zs,$n.isObjectLike=ta,$n.isPlainObject=ra,$n.isRegExp=oa,$n.isSafeInteger=function(t){return Qs(t)&&t>=-9007199254740991&&t<=h},$n.isSet=ia,$n.isString=sa,$n.isSymbol=aa,$n.isTypedArray=la,$n.isUndefined=function(t){return t===o},$n.isWeakMap=function(t){return ta(t)&&di(t)==P},$n.isWeakSet=function(t){return ta(t)&&"[object WeakSet]"==xr(t)},$n.join=function(t,e){return null==t?"":je.call(t,e)},$n.kebabCase=Va,$n.last=Ki,$n.lastIndexOf=function(t,e,n){var r=null==t?0:t.length;if(!r)return-1;var i=r;return n!==o&&(i=(i=fa(n))<0?gn(r+i,0):yn(i,r-1)),e==e?function(t,e,n){for(var r=n+1;r--;)if(t[r]===e)return r;return r}(t,e,i):$e(t,Ge,i,!0)},$n.lowerCase=ja,$n.lowerFirst=qa,$n.lt=ua,$n.lte=ca,$n.max=function(t){return t&&t.length?fr(t,nl,Er):o},$n.maxBy=function(t,e){return t&&t.length?fr(t,si(e,2),Er):o},$n.mean=function(t){return Ue(t,nl)},$n.meanBy=function(t,e){return Ue(t,si(e,2))},$n.min=function(t){return t&&t.length?fr(t,nl,Dr):o},$n.minBy=function(t,e){return t&&t.length?fr(t,si(e,2),Dr):o},$n.stubArray=pl,$n.stubFalse=ml,$n.stubObject=function(){return{}},$n.stubString=function(){return""},$n.stubTrue=function(){return!0},$n.multiply=wl,$n.nth=function(t,e){return t&&t.length?Hr(t,fa(e)):o},$n.noConflict=function(){return he._===this&&(he._=$t),this},$n.noop=al,$n.now=Ts,$n.pad=function(t,e,n){t=ya(t);var r=(e=fa(e))?cn(t):0;if(!e||r>=e)return t;var o=(e-r)/2;return Uo(fe(o),n)+t+Uo(de(o),n)},$n.padEnd=function(t,e,n){t=ya(t);var r=(e=fa(e))?cn(t):0;return e&&r<e?t+Uo(e-r,n):t},$n.padStart=function(t,e,n){t=ya(t);var r=(e=fa(e))?cn(t):0;return e&&r<e?Uo(e-r,n)+t:t},$n.parseInt=function(t,e,n){return n||null==e?e=0:e&&(e=+e),vn(ya(t).replace(rt,""),e||0)},$n.random=function(t,e,n){if(n&&"boolean"!=typeof n&&yi(t,e,n)&&(e=n=o),n===o&&("boolean"==typeof e?(n=e,e=o):"boolean"==typeof t&&(n=t,t=o)),t===o&&e===o?(t=0,e=1):(t=da(t),e===o?(e=t,t=0):e=da(e)),t>e){var r=t;t=e,e=r}if(n||t%1||e%1){var i=Cn();return yn(t+i*(e-t+ae("1e-"+((i+"").length-1))),e)}return qr(t,e)},$n.reduce=function(t,e,n){var r=Vs(t)?Oe:qe,o=arguments.length<3;return r(t,si(e,4),n,o,cr)},$n.reduceRight=function(t,e,n){var r=Vs(t)?Re:qe,o=arguments.length<3;return r(t,si(e,4),n,o,hr)},$n.repeat=function(t,e,n){return e=(n?yi(t,e,n):e===o)?1:fa(e),Wr(ya(t),e)},$n.replace=function(){var t=arguments,e=ya(t[0]);return t.length<3?e:e.replace(t[1],t[2])},$n.result=function(t,e,n){var r=-1,i=(e=yo(e,t)).length;for(i||(i=1,t=o);++r<i;){var s=null==t?o:t[Bi(e[r])];s===o&&(r=i,s=n),t=Js(s)?s.call(t):s}return t},$n.round=Al,$n.runInContext=t,$n.sample=function(t){return(Vs(t)?Kn:Yr)(t)},$n.size=function(t){if(null==t)return 0;if(qs(t))return sa(t)?cn(t):t.length;var e=di(t);return e==A||e==I?t.size:Rr(t).length},$n.snakeCase=Wa,$n.some=function(t,e,n){var r=Vs(t)?De:eo;return n&&yi(t,e,n)&&(e=o),r(t,si(e,3))},$n.sortedIndex=function(t,e){return no(t,e)},$n.sortedIndexBy=function(t,e,n){return ro(t,e,si(n,2))},$n.sortedIndexOf=function(t,e){var n=null==t?0:t.length;if(n){var r=no(t,e);if(r<n&&ks(t[r],e))return r}return-1},$n.sortedLastIndex=function(t,e){return no(t,e,!0)},$n.sortedLastIndexBy=function(t,e,n){return ro(t,e,si(n,2),!0)},$n.sortedLastIndexOf=function(t,e){if(null!=t&&t.length){var n=no(t,e,!0)-1;if(ks(t[n],e))return n}return-1},$n.startCase=za,$n.startsWith=function(t,e,n){return t=ya(t),n=null==n?0:ir(fa(n),0,t.length),e=so(e),t.slice(n,n+e.length)==e},$n.subtract=xl,$n.sum=function(t){return t&&t.length?We(t,nl):0},$n.sumBy=function(t,e){return t&&t.length?We(t,si(e,2)):0},$n.template=function(t,e,n){var r=$n.templateSettings;n&&yi(t,e,n)&&(e=o),t=ya(t),e=Ca({},e,r,Jo);var i,s,a=Ca({},e.imports,r.imports,Jo),l=Pa(a),u=Je(a,l),c=0,h=e.interpolate||vt,d="__p += '",f=Tt((e.escape||vt).source+"|"+h.source+"|"+(h===Q?ht:vt).source+"|"+(e.evaluate||vt).source+"|$","g"),p="//# sourceURL="+(Ot.call(e,"sourceURL")?(e.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++re+"]")+"\n";t.replace(f,(function(e,n,r,o,a,l){return r||(r=o),d+=t.slice(c,l).replace(Ct,nn),n&&(i=!0,d+="' +\n__e("+n+") +\n'"),a&&(s=!0,d+="';\n"+a+";\n__p += '"),r&&(d+="' +\n((__t = ("+r+")) == null ? '' : __t) +\n'"),c=l+e.length,e})),d+="';\n";var m=Ot.call(e,"variable")&&e.variable;if(m){if(ut.test(m))throw new wt("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("+(m||"obj")+") {\n"+(m?"":"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=Qa((function(){return At(l,p+"return "+d).apply(o,u)}));if(g.source=d,Ks(g))throw g;return g},$n.times=function(t,e){if((t=fa(t))<1||t>h)return[];var n=f,r=yn(t,f);e=si(e),t-=f;for(var o=ze(r,e);++n<t;)e(n);return o},$n.toFinite=da,$n.toInteger=fa,$n.toLength=pa,$n.toLower=function(t){return ya(t).toLowerCase()},$n.toNumber=ma,$n.toSafeInteger=function(t){return t?ir(fa(t),-9007199254740991,h):0===t?t:0},$n.toString=ya,$n.toUpper=function(t){return ya(t).toUpperCase()},$n.trim=function(t,e,n){if((t=ya(t))&&(n||e===o))return Ye(t);if(!t||!(e=so(e)))return t;var r=hn(t),i=hn(e);return vo(r,Xe(r,i),Ze(r,i)+1).join("")},$n.trimEnd=function(t,e,n){if((t=ya(t))&&(n||e===o))return t.slice(0,dn(t)+1);if(!t||!(e=so(e)))return t;var r=hn(t);return vo(r,0,Ze(r,hn(e))+1).join("")},$n.trimStart=function(t,e,n){if((t=ya(t))&&(n||e===o))return t.replace(rt,"");if(!t||!(e=so(e)))return t;var r=hn(t);return vo(r,Xe(r,hn(e))).join("")},$n.truncate=function(t,e){var n=30,r="...";if(Zs(e)){var i="separator"in e?e.separator:i;n="length"in e?fa(e.length):n,r="omission"in e?so(e.omission):r}var s=(t=ya(t)).length;if(rn(t)){var a=hn(t);s=a.length}if(n>=s)return t;var l=n-cn(r);if(l<1)return r;var u=a?vo(a,0,l).join(""):t.slice(0,l);if(i===o)return u+r;if(a&&(l+=u.length-l),oa(i)){if(t.slice(l).search(i)){var c,h=u;for(i.global||(i=Tt(i.source,ya(dt.exec(i))+"g")),i.lastIndex=0;c=i.exec(h);)var d=c.index;u=u.slice(0,d===o?l:d)}}else if(t.indexOf(so(i),l)!=l){var f=u.lastIndexOf(i);f>-1&&(u=u.slice(0,f))}return u+r},$n.unescape=function(t){return(t=ya(t))&&z.test(t)?t.replace(q,fn):t},$n.uniqueId=function(t){var e=++Rt;return ya(t)+e},$n.upperCase=Ya,$n.upperFirst=Ka,$n.each=ys,$n.eachRight=bs,$n.first=qi,sl($n,(gl={},br($n,(function(t,e){Ot.call($n.prototype,e)||(gl[e]=t)})),gl),{chain:!1}),$n.VERSION="4.17.21",Te(["bind","bindKey","curry","curryRight","partial","partialRight"],(function(t){$n[t].placeholder=$n})),Te(["drop","take"],(function(t,e){Un.prototype[t]=function(n){n=n===o?1:gn(fa(n),0);var r=this.__filtered__&&!e?new Un(this):this.clone();return r.__filtered__?r.__takeCount__=yn(n,r.__takeCount__):r.__views__.push({size:yn(n,f),type:t+(r.__dir__<0?"Right":"")}),r},Un.prototype[t+"Right"]=function(e){return this.reverse()[t](e).reverse()}})),Te(["filter","map","takeWhile"],(function(t,e){var n=e+1,r=1==n||3==n;Un.prototype[t]=function(t){var e=this.clone();return e.__iteratees__.push({iteratee:si(t,3),type:n}),e.__filtered__=e.__filtered__||r,e}})),Te(["head","last"],(function(t,e){var n="take"+(e?"Right":"");Un.prototype[t]=function(){return this[n](1).value()[0]}})),Te(["initial","tail"],(function(t,e){var n="drop"+(e?"":"Right");Un.prototype[t]=function(){return this.__filtered__?new Un(this):this[n](1)}})),Un.prototype.compact=function(){return this.filter(nl)},Un.prototype.find=function(t){return this.filter(t).head()},Un.prototype.findLast=function(t){return this.reverse().find(t)},Un.prototype.invokeMap=zr((function(t,e){return"function"==typeof t?new Un(this):this.map((function(n){return _r(n,t,e)}))})),Un.prototype.reject=function(t){return this.filter(Rs(si(t)))},Un.prototype.slice=function(t,e){t=fa(t);var n=this;return n.__filtered__&&(t>0||e<0)?new Un(n):(t<0?n=n.takeRight(-t):t&&(n=n.drop(t)),e!==o&&(n=(e=fa(e))<0?n.dropRight(-e):n.take(e-t)),n)},Un.prototype.takeRightWhile=function(t){return this.reverse().takeWhile(t).reverse()},Un.prototype.toArray=function(){return this.take(f)},br(Un.prototype,(function(t,e){var n=/^(?:filter|find|map|reject)|While$/.test(e),r=/^(?:head|last)$/.test(e),i=$n[r?"take"+("last"==e?"Right":""):e],s=r||/^find/.test(e);i&&($n.prototype[e]=function(){var e=this.__wrapped__,a=r?[1]:arguments,l=e instanceof Un,u=a[0],c=l||Vs(e),h=function(t){var e=i.apply($n,Le([t],a));return r&&d?e[0]:e};c&&n&&"function"==typeof u&&1!=u.length&&(l=c=!1);var d=this.__chain__,f=!!this.__actions__.length,p=s&&!d,m=l&&!f;if(!s&&c){e=m?e:new Un(this);var g=t.apply(e,a);return g.__actions__.push({func:ds,args:[h],thisArg:o}),new Gn(g,d)}return p&&m?t.apply(this,a):(g=this.thru(h),p?r?g.value()[0]:g.value():g)})})),Te(["pop","push","shift","sort","splice","unshift"],(function(t){var e=_t[t],n=/^(?:push|sort|unshift)$/.test(t)?"tap":"thru",r=/^(?:pop|shift)$/.test(t);$n.prototype[t]=function(){var t=arguments;if(r&&!this.__chain__){var o=this.value();return e.apply(Vs(o)?o:[],t)}return this[n]((function(n){return e.apply(Vs(n)?n:[],t)}))}})),br(Un.prototype,(function(t,e){var n=$n[e];if(n){var r=n.name+"";Ot.call(Nn,r)||(Nn[r]=[]),Nn[r].push({name:e,func:n})}})),Nn[$o(o,2).name]=[{name:"wrapper",func:o}],Un.prototype.clone=function(){var t=new Un(this.__wrapped__);return t.__actions__=Io(this.__actions__),t.__dir__=this.__dir__,t.__filtered__=this.__filtered__,t.__iteratees__=Io(this.__iteratees__),t.__takeCount__=this.__takeCount__,t.__views__=Io(this.__views__),t},Un.prototype.reverse=function(){if(this.__filtered__){var t=new Un(this);t.__dir__=-1,t.__filtered__=!0}else(t=this.clone()).__dir__*=-1;return t},Un.prototype.value=function(){var t=this.__wrapped__.value(),e=this.__dir__,n=Vs(t),r=e<0,o=n?t.length:0,i=function(t,e,n){for(var r=-1,o=n.length;++r<o;){var i=n[r],s=i.size;switch(i.type){case"drop":t+=s;break;case"dropRight":e-=s;break;case"take":e=yn(e,t+s);break;case"takeRight":t=gn(t,e-s)}}return{start:t,end:e}}(0,o,this.__views__),s=i.start,a=i.end,l=a-s,u=r?a:s-1,c=this.__iteratees__,h=c.length,d=0,f=yn(l,this.__takeCount__);if(!n||!r&&o==l&&f==l)return ho(t,this.__actions__);var p=[];t:for(;l--&&d<f;){for(var m=-1,g=t[u+=e];++m<h;){var y=c[m],b=y.iteratee,v=y.type,C=b(g);if(2==v)g=C;else if(!C){if(1==v)continue t;break t}}p[d++]=g}return p},$n.prototype.at=fs,$n.prototype.chain=function(){return hs(this)},$n.prototype.commit=function(){return new Gn(this.value(),this.__chain__)},$n.prototype.next=function(){this.__values__===o&&(this.__values__=ha(this.value()));var t=this.__index__>=this.__values__.length;return{done:t,value:t?o:this.__values__[this.__index__++]}},$n.prototype.plant=function(t){for(var e,n=this;n instanceof Hn;){var r=$i(n);r.__index__=0,r.__values__=o,e?i.__wrapped__=r:e=r;var i=r;n=n.__wrapped__}return i.__wrapped__=t,e},$n.prototype.reverse=function(){var t=this.__wrapped__;if(t instanceof Un){var e=t;return this.__actions__.length&&(e=new Un(this)),(e=e.reverse()).__actions__.push({func:ds,args:[Zi],thisArg:o}),new Gn(e,this.__chain__)}return this.thru(Zi)},$n.prototype.toJSON=$n.prototype.valueOf=$n.prototype.value=function(){return ho(this.__wrapped__,this.__actions__)},$n.prototype.first=$n.prototype.head,Kt&&($n.prototype[Kt]=function(){return this}),$n}();he._=pn,(r=function(){return pn}.call(e,n,e,t))===o||(t.exports=r)}.call(this)},4802:t=>{t.exports=function t(e,n,r){function o(s,a){if(!n[s]){if(!e[s]){if(i)return i(s,!0);throw new Error("Cannot find module '"+s+"'")}a=n[s]={exports:{}},e[s][0].call(a.exports,(function(t){return o(e[s][1][t]||t)}),a,a.exports,t,e,n,r)}return n[s].exports}for(var i=void 0,s=0;s<r.length;s++)o(r[s]);return o}({1:[function(t,e,n){(function(r,o,i,s,a,l,u,c,h){"use strict";var d=t("crypto");function f(t,e){var n;return void 0===(n="passthrough"!==(e=g(t,e)).algorithm?d.createHash(e.algorithm):new v).write&&(n.write=n.update,n.end=n.update),b(e,n).dispatch(t),n.update||n.end(""),n.digest?n.digest("buffer"===e.encoding?void 0:e.encoding):(t=n.read(),"buffer"!==e.encoding?t.toString(e.encoding):t)}(n=e.exports=f).sha1=function(t){return f(t)},n.keys=function(t){return f(t,{excludeValues:!0,algorithm:"sha1",encoding:"hex"})},n.MD5=function(t){return f(t,{algorithm:"md5",encoding:"hex"})},n.keysMD5=function(t){return f(t,{algorithm:"md5",encoding:"hex",excludeValues:!0})};var p=d.getHashes?d.getHashes().slice():["sha1","md5"],m=(p.push("passthrough"),["buffer","hex","binary","base64"]);function g(t,e){var n={};if(n.algorithm=(e=e||{}).algorithm||"sha1",n.encoding=e.encoding||"hex",n.excludeValues=!!e.excludeValues,n.algorithm=n.algorithm.toLowerCase(),n.encoding=n.encoding.toLowerCase(),n.ignoreUnknown=!0===e.ignoreUnknown,n.respectType=!1!==e.respectType,n.respectFunctionNames=!1!==e.respectFunctionNames,n.respectFunctionProperties=!1!==e.respectFunctionProperties,n.unorderedArrays=!0===e.unorderedArrays,n.unorderedSets=!1!==e.unorderedSets,n.unorderedObjects=!1!==e.unorderedObjects,n.replacer=e.replacer||void 0,n.excludeKeys=e.excludeKeys||void 0,void 0===t)throw new Error("Object argument required.");for(var r=0;r<p.length;++r)p[r].toLowerCase()===n.algorithm.toLowerCase()&&(n.algorithm=p[r]);if(-1===p.indexOf(n.algorithm))throw new Error('Algorithm "'+n.algorithm+'" not supported. supported values: '+p.join(", "));if(-1===m.indexOf(n.encoding)&&"passthrough"!==n.algorithm)throw new Error('Encoding "'+n.encoding+'" not supported. supported values: '+m.join(", "));return n}function y(t){if("function"==typeof t)return null!=/^function\s+\w*\s*\(\s*\)\s*{\s+\[native code\]\s+}$/i.exec(Function.prototype.toString.call(t))}function b(t,e,n){function r(t){return e.update?e.update(t,"utf8"):e.write(t,"utf8")}return n=n||[],{dispatch:function(e){return this["_"+(null===(e=t.replacer?t.replacer(e):e)?"null":typeof e)](e)},_object:function(e){var o,s=Object.prototype.toString.call(e),a=/\[object (.*)\]/i.exec(s);if(a=(a=a?a[1]:"unknown:["+s+"]").toLowerCase(),0<=(s=n.indexOf(e)))return this.dispatch("[CIRCULAR:"+s+"]");if(n.push(e),void 0!==i&&i.isBuffer&&i.isBuffer(e))return r("buffer:"),r(e);if("object"===a||"function"===a||"asyncfunction"===a)return s=Object.keys(e),t.unorderedObjects&&(s=s.sort()),!1===t.respectType||y(e)||s.splice(0,0,"prototype","__proto__","constructor"),t.excludeKeys&&(s=s.filter((function(e){return!t.excludeKeys(e)}))),r("object:"+s.length+":"),o=this,s.forEach((function(n){o.dispatch(n),r(":"),t.excludeValues||o.dispatch(e[n]),r(",")}));if(!this["_"+a]){if(t.ignoreUnknown)return r("["+a+"]");throw new Error('Unknown object type "'+a+'"')}this["_"+a](e)},_array:function(e,o){o=void 0!==o?o:!1!==t.unorderedArrays;var i=this;if(r("array:"+e.length+":"),!o||e.length<=1)return e.forEach((function(t){return i.dispatch(t)}));var s=[];return o=e.map((function(e){var r=new v,o=n.slice();return b(t,r,o).dispatch(e),s=s.concat(o.slice(n.length)),r.read().toString()})),n=n.concat(s),o.sort(),this._array(o,!1)},_date:function(t){return r("date:"+t.toJSON())},_symbol:function(t){return r("symbol:"+t.toString())},_error:function(t){return r("error:"+t.toString())},_boolean:function(t){return r("bool:"+t.toString())},_string:function(t){r("string:"+t.length+":"),r(t.toString())},_function:function(e){r("fn:"),y(e)?this.dispatch("[native]"):this.dispatch(e.toString()),!1!==t.respectFunctionNames&&this.dispatch("function-name:"+String(e.name)),t.respectFunctionProperties&&this._object(e)},_number:function(t){return r("number:"+t.toString())},_xml:function(t){return r("xml:"+t.toString())},_null:function(){return r("Null")},_undefined:function(){return r("Undefined")},_regexp:function(t){return r("regex:"+t.toString())},_uint8array:function(t){return r("uint8array:"),this.dispatch(Array.prototype.slice.call(t))},_uint8clampedarray:function(t){return r("uint8clampedarray:"),this.dispatch(Array.prototype.slice.call(t))},_int8array:function(t){return r("int8array:"),this.dispatch(Array.prototype.slice.call(t))},_uint16array:function(t){return r("uint16array:"),this.dispatch(Array.prototype.slice.call(t))},_int16array:function(t){return r("int16array:"),this.dispatch(Array.prototype.slice.call(t))},_uint32array:function(t){return r("uint32array:"),this.dispatch(Array.prototype.slice.call(t))},_int32array:function(t){return r("int32array:"),this.dispatch(Array.prototype.slice.call(t))},_float32array:function(t){return r("float32array:"),this.dispatch(Array.prototype.slice.call(t))},_float64array:function(t){return r("float64array:"),this.dispatch(Array.prototype.slice.call(t))},_arraybuffer:function(t){return r("arraybuffer:"),this.dispatch(new Uint8Array(t))},_url:function(t){return r("url:"+t.toString())},_map:function(e){return r("map:"),e=Array.from(e),this._array(e,!1!==t.unorderedSets)},_set:function(e){return r("set:"),e=Array.from(e),this._array(e,!1!==t.unorderedSets)},_file:function(t){return r("file:"),this.dispatch([t.name,t.size,t.type,t.lastModfied])},_blob:function(){if(t.ignoreUnknown)return r("[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 r("domwindow")},_bigint:function(t){return r("bigint:"+t.toString())},_process:function(){return r("process")},_timer:function(){return r("timer")},_pipe:function(){return r("pipe")},_tcp:function(){return r("tcp")},_udp:function(){return r("udp")},_tty:function(){return r("tty")},_statwatcher:function(){return r("statwatcher")},_securecontext:function(){return r("securecontext")},_connection:function(){return r("connection")},_zlib:function(){return r("zlib")},_context:function(){return r("context")},_nodescript:function(){return r("nodescript")},_httpparser:function(){return r("httpparser")},_dataview:function(){return r("dataview")},_signal:function(){return r("signal")},_fsevent:function(){return r("fsevent")},_tlswrap:function(){return r("tlswrap")}}}function v(){return{buf:"",write:function(t){this.buf+=t},end:function(t){this.buf+=t},read:function(){return this.buf}}}n.writeToStream=function(t,e,n){return void 0===n&&(n=e,e={}),b(e=g(t,e),n).dispatch(t)}}).call(this,t("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},t("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/fake_9a5aa49d.js","/")},{buffer:3,crypto:5,lYpoI2:11}],2:[function(t,e,n){(function(t,e,r,o,i,s,a,l,u){!function(t){"use strict";var e="undefined"!=typeof Uint8Array?Uint8Array:Array,n="+".charCodeAt(0),r="/".charCodeAt(0),o="0".charCodeAt(0),i="a".charCodeAt(0),s="A".charCodeAt(0),a="-".charCodeAt(0),l="_".charCodeAt(0);function u(t){return(t=t.charCodeAt(0))===n||t===a?62:t===r||t===l?63:t<o?-1:t<o+10?t-o+26+26:t<s+26?t-s:t<i+26?t-i+26:void 0}t.toByteArray=function(t){var n,r;if(0<t.length%4)throw new Error("Invalid string. Length must be a multiple of 4");var o=t.length,i=(o="="===t.charAt(o-2)?2:"="===t.charAt(o-1)?1:0,new e(3*t.length/4-o)),s=0<o?t.length-4:t.length,a=0;function l(t){i[a++]=t}for(n=0;n<s;n+=4,0)l((16711680&(r=u(t.charAt(n))<<18|u(t.charAt(n+1))<<12|u(t.charAt(n+2))<<6|u(t.charAt(n+3))))>>16),l((65280&r)>>8),l(255&r);return 2==o?l(255&(r=u(t.charAt(n))<<2|u(t.charAt(n+1))>>4)):1==o&&(l((r=u(t.charAt(n))<<10|u(t.charAt(n+1))<<4|u(t.charAt(n+2))>>2)>>8&255),l(255&r)),i},t.fromByteArray=function(t){var e,n,r,o,i=t.length%3,s="";function a(t){return"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(t)}for(e=0,r=t.length-i;e<r;e+=3)s+=a((o=n=(t[e]<<16)+(t[e+1]<<8)+t[e+2])>>18&63)+a(o>>12&63)+a(o>>6&63)+a(63&o);switch(i){case 1:s=(s+=a((n=t[t.length-1])>>2))+a(n<<4&63)+"==";break;case 2:s=(s=(s+=a((n=(t[t.length-2]<<8)+t[t.length-1])>>10))+a(n>>4&63))+a(n<<2&63)+"="}return s}}(void 0===n?this.base64js={}:n)}).call(this,t("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},t("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(t,e,n){(function(e,r,o,i,s,a,l,u,c){var h=t("base64-js"),d=t("ieee754");function o(t,e,n){if(!(this instanceof o))return new o(t,e,n);var r,i,s,a,l=typeof t;if("base64"===e&&"string"==l)for(t=(a=t).trim?a.trim():a.replace(/^\s+|\s+$/g,"");t.length%4!=0;)t+="=";if("number"==l)r=I(t);else if("string"==l)r=o.byteLength(t,e);else{if("object"!=l)throw new Error("First argument needs to be a number, array or string.");r=I(t.length)}if(o._useTypedArrays?i=o._augment(new Uint8Array(r)):((i=this).length=r,i._isBuffer=!0),o._useTypedArrays&&"number"==typeof t.byteLength)i._set(t);else if(_(a=t)||o.isBuffer(a)||a&&"object"==typeof a&&"number"==typeof a.length)for(s=0;s<r;s++)o.isBuffer(t)?i[s]=t.readUInt8(s):i[s]=t[s];else if("string"==l)i.write(t,0,e);else if("number"==l&&!o._useTypedArrays&&!n)for(s=0;s<r;s++)i[s]=0;return i}function f(t,e,n,r){var o;if(r||(F("boolean"==typeof n,"missing or invalid endian"),F(null!=e,"missing offset"),F(e+1<t.length,"Trying to read beyond buffer length")),!((r=t.length)<=e))return n?(o=t[e],e+1<r&&(o|=t[e+1]<<8)):(o=t[e]<<8,e+1<r&&(o|=t[e+1])),o}function p(t,e,n,r){var o;if(r||(F("boolean"==typeof n,"missing or invalid endian"),F(null!=e,"missing offset"),F(e+3<t.length,"Trying to read beyond buffer length")),!((r=t.length)<=e))return n?(e+2<r&&(o=t[e+2]<<16),e+1<r&&(o|=t[e+1]<<8),o|=t[e],e+3<r&&(o+=t[e+3]<<24>>>0)):(e+1<r&&(o=t[e+1]<<16),e+2<r&&(o|=t[e+2]<<8),e+3<r&&(o|=t[e+3]),o+=t[e]<<24>>>0),o}function m(t,e,n,r){if(r||(F("boolean"==typeof n,"missing or invalid endian"),F(null!=e,"missing offset"),F(e+1<t.length,"Trying to read beyond buffer length")),!(t.length<=e))return 32768&(r=f(t,e,n,!0))?-1*(65535-r+1):r}function g(t,e,n,r){if(r||(F("boolean"==typeof n,"missing or invalid endian"),F(null!=e,"missing offset"),F(e+3<t.length,"Trying to read beyond buffer length")),!(t.length<=e))return 2147483648&(r=p(t,e,n,!0))?-1*(4294967295-r+1):r}function y(t,e,n,r){return r||(F("boolean"==typeof n,"missing or invalid endian"),F(e+3<t.length,"Trying to read beyond buffer length")),d.read(t,e,n,23,4)}function b(t,e,n,r){return r||(F("boolean"==typeof n,"missing or invalid endian"),F(e+7<t.length,"Trying to read beyond buffer length")),d.read(t,e,n,52,8)}function v(t,e,n,r,o){if(o||(F(null!=e,"missing value"),F("boolean"==typeof r,"missing or invalid endian"),F(null!=n,"missing offset"),F(n+1<t.length,"trying to write beyond buffer length"),R(e,65535)),!((o=t.length)<=n))for(var i=0,s=Math.min(o-n,2);i<s;i++)t[n+i]=(e&255<<8*(r?i:1-i))>>>8*(r?i:1-i)}function C(t,e,n,r,o){if(o||(F(null!=e,"missing value"),F("boolean"==typeof r,"missing or invalid endian"),F(null!=n,"missing offset"),F(n+3<t.length,"trying to write beyond buffer length"),R(e,4294967295)),!((o=t.length)<=n))for(var i=0,s=Math.min(o-n,4);i<s;i++)t[n+i]=e>>>8*(r?i:3-i)&255}function w(t,e,n,r,o){o||(F(null!=e,"missing value"),F("boolean"==typeof r,"missing or invalid endian"),F(null!=n,"missing offset"),F(n+1<t.length,"Trying to write beyond buffer length"),D(e,32767,-32768)),t.length<=n||v(t,0<=e?e:65535+e+1,n,r,o)}function A(t,e,n,r,o){o||(F(null!=e,"missing value"),F("boolean"==typeof r,"missing or invalid endian"),F(null!=n,"missing offset"),F(n+3<t.length,"Trying to write beyond buffer length"),D(e,2147483647,-2147483648)),t.length<=n||C(t,0<=e?e:4294967295+e+1,n,r,o)}function x(t,e,n,r,o){o||(F(null!=e,"missing value"),F("boolean"==typeof r,"missing or invalid endian"),F(null!=n,"missing offset"),F(n+3<t.length,"Trying to write beyond buffer length"),B(e,34028234663852886e22,-34028234663852886e22)),t.length<=n||d.write(t,e,n,r,23,4)}function E(t,e,n,r,o){o||(F(null!=e,"missing value"),F("boolean"==typeof r,"missing or invalid endian"),F(null!=n,"missing offset"),F(n+7<t.length,"Trying to write beyond buffer length"),B(e,17976931348623157e292,-17976931348623157e292)),t.length<=n||d.write(t,e,n,r,52,8)}n.Buffer=o,n.SlowBuffer=o,n.INSPECT_MAX_BYTES=50,o.poolSize=8192,o._useTypedArrays=function(){try{var t=new ArrayBuffer(0),e=new Uint8Array(t);return e.foo=function(){return 42},42===e.foo()&&"function"==typeof e.subarray}catch(t){return!1}}(),o.isEncoding=function(t){switch(String(t).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}},o.isBuffer=function(t){return!(null==t||!t._isBuffer)},o.byteLength=function(t,e){var n;switch(t+="",e||"utf8"){case"hex":n=t.length/2;break;case"utf8":case"utf-8":n=P(t).length;break;case"ascii":case"binary":case"raw":n=t.length;break;case"base64":n=M(t).length;break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":n=2*t.length;break;default:throw new Error("Unknown encoding")}return n},o.concat=function(t,e){if(F(_(t),"Usage: Buffer.concat(list, [totalLength])\nlist should be an Array."),0===t.length)return new o(0);if(1===t.length)return t[0];if("number"!=typeof e)for(i=e=0;i<t.length;i++)e+=t[i].length;for(var n=new o(e),r=0,i=0;i<t.length;i++){var s=t[i];s.copy(n,r),r+=s.length}return n},o.prototype.write=function(t,e,n,r){isFinite(e)?isFinite(n)||(r=n,n=void 0):(u=r,r=e,e=n,n=u),e=Number(e)||0;var i,s,a,l,u=this.length-e;switch((!n||u<(n=Number(n)))&&(n=u),r=String(r||"utf8").toLowerCase()){case"hex":i=function(t,e,n,r){n=Number(n)||0;var i=t.length-n;(!r||i<(r=Number(r)))&&(r=i),F((i=e.length)%2==0,"Invalid hex string"),i/2<r&&(r=i/2);for(var s=0;s<r;s++){var a=parseInt(e.substr(2*s,2),16);F(!isNaN(a),"Invalid hex string"),t[n+s]=a}return o._charsWritten=2*s,s}(this,t,e,n);break;case"utf8":case"utf-8":s=this,a=e,l=n,i=o._charsWritten=L(P(t),s,a,l);break;case"ascii":case"binary":i=function(t,e,n,r){return o._charsWritten=L(function(t){for(var e=[],n=0;n<t.length;n++)e.push(255&t.charCodeAt(n));return e}(e),t,n,r)}(this,t,e,n);break;case"base64":s=this,a=e,l=n,i=o._charsWritten=L(M(t),s,a,l);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":i=function(t,e,n,r){return o._charsWritten=L(function(t){for(var e,n,r=[],o=0;o<t.length;o++)e=(n=t.charCodeAt(o))>>8,n%=256,r.push(n),r.push(e);return r}(e),t,n,r)}(this,t,e,n);break;default:throw new Error("Unknown encoding")}return i},o.prototype.toString=function(t,e,n){var r,o,i,s,a=this;if(t=String(t||"utf8").toLowerCase(),e=Number(e)||0,(n=void 0!==n?Number(n):a.length)===e)return"";switch(t){case"hex":r=function(t,e,n){var r=t.length;(!e||e<0)&&(e=0),(!n||n<0||r<n)&&(n=r);for(var o="",i=e;i<n;i++)o+=N(t[i]);return o}(a,e,n);break;case"utf8":case"utf-8":r=function(t,e,n){var r="",o="";n=Math.min(t.length,n);for(var i=e;i<n;i++)t[i]<=127?(r+=O(o)+String.fromCharCode(t[i]),o=""):o+="%"+t[i].toString(16);return r+O(o)}(a,e,n);break;case"ascii":case"binary":r=function(t,e,n){var r="";n=Math.min(t.length,n);for(var o=e;o<n;o++)r+=String.fromCharCode(t[o]);return r}(a,e,n);break;case"base64":o=a,s=n,r=0===(i=e)&&s===o.length?h.fromByteArray(o):h.fromByteArray(o.slice(i,s));break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":r=function(t,e,n){for(var r=t.slice(e,n),o="",i=0;i<r.length;i+=2)o+=String.fromCharCode(r[i]+256*r[i+1]);return o}(a,e,n);break;default:throw new Error("Unknown encoding")}return r},o.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},o.prototype.copy=function(t,e,n,r){if(e=e||0,(r=r||0===r?r:this.length)!==(n=n||0)&&0!==t.length&&0!==this.length){F(n<=r,"sourceEnd < sourceStart"),F(0<=e&&e<t.length,"targetStart out of bounds"),F(0<=n&&n<this.length,"sourceStart out of bounds"),F(0<=r&&r<=this.length,"sourceEnd out of bounds"),r>this.length&&(r=this.length);var i=(r=t.length-e<r-n?t.length-e+n:r)-n;if(i<100||!o._useTypedArrays)for(var s=0;s<i;s++)t[s+e]=this[s+n];else t._set(this.subarray(n,n+i),e)}},o.prototype.slice=function(t,e){var n=this.length;if(t=S(t,n,0),e=S(e,n,n),o._useTypedArrays)return o._augment(this.subarray(t,e));for(var r=e-t,i=new o(r,void 0,!0),s=0;s<r;s++)i[s]=this[s+t];return i},o.prototype.get=function(t){return console.log(".get() is deprecated. Access using array indexes instead."),this.readUInt8(t)},o.prototype.set=function(t,e){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(t,e)},o.prototype.readUInt8=function(t,e){if(e||(F(null!=t,"missing offset"),F(t<this.length,"Trying to read beyond buffer length")),!(t>=this.length))return this[t]},o.prototype.readUInt16LE=function(t,e){return f(this,t,!0,e)},o.prototype.readUInt16BE=function(t,e){return f(this,t,!1,e)},o.prototype.readUInt32LE=function(t,e){return p(this,t,!0,e)},o.prototype.readUInt32BE=function(t,e){return p(this,t,!1,e)},o.prototype.readInt8=function(t,e){if(e||(F(null!=t,"missing offset"),F(t<this.length,"Trying to read beyond buffer length")),!(t>=this.length))return 128&this[t]?-1*(255-this[t]+1):this[t]},o.prototype.readInt16LE=function(t,e){return m(this,t,!0,e)},o.prototype.readInt16BE=function(t,e){return m(this,t,!1,e)},o.prototype.readInt32LE=function(t,e){return g(this,t,!0,e)},o.prototype.readInt32BE=function(t,e){return g(this,t,!1,e)},o.prototype.readFloatLE=function(t,e){return y(this,t,!0,e)},o.prototype.readFloatBE=function(t,e){return y(this,t,!1,e)},o.prototype.readDoubleLE=function(t,e){return b(this,t,!0,e)},o.prototype.readDoubleBE=function(t,e){return b(this,t,!1,e)},o.prototype.writeUInt8=function(t,e,n){n||(F(null!=t,"missing value"),F(null!=e,"missing offset"),F(e<this.length,"trying to write beyond buffer length"),R(t,255)),e>=this.length||(this[e]=t)},o.prototype.writeUInt16LE=function(t,e,n){v(this,t,e,!0,n)},o.prototype.writeUInt16BE=function(t,e,n){v(this,t,e,!1,n)},o.prototype.writeUInt32LE=function(t,e,n){C(this,t,e,!0,n)},o.prototype.writeUInt32BE=function(t,e,n){C(this,t,e,!1,n)},o.prototype.writeInt8=function(t,e,n){n||(F(null!=t,"missing value"),F(null!=e,"missing offset"),F(e<this.length,"Trying to write beyond buffer length"),D(t,127,-128)),e>=this.length||(0<=t?this.writeUInt8(t,e,n):this.writeUInt8(255+t+1,e,n))},o.prototype.writeInt16LE=function(t,e,n){w(this,t,e,!0,n)},o.prototype.writeInt16BE=function(t,e,n){w(this,t,e,!1,n)},o.prototype.writeInt32LE=function(t,e,n){A(this,t,e,!0,n)},o.prototype.writeInt32BE=function(t,e,n){A(this,t,e,!1,n)},o.prototype.writeFloatLE=function(t,e,n){x(this,t,e,!0,n)},o.prototype.writeFloatBE=function(t,e,n){x(this,t,e,!1,n)},o.prototype.writeDoubleLE=function(t,e,n){E(this,t,e,!0,n)},o.prototype.writeDoubleBE=function(t,e,n){E(this,t,e,!1,n)},o.prototype.fill=function(t,e,n){if(e=e||0,n=n||this.length,F("number"==typeof(t="string"==typeof(t=t||0)?t.charCodeAt(0):t)&&!isNaN(t),"value is not a number"),F(e<=n,"end < start"),n!==e&&0!==this.length){F(0<=e&&e<this.length,"start out of bounds"),F(0<=n&&n<=this.length,"end out of bounds");for(var r=e;r<n;r++)this[r]=t}},o.prototype.inspect=function(){for(var t=[],e=this.length,r=0;r<e;r++)if(t[r]=N(this[r]),r===n.INSPECT_MAX_BYTES){t[r+1]="...";break}return"<Buffer "+t.join(" ")+">"},o.prototype.toArrayBuffer=function(){if("undefined"==typeof Uint8Array)throw new Error("Buffer.toArrayBuffer not supported in this browser");if(o._useTypedArrays)return new o(this).buffer;for(var t=new Uint8Array(this.length),e=0,n=t.length;e<n;e+=1)t[e]=this[e];return t.buffer};var T=o.prototype;function S(t,e,n){return"number"!=typeof t?n:e<=(t=~~t)?e:0<=t||0<=(t+=e)?t:0}function I(t){return(t=~~Math.ceil(+t))<0?0:t}function _(t){return(Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)})(t)}function N(t){return t<16?"0"+t.toString(16):t.toString(16)}function P(t){for(var e=[],n=0;n<t.length;n++){var r=t.charCodeAt(n);if(r<=127)e.push(t.charCodeAt(n));else for(var o=n,i=(55296<=r&&r<=57343&&n++,encodeURIComponent(t.slice(o,n+1)).substr(1).split("%")),s=0;s<i.length;s++)e.push(parseInt(i[s],16))}return e}function M(t){return h.toByteArray(t)}function L(t,e,n,r){for(var o=0;o<r&&!(o+n>=e.length||o>=t.length);o++)e[o+n]=t[o];return o}function O(t){try{return decodeURIComponent(t)}catch(t){return String.fromCharCode(65533)}}function R(t,e){F("number"==typeof t,"cannot write a non-number as a number"),F(0<=t,"specified a negative value for writing an unsigned value"),F(t<=e,"value is larger than maximum value for type"),F(Math.floor(t)===t,"value has a fractional component")}function D(t,e,n){F("number"==typeof t,"cannot write a non-number as a number"),F(t<=e,"value larger than maximum allowed value"),F(n<=t,"value smaller than minimum allowed value"),F(Math.floor(t)===t,"value has a fractional component")}function B(t,e,n){F("number"==typeof t,"cannot write a non-number as a number"),F(t<=e,"value larger than maximum allowed value"),F(n<=t,"value smaller than minimum allowed value")}function F(t,e){if(!t)throw new Error(e||"Failed assertion")}o._augment=function(t){return t._isBuffer=!0,t._get=t.get,t._set=t.set,t.get=T.get,t.set=T.set,t.write=T.write,t.toString=T.toString,t.toLocaleString=T.toString,t.toJSON=T.toJSON,t.copy=T.copy,t.slice=T.slice,t.readUInt8=T.readUInt8,t.readUInt16LE=T.readUInt16LE,t.readUInt16BE=T.readUInt16BE,t.readUInt32LE=T.readUInt32LE,t.readUInt32BE=T.readUInt32BE,t.readInt8=T.readInt8,t.readInt16LE=T.readInt16LE,t.readInt16BE=T.readInt16BE,t.readInt32LE=T.readInt32LE,t.readInt32BE=T.readInt32BE,t.readFloatLE=T.readFloatLE,t.readFloatBE=T.readFloatBE,t.readDoubleLE=T.readDoubleLE,t.readDoubleBE=T.readDoubleBE,t.writeUInt8=T.writeUInt8,t.writeUInt16LE=T.writeUInt16LE,t.writeUInt16BE=T.writeUInt16BE,t.writeUInt32LE=T.writeUInt32LE,t.writeUInt32BE=T.writeUInt32BE,t.writeInt8=T.writeInt8,t.writeInt16LE=T.writeInt16LE,t.writeInt16BE=T.writeInt16BE,t.writeInt32LE=T.writeInt32LE,t.writeInt32BE=T.writeInt32BE,t.writeFloatLE=T.writeFloatLE,t.writeFloatBE=T.writeFloatBE,t.writeDoubleLE=T.writeDoubleLE,t.writeDoubleBE=T.writeDoubleBE,t.fill=T.fill,t.inspect=T.inspect,t.toArrayBuffer=T.toArrayBuffer,t}}).call(this,t("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},t("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(t,e,n){(function(n,r,o,i,s,a,l,u,c){o=t("buffer").Buffer;var h=new o(4);h.fill(0),e.exports={hash:function(t,e,n,r){for(var i=e(function(t,e){t.length%4!=0&&(n=t.length+(4-t.length%4),t=o.concat([t,h],n));for(var n,r=[],i=e?t.readInt32BE:t.readInt32LE,s=0;s<t.length;s+=4)r.push(i.call(t,s));return r}(t=o.isBuffer(t)?t:new o(t),r),8*t.length),s=(e=r,new o(n)),a=e?s.writeInt32BE:s.writeInt32LE,l=0;l<i.length;l++)a.call(s,i[l],4*l,!0);return s}}}).call(this,t("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},t("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(t,e,n){(function(e,r,o,i,s,a,l,u,c){o=t("buffer").Buffer;var h=t("./sha"),d=t("./sha256"),f=t("./rng"),p={sha1:h,sha256:d,md5:t("./md5")},m=64,g=new o(m);function y(t,e){var n=p[t=t||"sha1"],r=[];return n||b("algorithm:",t,"is not yet supported"),{update:function(t){return o.isBuffer(t)||(t=new o(t)),r.push(t),t.length,this},digest:function(t){var i=o.concat(r);return i=e?function(t,e,n){o.isBuffer(e)||(e=new o(e)),o.isBuffer(n)||(n=new o(n)),e.length>m?e=t(e):e.length<m&&(e=o.concat([e,g],m));for(var r=new o(m),i=new o(m),s=0;s<m;s++)r[s]=54^e[s],i[s]=92^e[s];return n=t(o.concat([r,n])),t(o.concat([i,n]))}(n,e,i):n(i),r=null,t?i.toString(t):i}}}function b(){var t=[].slice.call(arguments).join(" ");throw new Error([t,"we accept pull requests","http://github.com/dominictarr/crypto-browserify"].join("\n"))}g.fill(0),n.createHash=function(t){return y(t)},n.createHmac=y,n.randomBytes=function(t,e){if(!e||!e.call)return new o(f(t));try{e.call(this,void 0,new o(f(t)))}catch(t){e(t)}};var v,C=["createCredentials","createCipher","createCipheriv","createDecipher","createDecipheriv","createSign","createVerify","createDiffieHellman","pbkdf2"],w=function(t){n[t]=function(){b("sorry,",t,"is not implemented yet")}};for(v in C)w(C[v])}).call(this,t("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},t("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(t,e,n){(function(n,r,o,i,s,a,l,u,c){var h=t("./helpers");function d(t,e){t[e>>5]|=128<<e%32,t[14+(e+64>>>9<<4)]=e;for(var n=1732584193,r=-271733879,o=-1732584194,i=271733878,s=0;s<t.length;s+=16){var a=n,l=r,u=o,c=i;n=p(n,r,o,i,t[s+0],7,-680876936),i=p(i,n,r,o,t[s+1],12,-389564586),o=p(o,i,n,r,t[s+2],17,606105819),r=p(r,o,i,n,t[s+3],22,-1044525330),n=p(n,r,o,i,t[s+4],7,-176418897),i=p(i,n,r,o,t[s+5],12,1200080426),o=p(o,i,n,r,t[s+6],17,-1473231341),r=p(r,o,i,n,t[s+7],22,-45705983),n=p(n,r,o,i,t[s+8],7,1770035416),i=p(i,n,r,o,t[s+9],12,-1958414417),o=p(o,i,n,r,t[s+10],17,-42063),r=p(r,o,i,n,t[s+11],22,-1990404162),n=p(n,r,o,i,t[s+12],7,1804603682),i=p(i,n,r,o,t[s+13],12,-40341101),o=p(o,i,n,r,t[s+14],17,-1502002290),n=m(n,r=p(r,o,i,n,t[s+15],22,1236535329),o,i,t[s+1],5,-165796510),i=m(i,n,r,o,t[s+6],9,-1069501632),o=m(o,i,n,r,t[s+11],14,643717713),r=m(r,o,i,n,t[s+0],20,-373897302),n=m(n,r,o,i,t[s+5],5,-701558691),i=m(i,n,r,o,t[s+10],9,38016083),o=m(o,i,n,r,t[s+15],14,-660478335),r=m(r,o,i,n,t[s+4],20,-405537848),n=m(n,r,o,i,t[s+9],5,568446438),i=m(i,n,r,o,t[s+14],9,-1019803690),o=m(o,i,n,r,t[s+3],14,-187363961),r=m(r,o,i,n,t[s+8],20,1163531501),n=m(n,r,o,i,t[s+13],5,-1444681467),i=m(i,n,r,o,t[s+2],9,-51403784),o=m(o,i,n,r,t[s+7],14,1735328473),n=g(n,r=m(r,o,i,n,t[s+12],20,-1926607734),o,i,t[s+5],4,-378558),i=g(i,n,r,o,t[s+8],11,-2022574463),o=g(o,i,n,r,t[s+11],16,1839030562),r=g(r,o,i,n,t[s+14],23,-35309556),n=g(n,r,o,i,t[s+1],4,-1530992060),i=g(i,n,r,o,t[s+4],11,1272893353),o=g(o,i,n,r,t[s+7],16,-155497632),r=g(r,o,i,n,t[s+10],23,-1094730640),n=g(n,r,o,i,t[s+13],4,681279174),i=g(i,n,r,o,t[s+0],11,-358537222),o=g(o,i,n,r,t[s+3],16,-722521979),r=g(r,o,i,n,t[s+6],23,76029189),n=g(n,r,o,i,t[s+9],4,-640364487),i=g(i,n,r,o,t[s+12],11,-421815835),o=g(o,i,n,r,t[s+15],16,530742520),n=y(n,r=g(r,o,i,n,t[s+2],23,-995338651),o,i,t[s+0],6,-198630844),i=y(i,n,r,o,t[s+7],10,1126891415),o=y(o,i,n,r,t[s+14],15,-1416354905),r=y(r,o,i,n,t[s+5],21,-57434055),n=y(n,r,o,i,t[s+12],6,1700485571),i=y(i,n,r,o,t[s+3],10,-1894986606),o=y(o,i,n,r,t[s+10],15,-1051523),r=y(r,o,i,n,t[s+1],21,-2054922799),n=y(n,r,o,i,t[s+8],6,1873313359),i=y(i,n,r,o,t[s+15],10,-30611744),o=y(o,i,n,r,t[s+6],15,-1560198380),r=y(r,o,i,n,t[s+13],21,1309151649),n=y(n,r,o,i,t[s+4],6,-145523070),i=y(i,n,r,o,t[s+11],10,-1120210379),o=y(o,i,n,r,t[s+2],15,718787259),r=y(r,o,i,n,t[s+9],21,-343485551),n=b(n,a),r=b(r,l),o=b(o,u),i=b(i,c)}return Array(n,r,o,i)}function f(t,e,n,r,o,i){return b((e=b(b(e,t),b(r,i)))<<o|e>>>32-o,n)}function p(t,e,n,r,o,i,s){return f(e&n|~e&r,t,e,o,i,s)}function m(t,e,n,r,o,i,s){return f(e&r|n&~r,t,e,o,i,s)}function g(t,e,n,r,o,i,s){return f(e^n^r,t,e,o,i,s)}function y(t,e,n,r,o,i,s){return f(n^(e|~r),t,e,o,i,s)}function b(t,e){var n=(65535&t)+(65535&e);return(t>>16)+(e>>16)+(n>>16)<<16|65535&n}e.exports=function(t){return h.hash(t,d,16)}}).call(this,t("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},t("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(t,e,n){(function(t,n,r,o,i,s,a,l,u){e.exports=function(t){for(var e,n=new Array(t),r=0;r<t;r++)!(3&r)&&(e=4294967296*Math.random()),n[r]=e>>>((3&r)<<3)&255;return n}}).call(this,t("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},t("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(t,e,n){(function(n,r,o,i,s,a,l,u,c){var h=t("./helpers");function d(t,e){t[e>>5]|=128<<24-e%32,t[15+(e+64>>9<<4)]=e;for(var n,r,o,i=Array(80),s=1732584193,a=-271733879,l=-1732584194,u=271733878,c=-1009589776,h=0;h<t.length;h+=16){for(var d=s,m=a,g=l,y=u,b=c,v=0;v<80;v++){i[v]=v<16?t[h+v]:p(i[v-3]^i[v-8]^i[v-14]^i[v-16],1);var C=f(f(p(s,5),(C=a,r=l,o=u,(n=v)<20?C&r|~C&o:!(n<40)&&n<60?C&r|C&o|r&o:C^r^o)),f(f(c,i[v]),(n=v)<20?1518500249:n<40?1859775393:n<60?-1894007588:-899497514));c=u,u=l,l=p(a,30),a=s,s=C}s=f(s,d),a=f(a,m),l=f(l,g),u=f(u,y),c=f(c,b)}return Array(s,a,l,u,c)}function f(t,e){var n=(65535&t)+(65535&e);return(t>>16)+(e>>16)+(n>>16)<<16|65535&n}function p(t,e){return t<<e|t>>>32-e}e.exports=function(t){return h.hash(t,d,20,!0)}}).call(this,t("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},t("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(t,e,n){(function(n,r,o,i,s,a,l,u,c){function h(t,e){var n=(65535&t)+(65535&e);return(t>>16)+(e>>16)+(n>>16)<<16|65535&n}function d(t,e){var n,r=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),o=new Array(1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225),i=new Array(64);t[e>>5]|=128<<24-e%32,t[15+(e+64>>9<<4)]=e;for(var s,a,l=0;l<t.length;l+=16){for(var u=o[0],c=o[1],d=o[2],f=o[3],g=o[4],y=o[5],b=o[6],v=o[7],C=0;C<64;C++)i[C]=C<16?t[C+l]:h(h(h((a=i[C-2],p(a,17)^p(a,19)^m(a,10)),i[C-7]),(a=i[C-15],p(a,7)^p(a,18)^m(a,3))),i[C-16]),n=h(h(h(h(v,p(a=g,6)^p(a,11)^p(a,25)),g&y^~g&b),r[C]),i[C]),s=h(p(s=u,2)^p(s,13)^p(s,22),u&c^u&d^c&d),v=b,b=y,y=g,g=h(f,n),f=d,d=c,c=u,u=h(n,s);o[0]=h(u,o[0]),o[1]=h(c,o[1]),o[2]=h(d,o[2]),o[3]=h(f,o[3]),o[4]=h(g,o[4]),o[5]=h(y,o[5]),o[6]=h(b,o[6]),o[7]=h(v,o[7])}return o}var f=t("./helpers"),p=function(t,e){return t>>>e|t<<32-e},m=function(t,e){return t>>>e};e.exports=function(t){return f.hash(t,d,32,!0)}}).call(this,t("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},t("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(t,e,n){(function(t,e,r,o,i,s,a,l,u){n.read=function(t,e,n,r,o){var i,s,a=8*o-r-1,l=(1<<a)-1,u=l>>1,c=-7,h=n?o-1:0,d=n?-1:1;for(o=t[e+h],h+=d,i=o&(1<<-c)-1,o>>=-c,c+=a;0<c;i=256*i+t[e+h],h+=d,c-=8);for(s=i&(1<<-c)-1,i>>=-c,c+=r;0<c;s=256*s+t[e+h],h+=d,c-=8);if(0===i)i=1-u;else{if(i===l)return s?NaN:1/0*(o?-1:1);s+=Math.pow(2,r),i-=u}return(o?-1:1)*s*Math.pow(2,i-r)},n.write=function(t,e,n,r,o,i){var s,a,l=8*i-o-1,u=(1<<l)-1,c=u>>1,h=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,d=r?0:i-1,f=r?1:-1;for(i=e<0||0===e&&1/e<0?1:0,e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=u):(s=Math.floor(Math.log(e)/Math.LN2),e*(r=Math.pow(2,-s))<1&&(s--,r*=2),2<=(e+=1<=s+c?h/r:h*Math.pow(2,1-c))*r&&(s++,r/=2),u<=s+c?(a=0,s=u):1<=s+c?(a=(e*r-1)*Math.pow(2,o),s+=c):(a=e*Math.pow(2,c-1)*Math.pow(2,o),s=0));8<=o;t[n+d]=255&a,d+=f,a/=256,o-=8);for(s=s<<o|a,l+=o;0<l;t[n+d]=255&s,d+=f,s/=256,l-=8);t[n+d-f]|=128*i}}).call(this,t("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},t("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(t,e,n){(function(t,n,r,o,i,s,a,l,u){var c,h,d;function f(){}(t=e.exports={}).nextTick=(h="undefined"!=typeof window&&window.setImmediate,d="undefined"!=typeof window&&window.postMessage&&window.addEventListener,h?function(t){return window.setImmediate(t)}:d?(c=[],window.addEventListener("message",(function(t){var e=t.source;e!==window&&null!==e||"process-tick"!==t.data||(t.stopPropagation(),0<c.length&&c.shift()())}),!0),function(t){c.push(t),window.postMessage("process-tick","*")}):function(t){setTimeout(t,0)}),t.title="browser",t.browser=!0,t.env={},t.argv=[],t.on=f,t.addListener=f,t.once=f,t.off=f,t.removeListener=f,t.removeAllListeners=f,t.emit=f,t.binding=function(t){throw new Error("process.binding is not supported")},t.cwd=function(){return"/"},t.chdir=function(t){throw new Error("process.chdir is not supported")}}).call(this,t("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},t("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:(t,e)=>{"use strict";var n;!function(){var r=e||{}||this||window;void 0===(n=function(){return r}.apply(e,[]))||(t.exports=n),r.default=r;var o="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(t){return t instanceof HTMLElement||t instanceof SVGElement},u=function(t){if(!l(t))throw new Error("an HTMLElement or SVGElement is required; got "+t)},c=function(t){return new Promise((function(e,n){l(t)?e(t):n(new Error("an HTMLElement or SVGElement is required; got "+t))}))},h=function(t,e,n){var r=t.viewBox&&t.viewBox.baseVal&&t.viewBox.baseVal[n]||null!==e.getAttribute(n)&&!e.getAttribute(n).match(/%$/)&&parseInt(e.getAttribute(n))||t.getBoundingClientRect()[n]||parseInt(e.style[n])||parseInt(window.getComputedStyle(t).getPropertyValue(n));return null==r||isNaN(parseFloat(r))?0:r},d=function(t){for(var e=window.atob(t.split(",")[1]),n=t.split(",")[0].split(":")[1].split(";")[0],r=new ArrayBuffer(e.length),o=new Uint8Array(r),i=0;i<e.length;i++)o[i]=e.charCodeAt(i);return new Blob([r],{type:n})},f={},p=null,m=function(t,e){var n=e||{},r=n.selectorRemap,o=n.modifyStyle,i=n.modifyCss,l=n.fonts,u=n.excludeUnusedCss,c=i||function(t,e){return(r?r(t):t)+"{"+(o?o(e):e)+"}\n"},h=[],d=void 0===l,m=l||[];return(p||(p=Array.from(document.styleSheets).map((function(t){try{return{rules:t.cssRules,href:t.href}}catch(e){return console.warn("Stylesheet could not be loaded: "+t.href,e),{}}})))).forEach((function(e){var n=e.rules,r=e.href;n&&Array.from(n).forEach((function(e){if(void 0!==e.style)if(function(t,e){if(e)try{return t.querySelector(e)||t.parentNode&&t.parentNode.querySelector(e)}catch(t){console.warn('Invalid CSS selector "'+e+'"',t)}}(t,e.selectorText))h.push(c(e.selectorText,e.style.cssText));else if(d&&e.cssText.match(/^@font-face/)){var n=function(t,e){var n=t.cssText.match(s),r=n&&n[1]||"";if(r&&!r.match(/^data:/)&&"about:blank"!==r){var o,i,l=r.startsWith("../")?e+"/../"+r:r.startsWith("./")?e+"/."+r:r;return{text:t.cssText,format:(o=l,i=Object.keys(a).filter((function(t){return o.indexOf("."+t)>0})).map((function(t){return a[t]})),i?i[0]:(console.error("Unknown font format for "+o+". Fonts may not be working correctly."),"application/octet-stream")),url:l}}}(e,r);n&&m.push(n)}else u||h.push(e.cssText)}))})),function(t){return Promise.all(t.map((function(t){return new Promise((function(e,n){if(f[t.url])return e(f[t.url]);var r=new XMLHttpRequest;r.addEventListener("load",(function(){var n=function(t){for(var e="",n=new Uint8Array(t),r=0;r<n.byteLength;r++)e+=String.fromCharCode(n[r]);return window.btoa(e)}(r.response),o=t.text.replace(s,'url("data:'+t.format+";base64,"+n+'")')+"\n";f[t.url]=o,e(o)})),r.addEventListener("error",(function(n){console.warn("Failed to load font from: "+t.url,n),f[t.url]=null,e(null)})),r.addEventListener("abort",(function(n){console.warn("Aborted loading font from: "+t.url,n),e(null)})),r.open("GET",t.url),r.responseType="arraybuffer",r.send()}))}))).then((function(t){return t.filter((function(t){return t})).join("")}))}(m).then((function(t){return h.join("\n")+t}))},g=function(){if(!navigator.msSaveOrOpenBlob&&!("download"in document.createElement("a")))return{popup:window.open()}};r.prepareSvg=function(t,e,n){u(t);var r=e||{},s=r.left,a=void 0===s?0:s,l=r.top,c=void 0===l?0:l,d=r.width,f=r.height,p=r.scale,g=void 0===p?1:p,y=r.responsive,b=void 0!==y&&y,v=r.excludeCss,C=void 0!==v&&v;return function(t){return Promise.all(Array.from(t.querySelectorAll("image")).map((function(t){var e,n=t.getAttributeNS("http://www.w3.org/1999/xlink","href")||t.getAttribute("href");return n?((e=n)&&0===e.lastIndexOf("http",0)&&-1===e.lastIndexOf(window.location.host)&&(n+=(-1===n.indexOf("?")?"?":"&")+"t="+(new Date).valueOf()),new Promise((function(e,r){var o=document.createElement("canvas"),i=new Image;i.crossOrigin="anonymous",i.src=n,i.onerror=function(){return r(new Error("Could not load "+n))},i.onload=function(){o.width=i.width,o.height=i.height,o.getContext("2d").drawImage(i,0,0),t.setAttributeNS("http://www.w3.org/1999/xlink","href",o.toDataURL("image/png")),e(!0)}}))):Promise.resolve(null)})))}(t).then((function(){var r=t.cloneNode(!0);r.style.backgroundColor=(e||{}).backgroundColor||t.style.backgroundColor;var s=function(t,e,n,r){if("svg"===t.tagName)return{width:n||h(t,e,"width"),height:r||h(t,e,"height")};if(t.getBBox){var o=t.getBBox(),i=o.x,s=o.y;return{width:i+o.width,height:s+o.height}}}(t,r,d,f),l=s.width,u=s.height;if("svg"!==t.tagName){if(!t.getBBox)return void console.error("Attempted to render non-SVG element",t);null!=r.getAttribute("transform")&&r.setAttribute("transform",r.getAttribute("transform").replace(/translate\(.*?\)/,""));var p=document.createElementNS("http://www.w3.org/2000/svg","svg");p.appendChild(r),r=p}if(r.setAttribute("version","1.1"),r.setAttribute("viewBox",[a,c,l,u].join(" ")),r.getAttribute("xmlns")||r.setAttributeNS(o,"xmlns",i),r.getAttribute("xmlns:xlink")||r.setAttributeNS(o,"xmlns:xlink","http://www.w3.org/1999/xlink"),b?(r.removeAttribute("width"),r.removeAttribute("height"),r.setAttribute("preserveAspectRatio","xMinYMin meet")):(r.setAttribute("width",l*g),r.setAttribute("height",u*g)),Array.from(r.querySelectorAll("foreignObject > *")).forEach((function(t){t.setAttributeNS(o,"xmlns","svg"===t.tagName?i:"http://www.w3.org/1999/xhtml")})),!C)return m(t,e).then((function(t){var e=document.createElement("style");e.setAttribute("type","text/css"),e.innerHTML="<![CDATA[\n"+t+"\n]]>";var o=document.createElement("defs");o.appendChild(e),r.insertBefore(o,r.firstChild);var i=document.createElement("div");i.appendChild(r);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:u};n(s,l,u)}));var y=document.createElement("div");y.appendChild(r);var v=y.innerHTML;if("function"!=typeof n)return{src:v,width:l,height:u};n(v,l,u)}))},r.svgAsDataUri=function(t,e,n){return u(t),r.prepareSvg(t,e).then((function(t){var e=t.src,r=t.width,o=t.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 " ">]>'+e).replace(/%([0-9A-F]{2})/g,(function(t,e){var n=String.fromCharCode("0x"+e);return"%"===n?"%25":n}))));return"function"==typeof n&&n(i,r,o),i}))},r.svgAsPngUri=function(t,e,n){u(t);var o=e||{},i=o.encoderType,s=void 0===i?"image/png":i,a=o.encoderOptions,l=void 0===a?.8:a,c=o.canvg,h=function(t){var e=t.src,r=t.width,o=t.height,i=document.createElement("canvas"),a=i.getContext("2d"),u=window.devicePixelRatio||1;i.width=r*u,i.height=o*u,i.style.width=i.width+"px",i.style.height=i.height+"px",a.setTransform(u,0,0,u,0,0),c?c(i,e):a.drawImage(e,0,0);var h=void 0;try{h=i.toDataURL(s,l)}catch(t){if("undefined"!=typeof SecurityError&&t instanceof SecurityError||"SecurityError"===t.name)return void console.error("Rendered SVG images cannot be downloaded in this browser.");throw t}return"function"==typeof n&&n(h,i.width,i.height),Promise.resolve(h)};return c?r.prepareSvg(t,e).then(h):r.svgAsDataUri(t,e).then((function(t){return new Promise((function(e,n){var r=new Image;r.onload=function(){return e(h({src:r,width:r.width,height:r.height}))},r.onerror=function(){n("There was an error loading the data URI as an image on the following SVG\n"+window.atob(t.slice(26))+"Open the following link to see browser's diagnosis\n"+t)},r.src=t}))}))},r.download=function(t,e,n){if(navigator.msSaveOrOpenBlob)navigator.msSaveOrOpenBlob(d(e),t);else{var r=document.createElement("a");if("download"in r){r.download=t,r.style.display="none",document.body.appendChild(r);try{var o=d(e),i=URL.createObjectURL(o);r.href=i,r.onclick=function(){return requestAnimationFrame((function(){return URL.revokeObjectURL(i)}))}}catch(t){console.error(t),console.warn("Error while getting object URL. Falling back to string URL."),r.href=e}r.click(),document.body.removeChild(r)}else n&&n.popup&&(n.popup.document.title=t,n.popup.location.replace(e))}},r.saveSvg=function(t,e,n){var o=g();return c(t).then((function(t){return r.svgAsDataUri(t,n||{})})).then((function(t){return r.download(e,t,o)}))},r.saveSvgAsPng=function(t,e,n){var o=g();return c(t).then((function(t){return r.svgAsPngUri(t,n||{})})).then((function(t){return r.download(e,t,o)}))}}()},5072:t=>{"use strict";var e=[];function n(t){for(var n=-1,r=0;r<e.length;r++)if(e[r].identifier===t){n=r;break}return n}function r(t,r){for(var i={},s=[],a=0;a<t.length;a++){var l=t[a],u=r.base?l[0]+r.base:l[0],c=i[u]||0,h="".concat(u," ").concat(c);i[u]=c+1;var d=n(h),f={css:l[1],media:l[2],sourceMap:l[3],supports:l[4],layer:l[5]};if(-1!==d)e[d].references++,e[d].updater(f);else{var p=o(f,r);r.byIndex=a,e.splice(a,0,{identifier:h,updater:p,references:1})}s.push(h)}return s}function o(t,e){var n=e.domAPI(e);return n.update(t),function(e){if(e){if(e.css===t.css&&e.media===t.media&&e.sourceMap===t.sourceMap&&e.supports===t.supports&&e.layer===t.layer)return;n.update(t=e)}else n.remove()}}t.exports=function(t,o){var i=r(t=t||[],o=o||{});return function(t){t=t||[];for(var s=0;s<i.length;s++){var a=n(i[s]);e[a].references--}for(var l=r(t,o),u=0;u<i.length;u++){var c=n(i[u]);0===e[c].references&&(e[c].updater(),e.splice(c,1))}i=l}}},7659:t=>{"use strict";var e={};t.exports=function(t,n){var r=function(t){if(void 0===e[t]){var n=document.querySelector(t);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(t){n=null}e[t]=n}return e[t]}(t);if(!r)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");r.appendChild(n)}},540:t=>{"use strict";t.exports=function(t){var e=document.createElement("style");return t.setAttributes(e,t.attributes),t.insert(e,t.options),e}},5056:(t,e,n)=>{"use strict";t.exports=function(t){var e=n.nc;e&&t.setAttribute("nonce",e)}},7825:t=>{"use strict";t.exports=function(t){if("undefined"==typeof document)return{update:function(){},remove:function(){}};var e=t.insertStyleElement(t);return{update:function(n){!function(t,e,n){var r="";n.supports&&(r+="@supports (".concat(n.supports,") {")),n.media&&(r+="@media ".concat(n.media," {"));var o=void 0!==n.layer;o&&(r+="@layer".concat(n.layer.length>0?" ".concat(n.layer):""," {")),r+=n.css,o&&(r+="}"),n.media&&(r+="}"),n.supports&&(r+="}");var i=n.sourceMap;i&&"undefined"!=typeof btoa&&(r+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(i))))," */")),e.styleTagTransform(r,t,e.options)}(e,t,n)},remove:function(){!function(t){if(null===t.parentNode)return!1;t.parentNode.removeChild(t)}(e)}}}},1113:t=>{"use strict";t.exports=function(t,e){if(e.styleSheet)e.styleSheet.cssText=t;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(t))}}},6686:(t,e,n)=>{"use strict";n.d(e,{AL:()=>r,NO:()=>o});const r=["A","G","C","U"];var o;!function(t){t.HELM="HELM",t.AXOLABS="Axolabs"}(o||(o={}))},9537:(t,e,n)=>{"use strict";n.d(e,{iL:()=>i,q7:()=>o,ti:()=>r});const r={NUCLEOSIDE:"nucleoside",LINKAGE:"phosphateBackbone"},o="p",i="<?>"},3480:(t,e,n)=>{"use strict";n.d(e,{C6:()=>l,Hs:()=>a,OT:()=>u,bD:()=>s});var r=n(6686),o=n(5067),i=n(9537);function s(t,e,n,o){const i=Object.keys(o.jsonData.codesToHelmDict).concat([r.NO.HELM]);if(!t||-1!==e&&n!==r.NO.HELM)return{};if(!i.includes(n))throw new Error(`${n} format is not supported by SequenceTranslator`);const s=i.filter((t=>t!=n)).sort(((t,e)=>t.localeCompare(e))),l=o.createFormatConverter(t,n),u=Object.fromEntries(s.map((t=>{let e;try{e=l.convertTo(t)}catch{e=null}return[t,e]})).filter((([t,e])=>e))),c=a(n===r.NO.HELM?t:u[r.NO.HELM],o.monomerLibWrapper);return c&&(u.Nucleotides=c),u}function a(t,e){const n=new RegExp("\\([^()]*\\)","g"),o=t.match(n);return o?o.map((t=>{const n=t.replace(/[\[\]()]/g,"");return r.AL.includes(n)?n:e.getNaturalAnalogBySymbol(n)})).map((t=>t||i.iL)).join(""):null}function l(t,e,n,i){const s=i.createFormatConverter(t,e);return n===o.qP?a(s.convertTo(r.NO.HELM),i.monomerLibWrapper):s.convertTo(n)}function u(t){return Object.keys(t.jsonData.codesToHelmDict).concat([r.NO.HELM,o.qP]).sort()}},5067:(t,e,n)=>{"use strict";n.d(e,{U_:()=>o,n_:()=>r,qP:()=>i});const r="Copied",o="Copy sequence",i="Nucleotides"},9788:(t,e,n)=>{"use strict";n.d(e,{PackageFunctions:()=>Er,_package:()=>Ar});var r=n(4328),o=n(6082),i=n(439),s=n(7291);const a=new class{constructor(){this.seqHandler="seq-handler",this.notationProvider="seq-handler.notation-provider"}};o.SemanticValue;var l=n(4971);class u{constructor(t,e,n=""){this.target=t,this.debugEnabled=e,this.prefix=n}error(t,e,n){return this.target.error(this.prefix+t,e,n)}warning(t,e){return this.target.warning(this.prefix+t,e)}info(t,e){return this.target.info(this.prefix+t,e)}debug(t,e){if(this.debugEnabled)return this.target.debug(this.prefix+t,e)}}const c="System:AppData/SequenceTranslator/monomers-sample",h="pattern-app-data.json",d="formats-to-helm.json",f="codes-to-symbols.json",p="linkers.json";var m=n(6686);function g(t){return t.sort(((t,e)=>e.length-t.length))}function y(t,e){const n=document.createElement("a");n.setAttribute("href","data:text/plain;charset=utf-8,"+e),n.setAttribute("download",t),n.click()}async function b(t,e,n="Oligo app"){try{return await t()}catch(t){const e=t.hasOwnProperty("message")?t.message:t.toString();throw r.shell.error(`${n} error: `+e),t}finally{e&&e()}}class v{constructor(t,e){this.sequence=t,this.th=e,this.libWrapper=this.th.monomerLibWrapper}getInvalidCodeIndex(t){if(t===m.NO.HELM)return this.sequence.length;const e=["r","d"],n=g(this.libWrapper.getCodesByFormat(t));let r=0;for(;r<this.sequence.length;){const t=n.find((t=>t===this.sequence.substring(r,r+t.length)));if(!t)break;if(r>1&&m.AL.includes(this.sequence[r])&&e.includes(this.sequence[r-2]))break;if(e.includes(this.sequence[r+1])&&m.AL.includes(this.sequence[r])){r++;break}r+=t.length}return r===this.sequence.length&&(r=-1),r}isValidSequence(t){return-1===this.getInvalidCodeIndex(t)}}class C{constructor(t,e,n,r){this.patternAppData=t,this.codesToHelmDict=e,this.codesToSymbolsDict=n,this.monomersWithPhosphate=r}}async function w(t){const e=await Promise.all([h,d,f,p].map((e=>async function(t,e){const n=t.endsWith("/")?`${t}${e}`:`${t}/${e}`;try{const t=await r.dapi.files.readAsText(n);return JSON.parse(t)}catch(t){console.error(`Error loading json from '${n}':`,t)}}(t,e))));return new C(e[0],e[1],e[2],e[3])}class A{constructor(t,e){if(this.lib=t,this.jsonData=e,null===this.lib)throw new Error("SequenceTranslator: monomer library is null");this.allMonomers=this.getAllMonomers()}formatMonomerForViewer(t){const e={};return e.name=t.symbol,e.symbol=t.symbol,e.molfile=t.molfile,this.getAllFormats().forEach((n=>{if(n===m.NO.HELM)return;const r=this.jsonData.codesToSymbolsDict[n],o=Object.keys(r).filter((e=>r[e]===t.symbol));e[n]=o.join(", ")})),e}getAllMonomers(){const t=this.lib.getPolymerTypes();let e=[];for(const n of t){const t=this.lib.getMonomerSymbolsByType(n).map((t=>this.lib.getMonomer(n,t))).filter((t=>null!==t));e=e.concat(t)}return e}getMonomer(t){const e=this.lib.getMonomer("RNA",t);if(void 0===e)throw new Error(`SequenceTranslator: no monomer with symbol ${t}`);return e}getMolfileBySymbol(t){return this.getMonomer(t).molfile}getNaturalAnalogBySymbol(t){const e=this.getMonomer(t).naturalAnalog;if(!e)throw new Error(`ST: no natural analog for ${t}`);return e}isModification(t){return!!this.getMolfileBySymbol(t).includes("MODIFICATION")}getCodeToSymbolMap(t){return new Map(Object.entries(this.jsonData.codesToSymbolsDict[t]))}getCodesByFormat(t){return Object.keys(this.jsonData.codesToSymbolsDict[t])}getAllFormats(){return Object.keys(this.jsonData.codesToSymbolsDict)}getTableForViewer(){const t=this.allMonomers.map((t=>this.formatMonomerForViewer(t)));return o.DataFrame.fromObjects(t)}getCodesToWeightsMap(){const t=new Map;return Object.entries(this.jsonData.codesToSymbolsDict).forEach((([e,n])=>{Object.entries(n).forEach((([e,n])=>{const r=this.getMonomer(n),o=r.meta?.molecularWeight;t.set(e,o)}))})),t}}var x=n(9537);const E=(t,e)=>e.length-t.length;class T{constructor(t){this.th=t,this.formats=this.getFormats()}getFormatNames(){return this.formats.sort()}getCodesByFormat(t){if(this.validateFormat(t),this.isHelm(t))throw new Error("Codes cannot be obtained for HELM");return this.getFormatCodes(t)}getHelmToFormatDict(t){return this.validateFormat(t),function(t){const e={};return Object.values(t).forEach((t=>{Object.entries(t).forEach((([t,n])=>{const r=n.replace(/\)p/g,")").replace(/\]p/g,"]");void 0===e[r]?e[r]=[t]:e[r].push(t)}))})),Object.entries(e).forEach((([t,n])=>{const r=n.sort(E);e[t]=r[0]})),e}(this.th.jsonData.codesToHelmDict[t])}getFormatToHelmDict(t){this.validateFormat(t);const e=this.th.jsonData.codesToHelmDict[t];return Object.assign({},...Object.values(e))}getTargetFormatHelmCodes(t){this.validateFormat(t);const e=this.getHelmToFormatDict(t);return Object.keys(e).sort(E)}getTargetFormatHelmCodesRegExp(t){this.validateFormat(t);const e=this.getTargetFormatHelmCodes(t);return new RegExp(S(e)+"|.","g")}getFormatRegExp(t){if(this.validateFormat(t),this.isHelm(t))throw new Error("Helm RegExp can be built for non-HELM target formats");return this.getNonHelmFormatRegExp(t)}getPhosphateHelmCodesRegExp(t){this.validateFormat(t);const e=this.th.jsonData.codesToHelmDict[t],n=S(Array.from(new Set(Object.values(e[x.ti.LINKAGE]))).sort(E));return new RegExp(`${x.q7}.(${n})`,"g")}isValidFormat(t){return this.formats.includes(t)}getFormats(){return Object.keys(this.th.jsonData.codesToHelmDict)}validateFormat(t){if(!this.isValidFormat(t))throw new Error(`Invalid format: ${t}`)}isHelm(t){return t===m.NO.HELM}getFormatCodes(t){const e=this.getFormatToHelmDict(t);return Object.keys(e).sort(E)}getNonHelmFormatRegExp(t){const e=this.getCodesByFormat(t);return new RegExp(S(e)+"|\\([^()]*\\)|.","g")}}function S(t){return t.map((t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"))).map((t=>t.includes("(")||t.includes(")")?t:`(?<!\\([^()]*)${t}(?![^()]*\\))`)).join("|")}const I={LEFT:"RNA1{",RIGHT:"}$$$$"};class _{constructor(t,e,n){this.sequence=t,this.sourceFormat=e,this.th=n,this.formats=new T(this.th)}convertTo(t){const e=this.formats.getFormatNames();if(this.sourceFormat===m.NO.HELM&&e.includes(t))return this.helmToFormat(this.sequence,t);if(e.includes(this.sourceFormat)&&t===m.NO.HELM)return this.formatToHelm(this.sequence,this.sourceFormat);if([this.sourceFormat,t].every((t=>e.includes(t)))){const e=this.formatToHelm(this.sequence,this.sourceFormat);return this.helmToFormat(e,t)}throw new Error(`ST: unsupported translation direction ${this.sourceFormat} -> ${t}`)}helmToFormat(t,e){const n=new RegExp(S(Object.values(I)),"g");let r=t.replace(n,"");const o=this.formats.getHelmToFormatDict(e),i=this.formats.getTargetFormatHelmCodes(e),s=this.formats.getTargetFormatHelmCodesRegExp(e);return r=r.replace(s,(t=>i.includes(t)?o[t]:"p"===t||"."===t?t:"?")).replace(/\?+/g,x.iL).replace(/p\.|\./g,""),r=r.replace(/<empty>/g,""),r=r.replace(/\/\//g,"/"),r}formatToHelm(t,e){const n=this.formats.getFormatToHelmDict(e),r=this.formats.getCodesByFormat(e),o=this.formats.getFormatRegExp(e),i=this.formats.getPhosphateHelmCodesRegExp(e);let s=t?t.replace(o,(t=>r.includes(t)?n[t]+".":"?")):"";return s=s.replace(/\?+/g,`${x.iL}.`),s=s.slice(0,-1),s[s.length-1]===x.q7&&(s=s.slice(0,-1)),s=s.replace(i,((t,e)=>e)),s=s.replace(/<empty>/g,""),`${I.LEFT+s+I.RIGHT}`}}class N{constructor(t,e){this.sequence=t,this.th=e,this.libWrapper=this.th.monomerLibWrapper,this.formats=Object.keys(this.th.jsonData.codesToHelmDict)}getFormat(){if(this.sequence.startsWith("RNA"))return m.NO.HELM;const t=this.getListOfPossibleSynthesizersByFirstMatchedCode();if(0===t.length)return null;const e=this.th.createSequenceValidator(this.sequence),n=Array(t.length).fill(0);for(let r=0;r<t.length;++r){const o=t[r];n[r]=e.getInvalidCodeIndex(o)}const r=n.some((t=>-1===t))?-1:Math.max(...n);return t[n.indexOf(r)]}getListOfPossibleSynthesizersByFirstMatchedCode(){const t=this.sequence,e=[];for(const n of this.formats){const r=g(this.libWrapper.getCodesByFormat(n));let o=0;for(let e=0;e<t.length;e++)if(")"===t[e]&&e!==t.length-1){o=e+1;break}r.some((e=>e===t.slice(o,o+e.length)))&&e.push(n)}return e}}var P=n(7389);const M=$;var L=n.n(M);function O(t,e){let n=0;const r=e.createFormatDetector(t).getFormat();null!==r&&(n=new v(t,e).getInvalidCodeIndex(r));const o=n<0||""===t,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"),o?i.innerHTML=t:(i.innerHTML=t.slice(0,n),s.innerHTML=t.slice(n)),[i,s]}class R extends o.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(t={debug:!1}){super(),this.highlightInvalidSubsequence=t=>O(t,this),super._logger=new u(super.logger,t.debug)}startInit(t){this._initPromise=t}completeInit(t){this._helmHelper=t}async initLibData(){return this.initLibDataPromise||(this.initLibDataPromise=(async()=>{const t=await this.getSettings();let e=t instanceof Map?t.get("MonomersPath"):t.MonomersPath;e&&await r.dapi.files.exists(e)||(this.logger.warning(`Monomers path '${e}' not found. Fallback to monomers sample path '${c}'.`),e=c),[this._jsonData,this._monomerLib]=await Promise.all([w(e),D(e)]),this._monomerLibWrapper=new A(this.monomerLib,this.jsonData)})()),this.initLibDataPromise}async getTranslationHelper(){return await r.functions.call(`${this.name}:getTranslationHelper`)}createSequenceValidator(t){return new v(t,this)}createFormatConverter(t,e){return new _(t,e,this)}createFormatDetector(t){return new N(t,this)}}async function D(t){const e=o.TaskBarProgressIndicator.create("Initializing Oligo Toolkit monomer library ...");try{const e=await(0,l.pj)(),n=(t.endsWith("/")?t:t+"/")+"monomer-lib.json";return await e.readLibraryFromFilePath(n)}finally{e.close()}}class B{constructor(t,e){this.appName=t,this.parentAppName=e}async getAppView(){const t=o.TaskBarProgressIndicator.create(`Loading ${this.appName}...`),e=r.shell.v?.root;e&&P.setUpdateIndicator(e,!0);try{return await this.constructView()}finally{t.close(),e&&P.setUpdateIndicator(e,!1)}}}class F extends B{constructor(t){super(t),this.view=o.View.create(),this.configureView()}async constructView(){await this.initView();const t=this.parentAppName?this.parentAppName+"/"+this.appName:this.appName;return this.view.path=`/apps/${Ar.name}/${t.replace(/\s/g,"")}/`,this.view}async initView(){const t=await this.getContent();this.view.append(t)}configureView(){this.view.box=!0,this.view.name=this.appName;const t=r.shell.windows;t.showProperties=!1,t.showToolbox=!1,t.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(t){t.IS_ANTISENSE_STRAND_INCLUDED="isAntisenseStrandIncluded",t.NUCLEOTIDE_SEQUENCES="nucleotideSequences",t.PHOSPHOROTHIOATE_LINKAGE_FLAGS="phosphorothioateLinkageFlags",t.STRAND_TERMINUS_MODIFICATIONS="strandTerminusModifications"}(V||(V={})),function(t){t.PATTERN_NAME="patternName",t.PATTERN_COMMENT="patternComment",t.NUCLEOTIDES_WITH_NUMERIC_LABELS="nucleotidesWithNumericLabels"}(j||(j={})),function(t){t.PATTERN_CONFIG="patternConfig",t.AUTHOR_ID="authorID",t.DATE="date"}(q||(q={})),function(t){t.CREATE="create",t.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 J extends Error{constructor(t){super(t),this.name="PatternNameExistsError"}}class Q extends Error{constructor(t){super(t),this.name="PatternExistsError"}}var X=n(4802),Z=n.n(X);class tt{constructor(t){this.th=t,this.otherUsersPatternNameToHash=new Map,this.currentUserPatternNameToHash=new Map}static async getInstance(){const t=await Ar.getTranslationHelper(),e=new tt(t);e.currentUserName=await e.fetchCurrentUserName(),e.currentUserId=await e.fetchCurrentUserId();const n=e.fetchPatterns();return await e.initializePatternMaps(n),e}getCurrentUserPatternNames(){return Array.from(this.currentUserPatternNameToHash.keys()).sort(((t,e)=>t.toLowerCase().localeCompare(e.toLowerCase())))}getOtherUsersPatternNames(){return Array.from(this.otherUsersPatternNameToHash.keys()).sort(((t,e)=>t.toLowerCase().localeCompare(e.toLowerCase())))}getCurrentUserName(){return this.currentUserName}validatePatternNameUniqueness(t){if(this.currentUserPatternNameToHash.has(t))throw new J(`Pattern with name ${t} already exists`)}validatePatternUniqueness(t){if(Array.from(this.currentUserPatternNameToHash.values()).concat(Array.from(this.otherUsersPatternNameToHash.values())).includes(t))throw new Q(t)}getPatternHash(t,e){const n=e?this.currentUserPatternNameToHash.get(t):this.otherUsersPatternNameToHash.get(t);if(void 0===n)throw new Error(`Pattern with name ${t} not found`);return n}async getPatternRecordByHash(t){if(null===t||""===t)return null;try{const e=r.userSettings.getValue(U,t,!1)??"null";return JSON.parse(e)}catch{return null}}async getPatternConfig(t){if(""===t||null===t)return null;const e=await this.getPatternRecordByHash(t);return null===e?null:e[q.PATTERN_CONFIG]}getDefaultPatternRecord(){const t=Y;return t[q.AUTHOR_ID]=this.currentUserId,t}getDefaultPatternConfig(){return Y[q.PATTERN_CONFIG]}getAuthorCategoryByHash(t){if(this.isCurrentUserPattern(t))return this.getCurrentUserAuthorshipCategory();if(this.isOtherUserPattern(t))return this.getOtherUsersAuthorshipCategory();throw new Error(`Pattern with hash ${t} not found`)}isCurrentUserPattern(t){return Array.from(this.currentUserPatternNameToHash.values()).includes(t)}isOtherUserPattern(t){return Array.from(this.otherUsersPatternNameToHash.values()).includes(t)}getPatternNameByHash(t){const e=[this.currentUserPatternNameToHash,this.otherUsersPatternNameToHash];for(const n of e)for(const[e,r]of n.entries())if(r===t)return e;throw new Error(`Pattern with hash ${t} not found`)}getHashOfPatternToBeLoadedAfterDeletion(){const t=this.getCurrentUserPatternNames()[0];if(!t)throw new Error("Cannot load pattern after deletion, as there are no patterns left");const e=this.currentUserPatternNameToHash.get(t);if(void 0===e)throw new Error(`Pattern with name ${t} not found`);return e}async getRecordFromPattern(t){return{[q.PATTERN_CONFIG]:t,[q.AUTHOR_ID]:await r.dapi.users.current().then((t=>t.id))}}getHash(t){const e=z.reduce(((e,n)=>(e[n]=t[n],e)),{});return Z().sha1(e)}async savePatternToUserStorage(t){const e=t.getPatternConfig();try{const n=this.getHash(e);this.validatePatternUniqueness(n);const o=e[j.PATTERN_NAME];this.validatePatternNameUniqueness(o);const i=await this.getRecordFromPattern(e),s=(new Date).toISOString();i[q.DATE]={[W.CREATE]:s,[W.MODIFY]:s};const a=JSON.stringify(i);r.userSettings.add(U,n,a,!1),this.currentUserPatternNameToHash.set(o,n),t.selectAuthor(this.getCurrentUserAuthorshipCategory()),t.updatePatternList(),t.requestPatternLoad(n),t.updateUrlState(n)}catch(t){if(t instanceof J||t instanceof Q)throw t;console.error("Error while saving pattern to user storage",t)}}async overwriteExistingPatternInUserStorage(t){const e=t.getPatternConfig(),n=e[j.PATTERN_NAME],o=this.currentUserPatternNameToHash.get(n);if(void 0===o)throw new Error("Old hash is undefined");const i=this.getHash(e),s=await this.getRecordFromPattern(e),a=(new Date).toISOString();s[q.DATE]={[W.MODIFY]:a};const l=r.userSettings.getValue(U,o,!1)??"null",u=JSON.parse(l);void 0!==u[q.DATE]&&null!=u[q.DATE][W.CREATE]&&(s[q.DATE][W.CREATE]=u[q.DATE][W.CREATE]);const c=JSON.stringify(s);r.userSettings.add(U,i,c,!1),r.userSettings.delete(U,o,!1),this.currentUserPatternNameToHash.set(n,i),t.requestPatternLoad(i),t.updateUrlState(i)}async deletePattern(t,e){const n=this.currentUserPatternNameToHash.get(t);if(t===this.getDefaultPatternName())return void r.shell.warning("Cannot delete default pattern");if(void 0===n)throw new Error(`Pattern with name ${t} not found`);r.userSettings.delete(U,n,!1),this.currentUserPatternNameToHash.delete(t),e.updatePatternList();const o=this.getHashOfPatternToBeLoadedAfterDeletion();e.requestPatternLoad(o)}fetchDefaultNucleobase(){return this.fetchAvailableNucleotideBases()[0]}fetchAvailableNucleotideBases(){const t=Object.keys(this.th.jsonData.patternAppData)[0];return Object.keys(this.th.jsonData.patternAppData[t])}async fetchCurrentUserName(){return(await r.dapi.users.current()).friendlyName}async fetchCurrentUserId(){return(await r.dapi.users.current()).id}fetchPatterns(){return r.userSettings.get(U,!1)??{}}async initializePatternMaps(t){if(!this.currentUserId)throw new Error("Current user ID is not set");const e=new Map;for(const[n,r]of Object.entries(t))await this.extractDataFromRecordToMaps(n,r,e);this.setDefaultPattern()}setDefaultPattern(){const t=Y[q.PATTERN_CONFIG];this.currentUserPatternNameToHash.set(t[j.PATTERN_NAME],"")}async extractDataFromRecordToMaps(t,e,n){const o=JSON.parse(e),i=o[q.PATTERN_CONFIG].patternName,s=o[q.AUTHOR_ID];if(this.isCurrentUserId(s))this.currentUserPatternNameToHash.set(i,t);else{if(!n.has(s)){let t="<UNKNOWN_USER>";try{t=(await r.dapi.users.find(s)).friendlyName}catch(t){}n.set(s,t)}const e=i+` (created by ${n.get(s)})`;this.otherUsersPatternNameToHash.set(e,t)}}getDefaultPatternName(){return Y[q.PATTERN_CONFIG][j.PATTERN_NAME]}getCurrentUserAuthorshipCategory(){return this.currentUserName+" (me)"}getOtherUsersAuthorshipCategory(){return"Other users"}isCurrentUserId(t){return t===this.currentUserId}}const et=rxjs,nt=rxjs.operators;function rt(t){return t.endsWith("(o)")}function ot(t){const e=Object.values(t).flat().reduce(((t,e)=>(t[e]=(t[e]||0)+1,t)),{});return Object.entries(e).reduce(((t,e)=>t[1]>e[1]?t:e),["",0])[0]}var it;function st(t){const e=Array.from(new Set(t));return Array.from(e).sort(((t,e)=>t.toLowerCase().localeCompare(e.toLowerCase())))}!function(t){t.getTruncatedStrandData=function(t,e,n){return{nucleotides:t.slice(0,n),ptoFlags:e.slice(0,n+1)}},t.getExtendedStrandData=function(t,e,n,r){const o=n-t.length,i=t.concat(new Array(n-t.length).fill(r)),s=0===t.length?n+1:o;return{nucleotides:i,ptoFlags:e.concat(new Array(s).fill(!0))}}}(it||(it={}));var at=n(2543),lt=n.n(at);class ut{constructor(t,e){this.dataManager=t,this._patternListUpdated$=new et.Subject,this._patternLoadRequested$=new et.Subject,this._patternLoaded$=new et.Subject,this._uniqueNucleotides$=new et.BehaviorSubject([]),this._patternDeletionRequested$=new et.Subject,this._tableSelection$=new et.BehaviorSubject(null),this._svgSaveRequested$=new et.Subject,this._loadPatternInNewTabRequested$=new et.Subject,this._urlStateUpdated$=new et.Subject,this._patternHasUnsavedChanges$=new et.BehaviorSubject(!1),this._selectedStrandColumn=new et.BehaviorSubject(null),this._selectedIdColumn=new et.BehaviorSubject(null),this.initializeAuthorSelection(e),this.initializePatternState(e),this._lastLoadedPatternConfig=new et.BehaviorSubject(lt().cloneDeep(this.getPatternConfig())),this.setupSubscriptions()}setupSubscriptions(){this._nucleotideSequences$.subscribe((()=>{this.updateUniqueNucleotides(),this.updateSequenceBase()})),this._isAntisenseStrandActive$.subscribe((t=>{t||G.forEach((t=>{this.updateTerminusModification("AS",t,"")}))})),this.patternStateChanged$.pipe((0,nt.debounceTime)(20)).subscribe((()=>{const t=this._lastLoadedPatternConfig.getValue(),e=this.getPatternConfig(),n=!lt().isEqual(e,t);this._patternHasUnsavedChanges$.next(n)}))}updateUniqueNucleotides(){const t=(e=this._nucleotideSequences$.getValue(),st(Object.values(e).flat()));var e;this._uniqueNucleotides$.next(t)}updateSequenceBase(){const t=ot(this._nucleotideSequences$.getValue());this._sequenceBase$.next(t)}get nucleotideSequencesChanged$(){return this._nucleotideSequences$.asObservable()}initializeAuthorSelection(t){const e=t[q.AUTHOR_ID];this.dataManager.isCurrentUserId(e)?this._patternAuthorSelection$=new et.BehaviorSubject(this.dataManager.getCurrentUserAuthorshipCategory()):this._patternAuthorSelection$=new et.BehaviorSubject(this.dataManager.getOtherUsersAuthorshipCategory())}initializePatternState(t){const e=t[q.PATTERN_CONFIG];this._patternName$=new et.BehaviorSubject(e[j.PATTERN_NAME]),this._isAntisenseStrandActive$=new et.BehaviorSubject(e[V.IS_ANTISENSE_STRAND_INCLUDED]),this._nucleotideSequences$=new et.BehaviorSubject(e[V.NUCLEOTIDE_SEQUENCES]),this._phosphorothioateLinkageFlags=new et.BehaviorSubject(e[V.PHOSPHOROTHIOATE_LINKAGE_FLAGS]),this._terminalModifications=new et.BehaviorSubject(e[V.STRAND_TERMINUS_MODIFICATIONS]),this._comment$=new et.BehaviorSubject(e[j.PATTERN_COMMENT]),this._modificationsWithNumericLabels$=new et.BehaviorSubject(e[j.NUCLEOTIDES_WITH_NUMERIC_LABELS]),this._sequenceBase$=new et.BehaviorSubject(ot(e[V.NUCLEOTIDE_SEQUENCES]))}getPatternName(){return this._patternName$.getValue()}updatePatternName(t){this._patternName$.next(t)}get antisenseStrandToggled$(){return this._isAntisenseStrandActive$.asObservable()}isAntisenseStrandActive(){return this._isAntisenseStrandActive$.getValue()}toggleAntisenseStrand(t){t?this.updateStrandLength("AS",this.getNucleotideSequences().SS.length):this.updateStrandLength("AS",0),this._isAntisenseStrandActive$.next(t)}getNucleotideSequences(){return this._nucleotideSequences$.getValue()}updateNucleotideSequences(t){this._nucleotideSequences$.next(t)}updateStrandLength(t,e){const n=this.getNucleotideSequences()[t];if(n.length===e)return;const r=this.getPhosphorothioateLinkageFlags()[t];if(0===e)return void this.setNewStrandData([],[],t);if(n.length>e){const{nucleotides:o,ptoFlags:i}=it.getTruncatedStrandData(n,r,e);return void this.setNewStrandData(o,i,t)}const o=this.getSequenceBase(),{nucleotides:i,ptoFlags:s}=it.getExtendedStrandData(n,r,e,o);this.setNewStrandData(i,s,t)}setNewStrandData(t,e,n){this.updateNucleotideSequences({...this.getNucleotideSequences(),[n]:t}),this.updatePhosphorothioateLinkageFlags({...this.getPhosphorothioateLinkageFlags(),[n]:e})}getPhosphorothioateLinkageFlags(){return this._phosphorothioateLinkageFlags.getValue()}updatePhosphorothioateLinkageFlags(t){this._phosphorothioateLinkageFlags.next(t)}get phosphorothioateLingeFlagsChanged$(){return this._phosphorothioateLinkageFlags.asObservable()}getTerminalModifications(){return this._terminalModifications.getValue()}updateTerminalModifications(t){this._terminalModifications.next(t)}updateTerminusModification(t,e,n){const r=this.getTerminalModifications();r[t][e]=n,this.updateTerminalModifications(r)}terminalModificationsUpdated$(){return this._terminalModifications.asObservable()}getComment(){return this._comment$.getValue()}updateComment(t){this._comment$.next(t)}getModificationsWithNumericLabels(){return this._modificationsWithNumericLabels$.getValue()}updateModificationsWithNumericLabels(t){const e=function(t){return st(t).filter((t=>!rt(t)))}(t);this._modificationsWithNumericLabels$.next(e)}get patternLoadRequested$(){return this._patternLoadRequested$.asObservable()}requestPatternLoad(t){this._patternLoadRequested$.next(t)}get patternListUpdated$(){return this._patternListUpdated$.asObservable()}updatePatternList(){this._patternListUpdated$.next()}get tableSelectionChanged$(){return this._tableSelection$.asObservable()}selectTable(t){this._tableSelection$.next(t)}getTableSelection(){return this._tableSelection$.getValue()}requestPatternDeletion(t){this._patternDeletionRequested$.next(t)}get patternDeletionRequested$(){return this._patternDeletionRequested$.asObservable()}replaceSequenceBase(t){const e=this._nucleotideSequences$.getValue(),n={};k.forEach((r=>{n[r]=e[r].map((()=>t))})),this._nucleotideSequences$.next(n);const r=this._modificationsWithNumericLabels$.getValue();r.includes(t)||this.updateModificationsWithNumericLabels(r.concat(t))}get patternStateChanged$(){return et.merge(this._patternName$.pipe((0,nt.debounceTime)(300),(0,nt.map)((()=>{}))),this._isAntisenseStrandActive$,this._nucleotideSequences$,this._phosphorothioateLinkageFlags,this._terminalModifications,this._comment$.pipe((0,nt.debounceTime)(300)),this._modificationsWithNumericLabels$)}getSequenceBase(){return this._sequenceBase$.getValue()}uniqueNucleotidesChanged$(){return this.patternStateChanged$.pipe((0,nt.switchMap)((()=>this._uniqueNucleotides$)))}getUniqueNucleotides(){return this._uniqueNucleotides$.getValue()}get svgSaveRequested$(){return this._svgSaveRequested$.asObservable()}requestSvgSave(){this._svgSaveRequested$.next()}setAllPTOLinkages(t){const e=this.getPhosphorothioateLinkageFlags();k.forEach((n=>{e[n]=e[n].map((()=>t))})),this.updatePhosphorothioateLinkageFlags(e)}setPatternConfig(t){this._patternName$.next(t[j.PATTERN_NAME]),this._isAntisenseStrandActive$.next(t[V.IS_ANTISENSE_STRAND_INCLUDED]),this._nucleotideSequences$.next(t[V.NUCLEOTIDE_SEQUENCES]),this._phosphorothioateLinkageFlags.next(t[V.PHOSPHOROTHIOATE_LINKAGE_FLAGS]),this._terminalModifications.next(t[V.STRAND_TERMINUS_MODIFICATIONS]),this._comment$.next(t[j.PATTERN_COMMENT]),this._modificationsWithNumericLabels$.next(t[j.NUCLEOTIDES_WITH_NUMERIC_LABELS])}setLastLoadedPatternConfig(t){this._lastLoadedPatternConfig.next(lt().cloneDeep(t))}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(t,e,n){const r=this.getPhosphorothioateLinkageFlags();r[t][e]=n,this.updatePhosphorothioateLinkageFlags(r)}setNucleotide(t,e,n){const r=this.getNucleotideSequences();r[t][e]=n;const o=this.getModificationsWithNumericLabels();this.updateModificationsWithNumericLabels(o.concat(n)),this.updateNucleotideSequences(r)}get strandsUpdated$(){return et.merge(this._isAntisenseStrandActive$.asObservable().pipe((0,nt.map)((()=>{}))),this._nucleotideSequences$.asObservable().pipe((0,nt.map)((()=>{}))),this._patternLoaded$.asObservable().pipe((0,nt.map)((()=>{})))).pipe((0,nt.debounceTime)(10))}get strandsLinkagesAndTerminalsUpdated$(){return et.merge(this.strandsUpdated$,this._phosphorothioateLinkageFlags.asObservable().pipe((0,nt.map)((()=>{}))),this._terminalModifications.asObservable().pipe((0,nt.map)((()=>{}))))}updateControlsUponPatternLoaded(t){this._patternLoaded$.next(t)}get patternLoaded$(){return this._patternLoaded$.asObservable()}get userSelection$(){return this._patternAuthorSelection$.asObservable().pipe((0,nt.skip)(1))}selectAuthor(t){if("string"!=typeof t)throw new Error("Selected user must be defined");this._patternAuthorSelection$.next(t)}getSelectedAuthor(){return this._patternAuthorSelection$.getValue()}get loadPatternInNewTabRequested$(){return this._loadPatternInNewTabRequested$.asObservable()}requestLoadPatternInNewTab(t){this._loadPatternInNewTabRequested$.next(t)}updateUrlState(t){this._urlStateUpdated$.next(t)}get urlStateUpdated$(){return this._urlStateUpdated$.asObservable()}get patternHasUnsavedChanges$(){return this._patternHasUnsavedChanges$.asObservable()}selectStrandColumn(t,e){this._selectedStrandColumn.next({...this._selectedStrandColumn.getValue(),[t]:e})}getSelectedStrandColumn(t){const e=this._selectedStrandColumn.getValue();return e?e[t]:null}selectIdColumn(t){this._selectedIdColumn.next(t)}getSelectedIdColumn(){return this._selectedIdColumn.getValue()}get updateSvgContainer$(){return this.patternStateChanged$.pipe((0,nt.debounceTime)(100))}}const ct="pattern";class ht{constructor(){this.urlSearchParams=new URLSearchParams(window.location.search)}subscribeToObservables(t){t.urlStateUpdated$.subscribe((t=>this.setPatternURL(t))),t.loadPatternInNewTabRequested$.subscribe((t=>{const e=`${window.location.origin}${window.location.pathname}?${ct}=${t}`;window.open(e,"_blank")})),window.addEventListener("popstate",(()=>{this.urlSearchParams=new URLSearchParams(window.location.search);const e=this.getPatternHash();null!==e&&t.requestPatternLoad(e)}))}getPatternHash(){return this.urlSearchParams.get(ct)}setPatternURL(t){null!==t&&""!==t?(this.urlSearchParams.set(ct,t),window.history.pushState({},"",`${window.location.pathname}?${this.urlSearchParams}`)):this.clearPatternURL()}clearPatternURL(){this.urlSearchParams.delete(ct),window.history.pushState({},"",`${window.location.pathname}`)}}var dt=n(5072),ft=n.n(dt),pt=n(7825),mt=n.n(pt),gt=n(7659),yt=n.n(gt),bt=n(5056),vt=n.n(bt),Ct=n(540),wt=n.n(Ct),At=n(1113),xt=n.n(At),Et=n(9252),Tt={};Tt.styleTagTransform=xt(),Tt.setAttributes=vt(),Tt.insert=yt().bind(null,"head"),Tt.domAPI=mt(),Tt.insertStyleElement=wt(),ft()(Et.A,Tt),Et.A&&Et.A.locals&&Et.A.locals;class St{constructor(t){this.eventBus=t,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 t=this.createStrandColumnInput(),e=t.SS,n=t.AS;this.eventBus.antisenseStrandToggled$.subscribe((t=>{L()(n).toggle(t)}));const r=this.createIdColumnInput();return[e,n,r]}createStrandColumnInput(){const t=this.selectedTable?this.selectedTable.columns.names().sort(((t,e)=>t.localeCompare(e))):[];return Object.fromEntries(k.map((e=>{const n=P.input.choice(`${H[e]} column`,{value:t[0],items:t,onValueChanged:t=>this.eventBus.selectStrandColumn(e,t)});return this.eventBus.selectStrandColumn(e,t[0]),[e,n.root]})))}createIdColumnInput(){const t=this.selectedTable?this.selectedTable.columns.names():[],e=P.input.choice("ID column",{value:t[0],items:t,onValueChanged:t=>this.eventBus.selectIdColumn(t)});return this.eventBus.selectIdColumn(t[0]),e.root}}class It{constructor(t){this.eventBus=t,this.availableTables=[],this.tableInputContainer=P.div([]),this.subscribeToTableEvents(),this.refreshTableInput()}getTableInputContainer(){return this.tableInputContainer}subscribeToTableEvents(){r.events.onTableAdded.subscribe((t=>this.handleTableAdded(t))),r.events.onTableRemoved.subscribe((t=>this.handleTableRemoved(t))),this.eventBus.tableSelectionChanged$.subscribe((()=>this.handleTableChoice()))}getTableFromEventData(t){if(!t&&t.args&&t.args.dataFrame instanceof o.DataFrame)throw new Error("EventData does not contain a dataframe",t);return t.args.dataFrame}handleTableAdded(t){const e=this.getTableFromEventData(t);this.availableTables.some((t=>t.name===e.name))||(this.availableTables.push(e),this.eventBus.selectTable(e),this.refreshTableInput())}handleTableRemoved(t){const e=this.getTableFromEventData(t);this.availableTables=this.availableTables.filter((t=>t.name!==e.name));const n=this.availableTables[0];this.eventBus.selectTable(n||null),this.refreshTableInput()}refreshTableInput(){const t=this.createTableInput();L()(this.tableInputContainer).empty(),this.tableInputContainer.append(t.root)}createTableInput(){const t=this.eventBus.getTableSelection();return P.input.table("Tables",{value:t,items:this.availableTables,onValueChanged:t=>{null!==t&&this.eventBus.selectTable(t)}})}handleTableChoice(){const t=this.eventBus.getTableSelection();t&&(this.isTableDisplayed(t)||this.displayTable(t))}isTableDisplayed(t){return r.shell.tableNames.includes(t.name)}displayTable(t){const e=r.shell.v;r.shell.addTableView(t),r.shell.v=e}}function _t(t,e,n,r){const o=function(t,e,n){const r=new Array(t.length+e.filter((t=>t)).length+G.length);r[0]=n["5'"],r[r.length-1]=n["3'"];let o=1;return e[0]&&(r[o]="ps",o++),t.forEach(((t,n)=>{r[n+o]=t,e[n+1]&&(r[n+o+1]="ps",o++)})),r}(t.split("").map(((t,n)=>{const r=function(t,e,n){const r=Object.keys(n.patternAppData)[0],o=n.patternAppData[r][e].substitution;return t.replace(/([AGCTU])/,o)}(t,e[n],Ar.jsonData);return r})),n,r);return o.join("")}class Nt{constructor(t){this.eventBus=t,this.tableInputManager=new It(t),this.columnInputManager=new St(t)}createControls(){const t=P.h1("Bulk convert"),e=this.tableInputManager.getTableInputContainer(),n=this.columnInputManager.getColumnControlsContainer(),r=P.bigButton("Convert",(()=>this.processConvertButtonClick()));return[t,e,n,P.buttonsInput([r])]}processConvertButtonClick(){!function(t){const e=t.getTableSelection();if(!e)return void r.shell.warning("Please select a table");const n=k.filter((e=>!("AS"===e&&!t.isAntisenseStrandActive()))).map((e=>({strand:e,column:t.getSelectedStrandColumn(e)}))).filter((t=>t.column));if(0===n.length)return void r.shell.warning("Select a sense strand column");const o=t.getSelectedIdColumn();if(!o)throw new Error("No ID column selected");e.getCol(o);const i=n.map((t=>({strand:t.strand,column:e.getCol(t.column)})));!function(t,e){const n=e.getNucleotideSequences();return t.every((t=>{const e=n[t.strand].length;return t.column.toList().every((t=>t.length===e))}))}(i,t)?r.shell.warning("Some strands in the table input do not match pattern length"):i.forEach((n=>{const r=n.column,o=n.strand,i=t.getNucleotideSequences()[o],s=t.getTerminalModifications()[o],a=t.getPhosphorothioateLinkageFlags()[o],l=`${t.getPatternName()}(${r.name})`;e.columns.addNewString(l).init((t=>_t(r.get(t),i,a,s)))}))}(this.eventBus)}}class Pt{constructor(t,e,n){this.eventBus=t,this.initialPatternConfig=e,this.subscriptions=n}create(){return P.divV([P.h1("PTO"),P.divH([this.createAllPtoActivationInput().root,...this.createFirstPtoInputs().map((t=>t.root))],{style:{gap:"12px"}})])}areAllPtoLinkagesSet(t){return k.map((e=>t[e].filter((t=>t)).length)).reduce(((t,e)=>t+e),0)===k.map((t=>this.initialPatternConfig.nucleotideSequences[t].length)).reduce(((t,e)=>t+e),0)+k.filter((e=>t[e].length)).length}createAllPtoActivationInput(){const t=this.initialPatternConfig.phosphorothioateLinkageFlags,e=this.areAllPtoLinkagesSet(t),n=P.input.bool("All PTO",{value:e});n.onInput.subscribe((()=>{const t=n.value;this.eventBus.setAllPTOLinkages(t)}));const r=this.eventBus.phosphorothioateLingeFlagsChanged$.subscribe((()=>{const t=this.eventBus.getPatternConfig().phosphorothioateLinkageFlags,e=this.areAllPtoLinkagesSet(t);n.value=e}));return this.subscriptions.add(r),this.addStyleToPtoInput(n),P.tooltip.bind(n.captionLabel,"Activate all phosphothioates"),n}addStyleToPtoInput(t){const e=t.captionLabel;e.classList.add("ui-label-right"),Object.assign(e.style,{textAlign:"left",maxWidth:"100px",minWidth:"40px",width:"auto"})}createFirstPtoInputs(){return k.map((t=>{if(!this.eventBus.isAntisenseStrandActive()&&"AS"===t)return;const e=this.isFirstPtoActive(t),n=P.input.bool(`First ${t} PTO`,{value:e});n.onInput.subscribe((()=>{const e=n.value;this.eventBus.setPhosphorothioateLinkageFlag(t,0,e)}));const r=this.eventBus.phosphorothioateLingeFlagsChanged$.subscribe((e=>{const r=e[t][0];n.value=r}));return this.subscriptions.add(r),this.addStyleToPtoInput(n),P.tooltip.bind(n.captionLabel,`Activate first phosphothioate in ${t}`),n})).filter((t=>void 0!==t))}isFirstPtoActive(t){return this.initialPatternConfig.phosphorothioateLinkageFlags[t][0]}}class Mt{constructor(t,e,n){this.eventBus=t,this.dataManager=e,this.subscriptions=n;const r=this.eventBus.nucleotideSequencesChanged$.subscribe((()=>{this.displayedInputLabels=this.computeDisplayedInputLabels()}));this.subscriptions.add(r)}create(){const t=k.map((t=>this.constructControlsPanel(t)));return P.divH(t,{style:{gap:"24px"}})}constructControlsPanel(t){if(!this.eventBus.isAntisenseStrandActive()&&"AS"===t)return P.div([]);const e=this.constructHeader(),n=this.createControls(t);return P.block([P.h1(`${H[t]}`),e,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(t){const e=this.createNucleobaseInputs(t),n=this.createLabelDivs(t),r=this.createPTOFlagInputs(t);return P.div(e.map(((t,e)=>P.divH([n[e],P.block75([t.root]),r[e].root],{style:{alignItems:"center"}}))))}createNucleobaseInputs(t){const e=this.dataManager.fetchAvailableNucleotideBases().sort(((t,e)=>t.toLowerCase().localeCompare(e.toLowerCase())));return this.eventBus.getNucleotideSequences()[t].map(((n,r)=>{const o=P.input.choice("",{value:n,items:e});return o.onInput.subscribe((()=>{const e=o.value;this.eventBus.setNucleotide(t,r,e)})),o}))}createPTOFlagInputs(t){return this.eventBus.getPhosphorothioateLinkageFlags()[t].slice(1).map(((e,n)=>{const r=P.input.bool("",{value:e});r.onInput.subscribe((()=>{const e=r.value;this.eventBus.setPhosphorothioateLinkageFlag(t,n+1,e)}));const o=this.eventBus.phosphorothioateLingeFlagsChanged$.subscribe((e=>{const o=e[t][n+1];r.value=o}));return this.subscriptions.add(o),r}))}computeDisplayedInputLabels(){const t=this.eventBus.getNucleotideSequences(),e=new Map;return k.forEach((n=>{let r=1;const o=t[n].map((t=>{if(rt(t))return"";const e=String(r);return r++,e}));e.set(n,o)})),e}createLabelDivs(t){const e=this.createLabels(t).map((t=>P.div([t],{style:{width:"20px"}}))),n=this.eventBus.nucleotideSequencesChanged$.subscribe((()=>{this.createLabels(t).forEach(((t,n)=>{L()(e[n]).empty(),L()(e[n]).append(t)}))}));return this.subscriptions.add(n),e}createLabels(t){return this.eventBus.getNucleotideSequences()[t].map(((e,n)=>{const r=this.displayedInputLabels.get(t)[n];return P.label(r)}))}}class Lt{constructor(){this.rxjsSubscriptions=[],this.dgSubscriptions=[]}add(t){t instanceof et.Subscription?this.rxjsSubscriptions.push(t):this.dgSubscriptions.push(t)}unsubscribeAll(){for(const t of[this.rxjsSubscriptions,this.dgSubscriptions])t.forEach((t=>t.unsubscribe())),t.length=0}}class Ot{constructor(t,e){this.eventBus=t,this.dataManager=e,this.subscriptions=new Lt}static open(t,e){Ot.isDialogOpen||(Ot.instance||(Ot.instance=new Ot(t,e)),Ot.instance.openDialog())}openDialog(){this.initialPatternConfig=lt().cloneDeep(this.eventBus.getPatternConfig()),Ot.isDialogOpen=!0,this.createDialog().show()}createDialog(){const t=P.divV([]);this.subscriptions.add(this.eventBus.strandsUpdated$.subscribe((()=>this.onStrandsUpdated(t))));const e=P.dialog("Edit strands").add(t).onOK((()=>{})).onCancel((()=>this.resetToInitialState()));return this.subscriptions.add(e.onClose.subscribe((()=>{Ot.isDialogOpen=!1,this.subscriptions.unsubscribeAll()}))),e}onStrandsUpdated(t){const e=new Pt(this.eventBus,this.initialPatternConfig,this.subscriptions).create(),n=new Mt(this.eventBus,this.dataManager,this.subscriptions).create();L()(t).empty(),L()(t).append(e,n)}resetToInitialState(){this.eventBus.setPatternConfig(this.initialPatternConfig)}}Ot.isDialogOpen=!1;class Rt{constructor(t){this.eventBus=t,this.subscriptions=new Lt}static open(t){Rt.isDialogOpen||(Rt.instance||(Rt.instance=new Rt(t)),Rt.instance.openDialog())}openDialog(){this.initialPatternConfig=lt().cloneDeep(this.eventBus.getPatternConfig()),Rt.isDialogOpen=!0,this.createDialog().show()}createDialog(){const t=P.divV([]);this.subscriptions.add(this.eventBus.strandsUpdated$.subscribe((()=>this.onStrandsUpdated(t))));const e=P.dialog("Edit terminal modifications").add(t).onOK((()=>{})).onCancel((()=>this.resetToInitialState()));return this.subscriptions.add(e.onClose.subscribe((()=>{Rt.isDialogOpen=!1,this.subscriptions.unsubscribeAll()}))),e}onStrandsUpdated(t){const e=new Dt(this.eventBus).create();L()(t).empty(),L()(t).append(e)}resetToInitialState(){this.eventBus.setPatternConfig(this.initialPatternConfig)}}Rt.isDialogOpen=!1;class Dt{constructor(t){this.eventBus=t}create(){const t=k.map((t=>this.constructControlsPanel(t)));return P.divH(t,{style:{gap:"24px"}})}constructControlsPanel(t){if(!this.eventBus.isAntisenseStrandActive()&&"AS"===t)return P.div([]);const e=this.createInputs(t);return P.block([P.h1(`${H[t]}`),e],{style:{paddingTop:"12px"}})}createInputs(t){const e=("SS"===t?[...G].reverse():G).map((e=>this.createInputForTerminus(t,e)));return P.form(e)}createInputForTerminus(t,e){const n=this.eventBus.getTerminalModifications()[t][e],r=P.input.textArea(e,{value:n});return this.applyStylingToInput(r),r.onInput.subscribe((()=>{const n=r.value;null!==n&&this.eventBus.updateTerminusModification(t,e,n)})),r}applyStylingToInput(t){const e=t.root.getElementsByTagName("textarea")[0];L()(e).css("resize","none")}}class Bt{constructor(t,e){this.eventBus=t,this.dataManager=e}createControls(){const t=this.createAntisenseStrandToggle(),e=this.createStrandLengthInputs(),n=e.SS.root,r=e.AS.root,o=this.createSequenceBaseInput().root,i=this.createPatternCommentInput().root,s=this.createPatternNameInputBlock(),a=this.createEditPatternButton(),l=this.createEditTerminalModificationsButton();return[P.h1("Edit"),t,n,r,o,s,i,P.buttonsInput([l,a])]}createEditPatternButton(){const t=P.button("Edit strands",(()=>Ot.open(this.eventBus,this.dataManager)));return P.tooltip.bind(t,"Edit strand modifications and PTOs"),t}createEditTerminalModificationsButton(){const t=P.button("Edit terminals",(()=>Rt.open(this.eventBus)));return P.tooltip.bind(t,"Edit terminal modifications"),L()(t).css("margin-right","20px"),t}createAntisenseStrandToggle(){const t=P.input.toggle(`${H.AS} strand`,{value:this.eventBus.isAntisenseStrandActive()});return t.onInput.subscribe((()=>this.eventBus.toggleAntisenseStrand(t.value))),this.eventBus.patternLoaded$.subscribe((()=>{t.value=this.eventBus.isAntisenseStrandActive()})),t.setTooltip("Toggle antisense strand"),t.root}createStrandLengthInputs(){const t=t=>{const n=this.eventBus.getNucleotideSequences()[t].length,r=P.input.int(`${H[t]} length`,{value:n});return r.onInput.subscribe((()=>e(t,r))),this.eventBus.nucleotideSequencesChanged$.subscribe((()=>{r.value=this.eventBus.getNucleotideSequences()[t].length})),r.setTooltip(`Number of nucleotides in ${t}, including overhangs`),[t,r]},e=(t,e)=>{const n=e.value;null!==n&&(n<=0&&(r.shell.warning("Sequence length must be greater than 0"),e.value=1),n>34&&(r.shell.warning("Sequence length must be less than 35"),e.value=34),this.eventBus.updateStrandLength(t,e.value))},n=Object.fromEntries(k.map((e=>t(e))));return this.eventBus.antisenseStrandToggled$.subscribe((t=>{L()(n.AS.root).toggle(t)})),n}createSequenceBaseInput(){const t=this.dataManager.fetchAvailableNucleotideBases().sort(((t,e)=>t.toLowerCase().localeCompare(e.toLowerCase()))),e=this.dataManager.fetchDefaultNucleobase(),n=P.input.choice("Sequence basis",{value:e,items:t});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 t=P.input.textArea("Comment",{value:this.eventBus.getComment()});return L()(t.root).addClass("st-pattern-text-input"),t.onInput.subscribe((()=>this.eventBus.updateComment(t.value))),this.eventBus.patternLoaded$.subscribe((()=>{t.value=this.eventBus.getComment()})),t}createPatternNameInputBlock(){const t=P.input.textArea("Pattern name",{value:this.eventBus.getPatternName()});return L()(t.root).addClass("st-pattern-text-input"),t.onInput.subscribe((()=>this.eventBus.updatePatternName(t.value))),this.eventBus.patternLoaded$.subscribe((()=>{t.value=this.eventBus.getPatternName()})),t.setTooltip("Name under which pattern will be saved"),t.root}}class Ft{constructor(t,e){this.eventBus=t,this.dataManager=e,this.subscriptions=new Lt,this.authorSelectedByUser=!1,this.eventBus.patternLoadRequested$.subscribe((t=>this.handlePatternChoice(t))),this.eventBus.patternDeletionRequested$.subscribe((async t=>{await this.dataManager.deletePattern(t,this.eventBus)}))}async handlePatternChoice(t){let e=await this.dataManager.getPatternConfig(t);null===e&&(e=this.dataManager.getDefaultPatternConfig()),this.eventBus.setPatternConfig(e),this.eventBus.updateControlsUponPatternLoaded(t),this.eventBus.setLastLoadedPatternConfig(e)}isCurrentUserSelected(){return this.eventBus.getSelectedAuthor()!==this.dataManager.getOtherUsersAuthorshipCategory()}createControls(){const t=this.getPatternInputsContainer();return[P.h1("Load"),t]}getPatternInputsContainer(){const t=P.divH(this.createPatternInputs());return this.eventBus.patternListUpdated$.subscribe((()=>{this.subscriptions.unsubscribeAll(),L()(t).empty(),L()(t).append(this.createPatternInputs())})),t}createPatternInputs(){const t=this.createAuthorChoiceInput(),e=this.createPatternChoiceInputContainer(),n=this.createDeletePatternButton();return[t.root,e,n]}createPatternChoiceInputContainer(){const t=this.createPatternChoiceInput(),e=P.div([t.root]),n=this.eventBus.userSelection$.subscribe((()=>{L()(e).empty(),L()(e).append(this.createPatternChoiceInput().root)}));return this.subscriptions.add(n),e}createAuthorChoiceInput(){const t=[this.dataManager.getCurrentUserAuthorshipCategory()];this.dataManager.getOtherUsersPatternNames().length>0&&t.push(this.dataManager.getOtherUsersAuthorshipCategory());const e=P.input.choice("Author",{value:this.eventBus.getSelectedAuthor(),items:t});return e.onInput.subscribe((()=>{if(this.authorSelectedByUser=!0,null===e.value)throw new Error("author choice must be non-null");this.eventBus.selectAuthor(e.value)})),this.setAuthorChoiceInputStyle(e),e.setTooltip("Select pattern author"),e}setAuthorChoiceInputStyle(t){L()(t.input).css({"max-width":"100px","min-width":"100px"}),L()(t.root).css({"padding-right":"30px","padding-left":"30px"})}createPatternChoiceInput(){const t=this.isCurrentUserSelected()?this.dataManager.getCurrentUserPatternNames():this.dataManager.getOtherUsersPatternNames();if(this.authorSelectedByUser){const e=this.dataManager.getPatternHash(t[0],this.isCurrentUserSelected());this.eventBus.requestPatternLoad(e),this.eventBus.updateUrlState(e),this.authorSelectedByUser=!1}const e=this.getPatternName(t),n=P.input.choice("Pattern",{value:e,items:t});return n.setTooltip("Select pattern to load"),L()(n.input).css({"max-width":"100px","min-width":"100px"}),this.subscriptions.add(n.onInput.subscribe((()=>{const t=this.dataManager.getPatternHash(n.value,this.isCurrentUserSelected());this.eventBus.requestPatternLoad(t),this.eventBus.updateUrlState(t)}))),this.subscriptions.add(this.eventBus.patternLoaded$.subscribe((()=>{const e=this.eventBus.getPatternName();n.value!==e&&(n.value=this.getPatternName(t))}))),n}getPatternName(t){return t.find((t=>t.split(" (")[0]===this.eventBus.getPatternName()))??t[0]}createDeletePatternButton(){const t=P.button(P.iconFA("trash-alt"),(()=>{this.eventBus.getPatternName()!==this.dataManager.getDefaultPatternName()?this.showDeletePatternDialog():r.shell.warning("Cannot delete example pattern")}));P.tooltip.bind(t,"Delete pattern from user storage");const e=this.eventBus.userSelection$.subscribe((()=>{t.disabled=!this.isCurrentUserSelected()}));return this.subscriptions.add(e),t}showDeletePatternDialog(){const t=P.dialog("Delete pattern"),e=this.eventBus.getPatternName();t.add(P.divText(`Are you sure you want to delete pattern ${e}?`)),t.onOK((()=>this.eventBus.requestPatternDeletion(e))),t.show()}}class $t{constructor(t,e){this.eventBus=t,this.dataManager=e}getLayout(){const t=new Ft(this.eventBus,this.dataManager),e=new Bt(this.eventBus,this.dataManager),n=new Nt(this.eventBus),r=t.createControls(),o=e.createControls(),i=n.createControls(),s=P.div(r);L()(s).css({"padding-bottom":"20px"});const a=P.div([...o,...i],"ui-form"),l=P.div([s,a]);return L()(l).css({padding:"25px"}),P.box(l,{style:{maxWidth:"450px"}})}}var kt=n(9146);class Ht{constructor(t,e,n){this.svgElementFactory=t,this.config=e,this.yShift=n}shiftElements(t){this.svgElements.forEach((e=>{const n=e.getAttribute("transform")||"",r=`translate(${t.x},${t.y})`;e.setAttribute("transform",`${n} ${r}`)}))}}class Gt{constructor(){}static getInstance(){return Gt.instance||(Gt.instance=new Gt,Gt.instance.canvas=document.createElement("canvas")),Gt.instance}static getTextDimensions(t,e){const n=Gt.getInstance().canvas.getContext("2d");if(!n)throw new Error("Canvas 2D context is not available");return n.font=`${e}px Arial`,{width:1.1*n.measureText(t).width,height:1.1*e}}}function Ut(t){const e=Object.keys(Ar.jsonData.patternAppData)[0];if(!e)throw new Error(`No format found in '${h}'`);return Ar.jsonData.patternAppData[e][t].color||""}class Vt extends Ht{constructor(t,e,n){super(t,e,n);const r=k.filter((t=>e.nucleotideSequences[t].length>0));this.strands=r.map((t=>new jt(this.svgElementFactory,e,n,t))),this.terminalModifications=r.map(((t,r)=>new Wt(this.svgElementFactory,e,n,t,this.strands[r]))),this.labels=r.map(((t,r)=>new qt(this.svgElementFactory,e,n,t,this.terminalModifications[r])))}get svgElements(){return[...this.strands,...this.terminalModifications,...this.labels].map((t=>t.svgElements)).flat()}getContentWidth(){return Math.max(...this.labels.map((t=>t.getContentWidth())))}getContentHeight(){return this.strands.reduce(((t,e)=>t+e.getContentHeight()),0)}}class jt extends Ht{constructor(t,e,n,r){super(t,e,n),this.svgElementFactory=t,this.config=e,this.yShift=n,this.strand=r,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 t=0;return this.config.nucleotideSequences[this.strand].map((e=>rt(e)?null:(t++,t)))}get svgElements(){return this._svgElements}getStrandCircleYShift(){return zt(this.strand,this.yShift)}createStrandCircles(){const t={x:80,y:this.getStrandCircleYShift()};return this.config.nucleotideSequences[this.strand].map(((e,n)=>this.createNucleotideElementGroup(e,n,t))).flat()}createNucleotideElementGroup(t,e,n){return[...this.createNucleotideCircleElements(t,e,n),this.config.nucleotidesWithNumericLabels.includes(t)?this.createNucleotideNumericLabel(e,n):null].filter((t=>null!==t))}createNucleotideCircleElements(t,e,n){const r=Ut(t),o={...n,x:n.x+30*e};return[this.svgElementFactory.createCircleElement(o,15,r),this.createNucleotideLetterLabel(e,n,t)]}getNucleotideCircleCenterPosition(t,e){return{x:e.x+30*t,y:e.y}}createNucleotideLetterLabel(t,e,n){if(!m.AL.includes(n))return null;const r=function(t){return!rt(t)&&m.AL.includes(t)?t:""}(n),o=function(t){const e=Ut(t),n=e.match(/\d+/g)?.map(Number);if(!n||n.length<3)return"#ffffff";const[r,o,i]=n;return.299*r+.587*o+.114*i>186?"#333333":"#ffffff"}(n),i=this.getPositionForNucleotideLabel(t,e);return this.svgElementFactory.createTextElement(r,i,17,o)}getPositionForNucleotideLabel(t,e){const n=this.getNucleotideCircleCenterPosition(t,e),r=Gt.getTextDimensions("A",17);return{x:n.x-r.width/2,y:n.y+r.height/3}}getNumericLabelYShift(t){return"SS"===this.strand?t.y-20:t.y+15+5+15}createNucleotideNumericLabel(t,e){const n=this.nucleotideNumericLabels[t];if(null===n)return null;const r=Gt.getTextDimensions(n.toString(),15).width,o={x:e.x+30*t-r/2,y:this.getNumericLabelYShift(e)};return this.svgElementFactory.createTextElement(n.toString(),o,15,"var(--grey-6)")}createPTOLinkageStars(){const t=this.config.phosphorothioateLinkageFlags[this.strand],e=this.getStrandCircleYShift()+12;return t.map(((t,n)=>{if(!t)return null;const r={x:65+30*n,y:e};return this.svgElementFactory.createStarElement(r,"red")})).filter((t=>null!==t))}getContentWidth(){return 30*this.config.nucleotideSequences[this.strand].length}getContentHeight(){return 62}}class qt extends Ht{constructor(t,e,n,r,o){super(t,e,n),this.svgElementFactory=t,this.config=e,this.yShift=n,this.strand=r,this.terminalModifications=o,this._svgElements=this.createSVGElements()}createSVGElements(){return[this.createLeftLabel(),this.createRightLabel()]}getLeftLabelWidth(){return 55}getRightLabelWidth(){return 20}createLeftLabel(){const t="SS"===this.strand?"5'":"3'",e=`${this.strand}: ${t} `,n=Gt.getTextDimensions(e,17),r={x:10,y:zt(this.strand,this.yShift)+n.height/3};return this.svgElementFactory.createTextElement(e,r,17,"var(--grey-6)")}createRightLabel(){const t=" "+("SS"===this.strand?"3'":"5'"),e=Gt.getTextDimensions(t,17),n={x:65+this.terminalModifications.getContentWidth()+5,y:zt(this.strand,this.yShift)+e.height/3};return this.svgElementFactory.createTextElement(t,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 Wt extends Ht{constructor(t,e,n,r,o){super(t,e,n),this.svgElementFactory=t,this.config=e,this.yShift=n,this.strand=r,this.strandSvgWrapper=o,this._svgElements=this.createSVGElements()}createSVGElements(){return this.createTerminalModifications()}getTerminalModification(t){return this.config.strandTerminusModifications[this.strand][t]}getTerminalModificationTextDimensions(t){const e=this.getTerminalModification(t);return Gt.getTextDimensions(e,17)}getLeftTerminus(){return"SS"===this.strand?"5'":"3'"}createTerminalModification(t){const e=this.getTerminalModification(t),n=this.getTerminalModificationTextDimensions(t),r=t===this.getLeftTerminus(),o={x:r?65:65+this.getTerminalModificationTextDimensions(this.getLeftTerminus()).width+this.strandSvgWrapper.getContentWidth(),y:zt(this.strand,this.yShift)+n.height/3};return r&&this.strandSvgWrapper.shiftElements({x:n.width,y:0}),this.svgElementFactory.createTextElement(e,o,17,"red")}createTerminalModifications(){return("AS"===this.strand?G:Array.from(G).reverse()).map((t=>this.createTerminalModification(t)))}get svgElements(){return this._svgElements}getContentWidth(){return this.strandSvgWrapper.getContentWidth()+G.map((t=>this.getTerminalModificationTextDimensions(t).width)).reduce(((t,e)=>t+e),0)}getContentHeight(){return this.strandSvgWrapper.getContentHeight()}}function zt(t,e){return"SS"===t?e+5+15+15:e+52+10+15}class Yt{constructor(){this.xmlNamespace="http://www.w3.org/2000/svg"}createElement(t){return document.createElementNS(this.xmlNamespace,t)}setAttributes(t,e){Object.entries(e).forEach((([e,n])=>{t.setAttribute(e,String(n))}))}createCanvas(t,e){const n=this.createElement("svg");return this.setAttributes(n,{id:"mySvg",width:t,height:e}),n}createCircleElement(t,e,n){const r=this.createElement("circle");return this.setAttributes(r,{cx:t.x,cy:t.y,r:e,fill:n}),r}createTextElement(t,e,n,r){const o=this.createElement("text");return this.setAttributes(o,{x:e.x,y:e.y,"font-size":n,"font-weight":"normal","font-family":"Arial",fill:r}),o.textContent=t,o}createStarElement(t,e){const n=this.createElement("polygon"),r=this.computeStarVertexCoordinates(t).map((t=>t.join(","))).join(" ");return this.setAttributes(n,{points:r,fill:e}),n}computeStarVertexCoordinates(t){const e=Math.PI/5,n=-e/2;return Array.from({length:10},((r,o)=>{const i=o%2==0?6:3,s=o*e+n;return[t.x+Math.cos(s)*i,t.y+Math.sin(s)*i]}))}createRectangleElement(t,e,n,r){const o=this.createElement("rect");return this.setAttributes(o,{x:t.x,y:t.y,width:e,height:n,fill:r}),o}}class Kt extends Ht{constructor(t,e,n){super(t,e,n),this.svgElementFactory=t,this.config=e,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 Gt.getTextDimensions(this.titleText,17).width}getContentHeight(){return Gt.getTextDimensions(this.titleText,17).height}getTitleText(){const t=`${this.config.nucleotideSequences.SS.length}`,e=this.config.isAntisenseStrandIncluded?`/${this.config.nucleotideSequences.AS.length}`:"";return`${this.config.patternName} for ${t}${e}-mer`}}class Jt extends Ht{constructor(t,e,n){super(t,e,n),this._svgElements=[];const{elements:r,width:o}=this.createLegendItems();this._svgElements=r,this.width=o}isPhosphorothioatePresent(){return Object.values(this.config.phosphorothioateLinkageFlags).flat().some((t=>t))}getModificationTypesList(){return[...new Set(Object.values(this.config.nucleotideSequences).flat().sort(((t,e)=>t.toLowerCase().localeCompare(e.toLowerCase()))))]}get svgElements(){return this._svgElements}createLegendItem(t,e){const n={x:e,y:this.yShift-6},r=t.includes("linkage")?this.svgElementFactory.createStarElement(n,"red"):this.svgElementFactory.createCircleElement(n,6,Ut(t));e+=12;const o={y:this.yShift,x:e};return{elements:[r,this.svgElementFactory.createTextElement(t,o,15,"var(--grey-6)")],width:12+Gt.getTextDimensions(t,15).width}}createLegendItems(){let t=10;const e=[],n=e=>t+=e+15;if(this.isPhosphorothioatePresent()){const{elements:r,width:o}=this.createLegendItem("PTO linkage",t);n(o),e.push(r)}return this.getModificationTypesList().forEach((r=>{const{elements:o,width:i}=this.createLegendItem(r,t);n(i),e.push(o)})),{elements:e.flat(),width:t}}getContentHeight(){return 20}getContentWidth(){return this.width}}class Qt{constructor(t){this.svgElementFactory=new Yt;const e=lt().cloneDeep(t);let n=10;this.title=new Kt(this.svgElementFactory,e,n),n+=this.title.getContentHeight(),this.strands=new Vt(this.svgElementFactory,e,n),n+=this.strands.getContentHeight()+10,this.legend=new Jt(this.svgElementFactory,e,n)}renderPattern(){const t=this.getGlobalWidth(),e=this.getGlobalHeight(),n=this.svgElementFactory.createCanvas(t,e),r=[this.title,this.strands,this.legend].map((t=>t.svgElements)).flat();return n.append(...r),n}getGlobalWidth(){const t=[this.title,this.strands,this.legend];return Math.max(...t.map((t=>t.getContentWidth())))}getGlobalHeight(){return[this.title,this.strands,this.legend].reduce(((t,e)=>t+e.getContentHeight()),10)}}class Xt{constructor(t){this.eventBus=t,this.svgDisplayDiv=P.div([]),t.updateSvgContainer$.subscribe((()=>this.updateSvgContainer())),t.svgSaveRequested$.subscribe((()=>this.saveSvgAsPng()))}static createSvgDiv(t){return new Xt(t).svgDisplayDiv}updateSvgContainer(){$(this.svgDisplayDiv).empty();const t=this.eventBus.getPatternConfig();this.svgElement=this.createSvg(t),this.svgDisplayDiv.append(this.svgElement)}createSvg(t){return new Qt(t).renderPattern()}saveSvgAsPng(){const t=this.eventBus.getPatternName();kt.saveSvgAsPng(this.svgElement,t,{backgroundColor:"white"})}}class Zt{constructor(t){this.eventBus=t,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 t=this.eventBus.getUniqueNucleotides().filter((t=>!rt(t))).map((t=>this.createSingleInput(t)));return t.sort(((t,e)=>t.captionLabel.textContent.localeCompare(e.captionLabel.textContent))),P.divH(t.map((t=>t.root)))}createSingleInput(t){const e=this.eventBus.getModificationsWithNumericLabels().includes(t),n=P.input.bool(t,{value:e,onValueChanged:e=>this.handleNumericLabelToggle(t,e)});return L()(n.root).css("padding-right","20px"),n.setTooltip(`Show numeric labels for ${t}`),n}handleNumericLabelToggle(t,e){const n=this.eventBus.getModificationsWithNumericLabels();if(n.includes(t)===e)return;const r=e?n.concat(t):n.filter((e=>e!==t));this.eventBus.updateModificationsWithNumericLabels(r)}}class te{constructor(t,e){this.eventBus=t,this.dataManager=e,this.subscriptions=new Lt}createContainer(){return P.div([P.h1("Translation example"),this.createTranslationExamples()],{style:{paddingTop:"20px"}})}createTranslationExamples(){const t=P.divH([...this.getExampleElements()],"ui-form");return this.eventBus.antisenseStrandToggled$.subscribe((()=>{this.subscriptions.unsubscribeAll(),L()(t).empty(),L()(t).append(this.getExampleElements())})),t}getExampleElements(){return k.map((t=>new ee(t,this.eventBus,this.subscriptions).create()))}}class ee{constructor(t,e,n){this.strand=t,this.eventBus=e,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 t=this.eventBus.strandsLinkagesAndTerminalsUpdated$.subscribe((()=>{const t=this.generateExampleSequence();this.inputExample.value=t,this.outputExample.value=this.computeOutputValue(t)}));"AS"===this.strand&&this.subscriptions.add(t)}createInputExample(){const t=this.createTextInputForExamples(),e=this.generateExampleSequence();return t.value=e,t.setTooltip(`Example raw nucleotides input for ${H[this.strand]}`),t}generateExampleSequence(){return this.eventBus.getNucleotideSequences()[this.strand].map(((t,e)=>m.AL[e%m.AL.length])).join("")}createOutputExample(t){const e=this.createTextInputForExamples();return e.value=this.computeOutputValue(t),e.setTooltip(`Pattern applied to the example input for ${H[this.strand]}`),e}computeOutputValue(t){const e=this.eventBus.getNucleotideSequences()[this.strand],n=this.eventBus.getTerminalModifications()[this.strand];return _t(t,e,this.eventBus.getPhosphorothioateLinkageFlags()[this.strand],n)}createTextInputForExamples(){const t=P.input.textArea("",{value:""});return this.applyStylingToInput(t),t}applyStylingToInput(t){const e=t.root.getElementsByTagName("textarea")[0];e.setAttribute("readonly","true"),L()(e).css("resize","none"),L()(t.root).css("opacity","75%")}}class ne{constructor(t,e){this.eventBus=t,this.dataManager=e,this.svgDisplay=Xt.createSvgDiv(t)}getLayout(){const t=new Zt(this.eventBus).getContainer(),e=this.generateDownloadControls(),n=new te(this.eventBus,this.dataManager).createContainer();return P.panel([this.svgDisplay,t,e,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 t=P.button("Get PNG",(()=>this.eventBus.requestSvgSave()));return P.tooltip.bind(t,"Download pattern as PNG"),t}createInfoButton(){const t=P.button(P.iconFA("info-circle"),(()=>this.openInfoDialog()));return this.eventBus.patternHasUnsavedChanges$.subscribe((e=>{t.disabled=e})),P.tooltip.bind(t,"View pattern metadata"),t}async openInfoDialog(){let t=this.dataManager.getCurrentUserName(),e=this.dataManager.getDefaultPatternName(),n=K,o=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(t=(await r.dapi.users.find(i)).friendlyName,e=s[q.PATTERN_CONFIG][j.PATTERN_NAME],void 0!==s[q.DATE]){const t=s[q.DATE][W.CREATE];void 0!==t&&(n=t);const e=s[q.DATE][W.MODIFY];void 0!==e&&(o=e)}}}const s=P.divV([P.divText(`Pattern Name: ${e}`),P.divText(`Author: ${t}`),P.divText(`Created: ${oe(new Date(n))}`),P.divText(`Modified: ${oe(new Date(o))}`)]);r.shell.info(s)}createShareLinkButton(){const t=P.button(P.iconFA("link"),(()=>navigator.clipboard.writeText(window.location.href).then((()=>r.shell.info("Link to pattern copied to clipboard")))));return this.eventBus.patternHasUnsavedChanges$.subscribe((e=>{t.disabled=e})),P.tooltip.bind(t,"Share pattern link"),t}createSavePatternButton(){const t=P.button("Save",(()=>this.processSaveButtonClick()));return this.eventBus.patternHasUnsavedChanges$.subscribe((e=>{t.disabled=!e})),P.tooltip.bind(t,"Save pattern to user storage"),t}processSaveButtonClick(){const t=this.eventBus.getPatternName();t!==this.dataManager.getDefaultPatternName()?""!==t?this.dataManager.savePatternToUserStorage(this.eventBus).then((()=>{r.shell.info(`Pattern ${t} saved`)})).catch((t=>this.handleErrorWhileSavingPattern(t))):r.shell.warning("Insert pattern name"):r.shell.warning("Cannot save default pattern")}handleErrorWhileSavingPattern(t){t instanceof J?new re(this.eventBus,this.dataManager).show():t instanceof Q?r.shell.warning(P.div([P.divText("Pattern already exists"),P.button("Load",(()=>{const e=t.message;this.eventBus.requestLoadPatternInNewTab(e)}))])):console.error("Error while saving pattern",t)}}class re{constructor(t,e){this.eventBus=t,this.dataManager=e}show(){const t=this.eventBus.getPatternName(),e=P.dialog(`Pattern "${t}" already exists`);e.add(P.divText(`Pattern "${t}" already exists. Do you want to overwrite it?`)),e.show(),e.onOK((()=>this.processOverwriteNamesakePattern()))}processOverwriteNamesakePattern(){const t=this.eventBus.getPatternName();this.dataManager.overwriteExistingPatternInUserStorage(this.eventBus).then((()=>{r.shell.info(`Pattern ${t} overwritten`)})).catch((t=>{console.error("Error while overwriting pattern in user storage",t),r.shell.error("Error while overwriting pattern")}))}}function oe(t){return t.toLocaleString().split(":").slice(0,-1).join(":")}class ie extends F{constructor(t){super("Oligo Pattern"),this.th=t}getContent(){return async function(){const t=await tt.getInstance(),e=new ht,n=await async function(t,e){const n=e.getPatternHash();if(!n)return e.clearPatternURL(),t.getDefaultPatternRecord();let r=await t.getPatternRecordByHash(n);return r||(e.clearPatternURL(),r=t.getDefaultPatternRecord()),r}(t,e),r=new ut(t,n);e.subscribeToObservables(r);const o=new $t(r,t).getLayout(),i=new ne(r,t).getLayout();return P.splitH([o,i],{},!0)}()}}var se=n(8507),ae={};function le(t){var e;return"string"==typeof t||t instanceof String?t:("object"==typeof t||t instanceof Object)&&"$thrownJsError"in t?le(t.$thrownJsError):t instanceof Error?null!==(e=t.stack)&&void 0!==e?e:t.message:t.toString()}ae.styleTagTransform=xt(),ae.setAttributes=vt(),ae.insert=yt().bind(null,"head"),ae.domAPI=mt(),ae.insertStyleElement=wt(),ft()(se.A,ae),se.A&&se.A.locals&&se.A.locals;var ue,ce=n(2074),he={};he.styleTagTransform=xt(),he.setAttributes=vt(),he.insert=yt().bind(null,"head"),he.domAPI=mt(),he.insertStyleElement=wt(),ft()(ce.A,he),ce.A&&ce.A.locals&&ce.A.locals;class de{constructor(t,e,n=!0){this.textInputBase=t,this.painter=e,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 t=this.painter(this.textInputBase.value);this.highlights.innerHTML="",t.forEach((t=>this.highlights.appendChild(t)))}}!function(t){t.TYPE="V2000",t[t.NUM_OF_HEADER_LINES=3]="NUM_OF_HEADER_LINES",t[t.NUM_OF_COUNTS_DIGITS=3]="NUM_OF_COUNTS_DIGITS",t[t.ATOM_TYPE_COL=4]="ATOM_TYPE_COL",t[t.FIRST_BONDED_ATOM_COL=1]="FIRST_BONDED_ATOM_COL",t[t.BOND_TYPE_COL=3]="BOND_TYPE_COL",t[t.RGP_SHIFT=8]="RGP_SHIFT",t[t.MAX_ATOM_COUNT=999]="MAX_ATOM_COUNT",t.RGP_LINE_START="M RGP",t.ATOM_ALIAS_LINE_START="A ",t.END="M END"}(ue||(ue={}));class fe{constructor(t){this.init(t)}init(t){this.fileContent=t.replace(/\r/g,""),this._atomCount=void 0,this._atomTypes=void 0,this._bondCount=void 0,this._bondTypes=void 0,this.xyzAtomCoordinates=void 0,this._pairsOfBondedAtoms=void 0}get atomCount(){return void 0===this._atomCount&&this.setAtomAndBondCounts(),this._atomCount}get bondCount(){return void 0===this._bondCount&&this.setAtomAndBondCounts(),this._bondCount}get x(){var t;return null!==(t=this.xyzAtomCoordinates)&&void 0!==t||(this.xyzAtomCoordinates=this.parseAtomCoordinates()),this.xyzAtomCoordinates.x}get y(){var t;return null!==(t=this.xyzAtomCoordinates)&&void 0!==t||(this.xyzAtomCoordinates=this.parseAtomCoordinates()),this.xyzAtomCoordinates.y}get z(){var t;return null!==(t=this.xyzAtomCoordinates)&&void 0!==t||(this.xyzAtomCoordinates=this.parseAtomCoordinates()),this.xyzAtomCoordinates.z}get atomTypes(){var t;return null!==(t=this._atomTypes)&&void 0!==t||(this._atomTypes=this.parseAtomTypes()),this._atomTypes}get pairsOfBondedAtoms(){var t;return null!==(t=this._pairsOfBondedAtoms)&&void 0!==t||(this._pairsOfBondedAtoms=this.parseBondedAtomPairs()),this._pairsOfBondedAtoms}get bondTypes(){var t;return null!==(t=this._bondTypes)&&void 0!==t||(this._bondTypes=this.parseBondTypes()),this._bondTypes}setAtomAndBondCounts(){const{atomCount:t,bondCount:e}=this.parseAtomAndBondCounts();this._atomCount=t,this._bondCount=e}getNextColumnIdx(t){for(;!this.isWhitespace(t);)++t;for(;this.isWhitespace(t);)++t;return t}shiftIdxToSpecifiedColumn(t,e){let n=t;const r=this.isWhitespace(n)?e:e-1;for(let t=0;t<r;t++)n=this.getNextColumnIdx(n);return n}parseAtomTypes(){const t=this.atomCount,e=new Array(t);let n=this.getAtomBlockIdx();for(let r=0;r<t;r++)n=this.shiftIdxToAtomType(n),e[r]=this.parseAtomType(n),n=this.getNextLineIdx(n);return e}parseAtomCoordinates(){const t=new Float32Array(this.atomCount),e=new Float32Array(this.atomCount),n=new Float32Array(this.atomCount);let r=this.getAtomBlockIdx();for(let o=0;o<this.atomCount;o++){r=this.shiftIdxToXColumn(r);for(const i of[t,e,n])i[o]=this.parseFloatValue(r),r=this.getNextColumnIdx(r);r=this.getNextLineIdx(r)}return{x:t,y:e,z:n}}parseBondedAtomPairs(){const t=new Array(this.bondCount);let e=this.getBondBlockIdx();for(let n=0;n<this.bondCount;n++){e=this.shiftIdxToBondedAtomsPair(e);const r=new Uint16Array(2);r[0]=this.parseIntValue(e),e=this.getNextColumnIdx(e),r[1]=this.parseIntValue(e),t[n]=r,e=this.getNextLineIdx(e)}return t}parseBondTypes(){const t=this.bondCount,e=new Uint16Array(t);let n=this.getBondBlockIdx();for(let r=0;r<t;r++)n=this.shiftIdxToBondType(n),e[r]=this.parseIntValue(n),n=this.getNextLineIdx(n);return e}isWhitespace(t){const e=this.fileContent[t];return" "===e||"\t"===e}getNextLineIdx(t){return"\n"!==this.fileContent[t]?this.fileContent.indexOf("\n",t)+1:t+1}parseFloatValue(t){return this.parseNumericValue(parseFloat,t)}parseIntValue(t){return this.parseNumericValue(parseInt,t)}parseNumericValue(t,e){let n=e+1;for(;!this.isWhitespace(n);)++n;return t(this.fileContent.substring(e,n))}}class pe extends fe{constructor(t){super(t),this.init(t)}init(t){super.init(t)}parseAtomType(t){let e=t,n=e;return this.isQuote(e)?(n=this.getNextIdenticalChar(e),e++):n=this.fileContent.indexOf(" ",n),this.fileContent.substring(e,n)}isQuote(t){const e=this.fileContent[t].charCodeAt(0);return 39===e||34===e}getNextIdenticalChar(t){const e=this.fileContent[t];return e?this.fileContent.indexOf(e,t+1):-1}isQuery(){return this.isQueryOrFragment(((t,e)=>{return 39===t||34===t||76===t&&!((n=this.fileContent.charCodeAt(e+1))>64&&n<91||n>96&&n<123);var n}))}isFragment(){return this.isQueryOrFragment((t=>82===t||42===t))}isQueryOrFragment(t){const e=this.atomCount;let n=this.getAtomBlockIdx();for(let r=0;r<e;r++){if(n=this.shiftIdxToAtomType(n),t(this.fileContent.charCodeAt(n),n))return!0;n=this.getNextLineIdx(n)}return!1}}class me extends pe{constructor(t){super(t)}getAtomLines(){const t=this.getAtomBlockIdx(),e=this.getBondBlockIdx();return this.fileContent.substring(t,e).split("\n").slice(0,this.atomCount)}getBondLines(){const t=this.getBondBlockIdx();return this.fileContent.substring(t).split("\n").slice(0,this.bondCount)}getRGroupIdToAtomicIdxMap(){const t=new Map,e=this.fileContent.split("\n");e.filter((t=>t.startsWith(ue.RGP_LINE_START))).forEach((e=>{const n=this.getAtomIdxToRgpIdxList(e);for(const[e,r]of n){if(t.has(e))throw new Error(`R group ${e} is already in the map`);t.set(e,r)}}));const n=e.map(((t,e)=>{if(t.startsWith(ue.ATOM_ALIAS_LINE_START))return e})).filter((t=>void 0!==t)),r=n.map((t=>e[t])),o=n.map((t=>e[t+1]));r.forEach(((e,n)=>{const r=parseInt(e.split(/\s+/)[1])-1,i=parseInt(o[n].substring(1));if(t.has(i))throw new Error(`R group ${i} is already in the map`);t.set(i,r)}));const i=this.getRGroupAtomicIndices().filter((e=>!Array.from(t.values()).includes(e)));if(0!==i.length)throw new Error(`Unaccounted R group indices: ${i}`);return t}getAtomIdxToRgpIdxList(t){const e=t.split(/\s+/).filter((t=>t)).slice(3).map((t=>parseInt(t))),n=new Array(e.length/2);for(let t=0;t<e.length;t+=2)n[t/2]=[e[t+1],e[t]-1];return n}getRGroupAtomicIndices(){return this.atomTypes.map(((t,e)=>{if(t.includes("R#"))return e})).filter((t=>void 0!==t))}static isValidMolfile(t){return-1!==t.indexOf(ue.TYPE)&&-1!==t.indexOf(ue.END)}shiftIdxToAtomType(t){return this.shiftIdxToSpecifiedColumn(t,ue.ATOM_TYPE_COL)}getCountsLineIdx(){let t=0;for(let e=0;e<ue.NUM_OF_HEADER_LINES;++e)t=this.getNextLineIdx(t);return t}getAtomBlockIdx(){let t=this.getCountsLineIdx();return t=this.getNextLineIdx(t),t}shiftIdxToXColumn(t){return this.getNextColumnIdx(t)}shiftIdxToBondedAtomsPair(t){return this.shiftIdxToSpecifiedColumn(t,ue.FIRST_BONDED_ATOM_COL)}shiftIdxToBondType(t){return this.shiftIdxToSpecifiedColumn(t,ue.BOND_TYPE_COL)}getBondBlockIdx(){let t=this.getAtomBlockIdx();for(let e=0;e<this.atomCount;e++)t=this.getNextLineIdx(t);return t}parseAtomAndBondCounts(){let t=this.getCountsLineIdx(),e=t+ue.NUM_OF_COUNTS_DIGITS;const n=parseInt(this.fileContent.substring(t,e));return t=e,e+=ue.NUM_OF_COUNTS_DIGITS,{atomCount:n,bondCount:parseInt(this.fileContent.substring(t,e))}}}class ge extends pe{constructor(t){super(t),this.init(t)}getAtomLines(){const t=this.getAtomBlockIdx(),e=this.getBondBlockIdx();return this.fileContent.substring(t,e).split("\n").slice(0,this.atomCount)}getBondLines(){const t=this.getBondBlockIdx();return this.fileContent.substring(t).split("\n").slice(0,this.bondCount)}getRGroupIdToAtomicIdxMap(){const t=new Map;return this.getAtomLines().forEach(((e,n)=>{const r=e.match(/RGROUPS=\(([\d\s]+)\)/);if(r){const e=r[1].split(/\s+/).map((t=>parseInt(t)));if(e.length>2)throw new Error(`R group data ${e} has more than 2 elements`);const o=e[1];if(t.has(o))throw new Error(`R group ${o} is already in the map`);t.set(o,n)}})),t}shiftIdxToAtomType(t){return this.shiftIdxToSpecifiedColumn(t,4)}getCountsLineIdx(){return this.fileContent.indexOf("M V30 COUNTS ")}getAtomBlockIdx(){let t=this.fileContent.indexOf("M V30 BEGIN ATOM");return t=this.getNextLineIdx(t),t}shiftIdxToXColumn(t){let e=this.shiftIdxToAtomType(t);return this.isQuote(e)?(e=this.getNextIdenticalChar(e),e=this.getNextColumnIdx(e),e):this.shiftIdxToSpecifiedColumn(t,5)}shiftIdxToBondedAtomsPair(t){return this.shiftIdxToSpecifiedColumn(t,5)}shiftIdxToBondType(t){return this.shiftIdxToSpecifiedColumn(t,4)}getBondBlockIdx(){return this.getNextLineIdx(this.fileContent.indexOf("M V30 BEGIN BOND"))}static isValidMolfile(t){return-1!==t.indexOf("V3000")&&-1!==t.indexOf("M END")}parseAtomAndBondCounts(){let t=this.fileContent.indexOf("M V30 COUNTS ")+14,e=this.fileContent.indexOf(" ",t+1);const n=parseInt(this.fileContent.substring(t,e));return t=e+1,e=this.fileContent.indexOf(" ",t+1),{atomCount:n,bondCount:parseInt(this.fileContent.substring(t,e))}}}class ye{constructor(){}static getInstance(t){if(ye.isMolfileV2K(t))return new me(t);if(ye.isMolfileV3K(t))return new ge(t);throw new Error("Malformed molfile")}static isMolfileV2K(t){return me.isValidMolfile(t)}static isMolfileV3K(t){return ge.isValidMolfile(t)}}const be=class extends Error{constructor(t){super(t)}};class ve{constructor(t){this.molblock=t}get molblock(){return this._validMolBlock}set molblock(t){if(""!==t){try{this.validateMolBlock(t)}catch(e){e instanceof be&&(t="");const n=le(e);console.error(n)}this._validMolBlock=t}else this._validMolBlock=t}validateMolBlock(t){if(""===t)throw new be("MoleculeImage: invalid molblock")}async drawMolBlockOnCanvas(t){try{await r.functions.call("Chem:canvasMol",{x:0,y:0,w:t.width,h:t.height,canvas:t,molString:this.molblock,scaffoldMolString:"",options:{normalizeDepiction:!1,straightenDepiction:!1}})}catch(t){const e=le(t);console.error(e)}}getMoleculeDimensions(){const t=ye.getInstance(this.molblock),e=Math.max(...t.x)-Math.min(...t.x);return{height:Math.max(...t.y)-Math.min(...t.y),width:e}}async zoomIn(){const t=P.dialog({title:"Molecule",showFooter:!1}),e=.7*L()(window).height(),n=this.getMoleculeDimensions(),r=e/n.height,o=e,i=n.width*r,s=P.canvas(i,o);await this.drawMolBlockOnCanvas(s);const a=P.block([s],{style:{overflowX:"scroll"}});t.add(a).showModal(!0),L()(t.root).find(".d4-dialog-contents").removeClass("ui-form"),L()(t.root).find(".d4-dialog-contents").removeClass("ui-panel"),L()(t.root).find(".d4-dialog-contents").addClass("ui-box"),L()(t.root).find(".d4-dialog-contents").css("padding","0")}async drawMolecule(t,e,n){t.innerHTML="";const r=P.canvas(e*window.devicePixelRatio,n*window.devicePixelRatio);r.style.width=`${e}px`,r.style.height=`${n}px`,r.style.cursor="zoom-in",this.drawMolBlockOnCanvas(r),r.addEventListener("click",(async()=>{await this.zoomIn()})),t.append(P.tooltip.bind(r,"Click to zoom"))}}class Ce extends Error{constructor(t,e){super(t,e)}}class we{constructor(t,e){this.sequence=t,this.codeMap=e}parseSequence(){const t=this.parseRawSequence();return this.addLinkers(t)}addLinkers(t){const e=[];return t.forEach(((n,r)=>{const o=this.getSymbolForCode(n);r>0&&function(t){return Ar.jsonData.monomersWithPhosphate.left.includes(t)}(o)&&e.pop(),e.push(o);const i=Ae(o),s=r===t.length-1,a=r+1<t.length&&Ae(this.getSymbolForCode(t[r+1]));i||function(t){return Ar.jsonData.monomersWithPhosphate.right.includes(t)}(o)||a||s||e.push("p")})),e}getSymbolForCode(t){let e=this.codeMap.get(t);return e??(e=t),e}parseRawSequence(){const t=this.getAllCodesOfFormat(),e=[];let n=0;for(;n<this.sequence.length;){const r=t.find((t=>t===this.sequence.substring(n,n+t.length)));if(void 0===r)throw new Ce(`Unable to match a monomer for the rest of the sequence '${this.sequence.slice(n)}'.`);e.push(r),n+=r.length}return e}getAllCodesOfFormat(){return g(Array.from(this.codeMap.keys()))}}function Ae(t){return Ar.jsonData.monomersWithPhosphate.phosphate.includes(t)}class xe{constructor(t,e=!1,n){this.invert=e,this.lib=Ar.monomerLibWrapper;const r=this.lib.getCodeToSymbolMap(n);this.parser=new we(t,r)}convert(){const t=this.parser.parseSequence(),e=[];t.forEach(((t,n)=>{const r=this.getMonomerMolfile(t,n);e.push(r)}));let n=this.getPolymerMolfile(e);return this.invert&&(n=this.reflect(n),n=this.invertBondConfiguration(n)),n}invertBondConfiguration(t){const e=t.indexOf("M V30 BEGIN BOND"),n=t.indexOf("M V30 END BOND");let r=t.substring(e,n);return r=r.replace(/(CFG=)([13])/g,((t,e,n)=>"1"===n?`${e}3`:"3"===n?`${e}1`:t)),t.substring(0,e)+r+t.substring(n)}getMonomerMolfile(t,e){const n=this.lib.getMolfileBySymbol(t);return this.lib.isModification(t)?0===e?this.reflect(n):n:this.rotateNucleotidesV3000(n)}getPolymerMolfile(t){return this.linkV3000(t)}reflect(t){const e=this.extractAtomDataV3000(t),n=e.atomIndex.length,r=e.atomIndex.indexOf(1),o=e.atomIndex.indexOf(n),i=(e.x[o]+e.x[r])/2,s=(e.y[o]+e.y[r])/2;for(let t=0;t<n;t++)e.x[t]-=i,e.y[t]-=s;for(let t=0;t<n;t++)e.x[t]=-e.x[t];const a=e.x[r];for(let t=0;t<n;t++)e.x[t]-=a;let l=t.indexOf("M V30 BEGIN ATOM");l=t.indexOf("\n",l);let u=l;for(let r=0;r<n;r++)l=t.indexOf("V30",l)+4,l=t.indexOf(" ",l)+1,l=t.indexOf(" ",l)+1,u=t.indexOf(" ",l)+1,u=t.indexOf(" ",u),l=(t=t.slice(0,l)+e.x[r]+" "+e.y[r]+t.slice(u)).indexOf("\n",l)+1;return t}extractAtomDataV3000(t){const e=this.extractAtomsBondsNumbersV3000(t);let n=t.indexOf("M V30 BEGIN ATOM");n=t.indexOf("\n",n);let r=n;const o=Array(e.natom),i=Array(e.natom),s=Array(e.natom),a=Array(e.natom);for(let l=0;l<e.natom;l++)n=t.indexOf("V30",n)+4,r=t.indexOf(" ",n),o[l]=parseInt(t.substring(n,r)),n=r+1,r=t.indexOf(" ",n),i[l]=t.substring(n,r),n=r+1,r=t.indexOf(" ",n),s[l]=parseFloat(t.substring(n,r)),n=r+1,r=t.indexOf(" ",n),a[l]=parseFloat(t.substring(n,r)),n=t.indexOf("\n",n)+1;return{atomIndex:o,atomType:i,x:s,y:a}}extractAtomsBondsNumbersV3000(t){let e=(t=t.replaceAll("\r","")).indexOf("COUNTS")+7,n=t.indexOf(" ",e);const r=parseInt(t.substring(e,n));return e=n+1,n=t.indexOf(" ",e),{natom:r,nbond:parseInt(t.substring(e,n))}}rotateNucleotidesV3000(t){const e=this.extractAtomDataV3000(t),n=e.atomIndex.length,r=e.atomIndex.indexOf(1),o=e.atomIndex.indexOf(n);n>8&&this.fix5Prime(e,r,o);const i=(e.x[o]+e.x[r])/2,s=(e.y[o]+e.y[r])/2;for(let t=0;t<n;t++)e.x[t]-=i,e.y[t]-=s;let a=0;if(0===e.x[r])a=e.y[r]>e.y[o]?Math.PI/2:3*Math.PI/2;else if(0===e.y[r])a=e.x[r]>e.x[o]?Math.PI:0;else{const t=e.y[r]/e.x[r];a=t>0?e.x[r]>0?Math.PI-Math.atan(t):2*Math.PI-Math.atan(t):e.x[r]>0?-Math.PI-Math.atan(t):Math.atan(t)}const l=Math.cos(a),u=Math.sin(a);for(let t=0;t<n;t++){const n=e.x[t];e.x[t]=n*l-e.y[t]*u,e.y[t]=n*u+e.y[t]*l}const c=e.x[r];for(let t=0;t<n;t++)e.x[t]-=c;let h=t.indexOf("M V30 BEGIN ATOM");h=t.indexOf("\n",h);let d=h;for(let r=0;r<n;r++)h=t.indexOf("V30",h)+4,h=t.indexOf(" ",h)+1,h=t.indexOf(" ",h)+1,d=t.indexOf(" ",h)+1,d=t.indexOf(" ",d),h=(t=t.slice(0,h)+e.x[r]+" "+e.y[r]+t.slice(d)).indexOf("\n",h)+1;return t}linkV3000(t,e=!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 r="",o="",i="";const s=[];let a=0,l=0,u=0;for(let e=0;e<t.length;e++){const n=t[e].includes("MODIFICATION")&&0===e;let i=0;n&&(i=this.extractAtomDataV3000(t[e]).atomIndex.length),t[e]=t[e].replaceAll("(-\nM V30 ","(").replaceAll("-\nM V30 ","").replaceAll(" )",")");const c=this.extractAtomsBondsNumbersV3000(t[e]),h=this.extractAtomDataV3000(t[e]);let d=t[e].indexOf("M V30 BEGIN ATOM");d=t[e].indexOf("\n",d);let f=d,p=d;for(let r=0;r<c.natom;r++)if(1!==h.atomIndex[r]||0===e){f=t[e].indexOf("V30",f)+4,p=t[e].indexOf(" ",f);let r=0;n?(r=parseInt(t[e].substring(f,p)),1===r?r=i:r===i&&(r=1),r+=a):r=parseInt(t[e].substring(f,p))+a,t[e]=t[e].slice(0,f)+r+t[e].slice(p),f=t[e].indexOf(" ",f)+1,f=t[e].indexOf(" ",f)+1,p=t[e].indexOf(" ",f);const o=u-h.x[0];let s=Math.round(1e4*(parseFloat(t[e].substring(f,p))+o))/1e4;t[e]=t[e].slice(0,f)+s+t[e].slice(p),f=t[e].indexOf(" ",f)+1,p=t[e].indexOf(" ",f),s=Math.round(1e4*parseFloat(t[e].substring(f,p)))/1e4,t[e]=t[e].slice(0,f)+s+t[e].slice(p),f=t[e].indexOf("\n",f)+1}else f=t[e].indexOf("M V30",f)-1,p=t[e].indexOf("\n",f+1),t[e]=t[e].slice(0,f)+t[e].slice(p);const m=t[e].indexOf("M V30 END ATOM");r+=t[e].substring(d+1,m);let g=t[e].indexOf("M V30 BEGIN BOND");g=t[e].indexOf("\n",g),f=g,p=g;for(let r=0;r<c.nbond;r++){f=t[e].indexOf("V30",f)+4,p=t[e].indexOf(" ",f);const r=parseInt(t[e].substring(f,p))+l;t[e]=t[e].slice(0,f)+r+t[e].slice(p),f=t[e].indexOf(" ",f)+1,f=t[e].indexOf(" ",f)+1,p=t[e].indexOf(" ",f);let o=0;n?(o=parseInt(t[e].substring(f,p)),1===o?o=i:o===i&&(o=1),o+=a):o=parseInt(t[e].substring(f,p))+a,t[e]=t[e].slice(0,f)+o+t[e].slice(p),f=t[e].indexOf(" ",f)+1,p=Math.min(t[e].indexOf("\n",f),t[e].indexOf(" ",f)),o=0,n?(o=parseInt(t[e].substring(f,p)),1===o?o=i:o===i&&(o=1),o+=a):o=parseInt(t[e].substring(f,p))+a,t[e]=t[e].slice(0,f)+o+t[e].slice(p),f=t[e].indexOf("\n",f)+1}const y=t[e].indexOf("M V30 END BOND");o+=t[e].substring(g+1,y);let b=t[e].indexOf("M V30 MDLV30/STEABS ATOMS=(");for(;-1!==b;){b+=28;const n=t[e].indexOf(")",b);t[e].substring(b,n).split(" ").slice(1).forEach((t=>{s.push(parseInt(t)+a)})),b=n,b=t[e].indexOf("M V30 MDLV30/STEABS ATOMS=(",b)}a+=c.natom-1,l+=c.nbond,u+=n?Math.max(...h.x):h.x[c.natom-1]-h.x[0]}const c=Math.ceil(s.length/4);i+="M V30 MDLV30/STEABS ATOMS=("+s.length+" -\n";for(let t=0;t<c;t++){i+="M V30 ";const e=t+1===c?s.length-4*(c-1):4;for(let n=0;n<e;n++)i+=n+1===e?t===c-1?s[4*t+n]+")\n":s[4*t+n]+" -\n":s[4*t+n]+" "}return a++,n+="M V30 COUNTS "+a+" "+l+" 0 0 0\n",n+="M V30 BEGIN ATOM\n",n+=r,n+="M V30 END ATOM\n",n+="M V30 BEGIN BOND\n",n+=o,n+="M V30 END BOND\n",e&&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(t,e,n){const r=e+1,o=t.x[r],i=t.y[r],s=t.x[n]-o,a=t.y[n]-i,l=t.x[e]-o,u=t.y[e]-i,c=l*Math.cos(2*Math.PI/3)-u*Math.sin(2*Math.PI/3),h=l*Math.sin(2*Math.PI/3)+u*Math.cos(2*Math.PI/3),d=l-s,f=u-a,p=c-s,m=h-a;Math.sqrt(m*m+p*p)>=Math.sqrt(f*f+d*d)&&(t.x[e]=c+o,t.y[e]=h+i)}}function Ee(t,e=!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 r="",o="",i="";const s=[];let a=0,l=0,u=0;if(t.antiStrands.length>0)for(let e=0;e<t.antiStrands.length;e++)t.antiStrands[e]=Te(t.antiStrands[e]);let c=!1;const h=t.senseStrands.concat(t.antiStrands);let d=0;for(let e=0;e<h.length;e++){h[e]=h[e].replaceAll("(-\nM V30 ","(").replaceAll("-\nM V30 ","").replaceAll(" )",")");const n=Se(h[e]),i=Ie(h[e]);if(e>=t.senseStrands.length?!1===c&&(c=!0,u=0):d=Math.min(d,Math.min(...i.y.filter((t=>t<0)))),c){const t=Math.min(...i.x)-u,e=Math.max(...i.y)+5;for(let e=0;e<i.x.length;e++)i.x[e]-=t;for(let t=0;t<i.y.length;t++)i.y[t]-=e-d}let f=h[e].indexOf("M V30 BEGIN ATOM");f=h[e].indexOf("\n",f);let p=f,m=f;for(let t=0;t<n.natom;t++){p=h[e].indexOf("V30",p)+4,m=h[e].indexOf(" ",p);const n=parseInt(h[e].substring(p,m))+a;h[e]=h[e].slice(0,p)+n+h[e].slice(m),p=h[e].indexOf(" ",p)+1,p=h[e].indexOf(" ",p)+1,m=h[e].indexOf(" ",p);let r=Math.round(1e4*i.x[t])/1e4;h[e]=h[e].slice(0,p)+r+h[e].slice(m),p=h[e].indexOf(" ",p)+1,m=h[e].indexOf(" ",p),r=Math.round(1e4*i.y[t])/1e4,h[e]=h[e].slice(0,p)+r+h[e].slice(m),p=h[e].indexOf("\n",p)+1}const g=h[e].indexOf("M V30 END ATOM");r+=h[e].substring(f+1,g);let y=h[e].indexOf("M V30 BEGIN BOND");y=h[e].indexOf("\n",y),p=y,m=y;for(let t=0;t<n.nbond;t++){p=h[e].indexOf("V30",p)+4,m=h[e].indexOf(" ",p);const t=parseInt(h[e].substring(p,m))+l;h[e]=h[e].slice(0,p)+t+h[e].slice(m),p=h[e].indexOf(" ",p)+1,p=h[e].indexOf(" ",p)+1,m=h[e].indexOf(" ",p);let n=parseInt(h[e].substring(p,m))+a;h[e]=h[e].slice(0,p)+n+h[e].slice(m),p=h[e].indexOf(" ",p)+1,m=Math.min(h[e].indexOf("\n",p),h[e].indexOf(" ",p)),n=parseInt(h[e].substring(p,m))+a,h[e]=h[e].slice(0,p)+n+h[e].slice(m),p=h[e].indexOf("\n",p)+1}const b=h[e].indexOf("M V30 END BOND");o+=h[e].substring(y+1,b);let v=h[e].indexOf("M V30 MDLV30/STEABS ATOMS=(");for(;-1!==v;){v+=28;const t=h[e].indexOf(")",v);h[e].substring(v,t).split(" ").slice(1).forEach((t=>{s.push(parseInt(t)+a)})),v=t,v=h[e].indexOf("M V30 MDLV30/STEABS ATOMS=(",v)}a+=n.natom,l+=n.nbond,u+=Math.max(...i.x)+5}const f=Math.ceil(s.length/4);i+="M V30 MDLV30/STEABS ATOMS=("+s.length+" -\n";for(let t=0;t<f;t++){i+="M V30 ";const e=t+1===f?s.length-4*(f-1):4;for(let n=0;n<e;n++)i+=n+1===e?t===f-1?s[4*t+n]+")\n":s[4*t+n]+" -\n":s[4*t+n]+" "}return n+="M V30 COUNTS "+a+" "+l+" 0 0 0\n",n+="M V30 BEGIN ATOM\n",n+=r,n+="M V30 END ATOM\n",n+="M V30 BEGIN BOND\n",n+=o,n+="M V30 END BOND\n",e&&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 Te(t){const e=Ie(t),n=e.atomIndex.length,r=(Math.max(...e.x)+Math.min(...e.x))/2,o=(Math.max(...e.y)+Math.min(...e.y))/2;for(let t=0;t<n;t++)e.x[t]-=r,e.y[t]-=o;const i=Math.PI,s=Math.cos(i),a=Math.sin(i);for(let t=0;t<n;t++){const n=e.x[t];e.x[t]=n*s-e.y[t]*a,e.y[t]=n*a+e.y[t]*s}const l=Math.max(...e.y);for(let t=0;t<n;t++)e.x[t]+=r,e.y[t]-=l;let u=t.indexOf("M V30 BEGIN ATOM");u=t.indexOf("\n",u);let c=u;for(let r=0;r<n;r++)u=t.indexOf("V30",u)+4,u=t.indexOf(" ",u)+1,u=t.indexOf(" ",u)+1,c=t.indexOf(" ",u)+1,c=t.indexOf(" ",c),u=(t=t.slice(0,u)+e.x[r]+" "+e.y[r]+t.slice(c)).indexOf("\n",u)+1;return t}function Se(t){let e=(t=t.replaceAll("\r","")).indexOf("COUNTS")+7,n=t.indexOf(" ",e);const r=parseInt(t.substring(e,n));return e=n+1,n=t.indexOf(" ",e),{natom:r,nbond:parseInt(t.substring(e,n))}}function Ie(t){const e=Se(t);let n=t.indexOf("M V30 BEGIN ATOM");n=t.indexOf("\n",n);let r=n;const o=Array(e.natom),i=Array(e.natom),s=Array(e.natom),a=Array(e.natom);for(let l=0;l<e.natom;l++)n=t.indexOf("V30",n)+4,r=t.indexOf(" ",n),o[l]=parseInt(t.substring(n,r)),n=r+1,r=t.indexOf(" ",n),i[l]=t.substring(n,r),n=r+1,r=t.indexOf(" ",n),s[l]=parseFloat(t.substring(n,r)),n=r+1,r=t.indexOf(" ",n),a[l]=parseFloat(t.substring(n,r)),n=t.indexOf("\n",n)+1;return{atomIndex:o,atomType:i,x:s,y:a}}function _e(t,e,n){if(""===t)return"";const r=n.createFormatDetector(t).getFormat();if(!r)return"";let o="";try{o=new xe(t,e,r).convert()}catch(t){const e=le(t);console.error(e)}return o}function Ne(t,e,n,r,o){const i=[t,e,n].filter((t=>""!==t.strand));return 1===i.length?_e(i[0].strand,i[0].invert,o):Ee({senseStrands:[_e(t.strand,t.invert,o)],antiStrands:[_e(e.strand,e.invert,o),_e(n.strand,n.invert,o)].filter((t=>""!==t))},r)}const Pe=["ss","as","as2"];class Me{constructor(){this.th=Ar,this.onInput=new et.Subject,this.onInvalidInput=new et.Subject,this.inputBase=Object.fromEntries(Pe.map((t=>{const e=P.input.textArea(t.toUpperCase(),{value:"",onValueChanged:()=>{this.onInput.next(),L()(e.root.getElementsByTagName("div")).css("padding-left","38px")}});return[t,e]}))),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(Pe.map((t=>[t,!1]))),this.moleculeImgDiv=P.block([]),L()(this.moleculeImgDiv).addClass("st-structure-mol-img"),o.debounce(this.onInput,300).subscribe((async()=>{await this.updateMoleculeImg()})),o.debounce(this.onInvalidInput,1e3).subscribe((async()=>{r.shell.warning("Insert Sense strand")}))}async getHtmlDivElement(t){const e=this.getTableInput(t),n=this.getBoolInputsAndButton();await this.updateMoleculeImg();const r=P.divH([n,this.moleculeImgDiv]);L()(r).addClass("st-structure-bottom");const o=P.divV([e,r]);return L()(o).addClass("st-structure-body"),o}getBoolInputsAndButton(){const t=P.buttonsInput([P.bigButton("Save SDF",(()=>{const t=this.getStrandData();!function(t,e,n,o,i,s){const a=[t.strand,e.strand,n.strand].filter((t=>""!==t));if(0===a.length||1===a.length&&""===t.strand)r.shell.warning("Enter SENSE_STRAND and optionally ANTISENSE_STRAND/AS2 to save SDF");else{let l;if(i)l=Ne(t,e,n,o,s)+"\n$$$$\n";else{const h=_e(t.strand,t.invert,s),d=_e(e.strand,e.invert,s),f=_e(n.strand,n.invert,s);l=h+"\n> <Sequence>\nSense Strand\n$$$$\n",d&&(l+=d+"\n> <Sequence>\nAnti Sense\n$$$$\n"),f&&(l+=f+"\n> <Sequence>\nAnti Sense 2\n$$$$\n")}const u=new Date;function c(t){return t>=10?t.toString():"0"+t.toString()}y(`SequenceTranslator-${u.getFullYear()+"-"+c(u.getMonth()+1)+"-"+c(u.getDate())+"_"+c(u.getHours())+"-"+c(u.getMinutes())+"-"+c(u.getSeconds())}.sdf`,encodeURIComponent(l))}}(t.ss,t.as,t.as2,this.useChiralInput.value,this.saveAllStrandsInput.value,this.th)}))]),e=[this.saveAllStrandsInput.root,this.useChiralInput.root,t],n=P.divV(e);for(const t of e)L()(t).addClass("st-structure-bool-button-block");return n}getTableInput(t){const e=Object.fromEntries(Pe.map((e=>[e,new de(this.inputBase[e],t.highlightInvalidSubsequence)]))),n=Object.fromEntries(Pe.map(((t,e)=>{const n=0===e?"5′ → 3′":"3′ → 5′";return[t,P.input.choice(`${t.toUpperCase()} direction`,{value:n,items:["5′ → 3′","3′ → 5′"]})]})));Pe.forEach(((t,e)=>{n[t].onChanged.subscribe((n=>{let r="3′ → 5′"===n;e>0&&(r=!r),this.directionInversion[t]=r,this.onInput.next()}))}));const r=["Sense Strand","Anti Sense","Anti Sense 2"],o=new Map(Pe.map(((t,e)=>[t,r[e]]))),i=(Object.fromEntries(Pe.map((t=>[t,P.label(o.get(t))]))),Object.fromEntries(Pe.map((t=>{const n=P.icons.delete((()=>{e[t].inputBase.value=""})),r=P.button(n,(()=>{}));return P.tooltip.bind(r,`Clear ${t.toUpperCase()}`),[t,n]})))),s=P.form([],"st-structure-inputs"),a=P.divV([],"st-structure-clear-buttons"),l=P.form([],"st-direction-inputs");for(const t of Pe)s.append(this.inputBase[t].root),a.append(i[t]),l.append(n[t].root);return P.divH([s,a,l])}getStrandData(){return Object.fromEntries(Pe.map((t=>{const e=this.directionInversion[t];return[t,{strand:this.inputBase[t].value.replace(/\s*/g,""),invert:e}]})))}getMolfile(t,e,n){return Ne(t,e,n,this.useChiralInput.value,this.th)}async updateMoleculeImg(){let t="";try{const e=this.getStrandData();Object.values(e).some((t=>""!==t.strand))&&(t=this.getMolfile(e.ss,e.as,e.as2))}catch(t){const e=le(t);console.error(e)}const e=new ve(t);await e.drawMolecule(this.moleculeImgDiv,650,150),L()(this.moleculeImgDiv).find("canvas").css("float","inherit")}}class Le extends F{constructor(t){super("Oligo Structure"),this.th=t,this.layout=new Me}getContent(){return this.layout.getHtmlDivElement(this.th)}}var Oe=n(2003);async function Re(t){try{const e={overflowX:"scroll"},n=P.div([],{style:e}),o=Ie(t),i=.7*L()(window).height(),s=Math.max(...o.x)-Math.min(...o.x),a=Math.max(...o.y)-Math.min(...o.y),l=i/a,u=l*s,c=l*a,h=P.canvas(u*window.devicePixelRatio,c*window.devicePixelRatio);h.style.width=`${u}px`,h.style.height=`${c}px`,await async function(t,e){await r.functions.call("Chem:canvasMol",{x:0,y:0,w:t.width,h:t.height,canvas:t,molString:e,scaffoldMolString:"",options:{normalizeDepiction:!1,straightenDepiction:!1}})}(h,t),n.appendChild(h),P.dialog("Molecule").add(n).showModal(!0)}catch(t){const e=le(t);console.error(e)}}class De{static async view(){const t=Ar.monomerLibWrapper.getTableForViewer();t.name="Monomer Library";const e=r.shell.addTableView(t);e.grid.props.allowEdit=!1,e.grid.onCellDoubleClick.subscribe((async t=>{const e=t.cell.value;"Molecule"===t.tableColumn?.semType&&await Re(e)}))}}var Be=n(3480),Fe=n(5067),$e=n(5254),ke={};ke.styleTagTransform=xt(),ke.setAttributes=vt(),ke.insert=yt().bind(null,"head"),ke.domAPI=mt(),ke.insertStyleElement=wt(),ft()($e.A,ke),$e.A&&$e.A.locals&&$e.A.locals;const He=["Sequence"];class Ge{constructor(t){this.th=t,this.inputFormats=Object.keys(Ar.jsonData.codesToHelmDict).concat(m.NO.HELM),this.seqHelper=Ar.seqHelper,this.onInput=new et.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:m.NO.HELM,items:this.inputFormats,onValueChanged:async(t,e)=>{this.format=t,this.updateTable(),await this.updateMolImg()}}),L()(this.formatChoiceInput.root.getElementsByTagName("select")[0]).css("width","20%"),this.sequenceInputBase=P.input.textArea("",{value:"Afcgacsu",onValueChanged:()=>{this.onInput.next()}}),this.init(),o.debounce(this.onInput,300).subscribe((async()=>{this.init(),this.formatChoiceInput.value=this.format,this.updateTable(),await this.updateMolImg()})),this.eventBus=qe.getInstance()}async getHtmlElement(){const t=this.constructSingleSequenceControls(),e=this.constructBulkTranslationControls(),n=P.box(P.panel([t,e,P.block([P.box(this.moleculeImgDiv)])]));return this.formatChoiceInput.value=this.format,this.updateTable(),await this.updateMolImg(),n}constructBulkTranslationControls(){const t=P.h1("Bulk");P.tooltip.bind(t,"Bulk translation from table input");const e=new Ue(this.eventBus).createUIComponents(),n=P.input.choice("Input format",{value:m.NO.AXOLABS,items:this.inputFormats,onValueChanged:t=>this.eventBus.selectInputFormat(t)}),r=P.input.choice("Output format",{value:Fe.qP,items:(0,Be.OT)(this.th),onValueChanged:t=>this.eventBus.selectOutputFormat(t)}),o=this.createConvertBulkButton(),i=P.div([...e,n,r,o],"ui-form");return P.block25([t,i])}createConvertBulkButton(){const t=P.bigButton("Convert",(()=>this.processConvertBulkButtonClick()));return P.tooltip.bind(t,"Convert sequences from table input"),L()(t).css({float:"right","margin-top":"20px"}),t}processConvertBulkButtonClick(){const t=this.eventBus.getSelectedTable();if(!t)return void r.shell.warning("No table selected");const e=this.eventBus.getSelectedInputFormat(),n=this.eventBus.getSelectedOutputFormat(),i=this.eventBus.getSelectedColumn("Sequence");if(!i)return void r.shell.warning("No sequence column selected");const s=`${i.name} (${n})`,a=o.Column.fromList(o.TYPE.STRING,s,i.toList().map((t=>(0,Be.C6)(t,e,n,this.th))));if(n===Fe.qP||n===m.NO.HELM){a.semType=o.SEMTYPE.MACROMOLECULE;const t=n==Fe.qP?Oe.Hi.FASTA:Oe.Hi.HELM;a.meta.units=t;const e=this.seqHelper.getSeqHandler(a);(n==Fe.qP?this.seqHelper.setUnitsToFastaColumn:this.seqHelper.setUnitsToHelmColumn)(e)}t.columns.add(a),r.data.detectSemanticTypes(t),r.shell.v=r.shell.getTableView(t.name)}constructSingleSequenceControls(){const t=new de(this.sequenceInputBase,(t=>O(t,this.th))),e=P.button("Get SDF",(()=>{this.saveMolfile()}),"Save structure as SDF"),n=P.button("Copy SMILES",(()=>{this.copySmiles()}),"Copy SMILES for the sequence"),r=P.div([this.formatChoiceInput]),o=P.button(P.icons.delete((()=>{t.inputBase.value=""})),(()=>{}));P.tooltip.bind(o,"Clear input");const i={format:r,textInput:t.root,clearBtn:o},s=P.table([i],(t=>[t.format,t.textInput,t.clearBtn]));s.classList.add("st-translator-input-table");const a=P.block([this.outputTableDiv,e,n]);return P.block75([P.h1("Single sequence"),s,a])}saveMolfile(){const t=new xe(this.sequence,!1,this.formatChoiceInput.value).convert()+"\n$$$$";y(this.sequence+".sdf",encodeURIComponent(t))}copySmiles(){const t=o.chem.convert(this.molfile,o.chem.Notation.MolBlock,o.chem.Notation.Smiles);navigator.clipboard.writeText(t).then((()=>r.shell.info(Fe.n_)))}updateTable(){this.outputTableDiv.innerHTML="";const t=this.format?this.th.createSequenceValidator(this.sequence).getInvalidCodeIndex(this.format):0,e=(0,Be.bD)(this.sequence,t,this.format,this.th),n=[];for(const t of Object.keys(e)){const o="indexOfFirstInvalidChar"in e?P.divH([]):P.link(e[t],(()=>navigator.clipboard.writeText(e[t]).then((()=>r.shell.info(Fe.n_)))),Fe.U_,"");n.push({format:t,sequence:o})}const o=P.table(n,(t=>[t.format,t.sequence]),["FORMAT","SEQUENCE"]);this.outputTableDiv.append(o),this.outputTableDiv.classList.add("st-translator-output-table")}async updateMolImg(){const t=new ve(this.molfile);await t.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===m.NO.HELM){const t=this.th.createFormatConverter(this.sequence,this.format).convertTo(m.NO.AXOLABS);return new xe(t,!1,m.NO.AXOLABS).convert()}return new xe(this.sequence,!1,this.format).convert()}}class Ue{constructor(t){this.tableInputManager=new Ve(t),this.columnInputManager=new je(t)}createUIComponents(){return[this.tableInputManager.getTableInputContainer(),this.columnInputManager.getColumnControlsContainer()]}}class Ve{constructor(t){this.eventBus=t,this.availableTables=[],this.tableInputContainer=P.div([]),this.subscribeToTableEvents(),this.refreshTableInput()}getTableInputContainer(){return this.tableInputContainer}subscribeToTableEvents(){r.events.onTableAdded.subscribe((t=>this.handleTableAdded(t))),r.events.onTableRemoved.subscribe((t=>this.handleTableRemoved(t))),this.eventBus.tableSelected$.subscribe((()=>this.handleTableChoice()))}getTableFromEventData(t){return t.args.dataFrame}handleTableAdded(t){const e=this.getTableFromEventData(t);this.availableTables.some((t=>t.name===e.name))||(this.availableTables.push(e),this.eventBus.selectTable(e),this.refreshTableInput())}handleTableRemoved(t){const e=this.getTableFromEventData(t);this.availableTables=this.availableTables.filter((t=>t.name!==e.name));const n=this.availableTables[0];this.eventBus.selectTable(n||null),this.refreshTableInput()}refreshTableInput(){const t=this.createTableInput();L()(this.tableInputContainer).empty(),this.tableInputContainer.append(t.root)}createTableInput(){const t=this.eventBus.getSelectedTable();return P.input.table("Table",{value:t,items:this.availableTables,onValueChanged:t=>{null!==t&&this.eventBus.selectTable(t)}})}handleTableChoice(){const t=this.eventBus.getSelectedTable();t&&(this.isTableDisplayed(t)||this.displayTable(t))}isTableDisplayed(t){return r.shell.tableNames.includes(t.name)}displayTable(t){const e=r.shell.v;r.shell.addTableView(t),r.shell.v=e}}class je{constructor(t){this.eventBus=t,this.columnControlsContainer=P.div([]),this.eventBus.tableSelected$.subscribe((()=>this.handleTableChoice())),this.refreshColumnControls()}getColumnControlsContainer(){return this.columnControlsContainer}handleTableChoice(){this.refreshColumnControls()}refreshColumnControls(){const t=this.createColumnInputs();L()(this.columnControlsContainer).empty();const e=t.map((t=>t.root));this.columnControlsContainer.append(...e)}createColumnInputs(){const t=this.eventBus.getSelectedTable(),e=null!==t?t.columns.names().sort(((t,e)=>t.localeCompare(e))):[];return He.map((n=>this.createColumnInput(n,e,t)))}createColumnInput(t,e,n){const r=t.toLowerCase(),o=e.find((t=>t.toLowerCase().includes(r)))||e[0];return this.selectColumnIfTableNotNull(n,o,t),P.input.choice(`${t}`,{value:o,items:e,onValueChanged:e=>this.selectColumnIfTableNotNull(n,e,t)})}selectColumnIfTableNotNull(t,e,n){if(null!==t&&e){const r=t.col(e);r&&this.eventBus.selectColumn(n,r)}}}class qe{constructor(){this._tableSelection$=new et.BehaviorSubject(null),this._columnSelection=Object.fromEntries(He.map((t=>[t,new et.BehaviorSubject(null)]))),this._inputFormatSelection$=new et.BehaviorSubject(m.NO.AXOLABS),this._outputFormatSelection$=new et.BehaviorSubject(Fe.qP)}static getInstance(){return void 0===qe._instance&&(qe._instance=new qe),qe._instance}get tableSelected$(){return this._tableSelection$.asObservable()}getSelectedTable(){return this._tableSelection$.getValue()}selectTable(t){this._tableSelection$.next(t)}selectColumn(t,e){this._columnSelection[t].next(e)}getSelectedColumn(t){return this._columnSelection[t].getValue()}getSelectedInputFormat(){return this._inputFormatSelection$.getValue()}selectInputFormat(t){this._inputFormatSelection$.next(t)}selectOutputFormat(t){this._outputFormatSelection$.next(t)}getSelectedOutputFormat(){return this._outputFormatSelection$.getValue()}}class We extends F{constructor(t){super("Oligo Translator"),this.th=t,this.th=Ar,this.layout=new Ge(this.th);const e=P.iconFA("book",De.view,"View monomer library");this.topPanel=[e],this.view.setRibbonPanels([this.topPanel])}getContent(){return this.layout.getHtmlElement()}}class ze extends F{constructor(t,e){super(t),this.content=e}getContent(){return Promise.resolve(this.content)}}class Ye extends B{constructor(t,e){super("Oligo Toolkit"),this.externalViewFactories=t,this.th=e;const n=this.getViewFactories(this.th);this.multiView=new o.MultiView({viewFactories:n})}getViewFactories(t){function e(e){o.View.create();const n=new e(t);return n.initView().catch((t=>console.error(`Failed to initialize ${e.name}: ${t}`))),()=>n.getView()}let n={TRANSLATOR:e(We),PATTERN:e(ie),STRUCTURE:e(Le)};return this.externalViewFactories&&(n=Object.assign({},n,this.externalViewFactories)),n}getCurrentPanePath(){let t=this.multiView.tabs.currentPane.name;return t=t.charAt(0).toUpperCase()+t.substring(1).toLowerCase(),`/apps/${Ar.name}/OligoToolkit/${t}`}setUrl(){this.multiView.path=this.getCurrentPanePath()}async constructView(){return this.multiView.tabs.onTabChanged.subscribe((()=>this.setUrl())),this.setUrl(),this.multiView}}var Ke=n(8070);function Je(t){const e=P.input.textArea("",{value:""});return{coloredInput:new de(e,t.highlightInvalidSubsequence),codes:t.jsonData.codesToSymbolsDict}}var Qe=n(9124),Xe=n(9192),Ze=n(8312),tn=n(1991),en=n.n(tn);const nn="object"==typeof performance&&performance&&"function"==typeof performance.now?performance:Date,rn=new Set,on="object"==typeof process&&process?process:{},sn=(t,e,n,r)=>{"function"==typeof on.emitWarning?on.emitWarning(t,e,n,r):console.error(`[${n}] ${e}: ${t}`)};let an=globalThis.AbortController,ln=globalThis.AbortSignal;if(void 0===an){ln=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(t,e){this._onabort.push(e)}},an=class{constructor(){e()}signal=new ln;abort(t){if(!this.signal.aborted){this.signal.reason=t,this.signal.aborted=!0;for(const e of this.signal._onabort)e(t);this.signal.onabort?.(t)}}};let t="1"!==on.env?.LRU_CACHE_IGNORE_AC_WARNING;const e=()=>{t&&(t=!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",e))}}Symbol("type");const un=t=>t&&t===Math.floor(t)&&t>0&&isFinite(t),cn=t=>un(t)?t<=Math.pow(2,8)?Uint8Array:t<=Math.pow(2,16)?Uint16Array:t<=Math.pow(2,32)?Uint32Array:t<=Number.MAX_SAFE_INTEGER?hn:null:null;class hn extends Array{constructor(t){super(t),this.fill(0)}}class dn{heap;length;static#t=!1;static create(t){const e=cn(t);if(!e)return[];dn.#t=!0;const n=new dn(t,e);return dn.#t=!1,n}constructor(t,e){if(!dn.#t)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new e(t),this.length=0}push(t){this.heap[this.length++]=t}pop(){return this.heap[--this.length]}}class fn{#e;#n;#r;#o;#i;#s;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#a;#l;#u;#c;#h;#d;#f;#p;#m;#g;#y;#b;#v;#C;#w;#A;#x;static unsafeExposeInternals(t){return{starts:t.#v,ttls:t.#C,sizes:t.#b,keyMap:t.#u,keyList:t.#c,valList:t.#h,next:t.#d,prev:t.#f,get head(){return t.#p},get tail(){return t.#m},free:t.#g,isBackgroundFetch:e=>t.#E(e),backgroundFetch:(e,n,r,o)=>t.#T(e,n,r,o),moveToTail:e=>t.#S(e),indexes:e=>t.#I(e),rindexes:e=>t.#_(e),isStale:e=>t.#N(e)}}get max(){return this.#e}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.#r}get disposeAfter(){return this.#o}constructor(t){const{max:e=0,ttl:n,ttlResolution:r=1,ttlAutopurge:o,updateAgeOnGet:i,updateAgeOnHas:s,allowStale:a,dispose:l,disposeAfter:u,noDisposeOnSet:c,noUpdateTTL:h,maxSize:d=0,maxEntrySize:f=0,sizeCalculation:p,fetchMethod:m,memoMethod:g,noDeleteOnFetchRejection:y,noDeleteOnStaleGet:b,allowStaleOnFetchRejection:v,allowStaleOnFetchAbort:C,ignoreFetchAbort:w}=t;if(0!==e&&!un(e))throw new TypeError("max option must be a nonnegative integer");const A=e?cn(e):Array;if(!A)throw new Error("invalid max value: "+e);if(this.#e=e,this.#n=d,this.maxEntrySize=f||this.#n,this.sizeCalculation=p,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!==m&&"function"!=typeof m)throw new TypeError("fetchMethod must be a function if specified");if(this.#i=m,this.#A=!!m,this.#u=new Map,this.#c=new Array(e).fill(void 0),this.#h=new Array(e).fill(void 0),this.#d=new A(e),this.#f=new A(e),this.#p=0,this.#m=0,this.#g=dn.create(e),this.#a=0,this.#l=0,"function"==typeof l&&(this.#r=l),"function"==typeof u?(this.#o=u,this.#y=[]):(this.#o=void 0,this.#y=void 0),this.#w=!!this.#r,this.#x=!!this.#o,this.noDisposeOnSet=!!c,this.noUpdateTTL=!!h,this.noDeleteOnFetchRejection=!!y,this.allowStaleOnFetchRejection=!!v,this.allowStaleOnFetchAbort=!!C,this.ignoreFetchAbort=!!w,0!==this.maxEntrySize){if(0!==this.#n&&!un(this.#n))throw new TypeError("maxSize must be a positive integer if specified");if(!un(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=un(r)||0===r?r:1,this.ttlAutopurge=!!o,this.ttl=n||0,this.ttl){if(!un(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#M()}if(0===this.#e&&0===this.ttl&&0===this.#n)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#e&&!this.#n){const t="LRU_CACHE_UNBOUNDED";(t=>!rn.has(t))(t)&&(rn.add(t),sn("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",t,fn))}}getRemainingTTL(t){return this.#u.has(t)?1/0:0}#M(){const t=new hn(this.#e),e=new hn(this.#e);this.#C=t,this.#v=e,this.#L=(n,r,o=nn.now())=>{if(e[n]=0!==r?o:0,t[n]=r,0!==r&&this.ttlAutopurge){const t=setTimeout((()=>{this.#N(n)&&this.#O(this.#c[n],"expire")}),r+1);t.unref&&t.unref()}},this.#R=n=>{e[n]=0!==t[n]?nn.now():0},this.#D=(o,i)=>{if(t[i]){const s=t[i],a=e[i];if(!s||!a)return;o.ttl=s,o.start=a,o.now=n||r();const l=o.now-a;o.remainingTTL=s-l}};let n=0;const r=()=>{const t=nn.now();if(this.ttlResolution>0){n=t;const e=setTimeout((()=>n=0),this.ttlResolution);e.unref&&e.unref()}return t};this.getRemainingTTL=o=>{const i=this.#u.get(o);if(void 0===i)return 0;const s=t[i],a=e[i];return s&&a?s-((n||r())-a):1/0},this.#N=o=>{const i=e[o],s=t[o];return!!s&&!!i&&(n||r())-i>s}}#R=()=>{};#D=()=>{};#L=()=>{};#N=()=>!1;#P(){const t=new hn(this.#e);this.#l=0,this.#b=t,this.#B=e=>{this.#l-=t[e],t[e]=0},this.#F=(t,e,n,r)=>{if(this.#E(e))return 0;if(!un(n)){if(!r)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 r)throw new TypeError("sizeCalculation must be a function");if(n=r(e,t),!un(n))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}return n},this.#$=(e,n,r)=>{if(t[e]=n,this.#n){const n=this.#n-t[e];for(;this.#l>n;)this.#k(!0)}this.#l+=t[e],r&&(r.entrySize=n,r.totalCalculatedSize=this.#l)}}#B=t=>{};#$=(t,e,n)=>{};#F=(t,e,n,r)=>{if(n||r)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#I({allowStale:t=this.allowStale}={}){if(this.#a)for(let e=this.#m;this.#H(e)&&(!t&&this.#N(e)||(yield e),e!==this.#p);)e=this.#f[e]}*#_({allowStale:t=this.allowStale}={}){if(this.#a)for(let e=this.#p;this.#H(e)&&(!t&&this.#N(e)||(yield e),e!==this.#m);)e=this.#d[e]}#H(t){return void 0!==t&&this.#u.get(this.#c[t])===t}*entries(){for(const t of this.#I())void 0===this.#h[t]||void 0===this.#c[t]||this.#E(this.#h[t])||(yield[this.#c[t],this.#h[t]])}*rentries(){for(const t of this.#_())void 0===this.#h[t]||void 0===this.#c[t]||this.#E(this.#h[t])||(yield[this.#c[t],this.#h[t]])}*keys(){for(const t of this.#I()){const e=this.#c[t];void 0===e||this.#E(this.#h[t])||(yield e)}}*rkeys(){for(const t of this.#_()){const e=this.#c[t];void 0===e||this.#E(this.#h[t])||(yield e)}}*values(){for(const t of this.#I())void 0===this.#h[t]||this.#E(this.#h[t])||(yield this.#h[t])}*rvalues(){for(const t of this.#_())void 0===this.#h[t]||this.#E(this.#h[t])||(yield this.#h[t])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(t,e={}){for(const n of this.#I()){const r=this.#h[n],o=this.#E(r)?r.__staleWhileFetching:r;if(void 0!==o&&t(o,this.#c[n],this))return this.get(this.#c[n],e)}}forEach(t,e=this){for(const n of this.#I()){const r=this.#h[n],o=this.#E(r)?r.__staleWhileFetching:r;void 0!==o&&t.call(e,o,this.#c[n],this)}}rforEach(t,e=this){for(const n of this.#_()){const r=this.#h[n],o=this.#E(r)?r.__staleWhileFetching:r;void 0!==o&&t.call(e,o,this.#c[n],this)}}purgeStale(){let t=!1;for(const e of this.#_({allowStale:!0}))this.#N(e)&&(this.#O(this.#c[e],"expire"),t=!0);return t}info(t){const e=this.#u.get(t);if(void 0===e)return;const n=this.#h[e],r=this.#E(n)?n.__staleWhileFetching:n;if(void 0===r)return;const o={value:r};if(this.#C&&this.#v){const t=this.#C[e],n=this.#v[e];if(t&&n){const e=t-(nn.now()-n);o.ttl=e,o.start=Date.now()}}return this.#b&&(o.size=this.#b[e]),o}dump(){const t=[];for(const e of this.#I({allowStale:!0})){const n=this.#c[e],r=this.#h[e],o=this.#E(r)?r.__staleWhileFetching:r;if(void 0===o||void 0===n)continue;const i={value:o};if(this.#C&&this.#v){i.ttl=this.#C[e];const t=nn.now()-this.#v[e];i.start=Math.floor(Date.now()-t)}this.#b&&(i.size=this.#b[e]),t.unshift([n,i])}return t}load(t){this.clear();for(const[e,n]of t){if(n.start){const t=Date.now()-n.start;n.start=nn.now()-t}this.set(e,n.value,n)}}set(t,e,n={}){if(void 0===e)return this.delete(t),this;const{ttl:r=this.ttl,start:o,noDisposeOnSet:i=this.noDisposeOnSet,sizeCalculation:s=this.sizeCalculation,status:a}=n;let{noUpdateTTL:l=this.noUpdateTTL}=n;const u=this.#F(t,e,n.size||0,s);if(this.maxEntrySize&&u>this.maxEntrySize)return a&&(a.set="miss",a.maxEntrySizeExceeded=!0),this.#O(t,"set"),this;let c=0===this.#a?void 0:this.#u.get(t);if(void 0===c)c=0===this.#a?this.#m:0!==this.#g.length?this.#g.pop():this.#a===this.#e?this.#k(!1):this.#a,this.#c[c]=t,this.#h[c]=e,this.#u.set(t,c),this.#d[this.#m]=c,this.#f[c]=this.#m,this.#m=c,this.#a++,this.#$(c,u,a),a&&(a.set="add"),l=!1;else{this.#S(c);const n=this.#h[c];if(e!==n){if(this.#A&&this.#E(n)){n.__abortController.abort(new Error("replaced"));const{__staleWhileFetching:e}=n;void 0===e||i||(this.#w&&this.#r?.(e,t,"set"),this.#x&&this.#y?.push([e,t,"set"]))}else i||(this.#w&&this.#r?.(n,t,"set"),this.#x&&this.#y?.push([n,t,"set"]));if(this.#B(c),this.#$(c,u,a),this.#h[c]=e,a){a.set="replace";const t=n&&this.#E(n)?n.__staleWhileFetching:n;void 0!==t&&(a.oldValue=t)}}else a&&(a.set="update")}if(0===r||this.#C||this.#M(),this.#C&&(l||this.#L(c,r,o),a&&this.#D(a,c)),!i&&this.#x&&this.#y){const t=this.#y;let e;for(;e=t?.shift();)this.#o?.(...e)}return this}pop(){try{for(;this.#a;){const t=this.#h[this.#p];if(this.#k(!0),this.#E(t)){if(t.__staleWhileFetching)return t.__staleWhileFetching}else if(void 0!==t)return t}}finally{if(this.#x&&this.#y){const t=this.#y;let e;for(;e=t?.shift();)this.#o?.(...e)}}}#k(t){const e=this.#p,n=this.#c[e],r=this.#h[e];return this.#A&&this.#E(r)?r.__abortController.abort(new Error("evicted")):(this.#w||this.#x)&&(this.#w&&this.#r?.(r,n,"evict"),this.#x&&this.#y?.push([r,n,"evict"])),this.#B(e),t&&(this.#c[e]=void 0,this.#h[e]=void 0,this.#g.push(e)),1===this.#a?(this.#p=this.#m=0,this.#g.length=0):this.#p=this.#d[e],this.#u.delete(n),this.#a--,e}has(t,e={}){const{updateAgeOnHas:n=this.updateAgeOnHas,status:r}=e,o=this.#u.get(t);if(void 0!==o){const t=this.#h[o];if(this.#E(t)&&void 0===t.__staleWhileFetching)return!1;if(!this.#N(o))return n&&this.#R(o),r&&(r.has="hit",this.#D(r,o)),!0;r&&(r.has="stale",this.#D(r,o))}else r&&(r.has="miss");return!1}peek(t,e={}){const{allowStale:n=this.allowStale}=e,r=this.#u.get(t);if(void 0===r||!n&&this.#N(r))return;const o=this.#h[r];return this.#E(o)?o.__staleWhileFetching:o}#T(t,e,n,r){const o=void 0===e?void 0:this.#h[e];if(this.#E(o))return o;const i=new an,{signal:s}=n;s?.addEventListener("abort",(()=>i.abort(s.reason)),{signal:i.signal});const a={signal:i.signal,options:n,context:r},l=(r,o=!1)=>{const{aborted:s}=i.signal,l=n.ignoreFetchAbort&&void 0!==r;if(n.status&&(s&&!o?(n.status.fetchAborted=!0,n.status.fetchError=i.signal.reason,l&&(n.status.fetchAbortIgnored=!0)):n.status.fetchResolved=!0),s&&!l&&!o)return u(i.signal.reason);const h=c;return this.#h[e]===c&&(void 0===r?h.__staleWhileFetching?this.#h[e]=h.__staleWhileFetching:this.#O(t,"fetch"):(n.status&&(n.status.fetchUpdated=!0),this.set(t,r,a.options))),r},u=r=>{const{aborted:o}=i.signal,s=o&&n.allowStaleOnFetchAbort,a=s||n.allowStaleOnFetchRejection,l=a||n.noDeleteOnFetchRejection,u=c;if(this.#h[e]===c&&(l&&void 0!==u.__staleWhileFetching?s||(this.#h[e]=u.__staleWhileFetching):this.#O(t,"fetch")),a)return n.status&&void 0!==u.__staleWhileFetching&&(n.status.returnedStale=!0),u.__staleWhileFetching;if(u.__returned===u)throw r};n.status&&(n.status.fetchDispatched=!0);const c=new Promise(((e,r)=>{const s=this.#i?.(t,o,a);s&&s instanceof Promise&&s.then((t=>e(void 0===t?void 0:t)),r),i.signal.addEventListener("abort",(()=>{n.ignoreFetchAbort&&!n.allowStaleOnFetchAbort||(e(void 0),n.allowStaleOnFetchAbort&&(e=t=>l(t,!0)))}))})).then(l,(t=>(n.status&&(n.status.fetchRejected=!0,n.status.fetchError=t),u(t)))),h=Object.assign(c,{__abortController:i,__staleWhileFetching:o,__returned:void 0});return void 0===e?(this.set(t,h,{...a.options,status:void 0}),e=this.#u.get(t)):this.#h[e]=h,h}#E(t){if(!this.#A)return!1;const e=t;return!!e&&e instanceof Promise&&e.hasOwnProperty("__staleWhileFetching")&&e.__abortController instanceof an}async fetch(t,e={}){const{allowStale:n=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,ttl:i=this.ttl,noDisposeOnSet:s=this.noDisposeOnSet,size:a=0,sizeCalculation:l=this.sizeCalculation,noUpdateTTL:u=this.noUpdateTTL,noDeleteOnFetchRejection:c=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:h=this.allowStaleOnFetchRejection,ignoreFetchAbort:d=this.ignoreFetchAbort,allowStaleOnFetchAbort:f=this.allowStaleOnFetchAbort,context:p,forceRefresh:m=!1,status:g,signal:y}=e;if(!this.#A)return g&&(g.fetch="get"),this.get(t,{allowStale:n,updateAgeOnGet:r,noDeleteOnStaleGet:o,status:g});const b={allowStale:n,updateAgeOnGet:r,noDeleteOnStaleGet:o,ttl:i,noDisposeOnSet:s,size:a,sizeCalculation:l,noUpdateTTL:u,noDeleteOnFetchRejection:c,allowStaleOnFetchRejection:h,allowStaleOnFetchAbort:f,ignoreFetchAbort:d,status:g,signal:y};let v=this.#u.get(t);if(void 0===v){g&&(g.fetch="miss");const e=this.#T(t,v,b,p);return e.__returned=e}{const e=this.#h[v];if(this.#E(e)){const t=n&&void 0!==e.__staleWhileFetching;return g&&(g.fetch="inflight",t&&(g.returnedStale=!0)),t?e.__staleWhileFetching:e.__returned=e}const o=this.#N(v);if(!m&&!o)return g&&(g.fetch="hit"),this.#S(v),r&&this.#R(v),g&&this.#D(g,v),e;const i=this.#T(t,v,b,p),s=void 0!==i.__staleWhileFetching&&n;return g&&(g.fetch=o?"stale":"refresh",s&&o&&(g.returnedStale=!0)),s?i.__staleWhileFetching:i.__returned=i}}async forceFetch(t,e={}){const n=await this.fetch(t,e);if(void 0===n)throw new Error("fetch() returned undefined");return n}memo(t,e={}){const n=this.#s;if(!n)throw new Error("no memoMethod provided to constructor");const{context:r,forceRefresh:o,...i}=e,s=this.get(t,i);if(!o&&void 0!==s)return s;const a=n(t,s,{options:i,context:r});return this.set(t,a,i),a}get(t,e={}){const{allowStale:n=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,status:i}=e,s=this.#u.get(t);if(void 0!==s){const e=this.#h[s],a=this.#E(e);return i&&this.#D(i,s),this.#N(s)?(i&&(i.get="stale"),a?(i&&n&&void 0!==e.__staleWhileFetching&&(i.returnedStale=!0),n?e.__staleWhileFetching:void 0):(o||this.#O(t,"expire"),i&&n&&(i.returnedStale=!0),n?e:void 0)):(i&&(i.get="hit"),a?e.__staleWhileFetching:(this.#S(s),r&&this.#R(s),e))}i&&(i.get="miss")}#G(t,e){this.#f[e]=t,this.#d[t]=e}#S(t){t!==this.#m&&(t===this.#p?this.#p=this.#d[t]:this.#G(this.#f[t],this.#d[t]),this.#G(this.#m,t),this.#m=t)}delete(t){return this.#O(t,"delete")}#O(t,e){let n=!1;if(0!==this.#a){const r=this.#u.get(t);if(void 0!==r)if(n=!0,1===this.#a)this.#U(e);else{this.#B(r);const n=this.#h[r];if(this.#E(n)?n.__abortController.abort(new Error("deleted")):(this.#w||this.#x)&&(this.#w&&this.#r?.(n,t,e),this.#x&&this.#y?.push([n,t,e])),this.#u.delete(t),this.#c[r]=void 0,this.#h[r]=void 0,r===this.#m)this.#m=this.#f[r];else if(r===this.#p)this.#p=this.#d[r];else{const t=this.#f[r];this.#d[t]=this.#d[r];const e=this.#d[r];this.#f[e]=this.#f[r]}this.#a--,this.#g.push(r)}}if(this.#x&&this.#y?.length){const t=this.#y;let e;for(;e=t?.shift();)this.#o?.(...e)}return n}clear(){return this.#U("delete")}#U(t){for(const e of this.#_({allowStale:!0})){const n=this.#h[e];if(this.#E(n))n.__abortController.abort(new Error("deleted"));else{const r=this.#c[e];this.#w&&this.#r?.(n,r,t),this.#x&&this.#y?.push([n,r,t])}}if(this.#u.clear(),this.#h.fill(void 0),this.#c.fill(void 0),this.#C&&this.#v&&(this.#C.fill(0),this.#v.fill(0)),this.#b&&this.#b.fill(0),this.#p=0,this.#m=0,this.#g.length=0,this.#l=0,this.#a=0,this.#x&&this.#y){const t=this.#y;let e;for(;e=t?.shift();)this.#o?.(...e)}}}function pn(){var t;return null!==(t=window.$monomerHover)&&void 0!==t?t:null}function mn(t){window.$monomerHover=t}function gn(t,e){let n=t["substruct-providers"];n||(n=t["substruct-providers"]=[]),n.push(e),t["substruct-providers"]=n}var yn=n(6077),bn=n(3561),vn=n(9235);const Cn="MonomerHoverLinks";function wn(t,e){let n=t[Cn];n||(n=t[Cn]=[]),n.push(e),t[Cn]=n}function An(t,e){try{const n=t.tableColumn;if(!n)return;const r=function(t){return t.temp[Cn]??[]}(n);for(let n=r.length-1;n>=0;--n){const o=r[n],i=t.grid.col(o.targetCol.name);if(i&&!o.handler(t,e,i))break}}catch(t){console.error(t)}}var xn=n(6717),En=n(6694),Tn=n(4229),Sn=n(5174);function In(t,e=!0){const[n,o]=(0,Xe.AP)(t);return Ar.logger.error(n,void 0,o),e&&r.shell.error(n),[n,o]}async function _n(){return(await(0,l.pj)()).getAvaliableLibraryNames()}const Nn={symbol:"Short Name",name:"Medium Name",smiles:"SMILES"},Pn=[{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"}],Mn="Get HELM",Ln="Chirality engine",On="Highlight monomers",Rn="Poly Tool Conversion",Dn="Poly Tool Enumeration",Bn="Rules used";var Fn=n(5412);async function $n(t){await Ar.initPromise;try{const e=await async function(t){const e=[],n=()=>{for(const t of e)t.unsubscribe()};try{const[i,s]=await Promise.all([_n(),(0,Qe.b2)()]),a=t&&t.rowIndex>=0?t.value:"\n\n\n 22 24 0 0 0 0 0 0 0 0999 V2000\n 0.3128 -0.7509 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n 0.3128 0.0740 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n -0.4054 -1.1623 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n -1.1081 -0.7509 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n -0.4054 0.4877 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0\n -1.1081 0.0740 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n -1.8175 -1.1623 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n 1.0222 0.4877 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n -1.8175 0.4877 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n -2.5292 -0.7509 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n 1.0222 1.3127 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n 1.7227 1.7263 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n -0.4054 -1.9896 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0\n -2.5292 0.0740 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n 2.4544 1.3127 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n 1.7406 0.0740 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n 1.0222 -1.1623 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0\n 2.4544 0.4877 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n -1.8175 -1.9896 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0\n -3.2453 0.4877 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0\n 3.1670 1.7285 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0\n 1.7149 2.5513 0.0000 R# 0 0 0 0 0 0 0 0 0 0 0 0\n 2 1 2 0 0 0 0\n 3 1 1 0 0 0 0\n 4 3 1 0 0 0 0\n 5 2 1 0 0 0 0\n 6 5 1 0 0 0 0\n 7 4 1 0 0 0 0\n 8 2 1 0 0 0 0\n 9 6 1 0 0 0 0\n 10 7 2 0 0 0 0\n 11 8 2 0 0 0 0\n 12 11 1 0 0 0 0\n 13 3 2 0 0 0 0\n 14 9 2 0 0 0 0\n 15 18 1 0 0 0 0\n 16 8 1 0 0 0 0\n 17 1 1 0 0 0 0\n 18 16 2 0 0 0 0\n 19 7 1 0 0 0 0\n 20 14 1 0 0 0 0\n 6 4 2 0 0 0 0\n 15 12 2 0 0 0 0\n 14 10 1 0 0 0 0\n 15 21 1 0 0 0 0\n 12 22 1 0 0 0 0\nM RGP 1 22 1\nM END";let u=await(async()=>o.chem.isMolBlock(a)?a:await r.functions.call("Chem:convertMolNotation",{molecule:a,sourceNotation:t?.column.getTag(o.TAGS.UNITS)??o.chem.Notation.Unknown,targetNotation:o.chem.Notation.MolBlock}))();const c=new o.chem.Sketcher(o.chem.SKETCHER_MODE.EXTERNAL);c.syncCurrentObject=!1,c.onChanged.subscribe((t=>{u=c.getMolFile()})),c.root.classList.add("ui-input-editor"),c.root.style.marginTop="3px",c.setMolFile(u);const h=P.input.choice("Library to use",{value:null,items:i});c.root.setAttribute("style","min-width:250px!important;"),c.root.setAttribute("style","max-width:250px!important;"),h.input.setAttribute("style","min-width:250px!important;");const d=P.div([c.root,h.root]);e.push(r.events.onCurrentCellChanged.subscribe((()=>{const t=r.shell.tv.dataFrame.currentCell;t.column.semType===o.SEMTYPE.MOLECULE&&c.setValue(t.value)})));const f=async()=>{try{const t=c.getMolFile();if(void 0===t||""===t)r.shell.warning("PolyTool: no molecule was provided");else if(t.includes("R#")){const e=await async function(t,e){const n=await async function(t){const e=await(0,l.pj)(),n=await e.readSingleLibraryByName(t);return n?n.getMonomerSymbolsByType("PEPTIDE"):(Ar.logger.error(`Monomer library '${t}' not found.`),[])}(e),o=await async function(t){const e=await(0,l.pj)(),n=await e.readSingleLibraryByName(t);if(!n)return Ar.logger.error(`Monomer library '${t}' not found.`),{};const r=n.getMonomerSymbolsByType("PEPTIDE");return new Array(r.length),n.getMonomerMolsByPolymerType("PEPTIDE")}(e),i=new Array(n.length),s=await r.functions.call("Chem:getRdKitModule"),a=s.get_mol(t),u=a.get_smiles();a.delete();const c=new Array(n.length);for(let t=0;t<n.length;t++){const e=o[n[t]],r=s.get_mol(e);c[t]=r.get_smiles(),r.delete()}for(let t=0;t<n.length;t++){let e=null;try{const n=`${`${u}.${c[t]}`.replaceAll("[1*]C","C([1*])").replaceAll("[1*]c","c([1*])").replaceAll("[1*]O","O([1*])").replaceAll("[1*]N","N([1*])")}`.replaceAll("([1*])","9").replaceAll("[1*]","9");e=s.get_mol(n,JSON.stringify({mappedDummiesAreRGroups:!0}));const r=e.get_v3Kmolblock();i[t]=r}catch(e){i[t]=""}finally{e?.delete()}}return i}(t,h.value),n=o.Column.fromStrings("Enumerated",e),i=o.DataFrame.fromColumns([n]);r.shell.addTableView(i)}else r.shell.warning("PolyTool: no R group was provided")}catch(t){In(t)}},p=P.dialog(Dn).add(d).onOK((()=>{f().finally((()=>{n()}))})).onCancel((()=>{n()}));return e.push(p.onClose.subscribe((()=>{n()}))),p.history((()=>({mol:c.getMolFile(),screenLibrary:h.value})),(t=>{c.setMolFile(t.mol),h.value=t.screenLibrary})),p}catch(t){throw n(),t}}(t);e.show({resizable:!0})}catch(t){r.shell.warning("To run PolyTool Enumeration, sketch the molecule and specify the R group to vary")}}async function kn(t,e,n,i,s,a){const l=o.TaskBarProgressIndicator.create("PolyTool converting...");try{const l=(t,e)=>t?t.columns.getUnusedName(e):e,u=await(0,Qe.b2)(),c=t.dataFrame,h=await(0,En.Q4)(a),[d,f,p]=(0,Tn.b)(t.toList(),h,u),m=l(c,`transformed(${t.name})`),g=o.Column.fromType(o.COLUMN_TYPE.STRING,m,d.length).init((t=>d[t]));g.semType=o.SEMTYPE.MACROMOLECULE,g.meta.units=Oe.Hi.HELM,g.setTag(o.TAGS.CELL_RENDERER,"helm"),e&&c&&c.columns.add(g,!0);const y=await(0,xn.j)(),b=await(0,Ze.Q)(),v=await(0,Sn.A)(h),C=g.temp;C[".mm.cellRenderer.overriddenLibrary"]=v,g.temp=C;const w=await(0,Fn.m)(g,d,f,i,s,n,v,y,b);return w.name=l(c,`molfile(${t.name})`),w.semType=o.SEMTYPE.MOLECULE,c&&(c.columns.add(w,!0),await r.data.detectSemanticTypes(c)),function(t,e,n,r,o,i,s){const a=new fn({max:100});function l(t,e){const n=t.get(e);if(null==n)return null;let s=a.get(n);return s||a.set(n,s=function(t,e){const n=o.getSeqHandler(t),s=n.getSplitted(e),a=n.defaultBiotype,l=en().count(0).take(s.length).map((t=>({position:t,symbol:s.getCanonical(t),biotype:a}))).toArray(),u=n.alphabet,c=u==Oe.YI.RNA||u==Oe.YI.DNA?"RNA":"PEPTIDE",h=(0,yn.eM)([l],c,u,r,i);return(0,bn.gU)(l,h,u,c).monomers}(t,e)),s}const u={targetCol:n,handler:(t,n,o)=>{if(!t||!o.grid||!e.dataFrame)return!0;const i=o.grid,a=t.tableRowIndex,u=t.gridRow,c=i.cell(o.name,u),h=s[u],d=pn();if(!d||d&&(d.dataFrameId!=e.dataFrame?.id||d.gridRowIdx!=u||d.seqColName!=e.name||d.seqPosition!=n?.position)){if(d&&(mn(null),d.gridCell.render()),!n)return mn(null),!0;mn({gridCell:c,dataFrameId:e.dataFrame.id,gridRowIdx:u,seqColName:e.name,seqPosition:n?n.position:-1,getSubstruct:()=>{if(!n||"*"===n.symbol)return;const t=l(e,a);if(!t)return;const o=[],i=h[n.position];for(const e of i){const n=t.get(e);if(!n)return{atoms:[],bonds:[],highlightAtomColors:[],highlightBondColors:[]};o.push((0,vn.H)([n],r))}return function(t){var e,n,r,o;const i={atoms:[],bonds:[],highlightAtomColors:{},highlightBondColors:{}};for(const s of t)i.atoms=[...null!==(e=i.atoms)&&void 0!==e?e:[],...null!==(n=s.atoms)&&void 0!==n?n:[]],i.bonds=[...null!==(r=i.bonds)&&void 0!==r?r:[],...null!==(o=s.bonds)&&void 0!==o?o:[]],i.highlightAtomColors=Object.assign(Object.assign({},i.highlightAtomColors),s.highlightAtomColors),i.highlightBondColors=Object.assign(Object.assign({},i.highlightBondColors),s.highlightBondColors);return i}(o)}}),c.render()}return!0},getSubstruct:t=>{if("true"!=n.getTag(".sequence-src-highlight-monomers"))return;if(null==t)return;if(!e.get(t))return;const o=l(e,t);return o?(0,vn.H)(o.values(),r):void 0}};wn(t.temp,u),gn(n.temp,u)}(t,g,w,v,b,y,p),[g,w]}finally{l.close()}}var Hn=n(6197);class Gn extends o.InputBase{constructor(t,e){super(P.input.column(t,e).dart,e?.onValueChanged),this.options=e}setColumnInputTable(t){P.input.setColumnInputTable(this,t,this.options?.filter)}}P.input.column2=function(t,e){return new Gn(t,e)};var Un=n(1296),Vn=n(3820);class jn extends o.JsInputBase{get inputType(){return"Positions"}get dataType(){return o.TYPE.DATA_FRAME}getInput(){return this.gridHost}getValue(){return this.grid.dataFrame}setValue(t){this.setDataFrame(t)}getStringValue(){return this.grid.dataFrame.toCsv()}setStringValue(t){this.setDataFrame(o.DataFrame.fromCsv(t))}clearInput(){const t=o.DataFrame.fromColumns([o.Column.fromType(o.COLUMN_TYPE.STRING,"Remove",0),o.Column.fromType(o.COLUMN_TYPE.INT,"Position",0),o.Column.fromType(o.COLUMN_TYPE.STRING,"Monomers",0)]);this.setDataFrame(t)}get placeholdersValue(){return function(t){const e=[];for(let n=0;n<t.rowCount;n++){if(t.getCol("Position").isNone(n))continue;const r=parseInt(t.get("Position",n))-1;if(!isNaN(r)){const o=qn(t.get("Monomers",n));e.push({position:r,monomers:o})}}return e}(this.grid.dataFrame)}constructor(t,e,n){super(),this.name=t,this.subs=[],this.dataFrameSubs=[],this.caption=t??"",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(e,n).then((()=>{}))}detach(){for(const t of this.subs)t.unsubscribe();for(const t of this.dataFrameSubs)t.unsubscribe()}async render(t,e){let n;const r=o.DataFrame.fromColumns([n=o.Column.fromType(o.COLUMN_TYPE.STRING,"Remove",0),o.Column.fromType(o.COLUMN_TYPE.INT,"Position",0),o.Column.fromType(o.COLUMN_TYPE.STRING,"Monomers",0)]);n.setTag(o.TAGS.FRIENDLY_NAME,""),this.grid=await r.plot.fromType(o.VIEWER.GRID,e),this.grid.sort(["Position"]),this.grid.columns.byIndex(1).width=this.grid.props.rowHeight+2,this.grid.onCellRender.subscribe((t=>{const e=t.cell;e.tableColumn?.name==n.name&&(e?.tableRowIndex??-1)>=0&&(e.element=P.div(P.icons.delete((()=>{this.grid.dataFrame.rows.removeAt(e.tableRowIndex)}),"Delete"),{style:{height:`${e.grid.props.rowHeight}px`,color:"var(--grey-6)",display:"flex",flexDirection:"row",justifyContent:"center"}}))})),this.updateGridHeight(t??this.grid.dataFrame.rowCount+.7),this.subs.push(P.onSizeChanged(this.grid.root).subscribe(this.gridRootOnSizeChanged.bind(this))),this.subs.push((0,et.fromEvent)(this.grid.root,"keydown").subscribe((t=>{"Enter"===t.key&&t.stopPropagation()}))),this.setDataFrame(r),this.grid.root.style.width="100%",this.gridHost.append(this.grid.root)}setDataFrame(t){for(const t of this.dataFrameSubs)t.unsubscribe();this.grid.dataFrame=t,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(t,e){const n=this.grid.dataFrame,r=n.columns.byName("Position").toList();let o=r.indexOf(t+1);-1===o&&(o=r.findIndex((t=>isNaN(t))),-1===o&&(o=n.rows.addNew(["",t+1,e??""]).idx),this.grid.cell("Monomers",o)),n.currentCell=n.cell(o,"Monomers")}setMonomersValue(t,e){const n=this.grid.dataFrame;n.rowCount<=t||n.set("Monomers",t,e)}static async create(t,e,n){return new jn(t,n,e)}updateGridHeight(t){const e=this.grid.colHeaderHeight+t*this.grid.props.rowHeight+6+2;this.grid.root.style.height=`${e}px`}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 qn(t){return t.split(/,(?![^(]*\))/).map((t=>('"'===(t=t.trim()).slice(0,1)&&'"'===t.slice(-1)&&(t=t.slice(1,-1)),"'"===t.slice(0,1)&&"'"===t.slice(-1)&&(t=t.slice(1,-1)),t.trim()))).filter((t=>!!t))}class Wn extends o.JsInputBase{get inputType(){return"Breadth"}get dataType(){return o.TYPE.DATA_FRAME}getInput(){return this.gridHost}getValue(){return this.grid.dataFrame}setValue(t){this.setDataFrame(t)}getStringValue(){return this.grid.dataFrame.toCsv()}setStringValue(t){this.setDataFrame(o.DataFrame.fromCsv(t))}get placeholdersBreadthValue(){return function(t){const e=[];for(let n=0;n<t.rowCount;n++){const r=parseInt(t.get("Start",n))-1,o=parseInt(t.get("End",n))-1;if(!isNaN(r)&&!isNaN(o)){const i=qn(t.get("Monomers",n));e.push({start:r,end:o,monomers:i})}}return e}(this.grid.dataFrame)}constructor(t,e,n){super(),this.name=t,this.subs=[],this.dataFrameSubs=[],this.caption=t??"",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(e,n).then((()=>{}))}detach(){for(const t of this.subs)t.unsubscribe();for(const t of this.dataFrameSubs)t.unsubscribe()}clearInput(){const t=o.DataFrame.fromColumns([o.Column.fromType(o.COLUMN_TYPE.STRING,"Remove",0),o.Column.fromType(o.COLUMN_TYPE.INT,"Start",0),o.Column.fromType(o.COLUMN_TYPE.INT,"End",0),o.Column.fromType(o.COLUMN_TYPE.STRING,"Monomers",0)]);this.setDataFrame(t)}async render(t,e){let n;const r=o.DataFrame.fromColumns([n=o.Column.fromType(o.COLUMN_TYPE.STRING,"Remove",0),o.Column.fromType(o.COLUMN_TYPE.INT,"Start",0),o.Column.fromType(o.COLUMN_TYPE.INT,"End",0),o.Column.fromType(o.COLUMN_TYPE.STRING,"Monomers",0)]);n.setTag(o.TAGS.FRIENDLY_NAME,""),this.grid=await r.plot.fromType(o.VIEWER.GRID,e),this.grid.sort(["Start","End"]),this.grid.columns.byIndex(1).width=this.grid.props.rowHeight+2,this.grid.onCellRender.subscribe((t=>{const e=t.cell;e.tableColumn?.name==n.name&&(e?.tableRowIndex??-1)>=0&&(e.element=P.div(P.icons.delete((()=>{this.grid.dataFrame.rows.removeAt(e.tableRowIndex)}),"Delete"),{style:{height:`${e.grid.props.rowHeight}px`,color:"var(--grey-6)",display:"flex",flexDirection:"row",justifyContent:"center"}}))})),this.updateGridHeight(t??this.grid.dataFrame.rowCount+.7),this.subs.push(P.onSizeChanged(this.grid.root).subscribe(this.gridRootOnSizeChanged.bind(this))),this.subs.push((0,et.fromEvent)(this.grid.root,"keydown").subscribe((t=>{"Enter"===t.key&&t.stopPropagation()}))),this.setDataFrame(r),this.grid.root.style.width="100%",this.gridHost.append(this.grid.root)}setDataFrame(t){for(const t of this.dataFrameSubs)t.unsubscribe();this.grid.dataFrame=t,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(t,e,n){return new Wn(t,n,e)}updateGridHeight(t){const e=this.grid.colHeaderHeight+t*this.grid.props.rowHeight+6+2;this.grid.root.style.height=`${e}px`}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 zn=n(6307);async function Yn(t){await Ar.initPromise;const e=window.innerWidth,n=window.innerHeight;try{let i;function s(){if(null==i)return;const t=L()(i.root).find("div.d4-dialog-contents").get(0),e=t.clientHeight,n={0:1},r=Object.values(n).reduce(((t,e)=>t+e),0),o=e-en().count(0).take(t.children.length).filter((t=>!(t in n))).map((e=>t.children[e])).filter((t=>t instanceof HTMLElement)).map((t=>t.offsetHeight)).reduce(((t,e)=>t+e),0)-38;for(const e of en().count(0).take(t.children.length))if(e in n){const i=t.children[e],s=o*n[e]/r;i.style.height=`${s}px`}}i=await async function(t,e){const n="ST: PT: HelmDialog()";let i;const s=[];let a=Un.aK.Single;const u=()=>{for(const t of s)t.unsubscribe();i.placeholders.detach()};try{const c=await(0,l.pj)(),h=c.getMonomerLib(),d=await(0,Ze.Q)(),f=o.DataFrame.fromColumns([]),[p,m]=await Promise.all([_n(),(0,Qe.b2)()]),g=m.buildMonomersFuncsFromLib(h),y=t=>{let e,n;if(t&&t.rowIndex>=0&&t?.column.semType==o.SEMTYPE.MACROMOLECULE)e=d.getSeqHandler(t.column).getValue(t.rowIndex),n=e.tags["polytool-data-role"]??"macromolecule";else{const t=o.Column.fromList(o.COLUMN_TYPE.STRING,"seq",[Vn.d]);t.semType=o.SEMTYPE.MACROMOLECULE,o.DataFrame.fromColumns([t]),t.meta.units=Oe.Hi.HELM,e=d.getSeqHandler(t).getValue(0),n="macromolecule"}return[e,n]};let b,v,[C,w]=y(t),A=null;const x=P.divText("",{style:{marginLeft:"8px",marginTop:"2px"}}),E=P.divText("",{style:{color:"red"}});i={macromolecule:m.createHelmInput("Macromolecule",{editable:!1,editorOptions:{drawOptions:{monomerNumbering:1,getMonomer:(t,e)=>{const n=t;if("ATOM"!==n.T)return g.getMonomer(t,e);try{if(C.isDna()||C.isRna()){const t=C.getSplittedWithSugarsAndPhosphates().getCanonical(n.bio.continuousId-1);return g.getMonomer(n.bio.type,t)}{const t=C.getSplitted().getCanonical(n.bio.continuousId-1);return g.getMonomer(n.bio.type,t)}}catch(n){return g.getMonomer(t,e)}}}}}),placeholders:await jn.create("Placeholders",{showAddNewRowIcon:!0,showRemoveRowIcon:!0,showRowHeader:!1,showCellTooltip:!1}),enumeratorType:P.input.choice("Enumerator type",{value:a,items:Object.values(Un.aK)}),placeholdersBreadth:await Wn.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:(t,e)=>{I()}}),generateHelm:P.input.bool(Mn,{value:!0}),chiralityEngine:P.input.bool(Ln,{value:!1}),highlightMonomers:P.input.bool(On,{value:!1}),rules:{header:P.inlineText([Bn]),form:await(v=new En._v(En.MU,En.yy,".json",{onValueChanged:t=>{b=t}})).getForm()},trivialNameCol:P.input.column2("Trivial name",{table:t?.dataFrame,filter:e=>e.type===o.COLUMN_TYPE.STRING&&e!=t?.column,onValueChanged:()=>{const e=i.trivialNameCol.value;let n=null;t&&e&&(n={value:e.get(t.rowIndex),colName:e.name}),A=n,x.textContent=A?`Original ID: ${A.value}`:""},nullable:!0}),library:P.input.choice("Monomer Library",{items:p,value:p[0],nullable:!0})},i.library.root.style.setProperty("display","none"),i.trivialNameCol.addOptions(x);let T=null;i.placeholders.addValidator((t=>{const e=[];try{if(i.enumeratorType.value===Un.aK.Library){setTimeout((()=>{_()}),10);const t=i.placeholders.placeholdersValue;if(t.length>1)return"Only one placeholder is allowed for Library mode";if(1===t.length){if(null==t[0].position)return"Position is required for Library mode";if(t[0].position>i.macromolecule.molValue.atoms.length)return`There is no monomer at position ${t[0].position+1}.`}return null}if("macromolecule"!==w)return null;const t=[];for(const n of i.placeholders.placeholdersValue){const r=n.position;if(null==r)continue;if(r>=i.macromolecule.molValue.atoms.length){e.push(`There is no monomer at position ${r+1}.`);continue}const o=i.macromolecule.molValue.atoms[r];if(o){const e=o.biotype(),r=(0,Hn.Y)(e);for(const e of n.monomers){const n=h.getMonomer(r,e);n&&n.lib||t.push({polymerType:r,symbol:e})}}}const n={};for(const e of t){let t=n[e.polymerType];t||(t=n[e.polymerType]=[]),t.push(e.symbol)}const r=Object.entries(n).map((([t,e])=>`${t}: ${e.join(", ")}`)).join("\n");Object.keys(r).length>0&&e.push(`Placeholders contain missed monomers: ${r}`),T=e.length>0?e.join("\n"):null}catch(t){const[e,n]=In(t,!1);T=e}return setTimeout((()=>{_()}),0),T})),i.library.addValidator((t=>i.enumeratorType.value!==Un.aK.Library||i.library.value?null:"Monomer Library is required for this enumerator type")),i.library.onChanged.subscribe((()=>{i.enumeratorType.value===Un.aK.Library&&i.placeholders.setMonomersValue(0,i.library.value??"")})),i.enumeratorType.onChanged.subscribe((t=>{const e=i.enumeratorType.value===Un.aK.Library;i.library.root.style.setProperty("display",e?"flex":"none");try{if(a!==Un.aK.Library&&e||a===Un.aK.Library&&!e){const t=1===i.placeholders.placeholdersValue.length?i.placeholders.placeholdersValue[0].position:null;i.placeholders.clearInput(),i.placeholdersBreadth.clearInput(),e&&null!=t&&i.placeholders.addPosition(t,i.library.value??"")}}catch(t){In(t,!1)}a=i.enumeratorType.value})),s.push(i.macromolecule.onMouseMove.subscribe((t=>{try{Ar.logger.debug(`${n}, placeholdersInput.onMouseMove()`);const e=t.offsetX,r=t.offsetY,o=i.macromolecule.molValue,s=m.getHoveredAtom(e,r,o,i.macromolecule.root.clientHeight);if(s){const e=s._parent.atoms.indexOf(s),n=i.placeholders.placeholdersValue.find((t=>t.position===e))?.monomers;if(n){const e=P.divText(n.join(", "));i.macromolecule.showTooltip(e,s),t.preventDefault(),t.stopPropagation()}}}catch(t){In(t,!1)}}))),s.push(i.macromolecule.onClick.subscribe((t=>{try{Ar.logger.debug(`${n}, placeholdersInput.onClick()`);const e=t.offsetX,r=t.offsetY,o=i.macromolecule.molValue,s=m.getHoveredAtom(e,r,o,i.macromolecule.root.clientHeight);if(s){const t=s._parent.atoms.indexOf(s);String(t+1);let e="";i.enumeratorType.value===Un.aK.Library&&(i.placeholders.clearInput(),e=i.library.value??""),i.placeholders.addPosition(t,e)}}catch(t){In(t)}}))),s.push(i.placeholders.onChanged.subscribe((()=>{S()}))),s.push(P.onSizeChanged(i.placeholders.root).subscribe((()=>{e&&e()}))),s.push(r.events.onCurrentCellChanged.subscribe((()=>{const t=r.shell.tv.dataFrame.currentCell;t.column.semType===o.SEMTYPE.MACROMOLECULE&&([C,w]=y(),M(C,w,t))}))),i.macromolecule.root.style.setProperty("min-width","250px","important");const S=()=>{const t=new Set(i.placeholders.placeholdersValue.map((t=>t.position))),e=i.macromolecule.molValue;for(let n=0;n<e.atoms.length;n++)e.atoms[n].highlighted=t.has(n);i.macromolecule.redraw()},I=()=>{i.toAtomicLevel.value&&"template"===w?(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"),e&&e()},_=()=>{const t=T,e=E;t?(e.innerText=t,e.style.removeProperty("display")):(e.innerText="",e.style.setProperty("display","none"))},N=t=>{t?(i.trivialNameCol.setColumnInputTable(t),i.trivialNameCol.root.style.removeProperty("display")):(i.trivialNameCol.setColumnInputTable(f),i.trivialNameCol.root.style.setProperty("display","none")),e&&e()},M=(t,e,n)=>{i.macromolecule.value=t;const r=n?.dataFrame;N(r)};M(C,w,t),I();const L=async()=>{try{const t=i.macromolecule.stringValue,e=en().enumerate(i.macromolecule.molValue.atoms).filter((([t,e])=>t.highlighted)).map((([t,e])=>e)).toArray();if(i.enumeratorType.value===Un.aK.Library){if(0===e.length)return void r.shell.warning("PolyTool: position for enumeration was not selected");if(!i.library.value)return void r.shell.warning("PolyTool: No monomer library was selected")}if(void 0===t||""===t)r.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 r.shell.warning(`${Dn}: placeholders are empty`);await(0,Qe.b2)();const e=i.placeholders.placeholdersValue;let n=i.enumeratorType.value;if(n===Un.aK.Library){if(1!==e.length)return void r.shell.warning("Only one placeholder is allowed for Library mode");if(!e[0].monomers||!p.includes(e[0].monomers[0]))return void r.shell.warning("Valid Monomer Library is required for this enumerator type");const t=e[0].monomers[0],o=await c.readSingleLibraryByName(t);if(!o)return void r.shell.warning(`Monomer Library '${t}' was not found`);const i=o.getMonomerSymbolsByType("PEPTIDE");e[0].monomers=i,n=Un.aK.Single}const s={placeholders:e,type:n,breadthPlaceholders:i.placeholdersBreadth.placeholdersBreadthValue,keepOriginal:i.keepOriginal.value},a=i.toAtomicLevel.value,u=await async function(t,e,n,i,s,a){const u=o.TaskBarProgressIndicator.create("PolyTool enumerating...");try{const u=await(0,l.pj)(),c=await(0,xn.j)(),h=u.getMonomerLib(),d=(0,Vn.o)(t,n?.value??"",i);let f;switch(e){case"macromolecule":f=o.Column.fromType(o.COLUMN_TYPE.STRING,"Enumerated",d.length).init((t=>d[t][0]));break;case"template":{const t=new Array(d.length);for(let e=0;e<d.length;e++){const n=d[e][0],r=zn.s.fromHelm(n,a);t[e]=r.getNotation()}f=o.Column.fromList(o.COLUMN_TYPE.STRING,"Enumerated",t),f.semType=o.SEMTYPE.MACROMOLECULE,f.setTag("polytool-data-role","template"),Er.applyNotationProviderForCyclized(f,"-");break}}const p=o.DataFrame.fromColumns([f]);if(await r.data.detectSemanticTypes(p),"template"==e&&Er.applyNotationProviderForCyclized(f,"-"),s){let t;if("macromolecule"===e){t=f;const e=await a.seqHelper.helmToAtomicLevel(t,s.chiralityEngine,s.highlightMonomers);p.columns.add(e.molCol,!1);const n=e.molCol;await async function(t,e,n,r,o,i=!1){const s=r.getSeqHandler(t),a=s.alphabet==Oe.YI.RNA||s.alphabet==Oe.YI.DNA,l=s.isHelm()&&a,u=!s.isHelm()&&a,c=t=>null==t?null:l?i?t:Math.floor(t/3):u&&i?3*t+1:t,h=i?await r.getHelmToMolfileConverter(n):null,d=new fn({max:100});function f(t,e){const s=t.get(e);if(null==s)return null;let a=d.get(s);return a||d.set(s,a=function(t,e){const s=r.getSeqHandler(t);if(i){const t=s.getHelm(e);return r.helmToAtomicLevelSingle(t,h,!1,!1).monomers}{const t=s.getSplitted(e),r=s.defaultBiotype,i=en().count(0).take(t.length).map((e=>({position:e,symbol:t.getCanonical(e),biotype:r}))).toArray(),a=s.alphabet,l=a==Oe.YI.RNA||a==Oe.YI.DNA?"RNA":"PEPTIDE",u=(0,yn.eM)([i],l,a,n,o);return(0,bn.gU)(i,u,a,l).monomers}}(t,e)),a}const p={targetCol:e,handler:(e,r,o)=>{const i=o.grid,s=e.tableRowIndex,a=e.gridRow,l=i.cell(o.name,a),u=pn();if(!u||u&&(u.dataFrameId!=t.dataFrame.id||u.gridRowIdx!=a||u.seqColName!=t.name||u.seqPosition!=r?.position)){if(u&&(mn(null),u.gridCell.render()),!r)return mn(null),!0;mn({gridCell:l,dataFrameId:t.dataFrame.id,gridRowIdx:a,seqColName:t.name,seqPosition:c(r?.position)??-1,getSubstruct:()=>{if(!r||"*"===r.symbol)return;const e=f(t,s);if(!e)return;const o=e.get(c(r?.position));return o?(0,vn.H)([o],n):{atoms:[],bonds:[],highlightAtomColors:[],highlightBondColors:[]}}}),l.render()}return!0},getSubstruct:r=>{if("true"!=e.getTag(".sequence-src-highlight-monomers"))return;if(null==r)return;if(!t.get(r))return;const o=f(t,r);return o?(0,vn.H)(o.values(),n):void 0}};return wn(t.temp,p),gn(e.temp,p),p}(t,n,h,a.seqHelper,c,!0)}else"template"===e&&(t=(await kn(f,s.generateHelm,!1,s.chiralityEngine,!1,s.rules))[0])}if(n){const t=o.Column.fromType(o.COLUMN_TYPE.STRING,n.colName,d.length).init((t=>d[t][1]));p.columns.add(t)}return p}finally{u.close()}}(t,w,A,s,!!a&&{generateHelm:i.generateHelm.value,chiralityEngine:i.chiralityEngine.value,highlightMonomers:i.highlightMonomers.value,rules:await v.getActive()},m);r.shell.addTableView(u)}}catch(t){In(t)}},O=P.dialog({title:Dn,showFooter:!0}).add(i.macromolecule.root).add(P.divH([P.divV([i.placeholders.root,i.enumeratorType.root,i.library.root],{style:{width:"50%"}}),P.divV([i.placeholdersBreadth.root],{style:{width:"50%"}})],{style:{width:"100%"}})).add(P.divH([P.divV([i.trivialNameCol.root,i.keepOriginal.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(E).onOK((()=>{L()}));return s.push(O.onClose.subscribe((()=>{u()}))),O.history((()=>({description:`${i.enumeratorType.value} ${i.placeholders.placeholdersValue?.map((t=>(t.position?.toString()??"")+": "+t.monomers?.join(", "))).join("; ")}`,placeholders:i.placeholders.stringValue,enumeratorType:i.enumeratorType.value,placeholdersBreadth:i.placeholdersBreadth.stringValue,trivialNameCol:i.trivialNameCol.stringValue,keepOriginal:i.keepOriginal.value,toAtomicLevel:i.toAtomicLevel.value,generateHelm:i.generateHelm.value,chiralityEngine:i.chiralityEngine.value,highlightMonomers:i.highlightMonomers.value,rules:b,library:i.library.value})),(t=>{i.enumeratorType.value=t.enumeratorType??Un.aK.Single,i.placeholders.stringValue=t.placeholders,i.placeholdersBreadth.stringValue=t.placeholdersBreadth,i.trivialNameCol.stringValue=t.trivialNameCol,i.keepOriginal.value=t.keepOriginal??!1,i.toAtomicLevel.value=t.toAtomicLevel??!0,i.generateHelm.value=t.generateHelm??!0,i.chiralityEngine.value=t.chiralityEngine??!1,i.highlightMonomers.value=t.highlightMonomers??!1,v.setActive(t.rules),i.library.value=t.library})),O}catch(t){throw u(),t}}(t,s);let a=!0;P.onSizeChanged(i.root).subscribe((()=>{if(a){const t=.7*e,r=.7*n;i.root.style.width=`${Math.min(e,t)}px`,i.root.style.height=`${Math.min(n,r)}px`,i.root.style.left=`${Math.floor((e-i.root.offsetWidth)/2)}px`,i.root.style.top=`${Math.floor((n-i.root.offsetHeight)/2)}px`,a=!1}s()})),s(),Ar.logger.debug("PolyToolEnumerateHelmUI: dialog before show"),i.show({width:Math.max(350,.7*e),resizable:!0}),Ar.logger.debug("PolyToolEnumerateHelmUI: dialog after show")}catch(u){const[c,h]=(0,Xe.AP)(u);Ar.logger.error(c,void 0,h)}}var Kn,Jn=n(3151);class Qn{constructor(t){this.rawLib=t}isValid(){return this.rawLib.every((t=>"object"==typeof t&&Object.values(Nn).every((e=>e in t&&"string"==typeof t[e]))))}getJsonMonomerLib(){const t=[];return this.rawLib.forEach((e=>{const n=this.prepareMonomer(e);t.push(n)})),t}prepareMonomer(t){const e={...Jn.pe};Object.entries(Nn).forEach((([n,r])=>{const o=t[r];e[n]=o}));let n="smiles";const r=t[Nn[n]],o=new Xn(r),i=o.getCappedSmiles();return e[n]=i,n="rgroups",e[n]=Zn.getRGroups(o.getNumberOfRGroups()),n="molfile",e[n]=new tr(o.getSmilesWithRGroups()).getMolfile(),e}}class Xn{constructor(t){let e=0;this.smilesWithRGroups=t.replace(/\[R(\d+)\]/g,((t,n)=>(++e,`[${n}*]`))),this.numberOfRGroups=e}getSmilesWithRGroups(){return this.smilesWithRGroups}getCappedSmiles(){return this.capRGroups()}getNumberOfRGroups(){return this.numberOfRGroups}capRGroups(){let t=this.smilesWithRGroups.replace("[1*]","[H:1]");return t=t.replace("[2*]","[OH:2]"),t.replace("[3*]","[H:3]")}}class Zn{constructor(){}static getRGroups(t){return Pn.slice(0,t)}}class tr{constructor(t){this.smilesWithRGroups=t}getMolfile(){let t=o.chem.convert(this.smilesWithRGroups,o.chem.Notation.Smiles,o.chem.Notation.MolBlock);return t=this.restoreRGPLine(t),t=this.fixRGroupSymbols(t),t}restoreRGPLine(t){return t.replace("M ISO","M RGP")}fixRGroupSymbols(t){return t.replace(/\bR\b/g,"R#")}}class er{constructor(t,e){this.fileName=t,this.fileContent=e,this.validateFileType();const n=o.DataFrame.fromCsv(this.fileContent),r=this.toJson(n);this.polyToolMonomerLib=new Qn(r),this.validateContent()}async getJson(){return this.polyToolMonomerLib.getJsonMonomerLib()}toJson(t){return Array.from({length:t.rowCount},((e,n)=>t.columns.names().reduce(((e,r)=>(e[r]=t.get(r,n),e)),{})))}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(t){t.table="table",t.seqCol="seqCol",t.generateHelm="generateHelm",t.chiralityEngine="chiralityEngine",t.rules="rules"}(Kn||(Kn={}));class nr{constructor(t){this.call=t,this.ruleInputs=new En._v(En.MU,En.yy,".json")}async initInputs(){const t=t=>this.call.inputParams[t],e=await this.ruleInputs.getForm();this.inputs={table:(()=>{const e=t(Kn.table);return P.input.table(e.property.caption,{value:e.value})})(),seqCol:(()=>{const e=t(Kn.seqCol);return P.input.column(e.property.caption,{value:e.value,table:e.value.dataFrame})})(),generateHelm:P.input.forProperty(t(Kn.generateHelm).property),chiralityEngine:P.input.forProperty(t(Kn.chiralityEngine).property),rules:{header:P.inlineText([Bn]),form:e}}}static async create(t){const e=new nr(t);return await e.initInputs(),e}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 t=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(((e,n)=>{P.dialog({title:Rn}).add(t).onOK((async()=>{const t=await this.getParams(),n=(await this.call.func.prepare(t).call(!0)).getOutputParamValue();e(n)})).onCancel((()=>{n(new Error("Cancelled by user"))})).show()}))}widget(){throw new Error("not implemented")}}class rr{onKeyDown(t,e){}onKeyPress(t,e){}onMouseEnter(t,e){}onMouseLeave(t,e){}onMouseDown(t,e){}onMouseUp(t,e){}onMouseMove(t,e){}onClick(t,e){}onDoubleClick(t,e){}}class or extends rr{constructor(t,e,n){super(),this.gridCol=t,this.tableCol=e,this.logger=n,this.subs=[],this.dirty=!0,this.destroyed=!1,this.viewerId=++or.viewerCounter,this.errors=[],this._onRendered=new et.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((t=>{try{this.destroyed||!this.tableCol||this.tableCol.dataFrame||this.destroy()}catch(t){this.logger.error(t)}})))),this.tableCol&&this.subs.push(r.events.onTableRemoved.subscribe((t=>{try{const e=t.args.dataFrame;this.tableCol?.dataFrame.id!==e.id||this.destroyed||this.destroy()}catch(t){this.logger.error(t)}}))),this.gridCol&&this.subs.push(r.events.onViewRemoving.subscribe((t=>{try{const e=t.args.view;this.gridCol?.dart&&this.gridCol.grid&&this.gridCol?.grid?.dart&&this.gridCol?.grid?.view?.id===e.id&&!this.destroyed&&this.destroy()}catch(t){this.logger.error(t)}})))}toLog(){return`${this.constructor.name}<${this.viewerId}>`}destroy(){for(const t of this.subs)t.unsubscribe();this.destroyed=!0}invalidateGrid(){this.gridCol&&this.gridCol.dart&&this.gridCol.grid?.invalidate()}reset(){this.dirty=!1}get onRendered(){return this._onRendered}invalidate(t){this.invalidateGrid()}async awaitRendered(t=1e4,e=`${t} timeout`){const n=`${this.toLog()}.awaitRendered()`;if(this.logger.debug(`${n}, start, testEvent before`),await(0,Ke.PE)(this._onRendered,(()=>{}),(()=>{this.invalidate()}),t,`${n}, ${e}`),this.errors.length>0){const t=this.errors[0];throw this.errors=[],t}this.logger.debug(`${n}, end`)}}or.viewerCounter=-1;const ir="rgb(100,100,100)",sr="rgb(0,0,0)",ar=s.zS;var lr,ur,cr;!function(t){t.maxMonomerLength=".mm.cellRenderer.maxMonomerLength"}(lr||(lr={})),function(t){t.applyToBackground=".m.cellRenderer.applyToBackground"}(ur||(ur={})),function(t){t.MSA="MSA",t.classic="classic"}(cr||(cr={}));const hr=new class{constructor(){this.color=ir,this.pivot=0,this.left=!1,this.transparencyRate=0,this.separator="",this.last=!1,this.drawStyle=cr.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 dr(t,e,n,r,i,s,a){var l,u,c;const h={...hr,...a};if(h.isMultiLineContext){t.textBaseline="middle",t.textAlign="center";let o=e;null!=h.maxLengthOfMonomer&&(o=ar(o,h.maxLengthOfMonomer));const a=Math.max(.1,1-(h.transparencyRate??0));t.globalAlpha=a;const l=t.measureText(o),u=l.fontBoundingBoxAscent+l.fontBoundingBoxDescent,c=r+(s-u)/2+l.fontBoundingBoxAscent;let d=h.color??ir;return d&&d!==ir||(d=sr),t.fillStyle=d,h.selectedPosition===h.wordIdx+1&&(t.save(),t.fillStyle="rgba(60, 177, 115, 0.2)",t.fillRect(n,r,i,s),t.restore(),t.fillStyle=d),t.fillText(o,n+i/2,c),t.globalAlpha=1,t.textBaseline="top",t.textAlign="start",n+i}a.logger?.debug("Bio: printLeftOrCentered(), start"),t.textAlign="start";let d=e.substring(0),f=h.last?"":h.separator;h.drawStyle===cr.MSA&&(f="");let p=!0,m=!0,g="difference";if(null!=h.gridCell&&null!=h.gridCell.cell.column&&(p=h.gridCell.cell.column.temp["color-code"]??!0,m=h.gridCell.cell.column.temp["compare-with-current"]??!0,g=h.gridCell.cell.column.temp["highlight-difference"]??"difference"),h.referenceSequence){const t=h.referenceSequence[h.wordIdx];m&&h.referenceSequence.length>0&&"difference"===g&&(h.transparencyRate=d==t?.7:h.transparencyRate),m&&h.referenceSequence.length>0&&"equal"===g&&(h.transparencyRate=d!=t?.7:h.transparencyRate)}null!=h.maxLengthOfMonomer&&(d=ar(d,h.maxLengthOfMonomer));const y=d+f;(l=h.monomerTextSizeMap)[y]??(l[y]=t.measureText(y));let b=h.monomerTextSizeMap[y];(u=h.monomerTextSizeMap)[d]??(u[d]=t.measureText(d));let v=h.monomerTextSizeMap[d].width;const C=s/2-(b.fontBoundingBoxAscent+b.fontBoundingBoxDescent)/2+1;(c=h.monomerTextSizeMap)[f]??(c[f]=t.measureText(f));const w=h.monomerTextSizeMap[f].width;function A(e,i){let a=p?h.color:sr;h.selectedPosition===h.wordIdx+1&&(t.fillStyle="rgba(60, 177, 115, 0.2)",t.fillRect(n+e-4,r-5,h.monomerTextSizeMap[d].width+8,s+10),a=o.Color.toHtml(o.Color.setAlpha(o.Color.fromHtml(a),255))),t.fillStyle=a,t.globalAlpha=1-h.transparencyRate,h.drawStyle===cr.classic&&(t.fillText(d,n+e,r+C),t.fillStyle="#808080",t.fillText(f,n+i,r+C)),h.drawStyle===cr.MSA&&t.fillText(d,n+e,r+C),t.globalAlpha=1}b=b.width,h.drawStyle===cr.MSA&&(v=h.maxWord[h.wordIdx],b=h.maxWord[h.wordIdx]);const x=(h.maxWord[h.wordIdx]??0)-(h.maxWord[0]??0);if(h.left||b>i)return A(x,x+v),n+x+v+w;{const t=(i-b)/2;return A(t,t+v),n+x+t+v}}var fr=n(3599);const pr="rgb(100,100,100)";class mr extends or{get separatorWidth(){return this.props?.fontCharWidth?this.props?.fontCharWidth:5}constructor(t,e,n,r,i){if(super(t,e,n),this.monomerLengthLimit=r,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.padding=5,this._leftThreeDotsPadding=0,this.props=this.propsProvider(),this._processedRows=o.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 t=[Oe.gp.positionShift,"renderMultiline"];this.subs.push(o.debounce(this.tableCol.dataFrame.onMetadataChanged.pipe(nt.filter((e=>e.args.source===this.tableCol&&t.includes(e.args.key)))),200).subscribe((t=>{this.reset()}))),this.subs.push(o.debounce(this.tableCol.dataFrame.onMetadataChanged.pipe(nt.filter((t=>t.args.source===this.tableCol&&t.args.key===Oe.gp.positionShift))),200).subscribe((t=>{this.reset()})))}}calculateFontBasedSpacing(t){const e=t.measureText("M");let n=12;if(this.tableCol?.temp[".mm.cellRenderer.fontSize"]){const t=this.tableCol.temp[".mm.cellRenderer.fontSize"];"number"!=typeof t||isNaN(t)||(n=Math.max(t,1))}return{lineHeight:Math.max(1.4*n,e.fontBoundingBoxAscent+e.fontBoundingBoxDescent+4),monomerSpacing:Math.max(2,.2*this.props.fontCharWidth)}}shouldUseMultilineRendering(t){return"true"===t.getTag("renderMultiline")}calculateMultiLineLayoutDynamic(t,e,n,r,o,i){if(this.dirty)try{this.reset()}catch(t){const[e,n]=(0,Xe.AP)(t);this.logger.error(e,void 0,n)}const{lineHeight:s,monomerSpacing:a}=this.calculateFontBasedSpacing(t),l=e-2*this.padding;let u=0;const c=[];if(r.length>0)for(let e=o;e<r.length;e++){const n=r.getOriginal(e),o=this.props.monomerToShort(n,i);c.push({text:o,posIdx:e}),u=Math.max(u,t.measureText(o).width)}if(0===c.length)return{lineLayouts:[],lineHeight:s};const h=u;let d=Math.floor((l+a)/(h+a));d=Math.max(1,d);const f=n-2*this.padding,p=Math.max(0,Math.floor(f/s)),m=[];let g=0;for(let t=0;t<p&&g<c.length;t++){const e=[];for(let t=0;t<d&&g<c.length;t++){const n=c[g],r=this.padding+t*(h+a);e.push({posIdx:n.posIdx,x:r,width:h,om:n.text,isSeparator:!1}),g++}m.push({lineIdx:t,elements:e})}return{lineLayouts:m,lineHeight:s}}async init(){await Promise.all([(async()=>{this.seqHelper=await(0,Ze.Q)(),this.invalidateGrid()})(),(async()=>{const t=await(0,l.pj)();this.sysMonomerLib=t.getMonomerLib()})()]),this.subs.push(this.sysMonomerLib.onChanged.subscribe((()=>{this.reset()}))),this.reset()}static getFontSettings(t){let e=12;return t&&t.temp[".mm.cellRenderer.fontSize"]&&"number"==typeof t.temp[".mm.cellRenderer.fontSize"]&&!isNaN(t.temp[".mm.cellRenderer.fontSize"])&&(e=Math.max(t.temp[".mm.cellRenderer.fontSize"],1)),{font:`${e}px monospace`,fontWidth:.6*e}}toLog(){return`MonomerPlacer<${this.viewerId}>`}getMonomerLib(){return this.tableCol.temp[".mm.cellRenderer.overriddenLibrary"]??this.sysMonomerLib}reset(){this.propsProvider&&(this.props=this.propsProvider()),this._processedRows=o.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(t,e){const n=this.seqHelper.getSeqHandler(this.tableCol);if(this.colWidth<e&&(this.colWidth=e,this.dirty=!0),this.dirty)try{this.reset()}catch(t){const[e,n]=(0,Xe.AP)(t);this.logger.error(e,void 0,n)}const r=n.isMsa()?this.getCellMonomerLengthsForSeqMsa():this.getCellMonomerLengthsForSeq(t);return[r,this.getSummedMonomerLengths(r)]}getSummedMonomerLengths(t){const e=new Array(t.length+1);e[0]=this.padding;for(let n=1;n<e.length;n++)e[n]=e[n-1]+t[n-1];let n=e[0];for(let t=1;t<e.length;t++)e[t]?n=e[t]:e[t]=n;return e}getCellMonomerLengthsForSeqValue(t,e){const n=this.seqHelper.getSeqHandler(this.tableCol),r=this.props.separatorWidth+1*this.props.fontCharWidth,o=this.positionShift,i=Math.ceil(e/r)+o,s=n.splitter(t),a=Math.min(i,s.length),l=new Array(a-o);let u=0;for(let t=o;t<a;++t){const r=s.getOriginal(t),i=this.props.monomerToShort(r,this.monomerLengthLimit),a=(n.isSeparator()?this.separatorWidth:this.props.separatorWidth)+i.length*this.props.fontCharWidth;if(l[t-o]=a,u+=a,u>e)break}return l}getCellMonomerLengthsForSeq(t){this.toLog(),null===this._monomerLengthList&&(this._monomerLengthList=new Array(this.tableCol.length).fill(null));const e=this.positionShift,n=this.seqHelper.getSeqHandler(this.tableCol),r=this.props.separatorWidth+1*this.props.fontCharWidth,o=Math.ceil(this.colWidth/r)+e,i=n.getSplitted(t),s=Math.min(o,i.length);let a=this._monomerLengthList[t];if(null===a||a.length!=s-e){a=this._monomerLengthList[t]=new Array(i.length);let r=0;for(let t=e;t<s;++t){const o=i.getOriginal(t),s=this.props.monomerToShort(o,this.monomerLengthLimit),l=(n.isSeparator()?this.separatorWidth:this.props.separatorWidth)+s.length*this.props.fontCharWidth;if(a[t-e]=l,r+=l,r>this.colWidth)break}}return a}getCellMonomerLengthsForSeqMsa(){var t;this.toLog(),null===this._monomerLengthList&&(this._monomerLengthList=new Array(1).fill(null)),(t=this._monomerLengthList)[0]??(t[0]=new Array(0));const e=this._monomerLengthList[0],{startIdx:n,endIdx:r}=(()=>{try{const t=this.gridCol&&this.gridCol.dart?this.gridCol.grid:null;return t&&t.dart?{startIdx:Math.max(Math.floor((t?.vertScroll.min??0)-10),0),endIdx:Math.min(Math.ceil((t?.vertScroll.max??0)+10),this.tableCol.length)}:{startIdx:0,endIdx:Math.min(this.tableCol.length,10)}}catch(t){return{startIdx:0,endIdx:Math.min(this.tableCol.length,10)}}})(),o=this.props.separatorWidth+1*this.props.fontCharWidth,i=this.positionShift,s=Math.ceil(this.colWidth/o)+i;for(let t=n;t<r;t++){if(this._processedRows.get(t)&&s<=this._processedMaxVisibleSeqLength)continue;const n=this.seqHelper.getSeqHandler(this.tableCol).getSplitted(t,s),r=Math.min(s,n.length);r-i>e.length&&e.push(...new Array(r-i-e.length).fill(o));let a=0;for(let t=i;t<r;++t){const r=n.getOriginal(t),o=this.props.monomerToShort(r,this.monomerLengthLimit),s=this.props.separatorWidth+o.length*this.props.fontCharWidth;if(e[t-i]=Math.max(e[t-i]??0,s),a+=s,a>=this.colWidth)break}this._processedMaxVisibleSeqLength=Math.max(this._processedMaxVisibleSeqLength,s),this._processedRows.set(t,!0)}return e}getPosition(t,e,n,r){const[o,i]=this.getCellMonomerLengths(t,n);return 0===this.seqHelper.getSeqHandler(this.tableCol).getSplitted(t).length?null:function(t,e,n){if((n??0)>0&&e<(t[0]??0)+n)return-1;e-=n??0;let r,o=100,i=0,s=t.length-1;for(;i<=s;){if(r=Math.floor((s+i)/2),t[r]<=e&&e<t[r+1])return r;if(e<t[r]?s=r-1:i=r+1,--o<=0)throw new Error(`Get position for pointer x = ${e} searching has not converged on ${JSON.stringify(t)}. `)}return null}(i,e,r)}setMonomerLengthLimit(t){this.monomerLengthLimit!=t&&(this.monomerLengthLimit=t,this.dirty=!0)}setSeparatorWidth(t){this.separatorWidth!=t&&(this.props.separatorWidth=t,this.dirty=!0)}get positionShift(){const t=Number.parseInt(this.tableCol?.tags[Oe.gp.positionShift]??"0")??0;return isNaN(t)?0:Math.max(t,0)}render(t,e,n,r,i,s,a){const l=s.grid?.dart&&s.grid?.canvas===t.canvas;if(!this.seqHelper)return;const u=this.tableCol,c=this.positionShift;t.save();try{const a=this.seqHelper.getSeqHandler(u);let h=this.monomerLengthLimit;if(lr.maxMonomerLength in u.tags){const t=parseInt(u.getTag(lr.maxMonomerLength));h=!isNaN(t)&&t?t:50}if(".mm.cellRenderer.maxMonomerLength"in u.temp){const t=u.temp[".mm.cellRenderer.maxMonomerLength"],e="number"==typeof t?t:parseInt(t);h=!isNaN(e)&&e?e:50}if("1"===u.temp[".mm.cellRenderer.settingsChanged"]||this.monomerLengthLimit!=h){let t=0;const e=8;t=u.temp[".mm.cellRenderer.gapLength"]??t,this.setMonomerLengthLimit(h),this.setSeparatorWidth(a.isMsa()?e:t),u.temp[".mm.cellRenderer.settingsChanged"]="0",this.dirty=!0}const d=s.cell.rowIndex,f=s.cell.value;l&&(r=function(t,e,n,r,o){return t?Math.max(Math.min(t.canvas.width/o-n,r)):Math.max(e.canvas.width/o-n,0)}(s.grid,t,e,r,window.devicePixelRatio)),t.beginPath(),t.rect(e,n,r,i),t.clip(),t.font=this.props?.font??"12px monospace",t.textBaseline="top";const p=u.meta.units,m=u.getTag(Oe.gp.aligned),g=u.getTag(Oe.gp.separator)??"",y=l?a.getSplitted(d):a.splitter(f);let b=cr.classic;m?.includes("MSA")&&p===Oe.Hi.SEPARATOR&&(b=cr.MSA);const v=u.temp["reference-sequence"],C=this.tableCol.temp["current-word"],w=(()=>{const t=(0,a.splitter)(null!=v&&""!==v?v:C??"");return en().count(0).take(t.length).slice(c).map((e=>t.getCanonical(e))).toArray()})(),A=Number.parseInt(u.getTag(Oe.gp.selectedPosition)??"-200");if(this.shouldUseMultilineRendering(u)){const l=[],d=this.calculateMultiLineLayoutDynamic(t,r,i,y,c,h);let f=n+this.padding;1===d.lineLayouts.length&&(f=n+(i-d.lineHeight)/2);for(const r of d.lineLayouts){const i=f+r.lineIdx*d.lineHeight;for(const h of r.elements){const f=e+h.x,p=h,m=p.posIdx,g=y.getCanonical(m);let b=pr;const v=this.getMonomerLib();v&&(b=v.getMonomerTextColor(a.defaultBiotype,g));let C=0;if(s.tableRowIndex!==u.dataFrame.currentRowIdx&&w.length>0){const t=m-c;t>=0&&t<w.length&&g===w[t]&&(C=.7)}l.push({lineIdx:r.lineIdx,monomerIdx:m-c,bounds:new o.Rect(h.x,i-n,h.width,d.lineHeight),sequencePosition:m}),dr(t,p.om,f,i,h.width,d.lineHeight,{color:b,isMultiLineContext:!0,transparencyRate:C,selectedPosition:isNaN(A)||A<1?void 0:A,wordIdx:m})}}null!==s.tableRowIndex&&this._cellBounds.set(s.tableRowIndex,l)}else{this._leftThreeDotsPadding=this.shouldRenderShiftedThreeDots(c)?t.measureText("...").width:0;let[,o]=this.getCellMonomerLengths(s.tableRowIndex,r);l||(o=this.getSummedMonomerLengths(this.getCellMonomerLengthsForSeqValue(f,r)));const u=this.props.separatorWidth+1*this.props.fontCharWidth,d=Math.min(y.length,Math.ceil(r/u)+c);for(let l=c;l<d;++l){const u=l<y.length?y.getOriginal(l):a.defaultGapOriginal,d=l<y.length?y.getCanonical(l):a.defaultGapOriginal;let f=pr;this.getMonomerLib()&&(f=this.getMonomerLib().getMonomerTextColor(a.defaultBiotype,d));const p=l===y.length-1,m={color:f,pivot:0,left:!0,transparencyRate:0,separator:(y?.graphInfo?.disjointSeqStarts?.indexOf(l+1)??0)>0?"|":g,last:p,drawStyle:b,maxWord:o,wordIdx:l-c,gridCell:s,referenceSequence:w,maxLengthOfMonomer:h,monomerTextSizeMap:this._monomerLengthMap,logger:this.logger,selectedPosition:isNaN(A)||A<1?void 0:A-c};dr(t,u,e+this.padding+this._leftThreeDotsPadding,n,r,i,m)}if(this.shouldRenderShiftedThreeDots(c)){const a={color:pr,pivot:0,left:!0,transparencyRate:0,separator:g,last:!1,drawStyle:b,maxWord:o,wordIdx:0,gridCell:s,maxLengthOfMonomer:h,monomerTextSizeMap:this._monomerLengthMap,logger:this.logger};dr(t,"...",e+this.padding,n,r,i,a)}}}catch(t){const[e,n]=(0,Xe.AP)(t);this.logger.error(e,void 0,n),this.errors.push(t)}finally{t.restore()}}shouldRenderShiftedThreeDots(t){return t>0&&(!this.gridCol||!this.gridCol.dart||!this.gridCol.grid||!this.gridCol.grid.dart||(this.gridCol.grid.props.colHeaderHeight??0)<=50)}onMouseMove(t,e){const n=`${this.toLog()}.onMouseMove()`;if(!this.seqHelper||null==t.tableRowIndex)return;const r=this.positionShift,o=t.bounds,i=e.offsetX-t.gridColumn.left+(t.gridColumn.left-o.x),s=e.offsetY-o.y;this.gridCol?.grid?.canvas&&(this.gridCol.grid.canvas.style.cursor="default");let a=null;const l=this._cellBounds.get(t.tableRowIndex);if(l){for(const t of l)if(t.bounds.contains(i,s)){a=t.monomerIdx;break}}else{const e=this.shouldRenderShiftedThreeDots(r)&&(this._leftThreeDotsPadding??0)>0?this._leftThreeDotsPadding:0;a=this.getPosition(t.tableRowIndex,i,o.width,e)}this.logger.debug(`${n}, argsX: ${i}, argsY: ${s}, left: ${a}`);const u=this.seqHelper.getSeqHandler(this.tableCol),c=u.getSplitted(t.tableRowIndex);if(null!==a&&a>=0&&a+r<c.length){const n=u.alphabet??Oe.YI.UN,o={position:a,biotype:n===Oe.YI.RNA||n===Oe.YI.DNA?fr.o.NUCLEOTIDE:fr.o.AA,symbol:c.getCanonical(a+r)},i=[];let s=this._monomerStructureMap[o.symbol];if(!s){const t=this.getMonomerLib();s=this._monomerStructureMap[o.symbol]=t?t.getTooltip(o.biotype,o.symbol):P.divText("Monomer library is not available")}i.push(s),P.tooltip.show(P.divV(i),e.x+16,e.y+16),An(t,o)}else-1===a?P.tooltip.show(P.divText(`${Math.min(r,c.length)} hidden monomers`),e.x+16,e.y+16):P.tooltip.hide(),An(t,null)}}class gr extends mr{constructor(t,e,n,r){super(t,e,Ar.logger,n,(()=>{const t=r.getSeqHandler(e),{font:n,fontWidth:o}=mr.getFontSettings(e);return{seqHandler:t,font:n,fontCharWidth:o,separatorWidth:11,monomerToShort:Oe.zS}}))}onMouseMove(t,e){super.onMouseMove(t,e)}}class yr{get defaultGapOriginal(){return""}constructor(t,e){this.separator=t,this.helmHelper=e,this.separatorSplitter=(0,Oe.dh)(this.separator),this.splitter=this._splitter.bind(this)}setUnits(){}_splitter(t){const e=this.separatorSplitter(t);return new br(en().count(0).take(e.length).map((t=>e.getOriginal(t))).toArray(),i.b9[i.Hi.SEPARATOR])}getHelm(t,e){return zn.s.fromSeparator(t,this.helmHelper).getHelm()}createCellRendererBack(t,e){const n=new gr(t,e,4,this.helmHelper.seqHelper);return n.init().then((()=>{})),n}}class br extends s.Mu{getCanonical(t){if(this.isGap(t))return i._S;const e=this.getOriginal(t);let n=e;return e.startsWith("{")?n=e.slice(1):e.endsWith("}")?n=e.slice(0,-1):e.startsWith("(")?n=e.replace(/^\(.\d+\)/,""):e.endsWith(")")&&(n=e.replace(/\(\d+\)$/,"")),n}constructor(t,e){super(t,e)}}var vr=function(t,e,n,r){var o,i=arguments.length,s=i<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(i<3?o(s):i>3?o(e,n,s):o(e,n))||s);return i>3&&s&&Object.defineProperty(e,n,s),s},Cr=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},wr=function(t,e){return function(n,r){e(n,r,t)}};r.decorators||(r.decorators={}),["func","init","param","panel","editor","demo","app","appTreeBrowser","fileHandler","fileExporter","model","viewer","filter","cellRenderer","autostart","dashboard","folderViewer","semTypeDetector","packageSettingsEditor","functionAnalysis","converter","fileViewer","model","treeBrowser","polyfill"].forEach((t=>{r.decorators[t]||(r.decorators[t]=function(t){return function(t,e,n){}})}));const Ar=new R({debug:!0});let xr=null;class Er{static async oligoToolkitApp(){await Ar.initLibData();const t=await async function(t){const e={"Mermadesynthesis:merMadeSynthesis":{tabName:"SYNTHESIZE",parameters:Je(t)}},n={};for(const[t,o]of Object.entries(e)){let e;try{e=await r.functions.call(t,o.parameters);const i=new ze(o.tabName,e);i.initView(),n[o.tabName]=()=>i.getView()}catch(e){console.warn(`Plugin ${t} not loaded, reason:`,e);continue}}return n}(Ar);if(!t)throw new Error("External app view factories not loaded");const e=new Ye(t,Ar);return await e.getAppView()}static async init(){return null===xr&&Ar.startInit(xr=async function(){const[t]=await Promise.all([(0,Qe.b2)()]);Ar.completeInit(t)}()),xr}static async oligoTranslatorApp(){return await Tr("Oligo Translator")}static async oligoPatternApp(){return await Tr("Oligo Pattern")}static async oligoStructureApp(){return await Tr("Oligo Structure")}static async getTranslationHelper(){return await Ar.initLibData(),Ar}static getCodeToWeightsMap(){const t=Ar.monomerLibWrapper.getCodesToWeightsMap();return Object.fromEntries(t)}static validateSequence(t){const e=Ar.createSequenceValidator(t),n=Ar.createFormatDetector(t).getFormat();return null!==n&&e.isValidSequence(n)}static getMolfileFromGcrsSequence(t,e){return new xe(t,e,"GCRS").convert()}static linkStrands(t){return Ee(t,!0)}static async demoTranslateSequence(){await async function(){await b((async()=>{const t=await Er.oligoTranslatorApp();r.shell.addView(t)}))}()}static async demoOligoPattern(){await async function(){await b((async()=>{const t=await Er.oligoPatternApp();r.shell.addView(t)}))}()}static async demoOligoStructure(){await async function(){await b((async()=>{const t=await Er.oligoStructureApp();r.shell.addView(t),["Afcgacsu","Afcgacsu","Afcgacsu"].forEach((async(t,e)=>{await async function(t,e){await(0,Ke.cb)(500);const n=document.querySelectorAll(".st-colored-text-input > textarea")[t];n.value=e;const r=new Event("input");n.dispatchEvent(r)}(e,t)}))}))}()}static async translateOligonucleotideSequence(t,e,n){return await Ar.initLibData(),Ar.createFormatConverter(t,e).convertTo(n)}static async polyToolConvertTopMenu(){await async function(){await Ar.initPromise;let t=null;try{t=await async function(){const t=[],e=()=>{for(const e of t)e.unsubscribe()};try{let n;const i=r.shell.t.columns.bySemTypeAll(o.SEMTYPE.MACROMOLECULE),s=i.filter((t=>Ar.seqHelper.getSeqHandler(t).notation===Oe.Hi.CUSTOM));if(!n){if(i.length<1)throw new Error("No dataframe with macromolecule columns open");if(s.length<1){const t=o.Func.find({package:"Bio",name:"toAtomicLevel"})[0];return t?(t.prepare().edit(),null):(r.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:t=>s.includes(t)}),l=P.input.bool(Mn,{value:!0});P.tooltip.bind(l.root,"Add HELM column");const u=P.input.bool("Linearize",{value:!0});P.tooltip.bind(u.root,"Make representation linear if possible");const c=P.input.bool(Ln,{value:!0}),h=P.input.bool(On,{value:!0});let d;const f=new En._v(En.MU,En.yy,".json",{onValueChanged:t=>{d=t}}),p=P.inlineText([Bn]);P.tooltip.bind(p,"Add or specify rules to use");const m=await f.getForm(),g=P.divV([a,l,u,c,h,p,m]),y=async()=>{try{const t=await f.getActive();await kn(a.value,l.value,u.value,c.value,h.value,t)}catch(t){In(t)}},b=P.dialog(Rn).add(g).onOK((()=>{y()}));return t.push(b.onClose.subscribe((()=>{e()}))),b.history((()=>({generateHelm:l.value,chiralityEngine:c.value,rules:d})),(t=>{l.value=t.generateHelm,c.value=t.chiralityEngine,f.setActive(t.rules)})),b}catch(t){throw e(),t}}(),t?.show()}catch(t){const[e,n]=(0,Xe.AP)(t);r.shell.warning("To run PolyTool Conversion, open a dataframe with macromolecules"),Ar.logger.error(e,void 0,n)}}()}static async getPolyToolConvertEditor(t){const e=await nr.create(t);return await e.showDialog()}static async polyToolConvert2(t,e,n,r,o){return(await kn(e,n,!1,r,!1,o))[0]}static async polyToolEnumerateHelmTopMenu(){await Yn(r.shell.tv?.dataFrame.currentCell)}static async polyToolEnumerateChemTopMenu(){$n()}static async polyToolColumnChoice(t,e){var n;(function(t){t.semType=o.SEMTYPE.MACROMOLECULE,t.setTag("aligned","SEQ"),t.setTag("alphabet",Oe.YI.PT)})(n=e),n.meta.units=Oe.Hi.SEPARATOR,n.setTag("separator","-"),await r.data.detectSemanticTypes(t)}static async createMonomerLibraryForPolyTool(t){const e=await t.readAsString(),n=new er(t.fileName,e),r=await n.getJson(),i=t.fileName.replace(/\.csv$/,".json"),s=JSON.stringify(r,null,2);o.Utils.download(i,s)}static async ptEnumeratorHelmApp(){await Yn()}static async ptEnumeratorChemApp(){$n()}static async getPtHelmEnumeratorDialog(t){return Yn(t)}static async getPtChemEnumeratorDialog(t){return $n(t)}static async getPolyToolCombineDialog(){!async function(){const t=[],e=P.divV([]),n=i=>{const s=(()=>{const t=P.divH([]),e=P.input.table("Table",{value:void 0,tooltipText:"Table with sequences"}),n=P.input.choice("Column",{items:[],value:void 0,tooltipText:"Sequence column"});return e.onChanged.subscribe((async()=>{const t=e.value;if(!t)return n.items=[],void(n.value=null);await t.meta.detectSemanticTypes(),await r.data.detectSemanticTypes(t);const i=Array.from(t.columns.categorical),s=i.map((t=>t.name));n.items=s,n.value=i.find((t=>t.semType===o.SEMTYPE.MACROMOLECULE))?.name??s.find((t=>{const e=t.toLowerCase();return e.includes("seq")||e.includes("pep")}))??s[0]})),t.appendChild(e.root),t.appendChild(n.root),t.style.alignItems="center",{root:t,getValue:()=>({table:e.value,column:n.value})}})(),a=P.icons.delete((()=>{if(!s.root.parentElement||t.length<2)return;s.root.remove();const e=t.indexOf(s);-1!==e&&t.splice(e,1)}),"Remove"),l=P.icons.add((()=>{let e=t.indexOf(s);-1===e&&(e=t.length),n(e+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 u=t[i];u?e.insertBefore(s.root,u.root):e.appendChild(s.root),t.splice(i,0,s)};n(0);const i=P.input.string("Separator",{value:"-",tooltipText:"Separator for sequences",nullable:!1});P.dialog("Combine Sequences").add(e).add(i.root).onOK((async()=>{if(!function(){const e=t.map((t=>t.getValue())),n=e.map((t=>t.table)),r=e.map((t=>t.column));return n.every((t=>!!t))&&r.every((t=>!!t))}())return void r.shell.error("Please fill all the fields");const e=t.map((t=>t.getValue())),n=e.map((t=>t.table)),s=e.map((t=>t.column)),a=i.value,l=s.map(((t,e)=>n[e].col(t).toList().filter((t=>!!t))));let u=0;const c=l.reduce(((t,e)=>t*e.length),1);if(c>1e7)return void r.shell.error("Too many combinations. Maximum allowed is 10M");const h=new Array(c).fill(null),d=(t,e)=>{if(e===l.length)return void(h[u++]=t);const n=`${t}${t?a:""}`,r=l[e];for(let t=0;t<l[e].length;t++)d(n+r[t],e+1)};d("",0);const f=o.DataFrame.fromColumns([o.Column.fromStrings("Combined Sequences",h)]);f.name="Combined Sequences",await f.meta.detectSemanticTypes(),await r.data.detectSemanticTypes(f),r.shell.addTableView(f)})).show({resizable:!0})}()}static applyNotationProviderForCyclized(t,e){t.setTag("aligned","SEQ"),t.setTag("alphabet","UN"),t.setTag(".alphabetIsMultichar","true"),t.meta.units=i.Hi.CUSTOM,t.tags["polytool-data-role"]="template",t.temp[a.notationProvider]=new yr(e,Ar.helmHelper)}}async function Tr(t){await Ar.initLibData();const e=function(t,e){switch(t){case"Oligo Translator":return new We(e);case"Oligo Pattern":return new ie(e);case"Oligo Structure":return new Le(e);default:throw new Error(`Unknown app name: ${t}`)}}(t,Ar);return await e.getAppView()}vr([r.decorators.app({icon:"img/icons/toolkit.png",browsePath:"Peptides | Oligo Toolkit",name:"Oligo Toolkit"}),Cr("design:type",Function),Cr("design:paramtypes",[]),Cr("design:returntype",Promise)],Er,"oligoToolkitApp",null),vr([r.decorators.init(),Cr("design:type",Function),Cr("design:paramtypes",[]),Cr("design:returntype",Promise)],Er,"init",null),vr([r.decorators.app({icon:"img/icons/translator.png",browsePath:"Peptides | Oligo Toolkit",name:"Oligo Translator"}),Cr("design:type",Function),Cr("design:paramtypes",[]),Cr("design:returntype",Promise)],Er,"oligoTranslatorApp",null),vr([r.decorators.app({icon:"img/icons/pattern.png",browsePath:"Peptides | Oligo Toolkit",name:"Oligo Pattern"}),Cr("design:type",Function),Cr("design:paramtypes",[]),Cr("design:returntype",Promise)],Er,"oligoPatternApp",null),vr([r.decorators.app({icon:"img/icons/structure.png",browsePath:"Peptides | Oligo Toolkit",name:"Oligo Structure"}),Cr("design:type",Function),Cr("design:paramtypes",[]),Cr("design:returntype",Promise)],Er,"oligoStructureApp",null),vr([r.decorators.func({outputs:[{type:"object",name:"result"}]}),Cr("design:type",Function),Cr("design:paramtypes",[]),Cr("design:returntype",Promise)],Er,"getTranslationHelper",null),vr([r.decorators.func({outputs:[{type:"object",name:"result"}]}),Cr("design:type",Function),Cr("design:paramtypes",[]),Cr("design:returntype",Object)],Er,"getCodeToWeightsMap",null),vr([r.decorators.func(),Cr("design:type",Function),Cr("design:paramtypes",[String]),Cr("design:returntype",Boolean)],Er,"validateSequence",null),vr([r.decorators.func({name:"validateSequence"}),Cr("design:type",Function),Cr("design:paramtypes",[String,Boolean]),Cr("design:returntype",String)],Er,"getMolfileFromGcrsSequence",null),vr([r.decorators.func(),wr(0,r.decorators.param({type:"object"})),Cr("design:type",Function),Cr("design:paramtypes",[Object]),Cr("design:returntype",String)],Er,"linkStrands",null),vr([r.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"}),Cr("design:type",Function),Cr("design:paramtypes",[]),Cr("design:returntype",Promise)],Er,"demoTranslateSequence",null),vr([r.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"}),Cr("design:type",Function),Cr("design:paramtypes",[]),Cr("design:returntype",Promise)],Er,"demoOligoPattern",null),vr([r.decorators.func({meta:{demoPath:"Bioinformatics | Oligo Toolkit | Structure",path:"%20/apps/Tutorials/Demo/Bioinformatics/Oligonucleotide%20Sequence:%20Visualize%20duplex"},description:"Visualize duplex and save SDF"}),Cr("design:type",Function),Cr("design:paramtypes",[]),Cr("design:returntype",Promise)],Er,"demoOligoStructure",null),vr([r.decorators.func(),Cr("design:type",Function),Cr("design:paramtypes",[String,String,String]),Cr("design:returntype",Promise)],Er,"translateOligonucleotideSequence",null),vr([r.decorators.func({"top-menu":"Bio | PolyTool | Convert...",name:"polyToolConvert",description:"Perform cyclization of polymers"}),Cr("design:type",Function),Cr("design:paramtypes",[]),Cr("design:returntype",Promise)],Er,"polyToolConvertTopMenu",null),vr([r.decorators.editor(),Cr("design:type",Function),Cr("design:paramtypes",[o.FuncCall]),Cr("design:returntype",Promise)],Er,"getPolyToolConvertEditor",null),vr([r.decorators.func({editor:"SequenceTranslator:getPolyToolConvertEditor"}),wr(1,r.decorators.param({options:{caption:"Sequence"}})),wr(2,r.decorators.param({options:{initialValue:"true"}})),wr(3,r.decorators.param({options:{initialValue:"true"}})),wr(4,r.decorators.param({type:"object"})),Cr("design:type",Function),Cr("design:paramtypes",[o.DataFrame,o.Column,Boolean,Boolean,Array]),Cr("design:returntype",Promise)],Er,"polyToolConvert2",null),vr([r.decorators.func({"top-menu":"Bio | PolyTool | Enumerate HELM...",name:"polyToolEnumerateHelm",description:"Perform cyclization of polymers"}),Cr("design:type",Function),Cr("design:paramtypes",[]),Cr("design:returntype",Promise)],Er,"polyToolEnumerateHelmTopMenu",null),vr([r.decorators.func({"top-menu":"Bio | PolyTool | Enumerate Chem...",name:"polyToolEnumerateChem",description:"Perform cyclization of polymers"}),Cr("design:type",Function),Cr("design:paramtypes",[]),Cr("design:returntype",Promise)],Er,"polyToolEnumerateChemTopMenu",null),vr([r.decorators.func(),wr(0,r.decorators.param({options:{description:"Input data table"}})),Cr("design:type",Function),Cr("design:paramtypes",[o.DataFrame,o.Column]),Cr("design:returntype",Promise)],Er,"polyToolColumnChoice",null),vr([r.decorators.func(),Cr("design:type",Function),Cr("design:paramtypes",[o.FileInfo]),Cr("design:returntype",Promise)],Er,"createMonomerLibraryForPolyTool",null),vr([r.decorators.func({meta:{icon:"img/icons/structure.png",browsePath:"Peptides | PolyTool"},tags:["app"],name:"HELM Enumerator"}),Cr("design:type",Function),Cr("design:paramtypes",[]),Cr("design:returntype",Promise)],Er,"ptEnumeratorHelmApp",null),vr([r.decorators.func({meta:{icon:"img/icons/structure.png",browsePath:"Peptides | PolyTool"},tags:["app"],name:"Chem Enumerator"}),Cr("design:type",Function),Cr("design:paramtypes",[]),Cr("design:returntype",Promise)],Er,"ptEnumeratorChemApp",null),vr([r.decorators.func({name:"Polytool Helm Enumerator dialog"}),wr(0,r.decorators.param({type:"object",options:{nullable:!0}})),Cr("design:type",Function),Cr("design:paramtypes",[o.Cell]),Cr("design:returntype",Promise)],Er,"getPtHelmEnumeratorDialog",null),vr([r.decorators.func({name:"Polytool Chem Enumerator dialog"}),wr(0,r.decorators.param({type:"object",options:{nullable:!0}})),Cr("design:type",Function),Cr("design:paramtypes",[o.Cell]),Cr("design:returntype",Promise)],Er,"getPtChemEnumeratorDialog",null),vr([r.decorators.func({name:"Combine Sequences","top-menu":"Bio | PolyTool | Combine Sequences..."}),Cr("design:type",Function),Cr("design:paramtypes",[]),Cr("design:returntype",Promise)],Er,"getPolyToolCombineDialog",null),vr([r.decorators.func({name:"applyNotationProviderForHarmonizedSequence"}),wr(0,r.decorators.param({type:"column"})),Cr("design:type",Function),Cr("design:paramtypes",[o.Column,String]),Cr("design:returntype",void 0)],Er,"applyNotationProviderForCyclized",null)},5412:(t,e,n)=>{"use strict";n.d(e,{m:()=>l});var r=n(6082),o=n(4328),i=n(4971),s=n(6077),a=n(2003);async function l(t,e,n,l,u,c,h,d,f){const p=(await f.helmToAtomicLevel(t,l,u,h)).molCol,m=n.filter((t=>t)).length;if(c&&m>0){const t=new Array(m);let l=0;for(let r=0;r<n.length;r++)n[r]&&(t[l]=e[r],l++);const u=r.Column.fromStrings("helm",t);u.semType=r.SEMTYPE.MACROMOLECULE,u.meta.units=a.Hi.HELM,u.setTag(r.TAGS.CELL_RENDERER,"helm");const c=(await(0,i.pj)()).getMonomerLib();try{const t=await(0,s.C4)(r.DataFrame.create(0),u,c,f,d);l=0;for(let e=0;e<n.length;e++)n[e]&&(p.set(e,t.molCol.get(l)),l++)}catch(t){o.shell.warning("PolyTool was not able to linearize sequences")}}return function(t){for(let e=0;e<t.length;e++)t.set(e,t.get(e).replaceAll("undefined","H")),t.set(e,t.get(e).replaceAll("Oh","O").replaceAll("OH","O")),t.set(e,t.get(e).replaceAll("0.000000 3","0.000000 0")),t.set(e,t.get(e).replaceAll("?","O")),t.set(e,t.get(e).replaceAll(" 0 3\n"," 0 0\n")),t.set(e,t.get(e).replaceAll("RGROUPS=(1 1)",""))}(p),p}},6307:(t,e,n)=>{"use strict";n.d(e,{s:()=>f});var r=n(2125),o=n(8438),i=n(6694);function s(t,e){let n="";for(let t=0;t<e.length;t++){t>0&&(n+="|"),n+=`PEPTIDE${t+1}{`;for(let r=0;r<e[t].length;r++){r>0&&(n+=".");const o=e[t][r];n+=o.length>1?`[${o}]`:o}n+="}"}n+="$";for(let o=0;o<t.length;o++)o>0&&(n+="|"),n+=`PEPTIDE${t[o].fChain+1},PEPTIDE${t[o].sChain+1},`,n+=`${(0,r.M)(t[o].fMonomer-1,e)[0]+1}:R${t[o].fR}-`,n+=`${(0,r.M)(t[o].sMonomer-1,e)[0]+1}:R${t[o].sR}`;return n+="$$$V2.0",n}function a(t,e,n,r=0,o=[],i=[]){let[s,a,l,u,c]=[!1,!1,!1,-1,-1];for(let h=0;h<t.length;h++)if(t[h].includes(e)){if(s){if(l&&(n||t[h]==i[r]+e)){a=!0,c=h;break}if(l||!n&&t[h]!=o[r]+e)continue;a=!0,c=h;break}if(n)s=!0,l=!0,u=h;else if(t[h]==o[r]+e)s=!0,l=!0,u=h;else{if(t[h]!=i[r]+e)continue;s=!0,l=!!n,u=h}}return[s,a,l,u,c]}function l(t,e){const n=[];for(let r=0;r<e.length;r++){const o=`(${e[r].code})`,[s,l]=(0,i.Ln)(e[r]);if(s.length>0)for(let e=0;e<s.length;e++){const[i,u,c,h,d]=a(t,o,!1,e,s,l);i&&u&&(c?n.push({firstIdx:h,secondIdx:d,ruleIdx:r}):n.push({firstIdx:d,secondIdx:h,ruleIdx:r}))}else{const[e,i,s,l,u]=a(t,o,!0);if(!e||!i)continue;s?n.push({firstIdx:l,secondIdx:u,ruleIdx:r}):n.push({firstIdx:u,secondIdx:l,ruleIdx:r})}}return n}function u(t,e,n){const r=[],o=[],i=[],s=[],a=n.length;for(let l=0;l<a;l++){if(-1==n[l].firstIdx)continue;const a=n[l].ruleIdx,u=t[a].code;e[n[l].firstIdx]=e[n[l].firstIdx].replace(`(${u})`,""),e[n[l].secondIdx]=e[n[l].secondIdx].replace(`(${u})`,""),r.push(n[l].firstIdx+1),o.push(n[l].secondIdx+1),i.push(t[a].firstLinkingGroup),s.push(t[a].secondLinkingGroup)}return[r,o,i,s]}function c(t,e,n){const r=[],o=[],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,u=n[a].ruleIdx,c=t[u].code;e[s]=e[s].replace(`(${c})`,"")+`_${t[u].name}`,e[l]=e[l].replace(`(${c})`,"")+`_${t[u].name}`,r.push(s+1),o.push(l+1),i.push(n[a].ruleIdx)}return[r,o,i]}var h=n(3599);function d(t,e,n){const r=n.createHelmWebEditor().editor.m;let o=0;const i=new JSDraw2.Point(0,0);for(let t=0;t<e.length;t++)for(let n=0;n<e[t].length;n++){if(e[t][n]){const s=e[t][n],a={type:h.o.AA,i:t,j:n,continuousId:o},l=new JSDraw2.Atom(i,s,a);if(r.addAtom(l),0!==n){const t=r.atoms[o-1],e=r.atoms[o],n=new JSDraw2.Bond(t,e);n.r1=2,n.r2=1,r.addBond(n)}o++,i.x+=JSDraw2.Editor.BONDLENGTH}i.y+=4*JSDraw2.Editor.BONDLENGTH}for(let e=0;e<t.length;e++){const n=r.atoms[t[e].fMonomer-1],o=r.atoms[t[e].sMonomer-1],i=new JSDraw2.Bond(n,o);i.r1=t[e].fR,i.r2=t[e].sR,r.addBond(i)}return r}class f{constructor(t,e,n){this.helmHelper=n,this.underRules=!1,this.posToPosUnderRules=[],this.linkages=e,this.monomers=t,this.mol=d(e,t,n)}static fromSeparator(t,e){const[n,r]=function(t){const e=[],n=[],r=/(\(.\d+\))?\{[^\}]*\}/g,o=[];o.push(t.replaceAll(r,""));const i=t.matchAll(r);for(const t of i){const e=t[0];e&&o.push(e)}let s=0;for(let t=0;t<o.length;t++){const r=o[t].split("-"),i=new Array(r.length);let a=0;for(let e=0;e<r.length;e++){const o=r[e].replace("{","").replace("}","");""!==o?(i[e]=o,s++,a++):n.push({fChain:t,sChain:t+1,fMonomer:s,sMonomer:s+1,fR:1,sR:1})}e.push(i.slice(0,a))}return[n,e]}(t);return new f(r,n,e)}static fromHelm(t,e){const[n,i]=function(t){const e=/(\w+\{.*\})\$(.*)\$(.*)\$(.*)\$/g.exec(t),n=[e[1],e[2],e[3],e[4]],i=n[0].split("|"),s=n[1].split("|"),a=new Array(i.length),l=[];for(let t=0;t<i.length;t++){const e=i[t].indexOf("{"),n=i[t].indexOf("}");a[t]=i[t].slice(e+1,n).split(".").map((t=>(0,o.D)(t)))}for(let t=0;t<s.length;t++)if(""!==s[t]&&"V2.0"!==s[t]){const e=s[t].split(","),n=parseInt(e[0].replace("PEPTIDE",""))-1,o=parseInt(e[1].replace("PEPTIDE",""))-1,i=e[2].split("-"),u=i[0].split(":"),c=i[1].split(":");l.push({fChain:n,sChain:o,fMonomer:(0,r.j)(parseInt(u[0]),n,a),sMonomer:(0,r.j)(parseInt(c[0]),o,a),fR:parseInt(u[1].replace("R","")),sR:parseInt(c[1].replace("R",""))})}return[l,a]}(t);return new f(i,n,e)}getNotation(){return function(t){const e=t.atoms,n=t.bonds,r=[],o=[];for(let t=0;t<n.length;t++)n[t].a1.bio.i!==n[t].a2.bio.i&&o.push(t);for(let t=0;t<e.length;t++){const n=e[t].bio?.i;n+1>r.length?r.push(1):r[n]++}const i=new Array(r.length);let s=0;for(let t=0;t<r.length;t++){const n=new Array(r[t]);for(let o=0;o<r[t];o++)n[o]=e[s].elem,s++;i[t]=n}let a="";for(let t=0;t<i.length;t++){let e="";for(let n=0;n<i[t].length;n++)e+=`${0==n?"":"-"}${i[t][n]}`;if(0!==t){const t=/(\(.\d+\))/,n=e.match(t);e=e.replace(n?.[0],""),e=`${n?n?.[0]:""}{${e}}`}else if(i.length>1){const t=0==n[o[0]].a1.bio.i&&0==n[o[0]].a1.bio.j,r=1==n[o[0]].a2.bio.i&&0==n[o[0]].a1.bio.j;t&&r&&(e+="-")}a+=e}return a}(this.mol)}getHelm(){return this.underRules?s(this.linkagesUnderRules,this.monomersUnderRules):s(this.linkages,this.monomers)}applyRules(t){const e=this.getNotation(),[n,r,o]=function(t,e){const n=[],r=[],o=[],i=e.heterodimerCode,s=e.homodimerCode,a=null!==i?t.split(`(${e.heterodimerCode})`):"";null!==i&&a.length>1?(o.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("}","")),r.push(!1),r.push(!1)):(n.push(t),r.push(!1));for(let t=0;t<n.length;t++)if(null!==s&&n[t].includes(`(${s})`)){const e=n.length;o.push({fChain:t,sChain:e,fMonomer:1,sMonomer:1,fR:1,sR:1});const i=n[t].replace(`(${s})`,""),a=i.indexOf("{"),l=i.slice(0,a),u=i.replace(l,"").replaceAll("{","").replaceAll("}","");n[t]=l+u,n.push(u),r.push(!0)}return[o,n,r]}(e,t),i=new Array(r.length);let s=0;for(let t=0;t<r.length;t++)if(i[t]=r[t].split("-"),o[t]){const e=this.posToPosUnderRules.length-i[t].length;for(let n=0;n<i[t].length;n++)this.posToPosUnderRules[e+n].push(s),s++}else for(let e=0;e<i[t].length;e++)this.posToPosUnderRules.push([s]),s++;!function(t,e,n){for(let r=0;r<t.length;r++){const o=t[r],i=l(o,n.linkRules),[s,a,c,h]=u(n.linkRules,o,i);for(let t=0;t<s.length;t++)e.push({fChain:r,sChain:r,fMonomer:s[t],sMonomer:a[t],fR:c[t],sR:h[t]});t[r]=o}}(i,n,t),function(t,e,n){for(let r=0;r<t.length;r++){const o=l(t[r],n.reactionRules),[i,s,a]=c(n.reactionRules,t[r],o);i.length>=1&&(e.push({fChain:r,sChain:t.length,fMonomer:i[0],sMonomer:1,fR:3,sR:1}),e.push({fChain:r,sChain:t.length,fMonomer:s[0],sMonomer:1,fR:3,sR:2}),t.push([n.reactionRules[a[0]].name]))}}(i,n,t),this.underRules=!0,this.linkagesUnderRules=n,this.monomersUnderRules=i,this.molUnderRules=d(n,i,this.helmHelper)}check(t=!1){const e=[],n=this.monomers.map((t=>t.length)).reduce(((t,e)=>t+e),0);this.mol.atoms.length!==n&&e.push(`The mol atoms count ${this.mol.atoms.length} does not match the total number ${n} of chains' monomers.`);const r=this.monomers.map((t=>t.length-1)).reduce(((t,e)=>t+e),0)+this.linkages.length;this.mol.bonds.length!==r&&e.push(`The mol bonds count ${this.mol.bonds.length} does not match the total number ${r} in- and inter-chain linkages.`);let o=0;for(let t=0;t<this.monomers.length;++t){const n=this.monomers[t];for(let t=0;t<n.length;++t)try{const r=n[t],i=this.mol.atoms[o];i.bio.continuousId!==o&&e.push(`Atom #${o} has incorrect .bio.continuousId: ${i.bio.continuousId}.`),i.elem!==r&&e.push(`Atom #${o} elem: '${i.elem}' does not match chain monomer: '${r}'.`)}finally{o++}}if(t&&e.length>0)throw new Error(`Chain errors:\n${e.map((t=>` ${t}`)).join("\n")}`);return e}}},4229:(t,e,n)=>{"use strict";n.d(e,{b:()=>s});var r=n(9192),o=n(6307),i=n(9788);function s(t,e,n){const s=new Array(t.length),a=new Array(t.length),l=new Array(t.length);for(let u=0;u<t.length;u++)try{if(null==t[u])s[u]="";else{const r=o.s.fromSeparator(t[u],n);r.applyRules(e),a[u]=!(r.monomersUnderRules.length>1||r.linkagesUnderRules.length>0),s[u]=r.getHelm(),l[u]=r.posToPosUnderRules}}catch(t){const[e,n]=(0,r.AP)(t);i._package.logger.error(e,void 0,n),s[u]=""}return[s,a,l]}},2125:(t,e,n)=>{"use strict";function r(t,e){let n,r=t;for(n=0;n<e.length&&r>=e[n].length;++n)r-=e[n].length;return[r,n]}function o(t,e,n){let r=0;for(let t=0;t<e;++t)r+=n[t].length;return r+t}n.d(e,{M:()=>r,j:()=>o})},6694:(t,e,n)=>{"use strict";n.d(e,{MU:()=>V,yy:()=>j,_v:()=>Q,Ln:()=>et,Q4:()=>tt});var r=n(6082),o=n(4328),i=n(7389),s=n(1991),a=n.n(s),l=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{l(r.next(t))}catch(t){i(t)}}function a(t){try{l(r.throw(t))}catch(t){i(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}l((r=r.apply(t,e||[])).next())}))};class u{constructor(t,e,n=".csv",r){this.path=t,this.userStorageName=e,this.ext=n,this.options=r,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 t=o.userSettings.getValue(this.userStorageName,"Settings"),e=t?JSON.parse(t):{excluded:[],explicit:[]};return e.explicit=e.explicit instanceof Array?e.explicit:[],e.excluded=e.excluded instanceof Array?e.excluded:[],this.settings=e}))}setUserSettings(t){this.settings=t,o.userSettings.add(this.userStorageName,"Settings",JSON.stringify(t))}getAllAvailable(){return l(this,void 0,void 0,(function*(){return(yield o.dapi.files.list(this.path)).map((t=>t.fullPath.replace(`${this.path}`,"")))}))}getActive(){return l(this,void 0,void 0,(function*(){const t=yield this.getUserSettings();return t.explicit.length>0?t.explicit:(yield this.getAllAvailable()).filter((e=>!t.excluded.includes(e)))}))}setActive(t){const e=new Set(t);for(const[t,n]of this.inputs.entries())n.value=e.has(t)}createInput(t,e){const n=i.input.bool(t,{value:e,onValueChanged:e=>this.updateSelectionStatus(t,e)});return n.addOptions(i.button(i.iconFA("trash"),(()=>{i.dialog({title:"Warning"}).add(i.divText(`Delete file '${t}'?`)).onOK((()=>{n.root.remove(),this.availableRemove(t)})).show()}),`Delete ${t}`)),n}getInputs(){return l(this,void 0,void 0,(function*(){this.inputs=new Map;const t=yield this.getAllAvailable(),e=yield this.getActive(),n=new Array(t.length);for(let r=0;r<t.length;r++){const o=e.includes(t[r]);n[r]=this.createInput(t[r],o),this.inputs.set(t[r],n[r])}return this.fireOnValueChanged(),n}))}getForm(){return l(this,void 0,void 0,(function*(){const t=yield this.getInputs(),e=i.divV(t);return i.divV([e,i.button("ADD",(()=>l(this,void 0,void 0,(function*(){let t="";if(t=yield this.getNewAvailable(),""!==t){const n=this.createInput(t,!0);e.append(n.root),this.inputs.set(t,n),this.fireOnValueChanged()}}))))])}))}fireOnValueChanged(){var t;null===(t=this.options)||void 0===t||t.onValueChanged(a()(this.inputs.entries()).filter((([t,e])=>e.value)).map((([t,e])=>t)).toArray())}updateSelectionStatus(t,e){return l(this,void 0,void 0,(function*(){const n=yield this.getUserSettings();if(!n.excluded.includes(t)!==e){if(e){const e=n.excluded.indexOf(t);e>-1&&n.excluded.splice(e,1)}else n.excluded.push(t);this.fireOnValueChanged(),this.setUserSettings(n)}}))}availableRemove(t){return l(this,void 0,void 0,(function*(){this.inputs.delete(t),this.fireOnValueChanged();const e=yield this.getUserSettings(),n=e.excluded.indexOf(t);n>-1&&e.excluded.splice(n,1),this.setUserSettings(e),yield o.dapi.files.delete(this.path+t),o.shell.info(`File ${t} successfully deleted`)}))}getNewAvailable(){return l(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{r.Utils.openFile({accept:this.ext,open:e=>l(this,void 0,void 0,(function*(){const n=e.name,r=yield e.arrayBuffer();yield o.dapi.files.write(this.path+`${e.name}`,new Uint8Array(r)),t(n)}))})}))}))}}var c=n(9788),h=n(9124),d=n(4229),f=n(439),p=n(5174),m=n(5412),g=n(6717),y=n(8312);function b(t){let e=t.replaceAll(/\[R[1-9]\]/g,(t=>`[*:${t[2]}]`));return e=e.replaceAll(/\[\d\*\]/g,(t=>`[*:${t[1]}]`)),e.replaceAll(/\[\d\*\:\d\]/g,(t=>`[*:${t[1]}]`))}function v(t){return t.replaceAll(/\[\*\:\d\]/g,(t=>`[C:${t[3]}]`))}function C(t){return t.replaceAll(/\[C\:\d\]/g,(t=>`[*:${t[3]}]`))}function w(t,e){const n=e?.firstReactantSmiles?C(e.firstReactantSmiles):"[*:1]C",r=e?.secondReactantSmiles?C(e.secondReactantSmiles):"[*:2]C",s=e?.productSmiles?C(e.productSmiles):"[*:1]CC[*:2]",a=e?.code,l=e?.firstMonomers??[],u=e?.secondMonomers??[],c=e?.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"}),f=i.input.string("Second monomers",{value:u.join(","),nullable:!1,tooltipText:"Comma-separated list of monomers for the second reactant"}),p=i.input.string("Result monomer name",{value:c,nullable:!1,tooltipText:"Name of the resulting pseudo-monomer generated by the reaction of the two reactants"}),m=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:r,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."}),w=()=>{if(!m||!g||!y)return"Inputs not initialized yet";const t=v(b(o.chem.convert(m.value??"",o.chem.Notation.Unknown,o.chem.Notation.Smiles))),e=v(b(o.chem.convert(g.value??"",o.chem.Notation.Unknown,o.chem.Notation.Smiles))),n=v(b(o.chem.convert(y.value??"",o.chem.Notation.Unknown,o.chem.Notation.Smiles)));return t&&e&&n?-1==t.indexOf("[C:1]")?"First Reactant must contain R1-group":-1==e.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"};m.addValidator(w),g.addValidator(w),y.addValidator(w);const A=i.dialog(e?"Edit Reaction Rule":"Add Reaction Rule").add(h).add(p).add(d).add(f).add(m).add(g).add(y);A.addButton("Save",(()=>{const n=w();if(null!=n)return void o.shell.warning(n);const r=v(b(o.chem.convert(m.value??"",o.chem.Notation.Unknown,o.chem.Notation.Smiles))),i=v(b(o.chem.convert(g.value??"",o.chem.Notation.Unknown,o.chem.Notation.Smiles))),s=v(b(o.chem.convert(y.value??"",o.chem.Notation.Unknown,o.chem.Notation.Smiles)));t({code:h.value,resultMonomerName:p.value,firstMonomers:d.value.split(",").map((t=>t.trim())).filter((t=>t.length>0)),secondMonomers:f.value.split(",").map((t=>t.trim())).filter((t=>t.length>0)),firstReactantSmiles:r,secondReactantSmiles:i,productSmiles:s,rowIndex:e?.rowIndex}),A.close()})),A.show()}const A="Links",x="Reactions";class E{constructor(t,e){this.v=null,this.substituteReactionGridDataFrame=null,this.rules=t;const n=this.rules.getLinkRulesDf();this.linkRuleDataFrame=n.res,this.addLinkRulesFunc=n.addNewRow;const r=this.rules.getSynthesisRulesDf();this.addSynthRulesFunc=t=>{r.addNewRow(t),this.rules.setSynthesisRules(r.df),this.synthRuleDataFrame=r.df,this.substituteReactionGridDataFrame?.(),this.save()},this.synthRuleDataFrame=r.df,this.fileName=e;const o=this.rules.homodimerCode?this.rules.homodimerCode:"",s=this.rules.heterodimerCode?this.rules.heterodimerCode:"";this.homoDimerInput=i.input.string("Homo dimer",{value:o,onValueChanged:()=>{},nullable:!1}),this.heteroDimerInput=i.input.string("Hetero dimer",{value:s,onValueChanged:()=>{},nullable:!1})}async getAndAddView(){if(this.v)try{const t=Array.from(o.shell.views).find((t=>t.name===this.v.name));if(!t)throw this.v.detach(),this.v.close(),new Error("View is closed, making it null in catch statement");o.shell.v=t}catch(t){this.v=null}return this.v||(this.v=r.View.create(),this.v.name=`Manage Polytool Rules - ${this.fileName}`,this.v.append(await this.getForm()),this.v=o.shell.addView(this.v),o.shell.v=this.v),this.v}static async getInstance(t){if(!this.instances[t]){const e=await tt([t]);this.instances[t]=new E(e,t)}return this.instances[t]}save(){this.rules.homodimerCode=this.homoDimerInput.value,this.rules.heterodimerCode=this.heteroDimerInput.value,this.rules.setLinkRules(this.linkRuleDataFrame),this.rules.setSynthesisRules(this.synthRuleDataFrame);const t={homodimerCode:this.rules.homodimerCode,heterodimerCode:this.rules.heterodimerCode,linkRules:this.rules.linkRules,reactionRules:this.rules.reactionRules},e=JSON.stringify(t,void 0,2);c._package.files.writeAsText(`polytool-rules/${this.fileName}`,e),o.shell.info(`Polytool rules at ${this.fileName} was updated`)}createGridDiv(t,e,n){const r=i.h1(t,"polytool-grid-header");i.tooltip.bind(r,n),r.style.marginTop="10px",r.style.marginRight="10px",e.root.style.height="100%";const o=i.splitV([i.box(r,{style:{maxHeight:"60px"}}),e.root]);return o.style.height="100%",o}async getLinkExamplesGrid(){const t=[];for(let e=0;e<this.rules.linkRules.length;e++){const n=this.rules.linkRules[e].code,[r,o]=et(this.rules.linkRules[e]);for(let e=0;e<r.length;e++){const i=`${r[e]}(${n})-A-A-A-A-${o[e]}(${n})`;t.push(i)}}const e=await(0,h.b2)(),[n,o,i]=(0,d.b)(t,this.rules,e),s=r.Column.fromStrings("Monomers",t),a=r.Column.fromStrings("Helm",n);return c.PackageFunctions.applyNotationProviderForCyclized(s,"-"),s.semType=r.SEMTYPE.MACROMOLECULE,a.semType=r.SEMTYPE.MACROMOLECULE,a.meta.units=f.Hi.HELM,a.setTag(r.TAGS.CELL_RENDERER,"helm"),r.DataFrame.fromColumns([s,a]).plot.grid()}async getReactionExamplesGrid(){const t=[];for(let e=0;e<this.rules.reactionRules.length;e++){const n=this.rules.reactionRules[e].code,[r,o]=et(this.rules.reactionRules[e]);for(let e=0;e<r.length;e++){const i=`${r[e]}(${n})-A-A-A-A-${o[e]}(${n})`;t.push(i)}}const e=await(0,h.b2)(),[n,o,i]=(0,d.b)(t,this.rules,e),s=r.Column.fromStrings("Monomers",t),a=r.Column.fromStrings("Helm",n),l=r.DataFrame.fromColumns([s,a]);s.semType=r.SEMTYPE.MACROMOLECULE;const u=await(0,g.j)(),b=await(0,y.Q)();c.PackageFunctions.applyNotationProviderForCyclized(s,"-"),s.tags[r.TAGS.CELL_RENDERER]="Sequence",a.semType=r.SEMTYPE.MACROMOLECULE,a.meta.units=f.Hi.HELM,a.setTag(r.TAGS.CELL_RENDERER,"helm");const v=await(0,p.A)(this.rules),C=a.temp;C[".mm.cellRenderer.overriddenLibrary"]=v,a.temp=C;const w=await(0,m.m)(a,t,o,!0,!1,!1,v,u,b);return w.name="molfile(sequence)",w.semType=r.SEMTYPE.MOLECULE,l.columns.add(w),l.plot.grid()}async getForm(){const t=this.linkRuleDataFrame.plot.grid({showAddNewRowIcon:!1,allowEdit:!1,rowHeight:60});t.onCellDoubleClick.subscribe((()=>{if(!t.dataFrame||-1==t.dataFrame.currentRowIdx||null==t.dataFrame.currentRowIdx)return;const e=t.dataFrame.currentRowIdx,n={row:e,code:this.linkRuleDataFrame.get("code",e),firstMonomers:this.linkRuleDataFrame.get("firstMonomers",e),secondMonomers:this.linkRuleDataFrame.get("secondMonomers",e),firstLinkingGroup:this.linkRuleDataFrame.get("firstLinkingGroup",e),secondLinkingGroup:this.linkRuleDataFrame.get("secondLinkingGroup",e)};this.getAddNewLinkRuleDialog(n)}));const e=this.createGridDiv("Rules",t,"specification for monomers to link and linking positions"),n=this.createGridDiv("Examples",await this.getLinkExamplesGrid(),"specification for monomers to link and linking positions");e.style.width="50%",n.style.width="50%";const r=i.h1("Monomers","polytool-grid-header");i.tooltip.bind(r,"Click different cobination to see how monomers will link"),this.linkCards=await this.rules.getLinkCards();const o=i.splitV([i.box(r,{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 t=this.linkRuleDataFrame.currentRowIdx;-1!==t&&null!=t&&(i.empty(o),o.append(i.splitV([i.box(r,{style:{maxHeight:"30px"}}),this.linkCards[t].root])),this.linkCards[t].render(),await this.linkCards[t].reset())}));const s=i.splitH([e,o],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 t=a.dataFrame.currentRowIdx;w((t=>this.addSynthRulesFunc(t)),{rowIndex:t,code:this.synthRuleDataFrame.get("code",t),firstMonomers:this.synthRuleDataFrame.get("firstMonomers",t).split(",").map((t=>t.trim())).filter((t=>t)),secondMonomers:this.synthRuleDataFrame.get("secondMonomers",t).split(",").map((t=>t.trim())).filter((t=>t)),resultMonomerName:this.synthRuleDataFrame.get("name",t),firstReactantSmiles:this.synthRuleDataFrame.get("firstReactant",t),secondReactantSmiles:this.synthRuleDataFrame.get("secondReactant",t),productSmiles:this.synthRuleDataFrame.get("product",t)})}));const l=this.createGridDiv("Rules",a),u=await this.getReactionExamplesGrid(),c=this.createGridDiv("Examples",u);this.substituteReactionGridDataFrame=async()=>{const t=await this.getReactionExamplesGrid();u.dataFrame=t.dataFrame},l.style.width="50%",c.style.width="50%";const h=i.divH([l,c]),d=i.divV([this.homoDimerInput,this.heteroDimerInput]),f=i.tabControl({Links:s,Reactions:h,Dimers:d},!1);i.tooltip.bind(f.getPane(A).header,"Specify rules to link monomers based on HELM notation"),i.tooltip.bind(f.getPane(x).header,"Specify rules to perform reactions within monomers"),i.tooltip.bind(f.getPane("Dimers").header,"Specify symbols for homodimeric and heterodimeric codes"),f.root.style.height="100%",f.root.style.width="100%",f.root.classList.add("rules-manager-form-tab-control"),f.header.style.marginBottom="10px";const p=i.divV([f.root]),m=[i.bigButton("Save",(()=>{this.save()})),i.button("Add rule",(()=>{const t=f.currentPane.name;t==A?this.getAddNewLinkRuleDialog():t==x&&w((t=>this.addSynthRulesFunc(t)))})),i.button("Remove rule",(()=>{const e=f.currentPane.name;if(e==A){if(null==this.linkRuleDataFrame||-1==this.linkRuleDataFrame.currentRowIdx||null==this.linkRuleDataFrame.currentRowIdx)return;const e=t.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(e),this.rules.setLinkRules(this.linkRuleDataFrame),this.save()})).show()}else if(e==x){if(null==this.synthRuleDataFrame||-1==this.synthRuleDataFrame.currentRowIdx||null==this.synthRuleDataFrame.currentRowIdx)return;const t=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(t),this.rules.setSynthesisRules(this.synthRuleDataFrame),this.substituteReactionGridDataFrame?.(),this.save()})).show()}}))];return this.v.setRibbonPanels([m]),p.style.height="100%",p.style.alignItems="center",f.root}getAddNewLinkRuleDialog(t){const e=i.input.int("Code",{nullable:!1,value:t?.code}),n=i.input.string("First monomers",{placeholder:"E.g. C,D,E",value:t?.firstMonomers,tooltipText:"Comma separated list of first monomers applicable for the rule. If left empty, all monomers will be considered",nullable:!0}),r=i.input.string("Second monomers",{placeholder:"E.g. C,D,E",value:t?.secondMonomers,tooltipText:"Comma separated list of second monomers applicable for the rule. If left empty, all monomers will be considered",nullable:!0}),o=t?.firstLinkingGroup?`R${t.firstLinkingGroup}`:"R3",s=t?.secondLinkingGroup?`R${t.secondLinkingGroup}`:"R3",a=i.input.choice("First linking group",{value:o,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(e).add(n).add(r).add(a).add(l).onOK((async()=>{const o=e.value,i=(n.value??"").split(",").map((t=>t.trim())).filter((t=>t)).join(","),s=(r.value??"").split(",").map((t=>t.trim())).filter((t=>t)).join(","),u=parseInt(a.value.substring(1)),c=parseInt(l.value.substring(1));this.addLinkRulesFunc({code:o,firstMonomers:i??"",secondMonomers:s??"",firstLinkingGroup:u,secondLinkingGroup:c,row:t?.row}),this.rules.setLinkRules(this.linkRuleDataFrame),this.linkCards=await this.rules.getLinkCards(),this.save()})).show()}}E.instances={};var T=n(5072),S=n.n(T),I=n(7825),_=n.n(I),N=n(7659),P=n.n(N),M=n(5056),L=n.n(M),O=n(540),R=n.n(O),D=n(1113),B=n.n(D),F=n(890),$={};$.styleTagTransform=B(),$.setAttributes=L(),$.insert=P().bind(null,"head"),$.domAPI=_(),$.insertStyleElement=R(),S()(F.A,$),F.A&&F.A.locals&&F.A.locals;var k=n(2003);class H{get selected(){return this._selected}set selected(t){this._selected=t,this.root.style.border=t?"2px solid var(--green-2)":"2px solid var(--grey-2)"}constructor(t,e){this.monomer=t,this.monomerSymbol=e,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 t=this.monomer.smiles&&o.chem.checkSmiles(this.monomer.smiles)?o.chem.drawMolecule(this.monomer.smiles,150,120):o.chem.drawMolecule(this.monomer.molfile??"",150,120);this.root.appendChild(t);const e=i.divH([i.divText("Monomer Name: "),i.divText(this.monomer.name)],{classes:"monomer-card-info-rules"});if(this.root.appendChild(e),i.tooltip.bind(e,this.monomer.name),this.monomer.lib?.source){const t=i.divH([i.divText("Source: "),i.divText(this.monomer.lib.source)],{classes:"monomer-card-info-rules"});this.root.appendChild(t),i.tooltip.bind(t,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(t,e,n,r,o){this.firstMonomers=t,this.secondMonomers=e,this.code=r,this.rules=o,this.root=i.divH([],{style:{width:"100%",overflow:"hidden",visibility:"visible"},classes:"monomer-cards"});const s=!t?.length,a=!e?.length;s&&(this.firstMonomers=t=["C","D","E","F","G"]),a&&(this.secondMonomers=e=["D","C","E","F","G"]),this.actionable=!0;const l=i.divH([],{style:{overflowX:"auto",width:"100%"}}),u=i.divH([],{style:{overflowX:"auto",width:"100%"}});this.resulting=i.divH([],{style:{overflowX:"auto",width:"100%",minHeight:"150px"}});const c=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([c,l,h,u,this.resulting]);this.cardsFirst=t.map((t=>new H(n.getMonomer("PEPTIDE",t),t))),this.cardsSecond=e.map((t=>new H(n.getMonomer("PEPTIDE",t),t))),this.cardsFirst.forEach((t=>{t.root.onclick=()=>{this.cardsFirst.forEach((t=>t.selected=!1)),t.selected=!0,this.firstCard=t,this.reset()},l.appendChild(t.root)})),this.cardsSecond.forEach((t=>{t.root.onclick=()=>{this.cardsSecond.forEach((t=>t.selected=!1)),t.selected=!0,this.secondCard=t,this.reset()},u.appendChild(t.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 t=[`${this.firstCard.monomer?.symbol}(${this.code})-A-A-A-A-${this.secondCard.monomer?.symbol}(${this.code})`],e=await(0,h.b2)(),[n,s,a]=(0,d.b)(t,this.rules,e),l=r.Column.fromType(r.COLUMN_TYPE.STRING,"helm",n.length).init((t=>n[t]));l.semType=r.SEMTYPE.MACROMOLECULE,l.meta.units=k.Hi.HELM,l.setTag(r.TAGS.CELL_RENDERER,"helm");const u=await(0,g.j)(),c=await(0,y.Q)(),f=await(0,p.A)(this.rules),b=l.temp;l.temp=b;const v=(await(0,m.m)(l,n,s,!0,!1,!1,f,u,c)).get(0),C=v&&o.chem.checkSmiles(v)?o.chem.drawMolecule(v,200,200):o.chem.drawMolecule(v??"",200,200);v&&(C.style.cursor="pointer",C.onclick=()=>{const t=window.innerWidth-200,e=window.innerHeight-200,n=o.chem.checkSmiles(v)?o.chem.drawMolecule(v,t,e):o.chem.drawMolecule(v??"",t,e);i.dialog({title:"Molecule"}).add(n).showModal(!0)},i.tooltip.bind(C,"Click to expand"));const w=i.divV([i.h2("Example Result:"),i.h2(t[0])],{style:{width:"200px"}});i.empty(this.resulting),this.resulting.append(i.divH([w,C],{style:{overflowX:"auto",width:"100%",minHeight:"150px"}}))}}render(){this.actionable&&(this.cardsFirst.forEach((t=>t.render())),this.cardsSecond.forEach((t=>t.render())))}}var U=n(4971);const V="System:AppData/SequenceTranslator/polytool-rules/",j="Polytool",q="code",W="firstMonomers",z="secondMonomers",Y="name",K="firstLinkingGroup",J="secondLinkingGroup";class Q extends u{constructor(t,e,n,r){super(t,e,n,r)}createInput(t,e){const n=super.createInput(t,e),o=i.icons.edit((async()=>{const e=await E.getInstance(t);r.Dialog.getOpenDialogs()?.filter((t=>t.root.contains(o))).forEach((t=>t.close())),await e.getAndAddView()}),"Edit rules");return n.addOptions(o),n}async getForm(){const t=await super.getForm();return this.processRulesForm(t),t}async processRulesForm(t){const e=Array.from(t.getElementsByTagName("label")??[]).filter((t=>t.textContent?.endsWith(".json")&&null!=t.parentElement));for(const t of e){const e=t.textContent.trim(),n=t.parentElement.getElementsByTagName("input")[0];i.tooltip.bind(n,i.wait((async()=>{var t;return(t=Q.ruleDescriptions)[e]??(t[e]=(async()=>{try{const t=JSON.parse(await o.dapi.files.readAsText(`${V}/${e}`)),n=i.divV([i.h1(e)]),r=t.linkRules??[];if(r.length>0){n.appendChild(i.h3("Linkage Rules"));const t=i.table(r,(t=>[t.code?.toString()??"",X((t.firstMonomers??[]).join(", ")),X((t.secondMonomers??[]).join(", ")),t.firstLinkingGroup?.toString()??"",t.secondLinkingGroup?.toString()??""]),["Code","M1","M2","L1","L2"]);n.appendChild(t)}const s=t.reactionRules??[];if(s.length>0){n.appendChild(i.h3("Synthesis Rules"));const t=i.table(s,(t=>[t.code?.toString()??"",X((t.firstMonomers??[]).join(", ")),X((t.secondMonomers??[]).join(", ")),X(t.name??""),o.chem.drawMolecule(t.reaction?.split(">>")[1]??"",70,70)]),["Code","M1","M2","Name","Product"]);n.appendChild(t)}return n}catch(t){return c._package.logger.error(`Failed to load rule ${e}: ${t?.toString?.()}`),console.error(t),i.divText(`Failed to load rule ${e}`)}})()),await Q.ruleDescriptions[e]})))}}}function X(t,e=30){return t.length<=e?t:`${t.substring(0,e)}...`}Q.ruleDescriptions={};class Z{constructor(t,e,n,r){this.homodimerCode=t,this.heterodimerCode=e,this.linkRules=n,this.reactionRules=r}set homodimer(t){this.homodimerCode=t}set heterodimer(t){this.heterodimerCode=t}addLinkRules(t){for(let e=0;e<t.length;e++)this.linkRules.push(t[e])}addSynthesisRules(t){for(let e=0;e<t.length;e++)this.reactionRules.push(t[e])}getLinkRulesDf(){const t=this.linkRules.length,e=r.Column.int(q,t);e.setTag("friendlyName","Code");const n=r.Column.string(W,t);n.temp[".mm.cellRenderer.fontSize"]=16,n.setTag("friendlyName","First monomers"),n.semType=r.SEMTYPE.MACROMOLECULE,c.PackageFunctions.applyNotationProviderForCyclized(n,",");const o=r.Column.string(z,t);o.setTag("friendlyName","Second monomers"),o.temp[".mm.cellRenderer.fontSize"]=16,o.semType=r.SEMTYPE.MACROMOLECULE,c.PackageFunctions.applyNotationProviderForCyclized(o,",");const i=r.Column.int(K,t);i.setTag("friendlyName","First group");const s=r.Column.int(J,t);s.setTag("friendlyName","Second group");for(let r=0;r<t;r++)e.set(r,this.linkRules[r].code),n.set(r,this.linkRules[r].firstMonomers.toString()),o.set(r,this.linkRules[r].secondMonomers.toString()),i.set(r,this.linkRules[r].firstLinkingGroup),s.set(r,this.linkRules[r].secondLinkingGroup);const a=r.DataFrame.fromColumns([e,n,o,i,s]);return{res:a,addNewRow:t=>{if(null!=t.row&&t.row<a.rowCount&&t.row>=0)e.set(t.row,t.code),n.set(t.row,t.firstMonomers),o.set(t.row,t.secondMonomers),i.set(t.row,t.firstLinkingGroup),s.set(t.row,t.secondLinkingGroup);else{const{code:e,firstMonomers:n,secondMonomers:r,firstLinkingGroup:o,secondLinkingGroup:i}=t;a.rows.addNew([e,n??"",r??"",o??1,i??2])}}}}async getLinkCards(){const t=this.linkRules.length,e=new Array(t),n=(await(0,U.pj)()).getMonomerLib();for(let r=0;r<t;r++)e[r]=new G(this.linkRules[r].firstMonomers,this.linkRules[r].secondMonomers,n,this.linkRules[r].code,this);return e}getSynthesisRulesDf(){const t=this.reactionRules.length,e=r.Column.int(q,t);e.setTag("friendlyName","Code");const n=r.Column.string(W,t);n.setTag("friendlyName","First monomers");const o=r.Column.string(z,t);o.setTag("friendlyName","Second monomers"),n.semType=r.SEMTYPE.MACROMOLECULE,n.temp[".mm.cellRenderer.fontSize"]=16,c.PackageFunctions.applyNotationProviderForCyclized(n,","),o.semType=r.SEMTYPE.MACROMOLECULE,o.temp[".mm.cellRenderer.fontSize"]=16,c.PackageFunctions.applyNotationProviderForCyclized(o,","),o.setTag(r.TAGS.CELL_RENDERER,"Sequence"),n.setTag(r.TAGS.CELL_RENDERER,"Sequence");const i=r.Column.string(Y,t);i.setTag("friendlyName","Name");const s=r.Column.string("firstReactant",t);s.setTag("friendlyName","First reactant");const a=r.Column.string("secondReactant",t);a.setTag("friendlyName","Second reactant");const l=r.Column.string("product",t);l.setTag("friendlyName","Product");for(let r=0;r<t;r++){e.set(r,this.reactionRules[r].code),n.set(r,this.reactionRules[r].firstMonomers.toString()),o.set(r,this.reactionRules[r].secondMonomers.toString()),i.set(r,this.reactionRules[r].name);const t=this.reactionRules[r].reaction.split(">>"),u=t[0].split(".");s.set(r,u[0]),a.set(r,u[1]),l.set(r,t[1])}s.semType=r.SEMTYPE.MOLECULE,a.semType=r.SEMTYPE.MOLECULE,l.semType=r.SEMTYPE.MOLECULE;const u=r.DataFrame.fromColumns([i,s,a,l,e,n,o]);return{df:u,addNewRow:t=>{if(null!=t.rowIndex&&t.rowIndex<u.rowCount&&t.rowIndex>=0)i.set(t.rowIndex,t.resultMonomerName),e.set(t.rowIndex,t.code),n.set(t.rowIndex,t.firstMonomers.join(",")),o.set(t.rowIndex,t.secondMonomers.join(",")),s.set(t.rowIndex,t.firstReactantSmiles),a.set(t.rowIndex,t.secondReactantSmiles),l.set(t.rowIndex,t.productSmiles);else{const{resultMonomerName:e,code:n,firstMonomers:r,secondMonomers:o,firstReactantSmiles:i,secondReactantSmiles:s,productSmiles:a}=t;u.rows.addNew([e,i,s,a,n,r.join(","),o.join(",")])}}}}setLinkRules(t){const e=t.rowCount,n=new Array(e),r=t.columns.byName(q),o=t.columns.byName(W),i=t.columns.byName(z),s=t.columns.byName(K),a=t.columns.byName(J);for(let t=0;t<e;t++){const e=o.get(t).split(","),l=i.get(t).split(","),u={code:r.get(t),firstMonomers:""!==e[0]?e:[],secondMonomers:""!==l[0]?l:[],firstLinkingGroup:s.get(t),secondLinkingGroup:a.get(t)};n[t]=u}this.linkRules=n}setSynthesisRules(t){const e=t.rowCount,n=new Array(e),r=t.columns.byName(q),o=t.columns.byName(W),i=t.columns.byName(z),s=t.columns.byName(Y),a=t.columns.byName("firstReactant"),l=t.columns.byName("secondReactant"),u=t.columns.byName("product");for(let t=0;t<e;t++){const e=`${a.get(t)}.${l.get(t)}>>${u.get(t)}`,c=o.get(t).split(","),h=i.get(t).split(","),d={code:r.get(t),firstMonomers:""!==c[0]?c:[],secondMonomers:""!==h[0]?h:[],reaction:e,name:s.get(t)};n[t]=d}this.reactionRules=n}}async function tt(t){const e=new r.FileSource(V),n=new Z(null,null,[],[]);for(let r=0;r<t.length;r++){const o=await e.readAsText(t[r].replace(V,"")),i=JSON.parse(o);n.homodimer=i.homodimerCode,n.heterodimer=i.heterodimerCode,n.addLinkRules(i.linkRules),n.addSynthesisRules(i.reactionRules)}return n}function et(t){const e=t.firstMonomers.length*t.secondMonomers.length,n=new Array(e),r=new Array(e);let o=0;for(let e=0;e<t.firstMonomers.length;e++)for(let i=0;i<t.secondMonomers.length;i++)n[o]=t.firstMonomers[e],r[o]=t.secondMonomers[i],o++;return[n,r]}},5174:(t,e,n)=>{"use strict";n.d(e,{A:()=>c,T:()=>h});var r=n(6717),o=n(1296),i=n(9192),s=n(4328),a=n(1991),l=n.n(a),u=n(4971);async function c(t){const e=(await(0,u.pj)()).getMonomerLib(),n=await(0,r.j)(),o={};let i=[],a=[];for(let r=0;r<t.reactionRules.length;r++)try{[i,a]=h(n,e,t.reactionRules[r])}catch(t){i=[],a=[],console.error(t),s.shell.warning(t)}finally{for(let t=0;t<i.length;t++)null!=i[t]&&null!=a[t]&&(o[i[t]]=a[t])}const c={PEPTIDE:o};return e.override(c,"ST-PT-reactions."+l().repeat(1).map((()=>Math.floor(36*Math.random()).toString(36))).take(4).toArray().join(""))}function h(t,e,n){const r=n.reaction,o=n.name,s=n.firstMonomers.length+n.secondMonomers.length+1,a=n.reaction.split(">>"),l=a[0].split("."),u=new Array(s),c=new Array(s),h=new Array(s),m=f(t,r),g=`${l[0]}>>[C:1]C`,y=`${l[1]}>>[C:2]C`,b=f(t,g),v=f(t,y);let C=0;for(let r=0;r<n.firstMonomers.length;r++){const i=e.getMonomer("PEPTIDE",n.firstMonomers[r]);if(i){const e=d(t,i.molfile,b,i.name);h[C]=e,u[C]=`${i.symbol}_${o}`}C++}for(let r=0;r<n.secondMonomers.length;r++){const i=e.getMonomer("PEPTIDE",n.secondMonomers[r]);if(i){const e=d(t,i.molfile,v,i.name);h[C]=e,u[C]=`${i.symbol}_${o}`}C++}let w=null;a[1]=a[1].replace("[C:1]","[1*]").replace("[C:2]","[2*]").replace("[C:3]","[3*]");let A="";try{w=t.get_mol(a[1]),A=w?.get_molblock()}catch(t){const[e,n]=(0,i.AP)(t);throw console.error(`Can not assemble monomer '${o}': ${e}.`),t}finally{w?.delete()}h[C]=A,u[C]=o;for(let t=0;t<s-1;t++)h[t]&&(h[t]=h[t].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(t){const e=t.replace("M RAD","M RGP").replace("M ISO","M RGP").split("\n"),n=e.findIndex((t=>t.startsWith("M RGP"))),r=Number(e[n].substring(9,13)),o=Number(e[n].substring(17,21)),i=Number(e[n].substring(13,17)),s=Number(e[n].substring(21,25));e[n]=e[n].substring(0,13)+` ${i}`+e[n].substring(17,21)+` ${s}`,e[3+r]=e[3+r].substring(0,30)+" R# 0 0 0 0 0 0 0 0 0 0 0 0",e[3+o]=e[3+o].substring(0,30)+" R# 0 0 0 0 0 0 0 0 0 0 0 0";let a="";for(let t=0;t<e.length;t++)a+=e[t]+"\n";return a}(h[s-1]);for(let t=0;t<s;t++){const e=t==s-1;if(!h[t]||!u[t])continue;const n={symbol:u[t],name:u[t],molfile:h[t],author:"",id:0,rgroups:p(e),smiles:"",polymerType:"PEPTIDE",monomerType:"Backbone",createDate:null};n.meta=Object.assign(n.meta??{},{colors:{default:{line:"#2083D5",text:"#2083D5",background:"#F2F2F5"}}}),u[t]=u[t],c[t]=n}return m.delete(),b.delete(),v.delete(),[u,c]}function d(t,e,n,r){let o=null,s=null,a=null,l=null,u="";try{o=new t.MolList,s=t.get_mol(e),o.append(s),a=n.run_reactants(o,1),l=a.get(0).next(),u=l?.get_molblock()}catch(t){const[e,n]=(0,i.AP)(t);throw console.error(`Can not assemble monomer '${r}': ${e}.`),t}finally{o?.delete(),s?.delete(),a?.delete(),l?.delete()}return u}function f(t,e){let n=null;try{if(n=t.get_rxn(e),!n)throw new o.J5(e)}catch(t){n?.delete();const[r,o]=(0,i.AP)(t);throw console.error(`Can not assemble monomer '${e}': ${r}.`),t}return n}function p(t){if(t){const t=new Array(2),e={capGroupSMILES:"[*:1][H]",alternateId:"R1-H",capGroupName:"H",label:"R1"},n={capGroupSMILES:"[*:2][H]",alternateId:"R2-H",capGroupName:"H",label:"R2"};return t[0]=e,t[1]=n,t}return[{capGroupSMILES:"[*:3][H]",alternateId:"R3-H",capGroupName:"H",label:"R3"}]}},3820:(t,e,n)=>{"use strict";n.d(e,{d:()=>o,o:()=>s});var r=n(1296);const o="PEPTIDE1{R.[Aca].T.G.H.F.G.A.A.Y.P.E.[meI]}$$$$";function i(t,e,n,r){const o=new Array(r.length*(n-e+1));for(let i=0;i<r.length;++i){const s=n-e+1;for(let n=0;n<s;++n){const a=e+n,l=r[i],u=o[i*s+n]=t.clone(),c=u.atoms[a].elem;u.atoms[a].elem=l;const h=c?.length>1?`[${c}]`:c,d=l?.length>1?`[${l}]`:l;u.name=`${t.name}-${h}${a+1}${d}`}}return o}function s(t,e,n){const o=new JSDraw2.MolHandler,s=new org.helm.webeditor.Plugin(o);org.helm.webeditor.IO.parseHelm(s,t,new JSDraw2.Point(0,0),void 0);const a=o.m;a.name=e;let l=[];if(n.placeholders)switch(n.type){case r.aK.Single:l=function(t,e){return e.map((e=>i(t,e.position,e.position,e.monomers))).reduce(((t,e)=>t.concat(e)),[])}(o.m,n.placeholders);break;case r.aK.Matrix:l=function(t,e){let n=[t];for(const t of e){const e=n.map((e=>i(e,t.position,t.position,t.monomers)));n=e.reduce(((t,e)=>t.concat(e)),[])}return n}(o.m,n.placeholders)}let u=[];n.breadthPlaceholders&&(u=function(t,e){if(0==e.length)return[];let n=[t];for(const t of e){const e=n.map((e=>i(e,t.start,t.end,t.monomers)));n=e.reduce(((t,e)=>t.concat(e)),[])}return n}(o.m,n.breadthPlaceholders)),l=l.concat(u),n.keepOriginal&&(l=[a,...l]);const c=l.map((t=>[org.helm.webeditor.IO.getHelm(t),t.name]));return c}},1296:(t,e,n)=>{"use strict";var r;n.d(e,{J5:()=>o,aK:()=>r}),function(t){t.Single="single",t.Matrix="matrix",t.Library="library"}(r||(r={})),Error;class o extends Error{constructor(t,e){super(`Invalid reaction '${t}'.`),this.type="InvalidReactionError"}}},6082:t=>{"use strict";t.exports=DG},4328:t=>{"use strict";t.exports=grok},7389:t=>{"use strict";t.exports=ui},1991:t=>{"use strict";t.exports=wu}},e={};function n(r){var o=e[r];if(void 0!==o)return o.exports;var i=e[r]={id:r,loaded:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.loaded=!0,i.exports}n.m=t,n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.u=t=>t+".js",n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.nmd=t=>(t.paths=[],t.children||(t.children=[]),t),(()=>{var t;n.g.importScripts&&(t=n.g.location+"");var e=n.g.document;if(!t&&e&&(e.currentScript&&"SCRIPT"===e.currentScript.tagName.toUpperCase()&&(t=e.currentScript.src),!t)){var r=e.getElementsByTagName("script");if(r.length)for(var o=r.length-1;o>-1&&(!t||!/^http(s?):/.test(t));)t=r[o--].src}if(!t)throw new Error("Automatic publicPath is not supported in this browser");t=t.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),n.p=t})(),n.b=document.baseURI||self.location.href,n.nc=void 0;var r={};(()=>{"use strict";n.r(r),n.d(r,{_package:()=>D,initAutoTests:()=>F,test:()=>B,tests:()=>e.CN});var t=n(6082),e=n(8070),o=n(4328),i=n(6686);class s extends t.Package{async getTranslationHelper(){return await o.functions.call(`${this.name}:getTranslationHelper`)}}function a(t,e,n){return n.createFormatConverter(t,e).convertTo(i.NO.HELM)}function l(t,e,n){return n.createFormatConverter(t,i.NO.HELM).convertTo(e)}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)}$$$$"}},c={"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"};(0,e.L1)("Formats to HELM",(()=>{let t;(0,e.gM)((async()=>{t=await D.getTranslationHelper()}));for(const n of Object.keys(u))for(const[r,o]of Object.entries(u[n]))(0,e.t6)(`${n} to HELM`,(async()=>{const i=o,s=a(r,n,t);(0,e.E3)(s,i)}))})),(0,e.L1)("HELM to Formats",(()=>{let t;(0,e.gM)((async()=>{t=await D.getTranslationHelper()}));for(const n of Object.keys(u))for(const[r,o]of Object.entries(u[n]))(0,e.t6)(`${n} to HELM`,(async()=>{const i=r,s=l(o,n,t);(0,e.E3)(s,i)}))}));var h=n(3480);(0,e.L1)("HELM to Nucleotides",(()=>{let t;(0,e.gM)((async()=>{t=await D.getTranslationHelper()})),Object.entries(c).forEach((([n,r],o)=>{(0,e.t6)(`Sequence ${o+1} to nucleotides`,(async()=>{const o=r,i=(0,h.Hs)(n,t.monomerLibWrapper);(0,e.E3)(i,o)}))}))}));const d={[i.NO.AXOLABS]:"Afcgacsu",[i.NO.HELM]:"RNA1{[fR](A)p.[25r](C)p.[25r](G)p.[25r](A)p.[25r](C)[sp].[25r](U)}$$$$"};(0,e.L1)("Formats support",(()=>{let t;(0,e.gM)((async()=>{t=await D.getTranslationHelper()})),Object.entries(d).forEach((([n,r])=>{(0,e.t6)(`All formats for ${n}`,(async()=>{const o=function(t,e,n){const r=n.createSequenceValidator(t).getInvalidCodeIndex(e);return(0,h.bD)(t,r,e,n)}(r,n,t),i=Object.keys(o).length,s=Object.keys(u).length+1;(0,e.E3)(!0,s<=i)}))}))}));var f=n(9192);(0,e.L1)("files",(()=>{let n;(0,e.gM)((async()=>{n=await D.getTranslationHelper()})),(0,e.t6)("list",(async()=>{let r;const o=t.DataFrame.fromColumns([t.Column.string("subTest"),r=t.Column.bool("success"),t.Column.string("format"),t.Column.string("src"),t.Column.string("res"),t.Column.string("tgt"),t.Column.string("error"),t.Column.string("stack")]),i=await D.files.list("tests",!0,".csv");for(const r of i){const i=t.DataFrame.fromCsv(await r.readAsString()),s=i.columns.byIndex(0),l=s.name,u=i.columns.byIndex(1),c=i.rowCount;for(let t=0;t<c;++t){const i=o.rows.addNew();i.subTest=`${r.name}, row: ${t}`;try{const r=s.get(t),o=u.get(t);i.format=l,i.src=r,i.tgt=o;const c=i.res=a(r,l,n);(0,e.E3)(c,o),i.success=!0}catch(t){const[e,n]=(0,f.AP)(t);i.error=e,i.stack=n,i.success=!1}}}0==o.rowCount&&o.rows.addNew(["empty",!0,"",""]);const s=r.toList().findIndex((t=>1!=t));if(-1!=s){const t=o.rows.get(s);throw new Error(`Subtest '${t.subTest}' failed: ${t.error}`)}return o}),{skipReason:"Can not create test in async manner based on files in Shares."})}));var p=n(8312),m=n(2003);class g{constructor(t,e,n,r,o,i){this.units=t,this.aligned=e,this.alphabet=n,this.alphabetSize=r,this.alphabetIsMultichar=o,this.separator=i}}async function y(e,n){const r=(await e()).getCol(n),i=await o.functions.call("Bio:detectMacromolecule",{col:r});if(i&&(r.semType=i),r.semType===t.SEMTYPE.MACROMOLECULE){const t=`Negative test detected semType='${r.semType}', units='${r.meta.units}'.`;throw new Error(t)}}async function b(n,r,i,s,a,l,u,c,h=null){const d=(await n()).col(r),f=await o.functions.call("Bio:detectMacromolecule",{col:d});f&&(d.semType=f),(0,e.E3)(d.semType,t.SEMTYPE.MACROMOLECULE),(0,e.E3)(d.meta.units,s),(0,e.E3)(d.getTag(m.gp.aligned),a),(0,e.E3)(d.getTag(m.gp.alphabet),l),h&&(0,e.E3)(d.getTag(m.gp.separator),h);const p=i.getSeqHandler(d);(0,e.E3)(p.getAlphabetSize(),u),(0,e.E3)(p.getAlphabetIsMultichar(),c),p.isHelm()||((0,e.E3)(p.aligned,a),(0,e.E3)(p.alphabet,l))}(0,e.L1)("PolyTool: detectors",(()=>{let n;(0,e.gM)((async()=>{n=await(0,p.Q)()}));const r={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 g(m.Hi.CUSTOM,"SEQ",m.YI.UN,13,!0,"-")}}};for(const[o,i]of Object.entries(r))(0,e.t6)(`${o}`,(async()=>{const e=async()=>t.DataFrame.fromCsv(i.csv);for(const t of i.neg??[])await y(e,t);for(const[t,r]of Object.entries(i.pos??{}))await b(e,t,n,r.units,r.aligned,r.alphabet,r.alphabetSize,r.alphabetIsMultichar,r.separator)}),{skipReason:"3156"})}));var v=n(4971);const C="Libraries",w="Settings",A="DuplicateMonomerPreferences";let x=Promise.resolve();async function E(){let t;return x=x.then((async()=>{const e=await o.userSettings.getValue(C,w,!0);t=e?JSON.parse(e):{exclude:[],explicit:[],duplicateMonomerPreferences:{}};const n=await o.userSettings.getValue(C,A,!0),r=n?JSON.parse(n):{};t.exclude=t.exclude instanceof Array?t.exclude:[],t.explicit=t.explicit instanceof Array?t.explicit:[],t.duplicateMonomerPreferences=t.duplicateMonomerPreferences instanceof Object?t.duplicateMonomerPreferences:{};for(const e in r){t.duplicateMonomerPreferences[e]=t.duplicateMonomerPreferences[e]??{};for(const n in r[e])for(const o of r[e][n])t.duplicateMonomerPreferences[e][o]=n}console.debug(`Bio: getUserLibSettings()\n${JSON.stringify(t,void 0,2)}`)})),await x,t}async function T(t){x=x.then((async()=>{t.duplicateMonomerPreferences=t.duplicateMonomerPreferences??{},console.debug(`Bio: setUserLibSettings()\n${JSON.stringify(t,void 0,2)}`);const e={};for(const n in t.duplicateMonomerPreferences){e[n]={};for(const r in t.duplicateMonomerPreferences[n]){const o=t.duplicateMonomerPreferences[n][r];e[n][o]=e[n][o]??[],e[n][o].push(r)}}await o.userSettings.add(C,A,JSON.stringify(e),!0),t.duplicateMonomerPreferences={},await o.userSettings.add(C,w,JSON.stringify(t),!0)})),await x}var S=n(6717),I=n(9124),_=n(4229),N=n(5174),P=n(6694);(0,e.L1)("PolyTool: Convert",(()=>{let n,r,i,s,a;(0,e.gM)((async()=>{i=await(0,S.j)(),n=await(0,I.b2)(),r=await(0,p.Q)(),s=await(0,v.pj)(),a=await E(),await s.loadMonomerLibForTests()})),(0,e.Pl)((async()=>{await T(a),await s.loadMonomerLib(!0)}));const l={"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[t,r]of Object.entries(l))(0,e.t6)(`toHelm-${t}`,(async()=>{const t=await(0,P.Q4)(["rules_example.json"]),o=(0,_.b)([r.src.seq],t,n);(0,e.E3)(o[0][0],r.tgt.helm)}));for(const[o,s]of Object.entries(l))(0,e.t6)(`toAtomicLevel-${o}`,(async()=>{const o=await(0,P.Q4)(["rules_example.json"]),[a,l,u]=(0,_.b)([s.src.seq],o,n),c=await(0,N.A)(o),h=t.Column.fromStrings("helm",a);h.semType=t.SEMTYPE.MACROMOLECULE,h.meta.units=m.Hi.HELM;const d=await r.helmToAtomicLevel(h,!1,!1,c);if(d.warnings&&d.warnings.length>0)throw new Error(d.warnings[0]);(0,e.E3)(null!=d.molCol,!0,".molCol is not null");const f=d.molCol.get(0),p=i.get_mol(f);try{const t={atomCount:p.get_num_atoms(),bondCount:p.get_num_bonds(),inchiKey:i.get_inchikey_for_inchi(p.get_inchi())};(0,e.Xk)(t,s.tgt.mol)}finally{p.delete()}}));(0,e.t6)("ui-col-wo-table",(async()=>{const n=D.name,r=Object.values(l).map((t=>t.src.seq)),i=Object.values(l).map((t=>t.tgt.helm)),s=t.Column.fromStrings("seq",r),a=await o.functions.call(`${n}:polyToolConvert2`,{seqCol:s,generateHelm:!0,chiralityEngine:!0,rules:["rules_example.json"]});(0,e.J6)(a.toList(),i),(0,e.E3)(a.semType,t.SEMTYPE.MACROMOLECULE),(0,e.E3)(a.meta.units,m.Hi.HELM),(0,e.E3)(a.dataFrame,null)})),(0,e.t6)("ui-col",(async()=>{const n=D.name,r=Object.values(l).map((t=>t.src.seq)),i=Object.values(l).map((t=>t.tgt.helm)),s=t.Column.fromStrings("seq",r),a=t.DataFrame.fromColumns([s]),u=o.shell.addTableView(a),c=await o.functions.call(`${n}:polyToolConvert2`,{seqCol:s,generateHelm:!0,chiralityEngine:!0,rules:["rules_example.json"]});(0,e.J6)(c.toList(),i),(0,e.E3)(c.semType,t.SEMTYPE.MACROMOLECULE),(0,e.E3)(c.meta.units,m.Hi.HELM),(0,e.E3)(c.dataFrame.id,a.id),await(0,e.PE)(u.grid.onAfterDrawContent,(()=>{}),(async()=>{u.grid.invalidate()}),15e3),(0,e.E3)(c.getTag(t.TAGS.CELL_RENDERER),"helm")}))}));var M=n(1296),L=n(3820);(0,e.L1)("PolyTool: Enumerate",(()=>{let t,n,r;(0,e.gM)((async()=>{t=await(0,I.b2)(),n=await(0,v.pj)(),r=await E(),await n.loadMonomerLibForTests()})),(0,e.Pl)((async()=>{await T(r),await n.loadMonomerLib(!0)}));const o={single1:{src:"PEPTIDE1{[Ac(1)].F.W.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",params:{type:M.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:M.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"}]},matrix1:{src:"PEPTIDE1{[Ac(1)].F.W.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",params:{type:M.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[t,n]of Object.entries(o))(0,e.t6)(`${t}`,(async()=>{const t=(0,L.o)(n.src,"",n.params);(0,e.J6)(t,n.tgt.map((t=>[t.seq,t.name])))}))})),(0,e.L1)("PolyTool: Enumerate",(()=>{let t,n,r;(0,e.gM)((async()=>{t=await(0,I.b2)(),n=await(0,v.pj)(),r=await E(),await n.loadMonomerLibForTests()})),(0,e.Pl)((async()=>{await T(r),await n.loadMonomerLib(!0)}));const o={breadth1:{src:"PEPTIDE1{[Ac(1)].F.W.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",params:{type:M.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:M.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:M.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:M.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[t,n]of Object.entries(o))(0,e.t6)(`${t}`,(async()=>{const t=(0,L.o)(n.src,"",n.params);(0,e.J6)(t,n.tgt.map((t=>[t.seq,t.name])))}))}));var O=n(6307),R=n(2125);(0,e.L1)("PolyTool: Chain: parseNotation",(()=>{let t;(0,e.gM)((async()=>{t=await(0,I.b2)()}));const n={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[r,o]of Object.entries(n))(0,e.t6)(`${r}`,(async()=>{await(0,P.Q4)(["rules_example.json"]);const n=await O.s.fromSeparator(o.src.seq,t),r=n.mol,i=t.createHelmWebEditor();i.editor.setMol(r);const s=i.editor.getHelm(),a=n.getHelm();(0,e.E3)(s,o.tgt.helm),(0,e.E3)(a,o.tgt.helm)}),"reaction2"==r?{skipReason:"reverse reaction"}:void 0);const r={"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[t,{inIdx:n,spIdx:o,outIdx:i,monomers:s}]of Object.entries(r))(0,e.t6)(`innerIdx-${t}`,(async()=>{const[t,r]=(0,R.M)(i,s);(0,e.E3)(t,n),(0,e.E3)(r,o)}));for(const[t,{inIdx:n,spIdx:o,outIdx:i,monomers:s}]of Object.entries(r))(0,e.t6)(`outerIdx-${t}`,(async()=>{const t=(0,R.j)(n,o,s);(0,e.E3)(t,i)}))})),(0,e.L1)("PolyTool: Chain",(()=>{let t;(0,e.gM)((async()=>{t=await(0,I.b2)()}));const n={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[r,{data:o,tgt:i}]of Object.entries(n))(0,e.t6)(`fromNotation-${r}`,(async()=>{const n=await(0,P.Q4)(["rules_example.json"]),r=O.s.fromSeparator(o.templateSeq,t);r.applyRules(n),r.check(!0),(0,e.J6)(r.monomers.map((t=>t.length)),i.mmChain.monomerCount),(0,e.E3)(r.linkages.length,i.mmChain.linkageCount),(0,e.E3)(r.getHelm(),o.mmHelm)}),{skipReason:"3157"});for(const[r,{data:o,tgt:i}]of Object.entries(n))(0,e.t6)(`parseNotation-${r}`,(async()=>{await(0,P.Q4)(["rules_example.json"]);const n=O.s.fromSeparator(o.templateSeq,t);n.check(!0),(0,e.J6)(n.monomers.map((t=>t.length)),i.templateChain.monomerCount),(0,e.E3)(n.linkages.length,i.templateChain.linkageCount),(0,e.E3)(n.getHelm(),o.templateHelm),(0,e.E3)(n.getNotation(),o.templateSeq)}));for(const[r,{data:o,tgt:i}]of Object.entries(n))(0,e.t6)(`parseHelm-${r}`,(async()=>{await(0,P.Q4)(["rules_example.json"]);const n=O.s.fromHelm(o.templateHelm,t);n.check(!0),(0,e.J6)(n.monomers.map((t=>t.length)),i.templateChain.monomerCount),(0,e.E3)(n.linkages.length,i.templateChain.linkageCount),(0,e.E3)(n.getHelm(),o.templateHelm),(0,e.E3)(n.getNotation(),o.templateSeq)}));for(const[r,{data:o,tgt:i}]of Object.entries(n))(0,e.t6)(`applyRules-${r}`,(async()=>{const n=await(0,P.Q4)(["rules_example.json"]),r=O.s.fromSeparator(o.templateSeq,t);r.applyRules(n),r.check(!0),(0,e.J6)(r.monomers.map((t=>t.length)),i.mmChain.monomerCount),(0,e.E3)(r.linkages.length,i.mmChain.linkageCount),(0,e.E3)(r.getHelm(),o.mmHelm)}),{skipReason:"applyRules is not implemented"})})),(0,e.L1)("toAtomicLevel",(()=>{let n,r,o;(0,e.gM)((async()=>{r=await(0,v.pj)(),n=await E(),o=await(0,S.j)(),await r.loadMonomerLibForTests()})),(0,e.Pl)((async()=>{await T(n),await r.loadMonomerLib(!0)})),(0,e.t6)("override",(async()=>{const n=r.getMonomerLib(),i=await D.files.readAsText("tests/polytool-reaction-lib.json"),s=JSON.parse(i).find((t=>"GGaz"===t.symbol));(0,e.E3)(null!=s,!0,"Monomer 'GGaz' not found.");const a={PEPTIDE:{GGaz:s}},l=n.override(a,"test"),u=await(0,p.Q)(),c=t.Column.fromList(t.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=t.SEMTYPE.MACROMOLECULE,c.meta.units=m.Hi.HELM;const h=await u.helmToAtomicLevel(c,!1,!1,l);(0,e.E3)(null!=h.molCol,!0,"Result molCol is null");const d=h.molCol.get(0);(0,e.E3)(!!d,!0,"Molfile is empty");const f=o.get_mol(d);try{const t=f.get_inchi(),n=o.get_inchikey_for_inchi(t);(0,e.E3)(f.get_num_bonds(),103),(0,e.E3)(f.get_num_atoms(),98),(0,e.E3)(n,"XPQUTLNSNIMERR-WKBTUBAPSA-N")}finally{f.delete()}})),(0,e.t6)("getNewMonomer",(async()=>{const t=await(0,S.j)(),n=r.getMonomerLib(),o=(await(0,P.Q4)(["rules_example.json"])).reactionRules.find((t=>"GGaz"==t.name)),[i,s]=(0,N.T)(t,n,o);(0,e.E3)(i?.[0],"azG_GGaz");const a=t.get_mol(s[0].molfile);try{const n=a.get_inchi();t.get_inchikey_for_inchi(n),(0,e.E3)(a.get_num_bonds(),7),(0,e.E3)(a.get_num_atoms(),8)}finally{a.delete()}}))}));const D=new s;async function B(n,r,o){const i=await(0,e.N$)({category:n,test:r,testContext:o,verbose:!0});return t.DataFrame.fromObjects(i)}async function F(){await(0,e.Xb)(D,D.getModule("package-test.js"))}})(),sequencetranslator_test=r})();
|
|
2
|
+
var sequencetranslator_test;(()=>{var t={6717:(t,e,n)=>{"use strict";n.d(e,{j:()=>o});var r=n(6082);async function o(){const t=r.Func.find({package:"Chem",name:"getRdKitModule"});if(0===t.length)throw new Error('Package "Chem" must be installed for getRdKitModule.');return(await t[0].prepare().call()).getOutputParamValue()}},3599:(t,e,n)=>{"use strict";n.d(e,{o:()=>r.o});var r=n(6869)},9124:(t,e,n)=>{"use strict";n.d(e,{b2:()=>i});var r=n(7389),o=n(6082);async function i(){const t="Helm",e=o.Func.find({package:t,name:"getHelmHelper"});if(0===e.length)throw new Error(`Package '${t}' must be installed for HelmHelper.`);return(await e[0].prepare().call()).getOutputParamValue()}o.JsInputBase,Error,r.input.helmAsync=async function(t,e){return(await i()).createHelmInput(t,e)}},8438:(t,e,n)=>{"use strict";function r(t){return t.startsWith("[")&&t.endsWith("]")?t.slice(1,-1):t}n.d(e,{D:()=>r})},8123:(t,e,n)=>{"use strict";n.d(e,{u:()=>r});const r={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:(t,e,n)=>{"use strict";n.d(e,{Y:()=>o});var r=n(3599);function o(t){let e;switch(t){case r.o.BASE:case r.o.SUGAR:case r.o.LINKER:case r.o.NUCLEOTIDE:case"nucleotide":e="RNA";break;case r.o.AA:e="PEPTIDE";break;case r.o.CHEM:e="CHEM";break;case r.o.BLOB:e="BLOB";break;default:e="PEPTIDE",console.warn(`Unexpected HelmType '${t}'`)}return e}},9235:(t,e,n)=>{"use strict";n.d(e,{H:()=>u,R:()=>l});var r=n(6082),o=n(1991),i=n.n(o),s=n(330),a=n(3599);async function l(t,e,o,l,u,c,h){const d=t.length,f=t.dataFrame,p=Math.max(navigator.hardwareConcurrency-2,1),m=new Array(p).fill(null).map((()=>new Worker(new URL(n.p+n.u(455),n.b)))),g=d/p,y=new Array(p),b=c.getSeqHandler(t),v="RNA"==l?a.o.NUCLEOTIDE:a.o.AA,C=i().count(0).take(t.length).map((t=>{const e=b.getSplitted(t);return i().count(0).take(e.length).map((t=>({position:t,symbol:e.getCanonical(t),biotype:v}))).toArray()})).toArray();for(let t=0;t<p;t++){const n=m[t],r=Math.floor(t*g),i=t===p-1?d:Math.floor((t+1)*g);y[t]=new Promise((t=>{n.onmessage=e=>{t(e.data)}})),n.postMessage({seqList:C,monomersDict:e,alphabet:o,polymerType:l,start:r,end:i})}const w=[],A=[];await Promise.all(y).then((t=>{for(const e of t)w.push(...e.molfiles),A.push(...e.warnings)})),setTimeout((()=>{m.forEach((t=>{t.terminate()}))}),0);const x=(0,s.qj)(f,t.name),E=r.Column.fromType(r.COLUMN_TYPE.STRING,x,t.length).init((t=>w[t]?.molfile));return E.semType=r.SEMTYPE.MOLECULE,E.meta.units=r.UNITS.Molecule.MOLBLOCK,E.setTag(".sequence-src-col",t.name),{molCol:E,warnings:A}}function u(t,e){const n={},o={};for(const i of t){const t=e.getWebEditorMonomer(i.biotype,i.symbol).backgroundcolor,a=(0,s.vG)(t??r.Color.toRgb(r.Color.mouseOverRows))??[1,0,0,.7];for(const t of i.atoms)n[t]=a;for(const t of i.bonds)o[t]=a}return{atoms:Object.keys(n).map((t=>parseInt(t))),bonds:Object.keys(o).map((t=>parseInt(t))),highlightAtomColors:n,highlightBondColors:o}}},3561:(t,e,n)=>{"use strict";n.d(e,{Hb:()=>l,YN:()=>m,gU:()=>u});var r=n(8123),o=n(294),i=n(3151),s=n(439),a=n(6197);function l(t,e,n){const o=new Map;for(const a of t.getMonomerSymbolsByType(e)){const l=t.getMonomer(e,a);if("RNA"===e&&("Branch"===l.monomerType||n===s.YI.DNA&&l.symbol===r.u.DEOXYRIBOSE.symbol||n===s.YI.RNA&&l.symbol===r.u.RIBOSE.symbol||l.symbol===r.u.PHOSPHATE.symbol)||"PEPTIDE"===e&&"Branch"!==l.monomerType){const t={};i.f6.forEach((e=>{t[e]=l[e]})),o.set(a,t)}}return o}function u(t,e,n,i){if(0===t.length)return o.vF.createEmpty();const l=p,{atomCount:u,bondCount:h,needsCapping:f}=l(t,e,n,i),g=new Array(u),y=new Array(h);let b,v=null,C=null;"PEPTIDE"===i?b=c:(b=d,v=n===s.YI.DNA?(0,o.xb)(e,r.u.DEOXYRIBOSE):(0,o.xb)(e,r.u.RIBOSE),C=(0,o.xb)(e,r.u.PHOSPHATE));const w={i:0,nodeShift:0,bondShift:0,backbonePositionShift:new Array(2).fill(0),branchPositionShift:new Array(2).fill(0),backboneAttachNode:0,branchAttachNode:0,flipFactor:1},A={sugar:v,phosphate:C,seqLength:t.length,atomCount:u,bondCount:h},x=new o.Cg,E=[];let T,S=0;for(w.i=0;w.i<A.seqLength;++w.i){const n=t[w.i];if(n.symbol===s._S)continue;const r=(0,o.xb)(e,{symbol:n.symbol,polymerType:(0,a.Y)(n.biotype)});T=r.terminalR2Atom;const i=w.nodeShift,l=w.bondShift;b(r,g,y,w,A),r.stereoAtoms?.forEach((t=>E.push(t+S))),S+=r.atoms.x.length;const u=w.nodeShift-i,c=new Array(u);for(let t=0;t<u;++t)c[t]=i+t;const h=w.bondShift-l,d=new Array(h);for(let t=0;t<h;++t)d[t]=l+t;x.set(w.i,{biotype:n.biotype,symbol:n.symbol,atoms:c,bonds:d})}f&&function(t,e,n,o,i=r.u.OXYGEN){const s=n.nodeShift+1;t[o.atomCount]=r.u.V3K_BEGIN_DATA_LINE+s+" "+(i??r.u.OXYGEN)+" "+m(n.backbonePositionShift[0])+" "+n.flipFactor*m(n.backbonePositionShift[1])+" 0.000000 0\n";const a=n.backboneAttachNode,l=s;e[o.bondCount]=r.u.V3K_BEGIN_DATA_LINE+n.bondShift+" 1 "+a+" "+l+"\n"}(g,y,w,A,T??r.u.OXYGEN);const I=r.u.V3K_BEGIN_COUNTS_LINE+u+" "+h+r.u.V3K_COUNTS_LINE_ENDING;let _="";return _+=r.u.V3K_HEADER_FIRST_LINE,_+=r.u.V3K_HEADER_SECOND_LINE,_+=r.u.V3K_BEGIN_CTAB_BLOCK,_+=I,_+=r.u.V3K_BEGIN_ATOM_BLOCK,_+=g.join(""),_+=r.u.V3K_END_ATOM_BLOCK,_+=r.u.V3K_BEGIN_BOND_BLOCK,_+=y.join(""),_+=r.u.V3K_END_BOND_BLOCK,E.length>0&&(_+=function(t){const e=[];let n=`M V30 MDLV30/STEABS ATOMS=(${t.length}`;for(let r=0;r<t.length;r++){const o=`${n} ${t[r]}`;o.length>76?(e.push(`${n} -\n`),n=`M V30 ${t[r]}`):n=o,r===t.length-1&&e.push(`${n})\n`)}return`M V30 BEGIN COLLECTION\n${e.join("")}M V30 END COLLECTION\n`}(E)),_+=r.u.V3K_END_CTAB_BLOCK,_+=r.u.V3K_END,{molfile:_,monomers:x}}function c(t,e,n,r){r.flipFactor=(-1)**(r.i%2),h(t,e,n,r)}function h(t,e,n,o){!function(t,e,n){for(let o=0;o<t.atoms.atomTypes.length;++o){const i=n.nodeShift+o+1;e[n.nodeShift+o]=r.u.V3K_BEGIN_DATA_LINE+i+" "+t.atoms.atomTypes[o]+" "+m(n.backbonePositionShift[0]+t.atoms.x[o])+" "+m(n.backbonePositionShift[1]+n.flipFactor*t.atoms.y[o])+" "+t.atoms.kwargs[o]}}(t,e,o),f(t,n,o),function(t,e,n){if(0!==n.backboneAttachNode){const o=n.bondShift,i=n.backboneAttachNode,s=t.meta.terminalNodes[0]+n.nodeShift;e[n.bondShift-1]=r.u.V3K_BEGIN_DATA_LINE+o+" 1 "+i+" "+s+"\n"}}(t,n,o),null!==t.meta.branchShift&&t.meta.terminalNodes.length>2&&function(t,e){e.branchAttachNode=e.nodeShift+t.meta.terminalNodes[2];for(let n=0;n<2;++n)e.branchPositionShift[n]=e.backbonePositionShift[n]+t.meta.branchShift[n]}(t,o),function(t,e){e.backboneAttachNode=e.nodeShift+t.meta.terminalNodes[1],e.bondShift+=t.bonds.atomPairs.length+1,e.nodeShift+=t.atoms.atomTypes.length,e.backbonePositionShift[0]+=t.meta.backboneShift?.[0]??0,e.backbonePositionShift[1]+=e.flipFactor*(t.meta.backboneShift?.[1]??0)}(t,o)}function d(t,e,n,o,i){if(0===o.i)h(i.sugar,e,n,o);else for(const t of[i.phosphate,i.sugar])h(t,e,n,o);!function(t,e,n,o){(function(t,e,n){for(let o=0;o<t.atoms.atomTypes.length;++o){const i=n.nodeShift+o+1;e[n.nodeShift+o]=r.u.V3K_BEGIN_DATA_LINE+i+" "+t.atoms.atomTypes[o]+" "+m(n.branchPositionShift[0]+t.atoms.x[o])+" "+m(n.branchPositionShift[1]+n.flipFactor*t.atoms.y[o])+" "+t.atoms.kwargs[o]}})(t,e,o),f(t,n,o),function(t,e,n){const o=n.bondShift,i=n.branchAttachNode,s=t.meta.terminalNodes[0]+n.nodeShift;e[o-1]=r.u.V3K_BEGIN_DATA_LINE+o+" 1 "+i+" "+s+"\n"}(t,n,o);const i=o.bondShift,s=o.branchAttachNode,a=t.meta.terminalNodes[0]+o.nodeShift;n[i-1]=r.u.V3K_BEGIN_DATA_LINE+i+" 1 "+s+" "+a+"\n",o.bondShift+=t.bonds.atomPairs.length+1,o.nodeShift+=t.atoms.atomTypes.length}(t,e,n,o)}function f(t,e,n){for(let o=0;o<t.bonds.atomPairs.length;++o){const i=n.bondShift+o+1,s=t.bonds.atomPairs[o][0]+n.nodeShift,a=t.bonds.atomPairs[o][1]+n.nodeShift;let l="";if(t.bonds.bondConfiguration.has(o)){let e=t.bonds.bondConfiguration.get(o);n.flipFactor<0&&(e=1===e?3:1),l=" CFG="+e}const u=t.bonds.kwargs.has(o)?" "+t.bonds.kwargs.get(o):"";e[n.bondShift+o]=r.u.V3K_BEGIN_DATA_LINE+i+" "+t.bonds.bondTypes[o]+" "+s+" "+a+l+u+"\n"}}function p(t,e,n,i){let l=0,u=0,c=0,h=!0,d=null;for(const n of t)if(n.symbol!==s._S){if("*"==n.symbol)throw new Error("Gap canonical symbol is '', not '*");d=(0,o.xb)(e,{symbol:n.symbol,polymerType:(0,a.Y)(n.biotype)}),l+=d.atoms.x.length,u+=d.bonds.bondTypes.length,c++}if("PEPTIDE"===i)l+=1,u+=c,c>0&&((d?.meta?.rNodes?.length??0)<2||d?.terminalR2Atom?.toLowerCase()===r.u.HYDROGEN.toLowerCase())&&(h=!1,l-=1,u-=1);else{const i=n===s.YI.DNA?(0,o.xb)(e,r.u.DEOXYRIBOSE):(0,o.xb)(e,r.u.RIBOSE),a=(0,o.xb)(e,r.u.PHOSPHATE);l+=(t.length-1)*a.atoms.x.length,l+=t.length*i.atoms.x.length,l+=1,u+=(t.length-1)*a.bonds.bondTypes.length,u+=t.length*i.bonds.bondTypes.length,u-=1,u+=3*t.length}return{atomCount:l,bondCount:u,needsCapping:h}}function m(t){return Math.round(r.u.PRECISION_FACTOR*t)/r.u.PRECISION_FACTOR}},6077:(t,e,n)=>{"use strict";n.d(e,{C4:()=>p,eM:()=>m});var r=n(4328),o=n(6082),i=n(1991),s=n.n(i),a=n(439),l=n(3561),u=n(9235),c=n(294),h=n(9192),d=n(330),f=n(8123);async function p(t,e,n,i,l){if(e.semType!==o.SEMTYPE.MACROMOLECULE)return{molCol:null,warnings:[`Only the ${o.SEMTYPE.MACROMOLECULE} columns can be converted to atomic level, the chosen column has semType '${e.semType}'`]};let c=e;const f=i.getSeqHandler(e);let p,g;f.notation!==a.Hi.SEPARATOR&&f.notation!==a.Hi.BILN&&(c=f.convert(a.Hi.SEPARATOR,"."),c.name=e.name);try{g=i.getSeqHandler(c).alphabet,p=(0,d.pz)(g)}catch(t){const[e,n]=(0,h.AP)(t);return{molCol:null,warnings:[e]}}const y=function(t,e){const n=t.length,o=new Array(n),i=e.getSeqHandler(t);let a=!1;const l=i.defaultBiotype;for(let t=0;t<n;++t){const e=i.getSplitted(t);a||(a=0===e.length),o[t]=s().count(0).take(e.length).filter((t=>!e.isGap(t))).map((t=>({position:t,biotype:l,symbol:e.getCanonical(t)}))).toArray()}return a&&r.shell.warning(`Some values in the "${t.name}" column are empty`),o}(c,i),b=m(y,p,g,n,l),v=c.length,C=await(0,u.R)(c,b,g,p,n,i,l);C.warnings.length>.05*v&&r.shell.warning(`Molfile conversion resulted in ${C.warnings.length} errors`);const w=o.Func.find({name:"convertToV3KViaOCL"})[0];if(w&&C.molCol)try{const t=C.molCol.toList(),e=await w.apply({mols:t});C.molCol.init((n=>e[n]?e[n]:t[n]))}catch(t){console.error(t)}return C}function m(t,e,n,r,o){const i=(0,l.Hb)(r,e,n),s={},u={value:null};if("RNA"===e){const t=n===a.YI.RNA?[f.u.RIBOSE,f.u.PHOSPHATE]:[f.u.DEOXYRIBOSE,f.u.PHOSPHATE];for(const n of t)g(s,n.symbol,i,o,e,u)}for(let n=0;n<t.length;++n){const r=t[n];for(const t of r){const n=t.symbol;if(""!==n)try{if("RNA"===e&&3===n.split(/\(|\)/).filter((t=>!!t)).length){const t=n.split(/\(|\)/)[1];g(s,t,i,o,e,u),s[e]?.[t]&&(s[e][n]=s[e][t])}else g(s,n,i,o,e,u)}catch(t){const e=t instanceof Error?t.message:t.toString(),r=t instanceof Error?t.stack:void 0;throw console.error(`bio lib: getMonomersDictFromLib() sym='${n}', error:\n${e}\n${r}`),new Error(`Can't get monomer '${n}' from library: ${e}`)}}}return s}function g(t,e,n,r,o,i){const s={polymerType:o,symbol:e};if(!(0,c.bq)(t,s)){const a=function(t,e,n,r,o){if(e.has(t)){const s=e.get(t),a=function(t){const e=[];for(const n of t){let t=n.capGroupSmiles;t||(t=n.capGroupSMILES),t=t.replace(/(\[|\]|\*|:|\d)/g,"").replace("OH","O").replace("Oh","O"),e.push(t)}return e}(s.rgroups),u=(i=s.molfile).includes("V3000")?function(t){const e=new Map,n=/M V30 (\d+) R#.+RGROUPS=\((\d+) (\d+)\).*/gm;let r;for(;null!==(r=n.exec(t));)r.index===n.lastIndex&&n.lastIndex++,e.set(parseInt(r[1]),parseInt(r[3]));return e}(i):function(t){const e=new Map;let n=t.indexOf(f.u.V2K_A_LINE,0),r=n;for(;-1!==n;){r=t.indexOf("\n",n);const o=parseInt(t.substring(n,r).replace(/^A\s+/,""));n=t.indexOf("R",r),r=t.indexOf("\n",n);const i=parseInt(t.substring(n,r).replace(/^R/,""));e.set(o,i),n=t.indexOf(f.u.V2K_A_LINE,r)}for(n=t.indexOf(f.u.V2K_RGP_LINE,0),r=t.indexOf("\n",n);-1!==n;){n+=f.u.V2K_RGP_SHIFT,r=t.indexOf("\n",n);const o=t.substring(n,r).replaceAll(/\s+/g," ").split(" ").map((t=>parseInt(t))).slice(1);for(let t=0;t<o.length;t+=2){if(e.has(o[t])&&e.get(o[t])!==o[t+1])throw new Error(`r-group index ${o[t]} has already been added with a different value`);e.set(o[t],o[t+1])}n=t.indexOf(f.u.V2K_RGP_LINE,r)}return e}(i),c=s.molfile.includes("V3000")?s.molfile:function(t,e){const n=e.get_mol(function(t){return t.split("\n").map((t=>{const e=t.indexOf(" R# "),n=t.indexOf(" R ");if(-1===e&&-1===n)return t;const r=-1!==e?e:n,o=t.split("");for(let t=r+5;t<o.length;t++)" "!==o[t]&&(o[t]="0");return o.join("")})).join("\n")}(t)),r=n.get_v3Kmolblock();return n.delete(),r}(function(t){let e=t.indexOf(f.u.V2K_A_LINE,0);-1===e&&(e=t.indexOf(f.u.V2K_RGP_LINE));const n=t.indexOf(f.u.V3K_END,e);return t.substring(0,e)+t.substring(n)}(s.molfile),n),h=function(t){let e=(t=t.replaceAll("\r","")).indexOf(f.u.V3K_BEGIN_COUNTS_LINE)+f.u.V3K_COUNTS_SHIFT,n=t.indexOf(" ",e+1);const r=parseInt(t.substring(e,n));return e=n+1,n=t.indexOf(" ",e+1),{atomCount:r,bondCount:parseInt(t.substring(e,n))}}(c),d=function(t,e){const n=new Array(e),r=new Float32Array(e),o=new Float32Array(e),i=new Array(e);let s=t.indexOf(f.u.V3K_BEGIN_ATOM_BLOCK);s=t.indexOf("\n",s);let a=s;for(let l=0;l<e;l++){s=t.indexOf(f.u.V3K_BEGIN_DATA_LINE,s)+f.u.V3K_IDX_SHIFT,a=t.indexOf(" ",s),s=a+1,a=t.indexOf(" ",s),n[l]=t.substring(s,a);const e=new Array(2);for(let n=0;n<2;++n)s=a+1,a=t.indexOf(" ",s),e[n]=parseFloat(t.substring(s,a));r[l]=e[0],o[l]=e[1],s=a,a=t.indexOf("\n",s)+1,i[l]=t.slice(s,a),s=a}return{atomTypes:n,x:r,y:o,kwargs:i}}(c,h.atomCount),p=function(t,e){const n=new Uint32Array(e),r=new Array(e),o=new Map,i=new Map;let s=t.indexOf(f.u.V3K_BEGIN_BOND_BLOCK);s=t.indexOf("\n",s);let a=s;for(let l=0;l<e;++l){const e=new Array(3);s=t.indexOf(f.u.V3K_BEGIN_DATA_LINE,a)+f.u.V3K_IDX_SHIFT,a=t.indexOf(" ",s);for(let n=0;n<3;++n)s=a+1,a=Math.min(t.indexOf("\n",s),t.indexOf(" ",s)),e[n]=parseInt(t.slice(s,a));n[l]=e[0],r[l]=e.slice(1);const u=t.indexOf("\n",s);let c=t.slice(a,u),h=c.indexOf(f.u.V3K_BOND_CONFIG);if(-1!==h){h=c.indexOf("=",h)+1;let t=c.indexOf(" ",h);-1===t&&(t=c.length);const e=parseInt(c.slice(h,t));o.set(l,e);const n=f.u.V3K_BOND_CONFIG+e.toString();c=c.replace(n,"")}c||i.set(l,c)}return{bondTypes:n,atomPairs:r,bondConfiguration:o,kwargs:i}}(c,h.bondCount),m=function(t,e,n,r){const o={backboneShift:null,branchShift:null,terminalNodes:[],rNodes:[]};if(n&&r&&[1,2].some((t=>!Array.from(r.values()).find((e=>e==t))))){const o=[1,2].find((t=>!Array.from(r.values()).find((e=>e==t)))),i=[1,2].find((t=>Array.from(r.values()).find((e=>e==t)))),s=Array.from(r.keys()).find((t=>r.get(t)===i))-1,a=t.x[s],l=t.y[s],u=e.atomPairs.find((t=>t.includes(s+1))).find((t=>t!==s+1))-1;let c=t.x.reduce(((e,n,r)=>{if(r===s)return e;if(r===u)return e;const o=t.y[r];return Math.sqrt((n-a)**2+(o-l)**2)>Math.sqrt((t.x[e]-a)**2+(t.y[e]-l)**2)?r:e}),-1);if(-1===c&&(c=t.x.length,t.x=new Float32Array([...t.x,-a]),t.y=new Float32Array([...t.y,-l]),t.atomTypes=[...t.atomTypes,"H"],t.kwargs=[...t.kwargs,""],e.atomPairs.push([u+1,c+1]),e.bondTypes=new Uint32Array([...e.bondTypes,1]),e.kwargs.set(e.atomPairs.length-1,"")),r.set(c+1,o),1===o)n.unshift(t.atomTypes[c]);else{if(2!==o)throw new Error(`Unexpected missing R-group: ${o}`);n.splice(1,0,t.atomTypes[c])}}return function(t,e,n){for(const[r,o]of n)t.atomTypes[r-1]=e[o-1]}(t,n,r),function(t,e){e.rNodes=Array.from(t.keys());for(let n=0;n<e.rNodes.length;n++)for(const r of[1,2])if(t.get(e.rNodes[n])===r){const t=e.rNodes[r-1];e.rNodes[r-1]=e.rNodes[n],e.rNodes[n]=t}}(r,o),y(e,o),o}(d,p,a,u),g=function(t){let e=[],n=t.indexOf("M V30 MDLV30/STEABS ATOMS=(");for(;-1!==n;){n+=28;const r=t.indexOf(")",n);e=e.concat(t.substring(n,r).split(" ").slice(1).map((t=>parseInt(t)))),n=r,n=t.indexOf("M V30 MDLV30/STEABS ATOMS=(",n)}return e}(c),v={atoms:d,bonds:p,meta:m,stereoAtoms:g};return"PEPTIDE"===r?function(t){const e=t.meta.terminalNodes[0]-1,n=t.meta.rNodes[0]-1,r=t.atoms.x,o=t.atoms.y;S(t,-r[e],-o[e]);const i=A(r[n],o[n]);x(t.atoms,-i),r[t.meta.rNodes[1]-1]<0&&E(t);const s=function(t){const e=function(t){const e=new Map;for(const n of t.bonds.atomPairs)for(let t=0;t<2;t++){const r=n[t],o=n[(t+1)%2];e.has(r)?e.get(r)?.push(o):e.set(r,new Array(1).fill(o))}return e}(t);let n=0;const r=t.atoms.atomTypes.length;let o=0;if(t.meta.terminalNodes.length<2)return null;for(;0===n;){const i=e.get(t.meta.terminalNodes[1])[o];if(t.atoms.atomTypes[i-1]===f.u.OXYGEN&&i!==t.meta.rNodes[1]&&(n=i),o++,o>r)return null}return n}(t);null!=s&&(function(t,e){t.atoms.y[t.meta.rNodes[1]-1]<0&&t.atoms.y[e-1]<0&&(function(t){T(t,!0)}(t),x(t.atoms,-function(t,e){return A(t,e)+Math.PI/2}(t.atoms.x[t.meta.terminalNodes[1]-1],t.atoms.y[t.meta.terminalNodes[1]-1])))}(t,s),function(t,e){const n=t.atoms.x;n[t.meta.rNodes[1]-1]>n[e-1]&&function(t,e,n){const r=e-1,o=n-1,i=t.atoms.x,s=t.atoms.y,a=i[r],l=s[r];i[r]=i[o],s[r]=s[o],i[o]=a,s[o]=l}(t,e,t.meta.rNodes[1])}(t,s))}(v):t===f.u.RIBOSE.symbol||t===f.u.DEOXYRIBOSE.symbol?function(t,e){const n=t.atoms.x,r=t.atoms.y;let o=t.meta.terminalNodes[0]-1;const i=t.meta.rNodes[1]-1;S(t,-n[o],-r[o]);const s=A(n[t.meta.rNodes[2]-1],r[t.meta.rNodes[2]-1]);x(t.atoms,-s),n[t.meta.rNodes[0]-1]>n[t.meta.rNodes[1]-1]&&E(t);const a=A(n[i],r[i]);x(t.atoms,3*Math.PI/2-a),e.value=function(t){const e=t.atoms.x,n=t.atoms.y,r=t.meta.rNodes[2]-1,o=t.meta.terminalNodes[2]-1,i=e[r]-e[o],s=n[r]-n[o];return Math.atan2(i,s)}(t),o=t.meta.terminalNodes[0]-1,S(t,-n[o],-r[o])}(v,o):t===f.u.PHOSPHATE.symbol?function(t){const e=t.meta.rNodes[1]-1,n=t.meta.rNodes[0]-1,r=t.atoms.x,o=t.atoms.y;S(t,-r[e],-o[e]);const i=A(r[n],o[n]);x(t.atoms,Math.PI/2-i)}(v):function(t,e){const n=t.atoms.x,r=t.atoms.y,o=t.meta.terminalNodes[0]-1,i=t.meta.rNodes[0]-1;S(t,-n[o],-r[o]);const s=A(n[i],r[i]),a=e.value;if(!a)throw new Error("The value of sugarBranchToOYAngle is null");x(t.atoms,Math.PI-s+a);const u=function(t,e){return(0,l.YN)(Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2))}({x:n[t.meta.rNodes[0]-1],y:r[t.meta.rNodes[0]-1]},{x:n[t.meta.terminalNodes[0]-1],y:r[t.meta.terminalNodes[0]-1]});if(1!=u)for(let t=0;t<n.length;++t)n[t]=(0,l.YN)(n[t]/u),r[t]=(0,l.YN)(r[t]/u)}(v,o),function(t,e,n){if("PEPTIDE"===t){b(e,t);const n=C(e,e.meta.rNodes[1]);n?.removedAtom&&(e.terminalR2Atom=n.removedAtom)}else n===f.u.RIBOSE.symbol||n===f.u.DEOXYRIBOSE.symbol?(C(e,e.meta.rNodes[1]),e.meta.rNodes[1]=e.meta.terminalNodes[1],y(e.bonds,e.meta),b(e,t),C(e,e.meta.rNodes[1]),C(e,e.meta.rNodes[0]),C(e,e.meta.rNodes[2])):n===f.u.PHOSPHATE.symbol&&(e.meta.terminalNodes[0]=e.meta.rNodes[0],S(e,-e.atoms.x[e.meta.terminalNodes[0]-1],-e.atoms.y[e.meta.terminalNodes[0]-1]),b(e,t),C(e,e.meta.rNodes[1]))}(r,v,t),function(t){let e=0;for(;e<t.atoms.atomTypes.length;)t.atoms.atomTypes[e]===f.u.HYDROGEN&&(C(t,e+1),--e),++e}(v),function(t){let e=0;for(;e<t.atoms.atomTypes.length;)"oh"===t.atoms.atomTypes[e]?.toLowerCase()&&(t.atoms.atomTypes[e]="O"),"?"===t.atoms.atomTypes[e]&&(t.atoms.atomTypes[e]="H"),++e}(v),function(t){const e=" RGROUPS=(1 1)";for(let n=0;n<(t.atoms.kwargs?.length??0);n++){const r=t.atoms.kwargs[n];r&&r.includes(e)&&(t.atoms.kwargs[n]=r.replace(e,""))}}(v),v}var i;return null}(e,n,r,o,i);if(!a)throw new Error(`Monomer with symbol '${e}' is absent the monomer library`);(0,c.LQ)(t,s,a)}}function y(t,e){const n=e.rNodes;e.terminalNodes=new Array(n.length).fill(0);const r=e.terminalNodes,o=t.atomPairs;let i=0,s=0;for(;i<o.length&&s<r.length;){for(let t=0;t<r.length;++t)for(let e=0;e<2;++e)o[i][e]===n[t]&&(r[t]=o[i][(e+1)%2],n.length,++s);++i}}function b(t,e){t.meta.rNodes.length>1&&(t.meta.backboneShift=v(t,t.meta.rNodes[1]-1,t.meta.terminalNodes[0]-1)),"RNA"===e&&t.meta.rNodes.length>2&&(t.meta.branchShift=v(t,t.meta.rNodes[2]-1,t.meta.terminalNodes[0]-1))}function v(t,e,n){return[(0,l.YN)(t.atoms.x[e]-t.atoms.x[n]),(0,l.YN)(t.atoms.y[e]-t.atoms.y[n])]}function C(t,e){if(void 0!==e){const n=e-1,r=t.atoms,o=t.bonds,i=t.meta,s=r.atomTypes.splice(n,1)[0];r.x=w(Float32Array,r.x,n,1),r.y=w(Float32Array,r.y,n,1),r.kwargs.splice(n,1);for(let t=0;t<i.terminalNodes.length;++t)i.terminalNodes[t]>e?--i.terminalNodes[t]:i.terminalNodes[t]===e&&(i.terminalNodes[t]=-1);for(let t=0;t<i.rNodes.length;++t)i.rNodes[t]>e?--i.rNodes[t]:i.rNodes[t]===e&&(i.rNodes[t]=-1);let a=0;for(;a<o.atomPairs.length;){const t=o.atomPairs[a][0],n=o.atomPairs[a][1];t===e||n===e?(o.atomPairs.splice(a,1),o.bondTypes=w(Uint32Array,o.bondTypes,a,1),o.bondConfiguration.has(a)&&o.bondConfiguration.delete(a),o.kwargs.has(a)&&o.kwargs.delete(a),--a):(o.atomPairs[a][0]=t>e?t-1:t,o.atomPairs[a][1]=n>e?n-1:n),++a}let l=Array.from(o.bondConfiguration.keys());return l.forEach((t=>{if(o.bondConfiguration.has(t)&&t>n){const e=o.bondConfiguration.get(t);o.bondConfiguration.delete(t),o.bondConfiguration.set(t-1,e)}})),l=Array.from(o.kwargs.keys()),l.forEach((t=>{if(o.kwargs.has(t)&&t>n){const e=o.kwargs.get(t);o.kwargs.delete(t),o.kwargs.set(t-1,e)}})),s?{removedAtom:s}:void 0}}function w(t,e,n,r){const o=new t(e.length-r);let i=0,s=0;for(;i<e.length;)i===n&&(i+=r),o[s]=e[i],++s,++i;return o}function A(t,e){let n;if(0===t)n=e>0?0:Math.PI;else if(0===e)n=t>0?-Math.PI/2:Math.PI/2;else{const r=e/t,o=Math.atan(r);n=t<0?Math.PI/2+o:-Math.PI/2+o}return n}function x(t,e){if(0!==e){const n=t.x,r=t.y,o=Math.cos(e),i=Math.sin(e);for(let t=0;t<n.length;++t){const e=n[t];n[t]=(0,l.YN)(e*o-r[t]*i),r[t]=(0,l.YN)(e*i+r[t]*o)}}}function E(t){T(t,!1)}function T(t,e){if(e){const e=t.atoms.y;for(let t=0;t<e.length;t++)e[t]=-e[t]}else{const e=t.atoms.x;for(let t=0;t<e.length;t++)e[t]=-e[t]}const n=t.bonds.bondConfiguration;for(const[t,e]of n){const r=1===e?3:1;n.set(t,r)}}function S(t,e,n){const r=t.atoms.x,o=t.atoms.y;for(let t=0;t<r.length;++t)r[t]=(0,l.YN)(r[t]+e),void 0!==n&&(o[t]=(0,l.YN)(o[t]+n))}},294:(t,e,n)=>{"use strict";function r(t,e){return t[e.polymerType]?.[e.symbol]}function o(t,e){return!!t[e.polymerType]?.[e.symbol]}function i(t,e,n){let r=t[e.polymerType];r||(r=t[e.polymerType]={}),r[e.symbol]=n}n.d(e,{Cg:()=>s,LQ:()=>i,bq:()=>o,vF:()=>a,xb:()=>r});class s extends Map{constructor(t){super(t)}}class a{constructor(t,e){this.molfile=t,this.monomers=e}static createEmpty(){return new a("",new s(null))}}},330:(t,e,n)=>{"use strict";n.d(e,{pz:()=>i,qj:()=>o,vG:()=>s});var r=n(2003);function o(t,e){return function(t,e){return t?t.columns.getUnusedName(e):e}(t,`molfile(${e})`)}function i(t){let e;if(t===r.YI.PT||t===r.YI.UN)e="PEPTIDE";else{if(t!==r.YI.RNA&&t!==r.YI.DNA)throw new Error(`Unexpected alphabet '${t}'.`);e="RNA"}return e}function s(t){const e=7===t.length?/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t):/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return e?[parseInt(e[1],16)/256,parseInt(e[2],16)/256,parseInt(e[3],16)/256,e.length>4?parseInt(e[4],16)/256:.3]:null}},4971:(t,e,n)=>{"use strict";n.d(e,{pj:()=>o});var r=n(6082);async function o(){const t=r.Func.find({package:"Bio",name:"getMonomerLibHelper"});if(0===t.length)throw new Error('Package "Bio" must be installed for MonomerLibHelper.');return(await t[0].prepare().call()).getOutputParamValue()}},3151:(t,e,n)=>{"use strict";n.d(e,{f6:()=>r,pe:()=>o});const r=["symbol","molfile","rgroups","name"],o={monomerType:"Backbone",smiles:"",name:"",author:"Datagrok",molfile:"",naturalAnalog:"",rgroups:[],createDate:null,id:0,polymerType:"PEPTIDE",symbol:""};new RegExp("[rd]\\((\\w)\\)p?","g")},9192:(t,e,n)=>{"use strict";function r(t){return"string"==typeof t||t instanceof String?t:"StateError"===t.constructor.name?t.message:"StateError"===t.constructor.name&&"$thrownJsError"in t?r(t.$thrownJsError):t instanceof Error?t.message:t.toString()}function o(t){return t instanceof Error?t.stack:"StateError"===t.constructor.name&&"$thrownJsError"in t?o(t.$thrownJsError):void 0}function i(t){return[r(t),o(t)]}n.d(e,{AP:()=>i})},439:(t,e,n)=>{"use strict";n.d(e,{Hi:()=>r,YI:()=>o,_S:()=>l,b9:()=>u,gp:()=>i});var r,o,i,s=n(2738);!function(t){t.FASTA="fasta",t.SEPARATOR="separator",t.HELM="helm",t.CUSTOM="custom",t.BILN="biln"}(r||(r={})),function(t){t.DNA="DNA",t.RNA="RNA",t.PT="PT",t.UN="UN"}(o||(o={})),function(t){t.aligned="aligned",t.alphabet="alphabet",t.alphabetSize=".alphabetSize",t.alphabetIsMultichar=".alphabetIsMultichar",t.separator="separator",t.isHelmCompatible=".isHelmCompatible",t.positionNames=".positionNames",t.positionLabels=".positionLabels",t.regions=".regions",t.positionShift=".positionShift",t.selectedPosition=".selectedPosition",t.polymerTypeColumnName=".polymerTypeColumnName"}(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.a(o.PT,a.fasta.peptide,.5),new s.a(o.DNA,a.fasta.dna,.55),new s.a(o.RNA,a.fasta.rna,.55),""),u={[r.FASTA]:"-",[r.SEPARATOR]:"",[r.HELM]:"*",[r.BILN]:""}},2003:(t,e,n)=>{"use strict";n.d(e,{Hi:()=>r.Hi,YI:()=>r.YI,dh:()=>o.dh,gp:()=>r.gp,qp:()=>o.qp,zS:()=>o.zS});var r=n(439),o=n(7291)},2738:(t,e,n)=>{"use strict";n.d(e,{a:()=>r});class r{constructor(t,e,n){this.name=t,this.alphabet=e,this.cutoff=n}}},7291:(t,e,n)=>{"use strict";n.d(e,{Mu:()=>y,dh:()=>v,zS:()=>A,qp:()=>C});var r=n(6082),o=n(1991),i=n.n(o),s=(n(2738),n(439));class a{static makePalette(t,e=!1,n=a){const r={};return t.forEach((t=>{const n=t[0],o=t[1];n.forEach(((t,n)=>{r[t]=this.colourPalette[o][e?0:n]}))})),new n(r)}constructor(t){this._palette=t}get(t,e){return this._palette[t]}}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(t){const e=t in l.aaSynonyms?l.aaSynonyms[t]:t;return super.get(e)}}l.aaSynonyms={MeNle:"L",MeA:"A",MeG:"G",MeF:"F"};class u{static getPalette(t="grok"){switch(t){case"grok":return l.GrokGroups;case"lesk":return l.Lesk;default:throw new Error(`ChemPalette: scheme \`${t}\` does not exist`)}}static getInnerOuter(t){let e=0,n="",r="";for(const o of t)"("==o?e++:")"==o?e--:e?n+=o:r+=o;return isNaN(parseInt(n))?[r,n]:[r,""]}static getColorAAPivot(t="",e="grok"){const n=this.getPalette(e);let[r,o]=this.getInnerOuter(t);if(r=r.length>6?`${r.slice(0,3)}...`:r,o=o.length>6?`${o.slice(0,3)}...`:o,1==t.length||"("==t[1]){const e=t[0]?.toUpperCase();return e in n?[n.get(e),e,o,1]:[this.undefinedColor,r,o,1]}if("d"==t[0]&&t[1]in n&&(2==t.length||"("==t[2])){const e=t[1]?.toUpperCase();return e in n?[n.get(e),e,o,2]:[this.undefinedColor,r,o,2]}if(t.substring(0,3)in this.AAFullNames&&(3==t.length||"("==t[3])){const e=this.AAFullNames[t.substring(0,3)];return e in n?[n.get(e),e,o,3]:[this.undefinedColor,r,o,3]}if(t[0]?.toLowerCase()==t[0]&&t.substring(1,3)in this.AAFullNames&&(4==t.length||"("==t[4])){const e=this.AAFullNames[t.substring(1,3)];return e in n?[n.get(e),e,o,4]:[this.undefinedColor,r,o,4]}return[this.undefinedColor,r,o,0]}}u.SemType="Aminoacids",u.SemTypeMultipleAlignment="AminoacidsMultipleAlignment",u.undefinedColor="rgb(100,100,100)",u.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"},u.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"},u.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(*)*"},u.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 c{}c.SemType="Nucleotides",c.SemTypeMultipleAlignment="NucleotidesMultipleAlignment",c.Names={A:"Adenine",C:"Cytosine",G:"Guanine",T:"Thymine",U:"Uracil"};var h=n(4971);function d(t,e=!0){if(null==t)return"rgb(100,100,100)";const n=r.Color.fromHtml(t);if(e){const t=r.Color.g(n),e=r.Color.r(n),o=r.Color.b(n),i=Math.sqrt(Math.pow(0-e,2)+Math.pow(0-t,2)+Math.pow(0-o,2));if(i>210)return`rgb(${e/i*210},${t/i*210},${o/i*210})`}return r.Color.toRgb(n)}class f{static hashCode(t){let e=0;if(0===t.length)return e;for(let n=0;n<t.length;n++)e=(e<<5)-e+t.charCodeAt(n),e|=0;return e}}class p{}class m extends p{static get palette(){return m._pallete||(m._pallete=m.buildPalette()),m._pallete}static buildPalette(){return(0,h.pj)().then((t=>{t.awaitLoaded(1/0).then((()=>{const e=t.getMonomerLib();e.onChanged.subscribe((()=>{m.customMonomerColors={},m.polymerTypes=e.getPolymerTypes();for(const t of this.polymerTypes){const n=e.getMonomerSymbolsByType(t);for(const r of n){const n=e.getMonomer(t,r);n?.meta?.colors?.default?.background&&(this.customMonomerColors[r]||(this.customMonomerColors[r]={}),this.customMonomerColors[r][t]=d(n.meta.colors.default.background))}}}))}))})),[].concat(...Object.values(a.colourPalette))}get(t,e){const n=m.palette.length,r=m.customMonomerColors[t],o=e??"PEPTIDE";if(r&&r[o])return r[o];const i=f.hashCode(t)%n;return d(m.palette[i])}}m._pallete=null,m.customMonomerColors={},m.polymerTypes=[];var g=n(8438);n(3599);class y{get length(){return this.mList.length}get graphInfo(){}isGap(t){return this.getOriginal(t)===this.gapOriginalMonomer}getCanonical(t){if(this.length<=t)throw new Error("Index out of bounds");const e=this.mList[t];return e!==this.gapOriginalMonomer?e:s._S}getOriginal(t){if(this.length<=t)throw new Error("Index out of bounds");return this.mList[t]}getCanonicalRegion(t,e){const n=Math.min(Math.max(0,t),this.length),r=Math.max(Math.min(this.length,e),0)-n,o=this.gapOriginalMonomer;return new Array(r).fill(null).map(((t,e)=>{const r=this.mList[e+n];return r===o?s._S:r}))}getOriginalRegion(t,e){const n=Math.min(Math.max(0,t),this.length),r=Math.max(Math.min(this.length,e),0);return new Array(r-n).fill(null).map(((t,e)=>this.mList[e+n]))}get gapOriginal(){return this.gapOriginalMonomer}constructor(t,e){this.mList=t,this.gapOriginalMonomer=e}}class b extends y{constructor(t,e,n,r){super(t.flat(),r),this.mListSeparated=t,this.connections=e,this._graphInfo=void 0,this.polymerTypes=t.map(((t,e)=>new Array(t.length).fill(n[e]))).flat()}get graphInfo(){return this._graphInfo??(this._graphInfo=this.parseConnections()),this._graphInfo}parseConnections(){const t={connections:[],disjointSeqStarts:[],polymerTypes:this.polymerTypes};if((this.connections?.length??0)>0){let e=0;for(let n=0;n<this.mListSeparated.length;++n)t.disjointSeqStarts.push(e),e+=this.mListSeparated[n].length;const n=(this.connections??"").split("|").filter((t=>(t?.length??0)>0)),r=/^(PEPTIDE|RNA|BLOB|CHEM)\d{1,2}$/,o=/^\d{1,2}:R\d{1}-\d{1,2}:R\d{1}$/;for(const e of n){const n=e.split(",");if(3!==n.length||!o.test(n[2])||!r.test(n[0])||!r.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 u=n[2].split("-");if(2!==u.length)continue;const c=u[0].split(":"),h=u[1].split(":");if(2!==c.length||2!==h.length)continue;const d=parseInt(c[0])-1,f=parseInt(h[0])-1;d<0||d>=this.mListSeparated[i].length||f<0||f>=this.mListSeparated[s].length||t.connections.push({seq1Type:a,seq2Type:l,seqIndex1:i,seqIndex2:s,monomerIndex1:d,monomerIndex2:f,rGroup1:parseInt(c[1].substring(1)),rGroup2:parseInt(h[1].substring(1))})}}return t}}function v(t,e=void 0){return n=>{if(n){let r;const o=new RegExp(`(?<=^|\\${t})("-"|'-'|[^\\${t}]*)(?=\\${t}|$)`,"g");return null!=e?(o.lastIndex=0,r=i()(n.matchAll(o)).take(e).map((t=>t[0])).toArray()):r=n.replaceAll('"-"',"").replaceAll("'-'","").split(t,e),new y(r,s.b9[s.Hi.SEPARATOR])}return new y([],s.b9[s.Hi.SEPARATOR])}}const C=t=>{const e=t.indexOf("}$"),n=t.substring(0,e+1),r=t.indexOf("$",e+2),o=t.substring(e+2,r),i=n.split("}|");for(let t=0;t<i.length-1;t++)i[t]=i[t]+"}";const a=i.map((t=>(t.match(/(?<=\{).+(?=})/)?.[0]?.split(".")??[]).map((t=>(0,g.D)(t))))),l=i.map((t=>t.replace(/\d{1,2}\{.+\}/,"")));return new b(a,o??"",l,s.b9[s.Hi.HELM])},w=/([^\W_]+)/g;function A(t,e){if(t.length<=e)return t;const n=t.match(w),r=t.length>e||(n?.length??0)>1,o=n?.[0]??" ";return r?o.substring(0,e-1)+"…":o}},8312:(t,e,n)=>{"use strict";n.d(e,{Q:()=>o});var r=n(6082);async function o(){const t=r.Func.find({package:"Bio",name:"getSeqHelper"});if(0===t.length)throw new Error("Package 'Bio' must be installed for SeqHelper.");return(await t[0].prepare().call()).getOutputParamValue()}},6869:(t,e,n)=>{"use strict";var r;n.d(e,{o:()=>r}),function(t){t.BASE="HELM_BASE",t.SUGAR="HELM_SUGAR",t.LINKER="HELM_LINKER",t.AA="HELM_AA",t.CHEM="HELM_CHEM",t.BLOB="HELM_BLOB",t.NUCLEOTIDE="HELM_NUCLETIDE"}(r||(r={}))},8070:(t,e,n)=>{"use strict";n.d(e,{Pl:()=>P,gM:()=>M,L1:()=>N,cb:()=>k,E3:()=>T,J6:()=>_,Xk:()=>I,Xb:()=>O,N$:()=>R,t6:()=>E,PE:()=>x,CN:()=>f});var r=n(4328),o=n(6082);n(9982);const i=o.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,,,,,,,,,,,,,,,,,,,,,');i.columns.add(o.Column.fromList(o.TYPE.BYTE_ARRAY,"BinaryImage",Array.from(new Uint8Array(11))));var s=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{l(r.next(t))}catch(t){i(t)}}function a(t){try{l(r.throw(t))}catch(t){i(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}l((r=r.apply(t,e||[])).next())}))};const a=3e4,l=108e5,u=console.log.bind(console),c=console.info.bind(console),h=console.warn.bind(console),d=console.error.bind(console),f={},p="Auto Tests",m="Demo",g="Detectors",y="Core",b={};let v;var C;!function(t){t.notNull=function(t,e){if(null==t)throw new Error(`${null==e?"Value":e} not defined`)}}(C||(C={}));class w{constructor(t,e){this.catchUnhandled=!0,this.report=!1,void 0!==t&&(this.catchUnhandled=t),void 0!==e&&(this.report=e)}}class A{constructor(t,e,n,r){var i;this.category=t,this.name=e,null!=r||(r={}),null!==(i=r.timeout)&&void 0!==i||(r.timeout=a),this.options=r,this.test=()=>s(this,void 0,void 0,(function*(){return new Promise(((t,e)=>s(this,void 0,void 0,(function*(){var r;let i="";try{o.Test.isInDebug;let t=yield n();try{i=null!==(r=null==t?void 0:t.toString())&&void 0!==r?r:""}catch(t){i="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(t){e(t)}t(i)}))))}))}}function x(t,e,n,r=0,o="timeout"){return s(this,void 0,void 0,(function*(){return new Promise(((i,s)=>{const a=t.subscribe((t=>{try{e(t),i("OK")}catch(t){s(t)}finally{a.unsubscribe(),clearTimeout(l)}})),l=setTimeout((()=>{a.unsubscribe(),s(o)}),r);n()}))}))}function E(t,e,n){null==f[v]&&(f[v]={}),null==f[v].tests&&(f[v].tests=[]),f[v].tests.push(new A(v,t,e,n))}function T(t,e=!0,n){if(n=n?`${n}, `:"",t!==e)throw new Error(`${n}Expected "${e}", got "${t}"`)}function S(t,e,n=.001,r){if(t===Number.POSITIVE_INFINITY&&e===Number.POSITIVE_INFINITY||t===Number.NEGATIVE_INFINITY&&e===Number.NEGATIVE_INFINITY||t===Number.NaN&&e===Number.NaN||isNaN(t)&&isNaN(e))return;const o=Math.abs(t-e)<n;if(T(o,!0,`${null!=r?r:""} (tolerance = ${n})`),!o)throw new Error(`Expected ${e}, got ${t} (tolerance = ${n})`)}function I(t,e){for(const[n,r]of Object.entries(e)){if(!t.hasOwnProperty(n))throw new Error(`Expected property "${n}" not found`);const e=t[n];if(e instanceof Array&&r instanceof Array)_(e,r);else if(e instanceof Object&&r instanceof Object)I(e,r);else if(Number.isFinite(e)&&Number.isFinite(r))S(e,r);else if(e!=r)throw new Error(`Expected (${r}) for key '${n}', got (${e})`)}}function _(t,e){const n=t.length,r=e.length;if(n!=r)throw new Error(`Arrays are of different length: actual array length is ${n} and expected array length is ${r}`);for(let r=0;r<n;r++)if(t[r]instanceof Array&&e[r]instanceof Array)_(t[r],e[r]);else if(t[r]instanceof Object&&e[r]instanceof Object)I(t[r],e[r]);else if(t[r]!=e[r])throw new Error(`Expected ${e[r]} at position ${r}, got ${t[r]}`)}function N(t,e,n){var r;v=t,e(),f[v]&&(f[v].clear=null===(r=null==n?void 0:n.clear)||void 0===r||r,f[v].timeout=null==n?void 0:n.timeout,f[v].benchmarks=null==n?void 0:n.benchmarks,f[v].stressTests=null==n?void 0:n.stressTests,f[v].owner=null==n?void 0:n.owner)}function M(t){null==f[v]&&(f[v]={}),f[v].before=t}function P(t){null==f[v]&&(f[v]={}),f[v].after=t}function L(t,e){return t.replace(new RegExp(e.name,"gi"),e.nqName)}function O(t,e){var n,u,c,h,d,v,C,w,x,E;return s(this,void 0,void 0,(function*(){const S=t.id;if(b[S])return;const I=e?e.tests:f;if("DevTools"===t.name||e&&"DevTools"===e._package.name)for(const t of window.dartTests){const e=t.name.split(/\s*\|\s*!/g);let r=null!==(n=e.pop())&&void 0!==n?n:t.name,o=e.length?y+": "+e.join(": "):y,i=r.split(" | ");r=i[i.length-1],i.unshift(o),i.pop(),o=i.join(": "),void 0===I[o]&&(I[o]={tests:[],clear:!0}),I[o].tests.push(new A(o,r,t.test,{isAggregated:!1,timeout:null!==(c=null===(u=t.options)||void 0===u?void 0:u.timeout)&&void 0!==c?c:a,skipReason:null===(h=t.options)||void 0===h?void 0:h.skipReason,owner:null===(d=t.options)||void 0===d?void 0:d.owner,benchmark:null!==(C=null===(v=t.options)||void 0===v?void 0:v.benchmark)&&void 0!==C&&C}))}const _=[],N=[],M=[],P=yield r.dapi.functions.filter(`package.id = "${S}"`).list(),O=new RegExp(/skip:\s*([^,\s]+)|wait:\s*(\d+)|cat:\s*([^,\s]+)|timeout:\s*(\d+)/g);for(const e of P){const n=e.options.test,u=e.options.demoPath;if(n&&Array.isArray(n)&&n.length)for(let t=0;t<n.length;t++){const i=n[t].matchAll(O),u={};Array.from(i).forEach((t=>{t[0].startsWith("skip")?u.skip=t[1]:t[0].startsWith("wait")?u.wait=parseInt(t[2]):t[0].startsWith("cat")?u.cat=t[3]:t[0].startsWith("timeout")&&(u.timeout=parseInt(t[4]))}));const c=new A(null!==(w=u.cat)&&void 0!==w?w:p,1===n.length?e.name:`${e.name} ${t+1}`,(()=>s(this,void 0,void 0,(function*(){const o=yield r.functions.eval(L(n[t],e));if(u.wait&&(yield k(u.wait)),"boolean"==typeof o&&!o)throw`Failed: ${n[t]}, expected true, got ${o}`}))),{skipReason:u.skip,timeout:o.Test.isInBenchmark?null!==(x=u.benchmarkTimeout)&&void 0!==x?x:l:null!==(E=u.timeout)&&void 0!==E?E:a});if(u.cat){const t=u.cat;void 0===I[t]&&(I[t]={tests:[],clear:!0}),I[t].tests||(I[t].tests=[]),I[t].tests.push(c)}else _.push(c)}if(u){const t=e.options.demoWait?parseInt(e.options.demoWait):void 0,n=new A(m,e.friendlyName,(()=>s(this,void 0,void 0,(function*(){yield k(300),r.shell.clearLastError(),yield e.apply(),yield k(t||2e3);const n=yield r.shell.lastError;if(n)throw new Error(n)}))),{skipReason:e.options.demoSkip});N.push(n)}if(e.hasTag("semTypeDetector")){let n=i;e.options.testData&&(n=yield r.data.files.openTable(`System:AppData/${t.nqName}/${e.options.testData}`));const o=new A(g,e.friendlyName,(()=>s(this,void 0,void 0,(function*(){const r=[];console.log(`System:AppData/${t.nqName}/${e.options.testData}`);for(const t of n.clone().columns){const n=yield e.apply([t]);r.push(n||t.semType)}const o=r.filter((t=>t));T(o.length,1),e.options.testDataColumnName&&T(o[0],e.options.testDataColumnName)}))),{skipReason:e.options.skipTest});M.push(o)}}b[S]=!0,_.length>0&&(I[p]={tests:_,clear:!0}),N.length>0&&(I[m]={tests:N,clear:!0}),M.length>0&&(I[g]={tests:M,clear:!1})}))}function R(t){var e,n,i,p,m,g;return s(this,void 0,void 0,(function*(){console.log("--------------------");const y=null===(n=null===(e=r.functions.getCurrentCall())||void 0===e?void 0:e.func)||void 0===n?void 0:n.package,b=(null!==(p=(null!==(i=null==y?void 0:y.packageOwner)&&void 0!==i?i:"").match(new RegExp("[^<]*<([^>]*)>")))&&void 0!==p?p:["",""])[1];yield O(y);const v=[];console.log("Running tests"),console.log(t),null!=t||(t={}),null!==(m=(g=t).testContext)&&void 0!==m||(g.testContext=new w),r.shell.clearLastError();const C=function(){const t=[];return console.log=(...e)=>{t.push(...e),u(...e)},console.info=(...e)=>{t.push(...e),c(...e)},console.warn=(...e)=>{t.push(...e),h(...e)},console.error=(...e)=>{t.push(...e),d(...e)},t}();yield function(t,e){var n,i,a,l,f,p,m;return s(this,void 0,void 0,(function*(){try{for(const[r,c]of Object.entries(t)){if(!(null==e?void 0:e.category)||(null===(n=e.exclude)||void 0===n?void 0:n.some((t=>r.startsWith(t)))))continue;if((!r.toLowerCase().startsWith(`${null==e?void 0:e.category.toLowerCase().trim()} :`)||e.test)&&r.toLowerCase().trim()!==(null==e?void 0:e.category.toLowerCase().trim()))continue;u(`Started ${r} category`);const t=null===(i=c.tests)||void 0===i?void 0:i.every((t=>{var e;return null===(e=t.options)||void 0===e?void 0:e.skipReason}));t||(c.beforeStatus=yield A(c.before,null!==(a=e.category)&&void 0!==a?a:""));let h,d=null!==(l=c.tests)&&void 0!==l?l:[];e.stressTest&&(d=d.filter((t=>{var e;return null===(e=t.options)||void 0===e?void 0:e.stressTest})),d=$(d)),(null!==(p=null===(f=e.tags)||void 0===f?void 0:f.length)&&void 0!==p?p:0)>0&&(d=d.filter((t=>{var n,r;return null===(r=null===(n=t.options)||void 0===n?void 0:n.tags)||void 0===r?void 0:r.some((t=>{var n;return(null!==(n=null==e?void 0:e.tags)&&void 0!==n?n:[]).includes(t)}))}))),c.beforeStatus?(h=Array.from(d.map((t=>({date:(new Date).toISOString(),category:r,name:t.name,success:!1,result:"before() failed",ms:0,skipped:!1,logs:"",owner:null==y?void 0:y.packageOwner,package:y.name,widgetsDifference:0,flaking:o.Test.isReproducing})))),h.forEach((t=>s(this,void 0,void 0,(function*(){return D("package",t)}))))):h=yield x(c,e);const g=h.filter((t=>"skipped"!=t.result));t||(c.afterStatus=yield A(c.after,null!==(m=e.category)&&void 0!==m?m:"")),c.afterStatus&&g.push({date:(new Date).toISOString(),category:r,name:"after",success:!1,result:c.afterStatus,ms:0,skipped:!1,logs:"",owner:null==y?void 0:y.packageOwner,package:y.name,widgetsDifference:0,flaking:o.Test.isReproducing}),c.beforeStatus&&g.push({date:(new Date).toISOString(),category:r,name:"before",success:!1,result:c.beforeStatus,ms:0,skipped:!1,logs:"",owner:null==y?void 0:y.packageOwner,package:y.name,widgetsDifference:0,flaking:o.Test.isReproducing}),v.push(...g)}}finally{console.log=u,console.info=c,console.warn=h,console.error=d}if(e.testContext.catchUnhandled&&!o.Test.isInBenchmark){yield k(1e3);const t=yield r.shell.lastError,e={logs:"",date:(new Date).toISOString(),category:"Unhandled exceptions",name:"Exception",result:null!=t?t:"",success:!t,ms:0,skipped:!1,owner:null!=b?b:"",package:y.name,widgetsDifference:0};v.push(Object.assign(Object.assign({},e),{flaking:o.Test.isReproducing&&!t})),e.package=y.name,yield D("package",e)}}))}(f,t);for(let t of v)t.result=t.result.toString().replace(/"/g,"'"),null!=t.logs&&(t.logs=t.logs.toString().replace(/"/g,"'"));return v;function A(t,e){return s(this,void 0,void 0,(function*(){let n;try{void 0!==t&&(yield H((()=>s(this,void 0,void 0,(function*(){yield t()}))),1e5,`before ${e}: timeout error`))}catch(t){n=yield F(t)}return n}))}function x(t,e){var n,i,u,c,h,d,f,p,m,g,v,w,A,x,T,S,I,_;return s(this,void 0,void 0,(function*(){let s=null!==(n=t.tests)&&void 0!==n?n:[];const N=[],M=E();if(t.clear)for(let n=0;n<s.length;n++){s[n].options&&void 0===(null===(i=s[n].options)||void 0===i?void 0:i.benchmark)&&(s[n].options||(s[n].options={}),s[n].options.benchmark=null!==(u=t.benchmarks)&&void 0!==u&&u);let w=s[n];if(e.test&&e.test.toLowerCase()!==w.name.toLowerCase())continue;(null==w?void 0:w.options)&&(w.options.owner=null!==(f=null!==(d=null!==(h=null===(c=s[n].options)||void 0===c?void 0:c.owner)&&void 0!==h?h:null==t?void 0:t.owner)&&void 0!==d?d:b)&&void 0!==f?f:"");let A=yield B(w,null==e?void 0:e.test,C,o.Test.isInBenchmark?null!==(m=null===(p=s[n].options)||void 0===p?void 0:p.benchmarkTimeout)&&void 0!==m?m:l:null!==(v=null===(g=s[n].options)||void 0===g?void 0:g.timeout)&&void 0!==v?v:a,y.name,e.verbose);A&&N.push(Object.assign(Object.assign({},A),{widgetsDifference:E()-M})),r.shell.closeAll(),o.Balloon.closeAll()}else for(let n=0;n<s.length;n++){let r=s[n];if(e.test&&e.test.toLowerCase()!==r.name.toLowerCase())continue;(null==r?void 0:r.options)&&(r.options.owner=null!==(T=null!==(x=null!==(A=null===(w=s[n].options)||void 0===w?void 0:w.owner)&&void 0!==A?A:null==t?void 0:t.owner)&&void 0!==x?x:b)&&void 0!==T?T:"");let i=yield B(r,null==e?void 0:e.test,C,o.Test.isInBenchmark?null!==(I=null===(S=s[n].options)||void 0===S?void 0:S.benchmarkTimeout)&&void 0!==I?I:l:null===(_=s[n].options)||void 0===_?void 0:_.timeout,y.name,e.verbose);i&&N.push(Object.assign(Object.assign({},i),{widgetsDifference:E()-M}))}return N}))}function E(){var t;let e=-1;try{e=o.Widget.getAll().length}catch(e){console.warn(null!==(t=e.message)&&void 0!==t?t:e)}return e}}))}function D(t,e){return s(this,void 0,void 0,(function*(){null!=r.shell.reportTest?yield r.shell.reportTest(t,e):yield fetch(`${r.dapi.root}/log/tests/${t}`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"same-origin",body:JSON.stringify(e)})}))}function F(t){return s(this,void 0,void 0,(function*(){return`${t.toString()}\n${t.stack?yield o.Logger.translateStackTrace(t.stack):""}`}))}function B(t,e,n,i,l,c){var h,f,p,m,g,y,b,v,C,w,A,x,T,S;return s(this,void 0,void 0,(function*(){let s;n.length=0;const I=null!=e&&t.name.toLowerCase()!==e.toLowerCase();let _=(null===(h=t.options)||void 0===h?void 0:h.skipReason)||I,N=I?"skipped":null===(f=t.options)||void 0===f?void 0:f.skipReason;if(console.log(E.name,_),o.Test.isInBenchmark&&!(null===(p=t.options)||void 0===p?void 0:p.benchmark))return void u(`SKIPPED: ${t.category} ${t.name} doesnt available in benchmark mode`);_||u(`Started ${t.category} ${t.name}`);const M=Date.now(),P=new Date(M).toISOString();try{if(_)s={name:t.name,owner:null!==(g=null===(m=t.options)||void 0===m?void 0:m.owner)&&void 0!==g?g:"",category:t.category,logs:"",date:P,success:!0,result:N,ms:0,skipped:!0,package:null!=l?l:"",flaking:o.Test.isReproducing};else{let e=null!=i?i:a;o.Test.isProfiling&&console.profile(`${t.category}: ${t.name}`),s={name:t.name,owner:null!==(b=null===(y=t.options)||void 0===y?void 0:y.owner)&&void 0!==b?b:"",category:t.category,logs:"",date:P,success:!0,result:null!==(v=(yield H(t.test,e)).toString())&&void 0!==v?v:"OK",ms:0,skipped:!1,package:null!=l?l:"",flaking:o.Test.isReproducing},o.Test.isProfiling&&(console.profileEnd(`${t.category}: ${t.name}`),r.shell.info(`Profiling of ${t.category}: ${t.name} finished \n Please ensure that you have opened DevTools (F12) / Performance panel before test starts.`))}}catch(e){d(e),s={name:t.name,owner:null!==(w=null===(C=t.options)||void 0===C?void 0:C.owner)&&void 0!==w?w:"",category:t.category,logs:"",date:P,success:!1,result:yield F(e),ms:0,skipped:!1,package:null!=l?l:"",flaking:!1}}if((null===(A=t.options)||void 0===A?void 0:A.isAggregated)&&s.result.constructor===o.DataFrame){const t=s.result.col("success");if(t&&(s.success=t.stats.sum===t.length),!c){const t=s.result;t.columns.remove("stack"),t.rows.removeWhere((t=>t.get("success"))),s.result=t}s.result=s.result.toCsv()}if(s.logs=n.join("\n"),s.ms=Date.now()-M,_||u(`Finished ${t.category} ${t.name} for ${s.ms} ms`),s.category=t.category,s.name=t.name,s.owner=null!==(T=null===(x=t.options)||void 0===x?void 0:x.owner)&&void 0!==T?T:"",!I){let e={success:s.success,result:s.result,ms:s.ms,date:s.date,skipped:s.skipped,category:t.category,name:t.name,logs:s.logs,owner:s.owner,flaking:o.Test.isReproducing&&s.success,package:s.package};if(s.result.constructor==Object){const t=Object.keys(s.result).reduce(((t,e)=>Object.assign(Object.assign({},t),{["result."+e]:s.result[e]})),{});e=Object.assign(Object.assign({},e),t)}e.result instanceof o.DataFrame&&(e.result=JSON.stringify(null===(S=e.result)||void 0===S?void 0:S.toJson())||""),yield D("package",e)}return s}))}function $(t){const e=t.slice();return e.sort((()=>Math.random()-.5)),e}function k(t){return s(this,void 0,void 0,(function*(){yield new Promise((e=>setTimeout(e,t)))}))}function H(t,e,n="EXECUTION TIMEOUT"){return s(this,void 0,void 0,(function*(){let r=null;const o=new Promise(((t,o)=>{r=setTimeout((()=>{o(n)}),e)}));try{return yield Promise.race([t(),o])}finally{r&&clearTimeout(r)}}))}o.DataFrame.fromColumns([o.Column.fromStrings("col",["val1","val2","val3"])])},2074:(t,e,n)=>{"use strict";n.d(e,{A:()=>a});var r=n(1354),o=n.n(r),i=n(6314),s=n.n(i)()(o());s.push([t.id,".st-colored-text-input > textarea {\n width: 100%;\n -webkit-text-fill-color: transparent;\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,oCAAoC;EACpC,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 -webkit-text-fill-color: transparent;\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:(t,e,n)=>{"use strict";n.d(e,{A:()=>a});var r=n(1354),o=n.n(r),i=n(6314),s=n.n(i)()(o());s.push([t.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:(t,e,n)=>{"use strict";n.d(e,{A:()=>a});var r=n(1354),o=n.n(r),i=n(6314),s=n.n(i)()(o());s.push([t.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}\n\n.st-structure-mol-img {\n margin-right: 30px;\n float: right;\n}\n\n.st-structure-bool-button-block {\n justify-content: right;\n margin-bottom: 10px;\n}\n\n.st-structure-bottom {\n flex-direction: row-reverse;\n padding-top: 20px;\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;AACrB;;AAEA;EACE,kBAAkB;EAClB,YAAY;AACd;;AAEA;EACE,sBAAsB;EACtB,mBAAmB;AACrB;;AAEA;EACE,2BAA2B;EAC3B,iBAAiB;AACnB;;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}\n\n.st-structure-mol-img {\n margin-right: 30px;\n float: right;\n}\n\n.st-structure-bool-button-block {\n justify-content: right;\n margin-bottom: 10px;\n}\n\n.st-structure-bottom {\n flex-direction: row-reverse;\n padding-top: 20px;\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:(t,e,n)=>{"use strict";n.d(e,{A:()=>a});var r=n(1354),o=n.n(r),i=n(6314),s=n.n(i)()(o());s.push([t.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:(t,e,n)=>{"use strict";n.d(e,{A:()=>a});var r=n(1354),o=n.n(r),i=n(6314),s=n.n(i)()(o());s.push([t.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:t=>{"use strict";t.exports=function(t){var e=[];return e.toString=function(){return this.map((function(e){var n="",r=void 0!==e[5];return e[4]&&(n+="@supports (".concat(e[4],") {")),e[2]&&(n+="@media ".concat(e[2]," {")),r&&(n+="@layer".concat(e[5].length>0?" ".concat(e[5]):""," {")),n+=t(e),r&&(n+="}"),e[2]&&(n+="}"),e[4]&&(n+="}"),n})).join("")},e.i=function(t,n,r,o,i){"string"==typeof t&&(t=[[null,t,void 0]]);var s={};if(r)for(var a=0;a<this.length;a++){var l=this[a][0];null!=l&&(s[l]=!0)}for(var u=0;u<t.length;u++){var c=[].concat(t[u]);r&&s[c[0]]||(void 0!==i&&(void 0===c[5]||(c[1]="@layer".concat(c[5].length>0?" ".concat(c[5]):""," {").concat(c[1],"}")),c[5]=i),n&&(c[2]?(c[1]="@media ".concat(c[2]," {").concat(c[1],"}"),c[2]=n):c[2]=n),o&&(c[4]?(c[1]="@supports (".concat(c[4],") {").concat(c[1],"}"),c[4]=o):c[4]="".concat(o)),e.push(c))}},e}},1354:t=>{"use strict";t.exports=function(t){var e=t[1],n=t[3];if(!n)return e;if("function"==typeof btoa){var r=btoa(unescape(encodeURIComponent(JSON.stringify(n)))),o="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(r),i="/*# ".concat(o," */");return[e].concat([i]).join("\n")}return[e].join("\n")}},9982:function(t,e,n){var r;!function(){var e={};!function(t){"use strict";t.__esModule=!0,t.digestLength=32,t.blockSize=64;var e=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function n(t,n,r,o,i){for(var s,a,l,u,c,h,d,f,p,m,g,y,b;i>=64;){for(s=n[0],a=n[1],l=n[2],u=n[3],c=n[4],h=n[5],d=n[6],f=n[7],m=0;m<16;m++)g=o+4*m,t[m]=(255&r[g])<<24|(255&r[g+1])<<16|(255&r[g+2])<<8|255&r[g+3];for(m=16;m<64;m++)y=((p=t[m-2])>>>17|p<<15)^(p>>>19|p<<13)^p>>>10,b=((p=t[m-15])>>>7|p<<25)^(p>>>18|p<<14)^p>>>3,t[m]=(y+t[m-7]|0)+(b+t[m-16]|0);for(m=0;m<64;m++)y=(((c>>>6|c<<26)^(c>>>11|c<<21)^(c>>>25|c<<7))+(c&h^~c&d)|0)+(f+(e[m]+t[m]|0)|0)|0,b=((s>>>2|s<<30)^(s>>>13|s<<19)^(s>>>22|s<<10))+(s&a^s&l^a&l)|0,f=d,d=h,h=c,c=u+y|0,u=l,l=a,a=s,s=y+b|0;n[0]+=s,n[1]+=a,n[2]+=l,n[3]+=u,n[4]+=c,n[5]+=h,n[6]+=d,n[7]+=f,o+=64,i-=64}return o}var r=function(){function e(){this.digestLength=t.digestLength,this.blockSize=t.blockSize,this.state=new Int32Array(8),this.temp=new Int32Array(64),this.buffer=new Uint8Array(128),this.bufferLength=0,this.bytesHashed=0,this.finished=!1,this.reset()}return e.prototype.reset=function(){return this.state[0]=1779033703,this.state[1]=3144134277,this.state[2]=1013904242,this.state[3]=2773480762,this.state[4]=1359893119,this.state[5]=2600822924,this.state[6]=528734635,this.state[7]=1541459225,this.bufferLength=0,this.bytesHashed=0,this.finished=!1,this},e.prototype.clean=function(){for(var t=0;t<this.buffer.length;t++)this.buffer[t]=0;for(t=0;t<this.temp.length;t++)this.temp[t]=0;this.reset()},e.prototype.update=function(t,e){if(void 0===e&&(e=t.length),this.finished)throw new Error("SHA256: can't update because hash was finished.");var r=0;if(this.bytesHashed+=e,this.bufferLength>0){for(;this.bufferLength<64&&e>0;)this.buffer[this.bufferLength++]=t[r++],e--;64===this.bufferLength&&(n(this.temp,this.state,this.buffer,0,64),this.bufferLength=0)}for(e>=64&&(r=n(this.temp,this.state,t,r,e),e%=64);e>0;)this.buffer[this.bufferLength++]=t[r++],e--;return this},e.prototype.finish=function(t){if(!this.finished){var e=this.bytesHashed,r=this.bufferLength,o=e/536870912|0,i=e<<3,s=e%64<56?64:128;this.buffer[r]=128;for(var a=r+1;a<s-8;a++)this.buffer[a]=0;this.buffer[s-8]=o>>>24&255,this.buffer[s-7]=o>>>16&255,this.buffer[s-6]=o>>>8&255,this.buffer[s-5]=o>>>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++)t[4*a+0]=this.state[a]>>>24&255,t[4*a+1]=this.state[a]>>>16&255,t[4*a+2]=this.state[a]>>>8&255,t[4*a+3]=this.state[a]>>>0&255;return this},e.prototype.digest=function(){var t=new Uint8Array(this.digestLength);return this.finish(t),t},e.prototype._saveState=function(t){for(var e=0;e<this.state.length;e++)t[e]=this.state[e]},e.prototype._restoreState=function(t,e){for(var n=0;n<this.state.length;n++)this.state[n]=t[n];this.bytesHashed=e,this.finished=!1,this.bufferLength=0},e}();t.Hash=r;var o=function(){function t(t){this.inner=new r,this.outer=new r,this.blockSize=this.inner.blockSize,this.digestLength=this.inner.digestLength;var e=new Uint8Array(this.blockSize);if(t.length>this.blockSize)(new r).update(t).finish(e).clean();else for(var n=0;n<t.length;n++)e[n]=t[n];for(n=0;n<e.length;n++)e[n]^=54;for(this.inner.update(e),n=0;n<e.length;n++)e[n]^=106;for(this.outer.update(e),this.istate=new Uint32Array(8),this.ostate=new Uint32Array(8),this.inner._saveState(this.istate),this.outer._saveState(this.ostate),n=0;n<e.length;n++)e[n]=0}return t.prototype.reset=function(){return this.inner._restoreState(this.istate,this.inner.blockSize),this.outer._restoreState(this.ostate,this.outer.blockSize),this},t.prototype.clean=function(){for(var t=0;t<this.istate.length;t++)this.ostate[t]=this.istate[t]=0;this.inner.clean(),this.outer.clean()},t.prototype.update=function(t){return this.inner.update(t),this},t.prototype.finish=function(t){return this.outer.finished?this.outer.finish(t):(this.inner.finish(t),this.outer.update(t,this.digestLength).finish(t)),this},t.prototype.digest=function(){var t=new Uint8Array(this.digestLength);return this.finish(t),t},t}();function i(t){var e=(new r).update(t),n=e.digest();return e.clean(),n}function s(t,e){var n=new o(t).update(e),r=n.digest();return n.clean(),r}function a(t,e,n,r){var o=r[0];if(0===o)throw new Error("hkdf: cannot expand more");e.reset(),o>1&&e.update(t),n&&e.update(n),e.update(r),e.finish(t),r[0]++}t.HMAC=o,t.hash=i,t.default=i,t.hmac=s;var l=new Uint8Array(t.digestLength);t.hkdf=function(t,e,n,r){void 0===e&&(e=l),void 0===r&&(r=32);for(var i=new Uint8Array([1]),u=s(e,t),c=new o(u),h=new Uint8Array(c.digestLength),d=h.length,f=new Uint8Array(r),p=0;p<r;p++)d===h.length&&(a(h,c,n,i),d=0),f[p]=h[d++];return c.clean(),h.fill(0),i.fill(0),f},t.pbkdf2=function(t,e,n,r){for(var i=new o(t),s=i.digestLength,a=new Uint8Array(4),l=new Uint8Array(s),u=new Uint8Array(s),c=new Uint8Array(r),h=0;h*s<r;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(e),i.update(a),i.finish(u);for(var f=0;f<s;f++)l[f]=u[f];for(f=2;f<=n;f++){i.reset(),i.update(u).finish(u);for(var p=0;p<s;p++)l[p]^=u[p]}for(f=0;f<s&&h*s+f<r;f++)c[h*s+f]=l[f]}for(h=0;h<s;h++)l[h]=u[h]=0;for(h=0;h<4;h++)a[h]=0;return i.clean(),c}}(e);var o=e.default;for(var i in e)o[i]=e[i];"object"==typeof t.exports?t.exports=o:void 0===(r=function(){return o}.call(e,n,e,t))||(t.exports=r)}()},2543:function(t,e,n){var r;t=n.nmd(t),function(){var o,i="Expected a function",s="__lodash_hash_undefined__",a="__lodash_placeholder__",l=32,u=128,c=1/0,h=9007199254740991,d=NaN,f=4294967295,p=[["ary",u],["bind",1],["bindKey",2],["curry",8],["curryRight",16],["flip",512],["partial",l],["partialRight",64],["rearg",256]],m="[object Arguments]",g="[object Array]",y="[object Boolean]",b="[object Date]",v="[object Error]",C="[object Function]",w="[object GeneratorFunction]",A="[object Map]",x="[object Number]",E="[object Object]",T="[object Promise]",S="[object RegExp]",I="[object Set]",_="[object String]",N="[object Symbol]",M="[object WeakMap]",P="[object ArrayBuffer]",L="[object DataView]",O="[object Float32Array]",R="[object Float64Array]",D="[object Int8Array]",F="[object Int16Array]",B="[object Int32Array]",$="[object Uint8Array]",k="[object Uint8ClampedArray]",H="[object Uint16Array]",G="[object Uint32Array]",U=/\b__p \+= '';/g,V=/\b(__p \+=) '' \+/g,q=/(__e\(.*?\)|\b__t\)) \+\n'';/g,j=/&(?:amp|lt|gt|quot|#39);/g,W=/[&<>"']/g,z=RegExp(j.source),Y=RegExp(W.source),K=/<%-([\s\S]+?)%>/g,J=/<%([\s\S]+?)%>/g,Q=/<%=([\s\S]+?)%>/g,X=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Z=/^\w*$/,tt=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,et=/[\\^$.*+?()[\]{}|]/g,nt=RegExp(et.source),rt=/^\s+/,ot=/\s/,it=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,st=/\{\n\/\* \[wrapped with (.+)\] \*/,at=/,? & /,lt=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,ut=/[()=,{}\[\]\/\s]/,ct=/\\(\\)?/g,ht=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,dt=/\w*$/,ft=/^[-+]0x[0-9a-f]+$/i,pt=/^0b[01]+$/i,mt=/^\[object .+?Constructor\]$/,gt=/^0o[0-7]+$/i,yt=/^(?:0|[1-9]\d*)$/,bt=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,vt=/($^)/,Ct=/['\n\r\u2028\u2029\\]/g,wt="\\ud800-\\udfff",At="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",xt="\\u2700-\\u27bf",Et="a-z\\xdf-\\xf6\\xf8-\\xff",Tt="A-Z\\xc0-\\xd6\\xd8-\\xde",St="\\ufe0e\\ufe0f",It="\\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",_t="["+wt+"]",Nt="["+It+"]",Mt="["+At+"]",Pt="\\d+",Lt="["+xt+"]",Ot="["+Et+"]",Rt="[^"+wt+It+Pt+xt+Et+Tt+"]",Dt="\\ud83c[\\udffb-\\udfff]",Ft="[^"+wt+"]",Bt="(?:\\ud83c[\\udde6-\\uddff]){2}",$t="[\\ud800-\\udbff][\\udc00-\\udfff]",kt="["+Tt+"]",Ht="\\u200d",Gt="(?:"+Ot+"|"+Rt+")",Ut="(?:"+kt+"|"+Rt+")",Vt="(?:['’](?:d|ll|m|re|s|t|ve))?",qt="(?:['’](?:D|LL|M|RE|S|T|VE))?",jt="(?:"+Mt+"|"+Dt+")?",Wt="["+St+"]?",zt=Wt+jt+"(?:"+Ht+"(?:"+[Ft,Bt,$t].join("|")+")"+Wt+jt+")*",Yt="(?:"+[Lt,Bt,$t].join("|")+")"+zt,Kt="(?:"+[Ft+Mt+"?",Mt,Bt,$t,_t].join("|")+")",Jt=RegExp("['’]","g"),Qt=RegExp(Mt,"g"),Xt=RegExp(Dt+"(?="+Dt+")|"+Kt+zt,"g"),Zt=RegExp([kt+"?"+Ot+"+"+Vt+"(?="+[Nt,kt,"$"].join("|")+")",Ut+"+"+qt+"(?="+[Nt,kt+Gt,"$"].join("|")+")",kt+"?"+Gt+"+"+Vt,kt+"+"+qt,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Pt,Yt].join("|"),"g"),te=RegExp("["+Ht+wt+At+St+"]"),ee=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,ne=["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"],re=-1,oe={};oe[O]=oe[R]=oe[D]=oe[F]=oe[B]=oe[$]=oe[k]=oe[H]=oe[G]=!0,oe[m]=oe[g]=oe[P]=oe[y]=oe[L]=oe[b]=oe[v]=oe[C]=oe[A]=oe[x]=oe[E]=oe[S]=oe[I]=oe[_]=oe[M]=!1;var ie={};ie[m]=ie[g]=ie[P]=ie[L]=ie[y]=ie[b]=ie[O]=ie[R]=ie[D]=ie[F]=ie[B]=ie[A]=ie[x]=ie[E]=ie[S]=ie[I]=ie[_]=ie[N]=ie[$]=ie[k]=ie[H]=ie[G]=!0,ie[v]=ie[C]=ie[M]=!1;var se={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},ae=parseFloat,le=parseInt,ue="object"==typeof n.g&&n.g&&n.g.Object===Object&&n.g,ce="object"==typeof self&&self&&self.Object===Object&&self,he=ue||ce||Function("return this")(),de=e&&!e.nodeType&&e,fe=de&&t&&!t.nodeType&&t,pe=fe&&fe.exports===de,me=pe&&ue.process,ge=function(){try{return fe&&fe.require&&fe.require("util").types||me&&me.binding&&me.binding("util")}catch(t){}}(),ye=ge&&ge.isArrayBuffer,be=ge&&ge.isDate,ve=ge&&ge.isMap,Ce=ge&&ge.isRegExp,we=ge&&ge.isSet,Ae=ge&&ge.isTypedArray;function xe(t,e,n){switch(n.length){case 0:return t.call(e);case 1:return t.call(e,n[0]);case 2:return t.call(e,n[0],n[1]);case 3:return t.call(e,n[0],n[1],n[2])}return t.apply(e,n)}function Ee(t,e,n,r){for(var o=-1,i=null==t?0:t.length;++o<i;){var s=t[o];e(r,s,n(s),t)}return r}function Te(t,e){for(var n=-1,r=null==t?0:t.length;++n<r&&!1!==e(t[n],n,t););return t}function Se(t,e){for(var n=null==t?0:t.length;n--&&!1!==e(t[n],n,t););return t}function Ie(t,e){for(var n=-1,r=null==t?0:t.length;++n<r;)if(!e(t[n],n,t))return!1;return!0}function _e(t,e){for(var n=-1,r=null==t?0:t.length,o=0,i=[];++n<r;){var s=t[n];e(s,n,t)&&(i[o++]=s)}return i}function Ne(t,e){return!(null==t||!t.length)&&ke(t,e,0)>-1}function Me(t,e,n){for(var r=-1,o=null==t?0:t.length;++r<o;)if(n(e,t[r]))return!0;return!1}function Pe(t,e){for(var n=-1,r=null==t?0:t.length,o=Array(r);++n<r;)o[n]=e(t[n],n,t);return o}function Le(t,e){for(var n=-1,r=e.length,o=t.length;++n<r;)t[o+n]=e[n];return t}function Oe(t,e,n,r){var o=-1,i=null==t?0:t.length;for(r&&i&&(n=t[++o]);++o<i;)n=e(n,t[o],o,t);return n}function Re(t,e,n,r){var o=null==t?0:t.length;for(r&&o&&(n=t[--o]);o--;)n=e(n,t[o],o,t);return n}function De(t,e){for(var n=-1,r=null==t?0:t.length;++n<r;)if(e(t[n],n,t))return!0;return!1}var Fe=Ve("length");function Be(t,e,n){var r;return n(t,(function(t,n,o){if(e(t,n,o))return r=n,!1})),r}function $e(t,e,n,r){for(var o=t.length,i=n+(r?1:-1);r?i--:++i<o;)if(e(t[i],i,t))return i;return-1}function ke(t,e,n){return e==e?function(t,e,n){for(var r=n-1,o=t.length;++r<o;)if(t[r]===e)return r;return-1}(t,e,n):$e(t,Ge,n)}function He(t,e,n,r){for(var o=n-1,i=t.length;++o<i;)if(r(t[o],e))return o;return-1}function Ge(t){return t!=t}function Ue(t,e){var n=null==t?0:t.length;return n?We(t,e)/n:d}function Ve(t){return function(e){return null==e?o:e[t]}}function qe(t){return function(e){return null==t?o:t[e]}}function je(t,e,n,r,o){return o(t,(function(t,o,i){n=r?(r=!1,t):e(n,t,o,i)})),n}function We(t,e){for(var n,r=-1,i=t.length;++r<i;){var s=e(t[r]);s!==o&&(n=n===o?s:n+s)}return n}function ze(t,e){for(var n=-1,r=Array(t);++n<t;)r[n]=e(n);return r}function Ye(t){return t?t.slice(0,dn(t)+1).replace(rt,""):t}function Ke(t){return function(e){return t(e)}}function Je(t,e){return Pe(e,(function(e){return t[e]}))}function Qe(t,e){return t.has(e)}function Xe(t,e){for(var n=-1,r=t.length;++n<r&&ke(e,t[n],0)>-1;);return n}function Ze(t,e){for(var n=t.length;n--&&ke(e,t[n],0)>-1;);return n}var tn=qe({À:"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"}),en=qe({"&":"&","<":"<",">":">",'"':""","'":"'"});function nn(t){return"\\"+se[t]}function rn(t){return te.test(t)}function on(t){var e=-1,n=Array(t.size);return t.forEach((function(t,r){n[++e]=[r,t]})),n}function sn(t,e){return function(n){return t(e(n))}}function an(t,e){for(var n=-1,r=t.length,o=0,i=[];++n<r;){var s=t[n];s!==e&&s!==a||(t[n]=a,i[o++]=n)}return i}function ln(t){var e=-1,n=Array(t.size);return t.forEach((function(t){n[++e]=t})),n}function un(t){var e=-1,n=Array(t.size);return t.forEach((function(t){n[++e]=[t,t]})),n}function cn(t){return rn(t)?function(t){for(var e=Xt.lastIndex=0;Xt.test(t);)++e;return e}(t):Fe(t)}function hn(t){return rn(t)?function(t){return t.match(Xt)||[]}(t):function(t){return t.split("")}(t)}function dn(t){for(var e=t.length;e--&&ot.test(t.charAt(e)););return e}var fn=qe({"&":"&","<":"<",">":">",""":'"',"'":"'"}),pn=function t(e){var n,r=(e=null==e?he:pn.defaults(he.Object(),e,pn.pick(he,ne))).Array,ot=e.Date,wt=e.Error,At=e.Function,xt=e.Math,Et=e.Object,Tt=e.RegExp,St=e.String,It=e.TypeError,_t=r.prototype,Nt=At.prototype,Mt=Et.prototype,Pt=e["__core-js_shared__"],Lt=Nt.toString,Ot=Mt.hasOwnProperty,Rt=0,Dt=(n=/[^.]+$/.exec(Pt&&Pt.keys&&Pt.keys.IE_PROTO||""))?"Symbol(src)_1."+n:"",Ft=Mt.toString,Bt=Lt.call(Et),$t=he._,kt=Tt("^"+Lt.call(Ot).replace(et,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Ht=pe?e.Buffer:o,Gt=e.Symbol,Ut=e.Uint8Array,Vt=Ht?Ht.allocUnsafe:o,qt=sn(Et.getPrototypeOf,Et),jt=Et.create,Wt=Mt.propertyIsEnumerable,zt=_t.splice,Yt=Gt?Gt.isConcatSpreadable:o,Kt=Gt?Gt.iterator:o,Xt=Gt?Gt.toStringTag:o,te=function(){try{var t=ui(Et,"defineProperty");return t({},"",{}),t}catch(t){}}(),se=e.clearTimeout!==he.clearTimeout&&e.clearTimeout,ue=ot&&ot.now!==he.Date.now&&ot.now,ce=e.setTimeout!==he.setTimeout&&e.setTimeout,de=xt.ceil,fe=xt.floor,me=Et.getOwnPropertySymbols,ge=Ht?Ht.isBuffer:o,Fe=e.isFinite,qe=_t.join,mn=sn(Et.keys,Et),gn=xt.max,yn=xt.min,bn=ot.now,vn=e.parseInt,Cn=xt.random,wn=_t.reverse,An=ui(e,"DataView"),xn=ui(e,"Map"),En=ui(e,"Promise"),Tn=ui(e,"Set"),Sn=ui(e,"WeakMap"),In=ui(Et,"create"),_n=Sn&&new Sn,Nn={},Mn=Bi(An),Pn=Bi(xn),Ln=Bi(En),On=Bi(Tn),Rn=Bi(Sn),Dn=Gt?Gt.prototype:o,Fn=Dn?Dn.valueOf:o,Bn=Dn?Dn.toString:o;function $n(t){if(ta(t)&&!Vs(t)&&!(t instanceof Un)){if(t instanceof Gn)return t;if(Ot.call(t,"__wrapped__"))return $i(t)}return new Gn(t)}var kn=function(){function t(){}return function(e){if(!Zs(e))return{};if(jt)return jt(e);t.prototype=e;var n=new t;return t.prototype=o,n}}();function Hn(){}function Gn(t,e){this.__wrapped__=t,this.__actions__=[],this.__chain__=!!e,this.__index__=0,this.__values__=o}function Un(t){this.__wrapped__=t,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=f,this.__views__=[]}function Vn(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function qn(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function jn(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function Wn(t){var e=-1,n=null==t?0:t.length;for(this.__data__=new jn;++e<n;)this.add(t[e])}function zn(t){var e=this.__data__=new qn(t);this.size=e.size}function Yn(t,e){var n=Vs(t),r=!n&&Us(t),o=!n&&!r&&zs(t),i=!n&&!r&&!o&&la(t),s=n||r||o||i,a=s?ze(t.length,St):[],l=a.length;for(var u in t)!e&&!Ot.call(t,u)||s&&("length"==u||o&&("offset"==u||"parent"==u)||i&&("buffer"==u||"byteLength"==u||"byteOffset"==u)||gi(u,l))||a.push(u);return a}function Kn(t){var e=t.length;return e?t[jr(0,e-1)]:o}function Jn(t,e){return Li(Io(t),ir(e,0,t.length))}function Qn(t){return Li(Io(t))}function Xn(t,e,n){(n!==o&&!ks(t[e],n)||n===o&&!(e in t))&&rr(t,e,n)}function Zn(t,e,n){var r=t[e];Ot.call(t,e)&&ks(r,n)&&(n!==o||e in t)||rr(t,e,n)}function tr(t,e){for(var n=t.length;n--;)if(ks(t[n][0],e))return n;return-1}function er(t,e,n,r){return cr(t,(function(t,o,i){e(r,t,n(t),i)})),r}function nr(t,e){return t&&_o(e,Ma(e),t)}function rr(t,e,n){"__proto__"==e&&te?te(t,e,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[e]=n}function or(t,e){for(var n=-1,i=e.length,s=r(i),a=null==t;++n<i;)s[n]=a?o:Ta(t,e[n]);return s}function ir(t,e,n){return t==t&&(n!==o&&(t=t<=n?t:n),e!==o&&(t=t>=e?t:e)),t}function sr(t,e,n,r,i,s){var a,l=1&e,u=2&e,c=4&e;if(n&&(a=i?n(t,r,i,s):n(t)),a!==o)return a;if(!Zs(t))return t;var h=Vs(t);if(h){if(a=function(t){var e=t.length,n=new t.constructor(e);return e&&"string"==typeof t[0]&&Ot.call(t,"index")&&(n.index=t.index,n.input=t.input),n}(t),!l)return Io(t,a)}else{var d=di(t),f=d==C||d==w;if(zs(t))return wo(t,l);if(d==E||d==m||f&&!i){if(a=u||f?{}:pi(t),!l)return u?function(t,e){return _o(t,hi(t),e)}(t,function(t,e){return t&&_o(e,Pa(e),t)}(a,t)):function(t,e){return _o(t,ci(t),e)}(t,nr(a,t))}else{if(!ie[d])return i?t:{};a=function(t,e,n){var r,o=t.constructor;switch(e){case P:return Ao(t);case y:case b:return new o(+t);case L:return function(t,e){var n=e?Ao(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.byteLength)}(t,n);case O:case R:case D:case F:case B:case $:case k:case H:case G:return xo(t,n);case A:return new o;case x:case _:return new o(t);case S:return function(t){var e=new t.constructor(t.source,dt.exec(t));return e.lastIndex=t.lastIndex,e}(t);case I:return new o;case N:return r=t,Fn?Et(Fn.call(r)):{}}}(t,d,l)}}s||(s=new zn);var p=s.get(t);if(p)return p;s.set(t,a),ia(t)?t.forEach((function(r){a.add(sr(r,e,n,r,t,s))})):ea(t)&&t.forEach((function(r,o){a.set(o,sr(r,e,n,o,t,s))}));var g=h?o:(c?u?ni:ei:u?Pa:Ma)(t);return Te(g||t,(function(r,o){g&&(r=t[o=r]),Zn(a,o,sr(r,e,n,o,t,s))})),a}function ar(t,e,n){var r=n.length;if(null==t)return!r;for(t=Et(t);r--;){var i=n[r],s=e[i],a=t[i];if(a===o&&!(i in t)||!s(a))return!1}return!0}function lr(t,e,n){if("function"!=typeof t)throw new It(i);return _i((function(){t.apply(o,n)}),e)}function ur(t,e,n,r){var o=-1,i=Ne,s=!0,a=t.length,l=[],u=e.length;if(!a)return l;n&&(e=Pe(e,Ke(n))),r?(i=Me,s=!1):e.length>=200&&(i=Qe,s=!1,e=new Wn(e));t:for(;++o<a;){var c=t[o],h=null==n?c:n(c);if(c=r||0!==c?c:0,s&&h==h){for(var d=u;d--;)if(e[d]===h)continue t;l.push(c)}else i(e,h,r)||l.push(c)}return l}$n.templateSettings={escape:K,evaluate:J,interpolate:Q,variable:"",imports:{_:$n}},$n.prototype=Hn.prototype,$n.prototype.constructor=$n,Gn.prototype=kn(Hn.prototype),Gn.prototype.constructor=Gn,Un.prototype=kn(Hn.prototype),Un.prototype.constructor=Un,Vn.prototype.clear=function(){this.__data__=In?In(null):{},this.size=0},Vn.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},Vn.prototype.get=function(t){var e=this.__data__;if(In){var n=e[t];return n===s?o:n}return Ot.call(e,t)?e[t]:o},Vn.prototype.has=function(t){var e=this.__data__;return In?e[t]!==o:Ot.call(e,t)},Vn.prototype.set=function(t,e){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=In&&e===o?s:e,this},qn.prototype.clear=function(){this.__data__=[],this.size=0},qn.prototype.delete=function(t){var e=this.__data__,n=tr(e,t);return!(n<0||(n==e.length-1?e.pop():zt.call(e,n,1),--this.size,0))},qn.prototype.get=function(t){var e=this.__data__,n=tr(e,t);return n<0?o:e[n][1]},qn.prototype.has=function(t){return tr(this.__data__,t)>-1},qn.prototype.set=function(t,e){var n=this.__data__,r=tr(n,t);return r<0?(++this.size,n.push([t,e])):n[r][1]=e,this},jn.prototype.clear=function(){this.size=0,this.__data__={hash:new Vn,map:new(xn||qn),string:new Vn}},jn.prototype.delete=function(t){var e=ai(this,t).delete(t);return this.size-=e?1:0,e},jn.prototype.get=function(t){return ai(this,t).get(t)},jn.prototype.has=function(t){return ai(this,t).has(t)},jn.prototype.set=function(t,e){var n=ai(this,t),r=n.size;return n.set(t,e),this.size+=n.size==r?0:1,this},Wn.prototype.add=Wn.prototype.push=function(t){return this.__data__.set(t,s),this},Wn.prototype.has=function(t){return this.__data__.has(t)},zn.prototype.clear=function(){this.__data__=new qn,this.size=0},zn.prototype.delete=function(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n},zn.prototype.get=function(t){return this.__data__.get(t)},zn.prototype.has=function(t){return this.__data__.has(t)},zn.prototype.set=function(t,e){var n=this.__data__;if(n instanceof qn){var r=n.__data__;if(!xn||r.length<199)return r.push([t,e]),this.size=++n.size,this;n=this.__data__=new jn(r)}return n.set(t,e),this.size=n.size,this};var cr=Po(br),hr=Po(vr,!0);function dr(t,e){var n=!0;return cr(t,(function(t,r,o){return n=!!e(t,r,o)})),n}function fr(t,e,n){for(var r=-1,i=t.length;++r<i;){var s=t[r],a=e(s);if(null!=a&&(l===o?a==a&&!aa(a):n(a,l)))var l=a,u=s}return u}function pr(t,e){var n=[];return cr(t,(function(t,r,o){e(t,r,o)&&n.push(t)})),n}function mr(t,e,n,r,o){var i=-1,s=t.length;for(n||(n=mi),o||(o=[]);++i<s;){var a=t[i];e>0&&n(a)?e>1?mr(a,e-1,n,r,o):Le(o,a):r||(o[o.length]=a)}return o}var gr=Lo(),yr=Lo(!0);function br(t,e){return t&&gr(t,e,Ma)}function vr(t,e){return t&&yr(t,e,Ma)}function Cr(t,e){return _e(e,(function(e){return Js(t[e])}))}function wr(t,e){for(var n=0,r=(e=yo(e,t)).length;null!=t&&n<r;)t=t[Fi(e[n++])];return n&&n==r?t:o}function Ar(t,e,n){var r=e(t);return Vs(t)?r:Le(r,n(t))}function xr(t){return null==t?t===o?"[object Undefined]":"[object Null]":Xt&&Xt in Et(t)?function(t){var e=Ot.call(t,Xt),n=t[Xt];try{t[Xt]=o;var r=!0}catch(t){}var i=Ft.call(t);return r&&(e?t[Xt]=n:delete t[Xt]),i}(t):function(t){return Ft.call(t)}(t)}function Er(t,e){return t>e}function Tr(t,e){return null!=t&&Ot.call(t,e)}function Sr(t,e){return null!=t&&e in Et(t)}function Ir(t,e,n){for(var i=n?Me:Ne,s=t[0].length,a=t.length,l=a,u=r(a),c=1/0,h=[];l--;){var d=t[l];l&&e&&(d=Pe(d,Ke(e))),c=yn(d.length,c),u[l]=!n&&(e||s>=120&&d.length>=120)?new Wn(l&&d):o}d=t[0];var f=-1,p=u[0];t:for(;++f<s&&h.length<c;){var m=d[f],g=e?e(m):m;if(m=n||0!==m?m:0,!(p?Qe(p,g):i(h,g,n))){for(l=a;--l;){var y=u[l];if(!(y?Qe(y,g):i(t[l],g,n)))continue t}p&&p.push(g),h.push(m)}}return h}function _r(t,e,n){var r=null==(t=Ti(t,e=yo(e,t)))?t:t[Fi(Ki(e))];return null==r?o:xe(r,t,n)}function Nr(t){return ta(t)&&xr(t)==m}function Mr(t,e,n,r,i){return t===e||(null==t||null==e||!ta(t)&&!ta(e)?t!=t&&e!=e:function(t,e,n,r,i,s){var a=Vs(t),l=Vs(e),u=a?g:di(t),c=l?g:di(e),h=(u=u==m?E:u)==E,d=(c=c==m?E:c)==E,f=u==c;if(f&&zs(t)){if(!zs(e))return!1;a=!0,h=!1}if(f&&!h)return s||(s=new zn),a||la(t)?Zo(t,e,n,r,i,s):function(t,e,n,r,o,i,s){switch(n){case L:if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case P:return!(t.byteLength!=e.byteLength||!i(new Ut(t),new Ut(e)));case y:case b:case x:return ks(+t,+e);case v:return t.name==e.name&&t.message==e.message;case S:case _:return t==e+"";case A:var a=on;case I:var l=1&r;if(a||(a=ln),t.size!=e.size&&!l)return!1;var u=s.get(t);if(u)return u==e;r|=2,s.set(t,e);var c=Zo(a(t),a(e),r,o,i,s);return s.delete(t),c;case N:if(Fn)return Fn.call(t)==Fn.call(e)}return!1}(t,e,u,n,r,i,s);if(!(1&n)){var p=h&&Ot.call(t,"__wrapped__"),C=d&&Ot.call(e,"__wrapped__");if(p||C){var w=p?t.value():t,T=C?e.value():e;return s||(s=new zn),i(w,T,n,r,s)}}return!!f&&(s||(s=new zn),function(t,e,n,r,i,s){var a=1&n,l=ei(t),u=l.length;if(u!=ei(e).length&&!a)return!1;for(var c=u;c--;){var h=l[c];if(!(a?h in e:Ot.call(e,h)))return!1}var d=s.get(t),f=s.get(e);if(d&&f)return d==e&&f==t;var p=!0;s.set(t,e),s.set(e,t);for(var m=a;++c<u;){var g=t[h=l[c]],y=e[h];if(r)var b=a?r(y,g,h,e,t,s):r(g,y,h,t,e,s);if(!(b===o?g===y||i(g,y,n,r,s):b)){p=!1;break}m||(m="constructor"==h)}if(p&&!m){var v=t.constructor,C=e.constructor;v==C||!("constructor"in t)||!("constructor"in e)||"function"==typeof v&&v instanceof v&&"function"==typeof C&&C instanceof C||(p=!1)}return s.delete(t),s.delete(e),p}(t,e,n,r,i,s))}(t,e,n,r,Mr,i))}function Pr(t,e,n,r){var i=n.length,s=i,a=!r;if(null==t)return!s;for(t=Et(t);i--;){var l=n[i];if(a&&l[2]?l[1]!==t[l[0]]:!(l[0]in t))return!1}for(;++i<s;){var u=(l=n[i])[0],c=t[u],h=l[1];if(a&&l[2]){if(c===o&&!(u in t))return!1}else{var d=new zn;if(r)var f=r(c,h,u,t,e,d);if(!(f===o?Mr(h,c,3,r,d):f))return!1}}return!0}function Lr(t){return!(!Zs(t)||(e=t,Dt&&Dt in e))&&(Js(t)?kt:mt).test(Bi(t));var e}function Or(t){return"function"==typeof t?t:null==t?nl:"object"==typeof t?Vs(t)?$r(t[0],t[1]):Br(t):hl(t)}function Rr(t){if(!wi(t))return mn(t);var e=[];for(var n in Et(t))Ot.call(t,n)&&"constructor"!=n&&e.push(n);return e}function Dr(t,e){return t<e}function Fr(t,e){var n=-1,o=js(t)?r(t.length):[];return cr(t,(function(t,r,i){o[++n]=e(t,r,i)})),o}function Br(t){var e=li(t);return 1==e.length&&e[0][2]?xi(e[0][0],e[0][1]):function(n){return n===t||Pr(n,t,e)}}function $r(t,e){return bi(t)&&Ai(e)?xi(Fi(t),e):function(n){var r=Ta(n,t);return r===o&&r===e?Sa(n,t):Mr(e,r,3)}}function kr(t,e,n,r,i){t!==e&&gr(e,(function(s,a){if(i||(i=new zn),Zs(s))!function(t,e,n,r,i,s,a){var l=Si(t,n),u=Si(e,n),c=a.get(u);if(c)Xn(t,n,c);else{var h=s?s(l,u,n+"",t,e,a):o,d=h===o;if(d){var f=Vs(u),p=!f&&zs(u),m=!f&&!p&&la(u);h=u,f||p||m?Vs(l)?h=l:Ws(l)?h=Io(l):p?(d=!1,h=wo(u,!0)):m?(d=!1,h=xo(u,!0)):h=[]:ra(u)||Us(u)?(h=l,Us(l)?h=ga(l):Zs(l)&&!Js(l)||(h=pi(u))):d=!1}d&&(a.set(u,h),i(h,u,r,s,a),a.delete(u)),Xn(t,n,h)}}(t,e,a,n,kr,r,i);else{var l=r?r(Si(t,a),s,a+"",t,e,i):o;l===o&&(l=s),Xn(t,a,l)}}),Pa)}function Hr(t,e){var n=t.length;if(n)return gi(e+=e<0?n:0,n)?t[e]:o}function Gr(t,e,n){e=e.length?Pe(e,(function(t){return Vs(t)?function(e){return wr(e,1===t.length?t[0]:t)}:t})):[nl];var r=-1;e=Pe(e,Ke(si()));var o=Fr(t,(function(t,n,o){var i=Pe(e,(function(e){return e(t)}));return{criteria:i,index:++r,value:t}}));return function(t){var e=t.length;for(t.sort((function(t,e){return function(t,e,n){for(var r=-1,o=t.criteria,i=e.criteria,s=o.length,a=n.length;++r<s;){var l=Eo(o[r],i[r]);if(l)return r>=a?l:l*("desc"==n[r]?-1:1)}return t.index-e.index}(t,e,n)}));e--;)t[e]=t[e].value;return t}(o)}function Ur(t,e,n){for(var r=-1,o=e.length,i={};++r<o;){var s=e[r],a=wr(t,s);n(a,s)&&Jr(i,yo(s,t),a)}return i}function Vr(t,e,n,r){var o=r?He:ke,i=-1,s=e.length,a=t;for(t===e&&(e=Io(e)),n&&(a=Pe(t,Ke(n)));++i<s;)for(var l=0,u=e[i],c=n?n(u):u;(l=o(a,c,l,r))>-1;)a!==t&&zt.call(a,l,1),zt.call(t,l,1);return t}function qr(t,e){for(var n=t?e.length:0,r=n-1;n--;){var o=e[n];if(n==r||o!==i){var i=o;gi(o)?zt.call(t,o,1):lo(t,o)}}return t}function jr(t,e){return t+fe(Cn()*(e-t+1))}function Wr(t,e){var n="";if(!t||e<1||e>h)return n;do{e%2&&(n+=t),(e=fe(e/2))&&(t+=t)}while(e);return n}function zr(t,e){return Ni(Ei(t,e,nl),t+"")}function Yr(t){return Kn(ka(t))}function Kr(t,e){var n=ka(t);return Li(n,ir(e,0,n.length))}function Jr(t,e,n,r){if(!Zs(t))return t;for(var i=-1,s=(e=yo(e,t)).length,a=s-1,l=t;null!=l&&++i<s;){var u=Fi(e[i]),c=n;if("__proto__"===u||"constructor"===u||"prototype"===u)return t;if(i!=a){var h=l[u];(c=r?r(h,u,l):o)===o&&(c=Zs(h)?h:gi(e[i+1])?[]:{})}Zn(l,u,c),l=l[u]}return t}var Qr=_n?function(t,e){return _n.set(t,e),t}:nl,Xr=te?function(t,e){return te(t,"toString",{configurable:!0,enumerable:!1,value:Za(e),writable:!0})}:nl;function Zr(t){return Li(ka(t))}function to(t,e,n){var o=-1,i=t.length;e<0&&(e=-e>i?0:i+e),(n=n>i?i:n)<0&&(n+=i),i=e>n?0:n-e>>>0,e>>>=0;for(var s=r(i);++o<i;)s[o]=t[o+e];return s}function eo(t,e){var n;return cr(t,(function(t,r,o){return!(n=e(t,r,o))})),!!n}function no(t,e,n){var r=0,o=null==t?r:t.length;if("number"==typeof e&&e==e&&o<=2147483647){for(;r<o;){var i=r+o>>>1,s=t[i];null!==s&&!aa(s)&&(n?s<=e:s<e)?r=i+1:o=i}return o}return ro(t,e,nl,n)}function ro(t,e,n,r){var i=0,s=null==t?0:t.length;if(0===s)return 0;for(var a=(e=n(e))!=e,l=null===e,u=aa(e),c=e===o;i<s;){var h=fe((i+s)/2),d=n(t[h]),f=d!==o,p=null===d,m=d==d,g=aa(d);if(a)var y=r||m;else y=c?m&&(r||f):l?m&&f&&(r||!p):u?m&&f&&!p&&(r||!g):!p&&!g&&(r?d<=e:d<e);y?i=h+1:s=h}return yn(s,4294967294)}function oo(t,e){for(var n=-1,r=t.length,o=0,i=[];++n<r;){var s=t[n],a=e?e(s):s;if(!n||!ks(a,l)){var l=a;i[o++]=0===s?0:s}}return i}function io(t){return"number"==typeof t?t:aa(t)?d:+t}function so(t){if("string"==typeof t)return t;if(Vs(t))return Pe(t,so)+"";if(aa(t))return Bn?Bn.call(t):"";var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}function ao(t,e,n){var r=-1,o=Ne,i=t.length,s=!0,a=[],l=a;if(n)s=!1,o=Me;else if(i>=200){var u=e?null:zo(t);if(u)return ln(u);s=!1,o=Qe,l=new Wn}else l=e?[]:a;t:for(;++r<i;){var c=t[r],h=e?e(c):c;if(c=n||0!==c?c:0,s&&h==h){for(var d=l.length;d--;)if(l[d]===h)continue t;e&&l.push(h),a.push(c)}else o(l,h,n)||(l!==a&&l.push(h),a.push(c))}return a}function lo(t,e){return null==(t=Ti(t,e=yo(e,t)))||delete t[Fi(Ki(e))]}function uo(t,e,n,r){return Jr(t,e,n(wr(t,e)),r)}function co(t,e,n,r){for(var o=t.length,i=r?o:-1;(r?i--:++i<o)&&e(t[i],i,t););return n?to(t,r?0:i,r?i+1:o):to(t,r?i+1:0,r?o:i)}function ho(t,e){var n=t;return n instanceof Un&&(n=n.value()),Oe(e,(function(t,e){return e.func.apply(e.thisArg,Le([t],e.args))}),n)}function fo(t,e,n){var o=t.length;if(o<2)return o?ao(t[0]):[];for(var i=-1,s=r(o);++i<o;)for(var a=t[i],l=-1;++l<o;)l!=i&&(s[i]=ur(s[i]||a,t[l],e,n));return ao(mr(s,1),e,n)}function po(t,e,n){for(var r=-1,i=t.length,s=e.length,a={};++r<i;){var l=r<s?e[r]:o;n(a,t[r],l)}return a}function mo(t){return Ws(t)?t:[]}function go(t){return"function"==typeof t?t:nl}function yo(t,e){return Vs(t)?t:bi(t,e)?[t]:Di(ya(t))}var bo=zr;function vo(t,e,n){var r=t.length;return n=n===o?r:n,!e&&n>=r?t:to(t,e,n)}var Co=se||function(t){return he.clearTimeout(t)};function wo(t,e){if(e)return t.slice();var n=t.length,r=Vt?Vt(n):new t.constructor(n);return t.copy(r),r}function Ao(t){var e=new t.constructor(t.byteLength);return new Ut(e).set(new Ut(t)),e}function xo(t,e){var n=e?Ao(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.length)}function Eo(t,e){if(t!==e){var n=t!==o,r=null===t,i=t==t,s=aa(t),a=e!==o,l=null===e,u=e==e,c=aa(e);if(!l&&!c&&!s&&t>e||s&&a&&u&&!l&&!c||r&&a&&u||!n&&u||!i)return 1;if(!r&&!s&&!c&&t<e||c&&n&&i&&!r&&!s||l&&n&&i||!a&&i||!u)return-1}return 0}function To(t,e,n,o){for(var i=-1,s=t.length,a=n.length,l=-1,u=e.length,c=gn(s-a,0),h=r(u+c),d=!o;++l<u;)h[l]=e[l];for(;++i<a;)(d||i<s)&&(h[n[i]]=t[i]);for(;c--;)h[l++]=t[i++];return h}function So(t,e,n,o){for(var i=-1,s=t.length,a=-1,l=n.length,u=-1,c=e.length,h=gn(s-l,0),d=r(h+c),f=!o;++i<h;)d[i]=t[i];for(var p=i;++u<c;)d[p+u]=e[u];for(;++a<l;)(f||i<s)&&(d[p+n[a]]=t[i++]);return d}function Io(t,e){var n=-1,o=t.length;for(e||(e=r(o));++n<o;)e[n]=t[n];return e}function _o(t,e,n,r){var i=!n;n||(n={});for(var s=-1,a=e.length;++s<a;){var l=e[s],u=r?r(n[l],t[l],l,n,t):o;u===o&&(u=t[l]),i?rr(n,l,u):Zn(n,l,u)}return n}function No(t,e){return function(n,r){var o=Vs(n)?Ee:er,i=e?e():{};return o(n,t,si(r,2),i)}}function Mo(t){return zr((function(e,n){var r=-1,i=n.length,s=i>1?n[i-1]:o,a=i>2?n[2]:o;for(s=t.length>3&&"function"==typeof s?(i--,s):o,a&&yi(n[0],n[1],a)&&(s=i<3?o:s,i=1),e=Et(e);++r<i;){var l=n[r];l&&t(e,l,r,s)}return e}))}function Po(t,e){return function(n,r){if(null==n)return n;if(!js(n))return t(n,r);for(var o=n.length,i=e?o:-1,s=Et(n);(e?i--:++i<o)&&!1!==r(s[i],i,s););return n}}function Lo(t){return function(e,n,r){for(var o=-1,i=Et(e),s=r(e),a=s.length;a--;){var l=s[t?a:++o];if(!1===n(i[l],l,i))break}return e}}function Oo(t){return function(e){var n=rn(e=ya(e))?hn(e):o,r=n?n[0]:e.charAt(0),i=n?vo(n,1).join(""):e.slice(1);return r[t]()+i}}function Ro(t){return function(e){return Oe(Ja(Ua(e).replace(Jt,"")),t,"")}}function Do(t){return function(){var e=arguments;switch(e.length){case 0:return new t;case 1:return new t(e[0]);case 2:return new t(e[0],e[1]);case 3:return new t(e[0],e[1],e[2]);case 4:return new t(e[0],e[1],e[2],e[3]);case 5:return new t(e[0],e[1],e[2],e[3],e[4]);case 6:return new t(e[0],e[1],e[2],e[3],e[4],e[5]);case 7:return new t(e[0],e[1],e[2],e[3],e[4],e[5],e[6])}var n=kn(t.prototype),r=t.apply(n,e);return Zs(r)?r:n}}function Fo(t){return function(e,n,r){var i=Et(e);if(!js(e)){var s=si(n,3);e=Ma(e),n=function(t){return s(i[t],t,i)}}var a=t(e,n,r);return a>-1?i[s?e[a]:a]:o}}function Bo(t){return ti((function(e){var n=e.length,r=n,s=Gn.prototype.thru;for(t&&e.reverse();r--;){var a=e[r];if("function"!=typeof a)throw new It(i);if(s&&!l&&"wrapper"==oi(a))var l=new Gn([],!0)}for(r=l?r:n;++r<n;){var u=oi(a=e[r]),c="wrapper"==u?ri(a):o;l=c&&vi(c[0])&&424==c[1]&&!c[4].length&&1==c[9]?l[oi(c[0])].apply(l,c[3]):1==a.length&&vi(a)?l[u]():l.thru(a)}return function(){var t=arguments,r=t[0];if(l&&1==t.length&&Vs(r))return l.plant(r).value();for(var o=0,i=n?e[o].apply(this,t):r;++o<n;)i=e[o].call(this,i);return i}}))}function $o(t,e,n,i,s,a,l,c,h,d){var f=e&u,p=1&e,m=2&e,g=24&e,y=512&e,b=m?o:Do(t);return function u(){for(var v=arguments.length,C=r(v),w=v;w--;)C[w]=arguments[w];if(g)var A=ii(u),x=function(t,e){for(var n=t.length,r=0;n--;)t[n]===e&&++r;return r}(C,A);if(i&&(C=To(C,i,s,g)),a&&(C=So(C,a,l,g)),v-=x,g&&v<d){var E=an(C,A);return jo(t,e,$o,u.placeholder,n,C,E,c,h,d-v)}var T=p?n:this,S=m?T[t]:t;return v=C.length,c?C=function(t,e){for(var n=t.length,r=yn(e.length,n),i=Io(t);r--;){var s=e[r];t[r]=gi(s,n)?i[s]:o}return t}(C,c):y&&v>1&&C.reverse(),f&&h<v&&(C.length=h),this&&this!==he&&this instanceof u&&(S=b||Do(S)),S.apply(T,C)}}function ko(t,e){return function(n,r){return function(t,e,n,r){return br(t,(function(t,o,i){e(r,n(t),o,i)})),r}(n,t,e(r),{})}}function Ho(t,e){return function(n,r){var i;if(n===o&&r===o)return e;if(n!==o&&(i=n),r!==o){if(i===o)return r;"string"==typeof n||"string"==typeof r?(n=so(n),r=so(r)):(n=io(n),r=io(r)),i=t(n,r)}return i}}function Go(t){return ti((function(e){return e=Pe(e,Ke(si())),zr((function(n){var r=this;return t(e,(function(t){return xe(t,r,n)}))}))}))}function Uo(t,e){var n=(e=e===o?" ":so(e)).length;if(n<2)return n?Wr(e,t):e;var r=Wr(e,de(t/cn(e)));return rn(e)?vo(hn(r),0,t).join(""):r.slice(0,t)}function Vo(t){return function(e,n,i){return i&&"number"!=typeof i&&yi(e,n,i)&&(n=i=o),e=da(e),n===o?(n=e,e=0):n=da(n),function(t,e,n,o){for(var i=-1,s=gn(de((e-t)/(n||1)),0),a=r(s);s--;)a[o?s:++i]=t,t+=n;return a}(e,n,i=i===o?e<n?1:-1:da(i),t)}}function qo(t){return function(e,n){return"string"==typeof e&&"string"==typeof n||(e=ma(e),n=ma(n)),t(e,n)}}function jo(t,e,n,r,i,s,a,u,c,h){var d=8&e;e|=d?l:64,4&(e&=~(d?64:l))||(e&=-4);var f=[t,e,i,d?s:o,d?a:o,d?o:s,d?o:a,u,c,h],p=n.apply(o,f);return vi(t)&&Ii(p,f),p.placeholder=r,Mi(p,t,e)}function Wo(t){var e=xt[t];return function(t,n){if(t=ma(t),(n=null==n?0:yn(fa(n),292))&&Fe(t)){var r=(ya(t)+"e").split("e");return+((r=(ya(e(r[0]+"e"+(+r[1]+n)))+"e").split("e"))[0]+"e"+(+r[1]-n))}return e(t)}}var zo=Tn&&1/ln(new Tn([,-0]))[1]==c?function(t){return new Tn(t)}:al;function Yo(t){return function(e){var n=di(e);return n==A?on(e):n==I?un(e):function(t,e){return Pe(e,(function(e){return[e,t[e]]}))}(e,t(e))}}function Ko(t,e,n,s,c,h,d,f){var p=2&e;if(!p&&"function"!=typeof t)throw new It(i);var m=s?s.length:0;if(m||(e&=-97,s=c=o),d=d===o?d:gn(fa(d),0),f=f===o?f:fa(f),m-=c?c.length:0,64&e){var g=s,y=c;s=c=o}var b=p?o:ri(t),v=[t,e,n,s,c,g,y,h,d,f];if(b&&function(t,e){var n=t[1],r=e[1],o=n|r,i=o<131,s=r==u&&8==n||r==u&&256==n&&t[7].length<=e[8]||384==r&&e[7].length<=e[8]&&8==n;if(!i&&!s)return t;1&r&&(t[2]=e[2],o|=1&n?0:4);var l=e[3];if(l){var c=t[3];t[3]=c?To(c,l,e[4]):l,t[4]=c?an(t[3],a):e[4]}(l=e[5])&&(c=t[5],t[5]=c?So(c,l,e[6]):l,t[6]=c?an(t[5],a):e[6]),(l=e[7])&&(t[7]=l),r&u&&(t[8]=null==t[8]?e[8]:yn(t[8],e[8])),null==t[9]&&(t[9]=e[9]),t[0]=e[0],t[1]=o}(v,b),t=v[0],e=v[1],n=v[2],s=v[3],c=v[4],!(f=v[9]=v[9]===o?p?0:t.length:gn(v[9]-m,0))&&24&e&&(e&=-25),e&&1!=e)C=8==e||16==e?function(t,e,n){var i=Do(t);return function s(){for(var a=arguments.length,l=r(a),u=a,c=ii(s);u--;)l[u]=arguments[u];var h=a<3&&l[0]!==c&&l[a-1]!==c?[]:an(l,c);return(a-=h.length)<n?jo(t,e,$o,s.placeholder,o,l,h,o,o,n-a):xe(this&&this!==he&&this instanceof s?i:t,this,l)}}(t,e,f):e!=l&&33!=e||c.length?$o.apply(o,v):function(t,e,n,o){var i=1&e,s=Do(t);return function e(){for(var a=-1,l=arguments.length,u=-1,c=o.length,h=r(c+l),d=this&&this!==he&&this instanceof e?s:t;++u<c;)h[u]=o[u];for(;l--;)h[u++]=arguments[++a];return xe(d,i?n:this,h)}}(t,e,n,s);else var C=function(t,e,n){var r=1&e,o=Do(t);return function e(){return(this&&this!==he&&this instanceof e?o:t).apply(r?n:this,arguments)}}(t,e,n);return Mi((b?Qr:Ii)(C,v),t,e)}function Jo(t,e,n,r){return t===o||ks(t,Mt[n])&&!Ot.call(r,n)?e:t}function Qo(t,e,n,r,i,s){return Zs(t)&&Zs(e)&&(s.set(e,t),kr(t,e,o,Qo,s),s.delete(e)),t}function Xo(t){return ra(t)?o:t}function Zo(t,e,n,r,i,s){var a=1&n,l=t.length,u=e.length;if(l!=u&&!(a&&u>l))return!1;var c=s.get(t),h=s.get(e);if(c&&h)return c==e&&h==t;var d=-1,f=!0,p=2&n?new Wn:o;for(s.set(t,e),s.set(e,t);++d<l;){var m=t[d],g=e[d];if(r)var y=a?r(g,m,d,e,t,s):r(m,g,d,t,e,s);if(y!==o){if(y)continue;f=!1;break}if(p){if(!De(e,(function(t,e){if(!Qe(p,e)&&(m===t||i(m,t,n,r,s)))return p.push(e)}))){f=!1;break}}else if(m!==g&&!i(m,g,n,r,s)){f=!1;break}}return s.delete(t),s.delete(e),f}function ti(t){return Ni(Ei(t,o,qi),t+"")}function ei(t){return Ar(t,Ma,ci)}function ni(t){return Ar(t,Pa,hi)}var ri=_n?function(t){return _n.get(t)}:al;function oi(t){for(var e=t.name+"",n=Nn[e],r=Ot.call(Nn,e)?n.length:0;r--;){var o=n[r],i=o.func;if(null==i||i==t)return o.name}return e}function ii(t){return(Ot.call($n,"placeholder")?$n:t).placeholder}function si(){var t=$n.iteratee||rl;return t=t===rl?Or:t,arguments.length?t(arguments[0],arguments[1]):t}function ai(t,e){var n,r,o=t.__data__;return("string"==(r=typeof(n=e))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?o["string"==typeof e?"string":"hash"]:o.map}function li(t){for(var e=Ma(t),n=e.length;n--;){var r=e[n],o=t[r];e[n]=[r,o,Ai(o)]}return e}function ui(t,e){var n=function(t,e){return null==t?o:t[e]}(t,e);return Lr(n)?n:o}var ci=me?function(t){return null==t?[]:(t=Et(t),_e(me(t),(function(e){return Wt.call(t,e)})))}:pl,hi=me?function(t){for(var e=[];t;)Le(e,ci(t)),t=qt(t);return e}:pl,di=xr;function fi(t,e,n){for(var r=-1,o=(e=yo(e,t)).length,i=!1;++r<o;){var s=Fi(e[r]);if(!(i=null!=t&&n(t,s)))break;t=t[s]}return i||++r!=o?i:!!(o=null==t?0:t.length)&&Xs(o)&&gi(s,o)&&(Vs(t)||Us(t))}function pi(t){return"function"!=typeof t.constructor||wi(t)?{}:kn(qt(t))}function mi(t){return Vs(t)||Us(t)||!!(Yt&&t&&t[Yt])}function gi(t,e){var n=typeof t;return!!(e=null==e?h:e)&&("number"==n||"symbol"!=n&&yt.test(t))&&t>-1&&t%1==0&&t<e}function yi(t,e,n){if(!Zs(n))return!1;var r=typeof e;return!!("number"==r?js(n)&&gi(e,n.length):"string"==r&&e in n)&&ks(n[e],t)}function bi(t,e){if(Vs(t))return!1;var n=typeof t;return!("number"!=n&&"symbol"!=n&&"boolean"!=n&&null!=t&&!aa(t))||Z.test(t)||!X.test(t)||null!=e&&t in Et(e)}function vi(t){var e=oi(t),n=$n[e];if("function"!=typeof n||!(e in Un.prototype))return!1;if(t===n)return!0;var r=ri(n);return!!r&&t===r[0]}(An&&di(new An(new ArrayBuffer(1)))!=L||xn&&di(new xn)!=A||En&&di(En.resolve())!=T||Tn&&di(new Tn)!=I||Sn&&di(new Sn)!=M)&&(di=function(t){var e=xr(t),n=e==E?t.constructor:o,r=n?Bi(n):"";if(r)switch(r){case Mn:return L;case Pn:return A;case Ln:return T;case On:return I;case Rn:return M}return e});var Ci=Pt?Js:ml;function wi(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||Mt)}function Ai(t){return t==t&&!Zs(t)}function xi(t,e){return function(n){return null!=n&&n[t]===e&&(e!==o||t in Et(n))}}function Ei(t,e,n){return e=gn(e===o?t.length-1:e,0),function(){for(var o=arguments,i=-1,s=gn(o.length-e,0),a=r(s);++i<s;)a[i]=o[e+i];i=-1;for(var l=r(e+1);++i<e;)l[i]=o[i];return l[e]=n(a),xe(t,this,l)}}function Ti(t,e){return e.length<2?t:wr(t,to(e,0,-1))}function Si(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}var Ii=Pi(Qr),_i=ce||function(t,e){return he.setTimeout(t,e)},Ni=Pi(Xr);function Mi(t,e,n){var r=e+"";return Ni(t,function(t,e){var n=e.length;if(!n)return t;var r=n-1;return e[r]=(n>1?"& ":"")+e[r],e=e.join(n>2?", ":" "),t.replace(it,"{\n/* [wrapped with "+e+"] */\n")}(r,function(t,e){return Te(p,(function(n){var r="_."+n[0];e&n[1]&&!Ne(t,r)&&t.push(r)})),t.sort()}(function(t){var e=t.match(st);return e?e[1].split(at):[]}(r),n)))}function Pi(t){var e=0,n=0;return function(){var r=bn(),i=16-(r-n);if(n=r,i>0){if(++e>=800)return arguments[0]}else e=0;return t.apply(o,arguments)}}function Li(t,e){var n=-1,r=t.length,i=r-1;for(e=e===o?r:e;++n<e;){var s=jr(n,i),a=t[s];t[s]=t[n],t[n]=a}return t.length=e,t}var Oi,Ri,Di=(Oi=Os((function(t){var e=[];return 46===t.charCodeAt(0)&&e.push(""),t.replace(tt,(function(t,n,r,o){e.push(r?o.replace(ct,"$1"):n||t)})),e}),(function(t){return 500===Ri.size&&Ri.clear(),t})),Ri=Oi.cache,Oi);function Fi(t){if("string"==typeof t||aa(t))return t;var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}function Bi(t){if(null!=t){try{return Lt.call(t)}catch(t){}try{return t+""}catch(t){}}return""}function $i(t){if(t instanceof Un)return t.clone();var e=new Gn(t.__wrapped__,t.__chain__);return e.__actions__=Io(t.__actions__),e.__index__=t.__index__,e.__values__=t.__values__,e}var ki=zr((function(t,e){return Ws(t)?ur(t,mr(e,1,Ws,!0)):[]})),Hi=zr((function(t,e){var n=Ki(e);return Ws(n)&&(n=o),Ws(t)?ur(t,mr(e,1,Ws,!0),si(n,2)):[]})),Gi=zr((function(t,e){var n=Ki(e);return Ws(n)&&(n=o),Ws(t)?ur(t,mr(e,1,Ws,!0),o,n):[]}));function Ui(t,e,n){var r=null==t?0:t.length;if(!r)return-1;var o=null==n?0:fa(n);return o<0&&(o=gn(r+o,0)),$e(t,si(e,3),o)}function Vi(t,e,n){var r=null==t?0:t.length;if(!r)return-1;var i=r-1;return n!==o&&(i=fa(n),i=n<0?gn(r+i,0):yn(i,r-1)),$e(t,si(e,3),i,!0)}function qi(t){return null!=t&&t.length?mr(t,1):[]}function ji(t){return t&&t.length?t[0]:o}var Wi=zr((function(t){var e=Pe(t,mo);return e.length&&e[0]===t[0]?Ir(e):[]})),zi=zr((function(t){var e=Ki(t),n=Pe(t,mo);return e===Ki(n)?e=o:n.pop(),n.length&&n[0]===t[0]?Ir(n,si(e,2)):[]})),Yi=zr((function(t){var e=Ki(t),n=Pe(t,mo);return(e="function"==typeof e?e:o)&&n.pop(),n.length&&n[0]===t[0]?Ir(n,o,e):[]}));function Ki(t){var e=null==t?0:t.length;return e?t[e-1]:o}var Ji=zr(Qi);function Qi(t,e){return t&&t.length&&e&&e.length?Vr(t,e):t}var Xi=ti((function(t,e){var n=null==t?0:t.length,r=or(t,e);return qr(t,Pe(e,(function(t){return gi(t,n)?+t:t})).sort(Eo)),r}));function Zi(t){return null==t?t:wn.call(t)}var ts=zr((function(t){return ao(mr(t,1,Ws,!0))})),es=zr((function(t){var e=Ki(t);return Ws(e)&&(e=o),ao(mr(t,1,Ws,!0),si(e,2))})),ns=zr((function(t){var e=Ki(t);return e="function"==typeof e?e:o,ao(mr(t,1,Ws,!0),o,e)}));function rs(t){if(!t||!t.length)return[];var e=0;return t=_e(t,(function(t){if(Ws(t))return e=gn(t.length,e),!0})),ze(e,(function(e){return Pe(t,Ve(e))}))}function os(t,e){if(!t||!t.length)return[];var n=rs(t);return null==e?n:Pe(n,(function(t){return xe(e,o,t)}))}var is=zr((function(t,e){return Ws(t)?ur(t,e):[]})),ss=zr((function(t){return fo(_e(t,Ws))})),as=zr((function(t){var e=Ki(t);return Ws(e)&&(e=o),fo(_e(t,Ws),si(e,2))})),ls=zr((function(t){var e=Ki(t);return e="function"==typeof e?e:o,fo(_e(t,Ws),o,e)})),us=zr(rs),cs=zr((function(t){var e=t.length,n=e>1?t[e-1]:o;return n="function"==typeof n?(t.pop(),n):o,os(t,n)}));function hs(t){var e=$n(t);return e.__chain__=!0,e}function ds(t,e){return e(t)}var fs=ti((function(t){var e=t.length,n=e?t[0]:0,r=this.__wrapped__,i=function(e){return or(e,t)};return!(e>1||this.__actions__.length)&&r instanceof Un&&gi(n)?((r=r.slice(n,+n+(e?1:0))).__actions__.push({func:ds,args:[i],thisArg:o}),new Gn(r,this.__chain__).thru((function(t){return e&&!t.length&&t.push(o),t}))):this.thru(i)})),ps=No((function(t,e,n){Ot.call(t,n)?++t[n]:rr(t,n,1)})),ms=Fo(Ui),gs=Fo(Vi);function ys(t,e){return(Vs(t)?Te:cr)(t,si(e,3))}function bs(t,e){return(Vs(t)?Se:hr)(t,si(e,3))}var vs=No((function(t,e,n){Ot.call(t,n)?t[n].push(e):rr(t,n,[e])})),Cs=zr((function(t,e,n){var o=-1,i="function"==typeof e,s=js(t)?r(t.length):[];return cr(t,(function(t){s[++o]=i?xe(e,t,n):_r(t,e,n)})),s})),ws=No((function(t,e,n){rr(t,n,e)}));function As(t,e){return(Vs(t)?Pe:Fr)(t,si(e,3))}var xs=No((function(t,e,n){t[n?0:1].push(e)}),(function(){return[[],[]]})),Es=zr((function(t,e){if(null==t)return[];var n=e.length;return n>1&&yi(t,e[0],e[1])?e=[]:n>2&&yi(e[0],e[1],e[2])&&(e=[e[0]]),Gr(t,mr(e,1),[])})),Ts=ue||function(){return he.Date.now()};function Ss(t,e,n){return e=n?o:e,e=t&&null==e?t.length:e,Ko(t,u,o,o,o,o,e)}function Is(t,e){var n;if("function"!=typeof e)throw new It(i);return t=fa(t),function(){return--t>0&&(n=e.apply(this,arguments)),t<=1&&(e=o),n}}var _s=zr((function(t,e,n){var r=1;if(n.length){var o=an(n,ii(_s));r|=l}return Ko(t,r,e,n,o)})),Ns=zr((function(t,e,n){var r=3;if(n.length){var o=an(n,ii(Ns));r|=l}return Ko(e,r,t,n,o)}));function Ms(t,e,n){var r,s,a,l,u,c,h=0,d=!1,f=!1,p=!0;if("function"!=typeof t)throw new It(i);function m(e){var n=r,i=s;return r=s=o,h=e,l=t.apply(i,n)}function g(t){var n=t-c;return c===o||n>=e||n<0||f&&t-h>=a}function y(){var t=Ts();if(g(t))return b(t);u=_i(y,function(t){var n=e-(t-c);return f?yn(n,a-(t-h)):n}(t))}function b(t){return u=o,p&&r?m(t):(r=s=o,l)}function v(){var t=Ts(),n=g(t);if(r=arguments,s=this,c=t,n){if(u===o)return function(t){return h=t,u=_i(y,e),d?m(t):l}(c);if(f)return Co(u),u=_i(y,e),m(c)}return u===o&&(u=_i(y,e)),l}return e=ma(e)||0,Zs(n)&&(d=!!n.leading,a=(f="maxWait"in n)?gn(ma(n.maxWait)||0,e):a,p="trailing"in n?!!n.trailing:p),v.cancel=function(){u!==o&&Co(u),h=0,r=c=s=u=o},v.flush=function(){return u===o?l:b(Ts())},v}var Ps=zr((function(t,e){return lr(t,1,e)})),Ls=zr((function(t,e,n){return lr(t,ma(e)||0,n)}));function Os(t,e){if("function"!=typeof t||null!=e&&"function"!=typeof e)throw new It(i);var n=function(){var r=arguments,o=e?e.apply(this,r):r[0],i=n.cache;if(i.has(o))return i.get(o);var s=t.apply(this,r);return n.cache=i.set(o,s)||i,s};return n.cache=new(Os.Cache||jn),n}function Rs(t){if("function"!=typeof t)throw new It(i);return function(){var e=arguments;switch(e.length){case 0:return!t.call(this);case 1:return!t.call(this,e[0]);case 2:return!t.call(this,e[0],e[1]);case 3:return!t.call(this,e[0],e[1],e[2])}return!t.apply(this,e)}}Os.Cache=jn;var Ds=bo((function(t,e){var n=(e=1==e.length&&Vs(e[0])?Pe(e[0],Ke(si())):Pe(mr(e,1),Ke(si()))).length;return zr((function(r){for(var o=-1,i=yn(r.length,n);++o<i;)r[o]=e[o].call(this,r[o]);return xe(t,this,r)}))})),Fs=zr((function(t,e){var n=an(e,ii(Fs));return Ko(t,l,o,e,n)})),Bs=zr((function(t,e){var n=an(e,ii(Bs));return Ko(t,64,o,e,n)})),$s=ti((function(t,e){return Ko(t,256,o,o,o,e)}));function ks(t,e){return t===e||t!=t&&e!=e}var Hs=qo(Er),Gs=qo((function(t,e){return t>=e})),Us=Nr(function(){return arguments}())?Nr:function(t){return ta(t)&&Ot.call(t,"callee")&&!Wt.call(t,"callee")},Vs=r.isArray,qs=ye?Ke(ye):function(t){return ta(t)&&xr(t)==P};function js(t){return null!=t&&Xs(t.length)&&!Js(t)}function Ws(t){return ta(t)&&js(t)}var zs=ge||ml,Ys=be?Ke(be):function(t){return ta(t)&&xr(t)==b};function Ks(t){if(!ta(t))return!1;var e=xr(t);return e==v||"[object DOMException]"==e||"string"==typeof t.message&&"string"==typeof t.name&&!ra(t)}function Js(t){if(!Zs(t))return!1;var e=xr(t);return e==C||e==w||"[object AsyncFunction]"==e||"[object Proxy]"==e}function Qs(t){return"number"==typeof t&&t==fa(t)}function Xs(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=h}function Zs(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function ta(t){return null!=t&&"object"==typeof t}var ea=ve?Ke(ve):function(t){return ta(t)&&di(t)==A};function na(t){return"number"==typeof t||ta(t)&&xr(t)==x}function ra(t){if(!ta(t)||xr(t)!=E)return!1;var e=qt(t);if(null===e)return!0;var n=Ot.call(e,"constructor")&&e.constructor;return"function"==typeof n&&n instanceof n&&Lt.call(n)==Bt}var oa=Ce?Ke(Ce):function(t){return ta(t)&&xr(t)==S},ia=we?Ke(we):function(t){return ta(t)&&di(t)==I};function sa(t){return"string"==typeof t||!Vs(t)&&ta(t)&&xr(t)==_}function aa(t){return"symbol"==typeof t||ta(t)&&xr(t)==N}var la=Ae?Ke(Ae):function(t){return ta(t)&&Xs(t.length)&&!!oe[xr(t)]},ua=qo(Dr),ca=qo((function(t,e){return t<=e}));function ha(t){if(!t)return[];if(js(t))return sa(t)?hn(t):Io(t);if(Kt&&t[Kt])return function(t){for(var e,n=[];!(e=t.next()).done;)n.push(e.value);return n}(t[Kt]());var e=di(t);return(e==A?on:e==I?ln:ka)(t)}function da(t){return t?(t=ma(t))===c||t===-1/0?17976931348623157e292*(t<0?-1:1):t==t?t:0:0===t?t:0}function fa(t){var e=da(t),n=e%1;return e==e?n?e-n:e:0}function pa(t){return t?ir(fa(t),0,f):0}function ma(t){if("number"==typeof t)return t;if(aa(t))return d;if(Zs(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=Zs(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=Ye(t);var n=pt.test(t);return n||gt.test(t)?le(t.slice(2),n?2:8):ft.test(t)?d:+t}function ga(t){return _o(t,Pa(t))}function ya(t){return null==t?"":so(t)}var ba=Mo((function(t,e){if(wi(e)||js(e))_o(e,Ma(e),t);else for(var n in e)Ot.call(e,n)&&Zn(t,n,e[n])})),va=Mo((function(t,e){_o(e,Pa(e),t)})),Ca=Mo((function(t,e,n,r){_o(e,Pa(e),t,r)})),wa=Mo((function(t,e,n,r){_o(e,Ma(e),t,r)})),Aa=ti(or),xa=zr((function(t,e){t=Et(t);var n=-1,r=e.length,i=r>2?e[2]:o;for(i&&yi(e[0],e[1],i)&&(r=1);++n<r;)for(var s=e[n],a=Pa(s),l=-1,u=a.length;++l<u;){var c=a[l],h=t[c];(h===o||ks(h,Mt[c])&&!Ot.call(t,c))&&(t[c]=s[c])}return t})),Ea=zr((function(t){return t.push(o,Qo),xe(Oa,o,t)}));function Ta(t,e,n){var r=null==t?o:wr(t,e);return r===o?n:r}function Sa(t,e){return null!=t&&fi(t,e,Sr)}var Ia=ko((function(t,e,n){null!=e&&"function"!=typeof e.toString&&(e=Ft.call(e)),t[e]=n}),Za(nl)),_a=ko((function(t,e,n){null!=e&&"function"!=typeof e.toString&&(e=Ft.call(e)),Ot.call(t,e)?t[e].push(n):t[e]=[n]}),si),Na=zr(_r);function Ma(t){return js(t)?Yn(t):Rr(t)}function Pa(t){return js(t)?Yn(t,!0):function(t){if(!Zs(t))return function(t){var e=[];if(null!=t)for(var n in Et(t))e.push(n);return e}(t);var e=wi(t),n=[];for(var r in t)("constructor"!=r||!e&&Ot.call(t,r))&&n.push(r);return n}(t)}var La=Mo((function(t,e,n){kr(t,e,n)})),Oa=Mo((function(t,e,n,r){kr(t,e,n,r)})),Ra=ti((function(t,e){var n={};if(null==t)return n;var r=!1;e=Pe(e,(function(e){return e=yo(e,t),r||(r=e.length>1),e})),_o(t,ni(t),n),r&&(n=sr(n,7,Xo));for(var o=e.length;o--;)lo(n,e[o]);return n})),Da=ti((function(t,e){return null==t?{}:function(t,e){return Ur(t,e,(function(e,n){return Sa(t,n)}))}(t,e)}));function Fa(t,e){if(null==t)return{};var n=Pe(ni(t),(function(t){return[t]}));return e=si(e),Ur(t,n,(function(t,n){return e(t,n[0])}))}var Ba=Yo(Ma),$a=Yo(Pa);function ka(t){return null==t?[]:Je(t,Ma(t))}var Ha=Ro((function(t,e,n){return e=e.toLowerCase(),t+(n?Ga(e):e)}));function Ga(t){return Ka(ya(t).toLowerCase())}function Ua(t){return(t=ya(t))&&t.replace(bt,tn).replace(Qt,"")}var Va=Ro((function(t,e,n){return t+(n?"-":"")+e.toLowerCase()})),qa=Ro((function(t,e,n){return t+(n?" ":"")+e.toLowerCase()})),ja=Oo("toLowerCase"),Wa=Ro((function(t,e,n){return t+(n?"_":"")+e.toLowerCase()})),za=Ro((function(t,e,n){return t+(n?" ":"")+Ka(e)})),Ya=Ro((function(t,e,n){return t+(n?" ":"")+e.toUpperCase()})),Ka=Oo("toUpperCase");function Ja(t,e,n){return t=ya(t),(e=n?o:e)===o?function(t){return ee.test(t)}(t)?function(t){return t.match(Zt)||[]}(t):function(t){return t.match(lt)||[]}(t):t.match(e)||[]}var Qa=zr((function(t,e){try{return xe(t,o,e)}catch(t){return Ks(t)?t:new wt(t)}})),Xa=ti((function(t,e){return Te(e,(function(e){e=Fi(e),rr(t,e,_s(t[e],t))})),t}));function Za(t){return function(){return t}}var tl=Bo(),el=Bo(!0);function nl(t){return t}function rl(t){return Or("function"==typeof t?t:sr(t,1))}var ol=zr((function(t,e){return function(n){return _r(n,t,e)}})),il=zr((function(t,e){return function(n){return _r(t,n,e)}}));function sl(t,e,n){var r=Ma(e),o=Cr(e,r);null!=n||Zs(e)&&(o.length||!r.length)||(n=e,e=t,t=this,o=Cr(e,Ma(e)));var i=!(Zs(n)&&"chain"in n&&!n.chain),s=Js(t);return Te(o,(function(n){var r=e[n];t[n]=r,s&&(t.prototype[n]=function(){var e=this.__chain__;if(i||e){var n=t(this.__wrapped__);return(n.__actions__=Io(this.__actions__)).push({func:r,args:arguments,thisArg:t}),n.__chain__=e,n}return r.apply(t,Le([this.value()],arguments))})})),t}function al(){}var ll=Go(Pe),ul=Go(Ie),cl=Go(De);function hl(t){return bi(t)?Ve(Fi(t)):function(t){return function(e){return wr(e,t)}}(t)}var dl=Vo(),fl=Vo(!0);function pl(){return[]}function ml(){return!1}var gl,yl=Ho((function(t,e){return t+e}),0),bl=Wo("ceil"),vl=Ho((function(t,e){return t/e}),1),Cl=Wo("floor"),wl=Ho((function(t,e){return t*e}),1),Al=Wo("round"),xl=Ho((function(t,e){return t-e}),0);return $n.after=function(t,e){if("function"!=typeof e)throw new It(i);return t=fa(t),function(){if(--t<1)return e.apply(this,arguments)}},$n.ary=Ss,$n.assign=ba,$n.assignIn=va,$n.assignInWith=Ca,$n.assignWith=wa,$n.at=Aa,$n.before=Is,$n.bind=_s,$n.bindAll=Xa,$n.bindKey=Ns,$n.castArray=function(){if(!arguments.length)return[];var t=arguments[0];return Vs(t)?t:[t]},$n.chain=hs,$n.chunk=function(t,e,n){e=(n?yi(t,e,n):e===o)?1:gn(fa(e),0);var i=null==t?0:t.length;if(!i||e<1)return[];for(var s=0,a=0,l=r(de(i/e));s<i;)l[a++]=to(t,s,s+=e);return l},$n.compact=function(t){for(var e=-1,n=null==t?0:t.length,r=0,o=[];++e<n;){var i=t[e];i&&(o[r++]=i)}return o},$n.concat=function(){var t=arguments.length;if(!t)return[];for(var e=r(t-1),n=arguments[0],o=t;o--;)e[o-1]=arguments[o];return Le(Vs(n)?Io(n):[n],mr(e,1))},$n.cond=function(t){var e=null==t?0:t.length,n=si();return t=e?Pe(t,(function(t){if("function"!=typeof t[1])throw new It(i);return[n(t[0]),t[1]]})):[],zr((function(n){for(var r=-1;++r<e;){var o=t[r];if(xe(o[0],this,n))return xe(o[1],this,n)}}))},$n.conforms=function(t){return function(t){var e=Ma(t);return function(n){return ar(n,t,e)}}(sr(t,1))},$n.constant=Za,$n.countBy=ps,$n.create=function(t,e){var n=kn(t);return null==e?n:nr(n,e)},$n.curry=function t(e,n,r){var i=Ko(e,8,o,o,o,o,o,n=r?o:n);return i.placeholder=t.placeholder,i},$n.curryRight=function t(e,n,r){var i=Ko(e,16,o,o,o,o,o,n=r?o:n);return i.placeholder=t.placeholder,i},$n.debounce=Ms,$n.defaults=xa,$n.defaultsDeep=Ea,$n.defer=Ps,$n.delay=Ls,$n.difference=ki,$n.differenceBy=Hi,$n.differenceWith=Gi,$n.drop=function(t,e,n){var r=null==t?0:t.length;return r?to(t,(e=n||e===o?1:fa(e))<0?0:e,r):[]},$n.dropRight=function(t,e,n){var r=null==t?0:t.length;return r?to(t,0,(e=r-(e=n||e===o?1:fa(e)))<0?0:e):[]},$n.dropRightWhile=function(t,e){return t&&t.length?co(t,si(e,3),!0,!0):[]},$n.dropWhile=function(t,e){return t&&t.length?co(t,si(e,3),!0):[]},$n.fill=function(t,e,n,r){var i=null==t?0:t.length;return i?(n&&"number"!=typeof n&&yi(t,e,n)&&(n=0,r=i),function(t,e,n,r){var i=t.length;for((n=fa(n))<0&&(n=-n>i?0:i+n),(r=r===o||r>i?i:fa(r))<0&&(r+=i),r=n>r?0:pa(r);n<r;)t[n++]=e;return t}(t,e,n,r)):[]},$n.filter=function(t,e){return(Vs(t)?_e:pr)(t,si(e,3))},$n.flatMap=function(t,e){return mr(As(t,e),1)},$n.flatMapDeep=function(t,e){return mr(As(t,e),c)},$n.flatMapDepth=function(t,e,n){return n=n===o?1:fa(n),mr(As(t,e),n)},$n.flatten=qi,$n.flattenDeep=function(t){return null!=t&&t.length?mr(t,c):[]},$n.flattenDepth=function(t,e){return null!=t&&t.length?mr(t,e=e===o?1:fa(e)):[]},$n.flip=function(t){return Ko(t,512)},$n.flow=tl,$n.flowRight=el,$n.fromPairs=function(t){for(var e=-1,n=null==t?0:t.length,r={};++e<n;){var o=t[e];r[o[0]]=o[1]}return r},$n.functions=function(t){return null==t?[]:Cr(t,Ma(t))},$n.functionsIn=function(t){return null==t?[]:Cr(t,Pa(t))},$n.groupBy=vs,$n.initial=function(t){return null!=t&&t.length?to(t,0,-1):[]},$n.intersection=Wi,$n.intersectionBy=zi,$n.intersectionWith=Yi,$n.invert=Ia,$n.invertBy=_a,$n.invokeMap=Cs,$n.iteratee=rl,$n.keyBy=ws,$n.keys=Ma,$n.keysIn=Pa,$n.map=As,$n.mapKeys=function(t,e){var n={};return e=si(e,3),br(t,(function(t,r,o){rr(n,e(t,r,o),t)})),n},$n.mapValues=function(t,e){var n={};return e=si(e,3),br(t,(function(t,r,o){rr(n,r,e(t,r,o))})),n},$n.matches=function(t){return Br(sr(t,1))},$n.matchesProperty=function(t,e){return $r(t,sr(e,1))},$n.memoize=Os,$n.merge=La,$n.mergeWith=Oa,$n.method=ol,$n.methodOf=il,$n.mixin=sl,$n.negate=Rs,$n.nthArg=function(t){return t=fa(t),zr((function(e){return Hr(e,t)}))},$n.omit=Ra,$n.omitBy=function(t,e){return Fa(t,Rs(si(e)))},$n.once=function(t){return Is(2,t)},$n.orderBy=function(t,e,n,r){return null==t?[]:(Vs(e)||(e=null==e?[]:[e]),Vs(n=r?o:n)||(n=null==n?[]:[n]),Gr(t,e,n))},$n.over=ll,$n.overArgs=Ds,$n.overEvery=ul,$n.overSome=cl,$n.partial=Fs,$n.partialRight=Bs,$n.partition=xs,$n.pick=Da,$n.pickBy=Fa,$n.property=hl,$n.propertyOf=function(t){return function(e){return null==t?o:wr(t,e)}},$n.pull=Ji,$n.pullAll=Qi,$n.pullAllBy=function(t,e,n){return t&&t.length&&e&&e.length?Vr(t,e,si(n,2)):t},$n.pullAllWith=function(t,e,n){return t&&t.length&&e&&e.length?Vr(t,e,o,n):t},$n.pullAt=Xi,$n.range=dl,$n.rangeRight=fl,$n.rearg=$s,$n.reject=function(t,e){return(Vs(t)?_e:pr)(t,Rs(si(e,3)))},$n.remove=function(t,e){var n=[];if(!t||!t.length)return n;var r=-1,o=[],i=t.length;for(e=si(e,3);++r<i;){var s=t[r];e(s,r,t)&&(n.push(s),o.push(r))}return qr(t,o),n},$n.rest=function(t,e){if("function"!=typeof t)throw new It(i);return zr(t,e=e===o?e:fa(e))},$n.reverse=Zi,$n.sampleSize=function(t,e,n){return e=(n?yi(t,e,n):e===o)?1:fa(e),(Vs(t)?Jn:Kr)(t,e)},$n.set=function(t,e,n){return null==t?t:Jr(t,e,n)},$n.setWith=function(t,e,n,r){return r="function"==typeof r?r:o,null==t?t:Jr(t,e,n,r)},$n.shuffle=function(t){return(Vs(t)?Qn:Zr)(t)},$n.slice=function(t,e,n){var r=null==t?0:t.length;return r?(n&&"number"!=typeof n&&yi(t,e,n)?(e=0,n=r):(e=null==e?0:fa(e),n=n===o?r:fa(n)),to(t,e,n)):[]},$n.sortBy=Es,$n.sortedUniq=function(t){return t&&t.length?oo(t):[]},$n.sortedUniqBy=function(t,e){return t&&t.length?oo(t,si(e,2)):[]},$n.split=function(t,e,n){return n&&"number"!=typeof n&&yi(t,e,n)&&(e=n=o),(n=n===o?f:n>>>0)?(t=ya(t))&&("string"==typeof e||null!=e&&!oa(e))&&!(e=so(e))&&rn(t)?vo(hn(t),0,n):t.split(e,n):[]},$n.spread=function(t,e){if("function"!=typeof t)throw new It(i);return e=null==e?0:gn(fa(e),0),zr((function(n){var r=n[e],o=vo(n,0,e);return r&&Le(o,r),xe(t,this,o)}))},$n.tail=function(t){var e=null==t?0:t.length;return e?to(t,1,e):[]},$n.take=function(t,e,n){return t&&t.length?to(t,0,(e=n||e===o?1:fa(e))<0?0:e):[]},$n.takeRight=function(t,e,n){var r=null==t?0:t.length;return r?to(t,(e=r-(e=n||e===o?1:fa(e)))<0?0:e,r):[]},$n.takeRightWhile=function(t,e){return t&&t.length?co(t,si(e,3),!1,!0):[]},$n.takeWhile=function(t,e){return t&&t.length?co(t,si(e,3)):[]},$n.tap=function(t,e){return e(t),t},$n.throttle=function(t,e,n){var r=!0,o=!0;if("function"!=typeof t)throw new It(i);return Zs(n)&&(r="leading"in n?!!n.leading:r,o="trailing"in n?!!n.trailing:o),Ms(t,e,{leading:r,maxWait:e,trailing:o})},$n.thru=ds,$n.toArray=ha,$n.toPairs=Ba,$n.toPairsIn=$a,$n.toPath=function(t){return Vs(t)?Pe(t,Fi):aa(t)?[t]:Io(Di(ya(t)))},$n.toPlainObject=ga,$n.transform=function(t,e,n){var r=Vs(t),o=r||zs(t)||la(t);if(e=si(e,4),null==n){var i=t&&t.constructor;n=o?r?new i:[]:Zs(t)&&Js(i)?kn(qt(t)):{}}return(o?Te:br)(t,(function(t,r,o){return e(n,t,r,o)})),n},$n.unary=function(t){return Ss(t,1)},$n.union=ts,$n.unionBy=es,$n.unionWith=ns,$n.uniq=function(t){return t&&t.length?ao(t):[]},$n.uniqBy=function(t,e){return t&&t.length?ao(t,si(e,2)):[]},$n.uniqWith=function(t,e){return e="function"==typeof e?e:o,t&&t.length?ao(t,o,e):[]},$n.unset=function(t,e){return null==t||lo(t,e)},$n.unzip=rs,$n.unzipWith=os,$n.update=function(t,e,n){return null==t?t:uo(t,e,go(n))},$n.updateWith=function(t,e,n,r){return r="function"==typeof r?r:o,null==t?t:uo(t,e,go(n),r)},$n.values=ka,$n.valuesIn=function(t){return null==t?[]:Je(t,Pa(t))},$n.without=is,$n.words=Ja,$n.wrap=function(t,e){return Fs(go(e),t)},$n.xor=ss,$n.xorBy=as,$n.xorWith=ls,$n.zip=us,$n.zipObject=function(t,e){return po(t||[],e||[],Zn)},$n.zipObjectDeep=function(t,e){return po(t||[],e||[],Jr)},$n.zipWith=cs,$n.entries=Ba,$n.entriesIn=$a,$n.extend=va,$n.extendWith=Ca,sl($n,$n),$n.add=yl,$n.attempt=Qa,$n.camelCase=Ha,$n.capitalize=Ga,$n.ceil=bl,$n.clamp=function(t,e,n){return n===o&&(n=e,e=o),n!==o&&(n=(n=ma(n))==n?n:0),e!==o&&(e=(e=ma(e))==e?e:0),ir(ma(t),e,n)},$n.clone=function(t){return sr(t,4)},$n.cloneDeep=function(t){return sr(t,5)},$n.cloneDeepWith=function(t,e){return sr(t,5,e="function"==typeof e?e:o)},$n.cloneWith=function(t,e){return sr(t,4,e="function"==typeof e?e:o)},$n.conformsTo=function(t,e){return null==e||ar(t,e,Ma(e))},$n.deburr=Ua,$n.defaultTo=function(t,e){return null==t||t!=t?e:t},$n.divide=vl,$n.endsWith=function(t,e,n){t=ya(t),e=so(e);var r=t.length,i=n=n===o?r:ir(fa(n),0,r);return(n-=e.length)>=0&&t.slice(n,i)==e},$n.eq=ks,$n.escape=function(t){return(t=ya(t))&&Y.test(t)?t.replace(W,en):t},$n.escapeRegExp=function(t){return(t=ya(t))&&nt.test(t)?t.replace(et,"\\$&"):t},$n.every=function(t,e,n){var r=Vs(t)?Ie:dr;return n&&yi(t,e,n)&&(e=o),r(t,si(e,3))},$n.find=ms,$n.findIndex=Ui,$n.findKey=function(t,e){return Be(t,si(e,3),br)},$n.findLast=gs,$n.findLastIndex=Vi,$n.findLastKey=function(t,e){return Be(t,si(e,3),vr)},$n.floor=Cl,$n.forEach=ys,$n.forEachRight=bs,$n.forIn=function(t,e){return null==t?t:gr(t,si(e,3),Pa)},$n.forInRight=function(t,e){return null==t?t:yr(t,si(e,3),Pa)},$n.forOwn=function(t,e){return t&&br(t,si(e,3))},$n.forOwnRight=function(t,e){return t&&vr(t,si(e,3))},$n.get=Ta,$n.gt=Hs,$n.gte=Gs,$n.has=function(t,e){return null!=t&&fi(t,e,Tr)},$n.hasIn=Sa,$n.head=ji,$n.identity=nl,$n.includes=function(t,e,n,r){t=js(t)?t:ka(t),n=n&&!r?fa(n):0;var o=t.length;return n<0&&(n=gn(o+n,0)),sa(t)?n<=o&&t.indexOf(e,n)>-1:!!o&&ke(t,e,n)>-1},$n.indexOf=function(t,e,n){var r=null==t?0:t.length;if(!r)return-1;var o=null==n?0:fa(n);return o<0&&(o=gn(r+o,0)),ke(t,e,o)},$n.inRange=function(t,e,n){return e=da(e),n===o?(n=e,e=0):n=da(n),function(t,e,n){return t>=yn(e,n)&&t<gn(e,n)}(t=ma(t),e,n)},$n.invoke=Na,$n.isArguments=Us,$n.isArray=Vs,$n.isArrayBuffer=qs,$n.isArrayLike=js,$n.isArrayLikeObject=Ws,$n.isBoolean=function(t){return!0===t||!1===t||ta(t)&&xr(t)==y},$n.isBuffer=zs,$n.isDate=Ys,$n.isElement=function(t){return ta(t)&&1===t.nodeType&&!ra(t)},$n.isEmpty=function(t){if(null==t)return!0;if(js(t)&&(Vs(t)||"string"==typeof t||"function"==typeof t.splice||zs(t)||la(t)||Us(t)))return!t.length;var e=di(t);if(e==A||e==I)return!t.size;if(wi(t))return!Rr(t).length;for(var n in t)if(Ot.call(t,n))return!1;return!0},$n.isEqual=function(t,e){return Mr(t,e)},$n.isEqualWith=function(t,e,n){var r=(n="function"==typeof n?n:o)?n(t,e):o;return r===o?Mr(t,e,o,n):!!r},$n.isError=Ks,$n.isFinite=function(t){return"number"==typeof t&&Fe(t)},$n.isFunction=Js,$n.isInteger=Qs,$n.isLength=Xs,$n.isMap=ea,$n.isMatch=function(t,e){return t===e||Pr(t,e,li(e))},$n.isMatchWith=function(t,e,n){return n="function"==typeof n?n:o,Pr(t,e,li(e),n)},$n.isNaN=function(t){return na(t)&&t!=+t},$n.isNative=function(t){if(Ci(t))throw new wt("Unsupported core-js use. Try https://npms.io/search?q=ponyfill.");return Lr(t)},$n.isNil=function(t){return null==t},$n.isNull=function(t){return null===t},$n.isNumber=na,$n.isObject=Zs,$n.isObjectLike=ta,$n.isPlainObject=ra,$n.isRegExp=oa,$n.isSafeInteger=function(t){return Qs(t)&&t>=-9007199254740991&&t<=h},$n.isSet=ia,$n.isString=sa,$n.isSymbol=aa,$n.isTypedArray=la,$n.isUndefined=function(t){return t===o},$n.isWeakMap=function(t){return ta(t)&&di(t)==M},$n.isWeakSet=function(t){return ta(t)&&"[object WeakSet]"==xr(t)},$n.join=function(t,e){return null==t?"":qe.call(t,e)},$n.kebabCase=Va,$n.last=Ki,$n.lastIndexOf=function(t,e,n){var r=null==t?0:t.length;if(!r)return-1;var i=r;return n!==o&&(i=(i=fa(n))<0?gn(r+i,0):yn(i,r-1)),e==e?function(t,e,n){for(var r=n+1;r--;)if(t[r]===e)return r;return r}(t,e,i):$e(t,Ge,i,!0)},$n.lowerCase=qa,$n.lowerFirst=ja,$n.lt=ua,$n.lte=ca,$n.max=function(t){return t&&t.length?fr(t,nl,Er):o},$n.maxBy=function(t,e){return t&&t.length?fr(t,si(e,2),Er):o},$n.mean=function(t){return Ue(t,nl)},$n.meanBy=function(t,e){return Ue(t,si(e,2))},$n.min=function(t){return t&&t.length?fr(t,nl,Dr):o},$n.minBy=function(t,e){return t&&t.length?fr(t,si(e,2),Dr):o},$n.stubArray=pl,$n.stubFalse=ml,$n.stubObject=function(){return{}},$n.stubString=function(){return""},$n.stubTrue=function(){return!0},$n.multiply=wl,$n.nth=function(t,e){return t&&t.length?Hr(t,fa(e)):o},$n.noConflict=function(){return he._===this&&(he._=$t),this},$n.noop=al,$n.now=Ts,$n.pad=function(t,e,n){t=ya(t);var r=(e=fa(e))?cn(t):0;if(!e||r>=e)return t;var o=(e-r)/2;return Uo(fe(o),n)+t+Uo(de(o),n)},$n.padEnd=function(t,e,n){t=ya(t);var r=(e=fa(e))?cn(t):0;return e&&r<e?t+Uo(e-r,n):t},$n.padStart=function(t,e,n){t=ya(t);var r=(e=fa(e))?cn(t):0;return e&&r<e?Uo(e-r,n)+t:t},$n.parseInt=function(t,e,n){return n||null==e?e=0:e&&(e=+e),vn(ya(t).replace(rt,""),e||0)},$n.random=function(t,e,n){if(n&&"boolean"!=typeof n&&yi(t,e,n)&&(e=n=o),n===o&&("boolean"==typeof e?(n=e,e=o):"boolean"==typeof t&&(n=t,t=o)),t===o&&e===o?(t=0,e=1):(t=da(t),e===o?(e=t,t=0):e=da(e)),t>e){var r=t;t=e,e=r}if(n||t%1||e%1){var i=Cn();return yn(t+i*(e-t+ae("1e-"+((i+"").length-1))),e)}return jr(t,e)},$n.reduce=function(t,e,n){var r=Vs(t)?Oe:je,o=arguments.length<3;return r(t,si(e,4),n,o,cr)},$n.reduceRight=function(t,e,n){var r=Vs(t)?Re:je,o=arguments.length<3;return r(t,si(e,4),n,o,hr)},$n.repeat=function(t,e,n){return e=(n?yi(t,e,n):e===o)?1:fa(e),Wr(ya(t),e)},$n.replace=function(){var t=arguments,e=ya(t[0]);return t.length<3?e:e.replace(t[1],t[2])},$n.result=function(t,e,n){var r=-1,i=(e=yo(e,t)).length;for(i||(i=1,t=o);++r<i;){var s=null==t?o:t[Fi(e[r])];s===o&&(r=i,s=n),t=Js(s)?s.call(t):s}return t},$n.round=Al,$n.runInContext=t,$n.sample=function(t){return(Vs(t)?Kn:Yr)(t)},$n.size=function(t){if(null==t)return 0;if(js(t))return sa(t)?cn(t):t.length;var e=di(t);return e==A||e==I?t.size:Rr(t).length},$n.snakeCase=Wa,$n.some=function(t,e,n){var r=Vs(t)?De:eo;return n&&yi(t,e,n)&&(e=o),r(t,si(e,3))},$n.sortedIndex=function(t,e){return no(t,e)},$n.sortedIndexBy=function(t,e,n){return ro(t,e,si(n,2))},$n.sortedIndexOf=function(t,e){var n=null==t?0:t.length;if(n){var r=no(t,e);if(r<n&&ks(t[r],e))return r}return-1},$n.sortedLastIndex=function(t,e){return no(t,e,!0)},$n.sortedLastIndexBy=function(t,e,n){return ro(t,e,si(n,2),!0)},$n.sortedLastIndexOf=function(t,e){if(null!=t&&t.length){var n=no(t,e,!0)-1;if(ks(t[n],e))return n}return-1},$n.startCase=za,$n.startsWith=function(t,e,n){return t=ya(t),n=null==n?0:ir(fa(n),0,t.length),e=so(e),t.slice(n,n+e.length)==e},$n.subtract=xl,$n.sum=function(t){return t&&t.length?We(t,nl):0},$n.sumBy=function(t,e){return t&&t.length?We(t,si(e,2)):0},$n.template=function(t,e,n){var r=$n.templateSettings;n&&yi(t,e,n)&&(e=o),t=ya(t),e=Ca({},e,r,Jo);var i,s,a=Ca({},e.imports,r.imports,Jo),l=Ma(a),u=Je(a,l),c=0,h=e.interpolate||vt,d="__p += '",f=Tt((e.escape||vt).source+"|"+h.source+"|"+(h===Q?ht:vt).source+"|"+(e.evaluate||vt).source+"|$","g"),p="//# sourceURL="+(Ot.call(e,"sourceURL")?(e.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++re+"]")+"\n";t.replace(f,(function(e,n,r,o,a,l){return r||(r=o),d+=t.slice(c,l).replace(Ct,nn),n&&(i=!0,d+="' +\n__e("+n+") +\n'"),a&&(s=!0,d+="';\n"+a+";\n__p += '"),r&&(d+="' +\n((__t = ("+r+")) == null ? '' : __t) +\n'"),c=l+e.length,e})),d+="';\n";var m=Ot.call(e,"variable")&&e.variable;if(m){if(ut.test(m))throw new wt("Invalid `variable` option passed into `_.template`")}else d="with (obj) {\n"+d+"\n}\n";d=(s?d.replace(U,""):d).replace(V,"$1").replace(q,"$1;"),d="function("+(m||"obj")+") {\n"+(m?"":"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=Qa((function(){return At(l,p+"return "+d).apply(o,u)}));if(g.source=d,Ks(g))throw g;return g},$n.times=function(t,e){if((t=fa(t))<1||t>h)return[];var n=f,r=yn(t,f);e=si(e),t-=f;for(var o=ze(r,e);++n<t;)e(n);return o},$n.toFinite=da,$n.toInteger=fa,$n.toLength=pa,$n.toLower=function(t){return ya(t).toLowerCase()},$n.toNumber=ma,$n.toSafeInteger=function(t){return t?ir(fa(t),-9007199254740991,h):0===t?t:0},$n.toString=ya,$n.toUpper=function(t){return ya(t).toUpperCase()},$n.trim=function(t,e,n){if((t=ya(t))&&(n||e===o))return Ye(t);if(!t||!(e=so(e)))return t;var r=hn(t),i=hn(e);return vo(r,Xe(r,i),Ze(r,i)+1).join("")},$n.trimEnd=function(t,e,n){if((t=ya(t))&&(n||e===o))return t.slice(0,dn(t)+1);if(!t||!(e=so(e)))return t;var r=hn(t);return vo(r,0,Ze(r,hn(e))+1).join("")},$n.trimStart=function(t,e,n){if((t=ya(t))&&(n||e===o))return t.replace(rt,"");if(!t||!(e=so(e)))return t;var r=hn(t);return vo(r,Xe(r,hn(e))).join("")},$n.truncate=function(t,e){var n=30,r="...";if(Zs(e)){var i="separator"in e?e.separator:i;n="length"in e?fa(e.length):n,r="omission"in e?so(e.omission):r}var s=(t=ya(t)).length;if(rn(t)){var a=hn(t);s=a.length}if(n>=s)return t;var l=n-cn(r);if(l<1)return r;var u=a?vo(a,0,l).join(""):t.slice(0,l);if(i===o)return u+r;if(a&&(l+=u.length-l),oa(i)){if(t.slice(l).search(i)){var c,h=u;for(i.global||(i=Tt(i.source,ya(dt.exec(i))+"g")),i.lastIndex=0;c=i.exec(h);)var d=c.index;u=u.slice(0,d===o?l:d)}}else if(t.indexOf(so(i),l)!=l){var f=u.lastIndexOf(i);f>-1&&(u=u.slice(0,f))}return u+r},$n.unescape=function(t){return(t=ya(t))&&z.test(t)?t.replace(j,fn):t},$n.uniqueId=function(t){var e=++Rt;return ya(t)+e},$n.upperCase=Ya,$n.upperFirst=Ka,$n.each=ys,$n.eachRight=bs,$n.first=ji,sl($n,(gl={},br($n,(function(t,e){Ot.call($n.prototype,e)||(gl[e]=t)})),gl),{chain:!1}),$n.VERSION="4.17.21",Te(["bind","bindKey","curry","curryRight","partial","partialRight"],(function(t){$n[t].placeholder=$n})),Te(["drop","take"],(function(t,e){Un.prototype[t]=function(n){n=n===o?1:gn(fa(n),0);var r=this.__filtered__&&!e?new Un(this):this.clone();return r.__filtered__?r.__takeCount__=yn(n,r.__takeCount__):r.__views__.push({size:yn(n,f),type:t+(r.__dir__<0?"Right":"")}),r},Un.prototype[t+"Right"]=function(e){return this.reverse()[t](e).reverse()}})),Te(["filter","map","takeWhile"],(function(t,e){var n=e+1,r=1==n||3==n;Un.prototype[t]=function(t){var e=this.clone();return e.__iteratees__.push({iteratee:si(t,3),type:n}),e.__filtered__=e.__filtered__||r,e}})),Te(["head","last"],(function(t,e){var n="take"+(e?"Right":"");Un.prototype[t]=function(){return this[n](1).value()[0]}})),Te(["initial","tail"],(function(t,e){var n="drop"+(e?"":"Right");Un.prototype[t]=function(){return this.__filtered__?new Un(this):this[n](1)}})),Un.prototype.compact=function(){return this.filter(nl)},Un.prototype.find=function(t){return this.filter(t).head()},Un.prototype.findLast=function(t){return this.reverse().find(t)},Un.prototype.invokeMap=zr((function(t,e){return"function"==typeof t?new Un(this):this.map((function(n){return _r(n,t,e)}))})),Un.prototype.reject=function(t){return this.filter(Rs(si(t)))},Un.prototype.slice=function(t,e){t=fa(t);var n=this;return n.__filtered__&&(t>0||e<0)?new Un(n):(t<0?n=n.takeRight(-t):t&&(n=n.drop(t)),e!==o&&(n=(e=fa(e))<0?n.dropRight(-e):n.take(e-t)),n)},Un.prototype.takeRightWhile=function(t){return this.reverse().takeWhile(t).reverse()},Un.prototype.toArray=function(){return this.take(f)},br(Un.prototype,(function(t,e){var n=/^(?:filter|find|map|reject)|While$/.test(e),r=/^(?:head|last)$/.test(e),i=$n[r?"take"+("last"==e?"Right":""):e],s=r||/^find/.test(e);i&&($n.prototype[e]=function(){var e=this.__wrapped__,a=r?[1]:arguments,l=e instanceof Un,u=a[0],c=l||Vs(e),h=function(t){var e=i.apply($n,Le([t],a));return r&&d?e[0]:e};c&&n&&"function"==typeof u&&1!=u.length&&(l=c=!1);var d=this.__chain__,f=!!this.__actions__.length,p=s&&!d,m=l&&!f;if(!s&&c){e=m?e:new Un(this);var g=t.apply(e,a);return g.__actions__.push({func:ds,args:[h],thisArg:o}),new Gn(g,d)}return p&&m?t.apply(this,a):(g=this.thru(h),p?r?g.value()[0]:g.value():g)})})),Te(["pop","push","shift","sort","splice","unshift"],(function(t){var e=_t[t],n=/^(?:push|sort|unshift)$/.test(t)?"tap":"thru",r=/^(?:pop|shift)$/.test(t);$n.prototype[t]=function(){var t=arguments;if(r&&!this.__chain__){var o=this.value();return e.apply(Vs(o)?o:[],t)}return this[n]((function(n){return e.apply(Vs(n)?n:[],t)}))}})),br(Un.prototype,(function(t,e){var n=$n[e];if(n){var r=n.name+"";Ot.call(Nn,r)||(Nn[r]=[]),Nn[r].push({name:e,func:n})}})),Nn[$o(o,2).name]=[{name:"wrapper",func:o}],Un.prototype.clone=function(){var t=new Un(this.__wrapped__);return t.__actions__=Io(this.__actions__),t.__dir__=this.__dir__,t.__filtered__=this.__filtered__,t.__iteratees__=Io(this.__iteratees__),t.__takeCount__=this.__takeCount__,t.__views__=Io(this.__views__),t},Un.prototype.reverse=function(){if(this.__filtered__){var t=new Un(this);t.__dir__=-1,t.__filtered__=!0}else(t=this.clone()).__dir__*=-1;return t},Un.prototype.value=function(){var t=this.__wrapped__.value(),e=this.__dir__,n=Vs(t),r=e<0,o=n?t.length:0,i=function(t,e,n){for(var r=-1,o=n.length;++r<o;){var i=n[r],s=i.size;switch(i.type){case"drop":t+=s;break;case"dropRight":e-=s;break;case"take":e=yn(e,t+s);break;case"takeRight":t=gn(t,e-s)}}return{start:t,end:e}}(0,o,this.__views__),s=i.start,a=i.end,l=a-s,u=r?a:s-1,c=this.__iteratees__,h=c.length,d=0,f=yn(l,this.__takeCount__);if(!n||!r&&o==l&&f==l)return ho(t,this.__actions__);var p=[];t:for(;l--&&d<f;){for(var m=-1,g=t[u+=e];++m<h;){var y=c[m],b=y.iteratee,v=y.type,C=b(g);if(2==v)g=C;else if(!C){if(1==v)continue t;break t}}p[d++]=g}return p},$n.prototype.at=fs,$n.prototype.chain=function(){return hs(this)},$n.prototype.commit=function(){return new Gn(this.value(),this.__chain__)},$n.prototype.next=function(){this.__values__===o&&(this.__values__=ha(this.value()));var t=this.__index__>=this.__values__.length;return{done:t,value:t?o:this.__values__[this.__index__++]}},$n.prototype.plant=function(t){for(var e,n=this;n instanceof Hn;){var r=$i(n);r.__index__=0,r.__values__=o,e?i.__wrapped__=r:e=r;var i=r;n=n.__wrapped__}return i.__wrapped__=t,e},$n.prototype.reverse=function(){var t=this.__wrapped__;if(t instanceof Un){var e=t;return this.__actions__.length&&(e=new Un(this)),(e=e.reverse()).__actions__.push({func:ds,args:[Zi],thisArg:o}),new Gn(e,this.__chain__)}return this.thru(Zi)},$n.prototype.toJSON=$n.prototype.valueOf=$n.prototype.value=function(){return ho(this.__wrapped__,this.__actions__)},$n.prototype.first=$n.prototype.head,Kt&&($n.prototype[Kt]=function(){return this}),$n}();he._=pn,(r=function(){return pn}.call(e,n,e,t))===o||(t.exports=r)}.call(this)},4802:t=>{t.exports=function t(e,n,r){function o(s,a){if(!n[s]){if(!e[s]){if(i)return i(s,!0);throw new Error("Cannot find module '"+s+"'")}a=n[s]={exports:{}},e[s][0].call(a.exports,(function(t){return o(e[s][1][t]||t)}),a,a.exports,t,e,n,r)}return n[s].exports}for(var i=void 0,s=0;s<r.length;s++)o(r[s]);return o}({1:[function(t,e,n){(function(r,o,i,s,a,l,u,c,h){"use strict";var d=t("crypto");function f(t,e){var n;return void 0===(n="passthrough"!==(e=g(t,e)).algorithm?d.createHash(e.algorithm):new v).write&&(n.write=n.update,n.end=n.update),b(e,n).dispatch(t),n.update||n.end(""),n.digest?n.digest("buffer"===e.encoding?void 0:e.encoding):(t=n.read(),"buffer"!==e.encoding?t.toString(e.encoding):t)}(n=e.exports=f).sha1=function(t){return f(t)},n.keys=function(t){return f(t,{excludeValues:!0,algorithm:"sha1",encoding:"hex"})},n.MD5=function(t){return f(t,{algorithm:"md5",encoding:"hex"})},n.keysMD5=function(t){return f(t,{algorithm:"md5",encoding:"hex",excludeValues:!0})};var p=d.getHashes?d.getHashes().slice():["sha1","md5"],m=(p.push("passthrough"),["buffer","hex","binary","base64"]);function g(t,e){var n={};if(n.algorithm=(e=e||{}).algorithm||"sha1",n.encoding=e.encoding||"hex",n.excludeValues=!!e.excludeValues,n.algorithm=n.algorithm.toLowerCase(),n.encoding=n.encoding.toLowerCase(),n.ignoreUnknown=!0===e.ignoreUnknown,n.respectType=!1!==e.respectType,n.respectFunctionNames=!1!==e.respectFunctionNames,n.respectFunctionProperties=!1!==e.respectFunctionProperties,n.unorderedArrays=!0===e.unorderedArrays,n.unorderedSets=!1!==e.unorderedSets,n.unorderedObjects=!1!==e.unorderedObjects,n.replacer=e.replacer||void 0,n.excludeKeys=e.excludeKeys||void 0,void 0===t)throw new Error("Object argument required.");for(var r=0;r<p.length;++r)p[r].toLowerCase()===n.algorithm.toLowerCase()&&(n.algorithm=p[r]);if(-1===p.indexOf(n.algorithm))throw new Error('Algorithm "'+n.algorithm+'" not supported. supported values: '+p.join(", "));if(-1===m.indexOf(n.encoding)&&"passthrough"!==n.algorithm)throw new Error('Encoding "'+n.encoding+'" not supported. supported values: '+m.join(", "));return n}function y(t){if("function"==typeof t)return null!=/^function\s+\w*\s*\(\s*\)\s*{\s+\[native code\]\s+}$/i.exec(Function.prototype.toString.call(t))}function b(t,e,n){function r(t){return e.update?e.update(t,"utf8"):e.write(t,"utf8")}return n=n||[],{dispatch:function(e){return this["_"+(null===(e=t.replacer?t.replacer(e):e)?"null":typeof e)](e)},_object:function(e){var o,s=Object.prototype.toString.call(e),a=/\[object (.*)\]/i.exec(s);if(a=(a=a?a[1]:"unknown:["+s+"]").toLowerCase(),0<=(s=n.indexOf(e)))return this.dispatch("[CIRCULAR:"+s+"]");if(n.push(e),void 0!==i&&i.isBuffer&&i.isBuffer(e))return r("buffer:"),r(e);if("object"===a||"function"===a||"asyncfunction"===a)return s=Object.keys(e),t.unorderedObjects&&(s=s.sort()),!1===t.respectType||y(e)||s.splice(0,0,"prototype","__proto__","constructor"),t.excludeKeys&&(s=s.filter((function(e){return!t.excludeKeys(e)}))),r("object:"+s.length+":"),o=this,s.forEach((function(n){o.dispatch(n),r(":"),t.excludeValues||o.dispatch(e[n]),r(",")}));if(!this["_"+a]){if(t.ignoreUnknown)return r("["+a+"]");throw new Error('Unknown object type "'+a+'"')}this["_"+a](e)},_array:function(e,o){o=void 0!==o?o:!1!==t.unorderedArrays;var i=this;if(r("array:"+e.length+":"),!o||e.length<=1)return e.forEach((function(t){return i.dispatch(t)}));var s=[];return o=e.map((function(e){var r=new v,o=n.slice();return b(t,r,o).dispatch(e),s=s.concat(o.slice(n.length)),r.read().toString()})),n=n.concat(s),o.sort(),this._array(o,!1)},_date:function(t){return r("date:"+t.toJSON())},_symbol:function(t){return r("symbol:"+t.toString())},_error:function(t){return r("error:"+t.toString())},_boolean:function(t){return r("bool:"+t.toString())},_string:function(t){r("string:"+t.length+":"),r(t.toString())},_function:function(e){r("fn:"),y(e)?this.dispatch("[native]"):this.dispatch(e.toString()),!1!==t.respectFunctionNames&&this.dispatch("function-name:"+String(e.name)),t.respectFunctionProperties&&this._object(e)},_number:function(t){return r("number:"+t.toString())},_xml:function(t){return r("xml:"+t.toString())},_null:function(){return r("Null")},_undefined:function(){return r("Undefined")},_regexp:function(t){return r("regex:"+t.toString())},_uint8array:function(t){return r("uint8array:"),this.dispatch(Array.prototype.slice.call(t))},_uint8clampedarray:function(t){return r("uint8clampedarray:"),this.dispatch(Array.prototype.slice.call(t))},_int8array:function(t){return r("int8array:"),this.dispatch(Array.prototype.slice.call(t))},_uint16array:function(t){return r("uint16array:"),this.dispatch(Array.prototype.slice.call(t))},_int16array:function(t){return r("int16array:"),this.dispatch(Array.prototype.slice.call(t))},_uint32array:function(t){return r("uint32array:"),this.dispatch(Array.prototype.slice.call(t))},_int32array:function(t){return r("int32array:"),this.dispatch(Array.prototype.slice.call(t))},_float32array:function(t){return r("float32array:"),this.dispatch(Array.prototype.slice.call(t))},_float64array:function(t){return r("float64array:"),this.dispatch(Array.prototype.slice.call(t))},_arraybuffer:function(t){return r("arraybuffer:"),this.dispatch(new Uint8Array(t))},_url:function(t){return r("url:"+t.toString())},_map:function(e){return r("map:"),e=Array.from(e),this._array(e,!1!==t.unorderedSets)},_set:function(e){return r("set:"),e=Array.from(e),this._array(e,!1!==t.unorderedSets)},_file:function(t){return r("file:"),this.dispatch([t.name,t.size,t.type,t.lastModfied])},_blob:function(){if(t.ignoreUnknown)return r("[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 r("domwindow")},_bigint:function(t){return r("bigint:"+t.toString())},_process:function(){return r("process")},_timer:function(){return r("timer")},_pipe:function(){return r("pipe")},_tcp:function(){return r("tcp")},_udp:function(){return r("udp")},_tty:function(){return r("tty")},_statwatcher:function(){return r("statwatcher")},_securecontext:function(){return r("securecontext")},_connection:function(){return r("connection")},_zlib:function(){return r("zlib")},_context:function(){return r("context")},_nodescript:function(){return r("nodescript")},_httpparser:function(){return r("httpparser")},_dataview:function(){return r("dataview")},_signal:function(){return r("signal")},_fsevent:function(){return r("fsevent")},_tlswrap:function(){return r("tlswrap")}}}function v(){return{buf:"",write:function(t){this.buf+=t},end:function(t){this.buf+=t},read:function(){return this.buf}}}n.writeToStream=function(t,e,n){return void 0===n&&(n=e,e={}),b(e=g(t,e),n).dispatch(t)}}).call(this,t("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},t("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/fake_9a5aa49d.js","/")},{buffer:3,crypto:5,lYpoI2:11}],2:[function(t,e,n){(function(t,e,r,o,i,s,a,l,u){!function(t){"use strict";var e="undefined"!=typeof Uint8Array?Uint8Array:Array,n="+".charCodeAt(0),r="/".charCodeAt(0),o="0".charCodeAt(0),i="a".charCodeAt(0),s="A".charCodeAt(0),a="-".charCodeAt(0),l="_".charCodeAt(0);function u(t){return(t=t.charCodeAt(0))===n||t===a?62:t===r||t===l?63:t<o?-1:t<o+10?t-o+26+26:t<s+26?t-s:t<i+26?t-i+26:void 0}t.toByteArray=function(t){var n,r;if(0<t.length%4)throw new Error("Invalid string. Length must be a multiple of 4");var o=t.length,i=(o="="===t.charAt(o-2)?2:"="===t.charAt(o-1)?1:0,new e(3*t.length/4-o)),s=0<o?t.length-4:t.length,a=0;function l(t){i[a++]=t}for(n=0;n<s;n+=4,0)l((16711680&(r=u(t.charAt(n))<<18|u(t.charAt(n+1))<<12|u(t.charAt(n+2))<<6|u(t.charAt(n+3))))>>16),l((65280&r)>>8),l(255&r);return 2==o?l(255&(r=u(t.charAt(n))<<2|u(t.charAt(n+1))>>4)):1==o&&(l((r=u(t.charAt(n))<<10|u(t.charAt(n+1))<<4|u(t.charAt(n+2))>>2)>>8&255),l(255&r)),i},t.fromByteArray=function(t){var e,n,r,o,i=t.length%3,s="";function a(t){return"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(t)}for(e=0,r=t.length-i;e<r;e+=3)s+=a((o=n=(t[e]<<16)+(t[e+1]<<8)+t[e+2])>>18&63)+a(o>>12&63)+a(o>>6&63)+a(63&o);switch(i){case 1:s=(s+=a((n=t[t.length-1])>>2))+a(n<<4&63)+"==";break;case 2:s=(s=(s+=a((n=(t[t.length-2]<<8)+t[t.length-1])>>10))+a(n>>4&63))+a(n<<2&63)+"="}return s}}(void 0===n?this.base64js={}:n)}).call(this,t("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},t("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(t,e,n){(function(e,r,o,i,s,a,l,u,c){var h=t("base64-js"),d=t("ieee754");function o(t,e,n){if(!(this instanceof o))return new o(t,e,n);var r,i,s,a,l=typeof t;if("base64"===e&&"string"==l)for(t=(a=t).trim?a.trim():a.replace(/^\s+|\s+$/g,"");t.length%4!=0;)t+="=";if("number"==l)r=I(t);else if("string"==l)r=o.byteLength(t,e);else{if("object"!=l)throw new Error("First argument needs to be a number, array or string.");r=I(t.length)}if(o._useTypedArrays?i=o._augment(new Uint8Array(r)):((i=this).length=r,i._isBuffer=!0),o._useTypedArrays&&"number"==typeof t.byteLength)i._set(t);else if(_(a=t)||o.isBuffer(a)||a&&"object"==typeof a&&"number"==typeof a.length)for(s=0;s<r;s++)o.isBuffer(t)?i[s]=t.readUInt8(s):i[s]=t[s];else if("string"==l)i.write(t,0,e);else if("number"==l&&!o._useTypedArrays&&!n)for(s=0;s<r;s++)i[s]=0;return i}function f(t,e,n,r){var o;if(r||(B("boolean"==typeof n,"missing or invalid endian"),B(null!=e,"missing offset"),B(e+1<t.length,"Trying to read beyond buffer length")),!((r=t.length)<=e))return n?(o=t[e],e+1<r&&(o|=t[e+1]<<8)):(o=t[e]<<8,e+1<r&&(o|=t[e+1])),o}function p(t,e,n,r){var o;if(r||(B("boolean"==typeof n,"missing or invalid endian"),B(null!=e,"missing offset"),B(e+3<t.length,"Trying to read beyond buffer length")),!((r=t.length)<=e))return n?(e+2<r&&(o=t[e+2]<<16),e+1<r&&(o|=t[e+1]<<8),o|=t[e],e+3<r&&(o+=t[e+3]<<24>>>0)):(e+1<r&&(o=t[e+1]<<16),e+2<r&&(o|=t[e+2]<<8),e+3<r&&(o|=t[e+3]),o+=t[e]<<24>>>0),o}function m(t,e,n,r){if(r||(B("boolean"==typeof n,"missing or invalid endian"),B(null!=e,"missing offset"),B(e+1<t.length,"Trying to read beyond buffer length")),!(t.length<=e))return 32768&(r=f(t,e,n,!0))?-1*(65535-r+1):r}function g(t,e,n,r){if(r||(B("boolean"==typeof n,"missing or invalid endian"),B(null!=e,"missing offset"),B(e+3<t.length,"Trying to read beyond buffer length")),!(t.length<=e))return 2147483648&(r=p(t,e,n,!0))?-1*(4294967295-r+1):r}function y(t,e,n,r){return r||(B("boolean"==typeof n,"missing or invalid endian"),B(e+3<t.length,"Trying to read beyond buffer length")),d.read(t,e,n,23,4)}function b(t,e,n,r){return r||(B("boolean"==typeof n,"missing or invalid endian"),B(e+7<t.length,"Trying to read beyond buffer length")),d.read(t,e,n,52,8)}function v(t,e,n,r,o){if(o||(B(null!=e,"missing value"),B("boolean"==typeof r,"missing or invalid endian"),B(null!=n,"missing offset"),B(n+1<t.length,"trying to write beyond buffer length"),R(e,65535)),!((o=t.length)<=n))for(var i=0,s=Math.min(o-n,2);i<s;i++)t[n+i]=(e&255<<8*(r?i:1-i))>>>8*(r?i:1-i)}function C(t,e,n,r,o){if(o||(B(null!=e,"missing value"),B("boolean"==typeof r,"missing or invalid endian"),B(null!=n,"missing offset"),B(n+3<t.length,"trying to write beyond buffer length"),R(e,4294967295)),!((o=t.length)<=n))for(var i=0,s=Math.min(o-n,4);i<s;i++)t[n+i]=e>>>8*(r?i:3-i)&255}function w(t,e,n,r,o){o||(B(null!=e,"missing value"),B("boolean"==typeof r,"missing or invalid endian"),B(null!=n,"missing offset"),B(n+1<t.length,"Trying to write beyond buffer length"),D(e,32767,-32768)),t.length<=n||v(t,0<=e?e:65535+e+1,n,r,o)}function A(t,e,n,r,o){o||(B(null!=e,"missing value"),B("boolean"==typeof r,"missing or invalid endian"),B(null!=n,"missing offset"),B(n+3<t.length,"Trying to write beyond buffer length"),D(e,2147483647,-2147483648)),t.length<=n||C(t,0<=e?e:4294967295+e+1,n,r,o)}function x(t,e,n,r,o){o||(B(null!=e,"missing value"),B("boolean"==typeof r,"missing or invalid endian"),B(null!=n,"missing offset"),B(n+3<t.length,"Trying to write beyond buffer length"),F(e,34028234663852886e22,-34028234663852886e22)),t.length<=n||d.write(t,e,n,r,23,4)}function E(t,e,n,r,o){o||(B(null!=e,"missing value"),B("boolean"==typeof r,"missing or invalid endian"),B(null!=n,"missing offset"),B(n+7<t.length,"Trying to write beyond buffer length"),F(e,17976931348623157e292,-17976931348623157e292)),t.length<=n||d.write(t,e,n,r,52,8)}n.Buffer=o,n.SlowBuffer=o,n.INSPECT_MAX_BYTES=50,o.poolSize=8192,o._useTypedArrays=function(){try{var t=new ArrayBuffer(0),e=new Uint8Array(t);return e.foo=function(){return 42},42===e.foo()&&"function"==typeof e.subarray}catch(t){return!1}}(),o.isEncoding=function(t){switch(String(t).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}},o.isBuffer=function(t){return!(null==t||!t._isBuffer)},o.byteLength=function(t,e){var n;switch(t+="",e||"utf8"){case"hex":n=t.length/2;break;case"utf8":case"utf-8":n=M(t).length;break;case"ascii":case"binary":case"raw":n=t.length;break;case"base64":n=P(t).length;break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":n=2*t.length;break;default:throw new Error("Unknown encoding")}return n},o.concat=function(t,e){if(B(_(t),"Usage: Buffer.concat(list, [totalLength])\nlist should be an Array."),0===t.length)return new o(0);if(1===t.length)return t[0];if("number"!=typeof e)for(i=e=0;i<t.length;i++)e+=t[i].length;for(var n=new o(e),r=0,i=0;i<t.length;i++){var s=t[i];s.copy(n,r),r+=s.length}return n},o.prototype.write=function(t,e,n,r){isFinite(e)?isFinite(n)||(r=n,n=void 0):(u=r,r=e,e=n,n=u),e=Number(e)||0;var i,s,a,l,u=this.length-e;switch((!n||u<(n=Number(n)))&&(n=u),r=String(r||"utf8").toLowerCase()){case"hex":i=function(t,e,n,r){n=Number(n)||0;var i=t.length-n;(!r||i<(r=Number(r)))&&(r=i),B((i=e.length)%2==0,"Invalid hex string"),i/2<r&&(r=i/2);for(var s=0;s<r;s++){var a=parseInt(e.substr(2*s,2),16);B(!isNaN(a),"Invalid hex string"),t[n+s]=a}return o._charsWritten=2*s,s}(this,t,e,n);break;case"utf8":case"utf-8":s=this,a=e,l=n,i=o._charsWritten=L(M(t),s,a,l);break;case"ascii":case"binary":i=function(t,e,n,r){return o._charsWritten=L(function(t){for(var e=[],n=0;n<t.length;n++)e.push(255&t.charCodeAt(n));return e}(e),t,n,r)}(this,t,e,n);break;case"base64":s=this,a=e,l=n,i=o._charsWritten=L(P(t),s,a,l);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":i=function(t,e,n,r){return o._charsWritten=L(function(t){for(var e,n,r=[],o=0;o<t.length;o++)e=(n=t.charCodeAt(o))>>8,n%=256,r.push(n),r.push(e);return r}(e),t,n,r)}(this,t,e,n);break;default:throw new Error("Unknown encoding")}return i},o.prototype.toString=function(t,e,n){var r,o,i,s,a=this;if(t=String(t||"utf8").toLowerCase(),e=Number(e)||0,(n=void 0!==n?Number(n):a.length)===e)return"";switch(t){case"hex":r=function(t,e,n){var r=t.length;(!e||e<0)&&(e=0),(!n||n<0||r<n)&&(n=r);for(var o="",i=e;i<n;i++)o+=N(t[i]);return o}(a,e,n);break;case"utf8":case"utf-8":r=function(t,e,n){var r="",o="";n=Math.min(t.length,n);for(var i=e;i<n;i++)t[i]<=127?(r+=O(o)+String.fromCharCode(t[i]),o=""):o+="%"+t[i].toString(16);return r+O(o)}(a,e,n);break;case"ascii":case"binary":r=function(t,e,n){var r="";n=Math.min(t.length,n);for(var o=e;o<n;o++)r+=String.fromCharCode(t[o]);return r}(a,e,n);break;case"base64":o=a,s=n,r=0===(i=e)&&s===o.length?h.fromByteArray(o):h.fromByteArray(o.slice(i,s));break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":r=function(t,e,n){for(var r=t.slice(e,n),o="",i=0;i<r.length;i+=2)o+=String.fromCharCode(r[i]+256*r[i+1]);return o}(a,e,n);break;default:throw new Error("Unknown encoding")}return r},o.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},o.prototype.copy=function(t,e,n,r){if(e=e||0,(r=r||0===r?r:this.length)!==(n=n||0)&&0!==t.length&&0!==this.length){B(n<=r,"sourceEnd < sourceStart"),B(0<=e&&e<t.length,"targetStart out of bounds"),B(0<=n&&n<this.length,"sourceStart out of bounds"),B(0<=r&&r<=this.length,"sourceEnd out of bounds"),r>this.length&&(r=this.length);var i=(r=t.length-e<r-n?t.length-e+n:r)-n;if(i<100||!o._useTypedArrays)for(var s=0;s<i;s++)t[s+e]=this[s+n];else t._set(this.subarray(n,n+i),e)}},o.prototype.slice=function(t,e){var n=this.length;if(t=S(t,n,0),e=S(e,n,n),o._useTypedArrays)return o._augment(this.subarray(t,e));for(var r=e-t,i=new o(r,void 0,!0),s=0;s<r;s++)i[s]=this[s+t];return i},o.prototype.get=function(t){return console.log(".get() is deprecated. Access using array indexes instead."),this.readUInt8(t)},o.prototype.set=function(t,e){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(t,e)},o.prototype.readUInt8=function(t,e){if(e||(B(null!=t,"missing offset"),B(t<this.length,"Trying to read beyond buffer length")),!(t>=this.length))return this[t]},o.prototype.readUInt16LE=function(t,e){return f(this,t,!0,e)},o.prototype.readUInt16BE=function(t,e){return f(this,t,!1,e)},o.prototype.readUInt32LE=function(t,e){return p(this,t,!0,e)},o.prototype.readUInt32BE=function(t,e){return p(this,t,!1,e)},o.prototype.readInt8=function(t,e){if(e||(B(null!=t,"missing offset"),B(t<this.length,"Trying to read beyond buffer length")),!(t>=this.length))return 128&this[t]?-1*(255-this[t]+1):this[t]},o.prototype.readInt16LE=function(t,e){return m(this,t,!0,e)},o.prototype.readInt16BE=function(t,e){return m(this,t,!1,e)},o.prototype.readInt32LE=function(t,e){return g(this,t,!0,e)},o.prototype.readInt32BE=function(t,e){return g(this,t,!1,e)},o.prototype.readFloatLE=function(t,e){return y(this,t,!0,e)},o.prototype.readFloatBE=function(t,e){return y(this,t,!1,e)},o.prototype.readDoubleLE=function(t,e){return b(this,t,!0,e)},o.prototype.readDoubleBE=function(t,e){return b(this,t,!1,e)},o.prototype.writeUInt8=function(t,e,n){n||(B(null!=t,"missing value"),B(null!=e,"missing offset"),B(e<this.length,"trying to write beyond buffer length"),R(t,255)),e>=this.length||(this[e]=t)},o.prototype.writeUInt16LE=function(t,e,n){v(this,t,e,!0,n)},o.prototype.writeUInt16BE=function(t,e,n){v(this,t,e,!1,n)},o.prototype.writeUInt32LE=function(t,e,n){C(this,t,e,!0,n)},o.prototype.writeUInt32BE=function(t,e,n){C(this,t,e,!1,n)},o.prototype.writeInt8=function(t,e,n){n||(B(null!=t,"missing value"),B(null!=e,"missing offset"),B(e<this.length,"Trying to write beyond buffer length"),D(t,127,-128)),e>=this.length||(0<=t?this.writeUInt8(t,e,n):this.writeUInt8(255+t+1,e,n))},o.prototype.writeInt16LE=function(t,e,n){w(this,t,e,!0,n)},o.prototype.writeInt16BE=function(t,e,n){w(this,t,e,!1,n)},o.prototype.writeInt32LE=function(t,e,n){A(this,t,e,!0,n)},o.prototype.writeInt32BE=function(t,e,n){A(this,t,e,!1,n)},o.prototype.writeFloatLE=function(t,e,n){x(this,t,e,!0,n)},o.prototype.writeFloatBE=function(t,e,n){x(this,t,e,!1,n)},o.prototype.writeDoubleLE=function(t,e,n){E(this,t,e,!0,n)},o.prototype.writeDoubleBE=function(t,e,n){E(this,t,e,!1,n)},o.prototype.fill=function(t,e,n){if(e=e||0,n=n||this.length,B("number"==typeof(t="string"==typeof(t=t||0)?t.charCodeAt(0):t)&&!isNaN(t),"value is not a number"),B(e<=n,"end < start"),n!==e&&0!==this.length){B(0<=e&&e<this.length,"start out of bounds"),B(0<=n&&n<=this.length,"end out of bounds");for(var r=e;r<n;r++)this[r]=t}},o.prototype.inspect=function(){for(var t=[],e=this.length,r=0;r<e;r++)if(t[r]=N(this[r]),r===n.INSPECT_MAX_BYTES){t[r+1]="...";break}return"<Buffer "+t.join(" ")+">"},o.prototype.toArrayBuffer=function(){if("undefined"==typeof Uint8Array)throw new Error("Buffer.toArrayBuffer not supported in this browser");if(o._useTypedArrays)return new o(this).buffer;for(var t=new Uint8Array(this.length),e=0,n=t.length;e<n;e+=1)t[e]=this[e];return t.buffer};var T=o.prototype;function S(t,e,n){return"number"!=typeof t?n:e<=(t=~~t)?e:0<=t||0<=(t+=e)?t:0}function I(t){return(t=~~Math.ceil(+t))<0?0:t}function _(t){return(Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)})(t)}function N(t){return t<16?"0"+t.toString(16):t.toString(16)}function M(t){for(var e=[],n=0;n<t.length;n++){var r=t.charCodeAt(n);if(r<=127)e.push(t.charCodeAt(n));else for(var o=n,i=(55296<=r&&r<=57343&&n++,encodeURIComponent(t.slice(o,n+1)).substr(1).split("%")),s=0;s<i.length;s++)e.push(parseInt(i[s],16))}return e}function P(t){return h.toByteArray(t)}function L(t,e,n,r){for(var o=0;o<r&&!(o+n>=e.length||o>=t.length);o++)e[o+n]=t[o];return o}function O(t){try{return decodeURIComponent(t)}catch(t){return String.fromCharCode(65533)}}function R(t,e){B("number"==typeof t,"cannot write a non-number as a number"),B(0<=t,"specified a negative value for writing an unsigned value"),B(t<=e,"value is larger than maximum value for type"),B(Math.floor(t)===t,"value has a fractional component")}function D(t,e,n){B("number"==typeof t,"cannot write a non-number as a number"),B(t<=e,"value larger than maximum allowed value"),B(n<=t,"value smaller than minimum allowed value"),B(Math.floor(t)===t,"value has a fractional component")}function F(t,e,n){B("number"==typeof t,"cannot write a non-number as a number"),B(t<=e,"value larger than maximum allowed value"),B(n<=t,"value smaller than minimum allowed value")}function B(t,e){if(!t)throw new Error(e||"Failed assertion")}o._augment=function(t){return t._isBuffer=!0,t._get=t.get,t._set=t.set,t.get=T.get,t.set=T.set,t.write=T.write,t.toString=T.toString,t.toLocaleString=T.toString,t.toJSON=T.toJSON,t.copy=T.copy,t.slice=T.slice,t.readUInt8=T.readUInt8,t.readUInt16LE=T.readUInt16LE,t.readUInt16BE=T.readUInt16BE,t.readUInt32LE=T.readUInt32LE,t.readUInt32BE=T.readUInt32BE,t.readInt8=T.readInt8,t.readInt16LE=T.readInt16LE,t.readInt16BE=T.readInt16BE,t.readInt32LE=T.readInt32LE,t.readInt32BE=T.readInt32BE,t.readFloatLE=T.readFloatLE,t.readFloatBE=T.readFloatBE,t.readDoubleLE=T.readDoubleLE,t.readDoubleBE=T.readDoubleBE,t.writeUInt8=T.writeUInt8,t.writeUInt16LE=T.writeUInt16LE,t.writeUInt16BE=T.writeUInt16BE,t.writeUInt32LE=T.writeUInt32LE,t.writeUInt32BE=T.writeUInt32BE,t.writeInt8=T.writeInt8,t.writeInt16LE=T.writeInt16LE,t.writeInt16BE=T.writeInt16BE,t.writeInt32LE=T.writeInt32LE,t.writeInt32BE=T.writeInt32BE,t.writeFloatLE=T.writeFloatLE,t.writeFloatBE=T.writeFloatBE,t.writeDoubleLE=T.writeDoubleLE,t.writeDoubleBE=T.writeDoubleBE,t.fill=T.fill,t.inspect=T.inspect,t.toArrayBuffer=T.toArrayBuffer,t}}).call(this,t("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},t("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(t,e,n){(function(n,r,o,i,s,a,l,u,c){o=t("buffer").Buffer;var h=new o(4);h.fill(0),e.exports={hash:function(t,e,n,r){for(var i=e(function(t,e){t.length%4!=0&&(n=t.length+(4-t.length%4),t=o.concat([t,h],n));for(var n,r=[],i=e?t.readInt32BE:t.readInt32LE,s=0;s<t.length;s+=4)r.push(i.call(t,s));return r}(t=o.isBuffer(t)?t:new o(t),r),8*t.length),s=(e=r,new o(n)),a=e?s.writeInt32BE:s.writeInt32LE,l=0;l<i.length;l++)a.call(s,i[l],4*l,!0);return s}}}).call(this,t("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},t("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(t,e,n){(function(e,r,o,i,s,a,l,u,c){o=t("buffer").Buffer;var h=t("./sha"),d=t("./sha256"),f=t("./rng"),p={sha1:h,sha256:d,md5:t("./md5")},m=64,g=new o(m);function y(t,e){var n=p[t=t||"sha1"],r=[];return n||b("algorithm:",t,"is not yet supported"),{update:function(t){return o.isBuffer(t)||(t=new o(t)),r.push(t),t.length,this},digest:function(t){var i=o.concat(r);return i=e?function(t,e,n){o.isBuffer(e)||(e=new o(e)),o.isBuffer(n)||(n=new o(n)),e.length>m?e=t(e):e.length<m&&(e=o.concat([e,g],m));for(var r=new o(m),i=new o(m),s=0;s<m;s++)r[s]=54^e[s],i[s]=92^e[s];return n=t(o.concat([r,n])),t(o.concat([i,n]))}(n,e,i):n(i),r=null,t?i.toString(t):i}}}function b(){var t=[].slice.call(arguments).join(" ");throw new Error([t,"we accept pull requests","http://github.com/dominictarr/crypto-browserify"].join("\n"))}g.fill(0),n.createHash=function(t){return y(t)},n.createHmac=y,n.randomBytes=function(t,e){if(!e||!e.call)return new o(f(t));try{e.call(this,void 0,new o(f(t)))}catch(t){e(t)}};var v,C=["createCredentials","createCipher","createCipheriv","createDecipher","createDecipheriv","createSign","createVerify","createDiffieHellman","pbkdf2"],w=function(t){n[t]=function(){b("sorry,",t,"is not implemented yet")}};for(v in C)w(C[v])}).call(this,t("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},t("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(t,e,n){(function(n,r,o,i,s,a,l,u,c){var h=t("./helpers");function d(t,e){t[e>>5]|=128<<e%32,t[14+(e+64>>>9<<4)]=e;for(var n=1732584193,r=-271733879,o=-1732584194,i=271733878,s=0;s<t.length;s+=16){var a=n,l=r,u=o,c=i;n=p(n,r,o,i,t[s+0],7,-680876936),i=p(i,n,r,o,t[s+1],12,-389564586),o=p(o,i,n,r,t[s+2],17,606105819),r=p(r,o,i,n,t[s+3],22,-1044525330),n=p(n,r,o,i,t[s+4],7,-176418897),i=p(i,n,r,o,t[s+5],12,1200080426),o=p(o,i,n,r,t[s+6],17,-1473231341),r=p(r,o,i,n,t[s+7],22,-45705983),n=p(n,r,o,i,t[s+8],7,1770035416),i=p(i,n,r,o,t[s+9],12,-1958414417),o=p(o,i,n,r,t[s+10],17,-42063),r=p(r,o,i,n,t[s+11],22,-1990404162),n=p(n,r,o,i,t[s+12],7,1804603682),i=p(i,n,r,o,t[s+13],12,-40341101),o=p(o,i,n,r,t[s+14],17,-1502002290),n=m(n,r=p(r,o,i,n,t[s+15],22,1236535329),o,i,t[s+1],5,-165796510),i=m(i,n,r,o,t[s+6],9,-1069501632),o=m(o,i,n,r,t[s+11],14,643717713),r=m(r,o,i,n,t[s+0],20,-373897302),n=m(n,r,o,i,t[s+5],5,-701558691),i=m(i,n,r,o,t[s+10],9,38016083),o=m(o,i,n,r,t[s+15],14,-660478335),r=m(r,o,i,n,t[s+4],20,-405537848),n=m(n,r,o,i,t[s+9],5,568446438),i=m(i,n,r,o,t[s+14],9,-1019803690),o=m(o,i,n,r,t[s+3],14,-187363961),r=m(r,o,i,n,t[s+8],20,1163531501),n=m(n,r,o,i,t[s+13],5,-1444681467),i=m(i,n,r,o,t[s+2],9,-51403784),o=m(o,i,n,r,t[s+7],14,1735328473),n=g(n,r=m(r,o,i,n,t[s+12],20,-1926607734),o,i,t[s+5],4,-378558),i=g(i,n,r,o,t[s+8],11,-2022574463),o=g(o,i,n,r,t[s+11],16,1839030562),r=g(r,o,i,n,t[s+14],23,-35309556),n=g(n,r,o,i,t[s+1],4,-1530992060),i=g(i,n,r,o,t[s+4],11,1272893353),o=g(o,i,n,r,t[s+7],16,-155497632),r=g(r,o,i,n,t[s+10],23,-1094730640),n=g(n,r,o,i,t[s+13],4,681279174),i=g(i,n,r,o,t[s+0],11,-358537222),o=g(o,i,n,r,t[s+3],16,-722521979),r=g(r,o,i,n,t[s+6],23,76029189),n=g(n,r,o,i,t[s+9],4,-640364487),i=g(i,n,r,o,t[s+12],11,-421815835),o=g(o,i,n,r,t[s+15],16,530742520),n=y(n,r=g(r,o,i,n,t[s+2],23,-995338651),o,i,t[s+0],6,-198630844),i=y(i,n,r,o,t[s+7],10,1126891415),o=y(o,i,n,r,t[s+14],15,-1416354905),r=y(r,o,i,n,t[s+5],21,-57434055),n=y(n,r,o,i,t[s+12],6,1700485571),i=y(i,n,r,o,t[s+3],10,-1894986606),o=y(o,i,n,r,t[s+10],15,-1051523),r=y(r,o,i,n,t[s+1],21,-2054922799),n=y(n,r,o,i,t[s+8],6,1873313359),i=y(i,n,r,o,t[s+15],10,-30611744),o=y(o,i,n,r,t[s+6],15,-1560198380),r=y(r,o,i,n,t[s+13],21,1309151649),n=y(n,r,o,i,t[s+4],6,-145523070),i=y(i,n,r,o,t[s+11],10,-1120210379),o=y(o,i,n,r,t[s+2],15,718787259),r=y(r,o,i,n,t[s+9],21,-343485551),n=b(n,a),r=b(r,l),o=b(o,u),i=b(i,c)}return Array(n,r,o,i)}function f(t,e,n,r,o,i){return b((e=b(b(e,t),b(r,i)))<<o|e>>>32-o,n)}function p(t,e,n,r,o,i,s){return f(e&n|~e&r,t,e,o,i,s)}function m(t,e,n,r,o,i,s){return f(e&r|n&~r,t,e,o,i,s)}function g(t,e,n,r,o,i,s){return f(e^n^r,t,e,o,i,s)}function y(t,e,n,r,o,i,s){return f(n^(e|~r),t,e,o,i,s)}function b(t,e){var n=(65535&t)+(65535&e);return(t>>16)+(e>>16)+(n>>16)<<16|65535&n}e.exports=function(t){return h.hash(t,d,16)}}).call(this,t("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},t("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(t,e,n){(function(t,n,r,o,i,s,a,l,u){e.exports=function(t){for(var e,n=new Array(t),r=0;r<t;r++)!(3&r)&&(e=4294967296*Math.random()),n[r]=e>>>((3&r)<<3)&255;return n}}).call(this,t("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},t("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(t,e,n){(function(n,r,o,i,s,a,l,u,c){var h=t("./helpers");function d(t,e){t[e>>5]|=128<<24-e%32,t[15+(e+64>>9<<4)]=e;for(var n,r,o,i=Array(80),s=1732584193,a=-271733879,l=-1732584194,u=271733878,c=-1009589776,h=0;h<t.length;h+=16){for(var d=s,m=a,g=l,y=u,b=c,v=0;v<80;v++){i[v]=v<16?t[h+v]:p(i[v-3]^i[v-8]^i[v-14]^i[v-16],1);var C=f(f(p(s,5),(C=a,r=l,o=u,(n=v)<20?C&r|~C&o:!(n<40)&&n<60?C&r|C&o|r&o:C^r^o)),f(f(c,i[v]),(n=v)<20?1518500249:n<40?1859775393:n<60?-1894007588:-899497514));c=u,u=l,l=p(a,30),a=s,s=C}s=f(s,d),a=f(a,m),l=f(l,g),u=f(u,y),c=f(c,b)}return Array(s,a,l,u,c)}function f(t,e){var n=(65535&t)+(65535&e);return(t>>16)+(e>>16)+(n>>16)<<16|65535&n}function p(t,e){return t<<e|t>>>32-e}e.exports=function(t){return h.hash(t,d,20,!0)}}).call(this,t("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},t("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(t,e,n){(function(n,r,o,i,s,a,l,u,c){function h(t,e){var n=(65535&t)+(65535&e);return(t>>16)+(e>>16)+(n>>16)<<16|65535&n}function d(t,e){var n,r=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),o=new Array(1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225),i=new Array(64);t[e>>5]|=128<<24-e%32,t[15+(e+64>>9<<4)]=e;for(var s,a,l=0;l<t.length;l+=16){for(var u=o[0],c=o[1],d=o[2],f=o[3],g=o[4],y=o[5],b=o[6],v=o[7],C=0;C<64;C++)i[C]=C<16?t[C+l]:h(h(h((a=i[C-2],p(a,17)^p(a,19)^m(a,10)),i[C-7]),(a=i[C-15],p(a,7)^p(a,18)^m(a,3))),i[C-16]),n=h(h(h(h(v,p(a=g,6)^p(a,11)^p(a,25)),g&y^~g&b),r[C]),i[C]),s=h(p(s=u,2)^p(s,13)^p(s,22),u&c^u&d^c&d),v=b,b=y,y=g,g=h(f,n),f=d,d=c,c=u,u=h(n,s);o[0]=h(u,o[0]),o[1]=h(c,o[1]),o[2]=h(d,o[2]),o[3]=h(f,o[3]),o[4]=h(g,o[4]),o[5]=h(y,o[5]),o[6]=h(b,o[6]),o[7]=h(v,o[7])}return o}var f=t("./helpers"),p=function(t,e){return t>>>e|t<<32-e},m=function(t,e){return t>>>e};e.exports=function(t){return f.hash(t,d,32,!0)}}).call(this,t("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},t("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(t,e,n){(function(t,e,r,o,i,s,a,l,u){n.read=function(t,e,n,r,o){var i,s,a=8*o-r-1,l=(1<<a)-1,u=l>>1,c=-7,h=n?o-1:0,d=n?-1:1;for(o=t[e+h],h+=d,i=o&(1<<-c)-1,o>>=-c,c+=a;0<c;i=256*i+t[e+h],h+=d,c-=8);for(s=i&(1<<-c)-1,i>>=-c,c+=r;0<c;s=256*s+t[e+h],h+=d,c-=8);if(0===i)i=1-u;else{if(i===l)return s?NaN:1/0*(o?-1:1);s+=Math.pow(2,r),i-=u}return(o?-1:1)*s*Math.pow(2,i-r)},n.write=function(t,e,n,r,o,i){var s,a,l=8*i-o-1,u=(1<<l)-1,c=u>>1,h=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,d=r?0:i-1,f=r?1:-1;for(i=e<0||0===e&&1/e<0?1:0,e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=u):(s=Math.floor(Math.log(e)/Math.LN2),e*(r=Math.pow(2,-s))<1&&(s--,r*=2),2<=(e+=1<=s+c?h/r:h*Math.pow(2,1-c))*r&&(s++,r/=2),u<=s+c?(a=0,s=u):1<=s+c?(a=(e*r-1)*Math.pow(2,o),s+=c):(a=e*Math.pow(2,c-1)*Math.pow(2,o),s=0));8<=o;t[n+d]=255&a,d+=f,a/=256,o-=8);for(s=s<<o|a,l+=o;0<l;t[n+d]=255&s,d+=f,s/=256,l-=8);t[n+d-f]|=128*i}}).call(this,t("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},t("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(t,e,n){(function(t,n,r,o,i,s,a,l,u){var c,h,d;function f(){}(t=e.exports={}).nextTick=(h="undefined"!=typeof window&&window.setImmediate,d="undefined"!=typeof window&&window.postMessage&&window.addEventListener,h?function(t){return window.setImmediate(t)}:d?(c=[],window.addEventListener("message",(function(t){var e=t.source;e!==window&&null!==e||"process-tick"!==t.data||(t.stopPropagation(),0<c.length&&c.shift()())}),!0),function(t){c.push(t),window.postMessage("process-tick","*")}):function(t){setTimeout(t,0)}),t.title="browser",t.browser=!0,t.env={},t.argv=[],t.on=f,t.addListener=f,t.once=f,t.off=f,t.removeListener=f,t.removeAllListeners=f,t.emit=f,t.binding=function(t){throw new Error("process.binding is not supported")},t.cwd=function(){return"/"},t.chdir=function(t){throw new Error("process.chdir is not supported")}}).call(this,t("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},t("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:(t,e)=>{"use strict";var n;!function(){var r=e||{}||this||window;void 0===(n=function(){return r}.apply(e,[]))||(t.exports=n),r.default=r;var o="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(t){return t instanceof HTMLElement||t instanceof SVGElement},u=function(t){if(!l(t))throw new Error("an HTMLElement or SVGElement is required; got "+t)},c=function(t){return new Promise((function(e,n){l(t)?e(t):n(new Error("an HTMLElement or SVGElement is required; got "+t))}))},h=function(t,e,n){var r=t.viewBox&&t.viewBox.baseVal&&t.viewBox.baseVal[n]||null!==e.getAttribute(n)&&!e.getAttribute(n).match(/%$/)&&parseInt(e.getAttribute(n))||t.getBoundingClientRect()[n]||parseInt(e.style[n])||parseInt(window.getComputedStyle(t).getPropertyValue(n));return null==r||isNaN(parseFloat(r))?0:r},d=function(t){for(var e=window.atob(t.split(",")[1]),n=t.split(",")[0].split(":")[1].split(";")[0],r=new ArrayBuffer(e.length),o=new Uint8Array(r),i=0;i<e.length;i++)o[i]=e.charCodeAt(i);return new Blob([r],{type:n})},f={},p=null,m=function(t,e){var n=e||{},r=n.selectorRemap,o=n.modifyStyle,i=n.modifyCss,l=n.fonts,u=n.excludeUnusedCss,c=i||function(t,e){return(r?r(t):t)+"{"+(o?o(e):e)+"}\n"},h=[],d=void 0===l,m=l||[];return(p||(p=Array.from(document.styleSheets).map((function(t){try{return{rules:t.cssRules,href:t.href}}catch(e){return console.warn("Stylesheet could not be loaded: "+t.href,e),{}}})))).forEach((function(e){var n=e.rules,r=e.href;n&&Array.from(n).forEach((function(e){if(void 0!==e.style)if(function(t,e){if(e)try{return t.querySelector(e)||t.parentNode&&t.parentNode.querySelector(e)}catch(t){console.warn('Invalid CSS selector "'+e+'"',t)}}(t,e.selectorText))h.push(c(e.selectorText,e.style.cssText));else if(d&&e.cssText.match(/^@font-face/)){var n=function(t,e){var n=t.cssText.match(s),r=n&&n[1]||"";if(r&&!r.match(/^data:/)&&"about:blank"!==r){var o,i,l=r.startsWith("../")?e+"/../"+r:r.startsWith("./")?e+"/."+r:r;return{text:t.cssText,format:(o=l,i=Object.keys(a).filter((function(t){return o.indexOf("."+t)>0})).map((function(t){return a[t]})),i?i[0]:(console.error("Unknown font format for "+o+". Fonts may not be working correctly."),"application/octet-stream")),url:l}}}(e,r);n&&m.push(n)}else u||h.push(e.cssText)}))})),function(t){return Promise.all(t.map((function(t){return new Promise((function(e,n){if(f[t.url])return e(f[t.url]);var r=new XMLHttpRequest;r.addEventListener("load",(function(){var n=function(t){for(var e="",n=new Uint8Array(t),r=0;r<n.byteLength;r++)e+=String.fromCharCode(n[r]);return window.btoa(e)}(r.response),o=t.text.replace(s,'url("data:'+t.format+";base64,"+n+'")')+"\n";f[t.url]=o,e(o)})),r.addEventListener("error",(function(n){console.warn("Failed to load font from: "+t.url,n),f[t.url]=null,e(null)})),r.addEventListener("abort",(function(n){console.warn("Aborted loading font from: "+t.url,n),e(null)})),r.open("GET",t.url),r.responseType="arraybuffer",r.send()}))}))).then((function(t){return t.filter((function(t){return t})).join("")}))}(m).then((function(t){return h.join("\n")+t}))},g=function(){if(!navigator.msSaveOrOpenBlob&&!("download"in document.createElement("a")))return{popup:window.open()}};r.prepareSvg=function(t,e,n){u(t);var r=e||{},s=r.left,a=void 0===s?0:s,l=r.top,c=void 0===l?0:l,d=r.width,f=r.height,p=r.scale,g=void 0===p?1:p,y=r.responsive,b=void 0!==y&&y,v=r.excludeCss,C=void 0!==v&&v;return function(t){return Promise.all(Array.from(t.querySelectorAll("image")).map((function(t){var e,n=t.getAttributeNS("http://www.w3.org/1999/xlink","href")||t.getAttribute("href");return n?((e=n)&&0===e.lastIndexOf("http",0)&&-1===e.lastIndexOf(window.location.host)&&(n+=(-1===n.indexOf("?")?"?":"&")+"t="+(new Date).valueOf()),new Promise((function(e,r){var o=document.createElement("canvas"),i=new Image;i.crossOrigin="anonymous",i.src=n,i.onerror=function(){return r(new Error("Could not load "+n))},i.onload=function(){o.width=i.width,o.height=i.height,o.getContext("2d").drawImage(i,0,0),t.setAttributeNS("http://www.w3.org/1999/xlink","href",o.toDataURL("image/png")),e(!0)}}))):Promise.resolve(null)})))}(t).then((function(){var r=t.cloneNode(!0);r.style.backgroundColor=(e||{}).backgroundColor||t.style.backgroundColor;var s=function(t,e,n,r){if("svg"===t.tagName)return{width:n||h(t,e,"width"),height:r||h(t,e,"height")};if(t.getBBox){var o=t.getBBox(),i=o.x,s=o.y;return{width:i+o.width,height:s+o.height}}}(t,r,d,f),l=s.width,u=s.height;if("svg"!==t.tagName){if(!t.getBBox)return void console.error("Attempted to render non-SVG element",t);null!=r.getAttribute("transform")&&r.setAttribute("transform",r.getAttribute("transform").replace(/translate\(.*?\)/,""));var p=document.createElementNS("http://www.w3.org/2000/svg","svg");p.appendChild(r),r=p}if(r.setAttribute("version","1.1"),r.setAttribute("viewBox",[a,c,l,u].join(" ")),r.getAttribute("xmlns")||r.setAttributeNS(o,"xmlns",i),r.getAttribute("xmlns:xlink")||r.setAttributeNS(o,"xmlns:xlink","http://www.w3.org/1999/xlink"),b?(r.removeAttribute("width"),r.removeAttribute("height"),r.setAttribute("preserveAspectRatio","xMinYMin meet")):(r.setAttribute("width",l*g),r.setAttribute("height",u*g)),Array.from(r.querySelectorAll("foreignObject > *")).forEach((function(t){t.setAttributeNS(o,"xmlns","svg"===t.tagName?i:"http://www.w3.org/1999/xhtml")})),!C)return m(t,e).then((function(t){var e=document.createElement("style");e.setAttribute("type","text/css"),e.innerHTML="<![CDATA[\n"+t+"\n]]>";var o=document.createElement("defs");o.appendChild(e),r.insertBefore(o,r.firstChild);var i=document.createElement("div");i.appendChild(r);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:u};n(s,l,u)}));var y=document.createElement("div");y.appendChild(r);var v=y.innerHTML;if("function"!=typeof n)return{src:v,width:l,height:u};n(v,l,u)}))},r.svgAsDataUri=function(t,e,n){return u(t),r.prepareSvg(t,e).then((function(t){var e=t.src,r=t.width,o=t.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 " ">]>'+e).replace(/%([0-9A-F]{2})/g,(function(t,e){var n=String.fromCharCode("0x"+e);return"%"===n?"%25":n}))));return"function"==typeof n&&n(i,r,o),i}))},r.svgAsPngUri=function(t,e,n){u(t);var o=e||{},i=o.encoderType,s=void 0===i?"image/png":i,a=o.encoderOptions,l=void 0===a?.8:a,c=o.canvg,h=function(t){var e=t.src,r=t.width,o=t.height,i=document.createElement("canvas"),a=i.getContext("2d"),u=window.devicePixelRatio||1;i.width=r*u,i.height=o*u,i.style.width=i.width+"px",i.style.height=i.height+"px",a.setTransform(u,0,0,u,0,0),c?c(i,e):a.drawImage(e,0,0);var h=void 0;try{h=i.toDataURL(s,l)}catch(t){if("undefined"!=typeof SecurityError&&t instanceof SecurityError||"SecurityError"===t.name)return void console.error("Rendered SVG images cannot be downloaded in this browser.");throw t}return"function"==typeof n&&n(h,i.width,i.height),Promise.resolve(h)};return c?r.prepareSvg(t,e).then(h):r.svgAsDataUri(t,e).then((function(t){return new Promise((function(e,n){var r=new Image;r.onload=function(){return e(h({src:r,width:r.width,height:r.height}))},r.onerror=function(){n("There was an error loading the data URI as an image on the following SVG\n"+window.atob(t.slice(26))+"Open the following link to see browser's diagnosis\n"+t)},r.src=t}))}))},r.download=function(t,e,n){if(navigator.msSaveOrOpenBlob)navigator.msSaveOrOpenBlob(d(e),t);else{var r=document.createElement("a");if("download"in r){r.download=t,r.style.display="none",document.body.appendChild(r);try{var o=d(e),i=URL.createObjectURL(o);r.href=i,r.onclick=function(){return requestAnimationFrame((function(){return URL.revokeObjectURL(i)}))}}catch(t){console.error(t),console.warn("Error while getting object URL. Falling back to string URL."),r.href=e}r.click(),document.body.removeChild(r)}else n&&n.popup&&(n.popup.document.title=t,n.popup.location.replace(e))}},r.saveSvg=function(t,e,n){var o=g();return c(t).then((function(t){return r.svgAsDataUri(t,n||{})})).then((function(t){return r.download(e,t,o)}))},r.saveSvgAsPng=function(t,e,n){var o=g();return c(t).then((function(t){return r.svgAsPngUri(t,n||{})})).then((function(t){return r.download(e,t,o)}))}}()},5072:t=>{"use strict";var e=[];function n(t){for(var n=-1,r=0;r<e.length;r++)if(e[r].identifier===t){n=r;break}return n}function r(t,r){for(var i={},s=[],a=0;a<t.length;a++){var l=t[a],u=r.base?l[0]+r.base:l[0],c=i[u]||0,h="".concat(u," ").concat(c);i[u]=c+1;var d=n(h),f={css:l[1],media:l[2],sourceMap:l[3],supports:l[4],layer:l[5]};if(-1!==d)e[d].references++,e[d].updater(f);else{var p=o(f,r);r.byIndex=a,e.splice(a,0,{identifier:h,updater:p,references:1})}s.push(h)}return s}function o(t,e){var n=e.domAPI(e);return n.update(t),function(e){if(e){if(e.css===t.css&&e.media===t.media&&e.sourceMap===t.sourceMap&&e.supports===t.supports&&e.layer===t.layer)return;n.update(t=e)}else n.remove()}}t.exports=function(t,o){var i=r(t=t||[],o=o||{});return function(t){t=t||[];for(var s=0;s<i.length;s++){var a=n(i[s]);e[a].references--}for(var l=r(t,o),u=0;u<i.length;u++){var c=n(i[u]);0===e[c].references&&(e[c].updater(),e.splice(c,1))}i=l}}},7659:t=>{"use strict";var e={};t.exports=function(t,n){var r=function(t){if(void 0===e[t]){var n=document.querySelector(t);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(t){n=null}e[t]=n}return e[t]}(t);if(!r)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");r.appendChild(n)}},540:t=>{"use strict";t.exports=function(t){var e=document.createElement("style");return t.setAttributes(e,t.attributes),t.insert(e,t.options),e}},5056:(t,e,n)=>{"use strict";t.exports=function(t){var e=n.nc;e&&t.setAttribute("nonce",e)}},7825:t=>{"use strict";t.exports=function(t){if("undefined"==typeof document)return{update:function(){},remove:function(){}};var e=t.insertStyleElement(t);return{update:function(n){!function(t,e,n){var r="";n.supports&&(r+="@supports (".concat(n.supports,") {")),n.media&&(r+="@media ".concat(n.media," {"));var o=void 0!==n.layer;o&&(r+="@layer".concat(n.layer.length>0?" ".concat(n.layer):""," {")),r+=n.css,o&&(r+="}"),n.media&&(r+="}"),n.supports&&(r+="}");var i=n.sourceMap;i&&"undefined"!=typeof btoa&&(r+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(i))))," */")),e.styleTagTransform(r,t,e.options)}(e,t,n)},remove:function(){!function(t){if(null===t.parentNode)return!1;t.parentNode.removeChild(t)}(e)}}}},1113:t=>{"use strict";t.exports=function(t,e){if(e.styleSheet)e.styleSheet.cssText=t;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(t))}}},6686:(t,e,n)=>{"use strict";n.d(e,{AL:()=>r,NO:()=>o});const r=["A","G","C","U"];var o;!function(t){t.HELM="HELM",t.AXOLABS="Axolabs"}(o||(o={}))},9537:(t,e,n)=>{"use strict";n.d(e,{iL:()=>i,q7:()=>o,ti:()=>r});const r={NUCLEOSIDE:"nucleoside",LINKAGE:"phosphateBackbone"},o="p",i="<?>"},3480:(t,e,n)=>{"use strict";n.d(e,{C6:()=>l,Hs:()=>a,OT:()=>u,bD:()=>s});var r=n(6686),o=n(5067),i=n(9537);function s(t,e,n,o){const i=Object.keys(o.jsonData.codesToHelmDict).concat([r.NO.HELM]);if(!t||-1!==e&&n!==r.NO.HELM)return{};if(!i.includes(n))throw new Error(`${n} format is not supported by SequenceTranslator`);const s=i.filter((t=>t!=n)).sort(((t,e)=>t.localeCompare(e))),l=o.createFormatConverter(t,n),u=Object.fromEntries(s.map((t=>{let e;try{e=l.convertTo(t)}catch{e=null}return[t,e]})).filter((([t,e])=>e))),c=a(n===r.NO.HELM?t:u[r.NO.HELM],o.monomerLibWrapper);return c&&(u.Nucleotides=c),u}function a(t,e){const n=new RegExp("\\([^()]*\\)","g"),o=t.match(n);return o?o.map((t=>{const n=t.replace(/[\[\]()]/g,"");return r.AL.includes(n)?n:e.getNaturalAnalogBySymbol(n)})).map((t=>t||i.iL)).join(""):null}function l(t,e,n,i){const s=i.createFormatConverter(t,e);return n===o.qP?a(s.convertTo(r.NO.HELM),i.monomerLibWrapper):s.convertTo(n)}function u(t){return Object.keys(t.jsonData.codesToHelmDict).concat([r.NO.HELM,o.qP]).sort()}},5067:(t,e,n)=>{"use strict";n.d(e,{U_:()=>o,n_:()=>r,qP:()=>i});const r="Copied",o="Copy sequence",i="Nucleotides"},9788:(t,e,n)=>{"use strict";n.d(e,{PackageFunctions:()=>Tr,_package:()=>xr});var r=n(4328),o=n(6082),i=n(439),s=n(7291);const a=new class{constructor(){this.seqHandler="seq-handler",this.notationProvider="seq-handler.notation-provider"}};o.SemanticValue;var l=n(4971);class u{constructor(t,e,n=""){this.target=t,this.debugEnabled=e,this.prefix=n}error(t,e,n){return this.target.error(this.prefix+t,e,n)}warning(t,e){return this.target.warning(this.prefix+t,e)}info(t,e){return this.target.info(this.prefix+t,e)}debug(t,e){if(this.debugEnabled)return this.target.debug(this.prefix+t,e)}}const c="System:AppData/SequenceTranslator/monomers-sample",h="pattern-app-data.json",d="formats-to-helm.json",f="codes-to-symbols.json",p="linkers.json";var m=n(6686);function g(t){return t.sort(((t,e)=>e.length-t.length))}function y(t,e){const n=document.createElement("a");n.setAttribute("href","data:text/plain;charset=utf-8,"+e),n.setAttribute("download",t),n.click()}async function b(t,e,n="Oligo app"){try{return await t()}catch(t){const e=t.hasOwnProperty("message")?t.message:t.toString();throw r.shell.error(`${n} error: `+e),t}finally{e&&e()}}class v{constructor(t,e){this.sequence=t,this.th=e,this.libWrapper=this.th.monomerLibWrapper}getInvalidCodeIndex(t){if(t===m.NO.HELM)return this.sequence.length;const e=["r","d"],n=g(this.libWrapper.getCodesByFormat(t));let r=0;for(;r<this.sequence.length;){const t=n.find((t=>t===this.sequence.substring(r,r+t.length)));if(!t)break;if(r>1&&m.AL.includes(this.sequence[r])&&e.includes(this.sequence[r-2]))break;if(e.includes(this.sequence[r+1])&&m.AL.includes(this.sequence[r])){r++;break}r+=t.length}return r===this.sequence.length&&(r=-1),r}isValidSequence(t){return-1===this.getInvalidCodeIndex(t)}}class C{constructor(t,e,n,r){this.patternAppData=t,this.codesToHelmDict=e,this.codesToSymbolsDict=n,this.monomersWithPhosphate=r}}async function w(t){const e=await Promise.all([h,d,f,p].map((e=>async function(t,e){const n=t.endsWith("/")?`${t}${e}`:`${t}/${e}`;try{const t=await r.dapi.files.readAsText(n);return JSON.parse(t)}catch(t){console.error(`Error loading json from '${n}':`,t)}}(t,e))));return new C(e[0],e[1],e[2],e[3])}class A{constructor(t,e){if(this.lib=t,this.jsonData=e,null===this.lib)throw new Error("SequenceTranslator: monomer library is null");this.allMonomers=this.getAllMonomers()}formatMonomerForViewer(t){const e={};return e.name=t.symbol,e.symbol=t.symbol,e.molfile=t.molfile,this.getAllFormats().forEach((n=>{if(n===m.NO.HELM)return;const r=this.jsonData.codesToSymbolsDict[n],o=Object.keys(r).filter((e=>r[e]===t.symbol));e[n]=o.join(", ")})),e}getAllMonomers(){const t=this.lib.getPolymerTypes();let e=[];for(const n of t){const t=this.lib.getMonomerSymbolsByType(n).map((t=>this.lib.getMonomer(n,t))).filter((t=>null!==t));e=e.concat(t)}return e}getMonomer(t){const e=this.lib.getMonomer("RNA",t);if(void 0===e)throw new Error(`SequenceTranslator: no monomer with symbol ${t}`);return e}getMolfileBySymbol(t){return this.getMonomer(t).molfile}getNaturalAnalogBySymbol(t){const e=this.getMonomer(t).naturalAnalog;if(!e)throw new Error(`ST: no natural analog for ${t}`);return e}isModification(t){return!!this.getMolfileBySymbol(t).includes("MODIFICATION")}getCodeToSymbolMap(t){return new Map(Object.entries(this.jsonData.codesToSymbolsDict[t]))}getCodesByFormat(t){return Object.keys(this.jsonData.codesToSymbolsDict[t])}getAllFormats(){return Object.keys(this.jsonData.codesToSymbolsDict)}getTableForViewer(){const t=this.allMonomers.map((t=>this.formatMonomerForViewer(t)));return o.DataFrame.fromObjects(t)}getCodesToWeightsMap(){const t=new Map;return Object.entries(this.jsonData.codesToSymbolsDict).forEach((([e,n])=>{Object.entries(n).forEach((([e,n])=>{const r=this.getMonomer(n),o=r.meta?.molecularWeight;t.set(e,o)}))})),t}}var x=n(9537);const E=(t,e)=>e.length-t.length;class T{constructor(t){this.th=t,this.formats=this.getFormats()}getFormatNames(){return this.formats.sort()}getCodesByFormat(t){if(this.validateFormat(t),this.isHelm(t))throw new Error("Codes cannot be obtained for HELM");return this.getFormatCodes(t)}getHelmToFormatDict(t){return this.validateFormat(t),function(t){const e={};return Object.values(t).forEach((t=>{Object.entries(t).forEach((([t,n])=>{const r=n.replace(/\)p/g,")").replace(/\]p/g,"]");void 0===e[r]?e[r]=[t]:e[r].push(t)}))})),Object.entries(e).forEach((([t,n])=>{const r=n.sort(E);e[t]=r[0]})),e}(this.th.jsonData.codesToHelmDict[t])}getFormatToHelmDict(t){this.validateFormat(t);const e=this.th.jsonData.codesToHelmDict[t];return Object.assign({},...Object.values(e))}getTargetFormatHelmCodes(t){this.validateFormat(t);const e=this.getHelmToFormatDict(t);return Object.keys(e).sort(E)}getTargetFormatHelmCodesRegExp(t){this.validateFormat(t);const e=this.getTargetFormatHelmCodes(t);return new RegExp(S(e)+"|.","g")}getFormatRegExp(t){if(this.validateFormat(t),this.isHelm(t))throw new Error("Helm RegExp can be built for non-HELM target formats");return this.getNonHelmFormatRegExp(t)}getPhosphateHelmCodesRegExp(t){this.validateFormat(t);const e=this.th.jsonData.codesToHelmDict[t],n=S(Array.from(new Set(Object.values(e[x.ti.LINKAGE]))).sort(E));return new RegExp(`${x.q7}.(${n})`,"g")}isValidFormat(t){return this.formats.includes(t)}getFormats(){return Object.keys(this.th.jsonData.codesToHelmDict)}validateFormat(t){if(!this.isValidFormat(t))throw new Error(`Invalid format: ${t}`)}isHelm(t){return t===m.NO.HELM}getFormatCodes(t){const e=this.getFormatToHelmDict(t);return Object.keys(e).sort(E)}getNonHelmFormatRegExp(t){const e=this.getCodesByFormat(t);return new RegExp(S(e)+"|\\([^()]*\\)|.","g")}}function S(t){return t.map((t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"))).map((t=>t.includes("(")||t.includes(")")?t:`(?<!\\([^()]*)${t}(?![^()]*\\))`)).join("|")}const I={LEFT:"RNA1{",RIGHT:"}$$$$"};class _{constructor(t,e,n){this.sequence=t,this.sourceFormat=e,this.th=n,this.formats=new T(this.th)}convertTo(t){const e=this.formats.getFormatNames();if(this.sourceFormat===m.NO.HELM&&e.includes(t))return this.helmToFormat(this.sequence,t);if(e.includes(this.sourceFormat)&&t===m.NO.HELM)return this.formatToHelm(this.sequence,this.sourceFormat);if([this.sourceFormat,t].every((t=>e.includes(t)))){const e=this.formatToHelm(this.sequence,this.sourceFormat);return this.helmToFormat(e,t)}throw new Error(`ST: unsupported translation direction ${this.sourceFormat} -> ${t}`)}helmToFormat(t,e){const n=new RegExp(S(Object.values(I)),"g");let r=t.replace(n,"");const o=this.formats.getHelmToFormatDict(e),i=this.formats.getTargetFormatHelmCodes(e),s=this.formats.getTargetFormatHelmCodesRegExp(e);return r=r.replace(s,(t=>i.includes(t)?o[t]:"p"===t||"."===t?t:"?")).replace(/\?+/g,x.iL).replace(/p\.|\./g,""),r=r.replace(/<empty>/g,""),r=r.replace(/\/\//g,"/"),r}formatToHelm(t,e){const n=this.formats.getFormatToHelmDict(e),r=this.formats.getCodesByFormat(e),o=this.formats.getFormatRegExp(e),i=this.formats.getPhosphateHelmCodesRegExp(e);let s=t?t.replace(o,(t=>r.includes(t)?n[t]+".":"?")):"";return s=s.replace(/\?+/g,`${x.iL}.`),s=s.slice(0,-1),s[s.length-1]===x.q7&&(s=s.slice(0,-1)),s=s.replace(i,((t,e)=>e)),s=s.replace(/<empty>/g,""),`${I.LEFT+s+I.RIGHT}`}}class N{constructor(t,e){this.sequence=t,this.th=e,this.libWrapper=this.th.monomerLibWrapper,this.formats=Object.keys(this.th.jsonData.codesToHelmDict)}getFormat(){if(this.sequence.startsWith("RNA"))return m.NO.HELM;const t=this.getListOfPossibleSynthesizersByFirstMatchedCode();if(0===t.length)return null;const e=this.th.createSequenceValidator(this.sequence),n=Array(t.length).fill(0);for(let r=0;r<t.length;++r){const o=t[r];n[r]=e.getInvalidCodeIndex(o)}const r=n.some((t=>-1===t))?-1:Math.max(...n);return t[n.indexOf(r)]}getListOfPossibleSynthesizersByFirstMatchedCode(){const t=this.sequence,e=[];for(const n of this.formats){const r=g(this.libWrapper.getCodesByFormat(n));let o=0;for(let e=0;e<t.length;e++)if(")"===t[e]&&e!==t.length-1){o=e+1;break}r.some((e=>e===t.slice(o,o+e.length)))&&e.push(n)}return e}}var M=n(7389);const P=$;var L=n.n(P);function O(t,e){let n=0;const r=e.createFormatDetector(t).getFormat();null!==r&&(n=new v(t,e).getInvalidCodeIndex(r));const o=n<0||""===t,i=M.span([]);L()(i).css("-webkit-text-fill-color","var(--grey-6)");const s=M.span([]);return L()(s).css("-webkit-text-fill-color","red"),o?i.innerHTML=t:(i.innerHTML=t.slice(0,n),s.innerHTML=t.slice(n)),[i,s]}class R extends o.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(t={debug:!1}){super(),this.highlightInvalidSubsequence=t=>O(t,this),super._logger=new u(super.logger,t.debug)}startInit(t){this._initPromise=t}completeInit(t){this._helmHelper=t}async initLibData(){return this.initLibDataPromise||(this.initLibDataPromise=(async()=>{const t=await this.getSettings();let e=t instanceof Map?t.get("MonomersPath"):t.MonomersPath;e&&await r.dapi.files.exists(e)||(this.logger.warning(`Monomers path '${e}' not found. Fallback to monomers sample path '${c}'.`),e=c),[this._jsonData,this._monomerLib]=await Promise.all([w(e),D(e)]),this._monomerLibWrapper=new A(this.monomerLib,this.jsonData)})()),this.initLibDataPromise}async getTranslationHelper(){return await r.functions.call(`${this.name}:getTranslationHelper`)}createSequenceValidator(t){return new v(t,this)}createFormatConverter(t,e){return new _(t,e,this)}createFormatDetector(t){return new N(t,this)}}async function D(t){const e=o.TaskBarProgressIndicator.create("Initializing Oligo Toolkit monomer library ...");try{const e=await(0,l.pj)(),n=(t.endsWith("/")?t:t+"/")+"monomer-lib.json";return await e.readLibraryFromFilePath(n)}finally{e.close()}}class F{constructor(t,e){this.appName=t,this.parentAppName=e}async getAppView(){const t=o.TaskBarProgressIndicator.create(`Loading ${this.appName}...`),e=r.shell.v?.root;e&&M.setUpdateIndicator(e,!0);try{return await this.constructView()}finally{t.close(),e&&M.setUpdateIndicator(e,!1)}}}class B extends F{constructor(t){super(t),this.view=o.View.create(),this.configureView()}async constructView(){await this.initView();const t=this.parentAppName?this.parentAppName+"/"+this.appName:this.appName;return this.view.path=`/apps/${xr.name}/${t.replace(/\s/g,"")}/`,this.view}async initView(){const t=await this.getContent();this.view.append(t)}configureView(){this.view.box=!0,this.view.name=this.appName;const t=r.shell.windows;t.showProperties=!1,t.showToolbox=!1,t.showHelp=!1}getView(){return this.view}}const k=["SS","AS"],H={SS:"Sense strand",AS:"Anti sense"},G=["3'","5'"],U="OligoToolkit";var V,q,j,W;!function(t){t.IS_ANTISENSE_STRAND_INCLUDED="isAntisenseStrandIncluded",t.NUCLEOTIDE_SEQUENCES="nucleotideSequences",t.PHOSPHOROTHIOATE_LINKAGE_FLAGS="phosphorothioateLinkageFlags",t.STRAND_TERMINUS_MODIFICATIONS="strandTerminusModifications"}(V||(V={})),function(t){t.PATTERN_NAME="patternName",t.PATTERN_COMMENT="patternComment",t.NUCLEOTIDES_WITH_NUMERIC_LABELS="nucleotidesWithNumericLabels"}(q||(q={})),function(t){t.PATTERN_CONFIG="patternConfig",t.AUTHOR_ID="authorID",t.DATE="date"}(j||(j={})),function(t){t.CREATE="create",t.MODIFY="modify"}(W||(W={}));const z=[V.IS_ANTISENSE_STRAND_INCLUDED,V.NUCLEOTIDE_SEQUENCES,V.PHOSPHOROTHIOATE_LINKAGE_FLAGS,V.STRAND_TERMINUS_MODIFICATIONS],Y=(q.PATTERN_NAME,q.PATTERN_COMMENT,q.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 J extends Error{constructor(t){super(t),this.name="PatternNameExistsError"}}class Q extends Error{constructor(t){super(t),this.name="PatternExistsError"}}var X=n(4802),Z=n.n(X);class tt{constructor(t){this.th=t,this.otherUsersPatternNameToHash=new Map,this.currentUserPatternNameToHash=new Map}static async getInstance(){const t=await xr.getTranslationHelper(),e=new tt(t);e.currentUserName=await e.fetchCurrentUserName(),e.currentUserId=await e.fetchCurrentUserId();const n=e.fetchPatterns();return await e.initializePatternMaps(n),e}getCurrentUserPatternNames(){return Array.from(this.currentUserPatternNameToHash.keys()).sort(((t,e)=>t.toLowerCase().localeCompare(e.toLowerCase())))}getOtherUsersPatternNames(){return Array.from(this.otherUsersPatternNameToHash.keys()).sort(((t,e)=>t.toLowerCase().localeCompare(e.toLowerCase())))}getCurrentUserName(){return this.currentUserName}validatePatternNameUniqueness(t){if(this.currentUserPatternNameToHash.has(t))throw new J(`Pattern with name ${t} already exists`)}validatePatternUniqueness(t){if(Array.from(this.currentUserPatternNameToHash.values()).concat(Array.from(this.otherUsersPatternNameToHash.values())).includes(t))throw new Q(t)}getPatternHash(t,e){const n=e?this.currentUserPatternNameToHash.get(t):this.otherUsersPatternNameToHash.get(t);if(void 0===n)throw new Error(`Pattern with name ${t} not found`);return n}async getPatternRecordByHash(t){if(null===t||""===t)return null;try{const e=r.userSettings.getValue(U,t,!1)??"null";return JSON.parse(e)}catch{return null}}async getPatternConfig(t){if(""===t||null===t)return null;const e=await this.getPatternRecordByHash(t);return null===e?null:e[j.PATTERN_CONFIG]}getDefaultPatternRecord(){const t=Y;return t[j.AUTHOR_ID]=this.currentUserId,t}getDefaultPatternConfig(){return Y[j.PATTERN_CONFIG]}getAuthorCategoryByHash(t){if(this.isCurrentUserPattern(t))return this.getCurrentUserAuthorshipCategory();if(this.isOtherUserPattern(t))return this.getOtherUsersAuthorshipCategory();throw new Error(`Pattern with hash ${t} not found`)}isCurrentUserPattern(t){return Array.from(this.currentUserPatternNameToHash.values()).includes(t)}isOtherUserPattern(t){return Array.from(this.otherUsersPatternNameToHash.values()).includes(t)}getPatternNameByHash(t){const e=[this.currentUserPatternNameToHash,this.otherUsersPatternNameToHash];for(const n of e)for(const[e,r]of n.entries())if(r===t)return e;throw new Error(`Pattern with hash ${t} not found`)}getHashOfPatternToBeLoadedAfterDeletion(){const t=this.getCurrentUserPatternNames()[0];if(!t)throw new Error("Cannot load pattern after deletion, as there are no patterns left");const e=this.currentUserPatternNameToHash.get(t);if(void 0===e)throw new Error(`Pattern with name ${t} not found`);return e}async getRecordFromPattern(t){return{[j.PATTERN_CONFIG]:t,[j.AUTHOR_ID]:await r.dapi.users.current().then((t=>t.id))}}getHash(t){const e=z.reduce(((e,n)=>(e[n]=t[n],e)),{});return Z().sha1(e)}async savePatternToUserStorage(t){const e=t.getPatternConfig();try{const n=this.getHash(e);this.validatePatternUniqueness(n);const o=e[q.PATTERN_NAME];this.validatePatternNameUniqueness(o);const i=await this.getRecordFromPattern(e),s=(new Date).toISOString();i[j.DATE]={[W.CREATE]:s,[W.MODIFY]:s};const a=JSON.stringify(i);r.userSettings.add(U,n,a,!1),this.currentUserPatternNameToHash.set(o,n),t.selectAuthor(this.getCurrentUserAuthorshipCategory()),t.updatePatternList(),t.requestPatternLoad(n),t.updateUrlState(n)}catch(t){if(t instanceof J||t instanceof Q)throw t;console.error("Error while saving pattern to user storage",t)}}async overwriteExistingPatternInUserStorage(t){const e=t.getPatternConfig(),n=e[q.PATTERN_NAME],o=this.currentUserPatternNameToHash.get(n);if(void 0===o)throw new Error("Old hash is undefined");const i=this.getHash(e),s=await this.getRecordFromPattern(e),a=(new Date).toISOString();s[j.DATE]={[W.MODIFY]:a};const l=r.userSettings.getValue(U,o,!1)??"null",u=JSON.parse(l);void 0!==u[j.DATE]&&null!=u[j.DATE][W.CREATE]&&(s[j.DATE][W.CREATE]=u[j.DATE][W.CREATE]);const c=JSON.stringify(s);r.userSettings.add(U,i,c,!1),r.userSettings.delete(U,o,!1),this.currentUserPatternNameToHash.set(n,i),t.requestPatternLoad(i),t.updateUrlState(i)}async deletePattern(t,e){const n=this.currentUserPatternNameToHash.get(t);if(t===this.getDefaultPatternName())return void r.shell.warning("Cannot delete default pattern");if(void 0===n)throw new Error(`Pattern with name ${t} not found`);r.userSettings.delete(U,n,!1),this.currentUserPatternNameToHash.delete(t),e.updatePatternList();const o=this.getHashOfPatternToBeLoadedAfterDeletion();e.requestPatternLoad(o)}fetchDefaultNucleobase(){return this.fetchAvailableNucleotideBases()[0]}fetchAvailableNucleotideBases(){const t=Object.keys(this.th.jsonData.patternAppData)[0];return Object.keys(this.th.jsonData.patternAppData[t])}async fetchCurrentUserName(){return(await r.dapi.users.current()).friendlyName}async fetchCurrentUserId(){return(await r.dapi.users.current()).id}fetchPatterns(){return r.userSettings.get(U,!1)??{}}async initializePatternMaps(t){if(!this.currentUserId)throw new Error("Current user ID is not set");const e=new Map;for(const[n,r]of Object.entries(t))await this.extractDataFromRecordToMaps(n,r,e);this.setDefaultPattern()}setDefaultPattern(){const t=Y[j.PATTERN_CONFIG];this.currentUserPatternNameToHash.set(t[q.PATTERN_NAME],"")}async extractDataFromRecordToMaps(t,e,n){const o=JSON.parse(e),i=o[j.PATTERN_CONFIG].patternName,s=o[j.AUTHOR_ID];if(this.isCurrentUserId(s))this.currentUserPatternNameToHash.set(i,t);else{if(!n.has(s)){let t="<UNKNOWN_USER>";try{t=(await r.dapi.users.find(s)).friendlyName}catch(t){}n.set(s,t)}const e=i+` (created by ${n.get(s)})`;this.otherUsersPatternNameToHash.set(e,t)}}getDefaultPatternName(){return Y[j.PATTERN_CONFIG][q.PATTERN_NAME]}getCurrentUserAuthorshipCategory(){return this.currentUserName+" (me)"}getOtherUsersAuthorshipCategory(){return"Other users"}isCurrentUserId(t){return t===this.currentUserId}}const et=rxjs,nt=rxjs.operators;function rt(t){return t.endsWith("(o)")}function ot(t){const e=Object.values(t).flat().reduce(((t,e)=>(t[e]=(t[e]||0)+1,t)),{});return Object.entries(e).reduce(((t,e)=>t[1]>e[1]?t:e),["",0])[0]}var it;function st(t){const e=Array.from(new Set(t));return Array.from(e).sort(((t,e)=>t.toLowerCase().localeCompare(e.toLowerCase())))}!function(t){t.getTruncatedStrandData=function(t,e,n){return{nucleotides:t.slice(0,n),ptoFlags:e.slice(0,n+1)}},t.getExtendedStrandData=function(t,e,n,r){const o=n-t.length,i=t.concat(new Array(n-t.length).fill(r)),s=0===t.length?n+1:o;return{nucleotides:i,ptoFlags:e.concat(new Array(s).fill(!0))}}}(it||(it={}));var at=n(2543),lt=n.n(at);class ut{constructor(t,e){this.dataManager=t,this._patternListUpdated$=new et.Subject,this._patternLoadRequested$=new et.Subject,this._patternLoaded$=new et.Subject,this._uniqueNucleotides$=new et.BehaviorSubject([]),this._patternDeletionRequested$=new et.Subject,this._tableSelection$=new et.BehaviorSubject(null),this._svgSaveRequested$=new et.Subject,this._loadPatternInNewTabRequested$=new et.Subject,this._urlStateUpdated$=new et.Subject,this._patternHasUnsavedChanges$=new et.BehaviorSubject(!1),this._selectedStrandColumn=new et.BehaviorSubject(null),this._selectedIdColumn=new et.BehaviorSubject(null),this.initializeAuthorSelection(e),this.initializePatternState(e),this._lastLoadedPatternConfig=new et.BehaviorSubject(lt().cloneDeep(this.getPatternConfig())),this.setupSubscriptions()}setupSubscriptions(){this._nucleotideSequences$.subscribe((()=>{this.updateUniqueNucleotides(),this.updateSequenceBase()})),this._isAntisenseStrandActive$.subscribe((t=>{t||G.forEach((t=>{this.updateTerminusModification("AS",t,"")}))})),this.patternStateChanged$.pipe((0,nt.debounceTime)(20)).subscribe((()=>{const t=this._lastLoadedPatternConfig.getValue(),e=this.getPatternConfig(),n=!lt().isEqual(e,t);this._patternHasUnsavedChanges$.next(n)}))}updateUniqueNucleotides(){const t=(e=this._nucleotideSequences$.getValue(),st(Object.values(e).flat()));var e;this._uniqueNucleotides$.next(t)}updateSequenceBase(){const t=ot(this._nucleotideSequences$.getValue());this._sequenceBase$.next(t)}get nucleotideSequencesChanged$(){return this._nucleotideSequences$.asObservable()}initializeAuthorSelection(t){const e=t[j.AUTHOR_ID];this.dataManager.isCurrentUserId(e)?this._patternAuthorSelection$=new et.BehaviorSubject(this.dataManager.getCurrentUserAuthorshipCategory()):this._patternAuthorSelection$=new et.BehaviorSubject(this.dataManager.getOtherUsersAuthorshipCategory())}initializePatternState(t){const e=t[j.PATTERN_CONFIG];this._patternName$=new et.BehaviorSubject(e[q.PATTERN_NAME]),this._isAntisenseStrandActive$=new et.BehaviorSubject(e[V.IS_ANTISENSE_STRAND_INCLUDED]),this._nucleotideSequences$=new et.BehaviorSubject(e[V.NUCLEOTIDE_SEQUENCES]),this._phosphorothioateLinkageFlags=new et.BehaviorSubject(e[V.PHOSPHOROTHIOATE_LINKAGE_FLAGS]),this._terminalModifications=new et.BehaviorSubject(e[V.STRAND_TERMINUS_MODIFICATIONS]),this._comment$=new et.BehaviorSubject(e[q.PATTERN_COMMENT]),this._modificationsWithNumericLabels$=new et.BehaviorSubject(e[q.NUCLEOTIDES_WITH_NUMERIC_LABELS]),this._sequenceBase$=new et.BehaviorSubject(ot(e[V.NUCLEOTIDE_SEQUENCES]))}getPatternName(){return this._patternName$.getValue()}updatePatternName(t){this._patternName$.next(t)}get antisenseStrandToggled$(){return this._isAntisenseStrandActive$.asObservable()}isAntisenseStrandActive(){return this._isAntisenseStrandActive$.getValue()}toggleAntisenseStrand(t){t?this.updateStrandLength("AS",this.getNucleotideSequences().SS.length):this.updateStrandLength("AS",0),this._isAntisenseStrandActive$.next(t)}getNucleotideSequences(){return this._nucleotideSequences$.getValue()}updateNucleotideSequences(t){this._nucleotideSequences$.next(t)}updateStrandLength(t,e){const n=this.getNucleotideSequences()[t];if(n.length===e)return;const r=this.getPhosphorothioateLinkageFlags()[t];if(0===e)return void this.setNewStrandData([],[],t);if(n.length>e){const{nucleotides:o,ptoFlags:i}=it.getTruncatedStrandData(n,r,e);return void this.setNewStrandData(o,i,t)}const o=this.getSequenceBase(),{nucleotides:i,ptoFlags:s}=it.getExtendedStrandData(n,r,e,o);this.setNewStrandData(i,s,t)}setNewStrandData(t,e,n){this.updateNucleotideSequences({...this.getNucleotideSequences(),[n]:t}),this.updatePhosphorothioateLinkageFlags({...this.getPhosphorothioateLinkageFlags(),[n]:e})}getPhosphorothioateLinkageFlags(){return this._phosphorothioateLinkageFlags.getValue()}updatePhosphorothioateLinkageFlags(t){this._phosphorothioateLinkageFlags.next(t)}get phosphorothioateLingeFlagsChanged$(){return this._phosphorothioateLinkageFlags.asObservable()}getTerminalModifications(){return this._terminalModifications.getValue()}updateTerminalModifications(t){this._terminalModifications.next(t)}updateTerminusModification(t,e,n){const r=this.getTerminalModifications();r[t][e]=n,this.updateTerminalModifications(r)}terminalModificationsUpdated$(){return this._terminalModifications.asObservable()}getComment(){return this._comment$.getValue()}updateComment(t){this._comment$.next(t)}getModificationsWithNumericLabels(){return this._modificationsWithNumericLabels$.getValue()}updateModificationsWithNumericLabels(t){const e=function(t){return st(t).filter((t=>!rt(t)))}(t);this._modificationsWithNumericLabels$.next(e)}get patternLoadRequested$(){return this._patternLoadRequested$.asObservable()}requestPatternLoad(t){this._patternLoadRequested$.next(t)}get patternListUpdated$(){return this._patternListUpdated$.asObservable()}updatePatternList(){this._patternListUpdated$.next()}get tableSelectionChanged$(){return this._tableSelection$.asObservable()}selectTable(t){this._tableSelection$.next(t)}getTableSelection(){return this._tableSelection$.getValue()}requestPatternDeletion(t){this._patternDeletionRequested$.next(t)}get patternDeletionRequested$(){return this._patternDeletionRequested$.asObservable()}replaceSequenceBase(t){const e=this._nucleotideSequences$.getValue(),n={};k.forEach((r=>{n[r]=e[r].map((()=>t))})),this._nucleotideSequences$.next(n);const r=this._modificationsWithNumericLabels$.getValue();r.includes(t)||this.updateModificationsWithNumericLabels(r.concat(t))}get patternStateChanged$(){return et.merge(this._patternName$.pipe((0,nt.debounceTime)(300),(0,nt.map)((()=>{}))),this._isAntisenseStrandActive$,this._nucleotideSequences$,this._phosphorothioateLinkageFlags,this._terminalModifications,this._comment$.pipe((0,nt.debounceTime)(300)),this._modificationsWithNumericLabels$)}getSequenceBase(){return this._sequenceBase$.getValue()}uniqueNucleotidesChanged$(){return this.patternStateChanged$.pipe((0,nt.switchMap)((()=>this._uniqueNucleotides$)))}getUniqueNucleotides(){return this._uniqueNucleotides$.getValue()}get svgSaveRequested$(){return this._svgSaveRequested$.asObservable()}requestSvgSave(){this._svgSaveRequested$.next()}setAllPTOLinkages(t){const e=this.getPhosphorothioateLinkageFlags();k.forEach((n=>{e[n]=e[n].map((()=>t))})),this.updatePhosphorothioateLinkageFlags(e)}setPatternConfig(t){this._patternName$.next(t[q.PATTERN_NAME]),this._isAntisenseStrandActive$.next(t[V.IS_ANTISENSE_STRAND_INCLUDED]),this._nucleotideSequences$.next(t[V.NUCLEOTIDE_SEQUENCES]),this._phosphorothioateLinkageFlags.next(t[V.PHOSPHOROTHIOATE_LINKAGE_FLAGS]),this._terminalModifications.next(t[V.STRAND_TERMINUS_MODIFICATIONS]),this._comment$.next(t[q.PATTERN_COMMENT]),this._modificationsWithNumericLabels$.next(t[q.NUCLEOTIDES_WITH_NUMERIC_LABELS])}setLastLoadedPatternConfig(t){this._lastLoadedPatternConfig.next(lt().cloneDeep(t))}getPatternConfig(){return{[q.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(),[q.PATTERN_COMMENT]:this.getComment(),[q.NUCLEOTIDES_WITH_NUMERIC_LABELS]:this.getModificationsWithNumericLabels()}}setPhosphorothioateLinkageFlag(t,e,n){const r=this.getPhosphorothioateLinkageFlags();r[t][e]=n,this.updatePhosphorothioateLinkageFlags(r)}setNucleotide(t,e,n){const r=this.getNucleotideSequences();r[t][e]=n;const o=this.getModificationsWithNumericLabels();this.updateModificationsWithNumericLabels(o.concat(n)),this.updateNucleotideSequences(r)}get strandsUpdated$(){return et.merge(this._isAntisenseStrandActive$.asObservable().pipe((0,nt.map)((()=>{}))),this._nucleotideSequences$.asObservable().pipe((0,nt.map)((()=>{}))),this._patternLoaded$.asObservable().pipe((0,nt.map)((()=>{})))).pipe((0,nt.debounceTime)(10))}get strandsLinkagesAndTerminalsUpdated$(){return et.merge(this.strandsUpdated$,this._phosphorothioateLinkageFlags.asObservable().pipe((0,nt.map)((()=>{}))),this._terminalModifications.asObservable().pipe((0,nt.map)((()=>{}))))}updateControlsUponPatternLoaded(t){this._patternLoaded$.next(t)}get patternLoaded$(){return this._patternLoaded$.asObservable()}get userSelection$(){return this._patternAuthorSelection$.asObservable().pipe((0,nt.skip)(1))}selectAuthor(t){if("string"!=typeof t)throw new Error("Selected user must be defined");this._patternAuthorSelection$.next(t)}getSelectedAuthor(){return this._patternAuthorSelection$.getValue()}get loadPatternInNewTabRequested$(){return this._loadPatternInNewTabRequested$.asObservable()}requestLoadPatternInNewTab(t){this._loadPatternInNewTabRequested$.next(t)}updateUrlState(t){this._urlStateUpdated$.next(t)}get urlStateUpdated$(){return this._urlStateUpdated$.asObservable()}get patternHasUnsavedChanges$(){return this._patternHasUnsavedChanges$.asObservable()}selectStrandColumn(t,e){this._selectedStrandColumn.next({...this._selectedStrandColumn.getValue(),[t]:e})}getSelectedStrandColumn(t){const e=this._selectedStrandColumn.getValue();return e?e[t]:null}selectIdColumn(t){this._selectedIdColumn.next(t)}getSelectedIdColumn(){return this._selectedIdColumn.getValue()}get updateSvgContainer$(){return this.patternStateChanged$.pipe((0,nt.debounceTime)(100))}}const ct="pattern";class ht{constructor(){this.urlSearchParams=new URLSearchParams(window.location.search)}subscribeToObservables(t){t.urlStateUpdated$.subscribe((t=>this.setPatternURL(t))),t.loadPatternInNewTabRequested$.subscribe((t=>{const e=`${window.location.origin}${window.location.pathname}?${ct}=${t}`;window.open(e,"_blank")})),window.addEventListener("popstate",(()=>{this.urlSearchParams=new URLSearchParams(window.location.search);const e=this.getPatternHash();null!==e&&t.requestPatternLoad(e)}))}getPatternHash(){return this.urlSearchParams.get(ct)}setPatternURL(t){null!==t&&""!==t?(this.urlSearchParams.set(ct,t),window.history.pushState({},"",`${window.location.pathname}?${this.urlSearchParams}`)):this.clearPatternURL()}clearPatternURL(){this.urlSearchParams.delete(ct),window.history.pushState({},"",`${window.location.pathname}`)}}var dt=n(5072),ft=n.n(dt),pt=n(7825),mt=n.n(pt),gt=n(7659),yt=n.n(gt),bt=n(5056),vt=n.n(bt),Ct=n(540),wt=n.n(Ct),At=n(1113),xt=n.n(At),Et=n(9252),Tt={};Tt.styleTagTransform=xt(),Tt.setAttributes=vt(),Tt.insert=yt().bind(null,"head"),Tt.domAPI=mt(),Tt.insertStyleElement=wt(),ft()(Et.A,Tt),Et.A&&Et.A.locals&&Et.A.locals;class St{constructor(t){this.eventBus=t,this.columnControlsContainer=M.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 t=this.createStrandColumnInput(),e=t.SS,n=t.AS;this.eventBus.antisenseStrandToggled$.subscribe((t=>{L()(n).toggle(t)}));const r=this.createIdColumnInput();return[e,n,r]}createStrandColumnInput(){const t=this.selectedTable?this.selectedTable.columns.names().sort(((t,e)=>t.localeCompare(e))):[];return Object.fromEntries(k.map((e=>{const n=M.input.choice(`${H[e]} column`,{value:t[0],items:t,onValueChanged:t=>this.eventBus.selectStrandColumn(e,t)});return this.eventBus.selectStrandColumn(e,t[0]),[e,n.root]})))}createIdColumnInput(){const t=this.selectedTable?this.selectedTable.columns.names():[],e=M.input.choice("ID column",{value:t[0],items:t,onValueChanged:t=>this.eventBus.selectIdColumn(t)});return this.eventBus.selectIdColumn(t[0]),e.root}}class It{constructor(t){this.eventBus=t,this.availableTables=[],this.tableInputContainer=M.div([]),this.subscribeToTableEvents(),this.refreshTableInput()}getTableInputContainer(){return this.tableInputContainer}subscribeToTableEvents(){r.events.onTableAdded.subscribe((t=>this.handleTableAdded(t))),r.events.onTableRemoved.subscribe((t=>this.handleTableRemoved(t))),this.eventBus.tableSelectionChanged$.subscribe((()=>this.handleTableChoice()))}getTableFromEventData(t){if(!t&&t.args&&t.args.dataFrame instanceof o.DataFrame)throw new Error("EventData does not contain a dataframe",t);return t.args.dataFrame}handleTableAdded(t){const e=this.getTableFromEventData(t);this.availableTables.some((t=>t.name===e.name))||(this.availableTables.push(e),this.eventBus.selectTable(e),this.refreshTableInput())}handleTableRemoved(t){const e=this.getTableFromEventData(t);this.availableTables=this.availableTables.filter((t=>t.name!==e.name));const n=this.availableTables[0];this.eventBus.selectTable(n||null),this.refreshTableInput()}refreshTableInput(){const t=this.createTableInput();L()(this.tableInputContainer).empty(),this.tableInputContainer.append(t.root)}createTableInput(){const t=this.eventBus.getTableSelection();return M.input.table("Tables",{value:t,items:this.availableTables,onValueChanged:t=>{null!==t&&this.eventBus.selectTable(t)}})}handleTableChoice(){const t=this.eventBus.getTableSelection();t&&(this.isTableDisplayed(t)||this.displayTable(t))}isTableDisplayed(t){return r.shell.tableNames.includes(t.name)}displayTable(t){const e=r.shell.v;r.shell.addTableView(t),r.shell.v=e}}function _t(t,e,n,r){const o=function(t,e,n){const r=new Array(t.length+e.filter((t=>t)).length+G.length);r[0]=n["5'"],r[r.length-1]=n["3'"];let o=1;return e[0]&&(r[o]="ps",o++),t.forEach(((t,n)=>{r[n+o]=t,e[n+1]&&(r[n+o+1]="ps",o++)})),r}(t.split("").map(((t,n)=>{const r=function(t,e,n){const r=Object.keys(n.patternAppData)[0],o=n.patternAppData[r][e].substitution;return t.replace(/([AGCTU])/,o)}(t,e[n],xr.jsonData);return r})),n,r);return o.join("")}class Nt{constructor(t){this.eventBus=t,this.tableInputManager=new It(t),this.columnInputManager=new St(t)}createControls(){const t=M.h1("Bulk convert"),e=this.tableInputManager.getTableInputContainer(),n=this.columnInputManager.getColumnControlsContainer(),r=M.bigButton("Convert",(()=>this.processConvertButtonClick()));return[t,e,n,M.buttonsInput([r])]}processConvertButtonClick(){!function(t){const e=t.getTableSelection();if(!e)return void r.shell.warning("Please select a table");const n=k.filter((e=>!("AS"===e&&!t.isAntisenseStrandActive()))).map((e=>({strand:e,column:t.getSelectedStrandColumn(e)}))).filter((t=>t.column));if(0===n.length)return void r.shell.warning("Select a sense strand column");const o=t.getSelectedIdColumn();if(!o)throw new Error("No ID column selected");e.getCol(o);const i=n.map((t=>({strand:t.strand,column:e.getCol(t.column)})));!function(t,e){const n=e.getNucleotideSequences();return t.every((t=>{const e=n[t.strand].length;return t.column.toList().every((t=>t.length===e))}))}(i,t)?r.shell.warning("Some strands in the table input do not match pattern length"):i.forEach((n=>{const r=n.column,o=n.strand,i=t.getNucleotideSequences()[o],s=t.getTerminalModifications()[o],a=t.getPhosphorothioateLinkageFlags()[o],l=`${t.getPatternName()}(${r.name})`;e.columns.addNewString(l).init((t=>_t(r.get(t),i,a,s)))}))}(this.eventBus)}}class Mt{constructor(t,e,n){this.eventBus=t,this.initialPatternConfig=e,this.subscriptions=n}create(){return M.divV([M.h1("PTO"),M.divH([this.createAllPtoActivationInput().root,...this.createFirstPtoInputs().map((t=>t.root))],{style:{gap:"12px"}})])}areAllPtoLinkagesSet(t){return k.map((e=>t[e].filter((t=>t)).length)).reduce(((t,e)=>t+e),0)===k.map((t=>this.initialPatternConfig.nucleotideSequences[t].length)).reduce(((t,e)=>t+e),0)+k.filter((e=>t[e].length)).length}createAllPtoActivationInput(){const t=this.initialPatternConfig.phosphorothioateLinkageFlags,e=this.areAllPtoLinkagesSet(t),n=M.input.bool("All PTO",{value:e});n.onInput.subscribe((()=>{const t=n.value;this.eventBus.setAllPTOLinkages(t)}));const r=this.eventBus.phosphorothioateLingeFlagsChanged$.subscribe((()=>{const t=this.eventBus.getPatternConfig().phosphorothioateLinkageFlags,e=this.areAllPtoLinkagesSet(t);n.value=e}));return this.subscriptions.add(r),this.addStyleToPtoInput(n),M.tooltip.bind(n.captionLabel,"Activate all phosphothioates"),n}addStyleToPtoInput(t){const e=t.captionLabel;e.classList.add("ui-label-right"),Object.assign(e.style,{textAlign:"left",maxWidth:"100px",minWidth:"40px",width:"auto"})}createFirstPtoInputs(){return k.map((t=>{if(!this.eventBus.isAntisenseStrandActive()&&"AS"===t)return;const e=this.isFirstPtoActive(t),n=M.input.bool(`First ${t} PTO`,{value:e});n.onInput.subscribe((()=>{const e=n.value;this.eventBus.setPhosphorothioateLinkageFlag(t,0,e)}));const r=this.eventBus.phosphorothioateLingeFlagsChanged$.subscribe((e=>{const r=e[t][0];n.value=r}));return this.subscriptions.add(r),this.addStyleToPtoInput(n),M.tooltip.bind(n.captionLabel,`Activate first phosphothioate in ${t}`),n})).filter((t=>void 0!==t))}isFirstPtoActive(t){return this.initialPatternConfig.phosphorothioateLinkageFlags[t][0]}}class Pt{constructor(t,e,n){this.eventBus=t,this.dataManager=e,this.subscriptions=n;const r=this.eventBus.nucleotideSequencesChanged$.subscribe((()=>{this.displayedInputLabels=this.computeDisplayedInputLabels()}));this.subscriptions.add(r)}create(){const t=k.map((t=>this.constructControlsPanel(t)));return M.divH(t,{style:{gap:"24px"}})}constructControlsPanel(t){if(!this.eventBus.isAntisenseStrandActive()&&"AS"===t)return M.div([]);const e=this.constructHeader(),n=this.createControls(t);return M.block([M.h1(`${H[t]}`),e,n],{style:{paddingTop:"12px"}})}constructHeader(){return M.divH([M.div([M.divText("#")],{style:{width:"20px"}}),M.block75([M.divText("Modification")]),M.div([M.divText("PTO")])])}createControls(t){const e=this.createNucleobaseInputs(t),n=this.createLabelDivs(t),r=this.createPTOFlagInputs(t);return M.div(e.map(((t,e)=>M.divH([n[e],M.block75([t.root]),r[e].root],{style:{alignItems:"center"}}))))}createNucleobaseInputs(t){const e=this.dataManager.fetchAvailableNucleotideBases().sort(((t,e)=>t.toLowerCase().localeCompare(e.toLowerCase())));return this.eventBus.getNucleotideSequences()[t].map(((n,r)=>{const o=M.input.choice("",{value:n,items:e});return o.onInput.subscribe((()=>{const e=o.value;this.eventBus.setNucleotide(t,r,e)})),o}))}createPTOFlagInputs(t){return this.eventBus.getPhosphorothioateLinkageFlags()[t].slice(1).map(((e,n)=>{const r=M.input.bool("",{value:e});r.onInput.subscribe((()=>{const e=r.value;this.eventBus.setPhosphorothioateLinkageFlag(t,n+1,e)}));const o=this.eventBus.phosphorothioateLingeFlagsChanged$.subscribe((e=>{const o=e[t][n+1];r.value=o}));return this.subscriptions.add(o),r}))}computeDisplayedInputLabels(){const t=this.eventBus.getNucleotideSequences(),e=new Map;return k.forEach((n=>{let r=1;const o=t[n].map((t=>{if(rt(t))return"";const e=String(r);return r++,e}));e.set(n,o)})),e}createLabelDivs(t){const e=this.createLabels(t).map((t=>M.div([t],{style:{width:"20px"}}))),n=this.eventBus.nucleotideSequencesChanged$.subscribe((()=>{this.createLabels(t).forEach(((t,n)=>{L()(e[n]).empty(),L()(e[n]).append(t)}))}));return this.subscriptions.add(n),e}createLabels(t){return this.eventBus.getNucleotideSequences()[t].map(((e,n)=>{const r=this.displayedInputLabels.get(t)[n];return M.label(r)}))}}class Lt{constructor(){this.rxjsSubscriptions=[],this.dgSubscriptions=[]}add(t){t instanceof et.Subscription?this.rxjsSubscriptions.push(t):this.dgSubscriptions.push(t)}unsubscribeAll(){for(const t of[this.rxjsSubscriptions,this.dgSubscriptions])t.forEach((t=>t.unsubscribe())),t.length=0}}class Ot{constructor(t,e){this.eventBus=t,this.dataManager=e,this.subscriptions=new Lt}static open(t,e){Ot.isDialogOpen||(Ot.instance||(Ot.instance=new Ot(t,e)),Ot.instance.openDialog())}openDialog(){this.initialPatternConfig=lt().cloneDeep(this.eventBus.getPatternConfig()),Ot.isDialogOpen=!0,this.createDialog().show()}createDialog(){const t=M.divV([]);this.subscriptions.add(this.eventBus.strandsUpdated$.subscribe((()=>this.onStrandsUpdated(t))));const e=M.dialog("Edit strands").add(t).onOK((()=>{})).onCancel((()=>this.resetToInitialState()));return this.subscriptions.add(e.onClose.subscribe((()=>{Ot.isDialogOpen=!1,this.subscriptions.unsubscribeAll()}))),e}onStrandsUpdated(t){const e=new Mt(this.eventBus,this.initialPatternConfig,this.subscriptions).create(),n=new Pt(this.eventBus,this.dataManager,this.subscriptions).create();L()(t).empty(),L()(t).append(e,n)}resetToInitialState(){this.eventBus.setPatternConfig(this.initialPatternConfig)}}Ot.isDialogOpen=!1;class Rt{constructor(t){this.eventBus=t,this.subscriptions=new Lt}static open(t){Rt.isDialogOpen||(Rt.instance||(Rt.instance=new Rt(t)),Rt.instance.openDialog())}openDialog(){this.initialPatternConfig=lt().cloneDeep(this.eventBus.getPatternConfig()),Rt.isDialogOpen=!0,this.createDialog().show()}createDialog(){const t=M.divV([]);this.subscriptions.add(this.eventBus.strandsUpdated$.subscribe((()=>this.onStrandsUpdated(t))));const e=M.dialog("Edit terminal modifications").add(t).onOK((()=>{})).onCancel((()=>this.resetToInitialState()));return this.subscriptions.add(e.onClose.subscribe((()=>{Rt.isDialogOpen=!1,this.subscriptions.unsubscribeAll()}))),e}onStrandsUpdated(t){const e=new Dt(this.eventBus).create();L()(t).empty(),L()(t).append(e)}resetToInitialState(){this.eventBus.setPatternConfig(this.initialPatternConfig)}}Rt.isDialogOpen=!1;class Dt{constructor(t){this.eventBus=t}create(){const t=k.map((t=>this.constructControlsPanel(t)));return M.divH(t,{style:{gap:"24px"}})}constructControlsPanel(t){if(!this.eventBus.isAntisenseStrandActive()&&"AS"===t)return M.div([]);const e=this.createInputs(t);return M.block([M.h1(`${H[t]}`),e],{style:{paddingTop:"12px"}})}createInputs(t){const e=("SS"===t?[...G].reverse():G).map((e=>this.createInputForTerminus(t,e)));return M.form(e)}createInputForTerminus(t,e){const n=this.eventBus.getTerminalModifications()[t][e],r=M.input.textArea(e,{value:n});return this.applyStylingToInput(r),r.onInput.subscribe((()=>{const n=r.value;null!==n&&this.eventBus.updateTerminusModification(t,e,n)})),r}applyStylingToInput(t){const e=t.root.getElementsByTagName("textarea")[0];L()(e).css("resize","none")}}class Ft{constructor(t,e){this.eventBus=t,this.dataManager=e}createControls(){const t=this.createAntisenseStrandToggle(),e=this.createStrandLengthInputs(),n=e.SS.root,r=e.AS.root,o=this.createSequenceBaseInput().root,i=this.createPatternCommentInput().root,s=this.createPatternNameInputBlock(),a=this.createEditPatternButton(),l=this.createEditTerminalModificationsButton();return[M.h1("Edit"),t,n,r,o,s,i,M.buttonsInput([l,a])]}createEditPatternButton(){const t=M.button("Edit strands",(()=>Ot.open(this.eventBus,this.dataManager)));return M.tooltip.bind(t,"Edit strand modifications and PTOs"),t}createEditTerminalModificationsButton(){const t=M.button("Edit terminals",(()=>Rt.open(this.eventBus)));return M.tooltip.bind(t,"Edit terminal modifications"),L()(t).css("margin-right","20px"),t}createAntisenseStrandToggle(){const t=M.input.toggle(`${H.AS} strand`,{value:this.eventBus.isAntisenseStrandActive()});return t.onInput.subscribe((()=>this.eventBus.toggleAntisenseStrand(t.value))),this.eventBus.patternLoaded$.subscribe((()=>{t.value=this.eventBus.isAntisenseStrandActive()})),t.setTooltip("Toggle antisense strand"),t.root}createStrandLengthInputs(){const t=t=>{const n=this.eventBus.getNucleotideSequences()[t].length,r=M.input.int(`${H[t]} length`,{value:n});return r.onInput.subscribe((()=>e(t,r))),this.eventBus.nucleotideSequencesChanged$.subscribe((()=>{r.value=this.eventBus.getNucleotideSequences()[t].length})),r.setTooltip(`Number of nucleotides in ${t}, including overhangs`),[t,r]},e=(t,e)=>{const n=e.value;null!==n&&(n<=0&&(r.shell.warning("Sequence length must be greater than 0"),e.value=1),n>34&&(r.shell.warning("Sequence length must be less than 35"),e.value=34),this.eventBus.updateStrandLength(t,e.value))},n=Object.fromEntries(k.map((e=>t(e))));return this.eventBus.antisenseStrandToggled$.subscribe((t=>{L()(n.AS.root).toggle(t)})),n}createSequenceBaseInput(){const t=this.dataManager.fetchAvailableNucleotideBases().sort(((t,e)=>t.toLowerCase().localeCompare(e.toLowerCase()))),e=this.dataManager.fetchDefaultNucleobase(),n=M.input.choice("Sequence basis",{value:e,items:t});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 t=M.input.textArea("Comment",{value:this.eventBus.getComment()});return L()(t.root).addClass("st-pattern-text-input"),t.onInput.subscribe((()=>this.eventBus.updateComment(t.value))),this.eventBus.patternLoaded$.subscribe((()=>{t.value=this.eventBus.getComment()})),t}createPatternNameInputBlock(){const t=M.input.textArea("Pattern name",{value:this.eventBus.getPatternName()});return L()(t.root).addClass("st-pattern-text-input"),t.onInput.subscribe((()=>this.eventBus.updatePatternName(t.value))),this.eventBus.patternLoaded$.subscribe((()=>{t.value=this.eventBus.getPatternName()})),t.setTooltip("Name under which pattern will be saved"),t.root}}class Bt{constructor(t,e){this.eventBus=t,this.dataManager=e,this.subscriptions=new Lt,this.authorSelectedByUser=!1,this.eventBus.patternLoadRequested$.subscribe((t=>this.handlePatternChoice(t))),this.eventBus.patternDeletionRequested$.subscribe((async t=>{await this.dataManager.deletePattern(t,this.eventBus)}))}async handlePatternChoice(t){let e=await this.dataManager.getPatternConfig(t);null===e&&(e=this.dataManager.getDefaultPatternConfig()),this.eventBus.setPatternConfig(e),this.eventBus.updateControlsUponPatternLoaded(t),this.eventBus.setLastLoadedPatternConfig(e)}isCurrentUserSelected(){return this.eventBus.getSelectedAuthor()!==this.dataManager.getOtherUsersAuthorshipCategory()}createControls(){const t=this.getPatternInputsContainer();return[M.h1("Load"),t]}getPatternInputsContainer(){const t=M.divH(this.createPatternInputs());return this.eventBus.patternListUpdated$.subscribe((()=>{this.subscriptions.unsubscribeAll(),L()(t).empty(),L()(t).append(this.createPatternInputs())})),t}createPatternInputs(){const t=this.createAuthorChoiceInput(),e=this.createPatternChoiceInputContainer(),n=this.createDeletePatternButton();return[t.root,e,n]}createPatternChoiceInputContainer(){const t=this.createPatternChoiceInput(),e=M.div([t.root]),n=this.eventBus.userSelection$.subscribe((()=>{L()(e).empty(),L()(e).append(this.createPatternChoiceInput().root)}));return this.subscriptions.add(n),e}createAuthorChoiceInput(){const t=[this.dataManager.getCurrentUserAuthorshipCategory()];this.dataManager.getOtherUsersPatternNames().length>0&&t.push(this.dataManager.getOtherUsersAuthorshipCategory());const e=M.input.choice("Author",{value:this.eventBus.getSelectedAuthor(),items:t});return e.onInput.subscribe((()=>{if(this.authorSelectedByUser=!0,null===e.value)throw new Error("author choice must be non-null");this.eventBus.selectAuthor(e.value)})),this.setAuthorChoiceInputStyle(e),e.setTooltip("Select pattern author"),e}setAuthorChoiceInputStyle(t){L()(t.input).css({"max-width":"100px","min-width":"100px"}),L()(t.root).css({"padding-right":"30px","padding-left":"30px"})}createPatternChoiceInput(){const t=this.isCurrentUserSelected()?this.dataManager.getCurrentUserPatternNames():this.dataManager.getOtherUsersPatternNames();if(this.authorSelectedByUser){const e=this.dataManager.getPatternHash(t[0],this.isCurrentUserSelected());this.eventBus.requestPatternLoad(e),this.eventBus.updateUrlState(e),this.authorSelectedByUser=!1}const e=this.getPatternName(t),n=M.input.choice("Pattern",{value:e,items:t});return n.setTooltip("Select pattern to load"),L()(n.input).css({"max-width":"100px","min-width":"100px"}),this.subscriptions.add(n.onInput.subscribe((()=>{const t=this.dataManager.getPatternHash(n.value,this.isCurrentUserSelected());this.eventBus.requestPatternLoad(t),this.eventBus.updateUrlState(t)}))),this.subscriptions.add(this.eventBus.patternLoaded$.subscribe((()=>{const e=this.eventBus.getPatternName();n.value!==e&&(n.value=this.getPatternName(t))}))),n}getPatternName(t){return t.find((t=>t.split(" (")[0]===this.eventBus.getPatternName()))??t[0]}createDeletePatternButton(){const t=M.button(M.iconFA("trash-alt"),(()=>{this.eventBus.getPatternName()!==this.dataManager.getDefaultPatternName()?this.showDeletePatternDialog():r.shell.warning("Cannot delete example pattern")}));M.tooltip.bind(t,"Delete pattern from user storage");const e=this.eventBus.userSelection$.subscribe((()=>{t.disabled=!this.isCurrentUserSelected()}));return this.subscriptions.add(e),t}showDeletePatternDialog(){const t=M.dialog("Delete pattern"),e=this.eventBus.getPatternName();t.add(M.divText(`Are you sure you want to delete pattern ${e}?`)),t.onOK((()=>this.eventBus.requestPatternDeletion(e))),t.show()}}class $t{constructor(t,e){this.eventBus=t,this.dataManager=e}getLayout(){const t=new Bt(this.eventBus,this.dataManager),e=new Ft(this.eventBus,this.dataManager),n=new Nt(this.eventBus),r=t.createControls(),o=e.createControls(),i=n.createControls(),s=M.div(r);L()(s).css({"padding-bottom":"20px"});const a=M.div([...o,...i],"ui-form"),l=M.div([s,a]);return L()(l).css({padding:"25px"}),M.box(l,{style:{maxWidth:"450px"}})}}var kt=n(9146);class Ht{constructor(t,e,n){this.svgElementFactory=t,this.config=e,this.yShift=n}shiftElements(t){this.svgElements.forEach((e=>{const n=e.getAttribute("transform")||"",r=`translate(${t.x},${t.y})`;e.setAttribute("transform",`${n} ${r}`)}))}}class Gt{constructor(){}static getInstance(){return Gt.instance||(Gt.instance=new Gt,Gt.instance.canvas=document.createElement("canvas")),Gt.instance}static getTextDimensions(t,e){const n=Gt.getInstance().canvas.getContext("2d");if(!n)throw new Error("Canvas 2D context is not available");return n.font=`${e}px Arial`,{width:1.1*n.measureText(t).width,height:1.1*e}}}function Ut(t){const e=Object.keys(xr.jsonData.patternAppData)[0];if(!e)throw new Error(`No format found in '${h}'`);return xr.jsonData.patternAppData[e][t].color||""}class Vt extends Ht{constructor(t,e,n){super(t,e,n);const r=k.filter((t=>e.nucleotideSequences[t].length>0));this.strands=r.map((t=>new qt(this.svgElementFactory,e,n,t))),this.terminalModifications=r.map(((t,r)=>new Wt(this.svgElementFactory,e,n,t,this.strands[r]))),this.labels=r.map(((t,r)=>new jt(this.svgElementFactory,e,n,t,this.terminalModifications[r])))}get svgElements(){return[...this.strands,...this.terminalModifications,...this.labels].map((t=>t.svgElements)).flat()}getContentWidth(){return Math.max(...this.labels.map((t=>t.getContentWidth())))}getContentHeight(){return this.strands.reduce(((t,e)=>t+e.getContentHeight()),0)}}class qt extends Ht{constructor(t,e,n,r){super(t,e,n),this.svgElementFactory=t,this.config=e,this.yShift=n,this.strand=r,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 t=0;return this.config.nucleotideSequences[this.strand].map((e=>rt(e)?null:(t++,t)))}get svgElements(){return this._svgElements}getStrandCircleYShift(){return zt(this.strand,this.yShift)}createStrandCircles(){const t={x:80,y:this.getStrandCircleYShift()};return this.config.nucleotideSequences[this.strand].map(((e,n)=>this.createNucleotideElementGroup(e,n,t))).flat()}createNucleotideElementGroup(t,e,n){return[...this.createNucleotideCircleElements(t,e,n),this.config.nucleotidesWithNumericLabels.includes(t)?this.createNucleotideNumericLabel(e,n):null].filter((t=>null!==t))}createNucleotideCircleElements(t,e,n){const r=Ut(t),o={...n,x:n.x+30*e};return[this.svgElementFactory.createCircleElement(o,15,r),this.createNucleotideLetterLabel(e,n,t)]}getNucleotideCircleCenterPosition(t,e){return{x:e.x+30*t,y:e.y}}createNucleotideLetterLabel(t,e,n){if(!m.AL.includes(n))return null;const r=function(t){return!rt(t)&&m.AL.includes(t)?t:""}(n),o=function(t){const e=Ut(t),n=e.match(/\d+/g)?.map(Number);if(!n||n.length<3)return"#ffffff";const[r,o,i]=n;return.299*r+.587*o+.114*i>186?"#333333":"#ffffff"}(n),i=this.getPositionForNucleotideLabel(t,e);return this.svgElementFactory.createTextElement(r,i,17,o)}getPositionForNucleotideLabel(t,e){const n=this.getNucleotideCircleCenterPosition(t,e),r=Gt.getTextDimensions("A",17);return{x:n.x-r.width/2,y:n.y+r.height/3}}getNumericLabelYShift(t){return"SS"===this.strand?t.y-20:t.y+15+5+15}createNucleotideNumericLabel(t,e){const n=this.nucleotideNumericLabels[t];if(null===n)return null;const r=Gt.getTextDimensions(n.toString(),15).width,o={x:e.x+30*t-r/2,y:this.getNumericLabelYShift(e)};return this.svgElementFactory.createTextElement(n.toString(),o,15,"var(--grey-6)")}createPTOLinkageStars(){const t=this.config.phosphorothioateLinkageFlags[this.strand],e=this.getStrandCircleYShift()+12;return t.map(((t,n)=>{if(!t)return null;const r={x:65+30*n,y:e};return this.svgElementFactory.createStarElement(r,"red")})).filter((t=>null!==t))}getContentWidth(){return 30*this.config.nucleotideSequences[this.strand].length}getContentHeight(){return 62}}class jt extends Ht{constructor(t,e,n,r,o){super(t,e,n),this.svgElementFactory=t,this.config=e,this.yShift=n,this.strand=r,this.terminalModifications=o,this._svgElements=this.createSVGElements()}createSVGElements(){return[this.createLeftLabel(),this.createRightLabel()]}getLeftLabelWidth(){return 55}getRightLabelWidth(){return 20}createLeftLabel(){const t="SS"===this.strand?"5'":"3'",e=`${this.strand}: ${t} `,n=Gt.getTextDimensions(e,17),r={x:10,y:zt(this.strand,this.yShift)+n.height/3};return this.svgElementFactory.createTextElement(e,r,17,"var(--grey-6)")}createRightLabel(){const t=" "+("SS"===this.strand?"3'":"5'"),e=Gt.getTextDimensions(t,17),n={x:65+this.terminalModifications.getContentWidth()+5,y:zt(this.strand,this.yShift)+e.height/3};return this.svgElementFactory.createTextElement(t,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 Wt extends Ht{constructor(t,e,n,r,o){super(t,e,n),this.svgElementFactory=t,this.config=e,this.yShift=n,this.strand=r,this.strandSvgWrapper=o,this._svgElements=this.createSVGElements()}createSVGElements(){return this.createTerminalModifications()}getTerminalModification(t){return this.config.strandTerminusModifications[this.strand][t]}getTerminalModificationTextDimensions(t){const e=this.getTerminalModification(t);return Gt.getTextDimensions(e,17)}getLeftTerminus(){return"SS"===this.strand?"5'":"3'"}createTerminalModification(t){const e=this.getTerminalModification(t),n=this.getTerminalModificationTextDimensions(t),r=t===this.getLeftTerminus(),o={x:r?65:65+this.getTerminalModificationTextDimensions(this.getLeftTerminus()).width+this.strandSvgWrapper.getContentWidth(),y:zt(this.strand,this.yShift)+n.height/3};return r&&this.strandSvgWrapper.shiftElements({x:n.width,y:0}),this.svgElementFactory.createTextElement(e,o,17,"red")}createTerminalModifications(){return("AS"===this.strand?G:Array.from(G).reverse()).map((t=>this.createTerminalModification(t)))}get svgElements(){return this._svgElements}getContentWidth(){return this.strandSvgWrapper.getContentWidth()+G.map((t=>this.getTerminalModificationTextDimensions(t).width)).reduce(((t,e)=>t+e),0)}getContentHeight(){return this.strandSvgWrapper.getContentHeight()}}function zt(t,e){return"SS"===t?e+5+15+15:e+52+10+15}class Yt{constructor(){this.xmlNamespace="http://www.w3.org/2000/svg"}createElement(t){return document.createElementNS(this.xmlNamespace,t)}setAttributes(t,e){Object.entries(e).forEach((([e,n])=>{t.setAttribute(e,String(n))}))}createCanvas(t,e){const n=this.createElement("svg");return this.setAttributes(n,{id:"mySvg",width:t,height:e}),n}createCircleElement(t,e,n){const r=this.createElement("circle");return this.setAttributes(r,{cx:t.x,cy:t.y,r:e,fill:n}),r}createTextElement(t,e,n,r){const o=this.createElement("text");return this.setAttributes(o,{x:e.x,y:e.y,"font-size":n,"font-weight":"normal","font-family":"Arial",fill:r}),o.textContent=t,o}createStarElement(t,e){const n=this.createElement("polygon"),r=this.computeStarVertexCoordinates(t).map((t=>t.join(","))).join(" ");return this.setAttributes(n,{points:r,fill:e}),n}computeStarVertexCoordinates(t){const e=Math.PI/5,n=-e/2;return Array.from({length:10},((r,o)=>{const i=o%2==0?6:3,s=o*e+n;return[t.x+Math.cos(s)*i,t.y+Math.sin(s)*i]}))}createRectangleElement(t,e,n,r){const o=this.createElement("rect");return this.setAttributes(o,{x:t.x,y:t.y,width:e,height:n,fill:r}),o}}class Kt extends Ht{constructor(t,e,n){super(t,e,n),this.svgElementFactory=t,this.config=e,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 Gt.getTextDimensions(this.titleText,17).width}getContentHeight(){return Gt.getTextDimensions(this.titleText,17).height}getTitleText(){const t=`${this.config.nucleotideSequences.SS.length}`,e=this.config.isAntisenseStrandIncluded?`/${this.config.nucleotideSequences.AS.length}`:"";return`${this.config.patternName} for ${t}${e}-mer`}}class Jt extends Ht{constructor(t,e,n){super(t,e,n),this._svgElements=[];const{elements:r,width:o}=this.createLegendItems();this._svgElements=r,this.width=o}isPhosphorothioatePresent(){return Object.values(this.config.phosphorothioateLinkageFlags).flat().some((t=>t))}getModificationTypesList(){return[...new Set(Object.values(this.config.nucleotideSequences).flat().sort(((t,e)=>t.toLowerCase().localeCompare(e.toLowerCase()))))]}get svgElements(){return this._svgElements}createLegendItem(t,e){const n={x:e,y:this.yShift-6},r=t.includes("linkage")?this.svgElementFactory.createStarElement(n,"red"):this.svgElementFactory.createCircleElement(n,6,Ut(t));e+=12;const o={y:this.yShift,x:e};return{elements:[r,this.svgElementFactory.createTextElement(t,o,15,"var(--grey-6)")],width:12+Gt.getTextDimensions(t,15).width}}createLegendItems(){let t=10;const e=[],n=e=>t+=e+15;if(this.isPhosphorothioatePresent()){const{elements:r,width:o}=this.createLegendItem("PTO linkage",t);n(o),e.push(r)}return this.getModificationTypesList().forEach((r=>{const{elements:o,width:i}=this.createLegendItem(r,t);n(i),e.push(o)})),{elements:e.flat(),width:t}}getContentHeight(){return 20}getContentWidth(){return this.width}}class Qt{constructor(t){this.svgElementFactory=new Yt;const e=lt().cloneDeep(t);let n=10;this.title=new Kt(this.svgElementFactory,e,n),n+=this.title.getContentHeight(),this.strands=new Vt(this.svgElementFactory,e,n),n+=this.strands.getContentHeight()+10,this.legend=new Jt(this.svgElementFactory,e,n)}renderPattern(){const t=this.getGlobalWidth(),e=this.getGlobalHeight(),n=this.svgElementFactory.createCanvas(t,e),r=[this.title,this.strands,this.legend].map((t=>t.svgElements)).flat();return n.append(...r),n}getGlobalWidth(){const t=[this.title,this.strands,this.legend];return Math.max(...t.map((t=>t.getContentWidth())))}getGlobalHeight(){return[this.title,this.strands,this.legend].reduce(((t,e)=>t+e.getContentHeight()),10)}}class Xt{constructor(t){this.eventBus=t,this.svgDisplayDiv=M.div([]),t.updateSvgContainer$.subscribe((()=>this.updateSvgContainer())),t.svgSaveRequested$.subscribe((()=>this.saveSvgAsPng()))}static createSvgDiv(t){return new Xt(t).svgDisplayDiv}updateSvgContainer(){$(this.svgDisplayDiv).empty();const t=this.eventBus.getPatternConfig();this.svgElement=this.createSvg(t),this.svgDisplayDiv.append(this.svgElement)}createSvg(t){return new Qt(t).renderPattern()}saveSvgAsPng(){const t=this.eventBus.getPatternName();kt.saveSvgAsPng(this.svgElement,t,{backgroundColor:"white"})}}class Zt{constructor(t){this.eventBus=t,this.togglesContainer=M.div([]),this.eventBus.uniqueNucleotidesChanged$().subscribe((()=>{this.updateContainer()}))}getContainer(){return this.togglesContainer}updateContainer(){L()(this.togglesContainer).empty(),L()(this.togglesContainer).append(this.createInputs())}createInputs(){const t=this.eventBus.getUniqueNucleotides().filter((t=>!rt(t))).map((t=>this.createSingleInput(t)));return t.sort(((t,e)=>t.captionLabel.textContent.localeCompare(e.captionLabel.textContent))),M.divH(t.map((t=>t.root)))}createSingleInput(t){const e=this.eventBus.getModificationsWithNumericLabels().includes(t),n=M.input.bool(t,{value:e,onValueChanged:e=>this.handleNumericLabelToggle(t,e)});return L()(n.root).css("padding-right","20px"),n.setTooltip(`Show numeric labels for ${t}`),n}handleNumericLabelToggle(t,e){const n=this.eventBus.getModificationsWithNumericLabels();if(n.includes(t)===e)return;const r=e?n.concat(t):n.filter((e=>e!==t));this.eventBus.updateModificationsWithNumericLabels(r)}}class te{constructor(t,e){this.eventBus=t,this.dataManager=e,this.subscriptions=new Lt}createContainer(){return M.div([M.h1("Translation example"),this.createTranslationExamples()],{style:{paddingTop:"20px"}})}createTranslationExamples(){const t=M.divH([...this.getExampleElements()],"ui-form");return this.eventBus.antisenseStrandToggled$.subscribe((()=>{this.subscriptions.unsubscribeAll(),L()(t).empty(),L()(t).append(this.getExampleElements())})),t}getExampleElements(){return k.map((t=>new ee(t,this.eventBus,this.subscriptions).create()))}}class ee{constructor(t,e,n){this.strand=t,this.eventBus=e,this.subscriptions=n}create(){return this.eventBus.isAntisenseStrandActive()||"AS"!==this.strand?(this.inputExample=this.createInputExample(),this.outputExample=this.createOutputExample(this.inputExample.value),this.subscribeToEvents(),M.block50([M.h2(H[this.strand]),this.inputExample.root,this.outputExample.root],{style:{paddingRight:"20px"}})):M.div([])}subscribeToEvents(){const t=this.eventBus.strandsLinkagesAndTerminalsUpdated$.subscribe((()=>{const t=this.generateExampleSequence();this.inputExample.value=t,this.outputExample.value=this.computeOutputValue(t)}));"AS"===this.strand&&this.subscriptions.add(t)}createInputExample(){const t=this.createTextInputForExamples(),e=this.generateExampleSequence();return t.value=e,t.setTooltip(`Example raw nucleotides input for ${H[this.strand]}`),t}generateExampleSequence(){return this.eventBus.getNucleotideSequences()[this.strand].map(((t,e)=>m.AL[e%m.AL.length])).join("")}createOutputExample(t){const e=this.createTextInputForExamples();return e.value=this.computeOutputValue(t),e.setTooltip(`Pattern applied to the example input for ${H[this.strand]}`),e}computeOutputValue(t){const e=this.eventBus.getNucleotideSequences()[this.strand],n=this.eventBus.getTerminalModifications()[this.strand];return _t(t,e,this.eventBus.getPhosphorothioateLinkageFlags()[this.strand],n)}createTextInputForExamples(){const t=M.input.textArea("",{value:""});return this.applyStylingToInput(t),t}applyStylingToInput(t){const e=t.root.getElementsByTagName("textarea")[0];e.setAttribute("readonly","true"),L()(e).css("resize","none"),L()(t.root).css("opacity","75%")}}class ne{constructor(t,e){this.eventBus=t,this.dataManager=e,this.svgDisplay=Xt.createSvgDiv(t)}getLayout(){const t=new Zt(this.eventBus).getContainer(),e=this.generateDownloadControls(),n=new te(this.eventBus,this.dataManager).createContainer();return M.panel([this.svgDisplay,t,e,n],{style:{overflowX:"scroll",padding:"12px 24px"}})}generateDownloadControls(){return M.divH([this.createSavePatternButton(),this.createDownloadPngButton(),this.createShareLinkButton(),this.createInfoButton()],{style:{gap:"12px",marginTop:"12px"}})}createDownloadPngButton(){const t=M.button("Get PNG",(()=>this.eventBus.requestSvgSave()));return M.tooltip.bind(t,"Download pattern as PNG"),t}createInfoButton(){const t=M.button(M.iconFA("info-circle"),(()=>this.openInfoDialog()));return this.eventBus.patternHasUnsavedChanges$.subscribe((e=>{t.disabled=e})),M.tooltip.bind(t,"View pattern metadata"),t}async openInfoDialog(){let t=this.dataManager.getCurrentUserName(),e=this.dataManager.getDefaultPatternName(),n=K,o=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[j.AUTHOR_ID];if(t=(await r.dapi.users.find(i)).friendlyName,e=s[j.PATTERN_CONFIG][q.PATTERN_NAME],void 0!==s[j.DATE]){const t=s[j.DATE][W.CREATE];void 0!==t&&(n=t);const e=s[j.DATE][W.MODIFY];void 0!==e&&(o=e)}}}const s=M.divV([M.divText(`Pattern Name: ${e}`),M.divText(`Author: ${t}`),M.divText(`Created: ${oe(new Date(n))}`),M.divText(`Modified: ${oe(new Date(o))}`)]);r.shell.info(s)}createShareLinkButton(){const t=M.button(M.iconFA("link"),(()=>navigator.clipboard.writeText(window.location.href).then((()=>r.shell.info("Link to pattern copied to clipboard")))));return this.eventBus.patternHasUnsavedChanges$.subscribe((e=>{t.disabled=e})),M.tooltip.bind(t,"Share pattern link"),t}createSavePatternButton(){const t=M.button("Save",(()=>this.processSaveButtonClick()));return this.eventBus.patternHasUnsavedChanges$.subscribe((e=>{t.disabled=!e})),M.tooltip.bind(t,"Save pattern to user storage"),t}processSaveButtonClick(){const t=this.eventBus.getPatternName();t!==this.dataManager.getDefaultPatternName()?""!==t?this.dataManager.savePatternToUserStorage(this.eventBus).then((()=>{r.shell.info(`Pattern ${t} saved`)})).catch((t=>this.handleErrorWhileSavingPattern(t))):r.shell.warning("Insert pattern name"):r.shell.warning("Cannot save default pattern")}handleErrorWhileSavingPattern(t){t instanceof J?new re(this.eventBus,this.dataManager).show():t instanceof Q?r.shell.warning(M.div([M.divText("Pattern already exists"),M.button("Load",(()=>{const e=t.message;this.eventBus.requestLoadPatternInNewTab(e)}))])):console.error("Error while saving pattern",t)}}class re{constructor(t,e){this.eventBus=t,this.dataManager=e}show(){const t=this.eventBus.getPatternName(),e=M.dialog(`Pattern "${t}" already exists`);e.add(M.divText(`Pattern "${t}" already exists. Do you want to overwrite it?`)),e.show(),e.onOK((()=>this.processOverwriteNamesakePattern()))}processOverwriteNamesakePattern(){const t=this.eventBus.getPatternName();this.dataManager.overwriteExistingPatternInUserStorage(this.eventBus).then((()=>{r.shell.info(`Pattern ${t} overwritten`)})).catch((t=>{console.error("Error while overwriting pattern in user storage",t),r.shell.error("Error while overwriting pattern")}))}}function oe(t){return t.toLocaleString().split(":").slice(0,-1).join(":")}class ie extends B{constructor(t){super("Oligo Pattern"),this.th=t}getContent(){return async function(){const t=await tt.getInstance(),e=new ht,n=await async function(t,e){const n=e.getPatternHash();if(!n)return e.clearPatternURL(),t.getDefaultPatternRecord();let r=await t.getPatternRecordByHash(n);return r||(e.clearPatternURL(),r=t.getDefaultPatternRecord()),r}(t,e),r=new ut(t,n);e.subscribeToObservables(r);const o=new $t(r,t).getLayout(),i=new ne(r,t).getLayout();return M.splitH([o,i],{},!0)}()}}var se=n(8507),ae={};function le(t){var e;return"string"==typeof t||t instanceof String?t:("object"==typeof t||t instanceof Object)&&"$thrownJsError"in t?le(t.$thrownJsError):t instanceof Error?null!==(e=t.stack)&&void 0!==e?e:t.message:t.toString()}ae.styleTagTransform=xt(),ae.setAttributes=vt(),ae.insert=yt().bind(null,"head"),ae.domAPI=mt(),ae.insertStyleElement=wt(),ft()(se.A,ae),se.A&&se.A.locals&&se.A.locals;var ue,ce=n(2074),he={};he.styleTagTransform=xt(),he.setAttributes=vt(),he.insert=yt().bind(null,"head"),he.domAPI=mt(),he.insertStyleElement=wt(),ft()(ce.A,he),ce.A&&ce.A.locals&&ce.A.locals;class de{constructor(t,e,n=!0){this.textInputBase=t,this.painter=e,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=M.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 t=this.painter(this.textInputBase.value);this.highlights.innerHTML="",t.forEach((t=>this.highlights.appendChild(t)))}}!function(t){t.TYPE="V2000",t[t.NUM_OF_HEADER_LINES=3]="NUM_OF_HEADER_LINES",t[t.NUM_OF_COUNTS_DIGITS=3]="NUM_OF_COUNTS_DIGITS",t[t.ATOM_TYPE_COL=4]="ATOM_TYPE_COL",t[t.FIRST_BONDED_ATOM_COL=1]="FIRST_BONDED_ATOM_COL",t[t.BOND_TYPE_COL=3]="BOND_TYPE_COL",t[t.RGP_SHIFT=8]="RGP_SHIFT",t[t.MAX_ATOM_COUNT=999]="MAX_ATOM_COUNT",t.RGP_LINE_START="M RGP",t.ATOM_ALIAS_LINE_START="A ",t.END="M END"}(ue||(ue={}));class fe{constructor(t){this.init(t)}init(t){this.fileContent=t.replace(/\r/g,""),this._atomCount=void 0,this._atomTypes=void 0,this._bondCount=void 0,this._bondTypes=void 0,this.xyzAtomCoordinates=void 0,this._pairsOfBondedAtoms=void 0}get atomCount(){return void 0===this._atomCount&&this.setAtomAndBondCounts(),this._atomCount}get bondCount(){return void 0===this._bondCount&&this.setAtomAndBondCounts(),this._bondCount}get x(){var t;return null!==(t=this.xyzAtomCoordinates)&&void 0!==t||(this.xyzAtomCoordinates=this.parseAtomCoordinates()),this.xyzAtomCoordinates.x}get y(){var t;return null!==(t=this.xyzAtomCoordinates)&&void 0!==t||(this.xyzAtomCoordinates=this.parseAtomCoordinates()),this.xyzAtomCoordinates.y}get z(){var t;return null!==(t=this.xyzAtomCoordinates)&&void 0!==t||(this.xyzAtomCoordinates=this.parseAtomCoordinates()),this.xyzAtomCoordinates.z}get atomTypes(){var t;return null!==(t=this._atomTypes)&&void 0!==t||(this._atomTypes=this.parseAtomTypes()),this._atomTypes}get pairsOfBondedAtoms(){var t;return null!==(t=this._pairsOfBondedAtoms)&&void 0!==t||(this._pairsOfBondedAtoms=this.parseBondedAtomPairs()),this._pairsOfBondedAtoms}get bondTypes(){var t;return null!==(t=this._bondTypes)&&void 0!==t||(this._bondTypes=this.parseBondTypes()),this._bondTypes}setAtomAndBondCounts(){const{atomCount:t,bondCount:e}=this.parseAtomAndBondCounts();this._atomCount=t,this._bondCount=e}getNextColumnIdx(t){for(;!this.isWhitespace(t);)++t;for(;this.isWhitespace(t);)++t;return t}shiftIdxToSpecifiedColumn(t,e){let n=t;const r=this.isWhitespace(n)?e:e-1;for(let t=0;t<r;t++)n=this.getNextColumnIdx(n);return n}parseAtomTypes(){const t=this.atomCount,e=new Array(t);let n=this.getAtomBlockIdx();for(let r=0;r<t;r++)n=this.shiftIdxToAtomType(n),e[r]=this.parseAtomType(n),n=this.getNextLineIdx(n);return e}parseAtomCoordinates(){const t=new Float32Array(this.atomCount),e=new Float32Array(this.atomCount),n=new Float32Array(this.atomCount);let r=this.getAtomBlockIdx();for(let o=0;o<this.atomCount;o++){r=this.shiftIdxToXColumn(r);for(const i of[t,e,n])i[o]=this.parseFloatValue(r),r=this.getNextColumnIdx(r);r=this.getNextLineIdx(r)}return{x:t,y:e,z:n}}parseBondedAtomPairs(){const t=new Array(this.bondCount);let e=this.getBondBlockIdx();for(let n=0;n<this.bondCount;n++){e=this.shiftIdxToBondedAtomsPair(e);const r=new Uint16Array(2);r[0]=this.parseIntValue(e),e=this.getNextColumnIdx(e),r[1]=this.parseIntValue(e),t[n]=r,e=this.getNextLineIdx(e)}return t}parseBondTypes(){const t=this.bondCount,e=new Uint16Array(t);let n=this.getBondBlockIdx();for(let r=0;r<t;r++)n=this.shiftIdxToBondType(n),e[r]=this.parseIntValue(n),n=this.getNextLineIdx(n);return e}isWhitespace(t){const e=this.fileContent[t];return" "===e||"\t"===e}getNextLineIdx(t){return"\n"!==this.fileContent[t]?this.fileContent.indexOf("\n",t)+1:t+1}parseFloatValue(t){return this.parseNumericValue(parseFloat,t)}parseIntValue(t){return this.parseNumericValue(parseInt,t)}parseNumericValue(t,e){let n=e+1;for(;!this.isWhitespace(n);)++n;return t(this.fileContent.substring(e,n))}}class pe extends fe{constructor(t){super(t),this.init(t)}init(t){super.init(t)}parseAtomType(t){let e=t,n=e;return this.isQuote(e)?(n=this.getNextIdenticalChar(e),e++):n=this.fileContent.indexOf(" ",n),this.fileContent.substring(e,n)}isQuote(t){const e=this.fileContent[t].charCodeAt(0);return 39===e||34===e}getNextIdenticalChar(t){const e=this.fileContent[t];return e?this.fileContent.indexOf(e,t+1):-1}isQuery(){return this.isQueryOrFragment(((t,e)=>{return 39===t||34===t||76===t&&!((n=this.fileContent.charCodeAt(e+1))>64&&n<91||n>96&&n<123);var n}))}isFragment(){return this.isQueryOrFragment((t=>82===t||42===t))}isQueryOrFragment(t){const e=this.atomCount;let n=this.getAtomBlockIdx();for(let r=0;r<e;r++){if(n=this.shiftIdxToAtomType(n),t(this.fileContent.charCodeAt(n),n))return!0;n=this.getNextLineIdx(n)}return!1}}class me extends pe{constructor(t){super(t)}getAtomLines(){const t=this.getAtomBlockIdx(),e=this.getBondBlockIdx();return this.fileContent.substring(t,e).split("\n").slice(0,this.atomCount)}getBondLines(){const t=this.getBondBlockIdx();return this.fileContent.substring(t).split("\n").slice(0,this.bondCount)}getRGroupIdToAtomicIdxMap(){const t=new Map,e=this.fileContent.split("\n");e.filter((t=>t.startsWith(ue.RGP_LINE_START))).forEach((e=>{const n=this.getAtomIdxToRgpIdxList(e);for(const[e,r]of n){if(t.has(e))throw new Error(`R group ${e} is already in the map`);t.set(e,r)}}));const n=e.map(((t,e)=>{if(t.startsWith(ue.ATOM_ALIAS_LINE_START))return e})).filter((t=>void 0!==t)),r=n.map((t=>e[t])),o=n.map((t=>e[t+1]));r.forEach(((e,n)=>{const r=parseInt(e.split(/\s+/)[1])-1,i=parseInt(o[n].substring(1));if(t.has(i))throw new Error(`R group ${i} is already in the map`);t.set(i,r)}));const i=this.getRGroupAtomicIndices().filter((e=>!Array.from(t.values()).includes(e)));if(0!==i.length)throw new Error(`Unaccounted R group indices: ${i}`);return t}getAtomIdxToRgpIdxList(t){const e=t.split(/\s+/).filter((t=>t)).slice(3).map((t=>parseInt(t))),n=new Array(e.length/2);for(let t=0;t<e.length;t+=2)n[t/2]=[e[t+1],e[t]-1];return n}getRGroupAtomicIndices(){return this.atomTypes.map(((t,e)=>{if(t.includes("R#"))return e})).filter((t=>void 0!==t))}static isValidMolfile(t){return-1!==t.indexOf(ue.TYPE)&&-1!==t.indexOf(ue.END)}shiftIdxToAtomType(t){return this.shiftIdxToSpecifiedColumn(t,ue.ATOM_TYPE_COL)}getCountsLineIdx(){let t=0;for(let e=0;e<ue.NUM_OF_HEADER_LINES;++e)t=this.getNextLineIdx(t);return t}getAtomBlockIdx(){let t=this.getCountsLineIdx();return t=this.getNextLineIdx(t),t}shiftIdxToXColumn(t){return this.getNextColumnIdx(t)}shiftIdxToBondedAtomsPair(t){return this.shiftIdxToSpecifiedColumn(t,ue.FIRST_BONDED_ATOM_COL)}shiftIdxToBondType(t){return this.shiftIdxToSpecifiedColumn(t,ue.BOND_TYPE_COL)}getBondBlockIdx(){let t=this.getAtomBlockIdx();for(let e=0;e<this.atomCount;e++)t=this.getNextLineIdx(t);return t}parseAtomAndBondCounts(){let t=this.getCountsLineIdx(),e=t+ue.NUM_OF_COUNTS_DIGITS;const n=parseInt(this.fileContent.substring(t,e));return t=e,e+=ue.NUM_OF_COUNTS_DIGITS,{atomCount:n,bondCount:parseInt(this.fileContent.substring(t,e))}}}class ge extends pe{constructor(t){super(t),this.init(t)}getAtomLines(){const t=this.getAtomBlockIdx(),e=this.getBondBlockIdx();return this.fileContent.substring(t,e).split("\n").slice(0,this.atomCount)}getBondLines(){const t=this.getBondBlockIdx();return this.fileContent.substring(t).split("\n").slice(0,this.bondCount)}getRGroupIdToAtomicIdxMap(){const t=new Map;return this.getAtomLines().forEach(((e,n)=>{const r=e.match(/RGROUPS=\(([\d\s]+)\)/);if(r){const e=r[1].split(/\s+/).map((t=>parseInt(t)));if(e.length>2)throw new Error(`R group data ${e} has more than 2 elements`);const o=e[1];if(t.has(o))throw new Error(`R group ${o} is already in the map`);t.set(o,n)}})),t}shiftIdxToAtomType(t){return this.shiftIdxToSpecifiedColumn(t,4)}getCountsLineIdx(){return this.fileContent.indexOf("M V30 COUNTS ")}getAtomBlockIdx(){let t=this.fileContent.indexOf("M V30 BEGIN ATOM");return t=this.getNextLineIdx(t),t}shiftIdxToXColumn(t){let e=this.shiftIdxToAtomType(t);return this.isQuote(e)?(e=this.getNextIdenticalChar(e),e=this.getNextColumnIdx(e),e):this.shiftIdxToSpecifiedColumn(t,5)}shiftIdxToBondedAtomsPair(t){return this.shiftIdxToSpecifiedColumn(t,5)}shiftIdxToBondType(t){return this.shiftIdxToSpecifiedColumn(t,4)}getBondBlockIdx(){return this.getNextLineIdx(this.fileContent.indexOf("M V30 BEGIN BOND"))}static isValidMolfile(t){return-1!==t.indexOf("V3000")&&-1!==t.indexOf("M END")}parseAtomAndBondCounts(){let t=this.fileContent.indexOf("M V30 COUNTS ")+14,e=this.fileContent.indexOf(" ",t+1);const n=parseInt(this.fileContent.substring(t,e));return t=e+1,e=this.fileContent.indexOf(" ",t+1),{atomCount:n,bondCount:parseInt(this.fileContent.substring(t,e))}}}class ye{constructor(){}static getInstance(t){if(ye.isMolfileV2K(t))return new me(t);if(ye.isMolfileV3K(t))return new ge(t);throw new Error("Malformed molfile")}static isMolfileV2K(t){return me.isValidMolfile(t)}static isMolfileV3K(t){return ge.isValidMolfile(t)}}const be=class extends Error{constructor(t){super(t)}};class ve{constructor(t){this.molblock=t}get molblock(){return this._validMolBlock}set molblock(t){if(""!==t){try{this.validateMolBlock(t)}catch(e){e instanceof be&&(t="");const n=le(e);console.error(n)}this._validMolBlock=t}else this._validMolBlock=t}validateMolBlock(t){if(""===t)throw new be("MoleculeImage: invalid molblock")}async drawMolBlockOnCanvas(t){try{await r.functions.call("Chem:canvasMol",{x:0,y:0,w:t.width,h:t.height,canvas:t,molString:this.molblock,scaffoldMolString:"",options:{normalizeDepiction:!1,straightenDepiction:!1}})}catch(t){const e=le(t);console.error(e)}}getMoleculeDimensions(){const t=ye.getInstance(this.molblock),e=Math.max(...t.x)-Math.min(...t.x);return{height:Math.max(...t.y)-Math.min(...t.y),width:e}}async zoomIn(){const t=M.dialog({title:"Molecule",showFooter:!1}),e=.7*L()(window).height(),n=this.getMoleculeDimensions(),r=e/n.height,o=e,i=n.width*r,s=M.canvas(i,o);await this.drawMolBlockOnCanvas(s);const a=M.block([s],{style:{overflowX:"scroll"}});t.add(a).showModal(!0),L()(t.root).find(".d4-dialog-contents").removeClass("ui-form"),L()(t.root).find(".d4-dialog-contents").removeClass("ui-panel"),L()(t.root).find(".d4-dialog-contents").addClass("ui-box"),L()(t.root).find(".d4-dialog-contents").css("padding","0")}async drawMolecule(t,e,n){t.innerHTML="";const r=M.canvas(e*window.devicePixelRatio,n*window.devicePixelRatio);r.style.width=`${e}px`,r.style.height=`${n}px`,r.style.cursor="zoom-in",this.drawMolBlockOnCanvas(r),r.addEventListener("click",(async()=>{await this.zoomIn()})),t.append(M.tooltip.bind(r,"Click to zoom"))}}class Ce extends Error{constructor(t,e){super(t,e)}}class we{constructor(t,e){this.sequence=t,this.codeMap=e}parseSequence(){const t=this.parseRawSequence();return this.addLinkers(t)}addLinkers(t){const e=[];return t.forEach(((n,r)=>{const o=this.getSymbolForCode(n);r>0&&function(t){return xr.jsonData.monomersWithPhosphate.left.includes(t)}(o)&&e.pop(),e.push(o);const i=Ae(o),s=r===t.length-1,a=r+1<t.length&&Ae(this.getSymbolForCode(t[r+1]));i||function(t){return xr.jsonData.monomersWithPhosphate.right.includes(t)}(o)||a||s||e.push("p")})),e}getSymbolForCode(t){let e=this.codeMap.get(t);return e??(e=t),e}parseRawSequence(){const t=this.getAllCodesOfFormat(),e=[];let n=0;for(;n<this.sequence.length;){const r=t.find((t=>t===this.sequence.substring(n,n+t.length)));if(void 0===r)throw new Ce(`Unable to match a monomer for the rest of the sequence '${this.sequence.slice(n)}'.`);e.push(r),n+=r.length}return e}getAllCodesOfFormat(){return g(Array.from(this.codeMap.keys()))}}function Ae(t){return xr.jsonData.monomersWithPhosphate.phosphate.includes(t)}class xe{constructor(t,e=!1,n){this.invert=e,this.lib=xr.monomerLibWrapper;const r=this.lib.getCodeToSymbolMap(n);this.parser=new we(t,r)}convert(){const t=this.parser.parseSequence(),e=[];t.forEach(((t,n)=>{const r=this.getMonomerMolfile(t,n);e.push(r)}));let n=this.getPolymerMolfile(e);return this.invert&&(n=this.reflect(n),n=this.invertBondConfiguration(n)),n}invertBondConfiguration(t){const e=t.indexOf("M V30 BEGIN BOND"),n=t.indexOf("M V30 END BOND");let r=t.substring(e,n);return r=r.replace(/(CFG=)([13])/g,((t,e,n)=>"1"===n?`${e}3`:"3"===n?`${e}1`:t)),t.substring(0,e)+r+t.substring(n)}getMonomerMolfile(t,e){const n=this.lib.getMolfileBySymbol(t);return this.lib.isModification(t)?0===e?this.reflect(n):n:this.rotateNucleotidesV3000(n)}getPolymerMolfile(t){return this.linkV3000(t)}reflect(t){const e=this.extractAtomDataV3000(t),n=e.atomIndex.length,r=e.atomIndex.indexOf(1),o=e.atomIndex.indexOf(n),i=(e.x[o]+e.x[r])/2,s=(e.y[o]+e.y[r])/2;for(let t=0;t<n;t++)e.x[t]-=i,e.y[t]-=s;for(let t=0;t<n;t++)e.x[t]=-e.x[t];const a=e.x[r];for(let t=0;t<n;t++)e.x[t]-=a;let l=t.indexOf("M V30 BEGIN ATOM");l=t.indexOf("\n",l);let u=l;for(let r=0;r<n;r++)l=t.indexOf("V30",l)+4,l=t.indexOf(" ",l)+1,l=t.indexOf(" ",l)+1,u=t.indexOf(" ",l)+1,u=t.indexOf(" ",u),l=(t=t.slice(0,l)+e.x[r]+" "+e.y[r]+t.slice(u)).indexOf("\n",l)+1;return t}extractAtomDataV3000(t){const e=this.extractAtomsBondsNumbersV3000(t);let n=t.indexOf("M V30 BEGIN ATOM");n=t.indexOf("\n",n);let r=n;const o=Array(e.natom),i=Array(e.natom),s=Array(e.natom),a=Array(e.natom);for(let l=0;l<e.natom;l++)n=t.indexOf("V30",n)+4,r=t.indexOf(" ",n),o[l]=parseInt(t.substring(n,r)),n=r+1,r=t.indexOf(" ",n),i[l]=t.substring(n,r),n=r+1,r=t.indexOf(" ",n),s[l]=parseFloat(t.substring(n,r)),n=r+1,r=t.indexOf(" ",n),a[l]=parseFloat(t.substring(n,r)),n=t.indexOf("\n",n)+1;return{atomIndex:o,atomType:i,x:s,y:a}}extractAtomsBondsNumbersV3000(t){let e=(t=t.replaceAll("\r","")).indexOf("COUNTS")+7,n=t.indexOf(" ",e);const r=parseInt(t.substring(e,n));return e=n+1,n=t.indexOf(" ",e),{natom:r,nbond:parseInt(t.substring(e,n))}}rotateNucleotidesV3000(t){const e=this.extractAtomDataV3000(t),n=e.atomIndex.length,r=e.atomIndex.indexOf(1),o=e.atomIndex.indexOf(n);n>8&&this.fix5Prime(e,r,o);const i=(e.x[o]+e.x[r])/2,s=(e.y[o]+e.y[r])/2;for(let t=0;t<n;t++)e.x[t]-=i,e.y[t]-=s;let a=0;if(0===e.x[r])a=e.y[r]>e.y[o]?Math.PI/2:3*Math.PI/2;else if(0===e.y[r])a=e.x[r]>e.x[o]?Math.PI:0;else{const t=e.y[r]/e.x[r];a=t>0?e.x[r]>0?Math.PI-Math.atan(t):2*Math.PI-Math.atan(t):e.x[r]>0?-Math.PI-Math.atan(t):Math.atan(t)}const l=Math.cos(a),u=Math.sin(a);for(let t=0;t<n;t++){const n=e.x[t];e.x[t]=n*l-e.y[t]*u,e.y[t]=n*u+e.y[t]*l}const c=e.x[r];for(let t=0;t<n;t++)e.x[t]-=c;let h=t.indexOf("M V30 BEGIN ATOM");h=t.indexOf("\n",h);let d=h;for(let r=0;r<n;r++)h=t.indexOf("V30",h)+4,h=t.indexOf(" ",h)+1,h=t.indexOf(" ",h)+1,d=t.indexOf(" ",h)+1,d=t.indexOf(" ",d),h=(t=t.slice(0,h)+e.x[r]+" "+e.y[r]+t.slice(d)).indexOf("\n",h)+1;return t}linkV3000(t,e=!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 r="",o="",i="";const s=[];let a=0,l=0,u=0;for(let e=0;e<t.length;e++){const n=t[e].includes("MODIFICATION")&&0===e;let i=0;n&&(i=this.extractAtomDataV3000(t[e]).atomIndex.length),t[e]=t[e].replaceAll("(-\nM V30 ","(").replaceAll("-\nM V30 ","").replaceAll(" )",")");const c=this.extractAtomsBondsNumbersV3000(t[e]),h=this.extractAtomDataV3000(t[e]);let d=t[e].indexOf("M V30 BEGIN ATOM");d=t[e].indexOf("\n",d);let f=d,p=d;for(let r=0;r<c.natom;r++)if(1!==h.atomIndex[r]||0===e){f=t[e].indexOf("V30",f)+4,p=t[e].indexOf(" ",f);let r=0;n?(r=parseInt(t[e].substring(f,p)),1===r?r=i:r===i&&(r=1),r+=a):r=parseInt(t[e].substring(f,p))+a,t[e]=t[e].slice(0,f)+r+t[e].slice(p),f=t[e].indexOf(" ",f)+1,f=t[e].indexOf(" ",f)+1,p=t[e].indexOf(" ",f);const o=u-h.x[0];let s=Math.round(1e4*(parseFloat(t[e].substring(f,p))+o))/1e4;t[e]=t[e].slice(0,f)+s+t[e].slice(p),f=t[e].indexOf(" ",f)+1,p=t[e].indexOf(" ",f),s=Math.round(1e4*parseFloat(t[e].substring(f,p)))/1e4,t[e]=t[e].slice(0,f)+s+t[e].slice(p),f=t[e].indexOf("\n",f)+1}else f=t[e].indexOf("M V30",f)-1,p=t[e].indexOf("\n",f+1),t[e]=t[e].slice(0,f)+t[e].slice(p);const m=t[e].indexOf("M V30 END ATOM");r+=t[e].substring(d+1,m);let g=t[e].indexOf("M V30 BEGIN BOND");g=t[e].indexOf("\n",g),f=g,p=g;for(let r=0;r<c.nbond;r++){f=t[e].indexOf("V30",f)+4,p=t[e].indexOf(" ",f);const r=parseInt(t[e].substring(f,p))+l;t[e]=t[e].slice(0,f)+r+t[e].slice(p),f=t[e].indexOf(" ",f)+1,f=t[e].indexOf(" ",f)+1,p=t[e].indexOf(" ",f);let o=0;n?(o=parseInt(t[e].substring(f,p)),1===o?o=i:o===i&&(o=1),o+=a):o=parseInt(t[e].substring(f,p))+a,t[e]=t[e].slice(0,f)+o+t[e].slice(p),f=t[e].indexOf(" ",f)+1,p=Math.min(t[e].indexOf("\n",f),t[e].indexOf(" ",f)),o=0,n?(o=parseInt(t[e].substring(f,p)),1===o?o=i:o===i&&(o=1),o+=a):o=parseInt(t[e].substring(f,p))+a,t[e]=t[e].slice(0,f)+o+t[e].slice(p),f=t[e].indexOf("\n",f)+1}const y=t[e].indexOf("M V30 END BOND");o+=t[e].substring(g+1,y);let b=t[e].indexOf("M V30 MDLV30/STEABS ATOMS=(");for(;-1!==b;){b+=28;const n=t[e].indexOf(")",b);t[e].substring(b,n).split(" ").slice(1).forEach((t=>{s.push(parseInt(t)+a)})),b=n,b=t[e].indexOf("M V30 MDLV30/STEABS ATOMS=(",b)}a+=c.natom-1,l+=c.nbond,u+=n?Math.max(...h.x):h.x[c.natom-1]-h.x[0]}const c=Math.ceil(s.length/4);i+="M V30 MDLV30/STEABS ATOMS=("+s.length+" -\n";for(let t=0;t<c;t++){i+="M V30 ";const e=t+1===c?s.length-4*(c-1):4;for(let n=0;n<e;n++)i+=n+1===e?t===c-1?s[4*t+n]+")\n":s[4*t+n]+" -\n":s[4*t+n]+" "}return a++,n+="M V30 COUNTS "+a+" "+l+" 0 0 0\n",n+="M V30 BEGIN ATOM\n",n+=r,n+="M V30 END ATOM\n",n+="M V30 BEGIN BOND\n",n+=o,n+="M V30 END BOND\n",e&&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(t,e,n){const r=e+1,o=t.x[r],i=t.y[r],s=t.x[n]-o,a=t.y[n]-i,l=t.x[e]-o,u=t.y[e]-i,c=l*Math.cos(2*Math.PI/3)-u*Math.sin(2*Math.PI/3),h=l*Math.sin(2*Math.PI/3)+u*Math.cos(2*Math.PI/3),d=l-s,f=u-a,p=c-s,m=h-a;Math.sqrt(m*m+p*p)>=Math.sqrt(f*f+d*d)&&(t.x[e]=c+o,t.y[e]=h+i)}}function Ee(t,e=!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 r="",o="",i="";const s=[];let a=0,l=0,u=0;if(t.antiStrands.length>0)for(let e=0;e<t.antiStrands.length;e++)t.antiStrands[e]=Te(t.antiStrands[e]);let c=!1;const h=t.senseStrands.concat(t.antiStrands);let d=0;for(let e=0;e<h.length;e++){h[e]=h[e].replaceAll("(-\nM V30 ","(").replaceAll("-\nM V30 ","").replaceAll(" )",")");const n=Se(h[e]),i=Ie(h[e]);if(e>=t.senseStrands.length?!1===c&&(c=!0,u=0):d=Math.min(d,Math.min(...i.y.filter((t=>t<0)))),c){const t=Math.min(...i.x)-u,e=Math.max(...i.y)+5;for(let e=0;e<i.x.length;e++)i.x[e]-=t;for(let t=0;t<i.y.length;t++)i.y[t]-=e-d}let f=h[e].indexOf("M V30 BEGIN ATOM");f=h[e].indexOf("\n",f);let p=f,m=f;for(let t=0;t<n.natom;t++){p=h[e].indexOf("V30",p)+4,m=h[e].indexOf(" ",p);const n=parseInt(h[e].substring(p,m))+a;h[e]=h[e].slice(0,p)+n+h[e].slice(m),p=h[e].indexOf(" ",p)+1,p=h[e].indexOf(" ",p)+1,m=h[e].indexOf(" ",p);let r=Math.round(1e4*i.x[t])/1e4;h[e]=h[e].slice(0,p)+r+h[e].slice(m),p=h[e].indexOf(" ",p)+1,m=h[e].indexOf(" ",p),r=Math.round(1e4*i.y[t])/1e4,h[e]=h[e].slice(0,p)+r+h[e].slice(m),p=h[e].indexOf("\n",p)+1}const g=h[e].indexOf("M V30 END ATOM");r+=h[e].substring(f+1,g);let y=h[e].indexOf("M V30 BEGIN BOND");y=h[e].indexOf("\n",y),p=y,m=y;for(let t=0;t<n.nbond;t++){p=h[e].indexOf("V30",p)+4,m=h[e].indexOf(" ",p);const t=parseInt(h[e].substring(p,m))+l;h[e]=h[e].slice(0,p)+t+h[e].slice(m),p=h[e].indexOf(" ",p)+1,p=h[e].indexOf(" ",p)+1,m=h[e].indexOf(" ",p);let n=parseInt(h[e].substring(p,m))+a;h[e]=h[e].slice(0,p)+n+h[e].slice(m),p=h[e].indexOf(" ",p)+1,m=Math.min(h[e].indexOf("\n",p),h[e].indexOf(" ",p)),n=parseInt(h[e].substring(p,m))+a,h[e]=h[e].slice(0,p)+n+h[e].slice(m),p=h[e].indexOf("\n",p)+1}const b=h[e].indexOf("M V30 END BOND");o+=h[e].substring(y+1,b);let v=h[e].indexOf("M V30 MDLV30/STEABS ATOMS=(");for(;-1!==v;){v+=28;const t=h[e].indexOf(")",v);h[e].substring(v,t).split(" ").slice(1).forEach((t=>{s.push(parseInt(t)+a)})),v=t,v=h[e].indexOf("M V30 MDLV30/STEABS ATOMS=(",v)}a+=n.natom,l+=n.nbond,u+=Math.max(...i.x)+5}const f=Math.ceil(s.length/4);i+="M V30 MDLV30/STEABS ATOMS=("+s.length+" -\n";for(let t=0;t<f;t++){i+="M V30 ";const e=t+1===f?s.length-4*(f-1):4;for(let n=0;n<e;n++)i+=n+1===e?t===f-1?s[4*t+n]+")\n":s[4*t+n]+" -\n":s[4*t+n]+" "}return n+="M V30 COUNTS "+a+" "+l+" 0 0 0\n",n+="M V30 BEGIN ATOM\n",n+=r,n+="M V30 END ATOM\n",n+="M V30 BEGIN BOND\n",n+=o,n+="M V30 END BOND\n",e&&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 Te(t){const e=Ie(t),n=e.atomIndex.length,r=(Math.max(...e.x)+Math.min(...e.x))/2,o=(Math.max(...e.y)+Math.min(...e.y))/2;for(let t=0;t<n;t++)e.x[t]-=r,e.y[t]-=o;const i=Math.PI,s=Math.cos(i),a=Math.sin(i);for(let t=0;t<n;t++){const n=e.x[t];e.x[t]=n*s-e.y[t]*a,e.y[t]=n*a+e.y[t]*s}const l=Math.max(...e.y);for(let t=0;t<n;t++)e.x[t]+=r,e.y[t]-=l;let u=t.indexOf("M V30 BEGIN ATOM");u=t.indexOf("\n",u);let c=u;for(let r=0;r<n;r++)u=t.indexOf("V30",u)+4,u=t.indexOf(" ",u)+1,u=t.indexOf(" ",u)+1,c=t.indexOf(" ",u)+1,c=t.indexOf(" ",c),u=(t=t.slice(0,u)+e.x[r]+" "+e.y[r]+t.slice(c)).indexOf("\n",u)+1;return t}function Se(t){let e=(t=t.replaceAll("\r","")).indexOf("COUNTS")+7,n=t.indexOf(" ",e);const r=parseInt(t.substring(e,n));return e=n+1,n=t.indexOf(" ",e),{natom:r,nbond:parseInt(t.substring(e,n))}}function Ie(t){const e=Se(t);let n=t.indexOf("M V30 BEGIN ATOM");n=t.indexOf("\n",n);let r=n;const o=Array(e.natom),i=Array(e.natom),s=Array(e.natom),a=Array(e.natom);for(let l=0;l<e.natom;l++)n=t.indexOf("V30",n)+4,r=t.indexOf(" ",n),o[l]=parseInt(t.substring(n,r)),n=r+1,r=t.indexOf(" ",n),i[l]=t.substring(n,r),n=r+1,r=t.indexOf(" ",n),s[l]=parseFloat(t.substring(n,r)),n=r+1,r=t.indexOf(" ",n),a[l]=parseFloat(t.substring(n,r)),n=t.indexOf("\n",n)+1;return{atomIndex:o,atomType:i,x:s,y:a}}function _e(t,e,n){if(""===t)return"";const r=n.createFormatDetector(t).getFormat();if(!r)return"";let o="";try{o=new xe(t,e,r).convert()}catch(t){const e=le(t);console.error(e)}return o}function Ne(t,e,n,r,o){const i=[t,e,n].filter((t=>""!==t.strand));return 1===i.length?_e(i[0].strand,i[0].invert,o):Ee({senseStrands:[_e(t.strand,t.invert,o)],antiStrands:[_e(e.strand,e.invert,o),_e(n.strand,n.invert,o)].filter((t=>""!==t))},r)}const Me=["ss","as","as2"];class Pe{constructor(){this.th=xr,this.onInput=new et.Subject,this.onInvalidInput=new et.Subject,this.inputBase=Object.fromEntries(Me.map((t=>{const e=M.input.textArea(t.toUpperCase(),{value:"",onValueChanged:()=>{this.onInput.next(),L()(e.root.getElementsByTagName("div")).css("padding-left","38px")}});return[t,e]}))),this.useChiralInput=M.input.bool("Use chiral",{value:!0}),this.saveAllStrandsInput=M.input.bool("Save as one entity",{value:!0}),M.tooltip.bind(this.saveAllStrandsInput.root,"Save SDF with all strands in one molfile"),this.directionInversion=Object.fromEntries(Me.map((t=>[t,!1]))),this.moleculeImgDiv=M.block([]),L()(this.moleculeImgDiv).addClass("st-structure-mol-img"),o.debounce(this.onInput,300).subscribe((async()=>{await this.updateMoleculeImg()})),o.debounce(this.onInvalidInput,1e3).subscribe((async()=>{r.shell.warning("Insert Sense strand")}))}async getHtmlDivElement(t){const e=this.getTableInput(t),n=this.getBoolInputsAndButton();await this.updateMoleculeImg();const r=M.divH([n,this.moleculeImgDiv]);L()(r).addClass("st-structure-bottom");const o=M.divV([e,r]);return L()(o).addClass("st-structure-body"),o}getBoolInputsAndButton(){const t=M.buttonsInput([M.bigButton("Save SDF",(()=>{const t=this.getStrandData();!function(t,e,n,o,i,s){const a=[t.strand,e.strand,n.strand].filter((t=>""!==t));if(0===a.length||1===a.length&&""===t.strand)r.shell.warning("Enter SENSE_STRAND and optionally ANTISENSE_STRAND/AS2 to save SDF");else{let l;if(i)l=Ne(t,e,n,o,s)+"\n$$$$\n";else{const h=_e(t.strand,t.invert,s),d=_e(e.strand,e.invert,s),f=_e(n.strand,n.invert,s);l=h+"\n> <Sequence>\nSense Strand\n$$$$\n",d&&(l+=d+"\n> <Sequence>\nAnti Sense\n$$$$\n"),f&&(l+=f+"\n> <Sequence>\nAnti Sense 2\n$$$$\n")}const u=new Date;function c(t){return t>=10?t.toString():"0"+t.toString()}y(`SequenceTranslator-${u.getFullYear()+"-"+c(u.getMonth()+1)+"-"+c(u.getDate())+"_"+c(u.getHours())+"-"+c(u.getMinutes())+"-"+c(u.getSeconds())}.sdf`,encodeURIComponent(l))}}(t.ss,t.as,t.as2,this.useChiralInput.value,this.saveAllStrandsInput.value,this.th)}))]),e=[this.saveAllStrandsInput.root,this.useChiralInput.root,t],n=M.divV(e);for(const t of e)L()(t).addClass("st-structure-bool-button-block");return n}getTableInput(t){const e=Object.fromEntries(Me.map((e=>[e,new de(this.inputBase[e],t.highlightInvalidSubsequence)]))),n=Object.fromEntries(Me.map(((t,e)=>{const n=0===e?"5′ → 3′":"3′ → 5′";return[t,M.input.choice(`${t.toUpperCase()} direction`,{value:n,items:["5′ → 3′","3′ → 5′"]})]})));Me.forEach(((t,e)=>{n[t].onChanged.subscribe((n=>{let r="3′ → 5′"===n;e>0&&(r=!r),this.directionInversion[t]=r,this.onInput.next()}))}));const r=["Sense Strand","Anti Sense","Anti Sense 2"],o=new Map(Me.map(((t,e)=>[t,r[e]]))),i=(Object.fromEntries(Me.map((t=>[t,M.label(o.get(t))]))),Object.fromEntries(Me.map((t=>{const n=M.icons.delete((()=>{e[t].inputBase.value=""})),r=M.button(n,(()=>{}));return M.tooltip.bind(r,`Clear ${t.toUpperCase()}`),[t,n]})))),s=M.form([],"st-structure-inputs"),a=M.divV([],"st-structure-clear-buttons"),l=M.form([],"st-direction-inputs");for(const t of Me)s.append(this.inputBase[t].root),a.append(i[t]),l.append(n[t].root);return M.divH([s,a,l])}getStrandData(){return Object.fromEntries(Me.map((t=>{const e=this.directionInversion[t];return[t,{strand:this.inputBase[t].value.replace(/\s*/g,""),invert:e}]})))}getMolfile(t,e,n){return Ne(t,e,n,this.useChiralInput.value,this.th)}async updateMoleculeImg(){let t="";try{const e=this.getStrandData();Object.values(e).some((t=>""!==t.strand))&&(t=this.getMolfile(e.ss,e.as,e.as2))}catch(t){const e=le(t);console.error(e)}const e=new ve(t);await e.drawMolecule(this.moleculeImgDiv,650,150),L()(this.moleculeImgDiv).find("canvas").css("float","inherit")}}class Le extends B{constructor(t){super("Oligo Structure"),this.th=t,this.layout=new Pe}getContent(){return this.layout.getHtmlDivElement(this.th)}}var Oe=n(2003);async function Re(t){try{const e={overflowX:"scroll"},n=M.div([],{style:e}),o=Ie(t),i=.7*L()(window).height(),s=Math.max(...o.x)-Math.min(...o.x),a=Math.max(...o.y)-Math.min(...o.y),l=i/a,u=l*s,c=l*a,h=M.canvas(u*window.devicePixelRatio,c*window.devicePixelRatio);h.style.width=`${u}px`,h.style.height=`${c}px`,await async function(t,e){await r.functions.call("Chem:canvasMol",{x:0,y:0,w:t.width,h:t.height,canvas:t,molString:e,scaffoldMolString:"",options:{normalizeDepiction:!1,straightenDepiction:!1}})}(h,t),n.appendChild(h),M.dialog("Molecule").add(n).showModal(!0)}catch(t){const e=le(t);console.error(e)}}class De{static async view(){const t=xr.monomerLibWrapper.getTableForViewer();t.name="Monomer Library";const e=r.shell.addTableView(t);e.grid.props.allowEdit=!1,e.grid.onCellDoubleClick.subscribe((async t=>{const e=t.cell.value;"Molecule"===t.tableColumn?.semType&&await Re(e)}))}}var Fe=n(3480),Be=n(5067),$e=n(5254),ke={};ke.styleTagTransform=xt(),ke.setAttributes=vt(),ke.insert=yt().bind(null,"head"),ke.domAPI=mt(),ke.insertStyleElement=wt(),ft()($e.A,ke),$e.A&&$e.A.locals&&$e.A.locals;const He=["Sequence"];class Ge{constructor(t){this.th=t,this.inputFormats=Object.keys(xr.jsonData.codesToHelmDict).concat(m.NO.HELM),this.seqHelper=xr.seqHelper,this.onInput=new et.Subject,this.moleculeImgDiv=M.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=M.div([]),this.formatChoiceInput=M.input.choice("",{value:m.NO.HELM,items:this.inputFormats,onValueChanged:async(t,e)=>{this.format=t,this.updateTable(),await this.updateMolImg()}}),L()(this.formatChoiceInput.root.getElementsByTagName("select")[0]).css("width","20%"),this.sequenceInputBase=M.input.textArea("",{value:"Afcgacsu",onValueChanged:()=>{this.onInput.next()}}),this.init(),o.debounce(this.onInput,300).subscribe((async()=>{this.init(),this.formatChoiceInput.value=this.format,this.updateTable(),await this.updateMolImg()})),this.eventBus=je.getInstance()}async getHtmlElement(){const t=this.constructSingleSequenceControls(),e=this.constructBulkTranslationControls(),n=M.box(M.panel([t,e,M.block([M.box(this.moleculeImgDiv)])]));return this.formatChoiceInput.value=this.format,this.updateTable(),await this.updateMolImg(),n}constructBulkTranslationControls(){const t=M.h1("Bulk");M.tooltip.bind(t,"Bulk translation from table input");const e=new Ue(this.eventBus).createUIComponents(),n=M.input.choice("Input format",{value:m.NO.AXOLABS,items:this.inputFormats,onValueChanged:t=>this.eventBus.selectInputFormat(t)}),r=M.input.choice("Output format",{value:Be.qP,items:(0,Fe.OT)(this.th),onValueChanged:t=>this.eventBus.selectOutputFormat(t)}),o=this.createConvertBulkButton(),i=M.div([...e,n,r,o],"ui-form");return M.block25([t,i])}createConvertBulkButton(){const t=M.bigButton("Convert",(()=>this.processConvertBulkButtonClick()));return M.tooltip.bind(t,"Convert sequences from table input"),L()(t).css({float:"right","margin-top":"20px"}),t}processConvertBulkButtonClick(){const t=this.eventBus.getSelectedTable();if(!t)return void r.shell.warning("No table selected");const e=this.eventBus.getSelectedInputFormat(),n=this.eventBus.getSelectedOutputFormat(),i=this.eventBus.getSelectedColumn("Sequence");if(!i)return void r.shell.warning("No sequence column selected");const s=`${i.name} (${n})`,a=o.Column.fromList(o.TYPE.STRING,s,i.toList().map((t=>(0,Fe.C6)(t,e,n,this.th))));if(n===Be.qP||n===m.NO.HELM){a.semType=o.SEMTYPE.MACROMOLECULE;const t=n==Be.qP?Oe.Hi.FASTA:Oe.Hi.HELM;a.meta.units=t;const e=this.seqHelper.getSeqHandler(a);(n==Be.qP?this.seqHelper.setUnitsToFastaColumn:this.seqHelper.setUnitsToHelmColumn)(e)}t.columns.add(a),r.data.detectSemanticTypes(t),r.shell.v=r.shell.getTableView(t.name)}constructSingleSequenceControls(){const t=new de(this.sequenceInputBase,(t=>O(t,this.th))),e=M.button("Get SDF",(()=>{this.saveMolfile()}),"Save structure as SDF"),n=M.button("Copy SMILES",(()=>{this.copySmiles()}),"Copy SMILES for the sequence"),r=M.div([this.formatChoiceInput]),o=M.button(M.icons.delete((()=>{t.inputBase.value=""})),(()=>{}));M.tooltip.bind(o,"Clear input");const i={format:r,textInput:t.root,clearBtn:o},s=M.table([i],(t=>[t.format,t.textInput,t.clearBtn]));s.classList.add("st-translator-input-table");const a=M.block([this.outputTableDiv,e,n]);return M.block75([M.h1("Single sequence"),s,a])}saveMolfile(){const t=new xe(this.sequence,!1,this.formatChoiceInput.value).convert()+"\n$$$$";y(this.sequence+".sdf",encodeURIComponent(t))}copySmiles(){const t=o.chem.convert(this.molfile,o.chem.Notation.MolBlock,o.chem.Notation.Smiles);navigator.clipboard.writeText(t).then((()=>r.shell.info(Be.n_)))}updateTable(){this.outputTableDiv.innerHTML="";const t=this.format?this.th.createSequenceValidator(this.sequence).getInvalidCodeIndex(this.format):0,e=(0,Fe.bD)(this.sequence,t,this.format,this.th),n=[];for(const t of Object.keys(e)){const o="indexOfFirstInvalidChar"in e?M.divH([]):M.link(e[t],(()=>navigator.clipboard.writeText(e[t]).then((()=>r.shell.info(Be.n_)))),Be.U_,"");n.push({format:t,sequence:o})}const o=M.table(n,(t=>[t.format,t.sequence]),["FORMAT","SEQUENCE"]);this.outputTableDiv.append(o),this.outputTableDiv.classList.add("st-translator-output-table")}async updateMolImg(){const t=new ve(this.molfile);await t.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===m.NO.HELM){const t=this.th.createFormatConverter(this.sequence,this.format).convertTo(m.NO.AXOLABS);return new xe(t,!1,m.NO.AXOLABS).convert()}return new xe(this.sequence,!1,this.format).convert()}}class Ue{constructor(t){this.tableInputManager=new Ve(t),this.columnInputManager=new qe(t)}createUIComponents(){return[this.tableInputManager.getTableInputContainer(),this.columnInputManager.getColumnControlsContainer()]}}class Ve{constructor(t){this.eventBus=t,this.availableTables=[],this.tableInputContainer=M.div([]),this.subscribeToTableEvents(),this.refreshTableInput()}getTableInputContainer(){return this.tableInputContainer}subscribeToTableEvents(){r.events.onTableAdded.subscribe((t=>this.handleTableAdded(t))),r.events.onTableRemoved.subscribe((t=>this.handleTableRemoved(t))),this.eventBus.tableSelected$.subscribe((()=>this.handleTableChoice()))}getTableFromEventData(t){return t.args.dataFrame}handleTableAdded(t){const e=this.getTableFromEventData(t);this.availableTables.some((t=>t.name===e.name))||(this.availableTables.push(e),this.eventBus.selectTable(e),this.refreshTableInput())}handleTableRemoved(t){const e=this.getTableFromEventData(t);this.availableTables=this.availableTables.filter((t=>t.name!==e.name));const n=this.availableTables[0];this.eventBus.selectTable(n||null),this.refreshTableInput()}refreshTableInput(){const t=this.createTableInput();L()(this.tableInputContainer).empty(),this.tableInputContainer.append(t.root)}createTableInput(){const t=this.eventBus.getSelectedTable();return M.input.table("Table",{value:t,items:this.availableTables,onValueChanged:t=>{null!==t&&this.eventBus.selectTable(t)}})}handleTableChoice(){const t=this.eventBus.getSelectedTable();t&&(this.isTableDisplayed(t)||this.displayTable(t))}isTableDisplayed(t){return r.shell.tableNames.includes(t.name)}displayTable(t){const e=r.shell.v;r.shell.addTableView(t),r.shell.v=e}}class qe{constructor(t){this.eventBus=t,this.columnControlsContainer=M.div([]),this.eventBus.tableSelected$.subscribe((()=>this.handleTableChoice())),this.refreshColumnControls()}getColumnControlsContainer(){return this.columnControlsContainer}handleTableChoice(){this.refreshColumnControls()}refreshColumnControls(){const t=this.createColumnInputs();L()(this.columnControlsContainer).empty();const e=t.map((t=>t.root));this.columnControlsContainer.append(...e)}createColumnInputs(){const t=this.eventBus.getSelectedTable(),e=null!==t?t.columns.names().sort(((t,e)=>t.localeCompare(e))):[];return He.map((n=>this.createColumnInput(n,e,t)))}createColumnInput(t,e,n){const r=t.toLowerCase(),o=e.find((t=>t.toLowerCase().includes(r)))||e[0];return this.selectColumnIfTableNotNull(n,o,t),M.input.choice(`${t}`,{value:o,items:e,onValueChanged:e=>this.selectColumnIfTableNotNull(n,e,t)})}selectColumnIfTableNotNull(t,e,n){if(null!==t&&e){const r=t.col(e);r&&this.eventBus.selectColumn(n,r)}}}class je{constructor(){this._tableSelection$=new et.BehaviorSubject(null),this._columnSelection=Object.fromEntries(He.map((t=>[t,new et.BehaviorSubject(null)]))),this._inputFormatSelection$=new et.BehaviorSubject(m.NO.AXOLABS),this._outputFormatSelection$=new et.BehaviorSubject(Be.qP)}static getInstance(){return void 0===je._instance&&(je._instance=new je),je._instance}get tableSelected$(){return this._tableSelection$.asObservable()}getSelectedTable(){return this._tableSelection$.getValue()}selectTable(t){this._tableSelection$.next(t)}selectColumn(t,e){this._columnSelection[t].next(e)}getSelectedColumn(t){return this._columnSelection[t].getValue()}getSelectedInputFormat(){return this._inputFormatSelection$.getValue()}selectInputFormat(t){this._inputFormatSelection$.next(t)}selectOutputFormat(t){this._outputFormatSelection$.next(t)}getSelectedOutputFormat(){return this._outputFormatSelection$.getValue()}}class We extends B{constructor(t){super("Oligo Translator"),this.th=t,this.th=xr,this.layout=new Ge(this.th);const e=M.iconFA("book",De.view,"View monomer library");this.topPanel=[e],this.view.setRibbonPanels([this.topPanel])}getContent(){return this.layout.getHtmlElement()}}class ze extends B{constructor(t,e){super(t),this.content=e}getContent(){return Promise.resolve(this.content)}}class Ye extends F{constructor(t,e){super("Oligo Toolkit"),this.externalViewFactories=t,this.th=e;const n=this.getViewFactories(this.th);this.multiView=new o.MultiView({viewFactories:n})}getViewFactories(t){function e(e){o.View.create();const n=new e(t);return n.initView().catch((t=>console.error(`Failed to initialize ${e.name}: ${t}`))),()=>n.getView()}let n={TRANSLATOR:e(We),PATTERN:e(ie),STRUCTURE:e(Le)};return this.externalViewFactories&&(n=Object.assign({},n,this.externalViewFactories)),n}getCurrentPanePath(){let t=this.multiView.tabs.currentPane.name;return t=t.charAt(0).toUpperCase()+t.substring(1).toLowerCase(),`/apps/${xr.name}/OligoToolkit/${t}`}setUrl(){this.multiView.path=this.getCurrentPanePath()}async constructView(){return this.multiView.tabs.onTabChanged.subscribe((()=>this.setUrl())),this.setUrl(),this.multiView}}var Ke=n(8070);function Je(t){const e=M.input.textArea("",{value:""});return{coloredInput:new de(e,t.highlightInvalidSubsequence),codes:t.jsonData.codesToSymbolsDict}}var Qe=n(9124),Xe=n(9192),Ze=n(8312),tn=n(1991),en=n.n(tn);const nn="object"==typeof performance&&performance&&"function"==typeof performance.now?performance:Date,rn=new Set,on="object"==typeof process&&process?process:{},sn=(t,e,n,r)=>{"function"==typeof on.emitWarning?on.emitWarning(t,e,n,r):console.error(`[${n}] ${e}: ${t}`)};let an=globalThis.AbortController,ln=globalThis.AbortSignal;if(void 0===an){ln=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(t,e){this._onabort.push(e)}},an=class{constructor(){e()}signal=new ln;abort(t){if(!this.signal.aborted){this.signal.reason=t,this.signal.aborted=!0;for(const e of this.signal._onabort)e(t);this.signal.onabort?.(t)}}};let t="1"!==on.env?.LRU_CACHE_IGNORE_AC_WARNING;const e=()=>{t&&(t=!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",e))}}Symbol("type");const un=t=>t&&t===Math.floor(t)&&t>0&&isFinite(t),cn=t=>un(t)?t<=Math.pow(2,8)?Uint8Array:t<=Math.pow(2,16)?Uint16Array:t<=Math.pow(2,32)?Uint32Array:t<=Number.MAX_SAFE_INTEGER?hn:null:null;class hn extends Array{constructor(t){super(t),this.fill(0)}}class dn{heap;length;static#t=!1;static create(t){const e=cn(t);if(!e)return[];dn.#t=!0;const n=new dn(t,e);return dn.#t=!1,n}constructor(t,e){if(!dn.#t)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new e(t),this.length=0}push(t){this.heap[this.length++]=t}pop(){return this.heap[--this.length]}}class fn{#e;#n;#r;#o;#i;#s;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#a;#l;#u;#c;#h;#d;#f;#p;#m;#g;#y;#b;#v;#C;#w;#A;#x;static unsafeExposeInternals(t){return{starts:t.#v,ttls:t.#C,sizes:t.#b,keyMap:t.#u,keyList:t.#c,valList:t.#h,next:t.#d,prev:t.#f,get head(){return t.#p},get tail(){return t.#m},free:t.#g,isBackgroundFetch:e=>t.#E(e),backgroundFetch:(e,n,r,o)=>t.#T(e,n,r,o),moveToTail:e=>t.#S(e),indexes:e=>t.#I(e),rindexes:e=>t.#_(e),isStale:e=>t.#N(e)}}get max(){return this.#e}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.#r}get disposeAfter(){return this.#o}constructor(t){const{max:e=0,ttl:n,ttlResolution:r=1,ttlAutopurge:o,updateAgeOnGet:i,updateAgeOnHas:s,allowStale:a,dispose:l,disposeAfter:u,noDisposeOnSet:c,noUpdateTTL:h,maxSize:d=0,maxEntrySize:f=0,sizeCalculation:p,fetchMethod:m,memoMethod:g,noDeleteOnFetchRejection:y,noDeleteOnStaleGet:b,allowStaleOnFetchRejection:v,allowStaleOnFetchAbort:C,ignoreFetchAbort:w}=t;if(0!==e&&!un(e))throw new TypeError("max option must be a nonnegative integer");const A=e?cn(e):Array;if(!A)throw new Error("invalid max value: "+e);if(this.#e=e,this.#n=d,this.maxEntrySize=f||this.#n,this.sizeCalculation=p,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!==m&&"function"!=typeof m)throw new TypeError("fetchMethod must be a function if specified");if(this.#i=m,this.#A=!!m,this.#u=new Map,this.#c=new Array(e).fill(void 0),this.#h=new Array(e).fill(void 0),this.#d=new A(e),this.#f=new A(e),this.#p=0,this.#m=0,this.#g=dn.create(e),this.#a=0,this.#l=0,"function"==typeof l&&(this.#r=l),"function"==typeof u?(this.#o=u,this.#y=[]):(this.#o=void 0,this.#y=void 0),this.#w=!!this.#r,this.#x=!!this.#o,this.noDisposeOnSet=!!c,this.noUpdateTTL=!!h,this.noDeleteOnFetchRejection=!!y,this.allowStaleOnFetchRejection=!!v,this.allowStaleOnFetchAbort=!!C,this.ignoreFetchAbort=!!w,0!==this.maxEntrySize){if(0!==this.#n&&!un(this.#n))throw new TypeError("maxSize must be a positive integer if specified");if(!un(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#M()}if(this.allowStale=!!a,this.noDeleteOnStaleGet=!!b,this.updateAgeOnGet=!!i,this.updateAgeOnHas=!!s,this.ttlResolution=un(r)||0===r?r:1,this.ttlAutopurge=!!o,this.ttl=n||0,this.ttl){if(!un(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#P()}if(0===this.#e&&0===this.ttl&&0===this.#n)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#e&&!this.#n){const t="LRU_CACHE_UNBOUNDED";(t=>!rn.has(t))(t)&&(rn.add(t),sn("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",t,fn))}}getRemainingTTL(t){return this.#u.has(t)?1/0:0}#P(){const t=new hn(this.#e),e=new hn(this.#e);this.#C=t,this.#v=e,this.#L=(n,r,o=nn.now())=>{if(e[n]=0!==r?o:0,t[n]=r,0!==r&&this.ttlAutopurge){const t=setTimeout((()=>{this.#N(n)&&this.#O(this.#c[n],"expire")}),r+1);t.unref&&t.unref()}},this.#R=n=>{e[n]=0!==t[n]?nn.now():0},this.#D=(o,i)=>{if(t[i]){const s=t[i],a=e[i];if(!s||!a)return;o.ttl=s,o.start=a,o.now=n||r();const l=o.now-a;o.remainingTTL=s-l}};let n=0;const r=()=>{const t=nn.now();if(this.ttlResolution>0){n=t;const e=setTimeout((()=>n=0),this.ttlResolution);e.unref&&e.unref()}return t};this.getRemainingTTL=o=>{const i=this.#u.get(o);if(void 0===i)return 0;const s=t[i],a=e[i];return s&&a?s-((n||r())-a):1/0},this.#N=o=>{const i=e[o],s=t[o];return!!s&&!!i&&(n||r())-i>s}}#R=()=>{};#D=()=>{};#L=()=>{};#N=()=>!1;#M(){const t=new hn(this.#e);this.#l=0,this.#b=t,this.#F=e=>{this.#l-=t[e],t[e]=0},this.#B=(t,e,n,r)=>{if(this.#E(e))return 0;if(!un(n)){if(!r)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 r)throw new TypeError("sizeCalculation must be a function");if(n=r(e,t),!un(n))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}return n},this.#$=(e,n,r)=>{if(t[e]=n,this.#n){const n=this.#n-t[e];for(;this.#l>n;)this.#k(!0)}this.#l+=t[e],r&&(r.entrySize=n,r.totalCalculatedSize=this.#l)}}#F=t=>{};#$=(t,e,n)=>{};#B=(t,e,n,r)=>{if(n||r)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#I({allowStale:t=this.allowStale}={}){if(this.#a)for(let e=this.#m;this.#H(e)&&(!t&&this.#N(e)||(yield e),e!==this.#p);)e=this.#f[e]}*#_({allowStale:t=this.allowStale}={}){if(this.#a)for(let e=this.#p;this.#H(e)&&(!t&&this.#N(e)||(yield e),e!==this.#m);)e=this.#d[e]}#H(t){return void 0!==t&&this.#u.get(this.#c[t])===t}*entries(){for(const t of this.#I())void 0===this.#h[t]||void 0===this.#c[t]||this.#E(this.#h[t])||(yield[this.#c[t],this.#h[t]])}*rentries(){for(const t of this.#_())void 0===this.#h[t]||void 0===this.#c[t]||this.#E(this.#h[t])||(yield[this.#c[t],this.#h[t]])}*keys(){for(const t of this.#I()){const e=this.#c[t];void 0===e||this.#E(this.#h[t])||(yield e)}}*rkeys(){for(const t of this.#_()){const e=this.#c[t];void 0===e||this.#E(this.#h[t])||(yield e)}}*values(){for(const t of this.#I())void 0===this.#h[t]||this.#E(this.#h[t])||(yield this.#h[t])}*rvalues(){for(const t of this.#_())void 0===this.#h[t]||this.#E(this.#h[t])||(yield this.#h[t])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(t,e={}){for(const n of this.#I()){const r=this.#h[n],o=this.#E(r)?r.__staleWhileFetching:r;if(void 0!==o&&t(o,this.#c[n],this))return this.get(this.#c[n],e)}}forEach(t,e=this){for(const n of this.#I()){const r=this.#h[n],o=this.#E(r)?r.__staleWhileFetching:r;void 0!==o&&t.call(e,o,this.#c[n],this)}}rforEach(t,e=this){for(const n of this.#_()){const r=this.#h[n],o=this.#E(r)?r.__staleWhileFetching:r;void 0!==o&&t.call(e,o,this.#c[n],this)}}purgeStale(){let t=!1;for(const e of this.#_({allowStale:!0}))this.#N(e)&&(this.#O(this.#c[e],"expire"),t=!0);return t}info(t){const e=this.#u.get(t);if(void 0===e)return;const n=this.#h[e],r=this.#E(n)?n.__staleWhileFetching:n;if(void 0===r)return;const o={value:r};if(this.#C&&this.#v){const t=this.#C[e],n=this.#v[e];if(t&&n){const e=t-(nn.now()-n);o.ttl=e,o.start=Date.now()}}return this.#b&&(o.size=this.#b[e]),o}dump(){const t=[];for(const e of this.#I({allowStale:!0})){const n=this.#c[e],r=this.#h[e],o=this.#E(r)?r.__staleWhileFetching:r;if(void 0===o||void 0===n)continue;const i={value:o};if(this.#C&&this.#v){i.ttl=this.#C[e];const t=nn.now()-this.#v[e];i.start=Math.floor(Date.now()-t)}this.#b&&(i.size=this.#b[e]),t.unshift([n,i])}return t}load(t){this.clear();for(const[e,n]of t){if(n.start){const t=Date.now()-n.start;n.start=nn.now()-t}this.set(e,n.value,n)}}set(t,e,n={}){if(void 0===e)return this.delete(t),this;const{ttl:r=this.ttl,start:o,noDisposeOnSet:i=this.noDisposeOnSet,sizeCalculation:s=this.sizeCalculation,status:a}=n;let{noUpdateTTL:l=this.noUpdateTTL}=n;const u=this.#B(t,e,n.size||0,s);if(this.maxEntrySize&&u>this.maxEntrySize)return a&&(a.set="miss",a.maxEntrySizeExceeded=!0),this.#O(t,"set"),this;let c=0===this.#a?void 0:this.#u.get(t);if(void 0===c)c=0===this.#a?this.#m:0!==this.#g.length?this.#g.pop():this.#a===this.#e?this.#k(!1):this.#a,this.#c[c]=t,this.#h[c]=e,this.#u.set(t,c),this.#d[this.#m]=c,this.#f[c]=this.#m,this.#m=c,this.#a++,this.#$(c,u,a),a&&(a.set="add"),l=!1;else{this.#S(c);const n=this.#h[c];if(e!==n){if(this.#A&&this.#E(n)){n.__abortController.abort(new Error("replaced"));const{__staleWhileFetching:e}=n;void 0===e||i||(this.#w&&this.#r?.(e,t,"set"),this.#x&&this.#y?.push([e,t,"set"]))}else i||(this.#w&&this.#r?.(n,t,"set"),this.#x&&this.#y?.push([n,t,"set"]));if(this.#F(c),this.#$(c,u,a),this.#h[c]=e,a){a.set="replace";const t=n&&this.#E(n)?n.__staleWhileFetching:n;void 0!==t&&(a.oldValue=t)}}else a&&(a.set="update")}if(0===r||this.#C||this.#P(),this.#C&&(l||this.#L(c,r,o),a&&this.#D(a,c)),!i&&this.#x&&this.#y){const t=this.#y;let e;for(;e=t?.shift();)this.#o?.(...e)}return this}pop(){try{for(;this.#a;){const t=this.#h[this.#p];if(this.#k(!0),this.#E(t)){if(t.__staleWhileFetching)return t.__staleWhileFetching}else if(void 0!==t)return t}}finally{if(this.#x&&this.#y){const t=this.#y;let e;for(;e=t?.shift();)this.#o?.(...e)}}}#k(t){const e=this.#p,n=this.#c[e],r=this.#h[e];return this.#A&&this.#E(r)?r.__abortController.abort(new Error("evicted")):(this.#w||this.#x)&&(this.#w&&this.#r?.(r,n,"evict"),this.#x&&this.#y?.push([r,n,"evict"])),this.#F(e),t&&(this.#c[e]=void 0,this.#h[e]=void 0,this.#g.push(e)),1===this.#a?(this.#p=this.#m=0,this.#g.length=0):this.#p=this.#d[e],this.#u.delete(n),this.#a--,e}has(t,e={}){const{updateAgeOnHas:n=this.updateAgeOnHas,status:r}=e,o=this.#u.get(t);if(void 0!==o){const t=this.#h[o];if(this.#E(t)&&void 0===t.__staleWhileFetching)return!1;if(!this.#N(o))return n&&this.#R(o),r&&(r.has="hit",this.#D(r,o)),!0;r&&(r.has="stale",this.#D(r,o))}else r&&(r.has="miss");return!1}peek(t,e={}){const{allowStale:n=this.allowStale}=e,r=this.#u.get(t);if(void 0===r||!n&&this.#N(r))return;const o=this.#h[r];return this.#E(o)?o.__staleWhileFetching:o}#T(t,e,n,r){const o=void 0===e?void 0:this.#h[e];if(this.#E(o))return o;const i=new an,{signal:s}=n;s?.addEventListener("abort",(()=>i.abort(s.reason)),{signal:i.signal});const a={signal:i.signal,options:n,context:r},l=(r,o=!1)=>{const{aborted:s}=i.signal,l=n.ignoreFetchAbort&&void 0!==r;if(n.status&&(s&&!o?(n.status.fetchAborted=!0,n.status.fetchError=i.signal.reason,l&&(n.status.fetchAbortIgnored=!0)):n.status.fetchResolved=!0),s&&!l&&!o)return u(i.signal.reason);const h=c;return this.#h[e]===c&&(void 0===r?h.__staleWhileFetching?this.#h[e]=h.__staleWhileFetching:this.#O(t,"fetch"):(n.status&&(n.status.fetchUpdated=!0),this.set(t,r,a.options))),r},u=r=>{const{aborted:o}=i.signal,s=o&&n.allowStaleOnFetchAbort,a=s||n.allowStaleOnFetchRejection,l=a||n.noDeleteOnFetchRejection,u=c;if(this.#h[e]===c&&(l&&void 0!==u.__staleWhileFetching?s||(this.#h[e]=u.__staleWhileFetching):this.#O(t,"fetch")),a)return n.status&&void 0!==u.__staleWhileFetching&&(n.status.returnedStale=!0),u.__staleWhileFetching;if(u.__returned===u)throw r};n.status&&(n.status.fetchDispatched=!0);const c=new Promise(((e,r)=>{const s=this.#i?.(t,o,a);s&&s instanceof Promise&&s.then((t=>e(void 0===t?void 0:t)),r),i.signal.addEventListener("abort",(()=>{n.ignoreFetchAbort&&!n.allowStaleOnFetchAbort||(e(void 0),n.allowStaleOnFetchAbort&&(e=t=>l(t,!0)))}))})).then(l,(t=>(n.status&&(n.status.fetchRejected=!0,n.status.fetchError=t),u(t)))),h=Object.assign(c,{__abortController:i,__staleWhileFetching:o,__returned:void 0});return void 0===e?(this.set(t,h,{...a.options,status:void 0}),e=this.#u.get(t)):this.#h[e]=h,h}#E(t){if(!this.#A)return!1;const e=t;return!!e&&e instanceof Promise&&e.hasOwnProperty("__staleWhileFetching")&&e.__abortController instanceof an}async fetch(t,e={}){const{allowStale:n=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,ttl:i=this.ttl,noDisposeOnSet:s=this.noDisposeOnSet,size:a=0,sizeCalculation:l=this.sizeCalculation,noUpdateTTL:u=this.noUpdateTTL,noDeleteOnFetchRejection:c=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:h=this.allowStaleOnFetchRejection,ignoreFetchAbort:d=this.ignoreFetchAbort,allowStaleOnFetchAbort:f=this.allowStaleOnFetchAbort,context:p,forceRefresh:m=!1,status:g,signal:y}=e;if(!this.#A)return g&&(g.fetch="get"),this.get(t,{allowStale:n,updateAgeOnGet:r,noDeleteOnStaleGet:o,status:g});const b={allowStale:n,updateAgeOnGet:r,noDeleteOnStaleGet:o,ttl:i,noDisposeOnSet:s,size:a,sizeCalculation:l,noUpdateTTL:u,noDeleteOnFetchRejection:c,allowStaleOnFetchRejection:h,allowStaleOnFetchAbort:f,ignoreFetchAbort:d,status:g,signal:y};let v=this.#u.get(t);if(void 0===v){g&&(g.fetch="miss");const e=this.#T(t,v,b,p);return e.__returned=e}{const e=this.#h[v];if(this.#E(e)){const t=n&&void 0!==e.__staleWhileFetching;return g&&(g.fetch="inflight",t&&(g.returnedStale=!0)),t?e.__staleWhileFetching:e.__returned=e}const o=this.#N(v);if(!m&&!o)return g&&(g.fetch="hit"),this.#S(v),r&&this.#R(v),g&&this.#D(g,v),e;const i=this.#T(t,v,b,p),s=void 0!==i.__staleWhileFetching&&n;return g&&(g.fetch=o?"stale":"refresh",s&&o&&(g.returnedStale=!0)),s?i.__staleWhileFetching:i.__returned=i}}async forceFetch(t,e={}){const n=await this.fetch(t,e);if(void 0===n)throw new Error("fetch() returned undefined");return n}memo(t,e={}){const n=this.#s;if(!n)throw new Error("no memoMethod provided to constructor");const{context:r,forceRefresh:o,...i}=e,s=this.get(t,i);if(!o&&void 0!==s)return s;const a=n(t,s,{options:i,context:r});return this.set(t,a,i),a}get(t,e={}){const{allowStale:n=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,status:i}=e,s=this.#u.get(t);if(void 0!==s){const e=this.#h[s],a=this.#E(e);return i&&this.#D(i,s),this.#N(s)?(i&&(i.get="stale"),a?(i&&n&&void 0!==e.__staleWhileFetching&&(i.returnedStale=!0),n?e.__staleWhileFetching:void 0):(o||this.#O(t,"expire"),i&&n&&(i.returnedStale=!0),n?e:void 0)):(i&&(i.get="hit"),a?e.__staleWhileFetching:(this.#S(s),r&&this.#R(s),e))}i&&(i.get="miss")}#G(t,e){this.#f[e]=t,this.#d[t]=e}#S(t){t!==this.#m&&(t===this.#p?this.#p=this.#d[t]:this.#G(this.#f[t],this.#d[t]),this.#G(this.#m,t),this.#m=t)}delete(t){return this.#O(t,"delete")}#O(t,e){let n=!1;if(0!==this.#a){const r=this.#u.get(t);if(void 0!==r)if(n=!0,1===this.#a)this.#U(e);else{this.#F(r);const n=this.#h[r];if(this.#E(n)?n.__abortController.abort(new Error("deleted")):(this.#w||this.#x)&&(this.#w&&this.#r?.(n,t,e),this.#x&&this.#y?.push([n,t,e])),this.#u.delete(t),this.#c[r]=void 0,this.#h[r]=void 0,r===this.#m)this.#m=this.#f[r];else if(r===this.#p)this.#p=this.#d[r];else{const t=this.#f[r];this.#d[t]=this.#d[r];const e=this.#d[r];this.#f[e]=this.#f[r]}this.#a--,this.#g.push(r)}}if(this.#x&&this.#y?.length){const t=this.#y;let e;for(;e=t?.shift();)this.#o?.(...e)}return n}clear(){return this.#U("delete")}#U(t){for(const e of this.#_({allowStale:!0})){const n=this.#h[e];if(this.#E(n))n.__abortController.abort(new Error("deleted"));else{const r=this.#c[e];this.#w&&this.#r?.(n,r,t),this.#x&&this.#y?.push([n,r,t])}}if(this.#u.clear(),this.#h.fill(void 0),this.#c.fill(void 0),this.#C&&this.#v&&(this.#C.fill(0),this.#v.fill(0)),this.#b&&this.#b.fill(0),this.#p=0,this.#m=0,this.#g.length=0,this.#l=0,this.#a=0,this.#x&&this.#y){const t=this.#y;let e;for(;e=t?.shift();)this.#o?.(...e)}}}function pn(){var t;return null!==(t=window.$monomerHover)&&void 0!==t?t:null}function mn(t){window.$monomerHover=t}function gn(t,e){let n=t["substruct-providers"];n||(n=t["substruct-providers"]=[]),n.push(e),t["substruct-providers"]=n}var yn=n(6077),bn=n(3561),vn=n(9235);const Cn="MonomerHoverLinks";function wn(t,e){let n=t[Cn];n||(n=t[Cn]=[]),n.push(e),t[Cn]=n}function An(t,e){try{const n=t.tableColumn;if(!n)return;const r=function(t){return t.temp[Cn]??[]}(n);for(let n=r.length-1;n>=0;--n){const o=r[n],i=t.grid.col(o.targetCol.name);if(i&&!o.handler(t,e,i))break}}catch(t){console.error(t)}}var xn=n(6717),En=n(6694),Tn=n(4229),Sn=n(5174);function In(t,e=!0){const[n,o]=(0,Xe.AP)(t);return xr.logger.error(n,void 0,o),e&&r.shell.error(n),[n,o]}async function _n(){return(await(0,l.pj)()).getAvaliableLibraryNames()}const Nn={symbol:"Short Name",name:"Medium Name",smiles:"SMILES"},Mn=[{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"}],Pn="Get HELM",Ln="Chirality engine",On="Highlight monomers",Rn="Poly Tool Conversion",Dn="Poly Tool Enumeration",Fn="Rules used";var Bn=n(5412);async function $n(t){await xr.initPromise;try{const e=await async function(t){const e=[],n=()=>{for(const t of e)t.unsubscribe()};try{const[i,s]=await Promise.all([_n(),(0,Qe.b2)()]),a=t&&t.rowIndex>=0?t.value:"\n\n\n 22 24 0 0 0 0 0 0 0 0999 V2000\n 0.3128 -0.7509 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n 0.3128 0.0740 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n -0.4054 -1.1623 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n -1.1081 -0.7509 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n -0.4054 0.4877 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0\n -1.1081 0.0740 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n -1.8175 -1.1623 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n 1.0222 0.4877 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n -1.8175 0.4877 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n -2.5292 -0.7509 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n 1.0222 1.3127 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n 1.7227 1.7263 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n -0.4054 -1.9896 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0\n -2.5292 0.0740 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n 2.4544 1.3127 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n 1.7406 0.0740 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n 1.0222 -1.1623 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0\n 2.4544 0.4877 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n -1.8175 -1.9896 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0\n -3.2453 0.4877 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0\n 3.1670 1.7285 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0\n 1.7149 2.5513 0.0000 R# 0 0 0 0 0 0 0 0 0 0 0 0\n 2 1 2 0 0 0 0\n 3 1 1 0 0 0 0\n 4 3 1 0 0 0 0\n 5 2 1 0 0 0 0\n 6 5 1 0 0 0 0\n 7 4 1 0 0 0 0\n 8 2 1 0 0 0 0\n 9 6 1 0 0 0 0\n 10 7 2 0 0 0 0\n 11 8 2 0 0 0 0\n 12 11 1 0 0 0 0\n 13 3 2 0 0 0 0\n 14 9 2 0 0 0 0\n 15 18 1 0 0 0 0\n 16 8 1 0 0 0 0\n 17 1 1 0 0 0 0\n 18 16 2 0 0 0 0\n 19 7 1 0 0 0 0\n 20 14 1 0 0 0 0\n 6 4 2 0 0 0 0\n 15 12 2 0 0 0 0\n 14 10 1 0 0 0 0\n 15 21 1 0 0 0 0\n 12 22 1 0 0 0 0\nM RGP 1 22 1\nM END";let u=await(async()=>o.chem.isMolBlock(a)?a:await r.functions.call("Chem:convertMolNotation",{molecule:a,sourceNotation:t?.column.getTag(o.TAGS.UNITS)??o.chem.Notation.Unknown,targetNotation:o.chem.Notation.MolBlock}))();const c=new o.chem.Sketcher(o.chem.SKETCHER_MODE.EXTERNAL);c.syncCurrentObject=!1,c.onChanged.subscribe((t=>{u=c.getMolFile()})),c.root.classList.add("ui-input-editor"),c.root.style.marginTop="3px",c.setMolFile(u);const h=M.input.choice("Library to use",{value:null,items:i});c.root.setAttribute("style","min-width:250px!important;"),c.root.setAttribute("style","max-width:250px!important;"),h.input.setAttribute("style","min-width:250px!important;");const d=M.div([c.root,h.root]);e.push(r.events.onCurrentCellChanged.subscribe((()=>{const t=r.shell.tv.dataFrame.currentCell;t.column.semType===o.SEMTYPE.MOLECULE&&c.setValue(t.value)})));const f=async()=>{try{const t=c.getMolFile();if(void 0===t||""===t)r.shell.warning("PolyTool: no molecule was provided");else if(t.includes("R#")){const e=await async function(t,e){const n=await async function(t){const e=await(0,l.pj)(),n=await e.readSingleLibraryByName(t);return n?n.getMonomerSymbolsByType("PEPTIDE"):(xr.logger.error(`Monomer library '${t}' not found.`),[])}(e),o=await async function(t){const e=await(0,l.pj)(),n=await e.readSingleLibraryByName(t);if(!n)return xr.logger.error(`Monomer library '${t}' not found.`),{};const r=n.getMonomerSymbolsByType("PEPTIDE");return new Array(r.length),n.getMonomerMolsByPolymerType("PEPTIDE")}(e),i=new Array(n.length),s=await r.functions.call("Chem:getRdKitModule"),a=s.get_mol(t),u=a.get_smiles();a.delete();const c=new Array(n.length);for(let t=0;t<n.length;t++){const e=o[n[t]],r=s.get_mol(e);c[t]=r.get_smiles(),r.delete()}for(let t=0;t<n.length;t++){let e=null;try{const n=`${`${u}.${c[t]}`.replaceAll("[1*]C","C([1*])").replaceAll("[1*]c","c([1*])").replaceAll("[1*]O","O([1*])").replaceAll("[1*]N","N([1*])")}`.replaceAll("([1*])","9").replaceAll("[1*]","9");e=s.get_mol(n,JSON.stringify({mappedDummiesAreRGroups:!0}));const r=e.get_v3Kmolblock();i[t]=r}catch(e){i[t]=""}finally{e?.delete()}}return i}(t,h.value),n=o.Column.fromStrings("Enumerated",e),i=o.DataFrame.fromColumns([n]);r.shell.addTableView(i)}else r.shell.warning("PolyTool: no R group was provided")}catch(t){In(t)}},p=M.dialog(Dn).add(d).onOK((()=>{f().finally((()=>{n()}))})).onCancel((()=>{n()}));return e.push(p.onClose.subscribe((()=>{n()}))),p.history((()=>({mol:c.getMolFile(),screenLibrary:h.value})),(t=>{c.setMolFile(t.mol),h.value=t.screenLibrary})),p}catch(t){throw n(),t}}(t);e.show({resizable:!0})}catch(t){r.shell.warning("To run PolyTool Enumeration, sketch the molecule and specify the R group to vary")}}async function kn(t,e,n,i,s,a){const l=o.TaskBarProgressIndicator.create("PolyTool converting...");try{const l=(t,e)=>t?t.columns.getUnusedName(e):e,u=await(0,Qe.b2)(),c=t.dataFrame,h=await(0,En.Q4)(a),[d,f,p]=(0,Tn.b)(t.toList(),h,u),m=l(c,`transformed(${t.name})`),g=o.Column.fromType(o.COLUMN_TYPE.STRING,m,d.length).init((t=>d[t]));g.semType=o.SEMTYPE.MACROMOLECULE,g.meta.units=Oe.Hi.HELM,g.setTag(o.TAGS.CELL_RENDERER,"helm"),e&&c&&c.columns.add(g,!0);const y=await(0,xn.j)(),b=await(0,Ze.Q)(),v=await(0,Sn.A)(h),C=g.temp;C[".mm.cellRenderer.overriddenLibrary"]=v,g.temp=C;const w=await(0,Bn.m)(g,d,f,i,s,n,v,y,b);return w.name=l(c,`molfile(${t.name})`),w.semType=o.SEMTYPE.MOLECULE,c&&(c.columns.add(w,!0),await r.data.detectSemanticTypes(c)),function(t,e,n,r,o,i,s){const a=new fn({max:100});function l(t,e){const n=t.get(e);if(null==n)return null;let s=a.get(n);return s||a.set(n,s=function(t,e){const n=o.getSeqHandler(t),s=n.getSplitted(e),a=n.defaultBiotype,l=en().count(0).take(s.length).map((t=>({position:t,symbol:s.getCanonical(t),biotype:a}))).toArray(),u=n.alphabet,c=u==Oe.YI.RNA||u==Oe.YI.DNA?"RNA":"PEPTIDE",h=(0,yn.eM)([l],c,u,r,i);return(0,bn.gU)(l,h,u,c).monomers}(t,e)),s}const u={targetCol:n,handler:(t,n,o)=>{if(!t||!o.grid||!e.dataFrame)return!0;const i=o.grid,a=t.tableRowIndex,u=t.gridRow,c=i.cell(o.name,u),h=s[u],d=pn();if(!d||d&&(d.dataFrameId!=e.dataFrame?.id||d.gridRowIdx!=u||d.seqColName!=e.name||d.seqPosition!=n?.position)){if(d&&(mn(null),d.gridCell.render()),!n)return mn(null),!0;mn({gridCell:c,dataFrameId:e.dataFrame.id,gridRowIdx:u,seqColName:e.name,seqPosition:n?n.position:-1,getSubstruct:()=>{if(!n||"*"===n.symbol)return;const t=l(e,a);if(!t)return;const o=[],i=h[n.position];for(const e of i){const n=t.get(e);if(!n)return{atoms:[],bonds:[],highlightAtomColors:[],highlightBondColors:[]};o.push((0,vn.H)([n],r))}return function(t){var e,n,r,o;const i={atoms:[],bonds:[],highlightAtomColors:{},highlightBondColors:{}};for(const s of t)i.atoms=[...null!==(e=i.atoms)&&void 0!==e?e:[],...null!==(n=s.atoms)&&void 0!==n?n:[]],i.bonds=[...null!==(r=i.bonds)&&void 0!==r?r:[],...null!==(o=s.bonds)&&void 0!==o?o:[]],i.highlightAtomColors=Object.assign(Object.assign({},i.highlightAtomColors),s.highlightAtomColors),i.highlightBondColors=Object.assign(Object.assign({},i.highlightBondColors),s.highlightBondColors);return i}(o)}}),c.render()}return!0},getSubstruct:t=>{if("true"!=n.getTag(".sequence-src-highlight-monomers"))return;if(null==t)return;if(!e.get(t))return;const o=l(e,t);return o?(0,vn.H)(o.values(),r):void 0}};wn(t.temp,u),gn(n.temp,u)}(t,g,w,v,b,y,p),[g,w]}finally{l.close()}}var Hn=n(6197);class Gn extends o.InputBase{constructor(t,e){super(M.input.column(t,e).dart,e?.onValueChanged),this.options=e}setColumnInputTable(t){M.input.setColumnInputTable(this,t,this.options?.filter)}}M.input.column2=function(t,e){return new Gn(t,e)};var Un=n(1296),Vn=n(3820);class qn extends o.JsInputBase{get inputType(){return"Positions"}get dataType(){return o.TYPE.DATA_FRAME}getInput(){return this.gridHost}getValue(){return this.grid.dataFrame}setValue(t){this.setDataFrame(t)}getStringValue(){return this.grid.dataFrame.toCsv()}setStringValue(t){this.setDataFrame(o.DataFrame.fromCsv(t))}clearInput(){const t=o.DataFrame.fromColumns([o.Column.fromType(o.COLUMN_TYPE.STRING,"Remove",0),o.Column.fromType(o.COLUMN_TYPE.INT,"Position",0),o.Column.fromType(o.COLUMN_TYPE.STRING,"Monomers",0)]);this.setDataFrame(t)}get placeholdersValue(){return function(t){const e=[];for(let n=0;n<t.rowCount;n++){if(t.getCol("Position").isNone(n))continue;const r=parseInt(t.get("Position",n))-1;if(!isNaN(r)){const o=jn(t.get("Monomers",n));e.push({position:r,monomers:o})}}return e}(this.grid.dataFrame)}constructor(t,e,n){super(),this.name=t,this.subs=[],this.dataFrameSubs=[],this.caption=t??"",this.root.classList.add("ui-input-polytool-pos-grid"),this.root.append(this.gridHost=M.div([],{classes:"ui-input-editor",style:{width:"100%",height:"100%",marginTop:"-8px",marginBottom:"8px",paddingBottom:"4px"}})),this.render(e,n).then((()=>{}))}detach(){for(const t of this.subs)t.unsubscribe();for(const t of this.dataFrameSubs)t.unsubscribe()}async render(t,e){let n;const r=o.DataFrame.fromColumns([n=o.Column.fromType(o.COLUMN_TYPE.STRING,"Remove",0),o.Column.fromType(o.COLUMN_TYPE.INT,"Position",0),o.Column.fromType(o.COLUMN_TYPE.STRING,"Monomers",0)]);n.setTag(o.TAGS.FRIENDLY_NAME,""),this.grid=await r.plot.fromType(o.VIEWER.GRID,e),this.grid.sort(["Position"]),this.grid.columns.byIndex(1).width=this.grid.props.rowHeight+2,this.grid.onCellRender.subscribe((t=>{const e=t.cell;e.tableColumn?.name==n.name&&(e?.tableRowIndex??-1)>=0&&(e.element=M.div(M.icons.delete((()=>{this.grid.dataFrame.rows.removeAt(e.tableRowIndex)}),"Delete"),{style:{height:`${e.grid.props.rowHeight}px`,color:"var(--grey-6)",display:"flex",flexDirection:"row",justifyContent:"center"}}))})),this.updateGridHeight(t??this.grid.dataFrame.rowCount+.7),this.subs.push(M.onSizeChanged(this.grid.root).subscribe(this.gridRootOnSizeChanged.bind(this))),this.subs.push((0,et.fromEvent)(this.grid.root,"keydown").subscribe((t=>{"Enter"===t.key&&t.stopPropagation()}))),this.setDataFrame(r),this.grid.root.style.width="100%",this.gridHost.append(this.grid.root)}setDataFrame(t){for(const t of this.dataFrameSubs)t.unsubscribe();this.grid.dataFrame=t,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(t,e){const n=this.grid.dataFrame,r=n.columns.byName("Position").toList();let o=r.indexOf(t+1);-1===o&&(o=r.findIndex((t=>isNaN(t))),-1===o&&(o=n.rows.addNew(["",t+1,e??""]).idx),this.grid.cell("Monomers",o)),n.currentCell=n.cell(o,"Monomers")}setMonomersValue(t,e){const n=this.grid.dataFrame;n.rowCount<=t||n.set("Monomers",t,e)}static async create(t,e,n){return new qn(t,n,e)}updateGridHeight(t){const e=this.grid.colHeaderHeight+t*this.grid.props.rowHeight+6+2;this.grid.root.style.height=`${e}px`}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 jn(t){return t.split(/,(?![^(]*\))/).map((t=>('"'===(t=t.trim()).slice(0,1)&&'"'===t.slice(-1)&&(t=t.slice(1,-1)),"'"===t.slice(0,1)&&"'"===t.slice(-1)&&(t=t.slice(1,-1)),t.trim()))).filter((t=>!!t))}class Wn extends o.JsInputBase{get inputType(){return"Breadth"}get dataType(){return o.TYPE.DATA_FRAME}getInput(){return this.gridHost}getValue(){return this.grid.dataFrame}setValue(t){this.setDataFrame(t)}getStringValue(){return this.grid.dataFrame.toCsv()}setStringValue(t){this.setDataFrame(o.DataFrame.fromCsv(t))}get placeholdersBreadthValue(){return function(t){const e=[];for(let n=0;n<t.rowCount;n++){const r=parseInt(t.get("Start",n))-1,o=parseInt(t.get("End",n))-1;if(!isNaN(r)&&!isNaN(o)){const i=jn(t.get("Monomers",n));e.push({start:r,end:o,monomers:i})}}return e}(this.grid.dataFrame)}constructor(t,e,n){super(),this.name=t,this.subs=[],this.dataFrameSubs=[],this.caption=t??"",this.root.classList.add("ui-input-polytool-pos-grid"),this.root.append(this.gridHost=M.div([],{classes:"ui-input-editor",style:{width:"100%",height:"100%",marginTop:"-8px",marginBottom:"8px",paddingBottom:"4px"}})),this.render(e,n).then((()=>{}))}detach(){for(const t of this.subs)t.unsubscribe();for(const t of this.dataFrameSubs)t.unsubscribe()}clearInput(){const t=o.DataFrame.fromColumns([o.Column.fromType(o.COLUMN_TYPE.STRING,"Remove",0),o.Column.fromType(o.COLUMN_TYPE.INT,"Start",0),o.Column.fromType(o.COLUMN_TYPE.INT,"End",0),o.Column.fromType(o.COLUMN_TYPE.STRING,"Monomers",0)]);this.setDataFrame(t)}async render(t,e){let n;const r=o.DataFrame.fromColumns([n=o.Column.fromType(o.COLUMN_TYPE.STRING,"Remove",0),o.Column.fromType(o.COLUMN_TYPE.INT,"Start",0),o.Column.fromType(o.COLUMN_TYPE.INT,"End",0),o.Column.fromType(o.COLUMN_TYPE.STRING,"Monomers",0)]);n.setTag(o.TAGS.FRIENDLY_NAME,""),this.grid=await r.plot.fromType(o.VIEWER.GRID,e),this.grid.sort(["Start","End"]),this.grid.columns.byIndex(1).width=this.grid.props.rowHeight+2,this.grid.onCellRender.subscribe((t=>{const e=t.cell;e.tableColumn?.name==n.name&&(e?.tableRowIndex??-1)>=0&&(e.element=M.div(M.icons.delete((()=>{this.grid.dataFrame.rows.removeAt(e.tableRowIndex)}),"Delete"),{style:{height:`${e.grid.props.rowHeight}px`,color:"var(--grey-6)",display:"flex",flexDirection:"row",justifyContent:"center"}}))})),this.updateGridHeight(t??this.grid.dataFrame.rowCount+.7),this.subs.push(M.onSizeChanged(this.grid.root).subscribe(this.gridRootOnSizeChanged.bind(this))),this.subs.push((0,et.fromEvent)(this.grid.root,"keydown").subscribe((t=>{"Enter"===t.key&&t.stopPropagation()}))),this.setDataFrame(r),this.grid.root.style.width="100%",this.gridHost.append(this.grid.root)}setDataFrame(t){for(const t of this.dataFrameSubs)t.unsubscribe();this.grid.dataFrame=t,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(t,e,n){return new Wn(t,n,e)}updateGridHeight(t){const e=this.grid.colHeaderHeight+t*this.grid.props.rowHeight+6+2;this.grid.root.style.height=`${e}px`}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 zn=n(6307);async function Yn(t){await xr.initPromise;const e=window.innerWidth,n=window.innerHeight;try{let i;function s(){if(null==i)return;const t=L()(i.root).find("div.d4-dialog-contents").get(0),e=t.clientHeight,n={0:1},r=Object.values(n).reduce(((t,e)=>t+e),0),o=e-en().count(0).take(t.children.length).filter((t=>!(t in n))).map((e=>t.children[e])).filter((t=>t instanceof HTMLElement)).map((t=>t.offsetHeight)).reduce(((t,e)=>t+e),0)-38;for(const e of en().count(0).take(t.children.length))if(e in n){const i=t.children[e],s=o*n[e]/r;i.style.height=`${s}px`}}i=await async function(t,e){const n="ST: PT: HelmDialog()";let i;const s=[];let a=Un.aK.Single;const u=()=>{for(const t of s)t.unsubscribe();i.placeholders.detach()};try{const c=await(0,l.pj)(),h=c.getMonomerLib(),d=await(0,Ze.Q)(),f=o.DataFrame.fromColumns([]),[p,m]=await Promise.all([_n(),(0,Qe.b2)()]),g=m.buildMonomersFuncsFromLib(h),y=t=>{let e,n;if(t&&t.rowIndex>=0&&t?.column.semType==o.SEMTYPE.MACROMOLECULE)e=d.getSeqHandler(t.column).getValue(t.rowIndex),n=e.tags["polytool-data-role"]??"macromolecule";else{const t=o.Column.fromList(o.COLUMN_TYPE.STRING,"seq",[Vn.d]);t.semType=o.SEMTYPE.MACROMOLECULE,o.DataFrame.fromColumns([t]),t.meta.units=Oe.Hi.HELM,e=d.getSeqHandler(t).getValue(0),n="macromolecule"}return[e,n]};let b,v,[C,w]=y(t),A=null;const x=M.divText("",{style:{marginLeft:"8px",marginTop:"2px"}}),E=M.divText("",{style:{color:"red"}});i={macromolecule:m.createHelmInput("Macromolecule",{editable:!1,editorOptions:{drawOptions:{monomerNumbering:1,getMonomer:(t,e)=>{const n=t;if("ATOM"!==n.T)return g.getMonomer(t,e);try{if(C.isDna()||C.isRna()){const t=C.getSplittedWithSugarsAndPhosphates().getCanonical(n.bio.continuousId-1);return g.getMonomer(n.bio.type,t)}{const t=C.getSplitted().getCanonical(n.bio.continuousId-1);return g.getMonomer(n.bio.type,t)}}catch(n){return g.getMonomer(t,e)}}}}}),placeholders:await qn.create("Placeholders",{showAddNewRowIcon:!0,showRemoveRowIcon:!0,showRowHeader:!1,showCellTooltip:!1}),enumeratorType:M.input.choice("Enumerator type",{value:a,items:Object.values(Un.aK)}),placeholdersBreadth:await Wn.create("Breadth",{showAddNewRowIcon:!0,showRemoveRowIcon:!0,showRowHeader:!1,showCellTooltip:!1}),keepOriginal:M.input.bool("Keep original",{value:!1}),toAtomicLevel:M.input.bool("To atomic level",{value:!1,onValueChanged:(t,e)=>{I()}}),generateHelm:M.input.bool(Pn,{value:!0}),chiralityEngine:M.input.bool(Ln,{value:!1}),highlightMonomers:M.input.bool(On,{value:!1}),rules:{header:M.inlineText([Fn]),form:await(v=new En._v(En.MU,En.yy,".json",{onValueChanged:t=>{b=t}})).getForm()},trivialNameCol:M.input.column2("Trivial name",{table:t?.dataFrame,filter:e=>e.type===o.COLUMN_TYPE.STRING&&e!=t?.column,onValueChanged:()=>{const e=i.trivialNameCol.value;let n=null;t&&e&&(n={value:e.get(t.rowIndex),colName:e.name}),A=n,x.textContent=A?`Original ID: ${A.value}`:""},nullable:!0}),library:M.input.choice("Monomer Library",{items:p,value:p[0],nullable:!0})},i.library.root.style.setProperty("display","none"),i.trivialNameCol.addOptions(x);let T=null;i.placeholders.addValidator((t=>{const e=[];try{if(i.enumeratorType.value===Un.aK.Library){setTimeout((()=>{_()}),10);const t=i.placeholders.placeholdersValue;if(t.length>1)return"Only one placeholder is allowed for Library mode";if(1===t.length){if(null==t[0].position)return"Position is required for Library mode";if(t[0].position>i.macromolecule.molValue.atoms.length)return`There is no monomer at position ${t[0].position+1}.`}return null}if("macromolecule"!==w)return null;const t=[];for(const n of i.placeholders.placeholdersValue){const r=n.position;if(null==r)continue;if(r>=i.macromolecule.molValue.atoms.length){e.push(`There is no monomer at position ${r+1}.`);continue}const o=i.macromolecule.molValue.atoms[r];if(o){const e=o.biotype(),r=(0,Hn.Y)(e);for(const e of n.monomers){const n=h.getMonomer(r,e);n&&n.lib||t.push({polymerType:r,symbol:e})}}}const n={};for(const e of t){let t=n[e.polymerType];t||(t=n[e.polymerType]=[]),t.push(e.symbol)}const r=Object.entries(n).map((([t,e])=>`${t}: ${e.join(", ")}`)).join("\n");Object.keys(r).length>0&&e.push(`Placeholders contain missed monomers: ${r}`),T=e.length>0?e.join("\n"):null}catch(t){const[e,n]=In(t,!1);T=e}return setTimeout((()=>{_()}),0),T})),i.library.addValidator((t=>i.enumeratorType.value!==Un.aK.Library||i.library.value?null:"Monomer Library is required for this enumerator type")),i.library.onChanged.subscribe((()=>{i.enumeratorType.value===Un.aK.Library&&i.placeholders.setMonomersValue(0,i.library.value??"")})),i.enumeratorType.onChanged.subscribe((t=>{const e=i.enumeratorType.value===Un.aK.Library;i.library.root.style.setProperty("display",e?"flex":"none");try{if(a!==Un.aK.Library&&e||a===Un.aK.Library&&!e){const t=1===i.placeholders.placeholdersValue.length?i.placeholders.placeholdersValue[0].position:null;i.placeholders.clearInput(),i.placeholdersBreadth.clearInput(),e&&null!=t&&i.placeholders.addPosition(t,i.library.value??"")}}catch(t){In(t,!1)}a=i.enumeratorType.value})),s.push(i.macromolecule.onMouseMove.subscribe((t=>{try{xr.logger.debug(`${n}, placeholdersInput.onMouseMove()`);const e=t.offsetX,r=t.offsetY,o=i.macromolecule.molValue,s=m.getHoveredAtom(e,r,o,i.macromolecule.root.clientHeight);if(s){const e=s._parent.atoms.indexOf(s),n=i.placeholders.placeholdersValue.find((t=>t.position===e))?.monomers;if(n){const e=M.divText(n.join(", "));i.macromolecule.showTooltip(e,s),t.preventDefault(),t.stopPropagation()}}}catch(t){In(t,!1)}}))),s.push(i.macromolecule.onClick.subscribe((t=>{try{xr.logger.debug(`${n}, placeholdersInput.onClick()`);const e=t.offsetX,r=t.offsetY,o=i.macromolecule.molValue,s=m.getHoveredAtom(e,r,o,i.macromolecule.root.clientHeight);if(s){const t=s._parent.atoms.indexOf(s);String(t+1);let e="";i.enumeratorType.value===Un.aK.Library&&(i.placeholders.clearInput(),e=i.library.value??""),i.placeholders.addPosition(t,e)}}catch(t){In(t)}}))),s.push(i.placeholders.onChanged.subscribe((()=>{S()}))),s.push(M.onSizeChanged(i.placeholders.root).subscribe((()=>{e&&e()}))),s.push(r.events.onCurrentCellChanged.subscribe((()=>{const t=r.shell.tv.dataFrame.currentCell;t.column.semType===o.SEMTYPE.MACROMOLECULE&&([C,w]=y(),P(C,w,t))}))),i.macromolecule.root.style.setProperty("min-width","250px","important");const S=()=>{const t=new Set(i.placeholders.placeholdersValue.map((t=>t.position))),e=i.macromolecule.molValue;for(let n=0;n<e.atoms.length;n++)e.atoms[n].highlighted=t.has(n);i.macromolecule.redraw()},I=()=>{i.toAtomicLevel.value&&"template"===w?(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"),e&&e()},_=()=>{const t=T,e=E;t?(e.innerText=t,e.style.removeProperty("display")):(e.innerText="",e.style.setProperty("display","none"))},N=t=>{t?(i.trivialNameCol.setColumnInputTable(t),i.trivialNameCol.root.style.removeProperty("display")):(i.trivialNameCol.setColumnInputTable(f),i.trivialNameCol.root.style.setProperty("display","none")),e&&e()},P=(t,e,n)=>{i.macromolecule.value=t;const r=n?.dataFrame;N(r)};P(C,w,t),I();const L=async()=>{try{const t=i.macromolecule.stringValue,e=en().enumerate(i.macromolecule.molValue.atoms).filter((([t,e])=>t.highlighted)).map((([t,e])=>e)).toArray();if(i.enumeratorType.value===Un.aK.Library){if(0===e.length)return void r.shell.warning("PolyTool: position for enumeration was not selected");if(!i.library.value)return void r.shell.warning("PolyTool: No monomer library was selected")}if(void 0===t||""===t)r.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 r.shell.warning(`${Dn}: placeholders are empty`);await(0,Qe.b2)();const e=i.placeholders.placeholdersValue;let n=i.enumeratorType.value;if(n===Un.aK.Library){if(1!==e.length)return void r.shell.warning("Only one placeholder is allowed for Library mode");if(!e[0].monomers||!p.includes(e[0].monomers[0]))return void r.shell.warning("Valid Monomer Library is required for this enumerator type");const t=e[0].monomers[0],o=await c.readSingleLibraryByName(t);if(!o)return void r.shell.warning(`Monomer Library '${t}' was not found`);const i=o.getMonomerSymbolsByType("PEPTIDE");e[0].monomers=i,n=Un.aK.Single}const o={placeholders:e,type:n,breadthPlaceholders:i.placeholdersBreadth.placeholdersBreadthValue,keepOriginal:i.keepOriginal.value},s=i.toAtomicLevel.value,a=await Kn(t,w,A,o,!!s&&{generateHelm:i.generateHelm.value,chiralityEngine:i.chiralityEngine.value,highlightMonomers:i.highlightMonomers.value,rules:await v.getActive()},m);r.shell.addTableView(a)}}catch(t){In(t)}},O=M.dialog({title:Dn,showFooter:!0}).add(i.macromolecule.root).add(M.divH([M.divV([i.placeholders.root,i.enumeratorType.root,i.library.root],{style:{width:"50%"}}),M.divV([i.placeholdersBreadth.root],{style:{width:"50%"}})],{style:{width:"100%"}})).add(M.divH([M.divV([i.trivialNameCol.root,i.keepOriginal.root],{style:{width:"50%"}}),M.divV([M.divH([i.toAtomicLevel.root,i.generateHelm.root]),M.divH([i.chiralityEngine.root,i.highlightMonomers.root]),i.rules.header,i.rules.form],{style:{width:"50%"}})],{style:{width:"100%"}})).add(E).onOK((()=>{L()}));return s.push(O.onClose.subscribe((()=>{u()}))),O.history((()=>({description:`${i.enumeratorType.value} ${i.placeholders.placeholdersValue?.map((t=>(t.position?.toString()??"")+": "+t.monomers?.join(", "))).join("; ")}`,placeholders:i.placeholders.stringValue,enumeratorType:i.enumeratorType.value,placeholdersBreadth:i.placeholdersBreadth.stringValue,trivialNameCol:i.trivialNameCol.stringValue,keepOriginal:i.keepOriginal.value,toAtomicLevel:i.toAtomicLevel.value,generateHelm:i.generateHelm.value,chiralityEngine:i.chiralityEngine.value,highlightMonomers:i.highlightMonomers.value,rules:b,library:i.library.value})),(t=>{i.enumeratorType.value=t.enumeratorType??Un.aK.Single,i.placeholders.stringValue=t.placeholders,i.placeholdersBreadth.stringValue=t.placeholdersBreadth,i.trivialNameCol.stringValue=t.trivialNameCol,i.keepOriginal.value=t.keepOriginal??!1,i.toAtomicLevel.value=t.toAtomicLevel??!0,i.generateHelm.value=t.generateHelm??!0,i.chiralityEngine.value=t.chiralityEngine??!1,i.highlightMonomers.value=t.highlightMonomers??!1,v.setActive(t.rules),i.library.value=t.library})),O}catch(t){throw u(),t}}(t,s);let a=!0;M.onSizeChanged(i.root).subscribe((()=>{if(a){const t=.7*e,r=.7*n;i.root.style.width=`${Math.min(e,t)}px`,i.root.style.height=`${Math.min(n,r)}px`,i.root.style.left=`${Math.floor((e-i.root.offsetWidth)/2)}px`,i.root.style.top=`${Math.floor((n-i.root.offsetHeight)/2)}px`,a=!1}s()})),s(),xr.logger.debug("PolyToolEnumerateHelmUI: dialog before show"),i.show({width:Math.max(350,.7*e),resizable:!0}),xr.logger.debug("PolyToolEnumerateHelmUI: dialog after show")}catch(u){const[c,h]=(0,Xe.AP)(u);xr.logger.error(c,void 0,h)}}async function Kn(t,e,n,i,s,a){const u=o.TaskBarProgressIndicator.create("PolyTool enumerating...");try{const u=await(0,l.pj)(),c=await(0,xn.j)(),h=u.getMonomerLib(),d=(0,Vn.o)(t,n?.value??"",i);let f;switch(e){case"macromolecule":f=o.Column.fromType(o.COLUMN_TYPE.STRING,"Enumerated",d.length).init((t=>d[t][0]));break;case"template":{const t=new Array(d.length);for(let e=0;e<d.length;e++){const n=d[e][0],r=zn.s.fromHelm(n,a);t[e]=r.getNotation()}f=o.Column.fromList(o.COLUMN_TYPE.STRING,"Enumerated",t),f.semType=o.SEMTYPE.MACROMOLECULE,f.setTag("polytool-data-role","template"),Tr.applyNotationProviderForCyclized(f,"-");break}}const p=o.DataFrame.fromColumns([f]);if(await r.data.detectSemanticTypes(p),"template"==e&&Tr.applyNotationProviderForCyclized(f,"-"),s){let t;if("macromolecule"===e){t=f;const e=await a.seqHelper.helmToAtomicLevel(t,s.chiralityEngine,s.highlightMonomers);p.columns.add(e.molCol,!1);const n=e.molCol;await async function(t,e,n,r,o,i=!1){const s=r.getSeqHandler(t),a=s.alphabet==Oe.YI.RNA||s.alphabet==Oe.YI.DNA,l=s.isHelm()&&a,u=!s.isHelm()&&a,c=t=>null==t?null:l?i?t:Math.floor(t/3):u&&i?3*t+1:t,h=i?await r.getHelmToMolfileConverter(n):null,d=new fn({max:100});function f(t,e){const s=t.get(e);if(null==s)return null;let a=d.get(s);return a||d.set(s,a=function(t,e){const s=r.getSeqHandler(t);if(i){const t=s.getHelm(e);return r.helmToAtomicLevelSingle(t,h,!1,!1).monomers}{const t=s.getSplitted(e),r=s.defaultBiotype,i=en().count(0).take(t.length).map((e=>({position:e,symbol:t.getCanonical(e),biotype:r}))).toArray(),a=s.alphabet,l=a==Oe.YI.RNA||a==Oe.YI.DNA?"RNA":"PEPTIDE",u=(0,yn.eM)([i],l,a,n,o);return(0,bn.gU)(i,u,a,l).monomers}}(t,e)),a}const p={targetCol:e,handler:(e,r,o)=>{const i=o.grid,s=e.tableRowIndex,a=e.gridRow,l=i.cell(o.name,a),u=pn();if(!u||u&&(u.dataFrameId!=t.dataFrame.id||u.gridRowIdx!=a||u.seqColName!=t.name||u.seqPosition!=r?.position)){if(u&&(mn(null),u.gridCell.render()),!r)return mn(null),!0;mn({gridCell:l,dataFrameId:t.dataFrame.id,gridRowIdx:a,seqColName:t.name,seqPosition:c(r?.position)??-1,getSubstruct:()=>{if(!r||"*"===r.symbol)return;const e=f(t,s);if(!e)return;const o=e.get(c(r?.position));return o?(0,vn.H)([o],n):{atoms:[],bonds:[],highlightAtomColors:[],highlightBondColors:[]}}}),l.render()}return!0},getSubstruct:r=>{if("true"!=e.getTag(".sequence-src-highlight-monomers"))return;if(null==r)return;if(!t.get(r))return;const o=f(t,r);return o?(0,vn.H)(o.values(),n):void 0}};return wn(t.temp,p),gn(e.temp,p),p}(t,n,h,a.seqHelper,c,!0)}else"template"===e&&(t=(await kn(f,s.generateHelm,!1,s.chiralityEngine,!1,s.rules))[0])}if(n){const t=o.Column.fromType(o.COLUMN_TYPE.STRING,n.colName,d.length).init((t=>d[t][1]));p.columns.add(t)}return p}finally{u.close()}}var Jn,Qn=n(3151);class Xn{constructor(t){this.rawLib=t}isValid(){return this.rawLib.every((t=>"object"==typeof t&&Object.values(Nn).every((e=>e in t&&"string"==typeof t[e]))))}getJsonMonomerLib(){const t=[];return this.rawLib.forEach((e=>{const n=this.prepareMonomer(e);t.push(n)})),t}prepareMonomer(t){const e={...Qn.pe};Object.entries(Nn).forEach((([n,r])=>{const o=t[r];e[n]=o}));let n="smiles";const r=t[Nn[n]],o=new Zn(r),i=o.getCappedSmiles();return e[n]=i,n="rgroups",e[n]=tr.getRGroups(o.getNumberOfRGroups()),n="molfile",e[n]=new er(o.getSmilesWithRGroups()).getMolfile(),e}}class Zn{constructor(t){let e=0;this.smilesWithRGroups=t.replace(/\[R(\d+)\]/g,((t,n)=>(++e,`[${n}*]`))),this.numberOfRGroups=e}getSmilesWithRGroups(){return this.smilesWithRGroups}getCappedSmiles(){return this.capRGroups()}getNumberOfRGroups(){return this.numberOfRGroups}capRGroups(){let t=this.smilesWithRGroups.replace("[1*]","[H:1]");return t=t.replace("[2*]","[OH:2]"),t.replace("[3*]","[H:3]")}}class tr{constructor(){}static getRGroups(t){return Mn.slice(0,t)}}class er{constructor(t){this.smilesWithRGroups=t}getMolfile(){let t=o.chem.convert(this.smilesWithRGroups,o.chem.Notation.Smiles,o.chem.Notation.MolBlock);return t=this.restoreRGPLine(t),t=this.fixRGroupSymbols(t),t}restoreRGPLine(t){return t.replace("M ISO","M RGP")}fixRGroupSymbols(t){return t.replace(/\bR\b/g,"R#")}}class nr{constructor(t,e){this.fileName=t,this.fileContent=e,this.validateFileType();const n=o.DataFrame.fromCsv(this.fileContent),r=this.toJson(n);this.polyToolMonomerLib=new Xn(r),this.validateContent()}async getJson(){return this.polyToolMonomerLib.getJsonMonomerLib()}toJson(t){return Array.from({length:t.rowCount},((e,n)=>t.columns.names().reduce(((e,r)=>(e[r]=t.get(r,n),e)),{})))}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(t){t.table="table",t.seqCol="seqCol",t.generateHelm="generateHelm",t.chiralityEngine="chiralityEngine",t.rules="rules"}(Jn||(Jn={}));class rr{constructor(t){this.call=t,this.ruleInputs=new En._v(En.MU,En.yy,".json")}async initInputs(){const t=t=>this.call.inputParams[t],e=await this.ruleInputs.getForm();this.inputs={table:(()=>{const e=t(Jn.table);return M.input.table(e.property.caption,{value:e.value})})(),seqCol:(()=>{const e=t(Jn.seqCol);return M.input.column(e.property.caption,{value:e.value,table:e.value.dataFrame})})(),generateHelm:M.input.forProperty(t(Jn.generateHelm).property),chiralityEngine:M.input.forProperty(t(Jn.chiralityEngine).property),rules:{header:M.inlineText([Fn]),form:e}}}static async create(t){const e=new rr(t);return await e.initInputs(),e}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 t=M.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(((e,n)=>{M.dialog({title:Rn}).add(t).onOK((async()=>{const t=await this.getParams(),n=(await this.call.func.prepare(t).call(!0)).getOutputParamValue();e(n)})).onCancel((()=>{n(new Error("Cancelled by user"))})).show()}))}widget(){throw new Error("not implemented")}}class or{onKeyDown(t,e){}onKeyPress(t,e){}onMouseEnter(t,e){}onMouseLeave(t,e){}onMouseDown(t,e){}onMouseUp(t,e){}onMouseMove(t,e){}onClick(t,e){}onDoubleClick(t,e){}}class ir extends or{constructor(t,e,n){super(),this.gridCol=t,this.tableCol=e,this.logger=n,this.subs=[],this.dirty=!0,this.destroyed=!1,this.viewerId=++ir.viewerCounter,this.errors=[],this._onRendered=new et.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((t=>{try{this.destroyed||!this.tableCol||this.tableCol.dataFrame||this.destroy()}catch(t){this.logger.error(t)}})))),this.tableCol&&this.subs.push(r.events.onTableRemoved.subscribe((t=>{try{const e=t.args.dataFrame;this.tableCol?.dataFrame.id!==e.id||this.destroyed||this.destroy()}catch(t){this.logger.error(t)}}))),this.gridCol&&this.subs.push(r.events.onViewRemoving.subscribe((t=>{try{const e=t.args.view;this.gridCol?.dart&&this.gridCol.grid&&this.gridCol?.grid?.dart&&this.gridCol?.grid?.view?.id===e.id&&!this.destroyed&&this.destroy()}catch(t){this.logger.error(t)}})))}toLog(){return`${this.constructor.name}<${this.viewerId}>`}destroy(){for(const t of this.subs)t.unsubscribe();this.destroyed=!0}invalidateGrid(){this.gridCol&&this.gridCol.dart&&this.gridCol.grid?.invalidate()}reset(){this.dirty=!1}get onRendered(){return this._onRendered}invalidate(t){this.invalidateGrid()}async awaitRendered(t=1e4,e=`${t} timeout`){const n=`${this.toLog()}.awaitRendered()`;if(this.logger.debug(`${n}, start, testEvent before`),await(0,Ke.PE)(this._onRendered,(()=>{}),(()=>{this.invalidate()}),t,`${n}, ${e}`),this.errors.length>0){const t=this.errors[0];throw this.errors=[],t}this.logger.debug(`${n}, end`)}}ir.viewerCounter=-1;const sr="rgb(100,100,100)",ar="rgb(0,0,0)",lr=s.zS;var ur,cr,hr;!function(t){t.maxMonomerLength=".mm.cellRenderer.maxMonomerLength"}(ur||(ur={})),function(t){t.applyToBackground=".m.cellRenderer.applyToBackground"}(cr||(cr={})),function(t){t.MSA="MSA",t.classic="classic"}(hr||(hr={}));const dr=new class{constructor(){this.color=sr,this.pivot=0,this.left=!1,this.transparencyRate=0,this.separator="",this.last=!1,this.drawStyle=hr.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 fr(t,e,n,r,i,s,a){var l,u,c;const h={...dr,...a};if(h.isMultiLineContext){t.textBaseline="middle",t.textAlign="center";let o=e;null!=h.maxLengthOfMonomer&&(o=lr(o,h.maxLengthOfMonomer));const a=Math.max(.1,1-(h.transparencyRate??0));t.globalAlpha=a;const l=t.measureText(o),u=l.fontBoundingBoxAscent+l.fontBoundingBoxDescent,c=r+(s-u)/2+l.fontBoundingBoxAscent;let d=h.color??sr;return d&&d!==sr||(d=ar),t.fillStyle=d,h.selectedPosition===h.wordIdx+1&&(t.save(),t.fillStyle="rgba(60, 177, 115, 0.2)",t.fillRect(n,r,i,s),t.restore(),t.fillStyle=d),t.fillText(o,n+i/2,c),t.globalAlpha=1,t.textBaseline="top",t.textAlign="start",n+i}a.logger?.debug("Bio: printLeftOrCentered(), start"),t.textAlign="start";let d=e.substring(0),f=h.last?"":h.separator;h.drawStyle===hr.MSA&&(f="");let p=!0,m=!0,g="difference";if(null!=h.gridCell&&null!=h.gridCell.cell.column&&(p=h.gridCell.cell.column.temp["color-code"]??!0,m=h.gridCell.cell.column.temp["compare-with-current"]??!0,g=h.gridCell.cell.column.temp["highlight-difference"]??"difference"),h.referenceSequence){const t=h.referenceSequence[h.wordIdx];m&&h.referenceSequence.length>0&&"difference"===g&&(h.transparencyRate=d==t?.7:h.transparencyRate),m&&h.referenceSequence.length>0&&"equal"===g&&(h.transparencyRate=d!=t?.7:h.transparencyRate)}null!=h.maxLengthOfMonomer&&(d=lr(d,h.maxLengthOfMonomer));const y=d+f;(l=h.monomerTextSizeMap)[y]??(l[y]=t.measureText(y));let b=h.monomerTextSizeMap[y];(u=h.monomerTextSizeMap)[d]??(u[d]=t.measureText(d));let v=h.monomerTextSizeMap[d].width;const C=s/2-(b.fontBoundingBoxAscent+b.fontBoundingBoxDescent)/2+1;(c=h.monomerTextSizeMap)[f]??(c[f]=t.measureText(f));const w=h.monomerTextSizeMap[f].width;function A(e,i){let a=p?h.color:ar;h.selectedPosition===h.wordIdx+1&&(t.fillStyle="rgba(60, 177, 115, 0.2)",t.fillRect(n+e-4,r-5,h.monomerTextSizeMap[d].width+8,s+10),a=o.Color.toHtml(o.Color.setAlpha(o.Color.fromHtml(a),255))),t.fillStyle=a,t.globalAlpha=1-h.transparencyRate,h.drawStyle===hr.classic&&(t.fillText(d,n+e,r+C),t.fillStyle="#808080",t.fillText(f,n+i,r+C)),h.drawStyle===hr.MSA&&t.fillText(d,n+e,r+C),t.globalAlpha=1}b=b.width,h.drawStyle===hr.MSA&&(v=h.maxWord[h.wordIdx],b=h.maxWord[h.wordIdx]);const x=(h.maxWord[h.wordIdx]??0)-(h.maxWord[0]??0);if(h.left||b>i)return A(x,x+v),n+x+v+w;{const t=(i-b)/2;return A(t,t+v),n+x+t+v}}var pr=n(3599);const mr="rgb(100,100,100)";class gr extends ir{get separatorWidth(){return this.props?.fontCharWidth?this.props?.fontCharWidth:5}constructor(t,e,n,r,i){if(super(t,e,n),this.monomerLengthLimit=r,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.padding=5,this._leftThreeDotsPadding=0,this.props=this.propsProvider(),this._processedRows=o.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 t=[Oe.gp.positionShift,"renderMultiline"];this.subs.push(o.debounce(this.tableCol.dataFrame.onMetadataChanged.pipe(nt.filter((e=>e.args.source===this.tableCol&&t.includes(e.args.key)))),200).subscribe((t=>{this.reset()}))),this.subs.push(o.debounce(this.tableCol.dataFrame.onMetadataChanged.pipe(nt.filter((t=>t.args.source===this.tableCol&&t.args.key===Oe.gp.positionShift))),200).subscribe((t=>{this.reset()})))}}calculateFontBasedSpacing(t){const e=t.measureText("M");let n=12;if(this.tableCol?.temp[".mm.cellRenderer.fontSize"]){const t=this.tableCol.temp[".mm.cellRenderer.fontSize"];"number"!=typeof t||isNaN(t)||(n=Math.max(t,1))}return{lineHeight:Math.max(1.4*n,e.fontBoundingBoxAscent+e.fontBoundingBoxDescent+4),monomerSpacing:Math.max(2,.2*this.props.fontCharWidth)}}shouldUseMultilineRendering(t){return"true"===t.getTag("renderMultiline")}calculateMultiLineLayoutDynamic(t,e,n,r,o,i){if(this.dirty)try{this.reset()}catch(t){const[e,n]=(0,Xe.AP)(t);this.logger.error(e,void 0,n)}const{lineHeight:s,monomerSpacing:a}=this.calculateFontBasedSpacing(t),l=e-2*this.padding;let u=0;const c=[];if(r.length>0)for(let e=o;e<r.length;e++){const n=r.getOriginal(e),o=this.props.monomerToShort(n,i);c.push({text:o,posIdx:e}),u=Math.max(u,t.measureText(o).width)}if(0===c.length)return{lineLayouts:[],lineHeight:s};const h=u;let d=Math.floor((l+a)/(h+a));d=Math.max(1,d);const f=n-2*this.padding,p=Math.max(0,Math.floor(f/s)),m=[];let g=0;for(let t=0;t<p&&g<c.length;t++){const e=[];for(let t=0;t<d&&g<c.length;t++){const n=c[g],r=this.padding+t*(h+a);e.push({posIdx:n.posIdx,x:r,width:h,om:n.text,isSeparator:!1}),g++}m.push({lineIdx:t,elements:e})}return{lineLayouts:m,lineHeight:s}}async init(){await Promise.all([(async()=>{this.seqHelper=await(0,Ze.Q)(),this.invalidateGrid()})(),(async()=>{const t=await(0,l.pj)();this.sysMonomerLib=t.getMonomerLib()})()]),this.subs.push(this.sysMonomerLib.onChanged.subscribe((()=>{this.reset()}))),this.reset()}static getFontSettings(t){let e=12;return t&&t.temp[".mm.cellRenderer.fontSize"]&&"number"==typeof t.temp[".mm.cellRenderer.fontSize"]&&!isNaN(t.temp[".mm.cellRenderer.fontSize"])&&(e=Math.max(t.temp[".mm.cellRenderer.fontSize"],1)),{font:`${e}px monospace`,fontWidth:.6*e}}toLog(){return`MonomerPlacer<${this.viewerId}>`}getMonomerLib(){return this.tableCol.temp[".mm.cellRenderer.overriddenLibrary"]??this.sysMonomerLib}reset(){this.propsProvider&&(this.props=this.propsProvider()),this._processedRows=o.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(t,e){const n=this.seqHelper.getSeqHandler(this.tableCol);if(this.colWidth<e&&(this.colWidth=e,this.dirty=!0),this.dirty)try{this.reset()}catch(t){const[e,n]=(0,Xe.AP)(t);this.logger.error(e,void 0,n)}const r=n.isMsa()?this.getCellMonomerLengthsForSeqMsa():this.getCellMonomerLengthsForSeq(t);return[r,this.getSummedMonomerLengths(r)]}getSummedMonomerLengths(t){const e=new Array(t.length+1);e[0]=this.padding;for(let n=1;n<e.length;n++)e[n]=e[n-1]+t[n-1];let n=e[0];for(let t=1;t<e.length;t++)e[t]?n=e[t]:e[t]=n;return e}getCellMonomerLengthsForSeqValue(t,e){const n=this.seqHelper.getSeqHandler(this.tableCol),r=this.props.separatorWidth+1*this.props.fontCharWidth,o=this.positionShift,i=Math.ceil(e/r)+o,s=n.splitter(t),a=Math.min(i,s.length),l=new Array(a-o);let u=0;for(let t=o;t<a;++t){const r=s.getOriginal(t),i=this.props.monomerToShort(r,this.monomerLengthLimit),a=(n.isSeparator()?this.separatorWidth:this.props.separatorWidth)+i.length*this.props.fontCharWidth;if(l[t-o]=a,u+=a,u>e)break}return l}getCellMonomerLengthsForSeq(t){this.toLog(),null===this._monomerLengthList&&(this._monomerLengthList=new Array(this.tableCol.length).fill(null));const e=this.positionShift,n=this.seqHelper.getSeqHandler(this.tableCol),r=this.props.separatorWidth+1*this.props.fontCharWidth,o=Math.ceil(this.colWidth/r)+e,i=n.getSplitted(t),s=Math.min(o,i.length);let a=this._monomerLengthList[t];if(null===a||a.length!=s-e){a=this._monomerLengthList[t]=new Array(i.length);let r=0;for(let t=e;t<s;++t){const o=i.getOriginal(t),s=this.props.monomerToShort(o,this.monomerLengthLimit),l=(n.isSeparator()?this.separatorWidth:this.props.separatorWidth)+s.length*this.props.fontCharWidth;if(a[t-e]=l,r+=l,r>this.colWidth)break}}return a}getCellMonomerLengthsForSeqMsa(){var t;this.toLog(),null===this._monomerLengthList&&(this._monomerLengthList=new Array(1).fill(null)),(t=this._monomerLengthList)[0]??(t[0]=new Array(0));const e=this._monomerLengthList[0],{startIdx:n,endIdx:r}=(()=>{try{const t=this.gridCol&&this.gridCol.dart?this.gridCol.grid:null;return t&&t.dart?{startIdx:Math.max(Math.floor((t?.vertScroll.min??0)-10),0),endIdx:Math.min(Math.ceil((t?.vertScroll.max??0)+10),this.tableCol.length)}:{startIdx:0,endIdx:Math.min(this.tableCol.length,10)}}catch(t){return{startIdx:0,endIdx:Math.min(this.tableCol.length,10)}}})(),o=this.props.separatorWidth+1*this.props.fontCharWidth,i=this.positionShift,s=Math.ceil(this.colWidth/o)+i;for(let t=n;t<r;t++){if(this._processedRows.get(t)&&s<=this._processedMaxVisibleSeqLength)continue;const n=this.seqHelper.getSeqHandler(this.tableCol).getSplitted(t,s),r=Math.min(s,n.length);r-i>e.length&&e.push(...new Array(r-i-e.length).fill(o));let a=0;for(let t=i;t<r;++t){const r=n.getOriginal(t),o=this.props.monomerToShort(r,this.monomerLengthLimit),s=this.props.separatorWidth+o.length*this.props.fontCharWidth;if(e[t-i]=Math.max(e[t-i]??0,s),a+=s,a>=this.colWidth)break}this._processedMaxVisibleSeqLength=Math.max(this._processedMaxVisibleSeqLength,s),this._processedRows.set(t,!0)}return e}getPosition(t,e,n,r){const[o,i]=this.getCellMonomerLengths(t,n);return 0===this.seqHelper.getSeqHandler(this.tableCol).getSplitted(t).length?null:function(t,e,n){if((n??0)>0&&e<(t[0]??0)+n)return-1;e-=n??0;let r,o=100,i=0,s=t.length-1;for(;i<=s;){if(r=Math.floor((s+i)/2),t[r]<=e&&e<t[r+1])return r;if(e<t[r]?s=r-1:i=r+1,--o<=0)throw new Error(`Get position for pointer x = ${e} searching has not converged on ${JSON.stringify(t)}. `)}return null}(i,e,r)}setMonomerLengthLimit(t){this.monomerLengthLimit!=t&&(this.monomerLengthLimit=t,this.dirty=!0)}setSeparatorWidth(t){this.separatorWidth!=t&&(this.props.separatorWidth=t,this.dirty=!0)}get positionShift(){const t=Number.parseInt(this.tableCol?.tags[Oe.gp.positionShift]??"0")??0;return isNaN(t)?0:Math.max(t,0)}render(t,e,n,r,i,s,a){const l=s.grid?.dart&&s.grid?.canvas===t.canvas;if(!this.seqHelper)return;const u=this.tableCol,c=this.positionShift;t.save();try{const a=this.seqHelper.getSeqHandler(u);let h=this.monomerLengthLimit;if(ur.maxMonomerLength in u.tags){const t=parseInt(u.getTag(ur.maxMonomerLength));h=!isNaN(t)&&t?t:50}if(".mm.cellRenderer.maxMonomerLength"in u.temp){const t=u.temp[".mm.cellRenderer.maxMonomerLength"],e="number"==typeof t?t:parseInt(t);h=!isNaN(e)&&e?e:50}if("1"===u.temp[".mm.cellRenderer.settingsChanged"]||this.monomerLengthLimit!=h){let t=0;const e=8;t=u.temp[".mm.cellRenderer.gapLength"]??t,this.setMonomerLengthLimit(h),this.setSeparatorWidth(a.isMsa()?e:t),u.temp[".mm.cellRenderer.settingsChanged"]="0",this.dirty=!0}const d=s.cell.rowIndex,f=s.cell.value;l&&(r=function(t,e,n,r,o){return t?Math.max(Math.min(t.canvas.width/o-n,r)):Math.max(e.canvas.width/o-n,0)}(s.grid,t,e,r,window.devicePixelRatio)),t.beginPath(),t.rect(e,n,r,i),t.clip(),t.font=this.props?.font??"12px monospace",t.textBaseline="top";const p=u.meta.units,m=u.getTag(Oe.gp.aligned),g=u.getTag(Oe.gp.separator)??"",y=l?a.getSplitted(d):a.splitter(f);let b=hr.classic;m?.includes("MSA")&&p===Oe.Hi.SEPARATOR&&(b=hr.MSA);const v=u.temp["reference-sequence"],C=this.tableCol.temp["current-word"],w=(()=>{const t=(0,a.splitter)(null!=v&&""!==v?v:C??"");return en().count(0).take(t.length).slice(c).map((e=>t.getCanonical(e))).toArray()})(),A=Number.parseInt(u.getTag(Oe.gp.selectedPosition)??"-200");if(this.shouldUseMultilineRendering(u)){const l=[],d=this.calculateMultiLineLayoutDynamic(t,r,i,y,c,h);let f=n+this.padding;1===d.lineLayouts.length&&(f=n+(i-d.lineHeight)/2);for(const r of d.lineLayouts){const i=f+r.lineIdx*d.lineHeight;for(const h of r.elements){const f=e+h.x,p=h,m=p.posIdx,g=y.getCanonical(m);let b=mr;const v=this.getMonomerLib();v&&(b=v.getMonomerTextColor(a.defaultBiotype,g));let C=0;if(s.tableRowIndex!==u.dataFrame.currentRowIdx&&w.length>0){const t=m-c;t>=0&&t<w.length&&g===w[t]&&(C=.7)}l.push({lineIdx:r.lineIdx,monomerIdx:m-c,bounds:new o.Rect(h.x,i-n,h.width,d.lineHeight),sequencePosition:m}),fr(t,p.om,f,i,h.width,d.lineHeight,{color:b,isMultiLineContext:!0,transparencyRate:C,selectedPosition:isNaN(A)||A<1?void 0:A,wordIdx:m})}}null!==s.tableRowIndex&&this._cellBounds.set(s.tableRowIndex,l)}else{this._leftThreeDotsPadding=this.shouldRenderShiftedThreeDots(c)?t.measureText("...").width:0;let[,o]=this.getCellMonomerLengths(s.tableRowIndex,r);l||(o=this.getSummedMonomerLengths(this.getCellMonomerLengthsForSeqValue(f,r)));const u=this.props.separatorWidth+1*this.props.fontCharWidth,d=Math.min(y.length,Math.ceil(r/u)+c);for(let l=c;l<d;++l){const u=l<y.length?y.getOriginal(l):a.defaultGapOriginal,d=l<y.length?y.getCanonical(l):a.defaultGapOriginal;let f=mr;this.getMonomerLib()&&(f=this.getMonomerLib().getMonomerTextColor(a.defaultBiotype,d));const p=l===y.length-1,m={color:f,pivot:0,left:!0,transparencyRate:0,separator:(y?.graphInfo?.disjointSeqStarts?.indexOf(l+1)??0)>0?"|":g,last:p,drawStyle:b,maxWord:o,wordIdx:l-c,gridCell:s,referenceSequence:w,maxLengthOfMonomer:h,monomerTextSizeMap:this._monomerLengthMap,logger:this.logger,selectedPosition:isNaN(A)||A<1?void 0:A-c};fr(t,u,e+this.padding+this._leftThreeDotsPadding,n,r,i,m)}if(this.shouldRenderShiftedThreeDots(c)){const a={color:mr,pivot:0,left:!0,transparencyRate:0,separator:g,last:!1,drawStyle:b,maxWord:o,wordIdx:0,gridCell:s,maxLengthOfMonomer:h,monomerTextSizeMap:this._monomerLengthMap,logger:this.logger};fr(t,"...",e+this.padding,n,r,i,a)}}}catch(t){const[e,n]=(0,Xe.AP)(t);this.logger.error(e,void 0,n),this.errors.push(t)}finally{t.restore()}}shouldRenderShiftedThreeDots(t){return t>0&&(!this.gridCol||!this.gridCol.dart||!this.gridCol.grid||!this.gridCol.grid.dart||(this.gridCol.grid.props.colHeaderHeight??0)<=50)}onMouseMove(t,e){const n=`${this.toLog()}.onMouseMove()`;if(!this.seqHelper||null==t.tableRowIndex)return;const r=this.positionShift,o=t.bounds,i=e.offsetX-t.gridColumn.left+(t.gridColumn.left-o.x),s=e.offsetY-o.y;this.gridCol?.grid?.canvas&&(this.gridCol.grid.canvas.style.cursor="default");let a=null;const l=this._cellBounds.get(t.tableRowIndex);if(l){for(const t of l)if(t.bounds.contains(i,s)){a=t.monomerIdx;break}}else{const e=this.shouldRenderShiftedThreeDots(r)&&(this._leftThreeDotsPadding??0)>0?this._leftThreeDotsPadding:0;a=this.getPosition(t.tableRowIndex,i,o.width,e)}this.logger.debug(`${n}, argsX: ${i}, argsY: ${s}, left: ${a}`);const u=this.seqHelper.getSeqHandler(this.tableCol),c=u.getSplitted(t.tableRowIndex);if(null!==a&&a>=0&&a+r<c.length){const n=u.alphabet??Oe.YI.UN,o={position:a,biotype:n===Oe.YI.RNA||n===Oe.YI.DNA?pr.o.NUCLEOTIDE:pr.o.AA,symbol:c.getCanonical(a+r)},i=[];let s=this._monomerStructureMap[o.symbol];if(!s){const t=this.getMonomerLib();s=this._monomerStructureMap[o.symbol]=t?t.getTooltip(o.biotype,o.symbol):M.divText("Monomer library is not available")}i.push(s),M.tooltip.show(M.divV(i),e.x+16,e.y+16),An(t,o)}else-1===a?M.tooltip.show(M.divText(`${Math.min(r,c.length)} hidden monomers`),e.x+16,e.y+16):M.tooltip.hide(),An(t,null)}}class yr extends gr{constructor(t,e,n,r){super(t,e,xr.logger,n,(()=>{const t=r.getSeqHandler(e),{font:n,fontWidth:o}=gr.getFontSettings(e);return{seqHandler:t,font:n,fontCharWidth:o,separatorWidth:11,monomerToShort:Oe.zS}}))}onMouseMove(t,e){super.onMouseMove(t,e)}}class br{get defaultGapOriginal(){return""}constructor(t,e){this.separator=t,this.helmHelper=e,this.separatorSplitter=(0,Oe.dh)(this.separator),this.splitter=this._splitter.bind(this)}setUnits(){}_splitter(t){const e=this.separatorSplitter(t);return new vr(en().count(0).take(e.length).map((t=>e.getOriginal(t))).toArray(),i.b9[i.Hi.SEPARATOR])}getHelm(t,e){return zn.s.fromSeparator(t,this.helmHelper).getHelm()}createCellRendererBack(t,e){const n=new yr(t,e,4,this.helmHelper.seqHelper);return n.init().then((()=>{})),n}}class vr extends s.Mu{getCanonical(t){if(this.isGap(t))return i._S;const e=this.getOriginal(t);let n=e;return e.startsWith("{")?n=e.slice(1):e.endsWith("}")?n=e.slice(0,-1):e.startsWith("(")?n=e.replace(/^\(.\d+\)/,""):e.endsWith(")")&&(n=e.replace(/\(\d+\)$/,"")),n}constructor(t,e){super(t,e)}}var Cr=function(t,e,n,r){var o,i=arguments.length,s=i<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(i<3?o(s):i>3?o(e,n,s):o(e,n))||s);return i>3&&s&&Object.defineProperty(e,n,s),s},wr=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},Ar=function(t,e){return function(n,r){e(n,r,t)}};r.decorators||(r.decorators={}),["func","init","param","panel","editor","demo","app","appTreeBrowser","fileHandler","fileExporter","model","viewer","filter","cellRenderer","autostart","dashboard","folderViewer","semTypeDetector","packageSettingsEditor","functionAnalysis","converter","fileViewer","model","treeBrowser","polyfill"].forEach((t=>{r.decorators[t]||(r.decorators[t]=function(t){return function(t,e,n){}})}));const xr=new R({debug:!0});let Er=null;class Tr{static async oligoToolkitApp(){await xr.initLibData();const t=await async function(t){const e={"Mermadesynthesis:merMadeSynthesis":{tabName:"SYNTHESIZE",parameters:Je(t)}},n={};for(const[t,o]of Object.entries(e)){let e;try{e=await r.functions.call(t,o.parameters);const i=new ze(o.tabName,e);i.initView(),n[o.tabName]=()=>i.getView()}catch(e){console.warn(`Plugin ${t} not loaded, reason:`,e);continue}}return n}(xr);if(!t)throw new Error("External app view factories not loaded");const e=new Ye(t,xr);return await e.getAppView()}static async init(){return null===Er&&xr.startInit(Er=async function(){const[t]=await Promise.all([(0,Qe.b2)()]);xr.completeInit(t)}()),Er}static async oligoTranslatorApp(){return await Sr("Oligo Translator")}static async oligoPatternApp(){return await Sr("Oligo Pattern")}static async oligoStructureApp(){return await Sr("Oligo Structure")}static async getTranslationHelper(){return await xr.initLibData(),xr}static getCodeToWeightsMap(){const t=xr.monomerLibWrapper.getCodesToWeightsMap();return Object.fromEntries(t)}static validateSequence(t){const e=xr.createSequenceValidator(t),n=xr.createFormatDetector(t).getFormat();return null!==n&&e.isValidSequence(n)}static getMolfileFromGcrsSequence(t,e){return new xe(t,e,"GCRS").convert()}static linkStrands(t){return Ee(t,!0)}static async demoTranslateSequence(){await async function(){await b((async()=>{const t=await Tr.oligoTranslatorApp();r.shell.addView(t)}))}()}static async demoOligoPattern(){await async function(){await b((async()=>{const t=await Tr.oligoPatternApp();r.shell.addView(t)}))}()}static async demoOligoStructure(){await async function(){await b((async()=>{const t=await Tr.oligoStructureApp();r.shell.addView(t),["Afcgacsu","Afcgacsu","Afcgacsu"].forEach((async(t,e)=>{await async function(t,e){await(0,Ke.cb)(500);const n=document.querySelectorAll(".st-colored-text-input > textarea")[t];n.value=e;const r=new Event("input");n.dispatchEvent(r)}(e,t)}))}))}()}static async translateOligonucleotideSequence(t,e,n){return await xr.initLibData(),xr.createFormatConverter(t,e).convertTo(n)}static async polyToolConvertTopMenu(){await async function(){await xr.initPromise;let t=null;try{t=await async function(){const t=[],e=()=>{for(const e of t)e.unsubscribe()};try{let n;const i=r.shell.t.columns.bySemTypeAll(o.SEMTYPE.MACROMOLECULE),s=i.filter((t=>xr.seqHelper.getSeqHandler(t).notation===Oe.Hi.CUSTOM));if(!n){if(i.length<1)throw new Error("No dataframe with macromolecule columns open");if(s.length<1){const t=o.Func.find({package:"Bio",name:"toAtomicLevel"})[0];return t?(t.prepare().edit(),null):(r.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=M.input.column("Column",{table:n.dataFrame,value:n,filter:t=>s.includes(t)}),l=M.input.bool(Pn,{value:!0});M.tooltip.bind(l.root,"Add HELM column");const u=M.input.bool("Linearize",{value:!0});M.tooltip.bind(u.root,"Make representation linear if possible");const c=M.input.bool(Ln,{value:!0}),h=M.input.bool(On,{value:!0});let d;const f=new En._v(En.MU,En.yy,".json",{onValueChanged:t=>{d=t}}),p=M.inlineText([Fn]);M.tooltip.bind(p,"Add or specify rules to use");const m=await f.getForm(),g=M.divV([a,l,u,c,h,p,m]),y=async()=>{try{const t=await f.getActive();await kn(a.value,l.value,u.value,c.value,h.value,t)}catch(t){In(t)}},b=M.dialog(Rn).add(g).onOK((()=>{y()}));return t.push(b.onClose.subscribe((()=>{e()}))),b.history((()=>({generateHelm:l.value,chiralityEngine:c.value,rules:d})),(t=>{l.value=t.generateHelm,c.value=t.chiralityEngine,f.setActive(t.rules)})),b}catch(t){throw e(),t}}(),t?.show()}catch(t){const[e,n]=(0,Xe.AP)(t);r.shell.warning("To run PolyTool Conversion, open a dataframe with macromolecules"),xr.logger.error(e,void 0,n)}}()}static async getPolyToolConvertEditor(t){const e=await rr.create(t);return await e.showDialog()}static async polyToolConvert2(t,e,n,r,o){return(await kn(e,n,!1,r,!1,o))[0]}static async polyToolEnumerateHelmTopMenu(){await Yn(r.shell.tv?.dataFrame.currentCell)}static async polyToolEnumerateChemTopMenu(){$n()}static async polyToolColumnChoice(t,e){var n;(function(t){t.semType=o.SEMTYPE.MACROMOLECULE,t.setTag("aligned","SEQ"),t.setTag("alphabet",Oe.YI.PT)})(n=e),n.meta.units=Oe.Hi.SEPARATOR,n.setTag("separator","-"),await r.data.detectSemanticTypes(t)}static async createMonomerLibraryForPolyTool(t){const e=await t.readAsString(),n=new nr(t.fileName,e),r=await n.getJson(),i=t.fileName.replace(/\.csv$/,".json"),s=JSON.stringify(r,null,2);o.Utils.download(i,s)}static async ptEnumeratorHelmApp(){await Yn()}static async ptEnumeratorChemApp(){$n()}static async getPtHelmEnumeratorDialog(t){return Yn(t)}static async getPtChemEnumeratorDialog(t){return $n(t)}static async enumerateSingleHelmSequence(t,e,n,r=!1){return await Kn(t,"macromolecule",null,{type:Un.aK.Single,placeholders:e.map(((t,e)=>({position:t,monomers:n[e]})))},!!r&&{generateHelm:!0,chiralityEngine:!0,highlightMonomers:!1,rules:[]},xr.helmHelper)}static async enumerateSingleHelmSequenceWithNaturalAAs(t,e=!1){const n=(0,Oe.qp)(t).length,r=Array.from({length:n},((t,e)=>e)),o=r.map((t=>["A","C","D","E","F","G","H","I","K","L","M","N","P","Q","R","S","T","V","W","Y"]));return await Tr.enumerateSingleHelmSequence(t,r,o,e)}static async getPolyToolCombineDialog(){!async function(){const t=[],e=M.divV([]),n=i=>{const s=(()=>{const t=M.divH([]),e=M.input.table("Table",{value:void 0,tooltipText:"Table with sequences"}),n=M.input.choice("Column",{items:[],value:void 0,tooltipText:"Sequence column"});return e.onChanged.subscribe((async()=>{const t=e.value;if(!t)return n.items=[],void(n.value=null);await t.meta.detectSemanticTypes(),await r.data.detectSemanticTypes(t);const i=Array.from(t.columns.categorical),s=i.map((t=>t.name));n.items=s,n.value=i.find((t=>t.semType===o.SEMTYPE.MACROMOLECULE))?.name??s.find((t=>{const e=t.toLowerCase();return e.includes("seq")||e.includes("pep")}))??s[0]})),t.appendChild(e.root),t.appendChild(n.root),t.style.alignItems="center",{root:t,getValue:()=>({table:e.value,column:n.value})}})(),a=M.icons.delete((()=>{if(!s.root.parentElement||t.length<2)return;s.root.remove();const e=t.indexOf(s);-1!==e&&t.splice(e,1)}),"Remove"),l=M.icons.add((()=>{let e=t.indexOf(s);-1===e&&(e=t.length),n(e+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 u=t[i];u?e.insertBefore(s.root,u.root):e.appendChild(s.root),t.splice(i,0,s)};n(0);const i=M.input.string("Separator",{value:"-",tooltipText:"Separator for sequences",nullable:!1});M.dialog("Combine Sequences").add(e).add(i.root).onOK((async()=>{if(!function(){const e=t.map((t=>t.getValue())),n=e.map((t=>t.table)),r=e.map((t=>t.column));return n.every((t=>!!t))&&r.every((t=>!!t))}())return void r.shell.error("Please fill all the fields");const e=t.map((t=>t.getValue())),n=e.map((t=>t.table)),s=e.map((t=>t.column)),a=i.value,l=s.map(((t,e)=>n[e].col(t).toList().filter((t=>!!t))));let u=0;const c=l.reduce(((t,e)=>t*e.length),1);if(c>1e7)return void r.shell.error("Too many combinations. Maximum allowed is 10M");const h=new Array(c).fill(null),d=(t,e)=>{if(e===l.length)return void(h[u++]=t);const n=`${t}${t?a:""}`,r=l[e];for(let t=0;t<l[e].length;t++)d(n+r[t],e+1)};d("",0);const f=o.DataFrame.fromColumns([o.Column.fromStrings("Combined Sequences",h)]);f.name="Combined Sequences",await f.meta.detectSemanticTypes(),await r.data.detectSemanticTypes(f),r.shell.addTableView(f)})).show({resizable:!0})}()}static applyNotationProviderForCyclized(t,e){t.setTag("aligned","SEQ"),t.setTag("alphabet","UN"),t.setTag(".alphabetIsMultichar","true"),t.meta.units=i.Hi.CUSTOM,t.tags["polytool-data-role"]="template",t.temp[a.notationProvider]=new br(e,xr.helmHelper)}}async function Sr(t){await xr.initLibData();const e=function(t,e){switch(t){case"Oligo Translator":return new We(e);case"Oligo Pattern":return new ie(e);case"Oligo Structure":return new Le(e);default:throw new Error(`Unknown app name: ${t}`)}}(t,xr);return await e.getAppView()}Cr([r.decorators.app({icon:"img/icons/toolkit.png",browsePath:"Peptides | Oligo Toolkit",name:"Oligo Toolkit"}),wr("design:type",Function),wr("design:paramtypes",[]),wr("design:returntype",Promise)],Tr,"oligoToolkitApp",null),Cr([r.decorators.init(),wr("design:type",Function),wr("design:paramtypes",[]),wr("design:returntype",Promise)],Tr,"init",null),Cr([r.decorators.app({icon:"img/icons/translator.png",browsePath:"Peptides | Oligo Toolkit",name:"Oligo Translator"}),wr("design:type",Function),wr("design:paramtypes",[]),wr("design:returntype",Promise)],Tr,"oligoTranslatorApp",null),Cr([r.decorators.app({icon:"img/icons/pattern.png",browsePath:"Peptides | Oligo Toolkit",name:"Oligo Pattern"}),wr("design:type",Function),wr("design:paramtypes",[]),wr("design:returntype",Promise)],Tr,"oligoPatternApp",null),Cr([r.decorators.app({icon:"img/icons/structure.png",browsePath:"Peptides | Oligo Toolkit",name:"Oligo Structure"}),wr("design:type",Function),wr("design:paramtypes",[]),wr("design:returntype",Promise)],Tr,"oligoStructureApp",null),Cr([r.decorators.func({outputs:[{type:"object",name:"result"}]}),wr("design:type",Function),wr("design:paramtypes",[]),wr("design:returntype",Promise)],Tr,"getTranslationHelper",null),Cr([r.decorators.func({outputs:[{type:"object",name:"result"}]}),wr("design:type",Function),wr("design:paramtypes",[]),wr("design:returntype",Object)],Tr,"getCodeToWeightsMap",null),Cr([r.decorators.func(),wr("design:type",Function),wr("design:paramtypes",[String]),wr("design:returntype",Boolean)],Tr,"validateSequence",null),Cr([r.decorators.func({name:"validateSequence"}),wr("design:type",Function),wr("design:paramtypes",[String,Boolean]),wr("design:returntype",String)],Tr,"getMolfileFromGcrsSequence",null),Cr([r.decorators.func(),Ar(0,r.decorators.param({type:"object"})),wr("design:type",Function),wr("design:paramtypes",[Object]),wr("design:returntype",String)],Tr,"linkStrands",null),Cr([r.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"}),wr("design:type",Function),wr("design:paramtypes",[]),wr("design:returntype",Promise)],Tr,"demoTranslateSequence",null),Cr([r.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"}),wr("design:type",Function),wr("design:paramtypes",[]),wr("design:returntype",Promise)],Tr,"demoOligoPattern",null),Cr([r.decorators.func({meta:{demoPath:"Bioinformatics | Oligo Toolkit | Structure",path:"%20/apps/Tutorials/Demo/Bioinformatics/Oligonucleotide%20Sequence:%20Visualize%20duplex"},description:"Visualize duplex and save SDF"}),wr("design:type",Function),wr("design:paramtypes",[]),wr("design:returntype",Promise)],Tr,"demoOligoStructure",null),Cr([r.decorators.func(),wr("design:type",Function),wr("design:paramtypes",[String,String,String]),wr("design:returntype",Promise)],Tr,"translateOligonucleotideSequence",null),Cr([r.decorators.func({"top-menu":"Bio | PolyTool | Convert...",name:"polyToolConvert",description:"editor for Performing conversion of sequences in custom notation to molfiles"}),wr("design:type",Function),wr("design:paramtypes",[]),wr("design:returntype",Promise)],Tr,"polyToolConvertTopMenu",null),Cr([r.decorators.editor(),wr("design:type",Function),wr("design:paramtypes",[o.FuncCall]),wr("design:returntype",Promise)],Tr,"getPolyToolConvertEditor",null),Cr([r.decorators.func({editor:"SequenceTranslator:getPolyToolConvertEditor"}),Ar(1,r.decorators.param({options:{caption:"Sequence"}})),Ar(2,r.decorators.param({options:{initialValue:"true"}})),Ar(3,r.decorators.param({options:{initialValue:"true"}})),Ar(4,r.decorators.param({type:"object"})),wr("design:type",Function),wr("design:paramtypes",[o.DataFrame,o.Column,Boolean,Boolean,Array]),wr("design:returntype",Promise)],Tr,"polyToolConvert2",null),Cr([r.decorators.func({"top-menu":"Bio | PolyTool | Enumerate HELM...",name:"polyToolEnumerateHelm",description:"Dialog for configuring enumeration of a HELM sequence"}),wr("design:type",Function),wr("design:paramtypes",[]),wr("design:returntype",Promise)],Tr,"polyToolEnumerateHelmTopMenu",null),Cr([r.decorators.func({"top-menu":"Bio | PolyTool | Enumerate Chem...",name:"polyToolEnumerateChem",description:"Perform enumeration of a molecule using different fragments at specified positions"}),wr("design:type",Function),wr("design:paramtypes",[]),wr("design:returntype",Promise)],Tr,"polyToolEnumerateChemTopMenu",null),Cr([r.decorators.func(),Ar(0,r.decorators.param({options:{description:"Input data table"}})),wr("design:type",Function),wr("design:paramtypes",[o.DataFrame,o.Column]),wr("design:returntype",Promise)],Tr,"polyToolColumnChoice",null),Cr([r.decorators.func(),wr("design:type",Function),wr("design:paramtypes",[o.FileInfo]),wr("design:returntype",Promise)],Tr,"createMonomerLibraryForPolyTool",null),Cr([r.decorators.func({meta:{icon:"img/icons/structure.png",browsePath:"Peptides | PolyTool"},tags:["app"],name:"HELM Enumerator"}),wr("design:type",Function),wr("design:paramtypes",[]),wr("design:returntype",Promise)],Tr,"ptEnumeratorHelmApp",null),Cr([r.decorators.func({meta:{icon:"img/icons/structure.png",browsePath:"Peptides | PolyTool"},tags:["app"],name:"Chem Enumerator"}),wr("design:type",Function),wr("design:paramtypes",[]),wr("design:returntype",Promise)],Tr,"ptEnumeratorChemApp",null),Cr([r.decorators.func({name:"Polytool Helm Enumerator dialog"}),Ar(0,r.decorators.param({type:"object",options:{nullable:!0}})),wr("design:type",Function),wr("design:paramtypes",[o.Cell]),wr("design:returntype",Promise)],Tr,"getPtHelmEnumeratorDialog",null),Cr([r.decorators.func({name:"Polytool Chem Enumerator dialog"}),Ar(0,r.decorators.param({type:"object",options:{nullable:!0}})),wr("design:type",Function),wr("design:paramtypes",[o.Cell]),wr("design:returntype",Promise)],Tr,"getPtChemEnumeratorDialog",null),Cr([r.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"}]}),wr("design:type",Function),wr("design:paramtypes",[String,Array,Array,Boolean]),wr("design:returntype",Promise)],Tr,"enumerateSingleHelmSequence",null),Cr([r.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"}]}),wr("design:type",Function),wr("design:paramtypes",[String,Boolean]),wr("design:returntype",Promise)],Tr,"enumerateSingleHelmSequenceWithNaturalAAs",null),Cr([r.decorators.func({name:"Combine Sequences","top-menu":"Bio | PolyTool | Combine Sequences..."}),wr("design:type",Function),wr("design:paramtypes",[]),wr("design:returntype",Promise)],Tr,"getPolyToolCombineDialog",null),Cr([r.decorators.func({name:"applyNotationProviderForHarmonizedSequence"}),Ar(0,r.decorators.param({type:"column"})),wr("design:type",Function),wr("design:paramtypes",[o.Column,String]),wr("design:returntype",void 0)],Tr,"applyNotationProviderForCyclized",null)},5412:(t,e,n)=>{"use strict";n.d(e,{m:()=>l});var r=n(6082),o=n(4328),i=n(4971),s=n(6077),a=n(2003);async function l(t,e,n,l,u,c,h,d,f){const p=(await f.helmToAtomicLevel(t,l,u,h)).molCol,m=n.filter((t=>t)).length;if(c&&m>0){const t=new Array(m);let l=0;for(let r=0;r<n.length;r++)n[r]&&(t[l]=e[r],l++);const u=r.Column.fromStrings("helm",t);u.semType=r.SEMTYPE.MACROMOLECULE,u.meta.units=a.Hi.HELM,u.setTag(r.TAGS.CELL_RENDERER,"helm");const c=(await(0,i.pj)()).getMonomerLib();try{const t=await(0,s.C4)(r.DataFrame.create(0),u,c,f,d);l=0;for(let e=0;e<n.length;e++)n[e]&&(p.set(e,t.molCol.get(l)),l++)}catch(t){o.shell.warning("PolyTool was not able to linearize sequences")}}return function(t){for(let e=0;e<t.length;e++)t.set(e,t.get(e).replaceAll("undefined","H")),t.set(e,t.get(e).replaceAll("Oh","O").replaceAll("OH","O")),t.set(e,t.get(e).replaceAll("0.000000 3","0.000000 0")),t.set(e,t.get(e).replaceAll("?","O")),t.set(e,t.get(e).replaceAll(" 0 3\n"," 0 0\n")),t.set(e,t.get(e).replaceAll("RGROUPS=(1 1)",""))}(p),p}},6307:(t,e,n)=>{"use strict";n.d(e,{s:()=>f});var r=n(2125),o=n(8438),i=n(6694);function s(t,e){let n="";for(let t=0;t<e.length;t++){t>0&&(n+="|"),n+=`PEPTIDE${t+1}{`;for(let r=0;r<e[t].length;r++){r>0&&(n+=".");const o=e[t][r];n+=o.length>1?`[${o}]`:o}n+="}"}n+="$";for(let o=0;o<t.length;o++)o>0&&(n+="|"),n+=`PEPTIDE${t[o].fChain+1},PEPTIDE${t[o].sChain+1},`,n+=`${(0,r.M)(t[o].fMonomer-1,e)[0]+1}:R${t[o].fR}-`,n+=`${(0,r.M)(t[o].sMonomer-1,e)[0]+1}:R${t[o].sR}`;return n+="$$$V2.0",n}function a(t,e,n,r=0,o=[],i=[]){let[s,a,l,u,c]=[!1,!1,!1,-1,-1];for(let h=0;h<t.length;h++)if(t[h].includes(e)){if(s){if(l&&(n||t[h]==i[r]+e)){a=!0,c=h;break}if(l||!n&&t[h]!=o[r]+e)continue;a=!0,c=h;break}if(n)s=!0,l=!0,u=h;else if(t[h]==o[r]+e)s=!0,l=!0,u=h;else{if(t[h]!=i[r]+e)continue;s=!0,l=!!n,u=h}}return[s,a,l,u,c]}function l(t,e){const n=[];for(let r=0;r<e.length;r++){const o=`(${e[r].code})`,[s,l]=(0,i.Ln)(e[r]);if(s.length>0)for(let e=0;e<s.length;e++){const[i,u,c,h,d]=a(t,o,!1,e,s,l);i&&u&&(c?n.push({firstIdx:h,secondIdx:d,ruleIdx:r}):n.push({firstIdx:d,secondIdx:h,ruleIdx:r}))}else{const[e,i,s,l,u]=a(t,o,!0);if(!e||!i)continue;s?n.push({firstIdx:l,secondIdx:u,ruleIdx:r}):n.push({firstIdx:u,secondIdx:l,ruleIdx:r})}}return n}function u(t,e,n){const r=[],o=[],i=[],s=[],a=n.length;for(let l=0;l<a;l++){if(-1==n[l].firstIdx)continue;const a=n[l].ruleIdx,u=t[a].code;e[n[l].firstIdx]=e[n[l].firstIdx].replace(`(${u})`,""),e[n[l].secondIdx]=e[n[l].secondIdx].replace(`(${u})`,""),r.push(n[l].firstIdx+1),o.push(n[l].secondIdx+1),i.push(t[a].firstLinkingGroup),s.push(t[a].secondLinkingGroup)}return[r,o,i,s]}function c(t,e,n){const r=[],o=[],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,u=n[a].ruleIdx,c=t[u].code;e[s]=e[s].replace(`(${c})`,"")+`_${t[u].name}`,e[l]=e[l].replace(`(${c})`,"")+`_${t[u].name}`,r.push(s+1),o.push(l+1),i.push(n[a].ruleIdx)}return[r,o,i]}var h=n(3599);function d(t,e,n){const r=n.createHelmWebEditor().editor.m;let o=0;const i=new JSDraw2.Point(0,0);for(let t=0;t<e.length;t++)for(let n=0;n<e[t].length;n++){if(e[t][n]){const s=e[t][n],a={type:h.o.AA,i:t,j:n,continuousId:o},l=new JSDraw2.Atom(i,s,a);if(r.addAtom(l),0!==n){const t=r.atoms[o-1],e=r.atoms[o],n=new JSDraw2.Bond(t,e);n.r1=2,n.r2=1,r.addBond(n)}o++,i.x+=JSDraw2.Editor.BONDLENGTH}i.y+=4*JSDraw2.Editor.BONDLENGTH}for(let e=0;e<t.length;e++){const n=r.atoms[t[e].fMonomer-1],o=r.atoms[t[e].sMonomer-1],i=new JSDraw2.Bond(n,o);i.r1=t[e].fR,i.r2=t[e].sR,r.addBond(i)}return r}class f{constructor(t,e,n){this.helmHelper=n,this.underRules=!1,this.posToPosUnderRules=[],this.linkages=e,this.monomers=t,this.mol=d(e,t,n)}static fromSeparator(t,e){const[n,r]=function(t){const e=[],n=[],r=/(\(.\d+\))?\{[^\}]*\}/g,o=[];o.push(t.replaceAll(r,""));const i=t.matchAll(r);for(const t of i){const e=t[0];e&&o.push(e)}let s=0;for(let t=0;t<o.length;t++){const r=o[t].split("-"),i=new Array(r.length);let a=0;for(let e=0;e<r.length;e++){const o=r[e].replace("{","").replace("}","");""!==o?(i[e]=o,s++,a++):n.push({fChain:t,sChain:t+1,fMonomer:s,sMonomer:s+1,fR:1,sR:1})}e.push(i.slice(0,a))}return[n,e]}(t);return new f(r,n,e)}static fromHelm(t,e){const[n,i]=function(t){const e=/(\w+\{.*\})\$(.*)\$(.*)\$(.*)\$/g.exec(t),n=[e[1],e[2],e[3],e[4]],i=n[0].split("|"),s=n[1].split("|"),a=new Array(i.length),l=[];for(let t=0;t<i.length;t++){const e=i[t].indexOf("{"),n=i[t].indexOf("}");a[t]=i[t].slice(e+1,n).split(".").map((t=>(0,o.D)(t)))}for(let t=0;t<s.length;t++)if(""!==s[t]&&"V2.0"!==s[t]){const e=s[t].split(","),n=parseInt(e[0].replace("PEPTIDE",""))-1,o=parseInt(e[1].replace("PEPTIDE",""))-1,i=e[2].split("-"),u=i[0].split(":"),c=i[1].split(":");l.push({fChain:n,sChain:o,fMonomer:(0,r.j)(parseInt(u[0]),n,a),sMonomer:(0,r.j)(parseInt(c[0]),o,a),fR:parseInt(u[1].replace("R","")),sR:parseInt(c[1].replace("R",""))})}return[l,a]}(t);return new f(i,n,e)}getNotation(){return function(t){const e=t.atoms,n=t.bonds,r=[],o=[];for(let t=0;t<n.length;t++)n[t].a1.bio.i!==n[t].a2.bio.i&&o.push(t);for(let t=0;t<e.length;t++){const n=e[t].bio?.i;n+1>r.length?r.push(1):r[n]++}const i=new Array(r.length);let s=0;for(let t=0;t<r.length;t++){const n=new Array(r[t]);for(let o=0;o<r[t];o++)n[o]=e[s].elem,s++;i[t]=n}let a="";for(let t=0;t<i.length;t++){let e="";for(let n=0;n<i[t].length;n++)e+=`${0==n?"":"-"}${i[t][n]}`;if(0!==t){const t=/(\(.\d+\))/,n=e.match(t);e=e.replace(n?.[0],""),e=`${n?n?.[0]:""}{${e}}`}else if(i.length>1){const t=0==n[o[0]].a1.bio.i&&0==n[o[0]].a1.bio.j,r=1==n[o[0]].a2.bio.i&&0==n[o[0]].a1.bio.j;t&&r&&(e+="-")}a+=e}return a}(this.mol)}getHelm(){return this.underRules?s(this.linkagesUnderRules,this.monomersUnderRules):s(this.linkages,this.monomers)}applyRules(t){const e=this.getNotation(),[n,r,o]=function(t,e){const n=[],r=[],o=[],i=e.heterodimerCode,s=e.homodimerCode,a=null!==i?t.split(`(${e.heterodimerCode})`):"";null!==i&&a.length>1?(o.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("}","")),r.push(!1),r.push(!1)):(n.push(t),r.push(!1));for(let t=0;t<n.length;t++)if(null!==s&&n[t].includes(`(${s})`)){const e=n.length;o.push({fChain:t,sChain:e,fMonomer:1,sMonomer:1,fR:1,sR:1});const i=n[t].replace(`(${s})`,""),a=i.indexOf("{"),l=i.slice(0,a),u=i.replace(l,"").replaceAll("{","").replaceAll("}","");n[t]=l+u,n.push(u),r.push(!0)}return[o,n,r]}(e,t),i=new Array(r.length);let s=0;for(let t=0;t<r.length;t++)if(i[t]=r[t].split("-"),o[t]){const e=this.posToPosUnderRules.length-i[t].length;for(let n=0;n<i[t].length;n++)this.posToPosUnderRules[e+n].push(s),s++}else for(let e=0;e<i[t].length;e++)this.posToPosUnderRules.push([s]),s++;!function(t,e,n){for(let r=0;r<t.length;r++){const o=t[r],i=l(o,n.linkRules),[s,a,c,h]=u(n.linkRules,o,i);for(let t=0;t<s.length;t++)e.push({fChain:r,sChain:r,fMonomer:s[t],sMonomer:a[t],fR:c[t],sR:h[t]});t[r]=o}}(i,n,t),function(t,e,n){for(let r=0;r<t.length;r++){const o=l(t[r],n.reactionRules),[i,s,a]=c(n.reactionRules,t[r],o);i.length>=1&&(e.push({fChain:r,sChain:t.length,fMonomer:i[0],sMonomer:1,fR:3,sR:1}),e.push({fChain:r,sChain:t.length,fMonomer:s[0],sMonomer:1,fR:3,sR:2}),t.push([n.reactionRules[a[0]].name]))}}(i,n,t),this.underRules=!0,this.linkagesUnderRules=n,this.monomersUnderRules=i,this.molUnderRules=d(n,i,this.helmHelper)}check(t=!1){const e=[],n=this.monomers.map((t=>t.length)).reduce(((t,e)=>t+e),0);this.mol.atoms.length!==n&&e.push(`The mol atoms count ${this.mol.atoms.length} does not match the total number ${n} of chains' monomers.`);const r=this.monomers.map((t=>t.length-1)).reduce(((t,e)=>t+e),0)+this.linkages.length;this.mol.bonds.length!==r&&e.push(`The mol bonds count ${this.mol.bonds.length} does not match the total number ${r} in- and inter-chain linkages.`);let o=0;for(let t=0;t<this.monomers.length;++t){const n=this.monomers[t];for(let t=0;t<n.length;++t)try{const r=n[t],i=this.mol.atoms[o];i.bio.continuousId!==o&&e.push(`Atom #${o} has incorrect .bio.continuousId: ${i.bio.continuousId}.`),i.elem!==r&&e.push(`Atom #${o} elem: '${i.elem}' does not match chain monomer: '${r}'.`)}finally{o++}}if(t&&e.length>0)throw new Error(`Chain errors:\n${e.map((t=>` ${t}`)).join("\n")}`);return e}}},4229:(t,e,n)=>{"use strict";n.d(e,{b:()=>s});var r=n(9192),o=n(6307),i=n(9788);function s(t,e,n){const s=new Array(t.length),a=new Array(t.length),l=new Array(t.length);for(let u=0;u<t.length;u++)try{if(null==t[u])s[u]="";else{const r=o.s.fromSeparator(t[u],n);r.applyRules(e),a[u]=!(r.monomersUnderRules.length>1||r.linkagesUnderRules.length>0),s[u]=r.getHelm(),l[u]=r.posToPosUnderRules}}catch(t){const[e,n]=(0,r.AP)(t);i._package.logger.error(e,void 0,n),s[u]=""}return[s,a,l]}},2125:(t,e,n)=>{"use strict";function r(t,e){let n,r=t;for(n=0;n<e.length&&r>=e[n].length;++n)r-=e[n].length;return[r,n]}function o(t,e,n){let r=0;for(let t=0;t<e;++t)r+=n[t].length;return r+t}n.d(e,{M:()=>r,j:()=>o})},6694:(t,e,n)=>{"use strict";n.d(e,{MU:()=>V,yy:()=>q,_v:()=>Q,Ln:()=>et,Q4:()=>tt});var r=n(6082),o=n(4328),i=n(7389),s=n(1991),a=n.n(s),l=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{l(r.next(t))}catch(t){i(t)}}function a(t){try{l(r.throw(t))}catch(t){i(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}l((r=r.apply(t,e||[])).next())}))};class u{constructor(t,e,n=".csv",r){this.path=t,this.userStorageName=e,this.ext=n,this.options=r,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 t=o.userSettings.getValue(this.userStorageName,"Settings"),e=t?JSON.parse(t):{excluded:[],explicit:[]};return e.explicit=e.explicit instanceof Array?e.explicit:[],e.excluded=e.excluded instanceof Array?e.excluded:[],this.settings=e}))}setUserSettings(t){this.settings=t,o.userSettings.add(this.userStorageName,"Settings",JSON.stringify(t))}getAllAvailable(){return l(this,void 0,void 0,(function*(){return(yield o.dapi.files.list(this.path)).map((t=>t.fullPath.replace(`${this.path}`,"")))}))}getActive(){return l(this,void 0,void 0,(function*(){const t=yield this.getUserSettings();return t.explicit.length>0?t.explicit:(yield this.getAllAvailable()).filter((e=>!t.excluded.includes(e)))}))}setActive(t){const e=new Set(t);for(const[t,n]of this.inputs.entries())n.value=e.has(t)}createInput(t,e){const n=i.input.bool(t,{value:e,onValueChanged:e=>this.updateSelectionStatus(t,e)});return n.addOptions(i.button(i.iconFA("trash"),(()=>{i.dialog({title:"Warning"}).add(i.divText(`Delete file '${t}'?`)).onOK((()=>{n.root.remove(),this.availableRemove(t)})).show()}),`Delete ${t}`)),n}getInputs(){return l(this,void 0,void 0,(function*(){this.inputs=new Map;const t=yield this.getAllAvailable(),e=yield this.getActive(),n=new Array(t.length);for(let r=0;r<t.length;r++){const o=e.includes(t[r]);n[r]=this.createInput(t[r],o),this.inputs.set(t[r],n[r])}return this.fireOnValueChanged(),n}))}getForm(){return l(this,void 0,void 0,(function*(){const t=yield this.getInputs(),e=i.divV(t);return i.divV([e,i.button("ADD",(()=>l(this,void 0,void 0,(function*(){let t="";if(t=yield this.getNewAvailable(),""!==t){const n=this.createInput(t,!0);e.append(n.root),this.inputs.set(t,n),this.fireOnValueChanged()}}))))])}))}fireOnValueChanged(){var t;null===(t=this.options)||void 0===t||t.onValueChanged(a()(this.inputs.entries()).filter((([t,e])=>e.value)).map((([t,e])=>t)).toArray())}updateSelectionStatus(t,e){return l(this,void 0,void 0,(function*(){const n=yield this.getUserSettings();if(!n.excluded.includes(t)!==e){if(e){const e=n.excluded.indexOf(t);e>-1&&n.excluded.splice(e,1)}else n.excluded.push(t);this.fireOnValueChanged(),this.setUserSettings(n)}}))}availableRemove(t){return l(this,void 0,void 0,(function*(){this.inputs.delete(t),this.fireOnValueChanged();const e=yield this.getUserSettings(),n=e.excluded.indexOf(t);n>-1&&e.excluded.splice(n,1),this.setUserSettings(e),yield o.dapi.files.delete(this.path+t),o.shell.info(`File ${t} successfully deleted`)}))}getNewAvailable(){return l(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{r.Utils.openFile({accept:this.ext,open:e=>l(this,void 0,void 0,(function*(){const n=e.name,r=yield e.arrayBuffer();yield o.dapi.files.write(this.path+`${e.name}`,new Uint8Array(r)),t(n)}))})}))}))}}var c=n(9788),h=n(9124),d=n(4229),f=n(439),p=n(5174),m=n(5412),g=n(6717),y=n(8312);function b(t){let e=t.replaceAll(/\[R[1-9]\]/g,(t=>`[*:${t[2]}]`));return e=e.replaceAll(/\[\d\*\]/g,(t=>`[*:${t[1]}]`)),e.replaceAll(/\[\d\*\:\d\]/g,(t=>`[*:${t[1]}]`))}function v(t){return t.replaceAll(/\[\*\:\d\]/g,(t=>`[C:${t[3]}]`))}function C(t){return t.replaceAll(/\[C\:\d\]/g,(t=>`[*:${t[3]}]`))}function w(t,e){const n=e?.firstReactantSmiles?C(e.firstReactantSmiles):"[*:1]C",r=e?.secondReactantSmiles?C(e.secondReactantSmiles):"[*:2]C",s=e?.productSmiles?C(e.productSmiles):"[*:1]CC[*:2]",a=e?.code,l=e?.firstMonomers??[],u=e?.secondMonomers??[],c=e?.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"}),f=i.input.string("Second monomers",{value:u.join(","),nullable:!1,tooltipText:"Comma-separated list of monomers for the second reactant"}),p=i.input.string("Result monomer name",{value:c,nullable:!1,tooltipText:"Name of the resulting pseudo-monomer generated by the reaction of the two reactants"}),m=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:r,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."}),w=()=>{if(!m||!g||!y)return"Inputs not initialized yet";const t=v(b(o.chem.convert(m.value??"",o.chem.Notation.Unknown,o.chem.Notation.Smiles))),e=v(b(o.chem.convert(g.value??"",o.chem.Notation.Unknown,o.chem.Notation.Smiles))),n=v(b(o.chem.convert(y.value??"",o.chem.Notation.Unknown,o.chem.Notation.Smiles)));return t&&e&&n?-1==t.indexOf("[C:1]")?"First Reactant must contain R1-group":-1==e.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"};m.addValidator(w),g.addValidator(w),y.addValidator(w);const A=i.dialog(e?"Edit Reaction Rule":"Add Reaction Rule").add(h).add(p).add(d).add(f).add(m).add(g).add(y);A.addButton("Save",(()=>{const n=w();if(null!=n)return void o.shell.warning(n);const r=v(b(o.chem.convert(m.value??"",o.chem.Notation.Unknown,o.chem.Notation.Smiles))),i=v(b(o.chem.convert(g.value??"",o.chem.Notation.Unknown,o.chem.Notation.Smiles))),s=v(b(o.chem.convert(y.value??"",o.chem.Notation.Unknown,o.chem.Notation.Smiles)));t({code:h.value,resultMonomerName:p.value,firstMonomers:d.value.split(",").map((t=>t.trim())).filter((t=>t.length>0)),secondMonomers:f.value.split(",").map((t=>t.trim())).filter((t=>t.length>0)),firstReactantSmiles:r,secondReactantSmiles:i,productSmiles:s,rowIndex:e?.rowIndex}),A.close()})),A.show()}const A="Links",x="Reactions";class E{constructor(t,e){this.v=null,this.substituteReactionGridDataFrame=null,this.rules=t;const n=this.rules.getLinkRulesDf();this.linkRuleDataFrame=n.res,this.addLinkRulesFunc=n.addNewRow;const r=this.rules.getSynthesisRulesDf();this.addSynthRulesFunc=t=>{r.addNewRow(t),this.rules.setSynthesisRules(r.df),this.synthRuleDataFrame=r.df,this.substituteReactionGridDataFrame?.(),this.save()},this.synthRuleDataFrame=r.df,this.fileName=e;const o=this.rules.homodimerCode?this.rules.homodimerCode:"",s=this.rules.heterodimerCode?this.rules.heterodimerCode:"";this.homoDimerInput=i.input.string("Homo dimer",{value:o,onValueChanged:()=>{},nullable:!1}),this.heteroDimerInput=i.input.string("Hetero dimer",{value:s,onValueChanged:()=>{},nullable:!1})}async getAndAddView(){if(this.v)try{const t=Array.from(o.shell.views).find((t=>t.name===this.v.name));if(!t)throw this.v.detach(),this.v.close(),new Error("View is closed, making it null in catch statement");o.shell.v=t}catch(t){this.v=null}return this.v||(this.v=r.View.create(),this.v.name=`Manage Polytool Rules - ${this.fileName}`,this.v.append(await this.getForm()),this.v=o.shell.addView(this.v),o.shell.v=this.v),this.v}static async getInstance(t){if(!this.instances[t]){const e=await tt([t]);this.instances[t]=new E(e,t)}return this.instances[t]}save(){this.rules.homodimerCode=this.homoDimerInput.value,this.rules.heterodimerCode=this.heteroDimerInput.value,this.rules.setLinkRules(this.linkRuleDataFrame),this.rules.setSynthesisRules(this.synthRuleDataFrame);const t={homodimerCode:this.rules.homodimerCode,heterodimerCode:this.rules.heterodimerCode,linkRules:this.rules.linkRules,reactionRules:this.rules.reactionRules},e=JSON.stringify(t,void 0,2);c._package.files.writeAsText(`polytool-rules/${this.fileName}`,e),o.shell.info(`Polytool rules at ${this.fileName} was updated`)}createGridDiv(t,e,n){const r=i.h1(t,"polytool-grid-header");i.tooltip.bind(r,n),r.style.marginTop="10px",r.style.marginRight="10px",e.root.style.height="100%";const o=i.splitV([i.box(r,{style:{maxHeight:"60px"}}),e.root]);return o.style.height="100%",o}async getLinkExamplesGrid(){const t=[];for(let e=0;e<this.rules.linkRules.length;e++){const n=this.rules.linkRules[e].code,[r,o]=et(this.rules.linkRules[e]);for(let e=0;e<r.length;e++){const i=`${r[e]}(${n})-A-A-A-A-${o[e]}(${n})`;t.push(i)}}const e=await(0,h.b2)(),[n,o,i]=(0,d.b)(t,this.rules,e),s=r.Column.fromStrings("Monomers",t),a=r.Column.fromStrings("Helm",n);return c.PackageFunctions.applyNotationProviderForCyclized(s,"-"),s.semType=r.SEMTYPE.MACROMOLECULE,a.semType=r.SEMTYPE.MACROMOLECULE,a.meta.units=f.Hi.HELM,a.setTag(r.TAGS.CELL_RENDERER,"helm"),r.DataFrame.fromColumns([s,a]).plot.grid()}async getReactionExamplesGrid(){const t=[];for(let e=0;e<this.rules.reactionRules.length;e++){const n=this.rules.reactionRules[e].code,[r,o]=et(this.rules.reactionRules[e]);for(let e=0;e<r.length;e++){const i=`${r[e]}(${n})-A-A-A-A-${o[e]}(${n})`;t.push(i)}}const e=await(0,h.b2)(),[n,o,i]=(0,d.b)(t,this.rules,e),s=r.Column.fromStrings("Monomers",t),a=r.Column.fromStrings("Helm",n),l=r.DataFrame.fromColumns([s,a]);s.semType=r.SEMTYPE.MACROMOLECULE;const u=await(0,g.j)(),b=await(0,y.Q)();c.PackageFunctions.applyNotationProviderForCyclized(s,"-"),s.tags[r.TAGS.CELL_RENDERER]="Sequence",a.semType=r.SEMTYPE.MACROMOLECULE,a.meta.units=f.Hi.HELM,a.setTag(r.TAGS.CELL_RENDERER,"helm");const v=await(0,p.A)(this.rules),C=a.temp;C[".mm.cellRenderer.overriddenLibrary"]=v,a.temp=C;const w=await(0,m.m)(a,t,o,!0,!1,!1,v,u,b);return w.name="molfile(sequence)",w.semType=r.SEMTYPE.MOLECULE,l.columns.add(w),l.plot.grid()}async getForm(){const t=this.linkRuleDataFrame.plot.grid({showAddNewRowIcon:!1,allowEdit:!1,rowHeight:60});t.onCellDoubleClick.subscribe((()=>{if(!t.dataFrame||-1==t.dataFrame.currentRowIdx||null==t.dataFrame.currentRowIdx)return;const e=t.dataFrame.currentRowIdx,n={row:e,code:this.linkRuleDataFrame.get("code",e),firstMonomers:this.linkRuleDataFrame.get("firstMonomers",e),secondMonomers:this.linkRuleDataFrame.get("secondMonomers",e),firstLinkingGroup:this.linkRuleDataFrame.get("firstLinkingGroup",e),secondLinkingGroup:this.linkRuleDataFrame.get("secondLinkingGroup",e)};this.getAddNewLinkRuleDialog(n)}));const e=this.createGridDiv("Rules",t,"specification for monomers to link and linking positions"),n=this.createGridDiv("Examples",await this.getLinkExamplesGrid(),"specification for monomers to link and linking positions");e.style.width="50%",n.style.width="50%";const r=i.h1("Monomers","polytool-grid-header");i.tooltip.bind(r,"Click different cobination to see how monomers will link"),this.linkCards=await this.rules.getLinkCards();const o=i.splitV([i.box(r,{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 t=this.linkRuleDataFrame.currentRowIdx;-1!==t&&null!=t&&(i.empty(o),o.append(i.splitV([i.box(r,{style:{maxHeight:"30px"}}),this.linkCards[t].root])),this.linkCards[t].render(),await this.linkCards[t].reset())}));const s=i.splitH([e,o],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 t=a.dataFrame.currentRowIdx;w((t=>this.addSynthRulesFunc(t)),{rowIndex:t,code:this.synthRuleDataFrame.get("code",t),firstMonomers:this.synthRuleDataFrame.get("firstMonomers",t).split(",").map((t=>t.trim())).filter((t=>t)),secondMonomers:this.synthRuleDataFrame.get("secondMonomers",t).split(",").map((t=>t.trim())).filter((t=>t)),resultMonomerName:this.synthRuleDataFrame.get("name",t),firstReactantSmiles:this.synthRuleDataFrame.get("firstReactant",t),secondReactantSmiles:this.synthRuleDataFrame.get("secondReactant",t),productSmiles:this.synthRuleDataFrame.get("product",t)})}));const l=this.createGridDiv("Rules",a),u=await this.getReactionExamplesGrid(),c=this.createGridDiv("Examples",u);this.substituteReactionGridDataFrame=async()=>{const t=await this.getReactionExamplesGrid();u.dataFrame=t.dataFrame},l.style.width="50%",c.style.width="50%";const h=i.divH([l,c]),d=i.divV([this.homoDimerInput,this.heteroDimerInput]),f=i.tabControl({Links:s,Reactions:h,Dimers:d},!1);i.tooltip.bind(f.getPane(A).header,"Specify rules to link monomers based on HELM notation"),i.tooltip.bind(f.getPane(x).header,"Specify rules to perform reactions within monomers"),i.tooltip.bind(f.getPane("Dimers").header,"Specify symbols for homodimeric and heterodimeric codes"),f.root.style.height="100%",f.root.style.width="100%",f.root.classList.add("rules-manager-form-tab-control"),f.header.style.marginBottom="10px";const p=i.divV([f.root]),m=[i.bigButton("Save",(()=>{this.save()})),i.button("Add rule",(()=>{const t=f.currentPane.name;t==A?this.getAddNewLinkRuleDialog():t==x&&w((t=>this.addSynthRulesFunc(t)))})),i.button("Remove rule",(()=>{const e=f.currentPane.name;if(e==A){if(null==this.linkRuleDataFrame||-1==this.linkRuleDataFrame.currentRowIdx||null==this.linkRuleDataFrame.currentRowIdx)return;const e=t.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(e),this.rules.setLinkRules(this.linkRuleDataFrame),this.save()})).show()}else if(e==x){if(null==this.synthRuleDataFrame||-1==this.synthRuleDataFrame.currentRowIdx||null==this.synthRuleDataFrame.currentRowIdx)return;const t=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(t),this.rules.setSynthesisRules(this.synthRuleDataFrame),this.substituteReactionGridDataFrame?.(),this.save()})).show()}}))];return this.v.setRibbonPanels([m]),p.style.height="100%",p.style.alignItems="center",f.root}getAddNewLinkRuleDialog(t){const e=i.input.int("Code",{nullable:!1,value:t?.code}),n=i.input.string("First monomers",{placeholder:"E.g. C,D,E",value:t?.firstMonomers,tooltipText:"Comma separated list of first monomers applicable for the rule. If left empty, all monomers will be considered",nullable:!0}),r=i.input.string("Second monomers",{placeholder:"E.g. C,D,E",value:t?.secondMonomers,tooltipText:"Comma separated list of second monomers applicable for the rule. If left empty, all monomers will be considered",nullable:!0}),o=t?.firstLinkingGroup?`R${t.firstLinkingGroup}`:"R3",s=t?.secondLinkingGroup?`R${t.secondLinkingGroup}`:"R3",a=i.input.choice("First linking group",{value:o,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(e).add(n).add(r).add(a).add(l).onOK((async()=>{const o=e.value,i=(n.value??"").split(",").map((t=>t.trim())).filter((t=>t)).join(","),s=(r.value??"").split(",").map((t=>t.trim())).filter((t=>t)).join(","),u=parseInt(a.value.substring(1)),c=parseInt(l.value.substring(1));this.addLinkRulesFunc({code:o,firstMonomers:i??"",secondMonomers:s??"",firstLinkingGroup:u,secondLinkingGroup:c,row:t?.row}),this.rules.setLinkRules(this.linkRuleDataFrame),this.linkCards=await this.rules.getLinkCards(),this.save()})).show()}}E.instances={};var T=n(5072),S=n.n(T),I=n(7825),_=n.n(I),N=n(7659),M=n.n(N),P=n(5056),L=n.n(P),O=n(540),R=n.n(O),D=n(1113),F=n.n(D),B=n(890),$={};$.styleTagTransform=F(),$.setAttributes=L(),$.insert=M().bind(null,"head"),$.domAPI=_(),$.insertStyleElement=R(),S()(B.A,$),B.A&&B.A.locals&&B.A.locals;var k=n(2003);class H{get selected(){return this._selected}set selected(t){this._selected=t,this.root.style.border=t?"2px solid var(--green-2)":"2px solid var(--grey-2)"}constructor(t,e){this.monomer=t,this.monomerSymbol=e,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 t=this.monomer.smiles&&o.chem.checkSmiles(this.monomer.smiles)?o.chem.drawMolecule(this.monomer.smiles,150,120):o.chem.drawMolecule(this.monomer.molfile??"",150,120);this.root.appendChild(t);const e=i.divH([i.divText("Monomer Name: "),i.divText(this.monomer.name)],{classes:"monomer-card-info-rules"});if(this.root.appendChild(e),i.tooltip.bind(e,this.monomer.name),this.monomer.lib?.source){const t=i.divH([i.divText("Source: "),i.divText(this.monomer.lib.source)],{classes:"monomer-card-info-rules"});this.root.appendChild(t),i.tooltip.bind(t,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(t,e,n,r,o){this.firstMonomers=t,this.secondMonomers=e,this.code=r,this.rules=o,this.root=i.divH([],{style:{width:"100%",overflow:"hidden",visibility:"visible"},classes:"monomer-cards"});const s=!t?.length,a=!e?.length;s&&(this.firstMonomers=t=["C","D","E","F","G"]),a&&(this.secondMonomers=e=["D","C","E","F","G"]),this.actionable=!0;const l=i.divH([],{style:{overflowX:"auto",width:"100%"}}),u=i.divH([],{style:{overflowX:"auto",width:"100%"}});this.resulting=i.divH([],{style:{overflowX:"auto",width:"100%",minHeight:"150px"}});const c=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([c,l,h,u,this.resulting]);this.cardsFirst=t.map((t=>new H(n.getMonomer("PEPTIDE",t),t))),this.cardsSecond=e.map((t=>new H(n.getMonomer("PEPTIDE",t),t))),this.cardsFirst.forEach((t=>{t.root.onclick=()=>{this.cardsFirst.forEach((t=>t.selected=!1)),t.selected=!0,this.firstCard=t,this.reset()},l.appendChild(t.root)})),this.cardsSecond.forEach((t=>{t.root.onclick=()=>{this.cardsSecond.forEach((t=>t.selected=!1)),t.selected=!0,this.secondCard=t,this.reset()},u.appendChild(t.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 t=[`${this.firstCard.monomer?.symbol}(${this.code})-A-A-A-A-${this.secondCard.monomer?.symbol}(${this.code})`],e=await(0,h.b2)(),[n,s,a]=(0,d.b)(t,this.rules,e),l=r.Column.fromType(r.COLUMN_TYPE.STRING,"helm",n.length).init((t=>n[t]));l.semType=r.SEMTYPE.MACROMOLECULE,l.meta.units=k.Hi.HELM,l.setTag(r.TAGS.CELL_RENDERER,"helm");const u=await(0,g.j)(),c=await(0,y.Q)(),f=await(0,p.A)(this.rules),b=l.temp;l.temp=b;const v=(await(0,m.m)(l,n,s,!0,!1,!1,f,u,c)).get(0),C=v&&o.chem.checkSmiles(v)?o.chem.drawMolecule(v,200,200):o.chem.drawMolecule(v??"",200,200);v&&(C.style.cursor="pointer",C.onclick=()=>{const t=window.innerWidth-200,e=window.innerHeight-200,n=o.chem.checkSmiles(v)?o.chem.drawMolecule(v,t,e):o.chem.drawMolecule(v??"",t,e);i.dialog({title:"Molecule"}).add(n).showModal(!0)},i.tooltip.bind(C,"Click to expand"));const w=i.divV([i.h2("Example Result:"),i.h2(t[0])],{style:{width:"200px"}});i.empty(this.resulting),this.resulting.append(i.divH([w,C],{style:{overflowX:"auto",width:"100%",minHeight:"150px"}}))}}render(){this.actionable&&(this.cardsFirst.forEach((t=>t.render())),this.cardsSecond.forEach((t=>t.render())))}}var U=n(4971);const V="System:AppData/SequenceTranslator/polytool-rules/",q="Polytool",j="code",W="firstMonomers",z="secondMonomers",Y="name",K="firstLinkingGroup",J="secondLinkingGroup";class Q extends u{constructor(t,e,n,r){super(t,e,n,r)}createInput(t,e){const n=super.createInput(t,e),o=i.icons.edit((async()=>{const e=await E.getInstance(t);r.Dialog.getOpenDialogs()?.filter((t=>t.root.contains(o))).forEach((t=>t.close())),await e.getAndAddView()}),"Edit rules");return n.addOptions(o),n}async getForm(){const t=await super.getForm();return this.processRulesForm(t),t}async processRulesForm(t){const e=Array.from(t.getElementsByTagName("label")??[]).filter((t=>t.textContent?.endsWith(".json")&&null!=t.parentElement));for(const t of e){const e=t.textContent.trim(),n=t.parentElement.getElementsByTagName("input")[0];i.tooltip.bind(n,i.wait((async()=>{var t;return(t=Q.ruleDescriptions)[e]??(t[e]=(async()=>{try{const t=JSON.parse(await o.dapi.files.readAsText(`${V}/${e}`)),n=i.divV([i.h1(e)]),r=t.linkRules??[];if(r.length>0){n.appendChild(i.h3("Linkage Rules"));const t=i.table(r,(t=>[t.code?.toString()??"",X((t.firstMonomers??[]).join(", ")),X((t.secondMonomers??[]).join(", ")),t.firstLinkingGroup?.toString()??"",t.secondLinkingGroup?.toString()??""]),["Code","M1","M2","L1","L2"]);n.appendChild(t)}const s=t.reactionRules??[];if(s.length>0){n.appendChild(i.h3("Synthesis Rules"));const t=i.table(s,(t=>[t.code?.toString()??"",X((t.firstMonomers??[]).join(", ")),X((t.secondMonomers??[]).join(", ")),X(t.name??""),o.chem.drawMolecule(t.reaction?.split(">>")[1]??"",70,70)]),["Code","M1","M2","Name","Product"]);n.appendChild(t)}return n}catch(t){return c._package.logger.error(`Failed to load rule ${e}: ${t?.toString?.()}`),console.error(t),i.divText(`Failed to load rule ${e}`)}})()),await Q.ruleDescriptions[e]})))}}}function X(t,e=30){return t.length<=e?t:`${t.substring(0,e)}...`}Q.ruleDescriptions={};class Z{constructor(t,e,n,r){this.homodimerCode=t,this.heterodimerCode=e,this.linkRules=n,this.reactionRules=r}set homodimer(t){this.homodimerCode=t}set heterodimer(t){this.heterodimerCode=t}addLinkRules(t){for(let e=0;e<t.length;e++)this.linkRules.push(t[e])}addSynthesisRules(t){for(let e=0;e<t.length;e++)this.reactionRules.push(t[e])}getLinkRulesDf(){const t=this.linkRules.length,e=r.Column.int(j,t);e.setTag("friendlyName","Code");const n=r.Column.string(W,t);n.temp[".mm.cellRenderer.fontSize"]=16,n.setTag("friendlyName","First monomers"),n.semType=r.SEMTYPE.MACROMOLECULE,c.PackageFunctions.applyNotationProviderForCyclized(n,",");const o=r.Column.string(z,t);o.setTag("friendlyName","Second monomers"),o.temp[".mm.cellRenderer.fontSize"]=16,o.semType=r.SEMTYPE.MACROMOLECULE,c.PackageFunctions.applyNotationProviderForCyclized(o,",");const i=r.Column.int(K,t);i.setTag("friendlyName","First group");const s=r.Column.int(J,t);s.setTag("friendlyName","Second group");for(let r=0;r<t;r++)e.set(r,this.linkRules[r].code),n.set(r,this.linkRules[r].firstMonomers.toString()),o.set(r,this.linkRules[r].secondMonomers.toString()),i.set(r,this.linkRules[r].firstLinkingGroup),s.set(r,this.linkRules[r].secondLinkingGroup);const a=r.DataFrame.fromColumns([e,n,o,i,s]);return{res:a,addNewRow:t=>{if(null!=t.row&&t.row<a.rowCount&&t.row>=0)e.set(t.row,t.code),n.set(t.row,t.firstMonomers),o.set(t.row,t.secondMonomers),i.set(t.row,t.firstLinkingGroup),s.set(t.row,t.secondLinkingGroup);else{const{code:e,firstMonomers:n,secondMonomers:r,firstLinkingGroup:o,secondLinkingGroup:i}=t;a.rows.addNew([e,n??"",r??"",o??1,i??2])}}}}async getLinkCards(){const t=this.linkRules.length,e=new Array(t),n=(await(0,U.pj)()).getMonomerLib();for(let r=0;r<t;r++)e[r]=new G(this.linkRules[r].firstMonomers,this.linkRules[r].secondMonomers,n,this.linkRules[r].code,this);return e}getSynthesisRulesDf(){const t=this.reactionRules.length,e=r.Column.int(j,t);e.setTag("friendlyName","Code");const n=r.Column.string(W,t);n.setTag("friendlyName","First monomers");const o=r.Column.string(z,t);o.setTag("friendlyName","Second monomers"),n.semType=r.SEMTYPE.MACROMOLECULE,n.temp[".mm.cellRenderer.fontSize"]=16,c.PackageFunctions.applyNotationProviderForCyclized(n,","),o.semType=r.SEMTYPE.MACROMOLECULE,o.temp[".mm.cellRenderer.fontSize"]=16,c.PackageFunctions.applyNotationProviderForCyclized(o,","),o.setTag(r.TAGS.CELL_RENDERER,"Sequence"),n.setTag(r.TAGS.CELL_RENDERER,"Sequence");const i=r.Column.string(Y,t);i.setTag("friendlyName","Name");const s=r.Column.string("firstReactant",t);s.setTag("friendlyName","First reactant");const a=r.Column.string("secondReactant",t);a.setTag("friendlyName","Second reactant");const l=r.Column.string("product",t);l.setTag("friendlyName","Product");for(let r=0;r<t;r++){e.set(r,this.reactionRules[r].code),n.set(r,this.reactionRules[r].firstMonomers.toString()),o.set(r,this.reactionRules[r].secondMonomers.toString()),i.set(r,this.reactionRules[r].name);const t=this.reactionRules[r].reaction.split(">>"),u=t[0].split(".");s.set(r,u[0]),a.set(r,u[1]),l.set(r,t[1])}s.semType=r.SEMTYPE.MOLECULE,a.semType=r.SEMTYPE.MOLECULE,l.semType=r.SEMTYPE.MOLECULE;const u=r.DataFrame.fromColumns([i,s,a,l,e,n,o]);return{df:u,addNewRow:t=>{if(null!=t.rowIndex&&t.rowIndex<u.rowCount&&t.rowIndex>=0)i.set(t.rowIndex,t.resultMonomerName),e.set(t.rowIndex,t.code),n.set(t.rowIndex,t.firstMonomers.join(",")),o.set(t.rowIndex,t.secondMonomers.join(",")),s.set(t.rowIndex,t.firstReactantSmiles),a.set(t.rowIndex,t.secondReactantSmiles),l.set(t.rowIndex,t.productSmiles);else{const{resultMonomerName:e,code:n,firstMonomers:r,secondMonomers:o,firstReactantSmiles:i,secondReactantSmiles:s,productSmiles:a}=t;u.rows.addNew([e,i,s,a,n,r.join(","),o.join(",")])}}}}setLinkRules(t){const e=t.rowCount,n=new Array(e),r=t.columns.byName(j),o=t.columns.byName(W),i=t.columns.byName(z),s=t.columns.byName(K),a=t.columns.byName(J);for(let t=0;t<e;t++){const e=o.get(t).split(","),l=i.get(t).split(","),u={code:r.get(t),firstMonomers:""!==e[0]?e:[],secondMonomers:""!==l[0]?l:[],firstLinkingGroup:s.get(t),secondLinkingGroup:a.get(t)};n[t]=u}this.linkRules=n}setSynthesisRules(t){const e=t.rowCount,n=new Array(e),r=t.columns.byName(j),o=t.columns.byName(W),i=t.columns.byName(z),s=t.columns.byName(Y),a=t.columns.byName("firstReactant"),l=t.columns.byName("secondReactant"),u=t.columns.byName("product");for(let t=0;t<e;t++){const e=`${a.get(t)}.${l.get(t)}>>${u.get(t)}`,c=o.get(t).split(","),h=i.get(t).split(","),d={code:r.get(t),firstMonomers:""!==c[0]?c:[],secondMonomers:""!==h[0]?h:[],reaction:e,name:s.get(t)};n[t]=d}this.reactionRules=n}}async function tt(t){const e=new r.FileSource(V),n=new Z(null,null,[],[]);for(let r=0;r<t.length;r++){const o=await e.readAsText(t[r].replace(V,"")),i=JSON.parse(o);n.homodimer=i.homodimerCode,n.heterodimer=i.heterodimerCode,n.addLinkRules(i.linkRules),n.addSynthesisRules(i.reactionRules)}return n}function et(t){const e=t.firstMonomers.length*t.secondMonomers.length,n=new Array(e),r=new Array(e);let o=0;for(let e=0;e<t.firstMonomers.length;e++)for(let i=0;i<t.secondMonomers.length;i++)n[o]=t.firstMonomers[e],r[o]=t.secondMonomers[i],o++;return[n,r]}},5174:(t,e,n)=>{"use strict";n.d(e,{A:()=>c,T:()=>h});var r=n(6717),o=n(1296),i=n(9192),s=n(4328),a=n(1991),l=n.n(a),u=n(4971);async function c(t){const e=(await(0,u.pj)()).getMonomerLib(),n=await(0,r.j)(),o={};let i=[],a=[];for(let r=0;r<t.reactionRules.length;r++)try{[i,a]=h(n,e,t.reactionRules[r])}catch(t){i=[],a=[],console.error(t),s.shell.warning(t)}finally{for(let t=0;t<i.length;t++)null!=i[t]&&null!=a[t]&&(o[i[t]]=a[t])}const c={PEPTIDE:o};return e.override(c,"ST-PT-reactions."+l().repeat(1).map((()=>Math.floor(36*Math.random()).toString(36))).take(4).toArray().join(""))}function h(t,e,n){const r=n.reaction,o=n.name,s=n.firstMonomers.length+n.secondMonomers.length+1,a=n.reaction.split(">>"),l=a[0].split("."),u=new Array(s),c=new Array(s),h=new Array(s),m=f(t,r),g=`${l[0]}>>[C:1]C`,y=`${l[1]}>>[C:2]C`,b=f(t,g),v=f(t,y);let C=0;for(let r=0;r<n.firstMonomers.length;r++){const i=e.getMonomer("PEPTIDE",n.firstMonomers[r]);if(i){const e=d(t,i.molfile,b,i.name);h[C]=e,u[C]=`${i.symbol}_${o}`}C++}for(let r=0;r<n.secondMonomers.length;r++){const i=e.getMonomer("PEPTIDE",n.secondMonomers[r]);if(i){const e=d(t,i.molfile,v,i.name);h[C]=e,u[C]=`${i.symbol}_${o}`}C++}let w=null;a[1]=a[1].replace("[C:1]","[1*]").replace("[C:2]","[2*]").replace("[C:3]","[3*]");let A="";try{w=t.get_mol(a[1]),A=w?.get_molblock()}catch(t){const[e,n]=(0,i.AP)(t);throw console.error(`Can not assemble monomer '${o}': ${e}.`),t}finally{w?.delete()}h[C]=A,u[C]=o;for(let t=0;t<s-1;t++)h[t]&&(h[t]=h[t].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(t){const e=t.replace("M RAD","M RGP").replace("M ISO","M RGP").split("\n"),n=e.findIndex((t=>t.startsWith("M RGP"))),r=Number(e[n].substring(9,13)),o=Number(e[n].substring(17,21)),i=Number(e[n].substring(13,17)),s=Number(e[n].substring(21,25));e[n]=e[n].substring(0,13)+` ${i}`+e[n].substring(17,21)+` ${s}`,e[3+r]=e[3+r].substring(0,30)+" R# 0 0 0 0 0 0 0 0 0 0 0 0",e[3+o]=e[3+o].substring(0,30)+" R# 0 0 0 0 0 0 0 0 0 0 0 0";let a="";for(let t=0;t<e.length;t++)a+=e[t]+"\n";return a}(h[s-1]);for(let t=0;t<s;t++){const e=t==s-1;if(!h[t]||!u[t])continue;const n={symbol:u[t],name:u[t],molfile:h[t],author:"",id:0,rgroups:p(e),smiles:"",polymerType:"PEPTIDE",monomerType:"Backbone",createDate:null};n.meta=Object.assign(n.meta??{},{colors:{default:{line:"#2083D5",text:"#2083D5",background:"#F2F2F5"}}}),u[t]=u[t],c[t]=n}return m.delete(),b.delete(),v.delete(),[u,c]}function d(t,e,n,r){let o=null,s=null,a=null,l=null,u="";try{o=new t.MolList,s=t.get_mol(e),o.append(s),a=n.run_reactants(o,1),l=a.get(0).next(),u=l?.get_molblock()}catch(t){const[e,n]=(0,i.AP)(t);throw console.error(`Can not assemble monomer '${r}': ${e}.`),t}finally{o?.delete(),s?.delete(),a?.delete(),l?.delete()}return u}function f(t,e){let n=null;try{if(n=t.get_rxn(e),!n)throw new o.J5(e)}catch(t){n?.delete();const[r,o]=(0,i.AP)(t);throw console.error(`Can not assemble monomer '${e}': ${r}.`),t}return n}function p(t){if(t){const t=new Array(2),e={capGroupSMILES:"[*:1][H]",alternateId:"R1-H",capGroupName:"H",label:"R1"},n={capGroupSMILES:"[*:2][H]",alternateId:"R2-H",capGroupName:"H",label:"R2"};return t[0]=e,t[1]=n,t}return[{capGroupSMILES:"[*:3][H]",alternateId:"R3-H",capGroupName:"H",label:"R3"}]}},3820:(t,e,n)=>{"use strict";n.d(e,{d:()=>o,o:()=>s});var r=n(1296);const o="PEPTIDE1{R.[Aca].T.G.H.F.G.A.A.Y.P.E.[meI]}$$$$";function i(t,e,n,r){const o=new Array(r.length*(n-e+1));for(let i=0;i<r.length;++i){const s=n-e+1;for(let n=0;n<s;++n){const a=e+n,l=r[i],u=o[i*s+n]=t.clone(),c=u.atoms[a].elem;u.atoms[a].elem=l;const h=c?.length>1?`[${c}]`:c,d=l?.length>1?`[${l}]`:l;u.name=`${t.name}-${h}${a+1}${d}`}}return o}function s(t,e,n){const o=new JSDraw2.MolHandler,s=new org.helm.webeditor.Plugin(o);org.helm.webeditor.IO.parseHelm(s,t,new JSDraw2.Point(0,0),void 0);const a=o.m;a.name=e;let l=[];if(n.placeholders)switch(n.type){case r.aK.Single:l=function(t,e){return e.map((e=>i(t,e.position,e.position,e.monomers))).reduce(((t,e)=>t.concat(e)),[])}(o.m,n.placeholders);break;case r.aK.Matrix:l=function(t,e){let n=[t];for(const t of e){const e=n.map((e=>i(e,t.position,t.position,t.monomers)));n=e.reduce(((t,e)=>t.concat(e)),[])}return n}(o.m,n.placeholders)}let u=[];n.breadthPlaceholders&&(u=function(t,e){if(0==e.length)return[];let n=[t];for(const t of e){const e=n.map((e=>i(e,t.start,t.end,t.monomers)));n=e.reduce(((t,e)=>t.concat(e)),[])}return n}(o.m,n.breadthPlaceholders)),l=l.concat(u),n.keepOriginal&&(l=[a,...l]);const c=l.map((t=>[org.helm.webeditor.IO.getHelm(t),t.name]));return c}},1296:(t,e,n)=>{"use strict";var r;n.d(e,{J5:()=>o,aK:()=>r}),function(t){t.Single="single",t.Matrix="matrix",t.Library="library"}(r||(r={})),Error;class o extends Error{constructor(t,e){super(`Invalid reaction '${t}'.`),this.type="InvalidReactionError"}}},6082:t=>{"use strict";t.exports=DG},4328:t=>{"use strict";t.exports=grok},7389:t=>{"use strict";t.exports=ui},1991:t=>{"use strict";t.exports=wu}},e={};function n(r){var o=e[r];if(void 0!==o)return o.exports;var i=e[r]={id:r,loaded:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.loaded=!0,i.exports}n.m=t,n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.u=t=>t+".js",n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.nmd=t=>(t.paths=[],t.children||(t.children=[]),t),(()=>{var t;n.g.importScripts&&(t=n.g.location+"");var e=n.g.document;if(!t&&e&&(e.currentScript&&"SCRIPT"===e.currentScript.tagName.toUpperCase()&&(t=e.currentScript.src),!t)){var r=e.getElementsByTagName("script");if(r.length)for(var o=r.length-1;o>-1&&(!t||!/^http(s?):/.test(t));)t=r[o--].src}if(!t)throw new Error("Automatic publicPath is not supported in this browser");t=t.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),n.p=t})(),n.b=document.baseURI||self.location.href,n.nc=void 0;var r={};(()=>{"use strict";n.r(r),n.d(r,{_package:()=>D,initAutoTests:()=>B,test:()=>F,tests:()=>e.CN});var t=n(6082),e=n(8070),o=n(4328),i=n(6686);class s extends t.Package{async getTranslationHelper(){return await o.functions.call(`${this.name}:getTranslationHelper`)}}function a(t,e,n){return n.createFormatConverter(t,e).convertTo(i.NO.HELM)}function l(t,e,n){return n.createFormatConverter(t,i.NO.HELM).convertTo(e)}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)}$$$$"}},c={"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"};(0,e.L1)("Formats to HELM",(()=>{let t;(0,e.gM)((async()=>{t=await D.getTranslationHelper()}));for(const n of Object.keys(u))for(const[r,o]of Object.entries(u[n]))(0,e.t6)(`${n} to HELM`,(async()=>{const i=o,s=a(r,n,t);(0,e.E3)(s,i)}))})),(0,e.L1)("HELM to Formats",(()=>{let t;(0,e.gM)((async()=>{t=await D.getTranslationHelper()}));for(const n of Object.keys(u))for(const[r,o]of Object.entries(u[n]))(0,e.t6)(`${n} to HELM`,(async()=>{const i=r,s=l(o,n,t);(0,e.E3)(s,i)}))}));var h=n(3480);(0,e.L1)("HELM to Nucleotides",(()=>{let t;(0,e.gM)((async()=>{t=await D.getTranslationHelper()})),Object.entries(c).forEach((([n,r],o)=>{(0,e.t6)(`Sequence ${o+1} to nucleotides`,(async()=>{const o=r,i=(0,h.Hs)(n,t.monomerLibWrapper);(0,e.E3)(i,o)}))}))}));const d={[i.NO.AXOLABS]:"Afcgacsu",[i.NO.HELM]:"RNA1{[fR](A)p.[25r](C)p.[25r](G)p.[25r](A)p.[25r](C)[sp].[25r](U)}$$$$"};(0,e.L1)("Formats support",(()=>{let t;(0,e.gM)((async()=>{t=await D.getTranslationHelper()})),Object.entries(d).forEach((([n,r])=>{(0,e.t6)(`All formats for ${n}`,(async()=>{const o=function(t,e,n){const r=n.createSequenceValidator(t).getInvalidCodeIndex(e);return(0,h.bD)(t,r,e,n)}(r,n,t),i=Object.keys(o).length,s=Object.keys(u).length+1;(0,e.E3)(!0,s<=i)}))}))}));var f=n(9192);(0,e.L1)("files",(()=>{let n;(0,e.gM)((async()=>{n=await D.getTranslationHelper()})),(0,e.t6)("list",(async()=>{let r;const o=t.DataFrame.fromColumns([t.Column.string("subTest"),r=t.Column.bool("success"),t.Column.string("format"),t.Column.string("src"),t.Column.string("res"),t.Column.string("tgt"),t.Column.string("error"),t.Column.string("stack")]),i=await D.files.list("tests",!0,".csv");for(const r of i){const i=t.DataFrame.fromCsv(await r.readAsString()),s=i.columns.byIndex(0),l=s.name,u=i.columns.byIndex(1),c=i.rowCount;for(let t=0;t<c;++t){const i=o.rows.addNew();i.subTest=`${r.name}, row: ${t}`;try{const r=s.get(t),o=u.get(t);i.format=l,i.src=r,i.tgt=o;const c=i.res=a(r,l,n);(0,e.E3)(c,o),i.success=!0}catch(t){const[e,n]=(0,f.AP)(t);i.error=e,i.stack=n,i.success=!1}}}0==o.rowCount&&o.rows.addNew(["empty",!0,"",""]);const s=r.toList().findIndex((t=>1!=t));if(-1!=s){const t=o.rows.get(s);throw new Error(`Subtest '${t.subTest}' failed: ${t.error}`)}return o}),{skipReason:"Can not create test in async manner based on files in Shares."})}));var p=n(8312),m=n(2003);class g{constructor(t,e,n,r,o,i){this.units=t,this.aligned=e,this.alphabet=n,this.alphabetSize=r,this.alphabetIsMultichar=o,this.separator=i}}async function y(e,n){const r=(await e()).getCol(n),i=await o.functions.call("Bio:detectMacromolecule",{col:r});if(i&&(r.semType=i),r.semType===t.SEMTYPE.MACROMOLECULE){const t=`Negative test detected semType='${r.semType}', units='${r.meta.units}'.`;throw new Error(t)}}async function b(n,r,i,s,a,l,u,c,h=null){const d=(await n()).col(r),f=await o.functions.call("Bio:detectMacromolecule",{col:d});f&&(d.semType=f),(0,e.E3)(d.semType,t.SEMTYPE.MACROMOLECULE),(0,e.E3)(d.meta.units,s),(0,e.E3)(d.getTag(m.gp.aligned),a),(0,e.E3)(d.getTag(m.gp.alphabet),l),h&&(0,e.E3)(d.getTag(m.gp.separator),h);const p=i.getSeqHandler(d);(0,e.E3)(p.getAlphabetSize(),u),(0,e.E3)(p.getAlphabetIsMultichar(),c),p.isHelm()||((0,e.E3)(p.aligned,a),(0,e.E3)(p.alphabet,l))}(0,e.L1)("PolyTool: detectors",(()=>{let n;(0,e.gM)((async()=>{n=await(0,p.Q)()}));const r={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 g(m.Hi.CUSTOM,"SEQ",m.YI.UN,13,!0,"-")}}};for(const[o,i]of Object.entries(r))(0,e.t6)(`${o}`,(async()=>{const e=async()=>t.DataFrame.fromCsv(i.csv);for(const t of i.neg??[])await y(e,t);for(const[t,r]of Object.entries(i.pos??{}))await b(e,t,n,r.units,r.aligned,r.alphabet,r.alphabetSize,r.alphabetIsMultichar,r.separator)}),{skipReason:"3156"})}));var v=n(4971);const C="Libraries",w="Settings",A="DuplicateMonomerPreferences";let x=Promise.resolve();async function E(){let t;return x=x.then((async()=>{const e=await o.userSettings.getValue(C,w,!0);t=e?JSON.parse(e):{exclude:[],explicit:[],duplicateMonomerPreferences:{}};const n=await o.userSettings.getValue(C,A,!0),r=n?JSON.parse(n):{};t.exclude=t.exclude instanceof Array?t.exclude:[],t.explicit=t.explicit instanceof Array?t.explicit:[],t.duplicateMonomerPreferences=t.duplicateMonomerPreferences instanceof Object?t.duplicateMonomerPreferences:{};for(const e in r){t.duplicateMonomerPreferences[e]=t.duplicateMonomerPreferences[e]??{};for(const n in r[e])for(const o of r[e][n])t.duplicateMonomerPreferences[e][o]=n}console.debug(`Bio: getUserLibSettings()\n${JSON.stringify(t,void 0,2)}`)})),await x,t}async function T(t){x=x.then((async()=>{t.duplicateMonomerPreferences=t.duplicateMonomerPreferences??{},console.debug(`Bio: setUserLibSettings()\n${JSON.stringify(t,void 0,2)}`);const e={};for(const n in t.duplicateMonomerPreferences){e[n]={};for(const r in t.duplicateMonomerPreferences[n]){const o=t.duplicateMonomerPreferences[n][r];e[n][o]=e[n][o]??[],e[n][o].push(r)}}await o.userSettings.add(C,A,JSON.stringify(e),!0),t.duplicateMonomerPreferences={},await o.userSettings.add(C,w,JSON.stringify(t),!0)})),await x}var S=n(6717),I=n(9124),_=n(4229),N=n(5174),M=n(6694);(0,e.L1)("PolyTool: Convert",(()=>{let n,r,i,s,a;(0,e.gM)((async()=>{i=await(0,S.j)(),n=await(0,I.b2)(),r=await(0,p.Q)(),s=await(0,v.pj)(),a=await E(),await s.loadMonomerLibForTests()})),(0,e.Pl)((async()=>{await T(a),await s.loadMonomerLib(!0)}));const l={"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[t,r]of Object.entries(l))(0,e.t6)(`toHelm-${t}`,(async()=>{const t=await(0,M.Q4)(["rules_example.json"]),o=(0,_.b)([r.src.seq],t,n);(0,e.E3)(o[0][0],r.tgt.helm)}));for(const[o,s]of Object.entries(l))(0,e.t6)(`toAtomicLevel-${o}`,(async()=>{const o=await(0,M.Q4)(["rules_example.json"]),[a,l,u]=(0,_.b)([s.src.seq],o,n),c=await(0,N.A)(o),h=t.Column.fromStrings("helm",a);h.semType=t.SEMTYPE.MACROMOLECULE,h.meta.units=m.Hi.HELM;const d=await r.helmToAtomicLevel(h,!1,!1,c);if(d.warnings&&d.warnings.length>0)throw new Error(d.warnings[0]);(0,e.E3)(null!=d.molCol,!0,".molCol is not null");const f=d.molCol.get(0),p=i.get_mol(f);try{const t={atomCount:p.get_num_atoms(),bondCount:p.get_num_bonds(),inchiKey:i.get_inchikey_for_inchi(p.get_inchi())};(0,e.Xk)(t,s.tgt.mol)}finally{p.delete()}}));(0,e.t6)("ui-col-wo-table",(async()=>{const n=D.name,r=Object.values(l).map((t=>t.src.seq)),i=Object.values(l).map((t=>t.tgt.helm)),s=t.Column.fromStrings("seq",r),a=await o.functions.call(`${n}:polyToolConvert2`,{seqCol:s,generateHelm:!0,chiralityEngine:!0,rules:["rules_example.json"]});(0,e.J6)(a.toList(),i),(0,e.E3)(a.semType,t.SEMTYPE.MACROMOLECULE),(0,e.E3)(a.meta.units,m.Hi.HELM),(0,e.E3)(a.dataFrame,null)})),(0,e.t6)("ui-col",(async()=>{const n=D.name,r=Object.values(l).map((t=>t.src.seq)),i=Object.values(l).map((t=>t.tgt.helm)),s=t.Column.fromStrings("seq",r),a=t.DataFrame.fromColumns([s]),u=o.shell.addTableView(a),c=await o.functions.call(`${n}:polyToolConvert2`,{seqCol:s,generateHelm:!0,chiralityEngine:!0,rules:["rules_example.json"]});(0,e.J6)(c.toList(),i),(0,e.E3)(c.semType,t.SEMTYPE.MACROMOLECULE),(0,e.E3)(c.meta.units,m.Hi.HELM),(0,e.E3)(c.dataFrame.id,a.id),await(0,e.PE)(u.grid.onAfterDrawContent,(()=>{}),(async()=>{u.grid.invalidate()}),15e3),(0,e.E3)(c.getTag(t.TAGS.CELL_RENDERER),"helm")}))}));var P=n(1296),L=n(3820);(0,e.L1)("PolyTool: Enumerate",(()=>{let t,n,r;(0,e.gM)((async()=>{t=await(0,I.b2)(),n=await(0,v.pj)(),r=await E(),await n.loadMonomerLibForTests()})),(0,e.Pl)((async()=>{await T(r),await n.loadMonomerLib(!0)}));const o={single1:{src:"PEPTIDE1{[Ac(1)].F.W.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",params:{type:P.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:P.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"}]},matrix1:{src:"PEPTIDE1{[Ac(1)].F.W.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",params:{type:P.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[t,n]of Object.entries(o))(0,e.t6)(`${t}`,(async()=>{const t=(0,L.o)(n.src,"",n.params);(0,e.J6)(t,n.tgt.map((t=>[t.seq,t.name])))}))})),(0,e.L1)("PolyTool: Enumerate",(()=>{let t,n,r;(0,e.gM)((async()=>{t=await(0,I.b2)(),n=await(0,v.pj)(),r=await E(),await n.loadMonomerLibForTests()})),(0,e.Pl)((async()=>{await T(r),await n.loadMonomerLib(!0)}));const o={breadth1:{src:"PEPTIDE1{[Ac(1)].F.W.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0",params:{type:P.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:P.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:P.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:P.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[t,n]of Object.entries(o))(0,e.t6)(`${t}`,(async()=>{const t=(0,L.o)(n.src,"",n.params);(0,e.J6)(t,n.tgt.map((t=>[t.seq,t.name])))}))}));var O=n(6307),R=n(2125);(0,e.L1)("PolyTool: Chain: parseNotation",(()=>{let t;(0,e.gM)((async()=>{t=await(0,I.b2)()}));const n={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[r,o]of Object.entries(n))(0,e.t6)(`${r}`,(async()=>{await(0,M.Q4)(["rules_example.json"]);const n=await O.s.fromSeparator(o.src.seq,t),r=n.mol,i=t.createHelmWebEditor();i.editor.setMol(r);const s=i.editor.getHelm(),a=n.getHelm();(0,e.E3)(s,o.tgt.helm),(0,e.E3)(a,o.tgt.helm)}),"reaction2"==r?{skipReason:"reverse reaction"}:void 0);const r={"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[t,{inIdx:n,spIdx:o,outIdx:i,monomers:s}]of Object.entries(r))(0,e.t6)(`innerIdx-${t}`,(async()=>{const[t,r]=(0,R.M)(i,s);(0,e.E3)(t,n),(0,e.E3)(r,o)}));for(const[t,{inIdx:n,spIdx:o,outIdx:i,monomers:s}]of Object.entries(r))(0,e.t6)(`outerIdx-${t}`,(async()=>{const t=(0,R.j)(n,o,s);(0,e.E3)(t,i)}))})),(0,e.L1)("PolyTool: Chain",(()=>{let t;(0,e.gM)((async()=>{t=await(0,I.b2)()}));const n={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[r,{data:o,tgt:i}]of Object.entries(n))(0,e.t6)(`fromNotation-${r}`,(async()=>{const n=await(0,M.Q4)(["rules_example.json"]),r=O.s.fromSeparator(o.templateSeq,t);r.applyRules(n),r.check(!0),(0,e.J6)(r.monomers.map((t=>t.length)),i.mmChain.monomerCount),(0,e.E3)(r.linkages.length,i.mmChain.linkageCount),(0,e.E3)(r.getHelm(),o.mmHelm)}),{skipReason:"3157"});for(const[r,{data:o,tgt:i}]of Object.entries(n))(0,e.t6)(`parseNotation-${r}`,(async()=>{await(0,M.Q4)(["rules_example.json"]);const n=O.s.fromSeparator(o.templateSeq,t);n.check(!0),(0,e.J6)(n.monomers.map((t=>t.length)),i.templateChain.monomerCount),(0,e.E3)(n.linkages.length,i.templateChain.linkageCount),(0,e.E3)(n.getHelm(),o.templateHelm),(0,e.E3)(n.getNotation(),o.templateSeq)}));for(const[r,{data:o,tgt:i}]of Object.entries(n))(0,e.t6)(`parseHelm-${r}`,(async()=>{await(0,M.Q4)(["rules_example.json"]);const n=O.s.fromHelm(o.templateHelm,t);n.check(!0),(0,e.J6)(n.monomers.map((t=>t.length)),i.templateChain.monomerCount),(0,e.E3)(n.linkages.length,i.templateChain.linkageCount),(0,e.E3)(n.getHelm(),o.templateHelm),(0,e.E3)(n.getNotation(),o.templateSeq)}));for(const[r,{data:o,tgt:i}]of Object.entries(n))(0,e.t6)(`applyRules-${r}`,(async()=>{const n=await(0,M.Q4)(["rules_example.json"]),r=O.s.fromSeparator(o.templateSeq,t);r.applyRules(n),r.check(!0),(0,e.J6)(r.monomers.map((t=>t.length)),i.mmChain.monomerCount),(0,e.E3)(r.linkages.length,i.mmChain.linkageCount),(0,e.E3)(r.getHelm(),o.mmHelm)}),{skipReason:"applyRules is not implemented"})})),(0,e.L1)("toAtomicLevel",(()=>{let n,r,o;(0,e.gM)((async()=>{r=await(0,v.pj)(),n=await E(),o=await(0,S.j)(),await r.loadMonomerLibForTests()})),(0,e.Pl)((async()=>{await T(n),await r.loadMonomerLib(!0)})),(0,e.t6)("override",(async()=>{const n=r.getMonomerLib(),i=await D.files.readAsText("tests/polytool-reaction-lib.json"),s=JSON.parse(i).find((t=>"GGaz"===t.symbol));(0,e.E3)(null!=s,!0,"Monomer 'GGaz' not found.");const a={PEPTIDE:{GGaz:s}},l=n.override(a,"test"),u=await(0,p.Q)(),c=t.Column.fromList(t.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=t.SEMTYPE.MACROMOLECULE,c.meta.units=m.Hi.HELM;const h=await u.helmToAtomicLevel(c,!1,!1,l);(0,e.E3)(null!=h.molCol,!0,"Result molCol is null");const d=h.molCol.get(0);(0,e.E3)(!!d,!0,"Molfile is empty");const f=o.get_mol(d);try{const t=f.get_inchi(),n=o.get_inchikey_for_inchi(t);(0,e.E3)(f.get_num_bonds(),103),(0,e.E3)(f.get_num_atoms(),98),(0,e.E3)(n,"XPQUTLNSNIMERR-WKBTUBAPSA-N")}finally{f.delete()}})),(0,e.t6)("getNewMonomer",(async()=>{const t=await(0,S.j)(),n=r.getMonomerLib(),o=(await(0,M.Q4)(["rules_example.json"])).reactionRules.find((t=>"GGaz"==t.name)),[i,s]=(0,N.T)(t,n,o);(0,e.E3)(i?.[0],"azG_GGaz");const a=t.get_mol(s[0].molfile);try{const n=a.get_inchi();t.get_inchikey_for_inchi(n),(0,e.E3)(a.get_num_bonds(),7),(0,e.E3)(a.get_num_atoms(),8)}finally{a.delete()}}))}));const D=new s;async function F(n,r,o){const i=await(0,e.N$)({category:n,test:r,testContext:o,verbose:!0});return t.DataFrame.fromObjects(i)}async function B(){await(0,e.Xb)(D,D.getModule("package-test.js"))}})(),sequencetranslator_test=r})();
|
|
3
3
|
//# sourceMappingURL=package-test.js.map
|